Merge branch 'glsl-to-tgsi'
authorBryan Cain <bryancain3@gmail.com>
Thu, 4 Aug 2011 20:43:34 +0000 (15:43 -0500)
committerBryan Cain <bryancain3@gmail.com>
Thu, 4 Aug 2011 20:43:34 +0000 (15:43 -0500)
Conflicts:
src/mesa/state_tracker/st_atom_pixeltransfer.c
src/mesa/state_tracker/st_program.c

1052 files changed:
.gitignore
Makefile
SConstruct
common.py
configs/aix
configs/aix-64
configs/aix-64-static
configs/aix-gcc
configs/aix-static
configs/autoconf.in
configs/beos
configs/darwin
configs/default
configs/freebsd
configs/freebsd-dri
configs/hpux10-gcc
configs/hpux10-static
configs/hpux11-32
configs/hpux11-32-static
configs/hpux11-32-static-nothreads
configs/hpux11-64
configs/hpux11-64-static
configs/hpux11-ia64
configs/hpux11-ia64-static
configs/irix6-64-static
configs/irix6-n32-static
configs/irix6-o32-static
configs/linux
configs/linux-alpha
configs/linux-alpha-static
configs/linux-cell
configs/linux-dri
configs/linux-dri-xcb
configs/linux-fbdev
configs/linux-ia64-icc
configs/linux-ia64-icc-static
configs/linux-icc
configs/linux-icc-static
configs/linux-indirect
configs/linux-llvm
configs/linux-osmesa-static
configs/linux-ppc-static
configs/linux-static
configs/linux-x86-64-static
configs/linux-x86-static
configs/netbsd
configs/openbsd
configs/osf1
configs/osf1-static
configs/solaris-x86
configs/solaris-x86-gcc
configs/solaris-x86-gcc-static
configs/sunos4-gcc
configs/sunos4-static
configs/sunos5
configs/sunos5-gcc
configs/sunos5-smp
configs/sunos5-v8
configs/sunos5-v8-static
configs/sunos5-v9
configs/sunos5-v9-cc-g++
configs/sunos5-v9-static
configs/ultrix-gcc
configure.ac
docs/GL3.txt
docs/autoconf.html
docs/devinfo.html
docs/download.html
docs/egl.html
docs/faq.html
docs/license.html
docs/opengles.html
docs/openvg.html
docs/relnotes-7.11.html
docs/sourcetree.html
include/EGL/eglplatform.h
include/GL/glext.h
include/GL/glut.h [deleted file]
include/GL/glutf90.h [deleted file]
include/GL/internal/dri_interface.h
include/pci_ids/r600_pci_ids.h
scons/custom.py
scons/gallium.py
scons/llvm.py
src/SConscript
src/driclient/src/Makefile [deleted file]
src/egl/drivers/dri2/Makefile
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/egl/drivers/dri2/platform_drm.c
src/egl/drivers/dri2/platform_wayland.c
src/egl/drivers/dri2/platform_x11.c
src/egl/drivers/glx/egl_glx.c
src/egl/main/Makefile
src/egl/main/eglapi.c
src/egl/main/eglapi.h
src/egl/main/eglarray.c
src/egl/main/eglarray.h
src/egl/main/eglcompiler.h
src/egl/main/eglconfig.c
src/egl/main/eglconfig.h
src/egl/main/eglcontext.c
src/egl/main/eglcontext.h
src/egl/main/eglcurrent.c
src/egl/main/eglcurrent.h
src/egl/main/egldefines.h
src/egl/main/egldisplay.c
src/egl/main/egldisplay.h
src/egl/main/egldriver.c
src/egl/main/egldriver.h
src/egl/main/eglfallbacks.c
src/egl/main/eglglobals.c
src/egl/main/eglglobals.h
src/egl/main/eglimage.c
src/egl/main/eglimage.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.c
src/egl/main/eglmode.h
src/egl/main/eglmutex.h
src/egl/main/eglscreen.c
src/egl/main/eglscreen.h
src/egl/main/eglstring.c
src/egl/main/eglstring.h
src/egl/main/eglsurface.c
src/egl/main/eglsurface.h
src/egl/main/eglsync.c
src/egl/main/eglsync.h
src/egl/main/egltypedefs.h
src/egl/wayland/wayland-drm/protocol/wayland-drm.xml
src/egl/wayland/wayland-drm/wayland-drm.c
src/gallium/SConscript
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_aapoint.c
src/gallium/auxiliary/gallivm/f.cpp
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
src/gallium/auxiliary/gallivm/lp_bld_type.c
src/gallium/auxiliary/indices/u_unfilled_gen.py
src/gallium/auxiliary/indices/u_unfilled_indices.c
src/gallium/auxiliary/os/os_memory.h
src/gallium/auxiliary/os/os_misc.h
src/gallium/auxiliary/os/os_thread.h
src/gallium/auxiliary/os/os_time.c
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h
src/gallium/auxiliary/util/u_debug.c
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_s3tc.c
src/gallium/auxiliary/util/u_format_yuv.c
src/gallium/auxiliary/util/u_format_yuv.h
src/gallium/auxiliary/util/u_pack_color.h
src/gallium/auxiliary/util/u_pstipple.c
src/gallium/auxiliary/util/u_surface.c
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/util/u_vbuf_mgr.c
src/gallium/auxiliary/util/u_vbuf_mgr.h
src/gallium/auxiliary/util/u_video.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_compositor.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_compositor.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_csc.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_csc.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_decoder.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_decoder.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_defines.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_idct.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_idct.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_mc.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_mc.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_mpeg12_decoder.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_types.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_vertex_buffers.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_vertex_buffers.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_video_buffer.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_video_buffer.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_vlc.h [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_zscan.c [new file with mode: 0644]
src/gallium/auxiliary/vl/vl_zscan.h [new file with mode: 0644]
src/gallium/docs/source/context.rst
src/gallium/drivers/i915/Makefile
src/gallium/drivers/i915/SConscript
src/gallium/drivers/i915/TODO
src/gallium/drivers/i915/i915_batch.h
src/gallium/drivers/i915/i915_clear.c
src/gallium/drivers/i915/i915_context.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_flush.c
src/gallium/drivers/i915/i915_fpc.h
src/gallium/drivers/i915/i915_fpc_emit.c
src/gallium/drivers/i915/i915_fpc_optimize.c [new file with mode: 0644]
src/gallium/drivers/i915/i915_fpc_translate.c
src/gallium/drivers/i915/i915_prim_emit.c
src/gallium/drivers/i915/i915_prim_vbuf.c
src/gallium/drivers/i915/i915_query.c [new file with mode: 0644]
src/gallium/drivers/i915/i915_query.h [new file with mode: 0644]
src/gallium/drivers/i915/i915_resource.c
src/gallium/drivers/i915/i915_resource.h
src/gallium/drivers/i915/i915_resource_texture.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i915/i915_screen.h
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i915/i915_state_derived.c
src/gallium/drivers/i915/i915_state_emit.c
src/gallium/drivers/i915/i915_state_inlines.h
src/gallium/drivers/i915/i915_state_sampler.c
src/gallium/drivers/i915/i915_state_static.c
src/gallium/drivers/i915/i915_winsys.h
src/gallium/drivers/llvmpipe/Makefile
src/gallium/drivers/llvmpipe/SConscript
src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_test_arit.c [new file with mode: 0644]
src/gallium/drivers/nouveau/Makefile
src/gallium/drivers/nouveau/nouveau_context.h
src/gallium/drivers/nouveau/nouveau_screen.c
src/gallium/drivers/nouveau/nouveau_screen.h
src/gallium/drivers/nouveau/nouveau_video.c [new file with mode: 0644]
src/gallium/drivers/nv50/nv50_3d.xml.h
src/gallium/drivers/nv50/nv50_context.c
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_defs.xml.h
src/gallium/drivers/nv50/nv50_formats.c
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_resource.h
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_screen.h
src/gallium/drivers/nv50/nv50_shader_state.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_stateobj.h
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/nv50/nv50_texture.xml.h
src/gallium/drivers/nv50/nv50_transfer.c
src/gallium/drivers/nv50/nv50_transfer.h
src/gallium/drivers/nv50/nv50_vbo.c
src/gallium/drivers/nvc0/nvc0_3d.xml.h
src/gallium/drivers/nvc0/nvc0_context.c
src/gallium/drivers/nvc0/nvc0_context.h
src/gallium/drivers/nvc0/nvc0_formats.c
src/gallium/drivers/nvc0/nvc0_miptree.c
src/gallium/drivers/nvc0/nvc0_resource.c
src/gallium/drivers/nvc0/nvc0_resource.h
src/gallium/drivers/nvc0/nvc0_screen.c
src/gallium/drivers/nvc0/nvc0_screen.h
src/gallium/drivers/nvc0/nvc0_state.c
src/gallium/drivers/nvc0/nvc0_state_validate.c
src/gallium/drivers/nvc0/nvc0_stateobj.h
src/gallium/drivers/nvc0/nvc0_surface.c
src/gallium/drivers/nvc0/nvc0_tex.c
src/gallium/drivers/nvc0/nvc0_transfer.c
src/gallium/drivers/nvc0/nvc0_transfer.h [deleted file]
src/gallium/drivers/nvc0/nvc0_vbo.c
src/gallium/drivers/nvfx/nvfx_context.c
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/nvfx/nvfx_screen.h
src/gallium/drivers/nvfx/nvfx_state.h
src/gallium/drivers/r300/Makefile
src/gallium/drivers/r300/SConscript
src/gallium/drivers/r300/compiler/memory_pool.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/memory_pool.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r300_fragprog.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r300_fragprog.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r300_fragprog_emit.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r3xx_fragprog.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r3xx_vertprog.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r3xx_vertprog_dump.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r500_fragprog.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r500_fragprog.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/r500_fragprog_emit.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_code.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_code.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_compiler.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_compiler.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_compiler_util.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_compiler_util.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_dataflow.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_dataflow.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_dataflow_deadcode.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_emulate_branches.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_emulate_branches.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_emulate_loops.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_emulate_loops.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_list.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_list.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_opcodes.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_opcodes.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_optimize.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_pair_dead_sources.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_pair_schedule.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_pair_translate.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program_alu.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program_alu.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program_constants.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program_pair.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program_pair.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program_print.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program_tex.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_program_tex.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_remove_constants.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_remove_constants.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_rename_regs.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_rename_regs.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_swizzle.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_variable.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/radeon_variable.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/tests/.gitignore [new file with mode: 0644]
src/gallium/drivers/r300/compiler/tests/Makefile [new file with mode: 0644]
src/gallium/drivers/r300/compiler/tests/radeon_compiler_util_tests.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/tests/rc_test_helpers.h [new file with mode: 0644]
src/gallium/drivers/r300/compiler/tests/unit_test.c [new file with mode: 0644]
src/gallium/drivers/r300/compiler/tests/unit_test.h [new file with mode: 0644]
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_chipset.c
src/gallium/drivers/r300/r300_chipset.h
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_flush.c
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_reg.h
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_screen.h
src/gallium/drivers/r300/r300_screen_buffer.c
src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_texture.h
src/gallium/drivers/r300/r300_texture_desc.c
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/r600/SConscript
src/gallium/drivers/r600/eg_asm.c
src/gallium/drivers/r600/eg_state_inlines.h [deleted file]
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/evergreend.h
src/gallium/drivers/r600/r600.h
src/gallium/drivers/r600/r600_asm.c
src/gallium/drivers/r600/r600_asm.h
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_formats.h
src/gallium/drivers/r600/r600_opcodes.h
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_query.c
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600_shader.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/r600/r600_state_inlines.h [deleted file]
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/r600/r600d.h
src/gallium/drivers/softpipe/Makefile
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_fs.h
src/gallium/drivers/softpipe/sp_fs_exec.c
src/gallium/drivers/softpipe/sp_fs_sse.c
src/gallium/drivers/softpipe/sp_quad_blend.c
src/gallium/drivers/softpipe/sp_quad_depth_test.c
src/gallium/drivers/softpipe/sp_quad_fs.c
src/gallium/drivers/softpipe/sp_quad_pipe.c
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_derived.c
src/gallium/drivers/softpipe/sp_state_sampler.c
src/gallium/drivers/softpipe/sp_state_shader.c
src/gallium/drivers/softpipe/sp_tex_sample.c
src/gallium/drivers/softpipe/sp_texture.h
src/gallium/drivers/svga/svga_context.c
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_draw.c
src/gallium/drivers/svga/svga_draw.h
src/gallium/drivers/svga/svga_draw_private.h
src/gallium/drivers/svga/svga_pipe_draw.c
src/gallium/drivers/svga/svga_resource_buffer.h
src/gallium/drivers/svga/svga_resource_buffer_upload.c
src/gallium/drivers/svga/svga_state_vdecl.c
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_format.h
src/gallium/include/pipe/p_screen.h
src/gallium/include/pipe/p_state.h
src/gallium/include/pipe/p_video_decoder.h [new file with mode: 0644]
src/gallium/include/pipe/p_video_enums.h [new file with mode: 0644]
src/gallium/include/pipe/p_video_state.h [new file with mode: 0644]
src/gallium/include/state_tracker/st_api.h
src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
src/gallium/state_trackers/dri/common/dri_context.c
src/gallium/state_trackers/dri/common/dri_drawable.c
src/gallium/state_trackers/dri/common/dri_drawable.h
src/gallium/state_trackers/dri/drm/SConscript
src/gallium/state_trackers/dri/drm/dri2.c
src/gallium/state_trackers/dri/sw/drisw.c
src/gallium/state_trackers/egl/Makefile
src/gallium/state_trackers/egl/SConscript
src/gallium/state_trackers/egl/common/egl_g3d.c
src/gallium/state_trackers/egl/common/egl_g3d.h
src/gallium/state_trackers/egl/common/egl_g3d_api.c
src/gallium/state_trackers/egl/common/egl_g3d_image.c
src/gallium/state_trackers/egl/common/egl_g3d_loader.h
src/gallium/state_trackers/egl/common/egl_g3d_st.c
src/gallium/state_trackers/egl/common/native.h
src/gallium/state_trackers/egl/common/native_buffer.h
src/gallium/state_trackers/egl/common/native_helper.c
src/gallium/state_trackers/egl/common/native_helper.h
src/gallium/state_trackers/egl/drm/modeset.c
src/gallium/state_trackers/egl/drm/native_drm.c
src/gallium/state_trackers/egl/drm/native_drm.h
src/gallium/state_trackers/egl/fbdev/native_fbdev.c
src/gallium/state_trackers/egl/gdi/native_gdi.c
src/gallium/state_trackers/egl/wayland/native_drm.c
src/gallium/state_trackers/egl/wayland/native_shm.c
src/gallium/state_trackers/egl/wayland/native_wayland.c
src/gallium/state_trackers/egl/wayland/native_wayland.h
src/gallium/state_trackers/egl/x11/native_dri2.c
src/gallium/state_trackers/egl/x11/native_x11.c
src/gallium/state_trackers/egl/x11/native_x11.h
src/gallium/state_trackers/egl/x11/native_ximage.c
src/gallium/state_trackers/egl/x11/x11_screen.c
src/gallium/state_trackers/gbm/Makefile [new file with mode: 0644]
src/gallium/state_trackers/gbm/gbm_drm.c [new file with mode: 0644]
src/gallium/state_trackers/gbm/gbm_gallium_drmint.h [new file with mode: 0644]
src/gallium/state_trackers/glx/xlib/glx_api.c
src/gallium/state_trackers/glx/xlib/xm_api.c
src/gallium/state_trackers/glx/xlib/xm_st.c
src/gallium/state_trackers/va/Makefile [new file with mode: 0644]
src/gallium/state_trackers/va/ftab.c [new file with mode: 0644]
src/gallium/state_trackers/va/htab.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_buffer.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_config.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_context.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_display.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_image.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_picture.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_private.h [new file with mode: 0644]
src/gallium/state_trackers/va/va_subpicture.c [new file with mode: 0644]
src/gallium/state_trackers/va/va_surface.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/Makefile [new file with mode: 0644]
src/gallium/state_trackers/vdpau/bitmap.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/decode.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/device.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/ftab.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/htab.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/mixer.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/output.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/preemption.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/presentation.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/query.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/surface.c [new file with mode: 0644]
src/gallium/state_trackers/vdpau/vdpau_private.h [new file with mode: 0644]
src/gallium/state_trackers/vega/vg_context.h
src/gallium/state_trackers/vega/vg_manager.c
src/gallium/state_trackers/wgl/stw_context.c
src/gallium/state_trackers/wgl/stw_ext_pbuffer.c
src/gallium/state_trackers/wgl/stw_st.c
src/gallium/state_trackers/xa/Makefile [new file with mode: 0644]
src/gallium/state_trackers/xa/README [new file with mode: 0644]
src/gallium/state_trackers/xa/xa-indent [new file with mode: 0755]
src/gallium/state_trackers/xa/xa_composite.c [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_composite.h [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_context.c [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_context.h [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_priv.h [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_renderer.c [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_symbols [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_tgsi.c [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_tracker.c [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_tracker.h [new file with mode: 0644]
src/gallium/state_trackers/xa/xa_yuv.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/SConscript
src/gallium/state_trackers/xorg/xorg_composite.c
src/gallium/state_trackers/xorg/xorg_crtc.c
src/gallium/state_trackers/xorg/xvmc/Makefile [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/attributes.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/block.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/context.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/subpicture.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/surface.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/.gitignore [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/Makefile [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/test_blocks.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/test_context.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/test_rendering.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/test_subpicture.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/test_surface.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/testlib.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/testlib.h [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/tests/xvmc_bench.c [new file with mode: 0644]
src/gallium/state_trackers/xorg/xvmc/xvmc_private.h [new file with mode: 0644]
src/gallium/targets/Makefile.dri
src/gallium/targets/Makefile.va [new file with mode: 0644]
src/gallium/targets/Makefile.vdpau [new file with mode: 0644]
src/gallium/targets/Makefile.xorg
src/gallium/targets/Makefile.xvmc [new file with mode: 0644]
src/gallium/targets/SConscript.dri
src/gallium/targets/dri-i915/Makefile
src/gallium/targets/dri-i915/SConscript
src/gallium/targets/dri-i965/Makefile
src/gallium/targets/dri-i965/SConscript
src/gallium/targets/dri-r300/target.c
src/gallium/targets/dri-swrast/Makefile
src/gallium/targets/dri-swrast/SConscript
src/gallium/targets/dri-vmwgfx/target.c
src/gallium/targets/egl-static/Makefile [new file with mode: 0644]
src/gallium/targets/egl-static/SConscript
src/gallium/targets/egl-static/egl.c
src/gallium/targets/egl-static/egl_st.c
src/gallium/targets/egl-static/egl_st.h
src/gallium/targets/egl-static/st_GL.c [moved from src/gallium/targets/egl/egl.h with 80% similarity]
src/gallium/targets/egl/Makefile [deleted file]
src/gallium/targets/egl/egl.c [deleted file]
src/gallium/targets/egl/st_GL.c [deleted file]
src/gallium/targets/egl/st_OpenVG.c [deleted file]
src/gallium/targets/gbm/Makefile [new file with mode: 0644]
src/gallium/targets/gbm/gbm.c [new file with mode: 0644]
src/gallium/targets/gbm/pipe_i915.c [moved from src/gallium/targets/egl/pipe_i915.c with 100% similarity]
src/gallium/targets/gbm/pipe_i965.c [moved from src/gallium/targets/egl/pipe_i965.c with 100% similarity]
src/gallium/targets/gbm/pipe_loader.c [new file with mode: 0644]
src/gallium/targets/gbm/pipe_loader.h [new file with mode: 0644]
src/gallium/targets/gbm/pipe_nouveau.c [moved from src/gallium/targets/egl/pipe_nouveau.c with 100% similarity]
src/gallium/targets/gbm/pipe_r300.c [moved from src/gallium/targets/egl/pipe_r300.c with 100% similarity]
src/gallium/targets/gbm/pipe_r600.c [moved from src/gallium/targets/egl/pipe_r600.c with 100% similarity]
src/gallium/targets/gbm/pipe_swrast.c [moved from src/gallium/targets/egl/pipe_swrast.c with 100% similarity]
src/gallium/targets/gbm/pipe_vmwgfx.c [moved from src/gallium/targets/egl/pipe_vmwgfx.c with 100% similarity]
src/gallium/targets/libgl-xlib/Makefile
src/gallium/targets/libgl-xlib/SConscript
src/gallium/targets/va-r300/Makefile [new file with mode: 0644]
src/gallium/targets/va-r300/target.c [new file with mode: 0644]
src/gallium/targets/va-r600/Makefile [new file with mode: 0644]
src/gallium/targets/va-r600/target.c [new file with mode: 0644]
src/gallium/targets/va-softpipe/Makefile [new file with mode: 0644]
src/gallium/targets/vdpau-r300/Makefile [new file with mode: 0644]
src/gallium/targets/vdpau-r300/target.c [new file with mode: 0644]
src/gallium/targets/vdpau-r600/Makefile [new file with mode: 0644]
src/gallium/targets/vdpau-r600/target.c [new file with mode: 0644]
src/gallium/targets/vdpau-softpipe/Makefile [new file with mode: 0644]
src/gallium/targets/xa-vmwgfx/Makefile [new file with mode: 0644]
src/gallium/targets/xa-vmwgfx/vmw_target.c [new file with mode: 0644]
src/gallium/targets/xa-vmwgfx/xatracker.pc.in [new file with mode: 0644]
src/gallium/targets/xorg-nouveau/Makefile
src/gallium/targets/xorg-nouveau/nouveau_xorg.c
src/gallium/targets/xorg-vmwgfx/SConscript
src/gallium/targets/xvmc-nouveau/Makefile [new file with mode: 0644]
src/gallium/targets/xvmc-nouveau/target.c [new file with mode: 0644]
src/gallium/targets/xvmc-r300/Makefile [new file with mode: 0644]
src/gallium/targets/xvmc-r300/target.c [new file with mode: 0644]
src/gallium/targets/xvmc-r600/Makefile [new file with mode: 0644]
src/gallium/targets/xvmc-r600/target.c [new file with mode: 0644]
src/gallium/targets/xvmc-softpipe/Makefile [new file with mode: 0644]
src/gallium/tests/trivial/Makefile
src/gallium/tests/trivial/quad-tex.c
src/gallium/tests/trivial/tri.c
src/gallium/winsys/g3dvl/Makefile [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/Makefile [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/XF86dri.c [moved from src/driclient/src/XF86dri.c with 100% similarity]
src/gallium/winsys/g3dvl/dri/dri2.c [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/dri2.h [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/dri_winsys.c [new file with mode: 0644]
src/gallium/winsys/g3dvl/dri/driclient.c [moved from src/driclient/src/driclient.c with 78% similarity]
src/gallium/winsys/g3dvl/dri/driclient.h [moved from src/driclient/include/driclient.h with 76% similarity]
src/gallium/winsys/g3dvl/dri/xf86dri.h [moved from src/driclient/include/xf86dri.h with 100% similarity]
src/gallium/winsys/g3dvl/dri/xf86dristr.h [moved from src/driclient/src/xf86dristr.h with 100% similarity]
src/gallium/winsys/g3dvl/vl_winsys.h [new file with mode: 0644]
src/gallium/winsys/g3dvl/xlib/xsp_winsys.c [new file with mode: 0644]
src/gallium/winsys/i915/drm/SConscript
src/gallium/winsys/i915/drm/i915_drm_buffer.c
src/gallium/winsys/i965/drm/SConscript
src/gallium/winsys/r600/drm/Makefile
src/gallium/winsys/r600/drm/SConscript
src/gallium/winsys/r600/drm/bof.c [deleted file]
src/gallium/winsys/r600/drm/bof.h [deleted file]
src/gallium/winsys/r600/drm/evergreen_hw_context.c
src/gallium/winsys/r600/drm/r600_bo.c
src/gallium/winsys/r600/drm/r600_drm.c
src/gallium/winsys/r600/drm/r600_hw_context.c
src/gallium/winsys/r600/drm/r600_priv.h
src/gallium/winsys/r600/drm/r600d.h
src/gallium/winsys/radeon/drm/SConscript
src/gallium/winsys/radeon/drm/radeon_drm_bo.c
src/gallium/winsys/radeon/drm/radeon_drm_bo.h
src/gallium/winsys/radeon/drm/radeon_drm_cs.c
src/gallium/winsys/radeon/drm/radeon_drm_cs.h
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
src/gallium/winsys/radeon/drm/radeon_winsys.h
src/gallium/winsys/svga/drm/SConscript
src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.c
src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.h
src/gallium/winsys/sw/wayland/wayland_sw_winsys.h
src/gbm/Makefile [new file with mode: 0644]
src/gbm/backends/Makefile [new file with mode: 0644]
src/gbm/backends/Makefile.template [new file with mode: 0644]
src/gbm/backends/dri/Makefile [new file with mode: 0644]
src/gbm/backends/dri/driver_name.c [new file with mode: 0644]
src/gbm/backends/dri/gbm_dri.c [new file with mode: 0644]
src/gbm/backends/dri/gbm_driint.h [new file with mode: 0644]
src/gbm/main/Makefile [new file with mode: 0644]
src/gbm/main/backend.c [new file with mode: 0644]
src/gbm/main/backend.h [new file with mode: 0644]
src/gbm/main/common.c [new file with mode: 0644]
src/gbm/main/common.h [new file with mode: 0644]
src/gbm/main/common_drm.h [new file with mode: 0644]
src/gbm/main/gbm.c [new file with mode: 0644]
src/gbm/main/gbm.h [new file with mode: 0644]
src/gbm/main/gbm.pc.in [new file with mode: 0644]
src/gbm/main/gbmint.h [new file with mode: 0644]
src/glsl/.gitignore
src/glsl/Makefile
src/glsl/SConscript
src/glsl/TODO
src/glsl/ast_function.cpp
src/glsl/ast_to_hir.cpp
src/glsl/builtins/ir/asin
src/glsl/builtins/ir/atan
src/glsl/builtins/ir/radians
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h
src/glsl/glsl_types.cpp
src/glsl/glsl_types.h
src/glsl/ir.cpp
src/glsl/ir.h
src/glsl/ir_constant_expression.cpp
src/glsl/ir_function.cpp
src/glsl/ir_function_detect_recursion.cpp [new file with mode: 0644]
src/glsl/ir_optimization.h
src/glsl/ir_print_visitor.cpp
src/glsl/ir_reader.cpp
src/glsl/ir_validate.cpp
src/glsl/link_functions.cpp
src/glsl/linker.cpp
src/glsl/linker.h
src/glsl/lower_if_to_cond_assign.cpp
src/glsl/lower_instructions.cpp
src/glsl/lower_jumps.cpp
src/glsl/lower_mat_op_to_vec.cpp
src/glsl/lower_variable_index_to_cond_assign.cpp
src/glsl/lower_vec_index_to_cond_assign.cpp
src/glsl/main.cpp
src/glsl/opt_constant_propagation.cpp
src/glsl/program.h
src/glsl/s_expression.cpp
src/glsl/s_expression.h
src/glsl/standalone_scaffolding.cpp [new file with mode: 0644]
src/glsl/standalone_scaffolding.h [new file with mode: 0644]
src/glsl/test.cpp [new file with mode: 0644]
src/glsl/test_optpass.cpp [new file with mode: 0644]
src/glsl/test_optpass.h [new file with mode: 0644]
src/glsl/tests/compare_ir [new file with mode: 0755]
src/glsl/tests/lower_jumps/.gitignore [new file with mode: 0644]
src/glsl/tests/lower_jumps/create_test_cases.py [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_breaks_1.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_breaks_2.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_breaks_3.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_breaks_4.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_breaks_5.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_breaks_6.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_returns_1.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_returns_1.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_returns_2.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_returns_2.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_returns_3.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_returns_3.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_returns_4.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_returns_4.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/lower_unified_returns.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/lower_unified_returns.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test.expected [new file with mode: 0644]
src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test [new file with mode: 0755]
src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test.expected [new file with mode: 0644]
src/glsl/tests/optimization-test [new file with mode: 0755]
src/glsl/tests/sexps.py [new file with mode: 0644]
src/glut/beos/Makefile [deleted file]
src/glut/beos/beos_x11.cpp [deleted file]
src/glut/beos/beos_x11.h [deleted file]
src/glut/beos/glutBlocker.cpp [deleted file]
src/glut/beos/glutBlocker.h [deleted file]
src/glut/beos/glutCallback.cpp [deleted file]
src/glut/beos/glutColor.cpp [deleted file]
src/glut/beos/glutCursor.cpp [deleted file]
src/glut/beos/glutCursors.h [deleted file]
src/glut/beos/glutDstr.cpp [deleted file]
src/glut/beos/glutEvent.cpp [deleted file]
src/glut/beos/glutGet.cpp [deleted file]
src/glut/beos/glutInit.cpp [deleted file]
src/glut/beos/glutMenu.cpp [deleted file]
src/glut/beos/glutMenu.h [deleted file]
src/glut/beos/glutOverlay.cpp [deleted file]
src/glut/beos/glutState.h [deleted file]
src/glut/beos/glutWindow.cpp [deleted file]
src/glut/beos/glutWindow.h [deleted file]
src/glut/beos/glut_8x13.c [deleted file]
src/glut/beos/glut_9x15.c [deleted file]
src/glut/beos/glut_bitmap.c [deleted file]
src/glut/beos/glut_bwidth.c [deleted file]
src/glut/beos/glut_ext.c [deleted file]
src/glut/beos/glut_hel10.c [deleted file]
src/glut/beos/glut_hel12.c [deleted file]
src/glut/beos/glut_hel18.c [deleted file]
src/glut/beos/glut_mroman.c [deleted file]
src/glut/beos/glut_roman.c [deleted file]
src/glut/beos/glut_shapes.c [deleted file]
src/glut/beos/glut_stroke.c [deleted file]
src/glut/beos/glut_swidth.c [deleted file]
src/glut/beos/glut_teapot.c [deleted file]
src/glut/beos/glut_tr10.c [deleted file]
src/glut/beos/glut_tr24.c [deleted file]
src/glut/beos/glut_util.c [deleted file]
src/glut/beos/glut_vidresize.c [deleted file]
src/glut/beos/glutbitmap.h [deleted file]
src/glut/beos/glutint.h [deleted file]
src/glut/beos/glutstroke.h [deleted file]
src/glut/glx/Makefile [deleted file]
src/glut/glx/Makefile.cygnus [deleted file]
src/glut/glx/Makefile.mgw [deleted file]
src/glut/glx/Makefile.sgi [deleted file]
src/glut/glx/Makefile.win [deleted file]
src/glut/glx/SConscript [deleted file]
src/glut/glx/capturexfont.c [deleted file]
src/glut/glx/fxglut.def [deleted file]
src/glut/glx/glut.def [deleted file]
src/glut/glx/glut.pc.in [deleted file]
src/glut/glx/glut_8x13.c [deleted file]
src/glut/glx/glut_9x15.c [deleted file]
src/glut/glx/glut_bitmap.c [deleted file]
src/glut/glx/glut_bwidth.c [deleted file]
src/glut/glx/glut_cindex.c [deleted file]
src/glut/glx/glut_cmap.c [deleted file]
src/glut/glx/glut_cursor.c [deleted file]
src/glut/glx/glut_dials.c [deleted file]
src/glut/glx/glut_dstr.c [deleted file]
src/glut/glx/glut_event.c [deleted file]
src/glut/glx/glut_ext.c [deleted file]
src/glut/glx/glut_fcb.c [deleted file]
src/glut/glx/glut_fullscrn.c [deleted file]
src/glut/glx/glut_gamemode.c [deleted file]
src/glut/glx/glut_get.c [deleted file]
src/glut/glx/glut_glxext.c [deleted file]
src/glut/glx/glut_hel10.c [deleted file]
src/glut/glx/glut_hel12.c [deleted file]
src/glut/glx/glut_hel18.c [deleted file]
src/glut/glx/glut_init.c [deleted file]
src/glut/glx/glut_input.c [deleted file]
src/glut/glx/glut_joy.c [deleted file]
src/glut/glx/glut_key.c [deleted file]
src/glut/glx/glut_keyctrl.c [deleted file]
src/glut/glx/glut_keyup.c [deleted file]
src/glut/glx/glut_menu.c [deleted file]
src/glut/glx/glut_menu2.c [deleted file]
src/glut/glx/glut_mesa.c [deleted file]
src/glut/glx/glut_modifier.c [deleted file]
src/glut/glx/glut_mroman.c [deleted file]
src/glut/glx/glut_overlay.c [deleted file]
src/glut/glx/glut_ppm.c [deleted file]
src/glut/glx/glut_roman.c [deleted file]
src/glut/glx/glut_shapes.c [deleted file]
src/glut/glx/glut_space.c [deleted file]
src/glut/glx/glut_stroke.c [deleted file]
src/glut/glx/glut_swap.c [deleted file]
src/glut/glx/glut_swidth.c [deleted file]
src/glut/glx/glut_tablet.c [deleted file]
src/glut/glx/glut_teapot.c [deleted file]
src/glut/glx/glut_tr10.c [deleted file]
src/glut/glx/glut_tr24.c [deleted file]
src/glut/glx/glut_util.c [deleted file]
src/glut/glx/glut_vidresize.c [deleted file]
src/glut/glx/glut_warp.c [deleted file]
src/glut/glx/glut_win.c [deleted file]
src/glut/glx/glut_winmisc.c [deleted file]
src/glut/glx/glutbitmap.h [deleted file]
src/glut/glx/glutint.h [deleted file]
src/glut/glx/glutstroke.h [deleted file]
src/glut/glx/glutwin32.h [deleted file]
src/glut/glx/layerutil.c [deleted file]
src/glut/glx/layerutil.h [deleted file]
src/glut/glx/stroke.h [deleted file]
src/glut/glx/win32_glx.c [deleted file]
src/glut/glx/win32_glx.h [deleted file]
src/glut/glx/win32_menu.c [deleted file]
src/glut/glx/win32_util.c [deleted file]
src/glut/glx/win32_winproc.c [deleted file]
src/glut/glx/win32_x11.c [deleted file]
src/glut/glx/win32_x11.h [deleted file]
src/glw/GLwDrawA.h
src/glw/GLwDrawAP.h
src/glx/SConscript [new file with mode: 0644]
src/glx/apple/Makefile
src/glx/apple/apple_glapi.c
src/glx/applegl_glx.c
src/glx/dri2.c
src/glx/dri2_glx.c
src/glx/dri_common.c
src/glx/dri_glx.c
src/glx/drisw_glx.c
src/glx/glx_pbuffer.c
src/glx/glxclient.h
src/glx/glxcmds.c
src/glx/glxcurrent.c
src/glx/glxext.c
src/glx/indirect_glx.c
src/mapi/glapi/SConscript
src/mapi/glapi/gen/ARB_geometry_shader4.xml
src/mesa/Makefile
src/mesa/drivers/common/driverfuncs.c
src/mesa/drivers/common/meta.c
src/mesa/drivers/common/meta.h
src/mesa/drivers/dri/common/xmlconfig.c
src/mesa/drivers/dri/i915/i830_context.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_fragprog.c
src/mesa/drivers/dri/i915/i915_program.c
src/mesa/drivers/dri/i915/i915_state.c
src/mesa/drivers/dri/i915/i915_tex_layout.c
src/mesa/drivers/dri/i915/i915_texstate.c
src/mesa/drivers/dri/i915/i915_vtbl.c
src/mesa/drivers/dri/i915/intel_tris.c
src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_clip.c
src/mesa/drivers/dri/i965/brw_clip_state.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_draw_upload.c
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
src/mesa/drivers/dri/i965/brw_fs_emit.cpp
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp
src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_gs.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_sf.c
src/mesa/drivers/dri/i965/brw_sf_state.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_batch.c
src/mesa/drivers/dri/i965/brw_state_cache.c
src/mesa/drivers/dri/i965/brw_state_dump.c
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_structs.h
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs_constval.c
src/mesa/drivers/dri/i965/brw_vs_emit.c
src/mesa/drivers/dri/i965/brw_vs_state.c
src/mesa/drivers/dri/i965/brw_vs_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_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/gen6_cc.c
src/mesa/drivers/dri/i965/gen6_depthstencil.c
src/mesa/drivers/dri/i965/gen6_gs_state.c
src/mesa/drivers/dri/i965/gen6_sampler_state.c
src/mesa/drivers/dri/i965/gen6_scissor_state.c
src/mesa/drivers/dri/i965/gen6_urb.c
src/mesa/drivers/dri/i965/gen6_viewport_state.c
src/mesa/drivers/dri/i965/gen6_vs_state.c
src/mesa/drivers/dri/i965/gen6_wm_state.c
src/mesa/drivers/dri/i965/gen7_disable.c
src/mesa/drivers/dri/i965/gen7_sampler_state.c
src/mesa/drivers/dri/i965/gen7_sf_state.c
src/mesa/drivers/dri/i965/gen7_urb.c
src/mesa/drivers/dri/i965/gen7_viewport_state.c
src/mesa/drivers/dri/i965/gen7_vs_state.c
src/mesa/drivers/dri/i965/gen7_wm_state.c
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
src/mesa/drivers/dri/intel/intel_batchbuffer.c
src/mesa/drivers/dri/intel/intel_batchbuffer.h
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_extensions.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_fbo.h
src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
src/mesa/drivers/dri/intel/intel_reg.h
src/mesa/drivers/dri/intel/intel_regions.c
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_tex.c
src/mesa/drivers/dri/intel/intel_tex_copy.c
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/intel/intel_tex_obj.h
src/mesa/drivers/dri/nouveau/nv10_render.c
src/mesa/drivers/dri/r200/r200_cmdbuf.c
src/mesa/drivers/dri/r200/r200_ioctl.c
src/mesa/drivers/dri/r200/r200_tex.c
src/mesa/drivers/dri/r200/r200_texstate.c
src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c
src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_texstate.c
src/mesa/drivers/dri/r600/evergreen_tex.c
src/mesa/drivers/dri/r600/r600_cmdbuf.c
src/mesa/drivers/dri/r600/r600_tex.c
src/mesa/drivers/dri/r600/r600_texstate.c
src/mesa/drivers/dri/r600/r700_render.c
src/mesa/drivers/dri/radeon/radeon_common.c
src/mesa/drivers/dri/radeon/radeon_common_context.c
src/mesa/drivers/dri/radeon/radeon_cs_legacy.c
src/mesa/drivers/dri/radeon/radeon_ioctl.c
src/mesa/drivers/dri/radeon/radeon_lock.c
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/radeon/radeon_tex.c
src/mesa/drivers/dri/radeon/radeon_tex_copy.c
src/mesa/drivers/dri/radeon/radeon_texstate.c
src/mesa/drivers/dri/radeon/radeon_texture.h
src/mesa/drivers/x11/fakeglx.c
src/mesa/main/arbprogram.c
src/mesa/main/bufferobj.c
src/mesa/main/bufferobj.h
src/mesa/main/buffers.c
src/mesa/main/buffers.h
src/mesa/main/compiler.h
src/mesa/main/context.c
src/mesa/main/dd.h
src/mesa/main/depthstencil.c
src/mesa/main/depthstencil.h
src/mesa/main/dlist.c
src/mesa/main/enable.c
src/mesa/main/fbobject.c
src/mesa/main/feedback.c
src/mesa/main/ff_fragment_shader.cpp
src/mesa/main/formats.c
src/mesa/main/formats.h
src/mesa/main/framebuffer.c
src/mesa/main/framebuffer.h
src/mesa/main/get.c
src/mesa/main/image.c
src/mesa/main/mipmap.c
src/mesa/main/mtypes.h
src/mesa/main/pack.c
src/mesa/main/pack.h
src/mesa/main/readpix.c
src/mesa/main/renderbuffer.c
src/mesa/main/renderbuffer.h
src/mesa/main/samplerobj.c
src/mesa/main/shaderapi.c
src/mesa/main/shaderobj.c
src/mesa/main/state.c
src/mesa/main/texcompress.c
src/mesa/main/texcompress.h
src/mesa/main/texenv.c
src/mesa/main/texfetch.c
src/mesa/main/texfetch_tmp.h
src/mesa/main/texformat.c
src/mesa/main/teximage.c
src/mesa/main/texobj.c
src/mesa/main/texobj.h
src/mesa/main/texparam.c
src/mesa/main/texstore.c
src/mesa/main/uniforms.c
src/mesa/main/version.h
src/mesa/program/ir_to_mesa.cpp
src/mesa/program/prog_optimize.c
src/mesa/program/program.c
src/mesa/program/program.h
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_blit.c
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_condrender.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_queryobj.c
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_cb_viewport.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_draw.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_glsl_to_tgsi.cpp
src/mesa/state_tracker/st_manager.c
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_texture.c
src/mesa/swrast/s_blit.c
src/mesa/swrast/s_readpix.c
src/mesa/swrast/s_span.c
src/mesa/vbo/vbo_exec_array.c
src/mesa/vbo/vbo_rebase.c

index e48dd3b..a9bc5d4 100644 (file)
 *.pyo
 *.so
 *.sw[a-z]
+*.tar
+*.tar.bz2
+*.tar.gz
+*.zip
 *~
 depend
 depend.bak
@@ -25,4 +29,5 @@ cscope*
 .scon*
 config.py
 build
+manifest.txt
 .dir-locals.el
index 07ec686..916c498 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,10 @@ all: default
 doxygen:
        cd doxygen && $(MAKE)
 
+check:
+       cd src/glsl/tests/ && ./optimization-test
+       @echo "All tests passed."
+
 clean:
        -@touch $(TOP)/configs/current
        -@for dir in $(SUBDIRS) ; do \
@@ -51,7 +55,7 @@ install:
        done
 
 
-.PHONY: default doxygen clean realclean distclean install
+.PHONY: default doxygen clean realclean distclean install check
 
 # If there's no current configuration file
 $(TOP)/configs/current:
@@ -183,288 +187,40 @@ ultrix-gcc:
 
 # Rules for making release tarballs
 
-VERSION=7.11-devel
-DIRECTORY = Mesa-$(VERSION)
-LIB_NAME = MesaLib-$(VERSION)
-GLUT_NAME = MesaGLUT-$(VERSION)
-
-# This is part of MAIN_FILES
-MAIN_ES_FILES = \
-       $(DIRECTORY)/src/mesa/main/*.xml                                \
-       $(DIRECTORY)/src/mesa/main/*.py                                 \
-       $(DIRECTORY)/src/mesa/main/*.dtd
-
-MAIN_FILES = \
-       $(DIRECTORY)/Makefile*                                          \
-       $(DIRECTORY)/configure                                          \
-       $(DIRECTORY)/configure.ac                                       \
-       $(DIRECTORY)/acinclude.m4                                       \
-       $(DIRECTORY)/aclocal.m4                                         \
-       $(DIRECTORY)/SConstruct                                         \
-       $(DIRECTORY)/common.py                                          \
-       $(DIRECTORY)/scons/*py                                          \
-       $(DIRECTORY)/bin/config.guess                                   \
-       $(DIRECTORY)/bin/config.sub                                     \
-       $(DIRECTORY)/bin/extract_git_sha1                               \
-       $(DIRECTORY)/bin/install-sh                                     \
-       $(DIRECTORY)/bin/mklib                                          \
-       $(DIRECTORY)/bin/minstall                                       \
-       $(DIRECTORY)/bin/version.mk                                     \
-       $(DIRECTORY)/configs/[a-z]*                                     \
-       $(DIRECTORY)/docs/*.html                                        \
-       $(DIRECTORY)/docs/COPYING                                       \
-       $(DIRECTORY)/docs/README.*                                      \
-       $(DIRECTORY)/docs/RELNOTES*                                     \
-       $(DIRECTORY)/docs/*.spec                                        \
-       $(DIRECTORY)/include/GL/gl.h                                    \
-       $(DIRECTORY)/include/GL/glext.h                                 \
-       $(DIRECTORY)/include/GL/gl_mangle.h                             \
-       $(DIRECTORY)/include/GL/glu.h                                   \
-       $(DIRECTORY)/include/GL/glu_mangle.h                            \
-       $(DIRECTORY)/include/GL/glx.h                                   \
-       $(DIRECTORY)/include/GL/glxext.h                                \
-       $(DIRECTORY)/include/GL/glx_mangle.h                            \
-       $(DIRECTORY)/include/GL/glfbdev.h                               \
-       $(DIRECTORY)/include/GL/mesa_wgl.h                              \
-       $(DIRECTORY)/include/GL/osmesa.h                                \
-       $(DIRECTORY)/include/GL/vms_x_fix.h                             \
-       $(DIRECTORY)/include/GL/wglext.h                                \
-       $(DIRECTORY)/include/GL/wmesa.h                                 \
-       $(DIRECTORY)/include/pci_ids/*.h                                \
-       $(DIRECTORY)/include/c99/*.h                                    \
-       $(DIRECTORY)/src/getopt/SConscript                              \
-       $(DIRECTORY)/src/getopt/getopt*.[ch]                            \
-       $(DIRECTORY)/src/glsl/Makefile                                  \
-       $(DIRECTORY)/src/glsl/Makefile.template                         \
-       $(DIRECTORY)/src/glsl/SConscript                                \
-       $(DIRECTORY)/src/glsl/*.[ch]                                    \
-       $(DIRECTORY)/src/glsl/*.ll                                      \
-       $(DIRECTORY)/src/glsl/*.yy                                      \
-       $(DIRECTORY)/src/glsl/*.[cly]pp                                 \
-       $(DIRECTORY)/src/glsl/README                                    \
-       $(DIRECTORY)/src/glsl/glcpp/*.[chly]                            \
-       $(DIRECTORY)/src/glsl/glcpp/README                              \
-       $(DIRECTORY)/src/glsl/builtins                                  \
-       $(DIRECTORY)/src/Makefile                                       \
-       $(DIRECTORY)/src/SConscript                                     \
-       $(DIRECTORY)/src/mesa/Makefile*                                 \
-       $(DIRECTORY)/src/mesa/SConscript                                \
-       $(DIRECTORY)/src/mesa/sources.mak                               \
-       $(DIRECTORY)/src/mesa/descrip.mms                               \
-       $(DIRECTORY)/src/mesa/gl.pc.in                                  \
-       $(DIRECTORY)/src/mesa/osmesa.pc.in                              \
-       $(DIRECTORY)/src/mesa/depend                                    \
-       $(MAIN_ES_FILES)                                                \
-       $(DIRECTORY)/src/mesa/main/*.[chS]                              \
-       $(DIRECTORY)/src/mesa/main/*.cpp                                \
-       $(DIRECTORY)/src/mesa/main/descrip.mms                          \
-       $(DIRECTORY)/src/mesa/math/*.[ch]                               \
-       $(DIRECTORY)/src/mesa/math/descrip.mms                          \
-       $(DIRECTORY)/src/mesa/program/*.[chly]                          \
-       $(DIRECTORY)/src/mesa/program/*.cpp                             \
-       $(DIRECTORY)/src/mesa/program/descrip.mms                       \
-       $(DIRECTORY)/src/mesa/swrast/*.[ch]                             \
-       $(DIRECTORY)/src/mesa/swrast/descrip.mms                        \
-       $(DIRECTORY)/src/mesa/swrast_setup/*.[ch]                       \
-       $(DIRECTORY)/src/mesa/swrast_setup/descrip.mms                  \
-       $(DIRECTORY)/src/mesa/vbo/*.[chS]                               \
-       $(DIRECTORY)/src/mesa/vbo/descrip.mms                           \
-       $(DIRECTORY)/src/mesa/tnl/*.[chS]                               \
-       $(DIRECTORY)/src/mesa/tnl/descrip.mms                           \
-       $(DIRECTORY)/src/mesa/tnl_dd/*.[ch]                             \
-       $(DIRECTORY)/src/mesa/tnl_dd/imm/*.[ch]                         \
-       $(DIRECTORY)/src/mesa/tnl_dd/imm/NOTES.imm                      \
-       $(DIRECTORY)/src/mesa/drivers/Makefile                          \
-       $(DIRECTORY)/src/mesa/drivers/beos/*.cpp                        \
-       $(DIRECTORY)/src/mesa/drivers/beos/Makefile                     \
-       $(DIRECTORY)/src/mesa/drivers/common/*.[ch]                     \
-       $(DIRECTORY)/src/mesa/drivers/common/descrip.mms                \
-       $(DIRECTORY)/src/mesa/drivers/fbdev/Makefile                    \
-       $(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c                   \
-       $(DIRECTORY)/src/mesa/drivers/osmesa/Makefile                   \
-       $(DIRECTORY)/src/mesa/drivers/osmesa/Makefile.win               \
-       $(DIRECTORY)/src/mesa/drivers/osmesa/descrip.mms                \
-       $(DIRECTORY)/src/mesa/drivers/osmesa/osmesa.def                 \
-       $(DIRECTORY)/src/mesa/drivers/osmesa/*.[ch]                     \
-       $(DIRECTORY)/src/mesa/drivers/dri/r300/compiler/*.[ch]          \
-       $(DIRECTORY)/src/mesa/drivers/dri/r300/compiler/Makefile        \
-       $(DIRECTORY)/src/mesa/drivers/dri/r300/compiler/SConscript      \
-       $(DIRECTORY)/src/mesa/drivers/windows/*/*.[ch]                  \
-       $(DIRECTORY)/src/mesa/drivers/windows/*/*.def                   \
-       $(DIRECTORY)/src/mesa/drivers/x11/Makefile                      \
-       $(DIRECTORY)/src/mesa/drivers/x11/descrip.mms                   \
-       $(DIRECTORY)/src/mesa/drivers/x11/*.[ch]                        \
-       $(DIRECTORY)/src/mesa/ppc/*.[ch]                                \
-       $(DIRECTORY)/src/mesa/sparc/*.[chS]                             \
-       $(DIRECTORY)/src/mesa/x86/Makefile                              \
-       $(DIRECTORY)/src/mesa/x86/*.[ch]                                \
-       $(DIRECTORY)/src/mesa/x86/*.S                                   \
-       $(DIRECTORY)/src/mesa/x86/rtasm/*.[ch]                          \
-       $(DIRECTORY)/src/mesa/x86-64/*.[chS]                            \
-       $(DIRECTORY)/src/mesa/x86-64/Makefile
-
-MAPI_FILES = \
-       $(DIRECTORY)/include/GLES/*.h                                   \
-       $(DIRECTORY)/include/GLES2/*.h                                  \
-       $(DIRECTORY)/include/VG/*.h                                     \
-       $(DIRECTORY)/src/mapi/es?api/Makefile                           \
-       $(DIRECTORY)/src/mapi/es?api/*.pc.in                            \
-       $(DIRECTORY)/src/mapi/glapi/gen/Makefile                        \
-       $(DIRECTORY)/src/mapi/glapi/gen/*.xml                           \
-       $(DIRECTORY)/src/mapi/glapi/gen/*.py                            \
-       $(DIRECTORY)/src/mapi/glapi/gen/*.dtd                           \
-       $(DIRECTORY)/src/mapi/glapi/gen-es/Makefile                     \
-       $(DIRECTORY)/src/mapi/glapi/gen-es/*.xml                        \
-       $(DIRECTORY)/src/mapi/glapi/gen-es/*.py                         \
-       $(DIRECTORY)/src/mapi/glapi/Makefile                            \
-       $(DIRECTORY)/src/mapi/glapi/SConscript                          \
-       $(DIRECTORY)/src/mapi/glapi/sources.mak                         \
-       $(DIRECTORY)/src/mapi/glapi/*.[chS]                             \
-       $(DIRECTORY)/src/mapi/mapi/mapi_abi.py                          \
-       $(DIRECTORY)/src/mapi/mapi/sources.mak                          \
-       $(DIRECTORY)/src/mapi/mapi/*.[ch]                               \
-       $(DIRECTORY)/src/mapi/shared-glapi/SConscript                   \
-       $(DIRECTORY)/src/mapi/shared-glapi/Makefile                     \
-       $(DIRECTORY)/src/mapi/vgapi/Makefile                            \
-       $(DIRECTORY)/src/mapi/vgapi/SConscript                          \
-       $(DIRECTORY)/src/mapi/vgapi/vgapi.csv                           \
-       $(DIRECTORY)/src/mapi/vgapi/vg.pc.in
-
-EGL_FILES = \
-       $(DIRECTORY)/include/KHR/*.h                                    \
-       $(DIRECTORY)/include/EGL/*.h                                    \
-       $(DIRECTORY)/src/egl/Makefile                                   \
-       $(DIRECTORY)/src/egl/*/Makefile                                 \
-       $(DIRECTORY)/src/egl/*/Makefile.template                        \
-       $(DIRECTORY)/src/egl/*/*.[ch]                                   \
-       $(DIRECTORY)/src/egl/*/*/Makefile                               \
-       $(DIRECTORY)/src/egl/*/*/*.[ch]                                 \
-       $(DIRECTORY)/src/egl/wayland/wayland-drm/protocol/*.xml         \
-       $(DIRECTORY)/src/egl/wayland/wayland-egl/*.pc.in                \
-       $(DIRECTORY)/src/egl/main/SConscript                            \
-       $(DIRECTORY)/src/egl/main/*.pc.in                               \
-       $(DIRECTORY)/src/egl/main/*.def
-
-GALLIUM_FILES = \
-       $(DIRECTORY)/src/mesa/state_tracker/*[ch]                       \
-       $(DIRECTORY)/src/gallium/Makefile                               \
-       $(DIRECTORY)/src/gallium/Makefile.template                      \
-       $(DIRECTORY)/src/gallium/SConscript                             \
-       $(DIRECTORY)/src/gallium/targets/Makefile.dri                   \
-       $(DIRECTORY)/src/gallium/targets/Makefile.xorg                  \
-       $(DIRECTORY)/src/gallium/targets/SConscript.dri                 \
-       $(DIRECTORY)/src/gallium/*/Makefile                             \
-       $(DIRECTORY)/src/gallium/*/SConscript                           \
-       $(DIRECTORY)/src/gallium/*/*/Makefile                           \
-       $(DIRECTORY)/src/gallium/*/*/SConscript                         \
-       $(DIRECTORY)/src/gallium/*/*/*.[ch]                             \
-       $(DIRECTORY)/src/gallium/auxiliary/gallivm/*.cpp                \
-       $(DIRECTORY)/src/gallium/*/*/*.py                               \
-       $(DIRECTORY)/src/gallium/*/*/*.csv                              \
-       $(DIRECTORY)/src/gallium/*/*/*/Makefile                         \
-       $(DIRECTORY)/src/gallium/*/*/*/SConscript                       \
-       $(DIRECTORY)/src/gallium/*/*/*/*.[ch]                           \
-       $(DIRECTORY)/src/gallium/*/*/*/*.py
-
-APPLE_DRI_FILES = \
-       $(DIRECTORY)/src/glx/apple/Makefile                             \
-       $(DIRECTORY)/src/glx/apple/*.[ch]
-
-DRI_FILES = \
-       $(DIRECTORY)/include/GL/internal/dri_interface.h                \
-       $(DIRECTORY)/include/GL/internal/sarea.h                        \
-       $(DIRECTORY)/src/glx/Makefile                                   \
-       $(DIRECTORY)/src/glx/*.[ch]                                     \
-       $(APPLE_DRI_FILES)                                              \
-       $(DIRECTORY)/src/mesa/drivers/dri/Makefile                      \
-       $(DIRECTORY)/src/mesa/drivers/dri/Makefile.template             \
-       $(DIRECTORY)/src/mesa/drivers/dri/dri.pc.in                     \
-       $(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.po           \
-       $(DIRECTORY)/src/mesa/drivers/dri/*/*.[chS]                     \
-       $(DIRECTORY)/src/mesa/drivers/dri/*/*.cpp                       \
-       $(DIRECTORY)/src/mesa/drivers/dri/*/*/*.[chS]                   \
-       $(DIRECTORY)/src/mesa/drivers/dri/*/Makefile                    \
-       $(DIRECTORY)/src/mesa/drivers/dri/*/*/Makefile                  \
-       $(DIRECTORY)/src/mesa/drivers/dri/*/Doxyfile
-
-SGI_GLU_FILES = \
-       $(DIRECTORY)/src/glu/Makefile                                   \
-       $(DIRECTORY)/src/glu/glu.pc.in                                  \
-       $(DIRECTORY)/src/glu/sgi/Makefile                               \
-       $(DIRECTORY)/src/glu/sgi/Makefile.mgw                           \
-       $(DIRECTORY)/src/glu/sgi/Makefile.win                           \
-       $(DIRECTORY)/src/glu/sgi/glu.def                                \
-       $(DIRECTORY)/src/glu/sgi/dummy.cc                               \
-       $(DIRECTORY)/src/glu/sgi/glu.exports                            \
-       $(DIRECTORY)/src/glu/sgi/glu.exports.darwin                     \
-       $(DIRECTORY)/src/glu/sgi/mesaglu.opt                            \
-       $(DIRECTORY)/src/glu/sgi/include/gluos.h                        \
-       $(DIRECTORY)/src/glu/sgi/libnurbs/interface/*.h                 \
-       $(DIRECTORY)/src/glu/sgi/libnurbs/interface/*.cc                \
-       $(DIRECTORY)/src/glu/sgi/libnurbs/internals/*.h                 \
-       $(DIRECTORY)/src/glu/sgi/libnurbs/internals/*.cc                \
-       $(DIRECTORY)/src/glu/sgi/libnurbs/nurbtess/*.h                  \
-       $(DIRECTORY)/src/glu/sgi/libnurbs/nurbtess/*.cc                 \
-       $(DIRECTORY)/src/glu/sgi/libtess/README                         \
-       $(DIRECTORY)/src/glu/sgi/libtess/alg-outline                    \
-       $(DIRECTORY)/src/glu/sgi/libtess/*.[ch]                         \
-       $(DIRECTORY)/src/glu/sgi/libutil/*.[ch]
-
-GLW_FILES = \
-       $(DIRECTORY)/src/glw/*.[ch]                     \
-       $(DIRECTORY)/src/glw/Makefile*                  \
-       $(DIRECTORY)/src/glw/README                     \
-       $(DIRECTORY)/src/glw/glw.pc.in                  \
-       $(DIRECTORY)/src/glw/depend
-
-GLUT_FILES = \
-       $(DIRECTORY)/include/GL/glut.h                  \
-       $(DIRECTORY)/include/GL/glutf90.h               \
-       $(DIRECTORY)/src/glut/glx/Makefile*             \
-       $(DIRECTORY)/src/glut/glx/SConscript            \
-       $(DIRECTORY)/src/glut/glx/depend                \
-       $(DIRECTORY)/src/glut/glx/glut.pc.in            \
-       $(DIRECTORY)/src/glut/glx/*def                  \
-       $(DIRECTORY)/src/glut/glx/*.[ch]                \
-       $(DIRECTORY)/src/glut/beos/*.[ch]               \
-       $(DIRECTORY)/src/glut/beos/*.cpp                \
-       $(DIRECTORY)/src/glut/beos/Makefile
-
-DEPEND_FILES = \
-       $(TOP)/src/mesa/depend          \
-       $(TOP)/src/glx/depend           \
-       $(TOP)/src/glw/depend           \
-       $(TOP)/src/glut/glx/depend      \
-       $(TOP)/src/glu/sgi/depend
-
-
-LIB_FILES = \
-       $(MAIN_FILES)           \
-       $(MAPI_FILES)           \
-       $(ES_FILES)             \
-       $(EGL_FILES)            \
-       $(GALLIUM_FILES)        \
-       $(DRI_FILES)            \
-       $(SGI_GLU_FILES)        \
-       $(GLW_FILES)
+PACKAGE_VERSION=7.12-devel
+PACKAGE_DIR = Mesa-$(PACKAGE_VERSION)
+PACKAGE_NAME = MesaLib-$(PACKAGE_VERSION)
+
+EXTRA_FILES = \
+       aclocal.m4                                      \
+       configure                                       \
+       src/glsl/glsl_parser.cpp                        \
+       src/glsl/glsl_parser.h                          \
+       src/glsl/glsl_lexer.cpp                         \
+       src/glsl/glcpp/glcpp-lex.c                      \
+       src/glsl/glcpp/glcpp-parse.c                    \
+       src/glsl/glcpp/glcpp-parse.h                    \
+       src/mesa/program/lex.yy.c                       \
+       src/mesa/program/program_parse.tab.c            \
+       src/mesa/program/program_parse.tab.h
+
+IGNORE_FILES = \
+       -x autogen.sh
 
 
 parsers: configure
        -@touch $(TOP)/configs/current
        $(MAKE) -C src/glsl glsl_parser.cpp glsl_parser.h glsl_lexer.cpp
        $(MAKE) -C src/glsl/glcpp glcpp-lex.c glcpp-parse.c glcpp-parse.h
-       $(MAKE) -C src/mesa/program lex.yy.c program_parse.tab.c program_parse.tab.h
+       $(MAKE) -C src/mesa program/lex.yy.c program/program_parse.tab.c program/program_parse.tab.h
 
 # Everything for new a Mesa release:
-ARCHIVES = $(LIB_NAME).tar.gz \
-       $(LIB_NAME).tar.bz2 \
-       $(LIB_NAME).zip \
-       $(GLUT_NAME).tar.gz \
-       $(GLUT_NAME).tar.bz2 \
-       $(GLUT_NAME).zip
+ARCHIVES = $(PACKAGE_NAME).tar.gz \
+       $(PACKAGE_NAME).tar.bz2 \
+       $(PACKAGE_NAME).zip \
 
 tarballs: md5
-       rm -f ../$(LIB_NAME).tar
+       rm -f ../$(PACKAGE_DIR) $(PACKAGE_NAME).tar
 
 # Helper for autoconf builds
 ACLOCAL = aclocal
@@ -473,55 +229,36 @@ AUTOCONF = autoconf
 AC_FLAGS =
 aclocal.m4: configure.ac acinclude.m4
        $(ACLOCAL) $(ACLOCAL_FLAGS)
-configure: rm_depend configure.ac aclocal.m4 acinclude.m4
+configure: configure.ac aclocal.m4 acinclude.m4
        $(AUTOCONF) $(AC_FLAGS)
 
-rm_depend:
-       @for dep in $(DEPEND_FILES) ; do \
-               rm -f $$dep ; \
-               touch $$dep ; \
-       done
-
-rm_config: parsers
-       rm -f configs/current
-       rm -f configs/autoconf
+manifest.txt: .git
+       ( \
+               ls -1 $(EXTRA_FILES) ; \
+               git ls-files $(IGNORE_FILES) \
+       ) | sed -e '/^\(.*\/\)\?\./d' -e "s@^@$(PACKAGE_DIR)/@" > $@
 
-$(LIB_NAME).tar: rm_config
-       cd .. ; tar -cf $(DIRECTORY)/$(LIB_NAME).tar $(LIB_FILES)
+../$(PACKAGE_DIR):
+       ln -s $(PWD) $@
 
-$(LIB_NAME).tar.gz: $(LIB_NAME).tar
-       gzip --stdout --best $(LIB_NAME).tar > $(LIB_NAME).tar.gz
+$(PACKAGE_NAME).tar: parsers ../$(PACKAGE_DIR) manifest.txt
+       cd .. ; tar -cf $(PACKAGE_DIR)/$(PACKAGE_NAME).tar -T $(PACKAGE_DIR)/manifest.txt
 
-$(GLUT_NAME).tar: rm_depend
-       cd .. ; tar -cf $(DIRECTORY)/$(GLUT_NAME).tar $(GLUT_FILES)
+$(PACKAGE_NAME).tar.gz: $(PACKAGE_NAME).tar ../$(PACKAGE_DIR)
+       gzip --stdout --best $(PACKAGE_NAME).tar > $(PACKAGE_NAME).tar.gz
 
-$(GLUT_NAME).tar.gz: $(GLUT_NAME).tar
-       gzip --stdout --best $(GLUT_NAME).tar > $(GLUT_NAME).tar.gz
+$(PACKAGE_NAME).tar.bz2: $(PACKAGE_NAME).tar
+       bzip2 --stdout --best $(PACKAGE_NAME).tar > $(PACKAGE_NAME).tar.bz2
 
-$(LIB_NAME).tar.bz2: $(LIB_NAME).tar
-       bzip2 --stdout --best $(LIB_NAME).tar > $(LIB_NAME).tar.bz2
-
-$(GLUT_NAME).tar.bz2: $(GLUT_NAME).tar
-       bzip2 --stdout --best $(GLUT_NAME).tar > $(GLUT_NAME).tar.bz2
-
-$(LIB_NAME).zip: rm_config
-       rm -f $(LIB_NAME).zip ; \
+$(PACKAGE_NAME).zip: parsers ../$(PACKAGE_DIR) manifest.txt
+       rm -f $(PACKAGE_NAME).zip ; \
        cd .. ; \
-       zip -qr $(LIB_NAME).zip $(LIB_FILES) ; \
-       mv $(LIB_NAME).zip $(DIRECTORY)
-
-$(GLUT_NAME).zip:
-       rm -f $(GLUT_NAME).zip ; \
-       cd .. ; \
-       zip -qr $(GLUT_NAME).zip $(GLUT_FILES) ; \
-       mv $(GLUT_NAME).zip $(DIRECTORY)
+       zip -q -@ $(PACKAGE_NAME).zip < $(PACKAGE_DIR)/manifest.txt ; \
+       mv $(PACKAGE_NAME).zip $(PACKAGE_DIR)
 
 md5: $(ARCHIVES)
-       @-md5sum $(LIB_NAME).tar.gz
-       @-md5sum $(LIB_NAME).tar.bz2
-       @-md5sum $(LIB_NAME).zip
-       @-md5sum $(GLUT_NAME).tar.gz
-       @-md5sum $(GLUT_NAME).tar.bz2
-       @-md5sum $(GLUT_NAME).zip
-
-.PHONY: tarballs rm_depend rm_config md5
+       @-md5sum $(PACKAGE_NAME).tar.gz
+       @-md5sum $(PACKAGE_NAME).tar.bz2
+       @-md5sum $(PACKAGE_NAME).zip
+
+.PHONY: tarballs md5
index 8607d2c..4a3fef0 100644 (file)
@@ -40,6 +40,9 @@ env = Environment(
        ENV = os.environ,
 )
 
+# XXX: This creates a many problems as it saves...
+#opts.Save('config.py', env)
+
 # Backwards compatability with old target configuration variable
 try:
     targets = ARGUMENTS['targets']
@@ -80,44 +83,6 @@ env.Append(CPPPATH = [
 if env['msvc']:
     env.Append(CPPPATH = ['#include/c99'])
 
-# Embedded
-if env['platform'] == 'embedded':
-       env.Append(CPPDEFINES = [
-               '_POSIX_SOURCE',
-               ('_POSIX_C_SOURCE', '199309L'), 
-               '_SVID_SOURCE',
-               '_BSD_SOURCE', 
-               '_GNU_SOURCE',
-               
-               'PTHREADS',
-       ])
-       env.Append(LIBS = [
-               'm',
-               'pthread',
-               'dl',
-       ])
-
-# Posix
-if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
-       env.Append(CPPDEFINES = [
-               '_POSIX_SOURCE',
-               ('_POSIX_C_SOURCE', '199309L'), 
-               '_SVID_SOURCE',
-               '_BSD_SOURCE', 
-               '_GNU_SOURCE',
-               'PTHREADS',
-               'HAVE_POSIX_MEMALIGN',
-       ])
-       if env['gcc']:
-               env.Append(CFLAGS = ['-fvisibility=hidden'])
-       if env['platform'] == 'darwin':
-               env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
-       env.Append(LIBS = [
-               'm',
-               'pthread',
-               'dl',
-       ])
-
 # for debugging
 #print env.Dump()
 
@@ -130,7 +95,7 @@ if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
 #
 
 # Create host environent
-if env['crosscompile'] and env['platform'] != 'embedded':
+if env['crosscompile'] and not env['embedded']:
     host_env = Environment(
         options = opts,
         # no tool used
@@ -179,3 +144,18 @@ SConscript(
        duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
 )
 
+
+########################################################################
+# List all aliases
+
+try:
+    from SCons.Node.Alias import default_ans
+except ImportError:
+    pass
+else:
+    aliases = default_ans.keys()
+    aliases.sort()
+    env.Help('\n')
+    env.Help('Recognized targets:\n')
+    for alias in aliases:
+        env.Help('    %s\n' % alias)
index 0a3dcdc..8657030 100644 (file)
--- a/common.py
+++ b/common.py
@@ -79,14 +79,17 @@ def AddOptions(opts):
                from SCons.Options.EnumOption import EnumOption
        opts.Add(EnumOption('build', 'build type', 'debug',
                          allowed_values=('debug', 'checked', 'profile', 'release')))
-       opts.Add(BoolOption('quiet', 'quiet command lines', 'yes'))
+       opts.Add(BoolOption('verbose', 'verbose output', 'no'))
        opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
                                                                                         allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
        opts.Add(EnumOption('platform', 'target platform', host_platform,
-                                                                                        allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded', 'cygwin', 'sunos', 'freebsd8')))
+                                                                                        allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'cygwin', 'sunos', 'freebsd8')))
+       opts.Add(BoolOption('embedded', 'embedded build', 'no'))
        opts.Add('toolchain', 'compiler toolchain', default_toolchain)
        opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no'))
        opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
        opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes'))
        opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no'))
-       opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
+       opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes'))
+       if host_platform == 'windows':
+               opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
index ebbf583..5d346d5 100644 (file)
@@ -17,13 +17,11 @@ MKLIB_OPTIONS =
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 GL_LIB_DEPS = -lX11 -lXext -lpthread -lm
 GLU_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lm -lC
-GLUT_LIB_DEPS = -L$(TOP)/lib -l$(GLU_LIB) -l$(GL_LIB) -lXi -lXmu -lX11 -lm
 GLW_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lXm -lXt -lX11
 OSMESA_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB)
 APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lpthread -lm -lC
index 5d2edc5..a048c55 100644 (file)
@@ -15,13 +15,11 @@ LIB_DIR = lib64
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 GL_LIB_DEPS = -lX11 -lXext -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lC
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lXi -lXmu -lX11 -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lXm -lXt -lX11
 APP_LIB_DEPS = -L$(TOP)/lib64 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm -lpthread -lC
 
index 6910e89..ee4147f 100644 (file)
@@ -16,7 +16,6 @@ LIB_DIR = lib64
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index 3b964f3..223e809 100644 (file)
@@ -18,6 +18,5 @@ CXXFLAGS += -fno-strict-aliasing
 MKLIB_OPTIONS = -arch aix-gcc
 GL_LIB_DEPS = -lX11 -lXext -lm
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lXi -lXmu
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -Wl,-brtl -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lX11 -lXext -lXmu -lXi
 
index 5631843..3350848 100644 (file)
@@ -15,7 +15,6 @@ MKLIB_OPTIONS = -static
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index abc01b1..37b7ea5 100644 (file)
@@ -36,7 +36,6 @@ LLVM_CFLAGS = @LLVM_CFLAGS@
 LLVM_LDFLAGS = @LLVM_LDFLAGS@
 LLVM_LIBS = @LLVM_LIBS@
 GLW_CFLAGS = @GLW_CFLAGS@
-GLUT_CFLAGS = @GLUT_CFLAGS@
 GLX_TLS = @GLX_TLS@
 DRI_CFLAGS = @DRI_CFLAGS@
 DRI_CXXFLAGS = @DRI_CXXFLAGS@
@@ -67,7 +66,6 @@ BISON = @BISON@
 # Library names (base name)
 GL_LIB = GL
 GLU_LIB = GLU
-GLUT_LIB = glut
 GLW_LIB = GLw
 OSMESA_LIB = @OSMESA_LIB@
 GLESv1_CM_LIB = GLESv1_CM
@@ -75,11 +73,11 @@ GLESv2_LIB = GLESv2
 VG_LIB = OpenVG
 GLAPI_LIB = glapi
 WAYLAND_EGL_LIB = wayland-egl
+GBM_LIB = gbm
 
 # Library names (actual file names)
 GL_LIB_NAME = @GL_LIB_NAME@
 GLU_LIB_NAME = @GLU_LIB_NAME@
-GLUT_LIB_NAME = @GLUT_LIB_NAME@
 GLW_LIB_NAME = @GLW_LIB_NAME@
 OSMESA_LIB_NAME = @OSMESA_LIB_NAME@
 EGL_LIB_NAME = @EGL_LIB_NAME@
@@ -88,11 +86,11 @@ GLESv2_LIB_NAME = @GLESv2_LIB_NAME@
 VG_LIB_NAME = @VG_LIB_NAME@
 GLAPI_LIB_NAME = @GLAPI_LIB_NAME@
 WAYLAND_EGL_LIB_NAME = @WAYLAND_EGL_LIB_NAME@
+GBM_LIB_NAME = @GBM_LIB_NAME@
 
 # Globs used to install the lib and all symlinks
 GL_LIB_GLOB = @GL_LIB_GLOB@
 GLU_LIB_GLOB = @GLU_LIB_GLOB@
-GLUT_LIB_GLOB = @GLUT_LIB_GLOB@
 GLW_LIB_GLOB = @GLW_LIB_GLOB@
 OSMESA_LIB_GLOB = @OSMESA_LIB_GLOB@
 EGL_LIB_GLOB = @EGL_LIB_GLOB@
@@ -101,6 +99,7 @@ GLESv2_LIB_GLOB = @GLESv2_LIB_GLOB@
 VG_LIB_GLOB = @VG_LIB_GLOB@
 GLAPI_LIB_GLOB = @GLAPI_LIB_GLOB@
 WAYLAND_EGL_LIB_GLOB = @WAYLAND_EGL_LIB_GLOB@
+GBM_LIB_GLOB = @GBM_LIB_GLOB@
 
 # Directories to build
 LIB_DIR = @LIB_DIR@
@@ -108,6 +107,7 @@ SRC_DIRS = @SRC_DIRS@
 GLU_DIRS = @GLU_DIRS@
 DRIVER_DIRS = @DRIVER_DIRS@
 EGL_DRIVERS_DIRS = @EGL_DRIVERS_DIRS@
+GBM_BACKEND_DIRS = @GBM_BACKEND_DIRS@
 GALLIUM_DIRS = @GALLIUM_DIRS@
 GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@
 GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@
@@ -138,8 +138,6 @@ OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @OSMESA_MESA_DEPS@ \
 EGL_LIB_DEPS = $(EXTRA_LIB_PATH) @EGL_LIB_DEPS@
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLU_MESA_DEPS@ \
        $(EXTRA_LIB_PATH) @GLU_LIB_DEPS@
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLUT_MESA_DEPS@ \
-       $(EXTRA_LIB_PATH) @GLUT_LIB_DEPS@
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLW_MESA_DEPS@ \
        $(EXTRA_LIB_PATH) @GLW_LIB_DEPS@
 APP_LIB_DEPS = $(EXTRA_LIB_PATH) @APP_LIB_DEPS@
@@ -147,7 +145,8 @@ GLESv1_CM_LIB_DEPS = $(EXTRA_LIB_PATH) @GLESv1_CM_LIB_DEPS@
 GLESv2_LIB_DEPS = $(EXTRA_LIB_PATH) @GLESv2_LIB_DEPS@
 VG_LIB_DEPS = $(EXTRA_LIB_PATH) @VG_LIB_DEPS@
 GLAPI_LIB_DEPS = $(EXTRA_LIB_PATH) @GLAPI_LIB_DEPS@
-WAYLAND_EGL_LIB_DEPS = $(EXTRA_LIBPATH) @WAYLAND_EGL_LIB_DEPS@
+WAYLAND_EGL_LIB_DEPS = $(EXTRA_LIB_PATH) @WAYLAND_EGL_LIB_DEPS@
+GBM_LIB_DEPS = $(EXTRA_LIB_PATH) @GBM_LIB_DEPS@
 
 # DRI dependencies
 MESA_MODULES = @MESA_MODULES@
@@ -178,6 +177,12 @@ DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@
 # EGL driver install directory
 EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@
 
+# VDPAU library install directory
+VDPAU_LIB_INSTALL_DIR=@VDPAU_LIB_INSTALL_DIR@
+
+# VA library install directory
+VA_LIB_INSTALL_DIR=@VA_LIB_INSTALL_DIR@
+
 # Xorg driver install directory (for xorg state-tracker)
 XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@
 
@@ -190,9 +195,6 @@ GLU_PC_REQ = @GLU_PC_REQ@
 GLU_PC_REQ_PRIV = @GLU_PC_REQ_PRIV@
 GLU_PC_LIB_PRIV = @GLU_PC_LIB_PRIV@
 GLU_PC_CFLAGS = @GLU_PC_CFLAGS@
-GLUT_PC_REQ_PRIV = @GLUT_PC_REQ_PRIV@
-GLUT_PC_LIB_PRIV = @GLUT_PC_LIB_PRIV@
-GLUT_PC_CFLAGS = @GLUT_PC_CFLAGS@
 GLW_PC_REQ_PRIV = @GLW_PC_REQ_PRIV@
 GLW_PC_LIB_PRIV = @GLW_PC_LIB_PRIV@
 GLW_PC_CFLAGS = @GLW_PC_CFLAGS@
@@ -206,6 +208,9 @@ EGL_PC_CFLAGS = @GL_PC_CFLAGS@
 WAYLAND_EGL_PC_REQ_PRIV = @WAYLAND_EGL_PC_REQ_PRIV@
 WAYLAND_EGL_PC_LIB_PRIV = @WAYLAND_EGL_PC_LIB_PRIV@
 WAYLAND_EGL_PC_CFLAGS = @WAYLAND_EGL_PC_CFLAGS@
+GBM_PC_REQ_PRIV = @GBM_PC_REQ_PRIV@
+GBM_PC_LIB_PRIV = @GBM_PC_LIB_PRIV@
+GBM_PC_CFLAGS = @GBM_PC_CFLAGS@
 
 XCB_DRI2_CFLAGS = @XCB_DRI2_CFLAGS@
 XCB_DRI2_LIBS = @XCB_DRI2_LIBS@
index ac8d6fc..91ea6f7 100644 (file)
@@ -90,7 +90,7 @@ else
 endif
 
 # Directories
-SRC_DIRS = gallium mesa glu glut/beos
+SRC_DIRS = gallium mesa glu
 GLU_DIRS = sgi
 DRIVER_DIRS = beos
 
@@ -98,6 +98,5 @@ DRIVER_DIRS = beos
 GL_LIB_DEPS = 
 OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
 GLU_LIB_DEPS =  
-GLUT_LIB_DEPS = -lgame -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
 APP_LIB_DEPS = -lbe -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -l$(GLUT_LIB)
 
index 9527f61..41e7ba8 100644 (file)
@@ -33,7 +33,6 @@ CXXFLAGS =  -ggdb3 -Os -Wall -fno-strict-aliasing -fvisibility=hidden \
 # Library names (actual file names)
 GL_LIB_NAME = lib$(GL_LIB).dylib
 GLU_LIB_NAME = lib$(GLU_LIB).dylib
-GLUT_LIB_NAME = lib$(GLUT_LIB).dylib
 GLW_LIB_NAME = lib$(GLW_LIB).dylib
 OSMESA_LIB_NAME = lib$(OSMESA_LIB).dylib
 VG_LIB_NAME = lib$(VG_LIB).dylib
@@ -41,7 +40,6 @@ VG_LIB_NAME = lib$(VG_LIB).dylib
 # globs used to install the lib and all symlinks
 GL_LIB_GLOB = lib$(GL_LIB).*dylib
 GLU_LIB_GLOB = lib$(GLU_LIB).*dylib
-GLUT_LIB_GLOB = lib$(GLUT_LIB).*dylib
 GLW_LIB_GLOB = lib$(GLW_LIB).*dylib
 OSMESA_LIB_GLOB = lib$(OSMESA_LIB).*dylib
 VG_LIB_GLOB = lib$(VG_LIB).*dylib
@@ -49,12 +47,11 @@ VG_LIB_GLOB = lib$(VG_LIB).*dylib
 GL_LIB_DEPS = -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXext -lm -lpthread
 OSMESA_LIB_DEPS =
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB)  -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXmu -lXi -lXext
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXt
 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 = glsl mapi/glapi mapi/vgapi glx/apple mesa gallium glu glut/glx
+SRC_DIRS = glsl mapi/glapi mapi/vgapi glx/apple mesa gallium glu
 GLU_DIRS = sgi
 DRIVER_DIRS = osmesa
 #DRIVER_DIRS = dri
index b7acfd2..e839a1e 100644 (file)
@@ -9,7 +9,7 @@ CONFIG_NAME = default
 
 # Version info
 MESA_MAJOR=7
-MESA_MINOR=11
+MESA_MINOR=12
 MESA_TINY=0
 MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
 
@@ -54,7 +54,6 @@ INDENT_FLAGS = -i4 -nut -br -brs -npcs -ce -T GLubyte -T GLbyte -T Bool
 # Library names (base name)
 GL_LIB = GL
 GLU_LIB = GLU
-GLUT_LIB = glut
 GLW_LIB = GLw
 OSMESA_LIB = OSMesa
 EGL_LIB = EGL
@@ -63,12 +62,11 @@ GLESv2_LIB = GLESv2
 VG_LIB = OpenVG
 GLAPI_LIB = glapi
 WAYLAND_EGL_LIB = wayland-egl
-
+GBM_LIB = gbm
 
 # Library names (actual file names)
 GL_LIB_NAME = lib$(GL_LIB).so
 GLU_LIB_NAME = lib$(GLU_LIB).so
-GLUT_LIB_NAME = lib$(GLUT_LIB).so
 GLW_LIB_NAME = lib$(GLW_LIB).so
 OSMESA_LIB_NAME = lib$(OSMESA_LIB).so
 EGL_LIB_NAME = lib$(EGL_LIB).so
@@ -77,11 +75,11 @@ GLESv2_LIB_NAME = lib$(GLESv2_LIB).so
 VG_LIB_NAME = lib$(VG_LIB).so
 GLAPI_LIB_NAME = lib$(GLAPI_LIB).so
 WAYLAND_EGL_LIB_NAME = lib$(WAYLAND_EGL_LIB).so
+GBM_LIB_NAME = lib$(GBM_LIB).so
 
 # globs used to install the lib and all symlinks
 GL_LIB_GLOB = $(GL_LIB_NAME)*
 GLU_LIB_GLOB = $(GLU_LIB_NAME)*
-GLUT_LIB_GLOB = $(GLUT_LIB_NAME)*
 GLW_LIB_GLOB = $(GLW_LIB_NAME)*
 OSMESA_LIB_GLOB = $(OSMESA_LIB_NAME)*
 EGL_LIB_GLOB = $(EGL_LIB_NAME)*
@@ -90,6 +88,7 @@ GLESv2_LIB_GLOB = $(GLESv2_LIB_NAME)*
 VG_LIB_GLOB = $(VG_LIB_NAME)*
 GLAPI_LIB_GLOB = $(GLAPI_LIB_NAME)*
 WAYLAND_EGL_LIB_GLOB = $(WAYLAND_EGL_LIB_NAME)*
+GBM_LIB_GLOB = $(GBM_LIB_NAME)*
 
 DRI_CFLAGS = $(CFLAGS)
 DRI_CXXFLAGS = $(CXXFLAGS)
@@ -106,13 +105,16 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2
 # Directories to build
 LIB_DIR = lib
 SRC_DIRS = glsl mapi/glapi mapi/vgapi mesa \
-       gallium egl gallium/winsys gallium/targets glu glut/glx glw
+       gallium egl gallium/winsys gallium/targets glu glw
 GLU_DIRS = sgi
 DRIVER_DIRS = x11 osmesa
 
 # EGL drivers to build
 EGL_DRIVERS_DIRS = glx
 
+# gbm backends to build
+GBM_BACKEND_DIRS = dri
+
 # Gallium directories and 
 GALLIUM_DIRS = auxiliary drivers state_trackers
 GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
@@ -132,7 +134,6 @@ GL_LIB_DEPS     = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
 EGL_LIB_DEPS    = $(EXTRA_LIB_PATH) -ldl -lpthread
 OSMESA_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
 GLU_LIB_DEPS    = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-GLUT_LIB_DEPS   = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXmu -lXi -lm
 GLW_LIB_DEPS    = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lXt -lX11
 APP_LIB_DEPS    = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
 GLESv1_CM_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread
@@ -140,8 +141,9 @@ GLESv2_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread
 VG_LIB_DEPS    = $(EXTRA_LIB_PATH) -lpthread
 GLAPI_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread
 WAYLAND_EGL_LIB_DEPS = $(EXTRA_LIB_PATH) -lwayland-client -ldrm
+GBM_LIB_DEPS = $(EXTRA_LIB_PATH) -ludev -ldl
 
-# Program dependencies - specific GL/glut libraries added in Makefiles
+# Program dependencies - specific GL libraries added in Makefiles
 APP_LIB_DEPS = -lm
 X11_LIBS = -lX11
 
@@ -159,6 +161,9 @@ DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
 # EGL driver install directory
 EGL_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/egl
 
+# gbm backend install directory
+GBM_BACKEND_INSTALL_DIR = $(INSTALL_LIB_DIR)/gbm
+
 # Xorg driver install directory (for xorg state-tracker)
 XORG_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/xorg/modules/drivers
 
@@ -171,9 +176,6 @@ GLU_PC_REQ = gl
 GLU_PC_REQ_PRIV =
 GLU_PC_LIB_PRIV =
 GLU_PC_CFLAGS =
-GLUT_PC_REQ_PRIV =
-GLUT_PC_LIB_PRIV =
-GLUT_PC_CFLAGS =
 GLW_PC_REQ_PRIV =
 GLW_PC_LIB_PRIV =
 GLW_PC_CFLAGS =
@@ -191,3 +193,6 @@ VG_PC_CFLAGS =
 WAYLAND_EGL_PC_REQ_PRIV =
 WAYLAND_EGL_PC_LIB_PRIV =
 WAYLAND_EGL_PC_CFLAGS =
+GBM_PC_REQ_PRIV =
+GBM_PC_LIB_PRIV =
+GBM_PC_CFLAGS =
index 976ddd1..00d46be 100644 (file)
@@ -21,7 +21,6 @@ CFLAGS += $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(DEFINES) $(X11_INCLUDES) -ff
 
 CXXFLAGS += $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(DEFINES) $(X11_INCLUDES)
 
-GLUT_CFLAGS = -fexceptions
 
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
index 23cf58a..fdf4b29 100644 (file)
@@ -38,12 +38,11 @@ DRI_LIB_DEPS = $(MESA_MODULES) -L/usr/local/lib -lm -pthread -lexpat $(LIBDRM_LI
 GL_LIB_DEPS = -L/usr/local/lib -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
        -lm -pthread $(LIBDRM_LIB)
 
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/local/lib -lGLU -lGL -lX11 -lXmu -lXt -lXi -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/local/lib -lGL -lXt -lX11
 
 
 # Directories
-SRC_DIRS = glx gallium mesa glu glut/glx glw
+SRC_DIRS = glx gallium mesa glu glw
 DRIVER_DIRS = dri
 
 DRM_SOURCE_PATH=$(TOP)/../drm
index be396f8..40f243c 100644 (file)
@@ -10,7 +10,6 @@ CXX = g++
 
 CFLAGS = -ansi -O3 -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include  -DUSE_XSHM
 CXXFLAGS = -ansi -O3 -D_HPUX_SOURCE
-GLUT_CFLAGS = -fexceptions
 
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
index 6101a4e..18847d9 100644 (file)
@@ -16,7 +16,6 @@ MKLIB_OPTIONS = -static
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
@@ -24,7 +23,6 @@ OSMESA_LIB_NAME = libOSMesa.a
 GL_LIB_DEPS = 
 OSMESA_LIB_DEPS = 
 GLU_LIB_DEPS = 
-GLUT_LIB_DEPS = 
 GLW_LIB_DEPS = 
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi -lpthread -lm -lstdc++
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm -lstdc++
index 035ef79..d783ae0 100644 (file)
@@ -18,7 +18,6 @@ MKLIB_OPTIONS =
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
@@ -26,5 +25,4 @@ OSMESA_LIB_NAME = libOSMesa.a
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB)
 GL_LIB_DEPS = -L/usr/lib/X11R6/ -L/usr/contrib/X11R6/lib/ -lXext -lXt -lXi -lX11 -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lCsup -lcl
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(GL_LIB_DEPS)
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(GL_LIB_DEPS)
index b8e8436..58a1c63 100644 (file)
@@ -18,7 +18,6 @@ MKLIB_OPTIONS = -static
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index cba166a..fa3d4c2 100644 (file)
@@ -18,7 +18,6 @@ MKLIB_OPTIONS = -static
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index 3833c07..0f963e2 100644 (file)
@@ -19,7 +19,6 @@ LIB_DIR = lib64
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
@@ -27,5 +26,4 @@ OSMESA_LIB_NAME = libOSMesa.a
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB)
 GL_LIB_DEPS = -L/usr/lib/X11R6/pa20_64 -L/usr/contrib/X11R6/lib/pa20_64 -lXext -lXmu -lXt -lXi -lX11 -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lCsup -lcl
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(GL_LIB_DEPS)
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(GL_LIB_DEPS)
index 32944f9..4161d53 100644 (file)
@@ -19,7 +19,6 @@ LIB_DIR = lib64
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index b94560b..e27a221 100644 (file)
@@ -19,12 +19,10 @@ LIB_DIR = lib64
 # Library names (actual file names)
 GL_LIB_NAME = libGL.so
 GLU_LIB_NAME = libGLU.so
-GLUT_LIB_NAME = libglut.so
 GLW_LIB_NAME = libGLw.so
 OSMESA_LIB_NAME = libOSMesa.so
 
 # Library/program dependencies
 GL_LIB_DEPS = -L/usr/lib/X11R6/ -L/usr/contrib/X11R6/lib/ -lXext -lXmu -lXt -lXi -lX11 -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lCsup -lcl
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(GL_LIB_DEPS)
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(GL_LIB_DEPS)
index e094c9f..de24a15 100644 (file)
@@ -19,7 +19,6 @@ LIB_DIR = lib64
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index ea9dabc..e61f624 100644 (file)
@@ -19,7 +19,6 @@ APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -64 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -l
 
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index fe47ccd..47b5e50 100644 (file)
@@ -15,11 +15,10 @@ GLW_SOURCES = GLwDrawA.c GLwMDrawA.c
 
 LIB_DIR = lib32
 
-APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -n32 -glut -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lpthread -lm -lC
+APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -n32 -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lpthread -lm -lC
 
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index 2d265df..58fbe4e 100644 (file)
@@ -15,11 +15,10 @@ GLW_SOURCES = GLwDrawA.c GLwMDrawA.c
 
 LIB_DIR = lib32
 
-APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -32 -glut -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm -lC
+APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -32 -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm -lC
 
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index c60f0d8..2560973 100644 (file)
@@ -33,6 +33,5 @@ CXXFLAGS = -Wall -Wpointer-arith $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
 CFLAGS += -fno-strict-aliasing
 CXXFLAGS += -fno-strict-aliasing
 
-GLUT_CFLAGS = -fexceptions
 
 EXTRA_LIB_PATH = -L/usr/X11R6/lib
index 65bf0c2..8038739 100644 (file)
@@ -9,14 +9,12 @@ CC = gcc
 CXX = g++
 CFLAGS = -O3 -mcpu=ev5 -ansi -mieee -pedantic -fPIC -D_XOPEN_SOURCE -DUSE_XSHM
 CXXFLAGS = -O3 -mcpu=ev5 -ansi -mieee -pedantic -fPIC -D_XOPEN_SOURCE
-GLUT_CFLAGS = -fexceptions
 
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
 CXXFLAGS += -fno-strict-aliasing
 
 GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
 
index 53808d7..33938e8 100644 (file)
@@ -9,7 +9,6 @@ CC = gcc
 CXX = g++
 CFLAGS = -O3 -mcpu=ev5 -ansi -mieee -pedantic -D_XOPEN_SOURCE -DUSE_XSHM
 CXXFLAGS = -O3 -mcpu=ev5 -ansi -mieee -pedantic -D_XOPEN_SOURCE
-GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -static
 PIC_FLAGS =
 
@@ -20,12 +19,10 @@ CXXFLAGS += -fno-strict-aliasing
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 
 GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -L/usr/X11R6/lib -lX11 -lm
index 606a11a..e87e69a 100644 (file)
@@ -38,7 +38,7 @@ CXXFLAGS = $(COMMON_C_CPP_FLAGS)
 
 # Omitting glw here:
 SRC_DIRS = glsl mapi/glapi mapi/vgapi mesa \
-       gallium gallium/winsys gallium/targets glu glut/glx
+       gallium gallium/winsys gallium/targets glu
 
 # Build no traditional Mesa drivers:
 DRIVER_DIRS =
index c4132f4..b82481e 100644 (file)
@@ -32,7 +32,6 @@ CFLAGS = -Wall -Wmissing-prototypes -std=c99 -ffast-math \
 
 CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
 
-GLUT_CFLAGS = -fexceptions
 
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
index 7518080..021aa3e 100644 (file)
@@ -49,7 +49,7 @@ DRI_LIB_DEPS  = $(MESA_MODULES) $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(L
 GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \
                 $(LIBDRM_LIB) $(shell pkg-config --libs xcb) $(shell pkg-config --libs x11-xcb) $(shell pkg-config --libs xcb-glx)
 
-SRC_DIRS = glx gallium mesa glu glut/glx glw
+SRC_DIRS = glx gallium mesa glu glw
 
 DRIVER_DIRS = dri
 DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \
index 4fc6384..45b482a 100644 (file)
@@ -9,10 +9,8 @@ CFLAGS += -DUSE_GLFBDEV_DRIVER
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
 
-SRC_DIRS += glut/fbdev
 DRIVER_DIRS = fbdev osmesa
 
 GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread
 OSMESA_LIB_DEPS = -lm -lpthread
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lgpm -lm
 
index bd11897..1594256 100644 (file)
@@ -9,12 +9,10 @@ CC = icc
 CXX = icpc
 CFLAGS = -O3 -ansi -KPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include
 CXXFLAGS = -O3 -ansi -KPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include
-GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -arch icc-istatic
 
 GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) 
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(GL_LIB_DEPS)
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB)
 
index ce8daf1..b5c33a5 100644 (file)
@@ -9,19 +9,16 @@ CC = icc
 CXX = icpc
 CFLAGS = -O3 -ansi -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include
 CXXFLAGS = -O3 -ansi -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include
-GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -static -arch icc-istatic
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 GL_LIB_DEPS =
 GLU_LIB_DEPS =
-GLUT_LIB_DEPS =
 GLW_LIB_DEPS =
 APP_LIB_DEPS = -i-static -cxxlib-icc -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lpthread -lm -lcxa -lunwind
 
index d90a1da..2cfb202 100644 (file)
@@ -9,11 +9,9 @@ CC = icc
 CXX = g++
 CFLAGS = -O3 -tpp6 -axK -KPIC -D_GCC_LIMITS_H_ -D__GNUC__ -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include
 CXXFLAGS = -O3
-GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -arch icc
 
 GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
 
 MESA_ASM_SOURCES = $(X86_SOURCES)
index 384db3b..d031196 100644 (file)
@@ -9,18 +9,15 @@ CC = icc
 CXX = icpc
 CFLAGS = -O3 -tpp6 -axK -D_GCC_LIMITS_H_ -D__GNUC__ -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include
 CXXFLAGS = -O3 -tpp6 -axK -DPTHREADS
-GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -static -arch icc
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
 GL_LIB_DEPS =
-GLUT_LIB_DEPS =
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm -lpthread -lcxa -lunwind
 
 MESA_ASM_SOURCES = $(X86_SOURCES)
index 507382a..82868c4 100644 (file)
@@ -48,5 +48,5 @@ GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl
 
 
 # Directories
-SRC_DIRS = glx glu glut/glx glw
+SRC_DIRS = glx glu glw
 DRIVER_DIRS =
index 359bee2..ef6c7bb 100644 (file)
@@ -30,7 +30,7 @@ else
 endif
 
 ifeq ($(MESA_LLVM),1)
-  LLVM_CFLAGS=`llvm-config --cppflags`
+  LLVM_CFLAGS=`llvm-config --cppflags|sed 's/-DNDEBUG\>//g'`
   LLVM_CXXFLAGS=`llvm-config --cxxflags` -Wno-long-long
   LLVM_LDFLAGS = $(shell llvm-config --ldflags)
   LLVM_LIBS = $(shell llvm-config --libs)
@@ -42,3 +42,6 @@ endif
 
 LD = g++
 GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -lstdc++
+
+# to allow the NV drivers to compile
+LIBDRM_CFLAGS = $(shell pkg-config --cflags libdrm)
index 7220794..d3af7a9 100644 (file)
@@ -17,7 +17,6 @@ MKLIB_OPTIONS = -static
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
@@ -30,7 +29,6 @@ DRIVER_DIRS = osmesa
 GL_LIB_DEPS =
 OSMESA_LIB_DEPS =
 GLU_LIB_DEPS =
-GLUT_LIB_DEPS =
 GLW_LIB_DEPS =
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
                $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm
index 3f3dc55..0a4ba43 100644 (file)
@@ -10,6 +10,5 @@ PIC_FLAGS =
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
index 907904b..2b97daa 100644 (file)
@@ -10,7 +10,6 @@ PIC_FLAGS =
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
@@ -18,7 +17,6 @@ OSMESA_LIB_NAME = libOSMesa.a
 GL_LIB_DEPS = 
 OSMESA_LIB_DEPS = 
 GLU_LIB_DEPS = 
-GLUT_LIB_DEPS = 
 GLW_LIB_DEPS = 
 
 # Need to specify all libraries we may need
index 626d579..89a0e3e 100644 (file)
@@ -10,7 +10,6 @@ PIC_FLAGS =
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
@@ -18,7 +17,6 @@ OSMESA_LIB_NAME = libOSMesa.a
 GL_LIB_DEPS = 
 OSMESA_LIB_DEPS = 
 GLU_LIB_DEPS = 
-GLUT_LIB_DEPS = 
 GLW_LIB_DEPS = 
 
 # Need to specify all libraries we may need
index 16c8731..dba6299 100644 (file)
@@ -10,7 +10,6 @@ PIC_FLAGS =
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
@@ -18,7 +17,6 @@ OSMESA_LIB_NAME = libOSMesa.a
 GL_LIB_DEPS = 
 OSMESA_LIB_DEPS = 
 GLU_LIB_DEPS = 
-GLUT_LIB_DEPS = 
 GLW_LIB_DEPS = 
 
 # Need to specify all libraries we may need
index aec4569..c65e901 100644 (file)
@@ -9,7 +9,6 @@ CC = gcc
 CXX = g++
 CFLAGS = -O2 -fPIC -DUSE_XSHM -I/usr/X11R6/include -DHZ=100
 CXXFLAGS = -O2 -fPIC
-GLUT_CFLAGS = -fexceptions
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
 
 # Work around aliasing bugs - developers should comment this out
index bd19fa8..982675f 100644 (file)
@@ -17,6 +17,5 @@ CXXFLAGS += -fno-strict-aliasing
 GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm
 OSMESA_LIB_DEPS = -lm
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi -lm
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
 
index 88a2ecc..5a2e1f2 100644 (file)
@@ -12,5 +12,4 @@ CXXFLAGS = -O2 -std ansi -ieee -DPTHREADS -D_REENTRANT
 
 GL_LIB_DEPS = -lX11 -lXext -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXmu -lXt -lXi -lm
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lpthread -lm
index e00f7ce..f20005d 100644 (file)
@@ -13,5 +13,4 @@ MKLIB_OPTIONS = -static
 
 GL_LIB_DEPS =
 GLU_LIB_DEPS =
-GLUT_LIB_DEPS =
 APP_LIB_DEPS = -noso -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -so_archive -lX11 -lXext -lXmu -lXi -lpthread -lm -lcxx
index a5a7a63..3c64d35 100644 (file)
@@ -9,10 +9,9 @@ CC = cc
 CFLAGS = -Xa -xO3 -xpentium -KPIC -I/usr/openwin/include -DUSE_XSHM
 MKLIB_OPTIONS = -static
 
-APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/openwin/lib -R/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm -lglut -lGLU -lGL
+APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/openwin/lib -R/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm -lGLU -lGL
 
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
index 616bfdf..065ce36 100644 (file)
@@ -9,7 +9,6 @@ CC = gcc
 CXX = g++
 CFLAGS = -O3 -march=i486 -fPIC -I/usr/openwin/include -DUSE_XSHM
 CXXFLAGS = -O3 -march=i486 -fPIC
-GLUT_CFLAGS = -fexceptions
 
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
@@ -17,5 +16,4 @@ CXXFLAGS += -fno-strict-aliasing
 
 GL_LIB_DEPS = -L/usr/openwin/lib -lX11 -lXext -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/openwin/lib -lX11 -lXmu -lXt -lXi -lm
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/openwin/lib -R/usr/openwin/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lX11 -lXext -lXi -lXmu
index 4850284..dd12084 100644 (file)
@@ -9,7 +9,6 @@ CC = gcc
 CXX = g++
 CFLAGS = -O3 -march=i486 -fPIC -I/usr/openwin/include -DUSE_XSHM
 CXXFLAGS = -O3 -march=i486 -fPIC
-GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -static
 
 # Work around aliasing bugs - developers should comment this out
@@ -18,11 +17,9 @@ CXXFLAGS += -fno-strict-aliasing
 
 GL_LIB_DEPS = -L/usr/openwin/lib -lX11 -lXext -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/openwin/lib -lX11 -lXmu -lXt -lXi -lm
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/openwin/lib -R/usr/openwin/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lX11 -lXext -lXi -lXmu
 
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
index 0942291..85439c9 100644 (file)
@@ -9,7 +9,6 @@ CC = gcc
 CXX = g++
 CFLAGS = -fPIC -O3 -I/usr/openwin/include -I/usr/include/X11R5 -I/usr/include/X11R5 -DUSE_XSHM -DSUNOS4
 CXXFLAGS = -fPIC -O3 -I/usr/openwin/include -DSUNOS4
-GLUT_CFLAGS = -fexceptions -DSOLARIS_2_4_BUG
 
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
index 9135fa7..b05184d 100644 (file)
@@ -12,7 +12,6 @@ MKLIB_OPTIONS = -static
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
@@ -20,6 +19,5 @@ OSMESA_LIB_NAME = libOSMesa.a
 GL_LIB_DEPS = 
 OSMESA_LIB_DEPS = 
 GLU_LIB_DEPS = 
-GLUT_LIB_DEPS = 
 GLW_LIB_DEPS = 
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi -lpthread -lm
index 6dd7539..b3d3fc6 100644 (file)
@@ -9,10 +9,8 @@ CC = cc
 CXX = c++
 CFLAGS = -KPIC -Xa -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM
 CXXFLAGS = -KPIC -Xa -O -I/usr/openwin/include -I/usr/dt/include
-GLUT_CFLAGS = -DSOLARIS_2_4_BUG
 
 GL_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -lX11 -lXext -lXmu -lXi -lm
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lCrun -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
index 571ff24..e4d3403 100644 (file)
@@ -26,7 +26,6 @@ CFLAGS   = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
 CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
        -I/usr/openwin/include
 
-GLUT_CFLAGS = -fexceptions -DSOLARIS_2_4_BUG
 
 # Work around aliasing bugs - developers should comment this out
 CFLAGS += -fno-strict-aliasing
@@ -36,5 +35,4 @@ CXXFLAGS += -fno-strict-aliasing
 EXTRA_LIB_PATH=-L/usr/openwin/lib
 
 GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXmu -lXi -lm
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
index 2740805..93132b6 100644 (file)
@@ -9,11 +9,9 @@ CC = cc
 CXX = c++
 CFLAGS = -KPIC -Xa -native -fast -xO5 -xlibmil -xsafe=mem -xdepend -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DSOLARIS_2_4_BUG
 CXXFLAGS = -KPIC -Xa -native -fast -xO5 -xlibmil -xsafe=mem -xdepend -I/usr/openwin/include -I/usr/dt/include
-GLUT_CFLAGS = -DSOLARIS_2_4_BUG
 
 GL_LIB_DEPS = -L/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lCrun
 
index cdaf3ee..19ff67b 100644 (file)
@@ -9,10 +9,8 @@ CC = cc
 CXX = CC
 CFLAGS = -xarch=v8 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DPTHREADS
 CXXFLAGS = -xarch=v8 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DPTHREADS
-GLUT_CFLAGS = -DSOLARIS_2_4_BUG
 
 GL_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -lX11 -lXext -lXmu -lXi -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lCstd -lCrun
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
index 5e428b1..edb3227 100644 (file)
@@ -11,6 +11,5 @@ CC = cc
 CXX = CC
 CFLAGS = -xarch=v8 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DPTHREADS
 CXXFLAGS = -xarch=v8 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DPTHREADS
-GLUT_CFLAGS = -DSOLARIS_2_4_BUG
 
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11 -lXext -lXmu -lXi -lpthread -lm -lCstd -lCrun
index ea2ab23..28b402e 100644 (file)
@@ -13,11 +13,9 @@ CC = cc
 CXX = CC
 CFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DPTHREADS
 CXXFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DPTHREADS
-GLUT_CFLAGS = -DSOLARIS_2_4_BUG
 
 GL_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -lX11 -lXext -lXmu -lXi -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lCstd -lCrun
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
 
index 8656251..a303f89 100644 (file)
@@ -26,10 +26,8 @@ CXXFLAGS += -fno-strict-aliasing
 
 CFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DPTHREADS
 #CXXFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DPTHREADS
-GLUT_CFLAGS = -DSOLARIS_2_4_BUG
 
 GL_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -lX11 -lXext -lXmu -lXi -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lCstd -lCrun
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
index 4919570..ccf5eb3 100644 (file)
@@ -13,6 +13,5 @@ CC = cc
 CXX = CC
 CFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DPTHREADS
 CXXFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DPTHREADS
-GLUT_CFLAGS = -DSOLARIS_2_4_BUG
 
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11 -lXext -lXmu -lXi -lpthread -lm -lCstd -lCrun
index 455b693..4414e7a 100644 (file)
@@ -9,7 +9,6 @@ CC = gcc
 CXX = g++
 CFLAGS = -pedantic -O2
 CXXFLAGS = -pedantic -O2
-GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -static
 
 # Work around aliasing bugs - developers should comment this out
@@ -18,7 +17,6 @@ CXXFLAGS += -fno-strict-aliasing
 
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
-GLUT_LIB_NAME = libglut.a
 GLW_LIB_NAME = libGLw.a
 OSMESA_LIB_NAME = libOSMesa.a
 
index 69513c1..1b1823a 100644 (file)
@@ -17,13 +17,17 @@ AC_INIT([Mesa],[mesa_version],
 AC_CONFIG_AUX_DIR([bin])
 AC_CANONICAL_HOST
 
+dnl Save user CFLAGS and CXXFLAGS so one can override the default ones
+USER_CFLAGS="$CFLAGS"
+USER_CXXFLAGS="$CXXFLAGS"
+
 dnl Versions for external dependencies
 LIBDRM_REQUIRED=2.4.24
 LIBDRM_RADEON_REQUIRED=2.4.24
 LIBDRM_INTEL_REQUIRED=2.4.24
 LIBDRM_NOUVEAU_REQUIRED=0.6
-DRI2PROTO_REQUIRED=2.1
-GLPROTO_REQUIRED=1.4.11
+DRI2PROTO_REQUIRED=2.6
+GLPROTO_REQUIRED=1.4.14
 LIBDRM_XORG_REQUIRED=2.4.24
 LIBKMS_XORG_REQUIRED=1.0.0
 
@@ -85,7 +89,7 @@ if test "x$GCC" = xyes -a "x$CLANG" = xno; then
     GCC_VERSION=`$CC -dumpversion`
     if test $? -eq 0; then
         major=`echo $GCC_VERSION | cut -d. -f1`
-        minor=`echo $GCC_VERSION | cut -d. -f1`
+        minor=`echo $GCC_VERSION | cut -d. -f2`
     fi
 
     if test $major -lt 3 -o $major -eq 3 -a $minor -lt 3 ; then
@@ -177,8 +181,10 @@ if test "x$GXX" = xyes; then
     AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
     VISIBILITY_CXXFLAGS="-fvisibility=hidden"
     CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
+    AC_LANG_PUSH([C++])
     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
                   [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
+    AC_LANG_POP([C++])
 
     # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
     CXXFLAGS=$save_CXXFLAGS
@@ -187,6 +193,15 @@ if test "x$GXX" = xyes; then
     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
 fi
 
+dnl even if the compiler appears to support it, using visibility attributes isn't
+dnl going to do anything useful currently on cygwin apart from emit lots of warnings
+case "$host_os" in
+cygwin*)
+    VISIBILITY_CFLAGS=""
+    VISIBILITY_CXXFLAGS=""
+    ;;
+esac
+
 AC_SUBST([VISIBILITY_CFLAGS])
 AC_SUBST([VISIBILITY_CXXFLAGS])
 
@@ -352,6 +367,7 @@ GLESv2_LIB_NAME='lib$(GLESv2_LIB).'${LIB_EXTENSION}
 VG_LIB_NAME='lib$(VG_LIB).'${LIB_EXTENSION}
 GLAPI_LIB_NAME='lib$(GLAPI_LIB).'${LIB_EXTENSION}
 WAYLAND_EGL_LIB_NAME='lib$(WAYLAND_EGL_LIB).'${LIB_EXTENSION}
+GBM_LIB_NAME='lib$(GBM_LIB).'${LIB_EXTENSION}
 
 GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
 GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
@@ -365,6 +381,7 @@ GLESv2_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv2_LIB)'${LIB_VERSION_SEPARATOR}'*'${LI
 VG_LIB_GLOB=${LIB_PREFIX_GLOB}'$(VG_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
 GLAPI_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLAPI_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
 WAYLAND_EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(WAYLAND_EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
+GBM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GBM_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
 
 AC_SUBST([GL_LIB_NAME])
 AC_SUBST([GLU_LIB_NAME])
@@ -377,6 +394,7 @@ AC_SUBST([GLESv2_LIB_NAME])
 AC_SUBST([VG_LIB_NAME])
 AC_SUBST([GLAPI_LIB_NAME])
 AC_SUBST([WAYLAND_EGL_LIB_NAME])
+AC_SUBST([GBM_LIB_NAME])
 
 AC_SUBST([GL_LIB_GLOB])
 AC_SUBST([GLU_LIB_GLOB])
@@ -389,6 +407,7 @@ AC_SUBST([GLESv2_LIB_GLOB])
 AC_SUBST([VG_LIB_GLOB])
 AC_SUBST([GLAPI_LIB_GLOB])
 AC_SUBST([WAYLAND_EGL_LIB_GLOB])
+AC_SUBST([GBM_LIB_GLOB])
 
 dnl
 dnl Arch/platform-specific settings
@@ -507,7 +526,7 @@ if test "x$enable_selinux" = "xyes"; then
     DEFINES="$DEFINES -DMESA_SELINUX"
 fi
 
-dnl Determine which APIs to support
+dnl Options for APIs
 AC_ARG_ENABLE([opengl],
     [AS_HELP_STRING([--disable-opengl],
         [disable support for standard OpenGL API @<:@default=no@:>@])],
@@ -523,32 +542,118 @@ AC_ARG_ENABLE([gles2],
         [enable support for OpenGL ES 2.x API @<:@default=no@:>@])],
     [enable_gles2="$enableval"],
     [enable_gles2=no])
-AC_ARG_ENABLE([gles-overlay],
-    [AS_HELP_STRING([--enable-gles-overlay],
-        [DEPRECATED.  Same as --enable-gles1 and --enable-gles2])],
-    [enable_gles1="$enableval"; enable_gles2="$enableval"],
-    [])
-
 AC_ARG_ENABLE([openvg],
     [AS_HELP_STRING([--enable-openvg],
         [enable support for OpenVG API @<:@default=no@:>@])],
     [enable_openvg="$enableval"],
     [enable_openvg=no])
 
-dnl smooth the transition; should be removed eventually
-if test "x$enable_openvg" = xno; then
-    case "x$with_state_trackers" in
-    x*vega*)
-        AC_MSG_WARN([vega state tracker is enabled without --enable-openvg])
-        enable_openvg=yes
-        ;;
-    esac
-fi
+AC_ARG_ENABLE([dri],
+    [AS_HELP_STRING([--enable-dri],
+        [enable DRI modules @<:@default=auto@:>@])],
+    [enable_dri="$enableval"],
+    [enable_dri=auto])
+AC_ARG_ENABLE([glx],
+    [AS_HELP_STRING([--enable-glx],
+        [enable GLX library @<:@default=auto@:>@])],
+    [enable_glx="$enableval"],
+    [enable_glx=auto])
+AC_ARG_ENABLE([osmesa],
+    [AS_HELP_STRING([--enable-osmesa],
+        [enable OSMesa library @<:@default=auto@:>@])],
+    [enable_osmesa="$enableval"],
+    [enable_osmesa=auto])
+AC_ARG_ENABLE([egl],
+    [AS_HELP_STRING([--disable-egl],
+        [disable EGL library @<:@default=enabled@:>@])],
+    [enable_egl="$enableval"],
+    [enable_egl=yes])
+
+AC_ARG_ENABLE([xorg],
+    [AS_HELP_STRING([--enable-xorg],
+        [enable support for X.Org DDX API @<:@default=no@:>@])],
+    [enable_xorg="$enableval"],
+    [enable_xorg=no])
+AC_ARG_ENABLE([xa],
+    [AS_HELP_STRING([--enable-xa],
+        [enable build of the XA X Acceleration API @<:@default=no@:>@])],
+    [enable_xa="$enableval"],
+    [enable_xa=no])
+AC_ARG_ENABLE([d3d1x],
+    [AS_HELP_STRING([--enable-d3d1x],
+        [enable support for Direct3D 10 & 11 low-level API @<:@default=no@:>@])],
+    [enable_d3d1x="$enableval"],
+    [enable_d3d1x=no])
+AC_ARG_ENABLE([gbm],
+   [AS_HELP_STRING([--enable-gbm],
+         [enable gbm library @<:@default=auto@:>@])],
+   [enable_gbm="$enableval"],
+   [enable_gbm=auto])
+
+AC_ARG_ENABLE([xvmc],
+   [AS_HELP_STRING([--enable-xvmc],
+         [enable xvmc library @<:@default=auto@:>@])],
+   [enable_xvmc="$enableval"],
+   [enable_xvmc=auto])
+AC_ARG_ENABLE([vdpau],
+   [AS_HELP_STRING([--enable-vdpau],
+         [enable vdpau library @<:@default=auto@:>@])],
+   [enable_vdpau="$enableval"],
+   [enable_vdpau=auto])
+AC_ARG_ENABLE([va],
+   [AS_HELP_STRING([--enable-va],
+         [enable va library @<:@default=auto@:>@])],
+   [enable_va="$enableval"],
+   [enable_va=auto])
+
+AC_ARG_ENABLE([xlib_glx],
+    [AS_HELP_STRING([--enable-xlib-glx],
+        [make GLX library Xlib-based instead of DRI-based @<:@default=disable@:>@])],
+    [enable_xlib_glx="$enableval"],
+    [enable_xlib_glx=auto])
+AC_ARG_ENABLE([gallium_egl],
+    [AS_HELP_STRING([--enable-gallium-egl],
+        [enable optional EGL state tracker (not required
+         for EGL support in Gallium with OpenGL and OpenGL ES)
+         @<:@default=disable@:>@])],
+    [enable_gallium_egl="$enableval"],
+    [enable_gallium_egl=no])
+AC_ARG_ENABLE([gallium_gbm],
+    [AS_HELP_STRING([--enable-gallium-gbm],
+        [enable optional gbm state tracker (not required for
+         gbm support in Gallium)
+         @<:@default=auto@:>@])],
+    [enable_gallium_gbm="$enableval"],
+    [enable_gallium_gbm=auto])
+
+# Option for Gallium drivers
+GALLIUM_DRIVERS_DEFAULT="r300,r600,swrast"
+
+AC_ARG_WITH([gallium-drivers],
+    [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
+        [comma delimited Gallium drivers list, e.g.
+        "i915,i965,nouveau,r300,r600,svga,swrast"
+        @<:@default=r300,r600,swrast@:>@])],
+    [with_gallium_drivers="$withval"],
+    [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
+
+# Doing '--without-gallium-drivers' will set this variable to 'no'.  Clear it
+# here so that the script doesn't choke on an unknown driver name later.
+case "$with_gallium_drivers" in
+    yes) with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT" ;;
+    no) with_gallium_drivers='' ;;
+esac
 
 if test "x$enable_opengl" = xno -a \
         "x$enable_gles1" = xno -a \
         "x$enable_gles2" = xno -a \
-        "x$enable_openvg" = xno; then
+        "x$enable_openvg" = xno -a \
+        "x$enable_xorg" = xno -a \
+        "x$enable_xa" = xno -a \
+        "x$enable_d3d1x" = xno -a \
+        "x$enable_xvmc" = xno -a \
+        "x$enable_vdpau" = xno -a \
+        "x$enable_va" = xno; then
     AC_MSG_ERROR([at least one API should be enabled])
 fi
 
@@ -602,24 +707,60 @@ if test "x$enable_opengl" = xno; then
 fi
 
 AC_ARG_WITH([driver],
-    [AS_HELP_STRING([--with-driver=DRIVER],
-        [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
+    [AS_HELP_STRING([--with-driver=DRIVER], [DEPRECATED])],
     [mesa_driver="$withval"],
-    [mesa_driver="$default_driver"])
+    [mesa_driver=auto])
 dnl Check for valid option
 case "x$mesa_driver" in
-xxlib|xdri|xosmesa)
-    if test "x$enable_opengl" = xno; then
-        AC_MSG_ERROR([Driver '$mesa_driver' requires OpenGL enabled])
+xxlib|xdri|xosmesa|xno)
+    if test "x$enable_dri" != xauto -o \
+            "x$enable_glx" != xauto -o \
+            "x$enable_osmesa" != xauto -o \
+            "x$enable_xlib_glx" != xauto; then
+        AC_MSG_ERROR([--with-driver=$mesa_driver is deprecated])
     fi
     ;;
-xno)
+xauto)
+    mesa_driver="$default_driver"
     ;;
 *)
     AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
     ;;
 esac
 
+# map $mesa_driver to APIs
+if test "x$enable_dri" = xauto; then
+    case "x$mesa_driver" in
+    xdri) enable_dri=yes ;;
+    *)    enable_dri=no ;;
+    esac
+fi
+
+if test "x$enable_glx" = xauto; then
+    case "x$mesa_driver" in
+    xdri|xxlib) enable_glx=yes ;;
+    *)          enable_glx=no ;;
+    esac
+fi
+
+if test "x$enable_osmesa" = xauto; then
+    case "x$mesa_driver" in
+    xxlib|xosmesa) enable_osmesa=yes ;;
+    *)             enable_osmesa=no ;;
+    esac
+fi
+
+if test "x$enable_xlib_glx" = xauto; then
+    case "x$mesa_driver" in
+    xxlib) enable_xlib_glx=yes ;;
+    *)     enable_xlib_glx=no ;;
+    esac
+fi
+
+if test "x$enable_glx" = xno; then
+    enable_xlib_glx=no
+fi
+
 dnl
 dnl Driver specific build directories
 dnl
@@ -632,7 +773,7 @@ GLU_DIRS="sgi"
 GALLIUM_DIRS="auxiliary drivers state_trackers"
 GALLIUM_TARGET_DIRS=""
 GALLIUM_WINSYS_DIRS="sw"
-GALLIUM_DRIVERS_DIRS="softpipe failover galahad trace rbug noop identity"
+GALLIUM_DRIVERS_DIRS="failover galahad trace rbug noop identity"
 GALLIUM_STATE_TRACKERS_DIRS=""
 
 # build shared-glapi if enabled for OpenGL or if OpenGL ES is enabled
@@ -657,11 +798,6 @@ if test "x$enable_gles2" = xyes; then
     CORE_DIRS="$CORE_DIRS mapi/es2api"
 fi
 
-# build vgapi if OpenVG is enabled
-if test "x$enable_openvg" = xyes; then
-    CORE_DIRS="$CORE_DIRS mapi/vgapi"
-fi
-
 # build glsl and mesa if OpenGL or OpenGL ES is enabled
 case "x$enable_opengl$enable_gles1$enable_gles2" in
 x*yes*)
@@ -669,24 +805,37 @@ x*yes*)
     ;;
 esac
 
-case "$mesa_driver" in
-xlib)
-    DRIVER_DIRS="x11"
+case "x$enable_glx$enable_xlib_glx" in
+xyesyes)
+    DRIVER_DIRS="$DRIVER_DIRS x11"
     GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
     GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS libgl-xlib"
+    GALLIUM_STATE_TRACKERS_DIRS="glx $GALLIUM_STATE_TRACKERS_DIRS"
+    HAVE_WINSYS_XLIB="yes"
     ;;
-dri)
+xyesno)
+    # DRI-based GLX
     SRC_DIRS="$SRC_DIRS glx"
-    DRIVER_DIRS="dri"
-    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/dri"
-    ;;
-osmesa)
-    DRIVER_DIRS="osmesa"
-    ;;
-no)
-    DRIVER_DRIS=""
     ;;
 esac
+
+if test "x$enable_dri" = xyes; then
+    DRIVER_DIRS="$DRIVER_DIRS dri"
+
+    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/dri"
+    GALLIUM_STATE_TRACKERS_DIRS="dri $GALLIUM_STATE_TRACKERS_DIRS"
+    HAVE_ST_DRI="yes"
+fi
+
+if test "x$enable_osmesa" = xyes; then
+    # the empty space matters for osmesa... (see src/mesa/Makefile)
+    if test -n "$DRIVER_DIRS"; then
+        DRIVER_DIRS="$DRIVER_DIRS osmesa"
+    else
+        DRIVER_DIRS="osmesa"
+    fi
+fi
+
 AC_SUBST([SRC_DIRS])
 AC_SUBST([GLU_DIRS])
 AC_SUBST([DRIVER_DIRS])
@@ -697,6 +846,22 @@ AC_SUBST([GALLIUM_DRIVERS_DIRS])
 AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
 AC_SUBST([MESA_LLVM])
 
+# Check for libdrm
+PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED],
+                  [have_libdrm=yes], [have_libdrm=no])
+
+if test "x$enable_dri" = xyes; then
+    # DRI must be shared, I think
+    if test "$enable_static" = yes; then
+        AC_MSG_ERROR([Can't use static libraries for DRI drivers])
+    fi
+
+    # not a hard requirement as swrast does not depend on it
+    if test "x$have_libdrm" = xyes; then
+        DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
+    fi
+fi
+
 dnl
 dnl Find out if X is available. The variable have_x is set if libX11 is
 dnl found to mimic AC_PATH_XTRA.
@@ -731,13 +896,9 @@ m4_divert_once([HELP_BEGIN],
 pkg-config utility.])
 
 dnl We need X for xlib and dri, so bomb now if it's not found
-case "$mesa_driver" in
-xlib|dri)
-    if test "$no_x" = yes; then
-        AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
-    fi
-    ;;
-esac
+if test "x$enable_glx" = xyes -a "x$no_x" = xyes; then
+    AC_MSG_ERROR([X11 development libraries needed for GLX])
+fi
 
 dnl XCB - this is only used for GLX right now
 AC_ARG_ENABLE([xcb],
@@ -775,8 +936,9 @@ AC_ARG_ENABLE([driglx-direct],
 dnl
 dnl libGL configuration per driver
 dnl
-case "$mesa_driver" in
-xlib)
+case "x$enable_glx$enable_xlib_glx" in
+xyesyes)
+    # Xlib-based GLX
     if test "$x11_pkgconfig" = yes; then
         PKG_CHECK_MODULES([XLIBGL], [x11 xext])
         GL_PC_REQ_PRIV="x11 xext"
@@ -789,7 +951,7 @@ xlib)
         GL_PC_LIB_PRIV="$GL_LIB_DEPS"
         GL_PC_CFLAGS="$X11_INCLUDES"
     fi
-    GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
+    GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $DLOPEN_LIBS"
     GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread"
 
     # if static, move the external libraries to the programs
@@ -799,22 +961,16 @@ xlib)
         GL_LIB_DEPS=""
     fi
     ;;
-dri|no) # these checks are still desired when there is no mesa_driver
-    # DRI must be shared, I think
-    if test "$enable_static" = yes; then
-        AC_MSG_ERROR([Can't use static libraries for DRI drivers])
-    fi
-
+xyesno)
+    # DRI-based GLX
     PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
     GL_PC_REQ_PRIV="glproto >= $GLPROTO_REQUIRED"
-    DRI_PC_REQ_PRIV=""
-
     if test x"$driglx_direct" = xyes; then
-        # Check for libdrm
-        PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
+        if test "x$have_libdrm" != xyes; then
+            AC_MSG_ERROR([Direct rendering requires libdrm >= $LIBDRM_REQUIRED])
+        fi
         PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
         GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
-        DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
     fi
 
     # find the DRI deps for libGL
@@ -839,7 +995,11 @@ dri|no) # these checks are still desired when there is no mesa_driver
     else
         # should check these...
         X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
-        GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
+        if test "x$HAVE_XF86VIDMODE" == xyes; then
+           GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
+       else
+           GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXdamage -lXfixes"
+       fi
         GL_PC_LIB_PRIV="$GL_LIB_DEPS"
         GL_PC_CFLAGS="$X11_INCLUDES"
 
@@ -855,16 +1015,14 @@ dri|no) # these checks are still desired when there is no mesa_driver
     # need DRM libs, -lpthread, etc.
     GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
     GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
-    GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
-    GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
-    GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
-    GLESv2_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
-    ;;
-osmesa)
-    # No libGL for osmesa
-    GL_LIB_DEPS=""
     ;;
 esac
+
+GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
+GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
+GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
+GLESv2_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
+
 AC_SUBST([GL_LIB_DEPS])
 AC_SUBST([GL_PC_REQ_PRIV])
 AC_SUBST([GL_PC_LIB_PRIV])
@@ -890,7 +1048,7 @@ AC_ARG_ENABLE([shared-dricore],
         [link DRI modules with shared core DRI routines @<:@default=disabled@:>@])],
     [enable_dricore="$enableval"],
     [enable_dricore=no])
-if test "$mesa_driver" = dri ; then
+if test "x$enable_dri" = xyes ; then
    if test "$enable_dricore" = yes ; then
       if test "$GCC$GXX" != yesyes ; then
         AC_MSG_WARN([Shared dricore requires GCC-compatible rpath handling.  Disabling shared dricore])
@@ -915,17 +1073,20 @@ AC_SUBST([MESA_MODULES])
 
 AC_SUBST([HAVE_XF86VIDMODE])
 
-PKG_CHECK_MODULES([LIBDRM_RADEON],
-                 [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED],
-                 HAVE_LIBDRM_RADEON=yes,
-                 HAVE_LIBDRM_RADEON=no)
-
 dnl
-dnl More X11 setup
+dnl More GLX setup
 dnl
-if test "$mesa_driver" = xlib; then
+case "x$enable_glx$enable_xlib_glx" in
+xyesyes)
     DEFINES="$DEFINES -DUSE_XSHM"
-fi
+    ;;
+xyesno)
+    DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
+    if test "x$driglx_direct" = xyes; then
+        DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
+    fi
+    ;;
+esac
 
 dnl
 dnl TLS detection
@@ -975,7 +1136,10 @@ DRI_DIRS=""
 case "$with_dri_drivers" in
 no) ;;
 yes)
-    DRI_DIRS="yes"
+    # classic DRI drivers require FEATURE_GL to build
+    if test "x$enable_opengl" = xyes; then
+        DRI_DIRS="yes"
+    fi
     ;;
 *)
     # verify the requested driver directories exist
@@ -985,19 +1149,19 @@ yes)
             AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
     done
     DRI_DIRS="$dri_drivers"
+    if test -n "$DRI_DIRS" -a "x$enable_opengl" != xyes; then
+        AC_MSG_ERROR([--with-dri-drivers requires OpenGL])
+    fi
     ;;
 esac
 
 dnl Set DRI_DIRS, DEFINES and LIB_DEPS
-if test "$mesa_driver" = dri -o "$mesa_driver" = no; then
+if test "x$enable_dri" = xyes; then
     # Platform specific settings and drivers to build
     case "$host_os" in
     linux*)
         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
-        if test "x$driglx_direct" = xyes; then
-            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
-        fi
-        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
+        DEFINES="$DEFINES -DHAVE_ALIAS"
 
         case "$host_cpu" in
         x86_64)
@@ -1027,10 +1191,6 @@ if test "$mesa_driver" = dri -o "$mesa_driver" = no; then
     freebsd* | dragonfly* | *netbsd*)
         DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
         DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
-        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
-        if test "x$driglx_direct" = xyes; then
-            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
-        fi
 
         if test "x$DRI_DIRS" = "xyes"; then
             DRI_DIRS="i810 i915 i965 mach64 mga nouveau r128 r200 r300 r600 \
@@ -1039,21 +1199,13 @@ if test "$mesa_driver" = dri -o "$mesa_driver" = no; then
         ;;
     gnu*)
         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
-        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
+        DEFINES="$DEFINES -DHAVE_ALIAS"
        ;;
     solaris*)
         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
-        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
-        if test "x$driglx_direct" = xyes; then
-            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
-        fi
         ;;
     cygwin*)
         DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
-        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
-        if test "x$driglx_direct" = xyes; then
-            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
-        fi
         if test "x$DRI_DIRS" = "xyes"; then
             DRI_DIRS="swrast"
         fi
@@ -1069,7 +1221,7 @@ if test "$mesa_driver" = dri -o "$mesa_driver" = no; then
     DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/  */ /g'`
 
     # Check for expat
-    if test "$mesa_driver" = dri; then
+    if test "x$enable_dri" = xyes; then
         EXPAT_INCLUDES=""
         EXPAT_LIB=-lexpat
         AC_ARG_WITH([expat],
@@ -1085,6 +1237,13 @@ if test "$mesa_driver" = dri -o "$mesa_driver" = no; then
             [AC_MSG_ERROR([Expat required for DRI.])])
     fi
 
+    # libdrm is required for all except swrast
+    if test -n "$DRI_DIRS" -a x"$DRI_DIRS" != xswrast; then
+        if test "x$have_libdrm" != xyes; then
+            AC_MSG_ERROR([DRI drivers requires libdrm >= $LIBDRM_REQUIRED])
+        fi
+    fi
+
     # put all the necessary libs together, including possibly libdricore
     DRI_LIB_DEPS="$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
 fi
@@ -1106,6 +1265,11 @@ esac
 
 case $DRI_DIRS in
 *radeon*|*r200*|*r300*|*r600*)
+    PKG_CHECK_MODULES([LIBDRM_RADEON],
+                     [libdrm_radeon >= $LIBDRM_RADEON_REQUIRED],
+                     HAVE_LIBDRM_RADEON=yes,
+                     HAVE_LIBDRM_RADEON=no)
+
     if test "x$HAVE_LIBDRM_RADEON" = xyes; then
        RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS"
        RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS
@@ -1119,26 +1283,6 @@ AC_SUBST([RADEON_LDFLAGS])
 dnl
 dnl OSMesa configuration
 dnl
-if test "$mesa_driver" = xlib; then
-    default_gl_osmesa=yes
-else
-    default_gl_osmesa=no
-fi
-AC_ARG_ENABLE([gl-osmesa],
-    [AS_HELP_STRING([--enable-gl-osmesa],
-        [enable OSMesa with libGL @<:@default=enabled for xlib driver@:>@])],
-    [gl_osmesa="$enableval"],
-    [gl_osmesa="$default_gl_osmesa"])
-if test "x$gl_osmesa" = xyes; then
-    if test "x$enable_opengl" = xno; then
-        AC_MSG_ERROR([OpenGL is not available for OSMesa driver])
-    fi
-    if test "$mesa_driver" = osmesa; then
-        AC_MSG_ERROR([libGL is not available for OSMesa driver])
-    else
-        DRIVER_DIRS="$DRIVER_DIRS osmesa"
-    fi
-fi
 
 dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
 AC_ARG_WITH([osmesa-bits],
@@ -1146,9 +1290,11 @@ AC_ARG_WITH([osmesa-bits],
         [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
     [osmesa_bits="$withval"],
     [osmesa_bits=8])
-if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
-    AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
-    osmesa_bits=8
+if test "x$osmesa_bits" != x8; then
+    if test "x$enable_dri" = xyes -o "x$enable_glx" = xyes; then
+        AC_MSG_WARN([Ignoring OSMesa channel bits because of non-OSMesa driver])
+        osmesa_bits=8
+    fi
 fi
 case "x$osmesa_bits" in
 x8)
@@ -1164,8 +1310,7 @@ x16|x32)
 esac
 AC_SUBST([OSMESA_LIB])
 
-case "$DRIVER_DIRS" in
-*osmesa*)
+if test "x$enable_osmesa" = xyes; then
     # only link libraries with osmesa if shared
     if test "$enable_static" = no; then
         OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
@@ -1174,36 +1319,60 @@ case "$DRIVER_DIRS" in
     fi
     OSMESA_MESA_DEPS=""
     OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
-    ;;
-esac
+fi
 AC_SUBST([OSMESA_LIB_DEPS])
 AC_SUBST([OSMESA_MESA_DEPS])
 AC_SUBST([OSMESA_PC_REQ])
 AC_SUBST([OSMESA_PC_LIB_PRIV])
 
 dnl
-dnl EGL configuration
+dnl gbm configuration
 dnl
-AC_ARG_ENABLE([egl],
-    [AS_HELP_STRING([--disable-egl],
-        [disable EGL library @<:@default=enabled@:>@])],
-    [enable_egl="$enableval"],
-    [enable_egl=yes])
-if test "x$enable_egl" = xno; then
-    if test "x$mesa_driver" = xno; then
-        AC_MSG_ERROR([cannot disable EGL when there is no mesa driver])
-    fi
-    if test "x$enable_openvg" = xyes; then
-        AC_MSG_ERROR([cannot enable OpenVG without EGL])
+if test "x$enable_gbm" = xauto; then
+    case "$with_egl_platforms" in
+        *drm*)
+            enable_gbm=yes ;;
+         *)
+            enable_gbm=no ;;
+    esac
+fi
+if test "x$enable_gbm" = xyes; then
+    SRC_DIRS="$SRC_DIRS gbm"
+    GBM_BACKEND_DIRS=""
+
+    PKG_CHECK_MODULES([LIBUDEV], [libudev], [],
+                      AC_MSG_ERROR([gbm needs udev]))
+    GBM_LIB_DEPS="$DLOPEN_LIBS $LIBUDEV_LIBS"
+
+    if test "x$enable_dri" = xyes; then
+        GBM_BACKEND_DIRS="$GBM_BACKEND_DIRS dri"
+        if test "$SHARED_GLAPI" -eq 0; then
+            AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi])
+        fi
     fi
 fi
+AC_SUBST([GBM_LIB_DEPS])
+AC_SUBST([GBM_BACKEND_DIRS])
+GBM_PC_REQ_PRIV="libudev"
+GBM_PC_LIB_PRIV="$DLOPEN_LIBS"
+GBM_PC_CFLAGS=
+AC_SUBST([GBM_PC_REQ_PRIV])
+AC_SUBST([GBM_PC_LIB_PRIV])
+AC_SUBST([GBM_PC_CFLAGS])
+
+dnl
+dnl EGL configuration
+dnl
+EGL_CLIENT_APIS=""
+
 if test "x$enable_egl" = xyes; then
     SRC_DIRS="$SRC_DIRS egl"
     EGL_LIB_DEPS="$DLOPEN_LIBS $SELINUX_LIBS -lpthread"
     EGL_DRIVERS_DIRS=""
+
     if test "$enable_static" != yes; then
         # build egl_glx when libGL is built
-        if test "$mesa_driver" = xlib -o "$mesa_driver" = dri; then
+        if test "x$enable_glx" = xyes; then
             EGL_DRIVERS_DIRS="glx"
         fi
 
@@ -1212,7 +1381,7 @@ if test "x$enable_egl" = xyes; then
         if test "$have_libudev" = yes; then
             DEFINES="$DEFINES -DHAVE_LIBUDEV"
         fi
-        if test "$mesa_driver" = dri; then
+        if test "x$enable_dri" = xyes; then
             # build egl_dri2 when xcb-dri2 is available
             PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 xcb-xfixes],
                          [have_xcb_dri2=yes],[have_xcb_dri2=no])
@@ -1233,6 +1402,154 @@ AC_SUBST([EGL_LIB_DEPS])
 AC_SUBST([EGL_DRIVERS_DIRS])
 
 dnl
+dnl EGL Gallium configuration
+dnl
+if test "x$enable_gallium_egl" = xyes; then
+    if test "x$with_gallium_drivers" = x; then
+        AC_MSG_ERROR([cannot enable egl_gallium without Gallium])
+    fi
+    if test "x$enable_egl" = xno; then
+        AC_MSG_ERROR([cannot enable egl_gallium without EGL])
+    fi
+    if test "x$have_libdrm" != xyes; then
+        AC_MSG_ERROR([egl_gallium requires libdrm >= $LIBDRM_REQUIRED])
+    fi
+
+    GALLIUM_STATE_TRACKERS_DIRS="egl $GALLIUM_STATE_TRACKERS_DIRS"
+    GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-static"
+    HAVE_ST_EGL="yes"
+fi
+
+dnl
+dnl gbm Gallium configuration
+dnl
+if test "x$enable_gallium_gbm" = xauto; then
+    case "$enable_gbm$HAVE_ST_EGL$with_egl_platforms" in
+        yesyes*drm*)
+            enable_gallium_gbm=yes ;;
+         *)
+            enable_gallium_gbm=no ;;
+    esac
+fi
+if test "x$enable_gallium_gbm" = xyes; then
+    if test "x$with_gallium_drivers" = x; then
+        AC_MSG_ERROR([cannot enable gbm_gallium without Gallium])
+    fi
+    if test "x$enable_gbm" = xno; then
+        AC_MSG_ERROR([cannot enable gbm_gallium without gbm])
+    fi
+
+    GALLIUM_STATE_TRACKERS_DIRS="gbm $GALLIUM_STATE_TRACKERS_DIRS"
+    GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS gbm"
+    HAVE_ST_GBM="yes"
+fi
+
+dnl
+dnl X.Org DDX configuration
+dnl
+if test "x$enable_xorg" = xyes; then
+    PKG_CHECK_MODULES([XORG], [xorg-server >= 1.6.0])
+    PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED])
+    PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED])
+    PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
+        HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
+        HAVE_XEXTPROTO_71="no")
+    GALLIUM_STATE_TRACKERS_DIRS="xorg $GALLIUM_STATE_TRACKERS_DIRS"
+    HAVE_ST_XORG=yes
+fi
+
+dnl
+dnl XA configuration
+dnl
+if test "x$enable_xa" = xyes; then
+    GALLIUM_STATE_TRACKERS_DIRS="xa $GALLIUM_STATE_TRACKERS_DIRS"
+    HAVE_ST_XA=yes
+fi
+
+dnl
+dnl OpenVG configuration
+dnl
+VG_LIB_DEPS=""
+
+if test "x$enable_openvg" = xyes; then
+    if test "x$enable_egl" = xno; then
+        AC_MSG_ERROR([cannot enable OpenVG without EGL])
+    fi
+    if test "x$with_gallium_drivers" = x; then
+        AC_MSG_ERROR([cannot enable OpenVG without Gallium])
+    fi
+    if test "x$enable_gallium_egl" = xno; then
+        AC_MSG_ERROR([cannot enable OpenVG without egl_gallium])
+    fi
+
+    EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)'
+    VG_LIB_DEPS="$VG_LIB_DEPS $SELINUX_LIBS -lpthread"
+    CORE_DIRS="$CORE_DIRS mapi/vgapi"
+    GALLIUM_STATE_TRACKERS_DIRS="vega $GALLIUM_STATE_TRACKERS_DIRS"
+    HAVE_ST_VEGA=yes
+fi
+
+dnl
+dnl D3D1X configuration
+dnl
+
+if test "x$enable_d3d1x" = xyes; then
+    if test "x$with_gallium_drivers" = x; then
+        AC_MSG_ERROR([cannot enable D3D1X without Gallium])
+    fi
+
+    GALLIUM_STATE_TRACKERS_DIRS="d3d1x $GALLIUM_STATE_TRACKERS_DIRS"
+    HAVE_ST_D3D1X=yes
+fi
+
+dnl
+dnl Gallium G3DVL configuration
+dnl
+AC_ARG_ENABLE([gallium-g3dvl],
+    [AS_HELP_STRING([--enable-gallium-g3dvl],
+        [build gallium g3dvl @<:@default=disabled@:>@])],
+    [enable_gallium_g3dvl="$enableval"],
+    [enable_gallium_g3dvl=no])
+if test "x$enable_gallium_g3dvl" = xyes; then
+    if test "x$with_gallium_drivers" = x; then
+        AC_MSG_ERROR([cannot enable G3DVL without Gallium])
+    fi
+
+    if test "x$enable_xvmc" = xauto; then
+       PKG_CHECK_EXISTS([xvmc], [enable_xvmc=yes], [enable_xvmc=no])
+    fi
+
+    if test "x$enable_vdpau" = xauto; then
+       PKG_CHECK_EXISTS([vdpau], [enable_vdpau=yes], [enable_vdpau=no])
+    fi
+
+    if test "x$enable_va" = xauto; then
+       #don't enable vaapi state tracker even if package exists
+       #PKG_CHECK_EXISTS([libva], [enable_vdpau=yes], [enable_vdpau=no])
+        enable_va=no
+    fi
+fi
+
+if test "x$enable_xvmc" = xyes; then
+    PKG_CHECK_MODULES([XVMC], [xvmc >= 1.0.6 xorg-server])
+    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg/xvmc"
+    HAVE_ST_XVMC="yes"
+fi
+
+if test "x$enable_vdpau" = xyes; then
+    PKG_CHECK_MODULES([VDPAU], [vdpau >= 0.4.1])
+    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vdpau"
+    HAVE_ST_VDPAU="yes"
+fi
+
+if test "x$enable_va" = xyes; then
+    PKG_CHECK_MODULES([LIBVA], [libva = 0.31.1])
+    AC_MSG_WARN([vaapi state tracker currently unmaintained])
+    GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS va"
+    HAVE_ST_VA="yes"
+fi
+
+dnl
 dnl GLU configuration
 dnl
 AC_ARG_ENABLE([glu],
@@ -1241,16 +1558,17 @@ AC_ARG_ENABLE([glu],
     [enable_glu="$enableval"],
     [enable_glu=yes])
 
-if test "x$enable_glu" = xyes -a "x$mesa_driver" = xno; then
-    AC_MSG_NOTICE([Disabling GLU since there is no OpenGL driver])
-    enable_glu=no
+if test "x$enable_glu" = xyes; then
+    if test "x$enable_glx" = xno -a "x$enable_osmesa" = xno; then
+        AC_MSG_NOTICE([Disabling GLU since there is no OpenGL driver])
+        enable_glu=no
+    fi
 fi
 
 if test "x$enable_glu" = xyes; then
     SRC_DIRS="$SRC_DIRS glu"
 
-    case "$mesa_driver" in
-    osmesa)
+    if test "x$enable_glx" = xno; then
         # Link libGLU to libOSMesa instead of libGL
         GLU_LIB_DEPS=""
         GLU_PC_REQ="osmesa"
@@ -1259,8 +1577,7 @@ if test "x$enable_glu" = xyes; then
         else
             GLU_MESA_DEPS=""
         fi
-        ;;
-    *)
+    else
         # If static, empty GLU_LIB_DEPS and add libs for programs to link
         GLU_PC_REQ="gl"
         GLU_PC_LIB_PRIV="-lm"
@@ -1272,8 +1589,7 @@ if test "x$enable_glu" = xyes; then
             GLU_MESA_DEPS=""
             APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
         fi
-        ;;
-    esac
+    fi
 fi
 if test "$enable_static" = no; then
     GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
@@ -1295,13 +1611,9 @@ AC_ARG_ENABLE([glw],
     [enable_glw="$enableval"],
     [enable_glw=yes])
 dnl Don't build GLw on osmesa
-if test "x$enable_glw" = xyes; then
-    case "$mesa_driver" in
-    osmesa|no)
-        AC_MSG_NOTICE([Disabling GLw since there is no OpenGL driver])
-        enable_glw=no
-        ;;
-    esac
+if test "x$enable_glw" = xyes -a "x$enable_glx" = xno; then
+    AC_MSG_NOTICE([Disabling GLw since there is no OpenGL driver])
+    enable_glw=no
 fi
 AC_ARG_ENABLE([motif],
     [AS_HELP_STRING([--enable-motif],
@@ -1362,69 +1674,6 @@ AC_SUBST([GLW_PC_LIB_PRIV])
 AC_SUBST([GLW_PC_CFLAGS])
 
 dnl
-dnl GLUT configuration
-dnl
-if test -f "$srcdir/include/GL/glut.h"; then
-    default_glut=yes
-else
-    default_glut=no
-fi
-AC_ARG_ENABLE([glut],
-    [AS_HELP_STRING([--disable-glut],
-        [enable GLUT library @<:@default=enabled if source available@:>@])],
-    [enable_glut="$enableval"],
-    [enable_glut="$default_glut"])
-
-dnl Don't build glut on osmesa
-if test "x$enable_glut" = xyes; then
-    case "$mesa_driver" in
-    osmesa|no)
-        AC_MSG_NOTICE([Disabling glut since there is no OpenGL driver])
-        enable_glut=no
-        ;;
-    esac
-fi
-dnl Can't build glut if GLU not available
-if test "x$enable_glu$enable_glut" = xnoyes; then
-    AC_MSG_WARN([Disabling glut since GLU is disabled])
-    enable_glut=no
-fi
-
-if test "x$enable_glut" = xyes; then
-    SRC_DIRS="$SRC_DIRS glut/glx"
-    if test "$x11_pkgconfig" = yes; then
-        PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
-        GLUT_PC_REQ_PRIV="x11 xmu xi"
-        GLUT_LIB_DEPS="$GLUT_LIBS"
-    else
-        # should check these...
-        GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
-        GLUT_PC_LIB_PRIV="$GLUT_LIB_DEPS"
-        GLUT_PC_CFLAGS="$X11_INCLUDES"
-    fi
-    if test "x$GCC" = xyes; then
-        GLUT_CFLAGS="$GLUT_CFLAGS -fexceptions"
-    fi
-    GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm"
-    GLUT_PC_LIB_PRIV="$GLUT_PC_LIB_PRIV -lm"
-
-    # If static, empty GLUT_LIB_DEPS and add libs for programs to link
-    if test "$enable_static" = no; then
-        GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
-    else
-        APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
-        GLUT_LIB_DEPS=""
-        GLUT_MESA_DEPS=""
-    fi
-fi
-AC_SUBST([GLUT_LIB_DEPS])
-AC_SUBST([GLUT_MESA_DEPS])
-AC_SUBST([GLUT_CFLAGS])
-AC_SUBST([GLUT_PC_REQ_PRIV])
-AC_SUBST([GLUT_PC_LIB_PRIV])
-AC_SUBST([GLUT_PC_CFLAGS])
-
-dnl
 dnl Program library dependencies
 dnl    Only libm is added here if necessary as the libraries should
 dnl    be pulled in by the linker
@@ -1448,17 +1697,8 @@ AC_SUBST([PROGRAM_DIRS])
 dnl
 dnl Gallium configuration
 dnl
-AC_ARG_ENABLE([gallium],
-    [AS_HELP_STRING([--disable-gallium],
-        [build gallium @<:@default=enabled@:>@])],
-    [enable_gallium="$enableval"],
-    [enable_gallium=yes])
-if test "x$enable_gallium" = xno -a "x$enable_openvg" = xyes; then
-    AC_MSG_ERROR([cannot enable OpenVG without Gallium])
-fi
-if test "x$enable_gallium" = xyes; then
+if test "x$with_gallium_drivers" != x; then
     SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets"
-    AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
 fi
 
 AC_SUBST([LLVM_CFLAGS])
@@ -1466,171 +1706,29 @@ AC_SUBST([LLVM_LIBS])
 AC_SUBST([LLVM_LDFLAGS])
 AC_SUBST([LLVM_VERSION])
 
-dnl
-dnl Gallium state trackers configuration
-dnl
-
-AC_ARG_ENABLE([gallium-egl],
-    [AS_HELP_STRING([--enable-gallium-egl],
-        [enable gallium EGL state tracker @<:@default=auto@:>@])],
-    [enable_gallium_egl="$enableval"],
-    [enable_gallium_egl=auto])
-if test "x$enable_gallium_egl" = xauto; then
-    case "$mesa_driver" in
-    dri|no)
-        enable_gallium_egl=$enable_egl
-        ;;
-    *)
-        enable_gallium_egl=$enable_openvg
-        ;;
-    esac
-fi
-case "x$enable_egl$enable_gallium_egl" in
-xnoyes)
-    AC_MSG_ERROR([cannot build Gallium EGL state tracker without EGL])
-esac
-
-AC_ARG_WITH([state-trackers],
-    [AS_HELP_STRING([--with-state-trackers@<:@=DIRS...@:>@],
-        [comma delimited state_trackers list, e.g.
-        "egl,glx" @<:@default=auto@:>@])],
-    [with_state_trackers="$withval"],
-    [with_state_trackers=yes])
-
-case "$with_state_trackers" in
-no)
-    GALLIUM_STATE_TRACKERS_DIRS=""
-    ;;
-yes)
-    # look at what else is built
-    case "$mesa_driver" in
-    xlib)
-        GALLIUM_STATE_TRACKERS_DIRS=glx
-        ;;
-    dri)
-        GALLIUM_STATE_TRACKERS_DIRS="dri"
-        HAVE_ST_DRI="yes"
-        # Have only tested st/xorg on 1.6.0 servers
-        PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0 libdrm >= $LIBDRM_XORG_REQUIRED libkms >= $LIBKMS_XORG_REQUIRED],
-            HAVE_ST_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
-            HAVE_ST_XORG="no")
-        ;;
-    esac
-
-    if test "x$enable_egl" = xyes; then
-        if test "$enable_openvg" = yes; then
-            GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS vega"
-            st_egl="yes"
-        fi
-
-        if test "$enable_gallium_egl" = yes; then
-            GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
-            HAVE_ST_EGL="yes"
-        fi
-    fi
-    ;;
-*)
-    # verify the requested state tracker exist
-    state_trackers=""
-    _state_trackers=`IFS=', '; echo $with_state_trackers`
-    for tracker in $_state_trackers; do
-        case "$tracker" in
-        dri)
-            if test "x$mesa_driver" != xdri; then
-                AC_MSG_ERROR([cannot build dri state tracker without mesa driver set to dri])
-            fi
-            HAVE_ST_DRI="yes"
-            ;;
-        egl)
-            if test "x$enable_egl" != xyes; then
-                AC_MSG_ERROR([cannot build egl state tracker without EGL library])
-            fi
-            HAVE_ST_EGL="yes"
-            ;;
-        xorg)
-            PKG_CHECK_MODULES([XORG], [xorg-server >= 1.6.0])
-            PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED])
-            PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED])
-            HAVE_ST_XORG="yes"
-            ;;
-        vega)
-            if test "x$enable_openvg" != xyes; then
-                AC_MSG_ERROR([cannot build vega state tracker without --enable-openvg])
-            fi
-            have_st_vega="yes"
-            ;;
-        esac
-
-       if test -n "$tracker"; then
-            test -d "$srcdir/src/gallium/state_trackers/$tracker" || \
-                AC_MSG_ERROR([state tracker '$tracker' doesn't exist])
-            if test -n "$state_trackers"; then
-                state_trackers="$state_trackers $tracker"
-            else
-                state_trackers="$tracker"
-            fi
-        fi
-    done
-    GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
-
-    # append --enable-openvg/--enable-gallium-egl to --with-state-trackers
-    if test "x$have_st_vega" != xyes -a "x$enable_openvg" = xyes; then
-        AC_MSG_ERROR([--with-state-trackers specified but vega is missing])
-    fi
-    if test "x$HAVE_ST_EGL" != xyes -a "x$enable_gallium_egl" = xyes; then
-        AC_MSG_ERROR([--with-state-trackers specified but egl is missing])
-    fi
-    ;;
-esac
-
-
-EGL_CLIENT_APIS=""
-VG_LIB_DEPS=""
-
 case "x$enable_opengl$enable_gles1$enable_gles2" in
 x*yes*)
     EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GL_LIB)'
     ;;
 esac
-if test "x$enable_openvg" = xyes; then
-    EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)'
-    VG_LIB_DEPS="$VG_LIB_DEPS $SELINUX_LIBS -lpthread"
-fi
 
 AC_SUBST([VG_LIB_DEPS])
 AC_SUBST([EGL_CLIENT_APIS])
 
-if test "x$HAVE_ST_EGL" = xyes; then
-       GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl"
-fi
-
-if test "x$HAVE_ST_XORG" = xyes; then
-    PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
-        HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
-        HAVE_XEXTPROTO_71="no")
-fi
-
 AC_ARG_WITH([egl-platforms],
     [AS_HELP_STRING([--with-egl-platforms@<:@=DIRS...@:>@],
         [comma delimited native platforms libEGL supports, e.g.
         "x11,drm" @<:@default=auto@:>@])],
     [with_egl_platforms="$withval"],
     [with_egl_platforms=yes])
-AC_ARG_WITH([egl-displays],
-    [AS_HELP_STRING([--with-egl-displays@<:@=DIRS...@:>@],
-        [DEPRECATED.  Use --with-egl-platforms instead])],
-    [with_egl_platforms="$withval"])
 
 EGL_PLATFORMS=""
 WAYLAND_EGL_LIB_DEPS=""
 
 case "$with_egl_platforms" in
 yes)
-    if test "x$enable_egl" = xyes && test "x$mesa_driver" != xosmesa; then
+    if test "x$enable_egl" = xyes; then
         EGL_PLATFORMS="x11"
-        if test "$mesa_driver" = dri; then
-            EGL_PLATFORMS="$EGL_PLATFORMS drm"
-        fi
     fi
     ;;
 *)
@@ -1651,6 +1749,13 @@ yes)
                WAYLAND_EGL_LIB_DEPS="$WAYLAND_LIBS $LIBDRM_LIBS"
                 GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/wayland"
        fi
+        if test "$plat" = "drm" && test "x$enable_gbm" = "xno"; then
+                AC_MSG_ERROR([EGL platform drm needs gbm])
+        fi
+        case "$plat$have_libudev" in
+                waylandno|drmno)
+                    AC_MSG_ERROR([cannot build $plat platfrom without udev]) ;;
+        esac
     done
     EGL_PLATFORMS="$egl_platforms"
     ;;
@@ -1704,20 +1809,24 @@ AC_ARG_ENABLE([gallium-llvm],
         [build gallium LLVM support @<:@default=enabled on x86/x86_64@:>@])],
     [enable_gallium_llvm="$enableval"],
     [enable_gallium_llvm=auto])
+if test "x$with_gallium_drivers" = x; then
+    enable_gallium_llvm=no
+fi
 if test "x$enable_gallium_llvm" = xauto; then
     case "$host_cpu" in
     i*86|x86_64) enable_gallium_llvm=yes;;
     esac
 fi
 if test "x$enable_gallium_llvm" = xyes; then
+    AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
+
     if test "x$LLVM_CONFIG" != xno; then
        LLVM_VERSION=`$LLVM_CONFIG --version`
-       LLVM_CFLAGS=`$LLVM_CONFIG --cppflags`
+       LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed 's/-DNDEBUG\>//g'`
        LLVM_LIBS="`$LLVM_CONFIG --libs` -lstdc++"
 
        LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
-       GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
-       DEFINES="$DEFINES -DGALLIUM_LLVMPIPE -D__STDC_CONSTANT_MACROS"
+       DEFINES="$DEFINES -D__STDC_CONSTANT_MACROS"
        MESA_LLVM=1
     else
        MESA_LLVM=0
@@ -1726,11 +1835,32 @@ else
     MESA_LLVM=0
 fi
 
+dnl Directory for VDPAU libs
+AC_ARG_WITH([vdpau-libdir],
+    [AS_HELP_STRING([--with-vdpau-libdir=DIR],
+        [directory for the VDPAU libraries @<:@default=${libdir}/vdpau@:>@])],
+    [VDPAU_LIB_INSTALL_DIR="$withval"],
+    [VDPAU_LIB_INSTALL_DIR='${libdir}/vdpau'])
+AC_SUBST([VDPAU_LIB_INSTALL_DIR])
+
+dnl Directory for VA libs
+AC_ARG_WITH([va-libdir],
+    [AS_HELP_STRING([--with-va-libdir=DIR],
+        [directory for the VA libraries @<:@default=${libdir}/va@:>@])],
+    [VA_LIB_INSTALL_DIR="$withval"],
+    [VA_LIB_INSTALL_DIR='${libdir}/va'])
+AC_SUBST([VA_LIB_INSTALL_DIR])
+
 dnl
 dnl Gallium helper functions
 dnl
 gallium_check_st() {
-    if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes; then
+    if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_XORG" = xyes ||
+        test "x$HAVE_ST_XA" = xyes || test "x$HAVE_ST_XVMC" = xyes ||
+        test "x$HAVE_ST_VDPAU" = xyes || test "x$HAVE_ST_VA" = xyes; then
+         if test "x$have_libdrm" != xyes; then
+            AC_MSG_ERROR([DRI or Xorg DDX requires libdrm >= $LIBDRM_REQUIRED])
+         fi
          GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1"
     fi
     if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then
@@ -1739,6 +1869,21 @@ gallium_check_st() {
     if test "x$HAVE_ST_XORG" = xyes && test "x$3" != x; then
          GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3"
     fi
+    if test "x$HAVE_ST_XA" = xyes && test "x$4" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $4"
+    fi
+    if test "x$HAVE_ST_XVMC" = xyes && test "x$5" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $5"
+         NEED_G3DVL_DRI="yes"
+    fi
+    if test "x$HAVE_ST_VDPAU" = xyes && test "x$6" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $6"
+         NEED_G3DVL_DRI="yes"
+    fi
+    if test "x$HAVE_ST_VA" = xyes && test "x$7" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $7"
+         NEED_G3DVL_DRI="yes"
+    fi
 }
 
 gallium_require_llvm() {
@@ -1749,108 +1894,82 @@ gallium_require_llvm() {
     fi
 }
 
+dnl Gallium drivers
+dnl Duplicates in GALLIUM_DRIVERS_DIRS are removed by sorting it after this block
+if test "x$with_gallium_drivers" != x; then
+    gallium_drivers=`IFS=', '; echo $with_gallium_drivers`
+    for driver in $gallium_drivers; do
+        case "x$driver" in
+        xsvga)
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga softpipe"
+            gallium_check_st "svga/drm" "dri-vmwgfx" "xorg-vmwgfx" "xa-vmwgfx"
+            ;;
+        xi915)
+            PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 softpipe"
+            if test "x$MESA_LLVM" = x1; then
+                GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
+            fi
+            GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
+            gallium_check_st "i915/drm" "dri-i915" "xorg-i915"
+            ;;
+        xi965)
+            PKG_CHECK_MODULES([INTEL], [libdrm_intel >= $LIBDRM_INTEL_REQUIRED])
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965 softpipe"
+            if test "x$MESA_LLVM" = x1; then
+                GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
+            fi
+            gallium_check_st "i965/drm" "dri-i965" "xorg-i965"
+            ;;
+        xr300)
+            gallium_require_llvm "Gallium R300"
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
+            gallium_check_st "radeon/drm" "dri-r300" "xorg-r300" "" "xvmc-r300" "vdpau-r300" "va-r300"
+            ;;
+        xr600)
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
+            gallium_check_st "r600/drm" "dri-r600" "" "" "xvmc-r600" "vdpau-r600" "va-r600"
+            ;;
+        xnouveau)
+            PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NOUVEAU_REQUIRED])
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0"
+            gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" "" "xvmc-nouveau"
+            ;;
+        xswrast)
+            GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe"
+            if test "x$MESA_LLVM" = x1; then
+                GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
+            fi
 
-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_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
-    gallium_check_st "svga/drm" "dri-vmwgfx" "xorg-vmwgfx"
-elif test "x$enable_gallium_svga" = xauto; then
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
-fi
-
-dnl
-dnl Gallium i915 configuration
-dnl
-AC_ARG_ENABLE([gallium-i915],
-    [AS_HELP_STRING([--enable-gallium-i915],
-        [build gallium i915 @<:@default=disabled@:>@])],
-    [enable_gallium_i915="$enableval"],
-    [enable_gallium_i915=auto])
-if test "x$enable_gallium_i915" = xyes; then
-    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
-    gallium_check_st "i915/drm" "dri-i915" "xorg-i915"
-elif test "x$enable_gallium_i915" = xauto; then
-    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS i915/sw"
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
-fi
-
-dnl
-dnl Gallium i965 configuration
-dnl
-AC_ARG_ENABLE([gallium-i965],
-    [AS_HELP_STRING([--enable-gallium-i965],
-        [build gallium i965 @<:@default=disabled@:>@])],
-    [enable_gallium_i965="$enableval"],
-    [enable_gallium_i965=auto])
-if test "x$enable_gallium_i965" = xyes; then
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965"
-    gallium_check_st "i965/drm" "dri-i965" "xorg-i965"
-elif test "x$enable_gallium_i965" = xauto; then
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i965"
-fi
-
-dnl
-dnl Gallium Radeon r300g configuration
-dnl
-AC_ARG_ENABLE([gallium-r300],
-    [AS_HELP_STRING([--disable-gallium-r300],
-        [build R300 driver @<:@default=enabled@:>@])],
-    [enable_gallium_r300="$enableval"],
-    [enable_gallium_r300=yes])
-
-if test "x$enable_gallium_r300" = xyes && test "x$mesa_driver" = xdri; then
-    gallium_require_llvm "Gallium R300"
-
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
-    gallium_check_st "radeon/drm" "dri-r300" "xorg-r300"
-fi
-
-dnl
-dnl Gallium Radeon r600g configuration
-dnl
-AC_ARG_ENABLE([gallium-r600],
-    [AS_HELP_STRING([--enable-gallium-r600],
-        [build gallium r600 @<:@default=disabled@:>@])],
-    [enable_gallium_r600="$enableval"],
-    [enable_gallium_r600=auto])
-if test "x$enable_gallium_r600" = xyes; then
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
-    gallium_check_st "r600/drm" "dri-r600"
-fi
-
-dnl
-dnl Gallium Nouveau configuration
-dnl
-AC_ARG_ENABLE([gallium-nouveau],
-    [AS_HELP_STRING([--enable-gallium-nouveau],
-        [build gallium nouveau @<:@default=disabled@:>@])],
-    [enable_gallium_nouveau="$enableval"],
-    [enable_gallium_nouveau=no])
-if test "x$enable_gallium_nouveau" = xyes; then
-    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0"
-    gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau"
+            if test "x$HAVE_ST_DRI" = xyes; then
+                GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast"
+            fi
+            if test "x$HAVE_ST_VDPAU" = xyes; then
+                GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS vdpau-softpipe"
+            fi
+            if test "x$HAVE_ST_XVMC" = xyes; then
+                GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS xvmc-softpipe"
+            fi
+            if test "x$HAVE_ST_VA" = xyes; then
+                GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS va-softpipe"
+            fi
+            if test "x$HAVE_ST_VDPAU" == xyes ||
+               test "x$HAVE_ST_XVMC" == xyes ||
+               test "x$HAVE_ST_VA" == xyes; then
+               if test "x$HAVE_WINSYS_XLIB" != xyes; then
+                  GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
+               fi
+            fi
+            ;;
+        *)
+            AC_MSG_ERROR([Unknown Gallium driver: $driver])
+            ;;
+        esac
+    done
 fi
 
-dnl
-dnl Gallium swrast configuration
-dnl
-AC_ARG_ENABLE([gallium-swrast],
-    [AS_HELP_STRING([--enable-gallium-swrast],
-        [build gallium swrast @<:@default=auto@:>@])],
-    [enable_gallium_swrast="$enableval"],
-    [enable_gallium_swrast=auto])
-if test "x$enable_gallium_swrast" = xyes || test "x$enable_gallium_swrast" = xauto; then
-    if test "x$HAVE_ST_DRI" = xyes; then
-        GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast"
-    fi
+if test "x$NEED_G3DVL_DRI" = xyes; then
+    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS g3dvl/dri"
 fi
 
 dnl prepend CORE_DIRS to SRC_DIRS
@@ -1860,6 +1979,10 @@ dnl Restore LDFLAGS and CPPFLAGS
 LDFLAGS="$_SAVE_LDFLAGS"
 CPPFLAGS="$_SAVE_CPPFLAGS"
 
+dnl Add user CFLAGS and CXXFLAGS
+CFLAGS="$CFLAGS $USER_CFLAGS"
+CXXFLAGS="$CXXFLAGS $USER_CXXFLAGS"
+
 dnl Substitute the config
 AC_CONFIG_FILES([configs/autoconf])
 
@@ -1871,6 +1994,12 @@ fi
 ln -s autoconf configs/current
 ])
 
+dnl Sort the dirs alphabetically
+GALLIUM_TARGET_DIRS=`echo $GALLIUM_TARGET_DIRS|tr " " "\n"|sort|tr "\n" " "`
+GALLIUM_WINSYS_DIRS=`echo $GALLIUM_WINSYS_DIRS|tr " " "\n"|sort|tr "\n" " "`
+GALLIUM_DRIVERS_DIRS=`echo $GALLIUM_DRIVERS_DIRS|tr " " "\n"|sort|tr "\n" " "`
+GALLIUM_STATE_TRACKERS_DIRS=`echo $GALLIUM_STATE_TRACKERS_DIRS|tr " " "\n"|sort|tr "\n" " "`
+
 AC_OUTPUT
 
 dnl
@@ -1889,14 +2018,13 @@ echo "        OpenVG:          $enable_openvg"
 
 dnl Driver info
 echo ""
-echo "        Driver:          $mesa_driver"
-if test "$mesa_driver" != no; then
-    if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
+if test "x$enable_osmesa" != xno; then
         echo "        OSMesa:          lib$OSMESA_LIB"
-    else
+else
         echo "        OSMesa:          no"
-    fi
-    if test "$mesa_driver" = dri; then
+fi
+
+if test "x$enable_dri" != xno; then
         # cleanup the drivers var
         dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/  */ /;s/ *$//'`
         if test "x$DRI_DIRS" = x; then
@@ -1905,14 +2033,25 @@ if test "$mesa_driver" != no; then
             echo "        DRI drivers:     $dri_dirs"
         fi
         echo "        DRI driver dir:  $DRI_DRIVER_INSTALL_DIR"
-        echo "        Use XCB:         $enable_xcb"
         echo "        Shared dricore:  $enable_dricore"
-    fi
 fi
+
+case "x$enable_glx$enable_xlib_glx" in
+xyesyes)
+    echo "        GLX:             Xlib-based"
+    ;;
+xyesno)
+    echo "        GLX:             DRI-based"
+    echo "        Use XCB:         $enable_xcb"
+    ;;
+*)
+    echo "        GLX:             $enable_glx"
+    ;;
+esac
+
 echo ""
 echo "        GLU:             $enable_glu"
 echo "        GLw:             $enable_glw (Motif: $enable_motif)"
-echo "        glut:            $enable_glut"
 
 dnl EGL
 echo ""
@@ -1925,7 +2064,7 @@ if test "$enable_egl" = yes; then
         egl_drivers="$egl_drivers builtin:egl_$d"
     done
 
-    if test "$enable_gallium" = yes -a "$HAVE_ST_EGL" = yes; then
+    if test "x$HAVE_ST_EGL" = xyes; then
         echo "        EGL drivers:    ${egl_drivers} egl_gallium"
         echo "        EGL Gallium STs:$EGL_CLIENT_APIS"
     else
index d86c4b0..135bc4b 100644 (file)
@@ -19,7 +19,7 @@ Clamping controls (GL_ARB_color_buffer_float)         DONE
 Float textures, renderbuffers (GL_ARB_texture_float)  DONE (gallium r300)
 GL_EXT_packed_float                                   DONE (gallium r600)
 GL_EXT_texture_shared_exponent                        DONE (gallium, swrast)
-Float depth buffers (GL_ARB_depth_buffer_float)       not started
+Float depth buffers (GL_ARB_depth_buffer_float)       DONE
 Framebuffer objects (GL_EXT_framebuffer_object)       DONE
 Half-float                                            DONE
 Multisample blit                                      DONE
@@ -40,7 +40,7 @@ glTexParameterI, glGetTexParameterI commands          DONE
 glVertexAttribI commands                              DONE (but converts int
                                                             values to floats)
 Depth format cube textures                            0% done
-
+GLX_ARB_create_context (GLX 1.4 is required)          not started
 
 
 GL 3.1:
@@ -49,7 +49,7 @@ GLSL 1.40                                             not started
 Instanced drawing (GL_ARB_draw_instanced)             DONE (gallium, swrast)
 Buffer copying (GL_ARB_copy_buffer)                   DONE
 Primitive restart (GL_NV_primitive_restart)           DONE (gallium)
-16 vertex texture image units                         not started
+16 vertex texture image units                         DONE
 Texture buffer objs (GL_ARB_texture_buffer_object)    not started
 Rectangular textures (GL_ARB_texture_rectangle)       DONE
 Uniform buffer objs (GL_ARB_uniform_buffer_object)    not started
@@ -69,6 +69,7 @@ Seamless cubemaps (GL_ARB_seamless_cube_map)          DONE
 Multisample textures (GL_ARB_texture_multisample)     not started
 Frag depth clamp (GL_ARB_depth_clamp)                 DONE
 Fence objects (GL_ARB_sync)                           DONE
+GLX_ARB_create_context_profile                        not started
 
 
 GL 3.3:
index 936ddcf..64bcbd4 100644 (file)
@@ -21,7 +21,6 @@
   <ul>
   <li><a href="#glu">GLU</a></li>
   <li><a href="#glw">GLw</a></li>
-  <li><a href="#glut">GLUT</a></li>
   </ul>
 <li><a href="#demos">Demo Program Options</a></li>
 </ol>
@@ -252,13 +251,6 @@ on all drivers. This can be disable with the option
 if libGLU has been enabled. This can be disable with the option
 <code>--disable-glw</code>.
 </li>
-
-<a name="glut">
-<li><b><em>GLUT</em></b> - The libglut library will be built by default
-if libGLU has been enabled and the glut source code from the MesaGLUT
-tarball is available. This can be disable with the option
-<code>--disable-glut</code>.
-</li>
 </ul>
 </p>
 
index 2d1c125..8887dd0 100644 (file)
@@ -161,12 +161,6 @@ Then: <code>git push origin mesa_X_Y</code>
 
 <H3>Make the tarballs</H3>
 <p>
-Make a symbolic link from $(DIRECTORY) to 'Mesa'.  For example,
-<code>ln -s Mesa Mesa-7.5</code>
-This is needed in order to make a correct tar file in the next step.
-</p>
-
-<p>
 Make the distribution files.  From inside the Mesa directory:
 <pre>
        make tarballs
index 03fa60b..3c4d597 100644 (file)
@@ -25,9 +25,8 @@ The Mesa package is named MesaLib-x.y.z.{tar.bz2, tar.gz, zip} where x.y.z
 is the version.  There are three types of compressed archives.
 </p>
 <p>
-There's also the MesaGLUT-x.y.z.{tar.bz2, tar.gz, zip} packages which
-contain Mark Kilgard's GLUT library.
-This is optional.
+In the past, there was also MesaGLUT-x.y.z.{tar.bz2, tar.gz, zip} packages which
+contained Mark Kilgard's GLUT library.
 Most Linux distributions include an implementation of GLUT (such as freeglut).
 </p>
 <p>
index fb15086..5b75007 100644 (file)
@@ -29,12 +29,14 @@ directly dispatched to the drivers.</p>
 the driver for your hardware.  For example</p>
 
 <pre>
-  $ ./configure --enable-gles2 --enable-openvg --enable-gallium-nouveau
+  $ ./configure --enable-gles1 --enable-gles2 \
+                --with-dri-drivers=... \
+                --with-gallium-drivers=...
 </pre>
 
-<p>The main library and OpenGL is enabled by default.  The first option above
-enables <a href="opengles.html">OpenGL ES 2.x</a>.  The second option enables
-<a href="openvg.html">OpenVG</a>.</p>
+<p>The main library and OpenGL is enabled by default.  The first two options
+above enables <a href="opengles.html">OpenGL ES 1.x and 2.x</a>.  The last two
+options enables the listed classic and and Gallium drivers respectively.</p>
 
 </li>
 
@@ -42,8 +44,8 @@ enables <a href="opengles.html">OpenGL ES 2.x</a>.  The second option enables
 </ol>
 
 <p>In the given example, it will build and install <code>libEGL</code>,
-<code>libGL</code>, <code>libGLESv1_CM</code>, <code>libGLESv2</code>,
-<code>libOpenVG</code>, and one or more EGL drivers.</p>
+<code>libGL</code>, <code>libGLESv1_CM</code>, <code>libGLESv2</code>, and one
+or more EGL drivers.</p>
 
 <h3>Configure Options</h3>
 
@@ -65,6 +67,12 @@ drivers will be installed to <code>${libdir}/egl</code>.</p>
 
 </li>
 
+<li><code>--enable-gallium-egl</code>
+
+<p>Enable the optional <code>egl_gallium</code> driver.</p>
+
+</li>
+
 <li><code>--with-egl-platforms</code>
 
 <p>List the platforms (window systems) to support.  Its argument is a comma
@@ -88,15 +96,17 @@ internal library that supports multiple APIs.</p>
 
 </li>
 
-<li><code>--enable-openvg</code>
+<li><code>--enable-shared-glapi</code>
 
-<p>OpenVG must be explicitly enabled by this option.</p>
+<p>By default, <code>libGL</code> has its own copy of <code>libglapi</code>.
+This options makes <code>libGL</code> use the shared <code>libglapi</code>.  This
+is required if applications mix OpenGL and OpenGL ES.</p>
 
 </li>
 
-<li><code>--enable-gallium-egl</code>
+<li><code>--enable-openvg</code>
 
-<p>Explicitly enable or disable <code>egl_gallium</code>.</p>
+<p>OpenVG must be explicitly enabled by this option.</p>
 
 </li>
 
@@ -220,8 +230,7 @@ distribution.</p>
 <p>Generally, <code>egl_dri2</code> is preferred over <code>egl_gallium</code>
 when the system already has DRI drivers.  As <code>egl_gallium</code> is loaded
 before <code>egl_dri2</code> when both are available, <code>egl_gallium</code>
-may either be disabled with <code>--disable-gallium-egl</code> or packaged
-separately.</p>
+is disabled by default.</p>
 
 <h2>Developers</h2>
 
@@ -307,17 +316,5 @@ not be called with the sample display at the same time.  If a driver has access
 to an <code>EGLDisplay</code> without going through the EGL APIs, the driver
 should as well lock the display before using it.
 
-<h3>TODOs</h3>
-
-<ul>
-<li>Pass the conformance tests</li>
-<li>Mixed use of OpenGL, OpenGL ES 1.1, and OpenGL ES 2.0 is supported.  But
-which one of <code>libGL.so</code>, <code>libGLESv1_CM.so</code>, and
-<code>libGLESv2.so</code> should an application link to?  Bad things may happen
-when, say, an application is linked to <code>libGLESv2.so</code> and
-<code>libcairo</code>, which is linked to <code>libGL.so</code> instead.</li>
-
-</ul>
-
 </body>
 </html>
index 65e279a..071381c 100644 (file)
@@ -198,9 +198,9 @@ Mesa's not the solution.
 
 <h2><a name="part2">2.3 Where is the GLUT library?</a></h2>
 <p>
-<a name="part2">GLUT (OpenGL Utility Toolkit) is in the separate MesaGLUT-x.y.z.tar.gz file.
-If you don't already have GLUT installed, you should grab the MesaGLUT
-package and compile it with the rest of Mesa.
+<a name="part2">GLUT (OpenGL Utility Toolkit) is no longer in the separate MesaGLUT-x.y.z.tar.gz file.
+If you don't already have GLUT installed, you should grab 
+<a href="http://freeglut.sourceforge.net/">freeglut</a>.
 </a></p>
 
 
index 44b980d..5da8ef1 100644 (file)
@@ -38,10 +38,10 @@ target="_parent">Silicon Graphics Incorporated</a>.
 
 <p>
 The Mesa distribution consists of several components.  Different copyrights
-and licenses apply to different components.  For example, GLUT is copyrighted
-by Mark Kilgard, some demo programs are copyrighted by SGI, some of the Mesa
-device drivers are copyrighted by their authors.  See below for a list of
-Mesa's main components and the license for each.
+and licenses apply to different components.  For example, some demo programs
+are copyrighted by SGI, some of the Mesa device drivers are copyrighted by
+their authors.  See below for a list of Mesa's main components and the license
+for each.
 </p>
 <p>
 The core Mesa library is licensed according to the terms of the MIT license.
index 742182e..0fee488 100644 (file)
@@ -34,27 +34,10 @@ EGL drivers for your hardware.</p>
 
 <h2>Run the Demos</h2>
 
-<p>There are some demos in <code>progs/egl/</code>.  You can use them to test
-your build.  For example,</p>
-
-<pre>
-  $ cd progs/egl/eglut
-  $ make
-  $ cd ../opengles1
-  $ make
-  $ ./torus_x11
-</pre>
+<p>There are some demos in <code>mesa/demos</code> repository.</p>
 
 <h2>Developers</h2>
 
-<h3>Internal Libraries</h3>
-
-<table border="1" style="text-align: center;">
-       <tr><td>Library Name</td><td>Used By</td><td>Enabled</td><td>OpenGL</td><td>OpenGL ES 1.x</td><td>OpenGL ES 2.x</td></tr>
-       <tr><td><code>libmesa.a</td><td>Classic DRI drivers</td><td>y</td><td>y</td><td>--enable-gles1</td><td>--enable-gles2</td></tr>
-       <tr><td><code>libmesagallium.a</td><td>Gallium EGL and DRI drivers</td><td>y</td><td>y</td><td>--enable-gles1</td><td>--enable-gles2</td></tr>
-</table>
-
 <h3>Dispatch Table</h3>
 
 <p>OpenGL ES has an additional indirection when dispatching fucntions</p>
index eff8c58..81e50b6 100644 (file)
@@ -11,7 +11,7 @@
 <H1>OpenVG State Tracker</H1>
 
 <p>
-The current version of the OpenVG state tracker implements OpenVG 1.0.
+The current version of the OpenVG state tracker implements OpenVG 1.1.
 </p>
 <p>
 More informations about OpenVG can be found at
@@ -26,9 +26,9 @@ Please refer to <a href="egl.html">Mesa EGL</a> for more information about EGL.
 
 <h2>Building the library</h2>
 <ol>
-<li>Run <code>configure</code> with <code>--enable-openvg</code>.  If you do
-not need OpenGL, you can add <code>--disable-opengl</code> to save the
-compilation time.</li>
+<li>Run <code>configure</code> with <code>--enable-openvg</code> and
+<code>--enable-gallium-egl</code>.  If you do not need OpenGL, you can add
+<code>--disable-opengl</code> to save the compilation time.</li>
 
 <li>Build and install Mesa as usual.</li>
 </ol>
@@ -36,7 +36,7 @@ compilation time.</li>
 <h3>Sample build</h3>
 A sample build looks as follows:
 <pre>
-  $ ./configure --disable-opengl --enable-openvg
+  $ ./configure --disable-opengl --enable-openvg --enable-gallium-egl
   $ make
   $ make install
 </pre>
index aaeabc2..c81ac9f 100644 (file)
@@ -45,7 +45,7 @@ tbd
 <li>GL_ARB_robustness (all drivers)
 <li>GL_ARB_sampler_objects (gallium drivers)
 <li>GL_ARB_seamless_cube_map (gallium r600)
-<li>GL_ARB_shader_texture_lod (gallium drivers)
+<li>GL_ARB_shader_texture_lod (gallium drivers, i965)
 <li>GL_ARB_sync (gallium drivers only, intel support was in 7.6)
 <li>GL_ARB_texture_compression_rgtc (gallium drivers, swrast, i965)
 <li>GL_ARB_texture_float (gallium, i965)
index 08a9a50..2e2d1d3 100644 (file)
@@ -150,7 +150,6 @@ each directory.
      <li><b>sgi</b> - GLU from SGI
      <li><b>mesa</b> - Mesa version of GLU (deprecated)
      </ul>
-  <li><b>glut</b> - Mark Kilgard's OpenGL OpenGL Utility Toolkit library
   <li><b>glx</b> - The GLX library code for building libGL.  This is used for
          direct rendering drivers.  It will dynamically load one of the 
          xxx_dri.so drivers.
index e4aa099..fbfdce3 100644 (file)
@@ -84,6 +84,12 @@ typedef struct wl_display     *EGLNativeDisplayType;
 typedef struct wl_egl_pixmap  *EGLNativePixmapType;
 typedef struct wl_egl_window  *EGLNativeWindowType;
 
+#elif defined(__GBM__)
+
+typedef struct gbm_device  *EGLNativeDisplayType;
+typedef struct gbm_bo      *EGLNativePixmapType;
+typedef void               *EGLNativeWindowType;
+
 #elif defined(__unix__) || defined(__unix)
 
 #ifdef MESA_EGL_NO_X11_HEADERS
index 6e5e6a1..9048515 100644 (file)
@@ -6,7 +6,7 @@ extern "C" {
 #endif
 
 /*
-** Copyright (c) 2007-2010 The Khronos Group Inc.
+** Copyright (c) 2007-2011 The Khronos Group Inc.
 ** 
 ** Permission is hereby granted, free of charge, to any person obtaining a
 ** copy of this software and/or associated documentation files (the
@@ -29,9 +29,9 @@ extern "C" {
 */
 
 /* Header file version number, required by OpenGL ABI for Linux */
-/* glext.h last updated $Date: 2010-12-09 02:15:08 -0800 (Thu, 09 Dec 2010) $ */
+/* glext.h last updated $Date: 2011-07-06 02:49:14 -0700 (Wed, 06 Jul 2011) $ */
 /* Current version at http://www.opengl.org/registry/ */
-#define GL_GLEXT_VERSION 67
+#define GL_GLEXT_VERSION 71
 /* Function declaration macros - to move into glplatform.h */
 
 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
@@ -5032,6 +5032,32 @@ extern "C" {
 #define GL_SKIP_DECODE_EXT                0x8A4A
 #endif
 
+#ifndef GL_NV_texture_multisample
+#define GL_TEXTURE_COVERAGE_SAMPLES_NV    0x9045
+#define GL_TEXTURE_COLOR_SAMPLES_NV       0x9046
+#endif
+
+#ifndef GL_AMD_blend_minmax_factor
+#define GL_FACTOR_MIN_AMD                 0x901C
+#define GL_FACTOR_MAX_AMD                 0x901D
+#endif
+
+#ifndef GL_AMD_sample_positions
+#define GL_SUBSAMPLE_DISTANCE_AMD         0x883F
+#endif
+
+#ifndef GL_EXT_x11_sync_object
+#define GL_SYNC_X11_FENCE_EXT             0x90E1
+#endif
+
+#ifndef GL_AMD_multi_draw_indirect
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample_blit_scaled
+#define GL_SCALED_RESOLVE_FASTEST_EXT     0x90BA
+#define GL_SCALED_RESOLVE_NICEST_EXT      0x90BB
+#endif
+
 
 /*************************************************************/
 
@@ -11041,6 +11067,58 @@ typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, cons
 #define GL_EXT_texture_sRGB_decode 1
 #endif
 
+#ifndef GL_NV_texture_multisample
+#define GL_NV_texture_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+#endif
+
+#ifndef GL_AMD_blend_minmax_factor
+#define GL_AMD_blend_minmax_factor 1
+#endif
+
+#ifndef GL_AMD_sample_positions
+#define GL_AMD_sample_positions 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val);
+#endif
+
+#ifndef GL_EXT_x11_sync_object
+#define GL_EXT_x11_sync_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
+#endif
+
+#ifndef GL_AMD_multi_draw_indirect
+#define GL_AMD_multi_draw_indirect 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample_blit_scaled
+#define GL_EXT_framebuffer_multisample_blit_scaled 1
+#endif
+
 
 #ifdef __cplusplus
 }
diff --git a/include/GL/glut.h b/include/GL/glut.h
deleted file mode 100644 (file)
index a282635..0000000
+++ /dev/null
@@ -1,665 +0,0 @@
-#ifndef __glut_h__
-#define __glut_h__
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */
-
-/* This program is freely distributable without licensing fees  and is
-   provided without guarantee or warrantee expressed or  implied. This
-   program is -not- in the public domain. */
-
-#if defined(_WIN32)
-#  ifndef WIN32_LEAN_AND_MEAN
-#    define WIN32_LEAN_AND_MEAN 1
-#  endif
-#  include <windows.h>
-#endif
-
-#include <GL/gl.h>
-#include <GL/glu.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(_WIN32)
-
-/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA
-   in your compile preprocessor options. */
-# if defined(_MSC_VER) && !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA)
-#  pragma comment (lib, "winmm.lib")      /* link with Windows MultiMedia lib */
-/* To enable automatic SGI OpenGL for Windows library usage for GLUT,
-   define GLUT_USE_SGI_OPENGL in your compile preprocessor options.  */
-#  ifdef GLUT_USE_SGI_OPENGL
-#   pragma comment (lib, "opengl.lib")    /* link with SGI OpenGL for Windows lib */
-#   pragma comment (lib, "glu.lib")       /* link with SGI OpenGL Utility lib */
-#   pragma comment (lib, "glut.lib")      /* link with Win32 GLUT for SGI OpenGL lib */
-#  else
-#   pragma comment (lib, "opengl32.lib")  /* link with Microsoft OpenGL lib */
-#   pragma comment (lib, "glu32.lib")     /* link with Microsoft OpenGL Utility lib */
-#   pragma comment (lib, "glut32.lib")    /* link with Win32 GLUT lib */
-#  endif
-# endif
-
-/* To disable supression of annoying warnings about floats being promoted
-   to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor
-   options. */
-# if defined(_MSC_VER) && !defined(GLUT_NO_WARNING_DISABLE)
-#  pragma warning (disable:4244)  /* Disable bogus VC++ 4.2 conversion warnings. */
-#  pragma warning (disable:4305)  /* VC++ 5.0 version of above warning. */
-# endif
-
-/* Win32 has an annoying issue where there are multiple C run-time
-   libraries (CRTs).  If the executable is linked with a different CRT
-   from the GLUT DLL, the GLUT DLL will not share the same CRT static
-   data seen by the executable.  In particular, atexit callbacks registered
-   in the executable will not be called if GLUT calls its (different)
-   exit routine).  GLUT is typically built with the
-   "/MD" option (the CRT with multithreading DLL support), but the Visual
-   C++ linker default is "/ML" (the single threaded CRT).
-
-   One workaround to this issue is requiring users to always link with
-   the same CRT as GLUT is compiled with.  That requires users supply a
-   non-standard option.  GLUT 3.7 has its own built-in workaround where
-   the executable's "exit" function pointer is covertly passed to GLUT.
-   GLUT then calls the executable's exit function pointer to ensure that
-   any "atexit" calls registered by the application are called if GLUT
-   needs to exit.
-
-   Note that the __glut*WithExit routines should NEVER be called directly.
-   To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
-
-/* XXX This is from Win32's <process.h> */
-# if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__cdecl)
-   /* Define __cdecl for non-Microsoft compilers. */
-#  define __cdecl
-#  define GLUT_DEFINED___CDECL
-# endif
-#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
-#include <stdlib.h>
-#endif
-
-/* GLUT callback calling convention for Win32. */
-# define GLUTCALLBACK __cdecl
-
-/* for callback/function pointer defs */
-# define GLUTAPIENTRYV __cdecl
-
-/* glut-win32 specific macros, defined to prevent collision with
-   and redifinition of Windows system defs, also removes requirement of
-   pretty much any standard windows header from this file */
-
-#if (_MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
-#      define GLUTAPIENTRY __stdcall
-#else
-#      define GLUTAPIENTRY
-#endif
-
-/* GLUT API entry point declarations for Win32. */
-#if (defined(BUILD_GLUT32) || defined(GLUT_BUILDING_LIB)) && !defined(GLUT_STATIC)
-#      define GLUTAPI __declspec(dllexport)
-#elif !defined(GLUT_STATIC)
-#   define GLUTAPI __declspec(dllimport)
-#else
-#      define GLUTAPI extern
-#endif
-
-#elif defined(__GNUC__)
-
-#  define GLUTAPIENTRY
-#  define GLUTAPIENTRYV
-#  define GLUTCALLBACK
-#  define GLUTAPI extern __attribute__((visibility("default")))
-
-#else
-
-/* Define GLUTAPIENTRY and GLUTCALLBACK to nothing */
-#  define GLUTAPIENTRY
-#  define GLUTAPIENTRYV
-#  define GLUTCALLBACK
-#  define GLUTAPI extern
-
-#endif
-
-
-/**
- GLUT API revision history:
-
- GLUT_API_VERSION is updated to reflect incompatible GLUT
- API changes (interface changes, semantic changes, deletions,
- or additions).
-
- GLUT_API_VERSION=1  First public release of GLUT.  11/29/94
-
- GLUT_API_VERSION=2  Added support for OpenGL/GLX multisampling,
- extension.  Supports new input devices like tablet, dial and button
- box, and Spaceball.  Easy to query OpenGL extensions.
-
- GLUT_API_VERSION=3  glutMenuStatus added.
-
- GLUT_API_VERSION=4  glutInitDisplayString, glutWarpPointer,
- glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic
- video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc,
- glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat,
- glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!).
-
- GLUT_API_VERSION=5  glutGetProcAddress (added by BrianP)
-**/
-#ifndef GLUT_API_VERSION  /* allow this to be overriden */
-#define GLUT_API_VERSION               5
-#endif
-
-/**
- GLUT implementation revision history:
-
- GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT
- API revisions and implementation revisions (ie, bug fixes).
-
- GLUT_XLIB_IMPLEMENTATION=1  mjk's first public release of
- GLUT Xlib-based implementation.  11/29/94
-
- GLUT_XLIB_IMPLEMENTATION=2  mjk's second public release of
- GLUT Xlib-based implementation providing GLUT version 2
- interfaces.
-
- GLUT_XLIB_IMPLEMENTATION=3  mjk's GLUT 2.2 images. 4/17/95
-
- GLUT_XLIB_IMPLEMENTATION=4  mjk's GLUT 2.3 images. 6/?/95
-
- GLUT_XLIB_IMPLEMENTATION=5  mjk's GLUT 3.0 images. 10/?/95
-
- GLUT_XLIB_IMPLEMENTATION=7  mjk's GLUT 3.1+ with glutWarpPoitner.  7/24/96
-
- GLUT_XLIB_IMPLEMENTATION=8  mjk's GLUT 3.1+ with glutWarpPoitner
- and video resize.  1/3/97
-
- GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines.
-
- GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release.
-
- GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling.
-
- GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support.
-
- GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface.
-
- GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa <GL/glut.h>
-**/
-#ifndef GLUT_XLIB_IMPLEMENTATION  /* Allow this to be overriden. */
-#define GLUT_XLIB_IMPLEMENTATION       15
-#endif
-
-/* Display mode bit masks. */
-#define GLUT_RGB                       0
-#define GLUT_RGBA                      GLUT_RGB
-#define GLUT_INDEX                     1
-#define GLUT_SINGLE                    0
-#define GLUT_DOUBLE                    2
-#define GLUT_ACCUM                     4
-#define GLUT_ALPHA                     8
-#define GLUT_DEPTH                     16
-#define GLUT_STENCIL                   32
-#if (GLUT_API_VERSION >= 2)
-#define GLUT_MULTISAMPLE               128
-#define GLUT_STEREO                    256
-#endif
-#if (GLUT_API_VERSION >= 3)
-#define GLUT_LUMINANCE                 512
-#endif
-
-/* Mouse buttons. */
-#define GLUT_LEFT_BUTTON               0
-#define GLUT_MIDDLE_BUTTON             1
-#define GLUT_RIGHT_BUTTON              2
-
-/* Mouse button  state. */
-#define GLUT_DOWN                      0
-#define GLUT_UP                                1
-
-#if (GLUT_API_VERSION >= 2)
-/* function keys */
-#define GLUT_KEY_F1                    1
-#define GLUT_KEY_F2                    2
-#define GLUT_KEY_F3                    3
-#define GLUT_KEY_F4                    4
-#define GLUT_KEY_F5                    5
-#define GLUT_KEY_F6                    6
-#define GLUT_KEY_F7                    7
-#define GLUT_KEY_F8                    8
-#define GLUT_KEY_F9                    9
-#define GLUT_KEY_F10                   10
-#define GLUT_KEY_F11                   11
-#define GLUT_KEY_F12                   12
-/* directional keys */
-#define GLUT_KEY_LEFT                  100
-#define GLUT_KEY_UP                    101
-#define GLUT_KEY_RIGHT                 102
-#define GLUT_KEY_DOWN                  103
-#define GLUT_KEY_PAGE_UP               104
-#define GLUT_KEY_PAGE_DOWN             105
-#define GLUT_KEY_HOME                  106
-#define GLUT_KEY_END                   107
-#define GLUT_KEY_INSERT                        108
-#endif
-
-/* Entry/exit  state. */
-#define GLUT_LEFT                      0
-#define GLUT_ENTERED                   1
-
-/* Menu usage  state. */
-#define GLUT_MENU_NOT_IN_USE           0
-#define GLUT_MENU_IN_USE               1
-
-/* Visibility  state. */
-#define GLUT_NOT_VISIBLE               0
-#define GLUT_VISIBLE                   1
-
-/* Window status  state. */
-#define GLUT_HIDDEN                    0
-#define GLUT_FULLY_RETAINED            1
-#define GLUT_PARTIALLY_RETAINED                2
-#define GLUT_FULLY_COVERED             3
-
-/* Color index component selection values. */
-#define GLUT_RED                       0
-#define GLUT_GREEN                     1
-#define GLUT_BLUE                      2
-
-/* Layers for use. */
-#define GLUT_NORMAL                    0
-#define GLUT_OVERLAY                   1
-
-#if defined(_WIN32) || defined (GLUT_IMPORT_LIB)
-/* Stroke font constants (use these in GLUT program). */
-#define GLUT_STROKE_ROMAN              ((void*)0)
-#define GLUT_STROKE_MONO_ROMAN         ((void*)1)
-
-/* Bitmap font constants (use these in GLUT program). */
-#define GLUT_BITMAP_9_BY_15            ((void*)2)
-#define GLUT_BITMAP_8_BY_13            ((void*)3)
-#define GLUT_BITMAP_TIMES_ROMAN_10     ((void*)4)
-#define GLUT_BITMAP_TIMES_ROMAN_24     ((void*)5)
-#if (GLUT_API_VERSION >= 3)
-#define GLUT_BITMAP_HELVETICA_10       ((void*)6)
-#define GLUT_BITMAP_HELVETICA_12       ((void*)7)
-#define GLUT_BITMAP_HELVETICA_18       ((void*)8)
-#endif
-#else
-/* Stroke font opaque addresses (use constants instead in source code). */
-GLUTAPI void *glutStrokeRoman;
-GLUTAPI void *glutStrokeMonoRoman;
-
-/* Stroke font constants (use these in GLUT program). */
-#define GLUT_STROKE_ROMAN              (&glutStrokeRoman)
-#define GLUT_STROKE_MONO_ROMAN         (&glutStrokeMonoRoman)
-
-/* Bitmap font opaque addresses (use constants instead in source code). */
-GLUTAPI void *glutBitmap9By15;
-GLUTAPI void *glutBitmap8By13;
-GLUTAPI void *glutBitmapTimesRoman10;
-GLUTAPI void *glutBitmapTimesRoman24;
-GLUTAPI void *glutBitmapHelvetica10;
-GLUTAPI void *glutBitmapHelvetica12;
-GLUTAPI void *glutBitmapHelvetica18;
-
-/* Bitmap font constants (use these in GLUT program). */
-#define GLUT_BITMAP_9_BY_15            (&glutBitmap9By15)
-#define GLUT_BITMAP_8_BY_13            (&glutBitmap8By13)
-#define GLUT_BITMAP_TIMES_ROMAN_10     (&glutBitmapTimesRoman10)
-#define GLUT_BITMAP_TIMES_ROMAN_24     (&glutBitmapTimesRoman24)
-#if (GLUT_API_VERSION >= 3)
-#define GLUT_BITMAP_HELVETICA_10       (&glutBitmapHelvetica10)
-#define GLUT_BITMAP_HELVETICA_12       (&glutBitmapHelvetica12)
-#define GLUT_BITMAP_HELVETICA_18       (&glutBitmapHelvetica18)
-#endif
-#endif
-
-/* glutGet parameters. */
-#define GLUT_WINDOW_X                  100
-#define GLUT_WINDOW_Y                  101
-#define GLUT_WINDOW_WIDTH              102
-#define GLUT_WINDOW_HEIGHT             103
-#define GLUT_WINDOW_BUFFER_SIZE                104
-#define GLUT_WINDOW_STENCIL_SIZE       105
-#define GLUT_WINDOW_DEPTH_SIZE         106
-#define GLUT_WINDOW_RED_SIZE           107
-#define GLUT_WINDOW_GREEN_SIZE         108
-#define GLUT_WINDOW_BLUE_SIZE          109
-#define GLUT_WINDOW_ALPHA_SIZE         110
-#define GLUT_WINDOW_ACCUM_RED_SIZE     111
-#define GLUT_WINDOW_ACCUM_GREEN_SIZE   112
-#define GLUT_WINDOW_ACCUM_BLUE_SIZE    113
-#define GLUT_WINDOW_ACCUM_ALPHA_SIZE   114
-#define GLUT_WINDOW_DOUBLEBUFFER       115
-#define GLUT_WINDOW_RGBA               116
-#define GLUT_WINDOW_PARENT             117
-#define GLUT_WINDOW_NUM_CHILDREN       118
-#define GLUT_WINDOW_COLORMAP_SIZE      119
-#if (GLUT_API_VERSION >= 2)
-#define GLUT_WINDOW_NUM_SAMPLES                120
-#define GLUT_WINDOW_STEREO             121
-#endif
-#if (GLUT_API_VERSION >= 3)
-#define GLUT_WINDOW_CURSOR             122
-#endif
-#define GLUT_SCREEN_WIDTH              200
-#define GLUT_SCREEN_HEIGHT             201
-#define GLUT_SCREEN_WIDTH_MM           202
-#define GLUT_SCREEN_HEIGHT_MM          203
-#define GLUT_MENU_NUM_ITEMS            300
-#define GLUT_DISPLAY_MODE_POSSIBLE     400
-#define GLUT_INIT_WINDOW_X             500
-#define GLUT_INIT_WINDOW_Y             501
-#define GLUT_INIT_WINDOW_WIDTH         502
-#define GLUT_INIT_WINDOW_HEIGHT                503
-#define GLUT_INIT_DISPLAY_MODE         504
-#if (GLUT_API_VERSION >= 2)
-#define GLUT_ELAPSED_TIME              700
-#endif
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
-#define GLUT_WINDOW_FORMAT_ID          123
-#endif
-
-#if (GLUT_API_VERSION >= 2)
-/* glutDeviceGet parameters. */
-#define GLUT_HAS_KEYBOARD              600
-#define GLUT_HAS_MOUSE                 601
-#define GLUT_HAS_SPACEBALL             602
-#define GLUT_HAS_DIAL_AND_BUTTON_BOX   603
-#define GLUT_HAS_TABLET                        604
-#define GLUT_NUM_MOUSE_BUTTONS         605
-#define GLUT_NUM_SPACEBALL_BUTTONS     606
-#define GLUT_NUM_BUTTON_BOX_BUTTONS    607
-#define GLUT_NUM_DIALS                 608
-#define GLUT_NUM_TABLET_BUTTONS                609
-#endif
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
-#define GLUT_DEVICE_IGNORE_KEY_REPEAT   610
-#define GLUT_DEVICE_KEY_REPEAT          611
-#define GLUT_HAS_JOYSTICK              612
-#define GLUT_OWNS_JOYSTICK             613
-#define GLUT_JOYSTICK_BUTTONS          614
-#define GLUT_JOYSTICK_AXES             615
-#define GLUT_JOYSTICK_POLL_RATE                616
-#endif
-
-#if (GLUT_API_VERSION >= 3)
-/* glutLayerGet parameters. */
-#define GLUT_OVERLAY_POSSIBLE           800
-#define GLUT_LAYER_IN_USE              801
-#define GLUT_HAS_OVERLAY               802
-#define GLUT_TRANSPARENT_INDEX         803
-#define GLUT_NORMAL_DAMAGED            804
-#define GLUT_OVERLAY_DAMAGED           805
-
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
-/* glutVideoResizeGet parameters. */
-#define GLUT_VIDEO_RESIZE_POSSIBLE     900
-#define GLUT_VIDEO_RESIZE_IN_USE       901
-#define GLUT_VIDEO_RESIZE_X_DELTA      902
-#define GLUT_VIDEO_RESIZE_Y_DELTA      903
-#define GLUT_VIDEO_RESIZE_WIDTH_DELTA  904
-#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 905
-#define GLUT_VIDEO_RESIZE_X            906
-#define GLUT_VIDEO_RESIZE_Y            907
-#define GLUT_VIDEO_RESIZE_WIDTH                908
-#define GLUT_VIDEO_RESIZE_HEIGHT       909
-#endif
-
-/* glutUseLayer parameters. */
-#define GLUT_NORMAL                    0
-#define GLUT_OVERLAY                   1
-
-/* glutGetModifiers return mask. */
-#define GLUT_ACTIVE_SHIFT               1
-#define GLUT_ACTIVE_CTRL                2
-#define GLUT_ACTIVE_ALT                 4
-
-/* glutSetCursor parameters. */
-/* Basic arrows. */
-#define GLUT_CURSOR_RIGHT_ARROW                0
-#define GLUT_CURSOR_LEFT_ARROW         1
-/* Symbolic cursor shapes. */
-#define GLUT_CURSOR_INFO               2
-#define GLUT_CURSOR_DESTROY            3
-#define GLUT_CURSOR_HELP               4
-#define GLUT_CURSOR_CYCLE              5
-#define GLUT_CURSOR_SPRAY              6
-#define GLUT_CURSOR_WAIT               7
-#define GLUT_CURSOR_TEXT               8
-#define GLUT_CURSOR_CROSSHAIR          9
-/* Directional cursors. */
-#define GLUT_CURSOR_UP_DOWN            10
-#define GLUT_CURSOR_LEFT_RIGHT         11
-/* Sizing cursors. */
-#define GLUT_CURSOR_TOP_SIDE           12
-#define GLUT_CURSOR_BOTTOM_SIDE                13
-#define GLUT_CURSOR_LEFT_SIDE          14
-#define GLUT_CURSOR_RIGHT_SIDE         15
-#define GLUT_CURSOR_TOP_LEFT_CORNER    16
-#define GLUT_CURSOR_TOP_RIGHT_CORNER   17
-#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER        18
-#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19
-/* Inherit from parent window. */
-#define GLUT_CURSOR_INHERIT            100
-/* Blank cursor. */
-#define GLUT_CURSOR_NONE               101
-/* Fullscreen crosshair (if available). */
-#define GLUT_CURSOR_FULL_CROSSHAIR     102
-#endif
-
-/* GLUT initialization sub-API. */
-GLUTAPI void GLUTAPIENTRY glutInit(int *argcp, char **argv);
-#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
-GLUTAPI void GLUTAPIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
-#ifndef GLUT_BUILDING_LIB
-#define glutInit(__argcp, __argv) __glutInitWithExit(__argcp, __argv, exit)
-#endif
-#endif
-GLUTAPI void GLUTAPIENTRY glutInitDisplayMode(unsigned int mode);
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
-GLUTAPI void GLUTAPIENTRY glutInitDisplayString(const char *string);
-#endif
-GLUTAPI void GLUTAPIENTRY glutInitWindowPosition(int x, int y);
-GLUTAPI void GLUTAPIENTRY glutInitWindowSize(int width, int height);
-GLUTAPI void GLUTAPIENTRY glutMainLoop(void);
-
-/* GLUT window sub-API. */
-GLUTAPI int GLUTAPIENTRY glutCreateWindow(const char *title);
-#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
-GLUTAPI int GLUTAPIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
-#ifndef GLUT_BUILDING_LIB
-#define glutCreateWindow(__title) __glutCreateWindowWithExit(__title, exit)
-#endif
-#endif
-GLUTAPI int GLUTAPIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height);
-GLUTAPI void GLUTAPIENTRY glutDestroyWindow(int win);
-GLUTAPI void GLUTAPIENTRY glutPostRedisplay(void);
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
-GLUTAPI void GLUTAPIENTRY glutPostWindowRedisplay(int win);
-#endif
-GLUTAPI void GLUTAPIENTRY glutSwapBuffers(void);
-GLUTAPI int GLUTAPIENTRY glutGetWindow(void);
-GLUTAPI void GLUTAPIENTRY glutSetWindow(int win);
-GLUTAPI void GLUTAPIENTRY glutSetWindowTitle(const char *title);
-GLUTAPI void GLUTAPIENTRY glutSetIconTitle(const char *title);
-GLUTAPI void GLUTAPIENTRY glutPositionWindow(int x, int y);
-GLUTAPI void GLUTAPIENTRY glutReshapeWindow(int width, int height);
-GLUTAPI void GLUTAPIENTRY glutPopWindow(void);
-GLUTAPI void GLUTAPIENTRY glutPushWindow(void);
-GLUTAPI void GLUTAPIENTRY glutIconifyWindow(void);
-GLUTAPI void GLUTAPIENTRY glutShowWindow(void);
-GLUTAPI void GLUTAPIENTRY glutHideWindow(void);
-#if (GLUT_API_VERSION >= 3)
-GLUTAPI void GLUTAPIENTRY glutFullScreen(void);
-GLUTAPI void GLUTAPIENTRY glutSetCursor(int cursor);
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
-GLUTAPI void GLUTAPIENTRY glutWarpPointer(int x, int y);
-#endif
-
-/* GLUT overlay sub-API. */
-GLUTAPI void GLUTAPIENTRY glutEstablishOverlay(void);
-GLUTAPI void GLUTAPIENTRY glutRemoveOverlay(void);
-GLUTAPI void GLUTAPIENTRY glutUseLayer(GLenum layer);
-GLUTAPI void GLUTAPIENTRY glutPostOverlayRedisplay(void);
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
-GLUTAPI void GLUTAPIENTRY glutPostWindowOverlayRedisplay(int win);
-#endif
-GLUTAPI void GLUTAPIENTRY glutShowOverlay(void);
-GLUTAPI void GLUTAPIENTRY glutHideOverlay(void);
-#endif
-
-/* GLUT menu sub-API. */
-GLUTAPI int GLUTAPIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int));
-#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
-GLUTAPI int GLUTAPIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int));
-#ifndef GLUT_BUILDING_LIB
-#define glutCreateMenu(__func) __glutCreateMenuWithExit(__func, exit)
-#endif
-#endif
-GLUTAPI void GLUTAPIENTRY glutDestroyMenu(int menu);
-GLUTAPI int GLUTAPIENTRY glutGetMenu(void);
-GLUTAPI void GLUTAPIENTRY glutSetMenu(int menu);
-GLUTAPI void GLUTAPIENTRY glutAddMenuEntry(const char *label, int value);
-GLUTAPI void GLUTAPIENTRY glutAddSubMenu(const char *label, int submenu);
-GLUTAPI void GLUTAPIENTRY glutChangeToMenuEntry(int item, const char *label, int value);
-GLUTAPI void GLUTAPIENTRY glutChangeToSubMenu(int item, const char *label, int submenu);
-GLUTAPI void GLUTAPIENTRY glutRemoveMenuItem(int item);
-GLUTAPI void GLUTAPIENTRY glutAttachMenu(int button);
-GLUTAPI void GLUTAPIENTRY glutDetachMenu(int button);
-
-/* GLUT window callback sub-API. */
-GLUTAPI void GLUTAPIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void));
-GLUTAPI void GLUTAPIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height));
-GLUTAPI void GLUTAPIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
-GLUTAPI void GLUTAPIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
-GLUTAPI void GLUTAPIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
-GLUTAPI void GLUTAPIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
-GLUTAPI void GLUTAPIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state));
-GLUTAPI void GLUTAPIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state));
-GLUTAPI void GLUTAPIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void));
-GLUTAPI void GLUTAPIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value);
-GLUTAPI void GLUTAPIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state));
-#if (GLUT_API_VERSION >= 2)
-GLUTAPI void GLUTAPIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
-GLUTAPI void GLUTAPIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
-GLUTAPI void GLUTAPIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
-GLUTAPI void GLUTAPIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state));
-GLUTAPI void GLUTAPIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state));
-GLUTAPI void GLUTAPIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value));
-GLUTAPI void GLUTAPIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
-GLUTAPI void GLUTAPIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
-#if (GLUT_API_VERSION >= 3)
-GLUTAPI void GLUTAPIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y));
-GLUTAPI void GLUTAPIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void));
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
-GLUTAPI void GLUTAPIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state));
-#endif
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
-GLUTAPI void GLUTAPIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
-GLUTAPI void GLUTAPIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
-GLUTAPI void GLUTAPIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval);
-#endif
-#endif
-#endif
-
-/* GLUT color index sub-API. */
-GLUTAPI void GLUTAPIENTRY glutSetColor(int ndx, GLfloat red, GLfloat green, GLfloat blue);
-GLUTAPI GLfloat GLUTAPIENTRY glutGetColor(int ndx, int component);
-GLUTAPI void GLUTAPIENTRY glutCopyColormap(int win);
-
-/* GLUT state retrieval sub-API. */
-GLUTAPI int GLUTAPIENTRY glutGet(GLenum type);
-GLUTAPI int GLUTAPIENTRY glutDeviceGet(GLenum type);
-#if (GLUT_API_VERSION >= 2)
-/* GLUT extension support sub-API */
-GLUTAPI int GLUTAPIENTRY glutExtensionSupported(const char *name);
-#endif
-#if (GLUT_API_VERSION >= 3)
-GLUTAPI int GLUTAPIENTRY glutGetModifiers(void);
-GLUTAPI int GLUTAPIENTRY glutLayerGet(GLenum type);
-#endif
-#if (GLUT_API_VERSION >= 5)
-typedef void (*GLUTproc)();
-GLUTAPI GLUTproc GLUTAPIENTRY glutGetProcAddress(const char *procName);
-#endif
-
-/* GLUT font sub-API */
-GLUTAPI void GLUTAPIENTRY glutBitmapCharacter(void *font, int character);
-GLUTAPI int GLUTAPIENTRY glutBitmapWidth(void *font, int character);
-GLUTAPI void GLUTAPIENTRY glutStrokeCharacter(void *font, int character);
-GLUTAPI int GLUTAPIENTRY glutStrokeWidth(void *font, int character);
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
-GLUTAPI int GLUTAPIENTRY glutBitmapLength(void *font, const unsigned char *string);
-GLUTAPI int GLUTAPIENTRY glutStrokeLength(void *font, const unsigned char *string);
-#endif
-
-/* GLUT pre-built models sub-API */
-GLUTAPI void GLUTAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
-GLUTAPI void GLUTAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
-GLUTAPI void GLUTAPIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
-GLUTAPI void GLUTAPIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
-GLUTAPI void GLUTAPIENTRY glutWireCube(GLdouble size);
-GLUTAPI void GLUTAPIENTRY glutSolidCube(GLdouble size);
-GLUTAPI void GLUTAPIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
-GLUTAPI void GLUTAPIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
-GLUTAPI void GLUTAPIENTRY glutWireDodecahedron(void);
-GLUTAPI void GLUTAPIENTRY glutSolidDodecahedron(void);
-GLUTAPI void GLUTAPIENTRY glutWireTeapot(GLdouble size);
-GLUTAPI void GLUTAPIENTRY glutSolidTeapot(GLdouble size);
-GLUTAPI void GLUTAPIENTRY glutWireOctahedron(void);
-GLUTAPI void GLUTAPIENTRY glutSolidOctahedron(void);
-GLUTAPI void GLUTAPIENTRY glutWireTetrahedron(void);
-GLUTAPI void GLUTAPIENTRY glutSolidTetrahedron(void);
-GLUTAPI void GLUTAPIENTRY glutWireIcosahedron(void);
-GLUTAPI void GLUTAPIENTRY glutSolidIcosahedron(void);
-
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
-/* GLUT video resize sub-API. */
-GLUTAPI int GLUTAPIENTRY glutVideoResizeGet(GLenum param);
-GLUTAPI void GLUTAPIENTRY glutSetupVideoResizing(void);
-GLUTAPI void GLUTAPIENTRY glutStopVideoResizing(void);
-GLUTAPI void GLUTAPIENTRY glutVideoResize(int x, int y, int width, int height);
-GLUTAPI void GLUTAPIENTRY glutVideoPan(int x, int y, int width, int height);
-
-/* GLUT debugging sub-API. */
-GLUTAPI void GLUTAPIENTRY glutReportErrors(void);
-#endif
-
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
-/* GLUT device control sub-API. */
-/* glutSetKeyRepeat modes. */
-#define GLUT_KEY_REPEAT_OFF            0
-#define GLUT_KEY_REPEAT_ON             1
-#define GLUT_KEY_REPEAT_DEFAULT                2
-
-/* Joystick button masks. */
-#define GLUT_JOYSTICK_BUTTON_A         1
-#define GLUT_JOYSTICK_BUTTON_B         2
-#define GLUT_JOYSTICK_BUTTON_C         4
-#define GLUT_JOYSTICK_BUTTON_D         8
-
-GLUTAPI void GLUTAPIENTRY glutIgnoreKeyRepeat(int ignore);
-GLUTAPI void GLUTAPIENTRY glutSetKeyRepeat(int repeatMode);
-GLUTAPI void GLUTAPIENTRY glutForceJoystickFunc(void);
-
-/* GLUT game mode sub-API. */
-/* glutGameModeGet. */
-#define GLUT_GAME_MODE_ACTIVE           0
-#define GLUT_GAME_MODE_POSSIBLE         1
-#define GLUT_GAME_MODE_WIDTH            2
-#define GLUT_GAME_MODE_HEIGHT           3
-#define GLUT_GAME_MODE_PIXEL_DEPTH      4
-#define GLUT_GAME_MODE_REFRESH_RATE     5
-#define GLUT_GAME_MODE_DISPLAY_CHANGED  6
-
-GLUTAPI void GLUTAPIENTRY glutGameModeString(const char *string);
-GLUTAPI int GLUTAPIENTRY glutEnterGameMode(void);
-GLUTAPI void GLUTAPIENTRY glutLeaveGameMode(void);
-GLUTAPI int GLUTAPIENTRY glutGameModeGet(GLenum mode);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif                  /* __glut_h__ */
diff --git a/include/GL/glutf90.h b/include/GL/glutf90.h
deleted file mode 100644 (file)
index 8a3a867..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef __glutf90_h__
-#define __glutf90_h__
-
-/* Copyright (c) Mark J. Kilgard & Willam F. Mitchell, 1998. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-/* This header provides the binding interface for William Mitchell's
-   f90gl Fortran 90 GLUT binding.  Other GLUT language bindings
-   can and should use this interace. */
-
-/* I appreciate the guidance from William Mitchell
-   (mitchell@cam.nist.gov) in developing this friend interface
-   for use by the f90gl package.  See ../../README.fortran */
-
-#include <GL/glut.h>
-
-/* Which callback enumerants for the __glutSetFCB/__glutGetFCB routines. */
-/* NOTE These values are part of a binary interface for the f90gl Fortran
-   90 binding and so must NOT changes (additions are allowed). */
-
-/* GLUTwindow callbacks. */
-#define GLUT_FCB_DISPLAY         0    /* GLUTdisplayFCB */
-#define GLUT_FCB_RESHAPE         1    /* GLUTreshapeFCB */
-#define GLUT_FCB_MOUSE           2    /* GLUTmouseFCB */
-#define GLUT_FCB_MOTION          3    /* GLUTmotionFCB */
-#define GLUT_FCB_PASSIVE         4    /* GLUTpassiveFCB */
-#define GLUT_FCB_ENTRY           5    /* GLUTentryFCB */
-#define GLUT_FCB_KEYBOARD        6    /* GLUTkeyboardFCB */
-#define GLUT_FCB_KEYBOARD_UP     7    /* GLUTkeyboardFCB */
-#define GLUT_FCB_WINDOW_STATUS   8    /* GLUTwindowStatusFCB */
-#define GLUT_FCB_VISIBILITY      9    /* GLUTvisibilityFCB */
-#define GLUT_FCB_SPECIAL         10   /* GLUTspecialFCB */
-#define GLUT_FCB_SPECIAL_UP      11   /* GLUTspecialFCB */
-#define GLUT_FCB_BUTTON_BOX      12   /* GLUTbuttonBoxFCB */
-#define GLUT_FCB_DIALS           13   /* GLUTdialsFCB */
-#define GLUT_FCB_SPACE_MOTION    14   /* GLUTspaceMotionFCB */
-#define GLUT_FCB_SPACE_ROTATE    15   /* GLUTspaceRotateFCB */
-#define GLUT_FCB_SPACE_BUTTON    16   /* GLUTspaceButtonFCB */
-#define GLUT_FCB_TABLET_MOTION   17   /* GLUTtabletMotionFCB */
-#define GLUT_FCB_TABLET_BUTTON   18   /* GLUTtabletButtonFCB */
-#define GLUT_FCB_JOYSTICK        19   /* GLUTjoystickFCB */
-/* Non-GLUTwindow callbacks. */
-#define GLUT_FCB_OVERLAY_DISPLAY 100  /* GLUTdisplayFCB */
-#define GLUT_FCB_SELECT          101  /* GLUTselectFCB */
-#define GLUT_FCB_TIMER           102  /* GLUTtimerFCB */
-
-/* GLUT Fortran callback function types. */
-typedef void (GLUTCALLBACK *GLUTdisplayFCB) (void);
-typedef void (GLUTCALLBACK *GLUTreshapeFCB) (int *, int *);
-/* NOTE the pressed key is int, not unsigned char for Fortran! */
-typedef void (GLUTCALLBACK *GLUTkeyboardFCB) (int *, int *, int *);
-typedef void (GLUTCALLBACK *GLUTmouseFCB) (int *, int *, int *, int *);
-typedef void (GLUTCALLBACK *GLUTmotionFCB) (int *, int *);
-typedef void (GLUTCALLBACK *GLUTpassiveFCB) (int *, int *);
-typedef void (GLUTCALLBACK *GLUTentryFCB) (int *);
-typedef void (GLUTCALLBACK *GLUTwindowStatusFCB) (int *);
-typedef void (GLUTCALLBACK *GLUTvisibilityFCB) (int *);
-typedef void (GLUTCALLBACK *GLUTspecialFCB) (int *, int *, int *);
-typedef void (GLUTCALLBACK *GLUTbuttonBoxFCB) (int *, int *);
-typedef void (GLUTCALLBACK *GLUTdialsFCB) (int *, int *);
-typedef void (GLUTCALLBACK *GLUTspaceMotionFCB) (int *, int *, int *);
-typedef void (GLUTCALLBACK *GLUTspaceRotateFCB) (int *, int *, int *);
-typedef void (GLUTCALLBACK *GLUTspaceButtonFCB) (int *, int *);
-typedef void (GLUTCALLBACK *GLUTtabletMotionFCB) (int *, int *);
-typedef void (GLUTCALLBACK *GLUTtabletButtonFCB) (int *, int *, int *, int *);
-typedef void (GLUTCALLBACK *GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z);
-
-typedef void (GLUTCALLBACK *GLUTselectFCB) (int *);
-typedef void (GLUTCALLBACK *GLUTtimerFCB) (int *);
-typedef void (GLUTCALLBACK *GLUTmenuStateFCB) (int *);  /* DEPRICATED. */
-typedef void (GLUTCALLBACK *GLUTmenuStatusFCB) (int *, int *, int *);
-typedef void (GLUTCALLBACK *GLUTidleFCB) (void);
-
-/* Functions that set and return Fortran callback functions. */
-GLUTAPI GLUTproc APIENTRY __glutGetFCB(int which);
-GLUTAPI void APIENTRY __glutSetFCB(int which, GLUTproc func);
-
-#endif  /* __glutf90_h__ */
index f022b44..4fe9e94 100644 (file)
@@ -849,6 +849,11 @@ struct __DRIimageExtensionRec {
                               void *loaderPrivate);
 
    GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
+
+   /**
+    * The new __DRIimage will share the content with the old one, see dup(2).
+    */
+   __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
 };
 
 
index 3340458..725270a 100644 (file)
@@ -249,6 +249,7 @@ CHIPSET(0x6749, TURKS_6749, TURKS)
 CHIPSET(0x6750, TURKS_6750, TURKS)
 CHIPSET(0x6758, TURKS_6758, TURKS)
 CHIPSET(0x6759, TURKS_6759, TURKS)
+CHIPSET(0x675F, TURKS_675F, TURKS)
 
 CHIPSET(0x6760, CAICOS_6760, CAICOS)
 CHIPSET(0x6761, CAICOS_6761, CAICOS)
@@ -260,4 +261,5 @@ CHIPSET(0x6766, CAICOS_6766, CAICOS)
 CHIPSET(0x6767, CAICOS_6767, CAICOS)
 CHIPSET(0x6768, CAICOS_6768, CAICOS)
 CHIPSET(0x6770, CAICOS_6770, CAICOS)
+CHIPSET(0x6778, CAICOS_6778, CAICOS)
 CHIPSET(0x6779, CAICOS_6779, CAICOS)
index a2c690f..df7ac93 100644 (file)
@@ -33,6 +33,8 @@ Custom builders and methods.
 import os
 import os.path
 import re
+import sys
+import subprocess
 
 import SCons.Action
 import SCons.Builder
@@ -154,15 +156,90 @@ def createCodeGenerateMethod(env):
     env.AddMethod(code_generate, 'CodeGenerate')
 
 
+def _pkg_check_modules(env, name, modules):
+    '''Simple wrapper for pkg-config.'''
+
+    env['HAVE_' + name] = False
+
+    # For backwards compatability
+    env[name.lower()] = False
+
+    if env['platform'] == 'windows':
+        return
+
+    if not env.Detect('pkg-config'):
+        return
+
+    if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0:
+        return
+
+    # Other flags may affect the compilation of unrelated targets, so store
+    # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc)
+    try:
+        flags = env.ParseFlags('!pkg-config --cflags --libs ' + ' '.join(modules))
+    except OSError:
+        return
+    prefix = name + '_'
+    for flag_name, flag_value in flags.iteritems():
+        assert '_' not in flag_name
+        env[prefix + flag_name] = flag_value
+
+    env['HAVE_' + name] = True
+
+def pkg_check_modules(env, name, modules):
+
+    sys.stdout.write('Checking for %s...' % name)
+    _pkg_check_modules(env, name, modules)
+    result = env['HAVE_' + name]
+    sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))])
+
+    # XXX: For backwards compatability
+    env[name.lower()] = result
+
+
+def pkg_use_modules(env, names):
+    '''Search for all environment flags that match NAME_FOO and append them to
+    the FOO environment variable.'''
+
+    names = env.Flatten(names)
+
+    for name in names:
+        prefix = name + '_'
+
+        if not 'HAVE_' + name in env:
+            print 'Attempt to use unknown module %s' % name
+            env.Exit(1)
+
+        if not env['HAVE_' + name]:
+            print 'Attempt to use unavailable module %s' % name
+            env.Exit(1)
+
+        flags = {}
+        for flag_name, flag_value in env.Dictionary().iteritems():
+            if flag_name.startswith(prefix):
+                flag_name = flag_name[len(prefix):]
+                if '_' not in flag_name:
+                    flags[flag_name] = flag_value
+        if flags:
+            env.MergeFlags(flags)
+
+
+def createPkgConfigMethods(env):
+    env.AddMethod(pkg_check_modules, 'PkgCheckModules')
+    env.AddMethod(pkg_use_modules, 'PkgUseModules')
+
+
 def generate(env):
     """Common environment generation code"""
 
-    if env.get('quiet', True):
+    verbose = env.get('verbose', False) or not env.get('quiet', True)
+    if not verbose:
         quietCommandLines(env)
 
     # Custom builders and methods
     createConvenienceLibBuilder(env)
     createCodeGenerateMethod(env)
+    createPkgConfigMethods(env)
 
     # for debugging
     #print env.Dump()
index a94bf73..8cd3bc7 100755 (executable)
@@ -104,41 +104,6 @@ def num_jobs():
     return 1
 
 
-def pkg_config_modules(env, name, modules):
-    '''Simple wrapper for pkg-config.'''
-
-    env[name] = False
-
-    if env['platform'] == 'windows':
-        return
-
-    if not env.Detect('pkg-config'):
-        return
-
-    if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0:
-        return
-
-    # Put -I and -L flags directly into the environment, as these don't affect
-    # the compilation of targets that do not use them
-    try:
-        env.ParseConfig('pkg-config --cflags-only-I --libs-only-L ' + ' '.join(modules))
-    except OSError:
-        return
-
-    # Other flags may affect the compilation of unrelated targets, so store
-    # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc)
-    try:
-        flags = env.ParseFlags('!pkg-config --cflags-only-other --libs-only-l --libs-only-other ' + ' '.join(modules))
-    except OSError:
-        return
-    prefix = name.upper() + '_'
-    for flag_name, flag_value in flags.iteritems():
-        env[prefix + flag_name] = flag_value
-
-    env[name] = True
-
-
-
 def generate(env):
     """Common environment generation code"""
 
@@ -247,6 +212,8 @@ def generate(env):
     # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
     build_topdir = 'build'
     build_subdir = env['platform']
+    if env['embedded']:
+        build_subdir =  'embedded-' + build_subdir
     if env['machine'] != 'generic':
         build_subdir += '-' + env['machine']
     if env['build'] != 'release':
@@ -277,6 +244,31 @@ def generate(env):
         cppdefines += ['NDEBUG']
     if env['build'] == 'profile':
         cppdefines += ['PROFILE']
+    if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
+        cppdefines += [
+            '_POSIX_SOURCE',
+            ('_POSIX_C_SOURCE', '199309L'),
+            '_SVID_SOURCE',
+            '_BSD_SOURCE',
+            '_GNU_SOURCE',
+            'PTHREADS',
+            'HAVE_POSIX_MEMALIGN',
+        ]
+        if env['platform'] == 'darwin':
+            cppdefines += [
+                '_DARWIN_C_SOURCE',
+                'GLX_USE_APPLEGL',
+                'GLX_DIRECT_RENDERING',
+            ]
+        else:
+            cppdefines += [
+                'GLX_DIRECT_RENDERING',
+                'GLX_INDIRECT_RENDERING',
+            ]
+        if env['platform'] in ('linux', 'freebsd'):
+            cppdefines += ['HAVE_ALIAS']
+        else:
+            cppdefines += ['GLX_ALIAS_UNSUPPORTED']
     if platform == 'windows':
         cppdefines += [
             'WIN32',
@@ -349,8 +341,8 @@ def generate(env):
     if platform == 'wince':
         cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
         cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
-    if platform == 'embedded':
-        cppdefines += ['PIPE_OS_EMBEDDED']
+    if env['embedded']:
+        cppdefines += ['PIPE_SUBSYSTEM_EMBEDDED']
     env.Append(CPPDEFINES = cppdefines)
 
     # C compiler options
@@ -367,6 +359,8 @@ def generate(env):
             ccflags += ['-O0']
         else:
             ccflags += ['-O3']
+        # Work around aliasing bugs - developers should comment this out
+        ccflags += ['-fno-strict-aliasing']
         ccflags += ['-g3']
         if env['build'] in ('checked', 'profile'):
             # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
@@ -403,6 +397,8 @@ def generate(env):
             ccflags += ['-m64']
             if platform == 'darwin':
                 ccflags += ['-fno-common']
+        if env['platform'] != 'windows':
+            ccflags += ['-fvisibility=hidden']
         # See also:
         # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
         ccflags += [
@@ -421,10 +417,10 @@ def generate(env):
             ]
         if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
             ccflags += [
-                '-Werror=pointer-arith',
+                '-Wpointer-arith',
             ]
             cflags += [
-                '-Werror=declaration-after-statement',
+                '-Wdeclaration-after-statement',
             ]
     if msvc:
         # See also:
@@ -595,7 +591,10 @@ def generate(env):
         env['LINK'] = env['CXX']
 
     # Default libs
-    env.Append(LIBS = [])
+    libs = []
+    if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
+        libs += ['m', 'pthread', 'dl']
+    env.Append(LIBS = libs)
 
     # Load tools
     env.Tool('lex')
@@ -603,19 +602,21 @@ def generate(env):
     if env['llvm']:
         env.Tool('llvm')
     
-    pkg_config_modules(env, 'x11', ['x11', 'xext'])
-    pkg_config_modules(env, 'drm', ['libdrm'])
-    pkg_config_modules(env, 'drm_intel', ['libdrm_intel'])
-    pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon'])
-    pkg_config_modules(env, 'xorg', ['xorg-server'])
-    pkg_config_modules(env, 'kms', ['libkms'])
-
-    env['dri'] = env['x11'] and env['drm']
-
     # Custom builders and methods
     env.Tool('custom')
     createInstallMethods(env)
 
+    env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes'])
+    env.PkgCheckModules('XF86VIDMODE', ['xxf86vm'])
+    env.PkgCheckModules('DRM', ['libdrm'])
+    env.PkgCheckModules('DRM_INTEL', ['libdrm_intel'])
+    env.PkgCheckModules('DRM_RADEON', ['libdrm_radeon'])
+    env.PkgCheckModules('XORG', ['xorg-server'])
+    env.PkgCheckModules('KMS', ['libkms'])
+    env.PkgCheckModules('UDEV', ['libudev'])
+
+    env['dri'] = env['x11'] and env['drm']
+
     # for debugging
     #print env.Dump()
 
index b89899b..66f972d 100644 (file)
@@ -141,7 +141,15 @@ def generate(env):
         llvm_version = distutils.version.LooseVersion(llvm_version)
 
         try:
-            env.ParseConfig('llvm-config --cppflags')
+            # Treat --cppflags specially to prevent NDEBUG from disabling
+            # assertion failures in debug builds.
+            cppflags = env.ParseFlags('!llvm-config --cppflags')
+            try:
+                cppflags['CPPDEFINES'].remove('NDEBUG')
+            except ValueError:
+                pass
+            env.MergeFlags(cppflags)
+
             env.ParseConfig('llvm-config --libs')
             env.ParseConfig('llvm-config --ldflags')
         except OSError:
index 7b614da..87e2444 100644 (file)
@@ -22,9 +22,9 @@ SConscript('mesa/SConscript')
 SConscript('mapi/vgapi/SConscript')
 
 if env['platform'] != 'embedded':
+    SConscript('glx/SConscript')
     SConscript('egl/main/SConscript')
     SConscript('glu/sgi/SConscript')
-    SConscript('glut/glx/SConscript')
 
     if env['gles']:
         SConscript('mapi/shared-glapi/SConscript')
diff --git a/src/driclient/src/Makefile b/src/driclient/src/Makefile
deleted file mode 100644 (file)
index 34435a2..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-TARGET         = libdriclient.a
-OBJECTS                = driclient.o XF86dri.o
-DRMDIR         ?= /usr
-
-CFLAGS         += -g -Wall -fPIC -I../include -I${DRMDIR}/include -I${DRMDIR}/include/drm
-
-#############################################
-
-.PHONY = all clean
-
-all: ${TARGET}
-
-${TARGET}: ${OBJECTS}
-       ar rcs $@ $^
-       if ! test -d ../lib; then mkdir ../lib; fi
-       cp ${TARGET} ../lib
-
-clean:
-       rm -rf ${OBJECTS} ${TARGET} ../lib/${TARGET}
index f8ff82b..d2b1f4f 100644 (file)
@@ -4,12 +4,14 @@ TOP = ../../../..
 include $(TOP)/configs/current
 
 EGL_DRIVER = egl_dri2
-EGL_SOURCES = egl_dri2.c platform_drm.c common.c
+EGL_SOURCES = egl_dri2.c common.c
 
 EGL_INCLUDES = \
        -I$(TOP)/include \
        -I$(TOP)/src/egl/main \
        -I$(TOP)/src/mapi \
+       -I$(TOP)/src/gbm/main \
+       -I$(TOP)/src/gbm/backends/dri \
        -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \
        $(LIBUDEV_CFLAGS) \
        $(LIBDRM_CFLAGS)
@@ -29,6 +31,11 @@ EGL_INCLUDES += -DHAVE_X11_PLATFORM $(XCB_DRI2_CFLAGS)
 EGL_LIBS +=  $(XCB_DRI2_LIBS)
 endif
 
+ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
+EGL_SOURCES += platform_drm.c
+EGL_INCLUDES += -DHAVE_DRM_PLATFORM
+endif
+
 ifneq ($(findstring wayland, $(EGL_PLATFORMS)),)
 EGL_SOURCES += platform_wayland.c
 EGL_INCLUDES += -DHAVE_WAYLAND_PLATFORM $(WAYLAND_CFLAGS) \
index d430145..9a37ea4 100644 (file)
@@ -244,7 +244,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
    return conf;
 }
 
-static __DRIimage *
+__DRIimage *
 dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
 {
    _EGLDisplay *disp = data;
@@ -416,11 +416,6 @@ dri2_load_driver_swrast(_EGLDisplay *disp)
 
    dri2_dpy->driver_name = "swrast";
    extensions = dri2_open_driver(disp);
-   if (!extensions) {
-      /* try again with swrastg */
-      dri2_dpy->driver_name = "swrastg";
-      extensions = dri2_open_driver(disp);
-   }
 
    if (!extensions)
       return EGL_FALSE;
@@ -433,42 +428,12 @@ dri2_load_driver_swrast(_EGLDisplay *disp)
    return EGL_TRUE;
 }
 
-EGLBoolean
-dri2_create_screen(_EGLDisplay *disp)
+void
+dri2_setup_screen(_EGLDisplay *disp)
 {
-   const __DRIextension **extensions;
-   struct dri2_egl_display *dri2_dpy;
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    unsigned int api_mask;
 
-   dri2_dpy = disp->DriverData;
-
-   if (dri2_dpy->dri2) {
-      dri2_dpy->dri_screen =
-         dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd, dri2_dpy->extensions,
-                                        &dri2_dpy->driver_configs, disp);
-   } else {
-      assert(dri2_dpy->swrast);
-      dri2_dpy->dri_screen =
-         dri2_dpy->swrast->createNewScreen(0, dri2_dpy->extensions,
-                                           &dri2_dpy->driver_configs, disp);
-   }
-
-   if (dri2_dpy->dri_screen == NULL) {
-      _eglLog(_EGL_WARNING, "DRI2: failed to create dri screen");
-      return EGL_FALSE;
-   }
-
-   extensions = dri2_dpy->core->getExtensions(dri2_dpy->dri_screen);
-   
-   if (dri2_dpy->dri2) {
-      if (!dri2_bind_extensions(dri2_dpy, dri2_core_extensions, extensions))
-         goto cleanup_dri_screen;
-   } else {
-      assert(dri2_dpy->swrast);
-      if (!dri2_bind_extensions(dri2_dpy, swrast_core_extensions, extensions))
-         goto cleanup_dri_screen;
-   }
-
    if (dri2_dpy->dri2) {
       if (dri2_dpy->dri2->base.version >= 2)
          api_mask = dri2_dpy->dri2->getAPIMask(dri2_dpy->dri_screen);
@@ -510,6 +475,46 @@ dri2_create_screen(_EGLDisplay *disp)
       disp->Extensions.KHR_image_base = EGL_TRUE;
       disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
    }
+}
+
+EGLBoolean
+dri2_create_screen(_EGLDisplay *disp)
+{
+   const __DRIextension **extensions;
+   struct dri2_egl_display *dri2_dpy;
+
+   dri2_dpy = disp->DriverData;
+
+   if (dri2_dpy->dri2) {
+      dri2_dpy->dri_screen =
+         dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd, dri2_dpy->extensions,
+                                        &dri2_dpy->driver_configs, disp);
+   } else {
+      assert(dri2_dpy->swrast);
+      dri2_dpy->dri_screen =
+         dri2_dpy->swrast->createNewScreen(0, dri2_dpy->extensions,
+                                           &dri2_dpy->driver_configs, disp);
+   }
+
+   if (dri2_dpy->dri_screen == NULL) {
+      _eglLog(_EGL_WARNING, "DRI2: failed to create dri screen");
+      return EGL_FALSE;
+   }
+
+   dri2_dpy->own_dri_screen = 1;
+
+   extensions = dri2_dpy->core->getExtensions(dri2_dpy->dri_screen);
+   
+   if (dri2_dpy->dri2) {
+      if (!dri2_bind_extensions(dri2_dpy, dri2_core_extensions, extensions))
+         goto cleanup_dri_screen;
+   } else {
+      assert(dri2_dpy->swrast);
+      if (!dri2_bind_extensions(dri2_dpy, swrast_core_extensions, extensions))
+         goto cleanup_dri_screen;
+   }
+
+   dri2_setup_screen(disp);
 
    return EGL_TRUE;
 
@@ -538,10 +543,12 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
 #endif
 
 #ifdef HAVE_LIBUDEV
+#ifdef HAVE_DRM_PLATFORM
    case _EGL_PLATFORM_DRM:
       if (disp->Options.TestOnly)
          return EGL_TRUE;
       return dri2_initialize_drm(drv, disp);
+#endif
 #ifdef HAVE_WAYLAND_PLATFORM
    case _EGL_PLATFORM_WAYLAND:
       if (disp->Options.TestOnly)
@@ -566,10 +573,12 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
    _eglReleaseDisplayResources(drv, disp);
    _eglCleanupDisplay(disp);
 
-   dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen);
+   if (dri2_dpy->own_dri_screen)
+      dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen);
    if (dri2_dpy->fd)
       close(dri2_dpy->fd);
-   dlclose(dri2_dpy->driver);
+   if (dri2_dpy->driver)
+      dlclose(dri2_dpy->driver);
 
    if (disp->PlatformDisplay == NULL) {
       switch (disp->Platform) {
@@ -583,6 +592,13 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
          wl_display_destroy(dri2_dpy->wl_dpy);
          break;
 #endif
+#ifdef HAVE_DRM_PLATFORM
+      case _EGL_PLATFORM_DRM:
+         if (dri2_dpy->own_gbm_device) {
+            gbm_device_destroy(&dri2_dpy->gbm_dri->base.base);
+         }
+         break;
+#endif
       default:
          break;
       }
@@ -909,8 +925,10 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx,
       return EGL_NO_IMAGE_KHR;
    }
 
-   if (!_eglInitImage(&dri2_img->base, disp))
+   if (!_eglInitImage(&dri2_img->base, disp)) {
+      free(dri2_img);
       return EGL_NO_IMAGE_KHR;
+   }
 
    dri2_img->dri_image = 
       dri2_dpy->image->createImageFromRenderbuffer(dri2_ctx->dri_context,
@@ -1321,8 +1339,10 @@ _EGL_MAIN(const char *args)
 
    memset(dri2_drv, 0, sizeof *dri2_drv);
 
-   if (!dri2_load(&dri2_drv->base))
+   if (!dri2_load(&dri2_drv->base)) {
+      free(dri2_drv);
       return NULL;
+   }
 
    _eglInitDriverFallbacks(&dri2_drv->base);
    dri2_drv->base.API.Initialize = dri2_initialize;
index dd9eb94..a729718 100644 (file)
 #include <GL/gl.h>
 #include <GL/internal/dri_interface.h>
 
+#ifdef HAVE_DRM_PLATFORM
+#include <gbm_driint.h>
+#endif
+
 #include "eglconfig.h"
 #include "eglcontext.h"
 #include "egldisplay.h"
@@ -69,6 +73,7 @@ struct dri2_egl_display
    int                       dri2_major;
    int                       dri2_minor;
    __DRIscreen              *dri_screen;
+   int                       own_dri_screen;
    const __DRIconfig       **driver_configs;
    void                     *driver;
    __DRIcoreExtension       *core;
@@ -79,12 +84,17 @@ struct dri2_egl_display
    __DRIimageExtension      *image;
    int                       fd;
 
+#ifdef HAVE_DRM_PLATFORM
+   struct gbm_dri_device    *gbm_dri;
+   int                       own_gbm_device;
+#endif
+
    char                     *device_name;
    char                     *driver_name;
 
    __DRIdri2LoaderExtension    dri2_loader_extension;
    __DRIswrastLoaderExtension  swrast_loader_extension;
-   const __DRIextension     *extensions[3];
+   const __DRIextension     *extensions[4];
 
 #ifdef HAVE_X11_PLATFORM
    xcb_connection_t         *conn;
@@ -110,6 +120,7 @@ struct dri2_egl_context
 enum wayland_buffer_type {
    WL_BUFFER_FRONT,
    WL_BUFFER_BACK,
+   WL_BUFFER_THIRD,
    WL_BUFFER_COUNT
 };
 
@@ -145,9 +156,11 @@ struct dri2_egl_surface
    struct wl_egl_window  *wl_win;
    struct wl_egl_pixmap  *wl_pix;
    struct wl_buffer      *wl_drm_buffer[WL_BUFFER_COUNT];
+   int                    wl_buffer_lock[WL_BUFFER_COUNT];
    int                    dx;
    int                    dy;
    __DRIbuffer           *dri_buffers[__DRI_BUFFER_COUNT];
+   __DRIbuffer           *third_buffer;
    __DRIbuffer           *pending_buffer;
    EGLBoolean             block_swap_buffers;
 #endif
@@ -182,12 +195,19 @@ extern const __DRIuseInvalidateExtension use_invalidate;
 EGLBoolean
 dri2_load_driver(_EGLDisplay *disp);
 
+/* Helper for platforms not using dri2_create_screen */
+void
+dri2_setup_screen(_EGLDisplay *disp);
+
 EGLBoolean
 dri2_load_driver_swrast(_EGLDisplay *disp);
 
 EGLBoolean
 dri2_create_screen(_EGLDisplay *disp);
 
+__DRIimage *
+dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data);
+
 struct dri2_egl_config *
 dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
                int depth, EGLint surface_type, const EGLint *attr_list);
index 27846de..04b10e2 100644 (file)
 #include <string.h>
 #include <xf86drm.h>
 #include <dlfcn.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
 
 #include "egl_dri2.h"
 
+static _EGLImage *
+dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx,
+                            EGLClientBuffer buffer, const EGLint *attr_list)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   struct gbm_dri_bo *dri_bo = gbm_dri_bo((struct gbm_bo *) buffer);
+   struct dri2_egl_image *dri2_img;
+
+   dri2_img = malloc(sizeof *dri2_img);
+   if (!dri2_img) {
+      _eglError(EGL_BAD_ALLOC, "dri2_create_image_khr_pixmap");
+      return NULL;
+   }
+
+   if (!_eglInitImage(&dri2_img->base, disp)) {
+      free(dri2_img);
+      return NULL;
+   }
+
+   dri2_img->dri_image = dri2_dpy->image->dupImage(dri_bo->image, dri2_img);
+   if (dri2_img->dri_image == NULL) {
+      free(dri2_img);
+      _eglError(EGL_BAD_ALLOC, "dri2_create_image_khr_pixmap");
+      return NULL;
+   }
+
+   return &dri2_img->base;
+}
+
+static _EGLImage *
+dri2_drm_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
+                          _EGLContext *ctx, EGLenum target,
+                          EGLClientBuffer buffer, const EGLint *attr_list)
+{
+   (void) drv;
+
+   switch (target) {
+   case EGL_NATIVE_PIXMAP_KHR:
+      return dri2_create_image_khr_pixmap(disp, ctx, buffer, attr_list);
+   default:
+      return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list);
+   }
+}
+
 static int
 dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id)
 {
@@ -45,57 +93,75 @@ EGLBoolean
 dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
 {
    struct dri2_egl_display *dri2_dpy;
+   struct gbm_device *gbm;
+   int fd = -1;
    int i;
 
    dri2_dpy = malloc(sizeof *dri2_dpy);
    if (!dri2_dpy)
       return _eglError(EGL_BAD_ALLOC, "eglInitialize");
-   
+
    memset(dri2_dpy, 0, sizeof *dri2_dpy);
 
    disp->DriverData = (void *) dri2_dpy;
-   dri2_dpy->fd = (int) (intptr_t) disp->PlatformDisplay;
 
-   dri2_dpy->driver_name = dri2_get_driver_for_fd(dri2_dpy->fd);
-   if (dri2_dpy->driver_name == NULL)
-      return _eglError(EGL_BAD_ALLOC, "DRI2: failed to get driver name");
+   gbm = disp->PlatformDisplay;
+   if (gbm == NULL) {
+      fd = open("/dev/dri/card0", O_RDWR);
+      dri2_dpy->own_gbm_device = 1;
+      gbm = gbm_create_device(fd);
+      if (gbm == NULL)
+         return EGL_FALSE;
+   }
 
-   dri2_dpy->device_name = dri2_get_device_name_for_fd(dri2_dpy->fd);
-   if (dri2_dpy->device_name == NULL) {
-      _eglError(EGL_BAD_ALLOC, "DRI2: failed to get device name");
-      goto cleanup_driver_name;
+   if (strcmp(gbm_device_get_backend_name(gbm), "drm") != 0) {
+      free(dri2_dpy);
+      return EGL_FALSE;
+   }
+
+   dri2_dpy->gbm_dri = gbm_dri_device(gbm);
+   if (dri2_dpy->gbm_dri->base.type != GBM_DRM_DRIVER_TYPE_DRI) {
+      free(dri2_dpy);
+      return EGL_FALSE;
+   }
+
+   if (fd < 0) {
+      fd = dup(gbm_device_get_fd(gbm));
+      if (fd < 0) {
+         free(dri2_dpy);
+         return EGL_FALSE;
+      }
    }
 
-   if (!dri2_load_driver(disp))
-      goto cleanup_device_name;
+   dri2_dpy->fd = fd;
+   dri2_dpy->device_name = dri2_get_device_name_for_fd(dri2_dpy->fd);
+   dri2_dpy->driver_name = dri2_dpy->gbm_dri->base.driver_name;
+
+   dri2_dpy->dri_screen = dri2_dpy->gbm_dri->screen;
+   dri2_dpy->core = dri2_dpy->gbm_dri->core;
+   dri2_dpy->dri2 = dri2_dpy->gbm_dri->dri2;
+   dri2_dpy->image = dri2_dpy->gbm_dri->image;
+   dri2_dpy->driver_configs = dri2_dpy->gbm_dri->driver_configs;
 
-   dri2_dpy->extensions[0] = &image_lookup_extension.base;
-   dri2_dpy->extensions[1] = &use_invalidate.base;
-   dri2_dpy->extensions[2] = NULL;
+   dri2_dpy->gbm_dri->lookup_image = dri2_lookup_egl_image;
+   dri2_dpy->gbm_dri->lookup_user_data = disp;
 
-   if (!dri2_create_screen(disp))
-      goto cleanup_driver;
+   dri2_setup_screen(disp);
 
    for (i = 0; dri2_dpy->driver_configs[i]; i++)
-      dri2_add_config(disp, dri2_dpy->driver_configs[i], i + 1, 0, 0, NULL);
+      dri2_add_config(disp, dri2_dpy->driver_configs[i],
+                      i + 1, 0, 0, NULL);
+
+   drv->API.CreateImageKHR = dri2_drm_create_image_khr;
 
 #ifdef HAVE_WAYLAND_PLATFORM
    disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
 #endif
    dri2_dpy->authenticate = dri2_drm_authenticate;
-   
+
    /* we're supporting EGL 1.4 */
    disp->VersionMajor = 1;
    disp->VersionMinor = 4;
 
    return EGL_TRUE;
-
- cleanup_driver:
-   dlclose(dri2_dpy->driver);
- cleanup_device_name:
-   free(dri2_dpy->device_name);
- cleanup_driver_name:
-   free(dri2_dpy->driver_name);
-
-   return EGL_FALSE;
 }
index e786780..c4fa126 100644 (file)
@@ -59,6 +59,29 @@ force_roundtrip(struct wl_display *display)
       wl_display_iterate(display, WL_DISPLAY_READABLE);
 }
 
+static void
+wl_buffer_release(void *data, struct wl_buffer *buffer)
+{
+   struct dri2_egl_surface *dri2_surf = data;
+   int i;
+
+   for (i = 0; i < WL_BUFFER_COUNT; ++i)
+      if (dri2_surf->wl_drm_buffer[i] == buffer)
+         break;
+
+   assert(i <= WL_BUFFER_COUNT);
+
+   /* not found? */
+   if (i == WL_BUFFER_COUNT)
+      return;
+
+   dri2_surf->wl_buffer_lock[i] = 0;
+
+}
+
+static struct wl_buffer_listener wl_buffer_listener = {
+   wl_buffer_release
+};
 
 /**
  * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
@@ -85,13 +108,16 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
    if (!_eglInitSurface(&dri2_surf->base, disp, type, conf, attrib_list))
       goto cleanup_surf;
 
-   for (i = 0; i < WL_BUFFER_COUNT; ++i)
+   for (i = 0; i < WL_BUFFER_COUNT; ++i) {
       dri2_surf->wl_drm_buffer[i] = NULL;
+      dri2_surf->wl_buffer_lock[i] = 0;
+   }
 
    for (i = 0; i < __DRI_BUFFER_COUNT; ++i)
       dri2_surf->dri_buffers[i] = NULL;
 
    dri2_surf->pending_buffer = NULL;
+   dri2_surf->third_buffer = NULL;
    dri2_surf->block_swap_buffers = EGL_FALSE;
 
    switch (type) {
@@ -187,6 +213,11 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
          dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
                                        dri2_surf->dri_buffers[i]);
 
+   if (dri2_surf->third_buffer) {
+      dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
+                                    dri2_surf->third_buffer);
+   }
+
    free(surf);
 
    return EGL_TRUE;
@@ -215,10 +246,14 @@ wayland_create_buffer(struct dri2_egl_surface *dri2_surf,
 {
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf->base.Resource.Display);
+   struct wl_buffer *buf;
 
-   return wl_drm_create_buffer(dri2_dpy->wl_drm, buffer->name,
-                               dri2_surf->base.Width, dri2_surf->base.Height,
-                               buffer->pitch, visual);
+   buf = wl_drm_create_buffer(dri2_dpy->wl_drm, buffer->name,
+                              dri2_surf->base.Width, dri2_surf->base.Height,
+                              buffer->pitch, visual);
+   wl_buffer_add_listener(buf, &wl_buffer_listener, dri2_surf);
+
+   return buf;
 }
 
 static void
@@ -232,6 +267,8 @@ dri2_process_back_buffer(struct dri2_egl_surface *dri2_surf, unsigned format)
    switch (dri2_surf->type) {
    case DRI2_WINDOW_SURFACE:
       /* allocate a front buffer for our double-buffered window*/
+      if (dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT] != NULL)
+         break;
       dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT] = 
          dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen,
                __DRI_BUFFER_FRONT_LEFT, format,
@@ -289,6 +326,12 @@ dri2_release_buffers(struct dri2_egl_surface *dri2_surf)
       dri2_egl_display(dri2_surf->base.Resource.Display);
    int i;
 
+   if (dri2_surf->third_buffer) {
+      dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
+                                    dri2_surf->third_buffer);
+      dri2_surf->third_buffer = NULL;
+   }
+
    for (i = 0; i < __DRI_BUFFER_COUNT; ++i) {
       if (dri2_surf->dri_buffers[i]) {
          switch (i) {
@@ -309,6 +352,76 @@ dri2_release_buffers(struct dri2_egl_surface *dri2_surf)
    }
 }
 
+static inline void
+pointer_swap(const void **p1, const void **p2)
+{
+   const void *tmp = *p1;
+   *p1 = *p2;
+   *p2 = tmp;
+}
+
+static void
+destroy_third_buffer(struct dri2_egl_surface *dri2_surf)
+{
+   struct dri2_egl_display *dri2_dpy =
+      dri2_egl_display(dri2_surf->base.Resource.Display);
+
+   if (dri2_surf->third_buffer == NULL)
+      return;
+
+   dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
+                                 dri2_surf->third_buffer);
+   dri2_surf->third_buffer = NULL;
+
+   if (dri2_surf->wl_drm_buffer[WL_BUFFER_THIRD])
+      wl_buffer_destroy(dri2_surf->wl_drm_buffer[WL_BUFFER_THIRD]);
+   dri2_surf->wl_drm_buffer[WL_BUFFER_THIRD] = NULL;
+   dri2_surf->wl_buffer_lock[WL_BUFFER_THIRD] = 0;
+}
+
+static void
+swap_wl_buffers(struct dri2_egl_surface *dri2_surf,
+                enum wayland_buffer_type a, enum wayland_buffer_type b)
+{
+   int tmp;
+
+   tmp = dri2_surf->wl_buffer_lock[a];
+   dri2_surf->wl_buffer_lock[a] = dri2_surf->wl_buffer_lock[b];
+   dri2_surf->wl_buffer_lock[b] = tmp;
+      
+   pointer_swap((const void **) &dri2_surf->wl_drm_buffer[a],
+                (const void **) &dri2_surf->wl_drm_buffer[b]);
+}
+
+static void
+swap_back_and_third(struct dri2_egl_surface *dri2_surf)
+{
+   if (dri2_surf->wl_buffer_lock[WL_BUFFER_THIRD])
+      destroy_third_buffer(dri2_surf);
+
+   pointer_swap((const void **) &dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT],
+                (const void **) &dri2_surf->third_buffer);
+
+   swap_wl_buffers(dri2_surf, WL_BUFFER_BACK, WL_BUFFER_THIRD);
+}
+
+static void
+dri2_prior_buffer_creation(struct dri2_egl_surface *dri2_surf,
+                           unsigned int type)
+{
+   switch (type) {
+   case __DRI_BUFFER_BACK_LEFT:
+         if (dri2_surf->wl_buffer_lock[WL_BUFFER_BACK])
+            swap_back_and_third(dri2_surf);
+         else if (dri2_surf->third_buffer)
+            destroy_third_buffer(dri2_surf);
+         break;
+   default:
+         break;
+
+   }
+}
+
 static __DRIbuffer *
 dri2_get_buffers_with_format(__DRIdrawable * driDrawable,
                             int *width, int *height,
@@ -335,6 +448,7 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable,
          if (dri2_surf->wl_drm_buffer[i])
             wl_buffer_destroy(dri2_surf->wl_drm_buffer[i]);
          dri2_surf->wl_drm_buffer[i]  = NULL;
+         dri2_surf->wl_buffer_lock[i] = 0;
       }
    }
 
@@ -343,6 +457,8 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable,
       assert(attachments[i] < __DRI_BUFFER_COUNT);
       assert(dri2_surf->buffer_count < 5);
 
+      dri2_prior_buffer_creation(dri2_surf, attachments[i]);
+
       if (dri2_surf->dri_buffers[attachments[i]] == NULL) {
 
          dri2_surf->dri_buffers[attachments[i]] =
@@ -443,14 +559,6 @@ wayland_frame_callback(struct wl_surface *surface, void *data, uint32_t time)
    dri2_surf->block_swap_buffers = EGL_FALSE;
 }
 
-static inline void
-pointer_swap(const void **p1, const void **p2)
-{
-   const void *tmp = *p1;
-   *p1 = *p2;
-   *p2 = tmp;
-}
-
 /**
  * Called via eglSwapBuffers(), drv->API.SwapBuffers().
  */
@@ -466,8 +574,8 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
 
    dri2_surf->block_swap_buffers = EGL_TRUE;
    wl_display_frame_callback(dri2_dpy->wl_dpy,
-                            dri2_surf->wl_win->surface,
-                            wayland_frame_callback, dri2_surf);
+                             dri2_surf->wl_win->surface,
+                             wayland_frame_callback, dri2_surf);
 
    if (dri2_surf->type == DRI2_WINDOW_SURFACE) {
       pointer_swap(
@@ -479,8 +587,7 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
       dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]->attachment = 
         __DRI_BUFFER_BACK_LEFT;
 
-      pointer_swap((const void **) &dri2_surf->wl_drm_buffer[WL_BUFFER_FRONT],
-                  (const void **) &dri2_surf->wl_drm_buffer[WL_BUFFER_BACK]);
+      swap_wl_buffers(dri2_surf, WL_BUFFER_FRONT, WL_BUFFER_BACK);
 
       if (!dri2_surf->wl_drm_buffer[WL_BUFFER_FRONT])
         dri2_surf->wl_drm_buffer[WL_BUFFER_FRONT] =
@@ -493,6 +600,7 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
       wl_surface_attach(dri2_surf->wl_win->surface,
            dri2_surf->wl_drm_buffer[WL_BUFFER_FRONT],
            dri2_surf->dx, dri2_surf->dy);
+      dri2_surf->wl_buffer_lock[WL_BUFFER_FRONT] = 1;
 
       dri2_surf->wl_win->attached_width  = dri2_surf->base.Width;
       dri2_surf->wl_win->attached_height = dri2_surf->base.Height;
@@ -720,7 +828,8 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
       
    dri2_dpy->extensions[0] = &dri2_dpy->dri2_loader_extension.base;
    dri2_dpy->extensions[1] = &image_lookup_extension.base;
-   dri2_dpy->extensions[2] = NULL;
+   dri2_dpy->extensions[2] = &use_invalidate.base;
+   dri2_dpy->extensions[3] = NULL;
 
    if (!dri2_create_screen(disp))
       goto cleanup_driver;
index 8bff294..f27bf17 100644 (file)
@@ -479,10 +479,19 @@ dri2_connect(struct dri2_egl_display *dri2_dpy)
    xcb_generic_error_t *error;
    xcb_screen_iterator_t s;
    char *driver_name, *device_name;
+   const xcb_query_extension_reply_t *extension;
 
    xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_xfixes_id);
    xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_dri2_id);
 
+   extension = xcb_get_extension_data(dri2_dpy->conn, &xcb_xfixes_id);
+   if (!(extension && extension->present))
+      return EGL_FALSE;
+
+   extension = xcb_get_extension_data(dri2_dpy->conn, &xcb_dri2_id);
+   if (!(extension && extension->present))
+      return EGL_FALSE;
+
    xfixes_query_cookie = xcb_xfixes_query_version(dri2_dpy->conn,
                                                  XCB_XFIXES_MAJOR_VERSION,
                                                  XCB_XFIXES_MINOR_VERSION);
@@ -836,6 +845,7 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx,
    if (!_eglInitImage(&dri2_img->base, disp)) {
       free(buffers_reply);
       free(geometry_reply);
+      free(dri2_img);
       return EGL_NO_IMAGE_KHR;
    }
 
index c3c11c7..7cf8f4d 100644 (file)
@@ -1,8 +1,10 @@
 /**************************************************************************
- * 
+ *
  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
  **************************************************************************/
 
 
index 6c4a392..775fbbe 100644 (file)
@@ -61,9 +61,13 @@ LOCAL_LIBS += $(TOP)/src/egl/drivers/dri2/libegl_dri2.a
 ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
 EGL_LIB_DEPS += $(XCB_DRI2_LIBS)
 endif
+ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
+EGL_LIB_DEPS += -lgbm
+endif
 EGL_LIB_DEPS += $(LIBUDEV_LIBS) $(DLOPEN_LIBS) $(LIBDRM_LIB) $(WAYLAND_LIBS)
 endif
 
+
 ifneq ($(findstring wayland, $(EGL_PLATFORMS)),)
 LOCAL_LIBS += $(TOP)/src/egl/wayland/wayland-drm/libwayland-drm.a
 endif
index bdfdcb3..0ba7794 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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.
+ *
+ **************************************************************************/
+
+
 /**
  * Public EGL API entrypoints
  *
index c9913f1..4fcbe40 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 EGLAPI_INCLUDED
 #define EGLAPI_INCLUDED
 
index fe2f1a7..3ccc8a6 100644 (file)
@@ -1,3 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2010 LunarG, 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 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 <stdlib.h>
 #include <string.h>
 
index a88189a..d07f301 100644 (file)
@@ -1,3 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2010 LunarG, 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 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 EGLARRAY_INCLUDED
 #define EGLARRAY_INCLUDED
 
index 90c75e8..1bc8cc8 100644 (file)
@@ -1,3 +1,32 @@
+/**************************************************************************
+ *
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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 EGLCOMPILER_INCLUDED
 #define EGLCOMPILER_INCLUDED
 
index 5b377b7..e1d53da 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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.
+ *
+ **************************************************************************/
+
+
 /**
  * EGL Configuration (pixel format) functions.
  */
@@ -305,6 +335,7 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
             break;
          default:
             assert(0);
+            mask = 0;
             break;
          }
          if (val & ~mask)
@@ -456,8 +487,6 @@ _eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
       return EGL_FALSE;
 
    switch (attr) {
-   case EGL_MATCH_NATIVE_PIXMAP:
-      return EGL_FALSE;
    case EGL_Y_INVERTED_NOK:
       return conf->Display->Extensions.NOK_texture_from_pixmap;
    default:
@@ -500,8 +529,9 @@ _eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy,
    if (!_eglValidateConfig(conf, EGL_TRUE))
       return EGL_FALSE;
 
-   /* the spec says that EGL_LEVEL cannot be EGL_DONT_CARE */
-   if (conf->Level == EGL_DONT_CARE)
+   /* EGL_LEVEL and EGL_MATCH_NATIVE_PIXMAP cannot be EGL_DONT_CARE */
+   if (conf->Level == EGL_DONT_CARE ||
+       conf->MatchNativePixmap == EGL_DONT_CARE)
       return EGL_FALSE;
 
    /* ignore other attributes when EGL_CONFIG_ID is given */
@@ -634,7 +664,7 @@ void _eglSwapConfigs(const _EGLConfig **conf1, const _EGLConfig **conf2)
  * qsort() in that the compare function accepts an additional
  * argument.
  */
-void
+static void
 _eglSortConfigs(const _EGLConfig **configs, EGLint count,
                 EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
                                   void *),
@@ -672,34 +702,27 @@ _eglSortConfigs(const _EGLConfig **configs, EGLint count,
 }
 
 
-static int
-_eglFallbackCompare(const _EGLConfig *conf1, const _EGLConfig *conf2,
-                   void *priv_data)
-{
-   const _EGLConfig *criteria = (const _EGLConfig *) priv_data;
-   return _eglCompareConfigs(conf1, conf2, criteria, EGL_TRUE);
-}
-
-
 /**
- * Typical fallback routine for eglChooseConfig
+ * A helper function for implementing eglChooseConfig.  See _eglFilterArray and
+ * _eglSortConfigs for the meanings of match and compare.
  */
 EGLBoolean
-_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
-                 EGLConfig *configs, EGLint config_size, EGLint *num_configs)
+_eglFilterConfigArray(_EGLArray *array, EGLConfig *configs,
+                      EGLint config_size, EGLint *num_configs,
+                      EGLBoolean (*match)(const _EGLConfig *, void *),
+                      EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
+                                        void *),
+                      void *priv_data)
 {
-   _EGLConfig **configList, criteria;
+   _EGLConfig **configList;
    EGLint i, count;
 
    if (!num_configs)
       return _eglError(EGL_BAD_PARAMETER, "eglChooseConfigs");
 
-   if (!_eglParseConfigAttribList(&criteria, disp, attrib_list))
-      return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
-
    /* get the number of matched configs */
-   count = _eglFilterArray(disp->Configs, NULL, 0,
-         (_EGLArrayForEach) _eglMatchConfig, (void *) &criteria);
+   count = _eglFilterArray(array, NULL, 0,
+         (_EGLArrayForEach) match, priv_data);
    if (!count) {
       *num_configs = count;
       return EGL_TRUE;
@@ -710,13 +733,13 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
       return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)");
 
    /* get the matched configs */
-   _eglFilterArray(disp->Configs, (void **) configList, count,
-         (_EGLArrayForEach) _eglMatchConfig, (void *) &criteria);
+   _eglFilterArray(array, (void **) configList, count,
+         (_EGLArrayForEach) match, priv_data);
 
    /* perform sorting of configs */
    if (configs && count) {
       _eglSortConfigs((const _EGLConfig **) configList, count,
-                      _eglFallbackCompare, (void *) &criteria);
+                      compare, priv_data);
       count = MIN2(count, config_size);
       for (i = 0; i < count; i++)
          configs[i] = _eglGetConfigHandle(configList[i]);
@@ -730,6 +753,41 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
 }
 
 
+static EGLBoolean
+_eglFallbackMatch(const _EGLConfig *conf, void *priv_data)
+{
+   return _eglMatchConfig(conf, (const _EGLConfig *) priv_data);
+}
+
+
+static EGLint
+_eglFallbackCompare(const _EGLConfig *conf1, const _EGLConfig *conf2,
+                    void *priv_data)
+{
+   return _eglCompareConfigs(conf1, conf2,
+         (const _EGLConfig *) priv_data, EGL_TRUE);
+}
+
+
+/**
+ * Typical fallback routine for eglChooseConfig
+ */
+EGLBoolean
+_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
+                 EGLConfig *configs, EGLint config_size, EGLint *num_configs)
+{
+   _EGLConfig criteria;
+
+   if (!_eglParseConfigAttribList(&criteria, disp, attrib_list))
+      return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
+
+   return _eglFilterConfigArray(disp->Configs,
+         configs, config_size, num_configs,
+         _eglFallbackMatch, _eglFallbackCompare,
+         (void *) &criteria);
+}
+
+
 /**
  * Fallback for eglGetConfigAttrib.
  */
@@ -739,6 +797,16 @@ _eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
 {
    if (!_eglIsConfigAttribValid(conf, attribute))
       return _eglError(EGL_BAD_ATTRIBUTE, "eglGetConfigAttrib");
+
+   /* nonqueryable attributes */
+   switch (attribute) {
+   case EGL_MATCH_NATIVE_PIXMAP:
+      return _eglError(EGL_BAD_ATTRIBUTE, "eglGetConfigAttrib");
+      break;
+   default:
+      break;
+   }
+
    if (!value)
       return _eglError(EGL_BAD_PARAMETER, "eglGetConfigAttrib");
 
index 2169960..adab95c 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 EGLCONFIG_INCLUDED
 #define EGLCONFIG_INCLUDED
 
@@ -172,11 +202,13 @@ _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
                    const _EGLConfig *criteria, EGLBoolean compare_id);
 
 
-PUBLIC void
-_eglSortConfigs(const _EGLConfig **configs, EGLint count,
-                EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
-                                  void *),
-                void *priv_data);
+PUBLIC EGLBoolean
+_eglFilterConfigArray(_EGLArray *array, EGLConfig *configs,
+                      EGLint config_size, EGLint *num_configs,
+                      EGLBoolean (*match)(const _EGLConfig *, void *),
+                      EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
+                                        void *),
+                      void *filter_data);
 
 
 extern EGLBoolean
index 33dcfa6..38e195f 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 <assert.h>
 #include <stdlib.h>
 #include <string.h>
index 8cd0df1..0ac8462 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 EGLCONTEXT_INCLUDED
 #define EGLCONTEXT_INCLUDED
 
index 4221a9b..54fc4f7 100644 (file)
@@ -1,3 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@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, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdlib.h>
 #include <string.h>
 #include "egllog.h"
index e5c94ce..a64821e 100644 (file)
@@ -1,3 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@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, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 EGLCURRENT_INCLUDED
 #define EGLCURRENT_INCLUDED
 
index 4ecd4c1..d468d7b 100644 (file)
@@ -1,8 +1,8 @@
 /**************************************************************************
- * 
+ *
  * 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
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
  **************************************************************************/
 
 
-
 /**
  * Internal EGL defines
  */
index 3059294..60f3177 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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.
+ *
+ **************************************************************************/
+
+
 /**
  * Functions related to EGLDisplay.
  */
index 97ae2b0..9cd4dbf 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 EGLDISPLAY_INCLUDED
 #define EGLDISPLAY_INCLUDED
 
index b75e8b6..ffdd146 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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.
+ *
+ **************************************************************************/
+
+
 /**
  * Functions for choosing and opening/loading device drivers.
  */
index 3cde102..4bb9612 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 EGLDRIVER_INCLUDED
 #define EGLDRIVER_INCLUDED
 
index 7c93adb..b4f35d7 100644 (file)
@@ -1,3 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2010 LunarG, 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 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 <string.h>
 #include "egltypedefs.h"
 #include "egldriver.h"
index 52eebb0..f53f078 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 <stdlib.h>
 #include <assert.h>
 #include "eglglobals.h"
index c3771a8..b40e30e 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 EGLGLOBALS_INCLUDED
 #define EGLGLOBALS_INCLUDED
 
index 6d4ee4e..458a2e4 100644 (file)
@@ -1,3 +1,32 @@
+/**************************************************************************
+ *
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 <assert.h>
 #include <string.h>
 
index adb939a..acb36aa 100644 (file)
@@ -1,3 +1,32 @@
+/**************************************************************************
+ *
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 EGLIMAGE_INCLUDED
 #define EGLIMAGE_INCLUDED
 
index 12c55f9..43eed64 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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.
+ *
+ **************************************************************************/
+
+
 /**
  * Logging facility for debug/info messages.
  * _EGL_FATAL messages are printed to stderr
index 03bef26..10a4184 100644 (file)
@@ -1,3 +1,32 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@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, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 EGLLOG_INCLUDED
 #define EGLLOG_INCLUDED
 
index 6bb2498..da189b6 100644 (file)
@@ -1,8 +1,10 @@
 /**************************************************************************
- * 
+ *
  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
  **************************************************************************/
 
 
index a753307..da0adbd 100644 (file)
@@ -1,8 +1,10 @@
 /**************************************************************************
- * 
+ *
  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
  **************************************************************************/
 
 
index a965349..617d4c2 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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 <assert.h>
 #include <stdlib.h>
 #include <string.h>
index ed4eb2c..a423f02 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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 EGLMODE_INCLUDED
 #define EGLMODE_INCLUDED
 
index 29faba0..852e251 100644 (file)
@@ -1,3 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Chia-I Wu <olvaffe@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, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 EGLMUTEX_INCLUDED
 #define EGLMUTEX_INCLUDED
 
index 3abe85f..e219520 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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.
+ *
+ **************************************************************************/
+
+
 /*
  * Ideas for screen management extension to EGL.
  *
index 2a99f23..5e2f657 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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 EGLSCREEN_INCLUDED
 #define EGLSCREEN_INCLUDED
 
index e4ab191..e3568cb 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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.
+ *
+ **************************************************************************/
+
+
 /**
  * String utils.
  */
index d4c8954..d3ab435 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010-2011 LunarG, 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 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 EGLSTRING_INCLUDED
 #define EGLSTRING_INCLUDED
 
index cc50504..3564ecd 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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.
+ *
+ **************************************************************************/
+
+
 /**
  * Surface-related functions.
  */
@@ -239,11 +269,13 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 {
    const char *func;
    EGLint renderBuffer = EGL_BACK_BUFFER;
+   EGLint swapBehavior = EGL_BUFFER_PRESERVED;
    EGLint err;
 
    switch (type) {
    case EGL_WINDOW_BIT:
       func = "eglCreateWindowSurface";
+      swapBehavior = EGL_BUFFER_DESTROYED;
       break;
    case EGL_PIXMAP_BIT:
       func = "eglCreatePixmapSurface";
@@ -285,7 +317,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 
    surf->MipmapLevel = 0;
    surf->MultisampleResolve = EGL_MULTISAMPLE_RESOLVE_DEFAULT;
-   surf->SwapBehavior = EGL_BUFFER_DESTROYED;
+   surf->SwapBehavior = swapBehavior;
 
    surf->HorizontalResolution = EGL_UNKNOWN;
    surf->VerticalResolution = EGL_UNKNOWN;
index ef01b32..0541ff4 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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 EGLSURFACE_INCLUDED
 #define EGLSURFACE_INCLUDED
 
index 95e97c7..d8e3ee0 100644 (file)
@@ -1,3 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2010 LunarG, 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 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 <string.h>
 
 #include "eglsync.h"
index a002523..1a56889 100644 (file)
@@ -1,3 +1,31 @@
+/**************************************************************************
+ *
+ * Copyright 2010 LunarG, 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 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 EGLSYNC_INCLUDED
 #define EGLSYNC_INCLUDED
 
index 20b67b2..120a277 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, 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 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 EGLTYPEDEFS_INCLUDED
 #define EGLTYPEDEFS_INCLUDED
 
index 0331f12..cde9430 100644 (file)
@@ -1,5 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <protocol name="drm">
+
+  <copyright>
+    Copyright Â© 2008-2011 Kristian Høgsberg
+    Copyright Â© 2010-2011 Intel Corporation
+
+    Permission to use, copy, modify, distribute, and sell this
+    software and its documentation for any purpose is hereby granted
+    without fee, provided that\n 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.
+  </copyright>
+
   <!-- drm support. This object is created by the server and published
        using the display's global event. -->
   <interface name="wl_drm" version="1">
index 6cc442b..ec96c04 100644 (file)
@@ -88,22 +88,23 @@ drm_create_buffer(struct wl_client *client, struct wl_drm *drm,
 {
        struct wl_drm_buffer *buffer;
 
-       buffer = malloc(sizeof *buffer);
+       buffer = calloc(1, sizeof *buffer);
        if (buffer == NULL) {
                wl_client_post_no_memory(client);
                return;
        }
 
        buffer->drm = drm;
-       buffer->buffer.compositor = NULL;
        buffer->buffer.width = width;
        buffer->buffer.height = height;
        buffer->buffer.visual = visual;
+       buffer->buffer.client = client;
 
        if (!visual || visual->object.interface != &wl_visual_interface) {
                wl_client_post_error(client, &drm->object,
                                     WL_DRM_ERROR_INVALID_VISUAL,
                                     "invalid visual");
+               free(buffer);
                return;
        }
 
index 428bc31..3072ee9 100644 (file)
@@ -53,7 +53,7 @@ if env['drm']:
 # Needed by some state trackers
 SConscript('winsys/sw/null/SConscript')
 
-if env['platform'] != 'embedded':
+if not env['embedded']:
     SConscript('state_trackers/vega/SConscript')
     SConscript('state_trackers/egl/SConscript')
 
@@ -66,8 +66,8 @@ if env['platform'] != 'embedded':
     if env['dri'] and env['xorg']:
         SConscript('state_trackers/xorg/SConscript')
 
-if env['platform'] == 'windows':
-    SConscript('state_trackers/wgl/SConscript')
+    if env['platform'] == 'windows':
+        SConscript('state_trackers/wgl/SConscript')
 
 #
 # Winsys
@@ -83,55 +83,55 @@ SConscript([
     'targets/graw-null/SConscript',
 ])
 
-if env['platform'] != 'embedded':
+if not env['embedded']:
     SConscript([
         'targets/egl-static/SConscript'
     ])
 
-if env['x11']:
-    SConscript([
-        'targets/graw-xlib/SConscript',
-        'targets/libgl-xlib/SConscript',
-    ])
+    if env['x11']:
+        SConscript([
+            'targets/graw-xlib/SConscript',
+            'targets/libgl-xlib/SConscript',
+        ])
 
-if env['platform'] == 'windows':
-    SConscript([
-        'targets/graw-gdi/SConscript',
-        'targets/libgl-gdi/SConscript',
-    ])
+    if env['platform'] == 'windows':
+        SConscript([
+            'targets/graw-gdi/SConscript',
+            'targets/libgl-gdi/SConscript',
+        ])
 
-if env['dri']:
-    SConscript([
-        'targets/SConscript.dri',
-        'targets/dri-swrast/SConscript',
-        'targets/dri-vmwgfx/SConscript',
-        #'targets/dri-nouveau/SConscript',
-    ])
-    if env['drm_intel']:
+    if env['dri']:
         SConscript([
-            'targets/dri-i915/SConscript',
-            'targets/dri-i965/SConscript',
+            'targets/SConscript.dri',
+            'targets/dri-swrast/SConscript',
+            'targets/dri-vmwgfx/SConscript',
+            #'targets/dri-nouveau/SConscript',
         ])
-    if env['drm_radeon']:
+        if env['drm_intel']:
+            SConscript([
+                'targets/dri-i915/SConscript',
+                'targets/dri-i965/SConscript',
+            ])
+        if env['drm_radeon']:
+            SConscript([
+                'targets/dri-r300/SConscript',
+                'targets/dri-r600/SConscript',
+            ])
+
+    if env['xorg'] and env['drm']:
         SConscript([
-            'targets/dri-r300/SConscript',
-            'targets/dri-r600/SConscript',
+            #'targets/xorg-i915/SConscript',
+            #'targets/xorg-i965/SConscript',
+            #'targets/xorg-nouveau/SConscript',
+            #'targets/xorg-radeon/SConscript',
+            'targets/xorg-vmwgfx/SConscript',
         ])
 
-if env['xorg'] and env['drm']:
-    SConscript([
-        #'targets/xorg-i915/SConscript',
-        #'targets/xorg-i965/SConscript',
-        #'targets/xorg-nouveau/SConscript',
-        #'targets/xorg-radeon/SConscript',
-        'targets/xorg-vmwgfx/SConscript',
-    ])
-
 
 #
 # Unit tests & tools
 #
 
-if env['platform'] != 'embedded':
+if not env['embedded']:
     SConscript('tests/unit/SConscript')
     SConscript('tests/graw/SConscript')
index d10f9cd..7dae7bc 100644 (file)
@@ -147,14 +147,17 @@ C_SOURCES = \
        util/u_transfer.c \
        util/u_resource.c \
        util/u_upload_mgr.c \
-       util/u_vbuf_mgr.c
-
-       # Disabling until pipe-video branch gets merged in
-       #vl/vl_bitstream_parser.c \
-       #vl/vl_mpeg12_mc_renderer.c \
-       #vl/vl_compositor.c \
-       #vl/vl_csc.c \
-       #vl/vl_shader_build.c \
+       util/u_vbuf_mgr.c \
+       vl/vl_csc.c \
+       vl/vl_compositor.c \
+       vl/vl_decoder.c \
+       vl/vl_mpeg12_decoder.c \
+       vl/vl_mpeg12_bitstream.c \
+       vl/vl_zscan.c \
+        vl/vl_idct.c \
+       vl/vl_mc.c \
+        vl/vl_vertex_buffers.c \
+        vl/vl_video_buffer.c
 
 GALLIVM_SOURCES = \
         gallivm/lp_bld_arit.c \
@@ -225,3 +228,4 @@ util/u_format_table.c: util/u_format_table.py util/u_format_pack.py util/u_forma
 
 util/u_half.c: util/u_half.py
        $(PYTHON2) util/u_half.py > $@
+# DO NOT DELETE
index 457911d..d18f55f 100644 (file)
@@ -195,12 +195,16 @@ source = [
     'util/u_transfer.c',
     'util/u_upload_mgr.c',
     'util/u_vbuf_mgr.c',
-    # Disabling until pipe-video branch gets merged in
-    #'vl/vl_bitstream_parser.c',
-    #'vl/vl_mpeg12_mc_renderer.c',
-    #'vl/vl_compositor.c',
-    #'vl/vl_csc.c',
-    #'vl/vl_shader_build.c',
+    'vl/vl_csc.c',
+    'vl/vl_compositor.c',
+    'vl/vl_decoder.c',
+    'vl/vl_mpeg12_decoder.c',
+    'vl/vl_mpeg12_bitstream.c',
+    'vl/vl_zscan.c',
+    'vl/vl_idct.c',
+    'vl/vl_mc.c',
+    'vl/vl_vertex_buffers.c',
+    'vl/vl_video_buffer.c',
 ]
 
 if env['llvm']:
index 56c26f5..996e295 100644 (file)
@@ -96,7 +96,7 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *var);
  * Create LLVM type for struct draw_jit_texture
  */
 static LLVMTypeRef
-create_jit_texture_type(struct gallivm_state *gallivm)
+create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
 {
    LLVMTargetDataRef target = gallivm->target;
    LLVMTypeRef texture_type;
@@ -120,13 +120,21 @@ create_jit_texture_type(struct gallivm_state *gallivm)
    elem_types[DRAW_JIT_TEXTURE_BORDER_COLOR] = 
       LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
 
+#if HAVE_LLVM >= 0x0300
+   texture_type = LLVMStructCreateNamed(gallivm->context, struct_name);
+   LLVMStructSetBody(texture_type, elem_types,
+                     Elements(elem_types), 0);
+#else
    texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
                                           Elements(elem_types), 0);
 
+   LLVMAddTypeName(gallivm->module, struct_name, texture_type);
+
    /* Make sure the target's struct layout cache doesn't return
     * stale/invalid data.
     */
    LLVMInvalidateStructLayout(gallivm->target, texture_type);
+#endif
 
    LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width,
                           target, texture_type,
@@ -176,7 +184,7 @@ create_jit_texture_type(struct gallivm_state *gallivm)
  */
 static LLVMTypeRef
 create_jit_context_type(struct gallivm_state *gallivm,
-                        LLVMTypeRef texture_type)
+                        LLVMTypeRef texture_type, const char *struct_name)
 {
    LLVMTargetDataRef target = gallivm->target;
    LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
@@ -189,11 +197,17 @@ create_jit_context_type(struct gallivm_state *gallivm,
    elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */
    elem_types[4] = LLVMArrayType(texture_type,
                                  PIPE_MAX_VERTEX_SAMPLERS); /* textures */
-
+#if HAVE_LLVM >= 0x0300
+   context_type = LLVMStructCreateNamed(gallivm->context, struct_name);
+   LLVMStructSetBody(context_type, elem_types,
+                     Elements(elem_types), 0);
+#else
    context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
                                           Elements(elem_types), 0);
+   LLVMAddTypeName(gallivm->module, struct_name, context_type);
 
    LLVMInvalidateStructLayout(gallivm->target, context_type);
+#endif
 
    LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants,
                           target, context_type, 0);
@@ -215,7 +229,7 @@ create_jit_context_type(struct gallivm_state *gallivm,
  * Create LLVM type for struct pipe_vertex_buffer
  */
 static LLVMTypeRef
-create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
+create_jit_vertex_buffer_type(struct gallivm_state *gallivm, const char *struct_name)
 {
    LLVMTargetDataRef target = gallivm->target;
    LLVMTypeRef elem_types[3];
@@ -225,10 +239,17 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
    elem_types[1] = LLVMInt32TypeInContext(gallivm->context);
    elem_types[2] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */
 
+#if HAVE_LLVM >= 0x0300
+   vb_type = LLVMStructCreateNamed(gallivm->context, struct_name);
+   LLVMStructSetBody(vb_type, elem_types,
+                     Elements(elem_types), 0);
+#else
    vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
                                      Elements(elem_types), 0);
+   LLVMAddTypeName(gallivm->module, struct_name, vb_type);
 
    LLVMInvalidateStructLayout(gallivm->target, vb_type);
+#endif
 
    LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
                           target, vb_type, 0);
@@ -258,10 +279,17 @@ create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
    elem_types[1]  = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
    elem_types[2]  = LLVMArrayType(elem_types[1], data_elems);
 
+#if HAVE_LLVM >= 0x0300
+   vertex_header = LLVMStructCreateNamed(gallivm->context, struct_name);
+   LLVMStructSetBody(vertex_header, elem_types,
+                     Elements(elem_types), 0);
+#else
    vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
                                            Elements(elem_types), 0);
+   LLVMAddTypeName(gallivm->module, struct_name, vertex_header);
 
    LLVMInvalidateStructLayout(gallivm->target, vertex_header);
+#endif
 
    /* these are bit-fields and we can't take address of them
       LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask,
@@ -284,8 +312,6 @@ create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
                           target, vertex_header,
                           DRAW_JIT_VERTEX_DATA);
 
-   LLVMAddTypeName(gallivm->module, struct_name, vertex_header);
-
    return vertex_header;
 }
 
@@ -299,19 +325,15 @@ create_jit_types(struct draw_llvm *llvm)
    struct gallivm_state *gallivm = llvm->gallivm;
    LLVMTypeRef texture_type, context_type, buffer_type, vb_type;
 
-   texture_type = create_jit_texture_type(gallivm);
-   LLVMAddTypeName(gallivm->module, "texture", texture_type);
+   texture_type = create_jit_texture_type(gallivm, "texture");
 
-   context_type = create_jit_context_type(gallivm, texture_type);
-   LLVMAddTypeName(gallivm->module, "draw_jit_context", context_type);
+   context_type = create_jit_context_type(gallivm, texture_type, "draw_jit_context");
    llvm->context_ptr_type = LLVMPointerType(context_type, 0);
 
    buffer_type = LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 8), 0);
-   LLVMAddTypeName(gallivm->module, "buffer", buffer_type);
    llvm->buffer_ptr_type = LLVMPointerType(buffer_type, 0);
 
-   vb_type = create_jit_vertex_buffer_type(gallivm);
-   LLVMAddTypeName(gallivm->module, "pipe_vertex_buffer", vb_type);
+   vb_type = create_jit_vertex_buffer_type(gallivm, "pipe_vertex_buffer");
    llvm->vb_ptr_type = LLVMPointerType(vb_type, 0);
 }
 
@@ -1163,6 +1185,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
    struct lp_build_loop_state lp_loop;
    const int max_vertices = 4;
    LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
+   LLVMValueRef fetch_max;
    void *code;
    struct lp_build_sampler_soa *sampler = 0;
    LLVMValueRef ret, ret_ptr;
@@ -1234,6 +1257,11 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
       draw_llvm_variant_key_samplers(&variant->key),
       context_ptr);
 
+   /* fetch_max = start + count - 1 */
+   fetch_max = LLVMBuildSub(builder, end,
+                            lp_build_const_int32(gallivm, 1),
+                            "fetch_max");
+
 #if DEBUG_STORE
    lp_build_printf(builder, "start = %d, end = %d, step = %d\n",
                    start, end, step);
@@ -1257,6 +1285,12 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
             builder,
             lp_loop.counter,
             lp_build_const_int32(gallivm, i), "");
+
+         /* make sure we're not out of bounds which can happen
+          * if fetch_count % 4 != 0, because on the last iteration
+          * a few of the 4 vertex fetches will be out of bounds */
+         true_index = lp_build_min(&bld, true_index, fetch_max);
+
          for (j = 0; j < draw->pt.nr_vertex_elements; ++j) {
             struct pipe_vertex_element *velem = &draw->pt.vertex_element[j];
             LLVMValueRef vb_index = lp_build_const_int32(gallivm, velem->vertex_buffer_index);
index 32af29a..458f85d 100644 (file)
@@ -784,6 +784,14 @@ aaline_destroy(struct draw_stage *stage)
 
    draw_free_temp_verts( stage );
 
+   /* restore the old entry points */
+   pipe->create_fs_state = aaline->driver_create_fs_state;
+   pipe->bind_fs_state = aaline->driver_bind_fs_state;
+   pipe->delete_fs_state = aaline->driver_delete_fs_state;
+
+   pipe->bind_fragment_sampler_states = aaline->driver_bind_sampler_states;
+   pipe->set_fragment_sampler_views = aaline->driver_set_sampler_views;
+
    FREE( stage );
 }
 
index 60f6380..9265c37 100644 (file)
@@ -768,7 +768,16 @@ aapoint_reset_stipple_counter(struct draw_stage *stage)
 static void
 aapoint_destroy(struct draw_stage *stage)
 {
+   struct aapoint_stage* aapoint = aapoint_stage(stage);
+   struct pipe_context *pipe = stage->draw->pipe;
+
    draw_free_temp_verts( stage );
+
+   /* restore the old entry points */
+   pipe->create_fs_state = aapoint->driver_create_fs_state;
+   pipe->bind_fs_state = aapoint->driver_bind_fs_state;
+   pipe->delete_fs_state = aapoint->driver_delete_fs_state;
+
    FREE( stage );
 }
 
index 5eb09c0..6b9c35b 100644 (file)
@@ -15,8 +15,9 @@
  *
  * How to use this source:
  *
- * - Download and abuild the NTL library from
- *   http://shoup.net/ntl/download.html
+ * - Download and build the NTL library from
+ *   http://shoup.net/ntl/download.html , or install libntl-dev package if on
+ *   Debian.
  *
  * - Download boost source code matching to your distro. 
  *
  *
  * - Build as
  *
- *   g++ -o minimax -I /path/to/ntl/include main.cpp f.cpp /path/to/ntl/src/ntl.a -lboost_math_tr1
+ *   g++ -o minimax -I /path/to/ntl/include main.cpp f.cpp /path/to/ntl/src/ntl.a
  *
  * - Run as 
  *
  *    ./minimax
  *
- * - For example, to compute exp2 5th order polynomial between [0, 1] do:
+ * - For example, to compute log2 5th order polynomial between [1, 2] do:
+ *
+ *    variant 0
+ *    range 1 2
+ *    order 5 0
+ *    step 200
+ *    info
+ *
+ *  and take the coefficients from the P = { ... } array.
+ *
+ * - To compute exp2 5th order polynomial between [0, 1] do:
  *
  *    variant 1
  *    range 0 1
  *    order 5 0
- *    steps 200
+ *    step 200
  *    info
  *
  * - For more info see
- * http://www.boost.org/doc/libs/1_36_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/minimax.html
+ * http://www.boost.org/doc/libs/1_47_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/minimax.html
  */
 
 #define L22
index 02b3bde..2be8598 100644 (file)
@@ -61,7 +61,7 @@
 #include "lp_bld_arit.h"
 
 
-#define EXP_POLY_DEGREE 3
+#define EXP_POLY_DEGREE 5
 
 #define LOG_POLY_DEGREE 5
 
@@ -1645,7 +1645,7 @@ lp_build_rsqrt(struct lp_build_context *bld,
    assert(type.floating);
 
    if (util_cpu_caps.has_sse && type.width == 32 && type.length == 4) {
-      const unsigned num_iterations = 0;
+      const unsigned num_iterations = 1;
       LLVMValueRef res;
       unsigned i;
 
@@ -2151,7 +2151,7 @@ lp_build_exp(struct lp_build_context *bld,
 
    assert(lp_check_value(bld->type, x));
 
-   return lp_build_mul(bld, log2e, lp_build_exp2(bld, x));
+   return lp_build_exp2(bld, lp_build_mul(bld, log2e, x));
 }
 
 
@@ -2168,7 +2168,7 @@ lp_build_log(struct lp_build_context *bld,
 
    assert(lp_check_value(bld->type, x));
 
-   return lp_build_mul(bld, log2, lp_build_exp2(bld, x));
+   return lp_build_mul(bld, log2, lp_build_log2(bld, x));
 }
 
 
@@ -2218,18 +2218,18 @@ lp_build_polynomial(struct lp_build_context *bld,
  */
 const double lp_build_exp2_polynomial[] = {
 #if EXP_POLY_DEGREE == 5
-   0.999999999690134838155,
-   0.583974334321735217258,
-   0.164553105719676828492,
-   0.0292811063701710962255,
-   0.00354944426657875141846,
-   0.000296253726543423377365
+   0.999999925063526176901,
+   0.693153073200168932794,
+   0.240153617044375388211,
+   0.0558263180532956664775,
+   0.00898934009049466391101,
+   0.00187757667519147912699
 #elif EXP_POLY_DEGREE == 4
-   1.00000001502262084505,
-   0.563586057338685991394,
-   0.150436017652442413623,
-   0.0243220604213317927308,
-   0.0025359088446580436489
+   1.00000259337069434683,
+   0.693003834469974940458,
+   0.24144275689150793076,
+   0.0520114606103070150235,
+   0.0135341679161270268764
 #elif EXP_POLY_DEGREE == 3
    0.999925218562710312959,
    0.695833540494823811697,
@@ -2465,6 +2465,12 @@ lp_build_log2_approx(struct lp_build_context *bld,
 
       assert(type.floating && type.width == 32);
 
+      /* 
+       * We don't explicitly handle denormalized numbers. They will yield a
+       * result in the neighbourhood of -127, which appears to be adequate
+       * enough.
+       */
+
       i = LLVMBuildBitCast(builder, x, int_vec_type, "");
 
       /* exp = (float) exponent(x) */
index 0b724a3..e252607 100644 (file)
@@ -193,7 +193,11 @@ lp_disassemble(const void* func)
 
    InitializeAllDisassemblers();
 
+#if HAVE_LLVM >= 0x0300
+   OwningPtr<const MCAsmInfo> AsmInfo(T->createMCAsmInfo(Triple));
+#else
    OwningPtr<const MCAsmInfo> AsmInfo(T->createAsmInfo(Triple));
+#endif
 
    if (!AsmInfo) {
       debug_printf("error: no assembly info for target %s\n", Triple.c_str());
@@ -207,17 +211,13 @@ lp_disassemble(const void* func)
    }
 
    raw_debug_ostream Out;
-   TargetMachine *TM = T->createTargetMachine(Triple, "");
 
 #if HAVE_LLVM >= 0x0300
    unsigned int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
 #else
    int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
 #endif
-#if HAVE_LLVM >= 0x0300
-   OwningPtr<MCInstPrinter> Printer(
-         T->createMCInstPrinter(*TM, AsmPrinterVariant, *AsmInfo));
-#elif HAVE_LLVM >= 0x0208
+#if HAVE_LLVM >= 0x0208
    OwningPtr<MCInstPrinter> Printer(
          T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo));
 #else
@@ -229,6 +229,12 @@ lp_disassemble(const void* func)
       return;
    }
 
+#if HAVE_LLVM >= 0x0300
+   TargetMachine *TM = T->createTargetMachine(Triple, sys::getHostCPUName(), "");
+#else
+   TargetMachine *TM = T->createTargetMachine(Triple, "");
+#endif
+
    const TargetInstrInfo *TII = TM->getInstrInfo();
 
    /*
@@ -287,7 +293,11 @@ lp_disassemble(const void* func)
 
       pc += Size;
 
+#if HAVE_LLVM >= 0x0300
+      const MCInstrDesc &TID = TII->get(Inst.getOpcode());
+#else
       const TargetInstrDesc &TID = TII->get(Inst.getOpcode());
+#endif
 
       /*
        * Keep track of forward jumps to a nearby address.
index d2d7ecc..85fabc5 100644 (file)
@@ -83,8 +83,12 @@ lp_set_target_options(void)
     * to only assume a 4 bytes alignment for backwards compatibility.
     */
 #if defined(PIPE_ARCH_X86)
+#if HAVE_LLVM >= 0x0300
+   llvm::StackAlignmentOverride = 4;
+#else
    llvm::StackAlignment = 4;
 #endif
+#endif
 
 #if defined(DEBUG) || defined(PROFILE)
    llvm::NoFramePointerElim = true;
index c5cf6d4..efd159f 100644 (file)
@@ -325,16 +325,18 @@ lp_typekind_name(LLVMTypeKind t)
       return "LLVMArrayTypeKind";
    case LLVMPointerTypeKind:
       return "LLVMPointerTypeKind";
+#if HAVE_LLVM < 0x0300
    case LLVMOpaqueTypeKind:
       return "LLVMOpaqueTypeKind";
+#endif
    case LLVMVectorTypeKind:
       return "LLVMVectorTypeKind";
    case LLVMMetadataTypeKind:
       return "LLVMMetadataTypeKind";
-   /* Only in LLVM 2.7 and later???
+#if HAVE_LLVM == 0x0207
    case LLVMUnionTypeKind:
       return "LLVMUnionTypeKind";
-   */
+#endif
    default:
       return "unknown LLVMTypeKind";
    }
index 36896ce..085c47a 100644 (file)
@@ -167,8 +167,8 @@ def trifan(intype, outtype):
 
 def polygon(intype, outtype):
     preamble(intype, outtype, prim='polygon')
-    print '  for (j = i = 0; j < nr; j+=6, i++) { '
-    do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2' );
+    print '  for (j = i = 0; j < nr; j+=2, i++) { '
+    line( intype, outtype, 'out+j', 'i', '(i+1)%(nr/2)' )
     print '   }'
     postamble()
 
index 26c5d4d..c353717 100644 (file)
@@ -71,6 +71,11 @@ static void generate_linear_uint( unsigned nr,
 }
 
 
+/**
+ * Given a primitive type and number of vertices, return the number of vertices
+ * needed to draw the primitive with fill mode = PIPE_POLYGON_MODE_LINE using
+ * separate lines (PIPE_PRIM_LINES).
+ */
 static unsigned nr_lines( unsigned prim,
                           unsigned nr )
 {
@@ -86,7 +91,7 @@ static unsigned nr_lines( unsigned prim,
    case PIPE_PRIM_QUAD_STRIP:
       return (nr - 2) / 2 * 8;
    case PIPE_PRIM_POLYGON:
-      return (nr - 2) * 6;
+      return 2 * nr; /* a line (two verts) for each polygon edge */
    default:
       assert(0);
       return 0;
index 556662d..91a84a2 100644 (file)
@@ -39,7 +39,7 @@
 #include "pipe/p_compiler.h"
 
 
-#if defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_SUBSYSTEM_EMBEDDED)
 
 #ifdef __cplusplus
 extern "C" {
index d59f981..48522da 100644 (file)
@@ -58,8 +58,6 @@ extern "C" {
 #  define os_break()  __debugbreak()
 #elif defined(PIPE_OS_UNIX)
 #  define os_break() kill(getpid(), SIGTRAP)
-#elif defined(PIPE_OS_EMBEDDED)
-void os_break(void);
 #else
 #  define os_break() abort()
 #endif
@@ -70,8 +68,6 @@ void os_break(void);
  */
 #if defined(DEBUG) || defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
 #  define os_abort() os_break()
-#elif defined(PIPE_OS_EMBEDDED)
-void os_abort(void);
 #else
 #  define os_abort() abort()
 #endif
index 6b4281a..8f1245b 100644 (file)
@@ -40,7 +40,7 @@
 #include "util/u_debug.h" /* for assert */
 
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
 
 #include <pthread.h> /* POSIX threads headers */
 #include <stdio.h> /* for perror() */
@@ -314,7 +314,7 @@ typedef int64_t pipe_condvar;
  * pipe_barrier
  */
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
 
 typedef pthread_barrier_t pipe_barrier;
 
@@ -442,7 +442,7 @@ pipe_semaphore_wait(pipe_semaphore *sema)
  */
 
 typedef struct {
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
    pthread_key_t key;
 #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
    DWORD key;
@@ -457,7 +457,7 @@ typedef struct {
 static INLINE void
 pipe_tsd_init(pipe_tsd *tsd)
 {
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
    if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
       perror("pthread_key_create(): failed to allocate key for thread specific data");
       exit(-1);
@@ -474,7 +474,7 @@ pipe_tsd_get(pipe_tsd *tsd)
    if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
       pipe_tsd_init(tsd);
    }
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
    return pthread_getspecific(tsd->key);
 #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
    assert(0);
@@ -491,7 +491,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value)
    if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
       pipe_tsd_init(tsd);
    }
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
    if (pthread_setspecific(tsd->key, value) != 0) {
       perror("pthread_set_specific() failed");
       exit(-1);
index 325f316..73d8629 100644 (file)
@@ -35,8 +35,6 @@
 
 #include "pipe/p_config.h"
 
-#if !defined(PIPE_OS_EMBEDDED)
-
 #if defined(PIPE_OS_UNIX)
 #  include <sys/time.h> /* timeval */
 #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
@@ -123,6 +121,3 @@ os_time_sleep(int64_t usecs)
 }
 
 #endif
-
-
-#endif /* !PIPE_OS_EMBEDDED */
index 072772e..587483c 100644 (file)
@@ -1839,6 +1839,17 @@ exec_tex(struct tgsi_exec_machine *mach,
       assert(0);
    }
 
+#if 0
+   debug_printf("fetch r: %g %g %g %g\n",
+         r[0].f[0], r[0].f[1], r[0].f[2], r[0].f[3]);
+   debug_printf("fetch g: %g %g %g %g\n",
+         r[1].f[0], r[1].f[1], r[1].f[2], r[1].f[3]);
+   debug_printf("fetch b: %g %g %g %g\n",
+         r[2].f[0], r[2].f[1], r[2].f[2], r[2].f[3]);
+   debug_printf("fetch a: %g %g %g %g\n",
+         r[3].f[0], r[3].f[1], r[3].f[2], r[3].f[3]);
+#endif
+
    for (chan = 0; chan < NUM_CHANNELS; chan++) {
       if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
          store_dest(mach, &r[chan], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
index 83c6ac7..f165f82 100644 (file)
@@ -200,19 +200,20 @@ 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;
+         {
+            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->properties[info->num_properties].name =
+               fullprop->Property.PropertyName;
+            memcpy(info->properties[info->num_properties].data,
+                   fullprop->u, 8 * sizeof(unsigned));;
 
-         ++info->num_properties;
-      }
-      break;
+            ++info->num_properties;
+         }
+         break;
 
       default:
          assert( 0 );
@@ -222,6 +223,23 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
    info->uses_kill = (info->opcode_count[TGSI_OPCODE_KIL] ||
                       info->opcode_count[TGSI_OPCODE_KILP]);
 
+   /* extract simple properties */
+   for (i = 0; i < info->num_properties; ++i) {
+      switch (info->properties[i].name) {
+      case TGSI_PROPERTY_FS_COORD_ORIGIN:
+         info->origin_lower_left = info->properties[i].data[0];
+         break;
+      case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER:
+         info->pixel_center_integer = info->properties[i].data[0];
+         break;
+      case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS:
+         info->color0_writes_all_cbufs = info->properties[i].data[0];
+         break;
+      default:
+         ;
+      }
+   }
+
    tgsi_parse_free (&parse);
 }
 
index 53ab3d5..d6e593b 100644 (file)
@@ -68,6 +68,9 @@ struct tgsi_shader_info
    boolean writes_edgeflag; /**< vertex shader outputs edgeflag */
    boolean uses_kill;  /**< KIL or KILP instruction used? */
    boolean uses_instanceid;
+   boolean origin_lower_left;
+   boolean pixel_center_integer;
+   boolean color0_writes_all_cbufs;
 
    /**
     * Bitmask indicating which register files are accessed with
index 36ce4b5..2d61930 100644 (file)
@@ -48,7 +48,7 @@
 
 void _debug_vprintf(const char *format, va_list ap)
 {
-#if defined(PIPE_OS_WINDOWS) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_WINDOWS) || defined(PIPE_SUBSYSTEM_EMBEDDED)
    /* We buffer until we find a newline. */
    static char buf[4096] = {'\0'};
    size_t len = strlen(buf);
@@ -730,7 +730,7 @@ debug_dump_float_rgba_bmp(const char *filename,
          pixel.rgbRed   = float_to_ubyte(ptr[x*4 + 0]);
          pixel.rgbGreen = float_to_ubyte(ptr[x*4 + 1]);
          pixel.rgbBlue  = float_to_ubyte(ptr[x*4 + 2]);
-         pixel.rgbAlpha = 255;
+         pixel.rgbAlpha = float_to_ubyte(ptr[x*4 + 3]);
          os_stream_write(stream, &pixel, 4);
       }
    }
index 9cbdd0a..34922ab 100644 (file)
@@ -390,3 +390,53 @@ util_format_translate(enum pipe_format dst_format,
       FREE(tmp_row);
    }
 }
+
+void util_format_compose_swizzles(const unsigned char swz1[4],
+                                  const unsigned char swz2[4],
+                                  unsigned char dst[4])
+{
+   unsigned i;
+
+   for (i = 0; i < 4; i++) {
+      dst[i] = swz2[i] <= UTIL_FORMAT_SWIZZLE_W ?
+               swz1[swz2[i]] : swz2[i];
+   }
+}
+
+void util_format_swizzle_4f(float *dst, const float *src,
+                            const unsigned char swz[4])
+{
+   unsigned i;
+
+   for (i = 0; i < 4; i++) {
+      if (swz[i] <= UTIL_FORMAT_SWIZZLE_W)
+         dst[i] = src[swz[i]];
+      else if (swz[i] == UTIL_FORMAT_SWIZZLE_0)
+         dst[i] = 0;
+      else if (swz[i] == UTIL_FORMAT_SWIZZLE_1)
+         dst[i] = 1;
+   }
+}
+
+void util_format_unswizzle_4f(float *dst, const float *src,
+                              const unsigned char swz[4])
+{
+   unsigned i;
+
+   for (i = 0; i < 4; i++) {
+      switch (swz[i]) {
+      case UTIL_FORMAT_SWIZZLE_X:
+         dst[0] = src[i];
+         break;
+      case UTIL_FORMAT_SWIZZLE_Y:
+         dst[1] = src[i];
+         break;
+      case UTIL_FORMAT_SWIZZLE_Z:
+         dst[2] = src[i];
+         break;
+      case UTIL_FORMAT_SWIZZLE_W:
+         dst[3] = src[i];
+         break;
+      }
+   }
+}
index a8baad1..a3d2aae 100644 (file)
@@ -259,3 +259,11 @@ PIPE_FORMAT_R32G32B32A32_FIXED    , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, r
 PIPE_FORMAT_R10G10B10X2_USCALED   , plain, 1, 1, u10 , u10 , u10  , x2 , xyz1, rgb
 # A.k.a. D3DDECLTYPE_DEC3N
 PIPE_FORMAT_R10G10B10X2_SNORM     , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb
+
+PIPE_FORMAT_YV12                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
+PIPE_FORMAT_YV16                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
+PIPE_FORMAT_IYUV                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
+PIPE_FORMAT_NV12                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
+PIPE_FORMAT_NV21                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
+PIPE_FORMAT_IA44                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
+PIPE_FORMAT_AI44                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
index bb3ed72..566fa79 100644 (file)
@@ -815,6 +815,25 @@ util_format_translate(enum pipe_format dst_format,
                       unsigned src_x, unsigned src_y,
                       unsigned width, unsigned height);
 
+/*
+ * Swizzle operations.
+ */
+
+/* Compose two sets of swizzles.
+ * If V is a 4D vector and the function parameters represent functions that
+ * swizzle vector components, this holds:
+ *     swz2(swz1(V)) = dst(V)
+ */
+void util_format_compose_swizzles(const unsigned char swz1[4],
+                                  const unsigned char swz2[4],
+                                  unsigned char dst[4]);
+
+void util_format_swizzle_4f(float *dst, const float *src,
+                            const unsigned char swz[4]);
+
+void util_format_unswizzle_4f(float *dst, const float *src,
+                              const unsigned char swz[4]);
+
 #ifdef __cplusplus
 } // extern "C" {
 #endif
index bb989c2..d8a7c0d 100644 (file)
@@ -119,8 +119,15 @@ util_format_s3tc_init(void)
 
    library = util_dl_open(DXTN_LIBNAME);
    if (!library) {
-      debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
-         "compression/decompression unavailable\n");
+      if (getenv("force_s3tc_enable") &&
+          !strcmp(getenv("force_s3tc_enable"), "true")) {
+         debug_printf("couldn't open " DXTN_LIBNAME ", enabling DXTn due to "
+            "force_s3tc_enable=true environment variable\n");
+         util_format_s3tc_enabled = TRUE;
+      } else {
+         debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
+            "compression/decompression unavailable\n");
+      }
       return;
    }
 
index ab8bf29..64ea0b3 100644 (file)
@@ -1045,3 +1045,138 @@ util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
 
    dst[3] = 1.0f;
 }
+
+/* XXX: Stubbed for now */
+void
+util_format_yv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_yv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_yv12_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_yv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_yv12_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j) {}
+void
+util_format_yv16_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_yv16_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_yv16_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_yv16_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_yv16_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j) {}
+void
+util_format_iyuv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_iyuv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_iyuv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_iyuv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_iyuv_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j) {}
+void
+util_format_nv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_nv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_nv12_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_nv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_nv12_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j) {}
+void
+util_format_nv21_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_nv21_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_nv21_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_nv21_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j) {}
+void
+util_format_ia44_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_ia44_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_ia44_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_ia44_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_ia44_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j) {}
+void
+util_format_ai44_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_ai44_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_ai44_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_ai44_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height) {}
+void
+util_format_ai44_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j) {}
index dc96323..9f2365a 100644 (file)
@@ -169,6 +169,141 @@ void
 util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src,
                              unsigned i, unsigned j);
 
+/* XXX: Stubbed for now */
+void
+util_format_yv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_yv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_yv12_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_yv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_yv12_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j);
+void
+util_format_yv16_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_yv16_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_yv16_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_yv16_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_yv16_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j);
+void
+util_format_iyuv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_iyuv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_iyuv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_iyuv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_iyuv_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j);
+void
+util_format_nv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_nv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_nv12_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_nv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_nv12_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j);
+void
+util_format_nv21_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_nv21_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_nv21_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_nv21_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j);
+void
+util_format_ia44_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_ia44_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_ia44_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_ia44_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_ia44_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j);
+void
+util_format_ai44_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_ai44_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_ai44_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+                             const uint8_t *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_ai44_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
+                             const float *src_row, unsigned src_stride,
+                             unsigned width, unsigned height);
+void
+util_format_ai44_fetch_rgba_float(float *dst, const uint8_t *src,
+                             unsigned i, unsigned j);
+
 
 void
 util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
index 5378f2d..9391f1b 100644 (file)
@@ -458,6 +458,19 @@ util_pack_mask_z(enum pipe_format format, uint32_t z)
    }
 }
 
+
+static INLINE uint64_t
+util_pack64_mask_z(enum pipe_format format, uint32_t z)
+{
+   switch (format) {
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      return z;
+   default:
+      return util_pack_mask_z(format, z);
+   }
+}
+
+
 static INLINE uint32_t
 util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s)
 {
@@ -481,6 +494,21 @@ util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s)
 }
 
 
+static INLINE uint64_t
+util_pack64_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s)
+{
+   uint64_t packed;
+
+   switch (format) {
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      packed = util_pack64_mask_z(format, z);
+      packed |= (uint64_t)s << 32ull;
+      return packed;
+   default:
+      return util_pack_mask_z_stencil(format, z, s);
+   }
+}
+
 
 /**
  * Note: it's assumed that z is in [0,1]
@@ -525,6 +553,24 @@ util_pack_z(enum pipe_format format, double z)
       return 0;
    }
 }
+
+
+static INLINE uint64_t
+util_pack64_z(enum pipe_format format, double z)
+{
+   union fi fui;
+
+   if (z == 0)
+      return 0;
+
+   switch (format) {
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      fui.f = (float)z;
+      return fui.ui;
+   default:
+      return util_pack_z(format, z);
+   }
+}
  
 
 /**
@@ -554,6 +600,24 @@ util_pack_z_stencil(enum pipe_format format, double z, uint8_t s)
 }
 
 
+static INLINE uint64_t
+util_pack64_z_stencil(enum pipe_format format, double z, uint8_t s)
+{
+   uint64_t packed;
+
+   switch (format) {
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      packed = util_pack64_z(format, z);
+      packed |= (uint64_t)s << 32ull;
+      break;
+   default:
+      return util_pack_z_stencil(format, z, s);
+   }
+
+   return packed;
+}
+
+
 /**
  * Pack 4 ubytes into a 4-byte word
  */
index f79a693..ac0df8c 100644 (file)
@@ -52,6 +52,7 @@
 
 #include "tgsi/tgsi_transform.h"
 #include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_scan.h"
 
 /** Approx number of new tokens for instructions in pstip_transform_inst() */
 #define NUM_NEW_TOKENS 50
@@ -175,6 +176,7 @@ util_pstipple_create_sampler(struct pipe_context *pipe)
  */
 struct pstip_transform_context {
    struct tgsi_transform_context base;
+   struct tgsi_shader_info info;
    uint tempsUsed;  /**< bitmask */
    int wincoordInput;
    int maxInput;
@@ -183,12 +185,13 @@ struct pstip_transform_context {
    int texTemp;  /**< temp registers */
    int numImmed;
    boolean firstInstruction;
+   uint coordOrigin;
 };
 
 
 /**
  * TGSI declaration transform callback.
- * Look for a free sampler, a free input attrib, and two free temp regs.
+ * Track samplers used, temps used, inputs used.
  */
 static void
 pstip_transform_decl(struct tgsi_transform_context *ctx,
@@ -197,10 +200,11 @@ pstip_transform_decl(struct tgsi_transform_context *ctx,
    struct pstip_transform_context *pctx =
       (struct pstip_transform_context *) ctx;
 
+   /* XXX we can use tgsi_shader_info instead of some of this */
+
    if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
       uint i;
-      for (i = decl->Range.First;
-           i <= decl->Range.Last; i++) {
+      for (i = decl->Range.First; i <= decl->Range.Last; i++) {
          pctx->samplersUsed |= 1 << i;
       }
    }
@@ -211,8 +215,7 @@ pstip_transform_decl(struct tgsi_transform_context *ctx,
    }
    else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
       uint i;
-      for (i = decl->Range.First;
-           i <= decl->Range.Last; i++) {
+      for (i = decl->Range.First; i <= decl->Range.Last; i++) {
          pctx->tempsUsed |= (1 << i);
       }
    }
@@ -243,8 +246,16 @@ free_bit(uint bitfield)
 
 /**
  * TGSI instruction transform callback.
- * Replace writes to result.color w/ a temp reg.
- * Upon END instruction, insert texture sampling code for antialiasing.
+ * Before the first instruction, insert our new code to sample the
+ * stipple texture (using the fragment coord register) then kill the
+ * fragment if the stipple texture bit is off.
+ *
+ * Insert:
+ *   declare new registers
+ *   MUL texTemp, INPUT[wincoord], 1/32;
+ *   TEX texTemp, texTemp, sampler;
+ *   KIL -texTemp;   # if -texTemp < 0, KILL fragment
+ *   [...original code...]
  */
 static void
 pstip_transform_inst(struct tgsi_transform_context *ctx,
@@ -261,7 +272,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
       uint i;
       int wincoordInput;
 
-      /* find free sampler */
+      /* find free texture sampler */
       pctx->freeSampler = free_bit(pctx->samplersUsed);
       if (pctx->freeSampler >= PIPE_MAX_SAMPLERS)
          pctx->freeSampler = PIPE_MAX_SAMPLERS - 1;
@@ -271,7 +282,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
       else
          wincoordInput = pctx->wincoordInput;
 
-      /* find one free temp reg */
+      /* find one free temp register */
       for (i = 0; i < 32; i++) {
          if ((pctx->tempsUsed & (1 << i)) == 0) {
             /* found a free temp */
@@ -397,6 +408,7 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
    struct pipe_shader_state *new_fs;
    struct pstip_transform_context transform;
    const uint newLen = tgsi_num_tokens(fs->tokens) + NUM_NEW_TOKENS;
+   unsigned i;
 
    new_fs = MALLOC(sizeof(*new_fs));
    if (!new_fs)
@@ -408,22 +420,33 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
       return NULL;
    }
 
+   /* Setup shader transformation info/context.
+    */
    memset(&transform, 0, sizeof(transform));
    transform.wincoordInput = -1;
    transform.maxInput = -1;
    transform.texTemp = -1;
    transform.firstInstruction = TRUE;
+   transform.coordOrigin = TGSI_FS_COORD_ORIGIN_UPPER_LEFT;
    transform.base.transform_instruction = pstip_transform_inst;
    transform.base.transform_declaration = pstip_transform_decl;
    transform.base.transform_immediate = pstip_transform_immed;
 
+   tgsi_scan_shader(fs->tokens, &transform.info);
+
+   /* find fragment coordinate origin property */
+   for (i = 0; i < transform.info.num_properties; i++) {
+      if (transform.info.properties[i].name == TGSI_PROPERTY_FS_COORD_ORIGIN)
+         transform.coordOrigin = transform.info.properties[i].data[0];
+   }
+
    tgsi_transform_shader(fs->tokens,
                          (struct tgsi_token *) new_fs->tokens,
                          newLen, &transform.base);
 
 #if 0 /* DEBUG */
    tgsi_dump(fs->tokens, 0);
-   tgsi_dump(pstip_fs.tokens, 0);
+   tgsi_dump(new_fs->tokens, 0);
 #endif
 
    assert(transform.freeSampler < PIPE_MAX_SAMPLERS);
index 4c5cc4d..8e12386 100644 (file)
@@ -358,8 +358,41 @@ util_clear_depth_stencil(struct pipe_context *pipe,
                dst_map += dst_stride;
             }
          }
-        break;
+         break;
       case 8:
+      {
+         uint64_t zstencil = util_pack64_z_stencil(dst->texture->format,
+                                                   depth, stencil);
+
+         assert(dst->format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED);
+
+         if (!need_rmw) {
+            for (i = 0; i < height; i++) {
+               uint64_t *row = (uint64_t *)dst_map;
+               for (j = 0; j < width; j++)
+                  *row++ = zstencil;
+               dst_map += dst_stride;
+            }
+         }
+         else {
+            uint64_t src_mask;
+
+            if (clear_flags & PIPE_CLEAR_DEPTH)
+               src_mask = 0x00000000ffffffffull;
+            else
+               src_mask = 0x000000ff00000000ull;
+
+            for (i = 0; i < height; i++) {
+               uint64_t *row = (uint64_t *)dst_map;
+               for (j = 0; j < width; j++) {
+                  uint64_t tmp = *row & ~src_mask;
+                  *row++ = tmp | (zstencil & src_mask);
+               }
+               dst_map += dst_stride;
+            }
+         }
+         break;
+      }
       default:
          assert(0);
          break;
index e3c7085..23f12e5 100644 (file)
@@ -318,6 +318,32 @@ z32f_get_tile_rgba(const float *src,
    }
 }
 
+/*** PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED ***/
+
+/**
+ * Return each Z value as four floats in [0,1].
+ */
+static void
+z32f_x24s8_get_tile_rgba(const float *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] = *src;
+         src += 2;
+      }
+      p += dst_stride;
+   }
+}
+
 
 void
 pipe_tile_raw_to_rgba(enum pipe_format format,
@@ -352,6 +378,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
    case PIPE_FORMAT_Z32_FLOAT:
       z32f_get_tile_rgba((float *) src, w, h, dst, dst_stride);
       break;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      z32f_x24s8_get_tile_rgba((float *) src, w, h, dst, dst_stride);
+      break;
    default:
       util_format_read_4f(format,
                           dst, dst_stride * sizeof(float),
@@ -445,6 +474,12 @@ pipe_put_tile_rgba_format(struct pipe_context *pipe,
    case PIPE_FORMAT_X8Z24_UNORM:
       /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
       break;
+   case PIPE_FORMAT_Z32_FLOAT:
+      /*z32f_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
+      break;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      /*z32f_s8x24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
+      break;
    default:
       util_format_write_4f(format,
                            p, src_stride * sizeof(float),
index 9562acb..71fe53e 100644 (file)
@@ -72,6 +72,22 @@ struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
    return upload;
 }
 
+void u_upload_unmap( struct u_upload_mgr *upload )
+{
+   if (upload->transfer) {
+      struct pipe_box *box = &upload->transfer->box;
+      if (upload->offset > box->x) {
+
+         pipe_buffer_flush_mapped_range(upload->pipe, upload->transfer,
+                                        box->x, upload->offset - box->x);
+      }
+      pipe_transfer_unmap(upload->pipe, upload->transfer);
+      pipe_transfer_destroy(upload->pipe, upload->transfer);
+      upload->transfer = NULL;
+      upload->map = NULL;
+   }
+}
+
 /* Release old buffer.
  * 
  * This must usually be called prior to firing the command stream
@@ -84,15 +100,7 @@ struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
 void u_upload_flush( struct u_upload_mgr *upload )
 {
    /* Unmap and unreference the upload buffer. */
-   if (upload->transfer) {
-      if (upload->offset) {
-         pipe_buffer_flush_mapped_range(upload->pipe, upload->transfer,
-                                        0, upload->offset);
-      }
-      pipe_transfer_unmap(upload->pipe, upload->transfer);
-      pipe_transfer_destroy(upload->pipe, upload->transfer);
-      upload->transfer = NULL;
-   }
+   u_upload_unmap(upload);
    pipe_resource_reference( &upload->buffer, NULL );
    upload->size = 0;
 }
@@ -172,6 +180,15 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
 
    offset = MAX2(upload->offset, alloc_offset);
 
+   if (!upload->map) {
+      upload->map = pipe_buffer_map_range(upload->pipe, upload->buffer,
+                                         offset, upload->size - offset,
+                                         PIPE_TRANSFER_WRITE |
+                                         PIPE_TRANSFER_FLUSH_EXPLICIT |
+                                         PIPE_TRANSFER_UNSYNCHRONIZED,
+                                         &upload->transfer);
+   }
+
    assert(offset < upload->buffer->width0);
    assert(offset + size <= upload->buffer->width0);
    assert(size);
@@ -223,10 +240,11 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
    struct pipe_transfer *transfer = NULL;
    const char *map = NULL;
 
-   map = (const char *)pipe_buffer_map(upload->pipe,
-                                      inbuf,
-                                      PIPE_TRANSFER_READ,
-                                      &transfer);
+   map = (const char *)pipe_buffer_map_range(upload->pipe,
+                                             inbuf,
+                                             offset, size,
+                                             PIPE_TRANSFER_READ,
+                                             &transfer);
 
    if (map == NULL) {
       ret = PIPE_ERROR_OUT_OF_MEMORY;
index c9a2ffe..9891513 100644 (file)
@@ -56,15 +56,27 @@ struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
  */
 void u_upload_destroy( struct u_upload_mgr *upload );
 
-/* Unmap and release old buffer.
+/* Unmap and release old upload buffer.
  * 
+ * This is like u_upload_unmap() except the upload buffer is released for
+ * recycling. This should be called on real hardware flushes on systems
+ * that don't support the PIPE_TRANSFER_UNSYNCHRONIZED flag, as otherwise
+ * the next u_upload_buffer will cause a sync on the buffer.
+ */
+
+void u_upload_flush( struct u_upload_mgr *upload );
+
+/**
+ * Unmap upload buffer
+ *
+ * \param upload           Upload manager
+ *
  * This must usually be called prior to firing the command stream
  * which references the upload buffer, as many memory managers either
  * don't like firing a mapped buffer or cause subsequent maps of a
- * fired buffer to wait.  For now, it's easiest just to grab a new
- * buffer.
+ * fired buffer to wait.
  */
-void u_upload_flush( struct u_upload_mgr *upload );
+void u_upload_unmap( struct u_upload_mgr *upload );
 
 /**
  * Sub-allocate new memory from the upload buffer.
index 0414952..19eb689 100644 (file)
@@ -79,6 +79,8 @@ struct u_vbuf_mgr_priv {
    void *saved_ve, *fallback_ve;
    boolean ve_binding_lock;
 
+   unsigned saved_buffer_offset[PIPE_MAX_ATTRIBS];
+
    boolean any_user_vbs;
    boolean incompatible_vb_layout;
 };
@@ -152,9 +154,9 @@ void u_vbuf_mgr_destroy(struct u_vbuf_mgr *mgrb)
 }
 
 
-static void u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
-                                   int min_index, int max_index,
-                                   boolean *upload_flushed)
+static enum u_vbuf_return_flags
+u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
+                       int min_index, int max_index)
 {
    struct translate_key key;
    struct translate_element *te;
@@ -166,6 +168,7 @@ static void u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
    struct pipe_resource *out_buffer = NULL;
    unsigned i, num_verts, out_offset;
    struct pipe_vertex_element new_velems[PIPE_MAX_ATTRIBS];
+   boolean upload_flushed = FALSE;
 
    memset(&key, 0, sizeof(key));
    memset(tr_elem_index, 0xff, sizeof(tr_elem_index));
@@ -248,7 +251,7 @@ static void u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
    u_upload_alloc(mgr->b.uploader,
                   key.output_stride * min_index,
                   key.output_stride * num_verts,
-                  &out_offset, &out_buffer, upload_flushed,
+                  &out_offset, &out_buffer, &upload_flushed,
                   (void**)&out_map);
 
    out_offset -= key.output_stride * min_index;
@@ -308,6 +311,8 @@ static void u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
    }
 
    pipe_resource_reference(&out_buffer, NULL);
+
+   return upload_flushed ? U_VBUF_UPLOAD_FLUSHED : 0;
 }
 
 static void u_vbuf_translate_end(struct u_vbuf_mgr_priv *mgr)
@@ -485,6 +490,7 @@ void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb,
 
       pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, vb->buffer);
       pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
+      mgr->saved_buffer_offset[i] = vb->buffer_offset;
 
       if (!vb->buffer) {
          continue;
@@ -510,14 +516,15 @@ void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb,
    mgr->b.nr_real_vertex_buffers = count;
 }
 
-static void u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr,
-                                  int min_index, int max_index,
-                                  unsigned instance_count,
-                                  boolean *upload_flushed)
+static enum u_vbuf_return_flags
+u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr,
+                      int min_index, int max_index,
+                      unsigned instance_count)
 {
    unsigned i, nr = mgr->ve->count;
    unsigned count = max_index + 1 - min_index;
    boolean uploaded[PIPE_MAX_ATTRIBS] = {0};
+   enum u_vbuf_return_flags retval = 0;
 
    for (i = 0; i < nr; i++) {
       unsigned index = mgr->ve->ve[i].vertex_buffer_index;
@@ -537,6 +544,11 @@ static void u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr,
          } else if (vb->stride) {
             first = vb->stride * min_index;
             size = vb->stride * count;
+
+            /* Unusual case when stride is smaller than the format size.
+             * XXX This won't work with interleaved arrays. */
+            if (mgr->ve->native_format_size[i] > vb->stride)
+               size += mgr->ve->native_format_size[i] - vb->stride;
          } else {
             first = 0;
             size = mgr->ve->native_format_size[i];
@@ -551,11 +563,14 @@ static void u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr,
          vb->buffer_offset -= first;
 
          uploaded[index] = TRUE;
-         *upload_flushed = *upload_flushed || flushed;
+         if (flushed)
+            retval |= U_VBUF_UPLOAD_FLUSHED;
       } else {
          assert(mgr->b.real_vertex_buffer[index]);
       }
    }
+
+   return retval;
 }
 
 static void u_vbuf_mgr_compute_max_index(struct u_vbuf_mgr_priv *mgr)
@@ -597,14 +612,13 @@ static void u_vbuf_mgr_compute_max_index(struct u_vbuf_mgr_priv *mgr)
    }
 }
 
-void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb,
-                           const struct pipe_draw_info *info,
-                           boolean *buffers_updated,
-                           boolean *uploader_flushed)
+enum u_vbuf_return_flags
+u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb,
+                      const struct pipe_draw_info *info)
 {
    struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
-   boolean bufs_updated = FALSE, upload_flushed = FALSE;
    int min_index, max_index;
+   enum u_vbuf_return_flags retval = 0;
 
    u_vbuf_mgr_compute_max_index(mgr);
 
@@ -617,32 +631,32 @@ void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb,
 
    /* Translate vertices with non-native layouts or formats. */
    if (mgr->incompatible_vb_layout || mgr->ve->incompatible_layout) {
-      u_vbuf_translate_begin(mgr, min_index, max_index, &upload_flushed);
+      retval |= u_vbuf_translate_begin(mgr, min_index, max_index);
 
       if (mgr->fallback_ve) {
-         bufs_updated = TRUE;
+         retval |= U_VBUF_BUFFERS_UPDATED;
       }
    }
 
    /* Upload user buffers. */
    if (mgr->any_user_vbs) {
-      u_vbuf_upload_buffers(mgr, min_index, max_index, info->instance_count,
-                            &upload_flushed);
-      bufs_updated = TRUE;
-   }
-
-   /* Set the return values. */
-   if (buffers_updated) {
-      *buffers_updated = bufs_updated;
-   }
-   if (uploader_flushed) {
-      *uploader_flushed = upload_flushed;
+      retval |= u_vbuf_upload_buffers(mgr, min_index, max_index,
+                                      info->instance_count);
+      retval |= U_VBUF_BUFFERS_UPDATED;
    }
+   return retval;
 }
 
 void u_vbuf_mgr_draw_end(struct u_vbuf_mgr *mgrb)
 {
    struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
+   unsigned i;
+
+   /* buffer offsets were modified in u_vbuf_upload_buffers */
+   if (mgr->any_user_vbs) {
+      for (i = 0; i < mgr->b.nr_vertex_buffers; i++)
+         mgr->b.vertex_buffer[i].buffer_offset = mgr->saved_buffer_offset[i];
+   }
 
    if (mgr->fallback_ve) {
       u_vbuf_translate_end(mgr);
index 9380dce..4e63724 100644 (file)
@@ -78,6 +78,11 @@ enum u_fetch_alignment {
    U_VERTEX_FETCH_DWORD_ALIGNED
 };
 
+enum u_vbuf_return_flags {
+   U_VBUF_BUFFERS_UPDATED = 1,
+   U_VBUF_UPLOAD_FLUSHED = 2
+};
+
 
 struct u_vbuf_mgr *
 u_vbuf_mgr_create(struct pipe_context *pipe,
@@ -105,10 +110,9 @@ void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgr,
                                    unsigned count,
                                    const struct pipe_vertex_buffer *bufs);
 
-void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgr,
-                           const struct pipe_draw_info *info,
-                           boolean *buffers_updated,
-                           boolean *uploader_flushed);
+enum u_vbuf_return_flags
+u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgr,
+                      const struct pipe_draw_info *info);
 
 void u_vbuf_mgr_draw_end(struct u_vbuf_mgr *mgr);
 
diff --git a/src/gallium/auxiliary/util/u_video.h b/src/gallium/auxiliary/util/u_video.h
new file mode 100644 (file)
index 0000000..6b67881
--- /dev/null
@@ -0,0 +1,76 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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_VIDEO_H
+#define U_VIDEO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <pipe/p_defines.h>
+#include <pipe/p_video_enums.h>
+
+/* u_reduce_video_profile() needs these */
+#include <pipe/p_compiler.h>
+#include <util/u_debug.h>
+
+static INLINE enum pipe_video_codec
+u_reduce_video_profile(enum pipe_video_profile profile)
+{
+   switch (profile)
+   {
+      case PIPE_VIDEO_PROFILE_MPEG1:
+      case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
+      case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
+         return PIPE_VIDEO_CODEC_MPEG12;
+
+      case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
+      case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
+         return PIPE_VIDEO_CODEC_MPEG4;
+
+      case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
+      case PIPE_VIDEO_PROFILE_VC1_MAIN:
+      case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
+         return PIPE_VIDEO_CODEC_VC1;
+
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
+         return PIPE_VIDEO_CODEC_MPEG4_AVC;
+
+      default:
+         assert(0);
+         return PIPE_VIDEO_CODEC_UNKNOWN;
+   }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_VIDEO_H */
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
new file mode 100644 (file)
index 0000000..faca96d
--- /dev/null
@@ -0,0 +1,765 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <pipe/p_compiler.h>
+#include <pipe/p_context.h>
+
+#include <util/u_memory.h>
+#include <util/u_draw.h>
+#include <util/u_surface.h>
+
+#include <tgsi/tgsi_ureg.h>
+
+#include "vl_csc.h"
+#include "vl_types.h"
+#include "vl_compositor.h"
+
+typedef float csc_matrix[16];
+
+static void *
+create_vert_shader(struct vl_compositor *c)
+{
+   struct ureg_program *shader;
+   struct ureg_src vpos, vtex;
+   struct ureg_dst o_vpos, o_vtex;
+
+   shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+   if (!shader)
+      return false;
+
+   vpos = ureg_DECL_vs_input(shader, 0);
+   vtex = ureg_DECL_vs_input(shader, 1);
+   o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, 0);
+   o_vtex = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, 1);
+
+   /*
+    * o_vpos = vpos
+    * o_vtex = vtex
+    */
+   ureg_MOV(shader, o_vpos, vpos);
+   ureg_MOV(shader, o_vtex, vtex);
+
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, c->pipe);
+}
+
+static void *
+create_frag_shader_video_buffer(struct vl_compositor *c)
+{
+   struct ureg_program *shader;
+   struct ureg_src tc;
+   struct ureg_src csc[3];
+   struct ureg_src sampler[3];
+   struct ureg_dst texel;
+   struct ureg_dst fragment;
+   unsigned i;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return false;
+
+   tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, 1, TGSI_INTERPOLATE_LINEAR);
+   for (i = 0; i < 3; ++i) {
+      csc[i] = ureg_DECL_constant(shader, i);
+      sampler[i] = ureg_DECL_sampler(shader, i);
+   }
+   texel = ureg_DECL_temporary(shader);
+   fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+   /*
+    * texel.xyz = tex(tc, sampler[i])
+    * fragment = csc * texel
+    */
+   for (i = 0; i < 3; ++i)
+      ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_2D, tc, sampler[i]);
+
+   ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
+
+   for (i = 0; i < 3; ++i)
+      ureg_DP4(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X << i), csc[i], ureg_src(texel));
+
+   ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
+
+   ureg_release_temporary(shader, texel);
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, c->pipe);
+}
+
+static void *
+create_frag_shader_palette(struct vl_compositor *c)
+{
+   struct ureg_program *shader;
+   struct ureg_src csc[3];
+   struct ureg_src tc;
+   struct ureg_src sampler;
+   struct ureg_src palette;
+   struct ureg_dst texel;
+   struct ureg_dst fragment;
+   unsigned i;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return false;
+
+   for (i = 0; i < 3; ++i)
+      csc[i] = ureg_DECL_constant(shader, i);
+
+   tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, 1, TGSI_INTERPOLATE_LINEAR);
+   sampler = ureg_DECL_sampler(shader, 0);
+   palette = ureg_DECL_sampler(shader, 1);
+   texel = ureg_DECL_temporary(shader);
+   fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+   /*
+    * texel = tex(tc, sampler)
+    * fragment.xyz = tex(texel, palette) * csc
+    * fragment.a = texel.a
+    */
+   ureg_TEX(shader, texel, TGSI_TEXTURE_2D, tc, sampler);
+   ureg_MUL(shader, ureg_writemask(texel, TGSI_WRITEMASK_X), ureg_src(texel), ureg_imm1f(shader, 15.0f / 16.0f));
+   ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), ureg_src(texel));
+
+   ureg_TEX(shader, texel, TGSI_TEXTURE_1D, ureg_src(texel), palette);
+
+   for (i = 0; i < 3; ++i)
+      ureg_DP4(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X << i), csc[i], ureg_src(texel));
+
+   ureg_release_temporary(shader, texel);
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, c->pipe);
+}
+
+static void *
+create_frag_shader_rgba(struct vl_compositor *c)
+{
+   struct ureg_program *shader;
+   struct ureg_src tc;
+   struct ureg_src sampler;
+   struct ureg_dst fragment;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return false;
+
+   tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, 1, TGSI_INTERPOLATE_LINEAR);
+   sampler = ureg_DECL_sampler(shader, 0);
+   fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+   /*
+    * fragment = tex(tc, sampler)
+    */
+   ureg_TEX(shader, fragment, TGSI_TEXTURE_2D, tc, sampler);
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, c->pipe);
+}
+
+static bool
+init_shaders(struct vl_compositor *c)
+{
+   assert(c);
+
+   c->vs = create_vert_shader(c);
+   if (!c->vs) {
+      debug_printf("Unable to create vertex shader.\n");
+      return false;
+   }
+
+   c->fs_video_buffer = create_frag_shader_video_buffer(c);
+   if (!c->fs_video_buffer) {
+      debug_printf("Unable to create YCbCr-to-RGB fragment shader.\n");
+      return false;
+   }
+
+   c->fs_palette = create_frag_shader_palette(c);
+   if (!c->fs_palette) {
+      debug_printf("Unable to create Palette-to-RGB fragment shader.\n");
+      return false;
+   }
+
+   c->fs_rgba = create_frag_shader_rgba(c);
+   if (!c->fs_rgba) {
+      debug_printf("Unable to create RGB-to-RGB fragment shader.\n");
+      return false;
+   }
+
+   return true;
+}
+
+static void cleanup_shaders(struct vl_compositor *c)
+{
+   assert(c);
+
+   c->pipe->delete_vs_state(c->pipe, c->vs);
+   c->pipe->delete_fs_state(c->pipe, c->fs_video_buffer);
+   c->pipe->delete_fs_state(c->pipe, c->fs_palette);
+   c->pipe->delete_fs_state(c->pipe, c->fs_rgba);
+}
+
+static bool
+init_pipe_state(struct vl_compositor *c)
+{
+   struct pipe_rasterizer_state rast;
+   struct pipe_sampler_state sampler;
+   struct pipe_blend_state blend;
+   struct pipe_depth_stencil_alpha_state dsa;
+   unsigned i;
+
+   assert(c);
+
+   c->fb_state.nr_cbufs = 1;
+   c->fb_state.zsbuf = NULL;
+
+   c->viewport.scale[2] = 1;
+   c->viewport.scale[3] = 1;
+   c->viewport.translate[2] = 0;
+   c->viewport.translate[3] = 0;
+
+   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_img_filter = PIPE_TEX_FILTER_LINEAR;
+   sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+   sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
+   sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
+   sampler.compare_func = PIPE_FUNC_ALWAYS;
+   sampler.normalized_coords = 1;
+
+   c->sampler_linear = c->pipe->create_sampler_state(c->pipe, &sampler);
+
+   sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
+   sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
+   c->sampler_nearest = c->pipe->create_sampler_state(c->pipe, &sampler);
+
+   memset(&blend, 0, sizeof blend);
+   blend.independent_blend_enable = 0;
+   blend.rt[0].blend_enable = 1;
+   blend.rt[0].rgb_func = PIPE_BLEND_ADD;
+   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA;
+   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
+   blend.rt[0].alpha_func = PIPE_BLEND_ADD;
+   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.logicop_enable = 0;
+   blend.logicop_func = PIPE_LOGICOP_CLEAR;
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
+   blend.dither = 0;
+   c->blend = c->pipe->create_blend_state(c->pipe, &blend);
+
+   memset(&rast, 0, sizeof rast);
+   rast.flatshade = 1;
+   rast.front_ccw = 1;
+   rast.cull_face = PIPE_FACE_NONE;
+   rast.fill_back = PIPE_POLYGON_MODE_FILL;
+   rast.fill_front = PIPE_POLYGON_MODE_FILL;
+   rast.scissor = 1;
+   rast.line_width = 1;
+   rast.point_size_per_vertex = 1;
+   rast.offset_units = 1;
+   rast.offset_scale = 1;
+   rast.gl_rasterization_rules = 1;
+
+   c->rast = c->pipe->create_rasterizer_state(c->pipe, &rast);
+
+   memset(&dsa, 0, sizeof dsa);
+   dsa.depth.enabled = 0;
+   dsa.depth.writemask = 0;
+   dsa.depth.func = PIPE_FUNC_ALWAYS;
+   for (i = 0; i < 2; ++i) {
+      dsa.stencil[i].enabled = 0;
+      dsa.stencil[i].func = PIPE_FUNC_ALWAYS;
+      dsa.stencil[i].fail_op = PIPE_STENCIL_OP_KEEP;
+      dsa.stencil[i].zpass_op = PIPE_STENCIL_OP_KEEP;
+      dsa.stencil[i].zfail_op = PIPE_STENCIL_OP_KEEP;
+      dsa.stencil[i].valuemask = 0;
+      dsa.stencil[i].writemask = 0;
+   }
+   dsa.alpha.enabled = 0;
+   dsa.alpha.func = PIPE_FUNC_ALWAYS;
+   dsa.alpha.ref_value = 0;
+   c->dsa = c->pipe->create_depth_stencil_alpha_state(c->pipe, &dsa);
+   c->pipe->bind_depth_stencil_alpha_state(c->pipe, c->dsa);
+   return true;
+}
+
+static void cleanup_pipe_state(struct vl_compositor *c)
+{
+   assert(c);
+
+   /* Asserted in softpipe_delete_fs_state() for some reason */
+   c->pipe->bind_vs_state(c->pipe, NULL);
+   c->pipe->bind_fs_state(c->pipe, NULL);
+
+   c->pipe->delete_depth_stencil_alpha_state(c->pipe, c->dsa);
+   c->pipe->delete_sampler_state(c->pipe, c->sampler_linear);
+   c->pipe->delete_sampler_state(c->pipe, c->sampler_nearest);
+   c->pipe->delete_blend_state(c->pipe, c->blend);
+   c->pipe->delete_rasterizer_state(c->pipe, c->rast);
+}
+
+static bool
+create_vertex_buffer(struct vl_compositor *c)
+{
+   assert(c);
+
+   pipe_resource_reference(&c->vertex_buf.buffer, NULL);
+   c->vertex_buf.buffer = pipe_buffer_create
+   (
+      c->pipe->screen,
+      PIPE_BIND_VERTEX_BUFFER,
+      PIPE_USAGE_STREAM,
+      sizeof(struct vertex4f) * VL_COMPOSITOR_MAX_LAYERS * 4
+   );
+   return c->vertex_buf.buffer != NULL;
+}
+
+static bool
+init_buffers(struct vl_compositor *c)
+{
+   struct pipe_vertex_element vertex_elems[2];
+
+   assert(c);
+
+   /*
+    * Create our vertex buffer and vertex buffer elements
+    */
+   c->vertex_buf.stride = sizeof(struct vertex4f);
+   c->vertex_buf.buffer_offset = 0;
+   create_vertex_buffer(c);
+
+   vertex_elems[0].src_offset = 0;
+   vertex_elems[0].instance_divisor = 0;
+   vertex_elems[0].vertex_buffer_index = 0;
+   vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
+   vertex_elems[1].src_offset = sizeof(struct vertex2f);
+   vertex_elems[1].instance_divisor = 0;
+   vertex_elems[1].vertex_buffer_index = 0;
+   vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
+   c->vertex_elems_state = c->pipe->create_vertex_elements_state(c->pipe, 2, vertex_elems);
+
+   /*
+    * Create our fragment shader's constant buffer
+    * Const buffer contains the color conversion matrix and bias vectors
+    */
+   /* XXX: Create with IMMUTABLE/STATIC... although it does change every once in a long while... */
+   c->csc_matrix = pipe_buffer_create
+   (
+      c->pipe->screen,
+      PIPE_BIND_CONSTANT_BUFFER,
+      PIPE_USAGE_STATIC,
+      sizeof(csc_matrix)
+   );
+
+   return true;
+}
+
+static void
+cleanup_buffers(struct vl_compositor *c)
+{
+   assert(c);
+
+   c->pipe->delete_vertex_elements_state(c->pipe, c->vertex_elems_state);
+   pipe_resource_reference(&c->vertex_buf.buffer, NULL);
+   pipe_resource_reference(&c->csc_matrix, NULL);
+}
+
+static INLINE struct pipe_video_rect
+default_rect(struct vl_compositor_layer *layer)
+{
+   struct pipe_resource *res = layer->sampler_views[0]->texture;
+   struct pipe_video_rect rect = { 0, 0, res->width0, res->height0 };
+   return rect;
+}
+
+static INLINE struct vertex2f
+calc_topleft(struct vertex2f size, struct pipe_video_rect rect)
+{
+   struct vertex2f res = { rect.x / size.x, rect.y / size.y };
+   return res;
+}
+
+static INLINE struct vertex2f
+calc_bottomright(struct vertex2f size, struct pipe_video_rect rect)
+{
+   struct vertex2f res = { (rect.x + rect.w) / size.x, (rect.y + rect.h) / size.y };
+   return res;
+}
+
+static INLINE void
+calc_src_and_dst(struct vl_compositor_layer *layer, unsigned width, unsigned height,
+                 struct pipe_video_rect src, struct pipe_video_rect dst)
+{
+   struct vertex2f size =  { width, height };
+
+   layer->src.tl = calc_topleft(size, src);
+   layer->src.br = calc_bottomright(size, src);
+   layer->dst.tl = calc_topleft(size, dst);
+   layer->dst.br = calc_bottomright(size, dst);
+}
+
+static void
+gen_rect_verts(struct vertex4f *vb, struct vl_compositor_layer *layer)
+{
+   assert(vb && layer);
+
+   vb[0].x = layer->dst.tl.x;
+   vb[0].y = layer->dst.tl.y;
+   vb[0].z = layer->src.tl.x;
+   vb[0].w = layer->src.tl.y;
+
+   vb[1].x = layer->dst.br.x;
+   vb[1].y = layer->dst.tl.y;
+   vb[1].z = layer->src.br.x;
+   vb[1].w = layer->src.tl.y;
+
+   vb[2].x = layer->dst.br.x;
+   vb[2].y = layer->dst.br.y;
+   vb[2].z = layer->src.br.x;
+   vb[2].w = layer->src.br.y;
+
+   vb[3].x = layer->dst.tl.x;
+   vb[3].y = layer->dst.br.y;
+   vb[3].z = layer->src.tl.x;
+   vb[3].w = layer->src.br.y;
+}
+
+static void
+gen_vertex_data(struct vl_compositor *c)
+{
+   struct vertex4f *vb;
+   struct pipe_transfer *buf_transfer;
+   unsigned i;
+
+   assert(c);
+
+   vb = pipe_buffer_map(c->pipe, c->vertex_buf.buffer,
+                        PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD | PIPE_TRANSFER_DONTBLOCK,
+                        &buf_transfer);
+
+   if (!vb) {
+      // If buffer is still locked from last draw create a new one
+      create_vertex_buffer(c);
+      vb = pipe_buffer_map(c->pipe, c->vertex_buf.buffer,
+                           PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+                           &buf_transfer);
+   }
+
+   for (i = 0; i < VL_COMPOSITOR_MAX_LAYERS; i++) {
+      if (c->used_layers & (1 << i)) {
+         struct vl_compositor_layer *layer = &c->layers[i];
+         gen_rect_verts(vb, layer);
+         vb += 4;
+
+         if (layer->clearing &&
+             c->dirty_tl.x >= layer->dst.tl.x &&
+             c->dirty_tl.y >= layer->dst.tl.y &&
+             c->dirty_br.x <= layer->dst.br.x &&
+             c->dirty_br.y <= layer->dst.br.y) {
+
+            // We clear the dirty area anyway, no need for clear_render_target
+            c->dirty_tl.x = c->dirty_tl.y = 1.0f;
+            c->dirty_br.x = c->dirty_br.y = 0.0f;
+         }
+      }
+   }
+
+   pipe_buffer_unmap(c->pipe, buf_transfer);
+}
+
+static void
+draw_layers(struct vl_compositor *c)
+{
+   unsigned vb_index, i;
+
+   assert(c);
+
+   for (i = 0, vb_index = 0; i < VL_COMPOSITOR_MAX_LAYERS; ++i) {
+      if (c->used_layers & (1 << i)) {
+         struct vl_compositor_layer *layer = &c->layers[i];
+         struct pipe_sampler_view **samplers = &layer->sampler_views[0];
+         unsigned num_sampler_views = !samplers[1] ? 1 : !samplers[2] ? 2 : 3;
+
+         c->pipe->bind_fs_state(c->pipe, layer->fs);
+         c->pipe->bind_fragment_sampler_states(c->pipe, num_sampler_views, layer->samplers);
+         c->pipe->set_fragment_sampler_views(c->pipe, num_sampler_views, samplers);
+         util_draw_arrays(c->pipe, PIPE_PRIM_QUADS, vb_index * 4, 4);
+         vb_index++;
+
+         // Remember the currently drawn area as dirty for the next draw command
+         c->dirty_tl.x = MIN2(layer->dst.tl.x, c->dirty_tl.x);
+         c->dirty_tl.y = MIN2(layer->dst.tl.y, c->dirty_tl.y);
+         c->dirty_br.x = MAX2(layer->dst.br.x, c->dirty_br.x);
+         c->dirty_br.y = MAX2(layer->dst.br.y, c->dirty_br.y);
+      }
+   }
+}
+
+void
+vl_compositor_reset_dirty_area(struct vl_compositor *c)
+{
+   assert(c);
+
+   c->dirty_tl.x = c->dirty_tl.y = 0.0f;
+   c->dirty_br.x = c->dirty_br.y = 1.0f;
+}
+
+void
+vl_compositor_set_clear_color(struct vl_compositor *c, float color[4])
+{
+   unsigned i;
+
+   assert(c);
+
+   for (i = 0; i < 4; ++i)
+      c->clear_color[i] = color[i];
+}
+
+void
+vl_compositor_clear_layers(struct vl_compositor *c)
+{
+   unsigned i, j;
+
+   assert(c);
+
+   c->used_layers = 0;
+   for ( i = 0; i < VL_COMPOSITOR_MAX_LAYERS; ++i) {
+      c->layers[i].fs = NULL;
+      for ( j = 0; j < 3; j++)
+         pipe_sampler_view_reference(&c->layers[i].sampler_views[j], NULL);
+   }
+}
+
+void
+vl_compositor_cleanup(struct vl_compositor *c)
+{
+   assert(c);
+
+   vl_compositor_clear_layers(c);
+
+   cleanup_buffers(c);
+   cleanup_shaders(c);
+   cleanup_pipe_state(c);
+}
+
+void
+vl_compositor_set_csc_matrix(struct vl_compositor *c, const float matrix[16])
+{
+   struct pipe_transfer *buf_transfer;
+
+   assert(c);
+
+   memcpy
+   (
+      pipe_buffer_map(c->pipe, c->csc_matrix,
+                      PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+                      &buf_transfer),
+               matrix,
+               sizeof(csc_matrix)
+   );
+
+   pipe_buffer_unmap(c->pipe, buf_transfer);
+}
+
+void
+vl_compositor_set_buffer_layer(struct vl_compositor *c,
+                               unsigned layer,
+                               struct pipe_video_buffer *buffer,
+                               struct pipe_video_rect *src_rect,
+                               struct pipe_video_rect *dst_rect)
+{
+   struct pipe_sampler_view **sampler_views;
+   unsigned i;
+
+   assert(c && buffer);
+
+   assert(layer < VL_COMPOSITOR_MAX_LAYERS);
+
+   c->used_layers |= 1 << layer;
+   c->layers[layer].clearing = true;
+   c->layers[layer].fs = c->fs_video_buffer;
+
+   sampler_views = buffer->get_sampler_view_components(buffer);
+   for (i = 0; i < 3; ++i) {
+      c->layers[layer].samplers[i] = c->sampler_linear;
+      pipe_sampler_view_reference(&c->layers[layer].sampler_views[i], sampler_views[i]);
+   }
+
+   calc_src_and_dst(&c->layers[layer], buffer->width, buffer->height,
+                    src_rect ? *src_rect : default_rect(&c->layers[layer]),
+                    dst_rect ? *dst_rect : default_rect(&c->layers[layer]));
+}
+
+void
+vl_compositor_set_palette_layer(struct vl_compositor *c,
+                                unsigned layer,
+                                struct pipe_sampler_view *indexes,
+                                struct pipe_sampler_view *palette,
+                                struct pipe_video_rect *src_rect,
+                                struct pipe_video_rect *dst_rect)
+{
+   assert(c && indexes && palette);
+
+   assert(layer < VL_COMPOSITOR_MAX_LAYERS);
+
+   c->used_layers |= 1 << layer;
+   c->layers[layer].clearing = false;
+   c->layers[layer].fs = c->fs_palette;
+   c->layers[layer].samplers[0] = c->sampler_linear;
+   c->layers[layer].samplers[1] = c->sampler_nearest;
+   c->layers[layer].samplers[2] = NULL;
+   pipe_sampler_view_reference(&c->layers[layer].sampler_views[0], indexes);
+   pipe_sampler_view_reference(&c->layers[layer].sampler_views[1], palette);
+   pipe_sampler_view_reference(&c->layers[layer].sampler_views[2], NULL);
+   calc_src_and_dst(&c->layers[layer], indexes->texture->width0, indexes->texture->height0,
+                    src_rect ? *src_rect : default_rect(&c->layers[layer]),
+                    dst_rect ? *dst_rect : default_rect(&c->layers[layer]));
+
+}
+
+void
+vl_compositor_set_rgba_layer(struct vl_compositor *c,
+                             unsigned layer,
+                             struct pipe_sampler_view *rgba,
+                             struct pipe_video_rect *src_rect,
+                             struct pipe_video_rect *dst_rect)
+{
+   assert(c && rgba);
+
+   assert(layer < VL_COMPOSITOR_MAX_LAYERS);
+
+   c->used_layers |= 1 << layer;
+   c->layers[layer].clearing = rgba->swizzle_a == PIPE_SWIZZLE_ONE;
+   c->layers[layer].fs = c->fs_rgba;
+   c->layers[layer].samplers[0] = c->sampler_linear;
+   c->layers[layer].samplers[1] = NULL;
+   c->layers[layer].samplers[2] = NULL;
+   pipe_sampler_view_reference(&c->layers[layer].sampler_views[0], rgba);
+   pipe_sampler_view_reference(&c->layers[layer].sampler_views[1], NULL);
+   pipe_sampler_view_reference(&c->layers[layer].sampler_views[2], NULL);
+   calc_src_and_dst(&c->layers[layer], rgba->texture->width0, rgba->texture->height0,
+                    src_rect ? *src_rect : default_rect(&c->layers[layer]),
+                    dst_rect ? *dst_rect : default_rect(&c->layers[layer]));
+}
+
+void
+vl_compositor_render(struct vl_compositor *c,
+                     enum pipe_mpeg12_picture_type picture_type,
+                     struct pipe_surface           *dst_surface,
+                     struct pipe_video_rect        *dst_area,
+                     struct pipe_video_rect        *dst_clip)
+{
+   struct pipe_scissor_state scissor;
+
+   assert(c);
+   assert(dst_surface);
+
+   c->fb_state.width = dst_surface->width;
+   c->fb_state.height = dst_surface->height;
+   c->fb_state.cbufs[0] = dst_surface;
+   
+   if (dst_area) {
+      c->viewport.scale[0] = dst_area->w;
+      c->viewport.scale[1] = dst_area->h;
+      c->viewport.translate[0] = dst_area->x;
+      c->viewport.translate[1] = dst_area->y;
+   } else {
+      c->viewport.scale[0] = dst_surface->width;
+      c->viewport.scale[1] = dst_surface->height;
+      c->viewport.translate[0] = 0;
+      c->viewport.translate[1] = 0;
+   }
+
+   if (dst_clip) {
+      scissor.minx = dst_clip->x;
+      scissor.miny = dst_clip->y;
+      scissor.maxx = dst_clip->x + dst_clip->w;
+      scissor.maxy = dst_clip->y + dst_clip->h;
+   } else {
+      scissor.minx = 0;
+      scissor.miny = 0;
+      scissor.maxx = dst_surface->width;
+      scissor.maxy = dst_surface->height;
+   }
+
+   gen_vertex_data(c);
+
+   if (c->dirty_tl.x < c->dirty_br.x || c->dirty_tl.y < c->dirty_br.y) {
+      util_clear_render_target(c->pipe, dst_surface, c->clear_color, 0, 0, dst_surface->width, dst_surface->height);
+      c->dirty_tl.x = c->dirty_tl.y = 1.0f;
+      c->dirty_br.x = c->dirty_br.y = 0.0f;
+   }
+
+   c->pipe->set_scissor_state(c->pipe, &scissor);
+   c->pipe->set_framebuffer_state(c->pipe, &c->fb_state);
+   c->pipe->set_viewport_state(c->pipe, &c->viewport);
+   c->pipe->bind_vs_state(c->pipe, c->vs);
+   c->pipe->set_vertex_buffers(c->pipe, 1, &c->vertex_buf);
+   c->pipe->bind_vertex_elements_state(c->pipe, c->vertex_elems_state);
+   c->pipe->set_constant_buffer(c->pipe, PIPE_SHADER_FRAGMENT, 0, c->csc_matrix);
+   c->pipe->bind_blend_state(c->pipe, c->blend);
+   c->pipe->bind_rasterizer_state(c->pipe, c->rast);
+
+   draw_layers(c);
+}
+
+bool
+vl_compositor_init(struct vl_compositor *c, struct pipe_context *pipe)
+{
+   csc_matrix csc_matrix;
+
+   c->pipe = pipe;
+
+   if (!init_pipe_state(c))
+      return false;
+
+   if (!init_shaders(c)) {
+      cleanup_pipe_state(c);
+      return false;
+   }
+   if (!init_buffers(c)) {
+      cleanup_shaders(c);
+      cleanup_pipe_state(c);
+      return false;
+   }
+
+   vl_compositor_clear_layers(c);
+
+   vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, csc_matrix);
+   vl_compositor_set_csc_matrix(c, csc_matrix);
+
+   c->clear_color[0] = c->clear_color[1] = 0.0f;
+   c->clear_color[2] = c->clear_color[3] = 0.0f;
+   vl_compositor_reset_dirty_area(c);
+
+   return true;
+}
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
new file mode 100644 (file)
index 0000000..0a9a741
--- /dev/null
@@ -0,0 +1,170 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_compositor_h
+#define vl_compositor_h
+
+#include <pipe/p_state.h>
+#include <pipe/p_video_decoder.h>
+#include <pipe/p_video_state.h>
+
+#include "vl_types.h"
+
+struct pipe_context;
+
+/**
+ * composing and displaying of image data
+ */
+
+#define VL_COMPOSITOR_MAX_LAYERS 16
+
+struct vl_compositor_layer
+{
+   bool clearing;
+
+   void *fs;
+   void *samplers[3];
+
+   struct pipe_sampler_view *sampler_views[3];
+   struct {
+      struct vertex2f tl, br;
+   } src, dst;
+};
+
+struct vl_compositor
+{
+   struct pipe_context *pipe;
+
+   struct pipe_framebuffer_state fb_state;
+   struct pipe_viewport_state viewport;
+   struct pipe_vertex_buffer vertex_buf;
+   struct pipe_resource *csc_matrix;
+
+   void *sampler_linear;
+   void *sampler_nearest;
+   void *blend;
+   void *rast;
+   void *dsa;
+   void *vertex_elems_state;
+
+   void *vs;
+   void *fs_video_buffer;
+   void *fs_palette;
+   void *fs_rgba;
+
+   float clear_color[4];
+   struct vertex2f dirty_tl, dirty_br;
+
+   unsigned used_layers:VL_COMPOSITOR_MAX_LAYERS;
+   struct vl_compositor_layer layers[VL_COMPOSITOR_MAX_LAYERS];
+};
+
+/**
+ * initialize this compositor
+ */
+bool
+vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);
+
+/**
+ * set yuv -> rgba conversion matrix
+ */
+void
+vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float mat[16]);
+
+/**
+ * reset dirty area, so it's cleared with the clear colour
+ */
+void
+vl_compositor_reset_dirty_area(struct vl_compositor *compositor);
+
+/**
+ * set the clear color
+ */
+void
+vl_compositor_set_clear_color(struct vl_compositor *compositor, float color[4]);
+
+/**
+ * set overlay samplers
+ */
+/*@{*/
+
+/**
+ * reset all currently set layers
+ */
+void
+vl_compositor_clear_layers(struct vl_compositor *compositor);
+
+/**
+ * set a video buffer as a layer to render
+ */
+void
+vl_compositor_set_buffer_layer(struct vl_compositor *compositor,
+                               unsigned layer,
+                               struct pipe_video_buffer *buffer,
+                               struct pipe_video_rect *src_rect,
+                               struct pipe_video_rect *dst_rect);
+
+/**
+ * set a paletted sampler as a layer to render
+ */
+void
+vl_compositor_set_palette_layer(struct vl_compositor *compositor,
+                                unsigned layer,
+                                struct pipe_sampler_view *indexes,
+                                struct pipe_sampler_view *palette,
+                                struct pipe_video_rect *src_rect,
+                                struct pipe_video_rect *dst_rect);
+
+/**
+ * set a rgba sampler as a layer to render
+ */
+void
+vl_compositor_set_rgba_layer(struct vl_compositor *compositor,
+                             unsigned layer,
+                             struct pipe_sampler_view *rgba,
+                             struct pipe_video_rect *src_rect,
+                             struct pipe_video_rect *dst_rect);
+
+/*@}*/
+
+/**
+ * render the layers to the frontbuffer
+ */
+void
+vl_compositor_render(struct vl_compositor          *compositor,
+                     enum pipe_mpeg12_picture_type picture_type,
+                     struct pipe_surface           *dst_surface,
+                     struct pipe_video_rect        *dst_area,
+                     struct pipe_video_rect        *dst_clip);
+
+/**
+* destroy this compositor
+*/
+void
+vl_compositor_cleanup(struct vl_compositor *compositor);
+
+#endif /* vl_compositor_h */
diff --git a/src/gallium/auxiliary/vl/vl_csc.c b/src/gallium/auxiliary/vl/vl_csc.c
new file mode 100644 (file)
index 0000000..4ca84e5
--- /dev/null
@@ -0,0 +1,217 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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_math.h>
+#include <util/u_debug.h>
+
+#include "vl_csc.h"
+
+/*
+ * Color space conversion formulas
+ *
+ * To convert YCbCr to RGB,
+ *    vec4  ycbcr, rgb
+ *    mat44 csc
+ *    rgb = csc * ycbcr
+ *
+ * To calculate the color space conversion matrix csc with ProcAmp adjustments,
+ *    mat44 csc, cstd, procamp, bias
+ *    csc = cstd * (procamp * bias)
+ *
+ * Where cstd is a matrix corresponding to one of the color standards (BT.601, BT.709, etc)
+ * adjusted for the kind of YCbCr -> RGB mapping wanted (1:1, full),
+ * bias is a matrix corresponding to the kind of YCbCr -> RGB mapping wanted (1:1, full)
+ *
+ * To calculate procamp,
+ *    mat44 procamp, hue, saturation, brightness, contrast
+ *    procamp = brightness * (saturation * (contrast * hue))
+ * Alternatively,
+ *    procamp = saturation * (brightness * (contrast * hue))
+ *
+ * contrast
+ * [ c, 0, 0, 0]
+ * [ 0, c, 0, 0]
+ * [ 0, 0, c, 0]
+ * [ 0, 0, 0, 1]
+ *
+ * brightness
+ * [ 1, 0, 0, b]
+ * [ 0, 1, 0, 0]
+ * [ 0, 0, 1, 0]
+ * [ 0, 0, 0, 1]
+ *
+ * saturation
+ * [ 1, 0, 0, 0]
+ * [ 0, s, 0, 0]
+ * [ 0, 0, s, 0]
+ * [ 0, 0, 0, 1]
+ *
+ * hue
+ * [ 1,       0,      0, 0]
+ * [ 0,  cos(h), sin(h), 0]
+ * [ 0, -sin(h), cos(h), 0]
+ * [ 0,       0,      0, 1]
+ *
+ * procamp
+ * [ c,           0,          0, b]
+ * [ 0,  c*s*cos(h), c*s*sin(h), 0]
+ * [ 0, -c*s*sin(h), c*s*cos(h), 0]
+ * [ 0,           0,          0, 1]
+ *
+ * bias
+ * [ 1, 0, 0,  ybias]
+ * [ 0, 1, 0, cbbias]
+ * [ 0, 0, 1, crbias]
+ * [ 0, 0, 0,      1]
+ *
+ * csc
+ * [ c*cstd[ 0], c*cstd[ 1]*s*cos(h) - c*cstd[ 2]*s*sin(h), c*cstd[ 2]*s*cos(h) + c*cstd[ 1]*s*sin(h), cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 2]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
+ * [ c*cstd[ 4], c*cstd[ 5]*s*cos(h) - c*cstd[ 6]*s*sin(h), c*cstd[ 6]*s*cos(h) + c*cstd[ 5]*s*sin(h), cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 6]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
+ * [ c*cstd[ 8], c*cstd[ 9]*s*cos(h) - c*cstd[10]*s*sin(h), c*cstd[10]*s*cos(h) + c*cstd[ 9]*s*sin(h), cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[10]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
+ * [ c*cstd[12], c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h), c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h), cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
+ */
+
+/*
+ * Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
+ * Y is in [16,235], Cb and Cr are in [16,240]
+ * R, G, and B are in [16,235]
+ */
+static const float bt_601[16] =
+{
+   1.0f,  0.0f,    1.371f, 0.0f,
+   1.0f, -0.336f, -0.698f, 0.0f,
+   1.0f,  1.732f,  0.0f,   0.0f,
+   0.0f,  0.0f,    0.0f,   1.0f
+};
+
+/*
+ * Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
+ * Y is in [16,235], Cb and Cr are in [16,240]
+ * R, G, and B are in [0,255]
+ */
+static const float bt_601_full[16] =
+{
+   1.164f,  0.0f,    1.596f, 0.0f,
+   1.164f, -0.391f, -0.813f, 0.0f,
+   1.164f,  2.018f,  0.0f,   0.0f,
+   0.0f,    0.0f,    0.0f,   1.0f
+};
+
+/*
+ * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
+ * Y is in [16,235], Cb and Cr are in [16,240]
+ * R, G, and B are in [16,235]
+ */
+static const float bt_709[16] =
+{
+   1.0f,  0.0f,    1.540f, 0.0f,
+   1.0f, -0.183f, -0.459f, 0.0f,
+   1.0f,  1.816f,  0.0f,   0.0f,
+   0.0f,  0.0f,    0.0f,   1.0f
+};
+
+/*
+ * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
+ * Y is in [16,235], Cb and Cr are in [16,240]
+ * R, G, and B are in [0,255]
+ */
+static const float bt_709_full[16] =
+{
+   1.164f,  0.0f,    1.793f, 0.0f,
+   1.164f, -0.213f, -0.534f, 0.0f,
+   1.164f,  2.115f,  0.0f,   0.0f,
+   0.0f,    0.0f,    0.0f,   1.0f
+};
+
+static const float identity[16] =
+{
+   1.0f, 0.0f, 0.0f, 0.0f,
+   0.0f, 1.0f, 0.0f, 0.0f,
+   0.0f, 0.0f, 1.0f, 0.0f,
+   0.0f, 0.0f, 0.0f, 1.0f
+};
+
+const struct vl_procamp vl_default_procamp = {
+   0.0f,  /* brightness */
+   1.0f,  /* contrast   */
+   1.0f,  /* saturation */
+   0.0f   /* hue        */
+};
+
+void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
+                       struct vl_procamp *procamp,
+                       bool full_range,
+                       float *matrix)
+{
+   float ybias = full_range ? -16.0f/255.0f : 0.0f;
+   float cbbias = -128.0f/255.0f;
+   float crbias = -128.0f/255.0f;
+
+   const struct vl_procamp *p = procamp ? procamp : &vl_default_procamp;
+   float c = p->contrast;
+   float s = p->saturation;
+   float b = p->brightness;
+   float h = p->hue;
+
+   const float *cstd;
+
+   assert(matrix);
+
+   switch (cs) {
+      case VL_CSC_COLOR_STANDARD_BT_601:
+         cstd = full_range ? &bt_601_full[0] : &bt_601[0];
+         break;
+      case VL_CSC_COLOR_STANDARD_BT_709:
+         cstd = full_range ? &bt_709_full[0] : &bt_709[0];
+         break;
+      case VL_CSC_COLOR_STANDARD_IDENTITY:
+      default:
+         assert(cs == VL_CSC_COLOR_STANDARD_IDENTITY);
+         memcpy(matrix, &identity[0], sizeof(float) * 16);
+         return;
+   }
+
+   matrix[ 0] = c*cstd[ 0];
+   matrix[ 1] = c*cstd[ 1]*s*cosf(h) - c*cstd[ 2]*s*sinf(h);
+   matrix[ 2] = c*cstd[ 2]*s*cosf(h) + c*cstd[ 1]*s*sinf(h);
+   matrix[ 3] = cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 2]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
+
+   matrix[ 4] = c*cstd[ 4];
+   matrix[ 5] = c*cstd[ 5]*s*cosf(h) - c*cstd[ 6]*s*sinf(h);
+   matrix[ 6] = c*cstd[ 6]*s*cosf(h) + c*cstd[ 5]*s*sinf(h);
+   matrix[ 7] = cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 6]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
+
+   matrix[ 8] = c*cstd[ 8];
+   matrix[ 9] = c*cstd[ 9]*s*cosf(h) - c*cstd[10]*s*sinf(h);
+   matrix[10] = c*cstd[10]*s*cosf(h) + c*cstd[ 9]*s*sinf(h);
+   matrix[11] = cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[10]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
+
+   matrix[12] = c*cstd[12];
+   matrix[13] = c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h);
+   matrix[14] = c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h);
+   matrix[15] = cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h));
+}
diff --git a/src/gallium/auxiliary/vl/vl_csc.h b/src/gallium/auxiliary/vl/vl_csc.h
new file mode 100644 (file)
index 0000000..9b73fb3
--- /dev/null
@@ -0,0 +1,55 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_csc_h
+#define vl_csc_h
+
+#include <pipe/p_compiler.h>
+
+struct vl_procamp
+{
+   float brightness;
+   float contrast;
+   float saturation;
+   float hue;
+};
+
+enum VL_CSC_COLOR_STANDARD
+{
+   VL_CSC_COLOR_STANDARD_IDENTITY,
+   VL_CSC_COLOR_STANDARD_BT_601,
+   VL_CSC_COLOR_STANDARD_BT_709
+};
+
+extern const struct vl_procamp vl_default_procamp;
+
+void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
+                       struct vl_procamp *procamp,
+                       bool full_range,
+                       float *matrix);
+
+#endif /* vl_csc_h */
diff --git a/src/gallium/auxiliary/vl/vl_decoder.c b/src/gallium/auxiliary/vl/vl_decoder.c
new file mode 100644 (file)
index 0000000..fac0335
--- /dev/null
@@ -0,0 +1,77 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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_video_decoder.h>
+
+#include <util/u_video.h>
+
+#include "vl_decoder.h"
+#include "vl_mpeg12_decoder.h"
+
+bool
+vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile)
+{
+   assert(screen);
+   switch (u_reduce_video_profile(profile)) {
+      case PIPE_VIDEO_CODEC_MPEG12:
+         return true;
+      default:
+         return false;
+   }
+}
+
+struct pipe_video_decoder *
+vl_create_decoder(struct pipe_context *pipe,
+                  enum pipe_video_profile profile,
+                  enum pipe_video_entrypoint entrypoint,
+                  enum pipe_video_chroma_format chroma_format,
+                  unsigned width, unsigned height)
+{
+   unsigned buffer_width, buffer_height;
+   bool pot_buffers;
+
+   assert(pipe);
+   assert(width > 0 && height > 0);
+   
+   pot_buffers = !pipe->screen->get_video_param
+   (
+      pipe->screen,
+      profile,
+      PIPE_VIDEO_CAP_NPOT_TEXTURES
+   );
+
+   buffer_width = pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH);
+   buffer_height = pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT);
+
+   switch (u_reduce_video_profile(profile)) {
+      case PIPE_VIDEO_CODEC_MPEG12:
+         return vl_create_mpeg12_decoder(pipe, profile, entrypoint, chroma_format, buffer_width, buffer_height);
+      default:
+         return NULL;
+   }
+   return NULL;
+}
diff --git a/src/gallium/auxiliary/vl/vl_decoder.h b/src/gallium/auxiliary/vl/vl_decoder.h
new file mode 100644 (file)
index 0000000..0e9280d
--- /dev/null
@@ -0,0 +1,50 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Younes Manton.
+ * Copyright 2011 Christian König.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_decoder_h
+#define vl_decoder_h
+
+#include <pipe/p_video_decoder.h>
+
+/**
+ * check if a given profile is supported with shader based decoding
+ */
+bool
+vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile);
+
+/**
+ * standard implementation of pipe->create_video_decoder
+ */
+struct pipe_video_decoder *
+vl_create_decoder(struct pipe_context *pipe,
+                  enum pipe_video_profile profile,
+                  enum pipe_video_entrypoint entrypoint,
+                  enum pipe_video_chroma_format chroma_format,
+                  unsigned width, unsigned height);
+
+#endif /* vl_decoder_h */
diff --git a/src/gallium/auxiliary/vl/vl_defines.h b/src/gallium/auxiliary/vl/vl_defines.h
new file mode 100644 (file)
index 0000000..7568db0
--- /dev/null
@@ -0,0 +1,41 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Christian König
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_defines_h
+#define vl_defines_h
+
+/* constants usually used with all known codecs */
+#define MACROBLOCK_WIDTH 16
+#define MACROBLOCK_HEIGHT 16
+
+#define BLOCK_WIDTH 8
+#define BLOCK_HEIGHT 8
+
+#define VL_MAX_PLANES 3
+#define VL_MAX_REF_FRAMES 2
+
+#endif
diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c
new file mode 100644 (file)
index 0000000..ad78614
--- /dev/null
@@ -0,0 +1,871 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Christian König
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <pipe/p_context.h>
+#include <pipe/p_screen.h>
+
+#include <util/u_draw.h>
+#include <util/u_sampler.h>
+#include <util/u_memory.h>
+
+#include <tgsi/tgsi_ureg.h>
+
+#include "vl_defines.h"
+#include "vl_types.h"
+#include "vl_vertex_buffers.h"
+#include "vl_idct.h"
+
+enum VS_OUTPUT
+{
+   VS_O_VPOS,
+   VS_O_L_ADDR0,
+   VS_O_L_ADDR1,
+   VS_O_R_ADDR0,
+   VS_O_R_ADDR1
+};
+
+/**
+ * The DCT matrix stored as hex representation of floats. Equal to the following equation:
+ * for (i = 0; i < 8; ++i)
+ *    for (j = 0; j < 8; ++j)
+ *       if (i == 0) const_matrix[i][j] = 1.0f / sqrtf(8.0f);
+ *       else const_matrix[i][j] = sqrtf(2.0f / 8.0f) * cosf((2 * j + 1) * i * M_PI / (2.0f * 8.0f));
+ */
+static const uint32_t const_matrix[8][8] = {
+   { 0x3eb504f3, 0x3eb504f3, 0x3eb504f3, 0x3eb504f3, 0x3eb504f3, 0x3eb504f3, 0x3eb504f3, 0x3eb504f3 },
+   { 0x3efb14be, 0x3ed4db31, 0x3e8e39da, 0x3dc7c5c4, 0xbdc7c5c2, 0xbe8e39d9, 0xbed4db32, 0xbefb14bf },
+   { 0x3eec835f, 0x3e43ef15, 0xbe43ef14, 0xbeec835e, 0xbeec835f, 0xbe43ef1a, 0x3e43ef1b, 0x3eec835f },
+   { 0x3ed4db31, 0xbdc7c5c2, 0xbefb14bf, 0xbe8e39dd, 0x3e8e39d7, 0x3efb14bf, 0x3dc7c5d0, 0xbed4db34 },
+   { 0x3eb504f3, 0xbeb504f3, 0xbeb504f4, 0x3eb504f1, 0x3eb504f3, 0xbeb504f0, 0xbeb504ef, 0x3eb504f4 },
+   { 0x3e8e39da, 0xbefb14bf, 0x3dc7c5c8, 0x3ed4db32, 0xbed4db34, 0xbdc7c5bb, 0x3efb14bf, 0xbe8e39d7 },
+   { 0x3e43ef15, 0xbeec835f, 0x3eec835f, 0xbe43ef07, 0xbe43ef23, 0x3eec8361, 0xbeec835c, 0x3e43ef25 },
+   { 0x3dc7c5c4, 0xbe8e39dd, 0x3ed4db32, 0xbefb14c0, 0x3efb14be, 0xbed4db31, 0x3e8e39ce, 0xbdc7c596 },
+};
+
+static void
+calc_addr(struct ureg_program *shader, struct ureg_dst addr[2],
+          struct ureg_src tc, struct ureg_src start, bool right_side,
+          bool transposed, float size)
+{
+   unsigned wm_start = (right_side == transposed) ? TGSI_WRITEMASK_X : TGSI_WRITEMASK_Y;
+   unsigned sw_start = right_side ? TGSI_SWIZZLE_Y : TGSI_SWIZZLE_X;
+
+   unsigned wm_tc = (right_side == transposed) ? TGSI_WRITEMASK_Y : TGSI_WRITEMASK_X;
+   unsigned sw_tc = right_side ? TGSI_SWIZZLE_X : TGSI_SWIZZLE_Y;
+
+   /*
+    * addr[0..1].(start) = right_side ? start.x : tc.x
+    * addr[0..1].(tc) = right_side ? tc.y : start.y
+    * addr[0..1].z = tc.z
+    * addr[1].(start) += 1.0f / scale
+    */
+   ureg_MOV(shader, ureg_writemask(addr[0], wm_start), ureg_scalar(start, sw_start));
+   ureg_MOV(shader, ureg_writemask(addr[0], wm_tc), ureg_scalar(tc, sw_tc));
+
+   ureg_ADD(shader, ureg_writemask(addr[1], wm_start), ureg_scalar(start, sw_start), ureg_imm1f(shader, 1.0f / size));
+   ureg_MOV(shader, ureg_writemask(addr[1], wm_tc), ureg_scalar(tc, sw_tc));
+}
+
+static void
+increment_addr(struct ureg_program *shader, struct ureg_dst daddr[2],
+               struct ureg_src saddr[2], bool right_side, bool transposed,
+               int pos, float size)
+{
+   unsigned wm_start = (right_side == transposed) ? TGSI_WRITEMASK_X : TGSI_WRITEMASK_Y;
+   unsigned wm_tc = (right_side == transposed) ? TGSI_WRITEMASK_Y : TGSI_WRITEMASK_X;
+
+   /*
+    * daddr[0..1].(start) = saddr[0..1].(start)
+    * daddr[0..1].(tc) = saddr[0..1].(tc)
+    */
+
+   ureg_MOV(shader, ureg_writemask(daddr[0], wm_start), saddr[0]);
+   ureg_ADD(shader, ureg_writemask(daddr[0], wm_tc), saddr[0], ureg_imm1f(shader, pos / size));
+   ureg_MOV(shader, ureg_writemask(daddr[1], wm_start), saddr[1]);
+   ureg_ADD(shader, ureg_writemask(daddr[1], wm_tc), saddr[1], ureg_imm1f(shader, pos / size));
+}
+
+static void
+fetch_four(struct ureg_program *shader, struct ureg_dst m[2], struct ureg_src addr[2],
+           struct ureg_src sampler, bool resource3d)
+{
+   ureg_TEX(shader, m[0], resource3d ? TGSI_TEXTURE_3D : TGSI_TEXTURE_2D, addr[0], sampler);
+   ureg_TEX(shader, m[1], resource3d ? TGSI_TEXTURE_3D : TGSI_TEXTURE_2D, addr[1], sampler);
+}
+
+static void
+matrix_mul(struct ureg_program *shader, struct ureg_dst dst, struct ureg_dst l[2], struct ureg_dst r[2])
+{
+   struct ureg_dst tmp;
+
+   tmp = ureg_DECL_temporary(shader);
+
+   /*
+    * tmp.xy = dot4(m[0][0..1], m[1][0..1])
+    * dst = tmp.x + tmp.y
+    */
+   ureg_DP4(shader, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_src(l[0]), ureg_src(r[0]));
+   ureg_DP4(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), ureg_src(l[1]), ureg_src(r[1]));
+   ureg_ADD(shader, dst,
+      ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X),
+      ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y));
+
+   ureg_release_temporary(shader, tmp);
+}
+
+static void *
+create_mismatch_vert_shader(struct vl_idct *idct)
+{
+   struct ureg_program *shader;
+   struct ureg_src vpos;
+   struct ureg_src scale;
+   struct ureg_dst t_tex;
+   struct ureg_dst o_vpos, o_addr[2];
+
+   shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+   if (!shader)
+      return NULL;
+
+   vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
+
+   t_tex = ureg_DECL_temporary(shader);
+
+   o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
+
+   o_addr[0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_L_ADDR0);
+   o_addr[1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_L_ADDR1);
+
+   /*
+    * scale = (BLOCK_WIDTH, BLOCK_HEIGHT) / (dst.width, dst.height)
+    *
+    * t_vpos = vpos + 7 / BLOCK_WIDTH
+    * o_vpos.xy = t_vpos * scale
+    *
+    * o_addr = calc_addr(...)
+    *
+    */
+
+   scale = ureg_imm2f(shader,
+      (float)BLOCK_WIDTH / idct->buffer_width,
+      (float)BLOCK_HEIGHT / idct->buffer_height);
+
+   ureg_MAD(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_XY), vpos, scale, scale);
+   ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_ZW), ureg_imm1f(shader, 1.0f));
+
+   ureg_MUL(shader, ureg_writemask(t_tex, TGSI_WRITEMASK_XY), vpos, scale);
+   calc_addr(shader, o_addr, ureg_src(t_tex), ureg_src(t_tex), false, false, idct->buffer_width / 4);
+
+   ureg_release_temporary(shader, t_tex);
+
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, idct->pipe);
+}
+
+static void *
+create_mismatch_frag_shader(struct vl_idct *idct)
+{
+   struct ureg_program *shader;
+
+   struct ureg_src addr[2];
+
+   struct ureg_dst m[8][2];
+   struct ureg_dst fragment;
+
+   unsigned i;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return NULL;
+
+   addr[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_L_ADDR0, TGSI_INTERPOLATE_LINEAR);
+   addr[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_L_ADDR1, TGSI_INTERPOLATE_LINEAR);
+
+   fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+   for (i = 0; i < 8; ++i) {
+      m[i][0] = ureg_DECL_temporary(shader);
+      m[i][1] = ureg_DECL_temporary(shader);
+   }
+
+   for (i = 0; i < 8; ++i) {
+      increment_addr(shader, m[i], addr, false, false, i, idct->buffer_height);
+   }
+
+   for (i = 0; i < 8; ++i) {
+      struct ureg_src s_addr[2];
+      s_addr[0] = ureg_src(m[i][0]);
+      s_addr[1] = ureg_src(m[i][1]);
+      fetch_four(shader, m[i], s_addr, ureg_DECL_sampler(shader, 0), false);
+   }
+
+   for (i = 1; i < 8; ++i) {
+      ureg_ADD(shader, m[0][0], ureg_src(m[0][0]), ureg_src(m[i][0]));
+      ureg_ADD(shader, m[0][1], ureg_src(m[0][1]), ureg_src(m[i][1]));
+   }
+
+   ureg_ADD(shader, m[0][0], ureg_src(m[0][0]), ureg_src(m[0][1]));
+   ureg_DP4(shader, m[0][0], ureg_abs(ureg_src(m[0][0])), ureg_imm1f(shader, 1 << 14));
+
+   ureg_MUL(shader, ureg_writemask(m[0][0], TGSI_WRITEMASK_W), ureg_abs(ureg_src(m[7][1])), ureg_imm1f(shader, 1 << 14));
+   ureg_FRC(shader, m[0][0], ureg_src(m[0][0]));
+   ureg_SGT(shader, m[0][0], ureg_imm1f(shader, 0.5f), ureg_abs(ureg_src(m[0][0])));
+
+   ureg_CMP(shader, ureg_writemask(m[0][0], TGSI_WRITEMASK_W), ureg_negate(ureg_src(m[0][0])),
+            ureg_imm1f(shader, 1.0f / (1 << 15)), ureg_imm1f(shader, -1.0f / (1 << 15)));
+   ureg_MUL(shader, ureg_writemask(m[0][0], TGSI_WRITEMASK_W), ureg_src(m[0][0]),
+            ureg_scalar(ureg_src(m[0][0]), TGSI_SWIZZLE_X));
+
+   ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_XYZ), ureg_src(m[7][1]));
+   ureg_ADD(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), ureg_src(m[0][0]), ureg_src(m[7][1]));
+
+   for (i = 0; i < 8; ++i) {
+      ureg_release_temporary(shader, m[i][0]);
+      ureg_release_temporary(shader, m[i][1]);
+   }
+
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, idct->pipe);
+}
+
+static void *
+create_stage1_vert_shader(struct vl_idct *idct)
+{
+   struct ureg_program *shader;
+   struct ureg_src vrect, vpos;
+   struct ureg_src scale;
+   struct ureg_dst t_tex, t_start;
+   struct ureg_dst o_vpos, o_l_addr[2], o_r_addr[2];
+
+   shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+   if (!shader)
+      return NULL;
+
+   vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
+   vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
+
+   t_tex = ureg_DECL_temporary(shader);
+   t_start = ureg_DECL_temporary(shader);
+
+   o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
+
+   o_l_addr[0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_L_ADDR0);
+   o_l_addr[1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_L_ADDR1);
+
+   o_r_addr[0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_R_ADDR0);
+   o_r_addr[1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_R_ADDR1);
+
+   /*
+    * scale = (BLOCK_WIDTH, BLOCK_HEIGHT) / (dst.width, dst.height)
+    *
+    * t_vpos = vpos + vrect
+    * o_vpos.xy = t_vpos * scale
+    * o_vpos.zw = vpos
+    *
+    * o_l_addr = calc_addr(...)
+    * o_r_addr = calc_addr(...)
+    *
+    */
+
+   scale = ureg_imm2f(shader,
+      (float)BLOCK_WIDTH / idct->buffer_width,
+      (float)BLOCK_HEIGHT / idct->buffer_height);
+
+   ureg_ADD(shader, ureg_writemask(t_tex, TGSI_WRITEMASK_XY), vpos, vrect);
+   ureg_MUL(shader, ureg_writemask(t_tex, TGSI_WRITEMASK_XY), ureg_src(t_tex), scale);
+
+   ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_XY), ureg_src(t_tex));
+   ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_ZW), ureg_imm1f(shader, 1.0f));
+
+   ureg_MUL(shader, ureg_writemask(t_start, TGSI_WRITEMASK_XY), vpos, scale);
+
+   calc_addr(shader, o_l_addr, ureg_src(t_tex), ureg_src(t_start), false, false, idct->buffer_width / 4);
+   calc_addr(shader, o_r_addr, vrect, ureg_imm1f(shader, 0.0f), true, true, BLOCK_WIDTH / 4);
+
+   ureg_release_temporary(shader, t_tex);
+   ureg_release_temporary(shader, t_start);
+
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, idct->pipe);
+}
+
+static void *
+create_stage1_frag_shader(struct vl_idct *idct)
+{
+   struct ureg_program *shader;
+
+   struct ureg_src l_addr[2], r_addr[2];
+
+   struct ureg_dst l[4][2], r[2];
+   struct ureg_dst *fragment;
+
+   int i, j;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return NULL;
+
+   fragment = MALLOC(idct->nr_of_render_targets * sizeof(struct ureg_dst));
+
+   l_addr[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_L_ADDR0, TGSI_INTERPOLATE_LINEAR);
+   l_addr[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_L_ADDR1, TGSI_INTERPOLATE_LINEAR);
+
+   r_addr[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_R_ADDR0, TGSI_INTERPOLATE_LINEAR);
+   r_addr[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_R_ADDR1, TGSI_INTERPOLATE_LINEAR);
+
+   for (i = 0; i < idct->nr_of_render_targets; ++i)
+       fragment[i] = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, i);
+
+   for (i = 0; i < 4; ++i) {
+      l[i][0] = ureg_DECL_temporary(shader);
+      l[i][1] = ureg_DECL_temporary(shader);
+   }
+
+   r[0] = ureg_DECL_temporary(shader);
+   r[1] = ureg_DECL_temporary(shader);
+
+   for (i = 0; i < 4; ++i) {
+      increment_addr(shader, l[i], l_addr, false, false, i - 2, idct->buffer_height);
+   }
+
+   for (i = 0; i < 4; ++i) {
+      struct ureg_src s_addr[2];
+      s_addr[0] = ureg_src(l[i][0]);
+      s_addr[1] = ureg_src(l[i][1]);
+      fetch_four(shader, l[i], s_addr, ureg_DECL_sampler(shader, 0), false);
+   }
+
+   for (i = 0; i < idct->nr_of_render_targets; ++i) {
+      struct ureg_src s_addr[2];
+
+      increment_addr(shader, r, r_addr, true, true, i - (signed)idct->nr_of_render_targets / 2, BLOCK_HEIGHT);
+
+      s_addr[0] = ureg_src(r[0]);
+      s_addr[1] = ureg_src(r[1]);
+      fetch_four(shader, r, s_addr, ureg_DECL_sampler(shader, 1), false);
+
+      for (j = 0; j < 4; ++j) {
+         matrix_mul(shader, ureg_writemask(fragment[i], TGSI_WRITEMASK_X << j), l[j], r);
+      }
+   }
+
+   for (i = 0; i < 4; ++i) {
+      ureg_release_temporary(shader, l[i][0]);
+      ureg_release_temporary(shader, l[i][1]);
+   }
+   ureg_release_temporary(shader, r[0]);
+   ureg_release_temporary(shader, r[1]);
+
+   ureg_END(shader);
+
+   FREE(fragment);
+
+   return ureg_create_shader_and_destroy(shader, idct->pipe);
+}
+
+void
+vl_idct_stage2_vert_shader(struct vl_idct *idct, struct ureg_program *shader,
+                           unsigned first_output, struct ureg_dst tex)
+{
+   struct ureg_src vrect, vpos;
+   struct ureg_src scale;
+   struct ureg_dst t_start;
+   struct ureg_dst o_l_addr[2], o_r_addr[2];
+
+   vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
+   vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
+
+   t_start = ureg_DECL_temporary(shader);
+
+   --first_output;
+
+   o_l_addr[0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, first_output + VS_O_L_ADDR0);
+   o_l_addr[1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, first_output + VS_O_L_ADDR1);
+
+   o_r_addr[0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, first_output + VS_O_R_ADDR0);
+   o_r_addr[1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, first_output + VS_O_R_ADDR1);
+
+   scale = ureg_imm2f(shader,
+      (float)BLOCK_WIDTH / idct->buffer_width,
+      (float)BLOCK_HEIGHT / idct->buffer_height);
+
+   ureg_MUL(shader, ureg_writemask(tex, TGSI_WRITEMASK_Z),
+      ureg_scalar(vrect, TGSI_SWIZZLE_X),
+      ureg_imm1f(shader, BLOCK_WIDTH / idct->nr_of_render_targets));
+   ureg_MUL(shader, ureg_writemask(t_start, TGSI_WRITEMASK_XY), vpos, scale);
+
+   calc_addr(shader, o_l_addr, vrect, ureg_imm1f(shader, 0.0f), false, false, BLOCK_WIDTH / 4);
+   calc_addr(shader, o_r_addr, ureg_src(tex), ureg_src(t_start), true, false, idct->buffer_height / 4);
+
+   ureg_MOV(shader, ureg_writemask(o_r_addr[0], TGSI_WRITEMASK_Z), ureg_src(tex));
+   ureg_MOV(shader, ureg_writemask(o_r_addr[1], TGSI_WRITEMASK_Z), ureg_src(tex));
+}
+
+void
+vl_idct_stage2_frag_shader(struct vl_idct *idct, struct ureg_program *shader,
+                           unsigned first_input, struct ureg_dst fragment)
+{
+   struct ureg_src l_addr[2], r_addr[2];
+
+   struct ureg_dst l[2], r[2];
+
+   --first_input;
+
+   l_addr[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, first_input + VS_O_L_ADDR0, TGSI_INTERPOLATE_LINEAR);
+   l_addr[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, first_input + VS_O_L_ADDR1, TGSI_INTERPOLATE_LINEAR);
+
+   r_addr[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, first_input + VS_O_R_ADDR0, TGSI_INTERPOLATE_LINEAR);
+   r_addr[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, first_input + VS_O_R_ADDR1, TGSI_INTERPOLATE_LINEAR);
+
+   l[0] = ureg_DECL_temporary(shader);
+   l[1] = ureg_DECL_temporary(shader);
+   r[0] = ureg_DECL_temporary(shader);
+   r[1] = ureg_DECL_temporary(shader);
+
+   fetch_four(shader, l, l_addr, ureg_DECL_sampler(shader, 1), false);
+   fetch_four(shader, r, r_addr, ureg_DECL_sampler(shader, 0), true);
+
+   matrix_mul(shader, fragment, l, r);
+
+   ureg_release_temporary(shader, l[0]);
+   ureg_release_temporary(shader, l[1]);
+   ureg_release_temporary(shader, r[0]);
+   ureg_release_temporary(shader, r[1]);
+}
+
+static bool
+init_shaders(struct vl_idct *idct)
+{
+   idct->vs_mismatch = create_mismatch_vert_shader(idct);
+   if (!idct->vs_mismatch)
+      goto error_vs_mismatch;
+
+   idct->fs_mismatch = create_mismatch_frag_shader(idct);
+   if (!idct->fs_mismatch)
+      goto error_fs_mismatch;
+
+   idct->vs = create_stage1_vert_shader(idct);
+   if (!idct->vs)
+      goto error_vs;
+
+   idct->fs = create_stage1_frag_shader(idct);
+   if (!idct->fs)
+      goto error_fs;
+
+   return true;
+
+error_fs:
+   idct->pipe->delete_vs_state(idct->pipe, idct->vs);
+
+error_vs:
+   idct->pipe->delete_vs_state(idct->pipe, idct->vs_mismatch);
+
+error_fs_mismatch:
+   idct->pipe->delete_vs_state(idct->pipe, idct->fs);
+
+error_vs_mismatch:
+   return false;
+}
+
+static void
+cleanup_shaders(struct vl_idct *idct)
+{
+   idct->pipe->delete_vs_state(idct->pipe, idct->vs_mismatch);
+   idct->pipe->delete_fs_state(idct->pipe, idct->fs_mismatch);
+   idct->pipe->delete_vs_state(idct->pipe, idct->vs);
+   idct->pipe->delete_fs_state(idct->pipe, idct->fs);
+}
+
+static bool
+init_state(struct vl_idct *idct)
+{
+   struct pipe_blend_state blend;
+   struct pipe_rasterizer_state rs_state;
+   struct pipe_sampler_state sampler;
+   unsigned i;
+
+   assert(idct);
+
+   memset(&rs_state, 0, sizeof(rs_state));
+   rs_state.point_size = 1;
+   rs_state.gl_rasterization_rules = true;
+   idct->rs_state = idct->pipe->create_rasterizer_state(idct->pipe, &rs_state);
+   if (!idct->rs_state)
+      goto error_rs_state;
+
+   memset(&blend, 0, sizeof blend);
+
+   blend.independent_blend_enable = 0;
+   blend.rt[0].blend_enable = 0;
+   blend.rt[0].rgb_func = PIPE_BLEND_ADD;
+   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_func = PIPE_BLEND_ADD;
+   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.logicop_enable = 0;
+   blend.logicop_func = PIPE_LOGICOP_CLEAR;
+   /* Needed to allow color writes to FB, even if blending disabled */
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
+   blend.dither = 0;
+   idct->blend = idct->pipe->create_blend_state(idct->pipe, &blend);
+   if (!idct->blend)
+      goto error_blend;
+
+   for (i = 0; i < 2; ++i) {
+      memset(&sampler, 0, sizeof(sampler));
+      sampler.wrap_s = PIPE_TEX_WRAP_REPEAT;
+      sampler.wrap_t = PIPE_TEX_WRAP_REPEAT;
+      sampler.wrap_r = PIPE_TEX_WRAP_REPEAT;
+      sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
+      sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+      sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
+      sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
+      sampler.compare_func = PIPE_FUNC_ALWAYS;
+      sampler.normalized_coords = 1;
+      idct->samplers[i] = idct->pipe->create_sampler_state(idct->pipe, &sampler);
+      if (!idct->samplers[i])
+         goto error_samplers;
+   }
+
+   return true;
+
+error_samplers:
+   for (i = 0; i < 2; ++i)
+      if (idct->samplers[i])
+         idct->pipe->delete_sampler_state(idct->pipe, idct->samplers[i]);
+
+   idct->pipe->delete_rasterizer_state(idct->pipe, idct->rs_state);
+
+error_blend:
+   idct->pipe->delete_blend_state(idct->pipe, idct->blend);
+
+error_rs_state:
+   return false;
+}
+
+static void
+cleanup_state(struct vl_idct *idct)
+{
+   unsigned i;
+
+   for (i = 0; i < 2; ++i)
+      idct->pipe->delete_sampler_state(idct->pipe, idct->samplers[i]);
+
+   idct->pipe->delete_rasterizer_state(idct->pipe, idct->rs_state);
+   idct->pipe->delete_blend_state(idct->pipe, idct->blend);
+}
+
+static bool
+init_source(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+{
+   struct pipe_resource *tex;
+   struct pipe_surface surf_templ;
+
+   assert(idct && buffer);
+
+   tex = buffer->sampler_views.individual.source->texture;
+
+   buffer->fb_state_mismatch.width = tex->width0;
+   buffer->fb_state_mismatch.height = tex->height0;
+   buffer->fb_state_mismatch.nr_cbufs = 1;
+
+   memset(&surf_templ, 0, sizeof(surf_templ));
+   surf_templ.format = tex->format;
+   surf_templ.u.tex.first_layer = 0;
+   surf_templ.u.tex.last_layer = 0;
+   surf_templ.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+   buffer->fb_state_mismatch.cbufs[0] = idct->pipe->create_surface(idct->pipe, tex, &surf_templ);
+
+   buffer->viewport_mismatch.scale[0] = tex->width0;
+   buffer->viewport_mismatch.scale[1] = tex->height0;
+   buffer->viewport_mismatch.scale[2] = 1;
+   buffer->viewport_mismatch.scale[3] = 1;
+
+   return true;
+}
+
+static void
+cleanup_source(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+{
+   assert(idct && buffer);
+
+   pipe_surface_reference(&buffer->fb_state_mismatch.cbufs[0], NULL);
+
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.source, NULL);
+}
+
+static bool
+init_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+{
+   struct pipe_resource *tex;
+   struct pipe_surface surf_templ;
+   unsigned i;
+
+   assert(idct && buffer);
+
+   tex = buffer->sampler_views.individual.intermediate->texture;
+
+   buffer->fb_state.width = tex->width0;
+   buffer->fb_state.height = tex->height0;
+   buffer->fb_state.nr_cbufs = idct->nr_of_render_targets;
+   for(i = 0; i < idct->nr_of_render_targets; ++i) {
+      memset(&surf_templ, 0, sizeof(surf_templ));
+      surf_templ.format = tex->format;
+      surf_templ.u.tex.first_layer = i;
+      surf_templ.u.tex.last_layer = i;
+      surf_templ.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+      buffer->fb_state.cbufs[i] = idct->pipe->create_surface(
+         idct->pipe, tex, &surf_templ);
+
+      if (!buffer->fb_state.cbufs[i])
+         goto error_surfaces;
+   }
+
+   buffer->viewport.scale[0] = tex->width0;
+   buffer->viewport.scale[1] = tex->height0;
+   buffer->viewport.scale[2] = 1;
+   buffer->viewport.scale[3] = 1;
+
+   return true;
+
+error_surfaces:
+   for(i = 0; i < idct->nr_of_render_targets; ++i)
+      pipe_surface_reference(&buffer->fb_state.cbufs[i], NULL);
+
+   return false;
+}
+
+static void
+cleanup_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
+{
+   unsigned i;
+
+   assert(idct && buffer);
+
+   for(i = 0; i < idct->nr_of_render_targets; ++i)
+      pipe_surface_reference(&buffer->fb_state.cbufs[i], NULL);
+
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, NULL);
+}
+
+struct pipe_sampler_view *
+vl_idct_upload_matrix(struct pipe_context *pipe, float scale)
+{
+   struct pipe_resource tex_templ, *matrix;
+   struct pipe_sampler_view sv_templ, *sv;
+   struct pipe_transfer *buf_transfer;
+   unsigned i, j, pitch;
+   float *f;
+
+   struct pipe_box rect =
+   {
+      0, 0, 0,
+      BLOCK_WIDTH / 4,
+      BLOCK_HEIGHT,
+      1
+   };
+
+   assert(pipe);
+
+   memset(&tex_templ, 0, sizeof(tex_templ));
+   tex_templ.target = PIPE_TEXTURE_2D;
+   tex_templ.format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+   tex_templ.last_level = 0;
+   tex_templ.width0 = 2;
+   tex_templ.height0 = 8;
+   tex_templ.depth0 = 1;
+   tex_templ.array_size = 1;
+   tex_templ.usage = PIPE_USAGE_IMMUTABLE;
+   tex_templ.bind = PIPE_BIND_SAMPLER_VIEW;
+   tex_templ.flags = 0;
+
+   matrix = pipe->screen->resource_create(pipe->screen, &tex_templ);
+   if (!matrix)
+      goto error_matrix;
+
+   buf_transfer = pipe->get_transfer
+   (
+      pipe, matrix,
+      0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+      &rect
+   );
+   if (!buf_transfer)
+      goto error_transfer;
+
+   pitch = buf_transfer->stride / sizeof(float);
+
+   f = pipe->transfer_map(pipe, buf_transfer);
+   if (!f)
+      goto error_map;
+
+   for(i = 0; i < BLOCK_HEIGHT; ++i)
+      for(j = 0; j < BLOCK_WIDTH; ++j)
+         // transpose and scale
+         f[i * pitch + j] = ((const float (*)[8])const_matrix)[j][i] * scale;
+
+   pipe->transfer_unmap(pipe, buf_transfer);
+   pipe->transfer_destroy(pipe, buf_transfer);
+
+   memset(&sv_templ, 0, sizeof(sv_templ));
+   u_sampler_view_default_template(&sv_templ, matrix, matrix->format);
+   sv = pipe->create_sampler_view(pipe, matrix, &sv_templ);
+   pipe_resource_reference(&matrix, NULL);
+   if (!sv)
+      goto error_map;
+
+   return sv;
+
+error_map:
+   pipe->transfer_destroy(pipe, buf_transfer);
+
+error_transfer:
+   pipe_resource_reference(&matrix, NULL);
+
+error_matrix:
+   return NULL;
+}
+
+bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe,
+                  unsigned buffer_width, unsigned buffer_height,
+                  unsigned nr_of_render_targets,
+                  struct pipe_sampler_view *matrix,
+                  struct pipe_sampler_view *transpose)
+{
+   assert(idct && pipe);
+   assert(matrix && transpose);
+
+   idct->pipe = pipe;
+   idct->buffer_width = buffer_width;
+   idct->buffer_height = buffer_height;
+   idct->nr_of_render_targets = nr_of_render_targets;
+
+   pipe_sampler_view_reference(&idct->matrix, matrix);
+   pipe_sampler_view_reference(&idct->transpose, transpose);
+
+   if(!init_shaders(idct))
+      return false;
+
+   if(!init_state(idct)) {
+      cleanup_shaders(idct);
+      return false;
+   }
+
+   return true;
+}
+
+void
+vl_idct_cleanup(struct vl_idct *idct)
+{
+   cleanup_shaders(idct);
+   cleanup_state(idct);
+
+   pipe_sampler_view_reference(&idct->matrix, NULL);
+   pipe_sampler_view_reference(&idct->transpose, NULL);
+}
+
+bool
+vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
+                    struct pipe_sampler_view *source,
+                    struct pipe_sampler_view *intermediate)
+{
+   assert(buffer && idct);
+   assert(source && intermediate);
+
+   memset(buffer, 0, sizeof(struct vl_idct_buffer));
+
+   buffer->idct = idct;
+
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, idct->matrix);
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.source, source);
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, idct->transpose);
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, intermediate);
+
+   if (!init_source(idct, buffer))
+      return false;
+
+   if (!init_intermediate(idct, buffer))
+      return false;
+
+   return true;
+}
+
+void
+vl_idct_cleanup_buffer(struct vl_idct_buffer *buffer)
+{
+   assert(buffer);
+
+   cleanup_source(buffer->idct, buffer);
+   cleanup_intermediate(buffer->idct, buffer);
+
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, NULL);
+   pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, NULL);
+}
+
+void
+vl_idct_flush(struct vl_idct_buffer *buffer, unsigned num_instances)
+{
+   struct vl_idct *idct;
+   assert(buffer);
+   
+   idct = buffer->idct;
+
+   idct->pipe->bind_rasterizer_state(idct->pipe, idct->rs_state);
+   idct->pipe->bind_blend_state(idct->pipe, idct->blend);
+   idct->pipe->bind_fragment_sampler_states(idct->pipe, 2, idct->samplers);
+   idct->pipe->set_fragment_sampler_views(idct->pipe, 2, buffer->sampler_views.stage[0]);
+
+   /* mismatch control */
+   idct->pipe->set_framebuffer_state(idct->pipe, &buffer->fb_state_mismatch);
+   idct->pipe->set_viewport_state(idct->pipe, &buffer->viewport_mismatch);
+   idct->pipe->bind_vs_state(idct->pipe, idct->vs_mismatch);
+   idct->pipe->bind_fs_state(idct->pipe, idct->fs_mismatch);
+   util_draw_arrays_instanced(idct->pipe, PIPE_PRIM_POINTS, 0, 1, 0, num_instances);
+
+   /* first stage */
+   idct->pipe->set_framebuffer_state(idct->pipe, &buffer->fb_state);
+   idct->pipe->set_viewport_state(idct->pipe, &buffer->viewport);
+   idct->pipe->bind_vs_state(idct->pipe, idct->vs);
+   idct->pipe->bind_fs_state(idct->pipe, idct->fs);
+   util_draw_arrays_instanced(idct->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_instances);
+}
+
+void
+vl_idct_prepare_stage2(struct vl_idct_buffer *buffer)
+{
+   assert(buffer);
+
+   /* second stage */
+   buffer->idct->pipe->bind_rasterizer_state(buffer->idct->pipe, buffer->idct->rs_state);
+   buffer->idct->pipe->bind_fragment_sampler_states(buffer->idct->pipe, 2, buffer->idct->samplers);
+   buffer->idct->pipe->set_fragment_sampler_views(buffer->idct->pipe, 2, buffer->sampler_views.stage[1]);
+}
+
diff --git a/src/gallium/auxiliary/vl/vl_idct.h b/src/gallium/auxiliary/vl/vl_idct.h
new file mode 100644 (file)
index 0000000..98e2c79
--- /dev/null
@@ -0,0 +1,121 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Christian König
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_idct_h
+#define vl_idct_h
+
+#include <pipe/p_state.h>
+
+#include <tgsi/tgsi_ureg.h>
+
+/* shader based inverse distinct cosinus transformation
+ * expect usage of vl_vertex_buffers as a todo list
+ */
+struct vl_idct
+{
+   struct pipe_context *pipe;
+
+   unsigned buffer_width;
+   unsigned buffer_height;
+   unsigned nr_of_render_targets;
+
+   void *rs_state;
+   void *blend;
+
+   void *samplers[2];
+
+   void *vs_mismatch, *fs_mismatch;
+   void *vs, *fs;
+
+   struct pipe_sampler_view *matrix;
+   struct pipe_sampler_view *transpose;
+};
+
+/* a set of buffers to work with */
+struct vl_idct_buffer
+{
+   struct vl_idct *idct;
+   
+   struct pipe_viewport_state viewport_mismatch;
+   struct pipe_viewport_state viewport;
+
+   struct pipe_framebuffer_state fb_state_mismatch;
+   struct pipe_framebuffer_state fb_state;
+
+   union
+   {
+      struct pipe_sampler_view *all[4];
+      struct pipe_sampler_view *stage[2][2];
+      struct {
+         struct pipe_sampler_view *source, *matrix;
+         struct pipe_sampler_view *intermediate, *transpose;
+      } individual;
+   } sampler_views;
+};
+
+/* upload the idct matrix, which can be shared by all idct instances of a pipe */
+struct pipe_sampler_view *
+vl_idct_upload_matrix(struct pipe_context *pipe, float scale);
+
+void
+vl_idct_stage2_vert_shader(struct vl_idct *idct, struct ureg_program *shader,
+                           unsigned first_output, struct ureg_dst tex);
+
+void
+vl_idct_stage2_frag_shader(struct vl_idct *idct, struct ureg_program *shader,
+                           unsigned first_input, struct ureg_dst fragment);
+
+/* init an idct instance */
+bool
+vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe,
+             unsigned buffer_width, unsigned buffer_height,
+             unsigned nr_of_render_targets,
+             struct pipe_sampler_view *matrix,
+             struct pipe_sampler_view *transpose);
+
+/* destroy an idct instance */
+void
+vl_idct_cleanup(struct vl_idct *idct);
+
+/* init a buffer assosiated with agiven idct instance */
+bool
+vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
+                    struct pipe_sampler_view *source,
+                    struct pipe_sampler_view *intermediate);
+
+/* cleanup a buffer of an idct instance */
+void
+vl_idct_cleanup_buffer(struct vl_idct_buffer *buffer);
+
+/* flush the buffer and start rendering, vertex buffers needs to be setup before calling this */
+void
+vl_idct_flush(struct vl_idct_buffer *buffer, unsigned num_verts);
+
+void
+vl_idct_prepare_stage2(struct vl_idct_buffer *buffer);
+
+#endif
diff --git a/src/gallium/auxiliary/vl/vl_mc.c b/src/gallium/auxiliary/vl/vl_mc.c
new file mode 100644 (file)
index 0000000..0b3723c
--- /dev/null
@@ -0,0 +1,658 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <pipe/p_context.h>
+
+#include <util/u_sampler.h>
+#include <util/u_draw.h>
+
+#include <tgsi/tgsi_ureg.h>
+
+#include "vl_defines.h"
+#include "vl_vertex_buffers.h"
+#include "vl_mc.h"
+#include "vl_idct.h"
+
+enum VS_OUTPUT
+{
+   VS_O_VPOS,
+   VS_O_VTOP,
+   VS_O_VBOTTOM,
+
+   VS_O_FLAGS = VS_O_VTOP,
+   VS_O_VTEX = VS_O_VBOTTOM
+};
+
+static struct ureg_dst
+calc_position(struct vl_mc *r, struct ureg_program *shader, struct ureg_src block_scale)
+{
+   struct ureg_src vrect, vpos;
+   struct ureg_dst t_vpos;
+   struct ureg_dst o_vpos;
+
+   vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
+   vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
+
+   t_vpos = ureg_DECL_temporary(shader);
+
+   o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
+
+   /*
+    * block_scale = (MACROBLOCK_WIDTH, MACROBLOCK_HEIGHT) / (dst.width, dst.height)
+    *
+    * t_vpos = (vpos + vrect) * block_scale
+    * o_vpos.xy = t_vpos
+    * o_vpos.zw = vpos
+    */
+   ureg_ADD(shader, ureg_writemask(t_vpos, TGSI_WRITEMASK_XY), vpos, vrect);
+   ureg_MUL(shader, ureg_writemask(t_vpos, TGSI_WRITEMASK_XY), ureg_src(t_vpos), block_scale);
+   ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_XY), ureg_src(t_vpos));
+   ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_ZW), ureg_imm1f(shader, 1.0f));
+
+   return t_vpos;
+}
+
+static struct ureg_dst
+calc_line(struct ureg_program *shader)
+{
+   struct ureg_dst tmp;
+   struct ureg_src pos;
+
+   tmp = ureg_DECL_temporary(shader);
+
+   pos = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS, TGSI_INTERPOLATE_LINEAR);
+
+   /*
+    * tmp.y = fraction(pos.y / 2) >= 0.5 ? 1 : 0
+    */
+   ureg_MUL(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), pos, ureg_imm1f(shader, 0.5f));
+   ureg_FRC(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), ureg_src(tmp));
+   ureg_SGE(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), ureg_src(tmp), ureg_imm1f(shader, 0.5f));
+
+   return tmp;
+}
+
+static void *
+create_ref_vert_shader(struct vl_mc *r)
+{
+   struct ureg_program *shader;
+   struct ureg_src mv_scale;
+   struct ureg_src vmv[2];
+   struct ureg_dst t_vpos;
+   struct ureg_dst o_vmv[2];
+   unsigned i;
+
+   shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+   if (!shader)
+      return NULL;
+
+   vmv[0] = ureg_DECL_vs_input(shader, VS_I_MV_TOP);
+   vmv[1] = ureg_DECL_vs_input(shader, VS_I_MV_BOTTOM);
+
+   t_vpos = calc_position(r, shader, ureg_imm2f(shader,
+      (float)MACROBLOCK_WIDTH / r->buffer_width,
+      (float)MACROBLOCK_HEIGHT / r->buffer_height)
+   );
+
+   o_vmv[0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTOP);
+   o_vmv[1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_VBOTTOM);
+
+   /*
+    * mv_scale.xy = 0.5 / (dst.width, dst.height);
+    * mv_scale.z = 1.0f / 4.0f
+    * mv_scale.w = 1.0f / 255.0f
+    *
+    * // Apply motion vectors
+    * o_vmv[0..1].xy = vmv[0..1] * mv_scale + t_vpos
+    * o_vmv[0..1].zw = vmv[0..1] * mv_scale
+    *
+    */
+
+   mv_scale = ureg_imm4f(shader,
+      0.5f / r->buffer_width,
+      0.5f / r->buffer_height,
+      1.0f / 4.0f,
+      1.0f / PIPE_VIDEO_MV_WEIGHT_MAX);
+
+   for (i = 0; i < 2; ++i) {
+      ureg_MAD(shader, ureg_writemask(o_vmv[i], TGSI_WRITEMASK_XY), mv_scale, vmv[i], ureg_src(t_vpos));
+      ureg_MUL(shader, ureg_writemask(o_vmv[i], TGSI_WRITEMASK_ZW), mv_scale, vmv[i]);
+   }
+
+   ureg_release_temporary(shader, t_vpos);
+
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, r->pipe);
+}
+
+static void *
+create_ref_frag_shader(struct vl_mc *r)
+{
+   const float y_scale =
+      r->buffer_height / 2 *
+      r->macroblock_size / MACROBLOCK_HEIGHT;
+
+   struct ureg_program *shader;
+   struct ureg_src tc[2], sampler;
+   struct ureg_dst ref, field;
+   struct ureg_dst fragment;
+   unsigned label;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return NULL;
+
+   tc[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTOP, TGSI_INTERPOLATE_LINEAR);
+   tc[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VBOTTOM, TGSI_INTERPOLATE_LINEAR);
+
+   sampler = ureg_DECL_sampler(shader, 0);
+   ref = ureg_DECL_temporary(shader);
+
+   fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+   field = calc_line(shader);
+
+   /*
+    * ref = field.z ? tc[1] : tc[0]
+    *
+    * // Adjust tc acording to top/bottom field selection
+    * if (|ref.z|) {
+    *    ref.y *= y_scale
+    *    ref.y = floor(ref.y)
+    *    ref.y += ref.z
+    *    ref.y /= y_scale
+    * }
+    * fragment.xyz = tex(ref, sampler[0])
+    */
+   ureg_CMP(shader, ureg_writemask(ref, TGSI_WRITEMASK_XYZ),
+            ureg_negate(ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Y)),
+            tc[1], tc[0]);
+   ureg_CMP(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W),
+            ureg_negate(ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Y)),
+            tc[1], tc[0]);
+
+   ureg_IF(shader, ureg_scalar(ureg_src(ref), TGSI_SWIZZLE_Z), &label);
+
+      ureg_MUL(shader, ureg_writemask(ref, TGSI_WRITEMASK_Y),
+               ureg_src(ref), ureg_imm1f(shader, y_scale));
+      ureg_FLR(shader, ureg_writemask(ref, TGSI_WRITEMASK_Y), ureg_src(ref));
+      ureg_ADD(shader, ureg_writemask(ref, TGSI_WRITEMASK_Y),
+               ureg_src(ref), ureg_scalar(ureg_src(ref), TGSI_SWIZZLE_Z));
+      ureg_MUL(shader, ureg_writemask(ref, TGSI_WRITEMASK_Y),
+               ureg_src(ref), ureg_imm1f(shader, 1.0f / y_scale));
+
+   ureg_fixup_label(shader, label, ureg_get_instruction_number(shader));
+   ureg_ENDIF(shader);
+
+   ureg_TEX(shader, ureg_writemask(fragment, TGSI_WRITEMASK_XYZ), TGSI_TEXTURE_2D, ureg_src(ref), sampler);
+
+   ureg_release_temporary(shader, ref);
+
+   ureg_release_temporary(shader, field);
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, r->pipe);
+}
+
+static void *
+create_ycbcr_vert_shader(struct vl_mc *r, vl_mc_ycbcr_vert_shader vs_callback, void *callback_priv)
+{
+   struct ureg_program *shader;
+
+   struct ureg_src vrect, vpos;
+   struct ureg_dst t_vpos, t_vtex;
+   struct ureg_dst o_vpos, o_flags;
+
+   struct vertex2f scale = {
+      (float)BLOCK_WIDTH / r->buffer_width * MACROBLOCK_WIDTH / r->macroblock_size,
+      (float)BLOCK_HEIGHT / r->buffer_height * MACROBLOCK_HEIGHT / r->macroblock_size
+   };
+
+   unsigned label;
+
+   shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+   if (!shader)
+      return NULL;
+
+   vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
+   vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
+
+   t_vpos = calc_position(r, shader, ureg_imm2f(shader, scale.x, scale.y));
+   t_vtex = ureg_DECL_temporary(shader);
+
+   o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
+   o_flags = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_FLAGS);
+
+   /*
+    * o_vtex.xy = t_vpos
+    * o_flags.z = intra * 0.5
+    *
+    * if(interlaced) {
+    *    t_vtex.xy = vrect.y ? { 0, scale.y } : { -scale.y : 0 }
+    *    t_vtex.z = vpos.y % 2
+    *    t_vtex.y = t_vtex.z ? t_vtex.x : t_vtex.y
+    *    o_vpos.y = t_vtex.y + t_vpos.y
+    *
+    *    o_flags.w = t_vtex.z ? 0 : 1
+    * }
+    *
+    */
+
+   vs_callback(callback_priv, r, shader, VS_O_VTEX, t_vpos);
+
+   ureg_MUL(shader, ureg_writemask(o_flags, TGSI_WRITEMASK_Z),
+            ureg_scalar(vpos, TGSI_SWIZZLE_Z), ureg_imm1f(shader, 0.5f));
+   ureg_MOV(shader, ureg_writemask(o_flags, TGSI_WRITEMASK_W), ureg_imm1f(shader, -1.0f));
+
+   if (r->macroblock_size == MACROBLOCK_HEIGHT) { //TODO
+      ureg_IF(shader, ureg_scalar(vpos, TGSI_SWIZZLE_W), &label);
+
+         ureg_CMP(shader, ureg_writemask(t_vtex, TGSI_WRITEMASK_XY),
+                  ureg_negate(ureg_scalar(vrect, TGSI_SWIZZLE_Y)),
+                  ureg_imm2f(shader, 0.0f, scale.y),
+                  ureg_imm2f(shader, -scale.y, 0.0f));
+         ureg_MUL(shader, ureg_writemask(t_vtex, TGSI_WRITEMASK_Z),
+                  ureg_scalar(vpos, TGSI_SWIZZLE_Y), ureg_imm1f(shader, 0.5f));
+
+         ureg_FRC(shader, ureg_writemask(t_vtex, TGSI_WRITEMASK_Z), ureg_src(t_vtex));
+
+         ureg_CMP(shader, ureg_writemask(t_vtex, TGSI_WRITEMASK_Y),
+                  ureg_negate(ureg_scalar(ureg_src(t_vtex), TGSI_SWIZZLE_Z)),
+                  ureg_scalar(ureg_src(t_vtex), TGSI_SWIZZLE_X),
+                  ureg_scalar(ureg_src(t_vtex), TGSI_SWIZZLE_Y));
+         ureg_ADD(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_Y),
+                  ureg_src(t_vpos), ureg_src(t_vtex));
+
+         ureg_CMP(shader, ureg_writemask(o_flags, TGSI_WRITEMASK_W),
+                  ureg_negate(ureg_scalar(ureg_src(t_vtex), TGSI_SWIZZLE_Z)),
+                  ureg_imm1f(shader, 0.0f), ureg_imm1f(shader, 1.0f));
+
+      ureg_fixup_label(shader, label, ureg_get_instruction_number(shader));
+      ureg_ENDIF(shader);
+   }
+
+   ureg_release_temporary(shader, t_vtex);
+   ureg_release_temporary(shader, t_vpos);
+
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, r->pipe);
+}
+
+static void *
+create_ycbcr_frag_shader(struct vl_mc *r, float scale, bool invert,
+                         vl_mc_ycbcr_frag_shader fs_callback, void *callback_priv)
+{
+   struct ureg_program *shader;
+   struct ureg_src flags;
+   struct ureg_dst tmp;
+   struct ureg_dst fragment;
+   unsigned label;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return NULL;
+
+   flags = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_FLAGS, TGSI_INTERPOLATE_LINEAR);
+
+   fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+   tmp = calc_line(shader);
+
+   /*
+    * if (field == tc.w)
+    *    kill();
+    * else {
+    *    fragment.xyz  = tex(tc, sampler) * scale + tc.z
+    *    fragment.w = 1.0f
+    * }
+    */
+
+   ureg_SEQ(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y),
+            ureg_scalar(flags, TGSI_SWIZZLE_W), ureg_src(tmp));
+
+   ureg_IF(shader, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y), &label);
+
+      ureg_KILP(shader);
+
+   ureg_fixup_label(shader, label, ureg_get_instruction_number(shader));
+   ureg_ELSE(shader, &label);
+
+      fs_callback(callback_priv, r, shader, VS_O_VTEX, tmp);
+
+      if (scale != 1.0f)
+         ureg_MAD(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XYZ),
+                  ureg_src(tmp), ureg_imm1f(shader, scale),
+                  ureg_scalar(flags, TGSI_SWIZZLE_Z));
+      else
+         ureg_ADD(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XYZ),
+                  ureg_src(tmp), ureg_scalar(flags, TGSI_SWIZZLE_Z));
+                  
+      ureg_MUL(shader, ureg_writemask(fragment, TGSI_WRITEMASK_XYZ), ureg_src(tmp), ureg_imm1f(shader, invert ? -1.0f : 1.0f));
+      ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
+
+   ureg_fixup_label(shader, label, ureg_get_instruction_number(shader));
+   ureg_ENDIF(shader);
+
+   ureg_release_temporary(shader, tmp);
+
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, r->pipe);
+}
+
+static bool
+init_pipe_state(struct vl_mc *r)
+{
+   struct pipe_sampler_state sampler;
+   struct pipe_blend_state blend;
+   struct pipe_rasterizer_state rs_state;
+   unsigned i;
+
+   assert(r);
+
+   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_BORDER;
+   sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
+   sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+   sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
+   sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
+   sampler.compare_func = PIPE_FUNC_ALWAYS;
+   sampler.normalized_coords = 1;
+   r->sampler_ref = r->pipe->create_sampler_state(r->pipe, &sampler);
+   if (!r->sampler_ref)
+      goto error_sampler_ref;
+
+   for (i = 0; i < VL_MC_NUM_BLENDERS; ++i) {
+      memset(&blend, 0, sizeof blend);
+      blend.independent_blend_enable = 0;
+      blend.rt[0].blend_enable = 1;
+      blend.rt[0].rgb_func = PIPE_BLEND_ADD;
+      blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA;
+      blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.rt[0].alpha_func = PIPE_BLEND_ADD;
+      blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA;
+      blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+      blend.logicop_enable = 0;
+      blend.logicop_func = PIPE_LOGICOP_CLEAR;
+      blend.rt[0].colormask = i;
+      blend.dither = 0;
+      r->blend_clear[i] = r->pipe->create_blend_state(r->pipe, &blend);
+      if (!r->blend_clear[i])
+         goto error_blend;
+
+      blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
+      blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+      r->blend_add[i] = r->pipe->create_blend_state(r->pipe, &blend);
+      if (!r->blend_add[i])
+         goto error_blend;
+
+      blend.rt[0].rgb_func = PIPE_BLEND_REVERSE_SUBTRACT;
+      blend.rt[0].alpha_dst_factor = PIPE_BLEND_REVERSE_SUBTRACT;
+      r->blend_sub[i] = r->pipe->create_blend_state(r->pipe, &blend);
+      if (!r->blend_sub[i])
+         goto error_blend;
+   }
+
+   memset(&rs_state, 0, sizeof(rs_state));
+   /*rs_state.sprite_coord_enable */
+   rs_state.sprite_coord_mode = PIPE_SPRITE_COORD_UPPER_LEFT;
+   rs_state.point_quad_rasterization = true;
+   rs_state.point_size = BLOCK_WIDTH;
+   rs_state.gl_rasterization_rules = true;
+   r->rs_state = r->pipe->create_rasterizer_state(r->pipe, &rs_state);
+   if (!r->rs_state)
+      goto error_rs_state;
+
+   return true;
+
+error_rs_state:
+error_blend:
+   for (i = 0; i < VL_MC_NUM_BLENDERS; ++i) {
+      if (r->blend_sub[i])
+         r->pipe->delete_blend_state(r->pipe, r->blend_sub[i]);
+
+      if (r->blend_add[i])
+         r->pipe->delete_blend_state(r->pipe, r->blend_add[i]);
+
+      if (r->blend_clear[i])
+         r->pipe->delete_blend_state(r->pipe, r->blend_clear[i]);
+   }
+
+   r->pipe->delete_sampler_state(r->pipe, r->sampler_ref);
+
+error_sampler_ref:
+   return false;
+}
+
+static void
+cleanup_pipe_state(struct vl_mc *r)
+{
+   unsigned i;
+
+   assert(r);
+
+   r->pipe->delete_sampler_state(r->pipe, r->sampler_ref);
+   for (i = 0; i < VL_MC_NUM_BLENDERS; ++i) {
+      r->pipe->delete_blend_state(r->pipe, r->blend_clear[i]);
+      r->pipe->delete_blend_state(r->pipe, r->blend_add[i]);
+      r->pipe->delete_blend_state(r->pipe, r->blend_sub[i]);
+   }
+   r->pipe->delete_rasterizer_state(r->pipe, r->rs_state);
+}
+
+bool
+vl_mc_init(struct vl_mc *renderer, struct pipe_context *pipe,
+           unsigned buffer_width, unsigned buffer_height,
+           unsigned macroblock_size, float scale,
+           vl_mc_ycbcr_vert_shader vs_callback,
+           vl_mc_ycbcr_frag_shader fs_callback,
+           void *callback_priv)
+{
+   assert(renderer);
+   assert(pipe);
+
+   memset(renderer, 0, sizeof(struct vl_mc));
+
+   renderer->pipe = pipe;
+   renderer->buffer_width = buffer_width;
+   renderer->buffer_height = buffer_height;
+   renderer->macroblock_size = macroblock_size;
+
+   if (!init_pipe_state(renderer))
+      goto error_pipe_state;
+
+   renderer->vs_ref = create_ref_vert_shader(renderer);
+   if (!renderer->vs_ref)
+      goto error_vs_ref;
+
+   renderer->vs_ycbcr = create_ycbcr_vert_shader(renderer, vs_callback, callback_priv);
+   if (!renderer->vs_ycbcr)
+      goto error_vs_ycbcr;
+
+   renderer->fs_ref = create_ref_frag_shader(renderer);
+   if (!renderer->fs_ref)
+      goto error_fs_ref;
+
+   renderer->fs_ycbcr = create_ycbcr_frag_shader(renderer, scale, false, fs_callback, callback_priv);
+   if (!renderer->fs_ycbcr)
+      goto error_fs_ycbcr;
+
+   renderer->fs_ycbcr_sub = create_ycbcr_frag_shader(renderer, scale, true, fs_callback, callback_priv);
+   if (!renderer->fs_ycbcr_sub)
+      goto error_fs_ycbcr_sub;
+
+   return true;
+   
+error_fs_ycbcr_sub:
+   renderer->pipe->delete_fs_state(renderer->pipe, renderer->fs_ycbcr);
+
+error_fs_ycbcr:
+   renderer->pipe->delete_fs_state(renderer->pipe, renderer->fs_ref);
+
+error_fs_ref:
+   renderer->pipe->delete_vs_state(renderer->pipe, renderer->vs_ycbcr);
+
+error_vs_ycbcr:
+   renderer->pipe->delete_vs_state(renderer->pipe, renderer->vs_ref);
+
+error_vs_ref:
+   cleanup_pipe_state(renderer);
+
+error_pipe_state:
+   return false;
+}
+
+void
+vl_mc_cleanup(struct vl_mc *renderer)
+{
+   assert(renderer);
+
+   cleanup_pipe_state(renderer);
+
+   renderer->pipe->delete_vs_state(renderer->pipe, renderer->vs_ref);
+   renderer->pipe->delete_vs_state(renderer->pipe, renderer->vs_ycbcr);
+   renderer->pipe->delete_fs_state(renderer->pipe, renderer->fs_ref);
+   renderer->pipe->delete_fs_state(renderer->pipe, renderer->fs_ycbcr);
+   renderer->pipe->delete_fs_state(renderer->pipe, renderer->fs_ycbcr_sub);
+}
+
+bool
+vl_mc_init_buffer(struct vl_mc *renderer, struct vl_mc_buffer *buffer)
+{
+   assert(renderer && buffer);
+
+   buffer->renderer = renderer;
+
+   buffer->viewport.scale[2] = 1;
+   buffer->viewport.scale[3] = 1;
+   buffer->viewport.translate[0] = 0;
+   buffer->viewport.translate[1] = 0;
+   buffer->viewport.translate[2] = 0;
+   buffer->viewport.translate[3] = 0;
+
+   buffer->fb_state.nr_cbufs = 1;
+   buffer->fb_state.zsbuf = NULL;
+
+   return true;
+}
+
+void
+vl_mc_cleanup_buffer(struct vl_mc_buffer *buffer)
+{
+   assert(buffer);
+}
+
+void
+vl_mc_set_surface(struct vl_mc_buffer *buffer, struct pipe_surface *surface)
+{
+   assert(buffer && surface);
+
+   buffer->surface_cleared = false;
+
+   buffer->viewport.scale[0] = surface->width;
+   buffer->viewport.scale[1] = surface->height;
+
+   buffer->fb_state.width = surface->width;
+   buffer->fb_state.height = surface->height;
+   buffer->fb_state.cbufs[0] = surface;
+}
+
+static void
+prepare_pipe_4_rendering(struct vl_mc_buffer *buffer, unsigned mask)
+{
+   struct vl_mc *renderer;
+
+   assert(buffer);
+
+   renderer = buffer->renderer;
+   renderer->pipe->bind_rasterizer_state(renderer->pipe, renderer->rs_state);
+
+   if (buffer->surface_cleared)
+      renderer->pipe->bind_blend_state(renderer->pipe, renderer->blend_add[mask]);
+   else
+      renderer->pipe->bind_blend_state(renderer->pipe, renderer->blend_clear[mask]);
+
+   renderer->pipe->set_framebuffer_state(renderer->pipe, &buffer->fb_state);
+   renderer->pipe->set_viewport_state(renderer->pipe, &buffer->viewport);
+}
+
+void
+vl_mc_render_ref(struct vl_mc_buffer *buffer, struct pipe_sampler_view *ref)
+{
+   struct vl_mc *renderer;
+
+   assert(buffer && ref);
+
+   prepare_pipe_4_rendering(buffer, PIPE_MASK_R | PIPE_MASK_G | PIPE_MASK_B);
+
+   renderer = buffer->renderer;
+
+   renderer->pipe->bind_vs_state(renderer->pipe, renderer->vs_ref);
+   renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs_ref);
+
+   renderer->pipe->set_fragment_sampler_views(renderer->pipe, 1, &ref);
+   renderer->pipe->bind_fragment_sampler_states(renderer->pipe, 1, &renderer->sampler_ref);
+
+   util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, 0,
+                              renderer->buffer_width / MACROBLOCK_WIDTH *
+                              renderer->buffer_height / MACROBLOCK_HEIGHT);
+
+   buffer->surface_cleared = true;
+}
+
+void
+vl_mc_render_ycbcr(struct vl_mc_buffer *buffer, unsigned component, unsigned num_instances)
+{
+   struct vl_mc *renderer;
+   unsigned mask = 1 << component;
+
+   assert(buffer);
+
+   if (num_instances == 0)
+      return;
+
+   prepare_pipe_4_rendering(buffer, mask);
+
+   renderer = buffer->renderer;
+
+   renderer->pipe->bind_vs_state(renderer->pipe, renderer->vs_ycbcr);
+   renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs_ycbcr);
+
+   util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_instances);
+   
+   if (buffer->surface_cleared) {
+      renderer->pipe->bind_blend_state(renderer->pipe, renderer->blend_sub[mask]);
+      renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs_ycbcr_sub);
+      util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_instances);
+   }
+}
diff --git a/src/gallium/auxiliary/vl/vl_mc.h b/src/gallium/auxiliary/vl/vl_mc.h
new file mode 100644 (file)
index 0000000..9fabf02
--- /dev/null
@@ -0,0 +1,99 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_mc_h
+#define vl_mc_h
+
+#include <pipe/p_state.h>
+#include <pipe/p_video_state.h>
+
+#include <tgsi/tgsi_ureg.h>
+
+#include "vl_defines.h"
+#include "vl_types.h"
+
+#define VL_MC_NUM_BLENDERS (1 << VL_MAX_PLANES)
+
+struct pipe_context;
+
+struct vl_mc
+{
+   struct pipe_context *pipe;
+   unsigned buffer_width;
+   unsigned buffer_height;
+   unsigned macroblock_size;
+
+   void *rs_state;
+
+   void *blend_clear[VL_MC_NUM_BLENDERS];
+   void *blend_add[VL_MC_NUM_BLENDERS];
+   void *blend_sub[VL_MC_NUM_BLENDERS];
+   void *vs_ref, *vs_ycbcr;
+   void *fs_ref, *fs_ycbcr, *fs_ycbcr_sub;
+   void *sampler_ref;
+};
+
+struct vl_mc_buffer
+{
+   struct vl_mc *renderer;
+
+   bool surface_cleared;
+
+   struct pipe_viewport_state viewport;
+   struct pipe_framebuffer_state fb_state;
+};
+
+typedef void (*vl_mc_ycbcr_vert_shader)(void *priv, struct vl_mc *mc,
+                                        struct ureg_program *shader,
+                                        unsigned first_output,
+                                        struct ureg_dst tex);
+
+typedef void (*vl_mc_ycbcr_frag_shader)(void *priv, struct vl_mc *mc,
+                                        struct ureg_program *shader,
+                                        unsigned first_input,
+                                        struct ureg_dst dst);
+
+bool vl_mc_init(struct vl_mc *renderer, struct pipe_context *pipe,
+                unsigned picture_width, unsigned picture_height,
+                unsigned macroblock_size, float scale,
+                vl_mc_ycbcr_vert_shader vs_callback,
+                vl_mc_ycbcr_frag_shader fs_callback,
+                void *callback_priv);
+
+void vl_mc_cleanup(struct vl_mc *renderer);
+
+bool vl_mc_init_buffer(struct vl_mc *renderer, struct vl_mc_buffer *buffer);
+
+void vl_mc_cleanup_buffer(struct vl_mc_buffer *buffer);
+
+void vl_mc_set_surface(struct vl_mc_buffer *buffer, struct pipe_surface *surface);
+
+void vl_mc_render_ref(struct vl_mc_buffer *buffer, struct pipe_sampler_view *ref);
+
+void vl_mc_render_ycbcr(struct vl_mc_buffer *buffer, unsigned component, unsigned num_instances);
+
+#endif /* vl_mc_h */
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c
new file mode 100644 (file)
index 0000000..9dd032e
--- /dev/null
@@ -0,0 +1,1837 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Christian König.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+
+/**
+ * This file is based uppon slice_xvmc.c and vlc.h from the xine project,
+ * which in turn is based on mpeg2dec. The following is the original copyright:
+ *
+ * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+ * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+ *
+ * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
+ * See http://libmpeg2.sourceforge.net/ for updates.
+ *
+ * mpeg2dec is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * mpeg2dec is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdint.h>
+
+#include <pipe/p_compiler.h>
+#include <pipe/p_video_state.h>
+
+#include "vl_vlc.h"
+#include "vl_mpeg12_bitstream.h"
+
+/* take num bits from the high part of bit_buf and zero extend them */
+#define UBITS(buf,num) (((uint32_t)(buf)) >> (32 - (num)))
+
+/* take num bits from the high part of bit_buf and sign extend them */
+#define SBITS(buf,num) (((int32_t)(buf)) >> (32 - (num)))
+
+/* macroblock modes */
+#define MACROBLOCK_INTRA 1
+#define MACROBLOCK_PATTERN 2
+#define MACROBLOCK_MOTION_BACKWARD 4
+#define MACROBLOCK_MOTION_FORWARD 8
+#define MACROBLOCK_QUANT 16
+
+/* motion_type */
+#define MOTION_TYPE_MASK (3*64)
+#define MOTION_TYPE_BASE 64
+#define MC_FIELD (1*64)
+#define MC_FRAME (2*64)
+#define MC_16X8 (2*64)
+#define MC_DMV (3*64)
+
+/* picture structure */
+#define TOP_FIELD     1
+#define BOTTOM_FIELD  2
+#define FRAME_PICTURE 3
+
+/* picture coding type (mpeg2 header) */
+#define I_TYPE 1
+#define P_TYPE 2
+#define B_TYPE 3
+#define D_TYPE 4
+
+typedef struct {
+   uint8_t modes;
+   uint8_t len;
+} MBtab;
+
+typedef struct {
+   uint8_t delta;
+   uint8_t len;
+} MVtab;
+
+typedef struct {
+   int8_t dmv;
+   uint8_t len;
+} DMVtab;
+
+typedef struct {
+   uint8_t cbp;
+   uint8_t len;
+} CBPtab;
+
+typedef struct {
+   uint8_t size;
+   uint8_t len;
+} DCtab;
+
+typedef struct {
+   uint8_t run;
+   uint8_t level;
+   uint8_t len;
+} DCTtab;
+
+typedef struct {
+   uint8_t mba;
+   uint8_t len;
+} MBAtab;
+
+#define INTRA MACROBLOCK_INTRA
+#define QUANT MACROBLOCK_QUANT
+#define MC MACROBLOCK_MOTION_FORWARD
+#define CODED MACROBLOCK_PATTERN
+#define FWD MACROBLOCK_MOTION_FORWARD
+#define BWD MACROBLOCK_MOTION_BACKWARD
+#define INTER MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD
+
+static const MBtab MB_I [] = {
+   {INTRA|QUANT, 2}, {INTRA, 1}
+};
+
+static const MBtab MB_P [] = {
+   {INTRA|QUANT, 6}, {CODED|QUANT, 5}, {MC|CODED|QUANT, 5}, {INTRA,    5},
+   {MC,          3}, {MC,          3}, {MC,             3}, {MC,       3},
+   {CODED,       2}, {CODED,       2}, {CODED,          2}, {CODED,    2},
+   {CODED,       2}, {CODED,       2}, {CODED,          2}, {CODED,    2},
+   {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
+   {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
+   {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
+   {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1}
+};
+
+static const MBtab MB_B [] = {
+   {0,                 0}, {INTRA|QUANT,       6},
+   {BWD|CODED|QUANT,   6}, {FWD|CODED|QUANT,   6},
+   {INTER|CODED|QUANT, 5}, {INTER|CODED|QUANT, 5},
+                                     {INTRA,       5}, {INTRA,       5},
+   {FWD,         4}, {FWD,         4}, {FWD,         4}, {FWD,         4},
+   {FWD|CODED,   4}, {FWD|CODED,   4}, {FWD|CODED,   4}, {FWD|CODED,   4},
+   {BWD,         3}, {BWD,         3}, {BWD,         3}, {BWD,         3},
+   {BWD,         3}, {BWD,         3}, {BWD,         3}, {BWD,         3},
+   {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3},
+   {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3},
+   {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
+   {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
+   {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
+   {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
+   {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
+   {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
+   {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
+   {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}
+};
+
+#undef INTRA
+#undef QUANT
+#undef MC
+#undef CODED
+#undef FWD
+#undef BWD
+#undef INTER
+
+static const MVtab MV_4 [] = {
+   { 3, 6}, { 2, 4}, { 1, 3}, { 1, 3}, { 0, 2}, { 0, 2}, { 0, 2}, { 0, 2}
+};
+
+static const MVtab MV_10 [] = {
+   { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10},
+   { 0,10}, { 0,10}, { 0,10}, { 0,10}, {15,10}, {14,10}, {13,10}, {12,10},
+   {11,10}, {10,10}, { 9, 9}, { 9, 9}, { 8, 9}, { 8, 9}, { 7, 9}, { 7, 9},
+   { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7},
+   { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7},
+   { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}
+};
+
+static const DMVtab DMV_2 [] = {
+   { 0, 1}, { 0, 1}, { 1, 2}, {-1, 2}
+};
+
+static const CBPtab CBP_7 [] = {
+   {0x22, 7}, {0x12, 7}, {0x0a, 7}, {0x06, 7},
+   {0x21, 7}, {0x11, 7}, {0x09, 7}, {0x05, 7},
+   {0x3f, 6}, {0x3f, 6}, {0x03, 6}, {0x03, 6},
+   {0x24, 6}, {0x24, 6}, {0x18, 6}, {0x18, 6},
+   {0x3e, 5}, {0x3e, 5}, {0x3e, 5}, {0x3e, 5},
+   {0x02, 5}, {0x02, 5}, {0x02, 5}, {0x02, 5},
+   {0x3d, 5}, {0x3d, 5}, {0x3d, 5}, {0x3d, 5},
+   {0x01, 5}, {0x01, 5}, {0x01, 5}, {0x01, 5},
+   {0x38, 5}, {0x38, 5}, {0x38, 5}, {0x38, 5},
+   {0x34, 5}, {0x34, 5}, {0x34, 5}, {0x34, 5},
+   {0x2c, 5}, {0x2c, 5}, {0x2c, 5}, {0x2c, 5},
+   {0x1c, 5}, {0x1c, 5}, {0x1c, 5}, {0x1c, 5},
+   {0x28, 5}, {0x28, 5}, {0x28, 5}, {0x28, 5},
+   {0x14, 5}, {0x14, 5}, {0x14, 5}, {0x14, 5},
+   {0x30, 5}, {0x30, 5}, {0x30, 5}, {0x30, 5},
+   {0x0c, 5}, {0x0c, 5}, {0x0c, 5}, {0x0c, 5},
+   {0x20, 4}, {0x20, 4}, {0x20, 4}, {0x20, 4},
+   {0x20, 4}, {0x20, 4}, {0x20, 4}, {0x20, 4},
+   {0x10, 4}, {0x10, 4}, {0x10, 4}, {0x10, 4},
+   {0x10, 4}, {0x10, 4}, {0x10, 4}, {0x10, 4},
+   {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
+   {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
+   {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
+   {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
+   {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
+   {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
+   {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
+   {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3}
+};
+
+static const CBPtab CBP_9 [] = {
+   {0,    0}, {0x00, 9}, {0x27, 9}, {0x1b, 9},
+   {0x3b, 9}, {0x37, 9}, {0x2f, 9}, {0x1f, 9},
+   {0x3a, 8}, {0x3a, 8}, {0x36, 8}, {0x36, 8},
+   {0x2e, 8}, {0x2e, 8}, {0x1e, 8}, {0x1e, 8},
+   {0x39, 8}, {0x39, 8}, {0x35, 8}, {0x35, 8},
+   {0x2d, 8}, {0x2d, 8}, {0x1d, 8}, {0x1d, 8},
+   {0x26, 8}, {0x26, 8}, {0x1a, 8}, {0x1a, 8},
+   {0x25, 8}, {0x25, 8}, {0x19, 8}, {0x19, 8},
+   {0x2b, 8}, {0x2b, 8}, {0x17, 8}, {0x17, 8},
+   {0x33, 8}, {0x33, 8}, {0x0f, 8}, {0x0f, 8},
+   {0x2a, 8}, {0x2a, 8}, {0x16, 8}, {0x16, 8},
+   {0x32, 8}, {0x32, 8}, {0x0e, 8}, {0x0e, 8},
+   {0x29, 8}, {0x29, 8}, {0x15, 8}, {0x15, 8},
+   {0x31, 8}, {0x31, 8}, {0x0d, 8}, {0x0d, 8},
+   {0x23, 8}, {0x23, 8}, {0x13, 8}, {0x13, 8},
+   {0x0b, 8}, {0x0b, 8}, {0x07, 8}, {0x07, 8}
+};
+
+static const DCtab DC_lum_5 [] = {
+   {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
+   {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
+   {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
+   {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}
+};
+
+static const DCtab DC_chrom_5 [] = {
+   {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
+   {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
+   {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
+   {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}
+};
+
+static const DCtab DC_long [] = {
+   {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
+   {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
+   {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, { 7, 6}, { 7, 6},
+   {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
+};
+
+static const DCTtab DCT_16 [] = {
+   {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
+   {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
+   {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
+   {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
+   {  2,18, 0}, {  2,17, 0}, {  2,16, 0}, {  2,15, 0},
+   {  7, 3, 0}, { 17, 2, 0}, { 16, 2, 0}, { 15, 2, 0},
+   { 14, 2, 0}, { 13, 2, 0}, { 12, 2, 0}, { 32, 1, 0},
+   { 31, 1, 0}, { 30, 1, 0}, { 29, 1, 0}, { 28, 1, 0}
+};
+
+static const DCTtab DCT_15 [] = {
+   {  1,40,15}, {  1,39,15}, {  1,38,15}, {  1,37,15},
+   {  1,36,15}, {  1,35,15}, {  1,34,15}, {  1,33,15},
+   {  1,32,15}, {  2,14,15}, {  2,13,15}, {  2,12,15},
+   {  2,11,15}, {  2,10,15}, {  2, 9,15}, {  2, 8,15},
+   {  1,31,14}, {  1,31,14}, {  1,30,14}, {  1,30,14},
+   {  1,29,14}, {  1,29,14}, {  1,28,14}, {  1,28,14},
+   {  1,27,14}, {  1,27,14}, {  1,26,14}, {  1,26,14},
+   {  1,25,14}, {  1,25,14}, {  1,24,14}, {  1,24,14},
+   {  1,23,14}, {  1,23,14}, {  1,22,14}, {  1,22,14},
+   {  1,21,14}, {  1,21,14}, {  1,20,14}, {  1,20,14},
+   {  1,19,14}, {  1,19,14}, {  1,18,14}, {  1,18,14},
+   {  1,17,14}, {  1,17,14}, {  1,16,14}, {  1,16,14}
+};
+
+static const DCTtab DCT_13 [] = {
+   { 11, 2,13}, { 10, 2,13}, {  6, 3,13}, {  4, 4,13},
+   {  3, 5,13}, {  2, 7,13}, {  2, 6,13}, {  1,15,13},
+   {  1,14,13}, {  1,13,13}, {  1,12,13}, { 27, 1,13},
+   { 26, 1,13}, { 25, 1,13}, { 24, 1,13}, { 23, 1,13},
+   {  1,11,12}, {  1,11,12}, {  9, 2,12}, {  9, 2,12},
+   {  5, 3,12}, {  5, 3,12}, {  1,10,12}, {  1,10,12},
+   {  3, 4,12}, {  3, 4,12}, {  8, 2,12}, {  8, 2,12},
+   { 22, 1,12}, { 22, 1,12}, { 21, 1,12}, { 21, 1,12},
+   {  1, 9,12}, {  1, 9,12}, { 20, 1,12}, { 20, 1,12},
+   { 19, 1,12}, { 19, 1,12}, {  2, 5,12}, {  2, 5,12},
+   {  4, 3,12}, {  4, 3,12}, {  1, 8,12}, {  1, 8,12},
+   {  7, 2,12}, {  7, 2,12}, { 18, 1,12}, { 18, 1,12}
+};
+
+static const DCTtab DCT_B14_10 [] = {
+   { 17, 1,10}, {  6, 2,10}, {  1, 7,10}, {  3, 3,10},
+   {  2, 4,10}, { 16, 1,10}, { 15, 1,10}, {  5, 2,10}
+};
+
+static const DCTtab DCT_B14_8 [] = {
+   { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
+   {  3, 2, 7}, {  3, 2, 7}, { 10, 1, 7}, { 10, 1, 7},
+   {  1, 4, 7}, {  1, 4, 7}, {  9, 1, 7}, {  9, 1, 7},
+   {  8, 1, 6}, {  8, 1, 6}, {  8, 1, 6}, {  8, 1, 6},
+   {  7, 1, 6}, {  7, 1, 6}, {  7, 1, 6}, {  7, 1, 6},
+   {  2, 2, 6}, {  2, 2, 6}, {  2, 2, 6}, {  2, 2, 6},
+   {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6},
+   { 14, 1, 8}, {  1, 6, 8}, { 13, 1, 8}, { 12, 1, 8},
+   {  4, 2, 8}, {  2, 3, 8}, {  1, 5, 8}, { 11, 1, 8}
+};
+
+static const DCTtab DCT_B14AC_5 [] = {
+                {  1, 3, 5}, {  5, 1, 5}, {  4, 1, 5},
+   {  1, 2, 4}, {  1, 2, 4}, {  3, 1, 4}, {  3, 1, 4},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
+   {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}
+};
+
+static const DCTtab DCT_B14DC_5 [] = {
+                {  1, 3, 5}, {  5, 1, 5}, {  4, 1, 5},
+   {  1, 2, 4}, {  1, 2, 4}, {  3, 1, 4}, {  3, 1, 4},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
+   {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
+   {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
+   {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}
+};
+
+static const DCTtab DCT_B15_10 [] = {
+   {  6, 2, 9}, {  6, 2, 9}, { 15, 1, 9}, { 15, 1, 9},
+   {  3, 4,10}, { 17, 1,10}, { 16, 1, 9}, { 16, 1, 9}
+};
+
+static const DCTtab DCT_B15_8 [] = {
+   { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
+   {  8, 1, 7}, {  8, 1, 7}, {  9, 1, 7}, {  9, 1, 7},
+   {  7, 1, 7}, {  7, 1, 7}, {  3, 2, 7}, {  3, 2, 7},
+   {  1, 7, 6}, {  1, 7, 6}, {  1, 7, 6}, {  1, 7, 6},
+   {  1, 6, 6}, {  1, 6, 6}, {  1, 6, 6}, {  1, 6, 6},
+   {  5, 1, 6}, {  5, 1, 6}, {  5, 1, 6}, {  5, 1, 6},
+   {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6},
+   {  2, 5, 8}, { 12, 1, 8}, {  1,11, 8}, {  1,10, 8},
+   { 14, 1, 8}, { 13, 1, 8}, {  4, 2, 8}, {  2, 4, 8},
+   {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5},
+   {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5},
+   {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5},
+   {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5},
+   {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5},
+   {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
+   {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
+   {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
+   {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
+   {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
+   {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
+   {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
+   {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
+   {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
+   {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
+   {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
+   {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
+   {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
+   {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
+   {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
+   {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
+   {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
+   {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5},
+   {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5},
+   {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5},
+   {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5},
+   { 10, 1, 7}, { 10, 1, 7}, {  2, 3, 7}, {  2, 3, 7},
+   { 11, 1, 7}, { 11, 1, 7}, {  1, 8, 7}, {  1, 8, 7},
+   {  1, 9, 7}, {  1, 9, 7}, {  1,12, 8}, {  1,13, 8},
+   {  3, 3, 8}, {  5, 2, 8}, {  1,14, 8}, {  1,15, 8}
+};
+
+static const MBAtab MBA_5 [] = {
+                   {6, 5}, {5, 5}, {4, 4}, {4, 4}, {3, 4}, {3, 4},
+   {2, 3}, {2, 3}, {2, 3}, {2, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
+   {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1},
+   {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}
+};
+
+static const MBAtab MBA_11 [] = {
+   {32, 11}, {31, 11}, {30, 11}, {29, 11},
+   {28, 11}, {27, 11}, {26, 11}, {25, 11},
+   {24, 11}, {23, 11}, {22, 11}, {21, 11},
+   {20, 10}, {20, 10}, {19, 10}, {19, 10},
+   {18, 10}, {18, 10}, {17, 10}, {17, 10},
+   {16, 10}, {16, 10}, {15, 10}, {15, 10},
+   {14,  8}, {14,  8}, {14,  8}, {14,  8},
+   {14,  8}, {14,  8}, {14,  8}, {14,  8},
+   {13,  8}, {13,  8}, {13,  8}, {13,  8},
+   {13,  8}, {13,  8}, {13,  8}, {13,  8},
+   {12,  8}, {12,  8}, {12,  8}, {12,  8},
+   {12,  8}, {12,  8}, {12,  8}, {12,  8},
+   {11,  8}, {11,  8}, {11,  8}, {11,  8},
+   {11,  8}, {11,  8}, {11,  8}, {11,  8},
+   {10,  8}, {10,  8}, {10,  8}, {10,  8},
+   {10,  8}, {10,  8}, {10,  8}, {10,  8},
+   { 9,  8}, { 9,  8}, { 9,  8}, { 9,  8},
+   { 9,  8}, { 9,  8}, { 9,  8}, { 9,  8},
+   { 8,  7}, { 8,  7}, { 8,  7}, { 8,  7},
+   { 8,  7}, { 8,  7}, { 8,  7}, { 8,  7},
+   { 8,  7}, { 8,  7}, { 8,  7}, { 8,  7},
+   { 8,  7}, { 8,  7}, { 8,  7}, { 8,  7},
+   { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7},
+   { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7},
+   { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7},
+   { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7}
+};
+
+static const int non_linear_quantizer_scale[] = {
+   0,  1,  2,  3,  4,  5,   6,   7,
+   8, 10, 12, 14, 16, 18,  20,  22,
+   24, 28, 32, 36, 40, 44,  48,  52,
+   56, 64, 72, 80, 88, 96, 104, 112
+};
+
+static INLINE int
+get_macroblock_modes(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture)
+{
+   int macroblock_modes;
+   const MBtab * tab;
+
+   switch (picture->picture_coding_type) {
+   case I_TYPE:
+
+      tab = MB_I + vl_vlc_ubits(&bs->vlc, 1);
+      vl_vlc_dumpbits(&bs->vlc, tab->len);
+      macroblock_modes = tab->modes;
+
+      return macroblock_modes;
+
+   case P_TYPE:
+
+      tab = MB_P + vl_vlc_ubits(&bs->vlc, 5);
+      vl_vlc_dumpbits(&bs->vlc, tab->len);
+      macroblock_modes = tab->modes;
+
+      if (picture->picture_structure != FRAME_PICTURE) {
+         if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) {
+            macroblock_modes |= vl_vlc_ubits(&bs->vlc, 2) * MOTION_TYPE_BASE;
+            vl_vlc_dumpbits(&bs->vlc, 2);
+          }
+          return macroblock_modes;
+      } else if (picture->frame_pred_frame_dct) {
+          if (macroblock_modes & MACROBLOCK_MOTION_FORWARD)
+            macroblock_modes |= MC_FRAME;
+          return macroblock_modes;
+      } else {
+          if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) {
+            macroblock_modes |= vl_vlc_ubits(&bs->vlc, 2) * MOTION_TYPE_BASE;
+            vl_vlc_dumpbits(&bs->vlc, 2);
+          }
+          return macroblock_modes;
+      }
+
+   case B_TYPE:
+
+      tab = MB_B + vl_vlc_ubits(&bs->vlc, 6);
+      vl_vlc_dumpbits(&bs->vlc, tab->len);
+      macroblock_modes = tab->modes;
+
+      if (picture->picture_structure != FRAME_PICTURE) {
+          if (! (macroblock_modes & MACROBLOCK_INTRA)) {
+            macroblock_modes |= vl_vlc_ubits(&bs->vlc, 2) * MOTION_TYPE_BASE;
+            vl_vlc_dumpbits(&bs->vlc, 2);
+          }
+      } else if (picture->frame_pred_frame_dct) {
+          macroblock_modes |= MC_FRAME;
+      } else if (!(macroblock_modes & MACROBLOCK_INTRA)) {
+          macroblock_modes |= vl_vlc_ubits(&bs->vlc, 2) * MOTION_TYPE_BASE;
+          vl_vlc_dumpbits(&bs->vlc, 2);
+      }
+      return macroblock_modes;
+
+   case D_TYPE:
+
+      vl_vlc_dumpbits(&bs->vlc, 1);
+      return MACROBLOCK_INTRA;
+
+   default:
+      return 0;
+   }
+}
+
+static INLINE enum pipe_mpeg12_dct_type
+get_dct_type(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, int macroblock_modes)
+{
+   enum pipe_mpeg12_dct_type dct_type = PIPE_MPEG12_DCT_TYPE_FRAME;
+
+   if ((picture->picture_structure == FRAME_PICTURE) &&
+       (!picture->frame_pred_frame_dct) &&
+       (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN))) {
+
+      dct_type = vl_vlc_ubits(&bs->vlc, 1) ? PIPE_MPEG12_DCT_TYPE_FIELD : PIPE_MPEG12_DCT_TYPE_FRAME;
+      vl_vlc_dumpbits(&bs->vlc, 1);
+   }
+   return dct_type;
+}
+
+static INLINE int
+get_quantizer_scale(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture)
+{
+   int quantizer_scale_code;
+
+   quantizer_scale_code = vl_vlc_ubits(&bs->vlc, 5);
+   vl_vlc_dumpbits(&bs->vlc, 5);
+
+   if (picture->q_scale_type)
+      return non_linear_quantizer_scale[quantizer_scale_code];
+   else
+      return quantizer_scale_code << 1;
+}
+
+static INLINE int
+get_motion_delta(struct vl_mpg12_bs *bs, unsigned f_code)
+{
+   int delta;
+   int sign;
+   const MVtab * tab;
+
+   if (bs->vlc.buf & 0x80000000) {
+      vl_vlc_dumpbits(&bs->vlc, 1);
+      return 0;
+   } else if (bs->vlc.buf >= 0x0c000000) {
+
+      tab = MV_4 + vl_vlc_ubits(&bs->vlc, 4);
+      delta = (tab->delta << f_code) + 1;
+      bs->vlc.bits += tab->len + f_code + 1;
+      bs->vlc.buf <<= tab->len;
+
+      sign = vl_vlc_sbits(&bs->vlc, 1);
+      bs->vlc.buf <<= 1;
+
+      if (f_code)
+         delta += vl_vlc_ubits(&bs->vlc, f_code);
+      bs->vlc.buf <<= f_code;
+
+      return (delta ^ sign) - sign;
+
+   } else {
+
+      tab = MV_10 + vl_vlc_ubits(&bs->vlc, 10);
+      delta = (tab->delta << f_code) + 1;
+      bs->vlc.bits += tab->len + 1;
+      bs->vlc.buf <<= tab->len;
+
+      sign = vl_vlc_sbits(&bs->vlc, 1);
+      bs->vlc.buf <<= 1;
+
+      if (f_code) {
+         vl_vlc_needbits(&bs->vlc);
+         delta += vl_vlc_ubits(&bs->vlc, f_code);
+         vl_vlc_dumpbits(&bs->vlc, f_code);
+      }
+
+      return (delta ^ sign) - sign;
+   }
+}
+
+static INLINE int
+bound_motion_vector(int vec, unsigned f_code)
+{
+#if 1
+   unsigned int limit;
+   int sign;
+
+   limit = 16 << f_code;
+
+   if ((unsigned int)(vec + limit) < 2 * limit)
+      return vec;
+   else {
+      sign = ((int32_t)vec) >> 31;
+      return vec - ((2 * limit) ^ sign) + sign;
+   }
+#else
+   return ((int32_t)vec << (28 - f_code)) >> (28 - f_code);
+#endif
+}
+
+static INLINE int
+get_dmv(struct vl_mpg12_bs *bs)
+{
+   const DMVtab * tab;
+
+   tab = DMV_2 + vl_vlc_ubits(&bs->vlc, 2);
+   vl_vlc_dumpbits(&bs->vlc, tab->len);
+   return tab->dmv;
+}
+
+static INLINE int
+get_coded_block_pattern(struct vl_mpg12_bs *bs)
+{
+   const CBPtab * tab;
+
+   vl_vlc_needbits(&bs->vlc);
+
+   if (bs->vlc.buf >= 0x20000000) {
+
+      tab = CBP_7 + (vl_vlc_ubits(&bs->vlc, 7) - 16);
+      vl_vlc_dumpbits(&bs->vlc, tab->len);
+      return tab->cbp;
+
+   } else {
+
+      tab = CBP_9 + vl_vlc_ubits(&bs->vlc, 9);
+      vl_vlc_dumpbits(&bs->vlc, tab->len);
+      return tab->cbp;
+   }
+}
+
+static INLINE int
+get_luma_dc_dct_diff(struct vl_mpg12_bs *bs)
+{
+   const DCtab * tab;
+   int size;
+   int dc_diff;
+
+   if (bs->vlc.buf < 0xf8000000) {
+      tab = DC_lum_5 + vl_vlc_ubits(&bs->vlc, 5);
+      size = tab->size;
+      if (size) {
+         bs->vlc.bits += tab->len + size;
+         bs->vlc.buf <<= tab->len;
+         dc_diff = vl_vlc_ubits(&bs->vlc, size) - UBITS (SBITS (~bs->vlc.buf, 1), size);
+         bs->vlc.buf <<= size;
+         return dc_diff;
+      } else {
+         vl_vlc_dumpbits(&bs->vlc, 3);
+         return 0;
+      }
+   } else {
+      tab = DC_long + (vl_vlc_ubits(&bs->vlc, 9) - 0x1e0);
+      size = tab->size;
+      vl_vlc_dumpbits(&bs->vlc, tab->len);
+      vl_vlc_needbits(&bs->vlc);
+      dc_diff = vl_vlc_ubits(&bs->vlc, size) - UBITS (SBITS (~bs->vlc.buf, 1), size);
+      vl_vlc_dumpbits(&bs->vlc, size);
+      return dc_diff;
+   }
+}
+
+static INLINE int
+get_chroma_dc_dct_diff(struct vl_mpg12_bs *bs)
+{
+   const DCtab * tab;
+   int size;
+   int dc_diff;
+
+   if (bs->vlc.buf < 0xf8000000) {
+      tab = DC_chrom_5 + vl_vlc_ubits(&bs->vlc, 5);
+      size = tab->size;
+      if (size) {
+         bs->vlc.bits += tab->len + size;
+         bs->vlc.buf <<= tab->len;
+         dc_diff = vl_vlc_ubits(&bs->vlc, size) - UBITS (SBITS (~bs->vlc.buf, 1), size);
+         bs->vlc.buf <<= size;
+         return dc_diff;
+      } else {
+         vl_vlc_dumpbits(&bs->vlc, 2);
+         return 0;
+      }
+   } else {
+      tab = DC_long + (vl_vlc_ubits(&bs->vlc, 10) - 0x3e0);
+      size = tab->size;
+      vl_vlc_dumpbits(&bs->vlc, tab->len + 1);
+      vl_vlc_needbits(&bs->vlc);
+      dc_diff = vl_vlc_ubits(&bs->vlc, size) - UBITS (SBITS (~bs->vlc.buf, 1), size);
+      vl_vlc_dumpbits(&bs->vlc, size);
+      return dc_diff;
+   }
+}
+
+static INLINE void
+get_intra_block_B14(struct vl_mpg12_bs *bs, int quantizer_scale, short *dest)
+{
+   int i, val;
+   const DCTtab *tab;
+
+   i = 0;
+
+   vl_vlc_needbits(&bs->vlc);
+
+   while (1) {
+      if (bs->vlc.buf >= 0x28000000) {
+
+         tab = DCT_B14AC_5 + (vl_vlc_ubits(&bs->vlc, 5) - 5);
+
+         i += tab->run;
+         if (i >= 64)
+            break;     /* end of block */
+
+      normal_code:
+         bs->vlc.buf <<= tab->len;
+         bs->vlc.bits += tab->len + 1;
+         val = tab->level * quantizer_scale;
+
+         val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1);
+
+         dest[i] = val;
+
+         bs->vlc.buf <<= 1;
+         vl_vlc_needbits(&bs->vlc);
+
+         continue;
+
+      } else if (bs->vlc.buf >= 0x04000000) {
+
+         tab = DCT_B14_8 + (vl_vlc_ubits(&bs->vlc, 8) - 4);
+
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+
+         /* escape code */
+
+         i += UBITS(bs->vlc.buf << 6, 6) - 64;
+         if (i >= 64)
+            break;     /* illegal, check needed to avoid buffer overflow */
+
+         vl_vlc_dumpbits(&bs->vlc, 12);
+         vl_vlc_needbits(&bs->vlc);
+         val = vl_vlc_sbits(&bs->vlc, 12) * quantizer_scale;
+
+         dest[i] = val;
+
+         vl_vlc_dumpbits(&bs->vlc, 12);
+         vl_vlc_needbits(&bs->vlc);
+
+         continue;
+
+      } else if (bs->vlc.buf >= 0x02000000) {
+         tab = DCT_B14_10 + (vl_vlc_ubits(&bs->vlc, 10) - 8);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00800000) {
+         tab = DCT_13 + (vl_vlc_ubits(&bs->vlc, 13) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00200000) {
+         tab = DCT_15 + (vl_vlc_ubits(&bs->vlc, 15) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else {
+         tab = DCT_16 + vl_vlc_ubits(&bs->vlc, 16);
+         bs->vlc.buf <<= 16;
+         vl_vlc_getword(&bs->vlc, bs->vlc.bits + 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      }
+      break;   /* illegal, check needed to avoid buffer overflow */
+   }
+
+   vl_vlc_dumpbits(&bs->vlc, 2);       /* dump end of block code */
+}
+
+static INLINE void
+get_intra_block_B15(struct vl_mpg12_bs *bs, int quantizer_scale, short *dest)
+{
+   int i, val;
+   const DCTtab * tab;
+
+   i = 0;
+
+   vl_vlc_needbits(&bs->vlc);
+
+   while (1) {
+      if (bs->vlc.buf >= 0x04000000) {
+
+         tab = DCT_B15_8 + (vl_vlc_ubits(&bs->vlc, 8) - 4);
+
+         i += tab->run;
+         if (i < 64) {
+
+         normal_code:
+            bs->vlc.buf <<= tab->len;
+            bs->vlc.bits += tab->len + 1;
+            val = tab->level * quantizer_scale;
+
+            val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1);
+
+            dest[i] = val;
+
+            bs->vlc.buf <<= 1;
+            vl_vlc_needbits(&bs->vlc);
+
+            continue;
+
+         } else {
+
+            /* end of block. I commented out this code because if we */
+            /* dont exit here we will still exit at the later test :) */
+
+            /* if (i >= 128) break;    */      /* end of block */
+
+            /* escape code */
+
+            i += UBITS(bs->vlc.buf << 6, 6) - 64;
+            if (i >= 64)
+                break; /* illegal, check against buffer overflow */
+
+            vl_vlc_dumpbits(&bs->vlc, 12);
+            vl_vlc_needbits(&bs->vlc);
+            val = vl_vlc_sbits(&bs->vlc, 12) * quantizer_scale;
+
+            dest[i] = val;
+
+            vl_vlc_dumpbits(&bs->vlc, 12);
+            vl_vlc_needbits(&bs->vlc);
+
+            continue;
+
+          }
+      } else if (bs->vlc.buf >= 0x02000000) {
+         tab = DCT_B15_10 + (vl_vlc_ubits(&bs->vlc, 10) - 8);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00800000) {
+         tab = DCT_13 + (vl_vlc_ubits(&bs->vlc, 13) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00200000) {
+         tab = DCT_15 + (vl_vlc_ubits(&bs->vlc, 15) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else {
+         tab = DCT_16 + vl_vlc_ubits(&bs->vlc, 16);
+         bs->vlc.buf <<= 16;
+         vl_vlc_getword(&bs->vlc, bs->vlc.bits + 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      }
+      break;   /* illegal, check needed to avoid buffer overflow */
+   }
+
+   vl_vlc_dumpbits(&bs->vlc, 4);       /* dump end of block code */
+}
+
+static INLINE void
+get_non_intra_block(struct vl_mpg12_bs *bs, int quantizer_scale, short *dest)
+{
+   int i, val;
+   const DCTtab *tab;
+
+   i = -1;
+
+   vl_vlc_needbits(&bs->vlc);
+   if (bs->vlc.buf >= 0x28000000) {
+      tab = DCT_B14DC_5 + (vl_vlc_ubits(&bs->vlc, 5) - 5);
+      goto entry_1;
+   } else
+      goto entry_2;
+
+   while (1) {
+      if (bs->vlc.buf >= 0x28000000) {
+
+         tab = DCT_B14AC_5 + (vl_vlc_ubits(&bs->vlc, 5) - 5);
+
+      entry_1:
+         i += tab->run;
+         if (i >= 64)
+            break;     /* end of block */
+
+      normal_code:
+         bs->vlc.buf <<= tab->len;
+         bs->vlc.bits += tab->len + 1;
+         val = ((2*tab->level+1) * quantizer_scale) >> 1;
+
+         val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1);
+
+         dest[i] = val;
+
+         bs->vlc.buf <<= 1;
+         vl_vlc_needbits(&bs->vlc);
+
+         continue;
+
+      }
+
+   entry_2:
+      if (bs->vlc.buf >= 0x04000000) {
+
+         tab = DCT_B14_8 + (vl_vlc_ubits(&bs->vlc, 8) - 4);
+
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+
+         /* escape code */
+
+         i += UBITS(bs->vlc.buf << 6, 6) - 64;
+         if (i >= 64)
+            break;     /* illegal, check needed to avoid buffer overflow */
+
+         vl_vlc_dumpbits(&bs->vlc, 12);
+         vl_vlc_needbits(&bs->vlc);
+         val = 2 * (vl_vlc_sbits(&bs->vlc, 12) + vl_vlc_sbits(&bs->vlc, 1)) + 1;
+         val = (val * quantizer_scale) / 2;
+
+         dest[i] = val;
+
+         vl_vlc_dumpbits(&bs->vlc, 12);
+         vl_vlc_needbits(&bs->vlc);
+
+         continue;
+
+      } else if (bs->vlc.buf >= 0x02000000) {
+         tab = DCT_B14_10 + (vl_vlc_ubits(&bs->vlc, 10) - 8);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00800000) {
+         tab = DCT_13 + (vl_vlc_ubits(&bs->vlc, 13) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00200000) {
+         tab = DCT_15 + (vl_vlc_ubits(&bs->vlc, 15) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else {
+         tab = DCT_16 + vl_vlc_ubits(&bs->vlc, 16);
+         bs->vlc.buf <<= 16;
+         vl_vlc_getword(&bs->vlc, bs->vlc.bits + 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      }
+      break;   /* illegal, check needed to avoid buffer overflow */
+   }
+   vl_vlc_dumpbits(&bs->vlc, 2);       /* dump end of block code */
+}
+
+static INLINE void
+get_mpeg1_intra_block(struct vl_mpg12_bs *bs, int quantizer_scale, short *dest)
+{
+   int i, val;
+   const DCTtab * tab;
+
+   i = 0;
+
+   vl_vlc_needbits(&bs->vlc);
+
+   while (1) {
+      if (bs->vlc.buf >= 0x28000000) {
+
+         tab = DCT_B14AC_5 + (vl_vlc_ubits(&bs->vlc, 5) - 5);
+
+         i += tab->run;
+         if (i >= 64)
+            break;     /* end of block */
+
+      normal_code:
+         bs->vlc.buf <<= tab->len;
+         bs->vlc.bits += tab->len + 1;
+         val = tab->level * quantizer_scale;
+
+         /* oddification */
+         val = (val - 1) | 1;
+
+         /* if (bitstream_get (1)) val = -val; */
+         val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1);
+
+         dest[i] = val;
+
+         bs->vlc.buf <<= 1;
+         vl_vlc_needbits(&bs->vlc);
+
+         continue;
+
+      } else if (bs->vlc.buf >= 0x04000000) {
+
+         tab = DCT_B14_8 + (vl_vlc_ubits(&bs->vlc, 8) - 4);
+
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+
+         /* escape code */
+
+         i += UBITS(bs->vlc.buf << 6, 6) - 64;
+         if (i >= 64)
+            break;     /* illegal, check needed to avoid buffer overflow */
+
+         vl_vlc_dumpbits(&bs->vlc, 12);
+         vl_vlc_needbits(&bs->vlc);
+         val = vl_vlc_sbits(&bs->vlc, 8);
+         if (! (val & 0x7f)) {
+            vl_vlc_dumpbits(&bs->vlc, 8);
+            val = vl_vlc_ubits(&bs->vlc, 8) + 2 * val;
+         }
+         val = val * quantizer_scale;
+
+         /* oddification */
+         val = (val + ~SBITS (val, 1)) | 1;
+
+         dest[i] = val;
+
+         vl_vlc_dumpbits(&bs->vlc, 8);
+         vl_vlc_needbits(&bs->vlc);
+
+         continue;
+
+      } else if (bs->vlc.buf >= 0x02000000) {
+         tab = DCT_B14_10 + (vl_vlc_ubits(&bs->vlc, 10) - 8);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00800000) {
+         tab = DCT_13 + (vl_vlc_ubits(&bs->vlc, 13) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00200000) {
+         tab = DCT_15 + (vl_vlc_ubits(&bs->vlc, 15) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else {
+         tab = DCT_16 + vl_vlc_ubits(&bs->vlc, 16);
+         bs->vlc.buf <<= 16;
+         vl_vlc_getword(&bs->vlc, bs->vlc.bits + 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      }
+      break;   /* illegal, check needed to avoid buffer overflow */
+   }
+   vl_vlc_dumpbits(&bs->vlc, 2);       /* dump end of block code */
+}
+
+static INLINE void
+get_mpeg1_non_intra_block(struct vl_mpg12_bs *bs, int quantizer_scale, short *dest)
+{
+   int i, val;
+   const DCTtab * tab;
+
+   i = -1;
+
+   vl_vlc_needbits(&bs->vlc);
+   if (bs->vlc.buf >= 0x28000000) {
+      tab = DCT_B14DC_5 + (vl_vlc_ubits(&bs->vlc, 5) - 5);
+      goto entry_1;
+   } else
+      goto entry_2;
+
+   while (1) {
+      if (bs->vlc.buf >= 0x28000000) {
+
+         tab = DCT_B14AC_5 + (vl_vlc_ubits(&bs->vlc, 5) - 5);
+
+      entry_1:
+         i += tab->run;
+         if (i >= 64)
+            break;     /* end of block */
+
+      normal_code:
+         bs->vlc.buf <<= tab->len;
+         bs->vlc.bits += tab->len + 1;
+         val = ((2*tab->level+1) * quantizer_scale) >> 1;
+
+         /* oddification */
+         val = (val - 1) | 1;
+
+         /* if (bitstream_get (1)) val = -val; */
+         val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1);
+
+         dest[i] = val;
+
+         bs->vlc.buf <<= 1;
+         vl_vlc_needbits(&bs->vlc);
+
+         continue;
+
+      }
+
+   entry_2:
+      if (bs->vlc.buf >= 0x04000000) {
+
+         tab = DCT_B14_8 + (vl_vlc_ubits(&bs->vlc, 8) - 4);
+
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+
+         /* escape code */
+
+         i += UBITS(bs->vlc.buf << 6, 6) - 64;
+         if (i >= 64)
+            break;     /* illegal, check needed to avoid buffer overflow */
+
+         vl_vlc_dumpbits(&bs->vlc, 12);
+         vl_vlc_needbits(&bs->vlc);
+         val = vl_vlc_sbits(&bs->vlc, 8);
+         if (! (val & 0x7f)) {
+            vl_vlc_dumpbits(&bs->vlc, 8);
+            val = vl_vlc_ubits(&bs->vlc, 8) + 2 * val;
+         }
+         val = 2 * (val + SBITS (val, 1)) + 1;
+         val = (val * quantizer_scale) / 2;
+
+         /* oddification */
+         val = (val + ~SBITS (val, 1)) | 1;
+
+         dest[i] = val;
+
+         vl_vlc_dumpbits(&bs->vlc, 8);
+         vl_vlc_needbits(&bs->vlc);
+
+         continue;
+
+      } else if (bs->vlc.buf >= 0x02000000) {
+         tab = DCT_B14_10 + (vl_vlc_ubits(&bs->vlc, 10) - 8);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00800000) {
+         tab = DCT_13 + (vl_vlc_ubits(&bs->vlc, 13) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else if (bs->vlc.buf >= 0x00200000) {
+         tab = DCT_15 + (vl_vlc_ubits(&bs->vlc, 15) - 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      } else {
+         tab = DCT_16 + vl_vlc_ubits(&bs->vlc, 16);
+         bs->vlc.buf <<= 16;
+         vl_vlc_getword(&bs->vlc, bs->vlc.bits + 16);
+         i += tab->run;
+         if (i < 64)
+            goto normal_code;
+      }
+      break;   /* illegal, check needed to avoid buffer overflow */
+   }
+   vl_vlc_dumpbits(&bs->vlc, 2);       /* dump end of block code */
+}
+
+static INLINE void
+slice_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, int cc,
+                 unsigned x, unsigned y, enum pipe_mpeg12_dct_type coding, int quantizer_scale, int dc_dct_pred[3])
+{
+   short dest[64];
+
+   bs->ycbcr_stream[cc]->x = x;
+   bs->ycbcr_stream[cc]->y = y;
+   bs->ycbcr_stream[cc]->intra = PIPE_MPEG12_DCT_INTRA;
+   bs->ycbcr_stream[cc]->coding = coding;
+
+   vl_vlc_needbits(&bs->vlc);
+
+   /* Get the intra DC coefficient and inverse quantize it */
+   if (cc == 0)
+      dc_dct_pred[0] += get_luma_dc_dct_diff(bs);
+   else
+      dc_dct_pred[cc] += get_chroma_dc_dct_diff(bs);
+
+   memset(dest, 0, sizeof(int16_t) * 64);
+   dest[0] = dc_dct_pred[cc];
+   if (picture->base.profile == PIPE_VIDEO_PROFILE_MPEG1) {
+      if (picture->picture_coding_type != D_TYPE)
+          get_mpeg1_intra_block(bs, quantizer_scale, dest);
+   } else if (picture->intra_vlc_format)
+      get_intra_block_B15(bs, quantizer_scale, dest);
+   else
+      get_intra_block_B14(bs, quantizer_scale, dest);
+
+   memcpy(bs->ycbcr_buffer[cc], dest, sizeof(int16_t) * 64);
+
+   bs->num_ycbcr_blocks[cc]++;
+   bs->ycbcr_stream[cc]++;
+   bs->ycbcr_buffer[cc] += 64;
+}
+
+static INLINE void
+slice_non_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, int cc,
+                    unsigned x, unsigned y,  enum pipe_mpeg12_dct_type coding, int quantizer_scale)
+{
+   short dest[64];
+
+   bs->ycbcr_stream[cc]->x = x;
+   bs->ycbcr_stream[cc]->y = y;
+   bs->ycbcr_stream[cc]->intra = PIPE_MPEG12_DCT_DELTA;
+   bs->ycbcr_stream[cc]->coding = coding;
+
+   memset(dest, 0, sizeof(int16_t) * 64);
+   if (picture->base.profile == PIPE_VIDEO_PROFILE_MPEG1)
+      get_mpeg1_non_intra_block(bs, quantizer_scale, dest);
+   else
+      get_non_intra_block(bs, quantizer_scale, dest);
+
+   memcpy(bs->ycbcr_buffer[cc], dest, sizeof(int16_t) * 64);
+
+   bs->num_ycbcr_blocks[cc]++;
+   bs->ycbcr_stream[cc]++;
+   bs->ycbcr_buffer[cc] += 64;
+}
+
+static INLINE void
+motion_mp1(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int motion_x, motion_y;
+
+   mv->top.field_select = mv->bottom.field_select = PIPE_VIDEO_FRAME;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_x = (mv->top.x + (get_motion_delta(bs, f_code[0]) << f_code[1]));
+   motion_x = bound_motion_vector (motion_x, f_code[0] + f_code[1]);
+   mv->top.x = mv->bottom.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = (mv->top.y + (get_motion_delta(bs, f_code[0]) << f_code[1]));
+   motion_y = bound_motion_vector (motion_y, f_code[0] + f_code[1]);
+   mv->top.y = mv->bottom.y = motion_y;
+}
+
+static INLINE void
+motion_fr_frame(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int motion_x, motion_y;
+
+   mv->top.field_select = mv->bottom.field_select = PIPE_VIDEO_FRAME;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_x = mv->top.x + get_motion_delta(bs, f_code[0]);
+   motion_x = bound_motion_vector(motion_x, f_code[0]);
+   mv->top.x = mv->bottom.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = mv->top.y + get_motion_delta(bs, f_code[1]);
+   motion_y = bound_motion_vector(motion_y, f_code[1]);
+   mv->top.y = mv->bottom.y = motion_y;
+}
+
+static INLINE void
+motion_fr_field(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int motion_x, motion_y;
+
+   vl_vlc_needbits(&bs->vlc);
+   mv->top.field_select = vl_vlc_ubits(&bs->vlc, 1) ?
+      PIPE_VIDEO_BOTTOM_FIELD : PIPE_VIDEO_TOP_FIELD;
+   vl_vlc_dumpbits(&bs->vlc, 1);
+
+   motion_x = mv->top.x + get_motion_delta(bs, f_code[0]);
+   motion_x = bound_motion_vector (motion_x, f_code[0]);
+   mv->top.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = (mv->top.y >> 1) + get_motion_delta(bs, f_code[1]);
+   /* motion_y = bound_motion_vector (motion_y, f_code[1]); */
+   mv->top.y = motion_y << 1;
+
+   vl_vlc_needbits(&bs->vlc);
+   mv->bottom.field_select = vl_vlc_ubits(&bs->vlc, 1) ?
+      PIPE_VIDEO_BOTTOM_FIELD : PIPE_VIDEO_TOP_FIELD;
+   vl_vlc_dumpbits(&bs->vlc, 1);
+
+   motion_x = mv->bottom.x + get_motion_delta(bs, f_code[0]);
+   motion_x = bound_motion_vector (motion_x, f_code[0]);
+   mv->bottom.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = (mv->bottom.y >> 1) + get_motion_delta(bs, f_code[1]);
+   /* motion_y = bound_motion_vector (motion_y, f_code[1]); */
+   mv->bottom.y = motion_y << 1;
+}
+
+static INLINE void
+motion_fr_dmv(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int motion_x, motion_y;
+
+   // TODO Implement dmv
+   mv->top.field_select = mv->bottom.field_select = PIPE_VIDEO_FRAME;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_x = mv->top.x + get_motion_delta(bs, f_code[0]);
+   motion_x = bound_motion_vector(motion_x, f_code[0]);
+   mv->top.x = mv->bottom.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = (mv->top.y >> 1) + get_motion_delta(bs, f_code[1]);
+   /* motion_y = bound_motion_vector (motion_y, f_code[1]); */
+   mv->top.y = mv->bottom.y = motion_y << 1;
+}
+
+/* like motion_frame, but parsing without actual motion compensation */
+static INLINE void
+motion_fr_conceal(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int tmp;
+
+   mv->top.field_select = mv->bottom.field_select = PIPE_VIDEO_FRAME;
+
+   vl_vlc_needbits(&bs->vlc);
+   tmp = (mv->top.x + get_motion_delta(bs, f_code[0]));
+   tmp = bound_motion_vector (tmp, f_code[0]);
+   mv->top.x = mv->bottom.x = tmp;
+
+   vl_vlc_needbits(&bs->vlc);
+   tmp = (mv->top.y + get_motion_delta(bs, f_code[1]));
+   tmp = bound_motion_vector (tmp, f_code[1]);
+   mv->top.y = mv->bottom.y = tmp;
+
+   vl_vlc_dumpbits(&bs->vlc, 1); /* remove marker_bit */
+}
+
+static INLINE void
+motion_fi_field(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int motion_x, motion_y;
+
+   vl_vlc_needbits(&bs->vlc);
+
+   // ref_field
+   //vl_vlc_ubits(&bs->vlc, 1);
+
+   // TODO field select may need to do something here for bob (weave ok)
+   mv->top.field_select = mv->bottom.field_select = PIPE_VIDEO_FRAME;
+   vl_vlc_dumpbits(&bs->vlc, 1);
+
+   motion_x = mv->top.x + get_motion_delta(bs, f_code[0]);
+   motion_x = bound_motion_vector (motion_x, f_code[0]);
+   mv->top.x = mv->bottom.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = mv->top.y + get_motion_delta(bs, f_code[1]);
+   motion_y = bound_motion_vector (motion_y, f_code[1]);
+   mv->top.y = mv->bottom.y = motion_y;
+}
+
+static INLINE void
+motion_fi_16x8(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int motion_x, motion_y;
+
+   vl_vlc_needbits(&bs->vlc);
+
+   // ref_field
+   //vl_vlc_ubits(&bs->vlc, 1);
+
+   // TODO field select may need to do something here bob  (weave ok)
+   mv->top.field_select = PIPE_VIDEO_FRAME;
+   vl_vlc_dumpbits(&bs->vlc, 1);
+
+   motion_x = mv->top.x + get_motion_delta(bs, f_code[0]);
+   motion_x = bound_motion_vector (motion_x, f_code[0]);
+   mv->top.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = mv->top.y + get_motion_delta(bs, f_code[1]);
+   motion_y = bound_motion_vector (motion_y, f_code[1]);
+   mv->top.y = motion_y;
+
+   vl_vlc_needbits(&bs->vlc);
+   // ref_field
+   //vl_vlc_ubits(&bs->vlc, 1);
+
+   // TODO field select may need to do something here for bob (weave ok)
+   mv->bottom.field_select = PIPE_VIDEO_FRAME;
+   vl_vlc_dumpbits(&bs->vlc, 1);
+
+   motion_x = mv->bottom.x + get_motion_delta(bs, f_code[0]);
+   motion_x = bound_motion_vector (motion_x, f_code[0]);
+   mv->bottom.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = mv->bottom.y + get_motion_delta(bs, f_code[1]);
+   motion_y = bound_motion_vector (motion_y, f_code[1]);
+   mv->bottom.y = motion_y;
+}
+
+static INLINE void
+motion_fi_dmv(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int motion_x, motion_y;
+
+   // TODO field select may need to do something here for bob  (weave ok)
+   mv->top.field_select = mv->bottom.field_select = PIPE_VIDEO_FRAME;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_x = mv->top.x + get_motion_delta(bs, f_code[0]);
+   motion_x = bound_motion_vector (motion_x, f_code[0]);
+   mv->top.x = mv->bottom.x = motion_x;
+
+   vl_vlc_needbits(&bs->vlc);
+   motion_y = mv->top.y + get_motion_delta(bs, f_code[1]);
+   motion_y = bound_motion_vector (motion_y, f_code[1]);
+   mv->top.y = mv->bottom.y = motion_y;
+}
+
+
+static INLINE void
+motion_fi_conceal(struct vl_mpg12_bs *bs, unsigned f_code[2], struct pipe_motionvector *mv)
+{
+   int tmp;
+
+   vl_vlc_needbits(&bs->vlc);
+   vl_vlc_dumpbits(&bs->vlc, 1); /* remove field_select */
+
+   tmp = (mv->top.x + get_motion_delta(bs, f_code[0]));
+   tmp = bound_motion_vector(tmp, f_code[0]);
+   mv->top.x = mv->bottom.x = tmp;
+
+   vl_vlc_needbits(&bs->vlc);
+   tmp = (mv->top.y + get_motion_delta(bs, f_code[1]));
+   tmp = bound_motion_vector(tmp, f_code[1]);
+   mv->top.y = mv->bottom.y = tmp;
+
+   vl_vlc_dumpbits(&bs->vlc, 1); /* remove marker_bit */
+}
+
+#define MOTION_CALL(routine, macroblock_modes)         \
+do {                                                   \
+   if ((macroblock_modes) & MACROBLOCK_MOTION_FORWARD)  \
+      routine(bs, picture->f_code[0], &mv_fwd);         \
+   if ((macroblock_modes) & MACROBLOCK_MOTION_BACKWARD)        \
+      routine(bs, picture->f_code[1], &mv_bwd);         \
+} while (0)
+
+static INLINE void
+store_motionvectors(struct vl_mpg12_bs *bs, unsigned *mv_pos,
+                    struct pipe_motionvector *mv_fwd,
+                    struct pipe_motionvector *mv_bwd)
+{
+   bs->mv_stream[0][*mv_pos].top = mv_fwd->top;
+   bs->mv_stream[0][*mv_pos].bottom =
+      mv_fwd->top.field_select == PIPE_VIDEO_FRAME ?
+      mv_fwd->top : mv_fwd->bottom;
+
+   bs->mv_stream[1][*mv_pos].top = mv_bwd->top;
+   bs->mv_stream[1][*mv_pos].bottom =
+      mv_bwd->top.field_select == PIPE_VIDEO_FRAME ?
+      mv_bwd->top : mv_bwd->bottom;
+
+   (*mv_pos)++;
+}
+
+static INLINE bool
+slice_init(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture,
+           int *quantizer_scale, unsigned *x, unsigned *y, unsigned *mv_pos)
+{
+   const MBAtab * mba;
+
+   vl_vlc_need32bits(&bs->vlc);
+   while(bs->vlc.buf < 0x101 || bs->vlc.buf > 0x1AF) {
+      if(!vl_vlc_getbyte(&bs->vlc))
+         return false;
+   }
+   *y = (bs->vlc.buf & 0xFF) - 1;
+   vl_vlc_restart(&bs->vlc);
+
+   *quantizer_scale = get_quantizer_scale(bs, picture);
+
+   /* ignore intra_slice and all the extra data */
+   while (bs->vlc.buf & 0x80000000) {
+      vl_vlc_dumpbits(&bs->vlc, 9);
+      vl_vlc_needbits(&bs->vlc);
+   }
+
+   /* decode initial macroblock address increment */
+   *x = 0;
+   while (1) {
+      if (bs->vlc.buf >= 0x08000000) {
+          mba = MBA_5 + (vl_vlc_ubits(&bs->vlc, 6) - 2);
+          break;
+      } else if (bs->vlc.buf >= 0x01800000) {
+          mba = MBA_11 + (vl_vlc_ubits(&bs->vlc, 12) - 24);
+          break;
+      } else switch (vl_vlc_ubits(&bs->vlc, 12)) {
+      case 8:          /* macroblock_escape */
+          *x += 33;
+          vl_vlc_dumpbits(&bs->vlc, 11);
+          vl_vlc_needbits(&bs->vlc);
+          continue;
+      case 15: /* macroblock_stuffing (MPEG1 only) */
+          bs->vlc.buf &= 0xfffff;
+          vl_vlc_dumpbits(&bs->vlc, 11);
+          vl_vlc_needbits(&bs->vlc);
+          continue;
+      default: /* error */
+          return false;
+      }
+   }
+   vl_vlc_dumpbits(&bs->vlc, mba->len + 1);
+   *x += mba->mba;
+
+   while (*x >= bs->width) {
+      *x -= bs->width;
+      (*y)++;
+   }
+   if (*y > bs->height)
+      return false;
+
+   *mv_pos = *x + *y * bs->width;
+
+   return true;
+}
+
+static INLINE bool
+decode_slice(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc *picture)
+{
+   enum pipe_video_field_select default_field_select;
+   struct pipe_motionvector mv_fwd, mv_bwd;
+   enum pipe_mpeg12_dct_type dct_type;
+
+   /* predictor for DC coefficients in intra blocks */
+   int dc_dct_pred[3] = { 0, 0, 0 };
+   int quantizer_scale;
+
+   unsigned x, y, mv_pos;
+
+   switch(picture->picture_structure) {
+   case TOP_FIELD:
+      default_field_select = PIPE_VIDEO_TOP_FIELD;
+      break;
+
+   case BOTTOM_FIELD:
+      default_field_select = PIPE_VIDEO_BOTTOM_FIELD;
+      break;
+
+   default:
+      default_field_select = PIPE_VIDEO_FRAME;
+      break;
+   }
+
+   if (!slice_init(bs, picture, &quantizer_scale, &x, &y, &mv_pos))
+      return false;
+
+   mv_fwd.top.x = mv_fwd.top.y = mv_fwd.bottom.x = mv_fwd.bottom.y = 0;
+   mv_fwd.top.field_select = mv_fwd.bottom.field_select = default_field_select;
+
+   mv_bwd.top.x = mv_bwd.top.y = mv_bwd.bottom.x = mv_bwd.bottom.y = 0;
+   mv_bwd.top.field_select = mv_bwd.bottom.field_select = default_field_select;
+
+   while (1) {
+      int macroblock_modes;
+      int mba_inc;
+      const MBAtab * mba;
+
+      vl_vlc_needbits(&bs->vlc);
+
+      macroblock_modes = get_macroblock_modes(bs, picture);
+      dct_type = get_dct_type(bs, picture, macroblock_modes);
+
+      switch(macroblock_modes & (MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD)) {
+      case (MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD):
+         mv_fwd.top.weight = mv_fwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_HALF;
+         mv_bwd.top.weight = mv_bwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_HALF;
+         break;
+
+      default:
+         mv_fwd.top.field_select = mv_fwd.bottom.field_select = default_field_select;
+         mv_bwd.top.field_select = mv_bwd.bottom.field_select = default_field_select;
+
+         /* fall through */
+      case MACROBLOCK_MOTION_FORWARD:
+         mv_fwd.top.weight = mv_fwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_MAX;
+         mv_bwd.top.weight = mv_bwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_MIN;
+         break;
+
+      case MACROBLOCK_MOTION_BACKWARD:
+         mv_fwd.top.weight = mv_fwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_MIN;
+         mv_bwd.top.weight = mv_bwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_MAX;
+         break;
+      }
+
+      /* maybe integrate MACROBLOCK_QUANT test into get_macroblock_modes ? */
+      if (macroblock_modes & MACROBLOCK_QUANT)
+         quantizer_scale = get_quantizer_scale(bs, picture);
+
+      if (macroblock_modes & MACROBLOCK_INTRA) {
+
+         if (picture->concealment_motion_vectors) {
+            if (picture->picture_structure == FRAME_PICTURE)
+               motion_fr_conceal(bs, picture->f_code[0], &mv_fwd);
+            else
+               motion_fi_conceal(bs, picture->f_code[0], &mv_fwd);
+
+         } else {
+            mv_fwd.top.x = mv_fwd.top.y = mv_fwd.bottom.x = mv_fwd.bottom.y = 0;
+            mv_bwd.top.x = mv_bwd.top.y = mv_bwd.bottom.x = mv_bwd.bottom.y = 0;
+         }
+         mv_fwd.top.weight = mv_fwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_MIN;
+         mv_bwd.top.weight = mv_bwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_MIN;
+
+         // unravaled loop of 6 block(i) calls in macroblock()
+         slice_intra_DCT(bs, picture, 0, x*2+0, y*2+0, dct_type, quantizer_scale, dc_dct_pred);
+         slice_intra_DCT(bs, picture, 0, x*2+1, y*2+0, dct_type, quantizer_scale, dc_dct_pred);
+         slice_intra_DCT(bs, picture, 0, x*2+0, y*2+1, dct_type, quantizer_scale, dc_dct_pred);
+         slice_intra_DCT(bs, picture, 0, x*2+1, y*2+1, dct_type, quantizer_scale, dc_dct_pred);
+         slice_intra_DCT(bs, picture, 1, x, y, PIPE_MPEG12_DCT_TYPE_FRAME, quantizer_scale, dc_dct_pred);
+         slice_intra_DCT(bs, picture, 2, x, y, PIPE_MPEG12_DCT_TYPE_FRAME, quantizer_scale, dc_dct_pred);
+
+         if (picture->picture_coding_type == D_TYPE) {
+            vl_vlc_needbits(&bs->vlc);
+            vl_vlc_dumpbits(&bs->vlc, 1);
+         }
+
+      } else {
+         if (picture->picture_structure == FRAME_PICTURE)
+            switch (macroblock_modes & MOTION_TYPE_MASK) {
+            case MC_FRAME:
+               if (picture->base.profile == PIPE_VIDEO_PROFILE_MPEG1) {
+                  MOTION_CALL(motion_mp1, macroblock_modes);
+               } else {
+                  MOTION_CALL(motion_fr_frame, macroblock_modes);
+               }
+               break;
+
+            case MC_FIELD:
+               MOTION_CALL (motion_fr_field, macroblock_modes);
+               break;
+
+            case MC_DMV:
+               MOTION_CALL (motion_fr_dmv, MACROBLOCK_MOTION_FORWARD);
+               break;
+
+            case 0:
+               /* non-intra mb without forward mv in a P picture */
+               mv_fwd.top.x = mv_fwd.top.y = mv_fwd.bottom.x = mv_fwd.bottom.y = 0;
+               mv_bwd.top.x = mv_bwd.top.y = mv_bwd.bottom.x = mv_bwd.bottom.y = 0;
+               break;
+            }
+         else
+            switch (macroblock_modes & MOTION_TYPE_MASK) {
+            case MC_FIELD:
+               MOTION_CALL (motion_fi_field, macroblock_modes);
+               break;
+
+            case MC_16X8:
+               MOTION_CALL (motion_fi_16x8, macroblock_modes);
+               break;
+
+            case MC_DMV:
+               MOTION_CALL (motion_fi_dmv, MACROBLOCK_MOTION_FORWARD);
+               break;
+
+            case 0:
+               /* non-intra mb without forward mv in a P picture */
+               mv_fwd.top.x = mv_fwd.top.y = mv_fwd.bottom.x = mv_fwd.bottom.y = 0;
+               mv_bwd.top.x = mv_bwd.top.y = mv_bwd.bottom.x = mv_bwd.bottom.y = 0;
+               break;
+            }
+
+         if (macroblock_modes & MACROBLOCK_PATTERN) {
+            int coded_block_pattern = get_coded_block_pattern(bs);
+
+            // TODO  optimize not fully used for idct accel only mc.
+            if (coded_block_pattern & 0x20)
+               slice_non_intra_DCT(bs, picture, 0, x*2+0, y*2+0, dct_type, quantizer_scale); // cc0  luma 0
+            if (coded_block_pattern & 0x10)
+               slice_non_intra_DCT(bs, picture, 0, x*2+1, y*2+0, dct_type, quantizer_scale); // cc0 luma 1
+            if (coded_block_pattern & 0x08)
+               slice_non_intra_DCT(bs, picture, 0, x*2+0, y*2+1, dct_type, quantizer_scale); // cc0 luma 2
+            if (coded_block_pattern & 0x04)
+               slice_non_intra_DCT(bs, picture, 0, x*2+1, y*2+1, dct_type, quantizer_scale); // cc0 luma 3
+            if (coded_block_pattern & 0x2)
+               slice_non_intra_DCT(bs, picture, 1, x, y, PIPE_MPEG12_DCT_TYPE_FRAME, quantizer_scale); // cc1 croma
+            if (coded_block_pattern & 0x1)
+               slice_non_intra_DCT(bs, picture, 2, x, y, PIPE_MPEG12_DCT_TYPE_FRAME, quantizer_scale); // cc2 croma
+         }
+
+         dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0;
+      }
+
+      store_motionvectors(bs, &mv_pos, &mv_fwd, &mv_bwd);
+      if (++x >= bs->width) {
+         ++y;
+         if (y >= bs->height)
+            return false;
+         x -= bs->width;
+      }
+
+      vl_vlc_needbits(&bs->vlc);
+      mba_inc = 0;
+      while (1) {
+         if (bs->vlc.buf >= 0x10000000) {
+            mba = MBA_5 + (vl_vlc_ubits(&bs->vlc, 5) - 2);
+            break;
+         } else if (bs->vlc.buf >= 0x03000000) {
+            mba = MBA_11 + (vl_vlc_ubits(&bs->vlc, 11) - 24);
+            break;
+         } else switch (vl_vlc_ubits(&bs->vlc, 11)) {
+         case 8:               /* macroblock_escape */
+            mba_inc += 33;
+            /* pass through */
+         case 15:      /* macroblock_stuffing (MPEG1 only) */
+            vl_vlc_dumpbits(&bs->vlc, 11);
+            vl_vlc_needbits(&bs->vlc);
+            continue;
+         default:      /* end of slice, or error */
+            return true;
+         }
+      }
+      vl_vlc_dumpbits(&bs->vlc, mba->len);
+      mba_inc += mba->mba;
+      if (mba_inc) {
+         //TODO  conversion to signed format signed format
+         dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0;
+
+         mv_fwd.top.field_select = mv_fwd.bottom.field_select = default_field_select;
+         mv_bwd.top.field_select = mv_bwd.bottom.field_select = default_field_select;
+
+         if (picture->picture_coding_type == P_TYPE) {
+            mv_fwd.top.x = mv_fwd.top.y = mv_fwd.bottom.x = mv_fwd.bottom.y = 0;
+            mv_fwd.top.weight = mv_fwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_MAX;
+         }
+
+         x += mba_inc;
+         do {
+            store_motionvectors(bs, &mv_pos, &mv_fwd, &mv_bwd);
+         } while (--mba_inc);
+      }
+      while (x >= bs->width) {
+         ++y;
+         if (y >= bs->height)
+            return false;
+         x -= bs->width;
+      }
+   }
+}
+
+void
+vl_mpg12_bs_init(struct vl_mpg12_bs *bs, unsigned width, unsigned height)
+{
+   assert(bs);
+
+   memset(bs, 0, sizeof(struct vl_mpg12_bs));
+
+   bs->width = width;
+   bs->height = height;
+}
+
+void
+vl_mpg12_bs_set_buffers(struct vl_mpg12_bs *bs, struct pipe_ycbcr_block *ycbcr_stream[VL_MAX_PLANES],
+                        short *ycbcr_buffer[VL_MAX_PLANES], struct pipe_motionvector *mv_stream[VL_MAX_REF_FRAMES])
+{
+   unsigned i;
+
+   assert(bs);
+   assert(ycbcr_stream && ycbcr_buffer);
+   assert(mv_stream);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      bs->ycbcr_stream[i] = ycbcr_stream[i];
+      bs->ycbcr_buffer[i] = ycbcr_buffer[i];
+   }
+   for (i = 0; i < VL_MAX_REF_FRAMES; ++i)
+      bs->mv_stream[i] = mv_stream[i];
+
+   // TODO
+   for (i = 0; i < bs->width*bs->height; ++i) {
+      bs->mv_stream[0][i].top.x = bs->mv_stream[0][i].top.y = 0;
+      bs->mv_stream[0][i].top.field_select = PIPE_VIDEO_FRAME;
+      bs->mv_stream[0][i].top.weight = PIPE_VIDEO_MV_WEIGHT_MAX;
+      bs->mv_stream[0][i].bottom.x = bs->mv_stream[0][i].bottom.y = 0;
+      bs->mv_stream[0][i].bottom.field_select = PIPE_VIDEO_FRAME;
+      bs->mv_stream[0][i].bottom.weight = PIPE_VIDEO_MV_WEIGHT_MAX;
+
+      bs->mv_stream[1][i].top.x = bs->mv_stream[1][i].top.y = 0;
+      bs->mv_stream[1][i].top.field_select = PIPE_VIDEO_FRAME;
+      bs->mv_stream[1][i].top.weight = PIPE_VIDEO_MV_WEIGHT_MIN;
+      bs->mv_stream[1][i].bottom.x = bs->mv_stream[1][i].bottom.y = 0;
+      bs->mv_stream[1][i].bottom.field_select = PIPE_VIDEO_FRAME;
+      bs->mv_stream[1][i].bottom.weight = PIPE_VIDEO_MV_WEIGHT_MIN;
+   }
+}
+
+void
+vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const void *buffer,
+                   struct pipe_mpeg12_picture_desc *picture, unsigned num_ycbcr_blocks[3])
+{
+   assert(bs);
+   assert(num_ycbcr_blocks);
+   assert(buffer && num_bytes);
+
+   bs->num_ycbcr_blocks = num_ycbcr_blocks;
+
+   vl_vlc_init(&bs->vlc, buffer, num_bytes);
+
+   while(decode_slice(bs, picture));
+}
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.h
new file mode 100644 (file)
index 0000000..4e48a9f
--- /dev/null
@@ -0,0 +1,59 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Christian König.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_mpeg12_bitstream_h
+#define vl_mpeg12_bitstream_h
+
+#include "vl_defines.h"
+#include "vl_vlc.h"
+
+struct vl_mpg12_bs
+{
+   unsigned width, height;
+
+   struct vl_vlc vlc;
+
+   unsigned *num_ycbcr_blocks;
+
+   struct pipe_ycbcr_block *ycbcr_stream[VL_MAX_PLANES];
+   short *ycbcr_buffer[VL_MAX_PLANES];
+
+   struct pipe_motionvector *mv_stream[VL_MAX_REF_FRAMES];
+};
+
+void
+vl_mpg12_bs_init(struct vl_mpg12_bs *bs, unsigned width, unsigned height);
+
+void
+vl_mpg12_bs_set_buffers(struct vl_mpg12_bs *bs, struct pipe_ycbcr_block *ycbcr_stream[VL_MAX_PLANES],
+                        short *ycbcr_buffer[VL_MAX_PLANES], struct pipe_motionvector *mv_stream[VL_MAX_REF_FRAMES]);
+
+void
+vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const void *buffer,
+                   struct pipe_mpeg12_picture_desc *picture, unsigned num_ycbcr_blocks[3]);
+
+#endif /* vl_mpeg12_bitstream_h */
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
new file mode 100644 (file)
index 0000000..61d947c
--- /dev/null
@@ -0,0 +1,972 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <math.h>
+#include <assert.h>
+
+#include <util/u_memory.h>
+#include <util/u_rect.h>
+#include <util/u_video.h>
+
+#include "vl_mpeg12_decoder.h"
+#include "vl_defines.h"
+
+#define SCALE_FACTOR_SNORM (32768.0f / 256.0f)
+#define SCALE_FACTOR_SSCALED (1.0f / 256.0f)
+
+struct format_config {
+   enum pipe_format zscan_source_format;
+   enum pipe_format idct_source_format;
+   enum pipe_format mc_source_format;
+
+   float idct_scale;
+   float mc_scale;
+};
+
+static const struct format_config bitstream_format_config[] = {
+   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SSCALED },
+   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 1.0f, SCALE_FACTOR_SSCALED },
+   { PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SNORM },
+   { PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, 1.0f, SCALE_FACTOR_SNORM }
+};
+
+static const unsigned num_bitstream_format_configs =
+   sizeof(bitstream_format_config) / sizeof(struct format_config);
+
+static const struct format_config idct_format_config[] = {
+   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SSCALED },
+   { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, PIPE_FORMAT_R16G16B16A16_SSCALED, 1.0f, SCALE_FACTOR_SSCALED },
+   { PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R16G16B16A16_FLOAT, 1.0f, SCALE_FACTOR_SNORM },
+   { PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, 1.0f, SCALE_FACTOR_SNORM }
+};
+
+static const unsigned num_idct_format_configs =
+   sizeof(idct_format_config) / sizeof(struct format_config);
+
+static const struct format_config mc_format_config[] = {
+   //{ PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_NONE, PIPE_FORMAT_R16_SSCALED, 0.0f, SCALE_FACTOR_SSCALED },
+   { PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_NONE, PIPE_FORMAT_R16_SNORM, 0.0f, SCALE_FACTOR_SNORM }
+};
+
+static const unsigned num_mc_format_configs =
+   sizeof(mc_format_config) / sizeof(struct format_config);
+
+static bool
+init_zscan_buffer(struct vl_mpeg12_buffer *buffer)
+{
+   enum pipe_format formats[3];
+
+   struct pipe_sampler_view **source;
+   struct pipe_surface **destination;
+
+   struct vl_mpeg12_decoder *dec;
+
+   unsigned i;
+
+   assert(buffer);
+
+   dec = (struct vl_mpeg12_decoder*)buffer->base.decoder;
+
+   formats[0] = formats[1] = formats[2] = dec->zscan_source_format;
+   buffer->zscan_source = vl_video_buffer_create_ex
+   (
+      dec->base.context,
+      dec->blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT,
+      align(dec->num_blocks, dec->blocks_per_line) / dec->blocks_per_line,
+      1, PIPE_VIDEO_CHROMA_FORMAT_444, formats, PIPE_USAGE_STATIC
+   );
+
+   if (!buffer->zscan_source)
+      goto error_source;
+
+   source = buffer->zscan_source->get_sampler_view_planes(buffer->zscan_source);
+   if (!source)
+      goto error_sampler;
+
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
+      destination = dec->idct_source->get_surfaces(dec->idct_source);
+   else
+      destination = dec->mc_source->get_surfaces(dec->mc_source);
+
+   if (!destination)
+      goto error_surface;
+
+   for (i = 0; i < VL_MAX_PLANES; ++i)
+      if (!vl_zscan_init_buffer(i == 0 ? &dec->zscan_y : &dec->zscan_c,
+                                &buffer->zscan[i], source[i], destination[i]))
+         goto error_plane;
+
+   return true;
+
+error_plane:
+   for (; i > 0; --i)
+      vl_zscan_cleanup_buffer(&buffer->zscan[i - 1]);
+
+error_surface:
+error_sampler:
+   buffer->zscan_source->destroy(buffer->zscan_source);
+
+error_source:
+   return false;
+}
+
+static void
+cleanup_zscan_buffer(struct vl_mpeg12_buffer *buffer)
+{
+   unsigned i;
+
+   assert(buffer);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i)
+      vl_zscan_cleanup_buffer(&buffer->zscan[i]);
+   buffer->zscan_source->destroy(buffer->zscan_source);
+}
+
+static bool
+init_idct_buffer(struct vl_mpeg12_buffer *buffer)
+{
+   struct pipe_sampler_view **idct_source_sv, **mc_source_sv;
+
+   struct vl_mpeg12_decoder *dec;
+
+   unsigned i;
+
+   assert(buffer);
+
+   dec = (struct vl_mpeg12_decoder*)buffer->base.decoder;
+
+   idct_source_sv = dec->idct_source->get_sampler_view_planes(dec->idct_source);
+   if (!idct_source_sv)
+      goto error_source_sv;
+
+   mc_source_sv = dec->mc_source->get_sampler_view_planes(dec->mc_source);
+   if (!mc_source_sv)
+      goto error_mc_source_sv;
+
+   for (i = 0; i < 3; ++i)
+      if (!vl_idct_init_buffer(i == 0 ? &dec->idct_y : &dec->idct_c,
+                               &buffer->idct[i], idct_source_sv[i],
+                               mc_source_sv[i]))
+         goto error_plane;
+
+   return true;
+
+error_plane:
+   for (; i > 0; --i)
+      vl_idct_cleanup_buffer(&buffer->idct[i - 1]);
+
+error_mc_source_sv:
+error_source_sv:
+   return false;
+}
+
+static void
+cleanup_idct_buffer(struct vl_mpeg12_buffer *buf)
+{
+   struct vl_mpeg12_decoder *dec;
+   unsigned i;
+   
+   assert(buf);
+
+   dec = (struct vl_mpeg12_decoder*)buf->base.decoder;
+   assert(dec);
+
+   for (i = 0; i < 3; ++i)
+      vl_idct_cleanup_buffer(&buf->idct[0]);
+}
+
+static bool
+init_mc_buffer(struct vl_mpeg12_buffer *buf)
+{
+   struct vl_mpeg12_decoder *dec;
+
+   assert(buf);
+
+   dec = (struct vl_mpeg12_decoder*)buf->base.decoder;
+   assert(dec);
+
+   if(!vl_mc_init_buffer(&dec->mc_y, &buf->mc[0]))
+      goto error_mc_y;
+
+   if(!vl_mc_init_buffer(&dec->mc_c, &buf->mc[1]))
+      goto error_mc_cb;
+
+   if(!vl_mc_init_buffer(&dec->mc_c, &buf->mc[2]))
+      goto error_mc_cr;
+
+   return true;
+
+error_mc_cr:
+   vl_mc_cleanup_buffer(&buf->mc[1]);
+
+error_mc_cb:
+   vl_mc_cleanup_buffer(&buf->mc[0]);
+
+error_mc_y:
+   return false;
+}
+
+static void
+cleanup_mc_buffer(struct vl_mpeg12_buffer *buf)
+{
+   unsigned i;
+
+   assert(buf);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i)
+      vl_mc_cleanup_buffer(&buf->mc[i]);
+}
+
+static void
+vl_mpeg12_buffer_destroy(struct pipe_video_decode_buffer *buffer)
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+   struct vl_mpeg12_decoder *dec;
+
+   assert(buf);
+
+   dec = (struct vl_mpeg12_decoder*)buf->base.decoder;
+   assert(dec);
+
+   cleanup_zscan_buffer(buf);
+
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
+      cleanup_idct_buffer(buf);
+
+   cleanup_mc_buffer(buf);
+
+   vl_vb_cleanup(&buf->vertex_stream);
+
+   FREE(buf);
+}
+
+static void
+vl_mpeg12_buffer_begin_frame(struct pipe_video_decode_buffer *buffer)
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+   struct vl_mpeg12_decoder *dec;
+
+   struct pipe_sampler_view **sampler_views;
+   unsigned i;
+
+   assert(buf);
+
+   dec = (struct vl_mpeg12_decoder *)buf->base.decoder;
+   assert(dec);
+
+   vl_vb_map(&buf->vertex_stream, dec->base.context);
+
+   sampler_views = buf->zscan_source->get_sampler_view_planes(buf->zscan_source);
+
+   assert(sampler_views);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      struct pipe_resource *tex = sampler_views[i]->texture;
+      struct pipe_box rect =
+      {
+         0, 0, 0,
+         tex->width0,
+         tex->height0,
+         1
+      };
+
+      buf->tex_transfer[i] = dec->base.context->get_transfer
+      (
+         dec->base.context, tex,
+         0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+         &rect
+      );
+
+      buf->texels[i] = dec->base.context->transfer_map(dec->base.context, buf->tex_transfer[i]);
+   }
+
+   if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
+      struct pipe_ycbcr_block *ycbcr_stream[VL_MAX_PLANES];
+      struct pipe_motionvector *mv_stream[VL_MAX_REF_FRAMES];
+
+      for (i = 0; i < VL_MAX_PLANES; ++i)
+         ycbcr_stream[i] = vl_vb_get_ycbcr_stream(&buf->vertex_stream, i);
+
+      for (i = 0; i < VL_MAX_REF_FRAMES; ++i)
+         mv_stream[i] = vl_vb_get_mv_stream(&buf->vertex_stream, i);
+
+      vl_mpg12_bs_set_buffers(&buf->bs, ycbcr_stream, buf->texels, mv_stream);
+   } else {
+
+      for (i = 0; i < VL_MAX_PLANES; ++i)
+         vl_zscan_set_layout(&buf->zscan[i], dec->zscan_linear);
+   }
+}
+
+static void
+vl_mpeg12_buffer_set_quant_matrix(struct pipe_video_decode_buffer *buffer,
+                                  const uint8_t intra_matrix[64],
+                                  const uint8_t non_intra_matrix[64])
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+   unsigned i;
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      vl_zscan_upload_quant(&buf->zscan[i], intra_matrix, true);
+      vl_zscan_upload_quant(&buf->zscan[i], non_intra_matrix, false);
+   }
+}
+
+static struct pipe_ycbcr_block *
+vl_mpeg12_buffer_get_ycbcr_stream(struct pipe_video_decode_buffer *buffer, int component)
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+
+   assert(buf);
+
+   return vl_vb_get_ycbcr_stream(&buf->vertex_stream, component);
+}
+
+static short *
+vl_mpeg12_buffer_get_ycbcr_buffer(struct pipe_video_decode_buffer *buffer, int component)
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+
+   assert(buf);
+   assert(component < VL_MAX_PLANES);
+
+   return buf->texels[component];
+}
+
+static unsigned
+vl_mpeg12_buffer_get_mv_stream_stride(struct pipe_video_decode_buffer *buffer)
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+
+   assert(buf);
+
+   return vl_vb_get_mv_stream_stride(&buf->vertex_stream);
+}
+
+static struct pipe_motionvector *
+vl_mpeg12_buffer_get_mv_stream(struct pipe_video_decode_buffer *buffer, int ref_frame)
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+
+   assert(buf);
+
+   return vl_vb_get_mv_stream(&buf->vertex_stream, ref_frame);
+}
+
+static void
+vl_mpeg12_buffer_decode_bitstream(struct pipe_video_decode_buffer *buffer,
+                                  unsigned num_bytes, const void *data,
+                                  struct pipe_picture_desc *picture,
+                                  unsigned num_ycbcr_blocks[3])
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+   struct pipe_mpeg12_picture_desc *pic = (struct pipe_mpeg12_picture_desc *)picture;
+   
+   struct vl_mpeg12_decoder *dec;
+   unsigned i;
+
+   assert(buf);
+
+   dec = (struct vl_mpeg12_decoder *)buf->base.decoder;
+   assert(dec);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i)
+      vl_zscan_set_layout(&buf->zscan[i], pic->alternate_scan ? dec->zscan_alternate : dec->zscan_normal);
+
+   vl_mpg12_bs_decode(&buf->bs, num_bytes, data, pic, num_ycbcr_blocks);
+}
+
+static void
+vl_mpeg12_buffer_end_frame(struct pipe_video_decode_buffer *buffer)
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+   struct vl_mpeg12_decoder *dec;
+   unsigned i;
+
+   assert(buf);
+
+   dec = (struct vl_mpeg12_decoder *)buf->base.decoder;
+   assert(dec);
+
+   vl_vb_unmap(&buf->vertex_stream, dec->base.context);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      dec->base.context->transfer_unmap(dec->base.context, buf->tex_transfer[i]);
+      dec->base.context->transfer_destroy(dec->base.context, buf->tex_transfer[i]);
+   }
+}
+
+static void
+vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
+{
+   struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
+
+   assert(decoder);
+
+   /* Asserted in softpipe_delete_fs_state() for some reason */
+   dec->base.context->bind_vs_state(dec->base.context, NULL);
+   dec->base.context->bind_fs_state(dec->base.context, NULL);
+
+   dec->base.context->delete_depth_stencil_alpha_state(dec->base.context, dec->dsa);
+   dec->base.context->delete_sampler_state(dec->base.context, dec->sampler_ycbcr);
+
+   vl_mc_cleanup(&dec->mc_y);
+   vl_mc_cleanup(&dec->mc_c);
+   dec->mc_source->destroy(dec->mc_source);
+
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
+      vl_idct_cleanup(&dec->idct_y);
+      vl_idct_cleanup(&dec->idct_c);
+      dec->idct_source->destroy(dec->idct_source);
+   }
+
+   vl_zscan_cleanup(&dec->zscan_y);
+   vl_zscan_cleanup(&dec->zscan_c);
+
+   dec->base.context->delete_vertex_elements_state(dec->base.context, dec->ves_ycbcr);
+   dec->base.context->delete_vertex_elements_state(dec->base.context, dec->ves_mv);
+
+   pipe_resource_reference(&dec->quads.buffer, NULL);
+   pipe_resource_reference(&dec->pos.buffer, NULL);
+   pipe_resource_reference(&dec->block_num.buffer, NULL);
+
+   pipe_sampler_view_reference(&dec->zscan_linear, NULL);
+   pipe_sampler_view_reference(&dec->zscan_normal, NULL);
+   pipe_sampler_view_reference(&dec->zscan_alternate, NULL);
+
+   FREE(dec);
+}
+
+static struct pipe_video_decode_buffer *
+vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
+{
+   struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
+   struct vl_mpeg12_buffer *buffer;
+
+   assert(dec);
+
+   buffer = CALLOC_STRUCT(vl_mpeg12_buffer);
+   if (buffer == NULL)
+      return NULL;
+
+   buffer->base.decoder = decoder;
+   buffer->base.destroy = vl_mpeg12_buffer_destroy;
+   buffer->base.begin_frame = vl_mpeg12_buffer_begin_frame;
+   buffer->base.set_quant_matrix = vl_mpeg12_buffer_set_quant_matrix;
+   buffer->base.get_ycbcr_stream = vl_mpeg12_buffer_get_ycbcr_stream;
+   buffer->base.get_ycbcr_buffer = vl_mpeg12_buffer_get_ycbcr_buffer;
+   buffer->base.get_mv_stream_stride = vl_mpeg12_buffer_get_mv_stream_stride;
+   buffer->base.get_mv_stream = vl_mpeg12_buffer_get_mv_stream;
+   buffer->base.decode_bitstream = vl_mpeg12_buffer_decode_bitstream;
+   buffer->base.end_frame = vl_mpeg12_buffer_end_frame;
+
+   if (!vl_vb_init(&buffer->vertex_stream, dec->base.context,
+                   dec->base.width / MACROBLOCK_WIDTH,
+                   dec->base.height / MACROBLOCK_HEIGHT))
+      goto error_vertex_buffer;
+
+   if (!init_mc_buffer(buffer))
+      goto error_mc;
+
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
+      if (!init_idct_buffer(buffer))
+         goto error_idct;
+
+   if (!init_zscan_buffer(buffer))
+      goto error_zscan;
+
+   if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM)
+      vl_mpg12_bs_init(&buffer->bs,
+                       dec->base.width / MACROBLOCK_WIDTH,
+                       dec->base.height / MACROBLOCK_HEIGHT);
+
+   return &buffer->base;
+
+error_zscan:
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
+      cleanup_idct_buffer(buffer);
+
+error_idct:
+   cleanup_mc_buffer(buffer);
+
+error_mc:
+   vl_vb_cleanup(&buffer->vertex_stream);
+
+error_vertex_buffer:
+   FREE(buffer);
+   return NULL;
+}
+
+static void
+vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer,
+                               unsigned num_ycbcr_blocks[3],
+                               struct pipe_video_buffer *refs[2],
+                               struct pipe_video_buffer *dst)
+{
+   struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer *)buffer;
+   struct vl_mpeg12_decoder *dec;
+
+   struct pipe_sampler_view **sv[VL_MAX_REF_FRAMES], **mc_source_sv;
+   struct pipe_surface **surfaces;
+
+   struct pipe_vertex_buffer vb[3];
+
+   unsigned i, j, component;
+   unsigned nr_components;
+
+   assert(buf);
+
+   dec = (struct vl_mpeg12_decoder *)buf->base.decoder;
+   assert(dec);
+
+   for (i = 0; i < 2; ++i)
+      sv[i] = refs[i] ? refs[i]->get_sampler_view_planes(refs[i]) : NULL;
+
+   vb[0] = dec->quads;
+   vb[1] = dec->pos;
+
+   surfaces = dst->get_surfaces(dst);
+
+   dec->base.context->bind_vertex_elements_state(dec->base.context, dec->ves_mv);
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      if (!surfaces[i]) continue;
+
+      vl_mc_set_surface(&buf->mc[i], surfaces[i]);
+
+      for (j = 0; j < VL_MAX_REF_FRAMES; ++j) {
+         if (!sv[j]) continue;
+
+         vb[2] = vl_vb_get_mv(&buf->vertex_stream, j);;
+         dec->base.context->set_vertex_buffers(dec->base.context, 3, vb);
+
+         vl_mc_render_ref(&buf->mc[i], sv[j][i]);
+      }
+   }
+
+   vb[2] = dec->block_num;
+
+   dec->base.context->bind_vertex_elements_state(dec->base.context, dec->ves_ycbcr);
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      if (!num_ycbcr_blocks[i]) continue;
+
+      vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, i);
+      dec->base.context->set_vertex_buffers(dec->base.context, 3, vb);
+
+      vl_zscan_render(&buf->zscan[i] , num_ycbcr_blocks[i]);
+
+      if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
+         vl_idct_flush(&buf->idct[i], num_ycbcr_blocks[i]);
+   }
+
+   mc_source_sv = dec->mc_source->get_sampler_view_planes(dec->mc_source);
+   for (i = 0, component = 0; i < VL_MAX_PLANES; ++i) {
+      if (!surfaces[i]) continue;
+
+      nr_components = util_format_get_nr_components(surfaces[i]->texture->format);
+      for (j = 0; j < nr_components; ++j, ++component) {
+         if (!num_ycbcr_blocks[i]) continue;
+
+         vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, component);
+         dec->base.context->set_vertex_buffers(dec->base.context, 3, vb);
+
+         if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
+            vl_idct_prepare_stage2(&buf->idct[component]);
+         else {
+            dec->base.context->set_fragment_sampler_views(dec->base.context, 1, &mc_source_sv[component]);
+            dec->base.context->bind_fragment_sampler_states(dec->base.context, 1, &dec->sampler_ycbcr);
+         }
+         vl_mc_render_ycbcr(&buf->mc[i], j, num_ycbcr_blocks[component]);
+      }
+   }
+}
+
+static bool
+init_pipe_state(struct vl_mpeg12_decoder *dec)
+{
+   struct pipe_depth_stencil_alpha_state dsa;
+   struct pipe_sampler_state sampler;
+   unsigned i;
+
+   assert(dec);
+
+   memset(&dsa, 0, sizeof dsa);
+   dsa.depth.enabled = 0;
+   dsa.depth.writemask = 0;
+   dsa.depth.func = PIPE_FUNC_ALWAYS;
+   for (i = 0; i < 2; ++i) {
+      dsa.stencil[i].enabled = 0;
+      dsa.stencil[i].func = PIPE_FUNC_ALWAYS;
+      dsa.stencil[i].fail_op = PIPE_STENCIL_OP_KEEP;
+      dsa.stencil[i].zpass_op = PIPE_STENCIL_OP_KEEP;
+      dsa.stencil[i].zfail_op = PIPE_STENCIL_OP_KEEP;
+      dsa.stencil[i].valuemask = 0;
+      dsa.stencil[i].writemask = 0;
+   }
+   dsa.alpha.enabled = 0;
+   dsa.alpha.func = PIPE_FUNC_ALWAYS;
+   dsa.alpha.ref_value = 0;
+   dec->dsa = dec->base.context->create_depth_stencil_alpha_state(dec->base.context, &dsa);
+   dec->base.context->bind_depth_stencil_alpha_state(dec->base.context, dec->dsa);
+
+   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_BORDER;
+   sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
+   sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+   sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
+   sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
+   sampler.compare_func = PIPE_FUNC_ALWAYS;
+   sampler.normalized_coords = 1;
+   dec->sampler_ycbcr = dec->base.context->create_sampler_state(dec->base.context, &sampler);
+   if (!dec->sampler_ycbcr)
+      return false;
+
+   return true;
+}
+
+static const struct format_config*
+find_format_config(struct vl_mpeg12_decoder *dec, const struct format_config configs[], unsigned num_configs)
+{
+   struct pipe_screen *screen;
+   unsigned i;
+
+   assert(dec);
+
+   screen = dec->base.context->screen;
+
+   for (i = 0; i < num_configs; ++i) {
+      if (!screen->is_format_supported(screen, configs[i].zscan_source_format, PIPE_TEXTURE_2D,
+                                       1, PIPE_BIND_SAMPLER_VIEW))
+         continue;
+
+      if (configs[i].idct_source_format != PIPE_FORMAT_NONE) {
+         if (!screen->is_format_supported(screen, configs[i].idct_source_format, PIPE_TEXTURE_2D,
+                                          1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET))
+            continue;
+
+         if (!screen->is_format_supported(screen, configs[i].mc_source_format, PIPE_TEXTURE_3D,
+                                          1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET))
+            continue;
+      } else {
+         if (!screen->is_format_supported(screen, configs[i].mc_source_format, PIPE_TEXTURE_2D,
+                                          1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET))
+            continue;
+      }
+      return &configs[i];
+   }
+
+   return NULL;
+}
+
+static bool
+init_zscan(struct vl_mpeg12_decoder *dec, const struct format_config* format_config)
+{
+   unsigned num_channels;
+
+   assert(dec);
+
+   dec->zscan_source_format = format_config->zscan_source_format;
+   dec->zscan_linear = vl_zscan_layout(dec->base.context, vl_zscan_linear, dec->blocks_per_line);
+   dec->zscan_normal = vl_zscan_layout(dec->base.context, vl_zscan_normal, dec->blocks_per_line);
+   dec->zscan_alternate = vl_zscan_layout(dec->base.context, vl_zscan_alternate, dec->blocks_per_line);
+
+   num_channels = dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT ? 4 : 1;
+
+   if (!vl_zscan_init(&dec->zscan_y, dec->base.context, dec->base.width, dec->base.height,
+                      dec->blocks_per_line, dec->num_blocks, num_channels))
+      return false;
+
+   if (!vl_zscan_init(&dec->zscan_c, dec->base.context, dec->chroma_width, dec->chroma_height,
+                      dec->blocks_per_line, dec->num_blocks, num_channels))
+      return false;
+
+   return true;
+}
+
+static bool
+init_idct(struct vl_mpeg12_decoder *dec, const struct format_config* format_config)
+{
+   unsigned nr_of_idct_render_targets, max_inst;
+   enum pipe_format formats[3];
+
+   struct pipe_sampler_view *matrix = NULL;
+
+   nr_of_idct_render_targets = dec->base.context->screen->get_param
+   (
+      dec->base.context->screen, PIPE_CAP_MAX_RENDER_TARGETS
+   );
+   
+   max_inst = dec->base.context->screen->get_shader_param
+   (
+      dec->base.context->screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INSTRUCTIONS
+   );
+
+   // Just assume we need 32 inst per render target, not 100% true, but should work in most cases
+   if (nr_of_idct_render_targets >= 4 && max_inst >= 32*4)
+      // more than 4 render targets usually doesn't makes any seens
+      nr_of_idct_render_targets = 4;
+   else
+      nr_of_idct_render_targets = 1;
+
+   formats[0] = formats[1] = formats[2] = format_config->idct_source_format;
+   dec->idct_source = vl_video_buffer_create_ex
+   (
+      dec->base.context, dec->base.width / 4, dec->base.height, 1,
+      dec->base.chroma_format, formats, PIPE_USAGE_STATIC
+   );
+
+   if (!dec->idct_source)
+      goto error_idct_source;
+
+   formats[0] = formats[1] = formats[2] = format_config->mc_source_format;
+   dec->mc_source = vl_video_buffer_create_ex
+   (
+      dec->base.context, dec->base.width / nr_of_idct_render_targets,
+      dec->base.height / 4, nr_of_idct_render_targets,
+      dec->base.chroma_format, formats, PIPE_USAGE_STATIC
+   );
+
+   if (!dec->mc_source)
+      goto error_mc_source;
+
+   if (!(matrix = vl_idct_upload_matrix(dec->base.context, format_config->idct_scale)))
+      goto error_matrix;
+
+   if (!vl_idct_init(&dec->idct_y, dec->base.context, dec->base.width, dec->base.height,
+                     nr_of_idct_render_targets, matrix, matrix))
+      goto error_y;
+
+   if(!vl_idct_init(&dec->idct_c, dec->base.context, dec->chroma_width, dec->chroma_height,
+                    nr_of_idct_render_targets, matrix, matrix))
+      goto error_c;
+
+   pipe_sampler_view_reference(&matrix, NULL);
+
+   return true;
+
+error_c:
+   vl_idct_cleanup(&dec->idct_y);
+
+error_y:
+   pipe_sampler_view_reference(&matrix, NULL);
+
+error_matrix:
+   dec->mc_source->destroy(dec->mc_source);
+
+error_mc_source:
+   dec->idct_source->destroy(dec->idct_source);
+
+error_idct_source:
+   return false;
+}
+
+static bool
+init_mc_source_widthout_idct(struct vl_mpeg12_decoder *dec, const struct format_config* format_config)
+{
+   enum pipe_format formats[3];
+
+   formats[0] = formats[1] = formats[2] = format_config->mc_source_format;
+   dec->mc_source = vl_video_buffer_create_ex
+   (
+      dec->base.context, dec->base.width, dec->base.height, 1,
+      dec->base.chroma_format, formats, PIPE_USAGE_STATIC
+   );
+      
+   return dec->mc_source != NULL;
+}
+
+static void
+mc_vert_shader_callback(void *priv, struct vl_mc *mc,
+                        struct ureg_program *shader,
+                        unsigned first_output,
+                        struct ureg_dst tex)
+{
+   struct vl_mpeg12_decoder *dec = priv;
+   struct ureg_dst o_vtex;
+
+   assert(priv && mc);
+   assert(shader);
+
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
+      struct vl_idct *idct = mc == &dec->mc_y ? &dec->idct_y : &dec->idct_c;
+      vl_idct_stage2_vert_shader(idct, shader, first_output, tex);
+   } else {
+      o_vtex = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, first_output);
+      ureg_MOV(shader, ureg_writemask(o_vtex, TGSI_WRITEMASK_XY), ureg_src(tex));
+   }
+}
+
+static void
+mc_frag_shader_callback(void *priv, struct vl_mc *mc,
+                        struct ureg_program *shader,
+                        unsigned first_input,
+                        struct ureg_dst dst)
+{
+   struct vl_mpeg12_decoder *dec = priv;
+   struct ureg_src src, sampler;
+
+   assert(priv && mc);
+   assert(shader);
+
+   if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
+      struct vl_idct *idct = mc == &dec->mc_y ? &dec->idct_y : &dec->idct_c;
+      vl_idct_stage2_frag_shader(idct, shader, first_input, dst);
+   } else {
+      src = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, first_input, TGSI_INTERPOLATE_LINEAR);
+      sampler = ureg_DECL_sampler(shader, 0);
+      ureg_TEX(shader, dst, TGSI_TEXTURE_2D, src, sampler);
+   }
+}
+
+struct pipe_video_decoder *
+vl_create_mpeg12_decoder(struct pipe_context *context,
+                         enum pipe_video_profile profile,
+                         enum pipe_video_entrypoint entrypoint,
+                         enum pipe_video_chroma_format chroma_format,
+                         unsigned width, unsigned height)
+{
+   const unsigned block_size_pixels = BLOCK_WIDTH * BLOCK_HEIGHT;
+   const struct format_config *format_config;
+   struct vl_mpeg12_decoder *dec;
+
+   assert(u_reduce_video_profile(profile) == PIPE_VIDEO_CODEC_MPEG12);
+
+   dec = CALLOC_STRUCT(vl_mpeg12_decoder);
+
+   if (!dec)
+      return NULL;
+
+   dec->base.context = context;
+   dec->base.profile = profile;
+   dec->base.entrypoint = entrypoint;
+   dec->base.chroma_format = chroma_format;
+   dec->base.width = width;
+   dec->base.height = height;
+
+   dec->base.destroy = vl_mpeg12_destroy;
+   dec->base.create_buffer = vl_mpeg12_create_buffer;
+   dec->base.flush_buffer = vl_mpeg12_decoder_flush_buffer;
+
+   dec->blocks_per_line = MAX2(util_next_power_of_two(dec->base.width) / block_size_pixels, 4);
+   dec->num_blocks = (dec->base.width * dec->base.height) / block_size_pixels;
+
+   dec->quads = vl_vb_upload_quads(dec->base.context);
+   dec->pos = vl_vb_upload_pos(
+      dec->base.context,
+      dec->base.width / MACROBLOCK_WIDTH,
+      dec->base.height / MACROBLOCK_HEIGHT
+   );
+   dec->block_num = vl_vb_upload_block_num(dec->base.context, dec->num_blocks);
+
+   dec->ves_ycbcr = vl_vb_get_ves_ycbcr(dec->base.context);
+   dec->ves_mv = vl_vb_get_ves_mv(dec->base.context);
+
+   /* TODO: Implement 422, 444 */
+   assert(dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
+
+   if (dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
+      dec->chroma_width = dec->base.width / 2;
+      dec->chroma_height = dec->base.height / 2;
+   } else if (dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
+      dec->chroma_width = dec->base.width;
+      dec->chroma_height = dec->base.height / 2;
+   } else {
+      dec->chroma_width = dec->base.width;
+      dec->chroma_height = dec->base.height;
+   }
+
+   switch (entrypoint) {
+   case PIPE_VIDEO_ENTRYPOINT_BITSTREAM:
+      format_config = find_format_config(dec, bitstream_format_config, num_bitstream_format_configs);
+      break;
+
+   case PIPE_VIDEO_ENTRYPOINT_IDCT:
+      format_config = find_format_config(dec, idct_format_config, num_idct_format_configs);
+      break;
+
+   case PIPE_VIDEO_ENTRYPOINT_MC:
+      format_config = find_format_config(dec, mc_format_config, num_mc_format_configs);
+      break;
+
+   default:
+      assert(0);
+      return NULL;
+   }
+
+   if (!format_config)
+      return NULL;
+
+   if (!init_zscan(dec, format_config))
+      goto error_zscan;
+
+   if (entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
+      if (!init_idct(dec, format_config))
+         goto error_sources;
+   } else {
+      if (!init_mc_source_widthout_idct(dec, format_config))
+         goto error_sources;
+   }
+
+   if (!vl_mc_init(&dec->mc_y, dec->base.context, dec->base.width, dec->base.height,
+                   MACROBLOCK_HEIGHT, format_config->mc_scale,
+                   mc_vert_shader_callback, mc_frag_shader_callback, dec))
+      goto error_mc_y;
+
+   // TODO
+   if (!vl_mc_init(&dec->mc_c, dec->base.context, dec->base.width, dec->base.height,
+                   BLOCK_HEIGHT, format_config->mc_scale,
+                   mc_vert_shader_callback, mc_frag_shader_callback, dec))
+      goto error_mc_c;
+
+   if (!init_pipe_state(dec))
+      goto error_pipe_state;
+
+   return &dec->base;
+
+error_pipe_state:
+   vl_mc_cleanup(&dec->mc_c);
+
+error_mc_c:
+   vl_mc_cleanup(&dec->mc_y);
+
+error_mc_y:
+   if (entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
+      vl_idct_cleanup(&dec->idct_y);
+      vl_idct_cleanup(&dec->idct_c);
+      dec->idct_source->destroy(dec->idct_source);
+   }
+   dec->mc_source->destroy(dec->mc_source);
+
+error_sources:
+   vl_zscan_cleanup(&dec->zscan_y);
+   vl_zscan_cleanup(&dec->zscan_c);
+
+error_zscan:
+   FREE(dec);
+   return NULL;
+}
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h
new file mode 100644 (file)
index 0000000..01265e3
--- /dev/null
@@ -0,0 +1,105 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_mpeg12_decoder_h
+#define vl_mpeg12_decoder_h
+
+#include <pipe/p_video_decoder.h>
+
+#include "vl_mpeg12_bitstream.h"
+#include "vl_zscan.h"
+#include "vl_idct.h"
+#include "vl_mc.h"
+
+#include "vl_vertex_buffers.h"
+#include "vl_video_buffer.h"
+
+struct pipe_screen;
+struct pipe_context;
+
+struct vl_mpeg12_decoder
+{
+   struct pipe_video_decoder base;
+
+   unsigned chroma_width, chroma_height;
+
+   unsigned blocks_per_line;
+   unsigned num_blocks;
+
+   enum pipe_format zscan_source_format;
+
+   struct pipe_vertex_buffer quads;
+   struct pipe_vertex_buffer pos;
+   struct pipe_vertex_buffer block_num;
+
+   void *ves_ycbcr;
+   void *ves_mv;
+
+   void *sampler_ycbcr;
+
+   struct pipe_sampler_view *zscan_linear;
+   struct pipe_sampler_view *zscan_normal;
+   struct pipe_sampler_view *zscan_alternate;
+
+   struct pipe_video_buffer *idct_source;
+   struct pipe_video_buffer *mc_source;
+
+   struct vl_zscan zscan_y, zscan_c;
+   struct vl_idct idct_y, idct_c;
+   struct vl_mc mc_y, mc_c;
+
+   void *dsa;
+};
+
+struct vl_mpeg12_buffer
+{
+   struct pipe_video_decode_buffer base;
+
+   struct vl_vertex_buffer vertex_stream;
+
+   struct pipe_video_buffer *zscan_source;
+
+   struct vl_mpg12_bs bs;
+   struct vl_zscan_buffer zscan[VL_MAX_PLANES];
+   struct vl_idct_buffer idct[VL_MAX_PLANES];
+   struct vl_mc_buffer mc[VL_MAX_PLANES];
+
+   struct pipe_transfer *tex_transfer[VL_MAX_PLANES];
+   short *texels[VL_MAX_PLANES];
+};
+
+/**
+ * creates a shader based mpeg12 decoder
+ */
+struct pipe_video_decoder *
+vl_create_mpeg12_decoder(struct pipe_context *pipe,
+                         enum pipe_video_profile profile,
+                         enum pipe_video_entrypoint entrypoint,
+                         enum pipe_video_chroma_format chroma_format,
+                         unsigned width, unsigned height);
+
+#endif /* vl_mpeg12_decoder_h */
diff --git a/src/gallium/auxiliary/vl/vl_types.h b/src/gallium/auxiliary/vl/vl_types.h
new file mode 100644 (file)
index 0000000..27bb69d
--- /dev/null
@@ -0,0 +1,51 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_types_h
+#define vl_types_h
+
+struct vertex2f
+{
+   float x, y;
+};
+
+struct vertex2s
+{
+   short x, y;
+};
+
+struct vertex4f
+{
+   float x, y, z, w;
+};
+
+struct vertex4s
+{
+   short x, y, z, w;
+};
+
+#endif /* vl_types_h */
diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.c b/src/gallium/auxiliary/vl/vl_vertex_buffers.c
new file mode 100644 (file)
index 0000000..c0f1449
--- /dev/null
@@ -0,0 +1,419 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Christian König
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <util/u_format.h>
+#include "vl_vertex_buffers.h"
+#include "vl_types.h"
+
+/* vertices for a quad covering a block */
+static const struct vertex2f block_quad[4] = {
+   {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}
+};
+
+struct pipe_vertex_buffer
+vl_vb_upload_quads(struct pipe_context *pipe)
+{
+   struct pipe_vertex_buffer quad;
+   struct pipe_transfer *buf_transfer;
+   struct vertex2f *v;
+
+   unsigned i;
+
+   assert(pipe);
+
+   /* create buffer */
+   quad.stride = sizeof(struct vertex2f);
+   quad.buffer_offset = 0;
+   quad.buffer = pipe_buffer_create
+   (
+      pipe->screen,
+      PIPE_BIND_VERTEX_BUFFER,
+      PIPE_USAGE_STATIC,
+      sizeof(struct vertex2f) * 4
+   );
+
+   if(!quad.buffer)
+      return quad;
+
+   /* and fill it */
+   v = pipe_buffer_map
+   (
+      pipe,
+      quad.buffer,
+      PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+      &buf_transfer
+   );
+
+   for (i = 0; i < 4; ++i, ++v) {
+      v->x = block_quad[i].x;
+      v->y = block_quad[i].y;
+   }
+
+   pipe_buffer_unmap(pipe, buf_transfer);
+
+   return quad;
+}
+
+struct pipe_vertex_buffer
+vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height)
+{
+   struct pipe_vertex_buffer pos;
+   struct pipe_transfer *buf_transfer;
+   struct vertex2s *v;
+
+   unsigned x, y;
+
+   assert(pipe);
+
+   /* create buffer */
+   pos.stride = sizeof(struct vertex2s);
+   pos.buffer_offset = 0;
+   pos.buffer = pipe_buffer_create
+   (
+      pipe->screen,
+      PIPE_BIND_VERTEX_BUFFER,
+      PIPE_USAGE_STATIC,
+      sizeof(struct vertex2s) * width * height
+   );
+
+   if(!pos.buffer)
+      return pos;
+
+   /* and fill it */
+   v = pipe_buffer_map
+   (
+      pipe,
+      pos.buffer,
+      PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+      &buf_transfer
+   );
+
+   for ( y = 0; y < height; ++y) {
+      for ( x = 0; x < width; ++x, ++v) {
+         v->x = x;
+         v->y = y;
+      }
+   }
+
+   pipe_buffer_unmap(pipe, buf_transfer);
+
+   return pos;
+}
+
+struct pipe_vertex_buffer
+vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks)
+{
+   struct pipe_vertex_buffer buf;
+   struct pipe_transfer *buf_transfer;
+   struct vertex2s *v;
+   unsigned i;
+
+   assert(pipe);
+
+   /* create buffer */
+   buf.stride = sizeof(struct vertex2s);
+   buf.buffer_offset = 0;
+   buf.buffer = pipe_buffer_create
+   (
+      pipe->screen,
+      PIPE_BIND_VERTEX_BUFFER,
+      PIPE_USAGE_STATIC,
+      sizeof(struct vertex2s) * num_blocks
+   );
+
+   if(!buf.buffer)
+      return buf;
+
+   /* and fill it */
+   v = pipe_buffer_map
+   (
+      pipe,
+      buf.buffer,
+      PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+      &buf_transfer
+   );
+
+   for ( i = 0; i < num_blocks; ++i, ++v) {
+      v->x = i;
+      v->y = i;
+   }
+
+   pipe_buffer_unmap(pipe, buf_transfer);
+
+   return buf;
+}
+
+static struct pipe_vertex_element
+vl_vb_get_quad_vertex_element(void)
+{
+   struct pipe_vertex_element element;
+
+   /* setup rectangle element */
+   element.src_offset = 0;
+   element.instance_divisor = 0;
+   element.vertex_buffer_index = 0;
+   element.src_format = PIPE_FORMAT_R32G32_FLOAT;
+
+   return element;
+}
+
+static void
+vl_vb_element_helper(struct pipe_vertex_element* elements, unsigned num_elements,
+                     unsigned vertex_buffer_index)
+{
+   unsigned i, offset = 0;
+
+   assert(elements && num_elements);
+
+   for ( i = 0; i < num_elements; ++i ) {
+      elements[i].src_offset = offset;
+      elements[i].instance_divisor = 1;
+      elements[i].vertex_buffer_index = vertex_buffer_index;
+      offset += util_format_get_blocksize(elements[i].src_format);
+   }
+}
+
+void *
+vl_vb_get_ves_ycbcr(struct pipe_context *pipe)
+{
+   struct pipe_vertex_element vertex_elems[NUM_VS_INPUTS];
+
+   assert(pipe);
+
+   memset(&vertex_elems, 0, sizeof(vertex_elems));
+   vertex_elems[VS_I_RECT] = vl_vb_get_quad_vertex_element();
+
+   /* Position element */
+   vertex_elems[VS_I_VPOS].src_format = PIPE_FORMAT_R8G8B8A8_USCALED;
+
+   vl_vb_element_helper(&vertex_elems[VS_I_VPOS], 1, 1);
+
+   /* block num element */
+   vertex_elems[VS_I_BLOCK_NUM].src_format = PIPE_FORMAT_R16G16_SSCALED;
+
+   vl_vb_element_helper(&vertex_elems[VS_I_BLOCK_NUM], 1, 2);
+
+   return pipe->create_vertex_elements_state(pipe, 3, vertex_elems);
+}
+
+void *
+vl_vb_get_ves_mv(struct pipe_context *pipe)
+{
+   struct pipe_vertex_element vertex_elems[NUM_VS_INPUTS];
+
+   assert(pipe);
+
+   memset(&vertex_elems, 0, sizeof(vertex_elems));
+   vertex_elems[VS_I_RECT] = vl_vb_get_quad_vertex_element();
+
+   /* Position element */
+   vertex_elems[VS_I_VPOS].src_format = PIPE_FORMAT_R16G16_SSCALED;
+
+   vl_vb_element_helper(&vertex_elems[VS_I_VPOS], 1, 1);
+
+   /* motion vector TOP element */
+   vertex_elems[VS_I_MV_TOP].src_format = PIPE_FORMAT_R16G16B16A16_SSCALED;
+
+   /* motion vector BOTTOM element */
+   vertex_elems[VS_I_MV_BOTTOM].src_format = PIPE_FORMAT_R16G16B16A16_SSCALED;
+
+   vl_vb_element_helper(&vertex_elems[VS_I_MV_TOP], 2, 2);
+
+   return pipe->create_vertex_elements_state(pipe, NUM_VS_INPUTS, vertex_elems);
+}
+
+bool
+vl_vb_init(struct vl_vertex_buffer *buffer, struct pipe_context *pipe,
+           unsigned width, unsigned height)
+{
+   unsigned i, size;
+
+   assert(buffer);
+
+   buffer->width = width;
+   buffer->height = height;
+
+   size = width * height;
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      buffer->ycbcr[i].resource = pipe_buffer_create
+      (
+         pipe->screen,
+         PIPE_BIND_VERTEX_BUFFER,
+         PIPE_USAGE_STREAM,
+         sizeof(struct pipe_ycbcr_block) * size * 4
+      );
+      if (!buffer->ycbcr[i].resource)
+         goto error_ycbcr;
+   }
+
+   for (i = 0; i < VL_MAX_REF_FRAMES; ++i) {
+      buffer->mv[i].resource = pipe_buffer_create
+      (
+         pipe->screen,
+         PIPE_BIND_VERTEX_BUFFER,
+         PIPE_USAGE_STREAM,
+         sizeof(struct pipe_motionvector) * size
+      );
+      if (!buffer->mv[i].resource)
+         goto error_mv;
+   }
+
+   vl_vb_map(buffer, pipe);
+   return true;
+
+error_mv:
+   for (i = 0; i < VL_MAX_PLANES; ++i)
+      pipe_resource_reference(&buffer->mv[i].resource, NULL);
+
+error_ycbcr:
+   for (i = 0; i < VL_MAX_PLANES; ++i)
+      pipe_resource_reference(&buffer->ycbcr[i].resource, NULL);
+   return false;
+}
+
+unsigned
+vl_vb_attributes_per_plock(struct vl_vertex_buffer *buffer)
+{
+   return 1;
+}
+
+struct pipe_vertex_buffer
+vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component)
+{
+   struct pipe_vertex_buffer buf;
+
+   assert(buffer);
+
+   buf.stride = sizeof(struct pipe_ycbcr_block);
+   buf.buffer_offset = 0;
+   buf.buffer = buffer->ycbcr[component].resource;
+
+   return buf;
+}
+
+struct pipe_vertex_buffer
+vl_vb_get_mv(struct vl_vertex_buffer *buffer, int motionvector)
+{
+   struct pipe_vertex_buffer buf;
+
+   assert(buffer);
+
+   buf.stride = sizeof(struct pipe_motionvector);
+   buf.buffer_offset = 0;
+   buf.buffer = buffer->mv[motionvector].resource;
+
+   return buf;
+}
+
+void
+vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe)
+{
+   unsigned i;
+
+   assert(buffer && pipe);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      buffer->ycbcr[i].vertex_stream = pipe_buffer_map
+      (
+         pipe,
+         buffer->ycbcr[i].resource,
+         PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+         &buffer->ycbcr[i].transfer
+      );
+   }
+
+   for (i = 0; i < VL_MAX_REF_FRAMES; ++i) {
+      buffer->mv[i].vertex_stream = pipe_buffer_map
+      (
+         pipe,
+         buffer->mv[i].resource,
+         PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+         &buffer->mv[i].transfer
+      );
+   }
+
+}
+
+struct pipe_ycbcr_block *
+vl_vb_get_ycbcr_stream(struct vl_vertex_buffer *buffer, int component)
+{
+   assert(buffer);
+   assert(component < VL_MAX_PLANES);
+
+   return buffer->ycbcr[component].vertex_stream;
+}
+
+unsigned
+vl_vb_get_mv_stream_stride(struct vl_vertex_buffer *buffer)
+{
+   assert(buffer);
+
+   return buffer->width;
+}
+
+struct pipe_motionvector *
+vl_vb_get_mv_stream(struct vl_vertex_buffer *buffer, int ref_frame)
+{
+   assert(buffer);
+   assert(ref_frame < VL_MAX_REF_FRAMES);
+
+   return buffer->mv[ref_frame].vertex_stream;
+}
+
+void
+vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe)
+{
+   unsigned i;
+
+   assert(buffer && pipe);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      pipe_buffer_unmap(pipe, buffer->ycbcr[i].transfer);
+   }
+
+   for (i = 0; i < VL_MAX_REF_FRAMES; ++i) {
+      pipe_buffer_unmap(pipe, buffer->mv[i].transfer);
+   }
+}
+
+void
+vl_vb_cleanup(struct vl_vertex_buffer *buffer)
+{
+   unsigned i;
+
+   assert(buffer);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      pipe_resource_reference(&buffer->ycbcr[i].resource, NULL);
+   }
+
+   for (i = 0; i < VL_MAX_REF_FRAMES; ++i) {
+      pipe_resource_reference(&buffer->mv[i].resource, NULL);
+   }
+}
diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.h b/src/gallium/auxiliary/vl/vl_vertex_buffers.h
new file mode 100644 (file)
index 0000000..74845a4
--- /dev/null
@@ -0,0 +1,104 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Christian König
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_vertex_buffers_h
+#define vl_vertex_buffers_h
+
+#include <pipe/p_state.h>
+#include <pipe/p_video_state.h>
+
+#include "vl_defines.h"
+#include "vl_types.h"
+
+/* vertex buffers act as a todo list
+ * uploading all the usefull informations to video ram
+ * so a vertex shader can work with them
+ */
+
+/* inputs to the vertex shaders */
+enum VS_INPUT
+{
+   VS_I_RECT = 0,
+   VS_I_VPOS = 1,
+
+   VS_I_BLOCK_NUM = 2,
+
+   VS_I_MV_TOP = 2,
+   VS_I_MV_BOTTOM = 3,
+
+   NUM_VS_INPUTS = 4
+};
+
+struct vl_vertex_buffer
+{
+   unsigned width, height;
+
+   struct {
+      struct pipe_resource    *resource;
+      struct pipe_transfer    *transfer;
+      struct pipe_ycbcr_block *vertex_stream;
+   } ycbcr[VL_MAX_PLANES];
+
+   struct {
+      struct pipe_resource     *resource;
+      struct pipe_transfer     *transfer;
+      struct pipe_motionvector *vertex_stream;
+   } mv[VL_MAX_REF_FRAMES];
+};
+
+struct pipe_vertex_buffer vl_vb_upload_quads(struct pipe_context *pipe);
+
+struct pipe_vertex_buffer vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height);
+
+struct pipe_vertex_buffer vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks);
+
+void *vl_vb_get_ves_ycbcr(struct pipe_context *pipe);
+
+void *vl_vb_get_ves_mv(struct pipe_context *pipe);
+
+bool vl_vb_init(struct vl_vertex_buffer *buffer,
+                struct pipe_context *pipe,
+                unsigned width, unsigned height);
+
+unsigned vl_vb_attributes_per_plock(struct vl_vertex_buffer *buffer);
+
+void vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
+
+struct pipe_vertex_buffer vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component);
+
+struct pipe_ycbcr_block *vl_vb_get_ycbcr_stream(struct vl_vertex_buffer *buffer, int component);
+
+struct pipe_vertex_buffer vl_vb_get_mv(struct vl_vertex_buffer *buffer, int ref_frame);
+
+unsigned vl_vb_get_mv_stream_stride(struct vl_vertex_buffer *buffer);
+
+struct pipe_motionvector *vl_vb_get_mv_stream(struct vl_vertex_buffer *buffer, int ref_frame);
+
+void vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
+
+void vl_vb_cleanup(struct vl_vertex_buffer *buffer);
+
+#endif /* vl_vertex_buffers_h */
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c
new file mode 100644 (file)
index 0000000..4d8b664
--- /dev/null
@@ -0,0 +1,340 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Christian König.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <pipe/p_screen.h>
+#include <pipe/p_context.h>
+#include <pipe/p_state.h>
+
+#include <util/u_format.h>
+#include <util/u_inlines.h>
+#include <util/u_sampler.h>
+#include <util/u_memory.h>
+
+#include "vl_video_buffer.h"
+
+const enum pipe_format const_resource_formats_YV12[3] = {
+   PIPE_FORMAT_R8_UNORM,
+   PIPE_FORMAT_R8_UNORM,
+   PIPE_FORMAT_R8_UNORM
+};
+
+const enum pipe_format const_resource_formats_NV12[3] = {
+   PIPE_FORMAT_R8_UNORM,
+   PIPE_FORMAT_R8G8_UNORM,
+   PIPE_FORMAT_NONE
+};
+
+const enum pipe_format *
+vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format)
+{
+   switch(format) {
+   case PIPE_FORMAT_YV12:
+      return const_resource_formats_YV12;
+
+   case PIPE_FORMAT_NV12:
+      return const_resource_formats_NV12;
+
+   default:
+      return NULL;
+   }
+}
+
+boolean
+vl_video_buffer_is_format_supported(struct pipe_screen *screen,
+                                    enum pipe_format format,
+                                    enum pipe_video_profile profile)
+{
+   const enum pipe_format *resource_formats;
+   unsigned i;
+
+   resource_formats = vl_video_buffer_formats(screen, format);
+   if (!resource_formats)
+      return false;
+
+   for(i = 0; i < VL_MAX_PLANES; ++i) {
+      if (!resource_formats[i])
+         continue;
+
+      if (!screen->is_format_supported(screen, resource_formats[i], PIPE_TEXTURE_2D, 0, PIPE_USAGE_STATIC))
+         return false;
+   }
+
+   return true;
+}
+
+unsigned
+vl_video_buffer_max_size(struct pipe_screen *screen)
+{
+   uint32_t max_2d_texture_level;
+
+   max_2d_texture_level = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+
+   return 1 << (max_2d_texture_level-1);
+}
+
+static void
+vl_video_buffer_destroy(struct pipe_video_buffer *buffer)
+{
+   struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
+   unsigned i;
+
+   assert(buf);
+
+   for (i = 0; i < VL_MAX_PLANES; ++i) {
+      pipe_surface_reference(&buf->surfaces[i], NULL);
+      pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL);
+      pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);
+      pipe_resource_reference(&buf->resources[i], NULL);
+   }
+
+   FREE(buffer);
+}
+
+static struct pipe_sampler_view **
+vl_video_buffer_sampler_view_planes(struct pipe_video_buffer *buffer)
+{
+   struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
+   struct pipe_sampler_view sv_templ;
+   struct pipe_context *pipe;
+   unsigned i;
+
+   assert(buf);
+
+   pipe = buf->base.context;
+
+   for (i = 0; i < buf->num_planes; ++i ) {
+      if (!buf->sampler_view_planes[i]) {
+         memset(&sv_templ, 0, sizeof(sv_templ));
+         u_sampler_view_default_template(&sv_templ, buf->resources[i], buf->resources[i]->format);
+
+         if (util_format_get_nr_components(buf->resources[i]->format) == 1)
+            sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = sv_templ.swizzle_a = PIPE_SWIZZLE_RED;
+
+         buf->sampler_view_planes[i] = pipe->create_sampler_view(pipe, buf->resources[i], &sv_templ);
+         if (!buf->sampler_view_planes[i])
+            goto error;
+      }
+   }
+
+   return buf->sampler_view_planes;
+
+error:
+   for (i = 0; i < buf->num_planes; ++i )
+      pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL);
+
+   return NULL;
+}
+
+static struct pipe_sampler_view **
+vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
+{
+   struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
+   struct pipe_sampler_view sv_templ;
+   struct pipe_context *pipe;
+   unsigned i, j, component;
+
+   assert(buf);
+
+   pipe = buf->base.context;
+
+   for (component = 0, i = 0; i < buf->num_planes; ++i ) {
+      unsigned nr_components = util_format_get_nr_components(buf->resources[i]->format);
+
+      for (j = 0; j < nr_components; ++j, ++component) {
+         assert(component < VL_MAX_PLANES);
+
+         if (!buf->sampler_view_components[component]) {
+            memset(&sv_templ, 0, sizeof(sv_templ));
+            u_sampler_view_default_template(&sv_templ, buf->resources[i], buf->resources[i]->format);
+            sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = PIPE_SWIZZLE_RED + j;
+            sv_templ.swizzle_a = PIPE_SWIZZLE_ONE;
+            buf->sampler_view_components[component] = pipe->create_sampler_view(pipe, buf->resources[i], &sv_templ);
+            if (!buf->sampler_view_components[component])
+               goto error;
+         }
+      }
+   }
+
+   return buf->sampler_view_components;
+
+error:
+   for (i = 0; i < VL_MAX_PLANES; ++i )
+      pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);
+
+   return NULL;
+}
+
+static struct pipe_surface **
+vl_video_buffer_surfaces(struct pipe_video_buffer *buffer)
+{
+   struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
+   struct pipe_surface surf_templ;
+   struct pipe_context *pipe;
+   unsigned i;
+
+   assert(buf);
+
+   pipe = buf->base.context;
+
+   for (i = 0; i < buf->num_planes; ++i ) {
+      if (!buf->surfaces[i]) {
+         memset(&surf_templ, 0, sizeof(surf_templ));
+         surf_templ.format = buf->resources[i]->format;
+         surf_templ.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+         buf->surfaces[i] = pipe->create_surface(pipe, buf->resources[i], &surf_templ);
+         if (!buf->surfaces[i])
+            goto error;
+      }
+   }
+
+   return buf->surfaces;
+
+error:
+   for (i = 0; i < buf->num_planes; ++i )
+      pipe_surface_reference(&buf->surfaces[i], NULL);
+
+   return NULL;
+}
+
+struct pipe_video_buffer *
+vl_video_buffer_create(struct pipe_context *pipe,
+                       enum pipe_format buffer_format,
+                       enum pipe_video_chroma_format chroma_format,
+                       unsigned width, unsigned height)
+{
+   const enum pipe_format *resource_formats;
+   struct pipe_video_buffer *result;
+   unsigned buffer_width, buffer_height;
+   bool pot_buffers;
+
+   assert(pipe);
+   assert(width > 0 && height > 0);
+
+   pot_buffers = !pipe->screen->get_video_param
+   (
+      pipe->screen,
+      PIPE_VIDEO_PROFILE_UNKNOWN,
+      PIPE_VIDEO_CAP_NPOT_TEXTURES
+   );
+
+   resource_formats = vl_video_buffer_formats(pipe->screen, buffer_format);
+   if (!resource_formats)
+      return NULL;
+
+   buffer_width = pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH);
+   buffer_height = pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT);
+
+   result = vl_video_buffer_create_ex
+   (
+      pipe, buffer_width, buffer_height, 1,
+      chroma_format, resource_formats, PIPE_USAGE_STATIC
+   );
+   if (result)
+      result->buffer_format = buffer_format;
+
+   return result;
+}
+
+struct pipe_video_buffer *
+vl_video_buffer_create_ex(struct pipe_context *pipe,
+                          unsigned width, unsigned height, unsigned depth,
+                          enum pipe_video_chroma_format chroma_format,
+                          const enum pipe_format resource_formats[VL_MAX_PLANES],
+                          unsigned usage)
+{
+   struct vl_video_buffer *buffer;
+   struct pipe_resource templ;
+   unsigned i;
+
+   assert(pipe);
+
+   buffer = CALLOC_STRUCT(vl_video_buffer);
+
+   buffer->base.context = pipe;
+   buffer->base.destroy = vl_video_buffer_destroy;
+   buffer->base.get_sampler_view_planes = vl_video_buffer_sampler_view_planes;
+   buffer->base.get_sampler_view_components = vl_video_buffer_sampler_view_components;
+   buffer->base.get_surfaces = vl_video_buffer_surfaces;
+   buffer->base.chroma_format = chroma_format;
+   buffer->base.width = width;
+   buffer->base.height = height;
+   buffer->num_planes = 1;
+
+   memset(&templ, 0, sizeof(templ));
+   templ.target = depth > 1 ? PIPE_TEXTURE_3D : PIPE_TEXTURE_2D;
+   templ.format = resource_formats[0];
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = depth;
+   templ.array_size = 1;
+   templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+   templ.usage = usage;
+
+   buffer->resources[0] = pipe->screen->resource_create(pipe->screen, &templ);
+   if (!buffer->resources[0])
+      goto error;
+
+   if (resource_formats[1] == PIPE_FORMAT_NONE) {
+      assert(chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444);
+      assert(resource_formats[2] == PIPE_FORMAT_NONE);
+      return &buffer->base;
+   } else
+      buffer->num_planes = 2;
+
+   templ.format = resource_formats[1];
+   if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
+      templ.width0 /= 2;
+      templ.height0 /= 2;
+   } else if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
+      templ.height0 /= 2;
+   }
+
+   buffer->resources[1] = pipe->screen->resource_create(pipe->screen, &templ);
+   if (!buffer->resources[1])
+      goto error;
+
+   if (resource_formats[2] == PIPE_FORMAT_NONE)
+      return &buffer->base;
+   else
+      buffer->num_planes = 3;
+
+   templ.format = resource_formats[2];
+   buffer->resources[2] = pipe->screen->resource_create(pipe->screen, &templ);
+   if (!buffer->resources[2])
+      goto error;
+
+   return &buffer->base;
+
+error:
+   for (i = 0; i < VL_MAX_PLANES; ++i)
+      pipe_resource_reference(&buffer->resources[i], NULL);
+   FREE(buffer);
+
+   return NULL;
+}
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h
new file mode 100644 (file)
index 0000000..291d15c
--- /dev/null
@@ -0,0 +1,91 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Christian König.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_ycbcr_buffer_h
+#define vl_ycbcr_buffer_h
+
+#include <pipe/p_context.h>
+#include <pipe/p_video_decoder.h>
+
+#include "vl_defines.h"
+
+/**
+ * implementation of a planar ycbcr buffer
+ */
+
+/* planar buffer for vl data upload and manipulation */
+struct vl_video_buffer
+{
+   struct pipe_video_buffer base;
+   unsigned                 num_planes;
+   struct pipe_resource     *resources[VL_MAX_PLANES];
+   struct pipe_sampler_view *sampler_view_planes[VL_MAX_PLANES];
+   struct pipe_sampler_view *sampler_view_components[VL_MAX_PLANES];
+   struct pipe_surface      *surfaces[VL_MAX_PLANES];
+};
+
+/**
+ * get subformats for each plane
+ */
+const enum pipe_format *
+vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format);
+
+/**
+ * get maximum size of video buffers
+ */
+unsigned
+vl_video_buffer_max_size(struct pipe_screen *screen);
+
+/**
+ * check if video buffer format is supported for a codec/profile
+ * can be used as default implementation of screen->is_video_format_supported
+ */
+boolean
+vl_video_buffer_is_format_supported(struct pipe_screen *screen,
+                                    enum pipe_format format,
+                                    enum pipe_video_profile profile);
+                                    
+/**
+ * creates a video buffer, can be used as a standard implementation for pipe->create_video_buffer
+ */
+struct pipe_video_buffer *
+vl_video_buffer_create(struct pipe_context *pipe,
+                       enum pipe_format buffer_format,
+                       enum pipe_video_chroma_format chroma_format,
+                       unsigned width, unsigned height);
+
+/**
+ * extended create function, gets depth, usage and formats for each plane seperately
+ */
+struct pipe_video_buffer *
+vl_video_buffer_create_ex(struct pipe_context *pipe,
+                          unsigned width, unsigned height, unsigned depth,
+                          enum pipe_video_chroma_format chroma_format,
+                          const enum pipe_format resource_formats[VL_MAX_PLANES],
+                          unsigned usage);
+
+#endif /* vl_ycbcr_buffer_h */
diff --git a/src/gallium/auxiliary/vl/vl_vlc.h b/src/gallium/auxiliary/vl/vl_vlc.h
new file mode 100644 (file)
index 0000000..e81b1e9
--- /dev/null
@@ -0,0 +1,140 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Christian König.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+
+/**
+ * This file is based uppon slice_xvmc.c and vlc.h from the xine project,
+ * which in turn is based on mpeg2dec. The following is the original copyright:
+ *
+ * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+ * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+ *
+ * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
+ * See http://libmpeg2.sourceforge.net/ for updates.
+ *
+ * mpeg2dec is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * mpeg2dec is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef vl_vlc_h
+#define vl_vlc_h
+
+#include "pipe/p_compiler.h"
+
+struct vl_vlc
+{
+   uint32_t buf; /* current 32 bit working set of buffer */
+   int bits;     /* used bits in working set */
+   const uint8_t *ptr; /* buffer with stream data */
+   const uint8_t *max; /* ptr+len of buffer */
+};
+
+static INLINE void
+vl_vlc_restart(struct vl_vlc *vlc)
+{
+   vlc->buf = (vlc->ptr[0] << 24) | (vlc->ptr[1] << 16) | (vlc->ptr[2] << 8) | vlc->ptr[3];
+   vlc->bits = -16;
+   vlc->ptr += 4;
+}
+
+static INLINE void
+vl_vlc_init(struct vl_vlc *vlc, const uint8_t *data, unsigned len)
+{
+   vlc->ptr = data;
+   vlc->max = data + len;
+   vl_vlc_restart(vlc);
+}
+
+static INLINE bool
+vl_vlc_getbyte(struct vl_vlc *vlc)
+{
+   vlc->buf <<= 8;
+   vlc->buf |= vlc->ptr[0];
+   vlc->ptr++;
+   return vlc->ptr < vlc->max;
+}
+
+#define vl_vlc_getword(vlc, shift)                                      \
+do {                                                                    \
+   (vlc)->buf |= (((vlc)->ptr[0] << 8) | (vlc)->ptr[1]) << (shift);     \
+   (vlc)->ptr += 2;                                                     \
+} while (0)
+
+/* make sure that there are at least 16 valid bits in bit_buf */
+#define vl_vlc_needbits(vlc)                    \
+do {                                            \
+    if ((vlc)->bits >= 0) {                      \
+       vl_vlc_getword(vlc, (vlc)->bits);       \
+       (vlc)->bits -= 16;                      \
+    }                                           \
+} while (0)
+
+/* make sure that the full 32 bit of the buffer are valid */
+static INLINE void
+vl_vlc_need32bits(struct vl_vlc *vlc)
+{
+   vl_vlc_needbits(vlc);
+   if (vlc->bits > -8) {
+      unsigned n = -vlc->bits;
+      vlc->buf <<= n;
+      vlc->buf |= *vlc->ptr << 8;
+      vlc->bits = -8;
+      vlc->ptr++;
+   }
+   if (vlc->bits > -16) {
+      unsigned n = -vlc->bits - 8;
+      vlc->buf <<= n;
+      vlc->buf |= *vlc->ptr;
+      vlc->bits = -16;
+      vlc->ptr++;
+   }
+}
+
+/* remove num valid bits from bit_buf */
+#define vl_vlc_dumpbits(vlc, num)       \
+do {                                   \
+    (vlc)->buf <<= (num);              \
+    (vlc)->bits += (num);              \
+} while (0)
+
+/* take num bits from the high part of bit_buf and zero extend them */
+#define vl_vlc_ubits(vlc, num) (((uint32_t)((vlc)->buf)) >> (32 - (num)))
+
+/* take num bits from the high part of bit_buf and sign extend them */
+#define vl_vlc_sbits(vlc, num) (((int32_t)((vlc)->buf)) >> (32 - (num)))
+
+#endif /* vl_vlc_h */
diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c
new file mode 100644 (file)
index 0000000..fde27f3
--- /dev/null
@@ -0,0 +1,609 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Christian König
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <pipe/p_screen.h>
+#include <pipe/p_context.h>
+
+#include <util/u_draw.h>
+#include <util/u_sampler.h>
+#include <util/u_inlines.h>
+#include <util/u_memory.h>
+
+#include <tgsi/tgsi_ureg.h>
+
+#include <vl/vl_defines.h>
+#include <vl/vl_types.h>
+
+#include "vl_zscan.h"
+#include "vl_vertex_buffers.h"
+
+enum VS_OUTPUT
+{
+   VS_O_VPOS,
+   VS_O_VTEX
+};
+
+const int vl_zscan_linear[] =
+{
+   /* Linear scan pattern */
+    0, 1, 2, 3, 4, 5, 6, 7,
+    8, 9,10,11,12,13,14,15,
+   16,17,18,19,20,21,22,23,
+   24,25,26,27,28,29,30,31,
+   32,33,34,35,36,37,38,39,
+   40,41,42,43,44,45,46,47,
+   48,49,50,51,52,53,54,55,
+   56,57,58,59,60,61,62,63
+};
+
+const int vl_zscan_normal[] =
+{
+   /* Zig-Zag scan pattern */
+    0, 1, 8,16, 9, 2, 3,10,
+   17,24,32,25,18,11, 4, 5,
+   12,19,26,33,40,48,41,34,
+   27,20,13, 6, 7,14,21,28,
+   35,42,49,56,57,50,43,36,
+   29,22,15,23,30,37,44,51,
+   58,59,52,45,38,31,39,46,
+   53,60,61,54,47,55,62,63
+};
+
+const int vl_zscan_alternate[] =
+{
+   /* Alternate scan pattern */
+    0, 8,16,24, 1, 9, 2,10,
+   17,25,32,40,48,56,57,49,
+   41,33,26,18, 3,11, 4,12,
+   19,27,34,42,50,58,35,43,
+   51,59,20,28, 5,13, 6,14,
+   21,29,36,44,52,60,37,45,
+   53,61,22,30, 7,15,23,31,
+   38,46,54,62,39,47,55,63
+};
+
+static void *
+create_vert_shader(struct vl_zscan *zscan)
+{
+   struct ureg_program *shader;
+
+   struct ureg_src scale;
+   struct ureg_src vrect, vpos, block_num;
+
+   struct ureg_dst tmp;
+   struct ureg_dst o_vpos;
+   struct ureg_dst *o_vtex;
+
+   signed i;
+
+   shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+   if (!shader)
+      return NULL;
+
+   o_vtex = MALLOC(zscan->num_channels * sizeof(struct ureg_dst));
+
+   scale = ureg_imm2f(shader,
+      (float)BLOCK_WIDTH / zscan->buffer_width,
+      (float)BLOCK_HEIGHT / zscan->buffer_height);
+
+   vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
+   vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
+   block_num = ureg_DECL_vs_input(shader, VS_I_BLOCK_NUM);
+
+   tmp = ureg_DECL_temporary(shader);
+
+   o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
+
+   for (i = 0; i < zscan->num_channels; ++i)
+      o_vtex[i] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX + i);
+
+   /*
+    * o_vpos.xy = (vpos + vrect) * scale
+    * o_vpos.zw = 1.0f
+    *
+    * tmp.xy = InstanceID / blocks_per_line
+    * tmp.x = frac(tmp.x)
+    * tmp.y = floor(tmp.y)
+    *
+    * o_vtex.x = vrect.x / blocks_per_line + tmp.x
+    * o_vtex.y = vrect.y
+    * o_vtex.z = tmp.z * blocks_per_line / blocks_total
+    */
+   ureg_ADD(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XY), vpos, vrect);
+   ureg_MUL(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_XY), ureg_src(tmp), scale);
+   ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_ZW), ureg_imm1f(shader, 1.0f));
+
+   ureg_MUL(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XW), ureg_scalar(block_num, TGSI_SWIZZLE_X),
+            ureg_imm1f(shader, 1.0f / zscan->blocks_per_line));
+
+   ureg_FRC(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X));
+   ureg_FLR(shader, ureg_writemask(tmp, TGSI_WRITEMASK_W), ureg_src(tmp));
+
+   for (i = 0; i < zscan->num_channels; ++i) {
+      ureg_ADD(shader, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y),
+               ureg_imm1f(shader, 1.0f / (zscan->blocks_per_line * BLOCK_WIDTH) * (i - (signed)zscan->num_channels / 2)));
+
+      ureg_MAD(shader, ureg_writemask(o_vtex[i], TGSI_WRITEMASK_X), vrect,
+               ureg_imm1f(shader, 1.0f / zscan->blocks_per_line), ureg_src(tmp));
+      ureg_MOV(shader, ureg_writemask(o_vtex[i], TGSI_WRITEMASK_Y), vrect);
+      ureg_MOV(shader, ureg_writemask(o_vtex[i], TGSI_WRITEMASK_Z), vpos);
+      ureg_MUL(shader, ureg_writemask(o_vtex[i], TGSI_WRITEMASK_W), ureg_src(tmp),
+               ureg_imm1f(shader, (float)zscan->blocks_per_line / zscan->blocks_total));
+   }
+
+   ureg_release_temporary(shader, tmp);
+   ureg_END(shader);
+
+   FREE(o_vtex);
+
+   return ureg_create_shader_and_destroy(shader, zscan->pipe);
+}
+
+static void *
+create_frag_shader(struct vl_zscan *zscan)
+{
+   struct ureg_program *shader;
+   struct ureg_src *vtex;
+
+   struct ureg_src samp_src, samp_scan, samp_quant;
+
+   struct ureg_dst *tmp;
+   struct ureg_dst quant, fragment;
+
+   unsigned i;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return NULL;
+
+   vtex = MALLOC(zscan->num_channels * sizeof(struct ureg_src));
+   tmp = MALLOC(zscan->num_channels * sizeof(struct ureg_dst));
+
+   for (i = 0; i < zscan->num_channels; ++i)
+      vtex[i] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX + i, TGSI_INTERPOLATE_LINEAR);
+
+   samp_src = ureg_DECL_sampler(shader, 0);
+   samp_scan = ureg_DECL_sampler(shader, 1);
+   samp_quant = ureg_DECL_sampler(shader, 2);
+
+   for (i = 0; i < zscan->num_channels; ++i)
+      tmp[i] = ureg_DECL_temporary(shader);
+   quant = ureg_DECL_temporary(shader);
+
+   fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+   /*
+    * tmp.x = tex(vtex, 1)
+    * tmp.y = vtex.z
+    * fragment = tex(tmp, 0) * quant
+    */
+   for (i = 0; i < zscan->num_channels; ++i)
+      ureg_TEX(shader, ureg_writemask(tmp[i], TGSI_WRITEMASK_X), TGSI_TEXTURE_2D, vtex[i], samp_scan);
+
+   for (i = 0; i < zscan->num_channels; ++i)
+      ureg_MOV(shader, ureg_writemask(tmp[i], TGSI_WRITEMASK_Y), ureg_scalar(vtex[i], TGSI_SWIZZLE_W));
+
+   for (i = 0; i < zscan->num_channels; ++i) {
+      ureg_TEX(shader, ureg_writemask(tmp[0], TGSI_WRITEMASK_X << i), TGSI_TEXTURE_2D, ureg_src(tmp[i]), samp_src);
+      ureg_TEX(shader, ureg_writemask(quant, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_3D, vtex[i], samp_quant);
+   }
+
+   ureg_MUL(shader, quant, ureg_src(quant), ureg_imm1f(shader, 16.0f));
+   ureg_MUL(shader, fragment, ureg_src(tmp[0]), ureg_src(quant));
+
+   for (i = 0; i < zscan->num_channels; ++i)
+      ureg_release_temporary(shader, tmp[i]);
+   ureg_END(shader);
+
+   FREE(vtex);
+   FREE(tmp);
+
+   return ureg_create_shader_and_destroy(shader, zscan->pipe);
+}
+
+static bool
+init_shaders(struct vl_zscan *zscan)
+{
+   assert(zscan);
+
+   zscan->vs = create_vert_shader(zscan);
+   if (!zscan->vs)
+      goto error_vs;
+
+   zscan->fs = create_frag_shader(zscan);
+   if (!zscan->fs)
+      goto error_fs;
+
+   return true;
+
+error_fs:
+   zscan->pipe->delete_vs_state(zscan->pipe, zscan->vs);
+
+error_vs:
+   return false;
+}
+
+static void
+cleanup_shaders(struct vl_zscan *zscan)
+{
+   assert(zscan);
+
+   zscan->pipe->delete_vs_state(zscan->pipe, zscan->vs);
+   zscan->pipe->delete_fs_state(zscan->pipe, zscan->fs);
+}
+
+static bool
+init_state(struct vl_zscan *zscan)
+{
+   struct pipe_blend_state blend;
+   struct pipe_rasterizer_state rs_state;
+   struct pipe_sampler_state sampler;
+   unsigned i;
+
+   assert(zscan);
+
+   memset(&rs_state, 0, sizeof(rs_state));
+   rs_state.gl_rasterization_rules = true;
+   zscan->rs_state = zscan->pipe->create_rasterizer_state(zscan->pipe, &rs_state);
+   if (!zscan->rs_state)
+      goto error_rs_state;
+
+   memset(&blend, 0, sizeof blend);
+
+   blend.independent_blend_enable = 0;
+   blend.rt[0].blend_enable = 0;
+   blend.rt[0].rgb_func = PIPE_BLEND_ADD;
+   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_func = PIPE_BLEND_ADD;
+   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.logicop_enable = 0;
+   blend.logicop_func = PIPE_LOGICOP_CLEAR;
+   /* Needed to allow color writes to FB, even if blending disabled */
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
+   blend.dither = 0;
+   zscan->blend = zscan->pipe->create_blend_state(zscan->pipe, &blend);
+   if (!zscan->blend)
+      goto error_blend;
+
+   for (i = 0; i < 3; ++i) {
+      memset(&sampler, 0, sizeof(sampler));
+      sampler.wrap_s = PIPE_TEX_WRAP_REPEAT;
+      sampler.wrap_t = PIPE_TEX_WRAP_REPEAT;
+      sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+      sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
+      sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+      sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
+      sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
+      sampler.compare_func = PIPE_FUNC_ALWAYS;
+      sampler.normalized_coords = 1;
+      zscan->samplers[i] = zscan->pipe->create_sampler_state(zscan->pipe, &sampler);
+      if (!zscan->samplers[i])
+         goto error_samplers;
+   }
+
+   return true;
+
+error_samplers:
+   for (i = 0; i < 2; ++i)
+      if (zscan->samplers[i])
+         zscan->pipe->delete_sampler_state(zscan->pipe, zscan->samplers[i]);
+
+   zscan->pipe->delete_rasterizer_state(zscan->pipe, zscan->rs_state);
+
+error_blend:
+   zscan->pipe->delete_blend_state(zscan->pipe, zscan->blend);
+
+error_rs_state:
+   return false;
+}
+
+static void
+cleanup_state(struct vl_zscan *zscan)
+{
+   unsigned i;
+
+   assert(zscan);
+
+   for (i = 0; i < 3; ++i)
+      zscan->pipe->delete_sampler_state(zscan->pipe, zscan->samplers[i]);
+
+   zscan->pipe->delete_rasterizer_state(zscan->pipe, zscan->rs_state);
+   zscan->pipe->delete_blend_state(zscan->pipe, zscan->blend);
+}
+
+struct pipe_sampler_view *
+vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks_per_line)
+{
+   const unsigned total_size = blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT;
+
+   int patched_layout[64];
+
+   struct pipe_resource res_tmpl, *res;
+   struct pipe_sampler_view sv_tmpl, *sv;
+   struct pipe_transfer *buf_transfer;
+   unsigned x, y, i, pitch;
+   float *f;
+
+   struct pipe_box rect =
+   {
+      0, 0, 0,
+      BLOCK_WIDTH * blocks_per_line,
+      BLOCK_HEIGHT,
+      1
+   };
+
+   assert(pipe && layout && blocks_per_line);
+
+   for (i = 0; i < 64; ++i)
+      patched_layout[layout[i]] = i;
+
+   memset(&res_tmpl, 0, sizeof(res_tmpl));
+   res_tmpl.target = PIPE_TEXTURE_2D;
+   res_tmpl.format = PIPE_FORMAT_R32_FLOAT;
+   res_tmpl.width0 = BLOCK_WIDTH * blocks_per_line;
+   res_tmpl.height0 = BLOCK_HEIGHT;
+   res_tmpl.depth0 = 1;
+   res_tmpl.array_size = 1;
+   res_tmpl.usage = PIPE_USAGE_IMMUTABLE;
+   res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
+
+   res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
+   if (!res)
+      goto error_resource;
+
+   buf_transfer = pipe->get_transfer
+   (
+      pipe, res,
+      0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+      &rect
+   );
+   if (!buf_transfer)
+      goto error_transfer;
+
+   pitch = buf_transfer->stride / sizeof(float);
+
+   f = pipe->transfer_map(pipe, buf_transfer);
+   if (!f)
+      goto error_map;
+
+   for (i = 0; i < blocks_per_line; ++i)
+      for (y = 0; y < BLOCK_HEIGHT; ++y)
+         for (x = 0; x < BLOCK_WIDTH; ++x) {
+            float addr = patched_layout[x + y * BLOCK_WIDTH] +
+               i * BLOCK_WIDTH * BLOCK_HEIGHT;
+
+            addr /= total_size;
+
+            f[i * BLOCK_WIDTH + y * pitch + x] = addr;
+         }
+
+   pipe->transfer_unmap(pipe, buf_transfer);
+   pipe->transfer_destroy(pipe, buf_transfer);
+
+   memset(&sv_tmpl, 0, sizeof(sv_tmpl));
+   u_sampler_view_default_template(&sv_tmpl, res, res->format);
+   sv = pipe->create_sampler_view(pipe, res, &sv_tmpl);
+   pipe_resource_reference(&res, NULL);
+   if (!sv)
+      goto error_map;
+
+   return sv;
+
+error_map:
+   pipe->transfer_destroy(pipe, buf_transfer);
+
+error_transfer:
+   pipe_resource_reference(&res, NULL);
+
+error_resource:
+   return NULL;
+}
+
+bool
+vl_zscan_init(struct vl_zscan *zscan, struct pipe_context *pipe,
+              unsigned buffer_width, unsigned buffer_height,
+              unsigned blocks_per_line, unsigned blocks_total,
+              unsigned num_channels)
+{
+   assert(zscan && pipe);
+
+   zscan->pipe = pipe;
+   zscan->buffer_width = buffer_width;
+   zscan->buffer_height = buffer_height;
+   zscan->num_channels = num_channels;
+   zscan->blocks_per_line = blocks_per_line;
+   zscan->blocks_total = blocks_total;
+
+   if(!init_shaders(zscan))
+      return false;
+
+   if(!init_state(zscan)) {
+      cleanup_shaders(zscan);
+      return false;
+   }
+
+   return true;
+}
+
+void
+vl_zscan_cleanup(struct vl_zscan *zscan)
+{
+   assert(zscan);
+
+   cleanup_shaders(zscan);
+   cleanup_state(zscan);
+}
+
+bool
+vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
+                     struct pipe_sampler_view *src, struct pipe_surface *dst)
+{
+   struct pipe_resource res_tmpl, *res;
+   struct pipe_sampler_view sv_tmpl;
+
+   assert(zscan && buffer);
+
+   memset(buffer, 0, sizeof(struct vl_zscan_buffer));
+
+   buffer->zscan = zscan;
+
+   pipe_sampler_view_reference(&buffer->src, src);
+
+   buffer->viewport.scale[0] = dst->width;
+   buffer->viewport.scale[1] = dst->height;
+   buffer->viewport.scale[2] = 1;
+   buffer->viewport.scale[3] = 1;
+   buffer->viewport.translate[0] = 0;
+   buffer->viewport.translate[1] = 0;
+   buffer->viewport.translate[2] = 0;
+   buffer->viewport.translate[3] = 0;
+
+   buffer->fb_state.width = dst->width;
+   buffer->fb_state.height = dst->height;
+   buffer->fb_state.nr_cbufs = 1;
+   pipe_surface_reference(&buffer->fb_state.cbufs[0], dst);
+
+   memset(&res_tmpl, 0, sizeof(res_tmpl));
+   res_tmpl.target = PIPE_TEXTURE_3D;
+   res_tmpl.format = PIPE_FORMAT_R8_UNORM;
+   res_tmpl.width0 = BLOCK_WIDTH * zscan->blocks_per_line;
+   res_tmpl.height0 = BLOCK_HEIGHT;
+   res_tmpl.depth0 = 2;
+   res_tmpl.array_size = 1;
+   res_tmpl.usage = PIPE_USAGE_IMMUTABLE;
+   res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
+
+   res = zscan->pipe->screen->resource_create(zscan->pipe->screen, &res_tmpl);
+   if (!res)
+      return false;
+
+   memset(&sv_tmpl, 0, sizeof(sv_tmpl));
+   u_sampler_view_default_template(&sv_tmpl, res, res->format);
+   sv_tmpl.swizzle_r = sv_tmpl.swizzle_g = sv_tmpl.swizzle_b = sv_tmpl.swizzle_a = TGSI_SWIZZLE_X;
+   buffer->quant = zscan->pipe->create_sampler_view(zscan->pipe, res, &sv_tmpl);
+   pipe_resource_reference(&res, NULL);
+   if (!buffer->quant)
+      return false;
+
+   return true;
+}
+
+void
+vl_zscan_cleanup_buffer(struct vl_zscan_buffer *buffer)
+{
+   assert(buffer);
+
+   pipe_sampler_view_reference(&buffer->src, NULL);
+   pipe_sampler_view_reference(&buffer->layout, NULL);
+   pipe_sampler_view_reference(&buffer->quant, NULL);
+   pipe_surface_reference(&buffer->fb_state.cbufs[0], NULL);
+}
+
+void
+vl_zscan_set_layout(struct vl_zscan_buffer *buffer, struct pipe_sampler_view *layout)
+{
+   assert(buffer);
+   assert(layout);
+
+   pipe_sampler_view_reference(&buffer->layout, layout);
+}
+
+void
+vl_zscan_upload_quant(struct vl_zscan_buffer *buffer, const uint8_t matrix[64], bool intra)
+{
+   struct pipe_context *pipe;
+   struct pipe_transfer *buf_transfer;
+   unsigned x, y, i, pitch;
+   uint8_t *data;
+
+   struct pipe_box rect =
+   {
+      0, 0, intra ? 1 : 0,
+      BLOCK_WIDTH,
+      BLOCK_HEIGHT,
+      1
+   };
+
+   assert(buffer);
+   assert(matrix);
+
+   pipe = buffer->zscan->pipe;
+
+   rect.width *= buffer->zscan->blocks_per_line;
+
+   buf_transfer = pipe->get_transfer
+   (
+      pipe, buffer->quant->texture,
+      0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+      &rect
+   );
+   if (!buf_transfer)
+      goto error_transfer;
+
+   pitch = buf_transfer->stride;
+
+   data = pipe->transfer_map(pipe, buf_transfer);
+   if (!data)
+      goto error_map;
+
+   for (i = 0; i < buffer->zscan->blocks_per_line; ++i)
+      for (y = 0; y < BLOCK_HEIGHT; ++y)
+         for (x = 0; x < BLOCK_WIDTH; ++x)
+            data[i * BLOCK_WIDTH + y * pitch + x] = matrix[x + y * BLOCK_WIDTH];
+
+   pipe->transfer_unmap(pipe, buf_transfer);
+
+error_map:
+   pipe->transfer_destroy(pipe, buf_transfer);
+
+error_transfer:
+   return;
+}
+
+void
+vl_zscan_render(struct vl_zscan_buffer *buffer, unsigned num_instances)
+{
+   struct vl_zscan *zscan;
+
+   assert(buffer);
+
+   zscan = buffer->zscan;
+
+   zscan->pipe->bind_rasterizer_state(zscan->pipe, zscan->rs_state);
+   zscan->pipe->bind_blend_state(zscan->pipe, zscan->blend);
+   zscan->pipe->bind_fragment_sampler_states(zscan->pipe, 3, zscan->samplers);
+   zscan->pipe->set_framebuffer_state(zscan->pipe, &buffer->fb_state);
+   zscan->pipe->set_viewport_state(zscan->pipe, &buffer->viewport);
+   zscan->pipe->set_fragment_sampler_views(zscan->pipe, 3, &buffer->src);
+   zscan->pipe->bind_vs_state(zscan->pipe, zscan->vs);
+   zscan->pipe->bind_fs_state(zscan->pipe, zscan->fs);
+   util_draw_arrays_instanced(zscan->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_instances);
+}
diff --git a/src/gallium/auxiliary/vl/vl_zscan.h b/src/gallium/auxiliary/vl/vl_zscan.h
new file mode 100644 (file)
index 0000000..dd8a943
--- /dev/null
@@ -0,0 +1,101 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Christian König
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_zscan_h
+#define vl_zscan_h
+
+#include <pipe/p_compiler.h>
+#include <pipe/p_state.h>
+
+/*
+ * shader based zscan and quantification
+ * expect usage of vl_vertex_buffers as a todo list
+ */
+struct vl_zscan
+{
+   struct pipe_context *pipe;
+
+   unsigned buffer_width;
+   unsigned buffer_height;
+
+   unsigned num_channels;
+
+   unsigned blocks_per_line;
+   unsigned blocks_total;
+
+   void *rs_state;
+   void *blend;
+
+   void *samplers[3];
+
+   void *vs, *fs;
+};
+
+struct vl_zscan_buffer
+{
+   struct vl_zscan *zscan;
+
+   struct pipe_viewport_state viewport;
+   struct pipe_framebuffer_state fb_state;
+
+   struct pipe_sampler_view *src, *layout, *quant;
+   struct pipe_surface *dst;
+};
+
+extern const int vl_zscan_linear[];
+extern const int vl_zscan_normal[];
+extern const int vl_zscan_alternate[];
+
+struct pipe_sampler_view *
+vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks_per_line);
+
+bool
+vl_zscan_init(struct vl_zscan *zscan, struct pipe_context *pipe,
+              unsigned buffer_width, unsigned buffer_height,
+              unsigned blocks_per_line, unsigned blocks_total,
+              unsigned num_channels);
+
+void
+vl_zscan_cleanup(struct vl_zscan *zscan);
+
+bool
+vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
+                     struct pipe_sampler_view *src, struct pipe_surface *dst);
+
+void
+vl_zscan_cleanup_buffer(struct vl_zscan_buffer *buffer);
+
+void
+vl_zscan_set_layout(struct vl_zscan_buffer *buffer, struct pipe_sampler_view *layout);
+
+void
+vl_zscan_upload_quant(struct vl_zscan_buffer *buffer, const uint8_t matrix[64], bool intra);
+
+void
+vl_zscan_render(struct vl_zscan_buffer *buffer, unsigned num_instances);
+
+#endif
index 25a3245..3faf801 100644 (file)
@@ -329,8 +329,15 @@ textured quad blitter.. The source and destination may be the same resource,
 but overlapping blits are not permitted.
 
 ``resource_resolve`` resolves a multisampled resource into a non-multisampled
-one. Formats and dimensions must match. This function must be present if a driver
+one. Their formats must match. This function must be present if a driver
 supports multisampling.
+The region that is to be resolved is described by ``pipe_resolve_info``, which
+provides a source and a destination rectangle.
+The source rectangle may be vertically flipped, but otherwise the dimensions
+of the rectangles must match, unless PIPE_CAP_SCALED_RESOLVE is supported,
+in which case scaling and horizontal flipping are allowed as well.
+The result of resolving depth/stencil values may be any function of the values at
+the sample points, but returning the value of the centermost sample is preferred.
 
 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
index b3f387f..36197fb 100644 (file)
@@ -21,11 +21,13 @@ C_SOURCES = \
        i915_screen.c \
        i915_prim_emit.c \
        i915_prim_vbuf.c \
+       i915_query.c \
        i915_resource.c \
        i915_resource_texture.c \
        i915_resource_buffer.c \
        i915_fpc_emit.c \
        i915_fpc_translate.c \
+       i915_fpc_optimize.c \
        i915_surface.c 
 
 include ../../Makefile.template
index 8f5deed..76f5970 100644 (file)
@@ -14,8 +14,10 @@ i915 = env.ConvenienceLibrary(
                'i915_flush.c',
                'i915_fpc_emit.c',
                'i915_fpc_translate.c',
+               'i915_fpc_optimize.c',
                'i915_prim_emit.c',
                'i915_prim_vbuf.c',
+               'i915_query.c',
                'i915_screen.c',
                'i915_state.c',
                'i915_state_derived.c',
index fba1800..c26db19 100644 (file)
@@ -26,5 +26,20 @@ Random list of problems with i915g:
 - src/xvmc/i915_structs.h in xf86-video-intel has a few more bits of various
   commands defined. Scavenge them and see what's useful.
 
+- Do smarter remapping. Right now we send everything onto tex coords 0-7.
+  We could also use diffuse/specular and pack two sets of 2D coords in a single
+  4D. Is it a big problem though? We're more limited by the # of texture
+  indirections and the # of instructions.
+
+- Leverage draw to enable more caps:
+  * PIPE_CAP_TGSI_INSTANCEID
+  * PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
+
+- Finish front/back face. We need to add face support to lp_build_system_values_array and use it in draw_llvm.c.
+
+- Replace constants and immediates which are 0,1,-1 or a combination of those with a swizzle.
+
+- i915_delete_fs_state doesn't call draw_delete_fragment_shader. Why?
+
 Other bugs can be found here:
 https://bugs.freedesktop.org/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&component=Drivers/Gallium/i915g
index ce2691b..a1f8bca 100644 (file)
@@ -29,6 +29,7 @@
 #define I915_BATCH_H
 
 #include "i915_batchbuffer.h"
+#include "i915_context.h"
 
 
 #define BEGIN_BATCH(dwords) \
 #define FLUSH_BATCH(fence) \
    i915_flush(i915, fence)
 
-
 /************************************************************************
  * i915_flush.c
  */
 void i915_flush(struct i915_context *i915, struct pipe_fence_handle **fence);
 
+/*
+ * Flush if the current color buf is idle and we have more than 256 vertices
+ * queued, or if the current color buf is busy and we have more than 4096
+ * vertices queued.
+ */
+static INLINE void i915_flush_heuristically(struct i915_context* i915,
+                                            int num_vertex)
+{
+   struct i915_winsys *iws = i915->iws;
+   i915->vertices_since_last_flush += num_vertex;
+   if ( i915->vertices_since_last_flush > 4096
+      || ( i915->vertices_since_last_flush > 256 &&
+           !iws->buffer_is_busy(iws, i915->current.cbuf_bo)) )
+      FLUSH_BATCH(NULL);
+}
+
 
 #endif
index 4a97746..e1d6a74 100644 (file)
@@ -66,7 +66,7 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers, const float *rgba,
       else
          clear_color = (u_color.ui & 0xffff) | (u_color.ui << 16);
 
-      util_pack_color(rgba, PIPE_FORMAT_B8G8R8A8_UNORM, &u_color);
+      util_pack_color(rgba, cbuf->format, &u_color);
       clear_color8888 = u_color.ui;
    } else
       clear_color = clear_color8888 = 0;
@@ -120,6 +120,11 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers, const float *rgba,
    OUT_BATCH_F(desty + height);
    OUT_BATCH_F(destx);
    OUT_BATCH_F(desty);
+
+   /* Flush after clear, its expected to be a costly operation.
+    * This is not required, just a heuristic
+    */
+   FLUSH_BATCH(NULL);
 }
 
 /**
index 7a98ef7..1b30309 100644 (file)
@@ -29,6 +29,7 @@
 #include "i915_state.h"
 #include "i915_screen.h"
 #include "i915_surface.h"
+#include "i915_query.h"
 #include "i915_batch.h"
 #include "i915_resource.h"
 
@@ -53,13 +54,11 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    struct i915_context *i915 = i915_context(pipe);
    struct draw_context *draw = i915->draw;
    void *mapped_indices = NULL;
-   unsigned cbuf_dirty;
 
 
    /*
     * Ack vs contants here, helps ipers a lot.
     */
-   cbuf_dirty = i915->dirty & I915_NEW_VS_CONSTANTS;
    i915->dirty &= ~I915_NEW_VS_CONSTANTS;
 
    if (i915->dirty)
@@ -72,15 +71,13 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
       mapped_indices = i915_buffer(i915->index_buffer.buffer)->data;
    draw_set_mapped_index_buffer(draw, mapped_indices);
 
-   if (cbuf_dirty) {
-      if (i915->constants[PIPE_SHADER_VERTEX])
-         draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
-                                         i915_buffer(i915->constants[PIPE_SHADER_VERTEX])->data,
-                                         (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * 
-                                         4 * sizeof(float)));
-      else
-         draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, NULL, 0);
-   }
+   if (i915->constants[PIPE_SHADER_VERTEX])
+      draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
+                                      i915_buffer(i915->constants[PIPE_SHADER_VERTEX])->data,
+                                      (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * 
+                                      4 * sizeof(float)));
+   else
+      draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, NULL, 0);
 
    /*
     * Do the drawing
@@ -102,11 +99,11 @@ static void i915_destroy(struct pipe_context *pipe)
    struct i915_context *i915 = i915_context(pipe);
    int i;
 
-   draw_destroy(i915->draw);
-
    if (i915->blitter)
       util_blitter_destroy(i915->blitter);
-   
+
+   draw_destroy(i915->draw);
+
    if(i915->batch)
       i915->iws->batchbuffer_destroy(i915->batch);
 
@@ -150,6 +147,8 @@ i915_create_context(struct pipe_screen *screen, void *priv)
    /* init this before draw */
    util_slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer),
                     16, UTIL_SLAB_SINGLETHREADED);
+   util_slab_create(&i915->texture_transfer_pool, sizeof(struct i915_transfer),
+                    16, UTIL_SLAB_SINGLETHREADED);
 
    /* Batch stream debugging is a bit hacked up at the moment:
     */
@@ -170,9 +169,11 @@ i915_create_context(struct pipe_screen *screen, void *priv)
    i915_init_state_functions(i915);
    i915_init_flush_functions(i915);
    i915_init_resource_functions(i915);
+   i915_init_query_functions(i915);
 
    draw_install_aaline_stage(i915->draw, &i915->base);
    draw_install_aapoint_stage(i915->draw, &i915->base);
+   draw_enable_point_sprites(i915->draw, TRUE);
 
    /* augmented draw pipeline clobbers state functions */
    i915_init_fixup_state_functions(i915);
index 964948e..8486235 100644 (file)
@@ -102,6 +102,8 @@ struct i915_fragment_shader
 
    struct tgsi_shader_info info;
 
+   struct draw_fragment_shader *draw_data;
+
    uint *program;
    uint program_len;
 
@@ -260,6 +262,9 @@ struct i915_context {
    int num_validation_buffers;
 
    struct util_slab_mempool transfer_pool;
+   struct util_slab_mempool texture_transfer_pool;
+
+   int vertices_since_last_flush;
 
    /** blitter/hw-clear */
    struct blitter_context* blitter;
index b4e8114..6d76afa 100644 (file)
@@ -77,4 +77,5 @@ void i915_flush(struct i915_context *i915, struct pipe_fence_handle **fence)
    i915->static_dirty = ~0;
    /* kernel emits flushes in between batchbuffers */
    i915->flush_dirty = 0;
+   i915->vertices_since_last_flush = 0;
 }
index 2f0f99d..b760bc4 100644 (file)
 #include "i915_context.h"
 #include "i915_reg.h"
 
+#include "pipe/p_shader_tokens.h"
 
+#include "tgsi/tgsi_parse.h"
 
 #define I915_PROGRAM_SIZE 192
 
+/* Use those indices for pos/face routing, must be >= I915_TEX_UNITS */
+#define I915_SEMANTIC_POS  10
+#define I915_SEMANTIC_FACE 11
 
 
 /**
@@ -67,13 +72,13 @@ struct i915_fp_compile {
    uint temp_flag;       /**< Tracks temporary regs which are in use */
    uint utemp_flag;      /**< Tracks TYPE_U temporary regs which are in use */
 
+   uint register_phases[16];
    uint nr_tex_indirect;
    uint nr_tex_insn;
    uint nr_alu_insn;
    uint nr_decl_insn;
 
    boolean error;      /**< Set if i915_program_error() is called */
-   uint wpos_tex;
    uint NumNativeInstructions;
    uint NumNativeAluInstructions;
    uint NumNativeTexInstructions;
@@ -204,4 +209,90 @@ extern void
 i915_program_error(struct i915_fp_compile *p, const char *msg, ...);
 
 
+/*======================================================================
+ * i915_fpc_optimize.c
+ */
+
+
+struct i915_src_register
+{
+   unsigned File        : 4;  /* TGSI_FILE_ */
+   unsigned Indirect    : 1;  /* BOOL */
+   unsigned Dimension   : 1;  /* BOOL */
+   int      Index       : 16; /* SINT */
+   unsigned SwizzleX    : 3;  /* TGSI_SWIZZLE_ */
+   unsigned SwizzleY    : 3;  /* TGSI_SWIZZLE_ */
+   unsigned SwizzleZ    : 3;  /* TGSI_SWIZZLE_ */
+   unsigned SwizzleW    : 3;  /* TGSI_SWIZZLE_ */
+   unsigned Absolute    : 1;    /* BOOL */
+   unsigned Negate      : 1;    /* BOOL */
+};
+
+/* Additional swizzle supported in i915 */
+#define TGSI_SWIZZLE_ZERO 4
+#define TGSI_SWIZZLE_ONE 5
+
+struct i915_dst_register
+{
+   unsigned File        : 4;  /* TGSI_FILE_ */
+   unsigned WriteMask   : 4;  /* TGSI_WRITEMASK_ */
+   unsigned Indirect    : 1;  /* BOOL */
+   unsigned Dimension   : 1;  /* BOOL */
+   int      Index       : 16; /* SINT */
+   unsigned Padding     : 6;
+};
+
+
+struct i915_full_dst_register
+{
+   struct i915_dst_register               Register;
+/*
+   struct tgsi_src_register               Indirect;
+   struct tgsi_dimension                  Dimension;
+   struct tgsi_src_register               DimIndirect;
+*/
+};
+
+struct i915_full_src_register
+{
+   struct i915_src_register         Register;
+/*
+   struct tgsi_src_register         Indirect;
+   struct tgsi_dimension            Dimension;
+   struct tgsi_src_register         DimIndirect;
+*/
+};
+
+struct i915_full_instruction
+{
+   struct tgsi_instruction             Instruction;
+/*
+   struct tgsi_instruction_predicate   Predicate;
+   struct tgsi_instruction_label       Label;
+*/
+   struct tgsi_instruction_texture     Texture;
+   struct i915_full_dst_register       Dst[1];
+   struct i915_full_src_register       Src[3];
+};
+
+
+union i915_full_token
+{
+   struct tgsi_token             Token;
+   struct tgsi_full_declaration  FullDeclaration;
+   struct tgsi_full_immediate    FullImmediate;
+   struct i915_full_instruction  FullInstruction;
+   struct tgsi_full_property     FullProperty;
+};
+
+struct i915_token_list
+{
+   union i915_full_token*     Tokens;
+   unsigned                   NumTokens;
+};
+
+extern struct i915_token_list* i915_optimize(const struct tgsi_token *tokens);
+
+extern void i915_optimize_free(struct i915_token_list* tokens);
+
 #endif
index 76c24d2..c4a42df 100644 (file)
@@ -67,7 +67,7 @@ i915_get_temp(struct i915_fp_compile *p)
 {
    int bit = ffs(~p->temp_flag);
    if (!bit) {
-      i915_program_error(p, "i915_get_temp: out of temporaries\n");
+      i915_program_error(p, "i915_get_temp: out of temporaries");
       return 0;
    }
 
@@ -92,7 +92,7 @@ i915_get_utemp(struct i915_fp_compile * p)
 {
    int bit = ffs(~p->utemp_flag);
    if (!bit) {
-      i915_program_error(p, "i915_get_utemp: out of temporaries\n");
+      i915_program_error(p, "i915_get_utemp: out of temporaries");
       return 0;
    }
 
@@ -128,9 +128,13 @@ i915_emit_decl(struct i915_fp_compile *p,
    else
       return reg;
 
-   *(p->decl++) = (D0_DCL | D0_DEST(reg) | d0_flags);
-   *(p->decl++) = D1_MBZ;
-   *(p->decl++) = D2_MBZ;
+   if (p->decl< p->declarations + I915_PROGRAM_SIZE) {
+      *(p->decl++) = (D0_DCL | D0_DEST(reg) | d0_flags);
+      *(p->decl++) = D1_MBZ;
+      *(p->decl++) = D2_MBZ;
+   }
+   else
+      i915_program_error(p, "Out of declarations");
 
    p->nr_decl_insn++;
    return reg;
@@ -187,9 +191,16 @@ i915_emit_arith(struct i915_fp_compile * p,
       p->utemp_flag = old_utemp_flag;   /* restore */
    }
 
-   *(p->csr++) = (op | A0_DEST(dest) | mask | saturate | A0_SRC0(src0));
-   *(p->csr++) = (A1_SRC0(src0) | A1_SRC1(src1));
-   *(p->csr++) = (A2_SRC1(src1) | A2_SRC2(src2));
+   if (p->csr< p->program + I915_PROGRAM_SIZE) {
+      *(p->csr++) = (op | A0_DEST(dest) | mask | saturate | A0_SRC0(src0));
+      *(p->csr++) = (A1_SRC0(src0) | A1_SRC1(src1));
+      *(p->csr++) = (A2_SRC1(src1) | A2_SRC2(src2));
+   }
+   else
+      i915_program_error(p, "Out of instructions");
+
+   if (GET_UREG_TYPE(dest) == REG_TYPE_R)
+      p->register_phases[GET_UREG_NR(dest)] = p->nr_tex_indirect;
 
    p->nr_alu_insn++;
    return dest;
@@ -245,17 +256,31 @@ uint i915_emit_texld( struct i915_fp_compile *p,
       assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST);
       assert(dest == UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)));
 
-      /* is the sampler coord a texcoord input reg? */
-      if (GET_UREG_TYPE(coord) != REG_TYPE_T) {
-        p->nr_tex_indirect++;
-      }
+      /* Output register being oC or oD defines a phase boundary */
+      if (GET_UREG_TYPE(dest) == REG_TYPE_OC ||
+          GET_UREG_TYPE(dest) == REG_TYPE_OD)
+         p->nr_tex_indirect++;
 
-      *(p->csr++) = (opcode | 
-                    T0_DEST( dest ) |
-                    T0_SAMPLER( sampler ));
+      /* Reading from an r# register whose contents depend on output of the
+       * current phase defines a phase boundary.
+       */
+      if (GET_UREG_TYPE(coord) == REG_TYPE_R &&
+          p->register_phases[GET_UREG_NR(coord)] == p->nr_tex_indirect)
+         p->nr_tex_indirect++;
+
+      if (p->csr< p->program + I915_PROGRAM_SIZE) {
+         *(p->csr++) = (opcode |
+                        T0_DEST( dest ) |
+                        T0_SAMPLER( sampler ));
+
+         *(p->csr++) = T1_ADDRESS_REG( coord );
+         *(p->csr++) = T2_MBZ;
+      }
+      else
+         i915_program_error(p, "Out of instructions");
 
-      *(p->csr++) = T1_ADDRESS_REG( coord );
-      *(p->csr++) = T2_MBZ;
+      if (GET_UREG_TYPE(dest) == REG_TYPE_R)
+         p->register_phases[GET_UREG_NR(dest)] = p->nr_tex_indirect;
 
       p->nr_tex_insn++;
    }
@@ -293,7 +318,7 @@ i915_emit_const1f(struct i915_fp_compile * p, float c0)
       }
    }
 
-   i915_program_error(p, "i915_emit_const1f: out of constants\n");
+   i915_program_error(p, "i915_emit_const1f: out of constants");
    return 0;
 }
 
@@ -313,6 +338,8 @@ i915_emit_const2f(struct i915_fp_compile * p, float c0, float c1)
    if (c1 == 1.0)
       return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W);
 
+   // XXX emit swizzle here for 0, 1, -1 and any combination thereof
+   // we can use swizzle + neg for that
    for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
       if (ifs->constant_flags[reg] == 0xf ||
           ifs->constant_flags[reg] == I915_CONSTFLAG_USER)
@@ -329,12 +356,10 @@ i915_emit_const2f(struct i915_fp_compile * p, float c0, float c1)
       }
    }
 
-   i915_program_error(p, "i915_emit_const2f: out of constants\n");
+   i915_program_error(p, "i915_emit_const2f: out of constants");
    return 0;
 }
 
-
-
 uint
 i915_emit_const4f(struct i915_fp_compile * p,
                   float c0, float c1, float c2, float c3)
@@ -342,6 +367,8 @@ i915_emit_const4f(struct i915_fp_compile * p,
    struct i915_fragment_shader *ifs = p->shader;
    unsigned reg;
 
+   // XXX emit swizzle here for 0, 1, -1 and any combination thereof
+   // we can use swizzle + neg for that
    for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
       if (ifs->constant_flags[reg] == 0xf &&
           ifs->constants[reg][0] == c0 &&
@@ -363,7 +390,7 @@ i915_emit_const4f(struct i915_fp_compile * p,
       }
    }
 
-   i915_program_error(p, "i915_emit_const4f: out of constants\n");
+   i915_program_error(p, "i915_emit_const4f: out of constants");
    return 0;
 }
 
diff --git a/src/gallium/drivers/i915/i915_fpc_optimize.c b/src/gallium/drivers/i915/i915_fpc_optimize.c
new file mode 100644 (file)
index 0000000..2b739e9
--- /dev/null
@@ -0,0 +1,259 @@
+/**************************************************************************
+ * 
+ * Copyright 2011 The Chromium OS authors.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL GOOGLE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+#include "i915_reg.h"
+#include "i915_context.h"
+#include "i915_fpc.h"
+
+#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_string.h"
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_dump.h"
+
+static boolean same_dst_reg(struct i915_full_dst_register* d1, struct i915_full_dst_register* d2)
+{
+   return (d1->Register.File == d2->Register.File &&
+           d1->Register.Indirect == d2->Register.Indirect &&
+           d1->Register.Dimension == d2->Register.Dimension &&
+           d1->Register.Index == d2->Register.Index);
+}
+
+static boolean same_src_reg(struct i915_full_src_register* d1, struct i915_full_src_register* d2)
+{
+   return (d1->Register.File == d2->Register.File &&
+           d1->Register.Indirect == d2->Register.Indirect &&
+           d1->Register.Dimension == d2->Register.Dimension &&
+           d1->Register.Index == d2->Register.Index &&
+           d1->Register.Absolute == d2->Register.Absolute &&
+           d1->Register.Negate == d2->Register.Negate);
+}
+
+static boolean is_unswizzled(struct i915_full_src_register* r,
+                             unsigned write_mask)
+{
+   if ( write_mask & TGSI_WRITEMASK_X && r->Register.SwizzleX != TGSI_SWIZZLE_X)
+      return FALSE;
+   if ( write_mask & TGSI_WRITEMASK_Y && r->Register.SwizzleY != TGSI_SWIZZLE_Y)
+      return FALSE;
+   if ( write_mask & TGSI_WRITEMASK_Z && r->Register.SwizzleZ != TGSI_SWIZZLE_Z)
+      return FALSE;
+   if ( write_mask & TGSI_WRITEMASK_W && r->Register.SwizzleW != TGSI_SWIZZLE_W)
+      return FALSE;
+   return TRUE;
+}
+
+static boolean op_commutes(unsigned opcode)
+{
+   if (opcode == TGSI_OPCODE_ADD) return TRUE;
+   if (opcode == TGSI_OPCODE_MUL) return TRUE;
+   return FALSE;
+}
+
+static unsigned op_neutral_element(unsigned opcode)
+{
+   if (opcode == TGSI_OPCODE_ADD)
+      return TGSI_SWIZZLE_ZERO;
+   if (opcode == TGSI_OPCODE_MUL)
+      return TGSI_SWIZZLE_ONE;
+
+   debug_printf("Unknown opcode %d\n",opcode);
+   return TGSI_SWIZZLE_ZERO;
+}
+
+/*
+ * Sets the swizzle to the neutral element for the operation for the bits
+ * of writemask which are set, swizzle to identity otherwise.
+ */
+static void set_neutral_element_swizzle(struct i915_full_src_register* r,
+                                        unsigned write_mask,
+                                        unsigned neutral)
+{
+   if ( write_mask & TGSI_WRITEMASK_X )
+      r->Register.SwizzleX = neutral;
+   else
+      r->Register.SwizzleX = TGSI_SWIZZLE_X;
+
+   if ( write_mask & TGSI_WRITEMASK_Y )
+      r->Register.SwizzleY = neutral;
+   else
+      r->Register.SwizzleY = TGSI_SWIZZLE_Y;
+
+   if ( write_mask & TGSI_WRITEMASK_Z )
+      r->Register.SwizzleZ = neutral;
+   else
+      r->Register.SwizzleZ = TGSI_SWIZZLE_Z;
+
+   if ( write_mask & TGSI_WRITEMASK_W )
+      r->Register.SwizzleW = neutral;
+   else
+      r->Register.SwizzleW = TGSI_SWIZZLE_W;
+}
+
+/*
+ * Optimize away things like:
+ *    MUL OUT[0].xyz, TEMP[1], TEMP[2]
+ *    MOV OUT[0].w, TEMP[2]
+ * into: 
+ *    MUL OUT[0].xyzw, TEMP[1].xyz1, TEMP[2]
+ * This is useful for optimizing texenv.
+ */
+static void i915_fpc_optimize_mov_after_alu(union i915_full_token* current, union i915_full_token* next)
+{
+   if ( current->Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  &&
+        next->Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  &&
+        op_commutes(current->FullInstruction.Instruction.Opcode) &&
+        current->FullInstruction.Instruction.Saturate == next->FullInstruction.Instruction.Saturate &&
+        next->FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV &&
+        same_dst_reg(&next->FullInstruction.Dst[0], &next->FullInstruction.Dst[0]) &&
+        same_src_reg(&next->FullInstruction.Src[0], &current->FullInstruction.Src[1]) &&
+        is_unswizzled(&current->FullInstruction.Src[0], current->FullInstruction.Dst[0].Register.WriteMask) &&
+        is_unswizzled(&current->FullInstruction.Src[1], current->FullInstruction.Dst[0].Register.WriteMask) &&
+        is_unswizzled(&next->FullInstruction.Src[0], next->FullInstruction.Dst[0].Register.WriteMask) )
+   {
+      next->FullInstruction.Instruction.Opcode = TGSI_OPCODE_NOP;
+
+      set_neutral_element_swizzle(&current->FullInstruction.Src[1], 0, 0);
+      set_neutral_element_swizzle(&current->FullInstruction.Src[0],
+                                  next->FullInstruction.Dst[0].Register.WriteMask,
+                                  op_neutral_element(current->FullInstruction.Instruction.Opcode));
+
+      current->FullInstruction.Dst[0].Register.WriteMask = current->FullInstruction.Dst[0].Register.WriteMask |
+                                                           next->FullInstruction.Dst[0].Register.WriteMask;
+      return;
+   }
+
+   if ( current->Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  &&
+        next->Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  &&
+        op_commutes(current->FullInstruction.Instruction.Opcode) &&
+        current->FullInstruction.Instruction.Saturate == next->FullInstruction.Instruction.Saturate &&
+        next->FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV &&
+        same_dst_reg(&next->FullInstruction.Dst[0], &next->FullInstruction.Dst[0]) &&
+        same_src_reg(&next->FullInstruction.Src[0], &current->FullInstruction.Src[0]) &&
+        is_unswizzled(&current->FullInstruction.Src[0], current->FullInstruction.Dst[0].Register.WriteMask) &&
+        is_unswizzled(&current->FullInstruction.Src[1], current->FullInstruction.Dst[0].Register.WriteMask) &&
+        is_unswizzled(&next->FullInstruction.Src[0], next->FullInstruction.Dst[0].Register.WriteMask) )
+   {
+      next->FullInstruction.Instruction.Opcode = TGSI_OPCODE_NOP;
+
+      set_neutral_element_swizzle(&current->FullInstruction.Src[0], 0, 0);
+      set_neutral_element_swizzle(&current->FullInstruction.Src[1],
+                                  next->FullInstruction.Dst[0].Register.WriteMask,
+                                  op_neutral_element(current->FullInstruction.Instruction.Opcode));
+
+      current->FullInstruction.Dst[0].Register.WriteMask = current->FullInstruction.Dst[0].Register.WriteMask |
+                                                           next->FullInstruction.Dst[0].Register.WriteMask;
+      return;
+   }
+}
+
+static void copy_src_reg(struct i915_src_register* o, const struct tgsi_src_register* i)
+{
+   o->File      = i->File;
+   o->Indirect  = i->Indirect;
+   o->Dimension = i->Dimension;
+   o->Index     = i->Index;
+   o->SwizzleX  = i->SwizzleX;
+   o->SwizzleY  = i->SwizzleY;
+   o->SwizzleZ  = i->SwizzleZ;
+   o->SwizzleW  = i->SwizzleW;
+   o->Absolute  = i->Absolute;
+   o->Negate    = i->Negate;
+}
+
+static void copy_dst_reg(struct i915_dst_register* o, const struct tgsi_dst_register* i)
+{
+   o->File      = i->File;
+   o->WriteMask = i->WriteMask;
+   o->Indirect  = i->Indirect;
+   o->Dimension = i->Dimension;
+   o->Index     = i->Index;
+}
+
+static void copy_instruction(struct i915_full_instruction* o, const struct tgsi_full_instruction* i)
+{
+   memcpy(&o->Instruction, &i->Instruction, sizeof(o->Instruction));
+   memcpy(&o->Texture, &i->Texture, sizeof(o->Texture));
+
+   copy_dst_reg(&o->Dst[0].Register, &i->Dst[0].Register);
+
+   copy_src_reg(&o->Src[0].Register, &i->Src[0].Register);
+   copy_src_reg(&o->Src[1].Register, &i->Src[1].Register);
+   copy_src_reg(&o->Src[2].Register, &i->Src[2].Register);
+}
+
+static void copy_token(union i915_full_token* o, union tgsi_full_token* i)
+{
+   if (i->Token.Type != TGSI_TOKEN_TYPE_INSTRUCTION)
+      memcpy(o, i, sizeof(*o));
+   else
+      copy_instruction(&o->FullInstruction, &i->FullInstruction);
+
+}
+
+struct i915_token_list* i915_optimize(const struct tgsi_token *tokens)
+{
+   struct i915_token_list *out_tokens = MALLOC(sizeof(struct i915_token_list));
+   struct tgsi_parse_context parse;
+   int i = 0;
+
+   out_tokens->NumTokens = 0;
+
+   /* Count the tokens */
+   tgsi_parse_init( &parse, tokens );
+   while( !tgsi_parse_end_of_tokens( &parse ) ) {
+      tgsi_parse_token( &parse );
+      out_tokens->NumTokens++;
+   }
+   tgsi_parse_free (&parse);
+
+   /* Allocate our tokens */
+   out_tokens->Tokens = MALLOC(sizeof(union i915_full_token) * out_tokens->NumTokens);
+
+   tgsi_parse_init( &parse, tokens );
+   while( !tgsi_parse_end_of_tokens( &parse ) ) {
+      tgsi_parse_token( &parse );
+      copy_token(&out_tokens->Tokens[i] , &parse.FullToken);
+
+      if (i > 0)
+         i915_fpc_optimize_mov_after_alu(&out_tokens->Tokens[i-1], &out_tokens->Tokens[i]);
+
+      i++;
+   }
+   tgsi_parse_free (&parse);
+
+   return out_tokens;
+}
+
+void i915_optimize_free(struct i915_token_list* tokens)
+{
+   free(tokens->Tokens);
+   free(tokens);
+}
+
+
index 27f1008..a4ea912 100644 (file)
@@ -41,6 +41,9 @@
 
 #include "draw/draw_vertex.h"
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
 
 /**
  * Simple pass-through fragment shader to use when we don't have
@@ -72,19 +75,33 @@ static unsigned passthrough[] =
 
 
 /* 1, -1/3!, 1/5!, -1/7! */
-static const float sin_constants[4] = { 1.0,
+static const float scs_sin_constants[4] = { 1.0,
    -1.0f / (3 * 2 * 1),
    1.0f / (5 * 4 * 3 * 2 * 1),
    -1.0f / (7 * 6 * 5 * 4 * 3 * 2 * 1)
 };
 
 /* 1, -1/2!, 1/4!, -1/6! */
-static const float cos_constants[4] = { 1.0,
+static const float scs_cos_constants[4] = { 1.0,
    -1.0f / (2 * 1),
    1.0f / (4 * 3 * 2 * 1),
    -1.0f / (6 * 5 * 4 * 3 * 2 * 1)
 };
 
+/* 2*pi, -(2*pi)^3/3!, (2*pi)^5/5!, -(2*pi)^7/7! */
+static const float sin_constants[4] = { 2.0 * M_PI,
+   -8.0f * M_PI * M_PI * M_PI / (3 * 2 * 1),
+   32.0f * M_PI * M_PI * M_PI * M_PI * M_PI / (5 * 4 * 3 * 2 * 1),
+   -128.0f * M_PI * M_PI * M_PI * M_PI * M_PI * M_PI * M_PI / (7 * 6 * 5 * 4 * 3 * 2 * 1)
+};
+
+/* 1, -(2*pi)^2/2!, (2*pi)^4/4!, -(2*pi)^6/6! */
+static const float cos_constants[4] = { 1.0,
+   -4.0f * M_PI * M_PI / (2 * 1),
+   16.0f * M_PI * M_PI * M_PI * M_PI / (4 * 3 * 2 * 1),
+   -64.0f * M_PI * M_PI * M_PI * M_PI * M_PI * M_PI / (6 * 5 * 4 * 3 * 2 * 1)
+};
+
 
 
 /**
@@ -155,7 +172,7 @@ static uint get_mapping(struct i915_fragment_shader* fs, int unit)
  */
 static uint
 src_vector(struct i915_fp_compile *p,
-           const struct tgsi_full_src_register *source,
+           const struct i915_full_src_register *source,
            struct i915_fragment_shader* fs)
 {
    uint index = source->Register.Index;
@@ -185,12 +202,12 @@ src_vector(struct i915_fp_compile *p,
 
       switch (sem_name) {
       case TGSI_SEMANTIC_POSITION:
-         debug_printf("SKIP SEM POS\n");
-         /*
-         assert(p->wpos_tex != -1);
-         src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL);
-         */
-         break;
+         {
+            /* for fragcoord */
+            int real_tex_unit = get_mapping(fs, I915_SEMANTIC_POS);
+            src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + real_tex_unit, D0_CHANNEL_ALL);
+            break;
+         }
       case TGSI_SEMANTIC_COLOR:
          if (sem_ind == 0) {
             src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL);
@@ -212,6 +229,13 @@ src_vector(struct i915_fp_compile *p,
             src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + real_tex_unit, D0_CHANNEL_ALL);
             break;
          }
+      case TGSI_SEMANTIC_FACE:
+         {
+            /* for back/front faces */
+            int real_tex_unit = get_mapping(fs, I915_SEMANTIC_FACE);
+            src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + real_tex_unit, D0_CHANNEL_X);
+            break;
+         }
       default:
          i915_program_error(p, "Bad source->Index");
          return 0;
@@ -237,7 +261,6 @@ src_vector(struct i915_fp_compile *p,
                 source->Register.SwizzleZ,
                 source->Register.SwizzleW);
 
-
    /* There's both negate-all-components and per-component negation.
     * Try to handle both here.
     */
@@ -252,6 +275,9 @@ src_vector(struct i915_fp_compile *p,
    /* XXX enable these assertions, or fix things */
    assert(!source->Register.Absolute);
 #endif
+   if (source->Register.Absolute)
+      debug_printf("Unhandled absolute value\n");
+
    return src;
 }
 
@@ -261,7 +287,7 @@ src_vector(struct i915_fp_compile *p,
  */
 static uint
 get_result_vector(struct i915_fp_compile *p,
-                  const struct tgsi_full_dst_register *dest)
+                  const struct i915_full_dst_register *dest)
 {
    switch (dest->Register.File) {
    case TGSI_FILE_OUTPUT:
@@ -290,7 +316,7 @@ get_result_vector(struct i915_fp_compile *p,
  * Compute flags for saturation and writemask.
  */
 static uint
-get_result_flags(const struct tgsi_full_instruction *inst)
+get_result_flags(const struct i915_full_instruction *inst)
 {
    const uint writeMask
       = inst->Dst[0].Register.WriteMask;
@@ -352,7 +378,7 @@ translate_tex_src_target(struct i915_fp_compile *p, uint tex)
  */
 static void
 emit_tex(struct i915_fp_compile *p,
-         const struct tgsi_full_instruction *inst,
+         const struct i915_full_instruction *inst,
          uint opcode,
          struct i915_fragment_shader* fs)
 {
@@ -378,7 +404,7 @@ emit_tex(struct i915_fp_compile *p,
  */
 static void
 emit_simple_arith(struct i915_fp_compile *p,
-                  const struct tgsi_full_instruction *inst,
+                  const struct i915_full_instruction *inst,
                   uint opcode, uint numArgs,
                   struct i915_fragment_shader* fs)
 {
@@ -403,11 +429,11 @@ emit_simple_arith(struct i915_fp_compile *p,
 /** As above, but swap the first two src regs */
 static void
 emit_simple_arith_swap2(struct i915_fp_compile *p,
-                        const struct tgsi_full_instruction *inst,
+                        const struct i915_full_instruction *inst,
                         uint opcode, uint numArgs,
                         struct i915_fragment_shader* fs)
 {
-   struct tgsi_full_instruction inst2;
+   struct i915_full_instruction inst2;
 
    assert(numArgs == 2);
 
@@ -419,23 +445,19 @@ emit_simple_arith_swap2(struct i915_fp_compile *p,
    emit_simple_arith(p, &inst2, opcode, numArgs, fs);
 }
 
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
 /*
  * Translate TGSI instruction to i915 instruction.
  *
  * Possible concerns:
  *
+ * DDX, DDY -- return 0
  * SIN, COS -- could use another taylor step?
  * LIT      -- results seem a little different to sw mesa
  * LOG      -- different to mesa on negative numbers, but this is conformant.
  */ 
 static void
 i915_translate_instruction(struct i915_fp_compile *p,
-                           const struct tgsi_full_instruction *inst,
+                           const struct i915_full_instruction *inst,
                            struct i915_fragment_shader *fs)
 {
    uint writemask;
@@ -477,13 +499,6 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
       i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0);
 
-      /* By choosing different taylor constants, could get rid of this mul:
-       */
-      i915_emit_arith(p,
-                      A0_MUL,
-                      tmp, A0_DEST_CHANNEL_X, 0,
-                      tmp, i915_emit_const1f(p, (float) (M_PI * 2.0)), 0);
-
       /* 
        * t0.xy = MUL x.xx11, x.x1111  ; x^2, x, 1, 1
        * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, 1
@@ -516,6 +531,18 @@ i915_translate_instruction(struct i915_fp_compile *p,
                       i915_emit_const4fv(p, cos_constants), 0);
       break;
 
+  case TGSI_OPCODE_DDX:
+  case TGSI_OPCODE_DDY:
+      /* XXX We just output 0 here */
+      debug_printf("Punting DDX/DDX\n");
+      src0 = get_result_vector(p, &inst->Dst[0]);
+      i915_emit_arith(p,
+                      A0_MOV,
+                      get_result_vector(p, &inst->Dst[0]),
+                      get_result_flags(inst), 0,
+                      swizzle(src0, ZERO, ZERO, ZERO, ZERO), 0, 0);
+      break;
+
   case TGSI_OPCODE_DP2:
       src0 = src_vector(p, &inst->Src[0], fs);
       src1 = src_vector(p, &inst->Src[1], fs);
@@ -701,6 +728,9 @@ i915_translate_instruction(struct i915_fp_compile *p,
       emit_simple_arith(p, inst, A0_MUL, 2, fs);
       break;
 
+   case TGSI_OPCODE_NOP:
+      break;
+
    case TGSI_OPCODE_POW:
       src0 = src_vector(p, &inst->Src[0], fs);
       src1 = src_vector(p, &inst->Src[1], fs);
@@ -754,9 +784,9 @@ i915_translate_instruction(struct i915_fp_compile *p,
        * t0.xy = MUL x.xx11, x.x1111  ; x^2, x, 1, 1
        * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x
        * t1 = MUL t0.xyyw t0.yz11    ; x^7 x^5 x^3 x
-       * scs.x = DP4 t1, sin_constants
+       * scs.x = DP4 t1, scs_sin_constants
        * t1 = MUL t0.xxz1 t0.z111    ; x^6 x^4 x^2 1
-       * scs.y = DP4 t1, cos_constants
+       * scs.y = DP4 t1, scs_cos_constants
        */
       i915_emit_arith(p,
                       A0_MUL,
@@ -791,7 +821,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
                          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);
+                         i915_emit_const4fv(p, scs_sin_constants), 0);
       }
 
       if (writemask & TGSI_WRITEMASK_X) {
@@ -806,7 +836,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
                          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);
+                         i915_emit_const4fv(p, scs_cos_constants), 0);
       }
       break;
 
@@ -853,13 +883,6 @@ i915_translate_instruction(struct i915_fp_compile *p,
 
       i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0);
 
-      /* By choosing different taylor constants, could get rid of this mul:
-       */
-      i915_emit_arith(p,
-                      A0_MUL,
-                      tmp, A0_DEST_CHANNEL_X, 0,
-                      tmp, i915_emit_const1f(p, (float) (M_PI * 2.0)), 0);
-
       /* 
        * t0.xy = MUL x.xx11, x.x1111  ; x^2, x, 1, 1
        * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x
@@ -907,7 +930,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
       break;
 
    case TGSI_OPCODE_SNE:
-      /* if we're neither < nor > then we're != */
+      /* if we're or > then we're != */
       src0 = src_vector(p, &inst->Src[0], fs);
       src1 = src_vector(p, &inst->Src[1], fs);
       tmp = i915_get_utemp(p);
@@ -1024,105 +1047,107 @@ i915_translate_instruction(struct i915_fp_compile *p,
 }
 
 
-/**
- * Translate TGSI fragment shader into i915 hardware instructions.
- * \param p  the translation state
- * \param tokens  the TGSI token array
- */
-static void
-i915_translate_instructions(struct i915_fp_compile *p,
-                            const struct tgsi_token *tokens,
-                            struct i915_fragment_shader *fs)
+static void i915_translate_token(struct i915_fp_compile *p,
+                                 const union i915_full_token* token,
+                                 struct i915_fragment_shader *fs)
 {
    struct i915_fragment_shader *ifs = p->shader;
-   struct tgsi_parse_context parse;
-
-   tgsi_parse_init( &parse, tokens );
-
-   while( !tgsi_parse_end_of_tokens( &parse ) ) {
-
-      tgsi_parse_token( &parse );
+   switch( token->Token.Type ) {
+   case TGSI_TOKEN_TYPE_PROPERTY:
+      /*
+       * We only support one cbuf, but we still need to ignore the property
+       * correctly so we don't hit the assert at the end of the switch case.
+       */
+      assert(token->FullProperty.Property.PropertyName ==
+             TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS);
+      break;
 
-      switch( parse.FullToken.Token.Type ) {
-      case TGSI_TOKEN_TYPE_PROPERTY:
-         /*
-          * We only support one cbuf, but we still need to ignore the property
-          * correctly so we don't hit the assert at the end of the switch case.
-          */
-         assert(parse.FullToken.FullProperty.Property.PropertyName ==
-                TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS);
-         break;
-      case TGSI_TOKEN_TYPE_DECLARATION:
-         if (parse.FullToken.FullDeclaration.Declaration.File
-                  == TGSI_FILE_CONSTANT) {
-            uint i;
-            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;
-               ifs->num_constants = MAX2(ifs->num_constants, i + 1);
-            }
+   case TGSI_TOKEN_TYPE_DECLARATION:
+      if (token->FullDeclaration.Declaration.File
+               == TGSI_FILE_CONSTANT) {
+         uint i;
+         for (i = token->FullDeclaration.Range.First;
+              i <= token->FullDeclaration.Range.Last;
+              i++) {
+            assert(ifs->constant_flags[i] == 0x0);
+            ifs->constant_flags[i] = I915_CONSTFLAG_USER;
+            ifs->num_constants = MAX2(ifs->num_constants, i + 1);
          }
-         else if (parse.FullToken.FullDeclaration.Declaration.File
-                  == TGSI_FILE_TEMPORARY) {
-            uint i;
-            for (i = parse.FullToken.FullDeclaration.Range.First;
-                 i <= parse.FullToken.FullDeclaration.Range.Last;
-                 i++) {
-               assert(i < I915_MAX_TEMPORARY);
+      }
+      else if (token->FullDeclaration.Declaration.File
+               == TGSI_FILE_TEMPORARY) {
+         uint i;
+         for (i = token->FullDeclaration.Range.First;
+              i <= token->FullDeclaration.Range.Last;
+              i++) {
+            if (i >= I915_MAX_TEMPORARY)
+               debug_printf("Too many temps (%d)\n",i);
+            else
                /* XXX just use shader->info->file_mask[TGSI_FILE_TEMPORARY] */
                p->temp_flag |= (1 << i); /* mark temp as used */
-            }
          }
-         break;
+      }
+      break;
 
-      case TGSI_TOKEN_TYPE_IMMEDIATE:
-         {
-            const struct tgsi_full_immediate *imm
-               = &parse.FullToken.FullImmediate;
-            const uint pos = p->num_immediates++;
-            uint j;
-            assert( imm->Immediate.NrTokens <= 4 + 1 );
-            for (j = 0; j < imm->Immediate.NrTokens - 1; j++) {
-               p->immediates[pos][j] = imm->u[j].Float;
-            }
+   case TGSI_TOKEN_TYPE_IMMEDIATE:
+      {
+         const struct tgsi_full_immediate *imm
+            = &token->FullImmediate;
+         const uint pos = p->num_immediates++;
+         uint j;
+         assert( imm->Immediate.NrTokens <= 4 + 1 );
+         for (j = 0; j < imm->Immediate.NrTokens - 1; j++) {
+            p->immediates[pos][j] = imm->u[j].Float;
          }
-         break;
+      }
+      break;
 
-      case TGSI_TOKEN_TYPE_INSTRUCTION:
-         if (p->first_instruction) {
-            /* resolve location of immediates */
-            uint i, j;
-            for (i = 0; i < p->num_immediates; i++) {
-               /* find constant slot for this immediate */
-               for (j = 0; j < I915_MAX_CONSTANT; j++) {
-                  if (ifs->constant_flags[j] == 0x0) {
-                     memcpy(ifs->constants[j],
-                            p->immediates[i],
-                            4 * sizeof(float));
-                     /*printf("immediate %d maps to const %d\n", i, j);*/
-                     ifs->constant_flags[j] = 0xf;  /* all four comps used */
-                     p->immediates_map[i] = j;
-                     ifs->num_constants = MAX2(ifs->num_constants, j + 1);
-                     break;
-                  }
+   case TGSI_TOKEN_TYPE_INSTRUCTION:
+      if (p->first_instruction) {
+         /* resolve location of immediates */
+         uint i, j;
+         for (i = 0; i < p->num_immediates; i++) {
+            /* find constant slot for this immediate */
+            for (j = 0; j < I915_MAX_CONSTANT; j++) {
+               if (ifs->constant_flags[j] == 0x0) {
+                  memcpy(ifs->constants[j],
+                         p->immediates[i],
+                         4 * sizeof(float));
+                  /*printf("immediate %d maps to const %d\n", i, j);*/
+                  ifs->constant_flags[j] = 0xf;  /* all four comps used */
+                  p->immediates_map[i] = j;
+                  ifs->num_constants = MAX2(ifs->num_constants, j + 1);
+                  break;
                }
             }
-
-            p->first_instruction = FALSE;
          }
 
-         i915_translate_instruction(p, &parse.FullToken.FullInstruction, fs);
-         break;
-
-      default:
-         assert( 0 );
+         p->first_instruction = FALSE;
       }
 
-   } /* while */
+      i915_translate_instruction(p, &token->FullInstruction, fs);
+      break;
+
+   default:
+      assert( 0 );
+   }
 
-   tgsi_parse_free (&parse);
+}
+
+/**
+ * Translate TGSI fragment shader into i915 hardware instructions.
+ * \param p  the translation state
+ * \param tokens  the TGSI token array
+ */
+static void
+i915_translate_instructions(struct i915_fp_compile *p,
+                            const struct i915_token_list *tokens,
+                            struct i915_fragment_shader *fs)
+{
+   int i;
+   for(i = 0; i<tokens->NumTokens; i++) {
+      i915_translate_token(p, &tokens->Tokens[i], fs);
+   }
 }
 
 
@@ -1144,6 +1169,8 @@ i915_init_compile(struct i915_context *i915,
    ifs->num_constants = 0;
    memset(ifs->constant_flags, 0, sizeof(ifs->constant_flags));
 
+   memset(&p->register_phases, 0, sizeof(p->register_phases));
+
    for (i = 0; i < I915_TEX_UNITS; i++)
       ifs->generic_mapping[i] = -1;
 
@@ -1161,8 +1188,6 @@ i915_init_compile(struct i915_context *i915,
    p->temp_flag = ~0x0 << I915_MAX_TEMPORARY;
    p->utemp_flag = ~0x7;
 
-   p->wpos_tex = -1;
-
    /* initialize the first program word */
    *(p->decl++) = _3DSTATE_PIXEL_SHADER_PROGRAM;
 
@@ -1181,7 +1206,7 @@ i915_fini_compile(struct i915_context *i915, struct i915_fp_compile *p)
    unsigned long decl_size = (unsigned long) (p->decl - p->declarations);
 
    if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT)
-      i915_program_error(p, "Exceeded max nr indirect texture lookups");
+      debug_printf("Exceeded max nr indirect texture lookups\n");
 
    if (p->nr_tex_insn > I915_MAX_TEX_INSN)
       i915_program_error(p, "Exceeded max TEX instructions");
@@ -1234,40 +1259,6 @@ i915_fini_compile(struct i915_context *i915, struct i915_fp_compile *p)
 }
 
 
-/**
- * Find an unused texture coordinate slot to use for fragment WPOS.
- * Update p->fp->wpos_tex with the result (-1 if no used texcoord slot is found).
- */
-static void
-i915_find_wpos_space(struct i915_fp_compile *p)
-{
-#if 0
-   const uint inputs
-      = p->shader->inputs_read | (1 << TGSI_ATTRIB_POS); /*XXX hack*/
-   uint i;
-
-   p->wpos_tex = -1;
-
-   if (inputs & (1 << TGSI_ATTRIB_POS)) {
-      for (i = 0; i < I915_TEX_UNITS; i++) {
-        if ((inputs & (1 << (TGSI_ATTRIB_TEX0 + i))) == 0) {
-           p->wpos_tex = i;
-           return;
-        }
-      }
-
-      i915_program_error(p, "No free texcoord for wpos value");
-   }
-#else
-   if (p->shader->info.input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
-      /* frag shader using the fragment position input */
-#if 0
-      assert(0);
-#endif
-   }
-#endif
-}
-
 
 
 
@@ -1300,6 +1291,7 @@ i915_translate_fragment_program( struct i915_context *i915,
 {
    struct i915_fp_compile *p;
    const struct tgsi_token *tokens = fs->state.tokens;
+   struct i915_token_list* i_tokens;
 
 #if 0
    tgsi_dump(tokens, 0);
@@ -1314,10 +1306,11 @@ i915_translate_fragment_program( struct i915_context *i915,
    }
 
    p = i915_init_compile(i915, fs);
-   i915_find_wpos_space(p);
 
-   i915_translate_instructions(p, tokens, fs);
+   i_tokens = i915_optimize(tokens);
+   i915_translate_instructions(p, i_tokens, fs);
    i915_fixup_depth_write(p);
 
    i915_fini_compile(i915, p);
+   i915_optimize_free(i_tokens);
 }
index 85656cd..1acde97 100644 (file)
@@ -166,6 +166,8 @@ emit_prim( struct draw_stage *stage,
 
    for (i = 0; i < nr; i++)
       emit_hw_vertex(i915, prim->v[i]);
+
+   i915_flush_heuristically(i915, nr);
 }
 
 
index 79db3b6..d8ae1de 100644 (file)
@@ -487,6 +487,7 @@ draw_arrays_fallback(struct vbuf_render *render,
 
    draw_arrays_generate_indices(render, start, nr, i915_render->fallback);
 
+   i915_flush_heuristically(i915, nr_indices);
 out:
    return;
 }
@@ -534,6 +535,7 @@ i915_vbuf_render_draw_arrays(struct vbuf_render *render,
              nr);
    OUT_BATCH(start); /* Beginning vertex index */
 
+   i915_flush_heuristically(i915, nr);
 out:
    return;
 }
@@ -657,6 +659,7 @@ i915_vbuf_render_draw_elements(struct vbuf_render *render,
                          save_nr_indices,
                          i915_render->fallback);
 
+   i915_flush_heuristically(i915, nr_indices);
 out:
    return;
 }
diff --git a/src/gallium/drivers/i915/i915_query.c b/src/gallium/drivers/i915/i915_query.c
new file mode 100644 (file)
index 0000000..c886df7
--- /dev/null
@@ -0,0 +1,86 @@
+/**************************************************************************
+ * 
+ * Copyright 2011 The Chromium OS authors.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL GOOGLE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+/* Fake occlusion queries which return 0, it's better than crashing */
+
+#include "pipe/p_compiler.h"
+
+#include "util/u_memory.h"
+
+#include "i915_context.h"
+#include "i915_query.h"
+
+struct i915_query
+{
+   unsigned query;
+};
+
+static struct pipe_query *i915_create_query(struct pipe_context *ctx,
+                                            unsigned query_type)
+{
+   struct i915_query *query = CALLOC_STRUCT( i915_query );
+
+   return (struct pipe_query *)query;
+}
+
+static void i915_destroy_query(struct pipe_context *ctx,
+                               struct pipe_query *query)
+{
+   FREE(query);
+}
+
+static void i915_begin_query(struct pipe_context *ctx,
+                             struct pipe_query *query)
+{
+}
+
+static void i915_end_query(struct pipe_context *ctx, struct pipe_query *query)
+{
+}
+
+static boolean i915_get_query_result(struct pipe_context *ctx,
+                                     struct pipe_query *query,
+                                     boolean wait,
+                                     void *vresult)
+{
+   uint64_t *result = (uint64_t*)vresult;
+
+   /* 2* viewport Max */
+   *result = 512*1024*1024;
+   return TRUE;
+}
+
+void
+i915_init_query_functions(struct i915_context *i915)
+{
+   i915->base.create_query = i915_create_query;
+   i915->base.destroy_query = i915_destroy_query;
+   i915->base.begin_query = i915_begin_query;
+   i915->base.end_query = i915_end_query;
+   i915->base.get_query_result = i915_get_query_result;
+}
+
diff --git a/src/gallium/drivers/i915/i915_query.h b/src/gallium/drivers/i915/i915_query.h
new file mode 100644 (file)
index 0000000..2c689ea
--- /dev/null
@@ -0,0 +1,36 @@
+/**************************************************************************
+ * 
+ * Copyright 2011 The Chromium OS authors.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL GOOGLE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+#ifndef I915_QUERY_H
+#define I915_QUERY_H
+
+struct i915_context;
+struct pipe_context;
+
+void i915_init_query_functions( struct i915_context *i915 );
+
+#endif /* I915_QUERY_H */
index 7f52ba1..b4719af 100644 (file)
@@ -7,12 +7,12 @@
 
 static struct pipe_resource *
 i915_resource_create(struct pipe_screen *screen,
-                    const struct pipe_resource *template)
+                     const struct pipe_resource *template)
 {
    if (template->target == PIPE_BUFFER)
       return i915_buffer_create(screen, template);
    else
-      return i915_texture_create(screen, template);
+      return i915_texture_create(screen, template, FALSE);
 
 }
 
index c15ecdf..14eed2c 100644 (file)
@@ -45,6 +45,15 @@ struct i915_buffer {
    boolean free_on_destroy;
 };
 
+
+/* Texture transfer. */
+struct i915_transfer {
+   /* Base class. */
+   struct pipe_transfer b;
+   struct pipe_resource *staging_texture;
+};
+
+
 #define I915_MAX_TEXTURE_2D_LEVELS 12  /* max 2048x2048 */
 #define I915_MAX_TEXTURE_3D_LEVELS  9  /* max 256x256x256 */
 
@@ -101,7 +110,8 @@ static INLINE struct i915_buffer *i915_buffer(struct pipe_resource *resource)
 
 struct pipe_resource *
 i915_texture_create(struct pipe_screen *screen,
-                    const struct pipe_resource *template);
+                    const struct pipe_resource *template,
+                    boolean force_untiled);
 
 struct pipe_resource *
 i915_texture_from_handle(struct pipe_screen * screen,
index b74b19d..0b6424f 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_rect.h"
 
 #include "i915_context.h"
 #include "i915_resource.h"
@@ -710,7 +711,7 @@ i915_texture_destroy(struct pipe_screen *screen,
    FREE(tex);
 }
 
-static struct pipe_transfer * 
+static struct pipe_transfer *
 i915_texture_get_transfer(struct pipe_context *pipe,
                           struct pipe_resource *resource,
                           unsigned level,
@@ -719,19 +720,45 @@ i915_texture_get_transfer(struct pipe_context *pipe,
 {
    struct i915_context *i915 = i915_context(pipe);
    struct i915_texture *tex = i915_texture(resource);
-   struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
+   struct i915_transfer *transfer = util_slab_alloc(&i915->texture_transfer_pool);
+   boolean use_staging_texture = FALSE;
 
    if (transfer == NULL)
       return NULL;
 
-   transfer->resource = resource;
-   transfer->level = level;
-   transfer->usage = usage;
-   transfer->box = *box;
-   transfer->stride = tex->stride;
-   /* FIXME: layer_stride */
+   transfer->b.resource = resource;
+   transfer->b.level = level;
+   transfer->b.usage = usage;
+   transfer->b.box = *box;
+   transfer->b.stride = tex->stride;
+   transfer->staging_texture = NULL;
+   /* XXX: handle depth textures everyhwere*/
+   transfer->b.layer_stride = 0;
+   transfer->b.data = NULL;
+
+   /* if we use staging transfers, only support textures we can render to,
+    * because we need that for u_blitter */
+   if (i915->blitter &&
+       i915_is_format_supported(NULL, /* screen */
+                                transfer->b.resource->format,
+                                0, /* target */
+                                1, /* sample count */
+                                PIPE_BIND_RENDER_TARGET) &&
+       (usage & PIPE_TRANSFER_WRITE) &&
+       !(usage & (PIPE_TRANSFER_READ | PIPE_TRANSFER_DONTBLOCK | PIPE_TRANSFER_UNSYNCHRONIZED)))
+      use_staging_texture = TRUE;
+
+   use_staging_texture = FALSE;
+
+   if (use_staging_texture) {
+      /* 
+       * Allocate the untiled staging texture.
+       * If the alloc fails, transfer->staging_texture is NULL and we fallback to a map() 
+       */
+      transfer->staging_texture = i915_texture_create(pipe->screen, resource, TRUE);
+   }
 
-   return transfer;
+   return (struct pipe_transfer*)transfer;
 }
 
 static void
@@ -739,17 +766,33 @@ i915_transfer_destroy(struct pipe_context *pipe,
                       struct pipe_transfer *transfer)
 {
    struct i915_context *i915 = i915_context(pipe);
-   util_slab_free(&i915->transfer_pool, transfer);
+   struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
+
+   if ((itransfer->staging_texture) &&
+       (transfer->usage & PIPE_TRANSFER_WRITE)) {
+      struct pipe_box sbox;
+
+      u_box_origin_2d(itransfer->b.box.width, itransfer->b.box.height, &sbox);
+      pipe->resource_copy_region(pipe, itransfer->b.resource, itransfer->b.level,
+                                   itransfer->b.box.x, itransfer->b.box.y, itransfer->b.box.z,
+                                   itransfer->staging_texture,
+                                   0, &sbox);
+      pipe->flush(pipe, NULL);
+      pipe_resource_reference(&itransfer->staging_texture, NULL);
+   }
+
+   util_slab_free(&i915->texture_transfer_pool, itransfer);
 }
 
 static void *
 i915_texture_transfer_map(struct pipe_context *pipe,
                           struct pipe_transfer *transfer)
 {
-   struct pipe_resource *resource = transfer->resource;
-   struct i915_texture *tex = i915_texture(resource);
+   struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
+   struct pipe_resource *resource = itransfer->b.resource;
+   struct i915_texture *tex = NULL;
    struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
-   struct pipe_box *box = &transfer->box;
+   struct pipe_box *box = &itransfer->b.box;
    enum pipe_format format = resource->format;
    unsigned offset;
    char *map;
@@ -757,18 +800,25 @@ i915_texture_transfer_map(struct pipe_context *pipe,
    if (resource->target != PIPE_TEXTURE_3D &&
        resource->target != PIPE_TEXTURE_CUBE)
       assert(box->z == 0);
-   offset = i915_texture_offset(tex, transfer->level, box->z);
 
-   /* TODO this is a sledgehammer */
-   pipe->flush(pipe, NULL);
+   if (itransfer->staging_texture) {
+      tex = i915_texture(itransfer->staging_texture);
+   } else {
+      /* TODO this is a sledgehammer */
+      tex = i915_texture(resource);
+      pipe->flush(pipe, NULL);
+   }
+
+   offset = i915_texture_offset(tex, itransfer->b.level, box->z);
 
    map = iws->buffer_map(iws, tex->buffer,
-                         (transfer->usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
-   if (map == NULL)
+                         (itransfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
+   if (map == NULL) {
       return NULL;
+   }
 
    return map + offset +
-      box->y / util_format_get_blockheight(format) * transfer->stride +
+      box->y / util_format_get_blockheight(format) * itransfer->b.stride +
       box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
 }
 
@@ -776,14 +826,106 @@ static void
 i915_texture_transfer_unmap(struct pipe_context *pipe,
                            struct pipe_transfer *transfer)
 {
-   struct i915_texture *tex = i915_texture(transfer->resource);
+   struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
+   struct i915_texture *tex = i915_texture(itransfer->b.resource);
    struct i915_winsys *iws = i915_screen(tex->b.b.screen)->iws;
+
+   if (itransfer->staging_texture)
+      tex = i915_texture(itransfer->staging_texture);
+
    iws->buffer_unmap(iws, tex->buffer);
 }
 
+static void i915_transfer_inline_write( struct pipe_context *pipe,
+                                 struct pipe_resource *resource,
+                                 unsigned level,
+                                 unsigned usage,
+                                 const struct pipe_box *box,
+                                 const void *data,
+                                 unsigned stride,
+                                 unsigned layer_stride)
+{
+   struct pipe_transfer *transfer = NULL;
+   struct i915_transfer *itransfer = NULL;
+   const uint8_t *src_data = data;
+   unsigned i;
+
+   transfer = pipe->get_transfer(pipe,
+                                 resource,
+                                 level,
+                                 usage,
+                                 box );
+   if (transfer == NULL)
+      goto out;
+
+   itransfer = (struct i915_transfer*)transfer;
+
+   if (itransfer->staging_texture) {
+      struct i915_texture *tex = i915_texture(itransfer->staging_texture);
+      enum pipe_format format = tex->b.b.format;
+      struct i915_winsys *iws = i915_screen(tex->b.b.screen)->iws;
+      size_t offset;
+      size_t size;
+
+      offset = i915_texture_offset(tex, transfer->level, transfer->box.z);
+
+      for (i = 0; i < box->depth; i++) {
+         if (!tex->b.b.last_level &&
+                     tex->b.b.width0 == transfer->box.width) {
+             unsigned nby = util_format_get_nblocksy(format, transfer->box.y);
+             assert(!offset);
+             assert(!transfer->box.x);
+             assert(tex->stride == transfer->stride);
+
+             offset += tex->stride * nby;
+             size = util_format_get_2d_size(format, transfer->stride,
+                             transfer->box.height);
+             iws->buffer_write(iws, tex->buffer, offset, size, transfer->data);
+
+         } else {
+             unsigned nby = util_format_get_nblocksy(format, transfer->box.y);
+             int i;
+             offset += util_format_get_stride(format, transfer->box.x);
+             size = transfer->stride;
+
+             for (i = 0; i < nby; i++) {
+                     iws->buffer_write(iws, tex->buffer, offset, size, transfer->data);
+                     offset += tex->stride;
+             }
+         }
+         offset += layer_stride;
+      }
+   } else {
+      uint8_t *map = pipe_transfer_map(pipe, &itransfer->b);
+      if (map == NULL)
+         goto nomap;
+
+      for (i = 0; i < box->depth; i++) {
+         util_copy_rect(map,
+                        resource->format,
+                        itransfer->b.stride, /* bytes */
+                        0, 0,
+                        box->width,
+                        box->height,
+                        src_data,
+                        stride,       /* bytes */
+                        0, 0);
+         map += itransfer->b.layer_stride;
+         src_data += layer_stride;
+      }
+nomap:
+      if (map)
+         pipe_transfer_unmap(pipe, &itransfer->b);
+   }
+
+out:
+   if (itransfer)
+      pipe_transfer_destroy(pipe, &itransfer->b);
+}
 
 
-struct u_resource_vtbl i915_texture_vtbl = 
+
+struct u_resource_vtbl i915_texture_vtbl =
 {
    i915_texture_get_handle,          /* get_handle */
    i915_texture_destroy,             /* resource_destroy */
@@ -792,7 +934,7 @@ struct u_resource_vtbl i915_texture_vtbl =
    i915_texture_transfer_map,        /* transfer_map */
    u_default_transfer_flush_region,   /* transfer_flush_region */
    i915_texture_transfer_unmap,              /* transfer_unmap */
-   u_default_transfer_inline_write    /* transfer_inline_write */
+   i915_transfer_inline_write         /* transfer_inline_write */
 };
 
 
@@ -800,7 +942,8 @@ struct u_resource_vtbl i915_texture_vtbl =
 
 struct pipe_resource *
 i915_texture_create(struct pipe_screen *screen,
-                    const struct pipe_resource *template)
+                    const struct pipe_resource *template,
+                    boolean force_untiled)
 {
    struct i915_screen *is = i915_screen(screen);
    struct i915_winsys *iws = is->iws;
@@ -815,7 +958,10 @@ i915_texture_create(struct pipe_screen *screen,
    pipe_reference_init(&tex->b.b.reference, 1);
    tex->b.b.screen = screen;
 
-   tex->tiling = i915_texture_tiling(is, tex);
+   if (force_untiled)
+      tex->tiling = I915_TILE_NONE;
+   else
+      tex->tiling = i915_texture_tiling(is, tex);
 
    if (is->is_i945) {
       if (!i945_texture_layout(tex))
@@ -836,7 +982,7 @@ i915_texture_create(struct pipe_screen *screen,
       buf_usage = I915_NEW_TEXTURE;
 
    tex->buffer = iws->buffer_create_tiled(iws, &tex->stride, tex->total_nblocksy,
-                                         &tex->tiling, buf_usage);
+                                             &tex->tiling, buf_usage);
    if (!tex->buffer)
       goto fail;
 
index 5b3af25..c108c70 100644 (file)
@@ -109,17 +109,17 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_ANISOTROPIC_FILTER:
    case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE:
    case PIPE_CAP_NPOT_TEXTURES:
+   case PIPE_CAP_POINT_SPRITE:
    case PIPE_CAP_PRIMITIVE_RESTART: /* draw module */
    case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
    case PIPE_CAP_TEXTURE_SHADOW_MAP:
    case PIPE_CAP_TWO_SIDED_STENCIL:
+   case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
       return 1;
 
    /* Features that should be supported (boolean caps). */
    /* XXX: Just test the code */
    case PIPE_CAP_BLEND_EQUATION_SEPARATE:
-   /* XXX: No code but hw supports it */
-   case PIPE_CAP_POINT_SPRITE:
       /* Also lie about these when asked to (needed for GLSL / GL 2.0) */
       return is->debug.lie ? 1 : 0;
 
@@ -129,7 +129,6 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_INDEP_BLEND_ENABLE:
    case PIPE_CAP_INDEP_BLEND_FUNC:
    case PIPE_CAP_TGSI_INSTANCEID:
-   case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
    case PIPE_CAP_SHADER_STENCIL_EXPORT:
    case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
    case PIPE_CAP_TEXTURE_SWIZZLE:
@@ -256,7 +255,7 @@ i915_get_paramf(struct pipe_screen *screen, enum pipe_cap cap)
    }
 }
 
-static boolean
+boolean
 i915_is_format_supported(struct pipe_screen *screen,
                          enum pipe_format format,
                          enum pipe_texture_target target,
@@ -266,7 +265,10 @@ i915_is_format_supported(struct pipe_screen *screen,
    static const enum pipe_format tex_supported[] = {
       PIPE_FORMAT_B8G8R8A8_UNORM,
       PIPE_FORMAT_B8G8R8X8_UNORM,
+      PIPE_FORMAT_R8G8B8A8_UNORM,
+      PIPE_FORMAT_R8G8B8X8_UNORM,
       PIPE_FORMAT_B5G6R5_UNORM,
+      PIPE_FORMAT_B10G10R10A2_UNORM,
       PIPE_FORMAT_L8_UNORM,
       PIPE_FORMAT_A8_UNORM,
       PIPE_FORMAT_I8_UNORM,
@@ -285,7 +287,12 @@ i915_is_format_supported(struct pipe_screen *screen,
    };
    static const enum pipe_format render_supported[] = {
       PIPE_FORMAT_B8G8R8A8_UNORM,
+      PIPE_FORMAT_R8G8B8A8_UNORM,
       PIPE_FORMAT_B5G6R5_UNORM,
+      PIPE_FORMAT_B10G10R10A2_UNORM,
+      PIPE_FORMAT_L8_UNORM,
+      PIPE_FORMAT_A8_UNORM,
+      PIPE_FORMAT_I8_UNORM,
       PIPE_FORMAT_NONE  /* list terminator */
    };
    static const enum pipe_format depth_supported[] = {
index cfc585b..9f2004e 100644 (file)
@@ -65,5 +65,11 @@ i915_screen(struct pipe_screen *pscreen)
    return (struct i915_screen *) pscreen;
 }
 
+boolean
+i915_is_format_supported(struct pipe_screen *screen,
+                         enum pipe_format format,
+                         enum pipe_texture_target target,
+                         unsigned sample_count,
+                         unsigned tex_usage);
 
 #endif /* I915_SCREEN_H */
index 1b57c57..2812de1 100644 (file)
@@ -146,6 +146,7 @@ i915_create_blend_state(struct pipe_context *pipe,
    if (blend->dither)
       cso_data->LIS5 |= S5_COLOR_DITHER_ENABLE;
 
+   /* XXX here take the target fixup into account */
    if ((blend->rt[0].colormask & PIPE_MASK_R) == 0)
       cso_data->LIS5 |= S5_WRITEDISABLE_RED;
 
@@ -243,10 +244,10 @@ i915_create_sampler_state(struct pipe_context *pipe,
 
    /* Shadow:
     */
-   if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) 
+   if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE)
    {
       cso->state[0] |= (SS2_SHADOW_ENABLE |
-                        i915_translate_compare_func(sampler->compare_func));
+                        i915_translate_shadow_compare_func(sampler->compare_func));
 
       minFilt = FILTER_4X4_FLAT;
       magFilt = FILTER_4X4_FLAT;
@@ -466,6 +467,7 @@ i915_create_fs_state(struct pipe_context *pipe,
    if (!ifs)
       return NULL;
 
+   ifs->draw_data = draw_create_fragment_shader(i915->draw, templ);
    ifs->state.tokens = tgsi_dup_tokens(templ->tokens);
 
    tgsi_scan_shader(templ->tokens, &ifs->info);
@@ -495,6 +497,8 @@ i915_bind_fs_state(struct pipe_context *pipe, void *shader)
 
    i915->fs = (struct i915_fragment_shader*) shader;
 
+   draw_bind_fragment_shader(i915->draw,  (i915->fs ? i915->fs->draw_data : NULL));
+
    i915->dirty |= I915_NEW_FS;
 }
 
@@ -503,12 +507,14 @@ void i915_delete_fs_state(struct pipe_context *pipe, void *shader)
 {
    struct i915_fragment_shader *ifs = (struct i915_fragment_shader *) shader;
 
-   if (ifs->program)
+   if (ifs->program) {
       FREE(ifs->program);
+      ifs->program = NULL;
+      FREE((struct tgsi_token *)ifs->state.tokens);
+      ifs->state.tokens = NULL;
+   }
    ifs->program_len = 0;
 
-   FREE((struct tgsi_token *)ifs->state.tokens);
-
    FREE(ifs);
 }
 
index 392ba19..e01f16e 100644 (file)
@@ -33,6 +33,7 @@
 #include "i915_context.h"
 #include "i915_state.h"
 #include "i915_debug.h"
+#include "i915_fpc.h"
 #include "i915_reg.h"
 
 static uint find_mapping(const struct i915_fragment_shader* fs, int unit)
@@ -58,12 +59,12 @@ static void calculate_vertex_layout(struct i915_context *i915)
    const struct i915_fragment_shader *fs = i915->fs;
    const enum interp_mode colorInterp = i915->rasterizer->color_interp;
    struct vertex_info vinfo;
-   boolean texCoords[I915_TEX_UNITS], colors[2], fog, needW;
+   boolean texCoords[I915_TEX_UNITS], colors[2], fog, needW, face;
    uint i;
    int src;
 
    memset(texCoords, 0, sizeof(texCoords));
-   colors[0] = colors[1] = fog = needW = FALSE;
+   colors[0] = colors[1] = fog = needW = face = FALSE;
    memset(&vinfo, 0, sizeof(vinfo));
 
    /* Determine which fragment program inputs are needed.  Setup HW vertex
@@ -72,6 +73,10 @@ static void calculate_vertex_layout(struct i915_context *i915)
    for (i = 0; i < fs->info.num_inputs; i++) {
       switch (fs->info.input_semantic_name[i]) {
       case TGSI_SEMANTIC_POSITION:
+         {
+            uint unit = I915_SEMANTIC_POS;
+            texCoords[find_mapping(fs, unit)] = TRUE;
+         }
          break;
       case TGSI_SEMANTIC_COLOR:
          assert(fs->info.input_semantic_index[i] < 2);
@@ -80,7 +85,6 @@ static void calculate_vertex_layout(struct i915_context *i915)
       case TGSI_SEMANTIC_GENERIC:
          {
             /* texcoords/varyings/other generic */
-            /* XXX handle back/front face and point size */
             uint unit = fs->info.input_semantic_index[i];
 
             texCoords[find_mapping(fs, unit)] = TRUE;
@@ -90,7 +94,11 @@ static void calculate_vertex_layout(struct i915_context *i915)
       case TGSI_SEMANTIC_FOG:
          fog = TRUE;
          break;
+      case TGSI_SEMANTIC_FACE:
+         face = TRUE;
+         break;
       default:
+         debug_printf("Unknown input type %d\n", fs->info.input_semantic_name[i]);
          assert(0);
       }
    }
@@ -147,6 +155,20 @@ static void calculate_vertex_layout(struct i915_context *i915)
       vinfo.hwfmt[1] |= hwtc << (i * 4);
    }
 
+   /* front/back face */
+   if (face) {
+      uint slot = find_mapping(fs, I915_SEMANTIC_FACE);
+      debug_printf("Front/back face is broken\n");
+      /* XXX Because of limitations in the draw module, currently src will be 0
+       * for SEMANTIC_FACE, so this aliases to POS. We need to fix in the draw
+       * module by adding an extra shader output.
+       */
+      src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_FACE, 0);
+      draw_emit_vertex_attr(&vinfo, EMIT_1F, INTERP_CONSTANT, src);
+      vinfo.hwfmt[1] &= ~(TEXCOORDFMT_NOT_PRESENT << (slot * 4));
+      vinfo.hwfmt[1] |= TEXCOORDFMT_1D << (slot * 4);
+   }
+
    draw_compute_vertex_size(&vinfo);
 
    if (memcmp(&i915->current.vertex_info, &vinfo, sizeof(vinfo))) {
index 0155cd8..4f44796 100644 (file)
@@ -34,7 +34,9 @@
 
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
+#include "pipe/p_format.h"
 
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -128,7 +130,7 @@ validate_immediate(struct i915_context *i915, unsigned *batch_space)
 static void
 emit_immediate(struct i915_context *i915)
 {
-   /* remove unwatned bits and S7 */
+   /* remove unwanted bits and S7 */
    unsigned dirty = (1 << I915_IMMEDIATE_S0 | 1 << I915_IMMEDIATE_S1 |
                      1 << I915_IMMEDIATE_S2 | 1 << I915_IMMEDIATE_S3 |
                      1 << I915_IMMEDIATE_S3 | 1 << I915_IMMEDIATE_S4 |
@@ -341,21 +343,84 @@ emit_constants(struct i915_context *i915)
    }
 }
 
+static const struct
+{
+   enum pipe_format format;
+   uint hw_swizzle;
+} fixup_formats[] = {
+   { PIPE_FORMAT_R8G8B8A8_UNORM, 0x21030000 /* BGRA */},
+   { PIPE_FORMAT_L8_UNORM,       0x00030000 /* RRRA */},
+   { PIPE_FORMAT_I8_UNORM,       0x00030000 /* RRRA */},
+   { PIPE_FORMAT_A8_UNORM,       0x33330000 /* AAAA */},
+   { PIPE_FORMAT_NONE,           0x00000000},
+};
+
+static uint need_target_fixup(struct pipe_surface* p)
+{
+   enum pipe_format f;
+   /* if we don't have a surface bound yet, we don't need to fixup the shader */
+   if (!p)
+      return 0;
+
+   f = p->format;
+   for(int i=0; fixup_formats[i].format != PIPE_FORMAT_NONE; i++)
+      if (fixup_formats[i].format == f)
+         return 1;
+
+   return 0;
+}
+
+static uint fixup_swizzle(enum pipe_format f)
+{
+   for(int i=0; fixup_formats[i].format != PIPE_FORMAT_NONE; i++)
+      if (fixup_formats[i].format == f)
+         return fixup_formats[i].hw_swizzle;
+
+   return 0;
+}
+
 static void
 validate_program(struct i915_context *i915, unsigned *batch_space)
 {
-   *batch_space = i915->fs->program_len;
+   struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
+   uint additional_size = need_target_fixup(cbuf_surface);
+
+   /* we need more batch space if we want to emulate rgba framebuffers */
+   *batch_space = i915->fs->program_len + 3 * additional_size;
 }
 
 static void
 emit_program(struct i915_context *i915)
 {
-      uint i;
-      /* we should always have, at least, a pass-through program */
-      assert(i915->fs->program_len > 0);
-      for (i = 0; i < i915->fs->program_len; i++) {
-         OUT_BATCH(i915->fs->program[i]);
-      }
+   struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
+   uint target_fixup = need_target_fixup(cbuf_surface);
+   uint i;
+
+   /* we should always have, at least, a pass-through program */
+   assert(i915->fs->program_len > 0);
+
+   {
+      /* first word has the size, we have to adjust that */
+      uint size = (i915->fs->program[0]);
+      size += target_fixup * 3;
+      OUT_BATCH(size);
+   }
+
+   /* output the declarations of the program */
+   for (i=1 ; i < i915->fs->program_len; i++) 
+      OUT_BATCH(i915->fs->program[i]);
+
+   /* we emit an additional mov with swizzle to fake RGBA framebuffers */
+   if (target_fixup) {
+      /* mov out_color, out_color.zyxw */
+      OUT_BATCH(A0_MOV |
+                (REG_TYPE_OC << A0_DEST_TYPE_SHIFT) |
+                A0_DEST_CHANNEL_ALL |
+                (REG_TYPE_OC << A0_SRC0_TYPE_SHIFT) |
+                (T_DIFFUSE << A0_SRC0_NR_SHIFT));
+      OUT_BATCH(fixup_swizzle(cbuf_surface->format));
+      OUT_BATCH(0);
+   }
 }
 
 static void
index b589117..aa992f7 100644 (file)
@@ -60,6 +60,31 @@ i915_translate_compare_func(unsigned func)
 }
 
 static INLINE unsigned
+i915_translate_shadow_compare_func(unsigned func)
+{
+   switch (func) {
+   case PIPE_FUNC_NEVER:
+      return COMPAREFUNC_ALWAYS;
+   case PIPE_FUNC_LESS:
+      return COMPAREFUNC_LEQUAL;
+   case PIPE_FUNC_LEQUAL:
+      return COMPAREFUNC_LESS;
+   case PIPE_FUNC_GREATER:
+      return COMPAREFUNC_GEQUAL;
+   case PIPE_FUNC_GEQUAL:
+      return COMPAREFUNC_GREATER;
+   case PIPE_FUNC_NOTEQUAL:
+      return COMPAREFUNC_EQUAL;
+   case PIPE_FUNC_EQUAL:
+      return COMPAREFUNC_NOTEQUAL;
+   case PIPE_FUNC_ALWAYS:
+      return COMPAREFUNC_NEVER;
+   default:
+      return COMPAREFUNC_NEVER;
+   }
+}
+
+static INLINE unsigned
 i915_translate_stencil_op(unsigned op)
 {
    switch (op) {
index be70e7a..0103f7c 100644 (file)
@@ -62,6 +62,7 @@ static void update_map(struct i915_context *i915,
                        uint unit,
                        const struct i915_texture *tex,
                        const struct i915_sampler_state *sampler,
+                       const struct pipe_sampler_view* view,
                        uint state[2]);
 
 
@@ -161,9 +162,10 @@ static void update_samplers(struct i915_context *i915)
                         i915->current.sampler[unit]); /* the result */
          update_map(i915,
                     unit,
-                    texture,                        /* texture */
-                    i915->sampler[unit],            /* sampler state */
-                    i915->current.texbuffer[unit]); /* the result */
+                    texture,                             /* texture */
+                    i915->sampler[unit],                 /* sampler state */
+                    i915->fragment_sampler_views[unit],  /* sampler view */
+                    i915->current.texbuffer[unit]);      /* the result */
 
          i915->current.sampler_enable_nr++;
          i915->current.sampler_enable_flags |= (1 << unit);
@@ -180,13 +182,21 @@ struct i915_tracked_state i915_hw_samplers = {
 };
 
 
-
 /***********************************************************************
  * Sampler views
  */
 
-static uint translate_texture_format(enum pipe_format pipeFormat)
+static uint translate_texture_format(enum pipe_format pipeFormat,
+                                     const struct pipe_sampler_view* view)
 {
+   if ( (view->swizzle_r != PIPE_SWIZZLE_RED ||
+         view->swizzle_g != PIPE_SWIZZLE_GREEN ||
+         view->swizzle_b != PIPE_SWIZZLE_BLUE ||
+         view->swizzle_a != PIPE_SWIZZLE_ALPHA ) &&
+        pipeFormat != PIPE_FORMAT_Z24_UNORM_S8_USCALED &&
+        pipeFormat != PIPE_FORMAT_Z24X8_UNORM )
+      debug_printf("i915: unsupported texture swizzle for format %d\n", pipeFormat);
+
    switch (pipeFormat) {
    case PIPE_FORMAT_L8_UNORM:
       return MAPSURF_8BIT | MT_8BIT_L8;
@@ -202,16 +212,16 @@ static uint translate_texture_format(enum pipe_format pipeFormat)
       return MAPSURF_16BIT | MT_16BIT_ARGB1555;
    case PIPE_FORMAT_B4G4R4A4_UNORM:
       return MAPSURF_16BIT | MT_16BIT_ARGB4444;
+   case PIPE_FORMAT_B10G10R10A2_UNORM:
+      return MAPSURF_32BIT | MT_32BIT_ARGB2101010;
    case PIPE_FORMAT_B8G8R8A8_UNORM:
       return MAPSURF_32BIT | MT_32BIT_ARGB8888;
    case PIPE_FORMAT_B8G8R8X8_UNORM:
       return MAPSURF_32BIT | MT_32BIT_XRGB8888;
    case PIPE_FORMAT_R8G8B8A8_UNORM:
       return MAPSURF_32BIT | MT_32BIT_ABGR8888;
-#if 0
    case PIPE_FORMAT_R8G8B8X8_UNORM:
       return MAPSURF_32BIT | MT_32BIT_XBGR8888;
-#endif
    case PIPE_FORMAT_YUYV:
       return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
    case PIPE_FORMAT_UYVY:
@@ -232,7 +242,25 @@ static uint translate_texture_format(enum pipe_format pipeFormat)
       return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
    case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
    case PIPE_FORMAT_Z24X8_UNORM:
-      return (MAPSURF_32BIT | MT_32BIT_xI824);
+      {
+         if ( view->swizzle_r == PIPE_SWIZZLE_RED &&
+              view->swizzle_g == PIPE_SWIZZLE_RED &&
+              view->swizzle_b == PIPE_SWIZZLE_RED &&
+              view->swizzle_a == PIPE_SWIZZLE_ONE)
+            return (MAPSURF_32BIT | MT_32BIT_xA824);
+         if ( view->swizzle_r == PIPE_SWIZZLE_RED &&
+              view->swizzle_g == PIPE_SWIZZLE_RED &&
+              view->swizzle_b == PIPE_SWIZZLE_RED &&
+              view->swizzle_a == PIPE_SWIZZLE_RED)
+            return (MAPSURF_32BIT | MT_32BIT_xI824);
+         if ( view->swizzle_r == PIPE_SWIZZLE_ZERO &&
+              view->swizzle_g == PIPE_SWIZZLE_ZERO &&
+              view->swizzle_b == PIPE_SWIZZLE_ZERO &&
+              view->swizzle_a == PIPE_SWIZZLE_RED)
+            return (MAPSURF_32BIT | MT_32BIT_xL824);
+         debug_printf("i915: unsupported depth swizzle\n");
+         return (MAPSURF_32BIT | MT_32BIT_xL824);
+      }
    default:
       debug_printf("i915: translate_texture_format() bad image format %x\n",
                    pipeFormat);
@@ -262,6 +290,7 @@ static void update_map(struct i915_context *i915,
                        uint unit,
                        const struct i915_texture *tex,
                        const struct i915_sampler_state *sampler,
+                       const struct pipe_sampler_view* view,
                        uint state[2])
 {
    const struct pipe_resource *pt = &tex->b.b;
@@ -275,7 +304,7 @@ static void update_map(struct i915_context *i915,
    assert(height);
    assert(depth);
 
-   format = translate_texture_format(pt->format);
+   format = translate_texture_format(pt->format, view);
    pitch = tex->stride;
 
    assert(format);
@@ -318,8 +347,9 @@ static void update_maps(struct i915_context *i915)
 
          update_map(i915,
                     unit,
-                    texture,                      /* texture */
-                    i915->sampler[unit],          /* sampler state */
+                    texture,                            /* texture */
+                    i915->sampler[unit],                /* sampler state */
+                    i915->fragment_sampler_views[unit], /* sampler view */
                     i915->current.texbuffer[unit]);
       }
    }
index 2865298..0e4000b 100644 (file)
@@ -42,6 +42,18 @@ static unsigned translate_format(enum pipe_format format)
       return COLOR_BUF_ARGB8888;
    case PIPE_FORMAT_B5G6R5_UNORM:
       return COLOR_BUF_RGB565;
+   case PIPE_FORMAT_B5G5R5A1_UNORM:
+      return COLOR_BUF_ARGB1555;
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
+      return COLOR_BUF_ARGB8888;
+   case PIPE_FORMAT_B4G4R4A4_UNORM:
+      return COLOR_BUF_ARGB4444;
+   case PIPE_FORMAT_B10G10R10A2_UNORM:
+      return COLOR_BUF_ARGB2101010;
+   case PIPE_FORMAT_L8_UNORM:
+   case PIPE_FORMAT_A8_UNORM:
+   case PIPE_FORMAT_I8_UNORM:
+      return COLOR_BUF_8BIT;
    default:
       assert(0);
       return 0;
@@ -137,7 +149,8 @@ static void update_framebuffer(struct i915_context *i915)
       i915->static_dirty |= I915_DST_RECT;
    }
 
-   i915->hardware_dirty |= I915_HW_STATIC;
+   /* we also send a new program to make sure the fixup for RGBA surfaces happens */
+   i915->hardware_dirty |= I915_HW_STATIC | I915_HW_PROGRAM;
 
    /* flush the cache in case we sample from the old renderbuffers */
    i915_set_flush_dirty(i915, I915_FLUSH_CACHE);
index 21cfdc9..2043860 100644 (file)
@@ -207,6 +207,12 @@ struct i915_winsys {
 
    void (*buffer_destroy)(struct i915_winsys *iws,
                           struct i915_winsys_buffer *buffer);
+
+   /**
+    * Check if a buffer is busy.
+    */
+   boolean (*buffer_is_busy)(struct i915_winsys *iws,
+                             struct i915_winsys_buffer *buffer);
    /*@}*/
 
 
index ba9705b..f930135 100644 (file)
@@ -51,6 +51,7 @@ C_SOURCES = \
 CPP_SOURCES = \
 
 PROGS := lp_test_format        \
+        lp_test_arit   \
         lp_test_blend  \
         lp_test_conv   \
         lp_test_printf \
index c10a8cb..2b232a5 100644 (file)
@@ -79,17 +79,18 @@ llvmpipe = env.ConvenienceLibrary(
 env.Alias('llvmpipe', llvmpipe)
 
 
-if env['platform'] != 'embedded':
+if not env['embedded']:
     env = env.Clone()
 
     env.Prepend(LIBS = [llvmpipe] + gallium)
 
     tests = [
+        'arit',
         'format',
         'blend',
         'conv',
-       'printf',
-       'sincos',
+        'printf',
+        'sincos',
     ]
 
     if not env['msvc']:
index 268f0fa..ce92a80 100644 (file)
@@ -68,10 +68,17 @@ lp_jit_create_types(struct llvmpipe_context *lp)
       elem_types[LP_JIT_TEXTURE_BORDER_COLOR] = 
          LLVMArrayType(LLVMFloatTypeInContext(lc), 4);
 
+#if HAVE_LLVM >= 0x0300
+   texture_type = LLVMStructCreateNamed(gallivm->context, "texture");
+   LLVMStructSetBody(texture_type, elem_types,
+                     Elements(elem_types), 0);
+#else
       texture_type = LLVMStructTypeInContext(lc, elem_types,
                                              Elements(elem_types), 0);
+      LLVMAddTypeName(gallivm->module, "texture", texture_type);
 
       LLVMInvalidateStructLayout(gallivm->target, texture_type);
+#endif
 
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width,
                              gallivm->target, texture_type,
@@ -112,8 +119,6 @@ lp_jit_create_types(struct llvmpipe_context *lp)
 
       LP_CHECK_STRUCT_SIZE(struct lp_jit_texture,
                            gallivm->target, texture_type);
-
-      LLVMAddTypeName(gallivm->module, "texture", texture_type);
    }
 
    /* struct lp_jit_context */
@@ -129,11 +134,19 @@ lp_jit_create_types(struct llvmpipe_context *lp)
       elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
                                                       PIPE_MAX_SAMPLERS);
 
+#if HAVE_LLVM >= 0x0300
+   context_type = LLVMStructCreateNamed(gallivm->context, "context");
+   LLVMStructSetBody(context_type, elem_types,
+                     Elements(elem_types), 0);
+#else
       context_type = LLVMStructTypeInContext(lc, elem_types,
                                              Elements(elem_types), 0);
 
       LLVMInvalidateStructLayout(gallivm->target, context_type);
 
+      LLVMAddTypeName(gallivm->module, "context", context_type);
+#endif
+
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
                              gallivm->target, context_type,
                              LP_JIT_CTX_CONSTANTS);
@@ -155,8 +168,6 @@ lp_jit_create_types(struct llvmpipe_context *lp)
       LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
                            gallivm->target, context_type);
 
-      LLVMAddTypeName(gallivm->module, "context", context_type);
-
       lp->jit_context_ptr_type = LLVMPointerType(context_type, 0);
    }
 
index 036a6e0..e3f8c19 100644 (file)
@@ -93,7 +93,9 @@ llvmpipe_get_vendor(struct pipe_screen *screen)
 static const char *
 llvmpipe_get_name(struct pipe_screen *screen)
 {
-   return "llvmpipe";
+   static char buf[100];
+   snprintf(buf, sizeof(buf), "llvmpipe (LLVM 0x%x)", HAVE_LLVM);
+   return buf;
 }
 
 
@@ -423,7 +425,7 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
    lp_jit_screen_init(screen);
 
    screen->num_threads = util_cpu_caps.nr_cpus > 1 ? util_cpu_caps.nr_cpus : 0;
-#ifdef PIPE_OS_EMBEDDED
+#ifdef PIPE_SUBSYSTEM_EMBEDDED
    screen->num_threads = 0;
 #endif
    screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads);
diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c
new file mode 100644 (file)
index 0000000..f0e43e0
--- /dev/null
@@ -0,0 +1,294 @@
+/**************************************************************************
+ *
+ * Copyright 2011 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 <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "util/u_pointer.h"
+#include "util/u_memory.h"
+
+#include "gallivm/lp_bld.h"
+#include "gallivm/lp_bld_init.h"
+#include "gallivm/lp_bld_arit.h"
+
+#include "lp_test.h"
+
+
+void
+write_tsv_header(FILE *fp)
+{
+   fprintf(fp,
+           "result\t"
+           "format\n");
+
+   fflush(fp);
+}
+
+
+typedef float (*unary_func_t)(float);
+
+
+/**
+ * Describe a test case of one unary function.
+ */
+struct unary_test_t
+{
+   /*
+    * Test name -- name of the mathematical function under test.
+    */
+
+   const char *name;
+
+   LLVMValueRef
+   (*builder)(struct lp_build_context *bld, LLVMValueRef a);
+
+   /*
+    * Reference (pure-C) function.
+    */
+   float
+   (*ref)(float a);
+
+   /*
+    * Test values.
+    */
+   const float *values;
+   unsigned num_values;
+};
+
+
+const float exp2_values[] = {
+   -60,
+   -4,
+   -2,
+   -1,
+   -1e-007,
+   0,
+   1e-007,
+   1, 
+   2, 
+   4, 
+   60
+};
+
+
+const float log2_values[] = {
+#if 0
+   /* 
+    * Smallest denormalized number; meant just for experimentation, but not
+    * validation.
+    */
+   1.4012984643248171e-45,
+#endif
+   1e-007,
+   0.5,
+   1,
+   2,
+   4,
+   100000,
+   1e+018
+};
+
+
+static float rsqrtf(float x)
+{
+   return 1.0/sqrt(x);
+}
+
+
+const float rsqrt_values[] = {
+   -1, -1e-007,
+   1e-007, 1,
+   -4, -1,
+   1, 4,
+   -1e+035, -100000,
+   100000, 1e+035,
+};
+
+
+const float sincos_values[] = {
+   -5*M_PI/4,
+   -4*M_PI/4,
+   -4*M_PI/4,
+   -3*M_PI/4,
+   -2*M_PI/4,
+   -1*M_PI/4,
+    1*M_PI/4,
+    2*M_PI/4,
+    3*M_PI/4,
+    4*M_PI/4,
+    5*M_PI/4,
+};
+
+
+/*
+ * Unary test cases.
+ */
+
+static const struct unary_test_t unary_tests[] = {
+   {"exp2", &lp_build_exp2, &exp2f, exp2_values, Elements(exp2_values)},
+   {"log2", &lp_build_log2, &log2f, log2_values, Elements(log2_values)},
+   {"exp", &lp_build_exp, &expf, exp2_values, Elements(exp2_values)},
+   {"log", &lp_build_log, &logf, log2_values, Elements(log2_values)},
+   {"rsqrt", &lp_build_rsqrt, &rsqrtf, rsqrt_values, Elements(rsqrt_values)},
+   {"sin", &lp_build_sin, &sinf, sincos_values, Elements(sincos_values)},
+   {"cos", &lp_build_cos, &cosf, sincos_values, Elements(sincos_values)},
+};
+
+
+/*
+ * Build LLVM function that exercises the unary operator builder.
+ */
+static LLVMValueRef
+build_unary_test_func(struct gallivm_state *gallivm,
+                      LLVMModuleRef module,
+                      LLVMContextRef context,
+                      const struct unary_test_t *test)
+{
+   LLVMTypeRef i32t = LLVMInt32TypeInContext(context);
+   LLVMTypeRef f32t = LLVMFloatTypeInContext(context);
+   LLVMTypeRef v4f32t = LLVMVectorType(f32t, 4);
+   LLVMTypeRef args[1] = { f32t };
+   LLVMValueRef func = LLVMAddFunction(module, test->name, LLVMFunctionType(f32t, args, Elements(args), 0));
+   LLVMValueRef arg1 = LLVMGetParam(func, 0);
+   LLVMBuilderRef builder = gallivm->builder;
+   LLVMBasicBlockRef block = LLVMAppendBasicBlockInContext(context, func, "entry");
+   LLVMValueRef index0 = LLVMConstInt(i32t, 0, 0);
+   LLVMValueRef ret;
+
+   struct lp_build_context bld;
+
+   lp_build_context_init(&bld, gallivm, lp_float32_vec4_type());
+
+   LLVMSetFunctionCallConv(func, LLVMCCallConv);
+
+   LLVMPositionBuilderAtEnd(builder, block);
+   
+   /* scalar to vector */
+   arg1 = LLVMBuildInsertElement(builder, LLVMGetUndef(v4f32t), arg1, index0, "");
+
+   ret = test->builder(&bld, arg1);
+   
+   /* vector to scalar */
+   ret = LLVMBuildExtractElement(builder, ret, index0, "");
+
+   LLVMBuildRet(builder, ret);
+   return func;
+}
+
+
+/*
+ * Test one LLVM unary arithmetic builder function.
+ */
+static boolean
+test_unary(struct gallivm_state *gallivm, unsigned verbose, FILE *fp, const struct unary_test_t *test)
+{
+   LLVMModuleRef module = gallivm->module;
+   LLVMValueRef test_func;
+   LLVMExecutionEngineRef engine = gallivm->engine;
+   LLVMContextRef context = gallivm->context;
+   char *error = NULL;
+   unary_func_t test_func_jit;
+   boolean success = TRUE;
+   int i;
+
+   test_func = build_unary_test_func(gallivm, module, context, test);
+
+   if (LLVMVerifyModule(module, LLVMPrintMessageAction, &error)) {
+      printf("LLVMVerifyModule: %s\n", error);
+      LLVMDumpModule(module);
+      abort();
+   }
+   LLVMDisposeMessage(error);
+
+   test_func_jit = (unary_func_t) pointer_to_func(LLVMGetPointerToGlobal(engine, test_func));
+
+   for (i = 0; i < test->num_values; ++i) {
+      float value = test->values[i];
+      float ref = test->ref(value);
+      float src = test_func_jit(value);
+
+      double error = fabs(src - ref);
+      double precision = error ? -log2(error/fabs(ref)) : FLT_MANT_DIG;
+
+      bool pass = precision >= 20.0;
+
+      if (isnan(ref)) {
+         continue;
+      }
+
+      if (!pass || verbose) {
+         printf("%s(%.9g): ref = %.9g, src = %.9g, precision = %f bits, %s\n",
+               test->name, value, ref, src, precision,
+               pass ? "PASS" : "FAIL");
+      }
+
+      if (!pass) {
+         success = FALSE;
+      }
+   }
+
+   LLVMFreeMachineCodeForFunction(engine, test_func);
+
+   return success;
+}
+
+
+boolean
+test_all(struct gallivm_state *gallivm, unsigned verbose, FILE *fp)
+{
+   boolean success = TRUE;
+   int i;
+
+   for (i = 0; i < Elements(unary_tests); ++i) {
+      if (!test_unary(gallivm, verbose, fp, &unary_tests[i])) {
+         success = FALSE;
+      }
+   }
+
+   return success;
+}
+
+
+boolean
+test_some(struct gallivm_state *gallivm, unsigned verbose, FILE *fp,
+          unsigned long n)
+{
+   /*
+    * Not randomly generated test cases, so test all.
+    */
+
+   return test_all(gallivm, verbose, fp);
+}
+
+
+boolean
+test_single(struct gallivm_state *gallivm, unsigned verbose, FILE *fp)
+{
+   return TRUE;
+}
index 3210d1f..aae6d98 100644 (file)
@@ -10,6 +10,7 @@ LIBRARY_INCLUDES = \
 C_SOURCES = nouveau_screen.c \
             nouveau_fence.c \
             nouveau_mm.c \
-            nouveau_buffer.c
+            nouveau_buffer.c \
+            nouveau_video.c
 
 include ../../Makefile.template
index 696e0d3..19bf7c8 100644 (file)
@@ -23,4 +23,7 @@ nouveau_context(struct pipe_context *pipe)
    return (struct nouveau_context *)pipe;
 }
 
+void
+nouveau_context_init_vdec(struct nouveau_context *);
+
 #endif
index 401155b..223e768 100644 (file)
@@ -81,20 +81,6 @@ nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
        return bo;
 }
 
-struct nouveau_bo *
-nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes)
-{
-       struct nouveau_device *dev = nouveau_screen(pscreen)->device;
-       struct nouveau_bo *bo = NULL;
-       int ret;
-
-       ret = nouveau_bo_user(dev, ptr, bytes, &bo);
-       if (ret)
-               return NULL;
-
-       return bo;
-}
-
 void *
 nouveau_screen_bo_map(struct pipe_screen *pscreen,
                      struct nouveau_bo *bo,
index 186ada3..cf291c6 100644 (file)
@@ -47,8 +47,6 @@ nouveau_screen(struct pipe_screen *pscreen)
 struct nouveau_bo *
 nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
                      unsigned usage, unsigned bind, unsigned size);
-struct nouveau_bo *
-nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes);
 void *
 nouveau_screen_bo_map(struct pipe_screen *pscreen,
                      struct nouveau_bo *pb,
@@ -78,6 +76,7 @@ nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
 int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *);
 void nouveau_screen_fini(struct nouveau_screen *);
 
+void nouveau_screen_init_vdec(struct nouveau_screen *);
 
 
 #ifndef NOUVEAU_NVC0
diff --git a/src/gallium/drivers/nouveau/nouveau_video.c b/src/gallium/drivers/nouveau/nouveau_video.c
new file mode 100644 (file)
index 0000000..32f038d
--- /dev/null
@@ -0,0 +1,39 @@
+
+#include "vl/vl_decoder.h"
+#include "vl/vl_video_buffer.h"
+
+#include "nouveau/nouveau_screen.h"
+#include "nouveau/nouveau_context.h"
+
+static int
+nouveau_screen_get_video_param(struct pipe_screen *pscreen,
+                               enum pipe_video_profile profile,
+                               enum pipe_video_cap param)
+{
+   switch (param) {
+   case PIPE_VIDEO_CAP_SUPPORTED:
+      return vl_profile_supported(pscreen, profile);
+   case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+      return 1;
+   case PIPE_VIDEO_CAP_MAX_WIDTH:
+   case PIPE_VIDEO_CAP_MAX_HEIGHT:
+      return vl_video_buffer_max_size(pscreen);
+   default:
+      debug_printf("unknown video param: %d\n", param);
+      return 0;
+   }
+}
+
+void
+nouveau_screen_init_vdec(struct nouveau_screen *screen)
+{
+   screen->base.get_video_param = nouveau_screen_get_video_param;
+   screen->base.is_video_format_supported = vl_video_buffer_is_format_supported;
+}
+
+void
+nouveau_context_init_vdec(struct nouveau_context *nv)
+{
+   nv->pipe.create_video_decoder = vl_create_decoder;
+   nv->pipe.create_video_buffer = vl_video_buffer_create;
+}
index 41a380e..1bde07f 100644 (file)
@@ -777,7 +777,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NVA3_3D_VERTEX_ARRAY_ATTRIB_ALT_FORMAT_8_8             0x03000000
 #define NVA3_3D_VERTEX_ARRAY_ATTRIB_ALT_FORMAT_16              0x03600000
 #define NVA3_3D_VERTEX_ARRAY_ATTRIB_ALT_FORMAT_8               0x03a00000
-#define NVA3_3D_VERTEX_ARRAY_ATTRIB_ALT_FORMAT_2_10_10_10      0x06000000
+#define NVA3_3D_VERTEX_ARRAY_ATTRIB_ALT_FORMAT_10_10_10_2      0x06000000
 #define NVA3_3D_VERTEX_ARRAY_ATTRIB_ALT_TYPE__MASK             0x38000000
 #define NVA3_3D_VERTEX_ARRAY_ATTRIB_ALT_TYPE__SHIFT            27
 #define NVA3_3D_VERTEX_ARRAY_ATTRIB_ALT_TYPE_SNORM             0x08000000
@@ -1935,7 +1935,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NV50_3D_VERTEX_ARRAY_ATTRIB_FORMAT_8_8                 0x00c00000
 #define NV50_3D_VERTEX_ARRAY_ATTRIB_FORMAT_16                  0x00d80000
 #define NV50_3D_VERTEX_ARRAY_ATTRIB_FORMAT_8                   0x00e80000
-#define NV50_3D_VERTEX_ARRAY_ATTRIB_FORMAT_2_10_10_10          0x01800000
+#define NV50_3D_VERTEX_ARRAY_ATTRIB_FORMAT_10_10_10_2          0x01800000
 #define NV50_3D_VERTEX_ARRAY_ATTRIB_TYPE__MASK                 0x7e000000
 #define NV50_3D_VERTEX_ARRAY_ATTRIB_TYPE__SHIFT                        25
 #define NV50_3D_VERTEX_ARRAY_ATTRIB_TYPE_FLOAT                 0x7e000000
index 632ca4d..0d46406 100644 (file)
@@ -60,13 +60,13 @@ nv50_texture_barrier(struct pipe_context *pipe)
 void
 nv50_default_flush_notify(struct nouveau_channel *chan)
 {
-   struct nv50_context *nv50 = chan->user_private;
+   struct nv50_screen *screen = chan->user_private;
 
-   if (!nv50)
+   if (!screen)
       return;
 
-   nouveau_fence_update(&nv50->screen->base, TRUE);
-   nouveau_fence_next(&nv50->screen->base);
+   nouveau_fence_update(&screen->base, TRUE);
+   nouveau_fence_next(&screen->base);
 }
 
 static void
@@ -100,10 +100,8 @@ nv50_destroy(struct pipe_context *pipe)
 
    draw_destroy(nv50->draw);
 
-   if (nv50->screen->cur_ctx == nv50) {
-      nv50->screen->base.channel->user_private = NULL;
+   if (nv50->screen->cur_ctx == nv50)
       nv50->screen->cur_ctx = NULL;
-   }
 
    FREE(nv50);
 }
@@ -140,7 +138,6 @@ nv50_create(struct pipe_screen *pscreen, void *priv)
 
    if (!screen->cur_ctx)
       screen->cur_ctx = nv50;
-   screen->base.channel->user_private = nv50;
    screen->base.channel->flush_notify = nv50_default_flush_notify;
 
    nv50_init_query_functions(nv50);
@@ -152,6 +149,8 @@ nv50_create(struct pipe_screen *pscreen, void *priv)
    assert(nv50->draw);
    draw_set_rasterize_stage(nv50->draw, nv50_draw_render_stage(nv50));
 
+   nouveau_context_init_vdec(&nv50->base);
+
    return pipe;
 }
 
@@ -168,6 +167,7 @@ nv50_bufctx_add_resident(struct nv50_context *nv50, int ctx,
 
    if (!resource->bo)
       return;
+   nv50->residents_size += sizeof(struct resident);
 
    /* We don't need to reference the resource here, it will be referenced
     * in the context/state, and bufctx will be reset when state changes.
@@ -189,6 +189,7 @@ nv50_bufctx_del_resident(struct nv50_context *nv50, int ctx,
          top = util_dynarray_pop_ptr(&nv50->residents[ctx], struct resident);
          if (rsd != top)
             *rsd = *top;
+         nv50->residents_size -= sizeof(struct resident);
          break;
       }
    }
@@ -201,11 +202,15 @@ nv50_bufctx_emit_relocs(struct nv50_context *nv50)
    struct util_dynarray *array;
    unsigned ctx, i, n;
 
+   n  = nv50->residents_size / sizeof(struct resident);
+   n += NV50_SCREEN_RESIDENT_BO_COUNT;
+
+   MARK_RING(nv50->screen->base.channel, n, n);
+
    for (ctx = 0; ctx < NV50_BUFCTX_COUNT; ++ctx) {
       array = &nv50->residents[ctx];
 
       n = array->size / sizeof(struct resident);
-      MARK_RING(nv50->screen->base.channel, n, n);
       for (i = 0; i < n; ++i) {
          rsd = util_dynarray_element(array, struct resident, i);
 
index 3f03199..284db69 100644 (file)
@@ -18,6 +18,7 @@
 #include "nv50_screen.h"
 #include "nv50_program.h"
 #include "nv50_resource.h"
+#include "nv50_transfer.h"
 
 #include "nouveau/nouveau_context.h"
 #include "nouveau/nv_object.xml.h"
@@ -64,6 +65,7 @@ struct nv50_context {
    struct nv50_screen *screen;
 
    struct util_dynarray residents[NV50_BUFCTX_COUNT];
+   unsigned residents_size;
 
    uint32_t dirty;
 
@@ -129,20 +131,6 @@ nv50_context(struct pipe_context *pipe)
    return (struct nv50_context *)pipe;
 }
 
-struct nv50_surface {
-   struct pipe_surface base;
-   uint32_t offset;
-   uint32_t width;
-   uint16_t height;
-   uint16_t depth;
-};
-
-static INLINE struct nv50_surface *
-nv50_surface(struct pipe_surface *ps)
-{
-   return (struct nv50_surface *)ps;
-}
-
 /* nv50_context.c */
 struct pipe_context *nv50_create(struct pipe_screen *, void *);
 
@@ -156,6 +144,7 @@ void nv50_bufctx_del_resident(struct nv50_context *, int ctx,
 static INLINE void
 nv50_bufctx_reset(struct nv50_context *nv50, int ctx)
 {
+   nv50->residents_size -= nv50->residents[ctx].size;
    util_dynarray_resize(&nv50->residents[ctx], 0);
 }
 
@@ -182,7 +171,8 @@ void nv50_validate_derived_rs(struct nv50_context *);
 extern void nv50_init_state_functions(struct nv50_context *);
 
 /* nv50_state_validate.c */
-extern boolean nv50_state_validate(struct nv50_context *);
+/* @words: check for space before emitting relocs */
+extern boolean nv50_state_validate(struct nv50_context *, unsigned words);
 
 /* nv50_surface.c */
 extern void nv50_clear(struct pipe_context *, unsigned buffers,
@@ -200,6 +190,11 @@ nv50_create_sampler_view(struct pipe_context *,
 
 /* nv50_transfer.c */
 void
+nv50_m2mf_transfer_rect(struct pipe_screen *pscreen,
+                        const struct nv50_m2mf_rect *dst,
+                        const struct nv50_m2mf_rect *src,
+                        uint32_t nblocksx, uint32_t nblocksy);
+void
 nv50_sifc_linear_u8(struct nouveau_context *pipe,
                     struct nouveau_bo *dst, unsigned offset, unsigned domain,
                     unsigned size, void *data);
index 1bf2f80..27046e9 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef NV50_DEFS_XML
-#define NV50_DEFS_XML
+#ifndef RNNDB_NV50_DEFS_XML
+#define RNNDB_NV50_DEFS_XML
 
 /* Autogenerated file, DO NOT EDIT manually!
 
@@ -8,10 +8,11 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- nv50_defs.xml (   4482 bytes, from 2010-10-03 13:18:37)
-- copyright.xml (   6498 bytes, from 2010-10-03 13:18:37)
+- rnndb/nv50_defs.xml    (   5468 bytes, from 2011-07-09 13:43:58)
+- ./rnndb/copyright.xml  (   6452 bytes, from 2011-07-09 13:43:58)
+- ./rnndb/nvchipsets.xml (   3617 bytes, from 2011-07-09 13:43:58)
 
-Copyright (C) 2006-2010 by the following authors:
+Copyright (C) 2006-2011 by the following authors:
 - Artur Huillet <arthur.huillet@free.fr> (ahuillet)
 - Ben Skeggs (darktama, darktama_)
 - B. R. <koala_br@users.sourceforge.net> (koala_br)
@@ -22,7 +23,7 @@ Copyright (C) 2006-2010 by the following authors:
 - Dmitry Eremin-Solenikov <lumag@users.sf.net> (lumag)
 - EdB <edb_@users.sf.net> (edb_)
 - Erik Waling <erikwailing@users.sf.net> (erikwaling)
-- Francisco Jerez <currojerez@riseup.net> (curro, curro_, currojerez)
+- Francisco Jerez <currojerez@riseup.net> (curro)
 - imirkin <imirkin@users.sf.net> (imirkin)
 - jb17bsome <jb17bsome@bellsouth.net> (jb17bsome)
 - Jeremy Kolb <kjeremy@users.sf.net> (kjeremy)
@@ -70,44 +71,50 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
 
 
-#define NV50_SURFACE_FORMAT_R32G32B32A32_FLOAT                 0x000000c0
-#define NV50_SURFACE_FORMAT_R32G32B32A32_SINT                  0x000000c1
-#define NV50_SURFACE_FORMAT_R32G32B32A32_UINT                  0x000000c2
-#define NV50_SURFACE_FORMAT_R32G32B32X32_FLOAT                 0x000000c3
-#define NV50_SURFACE_FORMAT_R16G16B16A16_UNORM                 0x000000c6
-#define NV50_SURFACE_FORMAT_R16G16B16A16_SNORM                 0x000000c7
-#define NV50_SURFACE_FORMAT_R16G16B16A16_SINT                  0x000000c8
-#define NV50_SURFACE_FORMAT_R16G16B16A16_UINT                  0x000000c9
-#define NV50_SURFACE_FORMAT_R16G16B16A16_FLOAT                 0x000000ca
-#define NV50_SURFACE_FORMAT_R32G32_FLOAT                       0x000000cb
-#define NV50_SURFACE_FORMAT_R32G32_SINT                                0x000000cc
-#define NV50_SURFACE_FORMAT_R32G32_UINT                                0x000000cd
-#define NV50_SURFACE_FORMAT_R16G16B16X16_FLOAT                 0x000000ce
-#define NV50_SURFACE_FORMAT_A8R8G8B8_UNORM                     0x000000cf
-#define NV50_SURFACE_FORMAT_A8R8G8B8_SRGB                      0x000000d0
-#define NV50_SURFACE_FORMAT_A2B10G10R10_UNORM                  0x000000d1
-#define NV50_SURFACE_FORMAT_A2B10G10R10_UINT                   0x000000d2
-#define NV50_SURFACE_FORMAT_A8B8G8R8_UNORM                     0x000000d5
-#define NV50_SURFACE_FORMAT_A8B8G8R8_SRGB                      0x000000d6
-#define NV50_SURFACE_FORMAT_A8B8G8R8_SNORM                     0x000000d7
-#define NV50_SURFACE_FORMAT_A8B8G8R8_SINT                      0x000000d8
-#define NV50_SURFACE_FORMAT_A8B8G8R8_UINT                      0x000000d9
-#define NV50_SURFACE_FORMAT_R16G16_UNORM                       0x000000da
-#define NV50_SURFACE_FORMAT_R16G16_SNORM                       0x000000db
-#define NV50_SURFACE_FORMAT_R16G16_SINT                                0x000000dc
-#define NV50_SURFACE_FORMAT_R16G16_UINT                                0x000000dd
-#define NV50_SURFACE_FORMAT_R16G16_FLOAT                       0x000000de
-#define NV50_SURFACE_FORMAT_A2R10G10B10_UNORM                  0x000000df
-#define NV50_SURFACE_FORMAT_B10G11R11_FLOAT                    0x000000e0
+#define NV50_SURFACE_FORMAT_BITMAP                             0x0000001c
+#define NV50_SURFACE_FORMAT_UNK1D                              0x0000001d
+#define NV50_SURFACE_FORMAT_RGBA32_FLOAT                       0x000000c0
+#define NV50_SURFACE_FORMAT_RGBA32_SINT                                0x000000c1
+#define NV50_SURFACE_FORMAT_RGBA32_UINT                                0x000000c2
+#define NV50_SURFACE_FORMAT_RGBX32_FLOAT                       0x000000c3
+#define NV50_SURFACE_FORMAT_RGBX32_SINT                                0x000000c4
+#define NV50_SURFACE_FORMAT_RGBX32_UINT                                0x000000c5
+#define NV50_SURFACE_FORMAT_RGBA16_UNORM                       0x000000c6
+#define NV50_SURFACE_FORMAT_RGBA16_SNORM                       0x000000c7
+#define NV50_SURFACE_FORMAT_RGBA16_SINT                                0x000000c8
+#define NV50_SURFACE_FORMAT_RGBA16_UINT                                0x000000c9
+#define NV50_SURFACE_FORMAT_RGBA16_FLOAT                       0x000000ca
+#define NV50_SURFACE_FORMAT_RG32_FLOAT                         0x000000cb
+#define NV50_SURFACE_FORMAT_RG32_SINT                          0x000000cc
+#define NV50_SURFACE_FORMAT_RG32_UINT                          0x000000cd
+#define NV50_SURFACE_FORMAT_RGBX16_FLOAT                       0x000000ce
+#define NV50_SURFACE_FORMAT_BGRA8_UNORM                                0x000000cf
+#define NV50_SURFACE_FORMAT_BGRA8_SRGB                         0x000000d0
+#define NV50_SURFACE_FORMAT_RGB10_A2_UNORM                     0x000000d1
+#define NV50_SURFACE_FORMAT_RGB10_A2_UINT                      0x000000d2
+#define NV50_SURFACE_FORMAT_RGBA8_UNORM                                0x000000d5
+#define NV50_SURFACE_FORMAT_RGBA8_SRGB                         0x000000d6
+#define NV50_SURFACE_FORMAT_RGBA8_SNORM                                0x000000d7
+#define NV50_SURFACE_FORMAT_RGBA8_SINT                         0x000000d8
+#define NV50_SURFACE_FORMAT_RGBA8_UINT                         0x000000d9
+#define NV50_SURFACE_FORMAT_RG16_UNORM                         0x000000da
+#define NV50_SURFACE_FORMAT_RG16_SNORM                         0x000000db
+#define NV50_SURFACE_FORMAT_RG16_SINT                          0x000000dc
+#define NV50_SURFACE_FORMAT_RG16_UINT                          0x000000dd
+#define NV50_SURFACE_FORMAT_RG16_FLOAT                         0x000000de
+#define NV50_SURFACE_FORMAT_BGR10_A2_UNORM                     0x000000df
+#define NV50_SURFACE_FORMAT_R11G11B10_FLOAT                    0x000000e0
+#define NV50_SURFACE_FORMAT_R32_SINT                           0x000000e3
+#define NV50_SURFACE_FORMAT_R32_UINT                           0x000000e4
 #define NV50_SURFACE_FORMAT_R32_FLOAT                          0x000000e5
-#define NV50_SURFACE_FORMAT_X8R8G8B8_UNORM                     0x000000e6
-#define NV50_SURFACE_FORMAT_X8R8G8B8_SRGB                      0x000000e7
-#define NV50_SURFACE_FORMAT_R5G6B5_UNORM                       0x000000e8
-#define NV50_SURFACE_FORMAT_A1R5G5B5_UNORM                     0x000000e9
-#define NV50_SURFACE_FORMAT_R8G8_UNORM                         0x000000ea
-#define NV50_SURFACE_FORMAT_R8G8_SNORM                         0x000000eb
-#define NV50_SURFACE_FORMAT_R8G8_SINT                          0x000000ec
-#define NV50_SURFACE_FORMAT_R8G8_UINT                          0x000000ed
+#define NV50_SURFACE_FORMAT_BGRX8_UNORM                                0x000000e6
+#define NV50_SURFACE_FORMAT_BGRX8_SRGB                         0x000000e7
+#define NV50_SURFACE_FORMAT_B5G6R5_UNORM                       0x000000e8
+#define NV50_SURFACE_FORMAT_BGR5_A1_UNORM                      0x000000e9
+#define NV50_SURFACE_FORMAT_RG8_UNORM                          0x000000ea
+#define NV50_SURFACE_FORMAT_RG8_SNORM                          0x000000eb
+#define NV50_SURFACE_FORMAT_RG8_SINT                           0x000000ec
+#define NV50_SURFACE_FORMAT_RG8_UINT                           0x000000ed
 #define NV50_SURFACE_FORMAT_R16_UNORM                          0x000000ee
 #define NV50_SURFACE_FORMAT_R16_SNORM                          0x000000ef
 #define NV50_SURFACE_FORMAT_R16_SINT                           0x000000f0
@@ -118,19 +125,24 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NV50_SURFACE_FORMAT_R8_SINT                            0x000000f5
 #define NV50_SURFACE_FORMAT_R8_UINT                            0x000000f6
 #define NV50_SURFACE_FORMAT_A8_UNORM                           0x000000f7
-#define NV50_SURFACE_FORMAT_X1R5G5B5_UNORM                     0x000000f8
-#define NV50_SURFACE_FORMAT_X8B8G8R8_UNORM                     0x000000f9
-#define NV50_SURFACE_FORMAT_X8B8G8R8_SRGB                      0x000000fa
+#define NV50_SURFACE_FORMAT_BGR5_X1_UNORM                      0x000000f8
+#define NV50_SURFACE_FORMAT_RGBX8_UNORM                                0x000000f9
+#define NV50_SURFACE_FORMAT_RGBX8_SRGB                         0x000000fa
+#define NV50_SURFACE_FORMAT_BGR5_X1_UNORM_UNKFB                        0x000000fb
+#define NV50_SURFACE_FORMAT_BGR5_X1_UNORM_UNKFC                        0x000000fc
+#define NV50_SURFACE_FORMAT_BGRX8_UNORM_UNKFD                  0x000000fd
+#define NV50_SURFACE_FORMAT_BGRX8_UNORM_UNKFE                  0x000000fe
+#define NV50_SURFACE_FORMAT_Y32_UINT_UNKFF                     0x000000ff
 #define NV50_ZETA_FORMAT_Z32_FLOAT                             0x0000000a
 #define NV50_ZETA_FORMAT_Z16_UNORM                             0x00000013
-#define NV50_ZETA_FORMAT_Z24S8_UNORM                           0x00000014
-#define NV50_ZETA_FORMAT_X8Z24_UNORM                           0x00000015
-#define NV50_ZETA_FORMAT_S8Z24_UNORM                           0x00000016
-#define NV50_ZETA_FORMAT_UNK18                                 0x00000018
-#define NV50_ZETA_FORMAT_Z32_FLOAT_X24S8_UNORM                 0x00000019
-#define NV50_ZETA_FORMAT_UNK1D                                 0x0000001d
-#define NV50_ZETA_FORMAT_UNK1E                                 0x0000001e
-#define NV50_ZETA_FORMAT_UNK1F                                 0x0000001f
+#define NV50_ZETA_FORMAT_S8_Z24_UNORM                          0x00000014
+#define NV50_ZETA_FORMAT_Z24_X8_UNORM                          0x00000015
+#define NV50_ZETA_FORMAT_Z24_S8_UNORM                          0x00000016
+#define NV50_ZETA_FORMAT_Z24_C8_UNORM                          0x00000018
+#define NV50_ZETA_FORMAT_Z32_S8_X24_FLOAT                      0x00000019
+#define NV50_ZETA_FORMAT_Z24_X8_S8_C8_X16_UNORM                        0x0000001d
+#define NV50_ZETA_FORMAT_Z32_X8_C8_X16_FLOAT                   0x0000001e
+#define NV50_ZETA_FORMAT_Z32_S8_C8_X16_FLOAT                   0x0000001f
 #define NV50_QUERY__SIZE                                       0x00000010
 #define NV50_QUERY_COUNTER                                     0x00000000
 
@@ -139,4 +151,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NV50_QUERY_TIME                                                0x00000008
 
 
-#endif /* NV50_DEFS_XML */
+#endif /* RNNDB_NV50_DEFS_XML */
index 96ed9a7..34502d0 100644 (file)
@@ -65,28 +65,32 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 {
    /* COMMON FORMATS */
 
-   [PIPE_FORMAT_B8G8R8A8_UNORM] = { NV50_SURFACE_FORMAT_A8R8G8B8_UNORM,
+   [PIPE_FORMAT_B8G8R8A8_UNORM] = { NV50_SURFACE_FORMAT_BGRA8_UNORM,
     A_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 1),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
-   [PIPE_FORMAT_B8G8R8X8_UNORM] = { NV50_SURFACE_FORMAT_X8R8G8B8_UNORM,
+   [PIPE_FORMAT_B8G8R8X8_UNORM] = { NV50_SURFACE_FORMAT_BGRX8_UNORM,
     A_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 1),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
-   [PIPE_FORMAT_B8G8R8A8_SRGB] = { NV50_SURFACE_FORMAT_A8R8G8B8_SRGB,
+   [PIPE_FORMAT_B8G8R8A8_SRGB] = { NV50_SURFACE_FORMAT_BGRA8_SRGB,
     A_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 1),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_B8G8R8X8_SRGB] = { NV50_SURFACE_FORMAT_X8R8G8B8_SRGB,
+   [PIPE_FORMAT_B8G8R8X8_SRGB] = { NV50_SURFACE_FORMAT_BGRX8_SRGB,
     A_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 1),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_B5G6R5_UNORM] = { NV50_SURFACE_FORMAT_R5G6B5_UNORM,
+   [PIPE_FORMAT_B5G6R5_UNORM] = { NV50_SURFACE_FORMAT_B5G6R5_UNORM,
     B_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 5_6_5, 1),
     SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
-   [PIPE_FORMAT_B5G5R5A1_UNORM] = { NV50_SURFACE_FORMAT_A1R5G5B5_UNORM,
-    B_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 1_5_5_5, 1),
+   [PIPE_FORMAT_B5G5R5A1_UNORM] = { NV50_SURFACE_FORMAT_BGR5_A1_UNORM,
+    B_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 5_5_5_1, 1),
+    SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
+
+   [PIPE_FORMAT_B5G5R5X1_UNORM] = { NV50_SURFACE_FORMAT_BGR5_X1_UNORM,
+    B_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 5_5_5_1, 1),
     SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
    [PIPE_FORMAT_B4G4R4A4_UNORM] = { 0,
@@ -97,12 +101,12 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
     B_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 4_4_4_4, 1),
     SAMPLER_VIEW },
 
-   [PIPE_FORMAT_R10G10B10A2_UNORM] = { NV50_SURFACE_FORMAT_A2B10G10R10_UNORM,
-    A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 2_10_10_10, 0),
+   [PIPE_FORMAT_R10G10B10A2_UNORM] = { NV50_SURFACE_FORMAT_RGB10_A2_UNORM,
+    A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 10_10_10_2, 0),
     SAMPLER_VIEW | RENDER_TARGET | VERTEX_BUFFER | SCANOUT },
 
-   [PIPE_FORMAT_B10G10R10A2_UNORM] = { NV50_SURFACE_FORMAT_A2R10G10B10_UNORM,
-    A_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 2_10_10_10, 1),
+   [PIPE_FORMAT_B10G10R10A2_UNORM] = { NV50_SURFACE_FORMAT_BGR10_A2_UNORM,
+    A_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 10_10_10_2, 1),
     SAMPLER_VIEW | RENDER_TARGET | VERTEX_BUFFER },
 
    /* DEPTH/STENCIL FORMATS */
@@ -111,25 +115,24 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
     B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, Z16, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
-   [PIPE_FORMAT_Z24_UNORM_S8_USCALED] = { NV50_ZETA_FORMAT_S8Z24_UNORM,
-    B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, S8Z24, 0),
+   [PIPE_FORMAT_Z24_UNORM_S8_USCALED] = { NV50_ZETA_FORMAT_Z24_S8_UNORM,
+    B_(C0, C1, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, Z24_S8, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
-   [PIPE_FORMAT_Z24X8_UNORM] = { NV50_ZETA_FORMAT_X8Z24_UNORM,
-    B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, X8Z24, 0),
+   [PIPE_FORMAT_Z24X8_UNORM] = { NV50_ZETA_FORMAT_Z24_X8_UNORM,
+    B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, Z24_X8, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
-   [PIPE_FORMAT_S8_USCALED_Z24_UNORM] = { NV50_ZETA_FORMAT_Z24S8_UNORM,
-    B_(C1, C1, C1, ONE_FLOAT, UINT, UNORM, UINT, UINT, Z24S8, 0),
+   [PIPE_FORMAT_S8_USCALED_Z24_UNORM] = { NV50_ZETA_FORMAT_S8_Z24_UNORM,
+    B_(C1, C0, C1, ONE_FLOAT, UINT, UNORM, UINT, UINT, S8_Z24, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
    [PIPE_FORMAT_Z32_FLOAT] = { NV50_ZETA_FORMAT_Z32_FLOAT,
     B_(C0, C0, C0, ONE_FLOAT, FLOAT, UINT, UINT, UINT, Z32, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
-   [PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED] = {
-    NV50_ZETA_FORMAT_Z32_FLOAT_X24S8_UNORM,
-    B_(C0, C0, C0, ONE_FLOAT, FLOAT, UINT, UINT, UINT, X24S8Z32, 0),
+   [PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED] = { NV50_ZETA_FORMAT_Z32_S8_X24_FLOAT,
+    B_(C0, C0, C0, ONE_FLOAT, FLOAT, UINT, UINT, UINT, Z32_S8_X24, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
    /* LUMINANCE, ALPHA, INTENSITY */
@@ -278,15 +281,15 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    /* FLOAT 16 */
 
-   [PIPE_FORMAT_R16G16B16A16_FLOAT] = { NV50_SURFACE_FORMAT_R16G16B16A16_FLOAT,
+   [PIPE_FORMAT_R16G16B16A16_FLOAT] = { NV50_SURFACE_FORMAT_RGBA16_FLOAT,
     A_(C0, C1, C2, C3, FLOAT, FLOAT, FLOAT, FLOAT, 16_16_16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R16G16B16_FLOAT] = { NV50_SURFACE_FORMAT_R16G16B16X16_FLOAT,
+   [PIPE_FORMAT_R16G16B16_FLOAT] = { NV50_SURFACE_FORMAT_RGBX16_FLOAT,
     A_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 16_16_16, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R16G16_FLOAT] = { NV50_SURFACE_FORMAT_R16G16_FLOAT,
+   [PIPE_FORMAT_R16G16_FLOAT] = { NV50_SURFACE_FORMAT_RG16_FLOAT,
     A_(C0, C1, ZERO, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -296,15 +299,15 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    /* FLOAT 32 */
 
-   [PIPE_FORMAT_R32G32B32A32_FLOAT] = { NV50_SURFACE_FORMAT_R32G32B32A32_FLOAT,
+   [PIPE_FORMAT_R32G32B32A32_FLOAT] = { NV50_SURFACE_FORMAT_RGBA32_FLOAT,
     A_(C0, C1, C2, C3, FLOAT, FLOAT, FLOAT, FLOAT, 32_32_32_32, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R32G32B32_FLOAT] = { NV50_SURFACE_FORMAT_R32G32B32X32_FLOAT,
+   [PIPE_FORMAT_R32G32B32_FLOAT] = { NV50_SURFACE_FORMAT_RGBX32_FLOAT,
     A_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 32_32_32, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R32G32_FLOAT] = { NV50_SURFACE_FORMAT_R32G32_FLOAT,
+   [PIPE_FORMAT_R32G32_FLOAT] = { NV50_SURFACE_FORMAT_RG32_FLOAT,
     A_(C0, C1, ZERO, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 32_32, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -314,12 +317,12 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    /* ODD FORMATS */
 
-   [PIPE_FORMAT_R11G11B10_FLOAT] = { NV50_SURFACE_FORMAT_B10G11R11_FLOAT,
-    B_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 10_11_11, 0),
+   [PIPE_FORMAT_R11G11B10_FLOAT] = { NV50_SURFACE_FORMAT_R11G11B10_FLOAT,
+    B_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 11_11_10, 0),
     SAMPLER_VIEW | RENDER_TARGET },
 
    [PIPE_FORMAT_R9G9B9E5_FLOAT] = { 0,
-    B_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, E5_9_9_9, 0),
+    B_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 9_9_9_E5, 0),
     SAMPLER_VIEW },
 
    /* SNORM 32 */
@@ -330,7 +333,7 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    [PIPE_FORMAT_R32G32B32_SNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 32_32_32, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
    [PIPE_FORMAT_R32G32_SNORM] = { 0,
     A_(C0, C1, ZERO, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 32_32, 0),
@@ -348,7 +351,7 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    [PIPE_FORMAT_R32G32B32_UNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 32_32_32, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
    [PIPE_FORMAT_R32G32_UNORM] = { 0,
     A_(C0, C1, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 32_32, 0),
@@ -360,15 +363,15 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    /* SNORM 16 */
 
-   [PIPE_FORMAT_R16G16B16A16_SNORM] = { NV50_SURFACE_FORMAT_R16G16B16A16_SNORM,
+   [PIPE_FORMAT_R16G16B16A16_SNORM] = { NV50_SURFACE_FORMAT_RGBA16_SNORM,
     A_(C0, C1, C2, C3, SNORM, SNORM, SNORM, SNORM, 16_16_16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
    [PIPE_FORMAT_R16G16B16_SNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 16_16_16, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R16G16_SNORM] = { NV50_SURFACE_FORMAT_R16G16_SNORM,
+   [PIPE_FORMAT_R16G16_SNORM] = { NV50_SURFACE_FORMAT_RG16_SNORM,
     A_(C0, C1, ZERO, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -378,15 +381,15 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    /* UNORM 16 */
 
-   [PIPE_FORMAT_R16G16B16A16_UNORM] = { NV50_SURFACE_FORMAT_R16G16B16A16_UNORM,
+   [PIPE_FORMAT_R16G16B16A16_UNORM] = { NV50_SURFACE_FORMAT_RGBA16_UNORM,
     A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 16_16_16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
    [PIPE_FORMAT_R16G16B16_UNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 16_16_16, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R16G16_UNORM] = { NV50_SURFACE_FORMAT_R16G16_UNORM,
+   [PIPE_FORMAT_R16G16_UNORM] = { NV50_SURFACE_FORMAT_RG16_UNORM,
     A_(C0, C1, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -396,15 +399,15 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    /* SNORM 8 */
 
-   [PIPE_FORMAT_R8G8B8A8_SNORM] = { NV50_SURFACE_FORMAT_A8B8G8R8_SNORM,
+   [PIPE_FORMAT_R8G8B8A8_SNORM] = { NV50_SURFACE_FORMAT_RGBA8_SNORM,
     A_(C0, C1, C2, C3, SNORM, SNORM, SNORM, SNORM, 8_8_8_8, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
    [PIPE_FORMAT_R8G8B8_SNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 8_8_8, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R8G8_SNORM] = { NV50_SURFACE_FORMAT_R8G8_SNORM,
+   [PIPE_FORMAT_R8G8_SNORM] = { NV50_SURFACE_FORMAT_RG8_SNORM,
     A_(C0, C1, ZERO, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 8_8, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -414,23 +417,23 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
 
    /* UNORM 8 */
 
-   [PIPE_FORMAT_R8G8B8A8_UNORM] = { NV50_SURFACE_FORMAT_A8B8G8R8_UNORM,
+   [PIPE_FORMAT_R8G8B8A8_UNORM] = { NV50_SURFACE_FORMAT_RGBA8_UNORM,
     A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R8G8B8A8_SRGB] = { NV50_SURFACE_FORMAT_A8B8G8R8_SRGB,
-    A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 0),
+   [PIPE_FORMAT_R8G8B8A8_SRGB] = { NV50_SURFACE_FORMAT_RGBA8_SRGB,
+    B_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 0),
     SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R8G8B8_UNORM] = { NV50_SURFACE_FORMAT_X8B8G8R8_UNORM,
-    A_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
+   [PIPE_FORMAT_R8G8B8X8_UNORM] = { NV50_SURFACE_FORMAT_RGBX8_UNORM,
+    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 0),
+    SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R8G8B8_SRGB] = { NV50_SURFACE_FORMAT_X8B8G8R8_SRGB,
+   [PIPE_FORMAT_R8G8B8_UNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8, 0),
-    SAMPLER_VIEW | RENDER_TARGET },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R8G8_UNORM] = { NV50_SURFACE_FORMAT_R8G8_UNORM,
+   [PIPE_FORMAT_R8G8_UNORM] = { NV50_SURFACE_FORMAT_RG8_UNORM,
     A_(C0, C1, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -549,11 +552,11 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
    /* OTHER FORMATS */
 
    [PIPE_FORMAT_R8G8_B8G8_UNORM] = { 0,
-    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, C1_C2_C1_C0, 0),
+    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, U8_YA8_V8_YB8, 0),
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_G8R8_G8B8_UNORM] = { 0,
-    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, C2_C1_C0_C1, 0),
+    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, YA8_U8_YB8_V8, 0),
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_R8SG8SB8UX8U_NORM] = { 0,
@@ -561,11 +564,11 @@ const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_R5SG5SB6U_NORM] = { 0,
-    B_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, UNORM, UNORM, 6_5_5, 0),
+    B_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, UNORM, UNORM, 5_5_6, 0),
     SAMPLER_VIEW },
 
-   [PIPE_FORMAT_R1_UNORM] = { 0,
-    B_(C0, ZERO, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, BITMAP_8X8, 0),
+   [PIPE_FORMAT_R1_UNORM] = { NV50_SURFACE_FORMAT_BITMAP,
+    B_(C0, ZERO, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, BITMAP, 0),
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_A8B8G8R8_UNORM] = { 0,
index 486b368..bc81604 100644 (file)
 
 #include "nv50_context.h"
 #include "nv50_resource.h"
-#include "nv50_transfer.h"
 
 static INLINE uint32_t
-get_tile_dims(unsigned nx, unsigned ny, unsigned nz)
+nv50_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz)
 {
-   uint32_t tile_mode = 0x00;
-
-   if (ny > 32) tile_mode = 0x04; /* height 128 tiles */
-   else
-   if (ny > 16) tile_mode = 0x03; /* height 64 tiles */
-   else
-   if (ny >  8) tile_mode = 0x02; /* height 32 tiles */
-   else
-   if (ny >  4) tile_mode = 0x01; /* height 16 tiles */
-
-   if (nz == 1)
-      return tile_mode;
-   else
-   if (tile_mode > 0x02)
-      tile_mode = 0x02;
-
-   if (nz > 16 && tile_mode < 0x02)
-      return tile_mode | 0x50; /* depth 32 tiles */
-   if (nz > 8) return tile_mode | 0x40; /* depth 16 tiles */
-   if (nz > 4) return tile_mode | 0x30; /* depth 8 tiles */
-   if (nz > 2) return tile_mode | 0x20; /* depth 4 tiles */
-
-   return tile_mode | 0x10;
+   return nvc0_tex_choose_tile_dims(nx, ny * 2, nz) >> 4;
 }
 
-static INLINE unsigned
-calc_zslice_offset(uint32_t tile_mode, unsigned z, unsigned pitch, unsigned nbh)
+static uint32_t
+nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed)
 {
-   unsigned tile_h = NV50_TILE_HEIGHT(tile_mode);
-   unsigned tile_d_shift = NV50_TILE_DIM_SHIFT(tile_mode, 1);
-   unsigned tile_d = 1 << tile_d_shift;
+   const unsigned ms = util_logbase2(mt->base.base.nr_samples);
 
-   /* stride_2d == to next slice within this volume tile */
-   /* stride_3d == size (in bytes) of a volume tile */
-   unsigned stride_2d = tile_h * NV50_TILE_PITCH(tile_mode);
-   unsigned stride_3d = tile_d * align(nbh, tile_h) * pitch;
+   uint32_t tile_flags;
+
+   if (mt->base.base.bind & PIPE_BIND_CURSOR)
+      return NOUVEAU_BO_TILE_SCANOUT;
+
+   switch (mt->base.base.format) {
+   case PIPE_FORMAT_Z16_UNORM:
+      tile_flags = 0x6c00 + (ms << 8);
+      break;
+   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+      tile_flags = 0x1800 + (ms << 8);
+      break;
+   case PIPE_FORMAT_Z24X8_UNORM:
+   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+      tile_flags = 0x22800 + (ms << 8);
+      break;
+   case PIPE_FORMAT_Z32_FLOAT:
+      tile_flags = 0x4000 + (ms << 8);
+      break;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      tile_flags = 0x6000 + (ms << 8);
+      break;
+   default:
+      switch (util_format_get_blocksizebits(mt->base.base.format)) {
+      case 128:
+         assert(ms < 3);
+         tile_flags = 0x7400;
+         break;
+      case 64:
+         switch (ms) {
+         case 2: tile_flags = 0x17c00; break;
+         case 3: tile_flags = 0x17d00; break;
+         default:
+            tile_flags = 0x7000;
+            break;
+         }
+         break;
+      case 32:
+         if (mt->base.base.bind & PIPE_BIND_SCANOUT) {
+            assert(ms == 0);
+            tile_flags = 0x7a00;
+         } else {
+            switch (ms) {
+            case 2: tile_flags = 0x17800; break;
+            case 3: tile_flags = 0x17900; break;
+            default:
+               tile_flags = 0x7000;
+               break;
+            }
+         }
+         break;
+      case 16:
+      case 8:
+         tile_flags = 0x7000;
+         break;
+      default:
+         return 0;
+      }
+      if (mt->base.base.bind & PIPE_BIND_CURSOR)
+         tile_flags = 0;
+   }
+
+   if (mt->base.base.bind & (PIPE_BIND_SCANOUT | PIPE_BIND_CURSOR))
+      tile_flags |= NOUVEAU_BO_TILE_SCANOUT;
+
+   if (!compressed)
+      tile_flags &= ~0x30000;
 
-   return (z & (tile_d - 1)) * stride_2d + (z >> tile_d_shift) * stride_3d;
+   return tile_flags;
 }
 
-static void
+void
 nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt)
 {
    struct nv50_miptree *mt = nv50_miptree(pt);
@@ -82,7 +120,7 @@ nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt)
    FREE(mt);
 }
 
-static boolean
+boolean
 nv50_miptree_get_handle(struct pipe_screen *pscreen,
                         struct pipe_resource *pt,
                         struct winsys_handle *whandle)
@@ -108,88 +146,95 @@ const struct u_resource_vtbl nv50_miptree_vtbl =
    nv50_miptree_destroy,            /* resource_destroy */
    nv50_miptree_transfer_new,       /* get_transfer */
    nv50_miptree_transfer_del,       /* transfer_destroy */
-   nv50_miptree_transfer_map,        /* transfer_map */
+   nv50_miptree_transfer_map,       /* transfer_map */
    u_default_transfer_flush_region, /* transfer_flush_region */
    nv50_miptree_transfer_unmap,     /* transfer_unmap */
    u_default_transfer_inline_write  /* transfer_inline_write */
 };
 
-struct pipe_resource *
-nv50_miptree_create(struct pipe_screen *pscreen,
-                    const struct pipe_resource *templ)
+static INLINE boolean
+nv50_miptree_init_ms_mode(struct nv50_miptree *mt)
 {
-   struct nouveau_device *dev = nouveau_screen(pscreen)->device;
-   struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
-   struct pipe_resource *pt = &mt->base.base;
-   int ret;
-   unsigned w, h, d, l, alloc_size;
-   uint32_t tile_flags;
-
-   if (!mt)
-      return NULL;
-
-   mt->base.vtbl = &nv50_miptree_vtbl;
-   *pt = *templ;
-   pipe_reference_init(&pt->reference, 1);
-   pt->screen = pscreen;
-
-   mt->layout_3d = pt->target == PIPE_TEXTURE_3D;
-
-   w = pt->width0;
-   h = pt->height0;
-   d = mt->layout_3d ? pt->depth0 : 1;
-
-   switch (pt->format) {
-   case PIPE_FORMAT_Z16_UNORM:
-      tile_flags = 0x6c00;
+   switch (mt->base.base.nr_samples) {
+   case 8:
+      mt->ms_mode = NV50_3D_MULTISAMPLE_MODE_MS8;
+      mt->ms_x = 2;
+      mt->ms_y = 1;
       break;
-   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-      tile_flags = 0x1800;
-      break;
-   case PIPE_FORMAT_Z24X8_UNORM:
-   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-      tile_flags = 0x2800;
+   case 4:
+      mt->ms_mode = NV50_3D_MULTISAMPLE_MODE_MS4;
+      mt->ms_x = 1;
+      mt->ms_y = 1;
       break;
-   case PIPE_FORMAT_R32G32B32A32_FLOAT:
-   case PIPE_FORMAT_R32G32B32_FLOAT:
-      tile_flags = 0x7400;
+   case 2:
+      mt->ms_mode = NV50_3D_MULTISAMPLE_MODE_MS2;
+      mt->ms_x = 1;
       break;
-   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
-      tile_flags = 0x6000;
+   case 1:
+   case 0:
+      mt->ms_mode = NV50_3D_MULTISAMPLE_MODE_MS1;
       break;
    default:
-      if (pt->bind & PIPE_BIND_CURSOR)
-         tile_flags = 0;
-      else
-      if ((pt->bind & PIPE_BIND_SCANOUT) &&
-          util_format_get_blocksizebits(pt->format) == 32)
-         tile_flags = 0x7a00;
-      else
-         tile_flags = 0x7000;
-      break;
+      NOUVEAU_ERR("invalid nr_samples: %u\n", mt->base.base.nr_samples);
+      return FALSE;
    }
-   if (pt->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_CURSOR))
-      tile_flags |= NOUVEAU_BO_TILE_SCANOUT;
+   return TRUE;
+}
+
+boolean
+nv50_miptree_init_layout_linear(struct nv50_miptree *mt)
+{
+   struct pipe_resource *pt = &mt->base.base;
+
+   if (util_format_is_depth_or_stencil(pt->format))
+      return FALSE;
+
+   if ((pt->last_level > 0) || (pt->depth0 > 1) || (pt->array_size > 1))
+      return FALSE;
+   if (mt->ms_x | mt->ms_y)
+      return FALSE;
+
+   mt->level[0].pitch = align(pt->width0, 64);
+
+   mt->total_size = mt->level[0].pitch * pt->height0;
+
+   return TRUE;
+}
+
+static void
+nv50_miptree_init_layout_tiled(struct nv50_miptree *mt)
+{
+   struct pipe_resource *pt = &mt->base.base;
+   unsigned w, h, d, l;
+   const unsigned blocksize = util_format_get_blocksize(pt->format);
+
+   mt->layout_3d = pt->target == PIPE_TEXTURE_3D;
+
+   w = pt->width0 << mt->ms_x;
+   h = pt->height0 << mt->ms_y;
 
    /* For 3D textures, a mipmap is spanned by all the layers, for array
     * textures and cube maps, each layer contains its own mipmaps.
     */
+   d = mt->layout_3d ? pt->depth0 : 1;
+
    for (l = 0; l <= pt->last_level; ++l) {
       struct nv50_miptree_level *lvl = &mt->level[l];
+      unsigned tsx, tsy, tsz;
       unsigned nbx = util_format_get_nblocksx(pt->format, w);
       unsigned nby = util_format_get_nblocksy(pt->format, h);
-      unsigned blocksize = util_format_get_blocksize(pt->format);
 
       lvl->offset = mt->total_size;
 
-      if (tile_flags & NOUVEAU_BO_TILE_LAYOUT_MASK)
-         lvl->tile_mode = get_tile_dims(nbx, nby, d);
+      lvl->tile_mode = nv50_tex_choose_tile_dims(nbx, nby, d);
 
-      lvl->pitch = align(nbx * blocksize, NV50_TILE_PITCH(lvl->tile_mode));
+      tsx = NV50_TILE_SIZE_X(lvl->tile_mode); /* x is tile row pitch in bytes */
+      tsy = NV50_TILE_SIZE_Y(lvl->tile_mode);
+      tsz = NV50_TILE_SIZE_Z(lvl->tile_mode);
 
-      mt->total_size += lvl->pitch *
-         align(nby, NV50_TILE_HEIGHT(lvl->tile_mode)) *
-         align(d, NV50_TILE_DEPTH(lvl->tile_mode));
+      lvl->pitch = align(nbx * blocksize, tsx);
+
+      mt->total_size += lvl->pitch * align(nby, tsy) * align(d, tsz);
 
       w = u_minify(w, 1);
       h = u_minify(h, 1);
@@ -201,10 +246,43 @@ nv50_miptree_create(struct pipe_screen *pscreen,
                                NV50_TILE_SIZE(mt->level[0].tile_mode));
       mt->total_size = mt->layer_stride * pt->array_size;
    }
+}
+
+struct pipe_resource *
+nv50_miptree_create(struct pipe_screen *pscreen,
+                    const struct pipe_resource *templ)
+{
+   struct nouveau_device *dev = nouveau_screen(pscreen)->device;
+   struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
+   struct pipe_resource *pt = &mt->base.base;
+   int ret;
+   uint32_t tile_flags;
+
+   if (!mt)
+      return NULL;
+
+   mt->base.vtbl = &nv50_miptree_vtbl;
+   *pt = *templ;
+   pipe_reference_init(&pt->reference, 1);
+   pt->screen = pscreen;
 
-   alloc_size = mt->total_size;
+   tile_flags = nv50_mt_choose_storage_type(mt, TRUE);
 
-   ret = nouveau_bo_new_tile(dev, NOUVEAU_BO_VRAM, 256, alloc_size,
+   if (!nv50_miptree_init_ms_mode(mt)) {
+      FREE(mt);
+      return NULL;
+   }
+
+   if (tile_flags & NOUVEAU_BO_TILE_LAYOUT_MASK) {
+      nv50_miptree_init_layout_tiled(mt);
+   } else
+   if (!nv50_miptree_init_layout_linear(mt)) {
+      FREE(mt);
+      return NULL;
+   }
+
+   ret = nouveau_bo_new_tile(dev, NOUVEAU_BO_VRAM, 4096,
+                             mt->total_size,
                              mt->level[0].tile_mode, tile_flags,
                              &mt->base.bo);
    if (ret) {
@@ -255,58 +333,92 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen,
 }
 
 
+/* Offset of zslice @z from start of level @l. */
+INLINE unsigned
+nv50_mt_zslice_offset(const struct nv50_miptree *mt, unsigned l, unsigned z)
+{
+   const struct pipe_resource *pt = &mt->base.base;
+
+   unsigned tds = NV50_TILE_SHIFT_Z(mt->level[l].tile_mode);
+   unsigned ths = NV50_TILE_SHIFT_Y(mt->level[l].tile_mode);
+
+   unsigned nby = util_format_get_nblocksy(pt->format,
+                                           u_minify(pt->height0, l));
+
+   /* to next 2D tile slice within a 3D tile */
+   unsigned stride_2d = NV50_TILE_SIZE_2D(mt->level[l].tile_mode);
+
+   /* to slice in the next (in z direction) 3D tile */
+   unsigned stride_3d = (align(nby, (1 << ths)) * mt->level[l].pitch) << tds;
+
+   return (z & ((1 << tds) - 1)) * stride_2d + (z >> tds) * stride_3d;
+}
+
 /* Surface functions.
  */
 
-struct pipe_surface *
-nv50_miptree_surface_new(struct pipe_context *pipe,
-                         struct pipe_resource *pt,
-                         const struct pipe_surface *templ)
+struct nv50_surface *
+nv50_surface_from_miptree(struct nv50_miptree *mt,
+                          const struct pipe_surface *templ)
 {
-   struct nv50_miptree *mt = nv50_miptree(pt); /* guaranteed */
-   struct nv50_surface *ns;
    struct pipe_surface *ps;
-   struct nv50_miptree_level *lvl = &mt->level[templ->u.tex.level];
-
-   ns = CALLOC_STRUCT(nv50_surface);
+   struct nv50_surface *ns = CALLOC_STRUCT(nv50_surface);
    if (!ns)
       return NULL;
    ps = &ns->base;
 
    pipe_reference_init(&ps->reference, 1);
-   pipe_resource_reference(&ps->texture, pt);
-   ps->context = pipe;
+   pipe_resource_reference(&ps->texture, &mt->base.base);
+
    ps->format = templ->format;
    ps->usage = templ->usage;
    ps->u.tex.level = templ->u.tex.level;
    ps->u.tex.first_layer = templ->u.tex.first_layer;
    ps->u.tex.last_layer = templ->u.tex.last_layer;
 
-   ns->width = u_minify(pt->width0, ps->u.tex.level);
-   ns->height = u_minify(pt->height0, ps->u.tex.level);
+   ns->width = u_minify(mt->base.base.width0, ps->u.tex.level);
+   ns->height = u_minify(mt->base.base.height0, ps->u.tex.level);
    ns->depth = ps->u.tex.last_layer - ps->u.tex.first_layer + 1;
-   ns->offset = lvl->offset;
+   ns->offset = mt->level[templ->u.tex.level].offset;
 
    /* comment says there are going to be removed, but they're used by the st */
    ps->width = ns->width;
    ps->height = ns->height;
 
-   if (mt->layout_3d) {
-      unsigned zslice = ps->u.tex.first_layer;
+   ns->width <<= mt->ms_x;
+   ns->height <<= mt->ms_y;
 
-      /* TODO: re-layout the texture to use only depth 1 tiles in this case: */
-      if (ns->depth > 1 && (zslice & (NV50_TILE_DEPTH(lvl->tile_mode) - 1)))
-         NOUVEAU_ERR("Creating unsupported 3D surface of slices [%u:%u].\n",
-                     zslice, ps->u.tex.last_layer);
+   return ns;
+}
 
-      ns->offset += calc_zslice_offset(lvl->tile_mode, zslice, lvl->pitch,
-                                       util_format_get_nblocksy(pt->format,
-                                                                ns->height));
-   } else {
-      ns->offset += mt->layer_stride * ps->u.tex.first_layer;
+struct pipe_surface *
+nv50_miptree_surface_new(struct pipe_context *pipe,
+                         struct pipe_resource *pt,
+                         const struct pipe_surface *templ)
+{
+   struct nv50_miptree *mt = nv50_miptree(pt);
+   struct nv50_surface *ns = nv50_surface_from_miptree(mt, templ);
+   if (!ns)
+      return NULL;
+   ns->base.context = pipe;
+
+   if (ns->base.u.tex.first_layer) {
+      const unsigned l = ns->base.u.tex.level;
+      const unsigned z = ns->base.u.tex.first_layer;
+
+      if (mt->layout_3d) {
+         ns->offset += nv50_mt_zslice_offset(mt, l, z);
+
+         /* TODO: switch to depth 1 tiles; but actually this shouldn't happen */
+         if (ns->depth > 1 &&
+             (z & (NV50_TILE_SIZE_Z(mt->level[l].tile_mode) - 1)))
+            NOUVEAU_ERR("Creating unsupported 3D surface !\n");
+      } else {
+         ns->offset += mt->layer_stride * z;
+      }
    }
 
-   return ps;
+   return &ns->base;
 }
 
 void
index 0e9f0a2..66d2120 100644 (file)
@@ -9,22 +9,32 @@
 #include "nouveau/nouveau_buffer.h"
 #undef NOUVEAU_NVC0
 
+#ifndef __NVC0_RESOURCE_H__ /* make sure we don't use these in nvc0: */
+
 void
 nv50_init_resource_functions(struct pipe_context *pcontext);
 
 void
 nv50_screen_init_resource_functions(struct pipe_screen *pscreen);
 
-#define NV50_TILE_DIM_SHIFT(m, d) (((m) >> (d * 4)) & 0xf)
 
-#define NV50_TILE_PITCH(m)  (64 << 0)
-#define NV50_TILE_HEIGHT(m) ( 4 << NV50_TILE_DIM_SHIFT(m, 0))
-#define NV50_TILE_DEPTH(m)  ( 1 << NV50_TILE_DIM_SHIFT(m, 1))
+#define NV50_TILE_SHIFT_X(m) 6
+#define NV50_TILE_SHIFT_Y(m) ((((m) >> 0) & 0xf) + 2)
+#define NV50_TILE_SHIFT_Z(m) ((((m) >> 4) & 0xf) + 0)
+
+#define NV50_TILE_SIZE_X(m) 64
+#define NV50_TILE_SIZE_Y(m) ( 4 << (((m) >> 0) & 0xf))
+#define NV50_TILE_SIZE_Z(m) ( 1 << (((m) >> 4) & 0xf))
+
+#define NV50_TILE_SIZE_2D(m) (NV50_TILE_SIZE_X(m) << NV50_TILE_SHIFT_Y(m))
 
-#define NV50_TILE_SIZE_2D(m) ((64 * 4) <<                     \
-                              NV50_TILE_DIM_SHIFT(m, 0))
+#define NV50_TILE_SIZE(m) (NV50_TILE_SIZE_2D(m) << NV50_TILE_SHIFT_Z(m))
+
+#endif /* __NVC0_RESOURCE_H__ */
+
+uint32_t
+nvc0_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz);
 
-#define NV50_TILE_SIZE(m) (NV50_TILE_SIZE_2D(m) << NV50_TILE_DIM_SHIFT(m, 1))
 
 struct nv50_miptree_level {
    uint32_t offset;
@@ -40,6 +50,9 @@ struct nv50_miptree {
    uint32_t total_size;
    uint32_t layer_stride;
    boolean layout_3d; /* TRUE if layer count varies with mip level */
+   uint8_t ms_x;      /* log2 of number of samples in x/y dimension */
+   uint8_t ms_y;
+   uint8_t ms_mode;
 };
 
 static INLINE struct nv50_miptree *
@@ -50,21 +63,73 @@ nv50_miptree(struct pipe_resource *pt)
 
 /* Internal functions:
  */
+boolean
+nv50_miptree_init_layout_linear(struct nv50_miptree *mt);
+
 struct pipe_resource *
 nv50_miptree_create(struct pipe_screen *pscreen,
                     const struct pipe_resource *tmp);
 
+void
+nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt);
+
 struct pipe_resource *
 nv50_miptree_from_handle(struct pipe_screen *pscreen,
                          const struct pipe_resource *template,
                          struct winsys_handle *whandle);
 
+boolean
+nv50_miptree_get_handle(struct pipe_screen *pscreen,
+                        struct pipe_resource *pt,
+                        struct winsys_handle *whandle);
+
+struct nv50_surface {
+   struct pipe_surface base;
+   uint32_t offset;
+   uint32_t width;
+   uint16_t height;
+   uint16_t depth;
+};
+
+static INLINE struct nv50_surface *
+nv50_surface(struct pipe_surface *ps)
+{
+   return (struct nv50_surface *)ps;
+}
+
+#ifndef __NVC0_RESOURCE_H__
+
+unsigned
+nv50_mt_zslice_offset(const struct nv50_miptree *mt, unsigned l, unsigned z);
+
 struct pipe_surface *
 nv50_miptree_surface_new(struct pipe_context *,
                          struct pipe_resource *,
                          const struct pipe_surface *templ);
 
+struct pipe_transfer *
+nv50_miptree_transfer_new(struct pipe_context *pcontext,
+                          struct pipe_resource *pt,
+                          unsigned level,
+                          unsigned usage,
+                          const struct pipe_box *box);
+void
+nv50_miptree_transfer_del(struct pipe_context *pcontext,
+                          struct pipe_transfer *ptx);
+void *
+nv50_miptree_transfer_map(struct pipe_context *pcontext,
+                          struct pipe_transfer *ptx);
+void
+nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
+                            struct pipe_transfer *ptx);
+
+#endif /* __NVC0_RESOURCE_H__ */
+
+struct nv50_surface *
+nv50_surface_from_miptree(struct nv50_miptree *mt,
+                          const struct pipe_surface *templ);
+
 void
 nv50_miptree_surface_del(struct pipe_context *, struct pipe_surface *);
 
-#endif
+#endif /* __NV50_RESOURCE_H__ */
index 7e436fd..581aad1 100644 (file)
@@ -43,7 +43,9 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
                                 unsigned sample_count,
                                 unsigned bindings)
 {
-   if (sample_count > 1)
+   if (sample_count > 2 && sample_count != 4 && sample_count != 8)
+      return FALSE;
+   if (sample_count == 8 && util_format_get_blocksizebits(format) >= 128)
       return FALSE;
 
    if (!util_format_is_supported(format, bindings))
@@ -89,6 +91,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_SHADOW_MAP:
    case PIPE_CAP_NPOT_TEXTURES:
    case PIPE_CAP_ANISOTROPIC_FILTER:
+   case PIPE_CAP_SCALED_RESOLVE:
       return 1;
    case PIPE_CAP_SEAMLESS_CUBE_MAP:
       return nv50_screen(pscreen)->tesla->grclass >= NVA0_3D;
@@ -217,6 +220,7 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
       nouveau_fence_wait(screen->base.fence.current);
       nouveau_fence_ref (NULL, &screen->base.fence.current);
    }
+   screen->base.channel->user_private = NULL;
 
    nouveau_bo_ref(NULL, &screen->code);
    nouveau_bo_ref(NULL, &screen->tls_bo);
@@ -302,6 +306,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
       FAIL_SCREEN_INIT("nouveau_screen_init failed: %d\n", ret);
 
    chan = screen->base.channel;
+   chan->user_private = screen;
 
    pscreen->winsys = ws;
    pscreen->destroy = nv50_screen_destroy;
@@ -313,6 +318,8 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 
    nv50_screen_init_resource_functions(pscreen);
 
+   nouveau_screen_init_vdec(&screen->base);
+
    ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, 4096,
                         &screen->fence.bo);
    if (ret)
@@ -600,6 +607,9 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 
    screen->mm_VRAM_fe0 = nouveau_mm_create(dev, NOUVEAU_BO_VRAM, 0xfe0);
 
+   if (!nv50_blitctx_create(screen))
+      goto fail;
+
    nouveau_fence_new(&screen->base, &screen->base.fence.current, FALSE);
 
    return pscreen;
index aea434b..315ca80 100644 (file)
@@ -19,6 +19,10 @@ struct nv50_context;
 #define NV50_SCRATCH_SIZE (2 << 20)
 #define NV50_SCRATCH_NR_BUFFERS 2
 
+#define NV50_SCREEN_RESIDENT_BO_COUNT 5
+
+struct nv50_blitctx;
+
 struct nv50_screen {
    struct nouveau_screen base;
    struct nouveau_winsys *nvws;
@@ -37,6 +41,8 @@ struct nv50_screen {
    struct nouveau_resource *gp_code_heap;
    struct nouveau_resource *fp_code_heap;
 
+   struct nv50_blitctx *blitctx;
+
    struct {
       void **entries;
       int next;
@@ -69,6 +75,8 @@ nv50_screen(struct pipe_screen *screen)
    return (struct nv50_screen *)screen;
 }
 
+boolean nv50_blitctx_create(struct nv50_screen *);
+
 void nv50_screen_make_buffers_resident(struct nv50_screen *);
 
 int nv50_screen_tic_alloc(struct nv50_screen *, void *);
index e5b10c3..d73f7c7 100644 (file)
@@ -130,13 +130,14 @@ nv50_program_validate(struct nv50_context *nv50, struct nv50_program *prog)
    int ret;
    unsigned size;
 
-   if (prog->translated)
+   if (!prog->translated) {
+      prog->translated = nv50_program_translate(prog);
+      if (!prog->translated)
+         return FALSE;
+   } else
+   if (prog->res)
       return TRUE;
 
-   prog->translated = nv50_program_translate(prog);
-   if (!prog->translated)
-      return FALSE;
-
    if (prog->type == PIPE_SHADER_FRAGMENT) heap = nv50->screen->fp_code_heap;
    else
    if (prog->type == PIPE_SHADER_GEOMETRY) heap = nv50->screen->gp_code_heap;
index fb125f3..49ea646 100644 (file)
@@ -119,6 +119,7 @@ nv50_blend_state_create(struct pipe_context *pipe,
    struct nv50_blend_stateobj *so = CALLOC_STRUCT(nv50_blend_stateobj);
    int i;
    boolean emit_common_func = cso->rt[0].blend_enable;
+   uint32_t ms;
 
    if (nv50_context(pipe)->screen->tesla->grclass >= NVA3_3D) {
       SB_BEGIN_3D(so, BLEND_INDEPENDENT, 1);
@@ -190,6 +191,15 @@ nv50_blend_state_create(struct pipe_context *pipe,
       SB_DATA    (so, nv50_colormask(cso->rt[0].colormask));
    }
 
+   ms = 0;
+   if (cso->alpha_to_coverage)
+      ms |= NV50_3D_MULTISAMPLE_CTRL_ALPHA_TO_COVERAGE;
+   if (cso->alpha_to_one)
+      ms |= NV50_3D_MULTISAMPLE_CTRL_ALPHA_TO_ONE;
+
+   SB_BEGIN_3D(so, MULTISAMPLE_CTRL, 1);
+   SB_DATA    (so, ms);
+
    assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
    return so;
 }
@@ -237,6 +247,9 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
    SB_BEGIN_3D(so, FRAG_COLOR_CLAMP_EN, 1);
    SB_DATA    (so, cso->clamp_fragment_color ? 0x11111111 : 0x00000000);
 
+   SB_BEGIN_3D(so, MULTISAMPLE_ENABLE, 1);
+   SB_DATA    (so, cso->multisample);
+
    SB_BEGIN_3D(so, LINE_WIDTH, 1);
    SB_DATA    (so, fui(cso->line_width));
    SB_BEGIN_3D(so, LINE_SMOOTH_ENABLE, 1);
index 11561f5..44f2d25 100644 (file)
@@ -8,6 +8,7 @@ nv50_validate_fb(struct nv50_context *nv50)
    struct nouveau_channel *chan = nv50->screen->base.channel;
    struct pipe_framebuffer_state *fb = &nv50->framebuffer;
    unsigned i;
+   unsigned ms_mode = NV50_3D_MULTISAMPLE_MODE_MS1;
    boolean serialize = FALSE;
 
    nv50_bufctx_reset(nv50, NV50_BUFCTX_FRAME);
@@ -38,6 +39,8 @@ nv50_validate_fb(struct nv50_context *nv50)
       BEGIN_RING(chan, RING_3D(RT_ARRAY_MODE), 1);
       OUT_RING  (chan, sf->depth);
 
+      ms_mode = mt->ms_mode;
+
       if (mt->base.status & NOUVEAU_BUFFER_STATUS_GPU_READING)
          serialize = TRUE;
       mt->base.status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING;
@@ -69,6 +72,8 @@ nv50_validate_fb(struct nv50_context *nv50)
       OUT_RING  (chan, sf->height);
       OUT_RING  (chan, (unk << 16) | sf->depth);
 
+      ms_mode = mt->ms_mode;
+
       if (mt->base.status & NOUVEAU_BUFFER_STATUS_GPU_READING)
          serialize = TRUE;
       mt->base.status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING;
@@ -81,6 +86,9 @@ nv50_validate_fb(struct nv50_context *nv50)
       OUT_RING  (chan, 0);
    }
 
+   BEGIN_RING(chan, RING_3D(MULTISAMPLE_MODE), 1);
+   OUT_RING  (chan, ms_mode);
+
    BEGIN_RING(chan, RING_3D(VIEWPORT_HORIZ(0)), 2);
    OUT_RING  (chan, fb->width << 16);
    OUT_RING  (chan, fb->height << 16);
@@ -258,6 +266,26 @@ nv50_validate_rasterizer(struct nv50_context *nv50)
 }
 
 static void
+nv50_validate_sample_mask(struct nv50_context *nv50)
+{
+   struct nouveau_channel *chan = nv50->screen->base.channel;
+
+   unsigned mask[4] =
+   {
+      nv50->sample_mask & 0xffff,
+      nv50->sample_mask & 0xffff,
+      nv50->sample_mask & 0xffff,
+      nv50->sample_mask & 0xffff
+   };
+
+   BEGIN_RING(chan, RING_3D(MSAA_MASK(0)), 4);
+   OUT_RING  (chan, mask[0]);
+   OUT_RING  (chan, mask[1]);
+   OUT_RING  (chan, mask[2]);
+   OUT_RING  (chan, mask[3]);
+}
+
+static void
 nv50_switch_pipe_context(struct nv50_context *ctx_to)
 {
    struct nv50_context *ctx_from = ctx_to->screen->cur_ctx;
@@ -282,8 +310,7 @@ nv50_switch_pipe_context(struct nv50_context *ctx_to)
    if (!ctx_to->zsa)
       ctx_to->dirty &= ~NV50_NEW_ZSA;
 
-   ctx_to->screen->base.channel->user_private = ctx_to->screen->cur_ctx =
-      ctx_to;
+   ctx_to->screen->cur_ctx = ctx_to;
 }
 
 static struct state_validate {
@@ -293,6 +320,7 @@ static struct state_validate {
     { nv50_validate_fb,            NV50_NEW_FRAMEBUFFER },
     { nv50_validate_blend,         NV50_NEW_BLEND },
     { nv50_validate_zsa,           NV50_NEW_ZSA },
+    { nv50_validate_sample_mask,   NV50_NEW_SAMPLE_MASK },
     { nv50_validate_rasterizer,    NV50_NEW_RASTERIZER },
     { nv50_validate_blend_colour,  NV50_NEW_BLEND_COLOUR },
     { nv50_validate_stencil_ref,   NV50_NEW_STENCIL_REF },
@@ -322,7 +350,7 @@ static struct state_validate {
 #define validate_list_len (sizeof(validate_list) / sizeof(validate_list[0]))
 
 boolean
-nv50_state_validate(struct nv50_context *nv50)
+nv50_state_validate(struct nv50_context *nv50, unsigned words)
 {
    unsigned i;
 
@@ -339,6 +367,8 @@ nv50_state_validate(struct nv50_context *nv50)
       nv50->dirty = 0;
    }
 
+   MARK_RING(nv50->screen->base.channel, words, 0);
+
    nv50_bufctx_emit_relocs(nv50);
 
    return TRUE;
index 4c98c7e..d367a06 100644 (file)
 struct nv50_blend_stateobj {
    struct pipe_blend_state pipe;
    int size;
-   uint32_t state[82]; // TODO: allocate less if !independent_blend_enable
+   uint32_t state[84]; // TODO: allocate less if !independent_blend_enable
 };
 
 struct nv50_rasterizer_stateobj {
    struct pipe_rasterizer_state pipe;
    int size;
-   uint32_t state[42];
+   uint32_t state[44];
 };
 
 struct nv50_zsa_stateobj {
index 3d7e880..1a5077e 100644 (file)
 
 #include "nv50_defs.xml.h"
 
+#define NV50_ENG2D_SUPPORTED_FORMATS 0xff0843e080608409ULL
+
 /* return TRUE for formats that can be converted among each other by NV50_2D */
 static INLINE boolean
 nv50_2d_format_faithful(enum pipe_format format)
 {
-   switch (format) {
-   case PIPE_FORMAT_B8G8R8A8_UNORM:
-   case PIPE_FORMAT_B8G8R8X8_UNORM:
-   case PIPE_FORMAT_B8G8R8A8_SRGB:
-   case PIPE_FORMAT_B8G8R8X8_SRGB:
-   case PIPE_FORMAT_B5G6R5_UNORM:
-   case PIPE_FORMAT_B5G5R5A1_UNORM:
-   case PIPE_FORMAT_B10G10R10A2_UNORM:
-   case PIPE_FORMAT_R8_UNORM:
-   case PIPE_FORMAT_R32G32B32A32_FLOAT:
-   case PIPE_FORMAT_R32G32B32_FLOAT:
-      return TRUE;
-   default:
-      return FALSE;
-   }
+   uint8_t id = nv50_format_table[format].rt;
+
+   return (id >= 0xc0) &&
+      (NV50_ENG2D_SUPPORTED_FORMATS & (1ULL << (id - 0xc0)));
 }
 
 static INLINE uint8_t
@@ -63,7 +54,7 @@ nv50_2d_format(enum pipe_format format)
    /* Hardware values for color formats range from 0xc0 to 0xff,
     * but the 2D engine doesn't support all of them.
     */
-   if ((id >= 0xc0) && (0xff0843e080608409ULL & (1ULL << (id - 0xc0))))
+   if ((id >= 0xc0) && (NV50_ENG2D_SUPPORTED_FORMATS & (1ULL << (id - 0xc0))))
       return id;
 
    switch (util_format_get_blocksize(format)) {
@@ -72,7 +63,7 @@ nv50_2d_format(enum pipe_format format)
    case 2:
       return NV50_SURFACE_FORMAT_R16_UNORM;
    case 4:
-      return NV50_SURFACE_FORMAT_A8R8G8B8_UNORM;
+      return NV50_SURFACE_FORMAT_BGRA8_UNORM;
    default:
       return 0;
    }
@@ -96,8 +87,8 @@ nv50_2d_texture_set(struct nouveau_channel *chan, int dst,
       return 1;
    }
 
-   width = u_minify(mt->base.base.width0, level);
-   height = u_minify(mt->base.base.height0, level);
+   width = u_minify(mt->base.base.width0, level) << mt->ms_x;
+   height = u_minify(mt->base.base.height0, level) << mt->ms_y;
 
    offset = mt->level[level].offset;
    if (!mt->layout_3d) {
@@ -152,7 +143,13 @@ nv50_2d_texture_do_copy(struct nouveau_channel *chan,
                         unsigned sx, unsigned sy, unsigned sz,
                         unsigned w, unsigned h)
 {
+   static const uint32_t duvdxy[5] =
+   {
+      0x40000000, 0x80000000, 0x00000001, 0x00000002, 0x00000004
+   };
+
    int ret;
+   uint32_t ctrl;
 
    ret = MARK_RING(chan, 2 * 16 + 32, 4);
    if (ret)
@@ -166,24 +163,28 @@ nv50_2d_texture_do_copy(struct nouveau_channel *chan,
    if (ret)
       return ret;
 
-   /* 0/1 = CENTER/CORNER, 10/00 = POINT/BILINEAR */
+   /* NOTE: 2D engine doesn't work for MS8 */
+   if (src->ms_x)
+      ctrl = 0x11;
+
+   /* 0/1 = CENTER/CORNER, 00/10 = POINT/BILINEAR */
    BEGIN_RING(chan, RING_2D(BLIT_CONTROL), 1);
-   OUT_RING  (chan, 0);
+   OUT_RING  (chan, ctrl);
    BEGIN_RING(chan, RING_2D(BLIT_DST_X), 4);
-   OUT_RING  (chan, dx);
-   OUT_RING  (chan, dy);
-   OUT_RING  (chan, w);
-   OUT_RING  (chan, h);
+   OUT_RING  (chan, dx << dst->ms_x);
+   OUT_RING  (chan, dy << dst->ms_y);
+   OUT_RING  (chan, w << dst->ms_x);
+   OUT_RING  (chan, h << dst->ms_y);
    BEGIN_RING(chan, RING_2D(BLIT_DU_DX_FRACT), 4);
-   OUT_RING  (chan, 0);
-   OUT_RING  (chan, 1);
-   OUT_RING  (chan, 0);
-   OUT_RING  (chan, 1);
+   OUT_RING  (chan, duvdxy[2 + ((int)src->ms_x - (int)dst->ms_x)] & 0xf0000000);
+   OUT_RING  (chan, duvdxy[2 + ((int)src->ms_x - (int)dst->ms_x)] & 0x0000000f);
+   OUT_RING  (chan, duvdxy[2 + ((int)src->ms_y - (int)dst->ms_y)] & 0xf0000000);
+   OUT_RING  (chan, duvdxy[2 + ((int)src->ms_y - (int)dst->ms_y)] & 0x0000000f);
    BEGIN_RING(chan, RING_2D(BLIT_SRC_X_FRACT), 4);
    OUT_RING  (chan, 0);
-   OUT_RING  (chan, sx);
+   OUT_RING  (chan, sx << src->ms_x);
    OUT_RING  (chan, 0);
-   OUT_RING  (chan, sy);
+   OUT_RING  (chan, sy << src->ms_y);
 
    return 0;
 }
@@ -206,6 +207,34 @@ nv50_resource_copy_region(struct pipe_context *pipe,
       return;
    }
 
+   nv04_resource(dst)->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING;
+
+   if (src->format == dst->format && src->nr_samples == dst->nr_samples) {
+      struct nv50_m2mf_rect drect, srect;
+      unsigned i;
+      unsigned nx = util_format_get_nblocksx(src->format, src_box->width);
+      unsigned ny = util_format_get_nblocksy(src->format, src_box->height);
+
+      nv50_m2mf_rect_setup(&drect, dst, dst_level, dstx, dsty, dstz);
+      nv50_m2mf_rect_setup(&srect, src, src_level,
+                           src_box->x, src_box->y, src_box->z);
+
+      for (i = 0; i < src_box->depth; ++i) {
+         nv50_m2mf_transfer_rect(&screen->base.base, &drect, &srect, nx, ny);
+
+         if (nv50_miptree(dst)->layout_3d)
+            drect.z++;
+         else
+            drect.base += nv50_miptree(dst)->layer_stride;
+
+         if (nv50_miptree(src)->layout_3d)
+            srect.z++;
+         else
+            srect.base += nv50_miptree(src)->layer_stride;
+      }
+      return;
+   }
+
    assert((src->format == dst->format) ||
           (nv50_2d_format_faithful(src->format) &&
            nv50_2d_format_faithful(dst->format)));
@@ -339,7 +368,7 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
 
    /* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */
    nv50->dirty &= NV50_NEW_FRAMEBUFFER;
-   if (!nv50_state_validate(nv50))
+   if (!nv50_state_validate(nv50, 9 + (fb->nr_cbufs * 2)))
       return;
 
    if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) {
@@ -376,12 +405,546 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
    nv50->dirty = dirty & ~NV50_NEW_FRAMEBUFFER;
 }
 
+
+struct nv50_blitctx
+{
+   struct nv50_screen *screen;
+   struct {
+      struct pipe_framebuffer_state fb;
+      struct nv50_program *vp;
+      struct nv50_program *gp;
+      struct nv50_program *fp;
+      unsigned num_textures[3];
+      unsigned num_samplers[3];
+      struct pipe_sampler_view *texture;
+      struct nv50_tsc_entry *sampler;
+      unsigned dirty;
+      unsigned clip_nr;
+   } saved;
+   struct nv50_program vp;
+   struct nv50_program fp;
+   struct nv50_tsc_entry sampler[2]; /* nearest, bilinear */
+   uint32_t fp_offset;
+   uint16_t color_mask;
+   uint8_t filter;
+};
+
+static void
+nv50_blitctx_make_vp(struct nv50_blitctx *blit)
+{
+   static const uint32_t code[] =
+   {
+      0x10000001, /* mov b32 o[0x00] s[0x00] */ /* HPOS.x */
+      0x0423c788,
+      0x10000205, /* mov b32 o[0x04] s[0x04] */ /* HPOS.y */
+      0x0423c788,
+      0x10000409, /* mov b32 o[0x08] s[0x08] */ /* TEXC.x */
+      0x0423c788,
+      0x1000060d, /* mov b32 o[0x0c] s[0x0c] */ /* TEXC.y */
+      0x0423c788,
+      0x10000811, /* exit mov b32 o[0x10] s[0x10] */ /* TEXC.z */
+      0x0423c789,
+   };
+
+   blit->vp.type = PIPE_SHADER_VERTEX;
+   blit->vp.translated = TRUE;
+   blit->vp.code = (uint32_t *)code; /* const_cast */
+   blit->vp.code_size = sizeof(code);
+   blit->vp.max_gpr = 4;
+   blit->vp.max_out = 5;
+   blit->vp.out_nr = 2;
+   blit->vp.out[0].mask = 0x3;
+   blit->vp.out[0].sn = TGSI_SEMANTIC_POSITION;
+   blit->vp.out[1].hw = 2;
+   blit->vp.out[1].mask = 0x7;
+   blit->vp.out[1].sn = TGSI_SEMANTIC_GENERIC;
+   blit->vp.vp.attrs[0] = 0x73;
+   blit->vp.vp.psiz = 0x40;
+   blit->vp.vp.edgeflag = 0x40;
+}
+
+static void
+nv50_blitctx_make_fp(struct nv50_blitctx *blit)
+{
+   static const uint32_t code[] =
+   {
+      /* 3 coords RGBA in, RGBA out, also for Z32_FLOAT(_S8X24_USCALED) */
+      0x80000000, /* interp $r0 v[0x0] */
+      0x80010004, /* interp $r1 v[0x4] */
+      0x80020009, /* interp $r2 flat v[0x8] */
+      0x00040780,
+      0xf6800001, /* texauto live { $r0,1,2,3 } $t0 $s0 { $r0,1,2 } */
+      0x0000c785, /* exit */
+
+      /* 3 coords ZS in, S encoded in R, Z encoded in GBA (8_UNORM) */
+      0x80000000, /* interp $r0 v[0x00] */
+      0x80010004, /* interp $r1 v[0x04] */
+      0x80020009, /* interp $r2 flat v[0x8] */
+      0x00040780,
+      0xf6800001, /* texauto live { $r0,1,#,# } $t0 $s0 { $r0,1,2 } */
+      0x00000784,
+      0xc03f0009, /* mul f32 $r2 $r0 (2^24 - 1) */
+      0x04b7ffff,
+      0xa0000201, /* cvt f32 $r0 s32 $r1 */
+      0x44014780,
+      0xa0000409, /* cvt rni s32 $r2 f32 $r2 */
+      0x8c004780,
+      0xc0010001, /* mul f32 $r0 $r0 1/0xff */
+      0x03b8080b,
+      0xd03f0405, /* and b32 $r1 $r2 0x0000ff */
+      0x0000000f,
+      0xd000040d, /* and b32 $r3 $r2 0xff0000 */
+      0x000ff003,
+      0xd0000409, /* and b32 $r2 $r2 0x00ff00 */
+      0x00000ff3,
+      0xa0000205, /* cvt f32 $r1 s32 $r1 */
+      0x44014780,
+      0xa000060d, /* cvt f32 $r3 s32 $r3 */
+      0x44014780,
+      0xa0000409, /* cvt f32 $r2 s32 $r2 */
+      0x44014780,
+      0xc0010205, /* mul f32 $r1 $r1 1/0x0000ff */
+      0x03b8080b,
+      0xc001060d, /* mul f32 $r3 $r3 1/0x00ff00 */
+      0x0338080b,
+      0xc0010409, /* mul f32 $r2 $r2 1/0xff0000 */
+      0x0378080b,
+      0xf0000001, /* exit never nop */
+      0xe0000001,
+
+      /* 3 coords ZS in, Z encoded in RGB, S encoded in A (U8_UNORM) */
+      0x80000000, /* interp $r0 v[0x00] */
+      0x80010004, /* interp $r1 v[0x04] */
+      0x80020009, /* interp $r2 flat v[0x8] */
+      0x00040780,
+      0xf6800001, /* texauto live { $r0,1,#,# } $t0 $s0 { $r0,1,2 } */
+      0x00000784,
+      0xc03f0009, /* mul f32 $r2 $r0 (2^24 - 1) */
+      0x04b7ffff,
+      0xa0000281, /* cvt f32 $r3 s32 $r1 */
+      0x44014780,
+      0xa0000409, /* cvt rni s32 $r2 f32 $r2 */
+      0x8c004780,
+      0xc001060d, /* mul f32 $r3 $r3 1/0xff */
+      0x03b8080b,
+      0xd03f0401, /* and b32 $r0 $r2 0x0000ff */
+      0x0000000f,
+      0xd0000405, /* and b32 $r1 $r2 0x00ff00 */
+      0x00000ff3,
+      0xd0000409, /* and b32 $r2 $r2 0xff0000 */
+      0x000ff003,
+      0xa0000001, /* cvt f32 $r0 s32 $r0 */
+      0x44014780,
+      0xa0000205, /* cvt f32 $r1 s32 $r1 */
+      0x44014780,
+      0xa0000409, /* cvt f32 $r2 s32 $r2 */
+      0x44014780,
+      0xc0010001, /* mul f32 $r0 $r0 1/0x0000ff */
+      0x03b8080b,
+      0xc0010205, /* mul f32 $r1 $r1 1/0x00ff00 */
+      0x0378080b,
+      0xc0010409, /* mul f32 $r2 $r2 1/0xff0000 */
+      0x0338080b,
+      0xf0000001, /* exit never nop */
+      0xe0000001
+   };
+
+   blit->fp.type = PIPE_SHADER_FRAGMENT;
+   blit->fp.translated = TRUE;
+   blit->fp.code = (uint32_t *)code; /* const_cast */
+   blit->fp.code_size = sizeof(code);
+   blit->fp.max_gpr = 4;
+   blit->fp.max_out = 4;
+   blit->fp.in_nr = 1;
+   blit->fp.in[0].mask = 0x7; /* last component flat */
+   blit->fp.in[0].linear = 1;
+   blit->fp.in[0].sn = TGSI_SEMANTIC_GENERIC;
+   blit->fp.out_nr = 1;
+   blit->fp.out[0].mask = 0xf;
+   blit->fp.out[0].sn = TGSI_SEMANTIC_COLOR;
+   blit->fp.fp.interp = 0x00020403;
+   blit->fp.gp.primid = 0x80;
+}
+
+static void
+nv50_blitctx_make_sampler(struct nv50_blitctx *blit)
+{
+   /* clamp to edge, min/max lod = 0, nearest filtering */
+
+   blit->sampler[0].id = -1;
+
+   blit->sampler[0].tsc[0] = 0x00000092;
+   blit->sampler[0].tsc[1] = 0x00000051;
+
+   /* clamp to edge, min/max lod = 0, bilinear filtering */
+
+   blit->sampler[1].id = -1;
+
+   blit->sampler[1].tsc[0] = 0x00000092;
+   blit->sampler[1].tsc[1] = 0x00000062;
+}
+
+/* Since shaders cannot export stencil, we cannot copy stencil values when
+ * rendering to ZETA, so we attach the ZS surface to a colour render target.
+ */
+static INLINE enum pipe_format
+nv50_blit_zeta_to_colour_format(enum pipe_format format)
+{
+   switch (format) {
+   case PIPE_FORMAT_Z16_UNORM:               return PIPE_FORMAT_R16_UNORM;
+   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+   case PIPE_FORMAT_Z24X8_UNORM:             return PIPE_FORMAT_R8G8B8A8_UNORM;
+   case PIPE_FORMAT_Z32_FLOAT:               return PIPE_FORMAT_R32_FLOAT;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: return PIPE_FORMAT_R32G32_FLOAT;
+   default:
+      assert(0);
+      return PIPE_FORMAT_NONE;
+   }
+}
+
+static void
+nv50_blitctx_get_color_mask_and_fp(struct nv50_blitctx *blit,
+                                   enum pipe_format format, uint8_t mask)
+{
+   blit->color_mask = 0;
+
+   switch (format) {
+   case PIPE_FORMAT_Z24X8_UNORM:
+   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+      blit->fp_offset = 160;
+      if (mask & PIPE_MASK_Z)
+         blit->color_mask |= 0x0111;
+      if (mask & PIPE_MASK_S)
+         blit->color_mask |= 0x1000;
+      break;
+   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+      blit->fp_offset = 24;
+      if (mask & PIPE_MASK_Z)
+         blit->color_mask |= 0x1110;
+      if (mask & PIPE_MASK_S)
+         blit->color_mask |= 0x0001;
+      break;
+   default:
+      blit->fp_offset = 0;
+      if (mask & (PIPE_MASK_R | PIPE_MASK_Z)) blit->color_mask |= 0x0001;
+      if (mask & (PIPE_MASK_G | PIPE_MASK_S)) blit->color_mask |= 0x0010;
+      if (mask & PIPE_MASK_B) blit->color_mask |= 0x0100;
+      if (mask & PIPE_MASK_A) blit->color_mask |= 0x1000;
+      break;
+   }
+}
+
+static void
+nv50_blit_set_dst(struct nv50_context *nv50,
+                  struct pipe_resource *res, unsigned level, unsigned layer)
+{
+   struct pipe_context *pipe = &nv50->base.pipe;
+   struct pipe_surface templ;
+
+   if (util_format_is_depth_or_stencil(res->format))
+      templ.format = nv50_blit_zeta_to_colour_format(res->format);
+   else
+      templ.format = res->format;
+
+   templ.usage = PIPE_USAGE_STREAM;
+   templ.u.tex.level = level;
+   templ.u.tex.first_layer = templ.u.tex.last_layer = layer;
+
+   nv50->framebuffer.cbufs[0] = nv50_miptree_surface_new(pipe, res, &templ);
+   nv50->framebuffer.nr_cbufs = 1;
+   nv50->framebuffer.zsbuf = NULL;
+   nv50->framebuffer.width = nv50->framebuffer.cbufs[0]->width;
+   nv50->framebuffer.height = nv50->framebuffer.cbufs[0]->height;
+}
+
+static INLINE void
+nv50_blit_fixup_tic_entry(struct pipe_sampler_view *view)
+{
+   struct nv50_tic_entry *ent = nv50_tic_entry(view);
+
+   ent->tic[2] &= ~(1 << 31); /* scaled coordinates, ok with 3d textures ? */
+
+   /* magic: */
+
+   ent->tic[3] = 0x20000000; /* affects quality of near vertical edges in MS8 */
+}
+
+static void
+nv50_blit_set_src(struct nv50_context *nv50,
+                  struct pipe_resource *res, unsigned level, unsigned layer)
+{
+   struct pipe_context *pipe = &nv50->base.pipe;
+   struct pipe_sampler_view templ;
+
+   templ.format = res->format;
+   templ.u.tex.first_layer = templ.u.tex.last_layer = layer;
+   templ.u.tex.first_level = templ.u.tex.last_level = level;
+   templ.swizzle_r = PIPE_SWIZZLE_RED;
+   templ.swizzle_g = PIPE_SWIZZLE_GREEN;
+   templ.swizzle_b = PIPE_SWIZZLE_BLUE;
+   templ.swizzle_a = PIPE_SWIZZLE_ALPHA;
+
+   nv50->textures[2][0] = nv50_create_sampler_view(pipe, res, &templ);
+
+   nv50_blit_fixup_tic_entry(nv50->textures[2][0]);
+
+   nv50->num_textures[0] = nv50->num_textures[1] = 0;
+   nv50->num_textures[2] = 1;
+}
+
+static void
+nv50_blitctx_prepare_state(struct nv50_blitctx *blit)
+{
+   struct nouveau_channel *chan = blit->screen->base.channel;
+
+   /* blend state */
+   BEGIN_RING(chan, RING_3D(COLOR_MASK(0)), 1);
+   OUT_RING  (chan, blit->color_mask);
+   BEGIN_RING(chan, RING_3D(BLEND_ENABLE(0)), 1);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(LOGIC_OP_ENABLE), 1);
+   OUT_RING  (chan, 0);
+
+   /* rasterizer state */
+#ifndef NV50_SCISSORS_CLIPPING
+   BEGIN_RING(chan, RING_3D(SCISSOR_ENABLE(0)), 1);
+   OUT_RING  (chan, 1);
+#endif
+   BEGIN_RING(chan, RING_3D(VERTEX_TWO_SIDE_ENABLE), 1);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(FRAG_COLOR_CLAMP_EN), 1);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(MULTISAMPLE_ENABLE), 1);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(MSAA_MASK(0)), 4);
+   OUT_RING  (chan, 0xffff);
+   OUT_RING  (chan, 0xffff);
+   OUT_RING  (chan, 0xffff);
+   OUT_RING  (chan, 0xffff);
+   BEGIN_RING(chan, RING_3D(POLYGON_MODE_FRONT), 3);
+   OUT_RING  (chan, NV50_3D_POLYGON_MODE_FRONT_FILL);
+   OUT_RING  (chan, NV50_3D_POLYGON_MODE_BACK_FILL);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(CULL_FACE_ENABLE), 1);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(POLYGON_STIPPLE_ENABLE), 1);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(POLYGON_OFFSET_FILL_ENABLE), 1);
+   OUT_RING  (chan, 0);
+
+   /* zsa state */
+   BEGIN_RING(chan, RING_3D(DEPTH_TEST_ENABLE), 1);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(STENCIL_ENABLE), 1);
+   OUT_RING  (chan, 0);
+   BEGIN_RING(chan, RING_3D(ALPHA_TEST_ENABLE), 1);
+   OUT_RING  (chan, 0);
+}
+
+static void
+nv50_blitctx_pre_blit(struct nv50_blitctx *blit, struct nv50_context *nv50)
+{
+   int s;
+
+   blit->saved.fb.width = nv50->framebuffer.width;
+   blit->saved.fb.height = nv50->framebuffer.height;
+   blit->saved.fb.nr_cbufs = nv50->framebuffer.nr_cbufs;
+   blit->saved.fb.cbufs[0] = nv50->framebuffer.cbufs[0];
+   blit->saved.fb.zsbuf = nv50->framebuffer.zsbuf;
+
+   blit->saved.vp = nv50->vertprog;
+   blit->saved.gp = nv50->gmtyprog;
+   blit->saved.fp = nv50->fragprog;
+
+   nv50->vertprog = &blit->vp;
+   nv50->gmtyprog = NULL;
+   nv50->fragprog = &blit->fp;
+
+   blit->saved.clip_nr = nv50->clip.nr;
+
+   nv50->clip.nr = 0;
+
+   for (s = 0; s < 3; ++s) {
+      blit->saved.num_textures[s] = nv50->num_textures[s];
+      blit->saved.num_samplers[s] = nv50->num_samplers[s];
+   }
+   blit->saved.texture = nv50->textures[2][0];
+   blit->saved.sampler = nv50->samplers[2][0];
+
+   nv50->samplers[2][0] = &blit->sampler[blit->filter];
+
+   nv50->num_samplers[0] = nv50->num_samplers[1] = 0;
+   nv50->num_samplers[2] = 1;
+
+   blit->saved.dirty = nv50->dirty;
+
+   nv50->dirty =
+      NV50_NEW_FRAMEBUFFER |
+      NV50_NEW_VERTPROG | NV50_NEW_FRAGPROG | NV50_NEW_GMTYPROG |
+      NV50_NEW_TEXTURES | NV50_NEW_SAMPLERS;
+}
+
+static void
+nv50_blitctx_post_blit(struct nv50_context *nv50, struct nv50_blitctx *blit)
+{
+   int s;
+
+   pipe_surface_reference(&nv50->framebuffer.cbufs[0], NULL);
+
+   nv50->framebuffer.width = blit->saved.fb.width;
+   nv50->framebuffer.height = blit->saved.fb.height;
+   nv50->framebuffer.nr_cbufs = blit->saved.fb.nr_cbufs;
+   nv50->framebuffer.cbufs[0] = blit->saved.fb.cbufs[0];
+   nv50->framebuffer.zsbuf = blit->saved.fb.zsbuf;
+
+   nv50->vertprog = blit->saved.vp;
+   nv50->gmtyprog = blit->saved.gp;
+   nv50->fragprog = blit->saved.fp;
+
+   nv50->clip.nr = blit->saved.clip_nr;
+
+   pipe_sampler_view_reference(&nv50->textures[2][0], NULL);
+
+   for (s = 0; s < 3; ++s) {
+      nv50->num_textures[s] = blit->saved.num_textures[s];
+      nv50->num_samplers[s] = blit->saved.num_samplers[s];
+   }
+   nv50->textures[2][0] = blit->saved.texture;
+   nv50->samplers[2][0] = blit->saved.sampler;
+
+   nv50->dirty = blit->saved.dirty |
+      (NV50_NEW_FRAMEBUFFER | NV50_NEW_SCISSOR | NV50_NEW_SAMPLE_MASK |
+       NV50_NEW_RASTERIZER | NV50_NEW_ZSA | NV50_NEW_BLEND |
+       NV50_NEW_TEXTURES | NV50_NEW_SAMPLERS |
+       NV50_NEW_VERTPROG | NV50_NEW_GMTYPROG | NV50_NEW_FRAGPROG);
+}
+
+static void
+nv50_resource_resolve(struct pipe_context *pipe,
+                      const struct pipe_resolve_info *info)
+{
+   struct nv50_context *nv50 = nv50_context(pipe);
+   struct nv50_screen *screen = nv50->screen;
+   struct nv50_blitctx *blit = screen->blitctx;
+   struct nouveau_channel *chan = screen->base.channel;
+   struct pipe_resource *src = info->src.res;
+   struct pipe_resource *dst = info->dst.res;
+   float x0, x1, y0, y1, z;
+   float x_range, y_range;
+
+   nv50_blitctx_get_color_mask_and_fp(blit, dst->format, info->mask);
+
+   blit->filter = util_format_is_depth_or_stencil(dst->format) ? 0 : 1;
+
+   nv50_blitctx_pre_blit(blit, nv50);
+
+   nv50_blit_set_dst(nv50, dst, info->dst.level, info->dst.layer);
+   nv50_blit_set_src(nv50, src, 0,               info->src.layer);
+
+   nv50_blitctx_prepare_state(blit);
+
+   nv50_state_validate(nv50, 36);
+
+   x_range =
+      (float)(info->src.x1 - info->src.x0) /
+      (float)(info->dst.x1 - info->dst.x0);
+   y_range =
+      (float)(info->src.y1 - info->src.y0) /
+      (float)(info->dst.y1 - info->dst.y0);
+
+   x0 = (float)info->src.x0 - x_range * (float)info->dst.x0;
+   y0 = (float)info->src.y0 - y_range * (float)info->dst.y0;
+
+   x1 = x0 + 16384.0f * x_range;
+   y1 = y0 + 16384.0f * y_range;
+
+   x0 *= (float)(1 << nv50_miptree(src)->ms_x);
+   x1 *= (float)(1 << nv50_miptree(src)->ms_x);
+   y0 *= (float)(1 << nv50_miptree(src)->ms_y);
+   y1 *= (float)(1 << nv50_miptree(src)->ms_y);
+
+   z = (float)info->src.layer;
+
+   BEGIN_RING(chan, RING_3D(FP_START_ID), 1);
+   OUT_RING  (chan,
+              blit->fp.code_base + blit->fp_offset);
+
+   BEGIN_RING(chan, RING_3D(VIEWPORT_TRANSFORM_EN), 1);
+   OUT_RING  (chan, 0);
+
+   /* Draw a large triangle in screen coordinates covering the whole
+    * render target, with scissors defining the destination region.
+    * The vertex is supplied with non-normalized texture coordinates
+    * arranged in a way to yield the desired offset and scale.
+    */
+
+   BEGIN_RING(chan, RING_3D(SCISSOR_HORIZ(0)), 2);
+   OUT_RING  (chan, (info->dst.x1 << 16) | info->dst.x0);
+   OUT_RING  (chan, (info->dst.y1 << 16) | info->dst.y0);
+
+   BEGIN_RING(chan, RING_3D(VERTEX_BEGIN_GL), 1);
+   OUT_RING  (chan, NV50_3D_VERTEX_BEGIN_GL_PRIMITIVE_TRIANGLES);
+   BEGIN_RING(chan, RING_3D(VTX_ATTR_3F_X(1)), 3);
+   OUT_RINGf (chan, x0);
+   OUT_RINGf (chan, y0);
+   OUT_RINGf (chan, z);
+   BEGIN_RING(chan, RING_3D(VTX_ATTR_2F_X(0)), 2);
+   OUT_RINGf (chan, 0.0f);
+   OUT_RINGf (chan, 0.0f);
+   BEGIN_RING(chan, RING_3D(VTX_ATTR_3F_X(1)), 3);
+   OUT_RINGf (chan, x1);
+   OUT_RINGf (chan, y0);
+   OUT_RINGf (chan, z);
+   BEGIN_RING(chan, RING_3D(VTX_ATTR_2F_X(0)), 2);
+   OUT_RINGf (chan, 16384 << nv50_miptree(dst)->ms_x);
+   OUT_RINGf (chan, 0.0f);
+   BEGIN_RING(chan, RING_3D(VTX_ATTR_3F_X(1)), 3);
+   OUT_RINGf (chan, x0);
+   OUT_RINGf (chan, y1);
+   OUT_RINGf (chan, z);
+   BEGIN_RING(chan, RING_3D(VTX_ATTR_2F_X(0)), 2);
+   OUT_RINGf (chan, 0.0f);
+   OUT_RINGf (chan, 16384 << nv50_miptree(dst)->ms_y);
+   BEGIN_RING(chan, RING_3D(VERTEX_END_GL), 1);
+   OUT_RING  (chan, 0);
+
+   /* re-enable normally constant state */
+
+   BEGIN_RING(chan, RING_3D(VIEWPORT_TRANSFORM_EN), 1);
+   OUT_RING  (chan, 1);
+
+   nv50_blitctx_post_blit(nv50, blit);
+}
+
+boolean
+nv50_blitctx_create(struct nv50_screen *screen)
+{
+   screen->blitctx = CALLOC_STRUCT(nv50_blitctx);
+   if (!screen->blitctx) {
+      NOUVEAU_ERR("failed to allocate blit context\n");
+      return FALSE;
+   }
+
+   screen->blitctx->screen = screen;
+
+   nv50_blitctx_make_vp(screen->blitctx);
+   nv50_blitctx_make_fp(screen->blitctx);
+
+   nv50_blitctx_make_sampler(screen->blitctx);
+
+   screen->blitctx->color_mask = 0x1111;
+
+   return TRUE;
+}
+
 void
 nv50_init_surface_functions(struct nv50_context *nv50)
 {
    struct pipe_context *pipe = &nv50->base.pipe;
 
    pipe->resource_copy_region = nv50_resource_copy_region;
+   pipe->resource_resolve = nv50_resource_resolve;
    pipe->clear_render_target = nv50_clear_render_target;
    pipe->clear_depth_stencil = nv50_clear_depth_stencil;
 }
index 9192d2e..73db9ca 100644 (file)
@@ -159,13 +159,13 @@ nv50_create_sampler_view(struct pipe_context *pipe,
    else
       tic[3] = 0x00300000;
 
-   tic[4] = (1 << 31) | mt->base.base.width0;
+   tic[4] = (1 << 31) | (mt->base.base.width0 << mt->ms_x);
 
-   tic[5] = mt->base.base.height0 & 0xffff;
+   tic[5] = (mt->base.base.height0 << mt->ms_y) & 0xffff;
    tic[5] |= depth << 16;
    tic[5] |= mt->base.base.last_level << 28;
 
-   tic[6] = 0x03000000;
+   tic[6] = (mt->ms_x > 1) ? 0x88000000 : 0x03000000; /* sampling points */
 
    tic[7] = (view->pipe.u.tex.last_level << 4) | view->pipe.u.tex.first_level;
 
index e0cbbdf..08f6efd 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef NV50_TEXTURE_XML
-#define NV50_TEXTURE_XML
+#ifndef RNNDB_NV50_TEXTURE_XML
+#define RNNDB_NV50_TEXTURE_XML
 
 /* Autogenerated file, DO NOT EDIT manually!
 
@@ -8,8 +8,10 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- nv50_texture.xml (   8377 bytes, from 2011-02-12 12:05:21)
-- copyright.xml    (   6452 bytes, from 2010-11-25 23:28:20)
+- rnndb/nv50_texture.xml (   7947 bytes, from 2011-07-09 13:43:58)
+- ./rnndb/copyright.xml  (   6452 bytes, from 2011-07-09 13:43:58)
+- ./rnndb/nvchipsets.xml (   3617 bytes, from 2011-07-09 13:43:58)
+- ./rnndb/nv50_defs.xml  (   5468 bytes, from 2011-07-09 13:43:58)
 
 Copyright (C) 2006-2011 by the following authors:
 - Artur Huillet <arthur.huillet@free.fr> (ahuillet)
@@ -115,52 +117,52 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NV50_TIC_0_FMT_32_32_32_32                             0x00000001
 #define NV50_TIC_0_FMT_16_16_16_16                             0x00000003
 #define NV50_TIC_0_FMT_32_32                                   0x00000004
-#define NV50_TIC_0_FMT_32_8                                    0x00000005
+#define NV50_TIC_0_FMT_32_8_X24                                        0x00000005
 #define NV50_TIC_0_FMT_8_8_8_8                                 0x00000008
-#define NV50_TIC_0_FMT_2_10_10_10                              0x00000009
+#define NV50_TIC_0_FMT_10_10_10_2                              0x00000009
 #define NV50_TIC_0_FMT_16_16                                   0x0000000c
-#define NV50_TIC_0_FMT_8_24                                    0x0000000d
-#define NV50_TIC_0_FMT_24_8                                    0x0000000e
+#define NV50_TIC_0_FMT_24_8                                    0x0000000d
+#define NV50_TIC_0_FMT_8_24                                    0x0000000e
 #define NV50_TIC_0_FMT_32                                      0x0000000f
 #define NV50_TIC_0_FMT_BPTC_FLOAT                              0x00000010
 #define NV50_TIC_0_FMT_BPTC_UFLOAT                             0x00000011
 #define NV50_TIC_0_FMT_4_4_4_4                                 0x00000012
-#define NV50_TIC_0_FMT_5_5_5_1                                 0x00000013
-#define NV50_TIC_0_FMT_1_5_5_5                                 0x00000014
+#define NV50_TIC_0_FMT_1_5_5_5                                 0x00000013
+#define NV50_TIC_0_FMT_5_5_5_1                                 0x00000014
 #define NV50_TIC_0_FMT_5_6_5                                   0x00000015
-#define NV50_TIC_0_FMT_6_5_5                                   0x00000016
+#define NV50_TIC_0_FMT_5_5_6                                   0x00000016
 #define NV50_TIC_0_FMT_BPTC                                    0x00000017
 #define NV50_TIC_0_FMT_8_8                                     0x00000018
 #define NV50_TIC_0_FMT_16                                      0x0000001b
 #define NV50_TIC_0_FMT_8                                       0x0000001d
 #define NV50_TIC_0_FMT_4_4                                     0x0000001e
-#define NV50_TIC_0_FMT_BITMAP_8X8                              0x0000001f
-#define NV50_TIC_0_FMT_E5_9_9_9                                        0x00000020
-#define NV50_TIC_0_FMT_10_11_11                                        0x00000021
-#define NV50_TIC_0_FMT_C1_C2_C1_C0                             0x00000022
-#define NV50_TIC_0_FMT_C2_C1_C0_C1                             0x00000023
+#define NV50_TIC_0_FMT_BITMAP                                  0x0000001f
+#define NV50_TIC_0_FMT_9_9_9_E5                                        0x00000020
+#define NV50_TIC_0_FMT_11_11_10                                        0x00000021
+#define NV50_TIC_0_FMT_U8_YA8_V8_YB8                           0x00000022
+#define NV50_TIC_0_FMT_YA8_U8_YB8_V8                           0x00000023
 #define NV50_TIC_0_FMT_DXT1                                    0x00000024
 #define NV50_TIC_0_FMT_DXT3                                    0x00000025
 #define NV50_TIC_0_FMT_DXT5                                    0x00000026
 #define NV50_TIC_0_FMT_RGTC1                                   0x00000027
 #define NV50_TIC_0_FMT_RGTC2                                   0x00000028
-#define NV50_TIC_0_FMT_Z24S8                                   0x00000029
-#define NV50_TIC_0_FMT_S8Z24                                   0x0000002a
-#define NV50_TIC_0_FMT_X8Z24                                   0x0000002b
-#define NV50_TIC_0_FMT_C8Z24_MS4_CS4                           0x0000002c
-#define NV50_TIC_0_FMT_C8Z24_MS8_CS8                           0x0000002d
-#define NV50_TIC_0_FMT_C8Z24_MS4_CS12                          0x0000002e
+#define NV50_TIC_0_FMT_S8_Z24                                  0x00000029
+#define NV50_TIC_0_FMT_Z24_S8                                  0x0000002a
+#define NV50_TIC_0_FMT_Z24_X8                                  0x0000002b
+#define NV50_TIC_0_FMT_Z24_C8_MS4_CS4                          0x0000002c
+#define NV50_TIC_0_FMT_Z24_C8_MS8_CS8                          0x0000002d
+#define NV50_TIC_0_FMT_Z24_C8_MS4_CS12                         0x0000002e
 #define NV50_TIC_0_FMT_Z32                                     0x0000002f
-#define NV50_TIC_0_FMT_X24S8Z32                                        0x00000030
-#define NV50_TIC_0_FMT_X16C8S8X8Z24_MS4_CS4                    0x00000031
-#define NV50_TIC_0_FMT_X16C8S8X8Z24_MS8_CS8                    0x00000032
-#define NV50_TIC_0_FMT_X16C8X8Z32_MS4_CS4                      0x00000033
-#define NV50_TIC_0_FMT_X16C8X8Z32_MS8_CS8                      0x00000034
-#define NV50_TIC_0_FMT_X16C8S8Z32_MS4_CS4                      0x00000035
-#define NV50_TIC_0_FMT_X16C8S8Z32_MS8_CS8                      0x00000036
-#define NV50_TIC_0_FMT_X16C8S8X8Z24_MS4_CS12                   0x00000037
-#define NV50_TIC_0_FMT_X16C8X8Z32_MS4_CS12                     0x00000038
-#define NV50_TIC_0_FMT_X16C8S8Z32_MS4_CS12                     0x00000039
+#define NV50_TIC_0_FMT_Z32_S8_X24                              0x00000030
+#define NV50_TIC_0_FMT_Z24_X8_S8_C8_X16_MS4_CS4                        0x00000031
+#define NV50_TIC_0_FMT_Z24_X8_S8_C8_X16_MS8_CS8                        0x00000032
+#define NV50_TIC_0_FMT_Z32_X8_C8_X16_MS4_CS4                   0x00000033
+#define NV50_TIC_0_FMT_Z32_X8_C8_X16_MS8_CS8                   0x00000034
+#define NV50_TIC_0_FMT_Z32_S8_C8_X16_MS4_CS4                   0x00000035
+#define NV50_TIC_0_FMT_Z32_S8_C8_X16_MS8_CS8                   0x00000036
+#define NV50_TIC_0_FMT_Z24_X8_S8_C8_X16_MS4_CS12               0x00000037
+#define NV50_TIC_0_FMT_Z32_X8_C8_X16_MS4_CS12                  0x00000038
+#define NV50_TIC_0_FMT_Z32_S8_C8_X16_MS4_CS12                  0x00000039
 #define NV50_TIC_0_FMT_Z16                                     0x0000003a
 
 #define NV50_TIC_1                                             0x00000004
@@ -215,6 +217,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NV50_TIC_7_BASE_LEVEL__SHIFT                           0
 #define NV50_TIC_7_MAX_LEVEL__MASK                             0x000000f0
 #define NV50_TIC_7_MAX_LEVEL__SHIFT                            4
+#define NV50_TIC_7_MS_MODE__MASK                               0x0000f000
+#define NV50_TIC_7_MS_MODE__SHIFT                              12
+#define NV50_TIC_7_MS_MODE_MS1                                 0x00000000
+#define NV50_TIC_7_MS_MODE_MS2                                 0x00001000
+#define NV50_TIC_7_MS_MODE_MS4                                 0x00002000
+#define NV50_TIC_7_MS_MODE_MS8                                 0x00003000
+#define NVA3_TIC_7_MS_MODE_MS8_ALT                             0x00004000
+#define NVA3_TIC_7_MS_MODE_MS2_ALT                             0x00005000
+#define NVC0_TIC_7_MS_MODE_UNK6                                        0x00006000
+#define NV50_TIC_7_MS_MODE_MS4_CS4                             0x00008000
+#define NV50_TIC_7_MS_MODE_MS4_CS12                            0x00009000
+#define NV50_TIC_7_MS_MODE_MS8_CS8                             0x0000a000
+#define NVC0_TIC_7_MS_MODE_MS8_CS24                            0x0000b000
 
 #define NV50_TSC__SIZE                                         0x00000020
 #define NV50_TSC_0                                             0x00000000
@@ -276,4 +291,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NV50_TSC_7_BORDER_COLOR_ALPHA__SHIFT                   0
 
 
-#endif /* NV50_TEXTURE_XML */
+#endif /* RNNDB_NV50_TEXTURE_XML */
index d9fb22a..0ff79eb 100644 (file)
@@ -2,7 +2,6 @@
 #include "util/u_format.h"
 
 #include "nv50_context.h"
-#include "nv50_transfer.h"
 
 #include "nv50_defs.xml.h"
 
@@ -13,7 +12,44 @@ struct nv50_transfer {
    uint32_t nblocksy;
 };
 
-static void
+void
+nv50_m2mf_rect_setup(struct nv50_m2mf_rect *rect,
+                     struct pipe_resource *restrict res, unsigned l,
+                     unsigned x, unsigned y, unsigned z)
+{
+   struct nv50_miptree *mt = nv50_miptree(res);
+   const unsigned w = u_minify(res->width0, l);
+   const unsigned h = u_minify(res->height0, l);
+
+   rect->bo = mt->base.bo;
+   rect->domain = mt->base.domain;
+   rect->base = mt->level[l].offset;
+   rect->pitch = mt->level[l].pitch;
+   if (util_format_is_plain(res->format)) {
+      rect->width = w << mt->ms_x;
+      rect->height = h << mt->ms_y;
+      rect->x = x << mt->ms_x;
+      rect->y = y << mt->ms_y;
+   } else {
+      rect->width = util_format_get_nblocksx(res->format, w);
+      rect->height = util_format_get_nblocksy(res->format, h);
+      rect->x = util_format_get_nblocksx(res->format, x);
+      rect->y = util_format_get_nblocksy(res->format, y);
+   }
+   rect->tile_mode = mt->level[l].tile_mode;
+   rect->cpp = util_format_get_blocksize(res->format);
+
+   if (mt->layout_3d) {
+      rect->z = z;
+      rect->depth = u_minify(res->depth0, l);
+   } else {
+      rect->base += z * mt->layer_stride;
+      rect->z = 0;
+      rect->depth = 1;
+   }
+}
+
+void
 nv50_m2mf_transfer_rect(struct pipe_screen *pscreen,
                         const struct nv50_m2mf_rect *dst,
                         const struct nv50_m2mf_rect *src,
@@ -202,26 +238,14 @@ nv50_miptree_transfer_new(struct pipe_context *pctx,
    struct nv50_context *nv50 = nv50_context(pctx);
    struct pipe_screen *pscreen = pctx->screen;
    struct nouveau_device *dev = nv50->screen->base.device;
-   struct nv50_miptree *mt = nv50_miptree(res);
-   struct nv50_miptree_level *lvl = &mt->level[level];
+   const struct nv50_miptree *mt = nv50_miptree(res);
    struct nv50_transfer *tx;
    uint32_t size;
-   uint32_t w, h, d, z, layer;
    int ret;
 
    if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
       return NULL;
 
-   if (mt->layout_3d) {
-      z = box->z;
-      d = u_minify(res->depth0, level);
-      layer = 0;
-   } else {
-      z = 0;
-      d = 1;
-      layer = box->z;
-   }
-
    tx = CALLOC_STRUCT(nv50_transfer);
    if (!tx)
       return NULL;
@@ -232,28 +256,18 @@ nv50_miptree_transfer_new(struct pipe_context *pctx,
    tx->base.usage = usage;
    tx->base.box = *box;
 
-   tx->nblocksx = util_format_get_nblocksx(res->format, box->width);
-   tx->nblocksy = util_format_get_nblocksy(res->format, box->height);
+   if (util_format_is_plain(res->format)) {
+      tx->nblocksx = box->width << mt->ms_x;
+      tx->nblocksy = box->height << mt->ms_x;
+   } else {
+      tx->nblocksx = util_format_get_nblocksx(res->format, box->width);
+      tx->nblocksy = util_format_get_nblocksy(res->format, box->height);
+   }
 
    tx->base.stride = tx->nblocksx * util_format_get_blocksize(res->format);
    tx->base.layer_stride = tx->nblocksy * tx->base.stride;
 
-   w = u_minify(res->width0, level);
-   h = u_minify(res->height0, level);
-
-   tx->rect[0].cpp = tx->rect[1].cpp = util_format_get_blocksize(res->format);
-
-   tx->rect[0].bo = mt->base.bo;
-   tx->rect[0].base = lvl->offset + layer * mt->layer_stride;
-   tx->rect[0].tile_mode = lvl->tile_mode;
-   tx->rect[0].x = util_format_get_nblocksx(res->format, box->x);
-   tx->rect[0].y = util_format_get_nblocksy(res->format, box->y);
-   tx->rect[0].z = z;
-   tx->rect[0].width = util_format_get_nblocksx(res->format, w);
-   tx->rect[0].height = util_format_get_nblocksy(res->format, h);
-   tx->rect[0].depth = d;
-   tx->rect[0].pitch = lvl->pitch;
-   tx->rect[0].domain = NOUVEAU_BO_VRAM;
+   nv50_m2mf_rect_setup(&tx->rect[0], res, level, box->x, box->y, box->z);
 
    size = tx->base.layer_stride;
 
@@ -264,6 +278,7 @@ nv50_miptree_transfer_new(struct pipe_context *pctx,
       return NULL;
    }
 
+   tx->rect[1].cpp = tx->rect[0].cpp;
    tx->rect[1].width = tx->nblocksx;
    tx->rect[1].height = tx->nblocksy;
    tx->rect[1].depth = 1;
@@ -272,6 +287,7 @@ nv50_miptree_transfer_new(struct pipe_context *pctx,
 
    if (usage & PIPE_TRANSFER_READ) {
       unsigned base = tx->rect[0].base;
+      unsigned z = tx->rect[0].z;
       unsigned i;
       for (i = 0; i < box->depth; ++i) {
          nv50_m2mf_transfer_rect(pscreen, &tx->rect[1], &tx->rect[0],
index d3259ef..c58cb00 100644 (file)
@@ -4,22 +4,6 @@
 
 #include "pipe/p_state.h"
 
-struct pipe_transfer *
-nv50_miptree_transfer_new(struct pipe_context *pcontext,
-                          struct pipe_resource *pt,
-                          unsigned level,
-                          unsigned usage,
-                          const struct pipe_box *box);
-void
-nv50_miptree_transfer_del(struct pipe_context *pcontext,
-                          struct pipe_transfer *ptx);
-void *
-nv50_miptree_transfer_map(struct pipe_context *pcontext,
-                          struct pipe_transfer *ptx);
-void
-nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
-                            struct pipe_transfer *ptx);
-
 struct nv50_m2mf_rect {
    struct nouveau_bo *bo;
    uint32_t base;
@@ -35,4 +19,9 @@ struct nv50_m2mf_rect {
    uint16_t cpp;
 };
 
+void
+nv50_m2mf_rect_setup(struct nv50_m2mf_rect *rect,
+                     struct pipe_resource *restrict res, unsigned l,
+                     unsigned x, unsigned y, unsigned z);
+
 #endif
index abdb9ce..1c8347a 100644 (file)
@@ -389,11 +389,11 @@ nv50_prim_gl(unsigned prim)
 static void
 nv50_draw_vbo_flush_notify(struct nouveau_channel *chan)
 {
-   struct nv50_context *nv50 = chan->user_private;
+   struct nv50_screen *screen = chan->user_private;
 
-   nouveau_fence_update(&nv50->screen->base, TRUE);
+   nouveau_fence_update(&screen->base, TRUE);
 
-   nv50_bufctx_emit_relocs(nv50);
+   nv50_bufctx_emit_relocs(screen->cur_ctx);
 }
 
 static void
@@ -404,9 +404,6 @@ nv50_draw_arrays(struct nv50_context *nv50,
    struct nouveau_channel *chan = nv50->screen->base.channel;
    unsigned prim;
 
-   chan->flush_notify = nv50_draw_vbo_flush_notify;
-   chan->user_private = nv50;
-
    prim = nv50_prim_gl(mode);
 
    while (instance_count--) {
@@ -420,8 +417,6 @@ nv50_draw_arrays(struct nv50_context *nv50,
 
       prim |= NV50_3D_VERTEX_BEGIN_GL_INSTANCE_NEXT;
    }
-
-   chan->flush_notify = nv50_default_flush_notify;
 }
 
 static void
@@ -523,9 +518,6 @@ nv50_draw_elements(struct nv50_context *nv50, boolean shorten,
    unsigned prim;
    const unsigned index_size = nv50->idxbuf.index_size;
 
-   chan->flush_notify = nv50_draw_vbo_flush_notify;
-   chan->user_private = nv50;
-
    prim = nv50_prim_gl(mode);
 
    if (index_bias != nv50->state.index_bias) {
@@ -631,8 +623,6 @@ nv50_draw_elements(struct nv50_context *nv50, boolean shorten,
          prim |= NV50_3D_VERTEX_BEGIN_GL_INSTANCE_NEXT;
       }
    }
-
-   chan->flush_notify = nv50_default_flush_notify;
 }
 
 void
@@ -657,10 +647,13 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    if (nv50->vbo_user && !(nv50->dirty & (NV50_NEW_VERTEX | NV50_NEW_ARRAYS)))
       nv50_update_user_vbufs(nv50);
 
-   nv50_state_validate(nv50);
+   nv50_state_validate(nv50, 8); /* 8 as minimum, we use flush_notify here */
+
+   chan->flush_notify = nv50_draw_vbo_flush_notify;
 
    if (nv50->vbo_fifo) {
       nv50_push_vbo(nv50, info);
+      chan->flush_notify = nv50_default_flush_notify;
       return;
    }
 
@@ -712,6 +705,7 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
                          info->mode, info->start, info->count,
                          info->instance_count, info->index_bias);
    }
+   chan->flush_notify = nv50_default_flush_notify;
 
    nv50_release_user_vbufs(nv50);
 }
index 2ca0bc2..6301637 100644 (file)
@@ -146,6 +146,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define NVC0_3D_TFB_ENABLE                                     0x00000744
 
+#define NVC0_3D_SAMPLE_SHADING                                 0x00000754
+#define NVC0_3D_SAMPLE_SHADING_MIN_SAMPLES__MASK               0x0000000f
+#define NVC0_3D_SAMPLE_SHADING_MIN_SAMPLES__SHIFT              0
+#define NVC0_3D_SAMPLE_SHADING_ENABLE                          0x00000010
+
 #define NVC0_3D_LOCAL_BASE                                     0x0000077c
 
 #define NVC0_3D_LOCAL_ADDRESS_HIGH                             0x00000790
@@ -419,7 +424,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT(i0)                      (0x00001160 + 0x4*(i0))
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT__ESIZE                    0x00000004
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT__LEN                      0x00000020
-#define NVC0_3D_VERTEX_ATTRIB_FORMAT_BUFFER__MASK              0x0000003f
+#define NVC0_3D_VERTEX_ATTRIB_FORMAT_BUFFER__MASK              0x0000001f
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_BUFFER__SHIFT             0
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_CONST                     0x00000040
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_OFFSET__MASK              0x001fff80
@@ -438,8 +443,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_SIZE_8_8                  0x03000000
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_SIZE_16                   0x03600000
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_SIZE_8                    0x03a00000
-#define NVC0_3D_VERTEX_ATTRIB_FORMAT_SIZE_2_10_10_10           0x06000000
-#define NVC0_3D_VERTEX_ATTRIB_FORMAT_TYPE__MASK                        0x78000000
+#define NVC0_3D_VERTEX_ATTRIB_FORMAT_SIZE_10_10_10_2           0x06000000
+#define NVC0_3D_VERTEX_ATTRIB_FORMAT_TYPE__MASK                        0x38000000
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_TYPE__SHIFT               27
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_TYPE_SNORM                        0x08000000
 #define NVC0_3D_VERTEX_ATTRIB_FORMAT_TYPE_UNORM                        0x10000000
@@ -819,13 +824,17 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NVC0_3D_LAYER_USE_GP                                   0x00010000
 
 #define NVC0_3D_MULTISAMPLE_MODE                               0x000015d0
-#define NVC0_3D_MULTISAMPLE_MODE_1X                            0x00000000
-#define NVC0_3D_MULTISAMPLE_MODE_2XMS                          0x00000001
-#define NVC0_3D_MULTISAMPLE_MODE_4XMS                          0x00000002
-#define NVC0_3D_MULTISAMPLE_MODE_8XMS                          0x00000003
-#define NVC0_3D_MULTISAMPLE_MODE_4XMS_4XCS                     0x00000008
-#define NVC0_3D_MULTISAMPLE_MODE_4XMS_12XCS                    0x00000009
-#define NVC0_3D_MULTISAMPLE_MODE_8XMS_8XCS                     0x0000000a
+#define NVC0_3D_MULTISAMPLE_MODE_MS1                           0x00000000
+#define NVC0_3D_MULTISAMPLE_MODE_MS2                           0x00000001
+#define NVC0_3D_MULTISAMPLE_MODE_MS4                           0x00000002
+#define NVC0_3D_MULTISAMPLE_MODE_MS8                           0x00000003
+#define NVC0_3D_MULTISAMPLE_MODE_MS8_ALT                       0x00000004
+#define NVC0_3D_MULTISAMPLE_MODE_MS2_ALT                       0x00000005
+#define NVC0_3D_MULTISAMPLE_MODE_UNK6                          0x00000006
+#define NVC0_3D_MULTISAMPLE_MODE_MS4_CS4                       0x00000008
+#define NVC0_3D_MULTISAMPLE_MODE_MS4_CS12                      0x00000009
+#define NVC0_3D_MULTISAMPLE_MODE_MS8_CS8                       0x0000000a
+#define NVC0_3D_MULTISAMPLE_MODE_MS8_CS24                      0x0000000b
 
 #define NVC0_3D_VERTEX_BEGIN_D3D                               0x000015d4
 #define NVC0_3D_VERTEX_BEGIN_D3D_PRIMITIVE__MASK               0x0fffffff
index 2f2a3da..360afbb 100644 (file)
@@ -89,10 +89,8 @@ nvc0_destroy(struct pipe_context *pipe)
 
    draw_destroy(nvc0->draw);
 
-   if (nvc0->screen->cur_ctx == nvc0) {
-      nvc0->screen->base.channel->user_private = NULL;
+   if (nvc0->screen->cur_ctx == nvc0)
       nvc0->screen->cur_ctx = NULL;
-   }
 
    FREE(nvc0);
 }
@@ -100,13 +98,13 @@ nvc0_destroy(struct pipe_context *pipe)
 void
 nvc0_default_flush_notify(struct nouveau_channel *chan)
 {
-   struct nvc0_context *nvc0 = chan->user_private;
+   struct nvc0_screen *screen = chan->user_private;
 
-   if (!nvc0)
+   if (!screen)
       return;
 
-   nouveau_fence_update(&nvc0->screen->base, TRUE);
-   nouveau_fence_next(&nvc0->screen->base);
+   nouveau_fence_update(&screen->base, TRUE);
+   nouveau_fence_next(&screen->base);
 }
 
 struct pipe_context *
@@ -141,7 +139,6 @@ nvc0_create(struct pipe_screen *pscreen, void *priv)
 
    if (!screen->cur_ctx)
       screen->cur_ctx = nvc0;
-   screen->base.channel->user_private = nvc0;
    screen->base.channel->flush_notify = nvc0_default_flush_notify;
 
    nvc0_init_query_functions(nvc0);
@@ -153,6 +150,8 @@ nvc0_create(struct pipe_screen *pscreen, void *priv)
    assert(nvc0->draw);
    draw_set_rasterize_stage(nvc0->draw, nvc0_draw_render_stage(nvc0));
 
+   nouveau_context_init_vdec(&nvc0->base);
+
    return pipe;
 }
 
@@ -169,6 +168,7 @@ nvc0_bufctx_add_resident(struct nvc0_context *nvc0, int ctx,
 
    if (!resource->bo)
       return;
+   nvc0->residents_size += sizeof(struct resident);
 
    /* We don't need to reference the resource here, it will be referenced
     * in the context/state, and bufctx will be reset when state changes.
@@ -190,6 +190,7 @@ nvc0_bufctx_del_resident(struct nvc0_context *nvc0, int ctx,
          top = util_dynarray_pop_ptr(&nvc0->residents[ctx], struct resident);
          if (rsd != top)
             *rsd = *top;
+         nvc0->residents_size -= sizeof(struct resident);
          break;
       }
    }
@@ -202,11 +203,15 @@ nvc0_bufctx_emit_relocs(struct nvc0_context *nvc0)
    struct util_dynarray *array;
    unsigned ctx, i, n;
 
+   n  = nvc0->residents_size / sizeof(struct resident);
+   n += NVC0_SCREEN_RESIDENT_BO_COUNT;
+
+   MARK_RING(nvc0->screen->base.channel, n, n);
+
    for (ctx = 0; ctx < NVC0_BUFCTX_COUNT; ++ctx) {
       array = &nvc0->residents[ctx];
 
       n = array->size / sizeof(struct resident);
-      MARK_RING(nvc0->screen->base.channel, n, n);
       for (i = 0; i < n; ++i) {
          rsd = util_dynarray_element(array, struct resident, i);
 
index f97141d..bf89164 100644 (file)
@@ -19,6 +19,8 @@
 #include "nvc0_program.h"
 #include "nvc0_resource.h"
 
+#include "nv50/nv50_transfer.h"
+
 #include "nouveau/nouveau_context.h"
 
 #include "nvc0_3ddefs.xml.h"
@@ -62,6 +64,7 @@ struct nvc0_context {
    struct nvc0_screen *screen;
 
    struct util_dynarray residents[NVC0_BUFCTX_COUNT];
+   unsigned residents_size;
 
    uint32_t dirty;
 
@@ -136,20 +139,6 @@ nvc0_context(struct pipe_context *pipe)
    return (struct nvc0_context *)pipe;
 }
 
-struct nvc0_surface {
-   struct pipe_surface base;
-   uint32_t offset;
-   uint32_t width;
-   uint16_t height;
-   uint16_t depth;
-};
-
-static INLINE struct nvc0_surface *
-nvc0_surface(struct pipe_surface *ps)
-{
-   return (struct nvc0_surface *)ps;
-}
-
 /* nvc0_context.c */
 struct pipe_context *nvc0_create(struct pipe_screen *, void *);
 
@@ -163,6 +152,7 @@ void nvc0_bufctx_del_resident(struct nvc0_context *, int ctx,
 static INLINE void
 nvc0_bufctx_reset(struct nvc0_context *nvc0, int ctx)
 {
+   nvc0->residents_size -= nvc0->residents[ctx].size;
    util_dynarray_resize(&nvc0->residents[ctx], 0);
 }
 
@@ -207,6 +197,11 @@ nvc0_create_sampler_view(struct pipe_context *,
 
 /* nvc0_transfer.c */
 void
+nvc0_m2mf_transfer_rect(struct pipe_screen *pscreen,
+                        const struct nv50_m2mf_rect *dst,
+                        const struct nv50_m2mf_rect *src,
+                        uint32_t nblocksx, uint32_t nblocksy);
+void
 nvc0_m2mf_push_linear(struct nouveau_context *nv,
                      struct nouveau_bo *dst, unsigned offset, unsigned domain,
                      unsigned size, void *data);
index 81077a7..8dd4419 100644 (file)
@@ -66,33 +66,33 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 {
    /* COMMON FORMATS */
 
-   [PIPE_FORMAT_B8G8R8A8_UNORM] = { NV50_SURFACE_FORMAT_A8R8G8B8_UNORM,
+   [PIPE_FORMAT_B8G8R8A8_UNORM] = { NV50_SURFACE_FORMAT_BGRA8_UNORM,
     A_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 1),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
-   [PIPE_FORMAT_B8G8R8X8_UNORM] = { NV50_SURFACE_FORMAT_X8R8G8B8_UNORM,
+   [PIPE_FORMAT_B8G8R8X8_UNORM] = { NV50_SURFACE_FORMAT_BGRX8_UNORM,
     A_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 1),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
-   [PIPE_FORMAT_B8G8R8A8_SRGB] = { NV50_SURFACE_FORMAT_A8R8G8B8_SRGB,
+   [PIPE_FORMAT_B8G8R8A8_SRGB] = { NV50_SURFACE_FORMAT_BGRA8_SRGB,
     A_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 1),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_B8G8R8X8_SRGB] = { NV50_SURFACE_FORMAT_X8R8G8B8_SRGB,
+   [PIPE_FORMAT_B8G8R8X8_SRGB] = { NV50_SURFACE_FORMAT_BGRX8_SRGB,
     A_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 1),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_B5G6R5_UNORM] = { NV50_SURFACE_FORMAT_R5G6B5_UNORM,
+   [PIPE_FORMAT_B5G6R5_UNORM] = { NV50_SURFACE_FORMAT_B5G6R5_UNORM,
     B_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 5_6_5, 1),
     SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
-   [PIPE_FORMAT_B5G5R5A1_UNORM] = { NV50_SURFACE_FORMAT_A1R5G5B5_UNORM,
-    B_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 1_5_5_5, 1),
+   [PIPE_FORMAT_B5G5R5A1_UNORM] = { NV50_SURFACE_FORMAT_BGR5_A1_UNORM,
+    B_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 5_5_5_1, 1),
     SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
-   [PIPE_FORMAT_B5G5R5X1_UNORM] = { 0,
-    B_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 1_5_5_5, 1),
-    SAMPLER_VIEW | SCANOUT },
+   [PIPE_FORMAT_B5G5R5X1_UNORM] = { NV50_SURFACE_FORMAT_BGR5_X1_UNORM,
+    B_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 5_5_5_1, 1),
+    SAMPLER_VIEW | RENDER_TARGET | SCANOUT },
 
    [PIPE_FORMAT_B4G4R4A4_UNORM] = { 0,
     B_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 4_4_4_4, 1),
@@ -102,12 +102,12 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
     B_(C2, C1, C0, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 4_4_4_4, 1),
     SAMPLER_VIEW },
 
-   [PIPE_FORMAT_R10G10B10A2_UNORM] = { NV50_SURFACE_FORMAT_A2B10G10R10_UNORM,
-    A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 2_10_10_10, 0),
+   [PIPE_FORMAT_R10G10B10A2_UNORM] = { NV50_SURFACE_FORMAT_RGB10_A2_UNORM,
+    A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 10_10_10_2, 0),
     SAMPLER_VIEW | RENDER_TARGET | VERTEX_BUFFER | SCANOUT },
 
-   [PIPE_FORMAT_B10G10R10A2_UNORM] = { NV50_SURFACE_FORMAT_A2R10G10B10_UNORM,
-    A_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 2_10_10_10, 1),
+   [PIPE_FORMAT_B10G10R10A2_UNORM] = { NV50_SURFACE_FORMAT_BGR10_A2_UNORM,
+    A_(C2, C1, C0, C3, UNORM, UNORM, UNORM, UNORM, 10_10_10_2, 1),
     SAMPLER_VIEW | RENDER_TARGET | VERTEX_BUFFER },
 
    /* DEPTH/STENCIL FORMATS */
@@ -116,25 +116,24 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
     B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, Z16, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
-   [PIPE_FORMAT_Z24_UNORM_S8_USCALED] = { NV50_ZETA_FORMAT_S8Z24_UNORM,
-    B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, S8Z24, 0),
+   [PIPE_FORMAT_Z24_UNORM_S8_USCALED] = { NV50_ZETA_FORMAT_Z24_S8_UNORM,
+    B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, Z24_S8, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
-   [PIPE_FORMAT_Z24X8_UNORM] = { NV50_ZETA_FORMAT_X8Z24_UNORM,
-    B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, X8Z24, 0),
+   [PIPE_FORMAT_Z24X8_UNORM] = { NV50_ZETA_FORMAT_Z24_X8_UNORM,
+    B_(C0, C0, C0, ONE_FLOAT, UNORM, UINT, UINT, UINT, Z24_X8, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
-   [PIPE_FORMAT_S8_USCALED_Z24_UNORM] = { NV50_ZETA_FORMAT_Z24S8_UNORM,
-    B_(C1, C1, C1, ONE_FLOAT, UINT, UNORM, UINT, UINT, Z24S8, 0),
+   [PIPE_FORMAT_S8_USCALED_Z24_UNORM] = { NV50_ZETA_FORMAT_S8_Z24_UNORM,
+    B_(C1, C1, C1, ONE_FLOAT, UINT, UNORM, UINT, UINT, S8_Z24, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
    [PIPE_FORMAT_Z32_FLOAT] = { NV50_ZETA_FORMAT_Z32_FLOAT,
     B_(C0, C0, C0, ONE_FLOAT, FLOAT, UINT, UINT, UINT, Z32, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
-   [PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED] = {
-    NV50_ZETA_FORMAT_Z32_FLOAT_X24S8_UNORM,
-    B_(C0, C0, C0, ONE_FLOAT, FLOAT, UINT, UINT, UINT, X24S8Z32, 0),
+   [PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED] = { NV50_ZETA_FORMAT_Z32_S8_X24_FLOAT,
+    B_(C0, C0, C0, ONE_FLOAT, FLOAT, UINT, UINT, UINT, Z32_S8_X24, 0),
     SAMPLER_VIEW | DEPTH_STENCIL },
 
    /* LUMINANCE, ALPHA, INTENSITY */
@@ -283,15 +282,15 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    /* FLOAT 16 */
 
-   [PIPE_FORMAT_R16G16B16A16_FLOAT] = { NV50_SURFACE_FORMAT_R16G16B16A16_FLOAT,
+   [PIPE_FORMAT_R16G16B16A16_FLOAT] = { NV50_SURFACE_FORMAT_RGBA16_FLOAT,
     A_(C0, C1, C2, C3, FLOAT, FLOAT, FLOAT, FLOAT, 16_16_16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R16G16B16_FLOAT] = { NV50_SURFACE_FORMAT_R16G16B16X16_FLOAT,
+   [PIPE_FORMAT_R16G16B16_FLOAT] = { NV50_SURFACE_FORMAT_RGBX16_FLOAT,
     A_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 16_16_16, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R16G16_FLOAT] = { NV50_SURFACE_FORMAT_R16G16_FLOAT,
+   [PIPE_FORMAT_R16G16_FLOAT] = { NV50_SURFACE_FORMAT_RG16_FLOAT,
     A_(C0, C1, ZERO, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -301,15 +300,15 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    /* FLOAT 32 */
 
-   [PIPE_FORMAT_R32G32B32A32_FLOAT] = { NV50_SURFACE_FORMAT_R32G32B32A32_FLOAT,
+   [PIPE_FORMAT_R32G32B32A32_FLOAT] = { NV50_SURFACE_FORMAT_RGBA32_FLOAT,
     A_(C0, C1, C2, C3, FLOAT, FLOAT, FLOAT, FLOAT, 32_32_32_32, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R32G32B32_FLOAT] = { NV50_SURFACE_FORMAT_R32G32B32X32_FLOAT,
+   [PIPE_FORMAT_R32G32B32_FLOAT] = { NV50_SURFACE_FORMAT_RGBX32_FLOAT,
     A_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 32_32_32, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R32G32_FLOAT] = { NV50_SURFACE_FORMAT_R32G32_FLOAT,
+   [PIPE_FORMAT_R32G32_FLOAT] = { NV50_SURFACE_FORMAT_RG32_FLOAT,
     A_(C0, C1, ZERO, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 32_32, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -319,12 +318,12 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    /* ODD FORMATS */
 
-   [PIPE_FORMAT_R11G11B10_FLOAT] = { NV50_SURFACE_FORMAT_B10G11R11_FLOAT,
-    B_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 10_11_11, 0),
+   [PIPE_FORMAT_R11G11B10_FLOAT] = { NV50_SURFACE_FORMAT_R11G11B10_FLOAT,
+    B_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 11_11_10, 0),
     SAMPLER_VIEW | RENDER_TARGET | VERTEX_BUFFER },
 
    [PIPE_FORMAT_R9G9B9E5_FLOAT] = { 0,
-    B_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, E5_9_9_9, 0),
+    B_(C0, C1, C2, ONE_FLOAT, FLOAT, FLOAT, FLOAT, FLOAT, 9_9_9_E5, 0),
     SAMPLER_VIEW },
 
    /* SNORM 32 */
@@ -335,7 +334,7 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    [PIPE_FORMAT_R32G32B32_SNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 32_32_32, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
    [PIPE_FORMAT_R32G32_SNORM] = { 0,
     A_(C0, C1, ZERO, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 32_32, 0),
@@ -353,7 +352,7 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    [PIPE_FORMAT_R32G32B32_UNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 32_32_32, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
    [PIPE_FORMAT_R32G32_UNORM] = { 0,
     A_(C0, C1, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 32_32, 0),
@@ -365,15 +364,15 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    /* SNORM 16 */
 
-   [PIPE_FORMAT_R16G16B16A16_SNORM] = { NV50_SURFACE_FORMAT_R16G16B16A16_SNORM,
+   [PIPE_FORMAT_R16G16B16A16_SNORM] = { NV50_SURFACE_FORMAT_RGBA16_SNORM,
     A_(C0, C1, C2, C3, SNORM, SNORM, SNORM, SNORM, 16_16_16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
    [PIPE_FORMAT_R16G16B16_SNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 16_16_16, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R16G16_SNORM] = { NV50_SURFACE_FORMAT_R16G16_SNORM,
+   [PIPE_FORMAT_R16G16_SNORM] = { NV50_SURFACE_FORMAT_RG16_SNORM,
     A_(C0, C1, ZERO, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -383,15 +382,15 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    /* UNORM 16 */
 
-   [PIPE_FORMAT_R16G16B16A16_UNORM] = { NV50_SURFACE_FORMAT_R16G16B16A16_UNORM,
+   [PIPE_FORMAT_R16G16B16A16_UNORM] = { NV50_SURFACE_FORMAT_RGBA16_UNORM,
     A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 16_16_16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
    [PIPE_FORMAT_R16G16B16_UNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 16_16_16, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R16G16_UNORM] = { NV50_SURFACE_FORMAT_R16G16_UNORM,
+   [PIPE_FORMAT_R16G16_UNORM] = { NV50_SURFACE_FORMAT_RG16_UNORM,
     A_(C0, C1, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 16_16, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -401,15 +400,15 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    /* SNORM 8 */
 
-   [PIPE_FORMAT_R8G8B8A8_SNORM] = { NV50_SURFACE_FORMAT_A8B8G8R8_SNORM,
+   [PIPE_FORMAT_R8G8B8A8_SNORM] = { NV50_SURFACE_FORMAT_RGBA8_SNORM,
     A_(C0, C1, C2, C3, SNORM, SNORM, SNORM, SNORM, 8_8_8_8, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
    [PIPE_FORMAT_R8G8B8_SNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 8_8_8, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R8G8_SNORM] = { NV50_SURFACE_FORMAT_R8G8_SNORM,
+   [PIPE_FORMAT_R8G8_SNORM] = { NV50_SURFACE_FORMAT_RG8_SNORM,
     A_(C0, C1, ZERO, ONE_FLOAT, SNORM, SNORM, SNORM, SNORM, 8_8, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -419,23 +418,23 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
 
    /* UNORM 8 */
 
-   [PIPE_FORMAT_R8G8B8A8_UNORM] = { NV50_SURFACE_FORMAT_A8B8G8R8_UNORM,
+   [PIPE_FORMAT_R8G8B8A8_UNORM] = { NV50_SURFACE_FORMAT_RGBA8_UNORM,
     A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R8G8B8A8_SRGB] = { NV50_SURFACE_FORMAT_A8B8G8R8_SRGB,
-    A_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 0),
+   [PIPE_FORMAT_R8G8B8A8_SRGB] = { NV50_SURFACE_FORMAT_RGBA8_SRGB,
+    B_(C0, C1, C2, C3, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 0),
     SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R8G8B8_UNORM] = { NV50_SURFACE_FORMAT_X8B8G8R8_UNORM,
-    A_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8, 0),
-    VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
+   [PIPE_FORMAT_R8G8B8X8_UNORM] = { NV50_SURFACE_FORMAT_RGBX8_UNORM,
+    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8_8, 0),
+    SAMPLER_VIEW | RENDER_TARGET },
 
-   [PIPE_FORMAT_R8G8B8_SRGB] = { NV50_SURFACE_FORMAT_X8B8G8R8_SRGB,
+   [PIPE_FORMAT_R8G8B8_UNORM] = { 0,
     A_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8_8, 0),
-    SAMPLER_VIEW | RENDER_TARGET },
+    VERTEX_BUFFER },
 
-   [PIPE_FORMAT_R8G8_UNORM] = { NV50_SURFACE_FORMAT_R8G8_UNORM,
+   [PIPE_FORMAT_R8G8_UNORM] = { NV50_SURFACE_FORMAT_RG8_UNORM,
     A_(C0, C1, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, 8_8, 0),
     VERTEX_BUFFER | SAMPLER_VIEW | RENDER_TARGET },
 
@@ -554,11 +553,11 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
    /* OTHER FORMATS */
 
    [PIPE_FORMAT_R8G8_B8G8_UNORM] = { 0,
-    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, C1_C2_C1_C0, 0),
+    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, U8_YA8_V8_YB8, 0),
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_G8R8_G8B8_UNORM] = { 0,
-    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, C2_C1_C0_C1, 0),
+    B_(C0, C1, C2, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, YA8_U8_YB8_V8, 0),
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_R8SG8SB8UX8U_NORM] = { 0,
@@ -566,11 +565,11 @@ const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_R5SG5SB6U_NORM] = { 0,
-    B_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, UNORM, UNORM, 6_5_5, 0),
+    B_(C0, C1, C2, ONE_FLOAT, SNORM, SNORM, UNORM, UNORM, 5_5_6, 0),
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_R1_UNORM] = { 0,
-    B_(C0, ZERO, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, BITMAP_8X8, 0),
+    B_(C0, ZERO, ZERO, ONE_FLOAT, UNORM, UNORM, UNORM, UNORM, BITMAP, 0),
     SAMPLER_VIEW },
 
    [PIPE_FORMAT_A8B8G8R8_UNORM] = { 0,
index bced324..a72ddf3 100644 (file)
 
 #include "nvc0_context.h"
 #include "nvc0_resource.h"
-#include "nvc0_transfer.h"
 
-static INLINE uint32_t
-get_tile_dims(unsigned nx, unsigned ny, unsigned nz)
+uint32_t
+nvc0_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz)
 {
    uint32_t tile_mode = 0x000;
 
@@ -57,66 +56,188 @@ get_tile_dims(unsigned nx, unsigned ny, unsigned nz)
    return tile_mode | 0x100;
 }
 
-uint32_t
-nvc0_miptree_zslice_offset(struct nvc0_miptree *mt, unsigned l, unsigned z)
+static uint32_t
+nvc0_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed)
 {
-   unsigned nblocksy; /* height of texture level aligned to tile height */
+   const unsigned ms = util_logbase2(mt->base.base.nr_samples);
 
-   unsigned stride_2d; /* to next slice within a 3D tile */
-   unsigned stride_3d; /* to slice in the next (in z direction !) 3D tile */
+   uint32_t tile_flags;
 
-   unsigned tile_d_shift = NVC0_TILE_DIM_SHIFT(mt->level[l].tile_mode, 2);
-   unsigned tile_d = 1 << tile_d_shift;
+   compressed = FALSE; /* not yet supported */
 
-   nblocksy = util_format_get_nblocksy(mt->base.base.format,
-                                       u_minify(mt->base.base.height0, l));
+   if (mt->base.base.bind & PIPE_BIND_CURSOR)
+      return NOUVEAU_BO_TILE_SCANOUT;
 
-   nblocksy = align(nblocksy, NVC0_TILE_HEIGHT(mt->level[l].tile_mode));
+   switch (mt->base.base.format) {
+   case PIPE_FORMAT_Z16_UNORM:
+      if (compressed)
+         tile_flags = 0x0200 + (ms << 8);
+      else
+         tile_flags = 0x0100;
+      break;
+   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+      if (compressed)
+         tile_flags = 0x5100 + (ms << 8);
+      else
+         tile_flags = 0x4600;
+      break;
+   case PIPE_FORMAT_Z24X8_UNORM:
+   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+      if (compressed)
+         tile_flags = 0x1700 + (ms << 8);
+      else
+         tile_flags = 0x1100;
+      break;
+   case PIPE_FORMAT_Z32_FLOAT:
+      if (compressed)
+         tile_flags = 0x8600 + (ms << 8);
+      else
+         tile_flags = 0x7b00;
+      break;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      if (compressed)
+         tile_flags = 0xce00 + (ms << 8);
+      else
+         tile_flags = 0xc300;
+      break;
+   default:
+      switch (util_format_get_blocksizebits(mt->base.base.format)) {
+      case 128:
+         if (compressed)
+            tile_flags = 0xf400 + (ms << 9);
+         else
+            tile_flags = 0xfe00;
+         break;
+      case 64:
+         if (compressed) {
+            switch (ms) {
+            case 0: tile_flags = 0xe600; break;
+            case 1: tile_flags = 0xeb00; break;
+            case 2: tile_flags = 0xed00; break;
+            case 3: tile_flags = 0xf200; break;
+            default:
+               return 0;
+            }
+         } else {
+            tile_flags = 0xfe00;
+         }
+         break;
+      case 32:
+         if (compressed) {
+            switch (ms) {
+            case 0: tile_flags = 0xdb00; break;
+            case 1: tile_flags = 0xdd00; break;
+            case 2: tile_flags = 0xdf00; break;
+            case 3: tile_flags = 0xe400; break;
+            default:
+               return 0;
+            }
+         } else {
+            tile_flags = 0xfe00;
+         }
+         break;
+      case 16:
+      case 8:
+         tile_flags = 0xfe00;
+         break;
+      default:
+         return 0;
+      }
+      break;
+   }
 
-   stride_2d = NVC0_TILE_SIZE_2D(mt->level[l].tile_mode);
+   if (mt->base.base.bind & PIPE_BIND_SCANOUT)
+      tile_flags |= NOUVEAU_BO_TILE_SCANOUT;
 
-   stride_3d = (nblocksy * mt->level[l].pitch) << tile_d_shift;
+   return tile_flags;
+}
 
-   return (z & (tile_d - 1)) * stride_2d + (z >> tile_d_shift) * stride_3d;
+static INLINE boolean
+nvc0_miptree_init_ms_mode(struct nv50_miptree *mt)
+{
+   switch (mt->base.base.nr_samples) {
+   case 8:
+      mt->ms_mode = NVC0_3D_MULTISAMPLE_MODE_MS8;
+      mt->ms_x = 2;
+      mt->ms_y = 1;
+      break;
+   case 4:
+      mt->ms_mode = NVC0_3D_MULTISAMPLE_MODE_MS4;
+      mt->ms_x = 1;
+      mt->ms_y = 1;
+      break;
+   case 2:
+      mt->ms_mode = NVC0_3D_MULTISAMPLE_MODE_MS2;
+      mt->ms_x = 1;
+      break;
+   case 1:
+   case 0:
+      mt->ms_mode = NVC0_3D_MULTISAMPLE_MODE_MS1;
+      break;
+   default:
+      NOUVEAU_ERR("invalid nr_samples: %u\n", mt->base.base.nr_samples);
+      return FALSE;
+   }
+   return TRUE;
 }
 
+boolean
+nv50_miptree_init_layout_linear(struct nv50_miptree *);
+
 static void
-nvc0_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt)
+nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt)
 {
-   struct nvc0_miptree *mt = nvc0_miptree(pt);
+   struct pipe_resource *pt = &mt->base.base;
+   unsigned w, h, d, l;
+   const unsigned blocksize = util_format_get_blocksize(pt->format);
 
-   nouveau_screen_bo_release(pscreen, mt->base.bo);
+   mt->layout_3d = pt->target == PIPE_TEXTURE_3D;
 
-   FREE(mt);
-}
+   w = pt->width0 << mt->ms_x;
+   h = pt->height0 << mt->ms_y;
 
-static boolean
-nvc0_miptree_get_handle(struct pipe_screen *pscreen,
-                        struct pipe_resource *pt,
-                        struct winsys_handle *whandle)
-{
-   struct nvc0_miptree *mt = nvc0_miptree(pt);
-   unsigned stride;
+   /* For 3D textures, a mipmap is spanned by all the layers, for array
+    * textures and cube maps, each layer contains its own mipmaps.
+    */
+   d = mt->layout_3d ? pt->depth0 : 1;
 
-   if (!mt || !mt->base.bo)
-      return FALSE;
+   for (l = 0; l <= pt->last_level; ++l) {
+      struct nv50_miptree_level *lvl = &mt->level[l];
+      unsigned tsx, tsy, tsz;
+      unsigned nbx = util_format_get_nblocksx(pt->format, w);
+      unsigned nby = util_format_get_nblocksy(pt->format, h);
+
+      lvl->offset = mt->total_size;
+
+      lvl->tile_mode = nvc0_tex_choose_tile_dims(nbx, nby, d);
+
+      tsx = NVC0_TILE_SIZE_X(lvl->tile_mode); /* x is tile row pitch in bytes */
+      tsy = NVC0_TILE_SIZE_Y(lvl->tile_mode);
+      tsz = NVC0_TILE_SIZE_Z(lvl->tile_mode);
 
-   stride = util_format_get_stride(mt->base.base.format,
-                                   mt->base.base.width0);
+      lvl->pitch = align(nbx * blocksize, tsx);
 
-   return nouveau_screen_bo_get_handle(pscreen,
-                                       mt->base.bo,
-                                       stride,
-                                       whandle);
+      mt->total_size += lvl->pitch * align(nby, tsy) * align(d, tsz);
+
+      w = u_minify(w, 1);
+      h = u_minify(h, 1);
+      d = u_minify(d, 1);
+   }
+
+   if (pt->array_size > 1) {
+      mt->layer_stride = align(mt->total_size,
+                               NVC0_TILE_SIZE(mt->level[0].tile_mode));
+      mt->total_size = mt->layer_stride * pt->array_size;
+   }
 }
 
 const struct u_resource_vtbl nvc0_miptree_vtbl =
 {
-   nvc0_miptree_get_handle,         /* get_handle */
-   nvc0_miptree_destroy,            /* resource_destroy */
+   nv50_miptree_get_handle,         /* get_handle */
+   nv50_miptree_destroy,            /* resource_destroy */
    nvc0_miptree_transfer_new,       /* get_transfer */
    nvc0_miptree_transfer_del,       /* transfer_destroy */
-   nvc0_miptree_transfer_map,        /* transfer_map */
+   nvc0_miptree_transfer_map,       /* transfer_map */
    u_default_transfer_flush_region, /* transfer_flush_region */
    nvc0_miptree_transfer_unmap,     /* transfer_unmap */
    u_default_transfer_inline_write  /* transfer_inline_write */
@@ -127,10 +248,9 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
                     const struct pipe_resource *templ)
 {
    struct nouveau_device *dev = nouveau_screen(pscreen)->device;
-   struct nvc0_miptree *mt = CALLOC_STRUCT(nvc0_miptree);
+   struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
    struct pipe_resource *pt = &mt->base.base;
    int ret;
-   unsigned w, h, d, l, alloc_size;
    uint32_t tile_flags;
 
    if (!mt)
@@ -141,84 +261,23 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
    pipe_reference_init(&pt->reference, 1);
    pt->screen = pscreen;
 
-   mt->layout_3d = pt->target == PIPE_TEXTURE_3D;
-
-   w = pt->width0;
-   h = pt->height0;
-   d = mt->layout_3d ? pt->depth0 : 1;
-
-   switch (pt->format) {
-   case PIPE_FORMAT_Z16_UNORM:
-      tile_flags = 0x0700; /* COMPRESSED */
-      tile_flags = 0x0100; /* NORMAL */
-      break;
-   case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-      tile_flags = 0x5300; /* MSAA 4, COMPRESSED */
-      tile_flags = 0x4600; /* NORMAL */
-      break;
-   case PIPE_FORMAT_Z24X8_UNORM:
-   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-      tile_flags = 0x1100; /* NORMAL */
-      if (w * h >= 128 * 128 && 0)
-         tile_flags = 0x1700; /* COMPRESSED, requires magic */
-      break;
-   case PIPE_FORMAT_R32G32B32A32_FLOAT:
-      tile_flags = 0xf500; /* COMPRESSED */
-      tile_flags = 0xf700; /* MSAA 2 */
-      tile_flags = 0xf900; /* MSAA 4 */
-      tile_flags = 0xfe00; /* NORMAL */
-      break;
-   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
-      tile_flags = 0xce00; /* COMPRESSED */
-      tile_flags = 0xcf00; /* MSAA 2, COMPRESSED */
-      tile_flags = 0xd000; /* MSAA 4, COMPRESSED */
-      tile_flags = 0xc300; /* NORMAL */
-      break;
-   case PIPE_FORMAT_R16G16B16A16_UNORM:
-      tile_flags = 0xe900; /* COMPRESSED */
-      tile_flags = 0xfe00; /* NORMAL */
-      break;
-   default:
-      tile_flags = 0xe000; /* MSAA 4, COMPRESSED 32 BIT */
-      tile_flags = 0xfe00; /* NORMAL 32 BIT */
-      if (w * h >= 128 * 128 && 0)
-         tile_flags = 0xdb00; /* COMPRESSED 32 BIT, requires magic */
-      break;
-   }
-
-   /* For 3D textures, a mipmap is spanned by all the layers, for array
-    * textures and cube maps, each layer contains its own mipmaps.
-    */
-   for (l = 0; l <= pt->last_level; ++l) {
-      struct nvc0_miptree_level *lvl = &mt->level[l];
-      unsigned nbx = util_format_get_nblocksx(pt->format, w);
-      unsigned nby = util_format_get_nblocksy(pt->format, h);
-      unsigned blocksize = util_format_get_blocksize(pt->format);
-
-      lvl->offset = mt->total_size;
-      lvl->tile_mode = get_tile_dims(nbx, nby, d);
-      lvl->pitch = align(nbx * blocksize, NVC0_TILE_PITCH(lvl->tile_mode));
+   tile_flags = nvc0_mt_choose_storage_type(mt, TRUE);
 
-      mt->total_size += lvl->pitch *
-         align(nby, NVC0_TILE_HEIGHT(lvl->tile_mode)) *
-         align(d, NVC0_TILE_DEPTH(lvl->tile_mode));
-
-      w = u_minify(w, 1);
-      h = u_minify(h, 1);
-      d = u_minify(d, 1);
+   if (!nvc0_miptree_init_ms_mode(mt)) {
+      FREE(mt);
+      return NULL;
    }
 
-   if (pt->array_size > 1) {
-      mt->layer_stride = align(mt->total_size,
-                               NVC0_TILE_SIZE(mt->level[0].tile_mode));
-      mt->total_size = mt->layer_stride * pt->array_size;
+   if (tile_flags & NOUVEAU_BO_TILE_LAYOUT_MASK) {
+      nvc0_miptree_init_layout_tiled(mt);
+   } else
+   if (!nv50_miptree_init_layout_linear(mt)) {
+      FREE(mt);
+      return NULL;
    }
 
-   alloc_size = mt->total_size;
-   if (tile_flags == 0x1700)
-      alloc_size *= 3; /* HiZ, XXX: correct size */
-
-   ret = nouveau_bo_new_tile(dev, NOUVEAU_BO_VRAM, 256, alloc_size,
+   ret = nouveau_bo_new_tile(dev, NOUVEAU_BO_VRAM, 4096,
+                             mt->total_size,
                              mt->level[0].tile_mode, tile_flags,
                              &mt->base.bo);
    if (ret) {
@@ -230,44 +289,26 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
    return pt;
 }
 
-struct pipe_resource *
-nvc0_miptree_from_handle(struct pipe_screen *pscreen,
-                         const struct pipe_resource *templ,
-                         struct winsys_handle *whandle)
+/* Offset of zslice @z from start of level @l. */
+INLINE unsigned
+nvc0_mt_zslice_offset(const struct nv50_miptree *mt, unsigned l, unsigned z)
 {
-   struct nvc0_miptree *mt;
-   unsigned stride;
-
-   /* only supports 2D, non-mipmapped textures for the moment */
-   if ((templ->target != PIPE_TEXTURE_2D &&
-        templ->target != PIPE_TEXTURE_RECT) ||
-       templ->last_level != 0 ||
-       templ->depth0 != 1 ||
-       templ->array_size > 1)
-      return NULL;
+   const struct pipe_resource *pt = &mt->base.base;
 
-   mt = CALLOC_STRUCT(nvc0_miptree);
-   if (!mt)
-      return NULL;
+   unsigned tds = NVC0_TILE_SHIFT_Z(mt->level[l].tile_mode);
+   unsigned ths = NVC0_TILE_SHIFT_Y(mt->level[l].tile_mode);
 
-   mt->base.bo = nouveau_screen_bo_from_handle(pscreen, whandle, &stride);
-   if (mt->base.bo == NULL) {
-      FREE(mt);
-      return NULL;
-   }
+   unsigned nby = util_format_get_nblocksy(pt->format,
+                                           u_minify(pt->height0, l));
 
-   mt->base.base = *templ;
-   mt->base.vtbl = &nvc0_miptree_vtbl;
-   pipe_reference_init(&mt->base.base.reference, 1);
-   mt->base.base.screen = pscreen;
-   mt->level[0].pitch = stride;
-   mt->level[0].offset = 0;
-   mt->level[0].tile_mode = mt->base.bo->tile_mode;
-
-   /* no need to adjust bo reference count */
-   return &mt->base.base;
-}
+   /* to next 2D tile slice within a 3D tile */
+   unsigned stride_2d = NVC0_TILE_SIZE_2D(mt->level[l].tile_mode);
+
+   /* to slice in the next (in z direction) 3D tile */
+   unsigned stride_3d = (align(nby, (1 << ths)) * mt->level[l].pitch) << tds;
 
+   return (z & (1 << (tds - 1))) * stride_2d + (z >> tds) * stride_3d;
+}
 
 /* Surface functions.
  */
@@ -277,43 +318,9 @@ nvc0_miptree_surface_new(struct pipe_context *pipe,
                          struct pipe_resource *pt,
                          const struct pipe_surface *templ)
 {
-   struct nvc0_miptree *mt = nvc0_miptree(pt); /* guaranteed */
-   struct nvc0_surface *ns;
-   struct pipe_surface *ps;
-   struct nvc0_miptree_level *lvl = &mt->level[templ->u.tex.level];
-
-   ns = CALLOC_STRUCT(nvc0_surface);
+   struct nv50_surface *ns = nv50_surface_from_miptree(nv50_miptree(pt), templ);
    if (!ns)
       return NULL;
-   ps = &ns->base;
-
-   pipe_reference_init(&ps->reference, 1);
-   pipe_resource_reference(&ps->texture, pt);
-   ps->context = pipe;
-   ps->format = templ->format;
-   ps->usage = templ->usage;
-   ps->u.tex.level = templ->u.tex.level;
-   ps->u.tex.first_layer = templ->u.tex.first_layer;
-   ps->u.tex.last_layer = templ->u.tex.last_layer;
-
-   ns->width = u_minify(pt->width0, ps->u.tex.level);
-   ns->height = u_minify(pt->height0, ps->u.tex.level);
-   ns->depth = ps->u.tex.last_layer - ps->u.tex.first_layer + 1;
-   ns->offset = lvl->offset;
-
-   /* comment says there are going to be removed, but they're used by the st */
-   ps->width = ns->width;
-   ps->height = ns->height;
-
-   return ps;
-}
-
-void
-nvc0_miptree_surface_del(struct pipe_context *pipe, struct pipe_surface *ps)
-{
-   struct nvc0_surface *s = nvc0_surface(ps);
-
-   pipe_resource_reference(&ps->texture, NULL);
-
-   FREE(s);
+   ns->base.context = pipe;
+   return &ns->base;
 }
index 44e6631..a028972 100644 (file)
@@ -21,10 +21,14 @@ nvc0_resource_from_handle(struct pipe_screen * screen,
                           const struct pipe_resource *templ,
                           struct winsys_handle *whandle)
 {
-   if (templ->target == PIPE_BUFFER)
+   if (templ->target == PIPE_BUFFER) {
       return NULL;
-   else
-      return nvc0_miptree_from_handle(screen, templ, whandle);
+   } else {
+      struct pipe_resource *res = nv50_miptree_from_handle(screen,
+                                                           templ, whandle);
+      nv04_resource(res)->vtbl = &nvc0_miptree_vtbl;
+      return res;
+   }
 }
 
 void
@@ -37,7 +41,7 @@ nvc0_init_resource_functions(struct pipe_context *pcontext)
    pcontext->transfer_destroy = u_transfer_destroy_vtbl;
    pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
    pcontext->create_surface = nvc0_miptree_surface_new;
-   pcontext->surface_destroy = nvc0_miptree_surface_del;
+   pcontext->surface_destroy = nv50_miptree_surface_del;
 }
 
 void
index f1c445b..6d946c8 100644 (file)
@@ -2,53 +2,29 @@
 #ifndef __NVC0_RESOURCE_H__
 #define __NVC0_RESOURCE_H__
 
-#include "util/u_transfer.h"
-#include "util/u_double_list.h"
-#define NOUVEAU_NVC0
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_fence.h"
-#include "nouveau/nouveau_buffer.h"
-#undef NOUVEAU_NVC0
+#include "nv50/nv50_resource.h"
 
-void
-nvc0_init_resource_functions(struct pipe_context *pcontext);
 
-void
-nvc0_screen_init_resource_functions(struct pipe_screen *pscreen);
+#define NVC0_TILE_SHIFT_X(m) ((((m) >> 0) & 0xf) + 6)
+#define NVC0_TILE_SHIFT_Y(m) ((((m) >> 4) & 0xf) + 3)
+#define NVC0_TILE_SHIFT_Z(m) ((((m) >> 8) & 0xf) + 0)
 
-#define NVC0_TILE_DIM_SHIFT(m, d) (((m) >> (d * 4)) & 0xf)
+#define NVC0_TILE_SIZE_X(m) (64 << (((m) >> 0) & 0xf))
+#define NVC0_TILE_SIZE_Y(m) ( 8 << (((m) >> 4) & 0xf))
+#define NVC0_TILE_SIZE_Z(m) ( 1 << (((m) >> 8) & 0xf))
 
-#define NVC0_TILE_PITCH(m)  (64 << NVC0_TILE_DIM_SHIFT(m, 0))
-#define NVC0_TILE_HEIGHT(m) ( 8 << NVC0_TILE_DIM_SHIFT(m, 1))
-#define NVC0_TILE_DEPTH(m)  ( 1 << NVC0_TILE_DIM_SHIFT(m, 2))
+/* it's ok to mask only in the end because max value is 3 * 5 */
 
-#define NVC0_TILE_SIZE_2D(m) (((64 * 8) <<                     \
-                               NVC0_TILE_DIM_SHIFT(m, 0)) <<   \
-                              NVC0_TILE_DIM_SHIFT(m, 1))
+#define NVC0_TILE_SIZE_2D(m) ((64 * 8) << (((m) + ((m) >> 4)) & 0xf))
 
-#define NVC0_TILE_SIZE(m) (NVC0_TILE_SIZE_2D(m) << NVC0_TILE_DIM_SHIFT(m, 2))
+#define NVC0_TILE_SIZE(m) ((64 * 8) << (((m) + ((m) >> 4) + ((m) >> 8)) & 0xf))
 
-struct nvc0_miptree_level {
-   uint32_t offset;
-   uint32_t pitch;
-   uint32_t tile_mode;
-};
 
-#define NVC0_MAX_TEXTURE_LEVELS 16
-
-struct nvc0_miptree {
-   struct nv04_resource base;
-   struct nvc0_miptree_level level[NVC0_MAX_TEXTURE_LEVELS];
-   uint32_t total_size;
-   uint32_t layer_stride;
-   boolean layout_3d; /* TRUE if layer count varies with mip level */
-};
+void
+nvc0_init_resource_functions(struct pipe_context *pcontext);
 
-static INLINE struct nvc0_miptree *
-nvc0_miptree(struct pipe_resource *pt)
-{
-   return (struct nvc0_miptree *)pt;
-}
+void
+nvc0_screen_init_resource_functions(struct pipe_screen *pscreen);
 
 /* Internal functions:
  */
@@ -56,20 +32,30 @@ struct pipe_resource *
 nvc0_miptree_create(struct pipe_screen *pscreen,
                     const struct pipe_resource *tmp);
 
-struct pipe_resource *
-nvc0_miptree_from_handle(struct pipe_screen *pscreen,
-                         const struct pipe_resource *template,
-                         struct winsys_handle *whandle);
+const struct u_resource_vtbl nvc0_miptree_vtbl;
 
 struct pipe_surface *
 nvc0_miptree_surface_new(struct pipe_context *,
                          struct pipe_resource *,
                          const struct pipe_surface *templ);
 
-void
-nvc0_miptree_surface_del(struct pipe_context *, struct pipe_surface *);
+unsigned
+nvc0_mt_zslice_offset(const struct nv50_miptree *, unsigned l, unsigned z);
 
-uint32_t
-nvc0_miptree_zslice_offset(struct nvc0_miptree *, unsigned l, unsigned z);
+struct pipe_transfer *
+nvc0_miptree_transfer_new(struct pipe_context *pcontext,
+                          struct pipe_resource *pt,
+                          unsigned level,
+                          unsigned usage,
+                          const struct pipe_box *box);
+void
+nvc0_miptree_transfer_del(struct pipe_context *pcontext,
+                          struct pipe_transfer *ptx);
+void *
+nvc0_miptree_transfer_map(struct pipe_context *pcontext,
+                          struct pipe_transfer *ptx);
+void
+nvc0_miptree_transfer_unmap(struct pipe_context *pcontext,
+                            struct pipe_transfer *ptx);
 
 #endif
index 5214398..c79256a 100644 (file)
@@ -24,6 +24,9 @@
 #include "util/u_format_s3tc.h"
 #include "pipe/p_screen.h"
 
+#include "vl/vl_decoder.h"
+#include "vl/vl_video_buffer.h"
+
 #include "nvc0_context.h"
 #include "nvc0_screen.h"
 
@@ -37,7 +40,7 @@ nvc0_screen_is_format_supported(struct pipe_screen *pscreen,
                                 unsigned sample_count,
                                 unsigned bindings)
 {
-   if (sample_count > 1)
+   if (sample_count > 2 && sample_count != 4 && sample_count != 8)
       return FALSE;
 
    if (!util_format_is_supported(format, bindings))
@@ -200,8 +203,11 @@ nvc0_screen_destroy(struct pipe_screen *pscreen)
 {
    struct nvc0_screen *screen = nvc0_screen(pscreen);
 
-   nouveau_fence_wait(screen->base.fence.current);
-   nouveau_fence_ref(NULL, &screen->base.fence.current);
+   if (screen->base.fence.current) {
+      nouveau_fence_wait(screen->base.fence.current);
+      nouveau_fence_ref(NULL, &screen->base.fence.current);
+   }
+   screen->base.channel->user_private = NULL;
 
    nouveau_bo_ref(NULL, &screen->text);
    nouveau_bo_ref(NULL, &screen->tls);
@@ -360,6 +366,7 @@ nvc0_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
       return NULL;
    }
    chan = screen->base.channel;
+   chan->user_private = screen;
 
    pscreen->winsys = ws;
    pscreen->destroy = nvc0_screen_destroy;
@@ -371,6 +378,8 @@ nvc0_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 
    nvc0_screen_init_resource_functions(pscreen);
 
+   nouveau_screen_init_vdec(&screen->base);
+
    ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, 4096,
                         &screen->fence.bo);
    if (ret)
@@ -435,7 +444,7 @@ nvc0_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
    BEGIN_RING(chan, RING_3D(MULTISAMPLE_ENABLE), 1);
    OUT_RING  (chan, 0);
    BEGIN_RING(chan, RING_3D(MULTISAMPLE_MODE), 1);
-   OUT_RING  (chan, NVC0_3D_MULTISAMPLE_MODE_1X);
+   OUT_RING  (chan, NVC0_3D_MULTISAMPLE_MODE_MS1);
    BEGIN_RING(chan, RING_3D(MULTISAMPLE_CTRL), 1);
    OUT_RING  (chan, 0);
    BEGIN_RING(chan, RING_3D(LINE_WIDTH_SEPARATE), 1);
index 94bf0cf..a3133b2 100644 (file)
@@ -4,6 +4,7 @@
 #define NOUVEAU_NVC0
 #include "nouveau/nouveau_screen.h"
 #include "nouveau/nouveau_mm.h"
+#include "nouveau/nouveau_fence.h"
 #undef NOUVEAU_NVC0
 #include "nvc0_winsys.h"
 #include "nvc0_stateobj.h"
@@ -16,6 +17,8 @@ struct nvc0_context;
 #define NVC0_SCRATCH_SIZE (2 << 20)
 #define NVC0_SCRATCH_NR_BUFFERS 2
 
+#define NVC0_SCREEN_RESIDENT_BO_COUNT 5
+
 struct nvc0_screen {
    struct nouveau_screen base;
    struct nouveau_winsys *nvws;
index b0b2065..9f9921c 100644 (file)
@@ -88,6 +88,7 @@ nvc0_blend_state_create(struct pipe_context *pipe,
 {
     struct nvc0_blend_stateobj *so = CALLOC_STRUCT(nvc0_blend_stateobj);
     int i;
+    uint32_t ms;
 
     so->pipe = *cso;
 
@@ -144,6 +145,15 @@ nvc0_blend_state_create(struct pipe_context *pipe,
             SB_DATA(so, nvc0_colormask(cso->rt[i].colormask));
     }
 
+    ms = 0;
+    if (cso->alpha_to_coverage)
+       ms |= NVC0_3D_MULTISAMPLE_CTRL_ALPHA_TO_COVERAGE;
+    if (cso->alpha_to_one)
+       ms |= NVC0_3D_MULTISAMPLE_CTRL_ALPHA_TO_ONE;
+
+    SB_BEGIN_3D(so, MULTISAMPLE_CTRL, 1);
+    SB_DATA    (so, ms);
+
     assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
     return so;
 }
@@ -190,6 +200,8 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe,
     SB_BEGIN_3D(so, FRAG_COLOR_CLAMP_EN, 1);
     SB_DATA    (so, cso->clamp_fragment_color ? 0x11111111 : 0x00000000);
 
+    SB_IMMED_3D(so, MULTISAMPLE_ENABLE, cso->multisample);
+
     SB_IMMED_3D(so, LINE_SMOOTH_ENABLE, cso->line_smooth);
     if (cso->line_smooth)
        SB_BEGIN_3D(so, LINE_WIDTH_SMOOTH, 1);
index 9b2a281..968d7a7 100644 (file)
@@ -8,8 +8,8 @@ nvc0_validate_zcull(struct nvc0_context *nvc0)
 {
     struct nouveau_channel *chan = nvc0->screen->base.channel;
     struct pipe_framebuffer_state *fb = &nvc0->framebuffer;
-    struct nvc0_surface *sf = nvc0_surface(fb->zsbuf);
-    struct nvc0_miptree *mt = nvc0_miptree(sf->base.texture);
+    struct nv50_surface *sf = nv50_surface(fb->zsbuf);
+    struct nv50_miptree *mt = nv50_miptree(sf->base.texture);
     struct nouveau_bo *bo = mt->base.bo;
     uint32_t size;
     uint32_t offset = align(mt->total_size, 1 << 17);
@@ -59,6 +59,7 @@ nvc0_validate_fb(struct nvc0_context *nvc0)
     struct nouveau_channel *chan = nvc0->screen->base.channel;
     struct pipe_framebuffer_state *fb = &nvc0->framebuffer;
     unsigned i;
+    unsigned ms_mode = NVC0_3D_MULTISAMPLE_MODE_MS1;
     boolean serialize = FALSE;
 
     nvc0_bufctx_reset(nvc0, NVC0_BUFCTX_FRAME);
@@ -72,8 +73,8 @@ nvc0_validate_fb(struct nvc0_context *nvc0)
     MARK_RING(chan, 9 * fb->nr_cbufs, 2 * fb->nr_cbufs);
 
     for (i = 0; i < fb->nr_cbufs; ++i) {
-        struct nvc0_miptree *mt = nvc0_miptree(fb->cbufs[i]->texture);
-        struct nvc0_surface *sf = nvc0_surface(fb->cbufs[i]);
+        struct nv50_miptree *mt = nv50_miptree(fb->cbufs[i]->texture);
+        struct nv50_surface *sf = nv50_surface(fb->cbufs[i]);
         struct nouveau_bo *bo = mt->base.bo;
         uint32_t offset = sf->offset;
 
@@ -89,6 +90,8 @@ nvc0_validate_fb(struct nvc0_context *nvc0)
         OUT_RING  (chan, mt->layer_stride >> 2);
         OUT_RING  (chan, sf->base.u.tex.first_layer);
 
+        ms_mode = mt->ms_mode;
+
         if (mt->base.status & NOUVEAU_BUFFER_STATUS_GPU_READING)
            serialize = TRUE;
         mt->base.status |=  NOUVEAU_BUFFER_STATUS_GPU_WRITING;
@@ -100,8 +103,8 @@ nvc0_validate_fb(struct nvc0_context *nvc0)
     }
 
     if (fb->zsbuf) {
-        struct nvc0_miptree *mt = nvc0_miptree(fb->zsbuf->texture);
-        struct nvc0_surface *sf = nvc0_surface(fb->zsbuf);
+        struct nv50_miptree *mt = nv50_miptree(fb->zsbuf->texture);
+        struct nv50_surface *sf = nv50_surface(fb->zsbuf);
         struct nouveau_bo *bo = mt->base.bo;
         int unk = mt->base.base.target == PIPE_TEXTURE_2D;
         uint32_t offset = sf->offset;
@@ -123,6 +126,8 @@ nvc0_validate_fb(struct nvc0_context *nvc0)
         BEGIN_RING(chan, RING_3D(ZETA_BASE_LAYER), 1);
         OUT_RING  (chan, sf->base.u.tex.first_layer);
 
+        ms_mode = mt->ms_mode;
+
         if (mt->base.status & NOUVEAU_BUFFER_STATUS_GPU_READING)
            serialize = TRUE;
         mt->base.status |=  NOUVEAU_BUFFER_STATUS_GPU_WRITING;
@@ -135,6 +140,8 @@ nvc0_validate_fb(struct nvc0_context *nvc0)
         OUT_RING  (chan, 0);
     }
 
+    IMMED_RING(chan, RING_3D(MULTISAMPLE_MODE), ms_mode);
+
     if (serialize) {
        BEGIN_RING(chan, RING_3D(SERIALIZE), 1);
        OUT_RING  (chan, 0);
@@ -390,6 +397,28 @@ nvc0_constbufs_validate(struct nvc0_context *nvc0)
 }
 
 static void
+nvc0_validate_sample_mask(struct nvc0_context *nvc0)
+{
+   struct nouveau_channel *chan = nvc0->screen->base.channel;
+
+   unsigned mask[4] =
+   {
+      nvc0->sample_mask & 0xffff,
+      nvc0->sample_mask & 0xffff,
+      nvc0->sample_mask & 0xffff,
+      nvc0->sample_mask & 0xffff
+   };
+
+   BEGIN_RING(chan, RING_3D(MSAA_MASK(0)), 4);
+   OUT_RING  (chan, mask[0]);
+   OUT_RING  (chan, mask[1]);
+   OUT_RING  (chan, mask[2]);
+   OUT_RING  (chan, mask[3]);
+   BEGIN_RING(chan, RING_3D(SAMPLE_SHADING), 1);
+   OUT_RING  (chan, 0x01);
+}
+
+static void
 nvc0_validate_derived_1(struct nvc0_context *nvc0)
 {
    struct nouveau_channel *chan = nvc0->screen->base.channel;
@@ -428,8 +457,7 @@ nvc0_switch_pipe_context(struct nvc0_context *ctx_to)
    if (!ctx_to->zsa)
       ctx_to->dirty &= ~NVC0_NEW_ZSA;
 
-   ctx_to->screen->base.channel->user_private = ctx_to->screen->cur_ctx =
-      ctx_to;
+   ctx_to->screen->cur_ctx = ctx_to;
 }
 
 static struct state_validate {
@@ -439,6 +467,7 @@ static struct state_validate {
     { nvc0_validate_fb,            NVC0_NEW_FRAMEBUFFER },
     { nvc0_validate_blend,         NVC0_NEW_BLEND },
     { nvc0_validate_zsa,           NVC0_NEW_ZSA },
+    { nvc0_validate_sample_mask,   NVC0_NEW_SAMPLE_MASK },
     { nvc0_validate_rasterizer,    NVC0_NEW_RASTERIZER },
     { nvc0_validate_blend_colour,  NVC0_NEW_BLEND_COLOUR },
     { nvc0_validate_stencil_ref,   NVC0_NEW_STENCIL_REF },
index e0fe9df..0686c52 100644 (file)
 struct nvc0_blend_stateobj {
    struct pipe_blend_state pipe;
    int size;
-   uint32_t state[70];
+   uint32_t state[72];
 };
 
 struct nvc0_rasterizer_stateobj {
    struct pipe_rasterizer_state pipe;
    int size;
-   uint32_t state[38];
+   uint32_t state[39];
 };
 
 struct nvc0_zsa_stateobj {
index 6be3702..67bba3c 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "nvc0_context.h"
 #include "nvc0_resource.h"
-#include "nvc0_transfer.h"
 
 #include "nv50/nv50_defs.xml.h"
 
@@ -63,11 +62,11 @@ nvc0_2d_format(enum pipe_format format)
    case 2:
       return NV50_SURFACE_FORMAT_R16_UNORM;
    case 4:
-      return NV50_SURFACE_FORMAT_A8R8G8B8_UNORM;
+      return NV50_SURFACE_FORMAT_BGRA8_UNORM;
    case 8:
-      return NV50_SURFACE_FORMAT_R16G16B16A16_UNORM;
+      return NV50_SURFACE_FORMAT_RGBA16_UNORM;
    case 16:
-      return NV50_SURFACE_FORMAT_R32G32B32A32_FLOAT;
+      return NV50_SURFACE_FORMAT_RGBA32_FLOAT;
    default:
       return 0;
    }
@@ -75,7 +74,7 @@ nvc0_2d_format(enum pipe_format format)
 
 static int
 nvc0_2d_texture_set(struct nouveau_channel *chan, int dst,
-                    struct nvc0_miptree *mt, unsigned level, unsigned layer)
+                    struct nv50_miptree *mt, unsigned level, unsigned layer)
 {
    struct nouveau_bo *bo = mt->base.bo;
    uint32_t width, height, depth;
@@ -91,8 +90,8 @@ nvc0_2d_texture_set(struct nouveau_channel *chan, int dst,
       return 1;
    }
 
-   width = u_minify(mt->base.base.width0, level);
-   height = u_minify(mt->base.base.height0, level);
+   width = u_minify(mt->base.base.width0, level) << mt->ms_x;
+   height = u_minify(mt->base.base.height0, level) << mt->ms_y;
    depth = u_minify(mt->base.base.depth0, level);
 
    /* layer has to be < depth, and depth > tile depth / 2 */
@@ -103,7 +102,7 @@ nvc0_2d_texture_set(struct nouveau_channel *chan, int dst,
       depth = 1;
    } else
    if (!dst) {
-      offset += nvc0_miptree_zslice_offset(mt, level, layer);
+      offset += nvc0_mt_zslice_offset(mt, level, layer);
       layer = 0;
    }
 
@@ -145,13 +144,19 @@ nvc0_2d_texture_set(struct nouveau_channel *chan, int dst,
 
 static int
 nvc0_2d_texture_do_copy(struct nouveau_channel *chan,
-                        struct nvc0_miptree *dst, unsigned dst_level,
+                        struct nv50_miptree *dst, unsigned dst_level,
                         unsigned dx, unsigned dy, unsigned dz,
-                        struct nvc0_miptree *src, unsigned src_level,
+                        struct nv50_miptree *src, unsigned src_level,
                         unsigned sx, unsigned sy, unsigned sz,
                         unsigned w, unsigned h)
 {
+   static const uint32_t duvdxy[5] =
+   {
+      0x40000000, 0x80000000, 0x00000001, 0x00000002, 0x00000004
+   };
+
    int ret;
+   uint32_t ctrl = 0x00;
 
    ret = MARK_RING(chan, 2 * 16 + 32, 4);
    if (ret)
@@ -165,66 +170,33 @@ nvc0_2d_texture_do_copy(struct nouveau_channel *chan,
    if (ret)
       return ret;
 
-   /* 0/1 = CENTER/CORNER, 10/00 = POINT/BILINEAR */
+   /* NOTE: 2D engine doesn't work for MS8 */
+   if (src->ms_x)
+      ctrl = 0x11;
+
+   /* 0/1 = CENTER/CORNER, 00/10 = POINT/BILINEAR */
    BEGIN_RING(chan, RING_2D(BLIT_CONTROL), 1);
-   OUT_RING  (chan, 0);
+   OUT_RING  (chan, ctrl);
    BEGIN_RING(chan, RING_2D(BLIT_DST_X), 4);
-   OUT_RING  (chan, dx);
-   OUT_RING  (chan, dy);
-   OUT_RING  (chan, w);
-   OUT_RING  (chan, h);
+   OUT_RING  (chan, dx << dst->ms_x);
+   OUT_RING  (chan, dy << dst->ms_y);
+   OUT_RING  (chan, w << dst->ms_x);
+   OUT_RING  (chan, h << dst->ms_y);
    BEGIN_RING(chan, RING_2D(BLIT_DU_DX_FRACT), 4);
-   OUT_RING  (chan, 0);
-   OUT_RING  (chan, 1);
-   OUT_RING  (chan, 0);
-   OUT_RING  (chan, 1);
+   OUT_RING  (chan, duvdxy[2 + ((int)src->ms_x - (int)dst->ms_x)] & 0xf0000000);
+   OUT_RING  (chan, duvdxy[2 + ((int)src->ms_x - (int)dst->ms_x)] & 0x0000000f);
+   OUT_RING  (chan, duvdxy[2 + ((int)src->ms_y - (int)dst->ms_y)] & 0xf0000000);
+   OUT_RING  (chan, duvdxy[2 + ((int)src->ms_y - (int)dst->ms_y)] & 0x0000000f);
    BEGIN_RING(chan, RING_2D(BLIT_SRC_X_FRACT), 4);
    OUT_RING  (chan, 0);
-   OUT_RING  (chan, sx);
+   OUT_RING  (chan, sx << src->ms_x);
    OUT_RING  (chan, 0);
-   OUT_RING  (chan, sy);
+   OUT_RING  (chan, sy << src->ms_x);
 
    return 0;
 }
 
 static void
-nvc0_setup_m2mf_rect(struct nvc0_m2mf_rect *rect,
-                     struct pipe_resource *restrict res, unsigned l,
-                     unsigned x, unsigned y, unsigned z)
-{
-   struct nvc0_miptree *mt = nvc0_miptree(res);
-   const unsigned w = u_minify(res->width0, l);
-   const unsigned h = u_minify(res->height0, l);
-
-   rect->bo = mt->base.bo;
-   rect->domain = mt->base.domain;
-   rect->base = mt->level[l].offset;
-   rect->pitch = mt->level[l].pitch;
-   if (util_format_is_plain(res->format)) {
-      rect->width = w;
-      rect->height = h;
-      rect->x = x;
-      rect->y = y;
-   } else {
-      rect->width = util_format_get_nblocksx(res->format, w);
-      rect->height = util_format_get_nblocksy(res->format, h);
-      rect->x = util_format_get_nblocksx(res->format, x);
-      rect->y = util_format_get_nblocksy(res->format, y);
-   }
-   rect->tile_mode = mt->level[l].tile_mode;
-   rect->cpp = util_format_get_blocksize(res->format);
-
-   if (mt->layout_3d) {
-      rect->z = z;
-      rect->depth = u_minify(res->depth0, l);
-   } else {
-      rect->base += z * mt->layer_stride;
-      rect->z = 0;
-      rect->depth = 1;
-   }
-}
-
-static void
 nvc0_resource_copy_region(struct pipe_context *pipe,
                           struct pipe_resource *dst, unsigned dst_level,
                           unsigned dstx, unsigned dsty, unsigned dstz,
@@ -244,28 +216,28 @@ nvc0_resource_copy_region(struct pipe_context *pipe,
 
    nv04_resource(dst)->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING;
 
-   if (src->format == dst->format) {
-      struct nvc0_m2mf_rect drect, srect;
+   if (src->format == dst->format && src->nr_samples == dst->nr_samples) {
+      struct nv50_m2mf_rect drect, srect;
       unsigned i;
       unsigned nx = util_format_get_nblocksx(src->format, src_box->width);
       unsigned ny = util_format_get_nblocksy(src->format, src_box->height);
 
-      nvc0_setup_m2mf_rect(&drect, dst, dst_level, dstx, dsty, dstz);
-      nvc0_setup_m2mf_rect(&srect, src, src_level,
+      nv50_m2mf_rect_setup(&drect, dst, dst_level, dstx, dsty, dstz);
+      nv50_m2mf_rect_setup(&srect, src, src_level,
                            src_box->x, src_box->y, src_box->z);
 
       for (i = 0; i < src_box->depth; ++i) {
          nvc0_m2mf_transfer_rect(&screen->base.base, &drect, &srect, nx, ny);
 
-         if (nvc0_miptree(dst)->layout_3d)
+         if (nv50_miptree(dst)->layout_3d)
             drect.z++;
          else
-            drect.base += nvc0_miptree(dst)->layer_stride;
+            drect.base += nv50_miptree(dst)->layer_stride;
 
-         if (nvc0_miptree(src)->layout_3d)
+         if (nv50_miptree(src)->layout_3d)
             srect.z++;
          else
-            srect.base += nvc0_miptree(src)->layer_stride;
+            srect.base += nv50_miptree(src)->layer_stride;
       }
       return;
    }
@@ -275,9 +247,9 @@ nvc0_resource_copy_region(struct pipe_context *pipe,
 
    for (; dst_layer < dstz + src_box->depth; ++dst_layer, ++src_layer) {
       ret = nvc0_2d_texture_do_copy(screen->base.channel,
-                                    nvc0_miptree(dst), dst_level,
+                                    nv50_miptree(dst), dst_level,
                                     dstx, dsty, dst_layer,
-                                    nvc0_miptree(src), src_level,
+                                    nv50_miptree(src), src_level,
                                     src_box->x, src_box->y, src_layer,
                                     src_box->width, src_box->height);
       if (ret)
@@ -295,8 +267,8 @@ nvc0_clear_render_target(struct pipe_context *pipe,
        struct nvc0_context *nv50 = nvc0_context(pipe);
        struct nvc0_screen *screen = nv50->screen;
        struct nouveau_channel *chan = screen->base.channel;
-       struct nvc0_miptree *mt = nvc0_miptree(dst->texture);
-       struct nvc0_surface *sf = nvc0_surface(dst);
+       struct nv50_miptree *mt = nv50_miptree(dst->texture);
+       struct nv50_surface *sf = nv50_surface(dst);
        struct nouveau_bo *bo = mt->base.bo;
 
        BEGIN_RING(chan, RING_3D(CLEAR_COLOR(0)), 4);
@@ -347,8 +319,8 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe,
        struct nvc0_context *nv50 = nvc0_context(pipe);
        struct nvc0_screen *screen = nv50->screen;
        struct nouveau_channel *chan = screen->base.channel;
-       struct nvc0_miptree *mt = nvc0_miptree(dst->texture);
-       struct nvc0_surface *sf = nvc0_surface(dst);
+       struct nv50_miptree *mt = nv50_miptree(dst->texture);
+       struct nv50_surface *sf = nv50_surface(dst);
        struct nouveau_bo *bo = mt->base.bo;
        uint32_t mode = 0;
        int unk = mt->base.base.target == PIPE_TEXTURE_2D;
index 24850b1..0cbb4b3 100644 (file)
@@ -60,7 +60,7 @@ nvc0_create_sampler_view(struct pipe_context *pipe,
    uint32_t swz[4];
    uint32_t depth;
    struct nv50_tic_entry *view;
-   struct nvc0_miptree *mt = nvc0_miptree(texture);
+   struct nv50_miptree *mt = nv50_miptree(texture);
    boolean tex_int;
 
    view = MALLOC_STRUCT(nv50_tic_entry);
@@ -114,6 +114,7 @@ nvc0_create_sampler_view(struct pipe_context *pipe,
    depth = MAX2(mt->base.base.array_size, mt->base.base.depth0);
 
    if (mt->base.base.target == PIPE_TEXTURE_1D_ARRAY ||
+   /*  mt->base.base.target == PIPE_TEXTURE_2D_ARRAY_MS || */
        mt->base.base.target == PIPE_TEXTURE_2D_ARRAY) {
       /* there doesn't seem to be a base layer field in TIC */
       tic[1] = view->pipe.u.tex.first_layer * mt->layer_stride;
@@ -124,6 +125,7 @@ nvc0_create_sampler_view(struct pipe_context *pipe,
    case PIPE_TEXTURE_1D:
       tic[2] |= NV50_TIC_2_TARGET_1D;
       break;
+/* case PIPE_TEXTURE_2D_MS: */
    case PIPE_TEXTURE_2D:
       tic[2] |= NV50_TIC_2_TARGET_2D;
       break;
@@ -143,6 +145,7 @@ nvc0_create_sampler_view(struct pipe_context *pipe,
    case PIPE_TEXTURE_1D_ARRAY:
       tic[2] |= NV50_TIC_2_TARGET_1D_ARRAY;
       break;
+/* case PIPE_TEXTURE_2D_ARRAY_MS: */
    case PIPE_TEXTURE_2D_ARRAY:
       tic[2] |= NV50_TIC_2_TARGET_2D_ARRAY;
       break;
@@ -159,16 +162,22 @@ nvc0_create_sampler_view(struct pipe_context *pipe,
    else
       tic[3] = 0x00300000;
 
-   tic[4] = (1 << 31) | mt->base.base.width0;
+   tic[4] = (1 << 31) | (mt->base.base.width0 << mt->ms_x);
 
-   tic[5] = mt->base.base.height0 & 0xffff;
+   tic[5] = (mt->base.base.height0 << mt->ms_y) & 0xffff;
    tic[5] |= depth << 16;
    tic[5] |= mt->base.base.last_level << 28;
 
-   tic[6] = 0x03000000;
+   tic[6] = (mt->ms_x > 1) ? 0x88000000 : 0x03000000; /* sampling points */
 
    tic[7] = (view->pipe.u.tex.last_level << 4) | view->pipe.u.tex.first_level;
 
+   /*
+   if (mt->base.base.target == PIPE_TEXTURE_2D_MS ||
+       mt->base.base.target == PIPE_TEXTURE_2D_ARRAY_MS)
+      tic[7] |= mt->ms_mode << 12;
+   */
+
    return &view->pipe;
 }
 
@@ -189,7 +198,7 @@ nvc0_validate_tic(struct nvc0_context *nvc0, int s)
          OUT_RING  (chan, (i << 1) | 0);
          continue;
       }
-      res = &nvc0_miptree(tic->pipe.texture)->base;
+      res = &nv50_miptree(tic->pipe.texture)->base;
 
       if (tic->id < 0) {
          uint32_t offset = tic->tic[1];
index 0509113..ecc9e21 100644 (file)
@@ -2,13 +2,12 @@
 #include "util/u_format.h"
 
 #include "nvc0_context.h"
-#include "nvc0_transfer.h"
 
 #include "nv50/nv50_defs.xml.h"
 
 struct nvc0_transfer {
    struct pipe_transfer base;
-   struct nvc0_m2mf_rect rect[2];
+   struct nv50_m2mf_rect rect[2];
    uint32_t nblocksx;
    uint16_t nblocksy;
    uint16_t nlayers;
@@ -16,8 +15,8 @@ struct nvc0_transfer {
 
 void
 nvc0_m2mf_transfer_rect(struct pipe_screen *pscreen,
-                        const struct nvc0_m2mf_rect *dst,
-                        const struct nvc0_m2mf_rect *src,
+                        const struct nv50_m2mf_rect *dst,
+                        const struct nv50_m2mf_rect *src,
                         uint32_t nblocksx, uint32_t nblocksy)
 {
    struct nouveau_channel *chan = nouveau_screen(pscreen)->channel;
@@ -174,9 +173,10 @@ nvc0_m2mf_copy_linear(struct nouveau_context *nv,
    }
 }
 
+#if 0
 static void
 nvc0_m2mf_push_rect(struct pipe_screen *pscreen,
-                    const struct nvc0_m2mf_rect *dst,
+                    const struct nv50_m2mf_rect *dst,
                     const void *data,
                     unsigned nblocksx, unsigned nblocksy)
 {
@@ -228,6 +228,7 @@ nvc0_m2mf_push_rect(struct pipe_screen *pscreen,
       nblocksy -= line_count;
    }
 }
+#endif
 
 struct pipe_transfer *
 nvc0_miptree_transfer_new(struct pipe_context *pctx,
@@ -239,11 +240,9 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
    struct nvc0_context *nvc0 = nvc0_context(pctx);
    struct pipe_screen *pscreen = pctx->screen;
    struct nouveau_device *dev = nvc0->screen->base.device;
-   struct nvc0_miptree *mt = nvc0_miptree(res);
-   struct nvc0_miptree_level *lvl = &mt->level[level];
+   struct nv50_miptree *mt = nv50_miptree(res);
    struct nvc0_transfer *tx;
    uint32_t size;
-   uint32_t w, h, d, z, layer;
    int ret;
 
    if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
@@ -253,45 +252,25 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
    if (!tx)
       return NULL;
 
-   if (mt->layout_3d) {
-      z = box->z;
-      d = u_minify(res->depth0, level);
-      layer = 0;
-   } else {
-      z = 0;
-      d = 1;
-      layer = box->z;
-   }
-   tx->nlayers = box->depth;
-
    pipe_resource_reference(&tx->base.resource, res);
 
    tx->base.level = level;
    tx->base.usage = usage;
    tx->base.box = *box;
 
-   tx->nblocksx = util_format_get_nblocksx(res->format, box->width);
-   tx->nblocksy = util_format_get_nblocksy(res->format, box->height);
+   if (util_format_is_plain(res->format)) {
+      tx->nblocksx = box->width << mt->ms_x;
+      tx->nblocksy = box->height << mt->ms_y;
+   } else {
+      tx->nblocksx = util_format_get_nblocksx(res->format, box->width);
+      tx->nblocksy = util_format_get_nblocksy(res->format, box->height);
+   }
+   tx->nlayers = box->depth;
 
    tx->base.stride = tx->nblocksx * util_format_get_blocksize(res->format);
    tx->base.layer_stride = tx->nblocksy * tx->base.stride;
 
-   w = u_minify(res->width0, level);
-   h = u_minify(res->height0, level);
-
-   tx->rect[0].cpp = tx->rect[1].cpp = util_format_get_blocksize(res->format);
-
-   tx->rect[0].bo = mt->base.bo;
-   tx->rect[0].base = lvl->offset + layer * mt->layer_stride;
-   tx->rect[0].tile_mode = lvl->tile_mode;
-   tx->rect[0].x = util_format_get_nblocksx(res->format, box->x);
-   tx->rect[0].y = util_format_get_nblocksy(res->format, box->y);
-   tx->rect[0].z = z;
-   tx->rect[0].width = util_format_get_nblocksx(res->format, w);
-   tx->rect[0].height = util_format_get_nblocksy(res->format, h);
-   tx->rect[0].depth = d;
-   tx->rect[0].pitch = lvl->pitch;
-   tx->rect[0].domain = NOUVEAU_BO_VRAM;
+   nv50_m2mf_rect_setup(&tx->rect[0], res, level, box->x, box->y, box->z);
 
    size = tx->base.layer_stride;
 
@@ -302,6 +281,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
       return NULL;
    }
 
+   tx->rect[1].cpp = tx->rect[0].cpp;
    tx->rect[1].width = tx->nblocksx;
    tx->rect[1].height = tx->nblocksy;
    tx->rect[1].depth = 1;
@@ -310,6 +290,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
 
    if (usage & PIPE_TRANSFER_READ) {
       unsigned base = tx->rect[0].base;
+      unsigned z = tx->rect[0].z;
       unsigned i;
       for (i = 0; i < tx->nlayers; ++i) {
          nvc0_m2mf_transfer_rect(pscreen, &tx->rect[1], &tx->rect[0],
@@ -334,7 +315,7 @@ nvc0_miptree_transfer_del(struct pipe_context *pctx,
 {
    struct pipe_screen *pscreen = pctx->screen;
    struct nvc0_transfer *tx = (struct nvc0_transfer *)transfer;
-   struct nvc0_miptree *mt = nvc0_miptree(tx->base.resource);
+   struct nv50_miptree *mt = nv50_miptree(tx->base.resource);
    unsigned i;
 
    if (tx->base.usage & PIPE_TRANSFER_WRITE) {
diff --git a/src/gallium/drivers/nvc0/nvc0_transfer.h b/src/gallium/drivers/nvc0/nvc0_transfer.h
deleted file mode 100644 (file)
index 803ee34..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-
-#ifndef __NVC0_TRANSFER_H__
-#define __NVC0_TRANSFER_H__
-
-#include "pipe/p_state.h"
-
-struct pipe_transfer *
-nvc0_miptree_transfer_new(struct pipe_context *pcontext,
-                          struct pipe_resource *pt,
-                          unsigned level,
-                          unsigned usage,
-                          const struct pipe_box *box);
-void
-nvc0_miptree_transfer_del(struct pipe_context *pcontext,
-                          struct pipe_transfer *ptx);
-void *
-nvc0_miptree_transfer_map(struct pipe_context *pcontext,
-                          struct pipe_transfer *ptx);
-void
-nvc0_miptree_transfer_unmap(struct pipe_context *pcontext,
-                            struct pipe_transfer *ptx);
-
-struct nvc0_m2mf_rect {
-   struct nouveau_bo *bo;
-   uint32_t base;
-   unsigned domain;
-   uint32_t pitch;
-   uint32_t width;
-   uint32_t x;
-   uint32_t height;
-   uint32_t y;
-   uint16_t depth;
-   uint16_t z;
-   uint16_t tile_mode;
-   uint16_t cpp;
-};
-
-void
-nvc0_m2mf_transfer_rect(struct pipe_screen *pscreen,
-                        const struct nvc0_m2mf_rect *dst,
-                        const struct nvc0_m2mf_rect *src,
-                        uint32_t nblocksx, uint32_t nblocksy);
-
-#endif
index 6bbcf24..8a5bf8d 100644 (file)
@@ -367,11 +367,11 @@ nvc0_prim_gl(unsigned prim)
 static void
 nvc0_draw_vbo_flush_notify(struct nouveau_channel *chan)
 {
-   struct nvc0_context *nvc0 = chan->user_private;
+   struct nvc0_screen *screen = chan->user_private;
 
-   nouveau_fence_update(&nvc0->screen->base, TRUE);
+   nouveau_fence_update(&screen->base, TRUE);
 
-   nvc0_bufctx_emit_relocs(nvc0);
+   nvc0_bufctx_emit_relocs(screen->cur_ctx);
 }
 
 static void
@@ -382,9 +382,6 @@ nvc0_draw_arrays(struct nvc0_context *nvc0,
    struct nouveau_channel *chan = nvc0->screen->base.channel;
    unsigned prim;
 
-   chan->flush_notify = nvc0_draw_vbo_flush_notify;
-   chan->user_private = nvc0;
-
    prim = nvc0_prim_gl(mode);
 
    while (instance_count--) {
@@ -397,8 +394,6 @@ nvc0_draw_arrays(struct nvc0_context *nvc0,
 
       prim |= NVC0_3D_VERTEX_BEGIN_GL_INSTANCE_NEXT;
    }
-
-   chan->flush_notify = nvc0_default_flush_notify;
 }
 
 static void
@@ -500,9 +495,6 @@ nvc0_draw_elements(struct nvc0_context *nvc0, boolean shorten,
    unsigned prim;
    const unsigned index_size = nvc0->idxbuf.index_size;
 
-   chan->flush_notify = nvc0_draw_vbo_flush_notify;
-   chan->user_private = nvc0;
-
    prim = nvc0_prim_gl(mode);
 
    if (index_bias != nvc0->state.index_bias) {
@@ -568,8 +560,6 @@ nvc0_draw_elements(struct nvc0_context *nvc0, boolean shorten,
          prim |= NVC0_3D_VERTEX_BEGIN_GL_INSTANCE_NEXT;
       }
    }
-
-   chan->flush_notify = nvc0_default_flush_notify;
 }
 
 void
@@ -596,8 +586,11 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 
    nvc0_state_validate(nvc0);
 
+   chan->flush_notify = nvc0_draw_vbo_flush_notify;
+
    if (nvc0->vbo_fifo) {
       nvc0_push_vbo(nvc0, info);
+      chan->flush_notify = nvc0_default_flush_notify;
       return;
    }
 
@@ -648,6 +641,7 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
                          info->mode, info->start, info->count,
                          info->instance_count, info->index_bias);
    }
+   chan->flush_notify = nvc0_default_flush_notify;
 
    nvc0_release_user_vbufs(nvc0);
 }
index 2b15102..e2cdcf6 100644 (file)
@@ -1,6 +1,8 @@
 #include "draw/draw_context.h"
 #include "pipe/p_defines.h"
 #include "util/u_framebuffer.h"
+#include "vl/vl_decoder.h"
+#include "vl/vl_video_buffer.h"
 
 #include "nvfx_context.h"
 #include "nvfx_screen.h"
@@ -24,9 +26,21 @@ nvfx_flush(struct pipe_context *pipe,
                OUT_RING(chan, 1);
         }*/
 
-       FIRE_RING(chan);
-       if (fence)
+       if (fence) {
+               /* horrific hack to make glFinish() work in the absence of
+                * having proper fences in nvfx.  a pending rewrite will
+                * fix this properly, but may be a while off.
+                */
+               MARK_RING(chan, 1, 1);
+               OUT_RELOC(chan, screen->fence, 0, NOUVEAU_BO_WR |
+                               NOUVEAU_BO_DUMMY, 0, 0);
+               FIRE_RING(chan);
+               nouveau_bo_map(screen->fence, NOUVEAU_BO_RDWR);
+               nouveau_bo_unmap(screen->fence);
                *fence = NULL;
+       } else {
+               FIRE_RING(chan);
+       }
 }
 
 static void
@@ -76,6 +90,9 @@ nvfx_create(struct pipe_screen *pscreen, void *priv)
        nvfx->pipe.clear = nvfx_clear;
        nvfx->pipe.flush = nvfx_flush;
 
+       nvfx->pipe.create_video_decoder = vl_create_decoder;
+       nvfx->pipe.create_video_buffer = vl_video_buffer_create;
+
        nvfx->is_nv4x = screen->is_nv4x;
        nvfx->use_nv4x = screen->use_nv4x;
        /* TODO: it seems that nv30 might have fixed function clipping usable with vertex programs
index d880b12..0e8f967 100644 (file)
@@ -3,6 +3,8 @@
 #include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_simple_screen.h"
+#include "vl/vl_decoder.h"
+#include "vl/vl_video_buffer.h"
 
 #include "nouveau/nouveau_screen.h"
 #include "nouveau/nv_object.xml.h"
@@ -33,6 +35,9 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                return 1;
        case PIPE_CAP_GLSL:
                return 1;
+       case PIPE_CAP_SM3:
+               /* TODO: >= nv4x support Shader Model 3.0 */
+               return 0;
        case PIPE_CAP_ANISOTROPIC_FILTER:
                return 1;
        case PIPE_CAP_POINT_SPRITE:
@@ -208,6 +213,24 @@ nvfx_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_cap param)
        }
 }
 
+static int
+nvfx_screen_get_video_param(struct pipe_screen *screen,
+                               enum pipe_video_profile profile,
+                               enum pipe_video_cap param)
+{
+       switch (param) {
+       case PIPE_VIDEO_CAP_SUPPORTED:
+               return vl_profile_supported(screen, profile);
+       case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+               return 0;
+       case PIPE_VIDEO_CAP_MAX_WIDTH:
+       case PIPE_VIDEO_CAP_MAX_HEIGHT:
+               return vl_video_buffer_max_size(screen);
+       default:
+               return 0;
+       }
+}
+
 static boolean
 nvfx_screen_is_format_supported(struct pipe_screen *pscreen,
                                     enum pipe_format format,
@@ -306,6 +329,7 @@ nvfx_screen_destroy(struct pipe_screen *pscreen)
        nouveau_notifier_free(&screen->sync);
        nouveau_grobj_free(&screen->eng3d);
        nvfx_screen_surface_takedown(pscreen);
+       nouveau_bo_ref(NULL, &screen->fence);
 
        nouveau_screen_fini(&screen->base);
 
@@ -467,9 +491,17 @@ nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        pscreen->get_param = nvfx_screen_get_param;
        pscreen->get_shader_param = nvfx_screen_get_shader_param;
        pscreen->get_paramf = nvfx_screen_get_paramf;
+       pscreen->get_video_param = nvfx_screen_get_video_param;
        pscreen->is_format_supported = nvfx_screen_is_format_supported;
+       pscreen->is_video_format_supported = vl_video_buffer_is_format_supported;
        pscreen->context_create = nvfx_create;
 
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 4096, &screen->fence);
+       if (ret) {
+               nvfx_screen_destroy(pscreen);
+               return NULL;
+       }
+
        switch (dev->chipset & 0xf0) {
        case 0x30:
                if (NV30_3D_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
index b1f0718..02e7c5d 100644 (file)
@@ -11,6 +11,7 @@ struct nvfx_screen {
        struct nouveau_screen base;
 
        struct nouveau_winsys *nvws;
+       struct nouveau_bo *fence;
 
        struct nvfx_context *cur_ctx;
 
index 8fafca1..15e1cbb 100644 (file)
@@ -2,6 +2,7 @@
 #define __NVFX_STATE_H__
 
 #include "pipe/p_state.h"
+#include "pipe/p_video_state.h"
 #include "tgsi/tgsi_scan.h"
 #include "nouveau/nouveau_statebuf.h"
 #include "util/u_dynarray.h"
index 4088216..4f02127 100644 (file)
@@ -26,19 +26,51 @@ C_SOURCES = \
        r300_texture.c \
        r300_texture_desc.c \
        r300_tgsi_to_rc.c \
-       r300_transfer.c
+       r300_transfer.c \
+       \
+       compiler/radeon_code.c \
+       compiler/radeon_compiler.c \
+       compiler/radeon_compiler_util.c \
+       compiler/radeon_emulate_branches.c \
+       compiler/radeon_emulate_loops.c \
+       compiler/radeon_program.c \
+       compiler/radeon_program_print.c \
+       compiler/radeon_opcodes.c \
+       compiler/radeon_program_alu.c \
+       compiler/radeon_program_pair.c \
+       compiler/radeon_program_tex.c \
+       compiler/radeon_pair_translate.c \
+       compiler/radeon_pair_schedule.c \
+       compiler/radeon_pair_regalloc.c \
+       compiler/radeon_pair_dead_sources.c \
+       compiler/radeon_dataflow.c \
+       compiler/radeon_dataflow_deadcode.c \
+       compiler/radeon_dataflow_swizzles.c \
+       compiler/radeon_list.c \
+       compiler/radeon_optimize.c \
+       compiler/radeon_remove_constants.c \
+       compiler/radeon_rename_regs.c \
+       compiler/radeon_variable.c \
+       compiler/r3xx_fragprog.c \
+       compiler/r300_fragprog.c \
+       compiler/r300_fragprog_swizzle.c \
+       compiler/r300_fragprog_emit.c \
+       compiler/r500_fragprog.c \
+       compiler/r500_fragprog_emit.c \
+       compiler/r3xx_vertprog.c \
+       compiler/r3xx_vertprog_dump.c \
+       compiler/memory_pool.c \
+       \
+       $(TOP)/src/glsl/ralloc.c \
+       $(TOP)/src/mesa/program/register_allocate.c
 
-LIBRARY_INCLUDES = \
-       -I$(TOP)/src/mesa/drivers/dri/r300/compiler \
-       -I$(TOP)/include
-
-COMPILER_ARCHIVE = $(TOP)/src/mesa/drivers/dri/r300/compiler/libr300compiler.a
 
-EXTRA_OBJECTS = \
-       $(COMPILER_ARCHIVE)
+LIBRARY_INCLUDES = \
+       -I$(TOP)/include \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/src/glsl
 
 include ../../Makefile.template
 
-.PHONY: $(COMPILER_ARCHIVE)
-$(COMPILER_ARCHIVE):
-       $(MAKE) -C $(TOP)/src/mesa/drivers/dri/r300/compiler
+test: default
+       @$(MAKE) -s -C compiler/tests/
index 3af157a..7ffd1c2 100644 (file)
@@ -1,13 +1,11 @@
 Import('*')
 
-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',
+    '#/src/glsl',
+    '#/src/mapi',
 ])
 
 r300 = env.ConvenienceLibrary(
@@ -36,7 +34,41 @@ r300 = env.ConvenienceLibrary(
         'r300_texture_desc.c',
         'r300_tgsi_to_rc.c',
         'r300_transfer.c',
-    ] + r300compiler) + r300compiler
+        'compiler/radeon_code.c',
+        'compiler/radeon_compiler.c',
+        'compiler/radeon_compiler_util.c',
+        'compiler/radeon_program.c',
+        'compiler/radeon_program_print.c',
+        'compiler/radeon_opcodes.c',
+        'compiler/radeon_program_alu.c',
+        'compiler/radeon_program_pair.c',
+        'compiler/radeon_program_tex.c',
+        'compiler/radeon_pair_translate.c',
+        'compiler/radeon_pair_schedule.c',
+        'compiler/radeon_pair_regalloc.c',
+        'compiler/radeon_pair_dead_sources.c',
+        'compiler/radeon_optimize.c',
+        'compiler/radeon_remove_constants.c',
+        'compiler/radeon_rename_regs.c',
+        'compiler/radeon_emulate_branches.c',
+        'compiler/radeon_emulate_loops.c',
+        'compiler/radeon_dataflow.c',
+        'compiler/radeon_dataflow_deadcode.c',
+        'compiler/radeon_dataflow_swizzles.c',
+        'compiler/radeon_variable.c',
+        'compiler/radeon_list.c',
+        'compiler/r3xx_fragprog.c',
+        'compiler/r300_fragprog.c',
+        'compiler/r300_fragprog_swizzle.c',
+        'compiler/r300_fragprog_emit.c',
+        'compiler/r500_fragprog.c',
+        'compiler/r500_fragprog_emit.c',
+        'compiler/r3xx_vertprog.c',
+        'compiler/r3xx_vertprog_dump.c',
+        'compiler/memory_pool.c',
+        '#/src/glsl/ralloc.c',
+        '#/src/mesa/program/register_allocate.c'
+    ])
 
 env.Alias('r300', r300)
 
diff --git a/src/gallium/drivers/r300/compiler/memory_pool.c b/src/gallium/drivers/r300/compiler/memory_pool.c
new file mode 100644 (file)
index 0000000..ddcdddf
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 "memory_pool.h"
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#define POOL_LARGE_ALLOC 4096
+#define POOL_ALIGN 8
+
+
+struct memory_block {
+       struct memory_block * next;
+};
+
+void memory_pool_init(struct memory_pool * pool)
+{
+       memset(pool, 0, sizeof(struct memory_pool));
+}
+
+
+void memory_pool_destroy(struct memory_pool * pool)
+{
+       while(pool->blocks) {
+               struct memory_block * block = pool->blocks;
+               pool->blocks = block->next;
+               free(block);
+       }
+}
+
+static void refill_pool(struct memory_pool * pool)
+{
+       unsigned int blocksize = pool->total_allocated;
+       struct memory_block * newblock;
+
+       if (!blocksize)
+               blocksize = 2*POOL_LARGE_ALLOC;
+
+       newblock = (struct memory_block*)malloc(blocksize);
+       newblock->next = pool->blocks;
+       pool->blocks = newblock;
+
+       pool->head = (unsigned char*)(newblock + 1);
+       pool->end = ((unsigned char*)newblock) + blocksize;
+       pool->total_allocated += blocksize;
+}
+
+
+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);
+
+               ptr = pool->head;
+
+               pool->head += bytes;
+               pool->head = (unsigned char*)(((unsigned long)pool->head + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1));
+
+               return ptr;
+       } else {
+               struct memory_block * block = (struct memory_block*)malloc(bytes + sizeof(struct memory_block));
+
+               block->next = pool->blocks;
+               pool->blocks = block;
+
+               return (block + 1);
+       }
+}
+
+
diff --git a/src/gallium/drivers/r300/compiler/memory_pool.h b/src/gallium/drivers/r300/compiler/memory_pool.h
new file mode 100644 (file)
index 0000000..42344d0
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 MEMORY_POOL_H
+#define MEMORY_POOL_H
+
+struct memory_block;
+
+/**
+ * Provides a pool of memory that can quickly be allocated from, at the
+ * cost of being unable to explicitly free one of the allocated blocks.
+ * Instead, the entire pool can be freed at once.
+ *
+ * The idea is to allow one to quickly allocate a flexible amount of
+ * memory during operations like shader compilation while avoiding
+ * reference counting headaches.
+ */
+struct memory_pool {
+       unsigned char * head;
+       unsigned char * end;
+       unsigned int total_allocated;
+       struct memory_block * blocks;
+};
+
+
+void memory_pool_init(struct memory_pool * pool);
+void memory_pool_destroy(struct memory_pool * pool);
+void * memory_pool_malloc(struct memory_pool * pool, unsigned int bytes);
+
+
+/**
+ * Generic helper for growing an array that has separate size/count
+ * and reserved counters to accomodate up to num new element.
+ *
+ *  type * Array;
+ *  unsigned int Size;
+ *  unsigned int Reserved;
+ *
+ * memory_pool_array_reserve(pool, type, Array, Size, Reserved, k);
+ * assert(Size + k < Reserved);
+ *
+ * \note Size is not changed by this macro.
+ *
+ * \warning Array, Size, Reserved have to be lvalues and may be evaluated
+ * several times.
+ */
+#define memory_pool_array_reserve(pool, type, array, size, reserved, num) do { \
+       unsigned int _num = (num); \
+       if ((size) + _num > (reserved)) { \
+               unsigned int newreserve = (reserved) * 2; \
+               type * newarray; \
+               if (newreserve < _num) \
+                       newreserve = 4 * _num; /* arbitrary heuristic */ \
+               newarray = memory_pool_malloc((pool), newreserve * sizeof(type)); \
+               memcpy(newarray, (array), (size) * sizeof(type)); \
+               (array) = newarray; \
+               (reserved) = newreserve; \
+       } \
+} while(0)
+
+#endif /* MEMORY_POOL_H */
diff --git a/src/gallium/drivers/r300/compiler/r300_fragprog.c b/src/gallium/drivers/r300/compiler/r300_fragprog.c
new file mode 100644 (file)
index 0000000..deba9ca
--- /dev/null
@@ -0,0 +1,338 @@
+/*
+ * Copyright (C) 2005 Ben Skeggs.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "r300_fragprog.h"
+
+#include <stdio.h>
+
+#include "../r300_reg.h"
+
+static void presub_string(char out[10], unsigned int inst)
+{
+       switch(inst & 0x600000){
+       case R300_ALU_SRCP_1_MINUS_2_SRC0:
+               sprintf(out, "bias");
+               break;
+       case R300_ALU_SRCP_SRC1_MINUS_SRC0:
+               sprintf(out, "sub");
+               break;
+       case R300_ALU_SRCP_SRC1_PLUS_SRC0:
+               sprintf(out, "add");
+               break;
+       case R300_ALU_SRCP_1_MINUS_SRC0:
+               sprintf(out, "inv ");
+               break;
+       }
+}
+
+static int get_msb(unsigned int bit, unsigned int r400_ext_addr)
+{
+       return (r400_ext_addr & bit) ? 1 << 5 : 0;
+}
+
+/* just some random things... */
+void r300FragmentProgramDump(struct radeon_compiler *c, void *user)
+{
+       struct r300_fragment_program_compiler *compiler = (struct r300_fragment_program_compiler*)c;
+       struct r300_fragment_program_code *code = &compiler->code->code.r300;
+       int n, i, j;
+       static int pc = 0;
+
+       fprintf(stderr, "pc=%d*************************************\n", pc++);
+
+       fprintf(stderr, "Hardware program\n");
+       fprintf(stderr, "----------------\n");
+       if (c->is_r400) {
+               fprintf(stderr, "code_offset_ext: %08x\n", code->r400_code_offset_ext);
+       }
+
+       for (n = 0; n <= (code->config & 3); n++) {
+               uint32_t code_addr = code->code_addr[3 - (code->config & 3) + n];
+               unsigned int alu_offset = ((code_addr & R300_ALU_START_MASK) >> R300_ALU_START_SHIFT) +
+                               (((code->r400_code_offset_ext >> (24 - (n * 6))) & 0x7) << 6);
+               unsigned int alu_end = ((code_addr & R300_ALU_SIZE_MASK) >> R300_ALU_SIZE_SHIFT) +
+                               (((code->r400_code_offset_ext >> (27 - (n * 6))) & 0x7) << 6);
+               int tex_offset = (code_addr & R300_TEX_START_MASK) >> R300_TEX_START_SHIFT;
+               int tex_end = (code_addr & R300_TEX_SIZE_MASK) >> R300_TEX_SIZE_SHIFT;
+
+               fprintf(stderr, "NODE %d: alu_offset: %u, tex_offset: %d, "
+                       "alu_end: %u, tex_end: %d  (code_addr: %08x)\n", n,
+                       alu_offset, tex_offset, alu_end, tex_end, code_addr);
+
+               if (n > 0 || (code->config & R300_PFS_CNTL_FIRST_NODE_HAS_TEX)) {
+                       fprintf(stderr, "  TEX:\n");
+                       for (i = tex_offset;
+                            i <= tex_offset + tex_end;
+                            ++i) {
+                               const char *instr;
+
+                               switch ((code->tex.
+                                        inst[i] >> R300_TEX_INST_SHIFT) &
+                                       15) {
+                               case R300_TEX_OP_LD:
+                                       instr = "TEX";
+                                       break;
+                               case R300_TEX_OP_KIL:
+                                       instr = "KIL";
+                                       break;
+                               case R300_TEX_OP_TXP:
+                                       instr = "TXP";
+                                       break;
+                               case R300_TEX_OP_TXB:
+                                       instr = "TXB";
+                                       break;
+                               default:
+                                       instr = "UNKNOWN";
+                               }
+
+                               fprintf(stderr,
+                                       "    %s t%i, %c%i, texture[%i]   (%08x)\n",
+                                       instr,
+                                       (code->tex.
+                                        inst[i] >> R300_DST_ADDR_SHIFT) & 31,
+                                       't',
+                                       (code->tex.
+                                        inst[i] >> R300_SRC_ADDR_SHIFT) & 31,
+                                       (code->tex.
+                                        inst[i] & R300_TEX_ID_MASK) >>
+                                       R300_TEX_ID_SHIFT,
+                                       code->tex.inst[i]);
+                       }
+               }
+
+               for (i = alu_offset;
+                    i <= alu_offset + alu_end; ++i) {
+                       char srcc[4][10], dstc[20];
+                       char srca[4][10], dsta[20];
+                       char argc[3][20];
+                       char arga[3][20];
+                       char flags[5], tmp[10];
+
+                       for (j = 0; j < 3; ++j) {
+                               int regc = code->alu.inst[i].rgb_addr >> (j * 6);
+                               int rega = code->alu.inst[i].alpha_addr >> (j * 6);
+                               int msbc = get_msb(R400_ADDR_EXT_RGB_MSB_BIT(j),
+                                       code->alu.inst[i].r400_ext_addr);
+                               int msba = get_msb(R400_ADDR_EXT_A_MSB_BIT(j),
+                                       code->alu.inst[i].r400_ext_addr);
+
+                               sprintf(srcc[j], "%c%i",
+                                       (regc & 32) ? 'c' : 't', (regc & 31) | msbc);
+                               sprintf(srca[j], "%c%i",
+                                       (rega & 32) ? 'c' : 't', (rega & 31) | msba);
+                       }
+
+                       dstc[0] = 0;
+                       sprintf(flags, "%s%s%s",
+                               (code->alu.inst[i].
+                                rgb_addr & R300_ALU_DSTC_REG_X) ? "x" : "",
+                               (code->alu.inst[i].
+                                rgb_addr & R300_ALU_DSTC_REG_Y) ? "y" : "",
+                               (code->alu.inst[i].
+                                rgb_addr & R300_ALU_DSTC_REG_Z) ? "z" : "");
+                       if (flags[0] != 0) {
+                               unsigned int msb = get_msb(
+                                       R400_ADDRD_EXT_RGB_MSB_BIT,
+                                       code->alu.inst[i].r400_ext_addr);
+
+                               sprintf(dstc, "t%i.%s ",
+                                       ((code->alu.inst[i].
+                                        rgb_addr >> R300_ALU_DSTC_SHIFT)
+                                        & 31) | msb,
+                                       flags);
+                       }
+                       sprintf(flags, "%s%s%s",
+                               (code->alu.inst[i].
+                                rgb_addr & R300_ALU_DSTC_OUTPUT_X) ? "x" : "",
+                               (code->alu.inst[i].
+                                rgb_addr & R300_ALU_DSTC_OUTPUT_Y) ? "y" : "",
+                               (code->alu.inst[i].
+                                rgb_addr & R300_ALU_DSTC_OUTPUT_Z) ? "z" : "");
+                       if (flags[0] != 0) {
+                               sprintf(tmp, "o%i.%s",
+                                       (code->alu.inst[i].
+                                        rgb_addr >> 29) & 3,
+                                       flags);
+                               strcat(dstc, tmp);
+                       }
+                       /* Presub */
+                       presub_string(srcc[3], code->alu.inst[i].rgb_inst);
+                       presub_string(srca[3], code->alu.inst[i].alpha_inst);
+
+                       dsta[0] = 0;
+                       if (code->alu.inst[i].alpha_addr & R300_ALU_DSTA_REG) {
+                               unsigned int msb = get_msb(
+                                       R400_ADDRD_EXT_A_MSB_BIT,
+                                       code->alu.inst[i].r400_ext_addr);
+                               sprintf(dsta, "t%i.w ",
+                                       ((code->alu.inst[i].
+                                        alpha_addr >> R300_ALU_DSTA_SHIFT) & 31)
+                                        | msb);
+                       }
+                       if (code->alu.inst[i].alpha_addr & R300_ALU_DSTA_OUTPUT) {
+                               sprintf(tmp, "o%i.w ",
+                                       (code->alu.inst[i].
+                                        alpha_addr >> 25) & 3);
+                               strcat(dsta, tmp);
+                       }
+                       if (code->alu.inst[i].alpha_addr & R300_ALU_DSTA_DEPTH) {
+                               strcat(dsta, "Z");
+                       }
+
+                       fprintf(stderr,
+                               "%3i: xyz: %3s %3s %3s %5s-> %-20s (%08x)\n"
+                               "       w: %3s %3s %3s %5s-> %-20s (%08x)\n", i,
+                               srcc[0], srcc[1], srcc[2], srcc[3], dstc,
+                               code->alu.inst[i].rgb_addr, srca[0], srca[1],
+                               srca[2], srca[3], dsta,
+                               code->alu.inst[i].alpha_addr);
+
+                       for (j = 0; j < 3; ++j) {
+                               int regc = code->alu.inst[i].rgb_inst >> (j * 7);
+                               int rega = code->alu.inst[i].alpha_inst >> (j * 7);
+                               int d;
+                               char buf[20];
+
+                               d = regc & 31;
+                               if (d < 12) {
+                                       switch (d % 4) {
+                                       case R300_ALU_ARGC_SRC0C_XYZ:
+                                               sprintf(buf, "%s.xyz",
+                                                       srcc[d / 4]);
+                                               break;
+                                       case R300_ALU_ARGC_SRC0C_XXX:
+                                               sprintf(buf, "%s.xxx",
+                                                       srcc[d / 4]);
+                                               break;
+                                       case R300_ALU_ARGC_SRC0C_YYY:
+                                               sprintf(buf, "%s.yyy",
+                                                       srcc[d / 4]);
+                                               break;
+                                       case R300_ALU_ARGC_SRC0C_ZZZ:
+                                               sprintf(buf, "%s.zzz",
+                                                       srcc[d / 4]);
+                                               break;
+                                       }
+                               } else if (d < 15) {
+                                       sprintf(buf, "%s.www", srca[d - 12]);
+                               } else if (d < 20 ) {
+                                       switch(d) {
+                                       case R300_ALU_ARGC_SRCP_XYZ:
+                                               sprintf(buf, "srcp.xyz");
+                                               break;
+                                       case R300_ALU_ARGC_SRCP_XXX:
+                                               sprintf(buf, "srcp.xxx");
+                                               break;
+                                       case R300_ALU_ARGC_SRCP_YYY:
+                                               sprintf(buf, "srcp.yyy");
+                                               break;
+                                       case R300_ALU_ARGC_SRCP_ZZZ:
+                                               sprintf(buf, "srcp.zzz");
+                                               break;
+                                       case R300_ALU_ARGC_SRCP_WWW:
+                                               sprintf(buf, "srcp.www");
+                                               break;
+                                       }
+                               } else if (d == 20) {
+                                       sprintf(buf, "0.0");
+                               } else if (d == 21) {
+                                       sprintf(buf, "1.0");
+                               } else if (d == 22) {
+                                       sprintf(buf, "0.5");
+                               } else if (d >= 23 && d < 32) {
+                                       d -= 23;
+                                       switch (d / 3) {
+                                       case 0:
+                                               sprintf(buf, "%s.yzx",
+                                                       srcc[d % 3]);
+                                               break;
+                                       case 1:
+                                               sprintf(buf, "%s.zxy",
+                                                       srcc[d % 3]);
+                                               break;
+                                       case 2:
+                                               sprintf(buf, "%s.Wzy",
+                                                       srcc[d % 3]);
+                                               break;
+                                       }
+                               } else {
+                                       sprintf(buf, "%i", d);
+                               }
+
+                               sprintf(argc[j], "%s%s%s%s",
+                                       (regc & 32) ? "-" : "",
+                                       (regc & 64) ? "|" : "",
+                                       buf, (regc & 64) ? "|" : "");
+
+                               d = rega & 31;
+                               if (d < 9) {
+                                       sprintf(buf, "%s.%c", srcc[d / 3],
+                                               'x' + (char)(d % 3));
+                               } else if (d < 12) {
+                                       sprintf(buf, "%s.w", srca[d - 9]);
+                               } else if (d < 16) {
+                                       switch(d) {
+                                       case R300_ALU_ARGA_SRCP_X:
+                                               sprintf(buf, "srcp.x");
+                                               break;
+                                       case R300_ALU_ARGA_SRCP_Y:
+                                               sprintf(buf, "srcp.y");
+                                               break;
+                                       case R300_ALU_ARGA_SRCP_Z:
+                                               sprintf(buf, "srcp.z");
+                                               break;
+                                       case R300_ALU_ARGA_SRCP_W:
+                                               sprintf(buf, "srcp.w");
+                                               break;
+                                       }
+                               } else if (d == 16) {
+                                       sprintf(buf, "0.0");
+                               } else if (d == 17) {
+                                       sprintf(buf, "1.0");
+                               } else if (d == 18) {
+                                       sprintf(buf, "0.5");
+                               } else {
+                                       sprintf(buf, "%i", d);
+                               }
+
+                               sprintf(arga[j], "%s%s%s%s",
+                                       (rega & 32) ? "-" : "",
+                                       (rega & 64) ? "|" : "",
+                                       buf, (rega & 64) ? "|" : "");
+                       }
+
+                       fprintf(stderr, "     xyz: %8s %8s %8s    op: %08x %s\n"
+                               "       w: %8s %8s %8s    op: %08x\n",
+                               argc[0], argc[1], argc[2],
+                               code->alu.inst[i].rgb_inst,
+                               code->alu.inst[i].rgb_inst & R300_ALU_INSERT_NOP ?
+                               "NOP" : "",
+                               arga[0], arga[1],arga[2],
+                               code->alu.inst[i].alpha_inst);
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/r300_fragprog.h b/src/gallium/drivers/r300/compiler/r300_fragprog.h
new file mode 100644 (file)
index 0000000..0c88bab
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2005 Ben Skeggs.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/*
+ * Authors:
+ *   Ben Skeggs <darktama@iinet.net.au>
+ *   Jerome Glisse <j.glisse@gmail.com>
+ */
+#ifndef __R300_FRAGPROG_H_
+#define __R300_FRAGPROG_H_
+
+#include "radeon_compiler.h"
+#include "radeon_program.h"
+
+
+extern void r300BuildFragmentProgramHwCode(struct radeon_compiler *c, void *user);
+
+extern void r300FragmentProgramDump(struct radeon_compiler *c, void *user);
+
+#endif
diff --git a/src/gallium/drivers/r300/compiler/r300_fragprog_emit.c b/src/gallium/drivers/r300/compiler/r300_fragprog_emit.c
new file mode 100644 (file)
index 0000000..e6fd1fd
--- /dev/null
@@ -0,0 +1,536 @@
+/*
+ * Copyright (C) 2005 Ben Skeggs.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * \file
+ *
+ * Emit the r300_fragment_program_code that can be understood by the hardware.
+ * Input is a pre-transformed radeon_program.
+ *
+ * \author Ben Skeggs <darktama@iinet.net.au>
+ *
+ * \author Jerome Glisse <j.glisse@gmail.com>
+ */
+
+#include "r300_fragprog.h"
+
+#include "../r300_reg.h"
+
+#include "radeon_program_pair.h"
+#include "r300_fragprog_swizzle.h"
+
+
+struct r300_emit_state {
+       struct r300_fragment_program_compiler * compiler;
+
+       unsigned current_node : 2;
+       unsigned node_first_tex : 8;
+       unsigned node_first_alu : 8;
+       uint32_t node_flags;
+};
+
+#define PROG_CODE \
+       struct r300_fragment_program_compiler *c = emit->compiler; \
+       struct r300_fragment_program_code *code = &c->code->code.r300
+
+#define error(fmt, args...) do {                       \
+               rc_error(&c->Base, "%s::%s(): " fmt "\n",       \
+                       __FILE__, __FUNCTION__, ##args);        \
+       } while(0)
+
+static unsigned int get_msbs_alu(unsigned int bits)
+{
+       return (bits >> 6) & 0x7;
+}
+
+/**
+ * @param lsbs The number of least significant bits
+ */
+static unsigned int get_msbs_tex(unsigned int bits, unsigned int lsbs)
+{
+       return (bits >> lsbs) & 0x15;
+}
+
+#define R400_EXT_GET_MSBS(x, lsbs, mask) (((x) >> lsbs) & mask)
+
+/**
+ * Mark a temporary register as used.
+ */
+static void use_temporary(struct r300_fragment_program_code *code, unsigned int index)
+{
+       if (index > code->pixsize)
+               code->pixsize = index;
+}
+
+static unsigned int use_source(struct r300_fragment_program_code* code, struct rc_pair_instruction_source src)
+{
+       if (!src.Used)
+               return 0;
+
+       if (src.File == RC_FILE_CONSTANT) {
+               return src.Index | (1 << 5);
+       } else if (src.File == RC_FILE_TEMPORARY || src.File == RC_FILE_INPUT) {
+               use_temporary(code, src.Index);
+               return src.Index & 0x1f;
+       }
+
+       return 0;
+}
+
+
+static unsigned int translate_rgb_opcode(struct r300_fragment_program_compiler * c, rc_opcode opcode)
+{
+       switch(opcode) {
+       case RC_OPCODE_CMP: return R300_ALU_OUTC_CMP;
+       case RC_OPCODE_CND: return R300_ALU_OUTC_CND;
+       case RC_OPCODE_DP3: return R300_ALU_OUTC_DP3;
+       case RC_OPCODE_DP4: return R300_ALU_OUTC_DP4;
+       case RC_OPCODE_FRC: return R300_ALU_OUTC_FRC;
+       default:
+               error("translate_rgb_opcode: Unknown opcode %s", rc_get_opcode_info(opcode)->Name);
+               /* fall through */
+       case RC_OPCODE_NOP:
+               /* fall through */
+       case RC_OPCODE_MAD: return R300_ALU_OUTC_MAD;
+       case RC_OPCODE_MAX: return R300_ALU_OUTC_MAX;
+       case RC_OPCODE_MIN: return R300_ALU_OUTC_MIN;
+       case RC_OPCODE_REPL_ALPHA: return R300_ALU_OUTC_REPL_ALPHA;
+       }
+}
+
+static unsigned int translate_alpha_opcode(struct r300_fragment_program_compiler * c, rc_opcode opcode)
+{
+       switch(opcode) {
+       case RC_OPCODE_CMP: return R300_ALU_OUTA_CMP;
+       case RC_OPCODE_CND: return R300_ALU_OUTA_CND;
+       case RC_OPCODE_DP3: return R300_ALU_OUTA_DP4;
+       case RC_OPCODE_DP4: return R300_ALU_OUTA_DP4;
+       case RC_OPCODE_EX2: return R300_ALU_OUTA_EX2;
+       case RC_OPCODE_FRC: return R300_ALU_OUTA_FRC;
+       case RC_OPCODE_LG2: return R300_ALU_OUTA_LG2;
+       default:
+               error("translate_rgb_opcode: Unknown opcode %s", rc_get_opcode_info(opcode)->Name);
+               /* fall through */
+       case RC_OPCODE_NOP:
+               /* fall through */
+       case RC_OPCODE_MAD: return R300_ALU_OUTA_MAD;
+       case RC_OPCODE_MAX: return R300_ALU_OUTA_MAX;
+       case RC_OPCODE_MIN: return R300_ALU_OUTA_MIN;
+       case RC_OPCODE_RCP: return R300_ALU_OUTA_RCP;
+       case RC_OPCODE_RSQ: return R300_ALU_OUTA_RSQ;
+       }
+}
+
+/**
+ * Emit one paired ALU instruction.
+ */
+static int emit_alu(struct r300_emit_state * emit, struct rc_pair_instruction* inst)
+{
+       int ip;
+       int j;
+       PROG_CODE;
+
+       if (code->alu.length >= c->Base.max_alu_insts) {
+               error("Too many ALU instructions");
+               return 0;
+       }
+
+       ip = code->alu.length++;
+
+       code->alu.inst[ip].rgb_inst = translate_rgb_opcode(c, inst->RGB.Opcode);
+       code->alu.inst[ip].alpha_inst = translate_alpha_opcode(c, inst->Alpha.Opcode);
+
+       for(j = 0; j < 3; ++j) {
+               /* Set the RGB address */
+               unsigned int src = use_source(code, inst->RGB.Src[j]);
+               unsigned int arg;
+               if (inst->RGB.Src[j].Index >= R300_PFS_NUM_TEMP_REGS)
+                       code->alu.inst[ip].r400_ext_addr |= R400_ADDR_EXT_RGB_MSB_BIT(j);
+
+               code->alu.inst[ip].rgb_addr |= src << (6*j);
+
+               /* Set the Alpha address */
+               src = use_source(code, inst->Alpha.Src[j]);
+               if (inst->Alpha.Src[j].Index >= R300_PFS_NUM_TEMP_REGS)
+                       code->alu.inst[ip].r400_ext_addr |= R400_ADDR_EXT_A_MSB_BIT(j);
+
+               code->alu.inst[ip].alpha_addr |= src << (6*j);
+
+               arg = r300FPTranslateRGBSwizzle(inst->RGB.Arg[j].Source, inst->RGB.Arg[j].Swizzle);
+               arg |= inst->RGB.Arg[j].Abs << 6;
+               arg |= inst->RGB.Arg[j].Negate << 5;
+               code->alu.inst[ip].rgb_inst |= arg << (7*j);
+
+               arg = r300FPTranslateAlphaSwizzle(inst->Alpha.Arg[j].Source, inst->Alpha.Arg[j].Swizzle);
+               arg |= inst->Alpha.Arg[j].Abs << 6;
+               arg |= inst->Alpha.Arg[j].Negate << 5;
+               code->alu.inst[ip].alpha_inst |= arg << (7*j);
+       }
+
+       /* Presubtract */
+       if (inst->RGB.Src[RC_PAIR_PRESUB_SRC].Used) {
+               switch(inst->RGB.Src[RC_PAIR_PRESUB_SRC].Index) {
+               case RC_PRESUB_BIAS:
+                       code->alu.inst[ip].rgb_inst |=
+                                               R300_ALU_SRCP_1_MINUS_2_SRC0;
+                       break;
+               case RC_PRESUB_ADD:
+                       code->alu.inst[ip].rgb_inst |=
+                                               R300_ALU_SRCP_SRC1_PLUS_SRC0;
+                       break;
+               case RC_PRESUB_SUB:
+                       code->alu.inst[ip].rgb_inst |=
+                                               R300_ALU_SRCP_SRC1_MINUS_SRC0;
+                       break;
+               case RC_PRESUB_INV:
+                       code->alu.inst[ip].rgb_inst |=
+                                               R300_ALU_SRCP_1_MINUS_SRC0;
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       if (inst->Alpha.Src[RC_PAIR_PRESUB_SRC].Used) {
+               switch(inst->Alpha.Src[RC_PAIR_PRESUB_SRC].Index) {
+               case RC_PRESUB_BIAS:
+                       code->alu.inst[ip].alpha_inst |=
+                                               R300_ALU_SRCP_1_MINUS_2_SRC0;
+                       break;
+               case RC_PRESUB_ADD:
+                       code->alu.inst[ip].alpha_inst |=
+                                               R300_ALU_SRCP_SRC1_PLUS_SRC0;
+                       break;
+               case RC_PRESUB_SUB:
+                       code->alu.inst[ip].alpha_inst |=
+                                               R300_ALU_SRCP_SRC1_MINUS_SRC0;
+                       break;
+               case RC_PRESUB_INV:
+                       code->alu.inst[ip].alpha_inst |=
+                                               R300_ALU_SRCP_1_MINUS_SRC0;
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       if (inst->RGB.Saturate)
+               code->alu.inst[ip].rgb_inst |= R300_ALU_OUTC_CLAMP;
+       if (inst->Alpha.Saturate)
+               code->alu.inst[ip].alpha_inst |= R300_ALU_OUTA_CLAMP;
+
+       if (inst->RGB.WriteMask) {
+               use_temporary(code, inst->RGB.DestIndex);
+               if (inst->RGB.DestIndex >= R300_PFS_NUM_TEMP_REGS)
+                       code->alu.inst[ip].r400_ext_addr |= R400_ADDRD_EXT_RGB_MSB_BIT;
+               code->alu.inst[ip].rgb_addr |=
+                       ((inst->RGB.DestIndex & 0x1f) << R300_ALU_DSTC_SHIFT) |
+                       (inst->RGB.WriteMask << R300_ALU_DSTC_REG_MASK_SHIFT);
+       }
+       if (inst->RGB.OutputWriteMask) {
+               code->alu.inst[ip].rgb_addr |=
+            (inst->RGB.OutputWriteMask << R300_ALU_DSTC_OUTPUT_MASK_SHIFT) |
+            R300_RGB_TARGET(inst->RGB.Target);
+               emit->node_flags |= R300_RGBA_OUT;
+       }
+
+       if (inst->Alpha.WriteMask) {
+               use_temporary(code, inst->Alpha.DestIndex);
+               if (inst->Alpha.DestIndex >= R300_PFS_NUM_TEMP_REGS)
+                       code->alu.inst[ip].r400_ext_addr |= R400_ADDRD_EXT_A_MSB_BIT;
+               code->alu.inst[ip].alpha_addr |=
+                       ((inst->Alpha.DestIndex & 0x1f) << R300_ALU_DSTA_SHIFT) |
+                       R300_ALU_DSTA_REG;
+       }
+       if (inst->Alpha.OutputWriteMask) {
+               code->alu.inst[ip].alpha_addr |= R300_ALU_DSTA_OUTPUT |
+            R300_ALPHA_TARGET(inst->Alpha.Target);
+               emit->node_flags |= R300_RGBA_OUT;
+       }
+       if (inst->Alpha.DepthWriteMask) {
+               code->alu.inst[ip].alpha_addr |= R300_ALU_DSTA_DEPTH;
+               emit->node_flags |= R300_W_OUT;
+               c->code->writes_depth = 1;
+       }
+       if (inst->Nop)
+               code->alu.inst[ip].rgb_inst |= R300_ALU_INSERT_NOP;
+
+       return 1;
+}
+
+
+/**
+ * Finish the current node without advancing to the next one.
+ */
+static int finish_node(struct r300_emit_state * emit)
+{
+       struct r300_fragment_program_compiler * c = emit->compiler;
+       struct r300_fragment_program_code *code = &emit->compiler->code->code.r300;
+       unsigned alu_offset;
+       unsigned alu_end;
+       unsigned tex_offset;
+       unsigned tex_end;
+
+       unsigned int alu_offset_msbs, alu_end_msbs;
+
+       if (code->alu.length == emit->node_first_alu) {
+               /* Generate a single NOP for this node */
+               struct rc_pair_instruction inst;
+               memset(&inst, 0, sizeof(inst));
+               if (!emit_alu(emit, &inst))
+                       return 0;
+       }
+
+       alu_offset = emit->node_first_alu;
+       alu_end = code->alu.length - alu_offset - 1;
+       tex_offset = emit->node_first_tex;
+       tex_end = code->tex.length - tex_offset - 1;
+
+       if (code->tex.length == emit->node_first_tex) {
+               if (emit->current_node > 0) {
+                       error("Node %i has no TEX instructions", emit->current_node);
+                       return 0;
+               }
+
+               tex_end = 0;
+       } else {
+               if (emit->current_node == 0)
+                       code->config |= R300_PFS_CNTL_FIRST_NODE_HAS_TEX;
+       }
+
+       /* Write the config register.
+        * Note: The order in which the words for each node are written
+        * is not correct here and needs to be fixed up once we're entirely
+        * done
+        *
+        * Also note that the register specification from AMD is slightly
+        * incorrect in its description of this register. */
+       code->code_addr[emit->current_node]  =
+                       ((alu_offset << R300_ALU_START_SHIFT)
+                               & R300_ALU_START_MASK)
+                       | ((alu_end << R300_ALU_SIZE_SHIFT)
+                               & R300_ALU_SIZE_MASK)
+                       | ((tex_offset << R300_TEX_START_SHIFT)
+                               & R300_TEX_START_MASK)
+                       | ((tex_end << R300_TEX_SIZE_SHIFT)
+                               & R300_TEX_SIZE_MASK)
+                       | emit->node_flags
+                       | (get_msbs_tex(tex_offset, 5)
+                               << R400_TEX_START_MSB_SHIFT)
+                       | (get_msbs_tex(tex_end, 5)
+                               << R400_TEX_SIZE_MSB_SHIFT)
+                       ;
+
+       /* Write r400 extended instruction fields.  These will be ignored on
+        * r300 cards.  */
+       alu_offset_msbs = get_msbs_alu(alu_offset);
+       alu_end_msbs = get_msbs_alu(alu_end);
+       switch(emit->current_node) {
+       case 0:
+               code->r400_code_offset_ext |=
+                       alu_offset_msbs << R400_ALU_START3_MSB_SHIFT
+                       | alu_end_msbs << R400_ALU_SIZE3_MSB_SHIFT;
+               break;
+       case 1:
+               code->r400_code_offset_ext |=
+                       alu_offset_msbs << R400_ALU_START2_MSB_SHIFT
+                       | alu_end_msbs << R400_ALU_SIZE2_MSB_SHIFT;
+               break;
+       case 2:
+               code->r400_code_offset_ext |=
+                       alu_offset_msbs << R400_ALU_START1_MSB_SHIFT
+                       | alu_end_msbs << R400_ALU_SIZE1_MSB_SHIFT;
+               break;
+       case 3:
+               code->r400_code_offset_ext |=
+                       alu_offset_msbs << R400_ALU_START0_MSB_SHIFT
+                       | alu_end_msbs << R400_ALU_SIZE0_MSB_SHIFT;
+               break;
+       }
+       return 1;
+}
+
+
+/**
+ * Begin a block of texture instructions.
+ * Create the necessary indirection.
+ */
+static int begin_tex(struct r300_emit_state * emit)
+{
+       PROG_CODE;
+
+       if (code->alu.length == emit->node_first_alu &&
+           code->tex.length == emit->node_first_tex) {
+               return 1;
+       }
+
+       if (emit->current_node == 3) {
+               error("Too many texture indirections");
+               return 0;
+       }
+
+       if (!finish_node(emit))
+               return 0;
+
+       emit->current_node++;
+       emit->node_first_tex = code->tex.length;
+       emit->node_first_alu = code->alu.length;
+       emit->node_flags = 0;
+       return 1;
+}
+
+
+static int emit_tex(struct r300_emit_state * emit, struct rc_instruction * inst)
+{
+       unsigned int unit;
+       unsigned int dest;
+       unsigned int opcode;
+       PROG_CODE;
+
+       if (code->tex.length >= emit->compiler->Base.max_tex_insts) {
+               error("Too many TEX instructions");
+               return 0;
+       }
+
+       unit = inst->U.I.TexSrcUnit;
+       dest = inst->U.I.DstReg.Index;
+
+       switch(inst->U.I.Opcode) {
+       case RC_OPCODE_KIL: opcode = R300_TEX_OP_KIL; break;
+       case RC_OPCODE_TEX: opcode = R300_TEX_OP_LD; break;
+       case RC_OPCODE_TXB: opcode = R300_TEX_OP_TXB; break;
+       case RC_OPCODE_TXP: opcode = R300_TEX_OP_TXP; break;
+       default:
+               error("Unknown texture opcode %s", rc_get_opcode_info(inst->U.I.Opcode)->Name);
+               return 0;
+       }
+
+       if (inst->U.I.Opcode == RC_OPCODE_KIL) {
+               unit = 0;
+               dest = 0;
+       } else {
+               use_temporary(code, dest);
+       }
+
+       use_temporary(code, inst->U.I.SrcReg[0].Index);
+
+       code->tex.inst[code->tex.length++] =
+               ((inst->U.I.SrcReg[0].Index << R300_SRC_ADDR_SHIFT)
+                       & R300_SRC_ADDR_MASK)
+               | ((dest << R300_DST_ADDR_SHIFT)
+                       & R300_DST_ADDR_MASK)
+               | (unit << R300_TEX_ID_SHIFT)
+               | (opcode << R300_TEX_INST_SHIFT)
+               | (inst->U.I.SrcReg[0].Index >= R300_PFS_NUM_TEMP_REGS ?
+                       R400_SRC_ADDR_EXT_BIT : 0)
+               | (dest >= R300_PFS_NUM_TEMP_REGS ?
+                       R400_DST_ADDR_EXT_BIT : 0)
+               ;
+       return 1;
+}
+
+
+/**
+ * Final compilation step: Turn the intermediate radeon_program into
+ * machine-readable instructions.
+ */
+void r300BuildFragmentProgramHwCode(struct radeon_compiler *c, void *user)
+{
+       struct r300_fragment_program_compiler *compiler = (struct r300_fragment_program_compiler*)c;
+       struct r300_emit_state emit;
+       struct r300_fragment_program_code *code = &compiler->code->code.r300;
+       unsigned int tex_end;
+
+       memset(&emit, 0, sizeof(emit));
+       emit.compiler = compiler;
+
+       memset(code, 0, sizeof(struct r300_fragment_program_code));
+
+       for(struct rc_instruction * inst = compiler->Base.Program.Instructions.Next;
+           inst != &compiler->Base.Program.Instructions && !compiler->Base.Error;
+           inst = inst->Next) {
+               if (inst->Type == RC_INSTRUCTION_NORMAL) {
+                       if (inst->U.I.Opcode == RC_OPCODE_BEGIN_TEX) {
+                               begin_tex(&emit);
+                               continue;
+                       }
+
+                       emit_tex(&emit, inst);
+               } else {
+                       emit_alu(&emit, &inst->U.P);
+               }
+       }
+
+       if (code->pixsize >= compiler->Base.max_temp_regs)
+               rc_error(&compiler->Base, "Too many hardware temporaries used.\n");
+
+       if (compiler->Base.Error)
+               return;
+
+       /* Finish the program */
+       finish_node(&emit);
+
+       code->config |= emit.current_node; /* FIRST_NODE_HAS_TEX set by finish_node */
+
+       /* Set r400 extended instruction fields.  These values will be ignored
+        * on r300 cards. */
+       code->r400_code_offset_ext |=
+               (get_msbs_alu(0)
+                               << R400_ALU_OFFSET_MSB_SHIFT)
+               | (get_msbs_alu(code->alu.length - 1)
+                               << R400_ALU_SIZE_MSB_SHIFT);
+
+       tex_end = code->tex.length ? code->tex.length - 1 : 0;
+       code->code_offset =
+               ((0 << R300_PFS_CNTL_ALU_OFFSET_SHIFT)
+                       & R300_PFS_CNTL_ALU_OFFSET_MASK)
+               | (((code->alu.length - 1) << R300_PFS_CNTL_ALU_END_SHIFT)
+                       & R300_PFS_CNTL_ALU_END_MASK)
+               | ((0 << R300_PFS_CNTL_TEX_OFFSET_SHIFT)
+                       & R300_PFS_CNTL_TEX_OFFSET_MASK)
+               | ((tex_end << R300_PFS_CNTL_TEX_END_SHIFT)
+                       & R300_PFS_CNTL_TEX_END_MASK)
+               | (get_msbs_tex(0, 5) << R400_TEX_START_MSB_SHIFT)
+               | (get_msbs_tex(tex_end, 6) << R400_TEX_SIZE_MSB_SHIFT)
+               ;
+
+       if (emit.current_node < 3) {
+               int shift = 3 - emit.current_node;
+               int i;
+               for(i = emit.current_node; i >= 0; --i)
+                       code->code_addr[shift + i] = code->code_addr[i];
+               for(i = 0; i < shift; ++i)
+                       code->code_addr[i] = 0;
+       }
+
+       if (code->pixsize >= R300_PFS_NUM_TEMP_REGS
+           || code->alu.length > R300_PFS_MAX_ALU_INST
+           || code->tex.length > R300_PFS_MAX_TEX_INST) {
+
+               code->r390_mode = 1;
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.c b/src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.c
new file mode 100644 (file)
index 0000000..b7bca8c
--- /dev/null
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * @file
+ * Utilities to deal with the somewhat odd restriction on R300 fragment
+ * program swizzles.
+ */
+
+#include "r300_fragprog_swizzle.h"
+
+#include <stdio.h>
+
+#include "../r300_reg.h"
+#include "radeon_compiler.h"
+
+#define MAKE_SWZ3(x, y, z) (RC_MAKE_SWIZZLE(RC_SWIZZLE_##x, RC_SWIZZLE_##y, RC_SWIZZLE_##z, RC_SWIZZLE_ZERO))
+
+struct swizzle_data {
+       unsigned int hash; /**< swizzle value this matches */
+       unsigned int base; /**< base value for hw swizzle */
+       unsigned int stride; /**< difference in base between arg0/1/2 */
+       unsigned int srcp_stride; /**< difference in base between arg0/scrp */
+};
+
+static const struct swizzle_data native_swizzles[] = {
+       {MAKE_SWZ3(X, Y, Z), R300_ALU_ARGC_SRC0C_XYZ, 4, 15},
+       {MAKE_SWZ3(X, X, X), R300_ALU_ARGC_SRC0C_XXX, 4, 15},
+       {MAKE_SWZ3(Y, Y, Y), R300_ALU_ARGC_SRC0C_YYY, 4, 15},
+       {MAKE_SWZ3(Z, Z, Z), R300_ALU_ARGC_SRC0C_ZZZ, 4, 15},
+       {MAKE_SWZ3(W, W, W), R300_ALU_ARGC_SRC0A, 1, 7},
+       {MAKE_SWZ3(Y, Z, X), R300_ALU_ARGC_SRC0C_YZX, 1, 0},
+       {MAKE_SWZ3(Z, X, Y), R300_ALU_ARGC_SRC0C_ZXY, 1, 0},
+       {MAKE_SWZ3(W, Z, Y), R300_ALU_ARGC_SRC0CA_WZY, 1, 0},
+       {MAKE_SWZ3(ONE, ONE, ONE), R300_ALU_ARGC_ONE, 0, 0},
+       {MAKE_SWZ3(ZERO, ZERO, ZERO), R300_ALU_ARGC_ZERO, 0, 0},
+       {MAKE_SWZ3(HALF, HALF, HALF), R300_ALU_ARGC_HALF, 0, 0}
+};
+
+static const int num_native_swizzles = sizeof(native_swizzles)/sizeof(native_swizzles[0]);
+
+/**
+ * Find a native RGB swizzle that matches the given swizzle.
+ * Returns 0 if none found.
+ */
+static const struct swizzle_data* lookup_native_swizzle(unsigned int swizzle)
+{
+       int i, comp;
+
+       for(i = 0; i < num_native_swizzles; ++i) {
+               const struct swizzle_data* sd = &native_swizzles[i];
+               for(comp = 0; comp < 3; ++comp) {
+                       unsigned int swz = GET_SWZ(swizzle, comp);
+                       if (swz == RC_SWIZZLE_UNUSED)
+                               continue;
+                       if (swz != GET_SWZ(sd->hash, comp))
+                               break;
+               }
+               if (comp == 3)
+                       return sd;
+       }
+
+       return 0;
+}
+
+/**
+ * Determines if the given swizzle is valid for r300/r400.  In most situations
+ * it is better to use r300_swizzle_is_native() which can be accesed via
+ * struct radeon_compiler *c; c->SwizzleCaps->IsNative().
+ */
+int r300_swizzle_is_native_basic(unsigned int swizzle)
+{
+       if(lookup_native_swizzle(swizzle))
+               return 1;
+       else
+               return 0;
+}
+
+/**
+ * Check whether the given instruction supports the swizzle and negate
+ * combinations in the given source register.
+ */
+static int r300_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
+{
+       const struct swizzle_data* sd;
+       unsigned int relevant;
+       int j;
+
+       if (opcode == RC_OPCODE_KIL ||
+           opcode == RC_OPCODE_TEX ||
+           opcode == RC_OPCODE_TXB ||
+           opcode == RC_OPCODE_TXP) {
+               if (reg.Abs || reg.Negate)
+                       return 0;
+
+               for(j = 0; j < 4; ++j) {
+                       unsigned int swz = GET_SWZ(reg.Swizzle, j);
+                       if (swz == RC_SWIZZLE_UNUSED)
+                               continue;
+                       if (swz != j)
+                               return 0;
+               }
+
+               return 1;
+       }
+
+       relevant = 0;
+
+       for(j = 0; j < 3; ++j)
+               if (GET_SWZ(reg.Swizzle, j) != RC_SWIZZLE_UNUSED)
+                       relevant |= 1 << j;
+
+       if ((reg.Negate & relevant) && ((reg.Negate & relevant) != relevant))
+               return 0;
+
+       sd = lookup_native_swizzle(reg.Swizzle);
+       if (!sd || (reg.File == RC_FILE_PRESUB && sd->srcp_stride == 0))
+               return 0;
+
+       return 1;
+}
+
+
+static void r300_swizzle_split(
+               struct rc_src_register src, unsigned int mask,
+               struct rc_swizzle_split * split)
+{
+       split->NumPhases = 0;
+
+       while(mask) {
+               unsigned int best_matchcount = 0;
+               unsigned int best_matchmask = 0;
+               int i, comp;
+
+               for(i = 0; i < num_native_swizzles; ++i) {
+                       const struct swizzle_data *sd = &native_swizzles[i];
+                       unsigned int matchcount = 0;
+                       unsigned int matchmask = 0;
+                       for(comp = 0; comp < 3; ++comp) {
+                               unsigned int swz;
+                               if (!GET_BIT(mask, comp))
+                                       continue;
+                               swz = GET_SWZ(src.Swizzle, comp);
+                               if (swz == RC_SWIZZLE_UNUSED)
+                                       continue;
+                               if (swz == GET_SWZ(sd->hash, comp)) {
+                                       /* check if the negate bit of current component
+                                        * is the same for already matched components */
+                                       if (matchmask && (!!(src.Negate & matchmask) != !!(src.Negate & (1 << comp))))
+                                               continue;
+
+                                       matchcount++;
+                                       matchmask |= 1 << comp;
+                               }
+                       }
+                       if (matchcount > best_matchcount) {
+                               best_matchcount = matchcount;
+                               best_matchmask = matchmask;
+                               if (matchmask == (mask & RC_MASK_XYZ))
+                                       break;
+                       }
+               }
+
+               if (mask & RC_MASK_W)
+                       best_matchmask |= RC_MASK_W;
+
+               split->Phase[split->NumPhases++] = best_matchmask;
+               mask &= ~best_matchmask;
+       }
+}
+
+struct rc_swizzle_caps r300_swizzle_caps = {
+       .IsNative = r300_swizzle_is_native,
+       .Split = r300_swizzle_split
+};
+
+
+/**
+ * Translate an RGB (XYZ) swizzle into the hardware code for the given
+ * instruction source.
+ */
+unsigned int r300FPTranslateRGBSwizzle(unsigned int src, unsigned int swizzle)
+{
+       const struct swizzle_data* sd = lookup_native_swizzle(swizzle);
+
+       if (!sd || (src == RC_PAIR_PRESUB_SRC && sd->srcp_stride == 0)) {
+               fprintf(stderr, "Not a native swizzle: %08x\n", swizzle);
+               return 0;
+       }
+
+       if (src == RC_PAIR_PRESUB_SRC) {
+               return sd->base + sd->srcp_stride;
+       } else {
+               return sd->base + src*sd->stride;
+       }
+}
+
+
+/**
+ * Translate an Alpha (W) swizzle into the hardware code for the given
+ * instruction source.
+ */
+unsigned int r300FPTranslateAlphaSwizzle(unsigned int src, unsigned int swizzle)
+{
+       unsigned int swz = GET_SWZ(swizzle, 0);
+       if (src == RC_PAIR_PRESUB_SRC) {
+               return R300_ALU_ARGA_SRCP_X + swz;
+       }
+       if (swz < 3)
+               return swz + 3*src;
+
+       switch(swz) {
+       case RC_SWIZZLE_W: return R300_ALU_ARGA_SRC0A + src;
+       case RC_SWIZZLE_ONE: return R300_ALU_ARGA_ONE;
+       case RC_SWIZZLE_ZERO: return R300_ALU_ARGA_ZERO;
+       case RC_SWIZZLE_HALF: return R300_ALU_ARGA_HALF;
+       default: return R300_ALU_ARGA_ONE;
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.h b/src/gallium/drivers/r300/compiler/r300_fragprog_swizzle.h
new file mode 100644 (file)
index 0000000..f2635be
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __R300_FRAGPROG_SWIZZLE_H_
+#define __R300_FRAGPROG_SWIZZLE_H_
+
+#include "radeon_swizzle.h"
+
+extern struct rc_swizzle_caps r300_swizzle_caps;
+
+unsigned int r300FPTranslateRGBSwizzle(unsigned int src, unsigned int swizzle);
+unsigned int r300FPTranslateAlphaSwizzle(unsigned int src, unsigned int swizzle);
+int r300_swizzle_is_native_basic(unsigned int swizzle);
+
+#endif /* __R300_FRAGPROG_SWIZZLE_H_ */
diff --git a/src/gallium/drivers/r300/compiler/r3xx_fragprog.c b/src/gallium/drivers/r300/compiler/r3xx_fragprog.c
new file mode 100644 (file)
index 0000000..bb6c010
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 "radeon_compiler.h"
+
+#include <stdio.h>
+
+#include "radeon_compiler_util.h"
+#include "radeon_dataflow.h"
+#include "radeon_emulate_branches.h"
+#include "radeon_emulate_loops.h"
+#include "radeon_program_alu.h"
+#include "radeon_program_tex.h"
+#include "radeon_rename_regs.h"
+#include "radeon_remove_constants.h"
+#include "r300_fragprog.h"
+#include "r300_fragprog_swizzle.h"
+#include "r500_fragprog.h"
+
+
+static void dataflow_outputs_mark_use(void * userdata, void * data,
+               void (*callback)(void *, unsigned int, unsigned int))
+{
+       struct r300_fragment_program_compiler * c = userdata;
+       callback(data, c->OutputColor[0], RC_MASK_XYZW);
+       callback(data, c->OutputColor[1], RC_MASK_XYZW);
+       callback(data, c->OutputColor[2], RC_MASK_XYZW);
+       callback(data, c->OutputColor[3], RC_MASK_XYZW);
+       callback(data, c->OutputDepth, RC_MASK_W);
+}
+
+static void rc_rewrite_depth_out(struct radeon_compiler *cc, void *user)
+{
+       struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)cc;
+       struct rc_instruction *rci;
+
+       for (rci = c->Base.Program.Instructions.Next; rci != &c->Base.Program.Instructions; rci = rci->Next) {
+               struct rc_sub_instruction * inst = &rci->U.I;
+               unsigned i;
+               const struct rc_opcode_info *info = rc_get_opcode_info(inst->Opcode);
+
+               if (inst->DstReg.File != RC_FILE_OUTPUT || inst->DstReg.Index != c->OutputDepth)
+                       continue;
+
+               if (inst->DstReg.WriteMask & RC_MASK_Z) {
+                       inst->DstReg.WriteMask = RC_MASK_W;
+               } else {
+                       inst->DstReg.WriteMask = 0;
+                       continue;
+               }
+
+               if (!info->IsComponentwise) {
+                       continue;
+               }
+
+               for (i = 0; i < info->NumSrcRegs; i++) {
+                       inst->SrcReg[i] = lmul_swizzle(RC_SWIZZLE_ZZZZ, inst->SrcReg[i]);
+               }
+       }
+}
+
+static int radeon_saturate_output(
+               struct radeon_compiler * c,
+               struct rc_instruction * inst,
+               void* data)
+{
+       const struct rc_opcode_info *info = rc_get_opcode_info(inst->U.I.Opcode);
+
+       if (!info->HasDstReg || inst->U.I.DstReg.File != RC_FILE_OUTPUT)
+               return 0;
+
+       inst->U.I.SaturateMode = RC_SATURATE_ZERO_ONE;
+       return 1;
+}
+
+void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
+{
+       int is_r500 = c->Base.is_r500;
+       int opt = !c->Base.disable_optimizations;
+       int sat_out = c->state.frag_clamp;
+
+       /* Lists of instruction transformations. */
+       struct radeon_program_transformation saturate_output[] = {
+               { &radeon_saturate_output, c },
+               { 0, 0 }
+       };
+
+       struct radeon_program_transformation rewrite_tex[] = {
+               { &radeonTransformTEX, c },
+               { 0, 0 }
+       };
+
+       struct radeon_program_transformation rewrite_if[] = {
+               { &r500_transform_IF, 0 },
+               {0, 0}
+       };
+
+       struct radeon_program_transformation native_rewrite_r500[] = {
+               { &radeonTransformALU, 0 },
+               { &radeonTransformDeriv, 0 },
+               { &radeonTransformTrigScale, 0 },
+               { 0, 0 }
+       };
+
+       struct radeon_program_transformation native_rewrite_r300[] = {
+               { &radeonTransformALU, 0 },
+               { &r300_transform_trig_simple, 0 },
+               { 0, 0 }
+       };
+
+       /* List of compiler passes. */
+       struct radeon_compiler_pass fs_list[] = {
+               /* NAME                         DUMP PREDICATE  FUNCTION                        PARAM */
+               {"rewrite depth out",           1, 1,           rc_rewrite_depth_out,           NULL},
+               /* This transformation needs to be done before any of the IF
+                * instructions are modified. */
+               {"transform KILP",              1, 1,           rc_transform_KILP,              NULL},
+               {"unroll loops",                1, is_r500,     rc_unroll_loops,                NULL},
+               {"transform loops",             1, !is_r500,    rc_transform_loops,             NULL},
+               {"emulate branches",            1, !is_r500,    rc_emulate_branches,            NULL},
+               {"saturate output writes",      1, sat_out,     rc_local_transform,             saturate_output},
+               {"transform TEX",               1, 1,           rc_local_transform,             rewrite_tex},
+               {"transform IF",                1, is_r500,     rc_local_transform,             rewrite_if},
+               {"native rewrite",              1, is_r500,     rc_local_transform,             native_rewrite_r500},
+               {"native rewrite",              1, !is_r500,    rc_local_transform,             native_rewrite_r300},
+               {"deadcode",                    1, opt,         rc_dataflow_deadcode,           dataflow_outputs_mark_use},
+               {"emulate loops",               1, !is_r500,    rc_emulate_loops,               NULL},
+               {"dataflow optimize",           1, opt,         rc_optimize,                    NULL},
+               {"dataflow swizzles",           1, 1,           rc_dataflow_swizzles,           NULL},
+               {"dead constants",              1, 1,           rc_remove_unused_constants,     &c->code->constants_remap_table},
+               /* This pass makes it easier for the scheduler to group TEX
+                * instructions and reduces the chances of creating too
+                * many texture indirections.*/
+               {"register rename",             1, !is_r500,    rc_rename_regs,                 NULL},
+               {"pair translate",              1, 1,           rc_pair_translate,              NULL},
+               {"pair scheduling",             1, 1,           rc_pair_schedule,               NULL},
+               {"dead sources",                1, 1,           rc_pair_remove_dead_sources, NULL},
+               {"register allocation",         1, 1,           rc_pair_regalloc,               &opt},
+               {"final code validation",       0, 1,           rc_validate_final_shader,       NULL},
+               {"machine code generation",     0, is_r500,     r500BuildFragmentProgramHwCode, NULL},
+               {"machine code generation",     0, !is_r500,    r300BuildFragmentProgramHwCode, NULL},
+               {"dump machine code",           0, is_r500  && (c->Base.Debug & RC_DBG_LOG), r500FragmentProgramDump, NULL},
+               {"dump machine code",           0, !is_r500 && (c->Base.Debug & RC_DBG_LOG), r300FragmentProgramDump, NULL},
+               {NULL, 0, 0, NULL, NULL}
+       };
+
+       c->Base.type = RC_FRAGMENT_PROGRAM;
+       c->Base.SwizzleCaps = c->Base.is_r500 ? &r500_swizzle_caps : &r300_swizzle_caps;
+
+       rc_run_compiler(&c->Base, fs_list);
+
+       rc_constants_copy(&c->code->constants, &c->Base.Program.Constants);
+}
diff --git a/src/gallium/drivers/r300/compiler/r3xx_vertprog.c b/src/gallium/drivers/r300/compiler/r3xx_vertprog.c
new file mode 100644 (file)
index 0000000..654f9a0
--- /dev/null
@@ -0,0 +1,1045 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 "radeon_compiler.h"
+
+#include <stdio.h>
+
+#include "../r300_reg.h"
+
+#include "radeon_compiler_util.h"
+#include "radeon_dataflow.h"
+#include "radeon_program_alu.h"
+#include "radeon_swizzle.h"
+#include "radeon_emulate_branches.h"
+#include "radeon_emulate_loops.h"
+#include "radeon_remove_constants.h"
+
+struct loop {
+       int BgnLoop;
+
+};
+
+/*
+ * Take an already-setup and valid source then swizzle it appropriately to
+ * obtain a constant ZERO or ONE source.
+ */
+#define __CONST(x, y)  \
+       (PVS_SRC_OPERAND(t_src_index(vp, &vpi->SrcReg[x]),      \
+                          t_swizzle(y),        \
+                          t_swizzle(y),        \
+                          t_swizzle(y),        \
+                          t_swizzle(y),        \
+                          t_src_class(vpi->SrcReg[x].File), \
+                          RC_MASK_NONE) | (vpi->SrcReg[x].RelAddr << 4))
+
+
+static unsigned long t_dst_mask(unsigned int mask)
+{
+       /* RC_MASK_* is equivalent to VSF_FLAG_* */
+       return mask & RC_MASK_XYZW;
+}
+
+static unsigned long t_dst_class(rc_register_file file)
+{
+       switch (file) {
+       default:
+               fprintf(stderr, "%s: Bad register file %i\n", __FUNCTION__, file);
+               /* fall-through */
+       case RC_FILE_TEMPORARY:
+               return PVS_DST_REG_TEMPORARY;
+       case RC_FILE_OUTPUT:
+               return PVS_DST_REG_OUT;
+       case RC_FILE_ADDRESS:
+               return PVS_DST_REG_A0;
+       }
+}
+
+static unsigned long t_dst_index(struct r300_vertex_program_code *vp,
+                                struct rc_dst_register *dst)
+{
+       if (dst->File == RC_FILE_OUTPUT)
+               return vp->outputs[dst->Index];
+
+       return dst->Index;
+}
+
+static unsigned long t_src_class(rc_register_file file)
+{
+       switch (file) {
+       default:
+               fprintf(stderr, "%s: Bad register file %i\n", __FUNCTION__, file);
+               /* fall-through */
+       case RC_FILE_NONE:
+       case RC_FILE_TEMPORARY:
+               return PVS_SRC_REG_TEMPORARY;
+       case RC_FILE_INPUT:
+               return PVS_SRC_REG_INPUT;
+       case RC_FILE_CONSTANT:
+               return PVS_SRC_REG_CONSTANT;
+       }
+}
+
+static int t_src_conflict(struct rc_src_register a, struct rc_src_register b)
+{
+       unsigned long aclass = t_src_class(a.File);
+       unsigned long bclass = t_src_class(b.File);
+
+       if (aclass != bclass)
+               return 0;
+       if (aclass == PVS_SRC_REG_TEMPORARY)
+               return 0;
+
+       if (a.RelAddr || b.RelAddr)
+               return 1;
+       if (a.Index != b.Index)
+               return 1;
+
+       return 0;
+}
+
+static inline unsigned long t_swizzle(unsigned int swizzle)
+{
+       /* this is in fact a NOP as the Mesa RC_SWIZZLE_* are all identical to VSF_IN_COMPONENT_* */
+       return swizzle;
+}
+
+static unsigned long t_src_index(struct r300_vertex_program_code *vp,
+                                struct rc_src_register *src)
+{
+       if (src->File == RC_FILE_INPUT) {
+               assert(vp->inputs[src->Index] != -1);
+               return vp->inputs[src->Index];
+       } else {
+               if (src->Index < 0) {
+                       fprintf(stderr,
+                               "negative offsets for indirect addressing do not work.\n");
+                       return 0;
+               }
+               return src->Index;
+       }
+}
+
+/* these two functions should probably be merged... */
+
+static unsigned long t_src(struct r300_vertex_program_code *vp,
+                          struct rc_src_register *src)
+{
+       /* src->Negate uses the RC_MASK_ flags from program_instruction.h,
+        * which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
+        */
+       return PVS_SRC_OPERAND(t_src_index(vp, src),
+                              t_swizzle(GET_SWZ(src->Swizzle, 0)),
+                              t_swizzle(GET_SWZ(src->Swizzle, 1)),
+                              t_swizzle(GET_SWZ(src->Swizzle, 2)),
+                              t_swizzle(GET_SWZ(src->Swizzle, 3)),
+                              t_src_class(src->File),
+                              src->Negate) |
+              (src->RelAddr << 4) | (src->Abs << 3);
+}
+
+static unsigned long t_src_scalar(struct r300_vertex_program_code *vp,
+                                 struct rc_src_register *src)
+{
+       /* src->Negate uses the RC_MASK_ flags from program_instruction.h,
+        * which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
+        */
+       return PVS_SRC_OPERAND(t_src_index(vp, src),
+                              t_swizzle(GET_SWZ(src->Swizzle, 0)),
+                              t_swizzle(GET_SWZ(src->Swizzle, 0)),
+                              t_swizzle(GET_SWZ(src->Swizzle, 0)),
+                              t_swizzle(GET_SWZ(src->Swizzle, 0)),
+                              t_src_class(src->File),
+                              src->Negate ? RC_MASK_XYZW : RC_MASK_NONE) |
+              (src->RelAddr << 4) | (src->Abs << 3);
+}
+
+static int valid_dst(struct r300_vertex_program_code *vp,
+                          struct rc_dst_register *dst)
+{
+       if (dst->File == RC_FILE_OUTPUT && vp->outputs[dst->Index] == -1) {
+               return 0;
+       } else if (dst->File == RC_FILE_ADDRESS) {
+               assert(dst->Index == 0);
+       }
+
+       return 1;
+}
+
+static void ei_vector1(struct r300_vertex_program_code *vp,
+                               unsigned int hw_opcode,
+                               struct rc_sub_instruction *vpi,
+                               unsigned int * inst)
+{
+       inst[0] = PVS_OP_DST_OPERAND(hw_opcode,
+                                    0,
+                                    0,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       inst[1] = t_src(vp, &vpi->SrcReg[0]);
+       inst[2] = __CONST(0, RC_SWIZZLE_ZERO);
+       inst[3] = __CONST(0, RC_SWIZZLE_ZERO);
+}
+
+static void ei_vector2(struct r300_vertex_program_code *vp,
+                               unsigned int hw_opcode,
+                               struct rc_sub_instruction *vpi,
+                               unsigned int * inst)
+{
+       inst[0] = PVS_OP_DST_OPERAND(hw_opcode,
+                                    0,
+                                    0,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       inst[1] = t_src(vp, &vpi->SrcReg[0]);
+       inst[2] = t_src(vp, &vpi->SrcReg[1]);
+       inst[3] = __CONST(1, RC_SWIZZLE_ZERO);
+}
+
+static void ei_math1(struct r300_vertex_program_code *vp,
+                               unsigned int hw_opcode,
+                               struct rc_sub_instruction *vpi,
+                               unsigned int * inst)
+{
+       inst[0] = PVS_OP_DST_OPERAND(hw_opcode,
+                                    1,
+                                    0,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       inst[1] = t_src_scalar(vp, &vpi->SrcReg[0]);
+       inst[2] = __CONST(0, RC_SWIZZLE_ZERO);
+       inst[3] = __CONST(0, RC_SWIZZLE_ZERO);
+}
+
+static void ei_lit(struct r300_vertex_program_code *vp,
+                                     struct rc_sub_instruction *vpi,
+                                     unsigned int * inst)
+{
+       //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
+
+       inst[0] = PVS_OP_DST_OPERAND(ME_LIGHT_COEFF_DX,
+                                    1,
+                                    0,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       /* NOTE: Users swizzling might not work. */
+       inst[1] = PVS_SRC_OPERAND(t_src_index(vp, &vpi->SrcReg[0]), t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 0)),      // X
+                                 t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 3)),        // W
+                                 PVS_SRC_SELECT_FORCE_0,       // Z
+                                 t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 1)),        // Y
+                                 t_src_class(vpi->SrcReg[0].File),
+                                 vpi->SrcReg[0].Negate ? RC_MASK_XYZW : RC_MASK_NONE) |
+           (vpi->SrcReg[0].RelAddr << 4);
+       inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &vpi->SrcReg[0]), t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 1)),      // Y
+                                 t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 3)),        // W
+                                 PVS_SRC_SELECT_FORCE_0,       // Z
+                                 t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 0)),        // X
+                                 t_src_class(vpi->SrcReg[0].File),
+                                 vpi->SrcReg[0].Negate ? RC_MASK_XYZW : RC_MASK_NONE) |
+           (vpi->SrcReg[0].RelAddr << 4);
+       inst[3] = PVS_SRC_OPERAND(t_src_index(vp, &vpi->SrcReg[0]), t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 1)),      // Y
+                                 t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 0)),        // X
+                                 PVS_SRC_SELECT_FORCE_0,       // Z
+                                 t_swizzle(GET_SWZ(vpi->SrcReg[0].Swizzle, 3)),        // W
+                                 t_src_class(vpi->SrcReg[0].File),
+                                 vpi->SrcReg[0].Negate ? RC_MASK_XYZW : RC_MASK_NONE) |
+           (vpi->SrcReg[0].RelAddr << 4);
+}
+
+static void ei_mad(struct r300_vertex_program_code *vp,
+                                     struct rc_sub_instruction *vpi,
+                                     unsigned int * inst)
+{
+       unsigned int i;
+       /* Remarks about hardware limitations of MAD
+        * (please preserve this comment, as this information is _NOT_
+        * in the documentation provided by AMD).
+        *
+        * As described in the documentation, MAD with three unique temporary
+        * source registers requires the use of the macro version.
+        *
+        * However (and this is not mentioned in the documentation), apparently
+        * the macro version is _NOT_ a full superset of the normal version.
+        * In particular, the macro version does not always work when relative
+        * addressing is used in the source operands.
+        *
+        * This limitation caused incorrect rendering in Sauerbraten's OpenGL
+        * assembly shader path when using medium quality animations
+        * (i.e. animations with matrix blending instead of quaternion blending).
+        *
+        * Unfortunately, I (nha) have been unable to extract a Piglit regression
+        * test for this issue - for some reason, it is possible to have vertex
+        * programs whose prefix is *exactly* the same as the prefix of the
+        * offending program in Sauerbraten up to the offending instruction
+        * without causing any trouble.
+        *
+        * Bottom line: Only use the macro version only when really necessary;
+        * according to AMD docs, this should improve performance by one clock
+        * as a nice side bonus.
+        */
+       if (vpi->SrcReg[0].File == RC_FILE_TEMPORARY &&
+           vpi->SrcReg[1].File == RC_FILE_TEMPORARY &&
+           vpi->SrcReg[2].File == RC_FILE_TEMPORARY &&
+           vpi->SrcReg[0].Index != vpi->SrcReg[1].Index &&
+           vpi->SrcReg[0].Index != vpi->SrcReg[2].Index &&
+           vpi->SrcReg[1].Index != vpi->SrcReg[2].Index) {
+               inst[0] = PVS_OP_DST_OPERAND(PVS_MACRO_OP_2CLK_MADD,
+                               0,
+                               1,
+                               t_dst_index(vp, &vpi->DstReg),
+                               t_dst_mask(vpi->DstReg.WriteMask),
+                               t_dst_class(vpi->DstReg.File));
+       } else {
+               inst[0] = PVS_OP_DST_OPERAND(VE_MULTIPLY_ADD,
+                               0,
+                               0,
+                               t_dst_index(vp, &vpi->DstReg),
+                               t_dst_mask(vpi->DstReg.WriteMask),
+                               t_dst_class(vpi->DstReg.File));
+
+               /* Arguments with constant swizzles still count as a unique
+                * temporary, so we should make sure these arguments share a
+                * register index with one of the other arguments. */
+               for (i = 0; i < 3; i++) {
+                       unsigned int j;
+                       if (vpi->SrcReg[i].File != RC_FILE_NONE)
+                               continue;
+
+                       for (j = 0; j < 3; j++) {
+                               if (i != j) {
+                                       vpi->SrcReg[i].Index =
+                                               vpi->SrcReg[j].Index;
+                                       break;
+                               }
+                       }
+               }
+       }
+       inst[1] = t_src(vp, &vpi->SrcReg[0]);
+       inst[2] = t_src(vp, &vpi->SrcReg[1]);
+       inst[3] = t_src(vp, &vpi->SrcReg[2]);
+}
+
+static void ei_pow(struct r300_vertex_program_code *vp,
+                                     struct rc_sub_instruction *vpi,
+                                     unsigned int * inst)
+{
+       inst[0] = PVS_OP_DST_OPERAND(ME_POWER_FUNC_FF,
+                                    1,
+                                    0,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       inst[1] = t_src_scalar(vp, &vpi->SrcReg[0]);
+       inst[2] = __CONST(0, RC_SWIZZLE_ZERO);
+       inst[3] = t_src_scalar(vp, &vpi->SrcReg[1]);
+}
+
+static void mark_write(void * userdata,        struct rc_instruction * inst,
+               rc_register_file file,  unsigned int index, unsigned int mask)
+{
+       unsigned int * writemasks = userdata;
+
+       if (file != RC_FILE_TEMPORARY)
+               return;
+
+       if (index >= R300_VS_MAX_TEMPS)
+               return;
+
+       writemasks[index] |= mask;
+}
+
+static unsigned long t_pred_src(struct r300_vertex_program_compiler * compiler)
+{
+       return PVS_SRC_OPERAND(compiler->PredicateIndex,
+               t_swizzle(RC_SWIZZLE_ZERO),
+               t_swizzle(RC_SWIZZLE_ZERO),
+               t_swizzle(RC_SWIZZLE_ZERO),
+               t_swizzle(RC_SWIZZLE_W),
+               t_src_class(RC_FILE_TEMPORARY),
+               0);
+}
+
+static unsigned long t_pred_dst(struct r300_vertex_program_compiler * compiler,
+                                       unsigned int hw_opcode, int is_math)
+{
+       return PVS_OP_DST_OPERAND(hw_opcode,
+            is_math,
+            0,
+            compiler->PredicateIndex,
+            RC_MASK_W,
+            t_dst_class(RC_FILE_TEMPORARY));
+
+}
+
+static void ei_if(struct r300_vertex_program_compiler * compiler,
+                                       struct rc_instruction *rci,
+                                       unsigned int * inst,
+                                       unsigned int branch_depth)
+{
+       unsigned int predicate_opcode;
+       int is_math = 0;
+
+       if (!compiler->Base.is_r500) {
+               rc_error(&compiler->Base,"Opcode IF not supported\n");
+               return;
+       }
+
+       /* Reserve a temporary to use as our predicate stack counter, if we
+        * don't already have one. */
+       if (!compiler->PredicateMask) {
+               unsigned int writemasks[RC_REGISTER_MAX_INDEX];
+               struct rc_instruction * inst;
+               unsigned int i;
+               memset(writemasks, 0, sizeof(writemasks));
+               for(inst = compiler->Base.Program.Instructions.Next;
+                               inst != &compiler->Base.Program.Instructions;
+                                                       inst = inst->Next) {
+                       rc_for_all_writes_mask(inst, mark_write, writemasks);
+               }
+               for(i = 0; i < compiler->Base.max_temp_regs; i++) {
+                       unsigned int mask = ~writemasks[i] & RC_MASK_XYZW;
+                       /* Only the W component can be used fo the predicate
+                        * stack counter. */
+                       if (mask & RC_MASK_W) {
+                               compiler->PredicateMask = RC_MASK_W;
+                               compiler->PredicateIndex = i;
+                               break;
+                       }
+               }
+               if (i == compiler->Base.max_temp_regs) {
+                       rc_error(&compiler->Base, "No free temporary to use for"
+                                       " predicate stack counter.\n");
+                       return;
+               }
+       }
+       predicate_opcode =
+                       branch_depth ? VE_PRED_SET_NEQ_PUSH : ME_PRED_SET_NEQ;
+
+       rci->U.I.SrcReg[0].Swizzle = RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(rci->U.I.SrcReg[0].Swizzle,0));
+       if (branch_depth == 0) {
+               is_math = 1;
+               predicate_opcode = ME_PRED_SET_NEQ;
+               inst[1] = t_src(compiler->code, &rci->U.I.SrcReg[0]);
+               inst[2] = 0;
+       } else {
+               predicate_opcode = VE_PRED_SET_NEQ_PUSH;
+               inst[1] = t_pred_src(compiler);
+               inst[2] = t_src(compiler->code, &rci->U.I.SrcReg[0]);
+       }
+
+       inst[0] = t_pred_dst(compiler, predicate_opcode, is_math);
+       inst[3] = 0;
+
+}
+
+static void ei_else(struct r300_vertex_program_compiler * compiler,
+                                                       unsigned int * inst)
+{
+       if (!compiler->Base.is_r500) {
+               rc_error(&compiler->Base,"Opcode ELSE not supported\n");
+               return;
+       }
+       inst[0] = t_pred_dst(compiler, ME_PRED_SET_INV, 1);
+       inst[1] = t_pred_src(compiler);
+       inst[2] = 0;
+       inst[3] = 0;
+}
+
+static void ei_endif(struct r300_vertex_program_compiler *compiler,
+                                                       unsigned int * inst)
+{
+       if (!compiler->Base.is_r500) {
+               rc_error(&compiler->Base,"Opcode ENDIF not supported\n");
+               return;
+       }
+       inst[0] = t_pred_dst(compiler, ME_PRED_SET_POP, 1);
+       inst[1] = t_pred_src(compiler);
+       inst[2] = 0;
+       inst[3] = 0;
+}
+
+static void translate_vertex_program(struct radeon_compiler *c, void *user)
+{
+       struct r300_vertex_program_compiler *compiler = (struct r300_vertex_program_compiler*)c;
+       struct rc_instruction *rci;
+
+       struct loop * loops = NULL;
+       int current_loop_depth = 0;
+       int loops_reserved = 0;
+
+       unsigned int branch_depth = 0;
+
+       compiler->code->pos_end = 0;    /* Not supported yet */
+       compiler->code->length = 0;
+       compiler->code->num_temporaries = 0;
+
+       compiler->SetHwInputOutput(compiler);
+
+       for(rci = compiler->Base.Program.Instructions.Next; rci != &compiler->Base.Program.Instructions; rci = rci->Next) {
+               struct rc_sub_instruction *vpi = &rci->U.I;
+               unsigned int *inst = compiler->code->body.d + compiler->code->length;
+               const struct rc_opcode_info *info = rc_get_opcode_info(vpi->Opcode);
+
+               /* Skip instructions writing to non-existing destination */
+               if (!valid_dst(compiler->code, &vpi->DstReg))
+                       continue;
+
+               if (info->HasDstReg) {
+                       /* Neither is Saturate. */
+                       if (vpi->SaturateMode != RC_SATURATE_NONE) {
+                               rc_error(&compiler->Base, "Vertex program does not support the Saturate "
+                                        "modifier (yet).\n");
+                       }
+               }
+
+               if (compiler->code->length >= c->max_alu_insts * 4) {
+                       rc_error(&compiler->Base, "Vertex program has too many instructions\n");
+                       return;
+               }
+
+               assert(compiler->Base.is_r500 ||
+                      (vpi->Opcode != RC_OPCODE_SEQ &&
+                       vpi->Opcode != RC_OPCODE_SNE));
+
+               switch (vpi->Opcode) {
+               case RC_OPCODE_ADD: ei_vector2(compiler->code, VE_ADD, vpi, inst); break;
+               case RC_OPCODE_ARL: ei_vector1(compiler->code, VE_FLT2FIX_DX, vpi, inst); break;
+               case RC_OPCODE_COS: ei_math1(compiler->code, ME_COS, vpi, inst); break;
+               case RC_OPCODE_DP4: ei_vector2(compiler->code, VE_DOT_PRODUCT, vpi, inst); break;
+               case RC_OPCODE_DST: ei_vector2(compiler->code, VE_DISTANCE_VECTOR, vpi, inst); break;
+               case RC_OPCODE_ELSE: ei_else(compiler, inst); break;
+               case RC_OPCODE_ENDIF: ei_endif(compiler, inst); branch_depth--; break;
+               case RC_OPCODE_EX2: ei_math1(compiler->code, ME_EXP_BASE2_FULL_DX, vpi, inst); break;
+               case RC_OPCODE_EXP: ei_math1(compiler->code, ME_EXP_BASE2_DX, vpi, inst); break;
+               case RC_OPCODE_FRC: ei_vector1(compiler->code, VE_FRACTION, vpi, inst); break;
+               case RC_OPCODE_IF: ei_if(compiler, rci, inst, branch_depth); branch_depth++; break;
+               case RC_OPCODE_LG2: ei_math1(compiler->code, ME_LOG_BASE2_FULL_DX, vpi, inst); break;
+               case RC_OPCODE_LIT: ei_lit(compiler->code, vpi, inst); break;
+               case RC_OPCODE_LOG: ei_math1(compiler->code, ME_LOG_BASE2_DX, vpi, inst); break;
+               case RC_OPCODE_MAD: ei_mad(compiler->code, vpi, inst); break;
+               case RC_OPCODE_MAX: ei_vector2(compiler->code, VE_MAXIMUM, vpi, inst); break;
+               case RC_OPCODE_MIN: ei_vector2(compiler->code, VE_MINIMUM, vpi, inst); break;
+               case RC_OPCODE_MOV: ei_vector1(compiler->code, VE_ADD, vpi, inst); break;
+               case RC_OPCODE_MUL: ei_vector2(compiler->code, VE_MULTIPLY, vpi, inst); break;
+               case RC_OPCODE_POW: ei_pow(compiler->code, vpi, inst); break;
+               case RC_OPCODE_RCP: ei_math1(compiler->code, ME_RECIP_DX, vpi, inst); break;
+               case RC_OPCODE_RSQ: ei_math1(compiler->code, ME_RECIP_SQRT_DX, vpi, inst); break;
+               case RC_OPCODE_SEQ: ei_vector2(compiler->code, VE_SET_EQUAL, vpi, inst); break;
+               case RC_OPCODE_SGE: ei_vector2(compiler->code, VE_SET_GREATER_THAN_EQUAL, vpi, inst); break;
+               case RC_OPCODE_SIN: ei_math1(compiler->code, ME_SIN, vpi, inst); break;
+               case RC_OPCODE_SLT: ei_vector2(compiler->code, VE_SET_LESS_THAN, vpi, inst); break;
+               case RC_OPCODE_SNE: ei_vector2(compiler->code, VE_SET_NOT_EQUAL, vpi, inst); break;
+               case RC_OPCODE_BGNLOOP:
+               {
+                       struct loop * l;
+
+                       if ((!compiler->Base.is_r500
+                               && loops_reserved >= R300_VS_MAX_LOOP_DEPTH)
+                               || loops_reserved >= R500_VS_MAX_FC_DEPTH) {
+                               rc_error(&compiler->Base,
+                                               "Loops are nested too deep.");
+                               return;
+                       }
+                       memory_pool_array_reserve(&compiler->Base.Pool,
+                                       struct loop, loops, current_loop_depth,
+                                       loops_reserved, 1);
+                       l = &loops[current_loop_depth++];
+                       memset(l , 0, sizeof(struct loop));
+                       l->BgnLoop = (compiler->code->length / 4);
+                       continue;
+               }
+               case RC_OPCODE_ENDLOOP:
+               {
+                       struct loop * l;
+                       unsigned int act_addr;
+                       unsigned int last_addr;
+                       unsigned int ret_addr;
+
+                       assert(loops);
+                       l = &loops[current_loop_depth - 1];
+                       act_addr = l->BgnLoop - 1;
+                       last_addr = (compiler->code->length / 4) - 1;
+                       ret_addr = l->BgnLoop;
+
+                       if (loops_reserved >= R300_VS_MAX_FC_OPS) {
+                               rc_error(&compiler->Base,
+                                       "Too many flow control instructions.");
+                               return;
+                       }
+                       if (compiler->Base.is_r500) {
+                               compiler->code->fc_op_addrs.r500
+                                       [compiler->code->num_fc_ops].lw =
+                                       R500_PVS_FC_ACT_ADRS(act_addr)
+                                       | R500_PVS_FC_LOOP_CNT_JMP_INST(0xffff)
+                                       ;
+                               compiler->code->fc_op_addrs.r500
+                                       [compiler->code->num_fc_ops].uw =
+                                       R500_PVS_FC_LAST_INST(last_addr)
+                                       | R500_PVS_FC_RTN_INST(ret_addr)
+                                       ;
+                       } else {
+                               compiler->code->fc_op_addrs.r300
+                                       [compiler->code->num_fc_ops] =
+                                       R300_PVS_FC_ACT_ADRS(act_addr)
+                                       | R300_PVS_FC_LOOP_CNT_JMP_INST(0xff)
+                                       | R300_PVS_FC_LAST_INST(last_addr)
+                                       | R300_PVS_FC_RTN_INST(ret_addr)
+                                       ;
+                       }
+                       compiler->code->fc_loop_index[compiler->code->num_fc_ops] =
+                               R300_PVS_FC_LOOP_INIT_VAL(0x0)
+                               | R300_PVS_FC_LOOP_STEP_VAL(0x1)
+                               ;
+                       compiler->code->fc_ops |= R300_VAP_PVS_FC_OPC_LOOP(
+                                               compiler->code->num_fc_ops);
+                       compiler->code->num_fc_ops++;
+                       current_loop_depth--;
+                       continue;
+               }
+
+               default:
+                       rc_error(&compiler->Base, "Unknown opcode %s\n", info->Name);
+                       return;
+               }
+
+               /* Non-flow control instructions that are inside an if statement
+                * need to pay attention to the predicate bit. */
+               if (branch_depth
+                       && vpi->Opcode != RC_OPCODE_IF
+                       && vpi->Opcode != RC_OPCODE_ELSE
+                       && vpi->Opcode != RC_OPCODE_ENDIF) {
+
+                       inst[0] |= (PVS_DST_PRED_ENABLE_MASK
+                                               << PVS_DST_PRED_ENABLE_SHIFT);
+                       inst[0] |= (PVS_DST_PRED_SENSE_MASK
+                                               << PVS_DST_PRED_SENSE_SHIFT);
+               }
+
+               /* Update the number of temporaries. */
+               if (info->HasDstReg && vpi->DstReg.File == RC_FILE_TEMPORARY &&
+                   vpi->DstReg.Index >= compiler->code->num_temporaries)
+                       compiler->code->num_temporaries = vpi->DstReg.Index + 1;
+
+               for (unsigned i = 0; i < info->NumSrcRegs; i++)
+                       if (vpi->SrcReg[i].File == RC_FILE_TEMPORARY &&
+                           vpi->SrcReg[i].Index >= compiler->code->num_temporaries)
+                               compiler->code->num_temporaries = vpi->SrcReg[i].Index + 1;
+
+               if (compiler->PredicateMask)
+                       if (compiler->PredicateIndex >= compiler->code->num_temporaries)
+                               compiler->code->num_temporaries = compiler->PredicateIndex + 1;
+
+               if (compiler->code->num_temporaries > compiler->Base.max_temp_regs) {
+                       rc_error(&compiler->Base, "Too many temporaries.\n");
+                       return;
+               }
+
+               compiler->code->length += 4;
+
+               if (compiler->Base.Error)
+                       return;
+       }
+}
+
+struct temporary_allocation {
+       unsigned int Allocated:1;
+       unsigned int HwTemp:15;
+       struct rc_instruction * LastRead;
+};
+
+static void allocate_temporary_registers(struct radeon_compiler *c, void *user)
+{
+       struct r300_vertex_program_compiler *compiler = (struct r300_vertex_program_compiler*)c;
+       struct rc_instruction *inst;
+       struct rc_instruction *end_loop = NULL;
+       unsigned int num_orig_temps = 0;
+       char hwtemps[RC_REGISTER_MAX_INDEX];
+       struct temporary_allocation * ta;
+       unsigned int i, j;
+
+       memset(hwtemps, 0, sizeof(hwtemps));
+
+       rc_recompute_ips(c);
+
+       /* Pass 1: Count original temporaries. */
+       for(inst = compiler->Base.Program.Instructions.Next; inst != &compiler->Base.Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+               for (i = 0; i < opcode->NumSrcRegs; ++i) {
+                       if (inst->U.I.SrcReg[i].File == RC_FILE_TEMPORARY) {
+                               if (inst->U.I.SrcReg[i].Index >= num_orig_temps)
+                                       num_orig_temps = inst->U.I.SrcReg[i].Index + 1;
+                       }
+               }
+
+               if (opcode->HasDstReg) {
+                       if (inst->U.I.DstReg.File == RC_FILE_TEMPORARY) {
+                               if (inst->U.I.DstReg.Index >= num_orig_temps)
+                                       num_orig_temps = inst->U.I.DstReg.Index + 1;
+                       }
+               }
+       }
+
+       ta = (struct temporary_allocation*)memory_pool_malloc(&compiler->Base.Pool,
+                       sizeof(struct temporary_allocation) * num_orig_temps);
+       memset(ta, 0, sizeof(struct temporary_allocation) * num_orig_temps);
+
+       /* Pass 2: Determine original temporary lifetimes */
+       for(inst = compiler->Base.Program.Instructions.Next; inst != &compiler->Base.Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+               /* Instructions inside of loops need to use the ENDLOOP
+                * instruction as their LastRead. */
+               if (!end_loop && inst->U.I.Opcode == RC_OPCODE_BGNLOOP) {
+                       int endloops = 1;
+                       struct rc_instruction * ptr;
+                       for(ptr = inst->Next;
+                               ptr != &compiler->Base.Program.Instructions;
+                                                       ptr = ptr->Next){
+                               if (ptr->U.I.Opcode == RC_OPCODE_BGNLOOP) {
+                                       endloops++;
+                               } else if (ptr->U.I.Opcode == RC_OPCODE_ENDLOOP) {
+                                       endloops--;
+                                       if (endloops <= 0) {
+                                               end_loop = ptr;
+                                               break;
+                                       }
+                               }
+                       }
+               }
+
+               if (inst == end_loop) {
+                       end_loop = NULL;
+                       continue;
+               }
+
+               for (i = 0; i < opcode->NumSrcRegs; ++i) {
+                       if (inst->U.I.SrcReg[i].File == RC_FILE_TEMPORARY) {
+                               ta[inst->U.I.SrcReg[i].Index].LastRead = end_loop ? end_loop : inst;
+                       }
+               }
+       }
+
+       /* Pass 3: Register allocation */
+       for(inst = compiler->Base.Program.Instructions.Next; inst != &compiler->Base.Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+               for (i = 0; i < opcode->NumSrcRegs; ++i) {
+                       if (inst->U.I.SrcReg[i].File == RC_FILE_TEMPORARY) {
+                               unsigned int orig = inst->U.I.SrcReg[i].Index;
+                               inst->U.I.SrcReg[i].Index = ta[orig].HwTemp;
+
+                               if (ta[orig].Allocated && inst == ta[orig].LastRead)
+                                       hwtemps[ta[orig].HwTemp] = 0;
+                       }
+               }
+
+               if (opcode->HasDstReg) {
+                       if (inst->U.I.DstReg.File == RC_FILE_TEMPORARY) {
+                               unsigned int orig = inst->U.I.DstReg.Index;
+
+                               if (!ta[orig].Allocated) {
+                                       for(j = 0; j < c->max_temp_regs; ++j) {
+                                               if (!hwtemps[j])
+                                                       break;
+                                       }
+                                       ta[orig].Allocated = 1;
+                                       ta[orig].HwTemp = j;
+                                       hwtemps[ta[orig].HwTemp] = 1;
+                               }
+
+                               inst->U.I.DstReg.Index = ta[orig].HwTemp;
+                       }
+               }
+       }
+}
+
+/**
+ * R3xx-R4xx vertex engine does not support the Absolute source operand modifier
+ * and the Saturate opcode modifier. Only Absolute is currently transformed.
+ */
+static int transform_nonnative_modifiers(
+       struct radeon_compiler *c,
+       struct rc_instruction *inst,
+       void* unused)
+{
+       const struct rc_opcode_info *opcode = rc_get_opcode_info(inst->U.I.Opcode);
+       unsigned i;
+
+       /* Transform ABS(a) to MAX(a, -a). */
+       for (i = 0; i < opcode->NumSrcRegs; i++) {
+               if (inst->U.I.SrcReg[i].Abs) {
+                       struct rc_instruction *new_inst;
+                       unsigned temp;
+
+                       inst->U.I.SrcReg[i].Abs = 0;
+
+                       temp = rc_find_free_temporary(c);
+
+                       new_inst = rc_insert_new_instruction(c, inst->Prev);
+                       new_inst->U.I.Opcode = RC_OPCODE_MAX;
+                       new_inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       new_inst->U.I.DstReg.Index = temp;
+                       new_inst->U.I.SrcReg[0] = inst->U.I.SrcReg[i];
+                       new_inst->U.I.SrcReg[1] = inst->U.I.SrcReg[i];
+                       new_inst->U.I.SrcReg[1].Negate ^= RC_MASK_XYZW;
+
+                       memset(&inst->U.I.SrcReg[i], 0, sizeof(inst->U.I.SrcReg[i]));
+                       inst->U.I.SrcReg[i].File = RC_FILE_TEMPORARY;
+                       inst->U.I.SrcReg[i].Index = temp;
+                       inst->U.I.SrcReg[i].Swizzle = RC_SWIZZLE_XYZW;
+               }
+       }
+       return 1;
+}
+
+/**
+ * Vertex engine cannot read two inputs or two constants at the same time.
+ * Introduce intermediate MOVs to temporary registers to account for this.
+ */
+static int transform_source_conflicts(
+       struct radeon_compiler *c,
+       struct rc_instruction* inst,
+       void* unused)
+{
+       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+       if (opcode->NumSrcRegs == 3) {
+               if (t_src_conflict(inst->U.I.SrcReg[1], inst->U.I.SrcReg[2])
+                   || t_src_conflict(inst->U.I.SrcReg[0], inst->U.I.SrcReg[2])) {
+                       int tmpreg = rc_find_free_temporary(c);
+                       struct rc_instruction * inst_mov = rc_insert_new_instruction(c, inst->Prev);
+                       inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+                       inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_mov->U.I.DstReg.Index = tmpreg;
+                       inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[2];
+
+                       reset_srcreg(&inst->U.I.SrcReg[2]);
+                       inst->U.I.SrcReg[2].File = RC_FILE_TEMPORARY;
+                       inst->U.I.SrcReg[2].Index = tmpreg;
+               }
+       }
+
+       if (opcode->NumSrcRegs >= 2) {
+               if (t_src_conflict(inst->U.I.SrcReg[1], inst->U.I.SrcReg[0])) {
+                       int tmpreg = rc_find_free_temporary(c);
+                       struct rc_instruction * inst_mov = rc_insert_new_instruction(c, inst->Prev);
+                       inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+                       inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_mov->U.I.DstReg.Index = tmpreg;
+                       inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[1];
+
+                       reset_srcreg(&inst->U.I.SrcReg[1]);
+                       inst->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+                       inst->U.I.SrcReg[1].Index = tmpreg;
+               }
+       }
+
+       return 1;
+}
+
+static void rc_vs_add_artificial_outputs(struct radeon_compiler *c, void *user)
+{
+       struct r300_vertex_program_compiler * compiler = (struct r300_vertex_program_compiler*)c;
+       int i;
+
+       for(i = 0; i < 32; ++i) {
+               if ((compiler->RequiredOutputs & (1 << i)) &&
+                   !(compiler->Base.Program.OutputsWritten & (1 << i))) {
+                       struct rc_instruction * 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 = i;
+                       inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+
+                       inst->U.I.SrcReg[0].File = RC_FILE_CONSTANT;
+                       inst->U.I.SrcReg[0].Index = 0;
+                       inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZW;
+
+                       compiler->Base.Program.OutputsWritten |= 1 << i;
+               }
+       }
+}
+
+static void dataflow_outputs_mark_used(void * userdata, void * data,
+               void (*callback)(void *, unsigned int, unsigned int))
+{
+       struct r300_vertex_program_compiler * c = userdata;
+       int i;
+
+       for(i = 0; i < 32; ++i) {
+               if (c->RequiredOutputs & (1 << i))
+                       callback(data, i, RC_MASK_XYZW);
+       }
+}
+
+static int swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
+{
+       (void) opcode;
+       (void) reg;
+
+       return 1;
+}
+
+static void transform_negative_addressing(struct r300_vertex_program_compiler *c,
+                                         struct rc_instruction *arl,
+                                         struct rc_instruction *end,
+                                         int min_offset)
+{
+       struct rc_instruction *inst, *add;
+       unsigned const_swizzle;
+
+       /* Transform ARL */
+       add = rc_insert_new_instruction(&c->Base, arl->Prev);
+       add->U.I.Opcode = RC_OPCODE_ADD;
+       add->U.I.DstReg.File = RC_FILE_TEMPORARY;
+       add->U.I.DstReg.Index = rc_find_free_temporary(&c->Base);
+       add->U.I.DstReg.WriteMask = RC_MASK_X;
+       add->U.I.SrcReg[0] = arl->U.I.SrcReg[0];
+       add->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
+       add->U.I.SrcReg[1].Index = rc_constants_add_immediate_scalar(&c->Base.Program.Constants,
+                                                                    min_offset, &const_swizzle);
+       add->U.I.SrcReg[1].Swizzle = const_swizzle;
+
+       arl->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+       arl->U.I.SrcReg[0].Index = add->U.I.DstReg.Index;
+       arl->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XXXX;
+
+       /* Rewrite offsets up to and excluding inst. */
+       for (inst = arl->Next; inst != end; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+               for (unsigned i = 0; i < opcode->NumSrcRegs; i++)
+                       if (inst->U.I.SrcReg[i].RelAddr)
+                               inst->U.I.SrcReg[i].Index -= min_offset;
+       }
+}
+
+static void rc_emulate_negative_addressing(struct radeon_compiler *compiler, void *user)
+{
+       struct r300_vertex_program_compiler * c = (struct r300_vertex_program_compiler*)compiler;
+       struct rc_instruction *inst, *lastARL = NULL;
+       int min_offset = 0;
+
+       for (inst = c->Base.Program.Instructions.Next; inst != &c->Base.Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+               if (inst->U.I.Opcode == RC_OPCODE_ARL) {
+                       if (lastARL != NULL && min_offset < 0)
+                               transform_negative_addressing(c, lastARL, inst, min_offset);
+
+                       lastARL = inst;
+                       min_offset = 0;
+                       continue;
+               }
+
+               for (unsigned i = 0; i < opcode->NumSrcRegs; i++) {
+                       if (inst->U.I.SrcReg[i].RelAddr &&
+                           inst->U.I.SrcReg[i].Index < 0) {
+                               /* ARL must precede any indirect addressing. */
+                               if (lastARL == NULL) {
+                                       rc_error(&c->Base, "Vertex shader: Found relative addressing without ARL.");
+                                       return;
+                               }
+
+                               if (inst->U.I.SrcReg[i].Index < min_offset)
+                                       min_offset = inst->U.I.SrcReg[i].Index;
+                       }
+               }
+       }
+
+       if (lastARL != NULL && min_offset < 0)
+               transform_negative_addressing(c, lastARL, inst, min_offset);
+}
+
+static struct rc_swizzle_caps r300_vertprog_swizzle_caps = {
+       .IsNative = &swizzle_is_native,
+       .Split = 0 /* should never be called */
+};
+
+void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
+{
+       int is_r500 = c->Base.is_r500;
+       int opt = !c->Base.disable_optimizations;
+
+       /* Lists of instruction transformations. */
+       struct radeon_program_transformation alu_rewrite_r500[] = {
+               { &r300_transform_vertex_alu, 0 },
+               { &r300_transform_trig_scale_vertex, 0 },
+               { 0, 0 }
+       };
+
+       struct radeon_program_transformation alu_rewrite_r300[] = {
+               { &r300_transform_vertex_alu, 0 },
+               { &r300_transform_trig_simple, 0 },
+               { 0, 0 }
+       };
+
+       /* Note: These passes have to be done seperately from ALU rewrite,
+        * otherwise non-native ALU instructions with source conflits
+        * or non-native modifiers will not be treated properly.
+        */
+       struct radeon_program_transformation emulate_modifiers[] = {
+               { &transform_nonnative_modifiers, 0 },
+               { 0, 0 }
+       };
+
+       struct radeon_program_transformation resolve_src_conflicts[] = {
+               { &transform_source_conflicts, 0 },
+               { 0, 0 }
+       };
+
+       /* List of compiler passes. */
+       struct radeon_compiler_pass vs_list[] = {
+               /* NAME                         DUMP PREDICATE  FUNCTION                        PARAM */
+               {"add artificial outputs",      0, 1,           rc_vs_add_artificial_outputs,   NULL},
+               {"transform loops",             1, 1,           rc_transform_loops,             NULL},
+               {"emulate branches",            1, !is_r500,    rc_emulate_branches,            NULL},
+               {"emulate negative addressing", 1, 1,           rc_emulate_negative_addressing, NULL},
+               {"native rewrite",              1, is_r500,     rc_local_transform,             alu_rewrite_r500},
+               {"native rewrite",              1, !is_r500,    rc_local_transform,             alu_rewrite_r300},
+               {"emulate modifiers",           1, !is_r500,    rc_local_transform,             emulate_modifiers},
+               {"deadcode",                    1, opt,         rc_dataflow_deadcode,           dataflow_outputs_mark_used},
+               {"dataflow optimize",           1, opt,         rc_optimize,                    NULL},
+               /* This pass must be done after optimizations. */
+               {"source conflict resolve",     1, 1,           rc_local_transform,             resolve_src_conflicts},
+               {"register allocation",         1, opt,         allocate_temporary_registers,   NULL},
+               {"dead constants",              1, 1,           rc_remove_unused_constants,     &c->code->constants_remap_table},
+               {"final code validation",       0, 1,           rc_validate_final_shader,       NULL},
+               {"machine code generation",     0, 1,           translate_vertex_program,       NULL},
+               {"dump machine code",           0, c->Base.Debug & RC_DBG_LOG, r300_vertex_program_dump,        NULL},
+               {NULL, 0, 0, NULL, NULL}
+       };
+
+       c->Base.type = RC_VERTEX_PROGRAM;
+       c->Base.SwizzleCaps = &r300_vertprog_swizzle_caps;
+
+       rc_run_compiler(&c->Base, vs_list);
+
+       c->code->InputsRead = c->Base.Program.InputsRead;
+       c->code->OutputsWritten = c->Base.Program.OutputsWritten;
+       rc_constants_copy(&c->code->constants, &c->Base.Program.Constants);
+}
diff --git a/src/gallium/drivers/r300/compiler/r3xx_vertprog_dump.c b/src/gallium/drivers/r300/compiler/r3xx_vertprog_dump.c
new file mode 100644 (file)
index 0000000..2bc0a87
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 "radeon_compiler.h"
+#include "radeon_code.h"
+#include "../r300_reg.h"
+
+#include <stdio.h>
+
+static char* r300_vs_ve_ops[] = {
+       /* R300 vector ops */
+       "                 VE_NO_OP",
+       "           VE_DOT_PRODUCT",
+       "              VE_MULTIPLY",
+       "                   VE_ADD",
+       "          VE_MULTIPLY_ADD",
+       "       VE_DISTANCE_FACTOR",
+       "              VE_FRACTION",
+       "               VE_MAXIMUM",
+       "               VE_MINIMUM",
+       "VE_SET_GREATER_THAN_EQUAL",
+       "         VE_SET_LESS_THAN",
+       "        VE_MULTIPLYX2_ADD",
+       "        VE_MULTIPLY_CLAMP",
+       "            VE_FLT2FIX_DX",
+       "        VE_FLT2FIX_DX_RND",
+       /* R500 vector ops */
+       "      VE_PRED_SET_EQ_PUSH",
+       "      VE_PRED_SET_GT_PUSH",
+       "     VE_PRED_SET_GTE_PUSH",
+       "     VE_PRED_SET_NEQ_PUSH",
+       "         VE_COND_WRITE_EQ",
+       "         VE_COND_WRITE_GT",
+       "        VE_COND_WRITE_GTE",
+       "        VE_COND_WRITE_NEQ",
+       "           VE_COND_MUX_EQ",
+       "           VE_COND_MUX_GT",
+       "          VE_COND_MUX_GTE",
+       "      VE_SET_GREATER_THAN",
+       "             VE_SET_EQUAL",
+       "         VE_SET_NOT_EQUAL",
+       "               (reserved)",
+       "               (reserved)",
+       "               (reserved)",
+};
+
+static char* r300_vs_me_ops[] = {
+       /* R300 math ops */
+       "                 ME_NO_OP",
+       "          ME_EXP_BASE2_DX",
+       "          ME_LOG_BASE2_DX",
+       "          ME_EXP_BASEE_FF",
+       "        ME_LIGHT_COEFF_DX",
+       "         ME_POWER_FUNC_FF",
+       "              ME_RECIP_DX",
+       "              ME_RECIP_FF",
+       "         ME_RECIP_SQRT_DX",
+       "         ME_RECIP_SQRT_FF",
+       "              ME_MULTIPLY",
+       "     ME_EXP_BASE2_FULL_DX",
+       "     ME_LOG_BASE2_FULL_DX",
+       " ME_POWER_FUNC_FF_CLAMP_B",
+       "ME_POWER_FUNC_FF_CLAMP_B1",
+       "ME_POWER_FUNC_FF_CLAMP_01",
+       "                   ME_SIN",
+       "                   ME_COS",
+       /* R500 math ops */
+       "        ME_LOG_BASE2_IEEE",
+       "            ME_RECIP_IEEE",
+       "       ME_RECIP_SQRT_IEEE",
+       "           ME_PRED_SET_EQ",
+       "           ME_PRED_SET_GT",
+       "          ME_PRED_SET_GTE",
+       "          ME_PRED_SET_NEQ",
+       "          ME_PRED_SET_CLR",
+       "          ME_PRED_SET_INV",
+       "          ME_PRED_SET_POP",
+       "      ME_PRED_SET_RESTORE",
+       "               (reserved)",
+       "               (reserved)",
+       "               (reserved)",
+};
+
+/* XXX refactor to avoid clashing symbols */
+static char* r300_vs_src_debug[] = {
+       "t",
+       "i",
+       "c",
+       "a",
+};
+
+static char* r300_vs_dst_debug[] = {
+       "t",
+       "a0",
+       "o",
+       "ox",
+       "a",
+       "i",
+       "u",
+       "u",
+};
+
+static char* r300_vs_swiz_debug[] = {
+       "X",
+       "Y",
+       "Z",
+       "W",
+       "0",
+       "1",
+       "U",
+       "U",
+};
+
+
+static void r300_vs_op_dump(uint32_t op)
+{
+       fprintf(stderr, " dst: %d%s op: ",
+                       (op >> 13) & 0x7f, r300_vs_dst_debug[(op >> 8) & 0x7]);
+       if ((op >> PVS_DST_PRED_ENABLE_SHIFT) & 0x1) {
+               fprintf(stderr, "PRED %u",
+                               (op >> PVS_DST_PRED_SENSE_SHIFT) & 0x1);
+       }
+       if (op & 0x80) {
+               if (op & 0x1) {
+                       fprintf(stderr, "PVS_MACRO_OP_2CLK_M2X_ADD\n");
+               } else {
+                       fprintf(stderr, "   PVS_MACRO_OP_2CLK_MADD\n");
+               }
+       } else if (op & 0x40) {
+               fprintf(stderr, "%s\n", r300_vs_me_ops[op & 0x1f]);
+       } else {
+               fprintf(stderr, "%s\n", r300_vs_ve_ops[op & 0x1f]);
+       }
+}
+
+static void r300_vs_src_dump(uint32_t src)
+{
+       fprintf(stderr, " reg: %d%s swiz: %s%s/%s%s/%s%s/%s%s\n",
+                       (src >> 5) & 0xff, r300_vs_src_debug[src & 0x3],
+                       src & (1 << 25) ? "-" : " ",
+                       r300_vs_swiz_debug[(src >> 13) & 0x7],
+                       src & (1 << 26) ? "-" : " ",
+                       r300_vs_swiz_debug[(src >> 16) & 0x7],
+                       src & (1 << 27) ? "-" : " ",
+                       r300_vs_swiz_debug[(src >> 19) & 0x7],
+                       src & (1 << 28) ? "-" : " ",
+                       r300_vs_swiz_debug[(src >> 22) & 0x7]);
+}
+
+void r300_vertex_program_dump(struct radeon_compiler *compiler, void *user)
+{
+       struct r300_vertex_program_compiler *c = (struct r300_vertex_program_compiler*)compiler;
+       struct r300_vertex_program_code * vs = c->code;
+       unsigned instrcount = vs->length / 4;
+       unsigned i;
+
+       fprintf(stderr, "Final vertex program code:\n");
+
+       for(i = 0; i < instrcount; i++) {
+               unsigned offset = i*4;
+               unsigned src;
+
+               fprintf(stderr, "%d: op: 0x%08x", i, vs->body.d[offset]);
+               r300_vs_op_dump(vs->body.d[offset]);
+
+               for(src = 0; src < 3; ++src) {
+                       fprintf(stderr, " src%i: 0x%08x", src, vs->body.d[offset+1+src]);
+                       r300_vs_src_dump(vs->body.d[offset+1+src]);
+               }
+       }
+
+       fprintf(stderr, "Flow Control Ops: 0x%08x\n",vs->fc_ops);
+       for(i = 0; i < vs->num_fc_ops; i++) {
+               switch((vs->fc_ops >> (i * 2)) & 0x3 ) {
+               case 0: fprintf(stderr, "NOP"); break;
+               case 1: fprintf(stderr, "JUMP"); break;
+               case 2: fprintf(stderr, "LOOP"); break;
+               case 3: fprintf(stderr, "JSR"); break;
+               }
+               if (c->Base.is_r500) {
+                       fprintf(stderr,": uw-> 0x%08x lw-> 0x%08x\n",
+                               vs->fc_op_addrs.r500[i].uw,
+                               vs->fc_op_addrs.r500[i].lw);
+               } else {
+                       fprintf(stderr,": 0x%08x\n", vs->fc_op_addrs.r300[i]);
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/r500_fragprog.c b/src/gallium/drivers/r300/compiler/r500_fragprog.c
new file mode 100644 (file)
index 0000000..cf99f5e
--- /dev/null
@@ -0,0 +1,539 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "r500_fragprog.h"
+
+#include <stdio.h>
+
+#include "radeon_compiler_util.h"
+#include "radeon_list.h"
+#include "radeon_variable.h"
+#include "../r300_reg.h"
+
+/**
+ * Rewrite IF instructions to use the ALU result special register.
+ */
+int r500_transform_IF(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst_if,
+       void *data)
+{
+       struct rc_variable * writer;
+       struct rc_list * writer_list, * list_ptr;
+       struct rc_list * var_list = rc_get_variables(c);
+       unsigned int generic_if = 0;
+       unsigned int alu_chan;
+
+       if (inst_if->U.I.Opcode != RC_OPCODE_IF) {
+               return 0;
+       }
+
+       writer_list = rc_variable_list_get_writers(
+                       var_list, inst_if->Type, &inst_if->U.I.SrcReg[0]);
+       if (!writer_list) {
+               generic_if = 1;
+       } else {
+
+               /* Make sure it is safe for the writers to write to
+                * ALU Result */
+               for (list_ptr = writer_list; list_ptr;
+                                               list_ptr = list_ptr->Next) {
+                       struct rc_instruction * inst;
+                       writer = list_ptr->Item;
+                       /* We are going to modify the destination register
+                        * of writer, so if it has a reader other than
+                        * inst_if (aka ReaderCount > 1) we must fall back to
+                        * our generic IF.
+                        * If the writer has a lower IP than inst_if, this
+                        * means that inst_if is above the writer in a loop.
+                        * I'm not sure why this would ever happen, but
+                        * if it does we want to make sure we fall back
+                        * to our generic IF. */
+                       if (writer->ReaderCount > 1 || writer->Inst->IP < inst_if->IP) {
+                               generic_if = 1;
+                               break;
+                       }
+
+                       /* The ALU Result is not preserved across IF
+                        * instructions, so if there is another IF
+                        * instruction between writer and inst_if, then
+                        * we need to fall back to generic IF. */
+                       for (inst = writer->Inst; inst != inst_if; inst = inst->Next) {
+                               const struct rc_opcode_info * info =
+                                       rc_get_opcode_info(inst->U.I.Opcode);
+                               if (info->IsFlowControl) {
+                                       generic_if = 1;
+                                       break;
+                               }
+                       }
+                       if (generic_if) {
+                               break;
+                       }
+               }
+       }
+
+       if (GET_SWZ(inst_if->U.I.SrcReg[0].Swizzle, 0) == RC_SWIZZLE_X) {
+               alu_chan = RC_ALURESULT_X;
+       } else {
+               alu_chan = RC_ALURESULT_W;
+       }
+       if (generic_if) {
+               struct rc_instruction * inst_mov =
+                               rc_insert_new_instruction(c, inst_if->Prev);
+
+               inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+               inst_mov->U.I.DstReg.WriteMask = 0;
+               inst_mov->U.I.DstReg.File = RC_FILE_NONE;
+               inst_mov->U.I.ALUResultCompare = RC_COMPARE_FUNC_NOTEQUAL;
+               inst_mov->U.I.WriteALUResult = alu_chan;
+               inst_mov->U.I.SrcReg[0] = inst_if->U.I.SrcReg[0];
+               if (alu_chan == RC_ALURESULT_X) {
+                       inst_mov->U.I.SrcReg[0].Swizzle = combine_swizzles4(
+                                       inst_mov->U.I.SrcReg[0].Swizzle,
+                                       RC_SWIZZLE_X, RC_SWIZZLE_UNUSED,
+                                       RC_SWIZZLE_UNUSED, RC_SWIZZLE_UNUSED);
+               } else {
+                       inst_mov->U.I.SrcReg[0].Swizzle = combine_swizzles4(
+                                       inst_mov->U.I.SrcReg[0].Swizzle,
+                                       RC_SWIZZLE_UNUSED, RC_SWIZZLE_UNUSED,
+                                       RC_SWIZZLE_UNUSED, RC_SWIZZLE_Z);
+               }
+       } else {
+               rc_compare_func compare_func = RC_COMPARE_FUNC_NEVER;
+               unsigned int reverse_srcs = 0;
+               unsigned int preserve_opcode = 0;
+               for (list_ptr = writer_list; list_ptr;
+                                               list_ptr = list_ptr->Next) {
+                       writer = list_ptr->Item;
+                       switch(writer->Inst->U.I.Opcode) {
+                       case RC_OPCODE_SEQ:
+                               compare_func = RC_COMPARE_FUNC_EQUAL;
+                               break;
+                       case RC_OPCODE_SNE:
+                               compare_func = RC_COMPARE_FUNC_NOTEQUAL;
+                               break;
+                       case RC_OPCODE_SLE:
+                               reverse_srcs = 1;
+                               /* Fall through */
+                       case RC_OPCODE_SGE:
+                               compare_func = RC_COMPARE_FUNC_GEQUAL;
+                               break;
+                       case RC_OPCODE_SGT:
+                               reverse_srcs = 1;
+                               /* Fall through */
+                       case RC_OPCODE_SLT:
+                               compare_func = RC_COMPARE_FUNC_LESS;
+                               break;
+                       default:
+                               compare_func = RC_COMPARE_FUNC_NOTEQUAL;
+                               preserve_opcode = 1;
+                               break;
+                       }
+                       if (!preserve_opcode) {
+                               writer->Inst->U.I.Opcode = RC_OPCODE_SUB;
+                       }
+                       writer->Inst->U.I.DstReg.WriteMask = 0;
+                       writer->Inst->U.I.DstReg.File = RC_FILE_NONE;
+                       writer->Inst->U.I.WriteALUResult = alu_chan;
+                       writer->Inst->U.I.ALUResultCompare = compare_func;
+                       if (reverse_srcs) {
+                               struct rc_src_register temp_src;
+                               temp_src = writer->Inst->U.I.SrcReg[0];
+                               writer->Inst->U.I.SrcReg[0] =
+                                       writer->Inst->U.I.SrcReg[1];
+                               writer->Inst->U.I.SrcReg[1] = temp_src;
+                       }
+               }
+       }
+
+       inst_if->U.I.SrcReg[0].File = RC_FILE_SPECIAL;
+       inst_if->U.I.SrcReg[0].Index = RC_SPECIAL_ALU_RESULT;
+       inst_if->U.I.SrcReg[0].Swizzle = RC_MAKE_SWIZZLE(
+                               RC_SWIZZLE_X, RC_SWIZZLE_UNUSED,
+                               RC_SWIZZLE_UNUSED, RC_SWIZZLE_UNUSED);
+       inst_if->U.I.SrcReg[0].Negate = 0;
+
+       return 1;
+}
+
+static int r500_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
+{
+       unsigned int relevant;
+       int i;
+
+       if (opcode == RC_OPCODE_TEX ||
+           opcode == RC_OPCODE_TXB ||
+           opcode == RC_OPCODE_TXP ||
+           opcode == RC_OPCODE_TXD ||
+           opcode == RC_OPCODE_TXL ||
+           opcode == RC_OPCODE_KIL) {
+               if (reg.Abs)
+                       return 0;
+
+               if (opcode == RC_OPCODE_KIL && (reg.Swizzle != RC_SWIZZLE_XYZW || reg.Negate != RC_MASK_NONE))
+                       return 0;
+
+               for(i = 0; i < 4; ++i) {
+                       unsigned int swz = GET_SWZ(reg.Swizzle, i);
+                       if (swz == RC_SWIZZLE_UNUSED) {
+                               reg.Negate &= ~(1 << i);
+                               continue;
+                       }
+                       if (swz >= 4)
+                               return 0;
+               }
+
+               if (reg.Negate)
+                       return 0;
+
+               return 1;
+       } else if (opcode == RC_OPCODE_DDX || opcode == RC_OPCODE_DDY) {
+               /* DDX/MDH and DDY/MDV explicitly ignore incoming swizzles;
+                * if it doesn't fit perfectly into a .xyzw case... */
+               if (reg.Swizzle == RC_SWIZZLE_XYZW && !reg.Abs && !reg.Negate)
+                       return 1;
+
+               return 0;
+       } else {
+               /* ALU instructions support almost everything */
+               relevant = 0;
+               for(i = 0; i < 3; ++i) {
+                       unsigned int swz = GET_SWZ(reg.Swizzle, i);
+                       if (swz != RC_SWIZZLE_UNUSED && swz != RC_SWIZZLE_ZERO)
+                               relevant |= 1 << i;
+               }
+               if ((reg.Negate & relevant) && ((reg.Negate & relevant) != relevant))
+                       return 0;
+
+               return 1;
+       }
+}
+
+/**
+ * Split source register access.
+ *
+ * The only thing we *cannot* do in an ALU instruction is per-component
+ * negation.
+ */
+static void r500_swizzle_split(struct rc_src_register src, unsigned int usemask,
+               struct rc_swizzle_split * split)
+{
+       unsigned int negatebase[2] = { 0, 0 };
+       int i;
+
+       for(i = 0; i < 4; ++i) {
+               unsigned int swz = GET_SWZ(src.Swizzle, i);
+               if (swz == RC_SWIZZLE_UNUSED || !GET_BIT(usemask, i))
+                       continue;
+               negatebase[GET_BIT(src.Negate, i)] |= 1 << i;
+       }
+
+       split->NumPhases = 0;
+
+       for(i = 0; i <= 1; ++i) {
+               if (!negatebase[i])
+                       continue;
+
+               split->Phase[split->NumPhases++] = negatebase[i];
+       }
+}
+
+struct rc_swizzle_caps r500_swizzle_caps = {
+       .IsNative = r500_swizzle_is_native,
+       .Split = r500_swizzle_split
+};
+
+static char *toswiz(int swiz_val) {
+  switch(swiz_val) {
+  case 0: return "R";
+  case 1: return "G";
+  case 2: return "B";
+  case 3: return "A";
+  case 4: return "0";
+  case 5: return "H";
+  case 6: return "1";
+  case 7: return "U";
+  }
+  return NULL;
+}
+
+static char *toop(int op_val)
+{
+  char *str = NULL;
+  switch (op_val) {
+  case 0: str = "MAD"; break;
+  case 1: str = "DP3"; break;
+  case 2: str = "DP4"; break;
+  case 3: str = "D2A"; break;
+  case 4: str = "MIN"; break;
+  case 5: str = "MAX"; break;
+  case 6: str = "Reserved"; break;
+  case 7: str = "CND"; break;
+  case 8: str = "CMP"; break;
+  case 9: str = "FRC"; break;
+  case 10: str = "SOP"; break;
+  case 11: str = "MDH"; break;
+  case 12: str = "MDV"; break;
+  }
+  return str;
+}
+
+static char *to_alpha_op(int op_val)
+{
+  char *str = NULL;
+  switch (op_val) {
+  case 0: str = "MAD"; break;
+  case 1: str = "DP"; break;
+  case 2: str = "MIN"; break;
+  case 3: str = "MAX"; break;
+  case 4: str = "Reserved"; break;
+  case 5: str = "CND"; break;
+  case 6: str = "CMP"; break;
+  case 7: str = "FRC"; break;
+  case 8: str = "EX2"; break;
+  case 9: str = "LN2"; break;
+  case 10: str = "RCP"; break;
+  case 11: str = "RSQ"; break;
+  case 12: str = "SIN"; break;
+  case 13: str = "COS"; break;
+  case 14: str = "MDH"; break;
+  case 15: str = "MDV"; break;
+  }
+  return str;
+}
+
+static char *to_mask(int val)
+{
+  char *str = NULL;
+  switch(val) {
+  case 0: str = "NONE"; break;
+  case 1: str = "R"; break;
+  case 2: str = "G"; break;
+  case 3: str = "RG"; break;
+  case 4: str = "B"; break;
+  case 5: str = "RB"; break;
+  case 6: str = "GB"; break;
+  case 7: str = "RGB"; break;
+  case 8: str = "A"; break;
+  case 9: str = "AR"; break;
+  case 10: str = "AG"; break;
+  case 11: str = "ARG"; break;
+  case 12: str = "AB"; break;
+  case 13: str = "ARB"; break;
+  case 14: str = "AGB"; break;
+  case 15: str = "ARGB"; break;
+  }
+  return str;
+}
+
+static char *to_texop(int val)
+{
+  switch(val) {
+  case 0: return "NOP";
+  case 1: return "LD";
+  case 2: return "TEXKILL";
+  case 3: return "PROJ";
+  case 4: return "LODBIAS";
+  case 5: return "LOD";
+  case 6: return "DXDY";
+  }
+  return NULL;
+}
+
+void r500FragmentProgramDump(struct radeon_compiler *c, void *user)
+{
+  struct r300_fragment_program_compiler *compiler = (struct r300_fragment_program_compiler*)c;
+  struct r500_fragment_program_code *code = &compiler->code->code.r500;
+  int n, i;
+  uint32_t inst;
+  uint32_t inst0;
+  char *str = NULL;
+  fprintf(stderr, "R500 Fragment Program:\n--------\n");
+
+  for (n = 0; n < code->inst_end+1; n++) {
+    inst0 = inst = code->inst[n].inst0;
+    fprintf(stderr,"%d\t0:CMN_INST   0x%08x:", n, inst);
+    switch(inst & 0x3) {
+    case R500_INST_TYPE_ALU: str = "ALU"; break;
+    case R500_INST_TYPE_OUT: str = "OUT"; break;
+    case R500_INST_TYPE_FC: str = "FC"; break;
+    case R500_INST_TYPE_TEX: str = "TEX"; break;
+    };
+    fprintf(stderr,"%s %s %s %s %s ", str,
+           inst & R500_INST_TEX_SEM_WAIT ? "TEX_WAIT" : "",
+           inst & R500_INST_LAST ? "LAST" : "",
+           inst & R500_INST_NOP ? "NOP" : "",
+           inst & R500_INST_ALU_WAIT ? "ALU WAIT" : "");
+    fprintf(stderr,"wmask: %s omask: %s\n", to_mask((inst >> 11) & 0xf),
+           to_mask((inst >> 15) & 0xf));
+
+    switch(inst0 & 0x3) {
+    case R500_INST_TYPE_ALU:
+    case R500_INST_TYPE_OUT:
+      fprintf(stderr,"\t1:RGB_ADDR   0x%08x:", code->inst[n].inst1);
+      inst = code->inst[n].inst1;
+
+      fprintf(stderr,"Addr0: %d%c, Addr1: %d%c, Addr2: %d%c, srcp:%d\n",
+             inst & 0xff, (inst & (1<<8)) ? 'c' : 't',
+             (inst >> 10) & 0xff, (inst & (1<<18)) ? 'c' : 't',
+             (inst >> 20) & 0xff, (inst & (1<<28)) ? 'c' : 't',
+             (inst >> 30));
+
+      fprintf(stderr,"\t2:ALPHA_ADDR 0x%08x:", code->inst[n].inst2);
+      inst = code->inst[n].inst2;
+      fprintf(stderr,"Addr0: %d%c, Addr1: %d%c, Addr2: %d%c, srcp:%d\n",
+             inst & 0xff, (inst & (1<<8)) ? 'c' : 't',
+             (inst >> 10) & 0xff, (inst & (1<<18)) ? 'c' : 't',
+             (inst >> 20) & 0xff, (inst & (1<<28)) ? 'c' : 't',
+             (inst >> 30));
+      fprintf(stderr,"\t3 RGB_INST:  0x%08x:", code->inst[n].inst3);
+      inst = code->inst[n].inst3;
+      fprintf(stderr,"rgb_A_src:%d %s/%s/%s %d rgb_B_src:%d %s/%s/%s %d targ: %d\n",
+             (inst) & 0x3, toswiz((inst >> 2) & 0x7), toswiz((inst >> 5) & 0x7), toswiz((inst >> 8) & 0x7),
+             (inst >> 11) & 0x3,
+             (inst >> 13) & 0x3, toswiz((inst >> 15) & 0x7), toswiz((inst >> 18) & 0x7), toswiz((inst >> 21) & 0x7),
+             (inst >> 24) & 0x3, (inst >> 29) & 0x3);
+
+
+      fprintf(stderr,"\t4 ALPHA_INST:0x%08x:", code->inst[n].inst4);
+      inst = code->inst[n].inst4;
+      fprintf(stderr,"%s dest:%d%s alp_A_src:%d %s %d alp_B_src:%d %s %d targ %d w:%d\n", to_alpha_op(inst & 0xf),
+             (inst >> 4) & 0x7f, inst & (1<<11) ? "(rel)":"",
+             (inst >> 12) & 0x3, toswiz((inst >> 14) & 0x7), (inst >> 17) & 0x3,
+             (inst >> 19) & 0x3, toswiz((inst >> 21) & 0x7), (inst >> 24) & 0x3,
+             (inst >> 29) & 0x3,
+             (inst >> 31) & 0x1);
+
+      fprintf(stderr,"\t5 RGBA_INST: 0x%08x:", code->inst[n].inst5);
+      inst = code->inst[n].inst5;
+      fprintf(stderr,"%s dest:%d%s rgb_C_src:%d %s/%s/%s %d alp_C_src:%d %s %d\n", toop(inst & 0xf),
+             (inst >> 4) & 0x7f, inst & (1<<11) ? "(rel)":"",
+             (inst >> 12) & 0x3, toswiz((inst >> 14) & 0x7), toswiz((inst >> 17) & 0x7), toswiz((inst >> 20) & 0x7),
+             (inst >> 23) & 0x3,
+             (inst >> 25) & 0x3, toswiz((inst >> 27) & 0x7), (inst >> 30) & 0x3);
+      break;
+    case R500_INST_TYPE_FC:
+      fprintf(stderr, "\t2:FC_INST    0x%08x:", code->inst[n].inst2);
+      inst = code->inst[n].inst2;
+      /* JUMP_FUNC JUMP_ANY*/
+      fprintf(stderr, "0x%02x %1x ", inst >> 8 & 0xff,
+          (inst & R500_FC_JUMP_ANY) >> 5);
+      
+      /* OP */
+      switch(inst & 0x7){
+      case R500_FC_OP_JUMP:
+       fprintf(stderr, "JUMP");
+        break;
+      case R500_FC_OP_LOOP:
+        fprintf(stderr, "LOOP");
+        break;
+      case R500_FC_OP_ENDLOOP:
+        fprintf(stderr, "ENDLOOP");
+        break;
+      case R500_FC_OP_REP:
+        fprintf(stderr, "REP");
+        break;
+      case R500_FC_OP_ENDREP:
+        fprintf(stderr, "ENDREP");
+        break;
+      case R500_FC_OP_BREAKLOOP:
+        fprintf(stderr, "BREAKLOOP");
+        break;
+      case R500_FC_OP_BREAKREP:
+        fprintf(stderr, "BREAKREP");
+       break;
+      case R500_FC_OP_CONTINUE:
+        fprintf(stderr, "CONTINUE");
+        break;
+      }
+      fprintf(stderr," "); 
+      /* A_OP */
+      switch(inst & (0x3 << 6)){
+      case R500_FC_A_OP_NONE:
+        fprintf(stderr, "NONE");
+        break;
+      case R500_FC_A_OP_POP:
+       fprintf(stderr, "POP");
+        break;
+      case R500_FC_A_OP_PUSH:
+        fprintf(stderr, "PUSH");
+        break;
+      }
+      /* B_OP0 B_OP1 */
+      for(i=0; i<2; i++){
+        fprintf(stderr, " ");
+        switch(inst & (0x3 << (24 + (i * 2)))){
+        /* R500_FC_B_OP0_NONE 
+        * R500_FC_B_OP1_NONE */
+       case 0:
+          fprintf(stderr, "NONE");
+          break;
+        case R500_FC_B_OP0_DECR:
+        case R500_FC_B_OP1_DECR:
+          fprintf(stderr, "DECR");
+          break;
+        case R500_FC_B_OP0_INCR:
+        case R500_FC_B_OP1_INCR:
+          fprintf(stderr, "INCR");
+          break;
+        }
+      }
+      /*POP_CNT B_ELSE */
+      fprintf(stderr, " %d %1x", (inst >> 16) & 0x1f, (inst & R500_FC_B_ELSE) >> 4);
+      inst = code->inst[n].inst3;
+      /* JUMP_ADDR */
+      fprintf(stderr, " %d", inst >> 16);
+      
+      if(code->inst[n].inst2 & R500_FC_IGNORE_UNCOVERED){
+        fprintf(stderr, " IGN_UNC");
+      }
+      inst = code->inst[n].inst3;
+      fprintf(stderr, "\n\t3:FC_ADDR    0x%08x:", inst);
+      fprintf(stderr, "BOOL: 0x%02x, INT: 0x%02x, JUMP_ADDR: %d, JMP_GLBL: %1x\n",
+      inst & 0x1f, (inst >> 8) & 0x1f, (inst >> 16) & 0x1ff, inst >> 31); 
+      break;
+    case R500_INST_TYPE_TEX:
+      inst = code->inst[n].inst1;
+      fprintf(stderr,"\t1:TEX_INST:  0x%08x: id: %d op:%s, %s, %s %s\n", inst, (inst >> 16) & 0xf,
+             to_texop((inst >> 22) & 0x7), (inst & (1<<25)) ? "ACQ" : "",
+             (inst & (1<<26)) ? "IGNUNC" : "", (inst & (1<<27)) ? "UNSCALED" : "SCALED");
+      inst = code->inst[n].inst2;
+      fprintf(stderr,"\t2:TEX_ADDR:  0x%08x: src: %d%s %s/%s/%s/%s dst: %d%s %s/%s/%s/%s\n", inst,
+             inst & 127, inst & (1<<7) ? "(rel)" : "",
+             toswiz((inst >> 8) & 0x3), toswiz((inst >> 10) & 0x3),
+             toswiz((inst >> 12) & 0x3), toswiz((inst >> 14) & 0x3),
+             (inst >> 16) & 127, inst & (1<<23) ? "(rel)" : "",
+             toswiz((inst >> 24) & 0x3), toswiz((inst >> 26) & 0x3),
+             toswiz((inst >> 28) & 0x3), toswiz((inst >> 30) & 0x3));
+
+      fprintf(stderr,"\t3:TEX_DXDY:  0x%08x\n", code->inst[n].inst3);
+      break;
+    }
+    fprintf(stderr,"\n");
+  }
+
+}
diff --git a/src/gallium/drivers/r300/compiler/r500_fragprog.h b/src/gallium/drivers/r300/compiler/r500_fragprog.h
new file mode 100644 (file)
index 0000000..6aa448c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2005 Ben Skeggs.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/*
+ * Authors:
+ *   Ben Skeggs <darktama@iinet.net.au>
+ *   Jerome Glisse <j.glisse@gmail.com>
+ */
+#ifndef __R500_FRAGPROG_H_
+#define __R500_FRAGPROG_H_
+
+#include "radeon_compiler.h"
+#include "radeon_swizzle.h"
+
+extern void r500BuildFragmentProgramHwCode(struct radeon_compiler *c, void *user);
+
+extern void r500FragmentProgramDump(struct radeon_compiler *c, void *user);
+
+extern struct rc_swizzle_caps r500_swizzle_caps;
+
+extern int r500_transform_IF(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst_if,
+       void* data);
+
+#endif
diff --git a/src/gallium/drivers/r300/compiler/r500_fragprog_emit.c b/src/gallium/drivers/r300/compiler/r500_fragprog_emit.c
new file mode 100644 (file)
index 0000000..c30cd75
--- /dev/null
@@ -0,0 +1,678 @@
+/*
+ * Copyright (C) 2005 Ben Skeggs.
+ *
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Adaptation and modification for ATI/AMD Radeon R500 GPU chipsets.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * \file
+ *
+ * \author Ben Skeggs <darktama@iinet.net.au>
+ *
+ * \author Jerome Glisse <j.glisse@gmail.com>
+ *
+ * \author Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ */
+
+#include "r500_fragprog.h"
+
+#include "../r300_reg.h"
+
+#include "radeon_program_pair.h"
+
+#define PROG_CODE \
+       struct r500_fragment_program_code *code = &c->code->code.r500
+
+#define error(fmt, args...) do {                       \
+               rc_error(&c->Base, "%s::%s(): " fmt "\n",       \
+                       __FILE__, __FUNCTION__, ##args);        \
+       } while(0)
+
+
+struct branch_info {
+       int If;
+       int Else;
+       int Endif;
+};
+
+struct r500_loop_info {
+       int BgnLoop;
+
+       int BranchDepth;
+       int * Brks;
+       int BrkCount;
+       int BrkReserved;
+
+       int * Conts;
+       int ContCount;
+       int ContReserved;
+};
+
+struct emit_state {
+       struct radeon_compiler * C;
+       struct r500_fragment_program_code * Code;
+
+       struct branch_info * Branches;
+       unsigned int CurrentBranchDepth;
+       unsigned int BranchesReserved;
+
+       struct r500_loop_info * Loops;
+       unsigned int CurrentLoopDepth;
+       unsigned int LoopsReserved;
+
+       unsigned int MaxBranchDepth;
+
+};
+
+static unsigned int translate_rgb_op(struct r300_fragment_program_compiler *c, rc_opcode opcode)
+{
+       switch(opcode) {
+       case RC_OPCODE_CMP: return R500_ALU_RGBA_OP_CMP;
+       case RC_OPCODE_CND: return R500_ALU_RGBA_OP_CND;
+       case RC_OPCODE_DDX: return R500_ALU_RGBA_OP_MDH;
+       case RC_OPCODE_DDY: return R500_ALU_RGBA_OP_MDV;
+       case RC_OPCODE_DP3: return R500_ALU_RGBA_OP_DP3;
+       case RC_OPCODE_DP4: return R500_ALU_RGBA_OP_DP4;
+       case RC_OPCODE_FRC: return R500_ALU_RGBA_OP_FRC;
+       default:
+               error("translate_rgb_op: unknown opcode %s\n", rc_get_opcode_info(opcode)->Name);
+               /* fall through */
+       case RC_OPCODE_NOP:
+               /* fall through */
+       case RC_OPCODE_MAD: return R500_ALU_RGBA_OP_MAD;
+       case RC_OPCODE_MAX: return R500_ALU_RGBA_OP_MAX;
+       case RC_OPCODE_MIN: return R500_ALU_RGBA_OP_MIN;
+       case RC_OPCODE_REPL_ALPHA: return R500_ALU_RGBA_OP_SOP;
+       }
+}
+
+static unsigned int translate_alpha_op(struct r300_fragment_program_compiler *c, rc_opcode opcode)
+{
+       switch(opcode) {
+       case RC_OPCODE_CMP: return R500_ALPHA_OP_CMP;
+       case RC_OPCODE_CND: return R500_ALPHA_OP_CND;
+       case RC_OPCODE_COS: return R500_ALPHA_OP_COS;
+       case RC_OPCODE_DDX: return R500_ALPHA_OP_MDH;
+       case RC_OPCODE_DDY: return R500_ALPHA_OP_MDV;
+       case RC_OPCODE_DP3: return R500_ALPHA_OP_DP;
+       case RC_OPCODE_DP4: return R500_ALPHA_OP_DP;
+       case RC_OPCODE_EX2: return R500_ALPHA_OP_EX2;
+       case RC_OPCODE_FRC: return R500_ALPHA_OP_FRC;
+       case RC_OPCODE_LG2: return R500_ALPHA_OP_LN2;
+       default:
+               error("translate_alpha_op: unknown opcode %s\n", rc_get_opcode_info(opcode)->Name);
+               /* fall through */
+       case RC_OPCODE_NOP:
+               /* fall through */
+       case RC_OPCODE_MAD: return R500_ALPHA_OP_MAD;
+       case RC_OPCODE_MAX: return R500_ALPHA_OP_MAX;
+       case RC_OPCODE_MIN: return R500_ALPHA_OP_MIN;
+       case RC_OPCODE_RCP: return R500_ALPHA_OP_RCP;
+       case RC_OPCODE_RSQ: return R500_ALPHA_OP_RSQ;
+       case RC_OPCODE_SIN: return R500_ALPHA_OP_SIN;
+       }
+}
+
+static unsigned int fix_hw_swizzle(unsigned int swz)
+{
+    switch (swz) {
+        case RC_SWIZZLE_ZERO:
+        case RC_SWIZZLE_UNUSED:
+            swz = 4;
+            break;
+        case RC_SWIZZLE_HALF:
+            swz = 5;
+            break;
+        case RC_SWIZZLE_ONE:
+            swz = 6;
+            break;
+    }
+
+       return swz;
+}
+
+static unsigned int translate_arg_rgb(struct rc_pair_instruction *inst, int arg)
+{
+       unsigned int t = inst->RGB.Arg[arg].Source;
+       int comp;
+       t |= inst->RGB.Arg[arg].Negate << 11;
+       t |= inst->RGB.Arg[arg].Abs << 12;
+
+       for(comp = 0; comp < 3; ++comp)
+               t |= fix_hw_swizzle(GET_SWZ(inst->RGB.Arg[arg].Swizzle, comp)) << (3*comp + 2);
+
+       return t;
+}
+
+static unsigned int translate_arg_alpha(struct rc_pair_instruction *inst, int i)
+{
+       unsigned int t = inst->Alpha.Arg[i].Source;
+       t |= fix_hw_swizzle(GET_SWZ(inst->Alpha.Arg[i].Swizzle, 0)) << 2;
+       t |= inst->Alpha.Arg[i].Negate << 5;
+       t |= inst->Alpha.Arg[i].Abs << 6;
+       return t;
+}
+
+static uint32_t translate_alu_result_op(struct r300_fragment_program_compiler * c, rc_compare_func func)
+{
+       switch(func) {
+       case RC_COMPARE_FUNC_EQUAL: return R500_INST_ALU_RESULT_OP_EQ;
+       case RC_COMPARE_FUNC_LESS: return R500_INST_ALU_RESULT_OP_LT;
+       case RC_COMPARE_FUNC_GEQUAL: return R500_INST_ALU_RESULT_OP_GE;
+       case RC_COMPARE_FUNC_NOTEQUAL: return R500_INST_ALU_RESULT_OP_NE;
+       default:
+               rc_error(&c->Base, "%s: unsupported compare func %i\n", __FUNCTION__, func);
+               return 0;
+       }
+}
+
+static void use_temporary(struct r500_fragment_program_code* code, unsigned int index)
+{
+       if (index > code->max_temp_idx)
+               code->max_temp_idx = index;
+}
+
+static unsigned int use_source(struct r500_fragment_program_code* code, struct rc_pair_instruction_source src)
+{
+       /* From docs:
+        *   Note that inline constants set the MSB of ADDR0 and clear ADDR0_CONST.
+        * MSB = 1 << 7 */
+       if (!src.Used)
+               return 1 << 7;
+
+       if (src.File == RC_FILE_CONSTANT) {
+               return src.Index | R500_RGB_ADDR0_CONST;
+       } else if (src.File == RC_FILE_TEMPORARY || src.File == RC_FILE_INPUT) {
+               use_temporary(code, src.Index);
+               return src.Index;
+       }
+
+       return 0;
+}
+
+/**
+ * NOP the specified instruction if it is not a texture lookup.
+ */
+static void alu_nop(struct r300_fragment_program_compiler *c, int ip)
+{
+       PROG_CODE;
+
+       if ((code->inst[ip].inst0 & 0x3) != R500_INST_TYPE_TEX) {
+               code->inst[ip].inst0 |= R500_INST_NOP;
+       }
+}
+
+/**
+ * Emit a paired ALU instruction.
+ */
+static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair_instruction *inst)
+{
+       int ip;
+       PROG_CODE;
+
+       if (code->inst_end >= c->Base.max_alu_insts-1) {
+               error("emit_alu: Too many instructions");
+               return;
+       }
+
+       ip = ++code->inst_end;
+
+       /* Quirk: MDH/MDV (DDX/DDY) need a NOP on previous non-TEX instructions. */
+       if (inst->RGB.Opcode == RC_OPCODE_DDX || inst->Alpha.Opcode == RC_OPCODE_DDX ||
+               inst->RGB.Opcode == RC_OPCODE_DDY || inst->Alpha.Opcode == RC_OPCODE_DDY) {
+               if (ip > 0) {
+                       alu_nop(c, ip - 1);
+               }
+       }
+
+       code->inst[ip].inst5 = translate_rgb_op(c, inst->RGB.Opcode);
+       code->inst[ip].inst4 = translate_alpha_op(c, inst->Alpha.Opcode);
+
+       if (inst->RGB.OutputWriteMask || inst->Alpha.OutputWriteMask || inst->Alpha.DepthWriteMask) {
+               code->inst[ip].inst0 = R500_INST_TYPE_OUT;
+               if (inst->WriteALUResult) {
+                       error("Cannot write output and ALU result at the same time");
+                       return;
+               }
+       } else {
+               code->inst[ip].inst0 = R500_INST_TYPE_ALU;
+       }
+       code->inst[ip].inst0 |= R500_INST_TEX_SEM_WAIT;
+
+       code->inst[ip].inst0 |= (inst->RGB.WriteMask << 11);
+       code->inst[ip].inst0 |= inst->Alpha.WriteMask ? 1 << 14 : 0;
+       code->inst[ip].inst0 |= (inst->RGB.OutputWriteMask << 15) | (inst->Alpha.OutputWriteMask << 18);
+       if (inst->Nop) {
+               code->inst[ip].inst0 |= R500_INST_NOP;
+       }
+       if (inst->Alpha.DepthWriteMask) {
+               code->inst[ip].inst4 |= R500_ALPHA_W_OMASK;
+               c->code->writes_depth = 1;
+       }
+
+       code->inst[ip].inst4 |= R500_ALPHA_ADDRD(inst->Alpha.DestIndex);
+       code->inst[ip].inst5 |= R500_ALU_RGBA_ADDRD(inst->RGB.DestIndex);
+       use_temporary(code, inst->Alpha.DestIndex);
+       use_temporary(code, inst->RGB.DestIndex);
+
+       if (inst->RGB.Saturate)
+               code->inst[ip].inst0 |= R500_INST_RGB_CLAMP;
+       if (inst->Alpha.Saturate)
+               code->inst[ip].inst0 |= R500_INST_ALPHA_CLAMP;
+
+       /* Set the presubtract operation. */
+       switch(inst->RGB.Src[RC_PAIR_PRESUB_SRC].Index) {
+               case RC_PRESUB_BIAS:
+                       code->inst[ip].inst1 |= R500_RGB_SRCP_OP_1_MINUS_2RGB0;
+                       break;
+               case RC_PRESUB_SUB:
+                       code->inst[ip].inst1 |= R500_RGB_SRCP_OP_RGB1_MINUS_RGB0;
+                       break;
+               case RC_PRESUB_ADD:
+                       code->inst[ip].inst1 |= R500_RGB_SRCP_OP_RGB1_PLUS_RGB0;
+                       break;
+               case RC_PRESUB_INV:
+                       code->inst[ip].inst1 |= R500_RGB_SRCP_OP_1_MINUS_RGB0;
+                       break;
+               default:
+                       break;
+       }
+       switch(inst->Alpha.Src[RC_PAIR_PRESUB_SRC].Index) {
+               case RC_PRESUB_BIAS:
+                       code->inst[ip].inst2 |= R500_ALPHA_SRCP_OP_1_MINUS_2A0;
+                       break;
+               case RC_PRESUB_SUB:
+                       code->inst[ip].inst2 |= R500_ALPHA_SRCP_OP_A1_MINUS_A0;
+                       break;
+               case RC_PRESUB_ADD:
+                       code->inst[ip].inst2 |= R500_ALPHA_SRCP_OP_A1_PLUS_A0;
+                       break;
+               case RC_PRESUB_INV:
+                       code->inst[ip].inst2 |= R500_ALPHA_SRCP_OP_1_MINUS_A0;
+                       break;
+               default:
+                       break;
+       }
+
+       code->inst[ip].inst1 |= R500_RGB_ADDR0(use_source(code, inst->RGB.Src[0]));
+       code->inst[ip].inst1 |= R500_RGB_ADDR1(use_source(code, inst->RGB.Src[1]));
+       code->inst[ip].inst1 |= R500_RGB_ADDR2(use_source(code, inst->RGB.Src[2]));
+
+       code->inst[ip].inst2 |= R500_ALPHA_ADDR0(use_source(code, inst->Alpha.Src[0]));
+       code->inst[ip].inst2 |= R500_ALPHA_ADDR1(use_source(code, inst->Alpha.Src[1]));
+       code->inst[ip].inst2 |= R500_ALPHA_ADDR2(use_source(code, inst->Alpha.Src[2]));
+
+       code->inst[ip].inst3 |= translate_arg_rgb(inst, 0) << R500_ALU_RGB_SEL_A_SHIFT;
+       code->inst[ip].inst3 |= translate_arg_rgb(inst, 1) << R500_ALU_RGB_SEL_B_SHIFT;
+       code->inst[ip].inst5 |= translate_arg_rgb(inst, 2) << R500_ALU_RGBA_SEL_C_SHIFT;
+
+       code->inst[ip].inst4 |= translate_arg_alpha(inst, 0) << R500_ALPHA_SEL_A_SHIFT;
+       code->inst[ip].inst4 |= translate_arg_alpha(inst, 1) << R500_ALPHA_SEL_B_SHIFT;
+       code->inst[ip].inst5 |= translate_arg_alpha(inst, 2) << R500_ALU_RGBA_ALPHA_SEL_C_SHIFT;
+
+       code->inst[ip].inst3 |= R500_ALU_RGB_TARGET(inst->RGB.Target);
+       code->inst[ip].inst4 |= R500_ALPHA_TARGET(inst->Alpha.Target);
+
+       if (inst->WriteALUResult) {
+               code->inst[ip].inst3 |= R500_ALU_RGB_WMASK;
+
+               if (inst->WriteALUResult == RC_ALURESULT_X)
+                       code->inst[ip].inst0 |= R500_INST_ALU_RESULT_SEL_RED;
+               else
+                       code->inst[ip].inst0 |= R500_INST_ALU_RESULT_SEL_ALPHA;
+
+               code->inst[ip].inst0 |= translate_alu_result_op(c, inst->ALUResultCompare);
+       }
+}
+
+static unsigned int translate_strq_swizzle(unsigned int swizzle)
+{
+       unsigned int swiz = 0;
+       int i;
+       for (i = 0; i < 4; i++)
+               swiz |= (GET_SWZ(swizzle, i) & 0x3) << i*2;
+       return swiz;
+}
+
+/**
+ * Emit a single TEX instruction
+ */
+static int emit_tex(struct r300_fragment_program_compiler *c, struct rc_sub_instruction *inst)
+{
+       int ip;
+       PROG_CODE;
+
+       if (code->inst_end >= c->Base.max_alu_insts-1) {
+               error("emit_tex: Too many instructions");
+               return 0;
+       }
+
+       ip = ++code->inst_end;
+
+       code->inst[ip].inst0 = R500_INST_TYPE_TEX
+               | (inst->DstReg.WriteMask << 11)
+               | R500_INST_TEX_SEM_WAIT;
+       code->inst[ip].inst1 = R500_TEX_ID(inst->TexSrcUnit)
+               | R500_TEX_SEM_ACQUIRE;
+
+       if (inst->TexSrcTarget == RC_TEXTURE_RECT)
+               code->inst[ip].inst1 |= R500_TEX_UNSCALED;
+
+       switch (inst->Opcode) {
+       case RC_OPCODE_KIL:
+               code->inst[ip].inst1 |= R500_TEX_INST_TEXKILL;
+               break;
+       case RC_OPCODE_TEX:
+               code->inst[ip].inst1 |= R500_TEX_INST_LD;
+               break;
+       case RC_OPCODE_TXB:
+               code->inst[ip].inst1 |= R500_TEX_INST_LODBIAS;
+               break;
+       case RC_OPCODE_TXP:
+               code->inst[ip].inst1 |= R500_TEX_INST_PROJ;
+               break;
+       case RC_OPCODE_TXD:
+               code->inst[ip].inst1 |= R500_TEX_INST_DXDY;
+               break;
+       case RC_OPCODE_TXL:
+               code->inst[ip].inst1 |= R500_TEX_INST_LOD;
+               break;
+       default:
+               error("emit_tex can't handle opcode %s\n", rc_get_opcode_info(inst->Opcode)->Name);
+       }
+
+       use_temporary(code, inst->SrcReg[0].Index);
+       if (inst->Opcode != RC_OPCODE_KIL)
+               use_temporary(code, inst->DstReg.Index);
+
+       code->inst[ip].inst2 = R500_TEX_SRC_ADDR(inst->SrcReg[0].Index)
+               | (translate_strq_swizzle(inst->SrcReg[0].Swizzle) << 8)
+               | R500_TEX_DST_ADDR(inst->DstReg.Index)
+               | (GET_SWZ(inst->TexSwizzle, 0) << 24)
+               | (GET_SWZ(inst->TexSwizzle, 1) << 26)
+               | (GET_SWZ(inst->TexSwizzle, 2) << 28)
+               | (GET_SWZ(inst->TexSwizzle, 3) << 30)
+               ;
+
+       if (inst->Opcode == RC_OPCODE_TXD) {
+               use_temporary(code, inst->SrcReg[1].Index);
+               use_temporary(code, inst->SrcReg[2].Index);
+
+               /* DX and DY parameters are specified in a separate register. */
+               code->inst[ip].inst3 =
+                       R500_DX_ADDR(inst->SrcReg[1].Index) |
+                       (translate_strq_swizzle(inst->SrcReg[1].Swizzle) << 8) |
+                       R500_DY_ADDR(inst->SrcReg[2].Index) |
+                       (translate_strq_swizzle(inst->SrcReg[2].Swizzle) << 24);
+       }
+
+       return 1;
+}
+
+static void emit_flowcontrol(struct emit_state * s, struct rc_instruction * inst)
+{
+       unsigned int newip;
+
+       if (s->Code->inst_end >= s->C->max_alu_insts-1) {
+               rc_error(s->C, "emit_tex: Too many instructions");
+               return;
+       }
+
+       newip = ++s->Code->inst_end;
+
+       /* Currently all loops use the same integer constant to intialize
+        * the loop variables. */
+       if(!s->Code->int_constants[0]) {
+               s->Code->int_constants[0] = R500_FC_INT_CONST_KR(0xff);
+               s->Code->int_constant_count = 1;
+       }
+       s->Code->inst[newip].inst0 = R500_INST_TYPE_FC | R500_INST_ALU_WAIT;
+
+       switch(inst->U.I.Opcode){
+       struct branch_info * branch;
+       struct r500_loop_info * loop;
+       case RC_OPCODE_BGNLOOP:
+               memory_pool_array_reserve(&s->C->Pool, struct r500_loop_info,
+                       s->Loops, s->CurrentLoopDepth, s->LoopsReserved, 1);
+
+               loop = &s->Loops[s->CurrentLoopDepth++];
+               memset(loop, 0, sizeof(struct r500_loop_info));
+               loop->BranchDepth = s->CurrentBranchDepth;
+               loop->BgnLoop = newip;
+
+               s->Code->inst[newip].inst2 = R500_FC_OP_LOOP
+                       | R500_FC_JUMP_FUNC(0x00)
+                       | R500_FC_IGNORE_UNCOVERED
+                       ;
+               break;
+       case RC_OPCODE_BRK:
+               loop = &s->Loops[s->CurrentLoopDepth - 1];
+               memory_pool_array_reserve(&s->C->Pool, int, loop->Brks,
+                                       loop->BrkCount, loop->BrkReserved, 1);
+
+               loop->Brks[loop->BrkCount++] = newip;
+               s->Code->inst[newip].inst2 = R500_FC_OP_BREAKLOOP
+                       | R500_FC_JUMP_FUNC(0xff)
+                       | R500_FC_B_OP1_DECR
+                       | R500_FC_B_POP_CNT(
+                               s->CurrentBranchDepth - loop->BranchDepth)
+                       | R500_FC_IGNORE_UNCOVERED
+                       ;
+               break;
+
+       case RC_OPCODE_CONT:
+               loop = &s->Loops[s->CurrentLoopDepth - 1];
+               memory_pool_array_reserve(&s->C->Pool, int, loop->Conts,
+                                       loop->ContCount, loop->ContReserved, 1);
+               loop->Conts[loop->ContCount++] = newip;
+               s->Code->inst[newip].inst2 = R500_FC_OP_CONTINUE
+                       | R500_FC_JUMP_FUNC(0xff)
+                       | R500_FC_B_OP1_DECR
+                       | R500_FC_B_POP_CNT(
+                               s->CurrentBranchDepth - loop->BranchDepth)
+                       | R500_FC_IGNORE_UNCOVERED
+                       ;
+               break;
+
+       case RC_OPCODE_ENDLOOP:
+       {
+               loop = &s->Loops[s->CurrentLoopDepth - 1];
+               /* Emit ENDLOOP */
+               s->Code->inst[newip].inst2 = R500_FC_OP_ENDLOOP
+                       | R500_FC_JUMP_FUNC(0xff)
+                       | R500_FC_JUMP_ANY
+                       | R500_FC_IGNORE_UNCOVERED
+                       ;
+               /* The constant integer at index 0 is used by all loops. */
+               s->Code->inst[newip].inst3 = R500_FC_INT_ADDR(0)
+                       | R500_FC_JUMP_ADDR(loop->BgnLoop + 1)
+                       ;
+
+               /* Set jump address and int constant for BGNLOOP */
+               s->Code->inst[loop->BgnLoop].inst3 = R500_FC_INT_ADDR(0)
+                       | R500_FC_JUMP_ADDR(newip)
+                       ;
+
+               /* Set jump address for the BRK instructions. */
+               while(loop->BrkCount--) {
+                       s->Code->inst[loop->Brks[loop->BrkCount]].inst3 =
+                                               R500_FC_JUMP_ADDR(newip + 1);
+               }
+
+               /* Set jump address for CONT instructions. */
+               while(loop->ContCount--) {
+                       s->Code->inst[loop->Conts[loop->ContCount]].inst3 =
+                                               R500_FC_JUMP_ADDR(newip);
+               }
+               s->CurrentLoopDepth--;
+               break;
+       }
+       case RC_OPCODE_IF:
+               if ( s->CurrentBranchDepth >= R500_PFS_MAX_BRANCH_DEPTH_FULL) {
+                       rc_error(s->C, "Branch depth exceeds hardware limit");
+                       return;
+               }
+               memory_pool_array_reserve(&s->C->Pool, struct branch_info,
+                               s->Branches, s->CurrentBranchDepth, s->BranchesReserved, 1);
+
+               branch = &s->Branches[s->CurrentBranchDepth++];
+               branch->If = newip;
+               branch->Else = -1;
+               branch->Endif = -1;
+
+               if (s->CurrentBranchDepth > s->MaxBranchDepth)
+                       s->MaxBranchDepth = s->CurrentBranchDepth;
+
+               /* actual instruction is filled in at ENDIF time */
+               break;
+       
+       case RC_OPCODE_ELSE:
+               if (!s->CurrentBranchDepth) {
+                       rc_error(s->C, "%s: got ELSE outside a branch", __FUNCTION__);
+                       return;
+               }
+
+               branch = &s->Branches[s->CurrentBranchDepth - 1];
+               branch->Else = newip;
+
+               /* actual instruction is filled in at ENDIF time */
+               break;
+
+       case RC_OPCODE_ENDIF:
+               if (!s->CurrentBranchDepth) {
+                       rc_error(s->C, "%s: got ELSE outside a branch", __FUNCTION__);
+                       return;
+               }
+
+               branch = &s->Branches[s->CurrentBranchDepth - 1];
+               branch->Endif = newip;
+
+               s->Code->inst[branch->Endif].inst2 = R500_FC_OP_JUMP
+                       | R500_FC_A_OP_NONE /* no address stack */
+                       | R500_FC_JUMP_ANY /* docs says set this, but I don't understand why */
+                       | R500_FC_B_OP0_DECR /* decrement branch counter if stay */
+                       | R500_FC_B_OP1_NONE /* no branch counter if stay */
+                       | R500_FC_B_POP_CNT(1)
+                       ;
+               s->Code->inst[branch->Endif].inst3 = R500_FC_JUMP_ADDR(branch->Endif + 1);
+               s->Code->inst[branch->If].inst2 = R500_FC_OP_JUMP
+                       | R500_FC_A_OP_NONE /* no address stack */
+                       | R500_FC_JUMP_FUNC(0x0f) /* jump if ALU result is false */
+                       | R500_FC_B_OP0_INCR /* increment branch counter if stay */
+                       | R500_FC_IGNORE_UNCOVERED
+               ;
+
+               if (branch->Else >= 0) {
+                       /* increment branch counter also if jump */
+                       s->Code->inst[branch->If].inst2 |= R500_FC_B_OP1_INCR;
+                       s->Code->inst[branch->If].inst3 = R500_FC_JUMP_ADDR(branch->Else + 1);
+
+                       s->Code->inst[branch->Else].inst2 = R500_FC_OP_JUMP
+                               | R500_FC_A_OP_NONE /* no address stack */
+                               | R500_FC_B_ELSE /* all active pixels want to jump */
+                               | R500_FC_B_OP0_NONE /* no counter op if stay */
+                               | R500_FC_B_OP1_DECR /* decrement branch counter if jump */
+                               | R500_FC_B_POP_CNT(1)
+                       ;
+                       s->Code->inst[branch->Else].inst3 = R500_FC_JUMP_ADDR(branch->Endif + 1);
+               } else {
+                       /* don't touch branch counter on jump */
+                       s->Code->inst[branch->If].inst2 |= R500_FC_B_OP1_NONE;
+                       s->Code->inst[branch->If].inst3 = R500_FC_JUMP_ADDR(branch->Endif + 1);
+               }
+
+
+               s->CurrentBranchDepth--;
+               break;
+       default:
+               rc_error(s->C, "%s: unknown opcode %s\n", __FUNCTION__, rc_get_opcode_info(inst->U.I.Opcode)->Name);
+       }
+}
+
+void r500BuildFragmentProgramHwCode(struct radeon_compiler *c, void *user)
+{
+       struct r300_fragment_program_compiler *compiler = (struct r300_fragment_program_compiler*)c;
+       struct emit_state s;
+       struct r500_fragment_program_code *code = &compiler->code->code.r500;
+
+       memset(&s, 0, sizeof(s));
+       s.C = &compiler->Base;
+       s.Code = code;
+
+       memset(code, 0, sizeof(*code));
+       code->max_temp_idx = 1;
+       code->inst_end = -1;
+
+       for(struct rc_instruction * inst = compiler->Base.Program.Instructions.Next;
+           inst != &compiler->Base.Program.Instructions && !compiler->Base.Error;
+           inst = inst->Next) {
+               if (inst->Type == RC_INSTRUCTION_NORMAL) {
+                       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+                       if (opcode->IsFlowControl) {
+                               emit_flowcontrol(&s, inst);
+                       } else if (inst->U.I.Opcode == RC_OPCODE_BEGIN_TEX) {
+                               continue;
+                       } else {
+                               emit_tex(compiler, &inst->U.I);
+                       }
+               } else {
+                       emit_paired(compiler, &inst->U.P);
+               }
+       }
+
+       if (code->max_temp_idx >= compiler->Base.max_temp_regs)
+               rc_error(&compiler->Base, "Too many hardware temporaries used");
+
+       if (compiler->Base.Error)
+               return;
+
+       if (code->inst_end == -1 ||
+           (code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) {
+               int ip;
+
+               /* This may happen when dead-code elimination is disabled or
+                * when most of the fragment program logic is leading to a KIL */
+               if (code->inst_end >= compiler->Base.max_alu_insts-1) {
+                       rc_error(&compiler->Base, "Introducing fake OUT: Too many instructions");
+                       return;
+               }
+
+               ip = ++code->inst_end;
+               code->inst[ip].inst0 = R500_INST_TYPE_OUT | R500_INST_TEX_SEM_WAIT;
+       }
+
+       /* Enable full flow control mode if we are using loops or have if
+        * statements nested at least four deep. */
+       if (s.MaxBranchDepth >= 4 || s.LoopsReserved > 0) {
+               if (code->max_temp_idx < 1)
+                       code->max_temp_idx = 1;
+
+               code->us_fc_ctrl |= R500_FC_FULL_FC_EN;
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_code.c b/src/gallium/drivers/r300/compiler/radeon_code.c
new file mode 100644 (file)
index 0000000..6842fb8
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_code.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "radeon_program.h"
+
+void rc_constants_init(struct rc_constant_list * c)
+{
+       memset(c, 0, sizeof(*c));
+}
+
+/**
+ * Copy a constants structure, assuming that the destination structure
+ * is not initialized.
+ */
+void rc_constants_copy(struct rc_constant_list * dst, struct rc_constant_list * src)
+{
+       dst->Constants = malloc(sizeof(struct rc_constant) * src->Count);
+       memcpy(dst->Constants, src->Constants, sizeof(struct rc_constant) * src->Count);
+       dst->Count = src->Count;
+       dst->_Reserved = src->Count;
+}
+
+void rc_constants_destroy(struct rc_constant_list * c)
+{
+       free(c->Constants);
+       memset(c, 0, sizeof(*c));
+}
+
+unsigned rc_constants_add(struct rc_constant_list * c, struct rc_constant * constant)
+{
+       unsigned index = c->Count;
+
+       if (c->Count >= c->_Reserved) {
+               struct rc_constant * newlist;
+
+               c->_Reserved = c->_Reserved * 2;
+               if (!c->_Reserved)
+                       c->_Reserved = 16;
+
+               newlist = malloc(sizeof(struct rc_constant) * c->_Reserved);
+               memcpy(newlist, c->Constants, sizeof(struct rc_constant) * c->Count);
+
+               free(c->Constants);
+               c->Constants = newlist;
+       }
+
+       c->Constants[index] = *constant;
+       c->Count++;
+
+       return index;
+}
+
+
+/**
+ * Add a state vector to the constant list, while trying to avoid duplicates.
+ */
+unsigned rc_constants_add_state(struct rc_constant_list * c, unsigned state0, unsigned state1)
+{
+       unsigned index;
+       struct rc_constant constant;
+
+       for(index = 0; index < c->Count; ++index) {
+               if (c->Constants[index].Type == RC_CONSTANT_STATE) {
+                       if (c->Constants[index].u.State[0] == state0 &&
+                           c->Constants[index].u.State[1] == state1)
+                               return index;
+               }
+       }
+
+       memset(&constant, 0, sizeof(constant));
+       constant.Type = RC_CONSTANT_STATE;
+       constant.Size = 4;
+       constant.u.State[0] = state0;
+       constant.u.State[1] = state1;
+
+       return rc_constants_add(c, &constant);
+}
+
+
+/**
+ * Add an immediate vector to the constant list, while trying to avoid
+ * duplicates.
+ */
+unsigned rc_constants_add_immediate_vec4(struct rc_constant_list * c, const float * data)
+{
+       unsigned index;
+       struct rc_constant constant;
+
+       for(index = 0; index < c->Count; ++index) {
+               if (c->Constants[index].Type == RC_CONSTANT_IMMEDIATE) {
+                       if (!memcmp(c->Constants[index].u.Immediate, data, sizeof(float)*4))
+                               return index;
+               }
+       }
+
+       memset(&constant, 0, sizeof(constant));
+       constant.Type = RC_CONSTANT_IMMEDIATE;
+       constant.Size = 4;
+       memcpy(constant.u.Immediate, data, sizeof(float) * 4);
+
+       return rc_constants_add(c, &constant);
+}
+
+
+/**
+ * Add an immediate scalar to the constant list, while trying to avoid
+ * duplicates.
+ */
+unsigned rc_constants_add_immediate_scalar(struct rc_constant_list * c, float data, unsigned * swizzle)
+{
+       unsigned index;
+       int free_index = -1;
+       struct rc_constant constant;
+
+       for(index = 0; index < c->Count; ++index) {
+               if (c->Constants[index].Type == RC_CONSTANT_IMMEDIATE) {
+                       unsigned comp;
+                       for(comp = 0; comp < c->Constants[index].Size; ++comp) {
+                               if (c->Constants[index].u.Immediate[comp] == data) {
+                                       *swizzle = RC_MAKE_SWIZZLE_SMEAR(comp);
+                                       return index;
+                               }
+                       }
+
+                       if (c->Constants[index].Size < 4)
+                               free_index = index;
+               }
+       }
+
+       if (free_index >= 0) {
+               unsigned comp = c->Constants[free_index].Size++;
+               c->Constants[free_index].u.Immediate[comp] = data;
+               *swizzle = RC_MAKE_SWIZZLE_SMEAR(comp);
+               return free_index;
+       }
+
+       memset(&constant, 0, sizeof(constant));
+       constant.Type = RC_CONSTANT_IMMEDIATE;
+       constant.Size = 1;
+       constant.u.Immediate[0] = data;
+       *swizzle = RC_SWIZZLE_XXXX;
+
+       return rc_constants_add(c, &constant);
+}
+
+void rc_constants_print(struct rc_constant_list * c)
+{
+       unsigned int i;
+       for(i = 0; i < c->Count; i++) {
+               if (c->Constants[i].Type == RC_CONSTANT_IMMEDIATE) {
+                       float * values = c->Constants[i].u.Immediate;
+                       fprintf(stderr, "CONST[%u] = "
+                               "{ %10.4f %10.4f %10.4f %10.4f }\n",
+                               i, values[0],values[1], values[2], values[3]);
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_code.h b/src/gallium/drivers/r300/compiler/radeon_code.h
new file mode 100644 (file)
index 0000000..67e6acf
--- /dev/null
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 RADEON_CODE_H
+#define RADEON_CODE_H
+
+#include <stdint.h>
+
+#define R300_PFS_MAX_ALU_INST     64
+#define R300_PFS_MAX_TEX_INST     32
+#define R300_PFS_MAX_TEX_INDIRECT 4
+#define R300_PFS_NUM_TEMP_REGS    32
+#define R300_PFS_NUM_CONST_REGS   32
+
+#define R400_PFS_MAX_ALU_INST     512
+#define R400_PFS_MAX_TEX_INST     512
+
+#define R500_PFS_MAX_INST         512
+#define R500_PFS_NUM_TEMP_REGS    128
+#define R500_PFS_NUM_CONST_REGS   256
+#define R500_PFS_MAX_BRANCH_DEPTH_FULL 32
+#define R500_PFS_MAX_BRANCH_DEPTH_PARTIAL 4
+
+
+#define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
+
+enum {
+       /**
+        * External constants are constants whose meaning is unknown to this
+        * compiler. For example, a Mesa gl_program's constants are turned
+        * into external constants.
+        */
+       RC_CONSTANT_EXTERNAL = 0,
+
+       RC_CONSTANT_IMMEDIATE,
+
+       /**
+        * Constant referring to state that is known by this compiler,
+        * see RC_STATE_xxx, i.e. *not* arbitrary Mesa (or other) state.
+        */
+       RC_CONSTANT_STATE
+};
+
+enum {
+       RC_STATE_SHADOW_AMBIENT = 0,
+
+       RC_STATE_R300_WINDOW_DIMENSION,
+       RC_STATE_R300_TEXRECT_FACTOR,
+       RC_STATE_R300_TEXSCALE_FACTOR,
+       RC_STATE_R300_VIEWPORT_SCALE,
+       RC_STATE_R300_VIEWPORT_OFFSET
+};
+
+struct rc_constant {
+       unsigned Type:2; /**< RC_CONSTANT_xxx */
+       unsigned Size:3;
+
+       union {
+               unsigned External;
+               float Immediate[4];
+               unsigned State[2];
+       } u;
+};
+
+struct rc_constant_list {
+       struct rc_constant * Constants;
+       unsigned Count;
+
+       unsigned _Reserved;
+};
+
+void rc_constants_init(struct rc_constant_list * c);
+void rc_constants_copy(struct rc_constant_list * dst, struct rc_constant_list * src);
+void rc_constants_destroy(struct rc_constant_list * c);
+unsigned rc_constants_add(struct rc_constant_list * c, struct rc_constant * constant);
+unsigned rc_constants_add_state(struct rc_constant_list * c, unsigned state1, unsigned state2);
+unsigned rc_constants_add_immediate_vec4(struct rc_constant_list * c, const float * data);
+unsigned rc_constants_add_immediate_scalar(struct rc_constant_list * c, float data, unsigned * swizzle);
+void rc_constants_print(struct rc_constant_list * c);
+
+/**
+ * Compare functions.
+ *
+ * \note By design, RC_COMPARE_FUNC_xxx + GL_NEVER gives you
+ * the correct GL compare function.
+ */
+typedef enum {
+       RC_COMPARE_FUNC_NEVER = 0,
+       RC_COMPARE_FUNC_LESS,
+       RC_COMPARE_FUNC_EQUAL,
+       RC_COMPARE_FUNC_LEQUAL,
+       RC_COMPARE_FUNC_GREATER,
+       RC_COMPARE_FUNC_NOTEQUAL,
+       RC_COMPARE_FUNC_GEQUAL,
+       RC_COMPARE_FUNC_ALWAYS
+} rc_compare_func;
+
+/**
+ * Coordinate wrapping modes.
+ *
+ * These are not quite the same as their GL counterparts yet.
+ */
+typedef enum {
+       RC_WRAP_NONE = 0,
+       RC_WRAP_REPEAT,
+       RC_WRAP_MIRRORED_REPEAT,
+       RC_WRAP_MIRRORED_CLAMP
+} rc_wrap_mode;
+
+/**
+ * Stores state that influences the compilation of a fragment program.
+ */
+struct r300_fragment_program_external_state {
+       struct {
+               /**
+                * This field contains swizzle for some lowering passes
+                * (shadow comparison, unorm->snorm conversion)
+                */
+               unsigned texture_swizzle:12;
+
+               /**
+                * If the sampler is used as a shadow sampler,
+                * this field specifies the compare function.
+                *
+                * Otherwise, this field is \ref RC_COMPARE_FUNC_NEVER (aka 0).
+                * \sa rc_compare_func
+                */
+               unsigned texture_compare_func : 3;
+
+               /**
+                * No matter what the sampler type is,
+                * this field turns it into a shadow sampler.
+                */
+               unsigned compare_mode_enabled : 1;
+
+               /**
+                * If the sampler will receive non-normalized coords,
+                * this field is set. The scaling factor is given by
+                * RC_STATE_R300_TEXRECT_FACTOR.
+                */
+               unsigned non_normalized_coords : 1;
+
+               /**
+                * This field specifies wrapping modes for the sampler.
+                *
+                * If this field is \ref RC_WRAP_NONE (aka 0), no wrapping maths
+                * will be performed on the coordinates.
+                */
+               unsigned wrap_mode : 3;
+
+               /**
+                * The coords are scaled after applying the wrap mode emulation
+                * and right before texture fetch. The scaling factor is given by
+                * RC_STATE_R300_TEXSCALE_FACTOR. */
+               unsigned clamp_and_scale_before_fetch : 1;
+
+               /**
+                * Fetch RGTC1_SNORM or LATC1_SNORM as UNORM and convert UNORM -> SNORM
+                * in the shader.
+                */
+               unsigned convert_unorm_to_snorm:1;
+       } unit[16];
+
+       unsigned frag_clamp:1;
+};
+
+
+
+struct r300_fragment_program_node {
+       int tex_offset; /**< first tex instruction */
+       int tex_end; /**< last tex instruction, relative to tex_offset */
+       int alu_offset; /**< first ALU instruction */
+       int alu_end; /**< last ALU instruction, relative to alu_offset */
+       int flags;
+};
+
+/**
+ * Stores an R300 fragment program in its compiled-to-hardware form.
+ */
+struct r300_fragment_program_code {
+       struct {
+               unsigned int length; /**< total # of texture instructions used */
+               uint32_t inst[R400_PFS_MAX_TEX_INST];
+       } tex;
+
+       struct {
+               unsigned int length; /**< total # of ALU instructions used */
+               struct {
+                       uint32_t rgb_inst;
+                       uint32_t rgb_addr;
+                       uint32_t alpha_inst;
+                       uint32_t alpha_addr;
+                       uint32_t r400_ext_addr;
+               } inst[R400_PFS_MAX_ALU_INST];
+       } alu;
+
+       uint32_t config; /* US_CONFIG */
+       uint32_t pixsize; /* US_PIXSIZE */
+       uint32_t code_offset; /* US_CODE_OFFSET */
+       uint32_t r400_code_offset_ext; /* US_CODE_EXT */
+       uint32_t code_addr[4]; /* US_CODE_ADDR */
+       /*US_CODE_BANK.R390_MODE: Enables 512 instructions and 64 temporaries
+        * for r400 cards */
+       unsigned int r390_mode:1;
+};
+
+
+struct r500_fragment_program_code {
+       struct {
+               uint32_t inst0;
+               uint32_t inst1;
+               uint32_t inst2;
+               uint32_t inst3;
+               uint32_t inst4;
+               uint32_t inst5;
+       } inst[R500_PFS_MAX_INST];
+
+       int inst_end; /* Number of instructions - 1; also, last instruction to be executed */
+
+       int max_temp_idx;
+
+       uint32_t us_fc_ctrl;
+
+       uint32_t int_constants[32];
+       uint32_t int_constant_count;
+};
+
+struct rX00_fragment_program_code {
+       union {
+               struct r300_fragment_program_code r300;
+               struct r500_fragment_program_code r500;
+       } code;
+
+       unsigned writes_depth:1;
+
+       struct rc_constant_list constants;
+       unsigned *constants_remap_table;
+};
+
+
+#define R300_VS_MAX_ALU                256
+#define R300_VS_MAX_ALU_DWORDS  (R300_VS_MAX_ALU * 4)
+#define R500_VS_MAX_ALU                1024
+#define R500_VS_MAX_ALU_DWORDS  (R500_VS_MAX_ALU * 4)
+#define R300_VS_MAX_TEMPS      32
+/* This is the max for all chipsets (r300-r500) */
+#define R300_VS_MAX_FC_OPS 16
+/* The r500 maximum depth is not just for loops, but any combination of loops
+ * and subroutine jumps. */
+#define R500_VS_MAX_FC_DEPTH 8
+#define R300_VS_MAX_LOOP_DEPTH 1
+
+#define VSF_MAX_INPUTS 32
+#define VSF_MAX_OUTPUTS 32
+
+struct r300_vertex_program_code {
+       int length;
+       union {
+               uint32_t d[R500_VS_MAX_ALU_DWORDS];
+               float f[R500_VS_MAX_ALU_DWORDS];
+       } body;
+
+       int pos_end;
+       int num_temporaries;    /* Number of temp vars used by program */
+       int inputs[VSF_MAX_INPUTS];
+       int outputs[VSF_MAX_OUTPUTS];
+
+       struct rc_constant_list constants;
+       unsigned *constants_remap_table;
+
+       uint32_t InputsRead;
+       uint32_t OutputsWritten;
+
+       unsigned int num_fc_ops;
+       uint32_t fc_ops;
+       union {
+               uint32_t r300[R300_VS_MAX_FC_OPS];
+               struct {
+                       uint32_t lw;
+                       uint32_t uw;
+               } r500[R300_VS_MAX_FC_OPS];
+       } fc_op_addrs;
+       int32_t fc_loop_index[R300_VS_MAX_FC_OPS];
+};
+
+#endif /* RADEON_CODE_H */
+
diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler.c b/src/gallium/drivers/r300/compiler/radeon_compiler.c
new file mode 100644 (file)
index 0000000..b793672
--- /dev/null
@@ -0,0 +1,489 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 "radeon_compiler.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "radeon_dataflow.h"
+#include "radeon_program.h"
+#include "radeon_program_pair.h"
+#include "radeon_compiler_util.h"
+
+
+void rc_init(struct radeon_compiler * c)
+{
+       memset(c, 0, sizeof(*c));
+
+       memory_pool_init(&c->Pool);
+       c->Program.Instructions.Prev = &c->Program.Instructions;
+       c->Program.Instructions.Next = &c->Program.Instructions;
+       c->Program.Instructions.U.I.Opcode = RC_OPCODE_ILLEGAL_OPCODE;
+}
+
+void rc_destroy(struct radeon_compiler * c)
+{
+       rc_constants_destroy(&c->Program.Constants);
+       memory_pool_destroy(&c->Pool);
+       free(c->ErrorMsg);
+}
+
+void rc_debug(struct radeon_compiler * c, const char * fmt, ...)
+{
+       va_list ap;
+
+       if (!(c->Debug & RC_DBG_LOG))
+               return;
+
+       va_start(ap, fmt);
+       vfprintf(stderr, fmt, ap);
+       va_end(ap);
+}
+
+void rc_error(struct radeon_compiler * c, const char * fmt, ...)
+{
+       va_list ap;
+
+       c->Error = 1;
+
+       if (!c->ErrorMsg) {
+               /* Only remember the first error */
+               char buf[1024];
+               int written;
+
+               va_start(ap, fmt);
+               written = vsnprintf(buf, sizeof(buf), fmt, ap);
+               va_end(ap);
+
+               if (written < sizeof(buf)) {
+                       c->ErrorMsg = strdup(buf);
+               } else {
+                       c->ErrorMsg = malloc(written + 1);
+
+                       va_start(ap, fmt);
+                       vsnprintf(c->ErrorMsg, written + 1, fmt, ap);
+                       va_end(ap);
+               }
+       }
+
+       if (c->Debug & RC_DBG_LOG) {
+               fprintf(stderr, "r300compiler error: ");
+
+               va_start(ap, fmt);
+               vfprintf(stderr, fmt, ap);
+               va_end(ap);
+       }
+}
+
+int rc_if_fail_helper(struct radeon_compiler * c, const char * file, int line, const char * assertion)
+{
+       rc_error(c, "ICE at %s:%i: assertion failed: %s\n", file, line, assertion);
+       return 1;
+}
+
+/**
+ * Recompute c->Program.InputsRead and c->Program.OutputsWritten
+ * based on which inputs and outputs are actually referenced
+ * in program instructions.
+ */
+void rc_calculate_inputs_outputs(struct radeon_compiler * c)
+{
+       struct rc_instruction *inst;
+
+       c->Program.InputsRead = 0;
+       c->Program.OutputsWritten = 0;
+
+       for(inst = c->Program.Instructions.Next; inst != &c->Program.Instructions; inst = inst->Next)
+       {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+               int i;
+
+               for (i = 0; i < opcode->NumSrcRegs; ++i) {
+                       if (inst->U.I.SrcReg[i].File == RC_FILE_INPUT)
+                               c->Program.InputsRead |= 1 << inst->U.I.SrcReg[i].Index;
+               }
+
+               if (opcode->HasDstReg) {
+                       if (inst->U.I.DstReg.File == RC_FILE_OUTPUT)
+                               c->Program.OutputsWritten |= 1 << inst->U.I.DstReg.Index;
+               }
+       }
+}
+
+/**
+ * Rewrite the program such that everything that source the given input
+ * register will source new_input instead.
+ */
+void rc_move_input(struct radeon_compiler * c, unsigned input, struct rc_src_register new_input)
+{
+       struct rc_instruction * inst;
+
+       c->Program.InputsRead &= ~(1 << input);
+
+       for(inst = c->Program.Instructions.Next; inst != &c->Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+               unsigned i;
+
+               for(i = 0; i < opcode->NumSrcRegs; ++i) {
+                       if (inst->U.I.SrcReg[i].File == RC_FILE_INPUT && inst->U.I.SrcReg[i].Index == input) {
+                               inst->U.I.SrcReg[i].File = new_input.File;
+                               inst->U.I.SrcReg[i].Index = new_input.Index;
+                               inst->U.I.SrcReg[i].Swizzle = combine_swizzles(new_input.Swizzle, inst->U.I.SrcReg[i].Swizzle);
+                               if (!inst->U.I.SrcReg[i].Abs) {
+                                       inst->U.I.SrcReg[i].Negate ^= new_input.Negate;
+                                       inst->U.I.SrcReg[i].Abs = new_input.Abs;
+                               }
+
+                               c->Program.InputsRead |= 1 << new_input.Index;
+                       }
+               }
+       }
+}
+
+
+/**
+ * Rewrite the program such that everything that writes into the given
+ * output register will instead write to new_output. The new_output
+ * writemask is honoured.
+ */
+void rc_move_output(struct radeon_compiler * c, unsigned output, unsigned new_output, unsigned writemask)
+{
+       struct rc_instruction * inst;
+
+       c->Program.OutputsWritten &= ~(1 << output);
+
+       for(inst = c->Program.Instructions.Next; inst != &c->Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+               if (opcode->HasDstReg) {
+                       if (inst->U.I.DstReg.File == RC_FILE_OUTPUT && inst->U.I.DstReg.Index == output) {
+                               inst->U.I.DstReg.Index = new_output;
+                               inst->U.I.DstReg.WriteMask &= writemask;
+
+                               c->Program.OutputsWritten |= 1 << new_output;
+                       }
+               }
+       }
+}
+
+
+/**
+ * Rewrite the program such that a given output is duplicated.
+ */
+void rc_copy_output(struct radeon_compiler * c, unsigned output, unsigned dup_output)
+{
+       unsigned tempreg = rc_find_free_temporary(c);
+       struct rc_instruction * inst;
+
+       for(inst = c->Program.Instructions.Next; inst != &c->Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+               if (opcode->HasDstReg) {
+                       if (inst->U.I.DstReg.File == RC_FILE_OUTPUT && inst->U.I.DstReg.Index == output) {
+                               inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                               inst->U.I.DstReg.Index = tempreg;
+                       }
+               }
+       }
+
+       inst = rc_insert_new_instruction(c, c->Program.Instructions.Prev);
+       inst->U.I.Opcode = RC_OPCODE_MOV;
+       inst->U.I.DstReg.File = RC_FILE_OUTPUT;
+       inst->U.I.DstReg.Index = output;
+
+       inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+       inst->U.I.SrcReg[0].Index = tempreg;
+       inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZW;
+
+       inst = rc_insert_new_instruction(c, c->Program.Instructions.Prev);
+       inst->U.I.Opcode = RC_OPCODE_MOV;
+       inst->U.I.DstReg.File = RC_FILE_OUTPUT;
+       inst->U.I.DstReg.Index = dup_output;
+
+       inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+       inst->U.I.SrcReg[0].Index = tempreg;
+       inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZW;
+
+       c->Program.OutputsWritten |= 1 << dup_output;
+}
+
+
+/**
+ * Introduce standard code fragment to deal with fragment.position.
+ */
+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 */
+       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;
+       inst_rcp->U.I.DstReg.Index = tempregi;
+       inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
+
+       inst_rcp->U.I.SrcReg[0].File = RC_FILE_INPUT;
+       inst_rcp->U.I.SrcReg[0].Index = new_input;
+       inst_rcp->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW;
+
+       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;
+       inst_mul->U.I.DstReg.Index = tempregi;
+       inst_mul->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+
+       inst_mul->U.I.SrcReg[0].File = RC_FILE_INPUT;
+       inst_mul->U.I.SrcReg[0].Index = new_input;
+
+       inst_mul->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+       inst_mul->U.I.SrcReg[1].Index = tempregi;
+       inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
+
+       /* viewport transformation */
+       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;
+       inst_mad->U.I.DstReg.Index = tempregi;
+       inst_mad->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+
+       inst_mad->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+       inst_mad->U.I.SrcReg[0].Index = tempregi;
+       inst_mad->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZ0;
+
+       inst_mad->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
+       inst_mad->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_XYZ0;
+
+       inst_mad->U.I.SrcReg[2].File = RC_FILE_CONSTANT;
+       inst_mad->U.I.SrcReg[2].Swizzle = RC_SWIZZLE_XYZ0;
+
+       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;
+
+               for(i = 0; i < opcode->NumSrcRegs; i++) {
+                       if (inst->U.I.SrcReg[i].File == RC_FILE_INPUT &&
+                           inst->U.I.SrcReg[i].Index == wpos) {
+                               inst->U.I.SrcReg[i].File = RC_FILE_TEMPORARY;
+                               inst->U.I.SrcReg[i].Index = tempregi;
+                       }
+               }
+       }
+}
+
+
+/**
+ * The FACE input in hardware contains 1 if it's a back face, 0 otherwise.
+ * Gallium and OpenGL define it the other way around.
+ *
+ * So let's just negate FACE at the beginning of the shader and rewrite the rest
+ * of the shader to read from the newly allocated temporary.
+ */
+void rc_transform_fragment_face(struct radeon_compiler *c, unsigned face)
+{
+       unsigned tempregi = rc_find_free_temporary(c);
+       struct rc_instruction *inst_add;
+       struct rc_instruction *inst;
+
+       /* perspective divide */
+       inst_add = rc_insert_new_instruction(c, &c->Program.Instructions);
+       inst_add->U.I.Opcode = RC_OPCODE_ADD;
+
+       inst_add->U.I.DstReg.File = RC_FILE_TEMPORARY;
+       inst_add->U.I.DstReg.Index = tempregi;
+       inst_add->U.I.DstReg.WriteMask = RC_MASK_X;
+
+       inst_add->U.I.SrcReg[0].File = RC_FILE_NONE;
+       inst_add->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_1111;
+
+       inst_add->U.I.SrcReg[1].File = RC_FILE_INPUT;
+       inst_add->U.I.SrcReg[1].Index = face;
+       inst_add->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_XXXX;
+       inst_add->U.I.SrcReg[1].Negate = RC_MASK_XYZW;
+
+       for (inst = inst_add->Next; inst != &c->Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+               unsigned i;
+
+               for(i = 0; i < opcode->NumSrcRegs; i++) {
+                       if (inst->U.I.SrcReg[i].File == RC_FILE_INPUT &&
+                           inst->U.I.SrcReg[i].Index == face) {
+                               inst->U.I.SrcReg[i].File = RC_FILE_TEMPORARY;
+                               inst->U.I.SrcReg[i].Index = tempregi;
+                       }
+               }
+       }
+}
+
+static void reg_count_callback(void * userdata, struct rc_instruction * inst,
+               rc_register_file file, unsigned int index, unsigned int mask)
+{
+       int *max_reg = userdata;
+       if (file == RC_FILE_TEMPORARY)
+               (int)index > *max_reg ? *max_reg = index : 0;
+}
+
+void rc_get_stats(struct radeon_compiler *c, struct rc_program_stats *s)
+{
+       int max_reg = -1;
+       struct rc_instruction * tmp;
+       memset(s, 0, sizeof(*s));
+
+       for(tmp = c->Program.Instructions.Next; tmp != &c->Program.Instructions;
+                                                       tmp = tmp->Next){
+               const struct rc_opcode_info * info;
+               rc_for_all_reads_mask(tmp, reg_count_callback, &max_reg);
+               if (tmp->Type == RC_INSTRUCTION_NORMAL) {
+                       info = rc_get_opcode_info(tmp->U.I.Opcode);
+                       if (info->Opcode == RC_OPCODE_BEGIN_TEX)
+                               continue;
+                       if (tmp->U.I.PreSub.Opcode != RC_PRESUB_NONE)
+                               s->num_presub_ops++;
+               } else {
+                       if (tmp->U.P.RGB.Src[RC_PAIR_PRESUB_SRC].Used)
+                               s->num_presub_ops++;
+                       if (tmp->U.P.Alpha.Src[RC_PAIR_PRESUB_SRC].Used)
+                               s->num_presub_ops++;
+                       /* Assuming alpha will never be a flow control or
+                        * a tex instruction. */
+                       if (tmp->U.P.Alpha.Opcode != RC_OPCODE_NOP)
+                               s->num_alpha_insts++;
+                       if (tmp->U.P.RGB.Opcode != RC_OPCODE_NOP)
+                               s->num_rgb_insts++;
+                       info = rc_get_opcode_info(tmp->U.P.RGB.Opcode);
+               }
+               if (info->IsFlowControl)
+                       s->num_fc_insts++;
+               if (info->HasTexture)
+                       s->num_tex_insts++;
+               s->num_insts++;
+       }
+       s->num_temp_regs = max_reg + 1;
+}
+
+static void print_stats(struct radeon_compiler * c)
+{
+       struct rc_program_stats s;
+
+       if (c->initial_num_insts <= 5)
+               return;
+
+       rc_get_stats(c, &s);
+
+       switch (c->type) {
+       case RC_VERTEX_PROGRAM:
+               fprintf(stderr,"~~~~~~~~~ VERTEX PROGRAM ~~~~~~~~\n"
+                              "~%4u Instructions\n"
+                              "~%4u Flow Control Instructions\n"
+                              "~%4u Temporary Registers\n"
+                              "~~~~~~~~~~~~~~ END ~~~~~~~~~~~~~~\n",
+                              s.num_insts, s.num_fc_insts, s.num_temp_regs);
+               break;
+
+       case RC_FRAGMENT_PROGRAM:
+               fprintf(stderr,"~~~~~~~~ FRAGMENT PROGRAM ~~~~~~~\n"
+                              "~%4u Instructions\n"
+                              "~%4u Vector Instructions (RGB)\n"
+                              "~%4u Scalar Instructions (Alpha)\n"
+                              "~%4u Flow Control Instructions\n"
+                              "~%4u Texture Instructions\n"
+                              "~%4u Presub Operations\n"
+                              "~%4u Temporary Registers\n"
+                              "~~~~~~~~~~~~~~ END ~~~~~~~~~~~~~~\n",
+                              s.num_insts, s.num_rgb_insts, s.num_alpha_insts,
+                              s.num_fc_insts, s.num_tex_insts, s.num_presub_ops,
+                              s.num_temp_regs);
+               break;
+       default:
+               assert(0);
+       }
+}
+
+static const char *shader_name[RC_NUM_PROGRAM_TYPES] = {
+       "Vertex Program",
+       "Fragment Program"
+};
+
+void rc_run_compiler_passes(struct radeon_compiler *c, struct radeon_compiler_pass *list)
+{
+       for (unsigned i = 0; list[i].name; i++) {
+               if (list[i].predicate) {
+                       list[i].run(c, list[i].user);
+
+                       if (c->Error)
+                               return;
+
+                       if ((c->Debug & RC_DBG_LOG) && list[i].dump) {
+                               fprintf(stderr, "%s: after '%s'\n", shader_name[c->type], list[i].name);
+                               rc_print_program(&c->Program);
+                       }
+               }
+       }
+}
+
+/* Executes a list of compiler passes given in the parameter 'list'. */
+void rc_run_compiler(struct radeon_compiler *c, struct radeon_compiler_pass *list)
+{
+       struct rc_program_stats s;
+
+       rc_get_stats(c, &s);
+       c->initial_num_insts = s.num_insts;
+
+       if (c->Debug & RC_DBG_LOG) {
+               fprintf(stderr, "%s: before compilation\n", shader_name[c->type]);
+               rc_print_program(&c->Program);
+       }
+
+       rc_run_compiler_passes(c, list);
+
+       if (c->Debug & RC_DBG_STATS)
+               print_stats(c);
+}
+
+void rc_validate_final_shader(struct radeon_compiler *c, void *user)
+{
+       /* Check the number of constants. */
+       if (c->Program.Constants.Count > c->max_constants) {
+               rc_error(c, "Too many constants. Max: %i, Got: %i\n",
+                        c->max_constants, c->Program.Constants.Count);
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler.h b/src/gallium/drivers/r300/compiler/radeon_compiler.h
new file mode 100644 (file)
index 0000000..74594af
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 RADEON_COMPILER_H
+#define RADEON_COMPILER_H
+
+#include "main/compiler.h"
+
+#include "memory_pool.h"
+#include "radeon_code.h"
+#include "radeon_program.h"
+#include "radeon_emulate_loops.h"
+
+#define RC_DBG_LOG        (1 << 0)
+#define RC_DBG_STATS      (1 << 1)
+
+struct rc_swizzle_caps;
+
+enum rc_program_type {
+       RC_VERTEX_PROGRAM,
+       RC_FRAGMENT_PROGRAM,
+       RC_NUM_PROGRAM_TYPES
+};
+
+struct radeon_compiler {
+       struct memory_pool Pool;
+       struct rc_program Program;
+       enum rc_program_type type;
+       unsigned Debug:2;
+       unsigned Error:1;
+       char * ErrorMsg;
+
+       /* Hardware specification. */
+       unsigned is_r400:1;
+       unsigned is_r500:1;
+       unsigned has_half_swizzles:1;
+       unsigned has_presub:1;
+       unsigned disable_optimizations:1;
+       unsigned max_temp_regs;
+       unsigned max_constants;
+       int max_alu_insts;
+       unsigned max_tex_insts;
+
+       /* Whether to remove unused constants and empty holes in constant space. */
+       unsigned remove_unused_constants:1;
+
+       /**
+        * Variables used internally, not be touched by callers
+        * of the compiler
+        */
+       /*@{*/
+       struct rc_swizzle_caps * SwizzleCaps;
+       /*@}*/
+
+       struct emulate_loop_state loop_state;
+
+       unsigned initial_num_insts; /* Number of instructions at start. */
+};
+
+void rc_init(struct radeon_compiler * c);
+void rc_destroy(struct radeon_compiler * c);
+
+void rc_debug(struct radeon_compiler * c, const char * fmt, ...);
+void rc_error(struct radeon_compiler * c, const char * fmt, ...);
+
+int rc_if_fail_helper(struct radeon_compiler * c, const char * file, int line, const char * assertion);
+
+/**
+ * This macro acts like an if-statement that can be used to implement
+ * non-aborting assertions in the compiler.
+ *
+ * It checks whether \p cond is true. If not, an internal compiler error is
+ * flagged and the if-clause is run.
+ *
+ * A typical use-case would be:
+ *
+ *  if (rc_assert(c, condition-that-must-be-true))
+ *     return;
+ */
+#define rc_assert(c, cond) \
+       (!(cond) && rc_if_fail_helper(c, __FILE__, __LINE__, #cond))
+
+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,
+                                int full_vtransform);
+void rc_transform_fragment_face(struct radeon_compiler *c, unsigned face);
+
+struct r300_fragment_program_compiler {
+       struct radeon_compiler Base;
+       struct rX00_fragment_program_code *code;
+       /* Optional transformations and features. */
+       struct r300_fragment_program_external_state state;
+       unsigned enable_shadow_ambient;
+       /* Register corresponding to the depthbuffer. */
+       unsigned OutputDepth;
+       /* Registers corresponding to the four colorbuffers. */
+       unsigned OutputColor[4];
+
+       void * UserData;
+       void (*AllocateHwInputs)(
+               struct r300_fragment_program_compiler * c,
+               void (*allocate)(void * data, unsigned input, unsigned hwreg),
+               void * mydata);
+};
+
+void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c);
+
+struct r300_vertex_program_compiler {
+       struct radeon_compiler Base;
+       struct r300_vertex_program_code *code;
+       uint32_t RequiredOutputs;
+
+       void * UserData;
+       void (*SetHwInputOutput)(struct r300_vertex_program_compiler * c);
+
+       int PredicateIndex;
+       unsigned int PredicateMask;
+};
+
+void r3xx_compile_vertex_program(struct r300_vertex_program_compiler* c);
+void r300_vertex_program_dump(struct radeon_compiler *compiler, void *user);
+
+struct radeon_compiler_pass {
+       const char *name;       /* Name of the pass. */
+       int dump;               /* Dump the program if Debug == 1? */
+       int predicate;          /* Run this pass? */
+       void (*run)(struct radeon_compiler *c, void *user); /* The main entrypoint. */
+       void *user;             /* Optional parameter which is passed to the run function. */
+};
+
+struct rc_program_stats {
+       unsigned num_insts;
+       unsigned num_fc_insts;
+       unsigned num_tex_insts;
+       unsigned num_rgb_insts;
+       unsigned num_alpha_insts;
+       unsigned num_presub_ops;
+       unsigned num_temp_regs;
+};
+
+void rc_get_stats(struct radeon_compiler *c, struct rc_program_stats *s);
+
+/* Executes a list of compiler passes given in the parameter 'list'. */
+void rc_run_compiler_passes(struct radeon_compiler *c, struct radeon_compiler_pass *list);
+void rc_run_compiler(struct radeon_compiler *c, struct radeon_compiler_pass *list);
+void rc_validate_final_shader(struct radeon_compiler *c, void *user);
+
+#endif /* RADEON_COMPILER_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c
new file mode 100644 (file)
index 0000000..2742721
--- /dev/null
@@ -0,0 +1,701 @@
+/*
+ * Copyright 2010 Tom Stellard <tstellar@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * \file
+ */
+
+#include "radeon_compiler_util.h"
+
+#include "radeon_compiler.h"
+#include "radeon_dataflow.h"
+/**
+ */
+unsigned int rc_swizzle_to_writemask(unsigned int swz)
+{
+       unsigned int mask = 0;
+       unsigned int i;
+
+       for(i = 0; i < 4; i++) {
+               mask |= 1 << GET_SWZ(swz, i);
+       }
+       mask &= RC_MASK_XYZW;
+
+       return mask;
+}
+
+rc_swizzle get_swz(unsigned int swz, rc_swizzle idx)
+{
+       if (idx & 0x4)
+               return idx;
+       return GET_SWZ(swz, idx);
+}
+
+/**
+ * The purpose of this function is to standardize the number channels used by
+ * swizzles.  All swizzles regardless of what instruction they are a part of
+ * should have 4 channels initialized with values.
+ * @param channels The number of channels in initial_value that have a
+ * meaningful value.
+ * @return An initialized swizzle that has all of the unused channels set to
+ * RC_SWIZZLE_UNUSED.
+ */
+unsigned int rc_init_swizzle(unsigned int initial_value, unsigned int channels)
+{
+       unsigned int i;
+       for (i = channels; i < 4; i++) {
+               SET_SWZ(initial_value, i, RC_SWIZZLE_UNUSED);
+       }
+       return initial_value;
+}
+
+unsigned int combine_swizzles4(unsigned int src,
+               rc_swizzle swz_x, rc_swizzle swz_y, rc_swizzle swz_z, rc_swizzle swz_w)
+{
+       unsigned int ret = 0;
+
+       ret |= get_swz(src, swz_x);
+       ret |= get_swz(src, swz_y) << 3;
+       ret |= get_swz(src, swz_z) << 6;
+       ret |= get_swz(src, swz_w) << 9;
+
+       return ret;
+}
+
+unsigned int combine_swizzles(unsigned int src, unsigned int swz)
+{
+       unsigned int ret = 0;
+
+       ret |= get_swz(src, GET_SWZ(swz, RC_SWIZZLE_X));
+       ret |= get_swz(src, GET_SWZ(swz, RC_SWIZZLE_Y)) << 3;
+       ret |= get_swz(src, GET_SWZ(swz, RC_SWIZZLE_Z)) << 6;
+       ret |= get_swz(src, GET_SWZ(swz, RC_SWIZZLE_W)) << 9;
+
+       return ret;
+}
+
+/**
+ * @param mask Must be either RC_MASK_X, RC_MASK_Y, RC_MASK_Z, or RC_MASK_W
+ */
+rc_swizzle rc_mask_to_swizzle(unsigned int mask)
+{
+       switch (mask) {
+       case RC_MASK_X: return RC_SWIZZLE_X;
+       case RC_MASK_Y: return RC_SWIZZLE_Y;
+       case RC_MASK_Z: return RC_SWIZZLE_Z;
+       case RC_MASK_W: return RC_SWIZZLE_W;
+       }
+       return RC_SWIZZLE_UNUSED;
+}
+
+/* Reorder mask bits according to swizzle. */
+unsigned swizzle_mask(unsigned swizzle, unsigned mask)
+{
+       unsigned ret = 0;
+       for (unsigned chan = 0; chan < 4; ++chan) {
+               unsigned swz = GET_SWZ(swizzle, chan);
+               if (swz < 4)
+                       ret |= GET_BIT(mask, swz) << chan;
+       }
+       return ret;
+}
+
+static unsigned int srcs_need_rewrite(const struct rc_opcode_info * info)
+{
+       if (info->HasTexture) {
+               return 0;
+       }
+       switch (info->Opcode) {
+               case RC_OPCODE_DP2:
+               case RC_OPCODE_DP3:
+               case RC_OPCODE_DP4:
+               case RC_OPCODE_DDX:
+               case RC_OPCODE_DDY:
+                       return 0;
+               default:
+                       return 1;
+       }
+}
+
+/**
+ * @return A swizzle the results from converting old_swizzle using
+ * conversion_swizzle
+ */
+unsigned int rc_adjust_channels(
+       unsigned int old_swizzle,
+       unsigned int conversion_swizzle)
+{
+       unsigned int i;
+       unsigned int new_swizzle = rc_init_swizzle(RC_SWIZZLE_UNUSED, 0);
+       for (i = 0; i < 4; i++) {
+               unsigned int new_chan = get_swz(conversion_swizzle, i);
+               if (new_chan == RC_SWIZZLE_UNUSED) {
+                       continue;
+               }
+               SET_SWZ(new_swizzle, new_chan, GET_SWZ(old_swizzle, i));
+       }
+       return new_swizzle;
+}
+
+static unsigned int rewrite_writemask(
+       unsigned int old_mask,
+       unsigned int conversion_swizzle)
+{
+       unsigned int new_mask = 0;
+       unsigned int i;
+
+       for (i = 0; i < 4; i++) {
+               if (!GET_BIT(old_mask, i)
+                  || GET_SWZ(conversion_swizzle, i) == RC_SWIZZLE_UNUSED) {
+                       continue;
+               }
+               new_mask |= (1 << GET_SWZ(conversion_swizzle, i));
+       }
+
+       return new_mask;
+}
+
+/**
+ * This function rewrites the writemask of sub and adjusts the swizzles
+ * of all its source registers based on the conversion_swizzle.
+ * conversion_swizzle represents a mapping of the old writemask to the
+ * new writemask.  For a detailed description of how conversion swizzles
+ * work see rc_rewrite_swizzle().
+ */
+void rc_pair_rewrite_writemask(
+       struct rc_pair_sub_instruction * sub,
+       unsigned int conversion_swizzle)
+{
+       const struct rc_opcode_info * info = rc_get_opcode_info(sub->Opcode);
+       unsigned int i;
+
+       sub->WriteMask = rewrite_writemask(sub->WriteMask, conversion_swizzle);
+
+       if (!srcs_need_rewrite(info)) {
+               return ;
+       }
+
+       for (i = 0; i < info->NumSrcRegs; i++) {
+               sub->Arg[i].Swizzle =
+                       rc_adjust_channels(sub->Arg[i].Swizzle,
+                                               conversion_swizzle);
+       }
+}
+
+static void normal_rewrite_writemask_cb(
+       void * userdata,
+       struct rc_instruction * inst,
+       struct rc_src_register * src)
+{
+       unsigned int * new_mask = (unsigned int *)userdata;
+       src->Swizzle = rc_adjust_channels(src->Swizzle, *new_mask);
+}
+
+/**
+ * This function is the same as rc_pair_rewrite_writemask() except it
+ * operates on normal instructions.
+ */
+void rc_normal_rewrite_writemask(
+       struct rc_instruction * inst,
+       unsigned int conversion_swizzle)
+{
+       unsigned int new_mask;
+       struct rc_sub_instruction * sub = &inst->U.I;
+       const struct rc_opcode_info * info = rc_get_opcode_info(sub->Opcode);
+       sub->DstReg.WriteMask =
+               rewrite_writemask(sub->DstReg.WriteMask, conversion_swizzle);
+
+       if (info->HasTexture) {
+               unsigned int i;
+               assert(sub->TexSwizzle == RC_SWIZZLE_XYZW);
+               for (i = 0; i < 4; i++) {
+                       unsigned int swz = GET_SWZ(conversion_swizzle, i);
+                       if (swz > 3)
+                               continue;
+                       SET_SWZ(sub->TexSwizzle, swz, i);
+               }
+       }
+
+       if (!srcs_need_rewrite(info)) {
+               return;
+       }
+
+       new_mask = sub->DstReg.WriteMask;
+       rc_for_all_reads_src(inst, normal_rewrite_writemask_cb, &new_mask);
+}
+
+/**
+ * This function replaces each value 'swz' in swizzle with the value of
+ * GET_SWZ(conversion_swizzle, swz).  So, if you want to change all the X's
+ * in swizzle to Y, then conversion_swizzle should be Y___ (0xff9).  If you want
+ * to change all the Y's in swizzle to X, then conversion_swizzle should be
+ * _X__ (0xfc7).  If you want to change the Y's to X and the X's to Y, then
+ * conversion swizzle should be YX__ (0xfc1).
+ * @param swizzle The swizzle to change
+ * @param conversion_swizzle Describes the conversion to perform on the swizzle
+ * @return A converted swizzle
+ */
+unsigned int rc_rewrite_swizzle(
+       unsigned int swizzle,
+       unsigned int conversion_swizzle)
+{
+       unsigned int chan;
+       unsigned int out_swizzle = swizzle;
+
+       for (chan = 0; chan < 4; chan++) {
+               unsigned int swz = GET_SWZ(swizzle, chan);
+               unsigned int new_swz;
+               if (swz > 3) {
+                       SET_SWZ(out_swizzle, chan, swz);
+               } else {
+                       new_swz = GET_SWZ(conversion_swizzle, swz);
+                       if (new_swz != RC_SWIZZLE_UNUSED) {
+                               SET_SWZ(out_swizzle, chan, new_swz);
+                       } else {
+                               SET_SWZ(out_swizzle, chan, swz);
+                       }
+               }
+       }
+       return out_swizzle;
+}
+
+/**
+ * Left multiplication of a register with a swizzle
+ */
+struct rc_src_register lmul_swizzle(unsigned int swizzle, struct rc_src_register srcreg)
+{
+       struct rc_src_register tmp = srcreg;
+       int i;
+       tmp.Swizzle = 0;
+       tmp.Negate = 0;
+       for(i = 0; i < 4; ++i) {
+               rc_swizzle swz = GET_SWZ(swizzle, i);
+               if (swz < 4) {
+                       tmp.Swizzle |= GET_SWZ(srcreg.Swizzle, swz) << (i*3);
+                       tmp.Negate |= GET_BIT(srcreg.Negate, swz) << i;
+               } else {
+                       tmp.Swizzle |= swz << (i*3);
+               }
+       }
+       return tmp;
+}
+
+void reset_srcreg(struct rc_src_register* reg)
+{
+       memset(reg, 0, sizeof(struct rc_src_register));
+       reg->Swizzle = RC_SWIZZLE_XYZW;
+}
+
+unsigned int rc_src_reads_dst_mask(
+               rc_register_file src_file,
+               unsigned int src_idx,
+               unsigned int src_swz,
+               rc_register_file dst_file,
+               unsigned int dst_idx,
+               unsigned int dst_mask)
+{
+       if (src_file != dst_file || src_idx != dst_idx) {
+               return RC_MASK_NONE;
+       }
+       return dst_mask & rc_swizzle_to_writemask(src_swz);
+}
+
+/**
+ * @return A bit mask specifying whether this swizzle will select from an RGB
+ * source, an Alpha source, or both.
+ */
+unsigned int rc_source_type_swz(unsigned int swizzle)
+{
+       unsigned int chan;
+       unsigned int swz = RC_SWIZZLE_UNUSED;
+       unsigned int ret = RC_SOURCE_NONE;
+
+       for(chan = 0; chan < 4; chan++) {
+               swz = GET_SWZ(swizzle, chan);
+               if (swz == RC_SWIZZLE_W) {
+                       ret |= RC_SOURCE_ALPHA;
+               } else if (swz == RC_SWIZZLE_X || swz == RC_SWIZZLE_Y
+                                               || swz == RC_SWIZZLE_Z) {
+                       ret |= RC_SOURCE_RGB;
+               }
+       }
+       return ret;
+}
+
+unsigned int rc_source_type_mask(unsigned int mask)
+{
+       unsigned int ret = RC_SOURCE_NONE;
+
+       if (mask & RC_MASK_XYZ)
+               ret |= RC_SOURCE_RGB;
+
+       if (mask & RC_MASK_W)
+               ret |= RC_SOURCE_ALPHA;
+
+       return ret;
+}
+
+struct src_select {
+       rc_register_file File;
+       int Index;
+       unsigned int SrcType;
+};
+
+struct can_use_presub_data {
+       struct src_select Selects[5];
+       unsigned int SelectCount;
+       const struct rc_src_register * ReplaceReg;
+       unsigned int ReplaceRemoved;
+};
+
+static void can_use_presub_data_add_select(
+       struct can_use_presub_data * data,
+       rc_register_file file,
+       unsigned int index,
+       unsigned int src_type)
+{
+       struct src_select * select;
+
+       select = &data->Selects[data->SelectCount++];
+       select->File = file;
+       select->Index = index;
+       select->SrcType = src_type;
+}
+
+/**
+ * This callback function counts the number of sources in inst that are
+ * different from the sources in can_use_presub_data->RemoveSrcs.
+ */
+static void can_use_presub_read_cb(
+       void * userdata,
+       struct rc_instruction * inst,
+       struct rc_src_register * src)
+{
+       struct can_use_presub_data * d = userdata;
+
+       if (!d->ReplaceRemoved && src == d->ReplaceReg) {
+               d->ReplaceRemoved = 1;
+               return;
+       }
+
+       if (src->File == RC_FILE_NONE)
+               return;
+
+       can_use_presub_data_add_select(d, src->File, src->Index,
+                                       rc_source_type_swz(src->Swizzle));
+}
+
+unsigned int rc_inst_can_use_presub(
+       struct rc_instruction * inst,
+       rc_presubtract_op presub_op,
+       unsigned int presub_writemask,
+       const struct rc_src_register * replace_reg,
+       const struct rc_src_register * presub_src0,
+       const struct rc_src_register * presub_src1)
+{
+       struct can_use_presub_data d;
+       unsigned int num_presub_srcs;
+       unsigned int i;
+       const struct rc_opcode_info * info =
+                                       rc_get_opcode_info(inst->U.I.Opcode);
+       int rgb_count = 0, alpha_count = 0;
+       unsigned int src_type0, src_type1;
+
+       if (presub_op == RC_PRESUB_NONE) {
+               return 1;
+       }
+
+       if (info->HasTexture) {
+               return 0;
+       }
+
+       /* We can't use more than one presubtract value in an
+        * instruction, unless the two prsubtract operations
+        * are the same and read from the same registers.
+        * XXX For now we will limit instructions to only one presubtract
+        * value.*/
+       if (inst->U.I.PreSub.Opcode != RC_PRESUB_NONE) {
+               return 0;
+       }
+
+       memset(&d, 0, sizeof(d));
+       d.ReplaceReg = replace_reg;
+
+       rc_for_all_reads_src(inst, can_use_presub_read_cb, &d);
+
+       num_presub_srcs = rc_presubtract_src_reg_count(presub_op);
+
+       src_type0 = rc_source_type_swz(presub_src0->Swizzle);
+       can_use_presub_data_add_select(&d,
+               presub_src0->File,
+               presub_src0->Index,
+               src_type0);
+
+       if (num_presub_srcs > 1) {
+               src_type1 = rc_source_type_swz(presub_src1->Swizzle);
+               can_use_presub_data_add_select(&d,
+                       presub_src1->File,
+                       presub_src1->Index,
+                       src_type1);
+
+               /* Even if both of the presub sources read from the same
+                * register, we still need to use 2 different source selects
+                * for them, so we need to increment the count to compensate.
+                */
+               if (presub_src0->File == presub_src1->File
+                   && presub_src0->Index == presub_src1->Index) {
+                       if (src_type0 & src_type1 & RC_SOURCE_RGB) {
+                               rgb_count++;
+                       }
+                       if (src_type0 & src_type1 & RC_SOURCE_ALPHA) {
+                               alpha_count++;
+                       }
+               }
+       }
+
+       /* Count the number of source selects for Alpha and RGB.  If we
+        * encounter two of the same source selects then we can ignore the
+        * first one. */
+       for (i = 0; i < d.SelectCount; i++) {
+               unsigned int j;
+               unsigned int src_type = d.Selects[i].SrcType;
+               for (j = i + 1; j < d.SelectCount; j++) {
+                       if (d.Selects[i].File == d.Selects[j].File
+                           && d.Selects[i].Index == d.Selects[j].Index) {
+                               src_type &= ~d.Selects[j].SrcType;
+                       }
+               }
+               if (src_type & RC_SOURCE_RGB) {
+                       rgb_count++;
+               }
+
+               if (src_type & RC_SOURCE_ALPHA) {
+                       alpha_count++;
+               }
+       }
+
+       if (rgb_count > 3 || alpha_count > 3) {
+               return 0;
+       }
+
+       return 1;
+}
+
+struct max_data {
+       unsigned int Max;
+       unsigned int HasFileType;
+       rc_register_file File;
+};
+
+static void max_callback(
+       void * userdata,
+       struct rc_instruction * inst,
+       rc_register_file file,
+       unsigned int index,
+       unsigned int mask)
+{
+       struct max_data * d = (struct max_data*)userdata;
+       if (file == d->File && (!d->HasFileType || index > d->Max)) {
+               d->Max = index;
+               d->HasFileType = 1;
+       }
+}
+
+/**
+ * @return The maximum index of the specified register file used by the
+ * program.
+ */
+int rc_get_max_index(
+       struct radeon_compiler * c,
+       rc_register_file file)
+{
+       struct max_data data;
+       struct rc_instruction * inst;
+       data.Max = 0;
+       data.HasFileType = 0;
+       data.File = file;
+       for (inst = c->Program.Instructions.Next;
+                                       inst != &c->Program.Instructions;
+                                       inst = inst->Next) {
+               rc_for_all_reads_mask(inst, max_callback, &data);
+               rc_for_all_writes_mask(inst, max_callback, &data);
+       }
+       if (!data.HasFileType) {
+               return -1;
+       } else {
+               return data.Max;
+       }
+}
+
+static unsigned int get_source_readmask(
+       struct rc_pair_sub_instruction * sub,
+       unsigned int source,
+       unsigned int src_type)
+{
+       unsigned int i;
+       unsigned int readmask = 0;
+       const struct rc_opcode_info * info = rc_get_opcode_info(sub->Opcode);
+
+       for (i = 0; i < info->NumSrcRegs; i++) {
+               if (sub->Arg[i].Source != source
+                   || src_type != rc_source_type_swz(sub->Arg[i].Swizzle)) {
+                       continue;
+               }
+               readmask |= rc_swizzle_to_writemask(sub->Arg[i].Swizzle);
+       }
+       return readmask;
+}
+
+/**
+ * This function attempts to remove a source from a pair instructions.
+ * @param inst
+ * @param src_type RC_SOURCE_RGB, RC_SOURCE_ALPHA, or both bitwise or'd
+ * @param source The index of the source to remove
+ * @param new_readmask A mask representing the components that are read by
+ * the source that is intended to replace the one you are removing.  If you
+ * want to remove a source only and not replace it, this parameter should be
+ * zero.
+ * @return 1 if the source was successfully removed, 0 if it was not
+ */
+unsigned int rc_pair_remove_src(
+       struct rc_instruction * inst,
+       unsigned int src_type,
+       unsigned int source,
+       unsigned int new_readmask)
+{
+       unsigned int readmask = 0;
+
+       readmask |= get_source_readmask(&inst->U.P.RGB, source, src_type);
+       readmask |= get_source_readmask(&inst->U.P.Alpha, source, src_type);
+
+       if ((new_readmask & readmask) != readmask)
+               return 0;
+
+       if (src_type & RC_SOURCE_RGB) {
+               memset(&inst->U.P.RGB.Src[source], 0,
+                       sizeof(struct rc_pair_instruction_source));
+       }
+
+       if (src_type & RC_SOURCE_ALPHA) {
+               memset(&inst->U.P.Alpha.Src[source], 0,
+                       sizeof(struct rc_pair_instruction_source));
+       }
+
+       return 1;
+}
+
+/**
+ * @return RC_OPCODE_NOOP if inst is not a flow control instruction.
+ * @return The opcode of inst if it is a flow control instruction.
+ */
+rc_opcode rc_get_flow_control_inst(struct rc_instruction * inst)
+{
+       const struct rc_opcode_info * info;
+       if (inst->Type == RC_INSTRUCTION_NORMAL) {
+               info = rc_get_opcode_info(inst->U.I.Opcode);
+       } else {
+               info = rc_get_opcode_info(inst->U.P.RGB.Opcode);
+               /*A flow control instruction shouldn't have an alpha
+                * instruction.*/
+               assert(!info->IsFlowControl ||
+                               inst->U.P.Alpha.Opcode == RC_OPCODE_NOP);
+       }
+
+       if (info->IsFlowControl)
+               return info->Opcode;
+       else
+               return RC_OPCODE_NOP;
+
+}
+
+/**
+ * @return The BGNLOOP instruction that starts the loop ended by endloop.
+ */
+struct rc_instruction * rc_match_endloop(struct rc_instruction * endloop)
+{
+       unsigned int endloop_count = 0;
+       struct rc_instruction * inst;
+       for (inst = endloop->Prev; inst != endloop; inst = inst->Prev) {
+               rc_opcode op = rc_get_flow_control_inst(inst);
+               if (op == RC_OPCODE_ENDLOOP) {
+                       endloop_count++;
+               } else if (op == RC_OPCODE_BGNLOOP) {
+                       if (endloop_count == 0) {
+                               return inst;
+                       } else {
+                               endloop_count--;
+                       }
+               }
+       }
+       return NULL;
+}
+
+/**
+ * @return The ENDLOOP instruction that ends the loop started by bgnloop.
+ */
+struct rc_instruction * rc_match_bgnloop(struct rc_instruction * bgnloop)
+{
+       unsigned int bgnloop_count = 0;
+       struct rc_instruction * inst;
+       for (inst = bgnloop->Next; inst!=bgnloop; inst = inst->Next) {
+               rc_opcode op = rc_get_flow_control_inst(inst);
+               if (op == RC_OPCODE_BGNLOOP) {
+                       bgnloop_count++;
+               } else if (op == RC_OPCODE_ENDLOOP) {
+                       if (bgnloop_count == 0) {
+                               return inst;
+                       } else {
+                               bgnloop_count--;
+                       }
+               }
+       }
+       return NULL;
+}
+
+/**
+ * @return A conversion swizzle for converting from old_mask->new_mask
+ */
+unsigned int rc_make_conversion_swizzle(
+       unsigned int old_mask,
+       unsigned int new_mask)
+{
+       unsigned int conversion_swizzle = rc_init_swizzle(RC_SWIZZLE_UNUSED, 0);
+       unsigned int old_idx;
+       unsigned int new_idx = 0;
+       for (old_idx = 0; old_idx < 4; old_idx++) {
+               if (!GET_BIT(old_mask, old_idx))
+                       continue;
+               for ( ; new_idx < 4; new_idx++) {
+                       if (GET_BIT(new_mask, new_idx)) {
+                               SET_SWZ(conversion_swizzle, old_idx, new_idx);
+                               new_idx++;
+                               break;
+                       }
+               }
+       }
+       return conversion_swizzle;
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler_util.h b/src/gallium/drivers/r300/compiler/radeon_compiler_util.h
new file mode 100644 (file)
index 0000000..3730aa8
--- /dev/null
@@ -0,0 +1,89 @@
+#include "radeon_program_constants.h"
+
+#ifndef RADEON_PROGRAM_UTIL_H
+#define RADEON_PROGRAM_UTIL_H
+
+#include "radeon_opcodes.h"
+
+struct radeon_compiler;
+struct rc_instruction;
+struct rc_pair_instruction;
+struct rc_pair_sub_instruction;
+struct rc_src_register;
+
+unsigned int rc_swizzle_to_writemask(unsigned int swz);
+
+rc_swizzle get_swz(unsigned int swz, rc_swizzle idx);
+
+unsigned int rc_init_swizzle(unsigned int initial_value, unsigned int channels);
+
+unsigned int combine_swizzles4(unsigned int src,
+                              rc_swizzle swz_x, rc_swizzle swz_y,
+                              rc_swizzle swz_z, rc_swizzle swz_w);
+
+unsigned int combine_swizzles(unsigned int src, unsigned int swz);
+
+rc_swizzle rc_mask_to_swizzle(unsigned int mask);
+
+unsigned swizzle_mask(unsigned swizzle, unsigned mask);
+
+unsigned int rc_adjust_channels(
+       unsigned int old_swizzle,
+       unsigned int conversion_swizzle);
+
+void rc_pair_rewrite_writemask(
+       struct rc_pair_sub_instruction * sub,
+       unsigned int conversion_swizzle);
+
+void rc_normal_rewrite_writemask(
+       struct rc_instruction * inst,
+       unsigned int conversion_swizzle);
+
+unsigned int rc_rewrite_swizzle(
+       unsigned int swizzle,
+       unsigned int new_mask);
+
+struct rc_src_register lmul_swizzle(unsigned int swizzle, struct rc_src_register srcreg);
+
+void reset_srcreg(struct rc_src_register* reg);
+
+unsigned int rc_src_reads_dst_mask(
+               rc_register_file src_file,
+               unsigned int src_idx,
+               unsigned int src_swz,
+               rc_register_file dst_file,
+               unsigned int dst_idx,
+               unsigned int dst_mask);
+
+unsigned int rc_source_type_swz(unsigned int swizzle);
+
+unsigned int rc_source_type_mask(unsigned int mask);
+
+unsigned int rc_inst_can_use_presub(
+       struct rc_instruction * inst,
+       rc_presubtract_op presub_op,
+       unsigned int presub_writemask,
+       const struct rc_src_register * replace_reg,
+       const struct rc_src_register * presub_src0,
+       const struct rc_src_register * presub_src1);
+
+int rc_get_max_index(
+       struct radeon_compiler * c,
+       rc_register_file file);
+
+unsigned int rc_pair_remove_src(
+       struct rc_instruction * inst,
+       unsigned int src_type,
+       unsigned int source,
+       unsigned int new_readmask);
+
+rc_opcode rc_get_flow_control_inst(struct rc_instruction * inst);
+
+struct rc_instruction * rc_match_endloop(struct rc_instruction * endloop);
+struct rc_instruction * rc_match_bgnloop(struct rc_instruction * bgnloop);
+
+unsigned int rc_make_conversion_swizzle(
+       unsigned int old_mask,
+       unsigned int new_mask);
+
+#endif /* RADEON_PROGRAM_UTIL_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_dataflow.c b/src/gallium/drivers/r300/compiler/radeon_dataflow.c
new file mode 100644 (file)
index 0000000..a8decac
--- /dev/null
@@ -0,0 +1,892 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ * Copyright 2010 Tom Stellard <tstellar@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_dataflow.h"
+
+#include "radeon_compiler.h"
+#include "radeon_compiler_util.h"
+#include "radeon_program.h"
+
+struct read_write_mask_data {
+       void * UserData;
+       rc_read_write_mask_fn Cb;
+};
+
+static void reads_normal_callback(
+       void * userdata,
+       struct rc_instruction * fullinst,
+       struct rc_src_register * src)
+{
+       struct read_write_mask_data * cb_data = userdata;
+       unsigned int refmask = 0;
+       unsigned int chan;
+       for(chan = 0; chan < 4; chan++) {
+               refmask |= 1 << GET_SWZ(src->Swizzle, chan);
+       }
+       refmask &= RC_MASK_XYZW;
+
+       if (refmask) {
+               cb_data->Cb(cb_data->UserData, fullinst, src->File,
+                                                       src->Index, refmask);
+       }
+
+       if (refmask && src->RelAddr) {
+               cb_data->Cb(cb_data->UserData, fullinst, RC_FILE_ADDRESS, 0,
+                                                               RC_MASK_X);
+       }
+}
+
+static void pair_get_src_refmasks(unsigned int * refmasks,
+                                       struct rc_pair_instruction * inst,
+                                       unsigned int swz, unsigned int src)
+{
+       if (swz >= 4)
+               return;
+
+       if (swz == RC_SWIZZLE_X || swz == RC_SWIZZLE_Y || swz == RC_SWIZZLE_Z) {
+               if(src == RC_PAIR_PRESUB_SRC) {
+                       unsigned int i;
+                       int srcp_regs =
+                               rc_presubtract_src_reg_count(
+                               inst->RGB.Src[src].Index);
+                       for(i = 0; i < srcp_regs; i++) {
+                               refmasks[i] |= 1 << swz;
+                       }
+               }
+               else {
+                       refmasks[src] |= 1 << swz;
+               }
+       }
+
+       if (swz == RC_SWIZZLE_W) {
+               if (src == RC_PAIR_PRESUB_SRC) {
+                       unsigned int i;
+                       int srcp_regs = rc_presubtract_src_reg_count(
+                                       inst->Alpha.Src[src].Index);
+                       for(i = 0; i < srcp_regs; i++) {
+                               refmasks[i] |= 1 << swz;
+                       }
+               }
+               else {
+                       refmasks[src] |= 1 << swz;
+               }
+       }
+}
+
+static void reads_pair(struct rc_instruction * fullinst, rc_read_write_mask_fn cb, void * userdata)
+{
+       struct rc_pair_instruction * inst = &fullinst->U.P;
+       unsigned int refmasks[3] = { 0, 0, 0 };
+
+       unsigned int arg;
+
+       for(arg = 0; arg < 3; ++arg) {
+               unsigned int chan;
+               for(chan = 0; chan < 3; ++chan) {
+                       unsigned int swz_rgb =
+                               GET_SWZ(inst->RGB.Arg[arg].Swizzle, chan);
+                       unsigned int swz_alpha =
+                               GET_SWZ(inst->Alpha.Arg[arg].Swizzle, chan);
+                       pair_get_src_refmasks(refmasks, inst, swz_rgb,
+                                               inst->RGB.Arg[arg].Source);
+                       pair_get_src_refmasks(refmasks, inst, swz_alpha,
+                                               inst->Alpha.Arg[arg].Source);
+               }
+       }
+
+       for(unsigned int src = 0; src < 3; ++src) {
+               if (inst->RGB.Src[src].Used && (refmasks[src] & RC_MASK_XYZ))
+                       cb(userdata, fullinst, inst->RGB.Src[src].File, inst->RGB.Src[src].Index,
+                          refmasks[src] & RC_MASK_XYZ);
+
+               if (inst->Alpha.Src[src].Used && (refmasks[src] & RC_MASK_W))
+                       cb(userdata, fullinst, inst->Alpha.Src[src].File, inst->Alpha.Src[src].Index, RC_MASK_W);
+       }
+}
+
+static void pair_sub_for_all_args(
+       struct rc_instruction * fullinst,
+       struct rc_pair_sub_instruction * sub,
+       rc_pair_read_arg_fn cb,
+       void * userdata)
+{
+       int i;
+       const struct rc_opcode_info * info = rc_get_opcode_info(sub->Opcode);
+
+       for(i = 0; i < info->NumSrcRegs; i++) {
+               unsigned int src_type;
+
+               src_type = rc_source_type_swz(sub->Arg[i].Swizzle);
+
+               if (src_type == RC_SOURCE_NONE)
+                       continue;
+
+               if (sub->Arg[i].Source == RC_PAIR_PRESUB_SRC) {
+                       unsigned int presub_type;
+                       unsigned int presub_src_count;
+                       struct rc_pair_instruction_source * src_array;
+                       unsigned int j;
+
+                       if (src_type & RC_SOURCE_RGB) {
+                               presub_type = fullinst->
+                                       U.P.RGB.Src[RC_PAIR_PRESUB_SRC].Index;
+                               src_array = fullinst->U.P.RGB.Src;
+                       } else {
+                               presub_type = fullinst->
+                                       U.P.Alpha.Src[RC_PAIR_PRESUB_SRC].Index;
+                               src_array = fullinst->U.P.Alpha.Src;
+                       }
+                       presub_src_count
+                               = rc_presubtract_src_reg_count(presub_type);
+                       for(j = 0; j < presub_src_count; j++) {
+                               cb(userdata, fullinst, &sub->Arg[i],
+                                                               &src_array[j]);
+                       }
+               } else {
+                       struct rc_pair_instruction_source * src =
+                               rc_pair_get_src(&fullinst->U.P, &sub->Arg[i]);
+                       if (src) {
+                               cb(userdata, fullinst, &sub->Arg[i], src);
+                       }
+               }
+       }
+}
+
+/* This function calls the callback function (cb) for each source used by
+ * the instruction.
+ * */
+void rc_for_all_reads_src(
+       struct rc_instruction * inst,
+       rc_read_src_fn cb,
+       void * userdata)
+{
+       const struct rc_opcode_info * opcode =
+                                       rc_get_opcode_info(inst->U.I.Opcode);
+
+       /* This function only works with normal instructions. */
+       if (inst->Type != RC_INSTRUCTION_NORMAL) {
+               assert(0);
+               return;
+       }
+
+       for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
+
+               if (inst->U.I.SrcReg[src].File == RC_FILE_NONE)
+                       continue;
+
+               if (inst->U.I.SrcReg[src].File == RC_FILE_PRESUB) {
+                       unsigned int i;
+                       unsigned int srcp_regs = rc_presubtract_src_reg_count(
+                                               inst->U.I.PreSub.Opcode);
+                       for( i = 0; i < srcp_regs; i++) {
+                               cb(userdata, inst, &inst->U.I.PreSub.SrcReg[i]);
+                       }
+               } else {
+                       cb(userdata, inst, &inst->U.I.SrcReg[src]);
+               }
+       }
+}
+
+/**
+ * This function calls the callback function (cb) for each arg of the RGB and
+ * alpha components.
+ */
+void rc_pair_for_all_reads_arg(
+       struct rc_instruction * inst,
+       rc_pair_read_arg_fn cb,
+       void * userdata)
+{
+       /* This function only works with pair instructions. */
+       if (inst->Type != RC_INSTRUCTION_PAIR) {
+               assert(0);
+               return;
+       }
+
+       pair_sub_for_all_args(inst, &inst->U.P.RGB, cb, userdata);
+       pair_sub_for_all_args(inst, &inst->U.P.Alpha, cb, userdata);
+}
+
+/**
+ * Calls a callback function for all register reads.
+ *
+ * This is conservative, i.e. if the same register is referenced multiple times,
+ * the callback may also be called multiple times.
+ * Also, the writemask of the instruction is not taken into account.
+ */
+void rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata)
+{
+       if (inst->Type == RC_INSTRUCTION_NORMAL) {
+               struct read_write_mask_data cb_data;
+               cb_data.UserData = userdata;
+               cb_data.Cb = cb;
+
+               rc_for_all_reads_src(inst, reads_normal_callback, &cb_data);
+       } else {
+               reads_pair(inst, cb, userdata);
+       }
+}
+
+
+
+static void writes_normal(struct rc_instruction * fullinst, rc_read_write_mask_fn cb, void * userdata)
+{
+       struct rc_sub_instruction * inst = &fullinst->U.I;
+       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Opcode);
+
+       if (opcode->HasDstReg && inst->DstReg.WriteMask)
+               cb(userdata, fullinst, inst->DstReg.File, inst->DstReg.Index, inst->DstReg.WriteMask);
+
+       if (inst->WriteALUResult)
+               cb(userdata, fullinst, RC_FILE_SPECIAL, RC_SPECIAL_ALU_RESULT, RC_MASK_X);
+}
+
+static void writes_pair(struct rc_instruction * fullinst, rc_read_write_mask_fn cb, void * userdata)
+{
+       struct rc_pair_instruction * inst = &fullinst->U.P;
+
+       if (inst->RGB.WriteMask)
+               cb(userdata, fullinst, RC_FILE_TEMPORARY, inst->RGB.DestIndex, inst->RGB.WriteMask);
+
+       if (inst->Alpha.WriteMask)
+               cb(userdata, fullinst, RC_FILE_TEMPORARY, inst->Alpha.DestIndex, RC_MASK_W);
+
+       if (inst->WriteALUResult)
+               cb(userdata, fullinst, RC_FILE_SPECIAL, RC_SPECIAL_ALU_RESULT, RC_MASK_X);
+}
+
+/**
+ * Calls a callback function for all register writes in the instruction,
+ * reporting writemasks to the callback function.
+ *
+ * \warning Does not report output registers for paired instructions!
+ */
+void rc_for_all_writes_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata)
+{
+       if (inst->Type == RC_INSTRUCTION_NORMAL) {
+               writes_normal(inst, cb, userdata);
+       } else {
+               writes_pair(inst, cb, userdata);
+       }
+}
+
+
+struct mask_to_chan_data {
+       void * UserData;
+       rc_read_write_chan_fn Fn;
+};
+
+static void mask_to_chan_cb(void * data, struct rc_instruction * inst,
+               rc_register_file file, unsigned int index, unsigned int mask)
+{
+       struct mask_to_chan_data * d = data;
+       for(unsigned int chan = 0; chan < 4; ++chan) {
+               if (GET_BIT(mask, chan))
+                       d->Fn(d->UserData, inst, file, index, chan);
+       }
+}
+
+/**
+ * Calls a callback function for all sourced register channels.
+ *
+ * This is conservative, i.e. channels may be called multiple times,
+ * and the writemask of the instruction is not taken into account.
+ */
+void rc_for_all_reads_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata)
+{
+       struct mask_to_chan_data d;
+       d.UserData = userdata;
+       d.Fn = cb;
+       rc_for_all_reads_mask(inst, &mask_to_chan_cb, &d);
+}
+
+/**
+ * Calls a callback function for all written register channels.
+ *
+ * \warning Does not report output registers for paired instructions!
+ */
+void rc_for_all_writes_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata)
+{
+       struct mask_to_chan_data d;
+       d.UserData = userdata;
+       d.Fn = cb;
+       rc_for_all_writes_mask(inst, &mask_to_chan_cb, &d);
+}
+
+static void remap_normal_instruction(struct rc_instruction * fullinst,
+               rc_remap_register_fn cb, void * userdata)
+{
+       struct rc_sub_instruction * inst = &fullinst->U.I;
+       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Opcode);
+       unsigned int remapped_presub = 0;
+
+       if (opcode->HasDstReg) {
+               rc_register_file file = inst->DstReg.File;
+               unsigned int index = inst->DstReg.Index;
+
+               cb(userdata, fullinst, &file, &index);
+
+               inst->DstReg.File = file;
+               inst->DstReg.Index = index;
+       }
+
+       for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
+               rc_register_file file = inst->SrcReg[src].File;
+               unsigned int index = inst->SrcReg[src].Index;
+
+               if (file == RC_FILE_PRESUB) {
+                       unsigned int i;
+                       unsigned int srcp_srcs = rc_presubtract_src_reg_count(
+                                               inst->PreSub.Opcode);
+                       /* Make sure we only remap presubtract sources once in
+                        * case more than one source register reads the
+                        * presubtract result. */
+                       if (remapped_presub)
+                               continue;
+
+                       for(i = 0; i < srcp_srcs; i++) {
+                               file = inst->PreSub.SrcReg[i].File;
+                               index = inst->PreSub.SrcReg[i].Index;
+                               cb(userdata, fullinst, &file, &index);
+                               inst->PreSub.SrcReg[i].File = file;
+                               inst->PreSub.SrcReg[i].Index = index;
+                       }
+                       remapped_presub = 1;
+               }
+               else {
+                       cb(userdata, fullinst, &file, &index);
+
+                       inst->SrcReg[src].File = file;
+                       inst->SrcReg[src].Index = index;
+               }
+       }
+}
+
+static void remap_pair_instruction(struct rc_instruction * fullinst,
+               rc_remap_register_fn cb, void * userdata)
+{
+       struct rc_pair_instruction * inst = &fullinst->U.P;
+
+       if (inst->RGB.WriteMask) {
+               rc_register_file file = RC_FILE_TEMPORARY;
+               unsigned int index = inst->RGB.DestIndex;
+
+               cb(userdata, fullinst, &file, &index);
+
+               inst->RGB.DestIndex = index;
+       }
+
+       if (inst->Alpha.WriteMask) {
+               rc_register_file file = RC_FILE_TEMPORARY;
+               unsigned int index = inst->Alpha.DestIndex;
+
+               cb(userdata, fullinst, &file, &index);
+
+               inst->Alpha.DestIndex = index;
+       }
+
+       for(unsigned int src = 0; src < 3; ++src) {
+               if (inst->RGB.Src[src].Used) {
+                       rc_register_file file = inst->RGB.Src[src].File;
+                       unsigned int index = inst->RGB.Src[src].Index;
+
+                       cb(userdata, fullinst, &file, &index);
+
+                       inst->RGB.Src[src].File = file;
+                       inst->RGB.Src[src].Index = index;
+               }
+
+               if (inst->Alpha.Src[src].Used) {
+                       rc_register_file file = inst->Alpha.Src[src].File;
+                       unsigned int index = inst->Alpha.Src[src].Index;
+
+                       cb(userdata, fullinst, &file, &index);
+
+                       inst->Alpha.Src[src].File = file;
+                       inst->Alpha.Src[src].Index = index;
+               }
+       }
+}
+
+
+/**
+ * Remap all register accesses according to the given function.
+ * That is, call the function \p cb for each referenced register (both read and written)
+ * and update the given instruction \p inst accordingly
+ * if it modifies its \ref pfile and \ref pindex contents.
+ */
+void rc_remap_registers(struct rc_instruction * inst, rc_remap_register_fn cb, void * userdata)
+{
+       if (inst->Type == RC_INSTRUCTION_NORMAL)
+               remap_normal_instruction(inst, cb, userdata);
+       else
+               remap_pair_instruction(inst, cb, userdata);
+}
+
+struct branch_write_mask {
+       unsigned int IfWriteMask:4;
+       unsigned int ElseWriteMask:4;
+       unsigned int HasElse:1;
+};
+
+union get_readers_read_cb {
+       rc_read_src_fn I;
+       rc_pair_read_arg_fn P;
+};
+
+struct get_readers_callback_data {
+       struct radeon_compiler * C;
+       struct rc_reader_data * ReaderData;
+       rc_read_src_fn ReadNormalCB;
+       rc_pair_read_arg_fn ReadPairCB;
+       rc_read_write_mask_fn WriteCB;
+       rc_register_file DstFile;
+       unsigned int DstIndex;
+       unsigned int DstMask;
+       unsigned int AliveWriteMask;
+       /*  For convenience, this is indexed starting at 1 */
+       struct branch_write_mask BranchMasks[R500_PFS_MAX_BRANCH_DEPTH_FULL + 1];
+};
+
+static struct rc_reader * add_reader(
+       struct memory_pool * pool,
+       struct rc_reader_data * data,
+       struct rc_instruction * inst,
+       unsigned int mask)
+{
+       struct rc_reader * new;
+       memory_pool_array_reserve(pool, struct rc_reader, data->Readers,
+                               data->ReaderCount, data->ReadersReserved, 1);
+       new = &data->Readers[data->ReaderCount++];
+       new->Inst = inst;
+       new->WriteMask = mask;
+       return new;
+}
+
+static void add_reader_normal(
+       struct memory_pool * pool,
+       struct rc_reader_data * data,
+       struct rc_instruction * inst,
+       unsigned int mask,
+       struct rc_src_register * src)
+{
+       struct rc_reader * new = add_reader(pool, data, inst, mask);
+       new->U.I.Src = src;
+}
+
+
+static void add_reader_pair(
+       struct memory_pool * pool,
+       struct rc_reader_data * data,
+       struct rc_instruction * inst,
+       unsigned int mask,
+       struct rc_pair_instruction_arg * arg,
+       struct rc_pair_instruction_source * src)
+{
+       struct rc_reader * new = add_reader(pool, data, inst, mask);
+       new->U.P.Src = src;
+       new->U.P.Arg = arg;
+}
+
+static unsigned int get_readers_read_callback(
+       struct get_readers_callback_data * cb_data,
+       unsigned int has_rel_addr,
+       rc_register_file file,
+       unsigned int index,
+       unsigned int swizzle)
+{
+       unsigned int shared_mask, read_mask;
+
+       if (has_rel_addr) {
+               cb_data->ReaderData->Abort = 1;
+               return RC_MASK_NONE;
+       }
+
+       shared_mask = rc_src_reads_dst_mask(file, index, swizzle,
+               cb_data->DstFile, cb_data->DstIndex, cb_data->AliveWriteMask);
+
+       if (shared_mask == RC_MASK_NONE)
+               return shared_mask;
+
+       /* If we make it this far, it means that this source reads from the
+        * same register written to by d->ReaderData->Writer. */
+
+       read_mask = rc_swizzle_to_writemask(swizzle);
+       if (cb_data->ReaderData->AbortOnRead & read_mask) {
+               cb_data->ReaderData->Abort = 1;
+               return shared_mask;
+       }
+
+       if (cb_data->ReaderData->LoopDepth > 0) {
+               cb_data->ReaderData->AbortOnWrite |=
+                               (read_mask & cb_data->AliveWriteMask);
+       }
+
+       /* XXX The behavior in this case should be configurable. */
+       if ((read_mask & cb_data->AliveWriteMask) != read_mask) {
+               cb_data->ReaderData->Abort = 1;
+               return shared_mask;
+       }
+
+       return shared_mask;
+}
+
+static void get_readers_pair_read_callback(
+       void * userdata,
+       struct rc_instruction * inst,
+       struct rc_pair_instruction_arg * arg,
+       struct rc_pair_instruction_source * src)
+{
+       unsigned int shared_mask;
+       struct get_readers_callback_data * d = userdata;
+
+       shared_mask = get_readers_read_callback(d,
+                               0 /*Pair Instructions don't use RelAddr*/,
+                               src->File, src->Index, arg->Swizzle);
+
+       if (shared_mask == RC_MASK_NONE)
+               return;
+
+       if (d->ReadPairCB)
+               d->ReadPairCB(d->ReaderData, inst, arg, src);
+
+       if (d->ReaderData->ExitOnAbort && d->ReaderData->Abort)
+               return;
+
+       add_reader_pair(&d->C->Pool, d->ReaderData, inst, shared_mask, arg, src);
+}
+
+/**
+ * This function is used by rc_get_readers_normal() to determine whether inst
+ * is a reader of userdata->ReaderData->Writer
+ */
+static void get_readers_normal_read_callback(
+       void * userdata,
+       struct rc_instruction * inst,
+       struct rc_src_register * src)
+{
+       struct get_readers_callback_data * d = userdata;
+       unsigned int shared_mask;
+
+       shared_mask = get_readers_read_callback(d,
+                       src->RelAddr, src->File, src->Index, src->Swizzle);
+
+       if (shared_mask == RC_MASK_NONE)
+               return;
+       /* The callback function could potentially clear d->ReaderData->Abort,
+        * so we need to call it before we return. */
+       if (d->ReadNormalCB)
+               d->ReadNormalCB(d->ReaderData, inst, src);
+
+       if (d->ReaderData->ExitOnAbort && d->ReaderData->Abort)
+               return;
+
+       add_reader_normal(&d->C->Pool, d->ReaderData, inst, shared_mask, src);
+}
+
+/**
+ * This function is used by rc_get_readers_normal() to determine when
+ * userdata->ReaderData->Writer is dead (i. e. All compontents of its
+ * destination register have been overwritten by other instructions).
+ */
+static void get_readers_write_callback(
+       void *userdata,
+       struct rc_instruction * inst,
+       rc_register_file file,
+       unsigned int index,
+       unsigned int mask)
+{
+       struct get_readers_callback_data * d = userdata;
+
+       if (index == d->DstIndex && file == d->DstFile) {
+               unsigned int shared_mask = mask & d->DstMask;
+               d->ReaderData->AbortOnRead &= ~shared_mask;
+               d->AliveWriteMask &= ~shared_mask;
+               if (d->ReaderData->AbortOnWrite & shared_mask) {
+                       d->ReaderData->Abort = 1;
+               }
+       }
+
+       if(d->WriteCB)
+               d->WriteCB(d->ReaderData, inst, file, index, mask);
+}
+
+static void push_branch_mask(
+       struct get_readers_callback_data * d,
+       unsigned int * branch_depth)
+{
+       (*branch_depth)++;
+       if (*branch_depth > R500_PFS_MAX_BRANCH_DEPTH_FULL) {
+               d->ReaderData->Abort = 1;
+               return;
+       }
+       d->BranchMasks[*branch_depth].IfWriteMask =
+                                       d->AliveWriteMask;
+}
+
+static void pop_branch_mask(
+       struct get_readers_callback_data * d,
+       unsigned int * branch_depth)
+{
+       struct branch_write_mask * masks = &d->BranchMasks[*branch_depth];
+
+       if (masks->HasElse) {
+               /* Abort on read for components that were written in the IF
+                * block. */
+               d->ReaderData->AbortOnRead |=
+                               masks->IfWriteMask & ~masks->ElseWriteMask;
+               /* Abort on read for components that were written in the ELSE
+                * block. */
+               d->ReaderData->AbortOnRead |=
+                               masks->ElseWriteMask & ~d->AliveWriteMask;
+
+               d->AliveWriteMask = masks->IfWriteMask
+                       ^ ((masks->IfWriteMask ^ masks->ElseWriteMask)
+                       & (masks->IfWriteMask ^ d->AliveWriteMask));
+       } else {
+               d->ReaderData->AbortOnRead |=
+                               masks->IfWriteMask & ~d->AliveWriteMask;
+               d->AliveWriteMask = masks->IfWriteMask;
+
+       }
+       memset(masks, 0, sizeof(struct branch_write_mask));
+       (*branch_depth)--;
+}
+
+static void get_readers_for_single_write(
+       void * userdata,
+       struct rc_instruction * writer,
+       rc_register_file dst_file,
+       unsigned int dst_index,
+       unsigned int dst_mask)
+{
+       struct rc_instruction * tmp;
+       unsigned int branch_depth = 0;
+       struct rc_instruction * endloop = NULL;
+       unsigned int abort_on_read_at_endloop = 0;
+       struct get_readers_callback_data * d = userdata;
+
+       d->ReaderData->Writer = writer;
+       d->ReaderData->AbortOnRead = 0;
+       d->ReaderData->AbortOnWrite = 0;
+       d->ReaderData->LoopDepth = 0;
+       d->ReaderData->InElse = 0;
+       d->DstFile = dst_file;
+       d->DstIndex = dst_index;
+       d->DstMask = dst_mask;
+       d->AliveWriteMask = dst_mask;
+       memset(d->BranchMasks, 0, sizeof(d->BranchMasks));
+
+       if (!dst_mask)
+               return;
+
+       for(tmp = writer->Next; tmp != &d->C->Program.Instructions;
+                                                       tmp = tmp->Next){
+               rc_opcode opcode = rc_get_flow_control_inst(tmp);
+               switch(opcode) {
+               case RC_OPCODE_BGNLOOP:
+                       d->ReaderData->LoopDepth++;
+                       push_branch_mask(d, &branch_depth);
+                       break;
+               case RC_OPCODE_ENDLOOP:
+                       if (d->ReaderData->LoopDepth > 0) {
+                               d->ReaderData->LoopDepth--;
+                               if (d->ReaderData->LoopDepth == 0) {
+                                       d->ReaderData->AbortOnWrite = 0;
+                               }
+                               pop_branch_mask(d, &branch_depth);
+                       } else {
+                               /* Here we have reached an ENDLOOP without
+                                * seeing its BGNLOOP.  These means that
+                                * the writer was written inside of a loop,
+                                * so it could have readers that are above it
+                                * (i.e. they have a lower IP).  To find these
+                                * readers we jump to the BGNLOOP instruction
+                                * and check each instruction until we get
+                                * back to the writer.
+                                */
+                               endloop = tmp;
+                               tmp = rc_match_endloop(tmp);
+                               if (!tmp) {
+                                       rc_error(d->C, "Failed to match endloop.\n");
+                                       d->ReaderData->Abort = 1;
+                                       return;
+                               }
+                               abort_on_read_at_endloop = d->ReaderData->AbortOnRead;
+                               d->ReaderData->AbortOnRead |= d->AliveWriteMask;
+                               continue;
+                       }
+                       break;
+               case RC_OPCODE_IF:
+                       push_branch_mask(d, &branch_depth);
+                       break;
+               case RC_OPCODE_ELSE:
+                       if (branch_depth == 0) {
+                               d->ReaderData->InElse = 1;
+                       } else {
+                               unsigned int temp_mask = d->AliveWriteMask;
+                               d->AliveWriteMask =
+                                       d->BranchMasks[branch_depth].IfWriteMask;
+                               d->BranchMasks[branch_depth].ElseWriteMask =
+                                                               temp_mask;
+                               d->BranchMasks[branch_depth].HasElse = 1;
+                       }
+                       break;
+               case RC_OPCODE_ENDIF:
+                       if (branch_depth == 0) {
+                               d->ReaderData->AbortOnRead = d->AliveWriteMask;
+                               d->ReaderData->InElse = 0;
+                       }
+                       else {
+                               pop_branch_mask(d, &branch_depth);
+                       }
+                       break;
+               default:
+                       break;
+               }
+
+               if (d->ReaderData->InElse)
+                       continue;
+
+               if (tmp->Type == RC_INSTRUCTION_NORMAL) {
+                       rc_for_all_reads_src(tmp,
+                               get_readers_normal_read_callback, d);
+               } else {
+                       rc_pair_for_all_reads_arg(tmp,
+                               get_readers_pair_read_callback, d);
+               }
+
+               /* This can happen when we jump from an ENDLOOP to BGNLOOP */
+               if (tmp == writer) {
+                       tmp = endloop;
+                       endloop = NULL;
+                       d->ReaderData->AbortOnRead = abort_on_read_at_endloop;
+                       continue;
+               }
+               rc_for_all_writes_mask(tmp, get_readers_write_callback, d);
+
+               if (d->ReaderData->ExitOnAbort && d->ReaderData->Abort)
+                       return;
+
+               if (branch_depth == 0 && !d->AliveWriteMask)
+                       return;
+       }
+}
+
+static void init_get_readers_callback_data(
+       struct get_readers_callback_data * d,
+       struct rc_reader_data * reader_data,
+       struct radeon_compiler * c,
+       rc_read_src_fn read_normal_cb,
+       rc_pair_read_arg_fn read_pair_cb,
+       rc_read_write_mask_fn write_cb)
+{
+       reader_data->Abort = 0;
+       reader_data->ReaderCount = 0;
+       reader_data->ReadersReserved = 0;
+       reader_data->Readers = NULL;
+
+       d->C = c;
+       d->ReaderData = reader_data;
+       d->ReadNormalCB = read_normal_cb;
+       d->ReadPairCB = read_pair_cb;
+       d->WriteCB = write_cb;
+}
+
+/**
+ * This function will create a list of readers via the rc_reader_data struct.
+ * This function will abort (set the flag data->Abort) and return if it
+ * encounters an instruction that reads from @param writer and also a different
+ * instruction.  Here are some examples:
+ *
+ * writer = instruction 0;
+ * 0 MOV TEMP[0].xy, TEMP[1].xy
+ * 1 MOV TEMP[0].zw, TEMP[2].xy
+ * 2 MOV TEMP[3], TEMP[0]
+ * The Abort flag will be set on instruction 2, because it reads values written
+ * by instructions 0 and 1.
+ *
+ * writer = instruction 1;
+ * 0 IF TEMP[0].x
+ * 1 MOV TEMP[1], TEMP[2]
+ * 2 ELSE
+ * 3 MOV TEMP[1], TEMP[2]
+ * 4 ENDIF
+ * 5 MOV TEMP[3], TEMP[1]
+ * The Abort flag will be set on instruction 5, because it could read from the
+ * value written by either instruction 1 or 3, depending on the jump decision
+ * made at instruction 0.
+ *
+ * writer = instruction 0;
+ * 0 MOV TEMP[0], TEMP[1]
+ * 2 BGNLOOP
+ * 3 ADD TEMP[0], TEMP[0], none.1
+ * 4 ENDLOOP
+ * The Abort flag will be set on instruction 3, because in the first iteration
+ * of the loop it reads the value written by instruction 0 and in all other
+ * iterations it reads the value written by instruction 3.
+ *
+ * @param read_cb This function will be called for for every instruction that
+ * has been determined to be a reader of writer.
+ * @param write_cb This function will be called for every instruction after
+ * writer.
+ */
+void rc_get_readers(
+       struct radeon_compiler * c,
+       struct rc_instruction * writer,
+       struct rc_reader_data * data,
+       rc_read_src_fn read_normal_cb,
+       rc_pair_read_arg_fn read_pair_cb,
+       rc_read_write_mask_fn write_cb)
+{
+       struct get_readers_callback_data d;
+
+       init_get_readers_callback_data(&d, data, c, read_normal_cb,
+                                               read_pair_cb, write_cb);
+
+       rc_for_all_writes_mask(writer, get_readers_for_single_write, &d);
+}
+
+void rc_get_readers_sub(
+       struct radeon_compiler * c,
+       struct rc_instruction * writer,
+       struct rc_pair_sub_instruction * sub_writer,
+       struct rc_reader_data * data,
+       rc_read_src_fn read_normal_cb,
+       rc_pair_read_arg_fn read_pair_cb,
+       rc_read_write_mask_fn write_cb)
+{
+       struct get_readers_callback_data d;
+
+       init_get_readers_callback_data(&d, data, c, read_normal_cb,
+                                               read_pair_cb, write_cb);
+
+       if (sub_writer->WriteMask) {
+               get_readers_for_single_write(&d, writer, RC_FILE_TEMPORARY,
+                       sub_writer->DestIndex, sub_writer->WriteMask);
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_dataflow.h b/src/gallium/drivers/r300/compiler/radeon_dataflow.h
new file mode 100644 (file)
index 0000000..d8a6272
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ * Copyright 2010 Tom Stellard <tstellar@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 RADEON_DATAFLOW_H
+#define RADEON_DATAFLOW_H
+
+#include "radeon_program_constants.h"
+
+struct radeon_compiler;
+struct rc_instruction;
+struct rc_swizzle_caps;
+struct rc_src_register;
+struct rc_pair_instruction_arg;
+struct rc_pair_instruction_source;
+struct rc_pair_sub_instruction;
+struct rc_compiler;
+
+
+/**
+ * Help analyze and modify the register accesses of instructions.
+ */
+/*@{*/
+typedef void (*rc_read_write_chan_fn)(void * userdata, struct rc_instruction * inst,
+                       rc_register_file file, unsigned int index, unsigned int chan);
+void rc_for_all_reads_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata);
+void rc_for_all_writes_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata);
+
+typedef void (*rc_read_write_mask_fn)(void * userdata, struct rc_instruction * inst,
+                       rc_register_file file, unsigned int index, unsigned int mask);
+void rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata);
+void rc_for_all_writes_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata);
+
+typedef void (*rc_read_src_fn)(void * userdata, struct rc_instruction * inst,
+                       struct rc_src_register * src);
+void rc_for_all_reads_src(struct rc_instruction * inst, rc_read_src_fn cb,
+                       void * userdata);
+
+typedef void (*rc_pair_read_arg_fn)(void * userdata,
+       struct rc_instruction * inst, struct rc_pair_instruction_arg * arg,
+       struct rc_pair_instruction_source * src);
+void rc_pair_for_all_reads_arg(struct rc_instruction * inst,
+                                       rc_pair_read_arg_fn cb, void * userdata);
+
+typedef void (*rc_remap_register_fn)(void * userdata, struct rc_instruction * inst,
+                       rc_register_file * pfile, unsigned int * pindex);
+void rc_remap_registers(struct rc_instruction * inst, rc_remap_register_fn cb, void * userdata);
+/*@}*/
+
+struct rc_reader {
+       struct rc_instruction * Inst;
+       unsigned int WriteMask;
+       union {
+               struct {
+                       struct rc_src_register * Src;
+               } I;
+               struct {
+                       struct rc_pair_instruction_arg * Arg;
+                       struct rc_pair_instruction_source * Src;
+               } P;
+       } U;
+};
+
+struct rc_reader_data {
+       unsigned int Abort;
+       unsigned int AbortOnRead;
+       unsigned int AbortOnWrite;
+       unsigned int LoopDepth;
+       unsigned int InElse;
+       struct rc_instruction * Writer;
+
+       unsigned int ReaderCount;
+       unsigned int ReadersReserved;
+       struct rc_reader * Readers;
+
+       /* If this flag is enabled, rc_get_readers will exit as soon possbile
+        * after the Abort flag is set.*/
+       unsigned int ExitOnAbort;
+       void * CbData;
+};
+
+void rc_get_readers(
+       struct radeon_compiler * c,
+       struct rc_instruction * writer,
+       struct rc_reader_data * data,
+       rc_read_src_fn read_normal_cb,
+       rc_pair_read_arg_fn read_pair_cb,
+       rc_read_write_mask_fn write_cb);
+
+void rc_get_readers_sub(
+       struct radeon_compiler * c,
+       struct rc_instruction * writer,
+       struct rc_pair_sub_instruction * sub_writer,
+       struct rc_reader_data * data,
+       rc_read_src_fn read_normal_cb,
+       rc_pair_read_arg_fn read_pair_cb,
+       rc_read_write_mask_fn write_cb);
+/**
+ * Compiler passes based on dataflow analysis.
+ */
+/*@{*/
+typedef void (*rc_dataflow_mark_outputs_fn)(void * userdata, void * data,
+                       void (*mark_fn)(void * data, unsigned int index, unsigned int mask));
+void rc_dataflow_deadcode(struct radeon_compiler * c, void *user);
+void rc_dataflow_swizzles(struct radeon_compiler * c, void *user);
+/*@}*/
+
+void rc_optimize(struct radeon_compiler * c, void *user);
+
+#endif /* RADEON_DATAFLOW_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_dataflow_deadcode.c b/src/gallium/drivers/r300/compiler/radeon_dataflow_deadcode.c
new file mode 100644 (file)
index 0000000..678e147
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_dataflow.h"
+
+#include "radeon_compiler.h"
+
+
+struct updatemask_state {
+       unsigned char Output[RC_REGISTER_MAX_INDEX];
+       unsigned char Temporary[RC_REGISTER_MAX_INDEX];
+       unsigned char Address;
+       unsigned char Special[RC_NUM_SPECIAL_REGISTERS];
+};
+
+struct instruction_state {
+       unsigned char WriteMask:4;
+       unsigned char WriteALUResult:1;
+       unsigned char SrcReg[3];
+};
+
+struct loopinfo {
+       struct updatemask_state * Breaks;
+       unsigned int BreakCount;
+       unsigned int BreaksReserved;
+};
+
+struct branchinfo {
+       unsigned int HaveElse:1;
+
+       struct updatemask_state StoreEndif;
+       struct updatemask_state StoreElse;
+};
+
+struct deadcode_state {
+       struct radeon_compiler * C;
+       struct instruction_state * Instructions;
+
+       struct updatemask_state R;
+
+       struct branchinfo * BranchStack;
+       unsigned int BranchStackSize;
+       unsigned int BranchStackReserved;
+
+       struct loopinfo * LoopStack;
+       unsigned int LoopStackSize;
+       unsigned int LoopStackReserved;
+};
+
+
+static void or_updatemasks(
+       struct updatemask_state * dst,
+       struct updatemask_state * a,
+       struct updatemask_state * b)
+{
+       for(unsigned int i = 0; i < RC_REGISTER_MAX_INDEX; ++i) {
+               dst->Output[i] = a->Output[i] | b->Output[i];
+               dst->Temporary[i] = a->Temporary[i] | b->Temporary[i];
+       }
+
+       for(unsigned int i = 0; i < RC_NUM_SPECIAL_REGISTERS; ++i)
+               dst->Special[i] = a->Special[i] | b->Special[i];
+
+       dst->Address = a->Address | b->Address;
+}
+
+static void push_break(struct deadcode_state *s)
+{
+       struct loopinfo * loop = &s->LoopStack[s->LoopStackSize - 1];
+       memory_pool_array_reserve(&s->C->Pool, struct updatemask_state,
+               loop->Breaks, loop->BreakCount, loop->BreaksReserved, 1);
+
+       memcpy(&loop->Breaks[loop->BreakCount++], &s->R, sizeof(s->R));
+}
+
+static void push_loop(struct deadcode_state * s)
+{
+       memory_pool_array_reserve(&s->C->Pool, struct loopinfo, s->LoopStack,
+                       s->LoopStackSize, s->LoopStackReserved, 1);
+       memset(&s->LoopStack[s->LoopStackSize++], 0, sizeof(struct loopinfo));
+}
+
+static void push_branch(struct deadcode_state * s)
+{
+       struct branchinfo * branch;
+
+       memory_pool_array_reserve(&s->C->Pool, struct branchinfo, s->BranchStack,
+                       s->BranchStackSize, s->BranchStackReserved, 1);
+
+       branch = &s->BranchStack[s->BranchStackSize++];
+       branch->HaveElse = 0;
+       memcpy(&branch->StoreEndif, &s->R, sizeof(s->R));
+}
+
+static unsigned char * get_used_ptr(struct deadcode_state *s, rc_register_file file, unsigned int index)
+{
+       if (file == RC_FILE_OUTPUT || file == RC_FILE_TEMPORARY) {
+               if (index >= RC_REGISTER_MAX_INDEX) {
+                       rc_error(s->C, "%s: index %i is out of bounds for file %i\n", __FUNCTION__, index, file);
+                       return 0;
+               }
+
+               if (file == RC_FILE_OUTPUT)
+                       return &s->R.Output[index];
+               else
+                       return &s->R.Temporary[index];
+       } else if (file == RC_FILE_ADDRESS) {
+               return &s->R.Address;
+       } else if (file == RC_FILE_SPECIAL) {
+               if (index >= RC_NUM_SPECIAL_REGISTERS) {
+                       rc_error(s->C, "%s: special file index %i out of bounds\n", __FUNCTION__, index);
+                       return 0;
+               }
+
+               return &s->R.Special[index];
+       }
+
+       return 0;
+}
+
+static void mark_used(struct deadcode_state * s, rc_register_file file, unsigned int index, unsigned int mask)
+{
+       unsigned char * pused = get_used_ptr(s, file, index);
+       if (pused)
+               *pused |= mask;
+}
+
+static void update_instruction(struct deadcode_state * s, struct rc_instruction * inst)
+{
+       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+       struct instruction_state * insts = &s->Instructions[inst->IP];
+       unsigned int usedmask = 0;
+       unsigned int srcmasks[3];
+
+       if (opcode->HasDstReg) {
+               unsigned char * pused = get_used_ptr(s, inst->U.I.DstReg.File, inst->U.I.DstReg.Index);
+               if (pused) {
+                       usedmask = *pused & inst->U.I.DstReg.WriteMask;
+                       *pused &= ~usedmask;
+               }
+       }
+
+       insts->WriteMask |= usedmask;
+
+       if (inst->U.I.WriteALUResult) {
+               unsigned char * pused = get_used_ptr(s, RC_FILE_SPECIAL, RC_SPECIAL_ALU_RESULT);
+               if (pused && *pused) {
+                       if (inst->U.I.WriteALUResult == RC_ALURESULT_X)
+                               usedmask |= RC_MASK_X;
+                       else if (inst->U.I.WriteALUResult == RC_ALURESULT_W)
+                               usedmask |= RC_MASK_W;
+
+                       *pused = 0;
+                       insts->WriteALUResult = 1;
+               }
+       }
+
+       rc_compute_sources_for_writemask(inst, usedmask, srcmasks);
+
+       for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
+               unsigned int refmask = 0;
+               unsigned int newsrcmask = srcmasks[src] & ~insts->SrcReg[src];
+               insts->SrcReg[src] |= newsrcmask;
+
+               for(unsigned int chan = 0; chan < 4; ++chan) {
+                       if (GET_BIT(newsrcmask, chan))
+                               refmask |= 1 << GET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan);
+               }
+
+               /* get rid of spurious bits from ZERO, ONE, etc. swizzles */
+               refmask &= RC_MASK_XYZW;
+
+               if (!refmask)
+                       continue;
+
+               mark_used(s, inst->U.I.SrcReg[src].File, inst->U.I.SrcReg[src].Index, refmask);
+
+               if (inst->U.I.SrcReg[src].RelAddr)
+                       mark_used(s, RC_FILE_ADDRESS, 0, RC_MASK_X);
+       }
+}
+
+static void mark_output_use(void * data, unsigned int index, unsigned int mask)
+{
+       struct deadcode_state * s = data;
+
+       mark_used(s, RC_FILE_OUTPUT, index, mask);
+}
+
+void rc_dataflow_deadcode(struct radeon_compiler * c, void *user)
+{
+       struct deadcode_state s;
+       unsigned int nr_instructions;
+       rc_dataflow_mark_outputs_fn dce = (rc_dataflow_mark_outputs_fn)user;
+       unsigned int ip;
+
+       memset(&s, 0, sizeof(s));
+       s.C = c;
+
+       nr_instructions = rc_recompute_ips(c);
+       s.Instructions = memory_pool_malloc(&c->Pool, sizeof(struct instruction_state)*nr_instructions);
+       memset(s.Instructions, 0, sizeof(struct instruction_state)*nr_instructions);
+
+       dce(c, &s, &mark_output_use);
+
+       for(struct rc_instruction * inst = c->Program.Instructions.Prev;
+           inst != &c->Program.Instructions;
+           inst = inst->Prev) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+               switch(opcode->Opcode){
+               /* Mark all sources in the loop body as used before doing
+                * normal deadcode analysis.  This is probably not optimal.
+                */
+               case RC_OPCODE_ENDLOOP:
+               {
+                       int endloops = 1;
+                       struct rc_instruction *ptr;
+                       for(ptr = inst->Prev; endloops > 0; ptr = ptr->Prev){
+                               opcode = rc_get_opcode_info(ptr->U.I.Opcode);
+                               if(ptr->U.I.Opcode == RC_OPCODE_BGNLOOP){
+                                       endloops--;
+                                       continue;
+                               }
+                               if(ptr->U.I.Opcode == RC_OPCODE_ENDLOOP){
+                                       endloops++;
+                                       continue;
+                               }
+                               if(opcode->HasDstReg){
+                                       int src = 0;
+                                       unsigned int srcmasks[3];
+                                       rc_compute_sources_for_writemask(ptr,
+                                               ptr->U.I.DstReg.WriteMask, srcmasks);
+                                       for(src=0; src < opcode->NumSrcRegs; src++){
+                                               mark_used(&s,
+                                                       ptr->U.I.SrcReg[src].File,
+                                                       ptr->U.I.SrcReg[src].Index,
+                                                       srcmasks[src]);
+                                       }
+                               }
+                       }
+                       push_loop(&s);
+                       break;
+               }
+               case RC_OPCODE_BRK:
+                       push_break(&s);
+                       break;
+               case RC_OPCODE_BGNLOOP:
+               {
+                       unsigned int i;
+                       struct loopinfo * loop = &s.LoopStack[s.LoopStackSize-1];
+                       for(i = 0; i < loop->BreakCount; i++) {
+                               or_updatemasks(&s.R, &s.R, &loop->Breaks[i]);
+                       }
+                       break;
+               }
+               case RC_OPCODE_CONT:
+                       break;
+               case RC_OPCODE_ENDIF:
+                       push_branch(&s);
+                       break;
+               default:
+                       if (opcode->IsFlowControl && s.BranchStackSize) {
+                               struct branchinfo * branch = &s.BranchStack[s.BranchStackSize-1];
+                               if (opcode->Opcode == RC_OPCODE_IF) {
+                                       or_updatemasks(&s.R,
+                                                       &s.R,
+                                                       branch->HaveElse ? &branch->StoreElse : &branch->StoreEndif);
+
+                                       s.BranchStackSize--;
+                               } else if (opcode->Opcode == RC_OPCODE_ELSE) {
+                                       if (branch->HaveElse) {
+                                               rc_error(c, "%s: Multiple ELSE for one IF/ENDIF\n", __FUNCTION__);
+                                       } else {
+                                               memcpy(&branch->StoreElse, &s.R, sizeof(s.R));
+                                               memcpy(&s.R, &branch->StoreEndif, sizeof(s.R));
+                                               branch->HaveElse = 1;
+                                       }
+                               } else {
+                                       rc_error(c, "%s: Unhandled control flow instruction %s\n", __FUNCTION__, opcode->Name);
+                               }
+                       }
+               }
+
+               update_instruction(&s, inst);
+       }
+
+       ip = 0;
+       for(struct rc_instruction * inst = c->Program.Instructions.Next;
+           inst != &c->Program.Instructions;
+           inst = inst->Next, ++ip) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+               int dead = 1;
+               unsigned int srcmasks[3];
+               unsigned int usemask;
+
+               if (!opcode->HasDstReg) {
+                       dead = 0;
+               } else {
+                       inst->U.I.DstReg.WriteMask = s.Instructions[ip].WriteMask;
+                       if (s.Instructions[ip].WriteMask)
+                               dead = 0;
+
+                       if (s.Instructions[ip].WriteALUResult)
+                               dead = 0;
+                       else
+                               inst->U.I.WriteALUResult = RC_ALURESULT_NONE;
+               }
+
+               if (dead) {
+                       struct rc_instruction * todelete = inst;
+                       inst = inst->Prev;
+                       rc_remove_instruction(todelete);
+                       continue;
+               }
+
+               usemask = s.Instructions[ip].WriteMask;
+
+               if (inst->U.I.WriteALUResult == RC_ALURESULT_X)
+                       usemask |= RC_MASK_X;
+               else if (inst->U.I.WriteALUResult == RC_ALURESULT_W)
+                       usemask |= RC_MASK_W;
+
+               rc_compute_sources_for_writemask(inst, usemask, srcmasks);
+
+               for(unsigned int src = 0; src < 3; ++src) {
+                       for(unsigned int chan = 0; chan < 4; ++chan) {
+                               if (!GET_BIT(srcmasks[src], chan))
+                                       SET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan, RC_SWIZZLE_UNUSED);
+                       }
+               }
+       }
+
+       rc_calculate_inputs_outputs(c);
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c b/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c
new file mode 100644 (file)
index 0000000..133a9f7
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_dataflow.h"
+
+#include "radeon_compiler.h"
+#include "radeon_swizzle.h"
+
+
+static void rewrite_source(struct radeon_compiler * c,
+               struct rc_instruction * inst, unsigned src)
+{
+       struct rc_swizzle_split split;
+       unsigned int tempreg = rc_find_free_temporary(c);
+       unsigned int usemask;
+
+       usemask = 0;
+       for(unsigned int chan = 0; chan < 4; ++chan) {
+               if (GET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan) != RC_SWIZZLE_UNUSED)
+                       usemask |= 1 << chan;
+       }
+
+       c->SwizzleCaps->Split(inst->U.I.SrcReg[src], usemask, &split);
+
+       for(unsigned int phase = 0; phase < split.NumPhases; ++phase) {
+               struct rc_instruction * mov = rc_insert_new_instruction(c, inst->Prev);
+               unsigned int phase_refmask;
+               unsigned int masked_negate;
+
+               mov->U.I.Opcode = RC_OPCODE_MOV;
+               mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               mov->U.I.DstReg.Index = tempreg;
+               mov->U.I.DstReg.WriteMask = split.Phase[phase];
+               mov->U.I.SrcReg[0] = inst->U.I.SrcReg[src];
+               mov->U.I.PreSub = inst->U.I.PreSub;
+
+               phase_refmask = 0;
+               for(unsigned int chan = 0; chan < 4; ++chan) {
+                       if (!GET_BIT(split.Phase[phase], chan))
+                               SET_SWZ(mov->U.I.SrcReg[0].Swizzle, chan, RC_SWIZZLE_UNUSED);
+                       else
+                               phase_refmask |= 1 << GET_SWZ(mov->U.I.SrcReg[0].Swizzle, chan);
+               }
+
+               phase_refmask &= RC_MASK_XYZW;
+
+               masked_negate = split.Phase[phase] & mov->U.I.SrcReg[0].Negate;
+               if (masked_negate == 0)
+                       mov->U.I.SrcReg[0].Negate = 0;
+               else if (masked_negate == split.Phase[phase])
+                       mov->U.I.SrcReg[0].Negate = RC_MASK_XYZW;
+
+       }
+
+       inst->U.I.SrcReg[src].File = RC_FILE_TEMPORARY;
+       inst->U.I.SrcReg[src].Index = tempreg;
+       inst->U.I.SrcReg[src].Swizzle = 0;
+       inst->U.I.SrcReg[src].Negate = RC_MASK_NONE;
+       inst->U.I.SrcReg[src].Abs = 0;
+       for(unsigned int chan = 0; chan < 4; ++chan) {
+               SET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan,
+                               GET_BIT(usemask, chan) ? chan : RC_SWIZZLE_UNUSED);
+       }
+}
+
+void rc_dataflow_swizzles(struct radeon_compiler * c, void *user)
+{
+       struct rc_instruction * inst;
+
+       for(inst = c->Program.Instructions.Next; inst != &c->Program.Instructions; inst = inst->Next) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+               unsigned int src;
+
+               for(src = 0; src < opcode->NumSrcRegs; ++src) {
+                       if (!c->SwizzleCaps->IsNative(inst->U.I.Opcode, inst->U.I.SrcReg[src]))
+                               rewrite_source(c, inst, src);
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_emulate_branches.c b/src/gallium/drivers/r300/compiler/radeon_emulate_branches.c
new file mode 100644 (file)
index 0000000..7bede34
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 "radeon_emulate_branches.h"
+
+#include <stdio.h>
+
+#include "radeon_compiler.h"
+#include "radeon_dataflow.h"
+
+#define VERBOSE 0
+
+#define DBG(...) do { if (VERBOSE) fprintf(stderr, __VA_ARGS__); } while(0)
+
+
+struct proxy_info {
+       unsigned int Proxied:1;
+       unsigned int Index:RC_REGISTER_INDEX_BITS;
+};
+
+struct register_proxies {
+       struct proxy_info Temporary[RC_REGISTER_MAX_INDEX];
+};
+
+struct branch_info {
+       struct rc_instruction * If;
+       struct rc_instruction * Else;
+};
+
+struct emulate_branch_state {
+       struct radeon_compiler * C;
+
+       struct branch_info * Branches;
+       unsigned int BranchCount;
+       unsigned int BranchReserved;
+};
+
+
+static void handle_if(struct emulate_branch_state * s, struct rc_instruction * inst)
+{
+       struct branch_info * branch;
+       struct rc_instruction * inst_mov;
+
+       memory_pool_array_reserve(&s->C->Pool, struct branch_info,
+                       s->Branches, s->BranchCount, s->BranchReserved, 1);
+
+       DBG("%s\n", __FUNCTION__);
+
+       branch = &s->Branches[s->BranchCount++];
+       memset(branch, 0, sizeof(struct branch_info));
+       branch->If = inst;
+
+       /* Make a safety copy of the decision register, because we will need
+        * it at ENDIF time and it might be overwritten in both branches. */
+       inst_mov = rc_insert_new_instruction(s->C, inst->Prev);
+       inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+       inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+       inst_mov->U.I.DstReg.Index = rc_find_free_temporary(s->C);
+       inst_mov->U.I.DstReg.WriteMask = RC_MASK_X;
+       inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+       inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+       inst->U.I.SrcReg[0].Index = inst_mov->U.I.DstReg.Index;
+       inst->U.I.SrcReg[0].Swizzle = 0;
+       inst->U.I.SrcReg[0].Abs = 0;
+       inst->U.I.SrcReg[0].Negate = 0;
+}
+
+static void handle_else(struct emulate_branch_state * s, struct rc_instruction * inst)
+{
+       struct branch_info * branch;
+
+       if (!s->BranchCount) {
+               rc_error(s->C, "Encountered ELSE outside of branches");
+               return;
+       }
+
+       DBG("%s\n", __FUNCTION__);
+
+       branch = &s->Branches[s->BranchCount - 1];
+       branch->Else = inst;
+}
+
+
+struct state_and_proxies {
+       struct emulate_branch_state * S;
+       struct register_proxies * Proxies;
+};
+
+static struct proxy_info * get_proxy_info(struct state_and_proxies * sap,
+                       rc_register_file file, unsigned int index)
+{
+       if (file == RC_FILE_TEMPORARY) {
+               return &sap->Proxies->Temporary[index];
+       } else {
+               return 0;
+       }
+}
+
+static void scan_write(void * userdata, struct rc_instruction * inst,
+               rc_register_file file, unsigned int index, unsigned int comp)
+{
+       struct state_and_proxies * sap = userdata;
+       struct proxy_info * proxy = get_proxy_info(sap, file, index);
+
+       if (proxy && !proxy->Proxied) {
+               proxy->Proxied = 1;
+               proxy->Index = rc_find_free_temporary(sap->S->C);
+       }
+}
+
+static void remap_proxy_function(void * userdata, struct rc_instruction * inst,
+               rc_register_file * pfile, unsigned int * pindex)
+{
+       struct state_and_proxies * sap = userdata;
+       struct proxy_info * proxy = get_proxy_info(sap, *pfile, *pindex);
+
+       if (proxy && proxy->Proxied) {
+               *pfile = RC_FILE_TEMPORARY;
+               *pindex = proxy->Index;
+       }
+}
+
+/**
+ * Redirect all writes in the instruction range [begin, end) to proxy
+ * temporary registers.
+ */
+static void allocate_and_insert_proxies(struct emulate_branch_state * s,
+               struct register_proxies * proxies,
+               struct rc_instruction * begin,
+               struct rc_instruction * end)
+{
+       struct state_and_proxies sap;
+
+       sap.S = s;
+       sap.Proxies = proxies;
+
+       for(struct rc_instruction * inst = begin; inst != end; inst = inst->Next) {
+               rc_for_all_writes_mask(inst, scan_write, &sap);
+               rc_remap_registers(inst, remap_proxy_function, &sap);
+       }
+
+       for(unsigned int index = 0; index < RC_REGISTER_MAX_INDEX; ++index) {
+               if (proxies->Temporary[index].Proxied) {
+                       struct rc_instruction * inst_mov = rc_insert_new_instruction(s->C, begin->Prev);
+                       inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+                       inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_mov->U.I.DstReg.Index = proxies->Temporary[index].Index;
+                       inst_mov->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+                       inst_mov->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+                       inst_mov->U.I.SrcReg[0].Index = index;
+               }
+       }
+}
+
+
+static void inject_cmp(struct emulate_branch_state * s,
+               struct rc_instruction * inst_if,
+               struct rc_instruction * inst_endif,
+               rc_register_file file, unsigned int index,
+               struct proxy_info ifproxy,
+               struct proxy_info elseproxy)
+{
+       struct rc_instruction * inst_cmp = rc_insert_new_instruction(s->C, inst_endif);
+       inst_cmp->U.I.Opcode = RC_OPCODE_CMP;
+       inst_cmp->U.I.DstReg.File = file;
+       inst_cmp->U.I.DstReg.Index = index;
+       inst_cmp->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+       inst_cmp->U.I.SrcReg[0] = inst_if->U.I.SrcReg[0];
+       inst_cmp->U.I.SrcReg[0].Abs = 1;
+       inst_cmp->U.I.SrcReg[0].Negate = RC_MASK_XYZW;
+       inst_cmp->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+       inst_cmp->U.I.SrcReg[1].Index = ifproxy.Proxied ? ifproxy.Index : index;
+       inst_cmp->U.I.SrcReg[2].File = RC_FILE_TEMPORARY;
+       inst_cmp->U.I.SrcReg[2].Index = elseproxy.Proxied ? elseproxy.Index : index;
+}
+
+static void handle_endif(struct emulate_branch_state * s, struct rc_instruction * inst)
+{
+       struct branch_info * branch;
+       struct register_proxies IfProxies;
+       struct register_proxies ElseProxies;
+
+       if (!s->BranchCount) {
+               rc_error(s->C, "Encountered ENDIF outside of branches");
+               return;
+       }
+
+       DBG("%s\n", __FUNCTION__);
+
+       branch = &s->Branches[s->BranchCount - 1];
+
+       memset(&IfProxies, 0, sizeof(IfProxies));
+       memset(&ElseProxies, 0, sizeof(ElseProxies));
+
+       allocate_and_insert_proxies(s, &IfProxies, branch->If->Next, branch->Else ? branch->Else : inst);
+
+       if (branch->Else)
+               allocate_and_insert_proxies(s, &ElseProxies, branch->Else->Next, inst);
+
+       /* Insert the CMP instructions at the end. */
+       for(unsigned int index = 0; index < RC_REGISTER_MAX_INDEX; ++index) {
+               if (IfProxies.Temporary[index].Proxied || ElseProxies.Temporary[index].Proxied) {
+                       inject_cmp(s, branch->If, inst, RC_FILE_TEMPORARY, index,
+                                       IfProxies.Temporary[index], ElseProxies.Temporary[index]);
+               }
+       }
+
+       /* Remove all traces of the branch instructions */
+       rc_remove_instruction(branch->If);
+       if (branch->Else)
+               rc_remove_instruction(branch->Else);
+       rc_remove_instruction(inst);
+
+       s->BranchCount--;
+
+       if (VERBOSE) {
+               DBG("Program after ENDIF handling:\n");
+               rc_print_program(&s->C->Program);
+       }
+}
+
+
+struct remap_output_data {
+       unsigned int Output:RC_REGISTER_INDEX_BITS;
+       unsigned int Temporary:RC_REGISTER_INDEX_BITS;
+};
+
+static void remap_output_function(void * userdata, struct rc_instruction * inst,
+               rc_register_file * pfile, unsigned int * pindex)
+{
+       struct remap_output_data * data = userdata;
+
+       if (*pfile == RC_FILE_OUTPUT && *pindex == data->Output) {
+               *pfile = RC_FILE_TEMPORARY;
+               *pindex = data->Temporary;
+       }
+}
+
+
+/**
+ * Output registers cannot be read from and so cannot be dealt with like
+ * temporary registers.
+ *
+ * We do the simplest thing: If an output registers is written within
+ * a branch, then *all* writes to this register are proxied to a
+ * temporary register, and a final MOV is appended to the end of
+ * the program.
+ */
+static void fix_output_writes(struct emulate_branch_state * s, struct rc_instruction * inst)
+{
+       const struct rc_opcode_info * opcode;
+
+       if (!s->BranchCount)
+               return;
+
+       opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+       if (!opcode->HasDstReg)
+               return;
+
+       if (inst->U.I.DstReg.File == RC_FILE_OUTPUT) {
+               struct remap_output_data remap;
+               struct rc_instruction * inst_mov;
+
+               remap.Output = inst->U.I.DstReg.Index;
+               remap.Temporary = rc_find_free_temporary(s->C);
+
+               for(struct rc_instruction * inst = s->C->Program.Instructions.Next;
+                   inst != &s->C->Program.Instructions;
+                   inst = inst->Next) {
+                       rc_remap_registers(inst, &remap_output_function, &remap);
+               }
+
+               inst_mov = rc_insert_new_instruction(s->C, s->C->Program.Instructions.Prev);
+               inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+               inst_mov->U.I.DstReg.File = RC_FILE_OUTPUT;
+               inst_mov->U.I.DstReg.Index = remap.Output;
+               inst_mov->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+               inst_mov->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+               inst_mov->U.I.SrcReg[0].Index = remap.Temporary;
+       }
+}
+
+/**
+ * Remove branch instructions; instead, execute both branches
+ * on different register sets and choose between their results
+ * using CMP instructions in place of the original ENDIF.
+ */
+void rc_emulate_branches(struct radeon_compiler *c, void *user)
+{
+       struct emulate_branch_state s;
+       struct rc_instruction * ptr;
+
+       memset(&s, 0, sizeof(s));
+       s.C = c;
+
+       /* Untypical loop because we may remove the current instruction */
+       ptr = c->Program.Instructions.Next;
+       while(ptr != &c->Program.Instructions) {
+               struct rc_instruction * inst = ptr;
+               ptr = ptr->Next;
+
+               if (inst->Type == RC_INSTRUCTION_NORMAL) {
+                       switch(inst->U.I.Opcode) {
+                       case RC_OPCODE_IF:
+                               handle_if(&s, inst);
+                               break;
+                       case RC_OPCODE_ELSE:
+                               handle_else(&s, inst);
+                               break;
+                       case RC_OPCODE_ENDIF:
+                               handle_endif(&s, inst);
+                               break;
+                       default:
+                               fix_output_writes(&s, inst);
+                               break;
+                       }
+               } else {
+                       rc_error(c, "%s: unhandled instruction type\n", __FUNCTION__);
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_emulate_branches.h b/src/gallium/drivers/r300/compiler/radeon_emulate_branches.h
new file mode 100644 (file)
index 0000000..818ab84
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 RADEON_EMULATE_BRANCHES_H
+#define RADEON_EMULATE_BRANCHES_H
+
+struct radeon_compiler;
+
+void rc_emulate_branches(struct radeon_compiler *c, void *user);
+
+#endif /* RADEON_EMULATE_BRANCHES_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c b/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c
new file mode 100644 (file)
index 0000000..205eecd
--- /dev/null
@@ -0,0 +1,522 @@
+/*
+ * Copyright 2010 Tom Stellard <tstellar@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * \file
+ */
+
+#include "radeon_emulate_loops.h"
+
+#include "radeon_compiler.h"
+#include "radeon_dataflow.h"
+
+#define VERBOSE 0
+
+#define DBG(...) do { if (VERBOSE) fprintf(stderr, __VA_ARGS__); } while(0)
+
+struct const_value {
+       struct radeon_compiler * C;
+       struct rc_src_register * Src;
+       float Value;
+       int HasValue;
+};
+
+struct count_inst {
+       struct radeon_compiler * C;
+       int Index;
+       rc_swizzle Swz;
+       float Amount;
+       int Unknown;
+};
+
+static float get_constant_value(struct radeon_compiler * c,
+                                               struct rc_src_register * src,
+                                               int chan)
+{
+       float base = 1.0f;
+       int swz = GET_SWZ(src->Swizzle, chan);
+       if(swz >= 4 || src->Index >= c->Program.Constants.Count ){
+               rc_error(c, "get_constant_value: Can't find a value.\n");
+               return 0.0f;
+       }
+       if(GET_BIT(src->Negate, chan)){
+               base = -1.0f;
+       }
+       return base *
+               c->Program.Constants.Constants[src->Index].u.Immediate[swz];
+}
+
+static int src_reg_is_immediate(struct rc_src_register * src,
+                                               struct radeon_compiler * c)
+{
+       return src->File == RC_FILE_CONSTANT &&
+       c->Program.Constants.Constants[src->Index].Type==RC_CONSTANT_IMMEDIATE;
+}
+
+static unsigned int loop_max_possible_iterations(struct radeon_compiler *c,
+                       struct loop_info * loop)
+{
+       unsigned int total_i = rc_recompute_ips(c);
+       unsigned int loop_i = (loop->EndLoop->IP - loop->BeginLoop->IP) - 1;
+       /* +1 because the program already has one iteration of the loop. */
+       return 1 + ((c->max_alu_insts - total_i) / loop_i);
+}
+
+static void unroll_loop(struct radeon_compiler * c, struct loop_info * loop,
+                                               unsigned int iterations)
+{
+       unsigned int i;
+       struct rc_instruction * ptr;
+       struct rc_instruction * first = loop->BeginLoop->Next;
+       struct rc_instruction * last = loop->EndLoop->Prev;
+       struct rc_instruction * append_to = last;
+       rc_remove_instruction(loop->BeginLoop);
+       rc_remove_instruction(loop->EndLoop);
+       for( i = 1; i < iterations; i++){
+               for(ptr = first; ptr != last->Next; ptr = ptr->Next){
+                       struct rc_instruction *new = rc_alloc_instruction(c);
+                       memcpy(new, ptr, sizeof(struct rc_instruction));
+                       rc_insert_instruction(append_to, new);
+                       append_to = new;
+               }
+       }
+}
+
+
+static void update_const_value(void * data, struct rc_instruction * inst,
+               rc_register_file file, unsigned int index, unsigned int mask)
+{
+       struct const_value * value = data;
+       if(value->Src->File != file ||
+          value->Src->Index != index ||
+          !(1 << GET_SWZ(value->Src->Swizzle, 0) & mask)){
+               return;
+       }
+       switch(inst->U.I.Opcode){
+       case RC_OPCODE_MOV:
+               if(!src_reg_is_immediate(&inst->U.I.SrcReg[0], value->C)){
+                       return;
+               }
+               value->HasValue = 1;
+               value->Value =
+                       get_constant_value(value->C, &inst->U.I.SrcReg[0], 0);
+               break;
+       }
+}
+
+static void get_incr_amount(void * data, struct rc_instruction * inst,
+               rc_register_file file, unsigned int index, unsigned int mask)
+{
+       struct count_inst * count_inst = data;
+       int amnt_src_index;
+       const struct rc_opcode_info * opcode;
+       float amount;
+
+       if(file != RC_FILE_TEMPORARY ||
+          count_inst->Index != index ||
+          (1 << GET_SWZ(count_inst->Swz,0) != mask)){
+               return;
+       }
+       /* Find the index of the counter register. */
+       opcode = rc_get_opcode_info(inst->U.I.Opcode);
+       if(opcode->NumSrcRegs != 2){
+               count_inst->Unknown = 1;
+               return;
+       }
+       if(inst->U.I.SrcReg[0].File == RC_FILE_TEMPORARY &&
+          inst->U.I.SrcReg[0].Index == count_inst->Index &&
+          inst->U.I.SrcReg[0].Swizzle == count_inst->Swz){
+               amnt_src_index = 1;
+       } else if( inst->U.I.SrcReg[1].File == RC_FILE_TEMPORARY &&
+                  inst->U.I.SrcReg[1].Index == count_inst->Index &&
+                  inst->U.I.SrcReg[1].Swizzle == count_inst->Swz){
+               amnt_src_index = 0;
+       }
+       else{
+               count_inst->Unknown = 1;
+               return;
+       }
+       if(src_reg_is_immediate(&inst->U.I.SrcReg[amnt_src_index],
+                                                       count_inst->C)){
+               amount = get_constant_value(count_inst->C,
+                               &inst->U.I.SrcReg[amnt_src_index], 0);
+       }
+       else{
+               count_inst->Unknown = 1 ;
+               return;
+       }
+       switch(inst->U.I.Opcode){
+       case RC_OPCODE_ADD:
+               count_inst->Amount += amount;
+               break;
+       case RC_OPCODE_SUB:
+               if(amnt_src_index == 0){
+                       count_inst->Unknown = 0;
+                       return;
+               }
+               count_inst->Amount -= amount;
+               break;
+       default:
+               count_inst->Unknown = 1;
+               return;
+       }
+}
+
+/**
+ * If c->max_alu_inst is -1, then all eligible loops will be unrolled regardless
+ * of how many iterations they have.
+ */
+static int try_unroll_loop(struct radeon_compiler * c, struct loop_info * loop)
+{
+       int end_loops;
+       int iterations;
+       struct count_inst count_inst;
+       float limit_value;
+       struct rc_src_register * counter;
+       struct rc_src_register * limit;
+       struct const_value counter_value;
+       struct rc_instruction * inst;
+
+       /* Find the counter and the upper limit */
+
+       if(src_reg_is_immediate(&loop->Cond->U.I.SrcReg[0], c)){
+               limit = &loop->Cond->U.I.SrcReg[0];
+               counter = &loop->Cond->U.I.SrcReg[1];
+       }
+       else if(src_reg_is_immediate(&loop->Cond->U.I.SrcReg[1], c)){
+               limit = &loop->Cond->U.I.SrcReg[1];
+               counter = &loop->Cond->U.I.SrcReg[0];
+       }
+       else{
+               DBG("No constant limit.\n");
+               return 0;
+       }
+
+       /* Find the initial value of the counter */
+       counter_value.Src = counter;
+       counter_value.Value = 0.0f;
+       counter_value.HasValue = 0;
+       counter_value.C = c;
+       for(inst = c->Program.Instructions.Next; inst != loop->BeginLoop;
+                                                       inst = inst->Next){
+               rc_for_all_writes_mask(inst, update_const_value, &counter_value);
+       }
+       if(!counter_value.HasValue){
+               DBG("Initial counter value cannot be determined.\n");
+               return 0;
+       }
+       DBG("Initial counter value is %f\n", counter_value.Value);
+       /* Determine how the counter is modified each loop */
+       count_inst.C = c;
+       count_inst.Index = counter->Index;
+       count_inst.Swz = counter->Swizzle;
+       count_inst.Amount = 0.0f;
+       count_inst.Unknown = 0;
+       end_loops = 1;
+       for(inst = loop->BeginLoop->Next; end_loops > 0; inst = inst->Next){
+               switch(inst->U.I.Opcode){
+               /* XXX In the future we might want to try to unroll nested
+                * loops here.*/
+               case RC_OPCODE_BGNLOOP:
+                       end_loops++;
+                       break;
+               case RC_OPCODE_ENDLOOP:
+                       loop->EndLoop = inst;
+                       end_loops--;
+                       break;
+               case RC_OPCODE_BRK:
+                       /* Don't unroll loops if it has a BRK instruction
+                        * other one used when testing the main conditional
+                        * of the loop. */
+
+                       /* Make sure we haven't entered a nested loops. */
+                       if(inst != loop->Brk && end_loops == 1) {
+                               return 0;
+                       }
+                       break;
+               /* XXX Check if the counter is modified within an if statement.
+                */
+               case RC_OPCODE_IF:
+                       break;
+               default:
+                       rc_for_all_writes_mask(inst, get_incr_amount, &count_inst);
+                       if(count_inst.Unknown){
+                               return 0;
+                       }
+                       break;
+               }
+       }
+       /* Infinite loop */
+       if(count_inst.Amount == 0.0f){
+               return 0;
+       }
+       DBG("Counter is increased by %f each iteration.\n", count_inst.Amount);
+       /* Calculate the number of iterations of this loop.  Keeping this
+        * simple, since we only support increment and decrement loops.
+        */
+       limit_value = get_constant_value(c, limit, 0);
+       DBG("Limit is %f.\n", limit_value);
+       /* The iteration calculations are opposite of what you would expect.
+        * In a normal loop, if the condition is met, then loop continues, but
+        * with our loops, if the condition is met, the is exited. */
+       switch(loop->Cond->U.I.Opcode){
+       case RC_OPCODE_SGE:
+       case RC_OPCODE_SLE:
+               iterations = (int) ceilf((limit_value - counter_value.Value) /
+                                                       count_inst.Amount);
+               break;
+
+       case RC_OPCODE_SGT:
+       case RC_OPCODE_SLT:
+               iterations = (int) floorf((limit_value - counter_value.Value) /
+                                                       count_inst.Amount) + 1;
+               break;
+       default:
+               return 0;
+       }
+
+       if (c->max_alu_insts > 0
+               && iterations > loop_max_possible_iterations(c, loop)) {
+               return 0;
+       }
+
+       DBG("Loop will have %d iterations.\n", iterations);
+
+       /* Prepare loop for unrolling */
+       rc_remove_instruction(loop->Cond);
+       rc_remove_instruction(loop->If);
+       rc_remove_instruction(loop->Brk);
+       rc_remove_instruction(loop->EndIf);
+
+       unroll_loop(c, loop, iterations);
+       loop->EndLoop = NULL;
+       return 1;
+}
+
+/**
+ * @param c
+ * @param loop
+ * @param inst A pointer to a BGNLOOP instruction.
+ * @return 1 if all of the members of loop where set.
+ * @return 0 if there was an error and some members of loop are still NULL.
+ */
+static int build_loop_info(struct radeon_compiler * c, struct loop_info * loop,
+                                               struct rc_instruction * inst)
+{
+       struct rc_instruction * ptr;
+
+       if(inst->U.I.Opcode != RC_OPCODE_BGNLOOP){
+               rc_error(c, "%s: expected BGNLOOP", __FUNCTION__);
+               return 0;
+       }
+
+       memset(loop, 0, sizeof(struct loop_info));
+
+       loop->BeginLoop = inst;
+
+       for(ptr = loop->BeginLoop->Next; !loop->EndLoop; ptr = ptr->Next) {
+
+               if (ptr == &c->Program.Instructions) {
+                       rc_error(c, "%s: BGNLOOP without an ENDLOOOP.\n",
+                                                               __FUNCTION__);
+                       return 0;
+               }
+
+               switch(ptr->U.I.Opcode){
+               case RC_OPCODE_BGNLOOP:
+               {
+                       /* Nested loop, skip ahead to the end. */
+                       unsigned int loop_depth = 1;
+                       for(ptr = ptr->Next; ptr != &c->Program.Instructions;
+                                                       ptr = ptr->Next){
+                               if (ptr->U.I.Opcode == RC_OPCODE_BGNLOOP) {
+                                       loop_depth++;
+                               } else if (ptr->U.I.Opcode == RC_OPCODE_ENDLOOP) {
+                                       if (!--loop_depth) {
+                                               break;
+                                       }
+                               }
+                       }
+                       if (ptr == &c->Program.Instructions) {
+                               rc_error(c, "%s: BGNLOOP without an ENDLOOOP\n",
+                                                               __FUNCTION__);
+                                       return 0;
+                       }
+                       break;
+               }
+               case RC_OPCODE_BRK:
+                       if(ptr->Next->U.I.Opcode != RC_OPCODE_ENDIF
+                                       || ptr->Prev->U.I.Opcode != RC_OPCODE_IF
+                                       || loop->Brk){
+                               continue;
+                       }
+                       loop->Brk = ptr;
+                       loop->If = ptr->Prev;
+                       loop->EndIf = ptr->Next;
+                       switch(loop->If->Prev->U.I.Opcode){
+                       case RC_OPCODE_SLT:
+                       case RC_OPCODE_SGE:
+                       case RC_OPCODE_SGT:
+                       case RC_OPCODE_SLE:
+                       case RC_OPCODE_SEQ:
+                       case RC_OPCODE_SNE:
+                               break;
+                       default:
+                               return 0;
+                       }
+                       loop->Cond = loop->If->Prev;
+                       break;
+
+               case RC_OPCODE_ENDLOOP:
+                       loop->EndLoop = ptr;
+                       break;
+               }
+       }
+
+       if (loop->BeginLoop && loop->Brk && loop->If && loop->EndIf
+                                       && loop->Cond && loop->EndLoop) {
+               return 1;
+       }
+       return 0;
+}
+
+/**
+ * This function prepares a loop to be unrolled by converting it into an if
+ * statement.  Here is an outline of the conversion process:
+ * BGNLOOP;                            -> BGNLOOP;
+ * <Additional conditional code>       -> <Additional conditional code>
+ * SGE/SLT temp[0], temp[1], temp[2];  -> SLT/SGE temp[0], temp[1], temp[2];
+ * IF temp[0];                         -> IF temp[0];
+ * BRK;                                ->
+ * ENDIF;                              -> <Loop Body>
+ * <Loop Body>                         -> ENDIF;
+ * ENDLOOP;                            -> ENDLOOP
+ *
+ * @param inst A pointer to a BGNLOOP instruction.
+ * @return 1 for success, 0 for failure
+ */
+static int transform_loop(struct emulate_loop_state * s,
+                                               struct rc_instruction * inst)
+{
+       struct loop_info * loop;
+
+       memory_pool_array_reserve(&s->C->Pool, struct loop_info,
+                       s->Loops, s->LoopCount, s->LoopReserved, 1);
+
+       loop = &s->Loops[s->LoopCount++];
+
+       if (!build_loop_info(s->C, loop, inst)) {
+               rc_error(s->C, "Failed to build loop info\n");
+               return 0;
+       }
+
+       if(try_unroll_loop(s->C, loop)){
+               return 1;
+       }
+
+       /* Reverse the conditional instruction */
+       switch(loop->Cond->U.I.Opcode){
+       case RC_OPCODE_SGE:
+               loop->Cond->U.I.Opcode = RC_OPCODE_SLT;
+               break;
+       case RC_OPCODE_SLT:
+               loop->Cond->U.I.Opcode = RC_OPCODE_SGE;
+               break;
+       case RC_OPCODE_SLE:
+               loop->Cond->U.I.Opcode = RC_OPCODE_SGT;
+               break;
+       case RC_OPCODE_SGT:
+               loop->Cond->U.I.Opcode = RC_OPCODE_SLE;
+               break;
+       case RC_OPCODE_SEQ:
+               loop->Cond->U.I.Opcode = RC_OPCODE_SNE;
+               break;
+       case RC_OPCODE_SNE:
+               loop->Cond->U.I.Opcode = RC_OPCODE_SEQ;
+               break;
+       default:
+               rc_error(s->C, "loop->Cond is not a conditional.\n");
+               return 0;
+       }
+
+       /* Prepare the loop to be emulated */
+       rc_remove_instruction(loop->Brk);
+       rc_remove_instruction(loop->EndIf);
+       rc_insert_instruction(loop->EndLoop->Prev, loop->EndIf);
+       return 1;
+}
+
+void rc_transform_loops(struct radeon_compiler *c, void *user)
+{
+       struct emulate_loop_state * s = &c->loop_state;
+       struct rc_instruction * ptr;
+
+       memset(s, 0, sizeof(struct emulate_loop_state));
+       s->C = c;
+       for(ptr = s->C->Program.Instructions.Next;
+                       ptr != &s->C->Program.Instructions; ptr = ptr->Next) {
+               if(ptr->Type == RC_INSTRUCTION_NORMAL &&
+                                       ptr->U.I.Opcode == RC_OPCODE_BGNLOOP){
+                       if (!transform_loop(s, ptr))
+                               return;
+               }
+       }
+}
+
+void rc_unroll_loops(struct radeon_compiler *c, void *user)
+{
+       struct rc_instruction * inst;
+       struct loop_info loop;
+
+       for(inst = c->Program.Instructions.Next;
+                       inst != &c->Program.Instructions; inst = inst->Next) {
+
+               if (inst->U.I.Opcode == RC_OPCODE_BGNLOOP) {
+                       if (build_loop_info(c, &loop, inst)) {
+                               try_unroll_loop(c, &loop);
+                       }
+               }
+       }
+}
+
+void rc_emulate_loops(struct radeon_compiler *c, void *user)
+{
+       struct emulate_loop_state * s = &c->loop_state;
+       int i;
+       /* Iterate backwards of the list of loops so that loops that nested
+        * loops are unrolled first.
+        */
+       for( i = s->LoopCount - 1; i >= 0; i-- ){
+               unsigned int iterations;
+
+               if(!s->Loops[i].EndLoop){
+                       continue;
+               }
+               iterations = loop_max_possible_iterations(s->C, &s->Loops[i]);
+               unroll_loop(s->C, &s->Loops[i], iterations);
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_emulate_loops.h b/src/gallium/drivers/r300/compiler/radeon_emulate_loops.h
new file mode 100644 (file)
index 0000000..cd800c0
--- /dev/null
@@ -0,0 +1,32 @@
+
+
+#ifndef RADEON_EMULATE_LOOPS_H
+#define RADEON_EMULATE_LOOPS_H
+
+#define MAX_ITERATIONS 8
+
+struct radeon_compiler;
+
+struct loop_info {
+       struct rc_instruction * BeginLoop;
+       struct rc_instruction * Cond;
+       struct rc_instruction * If;
+       struct rc_instruction * Brk;
+       struct rc_instruction * EndIf;
+       struct rc_instruction * EndLoop;
+};
+
+struct emulate_loop_state {
+       struct radeon_compiler * C;
+       struct loop_info * Loops;
+       unsigned int LoopCount;
+       unsigned int LoopReserved;
+};
+
+void rc_transform_loops(struct radeon_compiler *c, void *user);
+
+void rc_unroll_loops(struct radeon_compiler * c, void *user);
+
+void rc_emulate_loops(struct radeon_compiler * c, void *user);
+
+#endif /* RADEON_EMULATE_LOOPS_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_list.c b/src/gallium/drivers/r300/compiler/radeon_list.c
new file mode 100644 (file)
index 0000000..811c908
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2011 Tom Stellard <tstellar@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_list.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "memory_pool.h"
+
+struct rc_list * rc_list(struct memory_pool * pool, void * item)
+{
+       struct rc_list * new = memory_pool_malloc(pool, sizeof(struct rc_list));
+       new->Item = item;
+       new->Next = NULL;
+       new->Prev = NULL;
+
+       return new;
+}
+
+void rc_list_add(struct rc_list ** list, struct rc_list * new_value)
+{
+       struct rc_list * temp;
+
+       if (*list == NULL) {
+               *list = new_value;
+               return;
+       }
+
+       for (temp = *list; temp->Next; temp = temp->Next);
+
+       temp->Next = new_value;
+       new_value->Prev = temp;
+}
+
+void rc_list_remove(struct rc_list ** list, struct rc_list * rm_value)
+{
+       if (*list == rm_value) {
+               *list = rm_value->Next;
+               return;
+       }
+
+       rm_value->Prev->Next = rm_value->Next;
+       if (rm_value->Next) {
+               rm_value->Next->Prev = rm_value->Prev;
+       }
+}
+
+unsigned int rc_list_count(struct rc_list * list)
+{
+       unsigned int count = 0;
+       while (list) {
+               count++;
+               list = list->Next;
+       }
+       return count;
+}
+
+void rc_list_print(struct rc_list * list)
+{
+       while(list) {
+               fprintf(stderr, "%p->", list->Item);
+               list = list->Next;
+       }
+       fprintf(stderr, "\n");
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_list.h b/src/gallium/drivers/r300/compiler/radeon_list.h
new file mode 100644 (file)
index 0000000..b3c8f89
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Tom Stellard <tstellar@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 RADEON_LIST_H
+#define RADEON_LIST_H
+
+struct memory_pool;
+
+struct rc_list {
+       void * Item;
+       struct rc_list * Prev;
+       struct rc_list * Next;
+};
+
+struct rc_list * rc_list(struct memory_pool * pool, void * item);
+void rc_list_add(struct rc_list ** list, struct rc_list * new_value);
+void rc_list_remove(struct rc_list ** list, struct rc_list * rm_value);
+unsigned int rc_list_count(struct rc_list * list);
+void rc_list_print(struct rc_list * list);
+
+#endif /* RADEON_LIST_H */
+
diff --git a/src/gallium/drivers/r300/compiler/radeon_opcodes.c b/src/gallium/drivers/r300/compiler/radeon_opcodes.c
new file mode 100644 (file)
index 0000000..afd78ad
--- /dev/null
@@ -0,0 +1,546 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_opcodes.h"
+#include "radeon_program.h"
+
+#include "radeon_program_constants.h"
+
+struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = {
+       {
+               .Opcode = RC_OPCODE_NOP,
+               .Name = "NOP"
+       },
+       {
+               .Opcode = RC_OPCODE_ILLEGAL_OPCODE,
+               .Name = "ILLEGAL OPCODE"
+       },
+       {
+               .Opcode = RC_OPCODE_ABS,
+               .Name = "ABS",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_ADD,
+               .Name = "ADD",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_ARL,
+               .Name = "ARL",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_CEIL,
+               .Name = "CEIL",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_CLAMP,
+               .Name = "CLAMP",
+               .NumSrcRegs = 3,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_CMP,
+               .Name = "CMP",
+               .NumSrcRegs = 3,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_CND,
+               .Name = "CND",
+               .NumSrcRegs = 3,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_COS,
+               .Name = "COS",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsStandardScalar = 1
+       },
+       {
+               .Opcode = RC_OPCODE_DDX,
+               .Name = "DDX",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_DDY,
+               .Name = "DDY",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_DP2,
+               .Name = "DP2",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_DP3,
+               .Name = "DP3",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_DP4,
+               .Name = "DP4",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_DPH,
+               .Name = "DPH",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_DST,
+               .Name = "DST",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_EX2,
+               .Name = "EX2",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsStandardScalar = 1
+       },
+       {
+               .Opcode = RC_OPCODE_EXP,
+               .Name = "EXP",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_FLR,
+               .Name = "FLR",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_FRC,
+               .Name = "FRC",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_KIL,
+               .Name = "KIL",
+               .NumSrcRegs = 1
+       },
+       {
+               .Opcode = RC_OPCODE_LG2,
+               .Name = "LG2",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsStandardScalar = 1
+       },
+       {
+               .Opcode = RC_OPCODE_LIT,
+               .Name = "LIT",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_LOG,
+               .Name = "LOG",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_LRP,
+               .Name = "LRP",
+               .NumSrcRegs = 3,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_MAD,
+               .Name = "MAD",
+               .NumSrcRegs = 3,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_MAX,
+               .Name = "MAX",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_MIN,
+               .Name = "MIN",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_MOV,
+               .Name = "MOV",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_MUL,
+               .Name = "MUL",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_POW,
+               .Name = "POW",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsStandardScalar = 1
+       },
+       {
+               .Opcode = RC_OPCODE_RCP,
+               .Name = "RCP",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsStandardScalar = 1
+       },
+       {
+               .Opcode = RC_OPCODE_RSQ,
+               .Name = "RSQ",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsStandardScalar = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SCS,
+               .Name = "SCS",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SEQ,
+               .Name = "SEQ",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SFL,
+               .Name = "SFL",
+               .NumSrcRegs = 0,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SGE,
+               .Name = "SGE",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SGT,
+               .Name = "SGT",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SIN,
+               .Name = "SIN",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsStandardScalar = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SLE,
+               .Name = "SLE",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SLT,
+               .Name = "SLT",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SNE,
+               .Name = "SNE",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SSG,
+               .Name = "SSG",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SUB,
+               .Name = "SUB",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_SWZ,
+               .Name = "SWZ",
+               .NumSrcRegs = 1,
+               .HasDstReg = 1,
+               .IsComponentwise = 1
+       },
+       {
+               .Opcode = RC_OPCODE_XPD,
+               .Name = "XPD",
+               .NumSrcRegs = 2,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_TEX,
+               .Name = "TEX",
+               .HasTexture = 1,
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_TXB,
+               .Name = "TXB",
+               .HasTexture = 1,
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_TXD,
+               .Name = "TXD",
+               .HasTexture = 1,
+               .NumSrcRegs = 3,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_TXL,
+               .Name = "TXL",
+               .HasTexture = 1,
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_TXP,
+               .Name = "TXP",
+               .HasTexture = 1,
+               .NumSrcRegs = 1,
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_IF,
+               .Name = "IF",
+               .IsFlowControl = 1,
+               .NumSrcRegs = 1
+       },
+       {
+               .Opcode = RC_OPCODE_ELSE,
+               .Name = "ELSE",
+               .IsFlowControl = 1,
+               .NumSrcRegs = 0
+       },
+       {
+               .Opcode = RC_OPCODE_ENDIF,
+               .Name = "ENDIF",
+               .IsFlowControl = 1,
+               .NumSrcRegs = 0
+       },
+       {
+               .Opcode = RC_OPCODE_BGNLOOP,
+               .Name = "BGNLOOP",
+               .IsFlowControl = 1,
+               .NumSrcRegs = 0
+       },
+       {
+               .Opcode = RC_OPCODE_BRK,
+               .Name = "BRK",
+               .IsFlowControl = 1,
+               .NumSrcRegs = 0
+       },
+       {
+               .Opcode = RC_OPCODE_ENDLOOP,
+               .Name = "ENDLOOP",
+               .IsFlowControl = 1,
+               .NumSrcRegs = 0,
+       },
+       {
+               .Opcode = RC_OPCODE_CONT,
+               .Name = "CONT",
+               .IsFlowControl = 1,
+               .NumSrcRegs = 0
+       },
+       {
+               .Opcode = RC_OPCODE_REPL_ALPHA,
+               .Name = "REPL_ALPHA",
+               .HasDstReg = 1
+       },
+       {
+               .Opcode = RC_OPCODE_BEGIN_TEX,
+               .Name = "BEGIN_TEX"
+       },
+       {
+               .Opcode = RC_OPCODE_KILP,
+               .Name = "KILP",
+       }
+};
+
+void rc_compute_sources_for_writemask(
+               const struct rc_instruction *inst,
+               unsigned int writemask,
+               unsigned int *srcmasks)
+{
+       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+       srcmasks[0] = 0;
+       srcmasks[1] = 0;
+       srcmasks[2] = 0;
+
+       if (opcode->Opcode == RC_OPCODE_KIL)
+               srcmasks[0] |= RC_MASK_XYZW;
+       else if (opcode->Opcode == RC_OPCODE_IF)
+               srcmasks[0] |= RC_MASK_X;
+
+       if (!writemask)
+               return;
+
+       if (opcode->IsComponentwise) {
+               for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src)
+                       srcmasks[src] |= writemask;
+       } else if (opcode->IsStandardScalar) {
+               for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src)
+                       srcmasks[src] |= RC_MASK_X;
+       } else {
+               switch(opcode->Opcode) {
+               case RC_OPCODE_ARL:
+                       srcmasks[0] |= RC_MASK_X;
+                       break;
+               case RC_OPCODE_DP2:
+                       srcmasks[0] |= RC_MASK_XY;
+                       srcmasks[1] |= RC_MASK_XY;
+                       break;
+               case RC_OPCODE_DP3:
+               case RC_OPCODE_XPD:
+                       srcmasks[0] |= RC_MASK_XYZ;
+                       srcmasks[1] |= RC_MASK_XYZ;
+                       break;
+               case RC_OPCODE_DP4:
+                       srcmasks[0] |= RC_MASK_XYZW;
+                       srcmasks[1] |= RC_MASK_XYZW;
+                       break;
+               case RC_OPCODE_DPH:
+                       srcmasks[0] |= RC_MASK_XYZ;
+                       srcmasks[1] |= RC_MASK_XYZW;
+                       break;
+               case RC_OPCODE_TXB:
+               case RC_OPCODE_TXP:
+               case RC_OPCODE_TXL:
+                       srcmasks[0] |= RC_MASK_W;
+                       /* Fall through */
+               case RC_OPCODE_TEX:
+                       switch (inst->U.I.TexSrcTarget) {
+                               case RC_TEXTURE_1D:
+                                       srcmasks[0] |= RC_MASK_X;
+                                       break;
+                               case RC_TEXTURE_2D:
+                               case RC_TEXTURE_RECT:
+                               case RC_TEXTURE_1D_ARRAY:
+                                       srcmasks[0] |= RC_MASK_XY;
+                                       break;
+                               case RC_TEXTURE_3D:
+                               case RC_TEXTURE_CUBE:
+                               case RC_TEXTURE_2D_ARRAY:
+                                       srcmasks[0] |= RC_MASK_XYZ;
+                                       break;
+                       }
+                       break;
+               case RC_OPCODE_TXD:
+                       switch (inst->U.I.TexSrcTarget) {
+                               case RC_TEXTURE_1D_ARRAY:
+                                       srcmasks[0] |= RC_MASK_Y;
+                                       /* Fall through. */
+                               case RC_TEXTURE_1D:
+                                       srcmasks[0] |= RC_MASK_X;
+                                       srcmasks[1] |= RC_MASK_X;
+                                       srcmasks[2] |= RC_MASK_X;
+                                       break;
+                               case RC_TEXTURE_2D_ARRAY:
+                                       srcmasks[0] |= RC_MASK_Z;
+                                       /* Fall through. */
+                               case RC_TEXTURE_2D:
+                               case RC_TEXTURE_RECT:
+                                       srcmasks[0] |= RC_MASK_XY;
+                                       srcmasks[1] |= RC_MASK_XY;
+                                       srcmasks[2] |= RC_MASK_XY;
+                                       break;
+                               case RC_TEXTURE_3D:
+                               case RC_TEXTURE_CUBE:
+                                       srcmasks[0] |= RC_MASK_XYZ;
+                                       srcmasks[1] |= RC_MASK_XYZ;
+                                       srcmasks[2] |= RC_MASK_XYZ;
+                                       break;
+                       }
+                       break;
+               case RC_OPCODE_DST:
+                       srcmasks[0] |= RC_MASK_Y | RC_MASK_Z;
+                       srcmasks[1] |= RC_MASK_Y | RC_MASK_W;
+                       break;
+               case RC_OPCODE_EXP:
+               case RC_OPCODE_LOG:
+                       srcmasks[0] |= RC_MASK_XY;
+                       break;
+               case RC_OPCODE_LIT:
+                       srcmasks[0] |= RC_MASK_X | RC_MASK_Y | RC_MASK_W;
+                       break;
+               default:
+                       break;
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_opcodes.h b/src/gallium/drivers/r300/compiler/radeon_opcodes.h
new file mode 100644 (file)
index 0000000..b586882
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef RADEON_OPCODES_H
+#define RADEON_OPCODES_H
+
+#include <assert.h>
+
+/**
+ * Opcodes understood by the Radeon compiler.
+ */
+typedef enum {
+       RC_OPCODE_NOP = 0,
+       RC_OPCODE_ILLEGAL_OPCODE,
+
+       /** vec4 instruction: dst.c = abs(src0.c); */
+       RC_OPCODE_ABS,
+
+       /** vec4 instruction: dst.c = src0.c + src1.c; */
+       RC_OPCODE_ADD,
+
+       /** special instruction: load address register
+        * dst.x = floor(src.x), where dst must be an address register */
+       RC_OPCODE_ARL,
+
+       /** vec4 instruction: dst.c = ceil(src0.c) */
+       RC_OPCODE_CEIL,
+
+       /** vec4 instruction: dst.c = clamp(src0.c, src1.c, src2.c) */
+       RC_OPCODE_CLAMP,
+
+       /** vec4 instruction: dst.c = src0.c < 0.0 ? src1.c : src2.c */
+       RC_OPCODE_CMP,
+
+       /** vec4 instruction: dst.c = src2.c > 0.5 ? src0.c : src1.c */
+       RC_OPCODE_CND,
+
+       /** scalar instruction: dst = cos(src0.x) */
+       RC_OPCODE_COS,
+
+       /** special instruction: take vec4 partial derivative in X direction
+        * dst.c = d src0.c / dx */
+       RC_OPCODE_DDX,
+
+       /** special instruction: take vec4 partial derivative in Y direction
+        * dst.c = d src0.c / dy */
+       RC_OPCODE_DDY,
+
+       /** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y */
+       RC_OPCODE_DP2,
+
+       /** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z */
+       RC_OPCODE_DP3,
+
+       /** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z + src0.w*src1.w */
+       RC_OPCODE_DP4,
+
+       /** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z + src1.w */
+       RC_OPCODE_DPH,
+
+       /** special instruction, see ARB_fragment_program */
+       RC_OPCODE_DST,
+
+       /** scalar instruction: dst = 2**src0.x */
+       RC_OPCODE_EX2,
+
+       /** special instruction, see ARB_vertex_program */
+       RC_OPCODE_EXP,
+
+       /** vec4 instruction: dst.c = floor(src0.c) */
+       RC_OPCODE_FLR,
+
+       /** vec4 instruction: dst.c = src0.c - floor(src0.c) */
+       RC_OPCODE_FRC,
+
+       /** special instruction: stop execution if any component of src0 is negative */
+       RC_OPCODE_KIL,
+
+       /** scalar instruction: dst = log_2(src0.x) */
+       RC_OPCODE_LG2,
+
+       /** special instruction, see ARB_vertex_program */
+       RC_OPCODE_LIT,
+
+       /** special instruction, see ARB_vertex_program */
+       RC_OPCODE_LOG,
+
+       /** vec4 instruction: dst.c = src0.c*src1.c + (1 - src0.c)*src2.c */
+       RC_OPCODE_LRP,
+
+       /** vec4 instruction: dst.c = src0.c*src1.c + src2.c */
+       RC_OPCODE_MAD,
+
+       /** vec4 instruction: dst.c = max(src0.c, src1.c) */
+       RC_OPCODE_MAX,
+
+       /** vec4 instruction: dst.c = min(src0.c, src1.c) */
+       RC_OPCODE_MIN,
+
+       /** vec4 instruction: dst.c = src0.c */
+       RC_OPCODE_MOV,
+
+       /** vec4 instruction: dst.c = src0.c*src1.c */
+       RC_OPCODE_MUL,
+
+       /** scalar instruction: dst = src0.x ** src1.x */
+       RC_OPCODE_POW,
+
+       /** scalar instruction: dst = 1 / src0.x */
+       RC_OPCODE_RCP,
+
+       /** scalar instruction: dst = 1 / sqrt(src0.x) */
+       RC_OPCODE_RSQ,
+
+       /** special instruction, see ARB_fragment_program */
+       RC_OPCODE_SCS,
+
+       /** vec4 instruction: dst.c = (src0.c == src1.c) ? 1.0 : 0.0 */
+       RC_OPCODE_SEQ,
+
+       /** vec4 instruction: dst.c = 0.0 */
+       RC_OPCODE_SFL,
+
+       /** vec4 instruction: dst.c = (src0.c >= src1.c) ? 1.0 : 0.0 */
+       RC_OPCODE_SGE,
+
+       /** vec4 instruction: dst.c = (src0.c > src1.c) ? 1.0 : 0.0 */
+       RC_OPCODE_SGT,
+
+       /** scalar instruction: dst = sin(src0.x) */
+       RC_OPCODE_SIN,
+
+       /** vec4 instruction: dst.c = (src0.c <= src1.c) ? 1.0 : 0.0 */
+       RC_OPCODE_SLE,
+
+       /** vec4 instruction: dst.c = (src0.c < src1.c) ? 1.0 : 0.0 */
+       RC_OPCODE_SLT,
+
+       /** vec4 instruction: dst.c = (src0.c != src1.c) ? 1.0 : 0.0 */
+       RC_OPCODE_SNE,
+
+       /** vec4 instruction: dst.c = (src0.c < 0 ?) -1 : ((src0.c > 0) : 1 : 0) */
+       RC_OPCODE_SSG,
+
+       /** vec4 instruction: dst.c = src0.c - src1.c */
+       RC_OPCODE_SUB,
+
+       /** vec4 instruction: dst.c = src0.c */
+       RC_OPCODE_SWZ,
+
+       /** special instruction, see ARB_fragment_program */
+       RC_OPCODE_XPD,
+
+       RC_OPCODE_TEX,
+       RC_OPCODE_TXB,
+       RC_OPCODE_TXD,
+       RC_OPCODE_TXL,
+       RC_OPCODE_TXP,
+
+       /** branch instruction:
+        * If src0.x != 0.0, continue with the next instruction;
+        * otherwise, jump to matching RC_OPCODE_ELSE or RC_OPCODE_ENDIF.
+        */
+       RC_OPCODE_IF,
+
+       /** branch instruction: jump to matching RC_OPCODE_ENDIF */
+       RC_OPCODE_ELSE,
+
+       /** branch instruction: has no effect */
+       RC_OPCODE_ENDIF,
+       
+       RC_OPCODE_BGNLOOP,
+
+       RC_OPCODE_BRK,
+
+       RC_OPCODE_ENDLOOP,
+
+       RC_OPCODE_CONT,
+
+       /** special instruction, used in R300-R500 fragment program pair instructions
+        * indicates that the result of the alpha operation shall be replicated
+        * across all other channels */
+       RC_OPCODE_REPL_ALPHA,
+
+       /** special instruction, used in R300-R500 fragment programs
+        * to indicate the start of a block of texture instructions that
+        * can run simultaneously. */
+       RC_OPCODE_BEGIN_TEX,
+
+       /** Stop execution of the shader (GLSL discard) */
+       RC_OPCODE_KILP,
+
+       MAX_RC_OPCODE
+} rc_opcode;
+
+
+struct rc_opcode_info {
+       rc_opcode Opcode;
+       const char * Name;
+
+       /** true if the instruction reads from a texture.
+        *
+        * \note This is false for the KIL instruction, even though KIL is
+        * a texture instruction from a hardware point of view. */
+       unsigned int HasTexture:1;
+
+       unsigned int NumSrcRegs:2;
+       unsigned int HasDstReg:1;
+
+       /** true if this instruction affects control flow */
+       unsigned int IsFlowControl:1;
+
+       /** true if this is a vector instruction that operates on components in parallel
+        * without any cross-component interaction */
+       unsigned int IsComponentwise:1;
+
+       /** true if this instruction sources only its operands X components
+        * to compute one result which is smeared across all output channels */
+       unsigned int IsStandardScalar:1;
+};
+
+extern struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE];
+
+static inline const struct rc_opcode_info * rc_get_opcode_info(rc_opcode opcode)
+{
+       assert((unsigned int)opcode < MAX_RC_OPCODE);
+       assert(rc_opcodes[opcode].Opcode == opcode);
+
+       return &rc_opcodes[opcode];
+}
+
+struct rc_instruction;
+
+void rc_compute_sources_for_writemask(
+               const struct rc_instruction *inst,
+               unsigned int writemask,
+               unsigned int *srcmasks);
+
+#endif /* RADEON_OPCODES_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_optimize.c b/src/gallium/drivers/r300/compiler/radeon_optimize.c
new file mode 100644 (file)
index 0000000..39dcb21
--- /dev/null
@@ -0,0 +1,700 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ * Copyright 2010 Tom Stellard <tstellar@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_dataflow.h"
+
+#include "radeon_compiler.h"
+#include "radeon_compiler_util.h"
+#include "radeon_swizzle.h"
+
+struct src_clobbered_reads_cb_data {
+       rc_register_file File;
+       unsigned int Index;
+       unsigned int Mask;
+       struct rc_reader_data * ReaderData;
+};
+
+typedef void (*rc_presub_replace_fn)(struct rc_instruction *,
+                                               struct rc_instruction *,
+                                               unsigned int);
+
+static struct rc_src_register chain_srcregs(struct rc_src_register outer, struct rc_src_register inner)
+{
+       struct rc_src_register combine;
+       combine.File = inner.File;
+       combine.Index = inner.Index;
+       combine.RelAddr = inner.RelAddr;
+       if (outer.Abs) {
+               combine.Abs = 1;
+               combine.Negate = outer.Negate;
+       } else {
+               combine.Abs = inner.Abs;
+               combine.Negate = swizzle_mask(outer.Swizzle, inner.Negate);
+               combine.Negate ^= outer.Negate;
+       }
+       combine.Swizzle = combine_swizzles(inner.Swizzle, outer.Swizzle);
+       return combine;
+}
+
+static void copy_propagate_scan_read(void * data, struct rc_instruction * inst,
+                                               struct rc_src_register * src)
+{
+       rc_register_file file = src->File;
+       struct rc_reader_data * reader_data = data;
+
+       if(!rc_inst_can_use_presub(inst,
+                               reader_data->Writer->U.I.PreSub.Opcode,
+                               rc_swizzle_to_writemask(src->Swizzle),
+                               src,
+                               &reader_data->Writer->U.I.PreSub.SrcReg[0],
+                               &reader_data->Writer->U.I.PreSub.SrcReg[1])) {
+               reader_data->Abort = 1;
+               return;
+       }
+
+       /* XXX This could probably be handled better. */
+       if (file == RC_FILE_ADDRESS) {
+               reader_data->Abort = 1;
+               return;
+       }
+
+       /* These instructions cannot read from the constants file.
+        * see radeonTransformTEX()
+        */
+       if(reader_data->Writer->U.I.SrcReg[0].File != RC_FILE_TEMPORARY &&
+                       reader_data->Writer->U.I.SrcReg[0].File != RC_FILE_INPUT &&
+                               (inst->U.I.Opcode == RC_OPCODE_TEX ||
+                               inst->U.I.Opcode == RC_OPCODE_TXB ||
+                               inst->U.I.Opcode == RC_OPCODE_TXP ||
+                               inst->U.I.Opcode == RC_OPCODE_TXD ||
+                               inst->U.I.Opcode == RC_OPCODE_TXL ||
+                               inst->U.I.Opcode == RC_OPCODE_KIL)){
+               reader_data->Abort = 1;
+               return;
+       }
+}
+
+static void src_clobbered_reads_cb(
+       void * data,
+       struct rc_instruction * inst,
+       struct rc_src_register * src)
+{
+       struct src_clobbered_reads_cb_data * sc_data = data;
+
+       if (src->File == sc_data->File
+           && src->Index == sc_data->Index
+           && (rc_swizzle_to_writemask(src->Swizzle) & sc_data->Mask)) {
+
+               sc_data->ReaderData->AbortOnRead = RC_MASK_XYZW;
+       }
+
+       if (src->RelAddr && sc_data->File == RC_FILE_ADDRESS) {
+               sc_data->ReaderData->AbortOnRead = RC_MASK_XYZW;
+       }
+}
+
+static void is_src_clobbered_scan_write(
+       void * data,
+       struct rc_instruction * inst,
+       rc_register_file file,
+       unsigned int index,
+       unsigned int mask)
+{
+       struct src_clobbered_reads_cb_data sc_data;
+       struct rc_reader_data * reader_data = data;
+       sc_data.File = file;
+       sc_data.Index = index;
+       sc_data.Mask = mask;
+       sc_data.ReaderData = reader_data;
+       rc_for_all_reads_src(reader_data->Writer,
+                                       src_clobbered_reads_cb, &sc_data);
+}
+
+static void copy_propagate(struct radeon_compiler * c, struct rc_instruction * inst_mov)
+{
+       struct rc_reader_data reader_data;
+       unsigned int i;
+
+       if (inst_mov->U.I.DstReg.File != RC_FILE_TEMPORARY ||
+           inst_mov->U.I.WriteALUResult ||
+           inst_mov->U.I.SaturateMode)
+               return;
+
+       /* Get a list of all the readers of this MOV instruction. */
+       reader_data.ExitOnAbort = 1;
+       rc_get_readers(c, inst_mov, &reader_data,
+                      copy_propagate_scan_read, NULL,
+                      is_src_clobbered_scan_write);
+
+       if (reader_data.Abort || reader_data.ReaderCount == 0)
+               return;
+
+       /* Propagate the MOV instruction. */
+       for (i = 0; i < reader_data.ReaderCount; i++) {
+               struct rc_instruction * inst = reader_data.Readers[i].Inst;
+               *reader_data.Readers[i].U.I.Src = chain_srcregs(*reader_data.Readers[i].U.I.Src, inst_mov->U.I.SrcReg[0]);
+
+               if (inst_mov->U.I.SrcReg[0].File == RC_FILE_PRESUB)
+                       inst->U.I.PreSub = inst_mov->U.I.PreSub;
+       }
+
+       /* Finally, remove the original MOV instruction */
+       rc_remove_instruction(inst_mov);
+}
+
+/**
+ * Check if a source register is actually always the same
+ * swizzle constant.
+ */
+static int is_src_uniform_constant(struct rc_src_register src,
+               rc_swizzle * pswz, unsigned int * pnegate)
+{
+       int have_used = 0;
+
+       if (src.File != RC_FILE_NONE) {
+               *pswz = 0;
+               return 0;
+       }
+
+       for(unsigned int chan = 0; chan < 4; ++chan) {
+               unsigned int swz = GET_SWZ(src.Swizzle, chan);
+               if (swz < 4) {
+                       *pswz = 0;
+                       return 0;
+               }
+               if (swz == RC_SWIZZLE_UNUSED)
+                       continue;
+
+               if (!have_used) {
+                       *pswz = swz;
+                       *pnegate = GET_BIT(src.Negate, chan);
+                       have_used = 1;
+               } else {
+                       if (swz != *pswz || *pnegate != GET_BIT(src.Negate, chan)) {
+                               *pswz = 0;
+                               return 0;
+                       }
+               }
+       }
+
+       return 1;
+}
+
+static void constant_folding_mad(struct rc_instruction * inst)
+{
+       rc_swizzle swz = 0;
+       unsigned int negate= 0;
+
+       if (is_src_uniform_constant(inst->U.I.SrcReg[2], &swz, &negate)) {
+               if (swz == RC_SWIZZLE_ZERO) {
+                       inst->U.I.Opcode = RC_OPCODE_MUL;
+                       return;
+               }
+       }
+
+       if (is_src_uniform_constant(inst->U.I.SrcReg[1], &swz, &negate)) {
+               if (swz == RC_SWIZZLE_ONE) {
+                       inst->U.I.Opcode = RC_OPCODE_ADD;
+                       if (negate)
+                               inst->U.I.SrcReg[0].Negate ^= RC_MASK_XYZW;
+                       inst->U.I.SrcReg[1] = inst->U.I.SrcReg[2];
+                       return;
+               } else if (swz == RC_SWIZZLE_ZERO) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+                       inst->U.I.SrcReg[0] = inst->U.I.SrcReg[2];
+                       return;
+               }
+       }
+
+       if (is_src_uniform_constant(inst->U.I.SrcReg[0], &swz, &negate)) {
+               if (swz == RC_SWIZZLE_ONE) {
+                       inst->U.I.Opcode = RC_OPCODE_ADD;
+                       if (negate)
+                               inst->U.I.SrcReg[1].Negate ^= RC_MASK_XYZW;
+                       inst->U.I.SrcReg[0] = inst->U.I.SrcReg[2];
+                       return;
+               } else if (swz == RC_SWIZZLE_ZERO) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+                       inst->U.I.SrcReg[0] = inst->U.I.SrcReg[2];
+                       return;
+               }
+       }
+}
+
+static void constant_folding_mul(struct rc_instruction * inst)
+{
+       rc_swizzle swz = 0;
+       unsigned int negate = 0;
+
+       if (is_src_uniform_constant(inst->U.I.SrcReg[0], &swz, &negate)) {
+               if (swz == RC_SWIZZLE_ONE) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+                       inst->U.I.SrcReg[0] = inst->U.I.SrcReg[1];
+                       if (negate)
+                               inst->U.I.SrcReg[0].Negate ^= RC_MASK_XYZW;
+                       return;
+               } else if (swz == RC_SWIZZLE_ZERO) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+                       inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_0000;
+                       return;
+               }
+       }
+
+       if (is_src_uniform_constant(inst->U.I.SrcReg[1], &swz, &negate)) {
+               if (swz == RC_SWIZZLE_ONE) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+                       if (negate)
+                               inst->U.I.SrcReg[0].Negate ^= RC_MASK_XYZW;
+                       return;
+               } else if (swz == RC_SWIZZLE_ZERO) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+                       inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_0000;
+                       return;
+               }
+       }
+}
+
+static void constant_folding_add(struct rc_instruction * inst)
+{
+       rc_swizzle swz = 0;
+       unsigned int negate = 0;
+
+       if (is_src_uniform_constant(inst->U.I.SrcReg[0], &swz, &negate)) {
+               if (swz == RC_SWIZZLE_ZERO) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+                       inst->U.I.SrcReg[0] = inst->U.I.SrcReg[1];
+                       return;
+               }
+       }
+
+       if (is_src_uniform_constant(inst->U.I.SrcReg[1], &swz, &negate)) {
+               if (swz == RC_SWIZZLE_ZERO) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+                       return;
+               }
+       }
+}
+
+/**
+ * Replace 0.0, 1.0 and 0.5 immediate constants by their
+ * respective swizzles. Simplify instructions like ADD dst, src, 0;
+ */
+static void constant_folding(struct radeon_compiler * c, struct rc_instruction * inst)
+{
+       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+       unsigned int i;
+
+       /* Replace 0.0, 1.0 and 0.5 immediates by their explicit swizzles */
+       for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
+               struct rc_constant * constant;
+               struct rc_src_register newsrc;
+               int have_real_reference;
+               unsigned int chan;
+
+               /* If there are only 0, 0.5, 1, or _ swizzles, mark the source as a constant. */
+               for (chan = 0; chan < 4; ++chan)
+                       if (GET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan) <= 3)
+                               break;
+               if (chan == 4) {
+                       inst->U.I.SrcReg[src].File = RC_FILE_NONE;
+                       continue;
+               }
+
+               /* Convert immediates to swizzles. */
+               if (inst->U.I.SrcReg[src].File != RC_FILE_CONSTANT ||
+                   inst->U.I.SrcReg[src].RelAddr ||
+                   inst->U.I.SrcReg[src].Index >= c->Program.Constants.Count)
+                       continue;
+
+               constant =
+                       &c->Program.Constants.Constants[inst->U.I.SrcReg[src].Index];
+
+               if (constant->Type != RC_CONSTANT_IMMEDIATE)
+                       continue;
+
+               newsrc = inst->U.I.SrcReg[src];
+               have_real_reference = 0;
+               for (chan = 0; chan < 4; ++chan) {
+                       unsigned int swz = GET_SWZ(newsrc.Swizzle, chan);
+                       unsigned int newswz;
+                       float imm;
+                       float baseimm;
+
+                       if (swz >= 4)
+                               continue;
+
+                       imm = constant->u.Immediate[swz];
+                       baseimm = imm;
+                       if (imm < 0.0)
+                               baseimm = -baseimm;
+
+                       if (baseimm == 0.0) {
+                               newswz = RC_SWIZZLE_ZERO;
+                       } else if (baseimm == 1.0) {
+                               newswz = RC_SWIZZLE_ONE;
+                       } else if (baseimm == 0.5 && c->has_half_swizzles) {
+                               newswz = RC_SWIZZLE_HALF;
+                       } else {
+                               have_real_reference = 1;
+                               continue;
+                       }
+
+                       SET_SWZ(newsrc.Swizzle, chan, newswz);
+                       if (imm < 0.0 && !newsrc.Abs)
+                               newsrc.Negate ^= 1 << chan;
+               }
+
+               if (!have_real_reference) {
+                       newsrc.File = RC_FILE_NONE;
+                       newsrc.Index = 0;
+               }
+
+               /* don't make the swizzle worse */
+               if (!c->SwizzleCaps->IsNative(inst->U.I.Opcode, newsrc) &&
+                   c->SwizzleCaps->IsNative(inst->U.I.Opcode, inst->U.I.SrcReg[src]))
+                       continue;
+
+               inst->U.I.SrcReg[src] = newsrc;
+       }
+
+       /* Simplify instructions based on constants */
+       if (inst->U.I.Opcode == RC_OPCODE_MAD)
+               constant_folding_mad(inst);
+
+       /* note: MAD can simplify to MUL or ADD */
+       if (inst->U.I.Opcode == RC_OPCODE_MUL)
+               constant_folding_mul(inst);
+       else if (inst->U.I.Opcode == RC_OPCODE_ADD)
+               constant_folding_add(inst);
+
+       /* In case this instruction has been converted, make sure all of the
+        * registers that are no longer used are empty. */
+       opcode = rc_get_opcode_info(inst->U.I.Opcode);
+       for(i = opcode->NumSrcRegs; i < 3; i++) {
+               memset(&inst->U.I.SrcReg[i], 0, sizeof(struct rc_src_register));
+       }
+}
+
+/**
+ * If src and dst use the same register, this function returns a writemask that
+ * indicates wich components are read by src.  Otherwise zero is returned.
+ */
+static unsigned int src_reads_dst_mask(struct rc_src_register src,
+                                               struct rc_dst_register dst)
+{
+       if (dst.File != src.File || dst.Index != src.Index) {
+               return 0;
+       }
+       return rc_swizzle_to_writemask(src.Swizzle);
+}
+
+/* Return 1 if the source registers has a constant swizzle (e.g. 0, 0.5, 1.0)
+ * in any of its channels.  Return 0 otherwise. */
+static int src_has_const_swz(struct rc_src_register src) {
+       int chan;
+       for(chan = 0; chan < 4; chan++) {
+               unsigned int swz = GET_SWZ(src.Swizzle, chan);
+               if (swz == RC_SWIZZLE_ZERO || swz == RC_SWIZZLE_HALF
+                                               || swz == RC_SWIZZLE_ONE) {
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+static void presub_scan_read(
+       void * data,
+       struct rc_instruction * inst,
+       struct rc_src_register * src)
+{
+       struct rc_reader_data * reader_data = data;
+       rc_presubtract_op * presub_opcode = reader_data->CbData;
+
+       if (!rc_inst_can_use_presub(inst, *presub_opcode,
+                       reader_data->Writer->U.I.DstReg.WriteMask,
+                       src,
+                       &reader_data->Writer->U.I.SrcReg[0],
+                       &reader_data->Writer->U.I.SrcReg[1])) {
+               reader_data->Abort = 1;
+               return;
+       }
+}
+
+static int presub_helper(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst_add,
+       rc_presubtract_op presub_opcode,
+       rc_presub_replace_fn presub_replace)
+{
+       struct rc_reader_data reader_data;
+       unsigned int i;
+       rc_presubtract_op cb_op = presub_opcode;
+
+       reader_data.CbData = &cb_op;
+       reader_data.ExitOnAbort = 1;
+       rc_get_readers(c, inst_add, &reader_data, presub_scan_read, NULL,
+                                               is_src_clobbered_scan_write);
+
+       if (reader_data.Abort || reader_data.ReaderCount == 0)
+               return 0;
+
+       for(i = 0; i < reader_data.ReaderCount; i++) {
+               unsigned int src_index;
+               struct rc_reader reader = reader_data.Readers[i];
+               const struct rc_opcode_info * info =
+                               rc_get_opcode_info(reader.Inst->U.I.Opcode);
+
+               for (src_index = 0; src_index < info->NumSrcRegs; src_index++) {
+                       if (&reader.Inst->U.I.SrcReg[src_index] == reader.U.I.Src)
+                               presub_replace(inst_add, reader.Inst, src_index);
+               }
+       }
+       return 1;
+}
+
+/* This function assumes that inst_add->U.I.SrcReg[0] and
+ * inst_add->U.I.SrcReg[1] aren't both negative. */
+static void presub_replace_add(
+       struct rc_instruction * inst_add,
+       struct rc_instruction * inst_reader,
+       unsigned int src_index)
+{
+       rc_presubtract_op presub_opcode;
+       if (inst_add->U.I.SrcReg[1].Negate || inst_add->U.I.SrcReg[0].Negate)
+               presub_opcode = RC_PRESUB_SUB;
+       else
+               presub_opcode = RC_PRESUB_ADD;
+
+       if (inst_add->U.I.SrcReg[1].Negate) {
+               inst_reader->U.I.PreSub.SrcReg[0] = inst_add->U.I.SrcReg[1];
+               inst_reader->U.I.PreSub.SrcReg[1] = inst_add->U.I.SrcReg[0];
+       } else {
+               inst_reader->U.I.PreSub.SrcReg[0] = inst_add->U.I.SrcReg[0];
+               inst_reader->U.I.PreSub.SrcReg[1] = inst_add->U.I.SrcReg[1];
+       }
+       inst_reader->U.I.PreSub.SrcReg[0].Negate = 0;
+       inst_reader->U.I.PreSub.SrcReg[1].Negate = 0;
+       inst_reader->U.I.PreSub.Opcode = presub_opcode;
+       inst_reader->U.I.SrcReg[src_index] =
+                       chain_srcregs(inst_reader->U.I.SrcReg[src_index],
+                                       inst_reader->U.I.PreSub.SrcReg[0]);
+       inst_reader->U.I.SrcReg[src_index].File = RC_FILE_PRESUB;
+       inst_reader->U.I.SrcReg[src_index].Index = presub_opcode;
+}
+
+static int is_presub_candidate(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst)
+{
+       const struct rc_opcode_info * info = rc_get_opcode_info(inst->U.I.Opcode);
+       unsigned int i;
+       unsigned int is_constant[2] = {0, 0};
+
+       assert(inst->U.I.Opcode == RC_OPCODE_ADD);
+
+       if (inst->U.I.PreSub.Opcode != RC_PRESUB_NONE
+                       || inst->U.I.SaturateMode
+                       || inst->U.I.WriteALUResult) {
+               return 0;
+       }
+
+       /* If both sources use a constant swizzle, then we can't convert it to
+        * a presubtract operation.  In fact for the ADD and SUB presubtract
+        * operations neither source can contain a constant swizzle.  This
+        * specific case is checked in peephole_add_presub_add() when
+        * we make sure the swizzles for both sources are equal, so we
+        * don't need to worry about it here. */
+       for (i = 0; i < 2; i++) {
+               int chan;
+               for (chan = 0; chan < 4; chan++) {
+                       rc_swizzle swz =
+                               get_swz(inst->U.I.SrcReg[i].Swizzle, chan);
+                       if (swz == RC_SWIZZLE_ONE
+                                       || swz == RC_SWIZZLE_ZERO
+                                       || swz == RC_SWIZZLE_HALF) {
+                               is_constant[i] = 1;
+                       }
+               }
+       }
+       if (is_constant[0] && is_constant[1])
+               return 0;
+
+       for(i = 0; i < info->NumSrcRegs; i++) {
+               struct rc_src_register src = inst->U.I.SrcReg[i];
+               if (src_reads_dst_mask(src, inst->U.I.DstReg))
+                       return 0;
+
+               src.File = RC_FILE_PRESUB;
+               if (!c->SwizzleCaps->IsNative(inst->U.I.Opcode, src))
+                       return 0;
+       }
+       return 1;
+}
+
+static int peephole_add_presub_add(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst_add)
+{
+       unsigned dstmask = inst_add->U.I.DstReg.WriteMask;
+        unsigned src0_neg = inst_add->U.I.SrcReg[0].Negate & dstmask;
+        unsigned src1_neg = inst_add->U.I.SrcReg[1].Negate & dstmask;
+
+       if (inst_add->U.I.SrcReg[0].Swizzle != inst_add->U.I.SrcReg[1].Swizzle)
+               return 0;
+
+       /* src0 and src1 can't have absolute values */
+       if (inst_add->U.I.SrcReg[0].Abs || inst_add->U.I.SrcReg[1].Abs)
+               return 0;
+
+       /* presub_replace_add() assumes only one is negative */
+       if (inst_add->U.I.SrcReg[0].Negate && inst_add->U.I.SrcReg[1].Negate)
+               return 0;
+
+        /* if src0 is negative, at least all bits of dstmask have to be set */
+        if (inst_add->U.I.SrcReg[0].Negate && src0_neg != dstmask)
+               return 0;
+
+        /* if src1 is negative, at least all bits of dstmask have to be set */
+        if (inst_add->U.I.SrcReg[1].Negate && src1_neg != dstmask)
+               return 0;
+
+       if (!is_presub_candidate(c, inst_add))
+               return 0;
+
+       if (presub_helper(c, inst_add, RC_PRESUB_ADD, presub_replace_add)) {
+               rc_remove_instruction(inst_add);
+               return 1;
+       }
+       return 0;
+}
+
+static void presub_replace_inv(
+       struct rc_instruction * inst_add,
+       struct rc_instruction * inst_reader,
+       unsigned int src_index)
+{
+       /* We must be careful not to modify inst_add, since it
+        * is possible it will remain part of the program.*/
+       inst_reader->U.I.PreSub.SrcReg[0] = inst_add->U.I.SrcReg[1];
+       inst_reader->U.I.PreSub.SrcReg[0].Negate = 0;
+       inst_reader->U.I.PreSub.Opcode = RC_PRESUB_INV;
+       inst_reader->U.I.SrcReg[src_index] = chain_srcregs(inst_reader->U.I.SrcReg[src_index],
+                                               inst_reader->U.I.PreSub.SrcReg[0]);
+
+       inst_reader->U.I.SrcReg[src_index].File = RC_FILE_PRESUB;
+       inst_reader->U.I.SrcReg[src_index].Index = RC_PRESUB_INV;
+}
+
+/**
+ * PRESUB_INV: ADD TEMP[0], none.1, -TEMP[1]
+ * Use the presubtract 1 - src0 for all readers of TEMP[0].  The first source
+ * of the add instruction must have the constatnt 1 swizzle.  This function
+ * does not check const registers to see if their value is 1.0, so it should
+ * be called after the constant_folding optimization.
+ * @return
+ *     0 if the ADD instruction is still part of the program.
+ *     1 if the ADD instruction is no longer part of the program.
+ */
+static int peephole_add_presub_inv(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst_add)
+{
+       unsigned int i, swz;
+
+       if (!is_presub_candidate(c, inst_add))
+               return 0;
+
+       /* Check if src0 is 1. */
+       /* XXX It would be nice to use is_src_uniform_constant here, but that
+        * function only works if the register's file is RC_FILE_NONE */
+       for(i = 0; i < 4; i++ ) {
+               swz = GET_SWZ(inst_add->U.I.SrcReg[0].Swizzle, i);
+               if(((1 << i) & inst_add->U.I.DstReg.WriteMask)
+                                               && swz != RC_SWIZZLE_ONE) {
+                       return 0;
+               }
+       }
+
+       /* Check src1. */
+       if ((inst_add->U.I.SrcReg[1].Negate & inst_add->U.I.DstReg.WriteMask) !=
+                                               inst_add->U.I.DstReg.WriteMask
+               || inst_add->U.I.SrcReg[1].Abs
+               || (inst_add->U.I.SrcReg[1].File != RC_FILE_TEMPORARY
+                       && inst_add->U.I.SrcReg[1].File != RC_FILE_CONSTANT)
+               || src_has_const_swz(inst_add->U.I.SrcReg[1])) {
+
+               return 0;
+       }
+
+       if (presub_helper(c, inst_add, RC_PRESUB_INV, presub_replace_inv)) {
+               rc_remove_instruction(inst_add);
+               return 1;
+       }
+       return 0;
+}
+
+/**
+ * @return
+ *     0 if inst is still part of the program.
+ *     1 if inst is no longer part of the program.
+ */
+static int peephole(struct radeon_compiler * c, struct rc_instruction * inst)
+{
+       switch(inst->U.I.Opcode){
+       case RC_OPCODE_ADD:
+               if (c->has_presub) {
+                       if(peephole_add_presub_inv(c, inst))
+                               return 1;
+                       if(peephole_add_presub_add(c, inst))
+                               return 1;
+               }
+               break;
+       default:
+               break;
+       }
+       return 0;
+}
+
+void rc_optimize(struct radeon_compiler * c, void *user)
+{
+       struct rc_instruction * inst = c->Program.Instructions.Next;
+       while(inst != &c->Program.Instructions) {
+               struct rc_instruction * cur = inst;
+               inst = inst->Next;
+
+               constant_folding(c, cur);
+
+               if(peephole(c, cur))
+                       continue;
+
+               if (cur->U.I.Opcode == RC_OPCODE_MOV) {
+                       copy_propagate(c, cur);
+                       /* cur may no longer be part of the program */
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_dead_sources.c b/src/gallium/drivers/r300/compiler/radeon_pair_dead_sources.c
new file mode 100644 (file)
index 0000000..1e9a2c0
--- /dev/null
@@ -0,0 +1,62 @@
+
+#include "radeon_compiler.h"
+#include "radeon_compiler_util.h"
+#include "radeon_opcodes.h"
+#include "radeon_program_pair.h"
+
+static void mark_used_presub(struct rc_pair_sub_instruction * sub)
+{
+       if (sub->Src[RC_PAIR_PRESUB_SRC].Used) {
+               unsigned int presub_reg_count = rc_presubtract_src_reg_count(
+                                       sub->Src[RC_PAIR_PRESUB_SRC].Index);
+               unsigned int i;
+               for (i = 0; i < presub_reg_count; i++) {
+                       sub->Src[i].Used = 1;
+               }
+       }
+}
+
+static void mark_used(
+       struct rc_instruction * inst,
+       struct rc_pair_sub_instruction * sub)
+{
+       unsigned int i;
+       const struct rc_opcode_info * info = rc_get_opcode_info(sub->Opcode);
+       for (i = 0; i < info->NumSrcRegs; i++) {
+               unsigned int src_type = rc_source_type_swz(sub->Arg[i].Swizzle);
+               if (src_type & RC_SOURCE_RGB) {
+                       inst->U.P.RGB.Src[sub->Arg[i].Source].Used = 1;
+               }
+
+               if (src_type & RC_SOURCE_ALPHA) {
+                       inst->U.P.Alpha.Src[sub->Arg[i].Source].Used = 1;
+               }
+       }
+}
+
+/**
+ * This pass finds sources that are not used by their instruction and marks
+ * them as unused. 
+ */
+void rc_pair_remove_dead_sources(struct radeon_compiler * c, void *user)
+{
+       struct rc_instruction * inst;
+       for (inst = c->Program.Instructions.Next;
+                                       inst != &c->Program.Instructions;
+                                       inst = inst->Next) {
+               unsigned int i;
+               if (inst->Type == RC_INSTRUCTION_NORMAL)
+                       continue;
+
+               /* Mark all sources as unused */
+               for (i = 0; i < 4; i++) {
+                       inst->U.P.RGB.Src[i].Used = 0;
+                       inst->U.P.Alpha.Src[i].Used = 0;
+               }
+               mark_used(inst, &inst->U.P.RGB);
+               mark_used(inst, &inst->U.P.Alpha);
+
+               mark_used_presub(&inst->U.P.RGB);
+               mark_used_presub(&inst->U.P.Alpha);
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c
new file mode 100644 (file)
index 0000000..49983d6
--- /dev/null
@@ -0,0 +1,706 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ * Copyright 2011 Tom Stellard <tstellar@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_program_pair.h"
+
+#include <stdio.h>
+
+#include "main/glheader.h"
+#include "program/register_allocate.h"
+#include "ralloc.h"
+
+#include "r300_fragprog_swizzle.h"
+#include "radeon_compiler.h"
+#include "radeon_compiler_util.h"
+#include "radeon_dataflow.h"
+#include "radeon_list.h"
+#include "radeon_variable.h"
+
+#define VERBOSE 0
+
+#define DBG(...) do { if (VERBOSE) fprintf(stderr, __VA_ARGS__); } while(0)
+
+
+
+struct register_info {
+       struct live_intervals Live[4];
+
+       unsigned int Used:1;
+       unsigned int Allocated:1;
+       unsigned int File:3;
+       unsigned int Index:RC_REGISTER_INDEX_BITS;
+       unsigned int Writemask;
+};
+
+struct regalloc_state {
+       struct radeon_compiler * C;
+
+       struct register_info * Input;
+       unsigned int NumInputs;
+
+       struct register_info * Temporary;
+       unsigned int NumTemporaries;
+
+       unsigned int Simple;
+       int LoopEnd;
+};
+
+enum rc_reg_class {
+       RC_REG_CLASS_SINGLE,
+       RC_REG_CLASS_DOUBLE,
+       RC_REG_CLASS_TRIPLE,
+       RC_REG_CLASS_ALPHA,
+       RC_REG_CLASS_SINGLE_PLUS_ALPHA,
+       RC_REG_CLASS_DOUBLE_PLUS_ALPHA,
+       RC_REG_CLASS_TRIPLE_PLUS_ALPHA,
+       RC_REG_CLASS_X,
+       RC_REG_CLASS_Y,
+       RC_REG_CLASS_Z,
+       RC_REG_CLASS_XY,
+       RC_REG_CLASS_YZ,
+       RC_REG_CLASS_XZ,
+       RC_REG_CLASS_XW,
+       RC_REG_CLASS_YW,
+       RC_REG_CLASS_ZW,
+       RC_REG_CLASS_XYW,
+       RC_REG_CLASS_YZW,
+       RC_REG_CLASS_XZW,
+       RC_REG_CLASS_COUNT
+};
+
+struct rc_class {
+       enum rc_reg_class Class;
+
+       unsigned int WritemaskCount;
+
+       /** This is 1 if this class is being used by the register allocator
+        * and 0 otherwise */
+       unsigned int Used;
+
+       /** This is the ID number assigned to this class by ra. */
+       unsigned int Id;
+
+       /** List of writemasks that belong to this class */
+       unsigned int Writemasks[3];
+
+
+};
+
+static void print_live_intervals(struct live_intervals * src)
+{
+       if (!src || !src->Used) {
+               DBG("(null)");
+               return;
+       }
+
+       DBG("(%i,%i)", src->Start, src->End);
+}
+
+static int overlap_live_intervals(struct live_intervals * a, struct live_intervals * b)
+{
+       if (VERBOSE) {
+               DBG("overlap_live_intervals: ");
+               print_live_intervals(a);
+               DBG(" to ");
+               print_live_intervals(b);
+               DBG("\n");
+       }
+
+       if (!a->Used || !b->Used) {
+               DBG("    unused interval\n");
+               return 0;
+       }
+
+       if (a->Start > b->Start) {
+               if (a->Start < b->End) {
+                       DBG("    overlap\n");
+                       return 1;
+               }
+       } else if (b->Start > a->Start) {
+               if (b->Start < a->End) {
+                       DBG("    overlap\n");
+                       return 1;
+               }
+       } else { /* a->Start == b->Start */
+               if (a->Start != a->End && b->Start != b->End) {
+                       DBG("    overlap\n");
+                       return 1;
+               }
+       }
+
+       DBG("    no overlap\n");
+
+       return 0;
+}
+
+static void scan_read_callback(void * data, struct rc_instruction * inst,
+               rc_register_file file, unsigned int index, unsigned int mask)
+{
+       struct regalloc_state * s = data;
+       struct register_info * reg;
+       unsigned int i;
+
+       if (file != RC_FILE_INPUT)
+               return;
+
+       s->Input[index].Used = 1;
+       reg = &s->Input[index];
+
+       for (i = 0; i < 4; i++) {
+               if (!((mask >> i) & 0x1)) {
+                       continue;
+               }
+               reg->Live[i].Used = 1;
+               reg->Live[i].Start = 0;
+               reg->Live[i].End =
+                       s->LoopEnd > inst->IP ? s->LoopEnd : inst->IP;
+       }
+}
+
+static void remap_register(void * data, struct rc_instruction * inst,
+               rc_register_file * file, unsigned int * index)
+{
+       struct regalloc_state * s = data;
+       const struct register_info * reg;
+
+       if (*file == RC_FILE_TEMPORARY && s->Simple)
+               reg = &s->Temporary[*index];
+       else if (*file == RC_FILE_INPUT)
+               reg = &s->Input[*index];
+       else
+               return;
+
+       if (reg->Allocated) {
+               *index = reg->Index;
+       }
+}
+
+static void alloc_input_simple(void * data, unsigned int input,
+                                                       unsigned int hwreg)
+{
+       struct regalloc_state * s = data;
+
+       if (input >= s->NumInputs)
+               return;
+
+       s->Input[input].Allocated = 1;
+       s->Input[input].File = RC_FILE_TEMPORARY;
+       s->Input[input].Index = hwreg;
+}
+
+/* This functions offsets the temporary register indices by the number
+ * of input registers, because input registers are actually temporaries and
+ * should not occupy the same space.
+ *
+ * This pass is supposed to be used to maintain correct allocation of inputs
+ * if the standard register allocation is disabled. */
+static void do_regalloc_inputs_only(struct regalloc_state * s)
+{
+       for (unsigned i = 0; i < s->NumTemporaries; i++) {
+               s->Temporary[i].Allocated = 1;
+               s->Temporary[i].File = RC_FILE_TEMPORARY;
+               s->Temporary[i].Index = i + s->NumInputs;
+       }
+}
+
+static unsigned int is_derivative(rc_opcode op)
+{
+       return (op == RC_OPCODE_DDX || op == RC_OPCODE_DDY);
+}
+
+static int find_class(
+       struct rc_class * classes,
+       unsigned int writemask,
+       unsigned int max_writemask_count)
+{
+       unsigned int i;
+       for (i = 0; i < RC_REG_CLASS_COUNT; i++) {
+               unsigned int j;
+               if (classes[i].WritemaskCount > max_writemask_count) {
+                       continue;
+               }
+               for (j = 0; j < 3; j++) {
+                       if (classes[i].Writemasks[j] == writemask) {
+                               return i;
+                       }
+               }
+       }
+       return -1;
+}
+
+static enum rc_reg_class variable_get_class(
+       struct rc_variable * variable,
+       struct rc_class * classes)
+{
+       unsigned int i;
+       unsigned int can_change_writemask= 1;
+       unsigned int writemask = rc_variable_writemask_sum(variable);
+       struct rc_list * readers = rc_variable_readers_union(variable);
+       int class_index;
+
+       if (!variable->C->is_r500) {
+               struct rc_class c;
+               /* The assumption here is that if an instruction has type
+                * RC_INSTRUCTION_NORMAL then it is a TEX instruction.
+                * r300 and r400 can't swizzle the result of a TEX lookup. */
+               if (variable->Inst->Type == RC_INSTRUCTION_NORMAL) {
+                       writemask = RC_MASK_XYZW;
+               }
+
+               /* Check if it is possible to do swizzle packing for r300/r400
+                * without creating non-native swizzles. */
+               class_index = find_class(classes, writemask, 3);
+               if (class_index < 0) {
+                       goto error;
+               }
+               c = classes[class_index];
+               for (i = 0; i < c.WritemaskCount; i++) {
+                       int j;
+                       unsigned int conversion_swizzle =
+                                               rc_make_conversion_swizzle(
+                                               writemask, c.Writemasks[i]);
+                       for (j = 0; j < variable->ReaderCount; j++) {
+                               unsigned int old_swizzle;
+                               unsigned int new_swizzle;
+                               struct rc_reader r = variable->Readers[j];
+                               if (r.Inst->Type == RC_INSTRUCTION_PAIR ) {
+                                       old_swizzle = r.U.P.Arg->Swizzle;
+                               } else {
+                                       old_swizzle = r.U.I.Src->Swizzle;
+                               }
+                               new_swizzle = rc_adjust_channels(
+                                       old_swizzle, conversion_swizzle);
+                               if (!r300_swizzle_is_native_basic(new_swizzle)) {
+                                       can_change_writemask = 0;
+                                       break;
+                               }
+                       }
+                       if (!can_change_writemask) {
+                               break;
+                       }
+               }
+       }
+
+       if (variable->Inst->Type == RC_INSTRUCTION_PAIR) {
+               /* DDX/DDY seem to always fail when their writemasks are
+                * changed.*/
+               if (is_derivative(variable->Inst->U.P.RGB.Opcode)
+                   || is_derivative(variable->Inst->U.P.Alpha.Opcode)) {
+                       can_change_writemask = 0;
+               }
+       }
+       for ( ; readers; readers = readers->Next) {
+               struct rc_reader * r = readers->Item;
+               if (r->Inst->Type == RC_INSTRUCTION_PAIR) {
+                       if (r->U.P.Arg->Source == RC_PAIR_PRESUB_SRC) {
+                               can_change_writemask = 0;
+                               break;
+                       }
+                       /* DDX/DDY also fail when their swizzles are changed. */
+                       if (is_derivative(r->Inst->U.P.RGB.Opcode)
+                           || is_derivative(r->Inst->U.P.Alpha.Opcode)) {
+                               can_change_writemask = 0;
+                               break;
+                       }
+               }
+       }
+
+       class_index = find_class(classes, writemask,
+                                               can_change_writemask ? 3 : 1);
+       if (class_index > -1) {
+               return classes[class_index].Class;
+       } else {
+error:
+               rc_error(variable->C,
+                               "Could not find class for index=%u mask=%u\n",
+                               variable->Dst.Index, writemask);
+               return 0;
+       }
+}
+
+static unsigned int overlap_live_intervals_array(
+       struct live_intervals * a,
+       struct live_intervals * b)
+{
+       unsigned int a_chan, b_chan;
+       for (a_chan = 0; a_chan < 4; a_chan++) {
+               for (b_chan = 0; b_chan < 4; b_chan++) {
+                       if (overlap_live_intervals(&a[a_chan], &b[b_chan])) {
+                                       return 1;
+                       }
+               }
+       }
+       return 0;
+}
+
+static unsigned int reg_get_index(int reg)
+{
+       return reg / RC_MASK_XYZW;
+}
+
+static unsigned int reg_get_writemask(int reg)
+{
+       return (reg % RC_MASK_XYZW) + 1;
+}
+
+static int get_reg_id(unsigned int index, unsigned int writemask)
+{
+       assert(writemask);
+       if (writemask == 0) {
+               return 0;
+       }
+       return (index * RC_MASK_XYZW) + (writemask - 1);
+}
+
+#if VERBOSE
+static void print_reg(int reg)
+{
+       unsigned int index = reg_get_index(reg);
+       unsigned int mask = reg_get_writemask(reg);
+       fprintf(stderr, "Temp[%u].%c%c%c%c", index,
+               mask & RC_MASK_X ? 'x' : '_',
+               mask & RC_MASK_Y ? 'y' : '_',
+               mask & RC_MASK_Z ? 'z' : '_',
+               mask & RC_MASK_W ? 'w' : '_');
+}
+#endif
+
+static void add_register_conflicts(
+       struct ra_regs * regs,
+       unsigned int max_temp_regs)
+{
+       unsigned int index, a_mask, b_mask;
+       for (index = 0; index < max_temp_regs; index++) {
+               for(a_mask = 1; a_mask <= RC_MASK_XYZW; a_mask++) {
+                       for (b_mask = a_mask + 1; b_mask <= RC_MASK_XYZW;
+                                                               b_mask++) {
+                               if (a_mask & b_mask) {
+                                       ra_add_reg_conflict(regs,
+                                               get_reg_id(index, a_mask),
+                                               get_reg_id(index, b_mask));
+                               }
+                       }
+               }
+       }
+}
+
+static void do_advanced_regalloc(struct regalloc_state * s)
+{
+       struct rc_class rc_class_list [] = {
+               {RC_REG_CLASS_SINGLE, 3, 0, 0,
+                       {RC_MASK_X,
+                        RC_MASK_Y,
+                        RC_MASK_Z}},
+               {RC_REG_CLASS_DOUBLE, 3, 0, 0,
+                       {RC_MASK_X | RC_MASK_Y,
+                        RC_MASK_X | RC_MASK_Z,
+                        RC_MASK_Y | RC_MASK_Z}},
+               {RC_REG_CLASS_TRIPLE, 1, 0, 0,
+                       {RC_MASK_X | RC_MASK_Y | RC_MASK_Z,
+                        RC_MASK_NONE,
+                        RC_MASK_NONE}},
+               {RC_REG_CLASS_ALPHA, 1, 0, 0,
+                       {RC_MASK_W,
+                        RC_MASK_NONE,
+                        RC_MASK_NONE}},
+               {RC_REG_CLASS_SINGLE_PLUS_ALPHA, 3, 0, 0,
+                       {RC_MASK_X | RC_MASK_W,
+                        RC_MASK_Y | RC_MASK_W,
+                        RC_MASK_Z | RC_MASK_W}},
+               {RC_REG_CLASS_DOUBLE_PLUS_ALPHA, 3, 0, 0,
+                       {RC_MASK_X | RC_MASK_Y | RC_MASK_W,
+                        RC_MASK_X | RC_MASK_Z | RC_MASK_W,
+                        RC_MASK_Y | RC_MASK_Z | RC_MASK_W}},
+               {RC_REG_CLASS_TRIPLE_PLUS_ALPHA, 1, 0, 0,
+                       {RC_MASK_X | RC_MASK_Y | RC_MASK_Z | RC_MASK_W,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_X, 1, 0, 0,
+                       {RC_MASK_X,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_Y, 1, 0, 0,
+                       {RC_MASK_Y,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_Z, 1, 0, 0,
+                       {RC_MASK_Z,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_XY, 1, 0, 0,
+                       {RC_MASK_X | RC_MASK_Y,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_YZ, 1, 0, 0,
+                       {RC_MASK_Y | RC_MASK_Z,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_XZ, 1, 0, 0,
+                       {RC_MASK_X | RC_MASK_Z,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_XW, 1, 0, 0,
+                       {RC_MASK_X | RC_MASK_W,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_YW, 1, 0, 0,
+                       {RC_MASK_Y | RC_MASK_W,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_ZW, 1, 0, 0,
+                       {RC_MASK_Z | RC_MASK_W,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_XYW, 1, 0, 0,
+                       {RC_MASK_X | RC_MASK_Y | RC_MASK_W,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_YZW, 1, 0, 0,
+                       {RC_MASK_Y | RC_MASK_Z | RC_MASK_W,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}},
+               {RC_REG_CLASS_XZW, 1, 0, 0,
+                       {RC_MASK_X | RC_MASK_Z | RC_MASK_W,
+                       RC_MASK_NONE,
+                       RC_MASK_NONE}}
+       };
+
+       unsigned int i, j, index, input_node, node_count, node_index;
+       unsigned int * node_classes;
+       unsigned int * input_classes;
+       struct rc_instruction * inst;
+       struct rc_list * var_ptr;
+       struct rc_list * variables;
+       struct ra_regs * regs;
+       struct ra_graph * graph;
+
+       /* Allocate the main ra data structure */
+       regs = ra_alloc_reg_set(s->C->max_temp_regs * RC_MASK_XYZW);
+
+       /* Get list of program variables */
+       variables = rc_get_variables(s->C);
+       node_count = rc_list_count(variables);
+       node_classes = memory_pool_malloc(&s->C->Pool,
+                       node_count * sizeof(unsigned int));
+       input_classes = memory_pool_malloc(&s->C->Pool,
+                       s->NumInputs * sizeof(unsigned int));
+
+       for (var_ptr = variables, node_index = 0; var_ptr;
+                                       var_ptr = var_ptr->Next, node_index++) {
+               unsigned int class_index;
+               /* Compute the live intervals */
+               rc_variable_compute_live_intervals(var_ptr->Item);
+
+               class_index = variable_get_class(var_ptr->Item, rc_class_list);
+
+               /* If we haven't used this register class yet, mark it
+                * as used and allocate space for it. */
+               if (!rc_class_list[class_index].Used) {
+                       rc_class_list[class_index].Used = 1;
+                       rc_class_list[class_index].Id = ra_alloc_reg_class(regs);
+               }
+
+               node_classes[node_index] = rc_class_list[class_index].Id;
+       }
+
+
+       /* Assign registers to the classes */
+       for (i = 0; i < RC_REG_CLASS_COUNT; i++) {
+               struct rc_class class = rc_class_list[i];
+               if (!class.Used) {
+                       continue;
+               }
+
+               for (index = 0; index < s->C->max_temp_regs; index++) {
+                       for (j = 0; j < class.WritemaskCount; j++) {
+                               int reg_id = get_reg_id(index,
+                                                       class.Writemasks[j]);
+                               ra_class_add_reg(regs, class.Id, reg_id);
+                       }
+               }
+       }
+
+       /* Add register conflicts */
+       add_register_conflicts(regs, s->C->max_temp_regs);
+
+       /* Calculate live intervals for input registers */
+       for (inst = s->C->Program.Instructions.Next;
+                                       inst != &s->C->Program.Instructions;
+                                       inst = inst->Next) {
+               rc_opcode op = rc_get_flow_control_inst(inst);
+               if (op == RC_OPCODE_BGNLOOP) {
+                       struct rc_instruction * endloop =
+                                                       rc_match_bgnloop(inst);
+                       if (endloop->IP > s->LoopEnd) {
+                               s->LoopEnd = endloop->IP;
+                       }
+               }
+               rc_for_all_reads_mask(inst, scan_read_callback, s);
+       }
+
+       /* Create classes for input registers */
+       for (i = 0; i < s->NumInputs; i++) {
+               unsigned int chan, class_id, writemask = 0;
+               for (chan = 0; chan < 4; chan++) {
+                       if (s->Input[i].Live[chan].Used) {
+                               writemask |= (1 << chan);
+                       }
+               }
+               s->Input[i].Writemask = writemask;
+               if (!writemask) {
+                       continue;
+               }
+
+               class_id = ra_alloc_reg_class(regs);
+               input_classes[i] = class_id;
+               ra_class_add_reg(regs, class_id,
+                               get_reg_id(s->Input[i].Index, writemask));
+       }
+
+       ra_set_finalize(regs);
+
+       graph = ra_alloc_interference_graph(regs, node_count + s->NumInputs);
+
+       /* Build the interference graph */
+       for (var_ptr = variables, node_index = 0; var_ptr;
+                                       var_ptr = var_ptr->Next,node_index++) {
+               struct rc_list * a, * b;
+               unsigned int b_index;
+
+               ra_set_node_class(graph, node_index, node_classes[node_index]);
+
+               for (a = var_ptr, b = var_ptr->Next, b_index = node_index + 1;
+                                               b; b = b->Next, b_index++) {
+                       struct rc_variable * var_a = a->Item;
+                       while (var_a) {
+                               struct rc_variable * var_b = b->Item;
+                               while (var_b) {
+                                       if (overlap_live_intervals_array(var_a->Live, var_b->Live)) {
+                                               ra_add_node_interference(graph,
+                                                       node_index, b_index);
+                                       }
+                                       var_b = var_b->Friend;
+                               }
+                               var_a = var_a->Friend;
+                       }
+               }
+       }
+
+       /* Add input registers to the interference graph */
+       for (i = 0, input_node = 0; i< s->NumInputs; i++) {
+               if (!s->Input[i].Writemask) {
+                       continue;
+               }
+               ra_set_node_class(graph, node_count + input_node,
+                                                       input_classes[i]);
+               for (var_ptr = variables, node_index = 0;
+                               var_ptr; var_ptr = var_ptr->Next, node_index++) {
+                       struct rc_variable * var = var_ptr->Item;
+                       if (overlap_live_intervals_array(s->Input[i].Live,
+                                                               var->Live)) {
+                               ra_add_node_interference(graph, node_index,
+                                               node_count + input_node);
+                       }
+               }
+               /* Manually allocate a register for this input */
+               ra_set_node_reg(graph, node_count + input_node, get_reg_id(
+                               s->Input[i].Index, s->Input[i].Writemask));
+               input_node++;
+       }
+
+       if (!ra_allocate_no_spills(graph)) {
+               rc_error(s->C, "Ran out of hardware temporaries\n");
+               return;
+       }
+
+       /* Rewrite the registers */
+       for (var_ptr = variables, node_index = 0; var_ptr;
+                               var_ptr = var_ptr->Next, node_index++) {
+               int reg = ra_get_node_reg(graph, node_index);
+               unsigned int writemask = reg_get_writemask(reg);
+               unsigned int index = reg_get_index(reg);
+               struct rc_variable * var = var_ptr->Item;
+
+               if (!s->C->is_r500 && var->Inst->Type == RC_INSTRUCTION_NORMAL) {
+                       writemask = rc_variable_writemask_sum(var);
+               }
+
+               if (var->Dst.File == RC_FILE_INPUT) {
+                       continue;
+               }
+               rc_variable_change_dst(var, index, writemask);
+       }
+
+       ralloc_free(graph);
+       ralloc_free(regs);
+}
+
+/**
+ * @param user This parameter should be a pointer to an integer value.  If this
+ * integer value is zero, then a simple register allocator will be used that
+ * only allocates space for input registers (\sa do_regalloc_inputs_only).  If
+ * user is non-zero, then the regular register allocator will be used
+ * (\sa do_regalloc).
+  */
+void rc_pair_regalloc(struct radeon_compiler *cc, void *user)
+{
+       struct r300_fragment_program_compiler *c =
+                               (struct r300_fragment_program_compiler*)cc;
+       struct regalloc_state s;
+       int * do_full_regalloc = (int*)user;
+
+       memset(&s, 0, sizeof(s));
+       s.C = cc;
+       s.NumInputs = rc_get_max_index(cc, RC_FILE_INPUT) + 1;
+       s.Input = memory_pool_malloc(&cc->Pool,
+                       s.NumInputs * sizeof(struct register_info));
+       memset(s.Input, 0, s.NumInputs * sizeof(struct register_info));
+
+       s.NumTemporaries = rc_get_max_index(cc, RC_FILE_TEMPORARY) + 1;
+       s.Temporary = memory_pool_malloc(&cc->Pool,
+                       s.NumTemporaries * sizeof(struct register_info));
+       memset(s.Temporary, 0, s.NumTemporaries * sizeof(struct register_info));
+
+       rc_recompute_ips(s.C);
+
+       c->AllocateHwInputs(c, &alloc_input_simple, &s);
+       if (*do_full_regalloc) {
+               do_advanced_regalloc(&s);
+       } else {
+               s.Simple = 1;
+               do_regalloc_inputs_only(&s);
+       }
+
+       /* Rewrite inputs and if we are doing the simple allocation, rewrite
+        * temporaries too. */
+       for (struct rc_instruction *inst = s.C->Program.Instructions.Next;
+                                       inst != &s.C->Program.Instructions;
+                                       inst = inst->Next) {
+               rc_remap_registers(inst, &remap_register, &s);
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c b/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c
new file mode 100644 (file)
index 0000000..25cd52c
--- /dev/null
@@ -0,0 +1,1010 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_program_pair.h"
+
+#include <stdio.h>
+
+#include "radeon_compiler.h"
+#include "radeon_compiler_util.h"
+#include "radeon_dataflow.h"
+
+
+#define VERBOSE 0
+
+#define DBG(...) do { if (VERBOSE) fprintf(stderr, __VA_ARGS__); } while(0)
+
+struct schedule_instruction {
+       struct rc_instruction * Instruction;
+
+       /** Next instruction in the linked list of ready instructions. */
+       struct schedule_instruction *NextReady;
+
+       /** Values that this instruction reads and writes */
+       struct reg_value * WriteValues[4];
+       struct reg_value * ReadValues[12];
+       unsigned int NumWriteValues:3;
+       unsigned int NumReadValues:4;
+
+       /**
+        * Number of (read and write) dependencies that must be resolved before
+        * this instruction can be scheduled.
+        */
+       unsigned int NumDependencies:5;
+
+       /** List of all readers (see rc_get_readers() for the definition of
+        * "all readers"), even those outside the basic block this instruction
+        * lives in. */
+       struct rc_reader_data GlobalReaders;
+};
+
+
+/**
+ * Used to keep track of which instructions read a value.
+ */
+struct reg_value_reader {
+       struct schedule_instruction *Reader;
+       struct reg_value_reader *Next;
+};
+
+/**
+ * Used to keep track which values are stored in each component of a
+ * RC_FILE_TEMPORARY.
+ */
+struct reg_value {
+       struct schedule_instruction * Writer;
+
+       /**
+        * Unordered linked list of instructions that read from this value.
+        * When this value becomes available, we increase all readers'
+        * dependency count.
+        */
+       struct reg_value_reader *Readers;
+
+       /**
+        * Number of readers of this value. This is decremented each time
+        * a reader of the value is committed.
+        * When the reader cound reaches zero, the dependency count
+        * of the instruction writing \ref Next is decremented.
+        */
+       unsigned int NumReaders;
+
+       struct reg_value *Next; /**< Pointer to the next value to be written to the same register */
+};
+
+struct register_state {
+       struct reg_value * Values[4];
+};
+
+struct remap_reg {
+       struct rc_instruciont * Inst;
+       unsigned int OldIndex:(RC_REGISTER_INDEX_BITS+1);
+       unsigned int OldSwizzle:3;
+       unsigned int NewIndex:(RC_REGISTER_INDEX_BITS+1);
+       unsigned int NewSwizzle:3;
+       unsigned int OnlyTexReads:1;
+       struct remap_reg * Next;
+};
+
+struct schedule_state {
+       struct radeon_compiler * C;
+       struct schedule_instruction * Current;
+
+       struct register_state Temporary[RC_REGISTER_MAX_INDEX];
+
+       /**
+        * Linked lists of instructions that can be scheduled right now,
+        * based on which ALU/TEX resources they require.
+        */
+       /*@{*/
+       struct schedule_instruction *ReadyFullALU;
+       struct schedule_instruction *ReadyRGB;
+       struct schedule_instruction *ReadyAlpha;
+       struct schedule_instruction *ReadyTEX;
+       /*@}*/
+};
+
+static struct reg_value ** get_reg_valuep(struct schedule_state * s,
+               rc_register_file file, unsigned int index, unsigned int chan)
+{
+       if (file != RC_FILE_TEMPORARY)
+               return 0;
+
+       if (index >= RC_REGISTER_MAX_INDEX) {
+               rc_error(s->C, "%s: index %i out of bounds\n", __FUNCTION__, index);
+               return 0;
+       }
+
+       return &s->Temporary[index].Values[chan];
+}
+
+static void add_inst_to_list(struct schedule_instruction ** list, struct schedule_instruction * inst)
+{
+       inst->NextReady = *list;
+       *list = inst;
+}
+
+static void add_inst_to_list_end(struct schedule_instruction ** list,
+                                       struct schedule_instruction * inst)
+{
+       if(!*list){
+               *list = inst;
+       }else{
+               struct schedule_instruction * temp = *list;
+               while(temp->NextReady){
+                       temp = temp->NextReady;
+               }
+               temp->NextReady = inst;
+       }
+}
+
+static void instruction_ready(struct schedule_state * s, struct schedule_instruction * sinst)
+{
+       DBG("%i is now ready\n", sinst->Instruction->IP);
+
+       /* Adding Ready TEX instructions to the end of the "Ready List" helps
+        * us emit TEX instructions in blocks without losing our place. */
+       if (sinst->Instruction->Type == RC_INSTRUCTION_NORMAL)
+               add_inst_to_list_end(&s->ReadyTEX, sinst);
+       else if (sinst->Instruction->U.P.Alpha.Opcode == RC_OPCODE_NOP)
+               add_inst_to_list(&s->ReadyRGB, sinst);
+       else if (sinst->Instruction->U.P.RGB.Opcode == RC_OPCODE_NOP)
+               add_inst_to_list(&s->ReadyAlpha, sinst);
+       else
+               add_inst_to_list(&s->ReadyFullALU, sinst);
+}
+
+static void decrease_dependencies(struct schedule_state * s, struct schedule_instruction * sinst)
+{
+       assert(sinst->NumDependencies > 0);
+       sinst->NumDependencies--;
+       if (!sinst->NumDependencies)
+               instruction_ready(s, sinst);
+}
+
+/**
+ * This function decreases the dependencies of the next instruction that
+ * wants to write to each of sinst's read values.
+ */
+static void commit_update_reads(struct schedule_state * s,
+                                       struct schedule_instruction * sinst){
+       unsigned int i;
+       for(i = 0; i < sinst->NumReadValues; ++i) {
+               struct reg_value * v = sinst->ReadValues[i];
+               assert(v->NumReaders > 0);
+               v->NumReaders--;
+               if (!v->NumReaders) {
+                       if (v->Next)
+                               decrease_dependencies(s, v->Next->Writer);
+               }
+       }
+}
+
+static void commit_update_writes(struct schedule_state * s,
+                                       struct schedule_instruction * sinst){
+       unsigned int i;
+       for(i = 0; i < sinst->NumWriteValues; ++i) {
+               struct reg_value * v = sinst->WriteValues[i];
+               if (v->NumReaders) {
+                       for(struct reg_value_reader * r = v->Readers; r; r = r->Next) {
+                               decrease_dependencies(s, r->Reader);
+                       }
+               } else {
+                       /* This happens in instruction sequences of the type
+                        *  OP r.x, ...;
+                        *  OP r.x, r.x, ...;
+                        * See also the subtlety in how instructions that both
+                        * read and write the same register are scanned.
+                        */
+                       if (v->Next)
+                               decrease_dependencies(s, v->Next->Writer);
+               }
+       }
+}
+
+static void commit_alu_instruction(struct schedule_state * s, struct schedule_instruction * sinst)
+{
+       DBG("%i: commit\n", sinst->Instruction->IP);
+
+       commit_update_reads(s, sinst);
+
+       commit_update_writes(s, sinst);
+}
+
+/**
+ * Emit all ready texture instructions in a single block.
+ *
+ * Emit as a single block to (hopefully) sample many textures in parallel,
+ * and to avoid hardware indirections on R300.
+ */
+static void emit_all_tex(struct schedule_state * s, struct rc_instruction * before)
+{
+       struct schedule_instruction *readytex;
+       struct rc_instruction * inst_begin;
+
+       assert(s->ReadyTEX);
+
+       /* Node marker for R300 */
+       inst_begin = rc_insert_new_instruction(s->C, before->Prev);
+       inst_begin->U.I.Opcode = RC_OPCODE_BEGIN_TEX;
+
+       /* Link texture instructions back in */
+       readytex = s->ReadyTEX;
+       while(readytex) {
+               rc_insert_instruction(before->Prev, readytex->Instruction);
+               DBG("%i: commit TEX reads\n", readytex->Instruction->IP);
+
+               /* All of the TEX instructions in the same TEX block have
+                * their source registers read from before any of the
+                * instructions in that block write to their destination
+                * registers.  This means that when we commit a TEX
+                * instruction, any other TEX instruction that wants to write
+                * to one of the committed instruction's source register can be
+                * marked as ready and should be emitted in the same TEX
+                * block. This prevents the following sequence from being
+                * emitted in two different TEX blocks:
+                * 0: TEX temp[0].xyz, temp[1].xy__, 2D[0];
+                * 1: TEX temp[1].xyz, temp[2].xy__, 2D[0];
+                */
+               commit_update_reads(s, readytex);
+               readytex = readytex->NextReady;
+       }
+       readytex = s->ReadyTEX;
+       s->ReadyTEX = 0;
+       while(readytex){
+               DBG("%i: commit TEX writes\n", readytex->Instruction->IP);
+               commit_update_writes(s, readytex);
+               readytex = readytex->NextReady;
+       }
+}
+
+/* This is a helper function for destructive_merge_instructions().  It helps
+ * merge presubtract sources from two instructions and makes sure the
+ * presubtract sources end up in the correct spot.  This function assumes that
+ * dst_full is an rgb instruction, meaning that it has a vector instruction(rgb)
+ * but no scalar instruction (alpha).
+ * @return 0 if merging the presubtract sources fails.
+ * @retrun 1 if merging the presubtract sources succeeds.
+ */
+static int merge_presub_sources(
+       struct rc_pair_instruction * dst_full,
+       struct rc_pair_sub_instruction src,
+       unsigned int type)
+{
+       unsigned int srcp_src, srcp_regs, is_rgb, is_alpha;
+       struct rc_pair_sub_instruction * dst_sub;
+       const struct rc_opcode_info * info;
+
+       assert(dst_full->Alpha.Opcode == RC_OPCODE_NOP);
+
+       switch(type) {
+       case RC_SOURCE_RGB:
+               is_rgb = 1;
+               is_alpha = 0;
+               dst_sub = &dst_full->RGB;
+               break;
+       case RC_SOURCE_ALPHA:
+               is_rgb = 0;
+               is_alpha = 1;
+               dst_sub = &dst_full->Alpha;
+               break;
+       default:
+               assert(0);
+               return 0;
+       }
+
+       info = rc_get_opcode_info(dst_full->RGB.Opcode);
+
+       if (dst_sub->Src[RC_PAIR_PRESUB_SRC].Used)
+               return 0;
+
+       srcp_regs = rc_presubtract_src_reg_count(
+                                       src.Src[RC_PAIR_PRESUB_SRC].Index);
+       for(srcp_src = 0; srcp_src < srcp_regs; srcp_src++) {
+               unsigned int arg;
+               int free_source;
+               unsigned int one_way = 0;
+               struct rc_pair_instruction_source srcp = src.Src[srcp_src];
+               struct rc_pair_instruction_source temp;
+
+               free_source = rc_pair_alloc_source(dst_full, is_rgb, is_alpha,
+                                                       srcp.File, srcp.Index);
+
+               /* If free_source < 0 then there are no free source
+                * slots. */
+               if (free_source < 0)
+                       return 0;
+
+               temp = dst_sub->Src[srcp_src];
+               dst_sub->Src[srcp_src] = dst_sub->Src[free_source];
+
+               /* srcp needs src0 and src1 to be the same */
+               if (free_source < srcp_src) {
+                       if (!temp.Used)
+                               continue;
+                       free_source = rc_pair_alloc_source(dst_full, is_rgb,
+                                       is_alpha, temp.File, temp.Index);
+                       if (free_source < 0)
+                               return 0;
+                       one_way = 1;
+               } else {
+                       dst_sub->Src[free_source] = temp;
+               }
+
+               /* If free_source == srcp_src, then the presubtract
+                * source is already in the correct place. */
+               if (free_source == srcp_src)
+                       continue;
+
+               /* Shuffle the sources, so we can put the
+                * presubtract source in the correct place. */
+               for(arg = 0; arg < info->NumSrcRegs; arg++) {
+                       /*If this arg does not read from an rgb source,
+                        * do nothing. */
+                       if (!(rc_source_type_swz(dst_full->RGB.Arg[arg].Swizzle)
+                                                               & type)) {
+                               continue;
+                       }
+
+                       if (dst_full->RGB.Arg[arg].Source == srcp_src)
+                               dst_full->RGB.Arg[arg].Source = free_source;
+                       /* We need to do this just in case register
+                        * is one of the sources already, but in the
+                        * wrong spot. */
+                       else if(dst_full->RGB.Arg[arg].Source == free_source
+                                                       && !one_way) {
+                               dst_full->RGB.Arg[arg].Source = srcp_src;
+                       }
+               }
+       }
+       return 1;
+}
+
+
+/* This function assumes that rgb.Alpha and alpha.RGB are unused */
+static int destructive_merge_instructions(
+               struct rc_pair_instruction * rgb,
+               struct rc_pair_instruction * alpha)
+{
+       const struct rc_opcode_info * opcode;
+
+       assert(rgb->Alpha.Opcode == RC_OPCODE_NOP);
+       assert(alpha->RGB.Opcode == RC_OPCODE_NOP);
+
+       /* Presubtract registers need to be merged first so that registers
+        * needed by the presubtract operation can be placed in src0 and/or
+        * src1. */
+
+       /* Merge the rgb presubtract registers. */
+       if (alpha->RGB.Src[RC_PAIR_PRESUB_SRC].Used) {
+               if (!merge_presub_sources(rgb, alpha->RGB, RC_SOURCE_RGB)) {
+                       return 0;
+               }
+       }
+       /* Merge the alpha presubtract registers */
+       if (alpha->Alpha.Src[RC_PAIR_PRESUB_SRC].Used) {
+               if(!merge_presub_sources(rgb,  alpha->Alpha, RC_SOURCE_ALPHA)){
+                       return 0;
+               }
+       }
+
+       /* Copy alpha args into rgb */
+       opcode = rc_get_opcode_info(alpha->Alpha.Opcode);
+
+       for(unsigned int arg = 0; arg < opcode->NumSrcRegs; ++arg) {
+               unsigned int srcrgb = 0;
+               unsigned int srcalpha = 0;
+               unsigned int oldsrc = alpha->Alpha.Arg[arg].Source;
+               rc_register_file file = 0;
+               unsigned int index = 0;
+               int source;
+
+               if (GET_SWZ(alpha->Alpha.Arg[arg].Swizzle, 0) < 3) {
+                       srcrgb = 1;
+                       file = alpha->RGB.Src[oldsrc].File;
+                       index = alpha->RGB.Src[oldsrc].Index;
+               } else if (GET_SWZ(alpha->Alpha.Arg[arg].Swizzle, 0) < 4) {
+                       srcalpha = 1;
+                       file = alpha->Alpha.Src[oldsrc].File;
+                       index = alpha->Alpha.Src[oldsrc].Index;
+               }
+
+               source = rc_pair_alloc_source(rgb, srcrgb, srcalpha, file, index);
+               if (source < 0)
+                       return 0;
+
+               rgb->Alpha.Arg[arg].Source = source;
+               rgb->Alpha.Arg[arg].Swizzle = alpha->Alpha.Arg[arg].Swizzle;
+               rgb->Alpha.Arg[arg].Abs = alpha->Alpha.Arg[arg].Abs;
+               rgb->Alpha.Arg[arg].Negate = alpha->Alpha.Arg[arg].Negate;
+       }
+
+       /* Copy alpha opcode into rgb */
+       rgb->Alpha.Opcode = alpha->Alpha.Opcode;
+       rgb->Alpha.DestIndex = alpha->Alpha.DestIndex;
+       rgb->Alpha.WriteMask = alpha->Alpha.WriteMask;
+       rgb->Alpha.OutputWriteMask = alpha->Alpha.OutputWriteMask;
+       rgb->Alpha.DepthWriteMask = alpha->Alpha.DepthWriteMask;
+       rgb->Alpha.Saturate = alpha->Alpha.Saturate;
+
+       /* Merge ALU result writing */
+       if (alpha->WriteALUResult) {
+               if (rgb->WriteALUResult)
+                       return 0;
+
+               rgb->WriteALUResult = alpha->WriteALUResult;
+               rgb->ALUResultCompare = alpha->ALUResultCompare;
+       }
+
+       return 1;
+}
+
+/**
+ * Try to merge the given instructions into the rgb instructions.
+ *
+ * Return true on success; on failure, return false, and keep
+ * the instructions untouched.
+ */
+static int merge_instructions(struct rc_pair_instruction * rgb, struct rc_pair_instruction * alpha)
+{
+       struct rc_pair_instruction backup;
+
+       /*Instructions can't write output registers and ALU result at the
+        * same time. */
+       if ((rgb->WriteALUResult && alpha->Alpha.OutputWriteMask)
+               || (rgb->RGB.OutputWriteMask && alpha->WriteALUResult)) {
+               return 0;
+       }
+       memcpy(&backup, rgb, sizeof(struct rc_pair_instruction));
+
+       if (destructive_merge_instructions(rgb, alpha))
+               return 1;
+
+       memcpy(rgb, &backup, sizeof(struct rc_pair_instruction));
+       return 0;
+}
+
+static void presub_nop(struct rc_instruction * emitted) {
+       int prev_rgb_index, prev_alpha_index, i, num_src;
+
+       /* We don't need a nop if the previous instruction is a TEX. */
+       if (emitted->Prev->Type != RC_INSTRUCTION_PAIR) {
+               return;
+       }
+       if (emitted->Prev->U.P.RGB.WriteMask)
+               prev_rgb_index = emitted->Prev->U.P.RGB.DestIndex;
+       else
+               prev_rgb_index = -1;
+       if (emitted->Prev->U.P.Alpha.WriteMask)
+               prev_alpha_index = emitted->Prev->U.P.Alpha.DestIndex;
+       else
+               prev_alpha_index = 1;
+
+       /* Check the previous rgb instruction */
+       if (emitted->U.P.RGB.Src[RC_PAIR_PRESUB_SRC].Used) {
+               num_src = rc_presubtract_src_reg_count(
+                               emitted->U.P.RGB.Src[RC_PAIR_PRESUB_SRC].Index);
+               for (i = 0; i < num_src; i++) {
+                       unsigned int index = emitted->U.P.RGB.Src[i].Index;
+                       if (emitted->U.P.RGB.Src[i].File == RC_FILE_TEMPORARY
+                           && (index  == prev_rgb_index
+                               || index == prev_alpha_index)) {
+                               emitted->Prev->U.P.Nop = 1;
+                               return;
+                       }
+               }
+       }
+
+       /* Check the previous alpha instruction. */
+       if (!emitted->U.P.Alpha.Src[RC_PAIR_PRESUB_SRC].Used)
+               return;
+
+       num_src = rc_presubtract_src_reg_count(
+                               emitted->U.P.Alpha.Src[RC_PAIR_PRESUB_SRC].Index);
+       for (i = 0; i < num_src; i++) {
+               unsigned int index = emitted->U.P.Alpha.Src[i].Index;
+               if(emitted->U.P.Alpha.Src[i].File == RC_FILE_TEMPORARY
+                  && (index == prev_rgb_index || index == prev_alpha_index)) {
+                       emitted->Prev->U.P.Nop = 1;
+                       return;
+               }
+       }
+}
+
+static void rgb_to_alpha_remap (
+       struct rc_instruction * inst,
+       struct rc_pair_instruction_arg * arg,
+       rc_register_file old_file,
+       rc_swizzle old_swz,
+       unsigned int new_index)
+{
+       int new_src_index;
+       unsigned int i;
+
+       for (i = 0; i < 3; i++) {
+               if (get_swz(arg->Swizzle, i) == old_swz) {
+                       SET_SWZ(arg->Swizzle, i, RC_SWIZZLE_W);
+               }
+       }
+       new_src_index = rc_pair_alloc_source(&inst->U.P, 0, 1,
+                                                       old_file, new_index);
+       /* This conversion is not possible, we must have made a mistake in
+        * is_rgb_to_alpha_possible. */
+       if (new_src_index < 0) {
+               assert(0);
+               return;
+       }
+
+       arg->Source = new_src_index;
+}
+
+static int can_remap(unsigned int opcode)
+{
+       switch(opcode) {
+       case RC_OPCODE_DDX:
+       case RC_OPCODE_DDY:
+               return 0;
+       default:
+               return 1;
+       }
+}
+
+static int can_convert_opcode_to_alpha(unsigned int opcode)
+{
+       switch(opcode) {
+       case RC_OPCODE_DDX:
+       case RC_OPCODE_DDY:
+       case RC_OPCODE_DP2:
+       case RC_OPCODE_DP3:
+       case RC_OPCODE_DP4:
+       case RC_OPCODE_DPH:
+               return 0;
+       default:
+               return 1;
+       }
+}
+
+static void is_rgb_to_alpha_possible(
+       void * userdata,
+       struct rc_instruction * inst,
+       struct rc_pair_instruction_arg * arg,
+       struct rc_pair_instruction_source * src)
+{
+       unsigned int chan_count = 0;
+       unsigned int alpha_sources = 0;
+       unsigned int i;
+       struct rc_reader_data * reader_data = userdata;
+
+       if (!can_remap(inst->U.P.RGB.Opcode)
+           || !can_remap(inst->U.P.Alpha.Opcode)) {
+               reader_data->Abort = 1;
+               return;
+       }
+
+       if (!src)
+               return;
+
+       /* XXX There are some cases where we can still do the conversion if
+        * a reader reads from a presubtract source, but for now we'll prevent
+        * it. */
+       if (arg->Source == RC_PAIR_PRESUB_SRC) {
+               reader_data->Abort = 1;
+               return;
+       }
+
+       /* Make sure the source only reads from one component.
+        * XXX We should allow the source to read from the same component twice.
+        * XXX If the index we will be converting to is the same as the
+        * current index, then it is OK to read from more than one component.
+        */
+       for (i = 0; i < 3; i++) {
+               rc_swizzle swz = get_swz(arg->Swizzle, i);
+               switch(swz) {
+               case RC_SWIZZLE_X:
+               case RC_SWIZZLE_Y:
+               case RC_SWIZZLE_Z:
+               case RC_SWIZZLE_W:
+                       chan_count++;
+                       break;
+               default:
+                       break;
+               }
+       }
+       if (chan_count > 1) {
+               reader_data->Abort = 1;
+               return;
+       }
+
+       /* Make sure there are enough alpha sources.
+        * XXX If we know what register all the readers are going
+        * to be remapped to, then in some situations we can still do
+        * the subsitution, even if all 3 alpha sources are being used.*/
+       for (i = 0; i < 3; i++) {
+               if (inst->U.P.Alpha.Src[i].Used) {
+                       alpha_sources++;
+               }
+       }
+       if (alpha_sources > 2) {
+               reader_data->Abort = 1;
+               return;
+       }
+}
+
+static int convert_rgb_to_alpha(
+       struct schedule_state * s,
+       struct schedule_instruction * sched_inst)
+{
+       struct rc_pair_instruction * pair_inst = &sched_inst->Instruction->U.P;
+       unsigned int old_mask = pair_inst->RGB.WriteMask;
+       unsigned int old_swz = rc_mask_to_swizzle(old_mask);
+       const struct rc_opcode_info * info =
+                               rc_get_opcode_info(pair_inst->RGB.Opcode);
+       int new_index = -1;
+       unsigned int i;
+
+       if (sched_inst->GlobalReaders.Abort)
+               return 0;
+
+       if (!pair_inst->RGB.WriteMask)
+               return 0;
+
+       if (!can_convert_opcode_to_alpha(pair_inst->RGB.Opcode)
+           || !can_convert_opcode_to_alpha(pair_inst->Alpha.Opcode)) {
+               return 0;
+       }
+
+       assert(sched_inst->NumWriteValues == 1);
+
+       if (!sched_inst->WriteValues[0]) {
+               assert(0);
+               return 0;
+       }
+
+       /* We start at the old index, because if we can reuse the same
+        * register and just change the swizzle then it is more likely we
+        * will be able to convert all the readers. */
+       for (i = pair_inst->RGB.DestIndex; i < RC_REGISTER_MAX_INDEX; i++) {
+               struct reg_value ** new_regvalp = get_reg_valuep(
+                                               s, RC_FILE_TEMPORARY, i, 3);
+               if (!*new_regvalp) {
+                       struct reg_value ** old_regvalp =
+                               get_reg_valuep(s,
+                                       RC_FILE_TEMPORARY,
+                                       pair_inst->RGB.DestIndex,
+                                       rc_mask_to_swizzle(old_mask));
+                       new_index = i;
+                       *new_regvalp = *old_regvalp;
+                       *old_regvalp = NULL;
+                       new_regvalp = get_reg_valuep(s, RC_FILE_TEMPORARY, i, 3);
+                       break;
+               }
+       }
+       if (new_index < 0) {
+               return 0;
+       }
+
+       pair_inst->Alpha.Opcode = pair_inst->RGB.Opcode;
+       pair_inst->Alpha.DestIndex = new_index;
+       pair_inst->Alpha.WriteMask = RC_MASK_W;
+       pair_inst->Alpha.Target = pair_inst->RGB.Target;
+       pair_inst->Alpha.OutputWriteMask = pair_inst->RGB.OutputWriteMask;
+       pair_inst->Alpha.DepthWriteMask = pair_inst->RGB.DepthWriteMask;
+       pair_inst->Alpha.Saturate = pair_inst->RGB.Saturate;
+       memcpy(pair_inst->Alpha.Arg, pair_inst->RGB.Arg,
+                                               sizeof(pair_inst->Alpha.Arg));
+       /* Move the swizzles into the first chan */
+       for (i = 0; i < info->NumSrcRegs; i++) {
+               unsigned int j;
+               for (j = 0; j < 3; j++) {
+                       unsigned int swz = get_swz(pair_inst->Alpha.Arg[i].Swizzle, j);
+                       if (swz != RC_SWIZZLE_UNUSED) {
+                               pair_inst->Alpha.Arg[i].Swizzle =
+                                                       rc_init_swizzle(swz, 1);
+                               break;
+                       }
+               }
+       }
+       pair_inst->RGB.Opcode = RC_OPCODE_NOP;
+       pair_inst->RGB.DestIndex = 0;
+       pair_inst->RGB.WriteMask = 0;
+       pair_inst->RGB.Target = 0;
+       pair_inst->RGB.OutputWriteMask = 0;
+       pair_inst->RGB.DepthWriteMask = 0;
+       pair_inst->RGB.Saturate = 0;
+       memset(pair_inst->RGB.Arg, 0, sizeof(pair_inst->RGB.Arg));
+
+       for(i = 0; i < sched_inst->GlobalReaders.ReaderCount; i++) {
+               struct rc_reader reader = sched_inst->GlobalReaders.Readers[i];
+               rgb_to_alpha_remap(reader.Inst, reader.U.P.Arg,
+                                       RC_FILE_TEMPORARY, old_swz, new_index);
+       }
+       return 1;
+}
+
+/**
+ * Find a good ALU instruction or pair of ALU instruction and emit it.
+ *
+ * Prefer emitting full ALU instructions, so that when we reach a point
+ * where no full ALU instruction can be emitted, we have more candidates
+ * for RGB/Alpha pairing.
+ */
+static void emit_one_alu(struct schedule_state *s, struct rc_instruction * before)
+{
+       struct schedule_instruction * sinst;
+
+       if (s->ReadyFullALU) {
+               sinst = s->ReadyFullALU;
+               s->ReadyFullALU = s->ReadyFullALU->NextReady;
+               rc_insert_instruction(before->Prev, sinst->Instruction);
+               commit_alu_instruction(s, sinst);
+       } else {
+               struct schedule_instruction **prgb;
+               struct schedule_instruction **palpha;
+               struct schedule_instruction *prev;
+pair:
+               /* Some pairings might fail because they require too
+                * many source slots; try all possible pairings if necessary */
+               for(prgb = &s->ReadyRGB; *prgb; prgb = &(*prgb)->NextReady) {
+                       for(palpha = &s->ReadyAlpha; *palpha; palpha = &(*palpha)->NextReady) {
+                               struct schedule_instruction * psirgb = *prgb;
+                               struct schedule_instruction * psialpha = *palpha;
+
+                               if (!merge_instructions(&psirgb->Instruction->U.P, &psialpha->Instruction->U.P))
+                                       continue;
+
+                               *prgb = (*prgb)->NextReady;
+                               *palpha = (*palpha)->NextReady;
+                               rc_insert_instruction(before->Prev, psirgb->Instruction);
+                               commit_alu_instruction(s, psirgb);
+                               commit_alu_instruction(s, psialpha);
+                               goto success;
+                       }
+               }
+               prev = NULL;
+               /* No success in pairing, now try to convert one of the RGB
+                * instructions to an Alpha so we can pair it with another RGB.
+                */
+               if (s->ReadyRGB && s->ReadyRGB->NextReady) {
+               for(prgb = &s->ReadyRGB; *prgb; prgb = &(*prgb)->NextReady) {
+                       if ((*prgb)->NumWriteValues == 1) {
+                               struct schedule_instruction * prgb_next;
+                               if (!convert_rgb_to_alpha(s, *prgb))
+                                       goto cont_loop;
+                               prgb_next = (*prgb)->NextReady;
+                               /* Add instruction to the Alpha ready list. */
+                               (*prgb)->NextReady = s->ReadyAlpha;
+                               s->ReadyAlpha = *prgb;
+                               /* Remove instruction from the RGB ready list.*/
+                               if (prev)
+                                       prev->NextReady = prgb_next;
+                               else
+                                       s->ReadyRGB = prgb_next;
+                               goto pair;
+                       }
+cont_loop:
+                       prev = *prgb;
+               }
+               }
+               /* Still no success in pairing, just take the first RGB
+                * or alpha instruction. */
+               if (s->ReadyRGB) {
+                       sinst = s->ReadyRGB;
+                       s->ReadyRGB = s->ReadyRGB->NextReady;
+               } else if (s->ReadyAlpha) {
+                       sinst = s->ReadyAlpha;
+                       s->ReadyAlpha = s->ReadyAlpha->NextReady;
+               } else {
+                       /*XXX Something real bad has happened. */
+                       assert(0);
+               }
+
+               rc_insert_instruction(before->Prev, sinst->Instruction);
+               commit_alu_instruction(s, sinst);
+       success: ;
+       }
+       /* If the instruction we just emitted uses a presubtract value, and
+        * the presubtract sources were written by the previous intstruction,
+        * the previous instruction needs a nop. */
+       presub_nop(before->Prev);
+}
+
+static void scan_read(void * data, struct rc_instruction * inst,
+               rc_register_file file, unsigned int index, unsigned int chan)
+{
+       struct schedule_state * s = data;
+       struct reg_value ** v = get_reg_valuep(s, file, index, chan);
+       struct reg_value_reader * reader;
+
+       if (!v)
+               return;
+
+       if (*v && (*v)->Writer == s->Current) {
+               /* The instruction reads and writes to a register component.
+                * In this case, we only want to increment dependencies by one.
+                */
+               return;
+       }
+
+       DBG("%i: read %i[%i] chan %i\n", s->Current->Instruction->IP, file, index, chan);
+
+       reader = memory_pool_malloc(&s->C->Pool, sizeof(*reader));
+       reader->Reader = s->Current;
+       if (!*v) {
+               /* In this situation, the instruction reads from a register
+                * that hasn't been written to or read from in the current
+                * block. */
+               *v = memory_pool_malloc(&s->C->Pool, sizeof(struct reg_value));
+               memset(*v, 0, sizeof(struct reg_value));
+               (*v)->Readers = reader;
+       } else {
+               reader->Next = (*v)->Readers;
+               (*v)->Readers = reader;
+               /* Only update the current instruction's dependencies if the
+                * register it reads from has been written to in this block. */
+               if ((*v)->Writer) {
+                       s->Current->NumDependencies++;
+               }
+       }
+       (*v)->NumReaders++;
+
+       if (s->Current->NumReadValues >= 12) {
+               rc_error(s->C, "%s: NumReadValues overflow\n", __FUNCTION__);
+       } else {
+               s->Current->ReadValues[s->Current->NumReadValues++] = *v;
+       }
+}
+
+static void scan_write(void * data, struct rc_instruction * inst,
+               rc_register_file file, unsigned int index, unsigned int chan)
+{
+       struct schedule_state * s = data;
+       struct reg_value ** pv = get_reg_valuep(s, file, index, chan);
+       struct reg_value * newv;
+
+       if (!pv)
+               return;
+
+       DBG("%i: write %i[%i] chan %i\n", s->Current->Instruction->IP, file, index, chan);
+
+       newv = memory_pool_malloc(&s->C->Pool, sizeof(*newv));
+       memset(newv, 0, sizeof(*newv));
+
+       newv->Writer = s->Current;
+
+       if (*pv) {
+               (*pv)->Next = newv;
+               s->Current->NumDependencies++;
+       }
+
+       *pv = newv;
+
+       if (s->Current->NumWriteValues >= 4) {
+               rc_error(s->C, "%s: NumWriteValues overflow\n", __FUNCTION__);
+       } else {
+               s->Current->WriteValues[s->Current->NumWriteValues++] = newv;
+       }
+}
+
+static void is_rgb_to_alpha_possible_normal(
+       void * userdata,
+       struct rc_instruction * inst,
+       struct rc_src_register * src)
+{
+       struct rc_reader_data * reader_data = userdata;
+       reader_data->Abort = 1;
+
+}
+
+static void schedule_block(struct r300_fragment_program_compiler * c,
+               struct rc_instruction * begin, struct rc_instruction * end)
+{
+       struct schedule_state s;
+       unsigned int ip;
+
+       memset(&s, 0, sizeof(s));
+       s.C = &c->Base;
+
+       /* Scan instructions for data dependencies */
+       ip = 0;
+       for(struct rc_instruction * inst = begin; inst != end; inst = inst->Next) {
+               s.Current = memory_pool_malloc(&c->Base.Pool, sizeof(*s.Current));
+               memset(s.Current, 0, sizeof(struct schedule_instruction));
+
+               s.Current->Instruction = inst;
+               inst->IP = ip++;
+
+               DBG("%i: Scanning\n", inst->IP);
+
+               /* The order of things here is subtle and maybe slightly
+                * counter-intuitive, to account for the case where an
+                * instruction writes to the same register as it reads
+                * from. */
+               rc_for_all_writes_chan(inst, &scan_write, &s);
+               rc_for_all_reads_chan(inst, &scan_read, &s);
+
+               DBG("%i: Has %i dependencies\n", inst->IP, s.Current->NumDependencies);
+
+               if (!s.Current->NumDependencies)
+                       instruction_ready(&s, s.Current);
+
+               /* Get global readers for possible RGB->Alpha conversion. */
+               s.Current->GlobalReaders.ExitOnAbort = 1;
+               rc_get_readers(s.C, inst, &s.Current->GlobalReaders,
+                               is_rgb_to_alpha_possible_normal,
+                               is_rgb_to_alpha_possible, NULL);
+       }
+
+       /* Temporarily unlink all instructions */
+       begin->Prev->Next = end;
+       end->Prev = begin->Prev;
+
+       /* Schedule instructions back */
+       while(!s.C->Error &&
+             (s.ReadyTEX || s.ReadyRGB || s.ReadyAlpha || s.ReadyFullALU)) {
+               if (s.ReadyTEX)
+                       emit_all_tex(&s, end);
+
+               while(!s.C->Error && (s.ReadyFullALU || s.ReadyRGB || s.ReadyAlpha))
+                       emit_one_alu(&s, end);
+       }
+}
+
+static int is_controlflow(struct rc_instruction * inst)
+{
+       if (inst->Type == RC_INSTRUCTION_NORMAL) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+               return opcode->IsFlowControl;
+       }
+       return 0;
+}
+
+void rc_pair_schedule(struct radeon_compiler *cc, void *user)
+{
+       struct schedule_state s;
+
+       struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)cc;
+       struct rc_instruction * inst = c->Base.Program.Instructions.Next;
+
+       memset(&s, 0, sizeof(s));
+       s.C = &c->Base;
+       while(inst != &c->Base.Program.Instructions) {
+               struct rc_instruction * first;
+
+               if (is_controlflow(inst)) {
+                       inst = inst->Next;
+                       continue;
+               }
+
+               first = inst;
+
+               while(inst != &c->Base.Program.Instructions && !is_controlflow(inst))
+                       inst = inst->Next;
+
+               DBG("Schedule one block\n");
+               schedule_block(c, first, inst);
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_translate.c b/src/gallium/drivers/r300/compiler/radeon_pair_translate.c
new file mode 100644 (file)
index 0000000..2dae56a
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_program_pair.h"
+
+#include "radeon_compiler.h"
+#include "radeon_compiler_util.h"
+
+
+/**
+ * Finally rewrite ADD, MOV, MUL as the appropriate native instruction
+ * and reverse the order of arguments for CMP.
+ */
+static void final_rewrite(struct rc_sub_instruction *inst)
+{
+       struct rc_src_register tmp;
+
+       switch(inst->Opcode) {
+       case RC_OPCODE_ADD:
+               inst->SrcReg[2] = inst->SrcReg[1];
+               inst->SrcReg[1].File = RC_FILE_NONE;
+               inst->SrcReg[1].Swizzle = RC_SWIZZLE_1111;
+               inst->SrcReg[1].Negate = RC_MASK_NONE;
+               inst->Opcode = RC_OPCODE_MAD;
+               break;
+       case RC_OPCODE_CMP:
+               tmp = inst->SrcReg[2];
+               inst->SrcReg[2] = inst->SrcReg[0];
+               inst->SrcReg[0] = tmp;
+               break;
+       case RC_OPCODE_MOV:
+               /* AMD say we should use CMP.
+                * However, when we transform
+                *  KIL -r0;
+                * into
+                *  CMP tmp, -r0, -r0, 0;
+                *  KIL tmp;
+                * we get incorrect behaviour on R500 when r0 == 0.0.
+                * It appears that the R500 KIL hardware treats -0.0 as less
+                * than zero.
+                */
+               inst->SrcReg[1].File = RC_FILE_NONE;
+               inst->SrcReg[1].Swizzle = RC_SWIZZLE_1111;
+               inst->SrcReg[2].File = RC_FILE_NONE;
+               inst->SrcReg[2].Swizzle = RC_SWIZZLE_0000;
+               inst->Opcode = RC_OPCODE_MAD;
+               break;
+       case RC_OPCODE_MUL:
+               inst->SrcReg[2].File = RC_FILE_NONE;
+               inst->SrcReg[2].Swizzle = RC_SWIZZLE_0000;
+               inst->Opcode = RC_OPCODE_MAD;
+               break;
+       default:
+               /* nothing to do */
+               break;
+       }
+}
+
+
+/**
+ * Classify an instruction according to which ALUs etc. it needs
+ */
+static void classify_instruction(struct rc_sub_instruction * inst,
+       int * needrgb, int * needalpha, int * istranscendent)
+{
+       *needrgb = (inst->DstReg.WriteMask & RC_MASK_XYZ) ? 1 : 0;
+       *needalpha = (inst->DstReg.WriteMask & RC_MASK_W) ? 1 : 0;
+       *istranscendent = 0;
+
+       if (inst->WriteALUResult == RC_ALURESULT_X)
+               *needrgb = 1;
+       else if (inst->WriteALUResult == RC_ALURESULT_W)
+               *needalpha = 1;
+
+       switch(inst->Opcode) {
+       case RC_OPCODE_ADD:
+       case RC_OPCODE_CMP:
+       case RC_OPCODE_CND:
+       case RC_OPCODE_DDX:
+       case RC_OPCODE_DDY:
+       case RC_OPCODE_FRC:
+       case RC_OPCODE_MAD:
+       case RC_OPCODE_MAX:
+       case RC_OPCODE_MIN:
+       case RC_OPCODE_MOV:
+       case RC_OPCODE_MUL:
+               break;
+       case RC_OPCODE_COS:
+       case RC_OPCODE_EX2:
+       case RC_OPCODE_LG2:
+       case RC_OPCODE_RCP:
+       case RC_OPCODE_RSQ:
+       case RC_OPCODE_SIN:
+               *istranscendent = 1;
+               *needalpha = 1;
+               break;
+       case RC_OPCODE_DP4:
+               *needalpha = 1;
+               /* fall through */
+       case RC_OPCODE_DP3:
+               *needrgb = 1;
+               break;
+       default:
+               break;
+       }
+}
+
+static void src_uses(struct rc_src_register src, unsigned int * rgb,
+                                                       unsigned int * alpha)
+{
+       int j;
+       for(j = 0; j < 4; ++j) {
+               unsigned int swz = GET_SWZ(src.Swizzle, j);
+               if (swz < 3)
+                       *rgb = 1;
+               else if (swz < 4)
+                       *alpha = 1;
+       }
+}
+
+/**
+ * Fill the given ALU instruction's opcodes and source operands into the given pair,
+ * if possible.
+ */
+static void set_pair_instruction(struct r300_fragment_program_compiler *c,
+       struct rc_pair_instruction * pair,
+       struct rc_sub_instruction * inst)
+{
+       int needrgb, needalpha, istranscendent;
+       const struct rc_opcode_info * opcode;
+       int i;
+
+       memset(pair, 0, sizeof(struct rc_pair_instruction));
+
+       classify_instruction(inst, &needrgb, &needalpha, &istranscendent);
+
+       if (needrgb) {
+               if (istranscendent)
+                       pair->RGB.Opcode = RC_OPCODE_REPL_ALPHA;
+               else
+                       pair->RGB.Opcode = inst->Opcode;
+               if (inst->SaturateMode == RC_SATURATE_ZERO_ONE)
+                       pair->RGB.Saturate = 1;
+       }
+       if (needalpha) {
+               pair->Alpha.Opcode = inst->Opcode;
+               if (inst->SaturateMode == RC_SATURATE_ZERO_ONE)
+                       pair->Alpha.Saturate = 1;
+       }
+
+       opcode = rc_get_opcode_info(inst->Opcode);
+
+       /* Presubtract handling:
+        * We need to make sure that the values used by the presubtract
+        * operation end up in src0 or src1. */
+       if(inst->PreSub.Opcode != RC_PRESUB_NONE) {
+               /* rc_pair_alloc_source() will fill in data for
+                * pair->{RGB,ALPHA}.Src[RC_PAIR_PRESUB_SRC] */
+               int j;
+               for(j = 0; j < 3; j++) {
+                       int src_regs;
+                       if(inst->SrcReg[j].File != RC_FILE_PRESUB)
+                               continue;
+
+                       src_regs = rc_presubtract_src_reg_count(
+                                                       inst->PreSub.Opcode);
+                       for(i = 0; i < src_regs; i++) {
+                               unsigned int rgb = 0;
+                               unsigned int alpha = 0;
+                               src_uses(inst->SrcReg[j], &rgb, &alpha);
+                               if(rgb) {
+                                       pair->RGB.Src[i].File =
+                                               inst->PreSub.SrcReg[i].File;
+                                       pair->RGB.Src[i].Index =
+                                               inst->PreSub.SrcReg[i].Index;
+                                       pair->RGB.Src[i].Used = 1;
+                               }
+                               if(alpha) {
+                                       pair->Alpha.Src[i].File =
+                                               inst->PreSub.SrcReg[i].File;
+                                       pair->Alpha.Src[i].Index =
+                                               inst->PreSub.SrcReg[i].Index;
+                                       pair->Alpha.Src[i].Used = 1;
+                               }
+                       }
+               }
+       }
+
+       for(i = 0; i < opcode->NumSrcRegs; ++i) {
+               int source;
+               if (needrgb && !istranscendent) {
+                       unsigned int srcrgb = 0;
+                       unsigned int srcalpha = 0;
+                       unsigned int srcmask = 0;
+                       int j;
+                       /* We don't care about the alpha channel here.  We only
+                        * want the part of the swizzle that writes to rgb,
+                        * since we are creating an rgb instruction. */
+                       for(j = 0; j < 3; ++j) {
+                               unsigned int swz = GET_SWZ(inst->SrcReg[i].Swizzle, j);
+
+                               if (swz < RC_SWIZZLE_W)
+                                       srcrgb = 1;
+                               else if (swz == RC_SWIZZLE_W)
+                                       srcalpha = 1;
+
+                               if (swz < RC_SWIZZLE_UNUSED)
+                                       srcmask |= 1 << j;
+                       }
+                       source = rc_pair_alloc_source(pair, srcrgb, srcalpha,
+                                                       inst->SrcReg[i].File, inst->SrcReg[i].Index);
+                       if (source < 0) {
+                               rc_error(&c->Base, "Failed to translate "
+                                                       "rgb instruction.\n");
+                               return;
+                       }
+                       pair->RGB.Arg[i].Source = source;
+                       pair->RGB.Arg[i].Swizzle =
+                               rc_init_swizzle(inst->SrcReg[i].Swizzle, 3);
+                       pair->RGB.Arg[i].Abs = inst->SrcReg[i].Abs;
+                       pair->RGB.Arg[i].Negate = !!(srcmask & inst->SrcReg[i].Negate & (RC_MASK_X | RC_MASK_Y | RC_MASK_Z));
+               }
+               if (needalpha) {
+                       unsigned int srcrgb = 0;
+                       unsigned int srcalpha = 0;
+                       unsigned int swz = GET_SWZ(inst->SrcReg[i].Swizzle, istranscendent ? 0 : 3);
+                       if (swz < 3)
+                               srcrgb = 1;
+                       else if (swz < 4)
+                               srcalpha = 1;
+                       source = rc_pair_alloc_source(pair, srcrgb, srcalpha,
+                                                       inst->SrcReg[i].File, inst->SrcReg[i].Index);
+                       if (source < 0) {
+                               rc_error(&c->Base, "Failed to translate "
+                                                       "alpha instruction.\n");
+                               return;
+                       }
+                       pair->Alpha.Arg[i].Source = source;
+                       pair->Alpha.Arg[i].Swizzle = rc_init_swizzle(swz, 1);
+                       pair->Alpha.Arg[i].Abs = inst->SrcReg[i].Abs;
+                       pair->Alpha.Arg[i].Negate = !!(inst->SrcReg[i].Negate & RC_MASK_W);
+               }
+       }
+
+       /* Destination handling */
+       if (inst->DstReg.File == RC_FILE_OUTPUT) {
+        if (inst->DstReg.Index == c->OutputDepth) {
+            pair->Alpha.DepthWriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
+        } else {
+            for (i = 0; i < 4; i++) {
+                if (inst->DstReg.Index == c->OutputColor[i]) {
+                    pair->RGB.Target = i;
+                    pair->Alpha.Target = i;
+                    pair->RGB.OutputWriteMask |=
+                        inst->DstReg.WriteMask & RC_MASK_XYZ;
+                    pair->Alpha.OutputWriteMask |=
+                        GET_BIT(inst->DstReg.WriteMask, 3);
+                    break;
+                }
+            }
+        }
+       } else {
+               if (needrgb) {
+                       pair->RGB.DestIndex = inst->DstReg.Index;
+                       pair->RGB.WriteMask |= inst->DstReg.WriteMask & RC_MASK_XYZ;
+               }
+
+               if (needalpha) {
+                       pair->Alpha.WriteMask |= (GET_BIT(inst->DstReg.WriteMask, 3) << 3);
+                       if (pair->Alpha.WriteMask) {
+                               pair->Alpha.DestIndex = inst->DstReg.Index;
+                       }
+               }
+       }
+
+       if (inst->WriteALUResult) {
+               pair->WriteALUResult = inst->WriteALUResult;
+               pair->ALUResultCompare = inst->ALUResultCompare;
+       }
+}
+
+
+static void check_opcode_support(struct r300_fragment_program_compiler *c,
+                                struct rc_sub_instruction *inst)
+{
+       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Opcode);
+
+       if (opcode->HasDstReg) {
+               if (inst->SaturateMode == RC_SATURATE_MINUS_PLUS_ONE) {
+                       rc_error(&c->Base, "Fragment program does not support signed Saturate.\n");
+                       return;
+               }
+       }
+
+       for (unsigned i = 0; i < opcode->NumSrcRegs; i++) {
+               if (inst->SrcReg[i].RelAddr) {
+                       rc_error(&c->Base, "Fragment program does not support relative addressing "
+                                " of source operands.\n");
+                       return;
+               }
+       }
+}
+
+
+/**
+ * Translate all ALU instructions into corresponding pair instructions,
+ * performing no other changes.
+ */
+void rc_pair_translate(struct radeon_compiler *cc, void *user)
+{
+       struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)cc;
+
+       for(struct rc_instruction * inst = c->Base.Program.Instructions.Next;
+           inst != &c->Base.Program.Instructions;
+           inst = inst->Next) {
+               const struct rc_opcode_info * opcode;
+               struct rc_sub_instruction copy;
+
+               if (inst->Type != RC_INSTRUCTION_NORMAL)
+                       continue;
+
+               opcode = rc_get_opcode_info(inst->U.I.Opcode);
+
+               if (opcode->HasTexture || opcode->IsFlowControl || opcode->Opcode == RC_OPCODE_KIL)
+                       continue;
+
+               copy = inst->U.I;
+
+               check_opcode_support(c, &copy);
+
+               final_rewrite(&copy);
+               inst->Type = RC_INSTRUCTION_PAIR;
+               set_pair_instruction(c, &inst->U.P, &copy);
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_program.c b/src/gallium/drivers/r300/compiler/radeon_program.c
new file mode 100644 (file)
index 0000000..fe5756e
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_program.h"
+
+#include <stdio.h>
+
+#include "radeon_compiler.h"
+#include "radeon_dataflow.h"
+
+
+/**
+ * Transform the given clause in the following way:
+ *  1. Replace it with an empty clause
+ *  2. For every instruction in the original clause, try the given
+ *     transformations in order.
+ *  3. If one of the transformations returns GL_TRUE, assume that it
+ *     has emitted the appropriate instruction(s) into the new clause;
+ *     otherwise, copy the instruction verbatim.
+ *
+ * \note The transformation is currently not recursive; in other words,
+ * instructions emitted by transformations are not transformed.
+ *
+ * \note The transform is called 'local' because it can only look at
+ * one instruction at a time.
+ */
+void rc_local_transform(
+       struct radeon_compiler * c,
+       void *user)
+{
+       struct radeon_program_transformation *transformations =
+               (struct radeon_program_transformation*)user;
+       struct rc_instruction * inst = c->Program.Instructions.Next;
+
+       while(inst != &c->Program.Instructions) {
+               struct rc_instruction * current = inst;
+               int i;
+
+               inst = inst->Next;
+
+               for(i = 0; transformations[i].function; ++i) {
+                       struct radeon_program_transformation* t = transformations + i;
+
+                       if (t->function(c, current, t->userData))
+                               break;
+               }
+       }
+}
+
+struct get_used_temporaries_data {
+       unsigned char * Used;
+       unsigned int UsedLength;
+};
+
+static void get_used_temporaries_cb(
+       void * userdata,
+       struct rc_instruction * inst,
+       rc_register_file file,
+       unsigned int index,
+       unsigned int mask)
+{
+       struct get_used_temporaries_data * d = userdata;
+
+       if (file != RC_FILE_TEMPORARY)
+               return;
+
+       if (index >= d->UsedLength)
+               return;
+
+       d->Used[index] |= mask;
+}
+
+/**
+ * This function fills in the parameter 'used' with a writemask that
+ * represent which components of each temporary register are used by the
+ * program.  This is meant to be combined with rc_find_free_temporary_list as a
+ * more efficient version of rc_find_free_temporary.
+ * @param used The function does not initialize this parameter.
+ */
+void rc_get_used_temporaries(
+       struct radeon_compiler * c,
+       unsigned char * used,
+       unsigned int used_length)
+{
+       struct rc_instruction * inst;
+       struct get_used_temporaries_data d;
+       d.Used = used;
+       d.UsedLength = used_length;
+
+       for(inst = c->Program.Instructions.Next;
+                       inst != &c->Program.Instructions; inst = inst->Next) {
+
+               rc_for_all_reads_mask(inst, get_used_temporaries_cb, &d);
+               rc_for_all_writes_mask(inst, get_used_temporaries_cb, &d);
+       }
+}
+
+/* Search a list of used temporaries for a free one
+ * \sa rc_get_used_temporaries
+ * @note If this functions finds a free temporary, it will mark it as used
+ * in the used temporary list (param 'used')
+ * @param used list of used temporaries
+ * @param used_length number of items in param 'used'
+ * @param mask which components must be free in the temporary index that is
+ * returned.
+ * @return -1 If there are no more free temporaries, otherwise the index of
+ * a temporary register where the components specified in param 'mask' are
+ * not being used.
+ */
+int rc_find_free_temporary_list(
+       struct radeon_compiler * c,
+       unsigned char * used,
+       unsigned int used_length,
+       unsigned int mask)
+{
+       int i;
+       for(i = 0; i < used_length; i++) {
+               if ((~used[i] & mask) == mask) {
+                       used[i] |= mask;
+                       return i;
+               }
+       }
+       return -1;
+}
+
+unsigned int rc_find_free_temporary(struct radeon_compiler * c)
+{
+       unsigned char used[RC_REGISTER_MAX_INDEX];
+       int free;
+
+       memset(used, 0, sizeof(used));
+
+       rc_get_used_temporaries(c, used, RC_REGISTER_MAX_INDEX);
+
+       free = rc_find_free_temporary_list(c, used, RC_REGISTER_MAX_INDEX,
+                                                               RC_MASK_XYZW);
+       if (free < 0) {
+               rc_error(c, "Ran out of temporary registers\n");
+               return 0;
+       }
+       return free;
+}
+
+
+struct rc_instruction *rc_alloc_instruction(struct radeon_compiler * c)
+{
+       struct rc_instruction * inst = memory_pool_malloc(&c->Pool, sizeof(struct rc_instruction));
+
+       memset(inst, 0, sizeof(struct rc_instruction));
+
+       inst->U.I.Opcode = RC_OPCODE_ILLEGAL_OPCODE;
+       inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+       inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZW;
+       inst->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_XYZW;
+       inst->U.I.SrcReg[2].Swizzle = RC_SWIZZLE_XYZW;
+
+       return inst;
+}
+
+void rc_insert_instruction(struct rc_instruction * after, struct rc_instruction * inst)
+{
+       inst->Prev = after;
+       inst->Next = after->Next;
+
+       inst->Prev->Next = inst;
+       inst->Next->Prev = inst;
+}
+
+struct rc_instruction *rc_insert_new_instruction(struct radeon_compiler * c, struct rc_instruction * after)
+{
+       struct rc_instruction * inst = rc_alloc_instruction(c);
+
+       rc_insert_instruction(after, inst);
+
+       return inst;
+}
+
+void rc_remove_instruction(struct rc_instruction * inst)
+{
+       inst->Prev->Next = inst->Next;
+       inst->Next->Prev = inst->Prev;
+}
+
+/**
+ * Return the number of instructions in the program.
+ */
+unsigned int rc_recompute_ips(struct radeon_compiler * c)
+{
+       unsigned int ip = 0;
+       struct rc_instruction * inst;
+
+       for(inst = c->Program.Instructions.Next;
+           inst != &c->Program.Instructions;
+           inst = inst->Next) {
+               inst->IP = ip++;
+       }
+
+       c->Program.Instructions.IP = 0xcafedead;
+
+       return ip;
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_program.h b/src/gallium/drivers/r300/compiler/radeon_program.h
new file mode 100644 (file)
index 0000000..b899ecc
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __RADEON_PROGRAM_H_
+#define __RADEON_PROGRAM_H_
+
+#include <stdint.h>
+#include <string.h>
+
+#include "radeon_opcodes.h"
+#include "radeon_code.h"
+#include "radeon_program_constants.h"
+#include "radeon_program_pair.h"
+
+struct radeon_compiler;
+
+struct rc_src_register {
+       unsigned int File:4;
+
+       /** Negative values may be used for relative addressing. */
+       signed int Index:(RC_REGISTER_INDEX_BITS+1);
+       unsigned int RelAddr:1;
+
+       unsigned int Swizzle:12;
+
+       /** Take the component-wise absolute value */
+       unsigned int Abs:1;
+
+       /** Post-Abs negation. */
+       unsigned int Negate:4;
+};
+
+struct rc_dst_register {
+       unsigned int File:3;
+       unsigned int Index:RC_REGISTER_INDEX_BITS;
+       unsigned int WriteMask:4;
+};
+
+struct rc_presub_instruction {
+       rc_presubtract_op Opcode;
+       struct rc_src_register SrcReg[2];
+};
+
+/**
+ * Instructions are maintained by the compiler in a doubly linked list
+ * of these structures.
+ *
+ * This instruction format is intended to be expanded for hardware-specific
+ * trickery. At different stages of compilation, a different set of
+ * instruction types may be valid.
+ */
+struct rc_sub_instruction {
+       struct rc_src_register SrcReg[3];
+       struct rc_dst_register DstReg;
+
+       /**
+        * Opcode of this instruction, according to \ref rc_opcode enums.
+        */
+       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.
+        */
+       unsigned int SaturateMode:2;
+
+       /**
+        * Writing to the special register RC_SPECIAL_ALU_RESULT
+        */
+       /*@{*/
+       unsigned int WriteALUResult:2;
+       unsigned int ALUResultCompare:3;
+       /*@}*/
+
+       /**
+        * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions.
+        */
+       /*@{*/
+       /** Source texture unit. */
+       unsigned int TexSrcUnit:5;
+
+       /** Source texture target, one of the \ref rc_texture_target enums */
+       unsigned int TexSrcTarget:3;
+
+       /** True if tex instruction should do shadow comparison */
+       unsigned int TexShadow:1;
+
+       /**R500 Only.  How to swizzle the result of a TEX lookup*/
+       unsigned int TexSwizzle:12;
+       /*@}*/
+
+       /** This holds information about the presubtract operation used by
+        * this instruction. */
+       struct rc_presub_instruction PreSub;
+};
+
+typedef enum {
+       RC_INSTRUCTION_NORMAL = 0,
+       RC_INSTRUCTION_PAIR
+} rc_instruction_type;
+
+struct rc_instruction {
+       struct rc_instruction * Prev;
+       struct rc_instruction * Next;
+
+       rc_instruction_type Type;
+       union {
+               struct rc_sub_instruction I;
+               struct rc_pair_instruction P;
+       } U;
+
+       /**
+        * Warning: IPs are not stable. If you want to use them,
+        * you need to recompute them at the beginning of each pass
+        * using \ref rc_recompute_ips
+        */
+       unsigned int IP;
+};
+
+struct rc_program {
+       /**
+        * Instructions.Next points to the first instruction,
+        * Instructions.Prev points to the last instruction.
+        */
+       struct rc_instruction Instructions;
+
+       /* Long term, we should probably remove InputsRead & OutputsWritten,
+        * since updating dependent state can be fragile, and they aren't
+        * actually used very often. */
+       uint32_t InputsRead;
+       uint32_t OutputsWritten;
+       uint32_t ShadowSamplers; /**< Texture units used for shadow sampling. */
+
+       struct rc_constant_list Constants;
+};
+
+/**
+ * A transformation that can be passed to \ref rc_local_transform.
+ *
+ * The function will be called once for each instruction.
+ * It has to either emit the appropriate transformed code for the instruction
+ * and return true, or return false if it doesn't understand the
+ * instruction.
+ *
+ * The function gets passed the userData as last parameter.
+ */
+struct radeon_program_transformation {
+       int (*function)(
+               struct radeon_compiler*,
+               struct rc_instruction*,
+               void*);
+       void *userData;
+};
+
+void rc_local_transform(
+       struct radeon_compiler *c,
+       void *user);
+
+void rc_get_used_temporaries(
+       struct radeon_compiler * c,
+       unsigned char * used,
+       unsigned int used_length);
+
+int rc_find_free_temporary_list(
+       struct radeon_compiler * c,
+       unsigned char * used,
+       unsigned int used_length,
+       unsigned int mask);
+
+unsigned int rc_find_free_temporary(struct radeon_compiler * c);
+
+struct rc_instruction *rc_alloc_instruction(struct radeon_compiler * c);
+struct rc_instruction *rc_insert_new_instruction(struct radeon_compiler * c, struct rc_instruction * after);
+void rc_insert_instruction(struct rc_instruction * after, struct rc_instruction * inst);
+void rc_remove_instruction(struct rc_instruction * inst);
+
+unsigned int rc_recompute_ips(struct radeon_compiler * c);
+
+void rc_print_program(const struct rc_program *prog);
+
+rc_swizzle rc_mask_to_swizzle(unsigned int mask);
+#endif
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.c b/src/gallium/drivers/r300/compiler/radeon_program_alu.c
new file mode 100644 (file)
index 0000000..9fc9911
--- /dev/null
@@ -0,0 +1,1154 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * @file
+ *
+ * Shareable transformations that transform "special" ALU instructions
+ * into ALU instructions that are supported by hardware.
+ *
+ */
+
+#include "radeon_program_alu.h"
+
+#include "radeon_compiler.h"
+#include "radeon_compiler_util.h"
+
+
+static struct rc_instruction *emit1(
+       struct radeon_compiler * c, struct rc_instruction * after,
+       rc_opcode Opcode, rc_saturate_mode Saturate, struct rc_dst_register DstReg,
+       struct rc_src_register SrcReg)
+{
+       struct rc_instruction *fpi = rc_insert_new_instruction(c, after);
+
+       fpi->U.I.Opcode = Opcode;
+       fpi->U.I.SaturateMode = Saturate;
+       fpi->U.I.DstReg = DstReg;
+       fpi->U.I.SrcReg[0] = SrcReg;
+       return fpi;
+}
+
+static struct rc_instruction *emit2(
+       struct radeon_compiler * c, struct rc_instruction * after,
+       rc_opcode Opcode, rc_saturate_mode Saturate, struct rc_dst_register DstReg,
+       struct rc_src_register SrcReg0, struct rc_src_register SrcReg1)
+{
+       struct rc_instruction *fpi = rc_insert_new_instruction(c, after);
+
+       fpi->U.I.Opcode = Opcode;
+       fpi->U.I.SaturateMode = Saturate;
+       fpi->U.I.DstReg = DstReg;
+       fpi->U.I.SrcReg[0] = SrcReg0;
+       fpi->U.I.SrcReg[1] = SrcReg1;
+       return fpi;
+}
+
+static struct rc_instruction *emit3(
+       struct radeon_compiler * c, struct rc_instruction * after,
+       rc_opcode Opcode, rc_saturate_mode Saturate, struct rc_dst_register DstReg,
+       struct rc_src_register SrcReg0, struct rc_src_register SrcReg1,
+       struct rc_src_register SrcReg2)
+{
+       struct rc_instruction *fpi = rc_insert_new_instruction(c, after);
+
+       fpi->U.I.Opcode = Opcode;
+       fpi->U.I.SaturateMode = Saturate;
+       fpi->U.I.DstReg = DstReg;
+       fpi->U.I.SrcReg[0] = SrcReg0;
+       fpi->U.I.SrcReg[1] = SrcReg1;
+       fpi->U.I.SrcReg[2] = SrcReg2;
+       return fpi;
+}
+
+static struct rc_dst_register dstregtmpmask(int index, int mask)
+{
+       struct rc_dst_register dst = {0};
+       dst.File = RC_FILE_TEMPORARY;
+       dst.Index = index;
+       dst.WriteMask = mask;
+       return dst;
+}
+
+static const struct rc_src_register builtin_zero = {
+       .File = RC_FILE_NONE,
+       .Index = 0,
+       .Swizzle = RC_SWIZZLE_0000
+};
+static const struct rc_src_register builtin_one = {
+       .File = RC_FILE_NONE,
+       .Index = 0,
+       .Swizzle = RC_SWIZZLE_1111
+};
+static const struct rc_src_register srcreg_undefined = {
+       .File = RC_FILE_NONE,
+       .Index = 0,
+       .Swizzle = RC_SWIZZLE_XYZW
+};
+
+static struct rc_src_register srcreg(int file, int index)
+{
+       struct rc_src_register src = srcreg_undefined;
+       src.File = file;
+       src.Index = index;
+       return src;
+}
+
+static struct rc_src_register srcregswz(int file, int index, int swz)
+{
+       struct rc_src_register src = srcreg_undefined;
+       src.File = file;
+       src.Index = index;
+       src.Swizzle = swz;
+       return src;
+}
+
+static struct rc_src_register absolute(struct rc_src_register reg)
+{
+       struct rc_src_register newreg = reg;
+       newreg.Abs = 1;
+       newreg.Negate = RC_MASK_NONE;
+       return newreg;
+}
+
+static struct rc_src_register negate(struct rc_src_register reg)
+{
+       struct rc_src_register newreg = reg;
+       newreg.Negate = newreg.Negate ^ RC_MASK_XYZW;
+       return newreg;
+}
+
+static struct rc_src_register swizzle(struct rc_src_register reg,
+               rc_swizzle x, rc_swizzle y, rc_swizzle z, rc_swizzle w)
+{
+       struct rc_src_register swizzled = reg;
+       swizzled.Swizzle = combine_swizzles4(reg.Swizzle, x, y, z, w);
+       return swizzled;
+}
+
+static struct rc_src_register swizzle_smear(struct rc_src_register reg,
+               rc_swizzle x)
+{
+       return swizzle(reg, x, x, x, x);
+}
+
+static struct rc_src_register swizzle_xxxx(struct rc_src_register reg)
+{
+       return swizzle_smear(reg, RC_SWIZZLE_X);
+}
+
+static struct rc_src_register swizzle_yyyy(struct rc_src_register reg)
+{
+       return swizzle_smear(reg, RC_SWIZZLE_Y);
+}
+
+static struct rc_src_register swizzle_zzzz(struct rc_src_register reg)
+{
+       return swizzle_smear(reg, RC_SWIZZLE_Z);
+}
+
+static struct rc_src_register swizzle_wwww(struct rc_src_register reg)
+{
+       return swizzle_smear(reg, RC_SWIZZLE_W);
+}
+
+static int is_dst_safe_to_reuse(struct rc_instruction *inst)
+{
+       const struct rc_opcode_info *info = rc_get_opcode_info(inst->U.I.Opcode);
+       unsigned i;
+
+       assert(info->HasDstReg);
+
+       if (inst->U.I.DstReg.File != RC_FILE_TEMPORARY)
+               return 0;
+
+       for (i = 0; i < info->NumSrcRegs; i++) {
+               if (inst->U.I.SrcReg[i].File == RC_FILE_TEMPORARY &&
+                   inst->U.I.SrcReg[i].Index == inst->U.I.DstReg.Index)
+                       return 0;
+       }
+
+       return 1;
+}
+
+static struct rc_dst_register try_to_reuse_dst(struct radeon_compiler *c,
+                                              struct rc_instruction *inst)
+{
+       unsigned tmp;
+
+       if (is_dst_safe_to_reuse(inst))
+               tmp = inst->U.I.DstReg.Index;
+       else
+               tmp = rc_find_free_temporary(c);
+
+       return dstregtmpmask(tmp, inst->U.I.DstReg.WriteMask);
+}
+
+static void transform_ABS(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_src_register src = inst->U.I.SrcReg[0];
+       src.Abs = 1;
+       src.Negate = RC_MASK_NONE;
+       emit1(c, inst->Prev, RC_OPCODE_MOV, inst->U.I.SaturateMode, inst->U.I.DstReg, src);
+       rc_remove_instruction(inst);
+}
+
+static void transform_CEIL(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       /* Assuming:
+        *     ceil(x) = -floor(-x)
+        *
+        * After inlining floor:
+        *     ceil(x) = -(-x-frac(-x))
+        *
+        * After simplification:
+        *     ceil(x) = x+frac(-x)
+        */
+
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+       emit1(c, inst->Prev, RC_OPCODE_FRC, 0, dst, negate(inst->U.I.SrcReg[0]));
+       emit2(c, inst->Prev, RC_OPCODE_ADD, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               inst->U.I.SrcReg[0], srcreg(RC_FILE_TEMPORARY, dst.Index));
+       rc_remove_instruction(inst);
+}
+
+static void transform_CLAMP(struct radeon_compiler *c,
+       struct rc_instruction *inst)
+{
+       /* CLAMP dst, src, min, max
+        *    into:
+        * MIN tmp, src, max
+        * MAX dst, tmp, min
+        */
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+       emit2(c, inst->Prev, RC_OPCODE_MIN, 0, dst,
+               inst->U.I.SrcReg[0], inst->U.I.SrcReg[2]);
+       emit2(c, inst->Prev, RC_OPCODE_MAX, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               srcreg(RC_FILE_TEMPORARY, dst.Index), inst->U.I.SrcReg[1]);
+       rc_remove_instruction(inst);
+}
+
+static void transform_DP2(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_src_register src0 = inst->U.I.SrcReg[0];
+       struct rc_src_register src1 = inst->U.I.SrcReg[1];
+       src0.Negate &= ~(RC_MASK_Z | RC_MASK_W);
+       src0.Swizzle &= ~(63 << (3 * 2));
+       src0.Swizzle |= (RC_SWIZZLE_ZERO << (3 * 2)) | (RC_SWIZZLE_ZERO << (3 * 3));
+       src1.Negate &= ~(RC_MASK_Z | RC_MASK_W);
+       src1.Swizzle &= ~(63 << (3 * 2));
+       src1.Swizzle |= (RC_SWIZZLE_ZERO << (3 * 2)) | (RC_SWIZZLE_ZERO << (3 * 3));
+       emit2(c, inst->Prev, RC_OPCODE_DP3, inst->U.I.SaturateMode, inst->U.I.DstReg, src0, src1);
+       rc_remove_instruction(inst);
+}
+
+static void transform_DPH(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_src_register src0 = inst->U.I.SrcReg[0];
+       src0.Negate &= ~RC_MASK_W;
+       src0.Swizzle &= ~(7 << (3 * 3));
+       src0.Swizzle |= RC_SWIZZLE_ONE << (3 * 3);
+       emit2(c, inst->Prev, RC_OPCODE_DP4, inst->U.I.SaturateMode, inst->U.I.DstReg, src0, inst->U.I.SrcReg[1]);
+       rc_remove_instruction(inst);
+}
+
+/**
+ * [1, src0.y*src1.y, src0.z, src1.w]
+ * So basically MUL with lotsa swizzling.
+ */
+static void transform_DST(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       emit2(c, inst->Prev, RC_OPCODE_MUL, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               swizzle(inst->U.I.SrcReg[0], RC_SWIZZLE_ONE, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ONE),
+               swizzle(inst->U.I.SrcReg[1], RC_SWIZZLE_ONE, RC_SWIZZLE_Y, RC_SWIZZLE_ONE, RC_SWIZZLE_W));
+       rc_remove_instruction(inst);
+}
+
+static void transform_FLR(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+       emit1(c, inst->Prev, RC_OPCODE_FRC, 0, dst, inst->U.I.SrcReg[0]);
+       emit2(c, inst->Prev, RC_OPCODE_ADD, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               inst->U.I.SrcReg[0], negate(srcreg(RC_FILE_TEMPORARY, dst.Index)));
+       rc_remove_instruction(inst);
+}
+
+/**
+ * Definition of LIT (from ARB_fragment_program):
+ *
+ *  tmp = VectorLoad(op0);
+ *  if (tmp.x < 0) tmp.x = 0;
+ *  if (tmp.y < 0) tmp.y = 0;
+ *  if (tmp.w < -(128.0-epsilon)) tmp.w = -(128.0-epsilon);
+ *  else if (tmp.w > 128-epsilon) tmp.w = 128-epsilon;
+ *  result.x = 1.0;
+ *  result.y = tmp.x;
+ *  result.z = (tmp.x > 0) ? RoughApproxPower(tmp.y, tmp.w) : 0.0;
+ *  result.w = 1.0;
+ *
+ * The longest path of computation is the one leading to result.z,
+ * consisting of 5 operations. This implementation of LIT takes
+ * 5 slots, if the subsequent optimization passes are clever enough
+ * to pair instructions correctly.
+ */
+static void transform_LIT(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       unsigned int constant;
+       unsigned int constant_swizzle;
+       unsigned int temp;
+       struct rc_src_register srctemp;
+
+       constant = rc_constants_add_immediate_scalar(&c->Program.Constants, -127.999999, &constant_swizzle);
+
+       if (inst->U.I.DstReg.WriteMask != RC_MASK_XYZW || inst->U.I.DstReg.File != RC_FILE_TEMPORARY) {
+               struct rc_instruction * inst_mov;
+
+               inst_mov = emit1(c, inst,
+                       RC_OPCODE_MOV, 0, inst->U.I.DstReg,
+                       srcreg(RC_FILE_TEMPORARY, rc_find_free_temporary(c)));
+
+               inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               inst->U.I.DstReg.Index = inst_mov->U.I.SrcReg[0].Index;
+               inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+       }
+
+       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); */
+       emit2(c, inst->Prev, RC_OPCODE_MAX, 0,
+               dstregtmpmask(temp, RC_MASK_XYW),
+               inst->U.I.SrcReg[0],
+               swizzle(srcreg(RC_FILE_CONSTANT, constant),
+                       RC_SWIZZLE_ZERO, RC_SWIZZLE_ZERO, RC_SWIZZLE_ZERO, constant_swizzle&3));
+       emit2(c, inst->Prev, RC_OPCODE_MIN, 0,
+               dstregtmpmask(temp, RC_MASK_Z),
+               swizzle_wwww(srctemp),
+               negate(srcregswz(RC_FILE_CONSTANT, constant, constant_swizzle)));
+
+       /* tmp.w = Pow(tmp.y, tmp.w) */
+       emit1(c, inst->Prev, RC_OPCODE_LG2, 0,
+               dstregtmpmask(temp, RC_MASK_W),
+               swizzle_yyyy(srctemp));
+       emit2(c, inst->Prev, RC_OPCODE_MUL, 0,
+               dstregtmpmask(temp, RC_MASK_W),
+               swizzle_wwww(srctemp),
+               swizzle_zzzz(srctemp));
+       emit1(c, inst->Prev, RC_OPCODE_EX2, 0,
+               dstregtmpmask(temp, RC_MASK_W),
+               swizzle_wwww(srctemp));
+
+       /* 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_xxxx(srctemp)),
+               swizzle_wwww(srctemp),
+               builtin_zero);
+
+       /* 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));
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_LRP(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0,
+               dst,
+               inst->U.I.SrcReg[1], negate(inst->U.I.SrcReg[2]));
+       emit3(c, inst->Prev, RC_OPCODE_MAD, inst->U.I.SaturateMode,
+               inst->U.I.DstReg,
+               inst->U.I.SrcReg[0], srcreg(RC_FILE_TEMPORARY, dst.Index), inst->U.I.SrcReg[2]);
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_POW(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register tempdst = try_to_reuse_dst(c, inst);
+       struct rc_src_register tempsrc = srcreg(RC_FILE_TEMPORARY, tempdst.Index);
+       tempdst.WriteMask = RC_MASK_W;
+       tempsrc.Swizzle = RC_SWIZZLE_WWWW;
+
+       emit1(c, inst->Prev, RC_OPCODE_LG2, 0, tempdst, swizzle_xxxx(inst->U.I.SrcReg[0]));
+       emit2(c, inst->Prev, RC_OPCODE_MUL, 0, tempdst, tempsrc, swizzle_xxxx(inst->U.I.SrcReg[1]));
+       emit1(c, inst->Prev, RC_OPCODE_EX2, inst->U.I.SaturateMode, inst->U.I.DstReg, tempsrc);
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_RSQ(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       inst->U.I.SrcReg[0] = absolute(inst->U.I.SrcReg[0]);
+}
+
+static void transform_SEQ(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0, dst, inst->U.I.SrcReg[0], negate(inst->U.I.SrcReg[1]));
+       emit3(c, inst->Prev, RC_OPCODE_CMP, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               negate(absolute(srcreg(RC_FILE_TEMPORARY, dst.Index))), builtin_zero, builtin_one);
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_SFL(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       emit1(c, inst->Prev, RC_OPCODE_MOV, inst->U.I.SaturateMode, inst->U.I.DstReg, builtin_zero);
+       rc_remove_instruction(inst);
+}
+
+static void transform_SGE(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0, dst, inst->U.I.SrcReg[0], negate(inst->U.I.SrcReg[1]));
+       emit3(c, inst->Prev, RC_OPCODE_CMP, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               srcreg(RC_FILE_TEMPORARY, dst.Index), builtin_zero, builtin_one);
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_SGT(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0, dst, negate(inst->U.I.SrcReg[0]), inst->U.I.SrcReg[1]);
+       emit3(c, inst->Prev, RC_OPCODE_CMP, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               srcreg(RC_FILE_TEMPORARY, dst.Index), builtin_one, builtin_zero);
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_SLE(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0, dst, negate(inst->U.I.SrcReg[0]), inst->U.I.SrcReg[1]);
+       emit3(c, inst->Prev, RC_OPCODE_CMP, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               srcreg(RC_FILE_TEMPORARY, dst.Index), builtin_zero, builtin_one);
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_SLT(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0, dst, inst->U.I.SrcReg[0], negate(inst->U.I.SrcReg[1]));
+       emit3(c, inst->Prev, RC_OPCODE_CMP, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               srcreg(RC_FILE_TEMPORARY, dst.Index), builtin_one, builtin_zero);
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_SNE(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0, dst, inst->U.I.SrcReg[0], negate(inst->U.I.SrcReg[1]));
+       emit3(c, inst->Prev, RC_OPCODE_CMP, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               negate(absolute(srcreg(RC_FILE_TEMPORARY, dst.Index))), builtin_one, builtin_zero);
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_SSG(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       /* result = sign(x)
+        *
+        *   CMP tmp0, -x, 1, 0
+        *   CMP tmp1, x, 1, 0
+        *   ADD result, tmp0, -tmp1;
+        */
+       struct rc_dst_register dst0;
+       unsigned tmp1;
+
+       /* 0 < x */
+       dst0 = try_to_reuse_dst(c, inst);
+       emit3(c, inst->Prev, RC_OPCODE_CMP, 0,
+             dst0,
+             negate(inst->U.I.SrcReg[0]),
+             builtin_one,
+             builtin_zero);
+
+       /* x < 0 */
+       tmp1 = rc_find_free_temporary(c);
+       emit3(c, inst->Prev, RC_OPCODE_CMP, 0,
+             dstregtmpmask(tmp1, inst->U.I.DstReg.WriteMask),
+             inst->U.I.SrcReg[0],
+             builtin_one,
+             builtin_zero);
+
+       /* Either both are zero, or one of them is one and the other is zero. */
+       /* result = tmp0 - tmp1 */
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0,
+             inst->U.I.DstReg,
+             srcreg(RC_FILE_TEMPORARY, dst0.Index),
+             negate(srcreg(RC_FILE_TEMPORARY, tmp1)));
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_SUB(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       inst->U.I.Opcode = RC_OPCODE_ADD;
+       inst->U.I.SrcReg[1] = negate(inst->U.I.SrcReg[1]);
+}
+
+static void transform_SWZ(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       inst->U.I.Opcode = RC_OPCODE_MOV;
+}
+
+static void transform_XPD(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       emit2(c, inst->Prev, RC_OPCODE_MUL, 0, dst,
+               swizzle(inst->U.I.SrcReg[0], RC_SWIZZLE_Z, RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_W),
+               swizzle(inst->U.I.SrcReg[1], RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_X, RC_SWIZZLE_W));
+       emit3(c, inst->Prev, RC_OPCODE_MAD, inst->U.I.SaturateMode, inst->U.I.DstReg,
+               swizzle(inst->U.I.SrcReg[0], RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_X, RC_SWIZZLE_W),
+               swizzle(inst->U.I.SrcReg[1], RC_SWIZZLE_Z, RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_W),
+               negate(srcreg(RC_FILE_TEMPORARY, dst.Index)));
+
+       rc_remove_instruction(inst);
+}
+
+
+/**
+ * Can be used as a transformation for @ref radeonClauseLocalTransform,
+ * no userData necessary.
+ *
+ * Eliminates the following ALU instructions:
+ *  ABS, CEIL, DPH, DST, FLR, LIT, LRP, POW, SEQ, SFL, SGE, SGT, SLE, SLT, SNE, SUB, SWZ, XPD
+ * using:
+ *  MOV, ADD, MUL, MAD, FRC, DP3, LG2, EX2, CMP
+ *
+ * Transforms RSQ to Radeon's native RSQ by explicitly setting
+ * absolute value.
+ *
+ * @note should be applicable to R300 and R500 fragment programs.
+ */
+int radeonTransformALU(
+       struct radeon_compiler * c,
+       struct rc_instruction* inst,
+       void* unused)
+{
+       switch(inst->U.I.Opcode) {
+       case RC_OPCODE_ABS: transform_ABS(c, inst); return 1;
+       case RC_OPCODE_CEIL: transform_CEIL(c, inst); return 1;
+       case RC_OPCODE_CLAMP: transform_CLAMP(c, inst); return 1;
+       case RC_OPCODE_DP2: transform_DP2(c, inst); return 1;
+       case RC_OPCODE_DPH: transform_DPH(c, inst); return 1;
+       case RC_OPCODE_DST: transform_DST(c, inst); return 1;
+       case RC_OPCODE_FLR: transform_FLR(c, inst); return 1;
+       case RC_OPCODE_LIT: transform_LIT(c, inst); return 1;
+       case RC_OPCODE_LRP: transform_LRP(c, inst); return 1;
+       case RC_OPCODE_POW: transform_POW(c, inst); return 1;
+       case RC_OPCODE_RSQ: transform_RSQ(c, inst); return 1;
+       case RC_OPCODE_SEQ: transform_SEQ(c, inst); return 1;
+       case RC_OPCODE_SFL: transform_SFL(c, inst); return 1;
+       case RC_OPCODE_SGE: transform_SGE(c, inst); return 1;
+       case RC_OPCODE_SGT: transform_SGT(c, inst); return 1;
+       case RC_OPCODE_SLE: transform_SLE(c, inst); return 1;
+       case RC_OPCODE_SLT: transform_SLT(c, inst); return 1;
+       case RC_OPCODE_SNE: transform_SNE(c, inst); return 1;
+       case RC_OPCODE_SSG: transform_SSG(c, inst); return 1;
+       case RC_OPCODE_SUB: transform_SUB(c, inst); return 1;
+       case RC_OPCODE_SWZ: transform_SWZ(c, inst); return 1;
+       case RC_OPCODE_XPD: transform_XPD(c, inst); return 1;
+       default:
+               return 0;
+       }
+}
+
+
+static void transform_r300_vertex_ABS(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       /* Note: r500 can take absolute values, but r300 cannot. */
+       inst->U.I.Opcode = RC_OPCODE_MAX;
+       inst->U.I.SrcReg[1] = inst->U.I.SrcReg[0];
+       inst->U.I.SrcReg[1].Negate ^= RC_MASK_XYZW;
+}
+
+static void transform_r300_vertex_CMP(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       /* There is no decent CMP available, so let's rig one up.
+        * CMP is defined as dst = src0 < 0.0 ? src1 : src2
+        * The following sequence consumes zero to two temps and two extra slots
+        * (the second temp and the second slot is consumed by transform_LRP),
+        * but should be equivalent:
+        *
+        * SLT tmp0, src0, 0.0
+        * LRP dst, tmp0, src1, src2
+        *
+        * Yes, I know, I'm a mad scientist. ~ C. & M. */
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+
+       /* SLT tmp0, src0, 0.0 */
+       emit2(c, inst->Prev, RC_OPCODE_SLT, 0,
+               dst,
+               inst->U.I.SrcReg[0], builtin_zero);
+
+       /* LRP dst, tmp0, src1, src2 */
+       transform_LRP(c,
+               emit3(c, inst->Prev, RC_OPCODE_LRP, 0,
+                     inst->U.I.DstReg,
+                     srcreg(RC_FILE_TEMPORARY, dst.Index), inst->U.I.SrcReg[1],  inst->U.I.SrcReg[2]));
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_r300_vertex_DP2(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_instruction *next_inst = inst->Next;
+       transform_DP2(c, inst);
+       next_inst->Prev->U.I.Opcode = RC_OPCODE_DP4;
+}
+
+static void transform_r300_vertex_DP3(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_src_register src0 = inst->U.I.SrcReg[0];
+       struct rc_src_register src1 = inst->U.I.SrcReg[1];
+       src0.Negate &= ~RC_MASK_W;
+       src0.Swizzle &= ~(7 << (3 * 3));
+       src0.Swizzle |= RC_SWIZZLE_ZERO << (3 * 3);
+       src1.Negate &= ~RC_MASK_W;
+       src1.Swizzle &= ~(7 << (3 * 3));
+       src1.Swizzle |= RC_SWIZZLE_ZERO << (3 * 3);
+       emit2(c, inst->Prev, RC_OPCODE_DP4, inst->U.I.SaturateMode, inst->U.I.DstReg, src0, src1);
+       rc_remove_instruction(inst);
+}
+
+static void transform_r300_vertex_fix_LIT(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       struct rc_dst_register dst = try_to_reuse_dst(c, inst);
+       unsigned constant_swizzle;
+       int constant = rc_constants_add_immediate_scalar(&c->Program.Constants,
+                                                        0.0000000000000000001,
+                                                        &constant_swizzle);
+
+       /* MOV dst, src */
+       dst.WriteMask = RC_MASK_XYZW;
+       emit1(c, inst->Prev, RC_OPCODE_MOV, 0,
+               dst,
+               inst->U.I.SrcReg[0]);
+
+       /* MAX dst.y, src, 0.00...001 */
+       emit2(c, inst->Prev, RC_OPCODE_MAX, 0,
+               dstregtmpmask(dst.Index, RC_MASK_Y),
+               srcreg(RC_FILE_TEMPORARY, dst.Index),
+               srcregswz(RC_FILE_CONSTANT, constant, constant_swizzle));
+
+       inst->U.I.SrcReg[0] = srcreg(RC_FILE_TEMPORARY, dst.Index);
+}
+
+static void transform_r300_vertex_SEQ(struct radeon_compiler *c,
+       struct rc_instruction *inst)
+{
+       /* x = y  <==>  x >= y && y >= x */
+       int tmp = rc_find_free_temporary(c);
+
+       /* x <= y */
+       emit2(c, inst->Prev, RC_OPCODE_SGE, 0,
+             dstregtmpmask(tmp, inst->U.I.DstReg.WriteMask),
+             inst->U.I.SrcReg[0],
+             inst->U.I.SrcReg[1]);
+
+       /* y <= x */
+       emit2(c, inst->Prev, RC_OPCODE_SGE, 0,
+             inst->U.I.DstReg,
+             inst->U.I.SrcReg[1],
+             inst->U.I.SrcReg[0]);
+
+       /* x && y  =  x * y */
+       emit2(c, inst->Prev, RC_OPCODE_MUL, 0,
+             inst->U.I.DstReg,
+             srcreg(RC_FILE_TEMPORARY, tmp),
+             srcreg(inst->U.I.DstReg.File, inst->U.I.DstReg.Index));
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_r300_vertex_SNE(struct radeon_compiler *c,
+       struct rc_instruction *inst)
+{
+       /* x != y  <==>  x < y || y < x */
+       int tmp = rc_find_free_temporary(c);
+
+       /* x < y */
+       emit2(c, inst->Prev, RC_OPCODE_SLT, 0,
+             dstregtmpmask(tmp, inst->U.I.DstReg.WriteMask),
+             inst->U.I.SrcReg[0],
+             inst->U.I.SrcReg[1]);
+
+       /* y < x */
+       emit2(c, inst->Prev, RC_OPCODE_SLT, 0,
+             inst->U.I.DstReg,
+             inst->U.I.SrcReg[1],
+             inst->U.I.SrcReg[0]);
+
+       /* x || y  =  max(x, y) */
+       emit2(c, inst->Prev, RC_OPCODE_MAX, 0,
+             inst->U.I.DstReg,
+             srcreg(RC_FILE_TEMPORARY, tmp),
+             srcreg(inst->U.I.DstReg.File, inst->U.I.DstReg.Index));
+
+       rc_remove_instruction(inst);
+}
+
+static void transform_r300_vertex_SGT(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       /* x > y  <==>  -x < -y */
+       inst->U.I.Opcode = RC_OPCODE_SLT;
+       inst->U.I.SrcReg[0].Negate ^= RC_MASK_XYZW;
+       inst->U.I.SrcReg[1].Negate ^= RC_MASK_XYZW;
+}
+
+static void transform_r300_vertex_SLE(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       /* x <= y  <==>  -x >= -y */
+       inst->U.I.Opcode = RC_OPCODE_SGE;
+       inst->U.I.SrcReg[0].Negate ^= RC_MASK_XYZW;
+       inst->U.I.SrcReg[1].Negate ^= RC_MASK_XYZW;
+}
+
+static void transform_r300_vertex_SSG(struct radeon_compiler* c,
+       struct rc_instruction* inst)
+{
+       /* result = sign(x)
+        *
+        *   SLT tmp0, 0, x;
+        *   SLT tmp1, x, 0;
+        *   ADD result, tmp0, -tmp1;
+        */
+       struct rc_dst_register dst0 = try_to_reuse_dst(c, inst);
+       unsigned tmp1;
+
+       /* 0 < x */
+       dst0 = try_to_reuse_dst(c, inst);
+       emit2(c, inst->Prev, RC_OPCODE_SLT, 0,
+             dst0,
+             builtin_zero,
+             inst->U.I.SrcReg[0]);
+
+       /* x < 0 */
+       tmp1 = rc_find_free_temporary(c);
+       emit2(c, inst->Prev, RC_OPCODE_SLT, 0,
+             dstregtmpmask(tmp1, inst->U.I.DstReg.WriteMask),
+             inst->U.I.SrcReg[0],
+             builtin_zero);
+
+       /* Either both are zero, or one of them is one and the other is zero. */
+       /* result = tmp0 - tmp1 */
+       emit2(c, inst->Prev, RC_OPCODE_ADD, 0,
+             inst->U.I.DstReg,
+             srcreg(RC_FILE_TEMPORARY, dst0.Index),
+             negate(srcreg(RC_FILE_TEMPORARY, tmp1)));
+
+       rc_remove_instruction(inst);
+}
+
+/**
+ * For use with rc_local_transform, this transforms non-native ALU
+ * instructions of the r300 up to r500 vertex engine.
+ */
+int r300_transform_vertex_alu(
+       struct radeon_compiler * c,
+       struct rc_instruction* inst,
+       void* unused)
+{
+       switch(inst->U.I.Opcode) {
+       case RC_OPCODE_ABS: transform_r300_vertex_ABS(c, inst); return 1;
+       case RC_OPCODE_CEIL: transform_CEIL(c, inst); return 1;
+       case RC_OPCODE_CLAMP: transform_CLAMP(c, inst); return 1;
+       case RC_OPCODE_CMP: transform_r300_vertex_CMP(c, inst); return 1;
+       case RC_OPCODE_DP2: transform_r300_vertex_DP2(c, inst); return 1;
+       case RC_OPCODE_DP3: transform_r300_vertex_DP3(c, inst); return 1;
+       case RC_OPCODE_DPH: transform_DPH(c, inst); return 1;
+       case RC_OPCODE_FLR: transform_FLR(c, inst); return 1;
+       case RC_OPCODE_LIT: transform_r300_vertex_fix_LIT(c, inst); return 1;
+       case RC_OPCODE_LRP: transform_LRP(c, inst); return 1;
+       case RC_OPCODE_SEQ:
+               if (!c->is_r500) {
+                       transform_r300_vertex_SEQ(c, inst);
+                       return 1;
+               }
+               return 0;
+       case RC_OPCODE_SFL: transform_SFL(c, inst); return 1;
+       case RC_OPCODE_SGT: transform_r300_vertex_SGT(c, inst); return 1;
+       case RC_OPCODE_SLE: transform_r300_vertex_SLE(c, inst); return 1;
+       case RC_OPCODE_SNE:
+               if (!c->is_r500) {
+                       transform_r300_vertex_SNE(c, inst);
+                       return 1;
+               }
+               return 0;
+       case RC_OPCODE_SSG: transform_r300_vertex_SSG(c, inst); return 1;
+       case RC_OPCODE_SUB: transform_SUB(c, inst); return 1;
+       case RC_OPCODE_SWZ: transform_SWZ(c, inst); return 1;
+       case RC_OPCODE_XPD: transform_XPD(c, inst); return 1;
+       default:
+               return 0;
+       }
+}
+
+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 */
+               },
+               {
+                       0.75,
+                       0.5,
+                       0.159154943,            /* 1/(2*PI) */
+                       6.283185307             /* 2*PI */
+               }
+       };
+       int i;
+
+       for(i = 0; i < 2; ++i)
+               constants[i] = rc_constants_add_immediate_vec4(&c->Program.Constants, SinCosConsts[i]);
+}
+
+/**
+ * Approximate sin(x), where x is clamped to (-pi/2, pi/2).
+ *
+ * MUL tmp.xy, src, { 4/PI, -4/(PI^2) }
+ * MAD tmp.x, tmp.y, |src|, tmp.x
+ * MAD tmp.y, tmp.x, |tmp.x|, -tmp.x
+ * MAD dest, tmp.y, weight, tmp.x
+ */
+static void sin_approx(
+       struct radeon_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, inst->Prev, RC_OPCODE_MUL, 0, dstregtmpmask(tempreg, RC_MASK_XY),
+               swizzle_xxxx(src),
+               srcreg(RC_FILE_CONSTANT, constants[0]));
+       emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_X),
+               swizzle_yyyy(srcreg(RC_FILE_TEMPORARY, tempreg)),
+               absolute(swizzle_xxxx(src)),
+               swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg)));
+       emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_Y),
+               swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg)),
+               absolute(swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg))),
+               negate(swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg))));
+       emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dst,
+               swizzle_yyyy(srcreg(RC_FILE_TEMPORARY, tempreg)),
+               swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[0])),
+               swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg)));
+}
+
+/**
+ * Translate the trigonometric functions COS, SIN, and SCS
+ * using only the basic instructions
+ *  MOV, ADD, MUL, MAD, FRC
+ */
+int r300_transform_trig_simple(struct radeon_compiler* c,
+       struct rc_instruction* inst,
+       void* unused)
+{
+       unsigned int constants[2];
+       unsigned int tempreg;
+
+       if (inst->U.I.Opcode != RC_OPCODE_COS &&
+           inst->U.I.Opcode != RC_OPCODE_SIN &&
+           inst->U.I.Opcode != RC_OPCODE_SCS)
+               return 0;
+
+       tempreg = rc_find_free_temporary(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 */
+               emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_W),
+                       swizzle_xxxx(inst->U.I.SrcReg[0]),
+                       swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[1])),
+                       swizzle_xxxx(srcreg(RC_FILE_CONSTANT, constants[1])));
+               emit1(c, inst->Prev, RC_OPCODE_FRC, 0, dstregtmpmask(tempreg, RC_MASK_W),
+                       swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)));
+               emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_W),
+                       swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
+                       swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[1])),
+                       negate(swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[0]))));
+
+               sin_approx(c, inst, inst->U.I.DstReg,
+                       swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
+                       constants);
+       } else if (inst->U.I.Opcode == RC_OPCODE_SIN) {
+               emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_W),
+                       swizzle_xxxx(inst->U.I.SrcReg[0]),
+                       swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[1])),
+                       swizzle_yyyy(srcreg(RC_FILE_CONSTANT, constants[1])));
+               emit1(c, inst->Prev, RC_OPCODE_FRC, 0, dstregtmpmask(tempreg, RC_MASK_W),
+                       swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)));
+               emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_W),
+                       swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
+                       swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[1])),
+                       negate(swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[0]))));
+
+               sin_approx(c, inst, inst->U.I.DstReg,
+                       swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
+                       constants);
+       } else {
+               struct rc_dst_register dst;
+
+               emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_XY),
+                       swizzle_xxxx(inst->U.I.SrcReg[0]),
+                       swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[1])),
+                       swizzle(srcreg(RC_FILE_CONSTANT, constants[1]), RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_W));
+               emit1(c, inst->Prev, RC_OPCODE_FRC, 0, dstregtmpmask(tempreg, RC_MASK_XY),
+                       srcreg(RC_FILE_TEMPORARY, tempreg));
+               emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_XY),
+                       srcreg(RC_FILE_TEMPORARY, tempreg),
+                       swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[1])),
+                       negate(swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[0]))));
+
+               dst = inst->U.I.DstReg;
+
+               dst.WriteMask = inst->U.I.DstReg.WriteMask & RC_MASK_X;
+               sin_approx(c, inst, dst,
+                       swizzle_xxxx(srcreg(RC_FILE_TEMPORARY, tempreg)),
+                       constants);
+
+               dst.WriteMask = inst->U.I.DstReg.WriteMask & RC_MASK_Y;
+               sin_approx(c, inst, dst,
+                       swizzle_yyyy(srcreg(RC_FILE_TEMPORARY, tempreg)),
+                       constants);
+       }
+
+       rc_remove_instruction(inst);
+
+       return 1;
+}
+
+static void r300_transform_SIN_COS_SCS(struct radeon_compiler *c,
+       struct rc_instruction *inst,
+       unsigned srctmp)
+{
+       if (inst->U.I.Opcode == RC_OPCODE_COS) {
+               emit1(c, inst->Prev, RC_OPCODE_COS, inst->U.I.SaturateMode, inst->U.I.DstReg,
+                       srcregswz(RC_FILE_TEMPORARY, srctmp, RC_SWIZZLE_WWWW));
+       } else if (inst->U.I.Opcode == RC_OPCODE_SIN) {
+               emit1(c, inst->Prev, RC_OPCODE_SIN, inst->U.I.SaturateMode,
+                       inst->U.I.DstReg, srcregswz(RC_FILE_TEMPORARY, srctmp, RC_SWIZZLE_WWWW));
+       } else if (inst->U.I.Opcode == RC_OPCODE_SCS) {
+               struct rc_dst_register moddst = inst->U.I.DstReg;
+
+               if (inst->U.I.DstReg.WriteMask & RC_MASK_X) {
+                       moddst.WriteMask = RC_MASK_X;
+                       emit1(c, inst->Prev, RC_OPCODE_COS, inst->U.I.SaturateMode, moddst,
+                               srcregswz(RC_FILE_TEMPORARY, srctmp, RC_SWIZZLE_WWWW));
+               }
+               if (inst->U.I.DstReg.WriteMask & RC_MASK_Y) {
+                       moddst.WriteMask = RC_MASK_Y;
+                       emit1(c, inst->Prev, RC_OPCODE_SIN, inst->U.I.SaturateMode, moddst,
+                               srcregswz(RC_FILE_TEMPORARY, srctmp, RC_SWIZZLE_WWWW));
+               }
+       }
+
+       rc_remove_instruction(inst);
+}
+
+
+/**
+ * Transform the trigonometric functions COS, SIN, and SCS
+ * to include pre-scaling by 1/(2*PI) and taking the fractional
+ * part, so that the input to COS and SIN is always in the range [0,1).
+ * SCS is replaced by one COS and one SIN instruction.
+ *
+ * @warning This transformation implicitly changes the semantics of SIN and COS!
+ */
+int radeonTransformTrigScale(struct radeon_compiler* c,
+       struct rc_instruction* inst,
+       void* unused)
+{
+       static const float RCP_2PI = 0.15915494309189535;
+       unsigned int temp;
+       unsigned int constant;
+       unsigned int constant_swizzle;
+
+       if (inst->U.I.Opcode != RC_OPCODE_COS &&
+           inst->U.I.Opcode != RC_OPCODE_SIN &&
+           inst->U.I.Opcode != RC_OPCODE_SCS)
+               return 0;
+
+       temp = rc_find_free_temporary(c);
+       constant = rc_constants_add_immediate_scalar(&c->Program.Constants, RCP_2PI, &constant_swizzle);
+
+       emit2(c, inst->Prev, RC_OPCODE_MUL, 0, dstregtmpmask(temp, RC_MASK_W),
+               swizzle_xxxx(inst->U.I.SrcReg[0]),
+               srcregswz(RC_FILE_CONSTANT, constant, constant_swizzle));
+       emit1(c, inst->Prev, RC_OPCODE_FRC, 0, dstregtmpmask(temp, RC_MASK_W),
+               srcreg(RC_FILE_TEMPORARY, temp));
+
+       r300_transform_SIN_COS_SCS(c, inst, temp);
+       return 1;
+}
+
+/**
+ * Transform the trigonometric functions COS, SIN, and SCS
+ * so that the input to COS and SIN is always in the range [-PI, PI].
+ * SCS is replaced by one COS and one SIN instruction.
+ */
+int r300_transform_trig_scale_vertex(struct radeon_compiler *c,
+       struct rc_instruction *inst,
+       void *unused)
+{
+       static const float cons[4] = {0.15915494309189535, 0.5, 6.28318530717959, -3.14159265358979};
+       unsigned int temp;
+       unsigned int constant;
+
+       if (inst->U.I.Opcode != RC_OPCODE_COS &&
+           inst->U.I.Opcode != RC_OPCODE_SIN &&
+           inst->U.I.Opcode != RC_OPCODE_SCS)
+               return 0;
+
+       /* Repeat x in the range [-PI, PI]:
+        *
+        *   repeat(x) = frac(x / 2PI + 0.5) * 2PI - PI
+        */
+
+       temp = rc_find_free_temporary(c);
+       constant = rc_constants_add_immediate_vec4(&c->Program.Constants, cons);
+
+       emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(temp, RC_MASK_W),
+               swizzle_xxxx(inst->U.I.SrcReg[0]),
+               srcregswz(RC_FILE_CONSTANT, constant, RC_SWIZZLE_XXXX),
+               srcregswz(RC_FILE_CONSTANT, constant, RC_SWIZZLE_YYYY));
+       emit1(c, inst->Prev, RC_OPCODE_FRC, 0, dstregtmpmask(temp, RC_MASK_W),
+               srcreg(RC_FILE_TEMPORARY, temp));
+       emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(temp, RC_MASK_W),
+               srcreg(RC_FILE_TEMPORARY, temp),
+               srcregswz(RC_FILE_CONSTANT, constant, RC_SWIZZLE_ZZZZ),
+               srcregswz(RC_FILE_CONSTANT, constant, RC_SWIZZLE_WWWW));
+
+       r300_transform_SIN_COS_SCS(c, inst, temp);
+       return 1;
+}
+
+/**
+ * Rewrite DDX/DDY instructions to properly work with r5xx shaders.
+ * The r5xx MDH/MDV instruction provides per-quad partial derivatives.
+ * It takes the form A*B+C. A and C are set by setting src0. B should be -1.
+ *
+ * @warning This explicitly changes the form of DDX and DDY!
+ */
+
+int radeonTransformDeriv(struct radeon_compiler* c,
+       struct rc_instruction* inst,
+       void* unused)
+{
+       if (inst->U.I.Opcode != RC_OPCODE_DDX && inst->U.I.Opcode != RC_OPCODE_DDY)
+               return 0;
+
+       inst->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_1111;
+       inst->U.I.SrcReg[1].Negate = RC_MASK_XYZW;
+
+       return 1;
+}
+
+/**
+ * IF Temp[0].x -\
+ * KILP         - > KIL -abs(Temp[0].x)
+ * ENDIF        -/
+ *
+ * This needs to be done in its own pass, because it modifies the instructions
+ * before and after KILP.
+ */
+void rc_transform_KILP(struct radeon_compiler * c, void *user)
+{
+       struct rc_instruction * inst;
+       for (inst = c->Program.Instructions.Next;
+                       inst != &c->Program.Instructions; inst = inst->Next) {
+
+               if (inst->U.I.Opcode != RC_OPCODE_KILP)
+                       continue;
+
+               inst->U.I.Opcode = RC_OPCODE_KIL;
+
+               if (inst->Prev->U.I.Opcode != RC_OPCODE_IF
+                               || inst->Next->U.I.Opcode != RC_OPCODE_ENDIF) {
+                       inst->U.I.SrcReg[0] = negate(builtin_one);
+               } else {
+
+                       inst->U.I.SrcReg[0] =
+                               negate(absolute(inst->Prev->U.I.SrcReg[0]));
+                       /* Remove IF */
+                       rc_remove_instruction(inst->Prev);
+                       /* Remove ENDIF */
+                       rc_remove_instruction(inst->Next);
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.h b/src/gallium/drivers/r300/compiler/radeon_program_alu.h
new file mode 100644 (file)
index 0000000..b5f361e
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __RADEON_PROGRAM_ALU_H_
+#define __RADEON_PROGRAM_ALU_H_
+
+#include "radeon_program.h"
+
+int radeonTransformALU(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst,
+       void*);
+
+int r300_transform_vertex_alu(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst,
+       void*);
+
+int r300_transform_trig_simple(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst,
+       void*);
+
+int radeonTransformTrigScale(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst,
+       void*);
+
+int r300_transform_trig_scale_vertex(
+       struct radeon_compiler *c,
+       struct rc_instruction *inst,
+       void*);
+
+int radeonTransformDeriv(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst,
+       void*);
+
+void rc_transform_KILP(struct radeon_compiler * c,
+                      void *user);
+
+#endif /* __RADEON_PROGRAM_ALU_H_ */
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_constants.h b/src/gallium/drivers/r300/compiler/radeon_program_constants.h
new file mode 100644 (file)
index 0000000..2457733
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef RADEON_PROGRAM_CONSTANTS_H
+#define RADEON_PROGRAM_CONSTANTS_H
+
+typedef enum {
+       RC_SATURATE_NONE = 0,
+       RC_SATURATE_ZERO_ONE,
+       RC_SATURATE_MINUS_PLUS_ONE
+} rc_saturate_mode;
+
+typedef enum {
+       RC_TEXTURE_2D_ARRAY,
+       RC_TEXTURE_1D_ARRAY,
+       RC_TEXTURE_CUBE,
+       RC_TEXTURE_3D,
+       RC_TEXTURE_RECT,
+       RC_TEXTURE_2D,
+       RC_TEXTURE_1D
+} rc_texture_target;
+
+typedef enum {
+       /**
+        * Used to indicate unused register descriptions and
+        * source register that use a constant swizzle.
+        */
+       RC_FILE_NONE = 0,
+       RC_FILE_TEMPORARY,
+
+       /**
+        * Input register.
+        *
+        * \note The compiler attaches no implicit semantics to input registers.
+        * Fragment/vertex program specific semantics must be defined explicitly
+        * using the appropriate compiler interfaces.
+        */
+       RC_FILE_INPUT,
+
+       /**
+        * Output register.
+        *
+        * \note The compiler attaches no implicit semantics to input registers.
+        * Fragment/vertex program specific semantics must be defined explicitly
+        * using the appropriate compiler interfaces.
+        */
+       RC_FILE_OUTPUT,
+       RC_FILE_ADDRESS,
+
+       /**
+        * Indicates a constant from the \ref rc_constant_list .
+        */
+       RC_FILE_CONSTANT,
+
+       /**
+        * Indicates a special register, see RC_SPECIAL_xxx.
+        */
+       RC_FILE_SPECIAL,
+
+       /**
+        * Indicates this register should use the result of the presubtract
+        * operation.
+        */
+       RC_FILE_PRESUB
+} rc_register_file;
+
+enum {
+       /** R500 fragment program ALU result "register" */
+       RC_SPECIAL_ALU_RESULT = 0,
+
+       /** Must be last */
+       RC_NUM_SPECIAL_REGISTERS
+};
+
+#define RC_REGISTER_INDEX_BITS 10
+#define RC_REGISTER_MAX_INDEX (1 << RC_REGISTER_INDEX_BITS)
+
+typedef enum {
+       RC_SWIZZLE_X = 0,
+       RC_SWIZZLE_Y,
+       RC_SWIZZLE_Z,
+       RC_SWIZZLE_W,
+       RC_SWIZZLE_ZERO,
+       RC_SWIZZLE_ONE,
+       RC_SWIZZLE_HALF,
+       RC_SWIZZLE_UNUSED
+} rc_swizzle;
+
+#define RC_MAKE_SWIZZLE(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))
+#define RC_MAKE_SWIZZLE_SMEAR(a) RC_MAKE_SWIZZLE((a),(a),(a),(a))
+#define GET_SWZ(swz, idx)      (((swz) >> ((idx)*3)) & 0x7)
+#define GET_BIT(msk, idx)      (((msk) >> (idx)) & 0x1)
+#define SET_SWZ(swz, idx, newv) \
+       do { \
+               (swz) = ((swz) & ~(7 << ((idx)*3))) | ((newv) << ((idx)*3)); \
+       } while(0)
+
+#define RC_SWIZZLE_XYZW RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_W)
+#define RC_SWIZZLE_XYZ0 RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ZERO)
+#define RC_SWIZZLE_XYZZ RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_Z)
+#define RC_SWIZZLE_XXXX RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_X)
+#define RC_SWIZZLE_YYYY RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_Y)
+#define RC_SWIZZLE_ZZZZ RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_Z)
+#define RC_SWIZZLE_WWWW RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_W)
+#define RC_SWIZZLE_0000 RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_ZERO)
+#define RC_SWIZZLE_1111 RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_ONE)
+#define RC_SWIZZLE_HHHH RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_HALF)
+#define RC_SWIZZLE_UUUU RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_UNUSED)
+
+/**
+ * \name Bitmasks for components of vectors.
+ *
+ * Used for write masks, negation masks, etc.
+ */
+/*@{*/
+#define RC_MASK_NONE 0
+#define RC_MASK_X 1
+#define RC_MASK_Y 2
+#define RC_MASK_Z 4
+#define RC_MASK_W 8
+#define RC_MASK_XY (RC_MASK_X|RC_MASK_Y)
+#define RC_MASK_XYZ (RC_MASK_X|RC_MASK_Y|RC_MASK_Z)
+#define RC_MASK_XYW (RC_MASK_X|RC_MASK_Y|RC_MASK_W)
+#define RC_MASK_XYZW (RC_MASK_X|RC_MASK_Y|RC_MASK_Z|RC_MASK_W)
+/*@}*/
+
+typedef enum {
+       RC_ALURESULT_NONE = 0,
+       RC_ALURESULT_X,
+       RC_ALURESULT_W
+} rc_write_aluresult;
+
+typedef enum {
+       RC_PRESUB_NONE = 0,
+
+       /** 1 - 2 * src0 */
+       RC_PRESUB_BIAS,
+
+       /** src1 - src0 */
+       RC_PRESUB_SUB,
+
+       /** src1 + src0 */
+       RC_PRESUB_ADD,
+
+       /** 1 - src0 */
+       RC_PRESUB_INV
+} rc_presubtract_op;
+
+static inline int rc_presubtract_src_reg_count(rc_presubtract_op op){
+       switch(op){
+       case RC_PRESUB_BIAS:
+       case RC_PRESUB_INV:
+               return 1;
+       case RC_PRESUB_ADD:
+       case RC_PRESUB_SUB:
+               return 2;
+       default:
+               return 0;
+       }
+}
+
+#define RC_SOURCE_NONE  0x0
+#define RC_SOURCE_RGB   0x1
+#define RC_SOURCE_ALPHA 0x2
+
+#endif /* RADEON_PROGRAM_CONSTANTS_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_pair.c b/src/gallium/drivers/r300/compiler/radeon_program_pair.c
new file mode 100644 (file)
index 0000000..5231595
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * Copyright (C) 2008-2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_program_pair.h"
+
+#include "radeon_compiler_util.h"
+
+#include <stdlib.h>
+
+/**
+ * Return the source slot where we installed the given register access,
+ * or -1 if no slot was free anymore.
+ */
+int rc_pair_alloc_source(struct rc_pair_instruction *pair,
+       unsigned int rgb, unsigned int alpha,
+       rc_register_file file, unsigned int index)
+{
+       int candidate = -1;
+       int candidate_quality = -1;
+       unsigned int alpha_used = 0;
+       unsigned int rgb_used = 0;
+       int i;
+
+       if ((!rgb && !alpha) || file == RC_FILE_NONE)
+               return 0;
+
+       /* Make sure only one presubtract operation is used per instruction. */
+       if (file == RC_FILE_PRESUB) {
+               if (rgb && pair->RGB.Src[RC_PAIR_PRESUB_SRC].Used
+                       && index != pair->RGB.Src[RC_PAIR_PRESUB_SRC].Index) {
+                               return -1;
+               }
+
+               if (alpha && pair->Alpha.Src[RC_PAIR_PRESUB_SRC].Used
+                       && index != pair->Alpha.Src[RC_PAIR_PRESUB_SRC].Index) {
+                               return -1;
+               }
+       }
+
+       for(i = 0; i < 3; ++i) {
+               int q = 0;
+               if (rgb) {
+                       if (pair->RGB.Src[i].Used) {
+                               if (pair->RGB.Src[i].File != file ||
+                                   pair->RGB.Src[i].Index != index) {
+                                       rgb_used++;
+                                       continue;
+                               }
+                               q++;
+                       }
+               }
+               if (alpha) {
+                       if (pair->Alpha.Src[i].Used) {
+                               if (pair->Alpha.Src[i].File != file ||
+                                   pair->Alpha.Src[i].Index != index) {
+                                       alpha_used++;
+                                       continue;
+                               }
+                               q++;
+                       }
+               }
+               if (q > candidate_quality) {
+                       candidate_quality = q;
+                       candidate = i;
+               }
+       }
+
+       if (file == RC_FILE_PRESUB) {
+               candidate = RC_PAIR_PRESUB_SRC;
+       } else if (candidate < 0 || (rgb && rgb_used > 2)
+                       || (alpha && alpha_used > 2)) {
+               return -1;
+       }
+
+       /* candidate >= 0 */
+
+       if (rgb) {
+               pair->RGB.Src[candidate].Used = 1;
+               pair->RGB.Src[candidate].File = file;
+               pair->RGB.Src[candidate].Index = index;
+               if (candidate == RC_PAIR_PRESUB_SRC) {
+                       /* For registers with the RC_FILE_PRESUB file,
+                        * the index stores the presubtract op. */
+                       int src_regs = rc_presubtract_src_reg_count(index);
+                       for(i = 0; i < src_regs; i++) {
+                               pair->RGB.Src[i].Used = 1;
+                       }
+               }
+       }
+       if (alpha) {
+               pair->Alpha.Src[candidate].Used = 1;
+               pair->Alpha.Src[candidate].File = file;
+               pair->Alpha.Src[candidate].Index = index;
+               if (candidate == RC_PAIR_PRESUB_SRC) {
+                       /* For registers with the RC_FILE_PRESUB file,
+                        * the index stores the presubtract op. */
+                       int src_regs = rc_presubtract_src_reg_count(index);
+                       for(i=0; i < src_regs; i++) {
+                               pair->Alpha.Src[i].Used = 1;
+                       }
+               }
+       }
+
+       return candidate;
+}
+
+static void pair_foreach_source_callback(
+       struct rc_pair_instruction * pair,
+       void * data,
+       rc_pair_foreach_src_fn cb,
+       unsigned int swz,
+       unsigned int src)
+{
+       /* swz > 3 means that the swizzle is either not used, or a constant
+        * swizzle (e.g. 0, 1, 0.5). */
+       if(swz > 3)
+               return;
+
+       if(swz == RC_SWIZZLE_W) {
+               if (src == RC_PAIR_PRESUB_SRC) {
+                       unsigned int i;
+                       unsigned int src_count = rc_presubtract_src_reg_count(
+                               pair->Alpha.Src[RC_PAIR_PRESUB_SRC].Index);
+                       for(i = 0; i < src_count; i++) {
+                               cb(data, &pair->Alpha.Src[i]);
+                       }
+               } else {
+                       cb(data, &pair->Alpha.Src[src]);
+               }
+       } else {
+               if (src == RC_PAIR_PRESUB_SRC) {
+                       unsigned int i;
+                       unsigned int src_count = rc_presubtract_src_reg_count(
+                               pair->RGB.Src[RC_PAIR_PRESUB_SRC].Index);
+                       for(i = 0; i < src_count; i++) {
+                               cb(data, &pair->RGB.Src[i]);
+                       }
+               }
+               else {
+                       cb(data, &pair->RGB.Src[src]);
+               }
+       }
+}
+
+void rc_pair_foreach_source_that_alpha_reads(
+       struct rc_pair_instruction * pair,
+       void * data,
+       rc_pair_foreach_src_fn cb)
+{
+       unsigned int i;
+       const struct rc_opcode_info * info =
+                               rc_get_opcode_info(pair->Alpha.Opcode);
+       for(i = 0; i < info->NumSrcRegs; i++) {
+               pair_foreach_source_callback(pair, data, cb,
+                                       GET_SWZ(pair->Alpha.Arg[i].Swizzle, 0),
+                                       pair->Alpha.Arg[i].Source);
+       }
+}
+
+void rc_pair_foreach_source_that_rgb_reads(
+       struct rc_pair_instruction * pair,
+       void * data,
+       rc_pair_foreach_src_fn cb)
+{
+       unsigned int i;
+       const struct rc_opcode_info * info =
+                               rc_get_opcode_info(pair->RGB.Opcode);
+       for(i = 0; i < info->NumSrcRegs; i++) {
+               unsigned int chan;
+               unsigned int swz = RC_SWIZZLE_UNUSED;
+               /* Find a swizzle that is either X,Y,Z,or W.  We assume here
+                * that if one channel swizzles X,Y, or Z, then none of the
+                * other channels swizzle W, and vice-versa. */
+               for(chan = 0; chan < 4; chan++) {
+                       swz = GET_SWZ(pair->RGB.Arg[i].Swizzle, chan);
+                       if(swz == RC_SWIZZLE_X || swz == RC_SWIZZLE_Y
+                       || swz == RC_SWIZZLE_Z || swz == RC_SWIZZLE_W)
+                               continue;
+               }
+               pair_foreach_source_callback(pair, data, cb,
+                                       swz,
+                                       pair->RGB.Arg[i].Source);
+       }
+}
+
+struct rc_pair_instruction_source * rc_pair_get_src(
+       struct rc_pair_instruction * pair_inst,
+       struct rc_pair_instruction_arg * arg)
+{
+       unsigned int type;
+
+       type = rc_source_type_swz(arg->Swizzle);
+
+       if (type & RC_SOURCE_RGB) {
+               return &pair_inst->RGB.Src[arg->Source];
+       } else if (type & RC_SOURCE_ALPHA) {
+               return &pair_inst->Alpha.Src[arg->Source];
+       } else {
+               return NULL;
+       }
+}
+
+int rc_pair_get_src_index(
+       struct rc_pair_instruction * pair_inst,
+       struct rc_pair_instruction_source * src)
+{
+       int i;
+       for (i = 0; i < 3; i++) {
+               if (&pair_inst->RGB.Src[i] == src
+                       || &pair_inst->Alpha.Src[i] == src) {
+                       return i;
+               }
+       }
+       return -1;
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_pair.h b/src/gallium/drivers/r300/compiler/radeon_program_pair.h
new file mode 100644 (file)
index 0000000..a957ea9
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2008 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __RADEON_PROGRAM_PAIR_H_
+#define __RADEON_PROGRAM_PAIR_H_
+
+#include "radeon_code.h"
+#include "radeon_opcodes.h"
+#include "radeon_program_constants.h"
+
+struct radeon_compiler;
+
+
+/**
+ * \file
+ * Represents a paired ALU instruction, as found in R300 and R500
+ * fragment programs.
+ *
+ * Note that this representation is taking some liberties as far
+ * as register files are concerned, to allow separate register
+ * allocation.
+ *
+ * Also note that there are some subtleties in that the semantics
+ * of certain opcodes are implicitly changed in this representation;
+ * see \ref rc_pair_translate
+ */
+
+/* For rgb and alpha instructions when arg[n].Source = RC_PAIR_PRESUB_SRC, then
+ * the presubtract value will be used, and
+ * {RGB,Alpha}.Src[RC_PAIR_PRESUB_SRC].File will be set to RC_FILE_PRESUB.
+ */
+#define RC_PAIR_PRESUB_SRC 3
+
+struct rc_pair_instruction_source {
+       unsigned int Used:1;
+       unsigned int File:3;
+       unsigned int Index:RC_REGISTER_INDEX_BITS;
+};
+
+struct rc_pair_instruction_arg {
+       unsigned int Source:2;
+       unsigned int Swizzle:12;
+       unsigned int Abs:1;
+       unsigned int Negate:1;
+};
+
+struct rc_pair_sub_instruction {
+       unsigned int Opcode:8;
+       unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
+       unsigned int WriteMask:4;
+       unsigned int Target:2;
+       unsigned int OutputWriteMask:3;
+       unsigned int DepthWriteMask:1;
+       unsigned int Saturate:1;
+
+       struct rc_pair_instruction_source Src[4];
+       struct rc_pair_instruction_arg Arg[3];
+};
+
+struct rc_pair_instruction {
+       struct rc_pair_sub_instruction RGB;
+       struct rc_pair_sub_instruction Alpha;
+
+       unsigned int WriteALUResult:2;
+       unsigned int ALUResultCompare:3;
+       unsigned int Nop:1;
+};
+
+typedef void (*rc_pair_foreach_src_fn)
+                       (void *, struct rc_pair_instruction_source *);
+
+/**
+ * General helper functions for dealing with the paired instruction format.
+ */
+/*@{*/
+int rc_pair_alloc_source(struct rc_pair_instruction *pair,
+       unsigned int rgb, unsigned int alpha,
+       rc_register_file file, unsigned int index);
+
+void rc_pair_foreach_source_that_alpha_reads(
+       struct rc_pair_instruction * pair,
+       void * data,
+       rc_pair_foreach_src_fn cb);
+
+void rc_pair_foreach_source_that_rgb_reads(
+       struct rc_pair_instruction * pair,
+       void * data,
+       rc_pair_foreach_src_fn cb);
+
+struct rc_pair_instruction_source * rc_pair_get_src(
+       struct rc_pair_instruction * pair_inst,
+       struct rc_pair_instruction_arg * arg);
+
+int rc_pair_get_src_index(
+       struct rc_pair_instruction * pair_inst,
+       struct rc_pair_instruction_source * src);
+/*@}*/
+
+
+/**
+ * Compiler passes that operate with the paired format.
+ */
+/*@{*/
+struct radeon_pair_handler;
+
+void rc_pair_translate(struct radeon_compiler *cc, void *user);
+void rc_pair_schedule(struct radeon_compiler *cc, void *user);
+void rc_pair_regalloc(struct radeon_compiler *cc, void *user);
+void rc_pair_regalloc_inputs_only(struct radeon_compiler *cc, void *user);
+void rc_pair_remove_dead_sources(struct radeon_compiler *c, void *user);
+/*@}*/
+
+#endif /* __RADEON_PROGRAM_PAIR_H_ */
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_print.c b/src/gallium/drivers/r300/compiler/radeon_program_print.c
new file mode 100644 (file)
index 0000000..390d131
--- /dev/null
@@ -0,0 +1,418 @@
+/*
+ * Copyright 2009 Nicolai Hähnle <nhaehnle@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 "radeon_program.h"
+
+#include <stdio.h>
+
+static const char * textarget_to_string(rc_texture_target target)
+{
+       switch(target) {
+       case RC_TEXTURE_2D_ARRAY: return "2D_ARRAY";
+       case RC_TEXTURE_1D_ARRAY: return "1D_ARRAY";
+       case RC_TEXTURE_CUBE: return "CUBE";
+       case RC_TEXTURE_3D: return "3D";
+       case RC_TEXTURE_RECT: return "RECT";
+       case RC_TEXTURE_2D: return "2D";
+       case RC_TEXTURE_1D: return "1D";
+       default: return "BAD_TEXTURE_TARGET";
+       }
+}
+
+static const char * presubtract_op_to_string(rc_presubtract_op op)
+{
+       switch(op) {
+       case RC_PRESUB_NONE:
+               return "NONE";
+       case RC_PRESUB_BIAS:
+               return "(1 - 2 * src0)";
+       case RC_PRESUB_SUB:
+               return "(src1 - src0)";
+       case RC_PRESUB_ADD:
+               return "(src1 + src0)";
+       case RC_PRESUB_INV:
+               return "(1 - src0)";
+       default:
+               return "BAD_PRESUBTRACT_OP";
+       }
+}
+
+static void rc_print_comparefunc(FILE * f, const char * lhs, rc_compare_func func, const char * rhs)
+{
+       if (func == RC_COMPARE_FUNC_NEVER) {
+               fprintf(f, "false");
+       } else if (func == RC_COMPARE_FUNC_ALWAYS) {
+               fprintf(f, "true");
+       } else {
+               const char * op;
+               switch(func) {
+               case RC_COMPARE_FUNC_LESS: op = "<"; break;
+               case RC_COMPARE_FUNC_EQUAL: op = "=="; break;
+               case RC_COMPARE_FUNC_LEQUAL: op = "<="; break;
+               case RC_COMPARE_FUNC_GREATER: op = ">"; break;
+               case RC_COMPARE_FUNC_NOTEQUAL: op = "!="; break;
+               case RC_COMPARE_FUNC_GEQUAL: op = ">="; break;
+               default: op = "???"; break;
+               }
+               fprintf(f, "%s %s %s", lhs, op, rhs);
+       }
+}
+
+static void rc_print_register(FILE * f, rc_register_file file, int index, unsigned int reladdr)
+{
+       if (file == RC_FILE_NONE) {
+               fprintf(f, "none");
+       } else if (file == RC_FILE_SPECIAL) {
+               switch(index) {
+               case RC_SPECIAL_ALU_RESULT: fprintf(f, "aluresult"); break;
+               default: fprintf(f, "special[%i]", index); break;
+               }
+       } else {
+               const char * filename;
+               switch(file) {
+               case RC_FILE_TEMPORARY: filename = "temp"; break;
+               case RC_FILE_INPUT: filename = "input"; break;
+               case RC_FILE_OUTPUT: filename = "output"; break;
+               case RC_FILE_ADDRESS: filename = "addr"; break;
+               case RC_FILE_CONSTANT: filename = "const"; break;
+               default: filename = "BAD FILE"; break;
+               }
+               fprintf(f, "%s[%i%s]", filename, index, reladdr ? " + addr[0]" : "");
+       }
+}
+
+static void rc_print_mask(FILE * f, unsigned int mask)
+{
+       if (mask & RC_MASK_X) fprintf(f, "x");
+       if (mask & RC_MASK_Y) fprintf(f, "y");
+       if (mask & RC_MASK_Z) fprintf(f, "z");
+       if (mask & RC_MASK_W) fprintf(f, "w");
+}
+
+static void rc_print_dst_register(FILE * f, struct rc_dst_register dst)
+{
+       rc_print_register(f, dst.File, dst.Index, 0);
+       if (dst.WriteMask != RC_MASK_XYZW) {
+               fprintf(f, ".");
+               rc_print_mask(f, dst.WriteMask);
+       }
+}
+
+static char rc_swizzle_char(unsigned int swz)
+{
+       switch(swz) {
+       case RC_SWIZZLE_X: return 'x';
+       case RC_SWIZZLE_Y: return 'y';
+       case RC_SWIZZLE_Z: return 'z';
+       case RC_SWIZZLE_W: return 'w';
+       case RC_SWIZZLE_ZERO: return '0';
+       case RC_SWIZZLE_ONE: return '1';
+       case RC_SWIZZLE_HALF: return 'H';
+       case RC_SWIZZLE_UNUSED: return '_';
+       }
+       fprintf(stderr, "bad swz: %u\n", swz);
+       return '?';
+}
+
+static void rc_print_swizzle(FILE * f, unsigned int swizzle, unsigned int negate)
+{
+       unsigned int comp;
+       for(comp = 0; comp < 4; ++comp) {
+               rc_swizzle swz = GET_SWZ(swizzle, comp);
+               if (GET_BIT(negate, comp))
+                       fprintf(f, "-");
+               fprintf(f, "%c", rc_swizzle_char(swz));
+       }
+}
+
+static void rc_print_presub_instruction(FILE * f,
+                                       struct rc_presub_instruction inst)
+{
+       fprintf(f,"(");
+       switch(inst.Opcode){
+       case RC_PRESUB_BIAS:
+               fprintf(f, "1 - 2 * ");
+               rc_print_register(f, inst.SrcReg[0].File,
+                               inst.SrcReg[0].Index,inst.SrcReg[0].RelAddr);
+               break;
+       case RC_PRESUB_SUB:
+               rc_print_register(f, inst.SrcReg[1].File,
+                               inst.SrcReg[1].Index,inst.SrcReg[1].RelAddr);
+               fprintf(f, " - ");
+               rc_print_register(f, inst.SrcReg[0].File,
+                               inst.SrcReg[0].Index,inst.SrcReg[0].RelAddr);
+               break;
+       case RC_PRESUB_ADD:
+               rc_print_register(f, inst.SrcReg[1].File,
+                               inst.SrcReg[1].Index,inst.SrcReg[1].RelAddr);
+               fprintf(f, " + ");
+               rc_print_register(f, inst.SrcReg[0].File,
+                               inst.SrcReg[0].Index,inst.SrcReg[0].RelAddr);
+               break;
+       case RC_PRESUB_INV:
+               fprintf(f, "1 - ");
+               rc_print_register(f, inst.SrcReg[0].File,
+                               inst.SrcReg[0].Index,inst.SrcReg[0].RelAddr);
+               break;
+       default:
+               break;
+       }
+       fprintf(f, ")");
+}
+
+static void rc_print_src_register(FILE * f, struct rc_instruction * inst,
+                                               struct rc_src_register src)
+{
+       int trivial_negate = (src.Negate == RC_MASK_NONE || src.Negate == RC_MASK_XYZW);
+
+       if (src.Negate == RC_MASK_XYZW)
+               fprintf(f, "-");
+       if (src.Abs)
+               fprintf(f, "|");
+
+       if(src.File == RC_FILE_PRESUB)
+               rc_print_presub_instruction(f, inst->U.I.PreSub);
+       else
+               rc_print_register(f, src.File, src.Index, src.RelAddr);
+
+       if (src.Abs && !trivial_negate)
+               fprintf(f, "|");
+
+       if (src.Swizzle != RC_SWIZZLE_XYZW || !trivial_negate) {
+               fprintf(f, ".");
+               rc_print_swizzle(f, src.Swizzle, trivial_negate ? 0 : src.Negate);
+       }
+
+       if (src.Abs && trivial_negate)
+               fprintf(f, "|");
+}
+
+static unsigned update_branch_depth(rc_opcode opcode, unsigned *branch_depth)
+{
+       switch (opcode) {
+       case RC_OPCODE_IF:
+       case RC_OPCODE_BGNLOOP:
+               return (*branch_depth)++ * 2;
+
+       case RC_OPCODE_ENDIF:
+       case RC_OPCODE_ENDLOOP:
+               assert(*branch_depth > 0);
+               return --(*branch_depth) * 2;
+
+       case RC_OPCODE_ELSE:
+               assert(*branch_depth > 0);
+               return (*branch_depth - 1) * 2;
+
+       default:
+               return *branch_depth * 2;
+       }
+}
+
+static void rc_print_normal_instruction(FILE * f, struct rc_instruction * inst, unsigned *branch_depth)
+{
+       const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+       unsigned int reg;
+       unsigned spaces = update_branch_depth(inst->U.I.Opcode, branch_depth);
+
+       for (unsigned i = 0; i < spaces; i++)
+               fprintf(f, " ");
+
+       fprintf(f, "%s", opcode->Name);
+
+       switch(inst->U.I.SaturateMode) {
+       case RC_SATURATE_NONE: break;
+       case RC_SATURATE_ZERO_ONE: fprintf(f, "_SAT"); break;
+       case RC_SATURATE_MINUS_PLUS_ONE: fprintf(f, "_SAT2"); break;
+       default: fprintf(f, "_BAD_SAT"); break;
+       }
+
+       if (opcode->HasDstReg) {
+               fprintf(f, " ");
+               rc_print_dst_register(f, inst->U.I.DstReg);
+               if (opcode->NumSrcRegs)
+                       fprintf(f, ",");
+       }
+
+       for(reg = 0; reg < opcode->NumSrcRegs; ++reg) {
+               if (reg > 0)
+                       fprintf(f, ",");
+               fprintf(f, " ");
+               rc_print_src_register(f, inst, inst->U.I.SrcReg[reg]);
+       }
+
+       if (opcode->HasTexture) {
+               fprintf(f, ", %s%s[%u]",
+                       textarget_to_string(inst->U.I.TexSrcTarget),
+                       inst->U.I.TexShadow ? "SHADOW" : "",
+                       inst->U.I.TexSrcUnit);
+       }
+
+       fprintf(f, ";");
+
+       if (inst->U.I.WriteALUResult) {
+               fprintf(f, " [aluresult = (");
+               rc_print_comparefunc(f,
+                       (inst->U.I.WriteALUResult == RC_ALURESULT_X) ? "x" : "w",
+                       inst->U.I.ALUResultCompare, "0");
+               fprintf(f, ")]");
+       }
+
+       fprintf(f, "\n");
+}
+
+static void rc_print_pair_instruction(FILE * f, struct rc_instruction * fullinst, unsigned *branch_depth)
+{
+       struct rc_pair_instruction * inst = &fullinst->U.P;
+       int printedsrc = 0;
+       unsigned spaces = update_branch_depth(inst->RGB.Opcode != RC_OPCODE_NOP ?
+                                             inst->RGB.Opcode : inst->Alpha.Opcode, branch_depth);
+
+       for (unsigned i = 0; i < spaces; i++)
+               fprintf(f, " ");
+
+       for(unsigned int src = 0; src < 3; ++src) {
+               if (inst->RGB.Src[src].Used) {
+                       if (printedsrc)
+                               fprintf(f, ", ");
+                       fprintf(f, "src%i.xyz = ", src);
+                       rc_print_register(f, inst->RGB.Src[src].File, inst->RGB.Src[src].Index, 0);
+                       printedsrc = 1;
+               }
+               if (inst->Alpha.Src[src].Used) {
+                       if (printedsrc)
+                               fprintf(f, ", ");
+                       fprintf(f, "src%i.w = ", src);
+                       rc_print_register(f, inst->Alpha.Src[src].File, inst->Alpha.Src[src].Index, 0);
+                       printedsrc = 1;
+               }
+       }
+       if(inst->RGB.Src[RC_PAIR_PRESUB_SRC].Used) {
+               fprintf(f, ", srcp.xyz = %s",
+                       presubtract_op_to_string(
+                                       inst->RGB.Src[RC_PAIR_PRESUB_SRC].Index));
+       }
+       if(inst->Alpha.Src[RC_PAIR_PRESUB_SRC].Used) {
+               fprintf(f, ", srcp.w = %s",
+                       presubtract_op_to_string(
+                                       inst->Alpha.Src[RC_PAIR_PRESUB_SRC].Index));
+       }
+       fprintf(f, "\n");
+
+       if (inst->RGB.Opcode != RC_OPCODE_NOP) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->RGB.Opcode);
+
+               for (unsigned i = 0; i < spaces; i++)
+                       fprintf(f, " ");
+
+               fprintf(f, "     %s%s", opcode->Name, inst->RGB.Saturate ? "_SAT" : "");
+               if (inst->RGB.WriteMask)
+                       fprintf(f, " temp[%i].%s%s%s", inst->RGB.DestIndex,
+                               (inst->RGB.WriteMask & 1) ? "x" : "",
+                               (inst->RGB.WriteMask & 2) ? "y" : "",
+                               (inst->RGB.WriteMask & 4) ? "z" : "");
+               if (inst->RGB.OutputWriteMask)
+                       fprintf(f, " color[%i].%s%s%s", inst->RGB.Target,
+                               (inst->RGB.OutputWriteMask & 1) ? "x" : "",
+                               (inst->RGB.OutputWriteMask & 2) ? "y" : "",
+                               (inst->RGB.OutputWriteMask & 4) ? "z" : "");
+               if (inst->WriteALUResult == RC_ALURESULT_X)
+                       fprintf(f, " aluresult");
+
+               for(unsigned int arg = 0; arg < opcode->NumSrcRegs; ++arg) {
+                       const char* abs = inst->RGB.Arg[arg].Abs ? "|" : "";
+                       const char* neg = inst->RGB.Arg[arg].Negate ? "-" : "";
+                       fprintf(f, ", %s%ssrc", neg, abs);
+                       if(inst->RGB.Arg[arg].Source == RC_PAIR_PRESUB_SRC)
+                               fprintf(f,"p");
+                       else
+                               fprintf(f,"%d", inst->RGB.Arg[arg].Source);
+                       fprintf(f,".%c%c%c%s",
+                               rc_swizzle_char(GET_SWZ(inst->RGB.Arg[arg].Swizzle, 0)),
+                               rc_swizzle_char(GET_SWZ(inst->RGB.Arg[arg].Swizzle, 1)),
+                               rc_swizzle_char(GET_SWZ(inst->RGB.Arg[arg].Swizzle, 2)),
+                               abs);
+               }
+               fprintf(f, "\n");
+       }
+
+       if (inst->Alpha.Opcode != RC_OPCODE_NOP) {
+               const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Alpha.Opcode);
+
+               for (unsigned i = 0; i < spaces; i++)
+                       fprintf(f, " ");
+
+               fprintf(f, "     %s%s", opcode->Name, inst->Alpha.Saturate ? "_SAT" : "");
+               if (inst->Alpha.WriteMask)
+                       fprintf(f, " temp[%i].w", inst->Alpha.DestIndex);
+               if (inst->Alpha.OutputWriteMask)
+                       fprintf(f, " color[%i].w", inst->Alpha.Target);
+               if (inst->Alpha.DepthWriteMask)
+                       fprintf(f, " depth.w");
+               if (inst->WriteALUResult == RC_ALURESULT_W)
+                       fprintf(f, " aluresult");
+
+               for(unsigned int arg = 0; arg < opcode->NumSrcRegs; ++arg) {
+                       const char* abs = inst->Alpha.Arg[arg].Abs ? "|" : "";
+                       const char* neg = inst->Alpha.Arg[arg].Negate ? "-" : "";
+                       fprintf(f, ", %s%ssrc", neg, abs);
+                       if(inst->Alpha.Arg[arg].Source == RC_PAIR_PRESUB_SRC)
+                               fprintf(f,"p");
+                       else
+                               fprintf(f,"%d", inst->Alpha.Arg[arg].Source);
+                       fprintf(f,".%c%s",
+                               rc_swizzle_char(GET_SWZ(inst->Alpha.Arg[arg].Swizzle, 0)), abs);
+               }
+               fprintf(f, "\n");
+       }
+
+       if (inst->WriteALUResult) {
+               for (unsigned i = 0; i < spaces; i++)
+                       fprintf(f, " ");
+
+               fprintf(f, "      [aluresult = (");
+               rc_print_comparefunc(f, "result", inst->ALUResultCompare, "0");
+               fprintf(f, ")]\n");
+       }
+}
+
+/**
+ * Print program to stderr, default options.
+ */
+void rc_print_program(const struct rc_program *prog)
+{
+       unsigned int linenum = 0;
+       unsigned branch_depth = 0;
+       struct rc_instruction *inst;
+
+       fprintf(stderr, "# Radeon Compiler Program\n");
+
+       for(inst = prog->Instructions.Next; inst != &prog->Instructions; inst = inst->Next) {
+               fprintf(stderr, "%3d: ", linenum);
+
+               if (inst->Type == RC_INSTRUCTION_PAIR)
+                       rc_print_pair_instruction(stderr, inst, &branch_depth);
+               else
+                       rc_print_normal_instruction(stderr, inst, &branch_depth);
+
+               linenum++;
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_tex.c b/src/gallium/drivers/r300/compiler/radeon_program_tex.c
new file mode 100644 (file)
index 0000000..8d16b2c
--- /dev/null
@@ -0,0 +1,528 @@
+/*
+ * Copyright (C) 2010 Corbin Simpson
+ * Copyright (C) 2010 Marek Olšák <maraeo@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_program_tex.h"
+
+#include "radeon_compiler_util.h"
+
+/* Series of transformations to be done on textures. */
+
+static struct rc_src_register shadow_fail_value(struct r300_fragment_program_compiler *compiler,
+                                               int tmu)
+{
+       struct rc_src_register reg = { 0, };
+
+       if (compiler->enable_shadow_ambient) {
+               reg.File = RC_FILE_CONSTANT;
+               reg.Index = rc_constants_add_state(&compiler->Base.Program.Constants,
+                                                  RC_STATE_SHADOW_AMBIENT, tmu);
+               reg.Swizzle = RC_SWIZZLE_WWWW;
+       } else {
+               reg.File = RC_FILE_NONE;
+               reg.Swizzle = RC_SWIZZLE_0000;
+       }
+
+       reg.Swizzle = combine_swizzles(reg.Swizzle,
+                               compiler->state.unit[tmu].texture_swizzle);
+       return reg;
+}
+
+static struct rc_src_register shadow_pass_value(struct r300_fragment_program_compiler *compiler,
+                                               int tmu)
+{
+       struct rc_src_register reg = { 0, };
+
+       reg.File = RC_FILE_NONE;
+       reg.Swizzle = combine_swizzles(RC_SWIZZLE_1111,
+                               compiler->state.unit[tmu].texture_swizzle);
+       return reg;
+}
+
+static void scale_texcoords(struct r300_fragment_program_compiler *compiler,
+                           struct rc_instruction *inst,
+                           unsigned state_constant)
+{
+       struct rc_instruction *inst_mov;
+
+       unsigned temp = rc_find_free_temporary(&compiler->Base);
+
+       inst_mov = rc_insert_new_instruction(&compiler->Base, inst->Prev);
+
+       inst_mov->U.I.Opcode = RC_OPCODE_MUL;
+       inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+       inst_mov->U.I.DstReg.Index = temp;
+       inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+       inst_mov->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
+       inst_mov->U.I.SrcReg[1].Index =
+                       rc_constants_add_state(&compiler->Base.Program.Constants,
+                                              state_constant, inst->U.I.TexSrcUnit);
+
+       reset_srcreg(&inst->U.I.SrcReg[0]);
+       inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+       inst->U.I.SrcReg[0].Index = temp;
+}
+
+static void projective_divide(struct r300_fragment_program_compiler *compiler,
+                             struct rc_instruction *inst)
+{
+       struct rc_instruction *inst_mul, *inst_rcp;
+
+       unsigned temp = rc_find_free_temporary(&compiler->Base);
+
+       inst_rcp = rc_insert_new_instruction(&compiler->Base, inst->Prev);
+       inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
+       inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
+       inst_rcp->U.I.DstReg.Index = temp;
+       inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
+       inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+       /* Because the input can be arbitrarily swizzled,
+        * read the component mapped to W. */
+       inst_rcp->U.I.SrcReg[0].Swizzle =
+               RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 3));
+
+       inst_mul = rc_insert_new_instruction(&compiler->Base, inst->Prev);
+       inst_mul->U.I.Opcode = RC_OPCODE_MUL;
+       inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
+       inst_mul->U.I.DstReg.Index = temp;
+       inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+       inst_mul->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+       inst_mul->U.I.SrcReg[1].Index = temp;
+       inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
+
+       reset_srcreg(&inst->U.I.SrcReg[0]);
+       inst->U.I.Opcode = RC_OPCODE_TEX;
+       inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+       inst->U.I.SrcReg[0].Index = temp;
+}
+
+/**
+ * Transform TEX, TXP, TXB, and KIL instructions in the following ways:
+ *  - implement texture compare (shadow extensions)
+ *  - extract non-native source / destination operands
+ *  - premultiply texture coordinates for RECT
+ *  - extract operand swizzles
+ *  - introduce a temporary register when write masks are needed
+ */
+int radeonTransformTEX(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst,
+       void* data)
+{
+       struct r300_fragment_program_compiler *compiler =
+               (struct r300_fragment_program_compiler*)data;
+       rc_wrap_mode wrapmode = compiler->state.unit[inst->U.I.TexSrcUnit].wrap_mode;
+       int is_rect = inst->U.I.TexSrcTarget == RC_TEXTURE_RECT ||
+                     compiler->state.unit[inst->U.I.TexSrcUnit].non_normalized_coords;
+
+       if (inst->U.I.Opcode != RC_OPCODE_TEX &&
+               inst->U.I.Opcode != RC_OPCODE_TXB &&
+               inst->U.I.Opcode != RC_OPCODE_TXP &&
+               inst->U.I.Opcode != RC_OPCODE_TXD &&
+               inst->U.I.Opcode != RC_OPCODE_TXL &&
+               inst->U.I.Opcode != RC_OPCODE_KIL)
+               return 0;
+
+       /* ARB_shadow & EXT_shadow_funcs */
+       if (inst->U.I.Opcode != RC_OPCODE_KIL &&
+               ((c->Program.ShadowSamplers & (1 << inst->U.I.TexSrcUnit)) ||
+                (compiler->state.unit[inst->U.I.TexSrcUnit].compare_mode_enabled))) {
+               rc_compare_func comparefunc = compiler->state.unit[inst->U.I.TexSrcUnit].texture_compare_func;
+
+               if (comparefunc == RC_COMPARE_FUNC_NEVER || comparefunc == RC_COMPARE_FUNC_ALWAYS) {
+                       inst->U.I.Opcode = RC_OPCODE_MOV;
+
+                       if (comparefunc == RC_COMPARE_FUNC_ALWAYS) {
+                               inst->U.I.SrcReg[0] = shadow_pass_value(compiler, inst->U.I.TexSrcUnit);
+                       } else {
+                               inst->U.I.SrcReg[0] = shadow_fail_value(compiler, inst->U.I.TexSrcUnit);
+                       }
+
+                       return 1;
+               } else {
+                       struct rc_instruction * inst_rcp = NULL;
+                       struct rc_instruction *inst_mul, *inst_add, *inst_cmp;
+                       unsigned tmp_texsample;
+                       unsigned tmp_sum;
+                       int pass, fail;
+
+                       /* Save the output register. */
+                       struct rc_dst_register output_reg = inst->U.I.DstReg;
+                       unsigned saturate_mode = inst->U.I.SaturateMode;
+
+                       /* Redirect TEX to a new temp. */
+                       tmp_texsample = rc_find_free_temporary(c);
+                       inst->U.I.SaturateMode = 0;
+                       inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst->U.I.DstReg.Index = tmp_texsample;
+                       inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+
+                       tmp_sum = rc_find_free_temporary(c);
+
+                       if (inst->U.I.Opcode == RC_OPCODE_TXP) {
+                               /* Compute 1/W. */
+                               inst_rcp = rc_insert_new_instruction(c, inst);
+                               inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
+                               inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                               inst_rcp->U.I.DstReg.Index = tmp_sum;
+                               inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
+                               inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+                               inst_rcp->U.I.SrcReg[0].Swizzle =
+                                       RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 3));
+                       }
+
+                       /* Divide Z by W (if it's TXP) and saturate. */
+                       inst_mul = rc_insert_new_instruction(c, inst_rcp ? inst_rcp : inst);
+                       inst_mul->U.I.Opcode = inst->U.I.Opcode == RC_OPCODE_TXP ? RC_OPCODE_MUL : RC_OPCODE_MOV;
+                       inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_mul->U.I.DstReg.Index = tmp_sum;
+                       inst_mul->U.I.DstReg.WriteMask = RC_MASK_W;
+                       inst_mul->U.I.SaturateMode = RC_SATURATE_ZERO_ONE;
+                       inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+                       inst_mul->U.I.SrcReg[0].Swizzle =
+                               RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 2));
+                       if (inst->U.I.Opcode == RC_OPCODE_TXP) {
+                               inst_mul->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+                               inst_mul->U.I.SrcReg[1].Index = tmp_sum;
+                               inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
+                       }
+
+                       /* Add the depth texture value. */
+                       inst_add = rc_insert_new_instruction(c, inst_mul);
+                       inst_add->U.I.Opcode = RC_OPCODE_ADD;
+                       inst_add->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_add->U.I.DstReg.Index = tmp_sum;
+                       inst_add->U.I.DstReg.WriteMask = RC_MASK_W;
+                       inst_add->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+                       inst_add->U.I.SrcReg[0].Index = tmp_sum;
+                       inst_add->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW;
+                       inst_add->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+                       inst_add->U.I.SrcReg[1].Index = tmp_texsample;
+                       inst_add->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_XXXX;
+
+                       /* Note that SrcReg[0] is r, SrcReg[1] is tex and:
+                        *   LESS:    r  < tex  <=>      -tex+r < 0
+                        *   GEQUAL:  r >= tex  <=> not (-tex+r < 0)
+                        *   GREATER: r  > tex  <=>       tex-r < 0
+                        *   LEQUAL:  r <= tex  <=> not ( tex-r < 0)
+                        *   EQUAL:   GEQUAL
+                        *   NOTEQUAL:LESS
+                        */
+
+                       /* This negates either r or tex: */
+                       if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GEQUAL ||
+                           comparefunc == RC_COMPARE_FUNC_EQUAL || comparefunc == RC_COMPARE_FUNC_NOTEQUAL)
+                               inst_add->U.I.SrcReg[1].Negate = inst_add->U.I.SrcReg[1].Negate ^ RC_MASK_XYZW;
+                       else
+                               inst_add->U.I.SrcReg[0].Negate = inst_add->U.I.SrcReg[0].Negate ^ RC_MASK_XYZW;
+
+                       /* This negates the whole expresion: */
+                       if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GREATER ||
+                           comparefunc == RC_COMPARE_FUNC_NOTEQUAL) {
+                               pass = 1;
+                               fail = 2;
+                       } else {
+                               pass = 2;
+                               fail = 1;
+                       }
+
+                       inst_cmp = rc_insert_new_instruction(c, inst_add);
+                       inst_cmp->U.I.Opcode = RC_OPCODE_CMP;
+                       inst_cmp->U.I.SaturateMode = saturate_mode;
+                       inst_cmp->U.I.DstReg = output_reg;
+                       inst_cmp->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+                       inst_cmp->U.I.SrcReg[0].Index = tmp_sum;
+                       inst_cmp->U.I.SrcReg[0].Swizzle =
+                                       combine_swizzles(RC_SWIZZLE_WWWW,
+                                                        compiler->state.unit[inst->U.I.TexSrcUnit].texture_swizzle);
+                       inst_cmp->U.I.SrcReg[pass] = shadow_pass_value(compiler, inst->U.I.TexSrcUnit);
+                       inst_cmp->U.I.SrcReg[fail] = shadow_fail_value(compiler, inst->U.I.TexSrcUnit);
+
+                       assert(tmp_texsample != tmp_sum);
+               }
+       }
+
+       /* R300 cannot sample from rectangles and the wrap mode fallback needs
+        * normalized coordinates anyway. */
+       if (inst->U.I.Opcode != RC_OPCODE_KIL &&
+           is_rect && (!c->is_r500 || wrapmode != RC_WRAP_NONE)) {
+               scale_texcoords(compiler, inst, RC_STATE_R300_TEXRECT_FACTOR);
+               inst->U.I.TexSrcTarget = RC_TEXTURE_2D;
+       }
+
+       /* Divide by W if needed. */
+       if (inst->U.I.Opcode == RC_OPCODE_TXP &&
+           (wrapmode == RC_WRAP_REPEAT || wrapmode == RC_WRAP_MIRRORED_REPEAT ||
+            compiler->state.unit[inst->U.I.TexSrcUnit].clamp_and_scale_before_fetch)) {
+               projective_divide(compiler, inst);
+       }
+
+       /* Texture wrap modes don't work on NPOT textures.
+        *
+        * Non-wrapped/clamped texcoords with NPOT are free in HW. Repeat and
+        * mirroring are not. If we need to repeat, we do:
+        *
+        * MUL temp, texcoord, <scaling factor constant>
+        * FRC temp, temp ; Discard integer portion of coords
+        *
+        * This gives us coords in [0, 1].
+        *
+        * Mirroring is trickier. We're going to start out like repeat:
+        *
+        * MUL temp, texcoord, <scaling factor constant> ; De-mirror across axes
+        * MUL temp, temp, 0.5 ; Pattern repeats in [0, 2]
+        *                            ; so scale to [0, 1]
+        * FRC temp, temp ; Make the pattern repeat
+        * MAD temp, temp, 2, -1 ; Move the pattern to [-1, 1]
+        * ADD temp, 1, -abs(temp) ; Now comes a neat trick: use abs to mirror the pattern.
+        *                              ; The pattern is backwards, so reverse it (1-x).
+        *
+        * This gives us coords in [0, 1].
+        *
+        * ~ C & M. ;)
+        */
+       if (inst->U.I.Opcode != RC_OPCODE_KIL &&
+           wrapmode != RC_WRAP_NONE) {
+               struct rc_instruction *inst_mov;
+               unsigned temp = rc_find_free_temporary(c);
+
+               if (wrapmode == RC_WRAP_REPEAT) {
+                       /* Both instructions will be paired up. */
+                       struct rc_instruction *inst_frc = rc_insert_new_instruction(c, inst->Prev);
+
+                       inst_frc->U.I.Opcode = RC_OPCODE_FRC;
+                       inst_frc->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_frc->U.I.DstReg.Index = temp;
+                       inst_frc->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+                       inst_frc->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+               } else if (wrapmode == RC_WRAP_MIRRORED_REPEAT) {
+                       /*
+                        * Function:
+                        *   f(v) = 1 - abs(frac(v * 0.5) * 2 - 1)
+                        *
+                        * Code:
+                        *   MUL temp, src0, 0.5
+                        *   FRC temp, temp
+                        *   MAD temp, temp, 2, -1
+                        *   ADD temp, 1, -abs(temp)
+                        */
+
+                       struct rc_instruction *inst_mul, *inst_frc, *inst_mad, *inst_add;
+                       unsigned two, two_swizzle;
+
+                       inst_mul = rc_insert_new_instruction(c, inst->Prev);
+
+                       inst_mul->U.I.Opcode = RC_OPCODE_MUL;
+                       inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_mul->U.I.DstReg.Index = temp;
+                       inst_mul->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+                       inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+                       inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_HHHH;
+
+                       inst_frc = rc_insert_new_instruction(c, inst->Prev);
+
+                       inst_frc->U.I.Opcode = RC_OPCODE_FRC;
+                       inst_frc->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_frc->U.I.DstReg.Index = temp;
+                       inst_frc->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+                       inst_frc->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+                       inst_frc->U.I.SrcReg[0].Index = temp;
+                       inst_frc->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZ0;
+
+                       two = rc_constants_add_immediate_scalar(&c->Program.Constants, 2, &two_swizzle);
+                       inst_mad = rc_insert_new_instruction(c, inst->Prev);
+
+                       inst_mad->U.I.Opcode = RC_OPCODE_MAD;
+                       inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_mad->U.I.DstReg.Index = temp;
+                       inst_mad->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+                       inst_mad->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+                       inst_mad->U.I.SrcReg[0].Index = temp;
+                       inst_mad->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZ0;
+                       inst_mad->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
+                       inst_mad->U.I.SrcReg[1].Index = two;
+                       inst_mad->U.I.SrcReg[1].Swizzle = two_swizzle;
+                       inst_mad->U.I.SrcReg[2].Swizzle = RC_SWIZZLE_1111;
+                       inst_mad->U.I.SrcReg[2].Negate = RC_MASK_XYZ;
+
+                       inst_add = rc_insert_new_instruction(c, inst->Prev);
+
+                       inst_add->U.I.Opcode = RC_OPCODE_ADD;
+                       inst_add->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_add->U.I.DstReg.Index = temp;
+                       inst_add->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+                       inst_add->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_1111;
+                       inst_add->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+                       inst_add->U.I.SrcReg[1].Index = temp;
+                       inst_add->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_XYZ0;
+                       inst_add->U.I.SrcReg[1].Abs = 1;
+                       inst_add->U.I.SrcReg[1].Negate = RC_MASK_XYZ;
+               } else if (wrapmode == RC_WRAP_MIRRORED_CLAMP) {
+                       /*
+                        * Mirrored clamp modes are bloody simple, we just use abs
+                        * to mirror [0, 1] into [-1, 0]. This works for
+                        * all modes i.e. CLAMP, CLAMP_TO_EDGE, and CLAMP_TO_BORDER.
+                        */
+                       struct rc_instruction *inst_mov;
+
+                       inst_mov = rc_insert_new_instruction(c, inst->Prev);
+
+                       inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+                       inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                       inst_mov->U.I.DstReg.Index = temp;
+                       inst_mov->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+                       inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+                       inst_mov->U.I.SrcReg[0].Abs = 1;
+               }
+
+               /* Preserve W for TXP/TXB. */
+               inst_mov = rc_insert_new_instruction(c, inst->Prev);
+
+               inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+               inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               inst_mov->U.I.DstReg.Index = temp;
+               inst_mov->U.I.DstReg.WriteMask = RC_MASK_W;
+               inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+               reset_srcreg(&inst->U.I.SrcReg[0]);
+               inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+               inst->U.I.SrcReg[0].Index = temp;
+       }
+
+       /* NPOT -> POT conversion for 3D textures. */
+       if (inst->U.I.Opcode != RC_OPCODE_KIL &&
+           compiler->state.unit[inst->U.I.TexSrcUnit].clamp_and_scale_before_fetch) {
+               struct rc_instruction *inst_mov;
+               unsigned temp = rc_find_free_temporary(c);
+
+               /* Saturate XYZ. */
+               inst_mov = rc_insert_new_instruction(c, inst->Prev);
+               inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+               inst_mov->U.I.SaturateMode = RC_SATURATE_ZERO_ONE;
+               inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               inst_mov->U.I.DstReg.Index = temp;
+               inst_mov->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+               inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+               /* Copy W. */
+               inst_mov = rc_insert_new_instruction(c, inst->Prev);
+               inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+               inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               inst_mov->U.I.DstReg.Index = temp;
+               inst_mov->U.I.DstReg.WriteMask = RC_MASK_W;
+               inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+               reset_srcreg(&inst->U.I.SrcReg[0]);
+               inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+               inst->U.I.SrcReg[0].Index = temp;
+
+               scale_texcoords(compiler, inst, RC_STATE_R300_TEXSCALE_FACTOR);
+       }
+
+       /* Convert SNORM-encoded ATI1N sampled as UNORM to SNORM.
+        * Formula: dst = tex > 0.5 ? tex*2-2 : tex*2
+        */
+       if (inst->U.I.Opcode != RC_OPCODE_KIL &&
+           compiler->state.unit[inst->U.I.TexSrcUnit].convert_unorm_to_snorm) {
+               unsigned two, two_swizzle;
+               struct rc_instruction *inst_mul, *inst_mad, *inst_cnd;
+
+               two = rc_constants_add_immediate_scalar(&c->Program.Constants, 2.35, &two_swizzle);
+
+               inst_mul = rc_insert_new_instruction(c, inst);
+               inst_mul->U.I.Opcode = RC_OPCODE_MUL;
+               inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               inst_mul->U.I.DstReg.Index = rc_find_free_temporary(c);
+               inst_mul->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+               inst_mul->U.I.SrcReg[0].Index = rc_find_free_temporary(c); /* redirected TEX output */
+               inst_mul->U.I.SrcReg[1].File = RC_FILE_CONSTANT; /* 2 */
+               inst_mul->U.I.SrcReg[1].Index = two;
+               inst_mul->U.I.SrcReg[1].Swizzle = two_swizzle;
+
+               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;
+               inst_mad->U.I.DstReg.Index = rc_find_free_temporary(c);
+               inst_mad->U.I.SrcReg[0] = inst_mul->U.I.SrcReg[0]; /* redirected TEX output */
+               inst_mad->U.I.SrcReg[1] = inst_mul->U.I.SrcReg[1]; /* 2 */
+               inst_mad->U.I.SrcReg[2] = inst_mul->U.I.SrcReg[1]; /* 2 */
+               inst_mad->U.I.SrcReg[2].Negate = RC_MASK_XYZW;
+
+               inst_cnd = rc_insert_new_instruction(c, inst_mad);
+               inst_cnd->U.I.Opcode = RC_OPCODE_CND;
+               inst_cnd->U.I.SaturateMode = inst->U.I.SaturateMode;
+               inst_cnd->U.I.DstReg = inst->U.I.DstReg;
+               inst_cnd->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+               inst_cnd->U.I.SrcReg[0].Index = inst_mad->U.I.DstReg.Index;
+               inst_cnd->U.I.SrcReg[0].Swizzle = compiler->state.unit[inst->U.I.TexSrcUnit].texture_swizzle;
+               inst_cnd->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+               inst_cnd->U.I.SrcReg[1].Index = inst_mul->U.I.DstReg.Index;
+               inst_cnd->U.I.SrcReg[1].Swizzle = compiler->state.unit[inst->U.I.TexSrcUnit].texture_swizzle;
+               inst_cnd->U.I.SrcReg[2] = inst_mul->U.I.SrcReg[0]; /* redirected TEX output */
+
+               inst->U.I.SaturateMode = 0;
+               inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               inst->U.I.DstReg.Index = inst_mul->U.I.SrcReg[0].Index;
+               inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+       }
+
+       /* Cannot write texture to output registers or with saturate (all chips),
+        * or with masks (non-r500). */
+       if (inst->U.I.Opcode != RC_OPCODE_KIL &&
+               (inst->U.I.DstReg.File != RC_FILE_TEMPORARY ||
+                inst->U.I.SaturateMode ||
+                (!c->is_r500 && inst->U.I.DstReg.WriteMask != RC_MASK_XYZW))) {
+               struct rc_instruction * inst_mov = rc_insert_new_instruction(c, inst);
+
+               inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+               inst_mov->U.I.SaturateMode = inst->U.I.SaturateMode;
+               inst_mov->U.I.DstReg = inst->U.I.DstReg;
+               inst_mov->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+               inst_mov->U.I.SrcReg[0].Index = rc_find_free_temporary(c);
+
+               inst->U.I.SaturateMode = 0;
+               inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               inst->U.I.DstReg.Index = inst_mov->U.I.SrcReg[0].Index;
+               inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+       }
+
+       /* Cannot read texture coordinate from constants file */
+       if (inst->U.I.SrcReg[0].File != RC_FILE_TEMPORARY && inst->U.I.SrcReg[0].File != RC_FILE_INPUT) {
+               struct rc_instruction * inst_mov = rc_insert_new_instruction(c, inst->Prev);
+
+               inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+               inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+               inst_mov->U.I.DstReg.Index = rc_find_free_temporary(c);
+               inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+               reset_srcreg(&inst->U.I.SrcReg[0]);
+               inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+               inst->U.I.SrcReg[0].Index = inst_mov->U.I.DstReg.Index;
+       }
+
+       return 1;
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_tex.h b/src/gallium/drivers/r300/compiler/radeon_program_tex.h
new file mode 100644 (file)
index 0000000..a010505
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 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, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __RADEON_PROGRAM_TEX_H_
+#define __RADEON_PROGRAM_TEX_H_
+
+#include "radeon_compiler.h"
+#include "radeon_program.h"
+
+int radeonTransformTEX(
+       struct radeon_compiler * c,
+       struct rc_instruction * inst,
+       void* data);
+
+#endif /* __RADEON_PROGRAM_TEX_H_ */
diff --git a/src/gallium/drivers/r300/compiler/radeon_remove_constants.c b/src/gallium/drivers/r300/compiler/radeon_remove_constants.c
new file mode 100644 (file)
index 0000000..7d76585
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2010 Marek Olšák <maraeo@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_remove_constants.h"
+#include "radeon_dataflow.h"
+
+struct mark_used_data {
+       unsigned char * const_used;
+       unsigned * has_rel_addr;
+};
+
+static void remap_regs(void * userdata, struct rc_instruction * inst,
+                       rc_register_file * pfile, unsigned int * pindex)
+{
+       unsigned *inv_remap_table = userdata;
+
+       if (*pfile == RC_FILE_CONSTANT) {
+               *pindex = inv_remap_table[*pindex];
+       }
+}
+
+static void mark_used(void * userdata, struct rc_instruction * inst,
+                                               struct rc_src_register * src)
+{
+       struct mark_used_data * d = userdata;
+
+       if (src->File == RC_FILE_CONSTANT) {
+               if (src->RelAddr) {
+                       *d->has_rel_addr = 1;
+               } else {
+                       d->const_used[src->Index] = 1;
+               }
+       }
+}
+
+void rc_remove_unused_constants(struct radeon_compiler *c, void *user)
+{
+       unsigned **out_remap_table = (unsigned**)user;
+       unsigned char *const_used;
+       unsigned *remap_table;
+       unsigned *inv_remap_table;
+       unsigned has_rel_addr = 0;
+       unsigned is_identity = 1;
+       unsigned are_externals_remapped = 0;
+       struct rc_constant *constants = c->Program.Constants.Constants;
+       struct mark_used_data d;
+       unsigned new_count;
+
+       if (!c->Program.Constants.Count) {
+               *out_remap_table = NULL;
+               return;
+       }
+
+       const_used = malloc(c->Program.Constants.Count);
+       memset(const_used, 0, c->Program.Constants.Count);
+
+       d.const_used = const_used;
+       d.has_rel_addr = &has_rel_addr;
+
+       /* Pass 1: Mark used constants. */
+       for (struct rc_instruction *inst = c->Program.Instructions.Next;
+            inst != &c->Program.Instructions; inst = inst->Next) {
+               rc_for_all_reads_src(inst, mark_used, &d);
+       }
+
+       /* Pass 2: If there is relative addressing or dead constant elimination
+        * is disabled, mark all externals as used. */
+       if (has_rel_addr || !c->remove_unused_constants) {
+               for (unsigned i = 0; i < c->Program.Constants.Count; i++)
+                       if (constants[i].Type == RC_CONSTANT_EXTERNAL)
+                               const_used[i] = 1;
+       }
+
+       /* Pass 3: Make the remapping table and remap constants.
+        * This pass removes unused constants simply by overwriting them by other constants. */
+       remap_table = malloc(c->Program.Constants.Count * sizeof(unsigned));
+       inv_remap_table = malloc(c->Program.Constants.Count * sizeof(unsigned));
+       new_count = 0;
+
+       for (unsigned i = 0; i < c->Program.Constants.Count; i++) {
+               if (const_used[i]) {
+                       remap_table[new_count] = i;
+                       inv_remap_table[i] = new_count;
+
+                       if (i != new_count) {
+                               if (constants[i].Type == RC_CONSTANT_EXTERNAL)
+                                       are_externals_remapped = 1;
+
+                               constants[new_count] = constants[i];
+                               is_identity = 0;
+                       }
+                       new_count++;
+               }
+       }
+
+       /*  is_identity ==> new_count == old_count
+        * !is_identity ==> new_count <  old_count */
+       assert( is_identity || new_count <  c->Program.Constants.Count);
+       assert(!((has_rel_addr || !c->remove_unused_constants) && are_externals_remapped));
+
+       /* Pass 4: Redirect reads of all constants to their new locations. */
+       if (!is_identity) {
+               for (struct rc_instruction *inst = c->Program.Instructions.Next;
+                    inst != &c->Program.Instructions; inst = inst->Next) {
+                       rc_remap_registers(inst, remap_regs, inv_remap_table);
+               }
+       }
+
+       /* Set the new constant count. Note that new_count may be less than
+        * Count even though the remapping function is identity. In that case,
+        * the constants have been removed at the end of the array. */
+       c->Program.Constants.Count = new_count;
+
+       if (are_externals_remapped) {
+               *out_remap_table = remap_table;
+       } else {
+               *out_remap_table = NULL;
+               free(remap_table);
+       }
+
+       free(const_used);
+       free(inv_remap_table);
+
+       if (c->Debug & RC_DBG_LOG)
+               rc_constants_print(&c->Program.Constants);
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_remove_constants.h b/src/gallium/drivers/r300/compiler/radeon_remove_constants.h
new file mode 100644 (file)
index 0000000..f29113b
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2010 Marek Olšák <maraeo@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 RADEON_REMOVE_CONSTANTS_H
+#define RADEON_REMOVE_CONSTANTS_H
+
+#include "radeon_compiler.h"
+
+void rc_remove_unused_constants(struct radeon_compiler *c, void *user);
+
+#endif
diff --git a/src/gallium/drivers/r300/compiler/radeon_rename_regs.c b/src/gallium/drivers/r300/compiler/radeon_rename_regs.c
new file mode 100644 (file)
index 0000000..cafa057
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2010 Tom Stellard <tstellar@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * \file
+ */
+
+#include "radeon_rename_regs.h"
+
+#include "radeon_compiler.h"
+#include "radeon_dataflow.h"
+#include "radeon_program.h"
+
+/**
+ * This function renames registers in an attempt to get the code close to
+ * SSA form.  After this function has completed, most of the register are only
+ * written to one time, with a few exceptions.
+ *
+ * This function assumes all the instructions are still of type
+ * RC_INSTRUCTION_NORMAL.
+ */
+void rc_rename_regs(struct radeon_compiler *c, void *user)
+{
+       unsigned int i, used_length;
+       int new_index;
+       struct rc_instruction * inst;
+       struct rc_reader_data reader_data;
+       unsigned char * used;
+
+       /* XXX Remove this once the register allocation works with flow control. */
+       for(inst = c->Program.Instructions.Next;
+                                       inst != &c->Program.Instructions;
+                                       inst = inst->Next) {
+               if (inst->U.I.Opcode == RC_OPCODE_BGNLOOP)
+                       return;
+       }
+
+       used_length = 2 * rc_recompute_ips(c);
+       used = memory_pool_malloc(&c->Pool, sizeof(unsigned char) * used_length);
+       memset(used, 0, sizeof(unsigned char) * used_length);
+
+       rc_get_used_temporaries(c, used, used_length);
+       for(inst = c->Program.Instructions.Next;
+                                       inst != &c->Program.Instructions;
+                                       inst = inst->Next) {
+
+               if (inst->U.I.DstReg.File != RC_FILE_TEMPORARY)
+                       continue;
+
+               reader_data.ExitOnAbort = 1;
+               rc_get_readers(c, inst, &reader_data, NULL, NULL, NULL);
+
+               if (reader_data.Abort || reader_data.ReaderCount == 0)
+                       continue;
+
+               new_index = rc_find_free_temporary_list(c, used, used_length,
+                                               RC_MASK_XYZW);
+               if (new_index < 0) {
+                       rc_error(c, "Ran out of temporary registers\n");
+                       return;
+               }
+
+               reader_data.Writer->U.I.DstReg.Index = new_index;
+               for(i = 0; i < reader_data.ReaderCount; i++) {
+                       reader_data.Readers[i].U.I.Src->Index = new_index;
+               }
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_rename_regs.h b/src/gallium/drivers/r300/compiler/radeon_rename_regs.h
new file mode 100644 (file)
index 0000000..3baf29f
--- /dev/null
@@ -0,0 +1,9 @@
+
+#ifndef RADEON_RENAME_REGS_H
+#define RADEON_RENAME_REGS_H
+
+struct radeon_compiler;
+
+void rc_rename_regs(struct radeon_compiler *c, void *user);
+
+#endif /* RADEON_RENAME_REGS_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_swizzle.h b/src/gallium/drivers/r300/compiler/radeon_swizzle.h
new file mode 100644 (file)
index 0000000..c81d5f7
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 Nicolai Haehnle.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef RADEON_SWIZZLE_H
+#define RADEON_SWIZZLE_H
+
+#include "radeon_program.h"
+
+struct rc_swizzle_split {
+       unsigned char NumPhases;
+       unsigned char Phase[4];
+};
+
+/**
+ * Describe the swizzling capability of target hardware.
+ */
+struct rc_swizzle_caps {
+       /**
+        * Check whether the given swizzle, absolute and negate combination
+        * can be implemented natively by the hardware for this opcode.
+        *
+        * \return 1 if the swizzle is native for the given opcode
+        */
+       int (*IsNative)(rc_opcode opcode, struct rc_src_register reg);
+
+       /**
+        * Determine how to split access to the masked channels of the
+        * given source register to obtain ALU-native swizzles.
+        */
+       void (*Split)(struct rc_src_register reg, unsigned int mask, struct rc_swizzle_split * split);
+};
+
+#endif /* RADEON_SWIZZLE_H */
diff --git a/src/gallium/drivers/r300/compiler/radeon_variable.c b/src/gallium/drivers/r300/compiler/radeon_variable.c
new file mode 100644 (file)
index 0000000..938fb84
--- /dev/null
@@ -0,0 +1,517 @@
+/*
+ * Copyright 2011 Tom Stellard <tstellar@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_variable.h"
+
+#include "memory_pool.h"
+#include "radeon_compiler_util.h"
+#include "radeon_dataflow.h"
+#include "radeon_list.h"
+#include "radeon_opcodes.h"
+#include "radeon_program.h"
+
+/**
+ * Rewrite the index and writemask for the destination register of var
+ * and its friends to new_index and new_writemask.  This function also takes
+ * care of rewriting the swizzles for the sources of var.
+ */
+void rc_variable_change_dst(
+       struct rc_variable * var,
+       unsigned int new_index,
+       unsigned int new_writemask)
+{
+       struct rc_variable * var_ptr;
+       struct rc_list * readers;
+       unsigned int old_mask = rc_variable_writemask_sum(var);
+       unsigned int conversion_swizzle =
+                       rc_make_conversion_swizzle(old_mask, new_writemask);
+
+       for (var_ptr = var; var_ptr; var_ptr = var_ptr->Friend) {
+               if (var_ptr->Inst->Type == RC_INSTRUCTION_NORMAL) {
+                       rc_normal_rewrite_writemask(var_ptr->Inst,
+                                                       conversion_swizzle);
+                       var_ptr->Inst->U.I.DstReg.Index = new_index;
+               } else {
+                       struct rc_pair_sub_instruction * sub;
+                       if (var_ptr->Dst.WriteMask == RC_MASK_W) {
+                               assert(new_writemask & RC_MASK_W);
+                               sub = &var_ptr->Inst->U.P.Alpha;
+                       } else {
+                               sub = &var_ptr->Inst->U.P.RGB;
+                               rc_pair_rewrite_writemask(sub,
+                                                       conversion_swizzle);
+                       }
+                       sub->DestIndex = new_index;
+               }
+       }
+
+       readers = rc_variable_readers_union(var);
+
+       for ( ; readers; readers = readers->Next) {
+               struct rc_reader * reader = readers->Item;
+               if (reader->Inst->Type == RC_INSTRUCTION_NORMAL) {
+                       reader->U.I.Src->Index = new_index;
+                       reader->U.I.Src->Swizzle = rc_rewrite_swizzle(
+                               reader->U.I.Src->Swizzle, conversion_swizzle);
+               } else {
+                       struct rc_pair_instruction * pair_inst =
+                                                       &reader->Inst->U.P;
+                       unsigned int src_type = rc_source_type_swz(
+                                                       reader->U.P.Arg->Swizzle);
+
+                       int src_index = reader->U.P.Arg->Source;
+                       if (src_index == RC_PAIR_PRESUB_SRC) {
+                               src_index = rc_pair_get_src_index(
+                                               pair_inst, reader->U.P.Src);
+                       }
+                       /* Try to delete the old src, it is OK if this fails,
+                        * because rc_pair_alloc_source might be able to
+                        * find a source the ca be reused.
+                        */
+                       if (rc_pair_remove_src(reader->Inst, src_type,
+                                                       src_index, old_mask)) {
+                               /* Reuse the source index of the source that
+                                * was just deleted and set its register
+                                * index.  We can't use rc_pair_alloc_source
+                                * for this becuase it might return a source
+                                * index that is already being used. */
+                               if (src_type & RC_SOURCE_RGB) {
+                                       pair_inst->RGB.Src[src_index]
+                                               .Used = 1;
+                                       pair_inst->RGB.Src[src_index]
+                                               .Index = new_index;
+                                       pair_inst->RGB.Src[src_index]
+                                               .File = RC_FILE_TEMPORARY;
+                               }
+                               if (src_type & RC_SOURCE_ALPHA) {
+                                       pair_inst->Alpha.Src[src_index]
+                                               .Used = 1;
+                                       pair_inst->Alpha.Src[src_index]
+                                               .Index = new_index;
+                                       pair_inst->Alpha.Src[src_index]
+                                               .File = RC_FILE_TEMPORARY;
+                               }
+                       } else {
+                               src_index = rc_pair_alloc_source(
+                                               &reader->Inst->U.P,
+                                               src_type & RC_SOURCE_RGB,
+                                               src_type & RC_SOURCE_ALPHA,
+                                               RC_FILE_TEMPORARY,
+                                               new_index);
+                               if (src_index < 0) {
+                                       rc_error(var->C, "Rewrite of inst %u failed "
+                                               "Can't allocate source for "
+                                               "Inst %u src_type=%x "
+                                               "new_index=%u new_mask=%u\n",
+                                               var->Inst->IP, reader->Inst->IP, src_type, new_index, new_writemask);
+                                               continue;
+                               }
+                       }
+                       reader->U.P.Arg->Swizzle = rc_rewrite_swizzle(
+                               reader->U.P.Arg->Swizzle, conversion_swizzle);
+                       if (reader->U.P.Arg->Source != RC_PAIR_PRESUB_SRC) {
+                               reader->U.P.Arg->Source = src_index;
+                       }
+               }
+       }
+}
+
+/**
+ * Compute the live intervals for var and its friends.
+ */
+void rc_variable_compute_live_intervals(struct rc_variable * var)
+{
+       while(var) {
+               unsigned int i;
+               unsigned int start = var->Inst->IP;
+
+               for (i = 0; i < var->ReaderCount; i++) {
+                       unsigned int chan;
+                       unsigned int chan_start = start;
+                       unsigned int chan_end = var->Readers[i].Inst->IP;
+                       unsigned int mask = var->Readers[i].WriteMask;
+                       struct rc_instruction * inst;
+
+                       /* Extend the live interval of T0 to the start of the
+                        * loop for sequences like:
+                        * BGNLOOP
+                        * read T0
+                        * ...
+                        * write T0
+                        * ENDLOOP
+                        */
+                       if (var->Readers[i].Inst->IP < start) {
+                               struct rc_instruction * bgnloop =
+                                       rc_match_endloop(var->Readers[i].Inst);
+                               chan_start = bgnloop->IP;
+                       }
+
+                       /* Extend the live interval of T0 to the start of the
+                        * loop in case there is a BRK instruction in the loop
+                        * (we don't actually check for a BRK instruction we
+                        * assume there is one somewhere in the loop, which
+                        * there usually is) for sequences like:
+                        * BGNLOOP
+                        * ...
+                        * conditional BRK
+                        * ...
+                        * write T0
+                        * ENDLOOP
+                        * read T0
+                        ***************************************************
+                        * Extend the live interval of T0 to the end of the
+                        * loop for sequences like:
+                        * write T0
+                        * BGNLOOP
+                        * ...
+                        * read T0
+                        * ENDLOOP
+                        */
+                       for (inst = var->Inst; inst != var->Readers[i].Inst;
+                                                       inst = inst->Next) {
+                               rc_opcode op = rc_get_flow_control_inst(inst);
+                               if (op == RC_OPCODE_ENDLOOP) {
+                                       struct rc_instruction * bgnloop =
+                                               rc_match_endloop(inst);
+                                       if (bgnloop->IP < chan_start) {
+                                               chan_start = bgnloop->IP;
+                                       }
+                               } else if (op == RC_OPCODE_BGNLOOP) {
+                                       struct rc_instruction * endloop =
+                                               rc_match_bgnloop(inst);
+                                       if (endloop->IP > chan_end) {
+                                               chan_end = endloop->IP;
+                                       }
+                               }
+                       }
+
+                       for (chan = 0; chan < 4; chan++) {
+                               if ((mask >> chan) & 0x1) {
+                                       if (!var->Live[chan].Used
+                                       || chan_start < var->Live[chan].Start) {
+                                               var->Live[chan].Start =
+                                                               chan_start;
+                                       }
+                                       if (!var->Live[chan].Used
+                                       || chan_end > var->Live[chan].End) {
+                                               var->Live[chan].End = chan_end;
+                                       }
+                                       var->Live[chan].Used = 1;
+                               }
+                       }
+               }
+               var = var->Friend;
+       }
+}
+
+/**
+ * @return 1 if a and b share a reader
+ * @return 0 if they do not
+ */
+static unsigned int readers_intersect(
+       struct rc_variable * a,
+       struct rc_variable * b)
+{
+       unsigned int a_index, b_index;
+       for (a_index = 0; a_index < a->ReaderCount; a_index++) {
+               struct rc_reader reader_a = a->Readers[a_index];
+               for (b_index = 0; b_index < b->ReaderCount; b_index++) {
+                       struct rc_reader reader_b = b->Readers[b_index];
+                       if (reader_a.Inst->Type == RC_INSTRUCTION_NORMAL
+                               && reader_b.Inst->Type == RC_INSTRUCTION_NORMAL
+                               && reader_a.U.I.Src == reader_b.U.I.Src) {
+
+                               return 1;
+                       }
+                       if (reader_a.Inst->Type == RC_INSTRUCTION_PAIR
+                               && reader_b.Inst->Type == RC_INSTRUCTION_PAIR
+                               && reader_a.U.P.Src == reader_b.U.P.Src) {
+
+                               return 1;
+                       }
+               }
+       }
+       return 0;
+}
+
+void rc_variable_add_friend(
+       struct rc_variable * var,
+       struct rc_variable * friend)
+{
+       assert(var->Dst.Index == friend->Dst.Index);
+       while(var->Friend) {
+               var = var->Friend;
+       }
+       var->Friend = friend;
+}
+
+struct rc_variable * rc_variable(
+       struct radeon_compiler * c,
+       unsigned int DstFile,
+       unsigned int DstIndex,
+       unsigned int DstWriteMask,
+       struct rc_reader_data * reader_data)
+{
+       struct rc_variable * new =
+                       memory_pool_malloc(&c->Pool, sizeof(struct rc_variable));
+       memset(new, 0, sizeof(struct rc_variable));
+       new->C = c;
+       new->Dst.File = DstFile;
+       new->Dst.Index = DstIndex;
+       new->Dst.WriteMask = DstWriteMask;
+       if (reader_data) {
+               new->Inst = reader_data->Writer;
+               new->ReaderCount = reader_data->ReaderCount;
+               new->Readers = reader_data->Readers;
+       }
+       return new;
+}
+
+static void get_variable_helper(
+       struct rc_list ** variable_list,
+       struct rc_variable * variable)
+{
+       struct rc_list * list_ptr;
+       for (list_ptr = *variable_list; list_ptr; list_ptr = list_ptr->Next) {
+               if (readers_intersect(variable, list_ptr->Item)) {
+                       rc_variable_add_friend(list_ptr->Item, variable);
+                       return;
+               }
+       }
+       rc_list_add(variable_list, rc_list(&variable->C->Pool, variable));
+}
+
+static void get_variable_pair_helper(
+       struct rc_list ** variable_list,
+       struct radeon_compiler * c,
+       struct rc_instruction * inst,
+       struct rc_pair_sub_instruction * sub_inst)
+{
+       struct rc_reader_data reader_data;
+       struct rc_variable * new_var;
+       rc_register_file file;
+       unsigned int writemask;
+
+       if (sub_inst->Opcode == RC_OPCODE_NOP) {
+               return;
+       }
+       memset(&reader_data, 0, sizeof(struct rc_reader_data));
+       rc_get_readers_sub(c, inst, sub_inst, &reader_data, NULL, NULL, NULL);
+
+       if (reader_data.ReaderCount == 0) {
+               return;
+       }
+
+       if (sub_inst->WriteMask) {
+               file = RC_FILE_TEMPORARY;
+               writemask = sub_inst->WriteMask;
+       } else if (sub_inst->OutputWriteMask) {
+               file = RC_FILE_OUTPUT;
+               writemask = sub_inst->OutputWriteMask;
+       } else {
+               writemask = 0;
+               file = RC_FILE_NONE;
+       }
+       new_var = rc_variable(c, file, sub_inst->DestIndex, writemask,
+                                                               &reader_data);
+       get_variable_helper(variable_list, new_var);
+}
+
+/**
+ * Generate a list of variables used by the shader program.  Each instruction
+ * that writes to a register is considered a variable.  The struct rc_variable
+ * data structure includes a list of readers and is essentially a
+ * definition-use chain.  Any two variables that share a reader are considered
+ * "friends" and they are linked together via the Friend attribute.
+ */
+struct rc_list * rc_get_variables(struct radeon_compiler * c)
+{
+       struct rc_instruction * inst;
+       struct rc_list * variable_list = NULL;
+
+       for (inst = c->Program.Instructions.Next;
+                                       inst != &c->Program.Instructions;
+                                       inst = inst->Next) {
+               struct rc_reader_data reader_data;
+               struct rc_variable * new_var;
+               memset(&reader_data, 0, sizeof(reader_data));
+
+               if (inst->Type == RC_INSTRUCTION_NORMAL) {
+                       rc_get_readers(c, inst, &reader_data, NULL, NULL, NULL);
+                       if (reader_data.ReaderCount == 0) {
+                               continue;
+                       }
+                       new_var = rc_variable(c, inst->U.I.DstReg.File,
+                               inst->U.I.DstReg.Index,
+                               inst->U.I.DstReg.WriteMask, &reader_data);
+                       get_variable_helper(&variable_list, new_var);
+               } else {
+                       get_variable_pair_helper(&variable_list, c, inst,
+                                                       &inst->U.P.RGB);
+                       get_variable_pair_helper(&variable_list, c, inst,
+                                                       &inst->U.P.Alpha);
+               }
+       }
+
+       return variable_list;
+}
+
+/**
+ * @return The bitwise or of the writemasks of a variable and all of its
+ * friends.
+ */
+unsigned int rc_variable_writemask_sum(struct rc_variable * var)
+{
+       unsigned int writemask = 0;
+       while(var) {
+               writemask |= var->Dst.WriteMask;
+               var = var->Friend;
+       }
+       return writemask;
+}
+
+/*
+ * @return A list of readers for a variable and its friends.  Readers
+ * that read from two different variable friends are only included once in
+ * this list.
+ */
+struct rc_list * rc_variable_readers_union(struct rc_variable * var)
+{
+       struct rc_list * list = NULL;
+       while (var) {
+               unsigned int i;
+               for (i = 0; i < var->ReaderCount; i++) {
+                       struct rc_list * temp;
+                       struct rc_reader * a = &var->Readers[i];
+                       unsigned int match = 0;
+                       for (temp = list; temp; temp = temp->Next) {
+                               struct rc_reader * b = temp->Item;
+                               if (a->Inst->Type != b->Inst->Type) {
+                                       continue;
+                               }
+                               if (a->Inst->Type == RC_INSTRUCTION_NORMAL) {
+                                       if (a->U.I.Src == b->U.I.Src) {
+                                               match = 1;
+                                               break;
+                                       }
+                               }
+                               if (a->Inst->Type == RC_INSTRUCTION_PAIR) {
+                                       if (a->U.P.Arg == b->U.P.Arg
+                                           && a->U.P.Src == b->U.P.Src) {
+                                               match = 1;
+                                               break;
+                                       }
+                               }
+                       }
+                       if (match) {
+                               continue;
+                       }
+                       rc_list_add(&list, rc_list(&var->C->Pool, a));
+               }
+               var = var->Friend;
+       }
+       return list;
+}
+
+static unsigned int reader_equals_src(
+       struct rc_reader reader,
+       unsigned int src_type,
+       void * src)
+{
+       if (reader.Inst->Type != src_type) {
+               return 0;
+       }
+       if (src_type == RC_INSTRUCTION_NORMAL) {
+               return reader.U.I.Src == src;
+       } else {
+               return reader.U.P.Src == src;
+       }
+}
+
+static unsigned int variable_writes_src(
+       struct rc_variable * var,
+       unsigned int src_type,
+       void * src)
+{
+       unsigned int i;
+       for (i = 0; i < var->ReaderCount; i++) {
+               if (reader_equals_src(var->Readers[i], src_type, src)) {
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+
+struct rc_list * rc_variable_list_get_writers(
+       struct rc_list * var_list,
+       unsigned int src_type,
+       void * src)
+{
+       struct rc_list * list_ptr;
+       struct rc_list * writer_list = NULL;
+       for (list_ptr = var_list; list_ptr; list_ptr = list_ptr->Next) {
+               struct rc_variable * var = list_ptr->Item;
+               if (variable_writes_src(var, src_type, src)) {
+                       struct rc_variable * friend;
+                       rc_list_add(&writer_list, rc_list(&var->C->Pool, var));
+                       for (friend = var->Friend; friend;
+                                               friend = friend->Friend) {
+                               if (variable_writes_src(friend, src_type, src)) {
+                                       rc_list_add(&writer_list,
+                                               rc_list(&var->C->Pool, friend));
+                               }
+                       }
+                       /* Once we have indentifed the variable and its
+                        * friends that write this source, we can stop
+                        * stop searching, because we know know of the
+                        * other variables in the list will write this source.
+                        * If they did they would be friends of var.
+                        */
+                       break;
+               }
+       }
+       return writer_list;
+}
+
+void rc_variable_print(struct rc_variable * var)
+{
+       unsigned int i;
+       while (var) {
+               fprintf(stderr, "%u: TEMP[%u].%u: ",
+                       var->Inst->IP, var->Dst.Index, var->Dst.WriteMask);
+               for (i = 0; i < 4; i++) {
+                       fprintf(stderr, "chan %u: start=%u end=%u ", i,
+                                       var->Live[i].Start, var->Live[i].End);
+               }
+               fprintf(stderr, "%u readers\n", var->ReaderCount);
+               if (var->Friend) {
+                       fprintf(stderr, "Friend: \n\t");
+               }
+               var = var->Friend;
+       }
+}
diff --git a/src/gallium/drivers/r300/compiler/radeon_variable.h b/src/gallium/drivers/r300/compiler/radeon_variable.h
new file mode 100644 (file)
index 0000000..9427bee
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011 Tom Stellard <tstellar@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 RADEON_VARIABLE_H
+#define RADEON_VARIABLE_H
+
+#include "radeon_compiler.h"
+
+struct radeon_compiler;
+struct rc_list;
+struct rc_reader_data;
+struct rc_readers;
+
+struct live_intervals {
+       int Start;
+       int End;
+       int Used;
+};
+
+struct rc_variable {
+       struct radeon_compiler * C;
+       struct rc_dst_register Dst;
+
+       struct rc_instruction * Inst;
+       unsigned int ReaderCount;
+       struct rc_reader * Readers;
+       struct live_intervals Live[4];
+
+       /* A friend is a variable that shares a reader with another variable.
+        */
+       struct rc_variable * Friend;
+};
+
+void rc_variable_change_dst(
+       struct rc_variable * var,
+       unsigned int new_index,
+       unsigned int new_writemask);
+
+void rc_variable_compute_live_intervals(struct rc_variable * var);
+
+void rc_variable_add_friend(
+       struct rc_variable * var,
+       struct rc_variable * friend);
+
+struct rc_variable * rc_variable(
+       struct radeon_compiler * c,
+       unsigned int DstFile,
+       unsigned int DstIndex,
+       unsigned int DstWriteMask,
+       struct rc_reader_data * reader_data);
+
+struct rc_list * rc_get_variables(struct radeon_compiler * c);
+
+unsigned int rc_variable_writemask_sum(struct rc_variable * var);
+
+struct rc_list * rc_variable_readers_union(struct rc_variable * var);
+
+struct rc_list * rc_variable_list_get_writers(
+       struct rc_list * var_list,
+       unsigned int src_type,
+       void * src);
+
+void rc_variable_print(struct rc_variable * var);
+
+#endif /* RADEON_VARIABLE_H */
diff --git a/src/gallium/drivers/r300/compiler/tests/.gitignore b/src/gallium/drivers/r300/compiler/tests/.gitignore
new file mode 100644 (file)
index 0000000..85672fe
--- /dev/null
@@ -0,0 +1 @@
+radeon_compiler_util_tests
diff --git a/src/gallium/drivers/r300/compiler/tests/Makefile b/src/gallium/drivers/r300/compiler/tests/Makefile
new file mode 100644 (file)
index 0000000..6eda34a
--- /dev/null
@@ -0,0 +1,53 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+CFLAGS += -Wall -Werror
+
+### Basic defines ###
+TESTS =        radeon_compiler_util_tests
+
+TEST_SOURCES := $(TESTS:=.c)
+
+SHARED_SOURCES =               \
+       rc_test_helpers.c       \
+       unit_test.c
+
+C_SOURCES = $(SHARED_SOURCES) $(TEST_SOURCES)
+
+INCLUDES = \
+       -I. \
+       -I..
+
+COMPILER_LIB = ../../libr300.a
+
+##### TARGETS #####
+
+default: depend run_tests
+
+depend: $(C_SOURCES)
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $^ 2> /dev/null
+
+# Remove .o and backup files
+clean:
+       rm -f $(TESTS) depend depend.bak
+
+$(TESTS): $(TESTS:=.o) $(SHARED_SOURCES:.c=.o) $(COMPILER_LIB)
+       $(APP_CC) -o $@ $^
+
+run_tests: $(TESTS)
+       @echo "RUNNING TESTS:"
+       @echo ""
+       $(foreach test, $^, @./$(test))
+
+.PHONY: $(COMPILER_LIB)
+$(COMPILER_LIB):
+       $(MAKE) -C ../..
+
+##### RULES #####
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+
+sinclude depend
diff --git a/src/gallium/drivers/r300/compiler/tests/radeon_compiler_util_tests.c b/src/gallium/drivers/r300/compiler/tests/radeon_compiler_util_tests.c
new file mode 100644 (file)
index 0000000..a2e3f2a
--- /dev/null
@@ -0,0 +1,76 @@
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "radeon_compiler_util.h"
+#include "radeon_program.h"
+
+#include "rc_test_helpers.h"
+#include "unit_test.h"
+
+static void test_rc_inst_can_use_presub(
+       struct test_result * result,
+       int expected,
+       const char * add_str,
+       const char * replace_str)
+{
+       struct rc_instruction add_inst, replace_inst;
+       int ret;
+
+       test_begin(result);
+       init_rc_normal_instruction(&add_inst, add_str);
+       init_rc_normal_instruction(&replace_inst, replace_str);
+
+       ret = rc_inst_can_use_presub(&replace_inst, RC_PRESUB_ADD, 0,
+                       &replace_inst.U.I.SrcReg[0],
+                       &add_inst.U.I.SrcReg[0], &add_inst.U.I.SrcReg[1]);
+
+       test_check(result, ret == expected);
+}
+
+static void test_runner_rc_inst_can_use_presub(struct test_result * result)
+{
+
+       /* This tests the case where the source being replace has the same
+        * register file and register index as another source register in the
+        * CMP instruction.  A previous version of this function was ignoring
+        * all registers that shared the same file and index as the replacement
+        * register when counting the number of source selects.
+        *
+        * https://bugs.freedesktop.org/show_bug.cgi?id=36527
+        */
+       test_rc_inst_can_use_presub(result, 0,
+               "ADD temp[0].z, temp[6].__x_, const[1].__x_;",
+               "CMP temp[0].y, temp[0]._z__, const[0]._z__, temp[0]._y__;");
+
+
+       /* Testing a random case that should fail
+        *
+        * https://bugs.freedesktop.org/show_bug.cgi?id=36527
+        */
+       test_rc_inst_can_use_presub(result, 0,
+               "ADD temp[3], temp[1], temp[2];",
+               "MAD temp[1], temp[0], const[0].xxxx, -temp[3];");
+
+       /* This tests the case where the arguments of the ADD
+        * instruction share the same register file and index.  Normally, we
+        * would need only one source select for these two arguments, but since
+        * they will be part of a presubtract operation we need to use the two
+        * source selects that the presubtract instruction expects
+        * (src0 and src1).
+        *
+        * https://bugs.freedesktop.org/show_bug.cgi?id=36527
+        */
+       test_rc_inst_can_use_presub(result, 0,
+               "ADD temp[3].x, temp[0].x___, temp[0].x___;",
+               "MAD temp[0].xyz, temp[2].xyz_, -temp[3].xxx_, input[5].xyz_;");
+}
+
+int main(int argc, char ** argv)
+{
+       struct test tests[] = {
+               {"rc_inst_can_use_presub()", test_runner_rc_inst_can_use_presub},
+               {NULL, NULL}
+       };
+       run_tests(tests);
+}
diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
new file mode 100644 (file)
index 0000000..ca4738a
--- /dev/null
@@ -0,0 +1,380 @@
+#include <errno.h>
+#include <regex.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "../radeon_compiler_util.h"
+#include "../radeon_opcodes.h"
+#include "../radeon_program.h"
+
+#include "rc_test_helpers.h"
+
+/* This file contains some helper functions for filling out the rc_instruction
+ * data structures.  These functions take a string as input based on the format
+ * output by rc_program_print().
+ */
+
+#define VERBOSE 0
+
+#define DBG(...) do { if (VERBOSE) fprintf(stderr, __VA_ARGS__); } while(0)
+
+#define REGEX_ERR_BUF_SIZE 50
+
+struct match_info {
+       const char * String;
+       int Length;
+};
+
+static int match_length(regmatch_t * matches, int index)
+{
+       return matches[index].rm_eo - matches[index].rm_so;
+}
+
+static int regex_helper(
+       const char * regex_str,
+       const char * search_str,
+       regmatch_t * matches,
+       int num_matches)
+{
+       char err_buf[REGEX_ERR_BUF_SIZE];
+       regex_t regex;
+       int err_code;
+       unsigned int i;
+
+       err_code = regcomp(&regex, regex_str, REG_EXTENDED);
+       if (err_code) {
+               regerror(err_code, &regex, err_buf, REGEX_ERR_BUF_SIZE);
+               fprintf(stderr, "Failed to compile regex: %s\n", err_buf);
+               return 0;
+       }
+
+       err_code = regexec(&regex, search_str, num_matches, matches, 0);
+       DBG("Search string: '%s'\n", search_str);
+       for (i = 0; i < num_matches; i++) {
+               DBG("Match %u start = %d end = %d\n", i,
+                                       matches[i].rm_so, matches[i].rm_eo);
+       }
+       if (err_code) {
+               regerror(err_code, &regex, err_buf, REGEX_ERR_BUF_SIZE);
+               fprintf(stderr, "Failed to match regex: %s\n", err_buf);
+               return 0;
+       }
+       return 1;
+}
+
+#define REGEX_SRC_MATCHES 6
+
+struct src_tokens {
+       struct match_info Negate;
+       struct match_info Abs;
+       struct match_info File;
+       struct match_info Index;
+       struct match_info Swizzle;
+};
+
+/**
+ * Initialize the source register at index src_index for the instruction based
+ * on src_str.
+ *
+ * NOTE: Warning in init_rc_normal_instruction() applies to this function as
+ * well.
+ *
+ * @param src_str A string that represents the source register.  The format for
+ * this string is the same that is output by rc_program_print.
+ * @return 1 On success, 0 on failure
+ */
+int init_rc_normal_src(
+       struct rc_instruction * inst,
+       unsigned int src_index,
+       const char * src_str)
+{
+       const char * regex_str = "(-*)(\\|*)([[:lower:]]*)\\[([[:digit:]])\\](\\.*[[:lower:]-]*)";
+       regmatch_t matches[REGEX_SRC_MATCHES];
+       struct src_tokens tokens;
+       struct rc_src_register * src_reg = &inst->U.I.SrcReg[src_index];
+       unsigned int i;
+
+       /* Execute the regex */
+       if (!regex_helper(regex_str, src_str, matches, REGEX_SRC_MATCHES)) {
+               fprintf(stderr, "Failed to execute regex for src register.\n");
+               return 0;
+       }
+
+       /* Create Tokens */
+       tokens.Negate.String = src_str + matches[1].rm_so;
+       tokens.Negate.Length = match_length(matches, 1);
+       tokens.Abs.String = src_str + matches[2].rm_so;
+       tokens.Abs.Length = match_length(matches, 2);
+       tokens.File.String = src_str + matches[3].rm_so;
+       tokens.File.Length = match_length(matches, 3);
+       tokens.Index.String = src_str + matches[4].rm_so;
+       tokens.Index.Length = match_length(matches, 4);
+       tokens.Swizzle.String = src_str + matches[5].rm_so;
+       tokens.Swizzle.Length = match_length(matches, 5);
+
+       /* Negate */
+       if (tokens.Negate.Length  > 0) {
+               src_reg->Negate = RC_MASK_XYZW;
+       }
+
+       /* Abs */
+       if (tokens.Abs.Length > 0) {
+               src_reg->Abs = 1;
+       }
+
+       /* File */
+       if (!strncmp(tokens.File.String, "temp", tokens.File.Length)) {
+               src_reg->File = RC_FILE_TEMPORARY;
+       } else if (!strncmp(tokens.File.String, "input", tokens.File.Length)) {
+               src_reg->File = RC_FILE_INPUT;
+       } else if (!strncmp(tokens.File.String, "const", tokens.File.Length)) {
+               src_reg->File = RC_FILE_CONSTANT;
+       } else if (!strncmp(tokens.File.String, "none", tokens.File.Length)) {
+               src_reg->File = RC_FILE_NONE;
+       }
+
+       /* Index */
+       errno = 0;
+       src_reg->Index = strtol(tokens.Index.String, NULL, 10);
+       if (errno > 0) {
+               fprintf(stderr, "Could not convert src register index.\n");
+               return 0;
+       }
+
+       /* Swizzle */
+       if (tokens.Swizzle.Length == 0) {
+               src_reg->Swizzle = RC_SWIZZLE_XYZW;
+       } else {
+               int str_index = 1;
+               src_reg->Swizzle = RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_UNUSED);
+               if (tokens.Swizzle.String[0] != '.') {
+                       fprintf(stderr, "First char of swizzle is not valid.\n");
+                       return 0;
+               }
+               for (i = 0; i < 4; i++, str_index++) {
+                       if (tokens.Swizzle.String[str_index] == '-') {
+                               src_reg->Negate |= (1 << i);
+                               str_index++;
+                       }
+                       switch(tokens.Swizzle.String[str_index]) {
+                       case 'x':
+                               SET_SWZ(src_reg->Swizzle, i, RC_SWIZZLE_X);
+                               break;
+                       case 'y':
+                               SET_SWZ(src_reg->Swizzle, i, RC_SWIZZLE_Y);
+                               break;
+                       case 'z':
+                               SET_SWZ(src_reg->Swizzle, i, RC_SWIZZLE_Z);
+                               break;
+                       case 'w':
+                               SET_SWZ(src_reg->Swizzle, i, RC_SWIZZLE_W);
+                               break;
+                       case '1':
+                               SET_SWZ(src_reg->Swizzle, i, RC_SWIZZLE_ONE);
+                               break;
+                       case '0':
+                               SET_SWZ(src_reg->Swizzle, i, RC_SWIZZLE_ZERO);
+                               break;
+                       case 'H':
+                               SET_SWZ(src_reg->Swizzle, i, RC_SWIZZLE_HALF);
+                               break;
+                       case '_':
+                               SET_SWZ(src_reg->Swizzle, i, RC_SWIZZLE_UNUSED);
+                               break;
+                       default:
+                               fprintf(stderr, "Unknown src register swizzle.\n");
+                               return 0;
+                       }
+               }
+       }
+       DBG("File=%u index=%u swizzle=%x negate=%u abs=%u\n",
+                       src_reg->File, src_reg->Index, src_reg->Swizzle,
+                       src_reg->Negate, src_reg->Abs);
+       return 1;
+}
+
+#define REGEX_DST_MATCHES 4
+
+struct dst_tokens {
+       struct match_info File;
+       struct match_info Index;
+       struct match_info WriteMask;
+};
+
+/**
+ * Initialize the destination for the instruction based on dst_str.
+ *
+ * NOTE: Warning in init_rc_normal_instruction() applies to this function as
+ * well.
+ *
+ * @param dst_str A string that represents the destination register.  The format
+ * for this string is the same that is output by rc_program_print.
+ * @return 1 On success, 0 on failure
+ */
+int init_rc_normal_dst(
+       struct rc_instruction * inst,
+       const char * dst_str)
+{
+       const char * regex_str = "([[:lower:]]*)\\[([[:digit:]]*)\\](\\.*[[:lower:]]*)";
+       regmatch_t matches[REGEX_DST_MATCHES];
+       struct dst_tokens tokens;
+       unsigned int i;
+
+       /* Execute the regex */
+       if (!regex_helper(regex_str, dst_str, matches, REGEX_DST_MATCHES)) {
+               fprintf(stderr, "Failed to execute regex for dst register.\n");
+               return 0;
+       }
+
+       /* Create Tokens */
+       tokens.File.String = dst_str + matches[1].rm_so;
+       tokens.File.Length = match_length(matches, 1);
+       tokens.Index.String = dst_str + matches[2].rm_so;
+       tokens.Index.Length = match_length(matches, 2);
+       tokens.WriteMask.String = dst_str + matches[3].rm_so;
+       tokens.WriteMask.Length = match_length(matches, 3);
+
+       /* File Type */
+       if (!strncmp(tokens.File.String, "temp", tokens.File.Length)) {
+               inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
+       } else if (!strncmp(tokens.File.String, "output", tokens.File.Length)) {
+               inst->U.I.DstReg.File = RC_FILE_OUTPUT;
+       } else {
+               fprintf(stderr, "Unknown dst register file type.\n");
+               return 0;
+       }
+
+       /* File Index */
+       errno = 0;
+       inst->U.I.DstReg.Index = strtol(tokens.Index.String, NULL, 10);
+
+       if (errno > 0) {
+               fprintf(stderr, "Could not convert dst register index\n");
+               return 0;
+       }
+
+       /* WriteMask */
+       if (tokens.WriteMask.Length == 0) {
+               inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
+       } else {
+               /* The first character should be '.' */
+               if (tokens.WriteMask.String[0] != '.') {
+                       fprintf(stderr, "1st char of writemask is not valid.\n");
+                       return 0;
+               }
+               for (i = 1; i < tokens.WriteMask.Length; i++) {
+                       switch(tokens.WriteMask.String[i]) {
+                       case 'x':
+                               inst->U.I.DstReg.WriteMask |= RC_MASK_X;
+                               break;
+                       case 'y':
+                               inst->U.I.DstReg.WriteMask |= RC_MASK_Y;
+                               break;
+                       case 'z':
+                               inst->U.I.DstReg.WriteMask |= RC_MASK_Z;
+                               break;
+                       case 'w':
+                               inst->U.I.DstReg.WriteMask |= RC_MASK_W;
+                               break;
+                       default:
+                               fprintf(stderr, "Unknown swizzle in writemask.\n");
+                               return 0;
+                       }
+               }
+       }
+       DBG("Dst Reg File=%u Index=%d Writemask=%d\n",
+                       inst->U.I.DstReg.File,
+                       inst->U.I.DstReg.Index,
+                       inst->U.I.DstReg.WriteMask);
+       return 1;
+}
+
+#define REGEX_INST_MATCHES 7
+
+struct inst_tokens {
+       struct match_info Opcode;
+       struct match_info Sat;
+       struct match_info Dst;
+       struct match_info Srcs[3];
+};
+
+/**
+ * Initialize a normal instruction based on inst_str.
+ *
+ * WARNING: This function might not be able to handle every kind of format that
+ * rc_program_print() can output.  If you are having problems with a
+ * particular string, you may need to add support for it to this functions.
+ *
+ * @param inst_str A string that represents the source register.  The format for
+ * this string is the same that is output by rc_program_print.
+ * @return 1 On success, 0 on failure
+ */
+int init_rc_normal_instruction(
+       struct rc_instruction * inst,
+       const char * inst_str)
+{
+       const char * regex_str = "([[:upper:]]+)(_SAT)* ([^,]*)[, ]*([^,]*)[, ]*([^,]*)[, ]*([^;]*)";
+       int i;
+       regmatch_t matches[REGEX_INST_MATCHES];
+       struct inst_tokens tokens;
+
+       /* Initialize inst */
+       memset(inst, 0, sizeof(struct rc_instruction));
+       inst->Type = RC_INSTRUCTION_NORMAL;
+
+       /* Execute the regex */
+       if (!regex_helper(regex_str, inst_str, matches, REGEX_INST_MATCHES)) {
+               return 0;
+       }
+       memset(&tokens, 0, sizeof(tokens));
+
+       /* Create Tokens */
+       tokens.Opcode.String = inst_str + matches[1].rm_so;
+       tokens.Opcode.Length = match_length(matches, 1);
+       if (matches[2].rm_so > -1) {
+               tokens.Sat.String = inst_str + matches[2].rm_so;
+               tokens.Sat.Length = match_length(matches, 2);
+       }
+
+
+       /* Fill out the rest of the instruction. */
+       for (i = 0; i < MAX_RC_OPCODE; i++) {
+               const struct rc_opcode_info * info = rc_get_opcode_info(i);
+               unsigned int first_src = 3;
+               unsigned int j;
+               if (strncmp(tokens.Opcode.String, info->Name, tokens.Opcode.Length)) {
+                       continue;
+               }
+               inst->U.I.Opcode = info->Opcode;
+               if (info->HasDstReg) {
+                       char * dst_str;
+                       tokens.Dst.String = inst_str + matches[3].rm_so;
+                       tokens.Dst.Length = match_length(matches, 3);
+                       first_src++;
+
+                       dst_str = malloc(sizeof(char) * (tokens.Dst.Length + 1));
+                       strncpy(dst_str, tokens.Dst.String, tokens.Dst.Length);
+                       dst_str[tokens.Dst.Length] = '\0';
+                       init_rc_normal_dst(inst, dst_str);
+                       free(dst_str);
+               }
+               for (j = 0; j < info->NumSrcRegs; j++) {
+                       char * src_str;
+                       tokens.Srcs[j].String =
+                               inst_str + matches[first_src + j].rm_so;
+                       tokens.Srcs[j].Length =
+                               match_length(matches, first_src + j);
+
+                       src_str = malloc(sizeof(char) *
+                                               (tokens.Srcs[j].Length + 1));
+                       strncpy(src_str, tokens.Srcs[j].String,
+                                               tokens.Srcs[j].Length);
+                       src_str[tokens.Srcs[j].Length] = '\0';
+                       init_rc_normal_src(inst, j, src_str);
+               }
+               break;
+       }
+       return 1;
+}
diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.h b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.h
new file mode 100644 (file)
index 0000000..1a6bf96
--- /dev/null
@@ -0,0 +1,13 @@
+
+int init_rc_normal_src(
+       struct rc_instruction * inst,
+       unsigned int src_index,
+       const char * src_str);
+
+int init_rc_normal_dst(
+       struct rc_instruction * inst,
+       const char * dst_str);
+
+int init_rc_normal_instruction(
+       struct rc_instruction * inst,
+       const char * inst_str);
diff --git a/src/gallium/drivers/r300/compiler/tests/unit_test.c b/src/gallium/drivers/r300/compiler/tests/unit_test.c
new file mode 100644 (file)
index 0000000..266f336
--- /dev/null
@@ -0,0 +1,35 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "unit_test.h"
+
+void run_tests(struct test tests[])
+{
+       int i;
+       for (i = 0; tests[i].name; i++) {
+               printf("Test %s\n", tests[i].name);
+               memset(&tests[i].result, 0, sizeof(tests[i].result));
+               tests[i].test_func(&tests[i].result);
+               printf("Test %s (%d/%d) pass\n", tests[i].name,
+                       tests[i].result.pass, tests[i].result.test_count);
+       }
+}
+
+void test_begin(struct test_result * result)
+{
+       result->test_count++;
+}
+
+void test_check(struct test_result * result, int cond)
+{
+       printf("Subtest %u -> ", result->test_count);
+       if (cond) {
+               result->pass++;
+               printf("Pass");
+       } else {
+               result->fail++;
+               printf("Fail");
+       }
+       printf("\n");
+}
diff --git a/src/gallium/drivers/r300/compiler/tests/unit_test.h b/src/gallium/drivers/r300/compiler/tests/unit_test.h
new file mode 100644 (file)
index 0000000..441e8b6
--- /dev/null
@@ -0,0 +1,17 @@
+
+struct test_result {
+       unsigned int test_count;
+       unsigned int pass;
+       unsigned int fail;
+};
+
+struct test {
+       const char * name;
+       void (*test_func)(struct test_result * result);
+       struct test_result result;
+};
+
+void run_tests(struct test tests[]);
+
+void test_begin(struct test_result * result);
+void test_check(struct test_result * result, int cond);
index 388ebcd..db97e49 100644 (file)
@@ -247,7 +247,7 @@ static void r300_clear(struct pipe_context* pipe,
             if (!r300->hyperz_enabled) {
                 r300->hyperz_enabled =
                     r300->rws->cs_request_feature(r300->cs,
-                                                RADEON_FID_HYPERZ_RAM_ACCESS,
+                                                RADEON_FID_R300_HYPERZ_ACCESS,
                                                 TRUE);
                 if (r300->hyperz_enabled) {
                    /* Need to emit HyperZ buffer regs for the first time. */
index 571986c..80148b8 100644 (file)
@@ -31,9 +31,9 @@
  * Radeons. */
 
 /* Parse a PCI ID and fill an r300_capabilities struct with information. */
-void r300_parse_chipset(struct r300_capabilities* caps)
+void r300_parse_chipset(uint32_t pci_id, struct r300_capabilities* caps)
 {
-    switch (caps->pci_id) {
+    switch (pci_id) {
 #define CHIPSET(pci_id, name, chipfamily) \
         case pci_id: \
             caps->family = CHIP_FAMILY_##chipfamily; \
@@ -43,7 +43,7 @@ void r300_parse_chipset(struct r300_capabilities* caps)
 
     default:
         fprintf(stderr, "r300: Warning: Unknown chipset 0x%x\nAborting...",
-                caps->pci_id);
+                pci_id);
         abort();
     }
 
index 4df6b5b..f96cdaf 100644 (file)
@@ -43,16 +43,10 @@ enum r300_zmask_compression {
 /* Structure containing all the possible information about a specific Radeon
  * in the R3xx, R4xx, and R5xx families. */
 struct r300_capabilities {
-    /* PCI ID */
-    uint32_t pci_id;
     /* Chipset family */
     int family;
     /* The number of vertex floating-point units */
     unsigned num_vert_fpus;
-    /* The number of fragment pipes */
-    unsigned num_frag_pipes;
-    /* The number of z pipes */
-    unsigned num_z_pipes;
     /* The number of texture units. */
     unsigned num_tex_units;
     /* Whether or not TCL is physically present */
@@ -121,6 +115,6 @@ enum {
     CHIP_FAMILY_RV570
 };
 
-void r300_parse_chipset(struct r300_capabilities* caps);
+void r300_parse_chipset(uint32_t pci_id, struct r300_capabilities* caps);
 
 #endif /* R300_CHIPSET_H */
index 0554c40..5c22258 100644 (file)
@@ -27,6 +27,8 @@
 #include "util/u_simple_list.h"
 #include "util/u_upload_mgr.h"
 #include "os/os_time.h"
+#include "vl/vl_decoder.h"
+#include "vl/vl_video_buffer.h"
 
 #include "r300_cb.h"
 #include "r300_context.h"
@@ -97,7 +99,7 @@ static void r300_destroy_context(struct pipe_context* context)
     struct r300_context* r300 = r300_context(context);
 
     if (r300->cs && r300->hyperz_enabled) {
-        r300->rws->cs_request_feature(r300->cs, RADEON_FID_HYPERZ_RAM_ACCESS, FALSE);
+        r300->rws->cs_request_feature(r300->cs, RADEON_FID_R300_HYPERZ_ACCESS, FALSE);
     }
 
     if (r300->blitter)
@@ -171,7 +173,7 @@ static boolean r300_setup_atoms(struct r300_context* r300)
     boolean is_rv350 = r300->screen->caps.is_rv350;
     boolean is_r500 = r300->screen->caps.is_r500;
     boolean has_tcl = r300->screen->caps.has_tcl;
-    boolean drm_2_6_0 = r300->rws->get_value(r300->rws, RADEON_VID_DRM_2_6_0);
+    boolean drm_2_6_0 = r300->screen->info.drm_minor >= 6;
 
     /* Create the actual atom list.
      *
@@ -378,7 +380,7 @@ static void r300_init_states(struct pipe_context *pipe)
 
         if (r300->screen->caps.is_r500 ||
             (r300->screen->caps.is_rv350 &&
-             r300->rws->get_value(r300->rws, RADEON_VID_DRM_2_6_0))) {
+             r300->screen->info.drm_minor >= 6)) {
             OUT_CB_REG(R300_GB_Z_PEQ_CONFIG, 0);
         }
         END_CB;
@@ -436,6 +438,9 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300_init_query_functions(r300);
     r300_init_state_functions(r300);
     r300_init_resource_functions(r300);
+    
+    r300->context.create_video_decoder = vl_create_decoder;
+    r300->context.create_video_buffer = vl_video_buffer_create;
 
     r300->vbuf_mgr = u_vbuf_mgr_create(&r300->context, 1024 * 1024, 16,
                                        PIPE_BIND_VERTEX_BUFFER |
@@ -515,15 +520,15 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
                 "r300: DRM version: %d.%d.%d, Name: %s, ID: 0x%04x, GB: %d, Z: %d\n"
                 "r300: GART size: %d MB, VRAM size: %d MB\n"
                 "r300: AA compression RAM: %s, Z compression RAM: %s, HiZ RAM: %s\n",
-                rws->get_value(rws, RADEON_VID_DRM_MAJOR),
-                rws->get_value(rws, RADEON_VID_DRM_MINOR),
-                rws->get_value(rws, RADEON_VID_DRM_PATCHLEVEL),
+                r300->screen->info.drm_major,
+                r300->screen->info.drm_minor,
+                r300->screen->info.drm_patchlevel,
                 screen->get_name(screen),
-                rws->get_value(rws, RADEON_VID_PCI_ID),
-                rws->get_value(rws, RADEON_VID_R300_GB_PIPES),
-                rws->get_value(rws, RADEON_VID_R300_Z_PIPES),
-                rws->get_value(rws, RADEON_VID_GART_SIZE) >> 20,
-                rws->get_value(rws, RADEON_VID_VRAM_SIZE) >> 20,
+                r300->screen->info.pci_id,
+                r300->screen->info.r300_num_gb_pipes,
+                r300->screen->info.r300_num_z_pipes,
+                r300->screen->info.gart_size >> 20,
+                r300->screen->info.vram_size >> 20,
                 "YES", /* XXX really? */
                 r300->screen->caps.zmask_ram ? "YES" : "NO",
                 r300->screen->caps.hiz_ram ? "YES" : "NO");
index d214af4..502aed3 100644 (file)
@@ -574,11 +574,12 @@ static void r300_emit_query_end_frag_pipes(struct r300_context *r300,
                                            struct r300_query *query)
 {
     struct r300_capabilities* caps = &r300->screen->caps;
+    uint32_t gb_pipes = r300->screen->info.r300_num_gb_pipes;
     CS_LOCALS(r300);
 
-    assert(caps->num_frag_pipes);
+    assert(gb_pipes);
 
-    BEGIN_CS(6 * caps->num_frag_pipes + 2);
+    BEGIN_CS(6 * gb_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...
      *
@@ -587,7 +588,7 @@ static void r300_emit_query_end_frag_pipes(struct r300_context *r300,
      * 4-byte offset for each pipe. RV380 and older are special; they have
      * only two pipes, and the second pipe's enable is on bit 3, not bit 1,
      * so there's a chipset cap for that. */
-    switch (caps->num_frag_pipes) {
+    switch (gb_pipes) {
         case 4:
             /* pipe 3 only */
             OUT_CS_REG(R300_SU_REG_DEST, 1 << 3);
@@ -613,7 +614,7 @@ static void r300_emit_query_end_frag_pipes(struct r300_context *r300,
             break;
         default:
             fprintf(stderr, "r300: Implementation error: Chipset reports %d"
-                    " pixel pipes!\n", caps->num_frag_pipes);
+                    " pixel pipes!\n", gb_pipes);
             abort();
     }
 
@@ -663,7 +664,7 @@ void r300_emit_query_end(struct r300_context* r300)
         return;
 
     if (caps->family == CHIP_FAMILY_RV530) {
-        if (caps->num_z_pipes == 2)
+        if (r300->screen->info.r300_num_z_pipes == 2)
             rv530_emit_query_end_double_z(r300, query);
         else
             rv530_emit_query_end_single_z(r300, query);
index 6c1c9d2..234e043 100644 (file)
@@ -24,7 +24,6 @@
 #define R300_EMIT_H
 
 #include "r300_context.h"
-#include "radeon_code.h"
 
 struct rX00_fragment_program_code;
 struct r300_vertex_program_code;
index 34f5419..dc596c4 100644 (file)
@@ -76,7 +76,6 @@ void r300_flush(struct pipe_context *pipe,
         /* Create a fence, which is a dummy BO. */
         *rfence = r300->rws->buffer_create(r300->rws, 1, 1,
                                            PIPE_BIND_VERTEX_BUFFER,
-                                           PIPE_USAGE_STATIC,
                                            RADEON_DOMAIN_GTT);
         /* Add the fence as a dummy relocation. */
         r300->rws->cs_add_reloc(r300->cs,
@@ -121,7 +120,7 @@ void r300_flush(struct pipe_context *pipe,
         }
 
         /* Release HyperZ. */
-        r300->rws->cs_request_feature(r300->cs, RADEON_FID_HYPERZ_RAM_ACCESS,
+        r300->rws->cs_request_feature(r300->cs, RADEON_FID_R300_HYPERZ_ACCESS,
                                       FALSE);
     }
     r300->num_z_clears = 0;
index e3a1bc4..6f21125 100644 (file)
@@ -38,8 +38,7 @@
 #include "r300_texture.h"
 #include "r300_tgsi_to_rc.h"
 
-#include "radeon_code.h"
-#include "radeon_compiler.h"
+#include "compiler/radeon_compiler.h"
 
 /* Convert info about FS input semantics to r300_shader_semantics. */
 void r300_shader_read_fs_inputs(struct tgsi_shader_info* info,
@@ -181,9 +180,10 @@ static void get_external_state(
             v->base.format == PIPE_FORMAT_LATC1_SNORM) {
             unsigned char swizzle[4];
 
-            util_format_combine_swizzles(swizzle,
+            util_format_compose_swizzles(
                             util_format_description(v->base.format)->swizzle,
-                            v->swizzle);
+                            v->swizzle,
+                            swizzle);
 
             state->unit[i].texture_swizzle =
                     RC_MAKE_SWIZZLE(swizzle[0], swizzle[1],
index c86a90b..45c9e88 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "pipe/p_state.h"
 #include "tgsi/tgsi_scan.h"
-#include "radeon_code.h"
+#include "compiler/radeon_code.h"
 #include "r300_shader_semantics.h"
 
 struct r300_fragment_shader_code {
index 782f041..c0357f9 100644 (file)
@@ -49,16 +49,15 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe,
     q->buffer_size = 4096;
 
     if (r300screen->caps.family == CHIP_FAMILY_RV530)
-        q->num_pipes = r300screen->caps.num_z_pipes;
+        q->num_pipes = r300screen->info.r300_num_z_pipes;
     else
-        q->num_pipes = r300screen->caps.num_frag_pipes;
+        q->num_pipes = r300screen->info.r300_num_gb_pipes;
 
     insert_at_tail(&r300->query_list, q);
 
     /* Open up the occlusion query buffer. */
     q->buf = r300->rws->buffer_create(r300->rws, q->buffer_size, 4096,
-                                         PIPE_BIND_CUSTOM, PIPE_USAGE_STREAM,
-                                         q->domain);
+                                         PIPE_BIND_CUSTOM, q->domain);
     q->cs_buf = r300->rws->buffer_get_cs_handle(q->buf);
 
     return (struct pipe_query*)q;
index bb30b1a..5edbb22 100644 (file)
@@ -2078,7 +2078,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_ALU_OUTC_D2A                (3 << 23)
 #       define R300_ALU_OUTC_MIN                (4 << 23)
 #       define R300_ALU_OUTC_MAX                (5 << 23)
-#       define R300_ALU_OUTC_CMPH               (7 << 23)
+#       define R300_ALU_OUTC_CND                (7 << 23)
 #       define R300_ALU_OUTC_CMP                (8 << 23)
 #       define R300_ALU_OUTC_FRC                (9 << 23)
 #       define R300_ALU_OUTC_REPL_ALPHA         (10 << 23)
@@ -2944,6 +2944,23 @@ enum {
 
 /*\}*/
 
+#define PVS_OP_DST_OPERAND(opcode, math_inst, macro_inst, reg_index, reg_writemask, reg_class) \
+        (((opcode & PVS_DST_OPCODE_MASK) << PVS_DST_OPCODE_SHIFT)      \
+        | ((math_inst & PVS_DST_MATH_INST_MASK) << PVS_DST_MATH_INST_SHIFT)    \
+        | ((macro_inst & PVS_DST_MACRO_INST_MASK) << PVS_DST_MACRO_INST_SHIFT) \
+        | ((reg_index & PVS_DST_OFFSET_MASK) << PVS_DST_OFFSET_SHIFT)  \
+        | ((reg_writemask & 0xf) << PVS_DST_WE_X_SHIFT)        /* X Y Z W */   \
+        | ((reg_class & PVS_DST_REG_TYPE_MASK) << PVS_DST_REG_TYPE_SHIFT))
+
+#define PVS_SRC_OPERAND(in_reg_index, comp_x, comp_y, comp_z, comp_w, reg_class, negate)       \
+       (((in_reg_index & PVS_SRC_OFFSET_MASK) << PVS_SRC_OFFSET_SHIFT)                         \
+        | ((comp_x & PVS_SRC_SWIZZLE_X_MASK) << PVS_SRC_SWIZZLE_X_SHIFT)                       \
+        | ((comp_y & PVS_SRC_SWIZZLE_Y_MASK) << PVS_SRC_SWIZZLE_Y_SHIFT)                       \
+        | ((comp_z & PVS_SRC_SWIZZLE_Z_MASK) << PVS_SRC_SWIZZLE_Z_SHIFT)                       \
+        | ((comp_w & PVS_SRC_SWIZZLE_W_MASK) << PVS_SRC_SWIZZLE_W_SHIFT)                       \
+        | ((negate & 0xf) << PVS_SRC_MODIFIER_X_SHIFT) /* X Y Z W */                           \
+        | ((reg_class & PVS_SRC_REG_TYPE_MASK) << PVS_SRC_REG_TYPE_SHIFT))
+
 /* BEGIN: Packet 3 commands */
 
 /* A primitive emission dword. */
@@ -3249,6 +3266,8 @@ enum {
 #   define R500_INST_RGB_CLAMP                         (1 << 19)
 #   define R500_INST_ALPHA_CLAMP                       (1 << 20)
 #   define R500_INST_ALU_RESULT_SEL                    (1 << 21)
+#   define R500_INST_ALU_RESULT_SEL_RED                        (0 << 21)
+#   define R500_INST_ALU_RESULT_SEL_ALPHA              (1 << 21)
 #   define R500_INST_ALPHA_PRED_INV                    (1 << 22)
 #   define R500_INST_ALU_RESULT_OP_EQ                  (0 << 23)
 #   define R500_INST_ALU_RESULT_OP_LT                  (1 << 23)
index d9399d7..b31141a 100644 (file)
@@ -175,8 +175,8 @@ static void r300_split_index_bias(struct r300_context *r300, int index_bias,
 enum r300_prepare_flags {
     PREP_EMIT_STATES    = (1 << 0), /* call emit_dirty_state and friends? */
     PREP_VALIDATE_VBOS  = (1 << 1), /* validate VBOs? */
-    PREP_EMIT_AOS       = (1 << 2), /* call emit_vertex_arrays? */
-    PREP_EMIT_AOS_SWTCL = (1 << 3), /* call emit_vertex_arrays_swtcl? */
+    PREP_EMIT_VARRAYS       = (1 << 2), /* call emit_vertex_arrays? */
+    PREP_EMIT_VARRAYS_SWTCL = (1 << 3), /* call emit_vertex_arrays_swtcl? */
     PREP_INDEXED        = (1 << 4)  /* is this draw_elements? */
 };
 
@@ -193,23 +193,22 @@ static boolean r300_reserve_cs_dwords(struct r300_context *r300,
                                       unsigned cs_dwords)
 {
     boolean flushed        = FALSE;
-    boolean first_draw     = flags & PREP_EMIT_STATES;
-    boolean emit_vertex_arrays       = flags & PREP_EMIT_AOS;
-    boolean emit_vertex_arrays_swtcl = flags & PREP_EMIT_AOS_SWTCL;
+    boolean emit_states    = flags & PREP_EMIT_STATES;
+    boolean emit_vertex_arrays       = flags & PREP_EMIT_VARRAYS;
+    boolean emit_vertex_arrays_swtcl = flags & PREP_EMIT_VARRAYS_SWTCL;
 
     /* Add dirty state, index offset, and AOS. */
-    if (first_draw) {
+    if (emit_states)
         cs_dwords += r300_get_num_dirty_dwords(r300);
 
-        if (r300->screen->caps.is_r500)
-            cs_dwords += 2; /* emit_index_offset */
+    if (r300->screen->caps.is_r500)
+        cs_dwords += 2; /* emit_index_offset */
 
-        if (emit_vertex_arrays)
-            cs_dwords += 55; /* emit_vertex_arrays */
+    if (emit_vertex_arrays)
+        cs_dwords += 55; /* emit_vertex_arrays */
 
-        if (emit_vertex_arrays_swtcl)
-            cs_dwords += 7; /* emit_vertex_arrays_swtcl */
-    }
+    if (emit_vertex_arrays_swtcl)
+        cs_dwords += 7; /* emit_vertex_arrays_swtcl */
 
     cs_dwords += r300_get_num_cs_end_dwords(r300);
 
@@ -238,46 +237,48 @@ static boolean r300_emit_states(struct r300_context *r300,
                                 int buffer_offset,
                                 int index_bias, int instance_id)
 {
-    boolean first_draw     = flags & PREP_EMIT_STATES;
-    boolean emit_vertex_arrays       = flags & PREP_EMIT_AOS;
-    boolean emit_vertex_arrays_swtcl = flags & PREP_EMIT_AOS_SWTCL;
+    boolean emit_states    = flags & PREP_EMIT_STATES;
+    boolean emit_vertex_arrays       = flags & PREP_EMIT_VARRAYS;
+    boolean emit_vertex_arrays_swtcl = flags & PREP_EMIT_VARRAYS_SWTCL;
     boolean indexed        = flags & PREP_INDEXED;
     boolean validate_vbos  = flags & PREP_VALIDATE_VBOS;
 
     /* Validate buffers and emit dirty state if needed. */
-    if (first_draw) {
+    if (emit_states || (emit_vertex_arrays && validate_vbos)) {
         if (!r300_emit_buffer_validate(r300, validate_vbos,
                                        index_buffer)) {
            fprintf(stderr, "r300: CS space validation failed. "
                    "(not enough memory?) Skipping rendering.\n");
            return FALSE;
         }
+    }
 
+    if (emit_states)
         r300_emit_dirty_state(r300);
-        if (r300->screen->caps.is_r500) {
-            if (r300->screen->caps.has_tcl)
-                r500_emit_index_bias(r300, index_bias);
-            else
-                r500_emit_index_bias(r300, 0);
-        }
 
-        if (emit_vertex_arrays &&
-            (r300->vertex_arrays_dirty ||
-             r300->vertex_arrays_indexed != indexed ||
-             r300->vertex_arrays_offset != buffer_offset ||
-             r300->vertex_arrays_instance_id != instance_id)) {
-            r300_emit_vertex_arrays(r300, buffer_offset, indexed, instance_id);
-
-            r300->vertex_arrays_dirty = FALSE;
-            r300->vertex_arrays_indexed = indexed;
-            r300->vertex_arrays_offset = buffer_offset;
-            r300->vertex_arrays_instance_id = instance_id;
-        }
+    if (r300->screen->caps.is_r500) {
+        if (r300->screen->caps.has_tcl)
+            r500_emit_index_bias(r300, index_bias);
+        else
+            r500_emit_index_bias(r300, 0);
+    }
 
-        if (emit_vertex_arrays_swtcl)
-            r300_emit_vertex_arrays_swtcl(r300, indexed);
+    if (emit_vertex_arrays &&
+        (r300->vertex_arrays_dirty ||
+         r300->vertex_arrays_indexed != indexed ||
+         r300->vertex_arrays_offset != buffer_offset ||
+         r300->vertex_arrays_instance_id != instance_id)) {
+        r300_emit_vertex_arrays(r300, buffer_offset, indexed, instance_id);
+
+        r300->vertex_arrays_dirty = FALSE;
+        r300->vertex_arrays_indexed = indexed;
+        r300->vertex_arrays_offset = buffer_offset;
+        r300->vertex_arrays_instance_id = instance_id;
     }
 
+    if (emit_vertex_arrays_swtcl)
+        r300_emit_vertex_arrays_swtcl(r300, indexed);
+
     return TRUE;
 }
 
@@ -540,7 +541,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
 
     /* 19 dwords for r300_draw_elements_immediate. Give up if the function fails. */
     if (!r300_prepare_for_rendering(r300,
-            PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_AOS |
+            PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS |
             PREP_INDEXED, NULL, 2+count_dwords, 0, info->index_bias, -1))
         return;
 
@@ -662,7 +663,7 @@ static void r300_draw_elements(struct r300_context *r300,
 
     /* 19 dwords for emit_draw_elements. Give up if the function fails. */
     if (!r300_prepare_for_rendering(r300,
-            PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_AOS |
+            PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS |
             PREP_INDEXED, indexBuffer, 19, buffer_offset, info->index_bias,
             instance_id))
         goto done;
@@ -689,7 +690,7 @@ static void r300_draw_elements(struct r300_context *r300,
             /* 15 dwords for emit_draw_elements */
             if (count) {
                 if (!r300_prepare_for_rendering(r300,
-                        PREP_VALIDATE_VBOS | PREP_EMIT_AOS | PREP_INDEXED,
+                        PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS | PREP_INDEXED,
                         indexBuffer, 19, buffer_offset, info->index_bias,
                         instance_id))
                     goto done;
@@ -715,7 +716,7 @@ static void r300_draw_arrays(struct r300_context *r300,
 
     /* 9 spare dwords for emit_draw_arrays. Give up if the function fails. */
     if (!r300_prepare_for_rendering(r300,
-                                    PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_AOS,
+                                    PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS,
                                     NULL, 9, start, 0, instance_id))
         return;
 
@@ -736,7 +737,7 @@ static void r300_draw_arrays(struct r300_context *r300,
             /* 9 spare dwords for emit_draw_arrays. Give up if the function fails. */
             if (count) {
                 if (!r300_prepare_for_rendering(r300,
-                                                PREP_VALIDATE_VBOS | PREP_EMIT_AOS, NULL, 9,
+                                                PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS, NULL, 9,
                                                 start, 0, instance_id))
                     return;
             }
@@ -767,7 +768,6 @@ static void r300_draw_vbo(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
     struct pipe_draw_info info = *dinfo;
-    boolean buffers_updated, uploader_flushed;
 
     info.indexed = info.indexed && r300->index_buffer.buffer;
 
@@ -779,9 +779,7 @@ static void r300_draw_vbo(struct pipe_context* pipe,
     r300_update_derived_state(r300);
 
     /* Start the vbuf manager and update buffers if needed. */
-    u_vbuf_mgr_draw_begin(r300->vbuf_mgr, &info,
-                          &buffers_updated, &uploader_flushed);
-    if (buffers_updated) {
+    if (u_vbuf_mgr_draw_begin(r300->vbuf_mgr, &info) & U_VBUF_BUFFERS_UPDATED) {
         r300->vertex_arrays_dirty = TRUE;
     }
 
@@ -843,7 +841,7 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
     r300_update_derived_state(r300);
 
     r300_reserve_cs_dwords(r300,
-            PREP_EMIT_STATES | PREP_EMIT_AOS_SWTCL |
+            PREP_EMIT_STATES | PREP_EMIT_VARRAYS_SWTCL |
             (indexed ? PREP_INDEXED : 0),
             indexed ? 256 : 6);
 
@@ -1025,12 +1023,12 @@ static void r300_render_draw_arrays(struct vbuf_render* render,
 
     if (r300->draw_first_emitted) {
         if (!r300_prepare_for_rendering(r300,
-                PREP_EMIT_STATES | PREP_EMIT_AOS_SWTCL,
+                PREP_EMIT_STATES | PREP_EMIT_VARRAYS_SWTCL,
                 NULL, dwords, 0, 0, -1))
             return;
     } else {
         if (!r300_emit_states(r300,
-                PREP_EMIT_STATES | PREP_EMIT_AOS_SWTCL,
+                PREP_EMIT_STATES | PREP_EMIT_VARRAYS_SWTCL,
                 NULL, 0, 0, -1))
             return;
     }
@@ -1065,12 +1063,12 @@ static void r300_render_draw_elements(struct vbuf_render* render,
 
     if (r300->draw_first_emitted) {
         if (!r300_prepare_for_rendering(r300,
-                PREP_EMIT_STATES | PREP_EMIT_AOS_SWTCL | PREP_INDEXED,
+                PREP_EMIT_STATES | PREP_EMIT_VARRAYS_SWTCL | PREP_INDEXED,
                 NULL, 256, 0, 0, -1))
             return;
     } else {
         if (!r300_emit_states(r300,
-                PREP_EMIT_STATES | PREP_EMIT_AOS_SWTCL | PREP_INDEXED,
+                PREP_EMIT_STATES | PREP_EMIT_VARRAYS_SWTCL | PREP_INDEXED,
                 NULL, 0, 0, -1))
             return;
     }
@@ -1107,7 +1105,7 @@ static void r300_render_draw_elements(struct vbuf_render* render,
 
         if (count) {
             if (!r300_prepare_for_rendering(r300,
-                    PREP_EMIT_AOS_SWTCL | PREP_INDEXED,
+                    PREP_EMIT_VARRAYS_SWTCL | PREP_INDEXED,
                     NULL, 256, 0, 0, -1))
                 return;
 
index 93baba6..47de400 100644 (file)
@@ -25,6 +25,8 @@
 #include "util/u_format_s3tc.h"
 #include "util/u_memory.h"
 #include "os/os_time.h"
+#include "vl/vl_decoder.h"
+#include "vl/vl_video_buffer.h"
 
 #include "r300_context.h"
 #include "r300_texture.h"
@@ -304,15 +306,31 @@ static float r300_get_paramf(struct pipe_screen* pscreen, enum pipe_cap param)
     }
 }
 
+static int r300_get_video_param(struct pipe_screen *screen,
+                               enum pipe_video_profile profile,
+                               enum pipe_video_cap param)
+{
+   switch (param) {
+      case PIPE_VIDEO_CAP_SUPPORTED:
+         return vl_profile_supported(screen, profile);
+      case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+         return 0;
+      case PIPE_VIDEO_CAP_MAX_WIDTH:
+      case PIPE_VIDEO_CAP_MAX_HEIGHT:
+         return vl_video_buffer_max_size(screen);
+      default:
+         return 0;
+   }
+}
+
 static boolean r300_is_format_supported(struct pipe_screen* screen,
                                         enum pipe_format format,
                                         enum pipe_texture_target target,
                                         unsigned sample_count,
                                         unsigned usage)
 {
-    struct radeon_winsys *rws = r300_screen(screen)->rws;
     uint32_t retval = 0;
-    boolean drm_2_8_0 = rws->get_value(rws, RADEON_VID_DRM_2_8_0);
+    boolean drm_2_8_0 = r300_screen(screen)->info.drm_minor >= 8;
     boolean is_r500 = r300_screen(screen)->caps.is_r500;
     boolean is_r400 = r300_screen(screen)->caps.is_r400;
     boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM ||
@@ -480,19 +498,17 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws)
         return NULL;
     }
 
-    r300screen->caps.pci_id = rws->get_value(rws, RADEON_VID_PCI_ID);
-    r300screen->caps.num_frag_pipes = rws->get_value(rws, RADEON_VID_R300_GB_PIPES);
-    r300screen->caps.num_z_pipes = rws->get_value(rws, RADEON_VID_R300_Z_PIPES);
+    rws->query_info(rws, &r300screen->info);
 
     r300_init_debug(r300screen);
-    r300_parse_chipset(&r300screen->caps);
+    r300_parse_chipset(r300screen->info.pci_id, &r300screen->caps);
 
     if (SCREEN_DBG_ON(r300screen, DBG_NO_ZMASK))
         r300screen->caps.zmask_ram = 0;
     if (SCREEN_DBG_ON(r300screen, DBG_NO_HIZ))
         r300screen->caps.hiz_ram = 0;
 
-    if (!rws->get_value(rws, RADEON_VID_DRM_2_8_0))
+    if (r300screen->info.drm_minor < 8)
         r300screen->caps.has_us_format = FALSE;
 
     pipe_mutex_init(r300screen->num_contexts_mutex);
@@ -509,9 +525,10 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws)
     r300screen->screen.get_param = r300_get_param;
     r300screen->screen.get_shader_param = r300_get_shader_param;
     r300screen->screen.get_paramf = r300_get_paramf;
+    r300screen->screen.get_video_param = r300_get_video_param;
     r300screen->screen.is_format_supported = r300_is_format_supported;
+    r300screen->screen.is_video_format_supported = vl_video_buffer_is_format_supported;
     r300screen->screen.context_create = r300_create_context;
-
     r300screen->screen.fence_reference = r300_fence_reference;
     r300screen->screen.fence_signalled = r300_fence_signalled;
     r300screen->screen.fence_finish = r300_fence_finish;
index e5c53bf..82b2068 100644 (file)
 #ifndef R300_SCREEN_H
 #define R300_SCREEN_H
 
-#include "pipe/p_screen.h"
-
 #include "r300_chipset.h"
-
+#include "../../winsys/radeon/drm/radeon_winsys.h"
+#include "pipe/p_screen.h"
 #include "util/u_slab.h"
-
 #include <stdio.h>
 
-struct radeon_winsys;
-
 struct r300_screen {
     /* Parent class */
     struct pipe_screen screen;
 
     struct radeon_winsys *rws;
 
-    /* Chipset capabilities */
+    /* Chipset info and capabilities. */
+    struct radeon_info info;
     struct r300_capabilities caps;
 
     /* Memory pools. */
index 4154c81..c751a94 100644 (file)
@@ -201,8 +201,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
     rbuf->buf =
         r300screen->rws->buffer_create(r300screen->rws,
                                        rbuf->b.b.b.width0, alignment,
-                                       rbuf->b.b.b.bind, rbuf->b.b.b.usage,
-                                       rbuf->domain);
+                                       rbuf->b.b.b.bind, rbuf->domain);
     if (!rbuf->buf) {
         util_slab_free(&r300screen->pool_buffers, rbuf);
         return NULL;
index f63114e..45c11fc 100644 (file)
@@ -605,7 +605,6 @@ static uint32_t r300_get_border_color(enum pipe_format format,
 {
     const struct util_format_description *desc;
     float border_swizzled[4] = {0};
-    unsigned i;
     union util_color uc = {0};
 
     desc = util_format_description(format);
@@ -629,22 +628,7 @@ static uint32_t r300_get_border_color(enum pipe_format format,
     }
 
     /* Apply inverse swizzle of the format. */
-    for (i = 0; i < 4; i++) {
-        switch (desc->swizzle[i]) {
-        case UTIL_FORMAT_SWIZZLE_X:
-            border_swizzled[0] = border[i];
-            break;
-        case UTIL_FORMAT_SWIZZLE_Y:
-            border_swizzled[1] = border[i];
-            break;
-        case UTIL_FORMAT_SWIZZLE_Z:
-            border_swizzled[2] = border[i];
-            break;
-        case UTIL_FORMAT_SWIZZLE_W:
-            border_swizzled[3] = border[i];
-            break;
-        }
-    }
+    util_format_unswizzle_4f(border_swizzled, border, desc->swizzle);
 
     /* Compressed formats. */
     if (util_format_is_compressed(format)) {
index 38ca9a2..fc84004 100644 (file)
 
 #include "pipe/p_screen.h"
 
-void util_format_combine_swizzles(unsigned char *dst,
-                                  const unsigned char *swz1,
-                                  const unsigned char *swz2)
-{
-    unsigned i;
-
-    for (i = 0; i < 4; i++) {
-        dst[i] = swz2[i] <= UTIL_FORMAT_SWIZZLE_W ?
-                 swz1[swz2[i]] : swz2[i];
-    }
-}
-
 unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
                                    const unsigned char *swizzle_view,
                                    boolean dxtc_swizzle)
@@ -72,7 +60,7 @@ unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
 
     if (swizzle_view) {
         /* Combine two sets of swizzles. */
-        util_format_combine_swizzles(swizzle, swizzle_format, swizzle_view);
+        util_format_compose_swizzles(swizzle_format, swizzle_view, swizzle);
     } else {
         memcpy(swizzle, swizzle_format, 4);
     }
@@ -447,16 +435,8 @@ static uint32_t r300_translate_colorformat(enum pipe_format format)
         /*case PIPE_FORMAT_B8G8R8A8_SNORM:*/
         case PIPE_FORMAT_B8G8R8X8_UNORM:
         /*case PIPE_FORMAT_B8G8R8X8_SNORM:*/
-        case PIPE_FORMAT_A8R8G8B8_UNORM:
-        /*case PIPE_FORMAT_A8R8G8B8_SNORM:*/
-        case PIPE_FORMAT_X8R8G8B8_UNORM:
-        /*case PIPE_FORMAT_X8R8G8B8_SNORM:*/
-        case PIPE_FORMAT_A8B8G8R8_UNORM:
-        /*case PIPE_FORMAT_A8B8G8R8_SNORM:*/
         case PIPE_FORMAT_R8G8B8A8_UNORM:
         case PIPE_FORMAT_R8G8B8A8_SNORM:
-        case PIPE_FORMAT_X8B8G8R8_UNORM:
-        /*case PIPE_FORMAT_X8B8G8R8_SNORM:*/
         case PIPE_FORMAT_R8G8B8X8_UNORM:
         /*case PIPE_FORMAT_R8G8B8X8_SNORM:*/
         /* These formats work fine with ARGB8888 if US_OUT_FMT is set
@@ -662,10 +642,6 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format)
                 R300_C2_SEL_R | R300_C3_SEL_A;
 
         /* ARGB outputs. */
-        case PIPE_FORMAT_A8R8G8B8_UNORM:
-        /*case PIPE_FORMAT_A8R8G8B8_SNORM:*/
-        case PIPE_FORMAT_X8R8G8B8_UNORM:
-        /*case PIPE_FORMAT_X8R8G8B8_SNORM:*/
         case PIPE_FORMAT_A16_UNORM:
         case PIPE_FORMAT_A16_SNORM:
         case PIPE_FORMAT_A16_FLOAT:
@@ -674,15 +650,6 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format)
                 R300_C0_SEL_A | R300_C1_SEL_R |
                 R300_C2_SEL_G | R300_C3_SEL_B;
 
-        /* ABGR outputs. */
-        case PIPE_FORMAT_A8B8G8R8_UNORM:
-        /*case PIPE_FORMAT_A8B8G8R8_SNORM:*/
-        case PIPE_FORMAT_X8B8G8R8_UNORM:
-        /*case PIPE_FORMAT_X8B8G8R8_SNORM:*/
-            return modifier |
-                R300_C0_SEL_A | R300_C1_SEL_B |
-                R300_C2_SEL_G | R300_C3_SEL_R;
-
         /* RGBA outputs. */
         case PIPE_FORMAT_R8G8B8X8_UNORM:
         /*case PIPE_FORMAT_R8G8B8X8_SNORM:*/
@@ -947,7 +914,7 @@ r300_texture_create_object(struct r300_screen *rscreen,
     if (!buffer) {
         tex->buf_size = tex->tex.size_in_bytes;
         tex->buf = rws->buffer_create(rws, tex->tex.size_in_bytes, 2048,
-                                         base->bind, base->usage, tex->domain);
+                                      base->bind, tex->domain);
 
         if (!tex->buf) {
             FREE(tex);
index 4586bb2..158a387 100644 (file)
@@ -35,10 +35,6 @@ struct r300_texture_desc;
 struct r300_resource;
 struct r300_screen;
 
-void util_format_combine_swizzles(unsigned char *dst,
-                                  const unsigned char *swz1,
-                                  const unsigned char *swz2);
-
 unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
                                    const unsigned char *swizzle_view,
                                    boolean dxtc_swizzle);
index da5778b..fe4f8dd 100644 (file)
@@ -360,9 +360,9 @@ static void r300_setup_hyperz_properties(struct r300_screen *screen,
         unsigned i, pipes;
 
         if (screen->caps.family == CHIP_FAMILY_RV530) {
-            pipes = screen->caps.num_z_pipes;
+            pipes = screen->info.r300_num_z_pipes;
         } else {
-            pipes = screen->caps.num_frag_pipes;
+            pipes = screen->info.r300_num_gb_pipes;
         }
 
         for (i = 0; i <= tex->b.b.b.last_level; i++) {
index 0561ab9..07a3f3c 100644 (file)
@@ -22,8 +22,7 @@
 
 #include "r300_tgsi_to_rc.h"
 
-#include "radeon_compiler.h"
-#include "radeon_program.h"
+#include "compiler/radeon_compiler.h"
 
 #include "tgsi/tgsi_info.h"
 #include "tgsi/tgsi_parse.h"
index b319890..a5e8fd6 100644 (file)
@@ -32,7 +32,7 @@
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_ureg.h"
 
-#include "radeon_compiler.h"
+#include "compiler/radeon_compiler.h"
 
 /* Convert info about VS output semantics into r300_shader_semantics. */
 static void r300_shader_read_vs_outputs(
index 170de6c..a482ddc 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "pipe/p_state.h"
 #include "tgsi/tgsi_scan.h"
-#include "radeon_code.h"
+#include "compiler/radeon_code.h"
 
 #include "r300_context.h"
 #include "r300_shader_semantics.h"
index 0135808..19f07b2 100644 (file)
@@ -2,11 +2,7 @@ Import('*')
 
 env = env.Clone()
 
-try:
-    env.ParseConfig('pkg-config --cflags libdrm_radeon')
-except OSError:
-    print 'warning: not building r600'
-    Return()
+env.PkgUseModules('DRM_RADEON')
 
 env.Append(CPPPATH = [
     '#/include',
index fb0b0f1..c95872b 100644 (file)
@@ -69,7 +69,7 @@ int eg_bc_cf_build(struct r600_bc *bc, struct r600_bc_cf *cf)
                        S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_W(cf->output.swizzle_w) |
                        S_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(cf->output.barrier) |
                        S_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(cf->output.inst);
-               if (bc->chiprev == CHIPREV_EVERGREEN) /* no EOP on cayman */
+               if (bc->chip_class == EVERGREEN) /* no EOP on cayman */
                        bc->bytecode[id] |= S_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(cf->output.end_of_program);
                id++;
 
diff --git a/src/gallium/drivers/r600/eg_state_inlines.h b/src/gallium/drivers/r600/eg_state_inlines.h
deleted file mode 100644 (file)
index f889178..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- * Copyright 2010 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE 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 EG_STATE_INLINES_H
-#define EG_STATE_INLINES_H
-
-#include "util/u_format.h"
-#include "evergreend.h"
-#include "r600_formats.h"
-
-static INLINE uint32_t r600_translate_blend_function(int blend_func)
-{
-       switch (blend_func) {
-       case PIPE_BLEND_ADD:
-               return V_028780_COMB_DST_PLUS_SRC;
-       case PIPE_BLEND_SUBTRACT:
-               return V_028780_COMB_SRC_MINUS_DST;
-       case PIPE_BLEND_REVERSE_SUBTRACT:
-               return V_028780_COMB_DST_MINUS_SRC;
-       case PIPE_BLEND_MIN:
-               return V_028780_COMB_MIN_DST_SRC;
-       case PIPE_BLEND_MAX:
-               return V_028780_COMB_MAX_DST_SRC;
-       default:
-               R600_ERR("Unknown blend function %d\n", blend_func);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_blend_factor(int blend_fact)
-{
-       switch (blend_fact) {
-       case PIPE_BLENDFACTOR_ONE:
-               return V_028780_BLEND_ONE;
-       case PIPE_BLENDFACTOR_SRC_COLOR:
-               return V_028780_BLEND_SRC_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA:
-               return V_028780_BLEND_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_DST_ALPHA:
-               return V_028780_BLEND_DST_ALPHA;
-       case PIPE_BLENDFACTOR_DST_COLOR:
-               return V_028780_BLEND_DST_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-               return V_028780_BLEND_SRC_ALPHA_SATURATE;
-       case PIPE_BLENDFACTOR_CONST_COLOR:
-               return V_028780_BLEND_CONST_COLOR;
-       case PIPE_BLENDFACTOR_CONST_ALPHA:
-               return V_028780_BLEND_CONST_ALPHA;
-       case PIPE_BLENDFACTOR_ZERO:
-               return V_028780_BLEND_ZERO;
-       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
-               return V_028780_BLEND_ONE_MINUS_SRC_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
-               return V_028780_BLEND_ONE_MINUS_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
-               return V_028780_BLEND_ONE_MINUS_DST_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_COLOR:
-               return V_028780_BLEND_ONE_MINUS_DST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
-               return V_028780_BLEND_ONE_MINUS_CONST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
-               return V_028780_BLEND_ONE_MINUS_CONST_ALPHA;
-       case PIPE_BLENDFACTOR_SRC1_COLOR:
-               return V_028780_BLEND_SRC1_COLOR;
-       case PIPE_BLENDFACTOR_SRC1_ALPHA:
-               return V_028780_BLEND_SRC1_ALPHA;
-       case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
-               return V_028780_BLEND_INV_SRC1_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
-               return V_028780_BLEND_INV_SRC1_ALPHA;
-       default:
-               R600_ERR("Bad blend factor %d not supported!\n", blend_fact);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_stencil_op(int s_op)
-{
-       switch (s_op) {
-       case PIPE_STENCIL_OP_KEEP:
-               return V_028800_STENCIL_KEEP;
-       case PIPE_STENCIL_OP_ZERO:
-               return V_028800_STENCIL_ZERO;
-       case PIPE_STENCIL_OP_REPLACE:
-               return V_028800_STENCIL_REPLACE;
-       case PIPE_STENCIL_OP_INCR:
-               return V_028800_STENCIL_INCR;
-       case PIPE_STENCIL_OP_DECR:
-               return V_028800_STENCIL_DECR;
-       case PIPE_STENCIL_OP_INCR_WRAP:
-               return V_028800_STENCIL_INCR_WRAP;
-       case PIPE_STENCIL_OP_DECR_WRAP:
-               return V_028800_STENCIL_DECR_WRAP;
-       case PIPE_STENCIL_OP_INVERT:
-               return V_028800_STENCIL_INVERT;
-       default:
-               R600_ERR("Unknown stencil op %d", s_op);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_fill(uint32_t func)
-{
-       switch(func) {
-       case PIPE_POLYGON_MODE_FILL:
-               return 2;
-       case PIPE_POLYGON_MODE_LINE:
-               return 1;
-       case PIPE_POLYGON_MODE_POINT:
-               return 0;
-       default:
-               assert(0);
-               return 0;
-       }
-}
-
-/* translates straight */
-static INLINE uint32_t r600_translate_ds_func(int func)
-{
-       return func;
-}
-
-static inline unsigned r600_tex_wrap(unsigned wrap)
-{
-       switch (wrap) {
-       default:
-       case PIPE_TEX_WRAP_REPEAT:
-               return V_03C000_SQ_TEX_WRAP;
-       case PIPE_TEX_WRAP_CLAMP:
-               return V_03C000_SQ_TEX_CLAMP_HALF_BORDER;
-       case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
-               return V_03C000_SQ_TEX_CLAMP_LAST_TEXEL;
-       case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
-               return V_03C000_SQ_TEX_CLAMP_BORDER;
-       case PIPE_TEX_WRAP_MIRROR_REPEAT:
-               return V_03C000_SQ_TEX_MIRROR;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_BORDER;
-       }
-}
-
-static inline unsigned r600_tex_filter(unsigned filter)
-{
-       switch (filter) {
-       default:
-       case PIPE_TEX_FILTER_NEAREST:
-               return V_03C000_SQ_TEX_XY_FILTER_POINT;
-       case PIPE_TEX_FILTER_LINEAR:
-               return V_03C000_SQ_TEX_XY_FILTER_BILINEAR;
-       }
-}
-
-static inline unsigned r600_tex_mipfilter(unsigned filter)
-{
-       switch (filter) {
-       case PIPE_TEX_MIPFILTER_NEAREST:
-               return V_03C000_SQ_TEX_Z_FILTER_POINT;
-       case PIPE_TEX_MIPFILTER_LINEAR:
-               return V_03C000_SQ_TEX_Z_FILTER_LINEAR;
-       default:
-       case PIPE_TEX_MIPFILTER_NONE:
-               return V_03C000_SQ_TEX_Z_FILTER_NONE;
-       }
-}
-
-static inline unsigned r600_tex_compare(unsigned compare)
-{
-       switch (compare) {
-       default:
-       case PIPE_FUNC_NEVER:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER;
-       case PIPE_FUNC_LESS:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESS;
-       case PIPE_FUNC_EQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_EQUAL;
-       case PIPE_FUNC_LEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
-       case PIPE_FUNC_GREATER:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATER;
-       case PIPE_FUNC_NOTEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
-       case PIPE_FUNC_GEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
-       case PIPE_FUNC_ALWAYS:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_ALWAYS;
-       }
-}
-
-static inline unsigned r600_tex_swizzle(unsigned swizzle)
-{
-       switch (swizzle) {
-       case PIPE_SWIZZLE_RED:
-               return V_030010_SQ_SEL_X;
-       case PIPE_SWIZZLE_GREEN:
-               return V_030010_SQ_SEL_Y;
-       case PIPE_SWIZZLE_BLUE:
-               return V_030010_SQ_SEL_Z;
-       case PIPE_SWIZZLE_ALPHA:
-               return V_030010_SQ_SEL_W;
-       case PIPE_SWIZZLE_ZERO:
-               return V_030010_SQ_SEL_0;
-       default:
-       case PIPE_SWIZZLE_ONE:
-               return V_030010_SQ_SEL_1;
-       }
-}
-
-static inline unsigned r600_format_type(unsigned format_type)
-{
-       switch (format_type) {
-       default:
-       case UTIL_FORMAT_TYPE_UNSIGNED:
-               return V_030010_SQ_FORMAT_COMP_UNSIGNED;
-       case UTIL_FORMAT_TYPE_SIGNED:
-               return V_030010_SQ_FORMAT_COMP_SIGNED;
-       case UTIL_FORMAT_TYPE_FIXED:
-               return V_030010_SQ_FORMAT_COMP_UNSIGNED_BIASED;
-       }
-}
-
-static inline unsigned r600_tex_dim(unsigned dim)
-{
-       switch (dim) {
-       default:
-       case PIPE_TEXTURE_1D:
-               return V_030000_SQ_TEX_DIM_1D;
-       case PIPE_TEXTURE_1D_ARRAY:
-               return V_030000_SQ_TEX_DIM_1D_ARRAY;
-       case PIPE_TEXTURE_2D:
-       case PIPE_TEXTURE_RECT:
-               return V_030000_SQ_TEX_DIM_2D;
-       case PIPE_TEXTURE_2D_ARRAY:
-               return V_030000_SQ_TEX_DIM_2D_ARRAY;
-       case PIPE_TEXTURE_3D:
-               return V_030000_SQ_TEX_DIM_3D;
-       case PIPE_TEXTURE_CUBE:
-               return V_030000_SQ_TEX_DIM_CUBEMAP;
-       }
-}
-
-static inline uint32_t r600_translate_dbformat(enum pipe_format format)
-{
-       switch (format) {
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_028040_Z_16;
-       case PIPE_FORMAT_Z24X8_UNORM:
-               return V_028040_Z_24;
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_028040_Z_24;
-       default:
-               return ~0;
-       }
-}
-
-static inline uint32_t r600_translate_stencilformat(enum pipe_format format)
-{
-       if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
-               return 1;
-       else
-               return 0;
-}
-
-static inline uint32_t r600_translate_colorswap(enum pipe_format format)
-{
-       switch (format) {
-       /* 8-bit buffers. */
-       case PIPE_FORMAT_L4A4_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_A8_UNORM:
-               return V_028C70_SWAP_ALT_REV;
-       case PIPE_FORMAT_I8_UNORM:
-       case PIPE_FORMAT_L8_UNORM:
-       case PIPE_FORMAT_L8_SRGB:
-       case PIPE_FORMAT_R8_UNORM:
-       case PIPE_FORMAT_R8_SNORM:
-               return V_028C70_SWAP_STD;
-
-       /* 16-bit buffers. */
-       case PIPE_FORMAT_B5G6R5_UNORM:
-               return V_028C70_SWAP_STD_REV;
-
-       case PIPE_FORMAT_B5G5R5A1_UNORM:
-       case PIPE_FORMAT_B5G5R5X1_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_B4G4R4A4_UNORM:
-       case PIPE_FORMAT_B4G4R4X4_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_L8A8_UNORM:
-       case PIPE_FORMAT_L8A8_SRGB:
-               return V_028C70_SWAP_ALT;
-       case PIPE_FORMAT_R8G8_UNORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_R16_UNORM:
-               return V_028C70_SWAP_STD;
-
-       /* 32-bit buffers. */
-       case PIPE_FORMAT_A8B8G8R8_SRGB:
-               return V_028C70_SWAP_STD_REV;
-       case PIPE_FORMAT_B8G8R8A8_SRGB:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_B8G8R8A8_UNORM:
-       case PIPE_FORMAT_B8G8R8X8_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-               return V_028C70_SWAP_ALT_REV;
-       case PIPE_FORMAT_R8G8B8A8_SNORM:
-       case PIPE_FORMAT_R8G8B8X8_UNORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_A8B8G8R8_UNORM:
-       case PIPE_FORMAT_X8B8G8R8_UNORM:
-       /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
-               return V_028C70_SWAP_STD_REV;
-
-       case PIPE_FORMAT_Z24X8_UNORM:
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_X8Z24_UNORM:
-       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_R10G10B10A2_UNORM:
-       case PIPE_FORMAT_R10G10B10X2_SNORM:
-       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-               return V_028C70_SWAP_STD;
-
-       case PIPE_FORMAT_B10G10R10A2_UNORM:
-               return V_028C70_SWAP_ALT;
-
-       case PIPE_FORMAT_R11G11B10_FLOAT:
-       case PIPE_FORMAT_R32_FLOAT:
-       case PIPE_FORMAT_R16G16_FLOAT:
-       case PIPE_FORMAT_R16G16_UNORM:
-               return V_028C70_SWAP_STD;
-
-       /* 64-bit buffers. */
-       case PIPE_FORMAT_R32G32_FLOAT:
-       case PIPE_FORMAT_R16G16B16A16_UNORM:
-       case PIPE_FORMAT_R16G16B16A16_SNORM:
-       case PIPE_FORMAT_R16G16B16A16_FLOAT:
-
-       /* 128-bit buffers. */
-       case PIPE_FORMAT_R32G32B32A32_FLOAT:
-       case PIPE_FORMAT_R32G32B32A32_SNORM:
-       case PIPE_FORMAT_R32G32B32A32_UNORM:
-               return V_028C70_SWAP_STD;
-       default:
-               R600_ERR("unsupported colorswap format %d\n", format);
-               return ~0;
-       }
-       return ~0;
-}
-
-static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
-{
-       switch (format) {
-       /* 8-bit buffers. */
-       case PIPE_FORMAT_L4A4_UNORM:
-               return V_028C70_COLOR_4_4;
-
-       case PIPE_FORMAT_A8_UNORM:
-       case PIPE_FORMAT_I8_UNORM:
-       case PIPE_FORMAT_L8_UNORM:
-       case PIPE_FORMAT_L8_SRGB:
-       case PIPE_FORMAT_R8_UNORM:
-       case PIPE_FORMAT_R8_SNORM:
-               return V_028C70_COLOR_8;
-
-       /* 16-bit buffers. */
-       case PIPE_FORMAT_B5G6R5_UNORM:
-               return V_028C70_COLOR_5_6_5;
-
-       case PIPE_FORMAT_B5G5R5A1_UNORM:
-       case PIPE_FORMAT_B5G5R5X1_UNORM:
-               return V_028C70_COLOR_1_5_5_5;
-
-       case PIPE_FORMAT_B4G4R4A4_UNORM:
-       case PIPE_FORMAT_B4G4R4X4_UNORM:
-               return V_028C70_COLOR_4_4_4_4;
-
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_028C70_COLOR_16;
-
-       case PIPE_FORMAT_L8A8_UNORM:
-       case PIPE_FORMAT_L8A8_SRGB:
-       case PIPE_FORMAT_R8G8_UNORM:
-               return V_028C70_COLOR_8_8;
-
-       case PIPE_FORMAT_R16_UNORM:
-               return V_028C70_COLOR_16;
-
-       /* 32-bit buffers. */
-       case PIPE_FORMAT_A8B8G8R8_SRGB:
-       case PIPE_FORMAT_A8B8G8R8_UNORM:
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-       case PIPE_FORMAT_B8G8R8A8_SRGB:
-       case PIPE_FORMAT_B8G8R8A8_UNORM:
-       case PIPE_FORMAT_B8G8R8X8_UNORM:
-       case PIPE_FORMAT_R8G8B8A8_SNORM:
-       case PIPE_FORMAT_R8G8B8A8_UNORM:
-       case PIPE_FORMAT_R8G8B8X8_UNORM:
-       case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
-       case PIPE_FORMAT_X8B8G8R8_UNORM:
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-       case PIPE_FORMAT_R8G8B8_UNORM:
-               return V_028C70_COLOR_8_8_8_8;
-
-       case PIPE_FORMAT_R10G10B10A2_UNORM:
-       case PIPE_FORMAT_R10G10B10X2_SNORM:
-       case PIPE_FORMAT_B10G10R10A2_UNORM:
-       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-               return V_028C70_COLOR_2_10_10_10;
-
-       case PIPE_FORMAT_Z24X8_UNORM:
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_028C70_COLOR_8_24;
-
-       case PIPE_FORMAT_X8Z24_UNORM:
-       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-               return V_028C70_COLOR_24_8;
-
-       case PIPE_FORMAT_R32_FLOAT:
-               return V_028C70_COLOR_32_FLOAT;
-
-       case PIPE_FORMAT_R16G16_FLOAT:
-               return V_028C70_COLOR_16_16_FLOAT;
-
-       case PIPE_FORMAT_R16G16_SSCALED:
-       case PIPE_FORMAT_R16G16_UNORM:
-               return V_028C70_COLOR_16_16;
-
-       case PIPE_FORMAT_R11G11B10_FLOAT:
-               return V_028C70_COLOR_10_11_11_FLOAT;
-
-       /* 64-bit buffers. */
-       case PIPE_FORMAT_R16G16B16_USCALED:
-       case PIPE_FORMAT_R16G16B16A16_USCALED:
-       case PIPE_FORMAT_R16G16B16_SSCALED:
-       case PIPE_FORMAT_R16G16B16A16_SSCALED:
-       case PIPE_FORMAT_R16G16B16A16_UNORM:
-       case PIPE_FORMAT_R16G16B16A16_SNORM:
-               return V_028C70_COLOR_16_16_16_16;
-
-       case PIPE_FORMAT_R16G16B16_FLOAT:
-       case PIPE_FORMAT_R16G16B16A16_FLOAT:
-               return V_028C70_COLOR_16_16_16_16_FLOAT;
-
-       case PIPE_FORMAT_R32G32_FLOAT:
-               return V_028C70_COLOR_32_32_FLOAT;
-
-       case PIPE_FORMAT_R32G32_USCALED:
-       case PIPE_FORMAT_R32G32_SSCALED:
-               return V_028C70_COLOR_32_32;
-
-       /* 96-bit buffers. */
-       case PIPE_FORMAT_R32G32B32_FLOAT:
-               return V_028C70_COLOR_32_32_32_FLOAT;
-
-       /* 128-bit buffers. */
-       case PIPE_FORMAT_R32G32B32A32_SNORM:
-       case PIPE_FORMAT_R32G32B32A32_UNORM:
-               return V_028C70_COLOR_32_32_32_32;
-       case PIPE_FORMAT_R32G32B32A32_FLOAT:
-               return V_028C70_COLOR_32_32_32_32_FLOAT;
-
-       /* YUV buffers. */
-       case PIPE_FORMAT_UYVY:
-       case PIPE_FORMAT_YUYV:
-       default:
-               return ~0; /* Unsupported. */
-       }
-}
-
-static INLINE uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
-{
-       if (R600_BIG_ENDIAN) {
-               switch(colorformat) {
-               case V_028C70_COLOR_4_4:
-                       return(ENDIAN_NONE);
-
-               /* 8-bit buffers. */
-               case V_028C70_COLOR_8:
-                       return(ENDIAN_NONE);
-
-               /* 16-bit buffers. */
-               case V_028C70_COLOR_5_6_5:
-               case V_028C70_COLOR_1_5_5_5:
-               case V_028C70_COLOR_4_4_4_4:
-               case V_028C70_COLOR_16:
-               case V_028C70_COLOR_8_8:
-                       return(ENDIAN_8IN16);
-
-               /* 32-bit buffers. */
-               case V_028C70_COLOR_8_8_8_8:
-               case V_028C70_COLOR_2_10_10_10:
-               case V_028C70_COLOR_8_24:
-               case V_028C70_COLOR_24_8:
-               case V_028C70_COLOR_32_FLOAT:
-               case V_028C70_COLOR_16_16_FLOAT:
-               case V_028C70_COLOR_16_16:
-                       return(ENDIAN_8IN32);
-
-               /* 64-bit buffers. */
-               case V_028C70_COLOR_16_16_16_16:
-               case V_028C70_COLOR_16_16_16_16_FLOAT:
-                       return(ENDIAN_8IN16);
-
-               case V_028C70_COLOR_32_32_FLOAT:
-               case V_028C70_COLOR_32_32:
-                       return(ENDIAN_8IN32);
-
-               /* 96-bit buffers. */
-               case V_028C70_COLOR_32_32_32_FLOAT:
-               /* 128-bit buffers. */
-               case V_028C70_COLOR_32_32_32_32_FLOAT:
-               case V_028C70_COLOR_32_32_32_32:
-                       return(ENDIAN_8IN32);
-               default:
-                       return ENDIAN_NONE; /* Unsupported. */
-               }
-       } else {
-               return ENDIAN_NONE;
-       }
-}
-
-static INLINE boolean r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
-{
-       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0;
-}
-
-static INLINE boolean r600_is_colorbuffer_format_supported(enum pipe_format format)
-{
-       return r600_translate_colorformat(format) != ~0 &&
-               r600_translate_colorswap(format) != ~0;
-}
-
-static INLINE boolean r600_is_zs_format_supported(enum pipe_format format)
-{
-       return r600_translate_dbformat(format) != ~0;
-}
-
-#endif
index f86e4d4..c9eaf94 100644 (file)
 #include "r600_resource.h"
 #include "r600_shader.h"
 #include "r600_pipe.h"
-#include "eg_state_inlines.h"
+#include "r600_formats.h"
+
+static uint32_t r600_translate_blend_function(int blend_func)
+{
+       switch (blend_func) {
+       case PIPE_BLEND_ADD:
+               return V_028780_COMB_DST_PLUS_SRC;
+       case PIPE_BLEND_SUBTRACT:
+               return V_028780_COMB_SRC_MINUS_DST;
+       case PIPE_BLEND_REVERSE_SUBTRACT:
+               return V_028780_COMB_DST_MINUS_SRC;
+       case PIPE_BLEND_MIN:
+               return V_028780_COMB_MIN_DST_SRC;
+       case PIPE_BLEND_MAX:
+               return V_028780_COMB_MAX_DST_SRC;
+       default:
+               R600_ERR("Unknown blend function %d\n", blend_func);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_blend_factor(int blend_fact)
+{
+       switch (blend_fact) {
+       case PIPE_BLENDFACTOR_ONE:
+               return V_028780_BLEND_ONE;
+       case PIPE_BLENDFACTOR_SRC_COLOR:
+               return V_028780_BLEND_SRC_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA:
+               return V_028780_BLEND_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_DST_ALPHA:
+               return V_028780_BLEND_DST_ALPHA;
+       case PIPE_BLENDFACTOR_DST_COLOR:
+               return V_028780_BLEND_DST_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
+               return V_028780_BLEND_SRC_ALPHA_SATURATE;
+       case PIPE_BLENDFACTOR_CONST_COLOR:
+               return V_028780_BLEND_CONST_COLOR;
+       case PIPE_BLENDFACTOR_CONST_ALPHA:
+               return V_028780_BLEND_CONST_ALPHA;
+       case PIPE_BLENDFACTOR_ZERO:
+               return V_028780_BLEND_ZERO;
+       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+               return V_028780_BLEND_ONE_MINUS_SRC_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
+               return V_028780_BLEND_ONE_MINUS_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+               return V_028780_BLEND_ONE_MINUS_DST_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_COLOR:
+               return V_028780_BLEND_ONE_MINUS_DST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+               return V_028780_BLEND_ONE_MINUS_CONST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+               return V_028780_BLEND_ONE_MINUS_CONST_ALPHA;
+       case PIPE_BLENDFACTOR_SRC1_COLOR:
+               return V_028780_BLEND_SRC1_COLOR;
+       case PIPE_BLENDFACTOR_SRC1_ALPHA:
+               return V_028780_BLEND_SRC1_ALPHA;
+       case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+               return V_028780_BLEND_INV_SRC1_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
+               return V_028780_BLEND_INV_SRC1_ALPHA;
+       default:
+               R600_ERR("Bad blend factor %d not supported!\n", blend_fact);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_stencil_op(int s_op)
+{
+       switch (s_op) {
+       case PIPE_STENCIL_OP_KEEP:
+               return V_028800_STENCIL_KEEP;
+       case PIPE_STENCIL_OP_ZERO:
+               return V_028800_STENCIL_ZERO;
+       case PIPE_STENCIL_OP_REPLACE:
+               return V_028800_STENCIL_REPLACE;
+       case PIPE_STENCIL_OP_INCR:
+               return V_028800_STENCIL_INCR;
+       case PIPE_STENCIL_OP_DECR:
+               return V_028800_STENCIL_DECR;
+       case PIPE_STENCIL_OP_INCR_WRAP:
+               return V_028800_STENCIL_INCR_WRAP;
+       case PIPE_STENCIL_OP_DECR_WRAP:
+               return V_028800_STENCIL_DECR_WRAP;
+       case PIPE_STENCIL_OP_INVERT:
+               return V_028800_STENCIL_INVERT;
+       default:
+               R600_ERR("Unknown stencil op %d", s_op);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_fill(uint32_t func)
+{
+       switch(func) {
+       case PIPE_POLYGON_MODE_FILL:
+               return 2;
+       case PIPE_POLYGON_MODE_LINE:
+               return 1;
+       case PIPE_POLYGON_MODE_POINT:
+               return 0;
+       default:
+               assert(0);
+               return 0;
+       }
+}
+
+/* translates straight */
+static uint32_t r600_translate_ds_func(int func)
+{
+       return func;
+}
+
+static unsigned r600_tex_wrap(unsigned wrap)
+{
+       switch (wrap) {
+       default:
+       case PIPE_TEX_WRAP_REPEAT:
+               return V_03C000_SQ_TEX_WRAP;
+       case PIPE_TEX_WRAP_CLAMP:
+               return V_03C000_SQ_TEX_CLAMP_HALF_BORDER;
+       case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
+               return V_03C000_SQ_TEX_CLAMP_LAST_TEXEL;
+       case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
+               return V_03C000_SQ_TEX_CLAMP_BORDER;
+       case PIPE_TEX_WRAP_MIRROR_REPEAT:
+               return V_03C000_SQ_TEX_MIRROR;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_BORDER;
+       }
+}
+
+static unsigned r600_tex_filter(unsigned filter)
+{
+       switch (filter) {
+       default:
+       case PIPE_TEX_FILTER_NEAREST:
+               return V_03C000_SQ_TEX_XY_FILTER_POINT;
+       case PIPE_TEX_FILTER_LINEAR:
+               return V_03C000_SQ_TEX_XY_FILTER_BILINEAR;
+       }
+}
+
+static unsigned r600_tex_mipfilter(unsigned filter)
+{
+       switch (filter) {
+       case PIPE_TEX_MIPFILTER_NEAREST:
+               return V_03C000_SQ_TEX_Z_FILTER_POINT;
+       case PIPE_TEX_MIPFILTER_LINEAR:
+               return V_03C000_SQ_TEX_Z_FILTER_LINEAR;
+       default:
+       case PIPE_TEX_MIPFILTER_NONE:
+               return V_03C000_SQ_TEX_Z_FILTER_NONE;
+       }
+}
+
+static unsigned r600_tex_compare(unsigned compare)
+{
+       switch (compare) {
+       default:
+       case PIPE_FUNC_NEVER:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER;
+       case PIPE_FUNC_LESS:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESS;
+       case PIPE_FUNC_EQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_EQUAL;
+       case PIPE_FUNC_LEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
+       case PIPE_FUNC_GREATER:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATER;
+       case PIPE_FUNC_NOTEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
+       case PIPE_FUNC_GEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
+       case PIPE_FUNC_ALWAYS:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_ALWAYS;
+       }
+}
+
+static unsigned r600_tex_dim(unsigned dim)
+{
+       switch (dim) {
+       default:
+       case PIPE_TEXTURE_1D:
+               return V_030000_SQ_TEX_DIM_1D;
+       case PIPE_TEXTURE_1D_ARRAY:
+               return V_030000_SQ_TEX_DIM_1D_ARRAY;
+       case PIPE_TEXTURE_2D:
+       case PIPE_TEXTURE_RECT:
+               return V_030000_SQ_TEX_DIM_2D;
+       case PIPE_TEXTURE_2D_ARRAY:
+               return V_030000_SQ_TEX_DIM_2D_ARRAY;
+       case PIPE_TEXTURE_3D:
+               return V_030000_SQ_TEX_DIM_3D;
+       case PIPE_TEXTURE_CUBE:
+               return V_030000_SQ_TEX_DIM_CUBEMAP;
+       }
+}
+
+static uint32_t r600_translate_dbformat(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028040_Z_16;
+       case PIPE_FORMAT_Z24X8_UNORM:
+               return V_028040_Z_24;
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028040_Z_24;
+       default:
+               return ~0U;
+       }
+}
+
+static uint32_t r600_translate_stencilformat(enum pipe_format format)
+{
+       if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
+               return 1;
+       else
+               return 0;
+}
+
+static uint32_t r600_translate_colorswap(enum pipe_format format)
+{
+       switch (format) {
+       /* 8-bit buffers. */
+       case PIPE_FORMAT_L4A4_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_A8_UNORM:
+               return V_028C70_SWAP_ALT_REV;
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_SRGB:
+       case PIPE_FORMAT_R8_UNORM:
+       case PIPE_FORMAT_R8_SNORM:
+               return V_028C70_SWAP_STD;
+
+       /* 16-bit buffers. */
+       case PIPE_FORMAT_B5G6R5_UNORM:
+               return V_028C70_SWAP_STD_REV;
+
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+       case PIPE_FORMAT_B5G5R5X1_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+       case PIPE_FORMAT_B4G4R4X4_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_SRGB:
+               return V_028C70_SWAP_ALT;
+       case PIPE_FORMAT_R8G8_UNORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_R16_UNORM:
+       case PIPE_FORMAT_R16_FLOAT:
+               return V_028C70_SWAP_STD;
+
+       /* 32-bit buffers. */
+       case PIPE_FORMAT_A8B8G8R8_SRGB:
+               return V_028C70_SWAP_STD_REV;
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_B8G8R8A8_UNORM:
+       case PIPE_FORMAT_B8G8R8X8_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               return V_028C70_SWAP_ALT_REV;
+       case PIPE_FORMAT_R8G8B8A8_SNORM:
+       case PIPE_FORMAT_R8G8B8A8_UNORM:
+       case PIPE_FORMAT_R8G8B8X8_UNORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_A8B8G8R8_UNORM:
+       case PIPE_FORMAT_X8B8G8R8_UNORM:
+       /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
+               return V_028C70_SWAP_STD_REV;
+
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_X8Z24_UNORM:
+       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_R10G10B10A2_UNORM:
+       case PIPE_FORMAT_R10G10B10X2_SNORM:
+       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
+               return V_028C70_SWAP_STD;
+
+       case PIPE_FORMAT_B10G10R10A2_UNORM:
+               return V_028C70_SWAP_ALT;
+
+       case PIPE_FORMAT_R11G11B10_FLOAT:
+       case PIPE_FORMAT_R32_FLOAT:
+       case PIPE_FORMAT_R16G16_FLOAT:
+       case PIPE_FORMAT_R16G16_UNORM:
+               return V_028C70_SWAP_STD;
+
+       /* 64-bit buffers. */
+       case PIPE_FORMAT_R32G32_FLOAT:
+       case PIPE_FORMAT_R16G16B16A16_UNORM:
+       case PIPE_FORMAT_R16G16B16A16_SNORM:
+       case PIPE_FORMAT_R16G16B16A16_FLOAT:
+
+       /* 128-bit buffers. */
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+       case PIPE_FORMAT_R32G32B32A32_SNORM:
+       case PIPE_FORMAT_R32G32B32A32_UNORM:
+               return V_028C70_SWAP_STD;
+       default:
+               R600_ERR("unsupported colorswap format %d\n", format);
+               return ~0U;
+       }
+       return ~0U;
+}
+
+static uint32_t r600_translate_colorformat(enum pipe_format format)
+{
+       switch (format) {
+       /* 8-bit buffers. */
+       case PIPE_FORMAT_L4A4_UNORM:
+               return V_028C70_COLOR_4_4;
+
+       case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_SRGB:
+       case PIPE_FORMAT_R8_UNORM:
+       case PIPE_FORMAT_R8_SNORM:
+               return V_028C70_COLOR_8;
+
+       /* 16-bit buffers. */
+       case PIPE_FORMAT_B5G6R5_UNORM:
+               return V_028C70_COLOR_5_6_5;
+
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+       case PIPE_FORMAT_B5G5R5X1_UNORM:
+               return V_028C70_COLOR_1_5_5_5;
+
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+       case PIPE_FORMAT_B4G4R4X4_UNORM:
+               return V_028C70_COLOR_4_4_4_4;
+
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028C70_COLOR_16;
+
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_SRGB:
+       case PIPE_FORMAT_R8G8_UNORM:
+               return V_028C70_COLOR_8_8;
+
+       case PIPE_FORMAT_R16_UNORM:
+               return V_028C70_COLOR_16;
+
+       case PIPE_FORMAT_R16_FLOAT:
+               return V_028C70_COLOR_16_FLOAT;
+
+       /* 32-bit buffers. */
+       case PIPE_FORMAT_A8B8G8R8_SRGB:
+       case PIPE_FORMAT_A8B8G8R8_UNORM:
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+       case PIPE_FORMAT_B8G8R8A8_UNORM:
+       case PIPE_FORMAT_B8G8R8X8_UNORM:
+       case PIPE_FORMAT_R8G8B8A8_SNORM:
+       case PIPE_FORMAT_R8G8B8A8_UNORM:
+       case PIPE_FORMAT_R8G8B8X8_UNORM:
+       case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
+       case PIPE_FORMAT_X8B8G8R8_UNORM:
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+       case PIPE_FORMAT_R8G8B8_UNORM:
+               return V_028C70_COLOR_8_8_8_8;
+
+       case PIPE_FORMAT_R10G10B10A2_UNORM:
+       case PIPE_FORMAT_R10G10B10X2_SNORM:
+       case PIPE_FORMAT_B10G10R10A2_UNORM:
+       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
+               return V_028C70_COLOR_2_10_10_10;
+
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028C70_COLOR_8_24;
+
+       case PIPE_FORMAT_X8Z24_UNORM:
+       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               return V_028C70_COLOR_24_8;
+
+       case PIPE_FORMAT_R32_FLOAT:
+               return V_028C70_COLOR_32_FLOAT;
+
+       case PIPE_FORMAT_R16G16_FLOAT:
+               return V_028C70_COLOR_16_16_FLOAT;
+
+       case PIPE_FORMAT_R16G16_SSCALED:
+       case PIPE_FORMAT_R16G16_UNORM:
+               return V_028C70_COLOR_16_16;
+
+       case PIPE_FORMAT_R11G11B10_FLOAT:
+               return V_028C70_COLOR_10_11_11_FLOAT;
+
+       /* 64-bit buffers. */
+       case PIPE_FORMAT_R16G16B16_USCALED:
+       case PIPE_FORMAT_R16G16B16A16_USCALED:
+       case PIPE_FORMAT_R16G16B16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_UNORM:
+       case PIPE_FORMAT_R16G16B16A16_SNORM:
+               return V_028C70_COLOR_16_16_16_16;
+
+       case PIPE_FORMAT_R16G16B16_FLOAT:
+       case PIPE_FORMAT_R16G16B16A16_FLOAT:
+               return V_028C70_COLOR_16_16_16_16_FLOAT;
+
+       case PIPE_FORMAT_R32G32_FLOAT:
+               return V_028C70_COLOR_32_32_FLOAT;
+
+       case PIPE_FORMAT_R32G32_USCALED:
+       case PIPE_FORMAT_R32G32_SSCALED:
+               return V_028C70_COLOR_32_32;
+
+       /* 96-bit buffers. */
+       case PIPE_FORMAT_R32G32B32_FLOAT:
+               return V_028C70_COLOR_32_32_32_FLOAT;
+
+       /* 128-bit buffers. */
+       case PIPE_FORMAT_R32G32B32A32_SNORM:
+       case PIPE_FORMAT_R32G32B32A32_UNORM:
+               return V_028C70_COLOR_32_32_32_32;
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+               return V_028C70_COLOR_32_32_32_32_FLOAT;
+
+       /* YUV buffers. */
+       case PIPE_FORMAT_UYVY:
+       case PIPE_FORMAT_YUYV:
+       default:
+               return ~0U; /* Unsupported. */
+       }
+}
+
+static uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
+{
+       if (R600_BIG_ENDIAN) {
+               switch(colorformat) {
+               case V_028C70_COLOR_4_4:
+                       return ENDIAN_NONE;
+
+               /* 8-bit buffers. */
+               case V_028C70_COLOR_8:
+                       return ENDIAN_NONE;
+
+               /* 16-bit buffers. */
+               case V_028C70_COLOR_5_6_5:
+               case V_028C70_COLOR_1_5_5_5:
+               case V_028C70_COLOR_4_4_4_4:
+               case V_028C70_COLOR_16:
+               case V_028C70_COLOR_8_8:
+                       return ENDIAN_8IN16;
+
+               /* 32-bit buffers. */
+               case V_028C70_COLOR_8_8_8_8:
+               case V_028C70_COLOR_2_10_10_10:
+               case V_028C70_COLOR_8_24:
+               case V_028C70_COLOR_24_8:
+               case V_028C70_COLOR_32_FLOAT:
+               case V_028C70_COLOR_16_16_FLOAT:
+               case V_028C70_COLOR_16_16:
+                       return ENDIAN_8IN32;
+
+               /* 64-bit buffers. */
+               case V_028C70_COLOR_16_16_16_16:
+               case V_028C70_COLOR_16_16_16_16_FLOAT:
+                       return ENDIAN_8IN16;
+
+               case V_028C70_COLOR_32_32_FLOAT:
+               case V_028C70_COLOR_32_32:
+                       return ENDIAN_8IN32;
+
+               /* 96-bit buffers. */
+               case V_028C70_COLOR_32_32_32_FLOAT:
+               /* 128-bit buffers. */
+               case V_028C70_COLOR_32_32_32_32_FLOAT:
+               case V_028C70_COLOR_32_32_32_32:
+                       return ENDIAN_8IN32;
+               default:
+                       return ENDIAN_NONE; /* Unsupported. */
+               }
+       } else {
+               return ENDIAN_NONE;
+       }
+}
+
+static bool r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
+{
+       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0U;
+}
+
+static bool r600_is_colorbuffer_format_supported(enum pipe_format format)
+{
+       return r600_translate_colorformat(format) != ~0U &&
+               r600_translate_colorswap(format) != ~0U;
+}
+
+static bool r600_is_zs_format_supported(enum pipe_format format)
+{
+       return r600_translate_dbformat(format) != ~0U;
+}
+
+boolean evergreen_is_format_supported(struct pipe_screen *screen,
+                                     enum pipe_format format,
+                                     enum pipe_texture_target target,
+                                     unsigned sample_count,
+                                     unsigned usage)
+{
+       unsigned retval = 0;
+
+       if (target >= PIPE_MAX_TEXTURE_TYPES) {
+               R600_ERR("r600: unsupported texture type %d\n", target);
+               return FALSE;
+       }
+
+       if (!util_format_is_supported(format, usage))
+               return FALSE;
+
+       /* Multisample */
+       if (sample_count > 1)
+               return FALSE;
+
+       if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
+           r600_is_sampler_format_supported(screen, format)) {
+               retval |= PIPE_BIND_SAMPLER_VIEW;
+       }
+
+       if ((usage & (PIPE_BIND_RENDER_TARGET |
+                     PIPE_BIND_DISPLAY_TARGET |
+                     PIPE_BIND_SCANOUT |
+                     PIPE_BIND_SHARED)) &&
+           r600_is_colorbuffer_format_supported(format)) {
+               retval |= usage &
+                         (PIPE_BIND_RENDER_TARGET |
+                          PIPE_BIND_DISPLAY_TARGET |
+                          PIPE_BIND_SCANOUT |
+                          PIPE_BIND_SHARED);
+       }
+
+       if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
+           r600_is_zs_format_supported(format)) {
+               retval |= PIPE_BIND_DEPTH_STENCIL;
+       }
+
+       if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
+           r600_is_vertex_format_supported(format)) {
+               retval |= PIPE_BIND_VERTEX_BUFFER;
+       }
+
+       if (usage & PIPE_BIND_TRANSFER_READ)
+               retval |= PIPE_BIND_TRANSFER_READ;
+       if (usage & PIPE_BIND_TRANSFER_WRITE)
+               retval |= PIPE_BIND_TRANSFER_WRITE;
+
+       return retval == usage;
+}
 
 static void evergreen_set_blend_color(struct pipe_context *ctx,
                                        const struct pipe_blend_color *state)
@@ -77,13 +657,11 @@ static void *evergreen_create_blend_state(struct pipe_context *ctx,
        u32 color_control, target_mask;
        /* FIXME there is more then 8 framebuffer */
        unsigned blend_cntl[8];
-       enum radeon_family family;
 
        if (blend == NULL) {
                return NULL;
        }
 
-       family = r600_get_family(rctx->radeon);
        rstate = &blend->rstate;
 
        rstate->id = R600_PIPE_STATE_BLEND;
@@ -110,7 +688,7 @@ static void *evergreen_create_blend_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_028808_CB_COLOR_CONTROL,
                                color_control, 0xFFFFFFFD, NULL);
 
-       if (family != CHIP_CAYMAN)
+       if (rctx->chip_class != CAYMAN)
                r600_pipe_state_add_reg(rstate, R_028C3C_PA_SC_AA_MASK, 0xFFFFFFFF, 0xFFFFFFFF, NULL);
        else {
                r600_pipe_state_add_reg(rstate, CM_R_028C38_PA_SC_AA_MASK_X0Y0_X1Y0, 0xFFFFFFFF, 0xFFFFFFFF, NULL);
@@ -247,15 +825,14 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
        unsigned tmp;
        unsigned prov_vtx = 1, polygon_dual_mode;
        unsigned clip_rule;
-       enum radeon_family family;
-
-       family = r600_get_family(rctx->radeon);
 
        if (rs == NULL) {
                return NULL;
        }
 
        rstate = &rs->rstate;
+       rs->clamp_vertex_color = state->clamp_vertex_color;
+       rs->clamp_fragment_color = state->clamp_fragment_color;
        rs->flatshade = state->flatshade;
        rs->sprite_coord_enable = state->sprite_coord_enable;
 
@@ -306,7 +883,7 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
        tmp = (unsigned)state->line_width * 8;
        r600_pipe_state_add_reg(rstate, R_028A08_PA_SU_LINE_CNTL, S_028A08_WIDTH(tmp), 0xFFFFFFFF, NULL);
 
-       if (family == CHIP_CAYMAN) {
+       if (rctx->chip_class == CAYMAN) {
                r600_pipe_state_add_reg(rstate, CM_R_028BDC_PA_SC_LINE_CNTL, 0x00000400, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, CM_R_028BE4_PA_SU_VTX_CNTL,
                                        S_028C08_PIX_CENTER_HALF(state->gl_rasterization_rules),
@@ -446,8 +1023,8 @@ static struct pipe_sampler_view *evergreen_create_sampler_view(struct pipe_conte
        rstate->val[1] = (S_030004_TEX_HEIGHT(texture->height0 - 1) |
                          S_030004_TEX_DEPTH(texture->depth0 - 1) |
                          S_030004_ARRAY_MODE(array_mode));
-       rstate->val[2] = (tmp->offset[0] + r600_bo_offset(bo[0])) >> 8;
-       rstate->val[3] = (tmp->offset[1] + r600_bo_offset(bo[1])) >> 8;
+       rstate->val[2] = tmp->offset[0] >> 8;
+       rstate->val[3] = tmp->offset[1] >> 8;
        rstate->val[4] = (word4 |
                          S_030010_SRF_MODE_ALL(V_030010_SRF_MODE_ZERO_CLAMP_MINUS_ONE) |
                          S_030010_ENDIAN_SWAP(endian) |
@@ -777,7 +1354,7 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state
        /* FIXME handle enabling of CB beyond BASE8 which has different offset */
        r600_pipe_state_add_reg(rstate,
                                R_028C60_CB_COLOR0_BASE + cb * 0x3C,
-                               (offset +  r600_bo_offset(bo[0])) >> 8, 0xFFFFFFFF, bo[0]);
+                               offset >> 8, 0xFFFFFFFF, bo[0]);
        r600_pipe_state_add_reg(rstate,
                                R_028C78_CB_COLOR0_DIM + cb * 0x3C,
                                0x0, 0xFFFFFFFF, NULL);
@@ -830,18 +1407,18 @@ static void evergreen_db(struct r600_pipe_context *rctx, struct r600_pipe_state
        stencil_format = r600_translate_stencilformat(state->zsbuf->texture->format);
 
        r600_pipe_state_add_reg(rstate, R_028048_DB_Z_READ_BASE,
-                               (offset + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
+                               offset >> 8, 0xFFFFFFFF, rbuffer->bo);
        r600_pipe_state_add_reg(rstate, R_028050_DB_Z_WRITE_BASE,
-                               (offset  + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
+                               offset >> 8, 0xFFFFFFFF, rbuffer->bo);
 
        if (stencil_format) {
                uint32_t stencil_offset;
 
                stencil_offset = ((surf->aligned_height * rtex->pitch_in_bytes[level]) + 255) & ~255;
                r600_pipe_state_add_reg(rstate, R_02804C_DB_STENCIL_READ_BASE,
-                                       (offset + stencil_offset + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
+                                       (offset + stencil_offset) >> 8, 0xFFFFFFFF, rbuffer->bo);
                r600_pipe_state_add_reg(rstate, R_028054_DB_STENCIL_WRITE_BASE,
-                                       (offset + stencil_offset + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
+                                       (offset + stencil_offset) >> 8, 0xFFFFFFFF, rbuffer->bo);
        }
 
        r600_pipe_state_add_reg(rstate, R_028008_DB_DEPTH_VIEW, 0x00000000, 0xFFFFFFFF, NULL);
@@ -865,14 +1442,11 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
        u32 shader_mask, tl, br, target_mask;
-       enum radeon_family family;
        int tl_x, tl_y, br_x, br_y;
 
        if (rstate == NULL)
                return;
 
-       family = r600_get_family(rctx->radeon);
-
        evergreen_context_flush_dest_caches(&rctx->ctx);
        rctx->ctx.num_dest_buffers = state->nr_cbufs;
 
@@ -883,6 +1457,7 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
 
        /* build states */
        rctx->have_depth_fb = 0;
+       rctx->nr_cbufs = state->nr_cbufs;
        for (int i = 0; i < state->nr_cbufs; i++) {
                evergreen_cb(rctx, rstate, state, i);
        }
@@ -908,7 +1483,7 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
        if (br_y == 0)
                tl_y = 1;
        /* cayman hw workaround */
-       if (family == CHIP_CAYMAN) {
+       if (rctx->chip_class == CAYMAN) {
                if (br_x == 1 && br_y == 1)
                        br_x = 2;
        }
@@ -952,7 +1527,7 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
                                shader_mask, 0xFFFFFFFF, NULL);
 
 
-       if (family == CHIP_CAYMAN) {
+       if (rctx->chip_class == CAYMAN) {
                r600_pipe_state_add_reg(rstate, CM_R_028BE0_PA_SC_AA_CONFIG,
                                        0x00000000, 0xFFFFFFFF, NULL);
        } else {
@@ -1139,9 +1714,9 @@ void evergreen_init_config(struct r600_pipe_context *rctx)
        enum radeon_family family;
        unsigned tmp;
 
-       family = r600_get_family(rctx->radeon);
+       family = rctx->family;
 
-       if (family == CHIP_CAYMAN) {
+       if (rctx->chip_class == CAYMAN) {
                cayman_init_config(rctx);
                return;
        }
@@ -1451,6 +2026,11 @@ void evergreen_init_config(struct r600_pipe_context *rctx)
        tmp |= S_008C28_NUM_LS_STACK_ENTRIES(num_ls_stack_entries);
        r600_pipe_state_add_reg(rstate, R_008C28_SQ_STACK_RESOURCE_MGMT_3, tmp, 0xFFFFFFFF, NULL);
 
+       tmp = 0;
+       tmp |= S_008E2C_NUM_PS_LDS(0x1000);
+       tmp |= S_008E2C_NUM_LS_LDS(0x1000);
+       r600_pipe_state_add_reg(rstate, R_008E2C_SQ_LDS_RESOURCE_MGMT, tmp, 0xFFFFFFFF, NULL);
+
        r600_pipe_state_add_reg(rstate, R_009100_SPI_CONFIG_CNTL, 0x0, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_00913C_SPI_CONFIG_CNTL_1, S_00913C_VTX_DONE_DELAY(4), 0xFFFFFFFF, NULL);
 
@@ -1629,7 +2209,10 @@ void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader
                    rshader->output[i].name == TGSI_SEMANTIC_STENCIL)
                        exports_ps |= 1;
                else if (rshader->output[i].name == TGSI_SEMANTIC_COLOR) {
-                       num_cout++;
+                       if (rshader->fs_write_all)
+                               num_cout = rshader->nr_cbufs;
+                       else
+                               num_cout++;
                }
        }
        exports_ps |= S_02884C_EXPORT_COLORS(num_cout);
@@ -1682,7 +2265,7 @@ void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader
 
        r600_pipe_state_add_reg(rstate,
                                R_028840_SQ_PGM_START_PS,
-                               (r600_bo_offset(shader->bo)) >> 8, 0xFFFFFFFF, shader->bo);
+                               0, 0xFFFFFFFF, shader->bo);
        r600_pipe_state_add_reg(rstate,
                                R_028844_SQ_PGM_RESOURCES_PS,
                                S_028844_NUM_GPRS(rshader->bc.ngpr) |
@@ -1715,7 +2298,7 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader
        struct r600_pipe_state *rstate = &shader->rstate;
        struct r600_shader *rshader = &shader->shader;
        unsigned spi_vs_out_id[10];
-       unsigned i, tmp;
+       unsigned i, tmp, nparams;
 
        /* clear previous register */
        rstate->nregs = 0;
@@ -1734,9 +2317,17 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader
                                        spi_vs_out_id[i], 0xFFFFFFFF, NULL);
        }
 
+       /* Certain attributes (position, psize, etc.) don't count as params.
+        * VS is required to export at least one param and r600_shader_from_tgsi()
+        * takes care of adding a dummy export.
+        */
+       nparams = rshader->noutput - rshader->npos;
+       if (nparams < 1)
+               nparams = 1;
+
        r600_pipe_state_add_reg(rstate,
                        R_0286C4_SPI_VS_OUT_CONFIG,
-                       S_0286C4_VS_EXPORT_COUNT(rshader->noutput - 2),
+                       S_0286C4_VS_EXPORT_COUNT(nparams - 1),
                        0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                        R_028860_SQ_PGM_RESOURCES_VS,
@@ -1748,7 +2339,7 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader
                                0x0, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                        R_02885C_SQ_PGM_START_VS,
-                       (r600_bo_offset(shader->bo)) >> 8, 0xFFFFFFFF, shader->bo);
+                       0, 0xFFFFFFFF, shader->bo);
 
        r600_pipe_state_add_reg(rstate,
                                R_03A200_SQ_LOOP_CONST_0 + (32 * 4), 0x01000FFF,
@@ -1765,7 +2356,7 @@ void evergreen_fetch_shader(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_0288A8_SQ_PGM_RESOURCES_FS,
                                0x00000000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_0288A4_SQ_PGM_START_FS,
-                               (r600_bo_offset(ve->fetch_shader)) >> 8,
+                               0,
                                0xFFFFFFFF, ve->fetch_shader);
 }
 
index d795f57..96dbd4d 100644 (file)
 #define   S_008C28_NUM_LS_STACK_ENTRIES(x)             (((x) & 0xFFF) << 16)
 #define   G_008C28_NUM_LS_STACK_ENTRIES(x)             (((x) >> 16) & 0xFFF)
 #define   C_008C28_NUM_LS_STACK_ENTRIES(x)             0xF000FFFF
+#define R_008E2C_SQ_LDS_RESOURCE_MGMT                0x00008E2C
+#define   S_008E2C_NUM_PS_LDS(x)                       (((x) & 0xFFFF) << 0)
+#define   G_008E2C_NUM_PS_LDS(x)                       (((x) >> 0) & 0xFFFF)
+#define   C_008E2C_NUM_PS_LDS(x)                       0x0000FFFF
+#define   S_008E2C_NUM_LS_LDS(x)                       (((x) & 0xFFFF) << 16)
+#define   G_008E2C_NUM_LS_LDS(x)                       (((x) >> 16) & 0xFFFF)
+#define   C_008E2C_NUM_LS_LDS(x)                       0xFFFF0000
 
 #define R_008CF0_SQ_MS_FIFO_SIZES                     0x00008CF0
 #define   S_008CF0_CACHE_FIFO_SIZE(x)                  (((x) & 0xFF) << 0)
index 225c17c..2ac5ed4 100644 (file)
@@ -94,6 +94,8 @@ struct r600_tiling_info *r600_get_tiling_info(struct radeon *radeon);
 unsigned r600_get_clock_crystal_freq(struct radeon *radeon);
 unsigned r600_get_minor_version(struct radeon *radeon);
 unsigned r600_get_num_backends(struct radeon *radeon);
+unsigned r600_get_num_tile_pipes(struct radeon *radeon);
+unsigned r600_get_backend_map(struct radeon *radeon);
 
 /* r600_bo.c */
 struct r600_bo;
@@ -105,11 +107,8 @@ struct r600_bo *r600_bo_handle(struct radeon *radeon,
 void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, unsigned usage, void *ctx);
 void r600_bo_unmap(struct radeon *radeon, struct r600_bo *bo);
 boolean r600_bo_get_winsys_handle(struct radeon *radeon, struct r600_bo *pb_bo,
-                               unsigned stride, struct winsys_handle *whandle);
-static INLINE unsigned r600_bo_offset(struct r600_bo *bo)
-{
-       return 0;
-}
+                                 unsigned stride, struct winsys_handle *whandle);
+
 void r600_bo_destroy(struct radeon *radeon, struct r600_bo *bo);
 
 /* this relies on the pipe_reference being the first member of r600_bo */
@@ -211,14 +210,21 @@ struct r600_reloc {
  */
 struct r600_query {
        u64                                     result;
-       /* The kind of query. Currently only OQ is supported. */
+       /* The kind of query */
        unsigned                                type;
-       /* How many results have been written, in dwords. It's incremented
-        * after end_query and flush. */
-       unsigned                                num_results;
-       /* if we've flushed the query */
+       /* Offset of the first result for current query */
+       unsigned                                results_start;
+       /* Offset of the next free result after current query data */
+       unsigned                                results_end;
+       /* Size of the result */
+       unsigned                                result_size;
+       /* Count of new queries started in one stream without flushing */
+       unsigned                                queries_emitted;
+       /* State flags */
        unsigned                                state;
-       /* The buffer where query results are stored. */
+       /* The buffer where query results are stored. It's used as a ring,
+        * data blocks for current query are stored sequentially from
+        * results_start to results_end, with wrapping on the buffer end */
        struct r600_bo                  *buffer;
        unsigned                                buffer_size;
        /* linked list of queries */
@@ -228,6 +234,7 @@ struct r600_query {
 #define R600_QUERY_STATE_STARTED       (1 << 0)
 #define R600_QUERY_STATE_ENDED         (1 << 1)
 #define R600_QUERY_STATE_SUSPENDED     (1 << 2)
+#define R600_QUERY_STATE_FLUSHED       (1 << 3)
 
 #define R600_CONTEXT_DRAW_PENDING      (1 << 0)
 #define R600_CONTEXT_DST_CACHES_DIRTY  (1 << 1)
@@ -245,6 +252,7 @@ struct r600_context {
        unsigned                pm4_cdwords;
        unsigned                pm4_dirty_cdwords;
        unsigned                ctx_pm4_ndwords;
+       unsigned                init_dwords;
        unsigned                nreloc;
        unsigned                creloc;
        struct r600_reloc       *reloc;
@@ -252,6 +260,7 @@ struct r600_context {
        u32                     *pm4;
        struct list_head        query_list;
        unsigned                num_query_running;
+       unsigned                backend_mask;
        struct list_head        fenced_bo;
        unsigned                max_db; /* for OQ */
        unsigned                num_dest_buffers;
@@ -273,6 +282,7 @@ struct r600_draw {
        struct r600_bo          *indices;
 };
 
+void r600_get_backend_mask(struct r600_context *ctx);
 int r600_context_init(struct r600_context *ctx, struct radeon *radeon);
 void r600_context_fini(struct r600_context *ctx);
 void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_state *state);
@@ -282,7 +292,6 @@ void r600_context_pipe_state_set_fs_resource(struct r600_context *ctx, struct r6
 void r600_context_pipe_state_set_ps_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id);
 void r600_context_pipe_state_set_vs_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id);
 void r600_context_flush(struct r600_context *ctx);
-void r600_context_dump_bof(struct r600_context *ctx, const char *file);
 void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw);
 
 struct r600_query *r600_context_query_create(struct r600_context *ctx, unsigned query_type);
@@ -293,7 +302,7 @@ boolean r600_context_query_result(struct r600_context *ctx,
 void r600_query_begin(struct r600_context *ctx, struct r600_query *query);
 void r600_query_end(struct r600_context *ctx, struct r600_query *query);
 void r600_context_queries_suspend(struct r600_context *ctx);
-void r600_context_queries_resume(struct r600_context *ctx);
+void r600_context_queries_resume(struct r600_context *ctx, boolean flushed);
 void r600_query_predication(struct r600_context *ctx, struct r600_query *query, int operation,
                            int flag_wait);
 void r600_context_emit_fence(struct r600_context *ctx, struct r600_bo *fence,
index c447a03..5fae2b0 100644 (file)
@@ -41,9 +41,9 @@ static inline unsigned int r600_bc_get_num_operands(struct r600_bc *bc, struct r
        if(alu->is_op3)
                return 3;
 
-       switch (bc->chiprev) {
-       case CHIPREV_R600:
-       case CHIPREV_R700:
+       switch (bc->chip_class) {
+       case R600:
+       case R700:
                switch (alu->inst) {
                case V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP:
                        return 0;
@@ -93,8 +93,8 @@ static inline unsigned int r600_bc_get_num_operands(struct r600_bc *bc, struct r
                        "Need instruction operand number for 0x%x.\n", alu->inst);
                }
                break;
-       case CHIPREV_EVERGREEN:
-       case CHIPREV_CAYMAN:
+       case EVERGREEN:
+       case CAYMAN:
                switch (alu->inst) {
                case EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP:
                        return 0;
@@ -195,48 +195,10 @@ static struct r600_bc_tex *r600_bc_tex(void)
        return tex;
 }
 
-int r600_bc_init(struct r600_bc *bc, enum radeon_family family)
+void r600_bc_init(struct r600_bc *bc, enum chip_class chip_class)
 {
        LIST_INITHEAD(&bc->cf);
-       bc->family = family;
-       switch (bc->family) {
-       case CHIP_R600:
-       case CHIP_RV610:
-       case CHIP_RV630:
-       case CHIP_RV670:
-       case CHIP_RV620:
-       case CHIP_RV635:
-       case CHIP_RS780:
-       case CHIP_RS880:
-               bc->chiprev = CHIPREV_R600;
-               break;
-       case CHIP_RV770:
-       case CHIP_RV730:
-       case CHIP_RV710:
-       case CHIP_RV740:
-               bc->chiprev = CHIPREV_R700;
-               break;
-       case CHIP_CEDAR:
-       case CHIP_REDWOOD:
-       case CHIP_JUNIPER:
-       case CHIP_CYPRESS:
-       case CHIP_HEMLOCK:
-       case CHIP_PALM:
-       case CHIP_SUMO:
-       case CHIP_SUMO2:
-       case CHIP_BARTS:
-       case CHIP_TURKS:
-       case CHIP_CAICOS:
-               bc->chiprev = CHIPREV_EVERGREEN;
-               break;
-       case CHIP_CAYMAN:
-               bc->chiprev = CHIPREV_CAYMAN;
-               break;
-       default:
-               R600_ERR("unknown family %d\n", bc->family);
-               return -EINVAL;
-       }
-       return 0;
+       bc->chip_class = chip_class;
 }
 
 static int r600_bc_add_cf(struct r600_bc *bc)
@@ -301,9 +263,9 @@ int r600_bc_add_output(struct r600_bc *bc, const struct r600_bc_output *output)
 /* alu instructions that can ony exits once per group */
 static int is_alu_once_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 {
-       switch (bc->chiprev) {
-       case CHIPREV_R600:
-       case CHIPREV_R700:
+       switch (bc->chip_class) {
+       case R600:
+       case R700:
                return !alu->is_op3 && (
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLE ||
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT ||
@@ -339,8 +301,8 @@ static int is_alu_once_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_PUSH_INT ||
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETLT_PUSH_INT ||
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETLE_PUSH_INT);
-       case CHIPREV_EVERGREEN:
-       case CHIPREV_CAYMAN:
+       case EVERGREEN:
+       case CAYMAN:
        default:
                return !alu->is_op3 && (
                        alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLE ||
@@ -382,16 +344,16 @@ static int is_alu_once_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 
 static int is_alu_reduction_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 {
-       switch (bc->chiprev) {
-       case CHIPREV_R600:
-       case CHIPREV_R700:
+       switch (bc->chip_class) {
+       case R600:
+       case R700:
                return !alu->is_op3 && (
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE ||
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4 ||
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4_IEEE ||
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX4);
-       case CHIPREV_EVERGREEN:
-       case CHIPREV_CAYMAN:
+       case EVERGREEN:
+       case CAYMAN:
        default:
                return !alu->is_op3 && (
                        alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE ||
@@ -403,13 +365,13 @@ static int is_alu_reduction_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 
 static int is_alu_cube_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 {
-       switch (bc->chiprev) {
-       case CHIPREV_R600:
-       case CHIPREV_R700:
+       switch (bc->chip_class) {
+       case R600:
+       case R700:
                return !alu->is_op3 &&
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE;
-       case CHIPREV_EVERGREEN:
-       case CHIPREV_CAYMAN:
+       case EVERGREEN:
+       case CAYMAN:
        default:
                return !alu->is_op3 &&
                        alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE;
@@ -418,15 +380,15 @@ static int is_alu_cube_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 
 static int is_alu_mova_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 {
-       switch (bc->chiprev) {
-       case CHIPREV_R600:
-       case CHIPREV_R700:
+       switch (bc->chip_class) {
+       case R600:
+       case R700:
                return !alu->is_op3 && (
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA ||
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR ||
                        alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT);
-       case CHIPREV_EVERGREEN:
-       case CHIPREV_CAYMAN:
+       case EVERGREEN:
+       case CAYMAN:
        default:
                return !alu->is_op3 && (
                        alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT);
@@ -438,16 +400,16 @@ static int is_alu_vec_unit_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 {
        return is_alu_reduction_inst(bc, alu) ||
                is_alu_mova_inst(bc, alu) ||
-               (bc->chiprev == CHIPREV_EVERGREEN &&
+               (bc->chip_class == EVERGREEN &&
                alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR);
 }
 
 /* alu instructions that can only execute on the trans unit */
 static int is_alu_trans_unit_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
 {
-       switch (bc->chiprev) {
-       case CHIPREV_R600:
-       case CHIPREV_R700:
+       switch (bc->chip_class) {
+       case R600:
+       case R700:
                if (!alu->is_op3)
                        return alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT ||
                                alu->inst == V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT ||
@@ -478,8 +440,8 @@ static int is_alu_trans_unit_inst(struct r600_bc *bc, struct r600_bc_alu *alu)
                                alu->inst == V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT_D2 ||
                                alu->inst == V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT_M2 ||
                                alu->inst == V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT_M4;
-       case CHIPREV_EVERGREEN:
-       case CHIPREV_CAYMAN:
+       case EVERGREEN:
+       case CAYMAN:
        default:
                if (!alu->is_op3)
                        /* Note that FLT_TO_INT_* instructions are vector-only instructions
@@ -525,7 +487,7 @@ static int assign_alu_units(struct r600_bc *bc, struct r600_bc_alu *alu_first,
 {
        struct r600_bc_alu *alu;
        unsigned i, chan, trans;
-       int max_slots = bc->chiprev == CHIPREV_CAYMAN ? 4 : 5;
+       int max_slots = bc->chip_class == CAYMAN ? 4 : 5;
 
        for (i = 0; i < max_slots; i++)
                assignment[i] = NULL;
@@ -612,7 +574,7 @@ static int reserve_gpr(struct alu_bank_swizzle *bs, unsigned sel, unsigned chan,
 static int reserve_cfile(struct r600_bc *bc, struct alu_bank_swizzle *bs, unsigned sel, unsigned chan)
 {
        int res, num_res = 4;
-       if (bc->chiprev >= CHIPREV_R700) {
+       if (bc->chip_class >= R700) {
                num_res = 2;
                chan /= 2;
        }
@@ -733,8 +695,8 @@ static int check_and_set_bank_swizzle(struct r600_bc *bc,
        struct alu_bank_swizzle bs;
        int bank_swizzle[5];
        int i, r = 0, forced = 0;
-       boolean scalar_only = bc->chiprev == CHIPREV_CAYMAN ? false : true;
-       int max_slots = bc->chiprev == CHIPREV_CAYMAN ? 4 : 5;
+       boolean scalar_only = bc->chip_class == CAYMAN ? false : true;
+       int max_slots = bc->chip_class == CAYMAN ? 4 : 5;
 
        for (i = 0; i < max_slots; i++) {
                if (slots[i] && slots[i]->bank_swizzle_force) {
@@ -806,7 +768,7 @@ static int replace_gpr_with_pv_ps(struct r600_bc *bc,
        struct r600_bc_alu *prev[5];
        int gpr[5], chan[5];
        int i, j, r, src, num_src;
-       int max_slots = bc->chiprev == CHIPREV_CAYMAN ? 4 : 5;
+       int max_slots = bc->chip_class == CAYMAN ? 4 : 5;
 
        r = assign_alu_units(bc, alu_prev, prev);
        if (r)
@@ -834,7 +796,7 @@ static int replace_gpr_with_pv_ps(struct r600_bc *bc,
                        if (!is_gpr(alu->src[src].sel) || alu->src[src].rel)
                                continue;
 
-                       if (bc->chiprev < CHIPREV_CAYMAN) {
+                       if (bc->chip_class < CAYMAN) {
                                if (alu->src[src].sel == gpr[4] &&
                                    alu->src[src].chan == chan[4]) {
                                        alu->src[src].sel = V_SQ_ALU_SRC_PS;
@@ -948,7 +910,7 @@ static int merge_inst_groups(struct r600_bc *bc, struct r600_bc_alu *slots[5],
        int i, j, r, src, num_src;
        int num_once_inst = 0;
        int have_mova = 0, have_rel = 0;
-       int max_slots = bc->chiprev == CHIPREV_CAYMAN ? 4 : 5;
+       int max_slots = bc->chip_class == CAYMAN ? 4 : 5;
 
        r = assign_alu_units(bc, alu_prev, prev);
        if (r)
@@ -1252,7 +1214,7 @@ int r600_bc_add_alu_type(struct r600_bc *bc, const struct r600_bc_alu *alu, int
                uint32_t literal[4];
                unsigned nliteral;
                struct r600_bc_alu *slots[5];
-               int max_slots = bc->chiprev == CHIPREV_CAYMAN ? 4 : 5;
+               int max_slots = bc->chip_class == CAYMAN ? 4 : 5;
                r = assign_alu_units(bc, bc->cf_last->curr_bs_head, slots);
                if (r)
                        return r;
@@ -1302,26 +1264,26 @@ int r600_bc_add_alu(struct r600_bc *bc, const struct r600_bc_alu *alu)
 
 static unsigned r600_bc_num_tex_and_vtx_instructions(const struct r600_bc *bc)
 {
-       switch (bc->chiprev) {
-       case CHIPREV_R600:
+       switch (bc->chip_class) {
+       case R600:
                return 8;
 
-       case CHIPREV_R700:
+       case R700:
                return 16;
 
-       case CHIPREV_EVERGREEN:
-       case CHIPREV_CAYMAN:
+       case EVERGREEN:
+       case CAYMAN:
                return 64;
 
        default:
-               R600_ERR("Unknown chiprev %d.\n", bc->chiprev);
+               R600_ERR("Unknown chip class %d.\n", bc->chip_class);
                return 8;
        }
 }
 
 static inline boolean last_inst_was_vtx_fetch(struct r600_bc *bc)
 {
-       if (bc->chiprev == CHIPREV_CAYMAN) {
+       if (bc->chip_class == CAYMAN) {
                if (bc->cf_last->inst != CM_V_SQ_CF_WORD1_SQ_CF_INST_TC)
                        return TRUE;
        } else {
@@ -1350,7 +1312,7 @@ int r600_bc_add_vtx(struct r600_bc *bc, const struct r600_bc_vtx *vtx)
                        free(nvtx);
                        return r;
                }
-               if (bc->chiprev == CHIPREV_CAYMAN)
+               if (bc->chip_class == CAYMAN)
                        bc->cf_last->inst = CM_V_SQ_CF_WORD1_SQ_CF_INST_TC;
                else
                        bc->cf_last->inst = V_SQ_CF_WORD1_SQ_CF_INST_VTX;
@@ -1438,7 +1400,7 @@ static int r600_bc_vtx_build(struct r600_bc *bc, struct r600_bc_vtx *vtx, unsign
                        S_SQ_VTX_WORD0_FETCH_TYPE(vtx->fetch_type) |
                        S_SQ_VTX_WORD0_SRC_GPR(vtx->src_gpr) |
                        S_SQ_VTX_WORD0_SRC_SEL_X(vtx->src_sel_x);
-       if (bc->chiprev < CHIPREV_CAYMAN)
+       if (bc->chip_class < CAYMAN)
                bc->bytecode[id] |= S_SQ_VTX_WORD0_MEGA_FETCH_COUNT(vtx->mega_fetch_count);
        id++;
        bc->bytecode[id++] = S_SQ_VTX_WORD1_DST_SEL_X(vtx->dst_sel_x) |
@@ -1453,7 +1415,7 @@ static int r600_bc_vtx_build(struct r600_bc *bc, struct r600_bc_vtx *vtx, unsign
                                S_SQ_VTX_WORD1_GPR_DST_GPR(vtx->dst_gpr);
        bc->bytecode[id] = S_SQ_VTX_WORD2_OFFSET(vtx->offset)|
                                S_SQ_VTX_WORD2_ENDIAN_SWAP(vtx->endian);
-       if (bc->chiprev < CHIPREV_CAYMAN)
+       if (bc->chip_class < CAYMAN)
                bc->bytecode[id] |= S_SQ_VTX_WORD2_MEGA_FETCH(1);
        id++;
        bc->bytecode[id++] = 0;
@@ -1560,13 +1522,13 @@ static int r600_bc_cf_build(struct r600_bc *bc, struct r600_bc_cf *cf)
                        S_SQ_CF_ALU_WORD1_KCACHE_ADDR0(cf->kcache[0].addr) |
                        S_SQ_CF_ALU_WORD1_KCACHE_ADDR1(cf->kcache[1].addr) |
                                        S_SQ_CF_ALU_WORD1_BARRIER(1) |
-                                       S_SQ_CF_ALU_WORD1_USES_WATERFALL(bc->chiprev == CHIPREV_R600 ? cf->r6xx_uses_waterfall : 0) |
+                                       S_SQ_CF_ALU_WORD1_USES_WATERFALL(bc->chip_class == R600 ? cf->r6xx_uses_waterfall : 0) |
                                        S_SQ_CF_ALU_WORD1_COUNT((cf->ndw / 2) - 1);
                break;
        case V_SQ_CF_WORD1_SQ_CF_INST_TEX:
        case V_SQ_CF_WORD1_SQ_CF_INST_VTX:
        case V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC:
-               if (bc->chiprev == CHIPREV_R700)
+               if (bc->chip_class == R700)
                        r700_bc_cf_vtx_build(&bc->bytecode[id], cf);
                else
                        r600_bc_cf_vtx_build(&bc->bytecode[id], cf);
@@ -1673,7 +1635,7 @@ int r600_bc_build(struct r600_bc *bc)
                return -ENOMEM;
        LIST_FOR_EACH_ENTRY(cf, &bc->cf, list) {
                addr = cf->addr;
-               if (bc->chiprev >= CHIPREV_EVERGREEN)
+               if (bc->chip_class >= EVERGREEN)
                        r = eg_bc_cf_build(bc, cf);
                else
                        r = r600_bc_cf_build(bc, cf);
@@ -1691,17 +1653,17 @@ int r600_bc_build(struct r600_bc *bc)
                                if (r)
                                        return r;
                                r600_bc_alu_adjust_literals(bc, alu, literal, nliteral);
-                               switch(bc->chiprev) {
-                               case CHIPREV_R600:
+                               switch(bc->chip_class) {
+                               case R600:
                                        r = r600_bc_alu_build(bc, alu, addr);
                                        break;
-                               case CHIPREV_R700:
-                               case CHIPREV_EVERGREEN: /* eg alu is same encoding as r700 */
-                               case CHIPREV_CAYMAN: /* eg alu is same encoding as r700 */
+                               case R700:
+                               case EVERGREEN: /* eg alu is same encoding as r700 */
+                               case CAYMAN: /* eg alu is same encoding as r700 */
                                        r = r700_bc_alu_build(bc, alu, addr);
                                        break;
                                default:
-                                       R600_ERR("unknown family %d\n", bc->family);
+                                       R600_ERR("unknown chip class %d.\n", bc->chip_class);
                                        return -EINVAL;
                                }
                                if (r)
@@ -1726,7 +1688,7 @@ int r600_bc_build(struct r600_bc *bc)
                        }
                        break;
                case V_SQ_CF_WORD1_SQ_CF_INST_TEX:
-                       if (bc->chiprev == CHIPREV_CAYMAN) {
+                       if (bc->chip_class == CAYMAN) {
                                LIST_FOR_EACH_ENTRY(vtx, &cf->vtx, list) {
                                        r = r600_bc_vtx_build(bc, vtx, addr);
                                        if (r)
@@ -1812,17 +1774,17 @@ void r600_bc_dump(struct r600_bc *bc)
        unsigned nliteral;
        char chip = '6';
 
-       switch (bc->chiprev) {
-       case 1:
+       switch (bc->chip_class) {
+       case R700:
                chip = '7';
                break;
-       case 2:
+       case EVERGREEN:
                chip = 'E';
                break;
-       case 3:
+       case CAYMAN:
                chip = 'C';
                break;
-       case 0:
+       case R600:
        default:
                chip = '6';
                break;
@@ -1863,6 +1825,8 @@ void r600_bc_dump(struct r600_bc *bc)
                        break;
                case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT:
                case V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE:
+               case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT:
+               case EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE:
                        fprintf(stderr, "%04d %08X EXPORT ", id, bc->bytecode[id]);
                        fprintf(stderr, "GPR:%X ", cf->output.gpr);
                        fprintf(stderr, "ELEM_SIZE:%X ", cf->output.elem_size);
@@ -1991,7 +1955,7 @@ void r600_bc_dump(struct r600_bc *bc)
                        fprintf(stderr, "%04d %08X   ", id, bc->bytecode[id]);
                        fprintf(stderr, "SRC(GPR:%d ", vtx->src_gpr);
                        fprintf(stderr, "SEL_X:%d) ", vtx->src_sel_x);
-                       if (bc->chiprev < CHIPREV_CAYMAN)
+                       if (bc->chip_class < CAYMAN)
                                fprintf(stderr, "MEGA_FETCH_COUNT:%d ", vtx->mega_fetch_count);
                        else
                                fprintf(stderr, "SEL_Y:%d) ", 0);
@@ -2160,7 +2124,7 @@ int r600_vertex_elements_build_fetch_shader(struct r600_pipe_context *rctx, stru
        struct r600_bc_vtx vtx;
        struct pipe_vertex_element *elements = ve->elements;
        const struct util_format_description *desc;
-       unsigned fetch_resource_start = rctx->family >= CHIP_CEDAR ? 0 : 160;
+       unsigned fetch_resource_start = rctx->chip_class >= EVERGREEN ? 0 : 160;
        unsigned format, num_format, format_comp, endian;
        u32 *bytecode;
        int i, r;
@@ -2178,9 +2142,7 @@ int r600_vertex_elements_build_fetch_shader(struct r600_pipe_context *rctx, stru
        }
 
        memset(&bc, 0, sizeof(bc));
-       r = r600_bc_init(&bc, r600_get_family(rctx->radeon));
-       if (r)
-               return r;
+       r600_bc_init(&bc, rctx->chip_class);
 
        for (i = 0; i < ve->count; i++) {
                if (elements[i].instance_divisor > 1) {
@@ -2285,7 +2247,7 @@ int r600_vertex_elements_build_fetch_shader(struct r600_pipe_context *rctx, stru
        r600_bo_unmap(rctx->radeon, ve->fetch_shader);
        r600_bc_clear(&bc);
 
-       if (rctx->family >= CHIP_CEDAR)
+       if (rctx->chip_class >= EVERGREEN)
                evergreen_fetch_shader(&rctx->context, ve);
        else
                r600_fetch_shader(&rctx->context, ve);
index 540f45b..cbdaacf 100644 (file)
@@ -171,8 +171,7 @@ struct r600_cf_callstack {
 };
 
 struct r600_bc {
-       enum radeon_family              family;
-       int                             chiprev; /* 0 - r600, 1 - r700, 2 - evergreen */
+       enum chip_class                 chip_class;
        int                             type;
        struct list_head                cf;
        struct r600_bc_cf               *cf_last;
@@ -193,7 +192,7 @@ struct r600_bc {
 int eg_bc_cf_build(struct r600_bc *bc, struct r600_bc_cf *cf);
 
 /* r600_asm.c */
-int r600_bc_init(struct r600_bc *bc, enum radeon_family family);
+void r600_bc_init(struct r600_bc *bc, enum chip_class chip_class);
 void r600_bc_clear(struct r600_bc *bc);
 int r600_bc_add_alu(struct r600_bc *bc, const struct r600_bc_alu *alu);
 int r600_bc_add_vtx(struct r600_bc *bc, const struct r600_bc_vtx *vtx);
index 043c875..35e68b6 100644 (file)
@@ -97,7 +97,7 @@ static void r600_blitter_end(struct pipe_context *ctx)
                                               rctx->saved_render_cond_mode);
                rctx->saved_render_cond = NULL;
        }
-       r600_context_queries_resume(&rctx->ctx);
+       r600_context_queries_resume(&rctx->ctx, FALSE);
        rctx->blit = false;
 }
 
@@ -294,6 +294,8 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
 {
        struct r600_resource_texture *rsrc = (struct r600_resource_texture*)src;
        struct texture_orig_info orig_info[2];
+       struct pipe_box sbox;
+       const struct pipe_box *psbox;
        boolean restore_orig[2];
 
        /* Fallback for buffers. */
@@ -311,7 +313,15 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
        if (util_format_is_compressed(src->format)) {
                r600_compressed_to_blittable(src, src_level, &orig_info[0]);
                restore_orig[0] = TRUE;
-       }
+               sbox.x = util_format_get_nblocksx(orig_info[0].format, src_box->x);
+               sbox.y = util_format_get_nblocksy(orig_info[0].format, src_box->y);
+               sbox.z = src_box->z;
+               sbox.width = util_format_get_nblocksx(orig_info[0].format, src_box->width);
+               sbox.height = util_format_get_nblocksy(orig_info[0].format, src_box->height);
+               sbox.depth = src_box->depth;
+               psbox=&sbox;
+       } else
+               psbox=src_box;
 
        if (util_format_is_compressed(dst->format)) {
                r600_compressed_to_blittable(dst, dst_level, &orig_info[1]);
@@ -322,7 +332,7 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
        }
 
        r600_hw_copy_region(ctx, dst, dst_level, dstx, dsty, dstz,
-                           src, src_level, src_box);
+                           src, src_level, psbox);
 
        if (restore_orig[0])
                r600_reset_blittable_to_compressed(src, src_level, &orig_info[0]);
index ae0bc43..1c1089d 100644 (file)
@@ -81,4 +81,36 @@ static INLINE unsigned r600_endian_swap(unsigned size)
        }
 }
 
+static INLINE bool r600_is_vertex_format_supported(enum pipe_format format)
+{
+       const struct util_format_description *desc = util_format_description(format);
+       unsigned i;
+
+       if (!desc)
+               return false;
+
+       /* Find the first non-VOID channel. */
+       for (i = 0; i < 4; i++) {
+               if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
+                       break;
+       }
+       if (i == 4)
+               return false;
+
+       /* No fixed, no double. */
+       if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
+           desc->channel[i].type == UTIL_FORMAT_TYPE_FIXED ||
+           (desc->channel[i].size == 64 &&
+            desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT))
+               return false;
+
+       /* No scaled/norm formats with 32 bits per channel. */
+       if (desc->channel[i].size == 32 &&
+           (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED ||
+            desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED))
+               return false;
+
+       return true;
+}
+
 #endif
index 184f32c..7ae091e 100644 (file)
 #define     EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_EXPORT_COMBINED 0x0000005B
 #define     EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_RAT_COMBINED_CACHELESS  0x0000005C
 
+#define BC_INST(bc, x) ((bc)->chip_class >= EVERGREEN ? EG_##x : x)
 
-#define CHIPREV_R600      0
-#define CHIPREV_R700      1
-#define CHIPREV_EVERGREEN 2
-#define CHIPREV_CAYMAN    3
-
-#define BC_INST(bc, x) ((bc)->chiprev >= CHIPREV_EVERGREEN ? EG_##x : x)
-
-#define CTX_INST(x) (ctx->bc->chiprev >= CHIPREV_EVERGREEN ? EG_##x : x)
+#define CTX_INST(x) (ctx->bc->chip_class >= EVERGREEN ? EG_##x : x)
 
 #endif
index 2d74413..461f594 100644 (file)
@@ -38,6 +38,8 @@
 #include <util/u_memory.h>
 #include <util/u_inlines.h>
 #include "util/u_upload_mgr.h"
+#include <vl/vl_decoder.h>
+#include <vl/vl_video_buffer.h>
 #include "os/os_time.h"
 #include <pipebuffer/pb_buffer.h>
 #include "r600.h"
@@ -45,7 +47,6 @@
 #include "r600_resource.h"
 #include "r600_shader.h"
 #include "r600_pipe.h"
-#include "r600_state_inlines.h"
 
 /*
  * pipe_context
@@ -61,7 +62,7 @@ static struct r600_fence *r600_create_fence(struct r600_pipe_context *ctx)
                        R600_ERR("r600: failed to create bo for fence objects\n");
                        return NULL;
                }
-               ctx->fences.data = r600_bo_map(ctx->radeon, ctx->fences.bo, PB_USAGE_UNSYNCHRONIZED, NULL);
+               ctx->fences.data = r600_bo_map(ctx->radeon, ctx->fences.bo, PIPE_TRANSFER_UNSYNCHRONIZED, NULL);
        }
 
        if (!LIST_IS_EMPTY(&ctx->fences.pool)) {
@@ -118,25 +119,9 @@ static void r600_flush(struct pipe_context *ctx,
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_fence **rfence = (struct r600_fence**)fence;
 
-#if 0
-       static int dc = 0;
-       char dname[256];
-#endif
-
        if (rfence)
                *rfence = r600_create_fence(rctx);
 
-       if (!rctx->ctx.pm4_cdwords)
-               return;
-
-#if 0
-       sprintf(dname, "gallium-%08d.bof", dc);
-       if (dc < 20) {
-               r600_context_dump_bof(&rctx->ctx, dname);
-               R600_ERR("dumped %s\n", dname);
-       }
-       dc++;
-#endif
        r600_context_flush(&rctx->ctx);
 }
 
@@ -198,7 +183,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 {
        struct r600_pipe_context *rctx = CALLOC_STRUCT(r600_pipe_context);
        struct r600_screen* rscreen = (struct r600_screen *)screen;
-       enum chip_class class;
 
        if (rctx == NULL)
                return NULL;
@@ -215,6 +199,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        rctx->screen = rscreen;
        rctx->radeon = rscreen->radeon;
        rctx->family = r600_get_family(rctx->radeon);
+       rctx->chip_class = r600_get_family_class(rctx->radeon);
 
        rctx->fences.bo = NULL;
        rctx->fences.data = NULL;
@@ -228,47 +213,32 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        r600_init_surface_functions(rctx);
        rctx->context.draw_vbo = r600_draw_vbo;
 
-       switch (r600_get_family(rctx->radeon)) {
-       case CHIP_R600:
-       case CHIP_RV610:
-       case CHIP_RV630:
-       case CHIP_RV670:
-       case CHIP_RV620:
-       case CHIP_RV635:
-       case CHIP_RS780:
-       case CHIP_RS880:
-       case CHIP_RV770:
-       case CHIP_RV730:
-       case CHIP_RV710:
-       case CHIP_RV740:
+       rctx->context.create_video_decoder = vl_create_decoder;
+       rctx->context.create_video_buffer = vl_video_buffer_create;
+
+       switch (rctx->chip_class) {
+       case R600:
+       case R700:
                r600_init_state_functions(rctx);
                if (r600_context_init(&rctx->ctx, rctx->radeon)) {
                        r600_destroy_context(&rctx->context);
                        return NULL;
                }
                r600_init_config(rctx);
+               rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx);
                break;
-       case CHIP_CEDAR:
-       case CHIP_REDWOOD:
-       case CHIP_JUNIPER:
-       case CHIP_CYPRESS:
-       case CHIP_HEMLOCK:
-       case CHIP_PALM:
-       case CHIP_SUMO:
-       case CHIP_SUMO2:
-       case CHIP_BARTS:
-       case CHIP_TURKS:
-       case CHIP_CAICOS:
-       case CHIP_CAYMAN:
+       case EVERGREEN:
+       case CAYMAN:
                evergreen_init_state_functions(rctx);
                if (evergreen_context_init(&rctx->ctx, rctx->radeon)) {
                        r600_destroy_context(&rctx->context);
                        return NULL;
                }
                evergreen_init_config(rctx);
+               rctx->custom_dsa_flush = evergreen_create_db_flush_dsa(rctx);
                break;
        default:
-               R600_ERR("unsupported family %d\n", r600_get_family(rctx->radeon));
+               R600_ERR("Unsupported chip class %d.\n", rctx->chip_class);
                r600_destroy_context(&rctx->context);
                return NULL;
        }
@@ -293,12 +263,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
                return NULL;
        }
 
-       class = r600_get_family_class(rctx->radeon);
-       if (class == R600 || class == R700)
-               rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx);
-       else
-               rctx->custom_dsa_flush = evergreen_create_db_flush_dsa(rctx);
-
        return &rctx->context;
 }
 
@@ -376,6 +340,8 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
        case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
        case PIPE_CAP_SM3:
+       case PIPE_CAP_SEAMLESS_CUBE_MAP:
+       case PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL:
                return 1;
 
        /* Supported except the original R600. */
@@ -385,14 +351,12 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
                return family == CHIP_R600 ? 0 : 1;
 
        /* Supported on Evergreen. */
-       case PIPE_CAP_SEAMLESS_CUBE_MAP:
        case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
                return family >= CHIP_CEDAR ? 1 : 0;
 
        /* Unsupported features. */
        case PIPE_CAP_STREAM_OUTPUT:
        case PIPE_CAP_PRIMITIVE_RESTART:
-       case PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL:
        case PIPE_CAP_TGSI_INSTANCEID:
        case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
        case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
@@ -481,9 +445,9 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
                return 8; /* FIXME */
        case PIPE_SHADER_CAP_MAX_INPUTS:
                if(shader == PIPE_SHADER_FRAGMENT)
-                       return 10;
+                       return 34;
                else
-                       return 16;
+                       return 32;
        case PIPE_SHADER_CAP_MAX_TEMPS:
                return 256; /* Max native temporaries. */
        case PIPE_SHADER_CAP_MAX_ADDRS:
@@ -511,62 +475,21 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
        }
 }
 
-static boolean r600_is_format_supported(struct pipe_screen* screen,
-                                       enum pipe_format format,
-                                       enum pipe_texture_target target,
-                                       unsigned sample_count,
-                                        unsigned usage)
+static int r600_get_video_param(struct pipe_screen *screen,
+                               enum pipe_video_profile profile,
+                               enum pipe_video_cap param)
 {
-       unsigned retval = 0;
-       if (target >= PIPE_MAX_TEXTURE_TYPES) {
-               R600_ERR("r600: unsupported texture type %d\n", target);
-               return FALSE;
-       }
-
-        if (!util_format_is_supported(format, usage))
-                return FALSE;
-
-       /* Multisample */
-       if (sample_count > 1)
-               return FALSE;
-
-       if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
-           r600_is_sampler_format_supported(screen, format)) {
-               retval |= PIPE_BIND_SAMPLER_VIEW;
-       }
-
-       if ((usage & (PIPE_BIND_RENDER_TARGET |
-                       PIPE_BIND_DISPLAY_TARGET |
-                       PIPE_BIND_SCANOUT |
-                       PIPE_BIND_SHARED)) &&
-                       r600_is_colorbuffer_format_supported(format)) {
-               retval |= usage &
-                       (PIPE_BIND_RENDER_TARGET |
-                        PIPE_BIND_DISPLAY_TARGET |
-                        PIPE_BIND_SCANOUT |
-                        PIPE_BIND_SHARED);
-       }
-
-       if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
-           r600_is_zs_format_supported(format)) {
-               retval |= PIPE_BIND_DEPTH_STENCIL;
-       }
-
-       if (usage & PIPE_BIND_VERTEX_BUFFER) {
-               struct r600_screen *rscreen = (struct r600_screen *)screen;
-               enum radeon_family family = r600_get_family(rscreen->radeon);
-
-               if (r600_is_vertex_format_supported(format, family)) {
-                       retval |= PIPE_BIND_VERTEX_BUFFER;
-               }
+       switch (param) {
+       case PIPE_VIDEO_CAP_SUPPORTED:
+               return vl_profile_supported(screen, profile);
+       case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+               return 1;
+       case PIPE_VIDEO_CAP_MAX_WIDTH:
+       case PIPE_VIDEO_CAP_MAX_HEIGHT:
+               return vl_video_buffer_max_size(screen);
+       default:
+               return 0;
        }
-
-       if (usage & PIPE_BIND_TRANSFER_READ)
-               retval |= PIPE_BIND_TRANSFER_READ;
-       if (usage & PIPE_BIND_TRANSFER_WRITE)
-               retval |= PIPE_BIND_TRANSFER_WRITE;
-
-       return retval == usage;
 }
 
 static void r600_destroy_screen(struct pipe_screen* pscreen)
@@ -657,7 +580,13 @@ struct pipe_screen *r600_screen_create(struct radeon *radeon)
        rscreen->screen.get_param = r600_get_param;
        rscreen->screen.get_shader_param = r600_get_shader_param;
        rscreen->screen.get_paramf = r600_get_paramf;
-       rscreen->screen.is_format_supported = r600_is_format_supported;
+       rscreen->screen.get_video_param = r600_get_video_param;
+       if (r600_get_family_class(radeon) >= EVERGREEN) {
+               rscreen->screen.is_format_supported = evergreen_is_format_supported;
+       } else {
+               rscreen->screen.is_format_supported = r600_is_format_supported;
+       }
+       rscreen->screen.is_video_format_supported = vl_video_buffer_is_format_supported;
        rscreen->screen.context_create = r600_create_context;
        rscreen->screen.fence_reference = r600_fence_reference;
        rscreen->screen.fence_signalled = r600_fence_signalled;
index 84a45be..6f399ed 100644 (file)
@@ -50,6 +50,7 @@ enum r600_pipe_state_id {
        R600_PIPE_STATE_BLEND = 0,
        R600_PIPE_STATE_BLEND_COLOR,
        R600_PIPE_STATE_CONFIG,
+       R600_PIPE_STATE_SEAMLESS_CUBEMAP,
        R600_PIPE_STATE_CLIP,
        R600_PIPE_STATE_SCISSOR,
        R600_PIPE_STATE_VIEWPORT,
@@ -87,6 +88,8 @@ struct r600_pipe_sampler_view {
 
 struct r600_pipe_rasterizer {
        struct r600_pipe_state          rstate;
+       boolean                         clamp_vertex_color;
+       boolean                         clamp_fragment_color;
        boolean                         flatshade;
        unsigned                        sprite_coord_enable;
        float                           offset_units;
@@ -124,6 +127,12 @@ struct r600_pipe_shader {
        struct r600_bo                  *bo;
        struct r600_bo                  *bo_fetch;
        struct r600_vertex_element      vertex_elements;
+       struct tgsi_token               *tokens;
+};
+
+struct r600_pipe_sampler_state {
+       struct r600_pipe_state          rstate;
+       boolean seamless_cube_map;
 };
 
 /* needed for blitter save */
@@ -166,7 +175,8 @@ struct r600_pipe_fences {
 struct r600_pipe_context {
        struct pipe_context             context;
        struct blitter_context          *blitter;
-       unsigned                        family;
+       enum radeon_family              family;
+       enum chip_class                 chip_class;
        void                            *custom_dsa_flush;
        struct r600_screen              *screen;
        struct radeon                   *radeon;
@@ -196,11 +206,15 @@ struct r600_pipe_context {
        struct pipe_query               *saved_render_cond;
        unsigned                        saved_render_cond_mode;
        /* shader information */
+       boolean                         clamp_vertex_color;
+       boolean                         clamp_fragment_color;
+       boolean                         spi_dirty;
        unsigned                        sprite_coord_enable;
        boolean                         flatshade;
        boolean                         export_16bpc;
        unsigned                        alpha_ref;
        boolean                         alpha_ref_dirty;
+       unsigned                        nr_cbufs;
        struct r600_textures_info       ps_samplers;
 
        struct r600_pipe_fences         fences;
@@ -234,6 +248,11 @@ void evergreen_pipe_init_buffer_resource(struct r600_pipe_context *rctx,
 void evergreen_pipe_mod_buffer_resource(struct r600_pipe_resource_state *rstate,
                                        struct r600_resource *rbuffer,
                                        unsigned offset, unsigned stride);
+boolean evergreen_is_format_supported(struct pipe_screen *screen,
+                                     enum pipe_format format,
+                                     enum pipe_texture_target target,
+                                     unsigned sample_count,
+                                     unsigned usage);
 
 /* r600_blit.c */
 void r600_init_blit_functions(struct r600_pipe_context *rctx);
@@ -258,7 +277,7 @@ void r600_init_query_functions(struct r600_pipe_context *rctx);
 void r600_init_context_resource_functions(struct r600_pipe_context *r600);
 
 /* r600_shader.c */
-int r600_pipe_shader_create(struct pipe_context *ctx, struct r600_pipe_shader *shader, const struct tgsi_token *tokens);
+int r600_pipe_shader_create(struct pipe_context *ctx, struct r600_pipe_shader *shader);
 void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *shader);
 int r600_find_vs_semantic_index(struct r600_shader *vs,
                                struct r600_shader *ps, int id);
@@ -277,6 +296,11 @@ void r600_pipe_mod_buffer_resource(struct r600_pipe_resource_state *rstate,
                                   struct r600_resource *rbuffer,
                                   unsigned offset, unsigned stride);
 void r600_adjust_gprs(struct r600_pipe_context *rctx);
+boolean r600_is_format_supported(struct pipe_screen *screen,
+                                enum pipe_format format,
+                                enum pipe_texture_target target,
+                                unsigned sample_count,
+                                unsigned usage);
 
 /* r600_texture.c */
 void r600_init_screen_texture_functions(struct pipe_screen *screen);
index bedb48b..de1f5d0 100644 (file)
@@ -43,7 +43,7 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
        struct r600_query *rquery = (struct r600_query *)query;
 
        rquery->result = 0;
-       rquery->num_results = 0;
+       rquery->results_start = rquery->results_end;
        r600_query_begin(&rctx->ctx, (struct r600_query *)query);
 }
 
@@ -61,10 +61,7 @@ static boolean r600_get_query_result(struct pipe_context *ctx,
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_query *rquery = (struct r600_query *)query;
 
-       if (rquery->num_results) {
-                ctx->flush(ctx, NULL);
-       }
-       return r600_context_query_result(&rctx->ctx, (struct r600_query *)query, wait, vresult);
+       return r600_context_query_result(&rctx->ctx, rquery, wait, vresult);
 }
 
 static void r600_render_condition(struct pipe_context *ctx,
@@ -75,12 +72,18 @@ static void r600_render_condition(struct pipe_context *ctx,
        struct r600_query *rquery = (struct r600_query *)query;
        int wait_flag = 0;
 
+       /* If we already have nonzero result, render unconditionally */
+       if (query != NULL && rquery->result != 0)
+               return;
+
        rctx->current_render_cond = query;
        rctx->current_render_cond_mode = mode;
 
-       if (!query) {
-               rctx->ctx.predicate_drawing = false;
-               r600_query_predication(&rctx->ctx, NULL, PREDICATION_OP_CLEAR, 1);
+       if (query == NULL) {
+               if (rctx->ctx.predicate_drawing) {
+                       rctx->ctx.predicate_drawing = false;
+                       r600_query_predication(&rctx->ctx, NULL, PREDICATION_OP_CLEAR, 1);
+               }
                return;
        }
 
@@ -91,7 +94,6 @@ static void r600_render_condition(struct pipe_context *ctx,
 
        rctx->ctx.predicate_drawing = true;
        r600_query_predication(&rctx->ctx, rquery, PREDICATION_OP_ZPASS, wait_flag);
-       
 }
 
 void r600_init_query_functions(struct r600_pipe_context *rctx)
index b8a86b0..c55cdd7 100644 (file)
@@ -99,14 +99,14 @@ static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *s
        /* build state */
        switch (rshader->processor_type) {
        case TGSI_PROCESSOR_VERTEX:
-               if (rshader->family >= CHIP_CEDAR) {
+               if (rctx->chip_class >= EVERGREEN) {
                        evergreen_pipe_shader_vs(ctx, shader);
                } else {
                        r600_pipe_shader_vs(ctx, shader);
                }
                break;
        case TGSI_PROCESSOR_FRAGMENT:
-               if (rshader->family >= CHIP_CEDAR) {
+               if (rctx->chip_class >= EVERGREEN) {
                        evergreen_pipe_shader_ps(ctx, shader);
                } else {
                        r600_pipe_shader_ps(ctx, shader);
@@ -118,9 +118,9 @@ static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *s
        return 0;
 }
 
-static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_shader *shader);
+static int r600_shader_from_tgsi(struct r600_pipe_context * rctx, struct r600_pipe_shader *pipeshader);
 
-int r600_pipe_shader_create(struct pipe_context *ctx, struct r600_pipe_shader *shader, const struct tgsi_token *tokens)
+int r600_pipe_shader_create(struct pipe_context *ctx, struct r600_pipe_shader *shader)
 {
        static int dump_shaders = -1;
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
@@ -133,10 +133,9 @@ int r600_pipe_shader_create(struct pipe_context *ctx, struct r600_pipe_shader *s
 
        if (dump_shaders) {
                fprintf(stderr, "--------------------------------------------------------------\n");
-               tgsi_dump(tokens, 0);
+               tgsi_dump(shader->tokens, 0);
        }
-       shader->shader.family = r600_get_family(rctx->radeon);
-       r = r600_shader_from_tgsi(tokens, &shader->shader);
+       r = r600_shader_from_tgsi(rctx, shader);
        if (r) {
                R600_ERR("translation from TGSI failed !\n");
                return r;
@@ -159,6 +158,8 @@ void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader
 
        r600_bo_reference(rctx->radeon, &shader->bo, NULL);
        r600_bc_clear(&shader->shader.bc);
+
+       memset(&shader->shader,0,sizeof(struct r600_shader));
 }
 
 /*
@@ -315,7 +316,7 @@ static int tgsi_declaration(struct r600_shader_ctx *ctx)
                ctx->shader->input[i].interpolate = d->Declaration.Interpolate;
                ctx->shader->input[i].centroid = d->Declaration.Centroid;
                ctx->shader->input[i].gpr = ctx->file_offset[TGSI_FILE_INPUT] + i;
-               if (ctx->type == TGSI_PROCESSOR_FRAGMENT && ctx->bc->chiprev >= CHIPREV_EVERGREEN) {
+               if (ctx->type == TGSI_PROCESSOR_FRAGMENT && ctx->bc->chip_class >= EVERGREEN) {
                        /* turn input into interpolate on EG */
                        if (ctx->shader->input[i].name != TGSI_SEMANTIC_POSITION) {
                                if (ctx->shader->input[i].interpolate > 0) {
@@ -331,6 +332,12 @@ static int tgsi_declaration(struct r600_shader_ctx *ctx)
                ctx->shader->output[i].sid = d->Semantic.Index;
                ctx->shader->output[i].gpr = ctx->file_offset[TGSI_FILE_OUTPUT] + i;
                ctx->shader->output[i].interpolate = d->Declaration.Interpolate;
+               if (ctx->type == TGSI_PROCESSOR_VERTEX) {
+                       /* these don't count as vertex param exports */
+                       if ((ctx->shader->output[i].name == TGSI_SEMANTIC_POSITION) ||
+                           (ctx->shader->output[i].name == TGSI_SEMANTIC_PSIZE))
+                               ctx->shader->npos++;
+               }
                break;
        case TGSI_FILE_CONSTANT:
        case TGSI_FILE_TEMPORARY:
@@ -594,21 +601,21 @@ static int tgsi_split_literal_constant(struct r600_shader_ctx *ctx)
        return 0;
 }
 
-static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_shader *shader)
+static int r600_shader_from_tgsi(struct r600_pipe_context * rctx, struct r600_pipe_shader *pipeshader)
 {
+       struct r600_shader *shader = &pipeshader->shader;
+       struct tgsi_token *tokens = pipeshader->tokens;
        struct tgsi_full_immediate *immediate;
        struct tgsi_full_property *property;
        struct r600_shader_ctx ctx;
        struct r600_bc_output output[32];
        unsigned output_done, noutput;
        unsigned opcode;
-       int i, r = 0, pos0;
+       int i, j, r = 0, pos0;
 
        ctx.bc = &shader->bc;
        ctx.shader = shader;
-       r = r600_bc_init(ctx.bc, shader->family);
-       if (r)
-               return r;
+       r600_bc_init(ctx.bc, rctx->chip_class);
        ctx.tokens = tokens;
        tgsi_scan_shader(tokens, &ctx.info);
        tgsi_parse_init(&ctx.parse, tokens);
@@ -616,6 +623,11 @@ static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_sh
        shader->processor_type = ctx.type;
        ctx.bc->type = shader->processor_type;
 
+       shader->clamp_color = (((ctx.type == TGSI_PROCESSOR_FRAGMENT) && rctx->clamp_fragment_color) ||
+               ((ctx.type == TGSI_PROCESSOR_VERTEX) && rctx->clamp_vertex_color));
+
+       shader->nr_cbufs = rctx->nr_cbufs;
+
        /* register allocations */
        /* Values [0,127] correspond to GPR[0..127].
         * Values [128,159] correspond to constant buffer bank 0
@@ -642,19 +654,19 @@ static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_sh
        }
        if (ctx.type == TGSI_PROCESSOR_VERTEX) {
                ctx.file_offset[TGSI_FILE_INPUT] = 1;
-               if (ctx.bc->chiprev >= CHIPREV_EVERGREEN) {
+               if (ctx.bc->chip_class >= EVERGREEN) {
                        r600_bc_add_cfinst(ctx.bc, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS);
                } else {
                        r600_bc_add_cfinst(ctx.bc, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS);
                }
        }
-       if (ctx.type == TGSI_PROCESSOR_FRAGMENT && ctx.bc->chiprev >= CHIPREV_EVERGREEN) {
+       if (ctx.type == TGSI_PROCESSOR_FRAGMENT && ctx.bc->chip_class >= EVERGREEN) {
                ctx.file_offset[TGSI_FILE_INPUT] = evergreen_gpr_count(&ctx);
        }
        ctx.file_offset[TGSI_FILE_OUTPUT] = ctx.file_offset[TGSI_FILE_INPUT] +
-                                               ctx.info.file_count[TGSI_FILE_INPUT];
+                                               ctx.info.file_max[TGSI_FILE_INPUT] + 1;
        ctx.file_offset[TGSI_FILE_TEMPORARY] = ctx.file_offset[TGSI_FILE_OUTPUT] +
-                                               ctx.info.file_count[TGSI_FILE_OUTPUT];
+                                               ctx.info.file_max[TGSI_FILE_OUTPUT] + 1;
 
        /* Outside the GPR range. This will be translated to one of the
         * kcache banks later. */
@@ -662,7 +674,7 @@ static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_sh
 
        ctx.file_offset[TGSI_FILE_IMMEDIATE] = V_SQ_ALU_SRC_LITERAL;
        ctx.ar_reg = ctx.file_offset[TGSI_FILE_TEMPORARY] +
-                       ctx.info.file_count[TGSI_FILE_TEMPORARY];
+                       ctx.info.file_max[TGSI_FILE_TEMPORARY] + 1;
        ctx.temp_reg = ctx.ar_reg + 1;
 
        ctx.nliterals = 0;
@@ -702,9 +714,9 @@ static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_sh
                                goto out_err;
                        if ((r = tgsi_split_literal_constant(&ctx)))
                                goto out_err;
-                       if (ctx.bc->chiprev == CHIPREV_CAYMAN)
+                       if (ctx.bc->chip_class == CAYMAN)
                                ctx.inst_info = &cm_shader_tgsi_instruction[opcode];
-                       else if (ctx.bc->chiprev >= CHIPREV_EVERGREEN)
+                       else if (ctx.bc->chip_class >= EVERGREEN)
                                ctx.inst_info = &eg_shader_tgsi_instruction[opcode];
                        else
                                ctx.inst_info = &r600_shader_tgsi_instruction[opcode];
@@ -725,52 +737,103 @@ static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_sh
                        goto out_err;
                }
        }
-       /* export output */
+
        noutput = shader->noutput;
+
+       /* clamp color outputs */
+       if (shader->clamp_color) {
+               for (i = 0; i < noutput; i++) {
+                       if (shader->output[i].name == TGSI_SEMANTIC_COLOR ||
+                               shader->output[i].name == TGSI_SEMANTIC_BCOLOR) {
+
+                               int j;
+                               for (j = 0; j < 4; j++) {
+                                       struct r600_bc_alu alu;
+                                       memset(&alu, 0, sizeof(struct r600_bc_alu));
+
+                                       /* MOV_SAT R, R */
+                                       alu.inst = BC_INST(ctx.bc, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
+                                       alu.dst.sel = shader->output[i].gpr;
+                                       alu.dst.chan = j;
+                                       alu.dst.write = 1;
+                                       alu.dst.clamp = 1;
+                                       alu.src[0].sel = alu.dst.sel;
+                                       alu.src[0].chan = j;
+
+                                       if (j == 3) {
+                                               alu.last = 1;
+                                       }
+                                       r = r600_bc_add_alu(ctx.bc, &alu);
+                                       if (r)
+                                               return r;
+                               }
+                       }
+               }
+       }
+
+       /* export output */
+       j = 0;
        for (i = 0, pos0 = 0; i < noutput; i++) {
                memset(&output[i], 0, sizeof(struct r600_bc_output));
-               output[i].gpr = shader->output[i].gpr;
-               output[i].elem_size = 3;
-               output[i].swizzle_x = 0;
-               output[i].swizzle_y = 1;
-               output[i].swizzle_z = 2;
-               output[i].swizzle_w = 3;
-               output[i].burst_count = 1;
-               output[i].barrier = 1;
-               output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM;
-               output[i].array_base = i - pos0;
-               output[i].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
+               output[i + j].gpr = shader->output[i].gpr;
+               output[i + j].elem_size = 3;
+               output[i + j].swizzle_x = 0;
+               output[i + j].swizzle_y = 1;
+               output[i + j].swizzle_z = 2;
+               output[i + j].swizzle_w = 3;
+               output[i + j].burst_count = 1;
+               output[i + j].barrier = 1;
+               output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM;
+               output[i + j].array_base = i - pos0;
+               output[i + j].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
                switch (ctx.type) {
                case TGSI_PROCESSOR_VERTEX:
                        if (shader->output[i].name == TGSI_SEMANTIC_POSITION) {
-                               output[i].array_base = 60;
-                               output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
+                               output[i + j].array_base = 60;
+                               output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
                                /* position doesn't count in array_base */
                                pos0++;
                        }
                        if (shader->output[i].name == TGSI_SEMANTIC_PSIZE) {
-                               output[i].array_base = 61;
-                               output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
+                               output[i + j].array_base = 61;
+                               output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
                                /* position doesn't count in array_base */
                                pos0++;
                        }
                        break;
                case TGSI_PROCESSOR_FRAGMENT:
                        if (shader->output[i].name == TGSI_SEMANTIC_COLOR) {
-                               output[i].array_base = shader->output[i].sid;
-                               output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
+                               output[i + j].array_base = shader->output[i].sid;
+                               output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
+                               if (shader->fs_write_all && (rctx->chip_class >= EVERGREEN)) {
+                                       for (j = 1; j < shader->nr_cbufs; j++) {
+                                               memset(&output[i + j], 0, sizeof(struct r600_bc_output));
+                                               output[i + j].gpr = shader->output[i].gpr;
+                                               output[i + j].elem_size = 3;
+                                               output[i + j].swizzle_x = 0;
+                                               output[i + j].swizzle_y = 1;
+                                               output[i + j].swizzle_z = 2;
+                                               output[i + j].swizzle_w = 3;
+                                               output[i + j].burst_count = 1;
+                                               output[i + j].barrier = 1;
+                                               output[i + j].array_base = shader->output[i].sid + j;
+                                               output[i + j].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
+                                               output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
+                                       }
+                                       j--;
+                               }
                        } else if (shader->output[i].name == TGSI_SEMANTIC_POSITION) {
-                               output[i].array_base = 61;
-                               output[i].swizzle_x = 2;
-                               output[i].swizzle_y = 7;
-                               output[i].swizzle_z = output[i].swizzle_w = 7;
-                               output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
+                               output[i + j].array_base = 61;
+                               output[i + j].swizzle_x = 2;
+                               output[i + j].swizzle_y = 7;
+                               output[i + j].swizzle_z = output[i + j].swizzle_w = 7;
+                               output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
                        } else if (shader->output[i].name == TGSI_SEMANTIC_STENCIL) {
-                               output[i].array_base = 61;
-                               output[i].swizzle_x = 7;
-                               output[i].swizzle_y = 1;
-                               output[i].swizzle_z = output[i].swizzle_w = 7;
-                               output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
+                               output[i + j].array_base = 61;
+                               output[i + j].swizzle_x = 7;
+                               output[i + j].swizzle_y = 1;
+                               output[i + j].swizzle_z = output[i + j].swizzle_w = 7;
+                               output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
                        } else {
                                R600_ERR("unsupported fragment output name %d\n", shader->output[i].name);
                                r = -EINVAL;
@@ -783,6 +846,7 @@ static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_sh
                        goto out_err;
                }
        }
+       noutput += j;
        /* add fake param output for vertex shader if no param is exported */
        if (ctx.type == TGSI_PROCESSOR_VERTEX) {
                for (i = 0, pos0 = 0; i < noutput; i++) {
@@ -825,7 +889,7 @@ static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_sh
        }
        /* set export done on last export of each type */
        for (i = noutput - 1, output_done = 0; i >= 0; i--) {
-               if (ctx.bc->chiprev < CHIPREV_CAYMAN) {
+               if (ctx.bc->chip_class < CAYMAN) {
                        if (i == (noutput - 1)) {
                                output[i].end_of_program = 1;
                        }
@@ -842,7 +906,7 @@ static int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_sh
                        goto out_err;
        }
        /* add program end */
-       if (ctx.bc->chiprev == CHIPREV_CAYMAN)
+       if (ctx.bc->chip_class == CAYMAN)
                cm_bc_add_cf_end(ctx.bc);
 
        free(ctx.literals);
@@ -878,6 +942,17 @@ static void r600_bc_src(struct r600_bc_alu_src *bc_src,
        bc_src->value = shader_src->value[bc_src->chan];
 }
 
+static void r600_bc_src_set_abs(struct r600_bc_alu_src *bc_src)
+{
+       bc_src->abs = 1;
+       bc_src->neg = 0;
+}
+
+static void r600_bc_src_toggle_neg(struct r600_bc_alu_src *bc_src)
+{
+       bc_src->neg = !bc_src->neg;
+}
+
 static void tgsi_dst(struct r600_shader_ctx *ctx,
                     const struct tgsi_full_dst_register *tgsi_dst,
                     unsigned swizzle,
@@ -934,12 +1009,10 @@ static int tgsi_op2_s(struct r600_shader_ctx *ctx, int swap)
                /* handle some special cases */
                switch (ctx->inst_info->tgsi_opcode) {
                case TGSI_OPCODE_SUB:
-                       alu.src[1].neg = 1;
+                       r600_bc_src_toggle_neg(&alu.src[1]);
                        break;
                case TGSI_OPCODE_ABS:
-                       alu.src[0].abs = 1;
-                       if (alu.src[0].neg)
-                         alu.src[0].neg = 0;
+                       r600_bc_src_set_abs(&alu.src[0]);
                        break;
                default:
                        break;
@@ -1053,7 +1126,7 @@ static int tgsi_setup_trig(struct r600_shader_ctx *ctx)
        alu.src[2].sel = V_SQ_ALU_SRC_LITERAL;
        alu.src[2].chan = 0;
 
-       if (ctx->bc->chiprev == CHIPREV_R600) {
+       if (ctx->bc->chip_class == R600) {
                alu.src[1].value = *(uint32_t *)&double_pi;
                alu.src[2].value = *(uint32_t *)&neg_pi;
        } else {
@@ -1160,7 +1233,7 @@ static int tgsi_scs(struct r600_shader_ctx *ctx)
 
        /* dst.x = COS */
        if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) {
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0 ; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS);
@@ -1194,7 +1267,7 @@ static int tgsi_scs(struct r600_shader_ctx *ctx)
 
        /* dst.y = SIN */
        if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) {
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0 ; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN);
@@ -1303,36 +1376,17 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
        struct r600_bc_alu alu;
        int r;
 
-       /* dst.x, <- 1.0  */
-       memset(&alu, 0, sizeof(struct r600_bc_alu));
-       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
-       alu.src[0].sel  = V_SQ_ALU_SRC_1; /*1.0*/
-       alu.src[0].chan = 0;
-       tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
-       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 0) & 1;
-       r = r600_bc_add_alu(ctx->bc, &alu);
-       if (r)
-               return r;
-
-       /* dst.y = max(src.x, 0.0) */
+       /* tmp.x = max(src.y, 0.0) */
        memset(&alu, 0, sizeof(struct r600_bc_alu));
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX);
-       r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+       r600_bc_src(&alu.src[0], &ctx->src[0], 1);
        alu.src[1].sel  = V_SQ_ALU_SRC_0; /*0.0*/
-       alu.src[1].chan = 0;
-       tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);
-       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 1) & 1;
-       r = r600_bc_add_alu(ctx->bc, &alu);
-       if (r)
-               return r;
+       alu.src[1].chan = 1;
+
+       alu.dst.sel = ctx->temp_reg;
+       alu.dst.chan = 0;
+       alu.dst.write = 1;
 
-       /* dst.w, <- 1.0  */
-       memset(&alu, 0, sizeof(struct r600_bc_alu));
-       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
-       alu.src[0].sel  = V_SQ_ALU_SRC_1;
-       alu.src[0].chan = 0;
-       tgsi_dst(ctx, &inst->Dst[0], 3, &alu.dst);
-       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 3) & 1;
        alu.last = 1;
        r = r600_bc_add_alu(ctx->bc, &alu);
        if (r)
@@ -1344,13 +1398,15 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
                int sel;
                int i;
 
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
-                               /* dst.z = log(src.y) */
+                               /* tmp.z = log(tmp.x) */
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED);
-                               r600_bc_src(&alu.src[0], &ctx->src[0], 1);
-                               tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
+                               alu.src[0].sel = ctx->temp_reg;
+                               alu.src[0].chan = 0;
+                               alu.dst.sel = ctx->temp_reg;
+                               alu.dst.chan = i;
                                if (i == 2) {
                                        alu.dst.write = 1;
                                        alu.last = 1;
@@ -1362,11 +1418,14 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
                                        return r;
                        }
                } else {
-                       /* dst.z = log(src.y) */
+                       /* tmp.z = log(tmp.x) */
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED);
-                       r600_bc_src(&alu.src[0], &ctx->src[0], 1);
-                       tgsi_dst(ctx, &inst->Dst[0], 2, &alu.dst);
+                       alu.src[0].sel = ctx->temp_reg;
+                       alu.src[0].chan = 0;
+                       alu.dst.sel = ctx->temp_reg;
+                       alu.dst.chan = 2;
+                       alu.dst.write = 1;
                        alu.last = 1;
                        r = r600_bc_add_alu(ctx->bc, &alu);
                        if (r)
@@ -1376,13 +1435,12 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
                chan = alu.dst.chan;
                sel = alu.dst.sel;
 
-               /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
+               /* tmp.x = amd MUL_LIT(tmp.z, src.w, src.x ) */
                memset(&alu, 0, sizeof(struct r600_bc_alu));
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT);
-               r600_bc_src(&alu.src[0], &ctx->src[0], 3);
-               alu.src[1].sel  = sel;
-               alu.src[1].chan = chan;
-
+               alu.src[0].sel  = sel;
+               alu.src[0].chan = chan;
+               r600_bc_src(&alu.src[1], &ctx->src[0], 3);
                r600_bc_src(&alu.src[2], &ctx->src[0], 0);
                alu.dst.sel = ctx->temp_reg;
                alu.dst.chan = 0;
@@ -1393,7 +1451,7 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
                if (r)
                        return r;
 
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                /* dst.z = exp(tmp.x) */
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
@@ -1423,6 +1481,42 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
                                return r;
                }
        }
+
+       /* dst.x, <- 1.0  */
+       memset(&alu, 0, sizeof(struct r600_bc_alu));
+       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
+       alu.src[0].sel  = V_SQ_ALU_SRC_1; /*1.0*/
+       alu.src[0].chan = 0;
+       tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
+       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 0) & 1;
+       r = r600_bc_add_alu(ctx->bc, &alu);
+       if (r)
+               return r;
+
+       /* dst.y = max(src.x, 0.0) */
+       memset(&alu, 0, sizeof(struct r600_bc_alu));
+       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX);
+       r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+       alu.src[1].sel  = V_SQ_ALU_SRC_0; /*0.0*/
+       alu.src[1].chan = 0;
+       tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);
+       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 1) & 1;
+       r = r600_bc_add_alu(ctx->bc, &alu);
+       if (r)
+               return r;
+
+       /* dst.w, <- 1.0  */
+       memset(&alu, 0, sizeof(struct r600_bc_alu));
+       alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
+       alu.src[0].sel  = V_SQ_ALU_SRC_1;
+       alu.src[0].chan = 0;
+       tgsi_dst(ctx, &inst->Dst[0], 3, &alu.dst);
+       alu.dst.write = (inst->Dst[0].Register.WriteMask >> 3) & 1;
+       alu.last = 1;
+       r = r600_bc_add_alu(ctx->bc, &alu);
+       if (r)
+               return r;
+
        return 0;
 }
 
@@ -1442,7 +1536,7 @@ static int tgsi_rsq(struct r600_shader_ctx *ctx)
 
        for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
                r600_bc_src(&alu.src[i], &ctx->src[i], 0);
-               alu.src[i].abs = 1;
+               r600_bc_src_set_abs(&alu.src[i]);
        }
        alu.dst.sel = ctx->temp_reg;
        alu.dst.write = 1;
@@ -1834,7 +1928,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
        } else if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) {
                int out_chan;
                /* Add perspective divide */
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        out_chan = 2;
                        for (i = 0; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
@@ -1916,7 +2010,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
                }
 
                /* tmp1.z = RCP_e(|tmp1.z|) */
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE);
@@ -2128,7 +2222,7 @@ static int tgsi_lrp(struct r600_shader_ctx *ctx)
                alu.src[0].sel = V_SQ_ALU_SRC_1;
                alu.src[0].chan = 0;
                r600_bc_src(&alu.src[1], &ctx->src[0], i);
-               alu.src[1].neg = 1;
+               r600_bc_src_toggle_neg(&alu.src[1]);
                alu.dst.sel = ctx->temp_reg;
                alu.dst.chan = i;
                if (i == lasti) {
@@ -2309,7 +2403,7 @@ static int tgsi_exp(struct r600_shader_ctx *ctx)
                if (r)
                        return r;
 
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
                                alu.src[0].sel = ctx->temp_reg;
@@ -2365,7 +2459,7 @@ static int tgsi_exp(struct r600_shader_ctx *ctx)
 
        /* result.z = RoughApprox2ToX(tmp);*/
        if ((inst->Dst[0].Register.WriteMask >> 2) & 0x1) {
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
@@ -2425,14 +2519,15 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
        int r;
        int i;
 
-       /* result.x = floor(log2(src)); */
+       /* result.x = floor(log2(|src|)); */
        if (inst->Dst[0].Register.WriteMask & 1) {
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
                                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+                               r600_bc_src_set_abs(&alu.src[0]);
                        
                                alu.dst.sel = ctx->temp_reg;
                                alu.dst.chan = i;
@@ -2450,6 +2545,7 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
 
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
                        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+                       r600_bc_src_set_abs(&alu.src[0]);
                        
                        alu.dst.sel = ctx->temp_reg;
                        alu.dst.chan = 0;
@@ -2474,15 +2570,16 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
                        return r;
        }
 
-       /* result.y = src.x / (2 ^ floor(log2(src.x))); */
+       /* result.y = |src.x| / (2 ^ floor(log2(|src.x|))); */
        if ((inst->Dst[0].Register.WriteMask >> 1) & 1) {
 
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
                                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+                               r600_bc_src_set_abs(&alu.src[0]);
 
                                alu.dst.sel = ctx->temp_reg;
                                alu.dst.chan = i;
@@ -2500,6 +2597,7 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
 
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
                        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+                       r600_bc_src_set_abs(&alu.src[0]);
 
                        alu.dst.sel = ctx->temp_reg;
                        alu.dst.chan = 1;
@@ -2526,7 +2624,7 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
                if (r)
                        return r;
 
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
@@ -2560,7 +2658,7 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
                                return r;
                }
 
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE);
@@ -2599,6 +2697,7 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
 
                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+               r600_bc_src_set_abs(&alu.src[0]);
 
                alu.src[1].sel = ctx->temp_reg;
                alu.src[1].chan = 1;
@@ -2613,14 +2712,15 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
                        return r;
        }
 
-       /* result.z = log2(src);*/
+       /* result.z = log2(|src|);*/
        if ((inst->Dst[0].Register.WriteMask >> 2) & 1) {
-               if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
+               if (ctx->bc->chip_class == CAYMAN) {
                        for (i = 0; i < 3; i++) {
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
                                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+                               r600_bc_src_set_abs(&alu.src[0]);
 
                                alu.dst.sel = ctx->temp_reg;
                                if (i == 2)
@@ -2638,6 +2738,7 @@ static int tgsi_log(struct r600_shader_ctx *ctx)
 
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
                        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
+                       r600_bc_src_set_abs(&alu.src[0]);
 
                        alu.dst.sel = ctx->temp_reg;
                        alu.dst.write = 1;
@@ -2831,25 +2932,34 @@ static int emit_logic_pred(struct r600_shader_ctx *ctx, int opcode)
 
 static int pops(struct r600_shader_ctx *ctx, int pops)
 {
-       int alu_pop = 3;
-       if (ctx->bc->cf_last) {
-               if (ctx->bc->cf_last->inst == CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU) << 3)
-                       alu_pop = 0;
-               else if (ctx->bc->cf_last->inst == CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER) << 3)
-                       alu_pop = 1;
-       }
-       alu_pop += pops;
-       if (alu_pop == 1) {
-               ctx->bc->cf_last->inst = CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER) << 3;
-               ctx->bc->force_add_cf = 1;
-       } else if (alu_pop == 2) {
-               ctx->bc->cf_last->inst = CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER) << 3;
-               ctx->bc->force_add_cf = 1;
-       } else {
+       unsigned force_pop = ctx->bc->force_add_cf;
+
+       if (!force_pop) {
+               int alu_pop = 3;
+               if (ctx->bc->cf_last) {
+                       if (ctx->bc->cf_last->inst == CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU) << 3)
+                               alu_pop = 0;
+                       else if (ctx->bc->cf_last->inst == CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER) << 3)
+                               alu_pop = 1;
+               }
+               alu_pop += pops;
+               if (alu_pop == 1) {
+                       ctx->bc->cf_last->inst = CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER) << 3;
+                       ctx->bc->force_add_cf = 1;
+               } else if (alu_pop == 2) {
+                       ctx->bc->cf_last->inst = CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER) << 3;
+                       ctx->bc->force_add_cf = 1;
+               } else {
+                       force_pop = 1;
+               }
+       }
+
+       if (force_pop) {
                r600_bc_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP));
                ctx->bc->cf_last->pop_count = pops;
                ctx->bc->cf_last->cf_addr = ctx->bc->cf_last->id + 2;
        }
+
        return 0;
 }
 
@@ -3266,7 +3376,7 @@ static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_MOV,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV, tgsi_op2},
        {TGSI_OPCODE_LIT,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_lit},
        {TGSI_OPCODE_RCP,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE, tgsi_trans_srcx_replicate},
-       {TGSI_OPCODE_RSQ,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE, tgsi_trans_srcx_replicate},
+       {TGSI_OPCODE_RSQ,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE, tgsi_rsq},
        {TGSI_OPCODE_EXP,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_exp},
        {TGSI_OPCODE_LOG,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_log},
        {TGSI_OPCODE_MUL,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL, tgsi_op2},
index 8f96ce5..600c3e2 100644 (file)
@@ -40,12 +40,14 @@ struct r600_shader {
        struct r600_bc          bc;
        unsigned                ninput;
        unsigned                noutput;
+       unsigned                npos;
        unsigned                nlds;
        struct r600_shader_io   input[32];
        struct r600_shader_io   output[32];
-       enum radeon_family      family;
        boolean                 uses_kill;
        boolean                 fs_write_all;
+       boolean                 clamp_color;
+       unsigned                nr_cbufs;
 };
 
 #endif
index d927e4a..487b1df 100644 (file)
 #include "r600_resource.h"
 #include "r600_shader.h"
 #include "r600_pipe.h"
-#include "r600_state_inlines.h"
+#include "r600_formats.h"
+
+static uint32_t r600_translate_blend_function(int blend_func)
+{
+       switch (blend_func) {
+       case PIPE_BLEND_ADD:
+               return V_028804_COMB_DST_PLUS_SRC;
+       case PIPE_BLEND_SUBTRACT:
+               return V_028804_COMB_SRC_MINUS_DST;
+       case PIPE_BLEND_REVERSE_SUBTRACT:
+               return V_028804_COMB_DST_MINUS_SRC;
+       case PIPE_BLEND_MIN:
+               return V_028804_COMB_MIN_DST_SRC;
+       case PIPE_BLEND_MAX:
+               return V_028804_COMB_MAX_DST_SRC;
+       default:
+               R600_ERR("Unknown blend function %d\n", blend_func);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_blend_factor(int blend_fact)
+{
+       switch (blend_fact) {
+       case PIPE_BLENDFACTOR_ONE:
+               return V_028804_BLEND_ONE;
+       case PIPE_BLENDFACTOR_SRC_COLOR:
+               return V_028804_BLEND_SRC_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA:
+               return V_028804_BLEND_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_DST_ALPHA:
+               return V_028804_BLEND_DST_ALPHA;
+       case PIPE_BLENDFACTOR_DST_COLOR:
+               return V_028804_BLEND_DST_COLOR;
+       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
+               return V_028804_BLEND_SRC_ALPHA_SATURATE;
+       case PIPE_BLENDFACTOR_CONST_COLOR:
+               return V_028804_BLEND_CONST_COLOR;
+       case PIPE_BLENDFACTOR_CONST_ALPHA:
+               return V_028804_BLEND_CONST_ALPHA;
+       case PIPE_BLENDFACTOR_ZERO:
+               return V_028804_BLEND_ZERO;
+       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+               return V_028804_BLEND_ONE_MINUS_SRC_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
+               return V_028804_BLEND_ONE_MINUS_SRC_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+               return V_028804_BLEND_ONE_MINUS_DST_ALPHA;
+       case PIPE_BLENDFACTOR_INV_DST_COLOR:
+               return V_028804_BLEND_ONE_MINUS_DST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+               return V_028804_BLEND_ONE_MINUS_CONST_COLOR;
+       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+               return V_028804_BLEND_ONE_MINUS_CONST_ALPHA;
+       case PIPE_BLENDFACTOR_SRC1_COLOR:
+               return V_028804_BLEND_SRC1_COLOR;
+       case PIPE_BLENDFACTOR_SRC1_ALPHA:
+               return V_028804_BLEND_SRC1_ALPHA;
+       case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+               return V_028804_BLEND_INV_SRC1_COLOR;
+       case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
+               return V_028804_BLEND_INV_SRC1_ALPHA;
+       default:
+               R600_ERR("Bad blend factor %d not supported!\n", blend_fact);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_stencil_op(int s_op)
+{
+       switch (s_op) {
+       case PIPE_STENCIL_OP_KEEP:
+               return V_028800_STENCIL_KEEP;
+       case PIPE_STENCIL_OP_ZERO:
+               return V_028800_STENCIL_ZERO;
+       case PIPE_STENCIL_OP_REPLACE:
+               return V_028800_STENCIL_REPLACE;
+       case PIPE_STENCIL_OP_INCR:
+               return V_028800_STENCIL_INCR;
+       case PIPE_STENCIL_OP_DECR:
+               return V_028800_STENCIL_DECR;
+       case PIPE_STENCIL_OP_INCR_WRAP:
+               return V_028800_STENCIL_INCR_WRAP;
+       case PIPE_STENCIL_OP_DECR_WRAP:
+               return V_028800_STENCIL_DECR_WRAP;
+       case PIPE_STENCIL_OP_INVERT:
+               return V_028800_STENCIL_INVERT;
+       default:
+               R600_ERR("Unknown stencil op %d", s_op);
+               assert(0);
+               break;
+       }
+       return 0;
+}
+
+static uint32_t r600_translate_fill(uint32_t func)
+{
+       switch(func) {
+       case PIPE_POLYGON_MODE_FILL:
+               return 2;
+       case PIPE_POLYGON_MODE_LINE:
+               return 1;
+       case PIPE_POLYGON_MODE_POINT:
+               return 0;
+       default:
+               assert(0);
+               return 0;
+       }
+}
+
+/* translates straight */
+static uint32_t r600_translate_ds_func(int func)
+{
+       return func;
+}
+
+static unsigned r600_tex_wrap(unsigned wrap)
+{
+       switch (wrap) {
+       default:
+       case PIPE_TEX_WRAP_REPEAT:
+               return V_03C000_SQ_TEX_WRAP;
+       case PIPE_TEX_WRAP_CLAMP:
+               return V_03C000_SQ_TEX_CLAMP_HALF_BORDER;
+       case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
+               return V_03C000_SQ_TEX_CLAMP_LAST_TEXEL;
+       case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
+               return V_03C000_SQ_TEX_CLAMP_BORDER;
+       case PIPE_TEX_WRAP_MIRROR_REPEAT:
+               return V_03C000_SQ_TEX_MIRROR;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
+       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
+               return V_03C000_SQ_TEX_MIRROR_ONCE_BORDER;
+       }
+}
+
+static unsigned r600_tex_filter(unsigned filter)
+{
+       switch (filter) {
+       default:
+       case PIPE_TEX_FILTER_NEAREST:
+               return V_03C000_SQ_TEX_XY_FILTER_POINT;
+       case PIPE_TEX_FILTER_LINEAR:
+               return V_03C000_SQ_TEX_XY_FILTER_BILINEAR;
+       }
+}
+
+static unsigned r600_tex_mipfilter(unsigned filter)
+{
+       switch (filter) {
+       case PIPE_TEX_MIPFILTER_NEAREST:
+               return V_03C000_SQ_TEX_Z_FILTER_POINT;
+       case PIPE_TEX_MIPFILTER_LINEAR:
+               return V_03C000_SQ_TEX_Z_FILTER_LINEAR;
+       default:
+       case PIPE_TEX_MIPFILTER_NONE:
+               return V_03C000_SQ_TEX_Z_FILTER_NONE;
+       }
+}
+
+static unsigned r600_tex_compare(unsigned compare)
+{
+       switch (compare) {
+       default:
+       case PIPE_FUNC_NEVER:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER;
+       case PIPE_FUNC_LESS:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESS;
+       case PIPE_FUNC_EQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_EQUAL;
+       case PIPE_FUNC_LEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
+       case PIPE_FUNC_GREATER:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATER;
+       case PIPE_FUNC_NOTEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
+       case PIPE_FUNC_GEQUAL:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
+       case PIPE_FUNC_ALWAYS:
+               return V_03C000_SQ_TEX_DEPTH_COMPARE_ALWAYS;
+       }
+}
+
+static unsigned r600_tex_dim(unsigned dim)
+{
+       switch (dim) {
+       default:
+       case PIPE_TEXTURE_1D:
+               return V_038000_SQ_TEX_DIM_1D;
+       case PIPE_TEXTURE_1D_ARRAY:
+               return V_038000_SQ_TEX_DIM_1D_ARRAY;
+       case PIPE_TEXTURE_2D:
+       case PIPE_TEXTURE_RECT:
+               return V_038000_SQ_TEX_DIM_2D;
+       case PIPE_TEXTURE_2D_ARRAY:
+               return V_038000_SQ_TEX_DIM_2D_ARRAY;
+       case PIPE_TEXTURE_3D:
+               return V_038000_SQ_TEX_DIM_3D;
+       case PIPE_TEXTURE_CUBE:
+               return V_038000_SQ_TEX_DIM_CUBEMAP;
+       }
+}
+
+static uint32_t r600_translate_dbformat(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028010_DEPTH_16;
+       case PIPE_FORMAT_Z24X8_UNORM:
+               return V_028010_DEPTH_X8_24;
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028010_DEPTH_8_24;
+       case PIPE_FORMAT_Z32_FLOAT:
+               return V_028010_DEPTH_32_FLOAT;
+       case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+               return V_028010_DEPTH_X24_8_32_FLOAT;
+       default:
+               return ~0U;
+       }
+}
+
+static uint32_t r600_translate_colorswap(enum pipe_format format)
+{
+       switch (format) {
+       /* 8-bit buffers. */
+       case PIPE_FORMAT_A8_UNORM:
+               return V_0280A0_SWAP_ALT_REV;
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_SRGB:
+       case PIPE_FORMAT_R8_UNORM:
+       case PIPE_FORMAT_R8_SNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_L4A4_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       /* 16-bit buffers. */
+       case PIPE_FORMAT_B5G6R5_UNORM:
+               return V_0280A0_SWAP_STD_REV;
+
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+       case PIPE_FORMAT_B5G5R5X1_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+       case PIPE_FORMAT_B4G4R4X4_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_SRGB:
+               return V_0280A0_SWAP_ALT;
+       case PIPE_FORMAT_R8G8_UNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_R16_UNORM:
+       case PIPE_FORMAT_R16_FLOAT:
+               return V_0280A0_SWAP_STD;
+
+       /* 32-bit buffers. */
+
+       case PIPE_FORMAT_A8B8G8R8_SRGB:
+               return V_0280A0_SWAP_STD_REV;
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_B8G8R8A8_UNORM:
+       case PIPE_FORMAT_B8G8R8X8_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+               return V_0280A0_SWAP_ALT_REV;
+       case PIPE_FORMAT_R8G8B8A8_SNORM:
+       case PIPE_FORMAT_R8G8B8A8_UNORM:
+       case PIPE_FORMAT_R8G8B8X8_UNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_A8B8G8R8_UNORM:
+       case PIPE_FORMAT_X8B8G8R8_UNORM:
+       /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
+               return V_0280A0_SWAP_STD_REV;
+
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_X8Z24_UNORM:
+       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_R10G10B10A2_UNORM:
+       case PIPE_FORMAT_R10G10B10X2_SNORM:
+       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
+               return V_0280A0_SWAP_STD;
+
+       case PIPE_FORMAT_B10G10R10A2_UNORM:
+               return V_0280A0_SWAP_ALT;
+
+       case PIPE_FORMAT_R11G11B10_FLOAT:
+       case PIPE_FORMAT_R16G16_UNORM:
+       case PIPE_FORMAT_R16G16_FLOAT:
+       case PIPE_FORMAT_R32_FLOAT:
+       case PIPE_FORMAT_Z32_FLOAT:
+               return V_0280A0_SWAP_STD;
+
+       /* 64-bit buffers. */
+       case PIPE_FORMAT_R32G32_FLOAT:
+       case PIPE_FORMAT_R16G16B16A16_UNORM:
+       case PIPE_FORMAT_R16G16B16A16_SNORM:
+       case PIPE_FORMAT_R16G16B16A16_FLOAT:
+       case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+
+       /* 128-bit buffers. */
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+       case PIPE_FORMAT_R32G32B32A32_SNORM:
+       case PIPE_FORMAT_R32G32B32A32_UNORM:
+               return V_0280A0_SWAP_STD;
+       default:
+               R600_ERR("unsupported colorswap format %d\n", format);
+               return ~0U;
+       }
+       return ~0U;
+}
+
+static uint32_t r600_translate_colorformat(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_L4A4_UNORM:
+               return V_0280A0_COLOR_4_4;
+
+       /* 8-bit buffers. */
+       case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_SRGB:
+       case PIPE_FORMAT_R8_UNORM:
+       case PIPE_FORMAT_R8_SNORM:
+               return V_0280A0_COLOR_8;
+
+       /* 16-bit buffers. */
+       case PIPE_FORMAT_B5G6R5_UNORM:
+               return V_0280A0_COLOR_5_6_5;
+
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+       case PIPE_FORMAT_B5G5R5X1_UNORM:
+               return V_0280A0_COLOR_1_5_5_5;
+
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+       case PIPE_FORMAT_B4G4R4X4_UNORM:
+               return V_0280A0_COLOR_4_4_4_4;
+
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_0280A0_COLOR_16;
+
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_SRGB:
+       case PIPE_FORMAT_R8G8_UNORM:
+               return V_0280A0_COLOR_8_8;
+
+       case PIPE_FORMAT_R16_UNORM:
+               return V_0280A0_COLOR_16;
+
+       case PIPE_FORMAT_R16_FLOAT:
+               return V_0280A0_COLOR_16_FLOAT;
+
+       /* 32-bit buffers. */
+       case PIPE_FORMAT_A8B8G8R8_SRGB:
+       case PIPE_FORMAT_A8B8G8R8_UNORM:
+       case PIPE_FORMAT_A8R8G8B8_UNORM:
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+       case PIPE_FORMAT_B8G8R8A8_UNORM:
+       case PIPE_FORMAT_B8G8R8X8_UNORM:
+       case PIPE_FORMAT_R8G8B8A8_SNORM:
+       case PIPE_FORMAT_R8G8B8A8_UNORM:
+       case PIPE_FORMAT_R8G8B8X8_UNORM:
+       case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
+       case PIPE_FORMAT_X8B8G8R8_UNORM:
+       case PIPE_FORMAT_X8R8G8B8_UNORM:
+       case PIPE_FORMAT_R8G8B8_UNORM:
+               return V_0280A0_COLOR_8_8_8_8;
+
+       case PIPE_FORMAT_R10G10B10A2_UNORM:
+       case PIPE_FORMAT_R10G10B10X2_SNORM:
+       case PIPE_FORMAT_B10G10R10A2_UNORM:
+       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
+               return V_0280A0_COLOR_2_10_10_10;
+
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_0280A0_COLOR_8_24;
+
+       case PIPE_FORMAT_X8Z24_UNORM:
+       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               return V_0280A0_COLOR_24_8;
+
+       case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+               return V_0280A0_COLOR_X24_8_32_FLOAT;
+
+       case PIPE_FORMAT_R32_FLOAT:
+       case PIPE_FORMAT_Z32_FLOAT:
+               return V_0280A0_COLOR_32_FLOAT;
+
+       case PIPE_FORMAT_R16G16_FLOAT:
+               return V_0280A0_COLOR_16_16_FLOAT;
+
+       case PIPE_FORMAT_R16G16_SSCALED:
+       case PIPE_FORMAT_R16G16_UNORM:
+               return V_0280A0_COLOR_16_16;
+
+       case PIPE_FORMAT_R11G11B10_FLOAT:
+               return V_0280A0_COLOR_10_11_11_FLOAT;
+
+       /* 64-bit buffers. */
+       case PIPE_FORMAT_R16G16B16_USCALED:
+       case PIPE_FORMAT_R16G16B16A16_USCALED:
+       case PIPE_FORMAT_R16G16B16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_UNORM:
+       case PIPE_FORMAT_R16G16B16A16_SNORM:
+               return V_0280A0_COLOR_16_16_16_16;
+
+       case PIPE_FORMAT_R16G16B16_FLOAT:
+       case PIPE_FORMAT_R16G16B16A16_FLOAT:
+               return V_0280A0_COLOR_16_16_16_16_FLOAT;
+
+       case PIPE_FORMAT_R32G32_FLOAT:
+               return V_0280A0_COLOR_32_32_FLOAT;
+
+       case PIPE_FORMAT_R32G32_USCALED:
+       case PIPE_FORMAT_R32G32_SSCALED:
+               return V_0280A0_COLOR_32_32;
+
+       /* 96-bit buffers. */
+       case PIPE_FORMAT_R32G32B32_FLOAT:
+               return V_0280A0_COLOR_32_32_32_FLOAT;
+
+       /* 128-bit buffers. */
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+               return V_0280A0_COLOR_32_32_32_32_FLOAT;
+       case PIPE_FORMAT_R32G32B32A32_SNORM:
+       case PIPE_FORMAT_R32G32B32A32_UNORM:
+               return V_0280A0_COLOR_32_32_32_32;
+
+       /* YUV buffers. */
+       case PIPE_FORMAT_UYVY:
+       case PIPE_FORMAT_YUYV:
+       default:
+               return ~0U; /* Unsupported. */
+       }
+}
+
+static uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
+{
+       if (R600_BIG_ENDIAN) {
+               switch(colorformat) {
+               case V_0280A0_COLOR_4_4:
+                       return ENDIAN_NONE;
+
+               /* 8-bit buffers. */
+               case V_0280A0_COLOR_8:
+                       return ENDIAN_NONE;
+
+               /* 16-bit buffers. */
+               case V_0280A0_COLOR_5_6_5:
+               case V_0280A0_COLOR_1_5_5_5:
+               case V_0280A0_COLOR_4_4_4_4:
+               case V_0280A0_COLOR_16:
+               case V_0280A0_COLOR_8_8:
+                       return ENDIAN_8IN16;
+
+               /* 32-bit buffers. */
+               case V_0280A0_COLOR_8_8_8_8:
+               case V_0280A0_COLOR_2_10_10_10:
+               case V_0280A0_COLOR_8_24:
+               case V_0280A0_COLOR_24_8:
+               case V_0280A0_COLOR_32_FLOAT:
+               case V_0280A0_COLOR_16_16_FLOAT:
+               case V_0280A0_COLOR_16_16:
+                       return ENDIAN_8IN32;
+
+               /* 64-bit buffers. */
+               case V_0280A0_COLOR_16_16_16_16:
+               case V_0280A0_COLOR_16_16_16_16_FLOAT:
+                       return ENDIAN_8IN16;
+
+               case V_0280A0_COLOR_32_32_FLOAT:
+               case V_0280A0_COLOR_32_32:
+               case V_0280A0_COLOR_X24_8_32_FLOAT:
+                       return ENDIAN_8IN32;
+
+               /* 128-bit buffers. */
+               case V_0280A0_COLOR_32_32_32_FLOAT:
+               case V_0280A0_COLOR_32_32_32_32_FLOAT:
+               case V_0280A0_COLOR_32_32_32_32:
+                       return ENDIAN_8IN32;
+               default:
+                       return ENDIAN_NONE; /* Unsupported. */
+               }
+       } else {
+               return ENDIAN_NONE;
+       }
+}
+
+static bool r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
+{
+       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0U;
+}
+
+static bool r600_is_colorbuffer_format_supported(enum pipe_format format)
+{
+       return r600_translate_colorformat(format) != ~0U &&
+              r600_translate_colorswap(format) != ~0U;
+}
+
+static bool r600_is_zs_format_supported(enum pipe_format format)
+{
+       return r600_translate_dbformat(format) != ~0U;
+}
+
+boolean r600_is_format_supported(struct pipe_screen *screen,
+                                enum pipe_format format,
+                                enum pipe_texture_target target,
+                                unsigned sample_count,
+                                unsigned usage)
+{
+       unsigned retval = 0;
+
+       if (target >= PIPE_MAX_TEXTURE_TYPES) {
+               R600_ERR("r600: unsupported texture type %d\n", target);
+               return FALSE;
+       }
+
+       if (!util_format_is_supported(format, usage))
+               return FALSE;
+
+       /* Multisample */
+       if (sample_count > 1)
+               return FALSE;
+
+       if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
+           r600_is_sampler_format_supported(screen, format)) {
+               retval |= PIPE_BIND_SAMPLER_VIEW;
+       }
+
+       if ((usage & (PIPE_BIND_RENDER_TARGET |
+                     PIPE_BIND_DISPLAY_TARGET |
+                     PIPE_BIND_SCANOUT |
+                     PIPE_BIND_SHARED)) &&
+           r600_is_colorbuffer_format_supported(format)) {
+               retval |= usage &
+                         (PIPE_BIND_RENDER_TARGET |
+                          PIPE_BIND_DISPLAY_TARGET |
+                          PIPE_BIND_SCANOUT |
+                          PIPE_BIND_SHARED);
+       }
+
+       if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
+           r600_is_zs_format_supported(format)) {
+               retval |= PIPE_BIND_DEPTH_STENCIL;
+       }
+
+       if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
+           r600_is_vertex_format_supported(format)) {
+               retval |= PIPE_BIND_VERTEX_BUFFER;
+       }
+
+       if (usage & PIPE_BIND_TRANSFER_READ)
+               retval |= PIPE_BIND_TRANSFER_READ;
+       if (usage & PIPE_BIND_TRANSFER_WRITE)
+               retval |= PIPE_BIND_TRANSFER_WRITE;
+
+       return retval == usage;
+}
 
 void r600_polygon_offset_update(struct r600_pipe_context *rctx)
 {
@@ -63,6 +646,7 @@ void r600_polygon_offset_update(struct r600_pipe_context *rctx)
                        offset_units *= 2.0f;
                        break;
                case PIPE_FORMAT_Z32_FLOAT:
+               case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
                        depth = -23;
                        offset_units *= 1.0f;
                        offset_db_fmt_cntl |= S_028DF8_POLY_OFFSET_DB_IS_FLOAT_FMT(1);
@@ -299,6 +883,8 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
        }
 
        rstate = &rs->rstate;
+       rs->clamp_vertex_color = state->clamp_vertex_color;
+       rs->clamp_fragment_color = state->clamp_fragment_color;
        rs->flatshade = state->flatshade;
        rs->sprite_coord_enable = state->sprite_coord_enable;
 
@@ -369,14 +955,17 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
 static void *r600_create_sampler_state(struct pipe_context *ctx,
                                        const struct pipe_sampler_state *state)
 {
-       struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
+       struct r600_pipe_sampler_state *ss = CALLOC_STRUCT(r600_pipe_sampler_state);
+       struct r600_pipe_state *rstate;
        union util_color uc;
        unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 4 : 0;
 
-       if (rstate == NULL) {
+       if (ss == NULL) {
                return NULL;
        }
 
+       ss->seamless_cube_map = state->seamless_cube_map;
+       rstate = &ss->rstate;
        rstate->id = R600_PIPE_STATE_SAMPLER;
        util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
        r600_pipe_state_add_reg_noblock(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
@@ -488,8 +1077,8 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
        rstate->val[1] = (S_038004_TEX_HEIGHT(height - 1) |
                          S_038004_TEX_DEPTH(depth - 1) |
                          S_038004_DATA_FORMAT(format));
-       rstate->val[2] = (tmp->offset[offset_level] + r600_bo_offset(bo[0])) >> 8;
-       rstate->val[3] = (tmp->offset[offset_level+1] + r600_bo_offset(bo[1])) >> 8;
+       rstate->val[2] = tmp->offset[offset_level] >> 8;
+       rstate->val[3] = tmp->offset[offset_level+1] >> 8;
        rstate->val[4] = (word4 |
                          S_038010_SRF_MODE_ALL(V_038010_SRF_MODE_ZERO_CLAMP_MINUS_ONE) |
                          S_038010_REQUEST_SIZE(1) |
@@ -559,27 +1148,57 @@ static void r600_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
        rctx->ps_samplers.n_views = count;
 }
 
+static void r600_set_seamless_cubemap(struct r600_pipe_context *rctx, boolean enable)
+{
+       struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
+       if (rstate == NULL)
+               return;
+
+       rstate->id = R600_PIPE_STATE_SEAMLESS_CUBEMAP;
+       r600_pipe_state_add_reg(rstate, R_009508_TA_CNTL_AUX,
+                               (enable ? 0 : S_009508_DISABLE_CUBE_WRAP(1)),
+                               1, NULL);
+
+       free(rctx->states[R600_PIPE_STATE_SEAMLESS_CUBEMAP]);
+       rctx->states[R600_PIPE_STATE_SEAMLESS_CUBEMAP] = rstate;
+       r600_context_pipe_state_set(&rctx->ctx, rstate);
+}
+
 static void r600_bind_ps_sampler(struct pipe_context *ctx, unsigned count, void **states)
 {
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
-       struct r600_pipe_state **rstates = (struct r600_pipe_state **)states;
+       struct r600_pipe_sampler_state **sstates = (struct r600_pipe_sampler_state **)states;
+       int seamless = -1;
 
        memcpy(rctx->ps_samplers.samplers, states, sizeof(void*) * count);
        rctx->ps_samplers.n_samplers = count;
 
        for (int i = 0; i < count; i++) {
-               r600_context_pipe_state_set_ps_sampler(&rctx->ctx, rstates[i], i);
+               r600_context_pipe_state_set_ps_sampler(&rctx->ctx, &sstates[i]->rstate, i);
+
+               if (sstates[i])
+                       seamless = sstates[i]->seamless_cube_map;
        }
+
+       if (seamless != -1)
+               r600_set_seamless_cubemap(rctx, seamless);
 }
 
 static void r600_bind_vs_sampler(struct pipe_context *ctx, unsigned count, void **states)
 {
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
-       struct r600_pipe_state **rstates = (struct r600_pipe_state **)states;
+       struct r600_pipe_sampler_state **sstates = (struct r600_pipe_sampler_state **)states;
+       int seamless = -1;
 
        for (int i = 0; i < count; i++) {
-               r600_context_pipe_state_set_vs_sampler(&rctx->ctx, rstates[i], i);
+               r600_context_pipe_state_set_vs_sampler(&rctx->ctx, &sstates[i]->rstate, i);
+
+               if (sstates[i])
+                       seamless = sstates[i]->seamless_cube_map;
        }
+
+       if (seamless != -1)
+               r600_set_seamless_cubemap(rctx, seamless);
 }
 
 static void r600_set_clip_state(struct pipe_context *ctx,
@@ -792,7 +1411,7 @@ static void r600_cb(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
        /* EXPORT_NORM is an optimzation that can be enabled for better
         * performance in certain cases
         */
-       if (rctx->family < CHIP_RV770) {
+       if (rctx->chip_class == R600) {
                /* EXPORT_NORM can be enabled if:
                 * - 11-bit or smaller UNORM/SNORM/SRGB
                 * - BLEND_CLAMP is enabled
@@ -822,7 +1441,7 @@ static void r600_cb(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
 
        r600_pipe_state_add_reg(rstate,
                                R_028040_CB_COLOR0_BASE + cb * 4,
-                               (offset + r600_bo_offset(bo[0])) >> 8, 0xFFFFFFFF, bo[0]);
+                               offset >> 8, 0xFFFFFFFF, bo[0]);
        r600_pipe_state_add_reg(rstate,
                                R_0280A0_CB_COLOR0_INFO + cb * 4,
                                color_info, 0xFFFFFFFF, bo[0]);
@@ -836,10 +1455,10 @@ static void r600_cb(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
                                0x00000000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                                R_0280E0_CB_COLOR0_FRAG + cb * 4,
-                               r600_bo_offset(bo[1]) >> 8, 0xFFFFFFFF, bo[1]);
+                               0, 0xFFFFFFFF, bo[1]);
        r600_pipe_state_add_reg(rstate,
                                R_0280C0_CB_COLOR0_TILE + cb * 4,
-                               r600_bo_offset(bo[2]) >> 8, 0xFFFFFFFF, bo[2]);
+                               0, 0xFFFFFFFF, bo[2]);
        r600_pipe_state_add_reg(rstate,
                                R_028100_CB_COLOR0_MASK + cb * 4,
                                0x00000000, 0xFFFFFFFF, NULL);
@@ -873,7 +1492,7 @@ static void r600_db(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
        format = r600_translate_dbformat(state->zsbuf->texture->format);
 
        r600_pipe_state_add_reg(rstate, R_02800C_DB_DEPTH_BASE,
-                               (offset + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
+                               offset >> 8, 0xFFFFFFFF, rbuffer->bo);
        r600_pipe_state_add_reg(rstate, R_028000_DB_DEPTH_SIZE,
                                S_028000_PITCH_TILE_MAX(pitch) | S_028000_SLICE_TILE_MAX(slice),
                                0xFFFFFFFF, NULL);
@@ -952,7 +1571,7 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate,
                                R_028200_PA_SC_WINDOW_OFFSET, 0x00000000,
                                0xFFFFFFFF, NULL);
-       if (rctx->family >= CHIP_RV770) {
+       if (rctx->chip_class >= R700) {
                r600_pipe_state_add_reg(rstate,
                                        R_028230_PA_SC_EDGERULE, 0xAAAAAAAA,
                                        0xFFFFFFFF, NULL);
@@ -1046,16 +1665,13 @@ void r600_init_state_functions(struct r600_pipe_context *rctx)
 
 void r600_adjust_gprs(struct r600_pipe_context *rctx)
 {
-       enum radeon_family family;
        struct r600_pipe_state rstate;
        unsigned num_ps_gprs = rctx->default_ps_gprs;
        unsigned num_vs_gprs = rctx->default_vs_gprs;
        unsigned tmp;
        int diff;
 
-       family = r600_get_family(rctx->radeon);
-
-       if (family >= CHIP_CEDAR)
+       if (rctx->chip_class >= EVERGREEN)
                return;
 
        if (!rctx->ps_shader && !rctx->vs_shader)
@@ -1107,7 +1723,7 @@ void r600_init_config(struct r600_pipe_context *rctx)
        struct r600_pipe_state *rstate = &rctx->config;
        u32 tmp;
 
-       family = r600_get_family(rctx->radeon);
+       family = rctx->family;
        ps_prio = 0;
        vs_prio = 1;
        gs_prio = 2;
@@ -1288,16 +1904,24 @@ void r600_init_config(struct r600_pipe_context *rctx)
        r600_pipe_state_add_reg(rstate, R_009714_VC_ENHANCE, 0x00000000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_028350_SX_MISC, 0x00000000, 0xFFFFFFFF, NULL);
 
-       if (family >= CHIP_RV770) {
+       if (rctx->chip_class >= R700) {
                r600_pipe_state_add_reg(rstate, R_008D8C_SQ_DYN_GPR_CNTL_PS_FLUSH_REQ, 0x00004000, 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_009508_TA_CNTL_AUX, 0x07000002, 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg(rstate, R_009508_TA_CNTL_AUX,
+                                       S_009508_DISABLE_CUBE_ANISO(1) |
+                                       S_009508_SYNC_GRADIENT(1) |
+                                       S_009508_SYNC_WALKER(1) |
+                                       S_009508_SYNC_ALIGNER(1), 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_009830_DB_DEBUG, 0x00000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_009838_DB_WATERMARKS, 0x00420204, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_0286C8_SPI_THREAD_GROUPING, 0x00000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_028A4C_PA_SC_MODE_CNTL, 0x00514002, 0xFFFFFFFF, NULL);
        } else {
                r600_pipe_state_add_reg(rstate, R_008D8C_SQ_DYN_GPR_CNTL_PS_FLUSH_REQ, 0x00000000, 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_009508_TA_CNTL_AUX, 0x07000003, 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg(rstate, R_009508_TA_CNTL_AUX,
+                                       S_009508_DISABLE_CUBE_ANISO(1) |
+                                       S_009508_SYNC_GRADIENT(1) |
+                                       S_009508_SYNC_WALKER(1) |
+                                       S_009508_SYNC_ALIGNER(1), 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_009830_DB_DEBUG, 0x82000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_009838_DB_WATERMARKS, 0x01020204, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_0286C8_SPI_THREAD_GROUPING, 0x00000001, 0xFFFFFFFF, NULL);
@@ -1403,7 +2027,7 @@ void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shad
        r600_pipe_state_add_reg(rstate, R_0286D8_SPI_INPUT_Z, spi_input_z, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                                R_028840_SQ_PGM_START_PS,
-                               r600_bo_offset(shader->bo) >> 8, 0xFFFFFFFF, shader->bo);
+                               0, 0xFFFFFFFF, shader->bo);
        r600_pipe_state_add_reg(rstate,
                                R_028850_SQ_PGM_RESOURCES_PS,
                                S_028868_NUM_GPRS(rshader->bc.ngpr) |
@@ -1438,7 +2062,7 @@ void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shad
        struct r600_pipe_state *rstate = &shader->rstate;
        struct r600_shader *rshader = &shader->shader;
        unsigned spi_vs_out_id[10];
-       unsigned i, tmp;
+       unsigned i, tmp, nparams;
 
        /* clear previous register */
        rstate->nregs = 0;
@@ -1460,9 +2084,17 @@ void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shad
                                        spi_vs_out_id[i], 0xFFFFFFFF, NULL);
        }
 
+       /* Certain attributes (position, psize, etc.) don't count as params.
+        * VS is required to export at least one param and r600_shader_from_tgsi()
+        * takes care of adding a dummy export.
+        */
+       nparams = rshader->noutput - rshader->npos;
+       if (nparams < 1)
+               nparams = 1;
+
        r600_pipe_state_add_reg(rstate,
                        R_0286C4_SPI_VS_OUT_CONFIG,
-                       S_0286C4_VS_EXPORT_COUNT(rshader->noutput - 2),
+                       S_0286C4_VS_EXPORT_COUNT(nparams - 1),
                        0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                        R_028868_SQ_PGM_RESOURCES_VS,
@@ -1474,7 +2106,7 @@ void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shad
                        0x00000000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                        R_028858_SQ_PGM_START_VS,
-                       r600_bo_offset(shader->bo) >> 8, 0xFFFFFFFF, shader->bo);
+                       0, 0xFFFFFFFF, shader->bo);
 
        r600_pipe_state_add_reg(rstate,
                                R_03E200_SQ_LOOP_CONST_0 + (32 * 4), 0x01000FFF,
@@ -1495,7 +2127,7 @@ void r600_fetch_shader(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_0288DC_SQ_PGM_CF_OFFSET_FS,
                                0x00000000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_028894_SQ_PGM_START_FS,
-                               r600_bo_offset(ve->fetch_shader) >> 8,
+                               0,
                                0xFFFFFFFF, ve->fetch_shader);
 }
 
index fa0c5cb..9f3ab89 100644 (file)
@@ -28,6 +28,7 @@
 #include <util/u_format.h>
 #include <pipebuffer/pb_buffer.h>
 #include "pipe/p_shader_tokens.h"
+#include "tgsi/tgsi_parse.h"
 #include "r600_formats.h"
 #include "r600_pipe.h"
 #include "r600d.h"
@@ -99,6 +100,8 @@ void r600_bind_rs_state(struct pipe_context *ctx, void *state)
        if (state == NULL)
                return;
 
+       rctx->clamp_vertex_color = rs->clamp_vertex_color;
+       rctx->clamp_fragment_color = rs->clamp_fragment_color;
        rctx->flatshade = rs->flatshade;
        rctx->sprite_coord_enable = rs->sprite_coord_enable;
        rctx->rasterizer = rs;
@@ -106,13 +109,13 @@ void r600_bind_rs_state(struct pipe_context *ctx, void *state)
        rctx->states[rs->rstate.id] = &rs->rstate;
        r600_context_pipe_state_set(&rctx->ctx, &rs->rstate);
 
-       if (rctx->family >= CHIP_CEDAR) {
+       if (rctx->chip_class >= EVERGREEN) {
                evergreen_polygon_offset_update(rctx);
        } else {
                r600_polygon_offset_update(rctx);
        }
        if (rctx->ps_shader && rctx->vs_shader)
-               r600_spi_update(rctx);
+               rctx->spi_dirty = true;
 }
 
 void r600_delete_rs_state(struct pipe_context *ctx, void *state)
@@ -209,7 +212,7 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
        /* Zero states. */
        for (i = 0; i < count; i++) {
                if (!buffers[i].buffer) {
-                       if (rctx->family >= CHIP_CEDAR) {
+                       if (rctx->chip_class >= EVERGREEN) {
                                evergreen_context_pipe_state_set_fs_resource(&rctx->ctx, NULL, i);
                        } else {
                                r600_context_pipe_state_set_fs_resource(&rctx->ctx, NULL, i);
@@ -217,7 +220,7 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
                }
        }
        for (; i < rctx->vbuf_mgr->nr_real_vertex_buffers; i++) {
-               if (rctx->family >= CHIP_CEDAR) {
+               if (rctx->chip_class >= EVERGREEN) {
                        evergreen_context_pipe_state_set_fs_resource(&rctx->ctx, NULL, i);
                } else {
                        r600_context_pipe_state_set_fs_resource(&rctx->ctx, NULL, i);
@@ -257,7 +260,9 @@ void *r600_create_shader_state(struct pipe_context *ctx,
        struct r600_pipe_shader *shader =  CALLOC_STRUCT(r600_pipe_shader);
        int r;
 
-       r =  r600_pipe_shader_create(ctx, shader, state->tokens);
+       shader->tokens = tgsi_dup_tokens(state->tokens);
+
+       r =  r600_pipe_shader_create(ctx, shader);
        if (r) {
                return NULL;
        }
@@ -274,7 +279,7 @@ void r600_bind_ps_shader(struct pipe_context *ctx, void *state)
                r600_context_pipe_state_set(&rctx->ctx, &rctx->ps_shader->rstate);
        }
        if (rctx->ps_shader && rctx->vs_shader) {
-               r600_spi_update(rctx);
+               rctx->spi_dirty = true;
                r600_adjust_gprs(rctx);
        }
 }
@@ -289,7 +294,7 @@ void r600_bind_vs_shader(struct pipe_context *ctx, void *state)
                r600_context_pipe_state_set(&rctx->ctx, &rctx->vs_shader->rstate);
        }
        if (rctx->ps_shader && rctx->vs_shader) {
-               r600_spi_update(rctx);
+               rctx->spi_dirty = true;
                r600_adjust_gprs(rctx);
        }
 }
@@ -303,6 +308,7 @@ void r600_delete_ps_shader(struct pipe_context *ctx, void *state)
                rctx->ps_shader = NULL;
        }
 
+       free(shader->tokens);
        r600_pipe_shader_destroy(ctx, shader);
        free(shader);
 }
@@ -316,6 +322,7 @@ void r600_delete_vs_shader(struct pipe_context *ctx, void *state)
                rctx->vs_shader = NULL;
        }
 
+       free(shader->tokens);
        r600_pipe_shader_destroy(ctx, shader);
        free(shader);
 }
@@ -351,7 +358,7 @@ static void r600_spi_update(struct r600_pipe_context *rctx)
        struct r600_pipe_shader *shader = rctx->ps_shader;
        struct r600_pipe_state *rstate = &rctx->spi;
        struct r600_shader *rshader = &shader->shader;
-       unsigned i, tmp;
+       unsigned i, tmp, sid;
 
        if (rctx->spi.id == 0)
                r600_spi_block_init(rctx, &rctx->spi);
@@ -360,9 +367,14 @@ static void r600_spi_update(struct r600_pipe_context *rctx)
        for (i = 0; i < rshader->ninput; i++) {
                if (rshader->input[i].name == TGSI_SEMANTIC_POSITION ||
                    rshader->input[i].name == TGSI_SEMANTIC_FACE)
-                       continue;
+                       if (rctx->chip_class >= EVERGREEN)
+                               continue;
+                       else
+                               sid=0;
+               else
+                       sid=r600_find_vs_semantic_index(&rctx->vs_shader->shader, rshader, i);
 
-               tmp = S_028644_SEMANTIC(r600_find_vs_semantic_index(&rctx->vs_shader->shader, rshader, i));
+               tmp = S_028644_SEMANTIC(sid);
 
                if (rshader->input[i].name == TGSI_SEMANTIC_COLOR ||
                    rshader->input[i].name == TGSI_SEMANTIC_BCOLOR ||
@@ -375,7 +387,7 @@ static void r600_spi_update(struct r600_pipe_context *rctx)
                        tmp |= S_028644_PT_SPRITE_TEX(1);
                }
 
-               if (rctx->family < CHIP_CEDAR) {
+               if (rctx->chip_class < EVERGREEN) {
                        if (rshader->input[i].centroid)
                                tmp |= S_028644_SEL_CENTROID(1);
 
@@ -386,6 +398,7 @@ static void r600_spi_update(struct r600_pipe_context *rctx)
                r600_pipe_state_mod_reg(rstate, tmp);
        }
 
+       rctx->spi_dirty = false;
        r600_context_pipe_state_set(&rctx->ctx, rstate);
 }
 
@@ -405,7 +418,6 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
        }
 
        r600_upload_const_buffer(rctx, &rbuffer, &offset);
-       offset += r600_bo_offset(rbuffer->r.bo);
 
        switch (shader) {
        case PIPE_SHADER_VERTEX:
@@ -421,14 +433,14 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
 
                rstate = &rctx->vs_const_buffer_resource[index];
                if (!rstate->id) {
-                       if (rctx->family >= CHIP_CEDAR) {
+                       if (rctx->chip_class >= EVERGREEN) {
                                evergreen_pipe_init_buffer_resource(rctx, rstate);
                        } else {
                                r600_pipe_init_buffer_resource(rctx, rstate);
                        }
                }
 
-               if (rctx->family >= CHIP_CEDAR) {
+               if (rctx->chip_class >= EVERGREEN) {
                        evergreen_pipe_mod_buffer_resource(rstate, &rbuffer->r, offset, 16);
                        evergreen_context_pipe_state_set_vs_resource(&rctx->ctx, rstate, index);
                } else {
@@ -449,13 +461,13 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index,
 
                rstate = &rctx->ps_const_buffer_resource[index];
                if (!rstate->id) {
-                       if (rctx->family >= CHIP_CEDAR) {
+                       if (rctx->chip_class >= EVERGREEN) {
                                evergreen_pipe_init_buffer_resource(rctx, rstate);
                        } else {
                                r600_pipe_init_buffer_resource(rctx, rstate);
                        }
                }
-               if (rctx->family >= CHIP_CEDAR) {
+               if (rctx->chip_class >= EVERGREEN) {
                        evergreen_pipe_mod_buffer_resource(rstate, &rbuffer->r, offset, 16);
                        evergreen_context_pipe_state_set_ps_resource(&rctx->ctx, rstate, index);
                } else {
@@ -505,17 +517,17 @@ static void r600_vertex_buffer_update(struct r600_pipe_context *rctx)
                }
                if (vertex_buffer == NULL || rbuffer == NULL)
                        continue;
-               offset += vertex_buffer->buffer_offset + r600_bo_offset(rbuffer->bo);
+               offset += vertex_buffer->buffer_offset;
 
                if (!rstate->id) {
-                       if (rctx->family >= CHIP_CEDAR) {
+                       if (rctx->chip_class >= EVERGREEN) {
                                evergreen_pipe_init_buffer_resource(rctx, rstate);
                        } else {
                                r600_pipe_init_buffer_resource(rctx, rstate);
                        }
                }
 
-               if (rctx->family >= CHIP_CEDAR) {
+               if (rctx->chip_class >= EVERGREEN) {
                        evergreen_pipe_mod_buffer_resource(rstate, rbuffer, offset, vertex_buffer->stride);
                        evergreen_context_pipe_state_set_fs_resource(&rctx->ctx, rstate, i);
                } else {
@@ -525,24 +537,39 @@ static void r600_vertex_buffer_update(struct r600_pipe_context *rctx)
        }
 }
 
+static int r600_shader_rebuild(struct pipe_context * ctx, struct r600_pipe_shader * shader)
+{
+       struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
+       int r;
+
+       r600_pipe_shader_destroy(ctx, shader);
+       r = r600_pipe_shader_create(ctx, shader);
+       if (r) {
+               return r;
+       }
+       r600_context_pipe_state_set(&rctx->ctx, &shader->rstate);
+
+       return 0;
+}
+
 void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 {
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_resource *rbuffer;
-       u32 vgt_dma_index_type, vgt_dma_swap_mode, vgt_draw_initiator, mask;
        struct r600_draw rdraw;
-       struct r600_drawl draw = {};
-       unsigned prim;
+       struct r600_drawl draw;
+       unsigned prim, mask;
 
        if (!rctx->blit) {
                if (rctx->have_depth_fb || rctx->have_depth_texture)
                        r600_flush_depth_textures(rctx);
        }
-       u_vbuf_mgr_draw_begin(rctx->vbuf_mgr, info, NULL, NULL);
+       u_vbuf_mgr_draw_begin(rctx->vbuf_mgr, info);
        r600_vertex_buffer_update(rctx);
 
        draw.info = *info;
        draw.ctx = ctx;
+       draw.index_buffer = NULL;
        if (info->indexed && rctx->index_buffer.buffer) {
                draw.info.start += rctx->index_buffer.offset / rctx->index_buffer.index_size;
                pipe_resource_reference(&draw.index_buffer, rctx->index_buffer.buffer);
@@ -560,57 +587,29 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
                        r600_upload_index_buffer(rctx, &draw);
                }
        } else {
+               draw.index_size = 0;
+               draw.index_buffer_offset = 0;
                draw.info.index_bias = info->start;
        }
 
-       vgt_dma_swap_mode = 0;
-       switch (draw.index_size) {
-       case 2:
-               vgt_draw_initiator = 0;
-               vgt_dma_index_type = 0;
-               if (R600_BIG_ENDIAN) {
-                       vgt_dma_swap_mode = ENDIAN_8IN16;
-               }
-               break;
-       case 4:
-               vgt_draw_initiator = 0;
-               vgt_dma_index_type = 1;
-               if (R600_BIG_ENDIAN) {
-                       vgt_dma_swap_mode = ENDIAN_8IN32;
-               }
-               break;
-       case 0:
-               vgt_draw_initiator = 2;
-               vgt_dma_index_type = 0;
-               break;
-       default:
-               R600_ERR("unsupported index size %d\n", draw.index_size);
-               return;
-       }
        if (r600_conv_pipe_prim(draw.info.mode, &prim))
                return;
-       if (unlikely(rctx->ps_shader == NULL)) {
-               R600_ERR("missing vertex shader\n");
-               return;
-       }
-       if (unlikely(rctx->vs_shader == NULL)) {
-               R600_ERR("missing vertex shader\n");
-               return;
-       }
-       /* there should be enough input */
-       if (rctx->vertex_elements->count < rctx->vs_shader->shader.bc.nresource) {
-               R600_ERR("%d resources provided, expecting %d\n",
-                       rctx->vertex_elements->count, rctx->vs_shader->shader.bc.nresource);
-               return;
-       }
+
+       if (rctx->vs_shader->shader.clamp_color != rctx->clamp_vertex_color)
+               r600_shader_rebuild(ctx, rctx->vs_shader);
+
+       if ((rctx->ps_shader->shader.clamp_color != rctx->clamp_fragment_color) ||
+           ((rctx->chip_class >= EVERGREEN) && rctx->ps_shader->shader.fs_write_all &&
+            (rctx->ps_shader->shader.nr_cbufs != rctx->nr_cbufs)))
+               r600_shader_rebuild(ctx, rctx->ps_shader);
+
+       if (rctx->spi_dirty)
+               r600_spi_update(rctx);
 
        if (rctx->alpha_ref_dirty)
                r600_update_alpha_ref(rctx);
 
-       mask = 0;
-       for (int i = 0; i < rctx->framebuffer.nr_cbufs; i++) {
-               mask |= (0xF << (i * 4));
-       }
+       mask = (1ULL << ((unsigned)rctx->framebuffer.nr_cbufs * 4)) - 1;
 
        if (rctx->vgt.id != R600_PIPE_STATE_VGT) {
                rctx->vgt.id = R600_PIPE_STATE_VGT;
@@ -644,8 +643,10 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 
        rdraw.vgt_num_indices = draw.info.count;
        rdraw.vgt_num_instances = draw.info.instance_count;
-       rdraw.vgt_index_type = vgt_dma_index_type | (vgt_dma_swap_mode << 2);
-       rdraw.vgt_draw_initiator = vgt_draw_initiator;
+       rdraw.vgt_index_type = ((draw.index_size == 4) ? 1 : 0);
+       if (R600_BIG_ENDIAN)
+               rdraw.vgt_index_type |= (draw.index_size >> 1) << 2;
+       rdraw.vgt_draw_initiator = draw.index_size ? 0 : 2;
        rdraw.indices = NULL;
        if (draw.index_buffer) {
                rbuffer = (struct r600_resource*)draw.index_buffer;
@@ -653,7 +654,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
                rdraw.indices_bo_offset = draw.index_buffer_offset;
        }
 
-       if (rctx->family >= CHIP_CEDAR) {
+       if (rctx->chip_class >= EVERGREEN) {
                evergreen_context_draw(&rctx->ctx, &rdraw);
        } else {
                r600_context_draw(&rctx->ctx, &rdraw);
diff --git a/src/gallium/drivers/r600/r600_state_inlines.h b/src/gallium/drivers/r600/r600_state_inlines.h
deleted file mode 100644 (file)
index 5418570..0000000
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- * Copyright 2010 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE 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 R600_STATE_INLINES_H
-#define R600_STATE_INLINES_H
-
-#include "util/u_format.h"
-#include "r600d.h"
-#include "r600_formats.h"
-
-static INLINE uint32_t r600_translate_blend_function(int blend_func)
-{
-       switch (blend_func) {
-       case PIPE_BLEND_ADD:
-               return V_028804_COMB_DST_PLUS_SRC;
-       case PIPE_BLEND_SUBTRACT:
-               return V_028804_COMB_SRC_MINUS_DST;
-       case PIPE_BLEND_REVERSE_SUBTRACT:
-               return V_028804_COMB_DST_MINUS_SRC;
-       case PIPE_BLEND_MIN:
-               return V_028804_COMB_MIN_DST_SRC;
-       case PIPE_BLEND_MAX:
-               return V_028804_COMB_MAX_DST_SRC;
-       default:
-               R600_ERR("Unknown blend function %d\n", blend_func);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_blend_factor(int blend_fact)
-{
-       switch (blend_fact) {
-       case PIPE_BLENDFACTOR_ONE:
-               return V_028804_BLEND_ONE;
-       case PIPE_BLENDFACTOR_SRC_COLOR:
-               return V_028804_BLEND_SRC_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA:
-               return V_028804_BLEND_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_DST_ALPHA:
-               return V_028804_BLEND_DST_ALPHA;
-       case PIPE_BLENDFACTOR_DST_COLOR:
-               return V_028804_BLEND_DST_COLOR;
-       case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-               return V_028804_BLEND_SRC_ALPHA_SATURATE;
-       case PIPE_BLENDFACTOR_CONST_COLOR:
-               return V_028804_BLEND_CONST_COLOR;
-       case PIPE_BLENDFACTOR_CONST_ALPHA:
-               return V_028804_BLEND_CONST_ALPHA;
-       case PIPE_BLENDFACTOR_ZERO:
-               return V_028804_BLEND_ZERO;
-       case PIPE_BLENDFACTOR_INV_SRC_COLOR:
-               return V_028804_BLEND_ONE_MINUS_SRC_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
-               return V_028804_BLEND_ONE_MINUS_SRC_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_ALPHA:
-               return V_028804_BLEND_ONE_MINUS_DST_ALPHA;
-       case PIPE_BLENDFACTOR_INV_DST_COLOR:
-               return V_028804_BLEND_ONE_MINUS_DST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_COLOR:
-               return V_028804_BLEND_ONE_MINUS_CONST_COLOR;
-       case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
-               return V_028804_BLEND_ONE_MINUS_CONST_ALPHA;
-       case PIPE_BLENDFACTOR_SRC1_COLOR:
-               return V_028804_BLEND_SRC1_COLOR;
-       case PIPE_BLENDFACTOR_SRC1_ALPHA:
-               return V_028804_BLEND_SRC1_ALPHA;
-       case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
-               return V_028804_BLEND_INV_SRC1_COLOR;
-       case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
-               return V_028804_BLEND_INV_SRC1_ALPHA;
-       default:
-               R600_ERR("Bad blend factor %d not supported!\n", blend_fact);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_stencil_op(int s_op)
-{
-       switch (s_op) {
-       case PIPE_STENCIL_OP_KEEP:
-               return V_028800_STENCIL_KEEP;
-       case PIPE_STENCIL_OP_ZERO:
-               return V_028800_STENCIL_ZERO;
-       case PIPE_STENCIL_OP_REPLACE:
-               return V_028800_STENCIL_REPLACE;
-       case PIPE_STENCIL_OP_INCR:
-               return V_028800_STENCIL_INCR;
-       case PIPE_STENCIL_OP_DECR:
-               return V_028800_STENCIL_DECR;
-       case PIPE_STENCIL_OP_INCR_WRAP:
-               return V_028800_STENCIL_INCR_WRAP;
-       case PIPE_STENCIL_OP_DECR_WRAP:
-               return V_028800_STENCIL_DECR_WRAP;
-       case PIPE_STENCIL_OP_INVERT:
-               return V_028800_STENCIL_INVERT;
-       default:
-               R600_ERR("Unknown stencil op %d", s_op);
-               assert(0);
-               break;
-       }
-       return 0;
-}
-
-static INLINE uint32_t r600_translate_fill(uint32_t func)
-{
-       switch(func) {
-       case PIPE_POLYGON_MODE_FILL:
-               return 2;
-       case PIPE_POLYGON_MODE_LINE:
-               return 1;
-       case PIPE_POLYGON_MODE_POINT:
-               return 0;
-       default:
-               assert(0);
-               return 0;
-       }
-}
-
-/* translates straight */
-static INLINE uint32_t r600_translate_ds_func(int func)
-{
-       return func;
-}
-
-static inline unsigned r600_tex_wrap(unsigned wrap)
-{
-       switch (wrap) {
-       default:
-       case PIPE_TEX_WRAP_REPEAT:
-               return V_03C000_SQ_TEX_WRAP;
-       case PIPE_TEX_WRAP_CLAMP:
-               return V_03C000_SQ_TEX_CLAMP_HALF_BORDER;
-       case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
-               return V_03C000_SQ_TEX_CLAMP_LAST_TEXEL;
-       case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
-               return V_03C000_SQ_TEX_CLAMP_BORDER;
-       case PIPE_TEX_WRAP_MIRROR_REPEAT:
-               return V_03C000_SQ_TEX_MIRROR;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_HALF_BORDER;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_LAST_TEXEL;
-       case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
-               return V_03C000_SQ_TEX_MIRROR_ONCE_BORDER;
-       }
-}
-
-static inline unsigned r600_tex_filter(unsigned filter)
-{
-       switch (filter) {
-       default:
-       case PIPE_TEX_FILTER_NEAREST:
-               return V_03C000_SQ_TEX_XY_FILTER_POINT;
-       case PIPE_TEX_FILTER_LINEAR:
-               return V_03C000_SQ_TEX_XY_FILTER_BILINEAR;
-       }
-}
-
-static inline unsigned r600_tex_mipfilter(unsigned filter)
-{
-       switch (filter) {
-       case PIPE_TEX_MIPFILTER_NEAREST:
-               return V_03C000_SQ_TEX_Z_FILTER_POINT;
-       case PIPE_TEX_MIPFILTER_LINEAR:
-               return V_03C000_SQ_TEX_Z_FILTER_LINEAR;
-       default:
-       case PIPE_TEX_MIPFILTER_NONE:
-               return V_03C000_SQ_TEX_Z_FILTER_NONE;
-       }
-}
-
-static inline unsigned r600_tex_compare(unsigned compare)
-{
-       switch (compare) {
-       default:
-       case PIPE_FUNC_NEVER:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_NEVER;
-       case PIPE_FUNC_LESS:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESS;
-       case PIPE_FUNC_EQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_EQUAL;
-       case PIPE_FUNC_LEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_LESSEQUAL;
-       case PIPE_FUNC_GREATER:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATER;
-       case PIPE_FUNC_NOTEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_NOTEQUAL;
-       case PIPE_FUNC_GEQUAL:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_GREATEREQUAL;
-       case PIPE_FUNC_ALWAYS:
-               return V_03C000_SQ_TEX_DEPTH_COMPARE_ALWAYS;
-       }
-}
-
-static inline unsigned r600_tex_swizzle(unsigned swizzle)
-{
-       switch (swizzle) {
-       case PIPE_SWIZZLE_RED:
-               return V_038010_SQ_SEL_X;
-       case PIPE_SWIZZLE_GREEN:
-               return V_038010_SQ_SEL_Y;
-       case PIPE_SWIZZLE_BLUE:
-               return V_038010_SQ_SEL_Z;
-       case PIPE_SWIZZLE_ALPHA:
-               return V_038010_SQ_SEL_W;
-       case PIPE_SWIZZLE_ZERO:
-               return V_038010_SQ_SEL_0;
-       default:
-       case PIPE_SWIZZLE_ONE:
-               return V_038010_SQ_SEL_1;
-       }
-}
-
-static inline unsigned r600_format_type(unsigned format_type)
-{
-       switch (format_type) {
-       default:
-       case UTIL_FORMAT_TYPE_UNSIGNED:
-               return V_038010_SQ_FORMAT_COMP_UNSIGNED;
-       case UTIL_FORMAT_TYPE_SIGNED:
-               return V_038010_SQ_FORMAT_COMP_SIGNED;
-       case UTIL_FORMAT_TYPE_FIXED:
-               return V_038010_SQ_FORMAT_COMP_UNSIGNED_BIASED;
-       }
-}
-
-static inline unsigned r600_tex_dim(unsigned dim)
-{
-       switch (dim) {
-       default:
-       case PIPE_TEXTURE_1D:
-               return V_038000_SQ_TEX_DIM_1D;
-       case PIPE_TEXTURE_1D_ARRAY:
-               return V_038000_SQ_TEX_DIM_1D_ARRAY;
-       case PIPE_TEXTURE_2D:
-       case PIPE_TEXTURE_RECT:
-               return V_038000_SQ_TEX_DIM_2D;
-       case PIPE_TEXTURE_2D_ARRAY:
-               return V_038000_SQ_TEX_DIM_2D_ARRAY;
-       case PIPE_TEXTURE_3D:
-               return V_038000_SQ_TEX_DIM_3D;
-       case PIPE_TEXTURE_CUBE:
-               return V_038000_SQ_TEX_DIM_CUBEMAP;
-       }
-}
-
-static inline uint32_t r600_translate_dbformat(enum pipe_format format)
-{
-       switch (format) {
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_028010_DEPTH_16;
-       case PIPE_FORMAT_Z24X8_UNORM:
-               return V_028010_DEPTH_X8_24;
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_028010_DEPTH_8_24;
-       default:
-               return ~0;
-       }
-}
-
-static inline uint32_t r600_translate_colorswap(enum pipe_format format)
-{
-       switch (format) {
-       /* 8-bit buffers. */
-       case PIPE_FORMAT_A8_UNORM:
-               return V_0280A0_SWAP_ALT_REV;
-       case PIPE_FORMAT_I8_UNORM:
-       case PIPE_FORMAT_L8_UNORM:
-       case PIPE_FORMAT_L8_SRGB:
-       case PIPE_FORMAT_R8_UNORM:
-       case PIPE_FORMAT_R8_SNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_L4A4_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       /* 16-bit buffers. */
-       case PIPE_FORMAT_B5G6R5_UNORM:
-               return V_0280A0_SWAP_STD_REV;
-
-       case PIPE_FORMAT_B5G5R5A1_UNORM:
-       case PIPE_FORMAT_B5G5R5X1_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_B4G4R4A4_UNORM:
-       case PIPE_FORMAT_B4G4R4X4_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_L8A8_UNORM:
-       case PIPE_FORMAT_L8A8_SRGB:
-               return V_0280A0_SWAP_ALT;
-       case PIPE_FORMAT_R8G8_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_R16_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       /* 32-bit buffers. */
-
-       case PIPE_FORMAT_A8B8G8R8_SRGB:
-               return V_0280A0_SWAP_STD_REV;
-       case PIPE_FORMAT_B8G8R8A8_SRGB:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_B8G8R8A8_UNORM:
-       case PIPE_FORMAT_B8G8R8X8_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-               return V_0280A0_SWAP_ALT_REV;
-       case PIPE_FORMAT_R8G8B8A8_SNORM:
-       case PIPE_FORMAT_R8G8B8A8_UNORM:
-       case PIPE_FORMAT_R8G8B8X8_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_A8B8G8R8_UNORM:
-       case PIPE_FORMAT_X8B8G8R8_UNORM:
-       /* case PIPE_FORMAT_R8SG8SB8UX8U_NORM: */
-               return V_0280A0_SWAP_STD_REV;
-
-       case PIPE_FORMAT_Z24X8_UNORM:
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_X8Z24_UNORM:
-       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_R10G10B10A2_UNORM:
-       case PIPE_FORMAT_R10G10B10X2_SNORM:
-       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-               return V_0280A0_SWAP_STD;
-
-       case PIPE_FORMAT_B10G10R10A2_UNORM:
-               return V_0280A0_SWAP_ALT;
-
-       case PIPE_FORMAT_R11G11B10_FLOAT:
-       case PIPE_FORMAT_R16G16_UNORM:
-       case PIPE_FORMAT_R16G16_FLOAT:
-       case PIPE_FORMAT_R32_FLOAT:
-               return V_0280A0_SWAP_STD;
-
-       /* 64-bit buffers. */
-       case PIPE_FORMAT_R32G32_FLOAT:
-       case PIPE_FORMAT_R16G16B16A16_UNORM:
-       case PIPE_FORMAT_R16G16B16A16_SNORM:
-       case PIPE_FORMAT_R16G16B16A16_FLOAT:
-
-       /* 128-bit buffers. */
-       case PIPE_FORMAT_R32G32B32A32_FLOAT:
-       case PIPE_FORMAT_R32G32B32A32_SNORM:
-       case PIPE_FORMAT_R32G32B32A32_UNORM:
-               return V_0280A0_SWAP_STD;
-       default:
-               R600_ERR("unsupported colorswap format %d\n", format);
-               return ~0;
-       }
-       return ~0;
-}
-
-static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
-{
-       switch (format) {
-       case PIPE_FORMAT_L4A4_UNORM:
-               return V_0280A0_COLOR_4_4;
-
-       /* 8-bit buffers. */
-       case PIPE_FORMAT_A8_UNORM:
-       case PIPE_FORMAT_I8_UNORM:
-       case PIPE_FORMAT_L8_UNORM:
-       case PIPE_FORMAT_L8_SRGB:
-       case PIPE_FORMAT_R8_UNORM:
-       case PIPE_FORMAT_R8_SNORM:
-               return V_0280A0_COLOR_8;
-
-       /* 16-bit buffers. */
-       case PIPE_FORMAT_B5G6R5_UNORM:
-               return V_0280A0_COLOR_5_6_5;
-
-       case PIPE_FORMAT_B5G5R5A1_UNORM:
-       case PIPE_FORMAT_B5G5R5X1_UNORM:
-               return V_0280A0_COLOR_1_5_5_5;
-
-       case PIPE_FORMAT_B4G4R4A4_UNORM:
-       case PIPE_FORMAT_B4G4R4X4_UNORM:
-               return V_0280A0_COLOR_4_4_4_4;
-
-       case PIPE_FORMAT_Z16_UNORM:
-               return V_0280A0_COLOR_16;
-
-       case PIPE_FORMAT_L8A8_UNORM:
-       case PIPE_FORMAT_L8A8_SRGB:
-       case PIPE_FORMAT_R8G8_UNORM:
-               return V_0280A0_COLOR_8_8;
-
-       case PIPE_FORMAT_R16_UNORM:
-               return V_0280A0_COLOR_16;
-
-       /* 32-bit buffers. */
-       case PIPE_FORMAT_A8B8G8R8_SRGB:
-       case PIPE_FORMAT_A8B8G8R8_UNORM:
-       case PIPE_FORMAT_A8R8G8B8_UNORM:
-       case PIPE_FORMAT_B8G8R8A8_SRGB:
-       case PIPE_FORMAT_B8G8R8A8_UNORM:
-       case PIPE_FORMAT_B8G8R8X8_UNORM:
-       case PIPE_FORMAT_R8G8B8A8_SNORM:
-       case PIPE_FORMAT_R8G8B8A8_UNORM:
-       case PIPE_FORMAT_R8G8B8X8_UNORM:
-       case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
-       case PIPE_FORMAT_X8B8G8R8_UNORM:
-       case PIPE_FORMAT_X8R8G8B8_UNORM:
-       case PIPE_FORMAT_R8G8B8_UNORM:
-               return V_0280A0_COLOR_8_8_8_8;
-
-       case PIPE_FORMAT_R10G10B10A2_UNORM:
-       case PIPE_FORMAT_R10G10B10X2_SNORM:
-       case PIPE_FORMAT_B10G10R10A2_UNORM:
-       case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
-               return V_0280A0_COLOR_2_10_10_10;
-
-       case PIPE_FORMAT_Z24X8_UNORM:
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               return V_0280A0_COLOR_8_24;
-
-       case PIPE_FORMAT_X8Z24_UNORM:
-       case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-               return V_0280A0_COLOR_24_8;
-
-       case PIPE_FORMAT_R32_FLOAT:
-               return V_0280A0_COLOR_32_FLOAT;
-
-       case PIPE_FORMAT_R16G16_FLOAT:
-               return V_0280A0_COLOR_16_16_FLOAT;
-
-       case PIPE_FORMAT_R16G16_SSCALED:
-       case PIPE_FORMAT_R16G16_UNORM:
-               return V_0280A0_COLOR_16_16;
-
-       case PIPE_FORMAT_R11G11B10_FLOAT:
-               return V_0280A0_COLOR_10_11_11_FLOAT;
-
-       /* 64-bit buffers. */
-       case PIPE_FORMAT_R16G16B16_USCALED:
-       case PIPE_FORMAT_R16G16B16A16_USCALED:
-       case PIPE_FORMAT_R16G16B16_SSCALED:
-       case PIPE_FORMAT_R16G16B16A16_SSCALED:
-       case PIPE_FORMAT_R16G16B16A16_UNORM:
-       case PIPE_FORMAT_R16G16B16A16_SNORM:
-               return V_0280A0_COLOR_16_16_16_16;
-
-       case PIPE_FORMAT_R16G16B16_FLOAT:
-       case PIPE_FORMAT_R16G16B16A16_FLOAT:
-               return V_0280A0_COLOR_16_16_16_16_FLOAT;
-
-       case PIPE_FORMAT_R32G32_FLOAT:
-               return V_0280A0_COLOR_32_32_FLOAT;
-
-       case PIPE_FORMAT_R32G32_USCALED:
-       case PIPE_FORMAT_R32G32_SSCALED:
-               return V_0280A0_COLOR_32_32;
-
-       /* 96-bit buffers. */
-       case PIPE_FORMAT_R32G32B32_FLOAT:
-               return V_0280A0_COLOR_32_32_32_FLOAT;
-
-       /* 128-bit buffers. */
-       case PIPE_FORMAT_R32G32B32A32_FLOAT:
-               return V_0280A0_COLOR_32_32_32_32_FLOAT;
-       case PIPE_FORMAT_R32G32B32A32_SNORM:
-       case PIPE_FORMAT_R32G32B32A32_UNORM:
-               return V_0280A0_COLOR_32_32_32_32;
-
-       /* YUV buffers. */
-       case PIPE_FORMAT_UYVY:
-       case PIPE_FORMAT_YUYV:
-       default:
-               return ~0; /* Unsupported. */
-       }
-}
-
-static INLINE uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
-{
-       if (R600_BIG_ENDIAN) {
-               switch(colorformat) {
-               case V_0280A0_COLOR_4_4:
-                       return(ENDIAN_NONE);
-
-               /* 8-bit buffers. */
-               case V_0280A0_COLOR_8:
-                       return(ENDIAN_NONE);
-
-               /* 16-bit buffers. */
-               case V_0280A0_COLOR_5_6_5:
-               case V_0280A0_COLOR_1_5_5_5:
-               case V_0280A0_COLOR_4_4_4_4:
-               case V_0280A0_COLOR_16:
-               case V_0280A0_COLOR_8_8:
-                       return(ENDIAN_8IN16);
-
-               /* 32-bit buffers. */
-               case V_0280A0_COLOR_8_8_8_8:
-               case V_0280A0_COLOR_2_10_10_10:
-               case V_0280A0_COLOR_8_24:
-               case V_0280A0_COLOR_24_8:
-               case V_0280A0_COLOR_32_FLOAT:
-               case V_0280A0_COLOR_16_16_FLOAT:
-               case V_0280A0_COLOR_16_16:
-                       return(ENDIAN_8IN32);
-
-               /* 64-bit buffers. */
-               case V_0280A0_COLOR_16_16_16_16:
-               case V_0280A0_COLOR_16_16_16_16_FLOAT:
-                       return(ENDIAN_8IN16);
-
-               case V_0280A0_COLOR_32_32_FLOAT:
-               case V_0280A0_COLOR_32_32:
-                       return(ENDIAN_8IN32);
-
-               /* 128-bit buffers. */
-               case V_0280A0_COLOR_32_32_32_FLOAT:
-               case V_0280A0_COLOR_32_32_32_32_FLOAT:
-               case V_0280A0_COLOR_32_32_32_32:
-                       return(ENDIAN_8IN32);
-               default:
-                       return ENDIAN_NONE; /* Unsupported. */
-               }
-       } else {
-               return ENDIAN_NONE;
-       }
-}
-
-static INLINE boolean r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
-{
-       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0;
-}
-
-static INLINE boolean r600_is_colorbuffer_format_supported(enum pipe_format format)
-{
-       return r600_translate_colorformat(format) != ~0 &&
-              r600_translate_colorswap(format) != ~0;
-}
-
-static INLINE boolean r600_is_zs_format_supported(enum pipe_format format)
-{
-       return r600_translate_dbformat(format) != ~0;
-}
-
-static INLINE boolean r600_is_vertex_format_supported(enum pipe_format format,
-                                                     enum radeon_family family)
-{
-       unsigned i;
-       const struct util_format_description *desc = util_format_description(format);
-       if (!desc)
-               return FALSE;
-
-       /* Find the first non-VOID channel. */
-       for (i = 0; i < 4; i++) {
-               if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
-                       break;
-               }
-       }
-       if (i == 4)
-               return FALSE;
-
-       /* No fixed, no double. */
-       if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
-           desc->channel[i].type == UTIL_FORMAT_TYPE_FIXED ||
-           (desc->channel[i].size == 64 &&
-            desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT))
-               return FALSE;
-
-       /* No scaled/norm formats with 32 bits per channel. */
-       if (desc->channel[i].size == 32 &&
-           (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED ||
-            desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED))
-               return FALSE;
-
-       return TRUE;
-}
-
-#endif
index 470d26e..927eb5d 100644 (file)
@@ -35,7 +35,6 @@
 #include "pipebuffer/pb_buffer.h"
 #include "r600_pipe.h"
 #include "r600_resource.h"
-#include "r600_state_inlines.h"
 #include "r600d.h"
 #include "r600_formats.h"
 
@@ -243,10 +242,11 @@ static void r600_setup_miptree(struct pipe_screen *screen,
        struct radeon *radeon = (struct radeon *)screen->winsys;
        enum chip_class chipc = r600_get_family_class(radeon);
        unsigned size, layer_size, i, offset;
-       unsigned nblocksx, nblocksy;
+       unsigned nblocksx, nblocksy, extra_size = 0;
 
        for (i = 0, offset = 0; i <= ptex->last_level; i++) {
                unsigned blocksize = util_format_get_blocksize(ptex->format);
+               unsigned base_align = r600_get_base_alignment(screen, ptex->format, array_mode);
 
                r600_texture_set_array_mode(screen, rtex, i, array_mode);
 
@@ -265,9 +265,13 @@ static void r600_setup_miptree(struct pipe_screen *screen,
                else
                        size = layer_size * ptex->array_size;
 
+               /* evergreen stores depth and stencil separately */
+               if ((chipc >= EVERGREEN) && util_format_is_depth_or_stencil(ptex->format))
+                       extra_size = align(extra_size + (nblocksx * nblocksy * 1), base_align);
+
                /* align base image and start of miptree */
                if ((i == 0) || (i == 1))
-                       offset = align(offset, r600_get_base_alignment(screen, ptex->format, array_mode));
+                       offset = align(offset, base_align);
                rtex->offset[i] = offset;
                rtex->layer_size[i] = layer_size;
                rtex->pitch_in_blocks[i] = nblocksx; /* CB talks in elements */
@@ -275,7 +279,7 @@ static void r600_setup_miptree(struct pipe_screen *screen,
 
                offset += size;
        }
-       rtex->size = offset;
+       rtex->size = offset + extra_size;
 }
 
 /* Figure out whether u_blitter will fallback to a transfer operation.
@@ -309,7 +313,14 @@ static boolean permit_hardware_blit(struct pipe_screen *screen,
                                 PIPE_BIND_SAMPLER_VIEW))
                return FALSE;
 
-       return TRUE;
+       switch (res->usage) {
+       case PIPE_USAGE_STREAM:
+       case PIPE_USAGE_STAGING:
+               return FALSE;
+
+       default:
+               return TRUE;
+       }
 }
 
 static boolean r600_texture_get_handle(struct pipe_screen* screen,
@@ -678,7 +689,6 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
        enum pipe_format format = transfer->resource->format;
        struct radeon *radeon = (struct radeon *)ctx->screen->winsys;
        unsigned offset = 0;
-       unsigned usage = 0;
        char *map;
 
        if (rtransfer->staging_texture) {
@@ -696,30 +706,7 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
                        transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
        }
 
-       if (transfer->usage & PIPE_TRANSFER_WRITE) {
-               usage |= PB_USAGE_CPU_WRITE;
-
-               if (transfer->usage & PIPE_TRANSFER_DISCARD) {
-               }
-
-               if (transfer->usage & PIPE_TRANSFER_FLUSH_EXPLICIT) {
-               }
-       }
-
-       if (transfer->usage & PIPE_TRANSFER_READ) {
-               usage |= PB_USAGE_CPU_READ;
-       }
-
-       if (transfer->usage & PIPE_TRANSFER_DONTBLOCK) {
-               usage |= PB_USAGE_DONTBLOCK;
-       }
-
-       if (transfer->usage & PIPE_TRANSFER_UNSYNCHRONIZED) {
-               usage |= PB_USAGE_UNSYNCHRONIZED;
-       }
-
-       map = r600_bo_map(radeon, bo, usage, ctx);
-       if (!map) {
+       if (!(map = r600_bo_map(radeon, bo, transfer->usage, ctx))) {
                return NULL;
        }
 
@@ -767,11 +754,7 @@ static unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format,
        };
 
        if (swizzle_view) {
-               /* Combine two sets of swizzles. */
-               for (i = 0; i < 4; i++) {
-                       swizzle[i] = swizzle_view[i] <= UTIL_FORMAT_SWIZZLE_W ?
-                               swizzle_format[swizzle_view[i]] : swizzle_view[i];
-               }
+               util_format_compose_swizzles(swizzle_format, swizzle_view, swizzle);
        } else {
                memcpy(swizzle, swizzle_format, 4);
        }
@@ -847,6 +830,12 @@ uint32_t r600_translate_texformat(struct pipe_screen *screen,
                        result = FMT_8;
                        word4 |= S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT);
                        goto out_word4;
+               case PIPE_FORMAT_Z32_FLOAT:
+                       result = FMT_32_FLOAT;
+                       goto out_word4;
+               case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+                       result = FMT_X24_8_32_FLOAT;
+                       goto out_word4;
                default:
                        goto out_unknown;
                }
index 6373572..f6eec24 100644 (file)
 #define   S_009508_DISABLE_CUBE_WRAP(x)                (((x) & 0x1) << 0)
 #define   G_009508_DISABLE_CUBE_WRAP(x)                (((x) >> 0) & 0x1)
 #define   C_009508_DISABLE_CUBE_WRAP                   0xFFFFFFFE
+#define   S_009508_DISABLE_CUBE_ANISO(x)               (((x) & 0x1) << 1)
+#define   G_009508_DISABLE_CUBE_ANISO(x)               (((x) >> 1) & 0x1)
+#define   C_009508_DISABLE_CUBE_ANISO                  (~(1 << 1))
 #define   S_009508_SYNC_GRADIENT(x)                    (((x) & 0x1) << 24)
 #define   G_009508_SYNC_GRADIENT(x)                    (((x) >> 24) & 0x1)
 #define   C_009508_SYNC_GRADIENT                       0xFEFFFFFF
index 2895358..9403e6c 100644 (file)
@@ -19,7 +19,7 @@ C_SOURCES = \
        sp_quad_fs.c \
        sp_quad_blend.c \
        sp_screen.c \
-        sp_setup.c \
+       sp_setup.c \
        sp_state_blend.c \
        sp_state_clip.c \
        sp_state_derived.c \
index ae3f00f..22e8a2e 100644 (file)
@@ -60,7 +60,7 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
       return;
 
 #if 0
-   softpipe_update_derived(softpipe); /* not needed?? */
+   softpipe_update_derived(softpipe, PIPE_PRIM_TRIANGLES); /* not needed?? */
 #endif
 
    if (buffers & PIPE_CLEAR_COLOR) {
index ce22f64..c97b033 100644 (file)
 #include "pipe/p_defines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_pstipple.h"
 #include "util/u_inlines.h"
 #include "tgsi/tgsi_exec.h"
+#include "vl/vl_decoder.h"
+#include "vl/vl_video_buffer.h"
 #include "sp_clear.h"
 #include "sp_context.h"
 #include "sp_flush.h"
@@ -88,6 +91,14 @@ softpipe_destroy( struct pipe_context *pipe )
    struct softpipe_context *softpipe = softpipe_context( pipe );
    uint i;
 
+#if DO_PSTIPPLE_IN_HELPER_MODULE
+   if (softpipe->pstipple.sampler)
+      pipe->delete_sampler_state(pipe, softpipe->pstipple.sampler);
+
+   pipe_resource_reference(&softpipe->pstipple.texture, NULL);
+   pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, NULL);
+#endif
+
    if (softpipe->draw)
       draw_destroy( softpipe->draw );
 
@@ -258,6 +269,9 @@ softpipe_create_context( struct pipe_screen *screen,
    softpipe->pipe.flush = softpipe_flush_wrapped;
 
    softpipe->pipe.render_condition = softpipe_render_condition;
+   
+   softpipe->pipe.create_video_decoder = vl_create_decoder;
+   softpipe->pipe.create_video_buffer = vl_video_buffer_create;
 
    /*
     * Alloc caches for accessing drawing surfaces and textures.
@@ -341,6 +355,11 @@ softpipe_create_context( struct pipe_screen *screen,
 
    sp_init_surface_functions(softpipe);
 
+#if DO_PSTIPPLE_IN_HELPER_MODULE
+   /* create the polgon stipple sampler */
+   softpipe->pstipple.sampler = util_pstipple_create_sampler(&softpipe->pipe);
+#endif
+
    return &softpipe->pipe;
 
  fail:
index a572ee8..410b0a6 100644 (file)
 #include "sp_quad_pipe.h"
 
 
-/** Do polygon stipple in the driver here, or in the draw module? */
-#define DO_PSTIPPLE_IN_DRAW_MODULE 1
+/** Do polygon stipple in the draw module? */
+#define DO_PSTIPPLE_IN_DRAW_MODULE 0
+
+/** Do polygon stipple with the util module? */
+#define DO_PSTIPPLE_IN_HELPER_MODULE 1
 
 
 struct softpipe_vbuf_render;
@@ -64,6 +67,7 @@ struct softpipe_context {
    struct pipe_depth_stencil_alpha_state *depth_stencil;
    struct pipe_rasterizer_state *rasterizer;
    struct sp_fragment_shader *fs;
+   struct sp_fragment_shader_variant *fs_variant;
    struct sp_vertex_shader *vs;
    struct sp_geometry_shader *gs;
    struct sp_velems_state *velems;
@@ -143,6 +147,13 @@ struct softpipe_context {
    struct pipe_query *render_cond_query;
    uint render_cond_mode;
 
+   /** Polygon stipple items */
+   struct {
+      struct pipe_resource *texture;
+      struct pipe_sampler_state *sampler;
+      struct pipe_sampler_view *sampler_view;
+   } pstipple;
+
    /** Software quad rendering pipeline */
    struct {
       struct quad_stage *shade;
index 01b4ca9..69b5b96 100644 (file)
@@ -64,7 +64,7 @@ softpipe_draw_stream_output(struct pipe_context *pipe, unsigned mode)
    sp->reduced_api_prim = u_reduced_prim(mode);
 
    if (sp->dirty) {
-      softpipe_update_derived(sp);
+      softpipe_update_derived(sp, sp->reduced_api_prim);
    }
 
    softpipe_map_transfers(sp);
@@ -122,7 +122,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
    sp->reduced_api_prim = u_reduced_prim(info->mode);
 
    if (sp->dirty) {
-      softpipe_update_derived(sp);
+      softpipe_update_derived(sp, sp->reduced_api_prim);
    }
 
    softpipe_map_transfers(sp);
index 4792ace..d46d7d5 100644 (file)
 #ifndef SP_FS_H
 #define SP_FS_H
 
-struct sp_fragment_shader *
-softpipe_create_fs_exec(struct softpipe_context *softpipe,
-                      const struct pipe_shader_state *templ);
 
-struct sp_fragment_shader *
-softpipe_create_fs_sse(struct softpipe_context *softpipe,
-                      const struct pipe_shader_state *templ);
+struct sp_fragment_shader_variant *
+softpipe_create_fs_variant_exec(struct softpipe_context *softpipe,
+                                const struct pipe_shader_state *templ);
+
+struct sp_fragment_shader_variant *
+softpipe_create_fs_variant_sse(struct softpipe_context *softpipe,
+                               const struct pipe_shader_state *templ);
 
-struct sp_fragment_shader *
-softpipe_create_fs_llvm(struct softpipe_context *softpipe,
-                       const struct pipe_shader_state *templ);
 
 struct tgsi_interp_coef;
 struct tgsi_exec_vector;
index 346e1b4..779b8c4 100644 (file)
 
 
 /**
- * Subclass of sp_fragment_shader
+ * Subclass of sp_fragment_shader_variant
  */
 struct sp_exec_fragment_shader
 {
-   struct sp_fragment_shader base;
+   struct sp_fragment_shader_variant base;
    /* No other members for now */
 };
 
 
 /** cast wrapper */
 static INLINE struct sp_exec_fragment_shader *
-sp_exec_fragment_shader(const struct sp_fragment_shader *base)
+sp_exec_fragment_shader(const struct sp_fragment_shader_variant *var)
 {
-   return (struct sp_exec_fragment_shader *) base;
+   return (struct sp_exec_fragment_shader *) var;
 }
 
 
 static void
-exec_prepare( const struct sp_fragment_shader *base,
+exec_prepare( const struct sp_fragment_shader_variant *var,
              struct tgsi_exec_machine *machine,
              struct tgsi_sampler **samplers )
 {
@@ -68,9 +68,9 @@ exec_prepare( const struct sp_fragment_shader *base,
     * Bind tokens/shader to the interpreter's machine state.
     * Avoid redundant binding.
     */
-   if (machine->Tokens != base->shader.tokens) {
+   if (machine->Tokens != var->tokens) {
       tgsi_exec_machine_bind_shader( machine,
-                                     base->shader.tokens,
+                                     var->tokens,
                                      PIPE_MAX_SAMPLERS,
                                      samplers );
    }
@@ -118,7 +118,7 @@ setup_pos_vector(const struct tgsi_interp_coef *coef,
  * interface:
  */
 static unsigned 
-exec_run( const struct sp_fragment_shader *base,
+exec_run( const struct sp_fragment_shader_variant *var,
          struct tgsi_exec_machine *machine,
          struct quad_header *quad )
 {
@@ -136,9 +136,9 @@ exec_run( const struct sp_fragment_shader *base,
 
    /* store outputs */
    {
-      const ubyte *sem_name = base->info.output_semantic_name;
-      const ubyte *sem_index = base->info.output_semantic_index;
-      const uint n = base->info.num_outputs;
+      const ubyte *sem_name = var->info.output_semantic_name;
+      const ubyte *sem_index = var->info.output_semantic_index;
+      const uint n = var->info.num_outputs;
       uint i;
       for (i = 0; i < n; i++) {
          switch (sem_name[i]) {
@@ -180,29 +180,23 @@ exec_run( const struct sp_fragment_shader *base,
 
 
 static void 
-exec_delete( struct sp_fragment_shader *base )
+exec_delete( struct sp_fragment_shader_variant *var )
 {
-   FREE((void *) base->shader.tokens);
-   FREE(base);
+   FREE( (void *) var->tokens );
+   FREE(var);
 }
 
 
-struct sp_fragment_shader *
-softpipe_create_fs_exec(struct softpipe_context *softpipe,
-                       const struct pipe_shader_state *templ)
+struct sp_fragment_shader_variant *
+softpipe_create_fs_variant_exec(struct softpipe_context *softpipe,
+                                const struct pipe_shader_state *templ)
 {
    struct sp_exec_fragment_shader *shader;
 
-   /* Decide whether we'll be codegenerating this shader and if so do
-    * that now.
-    */
-
    shader = CALLOC_STRUCT(sp_exec_fragment_shader);
    if (!shader)
       return NULL;
 
-   /* we need to keep a local copy of the tokens */
-   shader->base.shader.tokens = tgsi_dup_tokens(templ->tokens);
    shader->base.prepare = exec_prepare;
    shader->base.run = exec_run;
    shader->base.delete = exec_delete;
index 5b18cd0..c873af1 100644 (file)
 
 
 /**
- * Subclass of sp_fragment_shader
+ * Subclass of sp_fragment_shader_variant
  */
 struct sp_sse_fragment_shader
 {
-   struct sp_fragment_shader base;
+   struct sp_fragment_shader_variant base;
    struct x86_function sse2_program;
    tgsi_sse2_fs_function func;
    float immediates[TGSI_EXEC_NUM_IMMEDIATES][4];
@@ -61,14 +61,14 @@ struct sp_sse_fragment_shader
 
 /** cast wrapper */
 static INLINE struct sp_sse_fragment_shader *
-sp_sse_fragment_shader(const struct sp_fragment_shader *base)
+sp_sse_fragment_shader(const struct sp_fragment_shader_variant *base)
 {
    return (struct sp_sse_fragment_shader *) base;
 }
 
 
 static void
-fs_sse_prepare( const struct sp_fragment_shader *base,
+fs_sse_prepare( const struct sp_fragment_shader_variant *base,
                struct tgsi_exec_machine *machine,
                struct tgsi_sampler **samplers )
 {
@@ -119,7 +119,7 @@ setup_pos_vector(const struct tgsi_interp_coef *coef,
  * TODO: process >1 quad at a time
  */
 static unsigned 
-fs_sse_run( const struct sp_fragment_shader *base,
+fs_sse_run( const struct sp_fragment_shader_variant *base,
            struct tgsi_exec_machine *machine,
            struct quad_header *quad )
 {
@@ -189,7 +189,7 @@ fs_sse_run( const struct sp_fragment_shader *base,
 
 
 static void 
-fs_sse_delete( struct sp_fragment_shader *base )
+fs_sse_delete( struct sp_fragment_shader_variant *base )
 {
    struct sp_sse_fragment_shader *shader = sp_sse_fragment_shader(base);
 
@@ -198,9 +198,9 @@ fs_sse_delete( struct sp_fragment_shader *base )
 }
 
 
-struct sp_fragment_shader *
-softpipe_create_fs_sse(struct softpipe_context *softpipe,
-                      const struct pipe_shader_state *templ)
+struct sp_fragment_shader_variant *
+softpipe_create_fs_variant_sse(struct softpipe_context *softpipe,
+                               const struct pipe_shader_state *templ)
 {
    struct sp_sse_fragment_shader *shader;
 
@@ -226,7 +226,6 @@ softpipe_create_fs_sse(struct softpipe_context *softpipe,
       return NULL;
    }
 
-   shader->base.shader.tokens = NULL; /* don't hold reference to templ->tokens */
    shader->base.prepare = fs_sse_prepare;
    shader->base.run = fs_sse_run;
    shader->base.delete = fs_sse_delete;
@@ -239,9 +238,9 @@ softpipe_create_fs_sse(struct softpipe_context *softpipe,
 
 /* Maybe put this variant in the header file.
  */
-struct sp_fragment_shader *
-softpipe_create_fs_sse(struct softpipe_context *softpipe,
-                      const struct pipe_shader_state *templ)
+struct sp_fragment_shader_variant *
+softpipe_create_fs_variant_sse(struct softpipe_context *softpipe,
+                               const struct pipe_shader_state *templ)
 {
    return NULL;
 }
index 76cfc0b..c881194 100644 (file)
@@ -240,6 +240,7 @@ blend_quad(struct quad_stage *qs,
    static const float one[4] = { 1, 1, 1, 1 };
    struct softpipe_context *softpipe = qs->softpipe;
    float source[4][QUAD_SIZE] = { { 0 } };
+   float blend_dest[4][QUAD_SIZE];
 
    /*
     * Compute src/first term RGB
@@ -480,79 +481,85 @@ blend_quad(struct quad_stage *qs,
       assert(0 && "invalid alpha src factor");
    }
 
+   /* Save the original dest for use in masking */
+   VEC4_COPY(blend_dest[0], dest[0]);
+   VEC4_COPY(blend_dest[1], dest[1]);
+   VEC4_COPY(blend_dest[2], dest[2]);
+   VEC4_COPY(blend_dest[3], dest[3]);
+
 
    /*
-    * Compute dest/second term RGB
+    * Compute blend_dest/second term RGB
     */
    switch (softpipe->blend->rt[blend_index].rgb_dst_factor) {
    case PIPE_BLENDFACTOR_ONE:
-      /* dest = dest * 1   NO-OP, leave dest as-is */
+      /* blend_dest = blend_dest * 1   NO-OP, leave blend_dest as-is */
       break;
    case PIPE_BLENDFACTOR_SRC_COLOR:
-      VEC4_MUL(dest[0], dest[0], quadColor[0]); /* R */
-      VEC4_MUL(dest[1], dest[1], quadColor[1]); /* G */
-      VEC4_MUL(dest[2], dest[2], quadColor[2]); /* B */
+      VEC4_MUL(blend_dest[0], blend_dest[0], quadColor[0]); /* R */
+      VEC4_MUL(blend_dest[1], blend_dest[1], quadColor[1]); /* G */
+      VEC4_MUL(blend_dest[2], blend_dest[2], quadColor[2]); /* B */
       break;
    case PIPE_BLENDFACTOR_SRC_ALPHA:
-      VEC4_MUL(dest[0], dest[0], quadColor[3]); /* R * A */
-      VEC4_MUL(dest[1], dest[1], quadColor[3]); /* G * A */
-      VEC4_MUL(dest[2], dest[2], quadColor[3]); /* B * A */
+      VEC4_MUL(blend_dest[0], blend_dest[0], quadColor[3]); /* R * A */
+      VEC4_MUL(blend_dest[1], blend_dest[1], quadColor[3]); /* G * A */
+      VEC4_MUL(blend_dest[2], blend_dest[2], quadColor[3]); /* B * A */
       break;
    case PIPE_BLENDFACTOR_DST_ALPHA:
       if (has_dst_alpha) {
-         VEC4_MUL(dest[0], dest[0], dest[3]); /* R * A */
-         VEC4_MUL(dest[1], dest[1], dest[3]); /* G * A */
-         VEC4_MUL(dest[2], dest[2], dest[3]); /* B * A */
+         VEC4_MUL(blend_dest[0], blend_dest[0], blend_dest[3]); /* R * A */
+         VEC4_MUL(blend_dest[1], blend_dest[1], blend_dest[3]); /* G * A */
+         VEC4_MUL(blend_dest[2], blend_dest[2], blend_dest[3]); /* B * A */
       }
       else {
-         /* dest = dest * 1   NO-OP, leave dest as-is */
+         /* blend_dest = blend_dest * 1   NO-OP, leave blend_dest as-is */
       }
       break;
    case PIPE_BLENDFACTOR_DST_COLOR:
-      VEC4_MUL(dest[0], dest[0], dest[0]); /* R */
-      VEC4_MUL(dest[1], dest[1], dest[1]); /* G */
-      VEC4_MUL(dest[2], dest[2], dest[2]); /* B */
+      VEC4_MUL(blend_dest[0], blend_dest[0], blend_dest[0]); /* R */
+      VEC4_MUL(blend_dest[1], blend_dest[1], blend_dest[1]); /* G */
+      VEC4_MUL(blend_dest[2], blend_dest[2], blend_dest[2]); /* B */
       break;
    case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
       if (has_dst_alpha) {
          const float *alpha = quadColor[3];
          float diff[4], temp[4];
-         VEC4_SUB(diff, one, dest[3]);
+         VEC4_SUB(diff, one, blend_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 */
+         VEC4_MUL(blend_dest[0], quadColor[0], temp); /* R */
+         VEC4_MUL(blend_dest[1], quadColor[1], temp); /* G */
+         VEC4_MUL(blend_dest[2], quadColor[2], temp); /* B */
       }
       else {
-         VEC4_COPY(dest[0], zero); /* R */
-         VEC4_COPY(dest[1], zero); /* G */
-         VEC4_COPY(dest[2], zero); /* B */
+         VEC4_COPY(blend_dest[0], zero); /* R */
+         VEC4_COPY(blend_dest[1], zero); /* G */
+         VEC4_COPY(blend_dest[2], zero); /* B */
       }
       break;
    case PIPE_BLENDFACTOR_CONST_COLOR:
    {
       float comp[4];
       VEC4_SCALAR(comp, softpipe->blend_color.color[0]); /* R */
-      VEC4_MUL(dest[0], dest[0], comp); /* R */
+      VEC4_MUL(blend_dest[0], blend_dest[0], comp); /* R */
       VEC4_SCALAR(comp, softpipe->blend_color.color[1]); /* G */
-      VEC4_MUL(dest[1], dest[1], comp); /* G */
+      VEC4_MUL(blend_dest[1], blend_dest[1], comp); /* G */
       VEC4_SCALAR(comp, softpipe->blend_color.color[2]); /* B */
-      VEC4_MUL(dest[2], dest[2], comp); /* B */
+      VEC4_MUL(blend_dest[2], blend_dest[2], comp); /* B */
    }
    break;
    case PIPE_BLENDFACTOR_CONST_ALPHA:
    {
       float comp[4];
       VEC4_SCALAR(comp, softpipe->blend_color.color[3]); /* A */
-      VEC4_MUL(dest[0], dest[0], comp); /* R */
-      VEC4_MUL(dest[1], dest[1], comp); /* G */
-      VEC4_MUL(dest[2], dest[2], comp); /* B */
+      VEC4_MUL(blend_dest[0], blend_dest[0], comp); /* R */
+      VEC4_MUL(blend_dest[1], blend_dest[1], comp); /* G */
+      VEC4_MUL(blend_dest[2], blend_dest[2], comp); /* B */
    }
    break;
    case PIPE_BLENDFACTOR_ZERO:
-      VEC4_COPY(dest[0], zero); /* R */
-      VEC4_COPY(dest[1], zero); /* G */
-      VEC4_COPY(dest[2], zero); /* B */
+      VEC4_COPY(blend_dest[0], zero); /* R */
+      VEC4_COPY(blend_dest[1], zero); /* G */
+      VEC4_COPY(blend_dest[2], zero); /* B */
       break;
    case PIPE_BLENDFACTOR_SRC1_COLOR:
    case PIPE_BLENDFACTOR_SRC1_ALPHA:
@@ -563,45 +570,45 @@ blend_quad(struct quad_stage *qs,
    {
       float inv_comp[4];
       VEC4_SUB(inv_comp, one, quadColor[0]); /* R */
-      VEC4_MUL(dest[0], inv_comp, dest[0]); /* R */
+      VEC4_MUL(blend_dest[0], inv_comp, blend_dest[0]); /* R */
       VEC4_SUB(inv_comp, one, quadColor[1]); /* G */
-      VEC4_MUL(dest[1], inv_comp, dest[1]); /* G */
+      VEC4_MUL(blend_dest[1], inv_comp, blend_dest[1]); /* G */
       VEC4_SUB(inv_comp, one, quadColor[2]); /* B */
-      VEC4_MUL(dest[2], inv_comp, dest[2]); /* B */
+      VEC4_MUL(blend_dest[2], inv_comp, blend_dest[2]); /* B */
    }
    break;
    case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
    {
       float one_minus_alpha[QUAD_SIZE];
       VEC4_SUB(one_minus_alpha, one, quadColor[3]);
-      VEC4_MUL(dest[0], dest[0], one_minus_alpha); /* R */
-      VEC4_MUL(dest[1], dest[1], one_minus_alpha); /* G */
-      VEC4_MUL(dest[2], dest[2], one_minus_alpha); /* B */
+      VEC4_MUL(blend_dest[0], blend_dest[0], one_minus_alpha); /* R */
+      VEC4_MUL(blend_dest[1], blend_dest[1], one_minus_alpha); /* G */
+      VEC4_MUL(blend_dest[2], blend_dest[2], one_minus_alpha); /* B */
    }
    break;
    case PIPE_BLENDFACTOR_INV_DST_ALPHA:
       if (has_dst_alpha) {
          float inv_comp[4];
-         VEC4_SUB(inv_comp, one, dest[3]); /* A */
-         VEC4_MUL(dest[0], inv_comp, dest[0]); /* R */
-         VEC4_MUL(dest[1], inv_comp, dest[1]); /* G */
-         VEC4_MUL(dest[2], inv_comp, dest[2]); /* B */
+         VEC4_SUB(inv_comp, one, blend_dest[3]); /* A */
+         VEC4_MUL(blend_dest[0], inv_comp, blend_dest[0]); /* R */
+         VEC4_MUL(blend_dest[1], inv_comp, blend_dest[1]); /* G */
+         VEC4_MUL(blend_dest[2], inv_comp, blend_dest[2]); /* B */
       }
       else {
-         VEC4_COPY(dest[0], zero); /* R */
-         VEC4_COPY(dest[1], zero); /* G */
-         VEC4_COPY(dest[2], zero); /* B */
+         VEC4_COPY(blend_dest[0], zero); /* R */
+         VEC4_COPY(blend_dest[1], zero); /* G */
+         VEC4_COPY(blend_dest[2], zero); /* B */
       }
    break;
    case PIPE_BLENDFACTOR_INV_DST_COLOR:
    {
       float inv_comp[4];
-      VEC4_SUB(inv_comp, one, dest[0]); /* R */
-      VEC4_MUL(dest[0], dest[0], inv_comp); /* R */
-      VEC4_SUB(inv_comp, one, dest[1]); /* G */
-      VEC4_MUL(dest[1], dest[1], inv_comp); /* G */
-      VEC4_SUB(inv_comp, one, dest[2]); /* B */
-      VEC4_MUL(dest[2], dest[2], inv_comp); /* B */
+      VEC4_SUB(inv_comp, one, blend_dest[0]); /* R */
+      VEC4_MUL(blend_dest[0], blend_dest[0], inv_comp); /* R */
+      VEC4_SUB(inv_comp, one, blend_dest[1]); /* G */
+      VEC4_MUL(blend_dest[1], blend_dest[1], inv_comp); /* G */
+      VEC4_SUB(inv_comp, one, blend_dest[2]); /* B */
+      VEC4_MUL(blend_dest[2], blend_dest[2], inv_comp); /* B */
    }
    break;
    case PIPE_BLENDFACTOR_INV_CONST_COLOR:
@@ -609,22 +616,22 @@ blend_quad(struct quad_stage *qs,
       float inv_comp[4];
       /* R */
       VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[0]);
-      VEC4_MUL(dest[0], dest[0], inv_comp);
+      VEC4_MUL(blend_dest[0], blend_dest[0], inv_comp);
       /* G */
       VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[1]);
-      VEC4_MUL(dest[1], dest[1], inv_comp);
+      VEC4_MUL(blend_dest[1], blend_dest[1], inv_comp);
       /* B */
       VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[2]);
-      VEC4_MUL(dest[2], dest[2], inv_comp);
+      VEC4_MUL(blend_dest[2], blend_dest[2], inv_comp);
    }
    break;
    case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
    {
       float inv_comp[4];
       VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[3]);
-      VEC4_MUL(dest[0], dest[0], inv_comp);
-      VEC4_MUL(dest[1], dest[1], inv_comp);
-      VEC4_MUL(dest[2], dest[2], inv_comp);
+      VEC4_MUL(blend_dest[0], blend_dest[0], inv_comp);
+      VEC4_MUL(blend_dest[1], blend_dest[1], inv_comp);
+      VEC4_MUL(blend_dest[2], blend_dest[2], inv_comp);
    }
    break;
    case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
@@ -637,29 +644,29 @@ blend_quad(struct quad_stage *qs,
    }
 
    /*
-    * Compute dest/second term A
+    * Compute blend_dest/second term A
     */
    switch (softpipe->blend->rt[blend_index].alpha_dst_factor) {
    case PIPE_BLENDFACTOR_ONE:
-      /* dest = dest * 1   NO-OP, leave dest as-is */
+      /* blend_dest = blend_dest * 1   NO-OP, leave blend_dest as-is */
       break;
    case PIPE_BLENDFACTOR_SRC_COLOR:
       /* fall-through */
    case PIPE_BLENDFACTOR_SRC_ALPHA:
-      VEC4_MUL(dest[3], dest[3], quadColor[3]); /* A * A */
+      VEC4_MUL(blend_dest[3], blend_dest[3], quadColor[3]); /* A * A */
       break;
    case PIPE_BLENDFACTOR_DST_COLOR:
       /* fall-through */
    case PIPE_BLENDFACTOR_DST_ALPHA:
       if (has_dst_alpha) {
-         VEC4_MUL(dest[3], dest[3], dest[3]); /* A */
+         VEC4_MUL(blend_dest[3], blend_dest[3], blend_dest[3]); /* A */
       }
       else {
-         /* dest = dest * 1   NO-OP, leave dest as-is */
+         /* blend_dest = blend_dest * 1   NO-OP, leave blend_dest as-is */
       }
       break;
    case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
-      /* dest = dest * 1   NO-OP, leave dest as-is */
+      /* blend_dest = blend_dest * 1   NO-OP, leave blend_dest as-is */
       break;
    case PIPE_BLENDFACTOR_CONST_COLOR:
       /* fall-through */
@@ -667,11 +674,11 @@ blend_quad(struct quad_stage *qs,
    {
       float comp[4];
       VEC4_SCALAR(comp, softpipe->blend_color.color[3]); /* A */
-      VEC4_MUL(dest[3], dest[3], comp); /* A */
+      VEC4_MUL(blend_dest[3], blend_dest[3], comp); /* A */
    }
    break;
    case PIPE_BLENDFACTOR_ZERO:
-      VEC4_COPY(dest[3], zero); /* A */
+      VEC4_COPY(blend_dest[3], zero); /* A */
       break;
    case PIPE_BLENDFACTOR_INV_SRC_COLOR:
       /* fall-through */
@@ -679,7 +686,7 @@ blend_quad(struct quad_stage *qs,
    {
       float one_minus_alpha[QUAD_SIZE];
       VEC4_SUB(one_minus_alpha, one, quadColor[3]);
-      VEC4_MUL(dest[3], dest[3], one_minus_alpha); /* A */
+      VEC4_MUL(blend_dest[3], blend_dest[3], one_minus_alpha); /* A */
    }
    break;
    case PIPE_BLENDFACTOR_INV_DST_COLOR:
@@ -687,11 +694,11 @@ blend_quad(struct quad_stage *qs,
    case PIPE_BLENDFACTOR_INV_DST_ALPHA:
       if (has_dst_alpha) {
          float inv_comp[4];
-         VEC4_SUB(inv_comp, one, dest[3]); /* A */
-         VEC4_MUL(dest[3], inv_comp, dest[3]); /* A */
+         VEC4_SUB(inv_comp, one, blend_dest[3]); /* A */
+         VEC4_MUL(blend_dest[3], inv_comp, blend_dest[3]); /* A */
       }
       else {
-         VEC4_COPY(dest[3], zero); /* A */
+         VEC4_COPY(blend_dest[3], zero); /* A */
       }
       break;
    case PIPE_BLENDFACTOR_INV_CONST_COLOR:
@@ -700,7 +707,7 @@ blend_quad(struct quad_stage *qs,
    {
       float inv_comp[4];
       VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[3]);
-      VEC4_MUL(dest[3], dest[3], inv_comp);
+      VEC4_MUL(blend_dest[3], blend_dest[3], inv_comp);
    }
    break;
    default:
@@ -712,29 +719,29 @@ blend_quad(struct quad_stage *qs,
     */
    switch (softpipe->blend->rt[blend_index].rgb_func) {
    case PIPE_BLEND_ADD:
-      VEC4_ADD_SAT(quadColor[0], source[0], dest[0]); /* R */
-      VEC4_ADD_SAT(quadColor[1], source[1], dest[1]); /* G */
-      VEC4_ADD_SAT(quadColor[2], source[2], dest[2]); /* B */
+      VEC4_ADD_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
+      VEC4_ADD_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
+      VEC4_ADD_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
       break;
    case PIPE_BLEND_SUBTRACT:
-      VEC4_SUB_SAT(quadColor[0], source[0], dest[0]); /* R */
-      VEC4_SUB_SAT(quadColor[1], source[1], dest[1]); /* G */
-      VEC4_SUB_SAT(quadColor[2], source[2], dest[2]); /* B */
+      VEC4_SUB_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
+      VEC4_SUB_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
+      VEC4_SUB_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
       break;
    case PIPE_BLEND_REVERSE_SUBTRACT:
-      VEC4_SUB_SAT(quadColor[0], dest[0], source[0]); /* R */
-      VEC4_SUB_SAT(quadColor[1], dest[1], source[1]); /* G */
-      VEC4_SUB_SAT(quadColor[2], dest[2], source[2]); /* B */
+      VEC4_SUB_SAT(quadColor[0], blend_dest[0], source[0]); /* R */
+      VEC4_SUB_SAT(quadColor[1], blend_dest[1], source[1]); /* G */
+      VEC4_SUB_SAT(quadColor[2], blend_dest[2], source[2]); /* B */
       break;
    case PIPE_BLEND_MIN:
-      VEC4_MIN(quadColor[0], source[0], dest[0]); /* R */
-      VEC4_MIN(quadColor[1], source[1], dest[1]); /* G */
-      VEC4_MIN(quadColor[2], source[2], dest[2]); /* B */
+      VEC4_MIN(quadColor[0], source[0], blend_dest[0]); /* R */
+      VEC4_MIN(quadColor[1], source[1], blend_dest[1]); /* G */
+      VEC4_MIN(quadColor[2], source[2], blend_dest[2]); /* B */
       break;
    case PIPE_BLEND_MAX:
-      VEC4_MAX(quadColor[0], source[0], dest[0]); /* R */
-      VEC4_MAX(quadColor[1], source[1], dest[1]); /* G */
-      VEC4_MAX(quadColor[2], source[2], dest[2]); /* B */
+      VEC4_MAX(quadColor[0], source[0], blend_dest[0]); /* R */
+      VEC4_MAX(quadColor[1], source[1], blend_dest[1]); /* G */
+      VEC4_MAX(quadColor[2], source[2], blend_dest[2]); /* B */
       break;
    default:
       assert(0 && "invalid rgb blend func");
@@ -745,19 +752,19 @@ blend_quad(struct quad_stage *qs,
     */
    switch (softpipe->blend->rt[blend_index].alpha_func) {
    case PIPE_BLEND_ADD:
-      VEC4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */
+      VEC4_ADD_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
       break;
    case PIPE_BLEND_SUBTRACT:
-      VEC4_SUB_SAT(quadColor[3], source[3], dest[3]); /* A */
+      VEC4_SUB_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
       break;
    case PIPE_BLEND_REVERSE_SUBTRACT:
-      VEC4_SUB_SAT(quadColor[3], dest[3], source[3]); /* A */
+      VEC4_SUB_SAT(quadColor[3], blend_dest[3], source[3]); /* A */
       break;
    case PIPE_BLEND_MIN:
-      VEC4_MIN(quadColor[3], source[3], dest[3]); /* A */
+      VEC4_MIN(quadColor[3], source[3], blend_dest[3]); /* A */
       break;
    case PIPE_BLEND_MAX:
-      VEC4_MAX(quadColor[3], source[3], dest[3]); /* A */
+      VEC4_MAX(quadColor[3], source[3], blend_dest[3]); /* A */
       break;
    default:
       assert(0 && "invalid alpha blend func");
@@ -797,7 +804,7 @@ blend_fallback(struct quad_stage *qs,
    unsigned cbuf;
    boolean write_all;
 
-   write_all = softpipe->fs->color0_writes_all_cbufs;
+   write_all = softpipe->fs_variant->info.color0_writes_all_cbufs;
 
    for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++) 
    {
@@ -810,17 +817,25 @@ blend_fallback(struct quad_stage *qs,
                               quads[0]->input.y0);
       boolean has_dst_alpha
          = util_format_has_alpha(softpipe->framebuffer.cbufs[cbuf]->format);
-      uint q, i, j, qbuf;
-
-      qbuf = write_all ? 0 : cbuf;
+      uint q, i, j;
 
       for (q = 0; q < nr; q++) {
          struct quad_header *quad = quads[q];
          float (*quadColor)[4];
+         float temp_quad_color[QUAD_SIZE][4];
          const int itx = (quad->input.x0 & (TILE_SIZE-1));
          const int ity = (quad->input.y0 & (TILE_SIZE-1));
 
-         quadColor = quad->output.color[qbuf];
+         if (write_all) {
+            for (j = 0; j < QUAD_SIZE; j++) {
+               for (i = 0; i < 4; i++) {
+                  temp_quad_color[i][j] = quad->output.color[0][i][j];
+               }
+            }
+            quadColor = temp_quad_color;
+         } else {
+            quadColor = quad->output.color[cbuf];
+         }
 
          /* get/swizzle dest colors
           */
index 89b2a91..a349f0d 100644 (file)
@@ -189,7 +189,8 @@ convert_quad_depth( struct depth_data *data,
 
 
 /**
- * Compute the depth_data::shader_stencil_refs[] values from the float fragment stencil values.
+ * Compute the depth_data::shader_stencil_refs[] values from the float
+ * fragment stencil values.
  */
 static void
 convert_quad_stencil( struct depth_data *data, 
@@ -205,10 +206,9 @@ convert_quad_stencil( struct depth_data *data,
    case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
    case PIPE_FORMAT_X8Z24_UNORM:
    case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
-      {
-         for (j = 0; j < QUAD_SIZE; j++) {
-            data->shader_stencil_refs[j] = ((unsigned)(quad->output.stencil[j]));
-         }
+   case PIPE_FORMAT_S8_USCALED:
+      for (j = 0; j < QUAD_SIZE; j++) {
+         data->shader_stencil_refs[j] = ((unsigned)(quad->output.stencil[j]));
       }
       break;
    default:
@@ -216,6 +216,7 @@ convert_quad_stencil( struct depth_data *data,
    }
 }
 
+
 /**
  * Write data->bzzzz[] values and data->stencilVals into the Z/stencil buffer.
  */
@@ -726,9 +727,9 @@ depth_test_quads_fallback(struct quad_stage *qs,
                           unsigned nr)
 {
    unsigned i, pass = 0;
-   const struct sp_fragment_shader *fs = qs->softpipe->fs;
-   boolean interp_depth = !fs->info.writes_z;
-   boolean shader_stencil_ref = fs->info.writes_stencil;
+   const struct tgsi_shader_info *fsInfo = &qs->softpipe->fs_variant->info;
+   boolean interp_depth = !fsInfo->writes_z;
+   boolean shader_stencil_ref = fsInfo->writes_stencil;
    struct depth_data data;
 
    data.use_shader_stencil_refs = FALSE;
@@ -837,7 +838,9 @@ choose_depth_test(struct quad_stage *qs,
                   struct quad_header *quads[],
                   unsigned nr)
 {
-   boolean interp_depth = !qs->softpipe->fs->info.writes_z;
+   const struct tgsi_shader_info *fsInfo = &qs->softpipe->fs_variant->info;
+
+   boolean interp_depth = !fsInfo->writes_z;
 
    boolean alpha = qs->softpipe->depth_stencil->alpha.enabled;
 
index 90f4787..d74d6d4 100644 (file)
@@ -74,7 +74,7 @@ shade_quad(struct quad_stage *qs, struct quad_header *quad)
    struct tgsi_exec_machine *machine = softpipe->fs_machine;
 
    /* run shader */
-   return softpipe->fs->run( softpipe->fs, machine, quad );
+   return softpipe->fs_variant->run( softpipe->fs_variant, machine, quad );
 }
 
 
@@ -140,10 +140,10 @@ shade_begin(struct quad_stage *qs)
 {
    struct softpipe_context *softpipe = qs->softpipe;
 
-   softpipe->fs->prepare( softpipe->fs
-                         softpipe->fs_machine,
-                         (struct tgsi_sampler **)
-                             softpipe->tgsi.frag_samplers_list );
+   softpipe->fs_variant->prepare( softpipe->fs_variant
+                                  softpipe->fs_machine,
+                                  (struct tgsi_sampler **)
+                                  softpipe->tgsi.frag_samplers_list );
 
    qs->next->begin(qs->next);
 }
index 2cfd02a..0c4506a 100644 (file)
@@ -30,9 +30,9 @@
 #include "sp_state.h"
 #include "pipe/p_shader_tokens.h"
 
+
 static void
-sp_push_quad_first( struct softpipe_context *sp,
-                    struct quad_stage *quad )
+insert_stage_at_head(struct softpipe_context *sp, struct quad_stage *quad)
 {
    quad->next = sp->quad.first;
    sp->quad.first = quad;
@@ -46,24 +46,24 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
       sp->depth_stencil->depth.enabled &&
       sp->framebuffer.zsbuf &&
       !sp->depth_stencil->alpha.enabled &&
-      !sp->fs->info.uses_kill &&
-      !sp->fs->info.writes_z &&
-      !sp->fs->info.writes_stencil;
+      !sp->fs_variant->info.uses_kill &&
+      !sp->fs_variant->info.writes_z &&
+      !sp->fs_variant->info.writes_stencil;
 
    sp->quad.first = sp->quad.blend;
 
    if (early_depth_test) {
-      sp_push_quad_first( sp, sp->quad.shade );
-      sp_push_quad_first( sp, sp->quad.depth_test );
+      insert_stage_at_head( sp, sp->quad.shade );
+      insert_stage_at_head( sp, sp->quad.depth_test );
    }
    else {
-      sp_push_quad_first( sp, sp->quad.depth_test );
-      sp_push_quad_first( sp, sp->quad.shade );
+      insert_stage_at_head( sp, sp->quad.depth_test );
+      insert_stage_at_head( sp, sp->quad.shade );
    }
 
-#if !DO_PSTIPPLE_IN_DRAW_MODULE
+#if !DO_PSTIPPLE_IN_DRAW_MODULE && !DO_PSTIPPLE_IN_HELPER_MODULE
    if (sp->rasterizer->poly_stipple_enable)
-      sp_push_quad_first( sp, sp->quad.pstipple );
+      insert_stage_at_head( sp, sp->quad.pstipple );
 #endif
 }
 
index 30f53a9..1e58d27 100644 (file)
@@ -1,8 +1,8 @@
 /**************************************************************************
- * 
+ *
  * 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
  * distribute, sub license, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
  * the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 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_format.h"
 #include "util/u_format_s3tc.h"
+#include "util/u_video.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 #include "draw/draw_context.h"
+#include "vl/vl_decoder.h"
+#include "vl/vl_video_buffer.h"
 
 #include "state_tracker/sw_winsys.h"
 #include "tgsi/tgsi_exec.h"
@@ -169,6 +172,23 @@ softpipe_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
    }
 }
 
+static int
+softpipe_get_video_param(struct pipe_screen *screen,
+                         enum pipe_video_profile profile,
+                         enum pipe_video_cap param)
+{
+   switch (param) {
+   case PIPE_VIDEO_CAP_SUPPORTED:
+       return vl_profile_supported(screen, profile);
+   case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+      return 0;
+   case PIPE_VIDEO_CAP_MAX_WIDTH:
+   case PIPE_VIDEO_CAP_MAX_HEIGHT:
+      return vl_video_buffer_max_size(screen);
+   default:
+      return 0;
+   }
+}
 
 /**
  * Query format support for creating a texture, drawing surface, etc.
@@ -307,7 +327,9 @@ softpipe_create_screen(struct sw_winsys *winsys)
    screen->base.get_param = softpipe_get_param;
    screen->base.get_shader_param = softpipe_get_shader_param;
    screen->base.get_paramf = softpipe_get_paramf;
+   screen->base.get_video_param = softpipe_get_video_param;
    screen->base.is_format_supported = softpipe_is_format_supported;
+   screen->base.is_video_format_supported = vl_video_buffer_is_format_supported;
    screen->base.context_create = softpipe_create_context;
    screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
 
index 0ce28f4..656d001 100644 (file)
@@ -568,17 +568,18 @@ tri_persp_coeff(struct setup_context *setup,
 static void
 setup_fragcoord_coeff(struct setup_context *setup, uint slot)
 {
-   struct sp_fragment_shader* spfs = setup->softpipe->fs;
+   const struct tgsi_shader_info *fsInfo = &setup->softpipe->fs_variant->info;
+
    /*X*/
-   setup->coef[slot].a0[0] = spfs->pixel_center_integer ? 0.0 : 0.5;
+   setup->coef[slot].a0[0] = fsInfo->pixel_center_integer ? 0.0 : 0.5;
    setup->coef[slot].dadx[0] = 1.0;
    setup->coef[slot].dady[0] = 0.0;
    /*Y*/
    setup->coef[slot].a0[1] =
-                  (spfs->origin_lower_left ? setup->softpipe->framebuffer.height-1 : 0)
-                  + (spfs->pixel_center_integer ? 0.0 : 0.5);
+                  (fsInfo->origin_lower_left ? setup->softpipe->framebuffer.height-1 : 0)
+                  + (fsInfo->pixel_center_integer ? 0.0 : 0.5);
    setup->coef[slot].dadx[1] = 0.0;
-   setup->coef[slot].dady[1] = spfs->origin_lower_left ? -1.0 : 1.0;
+   setup->coef[slot].dady[1] = fsInfo->origin_lower_left ? -1.0 : 1.0;
    /*Z*/
    setup->coef[slot].a0[2] = setup->posCoef.a0[2];
    setup->coef[slot].dadx[2] = setup->posCoef.dadx[2];
@@ -599,7 +600,7 @@ static void
 setup_tri_coefficients(struct setup_context *setup)
 {
    struct softpipe_context *softpipe = setup->softpipe;
-   const struct sp_fragment_shader *spfs = softpipe->fs;
+   const struct tgsi_shader_info *fsInfo = &setup->softpipe->fs_variant->info;
    const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
    uint fragSlot;
    float v[3];
@@ -618,7 +619,7 @@ setup_tri_coefficients(struct setup_context *setup)
 
    /* setup interpolation for all the remaining attributes:
     */
-   for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
+   for (fragSlot = 0; fragSlot < fsInfo->num_inputs; fragSlot++) {
       const uint vertSlot = vinfo->attrib[fragSlot].src_index;
       uint j;
 
@@ -632,7 +633,7 @@ setup_tri_coefficients(struct setup_context *setup)
             tri_apply_cylindrical_wrap(setup->vmin[vertSlot][j],
                                        setup->vmid[vertSlot][j],
                                        setup->vmax[vertSlot][j],
-                                       spfs->info.input_cylindrical_wrap[fragSlot] & (1 << j),
+                                       fsInfo->input_cylindrical_wrap[fragSlot] & (1 << j),
                                        v);
             tri_linear_coeff(setup, &setup->coef[fragSlot], j, v);
          }
@@ -642,7 +643,7 @@ setup_tri_coefficients(struct setup_context *setup)
             tri_apply_cylindrical_wrap(setup->vmin[vertSlot][j],
                                        setup->vmid[vertSlot][j],
                                        setup->vmax[vertSlot][j],
-                                       spfs->info.input_cylindrical_wrap[fragSlot] & (1 << j),
+                                       fsInfo->input_cylindrical_wrap[fragSlot] & (1 << j),
                                        v);
             tri_persp_coeff(setup, &setup->coef[fragSlot], j, v);
          }
@@ -654,7 +655,7 @@ setup_tri_coefficients(struct setup_context *setup)
          assert(0);
       }
 
-      if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
+      if (fsInfo->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
          /* convert 0 to 1.0 and 1 to -1.0 */
          setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
          setup->coef[fragSlot].dadx[0] = 0.0;
@@ -939,7 +940,7 @@ setup_line_coefficients(struct setup_context *setup,
                         const float (*v1)[4])
 {
    struct softpipe_context *softpipe = setup->softpipe;
-   const struct sp_fragment_shader *spfs = softpipe->fs;
+   const struct tgsi_shader_info *fsInfo = &setup->softpipe->fs_variant->info;
    const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
    uint fragSlot;
    float area;
@@ -974,7 +975,7 @@ setup_line_coefficients(struct setup_context *setup,
 
    /* setup interpolation for all the remaining attributes:
     */
-   for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
+   for (fragSlot = 0; fragSlot < fsInfo->num_inputs; fragSlot++) {
       const uint vertSlot = vinfo->attrib[fragSlot].src_index;
       uint j;
 
@@ -987,7 +988,7 @@ setup_line_coefficients(struct setup_context *setup,
          for (j = 0; j < NUM_CHANNELS; j++) {
             line_apply_cylindrical_wrap(setup->vmin[vertSlot][j],
                                         setup->vmax[vertSlot][j],
-                                        spfs->info.input_cylindrical_wrap[fragSlot] & (1 << j),
+                                        fsInfo->input_cylindrical_wrap[fragSlot] & (1 << j),
                                         v);
             line_linear_coeff(setup, &setup->coef[fragSlot], j, v);
          }
@@ -996,7 +997,7 @@ setup_line_coefficients(struct setup_context *setup,
          for (j = 0; j < NUM_CHANNELS; j++) {
             line_apply_cylindrical_wrap(setup->vmin[vertSlot][j],
                                         setup->vmax[vertSlot][j],
-                                        spfs->info.input_cylindrical_wrap[fragSlot] & (1 << j),
+                                        fsInfo->input_cylindrical_wrap[fragSlot] & (1 << j),
                                         v);
             line_persp_coeff(setup, &setup->coef[fragSlot], j, v);
          }
@@ -1008,7 +1009,7 @@ setup_line_coefficients(struct setup_context *setup,
          assert(0);
       }
 
-      if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
+      if (fsInfo->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
          /* convert 0 to 1.0 and 1 to -1.0 */
          setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
          setup->coef[fragSlot].dadx[0] = 0.0;
@@ -1188,7 +1189,7 @@ sp_setup_point(struct setup_context *setup,
                const float (*v0)[4])
 {
    struct softpipe_context *softpipe = setup->softpipe;
-   const struct sp_fragment_shader *spfs = softpipe->fs;
+   const struct tgsi_shader_info *fsInfo = &setup->softpipe->fs_variant->info;
    const int sizeAttr = setup->softpipe->psize_slot;
    const float size
       = sizeAttr > 0 ? v0[sizeAttr][0]
@@ -1232,7 +1233,7 @@ sp_setup_point(struct setup_context *setup,
    const_coeff(setup, &setup->posCoef, 0, 2);
    const_coeff(setup, &setup->posCoef, 0, 3);
 
-   for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
+   for (fragSlot = 0; fragSlot < fsInfo->num_inputs; fragSlot++) {
       const uint vertSlot = vinfo->attrib[fragSlot].src_index;
       uint j;
 
@@ -1255,7 +1256,7 @@ sp_setup_point(struct setup_context *setup,
          assert(0);
       }
 
-      if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
+      if (fsInfo->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
          /* convert 0 to 1.0 and 1 to -1.0 */
          setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
          setup->coef[fragSlot].dadx[0] = 0.0;
@@ -1396,7 +1397,7 @@ sp_setup_prepare(struct setup_context *setup)
    struct softpipe_context *sp = setup->softpipe;
 
    if (sp->dirty) {
-      softpipe_update_derived(sp);
+      softpipe_update_derived(sp, sp->reduced_api_prim);
    }
 
    /* Note: nr_attrs is only used for debugging (vertex printing) */
index bb19f8c..ec4c8cf 100644 (file)
@@ -60,34 +60,45 @@ struct tgsi_exec_machine;
 struct vertex_info;
 
 
-/**
- * Subclass of pipe_shader_state (though it doesn't really need to be).
- *
- * This is starting to look an awful lot like a quad pipeline stage...
- */
-struct sp_fragment_shader {
-   struct pipe_shader_state shader;
+struct sp_fragment_shader_variant_key
+{
+   boolean polygon_stipple;
+};
 
+
+struct sp_fragment_shader_variant
+{
+   const struct tgsi_token *tokens;
+   struct sp_fragment_shader_variant_key key;
    struct tgsi_shader_info info;
 
+   unsigned stipple_sampler_unit;
+
+   /* See comments about this elsewhere */
+#if 0
    struct draw_fragment_shader *draw_shader;
+#endif
 
-   boolean origin_lower_left; /**< fragment shader uses lower left position origin? */
-   boolean pixel_center_integer; /**< fragment shader uses integer pixel center? */
-   boolean color0_writes_all_cbufs; /**< fragment shader writes color0 to all bound cbufs */
-   void (*prepare)( const struct sp_fragment_shader *shader,
-                   struct tgsi_exec_machine *machine,
-                   struct tgsi_sampler **samplers);
+   void (*prepare)(const struct sp_fragment_shader_variant *shader,
+                  struct tgsi_exec_machine *machine,
+                  struct tgsi_sampler **samplers);
 
-   /* Run the shader - this interface will get cleaned up in the
-    * future:
-    */
-   unsigned (*run)( const struct sp_fragment_shader *shader,
-                   struct tgsi_exec_machine *machine,
-                   struct quad_header *quad );
+   unsigned (*run)(const struct sp_fragment_shader_variant *shader,
+                  struct tgsi_exec_machine *machine,
+                  struct quad_header *quad);
 
+   /* Deletes this instance of the object */
+   void (*delete)(struct sp_fragment_shader_variant *shader);
 
-   void (*delete)( struct sp_fragment_shader * );
+   struct sp_fragment_shader_variant *next;
+};
+
+
+/** Subclass of pipe_shader_state */
+struct sp_fragment_shader {
+   struct pipe_shader_state shader;
+   struct sp_fragment_shader_variant *variants;
+   struct draw_fragment_shader *draw_shader;
 };
 
 
@@ -141,7 +152,7 @@ softpipe_set_framebuffer_state(struct pipe_context *,
                                const struct pipe_framebuffer_state *);
 
 void
-softpipe_update_derived( struct softpipe_context *softpipe );
+softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim);
 
 void
 softpipe_draw_vbo(struct pipe_context *pipe,
@@ -170,4 +181,16 @@ struct vertex_info *
 softpipe_get_vbuf_vertex_info(struct softpipe_context *softpipe);
 
 
+struct sp_fragment_shader_variant *
+softpipe_find_fs_variant(struct softpipe_context *softpipe,
+                         struct sp_fragment_shader *fs,
+                         const struct sp_fragment_shader_variant_key *key);
+
+
+struct sp_fragment_shader_variant *
+softpipe_find_fs_variant(struct softpipe_context *softpipe,
+                         struct sp_fragment_shader *fs,
+                         const struct sp_fragment_shader_variant_key *key);
+
+
 #endif
index f9590eb..fd68808 100644 (file)
  * 
  **************************************************************************/
 
+#include "util/u_inlines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_pstipple.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw/draw_context.h"
 #include "draw/draw_vertex.h"
@@ -64,7 +66,7 @@ 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 struct tgsi_shader_info *fsInfo = &softpipe->fs_variant->info;
       struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf;
       const uint num = draw_num_shader_outputs(softpipe->draw);
       uint i;
@@ -84,11 +86,11 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
        * from the vertex shader.
        */
       vinfo->num_attribs = 0;
-      for (i = 0; i < spfs->info.num_inputs; i++) {
+      for (i = 0; i < fsInfo->num_inputs; i++) {
          int src;
          enum interp_mode interp;
 
-         switch (spfs->info.input_interpolate[i]) {
+         switch (fsInfo->input_interpolate[i]) {
          case TGSI_INTERPOLATE_CONSTANT:
             interp = INTERP_CONSTANT;
             break;
@@ -103,7 +105,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
             interp = INTERP_LINEAR;
          }
 
-         switch (spfs->info.input_semantic_name[i]) {
+         switch (fsInfo->input_semantic_name[i]) {
          case TGSI_SEMANTIC_POSITION:
             interp = INTERP_POS;
             break;
@@ -117,8 +119,8 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
 
          /* 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]);
+                                       fsInfo->input_semantic_name[i],
+                                       fsInfo->input_semantic_index[i]);
          draw_emit_vertex_attr(vinfo, EMIT_4F, interp, src);
       }
 
@@ -241,10 +243,101 @@ update_tgsi_samplers( struct softpipe_context *softpipe )
 }
 
 
+static void
+update_fragment_shader(struct softpipe_context *softpipe, unsigned prim)
+{
+   struct sp_fragment_shader_variant_key key;
+
+   memset(&key, 0, sizeof(key));
+
+   if (prim == PIPE_PRIM_TRIANGLES)
+      key.polygon_stipple = softpipe->rasterizer->poly_stipple_enable;
+
+   if (softpipe->fs) {
+      softpipe->fs_variant = softpipe_find_fs_variant(softpipe,
+                                                      softpipe->fs, &key);
+   }
+   else {
+      softpipe->fs_variant = NULL;
+   }
+
+   /* This would be the logical place to pass the fragment shader
+    * to the draw module.  However, doing this here, during state
+    * validation, causes problems with the 'draw' module helpers for
+    * wide/AA/stippled lines.
+    * In principle, the draw's fragment shader should be per-variant
+    * but that doesn't work.  So we use a single draw fragment shader
+    * per fragment shader, not per variant.
+    */
+#if 0
+   if (softpipe->fs_variant) {
+      draw_bind_fragment_shader(softpipe->draw,
+                                softpipe->fs_variant->draw_shader);
+   }
+   else {
+      draw_bind_fragment_shader(softpipe->draw, NULL);
+   }
+#endif
+}
+
+
+/**
+ * This should be called when the polygon stipple pattern changes.
+ * We create a new texture from the stipple pattern and create a new
+ * sampler view.
+ */
+static void
+update_polygon_stipple_pattern(struct softpipe_context *softpipe)
+{
+   struct pipe_resource *tex;
+   struct pipe_sampler_view *view;
+
+   tex = util_pstipple_create_stipple_texture(&softpipe->pipe,
+                                              softpipe->poly_stipple.stipple);
+   pipe_resource_reference(&softpipe->pstipple.texture, tex);
+
+   view = util_pstipple_create_sampler_view(&softpipe->pipe, tex);
+   pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, view);
+}
+
+
+/**
+ * Should be called when polygon stipple is enabled/disabled or when
+ * the fragment shader changes.
+ * We add/update the fragment sampler and sampler views to sample from
+ * the polygon stipple texture.  The texture unit that we use depends on
+ * the fragment shader (we need to use a unit not otherwise used by the
+ * shader).
+ */
+static void
+update_polygon_stipple_enable(struct softpipe_context *softpipe, unsigned prim)
+{
+   if (prim == PIPE_PRIM_TRIANGLES &&
+       softpipe->fs_variant->key.polygon_stipple) {
+      const unsigned unit = softpipe->fs_variant->stipple_sampler_unit;
+
+      assert(unit >= softpipe->num_fragment_samplers);
+
+      /* sampler state */
+      softpipe->fragment_samplers[unit] = softpipe->pstipple.sampler;
+
+      /* sampler view */
+      pipe_sampler_view_reference(&softpipe->fragment_sampler_views[unit],
+                                  softpipe->pstipple.sampler_view);
+
+      sp_tex_tile_cache_set_sampler_view(softpipe->fragment_tex_cache[unit],
+                                         softpipe->pstipple.sampler_view);
+
+      softpipe->dirty |= SP_NEW_SAMPLER;
+   }
+}
+
+
 /* Hopefully this will remain quite simple, otherwise need to pull in
  * something like the state tracker mechanism.
  */
-void softpipe_update_derived( struct softpipe_context *softpipe )
+void
+softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim)
 {
    struct softpipe_screen *sp_screen = softpipe_screen(softpipe->pipe.screen);
 
@@ -254,7 +347,24 @@ void softpipe_update_derived( struct softpipe_context *softpipe )
       softpipe->tex_timestamp = sp_screen->timestamp;
       softpipe->dirty |= SP_NEW_TEXTURE;
    }
-      
+
+#if DO_PSTIPPLE_IN_HELPER_MODULE
+   if (softpipe->dirty & SP_NEW_STIPPLE)
+      /* before updating samplers! */
+      update_polygon_stipple_pattern(softpipe);
+#endif
+
+   if (softpipe->dirty & (SP_NEW_RASTERIZER |
+                          SP_NEW_FS))
+      update_fragment_shader(softpipe, prim);
+
+#if DO_PSTIPPLE_IN_HELPER_MODULE
+   if (softpipe->dirty & (SP_NEW_RASTERIZER |
+                          SP_NEW_STIPPLE |
+                          SP_NEW_FS))
+      update_polygon_stipple_enable(softpipe, prim);
+#endif
+
    if (softpipe->dirty & (SP_NEW_SAMPLER |
                           SP_NEW_TEXTURE |
                           SP_NEW_FS | 
index 60331bc..16023c9 100644 (file)
@@ -373,8 +373,9 @@ softpipe_reset_sampler_variants(struct softpipe_context *softpipe)
       }
    }
 
-   for (i = 0; i <= softpipe->fs->info.file_max[TGSI_FILE_SAMPLER]; i++) {
+   for (i = 0; i <= softpipe->fs_variant->info.file_max[TGSI_FILE_SAMPLER]; i++) {
       if (softpipe->fragment_samplers[i]) {
+         assert(softpipe->fragment_sampler_views[i]->texture);
          softpipe->tgsi.frag_samplers_list[i] =
             get_sampler_variant( i,
                                  sp_sampler(softpipe->fragment_samplers[i]),
index 3dec5de..da89527 100644 (file)
@@ -33,6 +33,7 @@
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
+#include "util/u_pstipple.h"
 #include "draw/draw_context.h"
 #include "draw/draw_vs.h"
 #include "draw/draw_gs.h"
 #include "tgsi/tgsi_parse.h"
 
 
+/**
+ * Create a new fragment shader variant.
+ */
+static struct sp_fragment_shader_variant *
+create_fs_variant(struct softpipe_context *softpipe,
+                  struct sp_fragment_shader *fs,
+                  const struct sp_fragment_shader_variant_key *key)
+{
+   struct sp_fragment_shader_variant *var;
+   struct pipe_shader_state *stipple_fs = NULL, *curfs = &fs->shader;
+   unsigned unit = 0;
+
+   if (key->polygon_stipple) {
+      /* get new shader that implements polygon stippling */
+      stipple_fs = util_pstipple_create_fragment_shader(&softpipe->pipe,
+                                                        curfs, &unit);
+      curfs = stipple_fs;
+   }
+
+   /* codegen, create variant object */
+   var = softpipe_create_fs_variant_sse(softpipe, curfs);
+   if (!var) {
+      var = softpipe_create_fs_variant_exec(softpipe, curfs);
+   }
+
+   if (var) {
+      var->key = *key;
+      var->tokens = tgsi_dup_tokens(curfs->tokens);
+      var->stipple_sampler_unit = unit;
+
+      tgsi_scan_shader(var->tokens, &var->info);
+
+      /* See comments elsewhere about draw fragment shaders */
+#if 0
+      /* draw's fs state */
+      var->draw_shader = draw_create_fragment_shader(softpipe->draw,
+                                                     &fs->shader);
+      if (!var->draw_shader) {
+         var->delete(var);
+         FREE((void *) var->tokens);
+         return NULL;
+      }
+#endif
+
+      /* insert variant into linked list */
+      var->next = fs->variants;
+      fs->variants = var;
+   }
+
+   if (stipple_fs) {
+      free((void *) stipple_fs->tokens);
+      free(stipple_fs);
+   }
+
+   return var;
+}
+
+
+struct sp_fragment_shader_variant *
+softpipe_find_fs_variant(struct softpipe_context *sp,
+                         struct sp_fragment_shader *fs,
+                         const struct sp_fragment_shader_variant_key *key)
+{
+   struct sp_fragment_shader_variant *var;
+
+   for (var = fs->variants; var; var = var->next) {
+      if (memcmp(&var->key, key, sizeof(*key)) == 0) {
+         /* found it */
+         return var;
+      }
+   }
+
+   return create_fs_variant(sp, fs, key);
+}
+
+
 static void *
 softpipe_create_fs_state(struct pipe_context *pipe,
                          const struct pipe_shader_state *templ)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
-   struct sp_fragment_shader *state;
-   unsigned i;
+   struct sp_fragment_shader *state = CALLOC_STRUCT(sp_fragment_shader);
 
    /* debug */
    if (softpipe->dump_fs) 
       tgsi_dump(templ->tokens, 0);
 
-   /* codegen */
-   state = softpipe_create_fs_sse( softpipe, templ );
-   if (!state) {
-      state = softpipe_create_fs_exec( softpipe, templ );
-   }
-
-   if (!state)
-      return NULL;
+   /* we need to keep a local copy of the tokens */
+   state->shader.tokens = tgsi_dup_tokens(templ->tokens);
 
    /* draw's fs state */
-   state->draw_shader = draw_create_fragment_shader(softpipe->draw, templ);
+   state->draw_shader = draw_create_fragment_shader(softpipe->draw,
+                                                    &state->shader);
    if (!state->draw_shader) {
-      state->delete( state );
+      FREE((void *) state->shader.tokens);
+      FREE(state);
       return NULL;
    }
 
-   /* get/save the summary info for this shader */
-   tgsi_scan_shader(templ->tokens, &state->info);
-
-   for (i = 0; i < state->info.num_properties; ++i) {
-      if (state->info.properties[i].name == TGSI_PROPERTY_FS_COORD_ORIGIN)
-         state->origin_lower_left = state->info.properties[i].data[0];
-      else if (state->info.properties[i].name == TGSI_PROPERTY_FS_COORD_PIXEL_CENTER)
-        state->pixel_center_integer = state->info.properties[i].data[0];
-      else if (state->info.properties[i].name == TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS)
-        state->color0_writes_all_cbufs = state->info.properties[i].data[0];
-   }
-
    return state;
 }
 
@@ -90,6 +150,7 @@ static void
 softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
+   struct sp_fragment_shader *state = (struct sp_fragment_shader *) fs;
 
    if (softpipe->fs == fs)
       return;
@@ -98,8 +159,14 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 
    softpipe->fs = fs;
 
-   draw_bind_fragment_shader(softpipe->draw,
-                             (softpipe->fs ? softpipe->fs->draw_shader : NULL));
+   if (fs == NULL)
+      softpipe->fs_variant = NULL;
+
+   if (state)
+      draw_bind_fragment_shader(softpipe->draw,
+                                state->draw_shader);
+   else
+      draw_bind_fragment_shader(softpipe->draw, NULL);
 
    softpipe->dirty |= SP_NEW_FS;
 }
@@ -110,8 +177,9 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
    struct sp_fragment_shader *state = fs;
+   struct sp_fragment_shader_variant *var, *next_var;
 
-   assert(fs != softpipe_context(pipe)->fs);
+   assert(fs != softpipe->fs);
 
    if (softpipe->fs_machine->Tokens == state->shader.tokens) {
       /* unbind the shader from the tgsi executor if we're
@@ -120,9 +188,23 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
       tgsi_exec_machine_bind_shader(softpipe->fs_machine, NULL, 0, NULL);
    }
 
+   /* delete variants */
+   for (var = state->variants; var; var = next_var) {
+      next_var = var->next;
+
+      assert(var != softpipe->fs_variant);
+
+      /* See comments elsewhere about draw fragment shaders */
+#if 0
+      draw_delete_fragment_shader(softpipe->draw, var->draw_shader);
+#endif
+
+      var->delete(var);
+   }
+
    draw_delete_fragment_shader(softpipe->draw, state->draw_shader);
 
-   state->delete( state );
+   FREE((void *) state->shader.tokens);
 }
 
 
index 90766f4..f730948 100644 (file)
@@ -1662,7 +1662,7 @@ mip_filter_nearest(struct tgsi_sampler *tgsi_sampler,
       samp->mag_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
    else {
-      samp->level = samp->view->u.tex.first_level + (int)(lambda + 0.5) ;
+      samp->level = samp->view->u.tex.first_level + (int)(lambda + 0.5F) ;
       samp->level = MIN2(samp->level, (int)texture->last_level);
       samp->min_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
@@ -1815,13 +1815,13 @@ img_filter_2d_ewa(struct tgsi_sampler *tgsi_sampler,
        * and incrementally update the value of Ax^2+Bxy*Cy^2; when this
        * value, q, is less than F, we're inside the ellipse
        */
-      float tex_u=-0.5 + s[j] * texture->width0 * scaling;
-      float tex_v=-0.5 + t[j] * texture->height0 * scaling;
+      float tex_u = -0.5F + s[j] * texture->width0 * scaling;
+      float tex_v = -0.5F + t[j] * texture->height0 * scaling;
 
-      int u0 = floor(tex_u - box_u);
-      int u1 = ceil (tex_u + box_u);
-      int v0 = floor(tex_v - box_v);
-      int v1 = ceil (tex_v + box_v);
+      int u0 = (int) floorf(tex_u - box_u);
+      int u1 = (int) ceilf(tex_u + box_u);
+      int v0 = (int) floorf(tex_v - box_v);
+      int v1 = (int) ceilf(tex_v + box_v);
 
       float num[4] = {0.0F, 0.0F, 0.0F, 0.0F};
       buffer_next = 0;
@@ -1849,7 +1849,7 @@ img_filter_2d_ewa(struct tgsi_sampler *tgsi_sampler,
                buffer_next++;
                if (buffer_next == QUAD_SIZE) {
                   /* 4 texel coords are in the buffer -> read it now */
-                  int jj;
+                  unsigned jj;
                   /* it is assumed that samp->min_img_filter is set to
                    * img_filter_2d_nearest or one of the
                    * accelerated img_filter_2d_nearest_XXX functions.
@@ -1879,7 +1879,7 @@ img_filter_2d_ewa(struct tgsi_sampler *tgsi_sampler,
        * parameter, we need to read the whole quad and ignore the unused values
        */
       if (buffer_next > 0) {
-         int jj;
+         unsigned jj;
          /* it is assumed that samp->min_img_filter is set to
           * img_filter_2d_nearest or one of the
           * accelerated img_filter_2d_nearest_XXX functions.
@@ -1984,7 +1984,7 @@ mip_filter_linear_aniso(struct tgsi_sampler *tgsi_sampler,
       /* note: we need to have Pmin=sqrt(Pmin2) here, but we can avoid
        * this since 0.5*log(x) = log(sqrt(x))
        */
-      lambda = 0.5 * util_fast_log2(Pmin2)  + samp->sampler->lod_bias;
+      lambda = 0.5F * util_fast_log2(Pmin2) + samp->sampler->lod_bias;
       compute_lod(samp->sampler, lambda, c0, lod);
    }
    else {
@@ -2001,7 +2001,7 @@ mip_filter_linear_aniso(struct tgsi_sampler *tgsi_sampler,
    /* If the ellipse covers the whole image, we can
     * simply return the average of the whole image.
     */
-   if (level0 >= texture->last_level) {
+   if (level0 >= (int) texture->last_level) {
       samp->level = texture->last_level;
       samp->min_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
@@ -2226,9 +2226,9 @@ sample_cube(struct tgsi_sampler *tgsi_sampler,
     */
    {
       /* use the average of the four pixel's texcoords to choose the face */
-      const float rx = 0.25 * (s[0] + s[1] + s[2] + s[3]);
-      const float ry = 0.25 * (t[0] + t[1] + t[2] + t[3]);
-      const float rz = 0.25 * (p[0] + p[1] + p[2] + p[3]);
+      const float rx = 0.25F * (s[0] + s[1] + s[2] + s[3]);
+      const float ry = 0.25F * (t[0] + t[1] + t[2] + t[3]);
+      const float rz = 0.25F * (p[0] + p[1] + p[2] + p[3]);
       const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz);
 
       if (arx >= ary && arx >= arz) {
@@ -2255,7 +2255,7 @@ sample_cube(struct tgsi_sampler *tgsi_sampler,
          float sign = (rz >= 0.0F) ? 1.0F : -1.0F;
          uint face = (rz >= 0.0F) ? PIPE_TEX_FACE_POS_Z : PIPE_TEX_FACE_NEG_Z;
          for (j = 0; j < QUAD_SIZE; j++) {
-            const float ima = -0.5 / fabsf(p[j]);
+            const float ima = -0.5F / fabsf(p[j]);
             ssss[j] = sign * -s[j] * ima + 0.5F;
             tttt[j] =         t[j] * ima + 0.5F;
             samp->faces[j] = face;
index 5603110..533d625 100644 (file)
@@ -79,7 +79,6 @@ struct softpipe_transfer
 };
 
 
-
 /** cast wrappers */
 static INLINE struct softpipe_resource *
 softpipe_resource(struct pipe_resource *pt)
index dbbc249..cfb1b9d 100644 (file)
@@ -207,6 +207,14 @@ void svga_context_flush( struct svga_context *svga,
 
    svga->curr.nr_fbs = 0;
 
+   /* Flush the upload managers to ensure recycling of upload buffers
+    * without throttling. This should really be conditioned on
+    * pipe_buffer_map_range not supporting PIPE_TRANSFER_UNSYNCHRONIZED.
+    */
+
+   u_upload_flush(svga->upload_vb);
+   u_upload_flush(svga->upload_ib);
+
    /* Ensure that texture dma uploads are processed
     * before submitting commands.
     */
index eca529d..34b9e85 100644 (file)
@@ -372,9 +372,6 @@ struct svga_context
 
    /** List of buffers with queued transfers */
    struct list_head dirty_buffers;
-
-   /** Was the previous draw done with the SW path? */
-   boolean prev_draw_swtnl;
 };
 
 /* A flag for each state_tracker state object:
index d8af615..aa09669 100644 (file)
@@ -145,7 +145,7 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
       unsigned i;
 
       /* Unmap upload manager vertex buffers */
-      u_upload_flush(svga->upload_vb);
+      u_upload_unmap(svga->upload_vb);
 
       for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
          handle = svga_buffer_handle(svga, hwtnl->cmd.vdecl_vb[i]);
@@ -156,7 +156,7 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
       }
 
       /* Unmap upload manager index buffers */
-      u_upload_flush(svga->upload_ib);
+      u_upload_unmap(svga->upload_ib);
 
       for (i = 0; i < hwtnl->cmd.prim_count; i++) {
          if (hwtnl->cmd.prim_ib[i]) {
@@ -242,6 +242,11 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
 }
 
 
+void svga_hwtnl_set_index_bias( struct svga_hwtnl *hwtnl,
+                               int index_bias)
+{
+   hwtnl->index_bias = index_bias;
+}
 
 
 
@@ -265,15 +270,16 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
          unsigned size = vb ? vb->width0 : 0;
          unsigned offset = hwtnl->cmd.vdecl[i].array.offset;
          unsigned stride = hwtnl->cmd.vdecl[i].array.stride;
-         unsigned index_bias = range->indexBias;
+         int index_bias = (int) range->indexBias + hwtnl->index_bias;
          unsigned width;
 
          assert(vb);
          assert(size);
          assert(offset < size);
-         assert(index_bias >= 0);
          assert(min_index <= max_index);
-         assert(offset + index_bias*stride < size);
+         if (index_bias >= 0) {
+            assert(offset + index_bias*stride < size);
+         }
          if (min_index != ~0) {
             assert(offset + (index_bias + min_index) * stride < size);
          }
@@ -394,6 +400,7 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
    hwtnl->cmd.max_index[hwtnl->cmd.prim_count] = max_index;
 
    hwtnl->cmd.prim[hwtnl->cmd.prim_count] = *range;
+   hwtnl->cmd.prim[hwtnl->cmd.prim_count].indexBias += hwtnl->index_bias;
 
    pipe_resource_reference(&hwtnl->cmd.prim_ib[hwtnl->cmd.prim_count], ib);
    hwtnl->cmd.prim_count++;
index a2403d8..1dac174 100644 (file)
@@ -79,5 +79,8 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
 enum pipe_error
 svga_hwtnl_flush( struct svga_hwtnl *hwtnl );
 
+void svga_hwtnl_set_index_bias( struct svga_hwtnl *hwtnl,
+                                int index_bias);
+
 
 #endif /* SVGA_DRAW_H_ */
index ca658ac..8126f7e 100644 (file)
@@ -116,6 +116,13 @@ struct draw_cmd {
 struct svga_hwtnl {
    struct svga_context *svga;
    struct u_upload_mgr *upload_ib;
+
+   /* Additional negative index bias due to partial buffer uploads
+    * This is compensated for in the offset associated with all
+    * vertex buffers.
+    */
+
+   int index_bias;
    
    /* Flatshade information:
     */
index 2093bca..d53edcb 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "svga_cmd.h"
 
+#include "util/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_prim.h"
 #include "util/u_time.h"
 #include "svga_state.h"
 #include "svga_swtnl.h"
 #include "svga_debug.h"
+#include "svga_resource_buffer.h"
+#include "util/u_upload_mgr.h"
+
+/**
+ * Determine the ranges to upload for the user-buffers referenced
+ * by the next draw command.
+ *
+ * TODO: It might be beneficial to support multiple ranges. In that case,
+ * the struct svga_buffer::uploaded member should be made an array or a
+ * list, since we need to account for the possibility that different ranges
+ * may be uploaded to different hardware buffers chosen by the utility
+ * upload manager.
+ */
+
+static void
+svga_user_buffer_range(struct svga_context *svga,
+                       unsigned start,
+                       unsigned count,
+                       unsigned instance_count)
+{
+   const struct pipe_vertex_element *ve = svga->curr.velems->velem;
+   int i;
+
+   /*
+    * Release old uploaded range (if not done already) and
+    * initialize new ranges.
+    */
+
+   for (i=0; i < svga->curr.velems->count; i++) {
+      struct pipe_vertex_buffer *vb =
+         &svga->curr.vb[ve[i].vertex_buffer_index];
+
+      if (vb->buffer && svga_buffer_is_user_buffer(vb->buffer)) {
+         struct svga_buffer *buffer = svga_buffer(vb->buffer);
+
+         pipe_resource_reference(&buffer->uploaded.buffer, NULL);
+         buffer->uploaded.start = ~0;
+         buffer->uploaded.end = 0;
+      }
+   }
+
+   for (i=0; i < svga->curr.velems->count; i++) {
+      struct pipe_vertex_buffer *vb =
+         &svga->curr.vb[ve[i].vertex_buffer_index];
+
+      if (vb->buffer && svga_buffer_is_user_buffer(vb->buffer)) {
+         struct svga_buffer *buffer = svga_buffer(vb->buffer);
+         unsigned first, size;
+         unsigned instance_div = ve[i].instance_divisor;
+         unsigned elemSize = util_format_get_blocksize(ve[i].src_format);
+
+         svga->dirty |= SVGA_NEW_VBUFFER;
+
+         if (instance_div) {
+            first = ve[i].src_offset;
+            count = (instance_count + instance_div - 1) / instance_div;
+            size = vb->stride * (count - 1) + elemSize;
+         } else if (vb->stride) {
+            first = vb->stride * start + ve[i].src_offset;
+            size = vb->stride * (count - 1) + elemSize;
+         } else {
+            /* Only a single vertex!
+             * Upload with the largest vertex size the hw supports,
+             * if possible.
+             */
+            first = ve[i].src_offset;
+            size = MIN2(16, vb->buffer->width0);
+         }
+
+         buffer->uploaded.start = MIN2(buffer->uploaded.start, first);
+         buffer->uploaded.end = MAX2(buffer->uploaded.end, first + size);
+      }
+   }
+}
+
+/**
+ * svga_upload_user_buffers - upload parts of user buffers
+ *
+ * This function streams a part of a user buffer to hw and fills
+ * svga_buffer::uploaded with information on the upload.
+ */
+
+static int
+svga_upload_user_buffers(struct svga_context *svga,
+                         unsigned start,
+                         unsigned count,
+                         unsigned instance_count)
+{
+   const struct pipe_vertex_element *ve = svga->curr.velems->velem;
+   unsigned i;
+   int ret;
+
+   svga_user_buffer_range(svga, start, count, instance_count);
+
+   for (i=0; i < svga->curr.velems->count; i++) {
+      struct pipe_vertex_buffer *vb =
+         &svga->curr.vb[ve[i].vertex_buffer_index];
+
+      if (vb->buffer && svga_buffer_is_user_buffer(vb->buffer)) {
+         struct svga_buffer *buffer = svga_buffer(vb->buffer);
+         boolean flushed;
+
+         /*
+          * Check if already uploaded. Otherwise go ahead and upload.
+          */
+
+         if (buffer->uploaded.buffer)
+            continue;
+
+         ret = u_upload_buffer( svga->upload_vb,
+                                0,
+                                buffer->uploaded.start,
+                                buffer->uploaded.end - buffer->uploaded.start,
+                                &buffer->b.b,
+                                &buffer->uploaded.offset,
+                                &buffer->uploaded.buffer,
+                                &flushed);
+
+         if (ret)
+            return ret;
+
+         if (0)
+            debug_printf("%s: %d: orig buf %p upl buf %p ofs %d sofs %d"
+                         " sz %d\n",
+                         __FUNCTION__,
+                         i,
+                         buffer,
+                         buffer->uploaded.buffer,
+                         buffer->uploaded.offset,
+                         buffer->uploaded.start,
+                         buffer->uploaded.end - buffer->uploaded.start);
+
+         vb->buffer_offset = buffer->uploaded.offset;
+      }
+   }
+
+   return PIPE_OK;
+}
+
+/**
+ * svga_release_user_upl_buffers - release uploaded parts of user buffers
+ *
+ * This function releases the hw copy of the uploaded fraction of the
+ * user-buffer. It's important to do this as soon as all draw calls
+ * affecting the uploaded fraction are issued, as this allows for
+ * efficient reuse of the hardware surface backing the uploaded fraction.
+ *
+ * svga_buffer::source_offset is set to 0, and svga_buffer::uploaded::buffer
+ * is set to 0.
+ */
+
+static void
+svga_release_user_upl_buffers(struct svga_context *svga)
+{
+   unsigned i;
+   unsigned nr;
+
+   nr = svga->curr.num_vertex_buffers;
+
+   for (i = 0; i < nr; ++i) {
+      struct pipe_vertex_buffer *vb = &svga->curr.vb[i];
+
+      if (vb->buffer && svga_buffer_is_user_buffer(vb->buffer)) {
+         struct svga_buffer *buffer = svga_buffer(vb->buffer);
+
+         buffer->uploaded.start = ~0;
+         buffer->uploaded.end = 0;
+         if (buffer->uploaded.buffer)
+            pipe_resource_reference(&buffer->uploaded.buffer, NULL);
+      }
+   }
+}
 
 
 
@@ -50,6 +223,7 @@ retry_draw_range_elements( struct svga_context *svga,
                            unsigned prim, 
                            unsigned start, 
                            unsigned count,
+                           unsigned instance_count,
                            boolean do_retry )
 {
    enum pipe_error ret = 0;
@@ -61,6 +235,10 @@ retry_draw_range_elements( struct svga_context *svga,
                              svga->curr.rast->templ.flatshade,
                              svga->curr.rast->templ.flatshade_first );
 
+   ret = svga_upload_user_buffers( svga, min_index + index_bias,
+                                   max_index - min_index + 1, instance_count );
+   if (ret != PIPE_OK)
+      goto retry;
 
    ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
    if (ret)
@@ -84,7 +262,7 @@ retry:
                                         index_buffer, index_size, index_bias,
                                         min_index, max_index,
                                         prim, start, count,
-                                        FALSE );
+                                        instance_count, FALSE );
    }
 
    return ret;
@@ -96,6 +274,7 @@ retry_draw_arrays( struct svga_context *svga,
                    unsigned prim, 
                    unsigned start, 
                    unsigned count,
+                   unsigned instance_count,
                    boolean do_retry )
 {
    enum pipe_error ret;
@@ -107,6 +286,11 @@ retry_draw_arrays( struct svga_context *svga,
                              svga->curr.rast->templ.flatshade,
                              svga->curr.rast->templ.flatshade_first );
 
+   ret = svga_upload_user_buffers( svga, start, count, instance_count );
+
+   if (ret != PIPE_OK)
+      goto retry;
+
    ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
    if (ret)
       goto retry;
@@ -127,6 +311,7 @@ retry:
                                 prim,
                                 start,
                                 count,
+                                instance_count,
                                 FALSE );
    }
 
@@ -141,18 +326,11 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    unsigned reduced_prim = u_reduced_prim( info->mode );
    unsigned count = info->count;
    enum pipe_error ret = 0;
+   boolean needed_swtnl;
 
    if (!u_trim_pipe_prim( info->mode, &count ))
       return;
 
-   if (svga->state.sw.need_swtnl != svga->prev_draw_swtnl) {
-      /* We're switching between SW and HW drawing.  Do a flush to avoid
-       * mixing HW and SW rendering with the same vertex buffer.
-       */
-      pipe->flush(pipe, NULL);
-      svga->prev_draw_swtnl = svga->state.sw.need_swtnl;
-   }
-
    /*
     * Mark currently bound target surfaces as dirty
     * doesn't really matter if it is done before drawing.
@@ -167,6 +345,8 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
       svga->dirty |= SVGA_NEW_REDUCED_PRIMITIVE;
    }
    
+   needed_swtnl = svga->state.sw.need_swtnl;
+
    svga_update_state_retry( svga, SVGA_STATE_NEED_SWTNL );
 
 #ifdef DEBUG
@@ -176,6 +356,20 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 #endif
 
    if (svga->state.sw.need_swtnl) {
+      if (!needed_swtnl) {
+         /*
+          * We're switching from HW to SW TNL.  SW TNL will require mapping all
+          * currently bound vertex buffers, some of which may already be
+          * referenced in the current command buffer as result of previous HW
+          * TNL. So flush now, to prevent the context to flush while a referred
+          * vertex buffer is mapped.
+          */
+
+         svga_context_flush(svga, NULL);
+      }
+
+      /* Avoid leaking the previous hwtnl bias to swtnl */
+      svga_hwtnl_set_index_bias( svga->hwtnl, 0 );
       ret = svga_swtnl_draw_vbo( svga, info );
    }
    else {
@@ -194,6 +388,7 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
                                           info->mode,
                                           info->start + offset,
                                           info->count,
+                                          info->instance_count,
                                           TRUE );
       }
       else {
@@ -201,10 +396,13 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
                                   info->mode,
                                   info->start,
                                   info->count,
+                                  info->instance_count,
                                   TRUE );
       }
    }
 
+   svga_release_user_upl_buffers( svga );
+
    if (SVGA_DEBUG & DEBUG_FLUSH) {
       svga_hwtnl_flush_retry( svga );
       svga_context_flush(svga, NULL);
index 9503221..ca8c8d1 100644 (file)
@@ -129,6 +129,12 @@ struct svga_buffer
        * is the relative offset within that buffer.
        */
       unsigned offset;
+
+      /**
+       * Range of user buffer that is uploaded in @buffer at @offset.
+       */
+      unsigned start;
+      unsigned end;
    } uploaded;
 
    /**
@@ -193,7 +199,11 @@ svga_buffer(struct pipe_resource *buffer)
 static INLINE boolean 
 svga_buffer_is_user_buffer( struct pipe_resource *buffer )
 {
-   return svga_buffer(buffer)->user;
+   if (buffer) {
+      return svga_buffer(buffer)->user;
+   } else {
+      return FALSE;
+   }
 }
 
 
index 9239586..a657a8b 100644 (file)
@@ -651,8 +651,6 @@ svga_redefine_user_buffer(struct pipe_context *pipe,
                           unsigned offset,
                           unsigned size)
 {
-   struct svga_screen *ss = svga_screen(pipe->screen);
-   struct svga_context *svga = svga_context(pipe);
    struct svga_buffer *sbuf = svga_buffer(resource);
 
    assert(sbuf->user);
@@ -661,19 +659,8 @@ svga_redefine_user_buffer(struct pipe_context *pipe,
    assert(!sbuf->hwbuf);
 
    /*
-    * Release any uploaded user buffer.
-    *
-    * TODO: As an optimization, we could try to update the uploaded buffer
-    * instead.
+    * We always treat the contents of user-buffers as volatile,
+    * so no particular action needed here.
     */
 
-   pipe_resource_reference(&sbuf->uploaded.buffer, NULL);
-
-   pipe_mutex_lock(ss->swc_mutex);
-
-   sbuf->key.size.width = sbuf->b.b.width0 = offset + size;
-
-   pipe_mutex_unlock(ss->swc_mutex);
-
-   svga->dirty |= SVGA_NEW_VBUFFER | SVGA_NEW_VELEMENT;
 }
index 7c393a1..47eab1a 100644 (file)
 #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 svga_buffer *buffer = svga_buffer(svga->curr.vb[i].buffer);
-
-         if (!buffer->uploaded.buffer) {
-            boolean flushed;
-            ret = u_upload_buffer( svga->upload_vb,
-                                   0, 0,
-                                   buffer->b.b.width0,
-                                   &buffer->b.b,
-                                   &buffer->uploaded.offset,
-                                   &buffer->uploaded.buffer,
-                                   &flushed);
-            if (ret)
-               return ret;
-
-            if (0)
-               debug_printf("%s: %d: orig buf %p upl buf %p ofs %d sz %d\n",
-                            __FUNCTION__,
-                            i,
-                            buffer,
-                            buffer->uploaded.buffer,
-                            buffer->uploaded.offset,
-                            buffer->b.b.width0);
-         }
-
-         svga->curr.vb[i].buffer_offset = buffer->uploaded.offset;
-      }
-   }
-
-   if (0)
-      debug_printf("%s: DONE\n", __FUNCTION__);
-
-   return ret;
-}
-
-
 /***********************************************************************
  */
 
@@ -99,6 +48,7 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
    const struct pipe_vertex_element *ve = svga->curr.velems->velem;
    SVGA3dVertexDecl decl;
    unsigned i;
+   unsigned neg_bias = 0;
 
    assert(svga->curr.velems->count >=
           svga->curr.vs->base.info.file_count[TGSI_FILE_INPUT]);
@@ -106,12 +56,50 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
    svga_hwtnl_reset_vdecl( svga->hwtnl, 
                            svga->curr.velems->count );
 
+   /**
+    * We can't set the VDECL offset to something negative, so we
+    * must calculate a common negative additional index bias, and modify
+    * the VDECL offsets accordingly so they *all* end up positive.
+    *
+    * Note that the exact value of the negative index bias is not that
+    * important, since we compensate for it when we calculate the vertex
+    * buffer offset below. The important thing is that all vertex buffer
+    * offsets remain positive.
+    *
+    * Note that we use a negative bias variable in order to make the
+    * rounding maths more easy to follow, and to avoid int / unsigned
+    * confusion.
+    */
+
    for (i = 0; i < svga->curr.velems->count; i++) {
-      const struct pipe_vertex_buffer *vb = &svga->curr.vb[ve[i].vertex_buffer_index];
+      const struct pipe_vertex_buffer *vb =
+         &svga->curr.vb[ve[i].vertex_buffer_index];
+      struct svga_buffer *buffer;
+      unsigned int offset = vb->buffer_offset + ve[i].src_offset;
+      unsigned tmp_neg_bias = 0;
+
+      if (!vb->buffer)
+         continue;
+
+      buffer = svga_buffer(vb->buffer);
+      if (buffer->uploaded.start > offset) {
+         tmp_neg_bias = buffer->uploaded.start - offset;
+         if (vb->stride)
+            tmp_neg_bias = (tmp_neg_bias + vb->stride - 1) / vb->stride;
+         neg_bias = MAX2(neg_bias, tmp_neg_bias);
+      }
+   }
+
+   for (i = 0; i < svga->curr.velems->count; i++) {
+      const struct pipe_vertex_buffer *vb =
+         &svga->curr.vb[ve[i].vertex_buffer_index];
       unsigned usage, index;
-      struct svga_buffer *buffer = svga_buffer(vb->buffer);
+      struct svga_buffer *buffer;
 
+      if (!vb->buffer)
+         continue;
 
+      buffer= svga_buffer(vb->buffer);
       svga_generate_vdecl_semantics( i, &usage, &index );
 
       /* SVGA_NEW_VELEMENT
@@ -121,8 +109,16 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
       decl.identity.usage = usage;
       decl.identity.usageIndex = index;
       decl.array.stride = vb->stride;
-      decl.array.offset = (vb->buffer_offset +
-                           ve[i].src_offset);
+
+      /* Compensate for partially uploaded vbo, and
+       * for the negative index bias.
+       */
+      decl.array.offset = (vb->buffer_offset
+                           + ve[i].src_offset
+                          + neg_bias * vb->stride
+                          - buffer->uploaded.start);
+
+      assert(decl.array.offset >= 0);
 
       svga_hwtnl_vdecl( svga->hwtnl,
                         i,
@@ -131,6 +127,7 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
                         vb->buffer );
    }
 
+   svga_hwtnl_set_index_bias( svga->hwtnl, -neg_bias );
    return 0;
 }
 
@@ -138,23 +135,11 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
 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) {
-      ret = upload_user_buffers( svga );
-      if (ret)
-         return ret;
-   }
-
    return emit_hw_vs_vdecl( svga, dirty );
 }
 
index 40f6f2b..8a5d892 100644 (file)
@@ -99,9 +99,9 @@
 #endif
 #endif
 
-#if defined(__PPC__)
+#if defined(__ppc__) || defined(__ppc64__) || defined(__PPC__)
 #define PIPE_ARCH_PPC
-#if defined(__PPC64__)
+#if defined(__ppc64__) || defined(__PPC64__)
 #define PIPE_ARCH_PPC_64
 #endif
 #endif
 # define PIPE_ARCH_BIG_ENDIAN
 #endif
 
+#elif defined(__APPLE__)
+#include <machine/endian.h>
+
+#if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
+# define PIPE_ARCH_LITTLE_ENDIAN
+#elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
+# define PIPE_ARCH_BIG_ENDIAN
+#endif
+
 #else
 
 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
 #error Unknown Endianness
 #endif
 
-#if !defined(PIPE_OS_EMBEDDED)
-
 /*
  * Auto-detect the operating system family.
  * 
 #endif
 #endif /* PIPE_OS_WINDOWS */
 
-#endif /* !PIPE_OS_EMBEDDED */
-
 
 #endif /* P_CONFIG_H_ */
index d8de3ba..da3ee87 100644 (file)
@@ -29,6 +29,8 @@
 #define PIPE_CONTEXT_H
 
 #include "p_compiler.h"
+#include "p_format.h"
+#include "p_video_enums.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -47,6 +49,7 @@ struct pipe_index_buffer;
 struct pipe_query;
 struct pipe_poly_stipple;
 struct pipe_rasterizer_state;
+struct pipe_resolve_info;
 struct pipe_resource;
 struct pipe_sampler_state;
 struct pipe_sampler_view;
@@ -57,8 +60,11 @@ struct pipe_stream_output_state;
 struct pipe_surface;
 struct pipe_vertex_buffer;
 struct pipe_vertex_element;
+struct pipe_video_buffer;
+struct pipe_video_decoder;
 struct pipe_viewport_state;
 
+
 /**
  * Gallium rendering context.  Basically:
  *  - state setting functions
@@ -263,13 +269,10 @@ struct pipe_context {
 
    /**
     * Resolve a multisampled resource into a non-multisampled one.
-    * Source and destination must have the same size and same format.
+    * Source and destination must be of the same format.
     */
    void (*resource_resolve)(struct pipe_context *pipe,
-                            struct pipe_resource *dst,
-                            unsigned dst_layer,
-                            struct pipe_resource *src,
-                            unsigned src_layer);
+                            const struct pipe_resolve_info *info);
 
    /*@}*/
 
@@ -395,6 +398,23 @@ struct pipe_context {
     * Flush any pending framebuffer writes and invalidate texture caches.
     */
    void (*texture_barrier)(struct pipe_context *);
+   
+   /**
+    * Creates a video decoder for a specific video codec/profile
+    */
+   struct pipe_video_decoder *(*create_video_decoder)( struct pipe_context *context,
+                                                       enum pipe_video_profile profile,
+                                                       enum pipe_video_entrypoint entrypoint,
+                                                       enum pipe_video_chroma_format chroma_format,
+                                                       unsigned width, unsigned height );
+
+   /**
+    * Creates a video buffer as decoding target
+    */
+   struct pipe_video_buffer *(*create_video_buffer)( struct pipe_context *context,
+                                                     enum pipe_format buffer_format,
+                                                     enum pipe_video_chroma_format chroma_format,
+                                                     unsigned width, unsigned height );
 };
 
 
index 2c95c20..1ef3ae7 100644 (file)
@@ -99,6 +99,9 @@ enum pipe_error {
 #define PIPE_MASK_B  0x4
 #define PIPE_MASK_A  0x8
 #define PIPE_MASK_RGBA 0xf
+#define PIPE_MASK_Z  0x10
+#define PIPE_MASK_S  0x20
+#define PIPE_MASK_ZS 0x30
 
 
 /**
@@ -468,6 +471,7 @@ enum pipe_cap {
    PIPE_CAP_MIXED_COLORBUFFER_FORMATS = 46,
    PIPE_CAP_SEAMLESS_CUBE_MAP = 47,
    PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE = 48,
+   PIPE_CAP_SCALED_RESOLVE = 49
 };
 
 /* Shader caps not specific to any single stage */
@@ -509,6 +513,7 @@ struct pipe_query_data_timestamp_disjoint
    boolean  disjoint;
 };
 
+
 #ifdef __cplusplus
 }
 #endif
index 690e934..c9f75c0 100644 (file)
@@ -229,9 +229,27 @@ enum pipe_format {
    PIPE_FORMAT_L32A32_FLOAT            = 161,
    PIPE_FORMAT_I32_FLOAT               = 162,
 
+   PIPE_FORMAT_YV12                    = 163,
+   PIPE_FORMAT_YV16                    = 164,
+   PIPE_FORMAT_IYUV                    = 165,  /**< aka I420 */
+   PIPE_FORMAT_NV12                    = 166,
+   PIPE_FORMAT_NV21                    = 167,
+   PIPE_FORMAT_AYUV                    = PIPE_FORMAT_A8R8G8B8_UNORM,
+   PIPE_FORMAT_VUYA                    = PIPE_FORMAT_B8G8R8A8_UNORM,
+   PIPE_FORMAT_XYUV                    = PIPE_FORMAT_X8R8G8B8_UNORM,
+   PIPE_FORMAT_VUYX                    = PIPE_FORMAT_B8G8R8X8_UNORM,
+   PIPE_FORMAT_IA44                    = 168,
+   PIPE_FORMAT_AI44                    = 169,
+
    PIPE_FORMAT_COUNT
 };
 
+enum pipe_video_chroma_format
+{
+   PIPE_VIDEO_CHROMA_FORMAT_420,
+   PIPE_VIDEO_CHROMA_FORMAT_422,
+   PIPE_VIDEO_CHROMA_FORMAT_444
+};
 
 #ifdef __cplusplus
 }
index a7845dd..6821edd 100644 (file)
@@ -41,6 +41,7 @@
 #include "pipe/p_compiler.h"
 #include "pipe/p_format.h"
 #include "pipe/p_defines.h"
+#include "pipe/p_video_enums.h"
 
 
 
@@ -92,6 +93,14 @@ struct pipe_screen {
     */
    int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param );
 
+   /**
+    * Query an integer-valued capability/parameter/limit for a codec/profile
+    * \param param  one of PIPE_VIDEO_CAP_x
+    */
+   int (*get_video_param)( struct pipe_screen *,
+                          enum pipe_video_profile profile,
+                          enum pipe_video_cap param );
+
    struct pipe_context * (*context_create)( struct pipe_screen *,
                                            void *priv );
 
@@ -107,6 +116,14 @@ struct pipe_screen {
                                    unsigned bindings );
 
    /**
+    * Check if the given pipe_format is supported as output for this codec/profile.
+    * \param profile  profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN
+    */
+   boolean (*is_video_format_supported)( struct pipe_screen *,
+                                         enum pipe_format format,
+                                         enum pipe_video_profile profile );
+
+   /**
     * Create a new texture object, using the given template info.
     */
    struct pipe_resource * (*resource_create)(struct pipe_screen *,
index d442c15..840b3ee 100644 (file)
@@ -483,6 +483,34 @@ struct pipe_draw_info
 };
 
 
+/**
+ * Information to describe a resource_resolve call.
+ */
+struct pipe_resolve_info
+{
+   struct {
+      struct pipe_resource *res;
+      unsigned level;
+      unsigned layer;
+      int x0; /**< always left */
+      int y0; /**< always top */
+      int x1; /**< determines scale if PIPE_CAP_SCALED_RESOLVE is supported */
+      int y1; /**< determines scale if PIPE_CAP_SCALED_RESOLVE is supported */
+   } dst;
+
+   struct {
+      struct pipe_resource *res;
+      unsigned layer;
+      int x0;
+      int y0;
+      int x1; /**< may be < x0 only if PIPE_CAP_SCALED_RESOLVE is supported */
+      int y1; /**< may be < y1 even if PIPE_CAP_SCALED_RESOLVE not supported */
+   } src;
+
+   unsigned mask; /**< PIPE_MASK_RGBA, Z, S or ZS */
+};
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/gallium/include/pipe/p_video_decoder.h b/src/gallium/include/pipe/p_video_decoder.h
new file mode 100644 (file)
index 0000000..f063d8f
--- /dev/null
@@ -0,0 +1,170 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 PIPE_VIDEO_CONTEXT_H
+#define PIPE_VIDEO_CONTEXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <pipe/p_video_state.h>
+
+struct pipe_screen;
+struct pipe_surface;
+struct pipe_macroblock;
+struct pipe_picture_desc;
+struct pipe_fence_handle;
+
+/**
+ * Gallium video decoder for a specific codec/profile
+ */
+struct pipe_video_decoder
+{
+   struct pipe_context *context;
+
+   enum pipe_video_profile profile;
+   enum pipe_video_entrypoint entrypoint;
+   enum pipe_video_chroma_format chroma_format;
+   unsigned width;
+   unsigned height;
+
+   /**
+    * destroy this video decoder
+    */
+   void (*destroy)(struct pipe_video_decoder *decoder);
+
+   /**
+    * Creates a buffer as decoding input
+    */
+   struct pipe_video_decode_buffer *(*create_buffer)(struct pipe_video_decoder *decoder);
+
+   /**
+    * flush decoder buffer to video hardware
+    */
+   void (*flush_buffer)(struct pipe_video_decode_buffer *decbuf,
+                        unsigned num_ycbcr_blocks[3],
+                        struct pipe_video_buffer *ref_frames[2],
+                        struct pipe_video_buffer *dst);
+};
+
+/**
+ * input buffer for a decoder
+ */
+struct pipe_video_decode_buffer
+{
+   struct pipe_video_decoder *decoder;
+
+   /**
+    * destroy this decode buffer
+    */
+   void (*destroy)(struct pipe_video_decode_buffer *decbuf);
+
+   /**
+    * map the input buffer into memory before starting decoding
+    */
+   void (*begin_frame)(struct pipe_video_decode_buffer *decbuf);
+
+   /**
+    * set the quantification matrixes
+    */
+   void (*set_quant_matrix)(struct pipe_video_decode_buffer *decbuf,
+                            const uint8_t intra_matrix[64],
+                            const uint8_t non_intra_matrix[64]);
+
+   /**
+    * get the pointer where to put the ycbcr blocks of a component
+    */
+   struct pipe_ycbcr_block *(*get_ycbcr_stream)(struct pipe_video_decode_buffer *, int component);
+
+   /**
+    * get the pointer where to put the ycbcr dct block data of a component
+    */
+   short *(*get_ycbcr_buffer)(struct pipe_video_decode_buffer *, int component);
+
+   /**
+    * get the stride of the mv buffer
+    */
+   unsigned (*get_mv_stream_stride)(struct pipe_video_decode_buffer *decbuf);
+
+   /**
+    * get the pointer where to put the motion vectors of a ref frame
+    */
+   struct pipe_motionvector *(*get_mv_stream)(struct pipe_video_decode_buffer *decbuf, int ref_frame);
+
+   /**
+    * decode a bitstream
+    */
+   void (*decode_bitstream)(struct pipe_video_decode_buffer *decbuf,
+                            unsigned num_bytes, const void *data,
+                            struct pipe_picture_desc *picture,
+                            unsigned num_ycbcr_blocks[3]);
+
+   /**
+    * unmap decoder buffer before flushing
+    */
+   void (*end_frame)(struct pipe_video_decode_buffer *decbuf);
+};
+
+/**
+ * output for decoding / input for displaying
+ */
+struct pipe_video_buffer
+{
+   struct pipe_context *context;
+
+   enum pipe_format buffer_format;
+   enum pipe_video_chroma_format chroma_format;
+   unsigned width;
+   unsigned height;
+
+   /**
+    * destroy this video buffer
+    */
+   void (*destroy)(struct pipe_video_buffer *buffer);
+
+   /**
+    * get a individual sampler view for each plane
+    */
+   struct pipe_sampler_view **(*get_sampler_view_planes)(struct pipe_video_buffer *buffer);
+
+   /**
+    * get a individual sampler view for each component
+    */
+   struct pipe_sampler_view **(*get_sampler_view_components)(struct pipe_video_buffer *buffer);
+
+   /**
+    * get a individual surfaces for each plane
+    */
+   struct pipe_surface **(*get_surfaces)(struct pipe_video_buffer *buffer);
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PIPE_VIDEO_CONTEXT_H */
diff --git a/src/gallium/include/pipe/p_video_enums.h b/src/gallium/include/pipe/p_video_enums.h
new file mode 100644 (file)
index 0000000..492ab84
--- /dev/null
@@ -0,0 +1,74 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 PIPE_VIDEO_ENUMS_H
+#define PIPE_VIDEO_ENUMS_H
+
+enum pipe_video_profile
+{
+   PIPE_VIDEO_PROFILE_UNKNOWN,
+   PIPE_VIDEO_PROFILE_MPEG1,
+   PIPE_VIDEO_PROFILE_MPEG2_SIMPLE,
+   PIPE_VIDEO_PROFILE_MPEG2_MAIN,
+   PIPE_VIDEO_PROFILE_MPEG4_SIMPLE,
+   PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE,
+   PIPE_VIDEO_PROFILE_VC1_SIMPLE,
+   PIPE_VIDEO_PROFILE_VC1_MAIN,
+   PIPE_VIDEO_PROFILE_VC1_ADVANCED,
+   PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE,
+   PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN,
+   PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
+};
+
+/* Video caps, can be different for each codec/profile */
+enum pipe_video_cap
+{
+   PIPE_VIDEO_CAP_SUPPORTED = 0,
+   PIPE_VIDEO_CAP_NPOT_TEXTURES = 1,
+   PIPE_VIDEO_CAP_MAX_WIDTH = 2,
+   PIPE_VIDEO_CAP_MAX_HEIGHT = 3,
+};
+
+enum pipe_video_codec
+{
+   PIPE_VIDEO_CODEC_UNKNOWN = 0,
+   PIPE_VIDEO_CODEC_MPEG12,   /**< MPEG1, MPEG2 */
+   PIPE_VIDEO_CODEC_MPEG4,    /**< DIVX, XVID */
+   PIPE_VIDEO_CODEC_VC1,      /**< WMV */
+   PIPE_VIDEO_CODEC_MPEG4_AVC /**< H.264 */
+};
+
+enum pipe_video_entrypoint
+{
+   PIPE_VIDEO_ENTRYPOINT_UNKNOWN,
+   PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+   PIPE_VIDEO_ENTRYPOINT_IDCT,
+   PIPE_VIDEO_ENTRYPOINT_MC
+};
+
+
+#endif /* PIPE_VIDEO_ENUMS_H */
diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h
new file mode 100644 (file)
index 0000000..2a64ffb
--- /dev/null
@@ -0,0 +1,125 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 PIPE_VIDEO_STATE_H
+#define PIPE_VIDEO_STATE_H
+
+#include <pipe/p_defines.h>
+#include <pipe/p_format.h>
+#include <pipe/p_state.h>
+#include <pipe/p_screen.h>
+#include <util/u_inlines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct pipe_video_rect
+{
+   unsigned x, y, w, h;
+};
+
+enum pipe_mpeg12_picture_type
+{
+   PIPE_MPEG12_PICTURE_TYPE_FIELD_TOP,
+   PIPE_MPEG12_PICTURE_TYPE_FIELD_BOTTOM,
+   PIPE_MPEG12_PICTURE_TYPE_FRAME
+};
+
+enum pipe_mpeg12_dct_intra
+{
+   PIPE_MPEG12_DCT_DELTA = 0,
+   PIPE_MPEG12_DCT_INTRA = 1
+};
+
+enum pipe_mpeg12_dct_type
+{
+   PIPE_MPEG12_DCT_TYPE_FRAME = 0,
+   PIPE_MPEG12_DCT_TYPE_FIELD = 1
+};
+
+enum pipe_video_field_select
+{
+   PIPE_VIDEO_FRAME = 0,
+   PIPE_VIDEO_TOP_FIELD = 1,
+   PIPE_VIDEO_BOTTOM_FIELD = 3,
+
+   /* TODO
+   PIPE_VIDEO_DUALPRIME
+   PIPE_VIDEO_16x8
+   */
+};
+
+enum pipe_video_mv_weight
+{
+   PIPE_VIDEO_MV_WEIGHT_MIN = 0,
+   PIPE_VIDEO_MV_WEIGHT_HALF = 128,
+   PIPE_VIDEO_MV_WEIGHT_MAX = 256
+};
+
+/* bitfields because this is used as a vertex buffer element */
+struct pipe_motionvector
+{
+   struct {
+      short x, y;
+      ushort field_select; /**< enum pipe_video_field_select */
+      ushort weight;  /**< enum pipe_video_mv_weight  */
+   } top, bottom;
+};
+
+/* bitfields because this is used as a vertex buffer element */
+struct pipe_ycbcr_block
+{
+   ubyte x, y;
+   ubyte intra;  /**< enum pipe_mpeg12_dct_intra */
+   ubyte coding; /**< enum pipe_mpeg12_dct_type */
+};
+
+struct pipe_picture_desc
+{
+   enum pipe_video_profile profile;
+};
+
+struct pipe_mpeg12_picture_desc
+{
+   struct pipe_picture_desc base;
+
+   unsigned picture_coding_type;
+   unsigned picture_structure;
+   unsigned frame_pred_frame_dct;
+   unsigned q_scale_type;
+   unsigned alternate_scan;
+   unsigned intra_vlc_format;
+   unsigned concealment_motion_vectors;
+   unsigned f_code[2][2];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PIPE_VIDEO_STATE_H */
index 04fc7c6..f7cc243 100644 (file)
@@ -253,6 +253,12 @@ struct st_context_attribs
 struct st_framebuffer_iface
 {
    /**
+    * Atomic stamp which changes when framebuffers need to be updated.
+    */
+
+   int32_t stamp;
+
+   /**
     * Available for the state tracker manager to use.
     */
    void *st_manager_private;
@@ -315,25 +321,6 @@ struct st_context_iface
    void (*destroy)(struct st_context_iface *stctxi);
 
    /**
-    * Invalidate the current textures that was taken from a framebuffer.
-    *
-    * The state tracker manager calls this function to let the rendering
-    * context know that it should update the textures it got from
-    * st_framebuffer_iface::validate.  It should do so at the latest time possible.
-    * Possible right before sending triangles to the pipe context.
-    *
-    * For certain platforms this function might be called from a thread other
-    * than the thread that the context is currently bound in, and must
-    * therefore be thread safe. But it is the state tracker manager's
-    * responsibility to make sure that the framebuffer is bound to the context
-    * and the API context is current for the duration of this call.
-    *
-    * Thus reducing the sync primitive needed to a single atomic flag.
-    */
-   void (*notify_invalid_framebuffer)(struct st_context_iface *stctxi,
-                                      struct st_framebuffer_iface *stfbi);
-
-   /**
     * Flush all drawing from context to the pipe also flushes the pipe.
     */
    void (*flush)(struct st_context_iface *stctxi, unsigned flags,
index 741a97f..0bb9d85 100644 (file)
@@ -250,21 +250,21 @@ struct GalliumDXGIAdapter
        DXGI_ADAPTER_DESC1 desc;
        std::vector<ComPtr<IDXGIOutput> > outputs;
        int num_outputs;
-       struct native_event_handler handler;
 
        GalliumDXGIAdapter(GalliumDXGIFactory* factory, const struct native_platform* platform, void* dpy)
        {
                this->parent = factory;
 
-                /* FIXME handler should be static */
-               handler.invalid_surface = handle_invalid_surface;
-               handler.new_drm_screen = dxgi_loader_create_drm_screen;
-               handler.new_sw_screen = dxgi_loader_create_sw_screen;
-               platform->set_event_handler(&handler);
-
-               display = platform->create_display(dpy, FALSE, this);
+               display = platform->create_display(dpy, FALSE);
                if(!display)
-                   display = platform->create_display(dpy, TRUE, this);
+                   display = platform->create_display(dpy, TRUE);
+                if (display) {
+                   display->user_data = this;
+                   if (!display->init_screen(display)) {
+                      display->destroy(display);
+                      display = NULL;
+                   }
+                }
                 if(!display)
                        throw E_FAIL;
                memset(&desc, 0, sizeof(desc));
@@ -1413,6 +1413,11 @@ struct dxgi_binding
 
 static dxgi_binding dxgi_default_binding;
 static __thread dxgi_binding dxgi_thread_binding;
+static const struct native_event_handler dxgi_event_handler = {
+   GalliumDXGIAdapter::handle_invalid_surface,
+   dxgi_loader_create_drm_screen,
+   dxgi_loader_create_sw_screen
+};
 
 void STDMETHODCALLTYPE GalliumDXGIUseNothing()
 {
@@ -1427,7 +1432,7 @@ void STDMETHODCALLTYPE GalliumDXGIUseNothing()
 void STDMETHODCALLTYPE GalliumDXGIUseX11Display(Display* dpy, IGalliumDXGIBackend* backend)
 {
        GalliumDXGIUseNothing();
-       dxgi_thread_binding.platform = native_get_x11_platform();
+       dxgi_thread_binding.platform = native_get_x11_platform(&dxgi_event_handler);
        dxgi_thread_binding.display = dpy;
 
        if(backend)
@@ -1443,7 +1448,7 @@ void STDMETHODCALLTYPE GalliumDXGIUseX11Display(Display* dpy, IGalliumDXGIBacken
 void STDMETHODCALLTYPE GalliumDXGIUseDRMCard(int fd)
 {
        GalliumDXGIUseNothing();
-       dxgi_thread_binding.platform = native_get_drm_platform();
+       dxgi_thread_binding.platform = native_get_drm_platform(&dxgi_event_handler);
        dxgi_thread_binding.display = (void*)fd;
        dxgi_thread_binding.backend = 0;
 }
@@ -1453,7 +1458,7 @@ void STDMETHODCALLTYPE GalliumDXGIUseDRMCard(int fd)
 void STDMETHODCALLTYPE GalliumDXGIUseFBDev(int fd)
 {
        GalliumDXGIUseNothing();
-       dxgi_thread_binding.platform = native_get_fbdev_platform();
+       dxgi_thread_binding.platform = native_get_fbdev_platform(&dxgi_event_handler);
        dxgi_thread_binding.display = (void*)fd;
        dxgi_thread_binding.backend = 0;
 }
@@ -1463,7 +1468,7 @@ void STDMETHODCALLTYPE GalliumDXGIUseFBDev(int fd)
 void STDMETHODCALLTYPE GalliumDXGIUseHDC(HDC hdc, PFNHWNDRESOLVER resolver, void* resolver_cookie)
 {
        GalliumDXGIUseNothing();
-       dxgi_thread_binding.platform = native_get_gdi_platform();
+       dxgi_thread_binding.platform = native_get_gdi_platform(&dxgi_event_handler);
        dxgi_thread_binding.display = (void*)hdc;
        dxgi_thread_binding.backend = 0;
 }
@@ -1493,7 +1498,7 @@ void STDMETHODCALLTYPE GalliumDXGIMakeDefault()
         else if(dxgi_default_binding.platform)
                 factory = new GalliumDXGIFactory(dxgi_default_binding.platform, dxgi_default_binding.display, dxgi_default_binding.backend);
         else
-                factory = new GalliumDXGIFactory(native_get_x11_platform(), NULL, NULL);
+                factory = new GalliumDXGIFactory(native_get_x11_platform(&dxgi_event_handler), NULL, NULL);
         HRESULT hres = factory->QueryInterface(riid, out_factory);
         factory->Release();
         return hres;
index e23c1bc..e6612b1 100644 (file)
@@ -143,16 +143,12 @@ dri_unbind_context(__DRIcontext * cPriv)
    /* dri_util.c ensures cPriv is not null */
    struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
    struct dri_context *ctx = dri_context(cPriv);
-   struct dri_drawable *draw = dri_drawable(ctx->dPriv);
-   struct dri_drawable *read = dri_drawable(ctx->rPriv);
    struct st_api *stapi = screen->st_api;
 
    if (--ctx->bind_count == 0) {
       if (ctx->st == ctx->stapi->get_current(ctx->stapi)) {
          ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL);
          stapi->make_current(stapi, NULL, NULL, NULL);
-         draw->context = NULL;
-         read->context = NULL;
       }
    }
 
@@ -180,12 +176,10 @@ dri_make_current(__DRIcontext * cPriv,
    else if (!driDrawPriv || !driReadPriv)
       return GL_FALSE;
 
-   draw->context = ctx;
    if (ctx->dPriv != driDrawPriv) {
       ctx->dPriv = driDrawPriv;
       draw->texture_stamp = driDrawPriv->lastStamp - 1;
    }
-   read->context = ctx;
    if (ctx->rPriv != driReadPriv) {
       ctx->rPriv = driReadPriv;
       read->texture_stamp = driReadPriv->lastStamp - 1;
index 28a33ac..7b8de31 100644 (file)
@@ -136,6 +136,7 @@ dri_create_buffer(__DRIscreen * sPriv,
    drawable->sPriv = sPriv;
    drawable->dPriv = dPriv;
    dPriv->driverPrivate = (void *)drawable;
+   p_atomic_set(&drawable->base.stamp, 1);
 
    return GL_TRUE;
 fail:
index 7f1aa51..fd3460d 100644 (file)
@@ -42,7 +42,6 @@ struct dri_drawable
    struct st_visual stvis;
 
    struct dri_screen *screen;
-   struct dri_context *context;
 
    /* dri */
    __DRIdrawable *dPriv;
index b188f76..c63918a 100644 (file)
@@ -5,7 +5,7 @@ Import('*')
 
 env = env.Clone()
 
-env.ParseConfig('pkg-config --cflags --libs libdrm')
+env.PkgUseModules(['DRM'])
 
 env.Append(CPPPATH = [
     '#/src/mapi',
index e471e8e..fe4ddb3 100644 (file)
@@ -52,13 +52,11 @@ static void
 dri2_invalidate_drawable(__DRIdrawable *dPriv)
 {
    struct dri_drawable *drawable = dri_drawable(dPriv);
-   struct dri_context *ctx = drawable->context;
 
    dri2InvalidateDrawable(dPriv);
    drawable->dPriv->lastStamp = *drawable->dPriv->pStamp;
 
-   if (ctx)
-      ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base);
+   p_atomic_inc(&drawable->base.stamp);
 }
 
 static const __DRI2flushExtension dri2FlushExtension = {
@@ -564,6 +562,24 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
    }
 }
 
+static __DRIimage *
+dri2_dup_image(__DRIimage *image, void *loaderPrivate)
+{
+   __DRIimage *img;
+
+   img = CALLOC_STRUCT(__DRIimageRec);
+   if (!img)
+      return NULL;
+
+   img->texture = NULL;
+   pipe_resource_reference(&img->texture, image->texture);
+   img->level = image->level;
+   img->layer = image->layer;
+   img->loader_private = loaderPrivate;
+
+   return img;
+}
+
 static void
 dri2_destroy_image(__DRIimage *img)
 {
@@ -578,6 +594,7 @@ static struct __DRIimageExtensionRec dri2ImageExtension = {
     dri2_destroy_image,
     dri2_create_image,
     dri2_query_image,
+    dri2_dup_image,
 };
 
 /*
index ac11f7c..a1879a8 100644 (file)
@@ -103,14 +103,11 @@ drisw_present_texture(__DRIdrawable *dPriv,
 static INLINE void
 drisw_invalidate_drawable(__DRIdrawable *dPriv)
 {
-   struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv);
    struct dri_drawable *drawable = dri_drawable(dPriv);
 
    drawable->texture_stamp = dPriv->lastStamp - 1;
 
-   /* check if swapping currently bound buffer */
-   if (ctx && ctx->dPriv == dPriv)
-      ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base);
+   p_atomic_inc(&drawable->base.stamp);
 }
 
 static INLINE void
index 763e7b5..1c97022 100644 (file)
@@ -33,7 +33,8 @@ wayland_INCLUDES = \
 wayland_SOURCES = $(wildcard wayland/*.c)
 wayland_OBJECTS = $(wayland_SOURCES:.c=.o)
 
-drm_INCLUDES = -I$(TOP)/src/gallium/winsys $(shell pkg-config --cflags-only-I libdrm)
+drm_INCLUDES = -I$(TOP)/src/gallium/winsys $(shell pkg-config --cflags-only-I libdrm) \
+              -I$(TOP)/src/gbm/main -I$(TOP)/src/gallium/state_trackers/gbm
 drm_SOURCES = $(wildcard drm/*.c)
 drm_OBJECTS = $(drm_SOURCES:.c=.o)
 
index 9ade76e..c04fec6 100644 (file)
@@ -40,7 +40,12 @@ else:
             env.Append(CPPDEFINES = ['GLX_DIRECT_RENDERING'])
             sources.append(['#/src/glx/dri2.c'])
     if env['drm']:
+        env.PkgUseModules('DRM')
         env.Append(CPPDEFINES = ['HAVE_DRM_BACKEND'])
+        env.Append(CPPPATH = [
+            '#/src/gbm/main',
+            '#/src/gallium/state_trackers/gbm',
+        ])
         sources.append(['drm/native_drm.c', 'drm/modeset.c'])
 
 st_egl = env.ConvenienceLibrary(
index 29dbbef..6649f02 100644 (file)
@@ -31,6 +31,7 @@
 #include "util/u_memory.h"
 #include "util/u_format.h"
 #include "util/u_string.h"
+#include "util/u_atomic.h"
 
 #include "egl_g3d.h"
 #include "egl_g3d_api.h"
@@ -45,15 +46,9 @@ egl_g3d_invalid_surface(struct native_display *ndpy,
 {
    /* XXX not thread safe? */
    struct egl_g3d_surface *gsurf = egl_g3d_surface(nsurf->user_data);
-   struct egl_g3d_context *gctx;
-   
-   /*
-    * Some functions such as egl_g3d_copy_buffers create a temporary native
-    * surface.  There is no gsurf associated with it.
-    */
-   gctx = (gsurf) ? egl_g3d_context(gsurf->base.CurrentContext) : NULL;
-   if (gctx)
-      gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi, gsurf->stfbi);
+
+   if (gsurf && gsurf->stfbi)
+      p_atomic_inc(&gsurf->stfbi->stamp);
 }
 
 static struct pipe_screen *
@@ -72,10 +67,26 @@ egl_g3d_new_sw_screen(struct native_display *ndpy, struct sw_winsys *ws)
    return gdpy->loader->create_sw_screen(ws);
 }
 
-static struct native_event_handler egl_g3d_native_event_handler = {
+static struct pipe_resource *
+egl_g3d_lookup_egl_image(struct native_display *ndpy, void *egl_image)
+{
+   _EGLDisplay *dpy = (_EGLDisplay *) ndpy->user_data;
+   struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+   struct st_egl_image img;
+   struct pipe_resource *resource = NULL;
+
+   memset(&img, 0, sizeof(img));
+   if (gdpy->smapi->get_egl_image(gdpy->smapi, egl_image, &img))
+      resource = img.texture;
+
+   return resource;
+}
+
+static const struct native_event_handler egl_g3d_native_event_handler = {
    egl_g3d_invalid_surface,
    egl_g3d_new_drm_screen,
-   egl_g3d_new_sw_screen
+   egl_g3d_new_sw_screen,
+   egl_g3d_lookup_egl_image
 };
 
 /**
@@ -94,40 +105,38 @@ egl_g3d_get_platform(_EGLDriver *drv, _EGLPlatformType plat)
       case _EGL_PLATFORM_WINDOWS:
          plat_name = "Windows";
 #ifdef HAVE_GDI_BACKEND
-         nplat = native_get_gdi_platform();
+         nplat = native_get_gdi_platform(&egl_g3d_native_event_handler);
 #endif
          break;
       case _EGL_PLATFORM_X11:
          plat_name = "X11";
 #ifdef HAVE_X11_BACKEND
-         nplat = native_get_x11_platform();
+         nplat = native_get_x11_platform(&egl_g3d_native_event_handler);
 #endif
         break;
       case _EGL_PLATFORM_WAYLAND:
          plat_name = "wayland";
 #ifdef HAVE_WAYLAND_BACKEND
-         nplat = native_get_wayland_platform();
+         nplat = native_get_wayland_platform(&egl_g3d_native_event_handler);
 #endif
          break;
       case _EGL_PLATFORM_DRM:
          plat_name = "DRM";
 #ifdef HAVE_DRM_BACKEND
-         nplat = native_get_drm_platform();
+         nplat = native_get_drm_platform(&egl_g3d_native_event_handler);
 #endif
          break;
       case _EGL_PLATFORM_FBDEV:
          plat_name = "FBDEV";
 #ifdef HAVE_FBDEV_BACKEND
-         nplat = native_get_fbdev_platform();
+         nplat = native_get_fbdev_platform(&egl_g3d_native_event_handler);
 #endif
          break;
       default:
          break;
       }
 
-      if (nplat)
-         nplat->set_event_handler(&egl_g3d_native_event_handler);
-      else
+      if (!nplat)
          _eglLog(_EGL_WARNING, "unsupported platform %s", plat_name);
 
       gdrv->platforms[plat] = nplat;
@@ -504,13 +513,20 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy)
    gdpy->loader = gdrv->loader;
    dpy->DriverData = gdpy;
 
-   _eglLog(_EGL_INFO, "use %s for display %p", nplat->name, dpy->PlatformDisplay);
-   gdpy->native = nplat->create_display(dpy->PlatformDisplay,
-         dpy->Options.UseFallback, (void *) dpy);
+   _eglLog(_EGL_INFO, "use %s for display %p",
+         nplat->name, dpy->PlatformDisplay);
+   gdpy->native =
+      nplat->create_display(dpy->PlatformDisplay, dpy->Options.UseFallback);
    if (!gdpy->native) {
       _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)");
       goto fail;
    }
+   gdpy->native->user_data = (void *) dpy;
+   if (!gdpy->native->init_screen(gdpy->native)) {
+      _eglError(EGL_NOT_INITIALIZED,
+            "eglInitialize(failed to initialize screen)");
+      goto fail;
+   }
 
    if (gdpy->loader->profile_masks[ST_API_OPENGL] & ST_PROFILE_DEFAULT_MASK)
       dpy->ClientAPIs |= EGL_OPENGL_BIT;
index 301db31..5989a02 100644 (file)
@@ -126,4 +126,12 @@ _EGL_DRIVER_TYPECAST(egl_g3d_screen, _EGLScreen, obj)
 
 #endif /* EGL_MESA_screen_surface */
 
+static INLINE struct st_api *
+egl_g3d_get_st_api(_EGLDriver *drv, enum st_api_type api)
+{
+   struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
+
+   return gdrv->loader->get_st_api(api);
+}
+
 #endif /* _EGL_G3D_H_ */
index 8b1821e..f897054 100644 (file)
@@ -37,7 +37,6 @@
 #include "egl_g3d_image.h"
 #include "egl_g3d_sync.h"
 #include "egl_g3d_st.h"
-#include "egl_g3d_loader.h"
 #include "native.h"
 
 /**
@@ -47,7 +46,6 @@ static struct st_api *
 egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx,
                   enum st_profile_type *profile)
 {
-   struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
    struct st_api *stapi;
    EGLint api = -1;
 
@@ -81,96 +79,66 @@ egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx,
       break;
    }
 
-   switch (api) {
-   case ST_API_OPENGL:
-      stapi = gdrv->loader->guess_gl_api(*profile);
-      break;
-   case ST_API_OPENVG:
-      stapi = gdrv->loader->get_st_api(api);
-      break;
-   default:
-      stapi = NULL;
-      break;
-   }
+   stapi = egl_g3d_get_st_api(drv, api);
    if (stapi && !(stapi->profile_mask & (1 << *profile)))
       stapi = NULL;
 
    return stapi;
 }
 
+struct egl_g3d_choose_config_data {
+   _EGLConfig criteria;
+   enum pipe_format format;
+};
+
 static int
 egl_g3d_compare_config(const _EGLConfig *conf1, const _EGLConfig *conf2,
                        void *priv_data)
 {
-   const _EGLConfig *criteria = (const _EGLConfig *) priv_data;
+   struct egl_g3d_choose_config_data *data =
+      (struct egl_g3d_choose_config_data *) priv_data;
+   const _EGLConfig *criteria = &data->criteria;;
 
    /* EGL_NATIVE_VISUAL_TYPE ignored? */
    return _eglCompareConfigs(conf1, conf2, criteria, EGL_TRUE);
 }
 
 static EGLBoolean
-egl_g3d_match_config(const _EGLConfig *conf, const _EGLConfig *criteria)
+egl_g3d_match_config(const _EGLConfig *conf, void *priv_data)
 {
-   if (!_eglMatchConfig(conf, criteria))
-      return EGL_FALSE;
-
-   if (criteria->MatchNativePixmap != EGL_NONE &&
-       criteria->MatchNativePixmap != EGL_DONT_CARE) {
-      struct egl_g3d_display *gdpy = egl_g3d_display(conf->Display);
-      struct egl_g3d_config *gconf = egl_g3d_config(conf);
-      EGLNativePixmapType pix =
-         (EGLNativePixmapType) criteria->MatchNativePixmap;
+   struct egl_g3d_choose_config_data *data =
+      (struct egl_g3d_choose_config_data *) priv_data;
+   struct egl_g3d_config *gconf = egl_g3d_config(conf);
 
-      if (!gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native))
-         return EGL_FALSE;
-   }
+   if (data->format != PIPE_FORMAT_NONE &&
+       data->format != gconf->native->color_format)
+      return EGL_FALSE;
 
-   return EGL_TRUE;
+   return _eglMatchConfig(conf, &data->criteria);
 }
 
 static EGLBoolean
 egl_g3d_choose_config(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attribs,
                       EGLConfig *configs, EGLint size, EGLint *num_configs)
 {
-   _EGLConfig **tmp_configs, criteria;
-   EGLint tmp_size, i;
-
-   if (!num_configs)
-      return _eglError(EGL_BAD_PARAMETER, "eglChooseConfigs");
+   struct egl_g3d_choose_config_data data;
 
-   if (!_eglParseConfigAttribList(&criteria, dpy, attribs))
+   if (!_eglParseConfigAttribList(&data.criteria, dpy, attribs))
       return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
 
-   /* get the number of matched configs */
-   tmp_size = _eglFilterArray(dpy->Configs, NULL, 0,
-         (_EGLArrayForEach) egl_g3d_match_config, (void *) &criteria);
-   if (!tmp_size) {
-      *num_configs = tmp_size;
-      return EGL_TRUE;
-   }
-
-   tmp_configs = MALLOC(sizeof(tmp_configs[0]) * tmp_size);
-   if (!tmp_configs)
-      return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)");
+   data.format = PIPE_FORMAT_NONE;
+   if (data.criteria.MatchNativePixmap != EGL_NONE &&
+       data.criteria.MatchNativePixmap != EGL_DONT_CARE) {
+      struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
 
-   /* get the matched configs */
-   _eglFilterArray(dpy->Configs, (void **) tmp_configs, tmp_size,
-         (_EGLArrayForEach) egl_g3d_match_config, (void *) &criteria);
-
-   /* perform sorting of configs */
-   if (configs && tmp_size) {
-      _eglSortConfigs((const _EGLConfig **) tmp_configs, tmp_size,
-            egl_g3d_compare_config, (void *) &criteria);
-      tmp_size = MIN2(tmp_size, size);
-      for (i = 0; i < tmp_size; i++)
-         configs[i] = _eglGetConfigHandle(tmp_configs[i]);
+      if (!gdpy->native->get_pixmap_format(gdpy->native,
+               (EGLNativePixmapType) data.criteria.MatchNativePixmap,
+               &data.format))
+         return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglChooseConfig");
    }
 
-   FREE(tmp_configs);
-
-   *num_configs = tmp_size;
-
-   return EGL_TRUE;
+   return _eglFilterConfigArray(dpy->Configs, configs, size, num_configs,
+         egl_g3d_match_config, egl_g3d_compare_config, &data);
 }
 
 static _EGLContext *
@@ -536,19 +504,12 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy,
             (gdraw) ? gdraw->stfbi : NULL, (gread) ? gread->stfbi : NULL);
       if (ok) {
          if (gdraw) {
-            gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi,
-                  gdraw->stfbi);
-
             if (gdraw->base.Type == EGL_WINDOW_BIT) {
                gctx->base.WindowRenderBuffer =
                   (gdraw->stvis.render_buffer == ST_ATTACHMENT_FRONT_LEFT) ?
                   EGL_SINGLE_BUFFER : EGL_BACK_BUFFER;
             }
          }
-         if (gread && gread != gdraw) {
-            gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi,
-                  gread->stfbi);
-         }
       }
    }
    else if (old_gctx) {
@@ -614,21 +575,6 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
          gsurf->base.SwapInterval);
 }
 
-/**
- * Get the pipe surface of the given attachment of the native surface.
- */
-static struct pipe_resource *
-get_pipe_resource(struct native_display *ndpy, struct native_surface *nsurf,
-                  enum native_attachment natt)
-{
-   struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
-
-   textures[natt] = NULL;
-   nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL);
-
-   return textures[natt];
-}
-
 static EGLBoolean
 egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
                      EGLNativePixmapType target)
@@ -636,43 +582,18 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
    struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
    struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
    _EGLContext *ctx = _eglGetCurrentContext();
-   struct native_surface *nsurf;
-   struct pipe_resource *ptex;
-   struct pipe_context *pipe;
 
    if (!gsurf->render_texture)
       return EGL_TRUE;
 
-   nsurf = gdpy->native->create_pixmap_surface(gdpy->native, target, NULL);
-   if (!nsurf)
-      return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers");
-
    /* flush if the surface is current */
    if (ctx && ctx->DrawSurface == &gsurf->base) {
       struct egl_g3d_context *gctx = egl_g3d_context(ctx);
       gctx->stctxi->flush(gctx->stctxi, ST_FLUSH_FRONT, NULL);
    }
 
-   pipe = ndpy_get_copy_context(gdpy->native);
-   if (!pipe)
-      return EGL_FALSE;
-
-   ptex = get_pipe_resource(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
-   if (ptex) {
-      struct pipe_box src_box;
-
-      u_box_origin_2d(ptex->width0, ptex->height0, &src_box);
-      pipe->resource_copy_region(pipe, ptex, 0, 0, 0, 0,
-            gsurf->render_texture, 0, &src_box);
-      pipe->flush(pipe, NULL);
-      nsurf->present(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0);
-
-      pipe_resource_reference(&ptex, NULL);
-   }
-
-   nsurf->destroy(nsurf);
-
-   return EGL_TRUE;
+   return gdpy->native->copy_to_pixmap(gdpy->native,
+         target, gsurf->render_texture);
 }
 
 static EGLBoolean
index ce72e27..7e9a29b 100644 (file)
@@ -37,9 +37,6 @@
 #include "egl_g3d.h"
 #include "egl_g3d_image.h"
 
-/* for struct winsys_handle */
-#include "state_tracker/drm_driver.h"
-
 /**
  * Reference and return the front left buffer of the native pixmap.
  */
@@ -137,10 +134,9 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name,
                              _EGLImage *img, const EGLint *attribs)
 {
    struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
-   struct pipe_resource templ;
-   struct winsys_handle wsh;
    _EGLImageAttribs attrs;
    EGLint format;
+   struct native_buffer nbuf;
 
    if (!dpy->Extensions.MESA_drm_image)
       return NULL;
@@ -166,21 +162,21 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name,
       break;
    }
 
-   memset(&templ, 0, sizeof(templ));
-   templ.target = PIPE_TEXTURE_2D;
-   templ.format = format;
-   templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
-   templ.width0 = attrs.Width;
-   templ.height0 = attrs.Height;
-   templ.depth0 = 1;
-   templ.array_size = 1;
-
-   memset(&wsh, 0, sizeof(wsh));
-   wsh.handle = (unsigned) name;
-   wsh.stride =
-      attrs.DRMBufferStrideMESA * util_format_get_blocksize(templ.format);
-
-   return gdpy->native->buffer->import_buffer(gdpy->native, &templ, &wsh);
+   memset(&nbuf, 0, sizeof(nbuf));
+   nbuf.type = NATIVE_BUFFER_DRM;
+   nbuf.u.drm.templ.target = PIPE_TEXTURE_2D;
+   nbuf.u.drm.templ.format = format;
+   nbuf.u.drm.templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+   nbuf.u.drm.templ.width0 = attrs.Width;
+   nbuf.u.drm.templ.height0 = attrs.Height;
+   nbuf.u.drm.templ.depth0 = 1;
+   nbuf.u.drm.templ.array_size = 1;
+
+   nbuf.u.drm.name = name;
+   nbuf.u.drm.stride =
+      attrs.DRMBufferStrideMESA * util_format_get_blocksize(format);
+
+   return gdpy->native->buffer->import_buffer(gdpy->native, &nbuf);
 }
 
 #endif /* EGL_MESA_drm_image */
@@ -327,35 +323,26 @@ egl_g3d_export_drm_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img,
 {
    struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
    struct egl_g3d_image *gimg = egl_g3d_image(img);
-   struct winsys_handle wsh;
+   struct native_buffer nbuf;
 
    if (!dpy->Extensions.MESA_drm_image)
       return EGL_FALSE;
 
-   /* get shared handle */
-   if (name) {
-      memset(&handle, 0, sizeof(handle));
-      wsh.type = DRM_API_HANDLE_TYPE_SHARED;
-      if (!gdpy->native->buffer->export_buffer(gdpy->native,
-                                               gimg->texture, &wsh))
-         return EGL_FALSE;
+   memset(&nbuf, 0, sizeof(nbuf));
+   nbuf.type = NATIVE_BUFFER_DRM;
+   if (name)
+      nbuf.u.drm.templ.bind |= PIPE_BIND_SHARED;
 
-      *name = wsh.handle;
-   }
+   if (!gdpy->native->buffer->export_buffer(gdpy->native,
+                                            gimg->texture, &nbuf))
+      return EGL_FALSE;
 
-   /* get KMS handle */
-   if (handle || stride) {
-      memset(&wsh, 0, sizeof(wsh));
-      wsh.type = DRM_API_HANDLE_TYPE_KMS;
-      if (!gdpy->native->buffer->export_buffer(gdpy->native,
-                                               gimg->texture, &wsh))
-         return EGL_FALSE;
-
-      if (handle)
-         *handle = wsh.handle;
-      if (stride)
-         *stride = wsh.stride;
-   }
+   if (name)
+      *name = nbuf.u.drm.name;
+   if (handle)
+      *handle = nbuf.u.drm.handle;
+   if (stride)
+      *stride = nbuf.u.drm.stride;
 
    return EGL_TRUE;
 }
index 78bfe21..e9403fa 100644 (file)
@@ -39,7 +39,6 @@ struct sw_winsys;
 struct egl_g3d_loader {
    uint profile_masks[ST_API_COUNT];
    struct st_api *(*get_st_api)(enum st_api_type api);
-   struct st_api *(*guess_gl_api)(enum st_profile_type profile);
 
    struct pipe_screen *(*create_drm_screen)(const char *name, int fd);
    struct pipe_screen *(*create_sw_screen)(struct sw_winsys *ws);
index 2b944b5..b839f84 100644 (file)
@@ -126,7 +126,7 @@ pbuffer_reference_openvg_image(struct egl_g3d_surface *gsurf)
 }
 
 static void
-pbuffer_allocate_render_texture(struct egl_g3d_surface *gsurf)
+pbuffer_allocate_pbuffer_texture(struct egl_g3d_surface *gsurf)
 {
    struct egl_g3d_display *gdpy =
       egl_g3d_display(gsurf->base.Resource.Display);
@@ -141,7 +141,8 @@ pbuffer_allocate_render_texture(struct egl_g3d_surface *gsurf)
    templ.depth0 = 1;
    templ.array_size = 1;
    templ.format = gsurf->stvis.color_format;
-   templ.bind = PIPE_BIND_RENDER_TARGET;
+   /* for rendering and binding to texture */
+   templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
 
    ptex = screen->resource_create(screen, &templ);
    gsurf->render_texture = ptex;
@@ -166,7 +167,7 @@ egl_g3d_st_framebuffer_validate_pbuffer(struct st_framebuffer_iface *stfbi,
       if (!gsurf->render_texture) {
          switch (gsurf->client_buffer_type) {
          case EGL_NONE:
-            pbuffer_allocate_render_texture(gsurf);
+            pbuffer_allocate_pbuffer_texture(gsurf);
             break;
          case EGL_OPENVG_IMAGE:
             pbuffer_reference_openvg_image(gsurf);
@@ -292,6 +293,8 @@ egl_g3d_create_st_framebuffer(_EGLSurface *surf)
       return NULL;
 
    stfbi->visual = &gsurf->stvis;
+   p_atomic_set(&stfbi->stamp, 1);
+
    if (gsurf->base.Type != EGL_PBUFFER_BIT) {
       stfbi->flush_front = egl_g3d_st_framebuffer_flush_front;
       stfbi->validate = egl_g3d_st_framebuffer_validate;
index 8646e52..fc50ee4 100644 (file)
@@ -152,6 +152,11 @@ struct native_display {
     */
    void *user_data;
 
+   /**
+    * Initialize and create the pipe screen.
+    */
+   boolean (*init_screen)(struct native_display *ndpy);
+
    void (*destroy)(struct native_display *ndpy);
 
    /**
@@ -170,16 +175,21 @@ struct native_display {
                                                int *num_configs);
 
    /**
-    * Test if a pixmap is supported by the given config.  Required unless no
-    * config has pixmap_bit set.
-    *
-    * This function is usually called to find a config that supports a given
-    * pixmap.  Thus, it is usually called with the same pixmap in a row.
+    * Get the color format of the pixmap.  Required unless no config has
+    * pixmap_bit set.
     */
-   boolean (*is_pixmap_supported)(struct native_display *ndpy,
-                                  EGLNativePixmapType pix,
-                                  const struct native_config *nconf);
+   boolean (*get_pixmap_format)(struct native_display *ndpy,
+                                EGLNativePixmapType pix,
+                                enum pipe_format *format);
 
+   /**
+    * Copy the contents of the resource to the pixmap's front-left attachment.
+    * This is used to implement eglCopyBuffers.  Required unless no config has
+    * pixmap_bit set.
+    */
+   boolean (*copy_to_pixmap)(struct native_display *ndpy,
+                             EGLNativePixmapType pix,
+                             struct pipe_resource *src);
 
    /**
     * Create a window surface.  Required unless no config has window_bit set.
@@ -219,6 +229,9 @@ struct native_event_handler {
                                          const char *name, int fd);
    struct pipe_screen *(*new_sw_screen)(struct native_display *ndpy,
                                         struct sw_winsys *ws);
+
+   struct pipe_resource *(*lookup_egl_image)(struct native_display *ndpy,
+                                             void *egl_image);
 };
 
 /**
@@ -256,26 +269,29 @@ ndpy_uninit(struct native_display *ndpy)
 struct native_platform {
    const char *name;
 
-   void (*set_event_handler)(struct native_event_handler *handler);
-   struct native_display *(*create_display)(void *dpy,
-                                            boolean use_sw,
-                                            void *user_data);
+   /**
+    * Create the native display and usually establish a connection to the
+    * display server.
+    *
+    * No event should be generated at this stage.
+    */
+   struct native_display *(*create_display)(void *dpy, boolean use_sw);
 };
 
 const struct native_platform *
-native_get_gdi_platform(void);
+native_get_gdi_platform(const struct native_event_handler *event_handler);
 
 const struct native_platform *
-native_get_x11_platform(void);
+native_get_x11_platform(const struct native_event_handler *event_handler);
 
 const struct native_platform *
-native_get_wayland_platform(void);
+native_get_wayland_platform(const struct native_event_handler *event_handler);
 
 const struct native_platform *
-native_get_drm_platform(void);
+native_get_drm_platform(const struct native_event_handler *event_handler);
 
 const struct native_platform *
-native_get_fbdev_platform(void);
+native_get_fbdev_platform(const struct native_event_handler *event_handler);
 
 #ifdef __cplusplus
 }
index 5c29ab9..b8a66d1 100644 (file)
 #define _NATIVE_BUFFER_H_
 
 #include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
 
 struct native_display;
-struct pipe_resource;
+
+enum native_buffer_type {
+   NATIVE_BUFFER_DRM,
+
+   NUM_NATIVE_BUFFERS
+};
+
+struct native_buffer {
+   enum native_buffer_type type;
+
+   union {
+      struct {
+         struct pipe_resource templ;
+         unsigned name;   /**< the name of the GEM object */
+         unsigned handle; /**< the handle of the GEM object */
+         unsigned stride;
+      } drm;
+   } u;
+};
 
 /**
  * Buffer interface of the native display.  It allows native buffers to be
  * imported and exported.
- *
- * Just like a native window or a native pixmap, a native buffer is another
- * native type.  Its definition depends on the native display.
- *
- * For DRM platform, the type of a native buffer is struct winsys_handle.
  */
 struct native_display_buffer {
    struct pipe_resource *(*import_buffer)(struct native_display *ndpy,
-                                          const struct pipe_resource *templ,
-                                          void *buf);
+                                          struct native_buffer *buf);
 
    /**
     * The resource must be creatred with PIPE_BIND_SHARED.
     */
    boolean (*export_buffer)(struct native_display *ndpy,
                             struct pipe_resource *res,
-                            void *buf);
+                            struct native_buffer *nbuf);
 };
 
 #endif /* _NATIVE_BUFFER_H_ */
index ee18cb2..cca1e1c 100644 (file)
@@ -282,9 +282,9 @@ resource_surface_copy_swap(struct resource_surface *rsurf,
                              btex, 0, &src_box);
    ret = TRUE;
 
- out_no_ftex:
-   pipe_resource_reference(&btex, NULL);
  out_no_btex:
+   pipe_resource_reference(&btex, NULL);
+ out_no_ftex:
    pipe_resource_reference(&ftex, NULL);
 
    return ret;
@@ -367,3 +367,116 @@ resource_surface_wait(struct resource_surface *rsurf)
 {
    while (resource_surface_throttle(rsurf));
 }
+
+boolean
+native_display_copy_to_pixmap(struct native_display *ndpy,
+                              EGLNativePixmapType pix,
+                              struct pipe_resource *src)
+{
+   struct pipe_context *pipe;
+   struct native_surface *nsurf;
+   struct pipe_resource *dst;
+   struct pipe_resource *tmp[NUM_NATIVE_ATTACHMENTS];
+   const enum native_attachment natt = NATIVE_ATTACHMENT_FRONT_LEFT;
+
+   pipe = ndpy_get_copy_context(ndpy);
+   if (!pipe)
+      return FALSE;
+
+   nsurf = ndpy->create_pixmap_surface(ndpy, pix, NULL);
+   if (!nsurf)
+      return FALSE;
+
+   /* get the texutre */
+   tmp[natt] = NULL;
+   nsurf->validate(nsurf, 1 << natt, NULL, tmp, NULL, NULL);
+   dst = tmp[natt];
+
+   if (dst && dst->format == src->format) {
+      struct pipe_box src_box;
+
+      u_box_origin_2d(src->width0, src->height0, &src_box);
+      pipe->resource_copy_region(pipe, dst, 0, 0, 0, 0, src, 0, &src_box);
+      pipe->flush(pipe, NULL);
+      nsurf->present(nsurf, natt, FALSE, 0);
+   }
+
+   if (dst)
+      pipe_resource_reference(&dst, NULL);
+
+   nsurf->destroy(nsurf);
+
+   return TRUE;
+}
+
+#include "state_tracker/drm_driver.h"
+struct pipe_resource *
+drm_display_import_native_buffer(struct native_display *ndpy,
+                                 struct native_buffer *nbuf)
+{
+   struct pipe_screen *screen = ndpy->screen;
+   struct pipe_resource *res = NULL;
+
+   switch (nbuf->type) {
+   case NATIVE_BUFFER_DRM:
+      {
+         struct winsys_handle wsh;
+
+         memset(&wsh, 0, sizeof(wsh));
+         wsh.handle = nbuf->u.drm.name;
+         wsh.stride = nbuf->u.drm.stride;
+
+         res = screen->resource_from_handle(screen, &nbuf->u.drm.templ, &wsh);
+      }
+      break;
+   default:
+      break;
+   }
+
+   return res;
+}
+
+boolean
+drm_display_export_native_buffer(struct native_display *ndpy,
+                                 struct pipe_resource *res,
+                                 struct native_buffer *nbuf)
+{
+   struct pipe_screen *screen = ndpy->screen;
+   boolean ret = FALSE;
+
+   switch (nbuf->type) {
+   case NATIVE_BUFFER_DRM:
+      {
+         struct winsys_handle wsh;
+
+         if ((nbuf->u.drm.templ.bind & res->bind) != nbuf->u.drm.templ.bind)
+            break;
+
+         memset(&wsh, 0, sizeof(wsh));
+         wsh.type = DRM_API_HANDLE_TYPE_KMS;
+         if (!screen->resource_get_handle(screen, res, &wsh))
+            break;
+
+         nbuf->u.drm.handle = wsh.handle;
+         nbuf->u.drm.stride = wsh.stride;
+
+         /* get the name of the GEM object */
+         if (nbuf->u.drm.templ.bind & PIPE_BIND_SHARED) {
+            memset(&wsh, 0, sizeof(wsh));
+            wsh.type = DRM_API_HANDLE_TYPE_SHARED;
+            if (!screen->resource_get_handle(screen, res, &wsh))
+               break;
+
+            nbuf->u.drm.name = wsh.handle;
+         }
+
+         nbuf->u.drm.templ = *res;
+         ret = TRUE;
+      }
+      break;
+   default:
+      break;
+   }
+
+   return ret;
+}
index 39564a0..e8d91cc 100644 (file)
@@ -105,3 +105,17 @@ resource_surface_flush(struct resource_surface *rsurf,
  */
 void
 resource_surface_wait(struct resource_surface *rsurf);
+
+boolean
+native_display_copy_to_pixmap(struct native_display *ndpy,
+                              EGLNativePixmapType pix,
+                              struct pipe_resource *src);
+
+struct pipe_resource *
+drm_display_import_native_buffer(struct native_display *ndpy,
+                                 struct native_buffer *nbuf);
+
+boolean
+drm_display_export_native_buffer(struct native_display *ndpy,
+                                 struct pipe_resource *res,
+                                 struct native_buffer *nbuf);
index 3fff954..73968d1 100644 (file)
@@ -290,6 +290,42 @@ drm_display_create_surface(struct native_display *ndpy,
    return drmsurf;
 }
 
+struct native_surface *
+drm_display_create_surface_from_resource(struct native_display *ndpy,
+                                         struct pipe_resource *resource)
+{
+   struct drm_display *drmdpy = drm_display(ndpy);
+   struct drm_surface *drmsurf;
+   enum native_attachment natt = NATIVE_ATTACHMENT_FRONT_LEFT;
+
+   drmsurf = CALLOC_STRUCT(drm_surface);
+   if (!drmsurf)
+      return NULL;
+
+   drmsurf->drmdpy = drmdpy;
+   drmsurf->color_format = resource->format;
+   drmsurf->width = resource->width0;
+   drmsurf->height = resource->height0;
+   drmsurf->have_pageflip = FALSE;
+
+   drmsurf->rsurf = resource_surface_create(drmdpy->base.screen,
+         drmsurf->color_format,
+         PIPE_BIND_RENDER_TARGET |
+         PIPE_BIND_SAMPLER_VIEW |
+         PIPE_BIND_DISPLAY_TARGET |
+         PIPE_BIND_SCANOUT);
+   
+   resource_surface_import_resource(drmsurf->rsurf, natt, resource);
+
+   drmsurf->base.destroy = drm_surface_destroy;
+   drmsurf->base.present = drm_surface_present;
+   drmsurf->base.validate = drm_surface_validate;
+   drmsurf->base.wait = drm_surface_wait;
+
+   return &drmsurf->base;
+}
+        
+
 /**
  * Choose a CRTC that supports all given connectors.
  */
index 725fe28..c013769 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "native_drm.h"
 
+#include "gbm_gallium_drmint.h"
+
 #ifdef HAVE_LIBUDEV
 #include <libudev.h>
 #endif
@@ -125,65 +127,26 @@ drm_display_destroy(struct native_display *ndpy)
 
    drm_display_fini_modeset(&drmdpy->base);
 
+   /* gbm owns screen */
+   ndpy->screen = NULL;
    ndpy_uninit(ndpy);
 
    if (drmdpy->device_name)
       FREE(drmdpy->device_name);
 
-   if (drmdpy->fd >= 0)
-      close(drmdpy->fd);
-
-   FREE(drmdpy);
-}
-
-/**
- * Initialize KMS and pipe screen.
- */
-static boolean
-drm_display_init_screen(struct native_display *ndpy)
-{
-   struct drm_display *drmdpy = drm_display(ndpy);
-   drmVersionPtr version;
-
-   version = drmGetVersion(drmdpy->fd);
-   if (!version) {
-      _eglLog(_EGL_WARNING, "invalid fd %d", drmdpy->fd);
-      return FALSE;
-   }
-
-   drmdpy->base.screen =
-      drmdpy->event_handler->new_drm_screen(&drmdpy->base, NULL, drmdpy->fd);
-   drmFreeVersion(version);
-
-   if (!drmdpy->base.screen) {
-      _eglLog(_EGL_DEBUG, "failed to create DRM screen");
-      return FALSE;
+   if (drmdpy->own_gbm) {
+      gbm_device_destroy(&drmdpy->gbmdrm->base.base);
+      if (drmdpy->fd >= 0)
+         close(drmdpy->fd);
    }
 
-   return TRUE;
-}
-
-static struct pipe_resource *
-drm_display_import_buffer(struct native_display *ndpy,
-                          const struct pipe_resource *templ,
-                          void *buf)
-{
-   return ndpy->screen->resource_from_handle(ndpy->screen,
-         templ, (struct winsys_handle *) buf);
-}
-
-static boolean
-drm_display_export_buffer(struct native_display *ndpy,
-                          struct pipe_resource *res,
-                          void *buf)
-{
-   return ndpy->screen->resource_get_handle(ndpy->screen,
-         res, (struct winsys_handle *) buf);
+   FREE(drmdpy);
 }
 
 static struct native_display_buffer drm_display_buffer = {
-   drm_display_import_buffer,
-   drm_display_export_buffer
+   /* use the helpers */
+   drm_display_import_native_buffer,
+   drm_display_export_native_buffer
 };
 
 static int
@@ -281,9 +244,25 @@ static struct native_display_wayland_bufmgr drm_display_wayland_bufmgr = {
 
 #endif /* HAVE_WAYLAND_BACKEND */
 
+static struct native_surface *
+drm_create_pixmap_surface(struct native_display *ndpy,
+                              EGLNativePixmapType pix,
+                              const struct native_config *nconf)
+{
+   struct gbm_gallium_drm_bo *bo = (void *) pix;
+
+   return drm_display_create_surface_from_resource(ndpy, bo->resource);
+}
+
+static boolean
+drm_display_init_screen(struct native_display *ndpy)
+{
+   return TRUE;
+}
+
 static struct native_display *
-drm_create_display(int fd, struct native_event_handler *event_handler,
-                   void *user_data)
+drm_create_display(struct gbm_gallium_drm_device *gbmdrm, int own_gbm,
+                   const struct native_event_handler *event_handler)
 {
    struct drm_display *drmdpy;
 
@@ -291,20 +270,26 @@ drm_create_display(int fd, struct native_event_handler *event_handler,
    if (!drmdpy)
       return NULL;
 
-   drmdpy->fd = fd;
-   drmdpy->device_name = drm_get_device_name(fd);
+   drmdpy->gbmdrm = gbmdrm;
+   drmdpy->own_gbm = own_gbm;
+   drmdpy->fd = gbmdrm->base.base.fd;
+   drmdpy->device_name = drm_get_device_name(drmdpy->fd);
+
+   gbmdrm->lookup_egl_image = (struct pipe_resource *(*)(void *, void *))
+      event_handler->lookup_egl_image;
+   gbmdrm->lookup_egl_image_data = &drmdpy->base;
+
    drmdpy->event_handler = event_handler;
-   drmdpy->base.user_data = user_data;
 
-   if (!drm_display_init_screen(&drmdpy->base)) {
-      drm_display_destroy(&drmdpy->base);
-      return NULL;
-   }
+   drmdpy->base.screen = gbmdrm->screen;
 
+   drmdpy->base.init_screen = drm_display_init_screen;
    drmdpy->base.destroy = drm_display_destroy;
    drmdpy->base.get_param = drm_display_get_param;
    drmdpy->base.get_configs = drm_display_get_configs;
 
+   drmdpy->base.create_pixmap_surface = drm_create_pixmap_surface;
+
    drmdpy->base.buffer = &drm_display_buffer;
 #ifdef HAVE_WAYLAND_BACKEND
    if (drmdpy->device_name)
@@ -315,39 +300,47 @@ drm_create_display(int fd, struct native_event_handler *event_handler,
    return &drmdpy->base;
 }
 
-static struct native_event_handler *drm_event_handler;
-
-static void
-native_set_event_handler(struct native_event_handler *event_handler)
-{
-   drm_event_handler = event_handler;
-}
+static const struct native_event_handler *drm_event_handler;
 
 static struct native_display *
-native_create_display(void *dpy, boolean use_sw, void *user_data)
+native_create_display(void *dpy, boolean use_sw)
 {
+   struct gbm_gallium_drm_device *gbm;
    int fd;
+   int own_gbm = 0;
 
-   if (dpy) {
-      fd = dup((int) pointer_to_intptr(dpy));
-   }
-   else {
+   gbm = dpy;
+
+   if (gbm == NULL) {
       fd = open("/dev/dri/card0", O_RDWR);
+      /* FIXME: Use an internal constructor to create a gbm
+       * device with gallium backend directly, without setenv */
+      setenv("GBM_BACKEND", "gbm_gallium_drm.so", 1);
+      gbm = gbm_gallium_drm_device(gbm_create_device(fd));
+      own_gbm = 1;
    }
-   if (fd < 0)
+
+   if (gbm == NULL)
+      return NULL;
+   
+   if (strcmp(gbm_device_get_backend_name(&gbm->base.base), "drm") != 0 ||
+       gbm->base.type != GBM_DRM_DRIVER_TYPE_GALLIUM) {
+      if (own_gbm)
+         gbm_device_destroy(&gbm->base.base);
       return NULL;
+   }
 
-   return drm_create_display(fd, drm_event_handler, user_data);
+   return drm_create_display(gbm, own_gbm, drm_event_handler);
 }
 
 static const struct native_platform drm_platform = {
    "DRM", /* name */
-   native_set_event_handler,
    native_create_display
 };
 
 const struct native_platform *
-native_get_drm_platform(void)
+native_get_drm_platform(const struct native_event_handler *event_handler)
 {
+   drm_event_handler = event_handler;
    return &drm_platform;
 }
index 41cdc4f..18cebf4 100644 (file)
@@ -41,6 +41,8 @@
 #include "common/native_wayland_drm_bufmgr_helper.h"
 #endif
 
+#include "gbm_gallium_drmint.h"
+
 struct drm_config;
 struct drm_crtc;
 struct drm_connector;
@@ -50,8 +52,10 @@ struct drm_surface;
 struct drm_display {
    struct native_display base;
 
-   struct native_event_handler *event_handler;
+   const struct native_event_handler *event_handler;
 
+   struct gbm_gallium_drm_device *gbmdrm;
+   int own_gbm;
    int fd;
    char *device_name;
    struct drm_config *config;
@@ -154,4 +158,8 @@ drm_display_init_modeset(struct native_display *ndpy);
 void
 drm_display_fini_modeset(struct native_display *ndpy);
 
+struct native_surface *
+drm_display_create_surface_from_resource(struct native_display *ndpy,
+                                         struct pipe_resource *resource);
+
 #endif /* _NATIVE_DRM_H_ */
index e2fde00..6772d37 100644 (file)
  *    Chia-I Wu <olv@lunarg.com>
  */
 
+/**
+ * Considering fbdev as an in-kernel window system,
+ *
+ *  - opening a device opens a connection
+ *  - there is only one window: the framebuffer
+ *  - fb_var_screeninfo decides window position, size, and even color format
+ *  - there is no pixmap
+ *
+ * Now EGL is built on top of this window system.  So we should have
+ *
+ *  - the fd as the handle of the native display
+ *  - reject all but one native window: NULL
+ *  - no pixmap support
+ */
+
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -45,16 +60,13 @@ struct fbdev_display {
    struct native_display base;
 
    int fd;
-   struct native_event_handler *event_handler;
+   const struct native_event_handler *event_handler;
 
    struct fb_fix_screeninfo finfo;
-   struct fb_var_screeninfo vinfo;
-
+   struct fb_var_screeninfo config_vinfo;
    struct native_config config;
-   struct native_connector connector;
-   struct native_mode mode;
 
-   struct fbdev_surface *current_surface;
+   boolean assume_fixed_vinfo;
 };
 
 struct fbdev_surface {
@@ -66,7 +78,7 @@ struct fbdev_surface {
 
    unsigned int sequence_number;
 
-   boolean is_current;
+   struct fbdev_sw_drawable drawable;
 };
 
 static INLINE struct fbdev_display *
@@ -103,38 +115,70 @@ fbdev_surface_validate(struct native_surface *nsurf, uint attachment_mask,
    return TRUE;
 }
 
-static boolean
-fbdev_surface_flush_frontbuffer(struct native_surface *nsurf)
+static enum pipe_format
+vinfo_to_format(const struct fb_var_screeninfo *vinfo)
 {
-   struct fbdev_surface *fbsurf = fbdev_surface(nsurf);
+   enum pipe_format format = PIPE_FORMAT_NONE;
 
-   if (!fbsurf->is_current)
-      return TRUE;
+   /* should also check channel offsets... */
+   switch (vinfo->bits_per_pixel) {
+   case 32:
+      if (vinfo->red.length == 8 &&
+          vinfo->green.length == 8 &&
+          vinfo->blue.length == 8) {
+         format = (vinfo->transp.length == 8) ?
+            PIPE_FORMAT_B8G8R8A8_UNORM : PIPE_FORMAT_B8G8R8X8_UNORM;
+      }
+      break;
+   case 16:
+      if (vinfo->red.length == 5 &&
+          vinfo->green.length == 6 &&
+          vinfo->blue.length == 5 &&
+          vinfo->transp.length == 0)
+         format = PIPE_FORMAT_B5G6R5_UNORM;
+      break;
+   default:
+      break;
+   }
 
-   return resource_surface_present(fbsurf->rsurf,
-         NATIVE_ATTACHMENT_FRONT_LEFT, NULL);
+   return format;
 }
 
 static boolean
-fbdev_surface_swap_buffers(struct native_surface *nsurf)
+fbdev_surface_update_drawable(struct native_surface *nsurf,
+                              const struct fb_var_screeninfo *vinfo)
 {
    struct fbdev_surface *fbsurf = fbdev_surface(nsurf);
-   struct fbdev_display *fbdpy = fbsurf->fbdpy;
-   boolean ret = TRUE;
-
-   if (fbsurf->is_current) {
-      ret = resource_surface_present(fbsurf->rsurf,
-            NATIVE_ATTACHMENT_BACK_LEFT, NULL);
+   unsigned x, y, width, height;
+
+   x = vinfo->xoffset;
+   y = vinfo->yoffset;
+   width = MIN2(vinfo->xres, fbsurf->width);
+   height = MIN2(vinfo->yres, fbsurf->height);
+
+   /* sanitize the values */
+   if (x + width > vinfo->xres_virtual) {
+      if (x > vinfo->xres_virtual)
+         width = 0;
+      else
+         width = vinfo->xres_virtual - x;
+   }
+   if (y + height > vinfo->yres_virtual) {
+      if (y > vinfo->yres_virtual)
+         height = 0;
+      else
+         height = vinfo->yres_virtual - y;
    }
 
-   resource_surface_swap_buffers(fbsurf->rsurf,
-         NATIVE_ATTACHMENT_FRONT_LEFT, NATIVE_ATTACHMENT_BACK_LEFT, TRUE);
-   /* the front/back textures are swapped */
-   fbsurf->sequence_number++;
-   fbdpy->event_handler->invalid_surface(&fbdpy->base,
-         &fbsurf->base, fbsurf->sequence_number);
+   fbsurf->drawable.format = vinfo_to_format(vinfo);
+   fbsurf->drawable.x = vinfo->xoffset;
+   fbsurf->drawable.y = vinfo->yoffset;
+   fbsurf->drawable.width = vinfo->xres;
+   fbsurf->drawable.height = vinfo->yres;
 
-   return ret;
+   return (fbsurf->drawable.format != PIPE_FORMAT_NONE &&
+           fbsurf->drawable.width &&
+           fbsurf->drawable.height);
 }
 
 static boolean
@@ -143,21 +187,43 @@ fbdev_surface_present(struct native_surface *nsurf,
                       boolean preserve,
                       uint swap_interval)
 {
-   boolean ret;
+   struct fbdev_surface *fbsurf = fbdev_surface(nsurf);
+   struct fbdev_display *fbdpy = fbsurf->fbdpy;
+   boolean ret = FALSE;
 
-   if (preserve || swap_interval)
+   if (swap_interval)
+      return FALSE;
+   if (natt != NATIVE_ATTACHMENT_BACK_LEFT)
       return FALSE;
 
-   switch (natt) {
-   case NATIVE_ATTACHMENT_FRONT_LEFT:
-      ret = fbdev_surface_flush_frontbuffer(nsurf);
-      break;
-   case NATIVE_ATTACHMENT_BACK_LEFT:
-      ret = fbdev_surface_swap_buffers(nsurf);
-      break;
-   default:
-      ret = FALSE;
-      break;
+   if (!fbdpy->assume_fixed_vinfo) {
+      struct fb_var_screeninfo vinfo;
+
+      memset(&vinfo, 0, sizeof(vinfo));
+      if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &vinfo))
+         return FALSE;
+
+      /* present the surface */
+      if (fbdev_surface_update_drawable(&fbsurf->base, &vinfo)) {
+         ret = resource_surface_present(fbsurf->rsurf,
+               natt, (void *) &fbsurf->drawable);
+      }
+
+      fbsurf->width = vinfo.xres;
+      fbsurf->height = vinfo.yres;
+
+      if (resource_surface_set_size(fbsurf->rsurf,
+               fbsurf->width, fbsurf->height)) {
+         /* surface resized */
+         fbsurf->sequence_number++;
+         fbdpy->event_handler->invalid_surface(&fbdpy->base,
+               &fbsurf->base, fbsurf->sequence_number);
+      }
+   }
+   else {
+      /* the drawable never changes */
+      ret = resource_surface_present(fbsurf->rsurf,
+            natt, (void *) &fbsurf->drawable);
    }
 
    return ret;
@@ -179,26 +245,48 @@ fbdev_surface_destroy(struct native_surface *nsurf)
 }
 
 static struct native_surface *
-fbdev_display_create_scanout_surface(struct native_display *ndpy,
-                                   const struct native_config *nconf,
-                                   uint width, uint height)
+fbdev_display_create_window_surface(struct native_display *ndpy,
+                                    EGLNativeWindowType win,
+                                    const struct native_config *nconf)
 {
    struct fbdev_display *fbdpy = fbdev_display(ndpy);
    struct fbdev_surface *fbsurf;
+   struct fb_var_screeninfo vinfo;
+
+   /* there is only one native window: NULL */
+   if (win)
+      return NULL;
 
    fbsurf = CALLOC_STRUCT(fbdev_surface);
    if (!fbsurf)
       return NULL;
 
    fbsurf->fbdpy = fbdpy;
-   fbsurf->width = width;
-   fbsurf->height = height;
+
+   /* get current vinfo */
+   if (fbdpy->assume_fixed_vinfo) {
+      vinfo = fbdpy->config_vinfo;
+   }
+   else {
+      memset(&vinfo, 0, sizeof(vinfo));
+      if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &vinfo)) {
+         FREE(fbsurf);
+         return NULL;
+      }
+   }
+
+   fbsurf->width = vinfo.xres;
+   fbsurf->height = vinfo.yres;
+
+   if (!fbdev_surface_update_drawable(&fbsurf->base, &vinfo)) {
+      FREE(fbsurf);
+      return NULL;
+   }
 
    fbsurf->rsurf = resource_surface_create(fbdpy->base.screen,
          nconf->color_format,
          PIPE_BIND_RENDER_TARGET |
-         PIPE_BIND_DISPLAY_TARGET |
-         PIPE_BIND_SCANOUT);
+         PIPE_BIND_DISPLAY_TARGET);
    if (!fbsurf->rsurf) {
       FREE(fbsurf);
       return NULL;
@@ -214,42 +302,43 @@ fbdev_display_create_scanout_surface(struct native_display *ndpy,
    return &fbsurf->base;
 }
 
+static struct native_surface *
+fbdev_display_create_scanout_surface(struct native_display *ndpy,
+                                     const struct native_config *nconf,
+                                     uint width, uint height)
+{
+   return fbdev_display_create_window_surface(ndpy,
+         (EGLNativeWindowType) NULL, nconf);
+}
+
 static boolean
 fbdev_display_program(struct native_display *ndpy, int crtc_idx,
                       struct native_surface *nsurf, uint x, uint y,
                       const struct native_connector **nconns, int num_nconns,
                       const struct native_mode *nmode)
 {
-   struct fbdev_display *fbdpy = fbdev_display(ndpy);
-   struct fbdev_surface *fbsurf = fbdev_surface(nsurf);
-
-   if (x || y)
-      return FALSE;
-
-   if (fbdpy->current_surface) {
-      if (fbdpy->current_surface == fbsurf)
-         return TRUE;
-      fbdpy->current_surface->is_current = FALSE;
-   }
-
-   if (fbsurf)
-      fbsurf->is_current = TRUE;
-   fbdpy->current_surface = fbsurf;
-
    return TRUE;
 }
 
 static const struct native_mode **
 fbdev_display_get_modes(struct native_display *ndpy,
-                      const struct native_connector *nconn,
-                      int *num_modes)
+                        const struct native_connector *nconn,
+                        int *num_modes)
 {
-   struct fbdev_display *fbdpy = fbdev_display(ndpy);
+   static struct native_mode mode;
    const struct native_mode **modes;
 
+   if (!mode.desc) {
+      struct fbdev_display *fbdpy = fbdev_display(ndpy);
+      mode.desc = "Current Mode";
+      mode.width = fbdpy->config_vinfo.xres;
+      mode.height = fbdpy->config_vinfo.yres;
+      mode.refresh_rate = 60 * 1000; /* dummy */
+   }
+
    modes = MALLOC(sizeof(*modes));
    if (modes) {
-      modes[0] = &fbdpy->mode;
+      modes[0] = &mode;
       if (num_modes)
          *num_modes = 1;
    }
@@ -261,12 +350,12 @@ static const struct native_connector **
 fbdev_display_get_connectors(struct native_display *ndpy, int *num_connectors,
                            int *num_crtc)
 {
-   struct fbdev_display *fbdpy = fbdev_display(ndpy);
+   static struct native_connector connector;
    const struct native_connector **connectors;
 
    connectors = MALLOC(sizeof(*connectors));
    if (connectors) {
-      connectors[0] = &fbdpy->connector;
+      connectors[0] = &connector;
       if (num_connectors)
          *num_connectors = 1;
    }
@@ -274,7 +363,8 @@ fbdev_display_get_connectors(struct native_display *ndpy, int *num_connectors,
    return connectors;
 }
 
-static struct native_display_modeset fbdev_display_modeset = {
+/* remove modeset support one day! */
+static const struct native_display_modeset fbdev_display_modeset = {
    .get_connectors = fbdev_display_get_connectors,
    .get_modes = fbdev_display_get_modes,
    .create_scanout_surface = fbdev_display_create_scanout_surface,
@@ -304,8 +394,10 @@ fbdev_display_get_param(struct native_display *ndpy,
    int val;
 
    switch (param) {
-   case NATIVE_PARAM_USE_NATIVE_BUFFER:
    case NATIVE_PARAM_PRESERVE_BUFFER:
+      val = 1;
+      break;
+   case NATIVE_PARAM_USE_NATIVE_BUFFER:
    case NATIVE_PARAM_MAX_SWAP_INTERVAL:
    default:
       val = 0;
@@ -326,114 +418,55 @@ fbdev_display_destroy(struct native_display *ndpy)
 }
 
 static boolean
-fbdev_display_init_modes(struct native_display *ndpy)
+fbdev_display_init_screen(struct native_display *ndpy)
 {
    struct fbdev_display *fbdpy = fbdev_display(ndpy);
-   struct native_mode *nmode = &fbdpy->mode;
-
-   nmode->desc = "Current Mode";
-   nmode->width = fbdpy->vinfo.xres;
-   nmode->height = fbdpy->vinfo.yres;
-   nmode->refresh_rate = 60 * 1000; /* dummy */
-
-   return TRUE;
-}
-
-static boolean
-fbdev_display_init_connectors(struct native_display *ndpy)
-{
-   return TRUE;
-}
+   struct sw_winsys *ws;
 
-static enum pipe_format
-vinfo_to_format(const struct fb_var_screeninfo *vinfo)
-{
-   enum pipe_format format = PIPE_FORMAT_NONE;
+   ws = fbdev_create_sw_winsys(fbdpy->fd);
+   if (!ws)
+      return FALSE;
 
-   switch (vinfo->bits_per_pixel) {
-   case 32:
-      if (vinfo->red.length == 8 &&
-          vinfo->green.length == 8 &&
-          vinfo->blue.length == 8) {
-         format = (vinfo->transp.length == 8) ?
-            PIPE_FORMAT_B8G8R8A8_UNORM : PIPE_FORMAT_B8G8R8X8_UNORM;
-      }
-      break;
-   case 16:
-      if (vinfo->red.length == 5 &&
-          vinfo->green.length == 6 &&
-          vinfo->blue.length == 5 &&
-          vinfo->transp.length == 0)
-         format = PIPE_FORMAT_B5G6R5_UNORM;
-      break;
-   default:
-      break;
+   fbdpy->base.screen = fbdpy->event_handler->new_sw_screen(&fbdpy->base, ws);
+   if (!fbdpy->base.screen) {
+      if (ws->destroy)
+         ws->destroy(ws);
+      return FALSE;
    }
 
-   return format;
-}
-
-static boolean
-fbdev_display_init_configs(struct native_display *ndpy)
-{
-   struct fbdev_display *fbdpy = fbdev_display(ndpy);
-   struct native_config *nconf = &fbdpy->config;
-
-   nconf->color_format = vinfo_to_format(&fbdpy->vinfo);
-   if (nconf->color_format == PIPE_FORMAT_NONE)
+   if (!fbdpy->base.screen->is_format_supported(fbdpy->base.screen,
+            fbdpy->config.color_format, PIPE_TEXTURE_2D, 0,
+            PIPE_BIND_RENDER_TARGET)) {
+      fbdpy->base.screen->destroy(fbdpy->base.screen);
+      fbdpy->base.screen = NULL;
       return FALSE;
-
-   nconf->buffer_mask =
-      (1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
-      (1 << NATIVE_ATTACHMENT_BACK_LEFT);
-
-   nconf->scanout_bit = TRUE;
+   }
 
    return TRUE;
 }
 
 static boolean
-fbdev_display_init(struct native_display *ndpy)
+fbdev_display_init_config(struct native_display *ndpy)
 {
    struct fbdev_display *fbdpy = fbdev_display(ndpy);
-   struct sw_winsys *ws;
-
-   if (ioctl(fbdpy->fd, FBIOGET_FSCREENINFO, &fbdpy->finfo))
-      return FALSE;
+   struct native_config *nconf = &fbdpy->config;
 
-   if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &fbdpy->vinfo))
+   if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &fbdpy->config_vinfo))
       return FALSE;
 
-   if (fbdpy->finfo.visual != FB_VISUAL_TRUECOLOR ||
-       fbdpy->finfo.type != FB_TYPE_PACKED_PIXELS)
+   nconf->color_format = vinfo_to_format(&fbdpy->config_vinfo);
+   if (nconf->color_format == PIPE_FORMAT_NONE)
       return FALSE;
 
-   if (!fbdev_display_init_configs(&fbdpy->base) ||
-       !fbdev_display_init_connectors(&fbdpy->base) ||
-       !fbdev_display_init_modes(&fbdpy->base))
-      return FALSE;
+   nconf->buffer_mask = (1 << NATIVE_ATTACHMENT_BACK_LEFT);
 
-   ws = fbdev_create_sw_winsys(fbdpy->fd, fbdpy->config.color_format);
-   if (ws) {
-      fbdpy->base.screen =
-         fbdpy->event_handler->new_sw_screen(&fbdpy->base, ws);
-   }
+   nconf->window_bit = TRUE;
 
-   if (fbdpy->base.screen) {
-      if (!fbdpy->base.screen->is_format_supported(fbdpy->base.screen,
-               fbdpy->config.color_format, PIPE_TEXTURE_2D, 0,
-               PIPE_BIND_RENDER_TARGET)) {
-         fbdpy->base.screen->destroy(fbdpy->base.screen);
-         fbdpy->base.screen = NULL;
-      }
-   }
-
-   return (fbdpy->base.screen != NULL);
+   return TRUE;
 }
 
 static struct native_display *
-fbdev_display_create(int fd, struct native_event_handler *event_handler,
-                     void *user_data)
+fbdev_display_create(int fd, const struct native_event_handler *event_handler)
 {
    struct fbdev_display *fbdpy;
 
@@ -443,32 +476,41 @@ fbdev_display_create(int fd, struct native_event_handler *event_handler,
 
    fbdpy->fd = fd;
    fbdpy->event_handler = event_handler;
-   fbdpy->base.user_data = user_data;
 
-   if (!fbdev_display_init(&fbdpy->base)) {
-      FREE(fbdpy);
-      return NULL;
-   }
+   if (ioctl(fbdpy->fd, FBIOGET_FSCREENINFO, &fbdpy->finfo))
+      goto fail;
+
+   if (fbdpy->finfo.visual != FB_VISUAL_TRUECOLOR ||
+       fbdpy->finfo.type != FB_TYPE_PACKED_PIXELS)
+      goto fail;
+
+   if (!fbdev_display_init_config(&fbdpy->base))
+      goto fail;
 
+   fbdpy->assume_fixed_vinfo = TRUE;
+
+   fbdpy->base.init_screen = fbdev_display_init_screen;
    fbdpy->base.destroy = fbdev_display_destroy;
    fbdpy->base.get_param = fbdev_display_get_param;
    fbdpy->base.get_configs = fbdev_display_get_configs;
 
+   fbdpy->base.create_window_surface = fbdev_display_create_window_surface;
+
+   /* we'd like to remove modeset support one day */
+   fbdpy->config.scanout_bit = TRUE;
    fbdpy->base.modeset = &fbdev_display_modeset;
 
    return &fbdpy->base;
-}
 
-static struct native_event_handler *fbdev_event_handler;
-
-static void
-native_set_event_handler(struct native_event_handler *event_handler)
-{
-   fbdev_event_handler = event_handler;
+fail:
+   FREE(fbdpy);
+   return NULL;
 }
 
+static const struct native_event_handler *fbdev_event_handler;
+
 static struct native_display *
-native_create_display(void *dpy, boolean use_sw, void *user_data)
+native_create_display(void *dpy, boolean use_sw)
 {
    struct native_display *ndpy;
    int fd;
@@ -483,7 +525,7 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
    if (fd < 0)
       return NULL;
 
-   ndpy = fbdev_display_create(fd, fbdev_event_handler, user_data);
+   ndpy = fbdev_display_create(fd, fbdev_event_handler);
    if (!ndpy)
       close(fd);
 
@@ -492,12 +534,12 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
 
 static const struct native_platform fbdev_platform = {
    "FBDEV", /* name */
-   native_set_event_handler,
    native_create_display
 };
 
 const struct native_platform *
-native_get_fbdev_platform(void)
+native_get_fbdev_platform(const struct native_event_handler *event_handler)
 {
+   fbdev_event_handler = event_handler;
    return &fbdev_platform;
 }
index 5d0045f..6bf0d4e 100644 (file)
@@ -41,7 +41,7 @@ struct gdi_display {
    struct native_display base;
 
    HDC hDC;
-   struct native_event_handler *event_handler;
+   const struct native_event_handler *event_handler;
 
    struct native_config *configs;
    int num_configs;
@@ -368,35 +368,39 @@ gdi_display_destroy(struct native_display *ndpy)
    FREE(gdpy);
 }
 
-static struct native_display *
-gdi_create_display(HDC hDC, struct native_event_handler *event_handler,
-                   void *user_data)
+static boolean
+gdi_display_init_screen(struct native_display *ndpy)
 {
-   struct gdi_display *gdpy;
+   struct gdi_display *gdpy = gdi_display(ndpy);
    struct sw_winsys *winsys;
 
-   gdpy = CALLOC_STRUCT(gdi_display);
-   if (!gdpy)
-      return NULL;
-
-   gdpy->hDC = hDC;
-   gdpy->event_handler = event_handler;
-   gdpy->base.user_data = user_data;
-
    winsys = gdi_create_sw_winsys();
-   if (!winsys) {
-      FREE(gdpy);
-      return NULL;
-   }
+   if (!winsys)
+      return FALSE;
 
    gdpy->base.screen = gdpy->event_handler->new_sw_screen(&gdpy->base, winsys);
    if (!gdpy->base.screen) {
       if (winsys->destroy)
          winsys->destroy(winsys);
-      FREE(gdpy);
-      return NULL;
+      return FALSE;
    }
 
+   return TRUE;
+}
+
+static struct native_display *
+gdi_create_display(HDC hDC, const struct native_event_handler *event_handler)
+{
+   struct gdi_display *gdpy;
+
+   gdpy = CALLOC_STRUCT(gdi_display);
+   if (!gdpy)
+      return NULL;
+
+   gdpy->hDC = hDC;
+   gdpy->event_handler = event_handler;
+
+   gdpy->base.init_screen = gdi_display_init_screen;
    gdpy->base.destroy = gdi_display_destroy;
    gdpy->base.get_param = gdi_display_get_param;
 
@@ -406,28 +410,22 @@ gdi_create_display(HDC hDC, struct native_event_handler *event_handler,
    return &gdpy->base;
 }
 
-static struct native_event_handler *gdi_event_handler;
-
-static void
-native_set_event_handler(struct native_event_handler *event_handler)
-{
-   gdi_event_handler = event_handler;
-}
+static const struct native_event_handler *gdi_event_handler;
 
 static struct native_display *
-native_create_display(void *dpy, boolean use_sw, void *user_data)
+native_create_display(void *dpy, boolean use_sw)
 {
-   return gdi_create_display((HDC) dpy, gdi_event_handler, user_data);
+   return gdi_create_display((HDC) dpy, gdi_event_handler);
 }
 
 static const struct native_platform gdi_platform = {
    "GDI", /* name */
-   native_set_event_handler,
    native_create_display
 };
 
 const struct native_platform *
-native_get_gdi_platform(void)
+native_get_gdi_platform(const struct native_event_handler *event_handler)
 {
+   gdi_event_handler = event_handler;
    return &gdi_platform;
 }
index a9fd303..e34b24b 100644 (file)
@@ -51,7 +51,7 @@
 struct wayland_drm_display {
    struct wayland_display base;
 
-   struct native_event_handler *event_handler;
+   const struct native_event_handler *event_handler;
 
    struct wl_drm *wl_drm;
    struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
@@ -212,27 +212,10 @@ wayland_drm_display_init_screen(struct native_display *ndpy)
    return TRUE;
 }
 
-static struct pipe_resource *
-wayland_drm_display_import_buffer(struct native_display *ndpy,
-                                  const struct pipe_resource *templ,
-                                  void *buf)
-{
-   return ndpy->screen->resource_from_handle(ndpy->screen,
-                                             templ, (struct winsys_handle *) buf);
-}
-
-static boolean
-wayland_drm_display_export_buffer(struct native_display *ndpy,
-                                  struct pipe_resource *res,
-                                  void *buf)
-{
-   return ndpy->screen->resource_get_handle(ndpy->screen,
-                                            res, (struct winsys_handle *) buf);
-}
-
 static struct native_display_buffer wayland_drm_display_buffer = {
-   wayland_drm_display_import_buffer,
-   wayland_drm_display_export_buffer
+   /* use the helpers */
+   drm_display_import_native_buffer,
+   drm_display_export_native_buffer
 };
 
 static int
@@ -302,8 +285,7 @@ static struct native_display_wayland_bufmgr wayland_drm_display_wayland_bufmgr =
 
 struct wayland_display *
 wayland_create_drm_display(struct wl_display *dpy,
-                           struct native_event_handler *event_handler,
-                           void *user_data)
+                           const struct native_event_handler *event_handler)
 {
    struct wayland_drm_display *drmdpy;
 
@@ -312,7 +294,6 @@ wayland_create_drm_display(struct wl_display *dpy,
       return NULL;
 
    drmdpy->event_handler = event_handler;
-   drmdpy->base.base.user_data = user_data;
 
    drmdpy->base.dpy = dpy;
    if (!drmdpy->base.dpy) {
@@ -320,10 +301,7 @@ wayland_create_drm_display(struct wl_display *dpy,
       return NULL;
    }
 
-   if (!wayland_drm_display_init_screen(&drmdpy->base.base)) {
-      wayland_drm_display_destroy(&drmdpy->base.base);
-      return NULL;
-   }
+   drmdpy->base.base.init_screen = wayland_drm_display_init_screen;
    drmdpy->base.base.destroy = wayland_drm_display_destroy;
    drmdpy->base.base.buffer = &wayland_drm_display_buffer;
    drmdpy->base.base.wayland_bufmgr = &wayland_drm_display_wayland_bufmgr;
index 8614a76..1c07995 100644 (file)
@@ -47,7 +47,7 @@
 struct wayland_shm_display {
    struct wayland_display base;
 
-   struct native_event_handler *event_handler;
+   const struct native_event_handler *event_handler;
    struct wl_shm *wl_shm;
 };
 
@@ -144,8 +144,7 @@ wayland_shm_display_init_screen(struct native_display *ndpy)
 
 struct wayland_display *
 wayland_create_shm_display(struct wl_display *dpy,
-                           struct native_event_handler *event_handler,
-                           void *user_data)
+                           const struct native_event_handler *event_handler)
 {
    struct wayland_shm_display *shmdpy;
 
@@ -154,7 +153,6 @@ wayland_create_shm_display(struct wl_display *dpy,
       return NULL;
 
    shmdpy->event_handler = event_handler;
-   shmdpy->base.base.user_data = user_data;
 
    shmdpy->base.dpy = dpy;
    if (!shmdpy->base.dpy) {
@@ -162,11 +160,7 @@ wayland_create_shm_display(struct wl_display *dpy,
       return NULL;
    }
 
-   if (!wayland_shm_display_init_screen(&shmdpy->base.base)) {
-      wayland_shm_display_destroy(&shmdpy->base.base);
-      return NULL;
-   }
-
+   shmdpy->base.base.init_screen = wayland_shm_display_init_screen;
    shmdpy->base.base.destroy = wayland_shm_display_destroy;
    shmdpy->base.create_buffer = wayland_create_shm_buffer;
 
index 3d1bb6f..544d4be 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "native_wayland.h"
 
-static struct native_event_handler *wayland_event_handler;
+static const struct native_event_handler *wayland_event_handler;
 
 static void
 sync_callback(void *data)
@@ -114,11 +114,12 @@ wayland_display_get_param(struct native_display *ndpy,
 }
 
 static boolean
-wayland_display_is_pixmap_supported(struct native_display *ndpy,
-                                    EGLNativePixmapType pix,
-                                    const struct native_config *nconf)
+wayland_display_get_pixmap_format(struct native_display *ndpy,
+                                  EGLNativePixmapType pix,
+                                  enum pipe_format *format)
 {
    /* all wl_egl_pixmaps are supported */
+   *format = PIPE_FORMAT_NONE;
 
    return TRUE;
 }
@@ -195,13 +196,11 @@ wayland_window_surface_handle_resize(struct wayland_surface *surface)
             wl_buffer_destroy(surface->buffer[i]);
          surface->buffer[i] = NULL;
       }
+
+      surface->dx = surface->win->dx;
+      surface->dy = surface->win->dy;
    }
    pipe_resource_reference(&front_resource, NULL);
-
-   surface->dx = surface->win->dx;
-   surface->dy = surface->win->dy;
-   surface->win->dx = 0;
-   surface->win->dy = 0;
 }
 
 static boolean
@@ -449,14 +448,8 @@ wayland_create_window_surface(struct native_display *ndpy,
    return &surface->base;
 }
 
-static void
-native_set_event_handler(struct native_event_handler *event_handler)
-{
-   wayland_event_handler = event_handler;
-}
-
 static struct native_display *
-native_create_display(void *dpy, boolean use_sw, void *user_data)
+native_create_display(void *dpy, boolean use_sw)
 {
    struct wayland_display *display = NULL;
    boolean own_dpy = FALSE;
@@ -473,12 +466,10 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
    if (use_sw) {
       _eglLog(_EGL_INFO, "use software fallback");
       display = wayland_create_shm_display((struct wl_display *) dpy,
-                                           wayland_event_handler,
-                                           user_data);
+                                           wayland_event_handler);
    } else {
       display = wayland_create_drm_display((struct wl_display *) dpy,
-                                           wayland_event_handler,
-                                           user_data);
+                                           wayland_event_handler);
    }
 
    if (!display)
@@ -486,7 +477,8 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
 
    display->base.get_param = wayland_display_get_param;
    display->base.get_configs = wayland_display_get_configs;
-   display->base.is_pixmap_supported = wayland_display_is_pixmap_supported;
+   display->base.get_pixmap_format = wayland_display_get_pixmap_format;
+   display->base.copy_to_pixmap = native_display_copy_to_pixmap;
    display->base.create_window_surface = wayland_create_window_surface;
    display->base.create_pixmap_surface = wayland_create_pixmap_surface;
 
@@ -497,13 +489,13 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
 
 static const struct native_platform wayland_platform = {
    "wayland", /* name */
-   native_set_event_handler,
    native_create_display
 };
 
 const struct native_platform *
-native_get_wayland_platform(void)
+native_get_wayland_platform(const struct native_event_handler *event_handler)
 {
+   wayland_event_handler = event_handler;
    return &wayland_platform;
 }
 
index 81c7a8b..5390f2f 100644 (file)
@@ -103,11 +103,10 @@ wayland_config(const struct native_config *nconf)
 
 struct wayland_display *
 wayland_create_shm_display(struct wl_display *display,
-                           struct native_event_handler *event_handler,
-                           void *user_data);
+                           const struct native_event_handler *event_handler);
+
 struct wayland_display *
 wayland_create_drm_display(struct wl_display *display,
-                           struct native_event_handler *event_handler,
-                           void *user_data);
+                           const struct native_event_handler *event_handler);
 
 #endif /* _NATIVE_WAYLAND_H_ */
index a56d434..4b8be7b 100644 (file)
@@ -38,6 +38,7 @@
 #include "native_x11.h"
 #include "x11_screen.h"
 
+#include "common/native_helper.h"
 #ifdef HAVE_WAYLAND_BACKEND
 #include "common/native_wayland_drm_bufmgr_helper.h"
 #endif
@@ -49,7 +50,7 @@ struct dri2_display {
    Display *dpy;
    boolean own_dpy;
 
-   struct native_event_handler *event_handler;
+   const struct native_event_handler *event_handler;
 
    struct x11_screen *xscr;
    int xscr_number;
@@ -682,18 +683,30 @@ dri2_display_get_configs(struct native_display *ndpy, int *num_configs)
 }
 
 static boolean
-dri2_display_is_pixmap_supported(struct native_display *ndpy,
-                                 EGLNativePixmapType pix,
-                                 const struct native_config *nconf)
+dri2_display_get_pixmap_format(struct native_display *ndpy,
+                               EGLNativePixmapType pix,
+                               enum pipe_format *format)
 {
    struct dri2_display *dri2dpy = dri2_display(ndpy);
-   uint depth, nconf_depth;
+   boolean ret = EGL_TRUE;
+   uint depth;
 
    depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix);
-   nconf_depth = util_format_get_blocksizebits(nconf->color_format);
+   switch (depth) {
+   case 32:
+   case 24:
+      *format = PIPE_FORMAT_B8G8R8A8_UNORM;
+      break;
+   case 16:
+      *format = PIPE_FORMAT_B5G6R5_UNORM;
+      break;
+   default:
+      *format = PIPE_FORMAT_NONE;
+      ret = EGL_FALSE;
+      break;
+   }
 
-   /* simple depth match for now */
-   return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth));
+   return ret;
 }
 
 static int
@@ -870,8 +883,7 @@ static struct native_display_wayland_bufmgr dri2_display_wayland_bufmgr = {
 
 struct native_display *
 x11_create_dri2_display(Display *dpy,
-                        struct native_event_handler *event_handler,
-                        void *user_data)
+                        const struct native_event_handler *event_handler)
 {
    struct dri2_display *dri2dpy;
 
@@ -880,7 +892,6 @@ x11_create_dri2_display(Display *dpy,
       return NULL;
 
    dri2dpy->event_handler = event_handler;
-   dri2dpy->base.user_data = user_data;
 
    dri2dpy->dpy = dpy;
    if (!dri2dpy->dpy) {
@@ -899,11 +910,6 @@ x11_create_dri2_display(Display *dpy,
       return NULL;
    }
 
-   if (!dri2_display_init_screen(&dri2dpy->base)) {
-      dri2_display_destroy(&dri2dpy->base);
-      return NULL;
-   }
-
    dri2dpy->surfaces = util_hash_table_create(dri2_display_hash_table_hash,
          dri2_display_hash_table_compare);
    if (!dri2dpy->surfaces) {
@@ -911,10 +917,12 @@ x11_create_dri2_display(Display *dpy,
       return NULL;
    }
 
+   dri2dpy->base.init_screen = dri2_display_init_screen;
    dri2dpy->base.destroy = dri2_display_destroy;
    dri2dpy->base.get_param = dri2_display_get_param;
    dri2dpy->base.get_configs = dri2_display_get_configs;
-   dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;
+   dri2dpy->base.get_pixmap_format = dri2_display_get_pixmap_format;
+   dri2dpy->base.copy_to_pixmap = native_display_copy_to_pixmap;
    dri2dpy->base.create_window_surface = dri2_display_create_window_surface;
    dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface;
 #ifdef HAVE_WAYLAND_BACKEND
@@ -928,8 +936,7 @@ x11_create_dri2_display(Display *dpy,
 
 struct native_display *
 x11_create_dri2_display(Display *dpy,
-                        struct native_event_handler *event_handler,
-                        void *user_data)
+                        const struct native_event_handler *event_handler)
 {
    return NULL;
 }
index a0bcad4..ef038b5 100644 (file)
 
 #include "native_x11.h"
 
-static struct native_event_handler *x11_event_handler;
-
-static void
-native_set_event_handler(struct native_event_handler *event_handler)
-{
-   x11_event_handler = event_handler;
-}
+static const struct native_event_handler *x11_event_handler;
 
 static struct native_display *
-native_create_display(void *dpy, boolean use_sw, void *user_data)
+native_create_display(void *dpy, boolean use_sw)
 {
    struct native_display *ndpy = NULL;
    boolean force_sw;
@@ -48,12 +42,10 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
 
    if (force_sw || use_sw) {
       _eglLog(_EGL_INFO, "use software fallback");
-      ndpy = x11_create_ximage_display((Display *) dpy,
-            x11_event_handler, user_data);
+      ndpy = x11_create_ximage_display((Display *) dpy, x11_event_handler);
    }
    else {
-      ndpy = x11_create_dri2_display((Display *) dpy,
-            x11_event_handler, user_data);
+      ndpy = x11_create_dri2_display((Display *) dpy, x11_event_handler);
    }
 
    return ndpy;
@@ -61,12 +53,12 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
 
 static const struct native_platform x11_platform = {
    "X11", /* name */
-   native_set_event_handler,
    native_create_display
 };
 
 const struct native_platform *
-native_get_x11_platform(void)
+native_get_x11_platform(const struct native_event_handler *event_handler)
 {
+   x11_event_handler = event_handler;
    return &x11_platform;
 }
index 8945117..d3c9270 100644 (file)
 
 struct native_display *
 x11_create_ximage_display(Display *dpy,
-                          struct native_event_handler *event_handler,
-                          void *user_data);
+                          const struct native_event_handler *event_handler);
 
 struct native_display *
 x11_create_dri2_display(Display *dpy,
-                        struct native_event_handler *event_handler,
-                        void *user_data);
+                        const struct native_event_handler *event_handler);
 
 #endif /* _NATIVE_X11_H_ */
index 8e32c6f..e7794f0 100644 (file)
@@ -43,7 +43,7 @@ struct ximage_display {
    Display *dpy;
    boolean own_dpy;
 
-   struct native_event_handler *event_handler;
+   const struct native_event_handler *event_handler;
 
    struct x11_screen *xscr;
    int xscr_number;
@@ -437,14 +437,54 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs)
 }
 
 static boolean
-ximage_display_is_pixmap_supported(struct native_display *ndpy,
-                                   EGLNativePixmapType pix,
-                                   const struct native_config *nconf)
+ximage_display_get_pixmap_format(struct native_display *ndpy,
+                                 EGLNativePixmapType pix,
+                                 enum pipe_format *format)
 {
    struct ximage_display *xdpy = ximage_display(ndpy);
-   enum pipe_format fmt = get_pixmap_format(&xdpy->base, pix);
 
-   return (fmt == nconf->color_format);
+   *format = get_pixmap_format(&xdpy->base, pix);
+
+   return (*format != PIPE_FORMAT_NONE);
+}
+
+static boolean
+ximage_display_copy_to_pixmap(struct native_display *ndpy,
+                              EGLNativePixmapType pix,
+                              struct pipe_resource *src)
+{
+   /* fast path to avoid unnecessary allocation and resource_copy_region */
+   if (src->bind & PIPE_BIND_DISPLAY_TARGET) {
+      struct ximage_display *xdpy = ximage_display(ndpy);
+      enum pipe_format fmt = get_pixmap_format(&xdpy->base, pix);
+      const struct ximage_config *xconf;
+      struct xlib_drawable xdraw;
+      int i;
+
+      if (fmt == PIPE_FORMAT_NONE || src->format != fmt)
+         return FALSE;
+
+      for (i = 0; i < xdpy->num_configs; i++) {
+         if (xdpy->configs[i].base.color_format == fmt) {
+            xconf = &xdpy->configs[i];
+            break;
+         }
+      }
+      if (!xconf)
+         return FALSE;
+
+      memset(&xdraw, 0, sizeof(xdraw));
+      xdraw.visual = xconf->visual->visual;
+      xdraw.depth = xconf->visual->depth;
+      xdraw.drawable = (Drawable) pix;
+
+      xdpy->base.screen->flush_frontbuffer(xdpy->base.screen,
+            src, 0, 0, &xdraw);
+
+      return TRUE;
+   }
+
+   return native_display_copy_to_pixmap(ndpy, pix, src);
 }
 
 static int
@@ -484,13 +524,32 @@ ximage_display_destroy(struct native_display *ndpy)
    FREE(xdpy);
 }
 
+static boolean
+ximage_display_init_screen(struct native_display *ndpy)
+{
+   struct ximage_display *xdpy = ximage_display(ndpy);
+   struct sw_winsys *winsys;
+
+   winsys = xlib_create_sw_winsys(xdpy->dpy);
+   if (!winsys)
+      return FALSE;
+
+   xdpy->base.screen =
+      xdpy->event_handler->new_sw_screen(&xdpy->base, winsys);
+   if (!xdpy->base.screen) {
+      if (winsys->destroy)
+         winsys->destroy(winsys);
+      return FALSE;
+   }
+
+   return TRUE;
+}
+
 struct native_display *
 x11_create_ximage_display(Display *dpy,
-                          struct native_event_handler *event_handler,
-                          void *user_data)
+                          const struct native_event_handler *event_handler)
 {
    struct ximage_display *xdpy;
-   struct sw_winsys *winsys = NULL;
 
    xdpy = CALLOC_STRUCT(ximage_display);
    if (!xdpy)
@@ -507,39 +566,25 @@ x11_create_ximage_display(Display *dpy,
    }
 
    xdpy->event_handler = event_handler;
-   xdpy->base.user_data = user_data;
 
    xdpy->xscr_number = DefaultScreen(xdpy->dpy);
    xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number);
-   if (!xdpy->xscr)
-      goto fail;
-
-   winsys = xlib_create_sw_winsys(xdpy->dpy);
-   if (!winsys)
-      goto fail;
-
-   xdpy->base.screen =
-      xdpy->event_handler->new_sw_screen(&xdpy->base, winsys);
-   if (!xdpy->base.screen)
-      goto fail;
+   if (!xdpy->xscr) {
+      if (xdpy->own_dpy)
+         XCloseDisplay(xdpy->dpy);
+      FREE(xdpy);
+      return NULL;
+   }
 
+   xdpy->base.init_screen = ximage_display_init_screen;
    xdpy->base.destroy = ximage_display_destroy;
    xdpy->base.get_param = ximage_display_get_param;
 
    xdpy->base.get_configs = ximage_display_get_configs;
-   xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported;
+   xdpy->base.get_pixmap_format = ximage_display_get_pixmap_format;
+   xdpy->base.copy_to_pixmap = ximage_display_copy_to_pixmap;
    xdpy->base.create_window_surface = ximage_display_create_window_surface;
    xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface;
 
    return &xdpy->base;
-
-fail:
-   if (winsys && winsys->destroy)
-      winsys->destroy(winsys);
-   if (xdpy->xscr)
-      x11_screen_destroy(xdpy->xscr);
-   if (xdpy->dpy && xdpy->own_dpy)
-      XCloseDisplay(xdpy->dpy);
-   FREE(xdpy);
-   return NULL;
 }
index f1cc440..6155b4d 100644 (file)
@@ -452,6 +452,12 @@ dri2InvalidateBuffers(Display *dpy, XID drawable)
 extern unsigned
 dri2GetSwapEventType(Display *dpy, XID drawable);
 
+extern void *
+dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
+
+extern void *
+GetGLXDrawable(Display *dpy, XID drawable);
+
 /**
  * This is also called from src/glx/dri2.c.
  */
@@ -460,4 +466,16 @@ unsigned dri2GetSwapEventType(Display *dpy, XID drawable)
    return 0;
 }
 
+void *
+dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id)
+{
+   return NULL;
+}
+
+void *
+GetGLXDrawable(Display *dpy, XID drawable)
+{
+   return NULL;
+}
+
 #endif /* GLX_DIRECT_RENDERING */
diff --git a/src/gallium/state_trackers/gbm/Makefile b/src/gallium/state_trackers/gbm/Makefile
new file mode 100644 (file)
index 0000000..1d96eb2
--- /dev/null
@@ -0,0 +1,46 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+gbm_INCLUDES = \
+       -I. \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gbm/main \
+       -I$(TOP)/include
+
+gbm_SOURCES = $(wildcard *.c)
+gbm_OBJECTS = $(gbm_SOURCES:.c=.o)
+
+ALL_INCLUDES = $(gbm_INCLUDES)
+ALL_SOURCES = $(gbm_SOURCES)
+
+GBM_OBJECTS = $(gbm_OBJECTS)
+GBM_CPPFLAGS = $(gbm_INCLUDES)
+
+##### TARGETS #####
+
+default: depend libgbm.a
+
+libgbm.a: $(GBM_OBJECTS) Makefile
+       $(MKLIB) -o gbm -static $(GBM_OBJECTS)
+
+depend: 
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(ALL_INCLUDES) $(ALL_SOURCES) 2> /dev/null
+
+clean:
+       rm -f libgbm.a
+       rm -f $(GBM_OBJECTS)
+       rm -f depend depend.bak
+
+# Dummy target
+install:
+       @echo -n ""
+
+##### RULES #####
+
+$(gbm_OBJECTS): %.o: %.c
+       $(CC) -c $(GBM_CPPFLAGS) $(DEFINES) $(CFLAGS) $< -o $@
+
+sinclude depend
diff --git a/src/gallium/state_trackers/gbm/gbm_drm.c b/src/gallium/state_trackers/gbm/gbm_drm.c
new file mode 100644 (file)
index 0000000..d4baf87
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+
+#include "state_tracker/drm_driver.h"
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "gbm_gallium_drmint.h"
+
+static INLINE enum pipe_format
+gbm_format_to_gallium(enum gbm_bo_format format)
+{
+   switch (format) {
+   case GBM_BO_FORMAT_XRGB8888:
+      return PIPE_FORMAT_B8G8R8X8_UNORM;
+   case GBM_BO_FORMAT_ARGB8888:
+      return PIPE_FORMAT_B8G8R8A8_UNORM;
+   default:
+      return PIPE_FORMAT_NONE;
+   }
+
+   return PIPE_FORMAT_NONE;
+}
+
+static INLINE uint
+gbm_usage_to_gallium(uint usage)
+{
+   uint resource_usage = 0;
+
+   if (usage & GBM_BO_USE_SCANOUT)
+      resource_usage |= PIPE_BIND_SCANOUT;
+
+   if (usage & GBM_BO_USE_RENDERING)
+      resource_usage |= PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+
+   if (usage & GBM_BO_USE_CURSOR_64X64)
+      resource_usage |= PIPE_BIND_CURSOR;
+
+   return resource_usage;
+}
+
+static int
+gbm_gallium_drm_is_format_supported(struct gbm_device *gbm,
+                                    enum gbm_bo_format format,
+                                    uint32_t usage)
+{
+   struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm);
+   enum pipe_format pf;
+
+   pf = gbm_format_to_gallium(format);
+   if (pf == PIPE_FORMAT_NONE)
+      return 0;
+
+   if (!gdrm->screen->is_format_supported(gdrm->screen, PIPE_TEXTURE_2D, pf, 0,
+                                          gbm_usage_to_gallium(usage)))
+      return 0;
+
+   if (usage & GBM_BO_USE_SCANOUT && format != GBM_BO_FORMAT_XRGB8888)
+      return 0;
+
+   return 1;
+}
+
+static void
+gbm_gallium_drm_bo_destroy(struct gbm_bo *_bo)
+{
+   struct gbm_gallium_drm_bo *bo = gbm_gallium_drm_bo(_bo);
+
+   pipe_resource_reference(&bo->resource, NULL);
+   free(bo);
+}
+
+static struct gbm_bo *
+gbm_gallium_drm_bo_create_from_egl_image(struct gbm_device *gbm,
+                                         void *egl_dpy, void *egl_image,
+                                         uint32_t width, uint32_t height,
+                                         uint32_t usage)
+{
+   struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm);
+   struct gbm_gallium_drm_bo *bo;
+   struct winsys_handle whandle;
+
+   if (!gdrm->lookup_egl_image)
+      return NULL;
+
+   bo = CALLOC_STRUCT(gbm_gallium_drm_bo);
+   if (bo == NULL)
+      return NULL;
+
+   bo->resource = gdrm->lookup_egl_image(gdrm->lookup_egl_image_data,
+                                         egl_image);
+   if (bo->resource == NULL) {
+      FREE(bo);
+      return NULL;
+   }
+
+   bo->base.base.gbm = gbm;
+   bo->base.base.width = width;
+   bo->base.base.height = height;
+
+   memset(&whandle, 0, sizeof(whandle));
+   whandle.type = DRM_API_HANDLE_TYPE_KMS;
+   gdrm->screen->resource_get_handle(gdrm->screen, bo->resource, &whandle);
+
+   bo->base.base.handle.u32 = whandle.handle;
+   bo->base.base.pitch      = whandle.stride;
+
+   return &bo->base.base;
+}
+
+static struct gbm_bo *
+gbm_gallium_drm_bo_create(struct gbm_device *gbm,
+                          uint32_t width, uint32_t height,
+                          enum gbm_bo_format format, uint32_t usage)
+{
+   struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm);
+   struct gbm_gallium_drm_bo *bo;
+   struct pipe_resource templ;
+   struct winsys_handle whandle;
+   enum pipe_format pf;
+
+   bo = CALLOC_STRUCT(gbm_gallium_drm_bo);
+   if (bo == NULL)
+      return NULL;
+
+   bo->base.base.gbm = gbm;
+   bo->base.base.width = width;
+   bo->base.base.height = height;
+
+   pf = gbm_format_to_gallium(format);
+   if (pf == PIPE_FORMAT_NONE)
+      return NULL;
+
+   memset(&templ, 0, sizeof(templ));
+   templ.bind = gbm_usage_to_gallium(usage);
+   templ.format = pf;
+   templ.target = PIPE_TEXTURE_2D;
+   templ.last_level = 0;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
+   templ.array_size = 1;
+
+   bo->resource = gdrm->screen->resource_create(gdrm->screen, &templ);
+   if (bo->resource == NULL) {
+      FREE(bo);
+      return NULL;
+   }
+
+   memset(&whandle, 0, sizeof(whandle));
+   whandle.type = DRM_API_HANDLE_TYPE_KMS;
+   gdrm->screen->resource_get_handle(gdrm->screen, bo->resource, &whandle);
+
+   bo->base.base.handle.u32 = whandle.handle;
+   bo->base.base.pitch      = whandle.stride;
+
+   return &bo->base.base;
+}
+
+static void
+gbm_gallium_drm_destroy(struct gbm_device *gbm)
+{
+   struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm);
+
+   gdrm->screen->destroy(gdrm->screen);
+
+   FREE(gdrm->base.driver_name);
+
+   FREE(gdrm);
+}
+
+struct gbm_device *
+gbm_gallium_drm_device_create(int fd)
+{
+   struct gbm_gallium_drm_device *gdrm;
+   int ret;
+
+   gdrm = calloc(1, sizeof *gdrm);
+
+   gdrm->base.base.fd = fd;
+   gdrm->base.base.bo_create = gbm_gallium_drm_bo_create;
+   gdrm->base.base.bo_create_from_egl_image =
+      gbm_gallium_drm_bo_create_from_egl_image;
+   gdrm->base.base.bo_destroy = gbm_gallium_drm_bo_destroy;
+   gdrm->base.base.is_format_supported = gbm_gallium_drm_is_format_supported;
+   gdrm->base.base.destroy = gbm_gallium_drm_destroy;
+
+   gdrm->base.type = GBM_DRM_DRIVER_TYPE_GALLIUM;
+   gdrm->base.base.name = "drm";
+
+   ret = gallium_screen_create(gdrm);
+   if (ret) {
+      free(gdrm);
+      return NULL;
+   }
+
+   return &gdrm->base.base;
+}
diff --git a/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h b/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h
new file mode 100644 (file)
index 0000000..6277b8d
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#ifndef _GBM_GALLIUM_DRMINT_H_
+#define _GBM_GALLIUM_DRMINT_H_
+
+#include "pipe/p_state.h"
+
+#include "gbmint.h"
+
+#include "common.h"
+#include "common_drm.h"
+
+struct gbm_gallium_drm_device {
+   struct gbm_drm_device base;
+
+   struct pipe_screen *screen;
+   void *driver;
+
+   struct pipe_resource *(*lookup_egl_image)(void *data,
+                                             void *egl_image);
+   void *lookup_egl_image_data;
+
+};
+
+struct gbm_gallium_drm_bo {
+   struct gbm_drm_bo base;
+
+   struct pipe_resource *resource;
+};
+
+static inline struct gbm_gallium_drm_device *
+gbm_gallium_drm_device(struct gbm_device *gbm)
+{
+   return (struct gbm_gallium_drm_device *) gbm;
+}
+
+static inline struct gbm_gallium_drm_bo *
+gbm_gallium_drm_bo(struct gbm_bo *bo)
+{
+   return (struct gbm_gallium_drm_bo *) bo;
+}
+
+struct gbm_device *
+gbm_gallium_drm_device_create(int fd);
+
+int
+gallium_screen_create(struct gbm_gallium_drm_device *gdrm);
+
+#endif
index 6233fb8..a7aafd8 100644 (file)
@@ -864,16 +864,19 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
             parselist++;
             break;
          case GLX_FBCONFIG_ID:
+         case GLX_VISUAL_ID:
             if (!fbConfig)
                return NULL;
             parselist++;
             desiredVisualID = *parselist++;
             break;
          case GLX_X_RENDERABLE:
+         case GLX_MAX_PBUFFER_WIDTH:
+         case GLX_MAX_PBUFFER_HEIGHT:
+         case GLX_MAX_PBUFFER_PIXELS:
             if (!fbConfig)
-               return NULL;
-            parselist += 2;
-            /* ignore */
+               return NULL; /* invalid config option */
+            parselist += 2; /* ignore the parameter */
             break;
 
 #ifdef GLX_EXT_texture_from_pixmap
index ab4f675..8f6406d 100644 (file)
@@ -59,6 +59,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 #include "pipe/p_context.h"
+#include "util/u_atomic.h"
 
 #include "xm_public.h"
 #include <GL/glx.h>
@@ -1113,10 +1114,7 @@ XMesaDestroyBuffer(XMesaBuffer b)
 void
 xmesa_notify_invalid_buffer(XMesaBuffer b)
 {
-   XMesaContext xmctx = XMesaGetCurrentContext();
-
-   if (xmctx && xmctx->xm_buffer == b)
-      xmctx->st->notify_invalid_framebuffer(xmctx->st, b->stfb);
+   p_atomic_inc(&b->stfb->stamp);
 }
 
 
@@ -1126,11 +1124,18 @@ xmesa_notify_invalid_buffer(XMesaBuffer b)
 void
 xmesa_check_buffer_size(XMesaBuffer b)
 {
+   GLuint old_width, old_height;
+
    if (b->type == PBUFFER)
       return;
 
+   old_width = b->width;
+   old_height = b->height;
+
    xmesa_get_window_size(b->xm_visual->display, b, &b->width, &b->height);
-   xmesa_notify_invalid_buffer(b);
+
+   if (b->width != old_width || b->height != old_height)
+      xmesa_notify_invalid_buffer(b);
 }
 
 
index 6bfe8b0..ec3f531 100644 (file)
@@ -30,6 +30,7 @@
 #include "xm_st.h"
 
 #include "util/u_inlines.h"
+#include "util/u_atomic.h"
 
 struct xmesa_st_framebuffer {
    XMesaDisplay display;
@@ -302,6 +303,7 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b)
    stfbi->visual = &xstfb->stvis;
    stfbi->flush_front = xmesa_st_framebuffer_flush_front;
    stfbi->validate = xmesa_st_framebuffer_validate;
+   p_atomic_set(&stfbi->stamp, 1);
    stfbi->st_manager_private = (void *) xstfb;
 
    return stfbi;
diff --git a/src/gallium/state_trackers/va/Makefile b/src/gallium/state_trackers/va/Makefile
new file mode 100644 (file)
index 0000000..d5b3ec3
--- /dev/null
@@ -0,0 +1,28 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = vatracker
+
+VA_MAJOR = 0
+VA_MINOR = 3
+LIBRARY_DEFINES = -DVER_MAJOR=$(VA_MAJOR) -DVER_MINOR=$(VA_MINOR) $(STATE_TRACKER_DEFINES)
+
+LIBRARY_INCLUDES = \
+       $(shell pkg-config --cflags-only-I libva) \
+       -I$(TOP)/src/gallium/winsys/g3dvl
+
+C_SOURCES = htab.c \
+           ftab.c \
+           va_context.c \
+           va_image.c \
+           va_subpicture.c \
+           va_buffer.c \
+           va_config.c \
+            va_picture.c \
+            va_surface.c \
+           va_display.c
+           
+
+
+include ../../Makefile.template
+
diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c
new file mode 100644 (file)
index 0000000..dc9513e
--- /dev/null
@@ -0,0 +1,136 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+#include <va/va_backend.h>
+
+#include "va_private.h"
+
+static struct VADriverVTable vtable =
+{
+   &vlVaTerminate, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */
+   &vlVaQueryConfigProfiles, /* VAStatus (*vaQueryConfigProfiles) ( VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); */
+   &vlVaQueryConfigEntrypoints, /* VAStatus (*vaQueryConfigEntrypoints) ( VADriverContextP ctx,        VAProfile profile, VAEntrypoint  *entrypoint_list, int *num_entrypoints ); */
+   &vlVaGetConfigAttributes, /* VAStatus (*vaGetConfigAttributes) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs ); */
+   &vlVaCreateConfig, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,        VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */
+   &vlVaDestroyConfig, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id); */
+   &vlVaQueryConfigAttributes, /* VAStatus (*vaQueryConfigAttributes) ( VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); */
+   &vlVaCreateSurfaces, /* VAStatus (*vaCreateSurfaces) ( VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces); */
+   &vlVaDestroySurfaces, /* VAStatus (*vaDestroySurfaces) ( VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces ); */
+   &vlVaCreateContext, /* VAStatus (*vaCreateContext) (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context); */
+   &vlVaDestroyContext, /* VAStatus (*vaDestroyContext) (VADriverContextP ctx,VAContextID context); */
+   &vlVaCreateBuffer, /* VAStatus (*vaCreateBuffer) (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id); */
+   &vlVaBufferSetNumElements, /* VAStatus (*vaBufferSetNumElements) (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); */
+   &vlVaMapBuffer, /* VAStatus (*vaMapBuffer) (VADriverContextP ctx,VABufferID buf_id,void **pbuf); */
+   &vlVaUnmapBuffer, /* VAStatus (*vaUnmapBuffer) (VADriverContextP ctx,VABufferID buf_id); */
+   &vlVaDestroyBuffer, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */
+   &vlVaBeginPicture, /* VAStatus (*vaBeginPicture) (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); */
+   &vlVaRenderPicture, /* VAStatus (*vaRenderPicture) (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); */
+   &vlVaEndPicture, /* VAStatus (*vaEndPicture) (VADriverContextP ctx,VAContextID context); */
+   &vlVaSyncSurface, /* VAStatus (*vaSyncSurface) (VADriverContextP ctx,VASurfaceID render_target); */
+   &vlVaQuerySurfaceStatus, /* VAStatus (*vaQuerySurfaceStatus) (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status); */
+   &vlVaPutSurface, /* VAStatus (*vaPutSurface) (
+      VADriverContextP ctx,
+      VASurfaceID surface,
+      void* draw,
+      short srcx,
+      short srcy,
+      unsigned short srcw,
+      unsigned short srch,
+      short destx,
+      short desty,
+      unsigned short destw,
+      unsigned short desth,
+      VARectangle *cliprects,
+      unsigned int number_cliprects,
+      unsigned int flags); */
+   &vlVaQueryImageFormats, /* VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list,int *num_formats); */
+   &vlVaCreateImage, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */
+   &vlVaDeriveImage, /* VAStatus (*vaDeriveImage) (VADriverContextP ctx,VASurfaceID surface,VAImage *image); */
+   &vlVaDestroyImage, /* VAStatus (*vaDestroyImage) (VADriverContextP ctx,VAImageID image); */
+   &vlVaSetImagePalette, /* VAStatus (*vaSetImagePalette) (VADriverContextP ctx,VAImageID image, unsigned char *palette); */
+   &vlVaGetImage, /* VAStatus (*vaGetImage) (VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image); */
+   &vlVaPutImage, /* VAStatus (*vaPutImage) (
+      VADriverContextP ctx,
+      VASurfaceID surface,
+      VAImageID image,
+      int src_x,
+      int src_y,
+      unsigned int src_width,
+      unsigned int src_height,
+      int dest_x,
+      int dest_y,
+      unsigned int dest_width,
+      unsigned int dest_height
+   ); */
+   &vlVaQuerySubpictureFormats,        /* VAStatus (*vaQuerySubpictureFormats) (VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); */
+   &vlVaCreateSubpicture, /* VAStatus (*vaCreateSubpicture) (VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture); */
+   &vlVaDestroySubpicture, /* VAStatus (*vaDestroySubpicture) (VADriverContextP ctx,VASubpictureID subpicture); */
+   &vlVaSubpictureImage, /* VAStatus (*vaSetSubpictureImage) (VADriverContextP ctx,VASubpictureID subpicture,VAImageID image); */
+   &vlVaSetSubpictureChromakey, /* VAStatus (*vaSetSubpictureChromakey) (VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask); */
+   &vlVaSetSubpictureGlobalAlpha, /* VAStatus (*vaSetSubpictureGlobalAlpha) (VADriverContextP ctx,VASubpictureID subpicture,float global_alpha); */
+   &vlVaAssociateSubpicture, /* VAStatus (*vaAssociateSubpicture) (
+      VADriverContextP ctx,
+      VASubpictureID subpicture,
+      VASurfaceID *target_surfaces,
+      int num_surfaces,
+      short src_x,
+      short src_y,
+      unsigned short src_width,
+      unsigned short src_height,
+      short dest_x,
+      short dest_y,
+      unsigned short dest_width,
+      unsigned short dest_height,
+      unsigned int flags); */
+   &vlVaDeassociateSubpicture, /* VAStatus (*vaDeassociateSubpicture) (VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces); */
+   &vlVaQueryDisplayAttributes, /* VAStatus (*vaQueryDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes); */
+   &vlVaGetDisplayAttributes, /* VAStatus (*vaGetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */
+   &vlVaSetDisplayAttributes, /* VAStatus (*vaSetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */
+   &vlVaBufferInfo, /* VAStatus (*vaBufferInfo) (VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements); */
+   &vlVaLockSurface, /* VAStatus (*vaLockSurface) (
+      VADriverContextP ctx,
+      VASurfaceID surface,
+      unsigned int *fourcc,
+      unsigned int *luma_stride,
+      unsigned int *chroma_u_stride,
+      unsigned int *chroma_v_stride,
+      unsigned int *luma_offset,
+      unsigned int *chroma_u_offset,
+      unsigned int *chroma_v_offset,
+      unsigned int *buffer_name,
+      void **buffer); */
+   &vlVaUnlockSurface, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */
+   NULL /* struct VADriverVTableGLX *glx; "Optional" */
+};
+
+struct VADriverVTable vlVaGetVtable()
+{
+   return vtable;
+}
diff --git a/src/gallium/state_trackers/va/htab.c b/src/gallium/state_trackers/va/htab.c
new file mode 100644 (file)
index 0000000..40b9eda
--- /dev/null
@@ -0,0 +1,95 @@
+/**************************************************************************
+ *
+ * Copyright 2010 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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_handle_table.h>
+#include <os/os_thread.h>
+
+#include "va_private.h"
+
+#ifdef VL_HANDLES
+static struct handle_table *htab = NULL;
+pipe_static_mutex(htab_lock);
+#endif
+
+bool vlCreateHTAB(void)
+{
+#ifdef VL_HANDLES
+   bool ret;
+   /* Make sure handle table handles match VAAPI handles. */
+   assert(sizeof(unsigned) <= sizeof(VAGenericID));
+   pipe_mutex_lock(htab_lock);
+   if (!htab)
+      htab = handle_table_create();
+   ret = htab != NULL;
+   pipe_mutex_unlock(htab_lock);
+   return ret;
+#else
+   return TRUE;
+#endif
+}
+
+void vlDestroyHTAB(void)
+{
+#ifdef VL_HANDLES
+   pipe_mutex_lock(htab_lock);
+   if (htab) {
+      handle_table_destroy(htab);
+      htab = NULL;
+   }
+   pipe_mutex_unlock(htab_lock);
+#endif
+}
+
+VAGenericID vlAddDataHTAB(void *data)
+{
+   assert(data);
+#ifdef VL_HANDLES
+   VAGenericID handle = 0;
+   pipe_mutex_lock(htab_lock);
+   if (htab)
+      handle = handle_table_add(htab, data);
+   pipe_mutex_unlock(htab_lock);
+   return handle;
+#else
+   return (VAGenericID)data;
+#endif
+}
+
+void* vlGetDataHTAB(VAGenericID handle)
+{
+   assert(handle);
+#ifdef VL_HANDLES
+   void *data = NULL;
+   pipe_mutex_lock(htab_lock);
+   if (htab)
+      data = handle_table_get(htab, handle);
+   pipe_mutex_unlock(htab_lock);
+   return data;
+#else
+   return (void*)handle;
+#endif
+}
diff --git a/src/gallium/state_trackers/va/va_buffer.c b/src/gallium/state_trackers/va/va_buffer.c
new file mode 100644 (file)
index 0000000..d14e06d
--- /dev/null
@@ -0,0 +1,88 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+#include <va/va_backend.h>
+
+#include "va_private.h"
+
+VAStatus
+vlVaCreateBuffer(VADriverContextP ctx, VAContextID context, VABufferType type,
+                 unsigned int size, unsigned int num_elements, void *data,
+                 VABufferID *buf_id)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, unsigned int num_elements)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buffer_id)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaBufferInfo(VADriverContextP ctx, VAContextID context, VABufferID buf_id,
+               VABufferType *type, unsigned int *size, unsigned int *num_elements)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_config.c b/src/gallium/state_trackers/va/va_config.c
new file mode 100644 (file)
index 0000000..6f1cb78
--- /dev/null
@@ -0,0 +1,121 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+#include <va/va_backend.h>
+
+#include <util/u_debug.h>
+
+#include "va_private.h"
+
+VAStatus
+vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, int *num_profiles)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   int i = 0;
+
+   profile_list[i++] = VAProfileMPEG2Simple;
+   *num_profiles = i;
+
+   return VA_STATUS_SUCCESS;
+}
+
+
+VAStatus
+vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile,
+                           VAEntrypoint *entrypoint_list, int *num_entrypoints)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+               
+   VAStatus vaStatus = VA_STATUS_SUCCESS;
+
+   switch (profile) {
+   case VAProfileMPEG2Simple:
+   case VAProfileMPEG2Main:
+      VA_INFO("Using profile %08x\n",profile);
+      entrypoint_list[0] = VAEntrypointMoComp;
+      *num_entrypoints = 1;
+      break;
+
+   case VAProfileH264Baseline:
+   case VAProfileH264Main:
+   case VAProfileH264High:
+      vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+      *num_entrypoints = 0;
+      break;
+
+   default:
+      VA_ERROR("Unsupported profile %08x\n",profile);
+      vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+      *num_entrypoints = 0;
+      break;
+   }
+
+   return vaStatus;
+}
+
+VAStatus
+vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
+                        VAConfigAttrib *attrib_list, int num_attribs)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
+                 VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile *profile,
+                          VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_context.c b/src/gallium/state_trackers/va/va_context.c
new file mode 100644 (file)
index 0000000..62ba3d2
--- /dev/null
@@ -0,0 +1,106 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+#include <va/va_backend.h>
+
+#include <pipe/p_screen.h>
+#include <pipe/p_screen.h>
+#include <pipe/p_video_decoder.h>
+
+#include <util/u_debug.h>
+#include <util/u_memory.h>
+
+#include <vl_winsys.h>
+
+#include "va_private.h"
+
+PUBLIC VAStatus
+__vaDriverInit_0_31(VADriverContextP ctx)
+{
+   vlVaDriverContextPriv *driver_context = NULL;
+       
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+               
+               
+   /* Create private driver context */
+   driver_context = CALLOC(1,sizeof(vlVaDriverContextPriv));
+   if (!driver_context)
+      return VA_STATUS_ERROR_ALLOCATION_FAILED;
+               
+   driver_context->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
+   if (!driver_context->vscreen) {
+      FREE(driver_context);
+      return VA_STATUS_ERROR_ALLOCATION_FAILED;
+   }
+               
+   ctx->str_vendor = "mesa gallium vaapi";
+   ctx->vtable = vlVaGetVtable();
+   ctx->max_attributes = 1;
+   ctx->max_display_attributes = 1;
+   ctx->max_entrypoints = VA_MAX_ENTRYPOINTS;
+   ctx->max_image_formats = VA_MAX_IMAGE_FORMATS_SUPPORTED;
+   ctx->max_profiles = 1;
+   ctx->max_subpic_formats = VA_MAX_SUBPIC_FORMATS_SUPPORTED;
+   ctx->version_major = 3;
+   ctx->version_minor = 1;
+   ctx->pDriverData = (void *)driver_context;
+
+   VA_INFO("vl_screen_pointer %p\n",ctx->native_dpy);
+
+   return VA_STATUS_SUCCESS;
+}
+
+VAStatus
+vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
+                  int picture_height, int flag, VASurfaceID *render_targets,
+                  int num_render_targets, VAContextID *conext)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaDestroyContext(VADriverContextP ctx, VAContextID context)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaTerminate(VADriverContextP ctx)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_display.c b/src/gallium/state_trackers/va/va_display.c
new file mode 100644 (file)
index 0000000..11116d0
--- /dev/null
@@ -0,0 +1,63 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+ #include <va/va_backend.h>
+ #include "va_private.h"
+
+VAStatus
+vlVaQueryDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int *num_attributes)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   if (!(attr_list && num_attributes))
+      return VA_STATUS_ERROR_UNKNOWN;
+
+   *num_attributes = 0;
+
+   return VA_STATUS_SUCCESS;
+}
+
+VAStatus
+vlVaGetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaSetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_image.c b/src/gallium/state_trackers/va/va_image.c
new file mode 100644 (file)
index 0000000..43c3a94
--- /dev/null
@@ -0,0 +1,151 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+#include <va/va_backend.h>
+
+#include <pipe/p_format.h>
+
+#include <util/u_memory.h>
+#include <util/u_format.h>
+#include <util/u_debug.h>
+
+#include "va_private.h"
+
+typedef struct  {
+   enum pipe_format pipe_format;
+   VAImageFormat       va_format;
+} va_image_formats_supported_t;
+
+static const va_image_formats_supported_t va_image_formats_supported[VA_MAX_IMAGE_FORMATS_SUPPORTED] = 
+{
+   { PIPE_FORMAT_B8G8R8A8_UNORM,
+      { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }},
+   { PIPE_FORMAT_R8G8B8A8_UNORM, 
+      { VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }}
+};
+
+VAStatus
+vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num_formats)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   if (!(format_list && num_formats))
+      return VA_STATUS_ERROR_UNKNOWN;
+               
+   int n = 0;
+       
+   num_formats[0] = VA_MAX_IMAGE_FORMATS_SUPPORTED;
+       
+   /* Query supported formats */
+   for (n = 0; n < VA_MAX_IMAGE_FORMATS_SUPPORTED; n++) {
+      format_list[n] = va_image_formats_supported[n].va_format;
+   }
+
+   return VA_STATUS_SUCCESS;
+}
+
+VAStatus
+vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int height, VAImage *image)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   if(!format)
+      return VA_STATUS_ERROR_UNKNOWN;
+               
+   if (!(width && height))
+      return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
+               
+   if (!vlCreateHTAB())
+      return VA_STATUS_ERROR_UNKNOWN; 
+               
+   switch (format->fourcc) {
+   case VA_FOURCC('B','G','R','A'):
+      VA_INFO("Creating BGRA image of size %dx%d\n",width,height);
+      break;
+   case VA_FOURCC_RGBA:
+      VA_INFO("Creating RGBA image of size %dx%d\n",width,height);
+      break;
+   default:
+      VA_ERROR("Couldn't create image of type %0x08\n",format->fourcc);
+      return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
+   }
+               
+   VA_INFO("Image %p created successfully\n",format);
+       
+   return VA_STATUS_SUCCESS;
+}
+
+VAStatus
+vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaDestroyImage(VADriverContextP ctx, VAImageID image)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaSetImagePalette(VADriverContextP ctx, VAImageID image, unsigned char *palette)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y,
+             unsigned int width, unsigned int height, VAImageID image)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image,
+             int src_x, int src_y, unsigned int src_width, unsigned int src_height,
+             int dest_x, int dest_y, unsigned int dest_width, unsigned int dest_height)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_picture.c b/src/gallium/state_trackers/va/va_picture.c
new file mode 100644 (file)
index 0000000..3b52a6a
--- /dev/null
@@ -0,0 +1,60 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+#include <va/va_backend.h>
+
+#include <util/u_debug.h>
+
+#include "va_private.h"
+
+VAStatus
+vlVaBeginPicture(VADriverContextP ctx, VAContextID context, VASurfaceID render_target)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaRenderPicture(VADriverContextP ctx, VAContextID context, VABufferID *buffers, int num_buffers)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaEndPicture(VADriverContextP ctx, VAContextID context)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h
new file mode 100644 (file)
index 0000000..f1023db
--- /dev/null
@@ -0,0 +1,162 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 VA_PRIVATE_H
+#define VA_PRIVATE_H
+
+#include <va/va.h>
+#include <va/va_backend.h>
+
+#include <pipe/p_format.h>
+#include <pipe/p_state.h>
+
+#define VA_DEBUG(_str,...) debug_printf("[Gallium VA backend]: " _str,__VA_ARGS__)
+#define VA_INFO(_str,...) VA_DEBUG("INFO: " _str,__VA_ARGS__)
+#define VA_WARNING(_str,...) VA_DEBUG("WARNING: " _str,__VA_ARGS__)
+#define VA_ERROR(_str,...) VA_DEBUG("ERROR: " _str,__VA_ARGS__)
+
+#define VA_MAX_IMAGE_FORMATS_SUPPORTED 2
+#define VA_MAX_SUBPIC_FORMATS_SUPPORTED 2
+#define VA_MAX_ENTRYPOINTS 1
+
+#define VL_HANDLES
+
+typedef struct {
+   struct vl_screen *vscreen;
+   struct pipe_surface *backbuffer;
+} vlVaDriverContextPriv;
+
+typedef struct {
+   unsigned int width;
+   unsigned int height;
+   enum pipe_video_chroma_format format;
+   VADriverContextP ctx;
+} vlVaSurfacePriv;
+
+// Public functions:
+VAStatus __vaDriverInit_0_31 (VADriverContextP ctx);
+
+// Private functions:
+struct VADriverVTable vlVaGetVtable();
+
+bool vlCreateHTAB(void);
+void vlDestroyHTAB(void);
+VAGenericID vlAddDataHTAB(void *data);
+void* vlGetDataHTAB(VAGenericID handle);
+
+// Vtable functions:
+VAStatus vlVaTerminate (VADriverContextP ctx);
+VAStatus vlVaQueryConfigProfiles (VADriverContextP ctx, VAProfile *profile_list,int *num_profiles);
+VAStatus vlVaQueryConfigEntrypoints (VADriverContextP ctx, VAProfile profile, VAEntrypoint  *entrypoint_list, int *num_entrypoints);
+VAStatus vlVaGetConfigAttributes (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs);
+VAStatus vlVaCreateConfig (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id);
+VAStatus vlVaDestroyConfig (VADriverContextP ctx, VAConfigID config_id);
+VAStatus vlVaQueryConfigAttributes (VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs);
+VAStatus vlVaCreateSurfaces (VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces);
+VAStatus vlVaDestroySurfaces (VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces);
+VAStatus vlVaCreateContext (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context);
+VAStatus vlVaDestroyContext (VADriverContextP ctx,VAContextID context);
+VAStatus vlVaCreateBuffer (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id);
+VAStatus vlVaBufferSetNumElements (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements);
+VAStatus vlVaMapBuffer (VADriverContextP ctx,VABufferID buf_id,void **pbuf);
+VAStatus vlVaUnmapBuffer (VADriverContextP ctx,VABufferID buf_id);
+VAStatus vlVaDestroyBuffer (VADriverContextP ctx,VABufferID buffer_id);
+VAStatus vlVaBeginPicture (VADriverContextP ctx,VAContextID context,VASurfaceID render_target);
+VAStatus vlVaRenderPicture (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers);
+VAStatus vlVaEndPicture (VADriverContextP ctx,VAContextID context);
+VAStatus vlVaSyncSurface (VADriverContextP ctx,VASurfaceID render_target);
+VAStatus vlVaQuerySurfaceStatus (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status);
+VAStatus vlVaPutSurface (VADriverContextP ctx,
+                         VASurfaceID surface,
+                         void* draw,
+                         short srcx,
+                         short srcy,
+                         unsigned short srcw,
+                         unsigned short srch,
+                         short destx,
+                         short desty,
+                         unsigned short destw,
+                         unsigned short desth,
+                         VARectangle *cliprects,
+                         unsigned int number_cliprects,
+                         unsigned int flags);
+VAStatus vlVaQueryImageFormats (VADriverContextP ctx,VAImageFormat *format_list,int *num_formats);
+VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats);
+VAStatus vlVaCreateImage(VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image);
+VAStatus vlVaDeriveImage(VADriverContextP ctx,VASurfaceID surface,VAImage *image);
+VAStatus vlVaDestroyImage(VADriverContextP ctx,VAImageID image);
+VAStatus vlVaSetImagePalette(VADriverContextP ctx,VAImageID image, unsigned char *palette);
+VAStatus vlVaGetImage(VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image);
+VAStatus vlVaPutImage(VADriverContextP ctx,
+                      VASurfaceID surface,
+                      VAImageID image,
+                      int src_x,
+                      int src_y,
+                      unsigned int src_width,
+                      unsigned int src_height,
+                      int dest_x,
+                      int dest_y,
+                      unsigned int dest_width,
+                      unsigned int dest_height);
+VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats);
+VAStatus vlVaCreateSubpicture(VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture);
+VAStatus vlVaDestroySubpicture(VADriverContextP ctx,VASubpictureID subpicture);
+VAStatus vlVaSubpictureImage(VADriverContextP ctx,VASubpictureID subpicture,VAImageID image);
+VAStatus vlVaSetSubpictureChromakey(VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask);
+VAStatus vlVaSetSubpictureGlobalAlpha(VADriverContextP ctx,VASubpictureID subpicture,float global_alpha);
+VAStatus vlVaAssociateSubpicture(VADriverContextP ctx,
+                                 VASubpictureID subpicture,
+                                 VASurfaceID *target_surfaces,
+                                 int num_surfaces,
+                                 short src_x,
+                                 short src_y,
+                                 unsigned short src_width,
+                                 unsigned short src_height,
+                                 short dest_x,
+                                 short dest_y,
+                                 unsigned short dest_width,
+                                 unsigned short dest_height,
+                                 unsigned int flags);
+VAStatus vlVaDeassociateSubpicture(VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces);
+VAStatus vlVaQueryDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes);
+VAStatus vlVaGetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes);
+VAStatus vlVaSetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes);
+VAStatus vlVaBufferInfo(VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements);
+VAStatus vlVaLockSurface(VADriverContextP ctx,
+                         VASurfaceID surface,
+                         unsigned int *fourcc,
+                         unsigned int *luma_stride,
+                         unsigned int *chroma_u_stride,
+                         unsigned int *chroma_v_stride,
+                         unsigned int *luma_offset,
+                         unsigned int *chroma_u_offset,
+                         unsigned int *chroma_v_offset,
+                         unsigned int *buffer_name,
+                         void **buffer);
+VAStatus vlVaUnlockSurface(VADriverContextP ctx,VASurfaceID surface);
+
+#endif //VA_PRIVATE_H
diff --git a/src/gallium/state_trackers/va/va_subpicture.c b/src/gallium/state_trackers/va/va_subpicture.c
new file mode 100644 (file)
index 0000000..3f370e5
--- /dev/null
@@ -0,0 +1,143 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+#include <va/va_backend.h>
+
+#include <pipe/p_format.h>
+
+#include "va_private.h"
+
+typedef struct  {
+   enum pipe_format pipe_format;
+   VAImageFormat    va_format;
+   unsigned int     va_flags;
+} va_subpicture_formats_supported_t;
+
+static const va_subpicture_formats_supported_t va_subpicture_formats_supported[VA_MAX_SUBPIC_FORMATS_SUPPORTED + 1] = 
+{
+   { PIPE_FORMAT_B8G8R8A8_UNORM,
+      { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 },
+      0 },
+   { PIPE_FORMAT_R8G8B8A8_UNORM, 
+      { VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 },
+      0 }
+};
+
+VAStatus
+vlVaQuerySubpictureFormats(VADriverContextP ctx, VAImageFormat *format_list,
+                           unsigned int *flags, unsigned int *num_formats)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+               
+   if (!(format_list && flags && num_formats))
+      return VA_STATUS_ERROR_UNKNOWN;
+               
+   num_formats[0] = VA_MAX_SUBPIC_FORMATS_SUPPORTED;
+               
+   int n = 0;
+   /* Query supported formats */
+   for (n = 0; n < VA_MAX_SUBPIC_FORMATS_SUPPORTED ; n++) {
+      const va_subpicture_formats_supported_t * const format_map = &va_subpicture_formats_supported[n];
+      flags[n] = format_map->va_flags;
+      format_list[n] = format_map->va_format;
+   }
+
+   return VA_STATUS_SUCCESS;
+}
+
+VAStatus
+vlVaCreateSubpicture(VADriverContextP ctx, VAImageID image, VASubpictureID *subpicture)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaDestroySubpicture(VADriverContextP ctx, VASubpictureID subpicture)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaSubpictureImage(VADriverContextP ctx, VASubpictureID subpicture, VAImageID image)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaSetSubpictureChromakey(VADriverContextP ctx, VASubpictureID subpicture,
+                           unsigned int chromakey_min, unsigned int chromakey_max, unsigned int chromakey_mask)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaSetSubpictureGlobalAlpha(VADriverContextP ctx, VASubpictureID subpicture, float global_alpha)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaAssociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture, VASurfaceID *target_surfaces,
+                        int num_surfaces, short src_x, short src_y,
+                        unsigned short src_width, unsigned short src_height,
+                        short dest_x, short dest_y,
+                        unsigned short dest_width,
+                        unsigned short dest_height,
+                        unsigned int flags)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaDeassociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture,
+                          VASurfaceID *target_surfaces, int num_surfaces)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_surface.c b/src/gallium/state_trackers/va/va_surface.c
new file mode 100644 (file)
index 0000000..b7f9732
--- /dev/null
@@ -0,0 +1,142 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <va/va.h>
+#include <va/va_backend.h>
+#include <util/u_debug.h>
+#include <util/u_memory.h>
+#include "va_private.h"
+
+static enum pipe_video_chroma_format
+VaRTFormatToPipe(unsigned int va_type)
+{
+   switch (va_type) {
+   case VA_RT_FORMAT_YUV420:
+      return PIPE_VIDEO_CHROMA_FORMAT_420;
+   case VA_RT_FORMAT_YUV422:
+      return PIPE_VIDEO_CHROMA_FORMAT_422;
+   case VA_RT_FORMAT_YUV444:
+      return PIPE_VIDEO_CHROMA_FORMAT_444;
+   default:
+      assert(0);
+   }
+
+   return -1;
+}
+
+VAStatus
+vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format,
+                   int num_surfaces, VASurfaceID *surfaces)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   /* We only support one format */
+   if (VA_RT_FORMAT_YUV420 != format)
+      return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
+               
+   if (!(width && height))
+      return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
+               
+   if (!vlCreateHTAB())
+      return VA_STATUS_ERROR_UNKNOWN; 
+               
+   vlVaSurfacePriv *va_surface = (vlVaSurfacePriv *)CALLOC(num_surfaces,sizeof(vlVaSurfacePriv));
+   if (!va_surface)
+      return VA_STATUS_ERROR_ALLOCATION_FAILED;
+               
+   int n = 0;
+   for (n = 0; n < num_surfaces; n++) {
+      va_surface[n].width = width;
+      va_surface[n].height = height;
+      va_surface[n].format = VaRTFormatToPipe(format);
+      va_surface[n].ctx = ctx;
+      surfaces[n] = vlAddDataHTAB((void *)(va_surface + n));
+   }
+
+   return VA_STATUS_SUCCESS;
+}
+
+VAStatus
+vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaQuerySurfaceStatus(VADriverContextP ctx, VASurfaceID render_target, VASurfaceStatus *status)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface, void* draw, short srcx, short srcy,
+               unsigned short srcw, unsigned short srch, short destx, short desty,
+               unsigned short destw, unsigned short desth, VARectangle *cliprects,
+               unsigned int number_cliprects,  unsigned int flags)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaLockSurface(VADriverContextP ctx, VASurfaceID surface, unsigned int *fourcc,
+                unsigned int *luma_stride, unsigned int *chroma_u_stride, unsigned int *chroma_v_stride,
+                unsigned int *luma_offset, unsigned int *chroma_u_offset, unsigned int *chroma_v_offset,
+                unsigned int *buffer_name, void **buffer)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface)
+{
+   if (!ctx)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile
new file mode 100644 (file)
index 0000000..c1fd0eb
--- /dev/null
@@ -0,0 +1,28 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = vdpautracker
+
+VDPAU_MAJOR = 1
+VDPAU_MINOR = 0
+LIBRARY_DEFINES = -DVER_MAJOR=$(VDPAU_MAJOR) -DVER_MINOR=$(VDPAU_MINOR) $(STATE_TRACKER_DEFINES)
+
+LIBRARY_INCLUDES = \
+       $(shell pkg-config --cflags-only-I vdpau) \
+       -I$(TOP)/src/gallium/winsys/g3dvl
+
+C_SOURCES = htab.c \
+           ftab.c \
+           device.c \
+           query.c \
+           surface.c \
+           decode.c \
+           presentation.c \
+           bitmap.c \
+           output.c \
+           preemption.c \
+           mixer.c
+
+
+include ../../Makefile.template
+
diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c
new file mode 100644 (file)
index 0000000..e336568
--- /dev/null
@@ -0,0 +1,74 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <vdpau/vdpau.h>
+
+#include "vdpau_private.h"
+
+VdpStatus
+vlVdpBitmapSurfaceCreate(VdpDevice device,
+                         VdpRGBAFormat rgba_format,
+                         uint32_t width, uint32_t height,
+                         VdpBool frequently_accessed,
+                         VdpBitmapSurface *surface)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating a bitmap surface\n");
+   if (!surface)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpBitmapSurfaceDestroy(VdpBitmapSurface surface)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpBitmapSurfaceGetParameters(VdpBitmapSurface surface,
+                                VdpRGBAFormat *rgba_format,
+                                uint32_t *width, uint32_t *height,
+                                VdpBool *frequently_accessed)
+{
+   if (!(rgba_format && width && height && frequently_accessed))
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface,
+                                void const *const *source_data,
+                                uint32_t const *source_pitches,
+                                VdpRect const *destination_rect )
+{
+   if (!(source_data && source_pitches && destination_rect))
+       return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
new file mode 100644 (file)
index 0000000..96542f8
--- /dev/null
@@ -0,0 +1,274 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <util/u_math.h>
+#include <util/u_debug.h>
+
+#include "vdpau_private.h"
+
+VdpStatus
+vlVdpDecoderCreate(VdpDevice device,
+                   VdpDecoderProfile profile,
+                   uint32_t width, uint32_t height,
+                   uint32_t max_references,
+                   VdpDecoder *decoder)
+{
+   enum pipe_video_profile p_profile;
+   struct pipe_context *pipe;
+   vlVdpDevice *dev;
+   vlVdpDecoder *vldecoder;
+   VdpStatus ret;
+   unsigned i;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating decoder\n");
+
+   if (!decoder)
+      return VDP_STATUS_INVALID_POINTER;
+
+   if (!(width && height))
+      return VDP_STATUS_INVALID_VALUE;
+
+   p_profile = ProfileToPipe(profile);
+   if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN)
+      return VDP_STATUS_INVALID_DECODER_PROFILE;
+
+   dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   pipe = dev->context->pipe;
+
+   vldecoder = CALLOC(1,sizeof(vlVdpDecoder));
+   if (!vldecoder)
+      return VDP_STATUS_RESOURCES;
+
+   vldecoder->device = dev;
+
+   // TODO: Define max_references. Used mainly for H264
+   vldecoder->decoder = pipe->create_video_decoder
+   (
+      pipe, p_profile,
+      PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+      PIPE_VIDEO_CHROMA_FORMAT_420,
+      width, height
+   );
+   if (!vldecoder->decoder) {
+      ret = VDP_STATUS_ERROR;
+      goto error_decoder;
+   }
+
+   vldecoder->cur_buffer = 0;
+
+   for (i = 0; i < VL_NUM_DECODE_BUFFERS; ++i) {
+      vldecoder->buffer[i] = vldecoder->decoder->create_buffer(vldecoder->decoder);
+      if (!vldecoder->buffer[i]) {
+         ret = VDP_STATUS_ERROR;
+         goto error_buffer;
+      }
+   }
+
+   *decoder = vlAddDataHTAB(vldecoder);
+   if (*decoder == 0) {
+      ret = VDP_STATUS_ERROR;
+      goto error_handle;
+   }
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoder created succesfully\n");
+
+   return VDP_STATUS_OK;
+
+error_handle:
+error_buffer:
+
+   for (i = 0; i < VL_NUM_DECODE_BUFFERS; ++i)
+      if (vldecoder->buffer[i])
+         vldecoder->buffer[i]->destroy(vldecoder->buffer[i]);
+
+   vldecoder->decoder->destroy(vldecoder->decoder);
+
+error_decoder:
+   FREE(vldecoder);
+   return ret;
+}
+
+VdpStatus
+vlVdpDecoderDestroy(VdpDecoder decoder)
+{
+   vlVdpDecoder *vldecoder;
+   unsigned i;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying decoder\n");
+
+   vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
+   if (!vldecoder)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   for (i = 0; i < VL_NUM_DECODE_BUFFERS; ++i)
+      if (vldecoder->buffer[i])
+         vldecoder->buffer[i]->destroy(vldecoder->buffer[i]);
+
+   vldecoder->decoder->destroy(vldecoder->decoder);
+
+   FREE(vldecoder);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpDecoderGetParameters(VdpDecoder decoder,
+                          VdpDecoderProfile *profile,
+                          uint32_t *width,
+                          uint32_t *height)
+{
+   vlVdpDecoder *vldecoder;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] decoder get parameters called\n");
+
+   vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
+   if (!vldecoder)
+      return VDP_STATUS_INVALID_HANDLE;
+      
+   *profile = PipeToProfile(vldecoder->decoder->profile);
+   *width = vldecoder->decoder->width;
+   *height = vldecoder->decoder->height;
+   
+   return VDP_STATUS_OK;
+}
+
+static VdpStatus
+vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder,
+                         struct pipe_video_decode_buffer *buffer,
+                         struct pipe_video_buffer *target,
+                         VdpPictureInfoMPEG1Or2 *picture_info,
+                         uint32_t bitstream_buffer_count,
+                         VdpBitstreamBuffer const *bitstream_buffers)
+{
+   struct pipe_mpeg12_picture_desc picture;
+   struct pipe_video_buffer *ref_frames[2];
+   uint8_t intra_quantizer_matrix[64];
+   unsigned num_ycbcr_blocks[3] = { 0, 0, 0 };
+   unsigned i;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG2\n");
+
+   /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
+   if (picture_info->forward_reference ==  VDP_INVALID_HANDLE)
+      ref_frames[0] = NULL;
+   else {
+      ref_frames[0] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer;
+      if (!ref_frames[0])
+         return VDP_STATUS_INVALID_HANDLE;
+   }
+
+   if (picture_info->backward_reference ==  VDP_INVALID_HANDLE)
+      ref_frames[1] = NULL;
+   else {
+      ref_frames[1] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer;
+      if (!ref_frames[1])
+         return VDP_STATUS_INVALID_HANDLE;
+   }
+
+   memset(&picture, 0, sizeof(picture));
+   picture.base.profile = decoder->profile;
+   picture.picture_coding_type = picture_info->picture_coding_type;
+   picture.picture_structure = picture_info->picture_structure;
+   picture.frame_pred_frame_dct = picture_info->frame_pred_frame_dct;
+   picture.q_scale_type = picture_info->q_scale_type;
+   picture.alternate_scan = picture_info->alternate_scan;
+   picture.intra_vlc_format = picture_info->intra_vlc_format;
+   picture.concealment_motion_vectors = picture_info->concealment_motion_vectors;
+   picture.f_code[0][0] = picture_info->f_code[0][0] - 1;
+   picture.f_code[0][1] = picture_info->f_code[0][1] - 1;
+   picture.f_code[1][0] = picture_info->f_code[1][0] - 1;
+   picture.f_code[1][1] = picture_info->f_code[1][1] - 1;
+
+   buffer->begin_frame(buffer);
+
+   memcpy(intra_quantizer_matrix, picture_info->intra_quantizer_matrix, sizeof(intra_quantizer_matrix));
+   intra_quantizer_matrix[0] = 1 << (7 - picture_info->intra_dc_precision);
+   buffer->set_quant_matrix(buffer, intra_quantizer_matrix, picture_info->non_intra_quantizer_matrix);
+
+   for (i = 0; i < bitstream_buffer_count; ++i)
+      buffer->decode_bitstream(buffer, bitstream_buffers[i].bitstream_bytes,
+                               bitstream_buffers[i].bitstream, &picture.base, num_ycbcr_blocks);
+
+   buffer->end_frame(buffer);
+
+   decoder->flush_buffer(buffer, num_ycbcr_blocks, ref_frames, target);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpDecoderRender(VdpDecoder decoder,
+                   VdpVideoSurface target,
+                   VdpPictureInfo const *picture_info,
+                   uint32_t bitstream_buffer_count,
+                   VdpBitstreamBuffer const *bitstream_buffers)
+{
+   vlVdpDecoder *vldecoder;
+   vlVdpSurface *vlsurf;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding\n");
+
+   if (!(picture_info && bitstream_buffers))
+      return VDP_STATUS_INVALID_POINTER;
+
+   vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
+   if (!vldecoder)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vlsurf = (vlVdpSurface *)vlGetDataHTAB(target);
+   if (!vlsurf)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   if (vlsurf->device != vldecoder->device)
+      return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
+
+   if (vlsurf->video_buffer->chroma_format != vldecoder->decoder->chroma_format)
+      // TODO: Recreate decoder with correct chroma
+      return VDP_STATUS_INVALID_CHROMA_TYPE;
+
+   // TODO: Right now only mpeg 1 & 2 is supported.
+   switch (vldecoder->decoder->profile)   {
+   case PIPE_VIDEO_PROFILE_MPEG1:
+   case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
+   case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
+      ++vldecoder->cur_buffer;
+      vldecoder->cur_buffer %= VL_NUM_DECODE_BUFFERS;
+      return vlVdpDecoderRenderMpeg12(vldecoder->decoder,
+                                      vldecoder->buffer[vldecoder->cur_buffer],
+                                      vlsurf->video_buffer,
+                                      (VdpPictureInfoMPEG1Or2 *)picture_info,
+                                      bitstream_buffer_count,bitstream_buffers);
+      break;
+
+   default:
+      return VDP_STATUS_INVALID_DECODER_PROFILE;
+   }
+}
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
new file mode 100644 (file)
index 0000000..200d5f6
--- /dev/null
@@ -0,0 +1,225 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Younes Manton og Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <pipe/p_compiler.h>
+
+#include <util/u_memory.h>
+#include <util/u_debug.h>
+
+#include <vl_winsys.h>
+
+#include "vdpau_private.h"
+
+PUBLIC VdpStatus
+vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
+                          VdpGetProcAddress **get_proc_address)
+{
+   VdpStatus ret;
+   vlVdpDevice *dev = NULL;
+
+   if (!(display && device && get_proc_address))
+      return VDP_STATUS_INVALID_POINTER;
+
+   if (!vlCreateHTAB()) {
+      ret = VDP_STATUS_RESOURCES;
+      goto no_htab;
+   }
+
+   dev = CALLOC(1, sizeof(vlVdpDevice));
+   if (!dev) {
+      ret = VDP_STATUS_RESOURCES;
+      goto no_dev;
+   }
+
+   dev->vscreen = vl_screen_create(display, screen);
+   if (!dev->vscreen) {
+      ret = VDP_STATUS_RESOURCES;
+      goto no_vscreen;
+   }
+
+   dev->context = vl_video_create(dev->vscreen);
+   if (!dev->context) {
+      ret = VDP_STATUS_RESOURCES;
+      goto no_context;
+   }
+
+   *device = vlAddDataHTAB(dev);
+   if (*device == 0) {
+      ret = VDP_STATUS_ERROR;
+      goto no_handle;
+   }
+
+   *get_proc_address = &vlVdpGetProcAddress;
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Device created succesfully\n");
+
+   return VDP_STATUS_OK;
+
+no_handle:
+   /* Destroy vscreen */
+no_context:
+   vl_screen_destroy(dev->vscreen);
+no_vscreen:
+   FREE(dev);
+no_dev:
+   vlDestroyHTAB();
+no_htab:
+   return ret;
+}
+
+PUBLIC VdpStatus
+vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable,
+                                      VdpPresentationQueueTarget *target)
+{
+   vlVdpPresentationQueueTarget *pqt;
+   VdpStatus ret;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating PresentationQueueTarget\n");
+
+   if (!drawable)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vlVdpDevice *dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   pqt = CALLOC(1, sizeof(vlVdpPresentationQueue));
+   if (!pqt)
+      return VDP_STATUS_RESOURCES;
+
+   pqt->device = dev;
+   pqt->drawable = drawable;
+
+   *target = vlAddDataHTAB(pqt);
+   if (*target == 0) {
+      ret = VDP_STATUS_ERROR;
+      goto no_handle;
+   }
+
+   return VDP_STATUS_OK;
+
+no_handle:
+   FREE(pqt);
+   return ret;
+}
+
+VdpStatus
+vlVdpPresentationQueueTargetDestroy(VdpPresentationQueueTarget presentation_queue_target)
+{
+   vlVdpPresentationQueueTarget *pqt;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying PresentationQueueTarget\n");
+
+   pqt = vlGetDataHTAB(presentation_queue_target);
+   if (!pqt)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vlRemoveDataHTAB(presentation_queue_target);
+   FREE(pqt);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpDeviceDestroy(VdpDevice device)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying destroy\n");
+
+   vlVdpDevice *dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+      
+   vl_video_destroy(dev->context);
+   vl_screen_destroy(dev->vscreen);
+
+   FREE(dev);
+   vlDestroyHTAB();
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Device destroyed succesfully\n");
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer)
+{
+   vlVdpDevice *dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   if (!function_pointer)
+      return VDP_STATUS_INVALID_POINTER;
+
+   if (!vlGetFuncFTAB(function_id, function_pointer))
+      return VDP_STATUS_INVALID_FUNC_ID;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Got proc adress %p for id %d\n", *function_pointer, function_id);
+
+   return VDP_STATUS_OK;
+}
+
+#define _ERROR_TYPE(TYPE,STRING) case TYPE: return STRING;
+
+char const *
+vlVdpGetErrorString (VdpStatus status)
+{
+   switch (status) {
+   _ERROR_TYPE(VDP_STATUS_OK,"The operation completed successfully; no error.");
+   _ERROR_TYPE(VDP_STATUS_NO_IMPLEMENTATION,"No backend implementation could be loaded.");
+   _ERROR_TYPE(VDP_STATUS_DISPLAY_PREEMPTED,"The display was preempted, or a fatal error occurred. The application must re-initialize VDPAU.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_HANDLE,"An invalid handle value was provided. Either the handle does not exist at all, or refers to an object of an incorrect type.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_POINTER ,"An invalid pointer was provided. Typically, this means that a NULL pointer was provided for an 'output' parameter.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_CHROMA_TYPE ,"An invalid/unsupported VdpChromaType value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_Y_CB_CR_FORMAT,"An invalid/unsupported VdpYCbCrFormat value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_RGBA_FORMAT,"An invalid/unsupported VdpRGBAFormat value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_INDEXED_FORMAT,"An invalid/unsupported VdpIndexedFormat value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_STANDARD,"An invalid/unsupported VdpColorStandard value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_TABLE_FORMAT,"An invalid/unsupported VdpColorTableFormat value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_FACTOR,"An invalid/unsupported VdpOutputSurfaceRenderBlendFactor value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_EQUATION,"An invalid/unsupported VdpOutputSurfaceRenderBlendEquation value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_FLAG,"An invalid/unsupported flag value/combination was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_DECODER_PROFILE,"An invalid/unsupported VdpDecoderProfile value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE,"An invalid/unsupported VdpVideoMixerFeature value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER ,"An invalid/unsupported VdpVideoMixerParameter value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE,"An invalid/unsupported VdpVideoMixerAttribute value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE,"An invalid/unsupported VdpVideoMixerPictureStructure value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_FUNC_ID,"An invalid/unsupported VdpFuncId value was supplied.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_SIZE,"The size of a supplied object does not match the object it is being used with.\
+      For example, a VdpVideoMixer is configured to process VdpVideoSurface objects of a specific size.\
+      If presented with a VdpVideoSurface of a different size, this error will be raised.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_VALUE,"An invalid/unsupported value was supplied.\
+      This is a catch-all error code for values of type other than those with a specific error code.");
+   _ERROR_TYPE(VDP_STATUS_INVALID_STRUCT_VERSION,"An invalid/unsupported structure version was specified in a versioned structure. \
+      This implies that the implementation is older than the header file the application was built against.");
+   _ERROR_TYPE(VDP_STATUS_RESOURCES,"The system does not have enough resources to complete the requested operation at this time.");
+   _ERROR_TYPE(VDP_STATUS_HANDLE_DEVICE_MISMATCH,"The set of handles supplied are not all related to the same VdpDevice.When performing operations \
+      that operate on multiple surfaces, such as VdpOutputSurfaceRenderOutputSurface or VdpVideoMixerRender, \
+      all supplied surfaces must have been created within the context of the same VdpDevice object. \
+      This error is raised if they were not.");
+   _ERROR_TYPE(VDP_STATUS_ERROR,"A catch-all error, used when no other error code applies.");
+   default: return "Unknown Error";
+   }
+}
diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c
new file mode 100644 (file)
index 0000000..66ed50c
--- /dev/null
@@ -0,0 +1,122 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "vdpau_private.h"
+
+static void* ftab[67] =
+{
+   &vlVdpGetErrorString, /* VDP_FUNC_ID_GET_ERROR_STRING */
+   &vlVdpGetProcAddress, /* VDP_FUNC_ID_GET_PROC_ADDRESS */
+   &vlVdpGetApiVersion, /* VDP_FUNC_ID_GET_API_VERSION */
+   NULL, /* DUMMY */
+   &vlVdpGetInformationString, /* VDP_FUNC_ID_GET_INFORMATION_STRING */
+   &vlVdpDeviceDestroy, /* VDP_FUNC_ID_DEVICE_DESTROY */
+   &vlVdpGenerateCSCMatrix, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */
+   &vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */
+   &vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */
+   &vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */
+   &vlVdpVideoSurfaceDestroy, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */
+   &vlVdpVideoSurfaceGetParameters, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */
+   &vlVdpVideoSurfaceGetBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */
+   &vlVdpVideoSurfacePutBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */
+   &vlVdpOutputSurfaceQueryCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES */
+   &vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES */
+   &vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */
+   &vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES */
+   &vlVdpOutputSurfaceCreate, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */
+   &vlVdpOutputSurfaceDestroy, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */
+   &vlVdpOutputSurfaceGetParameters, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */
+   &vlVdpOutputSurfaceGetBitsNative, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */
+   &vlVdpOutputSurfacePutBitsNative, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE */
+   &vlVdpOutputSurfacePutBitsIndexed, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */
+   &vlVdpOutputSurfacePutBitsYCbCr, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */
+   &vlVdpBitmapSurfaceQueryCapabilities, /* VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES */
+   &vlVdpBitmapSurfaceCreate, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */
+   &vlVdpBitmapSurfaceDestroy, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */
+   &vlVdpBitmapSurfaceGetParameters, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */
+   &vlVdpBitmapSurfacePutBitsNative, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */
+   NULL, /* DUMMY */
+   NULL, /* DUMMY */
+   NULL, /* DUMMY */
+   &vlVdpOutputSurfaceRenderOutputSurface, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE */
+   &vlVdpOutputSurfaceRenderBitmapSurface, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */
+   NULL, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */
+   &vlVdpDecoderQueryCapabilities, /* VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES */
+   &vlVdpDecoderCreate, /* VDP_FUNC_ID_DECODER_CREATE */
+   &vlVdpDecoderDestroy, /* VDP_FUNC_ID_DECODER_DESTROY */
+   &vlVdpDecoderGetParameters, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */
+   &vlVdpDecoderRender, /* VDP_FUNC_ID_DECODER_RENDER */
+   &vlVdpVideoMixerQueryFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT */
+   &vlVdpVideoMixerQueryParameterSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT */
+   &vlVdpVideoMixerQueryAttributeSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT */
+   &vlVdpVideoMixerQueryParameterValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE */
+   &vlVdpVideoMixerQueryAttributeValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE */
+   &vlVdpVideoMixerCreate, /* VDP_FUNC_ID_VIDEO_MIXER_CREATE */
+   &vlVdpVideoMixerSetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES */
+   &vlVdpVideoMixerSetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES */
+   &vlVdpVideoMixerGetFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT */
+   &vlVdpVideoMixerGetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES */
+   &vlVdpVideoMixerGetParameterValues, /* VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES */
+   &vlVdpVideoMixerGetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */
+   &vlVdpVideoMixerDestroy, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */
+   &vlVdpVideoMixerRender, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */
+   &vlVdpPresentationQueueTargetDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */
+   &vlVdpPresentationQueueCreate, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */
+   &vlVdpPresentationQueueDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */
+   &vlVdpPresentationQueueSetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */
+   &vlVdpPresentationQueueGetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */
+   NULL, /* DUMMY */
+   NULL, /* DUMMY */
+   &vlVdpPresentationQueueGetTime, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */
+   &vlVdpPresentationQueueDisplay, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */
+   &vlVdpPresentationQueueBlockUntilSurfaceIdle, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */
+   &vlVdpPresentationQueueQuerySurfaceStatus, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */
+   &vlVdpPreemptionCallbackRegister  /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */
+};
+
+static void* ftab_winsys[1] =
+{
+   &vlVdpPresentationQueueTargetCreateX11  /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
+};
+
+boolean vlGetFuncFTAB(VdpFuncId function_id, void **func)
+{
+   assert(func);
+   if (function_id < VDP_FUNC_ID_BASE_WINSYS) {
+      if (function_id > 66)
+         return FALSE;
+      *func = ftab[function_id];
+   }
+   else {
+      function_id -= VDP_FUNC_ID_BASE_WINSYS;
+      if (function_id > 0)
+        return FALSE;
+      *func = ftab_winsys[function_id];
+   }
+   return *func != NULL;
+}
diff --git a/src/gallium/state_trackers/vdpau/htab.c b/src/gallium/state_trackers/vdpau/htab.c
new file mode 100644 (file)
index 0000000..20f5a17
--- /dev/null
@@ -0,0 +1,104 @@
+/**************************************************************************
+ *
+ * Copyright 2010 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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_handle_table.h>
+#include <os/os_thread.h>
+#include "vdpau_private.h"
+
+#ifdef VL_HANDLES
+static struct handle_table *htab = NULL;
+pipe_static_mutex(htab_lock);
+#endif
+
+boolean vlCreateHTAB(void)
+{
+#ifdef VL_HANDLES
+   boolean ret;
+   /* Make sure handle table handles match VDPAU handles. */
+   assert(sizeof(unsigned) <= sizeof(vlHandle));
+   pipe_mutex_lock(htab_lock);
+   if (!htab)
+      htab = handle_table_create();
+   ret = htab != NULL;
+   pipe_mutex_unlock(htab_lock);
+   return ret;
+#else
+   return TRUE;
+#endif
+}
+
+void vlDestroyHTAB(void)
+{
+#ifdef VL_HANDLES
+   pipe_mutex_lock(htab_lock);
+   if (htab) {
+      handle_table_destroy(htab);
+      htab = NULL;
+   }
+   pipe_mutex_unlock(htab_lock);
+#endif
+}
+
+vlHandle vlAddDataHTAB(void *data)
+{
+   assert(data);
+#ifdef VL_HANDLES
+   vlHandle handle = 0;
+   pipe_mutex_lock(htab_lock);
+   if (htab)
+      handle = handle_table_add(htab, data);
+   pipe_mutex_unlock(htab_lock);
+   return handle;
+#else
+   return (vlHandle)data;
+#endif
+}
+
+void* vlGetDataHTAB(vlHandle handle)
+{
+   assert(handle);
+#ifdef VL_HANDLES
+   void *data = NULL;
+   pipe_mutex_lock(htab_lock);
+   if (htab)
+      data = handle_table_get(htab, handle);
+   pipe_mutex_unlock(htab_lock);
+   return data;
+#else
+   return (void*)handle;
+#endif
+}
+
+void vlRemoveDataHTAB(vlHandle handle)
+{
+#ifdef VL_HANDLES
+   pipe_mutex_lock(htab_lock);
+   if (htab)
+      handle_table_remove(htab, handle);
+   pipe_mutex_unlock(htab_lock);
+#endif
+}
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
new file mode 100644 (file)
index 0000000..d518700
--- /dev/null
@@ -0,0 +1,233 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <vdpau/vdpau.h>
+
+#include <util/u_memory.h>
+#include <util/u_debug.h>
+
+#include <vl/vl_csc.h>
+
+#include "vdpau_private.h"
+
+VdpStatus
+vlVdpVideoMixerCreate(VdpDevice device,
+                      uint32_t feature_count,
+                      VdpVideoMixerFeature const *features,
+                      uint32_t parameter_count,
+                      VdpVideoMixerParameter const *parameters,
+                      void const *const *parameter_values,
+                      VdpVideoMixer *mixer)
+{
+   vlVdpVideoMixer *vmixer = NULL;
+   VdpStatus ret;
+   float csc[16];
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating VideoMixer\n");
+
+   vlVdpDevice *dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vmixer = CALLOC(1, sizeof(vlVdpVideoMixer));
+   if (!vmixer)
+      return VDP_STATUS_RESOURCES;
+
+   vmixer->device = dev;
+   vl_compositor_init(&vmixer->compositor, dev->context->pipe);
+
+   vl_csc_get_matrix
+   (
+      debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
+      VL_CSC_COLOR_STANDARD_IDENTITY : VL_CSC_COLOR_STANDARD_BT_601,
+      NULL, true, csc
+   );
+   vl_compositor_set_csc_matrix(&vmixer->compositor, csc);
+
+   /*
+    * TODO: Handle features and parameters
+    * */
+
+   *mixer = vlAddDataHTAB(vmixer);
+   if (*mixer == 0) {
+      ret = VDP_STATUS_ERROR;
+      goto no_handle;
+   }
+
+   return VDP_STATUS_OK;
+no_handle:
+   return ret;
+}
+
+VdpStatus
+vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
+{
+   vlVdpVideoMixer *vmixer;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying VideoMixer\n");
+
+   vmixer = vlGetDataHTAB(mixer);
+   if (!vmixer)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vl_compositor_cleanup(&vmixer->compositor);
+
+   FREE(vmixer);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
+                                 uint32_t feature_count,
+                                 VdpVideoMixerFeature const *features,
+                                 VdpBool const *feature_enables)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Setting VideoMixer features\n");
+
+   if (!(features && feature_enables))
+      return VDP_STATUS_INVALID_POINTER;
+
+   vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
+   if (!vmixer)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   /*
+    * TODO: Set features
+    * */
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
+                                VdpOutputSurface background_surface,
+                                VdpRect const *background_source_rect,
+                                VdpVideoMixerPictureStructure current_picture_structure,
+                                uint32_t video_surface_past_count,
+                                VdpVideoSurface const *video_surface_past,
+                                VdpVideoSurface video_surface_current,
+                                uint32_t video_surface_future_count,
+                                VdpVideoSurface const *video_surface_future,
+                                VdpRect const *video_source_rect,
+                                VdpOutputSurface destination_surface,
+                                VdpRect const *destination_rect,
+                                VdpRect const *destination_video_rect,
+                                uint32_t layer_count,
+                                VdpLayer const *layers)
+{
+   vlVdpVideoMixer *vmixer;
+   vlVdpSurface *surf;
+   vlVdpOutputSurface *dst;
+
+   vmixer = vlGetDataHTAB(mixer);
+   if (!vmixer)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   surf = vlGetDataHTAB(video_surface_current);
+   if (!surf)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   dst = vlGetDataHTAB(destination_surface);
+   if (!dst)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vl_compositor_clear_layers(&vmixer->compositor);
+   vl_compositor_set_buffer_layer(&vmixer->compositor, 0, surf->video_buffer, NULL, NULL);
+   vl_compositor_render(&vmixer->compositor, PIPE_MPEG12_PICTURE_TYPE_FRAME,
+                        dst->surface, NULL, NULL);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
+                                  uint32_t attribute_count,
+                                  VdpVideoMixerAttribute const *attributes,
+                                  void const *const *attribute_values)
+{
+   if (!(attributes && attribute_values))
+      return VDP_STATUS_INVALID_POINTER;
+
+   vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
+   if (!vmixer)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   /*
+    * TODO: Implement the function
+    *
+    * */
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
+                                 uint32_t feature_count,
+                                 VdpVideoMixerFeature const *features,
+                                 VdpBool *feature_supports)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,
+                                 uint32_t feature_count,
+                                 VdpVideoMixerFeature const *features,
+                                 VdpBool *feature_enables)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerGetParameterValues(VdpVideoMixer mixer,
+                                  uint32_t parameter_count,
+                                  VdpVideoMixerParameter const *parameters,
+                                  void *const *parameter_values)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer,
+                                  uint32_t attribute_count,
+                                  VdpVideoMixerAttribute const *attributes,
+                                  void *const *attribute_values)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpGenerateCSCMatrix(VdpProcamp *procamp,
+                       VdpColorStandard standard,
+                       VdpCSCMatrix *csc_matrix)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Generating CSCMatrix\n");
+   if (!(csc_matrix && procamp))
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_OK;
+}
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
new file mode 100644 (file)
index 0000000..bc4b39a
--- /dev/null
@@ -0,0 +1,221 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * Copyright 2011 Christian König.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <vdpau/vdpau.h>
+
+#include <util/u_debug.h>
+#include <util/u_memory.h>
+#include <util/u_sampler.h>
+
+#include "vdpau_private.h"
+
+VdpStatus
+vlVdpOutputSurfaceCreate(VdpDevice device,
+                         VdpRGBAFormat rgba_format,
+                         uint32_t width, uint32_t height,
+                         VdpOutputSurface  *surface)
+{
+   struct pipe_context *pipe;
+   struct pipe_resource res_tmpl, *res;
+   struct pipe_sampler_view sv_templ;
+   struct pipe_surface surf_templ;
+
+   vlVdpOutputSurface *vlsurface = NULL;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating output surface\n");
+   if (!(width && height))
+      return VDP_STATUS_INVALID_SIZE;
+
+   vlVdpDevice *dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   pipe = dev->context->pipe;
+   if (!pipe)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vlsurface = CALLOC(1, sizeof(vlVdpOutputSurface));
+   if (!vlsurface)
+      return VDP_STATUS_RESOURCES;
+
+   memset(&res_tmpl, 0, sizeof(res_tmpl));
+
+   res_tmpl.target = PIPE_TEXTURE_2D;
+   res_tmpl.format = FormatRGBAToPipe(rgba_format);
+   res_tmpl.width0 = width;
+   res_tmpl.height0 = height;
+   res_tmpl.depth0 = 1;
+   res_tmpl.array_size = 1;
+   res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+   res_tmpl.usage = PIPE_USAGE_STATIC;
+
+   res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
+   if (!res) {
+      FREE(dev);
+      return VDP_STATUS_ERROR;
+   }
+
+   memset(&sv_templ, 0, sizeof(sv_templ));
+   u_sampler_view_default_template(&sv_templ, res, res->format);
+
+   // as long as we don't have a background picture we don't want an alpha channel
+   sv_templ.swizzle_a = PIPE_SWIZZLE_ONE;
+
+   vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
+   if (!vlsurface->sampler_view) {
+      pipe_resource_reference(&res, NULL);
+      FREE(dev);
+      return VDP_STATUS_ERROR;
+   }
+
+   memset(&surf_templ, 0, sizeof(surf_templ));
+   surf_templ.format = res->format;
+   surf_templ.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+   vlsurface->surface = pipe->create_surface(pipe, res, &surf_templ);
+   if (!vlsurface->surface) {
+      pipe_resource_reference(&res, NULL);
+      FREE(dev);
+      return VDP_STATUS_ERROR;
+   }
+
+   *surface = vlAddDataHTAB(vlsurface);
+   if (*surface == 0) {
+      pipe_resource_reference(&res, NULL);
+      FREE(dev);
+      return VDP_STATUS_ERROR;
+   }
+   
+   pipe_resource_reference(&res, NULL);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpOutputSurfaceDestroy(VdpOutputSurface surface)
+{
+   vlVdpOutputSurface *vlsurface;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying output surface\n");
+
+   vlsurface = vlGetDataHTAB(surface);
+   if (!vlsurface)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   pipe_surface_reference(&vlsurface->surface, NULL);
+   pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
+
+   vlRemoveDataHTAB(surface);
+   FREE(vlsurface);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpOutputSurfaceGetParameters(VdpOutputSurface surface,
+                                VdpRGBAFormat *rgba_format,
+                                uint32_t *width, uint32_t *height)
+{
+   vlVdpOutputSurface *vlsurface;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] getting surface parameters\n");
+        
+   vlsurface = vlGetDataHTAB(surface);
+   if (!vlsurface)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   *rgba_format = PipeToFormatRGBA(vlsurface->sampler_view->texture->format);
+   *width = vlsurface->sampler_view->texture->width0;
+   *height = vlsurface->sampler_view->texture->height0;
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
+                                VdpRect const *source_rect,
+                                void *const *destination_data,
+                                uint32_t const *destination_pitches)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface,
+                                void const *const *source_data,
+                                uint32_t const *source_pitches,
+                                VdpRect const *destination_rect)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
+                                 VdpIndexedFormat source_indexed_format,
+                                 void const *const *source_data,
+                                 uint32_t const *source_pitch,
+                                 VdpRect const *destination_rect,
+                                 VdpColorTableFormat color_table_format,
+                                 void const *color_table)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
+                               VdpYCbCrFormat source_ycbcr_format,
+                               void const *const *source_data,
+                               uint32_t const *source_pitches,
+                               VdpRect const *destination_rect,
+                               VdpCSCMatrix const *csc_matrix)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
+                                      VdpRect const *destination_rect,
+                                      VdpOutputSurface source_surface,
+                                      VdpRect const *source_rect,
+                                      VdpColor const *colors,
+                                      VdpOutputSurfaceRenderBlendState const *blend_state,
+                                      uint32_t flags)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
+                                      VdpRect const *destination_rect,
+                                      VdpBitmapSurface source_surface,
+                                      VdpRect const *source_rect,
+                                      VdpColor const *colors,
+                                      VdpOutputSurfaceRenderBlendState const *blend_state,
+                                      uint32_t flags)
+{
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
diff --git a/src/gallium/state_trackers/vdpau/preemption.c b/src/gallium/state_trackers/vdpau/preemption.c
new file mode 100644 (file)
index 0000000..fa70bb0
--- /dev/null
@@ -0,0 +1,39 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <vdpau/vdpau.h>
+
+ void vlVdpPreemptionCallback(VdpDevice device, void *context)
+ {
+   /* TODO: Implement preemption */
+ }
+
+ VdpStatus vlVdpPreemptionCallbackRegister(VdpDevice device, VdpPreemptionCallback callback,
+                                           void *context)
+ {
+   return VDP_STATUS_OK;
+ }
diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c
new file mode 100644 (file)
index 0000000..1176c7a
--- /dev/null
@@ -0,0 +1,223 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <vdpau/vdpau.h>
+
+#include <util/u_debug.h>
+#include <util/u_memory.h>
+
+#include "vdpau_private.h"
+
+VdpStatus
+vlVdpPresentationQueueCreate(VdpDevice device,
+                             VdpPresentationQueueTarget presentation_queue_target,
+                             VdpPresentationQueue *presentation_queue)
+{
+   vlVdpPresentationQueue *pq = NULL;
+   VdpStatus ret;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating PresentationQueue\n");
+
+   if (!presentation_queue)
+      return VDP_STATUS_INVALID_POINTER;
+
+   vlVdpDevice *dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vlVdpPresentationQueueTarget *pqt = vlGetDataHTAB(presentation_queue_target);
+   if (!pqt)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   if (dev != pqt->device)
+      return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
+
+   pq = CALLOC(1, sizeof(vlVdpPresentationQueue));
+   if (!pq)
+      return VDP_STATUS_RESOURCES;
+
+   pq->device = dev;
+   pq->drawable = pqt->drawable;
+   
+   if (!vl_compositor_init(&pq->compositor, dev->context->pipe)) {
+      ret = VDP_STATUS_ERROR;
+      goto no_compositor;
+   }
+
+   *presentation_queue = vlAddDataHTAB(pq);
+   if (*presentation_queue == 0) {
+      ret = VDP_STATUS_ERROR;
+      goto no_handle;
+   }
+
+   return VDP_STATUS_OK;
+no_handle:
+no_compositor:
+   FREE(pq);
+   return ret;
+}
+
+VdpStatus
+vlVdpPresentationQueueDestroy(VdpPresentationQueue presentation_queue)
+{
+   vlVdpPresentationQueue *pq;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Destroying PresentationQueue\n");
+
+   pq = vlGetDataHTAB(presentation_queue);
+   if (!pq)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vl_compositor_cleanup(&pq->compositor);
+
+   vlRemoveDataHTAB(presentation_queue);
+   FREE(pq);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue,
+                                         VdpColor *const background_color)
+{
+   vlVdpPresentationQueue *pq;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Setting Background Color\n");
+
+   if (!background_color)
+      return VDP_STATUS_INVALID_POINTER;
+
+   pq = vlGetDataHTAB(presentation_queue);
+   if (!pq)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vl_compositor_set_clear_color(&pq->compositor, (float*)background_color);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue,
+                                         VdpColor *const background_color)
+{
+   if (!background_color)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueGetTime(VdpPresentationQueue presentation_queue,
+                              VdpTime *current_time)
+{
+   if (!current_time)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
+                              VdpOutputSurface surface,
+                              uint32_t clip_width,
+                              uint32_t clip_height,
+                              VdpTime  earliest_presentation_time)
+{
+   static int dump_window = -1;
+
+   vlVdpPresentationQueue *pq;
+   vlVdpOutputSurface *surf;
+   struct pipe_surface *drawable_surface;
+
+   pq = vlGetDataHTAB(presentation_queue);
+   if (!pq)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   drawable_surface = vl_drawable_surface_get(pq->device->context, pq->drawable);
+   if (!drawable_surface)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   surf = vlGetDataHTAB(surface);
+   if (!surf)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vl_compositor_clear_layers(&pq->compositor);
+   vl_compositor_set_rgba_layer(&pq->compositor, 0, surf->sampler_view, NULL, NULL);
+   vl_compositor_render(&pq->compositor, PIPE_MPEG12_PICTURE_TYPE_FRAME,
+                        drawable_surface, NULL, NULL);
+
+   pq->device->context->pipe->screen->flush_frontbuffer
+   (
+      pq->device->context->pipe->screen,
+      drawable_surface->texture,
+      0, 0,
+      vl_contextprivate_get(pq->device->context, drawable_surface)
+   );
+
+   if(dump_window == -1) {
+      dump_window = debug_get_num_option("VDPAU_DUMP", 0);
+   }
+
+   if(dump_window) {
+      static unsigned int framenum = 0;
+      char cmd[256];
+
+      sprintf(cmd, "xwd -id %d -out vdpau_frame_%08d.xwd", (int)pq->drawable, ++framenum);
+      if (system(cmd) != 0)
+         VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Dumping surface %d failed.\n", surface);
+   }
+   
+   pipe_surface_reference(&drawable_surface, NULL);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpPresentationQueueBlockUntilSurfaceIdle(VdpPresentationQueue presentation_queue,
+                                            VdpOutputSurface surface,
+                                            VdpTime *first_presentation_time)
+{
+   if (!first_presentation_time)
+      return VDP_STATUS_INVALID_POINTER;
+
+   //return VDP_STATUS_NO_IMPLEMENTATION;
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpPresentationQueueQuerySurfaceStatus(VdpPresentationQueue presentation_queue,
+                                         VdpOutputSurface surface,
+                                         VdpPresentationQueueStatus *status,
+                                         VdpTime *first_presentation_time)
+{
+   if (!(status && first_presentation_time))
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c
new file mode 100644 (file)
index 0000000..ec17e59
--- /dev/null
@@ -0,0 +1,279 @@
+/**************************************************************************
+ *
+ * Copyright 2010 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "vdpau_private.h"
+#include <vl_winsys.h>
+#include <assert.h>
+#include <pipe/p_screen.h>
+#include <pipe/p_defines.h>
+#include <math.h>
+#include <util/u_debug.h>
+
+
+VdpStatus
+vlVdpGetApiVersion(uint32_t *api_version)
+{
+   if (!api_version)
+      return VDP_STATUS_INVALID_POINTER;
+
+   *api_version = 1;
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpGetInformationString(char const **information_string)
+{
+   if (!information_string)
+      return VDP_STATUS_INVALID_POINTER;
+
+   *information_string = INFORMATION_STRING;
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
+                                   VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
+{
+   vlVdpDevice *dev;
+   struct pipe_screen *pscreen;
+   uint32_t max_2d_texture_level;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying video surfaces\n");
+
+   if (!(is_supported && max_width && max_height))
+      return VDP_STATUS_INVALID_POINTER;
+
+   dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   pscreen = dev->vscreen->pscreen;
+   if (!pscreen)
+      return VDP_STATUS_RESOURCES;
+
+   /* XXX: Current limits */
+   *is_supported = true;
+   if (surface_chroma_type != VDP_CHROMA_TYPE_420)
+      *is_supported = false;
+
+   max_2d_texture_level = pscreen->get_param(pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+   if (!max_2d_texture_level)
+      return VDP_STATUS_RESOURCES;
+
+   /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */
+   *max_width = *max_height = pow(2,max_2d_texture_level-1);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
+                                                  VdpYCbCrFormat bits_ycbcr_format,
+                                                  VdpBool *is_supported)
+{
+   vlVdpDevice *dev;
+   struct pipe_screen *pscreen;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying get put video surfaces\n");
+
+   if (!is_supported)
+      return VDP_STATUS_INVALID_POINTER;
+
+   dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   pscreen = dev->vscreen->pscreen;
+   if (!pscreen)
+      return VDP_STATUS_RESOURCES;
+
+   *is_supported = pscreen->is_video_format_supported
+   (
+      pscreen,
+      FormatYCBCRToPipe(bits_ycbcr_format),
+      PIPE_VIDEO_PROFILE_UNKNOWN
+   );
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
+                              VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks,
+                              uint32_t *max_width, uint32_t *max_height)
+{
+   vlVdpDevice *dev;
+   struct pipe_screen *pscreen;
+   enum pipe_video_profile p_profile;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying decoder\n");
+
+   if (!(is_supported && max_level && max_macroblocks && max_width && max_height))
+      return VDP_STATUS_INVALID_POINTER;
+
+   dev = vlGetDataHTAB(device);
+   if (!dev)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   pscreen = dev->vscreen->pscreen;
+   if (!pscreen)
+      return VDP_STATUS_RESOURCES;
+
+   p_profile = ProfileToPipe(profile);
+   if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN)        {
+      *is_supported = false;
+      return VDP_STATUS_OK;
+   }
+   
+   *is_supported = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_SUPPORTED);
+   if (*is_supported) {
+      *max_width = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_WIDTH); 
+      *max_height = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_HEIGHT);
+      *max_level = 16;
+      *max_macroblocks = (*max_width/16)*(*max_height/16);
+   } else {
+      *max_width = 0;
+      *max_height = 0;
+      *max_level = 0;
+      *max_macroblocks = 0;
+   }
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
+                                    VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
+{
+   if (!(is_supported && max_width && max_height))
+      return VDP_STATUS_INVALID_POINTER;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying ouput surfaces\n");
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
+                                                    VdpBool *is_supported)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces get put native cap\n");
+
+   if (!is_supported)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device,
+                                                  VdpRGBAFormat surface_rgba_format,
+                                                  VdpIndexedFormat bits_indexed_format,
+                                                  VdpColorTableFormat color_table_format,
+                                                  VdpBool *is_supported)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces get put indexed cap\n");
+
+   if (!is_supported)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
+                                                VdpYCbCrFormat bits_ycbcr_format,
+                                                VdpBool *is_supported)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying output surfaces put ycrcb cap\n");
+   if (!is_supported)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
+                                    VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying bitmap surfaces\n");
+   if (!(is_supported && max_width && max_height))
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature,
+                                   VdpBool *is_supported)
+{
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying mixer feature support\n");
+   if (!is_supported)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter,
+                                     VdpBool *is_supported)
+{
+   if (!is_supported)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter,
+                                        void *min_value, void *max_value)
+{
+   if (!(min_value && max_value))
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute,
+                                     VdpBool *is_supported)
+{
+   if (!is_supported)
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute,
+                                        void *min_value, void *max_value)
+{
+   if (!(min_value && max_value))
+      return VDP_STATUS_INVALID_POINTER;
+
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
new file mode 100644 (file)
index 0000000..d3f6b5d
--- /dev/null
@@ -0,0 +1,210 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * Copyright 2011 Christian König.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <pipe/p_state.h>
+
+#include <util/u_memory.h>
+#include <util/u_debug.h>
+#include <util/u_rect.h>
+
+#include "vdpau_private.h"
+
+VdpStatus
+vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type,
+                        uint32_t width, uint32_t height,
+                        VdpVideoSurface *surface)
+{
+   vlVdpSurface *p_surf;
+   VdpStatus ret;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating a surface\n");
+
+   if (!(width && height)) {
+      ret = VDP_STATUS_INVALID_SIZE;
+      goto inv_size;
+   }
+
+   if (!vlCreateHTAB()) {
+      ret = VDP_STATUS_RESOURCES;
+      goto no_htab;
+   }
+
+   p_surf = CALLOC(1, sizeof(vlVdpSurface));
+   if (!p_surf) {
+      ret = VDP_STATUS_RESOURCES;
+      goto no_res;
+   }
+
+   vlVdpDevice *dev = vlGetDataHTAB(device);
+   if (!dev) {
+      ret = VDP_STATUS_INVALID_HANDLE;
+      goto inv_device;
+   }
+
+   p_surf->device = dev;
+   p_surf->video_buffer = dev->context->pipe->create_video_buffer
+   (
+      dev->context->pipe,
+      PIPE_FORMAT_YV12, // most common used
+      ChromaToPipe(chroma_type),
+      width, height
+   );
+
+   *surface = vlAddDataHTAB(p_surf);
+   if (*surface == 0) {
+      ret = VDP_STATUS_ERROR;
+      goto no_handle;
+   }
+
+   return VDP_STATUS_OK;
+
+no_handle:
+   p_surf->video_buffer->destroy(p_surf->video_buffer);
+
+inv_device:
+   FREE(p_surf);
+
+no_res:
+no_htab:
+inv_size:
+   return ret;
+}
+
+VdpStatus
+vlVdpVideoSurfaceDestroy(VdpVideoSurface surface)
+{
+   vlVdpSurface *p_surf;
+
+   p_surf = (vlVdpSurface *)vlGetDataHTAB((vlHandle)surface);
+   if (!p_surf)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   if (p_surf->video_buffer)
+      p_surf->video_buffer->destroy(p_surf->video_buffer);
+
+   FREE(p_surf);
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoSurfaceGetParameters(VdpVideoSurface surface,
+                               VdpChromaType *chroma_type,
+                               uint32_t *width, uint32_t *height)
+{
+   if (!(width && height && chroma_type))
+      return VDP_STATUS_INVALID_POINTER;
+
+   vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+   if (!p_surf)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   *width = p_surf->video_buffer->width;
+   *height = p_surf->video_buffer->height;
+   *chroma_type = PipeToChroma(p_surf->video_buffer->chroma_format);
+
+   return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
+                              VdpYCbCrFormat destination_ycbcr_format,
+                              void *const *destination_data,
+                              uint32_t const *destination_pitches)
+{
+   if (!vlCreateHTAB())
+      return VDP_STATUS_RESOURCES;
+
+   vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+   if (!p_surf)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   //if (!p_surf->psurface)
+   //   return VDP_STATUS_RESOURCES;
+
+   //return VDP_STATUS_OK;
+   return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
+                              VdpYCbCrFormat source_ycbcr_format,
+                              void const *const *source_data,
+                              uint32_t const *source_pitches)
+{
+   enum pipe_format pformat = FormatYCBCRToPipe(source_ycbcr_format);
+   struct pipe_context *pipe;
+   struct pipe_sampler_view **sampler_views;
+   unsigned i;
+
+   if (!vlCreateHTAB())
+      return VDP_STATUS_RESOURCES;
+
+   vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+   if (!p_surf)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   pipe = p_surf->device->context->pipe;
+   if (!pipe)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   if (p_surf->video_buffer == NULL || pformat != p_surf->video_buffer->buffer_format) {
+      assert(0); // TODO Recreate resource
+      return VDP_STATUS_NO_IMPLEMENTATION;
+   }
+
+   sampler_views = p_surf->video_buffer->get_sampler_view_planes(p_surf->video_buffer);
+   if (!sampler_views)
+      return VDP_STATUS_RESOURCES;
+
+   for (i = 0; i < 3; ++i) { //TODO put nr of planes into util format
+      struct pipe_sampler_view *sv = sampler_views[i ? i ^ 3 : 0];
+      struct pipe_box dst_box = { 0, 0, 0, sv->texture->width0, sv->texture->height0, 1 };
+
+      struct pipe_transfer *transfer;
+      void *map;
+
+      transfer = pipe->get_transfer(pipe, sv->texture, 0, PIPE_TRANSFER_WRITE, &dst_box);
+      if (!transfer)
+         return VDP_STATUS_RESOURCES;
+
+      map = pipe->transfer_map(pipe, transfer);
+      if (map) {
+         util_copy_rect(map, sv->texture->format, transfer->stride, 0, 0,
+                        dst_box.width, dst_box.height,
+                        source_data[i], source_pitches[i], 0, 0);
+
+         pipe->transfer_unmap(pipe, transfer);
+      }
+
+      pipe->transfer_destroy(pipe, transfer);
+   }
+
+   return VDP_STATUS_OK;
+}
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
new file mode 100644 (file)
index 0000000..e5d9456
--- /dev/null
@@ -0,0 +1,361 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 VDPAU_PRIVATE_H
+#define VDPAU_PRIVATE_H
+
+#include <assert.h>
+
+#include <vdpau/vdpau.h>
+#include <vdpau/vdpau_x11.h>
+
+#include <pipe/p_compiler.h>
+#include <pipe/p_video_decoder.h>
+
+#include <util/u_debug.h>
+#include <vl/vl_compositor.h>
+
+#include <vl_winsys.h>
+
+#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
+#define QUOTEME(x) #x
+#define TOSTRING(x) QUOTEME(x)
+#define INFORMATION_STRING TOSTRING(INFORMATION)
+#define VL_HANDLES
+#define VL_NUM_DECODE_BUFFERS 4
+
+static inline enum pipe_video_chroma_format
+ChromaToPipe(VdpChromaType vdpau_type)
+{
+   switch (vdpau_type) {
+      case VDP_CHROMA_TYPE_420:
+         return PIPE_VIDEO_CHROMA_FORMAT_420;
+      case VDP_CHROMA_TYPE_422:
+         return PIPE_VIDEO_CHROMA_FORMAT_422;
+      case VDP_CHROMA_TYPE_444:
+         return PIPE_VIDEO_CHROMA_FORMAT_444;
+      default:
+         assert(0);
+   }
+
+   return -1;
+}
+
+static inline VdpChromaType
+PipeToChroma(enum pipe_video_chroma_format pipe_type)
+{
+   switch (pipe_type) {
+      case PIPE_VIDEO_CHROMA_FORMAT_420:
+         return VDP_CHROMA_TYPE_420;
+      case PIPE_VIDEO_CHROMA_FORMAT_422:
+         return VDP_CHROMA_TYPE_422;
+      case PIPE_VIDEO_CHROMA_FORMAT_444:
+         return VDP_CHROMA_TYPE_444;
+      default:
+         assert(0);
+   }
+
+   return -1;
+}
+
+
+static inline enum pipe_format
+FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format)
+{
+   switch (vdpau_format) {
+      case VDP_YCBCR_FORMAT_NV12:
+         return PIPE_FORMAT_NV12;
+      case VDP_YCBCR_FORMAT_YV12:
+         return PIPE_FORMAT_YV12;
+      case VDP_YCBCR_FORMAT_UYVY:
+         return PIPE_FORMAT_UYVY;
+      case VDP_YCBCR_FORMAT_YUYV:
+         return PIPE_FORMAT_YUYV;
+      case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */
+         return 0;
+      case VDP_YCBCR_FORMAT_V8U8Y8A8:
+            return PIPE_FORMAT_VUYA;
+      default:
+         assert(0);
+   }
+
+   return -1;
+}
+
+static inline VdpYCbCrFormat
+PipeToFormatYCBCR(enum pipe_format p_format)
+{
+   switch (p_format) {
+      case PIPE_FORMAT_NV12:
+         return VDP_YCBCR_FORMAT_NV12;
+      case PIPE_FORMAT_YV12:
+         return VDP_YCBCR_FORMAT_YV12;
+      case PIPE_FORMAT_UYVY:
+         return VDP_YCBCR_FORMAT_UYVY;
+      case PIPE_FORMAT_YUYV:
+         return VDP_YCBCR_FORMAT_YUYV;
+      //case PIPE_FORMAT_YUVA:
+        // return VDP_YCBCR_FORMAT_Y8U8V8A8;
+      case PIPE_FORMAT_VUYA:
+        return VDP_YCBCR_FORMAT_V8U8Y8A8;
+      default:
+         assert(0);
+   }
+
+   return -1;
+}
+
+static inline enum pipe_format
+FormatRGBAToPipe(VdpRGBAFormat vdpau_format)
+{
+   switch (vdpau_format) {
+      case VDP_RGBA_FORMAT_A8:
+         return PIPE_FORMAT_A8_UNORM;
+      case VDP_RGBA_FORMAT_B10G10R10A2:
+         return PIPE_FORMAT_B10G10R10A2_UNORM;
+      case VDP_RGBA_FORMAT_B8G8R8A8:
+         return PIPE_FORMAT_B8G8R8A8_UNORM;
+      case VDP_RGBA_FORMAT_R10G10B10A2:
+         return PIPE_FORMAT_R10G10B10A2_UNORM;
+      case VDP_RGBA_FORMAT_R8G8B8A8:
+         return PIPE_FORMAT_R8G8B8A8_UNORM;
+      default:
+         assert(0);
+   }
+
+   return -1;
+}
+
+static inline VdpRGBAFormat
+PipeToFormatRGBA(enum pipe_format p_format)
+{
+   switch (p_format) {
+      case PIPE_FORMAT_A8_UNORM:
+         return VDP_RGBA_FORMAT_A8;
+      case PIPE_FORMAT_B10G10R10A2_UNORM:
+         return VDP_RGBA_FORMAT_B10G10R10A2;
+      case PIPE_FORMAT_B8G8R8A8_UNORM:
+         return VDP_RGBA_FORMAT_B8G8R8A8;
+      case PIPE_FORMAT_R10G10B10A2_UNORM:
+         return VDP_RGBA_FORMAT_R10G10B10A2;
+      case PIPE_FORMAT_R8G8B8A8_UNORM:
+         return VDP_RGBA_FORMAT_R8G8B8A8;
+      default:
+         assert(0);
+   }
+
+   return -1;
+}
+
+static inline enum pipe_video_profile
+ProfileToPipe(VdpDecoderProfile vdpau_profile)
+{
+   switch (vdpau_profile) {
+      case VDP_DECODER_PROFILE_MPEG1:
+         return PIPE_VIDEO_PROFILE_MPEG1;
+      case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
+         return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
+      case VDP_DECODER_PROFILE_MPEG2_MAIN:
+         return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
+      case VDP_DECODER_PROFILE_H264_BASELINE:
+         return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
+      case VDP_DECODER_PROFILE_H264_MAIN: /* Not defined in p_format.h */
+         return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
+      case VDP_DECODER_PROFILE_H264_HIGH:
+            return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
+      default:
+         return PIPE_VIDEO_PROFILE_UNKNOWN;
+   }
+}
+
+static inline VdpDecoderProfile
+PipeToProfile(enum pipe_video_profile p_profile)
+{
+   switch (p_profile) {
+      case PIPE_VIDEO_PROFILE_MPEG1:
+         return VDP_DECODER_PROFILE_MPEG1;
+      case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
+         return VDP_DECODER_PROFILE_MPEG2_SIMPLE;
+      case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
+         return VDP_DECODER_PROFILE_MPEG2_MAIN;
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
+         return VDP_DECODER_PROFILE_H264_BASELINE;
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN: /* Not defined in p_format.h */
+         return VDP_DECODER_PROFILE_H264_MAIN;
+      case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
+            return VDP_DECODER_PROFILE_H264_HIGH;
+      default:
+         assert(0);
+         return -1;
+   }
+}
+
+typedef struct
+{
+   struct vl_screen *vscreen;
+   struct vl_context *context;
+} vlVdpDevice;
+
+typedef struct
+{
+   vlVdpDevice *device;
+   Drawable drawable;
+} vlVdpPresentationQueueTarget;
+
+typedef struct
+{
+   vlVdpDevice *device;
+   Drawable drawable;
+   struct vl_compositor compositor;
+} vlVdpPresentationQueue;
+
+typedef struct
+{
+   vlVdpDevice *device;
+   struct vl_compositor compositor;
+} vlVdpVideoMixer;
+
+typedef struct
+{
+   vlVdpDevice *device;
+   struct pipe_video_buffer *video_buffer;
+} vlVdpSurface;
+
+typedef struct
+{
+   vlVdpDevice *device;
+   struct pipe_surface *surface;
+   struct pipe_sampler_view *sampler_view;
+} vlVdpOutputSurface;
+
+typedef struct
+{
+   vlVdpDevice *device;
+   struct pipe_video_decoder *decoder;
+   struct pipe_video_decode_buffer *buffer[VL_NUM_DECODE_BUFFERS];
+   unsigned cur_buffer;
+} vlVdpDecoder;
+
+typedef uint32_t vlHandle;
+
+boolean vlCreateHTAB(void);
+void vlDestroyHTAB(void);
+vlHandle vlAddDataHTAB(void *data);
+void* vlGetDataHTAB(vlHandle handle);
+void vlRemoveDataHTAB(vlHandle handle);
+
+boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
+
+/* Public functions */
+VdpDeviceCreateX11 vdp_imp_device_create_x11;
+VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
+
+/* Internal function pointers */
+VdpGetErrorString vlVdpGetErrorString;
+VdpDeviceDestroy vlVdpDeviceDestroy;
+VdpGetProcAddress vlVdpGetProcAddress;
+VdpGetApiVersion vlVdpGetApiVersion;
+VdpGetInformationString vlVdpGetInformationString;
+VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities;
+VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities;
+VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities;
+VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities;
+VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities;
+VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities;
+VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities;
+VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities;
+VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport;
+VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
+VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
+VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
+VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
+VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
+VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
+VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
+VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
+VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
+VdpDecoderCreate vlVdpDecoderCreate;
+VdpDecoderDestroy vlVdpDecoderDestroy;
+VdpDecoderGetParameters vlVdpDecoderGetParameters;
+VdpDecoderRender vlVdpDecoderRender;
+VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;
+VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy;
+VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters;
+VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative;
+VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative;
+VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed;
+VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr;
+VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface;
+VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface;
+VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;
+VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;
+VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;
+VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;
+VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;
+VdpPresentationQueueCreate vlVdpPresentationQueueCreate;
+VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;
+VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;
+VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;
+VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;
+VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;
+VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;
+VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;
+VdpPreemptionCallback vlVdpPreemptionCallback;
+VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;
+VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;
+VdpVideoMixerCreate vlVdpVideoMixerCreate;
+VdpVideoMixerRender vlVdpVideoMixerRender;
+VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;
+VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport;
+VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables;
+VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues;
+VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues;
+VdpVideoMixerDestroy vlVdpVideoMixerDestroy;
+VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
+
+#define VDPAU_OUT   0
+#define VDPAU_ERR   1
+#define VDPAU_WARN  2
+#define VDPAU_TRACE 3
+
+static inline void VDPAU_MSG(unsigned int level, const char *fmt, ...)
+{
+   static int debug_level = -1;
+
+   if (debug_level == -1) {
+      debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0);
+   }
+
+   if (level <= debug_level) {
+      va_list ap;
+      va_start(ap, fmt);
+      _debug_vprintf(fmt, ap);
+      va_end(ap);
+   }
+}
+
+#endif // VDPAU_PRIVATE_H
index 71491a5..d91ee97 100644 (file)
@@ -65,6 +65,8 @@ struct st_framebuffer {
    enum st_attachment_type strb_att;
 
    void *privateData;
+   int32_t stamp;
+   int32_t iface_stamp;
 };
 
 enum vg_object_type {
@@ -105,7 +107,6 @@ struct vg_context
    VGErrorCode _error;
 
    struct st_framebuffer *draw_buffer;
-   int32_t draw_buffer_invalid;
 
    struct cso_hash *owned_objects[VG_OBJECT_LAST];
 
@@ -129,6 +130,8 @@ struct vg_context
    struct vg_paint *default_paint;
 
    struct blit_state *blit;
+
+   int32_t draw_stamp;
 };
 
 
index eeea686..dec1581 100644 (file)
@@ -106,35 +106,38 @@ vg_manager_validate_framebuffer(struct vg_context *ctx)
 {
    struct st_framebuffer *stfb = ctx->draw_buffer;
    struct pipe_resource *pt;
+   int32_t new_stamp;
 
    /* no binding surface */
    if (!stfb)
       return;
 
-   if (!p_atomic_read(&ctx->draw_buffer_invalid))
-      return;
+   new_stamp = p_atomic_read(&stfb->iface->stamp);
+   if (stfb->iface_stamp != new_stamp) {
+      do {
+        /* validate the fb */
+        if (!stfb->iface->validate(stfb->iface, &stfb->strb_att,
+                                   1, &pt) || !pt)
+           return;
 
-   /* validate the fb */
-   if (!stfb->iface->validate(stfb->iface, &stfb->strb_att, 1, &pt) || !pt)
-      return;
+        stfb->iface_stamp = new_stamp;
+        new_stamp = p_atomic_read(&stfb->iface->stamp);
 
-   p_atomic_set(&ctx->draw_buffer_invalid, FALSE);
+      } while (stfb->iface_stamp != new_stamp);
 
-   if (vg_context_update_color_rb(ctx, pt) ||
-       stfb->width != pt->width0 ||
-       stfb->height != pt->height0)
-      ctx->state.dirty |= FRAMEBUFFER_DIRTY;
+      if (vg_context_update_color_rb(ctx, pt) ||
+          stfb->width != pt->width0 ||
+          stfb->height != pt->height0)
+         ++stfb->stamp;
 
-   stfb->width = pt->width0;
-   stfb->height = pt->height0;
-}
+      stfb->width = pt->width0;
+      stfb->height = pt->height0;
+   }
 
-static void
-vg_context_notify_invalid_framebuffer(struct st_context_iface *stctxi,
-                                      struct st_framebuffer_iface *stfbi)
-{
-   struct vg_context *ctx = (struct vg_context *) stctxi;
-   p_atomic_set(&ctx->draw_buffer_invalid, TRUE);
+   if (ctx->draw_stamp != stfb->stamp) {
+      ctx->state.dirty |= FRAMEBUFFER_DIRTY;
+      ctx->draw_stamp = stfb->stamp;
+   }
 }
 
 static void
@@ -187,8 +190,6 @@ vg_api_create_context(struct st_api *stapi, struct st_manager *smapi,
 
    ctx->iface.destroy = vg_context_destroy;
 
-   ctx->iface.notify_invalid_framebuffer =
-      vg_context_notify_invalid_framebuffer;
    ctx->iface.flush = vg_context_flush;
 
    ctx->iface.teximage = NULL;
@@ -266,8 +267,6 @@ vg_context_bind_framebuffers(struct st_context_iface *stctxi,
    if (stdrawi != streadi)
       return FALSE;
 
-   p_atomic_set(&ctx->draw_buffer_invalid, TRUE);
-
    strb_att = (stdrawi) ? choose_attachment(stdrawi) : ST_ATTACHMENT_INVALID;
 
    if (ctx->draw_buffer) {
@@ -313,11 +312,14 @@ vg_context_bind_framebuffers(struct st_context_iface *stctxi,
       stfb->width = 0;
       stfb->height = 0;
       stfb->strb_att = strb_att;
+      stfb->stamp = 1;
+      stfb->iface_stamp = p_atomic_read(&stdrawi->stamp) - 1;
 
       ctx->draw_buffer = stfb;
    }
 
    ctx->draw_buffer->iface = stdrawi;
+   ctx->draw_stamp = ctx->draw_buffer->stamp - 1;
 
    return TRUE;
 }
index 5608d4f..c2839fe 100644 (file)
@@ -31,6 +31,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 #include "util/u_memory.h"
+#include "util/u_atomic.h"
 #include "state_tracker/st_api.h"
 
 #include "stw_icd.h"
@@ -361,10 +362,7 @@ stw_flush_current_locked( struct stw_framebuffer *fb )
 void
 stw_notify_current_locked( struct stw_framebuffer *fb )
 {
-   struct stw_context *ctx = stw_current_context();
-
-   if (ctx && ctx->current_framebuffer == fb)
-      ctx->st->notify_invalid_framebuffer(ctx->st, fb->stfb);
+   p_atomic_inc(&fb->stfb->stamp);
 }
 
 /**
index 424d8da..c7273f2 100644 (file)
@@ -268,7 +268,7 @@ wglQueryPbufferARB(HPBUFFERARB hPbuffer,
       *piValue = fb->width;
       return TRUE;
    case WGL_PBUFFER_HEIGHT_ARB:
-      *piValue = fb->width;
+      *piValue = fb->height;
       return TRUE;
    case WGL_PBUFFER_LOST_ARB:
       /* We assume that no content is ever lost due to display mode change */
index 9174533..28c93f4 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
+#include "util/u_atomic.h"
 #include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
 
 #include "stw_st.h"
@@ -196,6 +197,7 @@ stw_st_create_framebuffer(struct stw_framebuffer *fb)
    stwfb->stvis = fb->pfi->stvis;
 
    stwfb->base.visual = &stwfb->stvis;
+   p_atomic_set(&stwfb->base.stamp, 1);
    stwfb->base.flush_front = stw_st_framebuffer_flush_front;
    stwfb->base.validate = stw_st_framebuffer_validate;
 
diff --git a/src/gallium/state_trackers/xa/Makefile b/src/gallium/state_trackers/xa/Makefile
new file mode 100644 (file)
index 0000000..d95f938
--- /dev/null
@@ -0,0 +1,67 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+##### MACROS #####
+
+XA_MAJOR = 0
+XA_MINOR = 4
+XA_TINY = 0
+XA_CFLAGS = -g -fPIC -Wall
+
+XA_INCLUDES= -I$(TOP)/src/gallium/ \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/winsys \
+       -I$(TOP)/src/gallium/drivers
+
+XA_LIB = xatracker
+XA_LIB_NAME = lib$(XA_LIB).o
+XA_LIB_DEPS =
+
+COMMON_GALLIUM_SOURCES=
+
+SOURCES = \
+       xa_tracker.c \
+       xa_context.c \
+       xa_renderer.c \
+       xa_tgsi.c \
+       xa_yuv.c \
+       xa_composite.c
+OBJECTS = $(SOURCES:.c=.o)
+
+##### RULES #####
+
+.c.o:
+       $(CC) -c $(XA_CFLAGS) $(XA_INCLUDES) $<
+
+
+##### TARGETS #####
+
+default: $(XA_LIB_NAME)
+
+
+# Make the library
+$(XA_LIB_NAME): depend $(OBJECTS)
+       $(CC) -r -nostdlib -o $(XA_LIB_NAME) $(OBJECTS)
+
+install: FORCE
+
+clean:
+       -rm -f *.o *~
+       -rm -f *.lo
+       -rm -f *.la
+       -rm -f *.pc
+       -rm -rf .libs
+       -rm -f depend depend.bak
+
+
+depend: $(SOURCES)
+       @ echo "running $(MKDEP)"
+       @ rm -f depend
+       @ touch depend
+       @ $(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(XA_INCLUDES) $(SOURCES) \
+               > /dev/null
+
+-include depend
+
+FORCE:
diff --git a/src/gallium/state_trackers/xa/README b/src/gallium/state_trackers/xa/README
new file mode 100644 (file)
index 0000000..1f08861
--- /dev/null
@@ -0,0 +1,72 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+The XA state tracker is intended as a versioned interface to gallium for
+xorg driver writers. Initially it's mostly based on Zack Rusin's
+composite / video work for the Xorg state tracker.
+
+The motivation behind this state tracker is that the Xorg state tracker has
+a number of interfaces to work with:
+
+1) The Xorg sdk (versioned)
+2) Gallium3D (not versioned)
+3) KMS modesetting (versioned)
+4) Driver-private (hopefully versioned)
+
+Since Gallium3D is not versioned, the Xorg state tracker needs to be compiled
+with Gallium, but it's really beneficial to be able to compile xorg drivers
+standalone.
+
+Therefore the xa state tracker is intended to supply the following
+functionality:
+
+1) Versioning.
+2) Surface functionality (creation and copying for a basic dri2 implementation)
+3) YUV blits for textured Xv.
+4) Solid fills without ROP functionality.
+5) Copies with format conversion and - reinterpretation but without ROP
+6) Xrender- type compositing for general acceleration.
+
+
+The first user will be the vmwgfx xorg driver. When there are more users,
+we need to be able to load the appropriate gallium pipe driver, and we
+should investigate sharing the loadig mechanism with the EGL state tracker.
+
+IMPORTANT:
+Version compatibilities:
+While this library remains OUTSIDE any mesa release branch,
+and the major version number is still 0. Any minor bump should be viewed as
+an incompatibility event, and any user of this library should test for that
+and refuse to use the library if minor versions differ.
+As soon as the library enters a mesa release branch, if not earlier, major
+will be bumped to 1, and normal incompatibility rules (major bump)
+will be followed.
+It is allowed to add function interfaces while only bumping minor. Any
+user that uses these function interfaces must therefore use lazy symbol
+lookups and test minor for compatibility before using such a function.
diff --git a/src/gallium/state_trackers/xa/xa-indent b/src/gallium/state_trackers/xa/xa-indent
new file mode 100755 (executable)
index 0000000..1972e53
--- /dev/null
@@ -0,0 +1,3 @@
+#
+indent --linux-style -i4 -ip4 -bad -bap -psl $*
+
diff --git a/src/gallium/state_trackers/xa/xa_composite.c b/src/gallium/state_trackers/xa/xa_composite.c
new file mode 100644 (file)
index 0000000..347fe0c
--- /dev/null
@@ -0,0 +1,530 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#include "xa_composite.h"
+#include "xa_context.h"
+#include "xa_priv.h"
+#include "cso_cache/cso_context.h"
+#include "util/u_sampler.h"
+#include "util/u_inlines.h"
+
+
+/*XXX also in Xrender.h but the including it here breaks compilition */
+#define XFixedToDouble(f)    (((double) (f)) / 65536.)
+
+struct xa_composite_blend {
+    enum xa_composite_op op : 8;
+
+    unsigned alpha_dst : 4;
+    unsigned alpha_src : 4;
+
+    unsigned rgb_src : 8;    /**< PIPE_BLENDFACTOR_x */
+    unsigned rgb_dst : 8;    /**< PIPE_BLENDFACTOR_x */
+};
+
+#define XA_BLEND_OP_OVER 3
+static const struct xa_composite_blend xa_blends[] = {
+    { xa_op_clear,
+      0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO},
+    { xa_op_src,
+      0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ZERO},
+    { xa_op_dst,
+      0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE},
+    { xa_op_over,
+      0, 1, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+    { xa_op_over_reverse,
+      1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE},
+    { xa_op_in,
+      1, 0, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ZERO},
+    { xa_op_in_reverse,
+      0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_SRC_ALPHA},
+    { xa_op_out,
+      1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ZERO},
+    { xa_op_out_reverse,
+      0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+    { xa_op_atop,
+      1, 1, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+    { xa_op_atop_reverse,
+      1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_SRC_ALPHA},
+    { xa_op_xor,
+      1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA},
+    { xa_op_add,
+      0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE},
+};
+
+
+/*
+ * The alpha value stored in a luminance texture is read by the
+ * hardware as color.
+ */
+static unsigned
+xa_convert_blend_for_luminance(unsigned factor)
+{
+    switch(factor) {
+    case PIPE_BLENDFACTOR_DST_ALPHA:
+       return PIPE_BLENDFACTOR_DST_COLOR;
+    case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+       return PIPE_BLENDFACTOR_INV_DST_COLOR;
+    default:
+       break;
+    }
+    return factor;
+}
+
+
+static boolean
+blend_for_op(struct xa_composite_blend *blend,
+            enum xa_composite_op op,
+            struct xa_picture *src_pic,
+            struct xa_picture *mask_pic,
+            struct xa_picture *dst_pic)
+{
+    const int num_blends =
+       sizeof(xa_blends)/sizeof(struct xa_composite_blend);
+    int i;
+    boolean supported = FALSE;
+
+    /*
+     * Temporarily disable component alpha since it appears buggy.
+     */
+    if (src_pic->component_alpha ||
+       (mask_pic && mask_pic->component_alpha))
+       return FALSE;
+
+    /*
+     * our default in case something goes wrong
+     */
+    *blend = xa_blends[XA_BLEND_OP_OVER];
+
+    for (i = 0; i < num_blends; ++i) {
+       if (xa_blends[i].op == op) {
+           *blend = xa_blends[i];
+           supported = TRUE;
+       }
+    }
+
+    if (!dst_pic->srf)
+       return supported;
+
+    if (dst_pic->srf->tex->format == PIPE_FORMAT_L8_UNORM) {
+       blend->rgb_src = xa_convert_blend_for_luminance(blend->rgb_src);
+       blend->rgb_dst = xa_convert_blend_for_luminance(blend->rgb_dst);
+    }
+
+    /*
+     * If there's no dst alpha channel, adjust the blend op so that we'll treat
+     * it as always 1.
+     */
+
+    if (xa_format_a(dst_pic->pict_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;
+    }
+
+    /*
+     * 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 (mask_pic && mask_pic->component_alpha &&
+       xa_format_rgb(mask_pic->pict_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
+xa_repeat_to_gallium(int mode)
+{
+    switch(mode) {
+    case xa_wrap_clamp_to_border:
+       return PIPE_TEX_WRAP_CLAMP_TO_BORDER;
+    case xa_wrap_repeat:
+       return PIPE_TEX_WRAP_REPEAT;
+    case xa_wrap_mirror_repeat:
+       return PIPE_TEX_WRAP_MIRROR_REPEAT;
+    case xa_wrap_clamp_to_edge:
+       return PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+    default:
+       break;
+    }
+    return PIPE_TEX_WRAP_REPEAT;
+}
+
+static INLINE boolean
+xa_filter_to_gallium(int xrender_filter, int *out_filter)
+{
+
+    switch (xrender_filter) {
+    case xa_filter_nearest:
+       *out_filter = PIPE_TEX_FILTER_NEAREST;
+       break;
+    case xa_filter_linear:
+       *out_filter = PIPE_TEX_FILTER_LINEAR;
+       break;
+    default:
+       *out_filter = PIPE_TEX_FILTER_NEAREST;
+       return FALSE;
+    }
+    return TRUE;
+}
+
+static int
+xa_is_filter_accelerated(struct xa_picture *pic)
+{
+    int filter;
+    if (pic && !xa_filter_to_gallium(pic->filter, &filter))
+       return 0;
+    return 1;
+}
+
+int
+xa_composite_check_accelerated(const struct xa_composite *comp)
+{
+    struct xa_composite_blend blend;
+    struct xa_picture *src_pic = comp->src;
+
+    if (!xa_is_filter_accelerated(src_pic) ||
+       !xa_is_filter_accelerated(comp->mask)) {
+       return -XA_ERR_INVAL;
+    }
+
+
+    if (src_pic->src_pict) {
+       if (src_pic->src_pict->type != xa_src_pict_solid_fill)
+           return -XA_ERR_INVAL;
+    }
+
+    if (blend_for_op(&blend, comp->op, comp->src, comp->mask, comp->dst)) {
+       struct xa_picture *mask = comp->mask;
+       if (mask && mask->component_alpha &&
+           xa_format_rgb(mask->pict_format)) {
+           if (blend.alpha_src && blend.rgb_src != PIPE_BLENDFACTOR_ZERO) {
+               return -XA_ERR_INVAL;
+           }
+       }
+
+       return XA_ERR_NONE;
+    }
+    return -XA_ERR_INVAL;
+}
+
+static int
+bind_composite_blend_state(struct xa_context *ctx,
+                          const struct xa_composite *comp)
+{
+    struct xa_composite_blend blend_opt;
+    struct pipe_blend_state blend;
+
+    if (!blend_for_op(&blend_opt, comp->op, comp->src, comp->mask, comp->dst))
+       return -XA_ERR_INVAL;
+
+    memset(&blend, 0, sizeof(struct pipe_blend_state));
+    blend.rt[0].blend_enable = 1;
+    blend.rt[0].colormask = PIPE_MASK_RGBA;
+
+    blend.rt[0].rgb_src_factor   = blend_opt.rgb_src;
+    blend.rt[0].alpha_src_factor = blend_opt.rgb_src;
+    blend.rt[0].rgb_dst_factor   = blend_opt.rgb_dst;
+    blend.rt[0].alpha_dst_factor = blend_opt.rgb_dst;
+
+    cso_set_blend(ctx->cso, &blend);
+    return XA_ERR_NONE;
+}
+
+static unsigned int
+picture_format_fixups(struct xa_picture *src_pic,
+                     int mask)
+{
+    boolean set_alpha = FALSE;
+    boolean swizzle = FALSE;
+    unsigned ret = 0;
+    struct xa_surface *src = src_pic->srf;
+    enum xa_formats src_hw_format, src_pic_format;
+    enum xa_surface_type src_hw_type, src_pic_type;
+
+    if (!src)
+       return 0;
+
+    src_hw_format = xa_surface_format(src);
+    src_pic_format = src_pic->pict_format;
+
+    set_alpha = (xa_format_type_is_color(src_pic_format) &&
+                xa_format_a(src_pic_format) == 0);
+
+    if (set_alpha)
+       ret |= mask ? FS_MASK_SET_ALPHA : FS_SRC_SET_ALPHA;
+
+    if (src_hw_format == src_pic_format) {
+       if (src->tex->format == PIPE_FORMAT_L8_UNORM)
+           return ((mask) ? FS_MASK_LUMINANCE : FS_SRC_LUMINANCE);
+
+       return ret;
+    }
+
+    src_hw_type = xa_format_type(src_hw_format);
+    src_pic_type = xa_format_type(src_pic_format);
+
+    swizzle = ((src_hw_type == xa_type_argb &&
+               src_pic_type == xa_type_abgr) ||
+              ((src_hw_type == xa_type_abgr &&
+                src_pic_type == xa_type_argb)));
+
+    if (!swizzle && (src_hw_type != src_pic_type))
+      return ret;
+
+    if (swizzle)
+       ret |= mask ? FS_MASK_SWIZZLE_RGB : FS_SRC_SWIZZLE_RGB;
+
+    return ret;
+}
+
+static int
+bind_shaders(struct xa_context *ctx, const struct xa_composite *comp)
+{
+    unsigned vs_traits = 0, fs_traits = 0;
+    struct xa_shader shader;
+    struct xa_picture *src_pic = comp->src;
+    struct xa_picture *mask_pic = comp->mask;
+
+    ctx->has_solid_color = FALSE;
+
+    if (src_pic) {
+       if (src_pic->wrap == xa_wrap_clamp_to_border && src_pic->has_transform)
+           fs_traits |= FS_SRC_REPEAT_NONE;
+
+       if (src_pic->src_pict) {
+           if (src_pic->src_pict->type == xa_src_pict_solid_fill) {
+               fs_traits |= FS_SOLID_FILL;
+               vs_traits |= VS_SOLID_FILL;
+               xa_pixel_to_float4(src_pic->src_pict->solid_fill.color,
+                                  ctx->solid_color);
+               ctx->has_solid_color = TRUE;
+           }
+       } else {
+           fs_traits |= FS_COMPOSITE;
+           vs_traits |= VS_COMPOSITE;
+       }
+
+       fs_traits |= picture_format_fixups(src_pic, 0);
+    }
+
+    if (mask_pic) {
+       vs_traits |= VS_MASK;
+       fs_traits |= FS_MASK;
+       if (mask_pic->wrap == xa_wrap_clamp_to_border &&
+           mask_pic->has_transform)
+           fs_traits |= FS_MASK_REPEAT_NONE;
+
+       if (mask_pic->component_alpha) {
+           struct xa_composite_blend blend;
+           if (!blend_for_op(&blend, comp->op, src_pic, mask_pic, NULL))
+               return -XA_ERR_INVAL;
+
+           if (blend.alpha_src) {
+               fs_traits |= FS_CA_SRCALPHA;
+           } else
+               fs_traits |= FS_CA_FULL;
+       }
+
+       fs_traits |= picture_format_fixups(mask_pic, 1);
+    }
+
+    if (ctx->dst->srf->format == PIPE_FORMAT_L8_UNORM)
+       fs_traits |= FS_DST_LUMINANCE;
+
+    shader = xa_shaders_get(ctx->shaders, vs_traits, fs_traits);
+    cso_set_vertex_shader_handle(ctx->cso, shader.vs);
+    cso_set_fragment_shader_handle(ctx->cso, shader.fs);
+    return XA_ERR_NONE;
+}
+
+static void
+bind_samplers(struct xa_context *ctx,
+             const struct xa_composite *comp)
+{
+    struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
+    struct pipe_sampler_state src_sampler, mask_sampler;
+    struct pipe_sampler_view view_templ;
+    struct pipe_sampler_view *src_view;
+    struct pipe_context *pipe = ctx->pipe;
+    struct xa_picture *src_pic = comp->src;
+    struct xa_picture *mask_pic = comp->mask;
+
+    ctx->num_bound_samplers = 0;
+
+    memset(&src_sampler, 0, sizeof(struct pipe_sampler_state));
+    memset(&mask_sampler, 0, sizeof(struct pipe_sampler_state));
+
+    if (src_pic) {
+       if (ctx->has_solid_color) {
+           samplers[0] = NULL;
+           pipe_sampler_view_reference(&ctx->bound_sampler_views[0], NULL);
+       } else {
+           unsigned src_wrap = xa_repeat_to_gallium(src_pic->wrap);
+           int filter;
+
+           (void) xa_filter_to_gallium(src_pic->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;
+           ctx->num_bound_samplers = 1;
+           u_sampler_view_default_template(&view_templ,
+                                           src_pic->srf->tex,
+                                           src_pic->srf->tex->format);
+           src_view = pipe->create_sampler_view(pipe, src_pic->srf->tex,
+                                                &view_templ);
+           pipe_sampler_view_reference(&ctx->bound_sampler_views[0], NULL);
+           ctx->bound_sampler_views[0] = src_view;
+       }
+    }
+
+    if (mask_pic) {
+       unsigned mask_wrap = xa_repeat_to_gallium(mask_pic->wrap);
+       int filter;
+
+       (void) xa_filter_to_gallium(mask_pic->filter, &filter);
+
+       mask_sampler.wrap_s = mask_wrap;
+       mask_sampler.wrap_t = mask_wrap;
+       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;
+       ctx->num_bound_samplers = 2;
+       u_sampler_view_default_template(&view_templ,
+                                       mask_pic->srf->tex,
+                                       mask_pic->srf->tex->format);
+       src_view = pipe->create_sampler_view(pipe, mask_pic->srf->tex,
+                                            &view_templ);
+       pipe_sampler_view_reference(&ctx->bound_sampler_views[1], NULL);
+       ctx->bound_sampler_views[1] = src_view;
+    }
+
+    cso_set_samplers(ctx->cso, ctx->num_bound_samplers,
+                    (const struct pipe_sampler_state **)samplers);
+    cso_set_fragment_sampler_views(ctx->cso, ctx->num_bound_samplers,
+                                  ctx->bound_sampler_views);
+}
+
+int
+xa_composite_prepare(struct xa_context *ctx,
+                    const struct xa_composite *comp)
+{
+    struct xa_surface *dst_srf = comp->dst->srf;
+    int ret;
+
+    ret = xa_surface_psurf_create(ctx, dst_srf);
+    if (ret != XA_ERR_NONE)
+       return ret;
+
+    ctx->dst = dst_srf;
+    renderer_bind_destination(ctx, dst_srf->srf,
+                             dst_srf->srf->width,
+                             dst_srf->srf->height);
+
+    ret = bind_composite_blend_state(ctx, comp);
+    if (ret != XA_ERR_NONE)
+       return ret;
+    ret = bind_shaders(ctx, comp);
+    if (ret != XA_ERR_NONE)
+       return ret;
+    bind_samplers(ctx, comp);
+
+    if (ctx->num_bound_samplers == 0 ) { /* solid fill */
+       renderer_begin_solid(ctx);
+    } else {
+       renderer_begin_textures(ctx);
+       ctx->comp = comp;
+    }
+
+    xa_surface_psurf_destroy(dst_srf);
+    return XA_ERR_NONE;
+}
+
+void xa_composite_rect(struct xa_context *ctx,
+                      int srcX, int srcY, int maskX, int maskY,
+                      int dstX, int dstY, int width, int height)
+{
+    if (ctx->num_bound_samplers == 0 ) { /* solid fill */
+       renderer_solid(ctx, dstX, dstY, dstX + width, dstY + height,
+                      ctx->solid_color);
+    } else {
+       const struct xa_composite *comp = ctx->comp;
+       int pos[6] = {srcX, srcY, maskX, maskY, dstX, dstY};
+       const float *src_matrix = NULL;
+       const float *mask_matrix = NULL;
+
+       if (comp->src->has_transform)
+           src_matrix = comp->src->transform;
+       if (comp->mask && comp->mask->has_transform)
+           mask_matrix = comp->mask->transform;
+
+       renderer_texture(ctx, pos, width, height,
+                        src_matrix, mask_matrix);
+    }
+}
+
+void
+xa_composite_done(struct xa_context *ctx)
+{
+    renderer_draw_flush(ctx);
+    ctx->pipe->flush(ctx->pipe, &ctx->last_fence);
+
+    ctx->comp = NULL;
+    ctx->has_solid_color = FALSE;
+    ctx->num_bound_samplers = 0;
+}
+
+static const struct xa_composite_allocation a = {
+    .xa_composite_size = sizeof(struct xa_composite),
+    .xa_picture_size = sizeof(struct xa_picture),
+    .xa_source_pict_size = sizeof(union xa_source_pict),
+};
+
+const struct xa_composite_allocation *
+xa_composite_allocation(void)
+{
+    return &a;
+}
diff --git a/src/gallium/state_trackers/xa/xa_composite.h b/src/gallium/state_trackers/xa/xa_composite.h
new file mode 100644 (file)
index 0000000..d16ef89
--- /dev/null
@@ -0,0 +1,140 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#ifndef _XA_COMPOSITE_H_
+#define _XA_COMPOSITE_H_
+
+#include "xa_tracker.h"
+#include "xa_context.h"
+
+/*
+ * Supported composite ops.
+ */
+enum xa_composite_op {
+    xa_op_clear,
+    xa_op_src,
+    xa_op_dst,
+    xa_op_over,
+    xa_op_over_reverse,
+    xa_op_in,
+    xa_op_in_reverse,
+    xa_op_out,
+    xa_op_out_reverse,
+    xa_op_atop,
+    xa_op_atop_reverse,
+    xa_op_xor,
+    xa_op_add
+};
+
+/*
+ * Supported filters.
+ */
+enum xa_composite_filter {
+    xa_filter_nearest,
+    xa_filter_linear
+};
+
+/*
+ * Supported clamp methods.
+ */
+enum xa_composite_wrap {
+    xa_wrap_clamp_to_border,
+    xa_wrap_repeat,
+    xa_wrap_mirror_repeat,
+    xa_wrap_clamp_to_edge
+};
+
+/*
+ * Src picture types.
+ */
+enum xa_composite_src_pict_type {
+    xa_src_pict_solid_fill
+};
+
+struct xa_pict_solid_fill {
+    enum xa_composite_src_pict_type type;
+    unsigned int class;
+    uint32_t color;
+};
+
+union xa_source_pict {
+    unsigned int type;
+    struct xa_pict_solid_fill solid_fill;
+};
+
+struct xa_picture {
+    enum xa_formats pict_format;
+    struct xa_surface *srf;
+    struct xa_surface *alpha_map;
+    float transform[9];
+    int has_transform;
+    int component_alpha;
+    enum xa_composite_wrap wrap;
+    enum xa_composite_filter filter;
+    union xa_source_pict *src_pict;
+};
+
+struct xa_composite {
+    struct xa_picture *src, *mask, *dst;
+    int op;
+    int no_solid;
+};
+
+struct xa_composite_allocation {
+    unsigned int xa_composite_size;
+    unsigned int xa_picture_size;
+    unsigned int xa_source_pict_size;
+};
+
+/*
+ * Get allocation sizes for minor bump compatibility.
+ */
+
+extern const struct xa_composite_allocation *
+xa_composite_allocation(void);
+
+/*
+ * This function checks most things except the format of the hardware
+ * surfaces, since they are generally not available at the time this
+ * function is called. Returns usual XA error codes.
+ */
+extern int
+xa_composite_check_accelerated(const struct xa_composite *comp);
+
+extern int
+xa_composite_prepare(struct xa_context *ctx, const struct xa_composite *comp);
+
+extern void
+xa_composite_rect(struct xa_context *ctx,
+                 int srcX, int srcY, int maskX, int maskY,
+                 int dstX, int dstY, int width, int height);
+extern void
+xa_composite_done(struct xa_context *ctx);
+
+#endif
diff --git a/src/gallium/state_trackers/xa/xa_context.c b/src/gallium/state_trackers/xa/xa_context.c
new file mode 100644 (file)
index 0000000..118a390
--- /dev/null
@@ -0,0 +1,389 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+#include "xa_context.h"
+#include "xa_priv.h"
+#include "cso_cache/cso_context.h"
+#include "util/u_inlines.h"
+#include "util/u_rect.h"
+#include "util/u_surface.h"
+#include "pipe/p_context.h"
+
+
+struct xa_context *
+xa_context_default(struct xa_tracker *xa)
+{
+    return xa->default_ctx;
+}
+
+struct xa_context *
+xa_context_create(struct xa_tracker *xa)
+{
+    struct xa_context *ctx = calloc(1, sizeof(*ctx));
+
+    ctx->xa = xa;
+    ctx->pipe = xa->screen->context_create(xa->screen, NULL);
+    ctx->cso = cso_create_context(ctx->pipe);
+    ctx->shaders = xa_shaders_create(ctx);
+    renderer_init_state(ctx);
+
+    return ctx;
+}
+
+void
+xa_context_destroy(struct xa_context *r)
+{
+    struct pipe_resource **vsbuf = &r->vs_const_buffer;
+    struct pipe_resource **fsbuf = &r->fs_const_buffer;
+
+    if (*vsbuf)
+       pipe_resource_reference(vsbuf, NULL);
+
+    if (*fsbuf)
+       pipe_resource_reference(fsbuf, NULL);
+
+    if (r->shaders) {
+       xa_shaders_destroy(r->shaders);
+       r->shaders = NULL;
+    }
+
+    if (r->cso) {
+       cso_release_all(r->cso);
+       cso_destroy_context(r->cso);
+       r->cso = NULL;
+    }
+}
+
+int
+xa_surface_dma(struct xa_context *ctx,
+              struct xa_surface *srf,
+              void *data,
+              unsigned int pitch,
+              int to_surface, struct xa_box *boxes, unsigned int num_boxes)
+{
+    struct pipe_transfer *transfer;
+    void *map;
+    int w, h, i;
+    enum pipe_transfer_usage transfer_direction;
+    struct pipe_context *pipe = ctx->pipe;
+
+    transfer_direction = (to_surface ? PIPE_TRANSFER_WRITE :
+                         PIPE_TRANSFER_READ);
+
+    for (i = 0; i < num_boxes; ++i, ++boxes) {
+       w = boxes->x2 - boxes->x1;
+       h = boxes->y2 - boxes->y1;
+
+       transfer = pipe_get_transfer(pipe, srf->tex, 0, 0,
+                                    transfer_direction, boxes->x1, boxes->y1,
+                                    w, h);
+       if (!transfer)
+           return -XA_ERR_NORES;
+
+       map = pipe_transfer_map(ctx->pipe, transfer);
+       if (!map)
+           goto out_no_map;
+
+       if (to_surface) {
+           util_copy_rect(map, srf->tex->format, transfer->stride,
+                          0, 0, w, h, data, pitch, boxes->x1, boxes->y1);
+       } else {
+           util_copy_rect(data, srf->tex->format, pitch,
+                          boxes->x1, boxes->y1, w, h, map, transfer->stride, 0,
+                          0);
+       }
+       pipe->transfer_unmap(pipe, transfer);
+       pipe->transfer_destroy(pipe, transfer);
+       if (to_surface)
+           pipe->flush(pipe, &ctx->last_fence);
+    }
+    return XA_ERR_NONE;
+ out_no_map:
+    pipe->transfer_destroy(pipe, transfer);
+    return -XA_ERR_NORES;
+}
+
+void *
+xa_surface_map(struct xa_context *ctx,
+              struct xa_surface *srf, unsigned int usage)
+{
+    void *map;
+    unsigned int transfer_direction = 0;
+    struct pipe_context *pipe = ctx->pipe;
+
+    if (srf->transfer)
+       return NULL;
+
+    if (usage & XA_MAP_READ)
+       transfer_direction = PIPE_TRANSFER_READ;
+    if (usage & XA_MAP_WRITE)
+       transfer_direction = PIPE_TRANSFER_WRITE;
+
+    if (!transfer_direction)
+       return NULL;
+
+    srf->transfer = pipe_get_transfer(pipe, srf->tex, 0, 0,
+                                     transfer_direction, 0, 0,
+                                     srf->tex->width0, srf->tex->height0);
+    if (!srf->transfer)
+       return NULL;
+
+    map = pipe_transfer_map(pipe, srf->transfer);
+    if (!map)
+       pipe->transfer_destroy(pipe, srf->transfer);
+
+    srf->mapping_pipe = pipe;
+    return map;
+}
+
+void
+xa_surface_unmap(struct xa_surface *srf)
+{
+    if (srf->transfer) {
+       struct pipe_context *pipe = srf->mapping_pipe;
+
+       pipe->transfer_unmap(pipe, srf->transfer);
+       pipe->transfer_destroy(pipe, srf->transfer);
+       srf->transfer = NULL;
+    }
+}
+
+int
+xa_surface_psurf_create(struct xa_context *ctx, struct xa_surface *dst)
+{
+    struct pipe_screen *screen = ctx->pipe->screen;
+    struct pipe_surface srf_templ;
+
+    if (dst->srf)
+       return -XA_ERR_INVAL;
+
+    if (!screen->is_format_supported(screen,  dst->tex->format,
+                                    PIPE_TEXTURE_2D, 0,
+                                    PIPE_BIND_RENDER_TARGET))
+       return -XA_ERR_INVAL;
+
+    u_surface_default_template(&srf_templ, dst->tex,
+                              PIPE_BIND_RENDER_TARGET);
+    dst->srf = ctx->pipe->create_surface(ctx->pipe, dst->tex, &srf_templ);
+    if (!dst->srf)
+       return -XA_ERR_NORES;
+
+    return XA_ERR_NONE;
+}
+
+void
+xa_surface_psurf_destroy(struct xa_surface *dst)
+{
+    pipe_surface_reference(&dst->srf, NULL);
+}
+
+int
+xa_copy_prepare(struct xa_context *ctx,
+               struct xa_surface *dst, struct xa_surface *src)
+{
+    if (src == dst || dst->srf != NULL)
+       return -XA_ERR_INVAL;
+
+    if (src->tex->format != dst->tex->format) {
+       int ret = xa_surface_psurf_create(ctx, dst);
+       if (ret != XA_ERR_NONE)
+           return ret;
+       renderer_copy_prepare(ctx, dst->srf, src->tex);
+       ctx->simple_copy = 0;
+    } else
+       ctx->simple_copy = 1;
+
+    ctx->src = src;
+    ctx->dst = dst;
+
+    return 0;
+}
+
+void
+xa_copy(struct xa_context *ctx,
+       int dx, int dy, int sx, int sy, int width, int height)
+{
+    struct pipe_box src_box;
+
+    if (ctx->simple_copy) {
+       u_box_2d(sx, sy, width, height, &src_box);
+       ctx->pipe->resource_copy_region(ctx->pipe,
+                                       ctx->dst->tex, 0, dx, dy, 0,
+                                       ctx->src->tex,
+                                       0, &src_box);
+    } else
+       renderer_copy(ctx, dx, dy, sx, sy, width, height,
+                     (float) width, (float) height);
+}
+
+void
+xa_copy_done(struct xa_context *ctx)
+{
+    if (!ctx->simple_copy) {
+          renderer_draw_flush(ctx);
+          ctx->pipe->flush(ctx->pipe, &ctx->last_fence);
+          xa_surface_psurf_destroy(ctx->dst);
+    } else
+       ctx->pipe->flush(ctx->pipe, &ctx->last_fence);
+}
+
+static void
+bind_solid_blend_state(struct xa_context *ctx)
+{
+    struct pipe_blend_state blend;
+
+    memset(&blend, 0, sizeof(struct pipe_blend_state));
+    blend.rt[0].blend_enable = 0;
+    blend.rt[0].colormask = PIPE_MASK_RGBA;
+
+    blend.rt[0].rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
+    blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+    blend.rt[0].rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
+    blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+
+    cso_set_blend(ctx->cso, &blend);
+}
+
+int
+xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst,
+                uint32_t fg)
+{
+    unsigned vs_traits, fs_traits;
+    struct xa_shader shader;
+    int width, height;
+    int ret;
+
+    ret = xa_surface_psurf_create(ctx, dst);
+    if (ret != XA_ERR_NONE)
+       return ret;
+
+    if (dst->srf->format == PIPE_FORMAT_L8_UNORM)
+       xa_pixel_to_float4_a8(fg, ctx->solid_color);
+    else
+       xa_pixel_to_float4(fg, ctx->solid_color);
+    ctx->has_solid_color = 1;
+
+    ctx->dst = dst;
+    width = dst->srf->width;
+    height = dst->srf->height;
+
+#if 0
+    debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n",
+                (fg >> 24) & 0xff, (fg >> 16) & 0xff,
+                (fg >> 8) & 0xff,  (fg >> 0) & 0xff,
+                exa->solid_color[0], exa->solid_color[1],
+                exa->solid_color[2], exa->solid_color[3]);
+#endif
+
+    vs_traits = VS_SOLID_FILL;
+    fs_traits = FS_SOLID_FILL;
+
+    renderer_bind_destination(ctx, dst->srf, width, height);
+    bind_solid_blend_state(ctx);
+    cso_set_samplers(ctx->cso, 0, NULL);
+    cso_set_fragment_sampler_views(ctx->cso, 0, NULL);
+
+    shader = xa_shaders_get(ctx->shaders, vs_traits, fs_traits);
+    cso_set_vertex_shader_handle(ctx->cso, shader.vs);
+    cso_set_fragment_shader_handle(ctx->cso, shader.fs);
+
+    renderer_begin_solid(ctx);
+
+    xa_surface_psurf_destroy(dst);
+    return XA_ERR_NONE;
+}
+
+void
+xa_solid(struct xa_context *ctx, int x, int y, int width, int height)
+{
+    renderer_solid(ctx, x, y, x + width, y + height, ctx->solid_color);
+}
+
+void
+xa_solid_done(struct xa_context *ctx)
+{
+    renderer_draw_flush(ctx);
+    ctx->pipe->flush(ctx->pipe, &ctx->last_fence);
+
+    ctx->comp = NULL;
+    ctx->has_solid_color = FALSE;
+    ctx->num_bound_samplers = 0;
+}
+
+struct xa_fence *
+xa_fence_get(struct xa_context *ctx)
+{
+    struct xa_fence *fence = malloc(sizeof(*fence));
+    struct pipe_screen *screen = ctx->xa->screen;
+
+    if (!fence)
+       return NULL;
+
+    fence->xa = ctx->xa;
+
+    if (ctx->last_fence == NULL)
+       fence->pipe_fence = NULL;
+    else
+       screen->fence_reference(screen, &fence->pipe_fence, ctx->last_fence);
+
+    return fence;
+}
+
+int
+xa_fence_wait(struct xa_fence *fence, uint64_t timeout)
+{
+    if (!fence)
+       return XA_ERR_NONE;
+
+    if (fence->pipe_fence) {
+       struct pipe_screen *screen = fence->xa->screen;
+       boolean timed_out;
+
+       timed_out = !screen->fence_finish(screen, fence->pipe_fence, timeout);
+       if (timed_out)
+           return -XA_ERR_BUSY;
+
+       screen->fence_reference(screen, &fence->pipe_fence, NULL);
+    }
+    return XA_ERR_NONE;
+}
+
+void
+xa_fence_destroy(struct xa_fence *fence)
+{
+    if (!fence)
+       return;
+
+    if (fence->pipe_fence) {
+       struct pipe_screen *screen = fence->xa->screen;
+
+       screen->fence_reference(screen, &fence->pipe_fence, NULL);
+    }
+
+    free(fence);
+}
diff --git a/src/gallium/state_trackers/xa/xa_context.h b/src/gallium/state_trackers/xa/xa_context.h
new file mode 100644 (file)
index 0000000..ea2b923
--- /dev/null
@@ -0,0 +1,86 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#ifndef _XA_CONTEXT_H_
+#define _XA_CONTEXT_H_
+#include "xa_tracker.h"
+#include <stdint.h>
+
+struct xa_context;
+
+extern struct xa_context *xa_context_default(struct xa_tracker *xa);
+
+extern struct xa_context *xa_context_create(struct xa_tracker *xa);
+
+extern void xa_context_destroy(struct xa_context *r);
+
+extern int xa_yuv_planar_blit(struct xa_context *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 xa_box *box,
+                             unsigned int num_boxes,
+                             const float conversion_matrix[],
+                             struct xa_surface *dst, struct xa_surface *yuv[]);
+
+extern int xa_copy_prepare(struct xa_context *ctx,
+                          struct xa_surface *dst, struct xa_surface *src);
+
+extern void xa_copy(struct xa_context *ctx,
+                   int dx, int dy, int sx, int sy, int width, int height);
+
+extern void xa_copy_done(struct xa_context *ctx);
+
+extern int xa_surface_dma(struct xa_context *ctx,
+                         struct xa_surface *srf,
+                         void *data,
+                         unsigned int byte_pitch,
+                         int to_surface, struct xa_box *boxes,
+                         unsigned int num_boxes);
+
+extern int
+xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst,
+                uint32_t fg);
+extern void
+xa_solid(struct xa_context *ctx, int x, int y, int width, int height);
+
+extern void
+xa_solid_done(struct xa_context *ctx);
+
+extern struct xa_fence *xa_fence_get(struct xa_context *ctx);
+
+extern int xa_fence_wait(struct xa_fence *fence, uint64_t timeout);
+
+extern void xa_fence_destroy(struct xa_fence *fence);
+#endif
diff --git a/src/gallium/state_trackers/xa/xa_priv.h b/src/gallium/state_trackers/xa/xa_priv.h
new file mode 100644 (file)
index 0000000..e8f67a1
--- /dev/null
@@ -0,0 +1,253 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#ifndef _XA_PRIV_H_
+#define _XA_PRIV_H_
+
+#include "xa_tracker.h"
+#include "xa_context.h"
+#include "xa_composite.h"
+
+#include "pipe/p_screen.h"
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+
+#define XA_VB_SIZE (100 * 4 * 3 * 4)
+#define XA_LAST_SURFACE_TYPE (xa_type_yuv_component + 1)
+#define XA_MAX_SAMPLERS 3
+
+struct xa_fence {
+    struct pipe_fence_handle *pipe_fence;
+    struct xa_tracker *xa;
+};
+
+struct xa_format_descriptor {
+    enum pipe_format format;
+    enum xa_formats xa_format;
+};
+
+struct xa_surface {
+    struct pipe_resource template;
+    struct xa_tracker *xa;
+    struct pipe_resource *tex;
+    struct pipe_surface *srf;
+    struct pipe_sampler_view *view;
+    unsigned int flags;
+    struct xa_format_descriptor fdesc;
+    struct pipe_transfer *transfer;
+    struct pipe_context *mapping_pipe;
+};
+
+struct xa_tracker {
+    enum xa_formats *supported_formats;
+    unsigned int format_map[XA_LAST_SURFACE_TYPE][2];
+    int d_depth_bits_last;
+    int ds_depth_bits_last;
+    struct pipe_screen *screen;
+    struct xa_context *default_ctx;
+};
+
+struct xa_context {
+    struct xa_tracker *xa;
+    struct pipe_context *pipe;
+
+    struct cso_context *cso;
+    struct xa_shaders *shaders;
+
+    struct pipe_resource *vs_const_buffer;
+    struct pipe_resource *fs_const_buffer;
+
+    float buffer[XA_VB_SIZE];
+    unsigned int buffer_size;
+    struct pipe_vertex_element velems[3];
+
+    /* number of attributes per vertex for the current
+     * draw operation */
+    unsigned int attrs_per_vertex;
+
+    unsigned int fb_width;
+    unsigned int fb_height;
+
+    struct pipe_fence_handle *last_fence;
+    struct xa_surface *src;
+    struct xa_surface *dst;
+    int simple_copy;
+
+    int has_solid_color;
+    float solid_color[4];
+
+    unsigned int num_bound_samplers;
+    struct pipe_sampler_view *bound_sampler_views[XA_MAX_SAMPLERS];
+    const struct xa_composite *comp;
+};
+
+enum xa_vs_traits {
+    VS_COMPOSITE = 1 << 0,
+    VS_MASK = 1 << 1,
+    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)
+};
+
+enum xa_fs_traits {
+    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,
+    FS_DST_LUMINANCE = 1 << 16,
+
+    FS_FILL = (FS_SOLID_FILL | FS_LINGRAD_FILL | FS_RADGRAD_FILL),
+    FS_COMPONENT_ALPHA = (FS_CA_FULL | FS_CA_SRCALPHA)
+};
+
+struct xa_shader {
+    void *fs;
+    void *vs;
+};
+
+struct xa_shaders;
+
+/*
+ * Inline utilities
+ */
+
+static INLINE int
+xa_min(int a, int b)
+{
+    return ((a <= b) ? a : b);
+}
+
+static INLINE void
+xa_pixel_to_float4(uint32_t pixel, float *color)
+{
+    uint32_t       r, g, b, a;
+
+    a = (pixel >> 24) & 0xff;
+    r = (pixel >> 16) & 0xff;
+    g = (pixel >>  8) & 0xff;
+    b = (pixel >>  0) & 0xff;
+    color[0] = ((float)r) / 255.;
+    color[1] = ((float)g) / 255.;
+    color[2] = ((float)b) / 255.;
+    color[3] = ((float)a) / 255.;
+}
+
+static INLINE void
+xa_pixel_to_float4_a8(uint32_t pixel, float *color)
+{
+    uint32_t a;
+
+    a = (pixel >> 24) & 0xff;
+    color[0] = ((float)a) / 255.;
+    color[1] = ((float)a) / 255.;
+    color[2] = ((float)a) / 255.;
+    color[3] = ((float)a) / 255.;
+}
+
+/*
+ * xa_tgsi.c
+ */
+
+extern struct xa_shaders *xa_shaders_create(struct xa_context *);
+
+void xa_shaders_destroy(struct xa_shaders *shaders);
+
+struct xa_shader xa_shaders_get(struct xa_shaders *shaders,
+                               unsigned vs_traits, unsigned fs_traits);
+
+/*
+ * xa_context.c
+ */
+extern int
+xa_surface_psurf_create(struct xa_context *ctx, struct xa_surface *dst);
+
+extern void
+xa_surface_psurf_destroy(struct xa_surface *dst);
+
+/*
+ * xa_renderer.c
+ */
+void renderer_set_constants(struct xa_context *r,
+                           int shader_type, const float *params,
+                           int param_bytes);
+
+void renderer_draw_yuv(struct xa_context *r,
+                      float src_x,
+                      float src_y,
+                      float src_w,
+                      float src_h,
+                      int dst_x,
+                      int dst_y, int dst_w, int dst_h,
+                      struct xa_surface *srf[]);
+
+void renderer_bind_destination(struct xa_context *r,
+                              struct pipe_surface *surface, int width,
+                              int height);
+
+void renderer_init_state(struct xa_context *r);
+void renderer_copy_prepare(struct xa_context *r,
+                          struct pipe_surface *dst_surface,
+                          struct pipe_resource *src_texture);
+void renderer_copy(struct xa_context *r, int dx,
+                  int dy,
+                  int sx,
+                  int sy,
+                  int width, int height, float src_width, float src_height);
+
+void renderer_draw_flush(struct xa_context *r);
+
+void renderer_begin_solid(struct xa_context *r);
+void renderer_solid(struct xa_context *r,
+                   int x0, int y0, int x1, int y1, float *color);
+void
+renderer_begin_textures(struct xa_context *r);
+
+void
+renderer_texture(struct xa_context *r,
+                int *pos,
+                int width, int height,
+                const float *src_matrix,
+                const float *mask_matrix);
+
+#endif
diff --git a/src/gallium/state_trackers/xa/xa_renderer.c b/src/gallium/state_trackers/xa/xa_renderer.c
new file mode 100644 (file)
index 0000000..ef762f0
--- /dev/null
@@ -0,0 +1,632 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ */
+
+#include "xa_context.h"
+#include "xa_priv.h"
+#include <math.h>
+#include "cso_cache/cso_context.h"
+#include "util/u_inlines.h"
+#include "util/u_sampler.h"
+#include "util/u_draw_quad.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
+
+void
+
+
+renderer_set_constants(struct xa_context *r,
+                      int shader_type, const float *params, int param_bytes);
+
+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_resource *
+renderer_buffer_create(struct xa_context *r)
+{
+    struct pipe_resource *buf = pipe_user_buffer_create(r->pipe->screen,
+                                                       r->buffer,
+                                                       sizeof(float) *
+                                                       r->buffer_size,
+                                                       PIPE_BIND_VERTEX_BUFFER);
+
+    r->buffer_size = 0;
+
+    return buf;
+}
+
+static INLINE void
+renderer_draw(struct xa_context *r)
+{
+    struct pipe_context *pipe = r->pipe;
+    struct pipe_resource *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) {
+       cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
+
+       util_draw_vertex_buffer(pipe, r->cso, buf, 0, PIPE_PRIM_QUADS, num_verts,       /* verts */
+                               r->attrs_per_vertex);   /* attribs/vert */
+
+       pipe_resource_reference(&buf, NULL);
+    }
+}
+
+static INLINE void
+renderer_draw_conditional(struct xa_context *r, int next_batch)
+{
+    if (r->buffer_size + next_batch >= XA_VB_SIZE ||
+       (next_batch == 0 && r->buffer_size)) {
+       renderer_draw(r);
+    }
+}
+
+void
+renderer_init_state(struct xa_context *r)
+{
+    struct pipe_depth_stencil_alpha_state dsa;
+    struct pipe_rasterizer_state raster;
+    unsigned i;
+
+    /* 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);
+
+    /* vertex elements state */
+    memset(&r->velems[0], 0, sizeof(r->velems[0]) * 3);
+    for (i = 0; i < 3; i++) {
+       r->velems[i].src_offset = i * 4 * sizeof(float);
+       r->velems[i].instance_divisor = 0;
+       r->velems[i].vertex_buffer_index = 0;
+       r->velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+    }
+}
+
+static INLINE void
+add_vertex_color(struct xa_context *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 xa_context *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 INLINE void
+add_vertex_2tex(struct xa_context *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_data1(struct xa_context *r,
+                 float srcX, float srcY,  float dstX, float dstY,
+                 float width, float height,
+                 struct pipe_resource *src, const 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((float *)src_matrix, pt0[0], pt0[1], &pt0[0], &pt0[1]);
+       map_point((float *)src_matrix, pt1[0], pt1[1], &pt1[0], &pt1[1]);
+       map_point((float *)src_matrix, pt2[0], pt2[1], &pt2[0], &pt2[1]);
+       map_point((float *)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 void
+add_vertex_data2(struct xa_context *r,
+                 float srcX, float srcY, float maskX, float maskY,
+                 float dstX, float dstY, float width, float height,
+                 struct pipe_resource *src,
+                 struct pipe_resource *mask,
+                 const float *src_matrix, const 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((float *)src_matrix, spt0[0], spt0[1], &spt0[0], &spt0[1]);
+       map_point((float *)src_matrix, spt1[0], spt1[1], &spt1[0], &spt1[1]);
+    }
+
+    if (mask_matrix) {
+       map_point((float *)mask_matrix, mpt0[0], mpt0[1], &mpt0[0], &mpt0[1]);
+       map_point((float *)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_resource *
+setup_vertex_data_yuv(struct xa_context *r,
+                     float srcX,
+                     float srcY,
+                     float srcW,
+                     float srcH,
+                     float dstX,
+                     float dstY,
+                     float dstW, float dstH, struct xa_surface *srf[])
+{
+    float s0, t0, s1, t1;
+    float spt0[2], spt1[2];
+    struct pipe_resource *tex;
+
+    spt0[0] = srcX;
+    spt0[1] = srcY;
+    spt1[0] = srcX + srcW;
+    spt1[1] = srcY + srcH;
+
+    tex = srf[0]->tex;
+    s0 = spt0[0] / tex->width0;
+    t0 = spt0[1] / tex->height0;
+    s1 = spt1[0] / tex->width0;
+    t1 = spt1[1] / tex->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 xa_context *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);
+}
+
+void
+renderer_set_constants(struct xa_context *r,
+                      int shader_type, const float *params, int param_bytes)
+{
+    struct pipe_resource **cbuf =
+       (shader_type == PIPE_SHADER_VERTEX) ? &r->vs_const_buffer :
+       &r->fs_const_buffer;
+
+    pipe_resource_reference(cbuf, NULL);
+    *cbuf = pipe_buffer_create(r->pipe->screen,
+                              PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STATIC,
+                              param_bytes);
+
+    if (*cbuf) {
+       pipe_buffer_write(r->pipe, *cbuf, 0, param_bytes, params);
+    }
+    r->pipe->set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
+}
+
+void
+renderer_copy_prepare(struct xa_context *r,
+                     struct pipe_surface *dst_surface,
+                     struct pipe_resource *src_texture)
+{
+    struct pipe_context *pipe = r->pipe;
+    struct pipe_screen *screen = pipe->screen;
+    struct xa_shader shader;
+    uint32_t fs_traits = FS_COMPOSITE;
+
+    assert(screen->is_format_supported(screen, dst_surface->format,
+                                      PIPE_TEXTURE_2D, 0,
+                                      PIPE_BIND_RENDER_TARGET));
+    (void)screen;
+
+    /* set misc state we care about */
+    {
+       struct pipe_blend_state blend;
+
+       memset(&blend, 0, sizeof(blend));
+       blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+       blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+       blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+       blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+       blend.rt[0].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/sampler view */
+    {
+       struct pipe_sampler_view templ;
+       struct pipe_sampler_view *src_view;
+
+       u_sampler_view_default_template(&templ,
+                                       src_texture, src_texture->format);
+       src_view = pipe->create_sampler_view(pipe, src_texture, &templ);
+       cso_set_fragment_sampler_views(r->cso, 1, &src_view);
+       pipe_sampler_view_reference(&src_view, NULL);
+    }
+
+    /* shaders */
+    if (src_texture->format == PIPE_FORMAT_L8_UNORM)
+       fs_traits |= FS_SRC_LUMINANCE;
+    if (dst_surface->format == PIPE_FORMAT_L8_UNORM)
+       fs_traits |= FS_DST_LUMINANCE;
+
+    shader = xa_shaders_get(r->shaders, VS_COMPOSITE, fs_traits);
+    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;
+}
+
+void
+renderer_copy(struct xa_context *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 xa_context *r,
+                 float src_x,
+                 float src_y,
+                 float src_w,
+                 float src_h,
+                 int dst_x,
+                 int dst_y, int dst_w, int dst_h, struct xa_surface *srf[])
+{
+    struct pipe_context *pipe = r->pipe;
+    struct pipe_resource *buf = 0;
+
+    buf = setup_vertex_data_yuv(r,
+                               src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w,
+                               dst_h, srf);
+
+    if (buf) {
+       const int num_attribs = 2;      /*pos + tex coord */
+
+       cso_set_vertex_elements(r->cso, num_attribs, r->velems);
+
+       util_draw_vertex_buffer(pipe, r->cso, buf, 0, PIPE_PRIM_QUADS, 4,       /* verts */
+                               num_attribs);   /* attribs/vert */
+
+       pipe_resource_reference(&buf, NULL);
+    }
+}
+
+void
+renderer_begin_solid(struct xa_context *r)
+{
+    r->buffer_size = 0;
+    r->attrs_per_vertex = 2;
+}
+
+void
+renderer_solid(struct xa_context *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 xa_context *r)
+{
+    renderer_draw_conditional(r, 0);
+}
+
+void
+renderer_begin_textures(struct xa_context *r)
+{
+    r->attrs_per_vertex = 1 + r->num_bound_samplers;
+    r->buffer_size = 0;
+}
+
+void
+renderer_texture(struct xa_context *r,
+                int *pos,
+                int width, int height,
+                const float *src_matrix,
+                const float *mask_matrix)
+{
+    struct pipe_sampler_view **sampler_view = r->bound_sampler_views;
+
+#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,
+                        sampler_view[0]->texture, 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,
+                        sampler_view[0]->texture, sampler_view[1]->texture,
+                        src_matrix, mask_matrix);
+       break;
+    default:
+       break;
+    }
+}
diff --git a/src/gallium/state_trackers/xa/xa_symbols b/src/gallium/state_trackers/xa/xa_symbols
new file mode 100644 (file)
index 0000000..6da701f
--- /dev/null
@@ -0,0 +1,30 @@
+xa_tracker_version
+xa_tracker_create
+xa_tracker_destroy
+xa_surface_create
+xa_surface_destroy
+xa_surface_redefine
+xa_surface_dma
+xa_surface_map
+xa_surface_unmap
+xa_surface_format
+xa_surface_handle
+xa_format_check_supported
+xa_context_default
+xa_context_create
+xa_context_destroy
+xa_fence_get
+xa_fence_wait
+xa_fence_destroy
+xa_copy_prepare
+xa_copy
+xa_copy_done
+xa_solid_prepare
+xa_solid
+xa_solid_done
+xa_composite_allocation
+xa_composite_check_accelerated
+xa_composite_prepare
+xa_composite_rect
+xa_composite_done
+xa_yuv_planar_blit
diff --git a/src/gallium/state_trackers/xa/xa_tgsi.c b/src/gallium/state_trackers/xa/xa_tgsi.c
new file mode 100644 (file)
index 0000000..ed1690e
--- /dev/null
@@ -0,0 +1,663 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ */
+#include "xa_priv.h"
+
+#include "pipe/p_format.h"
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+#include "pipe/p_shader_tokens.h"
+
+#include "util/u_memory.h"
+
+#include "tgsi/tgsi_ureg.h"
+
+#include "cso_cache/cso_context.h"
+#include "cso_cache/cso_hash.h"
+
+/* Vertex shader:
+ * IN[0]    = vertex pos
+ * IN[1]    = src tex coord | solid fill color
+ * IN[2]    = mask tex coord
+ * IN[3]    = dst tex coord
+ * CONST[0] = (2/dst_width, 2/dst_height, 1, 1)
+ * CONST[1] = (-1, -1, 0, 0)
+ *
+ * OUT[0]   = vertex pos
+ * OUT[1]   = src tex coord | solid fill color
+ * OUT[2]   = mask tex coord
+ * OUT[3]   = dst tex coord
+ */
+
+/* Fragment shader:
+ * SAMP[0]  = src
+ * SAMP[1]  = mask
+ * SAMP[2]  = dst
+ * IN[0]    = pos src | solid fill color
+ * IN[1]    = pos mask
+ * IN[2]    = pos dst
+ * CONST[0] = (0, 0, 0, 1)
+ *
+ * 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, */
+       "FS_DST_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 xa_shaders {
+    struct xa_context *r;
+
+    struct cso_hash *vs_hash;
+    struct cso_hash *fs_hash;
+};
+
+static INLINE void
+src_in_mask(struct ureg_program *ureg,
+           struct ureg_dst dst,
+           struct ureg_src src,
+           struct ureg_src mask,
+           unsigned component_alpha, unsigned mask_luminance)
+{
+    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
+vs_normalize_coords(struct ureg_program *ureg,
+                   struct ureg_src coords,
+                   struct ureg_src const0, struct ureg_src const1)
+{
+    struct ureg_dst tmp = ureg_DECL_temporary(ureg);
+    struct ureg_src ret;
+
+    ureg_MAD(ureg, tmp, coords, const0, const1);
+    ret = ureg_src(tmp);
+    ureg_release_temporary(ureg, tmp);
+    return ret;
+}
+
+static void
+linear_gradient(struct ureg_program *ureg,
+               struct ureg_dst out,
+               struct ureg_src pos,
+               struct ureg_src sampler,
+               struct ureg_src coords,
+               struct ureg_src const0124,
+               struct ureg_src matrow0,
+               struct ureg_src matrow1, struct ureg_src matrow2)
+{
+    struct ureg_dst temp0 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp1 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp2 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp3 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp4 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp5 = ureg_DECL_temporary(ureg);
+
+    ureg_MOV(ureg, ureg_writemask(temp0, TGSI_WRITEMASK_XY), pos);
+    ureg_MOV(ureg,
+            ureg_writemask(temp0, TGSI_WRITEMASK_Z),
+            ureg_scalar(const0124, TGSI_SWIZZLE_Y));
+
+    ureg_DP3(ureg, temp1, matrow0, ureg_src(temp0));
+    ureg_DP3(ureg, temp2, matrow1, ureg_src(temp0));
+    ureg_DP3(ureg, temp3, matrow2, ureg_src(temp0));
+    ureg_RCP(ureg, temp3, ureg_src(temp3));
+    ureg_MUL(ureg, temp1, ureg_src(temp1), ureg_src(temp3));
+    ureg_MUL(ureg, temp2, ureg_src(temp2), ureg_src(temp3));
+
+    ureg_MOV(ureg, ureg_writemask(temp4, TGSI_WRITEMASK_X), ureg_src(temp1));
+    ureg_MOV(ureg, ureg_writemask(temp4, TGSI_WRITEMASK_Y), ureg_src(temp2));
+
+    ureg_MUL(ureg, temp0,
+            ureg_scalar(coords, TGSI_SWIZZLE_Y),
+            ureg_scalar(ureg_src(temp4), TGSI_SWIZZLE_Y));
+    ureg_MAD(ureg, temp1,
+            ureg_scalar(coords, TGSI_SWIZZLE_X),
+            ureg_scalar(ureg_src(temp4), TGSI_SWIZZLE_X), ureg_src(temp0));
+
+    ureg_MUL(ureg, temp2, ureg_src(temp1), ureg_scalar(coords, TGSI_SWIZZLE_Z));
+
+    ureg_TEX(ureg, out, TGSI_TEXTURE_1D, ureg_src(temp2), sampler);
+
+    ureg_release_temporary(ureg, temp0);
+    ureg_release_temporary(ureg, temp1);
+    ureg_release_temporary(ureg, temp2);
+    ureg_release_temporary(ureg, temp3);
+    ureg_release_temporary(ureg, temp4);
+    ureg_release_temporary(ureg, temp5);
+}
+
+static void
+radial_gradient(struct ureg_program *ureg,
+               struct ureg_dst out,
+               struct ureg_src pos,
+               struct ureg_src sampler,
+               struct ureg_src coords,
+               struct ureg_src const0124,
+               struct ureg_src matrow0,
+               struct ureg_src matrow1, struct ureg_src matrow2)
+{
+    struct ureg_dst temp0 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp1 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp2 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp3 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp4 = ureg_DECL_temporary(ureg);
+    struct ureg_dst temp5 = ureg_DECL_temporary(ureg);
+
+    ureg_MOV(ureg, ureg_writemask(temp0, TGSI_WRITEMASK_XY), pos);
+    ureg_MOV(ureg,
+            ureg_writemask(temp0, TGSI_WRITEMASK_Z),
+            ureg_scalar(const0124, TGSI_SWIZZLE_Y));
+
+    ureg_DP3(ureg, temp1, matrow0, ureg_src(temp0));
+    ureg_DP3(ureg, temp2, matrow1, ureg_src(temp0));
+    ureg_DP3(ureg, temp3, matrow2, ureg_src(temp0));
+    ureg_RCP(ureg, temp3, ureg_src(temp3));
+    ureg_MUL(ureg, temp1, ureg_src(temp1), ureg_src(temp3));
+    ureg_MUL(ureg, temp2, ureg_src(temp2), ureg_src(temp3));
+
+    ureg_MOV(ureg, ureg_writemask(temp5, TGSI_WRITEMASK_X), ureg_src(temp1));
+    ureg_MOV(ureg, ureg_writemask(temp5, TGSI_WRITEMASK_Y), ureg_src(temp2));
+
+    ureg_MUL(ureg, temp0, ureg_scalar(coords, TGSI_SWIZZLE_Y),
+            ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_Y));
+    ureg_MAD(ureg, temp1,
+            ureg_scalar(coords, TGSI_SWIZZLE_X),
+            ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_X), ureg_src(temp0));
+    ureg_ADD(ureg, temp1, ureg_src(temp1), ureg_src(temp1));
+    ureg_MUL(ureg, temp3,
+            ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_Y),
+            ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_Y));
+    ureg_MAD(ureg, temp4,
+            ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_X),
+            ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_X), ureg_src(temp3));
+    ureg_MOV(ureg, temp4, ureg_negate(ureg_src(temp4)));
+    ureg_MUL(ureg, temp2, ureg_scalar(coords, TGSI_SWIZZLE_Z), ureg_src(temp4));
+    ureg_MUL(ureg, temp0,
+            ureg_scalar(const0124, TGSI_SWIZZLE_W), ureg_src(temp2));
+    ureg_MUL(ureg, temp3, ureg_src(temp1), ureg_src(temp1));
+    ureg_SUB(ureg, temp2, ureg_src(temp3), ureg_src(temp0));
+    ureg_RSQ(ureg, temp2, ureg_abs(ureg_src(temp2)));
+    ureg_RCP(ureg, temp2, ureg_src(temp2));
+    ureg_SUB(ureg, temp1, ureg_src(temp2), ureg_src(temp1));
+    ureg_ADD(ureg, temp0,
+            ureg_scalar(coords, TGSI_SWIZZLE_Z),
+            ureg_scalar(coords, TGSI_SWIZZLE_Z));
+    ureg_RCP(ureg, temp0, ureg_src(temp0));
+    ureg_MUL(ureg, temp2, ureg_src(temp1), ureg_src(temp0));
+    ureg_TEX(ureg, out, TGSI_TEXTURE_1D, ureg_src(temp2), sampler);
+
+    ureg_release_temporary(ureg, temp0);
+    ureg_release_temporary(ureg, temp1);
+    ureg_release_temporary(ureg, temp2);
+    ureg_release_temporary(ureg, temp3);
+    ureg_release_temporary(ureg, temp4);
+    ureg_release_temporary(ureg, temp5);
+}
+
+static void *
+create_vs(struct pipe_context *pipe, unsigned vs_traits)
+{
+    struct ureg_program *ureg;
+    struct ureg_src src;
+    struct ureg_dst dst;
+    struct ureg_src const0, const1;
+    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);
+    if (ureg == NULL)
+       return 0;
+
+    const0 = ureg_DECL_constant(ureg, 0);
+    const1 = ureg_DECL_constant(ureg, 1);
+
+    /* it has to be either a fill or a composite op */
+    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);
+    src = vs_normalize_coords(ureg, src, 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);
+       ureg_MOV(ureg, dst, src);
+    }
+
+    if (is_fill) {
+       src = ureg_DECL_vs_input(ureg, input_slot++);
+       dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0);
+       ureg_MOV(ureg, dst, src);
+    }
+
+    if (has_mask) {
+       src = ureg_DECL_vs_input(ureg, input_slot++);
+       dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 1);
+       ureg_MOV(ureg, dst, src);
+    }
+
+    ureg_END(ureg);
+
+    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)
+{
+    struct ureg_program *ureg;
+    struct ureg_src /*dst_sampler, */ src_sampler, mask_sampler;
+    struct ureg_src /*dst_pos, */ src_input, mask_pos;
+    struct ureg_dst src, mask;
+    struct ureg_dst out;
+    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;
+    unsigned dst_luminance = (fs_traits & FS_DST_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, 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 if (is_fill) {
+       if (is_solid)
+           src_input = ureg_DECL_fs_input(ureg,
+                                          TGSI_SEMANTIC_COLOR, 0,
+                                          TGSI_INTERPOLATE_PERSPECTIVE);
+       else
+           src_input = ureg_DECL_fs_input(ureg,
+                                          TGSI_SEMANTIC_POSITION, 0,
+                                          TGSI_INTERPOLATE_PERSPECTIVE);
+    } else {
+       debug_assert(is_yuv);
+       return create_yuv_shader(pipe, ureg);
+    }
+
+    if (has_mask) {
+       mask_sampler = ureg_DECL_sampler(ureg, 1);
+       mask_pos = ureg_DECL_fs_input(ureg,
+                                     TGSI_SEMANTIC_GENERIC, 1,
+                                     TGSI_INTERPOLATE_PERSPECTIVE);
+    }
+#if 0                          /* unused right now */
+    dst_sampler = ureg_DECL_sampler(ureg, 2);
+    dst_pos = ureg_DECL_fs_input(ureg,
+                                TGSI_SEMANTIC_POSITION, 2,
+                                TGSI_INTERPOLATE_PERSPECTIVE);
+#endif
+
+    if (is_composite) {
+       if (has_mask || src_luminance || dst_luminance)
+           src = ureg_DECL_temporary(ureg);
+       else
+           src = out;
+       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 || src_luminance || dst_luminance)
+               src = ureg_dst(src_input);
+           else
+               ureg_MOV(ureg, out, src_input);
+       } else if (is_lingrad || is_radgrad) {
+           struct ureg_src coords, const0124, matrow0, matrow1, matrow2;
+
+           if (has_mask || src_luminance || dst_luminance)
+               src = ureg_DECL_temporary(ureg);
+           else
+               src = out;
+
+           coords = ureg_DECL_constant(ureg, 0);
+           const0124 = ureg_DECL_constant(ureg, 1);
+           matrow0 = ureg_DECL_constant(ureg, 2);
+           matrow1 = ureg_DECL_constant(ureg, 3);
+           matrow2 = ureg_DECL_constant(ureg, 4);
+
+           if (is_lingrad) {
+               linear_gradient(ureg, src,
+                               src_input, src_sampler,
+                               coords, const0124, matrow0, matrow1, matrow2);
+           } else if (is_radgrad) {
+               radial_gradient(ureg, src,
+                               src_input, src_sampler,
+                               coords, const0124, matrow0, matrow1, matrow2);
+           }
+       } 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 && !dst_luminance)
+           ureg_MOV(ureg, out, ureg_src(src));
+    }
+
+    if (has_mask) {
+       mask = ureg_DECL_temporary(ureg);
+       xrender_tex(ureg, mask, mask_pos, mask_sampler, imm0,
+                   mask_repeat_none, mask_swizzle, mask_set_alpha);
+       /* src IN mask */
+
+       src_in_mask(ureg, (dst_luminance) ? src : out, ureg_src(src),
+                   ureg_src(mask),
+                   comp_alpha_mask, mask_luminance);
+
+       ureg_release_temporary(ureg, mask);
+    }
+
+    if (dst_luminance) {
+       /*
+        * Make sure the alpha channel goes into the output L8 surface.
+        */
+       ureg_MOV(ureg, out, ureg_scalar(ureg_src(src), TGSI_SWIZZLE_W));
+    }
+
+    ureg_END(ureg);
+
+    return ureg_create_shader_and_destroy(ureg, pipe);
+}
+
+struct xa_shaders *
+xa_shaders_create(struct xa_context *r)
+{
+    struct xa_shaders *sc = CALLOC_STRUCT(xa_shaders);
+
+    sc->r = r;
+    sc->vs_hash = cso_hash_create();
+    sc->fs_hash = cso_hash_create();
+
+    return sc;
+}
+
+static void
+cache_destroy(struct cso_context *cso,
+             struct cso_hash *hash, unsigned processor)
+{
+    struct cso_hash_iter iter = cso_hash_first_node(hash);
+
+    while (!cso_hash_iter_is_null(iter)) {
+       void *shader = (void *)cso_hash_iter_data(iter);
+
+       if (processor == PIPE_SHADER_FRAGMENT) {
+           cso_delete_fragment_shader(cso, shader);
+       } else if (processor == PIPE_SHADER_VERTEX) {
+           cso_delete_vertex_shader(cso, shader);
+       }
+       iter = cso_hash_erase(hash, iter);
+    }
+    cso_hash_delete(hash);
+}
+
+void
+xa_shaders_destroy(struct xa_shaders *sc)
+{
+    cache_destroy(sc->r->cso, sc->vs_hash, PIPE_SHADER_VERTEX);
+    cache_destroy(sc->r->cso, sc->fs_hash, PIPE_SHADER_FRAGMENT);
+
+    FREE(sc);
+}
+
+static INLINE void *
+shader_from_cache(struct pipe_context *pipe,
+                 unsigned type, struct cso_hash *hash, unsigned key)
+{
+    void *shader = 0;
+
+    struct cso_hash_iter iter = cso_hash_find(hash, key);
+
+    if (cso_hash_iter_is_null(iter)) {
+       if (type == PIPE_SHADER_VERTEX)
+           shader = create_vs(pipe, key);
+       else
+           shader = create_fs(pipe, key);
+       cso_hash_insert(hash, key, shader);
+    } else
+       shader = (void *)cso_hash_iter_data(iter);
+
+    return shader;
+}
+
+struct xa_shader
+xa_shaders_get(struct xa_shaders *sc, unsigned vs_traits, unsigned fs_traits)
+{
+    struct xa_shader shader = { NULL, NULL };
+    void *vs, *fs;
+
+    vs = shader_from_cache(sc->r->pipe, PIPE_SHADER_VERTEX,
+                          sc->vs_hash, vs_traits);
+    fs = shader_from_cache(sc->r->pipe, PIPE_SHADER_FRAGMENT,
+                          sc->fs_hash, fs_traits);
+
+    debug_assert(vs && fs);
+    if (!vs || !fs)
+       return shader;
+
+    shader.vs = vs;
+    shader.fs = fs;
+
+    return shader;
+}
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
new file mode 100644 (file)
index 0000000..50922d3
--- /dev/null
@@ -0,0 +1,448 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#include "xa_tracker.h"
+#include "xa_priv.h"
+#include "pipe/p_state.h"
+#include "pipe/p_format.h"
+#include "state_tracker/drm_driver.h"
+#include "util/u_inlines.h"
+
+/*
+ * format_map [xa_surface_type][first..last in list].
+ * Needs to be updated when enum xa_formats is updated.
+ */
+
+static const enum xa_formats preferred_a[] = { xa_format_a8 };
+
+static const enum xa_formats preferred_argb[] =
+    { xa_format_a8r8g8b8, xa_format_x8r8g8b8, xa_format_r5g6b5,
+    xa_format_x1r5g5b5
+};
+static const enum xa_formats preferred_z[] =
+    { xa_format_z32, xa_format_z24, xa_format_z16 };
+static const enum xa_formats preferred_sz[] =
+    { xa_format_x8z24, xa_format_s8z24 };
+static const enum xa_formats preferred_zs[] =
+    { xa_format_z24x8, xa_format_z24s8 };
+static const enum xa_formats preferred_yuv[] = { xa_format_yuv8 };
+
+static const enum xa_formats *preferred[] =
+    { NULL, preferred_a, preferred_argb, NULL, NULL,
+    preferred_z, preferred_zs, preferred_sz, preferred_yuv
+};
+
+static const unsigned int num_preferred[] = { 0,
+    sizeof(preferred_a) / sizeof(enum xa_formats),
+    sizeof(preferred_argb) / sizeof(enum xa_formats),
+    0,
+    0,
+    sizeof(preferred_z) / sizeof(enum xa_formats),
+    sizeof(preferred_zs) / sizeof(enum xa_formats),
+    sizeof(preferred_sz) / sizeof(enum xa_formats),
+    sizeof(preferred_yuv) / sizeof(enum xa_formats)
+};
+
+static const unsigned int stype_bind[XA_LAST_SURFACE_TYPE] = { 0,
+    PIPE_BIND_SAMPLER_VIEW,
+    PIPE_BIND_SAMPLER_VIEW,
+    PIPE_BIND_SAMPLER_VIEW,
+    PIPE_BIND_SAMPLER_VIEW,
+    PIPE_BIND_DEPTH_STENCIL,
+    PIPE_BIND_DEPTH_STENCIL,
+    PIPE_BIND_DEPTH_STENCIL,
+    PIPE_BIND_SAMPLER_VIEW
+};
+
+static struct xa_format_descriptor
+xa_get_pipe_format(enum xa_formats xa_format)
+{
+    struct xa_format_descriptor fdesc;
+
+    fdesc.xa_format = xa_format;
+
+    switch (xa_format) {
+    case xa_format_a8r8g8b8:
+       fdesc.format = PIPE_FORMAT_B8G8R8A8_UNORM;
+       break;
+    case xa_format_x8r8g8b8:
+       fdesc.format = PIPE_FORMAT_B8G8R8X8_UNORM;
+       break;
+    case xa_format_r5g6b5:
+       fdesc.format = PIPE_FORMAT_B5G6R5_UNORM;
+       break;
+    case xa_format_x1r5g5b5:
+       fdesc.format = PIPE_FORMAT_B5G5R5A1_UNORM;
+       break;
+    case xa_format_a8:
+       fdesc.format = PIPE_FORMAT_L8_UNORM;
+       break;
+    case xa_format_z24:
+       fdesc.format = PIPE_FORMAT_Z24X8_UNORM;
+       break;
+    case xa_format_z16:
+       fdesc.format = PIPE_FORMAT_Z16_UNORM;
+       break;
+    case xa_format_z32:
+       fdesc.format = PIPE_FORMAT_Z32_UNORM;
+       break;
+    case xa_format_x8z24:
+       fdesc.format = PIPE_FORMAT_Z24X8_UNORM;
+       break;
+    case xa_format_z24x8:
+       fdesc.format = PIPE_FORMAT_X8Z24_UNORM;
+       break;
+    case xa_format_s8z24:
+       fdesc.format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
+       break;
+    case xa_format_z24s8:
+       fdesc.format = PIPE_FORMAT_S8_USCALED_Z24_UNORM;
+       break;
+    case xa_format_yuv8:
+       fdesc.format = PIPE_FORMAT_L8_UNORM;
+       break;
+    default:
+       fdesc.xa_format = xa_format_unknown;
+       break;
+    }
+    return fdesc;
+}
+
+struct xa_tracker *
+xa_tracker_create(int drm_fd)
+{
+    struct xa_tracker *xa = calloc(1, sizeof(struct xa_tracker));
+    enum xa_surface_type stype;
+    unsigned int num_formats;
+
+    if (!xa)
+       return NULL;
+
+    xa->screen = driver_descriptor.create_screen(drm_fd);
+    if (!xa->screen)
+       goto out_no_screen;
+
+    xa->default_ctx = xa_context_create(xa);
+    if (!xa->default_ctx)
+       goto out_no_pipe;
+
+    num_formats = 0;
+    for (stype = 0; stype < XA_LAST_SURFACE_TYPE; ++stype)
+       num_formats += num_preferred[stype];
+
+    num_formats += 1;
+    xa->supported_formats = calloc(num_formats, sizeof(*xa->supported_formats));
+    if (!xa->supported_formats)
+       goto out_sf_alloc_fail;
+
+    xa->supported_formats[0] = xa_format_unknown;
+    num_formats = 1;
+    memset(xa->format_map, 0, sizeof(xa->format_map));
+
+    for (stype = 0; stype < XA_LAST_SURFACE_TYPE; ++stype) {
+       unsigned int bind = stype_bind[stype];
+       enum xa_formats xa_format;
+       int i;
+
+       for (i = 0; i < num_preferred[stype]; ++i) {
+           xa_format = preferred[stype][i];
+
+           struct xa_format_descriptor fdesc = xa_get_pipe_format(xa_format);
+
+           if (xa->screen->is_format_supported(xa->screen, fdesc.format,
+                                               PIPE_TEXTURE_2D, 0, bind)) {
+               if (xa->format_map[stype][0] == 0)
+                   xa->format_map[stype][0] = num_formats;
+               xa->format_map[stype][1] = num_formats;
+               xa->supported_formats[num_formats++] = xa_format;
+           }
+       }
+    }
+    return xa;
+
+ out_sf_alloc_fail:
+    xa_context_destroy(xa->default_ctx);
+ out_no_pipe:
+    xa->screen->destroy(xa->screen);
+ out_no_screen:
+    free(xa);
+    return NULL;
+}
+
+void
+xa_tracker_destroy(struct xa_tracker *xa)
+{
+    free(xa->supported_formats);
+    xa_context_destroy(xa->default_ctx);
+    xa->screen->destroy(xa->screen);
+    free(xa);
+}
+
+static int
+xa_flags_compat(unsigned int old_flags, unsigned int new_flags)
+{
+    unsigned int flag_diff = (old_flags ^ new_flags);
+
+    if (flag_diff == 0)
+       return 1;
+
+    if (flag_diff & XA_FLAG_SHARED)
+       return 0;
+    /*
+     * Don't recreate if we're dropping the render target flag.
+     */
+    if (flag_diff & XA_FLAG_RENDER_TARGET)
+       return ((new_flags & XA_FLAG_RENDER_TARGET) == 0);
+
+    /*
+     * Always recreate for unknown / unimplemented flags.
+     */
+    return 0;
+}
+
+static struct xa_format_descriptor
+xa_get_format_stype_depth(struct xa_tracker *xa,
+                         enum xa_surface_type stype, unsigned int depth)
+{
+    unsigned int i;
+    struct xa_format_descriptor fdesc;
+    int found = 0;
+
+    for (i = xa->format_map[stype][0]; i <= xa->format_map[stype][1]; ++i) {
+       fdesc = xa_get_pipe_format(xa->supported_formats[i]);
+       if (fdesc.xa_format != xa_format_unknown &&
+           xa_format_depth(fdesc.xa_format) == depth) {
+           found = 1;
+           break;
+       }
+    }
+
+    if (!found)
+       fdesc.xa_format = xa_format_unknown;
+
+    return fdesc;
+}
+
+int
+xa_format_check_supported(struct xa_tracker *xa,
+                         enum xa_formats xa_format, unsigned int flags)
+{
+    struct xa_format_descriptor fdesc = xa_get_pipe_format(xa_format);
+    unsigned int bind;
+
+    if (fdesc.xa_format == xa_format_unknown)
+       return -XA_ERR_INVAL;
+
+    bind = stype_bind[xa_format_type(fdesc.xa_format)];
+    if (flags & XA_FLAG_SHARED)
+       bind |= PIPE_BIND_SHARED;
+    if (flags & XA_FLAG_RENDER_TARGET)
+       bind |= PIPE_BIND_RENDER_TARGET;
+
+    if (!xa->screen->is_format_supported(xa->screen, fdesc.format,
+                                        PIPE_TEXTURE_2D, 0, bind))
+       return -XA_ERR_INVAL;
+
+    return XA_ERR_NONE;
+}
+
+struct xa_surface *
+xa_surface_create(struct xa_tracker *xa,
+                 int width,
+                 int height,
+                 int depth,
+                 enum xa_surface_type stype,
+                 enum xa_formats xa_format, unsigned int flags)
+{
+    struct pipe_resource *template;
+    struct xa_surface *srf;
+    struct xa_format_descriptor fdesc;
+
+    if (xa_format == xa_format_unknown)
+       fdesc = xa_get_format_stype_depth(xa, stype, depth);
+    else
+       fdesc = xa_get_pipe_format(xa_format);
+
+    if (fdesc.xa_format == xa_format_unknown)
+       return NULL;
+
+    srf = calloc(1, sizeof(*srf));
+    if (!srf)
+       return NULL;
+
+    template = &srf->template;
+    template->format = fdesc.format;
+    template->target = PIPE_TEXTURE_2D;
+    template->width0 = width;
+    template->height0 = height;
+    template->depth0 = 1;
+    template->array_size = 1;
+    template->last_level = 0;
+    template->bind = stype_bind[xa_format_type(fdesc.xa_format)];
+
+    if (flags & XA_FLAG_SHARED)
+       template->bind |= PIPE_BIND_SHARED;
+    if (flags & XA_FLAG_RENDER_TARGET)
+       template->bind |= PIPE_BIND_RENDER_TARGET;
+
+    srf->tex = xa->screen->resource_create(xa->screen, template);
+    if (!srf->tex)
+       goto out_no_tex;
+
+    srf->srf = NULL;
+    srf->xa = xa;
+    srf->flags = flags;
+    srf->fdesc = fdesc;
+
+    return srf;
+ out_no_tex:
+    free(srf);
+    return NULL;
+}
+
+int
+xa_surface_redefine(struct xa_surface *srf,
+                   int width,
+                   int height,
+                   int depth,
+                   enum xa_surface_type stype,
+                   enum xa_formats xa_format,
+                   unsigned int new_flags,
+                   int copy_contents)
+{
+    struct pipe_resource *template = &srf->template;
+    struct pipe_resource *texture;
+    struct pipe_box src_box;
+    struct xa_tracker *xa = srf->xa;
+    int save_width;
+    int save_height;
+    struct xa_format_descriptor fdesc;
+
+    if (xa_format == xa_format_unknown)
+       fdesc = xa_get_format_stype_depth(xa, stype, depth);
+    else
+       fdesc = xa_get_pipe_format(xa_format);
+
+    if (width == template->width0 && height == template->height0 &&
+       template->format == fdesc.format &&
+       xa_flags_compat(srf->flags, new_flags))
+       return XA_ERR_NONE;
+
+    template->bind = stype_bind[xa_format_type(fdesc.xa_format)];
+    if (new_flags & XA_FLAG_SHARED)
+       template->bind |= PIPE_BIND_SHARED;
+    if (new_flags & XA_FLAG_RENDER_TARGET)
+       template->bind |= PIPE_BIND_RENDER_TARGET;
+
+    if (copy_contents) {
+       if (!xa_format_type_is_color(fdesc.xa_format) ||
+           xa_format_type(fdesc.xa_format) == xa_type_a)
+           return -XA_ERR_INVAL;
+
+       if (!xa->screen->is_format_supported(xa->screen, fdesc.format,
+                                            PIPE_TEXTURE_2D, 0,
+                                            template->bind |
+                                            PIPE_BIND_RENDER_TARGET))
+           return -XA_ERR_INVAL;
+    }
+
+    save_width = template->width0;
+    save_height = template->height0;
+
+    template->width0 = width;
+    template->height0 = height;
+
+    texture = xa->screen->resource_create(xa->screen, template);
+    if (!texture) {
+       template->width0 = save_width;
+       template->height0 = save_height;
+       return -XA_ERR_NORES;
+    }
+
+    pipe_surface_reference(&srf->srf, NULL);
+
+    if (copy_contents) {
+       struct pipe_context *pipe = xa->default_ctx->pipe;
+
+       u_box_origin_2d(xa_min(save_width, template->width0),
+                       xa_min(save_height, template->height0), &src_box);
+       pipe->resource_copy_region(pipe, texture,
+                                  0, 0, 0, 0, srf->tex, 0, &src_box);
+       pipe->flush(pipe, &xa->default_ctx->last_fence);
+    }
+
+    pipe_resource_reference(&srf->tex, texture);
+    pipe_resource_reference(&texture, NULL);
+    srf->fdesc = fdesc;
+    srf->flags = new_flags;
+
+    return XA_ERR_NONE;
+}
+
+void
+xa_surface_destroy(struct xa_surface *srf)
+{
+    pipe_surface_reference(&srf->srf, NULL);
+    pipe_resource_reference(&srf->tex, NULL);
+    free(srf);
+}
+
+extern void
+xa_tracker_version(int *major, int *minor, int *patch)
+{
+    *major = XA_TRACKER_VERSION_MAJOR;
+    *minor = XA_TRACKER_VERSION_MINOR;
+    *patch = XA_TRACKER_VERSION_PATCH;
+}
+
+extern int
+xa_surface_handle(struct xa_surface *srf,
+                 uint32_t * handle, unsigned int *stride)
+{
+    struct winsys_handle whandle;
+
+    struct pipe_screen *screen = srf->xa->screen;
+    boolean res;
+
+    memset(&whandle, 0, sizeof(whandle));
+    whandle.type = DRM_API_HANDLE_TYPE_SHARED;
+    res = screen->resource_get_handle(screen, srf->tex, &whandle);
+    if (!res)
+       return -XA_ERR_INVAL;
+
+    *handle = whandle.handle;
+    *stride = whandle.stride;
+
+    return XA_ERR_NONE;
+}
+
+enum xa_formats
+xa_surface_format(const struct xa_surface *srf)
+{
+    return srf->fdesc.xa_format;
+}
diff --git a/src/gallium/state_trackers/xa/xa_tracker.h b/src/gallium/state_trackers/xa/xa_tracker.h
new file mode 100644 (file)
index 0000000..62f8a21
--- /dev/null
@@ -0,0 +1,178 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ * The format encoding idea is partially borrowed from libpixman, but it is not
+ * considered a "substantial part of the software", so the pixman copyright
+ * is left out for simplicity, and acknowledgment is instead given in this way.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#ifndef _XA_TRACKER_H_
+#define _XA_TRACKER_H_
+
+#include <stdint.h>
+
+#define XA_TRACKER_VERSION_MAJOR 0
+#define XA_TRACKER_VERSION_MINOR 4
+#define XA_TRACKER_VERSION_PATCH 0
+
+#define XA_FLAG_SHARED         (1 << 0)
+#define XA_FLAG_RENDER_TARGET  (1 << 1)
+
+#define XA_MAP_READ            (1 << 0)
+#define XA_MAP_WRITE           (1 << 1)
+
+#define XA_ERR_NONE            0
+#define XA_ERR_NORES           1
+#define XA_ERR_INVAL           2
+#define XA_ERR_BUSY            3
+
+enum xa_surface_type {
+    xa_type_other,
+    xa_type_a,
+    xa_type_argb,
+    xa_type_abgr,
+    xa_type_bgra,
+    xa_type_z,
+    xa_type_zs,
+    xa_type_sz,
+    xa_type_yuv_component
+};
+
+/*
+ * Note that these formats should not be assumed to be binary compatible with
+ * pixman formats, but with the below macros and a format type map,
+ * conversion should be simple. Macros for now. We might replace with
+ * inline functions.
+ */
+
+#define xa_format(bpp,type,a,r,g,b)    (((bpp) << 24) |  \
+                                        ((type) << 16) | \
+                                        ((a) << 12) |    \
+                                        ((r) << 8) |     \
+                                        ((g) << 4) |     \
+                                        ((b)))
+/*
+ *  Non-RGBA one- and two component formats.
+ */
+
+#define xa_format_c(bpp,type,c1,c2) (((bpp) << 24) |     \
+                                    ((type) << 16) |     \
+                                    ((c1) << 8) |        \
+                                    ((c2)))
+#define xa_format_bpp(f)       (((f) >> 24)       )
+#define xa_format_type(f)      (((f) >> 16) & 0xff)
+#define xa_format_a(f) (((f) >> 12) & 0x0f)
+#define xa_format_r(f) (((f) >>  8) & 0x0f)
+#define xa_format_g(f) (((f) >>  4) & 0x0f)
+#define xa_format_b(f) (((f)      ) & 0x0f)
+#define xa_format_rgb(f)       (((f)      ) & 0xfff)
+#define xa_format_c1(f)          (((f) >> 8 ) & 0xff)
+#define xa_format_c2(f)          (((f)      ) & 0xff)
+#define xa_format_argb_depth(f)        (xa_format_a(f) +       \
+                                xa_format_r(f) +       \
+                                xa_format_g(f) +       \
+                                xa_format_b(f))
+#define xa_format_c_depth(f)    (xa_format_c1(f) + \
+                                xa_format_c2(f))
+
+static inline int
+xa_format_type_is_color(uint32_t xa_format)
+{
+    return (xa_format_type(xa_format) < xa_type_z);
+}
+
+static inline unsigned int
+xa_format_depth(uint32_t xa_format)
+{
+    return ((xa_format_type_is_color(xa_format)) ?
+           xa_format_argb_depth(xa_format) : xa_format_c_depth(xa_format));
+}
+
+enum xa_formats {
+    xa_format_unknown = 0,
+    xa_format_a8 = xa_format(8, xa_type_a, 8, 0, 0, 0),
+
+    xa_format_a8r8g8b8 = xa_format(32, xa_type_argb, 8, 8, 8, 8),
+    xa_format_x8r8g8b8 = xa_format(32, xa_type_argb, 0, 8, 8, 8),
+    xa_format_r5g6b5 = xa_format(16, xa_type_argb, 0, 5, 6, 5),
+    xa_format_x1r5g5b5 = xa_format(16, xa_type_argb, 0, 5, 5, 5),
+
+    xa_format_z16 = xa_format_c(16, xa_type_z, 16, 0),
+    xa_format_z32 = xa_format_c(32, xa_type_z, 32, 0),
+    xa_format_z24 = xa_format_c(32, xa_type_z, 24, 0),
+
+    xa_format_x8z24 = xa_format_c(32, xa_type_sz, 24, 0),
+    xa_format_s8z24 = xa_format_c(32, xa_type_sz, 24, 8),
+    xa_format_z24x8 = xa_format_c(32, xa_type_zs, 24, 0),
+    xa_format_z24s8 = xa_format_c(32, xa_type_zs, 24, 8),
+
+    xa_format_yuv8 = xa_format_c(8, xa_type_yuv_component, 8, 0)
+};
+
+struct xa_tracker;
+struct xa_surface;
+
+struct xa_box {
+    uint16_t x1, y1, x2, y2;
+};
+
+extern void xa_tracker_version(int *major, int *minor, int *patch);
+
+extern struct xa_tracker *xa_tracker_create(int drm_fd);
+
+extern void xa_tracker_destroy(struct xa_tracker *xa);
+
+extern int xa_format_check_supported(struct xa_tracker *xa,
+                                    enum xa_formats xa_format,
+                                    unsigned int flags);
+
+extern struct xa_surface *xa_surface_create(struct xa_tracker *xa,
+                                           int width,
+                                           int height,
+                                           int depth,
+                                           enum xa_surface_type stype,
+                                           enum xa_formats pform,
+                                           unsigned int flags);
+
+enum xa_formats xa_surface_format(const struct xa_surface *srf);
+
+extern void xa_surface_destroy(struct xa_surface *srf);
+
+extern int xa_surface_redefine(struct xa_surface *srf,
+                              int width,
+                              int height,
+                              int depth,
+                              enum xa_surface_type stype,
+                              enum xa_formats rgb_format,
+                              unsigned int new_flags,
+                              int copy_contents);
+
+extern int xa_surface_handle(struct xa_surface *srf,
+                            uint32_t * handle, unsigned int *byte_stride);
+
+#endif
diff --git a/src/gallium/state_trackers/xa/xa_yuv.c b/src/gallium/state_trackers/xa/xa_yuv.c
new file mode 100644 (file)
index 0000000..66cbc53
--- /dev/null
@@ -0,0 +1,179 @@
+/**********************************************************
+ * Copyright 2009-2011 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.
+ *
+ *********************************************************
+ * Authors:
+ * Zack Rusin <zackr-at-vmware-dot-com>
+ * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#include "xa_context.h"
+#include "xa_priv.h"
+#include "util/u_inlines.h"
+#include "util/u_sampler.h"
+#include "util/u_surface.h"
+#include "cso_cache/cso_context.h"
+
+static void
+xa_yuv_bind_blend_state(struct xa_context *r)
+{
+    struct pipe_blend_state blend;
+
+    memset(&blend, 0, sizeof(struct pipe_blend_state));
+    blend.rt[0].blend_enable = 0;
+    blend.rt[0].colormask = PIPE_MASK_RGBA;
+
+    /* porter&duff src */
+    blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+    blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+    blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+    blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+
+    cso_set_blend(r->cso, &blend);
+}
+
+static void
+xa_yuv_bind_shaders(struct xa_context *r)
+{
+    unsigned vs_traits = 0, fs_traits = 0;
+    struct xa_shader shader;
+
+    vs_traits |= VS_YUV;
+    fs_traits |= FS_YUV;
+
+    shader = xa_shaders_get(r->shaders, vs_traits, fs_traits);
+    cso_set_vertex_shader_handle(r->cso, shader.vs);
+    cso_set_fragment_shader_handle(r->cso, shader.fs);
+}
+
+static void
+xa_yuv_bind_samplers(struct xa_context *r, struct xa_surface *yuv[])
+{
+    struct pipe_sampler_state *samplers[3];
+    struct pipe_sampler_state sampler;
+    struct pipe_sampler_view *views[3];
+    struct pipe_sampler_view view_templ;
+    unsigned int i;
+
+    memset(&sampler, 0, sizeof(struct pipe_sampler_state));
+
+    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;
+
+    for (i = 0; i < 3; ++i) {
+       samplers[i] = &sampler;
+       if (!yuv[i]->view) {
+           u_sampler_view_default_template(&view_templ,
+                                           yuv[i]->tex, yuv[i]->tex->format);
+
+           yuv[i]->view = r->pipe->create_sampler_view(r->pipe,
+                                                       yuv[i]->tex,
+                                                       &view_templ);
+       }
+       views[i] = yuv[i]->view;
+    }
+
+    cso_set_samplers(r->cso, 3, (const struct pipe_sampler_state **)samplers);
+    cso_set_fragment_sampler_views(r->cso, 3, views);
+}
+
+static void
+xa_yuv_fs_constants(struct xa_context *r, const float conversion_matrix[])
+{
+    const int param_bytes = 12 * sizeof(float);
+
+    renderer_set_constants(r, PIPE_SHADER_FRAGMENT,
+                          conversion_matrix, param_bytes);
+}
+
+static void
+xa_yuv_destroy_sampler_views(struct xa_surface *yuv[])
+{
+    unsigned int i;
+
+    for (i = 0; i < 3; ++i) {
+       pipe_sampler_view_reference(&yuv[i]->view, NULL);
+    }
+}
+
+extern int
+xa_yuv_planar_blit(struct xa_context *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 xa_box *box,
+                  unsigned int num_boxes,
+                  const float conversion_matrix[],
+                  struct xa_surface *dst, struct xa_surface *yuv[])
+{
+    float scale_x;
+    float scale_y;
+    struct pipe_surface srf_templ;
+
+    if (dst_w == 0 || dst_h == 0)
+       return XA_ERR_NONE;
+
+    memset(&srf_templ, 0, sizeof(srf_templ));
+    u_surface_default_template(&srf_templ, dst->tex, PIPE_BIND_RENDER_TARGET);
+    dst->srf = r->pipe->create_surface(r->pipe, dst->tex, &srf_templ);
+    if (!dst->srf)
+       return -XA_ERR_NORES;
+
+    renderer_bind_destination(r, dst->srf, dst->srf->width, dst->srf->height);
+    xa_yuv_bind_blend_state(r);
+    xa_yuv_bind_shaders(r);
+    xa_yuv_bind_samplers(r, yuv);
+    xa_yuv_fs_constants(r, conversion_matrix);
+
+    scale_x = (float)src_w / (float)dst_w;
+    scale_y = (float)src_h / (float)dst_h;
+
+    while (num_boxes--) {
+       int x = box->x1;
+       int y = box->y1;
+       int w = box->x2 - box->x1;
+       int h = box->y2 - box->y1;
+
+       renderer_draw_yuv(r,
+                         (float)src_x + scale_x * (x - dst_x),
+                         (float)src_y + scale_y * (y - dst_y),
+                         scale_x * w, scale_y * h, x, y, w, h, yuv);
+       box++;
+    }
+
+    r->pipe->flush(r->pipe, &r->last_fence);
+
+    xa_yuv_destroy_sampler_views(yuv);
+    pipe_surface_reference(&dst->srf, NULL);
+
+    return XA_ERR_NONE;
+}
index 1931569..4ea4ec4 100644 (file)
@@ -9,10 +9,11 @@ env.Append(CPPPATH = [
     '#/src/mesa',
 ])
 
-env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server')
+env.PkgUseModules(['DRM', 'XORG'])
 
-if env['kms']:
+if env['HAVE_KMS']:
     env.Append(CPPDEFINES = ['HAVE_LIBKMS'])
+    env.PkgUseModules(['KMS'])
 
 conf = env.Configure()
 
index d4dc84a..f696b72 100644 (file)
@@ -237,7 +237,7 @@ picture_format_fixups(struct exa_pixmap_priv *pSrc, PicturePtr pSrcPicture, bool
    boolean swizzle = FALSE;
    unsigned ret = 0;
 
-   if (pSrc->picture_format == pSrcPicture->format) {
+   if (pSrc && pSrc->picture_format == pSrcPicture->format) {
       if (pSrc->picture_format == PICT_a8) {
          if (mask)
             return FS_MASK_LUMINANCE;
@@ -252,7 +252,7 @@ picture_format_fixups(struct exa_pixmap_priv *pSrc, PicturePtr pSrcPicture, bool
       return 0;
    }
 
-   if (pSrc->picture_format != PICT_a8r8g8b8) {
+   if (pSrc && pSrc->picture_format != PICT_a8r8g8b8) {
       assert(!"can not handle formats");
       return 0;
    }
@@ -355,7 +355,7 @@ bind_samplers(struct exa_context *exa, int op,
               struct exa_pixmap_priv *pMask,
               struct exa_pixmap_priv *pDst)
 {
-   struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS] = {0};
    struct pipe_sampler_state src_sampler, mask_sampler;
    struct pipe_sampler_view view_templ;
    struct pipe_sampler_view *src_view;
index 0499ed1..22e61cf 100644 (file)
@@ -122,6 +122,7 @@ crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
     drm_mode.hskew = mode->HSkew;
     drm_mode.vscan = mode->VScan;
     drm_mode.vrefresh = mode->VRefresh;
+    drm_mode.type = 0;
     if (!mode->name)
        xf86SetModeDefaultName(mode);
     strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN - 1);
diff --git a/src/gallium/state_trackers/xorg/xvmc/Makefile b/src/gallium/state_trackers/xorg/xvmc/Makefile
new file mode 100644 (file)
index 0000000..126dc6d
--- /dev/null
@@ -0,0 +1,16 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = xvmctracker
+
+LIBRARY_INCLUDES = \
+       $(shell pkg-config --cflags-only-I xvmc) \
+       -I$(TOP)/src/gallium/winsys/g3dvl
+
+C_SOURCES = block.c \
+            surface.c \
+            context.c \
+            subpicture.c \
+            attributes.c
+
+include ../../../Makefile.template
diff --git a/src/gallium/state_trackers/xorg/xvmc/attributes.c b/src/gallium/state_trackers/xorg/xvmc/attributes.c
new file mode 100644 (file)
index 0000000..817af53
--- /dev/null
@@ -0,0 +1,156 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <X11/Xlib.h>
+#include <X11/extensions/Xvlib.h>
+#include <X11/extensions/XvMClib.h>
+
+#include <vl/vl_compositor.h>
+
+#include "xvmc_private.h"
+
+#define XV_BRIGHTNESS "XV_BRIGHTNESS"
+#define XV_CONTRAST   "XV_CONTRAST"
+#define XV_SATURATION "XV_SATURATION"
+#define XV_HUE        "XV_HUE"
+#define XV_COLORSPACE "XV_COLORSPACE"
+
+static const XvAttribute attributes[] = {
+   { XvGettable | XvSettable, -1000, 1000, XV_BRIGHTNESS },
+   { XvGettable | XvSettable, -1000, 1000, XV_CONTRAST },
+   { XvGettable | XvSettable, -1000, 1000, XV_SATURATION },
+   { XvGettable | XvSettable, -1000, 1000, XV_HUE },
+   { XvGettable | XvSettable, 0, 1, XV_COLORSPACE }
+};
+
+PUBLIC
+XvAttribute* XvMCQueryAttributes(Display *dpy, XvMCContext *context, int *number)
+{
+   XvMCContextPrivate *context_priv;
+   XvAttribute *result;
+
+   assert(dpy && number);
+
+   if (!context || !context->privData)
+      return NULL;
+
+   context_priv = context->privData;
+
+   result = malloc(sizeof(attributes));
+   if (!result)
+      return NULL;
+
+   memcpy(result, attributes, sizeof(attributes));
+   *number = sizeof(attributes) / sizeof(XvAttribute);
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Returning %d attributes for context %p.\n", *number, context);
+
+   return result;
+}
+
+PUBLIC
+Status XvMCSetAttribute(Display *dpy, XvMCContext *context, Atom attribute, int value)
+{
+   XvMCContextPrivate *context_priv;
+   const char *attr;
+   float csc[16];
+
+   assert(dpy);
+
+   if (!context || !context->privData)
+      return XvMCBadContext;
+
+   context_priv = context->privData;
+
+   attr = XGetAtomName(dpy, attribute);
+   if (!attr)
+      return XvMCBadContext;
+
+   if (strcmp(attr, XV_BRIGHTNESS))
+      context_priv->procamp.brightness = value / 1000.0f;
+   else if (strcmp(attr, XV_CONTRAST))
+      context_priv->procamp.contrast = value / 1000.0f + 1.0f;
+   else if (strcmp(attr, XV_SATURATION))
+      context_priv->procamp.saturation = value / 1000.0f + 1.0f;
+   else if (strcmp(attr, XV_HUE))
+      context_priv->procamp.hue = value / 1000.0f;
+   else if (strcmp(attr, XV_COLORSPACE))
+      context_priv->color_standard = value ?
+         VL_CSC_COLOR_STANDARD_BT_601 :
+         VL_CSC_COLOR_STANDARD_BT_709;
+   else
+      return BadName;
+
+   vl_csc_get_matrix
+   (
+      context_priv->color_standard,
+      &context_priv->procamp, true, csc
+   );
+   vl_compositor_set_csc_matrix(&context_priv->compositor, csc);
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Set attribute %s to value %d.\n", attr, value);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCGetAttribute(Display *dpy, XvMCContext *context, Atom attribute, int *value)
+{
+   XvMCContextPrivate *context_priv;
+   const char *attr;
+
+   assert(dpy);
+
+   if (!context || !context->privData)
+      return XvMCBadContext;
+
+   context_priv = context->privData;
+
+   attr = XGetAtomName(dpy, attribute);
+   if (!attr)
+      return XvMCBadContext;
+
+   if (strcmp(attr, XV_BRIGHTNESS))
+      *value = context_priv->procamp.brightness * 1000;
+   else if (strcmp(attr, XV_CONTRAST))
+      *value = context_priv->procamp.contrast * 1000 - 1000;
+   else if (strcmp(attr, XV_SATURATION))
+      *value = context_priv->procamp.saturation * 1000 + 1000;
+   else if (strcmp(attr, XV_HUE))
+      *value = context_priv->procamp.hue * 1000;
+   else if (strcmp(attr, XV_COLORSPACE))
+      *value = context_priv->color_standard == VL_CSC_COLOR_STANDARD_BT_709;
+   else
+      return BadName;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Got value %d for attribute %s.\n", *value, attr);
+
+   return Success;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/block.c b/src/gallium/state_trackers/xorg/xvmc/block.c
new file mode 100644 (file)
index 0000000..6b0b212
--- /dev/null
@@ -0,0 +1,95 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <X11/Xlib.h>
+#include <X11/extensions/XvMClib.h>
+
+#include <util/u_memory.h>
+
+#include "xvmc_private.h"
+
+PUBLIC
+Status XvMCCreateBlocks(Display *dpy, XvMCContext *context, unsigned int num_blocks, XvMCBlockArray *blocks)
+{
+   assert(dpy);
+
+   if (!context)
+      return XvMCBadContext;
+   if (num_blocks == 0)
+      return BadValue;
+
+   assert(blocks);
+
+   blocks->context_id = context->context_id;
+   blocks->num_blocks = num_blocks;
+   blocks->blocks = MALLOC(BLOCK_SIZE_BYTES * num_blocks);
+   blocks->privData = NULL;
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCDestroyBlocks(Display *dpy, XvMCBlockArray *blocks)
+{
+   assert(dpy);
+   assert(blocks);
+   FREE(blocks->blocks);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCCreateMacroBlocks(Display *dpy, XvMCContext *context, unsigned int num_blocks, XvMCMacroBlockArray *blocks)
+{
+   assert(dpy);
+
+   if (!context)
+      return XvMCBadContext;
+   if (num_blocks == 0)
+      return BadValue;
+
+   assert(blocks);
+
+   blocks->context_id = context->context_id;
+   blocks->num_blocks = num_blocks;
+   blocks->macro_blocks = MALLOC(sizeof(XvMCMacroBlock) * num_blocks);
+   blocks->privData = NULL;
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCDestroyMacroBlocks(Display *dpy, XvMCMacroBlockArray *blocks)
+{
+   assert(dpy);
+   assert(blocks);
+   FREE(blocks->macro_blocks);
+
+   return Success;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/context.c b/src/gallium/state_trackers/xorg/xvmc/context.c
new file mode 100644 (file)
index 0000000..f21ebda
--- /dev/null
@@ -0,0 +1,332 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <X11/Xlibint.h>
+#include <X11/extensions/XvMClib.h>
+
+#include <pipe/p_screen.h>
+#include <pipe/p_video_decoder.h>
+#include <pipe/p_video_state.h>
+#include <pipe/p_state.h>
+
+#include <util/u_memory.h>
+
+#include <vl/vl_csc.h>
+#include <vl_winsys.h>
+
+#include "xvmc_private.h"
+
+static Status Validate(Display *dpy, XvPortID port, int surface_type_id,
+                       unsigned int width, unsigned int height, int flags,
+                       bool *found_port, int *screen, int *chroma_format,
+                       int *mc_type, int *surface_flags,
+                       unsigned short *subpic_max_w,
+                       unsigned short *subpic_max_h)
+{
+   bool found_surface = false;
+   XvAdaptorInfo *adaptor_info;
+   unsigned int num_adaptors;
+   int num_types;
+   unsigned int max_width = 0, max_height = 0;
+   Status ret;
+
+   assert(dpy);
+   assert(found_port);
+   assert(screen);
+   assert(chroma_format);
+   assert(mc_type);
+   assert(surface_flags);
+   assert(subpic_max_w);
+   assert(subpic_max_h);
+
+   *found_port = false;
+
+   for (unsigned int i = 0; i < XScreenCount(dpy); ++i) {
+      ret = XvQueryAdaptors(dpy, XRootWindow(dpy, i), &num_adaptors, &adaptor_info);
+      if (ret != Success)
+         return ret;
+
+      for (unsigned int j = 0; j < num_adaptors && !*found_port; ++j) {
+         for (unsigned int k = 0; k < adaptor_info[j].num_ports && !*found_port; ++k) {
+            XvMCSurfaceInfo *surface_info;
+
+            if (adaptor_info[j].base_id + k != port)
+               continue;
+
+            *found_port = true;
+
+            surface_info = XvMCListSurfaceTypes(dpy, adaptor_info[j].base_id, &num_types);
+            if (!surface_info) {
+               XvFreeAdaptorInfo(adaptor_info);
+               return BadAlloc;
+            }
+
+            for (unsigned int l = 0; l < num_types && !found_surface; ++l) {
+               if (surface_info[l].surface_type_id != surface_type_id)
+                  continue;
+
+               found_surface = true;
+               max_width = surface_info[l].max_width;
+               max_height = surface_info[l].max_height;
+               *chroma_format = surface_info[l].chroma_format;
+               *mc_type = surface_info[l].mc_type;
+               *surface_flags = surface_info[l].flags;
+               *subpic_max_w = surface_info[l].subpicture_max_width;
+               *subpic_max_h = surface_info[l].subpicture_max_height;
+               *screen = i;
+
+               XVMC_MSG(XVMC_TRACE, "[XvMC] Found requested context surface format.\n" \
+                                    "[XvMC]   screen=%u, port=%u\n" \
+                                    "[XvMC]   id=0x%08X\n" \
+                                    "[XvMC]   max width=%u, max height=%u\n" \
+                                    "[XvMC]   chroma format=0x%08X\n" \
+                                    "[XvMC]   acceleration level=0x%08X\n" \
+                                    "[XvMC]   flags=0x%08X\n" \
+                                    "[XvMC]   subpicture max width=%u, max height=%u\n",
+                                    i, port, surface_type_id, max_width, max_height, *chroma_format,
+                                    *mc_type, *surface_flags, *subpic_max_w, *subpic_max_h);
+            }
+
+            XFree(surface_info);
+         }
+      }
+
+      XvFreeAdaptorInfo(adaptor_info);
+   }
+
+   if (!*found_port) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Could not find a suitable port.\n");
+      return XvBadPort;
+   }
+   if (!found_surface) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Could not find a suitable surface.\n");
+      return BadMatch;
+   }
+   if (width > max_width || height > max_height) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Requested context dimensions (w=%u,h=%u) too large (max w=%u,h=%u).\n",
+               width, height, max_width, max_height);
+      return BadValue;
+   }
+   if (flags != XVMC_DIRECT && flags != 0) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Invalid context flags 0x%08X.\n", flags);
+      return BadValue;
+   }
+
+   return Success;
+}
+
+static enum pipe_video_profile ProfileToPipe(int xvmc_profile)
+{
+   if (xvmc_profile & XVMC_MPEG_1)
+      assert(0);
+   if (xvmc_profile & XVMC_MPEG_2)
+      return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
+   if (xvmc_profile & XVMC_H263)
+      assert(0);
+   if (xvmc_profile & XVMC_MPEG_4)
+      assert(0);
+
+   assert(0);
+
+   XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized profile 0x%08X.\n", xvmc_profile);
+
+   return -1;
+}
+
+static enum pipe_video_chroma_format FormatToPipe(int xvmc_format)
+{
+   switch (xvmc_format) {
+      case XVMC_CHROMA_FORMAT_420:
+         return PIPE_VIDEO_CHROMA_FORMAT_420;
+      case XVMC_CHROMA_FORMAT_422:
+         return PIPE_VIDEO_CHROMA_FORMAT_422;
+      case XVMC_CHROMA_FORMAT_444:
+         return PIPE_VIDEO_CHROMA_FORMAT_444;
+      default:
+         assert(0);
+   }
+
+   XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized format 0x%08X.\n", xvmc_format);
+
+   return -1;
+}
+
+PUBLIC
+Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,
+                         int width, int height, int flags, XvMCContext *context)
+{
+   bool found_port;
+   int scrn = 0;
+   int chroma_format = 0;
+   int mc_type = 0;
+   int surface_flags = 0;
+   unsigned short subpic_max_w = 0;
+   unsigned short subpic_max_h = 0;
+   Status ret;
+   struct vl_screen *vscreen;
+   struct vl_context *vctx;
+   XvMCContextPrivate *context_priv;
+   float csc[16];
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Creating context %p.\n", context);
+
+   assert(dpy);
+
+   if (!context)
+      return XvMCBadContext;
+
+   ret = Validate(dpy, port, surface_type_id, width, height, flags,
+                  &found_port, &scrn, &chroma_format, &mc_type, &surface_flags,
+                  &subpic_max_w, &subpic_max_h);
+
+   /* Success and XvBadPort have the same value */
+   if (ret != Success || !found_port)
+      return ret;
+
+   /* XXX: Current limits */
+   if (chroma_format != XVMC_CHROMA_FORMAT_420) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Cannot decode requested surface type. Unsupported chroma format.\n");
+      return BadImplementation;
+   }
+   if ((mc_type & ~XVMC_IDCT) != (XVMC_MOCOMP | XVMC_MPEG_2)) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Cannot decode requested surface type. Non-MPEG2/Mocomp/iDCT acceleration unsupported.\n");
+      return BadImplementation;
+   }
+   if (surface_flags & XVMC_INTRA_UNSIGNED) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Cannot decode requested surface type. Unsigned intra unsupported.\n");
+      return BadImplementation;
+   }
+
+   context_priv = CALLOC(1, sizeof(XvMCContextPrivate));
+   if (!context_priv)
+      return BadAlloc;
+
+   /* TODO: Reuse screen if process creates another context */
+   vscreen = vl_screen_create(dpy, scrn);
+
+   if (!vscreen) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL screen.\n");
+      FREE(context_priv);
+      return BadAlloc;
+   }
+
+   vctx = vl_video_create(vscreen);
+   if (!vctx) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL context.\n");
+      vl_screen_destroy(vscreen);
+      FREE(context_priv);
+      return BadAlloc;
+   }
+
+   context_priv->decoder = vctx->pipe->create_video_decoder
+   (
+      vctx->pipe,
+      ProfileToPipe(mc_type),
+      (mc_type & XVMC_IDCT) ? PIPE_VIDEO_ENTRYPOINT_IDCT : PIPE_VIDEO_ENTRYPOINT_MC,
+      FormatToPipe(chroma_format),
+      width, height
+   );
+
+   if (!context_priv->decoder) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL decoder.\n");
+      vl_video_destroy(vctx);
+      vl_screen_destroy(vscreen);
+      FREE(context_priv);
+      return BadAlloc;
+   }
+
+   if (!vl_compositor_init(&context_priv->compositor, vctx->pipe)) {
+      XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor.\n");
+      context_priv->decoder->destroy(context_priv->decoder);
+      vl_video_destroy(vctx);
+      vl_screen_destroy(vscreen);
+      FREE(context_priv);
+      return BadAlloc;
+   }
+
+   context_priv->color_standard =
+      debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
+      VL_CSC_COLOR_STANDARD_IDENTITY : VL_CSC_COLOR_STANDARD_BT_601;
+   context_priv->procamp = vl_default_procamp;
+
+   vl_csc_get_matrix
+   (
+      context_priv->color_standard,
+      &context_priv->procamp, true, csc
+   );
+   vl_compositor_set_csc_matrix(&context_priv->compositor, csc);
+
+   context_priv->vctx = vctx;
+   context_priv->subpicture_max_width = subpic_max_w;
+   context_priv->subpicture_max_height = subpic_max_h;
+
+   context->context_id = XAllocID(dpy);
+   context->surface_type_id = surface_type_id;
+   context->width = width;
+   context->height = height;
+   context->flags = flags;
+   context->port = port;
+   context->privData = context_priv;
+
+   SyncHandle();
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Context %p created.\n", context);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCDestroyContext(Display *dpy, XvMCContext *context)
+{
+   struct vl_screen *vscreen;
+   struct vl_context *vctx;
+   XvMCContextPrivate *context_priv;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Destroying context %p.\n", context);
+
+   assert(dpy);
+
+   if (!context || !context->privData)
+      return XvMCBadContext;
+
+   context_priv = context->privData;
+   vctx = context_priv->vctx;
+   vscreen = vctx->vscreen;
+   pipe_surface_reference(&context_priv->drawable_surface, NULL);
+   context_priv->decoder->destroy(context_priv->decoder);
+   vl_compositor_cleanup(&context_priv->compositor);
+   vl_video_destroy(vctx);
+   vl_screen_destroy(vscreen);
+   FREE(context_priv);
+   context->privData = NULL;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Context %p destroyed.\n", context);
+
+   return Success;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/subpicture.c b/src/gallium/state_trackers/xorg/xvmc/subpicture.c
new file mode 100644 (file)
index 0000000..7d6ff06
--- /dev/null
@@ -0,0 +1,561 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <X11/Xlibint.h>
+#include <X11/extensions/XvMClib.h>
+#include <xorg/fourcc.h>
+
+#include <pipe/p_screen.h>
+#include <pipe/p_video_decoder.h>
+#include <pipe/p_state.h>
+
+#include <util/u_memory.h>
+#include <util/u_math.h>
+#include <util/u_format.h>
+#include <util/u_sampler.h>
+#include <util/u_rect.h>
+
+#include <vl_winsys.h>
+
+#include "xvmc_private.h"
+
+#define FOURCC_RGB 0x0000003
+
+static enum pipe_format XvIDToPipe(int xvimage_id)
+{
+   switch (xvimage_id) {
+      case FOURCC_RGB:
+         return PIPE_FORMAT_B8G8R8X8_UNORM;
+
+      case FOURCC_AI44:
+      case FOURCC_IA44:
+         return PIPE_FORMAT_L4A4_UNORM;
+
+      default:
+         XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized Xv image ID 0x%08X.\n", xvimage_id);
+         return PIPE_FORMAT_NONE;
+   }
+}
+
+static unsigned NumPaletteEntries4XvID(int xvimage_id)
+{
+   switch (xvimage_id) {
+      case FOURCC_RGB:
+         return 0;
+
+      case FOURCC_AI44:
+      case FOURCC_IA44:
+         return 16;
+
+      default:
+         XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized Xv image ID 0x%08X.\n", xvimage_id);
+         return 0;
+   }
+}
+
+static void XvIDToSwizzle(int xvimage_id, struct pipe_sampler_view *tmpl)
+{
+   switch (xvimage_id) {
+      default:
+         XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized Xv image ID 0x%08X.\n", xvimage_id);
+
+      /* fall through */
+      case FOURCC_RGB:
+         tmpl->swizzle_r = PIPE_SWIZZLE_BLUE;
+         tmpl->swizzle_g = PIPE_SWIZZLE_GREEN;
+         tmpl->swizzle_b = PIPE_SWIZZLE_RED;
+         tmpl->swizzle_a = PIPE_SWIZZLE_ONE;
+         break;
+
+      case FOURCC_IA44:
+         tmpl->swizzle_r = PIPE_SWIZZLE_ALPHA;
+         tmpl->swizzle_g = PIPE_SWIZZLE_ZERO;
+         tmpl->swizzle_b = PIPE_SWIZZLE_ZERO;
+         tmpl->swizzle_a = PIPE_SWIZZLE_RED;
+         break;
+
+      case FOURCC_AI44:
+         tmpl->swizzle_r = PIPE_SWIZZLE_RED;
+         tmpl->swizzle_g = PIPE_SWIZZLE_ZERO;
+         tmpl->swizzle_b = PIPE_SWIZZLE_ZERO;
+         tmpl->swizzle_a = PIPE_SWIZZLE_ALPHA;
+         break;
+   }
+}
+
+static int PipeToComponentOrder(enum pipe_format format, char *component_order)
+{
+   assert(component_order);
+
+   switch (format) {
+      case PIPE_FORMAT_B8G8R8X8_UNORM:
+         return 0;
+
+      case PIPE_FORMAT_L4A4_UNORM:
+         component_order[0] = 'Y';
+         component_order[1] = 'U';
+         component_order[2] = 'V';
+         component_order[3] = 'A';
+         return 4;
+
+      default:
+         XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized PIPE_FORMAT 0x%08X.\n", format);
+         component_order[0] = 0;
+         component_order[1] = 0;
+         component_order[2] = 0;
+         component_order[3] = 0;
+         return 0;
+   }
+}
+
+static Status Validate(Display *dpy, XvPortID port, int surface_type_id, int xvimage_id)
+{
+   XvImageFormatValues *subpictures;
+   int num_subpics;
+   unsigned int i;
+
+   subpictures = XvMCListSubpictureTypes(dpy, port, surface_type_id, &num_subpics);
+   if (num_subpics < 1) {
+      if (subpictures)
+         XFree(subpictures);
+      return BadMatch;
+   }
+   if (!subpictures)
+      return BadAlloc;
+
+   for (i = 0; i < num_subpics; ++i) {
+      if (subpictures[i].id == xvimage_id) {
+         XVMC_MSG(XVMC_TRACE, "[XvMC] Found requested subpicture format.\n" \
+                              "[XvMC]   port=%u\n" \
+                              "[XvMC]   surface id=0x%08X\n" \
+                              "[XvMC]   image id=0x%08X\n" \
+                              "[XvMC]   type=%08X\n" \
+                              "[XvMC]   byte order=%08X\n" \
+                              "[XvMC]   bits per pixel=%u\n" \
+                              "[XvMC]   format=%08X\n" \
+                              "[XvMC]   num planes=%d\n",
+                              port, surface_type_id, xvimage_id, subpictures[i].type, subpictures[i].byte_order,
+                              subpictures[i].bits_per_pixel, subpictures[i].format, subpictures[i].num_planes);
+         if (subpictures[i].type == XvRGB) {
+            XVMC_MSG(XVMC_TRACE, "[XvMC]   depth=%d\n" \
+                                 "[XvMC]   red mask=0x%08X\n" \
+                                 "[XvMC]   green mask=0x%08X\n" \
+                                 "[XvMC]   blue mask=0x%08X\n",
+                                 subpictures[i].depth, subpictures[i].red_mask,
+                                 subpictures[i].green_mask, subpictures[i].blue_mask);
+         }
+         else if (subpictures[i].type == XvYUV) {
+            XVMC_MSG(XVMC_TRACE, "[XvMC]   y sample bits=0x%08X\n" \
+                                 "[XvMC]   u sample bits=0x%08X\n" \
+                                 "[XvMC]   v sample bits=0x%08X\n" \
+                                 "[XvMC]   horz y period=%u\n" \
+                                 "[XvMC]   horz u period=%u\n" \
+                                 "[XvMC]   horz v period=%u\n" \
+                                 "[XvMC]   vert y period=%u\n" \
+                                 "[XvMC]   vert u period=%u\n" \
+                                 "[XvMC]   vert v period=%u\n",
+                                 subpictures[i].y_sample_bits, subpictures[i].u_sample_bits, subpictures[i].v_sample_bits,
+                                 subpictures[i].horz_y_period, subpictures[i].horz_u_period, subpictures[i].horz_v_period,
+                                 subpictures[i].vert_y_period, subpictures[i].vert_u_period, subpictures[i].vert_v_period);
+         }
+         break;
+      }
+   }
+
+   XFree(subpictures);
+
+   return i < num_subpics ? Success : BadMatch;
+}
+
+static void
+upload_sampler(struct pipe_context *pipe, struct pipe_sampler_view *dst,
+               const struct pipe_box *dst_box, const void *src, unsigned src_stride,
+               unsigned src_x, unsigned src_y)
+{
+   struct pipe_transfer *transfer;
+   void *map;
+
+   transfer = pipe->get_transfer(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box);
+   if (!transfer)
+      return;
+
+   map = pipe->transfer_map(pipe, transfer);
+   if (map) {
+      util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0,
+                     dst_box->width, dst_box->height,
+                     src, src_stride, src_x, src_y);
+
+      pipe->transfer_unmap(pipe, transfer);
+   }
+
+   pipe->transfer_destroy(pipe, transfer);
+}
+
+PUBLIC
+Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *subpicture,
+                            unsigned short width, unsigned short height, int xvimage_id)
+{
+   XvMCContextPrivate *context_priv;
+   XvMCSubpicturePrivate *subpicture_priv;
+   struct pipe_context *pipe;
+   struct pipe_resource tex_templ, *tex;
+   struct pipe_sampler_view sampler_templ;
+   Status ret;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Creating subpicture %p.\n", subpicture);
+
+   assert(dpy);
+
+   if (!context)
+      return XvMCBadContext;
+
+   context_priv = context->privData;
+   pipe = context_priv->vctx->pipe;
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   if (width > context_priv->subpicture_max_width ||
+       height > context_priv->subpicture_max_height)
+      return BadValue;
+
+   ret = Validate(dpy, context->port, context->surface_type_id, xvimage_id);
+   if (ret != Success)
+      return ret;
+
+   subpicture_priv = CALLOC(1, sizeof(XvMCSubpicturePrivate));
+   if (!subpicture_priv)
+      return BadAlloc;
+
+   memset(&tex_templ, 0, sizeof(tex_templ));
+   tex_templ.target = PIPE_TEXTURE_2D;
+   tex_templ.format = XvIDToPipe(xvimage_id);
+   tex_templ.last_level = 0;
+   if (pipe->screen->get_video_param(pipe->screen,
+                                     PIPE_VIDEO_PROFILE_UNKNOWN,
+                                     PIPE_VIDEO_CAP_NPOT_TEXTURES)) {
+      tex_templ.width0 = width;
+      tex_templ.height0 = height;
+   }
+   else {
+      tex_templ.width0 = util_next_power_of_two(width);
+      tex_templ.height0 = util_next_power_of_two(height);
+   }
+   tex_templ.depth0 = 1;
+   tex_templ.array_size = 1;
+   tex_templ.usage = PIPE_USAGE_DYNAMIC;
+   tex_templ.bind = PIPE_BIND_SAMPLER_VIEW;
+   tex_templ.flags = 0;
+
+   tex = pipe->screen->resource_create(pipe->screen, &tex_templ);
+
+   memset(&sampler_templ, 0, sizeof(sampler_templ));
+   u_sampler_view_default_template(&sampler_templ, tex, tex->format);
+   XvIDToSwizzle(xvimage_id, &sampler_templ);
+
+   subpicture_priv->sampler = pipe->create_sampler_view(pipe, tex, &sampler_templ);
+   pipe_resource_reference(&tex, NULL);
+   if (!subpicture_priv->sampler) {
+      FREE(subpicture_priv);
+      return BadAlloc;
+   }
+
+   subpicture_priv->context = context;
+   subpicture->subpicture_id = XAllocID(dpy);
+   subpicture->context_id = context->context_id;
+   subpicture->xvimage_id = xvimage_id;
+   subpicture->width = width;
+   subpicture->height = height;
+   subpicture->num_palette_entries = NumPaletteEntries4XvID(xvimage_id);
+   subpicture->entry_bytes = PipeToComponentOrder(tex_templ.format, subpicture->component_order);
+   subpicture->privData = subpicture_priv;
+
+   if (subpicture->num_palette_entries > 0) {
+      tex_templ.target = PIPE_TEXTURE_1D;
+      tex_templ.format = PIPE_FORMAT_R8G8B8A8_UNORM;
+      tex_templ.width0 = subpicture->num_palette_entries;
+      tex_templ.height0 = 1;
+      tex_templ.usage = PIPE_USAGE_STATIC;
+
+      tex = pipe->screen->resource_create(pipe->screen, &tex_templ);
+
+      memset(&sampler_templ, 0, sizeof(sampler_templ));
+      u_sampler_view_default_template(&sampler_templ, tex, tex->format);
+      sampler_templ.swizzle_a = PIPE_SWIZZLE_ONE;
+      subpicture_priv->palette = pipe->create_sampler_view(pipe, tex, &sampler_templ);
+      pipe_resource_reference(&tex, NULL);
+      if (!subpicture_priv->sampler) {
+         FREE(subpicture_priv);
+         return BadAlloc;
+      }
+   }
+
+   SyncHandle();
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Subpicture %p created.\n", subpicture);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, short y,
+                           unsigned short width, unsigned short height, unsigned int color)
+{
+   XvMCSubpicturePrivate *subpicture_priv;
+   XvMCContextPrivate *context_priv;
+   struct pipe_context *pipe;
+   struct pipe_sampler_view *dst;
+   struct pipe_box dst_box = {x, y, 0, width, height, 1};
+   struct pipe_transfer *transfer;
+   union util_color uc;
+   void *map;
+
+   assert(dpy);
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   /* Convert color to float */
+   util_format_read_4f(PIPE_FORMAT_B8G8R8A8_UNORM,
+                       uc.f, 1, &color, 4,
+                       0, 0, 1, 1);
+
+   subpicture_priv = subpicture->privData;
+   context_priv = subpicture_priv->context->privData;
+   pipe = context_priv->vctx->pipe;
+   dst = subpicture_priv->sampler;
+   
+   /* TODO: Assert clear rect is within bounds? Or clip? */
+   transfer = pipe->get_transfer(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, &dst_box);
+   if (!transfer)
+      return XvMCBadSubpicture;
+
+   map = pipe->transfer_map(pipe, transfer);
+   if (map) {
+      util_fill_rect(map, dst->texture->format, transfer->stride, 0, 0,
+                     dst_box.width, dst_box.height, &uc);
+
+      pipe->transfer_unmap(pipe, transfer);
+   }
+
+   pipe->transfer_destroy(pipe, transfer);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCCompositeSubpicture(Display *dpy, XvMCSubpicture *subpicture, XvImage *image,
+                               short srcx, short srcy, unsigned short width, unsigned short height,
+                               short dstx, short dsty)
+{
+   XvMCSubpicturePrivate *subpicture_priv;
+   XvMCContextPrivate *context_priv;
+   struct pipe_context *pipe;
+   struct pipe_box dst_box = {dstx, dsty, 0, width, height, 1};
+   unsigned src_stride;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Compositing subpicture %p.\n", subpicture);
+
+   assert(dpy);
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   assert(image);
+
+   if (subpicture->xvimage_id != image->id)
+      return BadMatch;
+
+   /* No planar support for now */
+   if (image->num_planes != 1)
+      return BadMatch;
+
+   subpicture_priv = subpicture->privData;
+   context_priv = subpicture_priv->context->privData;
+   pipe = context_priv->vctx->pipe;
+
+   /* clipping should be done by upload_sampler and regardles what the documentation
+   says image->pitches[0] doesn't seems to be in bytes, so don't use it */
+   src_stride = image->width * util_format_get_blocksize(subpicture_priv->sampler->texture->format);
+   upload_sampler(pipe, subpicture_priv->sampler, &dst_box, image->data, src_stride, srcx, srcy);
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Subpicture %p composited.\n", subpicture);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCDestroySubpicture(Display *dpy, XvMCSubpicture *subpicture)
+{
+   XvMCSubpicturePrivate *subpicture_priv;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Destroying subpicture %p.\n", subpicture);
+
+   assert(dpy);
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   subpicture_priv = subpicture->privData;
+   pipe_sampler_view_reference(&subpicture_priv->sampler, NULL);
+   pipe_sampler_view_reference(&subpicture_priv->palette, NULL);
+   FREE(subpicture_priv);
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Subpicture %p destroyed.\n", subpicture);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCSetSubpicturePalette(Display *dpy, XvMCSubpicture *subpicture, unsigned char *palette)
+{
+   XvMCSubpicturePrivate *subpicture_priv;
+   XvMCContextPrivate *context_priv;
+   struct pipe_context *pipe;
+   struct pipe_box dst_box = {0, 0, 0, 0, 1, 1};
+
+   assert(dpy);
+   assert(palette);
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   subpicture_priv = subpicture->privData;
+   context_priv = subpicture_priv->context->privData;
+   pipe = context_priv->vctx->pipe;
+
+   dst_box.width = subpicture->num_palette_entries;
+
+   upload_sampler(pipe, subpicture_priv->palette, &dst_box, palette, 0, 0, 0);
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Palette of Subpicture %p set.\n", subpicture);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCBlendSubpicture(Display *dpy, XvMCSurface *target_surface, XvMCSubpicture *subpicture,
+                           short subx, short suby, unsigned short subw, unsigned short subh,
+                           short surfx, short surfy, unsigned short surfw, unsigned short surfh)
+{
+   struct pipe_video_rect src_rect = {subx, suby, subw, subh};
+   struct pipe_video_rect dst_rect = {surfx, surfy, surfw, surfh};
+
+   XvMCSurfacePrivate *surface_priv;
+   XvMCSubpicturePrivate *subpicture_priv;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Associating subpicture %p with surface %p.\n", subpicture, target_surface);
+
+   assert(dpy);
+
+   if (!target_surface)
+      return XvMCBadSurface;
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   if (target_surface->context_id != subpicture->context_id)
+      return BadMatch;
+
+   /* TODO: Verify against subpicture independent scaling */
+
+   surface_priv = target_surface->privData;
+   subpicture_priv = subpicture->privData;
+
+   /* TODO: Assert rects are within bounds? Or clip? */
+   subpicture_priv->src_rect = src_rect;
+   subpicture_priv->dst_rect = dst_rect;
+
+   surface_priv->subpicture = subpicture;
+   subpicture_priv->surface = target_surface;
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCBlendSubpicture2(Display *dpy, XvMCSurface *source_surface, XvMCSurface *target_surface,
+                            XvMCSubpicture *subpicture, short subx, short suby, unsigned short subw, unsigned short subh,
+                            short surfx, short surfy, unsigned short surfw, unsigned short surfh)
+{
+   assert(dpy);
+
+   if (!source_surface || !target_surface)
+      return XvMCBadSurface;
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   if (source_surface->context_id != subpicture->context_id)
+      return BadMatch;
+
+   if (source_surface->context_id != subpicture->context_id)
+      return BadMatch;
+
+   /* TODO: Assert rects are within bounds? Or clip? */
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCSyncSubpicture(Display *dpy, XvMCSubpicture *subpicture)
+{
+   assert(dpy);
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCFlushSubpicture(Display *dpy, XvMCSubpicture *subpicture)
+{
+   assert(dpy);
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCGetSubpictureStatus(Display *dpy, XvMCSubpicture *subpicture, int *status)
+{
+   assert(dpy);
+
+   if (!subpicture)
+      return XvMCBadSubpicture;
+
+   assert(status);
+
+   /* TODO */
+   *status = 0;
+
+   return Success;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
new file mode 100644 (file)
index 0000000..0c53b73
--- /dev/null
@@ -0,0 +1,666 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdio.h>
+
+#include <X11/Xlibint.h>
+
+#include <pipe/p_video_decoder.h>
+#include <pipe/p_video_state.h>
+#include <pipe/p_state.h>
+
+#include <util/u_inlines.h>
+#include <util/u_memory.h>
+#include <util/u_math.h>
+
+#include <vl_winsys.h>
+
+#include "xvmc_private.h"
+
+static const unsigned const_empty_block_mask_420[3][2][2] = {
+   { { 0x20, 0x10 },  { 0x08, 0x04 } },
+   { { 0x02, 0x02 },  { 0x02, 0x02 } },
+   { { 0x01, 0x01 },  { 0x01, 0x01 } }
+};
+
+static enum pipe_mpeg12_picture_type PictureToPipe(int xvmc_pic)
+{
+   switch (xvmc_pic) {
+      case XVMC_TOP_FIELD:
+         return PIPE_MPEG12_PICTURE_TYPE_FIELD_TOP;
+      case XVMC_BOTTOM_FIELD:
+         return PIPE_MPEG12_PICTURE_TYPE_FIELD_BOTTOM;
+      case XVMC_FRAME_PICTURE:
+         return PIPE_MPEG12_PICTURE_TYPE_FRAME;
+      default:
+         assert(0);
+   }
+
+   XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized picture type 0x%08X.\n", xvmc_pic);
+
+   return -1;
+}
+
+static inline void
+MacroBlockTypeToPipeWeights(const XvMCMacroBlock *xvmc_mb, unsigned weights[2])
+{
+   assert(xvmc_mb);
+
+   switch (xvmc_mb->macroblock_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) {
+   case XVMC_MB_TYPE_MOTION_FORWARD:
+      weights[0] = PIPE_VIDEO_MV_WEIGHT_MAX;
+      weights[1] = PIPE_VIDEO_MV_WEIGHT_MIN;
+      break;
+
+   case (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD):
+      weights[0] = PIPE_VIDEO_MV_WEIGHT_HALF;
+      weights[1] = PIPE_VIDEO_MV_WEIGHT_HALF;
+      break;
+
+   case XVMC_MB_TYPE_MOTION_BACKWARD:
+      weights[0] = PIPE_VIDEO_MV_WEIGHT_MIN;
+      weights[1] = PIPE_VIDEO_MV_WEIGHT_MAX;
+      break;
+
+   default:
+      /* workaround for xines xxmc video out plugin */
+      if (!(xvmc_mb->macroblock_type & ~XVMC_MB_TYPE_PATTERN)) {
+         weights[0] = PIPE_VIDEO_MV_WEIGHT_MAX;
+         weights[1] = PIPE_VIDEO_MV_WEIGHT_MIN;
+      } else {
+         weights[0] = PIPE_VIDEO_MV_WEIGHT_MIN;
+         weights[1] = PIPE_VIDEO_MV_WEIGHT_MIN;
+      }
+      break;
+   }
+}
+
+static inline struct pipe_motionvector
+MotionVectorToPipe(const XvMCMacroBlock *xvmc_mb, unsigned vector,
+                   unsigned field_select_mask, unsigned weight)
+{
+   struct pipe_motionvector mv;
+
+   assert(xvmc_mb);
+
+   switch (xvmc_mb->motion_type) {
+   case XVMC_PREDICTION_FRAME:
+      mv.top.x = xvmc_mb->PMV[0][vector][0];
+      mv.top.y = xvmc_mb->PMV[0][vector][1];
+      mv.top.field_select = PIPE_VIDEO_FRAME;
+      mv.top.weight = weight;
+
+      mv.bottom.x = xvmc_mb->PMV[0][vector][0];
+      mv.bottom.y = xvmc_mb->PMV[0][vector][1];
+      mv.bottom.weight = weight;
+      mv.bottom.field_select = PIPE_VIDEO_FRAME;
+      break;
+
+   case XVMC_PREDICTION_FIELD:
+      mv.top.x = xvmc_mb->PMV[0][vector][0];
+      mv.top.y = xvmc_mb->PMV[0][vector][1];
+      mv.top.field_select = (xvmc_mb->motion_vertical_field_select & field_select_mask) ?
+         PIPE_VIDEO_BOTTOM_FIELD : PIPE_VIDEO_TOP_FIELD;
+      mv.top.weight = weight;
+
+      mv.bottom.x = xvmc_mb->PMV[1][vector][0];
+      mv.bottom.y = xvmc_mb->PMV[1][vector][1];
+      mv.bottom.field_select = (xvmc_mb->motion_vertical_field_select & (field_select_mask << 2)) ?
+         PIPE_VIDEO_BOTTOM_FIELD : PIPE_VIDEO_TOP_FIELD;
+      mv.bottom.weight = weight;
+      break;
+
+   default: // TODO: Support DUALPRIME and 16x8
+      break;
+   }
+
+   return mv;
+}
+
+static inline void
+UploadYcbcrBlocks(XvMCSurfacePrivate *surface,
+                  const XvMCMacroBlock *xvmc_mb,
+                  const XvMCBlockArray *xvmc_blocks)
+{
+   enum pipe_mpeg12_dct_intra intra;
+   enum pipe_mpeg12_dct_type coding;
+
+   unsigned tb, x, y, luma_blocks;
+   short *blocks;
+
+   assert(surface);
+   assert(xvmc_mb);
+
+   if (!xvmc_mb->coded_block_pattern)
+      return;
+
+   intra = xvmc_mb->macroblock_type & XVMC_MB_TYPE_INTRA ?
+           PIPE_MPEG12_DCT_INTRA : PIPE_MPEG12_DCT_DELTA;
+
+   coding = xvmc_mb->dct_type == XVMC_DCT_TYPE_FIELD ?
+            PIPE_MPEG12_DCT_TYPE_FIELD : PIPE_MPEG12_DCT_TYPE_FRAME;
+
+   blocks = xvmc_blocks->blocks + xvmc_mb->index * BLOCK_SIZE_SAMPLES;
+
+   for (y = 0, luma_blocks = 0; y < 2; ++y) {
+      for (x = 0; x < 2; ++x, ++tb) {
+         if (xvmc_mb->coded_block_pattern & const_empty_block_mask_420[0][y][x]) {
+
+            struct pipe_ycbcr_block *stream = surface->ycbcr[0].stream;
+            stream->x = xvmc_mb->x * 2 + x;
+            stream->y = xvmc_mb->y * 2 + y;
+            stream->intra = intra;
+            stream->coding = coding;
+
+            surface->ycbcr[0].num_blocks_added++;
+            surface->ycbcr[0].stream++;
+
+            luma_blocks++;
+         }
+      }
+   }
+
+   if (luma_blocks > 0) {
+      memcpy(surface->ycbcr[0].buffer, blocks, BLOCK_SIZE_BYTES * luma_blocks);
+      surface->ycbcr[0].buffer += BLOCK_SIZE_SAMPLES * luma_blocks;
+      blocks += BLOCK_SIZE_SAMPLES * luma_blocks;
+   }
+
+   /* TODO: Implement 422, 444 */
+   //assert(ctx->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
+
+   for (tb = 1; tb < 3; ++tb) {
+      if (xvmc_mb->coded_block_pattern & const_empty_block_mask_420[tb][0][0]) {
+
+         struct pipe_ycbcr_block *stream = surface->ycbcr[tb].stream;
+         stream->x = xvmc_mb->x;
+         stream->y = xvmc_mb->y;
+         stream->intra = intra;
+         stream->coding = PIPE_MPEG12_DCT_TYPE_FRAME;
+
+         memcpy(surface->ycbcr[tb].buffer, blocks, BLOCK_SIZE_BYTES);
+
+         surface->ycbcr[tb].num_blocks_added++;
+         surface->ycbcr[tb].stream++;
+         surface->ycbcr[tb].buffer += BLOCK_SIZE_SAMPLES;
+         blocks += BLOCK_SIZE_SAMPLES;
+      }
+   }
+
+}
+
+static void
+MacroBlocksToPipe(XvMCSurfacePrivate *surface,
+                  unsigned int xvmc_picture_structure,
+                  const XvMCMacroBlock *xvmc_mb,
+                  const XvMCBlockArray *xvmc_blocks,
+                  unsigned int num_macroblocks)
+{
+   unsigned int i, j;
+
+   assert(xvmc_mb);
+   assert(xvmc_blocks);
+   assert(num_macroblocks);
+
+   for (i = 0; i < num_macroblocks; ++i) {
+      unsigned mv_pos = xvmc_mb->x + surface->mv_stride * xvmc_mb->y;
+      unsigned mv_weights[2];
+
+      if (xvmc_mb->macroblock_type & (XVMC_MB_TYPE_PATTERN | XVMC_MB_TYPE_INTRA))
+         UploadYcbcrBlocks(surface, xvmc_mb, xvmc_blocks);
+
+      MacroBlockTypeToPipeWeights(xvmc_mb, mv_weights);
+
+      for (j = 0; j < 2; ++j) {
+         if (!surface->ref[j].mv) continue;
+
+         surface->ref[j].mv[mv_pos] = MotionVectorToPipe
+         (
+            xvmc_mb, j,
+            j ? XVMC_SELECT_FIRST_BACKWARD : XVMC_SELECT_FIRST_FORWARD,
+            mv_weights[j]
+         );
+      }
+
+      ++xvmc_mb;
+   }
+}
+
+static void
+unmap_and_flush_surface(XvMCSurfacePrivate *surface)
+{
+   struct pipe_video_buffer *ref_frames[2];
+   XvMCContextPrivate *context_priv;
+   unsigned i, num_ycbcr_blocks[3];
+
+   assert(surface);
+
+   context_priv = surface->context->privData;
+
+   for ( i = 0; i < 2; ++i ) {
+      if (surface->ref[i].surface) {
+         XvMCSurfacePrivate *ref = surface->ref[i].surface->privData;
+
+         assert(ref);
+
+         unmap_and_flush_surface(ref);
+         surface->ref[i].surface = NULL;
+         ref_frames[i] = ref->video_buffer;
+      } else {
+         ref_frames[i] = NULL;
+      }
+   }
+
+   if (surface->mapped) {
+      surface->decode_buffer->end_frame(surface->decode_buffer);
+      for (i = 0; i < 3; ++i)
+         num_ycbcr_blocks[i] = surface->ycbcr[i].num_blocks_added;
+      context_priv->decoder->flush_buffer(surface->decode_buffer,
+                                          num_ycbcr_blocks,
+                                          ref_frames,
+                                          surface->video_buffer);
+      surface->mapped = 0;
+   }
+}
+
+PUBLIC
+Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surface)
+{
+   static const uint8_t dummy_quant[64] = {
+      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+      0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10
+   };
+
+   XvMCContextPrivate *context_priv;
+   struct pipe_context *pipe;
+   XvMCSurfacePrivate *surface_priv;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Creating surface %p.\n", surface);
+
+   assert(dpy);
+
+   if (!context)
+      return XvMCBadContext;
+   if (!surface)
+      return XvMCBadSurface;
+
+   context_priv = context->privData;
+   pipe = context_priv->vctx->pipe;
+
+   surface_priv = CALLOC(1, sizeof(XvMCSurfacePrivate));
+   if (!surface_priv)
+      return BadAlloc;
+
+   surface_priv->decode_buffer = context_priv->decoder->create_buffer(context_priv->decoder);
+   surface_priv->decode_buffer->set_quant_matrix(surface_priv->decode_buffer, dummy_quant, dummy_quant);
+
+   surface_priv->mv_stride = surface_priv->decode_buffer->get_mv_stream_stride(surface_priv->decode_buffer);
+   surface_priv->video_buffer = pipe->create_video_buffer
+   (
+      pipe, PIPE_FORMAT_NV12, context_priv->decoder->chroma_format,
+      context_priv->decoder->width, context_priv->decoder->height
+   );
+   
+   surface_priv->context = context;
+
+   surface->surface_id = XAllocID(dpy);
+   surface->context_id = context->context_id;
+   surface->surface_type_id = context->surface_type_id;
+   surface->width = context->width;
+   surface->height = context->height;
+   surface->privData = surface_priv;
+
+   SyncHandle();
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Surface %p created.\n", surface);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int picture_structure,
+                         XvMCSurface *target_surface, XvMCSurface *past_surface, XvMCSurface *future_surface,
+                         unsigned int flags, unsigned int num_macroblocks, unsigned int first_macroblock,
+                         XvMCMacroBlockArray *macroblocks, XvMCBlockArray *blocks
+)
+{
+   struct pipe_video_decode_buffer *t_buffer;
+
+   XvMCSurfacePrivate *target_surface_priv;
+   XvMCSurfacePrivate *past_surface_priv;
+   XvMCSurfacePrivate *future_surface_priv;
+   XvMCMacroBlock *xvmc_mb;
+
+   unsigned i;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Rendering to surface %p, with past %p and future %p\n",
+            target_surface, past_surface, future_surface);
+
+   assert(dpy);
+
+   if (!context || !context->privData)
+      return XvMCBadContext;
+   if (!target_surface || !target_surface->privData)
+      return XvMCBadSurface;
+
+   if (picture_structure != XVMC_TOP_FIELD &&
+       picture_structure != XVMC_BOTTOM_FIELD &&
+       picture_structure != XVMC_FRAME_PICTURE)
+      return BadValue;
+   /* Bkwd pred equivalent to fwd (past && !future) */
+   if (future_surface && !past_surface)
+      return BadMatch;
+
+   assert(context->context_id == target_surface->context_id);
+   assert(!past_surface || context->context_id == past_surface->context_id);
+   assert(!future_surface || context->context_id == future_surface->context_id);
+
+   assert(macroblocks);
+   assert(blocks);
+
+   assert(macroblocks->context_id == context->context_id);
+   assert(blocks->context_id == context->context_id);
+
+   assert(flags == 0 || flags == XVMC_SECOND_FIELD);
+
+   target_surface_priv = target_surface->privData;
+   past_surface_priv = past_surface ? past_surface->privData : NULL;
+   future_surface_priv = future_surface ? future_surface->privData : NULL;
+
+   assert(target_surface_priv->context == context);
+   assert(!past_surface || past_surface_priv->context == context);
+   assert(!future_surface || future_surface_priv->context == context);
+
+   t_buffer = target_surface_priv->decode_buffer;
+
+   // enshure that all reference frames are flushed
+   // not really nessasary, but speeds ups rendering
+   if (past_surface)
+      unmap_and_flush_surface(past_surface->privData);
+
+   if (future_surface)
+      unmap_and_flush_surface(future_surface->privData);
+
+   xvmc_mb = macroblocks->macro_blocks + first_macroblock;
+
+   /* If the surface we're rendering hasn't changed the ref frames shouldn't change. */
+   if (target_surface_priv->mapped && (
+       target_surface_priv->ref[0].surface != past_surface ||
+       target_surface_priv->ref[1].surface != future_surface ||
+       (xvmc_mb->x == 0 && xvmc_mb->y == 0))) {
+
+      // If they change anyway we need to clear our surface
+      unmap_and_flush_surface(target_surface_priv);
+   }
+
+   if (!target_surface_priv->mapped) {
+      t_buffer->begin_frame(t_buffer);
+
+      for (i = 0; i < 3; ++i) {
+         target_surface_priv->ycbcr[i].num_blocks_added = 0;
+         target_surface_priv->ycbcr[i].stream = t_buffer->get_ycbcr_stream(t_buffer, i);
+         target_surface_priv->ycbcr[i].buffer = t_buffer->get_ycbcr_buffer(t_buffer, i);
+      }
+
+      for (i = 0; i < 2; ++i) {
+         target_surface_priv->ref[i].surface = i == 0 ? past_surface : future_surface;
+
+         if (target_surface_priv->ref[i].surface)
+            target_surface_priv->ref[i].mv = t_buffer->get_mv_stream(t_buffer, i);
+         else
+            target_surface_priv->ref[i].mv = NULL;
+      }
+
+      target_surface_priv->mapped = 1;
+   }
+
+   MacroBlocksToPipe(target_surface_priv, picture_structure, xvmc_mb, blocks, num_macroblocks);
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for rendering.\n", target_surface);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCFlushSurface(Display *dpy, XvMCSurface *surface)
+{
+   assert(dpy);
+
+   if (!surface)
+      return XvMCBadSurface;
+
+   // don't call flush here, because this is usually
+   // called once for every slice instead of every frame
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Flushing surface %p\n", surface);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCSyncSurface(Display *dpy, XvMCSurface *surface)
+{
+   assert(dpy);
+
+   if (!surface)
+      return XvMCBadSurface;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Syncing surface %p\n", surface);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
+                      short srcx, short srcy, unsigned short srcw, unsigned short srch,
+                      short destx, short desty, unsigned short destw, unsigned short desth,
+                      int flags)
+{
+   static int dump_window = -1;
+
+   struct pipe_context *pipe;
+   struct vl_compositor *compositor;
+
+   XvMCSurfacePrivate *surface_priv;
+   XvMCContextPrivate *context_priv;
+   XvMCSubpicturePrivate *subpicture_priv;
+   XvMCContext *context;
+   struct pipe_video_rect src_rect = {srcx, srcy, srcw, srch};
+   struct pipe_video_rect dst_rect = {destx, desty, destw, desth};
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Displaying surface %p.\n", surface);
+
+   assert(dpy);
+
+   if (!surface || !surface->privData)
+      return XvMCBadSurface;
+
+   surface_priv = surface->privData;
+   context = surface_priv->context;
+   context_priv = context->privData;
+
+   assert(flags == XVMC_TOP_FIELD || flags == XVMC_BOTTOM_FIELD || flags == XVMC_FRAME_PICTURE);
+   assert(srcx + srcw - 1 < surface->width);
+   assert(srcy + srch - 1 < surface->height);
+
+   subpicture_priv = surface_priv->subpicture ? surface_priv->subpicture->privData : NULL;
+   pipe = context_priv->vctx->pipe;
+   compositor = &context_priv->compositor;
+
+   if (!context_priv->drawable_surface ||
+       context_priv->dst_rect.x != dst_rect.x || context_priv->dst_rect.y != dst_rect.y ||
+       context_priv->dst_rect.w != dst_rect.w || context_priv->dst_rect.h != dst_rect.h) {
+
+      pipe_surface_reference(&context_priv->drawable_surface, NULL);
+      context_priv->drawable_surface = vl_drawable_surface_get(context_priv->vctx, drawable);
+      context_priv->dst_rect = dst_rect;
+      vl_compositor_reset_dirty_area(compositor);
+   }
+
+   if (!context_priv->drawable_surface)
+      return BadDrawable;
+
+   /*
+    * Some apps (mplayer) hit these asserts because they call
+    * this function after the window has been resized by the WM
+    * but before they've handled the corresponding XEvent and
+    * know about the new dimensions. The output should be clipped
+    * until the app updates destw and desth.
+    */
+   /*
+   assert(destx + destw - 1 < drawable_surface->width);
+   assert(desty + desth - 1 < drawable_surface->height);
+    */
+
+   unmap_and_flush_surface(surface_priv);
+
+   vl_compositor_clear_layers(compositor);
+   vl_compositor_set_buffer_layer(compositor, 0, surface_priv->video_buffer, &src_rect, NULL);
+
+   if (subpicture_priv) {
+      XVMC_MSG(XVMC_TRACE, "[XvMC] Surface %p has subpicture %p.\n", surface, surface_priv->subpicture);
+
+      assert(subpicture_priv->surface == surface);
+
+      if (subpicture_priv->palette)
+         vl_compositor_set_palette_layer(compositor, 1, subpicture_priv->sampler, subpicture_priv->palette,
+                                         &subpicture_priv->src_rect, &subpicture_priv->dst_rect);
+      else
+         vl_compositor_set_rgba_layer(compositor, 1, subpicture_priv->sampler,
+                                      &subpicture_priv->src_rect, &subpicture_priv->dst_rect);
+
+      surface_priv->subpicture = NULL;
+      subpicture_priv->surface = NULL;
+   }
+
+   // Workaround for r600g, there seems to be a bug in the fence refcounting code
+   pipe->screen->fence_reference(pipe->screen, &surface_priv->fence, NULL);
+
+   vl_compositor_render(compositor, PictureToPipe(flags), context_priv->drawable_surface, &dst_rect, NULL);
+                        
+   pipe->flush(pipe, &surface_priv->fence);
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for display. Pushing to front buffer.\n", surface);
+
+   pipe->screen->flush_frontbuffer
+   (
+      pipe->screen,
+      context_priv->drawable_surface->texture,
+      0, 0,
+      vl_contextprivate_get(context_priv->vctx, context_priv->drawable_surface)
+   );
+
+   if(dump_window == -1) {
+      dump_window = debug_get_num_option("XVMC_DUMP", 0);
+   }
+
+   if(dump_window) {
+      static unsigned int framenum = 0;
+      char cmd[256];
+
+      sprintf(cmd, "xwd -id %d -out xvmc_frame_%08d.xwd", (int)drawable, ++framenum);
+      if (system(cmd) != 0)
+         XVMC_MSG(XVMC_ERR, "[XvMC] Dumping surface %p failed.\n", surface);
+   }
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Pushed surface %p to front buffer.\n", surface);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCGetSurfaceStatus(Display *dpy, XvMCSurface *surface, int *status)
+{
+   struct pipe_context *pipe;
+   XvMCSurfacePrivate *surface_priv;
+   XvMCContextPrivate *context_priv;
+
+   assert(dpy);
+
+   if (!surface)
+      return XvMCBadSurface;
+
+   assert(status);
+
+   surface_priv = surface->privData;
+   context_priv = surface_priv->context->privData;
+   pipe = context_priv->vctx->pipe;
+
+   *status = 0;
+
+   if (surface_priv->fence)
+      if (!pipe->screen->fence_signalled(pipe->screen, surface_priv->fence))
+         *status |= XVMC_RENDERING;
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface)
+{
+   XvMCSurfacePrivate *surface_priv;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Destroying surface %p.\n", surface);
+
+   assert(dpy);
+
+   if (!surface || !surface->privData)
+      return XvMCBadSurface;
+
+   surface_priv = surface->privData;
+   
+   if (surface_priv->mapped)
+      surface_priv->decode_buffer->end_frame(surface_priv->decode_buffer);
+   surface_priv->decode_buffer->destroy(surface_priv->decode_buffer);
+   surface_priv->video_buffer->destroy(surface_priv->video_buffer);
+   FREE(surface_priv);
+   surface->privData = NULL;
+
+   XVMC_MSG(XVMC_TRACE, "[XvMC] Surface %p destroyed.\n", surface);
+
+   return Success;
+}
+
+PUBLIC
+Status XvMCHideSurface(Display *dpy, XvMCSurface *surface)
+{
+   assert(dpy);
+
+   if (!surface || !surface->privData)
+      return XvMCBadSurface;
+
+   /* No op, only for overlaid rendering */
+
+   return Success;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/.gitignore b/src/gallium/state_trackers/xorg/xvmc/tests/.gitignore
new file mode 100644 (file)
index 0000000..9a8e05d
--- /dev/null
@@ -0,0 +1,6 @@
+test_context
+test_surface
+test_subpicture
+test_blocks
+test_rendering
+xvmc_bench
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/Makefile b/src/gallium/state_trackers/xorg/xvmc/tests/Makefile
new file mode 100644 (file)
index 0000000..88b0376
--- /dev/null
@@ -0,0 +1,31 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBS = -lXvMCW -lXvMC -lXv -lX11
+
+#############################################
+
+.PHONY: default clean
+
+default: test_context test_surface test_subpicture test_blocks test_rendering xvmc_bench
+
+test_context: test_context.o testlib.o
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+test_surface: test_surface.o testlib.o
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+test_subpicture: test_subpicture.o testlib.o
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+test_blocks: test_blocks.o testlib.o
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+test_rendering: test_rendering.o testlib.o
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+xvmc_bench: xvmc_bench.o testlib.o
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+clean:
+       $(RM) -rf *.o test_context test_surface test_subpicture test_blocks test_rendering xvmc_bench
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_blocks.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_blocks.c
new file mode 100644 (file)
index 0000000..994e3ca
--- /dev/null
@@ -0,0 +1,111 @@
+/**************************************************************************
+ * 
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <error.h>
+#include "testlib.h"
+
+int main(int argc, char **argv)
+{
+       const unsigned int      width = 16, height = 16;
+       const unsigned int      min_required_blocks = 1, min_required_macroblocks = 1;
+       const unsigned int      mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
+
+       Display                 *display;
+       XvPortID                port_num;
+       int                     surface_type_id;
+       unsigned int            is_overlay, intra_unsigned;
+       int                     colorkey;
+       XvMCContext             context;
+       XvMCSurface             surface;
+       XvMCBlockArray          blocks = {0};
+       XvMCMacroBlockArray     macroblocks = {0};
+
+       display = XOpenDisplay(NULL);
+
+       if (!GetPort
+       (
+               display,
+               width,
+               height,
+               XVMC_CHROMA_FORMAT_420,
+               mc_types,
+               2,
+               &port_num,
+               &surface_type_id,
+               &is_overlay,
+               &intra_unsigned
+       ))
+       {
+               XCloseDisplay(display);
+               error(1, 0, "Error, unable to find a good port.\n");
+       }
+
+       if (is_overlay)
+       {
+               Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
+               XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
+       }
+
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);
+       assert(XvMCCreateSurface(display, &context, &surface) == Success);
+
+       /* Test NULL context */
+       assert(XvMCCreateBlocks(display, NULL, 1, &blocks) == XvMCBadContext);
+       /* Test 0 blocks */
+       assert(XvMCCreateBlocks(display, &context, 0, &blocks) == BadValue);
+       /* Test valid params */
+       assert(XvMCCreateBlocks(display, &context, min_required_blocks, &blocks) == Success);
+       /* Test context id assigned and correct */
+       assert(blocks.context_id == context.context_id);
+       /* Test number of blocks assigned and correct */
+       assert(blocks.num_blocks == min_required_blocks);
+       /* Test block pointer valid */
+       assert(blocks.blocks != NULL);
+       /* Test NULL context */
+       assert(XvMCCreateMacroBlocks(display, NULL, 1, &macroblocks) == XvMCBadContext);
+       /* Test 0 macroblocks */
+       assert(XvMCCreateMacroBlocks(display, &context, 0, &macroblocks) == BadValue);
+       /* Test valid params */
+       assert(XvMCCreateMacroBlocks(display, &context, min_required_macroblocks, &macroblocks) == Success);
+       /* Test context id assigned and correct */
+       assert(macroblocks.context_id == context.context_id);
+       /* Test macroblock pointer valid */
+       assert(macroblocks.macro_blocks != NULL);
+       /* Test valid params */
+       assert(XvMCDestroyMacroBlocks(display, &macroblocks) == Success);
+       /* Test valid params */
+       assert(XvMCDestroyBlocks(display, &blocks) == Success);
+
+       assert(XvMCDestroySurface(display, &surface) == Success);
+       assert(XvMCDestroyContext(display, &context) == Success);
+
+       XvUngrabPort(display, port_num, CurrentTime);
+       XCloseDisplay(display);
+
+       return 0;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_context.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_context.c
new file mode 100644 (file)
index 0000000..3da957c
--- /dev/null
@@ -0,0 +1,119 @@
+/**************************************************************************
+ * 
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <error.h>
+#include "testlib.h"
+
+int main(int argc, char **argv)
+{
+       const unsigned int      width = 16, height = 16;
+       const unsigned int      mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
+
+       Display                 *display;
+       XvPortID                port_num;
+       int                     surface_type_id;
+       unsigned int            is_overlay, intra_unsigned;
+       int                     colorkey;
+       XvMCContext             context = {0};
+
+       display = XOpenDisplay(NULL);
+
+       if (!GetPort
+       (
+               display,
+               width,
+               height,
+               XVMC_CHROMA_FORMAT_420,
+               mc_types,
+               2,
+               &port_num,
+               &surface_type_id,
+               &is_overlay,
+               &intra_unsigned
+       ))
+       {
+               XCloseDisplay(display);
+               error(1, 0, "Error, unable to find a good port.\n");
+       }
+
+       if (is_overlay)
+       {
+               Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
+               XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
+       }
+
+       /* Test NULL context */
+       /* XXX: XvMCBadContext not a valid return for XvMCCreateContext in the XvMC API, but openChrome driver returns it */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, NULL) == XvMCBadContext);
+       /* Test invalid port */
+       /* XXX: Success and XvBadPort have the same value, if this call actually gets passed the validation step as of now we'll crash later */
+       assert(XvMCCreateContext(display, -1, surface_type_id, width, height, XVMC_DIRECT, &context) == XvBadPort);
+       /* Test invalid surface */
+       assert(XvMCCreateContext(display, port_num, -1, width, height, XVMC_DIRECT, &context) == BadMatch);
+       /* Test invalid flags */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, -1, &context) == BadValue);
+       /* Test huge width */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, 16384, height, XVMC_DIRECT, &context) == BadValue);
+       /* Test huge height */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width, 16384, XVMC_DIRECT, &context) == BadValue);
+       /* Test huge width & height */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, 16384, 16384, XVMC_DIRECT, &context) == BadValue);
+       /* Test valid params */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);
+       /* Test context id assigned */
+       assert(context.context_id != 0);
+       /* Test surface type id assigned and correct */
+       assert(context.surface_type_id == surface_type_id);
+       /* Test width & height assigned and correct */
+       assert(context.width == width && context.height == height);
+       /* Test port assigned and correct */
+       assert(context.port == port_num);
+       /* Test flags assigned and correct */
+       assert(context.flags == XVMC_DIRECT);
+       /* Test NULL context */
+       assert(XvMCDestroyContext(display, NULL) == XvMCBadContext);
+       /* Test valid params */
+       assert(XvMCDestroyContext(display, &context) == Success);
+       /* Test awkward but valid width */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width + 1, height, XVMC_DIRECT, &context) == Success);
+       assert(context.width >= width + 1);
+       assert(XvMCDestroyContext(display, &context) == Success);
+       /* Test awkward but valid height */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width, height + 1, XVMC_DIRECT, &context) == Success);
+       assert(context.height >= height + 1);
+       assert(XvMCDestroyContext(display, &context) == Success);
+       /* Test awkward but valid width & height */
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width + 1, height + 1, XVMC_DIRECT, &context) == Success);
+       assert(context.width >= width + 1 && context.height >= height + 1);
+       assert(XvMCDestroyContext(display, &context) == Success);
+
+       XvUngrabPort(display, port_num, CurrentTime);
+       XCloseDisplay(display);
+
+       return 0;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_rendering.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_rendering.c
new file mode 100644 (file)
index 0000000..6058783
--- /dev/null
@@ -0,0 +1,317 @@
+/**************************************************************************
+ * 
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdio.h>
+#include <string.h>
+#include <error.h>
+#include "testlib.h"
+
+#define BLOCK_WIDTH                    8
+#define BLOCK_HEIGHT                   8
+#define BLOCK_SIZE                     (BLOCK_WIDTH * BLOCK_HEIGHT)
+#define MACROBLOCK_WIDTH               16
+#define MACROBLOCK_HEIGHT              16
+#define MACROBLOCK_WIDTH_IN_BLOCKS     (MACROBLOCK_WIDTH / BLOCK_WIDTH)
+#define MACROBLOCK_HEIGHT_IN_BLOCKS    (MACROBLOCK_HEIGHT / BLOCK_HEIGHT)
+#define BLOCKS_PER_MACROBLOCK          6
+
+#define INPUT_WIDTH                    16
+#define INPUT_HEIGHT                   16
+#define INPUT_WIDTH_IN_MACROBLOCKS     (INPUT_WIDTH / MACROBLOCK_WIDTH)
+#define INPUT_HEIGHT_IN_MACROBLOCKS    (INPUT_HEIGHT / MACROBLOCK_HEIGHT)
+#define NUM_MACROBLOCKS                        (INPUT_WIDTH_IN_MACROBLOCKS * INPUT_HEIGHT_IN_MACROBLOCKS)
+
+#define DEFAULT_OUTPUT_WIDTH           INPUT_WIDTH
+#define DEFAULT_OUTPUT_HEIGHT          INPUT_HEIGHT
+#define DEFAULT_ACCEPTABLE_ERR         0.01
+
+void ParseArgs(int argc, char **argv, unsigned int *output_width, unsigned int *output_height, double *acceptable_error, int *prompt);
+void Gradient(short *block, unsigned int start, unsigned int stop, int horizontal);
+
+void ParseArgs(int argc, char **argv, unsigned int *output_width, unsigned int *output_height, double *acceptable_error, int *prompt)
+{
+       int fail = 0;
+       int i;
+
+       *output_width = DEFAULT_OUTPUT_WIDTH;
+       *output_height = DEFAULT_OUTPUT_WIDTH;
+       *acceptable_error = DEFAULT_ACCEPTABLE_ERR;
+       *prompt = 1;
+
+       for (i = 1; i < argc && !fail; ++i)
+       {
+               if (!strcmp(argv[i], "-w"))
+               {
+                       if (sscanf(argv[++i], "%u", output_width) != 1)
+                               fail = 1;
+               }
+               else if (!strcmp(argv[i], "-h"))
+               {
+                       if (sscanf(argv[++i], "%u", output_height) != 1)
+                               fail = 1;
+               }
+               else if (!strcmp(argv[i], "-e"))
+               {
+                       if (sscanf(argv[++i], "%lf", acceptable_error) != 1)
+                               fail = 1;
+               }
+               else if (strcmp(argv[i], "-n"))
+                       *prompt = 0;
+               else
+                       fail = 1;
+       }
+
+       if (fail)
+               error
+               (
+                       1, 0,
+                       "Bad argument.\n"
+                       "\n"
+                       "Usage: %s [options]\n"
+                       "\t-w <width>\tOutput width\n"
+                       "\t-h <height>\tOutput height\n"
+                       "\t-e <error>\tAcceptable margin of error per pixel, from 0 to 1\n"
+                       "\t-n\tDon't prompt for quit\n",
+                       argv[0]
+               );
+}
+
+void Gradient(short *block, unsigned int start, unsigned int stop, int horizontal)
+{
+       unsigned int x, y;
+       unsigned int range = stop - start;
+
+       if (horizontal)
+       {
+               for (y = 0; y < BLOCK_HEIGHT; ++y)
+                       for (x = 0; x < BLOCK_WIDTH; ++x)
+                               block[y * BLOCK_WIDTH + x] = (short)(start + range * (x / (float)(BLOCK_WIDTH - 1)));
+       }
+       else
+       {
+               for (y = 0; y < BLOCK_HEIGHT; ++y)
+                       for (x = 0; x < BLOCK_WIDTH; ++x)
+                               block[y * BLOCK_WIDTH + x] = (short)(start + range * (y / (float)(BLOCK_HEIGHT - 1)));
+       }
+}
+
+int main(int argc, char **argv)
+{
+       unsigned int            output_width;
+       unsigned int            output_height;
+       double                  acceptable_error;
+       int                     prompt;
+       Display                 *display;
+       Window                  root, window;
+       const unsigned int      mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
+       XvPortID                port_num;
+       int                     surface_type_id;
+       unsigned int            is_overlay, intra_unsigned;
+       int                     colorkey;
+       XvMCContext             context;
+       XvMCSurface             surface;
+       XvMCBlockArray          block_array;
+       XvMCMacroBlockArray     mb_array;
+       int                     mbx, mby, bx, by;
+       XvMCMacroBlock          *mb;
+       short                   *blocks;
+       int                     quit = 0;
+
+       ParseArgs(argc, argv, &output_width, &output_height, &acceptable_error, &prompt);
+
+       display = XOpenDisplay(NULL);
+
+       if (!GetPort
+       (
+               display,
+               INPUT_WIDTH,
+               INPUT_HEIGHT,
+               XVMC_CHROMA_FORMAT_420,
+               mc_types,
+               2,
+               &port_num,
+               &surface_type_id,
+               &is_overlay,
+               &intra_unsigned
+       ))
+       {
+               XCloseDisplay(display);
+               error(1, 0, "Error, unable to find a good port.\n");
+       }
+
+       if (is_overlay)
+       {
+               Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
+               XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
+       }
+
+       root = XDefaultRootWindow(display);
+       window = XCreateSimpleWindow(display, root, 0, 0, output_width, output_height, 0, 0, colorkey);
+
+       assert(XvMCCreateContext(display, port_num, surface_type_id, INPUT_WIDTH, INPUT_HEIGHT, XVMC_DIRECT, &context) == Success);
+       assert(XvMCCreateSurface(display, &context, &surface) == Success);
+       assert(XvMCCreateBlocks(display, &context, NUM_MACROBLOCKS * BLOCKS_PER_MACROBLOCK, &block_array) == Success);
+       assert(XvMCCreateMacroBlocks(display, &context, NUM_MACROBLOCKS, &mb_array) == Success);
+
+       mb = mb_array.macro_blocks;
+       blocks = block_array.blocks;
+
+       for (mby = 0; mby < INPUT_HEIGHT_IN_MACROBLOCKS; ++mby)
+               for (mbx = 0; mbx < INPUT_WIDTH_IN_MACROBLOCKS; ++mbx)
+               {
+                       mb->x = mbx;
+                       mb->y = mby;
+                       mb->macroblock_type = XVMC_MB_TYPE_INTRA;
+                       /*mb->motion_type = ;*/
+                       /*mb->motion_vertical_field_select = ;*/
+                       mb->dct_type = XVMC_DCT_TYPE_FRAME;
+                       /*mb->PMV[0][0][0] = ;
+                       mb->PMV[0][0][1] = ;
+                       mb->PMV[0][1][0] = ;
+                       mb->PMV[0][1][1] = ;
+                       mb->PMV[1][0][0] = ;
+                       mb->PMV[1][0][1] = ;
+                       mb->PMV[1][1][0] = ;
+                       mb->PMV[1][1][1] = ;*/
+                       mb->index = (mby * INPUT_WIDTH_IN_MACROBLOCKS + mbx) * BLOCKS_PER_MACROBLOCK;
+                       mb->coded_block_pattern = 0x3F;
+
+                       mb++;
+
+                       for (by = 0; by < MACROBLOCK_HEIGHT_IN_BLOCKS; ++by)
+                               for (bx = 0; bx < MACROBLOCK_WIDTH_IN_BLOCKS; ++bx)
+                               {
+                                       const int start = 16, stop = 235, range = stop - start;
+
+                                       Gradient
+                                       (
+                                               blocks,
+                                               (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))),
+                                               (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))),
+                                               1
+                                       );
+
+                                       blocks += BLOCK_SIZE;
+                               }
+
+                       for (by = 0; by < MACROBLOCK_HEIGHT_IN_BLOCKS / 2; ++by)
+                               for (bx = 0; bx < MACROBLOCK_WIDTH_IN_BLOCKS / 2; ++bx)
+                               {
+                                       const int start = 16, stop = 240, range = stop - start;
+
+                                       Gradient
+                                       (
+                                               blocks,
+                                               (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))),
+                                               (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))),
+                                               1
+                                       );
+
+                                       blocks += BLOCK_SIZE;
+
+                                       Gradient
+                                       (
+                                               blocks,
+                                               (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))),
+                                               (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))),
+                                               1
+                                       );
+
+                                       blocks += BLOCK_SIZE;
+                               }
+               }
+
+       XSelectInput(display, window, ExposureMask | KeyPressMask);
+       XMapWindow(display, window);
+       XSync(display, 0);
+
+       /* Test NULL context */
+       assert(XvMCRenderSurface(display, NULL, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == XvMCBadContext);
+       /* Test NULL surface */
+       assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, NULL, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == XvMCBadSurface);
+       /* Test bad picture structure */
+       assert(XvMCRenderSurface(display, &context, 0, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == BadValue);
+       /* Test valid params */
+       assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == Success);
+
+       /* Test NULL surface */
+       assert(XvMCPutSurface(display, NULL, window, 0, 0, INPUT_WIDTH, INPUT_HEIGHT, 0, 0, output_width, output_height, XVMC_FRAME_PICTURE) == XvMCBadSurface);
+       /* Test bad window */
+       /* XXX: X halts with a bad drawable for some reason, doesn't return BadDrawable as expected */
+       /*assert(XvMCPutSurface(display, &surface, 0, 0, 0, width, height, 0, 0, width, height, XVMC_FRAME_PICTURE) == BadDrawable);*/
+
+       if (prompt)
+       {
+               puts("Press any button to quit...");
+
+               while (!quit)
+               {
+                       if (XPending(display) > 0)
+                       {
+                               XEvent event;
+
+                               XNextEvent(display, &event);
+
+                               switch (event.type)
+                               {
+                                       case Expose:
+                                       {
+                                               /* Test valid params */
+                                               assert
+                                               (
+                                                       XvMCPutSurface
+                                                       (
+                                                               display, &surface, window,
+                                                               0, 0, INPUT_WIDTH, INPUT_HEIGHT,
+                                                               0, 0, output_width, output_height,
+                                                               XVMC_FRAME_PICTURE
+                                                       ) == Success
+                                               );
+                                               break;
+                                       }
+                                       case KeyPress:
+                                       {
+                                               quit = 1;
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       assert(XvMCDestroyBlocks(display, &block_array) == Success);
+       assert(XvMCDestroyMacroBlocks(display, &mb_array) == Success);
+       assert(XvMCDestroySurface(display, &surface) == Success);
+       assert(XvMCDestroyContext(display, &context) == Success);
+
+       XvUngrabPort(display, port_num, CurrentTime);
+       XDestroyWindow(display, window);
+       XCloseDisplay(display);
+
+       return 0;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_subpicture.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_subpicture.c
new file mode 100644 (file)
index 0000000..20d0907
--- /dev/null
@@ -0,0 +1,182 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <error.h>
+#include <stdio.h>
+#include "testlib.h"
+
+static void PrintGUID(const char *guid)
+{
+       int i;
+       printf("\tguid: ");
+       for (i = 0; i < 4; ++i)
+               printf("%C,", guid[i] == 0 ? '0' : guid[i]);
+       for (; i < 15; ++i)
+               printf("%x,", (unsigned char)guid[i]);
+       printf("%x\n", (unsigned int)guid[15]);
+}
+
+static void PrintComponentOrder(const char *co)
+{
+       int i;
+       printf("\tcomponent_order:\n\t   ");
+       for (i = 0; i < 4; ++i)
+               printf("%C,", co[i] == 0 ? '0' : co[i]);
+       for (; i < 31; ++i)
+               printf("%x,", (unsigned int)co[i]);
+       printf("%x\n", (unsigned int)co[31]);
+}
+
+int main(int argc, char **argv)
+{
+       const unsigned int      width = 16, height = 16;
+       const unsigned int      mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
+       const unsigned int      subpic_width = 16, subpic_height = 16;
+
+       Display                 *display;
+       XvPortID                port_num;
+       int                     surface_type_id;
+       unsigned int            is_overlay, intra_unsigned;
+       int                     colorkey;
+       XvMCContext             context;
+       XvImageFormatValues     *subpics;
+       int                     num_subpics;
+       XvMCSubpicture          subpicture = {0};
+       int                     i;
+
+       display = XOpenDisplay(NULL);
+
+       if (!GetPort
+       (
+               display,
+               width,
+               height,
+               XVMC_CHROMA_FORMAT_420,
+               mc_types,
+               2,
+               &port_num,
+               &surface_type_id,
+               &is_overlay,
+               &intra_unsigned
+       ))
+       {
+               XCloseDisplay(display);
+               error(1, 0, "Error, unable to find a good port.\n");
+       }
+
+       if (is_overlay)
+       {
+               Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
+               XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
+       }
+
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);
+       
+       subpics = XvMCListSubpictureTypes(display, port_num, surface_type_id, &num_subpics);
+       assert((subpics && num_subpics) > 0 || (!subpics && num_subpics == 0));
+       
+       for (i = 0; i < num_subpics; ++i)
+       {
+               printf("Subpicture %d:\n", i);
+               printf("\tid: 0x%08x\n", subpics[i].id);
+               printf("\ttype: %s\n", subpics[i].type == XvRGB ? "XvRGB" : (subpics[i].type == XvYUV ? "XvYUV" : "Unknown"));
+               printf("\tbyte_order: %s\n", subpics[i].byte_order == LSBFirst ? "LSB First" : (subpics[i].byte_order == MSBFirst ? "MSB First" : "Unknown"));
+               PrintGUID(subpics[i].guid);
+               printf("\tbpp: %u\n", subpics[i].bits_per_pixel);
+               printf("\tformat: %s\n", subpics[i].format == XvPacked ? "XvPacked" : (subpics[i].format == XvPlanar ? "XvPlanar" : "Unknown"));
+               printf("\tnum_planes: %u\n", subpics[i].num_planes);
+               
+               if (subpics[i].type == XvRGB)
+               {
+                       printf("\tdepth: %u\n", subpics[i].depth);
+                       printf("\tred_mask: 0x%08x\n", subpics[i].red_mask);
+                       printf("\tgreen_mask: 0x%08x\n", subpics[i].green_mask);
+                       printf("\tblue_mask: 0x%08x\n", subpics[i].blue_mask);
+               }
+               else if (subpics[i].type == XvYUV)
+               {
+                       printf("\ty_sample_bits: %u\n", subpics[i].y_sample_bits);
+                       printf("\tu_sample_bits: %u\n", subpics[i].u_sample_bits);
+                       printf("\tv_sample_bits: %u\n", subpics[i].v_sample_bits);
+                       printf("\thorz_y_period: %u\n", subpics[i].horz_y_period);
+                       printf("\thorz_u_period: %u\n", subpics[i].horz_u_period);
+                       printf("\thorz_v_period: %u\n", subpics[i].horz_v_period);
+                       printf("\tvert_y_period: %u\n", subpics[i].vert_y_period);
+                       printf("\tvert_u_period: %u\n", subpics[i].vert_u_period);
+                       printf("\tvert_v_period: %u\n", subpics[i].vert_v_period);
+               }
+               PrintComponentOrder(subpics[i].component_order);
+               printf("\tscanline_order: %s\n", subpics[i].scanline_order == XvTopToBottom ? "XvTopToBottom" : (subpics[i].scanline_order == XvBottomToTop ? "XvBottomToTop" : "Unknown"));
+       }
+       
+       if (num_subpics == 0)
+       {
+               printf("Subpictures not supported, nothing to test.\n");
+               return 0;
+       }
+
+       /* Test NULL context */
+       assert(XvMCCreateSubpicture(display, NULL, &subpicture, subpic_width, subpic_height, subpics[0].id) == XvMCBadContext);
+       /* Test NULL subpicture */
+       assert(XvMCCreateSubpicture(display, &context, NULL, subpic_width, subpic_height, subpics[0].id) == XvMCBadSubpicture);
+       /* Test invalid subpicture */
+       assert(XvMCCreateSubpicture(display, &context, &subpicture, subpic_width, subpic_height, -1) == BadMatch);
+       /* Test huge width */
+       assert(XvMCCreateSubpicture(display, &context, &subpicture, 16384, subpic_height, subpics[0].id) == BadValue);
+       /* Test huge height */
+       assert(XvMCCreateSubpicture(display, &context, &subpicture, subpic_width, 16384, subpics[0].id) == BadValue);
+       /* Test huge width & height */
+       assert(XvMCCreateSubpicture(display, &context, &subpicture, 16384, 16384, subpics[0].id) == BadValue);
+       for (i = 0; i < num_subpics; ++i)
+       {
+               /* Test valid params */
+               assert(XvMCCreateSubpicture(display, &context, &subpicture, subpic_width, subpic_height, subpics[i].id) == Success);
+               /* Test subpicture id assigned */
+               assert(subpicture.subpicture_id != 0);
+               /* Test context id assigned and correct */
+               assert(subpicture.context_id == context.context_id);
+               /* Test subpicture type id assigned and correct */
+               assert(subpicture.xvimage_id == subpics[i].id);
+               /* Test width & height assigned and correct */
+               assert(subpicture.width == width && subpicture.height == height);
+               /* Test no palette support */
+               assert(subpicture.num_palette_entries == 0 && subpicture.entry_bytes == 0);
+               /* Test valid params */
+               assert(XvMCDestroySubpicture(display, &subpicture) == Success);
+       }
+       /* Test NULL surface */
+       assert(XvMCDestroySubpicture(display, NULL) == XvMCBadSubpicture);
+
+       assert(XvMCDestroyContext(display, &context) == Success);
+
+       XFree(subpics);
+       XvUngrabPort(display, port_num, CurrentTime);
+       XCloseDisplay(display);
+
+       return 0;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_surface.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_surface.c
new file mode 100644 (file)
index 0000000..b65eb26
--- /dev/null
@@ -0,0 +1,98 @@
+/**************************************************************************
+ * 
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <error.h>
+#include "testlib.h"
+
+int main(int argc, char **argv)
+{
+       const unsigned int      width = 16, height = 16;
+       const unsigned int      mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
+
+       Display                 *display;
+       XvPortID                port_num;
+       int                     surface_type_id;
+       unsigned int            is_overlay, intra_unsigned;
+       int                     colorkey;
+       XvMCContext             context;
+       XvMCSurface             surface = {0};
+
+       display = XOpenDisplay(NULL);
+
+       if (!GetPort
+       (
+               display,
+               width,
+               height,
+               XVMC_CHROMA_FORMAT_420,
+               mc_types,
+               2,
+               &port_num,
+               &surface_type_id,
+               &is_overlay,
+               &intra_unsigned
+       ))
+       {
+               XCloseDisplay(display);
+               error(1, 0, "Error, unable to find a good port.\n");
+       }
+
+       if (is_overlay)
+       {
+               Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
+               XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
+       }
+
+       assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);
+
+       /* Test NULL context */
+       assert(XvMCCreateSurface(display, NULL, &surface) == XvMCBadContext);
+       /* Test NULL surface */
+       assert(XvMCCreateSurface(display, &context, NULL) == XvMCBadSurface);
+       /* Test valid params */
+       assert(XvMCCreateSurface(display, &context, &surface) == Success);
+       /* Test surface id assigned */
+       assert(surface.surface_id != 0);
+       /* Test context id assigned and correct */
+       assert(surface.context_id == context.context_id);
+       /* Test surface type id assigned and correct */
+       assert(surface.surface_type_id == surface_type_id);
+       /* Test width & height assigned and correct */
+       assert(surface.width == width && surface.height == height);
+       /* Test valid params */
+       assert(XvMCDestroySurface(display, &surface) == Success);
+       /* Test NULL surface */
+       assert(XvMCDestroySurface(display, NULL) == XvMCBadSurface);
+
+       assert(XvMCDestroyContext(display, &context) == Success);
+
+       XvUngrabPort(display, port_num, CurrentTime);
+       XCloseDisplay(display);
+
+       return 0;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/testlib.c b/src/gallium/state_trackers/xorg/xvmc/tests/testlib.c
new file mode 100644 (file)
index 0000000..142c09b
--- /dev/null
@@ -0,0 +1,146 @@
+/**************************************************************************
+ * 
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "testlib.h"
+#include <stdio.h>
+
+/*
+void test(int pred, const char *pred_string, const char *doc_string, const char *file, unsigned int line)
+{
+       fputs(doc_string, stderr);
+       if (!pred)
+               fprintf(stderr, " FAIL!\n\t\"%s\" at %s:%u\n", pred_string, file, line);
+       else
+               fputs(" PASS!\n", stderr);
+}
+*/
+
+int GetPort
+(
+       Display *display,
+       unsigned int width,
+       unsigned int height,
+       unsigned int chroma_format,
+       const unsigned int *mc_types,
+       unsigned int num_mc_types,
+       XvPortID *port_id,
+       int *surface_type_id,
+       unsigned int *is_overlay,
+       unsigned int *intra_unsigned
+)
+{
+       unsigned int    found_port = 0;
+       XvAdaptorInfo   *adaptor_info;
+       unsigned int    num_adaptors;
+       int             num_types;
+       int             ev_base, err_base;
+       unsigned int    i, j, k, l;
+
+       if (!XvMCQueryExtension(display, &ev_base, &err_base))
+               return 0;
+       if (XvQueryAdaptors(display, XDefaultRootWindow(display), &num_adaptors, &adaptor_info) != Success)
+               return 0;
+
+       for (i = 0; i < num_adaptors && !found_port; ++i)
+       {
+               if (adaptor_info[i].type & XvImageMask)
+               {
+                       XvMCSurfaceInfo *surface_info = XvMCListSurfaceTypes(display, adaptor_info[i].base_id, &num_types);
+
+                       if (surface_info)
+                       {
+                               for (j = 0; j < num_types && !found_port; ++j)
+                               {
+                                       if
+                                       (
+                                               surface_info[j].chroma_format == chroma_format &&
+                                               surface_info[j].max_width >= width &&
+                                               surface_info[j].max_height >= height
+                                       )
+                                       {
+                                               for (k = 0; k < num_mc_types && !found_port; ++k)
+                                               {
+                                                       if (surface_info[j].mc_type == mc_types[k])
+                                                       {
+                                                               for (l = 0; l < adaptor_info[i].num_ports && !found_port; ++l)
+                                                               {
+                                                                       if (XvGrabPort(display, adaptor_info[i].base_id + l, CurrentTime) == Success)
+                                                                       {
+                                                                               *port_id = adaptor_info[i].base_id + l;
+                                                                               *surface_type_id = surface_info[j].surface_type_id;
+                                                                               *is_overlay = surface_info[j].flags & XVMC_OVERLAID_SURFACE;
+                                                                               *intra_unsigned = surface_info[j].flags & XVMC_INTRA_UNSIGNED;
+                                                                               found_port = 1;
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               XFree(surface_info);
+                       }
+               }
+       }
+
+       XvFreeAdaptorInfo(adaptor_info);
+
+       return found_port;
+}
+
+unsigned int align(unsigned int value, unsigned int alignment)
+{
+       return (value + alignment - 1) & ~(alignment - 1);
+}
+
+/* From the glibc manual */
+int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
+{
+       /* Perform the carry for the later subtraction by updating y. */
+       if (x->tv_usec < y->tv_usec)
+       {
+               int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
+               y->tv_usec -= 1000000 * nsec;
+               y->tv_sec += nsec;
+       }
+       if (x->tv_usec - y->tv_usec > 1000000)
+       {
+               int nsec = (x->tv_usec - y->tv_usec) / 1000000;
+               y->tv_usec += 1000000 * nsec;
+               y->tv_sec -= nsec;
+       }
+
+       /*
+        * Compute the time remaining to wait.
+        * tv_usec is certainly positive.
+        */
+       result->tv_sec = x->tv_sec - y->tv_sec;
+       result->tv_usec = x->tv_usec - y->tv_usec;
+
+       /* Return 1 if result is negative. */
+       return x->tv_sec < y->tv_sec;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/testlib.h b/src/gallium/state_trackers/xorg/xvmc/tests/testlib.h
new file mode 100644 (file)
index 0000000..0438e52
--- /dev/null
@@ -0,0 +1,69 @@
+/**************************************************************************
+ * 
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 testlib_h
+#define testlib_h
+
+/*
+#define TEST(pred, doc)        test(pred, #pred, doc, __FILE__, __LINE__)
+
+void test(int pred, const char *pred_string, const char *doc_string, const char *file, unsigned int line);
+*/
+
+#include <sys/time.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XvMClib.h>
+
+/*
+ * display: IN                 A valid X display
+ * width, height: IN           Surface size that the port must display
+ * chroma_format: IN           Chroma format that the port must display
+ * mc_types, num_mc_types: IN  List of MC types that the port must support, first port that matches the first mc_type will be returned
+ * port_id: OUT                        Your port's ID
+ * surface_type_id: OUT                Your port's surface ID
+ * is_overlay: OUT             If 1, port uses overlay surfaces, you need to set a colorkey
+ * intra_unsigned: OUT         If 1, port uses unsigned values for intra-coded blocks
+ */
+int GetPort
+(
+       Display *display,
+       unsigned int width,
+       unsigned int height,
+       unsigned int chroma_format,
+       const unsigned int *mc_types,
+       unsigned int num_mc_types,
+       XvPortID *port_id,
+       int *surface_type_id,
+       unsigned int *is_overlay,
+       unsigned int *intra_unsigned
+);
+
+unsigned int align(unsigned int value, unsigned int alignment);
+
+int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
+
+#endif
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/xvmc_bench.c b/src/gallium/state_trackers/xorg/xvmc/tests/xvmc_bench.c
new file mode 100644 (file)
index 0000000..bf94d85
--- /dev/null
@@ -0,0 +1,300 @@
+/**************************************************************************
+ * 
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdio.h>
+#include <string.h>
+#include <error.h>
+#include <sys/time.h>
+#include "testlib.h"
+
+#define MACROBLOCK_WIDTH               16
+#define MACROBLOCK_HEIGHT              16
+#define BLOCKS_PER_MACROBLOCK          6
+
+#define DEFAULT_INPUT_WIDTH            720
+#define DEFAULT_INPUT_HEIGHT           480
+#define DEFAULT_REPS                   100
+
+#define PIPELINE_STEP_MC               1
+#define PIPELINE_STEP_CSC              2
+#define PIPELINE_STEP_SWAP             4
+
+#define MB_TYPE_I                      1
+#define MB_TYPE_P                      2
+#define MB_TYPE_B                      4
+
+struct Config
+{
+       unsigned int input_width;
+       unsigned int input_height;
+       unsigned int output_width;
+       unsigned int output_height;
+       unsigned int pipeline;
+       unsigned int mb_types;
+       unsigned int reps;
+};
+
+void ParseArgs(int argc, char **argv, struct Config *config);
+
+void ParseArgs(int argc, char **argv, struct Config *config)
+{
+       int fail = 0;
+       int i;
+
+       config->input_width = DEFAULT_INPUT_WIDTH;
+       config->input_height = DEFAULT_INPUT_HEIGHT;
+       config->output_width = 0;
+       config->output_height = 0;
+       config->pipeline = 0;
+       config->mb_types = 0;
+       config->reps = DEFAULT_REPS;
+
+       for (i = 1; i < argc && !fail; ++i)
+       {
+               if (!strcmp(argv[i], "-iw"))
+               {
+                       if (sscanf(argv[++i], "%u", &config->input_width) != 1)
+                               fail = 1;
+               }
+               else if (!strcmp(argv[i], "-ih"))
+               {
+                       if (sscanf(argv[++i], "%u", &config->input_height) != 1)
+                               fail = 1;
+               }
+               else if (!strcmp(argv[i], "-ow"))
+               {
+                       if (sscanf(argv[++i], "%u", &config->output_width) != 1)
+                               fail = 1;
+               }
+               else if (!strcmp(argv[i], "-oh"))
+               {
+                       if (sscanf(argv[++i], "%u", &config->output_height) != 1)
+                               fail = 1;
+               }
+               else if (!strcmp(argv[i], "-p"))
+               {
+                       char *token = strtok(argv[++i], ",");
+
+                       while (token && !fail)
+                       {
+                               if (!strcmp(token, "mc"))
+                                       config->pipeline |= PIPELINE_STEP_MC;
+                               else if (!strcmp(token, "csc"))
+                                       config->pipeline |= PIPELINE_STEP_CSC;
+                               else if (!strcmp(token, "swp"))
+                                       config->pipeline |= PIPELINE_STEP_SWAP;
+                               else
+                                       fail = 1;
+
+                               if (!fail)
+                                       token = strtok(NULL, ",");
+                       }
+               }
+               else if (!strcmp(argv[i], "-mb"))
+               {
+                       char *token = strtok(argv[++i], ",");
+
+                       while (token && !fail)
+                       {
+                               if (strcmp(token, "i"))
+                                       config->mb_types |= MB_TYPE_I;
+                               else if (strcmp(token, "p"))
+                                       config->mb_types |= MB_TYPE_P;
+                               else if (strcmp(token, "b"))
+                                       config->mb_types |= MB_TYPE_B;
+                               else
+                                       fail = 1;
+
+                               if (!fail)
+                                       token = strtok(NULL, ",");
+                       }
+               }
+               else if (!strcmp(argv[i], "-r"))
+               {
+                       if (sscanf(argv[++i], "%u", &config->reps) != 1)
+                               fail = 1;
+               }
+               else
+                       fail = 1;
+       }
+
+       if (fail)
+               error
+               (
+                       1, 0,
+                       "Bad argument.\n"
+                       "\n"
+                       "Usage: %s [options]\n"
+                       "\t-iw <width>\tInput width\n"
+                       "\t-ih <height>\tInput height\n"
+                       "\t-ow <width>\tOutput width\n"
+                       "\t-oh <height>\tOutput height\n"
+                       "\t-p <pipeline>\tPipeline to test\n"
+                       "\t-mb <mb type>\tMacroBlock types to use\n"
+                       "\t-r <reps>\tRepetitions\n\n"
+                       "\tPipeline steps: mc,csc,swap\n"
+                       "\tMB types: i,p,b\n",
+                       argv[0]
+               );
+
+       if (config->output_width == 0)
+               config->output_width = config->input_width;
+       if (config->output_height == 0)
+               config->output_height = config->input_height;
+       if (!config->pipeline)
+               config->pipeline = PIPELINE_STEP_MC | PIPELINE_STEP_CSC | PIPELINE_STEP_SWAP;
+       if (!config->mb_types)
+               config->mb_types = MB_TYPE_I | MB_TYPE_P | MB_TYPE_B;
+}
+
+int main(int argc, char **argv)
+{
+       struct Config           config;
+       Display                 *display;
+       Window                  root, window;
+       const unsigned int      mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
+       XvPortID                port_num;
+       int                     surface_type_id;
+       unsigned int            is_overlay, intra_unsigned;
+       int                     colorkey;
+       XvMCContext             context;
+       XvMCSurface             surface;
+       XvMCBlockArray          block_array;
+       XvMCMacroBlockArray     mb_array;
+       unsigned int            mbw, mbh;
+       unsigned int            mbx, mby;
+       unsigned int            reps;
+       struct timeval          start, stop, diff;
+       double                  diff_secs;
+
+       ParseArgs(argc, argv, &config);
+
+       mbw = align(config.input_width, MACROBLOCK_WIDTH) / MACROBLOCK_WIDTH;
+       mbh = align(config.input_height, MACROBLOCK_HEIGHT) / MACROBLOCK_HEIGHT;
+
+       display = XOpenDisplay(NULL);
+
+       if (!GetPort
+       (
+               display,
+               config.input_width,
+               config.input_height,
+               XVMC_CHROMA_FORMAT_420,
+               mc_types,
+               2,
+               &port_num,
+               &surface_type_id,
+               &is_overlay,
+               &intra_unsigned
+       ))
+       {
+               XCloseDisplay(display);
+               error(1, 0, "Error, unable to find a good port.\n");
+       }
+
+       if (is_overlay)
+       {
+               Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
+               XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
+       }
+
+       root = XDefaultRootWindow(display);
+       window = XCreateSimpleWindow(display, root, 0, 0, config.output_width, config.output_height, 0, 0, colorkey);
+
+       assert(XvMCCreateContext(display, port_num, surface_type_id, config.input_width, config.input_height, XVMC_DIRECT, &context) == Success);
+       assert(XvMCCreateSurface(display, &context, &surface) == Success);
+       assert(XvMCCreateBlocks(display, &context, mbw * mbh * BLOCKS_PER_MACROBLOCK, &block_array) == Success);
+       assert(XvMCCreateMacroBlocks(display, &context, mbw * mbh, &mb_array) == Success);
+
+       for (mby = 0; mby < mbh; ++mby)
+               for (mbx = 0; mbx < mbw; ++mbx)
+               {
+                       mb_array.macro_blocks[mby * mbw + mbx].x = mbx;
+                       mb_array.macro_blocks[mby * mbw + mbx].y = mby;
+                       mb_array.macro_blocks[mby * mbw + mbx].macroblock_type = XVMC_MB_TYPE_INTRA;
+                       /*mb->motion_type = ;*/
+                       /*mb->motion_vertical_field_select = ;*/
+                       mb_array.macro_blocks[mby * mbw + mbx].dct_type = XVMC_DCT_TYPE_FRAME;
+                       /*mb->PMV[0][0][0] = ;
+                       mb->PMV[0][0][1] = ;
+                       mb->PMV[0][1][0] = ;
+                       mb->PMV[0][1][1] = ;
+                       mb->PMV[1][0][0] = ;
+                       mb->PMV[1][0][1] = ;
+                       mb->PMV[1][1][0] = ;
+                       mb->PMV[1][1][1] = ;*/
+                       mb_array.macro_blocks[mby * mbw + mbx].index = (mby * mbw + mbx) * BLOCKS_PER_MACROBLOCK;
+                       mb_array.macro_blocks[mby * mbw + mbx].coded_block_pattern = 0x3F;
+               }
+
+       XSelectInput(display, window, ExposureMask | KeyPressMask);
+       XMapWindow(display, window);
+       XSync(display, 0);
+
+       gettimeofday(&start, NULL);
+
+       for (reps = 0; reps < config.reps; ++reps)
+       {
+               if (config.pipeline & PIPELINE_STEP_MC)
+               {
+                       assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, mbw * mbh, 0, &mb_array, &block_array) == Success);
+                       assert(XvMCFlushSurface(display, &surface) == Success);
+               }
+               if (config.pipeline & PIPELINE_STEP_CSC)
+                       assert(XvMCPutSurface(display, &surface, window, 0, 0, config.input_width, config.input_height, 0, 0, config.output_width, config.output_height, XVMC_FRAME_PICTURE) == Success);
+       }
+
+       gettimeofday(&stop, NULL);
+
+       timeval_subtract(&diff, &stop, &start);
+       diff_secs = (double)diff.tv_sec + (double)diff.tv_usec / 1000000.0;
+
+       printf("XvMC Benchmark\n");
+       printf("Input: %u,%u\nOutput: %u,%u\n", config.input_width, config.input_height, config.output_width, config.output_height);
+       printf("Pipeline: ");
+       if (config.pipeline & PIPELINE_STEP_MC)
+               printf("|mc|");
+       if (config.pipeline & PIPELINE_STEP_CSC)
+               printf("|csc|");
+       if (config.pipeline & PIPELINE_STEP_SWAP)
+               printf("|swap|");
+       printf("\n");
+       printf("Reps: %u\n", config.reps);
+       printf("Total time: %.2lf (%.2lf reps / sec)\n", diff_secs, config.reps / diff_secs);
+
+       assert(XvMCDestroyBlocks(display, &block_array) == Success);
+       assert(XvMCDestroyMacroBlocks(display, &mb_array) == Success);
+       assert(XvMCDestroySurface(display, &surface) == Success);
+       assert(XvMCDestroyContext(display, &context) == Success);
+
+       XvUngrabPort(display, port_num, CurrentTime);
+       XDestroyWindow(display, window);
+       XCloseDisplay(display);
+
+       return 0;
+}
diff --git a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
new file mode 100644 (file)
index 0000000..5f8d9d1
--- /dev/null
@@ -0,0 +1,139 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 xvmc_private_h
+#define xvmc_private_h
+
+#include <X11/Xlib.h>
+#include <X11/extensions/XvMClib.h>
+
+#include <pipe/p_video_state.h>
+
+#include <util/u_debug.h>
+#include <util/u_math.h>
+
+#include <vl/vl_csc.h>
+#include <vl/vl_compositor.h>
+
+#define BLOCK_SIZE_SAMPLES 64
+#define BLOCK_SIZE_BYTES (BLOCK_SIZE_SAMPLES * 2)
+
+struct vl_context;
+
+struct pipe_video_decoder;
+struct pipe_video_decode_buffer;
+struct pipe_video_buffer;
+
+struct pipe_sampler_view;
+struct pipe_fence_handle;
+
+typedef struct
+{
+   struct vl_context *vctx;
+   struct pipe_video_decoder *decoder;
+
+   enum VL_CSC_COLOR_STANDARD color_standard;
+   struct vl_procamp procamp;
+   struct vl_compositor compositor;
+
+   unsigned short subpicture_max_width;
+   unsigned short subpicture_max_height;
+
+   struct pipe_video_rect dst_rect;
+   struct pipe_surface *drawable_surface;
+
+} XvMCContextPrivate;
+
+typedef struct
+{
+   struct pipe_video_decode_buffer *decode_buffer;
+   struct pipe_video_buffer *video_buffer;
+
+   bool mapped; // are we still mapped to memory?
+
+   struct {
+      unsigned num_blocks_added;
+      struct pipe_ycbcr_block *stream;
+      short *buffer;
+   } ycbcr[3];
+
+   unsigned mv_stride;
+   struct {
+      XvMCSurface *surface;
+      struct pipe_motionvector *mv;
+   } ref[2];
+
+   struct pipe_fence_handle *fence;
+
+   /* The subpicture associated with this surface, if any. */
+   XvMCSubpicture *subpicture;
+
+   /* Some XvMC functions take a surface but not a context,
+      so we keep track of which context each surface belongs to. */
+   XvMCContext *context;
+} XvMCSurfacePrivate;
+
+typedef struct
+{
+   struct pipe_sampler_view *sampler;
+
+   /* optional palette for this subpicture */
+   struct pipe_sampler_view *palette;
+
+   struct pipe_video_rect src_rect;
+   struct pipe_video_rect dst_rect;
+
+   /* The surface this subpicture is currently associated with, if any. */
+   XvMCSurface *surface;
+
+   /* Some XvMC functions take a subpicture but not a context,
+      so we keep track of which context each subpicture belongs to. */
+   XvMCContext *context;
+} XvMCSubpicturePrivate;
+
+#define XVMC_OUT   0
+#define XVMC_ERR   1
+#define XVMC_WARN  2
+#define XVMC_TRACE 3
+
+static INLINE void XVMC_MSG(unsigned int level, const char *fmt, ...)
+{
+   static int debug_level = -1;
+
+   if (debug_level == -1) {
+      debug_level = MAX2(debug_get_num_option("XVMC_DEBUG", 0), 0);
+   }
+
+   if (level <= debug_level) {
+      va_list ap;
+      va_start(ap, fmt);
+      _debug_vprintf(fmt, ap);
+      va_end(ap);
+   }
+}
+
+#endif /* xvmc_private_h */
index 6c6ad18..857ebfe 100644 (file)
@@ -2,7 +2,6 @@
 
 
 ifeq ($(MESA_LLVM),1)
-PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
 LDFLAGS += $(LLVM_LDFLAGS)
 DRIVER_EXTRAS = $(LLVM_LIBS)
 else
diff --git a/src/gallium/targets/Makefile.va b/src/gallium/targets/Makefile.va
new file mode 100644 (file)
index 0000000..7ced430
--- /dev/null
@@ -0,0 +1,69 @@
+# This makefile template is used to build "driver"_drv_video.so
+
+LIBNAME = lib$(LIBBASENAME).so
+VA_LIB_GLOB= lib$(LIBBASENAME).*so*
+VA_MAJOR = 0
+VA_MINOR = 3
+INCLUDES = -I$(TOP)/src/gallium/include \
+          -I$(TOP)/src/gallium/drivers \
+          -I$(TOP)/src/gallium/auxiliary \
+          -I$(TOP)/src/gallium/winsys \
+          -I$(TOP)/src/gallium/winsys/g3dvl \
+          $(DRIVER_INCLUDES)
+DEFINES = -DGALLIUM_TRACE -DVER_MAJOR=$(VA_MAJOR) -DVER_MINOR=$(VA_MINOR) $(DRIVER_DEFINES)
+LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lva -lXext -lX11 -lm
+STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/va/libvatracker.a
+
+ifeq ($(MESA_LLVM),1)
+LDFLAGS += $(LLVM_LDFLAGS)
+DRIVER_EXTRAS = $(LLVM_LIBS)
+else
+LDFLAGS += -lstdc++
+endif
+
+# XXX: Hack, VA public funcs aren't exported
+OBJECTS = $(C_SOURCES:.c=.o) \
+         $(ASM_SOURCES:.S=.o) \
+         $(TOP)/src/gallium/state_trackers/va/*.o
+
+##### RULES #####
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+##### TARGETS #####
+
+default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
+
+$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(OBJECTS) $(PIPE_DRIVERS) $(STATE_TRACKER_LIB) $(TOP)/$(LIB_DIR)/gallium Makefile
+       $(MKLIB) -o $(LIBBASENAME) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               -major $(VA_MAJOR) -minor $(VA_MINOR) $(MKLIB_OPTIONS) \
+               -install $(TOP)/$(LIB_DIR)/gallium \
+               $(OBJECTS) $(STATE_TRACKER_LIB) $(PIPE_DRIVERS) $(LIBS) $(DRIVER_EXTRAS)
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDES) $(C_SOURCES) \
+               $(ASM_SOURCES) 2> /dev/null
+
+# Emacs tags
+tags:
+       etags `find . -name \*.[ch]` `find ../include`
+
+# Remove .o and backup files
+clean:
+       -rm -f *.o *~ *.so $(SYMLINKS)
+       -rm -f depend depend.bak
+
+install: default
+       $(INSTALL) -d $(DESTDIR)$(VA_LIB_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(VA_LIB_GLOB) $(DESTDIR)$(VA_LIB_INSTALL_DIR)
+
+include depend
diff --git a/src/gallium/targets/Makefile.vdpau b/src/gallium/targets/Makefile.vdpau
new file mode 100644 (file)
index 0000000..c0937ff
--- /dev/null
@@ -0,0 +1,69 @@
+# This makefile template is used to build libvdpau_g3dvl.so
+
+LIBNAME = lib$(LIBBASENAME).so
+VDPAU_LIB_GLOB=lib$(LIBBASENAME).*so*
+VDPAU_MAJOR = 1
+VDPAU_MINOR = 0
+INCLUDES = -I$(TOP)/src/gallium/include \
+          -I$(TOP)/src/gallium/drivers \
+          -I$(TOP)/src/gallium/auxiliary \
+          -I$(TOP)/src/gallium/winsys \
+          -I$(TOP)/src/gallium/winsys/g3dvl \
+          $(DRIVER_INCLUDES)
+DEFINES = -DGALLIUM_TRACE -DVER_MAJOR=$(VDPAU_MAJOR) -DVER_MINOR=$(VDPAU_MINOR) $(DRIVER_DEFINES)
+LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lvdpau -lXext -lX11 -lm
+STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/vdpau/libvdpautracker.a
+
+ifeq ($(MESA_LLVM),1)
+LDFLAGS += $(LLVM_LDFLAGS)
+DRIVER_EXTRAS = $(LLVM_LIBS)
+else
+LDFLAGS += -lstdc++
+endif
+
+# XXX: Hack, VDPAU public funcs aren't exported if we link to libvdpautracker.a :(
+OBJECTS = $(C_SOURCES:.c=.o) \
+         $(ASM_SOURCES:.S=.o) \
+         $(TOP)/src/gallium/state_trackers/vdpau/*.o
+
+##### RULES #####
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+##### TARGETS #####
+
+default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
+
+$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(OBJECTS) $(PIPE_DRIVERS) $(STATE_TRACKER_LIB) $(TOP)/$(LIB_DIR)/gallium Makefile
+       $(MKLIB) -o $(LIBBASENAME) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               -major $(VDPAU_MAJOR) -minor $(VDPAU_MINOR) $(MKLIB_OPTIONS) \
+               -install $(TOP)/$(LIB_DIR)/gallium \
+               $(OBJECTS) $(STATE_TRACKER_LIB) $(PIPE_DRIVERS) $(LIBS) $(DRIVER_EXTRAS)
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDES) $(C_SOURCES) \
+               $(ASM_SOURCES) 2> /dev/null
+
+# Emacs tags
+tags:
+       etags `find . -name \*.[ch]` `find ../include`
+
+# Remove .o and backup files
+clean:
+       -rm -f *.o *~ *.so $(SYMLINKS)
+       -rm -f depend depend.bak
+
+install: default
+       $(INSTALL) -d $(DESTDIR)$(VDPAU_LIB_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(VDPAU_LIB_GLOB) $(DESTDIR)$(VDPAU_LIB_INSTALL_DIR)
+
+include depend
index 47040bb..025f742 100644 (file)
@@ -32,7 +32,6 @@ ifeq ($(MESA_LLVM),1)
 LD = $(CXX)
 LDFLAGS += $(LLVM_LDFLAGS)
 USE_CXX=1
-DRIVER_PIPES += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
 DRIVER_LINKS += $(LLVM_LIBS) -lm -ldl
 endif
 
@@ -41,7 +40,7 @@ endif
 
 default: depend $(TOP)/$(LIB_DIR)/gallium $(LIBNAME) $(LIBNAME_STAGING)
 
-$(LIBNAME): $(OBJECTS) Makefile ../Makefile.xorg $(LIBS) $(DRIVER_PIPES)
+$(LIBNAME): $(OBJECTS) Makefile ../Makefile.xorg $(LIBS) $(DRIVER_PIPES) $(GALLIUM_AUXILIARIES)
        $(MKLIB) -linker '$(CC)' -noprefix -o $@ $(LDFLAGS) $(OBJECTS) $(DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $(DRIVER_LINKS)
 
 depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES)
diff --git a/src/gallium/targets/Makefile.xvmc b/src/gallium/targets/Makefile.xvmc
new file mode 100644 (file)
index 0000000..7182356
--- /dev/null
@@ -0,0 +1,70 @@
+# This makefile template is used to build libXvMCg3dvl.so
+
+LIBNAME = lib$(LIBBASENAME).so
+LIB_GLOB=lib$(LIBBASENAME).*so*
+XVMC_MAJOR = 1
+XVMC_MINOR = 0
+INCLUDES = -I$(TOP)/src/gallium/include \
+          -I$(TOP)/src/gallium/drivers \
+          -I$(TOP)/src/gallium/auxiliary \
+          -I$(TOP)/src/gallium/winsys \
+          -I$(TOP)/src/gallium/winsys/g3dvl \
+          $(DRIVER_INCLUDES)
+DEFINES = -DGALLIUM_TRACE $(DRIVER_DEFINES)
+LIBS = $(EXTRA_LIB_PATH) $(DRIVER_LIBS) -lXv -lX11 -lm
+STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/xorg/xvmc/libxvmctracker.a
+
+ifeq ($(MESA_LLVM),1)
+LDFLAGS += $(LLVM_LDFLAGS)
+DRIVER_EXTRAS = $(LLVM_LIBS)
+else
+LDFLAGS += -lstdc++
+endif
+
+
+# XXX: Hack, XvMC public funcs aren't exported if we link to libxvmctracker.a :(
+OBJECTS = $(C_SOURCES:.c=.o) \
+         $(ASM_SOURCES:.S=.o) \
+         $(TOP)/src/gallium/state_trackers/xorg/xvmc/*.o
+
+##### RULES #####
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+##### TARGETS #####
+
+default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
+
+$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(OBJECTS) $(PIPE_DRIVERS) $(STATE_TRACKER_LIB) $(TOP)/$(LIB_DIR)/gallium Makefile
+       $(MKLIB) -o $(LIBBASENAME) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               -major $(XVMC_MAJOR) -minor $(XVMC_MINOR) $(MKLIB_OPTIONS) \
+               -install $(TOP)/$(LIB_DIR)/gallium \
+               $(OBJECTS) $(STATE_TRACKER_LIB) $(PIPE_DRIVERS) $(LIBS) $(DRIVER_EXTRAS)
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDES) $(C_SOURCES) \
+               $(ASM_SOURCES) 2> /dev/null
+
+# Emacs tags
+tags:
+       etags `find . -name \*.[ch]` `find ../include`
+
+# Remove .o and backup files
+clean:
+       -rm -f *.o *~ *.so $(SYMLINKS)
+       -rm -f depend depend.bak
+
+install: default
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
+       $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(LIB_GLOB) $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
+
+include depend
index 101863a..5ad17f8 100644 (file)
@@ -29,7 +29,7 @@ drienv.Replace(CPPPATH = [
     '#src/egl/drivers/dri',
 ])
 
-drienv.ParseConfig('pkg-config --cflags --libs libdrm')
+drienv.PkgUseModules('DRM')
 
 dri_common_utils = drienv.SharedObject(
     target = 'utils.o',
index 9c10d71..2ba3eb6 100644 (file)
@@ -22,6 +22,7 @@ DRIVER_DEFINES = \
        -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD -DGALLIUM_SOFTPIPE
 
 ifeq ($(MESA_LLVM),1)
+PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
 DRIVER_DEFINES += -DGALLIUM_LLVMPIPE
 endif
 
index ab60013..b3bd3dd 100644 (file)
@@ -2,7 +2,7 @@ Import('*')
 
 env = drienv.Clone()
 
-env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
+env.PkgUseModules('DRM_INTEL')
 
 env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE', 'GALLIUM_GALAHAD'])
 
@@ -26,4 +26,4 @@ module = env.LoadableModule(
     SHLIBPREFIX = '',
 )
 
-env.Alias('dri-i915', module)
\ No newline at end of file
+env.Alias('dri-i915', module)
index 4b50d04..9e75bfe 100644 (file)
@@ -22,6 +22,7 @@ DRIVER_DEFINES = \
        -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD -DGALLIUM_SOFTPIPE
 
 ifeq ($(MESA_LLVM),1)
+PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
 DRIVER_DEFINES += -DGALLIUM_LLVMPIPE
 endif
 
index 669f70d..01a458d 100644 (file)
@@ -2,7 +2,7 @@ Import('*')
 
 env = drienv.Clone()
 
-env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
+env.PkgUseModules('DRM_INTEL')
 
 env.Append(CPPDEFINES = [
     'GALLIUM_SOFTPIPE',
@@ -29,4 +29,4 @@ module = env.LoadableModule(
     SHLIBPREFIX = '',
 )
 
-env.Alias('dri-i965', module)
\ No newline at end of file
+env.Alias('dri-i965', module)
index b48bcad..9b6d816 100644 (file)
@@ -1,4 +1,3 @@
-
 #include "target-helpers/inline_debug_helper.h"
 #include "state_tracker/drm_driver.h"
 #include "radeon/drm/radeon_drm_public.h"
index 948c45a..e83e024 100644 (file)
@@ -1,7 +1,7 @@
 TOP = ../../../..
 include $(TOP)/configs/current
 
-LIBNAME = swrastg_dri.so
+LIBNAME = swrast_dri.so
 
 DRIVER_DEFINES = \
        -D__NOT_HAVE_DRM_H -DGALLIUM_SOFTPIPE \
@@ -14,6 +14,11 @@ PIPE_DRIVERS = \
        $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/rbug/librbug.a
 
+ifeq ($(MESA_LLVM),1)
+PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
+DRIVER_DEFINES += -DGALLIUM_LLVMPIPE
+endif
+
 SWRAST_COMMON_GALLIUM_SOURCES = \
        $(TOP)/src/mesa/drivers/dri/common/utils.c \
        $(TOP)/src/mesa/drivers/dri/common/drisw_util.c \
index b674838..6b64c56 100644 (file)
@@ -29,14 +29,16 @@ if env['llvm']:
     env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
     env.Prepend(LIBS = [llvmpipe])
 
-swrastg_sources = [
+swrast_sources = [
     'swrast_drm_api.c'
 ]
 
 module = env.LoadableModule(
-    target ='swrastg_dri.so',
-    source = swrastg_sources,
+    target ='swrast_dri.so',
+    source = swrast_sources,
     SHLIBPREFIX = '',
 )
 
+module = env.InstallSharedLibrary(module)
+
 env.Alias('dri-swrast', module)
index 1362851..da50b8b 100644 (file)
@@ -19,6 +19,7 @@ create_screen(int fd)
    if (!screen)
       return NULL;
 
+   vmw_winsys_screen_set_throttling(screen, 10);
    screen = sw_screen_wrap(screen);
 
    screen = debug_screen_wrap(screen);
diff --git a/src/gallium/targets/egl-static/Makefile b/src/gallium/targets/egl-static/Makefile
new file mode 100644 (file)
index 0000000..42d34b8
--- /dev/null
@@ -0,0 +1,205 @@
+# src/gallium/targets/egl-static/Makefile
+#
+# This is Makefile for egl_gallium.so.  It is static in that all state trackers
+# and pipe drivers are linked statically when possible.
+#
+# The following variables are examined
+#
+#   EGL_PLATFORMS       - platforms to support
+#   EGL_CLIENT_APIS     - state trackers to support
+#   GALLIUM_WINSYS_DIRS - pipe drivers to support
+#   SHARED_GLAPI        - st/mesa can be statically linked or not
+#
+
+TOP = ../../../..
+include $(TOP)/configs/current
+
+OUTPUTS := egl_gallium
+
+egl_CPPFLAGS := \
+       -I$(TOP)/include \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/winsys
+egl_LIBS := \
+       $(TOP)/src/gallium/drivers/identity/libidentity.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/rbug/librbug.a \
+       $(GALLIUM_AUXILIARIES)
+egl_SYS :=
+
+egl_SOURCES := \
+       egl.c \
+       egl_pipe.c \
+       egl_st.c
+
+egl_OBJECTS := $(egl_SOURCES:%.c=%.o)
+
+# st/egl
+egl_CPPFLAGS += \
+       -I$(TOP)/src/gallium/state_trackers/egl \
+       -I$(TOP)/src/egl/main \
+       -D_EGL_MAIN=_eglMain
+egl_LIBS += $(TOP)/src/gallium/state_trackers/egl/libegl.a
+egl_SYS += $(LIBUDEV_LIBS) $(DLOPEN_LIBS) -lEGL -lm -lpthread
+
+# EGL platforms
+ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
+egl_CPPFLAGS += $(LIBDRM_CFLAGS)
+egl_LIBS += $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a
+egl_SYS += -lX11 -lXext -lXfixes $(LIBDRM_LIB)
+endif
+ifneq ($(findstring wayland, $(EGL_PLATFORMS)),)
+egl_CPPFLAGS += $(LIBDRM_CFLAGS)
+egl_LIBS += $(TOP)/src/gallium/winsys/sw/wayland/libws_wayland.a
+egl_LIBS += $(TOP)/src/egl/wayland/wayland-drm/libwayland-drm.a
+egl_SYS += $(LIBDRM_LIB) $(WAYLAND_LIBS)
+endif
+ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
+egl_CPPFLAGS += $(LIBDRM_CFLAGS)
+egl_SYS += $(LIBDRM_LIB) -lgbm
+endif
+ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
+egl_LIBS += $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a
+endif
+
+# st/mesa
+ifneq ($(filter $(GL_LIB), $(EGL_CLIENT_APIS)),)
+egl_CPPFLAGS += -I$(TOP)/src/mesa $(API_DEFINES)
+# make st/mesa built-in when there is a single glapi provider
+ifeq ($(SHARED_GLAPI),1)
+egl_LIBS += $(TOP)/src/mesa/libmesagallium.a
+egl_SYS += -lm -lpthread $(DLOPEN_LIBS) -l$(GLAPI_LIB)
+else
+egl_CPPFLAGS += -D_EGL_EXTERNAL_GL=1
+OUTPUTS += st_GL
+endif # SHARED_GLAPI
+endif
+
+# st/vega
+ifneq ($(filter $(VG_LIB), $(EGL_CLIENT_APIS)),)
+egl_CPPFLAGS += -I$(TOP)/src/gallium/state_trackers/vega -DFEATURE_VG=1
+egl_LIBS += $(TOP)/src/gallium/state_trackers/vega/libvega.a
+egl_SYS += -lm -l$(VG_LIB)
+endif
+
+# i915
+ifneq ($(findstring i915/drm,$(GALLIUM_WINSYS_DIRS)),)
+egl_CPPFLAGS += -D_EGL_PIPE_I915=1
+egl_LIBS += \
+       $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
+       $(TOP)/src/gallium/drivers/i915/libi915.a
+egl_SYS += -ldrm_intel
+endif
+
+# i965
+ifneq ($(findstring i965/drm,$(GALLIUM_WINSYS_DIRS)),)
+egl_CPPFLAGS += -D_EGL_PIPE_I995=1
+egl_LIBS += \
+       $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
+       $(TOP)/src/gallium/drivers/i965/libi965.a \
+       $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a
+egl_SYS += -ldrm_intel
+endif
+
+# nouveau
+ifneq ($(findstring nouveau/drm,$(GALLIUM_WINSYS_DIRS)),)
+egl_CPPFLAGS += -D_EGL_PIPE_NOUVEAU=1
+egl_LIBS += \
+       $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
+       $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
+       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
+       $(TOP)/src/gallium/drivers/nvc0/libnvc0.a \
+       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
+egl_SYS += -ldrm_nouveau
+endif
+
+# r300
+ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
+egl_CPPFLAGS += -D_EGL_PIPE_R300=1
+egl_LIBS += \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+       $(TOP)/src/gallium/drivers/r300/libr300.a
+endif
+
+# r600
+ifneq ($(findstring r600/drm,$(GALLIUM_WINSYS_DIRS)),)
+egl_CPPFLAGS += -D_EGL_PIPE_R600=1
+egl_LIBS += \
+       $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/drivers/r600/libr600.a
+endif
+
+# vmwgfx
+ifneq ($(findstring svga/drm,$(GALLIUM_WINSYS_DIRS)),)
+egl_CPPFLAGS += -D_EGL_PIPE_VMWGFX=1
+egl_LIBS += \
+       $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a
+endif
+
+# softpipe
+ifneq ($(findstring softpipe,$(GALLIUM_DRIVERS_DIRS)),)
+egl_CPPFLAGS += -DGALLIUM_SOFTPIPE -DGALLIUM_RBUG -DGALLIUM_TRACE
+egl_LIBS += $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+egl_SYS += -lm
+endif
+
+# llvmpipe
+ifneq ($(findstring llvmpipe,$(GALLIUM_DRIVERS_DIRS)),)
+egl_CPPFLAGS += -DGALLIUM_LLVMPIPE
+egl_LIBS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
+endif
+
+# sort to remove duplicates
+egl_CPPFLAGS := $(sort $(egl_CPPFLAGS))
+egl_LIBS := $(sort $(egl_LIBS))
+egl_SYS := $(sort $(egl_SYS))
+
+# st_GL, built only when shared glapi is not enabled
+st_GL_CPPFLAGS := -I $(TOP)/src/mesa -I$(TOP)/src/gallium/include
+st_GL_LIBS := $(TOP)/src/mesa/libmesagallium.a $(GALLIUM_AUXILIARIES)
+st_GL_SYS := -lm -lpthread $(DLOPEN_LIBS)
+
+# LLVM
+ifeq ($(MESA_LLVM),1)
+egl_SYS += $(LLVM_LIBS)
+LDFLAGS += $(LLVM_LDFLAGS)
+
+st_GL_SYS += $(LLVM_LIBS)
+endif
+
+OUTPUT_PATH := $(TOP)/$(LIB_DIR)/egl
+OUTPUTS := $(addprefix $(OUTPUT_PATH)/, $(addsuffix .so, $(OUTPUTS)))
+
+default: $(OUTPUTS)
+
+$(OUTPUT_PATH)/egl_gallium.so: $(egl_OBJECTS) $(egl_LIBS)
+       $(MKLIB) -o $(notdir $@) -noprefix -linker '$(CXX)' \
+               -ldflags '-L$(TOP)/$(LIB_DIR) -Wl,--no-undefined $(LDFLAGS)' \
+               -cplusplus -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) \
+               $(egl_OBJECTS) -Wl,--start-group $(egl_LIBS) -Wl,--end-group \
+               $(egl_SYS)
+
+$(OUTPUT_PATH)/st_GL.so: st_GL.o $(st_GL_LIBS)
+       $(MKLIB) -o $(notdir $@) -noprefix -linker '$(CXX)' \
+               -ldflags '-L$(TOP)/$(LIB_DIR) $(LDFLAGS)' \
+               -cplusplus -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) \
+               $< -Wl,--start-group $(st_GL_LIBS) -Wl,--end-group \
+               $(st_GL_SYS)
+
+$(egl_OBJECTS): %.o: %.c
+       $(CC) -c -o $@ $< $(egl_CPPFLAGS) $(DEFINES) $(CFLAGS)
+
+st_GL.o: st_GL.c
+       $(CC) -c -o $@ $< $(st_GL_CPPFLAGS) $(DEFINES) $(CFLAGS)
+
+install: $(OUTPUTS)
+       $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
+       for out in $(OUTPUTS); do \
+               $(MINSTALL) -m 755 "$$out" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
+       done
+
+clean:
+       rm -f *.o
index cbd98cc..dfd0543 100644 (file)
@@ -79,21 +79,17 @@ if True:
     openvg_name = 'OpenVG' if env['platform'] != 'windows' else 'libOpenVG'
     env.Prepend(LIBS = [openvg_name, st_vega])
 
-if env['x11']:
+if env['HAVE_X11']:
     env.Prepend(LIBS = [
         ws_xlib,
-        env['X11_LIBS'],
     ])
-
-if env['dri']:
-    env.ParseConfig('pkg-config --cflags --libs xfixes')
+    env.PkgUseModules('X11')
 
 # pipe drivers
-if env['drm']:
-    env.ParseConfig('pkg-config --cflags --libs libdrm')
+if env['HAVE_DRM']:
+    env.PkgUseModules('DRM')
 
-    if env['drm_intel']:
-        env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
+    if env['HAVE_DRM_INTEL']:
         env.Append(CPPDEFINES = ['_EGL_PIPE_I915', '_EGL_PIPE_I965'])
         env.Prepend(LIBS = [
             i915drm,
@@ -103,7 +99,7 @@ if env['drm']:
             ws_wrapper,
         ])
 
-    if env['drm_radeon']:
+    if env['HAVE_DRM_RADEON']:
         env.Append(CPPDEFINES = ['_EGL_PIPE_R300', '_EGL_PIPE_R600'])
         env.Prepend(LIBS = [
             radeonwinsys,
index e617ff5..568f549 100644 (file)
 
 #include "common/egl_g3d_loader.h"
 #include "egldriver.h"
+#include "egllog.h"
+
+#ifdef HAVE_LIBUDEV
+#include <stdio.h> /* for sscanf */
+#include <libudev.h>
+#endif
+
+#define DRIVER_MAP_GALLIUM_ONLY
+#include "pci_ids/pci_id_driver_map.h"
 
 #include "egl_pipe.h"
 #include "egl_st.h"
@@ -52,15 +61,108 @@ get_st_api(enum st_api_type api)
    return stmod->stapi;
 }
 
-static struct st_api *
-guess_gl_api(enum st_profile_type profile)
+#ifdef HAVE_LIBUDEV
+
+static boolean
+drm_fd_get_pci_id(int fd, int *vendor_id, int *chip_id)
 {
-   return get_st_api(ST_API_OPENGL);
+   struct udev *udev = NULL;
+   struct udev_device *device = NULL, *parent;
+   struct stat buf;
+   const char *pci_id;
+
+   *chip_id = -1;
+
+   udev = udev_new();
+   if (fstat(fd, &buf) < 0) {
+      _eglLog(_EGL_WARNING, "failed to stat fd %d", fd);
+      goto out;
+   }
+
+   device = udev_device_new_from_devnum(udev, 'c', buf.st_rdev);
+   if (device == NULL) {
+      _eglLog(_EGL_WARNING,
+              "could not create udev device for fd %d", fd);
+      goto out;
+   }
+
+   parent = udev_device_get_parent(device);
+   if (parent == NULL) {
+      _eglLog(_EGL_WARNING, "could not get parent device");
+      goto out;
+   }
+
+   pci_id = udev_device_get_property_value(parent, "PCI_ID");
+   if (pci_id == NULL ||
+       sscanf(pci_id, "%x:%x", vendor_id, chip_id) != 2) {
+      _eglLog(_EGL_WARNING, "malformed or no PCI ID");
+      *chip_id = -1;
+      goto out;
+   }
+
+out:
+   if (device)
+      udev_device_unref(device);
+   if (udev)
+      udev_unref(udev);
+
+   return (*chip_id >= 0);
+}
+
+#else
+
+static boolean
+drm_fd_get_pci_id(int fd, int *vendor_id, int *chip_id)
+{
+   return FALSE;
+}
+
+#endif /* HAVE_LIBUDEV */
+
+static const char *
+drm_fd_get_screen_name(int fd)
+{
+   int vendor_id, chip_id;
+   int idx, i;
+
+   if (!drm_fd_get_pci_id(fd, &vendor_id, &chip_id)) {
+      _eglLog(_EGL_WARNING, "failed to get driver name for fd %d", fd);
+      return NULL;
+   }
+
+   for (idx = 0; driver_map[idx].driver; idx++) {
+      if (vendor_id != driver_map[idx].vendor_id)
+         continue;
+
+      /* done if no chip id */
+      if (driver_map[idx].num_chips_ids == -1)
+         break;
+
+      for (i = 0; i < driver_map[idx].num_chips_ids; i++) {
+         if (driver_map[idx].chip_ids[i] == chip_id)
+            break;
+      }
+      /* matched! */
+      if (i < driver_map[idx].num_chips_ids)
+         break;
+   }
+
+   _eglLog((driver_map[idx].driver) ? _EGL_INFO : _EGL_WARNING,
+         "pci id for fd %d: %04x:%04x, driver %s",
+         fd, vendor_id, chip_id, driver_map[idx].driver);
+
+   return driver_map[idx].driver;
 }
 
 static struct pipe_screen *
 create_drm_screen(const char *name, int fd)
 {
+   if (!name) {
+      name = drm_fd_get_screen_name(fd);
+      if (!name)
+         return NULL;
+   }
+
    return egl_pipe_create_drm_screen(name, fd);
 }
 
@@ -79,7 +181,6 @@ loader_init(void)
       egl_g3d_loader.profile_masks[i] = egl_st_get_profile_mask(i);
 
    egl_g3d_loader.get_st_api = get_st_api;
-   egl_g3d_loader.guess_gl_api = guess_gl_api;
    egl_g3d_loader.create_drm_screen = create_drm_screen;
    egl_g3d_loader.create_sw_screen = create_sw_screen;
 
@@ -95,7 +196,7 @@ loader_fini(void)
       struct st_module *stmod = &st_modules[i];
 
       if (stmod->stapi) {
-         stmod->stapi->destroy(stmod->stapi);
+         egl_st_destroy_api(stmod->stapi);
          stmod->stapi = NULL;
       }
       stmod->initialized = FALSE;
index 3db5262..81d7bb4 100644 (file)
 #include "state_tracker/st_api.h"
 #include "egl_st.h"
 
-/* for st/mesa */
+#if FEATURE_GL || FEATURE_ES1 || FEATURE_ES2
 #include "state_tracker/st_gl_api.h"
-/* for st/vega */
+#endif
+
+#if FEATURE_VG
 #include "vg_api.h"
+#endif
+
+#if _EGL_EXTERNAL_GL
+
+#include "util/u_string.h"
+#include "util/u_dl.h"
+#include "egldriver.h"
+#include "egllog.h"
+
+static struct util_dl_library *egl_st_gl_lib;
+
+static EGLBoolean
+dlopen_gl_lib_cb(const char *dir, size_t len, void *callback_data)
+{
+   const char *name = (const char *) callback_data;
+   char path[1024];
+   int ret;
+
+   if (len) {
+      ret = util_snprintf(path, sizeof(path), "%.*s/%s" UTIL_DL_EXT,
+            len, dir, name);
+   }
+   else {
+      ret = util_snprintf(path, sizeof(path), "%s" UTIL_DL_EXT, name);
+   }
+
+   if (ret > 0 && ret < sizeof(path)) {
+      egl_st_gl_lib = util_dl_open(path);
+      if (egl_st_gl_lib)
+         _eglLog(_EGL_DEBUG, "loaded %s", path);
+   }
+
+   return !egl_st_gl_lib;
+}
 
 static struct st_api *
-st_GL_create_api(void)
+load_gl(const char *name, const char *procname)
 {
-#if FEATURE_GL || FEATURE_ES1 || FEATURE_ES2
-   return st_gl_api_create();
-#else
-   return NULL;
-#endif
+   struct st_api *(*create_api)(void);
+   struct st_api *stapi = NULL;
+
+   _eglSearchPathForEach(dlopen_gl_lib_cb, (void *) name);
+   if (!egl_st_gl_lib)
+      return NULL;
+
+   create_api = (struct st_api *(*)(void))
+      util_dl_get_proc_address(egl_st_gl_lib, procname);
+   if (create_api)
+      stapi = create_api();
+
+   if (!stapi) {
+      util_dl_close(egl_st_gl_lib);
+      egl_st_gl_lib = NULL;
+   }
+
+   return stapi;
 }
 
 static struct st_api *
-st_OpenVG_create_api(void)
+egl_st_load_gl(void)
 {
-#if FEATURE_VG
-   return (struct st_api *) vg_api_get();
-#else
-   return NULL;
-#endif
+   const char module[] = "st_GL";
+   const char symbol[] = "st_api_create_OpenGL";
+   struct st_api *stapi;
+
+   stapi = load_gl(module, symbol);
+
+   /* try again with libglapi.so loaded */
+   if (!stapi) {
+      struct util_dl_library *glapi = util_dl_open("libglapi" UTIL_DL_EXT);
+
+      if (glapi) {
+         _eglLog(_EGL_DEBUG, "retry with libglapi" UTIL_DL_EXT " loaded");
+
+         stapi = load_gl(module, symbol);
+         util_dl_close(glapi);
+      }
+   }
+   if (!stapi)
+      _eglLog(_EGL_WARNING, "unable to load %s" UTIL_DL_EXT, module);
+
+   return stapi;
 }
 
+#endif /* _EGL_EXTERNAL_GL */
+
 struct st_api *
 egl_st_create_api(enum st_api_type api)
 {
-   struct st_api *stapi;
+   struct st_api *stapi = NULL;
 
    switch (api) {
    case ST_API_OPENGL:
-      stapi = st_GL_create_api();
+#if FEATURE_GL || FEATURE_ES1 || FEATURE_ES2
+#if _EGL_EXTERNAL_GL
+      stapi = egl_st_load_gl();
+#else
+      stapi = st_gl_api_create();
+#endif
+#endif
       break;
    case ST_API_OPENVG:
-      stapi = st_OpenVG_create_api();
+#if FEATURE_VG
+      stapi = (struct st_api *) vg_api_get();
+#endif
       break;
    default:
       assert(!"Unknown API Type\n");
-      stapi = NULL;
       break;
    }
 
    return stapi;
 }
 
+void
+egl_st_destroy_api(struct st_api *stapi)
+{
+#if _EGL_EXTERNAL_GL
+   boolean is_gl = (stapi->api == ST_API_OPENGL);
+
+   stapi->destroy(stapi);
+
+   if (is_gl) {
+      util_dl_close(egl_st_gl_lib);
+      egl_st_gl_lib = NULL;
+   }
+#else
+   stapi->destroy(stapi);
+#endif
+}
+
 uint
 egl_st_get_profile_mask(enum st_api_type api)
 {
index ba82faf..7a3773c 100644 (file)
@@ -34,6 +34,9 @@
 struct st_api *
 egl_st_create_api(enum st_api_type api);
 
+void
+egl_st_destroy_api(struct st_api *stapi);
+
 uint
 egl_st_get_profile_mask(enum st_api_type api);
 
similarity index 80%
rename from src/gallium/targets/egl/egl.h
rename to src/gallium/targets/egl-static/st_GL.c
index 5fd0678..3f4b7a0 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.9
+ * Version:  7.10
  *
- * Copyright (C) 2010 LunarG Inc.
+ * Copyright (C) 2011 LunarG Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * Authors:
  *    Chia-I Wu <olv@lunarg.com>
  */
-
-#ifndef _EGL_H_
-#define _EGL_H_
-
+#include "state_tracker/st_gl_api.h"
 #include "pipe/p_compiler.h"
-#include "state_tracker/st_api.h"
-
-#define ST_CREATE_OPENGL_SYMBOL "st_api_create_OpenGL"
-#define ST_CREATE_OPENVG_SYMBOL "st_api_create_OpenVG"
 
 PUBLIC struct st_api *
 st_api_create_OpenGL(void);
 
-PUBLIC struct st_api *
-st_api_create_OpenVG(void);
-
-#endif /* _EGL_H_ */
+struct st_api *
+st_api_create_OpenGL(void)
+{
+   return st_gl_api_create();
+}
diff --git a/src/gallium/targets/egl/Makefile b/src/gallium/targets/egl/Makefile
deleted file mode 100644 (file)
index dd566bd..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-# src/gallium/targets/egl/Makefile
-#
-# This is the Makefile for EGL Gallium driver package.  The package consists of
-#
-#   egl_gallium.so - EGL driver
-#   pipe_<HW>.so   - pipe drivers
-#   st_<API>.so    - client API state trackers
-#
-# The following variables are examined
-#
-#   EGL_PLATFORMS       - platforms to support
-#   GALLIUM_WINSYS_DIRS - pipe drivers to support
-#   EGL_CLIENT_APIS     - state trackers to support
-#
-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-ST_PREFIX := st_
-PIPE_PREFIX := pipe_
-
-common_CPPFLAGS := \
-       -I$(TOP)/include \
-       -I$(TOP)/src/gallium/auxiliary \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/winsys \
-       $(LIBDRM_CFLAGS)
-
-common_SYS :=
-common_LIBS := \
-       $(TOP)/src/gallium/drivers/identity/libidentity.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/rbug/librbug.a \
-       $(GALLIUM_AUXILIARIES)
-
-# EGL driver
-egl_CPPFLAGS := \
-       -I$(TOP)/src/gallium/state_trackers/egl \
-       -I$(TOP)/src/egl/main \
-       -DPIPE_PREFIX=\"$(PIPE_PREFIX)\" -DST_PREFIX=\"$(ST_PREFIX)\"
-egl_SYS := -lm $(DLOPEN_LIBS) -lEGL
-egl_LIBS := $(TOP)/src/gallium/state_trackers/egl/libegl.a
-
-ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
-egl_SYS += -lX11 -lXext -lXfixes $(LIBDRM_LIB)
-egl_LIBS += $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a
-endif
-ifneq ($(findstring wayland, $(EGL_PLATFORMS)),)
-egl_SYS += $(WAYLAND_LIBS) $(LIBDRM_LIB)
-egl_LIBS += $(TOP)/src/gallium/winsys/sw/wayland/libws_wayland.a
-egl_LIBS += $(TOP)/src/egl/wayland/wayland-drm/libwayland-drm.a
-endif
-ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
-egl_SYS += $(LIBUDEV_LIBS) $(LIBDRM_LIB)
-endif
-ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
-egl_LIBS += $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a
-endif
-
-# EGL_RENDERABLE_TYPE is a compile time attribute
-ifneq ($(filter $(GL_LIB), $(EGL_CLIENT_APIS)),)
-egl_CPPFLAGS += $(API_DEFINES)
-endif
-ifneq ($(filter $(VG_LIB), $(EGL_CLIENT_APIS)),)
-egl_CPPFLAGS += -DFEATURE_VG=1
-endif
-egl_CPPFLAGS := $(sort $(egl_CPPFLAGS))
-
-# i915 pipe driver
-i915_CPPFLAGS :=
-i915_SYS := -ldrm_intel
-i915_LIBS := \
-       $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
-       $(TOP)/src/gallium/drivers/i915/libi915.a
-
-# i965 pipe driver
-i965_CPPFLAGS :=
-i965_SYS := -ldrm_intel
-i965_LIBS := \
-       $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
-       $(TOP)/src/gallium/drivers/i965/libi965.a \
-       $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a
-
-# nouveau pipe driver
-nouveau_CPPFLAGS :=
-nouveau_SYS := -ldrm_nouveau
-nouveau_LIBS := \
-       $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
-       $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
-       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
-       $(TOP)/src/gallium/drivers/nvc0/libnvc0.a \
-       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
-
-# r300 pipe driver
-r300_CPPFLAGS :=
-r300_SYS := -ldrm
-r300_LIBS := \
-       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
-       $(TOP)/src/gallium/drivers/r300/libr300.a
-
-# r600 pipe driver
-r600_CPPFLAGS :=
-r600_SYS := -ldrm -ldrm_radeon
-r600_LIBS := \
-       $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
-       $(TOP)/src/gallium/drivers/r600/libr600.a
-
-# vmwgfx pipe driver
-vmwgfx_CPPFLAGS :=
-vmwgfx_SYS :=
-vmwgfx_LIBS := \
-       $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
-       $(TOP)/src/gallium/drivers/svga/libsvga.a
-
-# swrast (pseudo) pipe driver
-swrast_CPPFLAGS := -DGALLIUM_SOFTPIPE -DGALLIUM_RBUG -DGALLIUM_TRACE
-swrast_SYS := -lm
-swrast_LIBS := $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
-
-# LLVM
-ifeq ($(MESA_LLVM),1)
-common_SYS += $(LLVM_LIBS)
-swrast_CPPFLAGS += -DGALLIUM_LLVMPIPE
-swrast_LIBS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
-LDFLAGS += $(LLVM_LDFLAGS)
-endif
-
-# OpenGL state tracker
-GL_CPPFLAGS := -I$(TOP)/src/mesa $(API_DEFINES)
-ifeq ($(SHARED_GLAPI),1)
-GL_SYS := $(DRI_LIB_DEPS) -l$(GLAPI_LIB)
-else
-# cannot link to $(GL_LIB) as the app might want GL or GLES
-GL_SYS := $(DRI_LIB_DEPS)
-endif
-GL_LIBS := $(TOP)/src/mesa/libmesagallium.a
-
-# OpenVG state tracker
-OpenVG_CPPFLAGS := -I$(TOP)/src/gallium/state_trackers/vega
-OpenVG_SYS := -lm -l$(VG_LIB)
-OpenVG_LIBS := $(TOP)/src/gallium/state_trackers/vega/libvega.a
-
-
-OUTPUT_PATH := $(TOP)/$(LIB_DIR)/egl
-
-# determine the outputs
-ifneq ($(findstring i915/drm,$(GALLIUM_WINSYS_DIRS)),)
-OUTPUTS += i915
-endif
-ifneq ($(findstring i965/drm,$(GALLIUM_WINSYS_DIRS)),)
-OUTPUTS += i965
-endif
-ifneq ($(findstring nouveau/drm,$(GALLIUM_WINSYS_DIRS)),)
-OUTPUTS += nouveau
-endif
-ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
-OUTPUTS += r300
-endif
-ifneq ($(findstring r600/drm,$(GALLIUM_WINSYS_DIRS)),)
-OUTPUTS += r600
-endif
-ifneq ($(findstring svga/drm,$(GALLIUM_WINSYS_DIRS)),)
-OUTPUTS += vmwgfx
-endif
-OUTPUTS += swrast
-OUTPUTS := $(addprefix $(PIPE_PREFIX), $(OUTPUTS))
-
-# EGL driver and state trackers
-OUTPUTS += egl_gallium $(addprefix $(ST_PREFIX), $(EGL_CLIENT_APIS))
-
-OUTPUTS := $(addsuffix .so, $(OUTPUTS))
-OUTPUTS := $(addprefix $(OUTPUT_PATH)/, $(OUTPUTS))
-
-default: $(OUTPUTS)
-
-define mklib
-$(MKLIB) -o $(notdir $@) -noprefix -linker '$(CC)' \
-       -L$(TOP)/$(LIB_DIR) -ldflags '$(LDFLAGS)' \
-       -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) $< \
-       -Wl,--start-group $(common_LIBS) $($(1)_LIBS) -Wl,--end-group \
-       $(common_SYS) $($(1)_SYS)
-endef
-
-define mklib-cxx
-$(MKLIB) -o $(notdir $@) -noprefix -linker '$(CXX)' \
-       -L$(TOP)/$(LIB_DIR) -ldflags '$(LDFLAGS)' \
-       -cplusplus -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) $< \
-       -Wl,--start-group $(common_LIBS) $($(1)_LIBS) -Wl,--end-group \
-       $(common_SYS) $($(1)_SYS)
-endef
-
-# EGL driver
-$(OUTPUT_PATH)/egl_gallium.so: egl.o $(egl_LIBS)
-       $(call mklib,egl)
-
-# pipe drivers
-$(OUTPUT_PATH)/$(PIPE_PREFIX)i915.so: pipe_i915.o $(i915_LIBS)
-       $(call mklib,i915)
-
-$(OUTPUT_PATH)/$(PIPE_PREFIX)i965.so: pipe_i965.o $(i965_LIBS)
-       $(call mklib,i965)
-
-$(OUTPUT_PATH)/$(PIPE_PREFIX)nouveau.so: pipe_nouveau.o $(nouveau_LIBS)
-       $(call mklib,nouveau)
-
-$(OUTPUT_PATH)/$(PIPE_PREFIX)r300.so: pipe_r300.o $(r300_LIBS)
-       $(call mklib,r300)
-
-$(OUTPUT_PATH)/$(PIPE_PREFIX)r600.so: pipe_r600.o $(r600_LIBS)
-       $(call mklib,r600)
-
-$(OUTPUT_PATH)/$(PIPE_PREFIX)vmwgfx.so: pipe_vmwgfx.o $(vmwgfx_LIBS)
-       $(call mklib,vmwgfx)
-
-$(OUTPUT_PATH)/$(PIPE_PREFIX)swrast.so: pipe_swrast.o $(swrast_LIBS)
-       $(call mklib,swrast)
-
-# state trackers
-$(OUTPUT_PATH)/$(ST_PREFIX)$(GL_LIB).so: st_GL.o $(GL_LIBS)
-       $(call mklib-cxx,GL)
-
-$(OUTPUT_PATH)/$(ST_PREFIX)$(VG_LIB).so: st_OpenVG.o $(OpenVG_LIBS)
-       $(call mklib,OpenVG)
-
-egl.o: egl.c
-       $(CC) -c -o $@ $< $(common_CPPFLAGS) $(egl_CPPFLAGS) $(DEFINES) $(CFLAGS)
-
-pipe_%.o: pipe_%.c
-       $(CC) -c -o $@ $< $(common_CPPFLAGS) $($*_CPPFLAGS) $(DEFINES) $(CFLAGS)
-
-st_%.o: st_%.c
-       $(CC) -c -o $@ $< $(common_CPPFLAGS) $($*_CPPFLAGS) $(DEFINES) $(CFLAGS)
-
-install: $(OUTPUTS)
-       $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
-       for out in $(OUTPUTS); do \
-               $(MINSTALL) -m 755 "$$out" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
-       done
-
-clean:
-       rm -f *.o
diff --git a/src/gallium/targets/egl/egl.c b/src/gallium/targets/egl/egl.c
deleted file mode 100644 (file)
index 3467aea..0000000
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  7.9
- *
- * Copyright (C) 2010 LunarG 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 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:
- *    Chia-I Wu <olv@lunarg.com>
- */
-
-#include "util/u_debug.h"
-#include "util/u_string.h"
-#include "util/u_memory.h"
-#include "util/u_dl.h"
-#include "egldriver.h"
-#include "egllog.h"
-
-#include "state_tracker/st_api.h"
-#include "state_tracker/drm_driver.h"
-#include "common/egl_g3d_loader.h"
-
-#ifdef HAVE_LIBUDEV
-#include <libudev.h>
-#define DRIVER_MAP_GALLIUM_ONLY
-#include "pci_ids/pci_id_driver_map.h"
-#endif
-
-#include "egl.h"
-
-struct egl_g3d_loader egl_g3d_loader;
-
-static struct st_module {
-   boolean initialized;
-   char *name;
-   struct util_dl_library *lib;
-   struct st_api *stapi;
-} st_modules[ST_API_COUNT];
-
-static struct pipe_module {
-   boolean initialized;
-   char *name;
-   struct util_dl_library *lib;
-   const struct drm_driver_descriptor *drmdd;
-   struct pipe_screen *(*swrast_create_screen)(struct sw_winsys *);
-} pipe_modules[16];
-
-static char *
-loader_strdup(const char *s)
-{
-   size_t len = (s) ? strlen(s) : 0;
-   char *t = MALLOC(len + 1);
-   if (t) {
-      memcpy(t, s, len);
-      t[len] = '\0';
-   }
-   return t;
-}
-
-static EGLBoolean
-dlopen_st_module_cb(const char *dir, size_t len, void *callback_data)
-{
-   struct st_module *stmod =
-      (struct st_module *) callback_data;
-   char path[1024];
-   int ret;
-
-   if (len) {
-      ret = util_snprintf(path, sizeof(path),
-            "%.*s/" ST_PREFIX "%s" UTIL_DL_EXT, len, dir, stmod->name);
-   }
-   else {
-      ret = util_snprintf(path, sizeof(path),
-            ST_PREFIX "%s" UTIL_DL_EXT, stmod->name);
-   }
-
-   if (ret > 0 && ret < sizeof(path)) {
-      stmod->lib = util_dl_open(path);
-      if (stmod->lib)
-         _eglLog(_EGL_DEBUG, "loaded %s", path);
-   }
-
-   return !(stmod->lib);
-}
-
-static boolean
-load_st_module(struct st_module *stmod,
-                       const char *name, const char *procname)
-{
-   struct st_api *(*create_api)(void);
-
-   if (name) {
-      _eglLog(_EGL_DEBUG, "searching for st module %s", name);
-      stmod->name = loader_strdup(name);
-   }
-   else {
-      stmod->name = NULL;
-   }
-
-   if (stmod->name)
-      _eglSearchPathForEach(dlopen_st_module_cb, (void *) stmod);
-   else
-      stmod->lib = util_dl_open(NULL);
-
-   if (stmod->lib) {
-      create_api = (struct st_api *(*)(void))
-         util_dl_get_proc_address(stmod->lib, procname);
-      if (create_api)
-         stmod->stapi = create_api();
-
-      if (!stmod->stapi) {
-         util_dl_close(stmod->lib);
-         stmod->lib = NULL;
-      }
-   }
-
-   if (!stmod->stapi) {
-      FREE(stmod->name);
-      stmod->name = NULL;
-   }
-
-   return (stmod->stapi != NULL);
-}
-
-static EGLBoolean
-dlopen_pipe_module_cb(const char *dir, size_t len, void *callback_data)
-{
-   struct pipe_module *pmod = (struct pipe_module *) callback_data;
-   char path[1024];
-   int ret;
-
-   if (len) {
-      ret = util_snprintf(path, sizeof(path),
-            "%.*s/" PIPE_PREFIX "%s" UTIL_DL_EXT, len, dir, pmod->name);
-   }
-   else {
-      ret = util_snprintf(path, sizeof(path),
-            PIPE_PREFIX "%s" UTIL_DL_EXT, pmod->name);
-   }
-   if (ret > 0 && ret < sizeof(path)) {
-      pmod->lib = util_dl_open(path);
-      if (pmod->lib)
-         _eglLog(_EGL_DEBUG, "loaded %s", path);
-   }
-
-   return !(pmod->lib);
-}
-
-static boolean
-load_pipe_module(struct pipe_module *pmod, const char *name)
-{
-   pmod->name = loader_strdup(name);
-   if (!pmod->name)
-      return FALSE;
-
-   _eglLog(_EGL_DEBUG, "searching for pipe module %s", pmod->name);
-   _eglSearchPathForEach(dlopen_pipe_module_cb, (void *) pmod);
-   if (pmod->lib) {
-      pmod->drmdd = (const struct drm_driver_descriptor *)
-         util_dl_get_proc_address(pmod->lib, "driver_descriptor");
-
-      /* sanity check on the name */
-      if (pmod->drmdd && strcmp(pmod->drmdd->name, pmod->name) != 0)
-         pmod->drmdd = NULL;
-
-      /* swrast */
-      if (pmod->drmdd && !pmod->drmdd->driver_name) {
-         pmod->swrast_create_screen =
-            (struct pipe_screen *(*)(struct sw_winsys *))
-            util_dl_get_proc_address(pmod->lib, "swrast_create_screen");
-         if (!pmod->swrast_create_screen)
-            pmod->drmdd = NULL;
-      }
-
-      if (!pmod->drmdd) {
-         util_dl_close(pmod->lib);
-         pmod->lib = NULL;
-      }
-   }
-
-   return (pmod->drmdd != NULL);
-}
-
-static struct st_api *
-get_st_api_full(enum st_api_type api, enum st_profile_type profile)
-{
-   struct st_module *stmod = &st_modules[api];
-   const char *names[8], *symbol;
-   int i, count = 0;
-
-   if (stmod->initialized)
-      return stmod->stapi;
-
-   switch (api) {
-   case ST_API_OPENGL:
-      symbol = ST_CREATE_OPENGL_SYMBOL;
-      names[count++] = "GL";
-      break;
-   case ST_API_OPENVG:
-      symbol = ST_CREATE_OPENVG_SYMBOL;
-      names[count++] = "OpenVG";
-      break;
-   default:
-      symbol = NULL;
-      assert(!"Unknown API Type\n");
-      break;
-   }
-
-   /* NULL means the process itself */
-   names[count++] = NULL;
-
-   for (i = 0; i < count; i++) {
-      if (load_st_module(stmod, names[i], symbol))
-         break;
-   }
-
-   /* try again with libGL.so loaded */
-   if (!stmod->stapi && api == ST_API_OPENGL) {
-      struct util_dl_library *glapi = util_dl_open("libGL" UTIL_DL_EXT);
-
-      if (glapi) {
-         _eglLog(_EGL_DEBUG, "retry with libGL" UTIL_DL_EXT " loaded");
-         /* skip the last name (which is NULL) */
-         for (i = 0; i < count - 1; i++) {
-            if (load_st_module(stmod, names[i], symbol))
-               break;
-         }
-         util_dl_close(glapi);
-      }
-   }
-
-   if (!stmod->stapi) {
-      EGLint level = (egl_g3d_loader.profile_masks[api]) ?
-         _EGL_WARNING : _EGL_DEBUG;
-      _eglLog(level, "unable to load " ST_PREFIX "%s" UTIL_DL_EXT, names[0]);
-   }
-
-   stmod->initialized = TRUE;
-
-   return stmod->stapi;
-}
-
-static struct st_api *
-get_st_api(enum st_api_type api)
-{
-   enum st_profile_type profile = ST_PROFILE_DEFAULT;
-
-   /* determine the profile from the linked libraries */
-   if (api == ST_API_OPENGL) {
-      struct util_dl_library *self;
-
-      self = util_dl_open(NULL);
-      if (self) {
-         if (util_dl_get_proc_address(self, "glColor4x"))
-            profile = ST_PROFILE_OPENGL_ES1;
-         else if (util_dl_get_proc_address(self, "glShaderBinary"))
-            profile = ST_PROFILE_OPENGL_ES2;
-         util_dl_close(self);
-      }
-   }
-
-   return get_st_api_full(api, profile);
-}
-
-static struct st_api *
-guess_gl_api(enum st_profile_type profile)
-{
-   return get_st_api_full(ST_API_OPENGL, profile);
-}
-
-static struct pipe_module *
-get_pipe_module(const char *name)
-{
-   struct pipe_module *pmod = NULL;
-   int i;
-
-   if (!name)
-      return NULL;
-
-   for (i = 0; i < Elements(pipe_modules); i++) {
-      if (!pipe_modules[i].initialized ||
-          strcmp(pipe_modules[i].name, name) == 0) {
-         pmod = &pipe_modules[i];
-         break;
-      }
-   }
-   if (!pmod)
-      return NULL;
-
-   if (!pmod->initialized) {
-      load_pipe_module(pmod, name);
-      pmod->initialized = TRUE;
-   }
-
-   return pmod;
-}
-
-static char *
-drm_fd_get_screen_name(int fd)
-{
-   char *driver = NULL;
-#ifdef HAVE_LIBUDEV
-   struct udev *udev;
-   struct udev_device *device, *parent;
-   struct stat buf;
-   const char *pci_id;
-   int vendor_id, chip_id, i, j;
-
-   udev = udev_new();
-   if (fstat(fd, &buf) < 0) {
-      _eglLog(_EGL_WARNING, "failed to stat fd %d", fd);
-      return NULL;
-   }
-
-   device = udev_device_new_from_devnum(udev, 'c', buf.st_rdev);
-   if (device == NULL) {
-      _eglLog(_EGL_WARNING,
-              "could not create udev device for fd %d", fd);
-      return NULL;
-   }
-
-   parent = udev_device_get_parent(device);
-   if (parent == NULL) {
-      _eglLog(_EGL_WARNING, "could not get parent device");
-      goto out;
-   }
-
-   pci_id = udev_device_get_property_value(parent, "PCI_ID");
-   if (pci_id == NULL ||
-       sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
-      _eglLog(_EGL_WARNING, "malformed or no PCI ID");
-      goto out;
-   }
-
-   for (i = 0; driver_map[i].driver; i++) {
-      if (vendor_id != driver_map[i].vendor_id)
-         continue;
-      if (driver_map[i].num_chips_ids == -1) {
-         driver = strdup(driver_map[i].driver);
-         _eglLog(_EGL_WARNING,
-                 "pci id for %d: %04x:%04x, driver %s",
-                 fd, vendor_id, chip_id, driver);
-         goto out;
-      }
-
-      for (j = 0; j < driver_map[i].num_chips_ids; j++)
-         if (driver_map[i].chip_ids[j] == chip_id) {
-            driver = strdup(driver_map[i].driver);
-            _eglLog(_EGL_WARNING,
-                    "pci id for %d: %04x:%04x, driver %s",
-                    fd, vendor_id, chip_id, driver);
-            goto out;
-         }
-   }
-
-out:
-   udev_device_unref(device);
-   udev_unref(udev);
-
-#endif
-   return driver;
-}
-
-static struct pipe_screen *
-create_drm_screen(const char *name, int fd)
-{
-   struct pipe_module *pmod;
-   const char *screen_name = name;
-   
-   if (screen_name == NULL)
-      if ((screen_name = drm_fd_get_screen_name(fd)) == NULL)
-         return NULL;
-   pmod = get_pipe_module(screen_name);
-
-   return (pmod && pmod->drmdd && pmod->drmdd->create_screen) ?
-      pmod->drmdd->create_screen(fd) : NULL;
-}
-
-static struct pipe_screen *
-create_sw_screen(struct sw_winsys *ws)
-{
-   struct pipe_module *pmod = get_pipe_module("swrast");
-   return (pmod && pmod->swrast_create_screen) ?
-      pmod->swrast_create_screen(ws) : NULL;
-}
-
-static const struct egl_g3d_loader *
-loader_init(void)
-{
-   /* TODO detect at runtime? */
-#if FEATURE_GL
-   egl_g3d_loader.profile_masks[ST_API_OPENGL] |= ST_PROFILE_DEFAULT_MASK;
-#endif
-#if FEATURE_ES1
-   egl_g3d_loader.profile_masks[ST_API_OPENGL] |= ST_PROFILE_OPENGL_ES1_MASK;
-#endif
-#if FEATURE_ES2
-   egl_g3d_loader.profile_masks[ST_API_OPENGL] |= ST_PROFILE_OPENGL_ES2_MASK;
-#endif
-#if FEATURE_VG
-   egl_g3d_loader.profile_masks[ST_API_OPENVG] |= ST_PROFILE_DEFAULT_MASK;
-#endif
-
-   egl_g3d_loader.get_st_api = get_st_api;
-   egl_g3d_loader.guess_gl_api = guess_gl_api;
-   egl_g3d_loader.create_drm_screen = create_drm_screen;
-   egl_g3d_loader.create_sw_screen = create_sw_screen;
-
-   return &egl_g3d_loader;
-}
-
-static void
-loader_fini(void)
-{
-   int i;
-
-   for (i = 0; i < ST_API_COUNT; i++) {
-      struct st_module *stmod = &st_modules[i];
-
-      if (stmod->stapi) {
-         stmod->stapi->destroy(stmod->stapi);
-         stmod->stapi = NULL;
-      }
-      if (stmod->lib) {
-         util_dl_close(stmod->lib);
-         stmod->lib = NULL;
-      }
-      if (stmod->name) {
-         FREE(stmod->name);
-         stmod->name = NULL;
-      }
-      stmod->initialized = FALSE;
-   }
-   for (i = 0; i < Elements(pipe_modules); i++) {
-      struct pipe_module *pmod = &pipe_modules[i];
-
-      if (!pmod->initialized)
-         break;
-
-      pmod->drmdd = NULL;
-      pmod->swrast_create_screen = NULL;
-      if (pmod->lib) {
-         util_dl_close(pmod->lib);
-         pmod->lib = NULL;
-      }
-      if (pmod->name) {
-         FREE(pmod->name);
-         pmod->name = NULL;
-      }
-      pmod->initialized = FALSE;
-   }
-}
-
-static void
-egl_g3d_unload(_EGLDriver *drv)
-{
-   egl_g3d_destroy_driver(drv);
-   loader_fini();
-}
-
-_EGLDriver *
-_eglMain(const char *args)
-{
-   const struct egl_g3d_loader *loader;
-   _EGLDriver *drv;
-
-   loader = loader_init();
-   drv = egl_g3d_create_driver(loader);
-   if (!drv) {
-      loader_fini();
-      return NULL;
-   }
-
-   drv->Name = "Gallium";
-   drv->Unload = egl_g3d_unload;
-
-   return drv;
-}
diff --git a/src/gallium/targets/egl/st_GL.c b/src/gallium/targets/egl/st_GL.c
deleted file mode 100644 (file)
index c1df844..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "state_tracker/st_gl_api.h"
-#include "egl.h"
-
-PUBLIC struct st_api *
-st_api_create_OpenGL(void)
-{
-   return st_gl_api_create();
-}
diff --git a/src/gallium/targets/egl/st_OpenVG.c b/src/gallium/targets/egl/st_OpenVG.c
deleted file mode 100644 (file)
index d0bf4db..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "vg_api.h"
-#include "egl.h"
-
-PUBLIC struct st_api *
-st_api_create_OpenVG(void)
-{
-   return (struct st_api *) vg_api_get();
-}
diff --git a/src/gallium/targets/gbm/Makefile b/src/gallium/targets/gbm/Makefile
new file mode 100644 (file)
index 0000000..b38782c
--- /dev/null
@@ -0,0 +1,167 @@
+# src/gallium/targets/gbm/Makefile
+
+TOP = ../../../..
+include $(TOP)/configs/current
+
+PIPE_PREFIX := pipe_
+
+GBM_BACKEND = gbm_gallium_drm
+GBM_SOURCES = gbm.c pipe_loader.c
+
+GBM_INCLUDES = \
+              -I$(TOP)/include \
+              -I$(TOP)/src/gallium/state_trackers/gbm \
+              -I$(TOP)/src/gbm/main \
+              -I$(TOP)/src/gallium/auxiliary \
+              -I$(TOP)/src/gallium/include \
+
+GBM_LIBS = $(LIBUDEV_LIBS) $(LIBDRM_LIB) -lm \
+          $(TOP)/src/gallium/state_trackers/gbm/libgbm.a \
+          $(TOP)/src/gallium/drivers/identity/libidentity.a \
+          $(TOP)/src/gallium/drivers/galahad/libgalahad.a \
+          $(TOP)/src/gallium/drivers/trace/libtrace.a \
+          $(TOP)/src/gallium/drivers/rbug/librbug.a \
+          $(GALLIUM_AUXILIARIES)
+
+
+GBM_CFLAGS = \
+            -DGBM_BACKEND_SEARCH_DIR=\"$(GBM_BACKEND_INSTALL_DIR)\" \
+            -DPIPE_PREFIX=\"$(PIPE_PREFIX)\" \
+            $(LIBUDEV_CFLAGS) \
+            $(LIBDRM_CFLAGS)  
+
+
+pipe_INCLUDES = \
+       -I$(TOP)/include \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/winsys
+
+pipe_LIBS = \
+       $(TOP)/src/gallium/drivers/identity/libidentity.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/rbug/librbug.a \
+       $(GALLIUM_AUXILIARIES)
+
+# as if we are DRI modules
+pipe_SYS = $(DRI_LIB_DEPS)
+
+pipe_CLFLAGS = \
+       -DGALLIUM_RBUG -DGALLIUM_TRACE -DGALLIUM_GALAHAD \
+       $(LIBDRM_CFLAGS)
+
+pipe_LDFLAGS = -Wl,--no-undefined
+
+# i915 pipe driver
+i915_LIBS = \
+       $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
+       $(TOP)/src/gallium/drivers/i915/libi915.a
+i915_SYS = -ldrm_intel
+
+# i965 pipe driver
+i965_LIBS = \
+       $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
+       $(TOP)/src/gallium/drivers/i965/libi965.a \
+       $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a
+i965_SYS = -ldrm_intel
+
+# nouveau pipe driver
+nouveau_LIBS = \
+       $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
+       $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
+       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
+       $(TOP)/src/gallium/drivers/nvc0/libnvc0.a \
+       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
+nouveau_SYS = -ldrm_nouveau
+
+# r300 pipe driver
+r300_LIBS = \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+       $(TOP)/src/gallium/drivers/r300/libr300.a
+
+# r600 pipe driver
+r600_LIBS = \
+       $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/drivers/r600/libr600.a
+
+# vmwgfx pipe driver
+vmwgfx_LIBS = \
+       $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a
+
+# LLVM
+ifeq ($(MESA_LLVM),1)
+pipe_LIBS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
+pipe_SYS += $(LLVM_LIBS)
+pipe_LDFLAGS += $(LLVM_LDFLAGS)
+endif
+
+# determine the targets/sources
+pipe_TARGETS =
+pipe_SOURCES =
+
+ifneq ($(findstring i915/drm,$(GALLIUM_WINSYS_DIRS)),)
+pipe_TARGETS += $(PIPE_PREFIX)i915.so
+pipe_SOURCES += pipe_i915.c
+endif
+
+ifneq ($(findstring i965/drm,$(GALLIUM_WINSYS_DIRS)),)
+pipe_TARGETS += $(PIPE_PREFIX)i965.so
+pipe_SOURCES += pipe_i965.c
+endif
+
+ifneq ($(findstring nouveau/drm,$(GALLIUM_WINSYS_DIRS)),)
+pipe_TARGETS += $(PIPE_PREFIX)nouveau.so
+pipe_SOURCES += pipe_nouveau.c
+endif
+
+ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
+pipe_TARGETS += $(PIPE_PREFIX)r300.so
+pipe_SOURCES += pipe_r300.c
+endif
+
+ifneq ($(findstring r600/drm,$(GALLIUM_WINSYS_DIRS)),)
+pipe_TARGETS += $(PIPE_PREFIX)r600.so
+pipe_SOURCES += pipe_r600.c
+endif
+
+ifneq ($(findstring svga/drm,$(GALLIUM_WINSYS_DIRS)),)
+pipe_TARGETS += $(PIPE_PREFIX)vmwgfx.so
+pipe_SOURCES += pipe_vmwgfx.c
+endif
+
+pipe_OBJECTS = $(pipe_SOURCES:.c=.o)
+
+
+GBM_EXTRA_TARGETS = $(addprefix $(TOP)/$(LIB_DIR)/gbm/, $(pipe_TARGETS))
+GBM_EXTRA_INSTALL = install-pipes
+GBM_EXTRA_CLEAN = clean-pipes
+GBM_EXTRA_SOURCES = $(pipe_SOURCES)
+
+include $(TOP)/src/gbm/backends/Makefile.template
+
+
+$(GBM_EXTRA_TARGETS): $(TOP)/$(LIB_DIR)/gbm/%: %
+       @$(INSTALL) -d $(dir $@)
+       $(INSTALL) $< $(dir $@)
+
+$(pipe_TARGETS): $(PIPE_PREFIX)%.so: pipe_%.o
+       $(MKLIB) -o $@ -noprefix -linker '$(CC)' \
+               -ldflags '-L$(TOP)/$(LIB_DIR) $(pipe_LDFLAGS) $(LDFLAGS)' \
+               $(MKLIB_OPTIONS) $< \
+               -Wl,--start-group $(pipe_LIBS) $($*_LIBS) -Wl,--end-group \
+               $(pipe_SYS) $($*_SYS)
+
+$(pipe_OBJECTS): %.o: %.c
+       $(CC) -c -o $@ $< $(pipe_INCLUDES) $(pipe_CFLAGS) $(CFLAGS)
+
+install-pipes: $(GBM_EXTRA_TARGETS)
+       $(INSTALL) -d $(DESTDIR)$(GBM_BACKEND_INSTALL_DIR)
+       for tgt in $(GBM_EXTRA_TARGETS); do \
+               $(MINSTALL) "$$tgt" $(DESTDIR)$(GBM_BACKEND_INSTALL_DIR); \
+       done
+
+clean-pipes:
+       rm -f $(pipe_TARGETS)
+       rm -f $(pipe_OBJECTS)
diff --git a/src/gallium/targets/gbm/gbm.c b/src/gallium/targets/gbm/gbm.c
new file mode 100644 (file)
index 0000000..e840fc5
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#include "util/u_inlines.h"
+
+#include "gbm_gallium_drmint.h"
+#include "pipe_loader.h"
+
+static struct pipe_screen *
+create_drm_screen(const char *name, int fd)
+{
+   struct pipe_module *pmod = get_pipe_module(name);
+   return (pmod && pmod->drmdd && pmod->drmdd->create_screen) ?
+      pmod->drmdd->create_screen(fd) : NULL;
+}
+
+int
+gallium_screen_create(struct gbm_gallium_drm_device *gdrm)
+{
+   gdrm->base.driver_name = drm_fd_get_screen_name(gdrm->base.base.fd);
+   if (gdrm->base.driver_name == NULL)
+      return -1;
+
+   gdrm->screen = create_drm_screen(gdrm->base.driver_name, gdrm->base.base.fd);
+   if (gdrm->screen == NULL) {
+      debug_printf("failed to load driver: %s\n", gdrm->base.driver_name);
+      return -1;
+   };
+
+   return 0;
+}
+
+GBM_EXPORT struct gbm_backend gbm_backend = {
+   .backend_name = "gallium_drm",
+   .create_device = gbm_gallium_drm_device_create,
+};
diff --git a/src/gallium/targets/gbm/pipe_loader.c b/src/gallium/targets/gbm/pipe_loader.c
new file mode 100644 (file)
index 0000000..6200541
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Kristian Høgsberg <krh@bitplanet.net>
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#include <stdio.h>
+#include "util/u_string.h"
+#include "util/u_memory.h"
+
+#include <libudev.h>
+
+#include "gbm_gallium_drmint.h"
+#include "pipe_loader.h"
+#define DRIVER_MAP_GALLIUM_ONLY
+#include "pci_ids/pci_id_driver_map.h"
+
+static struct pipe_module pipe_modules[16];
+
+static INLINE char *
+loader_strdup(const char *str)
+{
+   return mem_dup(str, strlen(str) + 1);
+}
+
+char *
+drm_fd_get_screen_name(int fd)
+{
+   struct udev *udev;
+   struct udev_device *device, *parent;
+   const char *pci_id;
+   char *driver = NULL;
+   int vendor_id, chip_id, i, j;
+
+   udev = udev_new();
+   device = _gbm_udev_device_new_from_fd(udev, fd);
+   if (device == NULL)
+      return NULL;
+
+   parent = udev_device_get_parent(device);
+   if (parent == NULL) {
+      fprintf(stderr, "gbm: could not get parent device");
+      goto out;
+   }
+
+   pci_id = udev_device_get_property_value(parent, "PCI_ID");
+   if (pci_id == NULL ||
+       sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
+      fprintf(stderr, "gbm: malformed or no PCI ID");
+      goto out;
+   }
+
+   for (i = 0; driver_map[i].driver; i++) {
+      if (vendor_id != driver_map[i].vendor_id)
+         continue;
+      if (driver_map[i].num_chips_ids == -1) {
+         driver = loader_strdup(driver_map[i].driver);
+         _gbm_log("pci id for %d: %04x:%04x, driver %s",
+                  fd, vendor_id, chip_id, driver);
+         goto out;
+      }
+
+      for (j = 0; j < driver_map[i].num_chips_ids; j++)
+         if (driver_map[i].chip_ids[j] == chip_id) {
+            driver = loader_strdup(driver_map[i].driver);
+            _gbm_log("pci id for %d: %04x:%04x, driver %s",
+                     fd, vendor_id, chip_id, driver);
+            goto out;
+         }
+   }
+
+out:
+   udev_device_unref(device);
+   udev_unref(udev);
+
+   return driver;
+}
+
+static void
+find_pipe_module(struct pipe_module *pmod, const char *name)
+{
+   char *search_paths, *end, *next, *p;
+   char path[PATH_MAX];
+   int ret;
+   
+   search_paths = NULL;
+   if (geteuid() == getuid()) {
+      /* don't allow setuid apps to use GBM_BACKENDS_PATH */
+      search_paths = getenv("GBM_BACKENDS_PATH");
+   }
+   if (search_paths == NULL)
+      search_paths = GBM_BACKEND_SEARCH_DIR;
+
+   end = search_paths + strlen(search_paths);
+   for (p = search_paths; p < end && pmod->lib == NULL; p = next + 1) {
+      int len;
+      next = strchr(p, ':');
+      if (next == NULL)
+         next = end;
+
+      len = next - p;
+
+      if (len) {
+         ret = util_snprintf(path, sizeof(path),
+                             "%.*s/" PIPE_PREFIX "%s" UTIL_DL_EXT, len, p, pmod->name);
+      }
+      else {
+         ret = util_snprintf(path, sizeof(path),
+                             PIPE_PREFIX "%s" UTIL_DL_EXT, pmod->name);
+      }
+      if (ret > 0 && ret < sizeof(path)) {
+         pmod->lib = util_dl_open(path);
+         debug_printf("loaded %s\n", path);
+      }
+
+   }
+}
+
+static boolean
+load_pipe_module(struct pipe_module *pmod, const char *name)
+{
+   pmod->name = loader_strdup(name);
+   if (!pmod->name)
+      return FALSE;
+
+   find_pipe_module(pmod, name);
+
+   if (pmod->lib) {
+      pmod->drmdd = (const struct drm_driver_descriptor *)
+         util_dl_get_proc_address(pmod->lib, "driver_descriptor");
+
+      /* sanity check on the name */
+      if (pmod->drmdd && strcmp(pmod->drmdd->name, pmod->name) != 0)
+         pmod->drmdd = NULL;
+
+      if (!pmod->drmdd) {
+         util_dl_close(pmod->lib);
+         pmod->lib = NULL;
+      }
+   }
+
+   return (pmod->drmdd != NULL);
+}
+
+struct pipe_module *
+get_pipe_module(const char *name)
+{
+   struct pipe_module *pmod = NULL;
+   int i;
+
+   if (!name)
+      return NULL;
+
+   for (i = 0; i < Elements(pipe_modules); i++) {
+      if (!pipe_modules[i].initialized ||
+          strcmp(pipe_modules[i].name, name) == 0) {
+         pmod = &pipe_modules[i];
+         break;
+      }
+   }
+   if (!pmod)
+      return NULL;
+
+   if (!pmod->initialized) {
+      load_pipe_module(pmod, name);
+      pmod->initialized = TRUE;
+   }
+
+   return pmod;
+}
diff --git a/src/gallium/targets/gbm/pipe_loader.h b/src/gallium/targets/gbm/pipe_loader.h
new file mode 100644 (file)
index 0000000..2e4cd99
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#ifndef _PIPE_LOADER_H_
+#define _PIPE_LOADER_H_
+
+#include "pipe/p_compiler.h"
+#include "util/u_dl.h"
+#include "state_tracker/drm_driver.h"
+
+struct pipe_module {
+   boolean initialized;
+   char *name;
+   struct util_dl_library *lib;
+   const struct drm_driver_descriptor *drmdd;
+};
+
+struct pipe_module *
+get_pipe_module(const char *name);
+
+char *
+drm_fd_get_screen_name(int fd);
+
+#endif
index 53a6c33..f8f6c81 100644 (file)
@@ -55,6 +55,7 @@ LIBS = \
 
 # LLVM
 ifeq ($(MESA_LLVM),1)
+PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
 DEFINES += -DGALLIUM_LLVMPIPE
 GL_LIB_DEPS += $(LLVM_LIBS) 
 LDFLAGS += $(LLVM_LDFLAGS)
index ca15372..ad8b099 100644 (file)
@@ -48,14 +48,17 @@ if False:
     env.Append(CPPDEFINES = 'GALLIUM_CELL')
     env.Prepend(LIBS = [cell])
 
-# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
-libgl = env.SharedLibrary(
+# libGL.so.1.5
+libgl_1_5 = env.SharedLibrary(
     target ='GL',
     source = sources,
+    SHLIBSUFFIX = env['SHLIBSUFFIX'] + '.1.5',
 )
 
-if True:
-    # XXX: Only install this libGL.so if DRI not enabled
-    libgl = env.InstallSharedLibrary(libgl, version=(1, 5))
+# libGL.so.1
+libgl = env.subst('${SHLIBPREFIX}GL${SHLIBSUFFIX}')
+libgl_1 = libgl + '.1'
+env.Command(libgl_1, libgl_1_5, "ln -sf ${SOURCE.file} ${TARGET}")
+env.Command(libgl, libgl_1, "ln -sf ${SOURCE.file} ${TARGET}")
 
 env.Alias('libgl-xlib', libgl)
diff --git a/src/gallium/targets/va-r300/Makefile b/src/gallium/targets/va-r300/Makefile
new file mode 100644 (file)
index 0000000..c4b8fe7
--- /dev/null
@@ -0,0 +1,26 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = r300_drv_video
+
+DRIVER_DEFINES = -DGALLIUM_SOFTPIPE
+DRIVER_INCLUDES =
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/drivers/r300/libr300.a \
+       $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
+        $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+        $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+C_SOURCES = \
+       target.c \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+DRIVER_LIBS = $(shell pkg-config libdrm --libs) -lXfixes
+
+include ../Makefile.va
+
+symlinks:
diff --git a/src/gallium/targets/va-r300/target.c b/src/gallium/targets/va-r300/target.c
new file mode 100644 (file)
index 0000000..9f673bf
--- /dev/null
@@ -0,0 +1,24 @@
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r300/r300_public.h"
+
+static struct pipe_screen *create_screen(int fd)
+{
+   struct radeon_winsys *radeon;
+   struct pipe_screen *screen;
+
+   radeon = radeon_drm_winsys_create(fd);
+   if (!radeon)
+      return NULL;
+
+   screen = r300_screen_create(radeon);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("r300", "radeon", create_screen)
diff --git a/src/gallium/targets/va-r600/Makefile b/src/gallium/targets/va-r600/Makefile
new file mode 100644 (file)
index 0000000..28797ad
--- /dev/null
@@ -0,0 +1,26 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = r600_drv_video
+
+DRIVER_DEFINES = -DGALLIUM_SOFTPIPE
+DRIVER_INCLUDES =
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/drivers/r600/libr600.a \
+       $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
+        $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+        $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+C_SOURCES = \
+       target.c \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+DRIVER_LIBS = $(shell pkg-config libdrm --libs) -lXfixes
+
+include ../Makefile.va
+
+symlinks:
diff --git a/src/gallium/targets/va-r600/target.c b/src/gallium/targets/va-r600/target.c
new file mode 100644 (file)
index 0000000..8753e2b
--- /dev/null
@@ -0,0 +1,24 @@
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "r600/drm/r600_drm_public.h"
+#include "r600/r600_public.h"
+
+static struct pipe_screen *create_screen(int fd)
+{
+   struct radeon *radeon;
+   struct pipe_screen *screen;
+
+   radeon = r600_drm_winsys_create(fd);
+   if (!radeon)
+      return NULL;
+
+   screen = r600_screen_create(radeon);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("r600", "radeon", create_screen)
diff --git a/src/gallium/targets/va-softpipe/Makefile b/src/gallium/targets/va-softpipe/Makefile
new file mode 100644 (file)
index 0000000..a58df36
--- /dev/null
@@ -0,0 +1,21 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = softpipe_drv_video
+
+DRIVER_DEFINES = -DGALLIUM_SOFTPIPE
+DRIVER_INCLUDES =
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+C_SOURCES = \
+       $(TOP)/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
+
+DRIVER_LIBS =
+
+include ../Makefile.va
+
+symlinks:
diff --git a/src/gallium/targets/vdpau-r300/Makefile b/src/gallium/targets/vdpau-r300/Makefile
new file mode 100644 (file)
index 0000000..fd4110b
--- /dev/null
@@ -0,0 +1,27 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = vdpau_r300
+
+
+PIPE_DRIVERS = \
+        $(TOP)/src/gallium/drivers/r300/libr300.a \
+       $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
+        $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+        $(TOP)/src/gallium/drivers/rbug/librbug.a \
+        $(TOP)/src/gallium/drivers/trace/libtrace.a \
+        $(TOP)/src/gallium/drivers/galahad/libgalahad.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a \
+       $(TOP)/src/mesa/libmesagallium.a
+
+C_SOURCES = \
+       target.c \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+DRIVER_LIBS = $(shell pkg-config libdrm --libs) -lXfixes
+
+include ../Makefile.vdpau
+
+symlinks:
diff --git a/src/gallium/targets/vdpau-r300/target.c b/src/gallium/targets/vdpau-r300/target.c
new file mode 100644 (file)
index 0000000..9f673bf
--- /dev/null
@@ -0,0 +1,24 @@
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r300/r300_public.h"
+
+static struct pipe_screen *create_screen(int fd)
+{
+   struct radeon_winsys *radeon;
+   struct pipe_screen *screen;
+
+   radeon = radeon_drm_winsys_create(fd);
+   if (!radeon)
+      return NULL;
+
+   screen = r300_screen_create(radeon);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("r300", "radeon", create_screen)
diff --git a/src/gallium/targets/vdpau-r600/Makefile b/src/gallium/targets/vdpau-r600/Makefile
new file mode 100644 (file)
index 0000000..0fd817b
--- /dev/null
@@ -0,0 +1,22 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = vdpau_r600
+
+PIPE_DRIVERS = \
+        $(TOP)/src/gallium/drivers/r600/libr600.a \
+       $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
+        $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+        $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+C_SOURCES = \
+       target.c \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+DRIVER_LIBS = $(shell pkg-config libdrm --libs) -lXfixes
+
+include ../Makefile.vdpau
+
+symlinks:
diff --git a/src/gallium/targets/vdpau-r600/target.c b/src/gallium/targets/vdpau-r600/target.c
new file mode 100644 (file)
index 0000000..8753e2b
--- /dev/null
@@ -0,0 +1,24 @@
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "r600/drm/r600_drm_public.h"
+#include "r600/r600_public.h"
+
+static struct pipe_screen *create_screen(int fd)
+{
+   struct radeon *radeon;
+   struct pipe_screen *screen;
+
+   radeon = r600_drm_winsys_create(fd);
+   if (!radeon)
+      return NULL;
+
+   screen = r600_screen_create(radeon);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("r600", "radeon", create_screen)
diff --git a/src/gallium/targets/vdpau-softpipe/Makefile b/src/gallium/targets/vdpau-softpipe/Makefile
new file mode 100644 (file)
index 0000000..139b01b
--- /dev/null
@@ -0,0 +1,21 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = vdpau_softpipe
+
+DRIVER_DEFINES = -DGALLIUM_SOFTPIPE
+DRIVER_INCLUDES =
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+C_SOURCES = \
+       $(TOP)/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
+
+DRIVER_LIBS =
+
+include ../Makefile.vdpau
+
+symlinks:
diff --git a/src/gallium/targets/xa-vmwgfx/Makefile b/src/gallium/targets/xa-vmwgfx/Makefile
new file mode 100644 (file)
index 0000000..fecdba6
--- /dev/null
@@ -0,0 +1,101 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+##### MACROS #####
+
+XA_MAJOR = 0
+XA_MINOR = 4
+XA_TINY = 0
+XA_CFLAGS = -g -fPIC
+
+XA_INCLUDES= -I$(TOP)/src/gallium/ \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/winsys \
+       -I$(TOP)/src/gallium/drivers
+
+XA_LIB = xatracker
+XA_LIB_NAME = lib$(XA_LIB).so
+XA_LIB_GLOB = lib$(XA_LIB)*.so*
+XA_LIB_DEPS = \
+       $(TOP)/src/gallium/state_trackers/xa/libxatracker.o \
+       $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/rbug/librbug.a
+
+
+COMMON_GALLIUM_SOURCES=
+
+SOURCES = vmw_target.c
+OBJECTS = $(SOURCES:.c=.o)
+
+ifeq ($(MESA_LLVM),1)
+LDFLAGS += $(LLVM_LDFLAGS)
+GALLIUM_AUXILIARIES += $(LLVM_LIBS)
+else
+LDFLAGS += -lstdc++
+endif
+
+##### RULES #####
+
+.c.o:
+       $(CC) -c $(XA_CFLAGS) $(XA_INCLUDES) $<
+
+
+##### TARGETS #####
+
+default: $(TOP)/$(LIB_DIR)/gallium/$(XA_LIB_NAME)
+
+
+# Make the library
+$(TOP)/$(LIB_DIR)/gallium/$(XA_LIB_NAME): depend $(OBJECTS) $(XA_LIB_DEPS)
+       $(MKLIB) -o $(XA_LIB) -linker $(CC) -ldflags '$(LDFLAGS)' \
+               -major $(XA_MAJOR) -minor $(XA_MINOR) -patch $(XA_TINY) \
+               $(MKLIB_OPTIONS) \
+               -exports $(TOP)/src/gallium/state_trackers/xa/xa_symbols\
+                -install $(TOP)/$(LIB_DIR)/gallium \
+               $(OBJECTS) $(XA_LIB_DEPS) $(GALLIUM_AUXILIARIES)
+
+# xa pkgconfig file
+pcedit = sed \
+       -e 's,@INSTALL_DIR@,$(INSTALL_DIR),g' \
+       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),g' \
+       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),g' \
+       -e 's,@VERSION@,$(XA_MAJOR).$(XA_MINOR).$(XA_TINY),g' \
+       -e 's,@XA_PC_REQ_PRIV@,$(XA_PC_REQ_PRIV),g' \
+       -e 's,@XA_PC_LIB_PRIV@,$(XA_PC_LIB_PRIV),g' \
+       -e 's,@XA_PC_CFLAGS@,$(XA_PC_CFLAGS),g' \
+       -e 's,@XA_LIB@,$(XA_LIB),g'
+xatracker.pc: xatracker.pc.in
+       $(pcedit) $< > $@
+
+install: xatracker.pc
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+       $(INSTALL) -m 644 $(TOP)/src/gallium/state_trackers/xa/xa_tracker.h $(DESTDIR)$(INSTALL_INC_DIR)
+       $(INSTALL) -m 644 $(TOP)/src/gallium/state_trackers/xa/xa_context.h $(DESTDIR)$(INSTALL_INC_DIR)
+       $(INSTALL) -m 644 $(TOP)/src/gallium/state_trackers/xa/xa_composite.h $(DESTDIR)$(INSTALL_INC_DIR)
+       $(MINSTALL) -m 755 $(TOP)/$(LIB_DIR)/gallium/$(XA_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -m 644 xatracker.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+
+clean:
+       -rm -f *.o *~
+       -rm -f *.lo
+       -rm -f *.la
+       -rm -f *.pc
+       -rm -rf .libs
+       -rm -f depend depend.bak exptmp
+
+
+depend: $(SOURCES)
+       @ echo "running $(MKDEP)"
+       @ rm -f depend
+       @ touch depend
+       @ $(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(XA_INCLUDES) $(SOURCES) \
+               > /dev/null
+
+-include depend
+
+FORCE:
diff --git a/src/gallium/targets/xa-vmwgfx/vmw_target.c b/src/gallium/targets/xa-vmwgfx/vmw_target.c
new file mode 100644 (file)
index 0000000..15089d6
--- /dev/null
@@ -0,0 +1,26 @@
+
+#include "target-helpers/inline_debug_helper.h"
+#include "state_tracker/drm_driver.h"
+#include "svga/drm/svga_drm_public.h"
+#include "svga/svga_public.h"
+
+static struct pipe_screen *
+create_screen(int fd)
+{
+   struct svga_winsys_screen *sws;
+   struct pipe_screen *screen;
+
+   sws = svga_drm_winsys_screen_create(fd);
+   if (!sws)
+      return NULL;
+
+   screen = svga_screen_create(sws);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("vmwgfx", "vmwgfx", create_screen)
diff --git a/src/gallium/targets/xa-vmwgfx/xatracker.pc.in b/src/gallium/targets/xa-vmwgfx/xatracker.pc.in
new file mode 100644 (file)
index 0000000..4ea2f40
--- /dev/null
@@ -0,0 +1,13 @@
+prefix=@INSTALL_DIR@
+exec_prefix=${prefix}
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+
+Name: xatracker
+Description: Xorg Gallium3D acceleration library
+Requires:
+Requires.private: @XA_PC_REQ_PRIV@
+Version: @VERSION@
+Libs: -L${libdir} -l@XA_LIB@
+Libs.private: @XA_PC_LIB_PRIV@
+Cflags: -I${includedir} @XA_PC_CFLAGS@
index 5a2cdb1..755969c 100644 (file)
@@ -1,7 +1,7 @@
 TOP = ../../../..
 include $(TOP)/configs/current
 
-LIBNAME = modesetting_drv.so
+LIBNAME = nouveau2_drv.so
 
 C_SOURCES = \
        nouveau_target.c \
@@ -23,4 +23,7 @@ DRIVER_PIPES = \
 DRIVER_LINKS = \
        $(shell pkg-config --libs libdrm libdrm_nouveau)
 
+DRIVER_INCLUDES = \
+       $(shell pkg-config --cflags-only-I libdrm libdrm_nouveau xf86driproto)
+
 include ../Makefile.xorg
index f0d6492..43470a1 100644 (file)
@@ -29,6 +29,9 @@
  */
 
 #include "../../state_trackers/xorg/xorg_winsys.h"
+#include <nouveau_drmif.h>
+#include <xorg/dri.h>
+#include <xf86drmMode.h>
 
 static void nouveau_xorg_identify(int flags);
 static Bool nouveau_xorg_pci_probe(DriverPtr driver, int entity_num,
@@ -38,23 +41,16 @@ static Bool nouveau_xorg_pci_probe(DriverPtr driver, int entity_num,
 static const struct pci_id_match nouveau_xorg_device_match[] = {
     { 0x10de, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
       0x00030000, 0x00ffffff, 0 },
-    { 0x12d2, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
-      0x00030000, 0x00ffffff, 0 },
     {0, 0, 0},
 };
 
-static SymTabRec nouveau_xorg_chipsets[] = {
-    {PCI_MATCH_ANY, "NVIDIA Graphics Device"},
-    {-1, NULL}
-};
-
 static PciChipsets nouveau_xorg_pci_devices[] = {
     {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
     {-1, -1, NULL}
 };
 
 static XF86ModuleVersionInfo nouveau_xorg_version = {
-    "modesetting",
+    "nouveau2",
     MODULEVENDORSTRING,
     MODINFOSTRING1,
     MODINFOSTRING2,
@@ -70,9 +66,9 @@ static XF86ModuleVersionInfo nouveau_xorg_version = {
  * Xorg driver exported structures
  */
 
-_X_EXPORT DriverRec modesetting = {
+_X_EXPORT DriverRec nouveau2 = {
     1,
-    "modesetting",
+    "nouveau2",
     nouveau_xorg_identify,
     NULL,
     xorg_tracker_available_options,
@@ -85,7 +81,7 @@ _X_EXPORT DriverRec modesetting = {
 
 static MODULESETUPPROTO(nouveau_xorg_setup);
 
-_X_EXPORT XF86ModuleData modesettingModuleData = {
+_X_EXPORT XF86ModuleData nouveau2ModuleData = {
     &nouveau_xorg_version,
     nouveau_xorg_setup,
     NULL
@@ -104,7 +100,7 @@ nouveau_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
      */
     if (!setupDone) {
        setupDone = 1;
-       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+       xf86AddDriver(&nouveau2, module, HaveDriverFuncs);
 
        /*
         * The return value must be non-NULL on success even though there
@@ -121,8 +117,7 @@ nouveau_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
 static void
 nouveau_xorg_identify(int flags)
 {
-    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
-                     nouveau_xorg_chipsets);
+    xf86DrvMsg(0, X_INFO, "nouveau2: Gallium3D based 2D driver for NV30+ NVIDIA chipsets\n");
 }
 
 static Bool
@@ -131,13 +126,63 @@ nouveau_xorg_pci_probe(DriverPtr driver,
 {
     ScrnInfoPtr scrn = NULL;
     EntityInfoPtr entity;
+    struct nouveau_device *dev = NULL;
+    char *busid;
+    int chipset, ret;
+
+    if (device->vendor_id != 0x10DE)
+       return FALSE;
+
+    if (!xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
+       xf86DrvMsg(-1, X_ERROR, "[drm] No DRICreatePCIBusID symbol\n");
+       return FALSE;
+    }
+    busid = DRICreatePCIBusID(device);
+
+    ret = nouveau_device_open(&dev, busid);
+    if (ret) {
+       xf86DrvMsg(-1, X_ERROR, "[drm] failed to open device\n");
+       free(busid);
+       return FALSE;
+    }
+
+    chipset = dev->chipset;
+    nouveau_device_close(&dev);
+
+    ret = drmCheckModesettingSupported(busid);
+    free(busid);
+    if (ret) {
+       xf86DrvMsg(-1, X_ERROR, "[drm] KMS not enabled\n");
+       return FALSE;
+    }
+
+    switch (chipset & 0xf0) {
+    case 0x00:
+    case 0x10:
+    case 0x20:
+       xf86DrvMsg(-1, X_NOTICE, "Too old chipset: NV%02x\n", chipset);
+       return FALSE;
+    case 0x30:
+    case 0x40:
+    case 0x60:
+    case 0x50:
+    case 0x80:
+    case 0x90:
+    case 0xa0:
+    case 0xc0:
+       xf86DrvMsg(-1, X_INFO, "Detected chipset: NV%02x\n", chipset);
+       break;
+    default:
+       xf86DrvMsg(-1, X_ERROR, "Unknown chipset: NV%02x\n", chipset);
+       return FALSE;
+    }
 
     scrn = xf86ConfigPciEntity(scrn, 0, entity_num, nouveau_xorg_pci_devices,
                               NULL, NULL, NULL, NULL, NULL);
     if (scrn != NULL) {
        scrn->driverVersion = 1;
        scrn->driverName = "nouveau";
-       scrn->name = "modesetting";
+       scrn->name = "nouveau2";
        scrn->Probe = NULL;
 
        entity = xf86GetEntityInfo(entity_num);
index 099d49c..41f4326 100644 (file)
@@ -4,10 +4,10 @@ Import('*')
 
 env = env.Clone()
 
-env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server')
+env.PkgUseModules(['DRM', 'XORG'])
 
 if env['kms']:
-    env.ParseConfig('pkg-config --cflags --libs libkms')
+    env.PkgUseModules(['KMS'])
 
 env.Prepend(CPPPATH = [
     '#/include',
diff --git a/src/gallium/targets/xvmc-nouveau/Makefile b/src/gallium/targets/xvmc-nouveau/Makefile
new file mode 100644 (file)
index 0000000..e1aadbf
--- /dev/null
@@ -0,0 +1,26 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = XvMCnouveau
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
+       $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
+       $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
+       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
+       $(TOP)/src/gallium/drivers/nvc0/libnvc0.a \
+       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+
+C_SOURCES = \
+       target.c \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+DRIVER_LIBS = $(shell pkg-config libdrm_nouveau --libs) -lXfixes
+
+include ../Makefile.xvmc
+
+symlinks:
diff --git a/src/gallium/targets/xvmc-nouveau/target.c b/src/gallium/targets/xvmc-nouveau/target.c
new file mode 100644 (file)
index 0000000..9b61b03
--- /dev/null
@@ -0,0 +1,18 @@
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "nouveau/drm/nouveau_drm_public.h"
+
+static struct pipe_screen *create_screen(int fd)
+{
+   struct pipe_screen *screen;
+
+   screen = nouveau_drm_screen_create(fd);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("nouveau", "nouveau", create_screen)
diff --git a/src/gallium/targets/xvmc-r300/Makefile b/src/gallium/targets/xvmc-r300/Makefile
new file mode 100644 (file)
index 0000000..a427fe1
--- /dev/null
@@ -0,0 +1,22 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = XvMCr300
+
+PIPE_DRIVERS = \
+        $(TOP)/src/gallium/drivers/r300/libr300.a \
+       $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
+        $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+        $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+C_SOURCES = \
+       target.c \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+DRIVER_LIBS = $(shell pkg-config libdrm --libs) -lXfixes
+
+include ../Makefile.xvmc
+
+symlinks:
diff --git a/src/gallium/targets/xvmc-r300/target.c b/src/gallium/targets/xvmc-r300/target.c
new file mode 100644 (file)
index 0000000..9f673bf
--- /dev/null
@@ -0,0 +1,24 @@
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r300/r300_public.h"
+
+static struct pipe_screen *create_screen(int fd)
+{
+   struct radeon_winsys *radeon;
+   struct pipe_screen *screen;
+
+   radeon = radeon_drm_winsys_create(fd);
+   if (!radeon)
+      return NULL;
+
+   screen = r300_screen_create(radeon);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("r300", "radeon", create_screen)
diff --git a/src/gallium/targets/xvmc-r600/Makefile b/src/gallium/targets/xvmc-r600/Makefile
new file mode 100644 (file)
index 0000000..0bb72f1
--- /dev/null
@@ -0,0 +1,22 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = XvMCr600
+
+PIPE_DRIVERS = \
+        $(TOP)/src/gallium/drivers/r600/libr600.a \
+       $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
+        $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+        $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+C_SOURCES = \
+       target.c \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+DRIVER_LIBS = $(shell pkg-config libdrm --libs) -lXfixes
+
+include ../Makefile.xvmc
+
+symlinks:
diff --git a/src/gallium/targets/xvmc-r600/target.c b/src/gallium/targets/xvmc-r600/target.c
new file mode 100644 (file)
index 0000000..8753e2b
--- /dev/null
@@ -0,0 +1,24 @@
+#include "state_tracker/drm_driver.h"
+#include "target-helpers/inline_debug_helper.h"
+#include "r600/drm/r600_drm_public.h"
+#include "r600/r600_public.h"
+
+static struct pipe_screen *create_screen(int fd)
+{
+   struct radeon *radeon;
+   struct pipe_screen *screen;
+
+   radeon = r600_drm_winsys_create(fd);
+   if (!radeon)
+      return NULL;
+
+   screen = r600_screen_create(radeon);
+   if (!screen)
+      return NULL;
+
+   screen = debug_screen_wrap(screen);
+
+   return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("r600", "radeon", create_screen)
diff --git a/src/gallium/targets/xvmc-softpipe/Makefile b/src/gallium/targets/xvmc-softpipe/Makefile
new file mode 100644 (file)
index 0000000..5b60bed
--- /dev/null
@@ -0,0 +1,21 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBBASENAME = XvMCsoftpipe
+
+DRIVER_DEFINES = -DGALLIUM_SOFTPIPE
+DRIVER_INCLUDES =
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/auxiliary/libgallium.a
+
+C_SOURCES = \
+       $(TOP)/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
+
+DRIVER_LIBS =
+
+include ../Makefile.xvmc
+
+symlinks:
index 2ed6341..4ddbb0b 100644 (file)
@@ -1,4 +1,4 @@
-# progs/gallium/simple/Makefile
+# src/gallium/tests/trivial/Makefile
 
 TOP = ../../../..
 include $(TOP)/configs/current
@@ -11,7 +11,12 @@ INCLUDES = \
        -I$(TOP)/src/gallium/winsys \
        $(PROG_INCLUDES)
 
-LINKS = \
+ifeq ($(MESA_LLVM),1)
+LINKS = $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
+LDFLAGS += $(LLVM_LDFLAGS)
+endif
+
+LINKS += \
        $(TOP)/src/gallium/drivers/rbug/librbug.a \
        $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/galahad/libgalahad.a \
@@ -46,4 +51,4 @@ $(OBJECTS): %.o: %.c
        $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(PROG_DEFINES) $< -o $@
 
 $(PROGS): %: %.o $(LINKS)
-       $(CC) $(LDFLAGS) $< $(LINKS) -lm -lpthread -ldl -o $@
+       $(CXX) $(LDFLAGS) $< $(LINKS) $(LLVM_LIBS) -lm -lpthread -ldl -o $@
index 3a64b1c..6c38b10 100644 (file)
@@ -212,7 +212,7 @@ static void init_prog(struct program *p)
        p->sampler.mag_img_filter = PIPE_TEX_MIPFILTER_LINEAR;
        p->sampler.normalized_coords = 1;
 
-       surf_tmpl.format = templat.format;
+       surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */
        surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
        surf_tmpl.u.tex.level = 0;
        surf_tmpl.u.tex.first_layer = 0;
@@ -329,7 +329,7 @@ static void draw(struct program *p)
        /* vertex element data */
        cso_set_vertex_elements(p->cso, 2, p->velem);
 
-       util_draw_vertex_buffer(p->pipe,
+       util_draw_vertex_buffer(p->pipe, p->cso,
                                p->vbuf, 0,
                                PIPE_PRIM_QUADS,
                                4,  /* verts */
index bfd2f3c..656e92e 100644 (file)
@@ -153,7 +153,7 @@ static void init_prog(struct program *p)
        p->rasterizer.cull_face = PIPE_FACE_NONE;
        p->rasterizer.gl_rasterization_rules = 1;
 
-       surf_tmpl.format = templat.format;
+       surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM;
        surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
        surf_tmpl.u.tex.level = 0;
        surf_tmpl.u.tex.first_layer = 0;
@@ -258,7 +258,7 @@ static void draw(struct program *p)
        /* vertex element data */
        cso_set_vertex_elements(p->cso, 2, p->velem);
 
-       util_draw_vertex_buffer(p->pipe,
+       util_draw_vertex_buffer(p->pipe, p->cso,
                                p->vbuf, 0,
                                PIPE_PRIM_TRIANGLES,
                                3,  /* verts */
diff --git a/src/gallium/winsys/g3dvl/Makefile b/src/gallium/winsys/g3dvl/Makefile
new file mode 100644 (file)
index 0000000..6c793e0
--- /dev/null
@@ -0,0 +1,12 @@
+# src/gallium/winsys/Makefile
+TOP = ../../../..
+include $(TOP)/configs/current
+
+SUBDIRS = $(GALLIUM_STATE_TRACKERS_DIRS) $(GALLIUM_WINSYS_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/g3dvl/dri/Makefile b/src/gallium/winsys/g3dvl/dri/Makefile
new file mode 100644 (file)
index 0000000..b270e78
--- /dev/null
@@ -0,0 +1,15 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = vldri
+
+LIBRARY_INCLUDES = -I$(TOP)/src/gallium/winsys/g3dvl \
+                   $(shell pkg-config libdrm --cflags-only-I)
+
+C_SOURCES = \
+       driclient.c \
+       XF86dri.c \
+       dri2.c \
+       dri_winsys.c
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/g3dvl/dri/dri2.c b/src/gallium/winsys/g3dvl/dri/dri2.c
new file mode 100644 (file)
index 0000000..12ed6d0
--- /dev/null
@@ -0,0 +1,666 @@
+/*
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/dri2proto.h>
+#include "xf86drm.h"
+#include "dri2.h"
+#if 0
+#include "glxclient.h"
+#include "GL/glxext.h"
+#endif
+
+/* Allow the build to work with an older versions of dri2proto.h and
+ * dri2tokens.h.
+ */
+#if DRI2_MINOR < 1
+#undef DRI2_MINOR
+#define DRI2_MINOR 1
+#define X_DRI2GetBuffersWithFormat 7
+#endif
+
+
+static char dri2ExtensionName[] = DRI2_NAME;
+static XExtensionInfo *dri2Info;
+static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
+
+static Bool
+DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire);
+static Status
+DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire);
+
+static /* const */ XExtensionHooks dri2ExtensionHooks = {
+  NULL,                   /* create_gc */
+  NULL,                   /* copy_gc */
+  NULL,                   /* flush_gc */
+  NULL,                   /* free_gc */
+  NULL,                   /* create_font */
+  NULL,                   /* free_font */
+  DRI2CloseDisplay,       /* close_display */
+  DRI2WireToEvent,        /* wire_to_event */
+  DRI2EventToWire,        /* event_to_wire */
+  NULL,                   /* error */
+  NULL,                   /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay,
+                                   dri2Info,
+                                   dri2ExtensionName,
+                                   &dri2ExtensionHooks,
+                                   0, NULL)
+
+static Bool
+DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
+{
+#if 0
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   XExtDisplayInfo *glx_info = __glXFindDisplay(dpy);
+
+   XextCheckExtension(dpy, info, dri2ExtensionName, False);
+
+   switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
+
+#ifdef X_DRI2SwapBuffers
+   case DRI2_BufferSwapComplete:
+   {
+      GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
+      xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire;
+      aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
+      aevent->type =
+         (glx_info->codes->first_event + GLX_BufferSwapComplete) & 0x75;
+      aevent->send_event = (awire->type & 0x80) != 0;
+      aevent->display = dpy;
+      aevent->drawable = awire->drawable;
+      switch (awire->event_type) {
+      case DRI2_EXCHANGE_COMPLETE:
+        aevent->event_type = GLX_EXCHANGE_COMPLETE_INTEL;
+        break;
+      case DRI2_BLIT_COMPLETE:
+        aevent->event_type = GLX_BLIT_COMPLETE_INTEL;
+        break;
+      case DRI2_FLIP_COMPLETE:
+        aevent->event_type = GLX_FLIP_COMPLETE_INTEL;
+        break;
+      default:
+        /* unknown swap completion type */
+        return False;
+      }
+      aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
+      aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
+      aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo;
+      return True;
+   }
+#endif
+#ifdef DRI2_InvalidateBuffers
+   case DRI2_InvalidateBuffers:
+   {
+      xDRI2InvalidateBuffers *awire = (xDRI2InvalidateBuffers *)wire;
+
+      dri2InvalidateBuffers(dpy, awire->drawable);
+      return False;
+   }
+#endif
+   default:
+      /* client doesn't support server event */
+      break;
+   }
+#endif
+   return False;
+}
+
+/* We don't actually support this.  It doesn't make sense for clients to
+ * send each other DRI2 events.
+ */
+static Status
+DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+
+   XextCheckExtension(dpy, info, dri2ExtensionName, False);
+
+   switch (event->type) {
+   default:
+      /* client doesn't support server event */
+      break;
+   }
+
+   return Success;
+}
+
+Bool
+DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+
+   if (XextHasExtension(info)) {
+      *eventBase = info->codes->first_event;
+      *errorBase = info->codes->first_error;
+      return True;
+   }
+
+   return False;
+}
+
+Bool
+DRI2QueryVersion(Display * dpy, int *major, int *minor)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   xDRI2QueryVersionReply rep;
+   xDRI2QueryVersionReq *req;
+   int i, nevents;
+
+   XextCheckExtension(dpy, info, dri2ExtensionName, False);
+
+   LockDisplay(dpy);
+   GetReq(DRI2QueryVersion, req);
+   req->reqType = info->codes->major_opcode;
+   req->dri2ReqType = X_DRI2QueryVersion;
+   req->majorVersion = DRI2_MAJOR;
+   req->minorVersion = DRI2_MINOR;
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+   *major = rep.majorVersion;
+   *minor = rep.minorVersion;
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   switch (rep.minorVersion) {
+   case 1:
+          nevents = 0;
+          break;
+   case 2:
+          nevents = 1;
+          break;
+   case 3:
+   default:
+          nevents = 2;
+          break;
+   }
+
+   for (i = 0; i < nevents; i++) {
+       XESetWireToEvent (dpy, info->codes->first_event + i, DRI2WireToEvent);
+       XESetEventToWire (dpy, info->codes->first_event + i, DRI2EventToWire);
+   }
+
+   return True;
+}
+
+Bool
+DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   xDRI2ConnectReply rep;
+   xDRI2ConnectReq *req;
+
+   XextCheckExtension(dpy, info, dri2ExtensionName, False);
+
+   LockDisplay(dpy);
+   GetReq(DRI2Connect, req);
+   req->reqType = info->codes->major_opcode;
+   req->dri2ReqType = X_DRI2Connect;
+   req->window = window;
+   req->driverType = DRI2DriverDRI;
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+
+   if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+
+   *driverName = Xmalloc(rep.driverNameLength + 1);
+   if (*driverName == NULL) {
+      _XEatData(dpy,
+                ((rep.driverNameLength + 3) & ~3) +
+                ((rep.deviceNameLength + 3) & ~3));
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+   _XReadPad(dpy, *driverName, rep.driverNameLength);
+   (*driverName)[rep.driverNameLength] = '\0';
+
+   *deviceName = Xmalloc(rep.deviceNameLength + 1);
+   if (*deviceName == NULL) {
+      Xfree(*driverName);
+      _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+   _XReadPad(dpy, *deviceName, rep.deviceNameLength);
+   (*deviceName)[rep.deviceNameLength] = '\0';
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return True;
+}
+
+Bool
+DRI2Authenticate(Display * dpy, XID window, drm_magic_t magic)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   xDRI2AuthenticateReq *req;
+   xDRI2AuthenticateReply rep;
+
+   XextCheckExtension(dpy, info, dri2ExtensionName, False);
+
+   LockDisplay(dpy);
+   GetReq(DRI2Authenticate, req);
+   req->reqType = info->codes->major_opcode;
+   req->dri2ReqType = X_DRI2Authenticate;
+   req->window = window;
+   req->magic = magic;
+
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return rep.authenticated;
+}
+
+void
+DRI2CreateDrawable(Display * dpy, XID drawable)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   xDRI2CreateDrawableReq *req;
+
+   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
+
+   LockDisplay(dpy);
+   GetReq(DRI2CreateDrawable, req);
+   req->reqType = info->codes->major_opcode;
+   req->dri2ReqType = X_DRI2CreateDrawable;
+   req->drawable = drawable;
+   UnlockDisplay(dpy);
+   SyncHandle();
+}
+
+void
+DRI2DestroyDrawable(Display * dpy, XID drawable)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   xDRI2DestroyDrawableReq *req;
+
+   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
+
+   XSync(dpy, False);
+
+   LockDisplay(dpy);
+   GetReq(DRI2DestroyDrawable, req);
+   req->reqType = info->codes->major_opcode;
+   req->dri2ReqType = X_DRI2DestroyDrawable;
+   req->drawable = drawable;
+   UnlockDisplay(dpy);
+   SyncHandle();
+}
+
+DRI2Buffer *
+DRI2GetBuffers(Display * dpy, XID drawable,
+               int *width, int *height,
+               unsigned int *attachments, int count, int *outCount)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   xDRI2GetBuffersReply rep;
+   xDRI2GetBuffersReq *req;
+   DRI2Buffer *buffers;
+   xDRI2Buffer repBuffer;
+   CARD32 *p;
+   int i;
+
+   XextCheckExtension(dpy, info, dri2ExtensionName, False);
+
+   LockDisplay(dpy);
+   GetReqExtra(DRI2GetBuffers, count * 4, req);
+   req->reqType = info->codes->major_opcode;
+   req->dri2ReqType = X_DRI2GetBuffers;
+   req->drawable = drawable;
+   req->count = count;
+   p = (CARD32 *) & req[1];
+   for (i = 0; i < count; i++)
+      p[i] = attachments[i];
+
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return NULL;
+   }
+
+   *width = rep.width;
+   *height = rep.height;
+   *outCount = rep.count;
+
+   buffers = Xmalloc(rep.count * sizeof buffers[0]);
+   if (buffers == NULL) {
+      _XEatData(dpy, rep.count * sizeof repBuffer);
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return NULL;
+   }
+
+   for (i = 0; i < rep.count; i++) {
+      _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
+      buffers[i].attachment = repBuffer.attachment;
+      buffers[i].name = repBuffer.name;
+      buffers[i].pitch = repBuffer.pitch;
+      buffers[i].cpp = repBuffer.cpp;
+      buffers[i].flags = repBuffer.flags;
+   }
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return buffers;
+}
+
+
+DRI2Buffer *
+DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
+                         int *width, int *height,
+                         unsigned int *attachments, int count, int *outCount)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   xDRI2GetBuffersReply rep;
+   xDRI2GetBuffersReq *req;
+   DRI2Buffer *buffers;
+   xDRI2Buffer repBuffer;
+   CARD32 *p;
+   int i;
+
+   XextCheckExtension(dpy, info, dri2ExtensionName, False);
+
+   LockDisplay(dpy);
+   GetReqExtra(DRI2GetBuffers, count * (4 * 2), req);
+   req->reqType = info->codes->major_opcode;
+   req->dri2ReqType = X_DRI2GetBuffersWithFormat;
+   req->drawable = drawable;
+   req->count = count;
+   p = (CARD32 *) & req[1];
+   for (i = 0; i < (count * 2); i++)
+      p[i] = attachments[i];
+
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return NULL;
+   }
+
+   *width = rep.width;
+   *height = rep.height;
+   *outCount = rep.count;
+
+   buffers = Xmalloc(rep.count * sizeof buffers[0]);
+   if (buffers == NULL) {
+      _XEatData(dpy, rep.count * sizeof repBuffer);
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return NULL;
+   }
+
+   for (i = 0; i < rep.count; i++) {
+      _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
+      buffers[i].attachment = repBuffer.attachment;
+      buffers[i].name = repBuffer.name;
+      buffers[i].pitch = repBuffer.pitch;
+      buffers[i].cpp = repBuffer.cpp;
+      buffers[i].flags = repBuffer.flags;
+   }
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return buffers;
+}
+
+
+void
+DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
+               CARD32 dest, CARD32 src)
+{
+   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   xDRI2CopyRegionReq *req;
+
+   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
+
+   LockDisplay(dpy);
+   GetReq(DRI2CopyRegion, req);
+   req->reqType = info->codes->major_opcode;
+   req->dri2ReqType = X_DRI2CopyRegion;
+   req->drawable = drawable;
+   req->region = region;
+   req->dest = dest;
+   req->src = src;
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+}
+
+#ifdef X_DRI2SwapBuffers
+static void
+load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor,
+            CARD64 remainder)
+{
+    req->target_msc_hi = target >> 32;
+    req->target_msc_lo = target & 0xffffffff;
+    req->divisor_hi = divisor >> 32;
+    req->divisor_lo = divisor & 0xffffffff;
+    req->remainder_hi = remainder >> 32;
+    req->remainder_lo = remainder & 0xffffffff;
+}
+
+static CARD64
+vals_to_card64(CARD32 lo, CARD32 hi)
+{
+    return (CARD64)hi << 32 | lo;
+}
+
+void DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc,
+                    CARD64 divisor, CARD64 remainder, CARD64 *count)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2SwapBuffersReq *req;
+    xDRI2SwapBuffersReply rep;
+
+    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+    LockDisplay(dpy);
+    GetReq(DRI2SwapBuffers, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2SwapBuffers;
+    req->drawable = drawable;
+    load_swap_req(req, target_msc, divisor, remainder);
+
+    _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
+    *count = vals_to_card64(rep.swap_lo, rep.swap_hi);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+#endif
+
+#ifdef X_DRI2GetMSC
+Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc,
+               CARD64 *sbc)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2GetMSCReq *req;
+    xDRI2MSCReply rep;
+
+    XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2GetMSC, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2GetMSC;
+    req->drawable = drawable;
+
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+
+    *ust = vals_to_card64(rep.ust_lo, rep.ust_hi);
+    *msc = vals_to_card64(rep.msc_lo, rep.msc_hi);
+    *sbc = vals_to_card64(rep.sbc_lo, rep.sbc_hi);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return True;
+}
+#endif
+
+#ifdef X_DRI2WaitMSC
+static void
+load_msc_req(xDRI2WaitMSCReq *req, CARD64 target, CARD64 divisor,
+            CARD64 remainder)
+{
+    req->target_msc_hi = target >> 32;
+    req->target_msc_lo = target & 0xffffffff;
+    req->divisor_hi = divisor >> 32;
+    req->divisor_lo = divisor & 0xffffffff;
+    req->remainder_hi = remainder >> 32;
+    req->remainder_lo = remainder & 0xffffffff;
+}
+
+Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
+                CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2WaitMSCReq *req;
+    xDRI2MSCReply rep;
+
+    XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2WaitMSC, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2WaitMSC;
+    req->drawable = drawable;
+    load_msc_req(req, target_msc, divisor, remainder);
+
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+
+    *ust = ((CARD64)rep.ust_hi << 32) | (CARD64)rep.ust_lo;
+    *msc = ((CARD64)rep.msc_hi << 32) | (CARD64)rep.msc_lo;
+    *sbc = ((CARD64)rep.sbc_hi << 32) | (CARD64)rep.sbc_lo;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return True;
+}
+#endif
+
+#ifdef X_DRI2WaitSBC
+static void
+load_sbc_req(xDRI2WaitSBCReq *req, CARD64 target)
+{
+    req->target_sbc_hi = target >> 32;
+    req->target_sbc_lo = target & 0xffffffff;
+}
+
+Bool DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
+                CARD64 *msc, CARD64 *sbc)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2WaitSBCReq *req;
+    xDRI2MSCReply rep;
+
+    XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2WaitSBC, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2WaitSBC;
+    req->drawable = drawable;
+    load_sbc_req(req, target_sbc);
+
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+
+    *ust = ((CARD64)rep.ust_hi << 32) | rep.ust_lo;
+    *msc = ((CARD64)rep.msc_hi << 32) | rep.msc_lo;
+    *sbc = ((CARD64)rep.sbc_hi << 32) | rep.sbc_lo;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return True;
+}
+#endif
+
+#ifdef X_DRI2SwapInterval
+void DRI2SwapInterval(Display *dpy, XID drawable, int interval)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2SwapIntervalReq *req;
+
+    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+    LockDisplay(dpy);
+    GetReq(DRI2SwapInterval, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2SwapInterval;
+    req->drawable = drawable;
+    req->interval = interval;
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+#endif
diff --git a/src/gallium/winsys/g3dvl/dri/dri2.h b/src/gallium/winsys/g3dvl/dri/dri2.h
new file mode 100644 (file)
index 0000000..114e9f8
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright Â© 2007,2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifndef _DRI2_H_
+#define _DRI2_H_
+
+#include <X11/extensions/Xfixes.h>
+#include <X11/extensions/dri2tokens.h>
+
+typedef struct
+{
+   unsigned int attachment;
+   unsigned int name;
+   unsigned int pitch;
+   unsigned int cpp;
+   unsigned int flags;
+} DRI2Buffer;
+
+extern Bool
+DRI2QueryExtension(Display * display, int *eventBase, int *errorBase);
+
+extern Bool
+DRI2QueryVersion(Display * display, int *major, int *minor);
+
+extern Bool
+DRI2Connect(Display * display, XID window,
+            char **driverName, char **deviceName);
+
+extern Bool
+DRI2Authenticate(Display * display, XID window, drm_magic_t magic);
+
+extern void
+DRI2CreateDrawable(Display * display, XID drawable);
+
+extern void
+DRI2DestroyDrawable(Display * display, XID handle);
+
+extern DRI2Buffer*
+DRI2GetBuffers(Display * dpy, XID drawable,
+               int *width, int *height,
+               unsigned int *attachments, int count,
+               int *outCount);
+
+/**
+ * \note
+ * This function is only supported with DRI2 version 1.1 or later.
+ */
+extern DRI2Buffer*
+DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
+                         int *width, int *height,
+                         unsigned int *attachments,
+                         int count, int *outCount);
+
+extern void
+DRI2CopyRegion(Display * dpy, XID drawable,
+               XserverRegion region,
+               CARD32 dest, CARD32 src);
+
+extern void
+DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
+               CARD64 remainder, CARD64 *count);
+
+extern Bool
+DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
+
+extern Bool
+DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
+           CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc);
+
+extern Bool
+DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
+           CARD64 *msc, CARD64 *sbc);
+
+extern void
+DRI2SwapInterval(Display *dpy, XID drawable, int interval);
+
+#endif
diff --git a/src/gallium/winsys/g3dvl/dri/dri_winsys.c b/src/gallium/winsys/g3dvl/dri/dri_winsys.c
new file mode 100644 (file)
index 0000000..276731c
--- /dev/null
@@ -0,0 +1,258 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <vl_winsys.h>
+#include <driclient.h>
+#include <pipe/p_screen.h>
+#include <pipe/p_context.h>
+#include <pipe/p_state.h>
+#include <util/u_memory.h>
+#include <util/u_hash.h>
+#include <util/u_hash_table.h>
+#include <util/u_inlines.h>
+#include <state_tracker/drm_driver.h>
+#include <X11/Xlibint.h>
+
+struct vl_dri_screen
+{
+   struct vl_screen base;
+   dri_screen_t *dri_screen;
+   struct util_hash_table *drawable_table;
+   Drawable last_seen_drawable;
+};
+
+struct vl_dri_context
+{
+   struct vl_context base;
+   int fd;
+};
+
+static struct pipe_surface*
+vl_dri2_get_front(struct vl_context *vctx, Drawable drawable)
+{
+   int w, h;
+   unsigned int attachments[1] = {DRI_BUFFER_FRONT_LEFT};
+   int count;
+   DRI2Buffer *dri2_front;
+   struct pipe_resource *front_tex;
+   struct pipe_surface *front_surf = NULL;
+
+   assert(vctx);
+
+   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vctx->vscreen;
+   assert(vl_dri_scrn);
+
+   dri2_front = DRI2GetBuffers(vl_dri_scrn->dri_screen->display,
+                               drawable, &w, &h, attachments, 1, &count);
+
+   assert(count == 1);
+
+   if (dri2_front) {
+      struct winsys_handle dri2_front_handle =
+      {
+         .type = DRM_API_HANDLE_TYPE_SHARED,
+         .handle = dri2_front->name,
+         .stride = dri2_front->pitch
+      };
+      struct pipe_resource template;
+      struct pipe_surface surf_template;
+
+      memset(&template, 0, sizeof(struct pipe_resource));
+      template.target = PIPE_TEXTURE_2D;
+      template.format = PIPE_FORMAT_B8G8R8X8_UNORM;
+      template.last_level = 0;
+      template.width0 = w;
+      template.height0 = h;
+      template.depth0 = 1;
+      template.usage = PIPE_USAGE_STATIC;
+      template.bind = PIPE_BIND_RENDER_TARGET;
+      template.flags = 0;
+
+      front_tex = vl_dri_scrn->base.pscreen->resource_from_handle(vl_dri_scrn->base.pscreen, &template, &dri2_front_handle);
+      if (front_tex) {
+         memset(&surf_template, 0, sizeof(surf_template));
+         surf_template.format = front_tex->format;
+         surf_template.usage = PIPE_BIND_RENDER_TARGET;
+         front_surf = vctx->pipe->create_surface(vctx->pipe, front_tex, &surf_template);
+      }
+      pipe_resource_reference(&front_tex, NULL);
+      Xfree(dri2_front);
+   }
+
+   return front_surf;
+}
+
+static void
+vl_dri2_flush_frontbuffer(struct pipe_screen *screen,
+                          struct pipe_resource *resource,
+                          unsigned level, unsigned layer,
+                          void *context_private)
+{
+   struct vl_dri_context *vl_dri_ctx = (struct vl_dri_context*)context_private;
+   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vl_dri_ctx->base.vscreen;
+
+   assert(screen);
+   assert(resource);
+   assert(context_private);
+
+   dri2CopyDrawable(vl_dri_scrn->dri_screen, vl_dri_scrn->last_seen_drawable,
+                    DRI_BUFFER_FRONT_LEFT, DRI_BUFFER_FAKE_FRONT_LEFT);
+}
+
+struct pipe_surface*
+vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable)
+{
+   assert(vctx);
+
+   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vctx->vscreen;
+   assert(vl_dri_scrn);
+
+   if (vl_dri_scrn->last_seen_drawable != drawable) {
+      /* Hash table business depends on this equality */
+      assert(None == NULL);
+      Drawable lookup_drawable = (Drawable)util_hash_table_get(vl_dri_scrn->drawable_table, (void*)drawable);
+      if (lookup_drawable == None) {
+         dri2CreateDrawable(vl_dri_scrn->dri_screen, drawable);
+         util_hash_table_set(vl_dri_scrn->drawable_table, (void*)drawable, (void*)drawable);
+      }
+      vl_dri_scrn->last_seen_drawable = drawable;
+   }
+
+   return vl_dri2_get_front(vctx, drawable);
+}
+
+void*
+vl_contextprivate_get(struct vl_context *vctx, struct pipe_surface *displaytarget)
+{
+   return vctx;
+}
+
+static unsigned drawable_hash(void *key)
+{
+   Drawable drawable = (Drawable)key;
+   assert(drawable != None);
+   return util_hash_crc32(&drawable, sizeof(Drawable));
+}
+
+static int drawable_cmp(void *key1, void *key2)
+{
+   Drawable d1 = (Drawable)key1;
+   Drawable d2 = (Drawable)key2;
+   assert(d1 != None);
+   assert(d2 != None);
+   return d1 != d2;
+}
+
+struct vl_screen*
+vl_screen_create(Display *display, int screen)
+{
+   struct vl_dri_screen *vl_dri_scrn;
+
+   assert(display);
+
+   vl_dri_scrn = CALLOC_STRUCT(vl_dri_screen);
+   if (!vl_dri_scrn)
+      goto no_struct;
+
+   if (dri2CreateScreen(display, screen, &vl_dri_scrn->dri_screen))
+      goto no_dri2screen;
+
+   vl_dri_scrn->base.pscreen = driver_descriptor.create_screen(vl_dri_scrn->dri_screen->fd);
+
+   if (!vl_dri_scrn->base.pscreen)
+      goto no_pscreen;
+
+   vl_dri_scrn->drawable_table = util_hash_table_create(&drawable_hash, &drawable_cmp);
+   if (!vl_dri_scrn->drawable_table)
+      goto no_hash;
+
+   vl_dri_scrn->last_seen_drawable = None;
+   vl_dri_scrn->base.pscreen->flush_frontbuffer = vl_dri2_flush_frontbuffer;
+
+   return &vl_dri_scrn->base;
+
+no_hash:
+   vl_dri_scrn->base.pscreen->destroy(vl_dri_scrn->base.pscreen);
+no_pscreen:
+   dri2DestroyScreen(vl_dri_scrn->dri_screen);
+no_dri2screen:
+   FREE(vl_dri_scrn);
+no_struct:
+   return NULL;
+}
+
+void vl_screen_destroy(struct vl_screen *vscreen)
+{
+   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vscreen;
+
+   assert(vscreen);
+
+   util_hash_table_destroy(vl_dri_scrn->drawable_table);
+   vl_dri_scrn->base.pscreen->destroy(vl_dri_scrn->base.pscreen);
+   dri2DestroyScreen(vl_dri_scrn->dri_screen);
+   FREE(vl_dri_scrn);
+}
+
+struct vl_context*
+vl_video_create(struct vl_screen *vscreen)
+{
+   struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vscreen;
+   struct vl_dri_context *vl_dri_ctx;
+
+   vl_dri_ctx = CALLOC_STRUCT(vl_dri_context);
+   if (!vl_dri_ctx)
+      goto no_struct;
+
+   vl_dri_ctx->base.pipe = vscreen->pscreen->context_create(vscreen->pscreen, vl_dri_ctx);
+   if (!vl_dri_ctx->base.pipe) {
+      debug_printf("[G3DVL] No video support found on %s/%s.\n",
+                   vscreen->pscreen->get_vendor(vscreen->pscreen),
+                   vscreen->pscreen->get_name(vscreen->pscreen));
+      goto no_pipe;
+   }
+
+   vl_dri_ctx->base.vscreen = vscreen;
+   vl_dri_ctx->fd = vl_dri_scrn->dri_screen->fd;
+
+   return &vl_dri_ctx->base;
+
+no_pipe:
+   FREE(vl_dri_ctx);
+
+no_struct:
+   return NULL;
+}
+
+void vl_video_destroy(struct vl_context *vctx)
+{
+   struct vl_dri_context *vl_dri_ctx = (struct vl_dri_context*)vctx;
+
+   assert(vctx);
+
+   vl_dri_ctx->base.pipe->destroy(vl_dri_ctx->base.pipe);
+   FREE(vl_dri_ctx);
+}
similarity index 78%
rename from src/driclient/src/driclient.c
rename to src/gallium/winsys/g3dvl/dri/driclient.c
index dc2189a..90e48a7 100644 (file)
@@ -1,6 +1,8 @@
 #include "driclient.h"
 #include <assert.h>
 #include <stdlib.h>
+#include <fcntl.h>
+#include <X11/Xlibint.h>
 
 int driCreateScreen(Display *display, int screen, dri_screen_t **dri_screen, dri_framebuffer_t *dri_framebuf)
 {
@@ -222,12 +224,12 @@ int driUpdateDrawableInfo(dri_drawable_t *dri_drawable)
                dri_drawable->dri_screen->display,
                dri_drawable->dri_screen->num,
                dri_drawable->x_drawable,
-               &dri_drawable->sarea_index,
-               &dri_drawable->last_sarea_stamp,
-               &dri_drawable->x,
-               &dri_drawable->y,
-               &dri_drawable->w,
-               &dri_drawable->h,
+               &dri_drawable->sarea_index,
+               &dri_drawable->last_sarea_stamp,
+               &dri_drawable->x,
+               &dri_drawable->y,
+               &dri_drawable->w,
+               &dri_drawable->h,
                &dri_drawable->num_cliprects,
                &dri_drawable->cliprects,
                &dri_drawable->back_x,
@@ -308,3 +310,79 @@ int driDestroyContext(dri_context_t *dri_context)
 
        return 0;
 }
+
+int dri2CreateScreen(Display *display, int screen, dri_screen_t **dri_screen)
+{
+       dri_screen_t    *dri_scrn;
+       drm_magic_t     magic;
+       char            *drvName;
+       char            *devName;
+
+       dri_scrn = calloc(1, sizeof(dri_screen_t));
+
+       if (!dri_scrn)
+               return 1;
+
+       if (!DRI2Connect(display, XRootWindow(display, screen), &drvName, &devName))
+               goto free_screen;
+
+       dri_scrn->fd = open(devName, O_RDWR);
+       Xfree(drvName);
+       Xfree(devName);
+       if (dri_scrn->fd < 0)
+               goto free_screen;
+
+       if (drmGetMagic(dri_scrn->fd, &magic))
+               goto free_screen;
+
+       if (!DRI2Authenticate(display, RootWindow(display, screen), magic))
+               goto free_screen;
+
+       dri_scrn->display = display;
+       dri_scrn->num = screen;
+       *dri_screen = dri_scrn;
+
+       return 0;
+
+free_screen:
+       free(dri_scrn);
+
+       return 1;
+}
+
+int dri2DestroyScreen(dri_screen_t *dri_screen)
+{
+       /* Not much to do here apparently... */
+       assert(dri_screen);
+       free(dri_screen);
+       return 0;
+}
+
+int dri2CreateDrawable(dri_screen_t *dri_screen, XID drawable)
+{
+       assert(dri_screen);
+       DRI2CreateDrawable(dri_screen->display, drawable);
+       return 0;
+}
+
+int dri2DestroyDrawable(dri_screen_t *dri_screen, XID drawable)
+{
+       assert(dri_screen);
+       DRI2DestroyDrawable(dri_screen->display, drawable);
+       return 0;
+}
+
+int dri2CopyDrawable(dri_screen_t *dri_screen, XID drawable, int dest, int src)
+{
+       XserverRegion region;
+
+       assert(dri_screen);
+       assert(dest >= DRI_BUFFER_FRONT_LEFT && dest <= DRI_BUFFER_DEPTH_STENCIL);
+       assert(src >= DRI_BUFFER_FRONT_LEFT && src <= DRI_BUFFER_DEPTH_STENCIL);
+
+       region = XFixesCreateRegionFromWindow(dri_screen->display, drawable, WindowRegionBounding);
+       DRI2CopyRegion(dri_screen->display, drawable, region, dest, src);
+       XFixesDestroyRegion(dri_screen->display, region);
+
+       return 0;
+}
similarity index 76%
rename from src/driclient/include/driclient.h
rename to src/gallium/winsys/g3dvl/dri/driclient.h
index d391525..4e4fd36 100644 (file)
@@ -2,9 +2,12 @@
 #define driclient_h
 
 #include <stdint.h>
+#include <X11/Xmd.h>
 #include <X11/Xlib.h>
 #include <drm_sarea.h>
+//#include <X11/extensions/dri2proto.h>
 #include "xf86dri.h"
+#include "dri2.h"
 
 /* TODO: Bring in DRI XML options */
 
@@ -93,5 +96,22 @@ do                                                                                           \
        }                                                                                       \
 } while (0)
 
+int dri2CreateScreen(Display *display, int screen, dri_screen_t **dri_screen);
+int dri2DestroyScreen(dri_screen_t *dri_screen);
+int dri2CreateDrawable(dri_screen_t *dri_screen, XID drawable);
+int dri2DestroyDrawable(dri_screen_t *dri_screen, XID drawable);
+int dri2CopyDrawable(dri_screen_t *dri_screen, XID drawable, int dest, int src);
+
+#define DRI_BUFFER_FRONT_LEFT          0
+#define DRI_BUFFER_BACK_LEFT           1
+#define DRI_BUFFER_FRONT_RIGHT         2
+#define DRI_BUFFER_BACK_RIGHT          3
+#define DRI_BUFFER_DEPTH               4
+#define DRI_BUFFER_STENCIL             5
+#define DRI_BUFFER_ACCUM               6
+#define DRI_BUFFER_FAKE_FRONT_LEFT     7
+#define DRI_BUFFER_FAKE_FRONT_RIGHT    8
+#define DRI_BUFFER_DEPTH_STENCIL       9  /**< Only available with DRI2 1.1 */
+
 #endif
 
diff --git a/src/gallium/winsys/g3dvl/vl_winsys.h b/src/gallium/winsys/g3dvl/vl_winsys.h
new file mode 100644 (file)
index 0000000..384a8ba
--- /dev/null
@@ -0,0 +1,65 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 vl_winsys_h
+#define vl_winsys_h
+
+#include <X11/Xlib.h>
+#include <pipe/p_defines.h>
+#include <pipe/p_format.h>
+
+struct pipe_screen;
+struct pipe_surface;
+
+struct vl_screen
+{
+   struct pipe_screen *pscreen;
+};
+
+struct vl_context
+{
+   struct vl_screen *vscreen;
+   struct pipe_context *pipe;
+};
+
+struct vl_screen*
+vl_screen_create(Display *display, int screen);
+
+void vl_screen_destroy(struct vl_screen *vscreen);
+
+struct vl_context*
+vl_video_create(struct vl_screen *vscreen);
+
+void vl_video_destroy(struct vl_context *vctx);
+
+struct pipe_surface*
+vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable);
+
+void*
+vl_contextprivate_get(struct vl_context *vctx, struct pipe_surface *drawable_surface);
+
+#endif
diff --git a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
new file mode 100644 (file)
index 0000000..92f0bd6
--- /dev/null
@@ -0,0 +1,201 @@
+/**************************************************************************
+ *
+ * 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <X11/Xlibint.h>
+
+#include <pipe/p_state.h>
+
+#include <util/u_memory.h>
+#include <util/u_format.h>
+#include <util/u_inlines.h>
+
+#include <state_tracker/xlib_sw_winsys.h>
+#include <softpipe/sp_public.h>
+
+#include <vl_winsys.h>
+
+struct vl_xsp_screen
+{
+   struct vl_screen base;
+   Display *display;
+   int screen;
+   Visual visual;
+   struct xlib_drawable xdraw;
+   struct pipe_surface *drawable_surface;
+};
+
+struct pipe_surface*
+vl_drawable_surface_get(struct vl_context *vctx, Drawable drawable)
+{
+   struct vl_screen *vscreen = vctx->vscreen;
+   struct vl_xsp_screen *xsp_screen = (struct vl_xsp_screen*)vscreen;
+   Window root;
+   int x, y;
+   unsigned int width, height;
+   unsigned int border_width;
+   unsigned int depth;
+   struct pipe_resource templat, *drawable_tex;
+   struct pipe_surface surf_template, *drawable_surface = NULL;
+
+   assert(vscreen);
+   assert(drawable != None);
+
+   if (XGetGeometry(xsp_screen->display, drawable, &root, &x, &y, &width, &height, &border_width, &depth) == BadDrawable)
+      return NULL;
+
+   xsp_screen->xdraw.drawable = drawable;
+
+   if (xsp_screen->drawable_surface) {
+      if (xsp_screen->drawable_surface->width == width &&
+          xsp_screen->drawable_surface->height == height) {
+         pipe_surface_reference(&drawable_surface, xsp_screen->drawable_surface);
+         return drawable_surface;
+      }
+      else
+         pipe_surface_reference(&xsp_screen->drawable_surface, NULL);
+   }
+
+   memset(&templat, 0, sizeof(struct pipe_resource));
+   templat.target = PIPE_TEXTURE_2D;
+   /* XXX: Need to figure out drawable's format */
+   templat.format = PIPE_FORMAT_B8G8R8X8_UNORM;
+   templat.last_level = 0;
+   templat.width0 = width;
+   templat.height0 = height;
+   templat.depth0 = 1;
+   templat.usage = PIPE_USAGE_DEFAULT;
+   templat.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET;
+   templat.flags = 0;
+
+   drawable_tex = vscreen->pscreen->resource_create(vscreen->pscreen, &templat);
+   if (!drawable_tex)
+      return NULL;
+
+   memset(&surf_template, 0, sizeof(surf_template));
+   surf_template.format = templat.format;
+   surf_template.usage = PIPE_BIND_RENDER_TARGET;
+   xsp_screen->drawable_surface = vctx->pipe->create_surface(vctx->pipe, drawable_tex,
+                                                             &surf_template);
+   pipe_resource_reference(&drawable_tex, NULL);
+
+   if (!xsp_screen->drawable_surface)
+      return NULL;
+
+   pipe_surface_reference(&drawable_surface, xsp_screen->drawable_surface);
+
+   xsp_screen->xdraw.depth = 24/*util_format_get_blocksizebits(templat.format) /
+                             util_format_get_blockwidth(templat.format)*/;
+
+   return drawable_surface;
+}
+
+void*
+vl_contextprivate_get(struct vl_context *vctx, struct pipe_surface *drawable_surface)
+{
+   struct vl_xsp_screen *xsp_screen = (struct vl_xsp_screen*)vctx->vscreen;
+
+   assert(vctx);
+   assert(drawable_surface);
+   assert(xsp_screen->drawable_surface == drawable_surface);
+
+   return &xsp_screen->xdraw;
+}
+
+struct vl_screen*
+vl_screen_create(Display *display, int screen)
+{
+   struct vl_xsp_screen *xsp_screen;
+   struct sw_winsys *winsys;
+
+   assert(display);
+
+   xsp_screen = CALLOC_STRUCT(vl_xsp_screen);
+   if (!xsp_screen)
+      return NULL;
+
+   winsys = xlib_create_sw_winsys(display);
+   if (!winsys) {
+      FREE(xsp_screen);
+      return NULL;
+   }
+
+   xsp_screen->base.pscreen = softpipe_create_screen(winsys);
+   if (!xsp_screen->base.pscreen) {
+      winsys->destroy(winsys);
+      FREE(xsp_screen);
+      return NULL;
+   }
+
+   xsp_screen->display = display;
+   xsp_screen->screen = screen;
+   xsp_screen->xdraw.visual = XDefaultVisual(display, screen);
+
+   return &xsp_screen->base;
+}
+
+void vl_screen_destroy(struct vl_screen *vscreen)
+{
+   struct vl_xsp_screen *xsp_screen = (struct vl_xsp_screen*)vscreen;
+
+   assert(vscreen);
+
+   pipe_surface_reference(&xsp_screen->drawable_surface, NULL);
+   vscreen->pscreen->destroy(vscreen->pscreen);
+   FREE(vscreen);
+}
+
+struct vl_context*
+vl_video_create(struct vl_screen *vscreen)
+{
+   struct pipe_context *pipe;
+   struct vl_context *vctx;
+
+   assert(vscreen);
+
+   pipe = vscreen->pscreen->context_create(vscreen->pscreen, NULL);
+   if (!pipe)
+      return NULL;
+
+   vctx = CALLOC_STRUCT(vl_context);
+   if (!vctx) {
+      pipe->destroy(pipe);
+      return NULL;
+   }
+
+   vctx->pipe = pipe;
+   vctx->vscreen = vscreen;
+
+   return vctx;
+}
+
+void vl_video_destroy(struct vl_context *vctx)
+{
+   assert(vctx);
+
+   vctx->pipe->destroy(vctx->pipe);
+   FREE(vctx);
+}
index d8f5885..15c9799 100644 (file)
@@ -2,7 +2,7 @@ Import('*')
 
 env = env.Clone()
 
-env.ParseConfig('pkg-config --cflags libdrm')
+env.PkgUseModules('DRM')
 
 i915drm_sources = [
     'i915_drm_batchbuffer.c',
index 01dd4bf..ac66af3 100644 (file)
@@ -213,6 +213,17 @@ i915_drm_buffer_destroy(struct i915_winsys *iws,
    FREE(buffer);
 }
 
+static boolean
+i915_drm_buffer_is_busy(struct i915_winsys *iws,
+                        struct i915_winsys_buffer *buffer)
+{
+   struct i915_drm_buffer* i915_buffer = i915_drm_buffer(buffer);
+   if (!i915_buffer)
+      return FALSE;
+   return drm_intel_bo_busy(i915_buffer->bo);
+}
+
+
 void
 i915_drm_winsys_init_buffer_functions(struct i915_drm_winsys *idws)
 {
@@ -224,4 +235,5 @@ i915_drm_winsys_init_buffer_functions(struct i915_drm_winsys *idws)
    idws->base.buffer_unmap = i915_drm_buffer_unmap;
    idws->base.buffer_write = i915_drm_buffer_write;
    idws->base.buffer_destroy = i915_drm_buffer_destroy;
+   idws->base.buffer_is_busy = i915_drm_buffer_is_busy;
 }
index 785be44..a0f32de 100644 (file)
@@ -2,7 +2,7 @@ Import('*')
 
 env = env.Clone()
 
-env.ParseConfig('pkg-config --cflags libdrm')
+env.PkgUseModules('DRM')
 
 i965drm_sources = [
     'i965_drm_buffer.c',
index fb7b09b..1d0de31 100644 (file)
@@ -5,7 +5,6 @@ include $(TOP)/configs/current
 LIBNAME = r600winsys
 
 C_SOURCES = \
-       bof.c \
        evergreen_hw_context.c \
        radeon_bo.c \
        radeon_pciid.c \
index cc9a06a..efcedc6 100644 (file)
@@ -3,7 +3,6 @@ Import('*')
 env = env.Clone()
 
 r600_sources = [
-    'bof.c',
     'evergreen_hw_context.c',
     'radeon_bo.c',
     'radeon_pciid.c',
@@ -13,11 +12,7 @@ r600_sources = [
     'r600_bomgr.c',
 ]
 
-try:
-    env.ParseConfig('pkg-config --cflags libdrm_radeon')
-except OSError:
-    print 'warning: not building r600g'
-    Return()
+env.PkgUseModules('DRM_RADEON')
 
 env.Append(CPPPATH = '#/src/gallium/drivers/r600')
 
diff --git a/src/gallium/winsys/r600/drm/bof.c b/src/gallium/winsys/r600/drm/bof.c
deleted file mode 100644 (file)
index 5c923ad..0000000
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * Copyright 2010 Jerome Glisse <glisse@freedesktop.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
- * 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.
- *
- * Authors:
- *      Jerome Glisse
- */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include "bof.h"
-
-/*
- * helpers
- */
-static int bof_entry_grow(bof_t *bof)
-{
-       bof_t **array;
-
-       if (bof->array_size < bof->nentry)
-               return 0;
-       array = realloc(bof->array, (bof->nentry + 16) * sizeof(void*));
-       if (array == NULL)
-               return -ENOMEM;
-       bof->array = array;
-       bof->nentry += 16;
-       return 0;
-}
-
-/*
- * object
- */
-bof_t *bof_object(void)
-{
-       bof_t *object;
-
-       object = calloc(1, sizeof(bof_t));
-       if (object == NULL)
-               return NULL;
-       object->refcount = 1;
-       object->type = BOF_TYPE_OBJECT;
-       object->size = 12;
-       return object;
-}
-
-bof_t *bof_object_get(bof_t *object, const char *keyname)
-{
-       unsigned i;
-
-       for (i = 0; i < object->array_size; i += 2) {
-               if (!strcmp(object->array[i]->value, keyname)) {
-                       return object->array[i + 1];
-               }
-       }
-       return NULL;
-}
-
-int bof_object_set(bof_t *object, const char *keyname, bof_t *value)
-{
-       bof_t *key;
-       int r;
-
-       if (object->type != BOF_TYPE_OBJECT)
-               return -EINVAL;
-       r = bof_entry_grow(object);
-       if (r)
-               return r;
-       key = bof_string(keyname);
-       if (key == NULL)
-               return -ENOMEM;
-       object->array[object->array_size++] = key;
-       object->array[object->array_size++] = value;
-       object->size += value->size;
-       object->size += key->size;
-       bof_incref(value);
-       return 0;
-}
-
-/*
- * array
- */
-bof_t *bof_array(void)
-{
-       bof_t *array = bof_object();
-
-       if (array == NULL)
-               return NULL;
-       array->type = BOF_TYPE_ARRAY;
-       array->size = 12;
-       return array;
-}
-
-int bof_array_append(bof_t *array, bof_t *value)
-{
-       int r;
-       if (array->type != BOF_TYPE_ARRAY)
-               return -EINVAL;
-       r = bof_entry_grow(array);
-       if (r)
-               return r;
-       array->array[array->array_size++] = value;
-       array->size += value->size;
-       bof_incref(value);
-       return 0;
-}
-
-bof_t *bof_array_get(bof_t *bof, unsigned i)
-{
-       if (!bof_is_array(bof) || i >= bof->array_size)
-               return NULL;
-       return bof->array[i];
-}
-
-unsigned bof_array_size(bof_t *bof)
-{
-       if (!bof_is_array(bof))
-               return 0;
-       return bof->array_size;
-}
-
-/*
- * blob
- */
-bof_t *bof_blob(unsigned size, void *value)
-{
-       bof_t *blob = bof_object();
-
-       if (blob == NULL)
-               return NULL;
-       blob->type = BOF_TYPE_BLOB;
-       blob->value = calloc(1, size);
-       if (blob->value == NULL) {
-               bof_decref(blob);
-               return NULL;
-       }
-       blob->size = size;
-       memcpy(blob->value, value, size);
-       blob->size += 12;
-       return blob;
-}
-
-unsigned bof_blob_size(bof_t *bof)
-{
-       if (!bof_is_blob(bof))
-               return 0;
-       return bof->size - 12;
-}
-
-void *bof_blob_value(bof_t *bof)
-{
-       if (!bof_is_blob(bof))
-               return NULL;
-       return bof->value;
-}
-
-/*
- * string
- */
-bof_t *bof_string(const char *value)
-{
-       bof_t *string = bof_object();
-
-       if (string == NULL)
-               return NULL;
-       string->type = BOF_TYPE_STRING;
-       string->size = strlen(value) + 1;
-       string->value = calloc(1, string->size);
-       if (string->value == NULL) {
-               bof_decref(string);
-               return NULL;
-       }
-       strcpy(string->value, value);
-       string->size += 12;
-       return string;
-}
-
-/*
- *  int32
- */
-bof_t *bof_int32(int32_t value)
-{
-       bof_t *int32 = bof_object();
-
-       if (int32 == NULL)
-               return NULL;
-       int32->type = BOF_TYPE_INT32;
-       int32->size = 4;
-       int32->value = calloc(1, int32->size);
-       if (int32->value == NULL) {
-               bof_decref(int32);
-               return NULL;
-       }
-       memcpy(int32->value, &value, 4);
-       int32->size += 12;
-       return int32;
-}
-
-int32_t bof_int32_value(bof_t *bof)
-{
-       return *((uint32_t*)bof->value);
-}
-
-/*
- *  common
- */
-static void bof_indent(int level)
-{
-       int i;
-
-       for (i = 0; i < level; i++)
-               fprintf(stderr, " ");
-}
-
-static void bof_print_bof(bof_t *bof, int level, int entry)
-{
-       bof_indent(level);
-       if (bof == NULL) {
-               fprintf(stderr, "--NULL-- for entry %d\n", entry);
-               return;
-       }
-       switch (bof->type) {
-       case BOF_TYPE_STRING:
-               fprintf(stderr, "%p string [%s %d]\n", bof, (char*)bof->value, bof->size);
-               break;
-       case BOF_TYPE_INT32:
-               fprintf(stderr, "%p int32 [%d %d]\n", bof, *(int*)bof->value, bof->size);
-               break;
-       case BOF_TYPE_BLOB:
-               fprintf(stderr, "%p blob [%d]\n", bof, bof->size);
-               break;
-       case BOF_TYPE_NULL:
-               fprintf(stderr, "%p null [%d]\n", bof, bof->size);
-               break;
-       case BOF_TYPE_OBJECT:
-               fprintf(stderr, "%p object [%d %d]\n", bof, bof->array_size / 2, bof->size);
-               break;
-       case BOF_TYPE_ARRAY:
-               fprintf(stderr, "%p array [%d %d]\n", bof, bof->array_size, bof->size);
-               break;
-       default:
-               fprintf(stderr, "%p unknown [%d]\n", bof, bof->type);
-               return;
-       }
-}
-
-static void bof_print_rec(bof_t *bof, int level, int entry)
-{
-       unsigned i;
-
-       bof_print_bof(bof, level, entry);
-       for (i = 0; i < bof->array_size; i++) {
-               bof_print_rec(bof->array[i], level + 2, i);
-       }
-}
-
-void bof_print(bof_t *bof)
-{
-       bof_print_rec(bof, 0, 0);
-}
-
-static int bof_read(bof_t *root, FILE *file, long end, int level)
-{
-       bof_t *bof = NULL;
-       int r;
-
-       if (ftell(file) >= end) {
-               return 0;
-       }
-       r = bof_entry_grow(root);
-       if (r)
-               return r;
-       bof = bof_object();
-       if (bof == NULL)
-               return -ENOMEM;
-       bof->offset = ftell(file);
-       r = fread(&bof->type, 4, 1, file);
-       if (r != 1)
-               goto out_err;
-       r = fread(&bof->size, 4, 1, file);
-       if (r != 1)
-               goto out_err;
-       r = fread(&bof->array_size, 4, 1, file);
-       if (r != 1)
-               goto out_err;
-       switch (bof->type) {
-       case BOF_TYPE_STRING:
-       case BOF_TYPE_INT32:
-       case BOF_TYPE_BLOB:
-               bof->value = calloc(1, bof->size - 12);
-               if (bof->value == NULL) {
-                       goto out_err;
-               }
-               r = fread(bof->value, bof->size - 12, 1, file);
-               if (r != 1) {
-                       fprintf(stderr, "error reading %d\n", bof->size - 12);
-                       goto out_err;
-               }
-               break;
-       case BOF_TYPE_NULL:
-               return 0;
-       case BOF_TYPE_OBJECT:
-       case BOF_TYPE_ARRAY:
-               r = bof_read(bof, file, bof->offset + bof->size, level + 2);
-               if (r)
-                       goto out_err;
-               break;
-       default:
-               fprintf(stderr, "invalid type %d\n", bof->type);
-               goto out_err;
-       }
-       root->array[root->centry++] = bof;
-       return bof_read(root, file, end, level);
-out_err:
-       bof_decref(bof);
-       return -EINVAL;
-}
-
-bof_t *bof_load_file(const char *filename)
-{
-       bof_t *root = bof_object();
-       int r;
-
-       if (root == NULL) {
-               fprintf(stderr, "%s failed to create root object\n", __func__);
-               return NULL;
-       }
-       root->file = fopen(filename, "r");
-       if (root->file == NULL)
-               goto out_err;
-       r = fseek(root->file, 0L, SEEK_SET);
-       if (r) {
-               fprintf(stderr, "%s failed to seek into file %s\n", __func__, filename);
-               goto out_err;
-       }
-       root->offset = ftell(root->file);
-       r = fread(&root->type, 4, 1, root->file);
-       if (r != 1)
-               goto out_err;
-       r = fread(&root->size, 4, 1, root->file);
-       if (r != 1)
-               goto out_err;
-       r = fread(&root->array_size, 4, 1, root->file);
-       if (r != 1)
-               goto out_err;
-       r = bof_read(root, root->file, root->offset + root->size, 2);
-       if (r)
-               goto out_err;
-       return root;
-out_err:
-       bof_decref(root);
-       return NULL;
-}
-
-void bof_incref(bof_t *bof)
-{
-       bof->refcount++;
-}
-
-void bof_decref(bof_t *bof)
-{
-       unsigned i;
-
-       if (bof == NULL)
-               return;
-       if (--bof->refcount > 0)
-               return;
-       for (i = 0; i < bof->array_size; i++) {
-               bof_decref(bof->array[i]);
-               bof->array[i] = NULL;
-       }
-       bof->array_size = 0;
-       if (bof->file) {
-               fclose(bof->file);
-               bof->file = NULL;
-       }
-       free(bof->array);
-       free(bof->value);
-       free(bof);
-}
-
-static int bof_file_write(bof_t *bof, FILE *file)
-{
-       unsigned i;
-       int r;
-
-       r = fwrite(&bof->type, 4, 1, file);
-       if (r != 1)
-               return -EINVAL;
-       r = fwrite(&bof->size, 4, 1, file);
-       if (r != 1)
-               return -EINVAL;
-       r = fwrite(&bof->array_size, 4, 1, file);
-       if (r != 1)
-               return -EINVAL;
-       switch (bof->type) {
-       case BOF_TYPE_NULL:
-               if (bof->size)
-                       return -EINVAL;
-               break;
-       case BOF_TYPE_STRING:
-       case BOF_TYPE_INT32:
-       case BOF_TYPE_BLOB:
-               r = fwrite(bof->value, bof->size - 12, 1, file);
-               if (r != 1)
-                       return -EINVAL;
-               break;
-       case BOF_TYPE_OBJECT:
-       case BOF_TYPE_ARRAY:
-               for (i = 0; i < bof->array_size; i++) {
-                       r = bof_file_write(bof->array[i], file);
-                       if (r)
-                               return r;
-               }
-               break;
-       default:
-               return -EINVAL;
-       }
-       return 0;
-}
-
-int bof_dump_file(bof_t *bof, const char *filename)
-{
-       unsigned i;
-       int r = 0;
-
-       if (bof->file) {
-               fclose(bof->file);
-               bof->file = NULL;
-       }
-       bof->file = fopen(filename, "w");
-       if (bof->file == NULL) {
-               fprintf(stderr, "%s failed to open file %s\n", __func__, filename);
-               r = -EINVAL;
-               goto out_err;
-       }
-       r = fseek(bof->file, 0L, SEEK_SET);
-       if (r) {
-               fprintf(stderr, "%s failed to seek into file %s\n", __func__, filename);
-               goto out_err;
-       }
-       r = fwrite(&bof->type, 4, 1, bof->file);
-       if (r != 1)
-               goto out_err;
-       r = fwrite(&bof->size, 4, 1, bof->file);
-       if (r != 1)
-               goto out_err;
-       r = fwrite(&bof->array_size, 4, 1, bof->file);
-       if (r != 1)
-               goto out_err;
-       for (i = 0; i < bof->array_size; i++) {
-               r = bof_file_write(bof->array[i], bof->file);
-               if (r)
-                       return r;
-       }
-out_err:
-       fclose(bof->file);
-       bof->file = NULL;
-       return r;
-}
diff --git a/src/gallium/winsys/r600/drm/bof.h b/src/gallium/winsys/r600/drm/bof.h
deleted file mode 100644 (file)
index 014affb..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2010 Jerome Glisse <glisse@freedesktop.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
- * 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.
- *
- * Authors:
- *      Jerome Glisse
- */
-#ifndef BOF_H
-#define BOF_H
-
-#include <stdio.h>
-#include <stdint.h>
-
-#define BOF_TYPE_STRING                0
-#define BOF_TYPE_NULL          1
-#define BOF_TYPE_BLOB          2
-#define BOF_TYPE_OBJECT                3
-#define BOF_TYPE_ARRAY         4
-#define BOF_TYPE_INT32         5
-
-struct bof;
-
-typedef struct bof {
-       struct bof      **array;
-       unsigned        centry;
-       unsigned        nentry;
-       unsigned        refcount;
-       FILE            *file;
-       uint32_t        type;
-       uint32_t        size;
-       uint32_t        array_size;
-       void            *value;
-       long            offset;
-} bof_t;
-
-extern int bof_file_flush(bof_t *root);
-extern bof_t *bof_file_new(const char *filename);
-extern int bof_object_dump(bof_t *object, const char *filename);
-
-/* object */
-extern bof_t *bof_object(void);
-extern bof_t *bof_object_get(bof_t *object, const char *keyname);
-extern int bof_object_set(bof_t *object, const char *keyname, bof_t *value);
-/* array */
-extern bof_t *bof_array(void);
-extern int bof_array_append(bof_t *array, bof_t *value);
-extern bof_t *bof_array_get(bof_t *bof, unsigned i);
-extern unsigned bof_array_size(bof_t *bof);
-/* blob */
-extern bof_t *bof_blob(unsigned size, void *value);
-extern unsigned bof_blob_size(bof_t *bof);
-extern void *bof_blob_value(bof_t *bof);
-/* string */
-extern bof_t *bof_string(const char *value);
-/* int32 */
-extern bof_t *bof_int32(int32_t value);
-extern int32_t bof_int32_value(bof_t *bof);
-/* common functions */
-extern void bof_decref(bof_t *bof);
-extern void bof_incref(bof_t *bof);
-extern bof_t *bof_load_file(const char *filename);
-extern int bof_dump_file(bof_t *bof, const char *filename);
-extern void bof_print(bof_t *bof);
-
-static inline int bof_is_object(bof_t *bof){return (bof->type == BOF_TYPE_OBJECT);}
-static inline int bof_is_blob(bof_t *bof){return (bof->type == BOF_TYPE_BLOB);}
-static inline int bof_is_null(bof_t *bof){return (bof->type == BOF_TYPE_NULL);}
-static inline int bof_is_int32(bof_t *bof){return (bof->type == BOF_TYPE_INT32);}
-static inline int bof_is_array(bof_t *bof){return (bof->type == BOF_TYPE_ARRAY);}
-static inline int bof_is_string(bof_t *bof){return (bof->type == BOF_TYPE_STRING);}
-
-#endif
index 4d9dd50..7fe2050 100644 (file)
@@ -32,7 +32,6 @@
 #include "r600.h"
 #include "evergreend.h"
 #include "radeon_drm.h"
-#include "bof.h"
 #include "pipe/p_compiler.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
@@ -55,6 +54,7 @@ static const struct r600_reg evergreen_config_reg_list[] = {
        {R_008C24_SQ_STACK_RESOURCE_MGMT_2, REG_FLAG_ENABLE_ALWAYS | REG_FLAG_FLUSH_CHANGE, 0, 0},
        {R_008C28_SQ_STACK_RESOURCE_MGMT_3, REG_FLAG_ENABLE_ALWAYS | REG_FLAG_FLUSH_CHANGE, 0, 0},
        {R_008D8C_SQ_DYN_GPR_CNTL_PS_FLUSH_REQ, REG_FLAG_ENABLE_ALWAYS | REG_FLAG_FLUSH_CHANGE, 0, 0},
+       {R_008E2C_SQ_LDS_RESOURCE_MGMT, REG_FLAG_ENABLE_ALWAYS | REG_FLAG_FLUSH_CHANGE, 0, 0},
        {R_009100_SPI_CONFIG_CNTL, REG_FLAG_ENABLE_ALWAYS | REG_FLAG_FLUSH_CHANGE, 0, 0},
        {R_00913C_SPI_CONFIG_CNTL_1, REG_FLAG_ENABLE_ALWAYS | REG_FLAG_FLUSH_CHANGE, 0, 0},
 };
@@ -1018,6 +1018,8 @@ int evergreen_context_init(struct r600_context *ctx, struct radeon *radeon)
 
        LIST_INITHEAD(&ctx->fenced_bo);
 
+       r600_get_backend_mask(ctx);
+
        return 0;
 out_err:
        r600_context_fini(ctx);
@@ -1202,7 +1204,7 @@ void evergreen_context_draw(struct r600_context *ctx, const struct r600_draw *dr
        pm4[3] = draw->vgt_num_instances;
        if (draw->indices) {
                pm4[4] = PKT3(PKT3_DRAW_INDEX, 3, ctx->predicate_drawing);
-               pm4[5] = draw->indices_bo_offset + r600_bo_offset(draw->indices);
+               pm4[5] = draw->indices_bo_offset;
                pm4[6] = 0;
                pm4[7] = draw->vgt_num_indices;
                pm4[8] = draw->vgt_draw_initiator;
index 4098a6e..0f5b063 100644 (file)
@@ -126,13 +126,13 @@ void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, unsigned usage, voi
 {
        struct pipe_context *pctx = ctx;
 
-       if (usage & PB_USAGE_UNSYNCHRONIZED) {
+       if (usage & PIPE_TRANSFER_UNSYNCHRONIZED) {
                radeon_bo_map(radeon, bo->bo);
                return (uint8_t *) bo->bo->data + bo->offset;
        }
 
        if (p_atomic_read(&bo->bo->reference.count) > 1) {
-               if (usage & PB_USAGE_DONTBLOCK) {
+               if (usage & PIPE_TRANSFER_DONTBLOCK) {
                        return NULL;
                }
                if (ctx) {
@@ -140,7 +140,7 @@ void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, unsigned usage, voi
                }
        }
 
-       if (usage & PB_USAGE_DONTBLOCK) {
+       if (usage & PIPE_TRANSFER_DONTBLOCK) {
                uint32_t domain;
 
                if (radeon_bo_busy(radeon, bo->bo, &domain))
index 03fe385..8aa8c3d 100644 (file)
 #define RADEON_INFO_NUM_BACKENDS 0xa
 #endif
 
+#ifndef RADEON_INFO_NUM_TILE_PIPES
+#define RADEON_INFO_NUM_TILE_PIPES 0xb
+#endif
+
+#ifndef RADEON_INFO_BACKEND_MAP
+#define RADEON_INFO_BACKEND_MAP 0xd
+#endif
+
 enum radeon_family r600_get_family(struct radeon *r600)
 {
        return r600->family;
@@ -75,6 +83,16 @@ unsigned r600_get_num_backends(struct radeon *radeon)
        return radeon->num_backends;
 }
 
+unsigned r600_get_num_tile_pipes(struct radeon *radeon)
+{
+       return radeon->num_tile_pipes;
+}
+
+unsigned r600_get_backend_map(struct radeon *radeon)
+{
+       return radeon->backend_map;
+}
+
 unsigned r600_get_minor_version(struct radeon *radeon)
 {
        return radeon->minor_version;
@@ -156,7 +174,20 @@ static int eg_interpret_tiling(struct radeon *radeon, uint32_t tiling_config)
                return -EINVAL;
        }
 
-       radeon->tiling_info.num_banks = (tiling_config & 0xf0) >> 4;
+       switch ((tiling_config & 0xf0) >> 4) {
+       case 0:
+               radeon->tiling_info.num_banks = 4;
+               break;
+       case 1:
+               radeon->tiling_info.num_banks = 8;
+               break;
+       case 2:
+               radeon->tiling_info.num_banks = 16;
+               break;
+       default:
+               return -EINVAL;
+
+       }
 
        switch ((tiling_config & 0xf00) >> 8) {
        case 0:
@@ -173,7 +204,7 @@ static int eg_interpret_tiling(struct radeon *radeon, uint32_t tiling_config)
 
 static int radeon_drm_get_tiling(struct radeon *radeon)
 {
-       struct drm_radeon_info info;
+       struct drm_radeon_info info = {};
        int r;
        uint32_t tiling_config = 0;
 
@@ -195,8 +226,8 @@ static int radeon_drm_get_tiling(struct radeon *radeon)
 
 static int radeon_get_clock_crystal_freq(struct radeon *radeon)
 {
-       struct drm_radeon_info info;
-       uint32_t clock_crystal_freq;
+       struct drm_radeon_info info = {};
+       uint32_t clock_crystal_freq = 0;
        int r;
 
        info.request = RADEON_INFO_CLOCK_CRYSTAL_FREQ;
@@ -213,8 +244,8 @@ static int radeon_get_clock_crystal_freq(struct radeon *radeon)
 
 static int radeon_get_num_backends(struct radeon *radeon)
 {
-       struct drm_radeon_info info;
-       uint32_t num_backends;
+       struct drm_radeon_info info = {};
+       uint32_t num_backends = 0;
        int r;
 
        info.request = RADEON_INFO_NUM_BACKENDS;
@@ -228,6 +259,42 @@ static int radeon_get_num_backends(struct radeon *radeon)
        return 0;
 }
 
+static int radeon_get_num_tile_pipes(struct radeon *radeon)
+{
+       struct drm_radeon_info info = {};
+       uint32_t num_tile_pipes = 0;
+       int r;
+
+       info.request = RADEON_INFO_NUM_TILE_PIPES;
+       info.value = (uintptr_t)&num_tile_pipes;
+       r = drmCommandWriteRead(radeon->fd, DRM_RADEON_INFO, &info,
+                       sizeof(struct drm_radeon_info));
+       if (r)
+               return r;
+
+       radeon->num_tile_pipes = num_tile_pipes;
+       return 0;
+}
+
+static int radeon_get_backend_map(struct radeon *radeon)
+{
+       struct drm_radeon_info info = {};
+       uint32_t backend_map = 0;
+       int r;
+
+       info.request = RADEON_INFO_BACKEND_MAP;
+       info.value = (uintptr_t)&backend_map;
+       r = drmCommandWriteRead(radeon->fd, DRM_RADEON_INFO, &info,
+                       sizeof(struct drm_radeon_info));
+       if (r)
+               return r;
+
+       radeon->backend_map = backend_map;
+       radeon->backend_map_valid = TRUE;
+
+       return 0;
+}
+
 
 static int radeon_init_fence(struct radeon *radeon)
 {
@@ -236,7 +303,7 @@ static int radeon_init_fence(struct radeon *radeon)
        if (radeon->fence_bo == NULL) {
                return -ENOMEM;
        }
-       radeon->cfence = r600_bo_map(radeon, radeon->fence_bo, PB_USAGE_UNSYNCHRONIZED, NULL);
+       radeon->cfence = r600_bo_map(radeon, radeon->fence_bo, PIPE_TRANSFER_UNSYNCHRONIZED, NULL);
        *radeon->cfence = 0;
        return 0;
 }
@@ -349,6 +416,11 @@ static struct radeon *radeon_new(int fd, unsigned device)
        if (radeon->minor_version >= 9)
                radeon_get_num_backends(radeon);
 
+       if (radeon->minor_version >= 11) {
+               radeon_get_num_tile_pipes(radeon);
+               radeon_get_backend_map(radeon);
+       }
+
        radeon->bomgr = r600_bomgr_create(radeon, 1000000);
        if (radeon->bomgr == NULL) {
                return NULL;
index f89f24c..30af4e8 100644 (file)
 #include "xf86drm.h"
 #include "radeon_drm.h"
 #include "r600_priv.h"
-#include "bof.h"
 #include "r600d.h"
 
 #define GROUP_FORCE_NEW_BLOCK  0
 
+/* Get backends mask */
+void r600_get_backend_mask(struct r600_context *ctx)
+{
+       struct r600_bo * buffer;
+       u32 * results;
+       unsigned num_backends = r600_get_num_backends(ctx->radeon);
+       unsigned i, mask = 0;
+
+       /* if backend_map query is supported by the kernel */
+       if (ctx->radeon->backend_map_valid) {
+               unsigned num_tile_pipes = r600_get_num_tile_pipes(ctx->radeon);
+               unsigned backend_map = r600_get_backend_map(ctx->radeon);
+               unsigned item_width, item_mask;
+
+               if (ctx->radeon->chip_class >= EVERGREEN) {
+                       item_width = 4;
+                       item_mask = 0x7;
+               } else {
+                       item_width = 2;
+                       item_mask = 0x3;
+               }
+
+               while(num_tile_pipes--) {
+                       i = backend_map & item_mask;
+                       mask |= (1<<i);
+                       backend_map >>= item_width;
+               }
+               if (mask != 0) {
+                       ctx->backend_mask = mask;
+                       return;
+               }
+       }
+
+       /* otherwise backup path for older kernels */
+
+       /* create buffer for event data */
+       buffer = r600_bo(ctx->radeon, ctx->max_db*16, 1, 0,
+                               PIPE_USAGE_STAGING);
+       if (!buffer)
+               goto err;
+
+       /* initialize buffer with zeroes */
+       results = r600_bo_map(ctx->radeon, buffer, PB_USAGE_CPU_WRITE, NULL);
+       if (results) {
+               memset(results, 0, ctx->max_db * 4 * 4);
+               r600_bo_unmap(ctx->radeon, buffer);
+
+               /* emit EVENT_WRITE for ZPASS_DONE */
+               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE, 2, 0);
+               ctx->pm4[ctx->pm4_cdwords++] = EVENT_TYPE(EVENT_TYPE_ZPASS_DONE) | EVENT_INDEX(1);
+               ctx->pm4[ctx->pm4_cdwords++] = 0;
+               ctx->pm4[ctx->pm4_cdwords++] = 0;
+
+               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, 0);
+               ctx->pm4[ctx->pm4_cdwords++] = 0;
+               r600_context_bo_reloc(ctx, &ctx->pm4[ctx->pm4_cdwords - 1], buffer);
+
+               /* execute */
+               r600_context_flush(ctx);
+
+               /* analyze results */
+               results = r600_bo_map(ctx->radeon, buffer, PB_USAGE_CPU_READ, NULL);
+               if (results) {
+                       for(i = 0; i < ctx->max_db; i++) {
+                               /* at least highest bit will be set if backend is used */
+                               if (results[i*4 + 1])
+                                       mask |= (1<<i);
+                       }
+                       r600_bo_unmap(ctx->radeon, buffer);
+               }
+       }
+
+       r600_bo_reference(ctx->radeon, &buffer, NULL);
+
+       if (mask != 0) {
+               ctx->backend_mask = mask;
+               return;
+       }
+
+err:
+       /* fallback to old method - set num_backends lower bits to 1 */
+       ctx->backend_mask = (~((u32)0))>>(32-num_backends);
+       return;
+}
+
 static inline void r600_context_ps_partial_flush(struct r600_context *ctx)
 {
        if (!(ctx->flags & R600_CONTEXT_DRAW_PENDING))
@@ -62,6 +146,8 @@ void r600_init_cs(struct r600_context *ctx)
        ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_CONTEXT_CONTROL, 1, 0);
        ctx->pm4[ctx->pm4_cdwords++] = 0x80000000;
        ctx->pm4[ctx->pm4_cdwords++] = 0x80000000;
+
+       ctx->init_dwords = ctx->pm4_cdwords;
 }
 
 static void INLINE r600_context_update_fenced_list(struct r600_context *ctx)
@@ -897,6 +983,8 @@ int r600_context_init(struct r600_context *ctx, struct radeon *radeon)
 
        ctx->max_db = 4;
 
+       r600_get_backend_mask(ctx);
+
        return 0;
 out_err:
        r600_context_fini(ctx);
@@ -1467,7 +1555,7 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
        pm4[3] = draw->vgt_num_instances;
        if (draw->indices) {
                pm4[4] = PKT3(PKT3_DRAW_INDEX, 3, ctx->predicate_drawing);
-               pm4[5] = draw->indices_bo_offset + r600_bo_offset(draw->indices);
+               pm4[5] = draw->indices_bo_offset;
                pm4[6] = 0;
                pm4[7] = draw->vgt_num_indices;
                pm4[8] = draw->vgt_draw_initiator;
@@ -1496,13 +1584,13 @@ void r600_context_flush(struct r600_context *ctx)
        int r;
        struct r600_block *enable_block = NULL;
 
-       if (!ctx->pm4_cdwords)
+       if (ctx->pm4_cdwords == ctx->init_dwords)
                return;
 
        /* suspend queries */
        r600_context_queries_suspend(ctx);
 
-       if (ctx->radeon->family >= CHIP_CEDAR)
+       if (ctx->radeon->chip_class >= EVERGREEN)
                evergreen_context_flush_dest_caches(ctx);
        else
                r600_context_flush_dest_caches(ctx);
@@ -1535,6 +1623,10 @@ void r600_context_flush(struct r600_context *ctx)
        chunk_array[1] = (uint64_t)(uintptr_t)&chunks[1];
        r = drmCommandWriteRead(ctx->radeon->fd, DRM_RADEON_CS, &drmib,
                                sizeof(struct drm_radeon_cs));
+       if (r) {
+               fprintf(stderr, "radeon: The kernel rejected CS, "
+                       "see dmesg for more information.\n");
+       }
 #else
        *ctx->radeon->cfence = ctx->radeon->fence;
 #endif
@@ -1563,7 +1655,7 @@ void r600_context_flush(struct r600_context *ctx)
        r600_init_cs(ctx);
 
        /* resume queries */
-       r600_context_queries_resume(ctx);
+       r600_context_queries_resume(ctx, TRUE);
 
        /* set all valid group as dirty so they get reemited on
         * next draw command
@@ -1609,122 +1701,44 @@ void r600_context_emit_fence(struct r600_context *ctx, struct r600_bo *fence_bo,
        r600_context_bo_reloc(ctx, &ctx->pm4[ctx->pm4_cdwords - 1], fence_bo);
 }
 
-void r600_context_dump_bof(struct r600_context *ctx, const char *file)
-{
-       bof_t *bcs, *blob, *array, *bo, *size, *handle, *device_id, *root;
-       unsigned i;
-
-       root = device_id = bcs = blob = array = bo = size = handle = NULL;
-       root = bof_object();
-       if (root == NULL)
-               goto out_err;
-       device_id = bof_int32(ctx->radeon->device);
-       if (device_id == NULL)
-               goto out_err;
-       if (bof_object_set(root, "device_id", device_id))
-               goto out_err;
-       bof_decref(device_id);
-       device_id = NULL;
-       /* dump relocs */
-       blob = bof_blob(ctx->creloc * 16, ctx->reloc);
-       if (blob == NULL)
-               goto out_err;
-       if (bof_object_set(root, "reloc", blob))
-               goto out_err;
-       bof_decref(blob);
-       blob = NULL;
-       /* dump cs */
-       blob = bof_blob(ctx->pm4_cdwords * 4, ctx->pm4);
-       if (blob == NULL)
-               goto out_err;
-       if (bof_object_set(root, "pm4", blob))
-               goto out_err;
-       bof_decref(blob);
-       blob = NULL;
-       /* dump bo */
-       array = bof_array();
-       if (array == NULL)
-               goto out_err;
-       for (i = 0; i < ctx->creloc; i++) {
-               struct radeon_bo *rbo = ctx->bo[i];
-               bo = bof_object();
-               if (bo == NULL)
-                       goto out_err;
-               size = bof_int32(rbo->size);
-               if (size == NULL)
-                       goto out_err;
-               if (bof_object_set(bo, "size", size))
-                       goto out_err;
-               bof_decref(size);
-               size = NULL;
-               handle = bof_int32(rbo->handle);
-               if (handle == NULL)
-                       goto out_err;
-               if (bof_object_set(bo, "handle", handle))
-                       goto out_err;
-               bof_decref(handle);
-               handle = NULL;
-               radeon_bo_map(ctx->radeon, rbo);
-               blob = bof_blob(rbo->size, rbo->data);
-               radeon_bo_unmap(ctx->radeon, rbo);
-               if (blob == NULL)
-                       goto out_err;
-               if (bof_object_set(bo, "data", blob))
-                       goto out_err;
-               bof_decref(blob);
-               blob = NULL;
-               if (bof_array_append(array, bo))
-                       goto out_err;
-               bof_decref(bo);
-               bo = NULL;
-       }
-       if (bof_object_set(root, "bo", array))
-               goto out_err;
-       bof_dump_file(root, file);
-out_err:
-       bof_decref(blob);
-       bof_decref(array);
-       bof_decref(bo);
-       bof_decref(size);
-       bof_decref(handle);
-       bof_decref(device_id);
-       bof_decref(root);
-}
-
 static boolean r600_query_result(struct r600_context *ctx, struct r600_query *query, boolean wait)
 {
+       unsigned results_base = query->results_start;
        u64 start, end;
-       u32 *results;
-       int i;
-       int size;
+       u32 *results, *current_result;
 
        if (wait)
-               results = r600_bo_map(ctx->radeon, query->buffer, PB_USAGE_CPU_READ, NULL);
+               results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_READ, NULL);
        else
-               results = r600_bo_map(ctx->radeon, query->buffer, PB_USAGE_DONTBLOCK | PB_USAGE_CPU_READ, NULL);
+               results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_DONTBLOCK | PIPE_TRANSFER_READ, NULL);
        if (!results)
                return FALSE;
 
-       /* query->num_results contains how many dwords were used for the query */
-       size = query->num_results;
-       for (i = 0; i < size; i += 4) {
-               start = (u64)results[i] | (u64)results[i + 1] << 32;
-               end = (u64)results[i + 2] | (u64)results[i + 3] << 32;
+
+       /* count all results across all data blocks */
+       while (results_base != query->results_end) {
+               current_result = (u32*)((char*)results + results_base);
+
+               start = (u64)current_result[0] | (u64)current_result[1] << 32;
+               end = (u64)current_result[2] | (u64)current_result[3] << 32;
                if (((start & 0x8000000000000000UL) && (end & 0x8000000000000000UL))
                     || query->type == PIPE_QUERY_TIME_ELAPSED) {
                        query->result += end - start;
                }
+
+               results_base += 4 * 4;
+               if (results_base >= query->buffer_size)
+                       results_base = 0;
        }
-       r600_bo_unmap(ctx->radeon, query->buffer);
-       query->num_results = 0;
 
+       query->results_start = query->results_end;
+       r600_bo_unmap(ctx->radeon, query->buffer);
        return TRUE;
 }
 
 void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
 {
-       unsigned required_space;
-       int num_backends = r600_get_num_backends(ctx->radeon);
+       unsigned required_space, new_results_end;
 
        /* query request needs 6/8 dwords for begin + 6/8 dwords for end */
        if (query->type == PIPE_QUERY_TIME_ELAPSED)
@@ -1737,25 +1751,44 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
                r600_context_flush(ctx);
        }
 
-       /* if query buffer is full force a flush */
-       if (query->num_results*4 >= query->buffer_size - 16) {
-               r600_context_flush(ctx);
+       if (query->type == PIPE_QUERY_OCCLUSION_COUNTER) {
+               /* Count queries emitted without flushes, and flush if more than
+                * half of buffer used, to avoid overwriting results which may be
+                * still in use. */
+               if (query->state & R600_QUERY_STATE_FLUSHED) {
+                       query->queries_emitted = 1;
+               } else {
+                       if (++query->queries_emitted > query->buffer_size / query->result_size / 2)
+                               r600_context_flush(ctx);
+               }
+       }
+
+       new_results_end = query->results_end + query->result_size;
+       if (new_results_end >= query->buffer_size)
+               new_results_end = 0;
+
+       /* collect current results if query buffer is full */
+       if (new_results_end == query->results_start) {
+               if (!(query->state & R600_QUERY_STATE_FLUSHED))
+                       r600_context_flush(ctx);
                r600_query_result(ctx, query, TRUE);
        }
 
-       if (query->type == PIPE_QUERY_OCCLUSION_COUNTER &&
-           num_backends > 0) {
-               /* as per info on ZPASS the driver must set the unusued DB top bits */
+       if (query->type == PIPE_QUERY_OCCLUSION_COUNTER) {
                u32 *results;
                int i;
 
-               results = r600_bo_map(ctx->radeon, query->buffer, PB_USAGE_DONTBLOCK | PB_USAGE_CPU_WRITE, NULL);
+               results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_WRITE, NULL);
                if (results) {
-                       memset(results + (query->num_results * 4), 0, ctx->max_db * 4 * 4);
-
-                       for (i = num_backends; i < ctx->max_db; i++) {
-                               results[(i * 4)+1] = 0x80000000;
-                               results[(i * 4)+3] = 0x80000000;
+                       results = (u32*)((char*)results + query->results_end);
+                       memset(results, 0, query->result_size);
+
+                       /* Set top bits for unused backends */
+                       for (i = 0; i < ctx->max_db; i++) {
+                               if (!(ctx->backend_mask & (1<<i))) {
+                                       results[(i * 4)+1] = 0x80000000;
+                                       results[(i * 4)+3] = 0x80000000;
+                               }
                        }
                        r600_bo_unmap(ctx->radeon, query->buffer);
                }
@@ -1765,14 +1798,14 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
        if (query->type == PIPE_QUERY_TIME_ELAPSED) {
                ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE_EOP, 4, 0);
                ctx->pm4[ctx->pm4_cdwords++] = EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5);
-               ctx->pm4[ctx->pm4_cdwords++] = query->num_results*4 + r600_bo_offset(query->buffer);
+               ctx->pm4[ctx->pm4_cdwords++] = query->results_end;
                ctx->pm4[ctx->pm4_cdwords++] = (3 << 29);
                ctx->pm4[ctx->pm4_cdwords++] = 0;
                ctx->pm4[ctx->pm4_cdwords++] = 0;
        } else {
                ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE, 2, 0);
                ctx->pm4[ctx->pm4_cdwords++] = EVENT_TYPE(EVENT_TYPE_ZPASS_DONE) | EVENT_INDEX(1);
-               ctx->pm4[ctx->pm4_cdwords++] = query->num_results*4 + r600_bo_offset(query->buffer);
+               ctx->pm4[ctx->pm4_cdwords++] = query->results_end;
                ctx->pm4[ctx->pm4_cdwords++] = 0;
        }
        ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, 0);
@@ -1786,49 +1819,75 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
 
 void r600_query_end(struct r600_context *ctx, struct r600_query *query)
 {
-       /* emit begin query */
+       /* emit end query */
        if (query->type == PIPE_QUERY_TIME_ELAPSED) {
                ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE_EOP, 4, 0);
                ctx->pm4[ctx->pm4_cdwords++] = EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5);
-               ctx->pm4[ctx->pm4_cdwords++] = query->num_results*4 + 8 + r600_bo_offset(query->buffer);
+               ctx->pm4[ctx->pm4_cdwords++] = query->results_end + 8;
                ctx->pm4[ctx->pm4_cdwords++] = (3 << 29);
                ctx->pm4[ctx->pm4_cdwords++] = 0;
                ctx->pm4[ctx->pm4_cdwords++] = 0;
        } else {
                ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE, 2, 0);
                ctx->pm4[ctx->pm4_cdwords++] = EVENT_TYPE(EVENT_TYPE_ZPASS_DONE) | EVENT_INDEX(1);
-               ctx->pm4[ctx->pm4_cdwords++] = query->num_results*4 + 8 + r600_bo_offset(query->buffer);
+               ctx->pm4[ctx->pm4_cdwords++] = query->results_end + 8;
                ctx->pm4[ctx->pm4_cdwords++] = 0;
        }
        ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, 0);
        ctx->pm4[ctx->pm4_cdwords++] = 0;
        r600_context_bo_reloc(ctx, &ctx->pm4[ctx->pm4_cdwords - 1], query->buffer);
 
-       query->num_results += 4 * (query->type == PIPE_QUERY_OCCLUSION_COUNTER ? ctx->max_db : 1);
+       query->results_end += query->result_size;
+       if (query->results_end >= query->buffer_size)
+               query->results_end = 0;
+
        query->state ^= R600_QUERY_STATE_STARTED;
        query->state |= R600_QUERY_STATE_ENDED;
+       query->state &= ~R600_QUERY_STATE_FLUSHED;
+
        ctx->num_query_running--;
 }
 
 void r600_query_predication(struct r600_context *ctx, struct r600_query *query, int operation,
                            int flag_wait)
 {
-       ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SET_PREDICATION, 1, 0);
-
        if (operation == PREDICATION_OP_CLEAR) {
+               if (ctx->pm4_cdwords + 3 > ctx->pm4_ndwords)
+                       r600_context_flush(ctx);
+
+               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SET_PREDICATION, 1, 0);
                ctx->pm4[ctx->pm4_cdwords++] = 0;
                ctx->pm4[ctx->pm4_cdwords++] = PRED_OP(PREDICATION_OP_CLEAR);
        } else {
-               int results_base = query->num_results - (4 * ctx->max_db);
+               unsigned results_base = query->results_start;
+               unsigned count;
+               u32 op;
 
-               if (results_base < 0)
-                       results_base = 0;
+               /* find count of the query data blocks */
+               count = query->buffer_size + query->results_end - query->results_start;
+               if (count >= query->buffer_size) count-=query->buffer_size;
+               count /= query->result_size;
 
-               ctx->pm4[ctx->pm4_cdwords++] = results_base*4 + r600_bo_offset(query->buffer);
-               ctx->pm4[ctx->pm4_cdwords++] = PRED_OP(operation) | (flag_wait ? PREDICATION_HINT_WAIT : PREDICATION_HINT_NOWAIT_DRAW) | PREDICATION_DRAW_VISIBLE;
-               ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, 0);
-               ctx->pm4[ctx->pm4_cdwords++] = 0;
-               r600_context_bo_reloc(ctx, &ctx->pm4[ctx->pm4_cdwords - 1], query->buffer);
+               if (ctx->pm4_cdwords + 5 * count > ctx->pm4_ndwords)
+                       r600_context_flush(ctx);
+
+               op = PRED_OP(operation) | PREDICATION_DRAW_VISIBLE |
+                               (flag_wait ? PREDICATION_HINT_WAIT : PREDICATION_HINT_NOWAIT_DRAW);
+
+               /* emit predicate packets for all data blocks */
+               while (results_base != query->results_end) {
+                       ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SET_PREDICATION, 1, 0);
+                       ctx->pm4[ctx->pm4_cdwords++] = results_base;
+                       ctx->pm4[ctx->pm4_cdwords++] = op;
+                       ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, 0);
+                       ctx->pm4[ctx->pm4_cdwords++] = 0;
+                       r600_context_bo_reloc(ctx, &ctx->pm4[ctx->pm4_cdwords - 1], query->buffer);
+                       results_base += query->result_size;
+                       if (results_base >= query->buffer_size)
+                               results_base = 0;
+                       /* set CONTINUE bit for all packets except the first */
+                       op |= PREDICATION_CONTINUE;
+               }
        }
 }
 
@@ -1846,6 +1905,14 @@ struct r600_query *r600_context_query_create(struct r600_context *ctx, unsigned
        query->type = query_type;
        query->buffer_size = 4096;
 
+       if (query_type == PIPE_QUERY_OCCLUSION_COUNTER)
+               query->result_size = 4 * 4 * ctx->max_db;
+       else
+               query->result_size = 4 * 4;
+
+       /* adjust buffer size to simplify offsets wrapping math */
+       query->buffer_size -= query->buffer_size % query->result_size;
+
        /* As of GL4, query buffers are normally read by the CPU after
         * being written by the gpu, hence staging is probably a good
         * usage pattern.
@@ -1875,7 +1942,7 @@ boolean r600_context_query_result(struct r600_context *ctx,
 {
        uint64_t *result = (uint64_t*)vresult;
 
-       if (query->num_results) {
+       if (!(query->state & R600_QUERY_STATE_FLUSHED)) {
                r600_context_flush(ctx);
        }
        if (!r600_query_result(ctx, query, wait))
@@ -1900,11 +1967,14 @@ void r600_context_queries_suspend(struct r600_context *ctx)
        }
 }
 
-void r600_context_queries_resume(struct r600_context *ctx)
+void r600_context_queries_resume(struct r600_context *ctx, boolean flushed)
 {
        struct r600_query *query;
 
        LIST_FOR_EACH_ENTRY(query, &ctx->query_list, list) {
+               if (flushed)
+                       query->state |= R600_QUERY_STATE_FLUSHED;
+
                if (query->state & R600_QUERY_STATE_SUSPENDED) {
                        r600_query_begin(ctx, query);
                        query->state ^= R600_QUERY_STATE_SUSPENDED;
index 69f7251..75115fd 100644 (file)
@@ -55,6 +55,9 @@ struct radeon {
        struct r600_bo                  *fence_bo;
        unsigned                        clock_crystal_freq;
        unsigned                        num_backends;
+       unsigned                        num_tile_pipes;
+       unsigned                        backend_map;
+       boolean                         backend_map_valid;
        unsigned                        minor_version;
 
         /* List of buffer handles and its mutex. */
index 8042481..4a19dcf 100644 (file)
 
 #define PRED_OP(x) ((x) << 16)
 
+#define PREDICATION_CONTINUE (1 << 31)
+
 #define PREDICATION_HINT_WAIT (0 << 12)
 #define PREDICATION_HINT_NOWAIT_DRAW (1 << 12)
 
index 39a8c71..2edb1e9 100644 (file)
@@ -8,11 +8,7 @@ radeon_sources = [
     'radeon_drm_winsys.c',
 ]
 
-try:
-    env.ParseConfig('pkg-config --cflags libdrm')
-except:
-    print 'warning: not building Gallium Radeon'
-    Return()
+env.PkgUseModules('DRM')
 
 radeonwinsys = env.ConvenienceLibrary(
     target ='radeonwinsys',
index b6f1272..2eb9d13 100644 (file)
@@ -89,7 +89,7 @@ static struct radeon_bo *get_radeon_bo(struct pb_buffer *_buf)
 
 static void radeon_bo_wait(struct pb_buffer *_buf)
 {
-    struct radeon_bo *bo = get_radeon_bo(pb_buffer(_buf));
+    struct radeon_bo *bo = get_radeon_bo(_buf);
     struct drm_radeon_gem_wait_idle args = {};
 
     while (p_atomic_read(&bo->num_active_ioctls)) {
@@ -105,7 +105,7 @@ static void radeon_bo_wait(struct pb_buffer *_buf)
 
 static boolean radeon_bo_is_busy(struct pb_buffer *_buf)
 {
-    struct radeon_bo *bo = get_radeon_bo(pb_buffer(_buf));
+    struct radeon_bo *bo = get_radeon_bo(_buf);
     struct drm_radeon_gem_busy args = {};
     boolean busy;
 
@@ -395,16 +395,14 @@ static void *radeon_bo_map(struct pb_buffer *buf,
                            struct radeon_winsys_cs *cs,
                            enum pipe_transfer_usage usage)
 {
-    struct pb_buffer *_buf = pb_buffer(buf);
-
-    return pb_map(_buf, get_pb_usage_from_transfer_flags(usage), cs);
+    return pb_map(buf, get_pb_usage_from_transfer_flags(usage), cs);
 }
 
 static void radeon_bo_get_tiling(struct pb_buffer *_buf,
                                  enum radeon_bo_layout *microtiled,
                                  enum radeon_bo_layout *macrotiled)
 {
-    struct radeon_bo *bo = get_radeon_bo(pb_buffer(_buf));
+    struct radeon_bo *bo = get_radeon_bo(_buf);
     struct drm_radeon_gem_set_tiling args = {};
 
     args.handle = bo->handle;
@@ -429,7 +427,7 @@ static void radeon_bo_set_tiling(struct pb_buffer *_buf,
                                  enum radeon_bo_layout macrotiled,
                                  uint32_t pitch)
 {
-    struct radeon_bo *bo = get_radeon_bo(pb_buffer(_buf));
+    struct radeon_bo *bo = get_radeon_bo(_buf);
     struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
     struct drm_radeon_gem_set_tiling args = {};
 
@@ -464,12 +462,10 @@ static struct radeon_winsys_cs_handle *radeon_drm_get_cs_handle(
         struct pb_buffer *_buf)
 {
     /* return radeon_bo. */
-    return (struct radeon_winsys_cs_handle*)
-            get_radeon_bo(pb_buffer(_buf));
+    return (struct radeon_winsys_cs_handle*)get_radeon_bo(_buf);
 }
 
-static unsigned get_pb_usage_from_create_flags(unsigned bind, unsigned usage,
-                                               enum radeon_bo_domain domain)
+static unsigned get_pb_usage_from_create_flags(enum radeon_bo_domain domain)
 {
     unsigned res = 0;
 
@@ -487,7 +483,6 @@ radeon_winsys_bo_create(struct radeon_winsys *rws,
                         unsigned size,
                         unsigned alignment,
                         unsigned bind,
-                        unsigned usage,
                         enum radeon_bo_domain domain)
 {
     struct radeon_drm_winsys *ws = radeon_drm_winsys(rws);
@@ -497,10 +492,11 @@ radeon_winsys_bo_create(struct radeon_winsys *rws,
 
     memset(&desc, 0, sizeof(desc));
     desc.alignment = alignment;
-    desc.usage = get_pb_usage_from_create_flags(bind, usage, domain);
+    desc.usage = get_pb_usage_from_create_flags(domain);
 
     /* Assign a buffer manager. */
-    if (bind & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER))
+    if (bind & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER |
+                PIPE_BIND_CONSTANT_BUFFER))
        provider = ws->cman;
     else
         provider = ws->kman;
@@ -587,7 +583,7 @@ static boolean radeon_winsys_bo_get_handle(struct pb_buffer *buffer,
                                            struct winsys_handle *whandle)
 {
     struct drm_gem_flink flink = {};
-    struct radeon_bo *bo = get_radeon_bo(pb_buffer(buffer));
+    struct radeon_bo *bo = get_radeon_bo(buffer);
 
     if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
         if (!bo->flinked) {
index b94881b..f4ea73a 100644 (file)
@@ -80,10 +80,4 @@ void radeon_bo_reference(struct radeon_bo **dst, struct radeon_bo *src)
     pb_reference((struct pb_buffer**)dst, (struct pb_buffer*)src);
 }
 
-static INLINE struct pb_buffer *
-pb_buffer(struct pb_buffer *buffer)
-{
-    return (struct pb_buffer *)buffer;
-}
-
 #endif
index 0139de1..f0f4a70 100644 (file)
@@ -308,8 +308,8 @@ static boolean radeon_drm_cs_validate(struct radeon_winsys_cs *rcs)
 {
     struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
 
-    return cs->csc->used_gart < cs->ws->gart_size * 0.8 &&
-           cs->csc->used_vram < cs->ws->vram_size * 0.8;
+    return cs->csc->used_gart < cs->ws->info.gart_size * 0.8 &&
+           cs->csc->used_vram < cs->ws->info.vram_size * 0.8;
 }
 
 static void radeon_drm_cs_write_reloc(struct radeon_winsys_cs *rcs,
index 339beed..ea2a820 100644 (file)
@@ -88,8 +88,9 @@ static INLINE boolean
 radeon_bo_is_referenced_by_cs(struct radeon_drm_cs *cs,
                               struct radeon_bo *bo)
 {
-    return bo->num_cs_references == bo->rws->num_cs ||
-           (bo->num_cs_references && radeon_get_reloc(cs->csc, bo) != -1);
+    int num_refs = bo->num_cs_references;
+    return num_refs == bo->rws->num_cs ||
+           (num_refs && radeon_get_reloc(cs->csc, bo) != -1);
 }
 
 static INLINE boolean
@@ -111,7 +112,7 @@ radeon_bo_is_referenced_by_cs_for_write(struct radeon_drm_cs *cs,
 static INLINE boolean
 radeon_bo_is_referenced_by_any_cs(struct radeon_bo *bo)
 {
-    return bo->num_cs_references;
+    return bo->num_cs_references != 0;
 }
 
 void radeon_drm_cs_sync_flush(struct radeon_drm_cs *cs);
index 0474b38..5983e86 100644 (file)
@@ -103,17 +103,31 @@ static boolean radeon_set_fd_access(struct radeon_drm_cs *applier,
     return FALSE;
 }
 
+static boolean radeon_get_drm_value(int fd, unsigned request,
+                                    const char *name, uint32_t *out)
+{
+    struct drm_radeon_info info = {0};
+    int retval;
+
+    info.value = (unsigned long)out;
+    info.request = request;
+
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get %s, error number %d\n",
+                __func__, name, retval);
+        return FALSE;
+    }
+    return TRUE;
+}
+
 /* Helper function to do the ioctls needed for setup and init. */
-static void do_ioctls(struct radeon_drm_winsys *winsys)
+static boolean do_winsys_init(struct radeon_drm_winsys *ws)
 {
     struct drm_radeon_gem_info gem_info = {0};
-    struct drm_radeon_info info = {0};
-    int target = 0;
     int retval;
     drmVersionPtr version;
 
-    info.value = (unsigned long)&target;
-
     /* We do things in a specific order here.
      *
      * DRM version first. We need to be sure we're running on a KMS chipset.
@@ -123,71 +137,76 @@ static void do_ioctls(struct radeon_drm_winsys *winsys)
      * for all Radeons. If this fails, we probably got handed an FD for some
      * non-Radeon card.
      *
+     * 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.
+     *
      * 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. */
+     */
 
-    version = drmGetVersion(winsys->fd);
+    /* Get DRM version. */
+    version = drmGetVersion(ws->fd);
     if (version->version_major != 2 ||
         version->version_minor < 3) {
         fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
-                "only compatible with 2.3.x (kernel 2.6.34) and later.\n",
+                "only compatible with 2.3.x (kernel 2.6.34) or later.\n",
                 __FUNCTION__,
                 version->version_major,
                 version->version_minor,
                 version->version_patchlevel);
         drmFreeVersion(version);
-        exit(1);
+        return FALSE;
     }
 
-    winsys->drm_major = version->version_major;
-    winsys->drm_minor = version->version_minor;
-    winsys->drm_patchlevel = version->version_patchlevel;
+    ws->info.drm_major = version->version_major;
+    ws->info.drm_minor = version->version_minor;
+    ws->info.drm_patchlevel = version->version_patchlevel;
+    drmFreeVersion(version);
 
-    info.request = RADEON_INFO_DEVICE_ID;
-    retval = drmCommandWriteRead(winsys->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;
+    /* Get PCI ID. */
+    if (!radeon_get_drm_value(ws->fd, RADEON_INFO_DEVICE_ID, "PCI ID",
+                              &ws->info.pci_id))
+        return FALSE;
 
-    info.request = RADEON_INFO_NUM_GB_PIPES;
-    retval = drmCommandWriteRead(winsys->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;
+    /* Check PCI ID. */
+    switch (ws->info.pci_id) {
+#define CHIPSET(pci_id, name, family) case pci_id:
+#include "pci_ids/r300_pci_ids.h"
+#undef CHIPSET
+        break;
 
-    info.request = RADEON_INFO_NUM_Z_PIPES;
-    retval = drmCommandWriteRead(winsys->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);
+    default:
+        fprintf(stderr, "radeon: Invalid PCI ID.\n");
+        return FALSE;
     }
-    winsys->z_pipes = target;
 
-    retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_GEM_INFO,
+    /* Get GEM info. */
+    retval = drmCommandWriteRead(ws->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);
+        return FALSE;
     }
-    winsys->gart_size = gem_info.gart_size;
-    winsys->vram_size = gem_info.vram_size;
+    ws->info.gart_size = gem_info.gart_size;
+    ws->info.vram_size = gem_info.vram_size;
 
-    drmFreeVersion(version);
+    ws->num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+
+    /* Generation-specific queries. */
+    if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_GB_PIPES,
+                              "GB pipe count",
+                              &ws->info.r300_num_gb_pipes))
+        return FALSE;
 
-    winsys->num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+    if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_Z_PIPES,
+                              "Z pipe count",
+                              &ws->info.r300_num_z_pipes))
+        return FALSE;
+
+    return TRUE;
 }
 
 static void radeon_winsys_destroy(struct radeon_winsys *rws)
@@ -202,34 +221,10 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws)
     FREE(rws);
 }
 
-static uint32_t radeon_get_value(struct radeon_winsys *rws,
-                                 enum radeon_value_id id)
+static void radeon_query_info(struct radeon_winsys *rws,
+                              struct radeon_info *info)
 {
-    struct radeon_drm_winsys *ws = (struct radeon_drm_winsys *)rws;
-
-    switch(id) {
-    case RADEON_VID_PCI_ID:
-       return ws->pci_id;
-    case RADEON_VID_R300_GB_PIPES:
-       return ws->gb_pipes;
-    case RADEON_VID_R300_Z_PIPES:
-       return ws->z_pipes;
-    case RADEON_VID_GART_SIZE:
-        return ws->gart_size;
-    case RADEON_VID_VRAM_SIZE:
-        return ws->vram_size;
-    case RADEON_VID_DRM_MAJOR:
-        return ws->drm_major;
-    case RADEON_VID_DRM_MINOR:
-        return ws->drm_minor;
-    case RADEON_VID_DRM_PATCHLEVEL:
-        return ws->drm_patchlevel;
-    case RADEON_VID_DRM_2_6_0:
-        return ws->drm_major*100 + ws->drm_minor >= 206;
-    case RADEON_VID_DRM_2_8_0:
-        return ws->drm_major*100 + ws->drm_minor >= 208;
-    }
-    return 0;
+    *info = ((struct radeon_drm_winsys *)rws)->info;
 }
 
 static boolean radeon_cs_request_feature(struct radeon_winsys_cs *rcs,
@@ -239,7 +234,7 @@ static boolean radeon_cs_request_feature(struct radeon_winsys_cs *rcs,
     struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
 
     switch (fid) {
-    case RADEON_FID_HYPERZ_RAM_ACCESS:
+    case RADEON_FID_R300_HYPERZ_ACCESS:
         if (debug_get_bool_option("RADEON_HYPERZ", FALSE)) {
             return radeon_set_fd_access(cs, &cs->ws->hyperz_owner,
                                         &cs->ws->hyperz_owner_mutex,
@@ -248,7 +243,7 @@ static boolean radeon_cs_request_feature(struct radeon_winsys_cs *rcs,
             return FALSE;
         }
 
-    case RADEON_FID_CMASK_RAM_ACCESS:
+    case RADEON_FID_R300_CMASK_ACCESS:
         if (debug_get_bool_option("RADEON_CMASK", FALSE)) {
             return radeon_set_fd_access(cs, &cs->ws->cmask_owner,
                                         &cs->ws->cmask_owner_mutex,
@@ -268,16 +263,9 @@ struct radeon_winsys *radeon_drm_winsys_create(int fd)
     }
 
     ws->fd = fd;
-    do_ioctls(ws);
 
-    switch (ws->pci_id) {
-#define CHIPSET(pci_id, name, family) case pci_id:
-#include "pci_ids/r300_pci_ids.h"
-#undef CHIPSET
-       break;
-    default:
-       goto fail;
-    }
+    if (!do_winsys_init(ws))
+        goto fail;
 
     /* Create managers. */
     ws->kman = radeon_bomgr_create(ws);
@@ -289,7 +277,7 @@ struct radeon_winsys *radeon_drm_winsys_create(int fd)
 
     /* Set functions. */
     ws->base.destroy = radeon_winsys_destroy;
-    ws->base.get_value = radeon_get_value;
+    ws->base.query_info = radeon_query_info;
     ws->base.cs_request_feature = radeon_cs_request_feature;
 
     radeon_bomgr_init_functions(ws);
index d5186bc..347e1f1 100644 (file)
@@ -31,7 +31,6 @@
 #define RADEON_DRM_WINSYS_H
 
 #include "radeon_winsys.h"
-
 #include "os/os_thread.h"
 
 struct radeon_drm_winsys {
@@ -40,20 +39,13 @@ struct radeon_drm_winsys {
     int fd; /* DRM file descriptor */
     int num_cs; /* The number of command streams created. */
 
+    struct radeon_info info;
+
     struct pb_manager *kman;
     struct pb_manager *cman;
 
-    uint32_t pci_id;        /* PCI ID */
-    uint32_t gb_pipes;      /* GB pipe count */
-    uint32_t z_pipes;       /* Z pipe count (rv530 only) */
-    uint32_t gart_size;     /* GART size. */
-    uint32_t vram_size;     /* VRAM size. */
     uint32_t num_cpus;      /* Number of CPUs. */
 
-    unsigned drm_major;
-    unsigned drm_minor;
-    unsigned drm_patchlevel;
-
     struct radeon_drm_cs *hyperz_owner;
     pipe_mutex hyperz_owner_mutex;
     struct radeon_drm_cs *cmask_owner;
index 3a64e4a..f8a4d3a 100644 (file)
 
 /* The public winsys interface header for the radeon driver. */
 
+/* R300 features in DRM.
+ *
+ * 2.6.0:
+ * - Hyper-Z
+ * - GB_Z_PEQ_CONFIG on rv350->r4xx
+ * - R500 FG_ALPHA_VALUE
+ *
+ * 2.8.0:
+ * - R500 US_FORMAT regs
+ * - R500 ARGB2101010 colorbuffer
+ * - CMask and AA regs
+ * - R16F/RG16F
+ */
+
 #include "pipebuffer/pb_bufmgr.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
@@ -55,43 +69,22 @@ struct radeon_winsys_cs {
     uint32_t *buf; /* The command buffer. */
 };
 
-enum radeon_value_id {
-    RADEON_VID_PCI_ID,
-    RADEON_VID_R300_GB_PIPES,
-    RADEON_VID_R300_Z_PIPES,
-    RADEON_VID_GART_SIZE,
-    RADEON_VID_VRAM_SIZE,
-    RADEON_VID_DRM_MAJOR,
-    RADEON_VID_DRM_MINOR,
-    RADEON_VID_DRM_PATCHLEVEL,
-
-    /* These should probably go away: */
-
-    /* R300 features:
-     * - Hyper-Z
-     * - GB_Z_PEQ_CONFIG on rv350->r4xx
-     * - R500 FG_ALPHA_VALUE
-     *
-     * R600 features:
-     * - TBD
-     */
-    RADEON_VID_DRM_2_6_0,
+struct radeon_info {
+    uint32_t pci_id;
+    uint32_t gart_size;
+    uint32_t vram_size;
 
-    /* R300 features:
-     * - R500 US_FORMAT regs
-     * - R500 ARGB2101010 colorbuffer
-     * - CMask and AA regs
-     * - R16F/RG16F
-     *
-     * R600 features:
-     * - TBD
-     */
-    RADEON_VID_DRM_2_8_0,
+    uint32_t drm_major; /* version */
+    uint32_t drm_minor;
+    uint32_t drm_patchlevel;
+
+    uint32_t r300_num_gb_pipes;
+    uint32_t r300_num_z_pipes;
 };
 
 enum radeon_feature_id {
-    RADEON_FID_HYPERZ_RAM_ACCESS,     /* ZMask + HiZ */
-    RADEON_FID_CMASK_RAM_ACCESS,
+    RADEON_FID_R300_HYPERZ_ACCESS,     /* ZMask + HiZ */
+    RADEON_FID_R300_CMASK_ACCESS,
 };
 
 struct radeon_winsys {
@@ -103,13 +96,13 @@ struct radeon_winsys {
     void (*destroy)(struct radeon_winsys *ws);
 
     /**
-     * Query a system value from a winsys.
+     * Query an info structure from winsys.
      *
      * \param ws        The winsys this function is called from.
-     * \param vid       One of the RADEON_VID_* enums.
+     * \param info      Return structure
      */
-    uint32_t (*get_value)(struct radeon_winsys *ws,
-                          enum radeon_value_id vid);
+    void (*query_info)(struct radeon_winsys *ws,
+                       struct radeon_info *info);
 
     /**************************************************************************
      * Buffer management. Buffer attributes are mostly fixed over its lifetime.
@@ -126,7 +119,6 @@ struct radeon_winsys {
      * \param size      The size to allocate.
      * \param alignment An alignment of the buffer in memory.
      * \param bind      A bitmask of the PIPE_BIND_* flags.
-     * \param usage     A bitmask of the PIPE_USAGE_* flags.
      * \param domain    A bitmask of the RADEON_DOMAIN_* flags.
      * \return          The created buffer object.
      */
@@ -134,7 +126,6 @@ struct radeon_winsys {
                                        unsigned size,
                                        unsigned alignment,
                                        unsigned bind,
-                                       unsigned usage,
                                        enum radeon_bo_domain domain);
 
     struct radeon_winsys_cs_handle *(*buffer_get_cs_handle)(
@@ -306,7 +297,7 @@ struct radeon_winsys {
      */
     void (*cs_set_flush)(struct radeon_winsys_cs *cs,
                          void (*flush)(void *ctx, unsigned flags),
-                         void *user);
+                         void *ctx);
 
     /**
      * Return TRUE if a buffer is referenced by a command stream.
@@ -321,7 +312,8 @@ struct radeon_winsys {
      * Request access to a feature for a command stream.
      *
      * \param cs        A command stream.
-     * \param fid       A winsys buffer.
+     * \param fid       Feature ID, one of RADEON_FID_*
+     * \param enable   Whether to enable or disable the feature.
      */
     boolean (*cs_request_feature)(struct radeon_winsys_cs *cs,
                                   enum radeon_feature_id fid,
index b049ea6..3e25c8a 100644 (file)
@@ -2,7 +2,7 @@ Import('*')
 
 env = env.Clone()
 
-env.ParseConfig('pkg-config --cflags libdrm')
+env.PkgUseModules('DRM')
 
 if env['gcc']:
     env.Append(CCFLAGS = ['-fvisibility=hidden'])
index f4f4cd7..38d88f6 100644 (file)
@@ -54,10 +54,8 @@ struct fbdev_sw_winsys
    struct sw_winsys base;
 
    int fd;
-   enum pipe_format format;
 
    struct fb_fix_screeninfo finfo;
-   void *fbmem;
    unsigned rows;
    unsigned stride;
 };
@@ -77,22 +75,53 @@ fbdev_sw_winsys(struct sw_winsys *ws)
 static void
 fbdev_displaytarget_display(struct sw_winsys *ws,
                             struct sw_displaytarget *dt,
-                            void *context_private)
+                            void *winsys_private)
 {
    struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws);
-   struct fbdev_sw_displaytarget *fbdt = fbdev_sw_displaytarget(dt);
-   unsigned rows, len, i;
+   struct fbdev_sw_displaytarget *src = fbdev_sw_displaytarget(dt);
+   const struct fbdev_sw_drawable *dst =
+      (const struct fbdev_sw_drawable *) winsys_private;
+   unsigned height, row_offset, row_len, i;
+   void *fbmem;
+
+   /* FIXME format conversion */
+   if (dst->format != src->format) {
+      assert(0);
+      return;
+   }
 
-   rows = MIN2(fbdt->height, fbdev->rows);
-   len = util_format_get_stride(fbdt->format, fbdt->width);
-   len = MIN2(len, fbdev->stride);
+   height = dst->height;
+   if (dst->y + dst->height > fbdev->rows) {
+      /* nothing to copy */
+      if (dst->y >= fbdev->rows)
+         return;
 
-   for (i = 0; i < rows; i++) {
-      void *dst = fbdev->fbmem + fbdev->stride * i;
-      void *src = fbdt->data + fbdt->stride * i;
+      height = fbdev->rows - dst->y;
+   }
+
+   row_offset = util_format_get_stride(dst->format, dst->x);
+   row_len = util_format_get_stride(dst->format, dst->width);
+   if (row_offset + row_len > fbdev->stride) {
+      /* nothing to copy */
+      if (row_offset >= fbdev->stride)
+         return;
 
-      memcpy(dst, src, len);
+      row_len = fbdev->stride - row_offset;
    }
+
+   fbmem = mmap(0, fbdev->finfo.smem_len,
+         PROT_WRITE, MAP_SHARED, fbdev->fd, 0);
+   if (fbmem == MAP_FAILED)
+      return;
+
+   for (i = 0; i < height; i++) {
+      char *from = (char *) src->data + src->stride * i;
+      char *to = (char *) fbmem + fbdev->stride * (dst->y + i) + row_offset;
+
+      memcpy(to, from, row_len);
+   }
+
+   munmap(fbmem, fbdev->finfo.smem_len);
 }
 
 static void
@@ -133,13 +162,9 @@ fbdev_displaytarget_create(struct sw_winsys *ws,
                            unsigned alignment,
                            unsigned *stride)
 {
-   struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws);
    struct fbdev_sw_displaytarget *fbdt;
    unsigned nblocksy, size, format_stride;
 
-   if (fbdev->format != format)
-      return NULL;
-
    fbdt = CALLOC_STRUCT(fbdev_sw_displaytarget);
    if (!fbdt)
       return NULL;
@@ -170,8 +195,7 @@ fbdev_is_displaytarget_format_supported(struct sw_winsys *ws,
                                         unsigned tex_usage,
                                         enum pipe_format format)
 {
-   struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws);
-   return (fbdev->format == format);
+   return TRUE;
 }
 
 static void
@@ -179,12 +203,11 @@ fbdev_destroy(struct sw_winsys *ws)
 {
    struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws);
 
-   munmap(fbdev->fbmem, fbdev->finfo.smem_len);
    FREE(fbdev);
 }
 
 struct sw_winsys *
-fbdev_create_sw_winsys(int fd, enum pipe_format format)
+fbdev_create_sw_winsys(int fd)
 {
    struct fbdev_sw_winsys *fbdev;
 
@@ -193,19 +216,11 @@ fbdev_create_sw_winsys(int fd, enum pipe_format format)
       return NULL;
 
    fbdev->fd = fd;
-   fbdev->format = format;
    if (ioctl(fbdev->fd, FBIOGET_FSCREENINFO, &fbdev->finfo)) {
       FREE(fbdev);
       return NULL;
    }
 
-   fbdev->fbmem = mmap(0, fbdev->finfo.smem_len,
-         PROT_WRITE, MAP_SHARED, fbdev->fd, 0);
-   if (fbdev->fbmem == MAP_FAILED) {
-      FREE(fbdev);
-      return NULL;
-   }
-
    fbdev->rows = fbdev->finfo.smem_len / fbdev->finfo.line_length;
    fbdev->stride = fbdev->finfo.line_length;
 
index d958ab9..59d8a8f 100644 (file)
 struct sw_winsys;
 enum pipe_format;
 
+/* for pipe_screen::flush_frontbuffer */
+struct fbdev_sw_drawable {
+   enum pipe_format format;
+   unsigned x, y;
+   unsigned width, height;
+};
+
 struct sw_winsys *
-fbdev_create_sw_winsys(int fd, enum pipe_format format);
+fbdev_create_sw_winsys(int fd);
 
 #endif /* FBDEV_SW_WINSYS */
index 5e3cfd0..bedd240 100644 (file)
@@ -27,6 +27,7 @@
 #define WAYLAND_SW_WINSYS
 
 struct sw_winsys;
+struct wl_display;
 
 struct winsys_handle {
    int fd;
diff --git a/src/gbm/Makefile b/src/gbm/Makefile
new file mode 100644 (file)
index 0000000..4769a97
--- /dev/null
@@ -0,0 +1,14 @@
+# src/gbm/Makefile
+
+TOP = ../..
+include $(TOP)/configs/current
+
+SUBDIRS = backends main
+
+
+default install clean:
+       @for dir in $(SUBDIRS) ; do \
+               if [ -d $$dir ] ; then \
+                       (cd $$dir && $(MAKE) $@) || exit 1 ; \
+               fi \
+       done
diff --git a/src/gbm/backends/Makefile b/src/gbm/backends/Makefile
new file mode 100644 (file)
index 0000000..97eaac4
--- /dev/null
@@ -0,0 +1,14 @@
+# src/gbm/backends/Makefile
+
+TOP = ../../..
+include $(TOP)/configs/current
+
+SUBDIRS = $(GBM_BACKEND_DIRS)
+
+
+default install clean:
+       @for dir in $(SUBDIRS) ; do \
+               if [ -d $$dir ] ; then \
+                       (cd $$dir ; $(MAKE) $@) || exit 1 ; \
+               fi \
+       done
diff --git a/src/gbm/backends/Makefile.template b/src/gbm/backends/Makefile.template
new file mode 100644 (file)
index 0000000..851e5c5
--- /dev/null
@@ -0,0 +1,65 @@
+# src/gbm/backends/Makefile.template
+#
+# Backends should define
+#
+# GBM_BACKEND, the driver name
+# GBM_SOURCES, the driver sources
+# GBM_INCLUDES, the include pathes
+# GBM_CFLAGS, additional CFLAGS
+# GBM_LIBS, additional LIBS
+#
+# before including this template.
+#
+
+
+GBM_BACKEND_PATH = $(TOP)/$(LIB_DIR)/gbm/$(GBM_BACKEND).so
+GBM_OBJECTS = $(GBM_SOURCES:.c=.o)
+
+# built-in or external
+ifeq ($(GBM_BUILTIN), true)
+GBM_TARGET = lib$(GBM_BACKEND).a
+GBM_INSTALL =
+else
+GBM_TARGET = $(GBM_BACKEND_PATH)
+GBM_INSTALL = install-so
+endif
+
+default: depend $(GBM_TARGET) $(GBM_EXTRA_TARGETS)
+
+$(GBM_BACKEND_PATH): $(GBM_BACKEND).so
+       @$(INSTALL) -d $(TOP)/$(LIB_DIR)/gbm
+       $(INSTALL) $< $(TOP)/$(LIB_DIR)/gbm
+
+$(GBM_BACKEND).so: $(GBM_OBJECTS) Makefile $(TOP)/src/gbm/backends/Makefile.template
+       @$(MKLIB) -o $(GBM_BACKEND).so -noprefix \
+               -linker '$(CC)' -ldflags '-L$(TOP)/$(LIB_DIR) $(LDFLAGS)' \
+               $(MKLIB_OPTIONS) \
+               $(GBM_OBJECTS) $(GBM_LIBS) -l$(GBM_LIB)
+
+lib$(GBM_BACKEND).a: $(GBM_OBJECTS) Makefile $(TOP)/src/gbm/backends/Makefile.template
+       @$(MKLIB) -o $(GBM_BACKEND) -static $(GBM_OBJECTS)
+
+.c.o:
+       $(CC) -c $(GBM_INCLUDES) $(CFLAGS) $(GBM_CFLAGS) $< -o $@
+
+install-so: $(GBM_BACKEND_PATH)
+       $(INSTALL) -d $(DESTDIR)$(GBM_BACKEND_INSTALL_DIR)
+       $(MINSTALL) $(GBM_BACKEND_PATH) $(DESTDIR)$(GBM_BACKEND_INSTALL_DIR)
+
+install: $(GBM_INSTALL) $(GBM_EXTRA_INSTALL)
+
+clean: $(GBM_EXTRA_CLEAN)
+       rm -f $(GBM_BACKEND).so
+       rm -f lib$(GBM_BACKEND).a
+       rm -f $(GBM_OBJECTS)
+       rm -f depend depend.bak
+
+depend: $(GBM_SOURCES) $(GBM_EXTRA_SOURCES)
+       @ echo "running $(MKDEP)"
+       @ rm -f depend
+       @ touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(GBM_INCLUDES) $(GBM_SOURCES) \
+               $(GBM_EXTRA_SOURCES) >/dev/null 2>/dev/null
+
+sinclude depend
+# DO NOT DELETE
diff --git a/src/gbm/backends/dri/Makefile b/src/gbm/backends/dri/Makefile
new file mode 100644 (file)
index 0000000..78fb329
--- /dev/null
@@ -0,0 +1,22 @@
+# src/gbm/backends/dri/Makefile
+
+TOP = ../../../..
+include $(TOP)/configs/current
+
+GBM_BACKEND = gbm_dri
+GBM_SOURCES = gbm_dri.c driver_name.c
+
+GBM_INCLUDES = \
+       -I$(TOP)/include \
+       -I$(TOP)/src/gbm/main \
+
+GBM_LIBS = $(LIBUDEV_LIBS) $(LIBDRM_LIB) -L$(TOP)/lib -lglapi 
+
+GBM_CFLAGS = \
+       -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \
+       $(LIBUDEV_CFLAGS) \
+       $(LIBDRM_CFLAGS)
+
+GBM_BUILTIN=true
+
+include ../Makefile.template
diff --git a/src/gbm/backends/dri/driver_name.c b/src/gbm/backends/dri/driver_name.c
new file mode 100644 (file)
index 0000000..2ed209f
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Kristian Høgsberg <krh@bitplanet.net>
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <libudev.h>
+
+#include "gbm_driint.h"
+#define DRIVER_MAP_DRI2_ONLY
+#include "pci_ids/pci_id_driver_map.h"
+
+char *
+dri_fd_get_driver_name(int fd)
+{
+   struct udev *udev;
+   struct udev_device *device, *parent;
+   const char *pci_id;
+   char *driver = NULL;
+   int vendor_id, chip_id, i, j;
+
+   udev = udev_new();
+   device = _gbm_udev_device_new_from_fd(udev, fd);
+   if (device == NULL)
+      return NULL;
+
+   parent = udev_device_get_parent(device);
+   if (parent == NULL) {
+      fprintf(stderr, "gbm: could not get parent device");
+      goto out;
+   }
+
+   pci_id = udev_device_get_property_value(parent, "PCI_ID");
+   if (pci_id == NULL ||
+       sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
+      fprintf(stderr, "gbm: malformed or no PCI ID");
+      goto out;
+   }
+
+   for (i = 0; driver_map[i].driver; i++) {
+      if (vendor_id != driver_map[i].vendor_id)
+         continue;
+      if (driver_map[i].num_chips_ids == -1) {
+         driver = strdup(driver_map[i].driver);
+         _gbm_log("pci id for %d: %04x:%04x, driver %s",
+                  fd, vendor_id, chip_id, driver);
+         goto out;
+      }
+
+      for (j = 0; j < driver_map[i].num_chips_ids; j++)
+         if (driver_map[i].chip_ids[j] == chip_id) {
+            driver = strdup(driver_map[i].driver);
+            _gbm_log("pci id for %d: %04x:%04x, driver %s",
+                     fd, vendor_id, chip_id, driver);
+            goto out;
+         }
+   }
+
+out:
+   udev_device_unref(device);
+   udev_unref(udev);
+
+   return driver;
+}
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
new file mode 100644 (file)
index 0000000..9de8cb6
--- /dev/null
@@ -0,0 +1,380 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <limits.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <dlfcn.h>
+
+#include <GL/gl.h> /* dri_interface needs GL types */
+#include <GL/internal/dri_interface.h>
+
+#include "gbm_driint.h"
+
+#include "gbmint.h"
+
+static __DRIimage *
+dri_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
+{
+   struct gbm_dri_device *dri = data;
+
+   if (dri->lookup_image == NULL)
+      return NULL;
+
+   return dri->lookup_image(screen, image, dri->lookup_user_data);
+}
+
+const __DRIuseInvalidateExtension use_invalidate = {
+   { __DRI_USE_INVALIDATE, 1 }
+};
+
+const __DRIimageLookupExtension image_lookup_extension = {
+   { __DRI_IMAGE_LOOKUP, 1 },
+   dri_lookup_egl_image
+};
+
+struct dri_extension_match {
+   const char *name;
+   int version;
+   int offset;
+};
+
+static struct dri_extension_match dri_core_extensions[] = {
+   { __DRI_IMAGE, 1, offsetof(struct gbm_dri_device, image) },
+   { NULL, 0, 0 }
+};
+
+static struct dri_extension_match gbm_dri_device_extensions[] = {
+   { __DRI_CORE, 1, offsetof(struct gbm_dri_device, core) },
+   { __DRI_DRI2, 1, offsetof(struct gbm_dri_device, dri2) },
+   { NULL, 0, 0 }
+};
+
+static int
+dri_bind_extensions(struct gbm_dri_device *dri,
+                    struct dri_extension_match *matches,
+                    const __DRIextension **extensions)
+{
+   int i, j, ret = 0;
+   void *field;
+
+   for (i = 0; extensions[i]; i++) {
+      for (j = 0; matches[j].name; j++) {
+         if (strcmp(extensions[i]->name, matches[j].name) == 0 &&
+             extensions[i]->version >= matches[j].version) {
+            field = ((char *) dri + matches[j].offset);
+            *(const __DRIextension **) field = extensions[i];
+         }
+      }
+   }
+
+   for (j = 0; matches[j].name; j++) {
+      field = ((char *) dri + matches[j].offset);
+      if (*(const __DRIextension **) field == NULL) {
+         ret = -1;
+      }
+   }
+
+   return ret;
+}
+
+static int
+dri_load_driver(struct gbm_dri_device *dri)
+{
+   const __DRIextension **extensions;
+   char path[PATH_MAX], *search_paths, *p, *next, *end;
+
+   search_paths = NULL;
+   if (geteuid() == getuid()) {
+      /* don't allow setuid apps to use GBM_DRIVERS_PATH */
+      search_paths = getenv("GBM_DRIVERS_PATH");
+   }
+   if (search_paths == NULL)
+      search_paths = DEFAULT_DRIVER_DIR;
+
+   dri->driver = NULL;
+   end = search_paths + strlen(search_paths);
+   for (p = search_paths; p < end && dri->driver == NULL; p = next + 1) {
+      int len;
+      next = strchr(p, ':');
+      if (next == NULL)
+         next = end;
+
+      len = next - p;
+#if GLX_USE_TLS
+      snprintf(path, sizeof path,
+               "%.*s/tls/%s_dri.so", len, p, dri->base.driver_name);
+      dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
+#endif
+      if (dri->driver == NULL) {
+         snprintf(path, sizeof path,
+                  "%.*s/%s_dri.so", len, p, dri->base.driver_name);
+         dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
+         if (dri->driver == NULL)
+            fprintf(stderr, "failed to open %s: %s\n", path, dlerror());
+      }
+   }
+
+   if (dri->driver == NULL) {
+      fprintf(stderr, "gbm: failed to open any driver (search paths %s)",
+              search_paths);
+      return -1;
+   }
+
+   extensions = dlsym(dri->driver, __DRI_DRIVER_EXTENSIONS);
+   if (extensions == NULL) {
+      fprintf(stderr, "gbm: driver exports no extensions (%s)", dlerror());
+      dlclose(dri->driver);
+      return -1;
+   }
+
+
+   if (dri_bind_extensions(dri, gbm_dri_device_extensions, extensions) < 0) {
+      dlclose(dri->driver);
+      fprintf(stderr, "failed to bind extensions\n");
+      return -1;
+   }
+
+   return 0;
+}
+
+static int
+dri_screen_create(struct gbm_dri_device *dri)
+{
+   const __DRIextension **extensions;
+   int ret = 0;
+
+   dri->base.driver_name = dri_fd_get_driver_name(dri->base.base.fd);
+   if (dri->base.driver_name == NULL)
+      return -1;
+
+   ret = dri_load_driver(dri);
+   if (ret) {
+      fprintf(stderr, "failed to load driver: %s\n", dri->base.driver_name);
+      return ret;
+   };
+
+   dri->extensions[0] = &image_lookup_extension.base;
+   dri->extensions[1] = &use_invalidate.base;
+   dri->extensions[2] = NULL;
+
+   if (dri->dri2 == NULL)
+      return -1;
+
+   dri->screen = dri->dri2->createNewScreen(0, dri->base.base.fd,
+                                            dri->extensions,
+                                            &dri->driver_configs, dri);
+   if (dri->screen == NULL)
+      return -1;
+
+   extensions = dri->core->getExtensions(dri->screen);
+   if (dri_bind_extensions(dri, dri_core_extensions, extensions) < 0) {
+      ret = -1;
+      goto free_screen;
+   }
+
+   dri->lookup_image = NULL;
+   dri->lookup_user_data = NULL;
+
+   return 0;
+
+free_screen:
+   dri->core->destroyScreen(dri->screen);
+
+   return ret;
+}
+
+static int
+gbm_dri_is_format_supported(struct gbm_device *gbm,
+                            enum gbm_bo_format format,
+                            uint32_t usage)
+{
+   switch (format) {
+   case GBM_BO_FORMAT_XRGB8888:
+      break;
+   case GBM_BO_FORMAT_ARGB8888:
+      if (usage & GBM_BO_USE_SCANOUT)
+         return 0;
+      break;
+   default:
+      return 0;
+   }
+
+   if (usage & GBM_BO_USE_CURSOR_64X64 &&
+       usage & GBM_BO_USE_RENDERING)
+      return 0;
+
+   return 1;
+}
+
+static void
+gbm_dri_bo_destroy(struct gbm_bo *_bo)
+{
+   struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
+   struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
+
+   dri->image->destroyImage(bo->image);
+   free(bo);
+}
+
+static struct gbm_bo *
+gbm_dri_bo_create_from_egl_image(struct gbm_device *gbm,
+                                 void *egl_dpy, void *egl_img,
+                                 uint32_t width, uint32_t height,
+                                 uint32_t usage)
+{
+   struct gbm_dri_device *dri = gbm_dri_device(gbm);
+   struct gbm_dri_bo *bo;
+
+   (void) egl_dpy;
+
+   if (dri->lookup_image == NULL)
+      return NULL;
+
+   bo = calloc(1, sizeof *bo);
+   if (bo == NULL)
+      return NULL;
+
+   bo->base.base.gbm = gbm;
+   bo->base.base.width = width;
+   bo->base.base.height = height;
+
+   __DRIimage *tmp = dri->lookup_image(dri->screen, egl_img,
+                                       dri->lookup_user_data);
+
+   bo->image = dri->image->dupImage(tmp, bo);
+   if (bo->image == NULL)
+      return NULL;
+   
+   dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE,
+                          &bo->base.base.handle.s32);
+   dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
+                          (int *) &bo->base.base.pitch);
+
+   return &bo->base.base;
+}
+
+static struct gbm_bo *
+gbm_dri_bo_create(struct gbm_device *gbm,
+                  uint32_t width, uint32_t height,
+                  enum gbm_bo_format format, uint32_t usage)
+{
+   struct gbm_dri_device *dri = gbm_dri_device(gbm);
+   struct gbm_dri_bo *bo;
+   int dri_format;
+   unsigned dri_use = 0;
+
+   bo = calloc(1, sizeof *bo);
+   if (bo == NULL)
+      return NULL;
+
+   bo->base.base.gbm = gbm;
+   bo->base.base.width = width;
+   bo->base.base.height = height;
+
+   switch (format) {
+   case GBM_BO_FORMAT_XRGB8888:
+      dri_format = __DRI_IMAGE_FORMAT_XRGB8888;
+      break;
+   case GBM_BO_FORMAT_ARGB8888:
+      dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
+      break;
+   default:
+      return NULL;
+   }
+
+   if (usage & GBM_BO_USE_SCANOUT)
+      dri_use |= __DRI_IMAGE_USE_SCANOUT;
+   if (usage & GBM_BO_USE_CURSOR_64X64)
+      dri_use |= __DRI_IMAGE_USE_CURSOR;
+
+   bo->image =
+      dri->image->createImage(dri->screen,
+                              width, height,
+                              dri_format, dri_use,
+                              bo);
+   if (bo->image == NULL)
+      return NULL;
+
+   dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE,
+                          &bo->base.base.handle.s32);
+   dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
+                          (int *) &bo->base.base.pitch);
+
+   return &bo->base.base;
+}
+
+static void
+dri_destroy(struct gbm_device *gbm)
+{
+   struct gbm_dri_device *dri = gbm_dri_device(gbm);
+
+   dri->core->destroyScreen(dri->screen);
+   free(dri->driver_configs);
+   dlclose(dri->driver);
+   free(dri->base.driver_name);
+
+   free(dri);
+}
+
+static struct gbm_device *
+dri_device_create(int fd)
+{
+   struct gbm_dri_device *dri;
+   int ret;
+
+   dri = calloc(1, sizeof *dri);
+
+   dri->base.base.fd = fd;
+   dri->base.base.bo_create = gbm_dri_bo_create;
+   dri->base.base.bo_create_from_egl_image = gbm_dri_bo_create_from_egl_image;
+   dri->base.base.is_format_supported = gbm_dri_is_format_supported;
+   dri->base.base.bo_destroy = gbm_dri_bo_destroy;
+   dri->base.base.destroy = dri_destroy;
+
+   dri->base.type = GBM_DRM_DRIVER_TYPE_DRI;
+   dri->base.base.name = "drm";
+
+   ret = dri_screen_create(dri);
+   if (ret) {
+      free(dri);
+      return NULL;
+   }
+
+   return &dri->base.base;
+}
+
+struct gbm_backend gbm_dri_backend = {
+   .backend_name = "dri",
+   .create_device = dri_device_create,
+};
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
new file mode 100644 (file)
index 0000000..c5b5e17
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#ifndef _GBM_DRI_INTERNAL_H_
+#define _GBM_DRI_INTERNAL_H_
+
+#include "gbmint.h"
+
+#include "common.h"
+#include "common_drm.h"
+
+#include <GL/gl.h> /* dri_interface needs GL types */
+#include "GL/internal/dri_interface.h"
+
+struct gbm_dri_device {
+   struct gbm_drm_device base;
+
+   void *driver;
+
+   __DRIscreen *screen;
+
+   __DRIcoreExtension   *core;
+   __DRIdri2Extension   *dri2;
+   __DRIimageExtension  *image;
+
+   const __DRIconfig   **driver_configs;
+   const __DRIextension *extensions[3];
+
+   __DRIimage *(*lookup_image)(__DRIscreen *screen, void *image, void *data);
+   void *lookup_user_data;
+};
+
+struct gbm_dri_bo {
+   struct gbm_drm_bo base;
+
+   __DRIimage *image;
+};
+
+static inline struct gbm_dri_device *
+gbm_dri_device(struct gbm_device *gbm)
+{
+   return (struct gbm_dri_device *) gbm;
+}
+
+static inline struct gbm_dri_bo *
+gbm_dri_bo(struct gbm_bo *bo)
+{
+   return (struct gbm_dri_bo *) bo;
+}
+
+char *
+dri_fd_get_driver_name(int fd);
+
+#endif
diff --git a/src/gbm/main/Makefile b/src/gbm/main/Makefile
new file mode 100644 (file)
index 0000000..5130b9b
--- /dev/null
@@ -0,0 +1,90 @@
+# src/gbm/main/Makefile
+
+TOP = ../../..
+include $(TOP)/configs/current
+
+INCLUDE_DIRS = -I$(TOP)/include
+
+HEADERS =              \
+       common.h        \
+       backend.h       \
+       gbmint.h        \
+       gbm.h   
+
+SOURCES =              \
+       gbm.c           \
+       backend.c       \
+       common.c
+
+OBJECTS = $(SOURCES:.c=.o)
+
+# use dl*() to load drivers
+LOCAL_CFLAGS = $(LIBUDEV_CFLAGS) $(DLOPEN_CFLAGS) \
+              -D_OS_UNIX=1 -DMODULEDIR='"$(GBM_BACKEND_INSTALL_DIR)"'
+LOCAL_LIBS =
+
+# Builtin backends
+ifeq ($(filter dri, $(GBM_BACKEND_DIRS)),dri)
+LOCAL_LIBS += $(TOP)/src/gbm/backends/dri/libgbm_dri.a
+endif
+
+.c.o:
+       $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@
+
+
+default: depend library
+
+
+library: $(TOP)/$(LIB_DIR)/libgbm.so
+
+$(TOP)/$(LIB_DIR)/libgbm.so: $(OBJECTS) $(LOCAL_LIBS)
+       $(MKLIB) -o gbm -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               -major 1 -minor 0 \
+               -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
+               -L$(TOP)/$(LIB_DIR) $(GBM_LIB_DEPS) \
+               $(OBJECTS) $(LOCAL_LIBS)
+
+install-headers:
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/
+       $(INSTALL) -m 644 $(TOP)/src/gbm/main/gbm.h \
+               $(DESTDIR)$(INSTALL_INC_DIR)
+
+
+PKG_CONFIG_DIR = $(INSTALL_LIB_DIR)/pkgconfig
+
+gbm_pcedit = sed \
+       -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
+       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
+       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
+       -e 's,@VERSION@,0.0.0,' \
+       -e 's,@GBM_PC_REQ_PRIV@,$(GBM_PC_REQ_PRIV),' \
+       -e 's,@GBM_PC_LIB_PRIV@,$(GBM_PC_LIB_PRIV),' \
+       -e 's,@GBM_PC_CFLAGS@,$(GBM_PC_CFLAGS),' \
+       -e 's,@GBM_LIB@,$(GBM_LIB),'
+
+gbm.pc: gbm.pc.in
+       $(gbm_pcedit) $< > $@
+
+install: default install-headers gbm.pc
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(MINSTALL) $(TOP)/$(LIB_DIR)/libgbm.so* \
+               $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(PKG_CONFIG_DIR)
+       $(INSTALL) -m 644 gbm.pc $(DESTDIR)$(PKG_CONFIG_DIR)
+
+clean:
+       -rm -f *.o
+       -rm -f depend depend.bak
+       -rm -f gbm.pc
+
+
+depend: $(SOURCES) $(HEADERS)
+       @ echo "running $(MKDEP)"
+       @ rm -f depend
+       @ touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \
+               $(SOURCES) $(HEADERS) > /dev/null 2>/dev/null
+
+
+-include depend
+# DO NOT DELETE
diff --git a/src/gbm/main/backend.c b/src/gbm/main/backend.c
new file mode 100644 (file)
index 0000000..aceb662
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <dlfcn.h>
+
+#include "backend.h"
+
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+
+extern const struct gbm_backend gbm_dri_backend;
+
+struct backend_desc {
+   const char *name;
+   const struct gbm_backend *builtin;
+};
+
+static const struct backend_desc backends[] = {
+   { "gbm_dri.so", &gbm_dri_backend },
+   { "gbm_gallium_drm.so", NULL },
+};
+
+static const void *
+load_backend(const struct backend_desc *backend)
+{
+   char path[PATH_MAX];
+   const void *init = NULL;
+   void *module;
+   const char *name;
+   const char *entrypoint = "gbm_backend";
+
+   if (backend == NULL)
+      return NULL;
+
+   name = backend->name;
+
+   if (backend->builtin) {
+      init = backend->builtin;
+   } else { 
+      if (name[0] != '/')
+         snprintf(path, sizeof path, MODULEDIR "/%s", name);
+      else
+         snprintf(path, sizeof path, "%s", name);
+
+      module = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
+      if (!module) {
+         fprintf(stderr,
+                 "failed to load module: %s\n", dlerror());
+         return NULL;
+      }
+
+      init = dlsym(module, entrypoint);
+      if (!init)
+         return NULL;
+   }
+
+   return init;
+}
+
+static const struct backend_desc *
+find_backend(const char *name)
+{
+   const struct backend_desc *backend = NULL;
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(backends); ++i) {
+      if (strcmp(backends[i].name, name) == 0) {
+         backend = &backends[i];
+         break;
+      }
+   }
+
+   return backend;
+}
+
+struct gbm_device *
+_gbm_create_device(int fd)
+{
+   const struct gbm_backend *backend = NULL;
+   struct gbm_device *dev = NULL;
+   int i;
+   const char *b;
+
+   b = getenv("GBM_BACKEND");
+   if (b)
+      backend = load_backend(find_backend(b));
+
+   if (backend)
+      dev = backend->create_device(fd);
+
+   for (i = 0; i < ARRAY_SIZE(backends) && dev == NULL; ++i) {
+      backend = load_backend(&backends[i]);
+      if (backend == NULL)
+         continue;
+
+      dev = backend->create_device(fd);
+   }
+   
+   return dev;
+}
diff --git a/src/gbm/main/backend.h b/src/gbm/main/backend.h
new file mode 100644 (file)
index 0000000..4a64375
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#ifndef MODULE_H_
+#define MODULE_H_
+
+#include "gbmint.h"
+
+struct gbm_device *
+_gbm_create_device(int fd);
+
+#endif
diff --git a/src/gbm/main/common.c b/src/gbm/main/common.c
new file mode 100644 (file)
index 0000000..f02162d
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <libudev.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "gbmint.h"
+
+GBM_EXPORT struct udev_device *
+_gbm_udev_device_new_from_fd(struct udev *udev, int fd)
+{
+   struct udev_device *device;
+   struct stat buf;
+
+   if (fstat(fd, &buf) < 0) {
+      fprintf(stderr, "gbm: failed to stat fd %d", fd);
+      return NULL;
+   }
+
+   device = udev_device_new_from_devnum(udev, 'c', buf.st_rdev);
+   if (device == NULL) {
+      fprintf(stderr,
+              "gbm: could not create udev device for fd %d", fd);
+      return NULL;
+   }
+
+   return device;
+}
+
+GBM_EXPORT char *
+_gbm_fd_get_device_name(int fd)
+{
+   struct udev *udev;
+   struct udev_device *device;
+   const char *const_device_name;
+   char *device_name = NULL;
+
+   udev = udev_new();
+   device = _gbm_udev_device_new_from_fd(udev, fd);
+   if (device == NULL)
+      return NULL;
+
+   const_device_name = udev_device_get_devnode(device);
+   if (!const_device_name)
+      goto out;
+   device_name = strdup(const_device_name);
+
+out:
+   udev_device_unref(device);
+   udev_unref(udev);
+
+   return device_name;
+}
+
+GBM_EXPORT void
+_gbm_log(const char *fmt_str, ...)
+{
+}
diff --git a/src/gbm/main/common.h b/src/gbm/main/common.h
new file mode 100644 (file)
index 0000000..1fcdfca
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#include <libudev.h>
+
+struct udev_device *
+_gbm_udev_device_new_from_fd(struct udev *udev, int fd);
+
+char *
+_gbm_fd_get_device_name(int fd);
+
+void
+_gbm_log(const char *fmt_str, ...);
+
+#endif
diff --git a/src/gbm/main/common_drm.h b/src/gbm/main/common_drm.h
new file mode 100644 (file)
index 0000000..d28c3f0
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#ifndef _COMMON_DRM_H_
+#define _COMMON_DRM_H_
+
+#include "gbmint.h"
+
+enum gbm_drm_driver_type {
+   GBM_DRM_DRIVER_TYPE_DRI,
+   GBM_DRM_DRIVER_TYPE_GALLIUM,
+};
+
+struct gbm_drm_device {
+   struct gbm_device base;
+   enum gbm_drm_driver_type type;
+   char *driver_name;
+};
+
+struct gbm_drm_bo {
+   struct gbm_bo base;
+};
+
+#endif
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
new file mode 100644 (file)
index 0000000..8440b2c
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#define _BSD_SOURCE
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "gbm.h"
+#include "gbmint.h"
+#include "common.h"
+#include "backend.h"
+
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+
+struct gbm_device *devices[16];
+
+static int device_num = 0;
+
+GBM_EXPORT int
+gbm_device_get_fd(struct gbm_device *gbm)
+{
+   return gbm->fd;
+}
+
+/* FIXME: maybe superfluous, use udev subclass from the fd? */
+GBM_EXPORT const char *
+gbm_device_get_backend_name(struct gbm_device *gbm)
+{
+   return gbm->name;
+}
+
+int
+gbm_device_is_format_supported(struct gbm_device *gbm,
+                               enum gbm_bo_format format,
+                               uint32_t usage)
+{
+   return gbm->is_format_supported(gbm, format, usage);
+}
+
+GBM_EXPORT void
+gbm_device_destroy(struct gbm_device *gbm)
+{
+   gbm->refcount--;
+   if (gbm->refcount == 0)
+      gbm->destroy(gbm);
+}
+
+GBM_EXPORT struct gbm_device *
+_gbm_mesa_get_device(int fd)
+{
+   struct gbm_device *gbm = NULL;
+   struct stat buf;
+   dev_t dev;
+   int i;
+
+   if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) {
+      fprintf(stderr, "_gbm_mesa_get_device: invalid fd: %d\n", fd);
+      return NULL;
+   }
+
+   for (i = 0; i < device_num; ++i) {
+      dev = devices[i]->stat.st_rdev;
+      if (major(dev) == major(buf.st_rdev) &&
+          minor(dev) == minor(buf.st_rdev)) {
+         gbm = devices[i];
+         gbm->refcount++;
+         break;
+      }
+   }
+
+   return gbm;
+}
+
+GBM_EXPORT struct gbm_device *
+gbm_create_device(int fd)
+{
+   struct gbm_device *gbm = NULL;
+   struct stat buf;
+
+   if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) {
+      fprintf(stderr, "gbm_create_device: invalid fd: %d\n", fd);
+      return NULL;
+   }
+
+   if (device_num == 0)
+      memset(devices, 0, sizeof devices);
+
+   gbm = _gbm_create_device(fd);
+   if (gbm == NULL)
+      return NULL;
+
+   gbm->dummy = gbm_create_device;
+   gbm->stat = buf;
+   gbm->refcount = 1;
+
+   if (device_num < ARRAY_SIZE(devices)-1)
+      devices[device_num++] = gbm;
+
+   return gbm;
+}
+
+GBM_EXPORT unsigned int
+gbm_bo_get_width(struct gbm_bo *bo)
+{
+   return bo->width;
+}
+
+GBM_EXPORT unsigned int
+gbm_bo_get_height(struct gbm_bo *bo)
+{
+   return bo->height;
+}
+
+GBM_EXPORT uint32_t
+gbm_bo_get_pitch(struct gbm_bo *bo)
+{
+   return bo->pitch;
+}
+
+GBM_EXPORT union gbm_bo_handle
+gbm_bo_get_handle(struct gbm_bo *bo)
+{
+   return bo->handle;
+}
+
+GBM_EXPORT void
+gbm_bo_destroy(struct gbm_bo *bo)
+{
+   bo->gbm->bo_destroy(bo);
+}
+
+GBM_EXPORT struct gbm_bo *
+gbm_bo_create(struct gbm_device *gbm,
+              uint32_t width, uint32_t height,
+              enum gbm_bo_format format, uint32_t usage)
+{
+   if (width == 0 || height == 0)
+      return NULL;
+
+   if (usage & GBM_BO_USE_CURSOR_64X64 &&
+       (width != 64 || height != 64))
+      return NULL;
+
+   return gbm->bo_create(gbm, width, height, format, usage);
+}
+
+GBM_EXPORT struct gbm_bo *
+gbm_bo_create_from_egl_image(struct gbm_device *gbm,
+                             void *egl_dpy, void *egl_image,
+                             uint32_t width, uint32_t height,
+                             uint32_t usage)
+{
+   if (width == 0 || height == 0)
+      return NULL;
+
+   return gbm->bo_create_from_egl_image(gbm, egl_dpy, egl_image,
+                                        width, height, usage);
+}
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
new file mode 100644 (file)
index 0000000..05d2292
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#ifndef _GBM_H_
+#define _GBM_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define __GBM__ 1
+
+#include <stdint.h>
+
+struct gbm_device;
+struct gbm_bo;
+
+union gbm_bo_handle {
+   void *ptr;
+   int32_t s32;
+   uint32_t u32;
+   int64_t s64;
+   uint64_t u64;
+};
+
+enum gbm_bo_format {
+   GBM_BO_FORMAT_XRGB8888,
+   GBM_BO_FORMAT_ARGB8888,
+};
+
+enum gbm_bo_flags {
+   GBM_BO_USE_SCANOUT      = (1 << 0),
+   GBM_BO_USE_CURSOR_64X64 = (1 << 1),
+   GBM_BO_USE_RENDERING    = (1 << 2),
+};
+
+int
+gbm_device_get_fd(struct gbm_device *gbm);
+
+const char *
+gbm_device_get_backend_name(struct gbm_device *gbm);
+
+int
+gbm_device_is_format_supported(struct gbm_device *gbm,
+                               enum gbm_bo_format format,
+                               uint32_t usage);
+
+void
+gbm_device_destroy(struct gbm_device *gbm);
+
+struct gbm_device *
+gbm_create_device(int fd);
+
+struct gbm_bo *
+gbm_bo_create(struct gbm_device *gbm,
+              uint32_t width, uint32_t height,
+              enum gbm_bo_format format, uint32_t flags);
+
+struct gbm_bo *
+gbm_bo_create_from_egl_image(struct gbm_device *gbm,
+                             void *egl_dpy, void *egl_img,
+                             uint32_t width, uint32_t height,
+                             uint32_t usage);
+
+uint32_t
+gbm_bo_get_width(struct gbm_bo *bo);
+
+uint32_t
+gbm_bo_get_height(struct gbm_bo *bo);
+
+uint32_t
+gbm_bo_get_pitch(struct gbm_bo *bo);
+
+union gbm_bo_handle
+gbm_bo_get_handle(struct gbm_bo *bo);
+
+void
+gbm_bo_destroy(struct gbm_bo *bo);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gbm/main/gbm.pc.in b/src/gbm/main/gbm.pc.in
new file mode 100644 (file)
index 0000000..76299e7
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@INSTALL_DIR@
+exec_prefix=${prefix}
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+
+Name: gbm
+Description: Mesa gbm library
+Requires.private: @GBM_PC_REQ_PRIV@
+Version: @VERSION@
+Libs: -L${libdir} -l@GBM_LIB@
+Libs.private: @GBM_PC_LIB_PRIV@
+Cflags: -I${includedir} @GBM_PC_CFLAGS@
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h
new file mode 100644 (file)
index 0000000..fb8db80
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright Â© 2011 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:
+ *    Benjamin Franzke <benjaminfranzke@googlemail.com>
+ */
+
+#ifndef INTERNAL_H_
+#define INTERNAL_H_
+
+#include "gbm.h"
+#include <sys/stat.h>
+
+/* GCC visibility */
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define GBM_EXPORT __attribute__ ((visibility("default")))
+#else
+#define GBM_EXPORT
+#endif
+
+struct gbm_device {
+   /* Hack to make a gbm_device detectable by its first element. */
+   struct gbm_device *(*dummy)(int);
+
+   int fd;
+   const char *name;
+   unsigned int refcount;
+   struct stat stat;
+
+   void (*destroy)(struct gbm_device *gbm);
+   int (*is_format_supported)(struct gbm_device *gbm,
+                              enum gbm_bo_format format,
+                              uint32_t usage);
+
+   struct gbm_bo *(*bo_create)(struct gbm_device *gbm,
+                               uint32_t width, uint32_t height,
+                               enum gbm_bo_format format,
+                               uint32_t usage);
+   struct gbm_bo *(*bo_create_from_egl_image)(struct gbm_device *gbm,
+                                              void *egl_dpy, void *egl_img,
+                                              uint32_t width, uint32_t height,
+                                              uint32_t usage);
+   void (*bo_destroy)(struct gbm_bo *bo);
+};
+
+struct gbm_bo {
+   struct gbm_device *gbm;
+   uint32_t width;
+   uint32_t height;
+   uint32_t pitch;
+   union gbm_bo_handle  handle;
+};
+
+struct gbm_backend {
+   const char *backend_name;
+   struct gbm_device *(*create_device)(int fd);
+};
+
+GBM_EXPORT struct gbm_device *
+_gbm_mesa_get_device(int fd);
+
+#endif
index dfbd572..d26839a 100644 (file)
@@ -5,3 +5,4 @@ glsl_parser.h
 glsl_parser.output
 builtin_function.cpp
 builtin_compiler
+glsl_test
index 4100414..c20a6c9 100644 (file)
@@ -39,6 +39,7 @@ CXX_SOURCES = \
        ir.cpp \
        ir_expression_flattening.cpp \
        ir_function_can_inline.cpp \
+       ir_function_detect_recursion.cpp \
        ir_function.cpp \
        ir_hierarchical_visitor.cpp \
        ir_hv_accept.cpp \
@@ -88,18 +89,32 @@ CXX_SOURCES = \
 LIBS = \
        $(TOP)/src/glsl/libglsl.a
 
-APPS = glsl_compiler glcpp/glcpp
+APPS = glsl_compiler glsl_test glcpp/glcpp
 
 GLSL2_C_SOURCES = \
        ../mesa/program/hash_table.c \
        ../mesa/program/symbol_table.c
 GLSL2_CXX_SOURCES = \
-       main.cpp
+       main.cpp \
+       standalone_scaffolding.cpp
 
 GLSL2_OBJECTS = \
        $(GLSL2_C_SOURCES:.c=.o) \
        $(GLSL2_CXX_SOURCES:.cpp=.o)
 
+TEST_C_SOURCES = \
+       ../mesa/program/hash_table.c \
+       ../mesa/program/symbol_table.c
+
+TEST_CXX_SOURCES = \
+       standalone_scaffolding.cpp \
+       test.cpp \
+       test_optpass.cpp
+
+TEST_OBJECTS = \
+       $(TEST_C_SOURCES:.c=.o) \
+       $(TEST_CXX_SOURCES:.cpp=.o)
+
 ### Basic defines ###
 
 DEFINES += \
@@ -128,7 +143,9 @@ ALL_SOURCES = \
        $(C_SOURCES) \
        $(CXX_SOURCES) \
        $(GLSL2_CXX_SOURCES) \
-       $(GLSL2_C_SOURCES)
+       $(GLSL2_C_SOURCES) \
+       $(TEST_CXX_SOURCES) \
+       $(TEST_C_SOURCES)
 
 ##### TARGETS #####
 
@@ -147,14 +164,15 @@ depend: $(ALL_SOURCES) Makefile
        rm -f depend
        touch depend
        $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
+       $(MKDEP) $(MKDEP_OPTIONS) -a -p $(DRICORE_OBJ_DIR)/ $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
 
 # Remove .o and backup files
 clean: clean-dricore
-       rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler
+       rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(TEST_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler
        -rm -f $(APPS)
 
 clean-dricore:
-       -rm -f $(DRICORE_OBJ_DIR) $(TOP)/$(LIB_DIR)/libglsl.so libglsl.so
+       -rm -f $(OBJECTS_DRICORE) $(TOP)/$(LIB_DIR)/libglsl.so libglsl.so
 
 ifneq (,$(DRICORE_GLSL_LIBS))
 DRICORE_INSTALL_TARGET = install-dricore
@@ -173,6 +191,9 @@ install-dricore: default
 glsl_compiler: $(GLSL2_OBJECTS) libglsl.a builtin_stubs.o
        $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) builtin_stubs.o $(LIBS) -o $@
 
+glsl_test: $(TEST_OBJECTS) libglsl.a builtin_stubs.o
+       $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(TEST_OBJECTS) builtin_stubs.o $(LIBS) -o $@
+
 glcpp: glcpp/glcpp
 glcpp/glcpp: $(GLCPP_OBJECTS)
        $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) -o $@
index c325583..1da58a9 100644 (file)
@@ -50,6 +50,7 @@ glsl_sources = [
     'ir.cpp',
     'ir_expression_flattening.cpp',
     'ir_function_can_inline.cpp',
+    'ir_function_detect_recursion.cpp',
     'ir_function.cpp',
     'ir_hierarchical_visitor.cpp',
     'ir_hv_accept.cpp',
@@ -95,6 +96,7 @@ glsl_sources = [
     'opt_tree_grafting.cpp',
     'ralloc.c',
     's_expression.cpp',
+    'standalone_scaffolding.cpp',
     'strtod.c',
 ] 
 
@@ -102,7 +104,7 @@ if env['msvc']:
     env.Prepend(CPPPATH = ['#/src/getopt'])
     env.PrependUnique(LIBS = [getopt])
 
-if env['crosscompile'] and env['platform'] != 'embedded':
+if env['crosscompile'] and not env['embedded']:
     Import('builtin_glsl_function')
 else:
     # Copy these files to avoid generation object files into src/mesa/program
@@ -156,7 +158,7 @@ Export('glsl')
 
 # Skip building these programs as they will cause SCons error "Two environments
 # with different actions were specified for the same target"
-if env['crosscompile'] or env['platform'] == 'embedded':
+if env['crosscompile'] or env['embedded']:
     Return()
 
 env = env.Clone()
index a376238..c99d7e1 100644 (file)
@@ -9,11 +9,12 @@
 - Implement support for ir_binop_dot in ir_algebraic.cpp.  Perform
   transformations such as "dot(v, vec3(0.0, 1.0, 0.0))" -> v.y.
 
-1.30 features:
-
-- Implement AST-to-HIR conversion of bit-shift operators.
+- Track source locations throughout the IR.  There are currently several
+  places where we cannot emit line numbers for errors (and currently emit 0:0)
+  because we've "lost" the line number information.  This is particularly
+  noticeable at link time.
 
-- Implement AST-to-HIR conversion of bit-wise {&,|,^,!} operators.
+1.30 features:
 
 - Implement AST-to-HIR conversion of switch-statements
   - switch
   - Update break to correcly handle mixed nexting of switch-statements
     and loops.
 
-- Handle currently unsupported constant expression types
-  - ir_unop_bit_not
-  - ir_binop_mod
-  - ir_binop_lshift
-  - ir_binop_rshift
-  - ir_binop_bit_and
-  - ir_binop_bit_xor
-  - ir_binop_bit_or
-
-- Implement support for 1.30 style shadow compares which only return a float
-  instead of a vec4.
-
 - Implement support for gl_ClipDistance.  This is non-trivial because
   gl_ClipDistance is exposed as a float[8], but all hardware actually
   implements it as vec4[2].
\ No newline at end of file
index 3ba699a..8bcf48d 100644 (file)
@@ -62,8 +62,10 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters,
  *
  * \param return_type Return type of the function.  May be \c NULL.
  * \param name        Name of the function.
- * \param parameters  Parameter list for the function.  This may be either a
- *                    formal or actual parameter list.  Only the type is used.
+ * \param parameters  List of \c ir_instruction nodes representing the
+ *                    parameter list for the function.  This may be either a
+ *                    formal (\c ir_variable) or actual (\c ir_rvalue)
+ *                    parameter list.  Only the type is used.
  *
  * \return
  * A ralloced string representing the prototype of the function.
@@ -271,17 +273,36 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
    assert(a <= GLSL_TYPE_BOOL);
    assert(b <= GLSL_TYPE_BOOL);
 
-   if ((a == b) || (src->type->is_integer() && desired_type->is_integer()))
+   if (a == b)
       return src;
 
    switch (a) {
    case GLSL_TYPE_UINT:
+      switch (b) {
+      case GLSL_TYPE_INT:
+        result = new(ctx) ir_expression(ir_unop_i2u, src);
+        break;
+      case GLSL_TYPE_FLOAT:
+        result = new(ctx) ir_expression(ir_unop_i2u,
+                 new(ctx) ir_expression(ir_unop_f2i, src));
+        break;
+      case GLSL_TYPE_BOOL:
+        result = new(ctx) ir_expression(ir_unop_i2u,
+                 new(ctx) ir_expression(ir_unop_b2i, src));
+        break;
+      }
+      break;
    case GLSL_TYPE_INT:
-      if (b == GLSL_TYPE_FLOAT)
-        result = new(ctx) ir_expression(ir_unop_f2i, desired_type, src, NULL);
-      else {
-        assert(b == GLSL_TYPE_BOOL);
-        result = new(ctx) ir_expression(ir_unop_b2i, desired_type, src, NULL);
+      switch (b) {
+      case GLSL_TYPE_UINT:
+        result = new(ctx) ir_expression(ir_unop_u2i, src);
+        break;
+      case GLSL_TYPE_FLOAT:
+        result = new(ctx) ir_expression(ir_unop_f2i, src);
+        break;
+      case GLSL_TYPE_BOOL:
+        result = new(ctx) ir_expression(ir_unop_b2i, src);
+        break;
       }
       break;
    case GLSL_TYPE_FLOAT:
@@ -300,6 +321,9 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
    case GLSL_TYPE_BOOL:
       switch (b) {
       case GLSL_TYPE_UINT:
+        result = new(ctx) ir_expression(ir_unop_i2b,
+                 new(ctx) ir_expression(ir_unop_u2i, src));
+        break;
       case GLSL_TYPE_INT:
         result = new(ctx) ir_expression(ir_unop_i2b, desired_type, src, NULL);
         break;
@@ -311,6 +335,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
    }
 
    assert(result != NULL);
+   assert(result->type == desired_type);
 
    /* Try constant folding; it may fold in the conversion we just added. */
    ir_constant *const constant = result->constant_expression_value();
@@ -417,13 +442,21 @@ process_array_constructor(exec_list *instructions,
       ir_rvalue *ir = (ir_rvalue *) n;
       ir_rvalue *result = ir;
 
-      /* Apply implicit conversions (not the scalar constructor rules!) */
+      /* Apply implicit conversions (not the scalar constructor rules!). See
+       * the spec quote above. */
       if (constructor_type->element_type()->is_float()) {
         const glsl_type *desired_type =
            glsl_type::get_instance(GLSL_TYPE_FLOAT,
                                    ir->type->vector_elements,
                                    ir->type->matrix_columns);
-        result = convert_component(ir, desired_type);
+        if (result->type->can_implicitly_convert_to(desired_type)) {
+           /* Even though convert_component() implements the constructor
+            * conversion rules (not the implicit conversion rules), its safe
+            * to use it here because we already checked that the implicit
+            * conversion is legal.
+            */
+           result = convert_component(ir, desired_type);
+        }
       }
 
       if (result->type != constructor_type->element_type()) {
index 3b87f0d..c0524bf 100644 (file)
@@ -83,6 +83,8 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
 
    foreach_list_typed (ast_node, ast, link, & state->translation_unit)
       ast->hir(instructions, state);
+
+   detect_recursion_unlinked(state, instructions);
 }
 
 
@@ -447,9 +449,17 @@ modulus_result_type(const struct glsl_type *type_a,
     *    integer vectors. The operand types must both be signed or both be
     *    unsigned."
     */
-   if (!type_a->is_integer() || !type_b->is_integer()
-       || (type_a->base_type != type_b->base_type)) {
-      _mesa_glsl_error(loc, state, "type mismatch");
+   if (!type_a->is_integer()) {
+      _mesa_glsl_error(loc, state, "LHS of operator %% must be an integer.");
+      return glsl_type::error_type;
+   }
+   if (!type_b->is_integer()) {
+      _mesa_glsl_error(loc, state, "RHS of operator %% must be an integer.");
+      return glsl_type::error_type;
+   }
+   if (type_a->base_type != type_b->base_type) {
+      _mesa_glsl_error(loc, state,
+                      "operands of %% must have the same base type");
       return glsl_type::error_type;
    }
 
@@ -1940,7 +1950,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
         break;
 
       case fragment_shader:
-        if (!global_scope || (var->mode != ir_var_in)) {
+        if (!global_scope || (var->mode != ir_var_out)) {
            fail = true;
            string = "output";
         }
@@ -2696,6 +2706,17 @@ ast_declarator_list::hir(exec_list *instructions,
                                                       : "and integer");
       }
 
+      /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
+       *
+       *    "[Sampler types] can only be declared as function
+       *    parameters or uniform variables (see Section 4.3.5
+       *    "Uniform")".
+       */
+      if (var_type->contains_sampler() &&
+          !this->type->qualifier.flags.q.uniform) {
+         _mesa_glsl_error(&loc, state, "samplers must be declared uniform");
+      }
+
       /* Process the initializer and add its instructions to a temporary
        * list.  This list will be added to the instruction stream (below) after
        * the declaration is added.  This is done because in some cases (such as
@@ -2856,6 +2877,18 @@ ast_parameter_declarator::hir(exec_list *instructions,
     */
    apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc);
 
+   /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
+    *
+    *    "Samplers cannot be treated as l-values; hence cannot be used
+    *    as out or inout function parameters, nor can they be assigned
+    *    into."
+    */
+   if ((var->mode == ir_var_inout || var->mode == ir_var_out)
+       && type->contains_sampler()) {
+      _mesa_glsl_error(&loc, state, "out and inout parameters cannot contain samplers");
+      type = glsl_type::error_type;
+   }
+
    instructions->push_tail(var);
 
    /* Parameter declarations do not have r-values.
@@ -2984,6 +3017,18 @@ ast_function::hir(exec_list *instructions,
                       "function `%s' return type has qualifiers", name);
    }
 
+   /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
+    *
+    *    "[Sampler types] can only be declared as function parameters
+    *    or uniform variables (see Section 4.3.5 "Uniform")".
+    */
+   if (return_type->contains_sampler()) {
+      YYLTYPE loc = this->get_location();
+      _mesa_glsl_error(&loc, state,
+                       "function `%s' return type can't contain a sampler",
+                       name);
+   }
+
    /* Verify that this function's signature either doesn't match a previously
     * seen signature for a function with the same name, or, if a match is found,
     * that the previously seen signature does not have an associated definition.
index e230ad6..45d9e67 100644 (file)
@@ -5,23 +5,26 @@
      ((return (expression float *
               (expression float sign (var_ref x))
               (expression float -
-               (expression float *
-                (constant float (3.1415926))
-                (constant float (0.5)))
+               (constant float (1.5707964))
                (expression float *
                 (expression float sqrt
                  (expression float -
                   (constant float (1.0))
                   (expression float abs (var_ref x))))
                 (expression float +
-                 (constant float (1.5707288))
+                 (constant float (1.5707964))
                  (expression float *
                   (expression float abs (var_ref x))
                   (expression float +
-                   (constant float (-0.2121144))
+                   (constant float (-0.21460183))
                    (expression float *
-                    (constant float (0.0742610))
-                    (expression float abs (var_ref x))))))))))))
+                    (expression float abs (var_ref x))
+                     (expression float +
+                      (constant float (0.086566724))
+                      (expression float *
+                       (expression float abs (var_ref x))
+                       (constant float (-0.03102955))
+                    ))))))))))))
 
    (signature vec2
      (parameters
      ((return (expression vec2 *
               (expression vec2 sign (var_ref x))
               (expression vec2 -
-               (expression float *
-                (constant float (3.1415926))
-                (constant float (0.5)))
+               (constant float (1.5707964))
                (expression vec2 *
                 (expression vec2 sqrt
                  (expression vec2 -
                   (constant float (1.0))
                   (expression vec2 abs (var_ref x))))
                 (expression vec2 +
-                 (constant float (1.5707288))
+                 (constant float (1.5707964))
                  (expression vec2 *
                   (expression vec2 abs (var_ref x))
                   (expression vec2 +
-                   (constant float (-0.2121144))
+                   (constant float (-0.21460183))
                    (expression vec2 *
-                    (constant float (0.0742610))
-                    (expression vec2 abs (var_ref x))))))))))))
+                    (expression vec2 abs (var_ref x))
+                     (expression vec2 +
+                      (constant float (0.086566724))
+                      (expression vec2 *
+                       (expression vec2 abs (var_ref x))
+                       (constant float (-0.03102955))
+                    ))))))))))))
 
    (signature vec3
      (parameters
      ((return (expression vec3 *
               (expression vec3 sign (var_ref x))
               (expression vec3 -
-               (expression float *
-                (constant float (3.1415926))
-                (constant float (0.5)))
+               (constant float (1.5707964))
                (expression vec3 *
                 (expression vec3 sqrt
                  (expression vec3 -
                   (constant float (1.0))
                   (expression vec3 abs (var_ref x))))
                 (expression vec3 +
-                 (constant float (1.5707288))
+                 (constant float (1.5707964))
                  (expression vec3 *
                   (expression vec3 abs (var_ref x))
                   (expression vec3 +
-                   (constant float (-0.2121144))
+                   (constant float (-0.21460183))
                    (expression vec3 *
-                    (constant float (0.0742610))
-                    (expression vec3 abs (var_ref x))))))))))))
+                    (expression vec3 abs (var_ref x))
+                     (expression vec3 +
+                      (constant float (0.086566724))
+                      (expression vec3 *
+                       (expression vec3 abs (var_ref x))
+                       (constant float (-0.03102955))
+                    ))))))))))))
 
    (signature vec4
      (parameters
      ((return (expression vec4 *
               (expression vec4 sign (var_ref x))
               (expression vec4 -
-               (expression float *
-                (constant float (3.1415926))
-                (constant float (0.5)))
+               (constant float (1.5707964))
                (expression vec4 *
                 (expression vec4 sqrt
                  (expression vec4 -
                   (constant float (1.0))
                   (expression vec4 abs (var_ref x))))
                 (expression vec4 +
-                 (constant float (1.5707288))
+                 (constant float (1.5707964))
                  (expression vec4 *
                   (expression vec4 abs (var_ref x))
                   (expression vec4 +
-                   (constant float (-0.2121144))
+                   (constant float (-0.21460183))
                    (expression vec4 *
-                    (constant float (0.0742610))
-                    (expression vec4 abs (var_ref x))))))))))))
+                    (expression vec4 abs (var_ref x))
+                     (expression vec4 +
+                      (constant float (0.086566724))
+                      (expression vec4 *
+                       (expression vec4 abs (var_ref x))
+                       (constant float (-0.03102955))
+                    ))))))))))))
 ))
index cfecc1f..7b5ea13 100644 (file)
@@ -54,7 +54,9 @@
     )
     (
       (declare () float r)
-      (if (expression bool > (expression float abs (var_ref x)) (constant float (0.000100))) (
+      (if (expression bool >
+           (expression float abs (var_ref x))
+           (expression float * (constant float (1.0e-8)) (expression float abs (var_ref y)))) (
         (assign (x) (var_ref r) (call atan ((expression float / (var_ref y) (var_ref x)))))
         (if (expression bool < (var_ref x) (constant float (0.000000)) ) (
           (if (expression bool >= (var_ref y) (constant float (0.000000)) )
index 6a0f5d2..a419101 100644 (file)
@@ -2,20 +2,20 @@
    (signature float
      (parameters
        (declare (in) float arg0))
-     ((return (expression float * (var_ref arg0) (constant float (0.017453))))))
+     ((return (expression float * (var_ref arg0) (constant float (0.0174532925))))))
 
    (signature vec2
      (parameters
        (declare (in) vec2 arg0))
-     ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))
+     ((return (expression vec2 * (var_ref arg0) (constant float (0.0174532925))))))
 
    (signature vec3
      (parameters
        (declare (in) vec3 arg0))
-     ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))
+     ((return (expression vec3 * (var_ref arg0) (constant float (0.0174532925))))))
 
    (signature vec4
      (parameters
        (declare (in) vec4 arg0))
-     ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))
+     ((return (expression vec4 * (var_ref arg0) (constant float (0.0174532925))))))
 ))
index d9aa300..cc78137 100644 (file)
@@ -165,133 +165,242 @@ _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
 }
 
 
+/**
+ * Enum representing the possible behaviors that can be specified in
+ * an #extension directive.
+ */
+enum ext_behavior {
+   extension_disable,
+   extension_enable,
+   extension_require,
+   extension_warn
+};
+
+/**
+ * Element type for _mesa_glsl_supported_extensions
+ */
+struct _mesa_glsl_extension {
+   /**
+    * Name of the extension when referred to in a GLSL extension
+    * statement
+    */
+   const char *name;
+
+   /** True if this extension is available to vertex shaders */
+   bool avail_in_VS;
+
+   /** True if this extension is available to geometry shaders */
+   bool avail_in_GS;
+
+   /** True if this extension is available to fragment shaders */
+   bool avail_in_FS;
+
+   /** True if this extension is available to desktop GL shaders */
+   bool avail_in_GL;
+
+   /** True if this extension is available to GLES shaders */
+   bool avail_in_ES;
+
+   /**
+    * Flag in the gl_extensions struct indicating whether this
+    * extension is supported by the driver, or
+    * &gl_extensions::dummy_true if supported by all drivers.
+    *
+    * Note: the type (GLboolean gl_extensions::*) is a "pointer to
+    * member" type, the type-safe alternative to the "offsetof" macro.
+    * In a nutshell:
+    *
+    * - foo bar::* p declares p to be an "offset" to a field of type
+    *   foo that exists within struct bar
+    * - &bar::baz computes the "offset" of field baz within struct bar
+    * - x.*p accesses the field of x that exists at "offset" p
+    * - x->*p is equivalent to (*x).*p
+    */
+   const GLboolean gl_extensions::* supported_flag;
+
+   /**
+    * Flag in the _mesa_glsl_parse_state struct that should be set
+    * when this extension is enabled.
+    *
+    * See note in _mesa_glsl_extension::supported_flag about "pointer
+    * to member" types.
+    */
+   bool _mesa_glsl_parse_state::* enable_flag;
+
+   /**
+    * Flag in the _mesa_glsl_parse_state struct that should be set
+    * when the shader requests "warn" behavior for this extension.
+    *
+    * See note in _mesa_glsl_extension::supported_flag about "pointer
+    * to member" types.
+    */
+   bool _mesa_glsl_parse_state::* warn_flag;
+
+
+   bool compatible_with_state(const _mesa_glsl_parse_state *state) const;
+   void set_flags(_mesa_glsl_parse_state *state, ext_behavior behavior) const;
+};
+
+#define EXT(NAME, VS, GS, FS, GL, ES, SUPPORTED_FLAG)                   \
+   { "GL_" #NAME, VS, GS, FS, GL, ES, &gl_extensions::SUPPORTED_FLAG,   \
+         &_mesa_glsl_parse_state::NAME##_enable,                        \
+         &_mesa_glsl_parse_state::NAME##_warn }
+
+/**
+ * Table of extensions that can be enabled/disabled within a shader,
+ * and the conditions under which they are supported.
+ */
+static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
+   /*                                  target availability  API availability */
+   /* name                             VS     GS     FS     GL     ES         supported flag */
+   EXT(ARB_draw_buffers,               false, false, true,  true,  false,     dummy_true),
+   EXT(ARB_draw_instanced,             true,  false, false, true,  false,     ARB_draw_instanced),
+   EXT(ARB_explicit_attrib_location,   true,  false, true,  true,  false,     ARB_explicit_attrib_location),
+   EXT(ARB_fragment_coord_conventions, true,  false, true,  true,  false,     ARB_fragment_coord_conventions),
+   EXT(ARB_texture_rectangle,          true,  false, true,  true,  false,     dummy_true),
+   EXT(EXT_texture_array,              true,  false, true,  true,  false,     EXT_texture_array),
+   EXT(ARB_shader_texture_lod,         true,  false, true,  true,  false,     ARB_shader_texture_lod),
+   EXT(ARB_shader_stencil_export,      false, false, true,  true,  false,     ARB_shader_stencil_export),
+   EXT(AMD_conservative_depth,         true,  false, true,  true,  false,     AMD_conservative_depth),
+   EXT(AMD_shader_stencil_export,      false, false, true,  true,  false,     ARB_shader_stencil_export),
+   EXT(OES_texture_3D,                 true,  false, true,  false, true,      EXT_texture3D),
+};
+
+#undef EXT
+
+
+/**
+ * Determine whether a given extension is compatible with the target,
+ * API, and extension information in the current parser state.
+ */
+bool _mesa_glsl_extension::compatible_with_state(const _mesa_glsl_parse_state *
+                                                 state) const
+{
+   /* Check that this extension matches the type of shader we are
+    * compiling to.
+    */
+   switch (state->target) {
+   case vertex_shader:
+      if (!this->avail_in_VS) {
+         return false;
+      }
+      break;
+   case geometry_shader:
+      if (!this->avail_in_GS) {
+         return false;
+      }
+      break;
+   case fragment_shader:
+      if (!this->avail_in_FS) {
+         return false;
+      }
+      break;
+   default:
+      assert (!"Unrecognized shader target");
+      return false;
+   }
+
+   /* Check that this extension matches whether we are compiling
+    * for desktop GL or GLES.
+    */
+   if (state->es_shader) {
+      if (!this->avail_in_ES) return false;
+   } else {
+      if (!this->avail_in_GL) return false;
+   }
+
+   /* Check that this extension is supported by the OpenGL
+    * implementation.
+    *
+    * Note: the ->* operator indexes into state->extensions by the
+    * offset this->supported_flag.  See
+    * _mesa_glsl_extension::supported_flag for more info.
+    */
+   return state->extensions->*(this->supported_flag);
+}
+
+/**
+ * Set the appropriate flags in the parser state to establish the
+ * given behavior for this extension.
+ */
+void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state,
+                                     ext_behavior behavior) const
+{
+   /* Note: the ->* operator indexes into state by the
+    * offsets this->enable_flag and this->warn_flag.  See
+    * _mesa_glsl_extension::supported_flag for more info.
+    */
+   state->*(this->enable_flag) = (behavior != extension_disable);
+   state->*(this->warn_flag)   = (behavior == extension_warn);
+}
+
+/**
+ * Find an extension by name in _mesa_glsl_supported_extensions.  If
+ * the name is not found, return NULL.
+ */
+static const _mesa_glsl_extension *find_extension(const char *name)
+{
+   for (unsigned i = 0; i < Elements(_mesa_glsl_supported_extensions); ++i) {
+      if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) {
+         return &_mesa_glsl_supported_extensions[i];
+      }
+   }
+   return NULL;
+}
+
+
 bool
 _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
-                            const char *behavior, YYLTYPE *behavior_locp,
+                            const char *behavior_string, YYLTYPE *behavior_locp,
                             _mesa_glsl_parse_state *state)
 {
-   enum {
-      extension_disable,
-      extension_enable,
-      extension_require,
-      extension_warn
-   } ext_mode;
-
-   if (strcmp(behavior, "warn") == 0) {
-      ext_mode = extension_warn;
-   } else if (strcmp(behavior, "require") == 0) {
-      ext_mode = extension_require;
-   } else if (strcmp(behavior, "enable") == 0) {
-      ext_mode = extension_enable;
-   } else if (strcmp(behavior, "disable") == 0) {
-      ext_mode = extension_disable;
+   ext_behavior behavior;
+   if (strcmp(behavior_string, "warn") == 0) {
+      behavior = extension_warn;
+   } else if (strcmp(behavior_string, "require") == 0) {
+      behavior = extension_require;
+   } else if (strcmp(behavior_string, "enable") == 0) {
+      behavior = extension_enable;
+   } else if (strcmp(behavior_string, "disable") == 0) {
+      behavior = extension_disable;
    } else {
       _mesa_glsl_error(behavior_locp, state,
                       "Unknown extension behavior `%s'",
-                      behavior);
+                      behavior_string);
       return false;
    }
 
-   bool unsupported = false;
-
    if (strcmp(name, "all") == 0) {
-      if ((ext_mode == extension_enable) || (ext_mode == extension_require)) {
+      if ((behavior == extension_enable) || (behavior == extension_require)) {
         _mesa_glsl_error(name_locp, state, "Cannot %s all extensions",
-                         (ext_mode == extension_enable)
+                         (behavior == extension_enable)
                          ? "enable" : "require");
         return false;
-      }
-   } else if (strcmp(name, "GL_ARB_draw_buffers") == 0) {
-      /* This extension is only supported in fragment shaders.
-       */
-      if (state->target != fragment_shader) {
-        unsupported = true;
       } else {
-        state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
-        state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
+         for (unsigned i = 0;
+              i < Elements(_mesa_glsl_supported_extensions); ++i) {
+            const _mesa_glsl_extension *extension
+               = &_mesa_glsl_supported_extensions[i];
+            if (extension->compatible_with_state(state)) {
+               _mesa_glsl_supported_extensions[i].set_flags(state, behavior);
+            }
+         }
       }
-   } else if (strcmp(name, "GL_ARB_draw_instanced") == 0) {
-      state->ARB_draw_instanced_enable = (ext_mode != extension_disable);
-      state->ARB_draw_instanced_warn = (ext_mode == extension_warn);
-
-      /* This extension is only supported in vertex shaders.
-       */
-      unsupported = (state->target != vertex_shader)
-        ||  !state->extensions->ARB_draw_instanced;
-   } else if (strcmp(name, "GL_ARB_explicit_attrib_location") == 0) {
-      state->ARB_explicit_attrib_location_enable =
-        (ext_mode != extension_disable);
-      state->ARB_explicit_attrib_location_warn =
-        (ext_mode == extension_warn);
-
-      unsupported = !state->extensions->ARB_explicit_attrib_location;
-   } else if (strcmp(name, "GL_ARB_fragment_coord_conventions") == 0) {
-      state->ARB_fragment_coord_conventions_enable =
-        (ext_mode != extension_disable);
-      state->ARB_fragment_coord_conventions_warn =
-        (ext_mode == extension_warn);
-
-      unsupported = !state->extensions->ARB_fragment_coord_conventions;
-   } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) {
-      state->ARB_texture_rectangle_enable = (ext_mode != extension_disable);
-      state->ARB_texture_rectangle_warn = (ext_mode == extension_warn);
-   } else if (strcmp(name, "GL_EXT_texture_array") == 0) {
-      state->EXT_texture_array_enable = (ext_mode != extension_disable);
-      state->EXT_texture_array_warn = (ext_mode == extension_warn);
-
-      unsupported = !state->extensions->EXT_texture_array;
-   } else if (strcmp(name, "GL_ARB_shader_texture_lod") == 0) {
-      /* Force ARB_texture_rectangle to be on so sampler2DRects are defined */
-      state->ARB_texture_rectangle_enable = true;
-
-      state->ARB_shader_texture_lod_enable = (ext_mode != extension_disable);
-      state->ARB_shader_texture_lod_warn = (ext_mode == extension_warn);
-
-      unsupported = !state->extensions->ARB_shader_texture_lod;
-   } else if (strcmp(name, "GL_ARB_shader_stencil_export") == 0) {
-      state->ARB_shader_stencil_export_enable = (ext_mode != extension_disable);
-      state->ARB_shader_stencil_export_warn = (ext_mode == extension_warn);
-
-      /* This extension is only supported in fragment shaders.
-       */
-      unsupported = (state->target != fragment_shader)
-        || !state->extensions->ARB_shader_stencil_export;
-   } else if (strcmp(name, "GL_AMD_conservative_depth") == 0) {
-      /* The AMD_conservative spec does not forbid requiring the extension in
-       * the vertex shader.
-       */
-      state->AMD_conservative_depth_enable = (ext_mode != extension_disable);
-      state->AMD_conservative_depth_warn = (ext_mode == extension_warn);
-      unsupported = !state->extensions->AMD_conservative_depth;
-   } else if (strcmp(name, "GL_AMD_shader_stencil_export") == 0) {
-      state->AMD_shader_stencil_export_enable = (ext_mode != extension_disable);
-      state->AMD_shader_stencil_export_warn = (ext_mode == extension_warn);
-
-      /* This extension is only supported in fragment shaders.
-       * Both the ARB and AMD variants share the same ARB flag
-       * in gl_extensions.
-       */
-      unsupported = (state->target != fragment_shader)
-        || !state->extensions->ARB_shader_stencil_export;
-   } else if (strcmp(name, "GL_OES_texture_3D") == 0 && state->es_shader) {
-      state->OES_texture_3D_enable = (ext_mode != extension_disable);
-      state->OES_texture_3D_warn = (ext_mode == extension_warn);
-
-      unsupported = !state->extensions->EXT_texture3D;
    } else {
-      unsupported = true;
-   }
-
-   if (unsupported) {
-      static const char *const fmt = "extension `%s' unsupported in %s shader";
-
-      if (ext_mode == extension_require) {
-        _mesa_glsl_error(name_locp, state, fmt,
-                         name, _mesa_glsl_shader_target_name(state->target));
-        return false;
+      const _mesa_glsl_extension *extension = find_extension(name);
+      if (extension && extension->compatible_with_state(state)) {
+         extension->set_flags(state, behavior);
       } else {
-        _mesa_glsl_warning(name_locp, state, fmt,
-                           name, _mesa_glsl_shader_target_name(state->target));
+         static const char *const fmt = "extension `%s' unsupported in %s shader";
+
+         if (behavior == extension_require) {
+            _mesa_glsl_error(name_locp, state, fmt,
+                             name, _mesa_glsl_shader_target_name(state->target));
+            return false;
+         } else {
+            _mesa_glsl_warning(name_locp, state, fmt,
+                               name, _mesa_glsl_shader_target_name(state->target));
+         }
       }
    }
 
index 878d2ae..2f4d3cb 100644 (file)
@@ -156,28 +156,28 @@ struct _mesa_glsl_parse_state {
     * \name Enable bits for GLSL extensions
     */
    /*@{*/
-   unsigned ARB_draw_buffers_enable:1;
-   unsigned ARB_draw_buffers_warn:1;
-   unsigned ARB_draw_instanced_enable:1;
-   unsigned ARB_draw_instanced_warn:1;
-   unsigned ARB_explicit_attrib_location_enable:1;
-   unsigned ARB_explicit_attrib_location_warn:1;
-   unsigned ARB_fragment_coord_conventions_enable:1;
-   unsigned ARB_fragment_coord_conventions_warn:1;
-   unsigned ARB_texture_rectangle_enable:1;
-   unsigned ARB_texture_rectangle_warn:1;
-   unsigned EXT_texture_array_enable:1;
-   unsigned EXT_texture_array_warn:1;
-   unsigned ARB_shader_texture_lod_enable:1;
-   unsigned ARB_shader_texture_lod_warn:1;
-   unsigned ARB_shader_stencil_export_enable:1;
-   unsigned ARB_shader_stencil_export_warn:1;
-   unsigned AMD_conservative_depth_enable:1;
-   unsigned AMD_conservative_depth_warn:1;
-   unsigned AMD_shader_stencil_export_enable:1;
-   unsigned AMD_shader_stencil_export_warn:1;
-   unsigned OES_texture_3D_enable:1;
-   unsigned OES_texture_3D_warn:1;
+   bool ARB_draw_buffers_enable;
+   bool ARB_draw_buffers_warn;
+   bool ARB_draw_instanced_enable;
+   bool ARB_draw_instanced_warn;
+   bool ARB_explicit_attrib_location_enable;
+   bool ARB_explicit_attrib_location_warn;
+   bool ARB_fragment_coord_conventions_enable;
+   bool ARB_fragment_coord_conventions_warn;
+   bool ARB_texture_rectangle_enable;
+   bool ARB_texture_rectangle_warn;
+   bool EXT_texture_array_enable;
+   bool EXT_texture_array_warn;
+   bool ARB_shader_texture_lod_enable;
+   bool ARB_shader_texture_lod_warn;
+   bool ARB_shader_stencil_export_enable;
+   bool ARB_shader_stencil_export_warn;
+   bool AMD_conservative_depth_enable;
+   bool AMD_conservative_depth_warn;
+   bool AMD_shader_stencil_export_enable;
+   bool AMD_shader_stencil_export_warn;
+   bool OES_texture_3D_enable;
+   bool OES_texture_3D_warn;
    /*@}*/
 
    /** Extensions supported by the OpenGL implementation. */
index 78d10bd..c94aec0 100644 (file)
@@ -111,6 +111,22 @@ add_types_to_symbol_table(glsl_symbol_table *symtab,
    }
 }
 
+bool
+glsl_type::contains_sampler() const
+{
+   if (this->is_array()) {
+      return this->fields.array->contains_sampler();
+   } else if (this->is_record()) {
+      for (unsigned int i = 0; i < this->length; i++) {
+        if (this->fields.structure[i].type->contains_sampler())
+           return true;
+      }
+      return false;
+   } else {
+      return this->is_sampler();
+   }
+}
+
 void
 glsl_type::generate_100ES_types(glsl_symbol_table *symtab)
 {
@@ -507,3 +523,19 @@ glsl_type::component_slots() const
       return 0;
    }
 }
+
+bool
+glsl_type::can_implicitly_convert_to(const glsl_type *desired) const
+{
+   if (this == desired)
+      return true;
+
+   /* There is no conversion among matrix types. */
+   if (this->matrix_columns > 1 || desired->matrix_columns > 1)
+      return false;
+
+   /* int and uint can be converted to float. */
+   return desired->is_float()
+          && this->is_integer()
+          && this->vector_elements == desired->vector_elements;
+}
index 1b069df..0486966 100644 (file)
@@ -224,6 +224,41 @@ struct glsl_type {
     */
    unsigned component_slots() const;
 
+   /**
+    * \brief Can this type be implicitly converted to another?
+    *
+    * \return True if the types are identical or if this type can be converted
+    *         to \c desired according to Section 4.1.10 of the GLSL spec.
+    *
+    * \verbatim
+    * From page 25 (31 of the pdf) of the GLSL 1.50 spec, Section 4.1.10
+    * Implicit Conversions:
+    *
+    *     In some situations, an expression and its type will be implicitly
+    *     converted to a different type. The following table shows all allowed
+    *     implicit conversions:
+    *
+    *     Type of expression | Can be implicitly converted to
+    *     --------------------------------------------------
+    *     int                  float
+    *     uint
+    *
+    *     ivec2                vec2
+    *     uvec2
+    *
+    *     ivec3                vec3
+    *     uvec3
+    *
+    *     ivec4                vec4
+    *     uvec4
+    *
+    *     There are no implicit array or structure conversions. For example,
+    *     an array of int cannot be implicitly converted to an array of float.
+    *     There are no implicit conversions between signed and unsigned
+    *     integers.
+    * \endverbatim
+    */
+   bool can_implicitly_convert_to(const glsl_type *desired) const;
 
    /**
     * Query whether or not a type is a scalar (non-vector and non-matrix).
@@ -296,6 +331,12 @@ struct glsl_type {
    }
 
    /**
+    * Query whether or not type is a sampler, or for struct and array
+    * types, contains a sampler.
+    */
+   bool contains_sampler() const;
+
+   /**
     * Query whether or not a type is an array
     */
    bool is_array() const
index a3623b3..827fe8e 100644 (file)
@@ -272,6 +272,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
 
    case ir_unop_f2i:
    case ir_unop_b2i:
+   case ir_unop_u2i:
       this->type = glsl_type::get_instance(GLSL_TYPE_INT,
                                           op0->type->vector_elements, 1);
       break;
@@ -289,6 +290,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
                                           op0->type->vector_elements, 1);
       break;
 
+   case ir_unop_i2u:
+      this->type = glsl_type::get_instance(GLSL_TYPE_UINT,
+                                          op0->type->vector_elements, 1);
+      break;
+
    case ir_unop_noise:
       this->type = glsl_type::float_type;
       break;
@@ -419,6 +425,8 @@ static const char *const operator_strs[] = {
    "i2b",
    "b2i",
    "u2f",
+   "i2u",
+   "u2i",
    "any",
    "trunc",
    "ceil",
@@ -1087,21 +1095,6 @@ ir_dereference_record::ir_dereference_record(ir_variable *var,
       ? this->record->type->field_type(field) : glsl_type::error_type;
 }
 
-bool type_contains_sampler(const glsl_type *type)
-{
-   if (type->is_array()) {
-      return type_contains_sampler(type->fields.array);
-   } else if (type->is_record()) {
-      for (unsigned int i = 0; i < type->length; i++) {
-        if (type_contains_sampler(type->fields.structure[i].type))
-           return true;
-      }
-      return false;
-   } else {
-      return type->is_sampler();
-   }
-}
-
 bool
 ir_dereference::is_lvalue()
 {
@@ -1121,7 +1114,7 @@ ir_dereference::is_lvalue()
     *     as out or inout function parameters, nor can they be
     *     assigned into."
     */
-   if (type_contains_sampler(this->type))
+   if (this->type->contains_sampler())
       return false;
 
    return true;
index a419843..50a9d6e 100644 (file)
@@ -682,7 +682,7 @@ public:
 
 class ir_assignment : public ir_instruction {
 public:
-   ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition);
+   ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition = NULL);
 
    /**
     * Construct an assignment with an explicit write mask
@@ -789,6 +789,8 @@ enum ir_expression_operation {
    ir_unop_i2b,      /**< int-to-boolean conversion */
    ir_unop_b2i,      /**< Boolean-to-int conversion */
    ir_unop_u2f,      /**< Unsigned-to-float conversion. */
+   ir_unop_i2u,      /**< Integer-to-unsigned conversion. */
+   ir_unop_u2i,      /**< Unsigned-to-integer conversion. */
    ir_unop_any,
 
    /**
@@ -989,6 +991,7 @@ public:
       assert(callee->return_type != NULL);
       type = callee->return_type;
       actual_parameters->move_nodes_to(& this->actual_parameters);
+      this->use_builtin = callee->is_builtin;
    }
 
    virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const;
@@ -1052,6 +1055,9 @@ public:
    /* List of ir_rvalue of paramaters passed in this call. */
    exec_list actual_parameters;
 
+   /** Should this call only bind to a built-in function? */
+   bool use_builtin;
+
 private:
    ir_call()
       : callee(NULL)
@@ -1629,6 +1635,32 @@ visit_exec_list(exec_list *list, ir_visitor *visitor);
  */
 void validate_ir_tree(exec_list *instructions);
 
+struct _mesa_glsl_parse_state;
+struct gl_shader_program;
+
+/**
+ * Detect whether an unlinked shader contains static recursion
+ *
+ * If the list of instructions is determined to contain static recursion,
+ * \c _mesa_glsl_error will be called to emit error messages for each function
+ * that is in the recursion cycle.
+ */
+void
+detect_recursion_unlinked(struct _mesa_glsl_parse_state *state,
+                         exec_list *instructions);
+
+/**
+ * Detect whether a linked shader contains static recursion
+ *
+ * If the list of instructions is determined to contain static recursion,
+ * \c link_error_printf will be called to emit error messages for each function
+ * that is in the recursion cycle.  In addition,
+ * \c gl_shader_program::LinkStatus will be set to false.
+ */
+void
+detect_recursion_linked(struct gl_shader_program *prog,
+                       exec_list *instructions);
+
 /**
  * Make a clone of each IR instruction in a list
  *
@@ -1663,4 +1695,8 @@ ir_has_call(ir_instruction *ir);
 extern void
 do_set_program_inouts(exec_list *instructions, struct gl_program *prog);
 
+extern char *
+prototype_string(const glsl_type *return_type, const char *name,
+                exec_list *parameters);
+
 #endif /* IR_H */
index 2a30848..f0299a2 100644 (file)
@@ -166,7 +166,18 @@ ir_expression::constant_expression_value()
         data.b[c] = op[0]->value.u[c] ? true : false;
       }
       break;
-
+   case ir_unop_u2i:
+      assert(op[0]->type->base_type == GLSL_TYPE_UINT);
+      for (unsigned c = 0; c < op[0]->type->components(); c++) {
+        data.i[c] = op[0]->value.u[c];
+      }
+      break;
+   case ir_unop_i2u:
+      assert(op[0]->type->base_type == GLSL_TYPE_INT);
+      for (unsigned c = 0; c < op[0]->type->components(); c++) {
+        data.u[c] = op[0]->value.i[c];
+      }
+      break;
    case ir_unop_any:
       assert(op[0]->type->is_boolean());
       data.b[0] = false;
index caee929..2a4de5b 100644 (file)
 #include "glsl_types.h"
 #include "ir.h"
 
-int
-type_compare(const glsl_type *a, const glsl_type *b)
-{
-   /* If the types are the same, they trivially match.
-    */
-   if (a == b)
-      return 0;
-
-   switch (a->base_type) {
-   case GLSL_TYPE_UINT:
-   case GLSL_TYPE_INT:
-   case GLSL_TYPE_BOOL:
-      /* There is no implicit conversion to or from integer types or bool.
-       */
-      if ((a->is_integer() != b->is_integer())
-         || (a->is_boolean() != b->is_boolean()))
-        return -1;
-
-      /* FALLTHROUGH */
-
-   case GLSL_TYPE_FLOAT:
-      if ((a->vector_elements != b->vector_elements)
-         || (a->matrix_columns != b->matrix_columns))
-        return -1;
-
-      return 1;
-
-   case GLSL_TYPE_SAMPLER:
-   case GLSL_TYPE_STRUCT:
-      /* Samplers and structures must match exactly.
-       */
-      return -1;
-
-   case GLSL_TYPE_ARRAY:
-      if ((b->base_type != GLSL_TYPE_ARRAY)
-         || (a->length != b->length))
-        return -1;
-
-      /* From GLSL 1.50 spec, page 27 (page 33 of the PDF):
-       *    "There are no implicit array or structure conversions."
-       *
-       * If the comparison of the array element types detects that a conversion
-       * would be required, the array types do not match.
-       */
-      return (type_compare(a->fields.array, b->fields.array) == 0) ? 0 : -1;
-
-   case GLSL_TYPE_VOID:
-   case GLSL_TYPE_ERROR:
-   default:
-      /* These are all error conditions.  It is invalid for a parameter to
-       * a function to be declared as error, void, or a function.
-       */
-      return -1;
-   }
-
-   /* This point should be unreachable.
-    */
-   assert(0);
-}
-
-
-static int
+typedef enum {
+   PARAMETER_LIST_NO_MATCH,
+   PARAMETER_LIST_EXACT_MATCH,
+   PARAMETER_LIST_INEXACT_MATCH, /*< Match requires implicit conversion. */
+} parameter_list_match_t;
+
+/**
+ * \brief Check if two parameter lists match.
+ *
+ * \param list_a Parameters of the function definition.
+ * \param list_b Actual parameters passed to the function.
+ * \see matching_signature()
+ */
+static parameter_list_match_t
 parameter_lists_match(const exec_list *list_a, const exec_list *list_b)
 {
    const exec_node *node_a = list_a->head;
    const exec_node *node_b = list_b->head;
-   int total_score = 0;
+
+   /* This is set to true if there is an inexact match requiring an implicit
+    * conversion. */
+   bool inexact_match = false;
 
    for (/* empty */
        ; !node_a->is_tail_sentinel()
@@ -100,18 +55,17 @@ parameter_lists_match(const exec_list *list_a, const exec_list *list_b)
        * do not match.
        */
       if (node_b->is_tail_sentinel())
-        return -1;
+        return PARAMETER_LIST_NO_MATCH;
 
 
       const ir_variable *const param = (ir_variable *) node_a;
       const ir_instruction *const actual = (ir_instruction *) node_b;
 
-      /* Determine whether or not the types match.  If the types are an
-       * exact match, the match score is zero.  If the types don't match
-       * but the actual parameter can be coerced to the type of the declared
-       * parameter, the match score is one.
-       */
-      int score;
+      if (param->type == actual->type)
+        continue;
+
+      /* Try to find an implicit conversion from actual to param. */
+      inexact_match = true;
       switch ((enum ir_variable_mode)(param->mode)) {
       case ir_var_auto:
       case ir_var_uniform:
@@ -121,15 +75,17 @@ parameter_lists_match(const exec_list *list_a, const exec_list *list_b)
          * as uniform.
          */
         assert(0);
-        return -1;
+        return PARAMETER_LIST_NO_MATCH;
 
       case ir_var_const_in:
       case ir_var_in:
-        score = type_compare(param->type, actual->type);
+        if (!actual->type->can_implicitly_convert_to(param->type))
+           return PARAMETER_LIST_NO_MATCH;
         break;
 
       case ir_var_out:
-        score = type_compare(actual->type, param->type);
+        if (!param->type->can_implicitly_convert_to(actual->type))
+           return PARAMETER_LIST_NO_MATCH;
         break;
 
       case ir_var_inout:
@@ -137,17 +93,12 @@ parameter_lists_match(const exec_list *list_a, const exec_list *list_b)
          * there is int -> float but no float -> int), inout parameters must
          * be exact matches.
          */
-        score = (type_compare(actual->type, param->type) == 0) ? 0 : -1;
-        break;
+        return PARAMETER_LIST_NO_MATCH;
 
       default:
         assert(false);
+        return PARAMETER_LIST_NO_MATCH;
       }
-
-      if (score < 0)
-        return -1;
-
-      total_score += score;
    }
 
    /* If all of the parameters from the other parameter list have been
@@ -155,9 +106,12 @@ parameter_lists_match(const exec_list *list_a, const exec_list *list_b)
     * match.
     */
    if (!node_b->is_tail_sentinel())
-      return -1;
+      return PARAMETER_LIST_NO_MATCH;
 
-   return total_score;
+   if (inexact_match)
+      return PARAMETER_LIST_INEXACT_MATCH;
+   else
+      return PARAMETER_LIST_EXACT_MATCH;
 }
 
 
@@ -165,25 +119,49 @@ ir_function_signature *
 ir_function::matching_signature(const exec_list *actual_parameters)
 {
    ir_function_signature *match = NULL;
-
+   bool multiple_inexact_matches = false;
+
+   /* From page 42 (page 49 of the PDF) of the GLSL 1.20 spec:
+    *
+    * "If an exact match is found, the other signatures are ignored, and
+    *  the exact match is used.  Otherwise, if no exact match is found, then
+    *  the implicit conversions in Section 4.1.10 "Implicit Conversions" will
+    *  be applied to the calling arguments if this can make their types match
+    *  a signature.  In this case, it is a semantic error if there are
+    *  multiple ways to apply these conversions to the actual arguments of a
+    *  call such that the call can be made to match multiple signatures."
+    */
    foreach_iter(exec_list_iterator, iter, signatures) {
       ir_function_signature *const sig =
         (ir_function_signature *) iter.get();
 
-      const int score = parameter_lists_match(& sig->parameters,
-                                             actual_parameters);
-
-      if (score == 0)
+      switch (parameter_lists_match(& sig->parameters, actual_parameters)) {
+      case PARAMETER_LIST_EXACT_MATCH:
         return sig;
-
-      if (score > 0) {
-        if (match != NULL)
-           return NULL;
-
-        match = sig;
+      case PARAMETER_LIST_INEXACT_MATCH:
+        if (match == NULL)
+           match = sig;
+        else
+           multiple_inexact_matches = true;
+        continue;
+      case PARAMETER_LIST_NO_MATCH:
+        continue;
+      default:
+        assert(false);
+        return NULL;
       }
    }
 
+   /* There is no exact match (we would have returned it by now).  If there
+    * are multiple inexact matches, the call is ambiguous, which is an error.
+    *
+    * FINISHME: Report a decent error.  Returning NULL will likely result in
+    * FINISHME: a "no matching signature" error; it should report that the
+    * FINISHME: call is ambiguous.  But reporting errors from here is hard.
+    */
+   if (multiple_inexact_matches)
+      return NULL;
+
    return match;
 }
 
diff --git a/src/glsl/ir_function_detect_recursion.cpp b/src/glsl/ir_function_detect_recursion.cpp
new file mode 100644 (file)
index 0000000..8f805bf
--- /dev/null
@@ -0,0 +1,370 @@
+/*
+ * Copyright Â© 2011 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.
+ */
+
+/**
+ * \file ir_function_detect_recursion.cpp
+ * Determine whether a shader contains static recursion.
+ *
+ * Consider the (possibly disjoint) graph of function calls in a shader.  If a
+ * program contains recursion, this graph will contain a cycle.  If a function
+ * is part of a cycle, it will have a caller and it will have a callee (it
+ * calls another function).
+ *
+ * To detect recursion, the function call graph is constructed.  The graph is
+ * repeatedly reduced by removing any function that either has no callees
+ * (leaf functions) or has no caller.  Eventually the only functions that
+ * remain will be the functions in the cycles.
+ *
+ * The GLSL spec is a bit wishy-washy about recursion.
+ *
+ * From page 39 (page 45 of the PDF) of the GLSL 1.10 spec:
+ *
+ *     "Behavior is undefined if recursion is used. Recursion means having any
+ *     function appearing more than once at any one time in the run-time stack
+ *     of function calls. That is, a function may not call itself either
+ *     directly or indirectly. Compilers may give diagnostic messages when
+ *     this is detectable at compile time, but not all such cases can be
+ *     detected at compile time."
+ *
+ * From page 79 (page 85 of the PDF):
+ *
+ *     "22) Should recursion be supported?
+ *
+ *      DISCUSSION: Probably not necessary, but another example of limiting
+ *      the language based on how it would directly map to hardware. One
+ *      thought is that recursion would benefit ray tracing shaders. On the
+ *      other hand, many recursion operations can also be implemented with the
+ *      user managing the recursion through arrays. RenderMan doesn't support
+ *      recursion. This could be added at a later date, if it proved to be
+ *      necessary.
+ *
+ *      RESOLVED on September 10, 2002: Implementations are not required to
+ *      support recursion.
+ *
+ *      CLOSED on September 10, 2002."
+ *
+ * From page 79 (page 85 of the PDF):
+ *
+ *     "56) Is it an error for an implementation to support recursion if the
+ *     specification says recursion is not supported?
+ *
+ *     ADDED on September 10, 2002.
+ *
+ *     DISCUSSION: This issues is related to Issue (22). If we say that
+ *     recursion (or some other piece of functionality) is not supported, is
+ *     it an error for an implementation to support it? Perhaps the
+ *     specification should remain silent on these kind of things so that they
+ *     could be gracefully added later as an extension or as part of the
+ *     standard.
+ *
+ *     RESOLUTION: Languages, in general, have programs that are not
+ *     well-formed in ways a compiler cannot detect. Portability is only
+ *     ensured for well-formed programs. Detecting recursion is an example of
+ *     this. The language will say a well-formed program may not recurse, but
+ *     compilers are not forced to detect that recursion may happen.
+ *
+ *     CLOSED: November 29, 2002."
+ *
+ * In GLSL 1.10 the behavior of recursion is undefined.  Compilers don't have
+ * to reject shaders (at compile-time or link-time) that contain recursion.
+ * Instead they could work, or crash, or kill a kitten.
+ *
+ * From page 44 (page 50 of the PDF) of the GLSL 1.20 spec:
+ *
+ *     "Recursion is not allowed, not even statically. Static recursion is
+ *     present if the static function call graph of the program contains
+ *     cycles."
+ *
+ * This langauge clears things up a bit, but it still leaves a lot of
+ * questions unanswered.
+ *
+ *     - Is the error generated at compile-time or link-time?
+ *
+ *     - Is it an error to have a recursive function that is never statically
+ *       called by main or any function called directly or indirectly by main?
+ *       Technically speaking, such a function is not in the "static function
+ *       call graph of the program" at all.
+ *
+ * \bug
+ * If a shader has multiple cycles, this algorithm may erroneously complain
+ * about functions that aren't in any cycle, but are in the part of the call
+ * tree that connects them.  For example, if the call graph consists of a
+ * cycle between A and B, and a cycle between D and E, and B also calls C
+ * which calls D, then this algorithm will report C as a function which "has
+ * static recursion" even though it is not part of any cycle.
+ *
+ * A better algorithm for cycle detection that doesn't have this drawback can
+ * be found here:
+ *
+ * http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm
+ *
+ * \author Ian Romanick <ian.d.romanick@intel.com>
+ */
+#include "main/core.h"
+#include "ir.h"
+#include "glsl_parser_extras.h"
+#include "linker.h"
+#include "program/hash_table.h"
+#include "program.h"
+
+struct call_node : public exec_node {
+   class function *func;
+};
+
+class function {
+public:
+   function(ir_function_signature *sig)
+      : sig(sig)
+   {
+      /* empty */
+   }
+
+
+   /* Callers of this ralloc-based new need not call delete. It's
+    * easier to just ralloc_free 'ctx' (or any of its ancestors). */
+   static void* operator new(size_t size, void *ctx)
+   {
+      void *node;
+
+      node = ralloc_size(ctx, size);
+      assert(node != NULL);
+
+      return node;
+   }
+
+   /* If the user *does* call delete, that's OK, we will just
+    * ralloc_free in that case. */
+   static void operator delete(void *node)
+   {
+      ralloc_free(node);
+   }
+
+   ir_function_signature *sig;
+
+   /** List of functions called by this function. */
+   exec_list callees;
+
+   /** List of functions that call this function. */
+   exec_list callers;
+};
+
+class has_recursion_visitor : public ir_hierarchical_visitor {
+public:
+   has_recursion_visitor()
+      : current(NULL)
+   {
+      this->mem_ctx = ralloc_context(NULL);
+      this->function_hash = hash_table_ctor(0, hash_table_pointer_hash,
+                                           hash_table_pointer_compare);
+   }
+
+   ~has_recursion_visitor()
+   {
+      hash_table_dtor(this->function_hash);
+      ralloc_free(this->mem_ctx);
+   }
+
+   function *get_function(ir_function_signature *sig)
+   {
+      function *f = (function *) hash_table_find(this->function_hash, sig);
+      if (f == NULL) {
+        f = new(mem_ctx) function(sig);
+        hash_table_insert(this->function_hash, f, sig);
+      }
+
+      return f;
+   }
+
+   virtual ir_visitor_status visit_enter(ir_function_signature *sig)
+   {
+      this->current = this->get_function(sig);
+      return visit_continue;
+   }
+
+   virtual ir_visitor_status visit_leave(ir_function_signature *sig)
+   {
+      (void) sig;
+      this->current = NULL;
+      return visit_continue;
+   }
+
+   virtual ir_visitor_status visit_enter(ir_call *call)
+   {
+      /* At global scope this->current will be NULL.  Since there is no way to
+       * call global scope, it can never be part of a cycle.  Don't bother
+       * adding calls from global scope to the graph.
+       */
+      if (this->current == NULL)
+        return visit_continue;
+
+      function *const target = this->get_function(call->get_callee());
+
+      /* Create a link from the caller to the callee.
+       */
+      call_node *node = new(mem_ctx) call_node;
+      node->func = target;
+      this->current->callees.push_tail(node);
+
+      /* Create a link from the callee to the caller.
+       */
+      node = new(mem_ctx) call_node;
+      node->func = this->current;
+      target->callers.push_tail(node);
+      return visit_continue;
+   }
+
+   function *current;
+   struct hash_table *function_hash;
+   void *mem_ctx;
+   bool progress;
+};
+
+static void
+destroy_links(exec_list *list, function *f)
+{
+   foreach_list_safe(node, list) {
+      struct call_node *n = (struct call_node *) node;
+
+      /* If this is the right function, remove it.  Note that the loop cannot
+       * terminate now.  There can be multiple links to a function if it is
+       * either called multiple times or calls multiple times.
+       */
+      if (n->func == f)
+        n->remove();
+   }
+}
+
+
+/**
+ * Remove a function if it has either no in or no out links
+ */
+static void
+remove_unlinked_functions(const void *key, void *data, void *closure)
+{
+   has_recursion_visitor *visitor = (has_recursion_visitor *) closure;
+   function *f = (function *) data;
+
+   if (f->callers.is_empty() || f->callees.is_empty()) {
+      while (!f->callers.is_empty()) {
+        struct call_node *n = (struct call_node *) f->callers.pop_head();
+        destroy_links(& n->func->callees, f);
+      }
+
+      while (!f->callees.is_empty()) {
+        struct call_node *n = (struct call_node *) f->callees.pop_head();
+        destroy_links(& n->func->callers, f);
+      }
+
+      hash_table_remove(visitor->function_hash, key);
+      visitor->progress = true;
+   }
+}
+
+
+static void
+emit_errors_unlinked(const void *key, void *data, void *closure)
+{
+   struct _mesa_glsl_parse_state *state =
+      (struct _mesa_glsl_parse_state *) closure;
+   function *f = (function *) data;
+   YYLTYPE loc;
+
+   char *proto = prototype_string(f->sig->return_type,
+                                 f->sig->function_name(),
+                                 &f->sig->parameters);
+
+   memset(&loc, 0, sizeof(loc));
+   _mesa_glsl_error(&loc, state,
+                   "function `%s' has static recursion.",
+                   proto);
+   ralloc_free(proto);
+}
+
+
+static void
+emit_errors_linked(const void *key, void *data, void *closure)
+{
+   struct gl_shader_program *prog =
+      (struct gl_shader_program *) closure;
+   function *f = (function *) data;
+
+   char *proto = prototype_string(f->sig->return_type,
+                                 f->sig->function_name(),
+                                 &f->sig->parameters);
+
+   linker_error(prog, "function `%s' has static recursion.\n", proto);
+   ralloc_free(proto);
+   prog->LinkStatus = false;
+}
+
+
+void
+detect_recursion_unlinked(struct _mesa_glsl_parse_state *state,
+                         exec_list *instructions)
+{
+   has_recursion_visitor v;
+
+   /* Collect all of the information about which functions call which other
+    * functions.
+    */
+   v.run(instructions);
+
+   /* Remove from the set all of the functions that either have no caller or
+    * call no other functions.  Repeat until no functions are removed.
+    */
+   do {
+      v.progress = false;
+      hash_table_call_foreach(v.function_hash, remove_unlinked_functions, & v);
+   } while (v.progress);
+
+
+   /* At this point any functions still in the hash must be part of a cycle.
+    */
+   hash_table_call_foreach(v.function_hash, emit_errors_unlinked, state);
+}
+
+
+void
+detect_recursion_linked(struct gl_shader_program *prog,
+                       exec_list *instructions)
+{
+   has_recursion_visitor v;
+
+   /* Collect all of the information about which functions call which other
+    * functions.
+    */
+   v.run(instructions);
+
+   /* Remove from the set all of the functions that either have no caller or
+    * call no other functions.  Repeat until no functions are removed.
+    */
+   do {
+      v.progress = false;
+      hash_table_call_foreach(v.function_hash, remove_unlinked_functions, & v);
+   } while (v.progress);
+
+
+   /* At this point any functions still in the hash must be part of a cycle.
+    */
+   hash_table_call_foreach(v.function_hash, emit_errors_linked, prog);
+}
index dd26567..f7808bd 100644 (file)
@@ -56,10 +56,8 @@ bool do_if_simplification(exec_list *instructions);
 bool do_discard_simplification(exec_list *instructions);
 bool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth = 0);
 bool do_mat_op_to_vec(exec_list *instructions);
-bool do_mod_to_fract(exec_list *instructions);
 bool do_noop_swizzle(exec_list *instructions);
 bool do_structure_splitting(exec_list *instructions);
-bool do_sub_to_add_neg(exec_list *instructions);
 bool do_swizzle_swizzle(exec_list *instructions);
 bool do_tree_grafting(exec_list *instructions);
 bool do_vec_index_to_cond_assign(exec_list *instructions);
@@ -71,3 +69,7 @@ bool lower_variable_index_to_cond_assign(exec_list *instructions,
     bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
 bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
 bool optimize_redundant_jumps(exec_list *instructions);
+
+ir_rvalue *
+compare_index_block(exec_list *instructions, ir_variable *index,
+                   unsigned base, unsigned components, void *mem_ctx);
index 5b5409d..518910b 100644 (file)
@@ -96,6 +96,16 @@ void ir_print_visitor::indent(void)
 const char *
 ir_print_visitor::unique_name(ir_variable *var)
 {
+   /* var->name can be NULL in function prototypes when a type is given for a
+    * parameter but no name is given.  In that case, just return an empty
+    * string.  Don't worry about tracking the generated name in the printable
+    * names hash because this is the only scope where it can ever appear.
+    */
+   if (var->name == NULL) {
+      static unsigned arg = 1;
+      return ralloc_asprintf(this->mem_ctx, "parameter@%u", arg++);
+   }
+
    /* Do we already have a name for this variable? */
    const char *name = (const char *) hash_table_find(this->printable_names, var);
    if (name != NULL)
index 30df257..f3a6217 100644 (file)
@@ -482,19 +482,21 @@ ir_reader::read_return(s_expression *expr)
 {
    s_expression *s_retval;
 
-   s_pattern pat[] = { "return", s_retval};
-   if (!MATCH(expr, pat)) {
-      ir_read_error(expr, "expected (return <rvalue>)");
-      return NULL;
-   }
-
-   ir_rvalue *retval = read_rvalue(s_retval);
-   if (retval == NULL) {
-      ir_read_error(NULL, "when reading return value");
+   s_pattern return_value_pat[] = { "return", s_retval};
+   s_pattern return_void_pat[] = { "return" };
+   if (MATCH(expr, return_value_pat)) {
+      ir_rvalue *retval = read_rvalue(s_retval);
+      if (retval == NULL) {
+         ir_read_error(NULL, "when reading return value");
+         return NULL;
+      }
+      return new(mem_ctx) ir_return(retval);
+   } else if (MATCH(expr, return_void_pat)) {
+      return new(mem_ctx) ir_return;
+   } else {
+      ir_read_error(expr, "expected (return <rvalue>) or (return)");
       return NULL;
    }
-
-   return new(mem_ctx) ir_return(retval);
 }
 
 
index 7b1c19d..f3fceb2 100644 (file)
@@ -254,7 +254,7 @@ ir_validate::visit_leave(ir_expression *ir)
 
    case ir_unop_f2i:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
-      assert(ir->type->is_integer());
+      assert(ir->type->base_type == GLSL_TYPE_INT);
       break;
    case ir_unop_i2f:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
@@ -269,17 +269,25 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->type->base_type == GLSL_TYPE_FLOAT);
       break;
    case ir_unop_i2b:
-      assert(ir->operands[0]->type->is_integer());
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
       assert(ir->type->base_type == GLSL_TYPE_BOOL);
       break;
    case ir_unop_b2i:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
-      assert(ir->type->is_integer());
+      assert(ir->type->base_type == GLSL_TYPE_INT);
       break;
    case ir_unop_u2f:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
       assert(ir->type->base_type == GLSL_TYPE_FLOAT);
       break;
+   case ir_unop_i2u:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
+      assert(ir->type->base_type == GLSL_TYPE_UINT);
+      break;
+   case ir_unop_u2i:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
+      assert(ir->type->base_type == GLSL_TYPE_INT);
+      break;
 
    case ir_unop_any:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
index ae8818b..d40f771 100644 (file)
@@ -31,7 +31,8 @@
 
 static ir_function_signature *
 find_matching_signature(const char *name, const exec_list *actual_parameters,
-                       gl_shader **shader_list, unsigned num_shaders);
+                       gl_shader **shader_list, unsigned num_shaders,
+                       bool use_builtin);
 
 class call_link_visitor : public ir_hierarchical_visitor {
 public:
@@ -75,7 +76,8 @@ public:
        * final linked shader.  If it does, use it as the target of the call.
        */
       ir_function_signature *sig =
-        find_matching_signature(name, &callee->parameters, &linked, 1);
+        find_matching_signature(name, &callee->parameters, &linked, 1,
+                                ir->use_builtin);
       if (sig != NULL) {
         ir->set_callee(sig);
         return visit_continue;
@@ -85,12 +87,12 @@ public:
        * linked.  If it's not found there, return an error.
        */
       sig = find_matching_signature(name, &ir->actual_parameters, shader_list,
-                                   num_shaders);
+                                   num_shaders, ir->use_builtin);
       if (sig == NULL) {
         /* FINISHME: Log the full signature of unresolved function.
          */
-        linker_error_printf(this->prog, "unresolved reference to function "
-                            "`%s'\n", name);
+        linker_error(this->prog, "unresolved reference to function `%s'\n",
+                     name);
         this->success = false;
         return visit_stop;
       }
@@ -110,7 +112,9 @@ public:
 
       ir_function_signature *linked_sig =
         f->exact_matching_signature(&callee->parameters);
-      if (linked_sig == NULL) {
+      if ((linked_sig == NULL)
+         || ((linked_sig != NULL)
+             && (linked_sig->is_builtin != ir->use_builtin))) {
         linked_sig = new(linked) ir_function_signature(callee->return_type);
         f->add_signature(linked_sig);
       }
@@ -241,7 +245,8 @@ private:
  */
 ir_function_signature *
 find_matching_signature(const char *name, const exec_list *actual_parameters,
-                       gl_shader **shader_list, unsigned num_shaders)
+                       gl_shader **shader_list, unsigned num_shaders,
+                       bool use_builtin)
 {
    for (unsigned i = 0; i < num_shaders; i++) {
       ir_function *const f = shader_list[i]->symbols->get_function(name);
@@ -254,6 +259,13 @@ find_matching_signature(const char *name, const exec_list *actual_parameters,
       if ((sig == NULL) || !sig->is_defined)
         continue;
 
+      /* If this function expects to bind to a built-in function and the
+       * signature that we found isn't a built-in, keep looking.  Also keep
+       * looking if we expect a non-built-in but found a built-in.
+       */
+      if (use_builtin != sig->is_builtin)
+           continue;
+
       return sig;
    }
 
index 255edc6..19eb9b5 100644 (file)
@@ -164,7 +164,7 @@ private:
 
 
 void
-linker_error_printf(gl_shader_program *prog, const char *fmt, ...)
+linker_error(gl_shader_program *prog, const char *fmt, ...)
 {
    va_list ap;
 
@@ -172,6 +172,21 @@ linker_error_printf(gl_shader_program *prog, const char *fmt, ...)
    va_start(ap, fmt);
    ralloc_vasprintf_append(&prog->InfoLog, fmt, ap);
    va_end(ap);
+
+   prog->LinkStatus = false;
+}
+
+
+void
+linker_warning(gl_shader_program *prog, const char *fmt, ...)
+{
+   va_list ap;
+
+   ralloc_strcat(&prog->InfoLog, "error: ");
+   va_start(ap, fmt);
+   ralloc_vasprintf_append(&prog->InfoLog, fmt, ap);
+   va_end(ap);
+
 }
 
 
@@ -243,8 +258,7 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
    find_assignment_visitor find("gl_Position");
    find.run(shader->ir);
    if (!find.variable_found()) {
-      linker_error_printf(prog,
-                         "vertex shader does not write to `gl_Position'\n");
+      linker_error(prog, "vertex shader does not write to `gl_Position'\n");
       return false;
    }
 
@@ -271,8 +285,8 @@ validate_fragment_shader_executable(struct gl_shader_program *prog,
    frag_data.run(shader->ir);
 
    if (frag_color.variable_found() && frag_data.variable_found()) {
-      linker_error_printf(prog,  "fragment shader writes to both "
-                         "`gl_FragColor' and `gl_FragData'\n");
+      linker_error(prog,  "fragment shader writes to both "
+                  "`gl_FragColor' and `gl_FragData'\n");
       return false;
    }
 
@@ -357,11 +371,11 @@ cross_validate_globals(struct gl_shader_program *prog,
                     existing->type = var->type;
                  }
               } else {
-                 linker_error_printf(prog, "%s `%s' declared as type "
-                                     "`%s' and type `%s'\n",
-                                     mode_string(var),
-                                     var->name, var->type->name,
-                                     existing->type->name);
+                 linker_error(prog, "%s `%s' declared as type "
+                              "`%s' and type `%s'\n",
+                              mode_string(var),
+                              var->name, var->type->name,
+                              existing->type->name);
                  return false;
               }
            }
@@ -369,9 +383,9 @@ cross_validate_globals(struct gl_shader_program *prog,
            if (var->explicit_location) {
               if (existing->explicit_location
                   && (var->location != existing->location)) {
-                    linker_error_printf(prog, "explicit locations for %s "
-                                        "`%s' have differing values\n",
-                                        mode_string(var), var->name);
+                    linker_error(prog, "explicit locations for %s "
+                                 "`%s' have differing values\n",
+                                 mode_string(var), var->name);
                     return false;
               }
 
@@ -392,12 +406,12 @@ cross_validate_globals(struct gl_shader_program *prog,
            bool layout_declared = var->depth_layout != ir_depth_layout_none;
            bool layout_differs = var->depth_layout != existing->depth_layout;
            if (layout_declared && layout_differs) {
-              linker_error_printf(prog,
+              linker_error(prog,
                  "All redeclarations of gl_FragDepth in all fragment shaders "
                  "in a single program must have the same set of qualifiers.");
            }
            if (var->used && layout_differs) {
-              linker_error_printf(prog,
+              linker_error(prog,
                     "If gl_FragDepth is redeclared with a layout qualifier in"
                     "any fragment shader, it must be redeclared with the same"
                     "layout qualifier in all fragment shaders that have"
@@ -410,9 +424,9 @@ cross_validate_globals(struct gl_shader_program *prog,
            if (var->constant_value != NULL) {
               if (existing->constant_value != NULL) {
                  if (!var->constant_value->has_value(existing->constant_value)) {
-                    linker_error_printf(prog, "initializers for %s "
-                                        "`%s' have differing values\n",
-                                        mode_string(var), var->name);
+                    linker_error(prog, "initializers for %s "
+                                 "`%s' have differing values\n",
+                                 mode_string(var), var->name);
                     return false;
                  }
               } else
@@ -433,15 +447,15 @@ cross_validate_globals(struct gl_shader_program *prog,
            }
 
            if (existing->invariant != var->invariant) {
-              linker_error_printf(prog, "declarations for %s `%s' have "
-                                  "mismatching invariant qualifiers\n",
-                                  mode_string(var), var->name);
+              linker_error(prog, "declarations for %s `%s' have "
+                           "mismatching invariant qualifiers\n",
+                           mode_string(var), var->name);
               return false;
            }
             if (existing->centroid != var->centroid) {
-               linker_error_printf(prog, "declarations for %s `%s' have "
-                                   "mismatching centroid qualifiers\n",
-                                   mode_string(var), var->name);
+               linker_error(prog, "declarations for %s `%s' have "
+                           "mismatching centroid qualifiers\n",
+                           mode_string(var), var->name);
                return false;
             }
         } else
@@ -529,13 +543,12 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
             */
            if (!output->type->is_array()
                || (strncmp("gl_", output->name, 3) != 0)) {
-              linker_error_printf(prog,
-                                  "%s shader output `%s' declared as "
-                                  "type `%s', but %s shader input declared "
-                                  "as type `%s'\n",
-                                  producer_stage, output->name,
-                                  output->type->name,
-                                  consumer_stage, input->type->name);
+              linker_error(prog,
+                           "%s shader output `%s' declared as type `%s', "
+                           "but %s shader input declared as type `%s'\n",
+                           producer_stage, output->name,
+                           output->type->name,
+                           consumer_stage, input->type->name);
               return false;
            }
         }
@@ -543,40 +556,40 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
         /* Check that all of the qualifiers match between stages.
          */
         if (input->centroid != output->centroid) {
-           linker_error_printf(prog,
-                               "%s shader output `%s' %s centroid qualifier, "
-                               "but %s shader input %s centroid qualifier\n",
-                               producer_stage,
-                               output->name,
-                               (output->centroid) ? "has" : "lacks",
-                               consumer_stage,
-                               (input->centroid) ? "has" : "lacks");
+           linker_error(prog,
+                        "%s shader output `%s' %s centroid qualifier, "
+                        "but %s shader input %s centroid qualifier\n",
+                        producer_stage,
+                        output->name,
+                        (output->centroid) ? "has" : "lacks",
+                        consumer_stage,
+                        (input->centroid) ? "has" : "lacks");
            return false;
         }
 
         if (input->invariant != output->invariant) {
-           linker_error_printf(prog,
-                               "%s shader output `%s' %s invariant qualifier, "
-                               "but %s shader input %s invariant qualifier\n",
-                               producer_stage,
-                               output->name,
-                               (output->invariant) ? "has" : "lacks",
-                               consumer_stage,
-                               (input->invariant) ? "has" : "lacks");
+           linker_error(prog,
+                        "%s shader output `%s' %s invariant qualifier, "
+                        "but %s shader input %s invariant qualifier\n",
+                        producer_stage,
+                        output->name,
+                        (output->invariant) ? "has" : "lacks",
+                        consumer_stage,
+                        (input->invariant) ? "has" : "lacks");
            return false;
         }
 
         if (input->interpolation != output->interpolation) {
-           linker_error_printf(prog,
-                               "%s shader output `%s' specifies %s "
-                               "interpolation qualifier, "
-                               "but %s shader input specifies %s "
-                               "interpolation qualifier\n",
-                               producer_stage,
-                               output->name,
-                               output->interpolation_string(),
-                               consumer_stage,
-                               input->interpolation_string());
+           linker_error(prog,
+                        "%s shader output `%s' specifies %s "
+                        "interpolation qualifier, "
+                        "but %s shader input specifies %s "
+                        "interpolation qualifier\n",
+                        producer_stage,
+                        output->name,
+                        output->interpolation_string(),
+                        consumer_stage,
+                        input->interpolation_string());
            return false;
         }
       }
@@ -823,9 +836,8 @@ link_intrastage_shaders(void *mem_ctx,
 
               if ((other_sig != NULL) && other_sig->is_defined
                   && !other_sig->is_builtin) {
-                 linker_error_printf(prog,
-                                     "function `%s' is multiply defined",
-                                     f->name);
+                 linker_error(prog, "function `%s' is multiply defined",
+                              f->name);
                  return NULL;
               }
            }
@@ -849,9 +861,9 @@ link_intrastage_shaders(void *mem_ctx,
    }
 
    if (main == NULL) {
-      linker_error_printf(prog, "%s shader lacks `main'\n",
-                         (shader_list[0]->Type == GL_VERTEX_SHADER)
-                         ? "vertex" : "fragment");
+      linker_error(prog, "%s shader lacks `main'\n",
+                  (shader_list[0]->Type == GL_VERTEX_SHADER)
+                  ? "vertex" : "fragment");
       return NULL;
    }
 
@@ -1194,16 +1206,43 @@ find_available_slots(unsigned used_mask, unsigned needed_count)
 }
 
 
+/**
+ * Assign locations for either VS inputs for FS outputs
+ *
+ * \param prog          Shader program whose variables need locations assigned
+ * \param target_index  Selector for the program target to receive location
+ *                      assignmnets.  Must be either \c MESA_SHADER_VERTEX or
+ *                      \c MESA_SHADER_FRAGMENT.
+ * \param max_index     Maximum number of generic locations.  This corresponds
+ *                      to either the maximum number of draw buffers or the
+ *                      maximum number of generic attributes.
+ *
+ * \return
+ * If locations are successfully assigned, true is returned.  Otherwise an
+ * error is emitted to the shader link log and false is returned.
+ *
+ * \bug
+ * Locations set via \c glBindFragDataLocation are not currently supported.
+ * Only locations assigned automatically by the linker, explicitly set by a
+ * layout qualifier, or explicitly set by a built-in variable (e.g., \c
+ * gl_FragColor) are supported for fragment shaders.
+ */
 bool
-assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index)
+assign_attribute_or_color_locations(gl_shader_program *prog,
+                                   unsigned target_index,
+                                   unsigned max_index)
 {
-   /* Mark invalid attribute locations as being used.
+   /* Mark invalid locations as being used.
     */
-   unsigned used_locations = (max_attribute_index >= 32)
-      ? ~0 : ~((1 << max_attribute_index) - 1);
+   unsigned used_locations = (max_index >= 32)
+      ? ~0 : ~((1 << max_index) - 1);
+
+   assert((target_index == MESA_SHADER_VERTEX)
+         || (target_index == MESA_SHADER_FRAGMENT));
 
-   gl_shader *const sh = prog->_LinkedShaders[0];
-   assert(sh->Type == GL_VERTEX_SHADER);
+   gl_shader *const sh = prog->_LinkedShaders[target_index];
+   if (sh == NULL)
+      return true;
 
    /* Operate in a total of four passes.
     *
@@ -1220,9 +1259,16 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index
     * 4. Assign locations to any inputs without assigned locations.
     */
 
-   invalidate_variable_locations(sh, ir_var_in, VERT_ATTRIB_GENERIC0);
+   const int generic_base = (target_index == MESA_SHADER_VERTEX)
+      ? (int) VERT_ATTRIB_GENERIC0 : (int) FRAG_RESULT_DATA0;
+
+   const enum ir_variable_mode direction =
+      (target_index == MESA_SHADER_VERTEX) ? ir_var_in : ir_var_out;
 
-   if (prog->Attributes != NULL) {
+
+   invalidate_variable_locations(sh, direction, generic_base);
+
+   if ((target_index == MESA_SHADER_VERTEX) && (prog->Attributes != NULL)) {
       for (unsigned i = 0; i < prog->Attributes->NumParameters; i++) {
         ir_variable *const var =
            sh->symbols->get_variable(prog->Attributes->Parameters[i].Name);
@@ -1275,10 +1321,10 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index
          * attribute overlaps any previously allocated bits.
          */
         if ((~(use_mask << attr) & used_locations) != used_locations) {
-           linker_error_printf(prog,
-                               "insufficient contiguous attribute locations "
-                               "available for vertex shader input `%s'",
-                               var->name);
+           linker_error(prog,
+                        "insufficient contiguous attribute locations "
+                        "available for vertex shader input `%s'",
+                        var->name);
            return false;
         }
 
@@ -1309,23 +1355,22 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index
    foreach_list(node, sh->ir) {
       ir_variable *const var = ((ir_instruction *) node)->as_variable();
 
-      if ((var == NULL) || (var->mode != ir_var_in))
+      if ((var == NULL) || (var->mode != (unsigned) direction))
         continue;
 
       if (var->explicit_location) {
         const unsigned slots = count_attribute_slots(var->type);
         const unsigned use_mask = (1 << slots) - 1;
-        const int attr = var->location - VERT_ATTRIB_GENERIC0;
+        const int attr = var->location - generic_base;
 
-        if ((var->location >= (int)(max_attribute_index + VERT_ATTRIB_GENERIC0))
+        if ((var->location >= (int)(max_index + generic_base))
             || (var->location < 0)) {
-           linker_error_printf(prog,
-                               "invalid explicit location %d specified for "
-                               "`%s'\n",
-                               (var->location < 0) ? var->location : attr,
-                               var->name);
+           linker_error(prog,
+                        "invalid explicit location %d specified for `%s'\n",
+                        (var->location < 0) ? var->location : attr,
+                        var->name);
            return false;
-        } else if (var->location >= VERT_ATTRIB_GENERIC0) {
+        } else if (var->location >= generic_base) {
            used_locations |= (use_mask << attr);
         }
       }
@@ -1349,14 +1394,16 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index
 
    qsort(to_assign, num_attr, sizeof(to_assign[0]), temp_attr::compare);
 
-   /* VERT_ATTRIB_GENERIC0 is a pseudo-alias for VERT_ATTRIB_POS.  It can only
-    * be explicitly assigned by via glBindAttribLocation.  Mark it as reserved
-    * to prevent it from being automatically allocated below.
-    */
-   find_deref_visitor find("gl_Vertex");
-   find.run(sh->ir);
-   if (find.variable_found())
-      used_locations |= (1 << 0);
+   if (target_index == MESA_SHADER_VERTEX) {
+      /* VERT_ATTRIB_GENERIC0 is a pseudo-alias for VERT_ATTRIB_POS.  It can
+       * only be explicitly assigned by via glBindAttribLocation.  Mark it as
+       * reserved to prevent it from being automatically allocated below.
+       */
+      find_deref_visitor find("gl_Vertex");
+      find.run(sh->ir);
+      if (find.variable_found())
+        used_locations |= (1 << 0);
+   }
 
    for (unsigned i = 0; i < num_attr; i++) {
       /* Mask representing the contiguous slots that will be used by this
@@ -1367,14 +1414,17 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index
       int location = find_available_slots(used_locations, to_assign[i].slots);
 
       if (location < 0) {
-        linker_error_printf(prog,
-                            "insufficient contiguous attribute locations "
-                            "available for vertex shader input `%s'",
-                            to_assign[i].var->name);
+        const char *const string = (target_index == MESA_SHADER_VERTEX)
+           ? "vertex shader input" : "fragment shader output";
+
+        linker_error(prog,
+                     "insufficient contiguous attribute locations "
+                     "available for %s `%s'",
+                     string, to_assign[i].var->name);
         return false;
       }
 
-      to_assign[i].var->location = VERT_ATTRIB_GENERIC0 + location;
+      to_assign[i].var->location = generic_base + location;
       used_locations |= (use_mask << location);
    }
 
@@ -1405,8 +1455,9 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode)
 }
 
 
-void
-assign_varying_locations(struct gl_shader_program *prog,
+bool
+assign_varying_locations(struct gl_context *ctx,
+                        struct gl_shader_program *prog,
                         gl_shader *producer, gl_shader *consumer)
 {
    /* FINISHME: Set dynamically when geometry shader support is added. */
@@ -1462,6 +1513,8 @@ assign_varying_locations(struct gl_shader_program *prog,
       }
    }
 
+   unsigned varying_vectors = 0;
+
    foreach_list(node, consumer->ir) {
       ir_variable *const var = ((ir_instruction *) node)->as_variable();
 
@@ -1483,17 +1536,40 @@ assign_varying_locations(struct gl_shader_program *prog,
             * "glsl1-varying read but not written" in piglit.
             */
 
-           linker_error_printf(prog, "fragment shader varying %s not written "
-                               "by vertex shader\n.", var->name);
-           prog->LinkStatus = false;
+           linker_error(prog, "fragment shader varying %s not written "
+                        "by vertex shader\n.", var->name);
         }
 
         /* An 'in' variable is only really a shader input if its
          * value is written by the previous stage.
          */
         var->mode = ir_var_auto;
+      } else {
+        /* The packing rules are used for vertex shader inputs are also used
+         * for fragment shader inputs.
+         */
+        varying_vectors += count_attribute_slots(var->type);
       }
    }
+
+   if (ctx->API == API_OPENGLES2 || prog->Version == 100) {
+      if (varying_vectors > ctx->Const.MaxVarying) {
+        linker_error(prog, "shader uses too many varying vectors "
+                     "(%u > %u)\n",
+                     varying_vectors, ctx->Const.MaxVarying);
+        return false;
+      }
+   } else {
+      const unsigned float_components = varying_vectors * 4;
+      if (float_components > ctx->Const.MaxVarying * 4) {
+        linker_error(prog, "shader uses too many varying components "
+                     "(%u > %u)\n",
+                     float_components, ctx->Const.MaxVarying * 4);
+        return false;
+      }
+   }
+
+   return true;
 }
 
 
@@ -1552,8 +1628,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    assert(max_version <= 130);
    if ((max_version >= 130 || min_version == 100)
        && min_version != max_version) {
-      linker_error_printf(prog, "all shaders must use same shading "
-                         "language version\n");
+      linker_error(prog, "all shaders must use same shading "
+                  "language version\n");
       goto done;
    }
 
@@ -1636,6 +1712,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       if (prog->_LinkedShaders[i] == NULL)
         continue;
 
+      detect_recursion_linked(prog, prog->_LinkedShaders[i]->ir);
+      if (!prog->LinkStatus)
+        goto done;
+
       while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, 32))
         ;
    }
@@ -1644,16 +1724,17 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
 
    assign_uniform_locations(prog);
 
-   if (prog->_LinkedShaders[MESA_SHADER_VERTEX] != NULL) {
-      /* FINISHME: The value of the max_attribute_index parameter is
-       * FINISHME: implementation dependent based on the value of
-       * FINISHME: GL_MAX_VERTEX_ATTRIBS.  GL_MAX_VERTEX_ATTRIBS must be
-       * FINISHME: at least 16, so hardcode 16 for now.
-       */
-      if (!assign_attribute_locations(prog, 16)) {
-        prog->LinkStatus = false;
-        goto done;
-      }
+   /* FINISHME: The value of the max_attribute_index parameter is
+    * FINISHME: implementation dependent based on the value of
+    * FINISHME: GL_MAX_VERTEX_ATTRIBS.  GL_MAX_VERTEX_ATTRIBS must be
+    * FINISHME: at least 16, so hardcode 16 for now.
+    */
+   if (!assign_attribute_or_color_locations(prog, MESA_SHADER_VERTEX, 16)) {
+      goto done;
+   }
+
+   if (!assign_attribute_or_color_locations(prog, MESA_SHADER_FRAGMENT, ctx->Const.MaxDrawBuffers)) {
+      goto done;
    }
 
    unsigned prev;
@@ -1666,9 +1747,12 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       if (prog->_LinkedShaders[i] == NULL)
         continue;
 
-      assign_varying_locations(prog,
-                              prog->_LinkedShaders[prev],
-                              prog->_LinkedShaders[i]);
+      if (!assign_varying_locations(ctx, prog,
+                                   prog->_LinkedShaders[prev],
+                                   prog->_LinkedShaders[i])) {
+        goto done;
+      }
+
       prev = i;
    }
 
@@ -1697,11 +1781,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
     */
    if (ctx->API == API_OPENGLES2 || prog->Version == 100) {
       if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
-        linker_error_printf(prog, "program lacks a vertex shader\n");
-        prog->LinkStatus = false;
+        linker_error(prog, "program lacks a vertex shader\n");
       } else if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) {
-        linker_error_printf(prog, "program lacks a fragment shader\n");
-        prog->LinkStatus = false;
+        linker_error(prog, "program lacks a fragment shader\n");
       }
    }
 
index a8ce16a..769cf68 100644 (file)
@@ -25,9 +25,6 @@
 #ifndef GLSL_LINKER_H
 #define GLSL_LINKER_H
 
-extern void
-linker_error_printf(gl_shader_program *prog, const char *fmt, ...);
-
 extern bool
 link_function_calls(gl_shader_program *prog, gl_shader *main,
                    gl_shader **shader_list, unsigned num_shaders);
index e3a1065..b637eb4 100644 (file)
@@ -149,11 +149,9 @@ ir_visitor_status
 ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir)
 {
    /* Only flatten when beyond the GPU's maximum supported nesting depth. */
-   if (this->depth <= this->max_depth)
+   if (this->depth-- <= this->max_depth)
       return visit_continue;
 
-   this->depth--;
-
    bool found_control_flow = false;
    ir_variable *cond_var;
    ir_assignment *assign;
index a5f61f2..806f863 100644 (file)
@@ -168,8 +168,13 @@ lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir)
 
       op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1);
 
-      ir->operation = ir_unop_f2i;
-      ir->operands[0] = op0;
+      if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) {
+        ir->operation = ir_unop_f2i;
+        ir->operands[0] = op0;
+      } else {
+        ir->operation = ir_unop_i2u;
+        ir->operands[0] = new(ir) ir_expression(ir_unop_f2i, op0);
+      }
       ir->operands[1] = NULL;
    }
 
@@ -271,7 +276,7 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
       break;
 
    case ir_binop_mod:
-      if (lowering(MOD_TO_FRACT))
+      if (lowering(MOD_TO_FRACT) && ir->type->is_float())
         mod_to_fract(ir);
       break;
 
index dd2601d..6187499 100644 (file)
 #include <string.h>
 #include "ir.h"
 
+/**
+ * Enum recording the result of analyzing how control flow might exit
+ * an IR node.
+ *
+ * Each possible value of jump_strength indicates a strictly stronger
+ * guarantee on control flow than the previous value.
+ *
+ * The ordering of strengths roughly reflects the way jumps are
+ * lowered: jumps with higher strength tend to be lowered to jumps of
+ * lower strength.  Accordingly, strength is used as a heuristic to
+ * determine which lowering to perform first.
+ *
+ * This enum is also used by get_jump_strength() to categorize
+ * instructions as either break, continue, return, or other.  When
+ * used in this fashion, strength_always_clears_execute_flag is not
+ * used.
+ *
+ * The control flow analysis made by this optimization pass makes two
+ * simplifying assumptions:
+ *
+ * - It ignores discard instructions, since they are lowered by a
+ *   separate pass (lower_discard.cpp).
+ *
+ * - It assumes it is always possible for control to flow from a loop
+ *   to the instruction immediately following it.  Technically, this
+ *   is not true (since all execution paths through the loop might
+ *   jump back to the top, or return from the function).
+ *
+ * Both of these simplifying assumtions are safe, since they can never
+ * cause reachable code to be incorrectly classified as unreachable;
+ * they can only do the opposite.
+ */
 enum jump_strength
 {
+   /**
+    * Analysis has produced no guarantee on how control flow might
+    * exit this IR node.  It might fall out the bottom (with or
+    * without clearing the execute flag, if present), or it might
+    * continue to the top of the innermost enclosing loop, break out
+    * of it, or return from the function.
+    */
    strength_none,
+
+   /**
+    * The only way control can fall out the bottom of this node is
+    * through a code path that clears the execute flag.  It might also
+    * continue to the top of the innermost enclosing loop, break out
+    * of it, or return from the function.
+    */
    strength_always_clears_execute_flag,
+
+   /**
+    * Control cannot fall out the bottom of this node.  It might
+    * continue to the top of the innermost enclosing loop, break out
+    * of it, or return from the function.
+    */
    strength_continue,
+
+   /**
+    * Control cannot fall out the bottom of this node, or continue the
+    * top of the innermost enclosing loop.  It can only break out of
+    * it or return from the function.
+    */
    strength_break,
+
+   /**
+    * Control cannot fall out the bottom of this node, continue to the
+    * top of the innermost enclosing loop, or break out of it.  It can
+    * only return from the function.
+    */
    strength_return
 };
 
@@ -146,16 +210,17 @@ struct function_record
    ir_function_signature* signature;
    ir_variable* return_flag; /* used to break out of all loops and then jump to the return instruction */
    ir_variable* return_value;
-   bool is_main;
+   bool lower_return;
    unsigned nesting_depth;
 
-   function_record(ir_function_signature* p_signature = 0)
+   function_record(ir_function_signature* p_signature = 0,
+                   bool lower_return = false)
    {
       this->signature = p_signature;
       this->return_flag = 0;
       this->return_value = 0;
       this->nesting_depth = 0;
-      this->is_main = this->signature && (strcmp(this->signature->function_name(), "main") == 0);
+      this->lower_return = lower_return;
    }
 
    ir_variable* get_return_flag()
@@ -180,6 +245,27 @@ struct function_record
 };
 
 struct ir_lower_jumps_visitor : public ir_control_flow_visitor {
+   /* Postconditions: on exit of any visit() function:
+    *
+    * ANALYSIS: this->block.min_strength,
+    * this->block.may_clear_execute_flag, and
+    * this->loop.may_set_return_flag are updated to reflect the
+    * characteristics of the visited statement.
+    *
+    * DEAD_CODE_ELIMINATION: If this->block.min_strength is not
+    * strength_none, the visited node is at the end of its exec_list.
+    * In other words, any unreachable statements that follow the
+    * visited statement in its exec_list have been removed.
+    *
+    * CONTAINED_JUMPS_LOWERED: If the visited statement contains other
+    * statements, then should_lower_jump() is false for all of the
+    * return, break, or continue statements it contains.
+    *
+    * Note that visiting a jump does not lower it.  That is the
+    * responsibility of the statement (or function signature) that
+    * contains the jump.
+    */
+
    bool progress;
 
    struct function_record function;
@@ -218,20 +304,140 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor {
       }
    }
 
+   /**
+    * Insert the instructions necessary to lower a return statement,
+    * before the given return instruction.
+    */
+   void insert_lowered_return(ir_return *ir)
+   {
+      ir_variable* return_flag = this->function.get_return_flag();
+      if(!this->function.signature->return_type->is_void()) {
+         ir_variable* return_value = this->function.get_return_value();
+         ir->insert_before(
+            new(ir) ir_assignment(
+               new (ir) ir_dereference_variable(return_value),
+               ir->value));
+      }
+      ir->insert_before(
+         new(ir) ir_assignment(
+            new (ir) ir_dereference_variable(return_flag),
+            new (ir) ir_constant(true)));
+      this->loop.may_set_return_flag = true;
+   }
+
+   /**
+    * If the given instruction is a return, lower it to instructions
+    * that store the return value (if there is one), set the return
+    * flag, and then break.
+    *
+    * It is safe to pass NULL to this function.
+    */
+   void lower_return_unconditionally(ir_instruction *ir)
+   {
+      if (get_jump_strength(ir) != strength_return) {
+         return;
+      }
+      insert_lowered_return((ir_return*)ir);
+      ir->replace_with(new(ir) ir_loop_jump(ir_loop_jump::jump_break));
+   }
+
+   /**
+    * Create the necessary instruction to replace a break instruction.
+    */
+   ir_instruction *create_lowered_break()
+   {
+      void *ctx = this->function.signature;
+      return new(ctx) ir_assignment(
+          new(ctx) ir_dereference_variable(this->loop.get_break_flag()),
+          new(ctx) ir_constant(true),
+          0);
+   }
+
+   /**
+    * If the given instruction is a break, lower it to an instruction
+    * that sets the break flag, without consulting
+    * should_lower_jump().
+    *
+    * It is safe to pass NULL to this function.
+    */
+   void lower_break_unconditionally(ir_instruction *ir)
+   {
+      if (get_jump_strength(ir) != strength_break) {
+         return;
+      }
+      ir->replace_with(create_lowered_break());
+   }
+
+   /**
+    * If the block ends in a conditional or unconditional break, lower
+    * it, even though should_lower_jump() says it needn't be lowered.
+    */
+   void lower_final_breaks(exec_list *block)
+   {
+      ir_instruction *ir = (ir_instruction *) block->get_tail();
+      lower_break_unconditionally(ir);
+      ir_if *ir_if = ir->as_if();
+      if (ir_if) {
+          lower_break_unconditionally(
+              (ir_instruction *) ir_if->then_instructions.get_tail());
+          lower_break_unconditionally(
+              (ir_instruction *) ir_if->else_instructions.get_tail());
+      }
+   }
+
    virtual void visit(class ir_loop_jump * ir)
    {
+      /* Eliminate all instructions after each one, since they are
+       * unreachable.  This satisfies the DEAD_CODE_ELIMINATION
+       * postcondition.
+       */
       truncate_after_instruction(ir);
+
+      /* Set this->block.min_strength based on this instruction.  This
+       * satisfies the ANALYSIS postcondition.  It is not necessary to
+       * update this->block.may_clear_execute_flag or
+       * this->loop.may_set_return_flag, because an unlowered jump
+       * instruction can't change any flags.
+       */
       this->block.min_strength = ir->is_break() ? strength_break : strength_continue;
+
+      /* The CONTAINED_JUMPS_LOWERED postcondition is already
+       * satisfied, because jump statements can't contain other
+       * statements.
+       */
    }
 
    virtual void visit(class ir_return * ir)
    {
+      /* Eliminate all instructions after each one, since they are
+       * unreachable.  This satisfies the DEAD_CODE_ELIMINATION
+       * postcondition.
+       */
       truncate_after_instruction(ir);
+
+      /* Set this->block.min_strength based on this instruction.  This
+       * satisfies the ANALYSIS postcondition.  It is not necessary to
+       * update this->block.may_clear_execute_flag or
+       * this->loop.may_set_return_flag, because an unlowered return
+       * instruction can't change any flags.
+       */
       this->block.min_strength = strength_return;
+
+      /* The CONTAINED_JUMPS_LOWERED postcondition is already
+       * satisfied, because jump statements can't contain other
+       * statements.
+       */
    }
 
    virtual void visit(class ir_discard * ir)
    {
+      /* Nothing needs to be done.  The ANALYSIS and
+       * DEAD_CODE_ELIMINATION postconditions are already satisfied,
+       * because discard statements are ignored by this optimization
+       * pass.  The CONTAINED_JUMPS_LOWERED postcondition is already
+       * satisfied, because discard statements can't contain other
+       * statements.
+       */
    }
 
    enum jump_strength get_jump_strength(ir_instruction* ir)
@@ -274,10 +480,8 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor {
          /* never lower return at the end of a this->function */
          if(this->function.nesting_depth == 0 && ir->get_next()->is_tail_sentinel())
             lower = false;
-         else if (this->function.is_main)
-            lower = lower_main_return;
          else
-            lower = lower_sub_return;
+            lower = this->function.lower_return;
          break;
       }
       return lower;
@@ -285,9 +489,20 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor {
 
    block_record visit_block(exec_list* list)
    {
+      /* Note: since visiting a node may change that node's next
+       * pointer, we can't use visit_exec_list(), because
+       * visit_exec_list() caches the node's next pointer before
+       * visiting it.  So we use foreach_list() instead.
+       *
+       * foreach_list() isn't safe if the node being visited gets
+       * removed, but fortunately this visitor doesn't do that.
+       */
+
       block_record saved_block = this->block;
       this->block = block_record();
-      visit_exec_list(list, this);
+      foreach_list(node, list) {
+         ((ir_instruction *) node)->accept(this);
+      }
       block_record ret = this->block;
       this->block = saved_block;
       return ret;
@@ -304,18 +519,34 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor {
       block_record block_records[2];
       ir_jump* jumps[2];
 
+      /* Recursively lower nested jumps.  This satisfies the
+       * CONTAINED_JUMPS_LOWERED postcondition, except in the case of
+       * unconditional jumps at the end of ir->then_instructions and
+       * ir->else_instructions, which are handled below.
+       */
       block_records[0] = visit_block(&ir->then_instructions);
       block_records[1] = visit_block(&ir->else_instructions);
 
 retry: /* we get here if we put code after the if inside a branch */
-   for(unsigned i = 0; i < 2; ++i) {
-      exec_list& list = i ? ir->else_instructions : ir->then_instructions;
-      jumps[i] = 0;
-      if(!list.is_empty() && get_jump_strength((ir_instruction*)list.get_tail()))
-         jumps[i] = (ir_jump*)list.get_tail();
-   }
 
+      /* Determine which of ir->then_instructions and
+       * ir->else_instructions end with an unconditional jump.
+       */
+      for(unsigned i = 0; i < 2; ++i) {
+         exec_list& list = i ? ir->else_instructions : ir->then_instructions;
+         jumps[i] = 0;
+         if(!list.is_empty() && get_jump_strength((ir_instruction*)list.get_tail()))
+            jumps[i] = (ir_jump*)list.get_tail();
+      }
+
+      /* Loop until we have satisfied the CONTAINED_JUMPS_LOWERED
+       * postcondition by lowering jumps in both then_instructions and
+       * else_instructions.
+       */
       for(;;) {
+         /* Determine the types of the jumps that terminate
+          * ir->then_instructions and ir->else_instructions.
+          */
          jump_strength jump_strengths[2];
 
          for(unsigned i = 0; i < 2; ++i) {
@@ -326,7 +557,12 @@ retry: /* we get here if we put code after the if inside a branch */
                jump_strengths[i] = strength_none;
          }
 
-         /* move both jumps out if possible */
+         /* If both code paths end in a jump, and the jumps are the
+          * same, and we are pulling out jumps, replace them with a
+          * single jump that comes after the if instruction.  The new
+          * jump will be visited next, and it will be lowered if
+          * necessary by the loop or conditional that encloses it.
+          */
          if(pull_out_jumps && jump_strengths[0] == jump_strengths[1]) {
             bool unify = true;
             if(jump_strengths[0] == strength_continue)
@@ -344,10 +580,19 @@ retry: /* we get here if we put code after the if inside a branch */
                jumps[1]->remove();
                this->progress = true;
 
+               /* Update jumps[] to reflect the fact that the jumps
+                * are gone, and update block_records[] to reflect the
+                * fact that control can now flow to the next
+                * instruction.
+                */
                jumps[0] = 0;
                jumps[1] = 0;
                block_records[0].min_strength = strength_none;
                block_records[1].min_strength = strength_none;
+
+               /* The CONTAINED_JUMPS_LOWERED postcondition is now
+                * satisfied, so we can break out of the loop.
+                */
                break;
             }
          }
@@ -367,50 +612,91 @@ retry: /* we get here if we put code after the if inside a branch */
          else if(should_lower[1])
             lower = 1;
          else
+            /* Neither code path ends in a jump that needs to be
+             * lowered, so the CONTAINED_JUMPS_LOWERED postcondition
+             * is satisfied and we can break out of the loop.
+             */
             break;
 
          if(jump_strengths[lower] == strength_return) {
-            ir_variable* return_flag = this->function.get_return_flag();
-            if(!this->function.signature->return_type->is_void()) {
-               ir_variable* return_value = this->function.get_return_value();
-               jumps[lower]->insert_before(new(ir) ir_assignment(new (ir) ir_dereference_variable(return_value), ((ir_return*)jumps[lower])->value, NULL));
-            }
-            jumps[lower]->insert_before(new(ir) ir_assignment(new (ir) ir_dereference_variable(return_flag), new (ir) ir_constant(true), NULL));
-            this->loop.may_set_return_flag = true;
+            /* To lower a return, we create a return flag (if the
+             * function doesn't have one already) and add instructions
+             * that: 1. store the return value (if this function has a
+             * non-void return) and 2. set the return flag
+             */
+            insert_lowered_return((ir_return*)jumps[lower]);
             if(this->loop.loop) {
+               /* If we are in a loop, replace the return instruction
+                * with a break instruction, and then loop so that the
+                * break instruction can be lowered if necessary.
+                */
                ir_loop_jump* lowered = 0;
                lowered = new(ir) ir_loop_jump(ir_loop_jump::jump_break);
+               /* Note: we must update block_records and jumps to
+                * reflect the fact that the control path has been
+                * altered from a return to a break.
+                */
                block_records[lower].min_strength = strength_break;
                jumps[lower]->replace_with(lowered);
                jumps[lower] = lowered;
-            } else
+            } else {
+               /* If we are not in a loop, we then proceed as we would
+                * for a continue statement (set the execute flag to
+                * false to prevent the rest of the function from
+                * executing).
+                */
                goto lower_continue;
+            }
             this->progress = true;
          } else if(jump_strengths[lower] == strength_break) {
-            /* We can't lower to an actual continue because that would execute the increment.
+            /* To lower a break, we create a break flag (if the loop
+             * doesn't have one already) and add an instruction that
+             * sets it.
              *
-             * In the lowered code, we instead put the break check between the this->loop body and the increment,
-             * which is impossible with a real continue as defined by the GLSL IR currently.
+             * Then we proceed as we would for a continue statement
+             * (set the execute flag to false to prevent the rest of
+             * the loop body from executing).
              *
-             * Smarter options (such as undoing the increment) are possible but it's not worth implementing them,
-             * because if break is lowered, continue is almost surely lowered too.
+             * The visit() function for the loop will ensure that the
+             * break flag is checked after executing the loop body.
              */
-            jumps[lower]->insert_before(new(ir) ir_assignment(new (ir) ir_dereference_variable(this->loop.get_break_flag()), new (ir) ir_constant(true), 0));
+            jumps[lower]->insert_before(create_lowered_break());
             goto lower_continue;
          } else if(jump_strengths[lower] == strength_continue) {
 lower_continue:
+            /* To lower a continue, we create an execute flag (if the
+             * loop doesn't have one already) and replace the continue
+             * with an instruction that clears it.
+             *
+             * Note that this code path gets exercised when lowering
+             * return statements that are not inside a loop, so
+             * this->loop must be initialized even outside of loops.
+             */
             ir_variable* execute_flag = this->loop.get_execute_flag();
             jumps[lower]->replace_with(new(ir) ir_assignment(new (ir) ir_dereference_variable(execute_flag), new (ir) ir_constant(false), 0));
+            /* Note: we must update block_records and jumps to reflect
+             * the fact that the control path has been altered to an
+             * instruction that clears the execute flag.
+             */
             jumps[lower] = 0;
             block_records[lower].min_strength = strength_always_clears_execute_flag;
             block_records[lower].may_clear_execute_flag = true;
             this->progress = true;
-            break;
+
+            /* Let the loop run again, in case the other branch of the
+             * if needs to be lowered too.
+             */
          }
       }
 
       /* move out a jump out if possible */
       if(pull_out_jumps) {
+         /* If one of the branches ends in a jump, and control cannot
+          * fall out the bottom of the other branch, then we can move
+          * the jump after the if.
+          *
+          * Set move_out to the branch we are moving a jump out of.
+          */
          int move_out = -1;
          if(jumps[0] && block_records[1].min_strength >= strength_continue)
             move_out = 0;
@@ -421,22 +707,46 @@ lower_continue:
          {
             jumps[move_out]->remove();
             ir->insert_after(jumps[move_out]);
+            /* Note: we must update block_records and jumps to reflect
+             * the fact that the jump has been moved out of the if.
+             */
             jumps[move_out] = 0;
             block_records[move_out].min_strength = strength_none;
             this->progress = true;
          }
       }
 
+      /* Now satisfy the ANALYSIS postcondition by setting
+       * this->block.min_strength and
+       * this->block.may_clear_execute_flag based on the
+       * characteristics of the two branches.
+       */
       if(block_records[0].min_strength < block_records[1].min_strength)
          this->block.min_strength = block_records[0].min_strength;
       else
          this->block.min_strength = block_records[1].min_strength;
       this->block.may_clear_execute_flag = this->block.may_clear_execute_flag || block_records[0].may_clear_execute_flag || block_records[1].may_clear_execute_flag;
 
+      /* Now we need to clean up the instructions that follow the
+       * if.
+       *
+       * If those instructions are unreachable, then satisfy the
+       * DEAD_CODE_ELIMINATION postcondition by eliminating them.
+       * Otherwise that postcondition is already satisfied.
+       */
       if(this->block.min_strength)
          truncate_after_instruction(ir);
       else if(this->block.may_clear_execute_flag)
       {
+         /* If the "if" instruction might clear the execute flag, then
+          * we need to guard any instructions that follow so that they
+          * are only executed if the execute flag is set.
+          *
+          * If one of the branches of the "if" always clears the
+          * execute flag, and the other branch never clears it, then
+          * this is easy: just move all the instructions following the
+          * "if" into the branch that never clears it.
+          */
          int move_into = -1;
          if(block_records[0].min_strength && !block_records[1].may_clear_execute_flag)
             move_into = 1;
@@ -451,14 +761,34 @@ lower_continue:
             if(!next->is_tail_sentinel()) {
                move_outer_block_inside(ir, list);
 
+               /* If any instructions moved, then we need to visit
+                * them (since they are now inside the "if").  Since
+                * block_records[move_into] is in its default state
+                * (see assertion above), we can safely replace
+                * block_records[move_into] with the result of this
+                * analysis.
+                */
                exec_list list;
                list.head = next;
                block_records[move_into] = visit_block(&list);
 
+               /*
+                * Then we need to re-start our jump lowering, since one
+                * of the instructions we moved might be a jump that
+                * needs to be lowered.
+                */
                this->progress = true;
                goto retry;
             }
          } else {
+            /* If we get here, then the simple case didn't apply; we
+             * need to actually guard the instructions that follow.
+             *
+             * To avoid creating unnecessarily-deep nesting, first
+             * look through the instructions that follow and unwrap
+             * any instructions that that are already wrapped in the
+             * appropriate guard.
+             */
             ir_instruction* ir_after;
             for(ir_after = (ir_instruction*)ir->get_next(); !ir_after->is_tail_sentinel();)
             {
@@ -479,6 +809,9 @@ lower_continue:
                this->progress = true;
             }
 
+            /* Then, wrap all the instructions that follow in a single
+             * guard.
+             */
             if(!ir->get_next()->is_tail_sentinel()) {
                assert(this->loop.execute_flag);
                ir_if* if_execute = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.execute_flag));
@@ -493,29 +826,111 @@ lower_continue:
 
    virtual void visit(ir_loop *ir)
    {
+      /* Visit the body of the loop, with a fresh data structure in
+       * this->loop so that the analysis we do here won't bleed into
+       * enclosing loops.
+       *
+       * We assume that all code after a loop is reachable from the
+       * loop (see comments on enum jump_strength), so the
+       * DEAD_CODE_ELIMINATION postcondition is automatically
+       * satisfied, as is the block.min_strength portion of the
+       * ANALYSIS postcondition.
+       *
+       * The block.may_clear_execute_flag portion of the ANALYSIS
+       * postcondition is automatically satisfied because execute
+       * flags do not propagate outside of loops.
+       *
+       * The loop.may_set_return_flag portion of the ANALYSIS
+       * postcondition is handled below.
+       */
       ++this->function.nesting_depth;
       loop_record saved_loop = this->loop;
       this->loop = loop_record(this->function.signature, ir);
 
+      /* Recursively lower nested jumps.  This satisfies the
+       * CONTAINED_JUMPS_LOWERED postcondition, except in the case of
+       * an unconditional continue or return at the bottom of the
+       * loop, which are handled below.
+       */
       block_record body = visit_block(&ir->body_instructions);
 
+      /* If the loop ends in an unconditional continue, eliminate it
+       * because it is redundant.
+       */
+      ir_instruction *ir_last
+         = (ir_instruction *) ir->body_instructions.get_tail();
+      if (get_jump_strength(ir_last) == strength_continue) {
+         ir_last->remove();
+      }
+
+      /* If the loop ends in an unconditional return, and we are
+       * lowering returns, lower it.
+       */
+      if (this->function.lower_return)
+         lower_return_unconditionally(ir_last);
+
       if(body.min_strength >= strength_break) {
-         /* FINISHME: turn the this->loop into an if, or replace it with its body */
+         /* FINISHME: If the min_strength of the loop body is
+          * strength_break or strength_return, that means that it
+          * isn't a loop at all, since control flow always leaves the
+          * body of the loop via break or return.  In principle the
+          * loop could be eliminated in this case.  This optimization
+          * is not implemented yet.
+          */
       }
 
       if(this->loop.break_flag) {
+         /* We only get here if we are lowering breaks */
+         assert (lower_break);
+
+         /* If a break flag was generated while visiting the body of
+          * the loop, then at least one break was lowered, so we need
+          * to generate an if statement at the end of the loop that
+          * does a "break" if the break flag is set.  The break we
+          * generate won't violate the CONTAINED_JUMPS_LOWERED
+          * postcondition, because should_lower_jump() always returns
+          * false for a break that happens at the end of a loop.
+          *
+          * However, if the loop already ends in a conditional or
+          * unconditional break, then we need to lower that break,
+          * because it won't be at the end of the loop anymore.
+          */
+         lower_final_breaks(&ir->body_instructions);
+
          ir_if* break_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.break_flag));
          break_if->then_instructions.push_tail(new(ir) ir_loop_jump(ir_loop_jump::jump_break));
          ir->body_instructions.push_tail(break_if);
       }
 
+      /* If the body of the loop may set the return flag, then at
+       * least one return was lowered to a break, so we need to ensure
+       * that the return flag is checked after the body of the loop is
+       * executed.
+       */
       if(this->loop.may_set_return_flag) {
          assert(this->function.return_flag);
+         /* Generate the if statement to check the return flag */
          ir_if* return_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->function.return_flag));
+         /* Note: we also need to propagate the knowledge that the
+          * return flag may get set to the outer context.  This
+          * satisfies the loop.may_set_return_flag part of the
+          * ANALYSIS postcondition.
+          */
          saved_loop.may_set_return_flag = true;
          if(saved_loop.loop)
+            /* If this loop is nested inside another one, then the if
+             * statement that we generated should break out of that
+             * loop if the return flag is set.  Caller will lower that
+             * break statement if necessary.
+             */
             return_if->then_instructions.push_tail(new(ir) ir_loop_jump(ir_loop_jump::jump_break));
          else
+            /* Otherwise, all we need to do is ensure that the
+             * instructions that follow are only executed if the
+             * return flag is clear.  We can do that by moving those
+             * instructions into the else clause of the generated if
+             * statement.
+             */
             move_outer_block_inside(ir, &return_if->else_instructions);
          ir->insert_after(return_if);
       }
@@ -530,14 +945,39 @@ lower_continue:
       assert(!this->function.signature);
       assert(!this->loop.loop);
 
+      bool lower_return;
+      if (strcmp(ir->function_name(), "main") == 0)
+         lower_return = lower_main_return;
+      else
+         lower_return = lower_sub_return;
+
       function_record saved_function = this->function;
       loop_record saved_loop = this->loop;
-      this->function = function_record(ir);
+      this->function = function_record(ir, lower_return);
       this->loop = loop_record(ir);
 
       assert(!this->loop.loop);
+
+      /* Visit the body of the function to lower any jumps that occur
+       * in it, except possibly an unconditional return statement at
+       * the end of it.
+       */
       visit_block(&ir->body);
 
+      /* If the body ended in an unconditional return of non-void,
+       * then we don't need to lower it because it's the one canonical
+       * return.
+       *
+       * If the body ended in a return of void, eliminate it because
+       * it is redundant.
+       */
+      if (ir->return_type->is_void() &&
+          get_jump_strength((ir_instruction *) ir->body.get_tail())) {
+         ir_jump *jump = (ir_jump *) ir->body.get_tail();
+         assert (jump->ir_type == ir_type_return);
+         jump->remove();
+      }
+
       if(this->function.return_value)
          ir->body.push_tail(new(ir) ir_return(new (ir) ir_dereference_variable(this->function.return_value)));
 
index 8cbbfa7..a371afc 100644 (file)
@@ -45,19 +45,19 @@ public:
 
    ir_visitor_status visit_leave(ir_assignment *);
 
-   ir_dereference *get_column(ir_variable *var, int col);
-   ir_rvalue *get_element(ir_variable *var, int col, int row);
-
-   void do_mul_mat_mat(ir_variable *result_var,
-                      ir_variable *a_var, ir_variable *b_var);
-   void do_mul_mat_vec(ir_variable *result_var,
-                      ir_variable *a_var, ir_variable *b_var);
-   void do_mul_vec_mat(ir_variable *result_var,
-                      ir_variable *a_var, ir_variable *b_var);
-   void do_mul_mat_scalar(ir_variable *result_var,
-                         ir_variable *a_var, ir_variable *b_var);
-   void do_equal_mat_mat(ir_variable *result_var, ir_variable *a_var,
-                        ir_variable *b_var, bool test_equal);
+   ir_dereference *get_column(ir_dereference *val, int col);
+   ir_rvalue *get_element(ir_dereference *val, int col, int row);
+
+   void do_mul_mat_mat(ir_dereference *result,
+                      ir_dereference *a, ir_dereference *b);
+   void do_mul_mat_vec(ir_dereference *result,
+                      ir_dereference *a, ir_dereference *b);
+   void do_mul_vec_mat(ir_dereference *result,
+                      ir_dereference *a, ir_dereference *b);
+   void do_mul_mat_scalar(ir_dereference *result,
+                         ir_dereference *a, ir_dereference *b);
+   void do_equal_mat_mat(ir_dereference *result, ir_dereference *a,
+                        ir_dereference *b, bool test_equal);
 
    void *mem_ctx;
    bool made_progress;
@@ -97,182 +97,137 @@ do_mat_op_to_vec(exec_list *instructions)
 }
 
 ir_rvalue *
-ir_mat_op_to_vec_visitor::get_element(ir_variable *var, int col, int row)
+ir_mat_op_to_vec_visitor::get_element(ir_dereference *val, int col, int row)
 {
-   ir_dereference *deref;
+   val = get_column(val, col);
 
-   deref = new(mem_ctx) ir_dereference_variable(var);
-
-   if (var->type->is_matrix()) {
-      deref = new(mem_ctx) ir_dereference_array(var,
-                                               new(mem_ctx) ir_constant(col));
-   } else {
-      assert(col == 0);
-   }
-
-   return new(mem_ctx) ir_swizzle(deref, row, 0, 0, 0, 1);
+   return new(mem_ctx) ir_swizzle(val, row, 0, 0, 0, 1);
 }
 
 ir_dereference *
-ir_mat_op_to_vec_visitor::get_column(ir_variable *var, int row)
+ir_mat_op_to_vec_visitor::get_column(ir_dereference *val, int row)
 {
-   ir_dereference *deref;
-
-   if (!var->type->is_matrix()) {
-      deref = new(mem_ctx) ir_dereference_variable(var);
-   } else {
-      deref = new(mem_ctx) ir_dereference_variable(var);
-      deref = new(mem_ctx) ir_dereference_array(deref,
-                                               new(mem_ctx) ir_constant(row));
+   val = val->clone(mem_ctx, NULL);
+
+   if (val->type->is_matrix()) {
+      val = new(mem_ctx) ir_dereference_array(val,
+                                             new(mem_ctx) ir_constant(row));
    }
 
-   return deref;
+   return val;
 }
 
 void
-ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_variable *result_var,
-                                        ir_variable *a_var,
-                                        ir_variable *b_var)
+ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_dereference *result,
+                                        ir_dereference *a,
+                                        ir_dereference *b)
 {
    int b_col, i;
    ir_assignment *assign;
    ir_expression *expr;
 
-   for (b_col = 0; b_col < b_var->type->matrix_columns; b_col++) {
-      ir_rvalue *a = get_column(a_var, 0);
-      ir_rvalue *b = get_element(b_var, b_col, 0);
-
+   for (b_col = 0; b_col < b->type->matrix_columns; b_col++) {
       /* first column */
       expr = new(mem_ctx) ir_expression(ir_binop_mul,
-                                       a->type,
-                                       a,
-                                       b);
+                                       get_column(a, 0),
+                                       get_element(b, b_col, 0));
 
       /* following columns */
-      for (i = 1; i < a_var->type->matrix_columns; i++) {
+      for (i = 1; i < a->type->matrix_columns; i++) {
         ir_expression *mul_expr;
 
-        a = get_column(a_var, i);
-        b = get_element(b_var, b_col, i);
-
         mul_expr = new(mem_ctx) ir_expression(ir_binop_mul,
-                                              a->type,
-                                              a,
-                                              b);
+                                              get_column(a, i),
+                                              get_element(b, b_col, i));
         expr = new(mem_ctx) ir_expression(ir_binop_add,
-                                          a->type,
                                           expr,
                                           mul_expr);
       }
 
-      ir_rvalue *result = get_column(result_var, b_col);
-      assign = new(mem_ctx) ir_assignment(result,
-                                         expr,
-                                         NULL);
+      assign = new(mem_ctx) ir_assignment(get_column(result, b_col), expr);
       base_ir->insert_before(assign);
    }
 }
 
 void
-ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_variable *result_var,
-                                        ir_variable *a_var,
-                                        ir_variable *b_var)
+ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_dereference *result,
+                                        ir_dereference *a,
+                                        ir_dereference *b)
 {
    int i;
-   ir_rvalue *a = get_column(a_var, 0);
-   ir_rvalue *b = get_element(b_var, 0, 0);
    ir_assignment *assign;
    ir_expression *expr;
 
    /* first column */
    expr = new(mem_ctx) ir_expression(ir_binop_mul,
-                                    result_var->type,
-                                    a,
-                                    b);
+                                    get_column(a, 0),
+                                    get_element(b, 0, 0));
 
    /* following columns */
-   for (i = 1; i < a_var->type->matrix_columns; i++) {
+   for (i = 1; i < a->type->matrix_columns; i++) {
       ir_expression *mul_expr;
 
-      a = get_column(a_var, i);
-      b = get_element(b_var, 0, i);
-
       mul_expr = new(mem_ctx) ir_expression(ir_binop_mul,
-                                           result_var->type,
-                                           a,
-                                           b);
-      expr = new(mem_ctx) ir_expression(ir_binop_add,
-                                       result_var->type,
-                                       expr,
-                                       mul_expr);
+                                           get_column(a, i),
+                                           get_element(b, 0, i));
+      expr = new(mem_ctx) ir_expression(ir_binop_add, expr, mul_expr);
    }
 
-   ir_rvalue *result = new(mem_ctx) ir_dereference_variable(result_var);
-   assign = new(mem_ctx) ir_assignment(result,
-                                      expr,
-                                      NULL);
+   result = result->clone(mem_ctx, NULL);
+   assign = new(mem_ctx) ir_assignment(result, expr);
    base_ir->insert_before(assign);
 }
 
 void
-ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_variable *result_var,
-                                        ir_variable *a_var,
-                                        ir_variable *b_var)
+ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_dereference *result,
+                                        ir_dereference *a,
+                                        ir_dereference *b)
 {
    int i;
 
-   for (i = 0; i < b_var->type->matrix_columns; i++) {
-      ir_rvalue *a = new(mem_ctx) ir_dereference_variable(a_var);
-      ir_rvalue *b = get_column(b_var, i);
-      ir_rvalue *result;
+   for (i = 0; i < b->type->matrix_columns; i++) {
+      ir_rvalue *column_result;
       ir_expression *column_expr;
       ir_assignment *column_assign;
 
-      result = new(mem_ctx) ir_dereference_variable(result_var);
-      result = new(mem_ctx) ir_swizzle(result, i, 0, 0, 0, 1);
+      column_result = result->clone(mem_ctx, NULL);
+      column_result = new(mem_ctx) ir_swizzle(column_result, i, 0, 0, 0, 1);
 
       column_expr = new(mem_ctx) ir_expression(ir_binop_dot,
-                                              result->type,
-                                              a,
-                                              b);
+                                              a->clone(mem_ctx, NULL),
+                                              get_column(b, i));
 
-      column_assign = new(mem_ctx) ir_assignment(result,
-                                                column_expr,
-                                                NULL);
+      column_assign = new(mem_ctx) ir_assignment(column_result,
+                                                column_expr);
       base_ir->insert_before(column_assign);
    }
 }
 
 void
-ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_variable *result_var,
-                                           ir_variable *a_var,
-                                           ir_variable *b_var)
+ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_dereference *result,
+                                           ir_dereference *a,
+                                           ir_dereference *b)
 {
    int i;
 
-   for (i = 0; i < a_var->type->matrix_columns; i++) {
-      ir_rvalue *a = get_column(a_var, i);
-      ir_rvalue *b = new(mem_ctx) ir_dereference_variable(b_var);
-      ir_rvalue *result = get_column(result_var, i);
+   for (i = 0; i < a->type->matrix_columns; i++) {
       ir_expression *column_expr;
       ir_assignment *column_assign;
 
       column_expr = new(mem_ctx) ir_expression(ir_binop_mul,
-                                              result->type,
-                                              a,
-                                              b);
+                                              get_column(a, i),
+                                              b->clone(mem_ctx, NULL));
 
-      column_assign = new(mem_ctx) ir_assignment(result,
-                                                column_expr,
-                                                NULL);
+      column_assign = new(mem_ctx) ir_assignment(get_column(result, i),
+                                                column_expr);
       base_ir->insert_before(column_assign);
    }
 }
 
 void
-ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_variable *result_var,
-                                          ir_variable *a_var,
-                                          ir_variable *b_var,
+ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_dereference *result,
+                                          ir_dereference *a,
+                                          ir_dereference *b,
                                           bool test_equal)
 {
    /* This essentially implements the following GLSL:
@@ -293,7 +248,7 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_variable *result_var,
     *                    a[3] != b[3]);
     * }
     */
-   const unsigned columns = a_var->type->matrix_columns;
+   const unsigned columns = a->type->matrix_columns;
    const glsl_type *const bvec_type =
       glsl_type::get_instance(GLSL_TYPE_BOOL, columns, 1);
 
@@ -303,12 +258,10 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_variable *result_var,
    this->base_ir->insert_before(tmp_bvec);
 
    for (unsigned i = 0; i < columns; i++) {
-      ir_dereference *const op0 = get_column(a_var, i);
-      ir_dereference *const op1 = get_column(b_var, i);
-
       ir_expression *const cmp =
         new(this->mem_ctx) ir_expression(ir_binop_any_nequal,
-                                         glsl_type::bool_type, op0, op1);
+                                         get_column(a, i),
+                                         get_column(b, i));
 
       ir_dereference *const lhs =
         new(this->mem_ctx) ir_dereference_variable(tmp_bvec);
@@ -319,23 +272,14 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_variable *result_var,
       this->base_ir->insert_before(assign);
    }
 
-   ir_rvalue *const val =
-      new(this->mem_ctx) ir_dereference_variable(tmp_bvec);
-
-   ir_expression *any =
-      new(this->mem_ctx) ir_expression(ir_unop_any, glsl_type::bool_type,
-                                      val, NULL);
+   ir_rvalue *const val = new(this->mem_ctx) ir_dereference_variable(tmp_bvec);
+   ir_expression *any = new(this->mem_ctx) ir_expression(ir_unop_any, val);
 
    if (test_equal)
-      any = new(this->mem_ctx) ir_expression(ir_unop_logic_not,
-                                            glsl_type::bool_type,
-                                            any, NULL);
-
-   ir_rvalue *const result =
-      new(this->mem_ctx) ir_dereference_variable(result_var);
+      any = new(this->mem_ctx) ir_expression(ir_unop_logic_not, any);
 
    ir_assignment *const assign =
-        new(mem_ctx) ir_assignment(result, any, NULL);
+      new(mem_ctx) ir_assignment(result->clone(mem_ctx, NULL), any);
    base_ir->insert_before(assign);
 }
 
@@ -358,7 +302,7 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
 {
    ir_expression *orig_expr = orig_assign->rhs->as_expression();
    unsigned int i, matrix_columns = 1;
-   ir_variable *op_var[2];
+   ir_dereference *op[2];
 
    if (!orig_expr)
       return visit_continue;
@@ -370,51 +314,53 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
 
    mem_ctx = ralloc_parent(orig_assign);
 
-   ir_dereference_variable *lhs_deref =
+   ir_dereference_variable *result =
       orig_assign->lhs->as_dereference_variable();
-   assert(lhs_deref);
-
-   ir_variable *result_var = lhs_deref->var;
+   assert(result);
 
    /* Store the expression operands in temps so we can use them
     * multiple times.
     */
    for (i = 0; i < orig_expr->get_num_operands(); i++) {
       ir_assignment *assign;
+      ir_dereference *deref = orig_expr->operands[i]->as_dereference();
 
-      op_var[i] = new(mem_ctx) ir_variable(orig_expr->operands[i]->type,
-                                          "mat_op_to_vec",
-                                          ir_var_temporary);
-      base_ir->insert_before(op_var[i]);
+      /* Avoid making a temporary if we don't need to to avoid aliasing. */
+      if (deref &&
+         deref->variable_referenced() != result->variable_referenced()) {
+        op[i] = deref;
+        continue;
+      }
 
-      lhs_deref = new(mem_ctx) ir_dereference_variable(op_var[i]);
-      assign = new(mem_ctx) ir_assignment(lhs_deref,
-                                         orig_expr->operands[i],
-                                         NULL);
+      /* Otherwise, store the operand in a temporary generally if it's
+       * not a dereference.
+       */
+      ir_variable *var = new(mem_ctx) ir_variable(orig_expr->operands[i]->type,
+                                                 "mat_op_to_vec",
+                                                 ir_var_temporary);
+      base_ir->insert_before(var);
+
+      /* Note that we use this dereference for the assignment.  That means
+       * that others that want to use op[i] have to clone the deref.
+       */
+      op[i] = new(mem_ctx) ir_dereference_variable(var);
+      assign = new(mem_ctx) ir_assignment(op[i], orig_expr->operands[i]);
       base_ir->insert_before(assign);
    }
 
    /* OK, time to break down this matrix operation. */
    switch (orig_expr->operation) {
    case ir_unop_neg: {
-      const unsigned mask = (1U << result_var->type->vector_elements) - 1;
-
       /* Apply the operation to each column.*/
       for (i = 0; i < matrix_columns; i++) {
-        ir_rvalue *op0 = get_column(op_var[0], i);
-        ir_dereference *result = get_column(result_var, i);
         ir_expression *column_expr;
         ir_assignment *column_assign;
 
         column_expr = new(mem_ctx) ir_expression(orig_expr->operation,
-                                                 result->type,
-                                                 op0,
-                                                 NULL);
-
-        column_assign = new(mem_ctx) ir_assignment(result,
-                                                   column_expr,
-                                                   NULL,
-                                                   mask);
+                                                 get_column(op[0], i));
+
+        column_assign = new(mem_ctx) ir_assignment(get_column(result, i),
+                                                   column_expr);
         assert(column_assign->write_mask != 0);
         base_ir->insert_before(column_assign);
       }
@@ -424,57 +370,49 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
    case ir_binop_sub:
    case ir_binop_div:
    case ir_binop_mod: {
-      const unsigned mask = (1U << result_var->type->vector_elements) - 1;
-
       /* For most operations, the matrix version is just going
        * column-wise through and applying the operation to each column
        * if available.
        */
       for (i = 0; i < matrix_columns; i++) {
-        ir_rvalue *op0 = get_column(op_var[0], i);
-        ir_rvalue *op1 = get_column(op_var[1], i);
-        ir_dereference *result = get_column(result_var, i);
         ir_expression *column_expr;
         ir_assignment *column_assign;
 
         column_expr = new(mem_ctx) ir_expression(orig_expr->operation,
-                                                 result->type,
-                                                 op0,
-                                                 op1);
-
-        column_assign = new(mem_ctx) ir_assignment(result,
-                                                   column_expr,
-                                                   NULL,
-                                                   mask);
+                                                 get_column(op[0], i),
+                                                 get_column(op[1], i));
+
+        column_assign = new(mem_ctx) ir_assignment(get_column(result, i),
+                                                   column_expr);
         assert(column_assign->write_mask != 0);
         base_ir->insert_before(column_assign);
       }
       break;
    }
    case ir_binop_mul:
-      if (op_var[0]->type->is_matrix()) {
-        if (op_var[1]->type->is_matrix()) {
-           do_mul_mat_mat(result_var, op_var[0], op_var[1]);
-        } else if (op_var[1]->type->is_vector()) {
-           do_mul_mat_vec(result_var, op_var[0], op_var[1]);
+      if (op[0]->type->is_matrix()) {
+        if (op[1]->type->is_matrix()) {
+           do_mul_mat_mat(result, op[0], op[1]);
+        } else if (op[1]->type->is_vector()) {
+           do_mul_mat_vec(result, op[0], op[1]);
         } else {
-           assert(op_var[1]->type->is_scalar());
-           do_mul_mat_scalar(result_var, op_var[0], op_var[1]);
+           assert(op[1]->type->is_scalar());
+           do_mul_mat_scalar(result, op[0], op[1]);
         }
       } else {
-        assert(op_var[1]->type->is_matrix());
-        if (op_var[0]->type->is_vector()) {
-           do_mul_vec_mat(result_var, op_var[0], op_var[1]);
+        assert(op[1]->type->is_matrix());
+        if (op[0]->type->is_vector()) {
+           do_mul_vec_mat(result, op[0], op[1]);
         } else {
-           assert(op_var[0]->type->is_scalar());
-           do_mul_mat_scalar(result_var, op_var[1], op_var[0]);
+           assert(op[0]->type->is_scalar());
+           do_mul_mat_scalar(result, op[1], op[0]);
         }
       }
       break;
 
    case ir_binop_all_equal:
    case ir_binop_any_nequal:
-      do_equal_mat_mat(result_var, op_var[1], op_var[0],
+      do_equal_mat_mat(result, op[1], op[0],
                       (orig_expr->operation == ir_binop_all_equal));
       break;
 
index 8eb1612..f8e4a1d 100644 (file)
  *
  * Pre-DX10 GPUs often don't have a native way to do this operation,
  * and this works around that.
+ *
+ * The lowering process proceeds as follows.  Each non-constant index
+ * found in an r-value is converted to a canonical form \c array[i].  Each
+ * element of the array is conditionally assigned to a temporary by comparing
+ * \c i to a constant index.  This is done by cloning the canonical form and
+ * replacing all occurances of \c i with a constant.  Each remaining occurance
+ * of the canonical form in the IR is replaced with a dereference of the
+ * temporary variable.
+ *
+ * L-values with non-constant indices are handled similarly.  In this case,
+ * the RHS of the assignment is assigned to a temporary.  The non-constant
+ * index is replace with the canonical form (just like for r-values).  The
+ * temporary is conditionally assigned to each element of the canonical form
+ * by comparing \c i with each index.  The same clone-and-replace scheme is
+ * used.
  */
 
 #include "ir.h"
 #include "glsl_types.h"
 #include "main/macros.h"
 
+/**
+ * Generate a comparison value for a block of indices
+ *
+ * Lowering passes for non-constant indexing of arrays, matrices, or vectors
+ * can use this to generate blocks of index comparison values.
+ *
+ * \param instructions  List where new instructions will be appended
+ * \param index         \c ir_variable containing the desired index
+ * \param base          Base value for this block of comparisons
+ * \param components    Number of unique index values to compare.  This must
+ *                      be on the range [1, 4].
+ * \param mem_ctx       ralloc memory context to be used for all allocations.
+ *
+ * \returns
+ * An \c ir_rvalue that \b must be cloned for each use in conditional
+ * assignments, etc.
+ */
+ir_rvalue *
+compare_index_block(exec_list *instructions, ir_variable *index,
+                   unsigned base, unsigned components, void *mem_ctx)
+{
+   ir_rvalue *broadcast_index = new(mem_ctx) ir_dereference_variable(index);
+
+   assert(index->type->is_scalar());
+   assert(index->type->base_type == GLSL_TYPE_INT);
+   assert(components >= 1 && components <= 4);
+
+   if (components > 1) {
+      const ir_swizzle_mask m = { 0, 0, 0, 0, components, false };
+      broadcast_index = new(mem_ctx) ir_swizzle(broadcast_index, m);
+   }
+
+   /* Compare the desired index value with the next block of four indices.
+    */
+   ir_constant_data test_indices_data;
+   memset(&test_indices_data, 0, sizeof(test_indices_data));
+   test_indices_data.i[0] = base;
+   test_indices_data.i[1] = base + 1;
+   test_indices_data.i[2] = base + 2;
+   test_indices_data.i[3] = base + 3;
+
+   ir_constant *const test_indices =
+      new(mem_ctx) ir_constant(broadcast_index->type,
+                              &test_indices_data);
+
+   ir_rvalue *const condition_val =
+      new(mem_ctx) ir_expression(ir_binop_equal,
+                                &glsl_type::bool_type[components - 1],
+                                broadcast_index,
+                                test_indices);
+
+   ir_variable *const condition =
+      new(mem_ctx) ir_variable(condition_val->type,
+                              "dereference_condition",
+                              ir_var_temporary);
+   instructions->push_tail(condition);
+
+   ir_rvalue *const cond_deref =
+      new(mem_ctx) ir_dereference_variable(condition);
+   instructions->push_tail(new(mem_ctx) ir_assignment(cond_deref, condition_val, 0));
+
+   return cond_deref;
+}
+
+static inline bool
+is_array_or_matrix(const ir_instruction *ir)
+{
+   return (ir->type->is_array() || ir->type->is_matrix());
+}
+
+/**
+ * Replace a dereference of a variable with a specified r-value
+ *
+ * Each time a dereference of the specified value is replaced, the r-value
+ * tree is cloned.
+ */
+class deref_replacer : public ir_rvalue_visitor {
+public:
+   deref_replacer(const ir_variable *variable_to_replace, ir_rvalue *value)
+      : variable_to_replace(variable_to_replace), value(value),
+       progress(false)
+   {
+      assert(this->variable_to_replace != NULL);
+      assert(this->value != NULL);
+   }
+
+   virtual void handle_rvalue(ir_rvalue **rvalue)
+   {
+      ir_dereference_variable *const dv = (*rvalue)->as_dereference_variable();
+
+      if ((dv != NULL) && (dv->var == this->variable_to_replace)) {
+        this->progress = true;
+        *rvalue = this->value->clone(ralloc_parent(*rvalue), NULL);
+      }
+   }
+
+   const ir_variable *variable_to_replace;
+   ir_rvalue *value;
+   bool progress;
+};
+
+/**
+ * Find a variable index dereference of an array in an rvalue tree
+ */
+class find_variable_index : public ir_hierarchical_visitor {
+public:
+   find_variable_index()
+      : deref(NULL)
+   {
+      /* empty */
+   }
+
+   virtual ir_visitor_status visit_enter(ir_dereference_array *ir)
+   {
+      if (is_array_or_matrix(ir->array)
+         && (ir->array_index->as_constant() == NULL)) {
+        this->deref = ir;
+        return visit_stop;
+      }
+
+      return visit_continue;
+   }
+
+   /**
+    * First array dereference found in the tree that has a non-constant index.
+    */
+   ir_dereference_array *deref;
+};
+
 struct assignment_generator
 {
    ir_instruction* base_ir;
-   ir_rvalue* array;
+   ir_dereference *rvalue;
+   ir_variable *old_index;
    bool is_write;
    unsigned int write_mask;
    ir_variable* var;
@@ -55,18 +200,23 @@ struct assignment_generator
        * underlying variable.
        */
       void *mem_ctx = ralloc_parent(base_ir);
-      ir_dereference *element =
-        new(mem_ctx) ir_dereference_array(this->array->clone(mem_ctx, NULL),
-                                          new(mem_ctx) ir_constant(i));
-      ir_rvalue *variable = new(mem_ctx) ir_dereference_variable(this->var);
 
-      ir_assignment *assignment;
-      if (is_write) {
-        assignment = new(mem_ctx) ir_assignment(element, variable, condition,
-                                                write_mask);
-      } else {
-        assignment = new(mem_ctx) ir_assignment(variable, element, condition);
-      }
+      /* Clone the old r-value in its entirety.  Then replace any occurances of
+       * the old variable index with the new constant index.
+       */
+      ir_dereference *element = this->rvalue->clone(mem_ctx, NULL);
+      ir_constant *const index = new(mem_ctx) ir_constant(i);
+      deref_replacer r(this->old_index, index);
+      element->accept(&r);
+      assert(r.progress);
+
+      /* Generate a conditional assignment to (or from) the constant indexed
+       * array dereference.
+       */
+      ir_rvalue *variable = new(mem_ctx) ir_dereference_variable(this->var);
+      ir_assignment *const assignment = (is_write)
+        ? new(mem_ctx) ir_assignment(element, variable, condition, write_mask)
+        : new(mem_ctx) ir_assignment(variable, element, condition);
 
       list->push_tail(assignment);
    }
@@ -118,54 +268,17 @@ struct switch_generator
       for (unsigned i = first; i < end; i += 4) {
          const unsigned comps = MIN2(condition_components, end - i);
 
-         ir_rvalue *broadcast_index =
-           new(this->mem_ctx) ir_dereference_variable(index);
-
-         if (comps) {
-           const ir_swizzle_mask m = { 0, 0, 0, 0, comps, false };
-           broadcast_index = new(this->mem_ctx) ir_swizzle(broadcast_index, m);
-        }
-
-        /* Compare the desired index value with the next block of four indices.
-         */
-         ir_constant_data test_indices_data;
-         memset(&test_indices_data, 0, sizeof(test_indices_data));
-         test_indices_data.i[0] = i;
-         test_indices_data.i[1] = i + 1;
-         test_indices_data.i[2] = i + 2;
-         test_indices_data.i[3] = i + 3;
-         ir_constant *const test_indices =
-           new(this->mem_ctx) ir_constant(broadcast_index->type,
-                                          &test_indices_data);
-
-         ir_rvalue *const condition_val =
-           new(this->mem_ctx) ir_expression(ir_binop_equal,
-                                            &glsl_type::bool_type[comps - 1],
-                                            broadcast_index,
-                                            test_indices);
-
-         ir_variable *const condition =
-           new(this->mem_ctx) ir_variable(condition_val->type,
-                                          "dereference_array_condition",
-                                          ir_var_temporary);
-         list->push_tail(condition);
-
         ir_rvalue *const cond_deref =
-           new(this->mem_ctx) ir_dereference_variable(condition);
-         list->push_tail(new(this->mem_ctx) ir_assignment(cond_deref,
-                                                         condition_val, 0));
+           compare_index_block(list, index, i, comps, this->mem_ctx);
 
          if (comps == 1) {
-           ir_rvalue *const cond_deref =
-              new(this->mem_ctx) ir_dereference_variable(condition);
-
-            this->generator.generate(i, cond_deref, list);
+            this->generator.generate(i, cond_deref->clone(this->mem_ctx, NULL),
+                                    list);
          } else {
             for (unsigned j = 0; j < comps; j++) {
-              ir_rvalue *const cond_deref =
-                 new(this->mem_ctx) ir_dereference_variable(condition);
               ir_rvalue *const cond_swiz =
-                 new(this->mem_ctx) ir_swizzle(cond_deref, j, 0, 0, 0, 1);
+                 new(this->mem_ctx) ir_swizzle(cond_deref->clone(this->mem_ctx, NULL),
+                                               j, 0, 0, 0, 1);
 
                this->generator.generate(i + j, cond_swiz, list);
             }
@@ -233,21 +346,18 @@ public:
    bool lower_temps;
    bool lower_uniforms;
 
-   bool is_array_or_matrix(const ir_instruction *ir) const
-   {
-      return (ir->type->is_array() || ir->type->is_matrix());
-   }
-
-   bool needs_lowering(ir_dereference_array *deref) const
+   bool storage_type_needs_lowering(ir_dereference_array *deref) const
    {
-      if (deref == NULL || deref->array_index->as_constant()
-         || !is_array_or_matrix(deref->array))
-        return false;
-
-      if (deref->array->ir_type == ir_type_constant)
+      /* If a variable isn't eventually the target of this dereference, then
+       * it must be a constant or some sort of anonymous temporary storage.
+       *
+       * FINISHME: Is this correct?  Most drivers treat arrays of constants as
+       * FINISHME: uniforms.  It seems like this should do the same.
+       */
+      const ir_variable *const var = deref->array->variable_referenced();
+      if (var == NULL)
         return this->lower_temps;
 
-      const ir_variable *const var = deref->array->variable_referenced();
       switch (var->mode) {
       case ir_var_auto:
       case ir_var_temporary:
@@ -267,8 +377,18 @@ public:
       return false;
    }
 
+   bool needs_lowering(ir_dereference_array *deref) const
+   {
+      if (deref == NULL || deref->array_index->as_constant()
+         || !is_array_or_matrix(deref->array))
+        return false;
+
+      return this->storage_type_needs_lowering(deref);
+   }
+
    ir_variable *convert_dereference_array(ir_dereference_array *orig_deref,
-                                         ir_assignment* orig_assign)
+                                         ir_assignment* orig_assign,
+                                         ir_dereference *orig_base)
    {
       assert(is_array_or_matrix(orig_deref->array));
 
@@ -314,9 +434,12 @@ public:
         new(mem_ctx) ir_assignment(lhs, orig_deref->array_index, NULL);
       base_ir->insert_before(assign);
 
+      orig_deref->array_index = lhs->clone(mem_ctx, NULL);
+
       assignment_generator ag;
-      ag.array = orig_deref->array;
+      ag.rvalue = orig_base;
       ag.base_ir = base_ir;
+      ag.old_index = index;
       ag.var = var;
       if (orig_assign) {
         ag.is_write = true;
@@ -327,21 +450,40 @@ public:
 
       switch_generator sg(ag, index, 4, 4);
 
-      exec_list list;
-      sg.generate(0, length, &list);
-      base_ir->insert_before(&list);
+      /* If the original assignment has a condition, respect that original
+       * condition!  This is acomplished by wrapping the new conditional
+       * assignments in an if-statement that uses the original condition.
+       */
+      if ((orig_assign != NULL) && (orig_assign->condition != NULL)) {
+        /* No need to clone the condition because the IR that it hangs on is
+         * going to be removed from the instruction sequence.
+         */
+        ir_if *if_stmt = new(mem_ctx) ir_if(orig_assign->condition);
+
+        sg.generate(0, length, &if_stmt->then_instructions);
+        base_ir->insert_before(if_stmt);
+      } else {
+        exec_list list;
+
+        sg.generate(0, length, &list);
+        base_ir->insert_before(&list);
+      }
 
       return var;
    }
 
    virtual void handle_rvalue(ir_rvalue **pir)
    {
+      if (this->in_assignee)
+        return;
+
       if (!*pir)
          return;
 
       ir_dereference_array* orig_deref = (*pir)->as_dereference_array();
       if (needs_lowering(orig_deref)) {
-         ir_variable* var = convert_dereference_array(orig_deref, 0);
+         ir_variable *var =
+           convert_dereference_array(orig_deref, NULL, orig_deref);
          assert(var);
          *pir = new(ralloc_parent(base_ir)) ir_dereference_variable(var);
          this->progress = true;
@@ -353,10 +495,11 @@ public:
    {
       ir_rvalue_visitor::visit_leave(ir);
 
-      ir_dereference_array *orig_deref = ir->lhs->as_dereference_array();
+      find_variable_index f;
+      ir->lhs->accept(&f);
 
-      if (needs_lowering(orig_deref)) {
-         convert_dereference_array(orig_deref, ir);
+      if ((f.deref != NULL) && storage_type_needs_lowering(f.deref)) {
+         convert_dereference_array(f.deref, ir, ir->lhs);
          ir->remove();
          this->progress = true;
       }
@@ -377,7 +520,17 @@ lower_variable_index_to_cond_assign(exec_list *instructions,
                                           lower_temp,
                                           lower_uniform);
 
-   visit_list_elements(&v, instructions);
-
-   return v.progress;
+   /* Continue lowering until no progress is made.  If there are multiple
+    * levels of indirection (e.g., non-constant indexing of array elements and
+    * matrix columns of an array of matrix), each pass will only lower one
+    * level of indirection.
+    */
+   bool progress_ever = false;
+   do {
+      v.progress = false;
+      visit_list_elements(&v, instructions);
+      progress_ever = v.progress || progress_ever;
+   } while (v.progress);
+
+   return progress_ever;
 }
index 3c4d932..fce9c34 100644 (file)
@@ -71,8 +71,6 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue
    ir_assignment *assign;
    ir_variable *index, *var;
    ir_dereference *deref;
-   ir_expression *condition;
-   ir_swizzle *swizzle;
    int i;
 
    if (!orig_deref)
@@ -86,39 +84,52 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue
 
    assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
 
+   exec_list list;
+
    /* Store the index to a temporary to avoid reusing its tree. */
    index = new(base_ir) ir_variable(glsl_type::int_type,
                                    "vec_index_tmp_i",
                                    ir_var_temporary);
-   base_ir->insert_before(index);
+   list.push_tail(index);
    deref = new(base_ir) ir_dereference_variable(index);
    assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL);
-   base_ir->insert_before(assign);
+   list.push_tail(assign);
 
    /* Temporary where we store whichever value we swizzle out. */
    var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v",
                                  ir_var_temporary);
-   base_ir->insert_before(var);
+   list.push_tail(var);
+
+   /* Generate a single comparison condition "mask" for all of the components
+    * in the vector.
+    */
+   ir_rvalue *const cond_deref =
+      compare_index_block(&list, index, 0,
+                         orig_deref->array->type->vector_elements,
+                         mem_ctx);
 
    /* Generate a conditional move of each vector element to the temp. */
    for (i = 0; i < orig_deref->array->type->vector_elements; i++) {
-      deref = new(base_ir) ir_dereference_variable(index);
-      condition = new(base_ir) ir_expression(ir_binop_equal,
-                                            glsl_type::bool_type,
-                                            deref,
-                                            new(base_ir) ir_constant(i));
+      ir_rvalue *condition_swizzle =
+        new(base_ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1);
 
       /* Just clone the rest of the deref chain when trying to get at the
        * underlying variable.
        */
-      swizzle = new(base_ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL),
-                                       i, 0, 0, 0, 1);
+      ir_rvalue *swizzle =
+        new(base_ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL),
+                                i, 0, 0, 0, 1);
 
       deref = new(base_ir) ir_dereference_variable(var);
-      assign = new(base_ir) ir_assignment(deref, swizzle, condition);
-      base_ir->insert_before(assign);
+      assign = new(base_ir) ir_assignment(deref, swizzle, condition_swizzle);
+      list.push_tail(assign);
    }
 
+   /* Put all of the new instructions in the IR stream before the old
+    * instruction.
+    */
+   base_ir->insert_before(&list);
+
    this->progress = true;
    return new(base_ir) ir_dereference_variable(var);
 }
@@ -171,42 +182,66 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir)
 
    assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
 
+   exec_list list;
+
    /* Store the index to a temporary to avoid reusing its tree. */
    index = new(ir) ir_variable(glsl_type::int_type, "vec_index_tmp_i",
                               ir_var_temporary);
-   ir->insert_before(index);
+   list.push_tail(index);
    deref = new(ir) ir_dereference_variable(index);
    assign = new(ir) ir_assignment(deref, orig_deref->array_index, NULL);
-   ir->insert_before(assign);
+   list.push_tail(assign);
 
    /* Store the RHS to a temporary to avoid reusing its tree. */
    var = new(ir) ir_variable(ir->rhs->type, "vec_index_tmp_v",
                             ir_var_temporary);
-   ir->insert_before(var);
+   list.push_tail(var);
    deref = new(ir) ir_dereference_variable(var);
    assign = new(ir) ir_assignment(deref, ir->rhs, NULL);
-   ir->insert_before(assign);
+   list.push_tail(assign);
+
+   /* Generate a single comparison condition "mask" for all of the components
+    * in the vector.
+    */
+   ir_rvalue *const cond_deref =
+      compare_index_block(&list, index, 0,
+                         orig_deref->array->type->vector_elements,
+                         mem_ctx);
 
    /* Generate a conditional move of each vector element to the temp. */
    for (i = 0; i < orig_deref->array->type->vector_elements; i++) {
-      ir_rvalue *condition, *swizzle;
+      ir_rvalue *condition_swizzle =
+        new(ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1);
 
-      deref = new(ir) ir_dereference_variable(index);
-      condition = new(ir) ir_expression(ir_binop_equal,
-                                       glsl_type::bool_type,
-                                       deref,
-                                       new(ir) ir_constant(i));
 
       /* Just clone the rest of the deref chain when trying to get at the
        * underlying variable.
        */
-      swizzle = new(ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL),
-                                  i, 0, 0, 0, 1);
+      ir_rvalue *swizzle =
+        new(ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL),
+                           i, 0, 0, 0, 1);
 
       deref = new(ir) ir_dereference_variable(var);
-      assign = new(ir) ir_assignment(swizzle, deref, condition);
-      ir->insert_before(assign);
+      assign = new(ir) ir_assignment(swizzle, deref, condition_swizzle);
+      list.push_tail(assign);
    }
+
+   /* If the original assignment has a condition, respect that original
+    * condition!  This is acomplished by wrapping the new conditional
+    * assignments in an if-statement that uses the original condition.
+    */
+   if (ir->condition != NULL) {
+      /* No need to clone the condition because the IR that it hangs on is
+       * going to be removed from the instruction sequence.
+       */
+      ir_if *if_stmt = new(mem_ctx) ir_if(ir->condition);
+
+      list.move_nodes_to(&if_stmt->then_instructions);
+      ir->insert_before(if_stmt);
+   } else {
+      ir->insert_before(&list);
+   }
+
    ir->remove();
 
    this->progress = true;
index 096da93..9b8a507 100644 (file)
 #include "ir_print_visitor.h"
 #include "program.h"
 #include "loop_analysis.h"
-
-extern "C" struct gl_shader *
-_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
-
-extern "C" void
-_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
-                       struct gl_shader *sh);
-
-/* Copied from shader_api.c for the stand-alone compiler.
- */
-void
-_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
-                       struct gl_shader *sh)
-{
-   *ptr = sh;
-}
-
-struct gl_shader *
-_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
-{
-   struct gl_shader *shader;
-
-   (void) ctx;
-
-   assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
-   shader = rzalloc(NULL, struct gl_shader);
-   if (shader) {
-      shader->Type = type;
-      shader->Name = name;
-      shader->RefCount = 1;
-   }
-   return shader;
-}
+#include "standalone_scaffolding.h"
 
 static void
 initialize_context(struct gl_context *ctx, gl_api api)
 {
-   memset(ctx, 0, sizeof(*ctx));
-
-   ctx->API = api;
-
-   ctx->Extensions.ARB_ES2_compatibility = GL_TRUE;
-   ctx->Extensions.ARB_draw_buffers = GL_TRUE;
-   ctx->Extensions.ARB_draw_instanced = GL_TRUE;
-   ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
-   ctx->Extensions.EXT_texture_array = GL_TRUE;
-   ctx->Extensions.NV_texture_rectangle = GL_TRUE;
+   initialize_context_to_defaults(ctx, api);
 
    /* GLSL 1.30 isn't fully supported, but we need to advertise 1.30 so that
     * the built-in functions for 1.30 can be built.
     */
    ctx->Const.GLSLVersion = 130;
 
-   /* 1.10 minimums. */
-   ctx->Const.MaxLights = 8;
    ctx->Const.MaxClipPlanes = 8;
-   ctx->Const.MaxTextureUnits = 2;
+   ctx->Const.MaxDrawBuffers = 2;
 
    /* More than the 1.10 minimum to appease parser tests taken from
     * apps that (hopefully) already checked the number of coords.
     */
    ctx->Const.MaxTextureCoordUnits = 4;
 
-   ctx->Const.VertexProgram.MaxAttribs = 16;
-   ctx->Const.VertexProgram.MaxUniformComponents = 512;
-   ctx->Const.MaxVarying = 8;
-   ctx->Const.MaxVertexTextureImageUnits = 0;
-   ctx->Const.MaxCombinedTextureImageUnits = 2;
-   ctx->Const.MaxTextureImageUnits = 2;
-   ctx->Const.FragmentProgram.MaxUniformComponents = 64;
-
-   ctx->Const.MaxDrawBuffers = 2;
-
    ctx->Driver.NewShader = _mesa_new_shader;
 }
 
@@ -274,6 +221,7 @@ main(int argc, char **argv)
 
    whole_program = rzalloc (NULL, struct gl_shader_program);
    assert(whole_program != NULL);
+   whole_program->InfoLog = ralloc_strdup(whole_program, "");
 
    for (/* empty */; argc > optind; optind++) {
       whole_program->Shaders =
index 4425f42..af77e49 100644 (file)
@@ -51,11 +51,23 @@ public:
       this->var = var;
       this->write_mask = write_mask;
       this->constant = constant;
+      this->initial_values = write_mask;
+   }
+
+   acp_entry(const acp_entry *src)
+   {
+      this->var = src->var;
+      this->write_mask = src->write_mask;
+      this->constant = src->constant;
+      this->initial_values = src->initial_values;
    }
 
    ir_variable *var;
    ir_constant *constant;
    unsigned write_mask;
+
+   /** Mask of values initially available in the constant. */
+   unsigned initial_values;
 };
 
 
@@ -172,7 +184,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
       for (int j = 0; j < 4; j++) {
         if (j == channel)
            break;
-        if (found->write_mask & (1 << j))
+        if (found->initial_values & (1 << j))
            rhs_channel++;
       }
 
@@ -285,8 +297,7 @@ ir_constant_propagation_visitor::handle_if_block(exec_list *instructions)
    /* Populate the initial acp with a constant of the original */
    foreach_iter(exec_list_iterator, iter, *orig_acp) {
       acp_entry *a = (acp_entry *)iter.get();
-      this->acp->push_tail(new(this->mem_ctx) acp_entry(a->var, a->write_mask,
-                                                       a->constant));
+      this->acp->push_tail(new(this->mem_ctx) acp_entry(a));
    }
 
    visit_list_elements(this, instructions);
index db602fa..437ca14 100644 (file)
 
 extern void
 link_shaders(struct gl_context *ctx, struct gl_shader_program *prog);
+
+extern void
+linker_error(gl_shader_program *prog, const char *fmt, ...)
+   PRINTFLIKE(2, 3);
+
+extern void
+linker_warning(gl_shader_program *prog, const char *fmt, ...)
+   PRINTFLIKE(2, 3);
index a922a50..e704a3b 100644 (file)
 #include <assert.h>
 #include "s_expression.h"
 
-s_symbol::s_symbol(const char *tmp, size_t n)
+s_symbol::s_symbol(const char *str, size_t n)
 {
-   this->str = ralloc_strndup (this, tmp, n);
-   assert(this->str != NULL);
+   /* Assume the given string is already nul-terminated and in memory that
+    * will live as long as this node.
+    */
+   assert(str[n] == '\0');
+   this->str = str;
 }
 
 s_list::s_list()
@@ -36,22 +39,26 @@ s_list::s_list()
 }
 
 static void
-skip_whitespace(const char *& src)
+skip_whitespace(const char *&src, char *&symbol_buffer)
 {
-   src += strspn(src, " \v\t\r\n");
+   size_t n = strspn(src, " \v\t\r\n");
+   src += n;
+   symbol_buffer += n;
    /* Also skip Scheme-style comments: semi-colon 'til end of line */
    if (src[0] == ';') {
-      src += strcspn(src, "\n");
-      skip_whitespace(src);
+      n = strcspn(src, "\n");
+      src += n;
+      symbol_buffer += n;
+      skip_whitespace(src, symbol_buffer);
    }
 }
 
 static s_expression *
-read_atom(void *ctx, const char *& src)
+read_atom(void *ctx, const char *&src, char *&symbol_buffer)
 {
    s_expression *expr = NULL;
 
-   skip_whitespace(src);
+   skip_whitespace(src, symbol_buffer);
 
    size_t n = strcspn(src, "( \v\t\r\n);");
    if (n == 0)
@@ -70,44 +77,65 @@ read_atom(void *ctx, const char *& src)
         expr = new(ctx) s_int(i);
    } else {
       // Not a number; return a symbol.
-      expr = new(ctx) s_symbol(src, n);
+      symbol_buffer[n] = '\0';
+      expr = new(ctx) s_symbol(symbol_buffer, n);
    }
 
    src += n;
+   symbol_buffer += n;
 
    return expr;
 }
 
-s_expression *
-s_expression::read_expression(void *ctx, const char *&src)
+static s_expression *
+__read_expression(void *ctx, const char *&src, char *&symbol_buffer)
 {
-   assert(src != NULL);
-
-   s_expression *atom = read_atom(ctx, src);
+   s_expression *atom = read_atom(ctx, src, symbol_buffer);
    if (atom != NULL)
       return atom;
 
-   skip_whitespace(src);
+   skip_whitespace(src, symbol_buffer);
    if (src[0] == '(') {
       ++src;
+      ++symbol_buffer;
 
       s_list *list = new(ctx) s_list;
       s_expression *expr;
 
-      while ((expr = read_expression(ctx, src)) != NULL) {
+      while ((expr = __read_expression(ctx, src, symbol_buffer)) != NULL) {
         list->subexpressions.push_tail(expr);
       }
-      skip_whitespace(src);
+      skip_whitespace(src, symbol_buffer);
       if (src[0] != ')') {
         printf("Unclosed expression (check your parenthesis).\n");
         return NULL;
       }
       ++src;
+      ++symbol_buffer;
       return list;
    }
    return NULL;
 }
 
+s_expression *
+s_expression::read_expression(void *ctx, const char *&src)
+{
+   assert(src != NULL);
+
+   /* When we encounter a Symbol, we need to save a nul-terminated copy of
+    * the string.  However, ralloc_strndup'ing every individual Symbol is
+    * extremely expensive.  We could avoid this by simply overwriting the
+    * next character (guaranteed to be whitespace, parens, or semicolon) with
+    * a nul-byte.  But overwriting non-whitespace would mess up parsing.
+    *
+    * So, just copy the whole buffer ahead of time.  Walk both, leaving the
+    * original source string unmodified, and altering the copy to contain the
+    * necessary nul-bytes whenever we encounter a symbol.
+    */
+   char *symbol_buffer = ralloc_strdup(ctx, src);
+   return __read_expression(ctx, src, symbol_buffer);
+}
+
 void s_int::print()
 {
    printf("%d", this->val);
index c9dc676..642af19 100644 (file)
@@ -129,7 +129,7 @@ public:
    void print();
 
 private:
-   char *str;
+   const char *str;
 };
 
 /* Lists of expressions: (expr1 ... exprN) */
diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp
new file mode 100644 (file)
index 0000000..696ea75
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright Â© 2011 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.
+ */
+
+/* This file declares stripped-down versions of functions that
+ * normally exist outside of the glsl folder, so that they can be used
+ * when running the GLSL compiler standalone (for unit testing or
+ * compiling builtins).
+ */
+
+#include "standalone_scaffolding.h"
+
+#include <assert.h>
+#include <string.h>
+#include "ralloc.h"
+
+void
+_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
+                       struct gl_shader *sh)
+{
+   *ptr = sh;
+}
+
+struct gl_shader *
+_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
+{
+   struct gl_shader *shader;
+
+   (void) ctx;
+
+   assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
+   shader = rzalloc(NULL, struct gl_shader);
+   if (shader) {
+      shader->Type = type;
+      shader->Name = name;
+      shader->RefCount = 1;
+   }
+   return shader;
+}
+
+void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
+{
+   memset(ctx, 0, sizeof(*ctx));
+
+   ctx->API = api;
+
+   ctx->Extensions.ARB_ES2_compatibility = true;
+   ctx->Extensions.ARB_draw_buffers = true;
+   ctx->Extensions.ARB_draw_instanced = true;
+   ctx->Extensions.ARB_fragment_coord_conventions = true;
+   ctx->Extensions.EXT_texture_array = true;
+   ctx->Extensions.NV_texture_rectangle = true;
+   ctx->Extensions.EXT_texture3D = true;
+
+   ctx->Const.GLSLVersion = 120;
+
+   /* 1.20 minimums. */
+   ctx->Const.MaxLights = 8;
+   ctx->Const.MaxClipPlanes = 6;
+   ctx->Const.MaxTextureUnits = 2;
+   ctx->Const.MaxTextureCoordUnits = 2;
+   ctx->Const.VertexProgram.MaxAttribs = 16;
+
+   ctx->Const.VertexProgram.MaxUniformComponents = 512;
+   ctx->Const.MaxVarying = 8; /* == gl_MaxVaryingFloats / 4 */
+   ctx->Const.MaxVertexTextureImageUnits = 0;
+   ctx->Const.MaxCombinedTextureImageUnits = 2;
+   ctx->Const.MaxTextureImageUnits = 2;
+   ctx->Const.FragmentProgram.MaxUniformComponents = 64;
+
+   ctx->Const.MaxDrawBuffers = 1;
+}
diff --git a/src/glsl/standalone_scaffolding.h b/src/glsl/standalone_scaffolding.h
new file mode 100644 (file)
index 0000000..8773320
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright Â© 2011 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.
+ */
+
+/* This file declares stripped-down versions of functions that
+ * normally exist outside of the glsl folder, so that they can be used
+ * when running the GLSL compiler standalone (for unit testing or
+ * compiling builtins).
+ */
+
+#pragma once
+#ifndef STANDALONE_SCAFFOLDING_H
+#define STANDALONE_SCAFFOLDING_H
+
+#include "main/mtypes.h"
+
+extern "C" void
+_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
+                       struct gl_shader *sh);
+
+extern "C" struct gl_shader *
+_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
+
+/**
+ * Initialize the given gl_context structure to a reasonable set of
+ * defaults representing the minimum capabilities required by the
+ * OpenGL spec.
+ *
+ * This is used when compiling builtin functions and in testing, when
+ * we don't have a connection to an actual driver.
+ */
+void initialize_context_to_defaults(struct gl_context *ctx, gl_api api);
+
+
+#endif /* STANDALONE_SCAFFOLDING_H */
diff --git a/src/glsl/test.cpp b/src/glsl/test.cpp
new file mode 100644 (file)
index 0000000..b1ff92e
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright Â© 2011 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.
+ */
+
+/**
+ * \file test.cpp
+ *
+ * Standalone tests for the GLSL compiler.
+ *
+ * This file provides a standalone executable which can be used to
+ * test components of the GLSL.
+ *
+ * Each test is a function with the same signature as main().  The
+ * main function interprets its first argument as the name of the test
+ * to run, strips out that argument, and then calls the test function.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "test_optpass.h"
+
+/**
+ * Print proper usage and exit with failure.
+ */
+static void
+usage_fail(const char *name)
+{
+   printf("*** usage: %s <command> <options>\n", name);
+   printf("\n");
+   printf("Possible commands are:\n");
+   printf("  optpass: test an optimization pass in isolation\n");
+   exit(EXIT_FAILURE);
+}
+
+static const char *extract_command_from_argv(int *argc, char **argv)
+{
+   if (*argc < 2) {
+      usage_fail(argv[0]);
+   }
+   const char *command = argv[1];
+   --*argc;
+   memmove(&argv[1], &argv[2], (*argc) * sizeof(argv[1]));
+   return command;
+}
+
+int main(int argc, char **argv)
+{
+   const char *command = extract_command_from_argv(&argc, argv);
+   if (strcmp(command, "optpass") == 0) {
+      return test_optpass(argc, argv);
+   } else {
+      usage_fail(argv[0]);
+   }
+
+   /* Execution should never reach here. */
+   return EXIT_FAILURE;
+}
diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp
new file mode 100644 (file)
index 0000000..89b7f83
--- /dev/null
@@ -0,0 +1,273 @@
+/*
+ * Copyright Â© 2011 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.
+ */
+
+/**
+ * \file test_optpass.cpp
+ *
+ * Standalone test for optimization passes.
+ *
+ * This file provides the "optpass" command for the standalone
+ * glsl_test app.  It accepts either GLSL or high-level IR as input,
+ * and performs the optimiation passes specified on the command line.
+ * It outputs the IR, both before and after optimiations.
+ */
+
+#include <string>
+#include <iostream>
+#include <sstream>
+#include <getopt.h>
+
+#include "ast.h"
+#include "ir_optimization.h"
+#include "ir_print_visitor.h"
+#include "program.h"
+#include "ir_reader.h"
+#include "standalone_scaffolding.h"
+
+using namespace std;
+
+static string read_stdin_to_eof()
+{
+   stringbuf sb;
+   cin.get(sb, '\0');
+   return sb.str();
+}
+
+static GLboolean
+do_optimization(struct exec_list *ir, const char *optimization)
+{
+   int int_0;
+   int int_1;
+   int int_2;
+   int int_3;
+   int int_4;
+
+   if (sscanf(optimization, "do_common_optimization ( %d , %d ) ",
+              &int_0, &int_1) == 2) {
+      return do_common_optimization(ir, int_0 != 0, int_1);
+   } else if (strcmp(optimization, "do_algebraic") == 0) {
+      return do_algebraic(ir);
+   } else if (strcmp(optimization, "do_constant_folding") == 0) {
+      return do_constant_folding(ir);
+   } else if (strcmp(optimization, "do_constant_variable") == 0) {
+      return do_constant_variable(ir);
+   } else if (strcmp(optimization, "do_constant_variable_unlinked") == 0) {
+      return do_constant_variable_unlinked(ir);
+   } else if (strcmp(optimization, "do_copy_propagation") == 0) {
+      return do_copy_propagation(ir);
+   } else if (strcmp(optimization, "do_copy_propagation_elements") == 0) {
+      return do_copy_propagation_elements(ir);
+   } else if (strcmp(optimization, "do_constant_propagation") == 0) {
+      return do_constant_propagation(ir);
+   } else if (strcmp(optimization, "do_dead_code") == 0) {
+      return do_dead_code(ir);
+   } else if (strcmp(optimization, "do_dead_code_local") == 0) {
+      return do_dead_code_local(ir);
+   } else if (strcmp(optimization, "do_dead_code_unlinked") == 0) {
+      return do_dead_code_unlinked(ir);
+   } else if (strcmp(optimization, "do_dead_functions") == 0) {
+      return do_dead_functions(ir);
+   } else if (strcmp(optimization, "do_function_inlining") == 0) {
+      return do_function_inlining(ir);
+   } else if (sscanf(optimization,
+                     "do_lower_jumps ( %d , %d , %d , %d , %d ) ",
+                     &int_0, &int_1, &int_2, &int_3, &int_4) == 5) {
+      return do_lower_jumps(ir, int_0 != 0, int_1 != 0, int_2 != 0,
+                            int_3 != 0, int_4 != 0);
+   } else if (strcmp(optimization, "do_lower_texture_projection") == 0) {
+      return do_lower_texture_projection(ir);
+   } else if (strcmp(optimization, "do_if_simplification") == 0) {
+      return do_if_simplification(ir);
+   } else if (strcmp(optimization, "do_discard_simplification") == 0) {
+      return do_discard_simplification(ir);
+   } else if (sscanf(optimization, "lower_if_to_cond_assign ( %d ) ",
+                     &int_0) == 1) {
+      return lower_if_to_cond_assign(ir, int_0);
+   } else if (strcmp(optimization, "do_mat_op_to_vec") == 0) {
+      return do_mat_op_to_vec(ir);
+   } else if (strcmp(optimization, "do_noop_swizzle") == 0) {
+      return do_noop_swizzle(ir);
+   } else if (strcmp(optimization, "do_structure_splitting") == 0) {
+      return do_structure_splitting(ir);
+   } else if (strcmp(optimization, "do_swizzle_swizzle") == 0) {
+      return do_swizzle_swizzle(ir);
+   } else if (strcmp(optimization, "do_tree_grafting") == 0) {
+      return do_tree_grafting(ir);
+   } else if (strcmp(optimization, "do_vec_index_to_cond_assign") == 0) {
+      return do_vec_index_to_cond_assign(ir);
+   } else if (strcmp(optimization, "do_vec_index_to_swizzle") == 0) {
+      return do_vec_index_to_swizzle(ir);
+   } else if (strcmp(optimization, "lower_discard") == 0) {
+      return lower_discard(ir);
+   } else if (sscanf(optimization, "lower_instructions ( %d ) ",
+                     &int_0) == 1) {
+      return lower_instructions(ir, int_0);
+   } else if (strcmp(optimization, "lower_noise") == 0) {
+      return lower_noise(ir);
+   } else if (sscanf(optimization, "lower_variable_index_to_cond_assign "
+                     "( %d , %d , %d , %d ) ", &int_0, &int_1, &int_2,
+                     &int_3) == 4) {
+      return lower_variable_index_to_cond_assign(ir, int_0 != 0, int_1 != 0,
+                                                 int_2 != 0, int_3 != 0);
+   } else if (sscanf(optimization, "lower_quadop_vector ( %d ) ",
+                     &int_0) == 1) {
+      return lower_quadop_vector(ir, int_0 != 0);
+   } else if (strcmp(optimization, "optimize_redundant_jumps") == 0) {
+      return optimize_redundant_jumps(ir);
+   } else {
+      printf("Unrecognized optimization %s\n", optimization);
+      exit(EXIT_FAILURE);
+      return false;
+   }
+}
+
+static GLboolean
+do_optimization_passes(struct exec_list *ir, char **optimizations,
+                       int num_optimizations, bool quiet)
+{
+   GLboolean overall_progress = false;
+
+   for (int i = 0; i < num_optimizations; ++i) {
+      const char *optimization = optimizations[i];
+      if (!quiet) {
+         printf("*** Running optimization %s...", optimization);
+      }
+      GLboolean progress = do_optimization(ir, optimization);
+      if (!quiet) {
+         printf("%s\n", progress ? "progress" : "no progress");
+      }
+      validate_ir_tree(ir);
+
+      overall_progress = overall_progress || progress;
+   }
+
+   return overall_progress;
+}
+
+int test_optpass(int argc, char **argv)
+{
+   int input_format_ir = 0; /* 0=glsl, 1=ir */
+   int loop = 0;
+   int shader_type = GL_VERTEX_SHADER;
+   int quiet = 0;
+
+   const struct option optpass_opts[] = {
+      { "input-ir", no_argument, &input_format_ir, 1 },
+      { "input-glsl", no_argument, &input_format_ir, 0 },
+      { "loop", no_argument, &loop, 1 },
+      { "vertex-shader", no_argument, &shader_type, GL_VERTEX_SHADER },
+      { "fragment-shader", no_argument, &shader_type, GL_FRAGMENT_SHADER },
+      { "quiet", no_argument, &quiet, 1 },
+      { NULL, 0, NULL, 0 }
+   };
+
+   int idx = 0;
+   int c;
+   while ((c = getopt_long(argc, argv, "", optpass_opts, &idx)) != -1) {
+      if (c != 0) {
+         printf("*** usage: %s optpass <optimizations> <options>\n", argv[0]);
+         printf("\n");
+         printf("Possible options are:\n");
+         printf("  --input-ir: input format is IR\n");
+         printf("  --input-glsl: input format is GLSL (the default)\n");
+         printf("  --loop: run optimizations repeatedly until no progress\n");
+         printf("  --vertex-shader: test with a vertex shader (the default)\n");
+         printf("  --fragment-shader: test with a fragment shader\n");
+         exit(EXIT_FAILURE);
+      }
+   }
+
+   struct gl_context local_ctx;
+   struct gl_context *ctx = &local_ctx;
+   initialize_context_to_defaults(ctx, API_OPENGL);
+
+   ctx->Driver.NewShader = _mesa_new_shader;
+
+   struct gl_shader *shader = rzalloc(NULL, struct gl_shader);
+   shader->Type = shader_type;
+
+   string input = read_stdin_to_eof();
+
+   struct _mesa_glsl_parse_state *state
+      = new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
+
+   if (input_format_ir) {
+      shader->ir = new(shader) exec_list;
+      _mesa_glsl_initialize_types(state);
+      _mesa_glsl_read_ir(state, shader->ir, input.c_str(), true);
+   } else {
+      shader->Source = input.c_str();
+      const char *source = shader->Source;
+      state->error = preprocess(state, &source, &state->info_log,
+                                state->extensions, ctx->API) != 0;
+
+      if (!state->error) {
+         _mesa_glsl_lexer_ctor(state, source);
+         _mesa_glsl_parse(state);
+         _mesa_glsl_lexer_dtor(state);
+      }
+
+      shader->ir = new(shader) exec_list;
+      if (!state->error && !state->translation_unit.is_empty())
+         _mesa_ast_to_hir(shader->ir, state);
+   }
+
+   /* Print out the initial IR */
+   if (!state->error && !quiet) {
+      printf("*** pre-optimization IR:\n");
+      _mesa_print_ir(shader->ir, state);
+      printf("\n--\n");
+   }
+
+   /* Optimization passes */
+   if (!state->error) {
+      GLboolean progress;
+      do {
+         progress = do_optimization_passes(shader->ir, &argv[optind],
+                                           argc - optind, quiet != 0);
+      } while (loop && progress);
+   }
+
+   /* Print out the resulting IR */
+   if (!state->error) {
+      if (!quiet) {
+         printf("*** resulting IR:\n");
+      }
+      _mesa_print_ir(shader->ir, state);
+      if (!quiet) {
+         printf("\n--\n");
+      }
+   }
+
+   if (state->error) {
+      printf("*** error(s) occurred:\n");
+      printf("%s\n", state->info_log);
+      printf("--\n");
+   }
+
+   ralloc_free(state);
+   ralloc_free(shader);
+
+   return state->error;
+}
+
diff --git a/src/glsl/test_optpass.h b/src/glsl/test_optpass.h
new file mode 100644 (file)
index 0000000..923ccf3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright Â© 2011 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.
+ */
+
+#pragma once
+#ifndef TEST_OPTPASS_H
+#define TEST_OPTPASS_H
+
+int test_optpass(int argc, char **argv);
+
+#endif /* TEST_OPTPASS_H */
diff --git a/src/glsl/tests/compare_ir b/src/glsl/tests/compare_ir
new file mode 100755 (executable)
index 0000000..a40fc81
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# coding=utf-8
+#
+# Copyright Â© 2011 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.
+
+# Compare two files containing IR code.  Ignore formatting differences
+# and declaration order.
+
+import os
+import os.path
+import subprocess
+import sys
+import tempfile
+
+from sexps import *
+
+if len(sys.argv) != 3:
+    print 'Usage: compare_ir <file1> <file2>'
+    exit(1)
+
+with open(sys.argv[1]) as f:
+    ir1 = sort_decls(parse_sexp(f.read()))
+with open(sys.argv[2]) as f:
+    ir2 = sort_decls(parse_sexp(f.read()))
+
+if ir1 == ir2:
+    exit(0)
+else:
+    file1, path1 = tempfile.mkstemp(os.path.basename(sys.argv[1]))
+    file2, path2 = tempfile.mkstemp(os.path.basename(sys.argv[2]))
+    try:
+        os.write(file1, '{0}\n'.format(sexp_to_string(ir1)))
+        os.close(file1)
+        os.write(file2, '{0}\n'.format(sexp_to_string(ir2)))
+        os.close(file2)
+        subprocess.call(['diff', '-u', path1, path2])
+    finally:
+        os.remove(path1)
+        os.remove(path2)
+    exit(1)
diff --git a/src/glsl/tests/lower_jumps/.gitignore b/src/glsl/tests/lower_jumps/.gitignore
new file mode 100644 (file)
index 0000000..f47cb20
--- /dev/null
@@ -0,0 +1 @@
+*.out
diff --git a/src/glsl/tests/lower_jumps/create_test_cases.py b/src/glsl/tests/lower_jumps/create_test_cases.py
new file mode 100644 (file)
index 0000000..fbc6f0a
--- /dev/null
@@ -0,0 +1,643 @@
+# coding=utf-8
+#
+# Copyright Â© 2011 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.
+
+import os
+import os.path
+import re
+import subprocess
+import sys
+
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) # For access to sexps.py, which is in parent dir
+from sexps import *
+
+def make_test_case(f_name, ret_type, body):
+    """Create a simple optimization test case consisting of a single
+    function with the given name, return type, and body.
+
+    Global declarations are automatically created for any undeclared
+    variables that are referenced by the function.  All undeclared
+    variables are assumed to be floats.
+    """
+    check_sexp(body)
+    declarations = {}
+    def make_declarations(sexp, already_declared = ()):
+        if isinstance(sexp, list):
+            if len(sexp) == 2 and sexp[0] == 'var_ref':
+                if sexp[1] not in already_declared:
+                    declarations[sexp[1]] = [
+                        'declare', ['in'], 'float', sexp[1]]
+            elif len(sexp) == 4 and sexp[0] == 'assign':
+                assert sexp[2][0] == 'var_ref'
+                if sexp[2][1] not in already_declared:
+                    declarations[sexp[2][1]] = [
+                        'declare', ['out'], 'float', sexp[2][1]]
+                make_declarations(sexp[3], already_declared)
+            else:
+                already_declared = set(already_declared)
+                for s in sexp:
+                    if isinstance(s, list) and len(s) >= 4 and \
+                            s[0] == 'declare':
+                        already_declared.add(s[3])
+                    else:
+                        make_declarations(s, already_declared)
+    make_declarations(body)
+    return declarations.values() + \
+        [['function', f_name, ['signature', ret_type, ['parameters'], body]]]
+
+
+# The following functions can be used to build expressions.
+
+def const_float(value):
+    """Create an expression representing the given floating point value."""
+    return ['constant', 'float', ['{0:.6f}'.format(value)]]
+
+def const_bool(value):
+    """Create an expression representing the given boolean value.
+
+    If value is not a boolean, it is converted to a boolean.  So, for
+    instance, const_bool(1) is equivalent to const_bool(True).
+    """
+    return ['constant', 'bool', ['{0}'.format(1 if value else 0)]]
+
+def gt_zero(var_name):
+    """Create Construct the expression var_name > 0"""
+    return ['expression', 'bool', '>', ['var_ref', var_name], const_float(0)]
+
+
+# The following functions can be used to build complex control flow
+# statements.  All of these functions return statement lists (even
+# those which only create a single statement), so that statements can
+# be sequenced together using the '+' operator.
+
+def return_(value = None):
+    """Create a return statement."""
+    if value is not None:
+        return [['return', value]]
+    else:
+        return [['return']]
+
+def break_():
+    """Create a break statement."""
+    return ['break']
+
+def continue_():
+    """Create a continue statement."""
+    return ['continue']
+
+def simple_if(var_name, then_statements, else_statements = None):
+    """Create a statement of the form
+
+    if (var_name > 0.0) {
+       <then_statements>
+    } else {
+       <else_statements>
+    }
+
+    else_statements may be omitted.
+    """
+    if else_statements is None:
+        else_statements = []
+    check_sexp(then_statements)
+    check_sexp(else_statements)
+    return [['if', gt_zero(var_name), then_statements, else_statements]]
+
+def loop(statements):
+    """Create a loop containing the given statements as its loop
+    body.
+    """
+    check_sexp(statements)
+    return [['loop', [], [], [], [], statements]]
+
+def declare_temp(var_type, var_name):
+    """Create a declaration of the form
+
+    (declare (temporary) <var_type> <var_name)
+    """
+    return [['declare', ['temporary'], var_type, var_name]]
+
+def assign_x(var_name, value):
+    """Create a statement that assigns <value> to the variable
+    <var_name>.  The assignment uses the mask (x).
+    """
+    check_sexp(value)
+    return [['assign', ['x'], ['var_ref', var_name], value]]
+
+def complex_if(var_prefix, statements):
+    """Create a statement of the form
+
+    if (<var_prefix>a > 0.0) {
+       if (<var_prefix>b > 0.0) {
+          <statements>
+       }
+    }
+
+    This is useful in testing jump lowering, because if <statements>
+    ends in a jump, lower_jumps.cpp won't try to combine this
+    construct with the code that follows it, as it might do for a
+    simple if.
+
+    All variables used in the if statement are prefixed with
+    var_prefix.  This can be used to ensure uniqueness.
+    """
+    check_sexp(statements)
+    return simple_if(var_prefix + 'a', simple_if(var_prefix + 'b', statements))
+
+def declare_execute_flag():
+    """Create the statements that lower_jumps.cpp uses to declare and
+    initialize the temporary boolean execute_flag.
+    """
+    return declare_temp('bool', 'execute_flag') + \
+        assign_x('execute_flag', const_bool(True))
+
+def declare_return_flag():
+    """Create the statements that lower_jumps.cpp uses to declare and
+    initialize the temporary boolean return_flag.
+    """
+    return declare_temp('bool', 'return_flag') + \
+        assign_x('return_flag', const_bool(False))
+
+def declare_return_value():
+    """Create the statements that lower_jumps.cpp uses to declare and
+    initialize the temporary variable return_value.  Assume that
+    return_value is a float.
+    """
+    return declare_temp('float', 'return_value')
+
+def declare_break_flag():
+    """Create the statements that lower_jumps.cpp uses to declare and
+    initialize the temporary boolean break_flag.
+    """
+    return declare_temp('bool', 'break_flag') + \
+        assign_x('break_flag', const_bool(False))
+
+def lowered_return_simple(value = None):
+    """Create the statements that lower_jumps.cpp lowers a return
+    statement to, in situations where it does not need to clear the
+    execute flag.
+    """
+    if value:
+        result = assign_x('return_value', value)
+    else:
+        result = []
+    return result + assign_x('return_flag', const_bool(True))
+
+def lowered_return(value = None):
+    """Create the statements that lower_jumps.cpp lowers a return
+    statement to, in situations where it needs to clear the execute
+    flag.
+    """
+    return lowered_return_simple(value) + \
+        assign_x('execute_flag', const_bool(False))
+
+def lowered_continue():
+    """Create the statement that lower_jumps.cpp lowers a continue
+    statement to.
+    """
+    return assign_x('execute_flag', const_bool(False))
+
+def lowered_break_simple():
+    """Create the statement that lower_jumps.cpp lowers a break
+    statement to, in situations where it does not need to clear the
+    execute flag.
+    """
+    return assign_x('break_flag', const_bool(True))
+
+def lowered_break():
+    """Create the statement that lower_jumps.cpp lowers a break
+    statement to, in situations where it needs to clear the execute
+    flag.
+    """
+    return lowered_break_simple() + assign_x('execute_flag', const_bool(False))
+
+def if_execute_flag(statements):
+    """Wrap statements in an if test so that they will only execute if
+    execute_flag is True.
+    """
+    check_sexp(statements)
+    return [['if', ['var_ref', 'execute_flag'], statements, []]]
+
+def if_not_return_flag(statements):
+    """Wrap statements in an if test so that they will only execute if
+    return_flag is False.
+    """
+    check_sexp(statements)
+    return [['if', ['var_ref', 'return_flag'], [], statements]]
+
+def final_return():
+    """Create the return statement that lower_jumps.cpp places at the
+    end of a function when lowering returns.
+    """
+    return [['return', ['var_ref', 'return_value']]]
+
+def final_break():
+    """Create the conditional break statement that lower_jumps.cpp
+    places at the end of a function when lowering breaks.
+    """
+    return [['if', ['var_ref', 'break_flag'], break_(), []]]
+
+def bash_quote(*args):
+    """Quote the arguments appropriately so that bash will understand
+    each argument as a single word.
+    """
+    def quote_word(word):
+        for c in word:
+            if not (c.isalpha() or c.isdigit() or c in '@%_-+=:,./'):
+                break
+        else:
+            if not word:
+                return "''"
+            return word
+        return "'{0}'".format(word.replace("'", "'\"'\"'"))
+    return ' '.join(quote_word(word) for word in args)
+
+def create_test_case(doc_string, input_sexp, expected_sexp, test_name,
+                     pull_out_jumps=False, lower_sub_return=False,
+                     lower_main_return=False, lower_continue=False,
+                     lower_break=False):
+    """Create a test case that verifies that do_lower_jumps transforms
+    the given code in the expected way.
+    """
+    doc_lines = [line.strip() for line in doc_string.splitlines()]
+    doc_string = ''.join('# {0}\n'.format(line) for line in doc_lines if line != '')
+    check_sexp(input_sexp)
+    check_sexp(expected_sexp)
+    input_str = sexp_to_string(sort_decls(input_sexp))
+    expected_output = sexp_to_string(sort_decls(expected_sexp))
+
+    optimization = (
+        'do_lower_jumps({0:d}, {1:d}, {2:d}, {3:d}, {4:d})'.format(
+            pull_out_jumps, lower_sub_return, lower_main_return,
+            lower_continue, lower_break))
+    args = ['../../glsl_test', 'optpass', '--quiet', '--input-ir', optimization]
+    test_file = '{0}.opt_test'.format(test_name)
+    with open(test_file, 'w') as f:
+        f.write('#!/bin/bash\n#\n# This file was generated by create_test_cases.py.\n#\n')
+        f.write(doc_string)
+        f.write('{0} <<EOF\n'.format(bash_quote(*args)))
+        f.write('{0}\nEOF\n'.format(input_str))
+    os.chmod(test_file, 0774)
+    expected_file = '{0}.opt_test.expected'.format(test_name)
+    with open(expected_file, 'w') as f:
+        f.write('{0}\n'.format(expected_output))
+
+def test_lower_returns_main():
+    doc_string = """Test that do_lower_jumps respects the lower_main_return
+    flag in deciding whether to lower returns in the main
+    function.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            complex_if('', return_())
+            ))
+    expected_sexp = make_test_case('main', 'void', (
+            declare_execute_flag() +
+            declare_return_flag() +
+            complex_if('', lowered_return())
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_returns_main_true',
+                     lower_main_return=True)
+    create_test_case(doc_string, input_sexp, input_sexp, 'lower_returns_main_false',
+                     lower_main_return=False)
+
+def test_lower_returns_sub():
+    doc_string = """Test that do_lower_jumps respects the lower_sub_return flag
+    in deciding whether to lower returns in subroutines.
+    """
+    input_sexp = make_test_case('sub', 'void', (
+            complex_if('', return_())
+            ))
+    expected_sexp = make_test_case('sub', 'void', (
+            declare_execute_flag() +
+            declare_return_flag() +
+            complex_if('', lowered_return())
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_returns_sub_true',
+                     lower_sub_return=True)
+    create_test_case(doc_string, input_sexp, input_sexp, 'lower_returns_sub_false',
+                     lower_sub_return=False)
+
+def test_lower_returns_1():
+    doc_string = """Test that a void return at the end of a function is
+    eliminated.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            assign_x('a', const_float(1)) +
+            return_()
+            ))
+    expected_sexp = make_test_case('main', 'void', (
+            assign_x('a', const_float(1))
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_returns_1',
+                     lower_main_return=True)
+
+def test_lower_returns_2():
+    doc_string = """Test that lowering is not performed on a non-void return at
+    the end of subroutine.
+    """
+    input_sexp = make_test_case('sub', 'float', (
+            assign_x('a', const_float(1)) +
+            return_(const_float(1))
+            ))
+    create_test_case(doc_string, input_sexp, input_sexp, 'lower_returns_2',
+                     lower_sub_return=True)
+
+def test_lower_returns_3():
+    doc_string = """Test lowering of returns when there is one nested inside a
+    complex structure of ifs, and one at the end of a function.
+
+    In this case, the latter return needs to be lowered because it
+    will not be at the end of the function once the final return
+    is inserted.
+    """
+    input_sexp = make_test_case('sub', 'float', (
+            complex_if('', return_(const_float(1))) +
+            return_(const_float(2))
+            ))
+    expected_sexp = make_test_case('sub', 'float', (
+            declare_execute_flag() +
+            declare_return_value() +
+            declare_return_flag() +
+            complex_if('', lowered_return(const_float(1))) +
+            if_execute_flag(lowered_return(const_float(2))) +
+            final_return()
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_returns_3',
+                     lower_sub_return=True)
+
+def test_lower_returns_4():
+    doc_string = """Test that returns are properly lowered when they occur in
+    both branches of an if-statement.
+    """
+    input_sexp = make_test_case('sub', 'float', (
+            simple_if('a', return_(const_float(1)),
+                      return_(const_float(2)))
+            ))
+    expected_sexp = make_test_case('sub', 'float', (
+            declare_execute_flag() +
+            declare_return_value() +
+            declare_return_flag() +
+            simple_if('a', lowered_return(const_float(1)),
+                      lowered_return(const_float(2))) +
+            final_return()
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_returns_4',
+                     lower_sub_return=True)
+
+def test_lower_unified_returns():
+    doc_string = """If both branches of an if statement end in a return, and
+    pull_out_jumps is True, then those returns should be lifted
+    outside the if and then properly lowered.
+
+    Verify that this lowering occurs during the same pass as the
+    lowering of other returns by checking that extra temporary
+    variables aren't generated.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            complex_if('a', return_()) +
+            simple_if('b', simple_if('c', return_(), return_()))
+            ))
+    expected_sexp = make_test_case('main', 'void', (
+            declare_execute_flag() +
+            declare_return_flag() +
+            complex_if('a', lowered_return()) +
+            if_execute_flag(simple_if('b', (simple_if('c', [], []) +
+                                            lowered_return())))
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_unified_returns',
+                     lower_main_return=True, pull_out_jumps=True)
+
+def test_lower_pulled_out_jump():
+    doc_string = """If one branch of an if ends in a jump, and control cannot
+    fall out the bottom of the other branch, and pull_out_jumps is
+    True, then the jump is lifted outside the if.
+
+    Verify that this lowering occurs during the same pass as the
+    lowering of other jumps by checking that extra temporary
+    variables aren't generated.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            complex_if('a', return_()) +
+            loop(simple_if('b', simple_if('c', break_(), continue_()),
+                           return_())) +
+            assign_x('d', const_float(1))
+            ))
+    # Note: optimization produces two other effects: the break
+    # gets lifted out of the if statements, and the code after the
+    # loop gets guarded so that it only executes if the return
+    # flag is clear.
+    expected_sexp = make_test_case('main', 'void', (
+            declare_execute_flag() +
+            declare_return_flag() +
+            complex_if('a', lowered_return()) +
+            if_execute_flag(
+                loop(simple_if('b', simple_if('c', [], continue_()),
+                               lowered_return_simple()) +
+                     break_()) +
+                if_not_return_flag(assign_x('d', const_float(1))))
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_pulled_out_jump',
+                     lower_main_return=True, pull_out_jumps=True)
+
+def test_lower_breaks_1():
+    doc_string = """If a loop contains an unconditional break at the bottom of
+    it, it should not be lowered."""
+    input_sexp = make_test_case('main', 'void', (
+            loop(assign_x('a', const_float(1)) +
+                 break_())
+            ))
+    expected_sexp = input_sexp
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_breaks_1', lower_break=True)
+
+def test_lower_breaks_2():
+    doc_string = """If a loop contains a conditional break at the bottom of it,
+    it should not be lowered if it is in the then-clause.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            loop(assign_x('a', const_float(1)) +
+                 simple_if('b', break_()))
+            ))
+    expected_sexp = input_sexp
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_breaks_2', lower_break=True)
+
+def test_lower_breaks_3():
+    doc_string = """If a loop contains a conditional break at the bottom of it,
+    it should not be lowered if it is in the then-clause, even if
+    there are statements preceding the break.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            loop(assign_x('a', const_float(1)) +
+                 simple_if('b', (assign_x('c', const_float(1)) +
+                                 break_())))
+            ))
+    expected_sexp = input_sexp
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_breaks_3', lower_break=True)
+
+def test_lower_breaks_4():
+    doc_string = """If a loop contains a conditional break at the bottom of it,
+    it should not be lowered if it is in the else-clause.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            loop(assign_x('a', const_float(1)) +
+                 simple_if('b', [], break_()))
+            ))
+    expected_sexp = input_sexp
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_breaks_4', lower_break=True)
+
+def test_lower_breaks_5():
+    doc_string = """If a loop contains a conditional break at the bottom of it,
+    it should not be lowered if it is in the else-clause, even if
+    there are statements preceding the break.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            loop(assign_x('a', const_float(1)) +
+                 simple_if('b', [], (assign_x('c', const_float(1)) +
+                                     break_())))
+            ))
+    expected_sexp = input_sexp
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_breaks_5', lower_break=True)
+
+def test_lower_breaks_6():
+    doc_string = """If a loop contains conditional breaks and continues, and
+    ends in an unconditional break, then the unconditional break
+    needs to be lowered, because it will no longer be at the end
+    of the loop after the final break is added.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            loop(simple_if('a', (complex_if('b', continue_()) +
+                                 complex_if('c', break_()))) +
+                 break_())
+            ))
+    expected_sexp = make_test_case('main', 'void', (
+            declare_break_flag() +
+            loop(declare_execute_flag() +
+                 simple_if(
+                    'a',
+                    (complex_if('b', lowered_continue()) +
+                     if_execute_flag(
+                            complex_if('c', lowered_break())))) +
+                 if_execute_flag(lowered_break_simple()) +
+                 final_break())
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_breaks_6',
+                     lower_break=True, lower_continue=True)
+
+def test_lower_guarded_conditional_break():
+    doc_string = """Normally a conditional break at the end of a loop isn't
+    lowered, however if the conditional break gets placed inside
+    an if(execute_flag) because of earlier lowering of continues,
+    then the break needs to be lowered.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            loop(complex_if('a', continue_()) +
+                 simple_if('b', break_()))
+            ))
+    expected_sexp = make_test_case('main', 'void', (
+            declare_break_flag() +
+            loop(declare_execute_flag() +
+                 complex_if('a', lowered_continue()) +
+                 if_execute_flag(simple_if('b', lowered_break())) +
+                 final_break())
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'lower_guarded_conditional_break',
+                     lower_break=True, lower_continue=True)
+
+def test_remove_continue_at_end_of_loop():
+    doc_string = """Test that a redundant continue-statement at the end of a
+    loop is removed.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            loop(assign_x('a', const_float(1)) +
+                 continue_())
+            ))
+    expected_sexp = make_test_case('main', 'void', (
+            loop(assign_x('a', const_float(1)))
+            ))
+    create_test_case(doc_string, input_sexp, expected_sexp, 'remove_continue_at_end_of_loop')
+
+def test_lower_return_void_at_end_of_loop():
+    doc_string = """Test that a return of void at the end of a loop is properly
+    lowered.
+    """
+    input_sexp = make_test_case('main', 'void', (
+            loop(assign_x('a', const_float(1)) +
+                 return_()) +
+            assign_x('b', const_float(2))
+            ))
+    expected_sexp = make_test_case('main', 'void', (
+            declare_return_flag() +
+            loop(assign_x('a', const_float(1)) +
+                 lowered_return_simple() +
+                 break_()) +
+            if_not_return_flag(assign_x('b', const_float(2)))
+            ))
+    create_test_case(doc_string, input_sexp, input_sexp, 'return_void_at_end_of_loop_lower_nothing')
+    create_test_case(doc_string, input_sexp, expected_sexp, 'return_void_at_end_of_loop_lower_return',
+                     lower_main_return=True)
+    create_test_case(doc_string, input_sexp, expected_sexp, 'return_void_at_end_of_loop_lower_return_and_break',
+                     lower_main_return=True, lower_break=True)
+
+def test_lower_return_non_void_at_end_of_loop():
+    doc_string = """Test that a non-void return at the end of a loop is
+    properly lowered.
+    """
+    input_sexp = make_test_case('sub', 'float', (
+            loop(assign_x('a', const_float(1)) +
+                 return_(const_float(2))) +
+            assign_x('b', const_float(3)) +
+            return_(const_float(4))
+            ))
+    expected_sexp = make_test_case('sub', 'float', (
+            declare_execute_flag() +
+            declare_return_value() +
+            declare_return_flag() +
+            loop(assign_x('a', const_float(1)) +
+                 lowered_return_simple(const_float(2)) +
+                 break_()) +
+            if_not_return_flag(assign_x('b', const_float(3)) +
+                               lowered_return(const_float(4))) +
+            final_return()
+            ))
+    create_test_case(doc_string, input_sexp, input_sexp, 'return_non_void_at_end_of_loop_lower_nothing')
+    create_test_case(doc_string, input_sexp, expected_sexp, 'return_non_void_at_end_of_loop_lower_return',
+                     lower_sub_return=True)
+    create_test_case(doc_string, input_sexp, expected_sexp, 'return_non_void_at_end_of_loop_lower_return_and_break',
+                     lower_sub_return=True, lower_break=True)
+
+if __name__ == '__main__':
+    test_lower_returns_main()
+    test_lower_returns_sub()
+    test_lower_returns_1()
+    test_lower_returns_2()
+    test_lower_returns_3()
+    test_lower_returns_4()
+    test_lower_unified_returns()
+    test_lower_pulled_out_jump()
+    test_lower_breaks_1()
+    test_lower_breaks_2()
+    test_lower_breaks_3()
+    test_lower_breaks_4()
+    test_lower_breaks_5()
+    test_lower_breaks_6()
+    test_lower_guarded_conditional_break()
+    test_remove_continue_at_end_of_loop()
+    test_lower_return_void_at_end_of_loop()
+    test_lower_return_non_void_at_end_of_loop()
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test
new file mode 100755 (executable)
index 0000000..01ad708
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# If a loop contains an unconditional break at the bottom of
+# it, it should not be lowered.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 1)' <<EOF
+((declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000))) break))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_1.opt_test.expected
new file mode 100644 (file)
index 0000000..d4bb6fc
--- /dev/null
@@ -0,0 +1,5 @@
+((declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000))) break))))))
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test
new file mode 100755 (executable)
index 0000000..0be22f9
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# If a loop contains a conditional break at the bottom of it,
+# it should not be lowered if it is in the then-clause.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 1)' <<EOF
+((declare (in) float b) (declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (if (expression bool > (var_ref b) (constant float (0.000000))) (break)
+       ())))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_2.opt_test.expected
new file mode 100644 (file)
index 0000000..a4cb2d6
--- /dev/null
@@ -0,0 +1,7 @@
+((declare (in) float b) (declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (if (expression bool > (var_ref b) (constant float (0.000000))) (break)
+       ())))))))
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test
new file mode 100755 (executable)
index 0000000..4149360
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# If a loop contains a conditional break at the bottom of it,
+# it should not be lowered if it is in the then-clause, even if
+# there are statements preceding the break.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 1)' <<EOF
+((declare (in) float b) (declare (out) float a) (declare (out) float c)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((assign (x) (var_ref c) (constant float (1.000000))) break)
+       ())))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_3.opt_test.expected
new file mode 100644 (file)
index 0000000..325f7b4
--- /dev/null
@@ -0,0 +1,8 @@
+((declare (in) float b) (declare (out) float a) (declare (out) float c)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((assign (x) (var_ref c) (constant float (1.000000))) break)
+       ())))))))
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test
new file mode 100755 (executable)
index 0000000..70458bb
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# If a loop contains a conditional break at the bottom of it,
+# it should not be lowered if it is in the else-clause.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 1)' <<EOF
+((declare (in) float b) (declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (if (expression bool > (var_ref b) (constant float (0.000000))) ()
+       (break))))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_4.opt_test.expected
new file mode 100644 (file)
index 0000000..a773545
--- /dev/null
@@ -0,0 +1,7 @@
+((declare (in) float b) (declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (if (expression bool > (var_ref b) (constant float (0.000000))) ()
+       (break))))))))
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test
new file mode 100755 (executable)
index 0000000..da9eef1
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# If a loop contains a conditional break at the bottom of it,
+# it should not be lowered if it is in the else-clause, even if
+# there are statements preceding the break.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 1)' <<EOF
+((declare (in) float b) (declare (out) float a) (declare (out) float c)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (if (expression bool > (var_ref b) (constant float (0.000000))) ()
+       ((assign (x) (var_ref c) (constant float (1.000000))) break))))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_5.opt_test.expected
new file mode 100644 (file)
index 0000000..0dd4a52
--- /dev/null
@@ -0,0 +1,7 @@
+((declare (in) float b) (declare (out) float a) (declare (out) float c)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (if (expression bool > (var_ref b) (constant float (0.000000))) ()
+       ((assign (x) (var_ref c) (constant float (1.000000))) break))))))))
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test b/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test
new file mode 100755 (executable)
index 0000000..9440dfe
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# If a loop contains conditional breaks and continues, and
+# ends in an unconditional break, then the unconditional break
+# needs to be lowered, because it will no longer be at the end
+# of the loop after the final break is added.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 1, 1)' <<EOF
+((declare (in) float a) (declare (in) float ba) (declare (in) float bb)
+ (declare (in) float ca)
+ (declare (in) float cb)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((if (expression bool > (var_ref a) (constant float (0.000000)))
+       ((if (expression bool > (var_ref ba) (constant float (0.000000)))
+         ((if (expression bool > (var_ref bb) (constant float (0.000000)))
+           (continue)
+           ()))
+         ())
+        (if (expression bool > (var_ref ca) (constant float (0.000000)))
+         ((if (expression bool > (var_ref cb) (constant float (0.000000)))
+           (break)
+           ()))
+         ()))
+       ())
+      break))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected b/src/glsl/tests/lower_jumps/lower_breaks_6.opt_test.expected
new file mode 100644 (file)
index 0000000..8222328
--- /dev/null
@@ -0,0 +1,29 @@
+((declare (in) float a) (declare (in) float ba) (declare (in) float bb)
+ (declare (in) float ca)
+ (declare (in) float cb)
+ (function main
+  (signature void (parameters)
+   ((declare (temporary) bool break_flag)
+    (assign (x) (var_ref break_flag) (constant bool (0)))
+    (loop () () () ()
+     ((declare (temporary) bool execute_flag)
+      (assign (x) (var_ref execute_flag) (constant bool (1)))
+      (if (expression bool > (var_ref a) (constant float (0.000000)))
+       ((if (expression bool > (var_ref ba) (constant float (0.000000)))
+         ((if (expression bool > (var_ref bb) (constant float (0.000000)))
+           ((assign (x) (var_ref execute_flag) (constant bool (0))))
+           ()))
+         ())
+        (if (var_ref execute_flag)
+         ((if (expression bool > (var_ref ca) (constant float (0.000000)))
+           ((if (expression bool > (var_ref cb) (constant float (0.000000)))
+             ((assign (x) (var_ref break_flag) (constant bool (1)))
+              (assign (x) (var_ref execute_flag) (constant bool (0))))
+             ()))
+           ()))
+         ()))
+       ())
+      (if (var_ref execute_flag)
+       ((assign (x) (var_ref break_flag) (constant bool (1))))
+       ())
+      (if (var_ref break_flag) (break) ())))))))
diff --git a/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test b/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test
new file mode 100755 (executable)
index 0000000..379aa59
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Normally a conditional break at the end of a loop isn't
+# lowered, however if the conditional break gets placed inside
+# an if(execute_flag) because of earlier lowering of continues,
+# then the break needs to be lowered.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 1, 1)' <<EOF
+((declare (in) float aa) (declare (in) float ab) (declare (in) float b)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((if (expression bool > (var_ref aa) (constant float (0.000000)))
+       ((if (expression bool > (var_ref ab) (constant float (0.000000)))
+         (continue)
+         ()))
+       ())
+      (if (expression bool > (var_ref b) (constant float (0.000000))) (break)
+       ())))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected b/src/glsl/tests/lower_jumps/lower_guarded_conditional_break.opt_test.expected
new file mode 100644 (file)
index 0000000..7c6e73f
--- /dev/null
@@ -0,0 +1,20 @@
+((declare (in) float aa) (declare (in) float ab) (declare (in) float b)
+ (function main
+  (signature void (parameters)
+   ((declare (temporary) bool break_flag)
+    (assign (x) (var_ref break_flag) (constant bool (0)))
+    (loop () () () ()
+     ((declare (temporary) bool execute_flag)
+      (assign (x) (var_ref execute_flag) (constant bool (1)))
+      (if (expression bool > (var_ref aa) (constant float (0.000000)))
+       ((if (expression bool > (var_ref ab) (constant float (0.000000)))
+         ((assign (x) (var_ref execute_flag) (constant bool (0))))
+         ()))
+       ())
+      (if (var_ref execute_flag)
+       ((if (expression bool > (var_ref b) (constant float (0.000000)))
+         ((assign (x) (var_ref break_flag) (constant bool (1)))
+          (assign (x) (var_ref execute_flag) (constant bool (0))))
+         ()))
+       ())
+      (if (var_ref break_flag) (break) ())))))))
diff --git a/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test b/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test
new file mode 100755 (executable)
index 0000000..15f3c41
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# If one branch of an if ends in a jump, and control cannot
+# fall out the bottom of the other branch, and pull_out_jumps is
+# True, then the jump is lifted outside the if.
+# Verify that this lowering occurs during the same pass as the
+# lowering of other jumps by checking that extra temporary
+# variables aren't generated.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(1, 0, 1, 0, 0)' <<EOF
+((declare (in) float aa) (declare (in) float ab) (declare (in) float b)
+ (declare (in) float c)
+ (declare (out) float d)
+ (function main
+  (signature void (parameters)
+   ((if (expression bool > (var_ref aa) (constant float (0.000000)))
+     ((if (expression bool > (var_ref ab) (constant float (0.000000)))
+       ((return))
+       ()))
+     ())
+    (loop () () () ()
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((if (expression bool > (var_ref c) (constant float (0.000000))) (break)
+         (continue)))
+       ((return)))))
+    (assign (x) (var_ref d) (constant float (1.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected b/src/glsl/tests/lower_jumps/lower_pulled_out_jump.opt_test.expected
new file mode 100644 (file)
index 0000000..bf45c2c
--- /dev/null
@@ -0,0 +1,25 @@
+((declare (in) float aa) (declare (in) float ab) (declare (in) float b)
+ (declare (in) float c)
+ (declare (out) float d)
+ (function main
+  (signature void (parameters)
+   ((declare (temporary) bool execute_flag)
+    (assign (x) (var_ref execute_flag) (constant bool (1)))
+    (declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (if (expression bool > (var_ref aa) (constant float (0.000000)))
+     ((if (expression bool > (var_ref ab) (constant float (0.000000)))
+       ((assign (x) (var_ref return_flag) (constant bool (1)))
+        (assign (x) (var_ref execute_flag) (constant bool (0))))
+       ()))
+     ())
+    (if (var_ref execute_flag)
+     ((loop () () () ()
+       ((if (expression bool > (var_ref b) (constant float (0.000000)))
+         ((if (expression bool > (var_ref c) (constant float (0.000000))) ()
+           (continue)))
+         ((assign (x) (var_ref return_flag) (constant bool (1)))))
+        break))
+      (if (var_ref return_flag) ()
+       ((assign (x) (var_ref d) (constant float (1.000000))))))
+     ())))))
diff --git a/src/glsl/tests/lower_jumps/lower_returns_1.opt_test b/src/glsl/tests/lower_jumps/lower_returns_1.opt_test
new file mode 100755 (executable)
index 0000000..a1f895b
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that a void return at the end of a function is
+# eliminated.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 1, 0, 0)' <<EOF
+((declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((assign (x) (var_ref a) (constant float (1.000000))) (return)))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_returns_1.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_1.opt_test.expected
new file mode 100644 (file)
index 0000000..7c3919c
--- /dev/null
@@ -0,0 +1,4 @@
+((declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((assign (x) (var_ref a) (constant float (1.000000)))))))
diff --git a/src/glsl/tests/lower_jumps/lower_returns_2.opt_test b/src/glsl/tests/lower_jumps/lower_returns_2.opt_test
new file mode 100755 (executable)
index 0000000..61673d4
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that lowering is not performed on a non-void return at
+# the end of subroutine.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 1, 0, 0, 0)' <<EOF
+((declare (out) float a)
+ (function sub
+  (signature float (parameters)
+   ((assign (x) (var_ref a) (constant float (1.000000)))
+    (return (constant float (1.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_returns_2.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_2.opt_test.expected
new file mode 100644 (file)
index 0000000..7777927
--- /dev/null
@@ -0,0 +1,5 @@
+((declare (out) float a)
+ (function sub
+  (signature float (parameters)
+   ((assign (x) (var_ref a) (constant float (1.000000)))
+    (return (constant float (1.000000)))))))
diff --git a/src/glsl/tests/lower_jumps/lower_returns_3.opt_test b/src/glsl/tests/lower_jumps/lower_returns_3.opt_test
new file mode 100755 (executable)
index 0000000..9881e24
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test lowering of returns when there is one nested inside a
+# complex structure of ifs, and one at the end of a function.
+# In this case, the latter return needs to be lowered because it
+# will not be at the end of the function once the final return
+# is inserted.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 1, 0, 0, 0)' <<EOF
+((declare (in) float a) (declare (in) float b)
+ (function sub
+  (signature float (parameters)
+   ((if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((return (constant float (1.000000))))
+       ()))
+     ())
+    (return (constant float (2.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_returns_3.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_3.opt_test.expected
new file mode 100644 (file)
index 0000000..d4835e9
--- /dev/null
@@ -0,0 +1,21 @@
+((declare (in) float a) (declare (in) float b)
+ (function sub
+  (signature float (parameters)
+   ((declare (temporary) bool execute_flag)
+    (assign (x) (var_ref execute_flag) (constant bool (1)))
+    (declare (temporary) float return_value)
+    (declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((assign (x) (var_ref return_value) (constant float (1.000000)))
+        (assign (x) (var_ref return_flag) (constant bool (1)))
+        (assign (x) (var_ref execute_flag) (constant bool (0))))
+       ()))
+     ())
+    (if (var_ref execute_flag)
+     ((assign (x) (var_ref return_value) (constant float (2.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      (assign (x) (var_ref execute_flag) (constant bool (0))))
+     ())
+    (return (var_ref return_value))))))
diff --git a/src/glsl/tests/lower_jumps/lower_returns_4.opt_test b/src/glsl/tests/lower_jumps/lower_returns_4.opt_test
new file mode 100755 (executable)
index 0000000..9f54c67
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that returns are properly lowered when they occur in
+# both branches of an if-statement.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 1, 0, 0, 0)' <<EOF
+((declare (in) float a)
+ (function sub
+  (signature float (parameters)
+   ((if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((return (constant float (1.000000))))
+     ((return (constant float (2.000000)))))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_returns_4.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_4.opt_test.expected
new file mode 100644 (file)
index 0000000..b551a06
--- /dev/null
@@ -0,0 +1,16 @@
+((declare (in) float a)
+ (function sub
+  (signature float (parameters)
+   ((declare (temporary) bool execute_flag)
+    (assign (x) (var_ref execute_flag) (constant bool (1)))
+    (declare (temporary) float return_value)
+    (declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((assign (x) (var_ref return_value) (constant float (1.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      (assign (x) (var_ref execute_flag) (constant bool (0))))
+     ((assign (x) (var_ref return_value) (constant float (2.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      (assign (x) (var_ref execute_flag) (constant bool (0)))))
+    (return (var_ref return_value))))))
diff --git a/src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test b/src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test
new file mode 100755 (executable)
index 0000000..5f97bfd
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that do_lower_jumps respects the lower_main_return
+# flag in deciding whether to lower returns in the main
+# function.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 0)' <<EOF
+((declare (in) float a) (declare (in) float b)
+ (function main
+  (signature void (parameters)
+   ((if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((return))
+       ()))
+     ())))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_main_false.opt_test.expected
new file mode 100644 (file)
index 0000000..e8b36f1
--- /dev/null
@@ -0,0 +1,8 @@
+((declare (in) float a) (declare (in) float b)
+ (function main
+  (signature void (parameters)
+   ((if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((return))
+       ()))
+     ())))))
diff --git a/src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test b/src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test
new file mode 100755 (executable)
index 0000000..59c7ba1
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that do_lower_jumps respects the lower_main_return
+# flag in deciding whether to lower returns in the main
+# function.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 1, 0, 0)' <<EOF
+((declare (in) float a) (declare (in) float b)
+ (function main
+  (signature void (parameters)
+   ((if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((return))
+       ()))
+     ())))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_main_true.opt_test.expected
new file mode 100644 (file)
index 0000000..e15a97d
--- /dev/null
@@ -0,0 +1,13 @@
+((declare (in) float a) (declare (in) float b)
+ (function main
+  (signature void (parameters)
+   ((declare (temporary) bool execute_flag)
+    (assign (x) (var_ref execute_flag) (constant bool (1)))
+    (declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((assign (x) (var_ref return_flag) (constant bool (1)))
+        (assign (x) (var_ref execute_flag) (constant bool (0))))
+       ()))
+     ())))))
diff --git a/src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test b/src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test
new file mode 100755 (executable)
index 0000000..40e784e
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that do_lower_jumps respects the lower_sub_return flag
+# in deciding whether to lower returns in subroutines.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 0)' <<EOF
+((declare (in) float a) (declare (in) float b)
+ (function sub
+  (signature void (parameters)
+   ((if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((return))
+       ()))
+     ())))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_sub_false.opt_test.expected
new file mode 100644 (file)
index 0000000..07db6e7
--- /dev/null
@@ -0,0 +1,8 @@
+((declare (in) float a) (declare (in) float b)
+ (function sub
+  (signature void (parameters)
+   ((if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((return))
+       ()))
+     ())))))
diff --git a/src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test b/src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test
new file mode 100755 (executable)
index 0000000..9fe6b90
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that do_lower_jumps respects the lower_sub_return flag
+# in deciding whether to lower returns in subroutines.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 1, 0, 0, 0)' <<EOF
+((declare (in) float a) (declare (in) float b)
+ (function sub
+  (signature void (parameters)
+   ((if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((return))
+       ()))
+     ())))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test.expected b/src/glsl/tests/lower_jumps/lower_returns_sub_true.opt_test.expected
new file mode 100644 (file)
index 0000000..3110980
--- /dev/null
@@ -0,0 +1,13 @@
+((declare (in) float a) (declare (in) float b)
+ (function sub
+  (signature void (parameters)
+   ((declare (temporary) bool execute_flag)
+    (assign (x) (var_ref execute_flag) (constant bool (1)))
+    (declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (if (expression bool > (var_ref a) (constant float (0.000000)))
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((assign (x) (var_ref return_flag) (constant bool (1)))
+        (assign (x) (var_ref execute_flag) (constant bool (0))))
+       ()))
+     ())))))
diff --git a/src/glsl/tests/lower_jumps/lower_unified_returns.opt_test b/src/glsl/tests/lower_jumps/lower_unified_returns.opt_test
new file mode 100755 (executable)
index 0000000..e716813
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# If both branches of an if statement end in a return, and
+# pull_out_jumps is True, then those returns should be lifted
+# outside the if and then properly lowered.
+# Verify that this lowering occurs during the same pass as the
+# lowering of other returns by checking that extra temporary
+# variables aren't generated.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(1, 0, 1, 0, 0)' <<EOF
+((declare (in) float aa) (declare (in) float ab) (declare (in) float b)
+ (declare (in) float c)
+ (function main
+  (signature void (parameters)
+   ((if (expression bool > (var_ref aa) (constant float (0.000000)))
+     ((if (expression bool > (var_ref ab) (constant float (0.000000)))
+       ((return))
+       ()))
+     ())
+    (if (expression bool > (var_ref b) (constant float (0.000000)))
+     ((if (expression bool > (var_ref c) (constant float (0.000000)))
+       ((return))
+       ((return))))
+     ())))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/lower_unified_returns.opt_test.expected b/src/glsl/tests/lower_jumps/lower_unified_returns.opt_test.expected
new file mode 100644 (file)
index 0000000..271cd3b
--- /dev/null
@@ -0,0 +1,21 @@
+((declare (in) float aa) (declare (in) float ab) (declare (in) float b)
+ (declare (in) float c)
+ (function main
+  (signature void (parameters)
+   ((declare (temporary) bool execute_flag)
+    (assign (x) (var_ref execute_flag) (constant bool (1)))
+    (declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (if (expression bool > (var_ref aa) (constant float (0.000000)))
+     ((if (expression bool > (var_ref ab) (constant float (0.000000)))
+       ((assign (x) (var_ref return_flag) (constant bool (1)))
+        (assign (x) (var_ref execute_flag) (constant bool (0))))
+       ()))
+     ())
+    (if (var_ref execute_flag)
+     ((if (expression bool > (var_ref b) (constant float (0.000000)))
+       ((if (expression bool > (var_ref c) (constant float (0.000000))) () ())
+        (assign (x) (var_ref return_flag) (constant bool (1)))
+        (assign (x) (var_ref execute_flag) (constant bool (0))))
+       ()))
+     ())))))
diff --git a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test
new file mode 100755 (executable)
index 0000000..18efc37
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that a redundant continue-statement at the end of a
+# loop is removed.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 0)' <<EOF
+((declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000))) continue))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected b/src/glsl/tests/lower_jumps/remove_continue_at_end_of_loop.opt_test.expected
new file mode 100644 (file)
index 0000000..d2a02c6
--- /dev/null
@@ -0,0 +1,5 @@
+((declare (out) float a)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))))))))
diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test
new file mode 100755 (executable)
index 0000000..79c0e82
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that a non-void return at the end of a loop is
+# properly lowered.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 0)' <<EOF
+((declare (out) float a) (declare (out) float b)
+ (function sub
+  (signature float (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (return (constant float (2.000000)))))
+    (assign (x) (var_ref b) (constant float (3.000000)))
+    (return (constant float (4.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test.expected b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_nothing.opt_test.expected
new file mode 100644 (file)
index 0000000..2cf117a
--- /dev/null
@@ -0,0 +1,8 @@
+((declare (out) float a) (declare (out) float b)
+ (function sub
+  (signature float (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (return (constant float (2.000000)))))
+    (assign (x) (var_ref b) (constant float (3.000000)))
+    (return (constant float (4.000000)))))))
diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test
new file mode 100755 (executable)
index 0000000..920d2ad
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that a non-void return at the end of a loop is
+# properly lowered.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 1, 0, 0, 0)' <<EOF
+((declare (out) float a) (declare (out) float b)
+ (function sub
+  (signature float (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (return (constant float (2.000000)))))
+    (assign (x) (var_ref b) (constant float (3.000000)))
+    (return (constant float (4.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test.expected b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return.opt_test.expected
new file mode 100644 (file)
index 0000000..0bab8f1
--- /dev/null
@@ -0,0 +1,19 @@
+((declare (out) float a) (declare (out) float b)
+ (function sub
+  (signature float (parameters)
+   ((declare (temporary) bool execute_flag)
+    (assign (x) (var_ref execute_flag) (constant bool (1)))
+    (declare (temporary) float return_value)
+    (declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (assign (x) (var_ref return_value) (constant float (2.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      break))
+    (if (var_ref return_flag) ()
+     ((assign (x) (var_ref b) (constant float (3.000000)))
+      (assign (x) (var_ref return_value) (constant float (4.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      (assign (x) (var_ref execute_flag) (constant bool (0)))))
+    (return (var_ref return_value))))))
diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test
new file mode 100755 (executable)
index 0000000..99f1f86
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that a non-void return at the end of a loop is
+# properly lowered.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 1, 0, 0, 1)' <<EOF
+((declare (out) float a) (declare (out) float b)
+ (function sub
+  (signature float (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (return (constant float (2.000000)))))
+    (assign (x) (var_ref b) (constant float (3.000000)))
+    (return (constant float (4.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test.expected b/src/glsl/tests/lower_jumps/return_non_void_at_end_of_loop_lower_return_and_break.opt_test.expected
new file mode 100644 (file)
index 0000000..0bab8f1
--- /dev/null
@@ -0,0 +1,19 @@
+((declare (out) float a) (declare (out) float b)
+ (function sub
+  (signature float (parameters)
+   ((declare (temporary) bool execute_flag)
+    (assign (x) (var_ref execute_flag) (constant bool (1)))
+    (declare (temporary) float return_value)
+    (declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (assign (x) (var_ref return_value) (constant float (2.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      break))
+    (if (var_ref return_flag) ()
+     ((assign (x) (var_ref b) (constant float (3.000000)))
+      (assign (x) (var_ref return_value) (constant float (4.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      (assign (x) (var_ref execute_flag) (constant bool (0)))))
+    (return (var_ref return_value))))))
diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test
new file mode 100755 (executable)
index 0000000..63487d3
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that a return of void at the end of a loop is properly
+# lowered.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 0, 0, 0)' <<EOF
+((declare (out) float a) (declare (out) float b)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000))) (return)))
+    (assign (x) (var_ref b) (constant float (2.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_nothing.opt_test.expected
new file mode 100644 (file)
index 0000000..0bd8037
--- /dev/null
@@ -0,0 +1,6 @@
+((declare (out) float a) (declare (out) float b)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000))) (return)))
+    (assign (x) (var_ref b) (constant float (2.000000)))))))
diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test
new file mode 100755 (executable)
index 0000000..523c92a
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that a return of void at the end of a loop is properly
+# lowered.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 1, 0, 0)' <<EOF
+((declare (out) float a) (declare (out) float b)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000))) (return)))
+    (assign (x) (var_ref b) (constant float (2.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test.expected b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return.opt_test.expected
new file mode 100644 (file)
index 0000000..53814ea
--- /dev/null
@@ -0,0 +1,11 @@
+((declare (out) float a) (declare (out) float b)
+ (function main
+  (signature void (parameters)
+   ((declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      break))
+    (if (var_ref return_flag) ()
+     ((assign (x) (var_ref b) (constant float (2.000000)))))))))
diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test
new file mode 100755 (executable)
index 0000000..22b5581
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# This file was generated by create_test_cases.py.
+#
+# Test that a return of void at the end of a loop is properly
+# lowered.
+../../glsl_test optpass --quiet --input-ir 'do_lower_jumps(0, 0, 1, 0, 1)' <<EOF
+((declare (out) float a) (declare (out) float b)
+ (function main
+  (signature void (parameters)
+   ((loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000))) (return)))
+    (assign (x) (var_ref b) (constant float (2.000000)))))))
+EOF
diff --git a/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test.expected b/src/glsl/tests/lower_jumps/return_void_at_end_of_loop_lower_return_and_break.opt_test.expected
new file mode 100644 (file)
index 0000000..53814ea
--- /dev/null
@@ -0,0 +1,11 @@
+((declare (out) float a) (declare (out) float b)
+ (function main
+  (signature void (parameters)
+   ((declare (temporary) bool return_flag)
+    (assign (x) (var_ref return_flag) (constant bool (0)))
+    (loop () () () ()
+     ((assign (x) (var_ref a) (constant float (1.000000)))
+      (assign (x) (var_ref return_flag) (constant bool (1)))
+      break))
+    (if (var_ref return_flag) ()
+     ((assign (x) (var_ref b) (constant float (2.000000)))))))))
diff --git a/src/glsl/tests/optimization-test b/src/glsl/tests/optimization-test
new file mode 100755 (executable)
index 0000000..0c130be
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+total=0
+pass=0
+
+echo "====== Testing optimization passes ======"
+for test in `find . -iname '*.opt_test'`; do
+    echo -n "Testing $test..."
+    (cd `dirname "$test"`; ./`basename "$test"`) > "$test.out" 2>&1
+    total=$((total+1))
+    if ./compare_ir "$test.expected" "$test.out" >/dev/null 2>&1; then
+        echo "PASS"
+        pass=$((pass+1))
+    else
+        echo "FAIL"
+        ./compare_ir "$test.expected" "$test.out"
+    fi
+done
+
+echo ""
+echo "$pass/$total tests returned correct results"
+echo ""
+
+if [[ $pass == $total ]]; then
+    exit 0
+else
+    exit 1
+fi
diff --git a/src/glsl/tests/sexps.py b/src/glsl/tests/sexps.py
new file mode 100644 (file)
index 0000000..a714af8
--- /dev/null
@@ -0,0 +1,103 @@
+# coding=utf-8
+#
+# Copyright Â© 2011 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.
+
+# This file contains helper functions for manipulating sexps in Python.
+#
+# We represent a sexp in Python using nested lists containing strings.
+# So, for example, the sexp (constant float (1.000000)) is represented
+# as ['constant', 'float', ['1.000000']].
+
+import re
+
+def check_sexp(sexp):
+    """Verify that the argument is a proper sexp.
+
+    That is, raise an exception if the argument is not a string or a
+    list, or if it contains anything that is not a string or a list at
+    any nesting level.
+    """
+    if isinstance(sexp, list):
+        for s in sexp:
+            check_sexp(s)
+    elif not isinstance(sexp, basestring):
+        raise Exception('Not a sexp: {0!r}'.format(sexp))
+
+def parse_sexp(sexp):
+    """Convert a string, of the form that would be output by mesa,
+    into a sexp represented as nested lists containing strings.
+    """
+    sexp_token_regexp = re.compile(
+        '[a-zA-Z_]+(@[0-9]+)?|[0-9]+(\\.[0-9]+)?|[^ \n]')
+    stack = [[]]
+    for match in sexp_token_regexp.finditer(sexp):
+        token = match.group(0)
+        if token == '(':
+            stack.append([])
+        elif token == ')':
+            if len(stack) == 1:
+                raise Exception('Unmatched )')
+            sexp = stack.pop()
+            stack[-1].append(sexp)
+        else:
+            stack[-1].append(token)
+    if len(stack) != 1:
+        raise Exception('Unmatched (')
+    if len(stack[0]) != 1:
+        raise Exception('Multiple sexps')
+    return stack[0][0]
+
+def sexp_to_string(sexp):
+    """Convert a sexp, represented as nested lists containing strings,
+    into a single string of the form parseable by mesa.
+    """
+    if isinstance(sexp, basestring):
+        return sexp
+    assert isinstance(sexp, list)
+    result = ''
+    for s in sexp:
+        sub_result = sexp_to_string(s)
+        if result == '':
+            result = sub_result
+        elif '\n' not in result and '\n' not in sub_result and \
+                len(result) + len(sub_result) + 1 <= 70:
+            result += ' ' + sub_result
+        else:
+            result += '\n' + sub_result
+    return '({0})'.format(result.replace('\n', '\n '))
+
+def sort_decls(sexp):
+    """Sort all toplevel variable declarations in sexp.
+
+    This is used to work around the fact that
+    ir_reader::read_instructions reorders declarations.
+    """
+    assert isinstance(sexp, list)
+    decls = []
+    other_code = []
+    for s in sexp:
+        if isinstance(s, list) and len(s) >= 4 and s[0] == 'declare':
+            decls.append(s)
+        else:
+            other_code.append(s)
+    return sorted(decls) + other_code
+
diff --git a/src/glut/beos/Makefile b/src/glut/beos/Makefile
deleted file mode 100644 (file)
index a9f8684..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-# Makefile for GLUT
-#
-# NOTICE:  The OpenGL Utility Toolkit (GLUT) distribution contains source
-# code published in a book titled "Programming OpenGL for the X Window
-# System" (ISBN: 0-201-48359-9) published by Addison-Wesley.  The
-# programs and associated files contained in the distribution were
-# developed by Mark J. Kilgard and are Copyright 1994, 1995, 1996 by Mark
-# J. Kilgard (unless otherwise noted).  The programs are not in the
-# public domain, but they are freely distributable without licensing
-# fees.  These programs are provided without guarantee or warrantee
-# expressed or implied.
-#
-# GLUT source included with Mesa with permission from Mark Kilgard.
-
-# src/glut/beos/Makefile
-
-TOP = ../../..
-include $(TOP)/configs/current
-
-GLUT_MAJOR = 3
-GLUT_MINOR = 7
-GLUT_TINY = 1
-
-CPP_SOURCES = \
-       glutBlocker.cpp \
-       glutInit.cpp \
-       glutWindow.cpp \
-       glutEvent.cpp \
-       glutCallback.cpp \
-       glutOverlay.cpp \
-       glutGet.cpp \
-       glutColor.cpp \
-       glutCursor.cpp \
-       glutMenu.cpp \
-       glutDstr.cpp \
-       beos_x11.cpp
-
-C_SOURCES = \
-       glut_8x13.c \
-       glut_9x15.c \
-       glut_bitmap.c \
-       glut_bwidth.c \
-       glut_hel10.c \
-       glut_hel12.c \
-       glut_hel18.c \
-       glut_tr10.c \
-       glut_tr24.c \
-       glut_mroman.c \
-       glut_roman.c \
-       glut_stroke.c \
-       glut_swidth.c \
-       glut_shapes.c \
-       glut_teapot.c \
-       glut_vidresize.c \
-       glut_util.c \
-       glut_ext.c
-
-OBJECTS = \
-       $(CPP_SOURCES:.cpp=.o) \
-       $(C_SOURCES:.c=.o)
-
-INCLUDES = \
-       -I. \
-       -I- \
-       -I$(TOP)/include
-
-# Rules
-
-.cpp.o:
-       $(CC) -c $< $(INCLUDES) $(CFLAGS) $(GLUT_CFLAGS) -o $@
-
-.c.o:
-       $(CC) -c $< $(INCLUDES) $(CFLAGS) $(GLUT_CFLAGS) -o $@
-
-
-# ---- TARGETS
-
-default: $(TOP)/$(LIB_DIR) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
-
-# Create the lib directory if missing
-$(TOP)/$(LIB_DIR):
-       mkdir $(TOP)/$(LIB_DIR)
-
-# Make the library
-$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       @$(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-               -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
-               -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
-               $(GLUT_LIB_DEPS) $(OBJECTS)
-
-clean:
-       -rm -f *.o
-
-depend: $(SOURCES)
-       rm -f depend
-       touch depend
-       $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) > /dev/null 
-
-include depend
diff --git a/src/glut/beos/beos_x11.cpp b/src/glut/beos/beos_x11.cpp
deleted file mode 100644 (file)
index 4f7ec48..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-
-/* Copyright (c) Nate Robins, 1997. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include <Screen.h>
-#include <stdio.h>
-#include "beos_x11.h"
-
-/* NOTE:  These functions require a BApplication to be instantiated first */
-int DisplayWidth() {
-       BScreen s;
-       return s.Frame().IntegerWidth() + 1;
-}
-
-int DisplayHeight() {
-       BScreen s;
-       return s.Frame().IntegerHeight() + 1;
-}
-
-/* the following function was stolen from the X sources as indicated. */
-
-/* Copyright   Massachusetts Institute of Technology  1985, 1986, 1987 */
-
-/*
-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 M.I.T. not be used in advertising or
-publicity pertaining to distribution of the software without specific,
-written prior permission.  M.I.T. makes no representations about the
-suitability of this software for any purpose.  It is provided "as is"
-without express or implied warranty.
-*/
-
-#if 0  // Not used currently...
-
-/* 
- *Returns pointer to first char ins search which is also in what, else NULL.
- */
-static char *strscan (char *search, char *what)
-{
-       int i, len = strlen (what);
-       char c;
-
-       while ((c = *(search++))) {
-               for (i = 0; i < len; i++)
-                       if (c == what [i])
-                               return (--search);
-       }
-       return (NULL);
-}
-
-#endif
-
-/*
- *    XParseGeometry parses strings of the form
- *   "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
- *   width, height, xoffset, and yoffset are unsigned integers.
- *   Example:  "=80x24+300-49"
- *   The equal sign is optional.
- *   It returns a bitmask that indicates which of the four values
- *   were actually found in the string.  For each value found,
- *   the corresponding argument is updated;  for each value
- *   not found, the corresponding argument is left unchanged. 
- */
-
-static int
-ReadInteger(char *string, char **NextString)
-{
-    register int Result = 0;
-    int Sign = 1;
-    
-    if (*string == '+')
-       string++;
-    else if (*string == '-')
-    {
-       string++;
-       Sign = -1;
-    }
-    for (; (*string >= '0') && (*string <= '9'); string++)
-    {
-       Result = (Result * 10) + (*string - '0');
-    }
-    *NextString = string;
-    if (Sign >= 0)
-       return (Result);
-    else
-       return (-Result);
-}
-
-int XParseGeometry (char *string, int *x, int *y, 
-                                       unsigned int *width, unsigned int *height)
-{
-       int mask = NoValue;
-       register char *strind;
-       unsigned int tempWidth=0, tempHeight=0;
-       int tempX=0, tempY=0;
-       char *nextCharacter;
-
-       if ( (string == NULL) || (*string == '\0')) return(mask);
-       if (*string == '=')
-               string++;  /* ignore possible '=' at beg of geometry spec */
-
-       strind = (char *)string;
-       if (*strind != '+' && *strind != '-' && *strind != 'x') {
-               tempWidth = ReadInteger(strind, &nextCharacter);
-               if (strind == nextCharacter) 
-                   return (0);
-               strind = nextCharacter;
-               mask |= WidthValue;
-       }
-
-       if (*strind == 'x' || *strind == 'X') { 
-               strind++;
-               tempHeight = ReadInteger(strind, &nextCharacter);
-               if (strind == nextCharacter)
-                   return (0);
-               strind = nextCharacter;
-               mask |= HeightValue;
-       }
-
-       if ((*strind == '+') || (*strind == '-')) {
-               if (*strind == '-') {
-                       strind++;
-                       tempX = -ReadInteger(strind, &nextCharacter);
-                       if (strind == nextCharacter)
-                           return (0);
-                       strind = nextCharacter;
-                       mask |= XNegative;
-
-               }
-               else
-               {       strind++;
-                       tempX = ReadInteger(strind, &nextCharacter);
-                       if (strind == nextCharacter)
-                           return(0);
-                       strind = nextCharacter;
-               }
-               mask |= XValue;
-               if ((*strind == '+') || (*strind == '-')) {
-                       if (*strind == '-') {
-                               strind++;
-                               tempY = -ReadInteger(strind, &nextCharacter);
-                               if (strind == nextCharacter)
-                                   return(0);
-                               strind = nextCharacter;
-                               mask |= YNegative;
-
-                       }
-                       else
-                       {
-                               strind++;
-                               tempY = ReadInteger(strind, &nextCharacter);
-                               if (strind == nextCharacter)
-                                   return(0);
-                               strind = nextCharacter;
-                       }
-                       mask |= YValue;
-               }
-       }
-       
-       /* If strind isn't at the end of the string the it's an invalid
-               geometry specification. */
-
-       if (*strind != '\0') return (0);
-
-       if (mask & XValue)
-           *x = tempX;
-       if (mask & YValue)
-           *y = tempY;
-       if (mask & WidthValue)
-            *width = tempWidth;
-       if (mask & HeightValue)
-            *height = tempHeight;
-       return (mask);
-}
diff --git a/src/glut/beos/beos_x11.h b/src/glut/beos/beos_x11.h
deleted file mode 100644 (file)
index 966dddd..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __beos_x11_h__
-#define __beos_x11_h__
-
-/* Copyright (c) Nate Robins, 1997. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-/* 
- * Bitmask returned by XParseGeometry().  Each bit tells if the corresponding
- * value (x, y, width, height) was found in the parsed string.
-*/
-#define NoValue                0x0000
-#define XValue         0x0001
-#define YValue         0x0002
-#define WidthValue     0x0004
-#define HeightValue    0x0008
-#define AllValues      0x000F
-#define XNegative      0x0010
-#define YNegative      0x0020
-
-/* Function prototypes. */
-
-extern int DisplayWidth();
-extern int DisplayHeight();
-
-extern int XParseGeometry(
-  char* string,
-  int* x, int* y, 
-  unsigned int* width, unsigned int* height);
-
-#endif /* __beos_x11_h__ */
diff --git a/src/glut/beos/glutBlocker.cpp b/src/glut/beos/glutBlocker.cpp
deleted file mode 100644 (file)
index aa94852..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/***********************************************************
- *     Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *  FILE:      glutBlocker.cpp
- *
- *     DESCRIPTION:    helper class for GLUT event loop.
- *             if a window receives an event, wake up the event loop.
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include "glutBlocker.h"
-
-/***********************************************************
- *     Global variable
- ***********************************************************/
-GlutBlocker gBlock;
-
-/***********************************************************
- *     Member functions
- ***********************************************************/
-GlutBlocker::GlutBlocker() {
-       gSem = create_sem(1, "gSem");
-       eSem = create_sem(0, "eSem");
-       events = false;
-       sleeping = false;
-}
-
-GlutBlocker::~GlutBlocker() {
-       delete_sem(eSem);
-       delete_sem(gSem);
-}
-
-void GlutBlocker::WaitEvent() {
-       acquire_sem(gSem);
-       if(!events) {                   // wait for new event
-               sleeping = true;
-               release_sem(gSem);
-               acquire_sem(eSem);      // next event will release eSem
-       } else {
-               release_sem(gSem);
-       }
-}
-
-void GlutBlocker::WaitEvent(bigtime_t usecs) {
-       acquire_sem(gSem);
-       if(!events) {                   // wait for new event
-               sleeping = true;
-               release_sem(gSem);
-               acquire_sem_etc(eSem, 1, B_TIMEOUT, usecs);     // wait for next event or timeout
-       } else {
-               release_sem(gSem);
-       }
-}
-
-void GlutBlocker::NewEvent() {
-       acquire_sem(gSem);
-       events = true;          // next call to WaitEvent returns immediately
-       if(sleeping) {
-               sleeping = false;
-               release_sem(eSem);      // if event loop is blocking, wake it up
-       }
-       release_sem(gSem);
-}
diff --git a/src/glut/beos/glutBlocker.h b/src/glut/beos/glutBlocker.h
deleted file mode 100644 (file)
index fc9e4cc..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *  FILE:      glutBlocker.h
- *
- *     DESCRIPTION:    helper class for GLUT event loop.
- *             if a window receives an event, wake up the event loop.
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <kernel/OS.h>
-
-/***********************************************************
- *     CLASS:  GlutBlocker
- *
- *     DESCRIPTION:  Fairly naive, but safe implementation.
- *             global semaphore controls access to state
- *             event semaphore blocks WaitEvent() call if necessary
- *             (this is basically a condition variable class)
- ***********************************************************/
-class GlutBlocker {
-public:
-       GlutBlocker();
-       ~GlutBlocker();
-       void WaitEvent();               // wait for new event
-       void WaitEvent(bigtime_t usecs);        // wait with timeout
-       void NewEvent();                // new event from a window (may need to wakeup main thread)
-       void QuickNewEvent() { events = true; } // new event from main thread
-       void ClearEvents() { events = false; }          // clear counter at beginning of event loop
-       bool PendingEvent() { return events; }          // XPending() equivalent
-private:
-       sem_id gSem;
-       sem_id eSem;
-       bool events;    // are there any new events?
-       bool sleeping;  // is someone sleeping on eSem?
-};
-
-/***********************************************************
- *     Global variable
- ***********************************************************/
-extern GlutBlocker gBlock;
diff --git a/src/glut/beos/glutCallback.cpp b/src/glut/beos/glutCallback.cpp
deleted file mode 100644 (file)
index cf3daaa..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutCallback.cpp
- *
- *     DESCRIPTION:    put all the callback setting routines in
- *             one place
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include "glutint.h"
-#include "glutState.h"
-
-/***********************************************************
- *     Window related callbacks
- ***********************************************************/
-void APIENTRY 
-glutDisplayFunc(GLUTdisplayCB displayFunc)
-{
-  /* XXX Remove the warning after GLUT 3.0. */
-  if (!displayFunc)
-    __glutFatalError("NULL display callback not allowed in GLUT 3.0; update your code.");
-  gState.currentWindow->display = displayFunc;
-}
-
-void APIENTRY 
-glutKeyboardFunc(GLUTkeyboardCB keyboardFunc)
-{
-  gState.currentWindow->keyboard = keyboardFunc;
-}
-
-void APIENTRY 
-glutSpecialFunc(GLUTspecialCB specialFunc)
-{
-  gState.currentWindow->special = specialFunc;
-}
-
-void APIENTRY 
-glutMouseFunc(GLUTmouseCB mouseFunc)
-{
-  gState.currentWindow->mouse = mouseFunc;
-}
-
-void APIENTRY 
-glutMotionFunc(GLUTmotionCB motionFunc)
-{
-  gState.currentWindow->motion = motionFunc;
-}
-
-void APIENTRY 
-glutPassiveMotionFunc(GLUTpassiveCB passiveMotionFunc)
-{
-  gState.currentWindow->passive = passiveMotionFunc;
-}
-
-void APIENTRY 
-glutEntryFunc(GLUTentryCB entryFunc)
-{
-  gState.currentWindow->entry = entryFunc;
-  if (!entryFunc) {
-    gState.currentWindow->entryState = -1;
-  }
-}
-
-void APIENTRY
-glutWindowStatusFunc(GLUTwindowStatusCB windowStatusFunc)
-{
-  gState.currentWindow->windowStatus = windowStatusFunc;
-}
-
-static void
-visibilityHelper(int status)
-{
-  if (status == GLUT_HIDDEN || status == GLUT_FULLY_COVERED)
-    gState.currentWindow->visibility(GLUT_NOT_VISIBLE);
-  else
-    gState.currentWindow->visibility(GLUT_VISIBLE);
-}
-
-void APIENTRY 
-glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
-{
-  gState.currentWindow->visibility = visibilityFunc;
-  if (visibilityFunc)
-    glutWindowStatusFunc(visibilityHelper);
-  else
-    glutWindowStatusFunc(NULL);
-}
-
-void APIENTRY 
-glutReshapeFunc(GLUTreshapeCB reshapeFunc)
-{
-  if (reshapeFunc) {
-    gState.currentWindow->reshape = reshapeFunc;
-  } else {
-    gState.currentWindow->reshape = __glutDefaultReshape;
-  }
-}
-
-/***********************************************************
- *     General callbacks (timer callback in glutEvent.cpp)
- ***********************************************************/
-/* DEPRICATED, use glutMenuStatusFunc instead. */
-void APIENTRY
-glutMenuStateFunc(GLUTmenuStateCB menuStateFunc)
-{
-  gState.menuStatus = (GLUTmenuStatusCB) menuStateFunc;
-}
-
-void APIENTRY
-glutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc)
-{
-  gState.menuStatus = menuStatusFunc;
-}
-
-void APIENTRY
-glutIdleFunc(GLUTidleCB idleFunc)
-{
-  gState.idle = idleFunc;
-}
-
-/***********************************************************
- *     Unsupported callbacks
- ***********************************************************/
-void APIENTRY
-glutOverlayDisplayFunc(GLUTdisplayCB displayFunc)
-{
-}
-
-void APIENTRY
-glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc)
-{
-}
-
-void APIENTRY
-glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc)
-{
-}
-
-void APIENTRY
-glutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc)
-{
-}
-
-void APIENTRY
-glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc)
-{
-}
-
-void APIENTRY
-glutDialsFunc(GLUTdialsCB dialsFunc)
-{
-}
-
-void APIENTRY
-glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc)
-{
-}
-
-void APIENTRY
-glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc)
-{
-}
diff --git a/src/glut/beos/glutColor.cpp b/src/glut/beos/glutColor.cpp
deleted file mode 100644 (file)
index d9f7739..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutColor.cpp
- *
- *     DESCRIPTION:    we don't support indexed color, so this code is
- *             really simple
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include "glutint.h"
-
-void glutSetColor(int cell, GLfloat red, GLfloat green, GLfloat blue) {
-       __glutWarning("glutSetColor: current window is RGBA");
-}
-
-GLfloat glutGetColor(int cell, int component) {
-       __glutWarning("glutGetColor: current window is RGBA");
-       return -1.0;
-}
-
-void glutCopyColormap(int win) {
-       __glutWarning("glutCopyColormap: color index not supported in BeOS");
-}
diff --git a/src/glut/beos/glutCursor.cpp b/src/glut/beos/glutCursor.cpp
deleted file mode 100644 (file)
index 3081fff..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutCursor.cpp
- *
- *     DESCRIPTION:    code for handling custom mouse cursors
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include "glutint.h"
-#include "glutState.h"
-#include "glutCursors.h"
-
-static const unsigned char *cursorTable[] = {
-  XC_arrow,              /* GLUT_CURSOR_RIGHT_ARROW */
-  XC_top_left_arrow,     /* GLUT_CURSOR_LEFT_ARROW */
-  XC_hand1,              /* GLUT_CURSOR_INFO */
-  XC_pirate,             /* GLUT_CURSOR_DESTROY */
-  XC_question_arrow,     /* GLUT_CURSOR_HELP */
-  XC_exchange,           /* GLUT_CURSOR_CYCLE */
-  XC_spraycan,           /* GLUT_CURSOR_SPRAY */
-  XC_watch,              /* GLUT_CURSOR_WAIT */
-  XC_xterm,              /* GLUT_CURSOR_TEXT */
-  XC_crosshair,                  /* GLUT_CURSOR_CROSSHAIR */
-  XC_sb_v_double_arrow,          /* GLUT_CURSOR_UP_DOWN */
-  XC_sb_h_double_arrow,          /* GLUT_CURSOR_LEFT_RIGHT */
-  XC_top_side,           /* GLUT_CURSOR_TOP_SIDE */
-  XC_bottom_side,        /* GLUT_CURSOR_BOTTOM_SIDE */
-  XC_left_side,                  /* GLUT_CURSOR_LEFT_SIDE */
-  XC_right_side,         /* GLUT_CURSOR_RIGHT_SIDE */
-  XC_top_left_corner,    /* GLUT_CURSOR_TOP_LEFT_CORNER */
-  XC_top_right_corner,   /* GLUT_CURSOR_TOP_RIGHT_CORNER */
-  XC_bottom_right_corner, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
-  XC_bottom_left_corner,  /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
-};
-
-/***********************************************************
- *     FUNCTION:       glutSetCursor (4.13)
- *
- *     DESCRIPTION:  set a new mouse cursor for current window
- ***********************************************************/
-void glutSetCursor(int cursor) {
-       gState.currentWindow->Window()->Lock();
-       gState.currentWindow->cursor = cursor;
-       __glutSetCursor(cursor);
-       gState.currentWindow->Window()->Unlock();
-}
-
-/***********************************************************
- *     FUNCTION:       __glutSetCursor
- *
- *     DESCRIPTION:  the actual cursor changing routine
- ***********************************************************/
-void __glutSetCursor(int cursor) {
-       int realcursor = cursor;
-       if (cursor < 0 || cursor > GLUT_CURSOR_BOTTOM_LEFT_CORNER) {
-               switch(cursor) {
-               case GLUT_CURSOR_INHERIT:
-                       return;         // don't change cursor
-               case GLUT_CURSOR_NONE:
-                       // this hides the cursor until the user moves the mouse
-                       // change it to HideCursor() AT YOUR OWN RISK!
-                       be_app->ObscureCursor();
-                       return;
-               case GLUT_CURSOR_FULL_CROSSHAIR:
-                       realcursor = GLUT_CURSOR_CROSSHAIR;
-                       break;
-               default:
-                       __glutWarning("unknown cursor\n");
-                       return;
-               }
-       }
-       be_app->SetCursor(cursorTable[realcursor]);
-}
-
-/***********************************************************
- *     FUNCTION:       glutWarpPointer (x.xx)
- *
- *     DESCRIPTION:  move the mouse pointer to a new location
- *             (note:  can't do this in BeOS!)
- ***********************************************************/
-void glutWarpPointer(int x, int y) { }
diff --git a/src/glut/beos/glutCursors.h b/src/glut/beos/glutCursors.h
deleted file mode 100644 (file)
index 59f6951..0000000
+++ /dev/null
@@ -1,3083 +0,0 @@
-/* cursors.h:  X Window standard cursor shapes */
-/* Generated by bdftobcursor */
-
-const unsigned char XC_X_cursor[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 9,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x70, 0xe,
-       0x78, 0x1e,
-       0x7c, 0x3e,
-       0x3e, 0x7c,
-       0x1f, 0xf8,
-       0xf, 0xf0,
-       0x7, 0xe0,
-       0x7, 0xe0,
-       0xf, 0xf0,
-       0x1f, 0xf8,
-       0x3e, 0x7c,
-       0x7c, 0x3e,
-       0x78, 0x1e,
-       0x70, 0xe,
-       0x0, 0x0,
-       /* mask */
-       0xf0, 0xf,
-       0xf8, 0x1f,
-       0xfc, 0x3f,
-       0xfe, 0x7f,
-       0x7f, 0xfe,
-       0x3f, 0xfc,
-       0x1f, 0xf8,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0x1f, 0xf8,
-       0x3f, 0xfc,
-       0x7f, 0xfe,
-       0xfe, 0x7f,
-       0xfc, 0x3f,
-       0xf8, 0x1f,
-       0xf0, 0xf,
-};
-
-const unsigned char XC_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 2,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x60, 0x0,
-       0x78, 0x0,
-       0x3e, 0x0,
-       0x3f, 0x80,
-       0x1f, 0xe0,
-       0x1f, 0xf8,
-       0xf, 0x80,
-       0xf, 0xc0,
-       0x6, 0xe0,
-       0x6, 0x70,
-       0x2, 0x38,
-       0x2, 0x1c,
-       0x0, 0xe,
-       0x0, 0x4,
-       0x0, 0x0,
-       /* mask */
-       0xe0, 0x0,
-       0xf8, 0x0,
-       0xfe, 0x0,
-       0x7f, 0x80,
-       0x7f, 0xe0,
-       0x3f, 0xf8,
-       0x3f, 0xfc,
-       0x1f, 0xfc,
-       0x1f, 0xe0,
-       0xf, 0xf0,
-       0xf, 0xf8,
-       0x7, 0x7c,
-       0x7, 0x3e,
-       0x2, 0x1f,
-       0x0, 0xe,
-       0x0, 0x4,
-};
-
-const unsigned char XC_based_arrow_down[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       12, 9,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0xf, 0xf0,
-       0x0, 0x0,
-       0xf, 0xf0,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x5, 0xa0,
-       0x3, 0xc0,
-       0x1, 0x80,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0x7, 0xe0,
-       0x3, 0xc0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_based_arrow_up[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       12, 9,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x1, 0x80,
-       0x3, 0xc0,
-       0x5, 0xa0,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0xf, 0xf0,
-       0x0, 0x0,
-       0xf, 0xf0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x1, 0x80,
-       0x3, 0xc0,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_boat[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 2,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x80,
-       0x3, 0xe0,
-       0x6, 0x11,
-       0xff, 0xff,
-       0x18, 0x0,
-       0x4, 0x0,
-       0x2, 0x0,
-       0x3, 0xff,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0xe0,
-       0x3, 0xf0,
-       0x7, 0xf9,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x1f, 0xff,
-       0x7, 0xff,
-       0x3, 0xff,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_bogosity[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x38, 0x8e,
-       0x8, 0x88,
-       0x8, 0x88,
-       0x8, 0x88,
-       0x3f, 0xfe,
-       0x28, 0x8a,
-       0x28, 0x8a,
-       0x28, 0x8a,
-       0x28, 0x8a,
-       0x3f, 0xfe,
-       0x8, 0x88,
-       0x8, 0x88,
-       0x8, 0x88,
-       0x38, 0x8e,
-       0x0, 0x0,
-       /* mask */
-       0x7d, 0xdf,
-       0x7d, 0xdf,
-       0x7d, 0xdf,
-       0x1d, 0xdc,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7d, 0xdf,
-       0x7d, 0xdf,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x1d, 0xdc,
-       0x7d, 0xdf,
-       0x7d, 0xdf,
-       0x7d, 0xdf,
-};
-
-const unsigned char XC_bottom_left_corner[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       14, 15, /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x6,
-       0x0, 0x6,
-       0x10, 0x46,
-       0x8, 0x46,
-       0x4, 0x46,
-       0x2, 0x46,
-       0x1, 0x46,
-       0x0, 0xc6,
-       0x1f, 0xc6,
-       0x0, 0x6,
-       0x0, 0x6,
-       0x0, 0x6,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0xf,
-       0x0, 0xf,
-       0x30, 0xef,
-       0x38, 0xef,
-       0x1c, 0xef,
-       0xe, 0xef,
-       0x7, 0xef,
-       0x3, 0xef,
-       0x3f, 0xef,
-       0x3f, 0xef,
-       0x3f, 0xef,
-       0x0, 0xf,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-};
-
-const unsigned char XC_bottom_right_corner[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       14, 2,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x60, 0x0,
-       0x60, 0x0,
-       0x62, 0x8,
-       0x62, 0x10,
-       0x62, 0x20,
-       0x62, 0x40,
-       0x62, 0x80,
-       0x63, 0x0,
-       0x63, 0xf8,
-       0x60, 0x0,
-       0x60, 0x0,
-       0x60, 0x0,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x0, 0x0,
-       /* mask */
-       0xf0, 0x0,
-       0xf0, 0x0,
-       0xf7, 0xc,
-       0xf7, 0x1c,
-       0xf7, 0x38,
-       0xf7, 0x70,
-       0xf7, 0xe0,
-       0xf7, 0xc0,
-       0xf7, 0xfc,
-       0xf7, 0xfc,
-       0xf7, 0xfc,
-       0xf0, 0x0,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-};
-
-const unsigned char XC_bottom_side[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       14, 8,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x8, 0x88,
-       0x4, 0x90,
-       0x2, 0xa0,
-       0x1, 0xc0,
-       0x0, 0x80,
-       0x0, 0x0,
-       0x3f, 0xfe,
-       0x3f, 0xfe,
-       0x0, 0x0,
-       /* mask */
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x19, 0xcc,
-       0x1d, 0xdc,
-       0xf, 0xf8,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-};
-
-const unsigned char XC_bottom_tee[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       12, 8,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_box_spiral[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 7,   /* y,x of hotspot */
-       /* data */
-       0xff, 0xff,
-       0x0, 0x1,
-       0x7f, 0xfd,
-       0x40, 0x5,
-       0x5f, 0xf5,
-       0x50, 0x15,
-       0x57, 0xd5,
-       0x54, 0x55,
-       0x55, 0x55,
-       0x55, 0xd5,
-       0x54, 0x15,
-       0x57, 0xf5,
-       0x50, 0x5,
-       0x5f, 0xfd,
-       0x40, 0x1,
-       0x7f, 0xff,
-       /* mask */
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-};
-
-const unsigned char XC_center_ptr[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 9,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x81, 0x80,
-       0x1, 0x80,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x7, 0xe0,
-       0x7, 0xe0,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0x19, 0x98,
-       0x11, 0x88,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x83, 0xc0,
-       0x3, 0xc0,
-       0x7, 0xe0,
-       0x7, 0xe0,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3b, 0xdc,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-};
-
-const unsigned char XC_circle[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x3, 0xc0,
-       0xf, 0xf0,
-       0x1f, 0xf8,
-       0x3c, 0x3c,
-       0x38, 0x1c,
-       0x70, 0xe,
-       0x70, 0xe,
-       0x70, 0xe,
-       0x70, 0xe,
-       0x38, 0x1c,
-       0x3c, 0x3c,
-       0x1f, 0xf8,
-       0xf, 0xf0,
-       0x3, 0xc0,
-       0x0, 0x0,
-       /* mask */
-       0x7, 0xe0,
-       0x1f, 0xf8,
-       0x3f, 0xfc,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0xfc, 0x3f,
-       0xf8, 0x1f,
-       0xf8, 0x1f,
-       0xf8, 0x1f,
-       0xf8, 0x1f,
-       0xfc, 0x3f,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x3f, 0xfc,
-       0x1f, 0xf8,
-       0x7, 0xe0,
-};
-
-const unsigned char XC_clock[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       3, 9,   /* y,x of hotspot */
-       /* data */
-       0x1f, 0xf8,
-       0x33, 0xcc,
-       0x66, 0x26,
-       0x49, 0x92,
-       0x48, 0xf2,
-       0x44, 0x22,
-       0x63, 0xc6,
-       0x3f, 0xfc,
-       0x29, 0x94,
-       0x29, 0x94,
-       0x29, 0x94,
-       0x2b, 0xd4,
-       0x69, 0x96,
-       0x78, 0x1e,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       /* mask */
-       0x1f, 0xfe,
-       0x39, 0xf7,
-       0x77, 0xdb,
-       0x6d, 0xed,
-       0x6f, 0xfd,
-       0x66, 0xf9,
-       0x73, 0xf3,
-       0x3f, 0xff,
-       0x35, 0xeb,
-       0x35, 0xeb,
-       0x35, 0xeb,
-       0x37, 0xfb,
-       0x75, 0xeb,
-       0x7c, 0xcf,
-       0x7f, 0xff,
-       0x7f, 0xff,
-};
-
-const unsigned char XC_coffee_mug[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       9, 8,   /* y,x of hotspot */
-       /* data */
-       0x8f, 0xf8,
-       0x10, 0x4,
-       0x60, 0x6,
-       0x58, 0xa,
-       0x47, 0xf2,
-       0x40, 0x3,
-       0x40, 0x3,
-       0x40, 0x2,
-       0x40, 0x2,
-       0x58, 0x9a,
-       0x55, 0x56,
-       0x55, 0xd7,
-       0x59, 0x5b,
-       0x40, 0x2,
-       0x40, 0x2,
-       0x3f, 0xfc,
-       /* mask */
-       0xf, 0xf8,
-       0x1f, 0xfc,
-       0xff, 0xfe,
-       0xff, 0xfe,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xfe,
-       0xff, 0xfe,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xfe,
-       0x3f, 0xfc,
-};
-
-const unsigned char XC_cross[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 9,   /* y,x of hotspot */
-       /* data */
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0xff, 0x7f,
-       0x0, 0x0,
-       0xff, 0x7f,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x0, 0x0,
-       /* mask */
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-};
-
-const unsigned char XC_cross_reverse[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 9,   /* y,x of hotspot */
-       /* data */
-       0x21, 0x42,
-       0x51, 0x45,
-       0x29, 0x4a,
-       0x15, 0x54,
-       0xb, 0x68,
-       0x5, 0x50,
-       0xfe, 0xbf,
-       0x1, 0x40,
-       0xfe, 0xbf,
-       0x5, 0x50,
-       0xb, 0x68,
-       0x15, 0x54,
-       0x29, 0x4a,
-       0x51, 0x45,
-       0x21, 0x42,
-       0x0, 0x0,
-       /* mask */
-       0x33, 0x66,
-       0xdb, 0x6d,
-       0x6f, 0x7b,
-       0x37, 0x76,
-       0x1b, 0x6c,
-       0xfd, 0x5f,
-       0xfe, 0x3f,
-       0x0, 0x80,
-       0xfe, 0x3f,
-       0xfd, 0x5f,
-       0x1b, 0x6c,
-       0x37, 0x76,
-       0x6f, 0x7b,
-       0xdb, 0x6d,
-       0x33, 0x66,
-       0x0, 0x0,
-};
-
-const unsigned char XC_crosshair[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 9,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0xff, 0x7f,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-};
-
-const unsigned char XC_diamond_cross[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x81, 0x40,
-       0x3, 0x60,
-       0x5, 0x50,
-       0x9, 0x48,
-       0x11, 0x44,
-       0x21, 0x42,
-       0x7f, 0x7f,
-       0x0, 0x0,
-       0x7f, 0x7f,
-       0x21, 0x42,
-       0x11, 0x44,
-       0x9, 0x48,
-       0x5, 0x50,
-       0x3, 0x60,
-       0x1, 0x40,
-       0x0, 0x0,
-       /* mask */
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0x1d, 0xdc,
-       0x39, 0xce,
-       0x71, 0xc7,
-       0xff, 0xff,
-       0xff, 0x7f,
-       0xff, 0xff,
-       0x71, 0xc7,
-       0x39, 0xce,
-       0x1d, 0xdc,
-       0xf, 0xf8,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-};
-
-const unsigned char XC_dot[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x83, 0xc0,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0xf, 0xf0,
-       0xf, 0xf0,
-       0x3, 0xc0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x87, 0xe0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x7, 0xe0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_dotbox[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x7f, 0xfc,
-       0x20, 0x4,
-       0x20, 0x4,
-       0x20, 0x4,
-       0x20, 0x4,
-       0x21, 0x84,
-       0x21, 0x84,
-       0x20, 0x4,
-       0x20, 0x4,
-       0x20, 0x4,
-       0x20, 0x4,
-       0x3f, 0xfc,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x70, 0xe,
-       0x70, 0xe,
-       0x73, 0xce,
-       0x73, 0xce,
-       0x73, 0xce,
-       0x73, 0xce,
-       0x70, 0xe,
-       0x70, 0xe,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x0, 0x0,
-};
-
-const unsigned char XC_double_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x81, 0x80,
-       0x3, 0xc0,
-       0x7, 0xe0,
-       0xd, 0xb0,
-       0x19, 0x98,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x19, 0x98,
-       0xd, 0xb0,
-       0x7, 0xe0,
-       0x3, 0xc0,
-       0x1, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x83, 0xc0,
-       0x7, 0xe0,
-       0xf, 0xf0,
-       0x1f, 0xf8,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x1f, 0xf8,
-       0xf, 0xf0,
-       0x7, 0xe0,
-       0x3, 0xc0,
-};
-
-const unsigned char XC_draft_large[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       0, 1,   /* y,x of hotspot */
-       /* data */
-       0xc0, 0x0,
-       0x30, 0x0,
-       0x3c, 0x0,
-       0x1f, 0x0,
-       0x1f, 0xc0,
-       0xf, 0xf0,
-       0xf, 0xfc,
-       0x7, 0x80,
-       0x7, 0x40,
-       0x3, 0x20,
-       0x3, 0x10,
-       0x1, 0x8,
-       0x1, 0x4,
-       0x0, 0x2,
-       0x0, 0x1,
-       0x0, 0x0,
-       /* mask */
-       0x60, 0x0,
-       0x78, 0x0,
-       0x7e, 0x0,
-       0x3f, 0x80,
-       0x1f, 0xe0,
-       0x1f, 0xf8,
-       0xf, 0xfe,
-       0xf, 0xfe,
-       0x7, 0xe0,
-       0x7, 0xf0,
-       0x3, 0xb8,
-       0x3, 0x9c,
-       0x1, 0x8e,
-       0x1, 0x87,
-       0x0, 0x3,
-       0x0, 0x1,
-};
-
-const unsigned char XC_draft_small[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       0, 1,   /* y,x of hotspot */
-       /* data */
-       0x40, 0x0,
-       0x30, 0x0,
-       0x3c, 0x0,
-       0x1f, 0x0,
-       0x1f, 0xc0,
-       0xe, 0x0,
-       0xd, 0x0,
-       0x4, 0x80,
-       0x4, 0x40,
-       0x0, 0x20,
-       0x0, 0x10,
-       0x0, 0x8,
-       0x0, 0x4,
-       0x0, 0x2,
-       0x0, 0x1,
-       0x0, 0x0,
-       /* mask */
-       0x60, 0x0,
-       0x78, 0x0,
-       0x3e, 0x0,
-       0x3f, 0x80,
-       0x1f, 0xe0,
-       0x1f, 0xe0,
-       0xf, 0x80,
-       0xf, 0xc0,
-       0x6, 0xe0,
-       0x2, 0x70,
-       0x0, 0x38,
-       0x0, 0x1c,
-       0x0, 0xe,
-       0x0, 0x7,
-       0x0, 0x3,
-       0x0, 0x0,
-};
-
-const unsigned char XC_draped_box[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x7f, 0xfc,
-       0x22, 0x44,
-       0x26, 0x64,
-       0x2c, 0x34,
-       0x38, 0x1c,
-       0x21, 0x84,
-       0x21, 0x84,
-       0x38, 0x1c,
-       0x2c, 0x34,
-       0x26, 0x64,
-       0x22, 0x44,
-       0x3f, 0xfc,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x67, 0xe6,
-       0x6f, 0xf6,
-       0x7e, 0x7e,
-       0x7d, 0xbe,
-       0x7b, 0xde,
-       0x7b, 0xde,
-       0x7d, 0xbe,
-       0x7e, 0x7e,
-       0x6f, 0xf6,
-       0x67, 0xe6,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x0, 0x0,
-};
-
-const unsigned char XC_exchange[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 9,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x7, 0xe2,
-       0xf, 0xf6,
-       0x18, 0x3e,
-       0x10, 0x12,
-       0x0, 0x32,
-       0x0, 0x7e,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x7e, 0x0,
-       0x4c, 0x0,
-       0x48, 0x8,
-       0x7c, 0x18,
-       0x6f, 0xf0,
-       0x47, 0xe0,
-       0x0, 0x0,
-       /* mask */
-       0x7, 0xe3,
-       0xf, 0xf7,
-       0x1f, 0xff,
-       0x3f, 0xff,
-       0x38, 0x3f,
-       0x30, 0xff,
-       0x0, 0xff,
-       0x0, 0xff,
-       0xff, 0x0,
-       0xff, 0x0,
-       0xfe, 0xc,
-       0xfc, 0x1c,
-       0xff, 0xfc,
-       0xff, 0xf8,
-       0xef, 0xf0,
-       0xc7, 0xe0,
-};
-
-const unsigned char XC_fleur[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x1, 0x80,
-       0x3, 0xc0,
-       0x7, 0xe0,
-       0x1, 0x80,
-       0x11, 0x88,
-       0x31, 0x8c,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x31, 0x8c,
-       0x11, 0x88,
-       0x1, 0x80,
-       0x7, 0xe0,
-       0x3, 0xc0,
-       0x1, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x3, 0xc0,
-       0x7, 0xc0,
-       0x7, 0xe0,
-       0xf, 0xf0,
-       0x17, 0xe8,
-       0x3b, 0xdc,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x3b, 0xdc,
-       0x17, 0xe8,
-       0xf, 0xf0,
-       0x7, 0xe0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-};
-
-const unsigned char XC_gobbler[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       2, 2,   /* y,x of hotspot */
-       /* data */
-       0x1e, 0x0,
-       0xe, 0x0,
-       0xcc, 0x1,
-       0xd, 0xf9,
-       0xf, 0xff,
-       0xc, 0x7f,
-       0xc, 0x3f,
-       0x1c, 0x6,
-       0xf, 0x0,
-       0x7, 0xf8,
-       0x0, 0x10,
-       0x0, 0x10,
-       0x0, 0x10,
-       0x0, 0x10,
-       0x0, 0x78,
-       0x0, 0x0,
-       /* mask */
-       0x3f, 0x0,
-       0x3f, 0x0,
-       0xff, 0x3,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x3f, 0xff,
-       0x3f, 0xff,
-       0x3f, 0xff,
-       0x3f, 0xff,
-       0x3f, 0xff,
-       0x1f, 0xfe,
-       0xf, 0xf8,
-       0x0, 0x38,
-       0x0, 0x38,
-       0x0, 0xfc,
-       0x0, 0xfc,
-};
-
-const unsigned char XC_gumby[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       0, 14,  /* y,x of hotspot */
-       /* data */
-       0x0, 0xfc,
-       0x1, 0x8,
-       0x2, 0x13,
-       0x5, 0x57,
-       0x4, 0x13,
-       0x5, 0xd3,
-       0x3c, 0x1f,
-       0xfc, 0x1c,
-       0xe4, 0x10,
-       0xe4, 0x10,
-       0xf4, 0x90,
-       0xe4, 0x90,
-       0x4, 0x90,
-       0x8, 0x88,
-       0x10, 0x84,
-       0x1f, 0x7c,
-       /* mask */
-       0x0, 0xfc,
-       0x1, 0xfb,
-       0x3, 0xf7,
-       0x7, 0xff,
-       0x7, 0xf7,
-       0x3f, 0xf7,
-       0x7f, 0xff,
-       0xff, 0xff,
-       0xf7, 0xfc,
-       0xf7, 0xf0,
-       0xff, 0xf0,
-       0xf7, 0xf0,
-       0xe7, 0xf0,
-       0xf, 0xf8,
-       0x1f, 0xfc,
-       0x1f, 0x7c,
-};
-
-const unsigned char XC_hand1[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       0, 2,   /* y,x of hotspot */
-       /* data */
-       0x30, 0x0,
-       0x3c, 0x0,
-       0xf, 0x0,
-       0x7, 0x80,
-       0x3, 0xc0,
-       0x7, 0xe0,
-       0xf, 0xf0,
-       0x7, 0xf4,
-       0xf, 0xfe,
-       0xf, 0xfa,
-       0x7, 0xe0,
-       0x3, 0xe0,
-       0x0, 0x52,
-       0x0, 0x46,
-       0x0, 0x2c,
-       0x0, 0x18,
-       /* mask */
-       0xb8, 0x0,
-       0x3e, 0x0,
-       0x1f, 0x80,
-       0xf, 0xc0,
-       0x7, 0xe0,
-       0xf, 0xf0,
-       0x1f, 0xfc,
-       0x1f, 0xfe,
-       0x1f, 0xfe,
-       0x1f, 0xfe,
-       0xf, 0xfe,
-       0x7, 0xfe,
-       0x3, 0xfe,
-       0x0, 0xfe,
-       0x0, 0x7e,
-       0x0, 0x3c,
-};
-
-const unsigned char XC_hand2[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 15,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x1, 0xfe,
-       0x2, 0x1,
-       0x4, 0x7e,
-       0x8, 0x8,
-       0x8, 0x70,
-       0x8, 0x8,
-       0x14, 0x70,
-       0x22, 0x8,
-       0x41, 0x30,
-       0x20, 0xc0,
-       0x12, 0x40,
-       0x8, 0x80,
-       0x5, 0x0,
-       0x2, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x1, 0xfe,
-       0x3, 0xff,
-       0x7, 0xff,
-       0xf, 0xff,
-       0x1f, 0xfe,
-       0x1f, 0xf8,
-       0x1f, 0xfc,
-       0x3f, 0xf8,
-       0x7f, 0xfc,
-       0xff, 0xf8,
-       0x7f, 0xf0,
-       0x3f, 0xe0,
-       0x1f, 0xc0,
-       0xf, 0x80,
-       0x7, 0x0,
-       0x2, 0x0,
-};
-
-const unsigned char XC_heart[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       9, 9,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x1f, 0x7c,
-       0x31, 0xc6,
-       0x60, 0x83,
-       0x40, 0x1,
-       0x40, 0x1,
-       0x40, 0x1,
-       0x40, 0x1,
-       0x60, 0x3,
-       0x30, 0x6,
-       0x18, 0xc,
-       0xc, 0x18,
-       0x6, 0x30,
-       0x3, 0x60,
-       0x1, 0xc0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x9f, 0x7c,
-       0x3f, 0xfe,
-       0x71, 0xc7,
-       0x60, 0x83,
-       0x60, 0x3,
-       0x60, 0x3,
-       0x61, 0x43,
-       0x70, 0x87,
-       0x38, 0xe,
-       0x1c, 0x1c,
-       0xe, 0x38,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_icon[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0xff, 0xff,
-       0xaa, 0xab,
-       0xd5, 0x55,
-       0xaa, 0xab,
-       0xd0, 0x5,
-       0xa0, 0xb,
-       0xd0, 0x5,
-       0xa0, 0xb,
-       0xd0, 0x5,
-       0xa0, 0xb,
-       0xd0, 0x5,
-       0xa0, 0xb,
-       0xd5, 0x55,
-       0xaa, 0xab,
-       0xd5, 0x55,
-       0xff, 0xff,
-       /* mask */
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-};
-
-const unsigned char XC_iron_cross[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x3f, 0xfc,
-       0x1f, 0xf8,
-       0x4f, 0xf2,
-       0x67, 0xe6,
-       0x73, 0xce,
-       0x79, 0x9e,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x79, 0x9e,
-       0x73, 0xce,
-       0x67, 0xe6,
-       0x4f, 0xf2,
-       0x1f, 0xf8,
-       0x3f, 0xfc,
-       0x0, 0x0,
-       /* mask */
-       0x3f, 0xfc,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x7f, 0xfe,
-       0x7f, 0xfe,
-       0x3f, 0xfc,
-};
-
-const unsigned char XC_left_ptr[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 12,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x10,
-       0x0, 0x30,
-       0x0, 0x70,
-       0x0, 0xf0,
-       0x1, 0xf0,
-       0x3, 0xf0,
-       0x7, 0xf0,
-       0xf, 0xf0,
-       0x1, 0xf0,
-       0x1, 0xb0,
-       0x3, 0x10,
-       0x3, 0x0,
-       0x6, 0x0,
-       0x6, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x18,
-       0x0, 0x38,
-       0x0, 0x78,
-       0x0, 0xf8,
-       0x1, 0xf8,
-       0x3, 0xf8,
-       0x7, 0xf8,
-       0xf, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x3, 0xf8,
-       0x7, 0xb8,
-       0x7, 0x98,
-       0xf, 0x0,
-       0xf, 0x0,
-       0x6, 0x0,
-};
-
-const unsigned char XC_left_side[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 15,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x6,
-       0x0, 0x6,
-       0x1, 0x6,
-       0x0, 0x86,
-       0x0, 0x46,
-       0x0, 0x26,
-       0x7f, 0xf6,
-       0x0, 0x26,
-       0x0, 0x46,
-       0x0, 0x86,
-       0x1, 0x6,
-       0x0, 0x6,
-       0x0, 0x6,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0xf,
-       0x0, 0xf,
-       0x3, 0xf,
-       0x3, 0x8f,
-       0x1, 0xcf,
-       0x0, 0xef,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x0, 0xef,
-       0x1, 0xcf,
-       0x3, 0x8f,
-       0x3, 0xf,
-       0x0, 0xf,
-       0x0, 0xf,
-       0x0, 0x0,
-};
-
-const unsigned char XC_left_tee[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 13,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x80, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-};
-
-const unsigned char XC_leftbutton[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0xc0, 0x1,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xa2, 0x22,
-       0xaa, 0xa2,
-       0xaa, 0xa2,
-       0xaa, 0xa2,
-       0xaa, 0xa2,
-       0xa2, 0x22,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xc0, 0x1,
-       /* mask */
-       0xbf, 0xfe,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x3f, 0xfe,
-};
-
-const unsigned char XC_ll_angle[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       12, 13, /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x80, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_lr_angle[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       12, 4,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x98, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_man[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       5, 2,   /* y,x of hotspot */
-       /* data */
-       0x1, 0xc0,
-       0xf, 0x78,
-       0x1, 0x40,
-       0x0, 0x81,
-       0xe1, 0xc2,
-       0xd2, 0x24,
-       0xe, 0xb8,
-       0x2, 0xa0,
-       0x2, 0x20,
-       0x1, 0x40,
-       0x2, 0x20,
-       0x4, 0x90,
-       0x9, 0x48,
-       0xa, 0x28,
-       0x3c, 0x1e,
-       0xfc, 0x1f,
-       /* mask */
-       0x7, 0xf8,
-       0xf, 0xfc,
-       0x1f, 0xfc,
-       0x41, 0xc3,
-       0xe3, 0xe7,
-       0xff, 0xfe,
-       0xdf, 0xfc,
-       0xf, 0xf8,
-       0x7, 0xe0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0x1f, 0xfc,
-       0x3f, 0x7e,
-       0xfe, 0x3f,
-       0xfe, 0x3f,
-};
-
-const unsigned char XC_middlebutton[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0xc0, 0x1,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xa2, 0x22,
-       0xaa, 0x2a,
-       0xaa, 0x2a,
-       0xaa, 0x2a,
-       0xaa, 0x2a,
-       0xa2, 0x22,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xc0, 0x1,
-       /* mask */
-       0xbf, 0xfe,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x3f, 0xfe,
-};
-
-const unsigned char XC_mouse[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       2, 11,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0xe0,
-       0x0, 0x30,
-       0x0, 0x60,
-       0x0, 0xc0,
-       0x1f, 0xfe,
-       0x20, 0x1,
-       0x6c, 0xcd,
-       0x6c, 0xcd,
-       0x6c, 0xcd,
-       0x60, 0x1,
-       0x60, 0x1,
-       0x38, 0x6,
-       0x6, 0x18,
-       0x1, 0xe0,
-       0x0, 0x0,
-       /* mask */
-       0x1, 0xf0,
-       0x0, 0x78,
-       0x0, 0xf0,
-       0x0, 0xe0,
-       0x1f, 0xfe,
-       0x3f, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xef, 0xfc,
-       0x7, 0xf8,
-       0x3, 0xf0,
-       0x1, 0xe0,
-};
-
-const unsigned char XC_pencil[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       15, 3,  /* y,x of hotspot */
-       /* data */
-       0x40, 0x38,
-       0x0, 0x44,
-       0x0, 0xc4,
-       0x1, 0x48,
-       0x1, 0x78,
-       0x2, 0x10,
-       0x2, 0x20,
-       0x4, 0x20,
-       0x4, 0x40,
-       0x8, 0xc0,
-       0x8, 0x80,
-       0x11, 0x0,
-       0x1e, 0x0,
-       0x1c, 0x0,
-       0x18, 0x0,
-       0x10, 0x0,
-       /* mask */
-       0x80, 0x7e,
-       0x0, 0xfe,
-       0x1, 0xfe,
-       0x1, 0xfc,
-       0x3, 0xf8,
-       0x3, 0xf8,
-       0x7, 0xf0,
-       0x7, 0xe0,
-       0xf, 0xe0,
-       0xf, 0xc0,
-       0x1f, 0xc0,
-       0x3f, 0x80,
-       0x3f, 0x0,
-       0x3e, 0x0,
-       0x3c, 0x0,
-       0x38, 0x0,
-};
-
-const unsigned char XC_pirate[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       12, 8,  /* y,x of hotspot */
-       /* data */
-       0x1, 0xe0,
-       0x3, 0xf0,
-       0x7, 0xf8,
-       0xc, 0xcc,
-       0xc, 0xcc,
-       0x7, 0xf8,
-       0x3, 0xf0,
-       0x1, 0xe0,
-       0x21, 0xe1,
-       0x61, 0xe1,
-       0x10, 0xc2,
-       0xe, 0x1c,
-       0x1, 0xe0,
-       0x47, 0xf8,
-       0x7c, 0xf,
-       0x20, 0x1,
-       /* mask */
-       0x3, 0xf0,
-       0x7, 0xf8,
-       0xf, 0xfc,
-       0x1f, 0xfe,
-       0x1f, 0xfe,
-       0xf, 0xfc,
-       0x7, 0xf8,
-       0x83, 0xf1,
-       0xe3, 0xf1,
-       0xf3, 0xf3,
-       0x39, 0xef,
-       0x1e, 0x1e,
-       0x1, 0xe0,
-       0xc7, 0xfe,
-       0xff, 0xff,
-       0x7c, 0xf,
-};
-
-const unsigned char XC_plus[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 9,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x81, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_question_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x83, 0xe0,
-       0x7, 0xf0,
-       0xe, 0x38,
-       0xc, 0x18,
-       0xc, 0x38,
-       0xe, 0x30,
-       0x7, 0x0,
-       0x3, 0xc0,
-       0x1, 0xc0,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x7, 0x70,
-       0x3, 0x60,
-       0x1, 0xc0,
-       0x0, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0x1f, 0xfc,
-       0x1e, 0x3c,
-       0x1e, 0x7c,
-       0x1f, 0x78,
-       0xf, 0xf0,
-       0x7, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-};
-
-const unsigned char XC_right_ptr[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 5,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x8, 0x0,
-       0xc, 0x0,
-       0xe, 0x0,
-       0xf, 0x0,
-       0xf, 0x80,
-       0xf, 0xc0,
-       0xf, 0xe0,
-       0xf, 0xf0,
-       0xf, 0x80,
-       0xd, 0x80,
-       0x8, 0xc0,
-       0x0, 0xc0,
-       0x0, 0x60,
-       0x0, 0x60,
-       0x0, 0x0,
-       /* mask */
-       0x18, 0x0,
-       0x1c, 0x0,
-       0x1e, 0x0,
-       0x1f, 0x0,
-       0x1f, 0x80,
-       0x1f, 0xc0,
-       0x1f, 0xe0,
-       0x1f, 0xf0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x1f, 0xc0,
-       0x1d, 0xe0,
-       0x19, 0xe0,
-       0x0, 0xf0,
-       0x0, 0xf0,
-       0x0, 0x60,
-};
-
-const unsigned char XC_right_side[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 2,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x60, 0x0,
-       0x60, 0x0,
-       0x60, 0x80,
-       0x61, 0x0,
-       0x62, 0x0,
-       0x64, 0x0,
-       0x6f, 0xfe,
-       0x64, 0x0,
-       0x62, 0x0,
-       0x61, 0x0,
-       0x60, 0x80,
-       0x60, 0x0,
-       0x60, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0xf0, 0x0,
-       0xf0, 0x0,
-       0xf0, 0xc0,
-       0xf1, 0xc0,
-       0xf3, 0x80,
-       0xf7, 0x0,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xf7, 0x0,
-       0xf3, 0x80,
-       0xf1, 0xc0,
-       0xf0, 0xc0,
-       0xf0, 0x0,
-       0xf0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_right_tee[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 4,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x98, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-};
-
-const unsigned char XC_rightbutton[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0xc0, 0x1,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xa2, 0x22,
-       0xa2, 0xaa,
-       0xa2, 0xaa,
-       0xa2, 0xaa,
-       0xa2, 0xaa,
-       0xa2, 0x22,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xbf, 0xfe,
-       0xc0, 0x1,
-       /* mask */
-       0xbf, 0xfe,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x3f, 0xfe,
-};
-
-const unsigned char XC_rtl_logo[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 9,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x7f, 0xfe,
-       0x44, 0x2,
-       0x44, 0x2,
-       0x44, 0x2,
-       0x47, 0xfe,
-       0x44, 0x22,
-       0x44, 0x22,
-       0x44, 0x22,
-       0x44, 0x22,
-       0x7f, 0xe2,
-       0x40, 0x22,
-       0x40, 0x22,
-       0x40, 0x22,
-       0x7f, 0xfe,
-       0x0, 0x0,
-       /* mask */
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xee, 0x7,
-       0xef, 0xff,
-       0xef, 0xff,
-       0xef, 0xff,
-       0xee, 0x77,
-       0xee, 0x77,
-       0xff, 0xf7,
-       0xff, 0xf7,
-       0xff, 0xf7,
-       0xe0, 0x77,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-};
-
-const unsigned char XC_sailboat[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       0, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x42, 0x0,
-       0x2, 0x0,
-       0x6, 0x80,
-       0x6, 0x80,
-       0x6, 0xc0,
-       0xe, 0xc0,
-       0xe, 0xe0,
-       0xe, 0xe0,
-       0x1e, 0xf0,
-       0x1e, 0xf0,
-       0x1e, 0xf8,
-       0x3e, 0xf8,
-       0x1c, 0x7c,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x3, 0x0,
-       0x7, 0x0,
-       0x7, 0x80,
-       0xf, 0xc0,
-       0xf, 0xc0,
-       0xf, 0xe0,
-       0x1f, 0xe0,
-       0x1f, 0xf0,
-       0x1f, 0xf0,
-       0x3f, 0xf8,
-       0x3f, 0xf8,
-       0x3f, 0xfc,
-       0xff, 0xfc,
-       0xff, 0xfe,
-       0x1f, 0xff,
-       0x7, 0xfe,
-};
-
-const unsigned char XC_sb_down_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       15, 8,  /* y,x of hotspot */
-       /* data */
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-       0x0, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-       0x0, 0x80,
-};
-
-const unsigned char XC_sb_h_double_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x8, 0x8,
-       0x18, 0xc,
-       0x3f, 0xfe,
-       0x78, 0xf,
-       0x3f, 0xfe,
-       0x18, 0xc,
-       0x8, 0x8,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x8c, 0x18,
-       0x1c, 0x1c,
-       0x3f, 0xfe,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x3f, 0xfe,
-       0x1c, 0x1c,
-       0xc, 0x18,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_sb_left_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 16,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x8,
-       0x0, 0xc,
-       0x7f, 0xfe,
-       0x0, 0xf,
-       0x7f, 0xfe,
-       0x0, 0xc,
-       0x0, 0x8,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x30,
-       0x0, 0x38,
-       0xff, 0xfc,
-       0xff, 0xfe,
-       0xff, 0xff,
-       0xff, 0xfe,
-       0xff, 0xfc,
-       0x0, 0x38,
-       0x0, 0x30,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_sb_right_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 0,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x8, 0x0,
-       0x18, 0x0,
-       0x3f, 0xff,
-       0x78, 0x0,
-       0x3f, 0xff,
-       0x18, 0x0,
-       0x8, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0xc, 0x0,
-       0x1c, 0x0,
-       0x3f, 0xff,
-       0x7f, 0xff,
-       0xff, 0xff,
-       0x7f, 0xff,
-       0x3f, 0xff,
-       0x1c, 0x0,
-       0xc, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_sb_up_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       0, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x80,
-       0x9, 0xc0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x80,
-       0x1, 0xc0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-};
-
-const unsigned char XC_sb_v_double_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x80,
-       0x9, 0xc0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-       0x0, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x1, 0xc0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0x3, 0xe0,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_shuttle[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       0, 5,   /* y,x of hotspot */
-       /* data */
-       0x84, 0x0,
-       0xe, 0x0,
-       0x1f, 0x0,
-       0x7b, 0x80,
-       0x7b, 0xa0,
-       0x7b, 0x90,
-       0x7b, 0x88,
-       0x7b, 0x88,
-       0x7b, 0x88,
-       0x7b, 0x88,
-       0x7b, 0x8c,
-       0x7b, 0x8e,
-       0x7b, 0xbf,
-       0x11, 0x18,
-       0x1e, 0x0,
-       0xc, 0x0,
-       /* mask */
-       0x1c, 0x0,
-       0x3e, 0x0,
-       0x7f, 0x0,
-       0xff, 0x0,
-       0xff, 0x60,
-       0xff, 0x70,
-       0xff, 0x78,
-       0xff, 0x78,
-       0xff, 0x78,
-       0xff, 0x78,
-       0xff, 0x7c,
-       0xff, 0x7e,
-       0xff, 0x7f,
-       0x7f, 0x7e,
-       0x7e, 0x30,
-       0x3c, 0x0,
-};
-
-const unsigned char XC_sizing[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x81, 0xfe,
-       0x0, 0x2,
-       0x0, 0x2,
-       0x0, 0x2,
-       0x7, 0xe2,
-       0x4, 0x22,
-       0x44, 0x22,
-       0x44, 0x22,
-       0x44, 0x20,
-       0x47, 0xe0,
-       0x48, 0x0,
-       0x50, 0x0,
-       0x60, 0x0,
-       0x7f, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x3, 0xff,
-       0x3, 0xff,
-       0x3, 0xff,
-       0x0, 0x7,
-       0xf, 0xf7,
-       0xf, 0xf7,
-       0xef, 0xf7,
-       0xee, 0x77,
-       0xee, 0x77,
-       0xef, 0xf7,
-       0xef, 0xf0,
-       0xff, 0xf0,
-       0xf8, 0x0,
-       0xff, 0xc0,
-       0xff, 0xc0,
-       0xff, 0xc0,
-};
-
-const unsigned char XC_spider[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 10,  /* y,x of hotspot */
-       /* data */
-       0x8, 0x4,
-       0x4, 0x8,
-       0x4, 0x8,
-       0x2, 0x10,
-       0x2, 0x10,
-       0xe1, 0xe1,
-       0x19, 0xe6,
-       0x7, 0xf8,
-       0x7, 0xf8,
-       0x19, 0xe6,
-       0xe1, 0xe1,
-       0x2, 0x10,
-       0x2, 0x10,
-       0x4, 0x8,
-       0x4, 0x8,
-       0x8, 0x4,
-       /* mask */
-       0x18, 0x6,
-       0xc, 0xc,
-       0x4, 0x8,
-       0x6, 0x18,
-       0x83, 0xf1,
-       0xf3, 0xf3,
-       0x3b, 0xf6,
-       0xf, 0xfc,
-       0x7, 0xfc,
-       0x1f, 0xf6,
-       0xf3, 0xf3,
-       0x83, 0xf1,
-       0x2, 0x18,
-       0x6, 0x18,
-       0xc, 0xc,
-       0x18, 0x6,
-};
-
-const unsigned char XC_spraycan[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       2, 4,   /* y,x of hotspot */
-       /* data */
-       0x98, 0x0,
-       0x2, 0x0,
-       0x18, 0xb0,
-       0x2, 0x78,
-       0x18, 0x58,
-       0x0, 0xfc,
-       0x0, 0x84,
-       0x0, 0x9c,
-       0x0, 0x94,
-       0x0, 0x9c,
-       0x0, 0x94,
-       0x0, 0x9c,
-       0x0, 0x9c,
-       0x0, 0x84,
-       0x0, 0x84,
-       0x0, 0xfc,
-       /* mask */
-       0x30, 0x0,
-       0x34, 0x60,
-       0x35, 0xf0,
-       0x35, 0xf0,
-       0x35, 0xf8,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-       0x3, 0xfc,
-};
-
-const unsigned char XC_star[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x80, 0x80,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x1, 0x40,
-       0x2, 0x20,
-       0x2, 0x20,
-       0x2, 0x20,
-       0x1c, 0x9c,
-       0x60, 0x3,
-       0x1c, 0x1c,
-       0x4, 0x90,
-       0x9, 0x48,
-       0x12, 0x24,
-       0x14, 0x14,
-       0x18, 0xc,
-       0x10, 0x4,
-       /* mask */
-       0x0, 0x80,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x3, 0x60,
-       0x3, 0x60,
-       0x6, 0x30,
-       0x1e, 0x38,
-       0x7c, 0x9f,
-       0xe0, 0x3,
-       0x7c, 0x1f,
-       0x1c, 0x9c,
-       0x19, 0xcc,
-       0x33, 0x66,
-       0x36, 0x36,
-       0x3c, 0x1e,
-       0x38, 0xe,
-};
-
-const unsigned char XC_target[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x81, 0xc0,
-       0x7, 0xf0,
-       0xe, 0x38,
-       0x18, 0xc,
-       0x30, 0x6,
-       0x60, 0x83,
-       0x61, 0x43,
-       0x60, 0x83,
-       0x30, 0x6,
-       0x18, 0xc,
-       0xe, 0x38,
-       0x7, 0xf0,
-       0x1, 0xc0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0x1e, 0x3c,
-       0x38, 0xe,
-       0x70, 0x87,
-       0xe1, 0xc3,
-       0xe3, 0x63,
-       0xe1, 0xc3,
-       0x70, 0x87,
-       0x38, 0xe,
-       0x1e, 0x3c,
-       0xf, 0xf8,
-       0x3, 0xe0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_tcross[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       7, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0xc0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x3f, 0xfe,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_top_left_arrow[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 15,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x80, 0x6,
-       0x0, 0x1e,
-       0x0, 0x7c,
-       0x1, 0xfc,
-       0x7, 0xf8,
-       0x1f, 0xf8,
-       0x1, 0xf0,
-       0x1, 0xf0,
-       0x2, 0x60,
-       0x4, 0x60,
-       0x8, 0x40,
-       0x10, 0x40,
-       0x20, 0x0,
-       0x40, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x7,
-       0x0, 0x1f,
-       0x0, 0x7f,
-       0x1, 0xfe,
-       0x7, 0xfe,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xf8,
-       0x3, 0xf8,
-       0x7, 0xf0,
-       0xe, 0xf0,
-       0x1c, 0xe0,
-       0x38, 0xe0,
-       0x70, 0xe0,
-       0xe0, 0x0,
-       0xc0, 0x0,
-};
-
-const unsigned char XC_top_left_corner[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 15,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0xff, 0xfe,
-       0x7f, 0xfe,
-       0x0, 0x6,
-       0x0, 0x6,
-       0x0, 0x6,
-       0x1f, 0xc6,
-       0x0, 0xc6,
-       0x1, 0x46,
-       0x2, 0x46,
-       0x4, 0x46,
-       0x8, 0x46,
-       0x10, 0x46,
-       0x0, 0x6,
-       0x0, 0x6,
-       0x0, 0x0,
-       /* mask */
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x0, 0xf,
-       0x3f, 0xef,
-       0x3f, 0xef,
-       0x3f, 0xef,
-       0x3, 0xef,
-       0x7, 0xef,
-       0xe, 0xef,
-       0x1c, 0xef,
-       0x38, 0xef,
-       0x30, 0xef,
-       0x0, 0xf,
-       0x0, 0xf,
-};
-
-const unsigned char XC_top_right_corner[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 2,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0xff, 0xfe,
-       0x7f, 0xfe,
-       0x60, 0x0,
-       0x60, 0x0,
-       0x60, 0x0,
-       0x63, 0xf8,
-       0x63, 0x0,
-       0x62, 0x80,
-       0x62, 0x40,
-       0x62, 0x20,
-       0x62, 0x10,
-       0x62, 0x8,
-       0x60, 0x0,
-       0x60, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xf0, 0x0,
-       0xf7, 0xfc,
-       0xf7, 0xfc,
-       0xf7, 0xfc,
-       0xf7, 0xc0,
-       0xf7, 0xe0,
-       0xf7, 0x70,
-       0xf7, 0x38,
-       0xf7, 0x1c,
-       0xf7, 0xc,
-       0xf0, 0x0,
-       0xf0, 0x0,
-};
-
-const unsigned char XC_top_side[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       1, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0xff, 0xfe,
-       0x3f, 0xfe,
-       0x0, 0x0,
-       0x0, 0x80,
-       0x1, 0xc0,
-       0x2, 0xa0,
-       0x4, 0x90,
-       0x8, 0x88,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x0,
-       /* mask */
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x7f, 0xff,
-       0x1, 0xc0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0x1d, 0xdc,
-       0x19, 0xcc,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-};
-
-const unsigned char XC_top_tee[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       3, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0xff, 0xfe,
-       0x7f, 0xfe,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x1, 0x80,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x3, 0xc0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_trek[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       0, 8,   /* y,x of hotspot */
-       /* data */
-       0x8, 0x80,
-       0x8, 0x0,
-       0x1, 0xc0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0x7, 0x70,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x1, 0xc0,
-       0x0, 0x80,
-       0x5, 0xd0,
-       0x6, 0xb0,
-       0x4, 0x90,
-       0x4, 0x10,
-       0x4, 0x10,
-       0x4, 0x10,
-       /* mask */
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x3, 0xe0,
-       0x7, 0xf0,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0x7, 0xf0,
-       0x3, 0xe0,
-       0x5, 0xd0,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0xe, 0xb8,
-       0xe, 0xb8,
-       0xe, 0x38,
-};
-
-const unsigned char XC_ul_angle[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       3, 13,  /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x18,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x3c,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_umbrella[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       3, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x89, 0x10,
-       0x14, 0x40,
-       0x65, 0x92,
-       0x13, 0xe4,
-       0xc, 0x98,
-       0x30, 0x86,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x2, 0x80,
-       0x2, 0x80,
-       0x1, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x76, 0xe8,
-       0xdf, 0xfb,
-       0x3f, 0xfd,
-       0xff, 0xfe,
-       0x3f, 0xff,
-       0xff, 0xff,
-       0x79, 0xcf,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x7, 0xc0,
-       0x7, 0xc0,
-       0x7, 0xc0,
-       0x7, 0xc0,
-       0x3, 0x80,
-};
-
-const unsigned char XC_ur_angle[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       3, 4,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x1f, 0xf8,
-       0x1f, 0xf8,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x18, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-       /* mask */
-       0x0, 0x0,
-       0x0, 0x0,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3f, 0xfc,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x3c, 0x0,
-       0x0, 0x0,
-       0x0, 0x0,
-};
-
-const unsigned char XC_watch[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       9, 1,   /* y,x of hotspot */
-       /* data */
-       0x7, 0xf8,
-       0x7, 0xf8,
-       0x7, 0xf8,
-       0xf, 0xfc,
-       0x18, 0x86,
-       0x30, 0x83,
-       0xe0, 0x81,
-       0xe1, 0xc1,
-       0xe1, 0xc1,
-       0xe0, 0x21,
-       0x30, 0x13,
-       0x18, 0x6,
-       0xf, 0xfc,
-       0x7, 0xf8,
-       0x7, 0xf8,
-       0x7, 0xf8,
-       /* mask */
-       0xf, 0xfc,
-       0xf, 0xfc,
-       0xf, 0xfc,
-       0x1f, 0xfe,
-       0x3f, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0xff, 0xff,
-       0x3f, 0xff,
-       0x1f, 0xfe,
-       0xf, 0xfc,
-       0xf, 0xfc,
-       0xf, 0xfc,
-};
-
-const unsigned char XC_xterm[] = {
-       16,     /* 16x16 size */
-       1,      /* 1 bit depth */
-       8, 8,   /* y,x of hotspot */
-       /* data */
-       0x0, 0x0,
-       0xf, 0x70,
-       0x9, 0xc0,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x0, 0x80,
-       0x1, 0xc0,
-       0x7, 0x70,
-       0x0, 0x0,
-       /* mask */
-       0xf, 0x78,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0x3, 0xe0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x1, 0xc0,
-       0x3, 0xe0,
-       0xf, 0xf8,
-       0xf, 0xf8,
-       0xf, 0x78,
-};
-
diff --git a/src/glut/beos/glutDstr.cpp b/src/glut/beos/glutDstr.cpp
deleted file mode 100644 (file)
index 281a039..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutDstr.cpp
- *
- *     DESCRIPTION:    convert display string into a Be options variable
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include <string.h>
-#include <stdlib.h>
-#include "glutint.h"
-#include "glutState.h"
-
-/***********************************************************
- *     FUNCTION:       glutInitDisplayString
- *
- *     DESCRIPTION:  sets the display string variable
- ***********************************************************/
-void APIENTRY 
-glutInitDisplayString(const char *string)
-{
-  if (gState.displayString) {
-    free(gState.displayString);
-  }
-  if (string) {
-    gState.displayString = strdup(string);
-    if (!gState.displayString)
-      __glutFatalError("out of memory.");
-  } else
-    gState.displayString = NULL;
-}
-
-/***********************************************************
- *     FUNCTION:       __glutConvertDisplayModeFromString
- *
- *     DESCRIPTION:  converts the current display mode into a BGLView
- *             display mode, printing warnings as appropriate.
- *
- *     PARAMETERS:      if options is non-NULL, the current display mode is
- *             returned in it.
- *
- *     RETURNS:        1 if the current display mode is possible, else 0
- ***********************************************************/
-int __glutConvertDisplayModeFromString(unsigned long *options) {
-       ulong newoptions = 0;
-       
-       char *word = strtok(gState.displayString, " \t");
-       do {
-               char *cstr = strpbrk(word, "=><!~");
-               if(cstr)
-                       *cstr = '\0';
-               // this is the most minimal possible parser.  scan for
-               // options that we support, and add them to newoptions
-               // this will certainly cause it to accept things that we
-               // don't actually support, but if we don't support it, the
-               // program's probably not going to work anyway.
-               if(!strcmp(word, "alpha")) {
-                       newoptions |= BGL_ALPHA;
-               } else if((!strcmp(word, "acc")) || (!strcmp(word, "acca"))) {
-                       newoptions |= BGL_ACCUM;
-               } else if(!strcmp(word, "depth")) {
-                       newoptions |= BGL_DEPTH;
-               } else if(!strcmp(word, "double")) {
-                       newoptions |= BGL_DOUBLE;
-               } else if(!strcmp(word, "stencil")) {
-                       newoptions |= BGL_STENCIL;
-               }
-       } while((word = strtok(0, " \t")) != 0);
-
-       if (options)
-               *options = newoptions;
-
-       return 1;       // assume we support it
-}
diff --git a/src/glut/beos/glutEvent.cpp b/src/glut/beos/glutEvent.cpp
deleted file mode 100644 (file)
index cffbc1a..0000000
+++ /dev/null
@@ -1,695 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutEvent.cpp
- *
- *     DESCRIPTION:    here it is, the BeOS GLUT event loop
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include "glutint.h"
-#include "glutState.h"
-#include "glutBlocker.h"
-
-/***********************************************************
- *     CLASS:  GLUTtimer
- *
- *     DESCRIPTION:    list of timer callbacks
- ***********************************************************/
-struct GLUTtimer {
-       GLUTtimer *next;        // list of timers
-       bigtime_t timeout;      // time to be called
-       GLUTtimerCB func;       // function to call
-       int value;                      // value
-};
-
-/***********************************************************
- *     Private variables
- ***********************************************************/
-static GLUTtimer *__glutTimerList = 0;                 // list of timer callbacks
-static GLUTtimer *freeTimerList = 0;
-
-/***********************************************************
- *     FUNCTION:       glutTimerFunc (7.19)
- *
- *     DESCRIPTION:  register a new timer callback
- ***********************************************************/
-void APIENTRY 
-glutTimerFunc(unsigned int interval, GLUTtimerCB timerFunc, int value)
-{
-  GLUTtimer *timer, *other;
-  GLUTtimer **prevptr;
-
-  if (!timerFunc)
-    return;
-
-  if (freeTimerList) {
-    timer = freeTimerList;
-    freeTimerList = timer->next;
-  } else {
-    timer = new GLUTtimer();
-    if (!timer)
-      __glutFatalError("out of memory.");
-  }
-
-  timer->func = timerFunc;
-  timer->value = value;
-  timer->next = NULL;
-  timer->timeout = system_time() + (interval*1000);    // 1000 ticks in a millisecond
-  prevptr = &__glutTimerList;
-  other = *prevptr;
-  while (other && (other->timeout < timer->timeout)) {
-    prevptr = &other->next;
-    other = *prevptr;
-  }
-  timer->next = other;
-  *prevptr = timer;
-}
-
-/***********************************************************
- *     FUNCTION:       handleTimeouts
- *
- *     DESCRIPTION:  private function to handle outstanding timeouts
- ***********************************************************/
-static void
-handleTimeouts(void)
-{
-  bigtime_t now;
-  GLUTtimer *timer;
-
-  /* Assumption is that __glutTimerList is already determined
-     to be non-NULL. */
-  now = system_time();
-  while (__glutTimerList->timeout <= now) {
-    timer = __glutTimerList;
-    if(gState.currentWindow)
-           gState.currentWindow->LockGL();
-    timer->func(timer->value);
-    if(gState.currentWindow)
-           gState.currentWindow->UnlockGL();
-    __glutTimerList = timer->next;
-    timer->next = freeTimerList;
-    freeTimerList = timer;
-    if (!__glutTimerList)
-      break;
-  }
-}
-
-
-/***********************************************************
- *     FUNCTION:       processEventsAndTimeouts
- *
- *     DESCRIPTION:  clear gBlock, then check all windows for events
- ***********************************************************/
-static void
-processEventsAndTimeouts(void)
-{
-       gBlock.WaitEvent();             // if there is already an event, returns
-                                                       // immediately, otherwise wait forever
-       gBlock.ClearEvents();
-       
-       if(gState.quitAll)
-               exit(0);                // exit handler cleans up windows and quits nicely
-       
-       if (gState.currentWindow)
-               gState.currentWindow->LockGL();
-       for(int i=0; i<gState.windowListSize; i++) {
-               if (gState.windowList[i]) {
-                       GlutWindow *win = gState.windowList[i];
-                       // NOTE: we can use win as a shortcut for gState.windowList[i]
-                       // in callbacks, EXCEPT we need to check the original variable
-                       // after each callback to make sure the window hasn't been destroyed
-                       if (win->anyevents) {
-                               win->anyevents = false;
-                               if (win->reshapeEvent) {
-                                       win->reshapeEvent = false;
-                                       __glutSetWindow(win);
-                                       win->reshape(win->m_width, win->m_height);
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->displayEvent) {
-                                       win->displayEvent = false;
-                                       __glutSetWindow(win);
-                                       win->display();
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->mouseEvent) {
-                                       win->mouseEvent = false;
-                                       __glutSetWindow(win);
-                                       if (win->mouse) {
-                                               gState.modifierKeys = win->modifierKeys;
-                                               win->mouse(win->button, win->mouseState, win->mouseX, win->mouseY);
-                                               gState.modifierKeys = ~0;
-                                       }
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->menuEvent) {
-                                       win->menuEvent = false;
-                                       __glutSetWindow(win);
-                                       GlutMenu *menu = __glutGetMenuByNum(win->menuNumber);
-                                       if (menu) {
-                                               gState.currentMenu = menu;
-                                               menu->select(win->menuValue);
-                                       }
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->statusEvent) {
-                                       win->statusEvent = false;
-                                       __glutSetWindow(win);
-                                       if (gState.menuStatus) {
-                                               gState.currentMenu = __glutGetMenuByNum(win->menuNumber);
-                                               gState.menuStatus(win->menuStatus, win->statusX, win->statusY);
-                                       }
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->motionEvent) {
-                                       win->motionEvent = false;
-                                       __glutSetWindow(win);
-                                       if (win->motion)
-                                               win->motion(win->motionX, win->motionY);
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->passiveEvent) {
-                                       win->passiveEvent = false;
-                                       __glutSetWindow(win);
-                                       if (win->passive)
-                                               win->passive(win->passiveX, win->passiveY);
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->keybEvent) {
-                                       win->keybEvent = false;
-                                       __glutSetWindow(win);
-                                       if (win->keyboard) {
-                                               gState.modifierKeys = win->modifierKeys;
-                                               win->keyboard(win->key, win->keyX, win->keyY);
-                                               gState.modifierKeys = ~0;
-                                       }
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->specialEvent) {
-                                       win->specialEvent = false;
-                                       __glutSetWindow(win);
-                                       if (win->special) {
-                                               gState.modifierKeys = win->modifierKeys;
-                                               win->special(win->specialKey, win->specialX, win->specialY);
-                                               gState.modifierKeys = ~0;
-                                       }
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->entryEvent) {
-                                       win->entryEvent = false;
-                                       __glutSetWindow(win);
-                                       if (win->entry)
-                                               win->entry(win->entryState);
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-
-                               if (win->windowStatusEvent) {
-                                       win->windowStatusEvent = false;
-                                       __glutSetWindow(win);
-                                       if (win->windowStatus)
-                                               win->windowStatus(win->visState);
-                               }
-                               if (!gState.windowList[i])
-                                       continue;       // window was destroyed by callback!
-                       }
-               }
-       }
-       if (gState.currentWindow)
-               gState.currentWindow->UnlockGL();
-
-       // This code isn't necessary since BGLView automatically traps errors
-#if 0
-       if(gState.debug) {
-               for(int i=0; i<gState.windowListSize; i++) {
-                       if (gState.windowList[i]) {
-                               gState.windowList[i]->LockGL();
-                               glutReportErrors();
-                               gState.windowList[i]->UnlockGL();
-                       }
-               }
-       }
-#endif
-       if (__glutTimerList) {
-      handleTimeouts();
-    }
-}
-
-/***********************************************************
- *     FUNCTION:       waitForSomething
- *
- *     DESCRIPTION:  use gBlock to wait for a new event or timeout
- ***********************************************************/
-static void
-waitForSomething(void)
-{
-       bigtime_t timeout = __glutTimerList->timeout;
-       bigtime_t now = system_time();
-       
-       if (gBlock.PendingEvent())
-               goto immediatelyHandleEvent;
-       
-       if(timeout>now)
-               gBlock.WaitEvent(timeout-now);
-       if (gBlock.PendingEvent()) {
-       immediatelyHandleEvent:
-               processEventsAndTimeouts();
-       } else {
-               if (__glutTimerList)
-                       handleTimeouts();
-       }
-}
-
-/***********************************************************
- *     FUNCTION:       idleWait
- *
- *     DESCRIPTION:  check for events, then call idle function
- ***********************************************************/
-static void
-idleWait(void)
-{
-  if (gBlock.PendingEvent()) {
-    processEventsAndTimeouts();
-  } else {
-    if (__glutTimerList)
-      handleTimeouts();
-  }
-  /* Make sure idle func still exists! */
-  if(gState.currentWindow)
-         gState.currentWindow->LockGL();
-  if (gState.idle) {
-    gState.idle();
-  }
-  if(gState.currentWindow)
-         gState.currentWindow->UnlockGL();
-}
-
-/***********************************************************
- *     FUNCTION:       glutMainLoop (3.1)
- *
- *     DESCRIPTION:  enter the event processing loop
- ***********************************************************/
-void glutMainLoop()
-{
-  if (!gState.windowListSize)
-    __glutFatalUsage("main loop entered with no windows created.");
-
-  if(gState.currentWindow)
-         gState.currentWindow->UnlockGL();
-
-  for (;;) {
-    if (gState.idle) {
-      idleWait();
-    } else {
-      if (__glutTimerList) {
-        waitForSomething();
-      } else {
-        processEventsAndTimeouts();
-      }
-    }
-  }
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       KeyDown
- *
- *     DESCRIPTION:  handles keyboard and special events
- ***********************************************************/
-void GlutWindow::KeyDown(const char *s, int32 slen)
-{
-  ulong aChar = s[0];
-  BGLView::KeyDown(s,slen);
-  
-  BPoint p;
-       
-       switch (aChar) {
-               case B_FUNCTION_KEY:
-               switch(Window()->CurrentMessage()->FindInt32("key")) {
-                       case B_F1_KEY:
-                               aChar = GLUT_KEY_F1;
-                               goto specialLabel;
-                       case B_F2_KEY:
-                               aChar = GLUT_KEY_F2;
-                               goto specialLabel;
-                       case B_F3_KEY:
-                               aChar = GLUT_KEY_F3;
-                               goto specialLabel;
-                       case B_F4_KEY:
-                               aChar = GLUT_KEY_F4;
-                               goto specialLabel;
-                       case B_F5_KEY:
-                               aChar = GLUT_KEY_F5;
-                               goto specialLabel;
-                       case B_F6_KEY:
-                               aChar = GLUT_KEY_F6;
-                               goto specialLabel;
-                       case B_F7_KEY:
-                               aChar = GLUT_KEY_F7;
-                               goto specialLabel;
-                       case B_F8_KEY:
-                               aChar = GLUT_KEY_F8;
-                               goto specialLabel;
-                       case B_F9_KEY:
-                               aChar = GLUT_KEY_F9;
-                               goto specialLabel;
-                       case B_F10_KEY:
-                               aChar = GLUT_KEY_F10;
-                               goto specialLabel;
-                       case B_F11_KEY:
-                               aChar = GLUT_KEY_F11;
-                               goto specialLabel;
-                       case B_F12_KEY:
-                               aChar = GLUT_KEY_F12;
-                               goto specialLabel;
-                       default:
-                               return;
-               }
-               case B_LEFT_ARROW:
-                       aChar = GLUT_KEY_LEFT;
-                       goto specialLabel;
-               case B_UP_ARROW:
-                       aChar = GLUT_KEY_UP;
-                       goto specialLabel;
-               case B_RIGHT_ARROW:
-                       aChar = GLUT_KEY_RIGHT;
-                       goto specialLabel;
-               case B_DOWN_ARROW:
-                       aChar = GLUT_KEY_DOWN;
-                       goto specialLabel;
-               case B_PAGE_UP:
-                       aChar = GLUT_KEY_PAGE_UP;
-                       goto specialLabel;
-               case B_PAGE_DOWN:
-                       aChar = GLUT_KEY_PAGE_DOWN;
-                       goto specialLabel;
-               case B_HOME:
-                       aChar = GLUT_KEY_HOME;
-                       goto specialLabel;
-               case B_END:
-                       aChar = GLUT_KEY_END;
-                       goto specialLabel;
-               case B_INSERT:
-            aChar = GLUT_KEY_INSERT;
-specialLabel:  
-                       if (special) {
-                               anyevents = specialEvent = true;
-                               GetMouse(&p,&m_buttons);
-                               specialKey = aChar;
-                               specialX = (int)p.x;
-                               specialY = (int)p.y;
-                               goto setModifiers;      // set the modifier variable
-                       }
-                       return;
-
-               default:
-                       break;
-       }
-               
-       if (keyboard) {
-               anyevents = keybEvent = true;
-               GetMouse(&p,&m_buttons);
-               key = aChar;
-               keyX = (int)p.x;
-               keyY = (int)p.y;
-setModifiers:
-               modifierKeys = 0;
-               uint32 beMod = Window()->CurrentMessage()->FindInt32("modifiers");
-               if(beMod & B_SHIFT_KEY)
-                       modifierKeys |= GLUT_ACTIVE_SHIFT;
-               if(beMod & B_CONTROL_KEY)
-                       modifierKeys |= GLUT_ACTIVE_CTRL;
-               if(beMod & B_OPTION_KEY) {
-                       // since the window traps B_COMMAND_KEY, we'll have to settle
-                       // for the option key.. but we need to get the raw character,
-                       // not the Unicode-enhanced version
-                       key = Window()->CurrentMessage()->FindInt32("raw_char");
-                       modifierKeys |= GLUT_ACTIVE_ALT;
-               }
-               gBlock.NewEvent();
-       }
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       MouseDown
- *
- *     DESCRIPTION:  handles mouse and menustatus events
- ***********************************************************/
-void GlutWindow::MouseDown(BPoint point)
-{
-       BGLView::MouseDown(point);
-       MouseCheck();
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       MouseCheck
- *
- *     DESCRIPTION:  checks for button state changes
- ***********************************************************/
-void GlutWindow::MouseCheck()
-{
-       if (mouseEvent)
-               return;         // we already have an outstanding mouse event
-
-       BPoint point;
-       uint32 newButtons;
-       GetMouse(&point, &newButtons);
-       if (m_buttons != newButtons) {
-               if (newButtons&B_PRIMARY_MOUSE_BUTTON && !(m_buttons&B_PRIMARY_MOUSE_BUTTON)) {
-                       button = GLUT_LEFT_BUTTON;
-                       mouseState = GLUT_DOWN;
-               } else if (m_buttons&B_PRIMARY_MOUSE_BUTTON && !(newButtons&B_PRIMARY_MOUSE_BUTTON)) {
-                       button = GLUT_LEFT_BUTTON;
-                       mouseState = GLUT_UP;
-               } else if (newButtons&B_SECONDARY_MOUSE_BUTTON && !(m_buttons&B_SECONDARY_MOUSE_BUTTON)) {
-                       button = GLUT_RIGHT_BUTTON;
-                       mouseState = GLUT_DOWN;
-               } else if (m_buttons&B_SECONDARY_MOUSE_BUTTON && !(newButtons&B_SECONDARY_MOUSE_BUTTON)) {
-                       button = GLUT_RIGHT_BUTTON;
-                       mouseState = GLUT_UP;
-               } else if (newButtons&B_TERTIARY_MOUSE_BUTTON && !(m_buttons&B_TERTIARY_MOUSE_BUTTON)) {
-                       button = GLUT_MIDDLE_BUTTON;
-                       mouseState = GLUT_DOWN;
-               } else if (m_buttons&B_TERTIARY_MOUSE_BUTTON && !(newButtons&B_TERTIARY_MOUSE_BUTTON)) {
-                       button = GLUT_MIDDLE_BUTTON;
-                       mouseState = GLUT_UP;
-               }
-       } else {
-               return;         // no change, return
-       }
-       m_buttons = newButtons;
-
-       if (mouseState == GLUT_DOWN) {
-               BWindow *w = Window();
-               GlutMenu *m = __glutGetMenuByNum(menu[button]);
-               if (m) {
-                       if (gState.menuStatus) {
-                               anyevents = statusEvent = true;
-                               menuNumber = menu[button];
-                               menuStatus = GLUT_MENU_IN_USE;
-                               statusX = (int)point.x;
-                               statusY = (int)point.y;
-                               gBlock.NewEvent();
-                       }               
-                       BRect bounds = w->Frame();
-                       point.x += bounds.left;
-                       point.y += bounds.top;
-                       GlutPopUp *bmenu = static_cast<GlutPopUp*>(m->CreateBMenu());   // start menu
-                       bmenu->point = point;
-                       bmenu->win = this;
-                       thread_id menu_thread = spawn_thread(MenuThread, "menu thread", B_NORMAL_PRIORITY, bmenu);
-                       resume_thread(menu_thread);
-                       return;
-               }
-       }
-
-       if (mouse) {
-               anyevents = mouseEvent = true;
-               mouseX = (int)point.x;
-               mouseY = (int)point.y;
-               modifierKeys = 0;
-               uint32 beMod = modifiers();
-               if(beMod & B_SHIFT_KEY)
-                       modifierKeys |= GLUT_ACTIVE_SHIFT;
-               if(beMod & B_CONTROL_KEY)
-                       modifierKeys |= GLUT_ACTIVE_CTRL;
-               if(beMod & B_OPTION_KEY) {
-                       modifierKeys |= GLUT_ACTIVE_ALT;
-               }
-               gBlock.NewEvent();
-       }
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       MouseMoved
- *
- *     DESCRIPTION:  handles entry, motion, and passive events
- ***********************************************************/
-void GlutWindow::MouseMoved(BPoint point,
-                                               ulong transit, const BMessage *msg)
-{
-       BGLView::MouseMoved(point,transit,msg);
-       
-       if(transit != B_INSIDE_VIEW) {
-               if (entry) {
-                       anyevents = entryEvent = true;
-                       gBlock.NewEvent();
-               }
-               if (transit == B_ENTERED_VIEW) {
-                       entryState = GLUT_ENTERED;
-                       MakeFocus();    // make me the current focus
-                       __glutSetCursor(cursor);
-               } else
-                       entryState = GLUT_LEFT;
-       }
-       
-       MouseCheck();
-       if(m_buttons) {
-               if(motion) {
-                       anyevents = motionEvent = true;
-                       motionX = (int)point.x;
-                       motionY = (int)point.y;
-                       gBlock.NewEvent();
-               }
-       } else {
-               if(passive) {
-                       anyevents = passiveEvent = true;
-                       passiveX = (int)point.x;
-                       passiveY = (int)point.y;
-                       gBlock.NewEvent();
-               }
-       }
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       FrameResized
- *
- *     DESCRIPTION:  handles reshape event
- ***********************************************************/
-void GlutWindow::FrameResized(float width, float height)
-{
-       BGLView::FrameResized(width, height);
-       if (visible) {
-               anyevents = reshapeEvent = true;
-               m_width = (int)(width)+1;
-               m_height = (int)(height)+1;
-               gBlock.NewEvent();
-       }
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       Draw
- *
- *     DESCRIPTION:  handles reshape and display events
- ***********************************************************/
-void GlutWindow::Draw(BRect updateRect)
-{
-       BGLView::Draw(updateRect);
-       BRect frame = Frame();
-       if (m_width != (frame.Width()+1) || m_height != (frame.Height()+1)) {
-               FrameResized(frame.Width(), frame.Height());
-       }
-       Window()->Lock();
-       if (visible) {
-               anyevents = displayEvent = true;
-               gBlock.NewEvent();
-       }
-       Window()->Unlock();
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       Pulse
- *
- *     DESCRIPTION:  handles mouse up event (MouseUp is broken)
- ***********************************************************/
-void GlutWindow::Pulse()
-{
-       BGLView::Pulse();
-       if (m_buttons) {        // if there are buttons pressed
-               MouseCheck();
-       }
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       ErrorCallback
- *
- *     DESCRIPTION:  handles GL error messages
- ***********************************************************/
-void GlutWindow::ErrorCallback(GLenum errorCode) {
-       __glutWarning("GL error: %s", gluErrorString(errorCode));
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       MenuThread
- *
- *     DESCRIPTION:  a new thread to launch popup menu, wait
- *                     wait for response, then clean up afterwards and
- *                     send appropriate messages
- ***********************************************************/
-long GlutWindow::MenuThread(void *m) {
-       GlutPopUp *bmenu = static_cast<GlutPopUp*>(m);
-       GlutWindow *win = bmenu->win;   // my window
-       GlutBMenuItem *result = (GlutBMenuItem*)bmenu->Go(bmenu->point);
-       win->Window()->Lock();
-       win->anyevents = win->statusEvent = true;
-       win->menuStatus = GLUT_MENU_NOT_IN_USE;
-       win->menuNumber = bmenu->menu;
-       BPoint cursor;
-       uint32 buttons;
-       win->GetMouse(&cursor, &buttons);
-       win->statusX = (int)cursor.x;
-       win->statusY = (int)cursor.y;
-       if(result && result->menu) {
-               win->menuEvent = true;
-               win->menuNumber = result->menu;  // in case it was a submenu
-               win->menuValue = result->value;
-       }
-       win->Window()->Unlock();
-       gBlock.NewEvent();
-       delete bmenu;
-       return 0;
-}
diff --git a/src/glut/beos/glutGet.cpp b/src/glut/beos/glutGet.cpp
deleted file mode 100644 (file)
index 04a8479..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutGet.cpp
- *
- *     DESCRIPTION:    get state information from GL
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include <string.h>
-#include <Autolock.h>
-#include <Screen.h>
-
-#include "glutint.h"
-#include "glutState.h"
-
-/***********************************************************
- *     Global variables
- ***********************************************************/
-// rough guess, since we don't know how big the monitor really is
-const float dots_per_mm = (72/25.4);   // dots per millimeter
-
-/***********************************************************
- *     FUNCTION:       glutGet (9.1)
- *
- *     DESCRIPTION:  retrieve window and GL state
- ***********************************************************/
-int glutGet(GLenum state) {
-       switch(state) {
-       case GLUT_WINDOW_X:
-               {BAutolock winlock(gState.currentWindow->Window());     // need to lock the window
-               if (gState.currentWindow->parent)
-                       return (int)gState.currentWindow->Frame().left;
-               else
-                       return (int)gState.currentWindow->Window()->Frame().left;
-               }
-       case GLUT_WINDOW_Y:
-               {BAutolock winlock(gState.currentWindow->Window());
-               if (gState.currentWindow->parent)
-                       return (int)gState.currentWindow->Frame().top;
-               else
-                       return (int)gState.currentWindow->Window()->Frame().top;
-               }
-       case GLUT_WINDOW_WIDTH:
-               {BAutolock winlock(gState.currentWindow->Window());
-               return gState.currentWindow->m_width;
-               }
-       case GLUT_WINDOW_HEIGHT:
-               {BAutolock winlock(gState.currentWindow->Window());
-               return gState.currentWindow->m_height;
-               }
-       case GLUT_WINDOW_PARENT:
-               {BAutolock winlock(gState.currentWindow->Window());
-               if(gState.currentWindow->parent)
-                       return gState.currentWindow->parent->num + 1;
-               else
-                       return 0;
-               }
-       case GLUT_WINDOW_NUM_CHILDREN:
-               {BAutolock winlock(gState.currentWindow->Window());
-               int num = 0;
-               GlutWindow *children = gState.currentWindow->children;
-               while (children) {
-                       num++;
-                       children = children->siblings;
-               }
-               return num; 
-               }
-  case GLUT_WINDOW_BUFFER_SIZE:        // best guesses
-  case GLUT_WINDOW_DEPTH_SIZE:
-        return 32;
-
-  case GLUT_WINDOW_STENCIL_SIZE:
-  case GLUT_WINDOW_RED_SIZE:           // always 24-bit color
-  case GLUT_WINDOW_GREEN_SIZE:
-  case GLUT_WINDOW_BLUE_SIZE:
-  case GLUT_WINDOW_ALPHA_SIZE:
-  case GLUT_WINDOW_ACCUM_RED_SIZE:
-  case GLUT_WINDOW_ACCUM_GREEN_SIZE:
-  case GLUT_WINDOW_ACCUM_BLUE_SIZE:
-  case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
-        return 8;
-
-  case GLUT_WINDOW_DOUBLEBUFFER:       // always double-buffered RGBA
-  case GLUT_WINDOW_RGBA:
-        return 1;
-
-  case GLUT_WINDOW_COLORMAP_SIZE:      // don't support these
-  case GLUT_WINDOW_NUM_SAMPLES:
-  case GLUT_WINDOW_STEREO:
-        return 0;
-       case GLUT_WINDOW_CURSOR:
-               return gState.currentWindow->cursor;    // don't need to lock window since it won't change
-
-       case GLUT_SCREEN_WIDTH:
-               return (int)(BScreen().Frame().Width()) + 1;
-       case GLUT_SCREEN_HEIGHT:
-               return (int)(BScreen().Frame().Height()) + 1;
-       case GLUT_SCREEN_WIDTH_MM:
-               return (int)((BScreen().Frame().Width() + 1) / dots_per_mm);
-       case GLUT_SCREEN_HEIGHT_MM:
-               return (int)((BScreen().Frame().Height() + 1) / dots_per_mm);
-       case GLUT_MENU_NUM_ITEMS:
-               return gState.currentMenu->num;
-       case GLUT_DISPLAY_MODE_POSSIBLE:
-               return __glutConvertDisplayMode(0);     // returns 1 if possible
-       case GLUT_INIT_DISPLAY_MODE:
-               return gState.displayMode;
-       case GLUT_INIT_WINDOW_X:
-               return gState.initX;
-       case GLUT_INIT_WINDOW_Y:
-               return gState.initY;
-       case GLUT_INIT_WINDOW_WIDTH:
-               return gState.initWidth;
-       case GLUT_INIT_WINDOW_HEIGHT:
-               return gState.initHeight;
-       case GLUT_ELAPSED_TIME:
-               bigtime_t elapsed, beginning, now;
-               __glutInitTime(&beginning);
-               now = system_time();
-               elapsed = now - beginning;
-               return (int) (elapsed / 1000);  // 1000 ticks in a millisecond
-       default:
-               __glutWarning("invalid glutGet parameter: %d", state);
-               return -1;
-       }
-}
-
-/***********************************************************
- *     FUNCTION:       glutLayerGet (9.2)
- *
- *     DESCRIPTION:  since we don't support layers, this is easy
- ***********************************************************/
-int glutLayerGet(GLenum info) {
-       switch(info) {
-       case GLUT_OVERLAY_POSSIBLE:
-       case GLUT_HAS_OVERLAY:
-               return 0;
-       case GLUT_LAYER_IN_USE:
-               return GLUT_NORMAL;
-       case GLUT_TRANSPARENT_INDEX:
-               return -1;
-       case GLUT_NORMAL_DAMAGED:
-               return gState.currentWindow->displayEvent;
-       case GLUT_OVERLAY_DAMAGED:
-               return -1;
-       default:
-               __glutWarning("invalid glutLayerGet param: %d", info);
-               return -1;
-       }
-}
-
-/***********************************************************
- *     FUNCTION:       glutDeviceGet (9.3)
- *
- *     DESCRIPTION:  get info about I/O devices we support
- *             easy, since BeOS only supports a keyboard and mouse now
- ***********************************************************/
-int glutDeviceGet(GLenum info) {
-       switch(info) {
-       case GLUT_HAS_KEYBOARD:
-       case GLUT_HAS_MOUSE:
-               return 1;
-
-       case GLUT_HAS_SPACEBALL:
-       case GLUT_HAS_DIAL_AND_BUTTON_BOX:
-       case GLUT_HAS_TABLET:
-       case GLUT_NUM_SPACEBALL_BUTTONS:
-       case GLUT_NUM_BUTTON_BOX_BUTTONS:
-       case GLUT_NUM_DIALS:
-       case GLUT_NUM_TABLET_BUTTONS:
-               return 0;
-       
-       case GLUT_NUM_MOUSE_BUTTONS:
-           {
-               int32 mouseButtons = 3;         // good guess
-               if(get_mouse_type(&mouseButtons) != B_OK) {
-                       __glutWarning("error getting number of mouse buttons");
-               }
-               return mouseButtons;
-           }
-
-       default:
-               __glutWarning("invalid glutDeviceGet parameter: %d", info);
-               return -1;
-       }
-}
-
-/***********************************************************
- *     FUNCTION:       glutGetModifiers (9.4)
- *
- *     DESCRIPTION:  get the modifier key state for the current window
- ***********************************************************/
-int glutGetModifiers() {
-       if(gState.modifierKeys == (int) ~0) {
-         __glutWarning(
-               "glutCurrentModifiers: do not call outside core input callback.");
-    return 0;
-       }
-       return gState.modifierKeys;
-}
-
diff --git a/src/glut/beos/glutInit.cpp b/src/glut/beos/glutInit.cpp
deleted file mode 100644 (file)
index 4010813..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutInit.cpp
- *
- *     DESCRIPTION:    initialize GLUT state
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include <string.h>
-#include <stdlib.h>
-#include <signal.h>
-#include "glutint.h"
-#include "glutState.h"
-#include "glutBlocker.h"
-#include "beos_x11.h"
-
-/***********************************************************
- *     Global variables
- ***********************************************************/
-GlutState gState;
-char *__glutProgramName = NULL;
-
-/***********************************************************
- *     Private variables
- ***********************************************************/
-static int __glutArgc;
-static char **__glutArgv;
-
-/***********************************************************
- *     FUNCTION:       __glutInitTime
- *
- *     DESCRIPTION:  set up start time variable
- ***********************************************************/
-void __glutInitTime(bigtime_t *beginning)
-{
-  static int beenhere = 0;
-  static bigtime_t genesis;
-
-  if (!beenhere) {
-    genesis = system_time();
-    beenhere = 1;
-  }
-  *beginning = genesis;
-}
-
-/***********************************************************
- *     FUNCTION:       removeArgs
- *
- *     DESCRIPTION:  helper function for glutInit to remove args
- *             from argv variable passed in
- ***********************************************************/
-static void
-removeArgs(int *argcp, char **argv, int numToRemove)
-{
-  int i, j;
-
-  for (i = 0, j = numToRemove; argv[j]; i++, j++) {
-    argv[i] = argv[j];
-  }
-  argv[i] = NULL;
-  *argcp -= numToRemove;
-}
-
-/***********************************************************
- *     FUNCTION:       bAppThread
- *
- *     DESCRIPTION:  starts the BApplication message loop running
- ***********************************************************/
-static int32 bAppThread(void *arg) {
-       be_app->Lock();
-       return be_app->Run();
-}
-
-/***********************************************************
- *     FUNCTION:       sigHandler
- *
- *     DESCRIPTION:  shuts down the app on CTRL-C
- ***********************************************************/
-static void sigHandler(int) {
-  gState.quitAll = true;
-  gBlock.NewEvent();
-}
-
-/***********************************************************
- *     FUNCTION:       glutInit (2.1)
- *
- *     DESCRIPTION:  create BApplication, parse cmd-line arguments,
- *             and set up gState structure.
- ***********************************************************/
-void glutInit(int *argcp, char **argv) {
-  char *str, *geometry = NULL;
-  int i;
-
-  if (gState.display) {
-    __glutWarning("glutInit being called a second time.");
-    return;
-  }
-  /* Determine temporary program name. */
-  str = strrchr(argv[0], '/');
-  if (str == NULL) {
-    __glutProgramName = argv[0];
-  } else {
-    __glutProgramName = str + 1;
-  }
-
-  /* Make private copy of command line arguments. */
-  __glutArgc = *argcp;
-  __glutArgv = (char **) malloc(__glutArgc * sizeof(char *));
-  if (!__glutArgv)
-    __glutFatalError("out of memory.");
-  for (i = 0; i < __glutArgc; i++) {
-    __glutArgv[i] = strdup(argv[i]);
-    if (!__glutArgv[i])
-      __glutFatalError("out of memory.");
-  }
-
-  /* determine permanent program name */
-  str = strrchr(__glutArgv[0], '/');
-  if (str == NULL) {
-    __glutProgramName = __glutArgv[0];
-  } else {
-    __glutProgramName = str + 1;
-  }
-
-  /* parse arguments for standard options */
-  for (i = 1; i < __glutArgc; i++) {
-    if (!strcmp(__glutArgv[i], "-display")) {
-      __glutWarning("-display option only valid for X glut.");
-      if (++i >= __glutArgc) {
-        __glutFatalError(
-          "follow -display option with X display name.");
-      }
-      removeArgs(argcp, &argv[1], 2);
-    } else if (!strcmp(__glutArgv[i], "-geometry")) {
-      if (++i >= __glutArgc) {
-        __glutFatalError(
-          "follow -geometry option with geometry parameter.");
-      }
-      geometry = __glutArgv[i];
-      removeArgs(argcp, &argv[1], 2);
-    } else if (!strcmp(__glutArgv[i], "-direct")) {
-      __glutWarning("-direct option only valid for X glut.");
-      removeArgs(argcp, &argv[1], 1);
-    } else if (!strcmp(__glutArgv[i], "-indirect")) {
-      __glutWarning("-indirect option only valid for X glut.");
-      removeArgs(argcp, &argv[1], 1);
-    } else if (!strcmp(__glutArgv[i], "-iconic")) {
-      __glutWarning("-iconic option doesn't make sense in BeOS.");
-      removeArgs(argcp, &argv[1], 1);
-    } else if (!strcmp(__glutArgv[i], "-gldebug")) {
-      gState.debug = true;
-      removeArgs(argcp, &argv[1], 1);
-    } else if (!strcmp(__glutArgv[i], "-sync")) {
-      __glutWarning("-sync option only valid for X glut.");
-      removeArgs(argcp, &argv[1], 1);
-    } else {
-      /* Once unknown option encountered, stop command line
-         processing. */
-      break;
-    }
-  }
-  
-  __glutInit();  /* Create BApplication first so DisplayWidth() works */
-  if (geometry) {
-    int flags, x, y, width, height;
-
-    /* Fix bogus "{width|height} may be used before set"
-       warning */
-    width = 0;
-    height = 0;
-
-    flags = XParseGeometry(geometry, &x, &y,
-      (unsigned int *) &width, (unsigned int *) &height);
-    if (WidthValue & flags) {
-      /* Careful because X does not allow zero or negative
-         width windows */
-      if (width > 0)
-        gState.initWidth = width;
-    }
-    if (HeightValue & flags) {
-      /* Careful because X does not allow zero or negative
-         height windows */
-      if (height > 0)
-        gState.initHeight = height;
-    }
-    if (XValue & flags) {
-      if (XNegative & flags)
-        x = DisplayWidth() + x - gState.initWidth;
-      /* Play safe: reject negative X locations */
-      if (x >= 0)
-        gState.initX = x;
-    }
-    if (YValue & flags) {
-      if (YNegative & flags)
-        y = DisplayHeight() + y - gState.initHeight;
-      /* Play safe: reject negative Y locations */
-      if (y >= 0)
-        gState.initY = y;
-    }
-  }
-}
-
-/***********************************************************
- *     FUNCTION:       __glutInit
- *
- *     DESCRIPTION:  create BApplication, parse cmd-line arguments,
- *             and set up gState structure.
- ***********************************************************/
-void __glutInit() {
-  // open BApplication
-  gState.display = new BApplication("application/x-glut-demo");
-  be_app->Unlock();
-  gState.appthread = spawn_thread(bAppThread, "BApplication", B_NORMAL_PRIORITY, 0);
-  resume_thread(gState.appthread);
-
-  bigtime_t unused;
-  __glutInitTime(&unused);
-
-  /* set atexit() function to destroy all windows before exiting */
-  if(atexit(__glutDestroyAllWindows))
-       __glutFatalError("can't set exit handler");
-  
-  /* similarly, destroy all windows on CTRL-C */
-  signal(SIGINT, sigHandler);
-}
-
-/***********************************************************
- *     FUNCTION:       glutInitWindowPosition (2.2)
- *
- *     DESCRIPTION:  set initial window position
- ***********************************************************/
-void glutInitWindowPosition(int x, int y) {
-       gState.initX = x;
-       gState.initY = y;
-}
-
-/***********************************************************
- *     FUNCTION:       glutInitWindowSize (2.2)
- *
- *     DESCRIPTION:  set initial window size
- ***********************************************************/
-void glutInitWindowSize(int width, int height) {
-       gState.initWidth = width;
-       gState.initHeight = height;
-}
-
-/***********************************************************
- *     FUNCTION:       glutInitDisplayMode (2.3)
- *
- *     DESCRIPTION:  set initial display mode
- ***********************************************************/
-void glutInitDisplayMode(unsigned int mode) {
-       gState.displayMode = mode;
-}
diff --git a/src/glut/beos/glutMenu.cpp b/src/glut/beos/glutMenu.cpp
deleted file mode 100644 (file)
index 2f9e6a2..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *  FILE:      glutMenu.cpp
- *
- *     DESCRIPTION:    code for popup menu handling
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include <stdlib.h>
-#include <string.h>
-#include "glutint.h"
-#include "glutState.h"
-
-/***********************************************************
- *     Private variables
- ***********************************************************/
-static GlutMenu **menuList = 0;
-static int menuListSize = 0;
-
-/***********************************************************
- *     FUNCTION:       getUnusedMenuSlot
- *
- *     DESCRIPTION:  helper function to get a new menu slot
- ***********************************************************/
-GlutMenu *__glutGetMenuByNum(int menunum)
-{
-  if (menunum < 1 || menunum > menuListSize) {
-    return NULL;
-  }
-  return menuList[menunum - 1];
-}
-
-/***********************************************************
- *     FUNCTION:       getUnusedMenuSlot
- *
- *     DESCRIPTION:  helper function to get a new menu slot
- ***********************************************************/
-static int
-getUnusedMenuSlot(void)
-{
-  int i;
-
-  /* Look for allocated, unused slot. */
-  for (i = 0; i < menuListSize; i++) {
-    if (!menuList[i]) {
-      return i;
-    }
-  }
-  /* Allocate a new slot. */
-  menuListSize++;
-  menuList = (GlutMenu **)
-      realloc(menuList, menuListSize * sizeof(GlutMenu *));
-  if (!menuList)
-    __glutFatalError("out of memory.");
-  menuList[menuListSize - 1] = NULL;
-  return menuListSize - 1;
-}
-
-/***********************************************************
- *     FUNCTION:       glutCreateMenu (6.1)
- *
- *     DESCRIPTION:  create a new menu
- ***********************************************************/
-int APIENTRY 
-glutCreateMenu(GLUTselectCB selectFunc)
-{
-  GlutMenu *menu;
-  int menuid;
-
-  menuid = getUnusedMenuSlot();
-  menu = new GlutMenu(menuid, selectFunc);     // constructor sets up members
-  menuList[menuid] = menu;
-  gState.currentMenu = menu;
-  return menuid + 1;
-}
-
-/***********************************************************
- *     FUNCTION:       glutSetMenu (6.2)
- *                             glutGetMenu
- *
- *     DESCRIPTION:  set and get the current menu
- ***********************************************************/
-int APIENTRY 
-glutGetMenu(void)
-{
-  if (gState.currentMenu) {
-    return gState.currentMenu->id + 1;
-  } else {
-    return 0;
-  }
-}
-
-void APIENTRY 
-glutSetMenu(int menuid)
-{
-  GlutMenu *menu;
-
-  if (menuid < 1 || menuid > menuListSize) {
-    __glutWarning("glutSetMenu attempted on bogus menu.");
-    return;
-  }
-  menu = menuList[menuid - 1];
-  if (!menu) {
-    __glutWarning("glutSetMenu attempted on bogus menu.");
-    return;
-  }
-  gState.currentMenu = menu;
-}
-
-/***********************************************************
- *     FUNCTION:       glutDestroyMenu (6.3)
- *
- *     DESCRIPTION:  destroy the specified menu
- ***********************************************************/
-void APIENTRY 
-glutDestroyMenu(int menunum)
-{
-  GlutMenu *menu = __glutGetMenuByNum(menunum);
-  menuList[menunum - 1] = 0;
-  if (gState.currentMenu == menu) {
-    gState.currentMenu = 0;
-  }
-  delete menu;
-}
-
-/***********************************************************
- *     FUNCTION:       glutAddMenuEntry (6.4)
- *
- *     DESCRIPTION:  add a new menu item
- ***********************************************************/
-void
-glutAddMenuEntry(const char *label, int value)
-{
-       new GlutMenuItem(gState.currentMenu, false, value, label);
-}
-
-/***********************************************************
- *     FUNCTION:       glutAddSubMenu (6.5)
- *
- *     DESCRIPTION:  add a new submenu
- ***********************************************************/
-void
-glutAddSubMenu(const char *label, int menu)
-{
-       new GlutMenuItem(gState.currentMenu, true, menu-1, label);
-}
-
-/***********************************************************
- *     FUNCTION:       glutChangeToMenuEntry (6.6)
- *
- *     DESCRIPTION:  change menuitem into a menu entry
- ***********************************************************/
-void
-glutChangeToMenuEntry(int num, const char *label, int value)
-{
-  GlutMenuItem *item;
-  int i;
-
-  i = gState.currentMenu->num;
-  item = gState.currentMenu->list;
-  while (item) {
-    if (i == num) {
-      free(item->label);
-      item->label = strdup(label);
-      item->isTrigger = false;
-      item->value = value;
-      return;
-    }
-    i--;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-/***********************************************************
- *     FUNCTION:       glutChangeToSubMenu (6.7)
- *
- *     DESCRIPTION:  change menuitem into a submenu
- ***********************************************************/
-void
-glutChangeToSubMenu(int num, const char *label, int menu)
-{
-  GlutMenuItem *item;
-  int i;
-
-  i = gState.currentMenu->num;
-  item = gState.currentMenu->list;
-  while (item) {
-    if (i == num) {
-      free(item->label);
-      item->label = strdup(label);
-      item->isTrigger = true;
-      item->value = menu-1;
-      return;
-    }
-    i--;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-/***********************************************************
- *     FUNCTION:       glutRemoveMenuItem (6.8)
- *
- *     DESCRIPTION:  remove a menu item
- ***********************************************************/
-void
-glutRemoveMenuItem(int num)
-{
-  GlutMenuItem *item, **prev;
-  int i;
-
-  i = gState.currentMenu->num;
-  prev = &gState.currentMenu->list;
-  item = gState.currentMenu->list;
-
-  while (item) {
-    if (i == num) {
-      gState.currentMenu->num--;
-
-      /* Patch up menu's item list. */
-      *prev = item->next;
-
-      free(item->label);
-      delete item;
-      return;
-    }
-    i--;
-    prev = &item->next;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-/***********************************************************
- *     FUNCTION:       glutAttachMenu (6.9)
- *                             glutDetachMenu
- *
- *     DESCRIPTION:  attach and detach menu from view
- ***********************************************************/
-void
-glutAttachMenu(int button)
-{
-       gState.currentWindow->menu[button] = gState.currentMenu->id + 1;
-}
-
-void
-glutDetachMenu(int button)
-{
-       gState.currentWindow->menu[button] = 0;
-}
-
-/***********************************************************
- *     CLASS:          GlutMenu
- *
- *     FUNCTION:       CreateBMenu
- *
- *     DESCRIPTION:  construct a BPopupMenu for this menu
- ***********************************************************/
-BMenu *GlutMenu::CreateBMenu(bool toplevel) {
-       BMenu *bpopup;
-       if(toplevel) {
-               bpopup = new GlutPopUp(id+1);
-       } else {
-               bpopup = new BMenu("");
-       }
-       GlutMenuItem *item = list;
-       while (item) {
-               GlutBMenuItem *bitem;
-               if(item->isTrigger) {
-                       // recursively call CreateBMenu
-                       bitem = new GlutBMenuItem(menuList[item->value]->CreateBMenu(false));
-                       bitem->SetLabel(item->label);
-                       bitem->menu = 0;        // real menu items start at 1
-                       bitem->value = 0;
-               } else {
-                       bitem = new GlutBMenuItem(item->label);
-                       bitem->menu = id + 1;
-                       bitem->value = item->value;
-               }
-               bpopup->AddItem(bitem, 0);
-               item = item->next;
-       }
-       return bpopup;
-}
-
-/***********************************************************
- *     CLASS:          GlutMenu
- *
- *     FUNCTION:       (destructor)
- *
- *     DESCRIPTION:  destroy the menu and its items (but not submenus!)
- ***********************************************************/
-GlutMenu::~GlutMenu() {
-       while (list) {
-               GlutMenuItem *next = list->next;
-               delete list;
-               list = next;
-       }
-}
-
-/***********************************************************
- *     CLASS:          GlutMenuItem
- *
- *     FUNCTION:       (constructor)
- *
- *     DESCRIPTION:  construct the new menu item and add to parent
- ***********************************************************/
-GlutMenuItem::GlutMenuItem(GlutMenu *n_menu, bool n_trig, int n_value, const char *n_label)
-{
-       menu = n_menu;
-       isTrigger = n_trig;
-       value = n_value;
-       label = strdup(n_label);
-       next = menu->list;
-       menu->list = this;
-       menu->num++;
-}
diff --git a/src/glut/beos/glutMenu.h b/src/glut/beos/glutMenu.h
deleted file mode 100644 (file)
index 1ee1706..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *  FILE:      glutMenu.h
- *
- *     DESCRIPTION:    the GlutMenu class is a simple popup menu
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include <Menu.h>
-#include <MenuItem.h>
-#include <PopUpMenu.h>
-
-/***********************************************************
- *     Definitions
- ***********************************************************/
-const int32 MENU_ITEM = 'menu';
-
-/***********************************************************
- *     CLASS:  GlutMenu
- ***********************************************************/
-class GlutMenuItem;
-class GlutPopUp;
-class GlutMenu {
-public:
-       GlutMenu(int n_id, GLUTselectCB n_select) {
-               id = n_id;
-               select = n_select;
-               list = 0;
-               num = 0;
-       }
-       ~GlutMenu();
-       BMenu *CreateBMenu(bool toplevel=true); // construct BPopUpMenu
-
-       // public data
-       int id;
-       GLUTselectCB select;    // callback function
-       GlutMenuItem *list;             // list of menu items
-       int num;                                // number of items
-};
-
-/***********************************************************
- *     CLASS:  GlutMenuItem
- ***********************************************************/
-class GlutMenuItem {
-public:
-       GlutMenuItem(GlutMenu *n_menu, bool n_trig, int n_value, const char *n_label);
-
-       // public data
-       GlutMenu *menu;         // parent menu
-       bool isTrigger;         // are we a submenu?
-       int value;                      // value to send, or submenu id if isTrigger
-       char *label;            // strdup'ed label string
-       GlutMenuItem *next; // next menu entry on list
-};
-
-/***********************************************************
- *     CLASS:  GlutPopUp
- ***********************************************************/
-class GlutPopUp : public BPopUpMenu {
-public:
-       GlutPopUp(int m) : BPopUpMenu(0, false, false) { menu = m;}
-       
-       BPoint point;   // point to start menu
-       GlutWindow *win;        // pointer to my window
-       int menu;               // my menu number
-};
-
-/***********************************************************
- *     CLASS:  GlutBMenuItem
- ***********************************************************/
-class GlutBMenuItem : public BMenuItem {
-public:
-       GlutBMenuItem(const char *name) : BMenuItem(name, 0) {}
-       GlutBMenuItem(BMenu* menu) : BMenuItem(menu) {}
-       int menu, value;
-};
diff --git a/src/glut/beos/glutOverlay.cpp b/src/glut/beos/glutOverlay.cpp
deleted file mode 100644 (file)
index fed757f..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutOverlay.cpp
- *
- *     DESCRIPTION:    we don't support overlays, so this code is
- *             really simple
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include "glutint.h"
-
-void glutEstablishOverlay() {
-       __glutFatalError("BeOS lacks overlay support.");
-}
-
-void glutUseLayer(GLenum layer) {
-       // ignore
-}
-
-void glutRemoveOverlay() {
-       // ignore
-}
-
-void glutPostOverlayRedisplay() {
-       // ignore
-}
-
-void glutShowOverlay() {
-       // ignore
-}
-
-void glutHideOverlay() {
-       // ignore
-}
-
-void glutPostWindowOverlayRedisplay(int win) {
-       // ignore
-}
diff --git a/src/glut/beos/glutState.h b/src/glut/beos/glutState.h
deleted file mode 100644 (file)
index 9c44eb6..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutState.h
- *
- *     DESCRIPTION:    the global state for GLUT
- *             (takes the place of glutint.h in the C version)
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include <Application.h>
-#include "glutWindow.h"
-#include "glutMenu.h"
-
-/***********************************************************
- *     CLASS:  GlutState
- *
- *     DESCRIPTION:    all the global state variables
- ***********************************************************/
-struct GlutState {
-       BApplication *display;
-       thread_id appthread;
-       
-       int initX, initY;                       // initial window position
-       int initWidth, initHeight;      // initial window size
-       unsigned int displayMode;       // initial display mode
-       char *displayString;            // verbose display mode
-
-       GlutWindow *currentWindow;      // current window
-       GlutMenu *currentMenu;          // current menu
-       
-       GlutWindow **windowList;        // array of pointers to windows
-       int windowListSize;                     // size of window list
-       
-       GLUTidleCB idle;                                // idle callback
-       GLUTmenuStatusCB menuStatus;    // menu status callback
-       int modifierKeys;                               // only valid during keyboard callback
-       
-       bool debug;                                     // call glGetError
-       bool quitAll;                           // quit 
-       
-       GlutState() {
-               display = 0;
-               appthread = 0;
-               initX = initY = -1;
-               initWidth = initHeight = 300;
-               displayMode = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH;
-               displayString = 0;
-               currentWindow = 0;
-               currentMenu = 0;
-               windowList = 0;
-               windowListSize = 0;
-               idle = 0;
-               menuStatus = 0;
-               modifierKeys = ~0;
-               debug = quitAll = false;
-       }
-};
-
-/***********************************************************
- *     Global variable (declared in glutInit.cpp)
- ***********************************************************/
-extern GlutState gState;
diff --git a/src/glut/beos/glutWindow.cpp b/src/glut/beos/glutWindow.cpp
deleted file mode 100644 (file)
index 66ea2a0..0000000
+++ /dev/null
@@ -1,633 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutWindow.cpp
- *
- *     DESCRIPTION:    all the routines for dealing with GlutWindows
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include <stdlib.h>
-#include "glutint.h"
-#include "glutState.h"
-#include "glutBlocker.h"
-
-/***********************************************************
- *     FUNCTION:       getUnusedWindowSlot
- *
- *     DESCRIPTION:  helper function to get a new window slot
- ***********************************************************/
-static int
-getUnusedWindowSlot()
-{
-  int i;
-
-  /* Look for allocated, unused slot. */
-  for (i = 0; i < gState.windowListSize; i++) {
-    if (!gState.windowList[i]) {
-      return i;
-    }
-  }
-  /* Allocate a new slot. */
-  gState.windowListSize++;
-  gState.windowList = (GlutWindow **)
-    realloc(gState.windowList,
-      gState.windowListSize * sizeof(GlutWindow *));
-
-  if (!gState.windowList)
-    __glutFatalError("out of memory.");
-  gState.windowList[gState.windowListSize - 1] = NULL;
-  return gState.windowListSize - 1;
-}
-
-/***********************************************************
- *     FUNCTION:       __glutDefaultDisplay
- *                             __glutDefaultReshape
- *
- *     DESCRIPTION:  default display and reshape functions
- ***********************************************************/
-static void
-__glutDefaultDisplay(void)
-{
-  /* XXX Remove the warning after GLUT 3.0. */
-  __glutWarning("The following is a new check for GLUT 3.0; update your code.");
-  __glutFatalError(
-    "redisplay needed for window %d, but no display callback.",
-    gState.currentWindow->num + 1);
-}
-
-void
-__glutDefaultReshape(int width, int height)
-{
-  /* Adjust the viewport of the window */
-  glViewport(0, 0, (GLsizei) width, (GLsizei) height);
-}
-
-/***********************************************************
- *     CLASS:          GlutWindow
- *
- *     FUNCTION:       (constructor)
- *
- *     DESCRIPTION:  creates a new GLUT window
- *             note:  subwindows don't resize, but top-level windows
- *             follow all sides
- ***********************************************************/
-GlutWindow::GlutWindow(GlutWindow *nparent, char *name,
-               int x, int y, int width, int height, ulong options) :
-               BGLView(
-               (nparent ? BRect(x,y,x+width-1,y+height-1) :
-                       BRect(0,0,width-1,height-1)), name,
-               (nparent ? B_FOLLOW_NONE : B_FOLLOW_ALL_SIDES), 
-               B_WILL_DRAW|B_FRAME_EVENTS|B_FULL_UPDATE_ON_RESIZE|B_PULSE_NEEDED,
-               options)
-{
-       // add myself to window list
-       num = getUnusedWindowSlot();
-       gState.windowList[num] = this;
-
-       // set up parent/children relationships
-       parent = nparent;
-       if (parent) {
-               siblings = parent->children;
-               parent->children = this;
-       } else {
-               siblings = 0;
-       }
-       children = 0;
-               
-       // initialize variables
-       cursor = GLUT_CURSOR_INHERIT;   // default cursor
-       for (int i = 0; i < GLUT_MAX_MENUS; i++) {
-               menu[i] = 0;
-       }
-       m_width = width;
-       m_height = height;
-       m_buttons = 0;
-       
-       // clear callbacks
-       display = __glutDefaultDisplay;
-       reshape = __glutDefaultReshape;
-       mouse = 0;
-       motion = 0;
-       passive = 0;
-       entry = 0;
-       keyboard = 0;
-       visibility = 0;
-       special = 0;
-       windowStatus = 0;
-               
-       // clear event counters
-       anyevents = 1;
-       displayEvent = 1;       // get a reshape and a display event right away
-       reshapeEvent = 1;
-       mouseEvent = 0;
-       motionEvent = 0;
-       passiveEvent = 0;
-       entryEvent = 0;
-       keybEvent = 0;
-       windowStatusEvent = 0; // DirectConnected() will report change in 
-       visState = -1;         // visibility
-       specialEvent = 0;
-       statusEvent = 0;
-       menuEvent = 0;
-       visible = true;
-       gBlock.QuickNewEvent();
-       
-       // if i'm a subwindow, add me to my parent view
-       if (parent) {
-               parent->Window()->Lock();
-               parent->AddChild(this);
-               parent->Window()->Unlock();
-       } else {
-               // if I'm a top-level window, create my BWindow
-               GlutBWindow *mybwindow = new GlutBWindow(
-                       BRect(x,y,x+width-1,y+height-1), name);
-               mybwindow->AddChild(this);
-               mybwindow->bgl = this;
-               mybwindow->Show();
-       }
-       
-       // give me the keyboard focus (focus follows mouse, X style, as
-       // implemented in GlutWindow::MouseMoved())
-       Window()->Lock();
-       MakeFocus();
-       Window()->Unlock();
-       
-       // make myself the default window
-       __glutSetWindow(this);
-}
-
-/***********************************************************
- *     FUNCTION:       glutCreateWindow (4.1)
- *
- *     DESCRIPTION:  creates a new GLUT window
- ***********************************************************/
-int glutCreateWindow(const char *name) {
-       if (!be_app)
-               __glutInit();
-
-       ulong options;
-       if (!__glutConvertDisplayMode(&options)) {
-               __glutWarning("visual with necessary capabilities not found.");
-       }
-       
-       // if X or Y is negative, then start at a reasonable position
-       bool defaultxy = (gState.initX < 0) || (gState.initY < 0);
-       
-       GlutWindow *window = new GlutWindow(0, const_cast<char*>(name), 
-               (defaultxy ? 50 : gState.initX), (defaultxy ? 50 : gState.initY), 
-               gState.initWidth, gState.initHeight, options);
-               
-       return window->num + 1;
-}
-
-/***********************************************************
- *     FUNCTION:       glutCreateSubWindow (4.2)
- *
- *     DESCRIPTION:  creates a new GLUT subwindow
- *             Note: a subwindow is a GlutWindow (which is actually
- *             a BGLView) without its own BWindow
- ***********************************************************/
-int glutCreateSubWindow(int win, int x, int y, int width, int height) {
-       ulong options;
-       if (!__glutConvertDisplayMode(&options)) {
-               __glutFatalError("visual with necessary capabilities not found.");
-       }
-       
-       GlutWindow *window = new GlutWindow(gState.windowList[win-1], "child",
-               x, y, width, height, options);
-       
-       return window->num + 1;
-}
-
-/***********************************************************
- *     FUNCTION:       __glutSetWindow
- *
- *     DESCRIPTION:  set the current window (utility function)
- ***********************************************************/
-void
-__glutSetWindow(GlutWindow * window)
-{
-  if (gState.currentWindow)
-         gState.currentWindow->UnlockGL();
-  gState.currentWindow = window;
-  gState.currentWindow->LockGL();
-}
-
-/***********************************************************
- *     FUNCTION:       glutSetWindow (4.3)
- *                             glutGetWindow
- *
- *     DESCRIPTION:  set and get the current window
- ***********************************************************/
-void glutSetWindow(int win) {
-  GlutWindow *window;
-
-  if (win < 1 || win > gState.windowListSize) {
-    __glutWarning("glutSetWindow attempted on bogus window.");
-    return;
-  }
-  window = gState.windowList[win - 1];
-  if (!window) {
-    __glutWarning("glutSetWindow attempted on bogus window.");
-    return;
-  }
-  __glutSetWindow(window);
-}
-
-int glutGetWindow() {
-  if (gState.currentWindow) {
-    return gState.currentWindow->num + 1;
-  } else {
-    return 0;
-  }
-}
-
-/***********************************************************
- *     FUNCTION:       __glutDestroyWindow
- *
- *     DESCRIPTION:  recursively set entries to 0
- ***********************************************************/
-static void
-__glutDestroyWindow(GlutWindow *window, GlutWindow *initialWindow) {
-       // first, find all children recursively and set their entries to 0
-       GlutWindow *cur = window->children;
-       while (cur) {
-               GlutWindow *siblings = cur->siblings;
-               __glutDestroyWindow(cur, initialWindow);
-               cur = siblings;
-       }
-       
-  /* Remove from parent's children list (only necessary for
-     non-initial windows and subwindows!). */
-  GlutWindow *parent = window->parent;
-  if (parent && parent == initialWindow->parent) {
-    GlutWindow **prev = &parent->children;
-    cur = parent->children;
-    while (cur) {
-      if (cur == window) {
-        *prev = cur->siblings;
-        break;
-      }
-      prev = &(cur->siblings);
-      cur = cur->siblings;
-    }
-  }
-  
-  // finally, check if we are the current window, and set to 0
-  if (gState.currentWindow == window) {
-       gState.currentWindow = 0;
-  }
-  gState.windowList[window->num] = 0;
-}
-
-/***********************************************************
- *     FUNCTION:       glutDestroyWindow (4.4)
- *
- *     DESCRIPTION:  destroy window and all its children
- ***********************************************************/
-void glutDestroyWindow(int win) {
-       // can't destroy a window if another window has the GL context
-       if (gState.currentWindow)
-               gState.currentWindow->UnlockGL();
-
-       // lock the window
-       GlutWindow *window = gState.windowList[win-1];
-       BWindow *bwindow = window->Window();
-       bwindow->Lock();
-
-       // if win is the current window, set current window to 0
-       if (gState.currentWindow == window) {
-               gState.currentWindow = 0;
-       }
-
-       // recursively set child entries to 0
-       __glutDestroyWindow(window, window);
-
-       // try flushing OpenGL
-       window->LockGL();
-       glFlush();
-       window->UnlockGL();
-
-       // now, if the window was top-level, delete its BWindow
-       if(!window->parent) {
-               bwindow->Quit();
-       } else {
-               // else, detach it from the BWindow and delete it
-               window->RemoveSelf();
-               delete window;
-               bwindow->Unlock();
-       }
-       // relock GL if the current window is still valid
-       if(gState.currentWindow)
-               gState.currentWindow->LockGL();
-}
-
-/***********************************************************
- *     FUNCTION:       __glutDestroyAllWindows
- *
- *     DESCRIPTION:  destroy all windows when exit() is called
- *                this seems to be necessary to avoid delays
- *                and crashes when using BDirectWindow
- ***********************************************************/
-void __glutDestroyAllWindows() {
-       for(int i=0; i<gState.windowListSize; i++) {
-               if (gState.windowList[i]) {
-                       glutDestroyWindow(i + 1);
-               }
-       }
-       gState.display->Lock();
-       gState.display->Quit();
-       status_t ignored;
-       wait_for_thread(gState.appthread, &ignored);
-}
-
-/***********************************************************
- *     FUNCTION:       glutPostRedisplay (4.5)
- *
- *     DESCRIPTION:  mark window as needing redisplay
- ***********************************************************/
-void glutPostRedisplay() {
-       gState.currentWindow->Window()->Lock();
-       gState.currentWindow->anyevents = true;
-       gState.currentWindow->displayEvent = true;
-       gState.currentWindow->Window()->Unlock();
-       gBlock.QuickNewEvent();
-}
-
-/***********************************************************
- *     FUNCTION:       glutPostWindowRedisplay
- *
- *     DESCRIPTION:  mark window as needing redisplay
- ***********************************************************/
-void glutPostWindowRedisplay(int win) {
-       GlutWindow *gwin = gState.windowList[win - 1];
-       gwin->Window()->Lock();
-       gwin->anyevents = true;
-       gwin->displayEvent = true;
-       gwin->Window()->Unlock();
-       gBlock.QuickNewEvent();
-}
-
-/***********************************************************
- *     FUNCTION:       glutSwapBuffers (4.6)
- *
- *     DESCRIPTION:  swap buffers
- ***********************************************************/
-void glutSwapBuffers() {
-       gState.currentWindow->SwapBuffers();
-}
-
-/***********************************************************
- *     FUNCTION:       glutPositionWindow (4.7)
- *
- *     DESCRIPTION:  move window
- ***********************************************************/
-void glutPositionWindow(int x, int y) {
-       BDirectWindow *win = dynamic_cast<BDirectWindow*>(gState.currentWindow->Window());
-       win->Lock();
-       if (gState.currentWindow->parent)
-               gState.currentWindow->MoveTo(x, y);     // move the child view
-       else {
-               if(win->IsFullScreen()) {
-                       win->SetFullScreen(false);
-               }
-               win->MoveTo(x, y);  // move the window
-       }
-       win->Unlock();
-}
-
-/***********************************************************
- *     FUNCTION:       glutReshapeWindow (4.8)
- *
- *     DESCRIPTION:  reshape window (we'll catch the callback
- *                             when the view gets a Draw() message
- ***********************************************************/
-void glutReshapeWindow(int width, int height) {
-       BDirectWindow *win = dynamic_cast<BDirectWindow*>(gState.currentWindow->Window());
-       win->Lock();
-       if (gState.currentWindow->parent)
-               gState.currentWindow->ResizeTo(width-1, height-1);              // resize the child
-       else {
-               if(win->IsFullScreen()) {
-                       win->SetFullScreen(false);
-               }
-               win->ResizeTo(width-1, height-1);  // resize the parent
-       }
-       win->Unlock();
-}
-
-/***********************************************************
- *     FUNCTION:       glutFullScreen (4.9)
- *
- *     DESCRIPTION:  makes the window full screen
- ***********************************************************/
-void glutFullScreen() {
-       BDirectWindow *win = dynamic_cast<BDirectWindow*>(gState.currentWindow->Window());
-       win->Lock();
-       win->SetFullScreen(true);
-       win->Unlock();
-}
-
-/***********************************************************
- *     FUNCTION:       glutPopWindow (4.10)
- *                             glutPushWindow
- *
- *     DESCRIPTION:  change the stacking order of the current window
- *             NOTE:   I can't figure out how to do this for windows,
- *                             and there is no concept of "stacking order" for
- *                             subwindows, so these are currently no-ops.
- ***********************************************************/
-void glutPopWindow() { }
-void glutPushWindow() { }
-
-/***********************************************************
- *     FUNCTION:       glutShowWindow (4.11)
- *                             glutHideWindow
- *                             glutIconifyWindow
- *
- *     DESCRIPTION:  change display status of current window
- ***********************************************************/
-void glutShowWindow() {
-       gState.currentWindow->Window()->Lock();
-       if (gState.currentWindow->parent)       // subwindow
-               gState.currentWindow->Show();
-       else {
-               if(gState.currentWindow->Window()->IsHidden())
-                       gState.currentWindow->Window()->Show(); // show the actual BWindow
-               gState.currentWindow->Window()->Minimize(false);
-       }
-       gState.currentWindow->Window()->Unlock();
-}
-
-void glutHideWindow() {
-       gState.currentWindow->Window()->Lock();
-       if (gState.currentWindow->parent)       // subwindow
-               gState.currentWindow->Hide();
-       else
-               gState.currentWindow->Window()->Hide(); // show the actual BWindow
-       gState.currentWindow->Window()->Unlock();
-}
-
-void glutIconifyWindow() {
-       if(gState.currentWindow->parent)
-               __glutFatalError("can't iconify a subwindow");
-               
-       gState.currentWindow->Window()->Lock();
-       gState.currentWindow->Window()->Minimize(true);
-       gState.currentWindow->Window()->Unlock();
-}
-
-/***********************************************************
- *     FUNCTION:       glutSetWindowTitle (4.12)
- *                             glutSetIconTitle
- *
- *     DESCRIPTION:  set the window title (icon title is same)
- ***********************************************************/
-void glutSetWindowTitle(const char *name) {
-       if (gState.currentWindow->parent)
-               __glutFatalError("glutSetWindowTitle: isn't a top-level window");
-       
-       gState.currentWindow->Window()->Lock();
-       gState.currentWindow->Window()->SetTitle(name);
-       gState.currentWindow->Window()->Unlock();
-}
-
-void glutSetIconTitle(const char *name) {
-       glutSetWindowTitle(name);
-}
-
-/***********************************************************
- *     FUNCTION:       __glutConvertDisplayMode
- *
- *     DESCRIPTION:  converts the current display mode into a BGLView
- *             display mode, printing warnings as appropriate.
- *
- *     PARAMETERS:      if options is non-NULL, the current display mode is
- *             returned in it.
- *
- *     RETURNS:        1 if the current display mode is possible, else 0
- ***********************************************************/
-int __glutConvertDisplayMode(unsigned long *options) {
-       if (gState.displayString) {
-               /* __glutDisplayString should be NULL except if
-       glutInitDisplayString has been called to register a
-       different display string.  Calling glutInitDisplayString
-       means using a string instead of an integer mask determine
-       the visual to use.  This big ugly code is in glutDstr.cpp */
-       return __glutConvertDisplayModeFromString(options);
-    }
-
-       if(options) {
-               ulong newoptions = 0;
-               if(gState.displayMode & GLUT_ACCUM)
-                       newoptions |= BGL_ACCUM;
-               if(gState.displayMode & GLUT_ALPHA)
-                       newoptions |= BGL_ALPHA;
-               if(gState.displayMode & GLUT_DEPTH)
-                       newoptions |= BGL_DEPTH;
-               if(gState.displayMode & GLUT_DOUBLE)
-                       newoptions |= BGL_DOUBLE;
-               if(gState.displayMode & GLUT_STENCIL)
-                       newoptions |= BGL_STENCIL;
-               *options = newoptions;
-       }
-       
-       if(gState.displayMode & GLUT_INDEX) {
-               __glutWarning("BeOS doesn't support indexed color");
-               return 0;
-       }
-       if(gState.displayMode & GLUT_MULTISAMPLE) {
-               return 1;       // try to go without multisampling
-       }
-       if(gState.displayMode & GLUT_STEREO) {
-               __glutWarning("BeOS doesn't support stereo windows");
-               return 0;
-       }
-       if(gState.displayMode & GLUT_LUMINANCE) {
-               __glutWarning("BeOS doesn't support luminance color model");
-               return 0;
-       }
-       return 1;       // visual supported
-}
-
-/***********************************************************
- *     CLASS:          GlutBWindow
- *
- *     DESCRIPTION:  very thin wrapper around BWindow
- ***********************************************************/
-GlutBWindow::GlutBWindow(BRect frame, char *name) :
-                       BDirectWindow(frame, name, B_TITLED_WINDOW, 0) {
-       fConnectionDisabled = false;
-       bgl = 0;
-       SetPulseRate(100000);
-       
-       if (!SupportsWindowMode()) {
-               __glutFatalError("video card doesn't support windowed operation");
-       }
-}
-
-void GlutBWindow::DirectConnected( direct_buffer_info *info ) {
-       bgl->DirectConnected(info);
-       if(bgl && !fConnectionDisabled) {
-               bgl->EnableDirectMode(true);
-       }
-       int newVisState;
-       if((info->buffer_state & B_DIRECT_MODE_MASK) == B_DIRECT_START) {
-               bgl->visible = true;
-       }
-       if(!bgl->visible || info->buffer_state == B_DIRECT_STOP)
-               newVisState = GLUT_HIDDEN;
-       else {
-               if (info->clip_list_count == 0)
-                       newVisState = GLUT_FULLY_COVERED;
-               else if (info->clip_list_count == 1)
-                       newVisState = GLUT_FULLY_RETAINED;
-               else
-                       newVisState = GLUT_PARTIALLY_RETAINED;
-       }
-       if(newVisState != bgl->visState) {
-               bgl->visState = newVisState;
-               bgl->anyevents = bgl->windowStatusEvent = true;
-               gBlock.NewEvent();
-       }
-}
-
-GlutBWindow::~GlutBWindow() {
-       fConnectionDisabled = true;
-       if(bgl) {
-               bgl->EnableDirectMode(false);
-       }
-       if(!IsHidden())
-               Hide();
-       Sync();
-}      
-
-bool GlutBWindow::QuitRequested() {
-       gState.quitAll = true;
-       gBlock.NewEvent();
-       return false;   // don't quit now, wait for main thread to do it
-}
-
-void GlutBWindow::Minimize(bool minimize) {
-       bgl->visible = !minimize;
-       BWindow::Minimize(minimize);
-}
-
-void GlutBWindow::Hide() {
-       BWindow::Hide();
-       bgl->visible = false;
-}
-
-void GlutBWindow::Show() {
-       BWindow::Show();
-       bgl->visible = true;
-}
diff --git a/src/glut/beos/glutWindow.h b/src/glut/beos/glutWindow.h
deleted file mode 100644 (file)
index d3ac186..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/***********************************************************
- *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
- *
- * This program is freely distributable without licensing fees
- * and is provided without guarantee or warrantee expressed or
- * implied. This program is -not- in the public domain.
- *
- *
- *  FILE:      glutWindow.h
- *
- *     DESCRIPTION:    the GlutWindow class saves all events for
- *             handling by main thread
- ***********************************************************/
-
-/***********************************************************
- *     Headers
- ***********************************************************/
-#include <GL/glut.h>
-#include <Window.h>
-#include <GLView.h>
-
-/***********************************************************
- *     CLASS:  GlutWindow
- *
- *  INHERITS FROM:  BGLView (NOT BWindow!)
- *
- *  DESCRIPTION:       all information needed for windows and
- *                     subwindows (handled as similarly as possible)
- ***********************************************************/
-class GlutWindow : public BGLView {
-public:
-       GlutWindow(GlutWindow *nparent, char *name, int x, int y, int width,
-                               int height, ulong options);
-       
-       void KeyDown(const char *bytes, int32 numBytes);
-       void MouseDown(BPoint point);
-       void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
-       void FrameResized(float width, float height);
-       void Draw(BRect updateRect);
-       void Pulse();           // needed since MouseUp() is broken
-       void MouseCheck();      // check for button state changes
-       void ErrorCallback(GLenum errorCode);
-
-       static long MenuThread(void *menu);
-       
-       int num;                        // window number returned to user
-       int cursor;                     // my cursor
-#define GLUT_MAX_MENUS              3
-       int menu[GLUT_MAX_MENUS];       // my popup menus
-       int m_width, m_height;          // the last width and height reported to GLUT
-       uint32 m_buttons;                       // the last mouse button state
-
-       /* Window relationship state. */
-  GlutWindow *parent;   /* parent window */
-  GlutWindow *children; /* first child window */
-  GlutWindow *siblings; /* next sibling */
-
-       // leave out buttons and dials callbacks that we don't support
-  GLUTdisplayCB display;  /* redraw  */
-  GLUTreshapeCB reshape;  /* resize  (width,height) */
-  GLUTmouseCB mouse;    /* mouse  (button,state,x,y) */
-  GLUTmotionCB motion;  /* motion  (x,y) */
-  GLUTpassiveCB passive;  /* passive motion  (x,y) */
-  GLUTentryCB entry;    /* window entry/exit  (state) */
-  GLUTkeyboardCB keyboard;  /* keyboard  (ASCII,x,y) */
-  GLUTvisibilityCB visibility;  /* visibility  */
-  GLUTspecialCB special;  /* special key  */
-  GLUTwindowStatusCB windowStatus;  /* window status */
-
-       bool anyevents;         // were any events received?
-       bool displayEvent;              // call display
-       bool reshapeEvent;              // call reshape
-       bool mouseEvent;                // call mouse
-       bool motionEvent;               // call motion
-       bool passiveEvent;              // call passive
-       bool entryEvent;                // call entry
-       bool keybEvent;                 // call keyboard
-       bool windowStatusEvent;         // call visibility
-       bool specialEvent;              // call special
-       bool statusEvent;               // menu status changed
-       bool menuEvent;                 // menu selected
-       
-       int button, mouseState; // for mouse callback
-       int mouseX, mouseY; // for mouse callback
-       int motionX, motionY; // for motion callback
-       int passiveX, passiveY; // for passive callback
-       int entryState;  // for entry callback
-       unsigned char key;  // for keyboard callback
-       int keyX, keyY;  // for keyboard callback
-       int visState;  // for visibility callback
-       int specialKey; // for special key callback
-       int specialX, specialY; // for special callback
-       int modifierKeys;       // modifier key state
-       int menuStatus;         // for status callback
-       int statusX, statusY;   // for status callback
-       int menuNumber;         // for menu and status callbacks
-       int menuValue;          // for menu callback
-       bool visible;           // for visibility callback
-};
-
-/***********************************************************
- *     CLASS:  GlutBWindow
- *
- *  INHERITS FROM:     BDirectWindow
- *
- *     DESCRIPTION:  basically a BWindow that won't quit
- ***********************************************************/
-class GlutBWindow : public BDirectWindow {
-public:
-       GlutBWindow(BRect frame, char *name);
-       ~GlutBWindow();
-       void DirectConnected(direct_buffer_info *info);
-       bool QuitRequested();   // exits app
-       void Minimize(bool minimized);  // minimized windows are not visible
-       void Hide();
-       void Show();
-       GlutWindow *bgl;
-       bool fConnectionDisabled;
-};
diff --git a/src/glut/beos/glut_8x13.c b/src/glut/beos/glut_8x13.c
deleted file mode 100644 (file)
index 843c63d..0000000
+++ /dev/null
@@ -1,2073 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmap8By13 XXX
-#include "glutbitmap.h"
-#undef glutBitmap8By13
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch0data[] = { 0x0 };
-static const BitmapCharRec ch0 = {1,1,0,0,8,ch0data};
-#else
-static const BitmapCharRec ch0 = {0,0,0,0,8,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,8,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,8,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch127data[] = { 0x0 };
-static const BitmapCharRec ch127 = {1,1,0,0,8,ch127data};
-#else
-static const BitmapCharRec ch127 = {0,0,0,0,8,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,8,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,8,0};
-#endif
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch255 = {6,12,-1,2,8,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0x80,0x80,0xb8,0xc4,0x84,0x84,0xc4,0xb8,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {6,10,-1,2,8,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch253 = {6,12,-1,2,8,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch252 = {6,10,-1,0,8,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,0x0,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch251 = {6,10,-1,0,8,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch250 = {6,10,-1,0,8,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,0x0,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch249 = {6,10,-1,0,8,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0x80,0x78,0xc4,0xa4,0x94,0x8c,0x78,0x4,
-};
-
-static const BitmapCharRec ch248 = {6,8,-1,1,8,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x20,0x20,0x0,0xf8,0x0,0x20,0x20,
-};
-
-static const BitmapCharRec ch247 = {5,7,-1,-1,8,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch246 = {6,10,-1,0,8,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch245 = {6,10,-1,0,8,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch244 = {6,10,-1,0,8,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch243 = {6,10,-1,0,8,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch242 = {6,10,-1,0,8,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0x84,0x84,0x84,0x84,0xc4,0xb8,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch241 = {6,10,-1,0,8,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x8,0x50,0x30,0x48,
-};
-
-static const BitmapCharRec ch240 = {6,10,-1,0,8,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x0,0x50,0x50,
-};
-
-static const BitmapCharRec ch239 = {5,10,-1,0,8,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x0,0x90,0x60,
-};
-
-static const BitmapCharRec ch238 = {5,10,-1,0,8,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch237 = {5,10,-1,0,8,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch236 = {5,10,-1,0,8,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch235 = {6,10,-1,0,8,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,0x0,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch234 = {6,10,-1,0,8,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch233 = {6,10,-1,0,8,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,0x0,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch232 = {6,10,-1,0,8,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x20,0x10,0x78,0x84,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch231 = {6,8,-1,2,8,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x6c,0x92,0x90,0x7c,0x12,0x6c,
-};
-
-static const BitmapCharRec ch230 = {7,6,0,0,8,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x30,0x48,0x30,
-};
-
-static const BitmapCharRec ch229 = {6,10,-1,0,8,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch228 = {6,10,-1,0,8,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch227 = {6,10,-1,0,8,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch226 = {6,10,-1,0,8,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch225 = {6,10,-1,0,8,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch224 = {6,10,-1,0,8,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0x80,0xb8,0xc4,0x84,0x84,0xf8,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch223 = {6,9,-1,1,8,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0x80,0x80,0x80,0xf8,0x84,0x84,0x84,0xf8,0x80,
-};
-
-static const BitmapCharRec ch222 = {6,9,-1,0,8,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x20,0x20,0x20,0x20,0x50,0x88,0x88,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch221 = {5,10,-1,0,8,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch220 = {6,10,-1,0,8,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch219 = {6,10,-1,0,8,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch218 = {6,10,-1,0,8,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch217 = {6,10,-1,0,8,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x78,0xc4,0xa4,0xa4,0xa4,0x94,0x94,0x8c,0x78,0x4,
-};
-
-static const BitmapCharRec ch216 = {6,11,-1,1,8,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x84,0x48,0x30,0x30,0x48,0x84,
-};
-
-static const BitmapCharRec ch215 = {6,6,-1,-1,8,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch214 = {7,10,0,0,8,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch213 = {7,10,0,0,8,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x24,0x18,
-};
-
-static const BitmapCharRec ch212 = {7,10,0,0,8,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch211 = {7,10,0,0,8,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x8,0x10,
-};
-
-static const BitmapCharRec ch210 = {7,10,0,0,8,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0x82,0x86,0x8a,0x92,0xa2,0xc2,0x82,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch209 = {7,10,0,0,8,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0xfc,0x42,0x42,0x42,0xe2,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch208 = {7,9,0,0,8,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x50,0x50,
-};
-
-static const BitmapCharRec ch207 = {5,10,-1,0,8,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch206 = {5,10,-1,0,8,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch205 = {5,10,-1,0,8,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch204 = {5,10,-1,0,8,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xfc,0x80,0x80,0xf0,0x80,0x80,0xfc,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch203 = {6,10,-1,0,8,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xfc,0x80,0x80,0xf0,0x80,0x80,0xfc,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch202 = {6,10,-1,0,8,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xfc,0x80,0x80,0xf0,0x80,0x80,0xfc,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch201 = {6,10,-1,0,8,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xfc,0x80,0x80,0xf0,0x80,0x80,0xfc,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch200 = {6,10,-1,0,8,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x20,0x10,0x78,0x84,0x80,0x80,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch199 = {6,11,-1,2,8,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0x9e,0x90,0x90,0xf0,0x9c,0x90,0x90,0x90,0x6e,
-};
-
-static const BitmapCharRec ch198 = {7,9,0,0,8,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x30,0x48,0x30,
-};
-
-static const BitmapCharRec ch197 = {6,10,-1,0,8,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch196 = {6,10,-1,0,8,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch195 = {6,10,-1,0,8,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch194 = {6,10,-1,0,8,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch193 = {6,10,-1,0,8,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch192 = {6,10,-1,0,8,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x78,0x84,0x84,0x80,0x40,0x20,0x20,0x0,0x20,
-};
-
-static const BitmapCharRec ch191 = {6,9,-1,0,8,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x6,0x1a,0x12,0xa,0x66,0x92,0x10,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch190 = {7,10,0,0,8,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x1e,0x10,0xc,0x2,0xf2,0x4c,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch189 = {7,10,0,0,8,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x6,0x1a,0x12,0xa,0xe6,0x42,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch188 = {7,10,0,0,8,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0x90,0x48,0x24,0x12,0x24,0x48,0x90,
-};
-
-static const BitmapCharRec ch187 = {7,7,0,-1,8,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xf0,0x0,0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch186 = {4,6,-1,-3,8,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {3,6,-1,-4,8,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xc0,0x40,
-};
-
-static const BitmapCharRec ch184 = {2,2,-3,2,8,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,1,-3,-4,8,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,0x7c,
-};
-
-static const BitmapCharRec ch182 = {6,9,-1,0,8,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0xb4,0xcc,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch181 = {6,7,-1,1,8,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x40,
-};
-
-static const BitmapCharRec ch180 = {2,2,-3,-8,8,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0x60,0x90,0x10,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch179 = {4,6,-1,-4,8,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xf0,0x80,0x60,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch178 = {4,6,-1,-4,8,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xf8,0x0,0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch177 = {5,7,-1,-1,8,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,-2,-5,8,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch175 = {6,1,-1,-8,8,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x38,0x44,0xaa,0xb2,0xaa,0xaa,0x92,0x44,0x38,
-};
-
-static const BitmapCharRec ch174 = {7,9,0,-1,8,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch173 = {6,1,-1,-4,8,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x4,0x4,0x4,0xfc,
-};
-
-static const BitmapCharRec ch172 = {6,4,-1,-1,8,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x12,0x24,0x48,0x90,0x48,0x24,0x12,
-};
-
-static const BitmapCharRec ch171 = {7,7,0,-1,8,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xf8,0x0,0x78,0x88,0x78,0x8,0x70,
-};
-
-static const BitmapCharRec ch170 = {5,7,-1,-2,8,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x38,0x44,0x92,0xaa,0xa2,0xaa,0x92,0x44,0x38,
-};
-
-static const BitmapCharRec ch169 = {7,9,0,-1,8,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xd8,
-};
-
-static const BitmapCharRec ch168 = {5,1,-1,-8,8,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x60,0x90,0x10,0x60,0x90,0x90,0x60,0x80,0x90,0x60,
-};
-
-static const BitmapCharRec ch167 = {4,10,-2,0,8,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x80,0x0,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,9,-3,0,8,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x10,0x10,0x7c,0x10,0x7c,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch165 = {7,9,0,0,8,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x84,0x78,0x48,0x48,0x78,0x84,
-};
-
-static const BitmapCharRec ch164 = {6,6,-1,-1,8,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xdc,0x62,0x20,0x20,0x20,0x70,0x20,0x22,0x1c,
-};
-
-static const BitmapCharRec ch163 = {7,9,0,0,8,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x20,0x70,0xa8,0xa0,0xa0,0xa8,0x70,0x20,
-};
-
-static const BitmapCharRec ch162 = {5,8,-1,-1,8,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,9,-3,0,8,ch161data};
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x90,0xa8,0x48,
-};
-
-static const BitmapCharRec ch126 = {5,3,-1,-6,8,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xe0,0x10,0x10,0x20,0x18,0x20,0x10,0x10,0xe0,
-};
-
-static const BitmapCharRec ch125 = {5,9,-1,0,8,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,9,-3,0,8,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x38,0x40,0x40,0x20,0xc0,0x20,0x40,0x40,0x38,
-};
-
-static const BitmapCharRec ch123 = {5,9,-2,0,8,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xfc,0x40,0x20,0x10,0x8,0xfc,
-};
-
-static const BitmapCharRec ch122 = {6,6,-1,0,8,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch121 = {6,8,-1,2,8,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0x84,0x48,0x30,0x30,0x48,0x84,
-};
-
-static const BitmapCharRec ch120 = {6,6,-1,0,8,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x44,0xaa,0x92,0x92,0x82,0x82,
-};
-
-static const BitmapCharRec ch119 = {7,6,0,0,8,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x20,0x50,0x50,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch118 = {5,6,-1,0,8,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch117 = {6,6,-1,0,8,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x38,0x44,0x40,0x40,0x40,0xf8,0x40,0x40,
-};
-
-static const BitmapCharRec ch116 = {6,8,-1,0,8,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x78,0x84,0x18,0x60,0x84,0x78,
-};
-
-static const BitmapCharRec ch115 = {6,6,-1,0,8,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0x40,0x40,0x40,0x40,0x44,0xb8,
-};
-
-static const BitmapCharRec ch114 = {6,6,-1,0,8,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x4,0x4,0x4,0x74,0x8c,0x84,0x8c,0x74,
-};
-
-static const BitmapCharRec ch113 = {6,8,-1,2,8,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0x80,0x80,0x80,0xb8,0xc4,0x84,0xc4,0xb8,
-};
-
-static const BitmapCharRec ch112 = {6,8,-1,2,8,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch111 = {6,6,-1,0,8,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0x84,0x84,0x84,0x84,0xc4,0xb8,
-};
-
-static const BitmapCharRec ch110 = {6,6,-1,0,8,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0x82,0x92,0x92,0x92,0x92,0xec,
-};
-
-static const BitmapCharRec ch109 = {7,6,0,0,8,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x60,
-};
-
-static const BitmapCharRec ch108 = {5,9,-1,0,8,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x84,0x88,0x90,0xe0,0x90,0x88,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {6,9,-1,0,8,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x70,0x88,0x88,0x8,0x8,0x8,0x8,0x18,0x0,0x8,
-};
-
-static const BitmapCharRec ch106 = {5,10,-1,2,8,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x20,
-};
-
-static const BitmapCharRec ch105 = {5,8,-1,0,8,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0x84,0x84,0x84,0x84,0xc4,0xb8,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {6,9,-1,0,8,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x78,0x84,0x78,0x80,0x70,0x88,0x88,0x74,
-};
-
-static const BitmapCharRec ch103 = {6,8,-1,2,8,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x40,0x40,0x40,0x40,0xf8,0x40,0x40,0x44,0x38,
-};
-
-static const BitmapCharRec ch102 = {6,9,-1,0,8,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,
-};
-
-static const BitmapCharRec ch101 = {6,6,-1,0,8,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x74,0x8c,0x84,0x84,0x8c,0x74,0x4,0x4,0x4,
-};
-
-static const BitmapCharRec ch100 = {6,9,-1,0,8,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x78,0x84,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch99 = {6,6,-1,0,8,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xb8,0xc4,0x84,0x84,0xc4,0xb8,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {6,9,-1,0,8,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,
-};
-
-static const BitmapCharRec ch97 = {6,6,-1,0,8,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0x10,0x60,0xe0,
-};
-
-static const BitmapCharRec ch96 = {4,3,-2,-6,8,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xfe,
-};
-
-static const BitmapCharRec ch95 = {7,1,0,1,8,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x88,0x50,0x20,
-};
-
-static const BitmapCharRec ch94 = {5,3,-1,-6,8,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xf0,
-};
-
-static const BitmapCharRec ch93 = {4,9,-1,0,8,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x2,0x2,0x4,0x8,0x10,0x20,0x40,0x80,0x80,
-};
-
-static const BitmapCharRec ch92 = {7,9,0,0,8,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xf0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xf0,
-};
-
-static const BitmapCharRec ch91 = {4,9,-2,0,8,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xfc,0x80,0x80,0x40,0x20,0x10,0x8,0x4,0xfc,
-};
-
-static const BitmapCharRec ch90 = {6,9,-1,0,8,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x10,0x10,0x10,0x10,0x10,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch89 = {7,9,0,0,8,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0x82,0x82,0x44,0x28,0x10,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch88 = {7,9,0,0,8,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x44,0xaa,0x92,0x92,0x92,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch87 = {7,9,0,0,8,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x28,0x28,0x28,0x44,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch86 = {7,9,0,0,8,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch85 = {6,9,-1,0,8,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xfe,
-};
-
-static const BitmapCharRec ch84 = {7,9,0,0,8,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x78,0x84,0x4,0x4,0x78,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch83 = {6,9,-1,0,8,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0x84,0x88,0x90,0xa0,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch82 = {6,9,-1,0,8,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x4,0x78,0x94,0xa4,0x84,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch81 = {6,10,-1,1,8,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0x80,0x80,0x80,0x80,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch80 = {6,9,-1,0,8,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch79 = {6,9,-1,0,8,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0x84,0x84,0x84,0x8c,0x94,0xa4,0xc4,0x84,0x84,
-};
-
-static const BitmapCharRec ch78 = {6,9,-1,0,8,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0x82,0x82,0x82,0x92,0x92,0xaa,0xc6,0x82,0x82,
-};
-
-static const BitmapCharRec ch77 = {7,9,0,0,8,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xfc,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch76 = {6,9,-1,0,8,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0x84,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x84,
-};
-
-static const BitmapCharRec ch75 = {6,9,-1,0,8,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x70,0x88,0x8,0x8,0x8,0x8,0x8,0x8,0x3c,
-};
-
-static const BitmapCharRec ch74 = {6,9,-1,0,8,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,
-};
-
-static const BitmapCharRec ch73 = {5,9,-1,0,8,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0x84,0x84,0x84,0x84,0xfc,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch72 = {6,9,-1,0,8,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x74,0x8c,0x84,0x9c,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch71 = {6,9,-1,0,8,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0x80,0x80,0x80,0x80,0xf0,0x80,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch70 = {6,9,-1,0,8,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xfc,0x80,0x80,0x80,0xf0,0x80,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch69 = {6,9,-1,0,8,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xfc,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch68 = {7,9,0,0,8,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x78,0x84,0x80,0x80,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch67 = {6,9,-1,0,8,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xfc,0x42,0x42,0x42,0x7c,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch66 = {7,9,0,0,8,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0x84,0x84,0x84,0xfc,0x84,0x84,0x84,0x48,0x30,
-};
-
-static const BitmapCharRec ch65 = {6,9,-1,0,8,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x78,0x80,0x94,0xac,0xa4,0x9c,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch64 = {6,9,-1,0,8,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x10,0x0,0x10,0x10,0x8,0x4,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch63 = {6,9,-1,0,8,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0x80,0x40,0x20,0x10,0x8,0x10,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch62 = {5,9,-1,0,8,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xfc,0x0,0x0,0xfc,
-};
-
-static const BitmapCharRec ch61 = {6,4,-1,-2,8,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x8,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x8,
-};
-
-static const BitmapCharRec ch60 = {5,9,-2,0,8,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x60,0x70,0x0,0x0,0x20,0x70,0x20,
-};
-
-static const BitmapCharRec ch59 = {4,8,-1,1,8,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0x40,0xe0,0x40,0x0,0x0,0x40,0xe0,0x40,
-};
-
-static const BitmapCharRec ch58 = {3,8,-2,1,8,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x70,0x8,0x4,0x4,0x74,0x8c,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch57 = {6,9,-1,0,8,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x78,0x84,0x84,0x84,0x78,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch56 = {6,9,-1,0,8,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x20,0x20,0x10,0x10,0x8,0x4,0xfc,
-};
-
-static const BitmapCharRec ch55 = {6,9,-1,0,8,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x78,0x84,0x84,0xc4,0xb8,0x80,0x80,0x40,0x38,
-};
-
-static const BitmapCharRec ch54 = {6,9,-1,0,8,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x78,0x84,0x4,0x4,0xc4,0xb8,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch53 = {6,9,-1,0,8,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x8,0x8,0xfc,0x88,0x88,0x48,0x28,0x18,0x8,
-};
-
-static const BitmapCharRec ch52 = {6,9,-1,0,8,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x78,0x84,0x4,0x4,0x38,0x10,0x8,0x4,0xfc,
-};
-
-static const BitmapCharRec ch51 = {6,9,-1,0,8,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xfc,0x80,0x40,0x30,0x8,0x4,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch50 = {6,9,-1,0,8,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xa0,0x60,0x20,
-};
-
-static const BitmapCharRec ch49 = {5,9,-1,0,8,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x30,0x48,0x84,0x84,0x84,0x84,0x84,0x48,0x30,
-};
-
-static const BitmapCharRec ch48 = {6,9,-1,0,8,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x80,0x40,0x20,0x10,0x8,0x4,0x2,0x2,
-};
-
-static const BitmapCharRec ch47 = {7,9,0,0,8,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0x40,0xe0,0x40,
-};
-
-static const BitmapCharRec ch46 = {3,3,-2,1,8,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch45 = {6,1,-1,-4,8,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x60,0x70,
-};
-
-static const BitmapCharRec ch44 = {4,3,-1,1,8,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch43 = {5,5,-1,-2,8,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0x48,0x30,0xfc,0x30,0x48,
-};
-
-static const BitmapCharRec ch42 = {6,5,-1,-2,8,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,9,-2,0,8,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,9,-3,0,8,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x60,0x70,
-};
-
-static const BitmapCharRec ch39 = {4,3,-1,-6,8,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x74,0x88,0x94,0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch38 = {6,7,-1,0,8,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x88,0x54,0x48,0x20,0x10,0x10,0x48,0xa4,0x44,
-};
-
-static const BitmapCharRec ch37 = {6,9,-1,0,8,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x20,0xf0,0x28,0x70,0xa0,0x78,0x20,
-};
-
-static const BitmapCharRec ch36 = {5,7,-1,-1,8,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x48,0x48,0xfc,0x48,0xfc,0x48,0x48,
-};
-
-static const BitmapCharRec ch35 = {6,7,-1,-1,8,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch34 = {4,3,-2,-6,8,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,9,-3,0,8,ch33data};
-
-/* char: 0x1f */
-
-static const GLubyte ch31data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch31 = {1,1,-3,-3,8,ch31data};
-
-/* char: 0x1e */
-
-static const GLubyte ch30data[] = {
-0xdc,0x62,0x20,0x20,0x20,0x70,0x20,0x22,0x1c,
-};
-
-static const BitmapCharRec ch30 = {7,9,0,0,8,ch30data};
-
-/* char: 0x1d */
-
-static const GLubyte ch29data[] = {
-0x80,0x40,0xfe,0x10,0xfe,0x4,0x2,
-};
-
-static const BitmapCharRec ch29 = {7,7,0,0,8,ch29data};
-
-/* char: 0x1c */
-
-static const GLubyte ch28data[] = {
-0x88,0x48,0x48,0x48,0x48,0xfc,
-};
-
-static const BitmapCharRec ch28 = {6,6,-1,0,8,ch28data};
-
-/* char: 0x1b */
-
-static const GLubyte ch27data[] = {
-0xfe,0x80,0x20,0x8,0x2,0x8,0x20,0x80,
-};
-
-static const BitmapCharRec ch27 = {7,8,0,0,8,ch27data};
-
-/* char: 0x1a */
-
-static const GLubyte ch26data[] = {
-0xfe,0x2,0x8,0x20,0x80,0x20,0x8,0x2,
-};
-
-static const BitmapCharRec ch26 = {7,8,0,0,8,ch26data};
-
-/* char: 0x19 */
-
-static const GLubyte ch25data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch25 = {1,13,-3,2,8,ch25data};
-
-/* char: 0x18 */
-
-static const GLubyte ch24data[] = {
-0x10,0x10,0x10,0x10,0x10,0xff,
-};
-
-static const BitmapCharRec ch24 = {8,6,0,2,8,ch24data};
-
-/* char: 0x17 */
-
-static const GLubyte ch23data[] = {
-0xff,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch23 = {8,8,0,-3,8,ch23data};
-
-/* char: 0x16 */
-
-static const GLubyte ch22data[] = {
-0x10,0x10,0x10,0x10,0x10,0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch22 = {4,13,0,2,8,ch22data};
-
-/* char: 0x15 */
-
-static const GLubyte ch21data[] = {
-0x80,0x80,0x80,0x80,0x80,0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch21 = {5,13,-3,2,8,ch21data};
-
-/* char: 0x14 */
-
-static const GLubyte ch20data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch20 = {8,1,0,1,8,ch20data};
-
-/* char: 0x13 */
-
-static const GLubyte ch19data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch19 = {8,1,0,-1,8,ch19data};
-
-/* char: 0x12 */
-
-static const GLubyte ch18data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch18 = {8,1,0,-3,8,ch18data};
-
-/* char: 0x11 */
-
-static const GLubyte ch17data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch17 = {8,1,0,-5,8,ch17data};
-
-/* char: 0x10 */
-
-static const GLubyte ch16data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch16 = {8,1,0,-7,8,ch16data};
-
-/* char: 0xf */
-
-static const GLubyte ch15data[] = {
-0x10,0x10,0x10,0x10,0x10,0xff,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch15 = {8,13,0,2,8,ch15data};
-
-/* char: 0xe */
-
-static const GLubyte ch14data[] = {
-0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch14 = {5,8,-3,-3,8,ch14data};
-
-/* char: 0xd */
-
-static const GLubyte ch13data[] = {
-0x80,0x80,0x80,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch13 = {5,6,-3,2,8,ch13data};
-
-/* char: 0xc */
-
-static const GLubyte ch12data[] = {
-0x10,0x10,0x10,0x10,0x10,0xf0,
-};
-
-static const BitmapCharRec ch12 = {4,6,0,2,8,ch12data};
-
-/* char: 0xb */
-
-static const GLubyte ch11data[] = {
-0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch11 = {4,8,0,-3,8,ch11data};
-
-/* char: 0xa */
-
-static const GLubyte ch10data[] = {
-0x8,0x8,0x8,0x8,0x3e,0x20,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch10 = {7,9,0,2,8,ch10data};
-
-/* char: 0x9 */
-
-static const GLubyte ch9data[] = {
-0x3e,0x20,0x20,0x20,0x88,0x98,0xa8,0xc8,0x88,
-};
-
-static const BitmapCharRec ch9 = {7,9,0,2,8,ch9data};
-
-/* char: 0x8 */
-
-static const GLubyte ch8data[] = {
-0xfe,0x10,0x10,0xfe,0x10,0x10,
-};
-
-static const BitmapCharRec ch8 = {7,6,0,0,8,ch8data};
-
-/* char: 0x7 */
-
-static const GLubyte ch7data[] = {
-0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch7 = {5,4,-1,-5,8,ch7data};
-
-/* char: 0x6 */
-
-static const GLubyte ch6data[] = {
-0x20,0x20,0x3c,0x20,0x3e,0xf8,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch6 = {7,9,0,2,8,ch6data};
-
-/* char: 0x5 */
-
-static const GLubyte ch5data[] = {
-0x22,0x22,0x3c,0x22,0x3c,0x78,0x80,0x80,0x78,
-};
-
-static const BitmapCharRec ch5 = {7,9,0,2,8,ch5data};
-
-/* char: 0x4 */
-
-static const GLubyte ch4data[] = {
-0x10,0x10,0x1c,0x10,0x9e,0x80,0xe0,0x80,0xf0,
-};
-
-static const BitmapCharRec ch4 = {7,9,0,2,8,ch4data};
-
-/* char: 0x3 */
-
-static const GLubyte ch3data[] = {
-0x8,0x8,0x8,0x3e,0x88,0x88,0xf8,0x88,0x88,
-};
-
-static const BitmapCharRec ch3 = {7,9,0,2,8,ch3data};
-
-/* char: 0x2 */
-
-static const GLubyte ch2data[] = {
-0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,
-};
-
-static const BitmapCharRec ch2 = {8,12,0,2,8,ch2data};
-
-/* char: 0x1 */
-
-static const GLubyte ch1data[] = {
-0x10,0x38,0x7c,0xfe,0x7c,0x38,0x10,
-};
-
-static const BitmapCharRec ch1 = {7,7,0,-1,8,ch1data};
-
-static const BitmapCharRec * const chars[] = {
-&ch0,
-&ch1,
-&ch2,
-&ch3,
-&ch4,
-&ch5,
-&ch6,
-&ch7,
-&ch8,
-&ch9,
-&ch10,
-&ch11,
-&ch12,
-&ch13,
-&ch14,
-&ch15,
-&ch16,
-&ch17,
-&ch18,
-&ch19,
-&ch20,
-&ch21,
-&ch22,
-&ch23,
-&ch24,
-&ch25,
-&ch26,
-&ch27,
-&ch28,
-&ch29,
-&ch30,
-&ch31,
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-&ch127,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-const BitmapFontRec glutBitmap8By13 = {
-"-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1",
-256,
-0,
-chars
-};
-
diff --git a/src/glut/beos/glut_9x15.c b/src/glut/beos/glut_9x15.c
deleted file mode 100644 (file)
index 2d5c004..0000000
+++ /dev/null
@@ -1,2075 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmap9By15 XXX
-#include "glutbitmap.h"
-#undef glutBitmap9By15
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch0data[] = { 0x0 };
-static const BitmapCharRec ch0 = {1,1,0,0,9,ch0data};
-#else
-static const BitmapCharRec ch0 = {0,0,0,0,9,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,9,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,9,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch127data[] = { 0x0 };
-static const BitmapCharRec ch127 = {1,1,0,0,9,ch127data};
-#else
-static const BitmapCharRec ch127 = {0,0,0,0,9,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,9,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,9,0};
-#endif
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch255 = {6,14,-1,3,9,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0x80,0x80,0x80,0xbc,0xc2,0x82,0x82,0x82,0xc2,0xbc,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {7,12,-1,3,9,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch253 = {6,14,-1,3,9,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch252 = {7,11,-1,0,9,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch251 = {7,11,-1,0,9,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch250 = {7,11,-1,0,9,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch249 = {7,11,-1,0,9,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0x80,0x7c,0xa2,0xa2,0x92,0x8a,0x8a,0x7c,0x2,
-};
-
-static const BitmapCharRec ch248 = {7,9,-1,1,9,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x10,0x38,0x10,0x0,0xfe,0x0,0x10,0x38,0x10,
-};
-
-static const BitmapCharRec ch247 = {7,9,-1,0,9,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch246 = {7,11,-1,0,9,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch245 = {7,11,-1,0,9,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch244 = {7,11,-1,0,9,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch243 = {7,11,-1,0,9,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch242 = {7,11,-1,0,9,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0x82,0x82,0x82,0x82,0x82,0xc2,0xbc,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch241 = {7,11,-1,0,9,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x8,0x50,0x30,0x48,
-};
-
-static const BitmapCharRec ch240 = {7,11,-1,0,9,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x50,0x50,
-};
-
-static const BitmapCharRec ch239 = {5,11,-2,0,9,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x90,0x60,
-};
-
-static const BitmapCharRec ch238 = {5,11,-2,0,9,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x60,0x10,
-};
-
-static const BitmapCharRec ch237 = {5,11,-2,0,9,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x30,0x40,
-};
-
-static const BitmapCharRec ch236 = {5,11,-2,0,9,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch235 = {7,11,-1,0,9,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,0x0,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch234 = {7,11,-1,0,9,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch233 = {7,11,-1,0,9,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,0x0,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch232 = {7,11,-1,0,9,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x30,0x48,0x18,0x7c,0x82,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch231 = {7,10,-1,3,9,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x6e,0x92,0x90,0x7c,0x12,0x92,0x6c,
-};
-
-static const BitmapCharRec ch230 = {7,7,-1,0,9,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x18,0x24,0x18,
-};
-
-static const BitmapCharRec ch229 = {7,11,-1,0,9,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch228 = {7,11,-1,0,9,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch227 = {7,11,-1,0,9,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch226 = {7,11,-1,0,9,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch225 = {7,11,-1,0,9,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch224 = {7,11,-1,0,9,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0x80,0xbc,0xc2,0x82,0x82,0xfc,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch223 = {7,9,-1,1,9,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0x80,0x80,0x80,0xfc,0x82,0x82,0x82,0xfc,0x80,0x80,
-};
-
-static const BitmapCharRec ch222 = {7,10,-1,0,9,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x10,0x10,0x10,0x10,0x28,0x44,0x82,0x82,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch221 = {7,11,-1,0,9,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch220 = {7,11,-1,0,9,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch219 = {7,11,-1,0,9,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch218 = {7,11,-1,0,9,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch217 = {7,11,-1,0,9,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x7c,0xc2,0xa2,0xa2,0x92,0x92,0x8a,0x8a,0x86,0x7c,0x2,
-};
-
-static const BitmapCharRec ch216 = {7,12,-1,1,9,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x82,0x44,0x28,0x10,0x28,0x44,0x82,
-};
-
-static const BitmapCharRec ch215 = {7,7,-1,-1,9,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch214 = {7,11,-1,0,9,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch213 = {7,11,-1,0,9,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch212 = {7,11,-1,0,9,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch211 = {7,11,-1,0,9,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch210 = {7,11,-1,0,9,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0x82,0x86,0x8a,0x92,0x92,0xa2,0xc2,0x82,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch209 = {7,11,-1,0,9,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0xfc,0x42,0x42,0x42,0x42,0xf2,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch208 = {7,10,-1,0,9,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x50,0x50,
-};
-
-static const BitmapCharRec ch207 = {5,11,-2,0,9,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x88,0x70,
-};
-
-static const BitmapCharRec ch206 = {5,11,-2,0,9,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x60,0x10,
-};
-
-static const BitmapCharRec ch205 = {5,11,-2,0,9,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x30,0x40,
-};
-
-static const BitmapCharRec ch204 = {5,11,-2,0,9,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xfe,0x40,0x40,0x40,0x78,0x40,0x40,0xfe,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch203 = {7,11,-1,0,9,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xfe,0x40,0x40,0x40,0x78,0x40,0x40,0xfe,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch202 = {7,11,-1,0,9,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xfe,0x40,0x40,0x40,0x78,0x40,0x40,0xfe,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch201 = {7,11,-1,0,9,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xfe,0x40,0x40,0x40,0x78,0x40,0x40,0xfe,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch200 = {7,11,-1,0,9,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x30,0x48,0x18,0x7c,0x82,0x80,0x80,0x80,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch199 = {7,13,-1,3,9,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0x9e,0x90,0x90,0x90,0xfc,0x90,0x90,0x90,0x90,0x6e,
-};
-
-static const BitmapCharRec ch198 = {7,10,-1,0,9,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x10,0x28,0x10,
-};
-
-static const BitmapCharRec ch197 = {7,11,-1,0,9,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch196 = {7,11,-1,0,9,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch195 = {7,11,-1,0,9,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch194 = {7,11,-1,0,9,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch193 = {7,11,-1,0,9,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch192 = {7,11,-1,0,9,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x7c,0x82,0x82,0x80,0x40,0x20,0x10,0x10,0x0,0x10,
-};
-
-static const BitmapCharRec ch191 = {7,10,-1,0,9,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x6,0x1a,0x12,0xa,0x66,0x92,0x10,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch190 = {7,10,-1,0,9,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x1e,0x10,0xc,0x2,0xf2,0x4c,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch189 = {7,10,-1,0,9,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x6,0x1a,0x12,0xa,0xe6,0x42,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch188 = {7,10,-1,0,9,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0x90,0x48,0x24,0x12,0x12,0x24,0x48,0x90,
-};
-
-static const BitmapCharRec ch187 = {7,8,-1,-1,9,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xf8,0x0,0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch186 = {5,6,-1,-5,9,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {3,6,-1,-4,9,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0x60,0x90,0x30,
-};
-
-static const BitmapCharRec ch184 = {4,3,-2,3,9,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,2,-4,-4,9,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0xa,0xa,0xa,0xa,0xa,0x7a,0x8a,0x8a,0x8a,0x7e,
-};
-
-static const BitmapCharRec ch182 = {7,10,-1,0,9,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0x80,0xba,0xc6,0x82,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch181 = {7,9,-1,2,9,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0xc0,0x20,
-};
-
-static const BitmapCharRec ch180 = {3,2,-3,-9,9,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0x60,0x90,0x10,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch179 = {4,6,-1,-4,9,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xf0,0x80,0x60,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch178 = {4,6,-1,-4,9,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xfe,0x0,0x10,0x10,0x10,0xfe,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch177 = {7,9,-1,-1,9,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,-3,-6,9,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch175 = {6,1,-1,-9,9,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x3c,0x42,0xa5,0xa9,0xbd,0xa5,0xb9,0x42,0x3c,
-};
-
-static const BitmapCharRec ch174 = {8,9,0,-1,9,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch173 = {6,1,-1,-4,9,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x4,0x4,0x4,0xfc,
-};
-
-static const BitmapCharRec ch172 = {6,4,-1,-2,9,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x12,0x24,0x48,0x90,0x90,0x48,0x24,0x12,
-};
-
-static const BitmapCharRec ch171 = {7,8,-1,-1,9,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xf8,0x0,0x78,0x90,0x70,0x90,0x60,
-};
-
-static const BitmapCharRec ch170 = {5,7,-3,-3,9,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x3c,0x42,0x99,0xa5,0xa1,0xa5,0x99,0x42,0x3c,
-};
-
-static const BitmapCharRec ch169 = {8,9,0,-1,9,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xa0,0xa0,
-};
-
-static const BitmapCharRec ch168 = {3,2,-3,-9,9,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x70,0x88,0x8,0x70,0x88,0x88,0x88,0x70,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch167 = {5,11,-2,1,9,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,11,-4,1,9,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x10,0x10,0x10,0x7c,0x10,0x7c,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch165 = {7,10,-1,0,9,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x82,0x7c,0x44,0x44,0x7c,0x82,
-};
-
-static const BitmapCharRec ch164 = {7,6,-1,-3,9,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0x5c,0xa2,0x60,0x20,0x20,0xf8,0x20,0x20,0x22,0x1c,
-};
-
-static const BitmapCharRec ch163 = {7,10,-1,0,9,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x40,0x78,0xa4,0xa0,0x90,0x94,0x78,0x8,
-};
-
-static const BitmapCharRec ch162 = {6,8,-1,0,9,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x80,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,11,-4,0,9,ch161data};
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x8c,0x92,0x62,
-};
-
-static const BitmapCharRec ch126 = {7,3,-1,-7,9,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xe0,0x10,0x10,0x10,0x20,0x18,0x18,0x20,0x10,0x10,0x10,0xe0,
-};
-
-static const BitmapCharRec ch125 = {5,12,-1,1,9,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,12,-4,1,9,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x38,0x40,0x40,0x40,0x20,0xc0,0xc0,0x20,0x40,0x40,0x40,0x38,
-};
-
-static const BitmapCharRec ch123 = {5,12,-3,1,9,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xfe,0x40,0x20,0x10,0x8,0x4,0xfe,
-};
-
-static const BitmapCharRec ch122 = {7,7,-1,0,9,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch121 = {6,10,-1,3,9,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0x82,0x44,0x28,0x10,0x28,0x44,0x82,
-};
-
-static const BitmapCharRec ch120 = {7,7,-1,0,9,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x44,0xaa,0x92,0x92,0x92,0x82,0x82,
-};
-
-static const BitmapCharRec ch119 = {7,7,-1,0,9,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x10,0x28,0x28,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch118 = {7,7,-1,0,9,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch117 = {7,7,-1,0,9,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x1c,0x22,0x20,0x20,0x20,0x20,0xfc,0x20,0x20,
-};
-
-static const BitmapCharRec ch116 = {7,9,-1,0,9,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x7c,0x82,0x2,0x7c,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch115 = {7,7,-1,0,9,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0x40,0x40,0x40,0x40,0x42,0x62,0x9c,
-};
-
-static const BitmapCharRec ch114 = {7,7,-1,0,9,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x2,0x2,0x2,0x7a,0x86,0x82,0x82,0x82,0x86,0x7a,
-};
-
-static const BitmapCharRec ch113 = {7,10,-1,3,9,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0x80,0x80,0x80,0xbc,0xc2,0x82,0x82,0x82,0xc2,0xbc,
-};
-
-static const BitmapCharRec ch112 = {7,10,-1,3,9,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch111 = {7,7,-1,0,9,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0x82,0x82,0x82,0x82,0x82,0xc2,0xbc,
-};
-
-static const BitmapCharRec ch110 = {7,7,-1,0,9,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0x82,0x92,0x92,0x92,0x92,0x92,0xec,
-};
-
-static const BitmapCharRec ch109 = {7,7,-1,0,9,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xe0,
-};
-
-static const BitmapCharRec ch108 = {5,10,-2,0,9,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x82,0x8c,0xb0,0xc0,0xb0,0x8c,0x82,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {7,10,-1,0,9,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x78,0x84,0x84,0x84,0x4,0x4,0x4,0x4,0x4,0x1c,0x0,0x0,0xc,
-};
-
-static const BitmapCharRec ch106 = {6,13,-1,3,9,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x60,
-};
-
-static const BitmapCharRec ch105 = {5,10,-2,0,9,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0x82,0x82,0x82,0x82,0x82,0xc2,0xbc,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {7,10,-1,0,9,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x7c,0x82,0x82,0x7c,0x80,0x78,0x84,0x84,0x84,0x7a,
-};
-
-static const BitmapCharRec ch103 = {7,10,-1,3,9,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x20,0x20,0x20,0x20,0xf8,0x20,0x20,0x22,0x22,0x1c,
-};
-
-static const BitmapCharRec ch102 = {7,10,-1,0,9,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch101 = {7,7,-1,0,9,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x7a,0x86,0x82,0x82,0x82,0x86,0x7a,0x2,0x2,0x2,
-};
-
-static const BitmapCharRec ch100 = {7,10,-1,0,9,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x7c,0x82,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch99 = {7,7,-1,0,9,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xbc,0xc2,0x82,0x82,0x82,0xc2,0xbc,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {7,10,-1,0,9,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,
-};
-
-static const BitmapCharRec ch97 = {7,7,-1,0,9,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0x10,0x20,0x40,0xc0,
-};
-
-static const BitmapCharRec ch96 = {4,4,-3,-6,9,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch95 = {8,1,0,1,9,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x82,0x44,0x28,0x10,
-};
-
-static const BitmapCharRec ch94 = {7,4,-1,-6,9,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xf0,
-};
-
-static const BitmapCharRec ch93 = {4,12,-2,1,9,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x2,0x4,0x4,0x8,0x10,0x10,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch92 = {7,10,-1,0,9,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xf0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xf0,
-};
-
-static const BitmapCharRec ch91 = {4,12,-3,1,9,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xfe,0x80,0x80,0x40,0x20,0x10,0x8,0x4,0x2,0xfe,
-};
-
-static const BitmapCharRec ch90 = {7,10,-1,0,9,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x10,0x10,0x10,0x10,0x10,0x10,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch89 = {7,10,-1,0,9,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0x82,0x82,0x44,0x28,0x10,0x10,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch88 = {7,10,-1,0,9,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x44,0xaa,0x92,0x92,0x92,0x92,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch87 = {7,10,-1,0,9,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x28,0x28,0x28,0x44,0x44,0x44,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch86 = {7,10,-1,0,9,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch85 = {7,10,-1,0,9,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xfe,
-};
-
-static const BitmapCharRec ch84 = {7,10,-1,0,9,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x7c,0x82,0x82,0x2,0xc,0x70,0x80,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch83 = {7,10,-1,0,9,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0x82,0x82,0x84,0x88,0x90,0xfc,0x82,0x82,0x82,0xfc,
-};
-
-static const BitmapCharRec ch82 = {7,10,-1,0,9,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x6,0x8,0x7c,0x92,0xa2,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch81 = {7,12,-1,2,9,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0x80,0x80,0x80,0x80,0x80,0xfc,0x82,0x82,0x82,0xfc,
-};
-
-static const BitmapCharRec ch80 = {7,10,-1,0,9,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch79 = {7,10,-1,0,9,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0x82,0x82,0x82,0x86,0x8a,0x92,0xa2,0xc2,0x82,0x82,
-};
-
-static const BitmapCharRec ch78 = {7,10,-1,0,9,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0x82,0x82,0x82,0x92,0x92,0xaa,0xaa,0xc6,0x82,0x82,
-};
-
-static const BitmapCharRec ch77 = {7,10,-1,0,9,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xfe,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch76 = {7,10,-1,0,9,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0x82,0x84,0x88,0x90,0xa0,0xe0,0x90,0x88,0x84,0x82,
-};
-
-static const BitmapCharRec ch75 = {7,10,-1,0,9,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x78,0x84,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x1e,
-};
-
-static const BitmapCharRec ch74 = {7,10,-1,0,9,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,
-};
-
-static const BitmapCharRec ch73 = {5,10,-2,0,9,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0x82,0x82,0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch72 = {7,10,-1,0,9,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x7c,0x82,0x82,0x82,0x8e,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch71 = {7,10,-1,0,9,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0x40,0x40,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0xfe,
-};
-
-static const BitmapCharRec ch70 = {7,10,-1,0,9,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xfe,0x40,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0xfe,
-};
-
-static const BitmapCharRec ch69 = {7,10,-1,0,9,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xfc,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch68 = {7,10,-1,0,9,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x7c,0x82,0x80,0x80,0x80,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch67 = {7,10,-1,0,9,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xfc,0x42,0x42,0x42,0x42,0x7c,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch66 = {7,10,-1,0,9,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x44,0x28,0x10,
-};
-
-static const BitmapCharRec ch65 = {7,10,-1,0,9,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x7c,0x80,0x80,0x9a,0xa6,0xa2,0x9e,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch64 = {7,10,-1,0,9,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x10,0x0,0x10,0x10,0x8,0x4,0x2,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch63 = {7,10,-1,0,9,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0x80,0x40,0x20,0x10,0x8,0x8,0x10,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch62 = {5,10,-2,0,9,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xfe,0x0,0x0,0xfe,
-};
-
-static const BitmapCharRec ch61 = {7,4,-1,-2,9,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x8,0x10,0x20,0x40,0x80,0x80,0x40,0x20,0x10,0x8,
-};
-
-static const BitmapCharRec ch60 = {5,10,-2,0,9,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x40,0x40,0xc0,0xc0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch59 = {2,10,-4,3,9,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0xc0,0xc0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch58 = {2,7,-4,0,9,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x78,0x4,0x2,0x2,0x7a,0x86,0x82,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch57 = {7,10,-1,0,9,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x38,0x44,0x82,0x82,0x44,0x38,0x44,0x82,0x44,0x38,
-};
-
-static const BitmapCharRec ch56 = {7,10,-1,0,9,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x20,0x20,0x10,0x8,0x4,0x2,0x2,0xfe,
-};
-
-static const BitmapCharRec ch55 = {7,10,-1,0,9,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x7c,0x82,0x82,0x82,0xc2,0xbc,0x80,0x80,0x40,0x3c,
-};
-
-static const BitmapCharRec ch54 = {7,10,-1,0,9,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x7c,0x82,0x2,0x2,0x2,0xc2,0xbc,0x80,0x80,0xfe,
-};
-
-static const BitmapCharRec ch53 = {7,10,-1,0,9,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x4,0x4,0x4,0xfe,0x84,0x44,0x24,0x14,0xc,0x4,
-};
-
-static const BitmapCharRec ch52 = {7,10,-1,0,9,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x7c,0x82,0x2,0x2,0x2,0x1c,0x8,0x4,0x2,0xfe,
-};
-
-static const BitmapCharRec ch51 = {7,10,-1,0,9,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xfe,0x80,0x40,0x30,0x8,0x4,0x2,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch50 = {7,10,-1,0,9,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0xfe,0x10,0x10,0x10,0x10,0x10,0x90,0x50,0x30,0x10,
-};
-
-static const BitmapCharRec ch49 = {7,10,-1,0,9,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x38,
-};
-
-static const BitmapCharRec ch48 = {7,10,-1,0,9,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x40,0x40,0x20,0x10,0x10,0x8,0x4,0x4,0x2,
-};
-
-static const BitmapCharRec ch47 = {7,10,-1,0,9,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch46 = {2,2,-4,0,9,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xfe,
-};
-
-static const BitmapCharRec ch45 = {7,1,-1,-4,9,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x40,0x40,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch44 = {2,5,-4,3,9,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x10,0x10,0x10,0xfe,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch43 = {7,7,-1,-1,9,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0x10,0x92,0x54,0x38,0x54,0x92,0x10,
-};
-
-static const BitmapCharRec ch42 = {7,7,-1,-1,9,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,12,-3,1,9,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,12,-3,1,9,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x40,0x20,0x30,
-};
-
-static const BitmapCharRec ch39 = {4,4,-3,-6,9,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x62,0x94,0x88,0x94,0x62,0x60,0x90,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch38 = {7,10,-1,0,9,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x84,0x4a,0x4a,0x24,0x10,0x10,0x48,0xa4,0xa4,0x42,
-};
-
-static const BitmapCharRec ch37 = {7,10,-1,0,9,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x10,0x7c,0x92,0x12,0x12,0x14,0x38,0x50,0x90,0x92,0x7c,0x10,
-};
-
-static const BitmapCharRec ch36 = {7,12,-1,1,9,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x48,0x48,0xfc,0x48,0x48,0xfc,0x48,0x48,
-};
-
-static const BitmapCharRec ch35 = {6,8,-1,-1,9,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch34 = {4,3,-3,-7,9,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x80,0x0,0x0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,11,-4,0,9,ch33data};
-
-/* char: 0x1f */
-
-static const GLubyte ch31data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch31 = {2,2,-4,-2,9,ch31data};
-
-/* char: 0x1e */
-
-static const GLubyte ch30data[] = {
-0x5c,0xa2,0x60,0x20,0x20,0xf8,0x20,0x20,0x22,0x1c,
-};
-
-static const BitmapCharRec ch30 = {7,10,-1,0,9,ch30data};
-
-/* char: 0x1d */
-
-static const GLubyte ch29data[] = {
-0x80,0x40,0xfe,0x10,0xfe,0x4,0x2,
-};
-
-static const BitmapCharRec ch29 = {7,7,-1,0,9,ch29data};
-
-/* char: 0x1c */
-
-static const GLubyte ch28data[] = {
-0x44,0x24,0x24,0x24,0x24,0x24,0xfe,
-};
-
-static const BitmapCharRec ch28 = {7,7,-1,0,9,ch28data};
-
-/* char: 0x1b */
-
-static const GLubyte ch27data[] = {
-0xfe,0x0,0x80,0x40,0x20,0x10,0x8,0x8,0x10,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch27 = {7,12,-1,2,9,ch27data};
-
-/* char: 0x1a */
-
-static const GLubyte ch26data[] = {
-0xfc,0x0,0x4,0x8,0x10,0x20,0x40,0x40,0x20,0x10,0x8,0x4,
-};
-
-static const BitmapCharRec ch26 = {6,12,-2,2,9,ch26data};
-
-/* char: 0x19 */
-
-static const GLubyte ch25data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch25 = {1,15,-4,3,9,ch25data};
-
-/* char: 0x18 */
-
-static const GLubyte ch24data[] = {
-0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0xff,0x80,
-};
-
-static const BitmapCharRec ch24 = {9,7,0,3,9,ch24data};
-
-/* char: 0x17 */
-
-static const GLubyte ch23data[] = {
-0xff,0x80,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,
-0x8,0x0,
-};
-
-static const BitmapCharRec ch23 = {9,9,0,-3,9,ch23data};
-
-/* char: 0x16 */
-
-static const GLubyte ch22data[] = {
-0x8,0x8,0x8,0x8,0x8,0x8,0xf8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,
-};
-
-static const BitmapCharRec ch22 = {5,15,0,3,9,ch22data};
-
-/* char: 0x15 */
-
-static const GLubyte ch21data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch21 = {5,15,-4,3,9,ch21data};
-
-/* char: 0x14 */
-
-static const GLubyte ch20data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch20 = {9,1,0,1,9,ch20data};
-
-/* char: 0x13 */
-
-static const GLubyte ch19data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch19 = {9,1,0,-1,9,ch19data};
-
-/* char: 0x12 */
-
-static const GLubyte ch18data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch18 = {9,1,0,-3,9,ch18data};
-
-/* char: 0x11 */
-
-static const GLubyte ch17data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch17 = {9,1,0,-5,9,ch17data};
-
-/* char: 0x10 */
-
-static const GLubyte ch16data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch16 = {9,1,0,-7,9,ch16data};
-
-/* char: 0xf */
-
-static const GLubyte ch15data[] = {
-0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0xff,0x80,0x8,0x0,
-0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,
-};
-
-static const BitmapCharRec ch15 = {9,15,0,3,9,ch15data};
-
-/* char: 0xe */
-
-static const GLubyte ch14data[] = {
-0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch14 = {5,9,-4,-3,9,ch14data};
-
-/* char: 0xd */
-
-static const GLubyte ch13data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch13 = {5,7,-4,3,9,ch13data};
-
-/* char: 0xc */
-
-static const GLubyte ch12data[] = {
-0x8,0x8,0x8,0x8,0x8,0x8,0xf8,
-};
-
-static const BitmapCharRec ch12 = {5,7,0,3,9,ch12data};
-
-/* char: 0xb */
-
-static const GLubyte ch11data[] = {
-0xf8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,
-};
-
-static const BitmapCharRec ch11 = {5,9,0,-3,9,ch11data};
-
-/* char: 0xa */
-
-static const GLubyte ch10data[] = {
-0x8,0x8,0x8,0x8,0x3e,0x0,0x20,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch10 = {7,10,-1,2,9,ch10data};
-
-/* char: 0x9 */
-
-static const GLubyte ch9data[] = {
-0x3e,0x20,0x20,0x20,0x20,0x88,0x98,0xa8,0xc8,0x88,
-};
-
-static const BitmapCharRec ch9 = {7,10,-1,2,9,ch9data};
-
-/* char: 0x8 */
-
-static const GLubyte ch8data[] = {
-0xfe,0x10,0x10,0xfe,0x10,0x10,
-};
-
-static const BitmapCharRec ch8 = {7,6,-1,0,9,ch8data};
-
-/* char: 0x7 */
-
-static const GLubyte ch7data[] = {
-0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch7 = {5,4,-2,-6,9,ch7data};
-
-/* char: 0x6 */
-
-static const GLubyte ch6data[] = {
-0x20,0x20,0x3c,0x20,0x3e,0x0,0xf8,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch6 = {7,10,-1,2,9,ch6data};
-
-/* char: 0x5 */
-
-static const GLubyte ch5data[] = {
-0x22,0x22,0x3c,0x22,0x3c,0x0,0x78,0x80,0x80,0x78,
-};
-
-static const BitmapCharRec ch5 = {7,10,-1,2,9,ch5data};
-
-/* char: 0x4 */
-
-static const GLubyte ch4data[] = {
-0x10,0x10,0x1c,0x10,0x1e,0x80,0x80,0xe0,0x80,0xf0,
-};
-
-static const BitmapCharRec ch4 = {7,10,-1,2,9,ch4data};
-
-/* char: 0x3 */
-
-static const GLubyte ch3data[] = {
-0x8,0x8,0x8,0x3e,0x0,0x88,0x88,0xf8,0x88,0x88,
-};
-
-static const BitmapCharRec ch3 = {7,10,-1,2,9,ch3data};
-
-/* char: 0x2 */
-
-static const GLubyte ch2data[] = {
-0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,
-};
-
-static const BitmapCharRec ch2 = {8,14,0,3,9,ch2data};
-
-/* char: 0x1 */
-
-static const GLubyte ch1data[] = {
-0x10,0x38,0x7c,0xfe,0x7c,0x38,0x10,
-};
-
-static const BitmapCharRec ch1 = {7,7,-1,0,9,ch1data};
-
-static const BitmapCharRec * const chars[] = {
-&ch0,
-&ch1,
-&ch2,
-&ch3,
-&ch4,
-&ch5,
-&ch6,
-&ch7,
-&ch8,
-&ch9,
-&ch10,
-&ch11,
-&ch12,
-&ch13,
-&ch14,
-&ch15,
-&ch16,
-&ch17,
-&ch18,
-&ch19,
-&ch20,
-&ch21,
-&ch22,
-&ch23,
-&ch24,
-&ch25,
-&ch26,
-&ch27,
-&ch28,
-&ch29,
-&ch30,
-&ch31,
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-&ch127,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-const BitmapFontRec glutBitmap9By15 = {
-"-misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1",
-256,
-0,
-chars
-};
-
diff --git a/src/glut/beos/glut_bitmap.c b/src/glut/beos/glut_bitmap.c
deleted file mode 100644 (file)
index f1afdd7..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-#include "glutbitmap.h"
-
-void APIENTRY 
-glutBitmapCharacter(GLUTbitmapFont font, int c)
-{
-  const BitmapCharRec *ch;
-  BitmapFontPtr fontinfo;
-  GLint swapbytes, lsbfirst, rowlength;
-  GLint skiprows, skippixels, alignment;
-
-#if defined(_WIN32)
-  fontinfo = (BitmapFontPtr) __glutFont(font);
-#else
-  fontinfo = (BitmapFontPtr) font;
-#endif
-
-  if (c < fontinfo->first ||
-    c >= fontinfo->first + fontinfo->num_chars)
-    return;
-  ch = fontinfo->ch[c - fontinfo->first];
-  if (ch) {
-    /* Save current modes. */
-    glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
-    glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
-    glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
-    glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
-    glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
-    glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
-    /* Little endian machines (DEC Alpha for example) could
-       benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
-       instead of GL_FALSE, but this would require changing the
-       generated bitmaps too. */
-    glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
-    glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
-    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
-    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
-    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
-      ch->advance, 0, ch->bitmap);
-    /* Restore saved modes. */
-    glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
-    glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
-    glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
-    glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
-    glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
-    glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
-  }
-}
diff --git a/src/glut/beos/glut_bwidth.c b/src/glut/beos/glut_bwidth.c
deleted file mode 100644 (file)
index bee5e88..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-#include "glutbitmap.h"
-
-/* CENTRY */
-int APIENTRY 
-glutBitmapWidth(GLUTbitmapFont font, int c)
-{
-  BitmapFontPtr fontinfo;
-  const BitmapCharRec *ch;
-
-#ifdef _WIN32
-  fontinfo = (BitmapFontPtr) __glutFont(font);
-#else
-  fontinfo = (BitmapFontPtr) font;
-#endif
-
-  if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars)
-    return 0;
-  ch = fontinfo->ch[c - fontinfo->first];
-  if (ch)
-    return ch->advance;
-  else
-    return 0;
-}
-
-int APIENTRY 
-glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
-{
-  int c, length;
-  BitmapFontPtr fontinfo;
-  const BitmapCharRec *ch;
-
-#ifdef _WIN32
-  fontinfo = (BitmapFontPtr) __glutFont(font);
-#else
-  fontinfo = (BitmapFontPtr) font;
-#endif
-
-  length = 0;
-  for (; *string != '\0'; string++) {
-    c = *string;
-    if (c >= fontinfo->first && c < fontinfo->first + fontinfo->num_chars) {
-      ch = fontinfo->ch[c - fontinfo->first];
-      if (ch)
-        length += ch->advance;
-    }
-  }
-  return length;
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/beos/glut_ext.c b/src/glut/beos/glut_ext.c
deleted file mode 100644 (file)
index 334f31f..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "glutint.h"
-
-/* CENTRY */
-int GLUTAPIENTRY 
-glutExtensionSupported(const char *extension)
-{
-  static const GLubyte *extensions = NULL;
-  const GLubyte *start;
-  GLubyte *where, *terminator;
-
-  /* Extension names should not have spaces. */
-  where = (GLubyte *) strchr(extension, ' ');
-  if (where || *extension == '\0')
-    return 0;
-
-  if (!extensions) {
-    extensions = glGetString(GL_EXTENSIONS);
-  }
-  /* It takes a bit of care to be fool-proof about parsing the
-     OpenGL extensions string.  Don't be fooled by sub-strings,
-     etc. */
-  start = extensions;
-  for (;;) {
-    /* If your application crashes in the strstr routine below,
-       you are probably calling glutExtensionSupported without
-       having a current window.  Calling glGetString without
-       a current OpenGL context has unpredictable results.
-       Please fix your program. */
-    where = (GLubyte *) strstr((const char *) start, extension);
-    if (!where)
-      break;
-    terminator = where + strlen(extension);
-    if (where == start || *(where - 1) == ' ') {
-      if (*terminator == ' ' || *terminator == '\0') {
-        return 1;
-      }
-    }
-    start = terminator;
-  }
-  return 0;
-}
-
-
-struct name_address_pair {
-   const char *name;
-   const GLUTproc address;
-};
-
-static struct name_address_pair glut_functions[] = {
-   { "glutInit", (const GLUTproc) glutInit },
-   { "glutInitDisplayMode", (const GLUTproc) glutInitDisplayMode },
-   { "glutInitDisplayString", (const GLUTproc) glutInitDisplayString },
-   { "glutInitWindowPosition", (const GLUTproc) glutInitWindowPosition },
-   { "glutInitWindowSize", (const GLUTproc) glutInitWindowSize },
-   { "glutMainLoop", (const GLUTproc) glutMainLoop },
-   { "glutCreateWindow", (const GLUTproc) glutCreateWindow },
-   { "glutCreateSubWindow", (const GLUTproc) glutCreateSubWindow },
-   { "glutDestroyWindow", (const GLUTproc) glutDestroyWindow },
-   { "glutPostRedisplay", (const GLUTproc) glutPostRedisplay },
-   { "glutPostWindowRedisplay", (const GLUTproc) glutPostWindowRedisplay },
-   { "glutSwapBuffers", (const GLUTproc) glutSwapBuffers },
-   { "glutGetWindow", (const GLUTproc) glutGetWindow },
-   { "glutSetWindow", (const GLUTproc) glutSetWindow },
-   { "glutSetWindowTitle", (const GLUTproc) glutSetWindowTitle },
-   { "glutSetIconTitle", (const GLUTproc) glutSetIconTitle },
-   { "glutPositionWindow", (const GLUTproc) glutPositionWindow },
-   { "glutReshapeWindow", (const GLUTproc) glutReshapeWindow },
-   { "glutPopWindow", (const GLUTproc) glutPopWindow },
-   { "glutPushWindow", (const GLUTproc) glutPushWindow },
-   { "glutIconifyWindow", (const GLUTproc) glutIconifyWindow },
-   { "glutShowWindow", (const GLUTproc) glutShowWindow },
-   { "glutHideWindow", (const GLUTproc) glutHideWindow },
-   { "glutFullScreen", (const GLUTproc) glutFullScreen },
-   { "glutSetCursor", (const GLUTproc) glutSetCursor },
-   { "glutWarpPointer", (const GLUTproc) glutWarpPointer },
-   { "glutEstablishOverlay", (const GLUTproc) glutEstablishOverlay },
-   { "glutRemoveOverlay", (const GLUTproc) glutRemoveOverlay },
-   { "glutUseLayer", (const GLUTproc) glutUseLayer },
-   { "glutPostOverlayRedisplay", (const GLUTproc) glutPostOverlayRedisplay },
-   { "glutPostWindowOverlayRedisplay", (const GLUTproc) glutPostWindowOverlayRedisplay },
-   { "glutShowOverlay", (const GLUTproc) glutShowOverlay },
-   { "glutHideOverlay", (const GLUTproc) glutHideOverlay },
-   { "glutCreateMenu", (const GLUTproc) glutCreateMenu },
-   { "glutDestroyMenu", (const GLUTproc) glutDestroyMenu },
-   { "glutGetMenu", (const GLUTproc) glutGetMenu },
-   { "glutSetMenu", (const GLUTproc) glutSetMenu },
-   { "glutAddMenuEntry", (const GLUTproc) glutAddMenuEntry },
-   { "glutAddSubMenu", (const GLUTproc) glutAddSubMenu },
-   { "glutChangeToMenuEntry", (const GLUTproc) glutChangeToMenuEntry },
-   { "glutChangeToSubMenu", (const GLUTproc) glutChangeToSubMenu },
-   { "glutRemoveMenuItem", (const GLUTproc) glutRemoveMenuItem },
-   { "glutAttachMenu", (const GLUTproc) glutAttachMenu },
-   { "glutDetachMenu", (const GLUTproc) glutDetachMenu },
-   { "glutDisplayFunc", (const GLUTproc) glutDisplayFunc },
-   { "glutReshapeFunc", (const GLUTproc) glutReshapeFunc },
-   { "glutKeyboardFunc", (const GLUTproc) glutKeyboardFunc },
-   { "glutMouseFunc", (const GLUTproc) glutMouseFunc },
-   { "glutMotionFunc", (const GLUTproc) glutMotionFunc },
-   { "glutPassiveMotionFunc", (const GLUTproc) glutPassiveMotionFunc },
-   { "glutEntryFunc", (const GLUTproc) glutEntryFunc },
-   { "glutVisibilityFunc", (const GLUTproc) glutVisibilityFunc },
-   { "glutIdleFunc", (const GLUTproc) glutIdleFunc },
-   { "glutTimerFunc", (const GLUTproc) glutTimerFunc },
-   { "glutMenuStateFunc", (const GLUTproc) glutMenuStateFunc },
-   { "glutSpecialFunc", (const GLUTproc) glutSpecialFunc },
-   { "glutSpaceballMotionFunc", (const GLUTproc) glutSpaceballMotionFunc },
-   { "glutSpaceballRotateFunc", (const GLUTproc) glutSpaceballRotateFunc },
-   { "glutSpaceballButtonFunc", (const GLUTproc) glutSpaceballButtonFunc },
-   { "glutButtonBoxFunc", (const GLUTproc) glutButtonBoxFunc },
-   { "glutDialsFunc", (const GLUTproc) glutDialsFunc },
-   { "glutTabletMotionFunc", (const GLUTproc) glutTabletMotionFunc },
-   { "glutTabletButtonFunc", (const GLUTproc) glutTabletButtonFunc },
-   { "glutMenuStatusFunc", (const GLUTproc) glutMenuStatusFunc },
-   { "glutOverlayDisplayFunc", (const GLUTproc) glutOverlayDisplayFunc },
-   { "glutWindowStatusFunc", (const GLUTproc) glutWindowStatusFunc },
-//   { "glutKeyboardUpFunc", (const GLUTproc) glutKeyboardUpFunc },
-//   { "glutSpecialUpFunc", (const GLUTproc) glutSpecialUpFunc },
-//   { "glutJoystickFunc", (const GLUTproc) glutJoystickFunc },
-   { "glutSetColor", (const GLUTproc) glutSetColor },
-   { "glutGetColor", (const GLUTproc) glutGetColor },
-   { "glutCopyColormap", (const GLUTproc) glutCopyColormap },
-   { "glutGet", (const GLUTproc) glutGet },
-   { "glutDeviceGet", (const GLUTproc) glutDeviceGet },
-   { "glutExtensionSupported", (const GLUTproc) glutExtensionSupported },
-   { "glutGetModifiers", (const GLUTproc) glutGetModifiers },
-   { "glutLayerGet", (const GLUTproc) glutLayerGet },
-   { "glutGetProcAddress", (const GLUTproc) glutGetProcAddress },
-   { "glutBitmapCharacter", (const GLUTproc) glutBitmapCharacter },
-   { "glutBitmapWidth", (const GLUTproc) glutBitmapWidth },
-   { "glutStrokeCharacter", (const GLUTproc) glutStrokeCharacter },
-   { "glutStrokeWidth", (const GLUTproc) glutStrokeWidth },
-   { "glutBitmapLength", (const GLUTproc) glutBitmapLength },
-   { "glutStrokeLength", (const GLUTproc) glutStrokeLength },
-   { "glutWireSphere", (const GLUTproc) glutWireSphere },
-   { "glutSolidSphere", (const GLUTproc) glutSolidSphere },
-   { "glutWireCone", (const GLUTproc) glutWireCone },
-   { "glutSolidCone", (const GLUTproc) glutSolidCone },
-   { "glutWireCube", (const GLUTproc) glutWireCube },
-   { "glutSolidCube", (const GLUTproc) glutSolidCube },
-   { "glutWireTorus", (const GLUTproc) glutWireTorus },
-   { "glutSolidTorus", (const GLUTproc) glutSolidTorus },
-   { "glutWireDodecahedron", (const GLUTproc) glutWireDodecahedron },
-   { "glutSolidDodecahedron", (const GLUTproc) glutSolidDodecahedron },
-   { "glutWireTeapot", (const GLUTproc) glutWireTeapot },
-   { "glutSolidTeapot", (const GLUTproc) glutSolidTeapot },
-   { "glutWireOctahedron", (const GLUTproc) glutWireOctahedron },
-   { "glutSolidOctahedron", (const GLUTproc) glutSolidOctahedron },
-   { "glutWireTetrahedron", (const GLUTproc) glutWireTetrahedron },
-   { "glutSolidTetrahedron", (const GLUTproc) glutSolidTetrahedron },
-   { "glutWireIcosahedron", (const GLUTproc) glutWireIcosahedron },
-   { "glutSolidIcosahedron", (const GLUTproc) glutSolidIcosahedron },
-   { "glutVideoResizeGet", (const GLUTproc) glutVideoResizeGet },
-   { "glutSetupVideoResizing", (const GLUTproc) glutSetupVideoResizing },
-   { "glutStopVideoResizing", (const GLUTproc) glutStopVideoResizing },
-   { "glutVideoResize", (const GLUTproc) glutVideoResize },
-   { "glutVideoPan", (const GLUTproc) glutVideoPan },
-   { "glutReportErrors", (const GLUTproc) glutReportErrors },
-//   { "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat },
-//   { "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat },
-//   { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc },
-//   { "glutGameModeString", (const GLUTproc) glutGameModeString },
-//   { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode },
-//   { "glutLeaveGameMode", (const GLUTproc) glutLeaveGameMode },
-//   { "glutGameModeGet", (const GLUTproc) glutGameModeGet },
-   { NULL, NULL }
-};   
-
-
-/* XXX This isn't an official GLUT function, yet */
-GLUTproc GLUTAPIENTRY 
-glutGetProcAddress(const char *procName)
-{
-   /* Try GLUT functions first */
-   int i;
-   for (i = 0; glut_functions[i].name; i++) {
-      if (strcmp(glut_functions[i].name, procName) == 0)
-         return glut_functions[i].address;
-   }
-
-   /* Try core GL functions */
-#if defined(_WIN32)
-  return (GLUTProc) wglGetProcAddress((LPCSTR) procName);
-#elif defined(GLX_ARB_get_proc_address)
-  return (GLUTProc) glXGetProcAddressARB((const GLubyte *) procName);
-#else
-  return NULL;
-#endif
-}
-
-
-/* ENDCENTRY */
diff --git a/src/glut/beos/glut_hel10.c b/src/glut/beos/glut_hel10.c
deleted file mode 100644 (file)
index 703cef3..0000000
+++ /dev/null
@@ -1,1778 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapHelvetica10 XXX
-#include "glutbitmap.h"
-#undef glutBitmapHelvetica10
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x80,0x40,0x40,0x60,0xa0,0xa0,0x90,0x90,0x0,0x50,
-};
-
-static const BitmapCharRec ch255 = {4,10,0,2,5,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {5,10,0,2,6,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x80,0x40,0x40,0x60,0xa0,0xa0,0x90,0x90,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch253 = {4,11,0,2,5,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,0x0,0x50,
-};
-
-static const BitmapCharRec ch252 = {4,8,0,0,5,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch251 = {4,9,0,0,5,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch250 = {4,9,0,0,5,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch249 = {4,9,0,0,5,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0x70,0x88,0xc8,0xa8,0x98,0x74,
-};
-
-static const BitmapCharRec ch248 = {6,6,0,0,6,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x20,0x0,0xf8,0x0,0x20,
-};
-
-static const BitmapCharRec ch247 = {5,5,0,-1,6,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x50,
-};
-
-static const BitmapCharRec ch246 = {5,8,0,0,6,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch245 = {5,9,0,0,6,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch244 = {5,9,0,0,6,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch243 = {5,9,0,0,6,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch242 = {5,9,0,0,6,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0x90,0x90,0x90,0x90,0x90,0xe0,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch241 = {4,9,0,0,5,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x70,0x88,0x88,0x88,0x88,0x78,0x90,0x60,0x50,
-};
-
-static const BitmapCharRec ch240 = {5,9,0,0,6,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,
-};
-
-static const BitmapCharRec ch239 = {3,8,0,0,2,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch238 = {3,9,1,0,2,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x40,
-};
-
-static const BitmapCharRec ch237 = {2,9,0,0,2,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch236 = {2,9,1,0,2,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,0x0,0x50,
-};
-
-static const BitmapCharRec ch235 = {4,8,0,0,5,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch234 = {4,9,0,0,5,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch233 = {4,9,0,0,5,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch232 = {4,9,0,0,5,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x60,0x20,0x60,0x90,0x80,0x80,0x90,0x60,
-};
-
-static const BitmapCharRec ch231 = {4,8,0,2,5,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x6c,0x92,0x90,0x7e,0x12,0xec,
-};
-
-static const BitmapCharRec ch230 = {7,6,0,0,8,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x20,0x50,0x20,
-};
-
-static const BitmapCharRec ch229 = {5,9,0,0,5,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0x50,
-};
-
-static const BitmapCharRec ch228 = {5,8,0,0,5,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch227 = {5,9,0,0,5,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch226 = {5,9,0,0,5,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch225 = {5,9,0,0,5,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch224 = {5,9,0,0,5,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xa0,0x90,0x90,0x90,0xa0,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch223 = {4,8,0,0,5,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0x80,0x80,0xf0,0x88,0x88,0xf0,0x80,0x80,
-};
-
-static const BitmapCharRec ch222 = {5,8,-1,0,7,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x10,0x10,0x10,0x28,0x28,0x44,0x44,0x82,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch221 = {7,11,0,0,7,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x48,
-};
-
-static const BitmapCharRec ch220 = {6,10,-1,0,8,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch219 = {6,11,-1,0,8,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch218 = {6,11,-1,0,8,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch217 = {6,11,-1,0,8,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x78,0xc4,0xa4,0xa4,0x94,0x94,0x8c,0x78,0x4,
-};
-
-static const BitmapCharRec ch216 = {6,10,-1,1,8,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x88,0x50,0x20,0x50,0x88,
-};
-
-static const BitmapCharRec ch215 = {5,5,0,-1,6,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x48,
-};
-
-static const BitmapCharRec ch214 = {6,10,-1,0,8,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch213 = {6,11,-1,0,8,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch212 = {6,11,-1,0,8,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch211 = {6,11,-1,0,8,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch210 = {6,11,-1,0,8,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0x8c,0x8c,0x94,0x94,0xa4,0xa4,0xc4,0xc4,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch209 = {6,11,-1,0,8,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0x78,0x44,0x42,0x42,0xf2,0x42,0x44,0x78,
-};
-
-static const BitmapCharRec ch208 = {7,8,0,0,8,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,
-};
-
-static const BitmapCharRec ch207 = {3,10,0,0,3,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch206 = {3,11,0,0,3,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x40,
-};
-
-static const BitmapCharRec ch205 = {2,11,-1,0,3,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch204 = {2,11,0,0,3,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,0x0,0x50,
-};
-
-static const BitmapCharRec ch203 = {5,10,-1,0,7,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xf8,0x80,0x80,0xf8,0x80,0x80,0x80,0xf8,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch202 = {5,11,-1,0,7,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch201 = {5,11,-1,0,7,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch200 = {5,11,-1,0,7,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x30,0x10,0x78,0x84,0x80,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch199 = {6,10,-1,2,8,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0x8f,0x80,0x88,0x0,0x78,0x0,0x48,0x0,0x2f,0x80,0x28,0x0,0x18,0x0,0x1f,0x80,
-};
-
-static const BitmapCharRec ch198 = {9,8,0,0,10,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x10,0x28,0x10,
-};
-
-static const BitmapCharRec ch197 = {7,11,0,0,7,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x28,
-};
-
-static const BitmapCharRec ch196 = {7,10,0,0,7,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch195 = {7,11,0,0,7,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch194 = {7,11,0,0,7,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch193 = {7,11,0,0,7,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch192 = {7,11,0,0,7,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x60,0x90,0x80,0x40,0x20,0x20,0x0,0x20,
-};
-
-static const BitmapCharRec ch191 = {4,8,-1,2,6,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x21,0x0,0x17,0x80,0x13,0x0,0x9,0x0,0xc8,0x0,0x24,0x0,0x44,0x0,0xe2,0x0,
-};
-
-static const BitmapCharRec ch190 = {9,8,0,0,9,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x27,0x12,0x15,0xb,0x48,0x44,0xc4,0x42,
-};
-
-static const BitmapCharRec ch189 = {8,8,0,0,9,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x21,0x0,0x17,0x80,0x13,0x0,0x9,0x0,0x48,0x0,0x44,0x0,0xc4,0x0,0x42,0x0,
-};
-
-static const BitmapCharRec ch188 = {9,8,0,0,9,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0xa0,0x50,0x28,0x50,0xa0,
-};
-
-static const BitmapCharRec ch187 = {5,5,0,0,6,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xe0,0x0,0xe0,0xa0,0xe0,
-};
-
-static const BitmapCharRec ch186 = {3,5,0,-3,4,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {2,4,0,-3,3,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xc0,0x40,
-};
-
-static const BitmapCharRec ch184 = {2,2,0,2,3,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,1,0,-3,3,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x28,0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,0x7c,
-};
-
-static const BitmapCharRec ch182 = {6,10,0,2,6,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0x80,0xf0,0x90,0x90,0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch181 = {4,8,0,2,5,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x40,
-};
-
-static const BitmapCharRec ch180 = {2,2,0,-6,3,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0xc0,0x20,0x40,0xe0,
-};
-
-static const BitmapCharRec ch179 = {3,4,0,-3,3,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xe0,0x40,0xa0,0x60,
-};
-
-static const BitmapCharRec ch178 = {3,4,0,-3,3,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xf8,0x0,0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch177 = {5,7,0,0,6,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,0,-3,4,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xe0,
-};
-
-static const BitmapCharRec ch175 = {3,1,0,-7,3,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x38,0x44,0xaa,0xb2,0xba,0x44,0x38,
-};
-
-static const BitmapCharRec ch174 = {7,7,-1,0,9,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xe0,
-};
-
-static const BitmapCharRec ch173 = {3,1,0,-3,4,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x8,0x8,0xf8,
-};
-
-static const BitmapCharRec ch172 = {5,3,-1,-2,7,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x28,0x50,0xa0,0x50,0x28,
-};
-
-static const BitmapCharRec ch171 = {5,5,0,0,6,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xe0,0x0,0xa0,0x20,0xe0,
-};
-
-static const BitmapCharRec ch170 = {3,5,0,-3,4,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x38,0x44,0x9a,0xa2,0x9a,0x44,0x38,
-};
-
-static const BitmapCharRec ch169 = {7,7,-1,0,9,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xa0,
-};
-
-static const BitmapCharRec ch168 = {3,1,0,-7,3,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x70,0x88,0x18,0x70,0xc8,0x98,0x70,0xc0,0x88,0x70,
-};
-
-static const BitmapCharRec ch167 = {5,10,0,2,6,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x80,0x0,0x0,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,10,-1,2,3,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x20,0xf8,0x20,0xf8,0x50,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch165 = {5,8,0,0,6,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x90,0x60,0x90,0x90,0x60,0x90,
-};
-
-static const BitmapCharRec ch164 = {4,6,0,-1,5,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xb0,0x48,0x40,0x40,0xe0,0x40,0x48,0x30,
-};
-
-static const BitmapCharRec ch163 = {5,8,0,0,6,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x40,0x70,0xa8,0xa0,0xa0,0xa8,0x70,0x10,
-};
-
-static const BitmapCharRec ch162 = {5,8,0,1,6,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,8,-1,2,3,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,3,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,3,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x98,0x64,
-};
-
-static const BitmapCharRec ch126 = {6,2,0,-3,7,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0x80,0x40,0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch125 = {3,10,0,2,3,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,10,-1,2,3,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x20,0x40,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch123 = {3,10,0,2,3,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xf0,0x80,0x40,0x20,0x10,0xf0,
-};
-
-static const BitmapCharRec ch122 = {4,6,0,0,5,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x80,0x40,0x40,0x60,0xa0,0xa0,0x90,0x90,
-};
-
-static const BitmapCharRec ch121 = {4,8,0,2,5,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0x88,0x88,0x50,0x20,0x50,0x88,
-};
-
-static const BitmapCharRec ch120 = {5,6,0,0,6,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x28,0x28,0x54,0x54,0x92,0x92,
-};
-
-static const BitmapCharRec ch119 = {7,6,0,0,8,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x20,0x20,0x50,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch118 = {5,6,0,0,6,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch117 = {4,6,0,0,5,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x60,0x40,0x40,0x40,0x40,0xe0,0x40,0x40,
-};
-
-static const BitmapCharRec ch116 = {3,8,0,0,4,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x60,0x90,0x10,0x60,0x90,0x60,
-};
-
-static const BitmapCharRec ch115 = {4,6,0,0,5,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0x80,0x80,0x80,0x80,0xc0,0xa0,
-};
-
-static const BitmapCharRec ch114 = {3,6,0,0,4,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x8,0x8,0x68,0x98,0x88,0x88,0x98,0x68,
-};
-
-static const BitmapCharRec ch113 = {5,8,0,2,6,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,0xb0,
-};
-
-static const BitmapCharRec ch112 = {5,8,0,2,6,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch111 = {5,6,0,0,6,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0x88,0x88,0x88,0x88,0xc8,0xb0,
-};
-
-static const BitmapCharRec ch110 = {5,6,0,0,6,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0x92,0x92,0x92,0x92,0x92,0xec,
-};
-
-static const BitmapCharRec ch109 = {7,6,0,0,8,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch108 = {1,8,0,0,2,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x90,0x90,0xa0,0xc0,0xa0,0x90,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {4,8,0,0,5,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch106 = {1,9,0,1,2,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch105 = {1,8,0,0,2,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0x88,0x88,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {5,8,0,0,6,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x70,0x8,0x68,0x98,0x88,0x88,0x98,0x68,
-};
-
-static const BitmapCharRec ch103 = {5,8,0,2,6,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x40,0x40,0x40,0x40,0x40,0xe0,0x40,0x30,
-};
-
-static const BitmapCharRec ch102 = {4,8,0,0,4,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,
-};
-
-static const BitmapCharRec ch101 = {4,6,0,0,5,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x68,0x98,0x88,0x88,0x98,0x68,0x8,0x8,
-};
-
-static const BitmapCharRec ch100 = {5,8,0,0,6,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x60,0x90,0x80,0x80,0x90,0x60,
-};
-
-static const BitmapCharRec ch99 = {4,6,0,0,5,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xb0,0xc8,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {5,8,0,0,6,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,
-};
-
-static const BitmapCharRec ch97 = {5,6,0,0,5,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0x80,0x80,0x40,
-};
-
-static const BitmapCharRec ch96 = {2,3,0,-5,3,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch95 = {6,1,0,2,6,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x88,0x50,0x50,0x20,0x20,
-};
-
-static const BitmapCharRec ch94 = {5,5,0,-3,6,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,
-};
-
-static const BitmapCharRec ch93 = {2,10,0,2,3,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x20,0x20,0x40,0x40,0x40,0x40,0x80,0x80,
-};
-
-static const BitmapCharRec ch92 = {3,8,0,0,3,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
-};
-
-static const BitmapCharRec ch91 = {2,10,-1,2,3,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xf8,0x80,0x40,0x20,0x20,0x10,0x8,0xf8,
-};
-
-static const BitmapCharRec ch90 = {5,8,-1,0,7,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x10,0x10,0x10,0x28,0x28,0x44,0x44,0x82,
-};
-
-static const BitmapCharRec ch89 = {7,8,0,0,7,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0x88,0x88,0x50,0x50,0x20,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch88 = {5,8,-1,0,7,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x22,0x0,0x22,0x0,0x22,0x0,0x55,0x0,0x49,0x0,0x49,0x0,0x88,0x80,0x88,0x80,
-};
-
-static const BitmapCharRec ch87 = {9,8,0,0,9,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x28,0x28,0x44,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch86 = {7,8,0,0,7,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch85 = {6,8,-1,0,8,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,
-};
-
-static const BitmapCharRec ch84 = {5,8,0,0,5,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x70,0x88,0x88,0x8,0x70,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch83 = {5,8,-1,0,7,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0x88,0x88,0x88,0x88,0xf0,0x88,0x88,0xf0,
-};
-
-static const BitmapCharRec ch82 = {5,8,-1,0,7,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x2,0x7c,0x8c,0x94,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch81 = {7,9,-1,1,8,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0x80,0x80,0x80,0x80,0xf0,0x88,0x88,0xf0,
-};
-
-static const BitmapCharRec ch80 = {5,8,-1,0,7,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch79 = {6,8,-1,0,8,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0x8c,0x8c,0x94,0x94,0xa4,0xa4,0xc4,0xc4,
-};
-
-static const BitmapCharRec ch78 = {6,8,-1,0,8,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0x92,0x92,0x92,0xaa,0xaa,0xc6,0xc6,0x82,
-};
-
-static const BitmapCharRec ch77 = {7,8,-1,0,9,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xf0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch76 = {4,8,-1,0,6,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0x88,0x88,0x90,0x90,0xe0,0xa0,0x90,0x88,
-};
-
-static const BitmapCharRec ch75 = {5,8,-1,0,7,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x60,0x90,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch74 = {4,8,0,0,5,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch73 = {1,8,-1,0,3,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0x84,0x84,0x84,0x84,0xfc,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch72 = {6,8,-1,0,8,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x74,0x8c,0x84,0x8c,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch71 = {6,8,-1,0,8,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0x80,0x80,0x80,0x80,0xf0,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch70 = {5,8,-1,0,6,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch69 = {5,8,-1,0,7,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xf0,0x88,0x84,0x84,0x84,0x84,0x88,0xf0,
-};
-
-static const BitmapCharRec ch68 = {6,8,-1,0,8,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x78,0x84,0x80,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch67 = {6,8,-1,0,8,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xf0,0x88,0x88,0x88,0xf0,0x88,0x88,0xf0,
-};
-
-static const BitmapCharRec ch66 = {5,8,-1,0,7,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,
-};
-
-static const BitmapCharRec ch65 = {7,8,0,0,7,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x3e,0x0,0x40,0x0,0x9b,0x0,0xa4,0x80,0xa4,0x80,0xa2,0x40,0x92,0x40,0x4d,0x40,
-0x20,0x80,0x1f,0x0,
-};
-
-static const BitmapCharRec ch64 = {10,10,0,2,11,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x40,0x0,0x40,0x40,0x20,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch63 = {4,8,-1,0,6,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0x80,0x40,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch62 = {3,5,-1,-1,6,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xf0,0x0,0xf0,
-};
-
-static const BitmapCharRec ch61 = {4,3,0,-2,5,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x20,0x40,0x80,0x40,0x20,
-};
-
-static const BitmapCharRec ch60 = {3,5,-1,-1,6,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x40,0x40,0x0,0x0,0x0,0x0,0x40,
-};
-
-static const BitmapCharRec ch59 = {2,8,0,2,3,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0x80,0x0,0x0,0x0,0x0,0x80,
-};
-
-static const BitmapCharRec ch58 = {1,6,-1,0,3,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x70,0x88,0x8,0x68,0x98,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch57 = {5,8,0,0,6,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x70,0x88,0x88,0x88,0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch56 = {5,8,0,0,6,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x20,0x20,0x10,0x10,0x8,0xf8,
-};
-
-static const BitmapCharRec ch55 = {5,8,0,0,6,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x70,0x88,0x88,0xc8,0xb0,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch54 = {5,8,0,0,6,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x70,0x88,0x8,0x8,0xf0,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch53 = {5,8,0,0,6,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x10,0x10,0xf8,0x90,0x50,0x50,0x30,0x10,
-};
-
-static const BitmapCharRec ch52 = {5,8,0,0,6,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x70,0x88,0x8,0x8,0x30,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch51 = {5,8,0,0,6,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xf8,0x80,0x40,0x30,0x8,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch50 = {5,8,0,0,6,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch49 = {2,8,-1,0,6,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch48 = {5,8,0,0,6,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x80,0x40,0x40,0x40,0x40,0x20,0x20,
-};
-
-static const BitmapCharRec ch47 = {3,8,0,0,3,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch46 = {1,1,-1,0,3,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xf8,
-};
-
-static const BitmapCharRec ch45 = {5,1,-1,-3,7,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x40,0x40,
-};
-
-static const BitmapCharRec ch44 = {2,3,0,2,3,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch43 = {5,5,0,-1,6,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0xa0,0x40,0xa0,
-};
-
-static const BitmapCharRec ch42 = {3,3,0,-5,4,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,10,-1,2,4,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,10,0,2,4,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x40,0x40,
-};
-
-static const BitmapCharRec ch39 = {2,3,-1,-5,3,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x64,0x98,0x98,0xa4,0x60,0x50,0x50,0x20,
-};
-
-static const BitmapCharRec ch38 = {6,8,-1,0,8,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x26,0x29,0x16,0x10,0x8,0x68,0x94,0x64,
-};
-
-static const BitmapCharRec ch37 = {8,8,0,0,9,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x20,0x70,0xa8,0x28,0x70,0xa0,0xa8,0x70,0x20,
-};
-
-static const BitmapCharRec ch36 = {5,9,0,1,6,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x50,0x50,0xf8,0x28,0x7c,0x28,0x28,
-};
-
-static const BitmapCharRec ch35 = {6,7,0,0,6,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0xa0,0xa0,
-};
-
-static const BitmapCharRec ch34 = {3,2,-1,-6,4,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x0,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,8,-1,0,3,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {0,0,0,0,3,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,3,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-const BitmapFontRec glutBitmapHelvetica10 = {
-"-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/beos/glut_hel12.c b/src/glut/beos/glut_hel12.c
deleted file mode 100644 (file)
index 68aed8a..0000000
+++ /dev/null
@@ -1,1788 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapHelvetica12 XXX
-#include "glutbitmap.h"
-#undef glutBitmapHelvetica12
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0xc0,0x20,0x20,0x20,0x30,0x50,0x50,0x48,0x88,0x88,0x0,0x50,
-};
-
-static const BitmapCharRec ch255 = {5,12,-1,3,7,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0x80,0x80,0x80,0xb0,0xc8,0x88,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {5,12,-1,3,7,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x80,0x40,0x20,0x20,0x50,0x50,0x90,0x88,0x88,0x88,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch253 = {5,13,-1,3,7,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,0x0,0x50,
-};
-
-static const BitmapCharRec ch252 = {5,9,-1,0,7,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch251 = {5,10,-1,0,7,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch250 = {5,10,-1,0,7,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch249 = {5,10,-1,0,7,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0xb8,0x44,0x64,0x54,0x4c,0x44,0x3a,
-};
-
-static const BitmapCharRec ch248 = {7,7,0,0,7,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x20,0x0,0xf8,0x0,0x20,
-};
-
-static const BitmapCharRec ch247 = {5,5,-1,-1,7,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x50,
-};
-
-static const BitmapCharRec ch246 = {5,9,-1,0,7,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch245 = {5,10,-1,0,7,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch244 = {5,10,-1,0,7,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch243 = {5,10,-1,0,7,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch242 = {5,10,-1,0,7,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0x88,0x88,0x88,0x88,0x88,0xc8,0xb0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch241 = {5,10,-1,0,7,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x70,0x88,0x88,0x88,0x88,0x78,0x8,0x50,0x30,0x68,
-};
-
-static const BitmapCharRec ch240 = {5,10,-1,0,7,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,
-};
-
-static const BitmapCharRec ch239 = {3,9,0,0,3,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch238 = {3,10,0,0,3,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x40,
-};
-
-static const BitmapCharRec ch237 = {2,10,-1,0,3,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch236 = {2,10,0,0,3,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,0x0,0x50,
-};
-
-static const BitmapCharRec ch235 = {5,9,-1,0,7,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch234 = {5,10,-1,0,7,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch233 = {5,10,-1,0,7,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch232 = {5,10,-1,0,7,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x60,0x10,0x20,0x70,0x88,0x80,0x80,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch231 = {5,10,-1,3,7,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x77,0x0,0x88,0x80,0x88,0x0,0x7f,0x80,0x8,0x80,0x88,0x80,0x77,0x0,
-};
-
-static const BitmapCharRec ch230 = {9,7,-1,0,11,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x30,0x48,0x30,
-};
-
-static const BitmapCharRec ch229 = {6,10,-1,0,7,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x50,
-};
-
-static const BitmapCharRec ch228 = {6,9,-1,0,7,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch227 = {6,10,-1,0,7,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch226 = {6,10,-1,0,7,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch225 = {6,10,-1,0,7,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch224 = {6,10,-1,0,7,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xb0,0x88,0x88,0x88,0xb0,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch223 = {5,9,-1,0,7,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0x80,0x80,0xf8,0x84,0x84,0x84,0xf8,0x80,0x80,
-};
-
-static const BitmapCharRec ch222 = {6,9,-1,0,8,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x10,0x10,0x10,0x10,0x28,0x44,0x44,0x82,0x82,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch221 = {7,12,-1,0,9,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x48,
-};
-
-static const BitmapCharRec ch220 = {6,11,-1,0,8,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch219 = {6,12,-1,0,8,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch218 = {6,12,-1,0,8,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch217 = {6,12,-1,0,8,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x0,0x5e,0x0,0x21,0x0,0x50,0x80,0x48,0x80,0x44,0x80,0x44,0x80,0x42,0x80,
-0x21,0x0,0x1e,0x80,0x0,0x40,
-};
-
-static const BitmapCharRec ch216 = {10,11,0,1,10,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x88,0x50,0x20,0x50,0x88,
-};
-
-static const BitmapCharRec ch215 = {5,5,-1,-1,7,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x24,
-};
-
-static const BitmapCharRec ch214 = {8,11,-1,0,10,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch213 = {8,12,-1,0,10,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x14,0x8,
-};
-
-static const BitmapCharRec ch212 = {8,12,-1,0,10,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x8,0x4,
-};
-
-static const BitmapCharRec ch211 = {8,12,-1,0,10,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x8,0x10,
-};
-
-static const BitmapCharRec ch210 = {8,12,-1,0,10,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0x82,0x86,0x8a,0x8a,0x92,0xa2,0xa2,0xc2,0x82,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch209 = {7,12,-1,0,9,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0x7c,0x42,0x41,0x41,0xf1,0x41,0x41,0x42,0x7c,
-};
-
-static const BitmapCharRec ch208 = {8,9,0,0,9,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,
-};
-
-static const BitmapCharRec ch207 = {3,11,0,0,3,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch206 = {3,12,0,0,3,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x40,
-};
-
-static const BitmapCharRec ch205 = {2,12,-1,0,3,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch204 = {2,12,0,0,3,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,0x0,0x28,
-};
-
-static const BitmapCharRec ch203 = {6,11,-1,0,8,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch202 = {6,12,-1,0,8,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch201 = {6,12,-1,0,8,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch200 = {6,12,-1,0,8,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x30,0x8,0x8,0x3c,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x3c,
-};
-
-static const BitmapCharRec ch199 = {7,12,-1,3,9,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0x8f,0x80,0x88,0x0,0x88,0x0,0x78,0x0,0x4f,0x80,0x48,0x0,0x28,0x0,0x28,0x0,
-0x1f,0x80,
-};
-
-static const BitmapCharRec ch198 = {9,9,-1,0,11,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x10,0x28,0x10,
-};
-
-static const BitmapCharRec ch197 = {7,12,-1,0,9,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x28,
-};
-
-static const BitmapCharRec ch196 = {7,11,-1,0,9,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch195 = {7,12,-1,0,9,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch194 = {7,12,-1,0,9,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch193 = {7,12,-1,0,9,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch192 = {7,12,-1,0,9,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x70,0x88,0x88,0x40,0x40,0x20,0x20,0x0,0x20,
-};
-
-static const BitmapCharRec ch191 = {5,9,-1,3,7,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x21,0x0,0x17,0x80,0x15,0x0,0xb,0x0,0xc9,0x0,0x24,0x0,0x44,0x0,0x22,0x0,
-0xe1,0x0,
-};
-
-static const BitmapCharRec ch190 = {9,9,0,0,10,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x47,0x80,0x22,0x0,0x11,0x0,0x14,0x80,0x4b,0x0,0x48,0x0,0x44,0x0,0xc2,0x0,
-0x41,0x0,
-};
-
-static const BitmapCharRec ch189 = {9,9,0,0,10,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x41,0x0,0x27,0x80,0x15,0x0,0x13,0x0,0x49,0x0,0x44,0x0,0x44,0x0,0xc2,0x0,
-0x41,0x0,
-};
-
-static const BitmapCharRec ch188 = {9,9,0,0,10,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0xa0,0x50,0x28,0x50,0xa0,
-};
-
-static const BitmapCharRec ch187 = {5,5,-1,-1,7,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xe0,0x0,0xe0,0xa0,0xe0,
-};
-
-static const BitmapCharRec ch186 = {3,5,-1,-4,5,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {2,5,-1,-3,4,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xc0,0x20,0x20,0x40,
-};
-
-static const BitmapCharRec ch184 = {3,4,0,3,3,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch183 = {1,1,-1,-3,3,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x28,0x28,0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,0x68,0x3c,
-};
-
-static const BitmapCharRec ch182 = {6,12,0,3,7,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0x80,0x80,0xe8,0x98,0x88,0x88,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch181 = {5,10,-1,3,7,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x40,
-};
-
-static const BitmapCharRec ch180 = {2,2,0,-8,2,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0xc0,0x20,0x40,0x20,0xe0,
-};
-
-static const BitmapCharRec ch179 = {3,5,0,-3,4,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xf0,0x40,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch178 = {4,5,0,-3,4,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xf8,0x0,0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch177 = {5,7,-1,0,7,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,0,-4,5,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xf0,
-};
-
-static const BitmapCharRec ch175 = {4,1,0,-8,4,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x3e,0x0,0x41,0x0,0x94,0x80,0x94,0x80,0x98,0x80,0x94,0x80,0x9c,0x80,0x41,0x0,
-0x3e,0x0,
-};
-
-static const BitmapCharRec ch174 = {9,9,-1,0,11,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xf0,
-};
-
-static const BitmapCharRec ch173 = {4,1,0,-3,5,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x4,0x4,0x4,0xfc,
-};
-
-static const BitmapCharRec ch172 = {6,4,-1,-2,8,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x28,0x50,0xa0,0x50,0x28,
-};
-
-static const BitmapCharRec ch171 = {5,5,-1,-1,7,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xe0,0x0,0xa0,0x20,0xe0,
-};
-
-static const BitmapCharRec ch170 = {3,5,-1,-4,5,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x3e,0x0,0x41,0x0,0x9c,0x80,0xa2,0x80,0xa0,0x80,0xa2,0x80,0x9c,0x80,0x41,0x0,
-0x3e,0x0,
-};
-
-static const BitmapCharRec ch169 = {9,9,-1,0,11,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xa0,
-};
-
-static const BitmapCharRec ch168 = {3,1,0,-8,3,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x70,0x88,0x8,0x30,0x48,0x88,0x88,0x90,0x60,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch167 = {5,12,0,3,6,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,11,-1,2,3,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x20,0x20,0xf8,0x20,0xf8,0x20,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch165 = {5,9,-1,0,7,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x84,0x78,0x48,0x48,0x78,0x84,
-};
-
-static const BitmapCharRec ch164 = {6,6,0,-1,7,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xb0,0x48,0x20,0x20,0xf0,0x40,0x40,0x48,0x30,
-};
-
-static const BitmapCharRec ch163 = {5,9,-1,0,7,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x40,0x70,0xc8,0xa0,0xa0,0xa0,0xa8,0x70,0x10,
-};
-
-static const BitmapCharRec ch162 = {5,9,-1,1,7,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,10,-1,3,3,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,4,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,4,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x98,0x64,
-};
-
-static const BitmapCharRec ch126 = {6,2,0,-3,7,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xc0,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0xc0,
-};
-
-static const BitmapCharRec ch125 = {4,12,0,3,4,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,12,-1,3,3,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x30,0x40,0x40,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x40,0x30,
-};
-
-static const BitmapCharRec ch123 = {4,12,0,3,4,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xf0,0x80,0x40,0x40,0x20,0x10,0xf0,
-};
-
-static const BitmapCharRec ch122 = {4,7,-1,0,6,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x80,0x40,0x20,0x20,0x50,0x50,0x90,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch121 = {5,10,-1,3,7,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0x84,0x84,0x48,0x30,0x30,0x48,0x84,
-};
-
-static const BitmapCharRec ch120 = {6,7,0,0,6,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x22,0x0,0x22,0x0,0x55,0x0,0x49,0x0,0x49,0x0,0x88,0x80,0x88,0x80,
-};
-
-static const BitmapCharRec ch119 = {9,7,0,0,9,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x20,0x20,0x50,0x50,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch118 = {5,7,-1,0,7,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch117 = {5,7,-1,0,7,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x60,0x40,0x40,0x40,0x40,0x40,0xe0,0x40,0x40,
-};
-
-static const BitmapCharRec ch116 = {3,9,0,0,3,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x60,0x90,0x10,0x60,0x80,0x90,0x60,
-};
-
-static const BitmapCharRec ch115 = {4,7,-1,0,6,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0x80,0x80,0x80,0x80,0x80,0xc0,0xa0,
-};
-
-static const BitmapCharRec ch114 = {3,7,-1,0,4,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x8,0x8,0x8,0x68,0x98,0x88,0x88,0x88,0x98,0x68,
-};
-
-static const BitmapCharRec ch113 = {5,10,-1,3,7,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0x80,0x80,0x80,0xb0,0xc8,0x88,0x88,0x88,0xc8,0xb0,
-};
-
-static const BitmapCharRec ch112 = {5,10,-1,3,7,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch111 = {5,7,-1,0,7,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0x88,0x88,0x88,0x88,0x88,0xc8,0xb0,
-};
-
-static const BitmapCharRec ch110 = {5,7,-1,0,7,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0x92,0x92,0x92,0x92,0x92,0xda,0xa4,
-};
-
-static const BitmapCharRec ch109 = {7,7,-1,0,9,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch108 = {1,9,-1,0,3,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x88,0x90,0xa0,0xc0,0xc0,0xa0,0x90,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {5,9,-1,0,6,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,
-};
-
-static const BitmapCharRec ch106 = {2,12,0,3,3,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch105 = {1,9,-1,0,3,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0x88,0x88,0x88,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {5,9,-1,0,7,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x70,0x88,0x8,0x68,0x98,0x88,0x88,0x88,0x98,0x68,
-};
-
-static const BitmapCharRec ch103 = {5,10,-1,3,7,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0xe0,0x40,0x30,
-};
-
-static const BitmapCharRec ch102 = {4,9,0,0,3,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch101 = {5,7,-1,0,7,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x68,0x98,0x88,0x88,0x88,0x98,0x68,0x8,0x8,
-};
-
-static const BitmapCharRec ch100 = {5,9,-1,0,7,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x70,0x88,0x80,0x80,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch99 = {5,7,-1,0,7,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xb0,0xc8,0x88,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {5,9,-1,0,7,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch97 = {6,7,-1,0,7,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0xc0,0x80,0x40,
-};
-
-static const BitmapCharRec ch96 = {2,3,0,-6,3,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xfe,
-};
-
-static const BitmapCharRec ch95 = {7,1,0,2,7,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x88,0x50,0x20,
-};
-
-static const BitmapCharRec ch94 = {5,3,0,-5,6,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,
-};
-
-static const BitmapCharRec ch93 = {2,12,0,3,3,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x10,0x10,0x20,0x20,0x20,0x40,0x40,0x80,0x80,
-};
-
-static const BitmapCharRec ch92 = {4,9,0,0,4,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
-};
-
-static const BitmapCharRec ch91 = {2,12,-1,3,3,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xfe,0x80,0x40,0x20,0x10,0x8,0x4,0x2,0xfe,
-};
-
-static const BitmapCharRec ch90 = {7,9,-1,0,9,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x10,0x10,0x10,0x10,0x28,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch89 = {7,9,-1,0,9,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0x82,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x82,
-};
-
-static const BitmapCharRec ch88 = {7,9,-1,0,9,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x22,0x0,0x22,0x0,0x22,0x0,0x55,0x0,0x55,0x0,0x49,0x0,0x88,0x80,0x88,0x80,
-0x88,0x80,
-};
-
-static const BitmapCharRec ch87 = {9,9,-1,0,11,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x10,0x28,0x28,0x44,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch86 = {7,9,-1,0,9,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch85 = {6,9,-1,0,8,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xfe,
-};
-
-static const BitmapCharRec ch84 = {7,9,0,0,7,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x78,0x84,0x84,0x4,0x18,0x60,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch83 = {6,9,-1,0,8,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0x84,0x84,0x84,0x88,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch82 = {6,9,-1,0,8,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x3d,0x42,0x85,0x89,0x81,0x81,0x81,0x42,0x3c,
-};
-
-static const BitmapCharRec ch81 = {8,9,-1,0,10,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0x80,0x80,0x80,0x80,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch80 = {6,9,-1,0,8,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,
-};
-
-static const BitmapCharRec ch79 = {8,9,-1,0,10,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0x82,0x86,0x8a,0x8a,0x92,0xa2,0xa2,0xc2,0x82,
-};
-
-static const BitmapCharRec ch78 = {7,9,-1,0,9,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0x88,0x80,0x88,0x80,0x94,0x80,0x94,0x80,0xa2,0x80,0xa2,0x80,0xc1,0x80,0xc1,0x80,
-0x80,0x80,
-};
-
-static const BitmapCharRec ch77 = {9,9,-1,0,11,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch76 = {5,9,-1,0,7,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0x82,0x84,0x88,0x90,0xe0,0xa0,0x90,0x88,0x84,
-};
-
-static const BitmapCharRec ch75 = {7,9,-1,0,8,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x70,0x88,0x88,0x8,0x8,0x8,0x8,0x8,0x8,
-};
-
-static const BitmapCharRec ch74 = {5,9,-1,0,7,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch73 = {1,9,-1,0,3,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0x82,0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch72 = {7,9,-1,0,9,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x3a,0x46,0x82,0x82,0x8e,0x80,0x80,0x42,0x3c,
-};
-
-static const BitmapCharRec ch71 = {7,9,-1,0,9,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0x80,0x80,0x80,0x80,0xf8,0x80,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch70 = {6,9,-1,0,8,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch69 = {6,9,-1,0,8,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xf8,0x84,0x82,0x82,0x82,0x82,0x82,0x84,0xf8,
-};
-
-static const BitmapCharRec ch68 = {7,9,-1,0,9,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x3c,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x3c,
-};
-
-static const BitmapCharRec ch67 = {7,9,-1,0,9,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xf8,0x84,0x84,0x84,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch66 = {6,9,-1,0,8,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x28,0x10,
-};
-
-static const BitmapCharRec ch65 = {7,9,-1,0,9,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x3e,0x0,0x40,0x0,0x9b,0x0,0xa6,0x80,0xa2,0x40,0xa2,0x40,0x92,0x40,0x4d,0x40,
-0x60,0x80,0x1f,0x0,
-};
-
-static const BitmapCharRec ch64 = {10,10,-1,1,12,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x20,0x0,0x20,0x20,0x10,0x10,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch63 = {5,9,-1,0,7,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0xc0,0x30,0xc,0x30,0xc0,
-};
-
-static const BitmapCharRec ch62 = {6,5,-1,-1,7,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xf8,0x0,0xf8,
-};
-
-static const BitmapCharRec ch61 = {5,3,-1,-2,7,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0xc,0x30,0xc0,0x30,0xc,
-};
-
-static const BitmapCharRec ch60 = {6,5,0,-1,7,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x40,0x40,0x0,0x0,0x0,0x0,0x40,
-};
-
-static const BitmapCharRec ch59 = {2,8,0,2,3,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0x80,0x0,0x0,0x0,0x0,0x80,
-};
-
-static const BitmapCharRec ch58 = {1,6,-1,0,3,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x70,0x88,0x8,0x8,0x78,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch57 = {5,9,-1,0,7,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch56 = {5,9,-1,0,7,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x20,0x20,0x20,0x10,0x10,0x8,0xf8,
-};
-
-static const BitmapCharRec ch55 = {5,9,-1,0,7,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x70,0x88,0x88,0x88,0xc8,0xb0,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch54 = {5,9,-1,0,7,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x70,0x88,0x88,0x8,0x8,0xf0,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch53 = {5,9,-1,0,7,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x8,0x8,0xfc,0x88,0x48,0x28,0x28,0x18,0x8,
-};
-
-static const BitmapCharRec ch52 = {6,9,0,0,7,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x70,0x88,0x88,0x8,0x8,0x30,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch51 = {5,9,-1,0,7,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xf8,0x80,0x80,0x40,0x20,0x10,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch50 = {5,9,-1,0,7,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xe0,0x20,
-};
-
-static const BitmapCharRec ch49 = {3,9,-1,0,7,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch48 = {5,9,-1,0,7,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x80,0x40,0x40,0x40,0x20,0x20,0x10,0x10,
-};
-
-static const BitmapCharRec ch47 = {4,9,0,0,4,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch46 = {1,1,-1,0,3,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xf8,
-};
-
-static const BitmapCharRec ch45 = {5,1,-1,-3,8,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x40,0x40,
-};
-
-static const BitmapCharRec ch44 = {2,3,-1,2,4,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch43 = {5,5,-1,-1,7,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0xa0,0x40,0xa0,
-};
-
-static const BitmapCharRec ch42 = {3,3,-1,-6,5,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,12,0,3,4,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,12,-1,3,4,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x40,0xc0,
-};
-
-static const BitmapCharRec ch39 = {2,3,-1,-6,3,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x72,0x8c,0x84,0x8a,0x50,0x30,0x48,0x48,0x30,
-};
-
-static const BitmapCharRec ch38 = {7,9,-1,0,9,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x23,0x0,0x14,0x80,0x14,0x80,0x13,0x0,0x8,0x0,0x68,0x0,0x94,0x0,0x94,0x0,
-0x62,0x0,
-};
-
-static const BitmapCharRec ch37 = {9,9,-1,0,11,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x20,0x70,0xa8,0xa8,0x28,0x70,0xa0,0xa8,0x70,0x20,
-};
-
-static const BitmapCharRec ch36 = {5,10,-1,1,7,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x50,0x50,0x50,0xfc,0x28,0xfc,0x28,0x28,
-};
-
-static const BitmapCharRec ch35 = {6,8,0,0,7,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0xa0,0xa0,0xa0,
-};
-
-static const BitmapCharRec ch34 = {3,3,-1,-6,5,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,9,-1,0,3,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,4,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,4,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-const BitmapFontRec glutBitmapHelvetica12 = {
-"-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/beos/glut_hel18.c b/src/glut/beos/glut_hel18.c
deleted file mode 100644 (file)
index f080084..0000000
+++ /dev/null
@@ -1,1897 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapHelvetica18 XXX
-#include "glutbitmap.h"
-#undef glutBitmapHelvetica18
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,0x0,0x66,
-0x66,
-};
-
-static const BitmapCharRec ch255 = {8,17,-1,4,10,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,0xff,0x0,0xde,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0xc0,0x0,
-};
-
-static const BitmapCharRec ch254 = {9,18,-1,4,11,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,0x0,0x18,
-0xc,0x6,
-};
-
-static const BitmapCharRec ch253 = {8,18,-1,4,10,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x66,0x66,
-};
-
-static const BitmapCharRec ch252 = {8,13,-1,0,10,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x66,0x3c,0x18,
-};
-
-static const BitmapCharRec ch251 = {8,14,-1,0,10,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x18,0xc,0x6,
-};
-
-static const BitmapCharRec ch250 = {8,14,-1,0,10,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0xc,0x18,0x30,
-};
-
-static const BitmapCharRec ch249 = {8,14,-1,0,10,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0xce,0x0,0x7f,0x80,0x31,0x80,0x78,0xc0,0x6c,0xc0,0x66,0xc0,0x63,0xc0,0x31,0x80,
-0x3f,0xc0,0xe,0x60,
-};
-
-static const BitmapCharRec ch248 = {11,10,0,0,11,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x18,0x18,0x0,0xff,0xff,0x0,0x18,0x18,
-};
-
-static const BitmapCharRec ch247 = {8,8,-1,-1,10,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0x36,0x0,0x36,0x0,
-};
-
-static const BitmapCharRec ch246 = {9,13,-1,0,11,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0x26,0x0,0x2d,0x0,0x19,0x0,
-};
-
-static const BitmapCharRec ch245 = {9,14,-1,0,11,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0x33,0x0,0x1e,0x0,0xc,0x0,
-};
-
-static const BitmapCharRec ch244 = {9,14,-1,0,11,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0x18,0x0,0xc,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch243 = {9,14,-1,0,11,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0xc,0x0,0x18,0x0,0x30,0x0,
-};
-
-static const BitmapCharRec ch242 = {9,14,-1,0,11,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,0x0,0x4c,0x5a,0x32,
-};
-
-static const BitmapCharRec ch241 = {8,14,-1,0,10,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x4c,0x0,0x38,0x0,0x36,0x0,0x60,0x0,
-};
-
-static const BitmapCharRec ch240 = {9,14,-1,0,11,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0xd8,0xd8,
-};
-
-static const BitmapCharRec ch239 = {5,13,0,0,4,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,0x78,0x30,
-};
-
-static const BitmapCharRec ch238 = {6,14,1,0,4,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0xc0,0x60,0x30,
-};
-
-static const BitmapCharRec ch237 = {4,14,0,0,4,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0x30,0x60,0xc0,
-};
-
-static const BitmapCharRec ch236 = {4,14,0,0,4,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x36,0x36,
-};
-
-static const BitmapCharRec ch235 = {8,13,-1,0,10,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x66,0x3c,0x18,
-};
-
-static const BitmapCharRec ch234 = {8,14,-1,0,10,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x18,0xc,0x6,
-};
-
-static const BitmapCharRec ch233 = {8,14,-1,0,10,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x18,0x30,0x60,
-};
-
-static const BitmapCharRec ch232 = {8,14,-1,0,10,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x78,0x6c,0xc,0x38,0x3e,0x7f,0x63,0xc0,0xc0,0xc0,0xc0,0x63,0x7f,0x3e,
-};
-
-static const BitmapCharRec ch231 = {8,14,-1,4,10,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x75,0xe0,0xef,0xf8,0xc7,0x18,0xc6,0x0,0xe6,0x0,0x7f,0xf8,0xe,0x18,0xc6,0x18,
-0xef,0xf0,0x7d,0xe0,
-};
-
-static const BitmapCharRec ch230 = {13,10,-1,0,15,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x38,0x6c,0x6c,0x38,
-};
-
-static const BitmapCharRec ch229 = {7,14,-1,0,9,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x6c,0x6c,
-};
-
-static const BitmapCharRec ch228 = {7,13,-1,0,9,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x4c,0x5a,0x32,
-};
-
-static const BitmapCharRec ch227 = {7,14,-1,0,9,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x66,0x3c,0x18,
-};
-
-static const BitmapCharRec ch226 = {7,14,-1,0,9,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x30,0x18,0xc,
-};
-
-static const BitmapCharRec ch225 = {7,14,-1,0,9,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x18,0x30,0x60,
-};
-
-static const BitmapCharRec ch224 = {7,14,-1,0,9,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xdc,0xde,0xc6,0xc6,0xc6,0xc6,0xdc,0xdc,0xc6,0xc6,0xc6,0xc6,0x7c,0x38,
-};
-
-static const BitmapCharRec ch223 = {7,14,-1,0,9,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x80,0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc1,0xc0,0xff,0x80,0xff,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-};
-
-static const BitmapCharRec ch222 = {10,14,-1,0,12,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
-0x30,0xc0,0x30,0xc0,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,0x0,0x0,0x6,0x0,
-0x3,0x0,0x1,0x80,
-};
-
-static const BitmapCharRec ch221 = {12,18,-1,0,14,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x19,0x80,
-0x19,0x80,
-};
-
-static const BitmapCharRec ch220 = {11,17,-1,0,13,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x19,0x80,
-0xf,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch219 = {11,18,-1,0,13,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0xc,0x0,
-0x6,0x0,0x3,0x0,
-};
-
-static const BitmapCharRec ch218 = {11,18,-1,0,13,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x6,0x0,
-0xc,0x0,0x18,0x0,
-};
-
-static const BitmapCharRec ch217 = {11,18,-1,0,13,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0xc7,0xc0,0xff,0xf0,0x78,0x38,0x38,0x18,0x6c,0x1c,0x6e,0xc,0x67,0xc,0x63,0x8c,
-0x61,0xcc,0x70,0xdc,0x30,0x78,0x38,0x38,0x1f,0xfc,0x7,0xcc,
-};
-
-static const BitmapCharRec ch216 = {14,14,0,0,15,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0xc0,0xc0,0x61,0x80,0x33,0x0,0x1e,0x0,0xc,0x0,0x1e,0x0,0x33,0x0,0x61,0x80,
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch215 = {10,9,0,0,10,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0xd,0x80,
-0xd,0x80,
-};
-
-static const BitmapCharRec ch214 = {13,17,-1,0,15,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x9,0x80,
-0xb,0x40,0x6,0x40,
-};
-
-static const BitmapCharRec ch213 = {13,18,-1,0,15,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0xc,0xc0,
-0x7,0x80,0x3,0x0,
-};
-
-static const BitmapCharRec ch212 = {13,18,-1,0,15,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x3,0x0,
-0x1,0x80,0x0,0xc0,
-};
-
-static const BitmapCharRec ch211 = {13,18,-1,0,15,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x3,0x0,
-0x6,0x0,0xc,0x0,
-};
-
-static const BitmapCharRec ch210 = {13,18,-1,0,15,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0xc0,0x60,0xc0,0xe0,0xc1,0xe0,0xc1,0xe0,0xc3,0x60,0xc6,0x60,0xc6,0x60,0xcc,0x60,
-0xcc,0x60,0xd8,0x60,0xd8,0x60,0xf0,0x60,0xe0,0x60,0xe0,0x60,0x0,0x0,0x13,0x0,
-0x16,0x80,0xc,0x80,
-};
-
-static const BitmapCharRec ch209 = {11,18,-1,0,13,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0x7f,0x80,0x7f,0xc0,0x60,0xe0,0x60,0x60,0x60,0x30,0x60,0x30,0xfc,0x30,0xfc,0x30,
-0x60,0x30,0x60,0x30,0x60,0x60,0x60,0xe0,0x7f,0xc0,0x7f,0x80,
-};
-
-static const BitmapCharRec ch208 = {12,14,0,0,13,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,
-0xcc,
-};
-
-static const BitmapCharRec ch207 = {6,17,0,0,6,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,
-0x78,0x30,
-};
-
-static const BitmapCharRec ch206 = {6,18,0,0,6,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0xc0,
-0x60,0x30,
-};
-
-static const BitmapCharRec ch205 = {4,18,-2,0,6,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0x30,
-0x60,0xc0,
-};
-
-static const BitmapCharRec ch204 = {4,18,0,0,6,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0x33,0x0,
-0x33,0x0,
-};
-
-static const BitmapCharRec ch203 = {9,17,-1,0,11,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0x33,0x0,
-0x1e,0x0,0xc,0x0,
-};
-
-static const BitmapCharRec ch202 = {9,18,-1,0,11,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0xc,0x0,
-0x6,0x0,0x3,0x0,
-};
-
-static const BitmapCharRec ch201 = {9,18,-1,0,11,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0xc,0x0,
-0x18,0x0,0x30,0x0,
-};
-
-static const BitmapCharRec ch200 = {9,18,-1,0,11,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x1e,0x0,0x1b,0x0,0x3,0x0,0xe,0x0,0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,
-0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xe0,0x0,0x60,0x30,0x70,0x70,
-0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch199 = {12,18,-1,4,14,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0xc1,0xff,0xc1,0xff,0x61,0x80,0x61,0x80,0x7f,0x80,0x3f,0x80,0x31,0xfe,0x31,0xfe,
-0x19,0x80,0x19,0x80,0xd,0x80,0xd,0x80,0x7,0xff,0x7,0xff,
-};
-
-static const BitmapCharRec ch198 = {16,14,-1,0,18,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
-0x19,0x80,0xf,0x0,
-};
-
-static const BitmapCharRec ch197 = {12,18,0,0,12,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x19,0x80,
-0x19,0x80,
-};
-
-static const BitmapCharRec ch196 = {12,17,0,0,12,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x13,0x0,
-0x16,0x80,0xc,0x80,
-};
-
-static const BitmapCharRec ch195 = {12,18,0,0,12,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x19,0x80,
-0xf,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch194 = {12,18,0,0,12,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x6,0x0,
-0x3,0x0,0x1,0x80,
-};
-
-static const BitmapCharRec ch193 = {12,18,0,0,12,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x6,0x0,
-0xc,0x0,0x18,0x0,
-};
-
-static const BitmapCharRec ch192 = {12,18,0,0,12,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x7c,0xfe,0xc6,0xc6,0xe0,0x70,0x38,0x18,0x18,0x18,0x0,0x0,0x18,0x18,
-};
-
-static const BitmapCharRec ch191 = {7,14,-1,4,10,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x18,0x18,0x18,0x18,0xc,0xfc,0x6,0xd8,0x6,0x78,0x73,0x38,0xf9,0x18,0x99,0x88,
-0x30,0xc0,0x30,0xc0,0x98,0x60,0xf8,0x30,0x70,0x30,
-};
-
-static const BitmapCharRec ch190 = {14,13,0,0,15,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x30,0xf8,0x30,0xf8,0x18,0x60,0xc,0x30,0xc,0x18,0x66,0x98,0x62,0xf8,0x63,0x70,
-0x61,0x80,0x61,0x80,0xe0,0xc0,0xe0,0x60,0x60,0x60,
-};
-
-static const BitmapCharRec ch189 = {13,13,-1,0,15,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x30,0x30,0x30,0x30,0x19,0xf8,0xd,0xb0,0xc,0xf0,0x66,0x70,0x62,0x30,0x63,0x10,
-0x61,0x80,0x61,0x80,0xe0,0xc0,0xe0,0x60,0x60,0x60,
-};
-
-static const BitmapCharRec ch188 = {13,13,-1,0,15,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0x90,0xd8,0x6c,0x36,0x36,0x6c,0xd8,0x90,
-};
-
-static const BitmapCharRec ch187 = {7,8,-1,-1,9,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xf8,0x0,0x70,0xd8,0x88,0x88,0xd8,0x70,
-};
-
-static const BitmapCharRec ch186 = {5,8,-1,-6,7,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,
-};
-
-static const BitmapCharRec ch185 = {3,8,-1,-5,6,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xf0,0xd8,0x18,0x70,0x60,
-};
-
-static const BitmapCharRec ch184 = {5,5,0,4,5,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,2,-1,-4,4,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x32,0x72,0xf2,0xf2,0xf2,0xf2,
-0x72,0x3f,
-};
-
-static const BitmapCharRec ch182 = {8,18,-1,4,10,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0xc0,0xc0,0xc0,0xc0,0xdb,0xff,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch181 = {8,14,-1,4,10,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0xc0,0x60,0x30,
-};
-
-static const BitmapCharRec ch180 = {4,3,0,-11,4,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0x70,0xf8,0x98,0x30,0x30,0x98,0xf8,0x70,
-};
-
-static const BitmapCharRec ch179 = {5,8,0,-5,6,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xf8,0xf8,0x60,0x30,0x18,0x98,0xf8,0x70,
-};
-
-static const BitmapCharRec ch178 = {5,8,0,-5,6,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xff,0xff,0x0,0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,
-};
-
-static const BitmapCharRec ch177 = {8,11,-1,0,10,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x70,0xd8,0x88,0xd8,0x70,
-};
-
-static const BitmapCharRec ch176 = {5,5,-1,-8,7,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xf8,
-};
-
-static const BitmapCharRec ch175 = {5,1,0,-12,5,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0xf,0x80,0x30,0x60,0x40,0x10,0x48,0x50,0x88,0x88,0x89,0x8,0x8f,0x88,0x88,0x48,
-0x88,0x48,0x4f,0x90,0x40,0x10,0x30,0x60,0xf,0x80,
-};
-
-static const BitmapCharRec ch174 = {13,13,-1,0,14,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xf8,0xf8,
-};
-
-static const BitmapCharRec ch173 = {5,2,-1,-4,7,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x1,0x80,0x1,0x80,0x1,0x80,0xff,0x80,0xff,0x80,
-};
-
-static const BitmapCharRec ch172 = {9,5,-1,-3,11,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x12,0x36,0x6c,0xd8,0xd8,0x6c,0x36,0x12,
-};
-
-static const BitmapCharRec ch171 = {7,8,-1,-1,9,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xf8,0x0,0x68,0xd8,0x48,0x38,0xc8,0x70,
-};
-
-static const BitmapCharRec ch170 = {5,8,-1,-6,7,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0xf,0x80,0x30,0x60,0x40,0x10,0x47,0x10,0x88,0x88,0x90,0x8,0x90,0x8,0x90,0x8,
-0x88,0x88,0x47,0x10,0x40,0x10,0x30,0x60,0xf,0x80,
-};
-
-static const BitmapCharRec ch169 = {13,13,-1,0,15,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xd8,0xd8,
-};
-
-static const BitmapCharRec ch168 = {5,2,0,-11,6,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x3c,0x7e,0xc3,0xc3,0x7,0xe,0x3e,0x73,0xe3,0xc3,0xc7,0x6e,0x7c,0xf0,0xc3,0xc3,
-0x7e,0x3c,
-};
-
-static const BitmapCharRec ch167 = {8,18,-1,4,10,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0x0,0x0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch166 = {2,17,-1,3,4,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x18,0x18,0x18,0x18,0xff,0x18,0xff,0x3c,0x66,0x66,0x66,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch165 = {8,13,-1,0,10,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0xc3,0xff,0x66,0x66,0x66,0xff,0xc3,
-};
-
-static const BitmapCharRec ch164 = {8,7,-1,-3,10,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xdf,0x0,0xff,0x80,0x60,0x80,0x30,0x0,0x18,0x0,0x18,0x0,0x7e,0x0,0x30,0x0,
-0x60,0x0,0x61,0x80,0x61,0x80,0x3f,0x0,0x1e,0x0,
-};
-
-static const BitmapCharRec ch163 = {9,13,0,0,10,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x10,0x10,0x3e,0x7f,0x6b,0xc8,0xc8,0xc8,0xc8,0x6b,0x7f,0x3e,0x4,0x4,
-};
-
-static const BitmapCharRec ch162 = {8,14,-1,2,10,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x40,0x40,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch161 = {2,14,-2,4,6,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,5,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,5,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0xcc,0x7e,0x33,
-};
-
-static const BitmapCharRec ch126 = {8,3,-1,-4,10,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xc0,0x60,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0xc,0x18,0x30,0x30,0x30,0x30,0x30,
-0x60,0xc0,
-};
-
-static const BitmapCharRec ch125 = {6,18,0,4,6,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch124 = {2,18,-1,4,4,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0xc,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0xc0,0x60,0x30,0x30,0x30,0x30,0x30,
-0x18,0xc,
-};
-
-static const BitmapCharRec ch123 = {6,18,0,4,6,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xfe,0xfe,0xc0,0x60,0x30,0x18,0xc,0x6,0xfe,0xfe,
-};
-
-static const BitmapCharRec ch122 = {7,10,-1,0,9,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch121 = {8,14,-1,4,10,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0xc3,0xe7,0x66,0x3c,0x18,0x18,0x3c,0x66,0xe7,0xc3,
-};
-
-static const BitmapCharRec ch120 = {8,10,-1,0,10,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x19,0x80,0x19,0x80,0x39,0xc0,0x29,0x40,0x69,0x60,0x66,0x60,0x66,0x60,0xc6,0x30,
-0xc6,0x30,0xc6,0x30,
-};
-
-static const BitmapCharRec ch119 = {12,10,-1,0,14,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch118 = {8,10,-1,0,10,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch117 = {8,10,-1,0,10,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x18,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0xfc,0xfc,0x30,0x30,0x30,
-};
-
-static const BitmapCharRec ch116 = {6,13,0,0,6,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x78,0xfc,0xc6,0x6,0x3e,0xfc,0xc0,0xc6,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch115 = {7,10,-1,0,9,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xe0,0xd8,0xd8,
-};
-
-static const BitmapCharRec ch114 = {5,10,-1,0,6,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x80,0x7f,0x80,0x3d,0x80,
-};
-
-static const BitmapCharRec ch113 = {9,14,-1,4,11,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,0xff,0x0,0xde,0x0,
-};
-
-static const BitmapCharRec ch112 = {9,14,-1,4,11,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,
-};
-
-static const BitmapCharRec ch111 = {9,10,-1,0,11,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,
-};
-
-static const BitmapCharRec ch110 = {8,10,-1,0,10,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xe7,0x30,
-0xde,0xf0,0xcc,0x60,
-};
-
-static const BitmapCharRec ch109 = {12,10,-1,0,14,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch108 = {2,14,-1,0,4,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0xc7,0xc6,0xce,0xcc,0xd8,0xf8,0xf0,0xd8,0xcc,0xc6,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch107 = {8,14,-1,0,9,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0xe0,0xf0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0x0,
-0x30,0x30,
-};
-
-static const BitmapCharRec ch106 = {4,18,1,4,4,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch105 = {2,14,-1,0,4,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch104 = {8,14,-1,0,10,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x1c,0x0,0x7f,0x0,0x63,0x0,0x1,0x80,0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0x61,0x80,0x7f,0x80,0x3d,0x80,
-};
-
-static const BitmapCharRec ch103 = {9,14,-1,4,11,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xfc,0xfc,0x30,0x30,0x3c,0x1c,
-};
-
-static const BitmapCharRec ch102 = {6,14,0,0,6,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch101 = {8,10,-1,0,10,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x80,
-0x7f,0x80,0x3d,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,
-};
-
-static const BitmapCharRec ch100 = {9,14,-1,0,11,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x3e,0x7f,0x63,0xc0,0xc0,0xc0,0xc0,0x63,0x7f,0x3e,
-};
-
-static const BitmapCharRec ch99 = {8,10,-1,0,10,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,
-0xff,0x0,0xde,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-};
-
-static const BitmapCharRec ch98 = {9,14,-1,0,11,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,
-};
-
-static const BitmapCharRec ch97 = {7,10,-1,0,9,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0xc0,0xc0,0x80,0x80,0x40,
-};
-
-static const BitmapCharRec ch96 = {2,5,-1,-9,4,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xff,0xc0,0xff,0xc0,
-};
-
-static const BitmapCharRec ch95 = {10,2,0,4,10,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x82,0xc6,0x6c,0x38,0x10,
-};
-
-static const BitmapCharRec ch94 = {7,5,-1,-8,9,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xf0,0xf0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xf0,0xf0,
-};
-
-static const BitmapCharRec ch93 = {4,18,0,4,5,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x18,0x18,0x10,0x10,0x30,0x30,0x20,0x20,0x60,0x60,0x40,0x40,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch92 = {5,14,0,0,5,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xf0,0xf0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xf0,0xf0,
-};
-
-static const BitmapCharRec ch91 = {4,18,-1,4,5,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xff,0xc0,0xff,0xc0,0xc0,0x0,0x60,0x0,0x30,0x0,0x18,0x0,0x1c,0x0,0xc,0x0,
-0x6,0x0,0x3,0x0,0x1,0x80,0x0,0xc0,0xff,0xc0,0xff,0xc0,
-};
-
-static const BitmapCharRec ch90 = {10,14,-1,0,12,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
-0x30,0xc0,0x30,0xc0,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,
-};
-
-static const BitmapCharRec ch89 = {12,14,-1,0,14,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0xc0,0x60,0xe0,0xe0,0x60,0xc0,0x71,0xc0,0x31,0x80,0x1b,0x0,0xe,0x0,0xe,0x0,
-0x1b,0x0,0x31,0x80,0x71,0xc0,0x60,0xc0,0xe0,0xe0,0xc0,0x60,
-};
-
-static const BitmapCharRec ch88 = {11,14,-1,0,13,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x18,0x18,0x18,0x18,0x1c,0x38,0x34,0x2c,0x36,0x6c,0x36,0x6c,0x66,0x66,0x66,0x66,
-0x62,0x46,0x63,0xc6,0xc3,0xc3,0xc1,0x83,0xc1,0x83,0xc1,0x83,
-};
-
-static const BitmapCharRec ch87 = {16,14,-1,0,18,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x6,0x0,0xf,0x0,0xf,0x0,0x19,0x80,0x19,0x80,0x19,0x80,0x30,0xc0,0x30,0xc0,
-0x30,0xc0,0x60,0x60,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,
-};
-
-static const BitmapCharRec ch86 = {12,14,-1,0,14,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-};
-
-static const BitmapCharRec ch85 = {11,14,-1,0,13,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,
-0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xff,0xc0,0xff,0xc0,
-};
-
-static const BitmapCharRec ch84 = {10,14,-1,0,12,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x3f,0x0,0x7f,0xc0,0xe0,0xe0,0xc0,0x60,0x0,0x60,0x0,0xe0,0x3,0xc0,0x1f,0x0,
-0x7c,0x0,0xe0,0x0,0xc0,0x60,0xe0,0xe0,0x7f,0xc0,0x1f,0x0,
-};
-
-static const BitmapCharRec ch83 = {11,14,-1,0,13,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0x80,0xc1,0x80,0xff,0x0,0xff,0x80,
-0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
-};
-
-static const BitmapCharRec ch82 = {10,14,-1,0,12,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x0,0x30,0xf,0xb0,0x3f,0xe0,0x70,0xf0,0x61,0xb0,0xe1,0xb8,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch81 = {13,15,-1,1,15,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x80,
-0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
-};
-
-static const BitmapCharRec ch80 = {10,14,-1,0,12,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch79 = {13,14,-1,0,15,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0xc0,0x60,0xc0,0xe0,0xc1,0xe0,0xc1,0xe0,0xc3,0x60,0xc6,0x60,0xc6,0x60,0xcc,0x60,
-0xcc,0x60,0xd8,0x60,0xf0,0x60,0xf0,0x60,0xe0,0x60,0xc0,0x60,
-};
-
-static const BitmapCharRec ch78 = {11,14,-1,0,13,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0xc3,0xc,0xc3,0xc,0xc7,0x8c,0xc4,0x8c,0xcc,0xcc,0xcc,0xcc,0xd8,0x6c,0xd8,0x6c,
-0xf0,0x3c,0xf0,0x3c,0xe0,0x1c,0xe0,0x1c,0xc0,0xc,0xc0,0xc,
-};
-
-static const BitmapCharRec ch77 = {14,14,-1,0,16,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch76 = {8,14,-1,0,10,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0xc0,0x70,0xc0,0xe0,0xc1,0xc0,0xc3,0x80,0xc7,0x0,0xce,0x0,0xfc,0x0,0xf8,0x0,
-0xdc,0x0,0xce,0x0,0xc7,0x0,0xc3,0x80,0xc1,0xc0,0xc0,0xe0,
-};
-
-static const BitmapCharRec ch75 = {12,14,-1,0,13,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x3c,0x7e,0xe7,0xc3,0xc3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,
-};
-
-static const BitmapCharRec ch74 = {8,14,-1,0,10,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch73 = {2,14,-2,0,6,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xff,0xe0,0xff,0xe0,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-};
-
-static const BitmapCharRec ch72 = {11,14,-1,0,13,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0xf,0xb0,0x3f,0xf0,0x70,0x70,0x60,0x30,0xe0,0x30,0xc1,0xf0,0xc1,0xf0,0xc0,0x0,
-0xc0,0x0,0xe0,0x30,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch71 = {12,14,-1,0,14,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,
-};
-
-static const BitmapCharRec ch70 = {9,14,-1,0,11,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,
-};
-
-static const BitmapCharRec ch69 = {9,14,-1,0,11,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xff,0x0,0xff,0x80,0xc1,0xc0,0xc0,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
-};
-
-static const BitmapCharRec ch68 = {11,14,-1,0,13,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0xe0,0x0,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch67 = {12,14,-1,0,14,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xff,0x80,0xff,0xc0,0xc0,0xe0,0xc0,0x60,0xc0,0x60,0xc0,0xe0,0xff,0xc0,0xff,0x80,
-0xc1,0x80,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
-};
-
-static const BitmapCharRec ch66 = {11,14,-1,0,13,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch65 = {12,14,0,0,12,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x7,0xe0,0x1f,0xf0,0x38,0x0,0x70,0x0,0x67,0x70,0xcf,0xf8,0xcc,0xcc,0xcc,0x66,
-0xcc,0x66,0xcc,0x63,0xc6,0x33,0x67,0x73,0x63,0xb3,0x30,0x6,0x1c,0xe,0xf,0xfc,
-0x3,0xf0,
-};
-
-static const BitmapCharRec ch64 = {16,17,-1,3,18,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x30,0x30,0x0,0x0,0x30,0x30,0x30,0x38,0x1c,0xe,0xc6,0xc6,0xfe,0x7c,
-};
-
-static const BitmapCharRec ch63 = {7,14,-1,0,10,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0xc0,0xf0,0x3c,0xe,0x3,0xe,0x3c,0xf0,0xc0,
-};
-
-static const BitmapCharRec ch62 = {8,9,-1,0,10,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xfe,0xfe,0x0,0x0,0xfe,0xfe,
-};
-
-static const BitmapCharRec ch61 = {7,6,-2,-2,11,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x3,0xf,0x3c,0x70,0xc0,0x70,0x3c,0xf,0x3,
-};
-
-static const BitmapCharRec ch60 = {8,9,-1,0,10,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x40,0x40,0xc0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch59 = {2,13,-1,3,5,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0xc0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch58 = {2,10,-1,0,5,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x7c,0xfe,0xc6,0x3,0x3,0x3b,0x7f,0xc3,0xc3,0xc3,0xc7,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch57 = {8,13,-1,0,10,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x3c,0x7e,0xe7,0xc3,0xc3,0x66,0x7e,0x66,0xc3,0xc3,0xe7,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch56 = {8,13,-1,0,10,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x60,0x60,0x30,0x30,0x30,0x18,0x18,0xc,0xc,0x6,0x3,0xff,0xff,
-};
-
-static const BitmapCharRec ch55 = {8,13,-1,0,10,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x3c,0x7e,0xe3,0xc3,0xc3,0xc3,0xfe,0xdc,0xc0,0xc0,0x63,0x7f,0x3c,
-};
-
-static const BitmapCharRec ch54 = {8,13,-1,0,10,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x7c,0xfe,0xc7,0xc3,0x3,0x3,0xc7,0xfe,0xfc,0xc0,0xc0,0xfe,0xfe,
-};
-
-static const BitmapCharRec ch53 = {8,13,-1,0,10,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x3,0x0,0x3,0x0,0x3,0x0,0xff,0x80,0xff,0x80,0xc3,0x0,0x63,0x0,0x33,0x0,
-0x33,0x0,0x1b,0x0,0xf,0x0,0x7,0x0,0x3,0x0,
-};
-
-static const BitmapCharRec ch52 = {9,13,-1,0,10,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x3c,0x7e,0xc7,0xc3,0x3,0x7,0x1e,0x1c,0x6,0xc3,0xc3,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch51 = {8,13,-1,0,10,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xff,0xff,0xc0,0xe0,0x70,0x38,0x1c,0xe,0x7,0x3,0xc3,0xfe,0x3c,
-};
-
-static const BitmapCharRec ch50 = {8,13,-1,0,10,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0xf8,0x18,
-};
-
-static const BitmapCharRec ch49 = {5,13,-2,0,10,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x3c,0x7e,0x66,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch48 = {8,13,-1,0,10,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0xc0,0xc0,0x40,0x40,0x60,0x60,0x20,0x20,0x30,0x30,0x10,0x10,0x18,0x18,
-};
-
-static const BitmapCharRec ch47 = {5,14,0,0,5,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch46 = {2,2,-1,0,5,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xff,0xff,
-};
-
-static const BitmapCharRec ch45 = {8,2,-1,-4,11,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x40,0x40,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch44 = {2,5,-1,3,5,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x18,0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,0x18,
-};
-
-static const BitmapCharRec ch43 = {8,10,-1,0,10,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0x88,0x70,0x70,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch42 = {5,6,-1,-8,7,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0xc0,0x60,0x60,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0x60,
-0xc0,0x80,
-};
-
-static const BitmapCharRec ch41 = {4,18,-1,4,6,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x10,0x30,0x60,0x60,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x60,0x60,
-0x30,0x10,
-};
-
-static const BitmapCharRec ch40 = {4,18,-1,4,6,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x40,0x40,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch39 = {2,5,-1,-9,4,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x3c,0x70,0x7e,0xe0,0xe7,0xc0,0xc3,0x80,0xc3,0xc0,0xc6,0xc0,0xee,0xc0,0x7c,0x0,
-0x3c,0x0,0x66,0x0,0x66,0x0,0x7e,0x0,0x3c,0x0,
-};
-
-static const BitmapCharRec ch38 = {12,13,-1,0,13,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x18,0x78,0x18,0xfc,0xc,0xcc,0xc,0xcc,0x6,0xfc,0x6,0x78,0x3,0x0,0x7b,0x0,
-0xfd,0x80,0xcd,0x80,0xcc,0xc0,0xfc,0xc0,0x78,0x60,
-};
-
-static const BitmapCharRec ch37 = {14,13,-1,0,16,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x8,0x0,0x8,0x0,0x3e,0x0,0x7f,0x0,0xeb,0x80,0xc9,0x80,0x9,0x80,0xf,0x0,
-0x3e,0x0,0x78,0x0,0xe8,0x0,0xc8,0x0,0xcb,0x0,0x7f,0x0,0x3e,0x0,0x8,0x0,
-};
-
-static const BitmapCharRec ch36 = {9,16,-1,2,10,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x24,0x0,0x24,0x0,0x24,0x0,0xff,0x80,0xff,0x80,0x12,0x0,0x12,0x0,0x12,0x0,
-0x7f,0xc0,0x7f,0xc0,0x9,0x0,0x9,0x0,0x9,0x0,
-};
-
-static const BitmapCharRec ch35 = {10,13,0,0,10,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0x90,0x90,0xd8,0xd8,0xd8,
-};
-
-static const BitmapCharRec ch34 = {5,5,0,-9,5,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0xc0,0xc0,0x0,0x0,0x80,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch33 = {2,14,-2,0,6,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,5,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,5,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-const BitmapFontRec glutBitmapHelvetica18 = {
-"-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/beos/glut_mroman.c b/src/glut/beos/glut_mroman.c
deleted file mode 100644 (file)
index a29f043..0000000
+++ /dev/null
@@ -1,2451 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#include "glutstroke.h"
-
-/* char: 33 '!' */
-
-static const CoordRec char33_stroke0[] = {
-    { 52.381, 100 },
-    { 52.381, 33.3333 },
-};
-
-static const CoordRec char33_stroke1[] = {
-    { 52.381, 9.5238 },
-    { 47.6191, 4.7619 },
-    { 52.381, 0 },
-    { 57.1429, 4.7619 },
-    { 52.381, 9.5238 },
-};
-
-static const StrokeRec char33[] = {
-   { 2, char33_stroke0 },
-   { 5, char33_stroke1 },
-};
-
-/* char: 34 '"' */
-
-static const CoordRec char34_stroke0[] = {
-    { 33.3334, 100 },
-    { 33.3334, 66.6667 },
-};
-
-static const CoordRec char34_stroke1[] = {
-    { 71.4286, 100 },
-    { 71.4286, 66.6667 },
-};
-
-static const StrokeRec char34[] = {
-   { 2, char34_stroke0 },
-   { 2, char34_stroke1 },
-};
-
-/* char: 35 '#' */
-
-static const CoordRec char35_stroke0[] = {
-    { 54.7619, 119.048 },
-    { 21.4286, -33.3333 },
-};
-
-static const CoordRec char35_stroke1[] = {
-    { 83.3334, 119.048 },
-    { 50, -33.3333 },
-};
-
-static const CoordRec char35_stroke2[] = {
-    { 21.4286, 57.1429 },
-    { 88.0952, 57.1429 },
-};
-
-static const CoordRec char35_stroke3[] = {
-    { 16.6667, 28.5714 },
-    { 83.3334, 28.5714 },
-};
-
-static const StrokeRec char35[] = {
-   { 2, char35_stroke0 },
-   { 2, char35_stroke1 },
-   { 2, char35_stroke2 },
-   { 2, char35_stroke3 },
-};
-
-/* char: 36 '$' */
-
-static const CoordRec char36_stroke0[] = {
-    { 42.8571, 119.048 },
-    { 42.8571, -19.0476 },
-};
-
-static const CoordRec char36_stroke1[] = {
-    { 61.9047, 119.048 },
-    { 61.9047, -19.0476 },
-};
-
-static const CoordRec char36_stroke2[] = {
-    { 85.7143, 85.7143 },
-    { 76.1905, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-    { 28.5714, 95.2381 },
-    { 19.0476, 85.7143 },
-    { 19.0476, 76.1905 },
-    { 23.8095, 66.6667 },
-    { 28.5714, 61.9048 },
-    { 38.0952, 57.1429 },
-    { 66.6666, 47.619 },
-    { 76.1905, 42.8571 },
-    { 80.9524, 38.0952 },
-    { 85.7143, 28.5714 },
-    { 85.7143, 14.2857 },
-    { 76.1905, 4.7619 },
-    { 61.9047, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 19.0476, 14.2857 },
-};
-
-static const StrokeRec char36[] = {
-   { 2, char36_stroke0 },
-   { 2, char36_stroke1 },
-   { 20, char36_stroke2 },
-};
-
-/* char: 37 '%' */
-
-static const CoordRec char37_stroke0[] = {
-    { 95.2381, 100 },
-    { 9.5238, 0 },
-};
-
-static const CoordRec char37_stroke1[] = {
-    { 33.3333, 100 },
-    { 42.8571, 90.4762 },
-    { 42.8571, 80.9524 },
-    { 38.0952, 71.4286 },
-    { 28.5714, 66.6667 },
-    { 19.0476, 66.6667 },
-    { 9.5238, 76.1905 },
-    { 9.5238, 85.7143 },
-    { 14.2857, 95.2381 },
-    { 23.8095, 100 },
-    { 33.3333, 100 },
-    { 42.8571, 95.2381 },
-    { 57.1428, 90.4762 },
-    { 71.4286, 90.4762 },
-    { 85.7143, 95.2381 },
-    { 95.2381, 100 },
-};
-
-static const CoordRec char37_stroke2[] = {
-    { 76.1905, 33.3333 },
-    { 66.6667, 28.5714 },
-    { 61.9048, 19.0476 },
-    { 61.9048, 9.5238 },
-    { 71.4286, 0 },
-    { 80.9524, 0 },
-    { 90.4762, 4.7619 },
-    { 95.2381, 14.2857 },
-    { 95.2381, 23.8095 },
-    { 85.7143, 33.3333 },
-    { 76.1905, 33.3333 },
-};
-
-static const StrokeRec char37[] = {
-   { 2, char37_stroke0 },
-   { 16, char37_stroke1 },
-   { 11, char37_stroke2 },
-};
-
-/* char: 38 '&' */
-
-static const CoordRec char38_stroke0[] = {
-    { 100, 57.1429 },
-    { 100, 61.9048 },
-    { 95.2381, 66.6667 },
-    { 90.4762, 66.6667 },
-    { 85.7143, 61.9048 },
-    { 80.9524, 52.381 },
-    { 71.4286, 28.5714 },
-    { 61.9048, 14.2857 },
-    { 52.3809, 4.7619 },
-    { 42.8571, 0 },
-    { 23.8095, 0 },
-    { 14.2857, 4.7619 },
-    { 9.5238, 9.5238 },
-    { 4.7619, 19.0476 },
-    { 4.7619, 28.5714 },
-    { 9.5238, 38.0952 },
-    { 14.2857, 42.8571 },
-    { 47.619, 61.9048 },
-    { 52.3809, 66.6667 },
-    { 57.1429, 76.1905 },
-    { 57.1429, 85.7143 },
-    { 52.3809, 95.2381 },
-    { 42.8571, 100 },
-    { 33.3333, 95.2381 },
-    { 28.5714, 85.7143 },
-    { 28.5714, 76.1905 },
-    { 33.3333, 61.9048 },
-    { 42.8571, 47.619 },
-    { 66.6667, 14.2857 },
-    { 76.1905, 4.7619 },
-    { 85.7143, 0 },
-    { 95.2381, 0 },
-    { 100, 4.7619 },
-    { 100, 9.5238 },
-};
-
-static const StrokeRec char38[] = {
-   { 34, char38_stroke0 },
-};
-
-/* char: 39 ''' */
-
-static const CoordRec char39_stroke0[] = {
-    { 52.381, 100 },
-    { 52.381, 66.6667 },
-};
-
-static const StrokeRec char39[] = {
-   { 2, char39_stroke0 },
-};
-
-/* char: 40 '(' */
-
-static const CoordRec char40_stroke0[] = {
-    { 69.0476, 119.048 },
-    { 59.5238, 109.524 },
-    { 50, 95.2381 },
-    { 40.4762, 76.1905 },
-    { 35.7143, 52.381 },
-    { 35.7143, 33.3333 },
-    { 40.4762, 9.5238 },
-    { 50, -9.5238 },
-    { 59.5238, -23.8095 },
-    { 69.0476, -33.3333 },
-};
-
-static const StrokeRec char40[] = {
-   { 10, char40_stroke0 },
-};
-
-/* char: 41 ')' */
-
-static const CoordRec char41_stroke0[] = {
-    { 35.7143, 119.048 },
-    { 45.2381, 109.524 },
-    { 54.7619, 95.2381 },
-    { 64.2857, 76.1905 },
-    { 69.0476, 52.381 },
-    { 69.0476, 33.3333 },
-    { 64.2857, 9.5238 },
-    { 54.7619, -9.5238 },
-    { 45.2381, -23.8095 },
-    { 35.7143, -33.3333 },
-};
-
-static const StrokeRec char41[] = {
-   { 10, char41_stroke0 },
-};
-
-/* char: 42 '*' */
-
-static const CoordRec char42_stroke0[] = {
-    { 52.381, 71.4286 },
-    { 52.381, 14.2857 },
-};
-
-static const CoordRec char42_stroke1[] = {
-    { 28.5715, 57.1429 },
-    { 76.1905, 28.5714 },
-};
-
-static const CoordRec char42_stroke2[] = {
-    { 76.1905, 57.1429 },
-    { 28.5715, 28.5714 },
-};
-
-static const StrokeRec char42[] = {
-   { 2, char42_stroke0 },
-   { 2, char42_stroke1 },
-   { 2, char42_stroke2 },
-};
-
-/* char: 43 '+' */
-
-static const CoordRec char43_stroke0[] = {
-    { 52.3809, 85.7143 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char43_stroke1[] = {
-    { 9.5238, 42.8571 },
-    { 95.2381, 42.8571 },
-};
-
-static const StrokeRec char43[] = {
-   { 2, char43_stroke0 },
-   { 2, char43_stroke1 },
-};
-
-/* char: 44 ',' */
-
-static const CoordRec char44_stroke0[] = {
-    { 57.1429, 4.7619 },
-    { 52.381, 0 },
-    { 47.6191, 4.7619 },
-    { 52.381, 9.5238 },
-    { 57.1429, 4.7619 },
-    { 57.1429, -4.7619 },
-    { 52.381, -14.2857 },
-    { 47.6191, -19.0476 },
-};
-
-static const StrokeRec char44[] = {
-   { 8, char44_stroke0 },
-};
-
-/* char: 45 '-' */
-
-static const CoordRec char45_stroke0[] = {
-    { 9.5238, 42.8571 },
-    { 95.2381, 42.8571 },
-};
-
-static const StrokeRec char45[] = {
-   { 2, char45_stroke0 },
-};
-
-/* char: 46 '.' */
-
-static const CoordRec char46_stroke0[] = {
-    { 52.381, 9.5238 },
-    { 47.6191, 4.7619 },
-    { 52.381, 0 },
-    { 57.1429, 4.7619 },
-    { 52.381, 9.5238 },
-};
-
-static const StrokeRec char46[] = {
-   { 5, char46_stroke0 },
-};
-
-/* char: 47 '/' */
-
-static const CoordRec char47_stroke0[] = {
-    { 19.0476, -14.2857 },
-    { 85.7143, 100 },
-};
-
-static const StrokeRec char47[] = {
-   { 2, char47_stroke0 },
-};
-
-/* char: 48 '0' */
-
-static const CoordRec char48_stroke0[] = {
-    { 47.619, 100 },
-    { 33.3333, 95.2381 },
-    { 23.8095, 80.9524 },
-    { 19.0476, 57.1429 },
-    { 19.0476, 42.8571 },
-    { 23.8095, 19.0476 },
-    { 33.3333, 4.7619 },
-    { 47.619, 0 },
-    { 57.1428, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 19.0476 },
-    { 85.7143, 42.8571 },
-    { 85.7143, 57.1429 },
-    { 80.9524, 80.9524 },
-    { 71.4286, 95.2381 },
-    { 57.1428, 100 },
-    { 47.619, 100 },
-};
-
-static const StrokeRec char48[] = {
-   { 17, char48_stroke0 },
-};
-
-/* char: 49 '1' */
-
-static const CoordRec char49_stroke0[] = {
-    { 40.4762, 80.9524 },
-    { 50, 85.7143 },
-    { 64.2857, 100 },
-    { 64.2857, 0 },
-};
-
-static const StrokeRec char49[] = {
-   { 4, char49_stroke0 },
-};
-
-/* char: 50 '2' */
-
-static const CoordRec char50_stroke0[] = {
-    { 23.8095, 76.1905 },
-    { 23.8095, 80.9524 },
-    { 28.5714, 90.4762 },
-    { 33.3333, 95.2381 },
-    { 42.8571, 100 },
-    { 61.9047, 100 },
-    { 71.4286, 95.2381 },
-    { 76.1905, 90.4762 },
-    { 80.9524, 80.9524 },
-    { 80.9524, 71.4286 },
-    { 76.1905, 61.9048 },
-    { 66.6666, 47.619 },
-    { 19.0476, 0 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char50[] = {
-   { 14, char50_stroke0 },
-};
-
-/* char: 51 '3' */
-
-static const CoordRec char51_stroke0[] = {
-    { 28.5714, 100 },
-    { 80.9524, 100 },
-    { 52.3809, 61.9048 },
-    { 66.6666, 61.9048 },
-    { 76.1905, 57.1429 },
-    { 80.9524, 52.381 },
-    { 85.7143, 38.0952 },
-    { 85.7143, 28.5714 },
-    { 80.9524, 14.2857 },
-    { 71.4286, 4.7619 },
-    { 57.1428, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 23.8095, 9.5238 },
-    { 19.0476, 19.0476 },
-};
-
-static const StrokeRec char51[] = {
-   { 15, char51_stroke0 },
-};
-
-/* char: 52 '4' */
-
-static const CoordRec char52_stroke0[] = {
-    { 64.2857, 100 },
-    { 16.6667, 33.3333 },
-    { 88.0952, 33.3333 },
-};
-
-static const CoordRec char52_stroke1[] = {
-    { 64.2857, 100 },
-    { 64.2857, 0 },
-};
-
-static const StrokeRec char52[] = {
-   { 3, char52_stroke0 },
-   { 2, char52_stroke1 },
-};
-
-/* char: 53 '5' */
-
-static const CoordRec char53_stroke0[] = {
-    { 76.1905, 100 },
-    { 28.5714, 100 },
-    { 23.8095, 57.1429 },
-    { 28.5714, 61.9048 },
-    { 42.8571, 66.6667 },
-    { 57.1428, 66.6667 },
-    { 71.4286, 61.9048 },
-    { 80.9524, 52.381 },
-    { 85.7143, 38.0952 },
-    { 85.7143, 28.5714 },
-    { 80.9524, 14.2857 },
-    { 71.4286, 4.7619 },
-    { 57.1428, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 23.8095, 9.5238 },
-    { 19.0476, 19.0476 },
-};
-
-static const StrokeRec char53[] = {
-   { 17, char53_stroke0 },
-};
-
-/* char: 54 '6' */
-
-static const CoordRec char54_stroke0[] = {
-    { 78.5714, 85.7143 },
-    { 73.8096, 95.2381 },
-    { 59.5238, 100 },
-    { 50, 100 },
-    { 35.7143, 95.2381 },
-    { 26.1905, 80.9524 },
-    { 21.4286, 57.1429 },
-    { 21.4286, 33.3333 },
-    { 26.1905, 14.2857 },
-    { 35.7143, 4.7619 },
-    { 50, 0 },
-    { 54.7619, 0 },
-    { 69.0476, 4.7619 },
-    { 78.5714, 14.2857 },
-    { 83.3334, 28.5714 },
-    { 83.3334, 33.3333 },
-    { 78.5714, 47.619 },
-    { 69.0476, 57.1429 },
-    { 54.7619, 61.9048 },
-    { 50, 61.9048 },
-    { 35.7143, 57.1429 },
-    { 26.1905, 47.619 },
-    { 21.4286, 33.3333 },
-};
-
-static const StrokeRec char54[] = {
-   { 23, char54_stroke0 },
-};
-
-/* char: 55 '7' */
-
-static const CoordRec char55_stroke0[] = {
-    { 85.7143, 100 },
-    { 38.0952, 0 },
-};
-
-static const CoordRec char55_stroke1[] = {
-    { 19.0476, 100 },
-    { 85.7143, 100 },
-};
-
-static const StrokeRec char55[] = {
-   { 2, char55_stroke0 },
-   { 2, char55_stroke1 },
-};
-
-/* char: 56 '8' */
-
-static const CoordRec char56_stroke0[] = {
-    { 42.8571, 100 },
-    { 28.5714, 95.2381 },
-    { 23.8095, 85.7143 },
-    { 23.8095, 76.1905 },
-    { 28.5714, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 57.1428, 57.1429 },
-    { 71.4286, 52.381 },
-    { 80.9524, 42.8571 },
-    { 85.7143, 33.3333 },
-    { 85.7143, 19.0476 },
-    { 80.9524, 9.5238 },
-    { 76.1905, 4.7619 },
-    { 61.9047, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 23.8095, 9.5238 },
-    { 19.0476, 19.0476 },
-    { 19.0476, 33.3333 },
-    { 23.8095, 42.8571 },
-    { 33.3333, 52.381 },
-    { 47.619, 57.1429 },
-    { 66.6666, 61.9048 },
-    { 76.1905, 66.6667 },
-    { 80.9524, 76.1905 },
-    { 80.9524, 85.7143 },
-    { 76.1905, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-};
-
-static const StrokeRec char56[] = {
-   { 29, char56_stroke0 },
-};
-
-/* char: 57 '9' */
-
-static const CoordRec char57_stroke0[] = {
-    { 83.3334, 66.6667 },
-    { 78.5714, 52.381 },
-    { 69.0476, 42.8571 },
-    { 54.7619, 38.0952 },
-    { 50, 38.0952 },
-    { 35.7143, 42.8571 },
-    { 26.1905, 52.381 },
-    { 21.4286, 66.6667 },
-    { 21.4286, 71.4286 },
-    { 26.1905, 85.7143 },
-    { 35.7143, 95.2381 },
-    { 50, 100 },
-    { 54.7619, 100 },
-    { 69.0476, 95.2381 },
-    { 78.5714, 85.7143 },
-    { 83.3334, 66.6667 },
-    { 83.3334, 42.8571 },
-    { 78.5714, 19.0476 },
-    { 69.0476, 4.7619 },
-    { 54.7619, 0 },
-    { 45.2381, 0 },
-    { 30.9524, 4.7619 },
-    { 26.1905, 14.2857 },
-};
-
-static const StrokeRec char57[] = {
-   { 23, char57_stroke0 },
-};
-
-/* char: 58 ':' */
-
-static const CoordRec char58_stroke0[] = {
-    { 52.381, 66.6667 },
-    { 47.6191, 61.9048 },
-    { 52.381, 57.1429 },
-    { 57.1429, 61.9048 },
-    { 52.381, 66.6667 },
-};
-
-static const CoordRec char58_stroke1[] = {
-    { 52.381, 9.5238 },
-    { 47.6191, 4.7619 },
-    { 52.381, 0 },
-    { 57.1429, 4.7619 },
-    { 52.381, 9.5238 },
-};
-
-static const StrokeRec char58[] = {
-   { 5, char58_stroke0 },
-   { 5, char58_stroke1 },
-};
-
-/* char: 59 ';' */
-
-static const CoordRec char59_stroke0[] = {
-    { 52.381, 66.6667 },
-    { 47.6191, 61.9048 },
-    { 52.381, 57.1429 },
-    { 57.1429, 61.9048 },
-    { 52.381, 66.6667 },
-};
-
-static const CoordRec char59_stroke1[] = {
-    { 57.1429, 4.7619 },
-    { 52.381, 0 },
-    { 47.6191, 4.7619 },
-    { 52.381, 9.5238 },
-    { 57.1429, 4.7619 },
-    { 57.1429, -4.7619 },
-    { 52.381, -14.2857 },
-    { 47.6191, -19.0476 },
-};
-
-static const StrokeRec char59[] = {
-   { 5, char59_stroke0 },
-   { 8, char59_stroke1 },
-};
-
-/* char: 60 '<' */
-
-static const CoordRec char60_stroke0[] = {
-    { 90.4762, 85.7143 },
-    { 14.2857, 42.8571 },
-    { 90.4762, 0 },
-};
-
-static const StrokeRec char60[] = {
-   { 3, char60_stroke0 },
-};
-
-/* char: 61 '=' */
-
-static const CoordRec char61_stroke0[] = {
-    { 9.5238, 57.1429 },
-    { 95.2381, 57.1429 },
-};
-
-static const CoordRec char61_stroke1[] = {
-    { 9.5238, 28.5714 },
-    { 95.2381, 28.5714 },
-};
-
-static const StrokeRec char61[] = {
-   { 2, char61_stroke0 },
-   { 2, char61_stroke1 },
-};
-
-/* char: 62 '>' */
-
-static const CoordRec char62_stroke0[] = {
-    { 14.2857, 85.7143 },
-    { 90.4762, 42.8571 },
-    { 14.2857, 0 },
-};
-
-static const StrokeRec char62[] = {
-   { 3, char62_stroke0 },
-};
-
-/* char: 63 '?' */
-
-static const CoordRec char63_stroke0[] = {
-    { 23.8095, 76.1905 },
-    { 23.8095, 80.9524 },
-    { 28.5714, 90.4762 },
-    { 33.3333, 95.2381 },
-    { 42.8571, 100 },
-    { 61.9047, 100 },
-    { 71.4285, 95.2381 },
-    { 76.1905, 90.4762 },
-    { 80.9524, 80.9524 },
-    { 80.9524, 71.4286 },
-    { 76.1905, 61.9048 },
-    { 71.4285, 57.1429 },
-    { 52.3809, 47.619 },
-    { 52.3809, 33.3333 },
-};
-
-static const CoordRec char63_stroke1[] = {
-    { 52.3809, 9.5238 },
-    { 47.619, 4.7619 },
-    { 52.3809, 0 },
-    { 57.1428, 4.7619 },
-    { 52.3809, 9.5238 },
-};
-
-static const StrokeRec char63[] = {
-   { 14, char63_stroke0 },
-   { 5, char63_stroke1 },
-};
-
-/* char: 64 '@' */
-
-static const CoordRec char64_stroke0[] = {
-    { 64.2857, 52.381 },
-    { 54.7619, 57.1429 },
-    { 45.2381, 57.1429 },
-    { 40.4762, 47.619 },
-    { 40.4762, 42.8571 },
-    { 45.2381, 33.3333 },
-    { 54.7619, 33.3333 },
-    { 64.2857, 38.0952 },
-};
-
-static const CoordRec char64_stroke1[] = {
-    { 64.2857, 57.1429 },
-    { 64.2857, 38.0952 },
-    { 69.0476, 33.3333 },
-    { 78.5714, 33.3333 },
-    { 83.3334, 42.8571 },
-    { 83.3334, 47.619 },
-    { 78.5714, 61.9048 },
-    { 69.0476, 71.4286 },
-    { 54.7619, 76.1905 },
-    { 50, 76.1905 },
-    { 35.7143, 71.4286 },
-    { 26.1905, 61.9048 },
-    { 21.4286, 47.619 },
-    { 21.4286, 42.8571 },
-    { 26.1905, 28.5714 },
-    { 35.7143, 19.0476 },
-    { 50, 14.2857 },
-    { 54.7619, 14.2857 },
-    { 69.0476, 19.0476 },
-};
-
-static const StrokeRec char64[] = {
-   { 8, char64_stroke0 },
-   { 19, char64_stroke1 },
-};
-
-/* char: 65 'A' */
-
-static const CoordRec char65_stroke0[] = {
-    { 52.3809, 100 },
-    { 14.2857, 0 },
-};
-
-static const CoordRec char65_stroke1[] = {
-    { 52.3809, 100 },
-    { 90.4762, 0 },
-};
-
-static const CoordRec char65_stroke2[] = {
-    { 28.5714, 33.3333 },
-    { 76.1905, 33.3333 },
-};
-
-static const StrokeRec char65[] = {
-   { 2, char65_stroke0 },
-   { 2, char65_stroke1 },
-   { 2, char65_stroke2 },
-};
-
-/* char: 66 'B' */
-
-static const CoordRec char66_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char66_stroke1[] = {
-    { 19.0476, 100 },
-    { 61.9047, 100 },
-    { 76.1905, 95.2381 },
-    { 80.9524, 90.4762 },
-    { 85.7143, 80.9524 },
-    { 85.7143, 71.4286 },
-    { 80.9524, 61.9048 },
-    { 76.1905, 57.1429 },
-    { 61.9047, 52.381 },
-};
-
-static const CoordRec char66_stroke2[] = {
-    { 19.0476, 52.381 },
-    { 61.9047, 52.381 },
-    { 76.1905, 47.619 },
-    { 80.9524, 42.8571 },
-    { 85.7143, 33.3333 },
-    { 85.7143, 19.0476 },
-    { 80.9524, 9.5238 },
-    { 76.1905, 4.7619 },
-    { 61.9047, 0 },
-    { 19.0476, 0 },
-};
-
-static const StrokeRec char66[] = {
-   { 2, char66_stroke0 },
-   { 9, char66_stroke1 },
-   { 10, char66_stroke2 },
-};
-
-/* char: 67 'C' */
-
-static const CoordRec char67_stroke0[] = {
-    { 88.0952, 76.1905 },
-    { 83.3334, 85.7143 },
-    { 73.8096, 95.2381 },
-    { 64.2857, 100 },
-    { 45.2381, 100 },
-    { 35.7143, 95.2381 },
-    { 26.1905, 85.7143 },
-    { 21.4286, 76.1905 },
-    { 16.6667, 61.9048 },
-    { 16.6667, 38.0952 },
-    { 21.4286, 23.8095 },
-    { 26.1905, 14.2857 },
-    { 35.7143, 4.7619 },
-    { 45.2381, 0 },
-    { 64.2857, 0 },
-    { 73.8096, 4.7619 },
-    { 83.3334, 14.2857 },
-    { 88.0952, 23.8095 },
-};
-
-static const StrokeRec char67[] = {
-   { 18, char67_stroke0 },
-};
-
-/* char: 68 'D' */
-
-static const CoordRec char68_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char68_stroke1[] = {
-    { 19.0476, 100 },
-    { 52.3809, 100 },
-    { 66.6666, 95.2381 },
-    { 76.1905, 85.7143 },
-    { 80.9524, 76.1905 },
-    { 85.7143, 61.9048 },
-    { 85.7143, 38.0952 },
-    { 80.9524, 23.8095 },
-    { 76.1905, 14.2857 },
-    { 66.6666, 4.7619 },
-    { 52.3809, 0 },
-    { 19.0476, 0 },
-};
-
-static const StrokeRec char68[] = {
-   { 2, char68_stroke0 },
-   { 12, char68_stroke1 },
-};
-
-/* char: 69 'E' */
-
-static const CoordRec char69_stroke0[] = {
-    { 21.4286, 100 },
-    { 21.4286, 0 },
-};
-
-static const CoordRec char69_stroke1[] = {
-    { 21.4286, 100 },
-    { 83.3334, 100 },
-};
-
-static const CoordRec char69_stroke2[] = {
-    { 21.4286, 52.381 },
-    { 59.5238, 52.381 },
-};
-
-static const CoordRec char69_stroke3[] = {
-    { 21.4286, 0 },
-    { 83.3334, 0 },
-};
-
-static const StrokeRec char69[] = {
-   { 2, char69_stroke0 },
-   { 2, char69_stroke1 },
-   { 2, char69_stroke2 },
-   { 2, char69_stroke3 },
-};
-
-/* char: 70 'F' */
-
-static const CoordRec char70_stroke0[] = {
-    { 21.4286, 100 },
-    { 21.4286, 0 },
-};
-
-static const CoordRec char70_stroke1[] = {
-    { 21.4286, 100 },
-    { 83.3334, 100 },
-};
-
-static const CoordRec char70_stroke2[] = {
-    { 21.4286, 52.381 },
-    { 59.5238, 52.381 },
-};
-
-static const StrokeRec char70[] = {
-   { 2, char70_stroke0 },
-   { 2, char70_stroke1 },
-   { 2, char70_stroke2 },
-};
-
-/* char: 71 'G' */
-
-static const CoordRec char71_stroke0[] = {
-    { 88.0952, 76.1905 },
-    { 83.3334, 85.7143 },
-    { 73.8096, 95.2381 },
-    { 64.2857, 100 },
-    { 45.2381, 100 },
-    { 35.7143, 95.2381 },
-    { 26.1905, 85.7143 },
-    { 21.4286, 76.1905 },
-    { 16.6667, 61.9048 },
-    { 16.6667, 38.0952 },
-    { 21.4286, 23.8095 },
-    { 26.1905, 14.2857 },
-    { 35.7143, 4.7619 },
-    { 45.2381, 0 },
-    { 64.2857, 0 },
-    { 73.8096, 4.7619 },
-    { 83.3334, 14.2857 },
-    { 88.0952, 23.8095 },
-    { 88.0952, 38.0952 },
-};
-
-static const CoordRec char71_stroke1[] = {
-    { 64.2857, 38.0952 },
-    { 88.0952, 38.0952 },
-};
-
-static const StrokeRec char71[] = {
-   { 19, char71_stroke0 },
-   { 2, char71_stroke1 },
-};
-
-/* char: 72 'H' */
-
-static const CoordRec char72_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char72_stroke1[] = {
-    { 85.7143, 100 },
-    { 85.7143, 0 },
-};
-
-static const CoordRec char72_stroke2[] = {
-    { 19.0476, 52.381 },
-    { 85.7143, 52.381 },
-};
-
-static const StrokeRec char72[] = {
-   { 2, char72_stroke0 },
-   { 2, char72_stroke1 },
-   { 2, char72_stroke2 },
-};
-
-/* char: 73 'I' */
-
-static const CoordRec char73_stroke0[] = {
-    { 52.381, 100 },
-    { 52.381, 0 },
-};
-
-static const StrokeRec char73[] = {
-   { 2, char73_stroke0 },
-};
-
-/* char: 74 'J' */
-
-static const CoordRec char74_stroke0[] = {
-    { 76.1905, 100 },
-    { 76.1905, 23.8095 },
-    { 71.4286, 9.5238 },
-    { 66.6667, 4.7619 },
-    { 57.1429, 0 },
-    { 47.6191, 0 },
-    { 38.0953, 4.7619 },
-    { 33.3334, 9.5238 },
-    { 28.5715, 23.8095 },
-    { 28.5715, 33.3333 },
-};
-
-static const StrokeRec char74[] = {
-   { 10, char74_stroke0 },
-};
-
-/* char: 75 'K' */
-
-static const CoordRec char75_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char75_stroke1[] = {
-    { 85.7143, 100 },
-    { 19.0476, 33.3333 },
-};
-
-static const CoordRec char75_stroke2[] = {
-    { 42.8571, 57.1429 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char75[] = {
-   { 2, char75_stroke0 },
-   { 2, char75_stroke1 },
-   { 2, char75_stroke2 },
-};
-
-/* char: 76 'L' */
-
-static const CoordRec char76_stroke0[] = {
-    { 23.8095, 100 },
-    { 23.8095, 0 },
-};
-
-static const CoordRec char76_stroke1[] = {
-    { 23.8095, 0 },
-    { 80.9524, 0 },
-};
-
-static const StrokeRec char76[] = {
-   { 2, char76_stroke0 },
-   { 2, char76_stroke1 },
-};
-
-/* char: 77 'M' */
-
-static const CoordRec char77_stroke0[] = {
-    { 14.2857, 100 },
-    { 14.2857, 0 },
-};
-
-static const CoordRec char77_stroke1[] = {
-    { 14.2857, 100 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char77_stroke2[] = {
-    { 90.4762, 100 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char77_stroke3[] = {
-    { 90.4762, 100 },
-    { 90.4762, 0 },
-};
-
-static const StrokeRec char77[] = {
-   { 2, char77_stroke0 },
-   { 2, char77_stroke1 },
-   { 2, char77_stroke2 },
-   { 2, char77_stroke3 },
-};
-
-/* char: 78 'N' */
-
-static const CoordRec char78_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char78_stroke1[] = {
-    { 19.0476, 100 },
-    { 85.7143, 0 },
-};
-
-static const CoordRec char78_stroke2[] = {
-    { 85.7143, 100 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char78[] = {
-   { 2, char78_stroke0 },
-   { 2, char78_stroke1 },
-   { 2, char78_stroke2 },
-};
-
-/* char: 79 'O' */
-
-static const CoordRec char79_stroke0[] = {
-    { 42.8571, 100 },
-    { 33.3333, 95.2381 },
-    { 23.8095, 85.7143 },
-    { 19.0476, 76.1905 },
-    { 14.2857, 61.9048 },
-    { 14.2857, 38.0952 },
-    { 19.0476, 23.8095 },
-    { 23.8095, 14.2857 },
-    { 33.3333, 4.7619 },
-    { 42.8571, 0 },
-    { 61.9047, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 14.2857 },
-    { 85.7143, 23.8095 },
-    { 90.4762, 38.0952 },
-    { 90.4762, 61.9048 },
-    { 85.7143, 76.1905 },
-    { 80.9524, 85.7143 },
-    { 71.4286, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-};
-
-static const StrokeRec char79[] = {
-   { 21, char79_stroke0 },
-};
-
-/* char: 80 'P' */
-
-static const CoordRec char80_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char80_stroke1[] = {
-    { 19.0476, 100 },
-    { 61.9047, 100 },
-    { 76.1905, 95.2381 },
-    { 80.9524, 90.4762 },
-    { 85.7143, 80.9524 },
-    { 85.7143, 66.6667 },
-    { 80.9524, 57.1429 },
-    { 76.1905, 52.381 },
-    { 61.9047, 47.619 },
-    { 19.0476, 47.619 },
-};
-
-static const StrokeRec char80[] = {
-   { 2, char80_stroke0 },
-   { 10, char80_stroke1 },
-};
-
-/* char: 81 'Q' */
-
-static const CoordRec char81_stroke0[] = {
-    { 42.8571, 100 },
-    { 33.3333, 95.2381 },
-    { 23.8095, 85.7143 },
-    { 19.0476, 76.1905 },
-    { 14.2857, 61.9048 },
-    { 14.2857, 38.0952 },
-    { 19.0476, 23.8095 },
-    { 23.8095, 14.2857 },
-    { 33.3333, 4.7619 },
-    { 42.8571, 0 },
-    { 61.9047, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 14.2857 },
-    { 85.7143, 23.8095 },
-    { 90.4762, 38.0952 },
-    { 90.4762, 61.9048 },
-    { 85.7143, 76.1905 },
-    { 80.9524, 85.7143 },
-    { 71.4286, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-};
-
-static const CoordRec char81_stroke1[] = {
-    { 57.1428, 19.0476 },
-    { 85.7143, -9.5238 },
-};
-
-static const StrokeRec char81[] = {
-   { 21, char81_stroke0 },
-   { 2, char81_stroke1 },
-};
-
-/* char: 82 'R' */
-
-static const CoordRec char82_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char82_stroke1[] = {
-    { 19.0476, 100 },
-    { 61.9047, 100 },
-    { 76.1905, 95.2381 },
-    { 80.9524, 90.4762 },
-    { 85.7143, 80.9524 },
-    { 85.7143, 71.4286 },
-    { 80.9524, 61.9048 },
-    { 76.1905, 57.1429 },
-    { 61.9047, 52.381 },
-    { 19.0476, 52.381 },
-};
-
-static const CoordRec char82_stroke2[] = {
-    { 52.3809, 52.381 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char82[] = {
-   { 2, char82_stroke0 },
-   { 10, char82_stroke1 },
-   { 2, char82_stroke2 },
-};
-
-/* char: 83 'S' */
-
-static const CoordRec char83_stroke0[] = {
-    { 85.7143, 85.7143 },
-    { 76.1905, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-    { 28.5714, 95.2381 },
-    { 19.0476, 85.7143 },
-    { 19.0476, 76.1905 },
-    { 23.8095, 66.6667 },
-    { 28.5714, 61.9048 },
-    { 38.0952, 57.1429 },
-    { 66.6666, 47.619 },
-    { 76.1905, 42.8571 },
-    { 80.9524, 38.0952 },
-    { 85.7143, 28.5714 },
-    { 85.7143, 14.2857 },
-    { 76.1905, 4.7619 },
-    { 61.9047, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 19.0476, 14.2857 },
-};
-
-static const StrokeRec char83[] = {
-   { 20, char83_stroke0 },
-};
-
-/* char: 84 'T' */
-
-static const CoordRec char84_stroke0[] = {
-    { 52.3809, 100 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char84_stroke1[] = {
-    { 19.0476, 100 },
-    { 85.7143, 100 },
-};
-
-static const StrokeRec char84[] = {
-   { 2, char84_stroke0 },
-   { 2, char84_stroke1 },
-};
-
-/* char: 85 'U' */
-
-static const CoordRec char85_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 28.5714 },
-    { 23.8095, 14.2857 },
-    { 33.3333, 4.7619 },
-    { 47.619, 0 },
-    { 57.1428, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 14.2857 },
-    { 85.7143, 28.5714 },
-    { 85.7143, 100 },
-};
-
-static const StrokeRec char85[] = {
-   { 10, char85_stroke0 },
-};
-
-/* char: 86 'V' */
-
-static const CoordRec char86_stroke0[] = {
-    { 14.2857, 100 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char86_stroke1[] = {
-    { 90.4762, 100 },
-    { 52.3809, 0 },
-};
-
-static const StrokeRec char86[] = {
-   { 2, char86_stroke0 },
-   { 2, char86_stroke1 },
-};
-
-/* char: 87 'W' */
-
-static const CoordRec char87_stroke0[] = {
-    { 4.7619, 100 },
-    { 28.5714, 0 },
-};
-
-static const CoordRec char87_stroke1[] = {
-    { 52.3809, 100 },
-    { 28.5714, 0 },
-};
-
-static const CoordRec char87_stroke2[] = {
-    { 52.3809, 100 },
-    { 76.1905, 0 },
-};
-
-static const CoordRec char87_stroke3[] = {
-    { 100, 100 },
-    { 76.1905, 0 },
-};
-
-static const StrokeRec char87[] = {
-   { 2, char87_stroke0 },
-   { 2, char87_stroke1 },
-   { 2, char87_stroke2 },
-   { 2, char87_stroke3 },
-};
-
-/* char: 88 'X' */
-
-static const CoordRec char88_stroke0[] = {
-    { 19.0476, 100 },
-    { 85.7143, 0 },
-};
-
-static const CoordRec char88_stroke1[] = {
-    { 85.7143, 100 },
-    { 19.0476, 0 },
-};
-
-static const StrokeRec char88[] = {
-   { 2, char88_stroke0 },
-   { 2, char88_stroke1 },
-};
-
-/* char: 89 'Y' */
-
-static const CoordRec char89_stroke0[] = {
-    { 14.2857, 100 },
-    { 52.3809, 52.381 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char89_stroke1[] = {
-    { 90.4762, 100 },
-    { 52.3809, 52.381 },
-};
-
-static const StrokeRec char89[] = {
-   { 3, char89_stroke0 },
-   { 2, char89_stroke1 },
-};
-
-/* char: 90 'Z' */
-
-static const CoordRec char90_stroke0[] = {
-    { 85.7143, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char90_stroke1[] = {
-    { 19.0476, 100 },
-    { 85.7143, 100 },
-};
-
-static const CoordRec char90_stroke2[] = {
-    { 19.0476, 0 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char90[] = {
-   { 2, char90_stroke0 },
-   { 2, char90_stroke1 },
-   { 2, char90_stroke2 },
-};
-
-/* char: 91 '[' */
-
-static const CoordRec char91_stroke0[] = {
-    { 35.7143, 119.048 },
-    { 35.7143, -33.3333 },
-};
-
-static const CoordRec char91_stroke1[] = {
-    { 40.4762, 119.048 },
-    { 40.4762, -33.3333 },
-};
-
-static const CoordRec char91_stroke2[] = {
-    { 35.7143, 119.048 },
-    { 69.0476, 119.048 },
-};
-
-static const CoordRec char91_stroke3[] = {
-    { 35.7143, -33.3333 },
-    { 69.0476, -33.3333 },
-};
-
-static const StrokeRec char91[] = {
-   { 2, char91_stroke0 },
-   { 2, char91_stroke1 },
-   { 2, char91_stroke2 },
-   { 2, char91_stroke3 },
-};
-
-/* char: 92 '\' */
-
-static const CoordRec char92_stroke0[] = {
-    { 19.0476, 100 },
-    { 85.7143, -14.2857 },
-};
-
-static const StrokeRec char92[] = {
-   { 2, char92_stroke0 },
-};
-
-/* char: 93 ']' */
-
-static const CoordRec char93_stroke0[] = {
-    { 64.2857, 119.048 },
-    { 64.2857, -33.3333 },
-};
-
-static const CoordRec char93_stroke1[] = {
-    { 69.0476, 119.048 },
-    { 69.0476, -33.3333 },
-};
-
-static const CoordRec char93_stroke2[] = {
-    { 35.7143, 119.048 },
-    { 69.0476, 119.048 },
-};
-
-static const CoordRec char93_stroke3[] = {
-    { 35.7143, -33.3333 },
-    { 69.0476, -33.3333 },
-};
-
-static const StrokeRec char93[] = {
-   { 2, char93_stroke0 },
-   { 2, char93_stroke1 },
-   { 2, char93_stroke2 },
-   { 2, char93_stroke3 },
-};
-
-/* char: 94 '^' */
-
-static const CoordRec char94_stroke0[] = {
-    { 52.3809, 109.524 },
-    { 14.2857, 42.8571 },
-};
-
-static const CoordRec char94_stroke1[] = {
-    { 52.3809, 109.524 },
-    { 90.4762, 42.8571 },
-};
-
-static const StrokeRec char94[] = {
-   { 2, char94_stroke0 },
-   { 2, char94_stroke1 },
-};
-
-/* char: 95 '_' */
-
-static const CoordRec char95_stroke0[] = {
-    { 0, -33.3333 },
-    { 104.762, -33.3333 },
-    { 104.762, -28.5714 },
-    { 0, -28.5714 },
-    { 0, -33.3333 },
-};
-
-static const StrokeRec char95[] = {
-   { 5, char95_stroke0 },
-};
-
-/* char: 96 '`' */
-
-static const CoordRec char96_stroke0[] = {
-    { 42.8572, 100 },
-    { 66.6667, 71.4286 },
-};
-
-static const CoordRec char96_stroke1[] = {
-    { 42.8572, 100 },
-    { 38.0953, 95.2381 },
-    { 66.6667, 71.4286 },
-};
-
-static const StrokeRec char96[] = {
-   { 2, char96_stroke0 },
-   { 3, char96_stroke1 },
-};
-
-/* char: 97 'a' */
-
-static const CoordRec char97_stroke0[] = {
-    { 80.9524, 66.6667 },
-    { 80.9524, 0 },
-};
-
-static const CoordRec char97_stroke1[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char97[] = {
-   { 2, char97_stroke0 },
-   { 14, char97_stroke1 },
-};
-
-/* char: 98 'b' */
-
-static const CoordRec char98_stroke0[] = {
-    { 23.8095, 100 },
-    { 23.8095, 0 },
-};
-
-static const CoordRec char98_stroke1[] = {
-    { 23.8095, 52.381 },
-    { 33.3333, 61.9048 },
-    { 42.8571, 66.6667 },
-    { 57.1428, 66.6667 },
-    { 66.6666, 61.9048 },
-    { 76.1905, 52.381 },
-    { 80.9524, 38.0952 },
-    { 80.9524, 28.5714 },
-    { 76.1905, 14.2857 },
-    { 66.6666, 4.7619 },
-    { 57.1428, 0 },
-    { 42.8571, 0 },
-    { 33.3333, 4.7619 },
-    { 23.8095, 14.2857 },
-};
-
-static const StrokeRec char98[] = {
-   { 2, char98_stroke0 },
-   { 14, char98_stroke1 },
-};
-
-/* char: 99 'c' */
-
-static const CoordRec char99_stroke0[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char99[] = {
-   { 14, char99_stroke0 },
-};
-
-/* char: 100 'd' */
-
-static const CoordRec char100_stroke0[] = {
-    { 80.9524, 100 },
-    { 80.9524, 0 },
-};
-
-static const CoordRec char100_stroke1[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char100[] = {
-   { 2, char100_stroke0 },
-   { 14, char100_stroke1 },
-};
-
-/* char: 101 'e' */
-
-static const CoordRec char101_stroke0[] = {
-    { 23.8095, 38.0952 },
-    { 80.9524, 38.0952 },
-    { 80.9524, 47.619 },
-    { 76.1905, 57.1429 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char101[] = {
-   { 17, char101_stroke0 },
-};
-
-/* char: 102 'f' */
-
-static const CoordRec char102_stroke0[] = {
-    { 71.4286, 100 },
-    { 61.9048, 100 },
-    { 52.381, 95.2381 },
-    { 47.6191, 80.9524 },
-    { 47.6191, 0 },
-};
-
-static const CoordRec char102_stroke1[] = {
-    { 33.3334, 66.6667 },
-    { 66.6667, 66.6667 },
-};
-
-static const StrokeRec char102[] = {
-   { 5, char102_stroke0 },
-   { 2, char102_stroke1 },
-};
-
-/* char: 103 'g' */
-
-static const CoordRec char103_stroke0[] = {
-    { 80.9524, 66.6667 },
-    { 80.9524, -9.5238 },
-    { 76.1905, -23.8095 },
-    { 71.4285, -28.5714 },
-    { 61.9047, -33.3333 },
-    { 47.619, -33.3333 },
-    { 38.0952, -28.5714 },
-};
-
-static const CoordRec char103_stroke1[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char103[] = {
-   { 7, char103_stroke0 },
-   { 14, char103_stroke1 },
-};
-
-/* char: 104 'h' */
-
-static const CoordRec char104_stroke0[] = {
-    { 26.1905, 100 },
-    { 26.1905, 0 },
-};
-
-static const CoordRec char104_stroke1[] = {
-    { 26.1905, 47.619 },
-    { 40.4762, 61.9048 },
-    { 50, 66.6667 },
-    { 64.2857, 66.6667 },
-    { 73.8095, 61.9048 },
-    { 78.5715, 47.619 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char104[] = {
-   { 2, char104_stroke0 },
-   { 7, char104_stroke1 },
-};
-
-/* char: 105 'i' */
-
-static const CoordRec char105_stroke0[] = {
-    { 47.6191, 100 },
-    { 52.381, 95.2381 },
-    { 57.1429, 100 },
-    { 52.381, 104.762 },
-    { 47.6191, 100 },
-};
-
-static const CoordRec char105_stroke1[] = {
-    { 52.381, 66.6667 },
-    { 52.381, 0 },
-};
-
-static const StrokeRec char105[] = {
-   { 5, char105_stroke0 },
-   { 2, char105_stroke1 },
-};
-
-/* char: 106 'j' */
-
-static const CoordRec char106_stroke0[] = {
-    { 57.1429, 100 },
-    { 61.9048, 95.2381 },
-    { 66.6667, 100 },
-    { 61.9048, 104.762 },
-    { 57.1429, 100 },
-};
-
-static const CoordRec char106_stroke1[] = {
-    { 61.9048, 66.6667 },
-    { 61.9048, -14.2857 },
-    { 57.1429, -28.5714 },
-    { 47.6191, -33.3333 },
-    { 38.0953, -33.3333 },
-};
-
-static const StrokeRec char106[] = {
-   { 5, char106_stroke0 },
-   { 5, char106_stroke1 },
-};
-
-/* char: 107 'k' */
-
-static const CoordRec char107_stroke0[] = {
-    { 26.1905, 100 },
-    { 26.1905, 0 },
-};
-
-static const CoordRec char107_stroke1[] = {
-    { 73.8095, 66.6667 },
-    { 26.1905, 19.0476 },
-};
-
-static const CoordRec char107_stroke2[] = {
-    { 45.2381, 38.0952 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char107[] = {
-   { 2, char107_stroke0 },
-   { 2, char107_stroke1 },
-   { 2, char107_stroke2 },
-};
-
-/* char: 108 'l' */
-
-static const CoordRec char108_stroke0[] = {
-    { 52.381, 100 },
-    { 52.381, 0 },
-};
-
-static const StrokeRec char108[] = {
-   { 2, char108_stroke0 },
-};
-
-/* char: 109 'm' */
-
-static const CoordRec char109_stroke0[] = {
-    { 0, 66.6667 },
-    { 0, 0 },
-};
-
-static const CoordRec char109_stroke1[] = {
-    { 0, 47.619 },
-    { 14.2857, 61.9048 },
-    { 23.8095, 66.6667 },
-    { 38.0952, 66.6667 },
-    { 47.619, 61.9048 },
-    { 52.381, 47.619 },
-    { 52.381, 0 },
-};
-
-static const CoordRec char109_stroke2[] = {
-    { 52.381, 47.619 },
-    { 66.6667, 61.9048 },
-    { 76.1905, 66.6667 },
-    { 90.4762, 66.6667 },
-    { 100, 61.9048 },
-    { 104.762, 47.619 },
-    { 104.762, 0 },
-};
-
-static const StrokeRec char109[] = {
-   { 2, char109_stroke0 },
-   { 7, char109_stroke1 },
-   { 7, char109_stroke2 },
-};
-
-/* char: 110 'n' */
-
-static const CoordRec char110_stroke0[] = {
-    { 26.1905, 66.6667 },
-    { 26.1905, 0 },
-};
-
-static const CoordRec char110_stroke1[] = {
-    { 26.1905, 47.619 },
-    { 40.4762, 61.9048 },
-    { 50, 66.6667 },
-    { 64.2857, 66.6667 },
-    { 73.8095, 61.9048 },
-    { 78.5715, 47.619 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char110[] = {
-   { 2, char110_stroke0 },
-   { 7, char110_stroke1 },
-};
-
-/* char: 111 'o' */
-
-static const CoordRec char111_stroke0[] = {
-    { 45.2381, 66.6667 },
-    { 35.7143, 61.9048 },
-    { 26.1905, 52.381 },
-    { 21.4286, 38.0952 },
-    { 21.4286, 28.5714 },
-    { 26.1905, 14.2857 },
-    { 35.7143, 4.7619 },
-    { 45.2381, 0 },
-    { 59.5238, 0 },
-    { 69.0476, 4.7619 },
-    { 78.5714, 14.2857 },
-    { 83.3334, 28.5714 },
-    { 83.3334, 38.0952 },
-    { 78.5714, 52.381 },
-    { 69.0476, 61.9048 },
-    { 59.5238, 66.6667 },
-    { 45.2381, 66.6667 },
-};
-
-static const StrokeRec char111[] = {
-   { 17, char111_stroke0 },
-};
-
-/* char: 112 'p' */
-
-static const CoordRec char112_stroke0[] = {
-    { 23.8095, 66.6667 },
-    { 23.8095, -33.3333 },
-};
-
-static const CoordRec char112_stroke1[] = {
-    { 23.8095, 52.381 },
-    { 33.3333, 61.9048 },
-    { 42.8571, 66.6667 },
-    { 57.1428, 66.6667 },
-    { 66.6666, 61.9048 },
-    { 76.1905, 52.381 },
-    { 80.9524, 38.0952 },
-    { 80.9524, 28.5714 },
-    { 76.1905, 14.2857 },
-    { 66.6666, 4.7619 },
-    { 57.1428, 0 },
-    { 42.8571, 0 },
-    { 33.3333, 4.7619 },
-    { 23.8095, 14.2857 },
-};
-
-static const StrokeRec char112[] = {
-   { 2, char112_stroke0 },
-   { 14, char112_stroke1 },
-};
-
-/* char: 113 'q' */
-
-static const CoordRec char113_stroke0[] = {
-    { 80.9524, 66.6667 },
-    { 80.9524, -33.3333 },
-};
-
-static const CoordRec char113_stroke1[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char113[] = {
-   { 2, char113_stroke0 },
-   { 14, char113_stroke1 },
-};
-
-/* char: 114 'r' */
-
-static const CoordRec char114_stroke0[] = {
-    { 33.3334, 66.6667 },
-    { 33.3334, 0 },
-};
-
-static const CoordRec char114_stroke1[] = {
-    { 33.3334, 38.0952 },
-    { 38.0953, 52.381 },
-    { 47.6191, 61.9048 },
-    { 57.1429, 66.6667 },
-    { 71.4286, 66.6667 },
-};
-
-static const StrokeRec char114[] = {
-   { 2, char114_stroke0 },
-   { 5, char114_stroke1 },
-};
-
-/* char: 115 's' */
-
-static const CoordRec char115_stroke0[] = {
-    { 78.5715, 52.381 },
-    { 73.8095, 61.9048 },
-    { 59.5238, 66.6667 },
-    { 45.2381, 66.6667 },
-    { 30.9524, 61.9048 },
-    { 26.1905, 52.381 },
-    { 30.9524, 42.8571 },
-    { 40.4762, 38.0952 },
-    { 64.2857, 33.3333 },
-    { 73.8095, 28.5714 },
-    { 78.5715, 19.0476 },
-    { 78.5715, 14.2857 },
-    { 73.8095, 4.7619 },
-    { 59.5238, 0 },
-    { 45.2381, 0 },
-    { 30.9524, 4.7619 },
-    { 26.1905, 14.2857 },
-};
-
-static const StrokeRec char115[] = {
-   { 17, char115_stroke0 },
-};
-
-/* char: 116 't' */
-
-static const CoordRec char116_stroke0[] = {
-    { 47.6191, 100 },
-    { 47.6191, 19.0476 },
-    { 52.381, 4.7619 },
-    { 61.9048, 0 },
-    { 71.4286, 0 },
-};
-
-static const CoordRec char116_stroke1[] = {
-    { 33.3334, 66.6667 },
-    { 66.6667, 66.6667 },
-};
-
-static const StrokeRec char116[] = {
-   { 5, char116_stroke0 },
-   { 2, char116_stroke1 },
-};
-
-/* char: 117 'u' */
-
-static const CoordRec char117_stroke0[] = {
-    { 26.1905, 66.6667 },
-    { 26.1905, 19.0476 },
-    { 30.9524, 4.7619 },
-    { 40.4762, 0 },
-    { 54.7619, 0 },
-    { 64.2857, 4.7619 },
-    { 78.5715, 19.0476 },
-};
-
-static const CoordRec char117_stroke1[] = {
-    { 78.5715, 66.6667 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char117[] = {
-   { 7, char117_stroke0 },
-   { 2, char117_stroke1 },
-};
-
-/* char: 118 'v' */
-
-static const CoordRec char118_stroke0[] = {
-    { 23.8095, 66.6667 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char118_stroke1[] = {
-    { 80.9524, 66.6667 },
-    { 52.3809, 0 },
-};
-
-static const StrokeRec char118[] = {
-   { 2, char118_stroke0 },
-   { 2, char118_stroke1 },
-};
-
-/* char: 119 'w' */
-
-static const CoordRec char119_stroke0[] = {
-    { 14.2857, 66.6667 },
-    { 33.3333, 0 },
-};
-
-static const CoordRec char119_stroke1[] = {
-    { 52.3809, 66.6667 },
-    { 33.3333, 0 },
-};
-
-static const CoordRec char119_stroke2[] = {
-    { 52.3809, 66.6667 },
-    { 71.4286, 0 },
-};
-
-static const CoordRec char119_stroke3[] = {
-    { 90.4762, 66.6667 },
-    { 71.4286, 0 },
-};
-
-static const StrokeRec char119[] = {
-   { 2, char119_stroke0 },
-   { 2, char119_stroke1 },
-   { 2, char119_stroke2 },
-   { 2, char119_stroke3 },
-};
-
-/* char: 120 'x' */
-
-static const CoordRec char120_stroke0[] = {
-    { 26.1905, 66.6667 },
-    { 78.5715, 0 },
-};
-
-static const CoordRec char120_stroke1[] = {
-    { 78.5715, 66.6667 },
-    { 26.1905, 0 },
-};
-
-static const StrokeRec char120[] = {
-   { 2, char120_stroke0 },
-   { 2, char120_stroke1 },
-};
-
-/* char: 121 'y' */
-
-static const CoordRec char121_stroke0[] = {
-    { 26.1905, 66.6667 },
-    { 54.7619, 0 },
-};
-
-static const CoordRec char121_stroke1[] = {
-    { 83.3334, 66.6667 },
-    { 54.7619, 0 },
-    { 45.2381, -19.0476 },
-    { 35.7143, -28.5714 },
-    { 26.1905, -33.3333 },
-    { 21.4286, -33.3333 },
-};
-
-static const StrokeRec char121[] = {
-   { 2, char121_stroke0 },
-   { 6, char121_stroke1 },
-};
-
-/* char: 122 'z' */
-
-static const CoordRec char122_stroke0[] = {
-    { 78.5715, 66.6667 },
-    { 26.1905, 0 },
-};
-
-static const CoordRec char122_stroke1[] = {
-    { 26.1905, 66.6667 },
-    { 78.5715, 66.6667 },
-};
-
-static const CoordRec char122_stroke2[] = {
-    { 26.1905, 0 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char122[] = {
-   { 2, char122_stroke0 },
-   { 2, char122_stroke1 },
-   { 2, char122_stroke2 },
-};
-
-/* char: 123 '{' */
-
-static const CoordRec char123_stroke0[] = {
-    { 64.2857, 119.048 },
-    { 54.7619, 114.286 },
-    { 50, 109.524 },
-    { 45.2381, 100 },
-    { 45.2381, 90.4762 },
-    { 50, 80.9524 },
-    { 54.7619, 76.1905 },
-    { 59.5238, 66.6667 },
-    { 59.5238, 57.1429 },
-    { 50, 47.619 },
-};
-
-static const CoordRec char123_stroke1[] = {
-    { 54.7619, 114.286 },
-    { 50, 104.762 },
-    { 50, 95.2381 },
-    { 54.7619, 85.7143 },
-    { 59.5238, 80.9524 },
-    { 64.2857, 71.4286 },
-    { 64.2857, 61.9048 },
-    { 59.5238, 52.381 },
-    { 40.4762, 42.8571 },
-    { 59.5238, 33.3333 },
-    { 64.2857, 23.8095 },
-    { 64.2857, 14.2857 },
-    { 59.5238, 4.7619 },
-    { 54.7619, 0 },
-    { 50, -9.5238 },
-    { 50, -19.0476 },
-    { 54.7619, -28.5714 },
-};
-
-static const CoordRec char123_stroke2[] = {
-    { 50, 38.0952 },
-    { 59.5238, 28.5714 },
-    { 59.5238, 19.0476 },
-    { 54.7619, 9.5238 },
-    { 50, 4.7619 },
-    { 45.2381, -4.7619 },
-    { 45.2381, -14.2857 },
-    { 50, -23.8095 },
-    { 54.7619, -28.5714 },
-    { 64.2857, -33.3333 },
-};
-
-static const StrokeRec char123[] = {
-   { 10, char123_stroke0 },
-   { 17, char123_stroke1 },
-   { 10, char123_stroke2 },
-};
-
-/* char: 124 '|' */
-
-static const CoordRec char124_stroke0[] = {
-    { 52.381, 119.048 },
-    { 52.381, -33.3333 },
-};
-
-static const StrokeRec char124[] = {
-   { 2, char124_stroke0 },
-};
-
-/* char: 125 '}' */
-
-static const CoordRec char125_stroke0[] = {
-    { 40.4762, 119.048 },
-    { 50, 114.286 },
-    { 54.7619, 109.524 },
-    { 59.5238, 100 },
-    { 59.5238, 90.4762 },
-    { 54.7619, 80.9524 },
-    { 50, 76.1905 },
-    { 45.2381, 66.6667 },
-    { 45.2381, 57.1429 },
-    { 54.7619, 47.619 },
-};
-
-static const CoordRec char125_stroke1[] = {
-    { 50, 114.286 },
-    { 54.7619, 104.762 },
-    { 54.7619, 95.2381 },
-    { 50, 85.7143 },
-    { 45.2381, 80.9524 },
-    { 40.4762, 71.4286 },
-    { 40.4762, 61.9048 },
-    { 45.2381, 52.381 },
-    { 64.2857, 42.8571 },
-    { 45.2381, 33.3333 },
-    { 40.4762, 23.8095 },
-    { 40.4762, 14.2857 },
-    { 45.2381, 4.7619 },
-    { 50, 0 },
-    { 54.7619, -9.5238 },
-    { 54.7619, -19.0476 },
-    { 50, -28.5714 },
-};
-
-static const CoordRec char125_stroke2[] = {
-    { 54.7619, 38.0952 },
-    { 45.2381, 28.5714 },
-    { 45.2381, 19.0476 },
-    { 50, 9.5238 },
-    { 54.7619, 4.7619 },
-    { 59.5238, -4.7619 },
-    { 59.5238, -14.2857 },
-    { 54.7619, -23.8095 },
-    { 50, -28.5714 },
-    { 40.4762, -33.3333 },
-};
-
-static const StrokeRec char125[] = {
-   { 10, char125_stroke0 },
-   { 17, char125_stroke1 },
-   { 10, char125_stroke2 },
-};
-
-/* char: 126 '~' */
-
-static const CoordRec char126_stroke0[] = {
-    { 9.5238, 28.5714 },
-    { 9.5238, 38.0952 },
-    { 14.2857, 52.381 },
-    { 23.8095, 57.1429 },
-    { 33.3333, 57.1429 },
-    { 42.8571, 52.381 },
-    { 61.9048, 38.0952 },
-    { 71.4286, 33.3333 },
-    { 80.9524, 33.3333 },
-    { 90.4762, 38.0952 },
-    { 95.2381, 47.619 },
-};
-
-static const CoordRec char126_stroke1[] = {
-    { 9.5238, 38.0952 },
-    { 14.2857, 47.619 },
-    { 23.8095, 52.381 },
-    { 33.3333, 52.381 },
-    { 42.8571, 47.619 },
-    { 61.9048, 33.3333 },
-    { 71.4286, 28.5714 },
-    { 80.9524, 28.5714 },
-    { 90.4762, 33.3333 },
-    { 95.2381, 47.619 },
-    { 95.2381, 57.1429 },
-};
-
-static const StrokeRec char126[] = {
-   { 11, char126_stroke0 },
-   { 11, char126_stroke1 },
-};
-
-/* char: 127 */
-
-static const CoordRec char127_stroke0[] = {
-    { 71.4286, 100 },
-    { 33.3333, -33.3333 },
-};
-
-static const CoordRec char127_stroke1[] = {
-    { 47.619, 66.6667 },
-    { 33.3333, 61.9048 },
-    { 23.8095, 52.381 },
-    { 19.0476, 38.0952 },
-    { 19.0476, 23.8095 },
-    { 23.8095, 14.2857 },
-    { 33.3333, 4.7619 },
-    { 47.619, 0 },
-    { 57.1428, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 14.2857 },
-    { 85.7143, 28.5714 },
-    { 85.7143, 42.8571 },
-    { 80.9524, 52.381 },
-    { 71.4286, 61.9048 },
-    { 57.1428, 66.6667 },
-    { 47.619, 66.6667 },
-};
-
-static const StrokeRec char127[] = {
-   { 2, char127_stroke0 },
-   { 17, char127_stroke1 },
-};
-
-static const StrokeCharRec chars[] = {
-    { 0, /* char0 */ 0, 0, 0 },
-    { 0, /* char1 */ 0, 0, 0 },
-    { 0, /* char2 */ 0, 0, 0 },
-    { 0, /* char3 */ 0, 0, 0 },
-    { 0, /* char4 */ 0, 0, 0 },
-    { 0, /* char5 */ 0, 0, 0 },
-    { 0, /* char6 */ 0, 0, 0 },
-    { 0, /* char7 */ 0, 0, 0 },
-    { 0, /* char8 */ 0, 0, 0 },
-    { 0, /* char9 */ 0, 0, 0 },
-    { 0, /* char10 */ 0, 0, 0 },
-    { 0, /* char11 */ 0, 0, 0 },
-    { 0, /* char12 */ 0, 0, 0 },
-    { 0, /* char13 */ 0, 0, 0 },
-    { 0, /* char14 */ 0, 0, 0 },
-    { 0, /* char15 */ 0, 0, 0 },
-    { 0, /* char16 */ 0, 0, 0 },
-    { 0, /* char17 */ 0, 0, 0 },
-    { 0, /* char18 */ 0, 0, 0 },
-    { 0, /* char19 */ 0, 0, 0 },
-    { 0, /* char20 */ 0, 0, 0 },
-    { 0, /* char21 */ 0, 0, 0 },
-    { 0, /* char22 */ 0, 0, 0 },
-    { 0, /* char23 */ 0, 0, 0 },
-    { 0, /* char24 */ 0, 0, 0 },
-    { 0, /* char25 */ 0, 0, 0 },
-    { 0, /* char26 */ 0, 0, 0 },
-    { 0, /* char27 */ 0, 0, 0 },
-    { 0, /* char28 */ 0, 0, 0 },
-    { 0, /* char29 */ 0, 0, 0 },
-    { 0, /* char30 */ 0, 0, 0 },
-    { 0, /* char31 */ 0, 0, 0 },
-    { 0, /* char32 */ 0, 52.381, 104.762 },
-    { 2, char33, 52.381, 104.762 },
-    { 2, char34, 52.381, 104.762 },
-    { 4, char35, 52.381, 104.762 },
-    { 3, char36, 52.381, 104.762 },
-    { 3, char37, 52.381, 104.762 },
-    { 1, char38, 52.381, 104.762 },
-    { 1, char39, 52.381, 104.762 },
-    { 1, char40, 52.381, 104.762 },
-    { 1, char41, 52.381, 104.762 },
-    { 3, char42, 52.381, 104.762 },
-    { 2, char43, 52.381, 104.762 },
-    { 1, char44, 52.381, 104.762 },
-    { 1, char45, 52.381, 104.762 },
-    { 1, char46, 52.381, 104.762 },
-    { 1, char47, 52.381, 104.762 },
-    { 1, char48, 52.381, 104.762 },
-    { 1, char49, 52.381, 104.762 },
-    { 1, char50, 52.381, 104.762 },
-    { 1, char51, 52.381, 104.762 },
-    { 2, char52, 52.381, 104.762 },
-    { 1, char53, 52.381, 104.762 },
-    { 1, char54, 52.381, 104.762 },
-    { 2, char55, 52.381, 104.762 },
-    { 1, char56, 52.381, 104.762 },
-    { 1, char57, 52.381, 104.762 },
-    { 2, char58, 52.381, 104.762 },
-    { 2, char59, 52.381, 104.762 },
-    { 1, char60, 52.381, 104.762 },
-    { 2, char61, 52.381, 104.762 },
-    { 1, char62, 52.381, 104.762 },
-    { 2, char63, 52.381, 104.762 },
-    { 2, char64, 52.381, 104.762 },
-    { 3, char65, 52.381, 104.762 },
-    { 3, char66, 52.381, 104.762 },
-    { 1, char67, 52.381, 104.762 },
-    { 2, char68, 52.381, 104.762 },
-    { 4, char69, 52.381, 104.762 },
-    { 3, char70, 52.381, 104.762 },
-    { 2, char71, 52.381, 104.762 },
-    { 3, char72, 52.381, 104.762 },
-    { 1, char73, 52.381, 104.762 },
-    { 1, char74, 52.381, 104.762 },
-    { 3, char75, 52.381, 104.762 },
-    { 2, char76, 52.381, 104.762 },
-    { 4, char77, 52.381, 104.762 },
-    { 3, char78, 52.381, 104.762 },
-    { 1, char79, 52.381, 104.762 },
-    { 2, char80, 52.381, 104.762 },
-    { 2, char81, 52.381, 104.762 },
-    { 3, char82, 52.381, 104.762 },
-    { 1, char83, 52.381, 104.762 },
-    { 2, char84, 52.381, 104.762 },
-    { 1, char85, 52.381, 104.762 },
-    { 2, char86, 52.381, 104.762 },
-    { 4, char87, 52.381, 104.762 },
-    { 2, char88, 52.381, 104.762 },
-    { 2, char89, 52.381, 104.762 },
-    { 3, char90, 52.381, 104.762 },
-    { 4, char91, 52.381, 104.762 },
-    { 1, char92, 52.381, 104.762 },
-    { 4, char93, 52.381, 104.762 },
-    { 2, char94, 52.381, 104.762 },
-    { 1, char95, 52.381, 104.762 },
-    { 2, char96, 52.381, 104.762 },
-    { 2, char97, 52.381, 104.762 },
-    { 2, char98, 52.381, 104.762 },
-    { 1, char99, 52.381, 104.762 },
-    { 2, char100, 52.381, 104.762 },
-    { 1, char101, 52.381, 104.762 },
-    { 2, char102, 52.381, 104.762 },
-    { 2, char103, 52.381, 104.762 },
-    { 2, char104, 52.381, 104.762 },
-    { 2, char105, 52.381, 104.762 },
-    { 2, char106, 52.381, 104.762 },
-    { 3, char107, 52.381, 104.762 },
-    { 1, char108, 52.381, 104.762 },
-    { 3, char109, 52.381, 104.762 },
-    { 2, char110, 52.381, 104.762 },
-    { 1, char111, 52.381, 104.762 },
-    { 2, char112, 52.381, 104.762 },
-    { 2, char113, 52.381, 104.762 },
-    { 2, char114, 52.381, 104.762 },
-    { 1, char115, 52.381, 104.762 },
-    { 2, char116, 52.381, 104.762 },
-    { 2, char117, 52.381, 104.762 },
-    { 2, char118, 52.381, 104.762 },
-    { 4, char119, 52.381, 104.762 },
-    { 2, char120, 52.381, 104.762 },
-    { 2, char121, 52.381, 104.762 },
-    { 3, char122, 52.381, 104.762 },
-    { 3, char123, 52.381, 104.762 },
-    { 1, char124, 52.381, 104.762 },
-    { 3, char125, 52.381, 104.762 },
-    { 2, char126, 52.381, 104.762 },
-    { 2, char127, 52.381, 104.762 },
-};
-
-StrokeFontRec glutStrokeMonoRoman = { "Roman", 128, chars, 119.048, -33.3333 };
-
diff --git a/src/glut/beos/glut_roman.c b/src/glut/beos/glut_roman.c
deleted file mode 100644 (file)
index af2b4ec..0000000
+++ /dev/null
@@ -1,2451 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#include "glutstroke.h"
-
-/* char: 33 '!' */
-
-static const CoordRec char33_stroke0[] = {
-    { 13.3819, 100 },
-    { 13.3819, 33.3333 },
-};
-
-static const CoordRec char33_stroke1[] = {
-    { 13.3819, 9.5238 },
-    { 8.62, 4.7619 },
-    { 13.3819, 0 },
-    { 18.1438, 4.7619 },
-    { 13.3819, 9.5238 },
-};
-
-static const StrokeRec char33[] = {
-   { 2, char33_stroke0 },
-   { 5, char33_stroke1 },
-};
-
-/* char: 34 '"' */
-
-static const CoordRec char34_stroke0[] = {
-    { 4.02, 100 },
-    { 4.02, 66.6667 },
-};
-
-static const CoordRec char34_stroke1[] = {
-    { 42.1152, 100 },
-    { 42.1152, 66.6667 },
-};
-
-static const StrokeRec char34[] = {
-   { 2, char34_stroke0 },
-   { 2, char34_stroke1 },
-};
-
-/* char: 35 '#' */
-
-static const CoordRec char35_stroke0[] = {
-    { 41.2952, 119.048 },
-    { 7.9619, -33.3333 },
-};
-
-static const CoordRec char35_stroke1[] = {
-    { 69.8667, 119.048 },
-    { 36.5333, -33.3333 },
-};
-
-static const CoordRec char35_stroke2[] = {
-    { 7.9619, 57.1429 },
-    { 74.6286, 57.1429 },
-};
-
-static const CoordRec char35_stroke3[] = {
-    { 3.2, 28.5714 },
-    { 69.8667, 28.5714 },
-};
-
-static const StrokeRec char35[] = {
-   { 2, char35_stroke0 },
-   { 2, char35_stroke1 },
-   { 2, char35_stroke2 },
-   { 2, char35_stroke3 },
-};
-
-/* char: 36 '$' */
-
-static const CoordRec char36_stroke0[] = {
-    { 28.6295, 119.048 },
-    { 28.6295, -19.0476 },
-};
-
-static const CoordRec char36_stroke1[] = {
-    { 47.6771, 119.048 },
-    { 47.6771, -19.0476 },
-};
-
-static const CoordRec char36_stroke2[] = {
-    { 71.4867, 85.7143 },
-    { 61.9629, 95.2381 },
-    { 47.6771, 100 },
-    { 28.6295, 100 },
-    { 14.3438, 95.2381 },
-    { 4.82, 85.7143 },
-    { 4.82, 76.1905 },
-    { 9.5819, 66.6667 },
-    { 14.3438, 61.9048 },
-    { 23.8676, 57.1429 },
-    { 52.439, 47.619 },
-    { 61.9629, 42.8571 },
-    { 66.7248, 38.0952 },
-    { 71.4867, 28.5714 },
-    { 71.4867, 14.2857 },
-    { 61.9629, 4.7619 },
-    { 47.6771, 0 },
-    { 28.6295, 0 },
-    { 14.3438, 4.7619 },
-    { 4.82, 14.2857 },
-};
-
-static const StrokeRec char36[] = {
-   { 2, char36_stroke0 },
-   { 2, char36_stroke1 },
-   { 20, char36_stroke2 },
-};
-
-/* char: 37 '%' */
-
-static const CoordRec char37_stroke0[] = {
-    { 92.0743, 100 },
-    { 6.36, 0 },
-};
-
-static const CoordRec char37_stroke1[] = {
-    { 30.1695, 100 },
-    { 39.6933, 90.4762 },
-    { 39.6933, 80.9524 },
-    { 34.9314, 71.4286 },
-    { 25.4076, 66.6667 },
-    { 15.8838, 66.6667 },
-    { 6.36, 76.1905 },
-    { 6.36, 85.7143 },
-    { 11.1219, 95.2381 },
-    { 20.6457, 100 },
-    { 30.1695, 100 },
-    { 39.6933, 95.2381 },
-    { 53.979, 90.4762 },
-    { 68.2648, 90.4762 },
-    { 82.5505, 95.2381 },
-    { 92.0743, 100 },
-};
-
-static const CoordRec char37_stroke2[] = {
-    { 73.0267, 33.3333 },
-    { 63.5029, 28.5714 },
-    { 58.741, 19.0476 },
-    { 58.741, 9.5238 },
-    { 68.2648, 0 },
-    { 77.7886, 0 },
-    { 87.3124, 4.7619 },
-    { 92.0743, 14.2857 },
-    { 92.0743, 23.8095 },
-    { 82.5505, 33.3333 },
-    { 73.0267, 33.3333 },
-};
-
-static const StrokeRec char37[] = {
-   { 2, char37_stroke0 },
-   { 16, char37_stroke1 },
-   { 11, char37_stroke2 },
-};
-
-/* char: 38 '&' */
-
-static const CoordRec char38_stroke0[] = {
-    { 101.218, 57.1429 },
-    { 101.218, 61.9048 },
-    { 96.4562, 66.6667 },
-    { 91.6943, 66.6667 },
-    { 86.9324, 61.9048 },
-    { 82.1705, 52.381 },
-    { 72.6467, 28.5714 },
-    { 63.1229, 14.2857 },
-    { 53.599, 4.7619 },
-    { 44.0752, 0 },
-    { 25.0276, 0 },
-    { 15.5038, 4.7619 },
-    { 10.7419, 9.5238 },
-    { 5.98, 19.0476 },
-    { 5.98, 28.5714 },
-    { 10.7419, 38.0952 },
-    { 15.5038, 42.8571 },
-    { 48.8371, 61.9048 },
-    { 53.599, 66.6667 },
-    { 58.361, 76.1905 },
-    { 58.361, 85.7143 },
-    { 53.599, 95.2381 },
-    { 44.0752, 100 },
-    { 34.5514, 95.2381 },
-    { 29.7895, 85.7143 },
-    { 29.7895, 76.1905 },
-    { 34.5514, 61.9048 },
-    { 44.0752, 47.619 },
-    { 67.8848, 14.2857 },
-    { 77.4086, 4.7619 },
-    { 86.9324, 0 },
-    { 96.4562, 0 },
-    { 101.218, 4.7619 },
-    { 101.218, 9.5238 },
-};
-
-static const StrokeRec char38[] = {
-   { 34, char38_stroke0 },
-};
-
-/* char: 39 ''' */
-
-static const CoordRec char39_stroke0[] = {
-    { 4.44, 100 },
-    { 4.44, 66.6667 },
-};
-
-static const StrokeRec char39[] = {
-   { 2, char39_stroke0 },
-};
-
-/* char: 40 '(' */
-
-static const CoordRec char40_stroke0[] = {
-    { 40.9133, 119.048 },
-    { 31.3895, 109.524 },
-    { 21.8657, 95.2381 },
-    { 12.3419, 76.1905 },
-    { 7.58, 52.381 },
-    { 7.58, 33.3333 },
-    { 12.3419, 9.5238 },
-    { 21.8657, -9.5238 },
-    { 31.3895, -23.8095 },
-    { 40.9133, -33.3333 },
-};
-
-static const StrokeRec char40[] = {
-   { 10, char40_stroke0 },
-};
-
-/* char: 41 ')' */
-
-static const CoordRec char41_stroke0[] = {
-    { 5.28, 119.048 },
-    { 14.8038, 109.524 },
-    { 24.3276, 95.2381 },
-    { 33.8514, 76.1905 },
-    { 38.6133, 52.381 },
-    { 38.6133, 33.3333 },
-    { 33.8514, 9.5238 },
-    { 24.3276, -9.5238 },
-    { 14.8038, -23.8095 },
-    { 5.28, -33.3333 },
-};
-
-static const StrokeRec char41[] = {
-   { 10, char41_stroke0 },
-};
-
-/* char: 42 '*' */
-
-static const CoordRec char42_stroke0[] = {
-    { 30.7695, 71.4286 },
-    { 30.7695, 14.2857 },
-};
-
-static const CoordRec char42_stroke1[] = {
-    { 6.96, 57.1429 },
-    { 54.579, 28.5714 },
-};
-
-static const CoordRec char42_stroke2[] = {
-    { 54.579, 57.1429 },
-    { 6.96, 28.5714 },
-};
-
-static const StrokeRec char42[] = {
-   { 2, char42_stroke0 },
-   { 2, char42_stroke1 },
-   { 2, char42_stroke2 },
-};
-
-/* char: 43 '+' */
-
-static const CoordRec char43_stroke0[] = {
-    { 48.8371, 85.7143 },
-    { 48.8371, 0 },
-};
-
-static const CoordRec char43_stroke1[] = {
-    { 5.98, 42.8571 },
-    { 91.6943, 42.8571 },
-};
-
-static const StrokeRec char43[] = {
-   { 2, char43_stroke0 },
-   { 2, char43_stroke1 },
-};
-
-/* char: 44 ',' */
-
-static const CoordRec char44_stroke0[] = {
-    { 18.2838, 4.7619 },
-    { 13.5219, 0 },
-    { 8.76, 4.7619 },
-    { 13.5219, 9.5238 },
-    { 18.2838, 4.7619 },
-    { 18.2838, -4.7619 },
-    { 13.5219, -14.2857 },
-    { 8.76, -19.0476 },
-};
-
-static const StrokeRec char44[] = {
-   { 8, char44_stroke0 },
-};
-
-/* char: 45 '-' */
-
-static const CoordRec char45_stroke0[] = {
-    { 7.38, 42.8571 },
-    { 93.0943, 42.8571 },
-};
-
-static const StrokeRec char45[] = {
-   { 2, char45_stroke0 },
-};
-
-/* char: 46 '.' */
-
-static const CoordRec char46_stroke0[] = {
-    { 13.1019, 9.5238 },
-    { 8.34, 4.7619 },
-    { 13.1019, 0 },
-    { 17.8638, 4.7619 },
-    { 13.1019, 9.5238 },
-};
-
-static const StrokeRec char46[] = {
-   { 5, char46_stroke0 },
-};
-
-/* char: 47 '/' */
-
-static const CoordRec char47_stroke0[] = {
-    { 7.24, -14.2857 },
-    { 73.9067, 100 },
-};
-
-static const StrokeRec char47[] = {
-   { 2, char47_stroke0 },
-};
-
-/* char: 48 '0' */
-
-static const CoordRec char48_stroke0[] = {
-    { 33.5514, 100 },
-    { 19.2657, 95.2381 },
-    { 9.7419, 80.9524 },
-    { 4.98, 57.1429 },
-    { 4.98, 42.8571 },
-    { 9.7419, 19.0476 },
-    { 19.2657, 4.7619 },
-    { 33.5514, 0 },
-    { 43.0752, 0 },
-    { 57.361, 4.7619 },
-    { 66.8848, 19.0476 },
-    { 71.6467, 42.8571 },
-    { 71.6467, 57.1429 },
-    { 66.8848, 80.9524 },
-    { 57.361, 95.2381 },
-    { 43.0752, 100 },
-    { 33.5514, 100 },
-};
-
-static const StrokeRec char48[] = {
-   { 17, char48_stroke0 },
-};
-
-/* char: 49 '1' */
-
-static const CoordRec char49_stroke0[] = {
-    { 11.82, 80.9524 },
-    { 21.3438, 85.7143 },
-    { 35.6295, 100 },
-    { 35.6295, 0 },
-};
-
-static const StrokeRec char49[] = {
-   { 4, char49_stroke0 },
-};
-
-/* char: 50 '2' */
-
-static const CoordRec char50_stroke0[] = {
-    { 10.1819, 76.1905 },
-    { 10.1819, 80.9524 },
-    { 14.9438, 90.4762 },
-    { 19.7057, 95.2381 },
-    { 29.2295, 100 },
-    { 48.2771, 100 },
-    { 57.801, 95.2381 },
-    { 62.5629, 90.4762 },
-    { 67.3248, 80.9524 },
-    { 67.3248, 71.4286 },
-    { 62.5629, 61.9048 },
-    { 53.039, 47.619 },
-    { 5.42, 0 },
-    { 72.0867, 0 },
-};
-
-static const StrokeRec char50[] = {
-   { 14, char50_stroke0 },
-};
-
-/* char: 51 '3' */
-
-static const CoordRec char51_stroke0[] = {
-    { 14.5238, 100 },
-    { 66.9048, 100 },
-    { 38.3333, 61.9048 },
-    { 52.619, 61.9048 },
-    { 62.1429, 57.1429 },
-    { 66.9048, 52.381 },
-    { 71.6667, 38.0952 },
-    { 71.6667, 28.5714 },
-    { 66.9048, 14.2857 },
-    { 57.381, 4.7619 },
-    { 43.0952, 0 },
-    { 28.8095, 0 },
-    { 14.5238, 4.7619 },
-    { 9.7619, 9.5238 },
-    { 5, 19.0476 },
-};
-
-static const StrokeRec char51[] = {
-   { 15, char51_stroke0 },
-};
-
-/* char: 52 '4' */
-
-static const CoordRec char52_stroke0[] = {
-    { 51.499, 100 },
-    { 3.88, 33.3333 },
-    { 75.3086, 33.3333 },
-};
-
-static const CoordRec char52_stroke1[] = {
-    { 51.499, 100 },
-    { 51.499, 0 },
-};
-
-static const StrokeRec char52[] = {
-   { 3, char52_stroke0 },
-   { 2, char52_stroke1 },
-};
-
-/* char: 53 '5' */
-
-static const CoordRec char53_stroke0[] = {
-    { 62.0029, 100 },
-    { 14.3838, 100 },
-    { 9.6219, 57.1429 },
-    { 14.3838, 61.9048 },
-    { 28.6695, 66.6667 },
-    { 42.9552, 66.6667 },
-    { 57.241, 61.9048 },
-    { 66.7648, 52.381 },
-    { 71.5267, 38.0952 },
-    { 71.5267, 28.5714 },
-    { 66.7648, 14.2857 },
-    { 57.241, 4.7619 },
-    { 42.9552, 0 },
-    { 28.6695, 0 },
-    { 14.3838, 4.7619 },
-    { 9.6219, 9.5238 },
-    { 4.86, 19.0476 },
-};
-
-static const StrokeRec char53[] = {
-   { 17, char53_stroke0 },
-};
-
-/* char: 54 '6' */
-
-static const CoordRec char54_stroke0[] = {
-    { 62.7229, 85.7143 },
-    { 57.961, 95.2381 },
-    { 43.6752, 100 },
-    { 34.1514, 100 },
-    { 19.8657, 95.2381 },
-    { 10.3419, 80.9524 },
-    { 5.58, 57.1429 },
-    { 5.58, 33.3333 },
-    { 10.3419, 14.2857 },
-    { 19.8657, 4.7619 },
-    { 34.1514, 0 },
-    { 38.9133, 0 },
-    { 53.199, 4.7619 },
-    { 62.7229, 14.2857 },
-    { 67.4848, 28.5714 },
-    { 67.4848, 33.3333 },
-    { 62.7229, 47.619 },
-    { 53.199, 57.1429 },
-    { 38.9133, 61.9048 },
-    { 34.1514, 61.9048 },
-    { 19.8657, 57.1429 },
-    { 10.3419, 47.619 },
-    { 5.58, 33.3333 },
-};
-
-static const StrokeRec char54[] = {
-   { 23, char54_stroke0 },
-};
-
-/* char: 55 '7' */
-
-static const CoordRec char55_stroke0[] = {
-    { 72.2267, 100 },
-    { 24.6076, 0 },
-};
-
-static const CoordRec char55_stroke1[] = {
-    { 5.56, 100 },
-    { 72.2267, 100 },
-};
-
-static const StrokeRec char55[] = {
-   { 2, char55_stroke0 },
-   { 2, char55_stroke1 },
-};
-
-/* char: 56 '8' */
-
-static const CoordRec char56_stroke0[] = {
-    { 29.4095, 100 },
-    { 15.1238, 95.2381 },
-    { 10.3619, 85.7143 },
-    { 10.3619, 76.1905 },
-    { 15.1238, 66.6667 },
-    { 24.6476, 61.9048 },
-    { 43.6952, 57.1429 },
-    { 57.981, 52.381 },
-    { 67.5048, 42.8571 },
-    { 72.2667, 33.3333 },
-    { 72.2667, 19.0476 },
-    { 67.5048, 9.5238 },
-    { 62.7429, 4.7619 },
-    { 48.4571, 0 },
-    { 29.4095, 0 },
-    { 15.1238, 4.7619 },
-    { 10.3619, 9.5238 },
-    { 5.6, 19.0476 },
-    { 5.6, 33.3333 },
-    { 10.3619, 42.8571 },
-    { 19.8857, 52.381 },
-    { 34.1714, 57.1429 },
-    { 53.219, 61.9048 },
-    { 62.7429, 66.6667 },
-    { 67.5048, 76.1905 },
-    { 67.5048, 85.7143 },
-    { 62.7429, 95.2381 },
-    { 48.4571, 100 },
-    { 29.4095, 100 },
-};
-
-static const StrokeRec char56[] = {
-   { 29, char56_stroke0 },
-};
-
-/* char: 57 '9' */
-
-static const CoordRec char57_stroke0[] = {
-    { 68.5048, 66.6667 },
-    { 63.7429, 52.381 },
-    { 54.219, 42.8571 },
-    { 39.9333, 38.0952 },
-    { 35.1714, 38.0952 },
-    { 20.8857, 42.8571 },
-    { 11.3619, 52.381 },
-    { 6.6, 66.6667 },
-    { 6.6, 71.4286 },
-    { 11.3619, 85.7143 },
-    { 20.8857, 95.2381 },
-    { 35.1714, 100 },
-    { 39.9333, 100 },
-    { 54.219, 95.2381 },
-    { 63.7429, 85.7143 },
-    { 68.5048, 66.6667 },
-    { 68.5048, 42.8571 },
-    { 63.7429, 19.0476 },
-    { 54.219, 4.7619 },
-    { 39.9333, 0 },
-    { 30.4095, 0 },
-    { 16.1238, 4.7619 },
-    { 11.3619, 14.2857 },
-};
-
-static const StrokeRec char57[] = {
-   { 23, char57_stroke0 },
-};
-
-/* char: 58 ':' */
-
-static const CoordRec char58_stroke0[] = {
-    { 14.0819, 66.6667 },
-    { 9.32, 61.9048 },
-    { 14.0819, 57.1429 },
-    { 18.8438, 61.9048 },
-    { 14.0819, 66.6667 },
-};
-
-static const CoordRec char58_stroke1[] = {
-    { 14.0819, 9.5238 },
-    { 9.32, 4.7619 },
-    { 14.0819, 0 },
-    { 18.8438, 4.7619 },
-    { 14.0819, 9.5238 },
-};
-
-static const StrokeRec char58[] = {
-   { 5, char58_stroke0 },
-   { 5, char58_stroke1 },
-};
-
-/* char: 59 ';' */
-
-static const CoordRec char59_stroke0[] = {
-    { 12.9619, 66.6667 },
-    { 8.2, 61.9048 },
-    { 12.9619, 57.1429 },
-    { 17.7238, 61.9048 },
-    { 12.9619, 66.6667 },
-};
-
-static const CoordRec char59_stroke1[] = {
-    { 17.7238, 4.7619 },
-    { 12.9619, 0 },
-    { 8.2, 4.7619 },
-    { 12.9619, 9.5238 },
-    { 17.7238, 4.7619 },
-    { 17.7238, -4.7619 },
-    { 12.9619, -14.2857 },
-    { 8.2, -19.0476 },
-};
-
-static const StrokeRec char59[] = {
-   { 5, char59_stroke0 },
-   { 8, char59_stroke1 },
-};
-
-/* char: 60 '<' */
-
-static const CoordRec char60_stroke0[] = {
-    { 79.2505, 85.7143 },
-    { 3.06, 42.8571 },
-    { 79.2505, 0 },
-};
-
-static const StrokeRec char60[] = {
-   { 3, char60_stroke0 },
-};
-
-/* char: 61 '=' */
-
-static const CoordRec char61_stroke0[] = {
-    { 5.7, 57.1429 },
-    { 91.4143, 57.1429 },
-};
-
-static const CoordRec char61_stroke1[] = {
-    { 5.7, 28.5714 },
-    { 91.4143, 28.5714 },
-};
-
-static const StrokeRec char61[] = {
-   { 2, char61_stroke0 },
-   { 2, char61_stroke1 },
-};
-
-/* char: 62 '>' */
-
-static const CoordRec char62_stroke0[] = {
-    { 2.78, 85.7143 },
-    { 78.9705, 42.8571 },
-    { 2.78, 0 },
-};
-
-static const StrokeRec char62[] = {
-   { 3, char62_stroke0 },
-};
-
-/* char: 63 '?' */
-
-static const CoordRec char63_stroke0[] = {
-    { 8.42, 76.1905 },
-    { 8.42, 80.9524 },
-    { 13.1819, 90.4762 },
-    { 17.9438, 95.2381 },
-    { 27.4676, 100 },
-    { 46.5152, 100 },
-    { 56.039, 95.2381 },
-    { 60.801, 90.4762 },
-    { 65.5629, 80.9524 },
-    { 65.5629, 71.4286 },
-    { 60.801, 61.9048 },
-    { 56.039, 57.1429 },
-    { 36.9914, 47.619 },
-    { 36.9914, 33.3333 },
-};
-
-static const CoordRec char63_stroke1[] = {
-    { 36.9914, 9.5238 },
-    { 32.2295, 4.7619 },
-    { 36.9914, 0 },
-    { 41.7533, 4.7619 },
-    { 36.9914, 9.5238 },
-};
-
-static const StrokeRec char63[] = {
-   { 14, char63_stroke0 },
-   { 5, char63_stroke1 },
-};
-
-/* char: 64 '@' */
-
-static const CoordRec char64_stroke0[] = {
-    { 49.2171, 52.381 },
-    { 39.6933, 57.1429 },
-    { 30.1695, 57.1429 },
-    { 25.4076, 47.619 },
-    { 25.4076, 42.8571 },
-    { 30.1695, 33.3333 },
-    { 39.6933, 33.3333 },
-    { 49.2171, 38.0952 },
-};
-
-static const CoordRec char64_stroke1[] = {
-    { 49.2171, 57.1429 },
-    { 49.2171, 38.0952 },
-    { 53.979, 33.3333 },
-    { 63.5029, 33.3333 },
-    { 68.2648, 42.8571 },
-    { 68.2648, 47.619 },
-    { 63.5029, 61.9048 },
-    { 53.979, 71.4286 },
-    { 39.6933, 76.1905 },
-    { 34.9314, 76.1905 },
-    { 20.6457, 71.4286 },
-    { 11.1219, 61.9048 },
-    { 6.36, 47.619 },
-    { 6.36, 42.8571 },
-    { 11.1219, 28.5714 },
-    { 20.6457, 19.0476 },
-    { 34.9314, 14.2857 },
-    { 39.6933, 14.2857 },
-    { 53.979, 19.0476 },
-};
-
-static const StrokeRec char64[] = {
-   { 8, char64_stroke0 },
-   { 19, char64_stroke1 },
-};
-
-/* char: 65 'A' */
-
-static const CoordRec char65_stroke0[] = {
-    { 40.5952, 100 },
-    { 2.5, 0 },
-};
-
-static const CoordRec char65_stroke1[] = {
-    { 40.5952, 100 },
-    { 78.6905, 0 },
-};
-
-static const CoordRec char65_stroke2[] = {
-    { 16.7857, 33.3333 },
-    { 64.4048, 33.3333 },
-};
-
-static const StrokeRec char65[] = {
-   { 2, char65_stroke0 },
-   { 2, char65_stroke1 },
-   { 2, char65_stroke2 },
-};
-
-/* char: 66 'B' */
-
-static const CoordRec char66_stroke0[] = {
-    { 11.42, 100 },
-    { 11.42, 0 },
-};
-
-static const CoordRec char66_stroke1[] = {
-    { 11.42, 100 },
-    { 54.2771, 100 },
-    { 68.5629, 95.2381 },
-    { 73.3248, 90.4762 },
-    { 78.0867, 80.9524 },
-    { 78.0867, 71.4286 },
-    { 73.3248, 61.9048 },
-    { 68.5629, 57.1429 },
-    { 54.2771, 52.381 },
-};
-
-static const CoordRec char66_stroke2[] = {
-    { 11.42, 52.381 },
-    { 54.2771, 52.381 },
-    { 68.5629, 47.619 },
-    { 73.3248, 42.8571 },
-    { 78.0867, 33.3333 },
-    { 78.0867, 19.0476 },
-    { 73.3248, 9.5238 },
-    { 68.5629, 4.7619 },
-    { 54.2771, 0 },
-    { 11.42, 0 },
-};
-
-static const StrokeRec char66[] = {
-   { 2, char66_stroke0 },
-   { 9, char66_stroke1 },
-   { 10, char66_stroke2 },
-};
-
-/* char: 67 'C' */
-
-static const CoordRec char67_stroke0[] = {
-    { 78.0886, 76.1905 },
-    { 73.3267, 85.7143 },
-    { 63.8029, 95.2381 },
-    { 54.279, 100 },
-    { 35.2314, 100 },
-    { 25.7076, 95.2381 },
-    { 16.1838, 85.7143 },
-    { 11.4219, 76.1905 },
-    { 6.66, 61.9048 },
-    { 6.66, 38.0952 },
-    { 11.4219, 23.8095 },
-    { 16.1838, 14.2857 },
-    { 25.7076, 4.7619 },
-    { 35.2314, 0 },
-    { 54.279, 0 },
-    { 63.8029, 4.7619 },
-    { 73.3267, 14.2857 },
-    { 78.0886, 23.8095 },
-};
-
-static const StrokeRec char67[] = {
-   { 18, char67_stroke0 },
-};
-
-/* char: 68 'D' */
-
-static const CoordRec char68_stroke0[] = {
-    { 11.96, 100 },
-    { 11.96, 0 },
-};
-
-static const CoordRec char68_stroke1[] = {
-    { 11.96, 100 },
-    { 45.2933, 100 },
-    { 59.579, 95.2381 },
-    { 69.1029, 85.7143 },
-    { 73.8648, 76.1905 },
-    { 78.6267, 61.9048 },
-    { 78.6267, 38.0952 },
-    { 73.8648, 23.8095 },
-    { 69.1029, 14.2857 },
-    { 59.579, 4.7619 },
-    { 45.2933, 0 },
-    { 11.96, 0 },
-};
-
-static const StrokeRec char68[] = {
-   { 2, char68_stroke0 },
-   { 12, char68_stroke1 },
-};
-
-/* char: 69 'E' */
-
-static const CoordRec char69_stroke0[] = {
-    { 11.42, 100 },
-    { 11.42, 0 },
-};
-
-static const CoordRec char69_stroke1[] = {
-    { 11.42, 100 },
-    { 73.3248, 100 },
-};
-
-static const CoordRec char69_stroke2[] = {
-    { 11.42, 52.381 },
-    { 49.5152, 52.381 },
-};
-
-static const CoordRec char69_stroke3[] = {
-    { 11.42, 0 },
-    { 73.3248, 0 },
-};
-
-static const StrokeRec char69[] = {
-   { 2, char69_stroke0 },
-   { 2, char69_stroke1 },
-   { 2, char69_stroke2 },
-   { 2, char69_stroke3 },
-};
-
-/* char: 70 'F' */
-
-static const CoordRec char70_stroke0[] = {
-    { 11.42, 100 },
-    { 11.42, 0 },
-};
-
-static const CoordRec char70_stroke1[] = {
-    { 11.42, 100 },
-    { 73.3248, 100 },
-};
-
-static const CoordRec char70_stroke2[] = {
-    { 11.42, 52.381 },
-    { 49.5152, 52.381 },
-};
-
-static const StrokeRec char70[] = {
-   { 2, char70_stroke0 },
-   { 2, char70_stroke1 },
-   { 2, char70_stroke2 },
-};
-
-/* char: 71 'G' */
-
-static const CoordRec char71_stroke0[] = {
-    { 78.4886, 76.1905 },
-    { 73.7267, 85.7143 },
-    { 64.2029, 95.2381 },
-    { 54.679, 100 },
-    { 35.6314, 100 },
-    { 26.1076, 95.2381 },
-    { 16.5838, 85.7143 },
-    { 11.8219, 76.1905 },
-    { 7.06, 61.9048 },
-    { 7.06, 38.0952 },
-    { 11.8219, 23.8095 },
-    { 16.5838, 14.2857 },
-    { 26.1076, 4.7619 },
-    { 35.6314, 0 },
-    { 54.679, 0 },
-    { 64.2029, 4.7619 },
-    { 73.7267, 14.2857 },
-    { 78.4886, 23.8095 },
-    { 78.4886, 38.0952 },
-};
-
-static const CoordRec char71_stroke1[] = {
-    { 54.679, 38.0952 },
-    { 78.4886, 38.0952 },
-};
-
-static const StrokeRec char71[] = {
-   { 19, char71_stroke0 },
-   { 2, char71_stroke1 },
-};
-
-/* char: 72 'H' */
-
-static const CoordRec char72_stroke0[] = {
-    { 11.42, 100 },
-    { 11.42, 0 },
-};
-
-static const CoordRec char72_stroke1[] = {
-    { 78.0867, 100 },
-    { 78.0867, 0 },
-};
-
-static const CoordRec char72_stroke2[] = {
-    { 11.42, 52.381 },
-    { 78.0867, 52.381 },
-};
-
-static const StrokeRec char72[] = {
-   { 2, char72_stroke0 },
-   { 2, char72_stroke1 },
-   { 2, char72_stroke2 },
-};
-
-/* char: 73 'I' */
-
-static const CoordRec char73_stroke0[] = {
-    { 10.86, 100 },
-    { 10.86, 0 },
-};
-
-static const StrokeRec char73[] = {
-   { 2, char73_stroke0 },
-};
-
-/* char: 74 'J' */
-
-static const CoordRec char74_stroke0[] = {
-    { 50.119, 100 },
-    { 50.119, 23.8095 },
-    { 45.3571, 9.5238 },
-    { 40.5952, 4.7619 },
-    { 31.0714, 0 },
-    { 21.5476, 0 },
-    { 12.0238, 4.7619 },
-    { 7.2619, 9.5238 },
-    { 2.5, 23.8095 },
-    { 2.5, 33.3333 },
-};
-
-static const StrokeRec char74[] = {
-   { 10, char74_stroke0 },
-};
-
-/* char: 75 'K' */
-
-static const CoordRec char75_stroke0[] = {
-    { 11.28, 100 },
-    { 11.28, 0 },
-};
-
-static const CoordRec char75_stroke1[] = {
-    { 77.9467, 100 },
-    { 11.28, 33.3333 },
-};
-
-static const CoordRec char75_stroke2[] = {
-    { 35.0895, 57.1429 },
-    { 77.9467, 0 },
-};
-
-static const StrokeRec char75[] = {
-   { 2, char75_stroke0 },
-   { 2, char75_stroke1 },
-   { 2, char75_stroke2 },
-};
-
-/* char: 76 'L' */
-
-static const CoordRec char76_stroke0[] = {
-    { 11.68, 100 },
-    { 11.68, 0 },
-};
-
-static const CoordRec char76_stroke1[] = {
-    { 11.68, 0 },
-    { 68.8229, 0 },
-};
-
-static const StrokeRec char76[] = {
-   { 2, char76_stroke0 },
-   { 2, char76_stroke1 },
-};
-
-/* char: 77 'M' */
-
-static const CoordRec char77_stroke0[] = {
-    { 10.86, 100 },
-    { 10.86, 0 },
-};
-
-static const CoordRec char77_stroke1[] = {
-    { 10.86, 100 },
-    { 48.9552, 0 },
-};
-
-static const CoordRec char77_stroke2[] = {
-    { 87.0505, 100 },
-    { 48.9552, 0 },
-};
-
-static const CoordRec char77_stroke3[] = {
-    { 87.0505, 100 },
-    { 87.0505, 0 },
-};
-
-static const StrokeRec char77[] = {
-   { 2, char77_stroke0 },
-   { 2, char77_stroke1 },
-   { 2, char77_stroke2 },
-   { 2, char77_stroke3 },
-};
-
-/* char: 78 'N' */
-
-static const CoordRec char78_stroke0[] = {
-    { 11.14, 100 },
-    { 11.14, 0 },
-};
-
-static const CoordRec char78_stroke1[] = {
-    { 11.14, 100 },
-    { 77.8067, 0 },
-};
-
-static const CoordRec char78_stroke2[] = {
-    { 77.8067, 100 },
-    { 77.8067, 0 },
-};
-
-static const StrokeRec char78[] = {
-   { 2, char78_stroke0 },
-   { 2, char78_stroke1 },
-   { 2, char78_stroke2 },
-};
-
-/* char: 79 'O' */
-
-static const CoordRec char79_stroke0[] = {
-    { 34.8114, 100 },
-    { 25.2876, 95.2381 },
-    { 15.7638, 85.7143 },
-    { 11.0019, 76.1905 },
-    { 6.24, 61.9048 },
-    { 6.24, 38.0952 },
-    { 11.0019, 23.8095 },
-    { 15.7638, 14.2857 },
-    { 25.2876, 4.7619 },
-    { 34.8114, 0 },
-    { 53.859, 0 },
-    { 63.3829, 4.7619 },
-    { 72.9067, 14.2857 },
-    { 77.6686, 23.8095 },
-    { 82.4305, 38.0952 },
-    { 82.4305, 61.9048 },
-    { 77.6686, 76.1905 },
-    { 72.9067, 85.7143 },
-    { 63.3829, 95.2381 },
-    { 53.859, 100 },
-    { 34.8114, 100 },
-};
-
-static const StrokeRec char79[] = {
-   { 21, char79_stroke0 },
-};
-
-/* char: 80 'P' */
-
-static const CoordRec char80_stroke0[] = {
-    { 12.1, 100 },
-    { 12.1, 0 },
-};
-
-static const CoordRec char80_stroke1[] = {
-    { 12.1, 100 },
-    { 54.9571, 100 },
-    { 69.2429, 95.2381 },
-    { 74.0048, 90.4762 },
-    { 78.7667, 80.9524 },
-    { 78.7667, 66.6667 },
-    { 74.0048, 57.1429 },
-    { 69.2429, 52.381 },
-    { 54.9571, 47.619 },
-    { 12.1, 47.619 },
-};
-
-static const StrokeRec char80[] = {
-   { 2, char80_stroke0 },
-   { 10, char80_stroke1 },
-};
-
-/* char: 81 'Q' */
-
-static const CoordRec char81_stroke0[] = {
-    { 33.8714, 100 },
-    { 24.3476, 95.2381 },
-    { 14.8238, 85.7143 },
-    { 10.0619, 76.1905 },
-    { 5.3, 61.9048 },
-    { 5.3, 38.0952 },
-    { 10.0619, 23.8095 },
-    { 14.8238, 14.2857 },
-    { 24.3476, 4.7619 },
-    { 33.8714, 0 },
-    { 52.919, 0 },
-    { 62.4429, 4.7619 },
-    { 71.9667, 14.2857 },
-    { 76.7286, 23.8095 },
-    { 81.4905, 38.0952 },
-    { 81.4905, 61.9048 },
-    { 76.7286, 76.1905 },
-    { 71.9667, 85.7143 },
-    { 62.4429, 95.2381 },
-    { 52.919, 100 },
-    { 33.8714, 100 },
-};
-
-static const CoordRec char81_stroke1[] = {
-    { 48.1571, 19.0476 },
-    { 76.7286, -9.5238 },
-};
-
-static const StrokeRec char81[] = {
-   { 21, char81_stroke0 },
-   { 2, char81_stroke1 },
-};
-
-/* char: 82 'R' */
-
-static const CoordRec char82_stroke0[] = {
-    { 11.68, 100 },
-    { 11.68, 0 },
-};
-
-static const CoordRec char82_stroke1[] = {
-    { 11.68, 100 },
-    { 54.5371, 100 },
-    { 68.8229, 95.2381 },
-    { 73.5848, 90.4762 },
-    { 78.3467, 80.9524 },
-    { 78.3467, 71.4286 },
-    { 73.5848, 61.9048 },
-    { 68.8229, 57.1429 },
-    { 54.5371, 52.381 },
-    { 11.68, 52.381 },
-};
-
-static const CoordRec char82_stroke2[] = {
-    { 45.0133, 52.381 },
-    { 78.3467, 0 },
-};
-
-static const StrokeRec char82[] = {
-   { 2, char82_stroke0 },
-   { 10, char82_stroke1 },
-   { 2, char82_stroke2 },
-};
-
-/* char: 83 'S' */
-
-static const CoordRec char83_stroke0[] = {
-    { 74.6667, 85.7143 },
-    { 65.1429, 95.2381 },
-    { 50.8571, 100 },
-    { 31.8095, 100 },
-    { 17.5238, 95.2381 },
-    { 8, 85.7143 },
-    { 8, 76.1905 },
-    { 12.7619, 66.6667 },
-    { 17.5238, 61.9048 },
-    { 27.0476, 57.1429 },
-    { 55.619, 47.619 },
-    { 65.1429, 42.8571 },
-    { 69.9048, 38.0952 },
-    { 74.6667, 28.5714 },
-    { 74.6667, 14.2857 },
-    { 65.1429, 4.7619 },
-    { 50.8571, 0 },
-    { 31.8095, 0 },
-    { 17.5238, 4.7619 },
-    { 8, 14.2857 },
-};
-
-static const StrokeRec char83[] = {
-   { 20, char83_stroke0 },
-};
-
-/* char: 84 'T' */
-
-static const CoordRec char84_stroke0[] = {
-    { 35.6933, 100 },
-    { 35.6933, 0 },
-};
-
-static const CoordRec char84_stroke1[] = {
-    { 2.36, 100 },
-    { 69.0267, 100 },
-};
-
-static const StrokeRec char84[] = {
-   { 2, char84_stroke0 },
-   { 2, char84_stroke1 },
-};
-
-/* char: 85 'U' */
-
-static const CoordRec char85_stroke0[] = {
-    { 11.54, 100 },
-    { 11.54, 28.5714 },
-    { 16.3019, 14.2857 },
-    { 25.8257, 4.7619 },
-    { 40.1114, 0 },
-    { 49.6352, 0 },
-    { 63.921, 4.7619 },
-    { 73.4448, 14.2857 },
-    { 78.2067, 28.5714 },
-    { 78.2067, 100 },
-};
-
-static const StrokeRec char85[] = {
-   { 10, char85_stroke0 },
-};
-
-/* char: 86 'V' */
-
-static const CoordRec char86_stroke0[] = {
-    { 2.36, 100 },
-    { 40.4552, 0 },
-};
-
-static const CoordRec char86_stroke1[] = {
-    { 78.5505, 100 },
-    { 40.4552, 0 },
-};
-
-static const StrokeRec char86[] = {
-   { 2, char86_stroke0 },
-   { 2, char86_stroke1 },
-};
-
-/* char: 87 'W' */
-
-static const CoordRec char87_stroke0[] = {
-    { 2.22, 100 },
-    { 26.0295, 0 },
-};
-
-static const CoordRec char87_stroke1[] = {
-    { 49.839, 100 },
-    { 26.0295, 0 },
-};
-
-static const CoordRec char87_stroke2[] = {
-    { 49.839, 100 },
-    { 73.6486, 0 },
-};
-
-static const CoordRec char87_stroke3[] = {
-    { 97.4581, 100 },
-    { 73.6486, 0 },
-};
-
-static const StrokeRec char87[] = {
-   { 2, char87_stroke0 },
-   { 2, char87_stroke1 },
-   { 2, char87_stroke2 },
-   { 2, char87_stroke3 },
-};
-
-/* char: 88 'X' */
-
-static const CoordRec char88_stroke0[] = {
-    { 2.5, 100 },
-    { 69.1667, 0 },
-};
-
-static const CoordRec char88_stroke1[] = {
-    { 69.1667, 100 },
-    { 2.5, 0 },
-};
-
-static const StrokeRec char88[] = {
-   { 2, char88_stroke0 },
-   { 2, char88_stroke1 },
-};
-
-/* char: 89 'Y' */
-
-static const CoordRec char89_stroke0[] = {
-    { 1.52, 100 },
-    { 39.6152, 52.381 },
-    { 39.6152, 0 },
-};
-
-static const CoordRec char89_stroke1[] = {
-    { 77.7105, 100 },
-    { 39.6152, 52.381 },
-};
-
-static const StrokeRec char89[] = {
-   { 3, char89_stroke0 },
-   { 2, char89_stroke1 },
-};
-
-/* char: 90 'Z' */
-
-static const CoordRec char90_stroke0[] = {
-    { 69.1667, 100 },
-    { 2.5, 0 },
-};
-
-static const CoordRec char90_stroke1[] = {
-    { 2.5, 100 },
-    { 69.1667, 100 },
-};
-
-static const CoordRec char90_stroke2[] = {
-    { 2.5, 0 },
-    { 69.1667, 0 },
-};
-
-static const StrokeRec char90[] = {
-   { 2, char90_stroke0 },
-   { 2, char90_stroke1 },
-   { 2, char90_stroke2 },
-};
-
-/* char: 91 '[' */
-
-static const CoordRec char91_stroke0[] = {
-    { 7.78, 119.048 },
-    { 7.78, -33.3333 },
-};
-
-static const CoordRec char91_stroke1[] = {
-    { 12.5419, 119.048 },
-    { 12.5419, -33.3333 },
-};
-
-static const CoordRec char91_stroke2[] = {
-    { 7.78, 119.048 },
-    { 41.1133, 119.048 },
-};
-
-static const CoordRec char91_stroke3[] = {
-    { 7.78, -33.3333 },
-    { 41.1133, -33.3333 },
-};
-
-static const StrokeRec char91[] = {
-   { 2, char91_stroke0 },
-   { 2, char91_stroke1 },
-   { 2, char91_stroke2 },
-   { 2, char91_stroke3 },
-};
-
-/* char: 92 '\' */
-
-static const CoordRec char92_stroke0[] = {
-    { 5.84, 100 },
-    { 72.5067, -14.2857 },
-};
-
-static const StrokeRec char92[] = {
-   { 2, char92_stroke0 },
-};
-
-/* char: 93 ']' */
-
-static const CoordRec char93_stroke0[] = {
-    { 33.0114, 119.048 },
-    { 33.0114, -33.3333 },
-};
-
-static const CoordRec char93_stroke1[] = {
-    { 37.7733, 119.048 },
-    { 37.7733, -33.3333 },
-};
-
-static const CoordRec char93_stroke2[] = {
-    { 4.44, 119.048 },
-    { 37.7733, 119.048 },
-};
-
-static const CoordRec char93_stroke3[] = {
-    { 4.44, -33.3333 },
-    { 37.7733, -33.3333 },
-};
-
-static const StrokeRec char93[] = {
-   { 2, char93_stroke0 },
-   { 2, char93_stroke1 },
-   { 2, char93_stroke2 },
-   { 2, char93_stroke3 },
-};
-
-/* char: 94 '^' */
-
-static const CoordRec char94_stroke0[] = {
-    { 44.0752, 109.524 },
-    { 5.98, 42.8571 },
-};
-
-static const CoordRec char94_stroke1[] = {
-    { 44.0752, 109.524 },
-    { 82.1705, 42.8571 },
-};
-
-static const StrokeRec char94[] = {
-   { 2, char94_stroke0 },
-   { 2, char94_stroke1 },
-};
-
-/* char: 95 '_' */
-
-static const CoordRec char95_stroke0[] = {
-    { -1.1, -33.3333 },
-    { 103.662, -33.3333 },
-    { 103.662, -28.5714 },
-    { -1.1, -28.5714 },
-    { -1.1, -33.3333 },
-};
-
-static const StrokeRec char95[] = {
-   { 5, char95_stroke0 },
-};
-
-/* char: 96 '`' */
-
-static const CoordRec char96_stroke0[] = {
-    { 33.0219, 100 },
-    { 56.8314, 71.4286 },
-};
-
-static const CoordRec char96_stroke1[] = {
-    { 33.0219, 100 },
-    { 28.26, 95.2381 },
-    { 56.8314, 71.4286 },
-};
-
-static const StrokeRec char96[] = {
-   { 2, char96_stroke0 },
-   { 3, char96_stroke1 },
-};
-
-/* char: 97 'a' */
-
-static const CoordRec char97_stroke0[] = {
-    { 63.8229, 66.6667 },
-    { 63.8229, 0 },
-};
-
-static const CoordRec char97_stroke1[] = {
-    { 63.8229, 52.381 },
-    { 54.299, 61.9048 },
-    { 44.7752, 66.6667 },
-    { 30.4895, 66.6667 },
-    { 20.9657, 61.9048 },
-    { 11.4419, 52.381 },
-    { 6.68, 38.0952 },
-    { 6.68, 28.5714 },
-    { 11.4419, 14.2857 },
-    { 20.9657, 4.7619 },
-    { 30.4895, 0 },
-    { 44.7752, 0 },
-    { 54.299, 4.7619 },
-    { 63.8229, 14.2857 },
-};
-
-static const StrokeRec char97[] = {
-   { 2, char97_stroke0 },
-   { 14, char97_stroke1 },
-};
-
-/* char: 98 'b' */
-
-static const CoordRec char98_stroke0[] = {
-    { 8.76, 100 },
-    { 8.76, 0 },
-};
-
-static const CoordRec char98_stroke1[] = {
-    { 8.76, 52.381 },
-    { 18.2838, 61.9048 },
-    { 27.8076, 66.6667 },
-    { 42.0933, 66.6667 },
-    { 51.6171, 61.9048 },
-    { 61.141, 52.381 },
-    { 65.9029, 38.0952 },
-    { 65.9029, 28.5714 },
-    { 61.141, 14.2857 },
-    { 51.6171, 4.7619 },
-    { 42.0933, 0 },
-    { 27.8076, 0 },
-    { 18.2838, 4.7619 },
-    { 8.76, 14.2857 },
-};
-
-static const StrokeRec char98[] = {
-   { 2, char98_stroke0 },
-   { 14, char98_stroke1 },
-};
-
-/* char: 99 'c' */
-
-static const CoordRec char99_stroke0[] = {
-    { 62.6629, 52.381 },
-    { 53.139, 61.9048 },
-    { 43.6152, 66.6667 },
-    { 29.3295, 66.6667 },
-    { 19.8057, 61.9048 },
-    { 10.2819, 52.381 },
-    { 5.52, 38.0952 },
-    { 5.52, 28.5714 },
-    { 10.2819, 14.2857 },
-    { 19.8057, 4.7619 },
-    { 29.3295, 0 },
-    { 43.6152, 0 },
-    { 53.139, 4.7619 },
-    { 62.6629, 14.2857 },
-};
-
-static const StrokeRec char99[] = {
-   { 14, char99_stroke0 },
-};
-
-/* char: 100 'd' */
-
-static const CoordRec char100_stroke0[] = {
-    { 61.7829, 100 },
-    { 61.7829, 0 },
-};
-
-static const CoordRec char100_stroke1[] = {
-    { 61.7829, 52.381 },
-    { 52.259, 61.9048 },
-    { 42.7352, 66.6667 },
-    { 28.4495, 66.6667 },
-    { 18.9257, 61.9048 },
-    { 9.4019, 52.381 },
-    { 4.64, 38.0952 },
-    { 4.64, 28.5714 },
-    { 9.4019, 14.2857 },
-    { 18.9257, 4.7619 },
-    { 28.4495, 0 },
-    { 42.7352, 0 },
-    { 52.259, 4.7619 },
-    { 61.7829, 14.2857 },
-};
-
-static const StrokeRec char100[] = {
-   { 2, char100_stroke0 },
-   { 14, char100_stroke1 },
-};
-
-/* char: 101 'e' */
-
-static const CoordRec char101_stroke0[] = {
-    { 5.72, 38.0952 },
-    { 62.8629, 38.0952 },
-    { 62.8629, 47.619 },
-    { 58.101, 57.1429 },
-    { 53.339, 61.9048 },
-    { 43.8152, 66.6667 },
-    { 29.5295, 66.6667 },
-    { 20.0057, 61.9048 },
-    { 10.4819, 52.381 },
-    { 5.72, 38.0952 },
-    { 5.72, 28.5714 },
-    { 10.4819, 14.2857 },
-    { 20.0057, 4.7619 },
-    { 29.5295, 0 },
-    { 43.8152, 0 },
-    { 53.339, 4.7619 },
-    { 62.8629, 14.2857 },
-};
-
-static const StrokeRec char101[] = {
-   { 17, char101_stroke0 },
-};
-
-/* char: 102 'f' */
-
-static const CoordRec char102_stroke0[] = {
-    { 38.7752, 100 },
-    { 29.2514, 100 },
-    { 19.7276, 95.2381 },
-    { 14.9657, 80.9524 },
-    { 14.9657, 0 },
-};
-
-static const CoordRec char102_stroke1[] = {
-    { 0.68, 66.6667 },
-    { 34.0133, 66.6667 },
-};
-
-static const StrokeRec char102[] = {
-   { 5, char102_stroke0 },
-   { 2, char102_stroke1 },
-};
-
-/* char: 103 'g' */
-
-static const CoordRec char103_stroke0[] = {
-    { 62.5029, 66.6667 },
-    { 62.5029, -9.5238 },
-    { 57.741, -23.8095 },
-    { 52.979, -28.5714 },
-    { 43.4552, -33.3333 },
-    { 29.1695, -33.3333 },
-    { 19.6457, -28.5714 },
-};
-
-static const CoordRec char103_stroke1[] = {
-    { 62.5029, 52.381 },
-    { 52.979, 61.9048 },
-    { 43.4552, 66.6667 },
-    { 29.1695, 66.6667 },
-    { 19.6457, 61.9048 },
-    { 10.1219, 52.381 },
-    { 5.36, 38.0952 },
-    { 5.36, 28.5714 },
-    { 10.1219, 14.2857 },
-    { 19.6457, 4.7619 },
-    { 29.1695, 0 },
-    { 43.4552, 0 },
-    { 52.979, 4.7619 },
-    { 62.5029, 14.2857 },
-};
-
-static const StrokeRec char103[] = {
-   { 7, char103_stroke0 },
-   { 14, char103_stroke1 },
-};
-
-/* char: 104 'h' */
-
-static const CoordRec char104_stroke0[] = {
-    { 9.6, 100 },
-    { 9.6, 0 },
-};
-
-static const CoordRec char104_stroke1[] = {
-    { 9.6, 47.619 },
-    { 23.8857, 61.9048 },
-    { 33.4095, 66.6667 },
-    { 47.6952, 66.6667 },
-    { 57.219, 61.9048 },
-    { 61.981, 47.619 },
-    { 61.981, 0 },
-};
-
-static const StrokeRec char104[] = {
-   { 2, char104_stroke0 },
-   { 7, char104_stroke1 },
-};
-
-/* char: 105 'i' */
-
-static const CoordRec char105_stroke0[] = {
-    { 10.02, 100 },
-    { 14.7819, 95.2381 },
-    { 19.5438, 100 },
-    { 14.7819, 104.762 },
-    { 10.02, 100 },
-};
-
-static const CoordRec char105_stroke1[] = {
-    { 14.7819, 66.6667 },
-    { 14.7819, 0 },
-};
-
-static const StrokeRec char105[] = {
-   { 5, char105_stroke0 },
-   { 2, char105_stroke1 },
-};
-
-/* char: 106 'j' */
-
-static const CoordRec char106_stroke0[] = {
-    { 17.3876, 100 },
-    { 22.1495, 95.2381 },
-    { 26.9114, 100 },
-    { 22.1495, 104.762 },
-    { 17.3876, 100 },
-};
-
-static const CoordRec char106_stroke1[] = {
-    { 22.1495, 66.6667 },
-    { 22.1495, -14.2857 },
-    { 17.3876, -28.5714 },
-    { 7.8638, -33.3333 },
-    { -1.66, -33.3333 },
-};
-
-static const StrokeRec char106[] = {
-   { 5, char106_stroke0 },
-   { 5, char106_stroke1 },
-};
-
-/* char: 107 'k' */
-
-static const CoordRec char107_stroke0[] = {
-    { 9.6, 100 },
-    { 9.6, 0 },
-};
-
-static const CoordRec char107_stroke1[] = {
-    { 57.219, 66.6667 },
-    { 9.6, 19.0476 },
-};
-
-static const CoordRec char107_stroke2[] = {
-    { 28.6476, 38.0952 },
-    { 61.981, 0 },
-};
-
-static const StrokeRec char107[] = {
-   { 2, char107_stroke0 },
-   { 2, char107_stroke1 },
-   { 2, char107_stroke2 },
-};
-
-/* char: 108 'l' */
-
-static const CoordRec char108_stroke0[] = {
-    { 10.02, 100 },
-    { 10.02, 0 },
-};
-
-static const StrokeRec char108[] = {
-   { 2, char108_stroke0 },
-};
-
-/* char: 109 'm' */
-
-static const CoordRec char109_stroke0[] = {
-    { 9.6, 66.6667 },
-    { 9.6, 0 },
-};
-
-static const CoordRec char109_stroke1[] = {
-    { 9.6, 47.619 },
-    { 23.8857, 61.9048 },
-    { 33.4095, 66.6667 },
-    { 47.6952, 66.6667 },
-    { 57.219, 61.9048 },
-    { 61.981, 47.619 },
-    { 61.981, 0 },
-};
-
-static const CoordRec char109_stroke2[] = {
-    { 61.981, 47.619 },
-    { 76.2667, 61.9048 },
-    { 85.7905, 66.6667 },
-    { 100.076, 66.6667 },
-    { 109.6, 61.9048 },
-    { 114.362, 47.619 },
-    { 114.362, 0 },
-};
-
-static const StrokeRec char109[] = {
-   { 2, char109_stroke0 },
-   { 7, char109_stroke1 },
-   { 7, char109_stroke2 },
-};
-
-/* char: 110 'n' */
-
-static const CoordRec char110_stroke0[] = {
-    { 9.18, 66.6667 },
-    { 9.18, 0 },
-};
-
-static const CoordRec char110_stroke1[] = {
-    { 9.18, 47.619 },
-    { 23.4657, 61.9048 },
-    { 32.9895, 66.6667 },
-    { 47.2752, 66.6667 },
-    { 56.799, 61.9048 },
-    { 61.561, 47.619 },
-    { 61.561, 0 },
-};
-
-static const StrokeRec char110[] = {
-   { 2, char110_stroke0 },
-   { 7, char110_stroke1 },
-};
-
-/* char: 111 'o' */
-
-static const CoordRec char111_stroke0[] = {
-    { 28.7895, 66.6667 },
-    { 19.2657, 61.9048 },
-    { 9.7419, 52.381 },
-    { 4.98, 38.0952 },
-    { 4.98, 28.5714 },
-    { 9.7419, 14.2857 },
-    { 19.2657, 4.7619 },
-    { 28.7895, 0 },
-    { 43.0752, 0 },
-    { 52.599, 4.7619 },
-    { 62.1229, 14.2857 },
-    { 66.8848, 28.5714 },
-    { 66.8848, 38.0952 },
-    { 62.1229, 52.381 },
-    { 52.599, 61.9048 },
-    { 43.0752, 66.6667 },
-    { 28.7895, 66.6667 },
-};
-
-static const StrokeRec char111[] = {
-   { 17, char111_stroke0 },
-};
-
-/* char: 112 'p' */
-
-static const CoordRec char112_stroke0[] = {
-    { 9.46, 66.6667 },
-    { 9.46, -33.3333 },
-};
-
-static const CoordRec char112_stroke1[] = {
-    { 9.46, 52.381 },
-    { 18.9838, 61.9048 },
-    { 28.5076, 66.6667 },
-    { 42.7933, 66.6667 },
-    { 52.3171, 61.9048 },
-    { 61.841, 52.381 },
-    { 66.6029, 38.0952 },
-    { 66.6029, 28.5714 },
-    { 61.841, 14.2857 },
-    { 52.3171, 4.7619 },
-    { 42.7933, 0 },
-    { 28.5076, 0 },
-    { 18.9838, 4.7619 },
-    { 9.46, 14.2857 },
-};
-
-static const StrokeRec char112[] = {
-   { 2, char112_stroke0 },
-   { 14, char112_stroke1 },
-};
-
-/* char: 113 'q' */
-
-static const CoordRec char113_stroke0[] = {
-    { 61.9829, 66.6667 },
-    { 61.9829, -33.3333 },
-};
-
-static const CoordRec char113_stroke1[] = {
-    { 61.9829, 52.381 },
-    { 52.459, 61.9048 },
-    { 42.9352, 66.6667 },
-    { 28.6495, 66.6667 },
-    { 19.1257, 61.9048 },
-    { 9.6019, 52.381 },
-    { 4.84, 38.0952 },
-    { 4.84, 28.5714 },
-    { 9.6019, 14.2857 },
-    { 19.1257, 4.7619 },
-    { 28.6495, 0 },
-    { 42.9352, 0 },
-    { 52.459, 4.7619 },
-    { 61.9829, 14.2857 },
-};
-
-static const StrokeRec char113[] = {
-   { 2, char113_stroke0 },
-   { 14, char113_stroke1 },
-};
-
-/* char: 114 'r' */
-
-static const CoordRec char114_stroke0[] = {
-    { 9.46, 66.6667 },
-    { 9.46, 0 },
-};
-
-static const CoordRec char114_stroke1[] = {
-    { 9.46, 38.0952 },
-    { 14.2219, 52.381 },
-    { 23.7457, 61.9048 },
-    { 33.2695, 66.6667 },
-    { 47.5552, 66.6667 },
-};
-
-static const StrokeRec char114[] = {
-   { 2, char114_stroke0 },
-   { 5, char114_stroke1 },
-};
-
-/* char: 115 's' */
-
-static const CoordRec char115_stroke0[] = {
-    { 57.081, 52.381 },
-    { 52.319, 61.9048 },
-    { 38.0333, 66.6667 },
-    { 23.7476, 66.6667 },
-    { 9.4619, 61.9048 },
-    { 4.7, 52.381 },
-    { 9.4619, 42.8571 },
-    { 18.9857, 38.0952 },
-    { 42.7952, 33.3333 },
-    { 52.319, 28.5714 },
-    { 57.081, 19.0476 },
-    { 57.081, 14.2857 },
-    { 52.319, 4.7619 },
-    { 38.0333, 0 },
-    { 23.7476, 0 },
-    { 9.4619, 4.7619 },
-    { 4.7, 14.2857 },
-};
-
-static const StrokeRec char115[] = {
-   { 17, char115_stroke0 },
-};
-
-/* char: 116 't' */
-
-static const CoordRec char116_stroke0[] = {
-    { 14.8257, 100 },
-    { 14.8257, 19.0476 },
-    { 19.5876, 4.7619 },
-    { 29.1114, 0 },
-    { 38.6352, 0 },
-};
-
-static const CoordRec char116_stroke1[] = {
-    { 0.54, 66.6667 },
-    { 33.8733, 66.6667 },
-};
-
-static const StrokeRec char116[] = {
-   { 5, char116_stroke0 },
-   { 2, char116_stroke1 },
-};
-
-/* char: 117 'u' */
-
-static const CoordRec char117_stroke0[] = {
-    { 9.46, 66.6667 },
-    { 9.46, 19.0476 },
-    { 14.2219, 4.7619 },
-    { 23.7457, 0 },
-    { 38.0314, 0 },
-    { 47.5552, 4.7619 },
-    { 61.841, 19.0476 },
-};
-
-static const CoordRec char117_stroke1[] = {
-    { 61.841, 66.6667 },
-    { 61.841, 0 },
-};
-
-static const StrokeRec char117[] = {
-   { 7, char117_stroke0 },
-   { 2, char117_stroke1 },
-};
-
-/* char: 118 'v' */
-
-static const CoordRec char118_stroke0[] = {
-    { 1.8, 66.6667 },
-    { 30.3714, 0 },
-};
-
-static const CoordRec char118_stroke1[] = {
-    { 58.9429, 66.6667 },
-    { 30.3714, 0 },
-};
-
-static const StrokeRec char118[] = {
-   { 2, char118_stroke0 },
-   { 2, char118_stroke1 },
-};
-
-/* char: 119 'w' */
-
-static const CoordRec char119_stroke0[] = {
-    { 2.5, 66.6667 },
-    { 21.5476, 0 },
-};
-
-static const CoordRec char119_stroke1[] = {
-    { 40.5952, 66.6667 },
-    { 21.5476, 0 },
-};
-
-static const CoordRec char119_stroke2[] = {
-    { 40.5952, 66.6667 },
-    { 59.6429, 0 },
-};
-
-static const CoordRec char119_stroke3[] = {
-    { 78.6905, 66.6667 },
-    { 59.6429, 0 },
-};
-
-static const StrokeRec char119[] = {
-   { 2, char119_stroke0 },
-   { 2, char119_stroke1 },
-   { 2, char119_stroke2 },
-   { 2, char119_stroke3 },
-};
-
-/* char: 120 'x' */
-
-static const CoordRec char120_stroke0[] = {
-    { 1.66, 66.6667 },
-    { 54.041, 0 },
-};
-
-static const CoordRec char120_stroke1[] = {
-    { 54.041, 66.6667 },
-    { 1.66, 0 },
-};
-
-static const StrokeRec char120[] = {
-   { 2, char120_stroke0 },
-   { 2, char120_stroke1 },
-};
-
-/* char: 121 'y' */
-
-static const CoordRec char121_stroke0[] = {
-    { 6.5619, 66.6667 },
-    { 35.1333, 0 },
-};
-
-static const CoordRec char121_stroke1[] = {
-    { 63.7048, 66.6667 },
-    { 35.1333, 0 },
-    { 25.6095, -19.0476 },
-    { 16.0857, -28.5714 },
-    { 6.5619, -33.3333 },
-    { 1.8, -33.3333 },
-};
-
-static const StrokeRec char121[] = {
-   { 2, char121_stroke0 },
-   { 6, char121_stroke1 },
-};
-
-/* char: 122 'z' */
-
-static const CoordRec char122_stroke0[] = {
-    { 56.821, 66.6667 },
-    { 4.44, 0 },
-};
-
-static const CoordRec char122_stroke1[] = {
-    { 4.44, 66.6667 },
-    { 56.821, 66.6667 },
-};
-
-static const CoordRec char122_stroke2[] = {
-    { 4.44, 0 },
-    { 56.821, 0 },
-};
-
-static const StrokeRec char122[] = {
-   { 2, char122_stroke0 },
-   { 2, char122_stroke1 },
-   { 2, char122_stroke2 },
-};
-
-/* char: 123 '{' */
-
-static const CoordRec char123_stroke0[] = {
-    { 31.1895, 119.048 },
-    { 21.6657, 114.286 },
-    { 16.9038, 109.524 },
-    { 12.1419, 100 },
-    { 12.1419, 90.4762 },
-    { 16.9038, 80.9524 },
-    { 21.6657, 76.1905 },
-    { 26.4276, 66.6667 },
-    { 26.4276, 57.1429 },
-    { 16.9038, 47.619 },
-};
-
-static const CoordRec char123_stroke1[] = {
-    { 21.6657, 114.286 },
-    { 16.9038, 104.762 },
-    { 16.9038, 95.2381 },
-    { 21.6657, 85.7143 },
-    { 26.4276, 80.9524 },
-    { 31.1895, 71.4286 },
-    { 31.1895, 61.9048 },
-    { 26.4276, 52.381 },
-    { 7.38, 42.8571 },
-    { 26.4276, 33.3333 },
-    { 31.1895, 23.8095 },
-    { 31.1895, 14.2857 },
-    { 26.4276, 4.7619 },
-    { 21.6657, 0 },
-    { 16.9038, -9.5238 },
-    { 16.9038, -19.0476 },
-    { 21.6657, -28.5714 },
-};
-
-static const CoordRec char123_stroke2[] = {
-    { 16.9038, 38.0952 },
-    { 26.4276, 28.5714 },
-    { 26.4276, 19.0476 },
-    { 21.6657, 9.5238 },
-    { 16.9038, 4.7619 },
-    { 12.1419, -4.7619 },
-    { 12.1419, -14.2857 },
-    { 16.9038, -23.8095 },
-    { 21.6657, -28.5714 },
-    { 31.1895, -33.3333 },
-};
-
-static const StrokeRec char123[] = {
-   { 10, char123_stroke0 },
-   { 17, char123_stroke1 },
-   { 10, char123_stroke2 },
-};
-
-/* char: 124 '|' */
-
-static const CoordRec char124_stroke0[] = {
-    { 11.54, 119.048 },
-    { 11.54, -33.3333 },
-};
-
-static const StrokeRec char124[] = {
-   { 2, char124_stroke0 },
-};
-
-/* char: 125 '}' */
-
-static const CoordRec char125_stroke0[] = {
-    { 9.18, 119.048 },
-    { 18.7038, 114.286 },
-    { 23.4657, 109.524 },
-    { 28.2276, 100 },
-    { 28.2276, 90.4762 },
-    { 23.4657, 80.9524 },
-    { 18.7038, 76.1905 },
-    { 13.9419, 66.6667 },
-    { 13.9419, 57.1429 },
-    { 23.4657, 47.619 },
-};
-
-static const CoordRec char125_stroke1[] = {
-    { 18.7038, 114.286 },
-    { 23.4657, 104.762 },
-    { 23.4657, 95.2381 },
-    { 18.7038, 85.7143 },
-    { 13.9419, 80.9524 },
-    { 9.18, 71.4286 },
-    { 9.18, 61.9048 },
-    { 13.9419, 52.381 },
-    { 32.9895, 42.8571 },
-    { 13.9419, 33.3333 },
-    { 9.18, 23.8095 },
-    { 9.18, 14.2857 },
-    { 13.9419, 4.7619 },
-    { 18.7038, 0 },
-    { 23.4657, -9.5238 },
-    { 23.4657, -19.0476 },
-    { 18.7038, -28.5714 },
-};
-
-static const CoordRec char125_stroke2[] = {
-    { 23.4657, 38.0952 },
-    { 13.9419, 28.5714 },
-    { 13.9419, 19.0476 },
-    { 18.7038, 9.5238 },
-    { 23.4657, 4.7619 },
-    { 28.2276, -4.7619 },
-    { 28.2276, -14.2857 },
-    { 23.4657, -23.8095 },
-    { 18.7038, -28.5714 },
-    { 9.18, -33.3333 },
-};
-
-static const StrokeRec char125[] = {
-   { 10, char125_stroke0 },
-   { 17, char125_stroke1 },
-   { 10, char125_stroke2 },
-};
-
-/* char: 126 '~' */
-
-static const CoordRec char126_stroke0[] = {
-    { 2.92, 28.5714 },
-    { 2.92, 38.0952 },
-    { 7.6819, 52.381 },
-    { 17.2057, 57.1429 },
-    { 26.7295, 57.1429 },
-    { 36.2533, 52.381 },
-    { 55.301, 38.0952 },
-    { 64.8248, 33.3333 },
-    { 74.3486, 33.3333 },
-    { 83.8724, 38.0952 },
-    { 88.6343, 47.619 },
-};
-
-static const CoordRec char126_stroke1[] = {
-    { 2.92, 38.0952 },
-    { 7.6819, 47.619 },
-    { 17.2057, 52.381 },
-    { 26.7295, 52.381 },
-    { 36.2533, 47.619 },
-    { 55.301, 33.3333 },
-    { 64.8248, 28.5714 },
-    { 74.3486, 28.5714 },
-    { 83.8724, 33.3333 },
-    { 88.6343, 47.619 },
-    { 88.6343, 57.1429 },
-};
-
-static const StrokeRec char126[] = {
-   { 11, char126_stroke0 },
-   { 11, char126_stroke1 },
-};
-
-/* char: 127 */
-
-static const CoordRec char127_stroke0[] = {
-    { 52.381, 100 },
-    { 14.2857, -33.3333 },
-};
-
-static const CoordRec char127_stroke1[] = {
-    { 28.5714, 66.6667 },
-    { 14.2857, 61.9048 },
-    { 4.7619, 52.381 },
-    { 0, 38.0952 },
-    { 0, 23.8095 },
-    { 4.7619, 14.2857 },
-    { 14.2857, 4.7619 },
-    { 28.5714, 0 },
-    { 38.0952, 0 },
-    { 52.381, 4.7619 },
-    { 61.9048, 14.2857 },
-    { 66.6667, 28.5714 },
-    { 66.6667, 42.8571 },
-    { 61.9048, 52.381 },
-    { 52.381, 61.9048 },
-    { 38.0952, 66.6667 },
-    { 28.5714, 66.6667 },
-};
-
-static const StrokeRec char127[] = {
-   { 2, char127_stroke0 },
-   { 17, char127_stroke1 },
-};
-
-static const StrokeCharRec chars[] = {
-    { 0, /* char0 */ 0, 0, 0 },
-    { 0, /* char1 */ 0, 0, 0 },
-    { 0, /* char2 */ 0, 0, 0 },
-    { 0, /* char3 */ 0, 0, 0 },
-    { 0, /* char4 */ 0, 0, 0 },
-    { 0, /* char5 */ 0, 0, 0 },
-    { 0, /* char6 */ 0, 0, 0 },
-    { 0, /* char7 */ 0, 0, 0 },
-    { 0, /* char8 */ 0, 0, 0 },
-    { 0, /* char9 */ 0, 0, 0 },
-    { 0, /* char10 */ 0, 0, 0 },
-    { 0, /* char11 */ 0, 0, 0 },
-    { 0, /* char12 */ 0, 0, 0 },
-    { 0, /* char13 */ 0, 0, 0 },
-    { 0, /* char14 */ 0, 0, 0 },
-    { 0, /* char15 */ 0, 0, 0 },
-    { 0, /* char16 */ 0, 0, 0 },
-    { 0, /* char17 */ 0, 0, 0 },
-    { 0, /* char18 */ 0, 0, 0 },
-    { 0, /* char19 */ 0, 0, 0 },
-    { 0, /* char20 */ 0, 0, 0 },
-    { 0, /* char21 */ 0, 0, 0 },
-    { 0, /* char22 */ 0, 0, 0 },
-    { 0, /* char23 */ 0, 0, 0 },
-    { 0, /* char24 */ 0, 0, 0 },
-    { 0, /* char25 */ 0, 0, 0 },
-    { 0, /* char26 */ 0, 0, 0 },
-    { 0, /* char27 */ 0, 0, 0 },
-    { 0, /* char28 */ 0, 0, 0 },
-    { 0, /* char29 */ 0, 0, 0 },
-    { 0, /* char30 */ 0, 0, 0 },
-    { 0, /* char31 */ 0, 0, 0 },
-    { 0, /* char32 */ 0, 52.381, 104.762 },
-    { 2, char33, 13.3819, 26.6238 },
-    { 2, char34, 23.0676, 51.4352 },
-    { 4, char35, 36.5333, 79.4886 },
-    { 3, char36, 38.1533, 76.2067 },
-    { 3, char37, 49.2171, 96.5743 },
-    { 1, char38, 53.599, 101.758 },
-    { 1, char39, 4.44, 13.62 },
-    { 1, char40, 21.8657, 47.1733 },
-    { 1, char41, 24.3276, 47.5333 },
-    { 3, char42, 30.7695, 59.439 },
-    { 2, char43, 48.8371, 97.2543 },
-    { 1, char44, 13.5219, 26.0638 },
-    { 1, char45, 50.2371, 100.754 },
-    { 1, char46, 13.1019, 26.4838 },
-    { 1, char47, 40.5733, 82.1067 },
-    { 1, char48, 38.3133, 77.0667 },
-    { 1, char49, 30.8676, 66.5295 },
-    { 1, char50, 38.7533, 77.6467 },
-    { 1, char51, 38.3333, 77.0467 },
-    { 2, char52, 37.2133, 80.1686 },
-    { 1, char53, 38.1933, 77.6867 },
-    { 1, char54, 34.1514, 73.8048 },
-    { 2, char55, 38.8933, 77.2267 },
-    { 1, char56, 38.9333, 77.6667 },
-    { 1, char57, 39.9333, 74.0648 },
-    { 2, char58, 14.0819, 26.2238 },
-    { 2, char59, 12.9619, 26.3038 },
-    { 1, char60, 41.1552, 81.6105 },
-    { 2, char61, 48.5571, 97.2543 },
-    { 1, char62, 40.8752, 81.6105 },
-    { 2, char63, 36.9914, 73.9029 },
-    { 2, char64, 34.9314, 74.3648 },
-    { 3, char65, 40.5952, 80.4905 },
-    { 3, char66, 44.7533, 83.6267 },
-    { 1, char67, 39.9933, 84.4886 },
-    { 2, char68, 45.2933, 85.2867 },
-    { 4, char69, 39.9914, 78.1848 },
-    { 3, char70, 39.9914, 78.7448 },
-    { 2, char71, 40.3933, 89.7686 },
-    { 3, char72, 44.7533, 89.0867 },
-    { 1, char73, 10.86, 21.3 },
-    { 1, char74, 31.0714, 59.999 },
-    { 3, char75, 44.6133, 79.3267 },
-    { 2, char76, 40.2514, 71.3229 },
-    { 4, char77, 48.9552, 97.2105 },
-    { 3, char78, 44.4733, 88.8067 },
-    { 1, char79, 44.3352, 88.8305 },
-    { 2, char80, 45.4333, 85.6667 },
-    { 2, char81, 43.3952, 88.0905 },
-    { 3, char82, 45.0133, 82.3667 },
-    { 1, char83, 41.3333, 80.8267 },
-    { 2, char84, 35.6933, 71.9467 },
-    { 1, char85, 44.8733, 89.4867 },
-    { 2, char86, 40.4552, 81.6105 },
-    { 4, char87, 49.839, 100.518 },
-    { 2, char88, 35.8333, 72.3667 },
-    { 2, char89, 39.6152, 79.6505 },
-    { 3, char90, 35.8333, 73.7467 },
-    { 4, char91, 22.0657, 46.1133 },
-    { 1, char92, 39.1733, 78.2067 },
-    { 4, char93, 23.4876, 46.3933 },
-    { 2, char94, 44.0752, 90.2305 },
-    { 1, char95, 51.281, 104.062 },
-    { 2, char96, 42.5457, 83.5714 },
-    { 2, char97, 35.2514, 66.6029 },
-    { 2, char98, 37.3314, 70.4629 },
-    { 1, char99, 34.0914, 68.9229 },
-    { 2, char100, 33.2114, 70.2629 },
-    { 1, char101, 34.2914, 68.5229 },
-    { 2, char102, 14.9657, 38.6552 },
-    { 2, char103, 33.9314, 70.9829 },
-    { 2, char104, 33.4095, 71.021 },
-    { 2, char105, 14.7819, 28.8638 },
-    { 2, char106, 17.3876, 36.2314 },
-    { 3, char107, 33.4095, 62.521 },
-    { 1, char108, 10.02, 19.34 },
-    { 3, char109, 61.981, 123.962 },
-    { 2, char110, 32.9895, 70.881 },
-    { 1, char111, 33.5514, 71.7448 },
-    { 2, char112, 38.0314, 70.8029 },
-    { 2, char113, 33.4114, 70.7429 },
-    { 2, char114, 23.7457, 49.4952 },
-    { 1, char115, 28.5095, 62.321 },
-    { 2, char116, 14.8257, 39.3152 },
-    { 2, char117, 33.2695, 71.161 },
-    { 2, char118, 30.3714, 60.6029 },
-    { 4, char119, 40.5952, 80.4905 },
-    { 2, char120, 25.4695, 56.401 },
-    { 2, char121, 35.1333, 66.0648 },
-    { 3, char122, 28.2495, 61.821 },
-    { 3, char123, 21.6657, 41.6295 },
-    { 1, char124, 11.54, 23.78 },
-    { 3, char125, 18.7038, 41.4695 },
-    { 2, char126, 45.7771, 91.2743 },
-    { 2, char127, 33.3333, 66.6667 },
-};
-
-StrokeFontRec glutStrokeRoman = { "Roman", 128, chars, 119.048, -33.3333 };
-
diff --git a/src/glut/beos/glut_shapes.c b/src/glut/beos/glut_shapes.c
deleted file mode 100644 (file)
index ce5bebb..0000000
+++ /dev/null
@@ -1,596 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
-
-/**
-(c) Copyright 1993, Silicon Graphics, Inc.
-
-ALL RIGHTS RESERVED
-
-Permission to use, copy, modify, and distribute this software
-for any purpose and without fee is hereby granted, provided
-that the above copyright notice appear in all copies and that
-both the copyright notice and this permission notice appear in
-supporting documentation, and that the name of Silicon
-Graphics, Inc. not be used in advertising or publicity
-pertaining to distribution of the software without specific,
-written prior permission.
-
-THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
-"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
-OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  IN NO
-EVENT SHALL SILICON GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE
-ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
-INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
-SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
-NOT SILICON GRAPHICS, INC.  HAS BEEN ADVISED OF THE POSSIBILITY
-OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
-US Government Users Restricted Rights
-
-Use, duplication, or disclosure by the Government is subject to
-restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
-(c)(1)(ii) of the Rights in Technical Data and Computer
-Software clause at DFARS 252.227-7013 and/or in similar or
-successor clauses in the FAR or the DOD or NASA FAR
-Supplement.  Unpublished-- rights reserved under the copyright
-laws of the United States.  Contractor/manufacturer is Silicon
-Graphics, Inc., 2011 N.  Shoreline Blvd., Mountain View, CA
-94039-7311.
-
-OpenGL(TM) is a trademark of Silicon Graphics, Inc.
-*/
-
-#include <math.h>
-#include "glutint.h"
-
-/* Some <math.h> files do not define M_PI... */
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-static GLUquadricObj *quadObj;
-
-#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }
-
-static void
-initQuadObj(void)
-{
-  quadObj = gluNewQuadric();
-  if (!quadObj)
-    __glutFatalError("out of memory.");
-}
-
-/* CENTRY */
-void APIENTRY
-glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
-{
-  QUAD_OBJ_INIT();
-  gluQuadricDrawStyle(quadObj, GLU_LINE);
-  gluQuadricNormals(quadObj, GLU_SMOOTH);
-  /* If we ever changed/used the texture or orientation state
-     of quadObj, we'd need to change it to the defaults here
-     with gluQuadricTexture and/or gluQuadricOrientation. */
-  gluSphere(quadObj, radius, slices, stacks);
-}
-
-void APIENTRY
-glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
-{
-  QUAD_OBJ_INIT();
-  gluQuadricDrawStyle(quadObj, GLU_FILL);
-  gluQuadricNormals(quadObj, GLU_SMOOTH);
-  /* If we ever changed/used the texture or orientation state
-     of quadObj, we'd need to change it to the defaults here
-     with gluQuadricTexture and/or gluQuadricOrientation. */
-  gluSphere(quadObj, radius, slices, stacks);
-}
-
-void APIENTRY
-glutWireCone(GLdouble base, GLdouble height,
-  GLint slices, GLint stacks)
-{
-  QUAD_OBJ_INIT();
-  gluQuadricDrawStyle(quadObj, GLU_LINE);
-  gluQuadricNormals(quadObj, GLU_SMOOTH);
-  /* If we ever changed/used the texture or orientation state
-     of quadObj, we'd need to change it to the defaults here
-     with gluQuadricTexture and/or gluQuadricOrientation. */
-  gluCylinder(quadObj, base, 0.0, height, slices, stacks);
-}
-
-void APIENTRY
-glutSolidCone(GLdouble base, GLdouble height,
-  GLint slices, GLint stacks)
-{
-  QUAD_OBJ_INIT();
-  gluQuadricDrawStyle(quadObj, GLU_FILL);
-  gluQuadricNormals(quadObj, GLU_SMOOTH);
-  /* If we ever changed/used the texture or orientation state
-     of quadObj, we'd need to change it to the defaults here
-     with gluQuadricTexture and/or gluQuadricOrientation. */
-  gluCylinder(quadObj, base, 0.0, height, slices, stacks);
-}
-
-/* ENDCENTRY */
-
-static void
-drawBox(GLfloat size, GLenum type)
-{
-  static GLfloat n[6][3] =
-  {
-    {-1.0, 0.0, 0.0},
-    {0.0, 1.0, 0.0},
-    {1.0, 0.0, 0.0},
-    {0.0, -1.0, 0.0},
-    {0.0, 0.0, 1.0},
-    {0.0, 0.0, -1.0}
-  };
-  static GLint faces[6][4] =
-  {
-    {0, 1, 2, 3},
-    {3, 2, 6, 7},
-    {7, 6, 5, 4},
-    {4, 5, 1, 0},
-    {5, 6, 2, 1},
-    {7, 4, 0, 3}
-  };
-  GLfloat v[8][3];
-  GLint i;
-
-  v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
-  v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
-  v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
-  v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
-  v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
-  v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
-
-  for (i = 5; i >= 0; i--) {
-    glBegin(type);
-    glNormal3fv(&n[i][0]);
-    glVertex3fv(&v[faces[i][0]][0]);
-    glVertex3fv(&v[faces[i][1]][0]);
-    glVertex3fv(&v[faces[i][2]][0]);
-    glVertex3fv(&v[faces[i][3]][0]);
-    glEnd();
-  }
-}
-
-/* CENTRY */
-void APIENTRY
-glutWireCube(GLdouble size)
-{
-  drawBox(size, GL_LINE_LOOP);
-}
-
-void APIENTRY
-glutSolidCube(GLdouble size)
-{
-  drawBox(size, GL_QUADS);
-}
-
-/* ENDCENTRY */
-
-static void
-doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
-{
-  int i, j;
-  GLfloat theta, phi, theta1;
-  GLfloat cosTheta, sinTheta;
-  GLfloat cosTheta1, sinTheta1;
-  GLfloat ringDelta, sideDelta;
-
-  ringDelta = 2.0 * M_PI / rings;
-  sideDelta = 2.0 * M_PI / nsides;
-
-  theta = 0.0;
-  cosTheta = 1.0;
-  sinTheta = 0.0;
-  for (i = rings - 1; i >= 0; i--) {
-    theta1 = theta + ringDelta;
-    cosTheta1 = cos(theta1);
-    sinTheta1 = sin(theta1);
-    glBegin(GL_QUAD_STRIP);
-    phi = 0.0;
-    for (j = nsides; j >= 0; j--) {
-      GLfloat cosPhi, sinPhi, dist;
-
-      phi += sideDelta;
-      cosPhi = cos(phi);
-      sinPhi = sin(phi);
-      dist = R + r * cosPhi;
-
-      glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
-      glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
-      glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
-      glVertex3f(cosTheta * dist, -sinTheta * dist,  r * sinPhi);
-    }
-    glEnd();
-    theta = theta1;
-    cosTheta = cosTheta1;
-    sinTheta = sinTheta1;
-  }
-}
-
-/* CENTRY */
-void APIENTRY
-glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
-  GLint nsides, GLint rings)
-{
-  glPushAttrib(GL_POLYGON_BIT);
-  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-  doughnut(innerRadius, outerRadius, nsides, rings);
-  glPopAttrib();
-}
-
-void APIENTRY
-glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius,
-  GLint nsides, GLint rings)
-{
-  doughnut(innerRadius, outerRadius, nsides, rings);
-}
-
-/* ENDCENTRY */
-
-static GLfloat dodec[20][3];
-
-static void
-initDodecahedron(void)
-{
-  GLfloat alpha, beta;
-
-  alpha = sqrt(2.0 / (3.0 + sqrt(5.0)));
-  beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) -
-    2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0))));
-  /* *INDENT-OFF* */
-  dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;
-  dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;
-  dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;
-  dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;
-  dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;
-  dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;
-  dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;
-  dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;
-  dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;
-  dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;
-  dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;
-  dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;
-  dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;
-  dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;
-  dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;
-  dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;
-  dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;
-  dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;
-  dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;
-  dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;
-  /* *INDENT-ON* */
-
-}
-
-#define DIFF3(_a,_b,_c) { \
-    (_c)[0] = (_a)[0] - (_b)[0]; \
-    (_c)[1] = (_a)[1] - (_b)[1]; \
-    (_c)[2] = (_a)[2] - (_b)[2]; \
-}
-
-static void
-crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])
-{
-  GLfloat p[3];         /* in case prod == v1 or v2 */
-
-  p[0] = v1[1] * v2[2] - v2[1] * v1[2];
-  p[1] = v1[2] * v2[0] - v2[2] * v1[0];
-  p[2] = v1[0] * v2[1] - v2[0] * v1[1];
-  prod[0] = p[0];
-  prod[1] = p[1];
-  prod[2] = p[2];
-}
-
-static void
-normalize(GLfloat v[3])
-{
-  GLfloat d;
-
-  d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
-  if (d == 0.0) {
-    __glutWarning("normalize: zero length vector");
-    v[0] = d = 1.0;
-  }
-  d = 1 / d;
-  v[0] *= d;
-  v[1] *= d;
-  v[2] *= d;
-}
-
-static void
-pentagon(int a, int b, int c, int d, int e, GLenum shadeType)
-{
-  GLfloat n0[3], d1[3], d2[3];
-
-  DIFF3(dodec[a], dodec[b], d1);
-  DIFF3(dodec[b], dodec[c], d2);
-  crossprod(d1, d2, n0);
-  normalize(n0);
-
-  glBegin(shadeType);
-  glNormal3fv(n0);
-  glVertex3fv(&dodec[a][0]);
-  glVertex3fv(&dodec[b][0]);
-  glVertex3fv(&dodec[c][0]);
-  glVertex3fv(&dodec[d][0]);
-  glVertex3fv(&dodec[e][0]);
-  glEnd();
-}
-
-static void
-dodecahedron(GLenum type)
-{
-  static int inited = 0;
-
-  if (inited == 0) {
-    inited = 1;
-    initDodecahedron();
-  }
-  pentagon(0, 1, 9, 16, 5, type);
-  pentagon(1, 0, 3, 18, 7, type);
-  pentagon(1, 7, 11, 10, 9, type);
-  pentagon(11, 7, 18, 19, 6, type);
-  pentagon(8, 17, 16, 9, 10, type);
-  pentagon(2, 14, 15, 6, 19, type);
-  pentagon(2, 13, 12, 4, 14, type);
-  pentagon(2, 19, 18, 3, 13, type);
-  pentagon(3, 0, 5, 12, 13, type);
-  pentagon(6, 15, 8, 10, 11, type);
-  pentagon(4, 17, 8, 15, 14, type);
-  pentagon(4, 12, 5, 16, 17, type);
-}
-
-/* CENTRY */
-void APIENTRY
-glutWireDodecahedron(void)
-{
-  dodecahedron(GL_LINE_LOOP);
-}
-
-void APIENTRY
-glutSolidDodecahedron(void)
-{
-  dodecahedron(GL_TRIANGLE_FAN);
-}
-
-/* ENDCENTRY */
-
-static void
-recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,
-  GLenum shadeType)
-{
-  GLfloat q0[3], q1[3];
-
-  DIFF3(n1, n2, q0);
-  DIFF3(n2, n3, q1);
-  crossprod(q0, q1, q1);
-  normalize(q1);
-
-  glBegin(shadeType);
-  glNormal3fv(q1);
-  glVertex3fv(n1);
-  glVertex3fv(n2);
-  glVertex3fv(n3);
-  glEnd();
-}
-
-static void
-subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2,
-  GLenum shadeType)
-{
-  int depth;
-  GLfloat w0[3], w1[3], w2[3];
-  GLfloat l;
-  int i, j, k, n;
-
-  depth = 1;
-  for (i = 0; i < depth; i++) {
-    for (j = 0; i + j < depth; j++) {
-      k = depth - i - j;
-      for (n = 0; n < 3; n++) {
-        w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;
-        w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])
-          / depth;
-        w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])
-          / depth;
-      }
-      l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);
-      w0[0] /= l;
-      w0[1] /= l;
-      w0[2] /= l;
-      l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);
-      w1[0] /= l;
-      w1[1] /= l;
-      w1[2] /= l;
-      l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);
-      w2[0] /= l;
-      w2[1] /= l;
-      w2[2] /= l;
-      recorditem(w1, w0, w2, shadeType);
-    }
-  }
-}
-
-static void
-drawtriangle(int i, GLfloat data[][3], int ndx[][3],
-  GLenum shadeType)
-{
-  GLfloat *x0, *x1, *x2;
-
-  x0 = data[ndx[i][0]];
-  x1 = data[ndx[i][1]];
-  x2 = data[ndx[i][2]];
-  subdivide(x0, x1, x2, shadeType);
-}
-
-/* octahedron data: The octahedron produced is centered at the
-   origin and has radius 1.0 */
-static GLfloat odata[6][3] =
-{
-  {1.0, 0.0, 0.0},
-  {-1.0, 0.0, 0.0},
-  {0.0, 1.0, 0.0},
-  {0.0, -1.0, 0.0},
-  {0.0, 0.0, 1.0},
-  {0.0, 0.0, -1.0}
-};
-
-static int ondex[8][3] =
-{
-  {0, 4, 2},
-  {1, 2, 4},
-  {0, 3, 4},
-  {1, 4, 3},
-  {0, 2, 5},
-  {1, 5, 2},
-  {0, 5, 3},
-  {1, 3, 5}
-};
-
-static void
-octahedron(GLenum shadeType)
-{
-  int i;
-
-  for (i = 7; i >= 0; i--) {
-    drawtriangle(i, odata, ondex, shadeType);
-  }
-}
-
-/* CENTRY */
-void APIENTRY
-glutWireOctahedron(void)
-{
-  octahedron(GL_LINE_LOOP);
-}
-
-void APIENTRY
-glutSolidOctahedron(void)
-{
-  octahedron(GL_TRIANGLES);
-}
-
-/* ENDCENTRY */
-
-/* icosahedron data: These numbers are rigged to make an
-   icosahedron of radius 1.0 */
-
-#define X .525731112119133606
-#define Z .850650808352039932
-
-static GLfloat idata[12][3] =
-{
-  {-X, 0, Z},
-  {X, 0, Z},
-  {-X, 0, -Z},
-  {X, 0, -Z},
-  {0, Z, X},
-  {0, Z, -X},
-  {0, -Z, X},
-  {0, -Z, -X},
-  {Z, X, 0},
-  {-Z, X, 0},
-  {Z, -X, 0},
-  {-Z, -X, 0}
-};
-
-static int index[20][3] =
-{
-  {0, 4, 1},
-  {0, 9, 4},
-  {9, 5, 4},
-  {4, 5, 8},
-  {4, 8, 1},
-  {8, 10, 1},
-  {8, 3, 10},
-  {5, 3, 8},
-  {5, 2, 3},
-  {2, 7, 3},
-  {7, 10, 3},
-  {7, 6, 10},
-  {7, 11, 6},
-  {11, 0, 6},
-  {0, 1, 6},
-  {6, 1, 10},
-  {9, 0, 11},
-  {9, 11, 2},
-  {9, 2, 5},
-  {7, 2, 11},
-};
-
-static void
-icosahedron(GLenum shadeType)
-{
-  int i;
-
-  for (i = 19; i >= 0; i--) {
-    drawtriangle(i, idata, index, shadeType);
-  }
-}
-
-/* CENTRY */
-void APIENTRY
-glutWireIcosahedron(void)
-{
-  icosahedron(GL_LINE_LOOP);
-}
-
-void APIENTRY
-glutSolidIcosahedron(void)
-{
-  icosahedron(GL_TRIANGLES);
-}
-
-/* ENDCENTRY */
-
-/* tetrahedron data: */
-
-#define T       1.73205080756887729
-
-static GLfloat tdata[4][3] =
-{
-  {T, T, T},
-  {T, -T, -T},
-  {-T, T, -T},
-  {-T, -T, T}
-};
-
-static int tndex[4][3] =
-{
-  {0, 1, 3},
-  {2, 1, 0},
-  {3, 2, 0},
-  {1, 2, 3}
-};
-
-static void
-tetrahedron(GLenum shadeType)
-{
-  int i;
-
-  for (i = 3; i >= 0; i--)
-    drawtriangle(i, tdata, tndex, shadeType);
-}
-
-/* CENTRY */
-void APIENTRY
-glutWireTetrahedron(void)
-{
-  tetrahedron(GL_LINE_LOOP);
-}
-
-void APIENTRY
-glutSolidTetrahedron(void)
-{
-  tetrahedron(GL_TRIANGLES);
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/beos/glut_stroke.c b/src/glut/beos/glut_stroke.c
deleted file mode 100644 (file)
index 2fe408b..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-#include "glutstroke.h"
-
-void APIENTRY 
-glutStrokeCharacter(GLUTstrokeFont font, int c)
-{
-  const StrokeCharRec *ch;
-  const StrokeRec *stroke;
-  const CoordRec *coord;
-  StrokeFontPtr fontinfo;
-  int i, j;
-
-
-#if defined(_WIN32)
-  fontinfo = (StrokeFontPtr) __glutFont(font);
-#else
-  fontinfo = (StrokeFontPtr) font;
-#endif
-
-  if (c < 0 || c >= fontinfo->num_chars)
-    return;
-  ch = &(fontinfo->ch[c]);
-  if (ch) {
-    for (i = ch->num_strokes, stroke = ch->stroke;
-      i > 0; i--, stroke++) {
-      glBegin(GL_LINE_STRIP);
-      for (j = stroke->num_coords, coord = stroke->coord;
-        j > 0; j--, coord++) {
-        glVertex2f(coord->x, coord->y);
-      }
-      glEnd();
-    }
-    glTranslatef(ch->right, 0.0, 0.0);
-  }
-}
diff --git a/src/glut/beos/glut_swidth.c b/src/glut/beos/glut_swidth.c
deleted file mode 100644 (file)
index e1b7374..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1995. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-#include "glutstroke.h"
-
-/* CENTRY */
-int APIENTRY 
-glutStrokeWidth(GLUTstrokeFont font, int c)
-{
-  StrokeFontPtr fontinfo;
-  const StrokeCharRec *ch;
-
-#if defined(_WIN32)
-  fontinfo = (StrokeFontPtr) __glutFont(font);
-#else
-  fontinfo = (StrokeFontPtr) font;
-#endif
-
-  if (c < 0 || c >= fontinfo->num_chars)
-    return 0;
-  ch = &(fontinfo->ch[c]);
-  if (ch)
-    return ch->right;
-  else
-    return 0;
-}
-
-int APIENTRY 
-glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
-{
-  int c, length;
-  StrokeFontPtr fontinfo;
-  const StrokeCharRec *ch;
-
-#if defined(_WIN32)
-  fontinfo = (StrokeFontPtr) __glutFont(font);
-#else
-  fontinfo = (StrokeFontPtr) font;
-#endif
-
-  length = 0;
-  for (; *string != '\0'; string++) {
-    c = *string;
-    if (c >= 0 && c < fontinfo->num_chars) {
-      ch = &(fontinfo->ch[c]);
-      if (ch)
-        length += ch->right;
-    }
-  }
-  return length;
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/beos/glut_teapot.c b/src/glut/beos/glut_teapot.c
deleted file mode 100644 (file)
index 3c9bdc1..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/**
-(c) Copyright 1993, Silicon Graphics, Inc.
-
-ALL RIGHTS RESERVED
-
-Permission to use, copy, modify, and distribute this software
-for any purpose and without fee is hereby granted, provided
-that the above copyright notice appear in all copies and that
-both the copyright notice and this permission notice appear in
-supporting documentation, and that the name of Silicon
-Graphics, Inc. not be used in advertising or publicity
-pertaining to distribution of the software without specific,
-written prior permission.
-
-THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
-"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
-OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  IN NO
-EVENT SHALL SILICON GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE
-ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
-INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
-SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
-NOT SILICON GRAPHICS, INC.  HAS BEEN ADVISED OF THE POSSIBILITY
-OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
-US Government Users Restricted Rights
-
-Use, duplication, or disclosure by the Government is subject to
-restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
-(c)(1)(ii) of the Rights in Technical Data and Computer
-Software clause at DFARS 252.227-7013 and/or in similar or
-successor clauses in the FAR or the DOD or NASA FAR
-Supplement.  Unpublished-- rights reserved under the copyright
-laws of the United States.  Contractor/manufacturer is Silicon
-Graphics, Inc., 2011 N.  Shoreline Blvd., Mountain View, CA
-94039-7311.
-
-OpenGL(TM) is a trademark of Silicon Graphics, Inc.
-*/
-
-#include "glutint.h"
-
-/* Rim, body, lid, and bottom data must be reflected in x and
-   y; handle and spout data across the y axis only.  */
-
-static int patchdata[][16] =
-{
-    /* rim */
-  {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
-    12, 13, 14, 15},
-    /* body */
-  {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
-    24, 25, 26, 27},
-  {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
-    37, 38, 39, 40},
-    /* lid */
-  {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
-    101, 0, 1, 2, 3,},
-  {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
-    113, 114, 115, 116, 117},
-    /* bottom */
-  {118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
-    125, 120, 40, 39, 38, 37},
-    /* handle */
-  {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
-    53, 54, 55, 56},
-  {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
-    28, 65, 66, 67},
-    /* spout */
-  {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
-    80, 81, 82, 83},
-  {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
-    92, 93, 94, 95}
-};
-/* *INDENT-OFF* */
-
-static float cpdata[][3] =
-{
-    {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,
-    -0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
-    {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,
-    0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,
-    2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,
-    2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},
-    {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,
-    1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
-    {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,
-    0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,
-    0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},
-    {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},
-    {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,
-    -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,
-    -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,
-    2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,
-    2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,
-    2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},
-    {-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,
-    -0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,
-    1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,
-    -0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,
-    1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,
-    0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,
-    0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
-    {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,
-    -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,
-    2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
-    {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
-    {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
-    {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,
-    3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,
-    3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,
-    -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,
-    2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,
-    2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,
-    2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},
-    {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,
-    -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,
-    0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
-    {0.84, -1.5, 0.075}
-};
-
-static float tex[2][2][2] =
-{
-  { {0, 0},
-    {1, 0}},
-  { {0, 1},
-    {1, 1}}
-};
-
-/* *INDENT-ON* */
-
-static void
-teapot(GLint grid, GLdouble scale, GLenum type)
-{
-  float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
-  long i, j, k, l;
-
-  glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
-  glEnable(GL_AUTO_NORMAL);
-  glEnable(GL_NORMALIZE);
-  glEnable(GL_MAP2_VERTEX_3);
-  glEnable(GL_MAP2_TEXTURE_COORD_2);
-  glPushMatrix();
-  glRotatef(270.0, 1.0, 0.0, 0.0);
-  glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
-  glTranslatef(0.0, 0.0, -1.5);
-  for (i = 0; i < 10; i++) {
-    for (j = 0; j < 4; j++) {
-      for (k = 0; k < 4; k++) {
-        for (l = 0; l < 3; l++) {
-          p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
-          q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
-          if (l == 1)
-            q[j][k][l] *= -1.0;
-          if (i < 6) {
-            r[j][k][l] =
-              cpdata[patchdata[i][j * 4 + (3 - k)]][l];
-            if (l == 0)
-              r[j][k][l] *= -1.0;
-            s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
-            if (l == 0)
-              s[j][k][l] *= -1.0;
-            if (l == 1)
-              s[j][k][l] *= -1.0;
-          }
-        }
-      }
-    }
-    glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
-      &tex[0][0][0]);
-    glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
-      &p[0][0][0]);
-    glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
-    glEvalMesh2(type, 0, grid, 0, grid);
-    glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
-      &q[0][0][0]);
-    glEvalMesh2(type, 0, grid, 0, grid);
-    if (i < 6) {
-      glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
-        &r[0][0][0]);
-      glEvalMesh2(type, 0, grid, 0, grid);
-      glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
-        &s[0][0][0]);
-      glEvalMesh2(type, 0, grid, 0, grid);
-    }
-  }
-  glPopMatrix();
-  glPopAttrib();
-}
-
-/* CENTRY */
-void APIENTRY 
-glutSolidTeapot(GLdouble scale)
-{
-  teapot(14, scale, GL_FILL);
-}
-
-void APIENTRY 
-glutWireTeapot(GLdouble scale)
-{
-  teapot(10, scale, GL_LINE);
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/beos/glut_tr10.c b/src/glut/beos/glut_tr10.c
deleted file mode 100644 (file)
index 0fac807..0000000
+++ /dev/null
@@ -1,1777 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapTimesRoman10 XXX
-#include "glutbitmap.h"
-#undef glutBitmapTimesRoman10
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x80,0xc0,0x40,0x60,0xa0,0x90,0xb8,0x0,0xa0,
-};
-
-static const BitmapCharRec ch255 = {5,9,0,2,5,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0xc0,0x80,0xe0,0x90,0x90,0x90,0xe0,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {4,9,0,2,5,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x80,0xc0,0x40,0x60,0xa0,0x90,0xb8,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch253 = {5,10,0,2,5,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x68,0x90,0x90,0x90,0x90,0x0,0x50,
-};
-
-static const BitmapCharRec ch252 = {5,7,0,0,5,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x68,0x90,0x90,0x90,0x90,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch251 = {5,8,0,0,5,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x68,0x90,0x90,0x90,0x90,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch250 = {5,8,0,0,5,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x68,0x90,0x90,0x90,0x90,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch249 = {5,8,0,0,5,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0x80,0x70,0x48,0x48,0x48,0x38,0x4,
-};
-
-static const BitmapCharRec ch248 = {6,7,1,1,5,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x20,0x0,0xf8,0x0,0x20,
-};
-
-static const BitmapCharRec ch247 = {5,5,0,0,6,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0xa0,
-};
-
-static const BitmapCharRec ch246 = {4,7,0,0,5,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch245 = {4,8,0,0,5,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch244 = {4,8,0,0,5,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch243 = {4,8,0,0,5,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch242 = {4,8,0,0,5,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0xd8,0x90,0x90,0x90,0xe0,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch241 = {5,8,0,0,5,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x60,0x90,0x90,0x90,0x70,0xa0,0x70,0x40,
-};
-
-static const BitmapCharRec ch240 = {4,8,0,0,5,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x0,0xa0,
-};
-
-static const BitmapCharRec ch239 = {3,7,0,0,4,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch238 = {3,8,0,0,4,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch237 = {3,8,0,0,4,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch236 = {3,8,0,0,4,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x60,0x80,0xc0,0xa0,0x60,0x0,0xa0,
-};
-
-static const BitmapCharRec ch235 = {3,7,0,0,4,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x60,0x80,0xc0,0xa0,0x60,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch234 = {3,8,0,0,4,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x60,0x80,0xc0,0xa0,0x60,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch233 = {3,8,0,0,4,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x60,0x80,0xc0,0xa0,0x60,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch232 = {3,8,0,0,4,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0xc0,0x20,0x40,0x60,0x80,0x80,0x80,0x60,
-};
-
-static const BitmapCharRec ch231 = {3,8,0,3,4,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0xd8,0xa0,0x70,0x28,0xd8,
-};
-
-static const BitmapCharRec ch230 = {5,5,0,0,6,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x40,0xa0,0x40,
-};
-
-static const BitmapCharRec ch229 = {3,8,0,0,4,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0xa0,
-};
-
-static const BitmapCharRec ch228 = {3,7,0,0,4,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch227 = {4,8,0,0,4,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch226 = {3,8,0,0,4,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch225 = {3,8,0,0,4,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch224 = {3,8,0,0,4,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xe0,0x50,0x50,0x60,0x50,0x50,0x20,
-};
-
-static const BitmapCharRec ch223 = {4,7,0,0,5,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0xe0,0x40,0x70,0x48,0x70,0x40,0xe0,
-};
-
-static const BitmapCharRec ch222 = {5,7,0,0,6,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x38,0x10,0x10,0x28,0x28,0x44,0xee,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch221 = {7,10,0,0,8,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,0x0,0x28,
-};
-
-static const BitmapCharRec ch220 = {7,9,0,0,8,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch219 = {7,10,0,0,8,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch218 = {7,10,0,0,8,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch217 = {7,10,0,0,8,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x7c,0x66,0x52,0x52,0x4a,0x66,0x3e,0x1,
-};
-
-static const BitmapCharRec ch216 = {8,9,0,1,8,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x88,0x50,0x20,0x50,0x88,
-};
-
-static const BitmapCharRec ch215 = {5,5,0,0,6,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x50,
-};
-
-static const BitmapCharRec ch214 = {6,9,0,0,7,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch213 = {6,10,0,0,7,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch212 = {6,10,0,0,7,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch211 = {6,10,0,0,7,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch210 = {6,10,0,0,7,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0xe4,0x4c,0x4c,0x54,0x54,0x64,0xee,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch209 = {7,10,0,0,8,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0xf8,0x4c,0x44,0xe4,0x44,0x4c,0xf8,
-};
-
-static const BitmapCharRec ch208 = {6,7,0,0,7,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,0x0,0xa0,
-};
-
-static const BitmapCharRec ch207 = {3,9,0,0,4,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch206 = {3,10,0,0,4,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch205 = {3,10,0,0,4,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch204 = {3,10,0,0,4,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,0x0,0x50,
-};
-
-static const BitmapCharRec ch203 = {5,9,0,0,6,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch202 = {5,10,0,0,6,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch201 = {5,10,0,0,6,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch200 = {5,10,0,0,6,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x60,0x10,0x20,0x78,0xc4,0x80,0x80,0x80,0xc4,0x7c,
-};
-
-static const BitmapCharRec ch199 = {6,10,0,3,7,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0xef,0x49,0x78,0x2e,0x28,0x39,0x1f,
-};
-
-static const BitmapCharRec ch198 = {8,7,0,0,9,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x10,0x28,0x10,
-};
-
-static const BitmapCharRec ch197 = {7,10,0,0,8,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x28,
-};
-
-static const BitmapCharRec ch196 = {7,9,0,0,8,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch195 = {7,10,0,0,8,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch194 = {7,10,0,0,8,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch193 = {7,10,0,0,8,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch192 = {7,10,0,0,8,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0xe0,0xa0,0x80,0x40,0x40,0x0,0x40,
-};
-
-static const BitmapCharRec ch191 = {3,7,0,2,4,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x44,0x3e,0x2c,0xd4,0x28,0x48,0xe4,
-};
-
-static const BitmapCharRec ch190 = {7,7,0,0,8,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x4e,0x24,0x2a,0xf6,0x48,0xc8,0x44,
-};
-
-static const BitmapCharRec ch189 = {7,7,0,0,8,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x44,0x3e,0x2c,0xf4,0x48,0xc8,0x44,
-};
-
-static const BitmapCharRec ch188 = {7,7,0,0,8,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0xa0,0x50,0x50,0xa0,
-};
-
-static const BitmapCharRec ch187 = {4,4,0,-1,5,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xe0,0x0,0x40,0xa0,0x40,
-};
-
-static const BitmapCharRec ch186 = {3,5,0,-2,4,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0xe0,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {3,4,0,-3,3,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xc0,0x20,0x40,
-};
-
-static const BitmapCharRec ch184 = {3,3,0,3,4,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch183 = {1,1,0,-2,2,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,0x7c,
-};
-
-static const BitmapCharRec ch182 = {6,9,0,2,6,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0x80,0xe8,0x90,0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch181 = {5,7,0,2,5,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x40,
-};
-
-static const BitmapCharRec ch180 = {2,2,0,-5,3,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0xc0,0x20,0x40,0xe0,
-};
-
-static const BitmapCharRec ch179 = {3,4,0,-3,3,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xe0,0x40,0xa0,0x60,
-};
-
-static const BitmapCharRec ch178 = {3,4,0,-3,3,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xf8,0x0,0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch177 = {5,7,0,0,6,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,0,-3,4,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xe0,
-};
-
-static const BitmapCharRec ch175 = {3,1,0,-6,4,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x38,0x44,0xaa,0xb2,0xba,0x44,0x38,
-};
-
-static const BitmapCharRec ch174 = {7,7,-1,0,9,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xe0,
-};
-
-static const BitmapCharRec ch173 = {3,1,0,-2,4,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x8,0x8,0xf8,
-};
-
-static const BitmapCharRec ch172 = {5,3,-1,-1,7,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x50,0xa0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch171 = {4,4,0,-1,5,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xe0,0x0,0xa0,0x20,0xc0,
-};
-
-static const BitmapCharRec ch170 = {3,5,0,-2,4,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x38,0x44,0x9a,0xa2,0x9a,0x44,0x38,
-};
-
-static const BitmapCharRec ch169 = {7,7,-1,0,9,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xa0,
-};
-
-static const BitmapCharRec ch168 = {3,1,-1,-6,5,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0xe0,0x90,0x20,0x50,0x90,0xa0,0x40,0x90,0x70,
-};
-
-static const BitmapCharRec ch167 = {4,9,0,1,5,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x0,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,7,0,0,2,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x70,0x20,0xf8,0x20,0xd8,0x50,0x88,
-};
-
-static const BitmapCharRec ch165 = {5,7,0,0,5,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x88,0x70,0x50,0x50,0x70,0x88,
-};
-
-static const BitmapCharRec ch164 = {5,6,0,-1,5,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xf0,0xc8,0x40,0xe0,0x40,0x50,0x30,
-};
-
-static const BitmapCharRec ch163 = {5,7,0,0,5,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x80,0xe0,0x90,0x80,0x90,0x70,0x10,
-};
-
-static const BitmapCharRec ch162 = {4,7,0,1,5,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,7,-1,2,3,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,2,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,2,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x98,0x64,
-};
-
-static const BitmapCharRec ch126 = {6,2,0,-2,7,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0x80,0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch125 = {3,9,0,2,4,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,9,0,2,2,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x20,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch123 = {3,9,0,2,4,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xf0,0x90,0x40,0x20,0xf0,
-};
-
-static const BitmapCharRec ch122 = {4,5,0,0,5,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x40,0x40,0x20,0x30,0x50,0x48,0xdc,
-};
-
-static const BitmapCharRec ch121 = {6,7,1,2,5,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0xd8,0x50,0x20,0x50,0xd8,
-};
-
-static const BitmapCharRec ch120 = {5,5,0,0,6,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x28,0x6c,0x54,0x92,0xdb,
-};
-
-static const BitmapCharRec ch119 = {8,5,0,0,8,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x20,0x60,0x50,0x90,0xd8,
-};
-
-static const BitmapCharRec ch118 = {5,5,0,0,5,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x68,0x90,0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch117 = {5,5,0,0,5,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x30,0x40,0x40,0x40,0xe0,0x40,
-};
-
-static const BitmapCharRec ch116 = {4,6,0,0,4,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0xe0,0x20,0x60,0x80,0xe0,
-};
-
-static const BitmapCharRec ch115 = {3,5,0,0,4,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0xe0,0x40,0x40,0x60,0xa0,
-};
-
-static const BitmapCharRec ch114 = {3,5,0,0,4,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x38,0x10,0x70,0x90,0x90,0x90,0x70,
-};
-
-static const BitmapCharRec ch113 = {5,7,0,2,5,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0xc0,0x80,0xe0,0x90,0x90,0x90,0xe0,
-};
-
-static const BitmapCharRec ch112 = {4,7,0,2,5,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x60,0x90,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch111 = {4,5,0,0,5,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0xd8,0x90,0x90,0x90,0xe0,
-};
-
-static const BitmapCharRec ch110 = {5,5,0,0,5,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0xdb,0x92,0x92,0x92,0xec,
-};
-
-static const BitmapCharRec ch109 = {8,5,0,0,8,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xc0,
-};
-
-static const BitmapCharRec ch108 = {3,7,0,0,4,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x98,0x90,0xe0,0xa0,0x90,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {5,7,0,0,5,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x80,0x40,0x40,0x40,0x40,0x40,0xc0,0x0,0x40,
-};
-
-static const BitmapCharRec ch106 = {2,9,0,2,3,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0x40,0x40,0x40,0x40,0xc0,0x0,0x40,
-};
-
-static const BitmapCharRec ch105 = {2,7,0,0,3,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0xd8,0x90,0x90,0x90,0xe0,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {5,7,0,0,5,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0xe0,0x90,0x60,0x40,0xa0,0xa0,0x70,
-};
-
-static const BitmapCharRec ch103 = {4,7,0,2,5,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0xe0,0x40,0x40,0x40,0xe0,0x40,0x30,
-};
-
-static const BitmapCharRec ch102 = {4,7,0,0,4,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x60,0x80,0xc0,0xa0,0x60,
-};
-
-static const BitmapCharRec ch101 = {3,5,0,0,4,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x68,0x90,0x90,0x90,0x70,0x10,0x30,
-};
-
-static const BitmapCharRec ch100 = {5,7,0,0,5,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x60,0x80,0x80,0x80,0x60,
-};
-
-static const BitmapCharRec ch99 = {3,5,0,0,4,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xe0,0x90,0x90,0x90,0xe0,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {4,7,0,0,5,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,
-};
-
-static const BitmapCharRec ch97 = {3,5,0,0,4,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0xc0,0x80,
-};
-
-static const BitmapCharRec ch96 = {2,2,0,-5,3,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xf8,
-};
-
-static const BitmapCharRec ch95 = {5,1,0,3,5,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0xa0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch94 = {3,3,-1,-4,5,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,
-};
-
-static const BitmapCharRec ch93 = {2,9,0,2,3,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x20,0x20,0x40,0x40,0x40,0x80,0x80,
-};
-
-static const BitmapCharRec ch92 = {3,7,0,0,3,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
-};
-
-static const BitmapCharRec ch91 = {2,9,0,2,3,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xf8,0x88,0x40,0x20,0x10,0x88,0xf8,
-};
-
-static const BitmapCharRec ch90 = {5,7,0,0,6,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x38,0x10,0x10,0x28,0x28,0x44,0xee,
-};
-
-static const BitmapCharRec ch89 = {7,7,0,0,8,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0xee,0x44,0x28,0x10,0x28,0x44,0xee,
-};
-
-static const BitmapCharRec ch88 = {7,7,0,0,8,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x22,0x0,0x22,0x0,0x55,0x0,0x55,0x0,0xc9,0x80,0x88,0x80,0xdd,0xc0,
-};
-
-static const BitmapCharRec ch87 = {10,7,0,0,10,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x10,0x28,0x28,0x6c,0x44,0xee,
-};
-
-static const BitmapCharRec ch86 = {7,7,0,0,8,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,
-};
-
-static const BitmapCharRec ch85 = {7,7,0,0,8,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x70,0x20,0x20,0x20,0x20,0xa8,0xf8,
-};
-
-static const BitmapCharRec ch84 = {5,7,0,0,6,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0xe0,0x90,0x10,0x60,0xc0,0x90,0x70,
-};
-
-static const BitmapCharRec ch83 = {4,7,0,0,5,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0xec,0x48,0x50,0x70,0x48,0x48,0xf0,
-};
-
-static const BitmapCharRec ch82 = {6,7,0,0,7,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0xc,0x18,0x70,0xcc,0x84,0x84,0x84,0xcc,0x78,
-};
-
-static const BitmapCharRec ch81 = {6,9,0,2,7,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0xe0,0x40,0x40,0x70,0x48,0x48,0xf0,
-};
-
-static const BitmapCharRec ch80 = {5,7,0,0,6,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,
-};
-
-static const BitmapCharRec ch79 = {6,7,0,0,7,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0xe4,0x4c,0x4c,0x54,0x54,0x64,0xee,
-};
-
-static const BitmapCharRec ch78 = {7,7,0,0,8,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0xeb,0x80,0x49,0x0,0x55,0x0,0x55,0x0,0x63,0x0,0x63,0x0,0xe3,0x80,
-};
-
-static const BitmapCharRec ch77 = {9,7,0,0,10,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xf8,0x48,0x40,0x40,0x40,0x40,0xe0,
-};
-
-static const BitmapCharRec ch76 = {5,7,0,0,6,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0xec,0x48,0x50,0x60,0x50,0x48,0xec,
-};
-
-static const BitmapCharRec ch75 = {6,7,0,0,7,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0xc0,0xa0,0x20,0x20,0x20,0x20,0x70,
-};
-
-static const BitmapCharRec ch74 = {4,7,0,0,4,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,
-};
-
-static const BitmapCharRec ch73 = {3,7,0,0,4,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0xee,0x44,0x44,0x7c,0x44,0x44,0xee,
-};
-
-static const BitmapCharRec ch72 = {7,7,0,0,8,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x78,0xc4,0x84,0x9c,0x80,0xc4,0x7c,
-};
-
-static const BitmapCharRec ch71 = {6,7,0,0,7,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0xe0,0x40,0x40,0x70,0x40,0x48,0xf8,
-};
-
-static const BitmapCharRec ch70 = {5,7,0,0,6,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,
-};
-
-static const BitmapCharRec ch69 = {5,7,0,0,6,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xf8,0x4c,0x44,0x44,0x44,0x4c,0xf8,
-};
-
-static const BitmapCharRec ch68 = {6,7,0,0,7,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x78,0xc4,0x80,0x80,0x80,0xc4,0x7c,
-};
-
-static const BitmapCharRec ch67 = {6,7,0,0,7,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xf0,0x48,0x48,0x70,0x48,0x48,0xf0,
-};
-
-static const BitmapCharRec ch66 = {5,7,0,0,6,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,
-};
-
-static const BitmapCharRec ch65 = {7,7,0,0,8,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x3e,0x40,0x92,0xad,0xa5,0xa5,0x9d,0x42,0x3c,
-};
-
-static const BitmapCharRec ch64 = {8,9,0,2,9,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x40,0x0,0x40,0x40,0x20,0xa0,0xe0,
-};
-
-static const BitmapCharRec ch63 = {3,7,0,0,4,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0x80,0x40,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch62 = {3,5,0,0,5,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xf8,0x0,0xf8,
-};
-
-static const BitmapCharRec ch61 = {5,3,0,-1,6,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x20,0x40,0x80,0x40,0x20,
-};
-
-static const BitmapCharRec ch60 = {3,5,-1,0,5,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x80,0x80,0x0,0x0,0x0,0x80,
-};
-
-static const BitmapCharRec ch59 = {1,7,-1,2,3,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0x80,0x0,0x0,0x0,0x80,
-};
-
-static const BitmapCharRec ch58 = {1,5,-1,0,3,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0xc0,0x20,0x70,0x90,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch57 = {4,7,0,0,5,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x60,0x90,0x90,0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch56 = {4,7,0,0,5,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x40,0x20,0x20,0x90,0xf0,
-};
-
-static const BitmapCharRec ch55 = {4,7,0,0,5,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x60,0x90,0x90,0x90,0xe0,0x40,0x30,
-};
-
-static const BitmapCharRec ch54 = {4,7,0,0,5,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0xe0,0x90,0x10,0x10,0xe0,0x40,0x70,
-};
-
-static const BitmapCharRec ch53 = {4,7,0,0,5,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x10,0x10,0xf8,0x90,0x50,0x30,0x10,
-};
-
-static const BitmapCharRec ch52 = {5,7,0,0,5,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0xe0,0x10,0x10,0x60,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch51 = {4,7,0,0,5,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xf0,0x40,0x20,0x20,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch50 = {4,7,0,0,5,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0xe0,0x40,0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch49 = {3,7,-1,0,5,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x60,0x90,0x90,0x90,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch48 = {4,7,0,0,5,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x80,0x40,0x40,0x40,0x20,0x20,
-};
-
-static const BitmapCharRec ch47 = {3,7,0,0,3,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch46 = {1,1,-1,0,3,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xf0,
-};
-
-static const BitmapCharRec ch45 = {4,1,-1,-2,7,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch44 = {1,3,-1,2,3,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch43 = {5,5,0,0,6,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0xa0,0x40,0xa0,
-};
-
-static const BitmapCharRec ch42 = {3,3,0,-4,5,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,9,0,2,4,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,9,0,2,4,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x40,0xc0,
-};
-
-static const BitmapCharRec ch39 = {2,2,0,-5,3,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x76,0x8d,0x98,0x74,0x6e,0x50,0x30,
-};
-
-static const BitmapCharRec ch38 = {8,7,0,0,8,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x44,0x2a,0x2a,0x56,0xa8,0xa4,0x7e,
-};
-
-static const BitmapCharRec ch37 = {7,7,0,0,8,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x20,0xe0,0x90,0x10,0x60,0x80,0x90,0x70,0x20,
-};
-
-static const BitmapCharRec ch36 = {4,9,0,1,5,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x50,0x50,0xf8,0x50,0xf8,0x50,0x50,
-};
-
-static const BitmapCharRec ch35 = {5,7,0,0,5,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0xa0,0xa0,
-};
-
-static const BitmapCharRec ch34 = {3,2,0,-5,4,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x0,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,7,-1,0,3,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,2,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,2,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-const BitmapFontRec glutBitmapTimesRoman10 = {
-"-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/beos/glut_tr24.c b/src/glut/beos/glut_tr24.c
deleted file mode 100644 (file)
index 22b0e51..0000000
+++ /dev/null
@@ -1,2060 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapTimesRoman24 XXX
-#include "glutbitmap.h"
-#undef glutBitmapTimesRoman24
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0xe0,0x0,0xf0,0x0,0x18,0x0,0x8,0x0,0xc,0x0,0x4,0x0,0xe,0x0,0xe,0x0,
-0x1a,0x0,0x19,0x0,0x19,0x0,0x31,0x0,0x30,0x80,0x30,0x80,0x60,0x80,0x60,0xc0,
-0xf1,0xe0,0x0,0x0,0x0,0x0,0x33,0x0,0x33,0x0,
-};
-
-static const BitmapCharRec ch255 = {11,21,0,5,11,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0xf0,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x6e,0x0,0x73,0x80,0x61,0x80,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x61,0x80,0x73,0x80,
-0x6e,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0xe0,0x0,
-};
-
-static const BitmapCharRec ch254 = {10,22,-1,5,12,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0xe0,0x0,0xf0,0x0,0x18,0x0,0x8,0x0,0xc,0x0,0x4,0x0,0xe,0x0,0xe,0x0,
-0x1a,0x0,0x19,0x0,0x19,0x0,0x31,0x0,0x30,0x80,0x30,0x80,0x60,0x80,0x60,0xc0,
-0xf1,0xe0,0x0,0x0,0x8,0x0,0x6,0x0,0x3,0x80,0x1,0x80,
-};
-
-static const BitmapCharRec ch253 = {11,22,0,5,11,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,0x0,0x0,0x0,0x0,0x33,0x0,0x33,0x0,
-};
-
-static const BitmapCharRec ch252 = {11,16,-1,0,13,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,0x0,0x0,0x21,0x0,0x12,0x0,0x1e,0x0,
-0xc,0x0,
-};
-
-static const BitmapCharRec ch251 = {11,17,-1,0,13,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,0x0,0x0,0x8,0x0,0x6,0x0,0x3,0x80,
-0x1,0x80,
-};
-
-static const BitmapCharRec ch250 = {11,17,-1,0,13,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,0x0,0x0,0x2,0x0,0xc,0x0,0x38,0x0,
-0x30,0x0,
-};
-
-static const BitmapCharRec ch249 = {11,17,-1,0,13,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0xc0,0x0,0xde,0x0,0x73,0x80,0x71,0x80,0xd0,0xc0,0xd8,0xc0,0xc8,0xc0,0xcc,0xc0,
-0xc4,0xc0,0xc6,0xc0,0x63,0x80,0x73,0x80,0x1e,0xc0,0x0,0xc0,
-};
-
-static const BitmapCharRec ch248 = {10,14,-1,1,12,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x0,0xff,0xf0,0xff,0xf0,0x0,0x0,0x0,0x0,
-0x6,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch247 = {12,10,-1,-2,14,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x0,0x0,0x33,0x0,0x33,0x0,
-};
-
-static const BitmapCharRec ch246 = {10,16,-1,0,12,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x0,0x0,0x27,0x0,0x1c,0x80,
-};
-
-static const BitmapCharRec ch245 = {10,16,-1,0,12,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x21,0x0,0x12,0x0,0x1e,0x0,
-0xc,0x0,
-};
-
-static const BitmapCharRec ch244 = {10,17,-1,0,12,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x8,0x0,0x6,0x0,0x3,0x80,
-0x1,0x80,
-};
-
-static const BitmapCharRec ch243 = {10,17,-1,0,12,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x2,0x0,0xc,0x0,0x38,0x0,
-0x30,0x0,
-};
-
-static const BitmapCharRec ch242 = {10,17,-1,0,12,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0xf1,0xe0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x71,0xc0,0x6f,0x80,0xe7,0x0,0x0,0x0,0x0,0x0,0x27,0x0,0x1c,0x80,
-};
-
-static const BitmapCharRec ch241 = {11,16,-1,0,13,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1f,0x0,0xc6,0x0,0x3c,0x0,0x1e,0x0,0x71,0x80,
-0xc0,0x0,
-};
-
-static const BitmapCharRec ch240 = {10,17,-1,0,12,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x70,0x0,0x0,0xcc,0xcc,
-};
-
-static const BitmapCharRec ch239 = {6,16,0,0,6,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x70,0x0,0x84,0x48,0x78,
-0x30,
-};
-
-static const BitmapCharRec ch238 = {6,17,0,0,6,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0x0,0x80,0x60,0x38,
-0x18,
-};
-
-static const BitmapCharRec ch237 = {5,17,-1,0,6,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x70,0x0,0x8,0x30,0xe0,
-0xc0,
-};
-
-static const BitmapCharRec ch236 = {5,17,0,0,6,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,0x0,0x0,0x0,0x0,0x33,0x0,0x33,0x0,
-};
-
-static const BitmapCharRec ch235 = {9,16,-1,0,11,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,0x0,0x0,0x21,0x0,0x12,0x0,0x1e,0x0,
-0xc,0x0,
-};
-
-static const BitmapCharRec ch234 = {9,17,-1,0,11,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,0x0,0x0,0x10,0x0,0xc,0x0,0x7,0x0,
-0x3,0x0,
-};
-
-static const BitmapCharRec ch233 = {9,17,-1,0,11,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,0x0,0x0,0x4,0x0,0x18,0x0,0x70,0x0,
-0x60,0x0,
-};
-
-static const BitmapCharRec ch232 = {9,17,-1,0,11,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x3c,0x0,0x66,0x0,0x6,0x0,0x1e,0x0,0x18,0x0,0x8,0x0,0x1e,0x0,0x7f,0x0,
-0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0x41,0x80,
-0x63,0x80,0x1f,0x0,
-};
-
-static const BitmapCharRec ch231 = {9,18,-1,6,11,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x70,0xf0,0xfb,0xf8,0xc7,0x84,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0xfc,
-0x3,0xc,0x63,0xc,0x67,0x98,0x3c,0xf0,
-};
-
-static const BitmapCharRec ch230 = {14,12,-1,0,16,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x1c,0x0,0x22,0x0,0x22,0x0,
-0x1c,0x0,
-};
-
-static const BitmapCharRec ch229 = {9,17,-1,0,11,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x66,0x0,0x66,0x0,
-};
-
-static const BitmapCharRec ch228 = {9,16,-1,0,11,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x5c,0x0,0x3a,0x0,
-};
-
-static const BitmapCharRec ch227 = {9,16,-1,0,11,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x42,0x0,0x24,0x0,0x3c,0x0,
-0x18,0x0,
-};
-
-static const BitmapCharRec ch226 = {9,17,-1,0,11,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x10,0x0,0xc,0x0,0x7,0x0,
-0x3,0x0,
-};
-
-static const BitmapCharRec ch225 = {9,17,-1,0,11,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x4,0x0,0x18,0x0,0x70,0x0,
-0x60,0x0,
-};
-
-static const BitmapCharRec ch224 = {9,17,-1,0,11,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xe7,0x0,0x6c,0x80,0x6c,0xc0,0x60,0xc0,0x60,0xc0,0x61,0xc0,0x61,0x80,0x63,0x80,
-0x67,0x0,0x6c,0x0,0x63,0x0,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x0,
-0x1e,0x0,
-};
-
-static const BitmapCharRec ch223 = {10,17,-1,0,12,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0xfc,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x3f,0xc0,0x30,0x70,0x30,0x30,0x30,0x18,
-0x30,0x18,0x30,0x18,0x30,0x30,0x30,0x70,0x3f,0xc0,0x30,0x0,0x30,0x0,0x30,0x0,
-0xfc,0x0,
-};
-
-static const BitmapCharRec ch222 = {13,17,-1,0,15,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x7,0xe0,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x3,0xc0,
-0x3,0x40,0x6,0x60,0x6,0x20,0xc,0x30,0x1c,0x10,0x18,0x18,0x38,0x8,0x30,0xc,
-0xfc,0x3f,0x0,0x0,0x1,0x0,0x0,0xc0,0x0,0x70,0x0,0x30,
-};
-
-static const BitmapCharRec ch221 = {16,22,0,0,16,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,0x0,0x0,0x0,0x0,0x6,0x30,0x6,0x30,
-};
-
-static const BitmapCharRec ch220 = {16,21,-1,0,18,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,0x0,0x0,0x8,0x10,0x6,0x60,0x3,0xc0,0x1,0x80,
-};
-
-static const BitmapCharRec ch219 = {16,22,-1,0,18,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,0x0,0x0,0x1,0x0,0x0,0xc0,0x0,0x70,0x0,0x30,
-};
-
-static const BitmapCharRec ch218 = {16,22,-1,0,18,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,0x0,0x0,0x0,0x40,0x1,0x80,0x7,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch217 = {16,22,-1,0,18,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x20,0x0,0x27,0xe0,0x1c,0x38,0x38,0x1c,0x68,0x6,0x64,0x6,0xc2,0x3,0xc2,0x3,
-0xc1,0x3,0xc1,0x3,0xc0,0x83,0xc0,0x83,0xc0,0x43,0x60,0x46,0x60,0x26,0x38,0x1c,
-0x1c,0x38,0x7,0xe4,0x0,0x4,
-};
-
-static const BitmapCharRec ch216 = {16,19,-1,1,18,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x80,0x40,0xc0,0xc0,0x61,0x80,0x33,0x0,0x1e,0x0,0xc,0x0,0x1e,0x0,0x33,0x0,
-0x61,0x80,0xc0,0xc0,0x80,0x40,
-};
-
-static const BitmapCharRec ch215 = {10,11,-2,-1,14,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x0,0x0,0x6,0x60,0x6,0x60,
-};
-
-static const BitmapCharRec ch214 = {16,21,-1,0,18,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x0,0x0,0x4,0xe0,0x3,0x90,
-};
-
-static const BitmapCharRec ch213 = {16,21,-1,0,18,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x8,0x10,0x6,0x60,0x3,0xc0,0x1,0x80,
-};
-
-static const BitmapCharRec ch212 = {16,22,-1,0,18,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x1,0x0,0x0,0xc0,0x0,0x70,0x0,0x30,
-};
-
-static const BitmapCharRec ch211 = {16,22,-1,0,18,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x0,0x40,0x1,0x80,0x7,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch210 = {16,22,-1,0,18,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0xf8,0xc,0x20,0x1c,0x20,0x1c,0x20,0x34,0x20,0x64,0x20,0x64,0x20,0xc4,0x21,0x84,
-0x21,0x84,0x23,0x4,0x26,0x4,0x26,0x4,0x2c,0x4,0x38,0x4,0x38,0x4,0x30,0x4,
-0xf0,0x1f,0x0,0x0,0x0,0x0,0x4,0xe0,0x3,0x90,
-};
-
-static const BitmapCharRec ch209 = {16,21,-1,0,18,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0x7f,0xe0,0x18,0x38,0x18,0x1c,0x18,0x6,0x18,0x6,0x18,0x3,0x18,0x3,0x18,0x3,
-0xff,0x3,0x18,0x3,0x18,0x3,0x18,0x3,0x18,0x6,0x18,0x6,0x18,0x1c,0x18,0x38,
-0x7f,0xe0,
-};
-
-static const BitmapCharRec ch208 = {16,17,0,0,17,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0xfc,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xfc,0x0,0x0,0xcc,0xcc,
-};
-
-static const BitmapCharRec ch207 = {6,21,-1,0,8,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
-0x7e,0x0,0x81,0x66,0x3c,0x18,
-};
-
-static const BitmapCharRec ch206 = {8,22,-1,0,8,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xfc,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xfc,0x0,0x40,0x30,0x1c,0xc,
-};
-
-static const BitmapCharRec ch205 = {6,22,-1,0,8,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0xfc,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xfc,0x0,0x8,0x30,0xe0,0xc0,
-};
-
-static const BitmapCharRec ch204 = {6,22,-1,0,8,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,0x0,0x0,0x0,0x0,0x19,0x80,0x19,0x80,
-};
-
-static const BitmapCharRec ch203 = {13,21,-1,0,15,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,0x0,0x0,0x10,0x20,0xc,0xc0,0x7,0x80,0x3,0x0,
-};
-
-static const BitmapCharRec ch202 = {13,22,-1,0,15,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,0x0,0x0,0x4,0x0,0x3,0x0,0x1,0xc0,0x0,0xc0,
-};
-
-static const BitmapCharRec ch201 = {13,22,-1,0,15,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,0x0,0x0,0x1,0x0,0x6,0x0,0x1c,0x0,0x18,0x0,
-};
-
-static const BitmapCharRec ch200 = {13,22,-1,0,15,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x7,0x80,0xc,0xc0,0x0,0xc0,0x3,0xc0,0x3,0x0,0x1,0x0,0x7,0xe0,0x1e,0x38,
-0x38,0x8,0x60,0x4,0x60,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0xc0,0x0,0x60,0x4,0x60,0x4,0x38,0xc,0x1c,0x3c,0x7,0xe4,
-};
-
-static const BitmapCharRec ch199 = {14,23,-1,6,16,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0xf9,0xff,0xf0,0x30,0x60,0x30,0x10,0x60,0x10,0x10,0x60,0x10,0x18,0x60,0x0,0x8,
-0x60,0x0,0xf,0xe0,0x80,0xc,0x60,0x80,0x4,0x7f,0x80,0x4,0x60,0x80,0x6,0x60,
-0x80,0x2,0x60,0x0,0x2,0x60,0x0,0x1,0x60,0x20,0x1,0x60,0x20,0x1,0xe0,0x60,
-0x3,0xff,0xe0,
-};
-
-static const BitmapCharRec ch198 = {20,17,0,0,21,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x1,0xc0,0x0,0x2,0x20,0x0,0x2,0x20,0x0,0x1,0xc0,0x0,
-};
-
-static const BitmapCharRec ch197 = {17,21,0,0,17,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x30,0x0,0x6,0x30,0x0,
-};
-
-static const BitmapCharRec ch196 = {17,21,0,0,17,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0xfc,0x1f,0x80,0x30,0x7,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0xe0,0x0,0x3,0x90,0x0,
-};
-
-static const BitmapCharRec ch195 = {17,21,0,0,17,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x8,0x10,0x0,0x6,0x60,0x0,0x3,0xc0,0x0,0x1,
-0x80,0x0,
-};
-
-static const BitmapCharRec ch194 = {17,22,0,0,17,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0xc0,0x0,0x0,0x70,0x0,0x0,
-0x30,0x0,
-};
-
-static const BitmapCharRec ch193 = {17,22,0,0,17,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x20,0x0,0x0,0xc0,0x0,0x3,0x80,0x0,0x3,
-0x0,0x0,
-};
-
-static const BitmapCharRec ch192 = {17,22,0,0,17,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x3e,0x63,0xc1,0xc3,0xc3,0xe0,0x70,0x30,0x38,0x18,0x18,0x8,0x8,0x0,0x0,0xc,
-0xc,
-};
-
-static const BitmapCharRec ch191 = {8,17,-1,5,11,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x18,0x2,0x0,0x8,0x2,0x0,0xc,0x7f,0x80,0x4,0x22,0x0,0x6,0x32,0x0,0x3,
-0x12,0x0,0x1,0xa,0x0,0x71,0x8e,0x0,0x88,0x86,0x0,0x8c,0xc2,0x0,0xc,0x60,
-0x0,0x8,0x20,0x0,0x30,0x30,0x0,0x8,0x10,0x0,0x8c,0x18,0x0,0x4c,0xc,0x0,
-0x38,0x4,0x0,
-};
-
-static const BitmapCharRec ch190 = {17,17,0,0,18,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x30,0x7e,0x10,0x22,0x18,0x10,0x8,0x18,0xc,0x8,0x6,0x4,0x2,0x6,0xfb,0x46,
-0x21,0x26,0x21,0x9c,0x20,0xc0,0x20,0x40,0x20,0x60,0x20,0x20,0xa0,0x30,0x60,0x18,
-0x20,0x8,
-};
-
-static const BitmapCharRec ch189 = {15,17,-1,0,18,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x30,0x4,0x10,0x4,0x18,0xff,0x8,0x44,0xc,0x64,0x6,0x24,0x2,0x14,0xfb,0x1c,
-0x21,0xc,0x21,0x84,0x20,0xc0,0x20,0x40,0x20,0x60,0x20,0x20,0xa0,0x30,0x60,0x18,
-0x20,0x8,
-};
-
-static const BitmapCharRec ch188 = {16,17,-1,0,18,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0x88,0x0,0xcc,0x0,0x66,0x0,0x33,0x0,0x19,0x80,0x19,0x80,0x33,0x0,0x66,0x0,
-0xcc,0x0,0x88,0x0,
-};
-
-static const BitmapCharRec ch187 = {9,10,-2,-1,12,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xfc,0x0,0x78,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,
-};
-
-static const BitmapCharRec ch186 = {6,9,-1,-8,8,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xa0,0x60,0x20,
-};
-
-static const BitmapCharRec ch185 = {5,10,-1,-7,7,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0x78,0xcc,0xc,0x3c,0x30,0x10,
-};
-
-static const BitmapCharRec ch184 = {6,6,-1,6,8,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,2,-2,-6,6,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,
-0x9,0x0,0x9,0x0,0x9,0x0,0x19,0x0,0x39,0x0,0x79,0x0,0x79,0x0,0xf9,0x0,
-0xf9,0x0,0xf9,0x0,0x79,0x0,0x79,0x0,0x39,0x0,0x1f,0x80,
-};
-
-static const BitmapCharRec ch182 = {9,22,-1,5,11,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x40,0x0,0xe0,0x0,0xc0,0x0,0x40,0x0,0x40,0x0,0x5c,0xe0,0x7e,0xc0,0x71,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0xe1,0xc0,
-};
-
-static const BitmapCharRec ch181 = {11,17,-1,5,13,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x60,0x38,0x18,
-};
-
-static const BitmapCharRec ch180 = {5,4,-2,-13,8,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0x70,0x88,0x8c,0xc,0x8,0x30,0x8,0x8c,0x4c,0x38,
-};
-
-static const BitmapCharRec ch179 = {6,10,0,-7,7,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xfc,0x44,0x20,0x30,0x10,0x8,0xc,0x8c,0x4c,0x38,
-};
-
-static const BitmapCharRec ch178 = {6,10,0,-7,7,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xff,0xf0,0xff,0xf0,0x0,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-0xff,0xf0,0xff,0xf0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch177 = {12,15,-1,0,14,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x38,0x44,0x82,0x82,0x82,0x44,0x38,
-};
-
-static const BitmapCharRec ch176 = {7,7,-1,-10,9,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xfc,0xfc,
-};
-
-static const BitmapCharRec ch175 = {6,2,-1,-14,8,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x7,0xf0,0x0,0x1c,0x1c,0x0,0x30,0x6,0x0,0x60,0x3,0x0,0x47,0x19,0x0,0xc2,
-0x31,0x80,0x82,0x20,0x80,0x82,0x40,0x80,0x83,0xe0,0x80,0x82,0x30,0x80,0x82,0x10,
-0x80,0xc2,0x11,0x80,0x42,0x31,0x0,0x67,0xe3,0x0,0x30,0x6,0x0,0x1c,0x1c,0x0,
-0x7,0xf0,0x0,
-};
-
-static const BitmapCharRec ch174 = {17,17,-1,0,19,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xfe,0xfe,
-};
-
-static const BitmapCharRec ch173 = {7,2,-1,-5,9,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0xff,0xf0,0xff,0xf0,
-};
-
-static const BitmapCharRec ch172 = {12,7,-1,-3,14,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x8,0x80,0x19,0x80,0x33,0x0,0x66,0x0,0xcc,0x0,0xcc,0x0,0x66,0x0,0x33,0x0,
-0x19,0x80,0x8,0x80,
-};
-
-static const BitmapCharRec ch171 = {9,10,-2,-1,13,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0x7e,0x0,0x76,0xcc,0xcc,0x7c,0xc,0xcc,0x78,
-};
-
-static const BitmapCharRec ch170 = {7,9,0,-8,8,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x7,0xf0,0x0,0x1c,0x1c,0x0,0x30,0x6,0x0,0x61,0xc3,0x0,0x47,0x71,0x0,0xc4,
-0x19,0x80,0x8c,0x0,0x80,0x88,0x0,0x80,0x88,0x0,0x80,0x88,0x0,0x80,0x8c,0x0,
-0x80,0xc4,0x19,0x80,0x47,0x31,0x0,0x61,0xe3,0x0,0x30,0x6,0x0,0x1c,0x1c,0x0,
-0x7,0xf0,0x0,
-};
-
-static const BitmapCharRec ch169 = {17,17,-1,0,19,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xcc,0xcc,
-};
-
-static const BitmapCharRec ch168 = {6,2,-1,-14,8,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x38,0x64,0x62,0x6,0xe,0x1c,0x38,0x74,0xe2,0xc3,0x83,0x87,0x4e,0x3c,0x38,0x70,
-0x60,0x46,0x26,0x1c,
-};
-
-static const BitmapCharRec ch167 = {8,20,-2,2,12,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0x0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch166 = {2,17,-2,0,6,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0xf,0xc0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x1f,0xe0,0x3,0x0,0x1f,0xe0,
-0x3,0x0,0x7,0x80,0xc,0x80,0xc,0xc0,0x18,0x40,0x18,0x60,0x30,0x20,0x70,0x30,
-0xf8,0x7c,
-};
-
-static const BitmapCharRec ch165 = {14,17,0,0,14,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0xc0,0x60,0xee,0xe0,0x7f,0xc0,0x31,0x80,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x31,0x80,0x7f,0xc0,0xee,0xe0,0xc0,0x60,
-};
-
-static const BitmapCharRec ch164 = {11,12,-1,-3,13,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xe7,0x80,0xbe,0xc0,0x78,0x40,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,
-0x30,0x0,0xfc,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x31,0x80,0x19,0x80,
-0xf,0x0,
-};
-
-static const BitmapCharRec ch163 = {10,17,-1,0,12,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x40,0x0,0x40,0x0,0x3e,0x0,0x7f,0x0,0x70,0x80,0xd0,0x0,0xc8,0x0,0xc8,0x0,
-0xc8,0x0,0xc4,0x0,0xc4,0x0,0x43,0x80,0x63,0x80,0x1f,0x0,0x1,0x0,0x1,0x0,
-};
-
-static const BitmapCharRec ch162 = {9,16,-1,2,12,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0x0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch161 = {2,17,-4,5,8,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,6,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,6,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x83,0x80,0xc7,0xc0,0x7c,0x60,0x38,0x20,
-};
-
-static const BitmapCharRec ch126 = {11,4,-1,-5,13,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xe0,0x30,0x18,0x18,0x18,0x18,0x18,0x18,0x8,0xc,0x4,0x3,0x4,0xc,0x8,0x18,
-0x18,0x18,0x18,0x18,0x30,0xe0,
-};
-
-static const BitmapCharRec ch125 = {8,22,-1,5,10,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch124 = {2,17,-2,0,6,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x7,0xc,0x18,0x18,0x18,0x18,0x18,0x18,0x10,0x30,0x20,0xc0,0x20,0x30,0x10,0x18,
-0x18,0x18,0x18,0x18,0xc,0x7,
-};
-
-static const BitmapCharRec ch123 = {8,22,-1,5,10,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xff,0xc3,0x61,0x70,0x30,0x38,0x18,0x1c,0xe,0x86,0xc3,0xff,
-};
-
-static const BitmapCharRec ch122 = {8,12,-1,0,10,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0xe0,0x0,0xf0,0x0,0x18,0x0,0x8,0x0,0xc,0x0,0x4,0x0,0xe,0x0,0xe,0x0,
-0x1a,0x0,0x19,0x0,0x19,0x0,0x31,0x0,0x30,0x80,0x30,0x80,0x60,0x80,0x60,0xc0,
-0xf1,0xe0,
-};
-
-static const BitmapCharRec ch121 = {11,17,0,5,11,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0xf1,0xe0,0x60,0xc0,0x21,0x80,0x33,0x80,0x1b,0x0,0xe,0x0,0xc,0x0,0x1a,0x0,
-0x39,0x0,0x31,0x80,0x60,0xc0,0xf1,0xe0,
-};
-
-static const BitmapCharRec ch120 = {11,12,-1,0,13,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x4,0x10,0x0,0xe,0x38,0x0,0xe,0x38,0x0,0x1a,0x28,0x0,0x1a,0x64,0x0,0x19,
-0x64,0x0,0x31,0x64,0x0,0x30,0xc2,0x0,0x30,0xc2,0x0,0x60,0xc2,0x0,0x60,0xc3,
-0x0,0xf1,0xe7,0x80,
-};
-
-static const BitmapCharRec ch119 = {17,12,0,0,17,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x4,0x0,0xe,0x0,0xe,0x0,0x1a,0x0,0x19,0x0,0x19,0x0,0x31,0x0,0x30,0x80,
-0x30,0x80,0x60,0x80,0x60,0xc0,0xf1,0xe0,
-};
-
-static const BitmapCharRec ch118 = {11,12,0,0,11,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,
-};
-
-static const BitmapCharRec ch117 = {11,12,-1,0,13,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x1c,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xfe,0x70,0x30,0x10,
-};
-
-static const BitmapCharRec ch116 = {7,15,0,0,7,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0xf8,0xc6,0x83,0x3,0x7,0x1e,0x7c,0x70,0xe0,0xc2,0x66,0x3e,
-};
-
-static const BitmapCharRec ch115 = {8,12,-1,0,10,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x76,0x6e,0xe6,
-};
-
-static const BitmapCharRec ch114 = {7,12,-1,0,8,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x3,0xc0,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1d,0x80,0x73,0x80,0x61,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x61,0x80,0x73,0x80,
-0x1d,0x80,
-};
-
-static const BitmapCharRec ch113 = {10,17,-1,5,12,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0xf0,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x6e,0x0,0x73,0x80,0x61,0x80,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x61,0x80,0x73,0x80,
-0xee,0x0,
-};
-
-static const BitmapCharRec ch112 = {10,17,-1,5,12,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,
-};
-
-static const BitmapCharRec ch111 = {10,12,-1,0,12,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0xf1,0xe0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x71,0xc0,0x6f,0x80,0xe7,0x0,
-};
-
-static const BitmapCharRec ch110 = {11,12,-1,0,13,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0xf1,0xe3,0xc0,0x60,0xc1,0x80,0x60,0xc1,0x80,0x60,0xc1,0x80,0x60,0xc1,0x80,0x60,
-0xc1,0x80,0x60,0xc1,0x80,0x60,0xc1,0x80,0x60,0xc1,0x80,0x71,0xe3,0x80,0x6f,0x9f,
-0x0,0xe7,0xe,0x0,
-};
-
-static const BitmapCharRec ch109 = {18,12,-1,0,20,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
-0xe0,
-};
-
-static const BitmapCharRec ch108 = {4,17,-1,0,6,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0xf3,0xe0,0x61,0xc0,0x63,0x80,0x67,0x0,0x6e,0x0,0x6c,0x0,0x78,0x0,0x68,0x0,
-0x64,0x0,0x66,0x0,0x63,0x0,0x67,0xc0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,
-0xe0,0x0,
-};
-
-static const BitmapCharRec ch107 = {11,17,-1,0,12,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0xc0,0xe0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0x70,0x0,0x0,0x0,0x30,0x30,
-};
-
-static const BitmapCharRec ch106 = {4,22,0,5,6,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0x0,0x0,0x0,0x60,
-0x60,
-};
-
-static const BitmapCharRec ch105 = {4,17,-1,0,6,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0xf1,0xe0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x71,0xc0,0x6f,0x80,0x67,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,
-0xe0,0x0,
-};
-
-static const BitmapCharRec ch104 = {11,17,-1,0,13,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x3f,0x0,0xf1,0xc0,0xc0,0x60,0xc0,0x20,0x60,0x60,0x3f,0xc0,0x7f,0x0,0x60,0x0,
-0x30,0x0,0x3e,0x0,0x33,0x0,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x0,
-0x1f,0xc0,
-};
-
-static const BitmapCharRec ch103 = {11,17,-1,5,12,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xfe,0x30,0x30,0x30,0x16,
-0xe,
-};
-
-static const BitmapCharRec ch102 = {7,17,0,0,7,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,
-};
-
-static const BitmapCharRec ch101 = {9,12,-1,0,11,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x1e,0xc0,0x73,0x80,0x61,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,
-0xc1,0x80,0x61,0x80,0x73,0x80,0x1d,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,
-0x3,0x80,
-};
-
-static const BitmapCharRec ch100 = {10,17,-1,0,12,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0x41,0x80,0x63,0x80,0x1f,0x0,
-};
-
-static const BitmapCharRec ch99 = {9,12,-1,0,11,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0x5e,0x0,0x73,0x80,0x61,0x80,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x61,0x80,0x73,0x80,0x6e,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,
-0xe0,0x0,
-};
-
-static const BitmapCharRec ch98 = {10,17,-1,0,12,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,
-};
-
-static const BitmapCharRec ch97 = {9,12,-1,0,11,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0x60,0xe0,0x80,0xc0,0x60,
-};
-
-static const BitmapCharRec ch96 = {3,5,-2,-12,7,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xff,0xf8,0xff,0xf8,
-};
-
-static const BitmapCharRec ch95 = {13,2,0,5,13,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x80,0x80,0xc1,0x80,0x41,0x0,0x63,0x0,0x22,0x0,0x36,0x0,0x14,0x0,0x1c,0x0,
-0x8,0x0,
-};
-
-static const BitmapCharRec ch94 = {9,9,-1,-8,11,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
-0x18,0x18,0x18,0x18,0xf8,
-};
-
-static const BitmapCharRec ch93 = {5,21,-1,4,8,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x6,0x6,0x4,0xc,0xc,0x8,0x18,0x18,0x10,0x30,0x30,0x20,0x60,0x60,0x40,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch92 = {7,17,0,0,7,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xf8,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0xc0,0xc0,0xf8,
-};
-
-static const BitmapCharRec ch91 = {5,21,-2,4,8,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xff,0xf8,0xe0,0x18,0x70,0x8,0x30,0x8,0x38,0x0,0x18,0x0,0x1c,0x0,0xe,0x0,
-0x6,0x0,0x7,0x0,0x3,0x0,0x3,0x80,0x1,0xc0,0x80,0xc0,0x80,0xe0,0xc0,0x70,
-0xff,0xf0,
-};
-
-static const BitmapCharRec ch90 = {13,17,-1,0,15,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x7,0xe0,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x3,0xc0,
-0x3,0x40,0x6,0x60,0x6,0x20,0xc,0x30,0x1c,0x10,0x18,0x18,0x38,0x8,0x30,0xc,
-0xfc,0x3f,
-};
-
-static const BitmapCharRec ch89 = {16,17,0,0,16,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0xfc,0xf,0xc0,0x30,0x3,0x80,0x18,0x7,0x0,0x8,0xe,0x0,0x4,0xc,0x0,0x6,
-0x18,0x0,0x2,0x38,0x0,0x1,0x70,0x0,0x0,0xe0,0x0,0x0,0xc0,0x0,0x1,0xc0,
-0x0,0x3,0xa0,0x0,0x3,0x10,0x0,0x6,0x8,0x0,0xe,0xc,0x0,0x1c,0x6,0x0,
-0x7e,0xf,0x80,
-};
-
-static const BitmapCharRec ch88 = {18,17,0,0,18,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x1,0x83,0x0,0x1,0x83,0x0,0x1,0x83,0x80,0x3,0x87,0x80,0x3,0x46,0x80,0x3,
-0x46,0xc0,0x6,0x46,0x40,0x6,0x4c,0x40,0x6,0x4c,0x60,0xc,0x2c,0x60,0xc,0x2c,
-0x20,0x18,0x2c,0x20,0x18,0x18,0x30,0x18,0x18,0x10,0x30,0x18,0x10,0x30,0x18,0x18,
-0xfc,0x7e,0x7e,
-};
-
-static const BitmapCharRec ch87 = {23,17,0,0,23,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x1,0x80,0x0,0x1,0x80,0x0,0x1,0x80,0x0,0x3,0xc0,0x0,0x3,0x40,0x0,0x3,
-0x60,0x0,0x6,0x20,0x0,0x6,0x20,0x0,0x6,0x30,0x0,0xc,0x10,0x0,0xc,0x18,
-0x0,0x18,0x8,0x0,0x18,0x8,0x0,0x18,0xc,0x0,0x30,0x4,0x0,0x30,0x6,0x0,
-0xfc,0x1f,0x80,
-};
-
-static const BitmapCharRec ch86 = {17,17,0,0,17,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,
-};
-
-static const BitmapCharRec ch85 = {16,17,-1,0,18,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0xf,0xc0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,
-0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x83,0x4,0x83,0x4,0xc3,0xc,
-0xff,0xfc,
-};
-
-static const BitmapCharRec ch84 = {14,17,-1,0,16,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x9e,0x0,0xf1,0x80,0xc0,0xc0,0x80,0x60,0x80,0x60,0x0,0x60,0x0,0xe0,0x3,0xc0,
-0xf,0x80,0x1e,0x0,0x78,0x0,0xe0,0x0,0xc0,0x40,0xc0,0x40,0xc0,0xc0,0x63,0xc0,
-0x1e,0x40,
-};
-
-static const BitmapCharRec ch83 = {11,17,-1,0,13,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0xfc,0x1e,0x30,0x1c,0x30,0x38,0x30,0x70,0x30,0x60,0x30,0xc0,0x31,0xc0,0x33,0x80,
-0x3f,0xc0,0x30,0x70,0x30,0x30,0x30,0x38,0x30,0x18,0x30,0x38,0x30,0x30,0x30,0x70,
-0xff,0xc0,
-};
-
-static const BitmapCharRec ch82 = {15,17,-1,0,16,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x0,0xf,0x0,0x38,0x0,0x70,0x0,0xe0,0x1,0xc0,0x7,0xe0,0x1c,0x38,0x38,0x1c,
-0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,0x7,0xe0,
-};
-
-static const BitmapCharRec ch81 = {16,22,-1,5,18,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0xfc,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,
-0x3f,0xc0,0x30,0x70,0x30,0x30,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x30,0x30,0x70,
-0xff,0xc0,
-};
-
-static const BitmapCharRec ch80 = {13,17,-1,0,15,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,
-};
-
-static const BitmapCharRec ch79 = {16,17,-1,0,18,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0xf8,0xc,0x20,0x1c,0x20,0x1c,0x20,0x34,0x20,0x64,0x20,0x64,0x20,0xc4,0x21,0x84,
-0x21,0x84,0x23,0x4,0x26,0x4,0x26,0x4,0x2c,0x4,0x38,0x4,0x38,0x4,0x30,0x4,
-0xf0,0x1f,
-};
-
-static const BitmapCharRec ch78 = {16,17,-1,0,18,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0xf8,0x21,0xf8,0x20,0x60,0x60,0x20,0x60,0x60,0x20,0xd0,0x60,0x20,0xd0,0x60,0x21,
-0x88,0x60,0x21,0x88,0x60,0x23,0x8,0x60,0x23,0x4,0x60,0x26,0x4,0x60,0x26,0x2,
-0x60,0x2c,0x2,0x60,0x2c,0x2,0x60,0x38,0x1,0x60,0x38,0x1,0x60,0x30,0x0,0xe0,
-0xf0,0x0,0xf8,
-};
-
-static const BitmapCharRec ch77 = {21,17,-1,0,22,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,
-0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,
-0xfc,0x0,
-};
-
-static const BitmapCharRec ch76 = {13,17,-1,0,14,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0xfc,0x1f,0x30,0xe,0x30,0x1c,0x30,0x38,0x30,0x70,0x30,0xe0,0x31,0xc0,0x33,0x80,
-0x3f,0x0,0x3e,0x0,0x33,0x0,0x31,0x80,0x30,0xc0,0x30,0x60,0x30,0x30,0x30,0x18,
-0xfc,0x7e,
-};
-
-static const BitmapCharRec ch75 = {16,17,-1,0,17,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x78,0x0,0xcc,0x0,0xc6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-0x1f,0x80,
-};
-
-static const BitmapCharRec ch74 = {9,17,-1,0,11,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xfc,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xfc,
-};
-
-static const BitmapCharRec ch73 = {6,17,-1,0,8,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,
-0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x3f,0xfe,0x0,0x30,0x6,0x0,0x30,0x6,
-0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,
-0xfc,0x1f,0x80,
-};
-
-static const BitmapCharRec ch72 = {17,17,-1,0,19,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x7,0xe0,0x1e,0x38,0x38,0x1c,0x60,0xc,0x60,0xc,0xc0,0xc,0xc0,0xc,0xc0,0x3f,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0x60,0x4,0x60,0x4,0x38,0xc,0x1c,0x3c,
-0x7,0xe4,
-};
-
-static const BitmapCharRec ch71 = {16,17,-1,0,18,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0xfc,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x20,0x30,0x20,
-0x3f,0xe0,0x30,0x20,0x30,0x20,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,
-};
-
-static const BitmapCharRec ch70 = {12,17,-1,0,14,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,
-};
-
-static const BitmapCharRec ch69 = {13,17,-1,0,15,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xff,0xc0,0x30,0x70,0x30,0x38,0x30,0xc,0x30,0xc,0x30,0x6,0x30,0x6,0x30,0x6,
-0x30,0x6,0x30,0x6,0x30,0x6,0x30,0x6,0x30,0xc,0x30,0xc,0x30,0x38,0x30,0x70,
-0xff,0xc0,
-};
-
-static const BitmapCharRec ch68 = {15,17,-1,0,17,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x7,0xe0,0x1e,0x38,0x38,0x8,0x60,0x4,0x60,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0x60,0x4,0x60,0x4,0x38,0xc,0x1c,0x3c,
-0x7,0xe4,
-};
-
-static const BitmapCharRec ch67 = {14,17,-1,0,16,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xff,0xe0,0x30,0x78,0x30,0x18,0x30,0xc,0x30,0xc,0x30,0xc,0x30,0x18,0x30,0x38,
-0x3f,0xe0,0x30,0x40,0x30,0x30,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x30,0x30,0x70,
-0xff,0xc0,
-};
-
-static const BitmapCharRec ch66 = {14,17,-1,0,16,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,
-};
-
-static const BitmapCharRec ch65 = {17,17,0,0,17,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x3,0xf0,0x0,0xe,0xc,0x0,0x18,0x0,0x0,0x30,0x0,0x0,0x61,0xde,0x0,0x63,
-0x7b,0x0,0xc6,0x39,0x80,0xc6,0x18,0x80,0xc6,0x18,0xc0,0xc6,0x18,0x40,0xc6,0xc,
-0x40,0xc3,0xc,0x40,0xc3,0x8c,0x40,0xe1,0xfc,0x40,0x60,0xec,0xc0,0x70,0x0,0x80,
-0x38,0x1,0x80,0x1c,0x3,0x0,0xf,0xe,0x0,0x3,0xf8,0x0,
-};
-
-static const BitmapCharRec ch64 = {18,20,-2,3,22,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x30,0x30,0x0,0x0,0x10,0x10,0x10,0x18,0x18,0xc,0xe,0x7,0xc3,0xc3,0x83,0xc6,
-0x7c,
-};
-
-static const BitmapCharRec ch63 = {8,17,-2,0,11,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0xc0,0x0,0x70,0x0,0x1c,0x0,0x7,0x0,0x1,0xc0,0x0,0x60,0x1,0xc0,0x7,0x0,
-0x1c,0x0,0x70,0x0,0xc0,0x0,
-};
-
-static const BitmapCharRec ch62 = {11,11,-1,-1,13,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xff,0xf0,0xff,0xf0,0x0,0x0,0x0,0x0,0xff,0xf0,0xff,0xf0,
-};
-
-static const BitmapCharRec ch61 = {12,6,-1,-4,14,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x0,0x60,0x1,0xc0,0x7,0x0,0x1c,0x0,0x70,0x0,0xc0,0x0,0x70,0x0,0x1c,0x0,
-0x7,0x0,0x1,0xc0,0x0,0x60,
-};
-
-static const BitmapCharRec ch60 = {11,11,-1,-1,13,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0xc0,0x60,0x20,0xe0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch59 = {3,14,-2,3,7,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0xc0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch58 = {2,11,-2,0,6,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0xf0,0x0,0x1c,0x0,0x6,0x0,0x3,0x0,0x3,0x80,0x1,0x80,0x1d,0x80,0x73,0xc0,
-0x61,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0x61,0x80,0x77,0x80,
-0x1e,0x0,
-};
-
-static const BitmapCharRec ch57 = {10,17,-1,0,12,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x1e,0x0,0x73,0x80,0xe1,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x41,0xc0,0x61,0x80,
-0x37,0x0,0x1e,0x0,0x1e,0x0,0x33,0x0,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x0,
-0x1e,0x0,
-};
-
-static const BitmapCharRec ch56 = {10,17,-1,0,12,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x18,0x0,0x18,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0x4,0x0,0x6,0x0,0x6,0x0,
-0x2,0x0,0x3,0x0,0x3,0x0,0x1,0x0,0x1,0x80,0x81,0x80,0xc0,0xc0,0xff,0xc0,
-0x7f,0xc0,
-};
-
-static const BitmapCharRec ch55 = {10,17,-1,0,12,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x1e,0x0,0x7b,0x80,0x61,0x80,0xe0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc1,0x80,0xf3,0x80,0xee,0x0,0x60,0x0,0x70,0x0,0x30,0x0,0x18,0x0,0xe,0x0,
-0x3,0xc0,
-};
-
-static const BitmapCharRec ch54 = {10,17,-1,0,12,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x7e,0x0,0xe3,0x80,0xc1,0x80,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x1,0xc0,
-0x3,0x80,0xf,0x80,0x7e,0x0,0x78,0x0,0x60,0x0,0x20,0x0,0x20,0x0,0x1f,0x80,
-0x1f,0xc0,
-};
-
-static const BitmapCharRec ch53 = {10,17,-1,0,12,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0xff,0xc0,0xff,0xc0,0xc3,0x0,0x43,0x0,
-0x63,0x0,0x23,0x0,0x33,0x0,0x13,0x0,0x1b,0x0,0xb,0x0,0x7,0x0,0x7,0x0,
-0x3,0x0,
-};
-
-static const BitmapCharRec ch52 = {10,17,-1,0,12,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x78,0x0,0xe6,0x0,0xc3,0x0,0x1,0x0,0x1,0x80,0x1,0x80,0x1,0x80,0x3,0x80,
-0x7,0x0,0x1e,0x0,0xc,0x0,0x6,0x0,0x83,0x0,0x83,0x0,0x47,0x0,0x7e,0x0,
-0x1c,0x0,
-};
-
-static const BitmapCharRec ch51 = {9,17,-1,0,12,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xff,0x80,0xff,0xc0,0x60,0x40,0x30,0x0,0x18,0x0,0xc,0x0,0x4,0x0,0x6,0x0,
-0x3,0x0,0x3,0x0,0x1,0x80,0x1,0x80,0x81,0x80,0x81,0x80,0x43,0x80,0x7f,0x0,
-0x1c,0x0,
-};
-
-static const BitmapCharRec ch50 = {10,17,-1,0,12,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x78,0x18,
-0x8,
-};
-
-static const BitmapCharRec ch49 = {8,17,-2,0,12,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x1e,0x0,0x33,0x0,0x61,0x80,0x61,0x80,0xe1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x61,0x80,0x61,0x80,0x33,0x0,
-0x1e,0x0,
-};
-
-static const BitmapCharRec ch48 = {10,17,-1,0,12,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0xc0,0xc0,0xc0,0x60,0x60,0x20,0x30,0x30,0x10,0x18,0x18,0x8,0xc,0xc,0x4,0x6,
-0x6,0x3,0x3,0x3,
-};
-
-static const BitmapCharRec ch47 = {8,20,1,3,7,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch46 = {2,2,-2,0,6,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xff,0xf0,0xff,0xf0,
-};
-
-static const BitmapCharRec ch45 = {12,2,-1,-6,14,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0xc0,0x60,0x20,0xe0,0xc0,
-};
-
-static const BitmapCharRec ch44 = {3,5,-2,3,7,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0xff,0xf0,0xff,0xf0,0x6,0x0,
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch43 = {12,12,-1,-1,14,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0x8,0x0,0x1c,0x0,0xc9,0x80,0xeb,0x80,0x1c,0x0,0xeb,0x80,0xc9,0x80,0x1c,0x0,
-0x8,0x0,
-};
-
-static const BitmapCharRec ch42 = {9,9,-2,-8,12,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x20,0x30,0x10,0x18,0x18,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0x18,
-0x18,0x10,0x30,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {6,22,-1,5,8,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x4,0x8,0x10,0x30,0x20,0x60,0x60,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x60,
-0x60,0x20,0x30,0x10,0x8,0x4,
-};
-
-static const BitmapCharRec ch40 = {6,22,-1,5,8,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0xc0,0x60,0x20,0xe0,0xc0,
-};
-
-static const BitmapCharRec ch39 = {3,5,-3,-12,8,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x3c,0x3c,0x7f,0x7e,0xe1,0xe1,0xc0,0xc0,0xc1,0xc0,0xc1,0xa0,0x63,0x20,0x37,0x10,
-0x1e,0x18,0xe,0x3e,0xf,0x0,0x1d,0x80,0x18,0xc0,0x18,0x40,0x18,0x40,0xc,0xc0,
-0x7,0x80,
-};
-
-static const BitmapCharRec ch38 = {16,17,-1,0,18,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x30,0x3c,0x0,0x18,0x72,0x0,0xc,0x61,0x0,0x4,0x60,0x80,0x6,0x60,0x80,0x3,
-0x30,0x80,0x1,0x19,0x80,0x1,0x8f,0x0,0x78,0xc0,0x0,0xe4,0x40,0x0,0xc2,0x60,
-0x0,0xc1,0x30,0x0,0xc1,0x10,0x0,0x61,0x18,0x0,0x33,0xfc,0x0,0x1e,0xc,0x0,
-};
-
-static const BitmapCharRec ch37 = {17,16,-1,0,19,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x4,0x0,0x4,0x0,0x3f,0x0,0xe5,0xc0,0xc4,0xc0,0x84,0x60,0x84,0x60,0x4,0x60,
-0x4,0xe0,0x7,0xc0,0x7,0x80,0x1e,0x0,0x3c,0x0,0x74,0x0,0x64,0x0,0x64,0x20,
-0x64,0x60,0x34,0xe0,0x1f,0x80,0x4,0x0,0x4,0x0,
-};
-
-static const BitmapCharRec ch36 = {11,21,0,2,12,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x22,0x0,0x22,0x0,0x22,0x0,0x22,0x0,0x22,0x0,0xff,0xc0,0xff,0xc0,0x11,0x0,
-0x11,0x0,0x11,0x0,0x7f,0xe0,0x7f,0xe0,0x8,0x80,0x8,0x80,0x8,0x80,0x8,0x80,
-0x8,0x80,
-};
-
-static const BitmapCharRec ch35 = {11,17,-1,0,13,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0x88,0xcc,0xcc,0xcc,0xcc,
-};
-
-static const BitmapCharRec ch34 = {6,5,-1,-12,10,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0xc0,0xc0,0x0,0x0,0x0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch33 = {2,17,-3,0,8,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,6,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,6,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-const BitmapFontRec glutBitmapTimesRoman24 = {
-"-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/beos/glut_util.c b/src/glut/beos/glut_util.c
deleted file mode 100644 (file)
index 29e7951..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "glutint.h"
-
-/* strdup is actually not a standard ANSI C or POSIX routine
-   so implement a private one for GLUT.  OpenVMS does not have a
-   strdup; Linux's standard libc doesn't declare strdup by default
-   (unless BSD or SVID interfaces are requested). */
-char *
-__glutStrdup(const char *string)
-{
-  char *copy;
-
-  copy = (char*) malloc(strlen(string) + 1);
-  if (copy == NULL)
-    return NULL;
-  strcpy(copy, string);
-  return copy;
-}
-
-void
-__glutWarning(char *format,...)
-{
-  va_list args;
-
-  va_start(args, format);
-  fprintf(stderr, "GLUT: Warning in %s: ",
-    __glutProgramName ? __glutProgramName : "(unamed)");
-  vfprintf(stderr, format, args);
-  va_end(args);
-  putc('\n', stderr);
-}
-
-/* CENTRY */
-void APIENTRY 
-glutReportErrors(void)
-{
-  GLenum error;
-
-  while ((error = glGetError()) != GL_NO_ERROR)
-    __glutWarning("GL error: %s", gluErrorString(error));
-}
-/* ENDCENTRY */
-
-void
-__glutFatalError(char *format,...)
-{
-  va_list args;
-
-  va_start(args, format);
-  fprintf(stderr, "GLUT: Fatal Error in %s: ",
-    __glutProgramName ? __glutProgramName : "(unamed)");
-  vfprintf(stderr, format, args);
-  va_end(args);
-  putc('\n', stderr);
-  exit(1);
-}
-
-void
-__glutFatalUsage(char *format,...)
-{
-  va_list args;
-
-  va_start(args, format);
-  fprintf(stderr, "GLUT: Fatal API Usage in %s: ",
-    __glutProgramName ? __glutProgramName : "(unamed)");
-  vfprintf(stderr, format, args);
-  va_end(args);
-  putc('\n', stderr);
-  abort();
-}
diff --git a/src/glut/beos/glut_vidresize.c b/src/glut/beos/glut_vidresize.c
deleted file mode 100644 (file)
index a9d9e63..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1996. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-
-#if !defined(_WIN32) && !defined(__BEOS__)
-#include <GL/glx.h>
-#endif
-
-#ifdef __sgi
-#include <dlfcn.h>
-#endif
-
-#include "glutint.h"
-
-/* Grumble.  The IRIX 6.3 and early IRIX 6.4 OpenGL headers
-   support the video resize extension, but failed to define
-   GLX_SGIX_video_resize. */
-#ifdef GLX_SYNC_FRAME_SGIX
-#define GLX_SGIX_video_resize 1
-#endif
-
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-static int canVideoResize = -1;
-static int videoResizeChannel;
-#else
-static int canVideoResize = 0;
-#endif
-static int videoResizeInUse = 0;
-static int dx = -1, dy = -1, dw = -1, dh = -1;
-
-/* XXX Note that IRIX 6.2, 6.3, and some 6.4 versions have a
-   bug where programs seg-fault when they attempt video
-   resizing from an indirect OpenGL context (either local or
-   over a network). */
-
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-
-static volatile int errorCaught;
-
-/* ARGSUSED */
-static
-catchXSGIvcErrors(Display * dpy, XErrorEvent * event)
-{
-  errorCaught = 1;
-  return 0;
-}
-#endif
-
-/* CENTRY */
-int APIENTRY 
-glutVideoResizeGet(GLenum param)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (canVideoResize < 0) {
-    canVideoResize = __glutIsSupportedByGLX("GLX_SGIX_video_resize");
-    if (canVideoResize) {
-#if __sgi
-      /* This is a hack because IRIX 6.2, 6.3, and some 6.4
-         versions were released with GLX_SGIX_video_resize
-         being advertised by the X server though the video
-         resize extension is not actually supported.  We try to
-         determine if the libGL.so we are using actually has a
-         video resize entrypoint before we try to use the
-         feature. */
-      void (*func) (void);
-      void *glxDso = dlopen("libGL.so", RTLD_LAZY);
-
-      func = (void (*)(void)) dlsym(glxDso, "glXQueryChannelDeltasSGIX");
-      if (!func) {
-        canVideoResize = 0;
-      } else
-#endif
-      {
-        char *channelString;
-        int (*handler) (Display *, XErrorEvent *);
-
-        channelString = getenv("GLUT_VIDEO_RESIZE_CHANNEL");
-        videoResizeChannel = channelString ? atoi(channelString) : 0;
-
-        /* Work around another annoying problem with SGI's
-           GLX_SGIX_video_resize implementation.  Early IRIX
-           6.4 OpenGL's advertise the extension and have the
-           video resize API, but an XSGIvc X protocol errors
-           result trying to use the API.  Set up an error
-           handler to intercept what would otherwise be a fatal
-           error.  If an error was recieved, do not report that
-           video resize is possible. */
-        handler = XSetErrorHandler(catchXSGIvcErrors);
-
-        errorCaught = 0;
-
-        glXQueryChannelDeltasSGIX(__glutDisplay, __glutScreen,
-          videoResizeChannel, &dx, &dy, &dw, &dh);
-
-        /* glXQueryChannelDeltasSGIX is an inherent X server
-           round-trip so we know we will have gotten either the
-           correct reply or and error by this time. */
-        XSetErrorHandler(handler);
-
-        /* Still yet another work around.  In IRIX 6.4 betas,
-           glXQueryChannelDeltasSGIX will return as if it
-           succeeded, but the values are filled with junk.
-           Watch to make sure the delta variables really make
-           sense. */
-        if (errorCaught ||
-          dx < 0 || dy < 0 || dw < 0 || dh < 0 ||
-          dx > 2048 || dy > 2048 || dw > 2048 || dh > 2048) {
-          canVideoResize = 0;
-        }
-      }
-    }
-  }
-#endif /* GLX_SGIX_video_resize */
-
-  switch (param) {
-  case GLUT_VIDEO_RESIZE_POSSIBLE:
-    return canVideoResize;
-  case GLUT_VIDEO_RESIZE_IN_USE:
-    return videoResizeInUse;
-  case GLUT_VIDEO_RESIZE_X_DELTA:
-    return dx;
-  case GLUT_VIDEO_RESIZE_Y_DELTA:
-    return dy;
-  case GLUT_VIDEO_RESIZE_WIDTH_DELTA:
-    return dw;
-  case GLUT_VIDEO_RESIZE_HEIGHT_DELTA:
-    return dh;
-  case GLUT_VIDEO_RESIZE_X:
-  case GLUT_VIDEO_RESIZE_Y:
-  case GLUT_VIDEO_RESIZE_WIDTH:
-  case GLUT_VIDEO_RESIZE_HEIGHT:
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-    if (videoResizeInUse) {
-      int x, y, width, height;
-
-      glXQueryChannelRectSGIX(__glutDisplay, __glutScreen,
-        videoResizeChannel, &x, &y, &width, &height);
-      switch (param) {
-      case GLUT_VIDEO_RESIZE_X:
-        return x;
-      case GLUT_VIDEO_RESIZE_Y:
-        return y;
-      case GLUT_VIDEO_RESIZE_WIDTH:
-        return width;
-      case GLUT_VIDEO_RESIZE_HEIGHT:
-        return height;
-      }
-    }
-#endif
-    return -1;
-  default:
-    __glutWarning("invalid glutVideoResizeGet parameter: %d", param);
-    return -1;
-  }
-}
-
-void APIENTRY 
-glutSetupVideoResizing(void)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
-    glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, __glutCurrentWindow->win);
-    videoResizeInUse = 1;
-  } else
-#endif
-    __glutFatalError("glutEstablishVideoResizing: video resizing not possible.\n");
-}
-
-void APIENTRY 
-glutStopVideoResizing(void)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
-    if (videoResizeInUse) {
-      glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
-        videoResizeChannel, None);
-      videoResizeInUse = 0;
-    }
-  }
-#endif
-}
-
-/* ARGSUSED */
-void APIENTRY 
-glutVideoResize(int x, int y, int width, int height)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (videoResizeInUse) {
-#ifdef GLX_SYNC_SWAP_SGIX
-    /* glXChannelRectSyncSGIX introduced in a patch to IRIX
-       6.2; the original unpatched IRIX 6.2 behavior is always
-       GLX_SYNC_SWAP_SGIX. */
-    glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, GLX_SYNC_SWAP_SGIX);
-#endif
-    glXChannelRectSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, x, y, width, height);
-  }
-#endif
-}
-
-/* ARGSUSED */
-void APIENTRY 
-glutVideoPan(int x, int y, int width, int height)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (videoResizeInUse) {
-#ifdef GLX_SYNC_FRAME_SGIX
-    /* glXChannelRectSyncSGIX introduced in a patch to IRIX
-       6.2; the original unpatched IRIX 6.2 behavior is always
-       GLX_SYNC_SWAP_SGIX.  We just ignore that we cannot
-       accomplish GLX_SYNC_FRAME_SGIX on IRIX unpatched 6.2;
-       this means you'd need a glutSwapBuffers to actually
-       realize the video resize. */
-    glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, GLX_SYNC_FRAME_SGIX);
-#endif
-    glXChannelRectSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, x, y, width, height);
-  }
-#endif
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/beos/glutbitmap.h b/src/glut/beos/glutbitmap.h
deleted file mode 100644 (file)
index 32bf53c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __glutbitmap_h__
-#define __glutbitmap_h__
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include <GL/glut.h>
-
-typedef struct {
-  const GLsizei width;
-  const GLsizei height;
-  const GLfloat xorig;
-  const GLfloat yorig;
-  const GLfloat advance;
-  const GLubyte *bitmap;
-} BitmapCharRec, *BitmapCharPtr;
-
-typedef struct {
-  const char *name;
-  const int num_chars;
-  const int first;
-  const BitmapCharRec * const *ch;
-} BitmapFontRec, *BitmapFontPtr;
-
-typedef void *GLUTbitmapFont;
-
-#endif /* __glutbitmap_h__ */
diff --git a/src/glut/beos/glutint.h b/src/glut/beos/glutint.h
deleted file mode 100644 (file)
index 06b417e..0000000
+++ /dev/null
@@ -1,814 +0,0 @@
-#ifndef __glutint_h__
-#define __glutint_h__
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#if defined(__CYGWIN32__)
-#include <sys/time.h>
-#endif
-
-#if defined(_WIN32)
-#include "glutwin32.h"
-#elif !defined(__BEOS__)
-#ifdef __sgi
-#define SUPPORT_FORTRAN
-#endif
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <GL/glx.h>
-#endif
-
-#include <GL/glut.h>
-
-/* Non-Win32 platforms need APIENTRY defined to nothing
-   because all the GLUT routines have the APIENTRY prefix
-   to make Win32 happy. */
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-
-#ifdef __vms
-#if ( __VMS_VER < 70000000 )
-struct timeval {
-  __int64 val;
-};
-extern int sys$gettim(struct timeval *);
-#else
-#include <time.h>
-#endif
-#else
-#include <sys/types.h>
-#if !defined(_WIN32)
-#include <sys/time.h>
-#else
-#include <winsock.h>
-#endif
-#endif
-#if defined(__vms) && ( __VMS_VER < 70000000 )
-
-/* For VMS6.2 or lower :
-   One TICK on VMS is 100 nanoseconds; 0.1 microseconds or
-   0.0001 milliseconds. This means that there are 0.01
-   ticks/ns, 10 ticks/us, 10,000 ticks/ms and 10,000,000
-   ticks/second. */
-
-#define TICKS_PER_MILLISECOND 10000
-#define TICKS_PER_SECOND      10000000
-
-#define GETTIMEOFDAY(_x) (void) sys$gettim (_x);
-
-#define ADD_TIME(dest, src1, src2) { \
-  (dest).val = (src1).val + (src2).val; \
-}
-
-#define TIMEDELTA(dest, src1, src2) { \
-  (dest).val = (src1).val - (src2).val; \
-}
-
-#define IS_AFTER(t1, t2) ((t2).val > (t1).val)
-
-#define IS_AT_OR_AFTER(t1, t2) ((t2).val >= (t1).val)
-
-#else
-#if defined(SVR4) && !defined(sun)  /* Sun claims SVR4, but
-                                       wants 2 args. */
-#define GETTIMEOFDAY(_x) gettimeofday(_x)
-#else
-#define GETTIMEOFDAY(_x) gettimeofday(_x, NULL)
-#endif
-#define ADD_TIME(dest, src1, src2) { \
-  if(((dest).tv_usec = \
-    (src1).tv_usec + (src2).tv_usec) >= 1000000) { \
-    (dest).tv_usec -= 1000000; \
-    (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1; \
-  } else { \
-    (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \
-    if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
-      (dest).tv_sec --;(dest).tv_usec += 1000000; \
-    } \
-  } \
-}
-#define TIMEDELTA(dest, src1, src2) { \
-  if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \
-    (dest).tv_usec += 1000000; \
-    (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
-  } else { \
-     (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
-  } \
-}
-#define IS_AFTER(t1, t2) \
-  (((t2).tv_sec > (t1).tv_sec) || \
-  (((t2).tv_sec == (t1).tv_sec) && \
-  ((t2).tv_usec > (t1).tv_usec)))
-#define IS_AT_OR_AFTER(t1, t2) \
-  (((t2).tv_sec > (t1).tv_sec) || \
-  (((t2).tv_sec == (t1).tv_sec) && \
-  ((t2).tv_usec >= (t1).tv_usec)))
-#endif
-
-#define IGNORE_IN_GAME_MODE() \
-  { if (__glutGameModeWindow) return; }
-
-/* BeOS doesn't need most of this file */
-#ifndef __BEOS__
-
-#define GLUT_WIND_IS_RGB(x)         (((x) & GLUT_INDEX) == 0)
-#define GLUT_WIND_IS_INDEX(x)       (((x) & GLUT_INDEX) != 0)
-#define GLUT_WIND_IS_SINGLE(x)      (((x) & GLUT_DOUBLE) == 0)
-#define GLUT_WIND_IS_DOUBLE(x)      (((x) & GLUT_DOUBLE) != 0)
-#define GLUT_WIND_HAS_ACCUM(x)      (((x) & GLUT_ACCUM) != 0)
-#define GLUT_WIND_HAS_ALPHA(x)      (((x) & GLUT_ALPHA) != 0)
-#define GLUT_WIND_HAS_DEPTH(x)      (((x) & GLUT_DEPTH) != 0)
-#define GLUT_WIND_HAS_STENCIL(x)    (((x) & GLUT_STENCIL) != 0)
-#define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0)
-#define GLUT_WIND_IS_STEREO(x)      (((x) & GLUT_STEREO) != 0)
-#define GLUT_WIND_IS_LUMINANCE(x)   (((x) & GLUT_LUMINANCE) != 0)
-#define GLUT_MAP_WORK               (1 << 0)
-#define GLUT_EVENT_MASK_WORK        (1 << 1)
-#define GLUT_REDISPLAY_WORK         (1 << 2)
-#define GLUT_CONFIGURE_WORK         (1 << 3)
-#define GLUT_COLORMAP_WORK          (1 << 4)
-#define GLUT_DEVICE_MASK_WORK      (1 << 5)
-#define GLUT_FINISH_WORK           (1 << 6)
-#define GLUT_DEBUG_WORK                    (1 << 7)
-#define GLUT_DUMMY_WORK                    (1 << 8)
-#define GLUT_FULL_SCREEN_WORK       (1 << 9)
-#define GLUT_OVERLAY_REDISPLAY_WORK (1 << 10)
-#define GLUT_REPAIR_WORK            (1 << 11)
-#define GLUT_OVERLAY_REPAIR_WORK    (1 << 12)
-
-/* Frame buffer capability macros and types. */
-#define RGBA                    0
-#define BUFFER_SIZE             1
-#define DOUBLEBUFFER            2
-#define STEREO                  3
-#define AUX_BUFFERS             4
-#define RED_SIZE                5  /* Used as mask bit for
-                                      "color selected". */
-#define GREEN_SIZE              6
-#define BLUE_SIZE               7
-#define ALPHA_SIZE              8
-#define DEPTH_SIZE              9
-#define STENCIL_SIZE            10
-#define ACCUM_RED_SIZE          11  /* Used as mask bit for
-                                       "acc selected". */
-#define ACCUM_GREEN_SIZE        12
-#define ACCUM_BLUE_SIZE         13
-#define ACCUM_ALPHA_SIZE        14
-#define LEVEL                   15
-
-#define NUM_GLXCAPS             (LEVEL + 1)
-
-#define XVISUAL                 (NUM_GLXCAPS + 0)
-#define TRANSPARENT             (NUM_GLXCAPS + 1)
-#define SAMPLES                 (NUM_GLXCAPS + 2)
-#define XSTATICGRAY             (NUM_GLXCAPS + 3)  /* Used as
-                                                      mask bit
-                                                      for "any
-                                                      visual type 
-                                                      selected". */
-#define XGRAYSCALE              (NUM_GLXCAPS + 4)
-#define XSTATICCOLOR            (NUM_GLXCAPS + 5)
-#define XPSEUDOCOLOR            (NUM_GLXCAPS + 6)
-#define XTRUECOLOR              (NUM_GLXCAPS + 7)
-#define XDIRECTCOLOR            (NUM_GLXCAPS + 8)
-#define SLOW                    (NUM_GLXCAPS + 9)
-#define CONFORMANT              (NUM_GLXCAPS + 10)
-
-#define NUM_CAPS                (NUM_GLXCAPS + 11)
-
-/* Frame buffer capablities that don't have a corresponding
-   FrameBufferMode entry.  These get used as mask bits. */
-#define NUM                     (NUM_CAPS + 0)
-#define RGBA_MODE               (NUM_CAPS + 1)
-#define CI_MODE                 (NUM_CAPS + 2)
-#define LUMINANCE_MODE         (NUM_CAPS + 3)
-
-#define NONE                   0
-#define EQ                     1
-#define NEQ                    2
-#define LTE                    3
-#define GTE                    4
-#define GT                     5
-#define LT                     6
-#define MIN                    7
-
-typedef struct _Criterion {
-  int capability;
-  int comparison;
-  int value;
-} Criterion;
-
-typedef struct _FrameBufferMode {
-  XVisualInfo *vi;
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-
-  /* fbc is non-NULL when the XVisualInfo* is not OpenGL-capable
-     (ie, GLX_USE_GL is false), but the SGIX_fbconfig extension shows
-     the visual's fbconfig is OpenGL-capable.  The reason for this is typically
-     an RGBA luminance fbconfig such as 16-bit StaticGray that could
-     not be advertised as a GLX visual since StaticGray visuals are
-     required (by the GLX specification) to be color index.  The
-     SGIX_fbconfig allows StaticGray visuals to instead advertised as
-     fbconfigs that can provide RGBA luminance support. */
-
-  GLXFBConfigSGIX fbc;
-#endif
-  int valid;
-  int cap[NUM_CAPS];
-} FrameBufferMode;
-
-/* DisplayMode capability macros for game mode. */
-#define DM_WIDTH        0  /* "width" */
-#define DM_HEIGHT       1  /* "height" */
-#define DM_PIXEL_DEPTH  2  /* "bpp" (bits per pixel) */
-#define DM_HERTZ        3  /* "hertz" */
-#define DM_NUM          4  /* "num" */
-
-#define NUM_DM_CAPS     (DM_NUM+1)
-
-typedef struct _DisplayMode {
-#ifdef _WIN32
-  DEVMODE devmode;
-#else
-  /* XXX The X Window System does not have a standard
-     mechanism for display setting changes.  On SGI
-     systems, GLUT could use the XSGIvc (SGI X video
-     control extension).  Perhaps this can be done in
-     a future release of GLUT. */
-#endif
-  int valid;
-  int cap[NUM_DM_CAPS];
-} DisplayMode;
-
-#endif  /* BeOS */
-
-/* GLUT  function types */
-typedef void (*GLUTdisplayCB) (void);
-typedef void (*GLUTreshapeCB) (int, int);
-typedef void (*GLUTkeyboardCB) (unsigned char, int, int);
-typedef void (*GLUTmouseCB) (int, int, int, int);
-typedef void (*GLUTmotionCB) (int, int);
-typedef void (*GLUTpassiveCB) (int, int);
-typedef void (*GLUTentryCB) (int);
-typedef void (*GLUTvisibilityCB) (int);
-typedef void (*GLUTwindowStatusCB) (int);
-typedef void (*GLUTidleCB) (void);
-typedef void (*GLUTtimerCB) (int);
-typedef void (*GLUTmenuStateCB) (int);  /* DEPRICATED. */
-typedef void (*GLUTmenuStatusCB) (int, int, int);
-typedef void (*GLUTselectCB) (int);
-typedef void (*GLUTspecialCB) (int, int, int);
-typedef void (*GLUTspaceMotionCB) (int, int, int);
-typedef void (*GLUTspaceRotateCB) (int, int, int);
-typedef void (*GLUTspaceButtonCB) (int, int);
-typedef void (*GLUTdialsCB) (int, int);
-typedef void (*GLUTbuttonBoxCB) (int, int);
-typedef void (*GLUTtabletMotionCB) (int, int);
-typedef void (*GLUTtabletButtonCB) (int, int, int, int);
-typedef void (*GLUTjoystickCB) (unsigned int buttonMask, int x, int y, int z);
-#ifdef SUPPORT_FORTRAN
-typedef void (*GLUTdisplayFCB) (void);
-typedef void (*GLUTreshapeFCB) (int *, int *);
-/* NOTE the pressed key is int, not unsigned char for Fortran! */
-typedef void (*GLUTkeyboardFCB) (int *, int *, int *);
-typedef void (*GLUTmouseFCB) (int *, int *, int *, int *);
-typedef void (*GLUTmotionFCB) (int *, int *);
-typedef void (*GLUTpassiveFCB) (int *, int *);
-typedef void (*GLUTentryFCB) (int *);
-typedef void (*GLUTvisibilityFCB) (int *);
-typedef void (*GLUTwindowStatusFCB) (int *);
-typedef void (*GLUTidleFCB) (void);
-typedef void (*GLUTtimerFCB) (int *);
-typedef void (*GLUTmenuStateFCB) (int *);  /* DEPRICATED. */
-typedef void (*GLUTmenuStatusFCB) (int *, int *, int *);
-typedef void (*GLUTselectFCB) (int *);
-typedef void (*GLUTspecialFCB) (int *, int *, int *);
-typedef void (*GLUTspaceMotionFCB) (int *, int *, int *);
-typedef void (*GLUTspaceRotateFCB) (int *, int *, int *);
-typedef void (*GLUTspaceButtonFCB) (int *, int *);
-typedef void (*GLUTdialsFCB) (int *, int *);
-typedef void (*GLUTbuttonBoxFCB) (int *, int *);
-typedef void (*GLUTtabletMotionFCB) (int *, int *);
-typedef void (*GLUTtabletButtonFCB) (int *, int *, int *, int *);
-typedef void (*GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z);
-#endif
-
-#ifndef __BEOS__
-
-typedef struct _GLUTcolorcell GLUTcolorcell;
-struct _GLUTcolorcell {
-  /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */
-  GLfloat component[3];
-};
-
-typedef struct _GLUTcolormap GLUTcolormap;
-struct _GLUTcolormap {
-  Visual *visual;       /* visual of the colormap */
-  Colormap cmap;        /* X colormap ID */
-  int refcnt;           /* number of windows using colormap */
-  int size;             /* number of cells in colormap */
-  int transparent;      /* transparent pixel, or -1 if opaque */
-  GLUTcolorcell *cells; /* array of cells */
-  GLUTcolormap *next;   /* next colormap in list */
-};
-
-typedef struct _GLUTwindow GLUTwindow;
-typedef struct _GLUToverlay GLUToverlay;
-struct _GLUTwindow {
-  int num;              /* Small integer window id (0-based). */
-
-  /* Window system related state. */
-#if defined(_WIN32)
-  int pf;               /* Pixel format. */
-  HDC hdc;              /* Window's Win32 device context. */
-#endif
-  Window win;           /* X window for GLUT window */
-  GLXContext ctx;       /* OpenGL context GLUT glut window */
-  XVisualInfo *vis;     /* visual for window */
-  Bool visAlloced;      /* if vis needs deallocate on destroy */
-  Colormap cmap;        /* RGB colormap for window; None if CI */
-  GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
-  GLUToverlay *overlay; /* overlay; NULL if no overlay */
-#if defined(_WIN32)
-  HDC renderDc;         /* Win32's device context for rendering. */
-#endif
-  Window renderWin;     /* X window for rendering (might be
-                           overlay) */
-  GLXContext renderCtx; /* OpenGL context for rendering (might
-                           be overlay) */
-  /* GLUT settable or visible window state. */
-  int width;            /* window width in pixels */
-  int height;           /* window height in pixels */
-  int cursor;           /* cursor name */
-  int visState;         /* visibility state (-1 is unknown) */
-  int shownState;       /* if window mapped */
-  int entryState;       /* entry state (-1 is unknown) */
-#define GLUT_MAX_MENUS              3
-
-  int menu[GLUT_MAX_MENUS];  /* attatched menu nums */
-  /* Window relationship state. */
-  GLUTwindow *parent;   /* parent window */
-  GLUTwindow *children; /* list of children */
-  GLUTwindow *siblings; /* list of siblings */
-  /* Misc. non-API visible (hidden) state. */
-  Bool treatAsSingle;   /* treat this window as single-buffered
-                           (it might be "fake" though) */
-  Bool forceReshape;    /* force reshape before display */
-#if !defined(_WIN32)
-  Bool isDirect;        /* if direct context (X11 only) */
-#endif
-  Bool usedSwapBuffers; /* if swap buffers used last display */
-  long eventMask;       /* mask of X events selected for */
-  int buttonUses;       /* number of button uses, ref cnt */
-  int tabletPos[2];     /* tablet position (-1 is invalid) */
-  /* Work list related state. */
-  unsigned int workMask;  /* mask of window work to be done */
-  GLUTwindow *prevWorkWin;  /* link list of windows to work on */
-  Bool desiredMapState; /* how to mapped window if on map work
-                           list */
-  Bool ignoreKeyRepeat;  /* if window ignores autorepeat */
-  int desiredConfMask;  /* mask of desired window configuration
-                         */
-  int desiredX;         /* desired X location */
-  int desiredY;         /* desired Y location */
-  int desiredWidth;     /* desired window width */
-  int desiredHeight;    /* desired window height */
-  int desiredStack;     /* desired window stack */
-  /* Per-window callbacks. */
-  GLUTdisplayCB display;  /* redraw */
-  GLUTreshapeCB reshape;  /* resize (width,height) */
-  GLUTmouseCB mouse;    /* mouse (button,state,x,y) */
-  GLUTmotionCB motion;  /* motion (x,y) */
-  GLUTpassiveCB passive;  /* passive motion (x,y) */
-  GLUTentryCB entry;    /* window entry/exit (state) */
-  GLUTkeyboardCB keyboard;  /* keyboard (ASCII,x,y) */
-  GLUTkeyboardCB keyboardUp;  /* keyboard up (ASCII,x,y) */
-  GLUTwindowStatusCB windowStatus;  /* window status */
-  GLUTvisibilityCB visibility;  /* visibility */
-  GLUTspecialCB special;  /* special key */
-  GLUTspecialCB specialUp;  /* special up key */
-  GLUTbuttonBoxCB buttonBox;  /* button box */
-  GLUTdialsCB dials;    /* dials */
-  GLUTspaceMotionCB spaceMotion;  /* Spaceball motion */
-  GLUTspaceRotateCB spaceRotate;  /* Spaceball rotate */
-  GLUTspaceButtonCB spaceButton;  /* Spaceball button */
-  GLUTtabletMotionCB tabletMotion;  /* tablet motion */
-  GLUTtabletButtonCB tabletButton;  /* tablet button */
-#ifdef _WIN32
-  GLUTjoystickCB joystick;  /* joystick */
-  int joyPollInterval; /* joystick polling interval */
-#endif
-#ifdef SUPPORT_FORTRAN
-  /* Special Fortran display  unneeded since no
-     parameters! */
-  GLUTreshapeFCB freshape;  /* Fortran reshape  */
-  GLUTmouseFCB fmouse;  /* Fortran mouse  */
-  GLUTmotionFCB fmotion;  /* Fortran motion  */
-  GLUTpassiveFCB fpassive;  /* Fortran passive  */
-  GLUTentryFCB fentry;  /* Fortran entry  */
-  GLUTkeyboardFCB fkeyboard;  /* Fortran keyboard  */
-  GLUTkeyboardFCB fkeyboardUp;  /* Fortran keyboard up */
-  GLUTwindowStatusFCB fwindowStatus;  /* Fortran visibility
-                                          */
-  GLUTvisibilityFCB fvisibility;  /* Fortran visibility
-                                      */
-  GLUTspecialFCB fspecial;  /* special key */
-  GLUTspecialFCB fspecialUp;  /* special key up */
-  GLUTbuttonBoxFCB fbuttonBox;  /* button box */
-  GLUTdialsFCB fdials;  /* dials */
-  GLUTspaceMotionFCB fspaceMotion;  /* Spaceball motion
-                                        */
-  GLUTspaceRotateFCB fspaceRotate;  /* Spaceball rotate
-                                        */
-  GLUTspaceButtonFCB fspaceButton;  /* Spaceball button
-                                        */
-  GLUTtabletMotionFCB ftabletMotion;  /* tablet motion
-                                       */
-  GLUTtabletButtonFCB ftabletButton;  /* tablet button
-                                       */
-#ifdef _WIN32
-  GLUTjoystickFCB fjoystick;  /* joystick */
-#endif
-#endif
-};
-
-struct _GLUToverlay {
-#if defined(_WIN32)
-  int pf;
-  HDC hdc;
-#endif
-  Window win;
-  GLXContext ctx;
-  XVisualInfo *vis;     /* visual for window */
-  Bool visAlloced;      /* if vis needs deallocate on destroy */
-  Colormap cmap;        /* RGB colormap for window; None if CI */
-  GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
-  int shownState;       /* if overlay window mapped */
-  Bool treatAsSingle;   /* treat as single-buffered */
-#if !defined(_WIN32)
-  Bool isDirect;        /* if direct context */
-#endif
-  int transparentPixel; /* transparent pixel value */
-  GLUTdisplayCB display;  /* redraw  */
-  /* Special Fortran display  unneeded since no
-     parameters! */
-};
-
-typedef struct _GLUTstale GLUTstale;
-struct _GLUTstale {
-  GLUTwindow *window;
-  Window win;
-  GLUTstale *next;
-};
-
-extern GLUTstale *__glutStaleWindowList;
-
-#define GLUT_OVERLAY_EVENT_FILTER_MASK \
-  (ExposureMask | \
-  StructureNotifyMask | \
-  EnterWindowMask | \
-  LeaveWindowMask)
-#define GLUT_DONT_PROPAGATE_FILTER_MASK \
-  (ButtonReleaseMask | \
-  ButtonPressMask | \
-  KeyPressMask | \
-  KeyReleaseMask | \
-  PointerMotionMask | \
-  Button1MotionMask | \
-  Button2MotionMask | \
-  Button3MotionMask)
-#define GLUT_HACK_STOP_PROPAGATE_MASK \
-  (KeyPressMask | \
-  KeyReleaseMask)
-
-typedef struct _GLUTmenu GLUTmenu;
-typedef struct _GLUTmenuItem GLUTmenuItem;
-struct _GLUTmenu {
-  int id;               /* small integer menu id (0-based) */
-  Window win;           /* X window for the menu */
-  GLUTselectCB select;  /*  function of menu */
-  GLUTmenuItem *list;   /* list of menu entries */
-  int num;              /* number of entries */
-#if !defined(_WIN32)
-  Bool managed;         /* are the InputOnly windows size
-                           validated? */
-  Bool searched;       /* help detect menu loops */
-  int pixheight;        /* height of menu in pixels */
-  int pixwidth;         /* width of menu in pixels */
-#endif
-  int submenus;         /* number of submenu entries */
-  GLUTmenuItem *highlighted;  /* pointer to highlighted menu
-                                 entry, NULL not highlighted */
-  GLUTmenu *cascade;    /* currently cascading this menu  */
-  GLUTmenuItem *anchor; /* currently anchored to this entry */
-  int x;                /* current x origin relative to the
-                           root window */
-  int y;                /* current y origin relative to the
-                           root window */
-#ifdef SUPPORT_FORTRAN
-  GLUTselectFCB fselect;  /*  function of menu */
-#endif
-};
-
-struct _GLUTmenuItem {
-  Window win;           /* InputOnly X window for entry */
-  GLUTmenu *menu;       /* menu entry belongs to */
-  Bool isTrigger;       /* is a submenu trigger? */
-  int value;            /* value to return for selecting this
-                           entry; doubles as submenu id
-                           (0-base) if submenu trigger */
-#if defined(_WIN32)
-  UINT unique;          /* unique menu item id (Win32 only) */
-#endif
-  char *label;          /* __glutStrdup'ed label string */
-  int len;              /* length of label string */
-  int pixwidth;         /* width of X window in pixels */
-  GLUTmenuItem *next;   /* next menu entry on list for menu */
-};
-
-typedef struct _GLUTtimer GLUTtimer;
-struct _GLUTtimer {
-  GLUTtimer *next;      /* list of timers */
-  struct timeval timeout;  /* time to be called */
-  GLUTtimerCB func;     /* timer  (value) */
-  int value;            /*  return value */
-#ifdef SUPPORT_FORTRAN
-  GLUTtimerFCB ffunc;   /* Fortran timer  */
-#endif
-};
-
-typedef struct _GLUTeventParser GLUTeventParser;
-struct _GLUTeventParser {
-  int (*func) (XEvent *);
-  GLUTeventParser *next;
-};
-
-/* Declarations to implement glutFullScreen support with
-   mwm/4Dwm. */
-
-/* The following X property format is defined in Motif 1.1's
-   Xm/MwmUtils.h, but GLUT should not depend on that header
-   file. Note: Motif 1.2 expanded this structure with
-   uninteresting fields (to GLUT) so just stick with the
-   smaller Motif 1.1 structure. */
-typedef struct {
-#define MWM_HINTS_DECORATIONS   2
-  long flags;
-  long functions;
-  long decorations;
-  long input_mode;
-} MotifWmHints;
-
-/* Make current and buffer swap macros. */
-#ifdef _WIN32
-#define MAKE_CURRENT_LAYER(window)                                    \
-  {                                                                   \
-    HGLRC currentContext = wglGetCurrentContext();                    \
-    HDC currentDc = wglGetCurrentDC();                                \
-                                                                      \
-    if (currentContext != window->renderCtx                           \
-      || currentDc != window->renderDc) {                             \
-      wglMakeCurrent(window->renderDc, window->renderCtx);            \
-    }                                                                 \
-  }
-#define MAKE_CURRENT_WINDOW(window)                                   \
-  {                                                                   \
-    HGLRC currentContext = wglGetCurrentContext();                    \
-    HDC currentDc = wglGetCurrentDC();                                \
-                                                                      \
-    if (currentContext != window->ctx || currentDc != window->hdc) {  \
-      wglMakeCurrent(window->hdc, window->ctx);                       \
-    }                                                                 \
-  }
-#define MAKE_CURRENT_OVERLAY(overlay) \
-  wglMakeCurrent(overlay->hdc, overlay->ctx)
-#define UNMAKE_CURRENT() \
-  wglMakeCurrent(NULL, NULL)
-#define SWAP_BUFFERS_WINDOW(window) \
-  SwapBuffers(window->hdc)
-#define SWAP_BUFFERS_LAYER(window) \
-  SwapBuffers(window->renderDc)
-#else
-#define MAKE_CURRENT_LAYER(window) \
-  glXMakeCurrent(__glutDisplay, window->renderWin, window->renderCtx)
-#define MAKE_CURRENT_WINDOW(window) \
-  glXMakeCurrent(__glutDisplay, window->win, window->ctx)
-#define MAKE_CURRENT_OVERLAY(overlay) \
-  glXMakeCurrent(__glutDisplay, overlay->win, overlay->ctx)
-#define UNMAKE_CURRENT() \
-  glXMakeCurrent(__glutDisplay, None, NULL)
-#define SWAP_BUFFERS_WINDOW(window) \
-  glXSwapBuffers(__glutDisplay, window->win)
-#define SWAP_BUFFERS_LAYER(window) \
-  glXSwapBuffers(__glutDisplay, window->renderWin)
-#endif
-
-/* private variables from glut_event.c */
-extern GLUTwindow *__glutWindowWorkList;
-extern int __glutWindowDamaged;
-#ifdef SUPPORT_FORTRAN
-extern GLUTtimer *__glutTimerList;
-extern GLUTtimer *__glutNewTimer;
-#endif
-extern GLUTmenu *__glutMappedMenu;
-
-extern void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *);
-#if !defined(_WIN32)
-extern void (*__glutMenuItemEnterOrLeave)(GLUTmenuItem * item,
-  int num, int type);
-extern void (*__glutFinishMenu)(Window win, int x, int y);
-extern void (*__glutPaintMenu)(GLUTmenu * menu);
-extern void (*__glutStartMenu)(GLUTmenu * menu,
-  GLUTwindow * window, int x, int y, int x_win, int y_win);
-extern GLUTmenu * (*__glutGetMenuByNum)(int menunum);
-extern GLUTmenuItem * (*__glutGetMenuItem)(GLUTmenu * menu,
-  Window win, int *which);
-extern GLUTmenu * (*__glutGetMenu)(Window win);
-#endif
-
-/* private variables from glut_init.c */
-extern Atom __glutWMDeleteWindow;
-extern Display *__glutDisplay;
-extern unsigned int __glutDisplayMode;
-extern char *__glutDisplayString;
-extern XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle,
-  Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc);
-extern GLboolean __glutDebug;
-extern GLboolean __glutForceDirect;
-extern GLboolean __glutIconic;
-extern GLboolean __glutTryDirect;
-extern Window __glutRoot;
-extern XSizeHints __glutSizeHints;
-extern char **__glutArgv;
-#endif  /* BeOS */
-extern char *__glutProgramName;
-#ifndef __BEOS__
-extern int __glutArgc;
-extern int __glutConnectionFD;
-extern int __glutInitHeight;
-extern int __glutInitWidth;
-extern int __glutInitX;
-extern int __glutInitY;
-extern int __glutScreen;
-extern int __glutScreenHeight;
-extern int __glutScreenWidth;
-extern Atom __glutMotifHints;
-extern unsigned int __glutModifierMask;
-
-/* private variables from glut_menu.c */
-extern GLUTmenuItem *__glutItemSelected;
-extern GLUTmenu **__glutMenuList;
-extern void (*__glutMenuStatusFunc) (int, int, int);
-extern void __glutMenuModificationError(void);
-extern void __glutSetMenuItem(GLUTmenuItem * item,
-  const char *label, int value, Bool isTrigger);
-
-/* private variables from glut_win.c */
-extern GLUTwindow **__glutWindowList;
-extern GLUTwindow *__glutCurrentWindow;
-extern GLUTwindow *__glutMenuWindow;
-extern GLUTmenu *__glutCurrentMenu;
-extern int __glutWindowListSize;
-extern void (*__glutFreeOverlayFunc) (GLUToverlay *);
-extern XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle,
-  Bool * visAlloced, void **fbc);
-
-/* private variables from glut_mesa.c */
-extern int __glutMesaSwapHackSupport;
-
-/* private variables from glut_gamemode.c */
-extern GLUTwindow *__glutGameModeWindow;
-
-/* private routines from glut_cindex.c */
-extern GLUTcolormap * __glutAssociateNewColormap(XVisualInfo * vis);
-extern void __glutFreeColormap(GLUTcolormap *);
-
-/* private routines from glut_cmap.c */
-extern void __glutSetupColormap(
-  XVisualInfo * vi,
-  GLUTcolormap ** colormap,
-  Colormap * cmap);
-#if !defined(_WIN32)
-extern void __glutEstablishColormapsProperty(
-  GLUTwindow * window);
-extern GLUTwindow *__glutToplevelOf(GLUTwindow * window);
-#endif
-
-/* private routines from glut_cursor.c */
-extern void __glutSetCursor(GLUTwindow *window);
-
-/* private routines from glut_event.c */
-extern void __glutPutOnWorkList(GLUTwindow * window,
-  int work_mask);
-extern void __glutRegisterEventParser(GLUTeventParser * parser);
-extern void __glutPostRedisplay(GLUTwindow * window, int layerMask);
-
-/* private routines from glut_init.c */
-#if !defined(_WIN32)
-extern void __glutOpenXConnection(char *display);
-#else
-extern void __glutOpenWin32Connection(char *display);
-#endif
-extern void __glutInitTime(struct timeval *beginning);
-
-/* private routines for glut_menu.c (or win32_menu.c) */
-#if defined(_WIN32)
-extern GLUTmenu *__glutGetMenu(Window win);
-extern GLUTmenu *__glutGetMenuByNum(int menunum);
-extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu,
-  Window win, int *which);
-extern void __glutStartMenu(GLUTmenu * menu,
-  GLUTwindow * window, int x, int y, int x_win, int y_win);
-extern void __glutFinishMenu(Window win, int x, int y);
-#endif
-extern void __glutSetMenu(GLUTmenu * menu);
-
-#endif  /* BeOS */
-#ifdef __cplusplus
-extern "C" {
-#endif
-/* private routines from glut_util.c */
-extern char * __glutStrdup(const char *string);
-extern void __glutWarning(char *format,...);
-extern void __glutFatalError(char *format,...);
-extern void __glutFatalUsage(char *format,...);
-#ifdef __cplusplus
-}
-#endif
-#ifndef __BEOS__
-
-/* private routines from glut_win.c */
-extern GLUTwindow *__glutGetWindow(Window win);
-extern void __glutChangeWindowEventMask(long mask, Bool add);
-extern XVisualInfo *__glutDetermineVisual(
-  unsigned int mode,
-  Bool * fakeSingle,
-  XVisualInfo * (getVisualInfo) (unsigned int));
-extern XVisualInfo *__glutGetVisualInfo(unsigned int mode);
-extern void __glutSetWindow(GLUTwindow * window);
-extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc,
-  int callingConvention);
-extern void  __glutDefaultReshape(int, int);
-extern GLUTwindow *__glutCreateWindow(
-  GLUTwindow * parent,
-  int x, int y, int width, int height, int gamemode);
-extern void __glutDestroyWindow(
-  GLUTwindow * window,
-  GLUTwindow * initialWindow);
-
-#if !defined(_WIN32)
-/* private routines from glut_glxext.c */
-extern int __glutIsSupportedByGLX(char *);
-#endif
-
-/* private routines from glut_input.c */
-extern void  __glutUpdateInputDeviceMask(GLUTwindow * window);
-
-/* private routines from glut_mesa.c */
-extern void __glutDetermineMesaSwapHackSupport(void);
-
-/* private routines from glut_gameglut.c */
-extern void __glutCloseDownGameMode(void);
-
-#if defined(_WIN32)
-/* private routines from win32_*.c */
-extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l);
-extern HDC XHDC;
-#endif
-
-#else  /* BeOS */
-/* BeOS specific C++ function prototypes */
-#ifdef __cplusplus
-
-#include <SupportDefs.h>
-
-/* private routines from glutInit.cpp */
-void __glutInitTime(bigtime_t *beginning);
-void __glutInit();
-
-/* private routines from glutMenu.cpp */
-class GlutMenu;         // avoid including glutMenu.h
-GlutMenu *__glutGetMenuByNum(int menunum);
-
-/* private routines from glutWindow.cpp */
-int __glutConvertDisplayMode(unsigned long *options);
-void __glutDefaultReshape(int width, int height);
-class GlutWindow;       // avoid including glutWindow.h in every source file
-void __glutSetWindow(GlutWindow * window);
-void __glutDestroyAllWindows();
-
-/* private routines from glutDstr.cpp */
-int __glutConvertDisplayModeFromString(unsigned long *options);
-
-/* private routines from glutCursor.cpp */
-void __glutSetCursor(int cursor);
-
-#endif /* __cplusplus */
-#endif  /* BeOS */
-
-#endif /* __glutint_h__ */
diff --git a/src/glut/beos/glutstroke.h b/src/glut/beos/glutstroke.h
deleted file mode 100644 (file)
index cbc9e15..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __glutstroke_h__
-#define __glutstroke_h__
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#if defined(_WIN32)
-#pragma warning (disable:4244)  /* disable bogus conversion warnings */
-#pragma warning (disable:4305)  /* VC++ 5.0 version of above warning. */
-#endif
-
-typedef struct {
-  float x;
-  float y;
-} CoordRec, *CoordPtr;
-
-typedef struct {
-  int num_coords;
-  const CoordRec *coord;
-} StrokeRec, *StrokePtr;
-
-typedef struct {
-  int num_strokes;
-  const StrokeRec *stroke;
-  float center;
-  float right;
-} StrokeCharRec, *StrokeCharPtr;
-
-typedef struct {
-  const char *name;
-  int num_chars;
-  const StrokeCharRec *ch;
-  float top;
-  float bottom;
-} StrokeFontRec, *StrokeFontPtr;
-
-typedef void *GLUTstrokeFont;
-
-#endif /* __glutstroke_h__ */
diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile
deleted file mode 100644 (file)
index 69f8052..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-# Makefile for GLUT
-#
-# NOTICE:  The OpenGL Utility Toolkit (GLUT) distribution contains source
-# code published in a book titled "Programming OpenGL for the X Window
-# System" (ISBN: 0-201-48359-9) published by Addison-Wesley.  The
-# programs and associated files contained in the distribution were
-# developed by Mark J. Kilgard and are Copyright 1994, 1995, 1996 by Mark
-# J. Kilgard (unless otherwise noted).  The programs are not in the
-# public domain, but they are freely distributable without licensing
-# fees.  These programs are provided without guarantee or warrantee
-# expressed or implied.
-#
-# GLUT source included with Mesa with permission from Mark Kilgard.
-
-
-TOP = ../../..
-
-include $(TOP)/configs/current
-
-
-##### MACROS #####
-
-GLUT_MAJOR = 3
-GLUT_MINOR = 7
-GLUT_TINY = 1
-
-SOURCES = \
-       glut_8x13.c \
-       glut_9x15.c \
-       glut_bitmap.c \
-       glut_bwidth.c \
-       glut_cindex.c \
-       glut_cmap.c \
-       glut_cursor.c \
-       glut_dials.c \
-       glut_dstr.c \
-       glut_event.c \
-       glut_ext.c \
-       glut_fcb.c \
-       glut_fullscrn.c \
-       glut_gamemode.c \
-       glut_get.c \
-       glut_glxext.c \
-       glut_hel10.c \
-       glut_hel12.c \
-       glut_hel18.c \
-       glut_init.c \
-       glut_input.c \
-       glut_joy.c \
-       glut_key.c \
-       glut_keyctrl.c \
-       glut_keyup.c \
-       glut_menu.c \
-       glut_menu2.c \
-       glut_mesa.c \
-       glut_modifier.c \
-       glut_mroman.c \
-       glut_overlay.c \
-       glut_ppm.c \
-       glut_roman.c \
-       glut_shapes.c \
-       glut_space.c \
-       glut_stroke.c \
-       glut_swap.c \
-       glut_swidth.c \
-       glut_tablet.c \
-       glut_teapot.c \
-       glut_tr10.c \
-       glut_tr24.c \
-       glut_util.c \
-       glut_vidresize.c \
-       glut_warp.c \
-       glut_win.c \
-       glut_winmisc.c \
-       layerutil.c
-
-
-OBJECTS = $(SOURCES:.c=.o)
-
-
-##### RULES #####
-
-.c.o:
-       $(CC) -c -I$(TOP)/include $(X11_INCLUDES) $(CFLAGS) $(GLUT_CFLAGS) $<
-
-
-
-##### TARGETS #####
-
-default: $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
-
-
-# Make the library
-$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-               -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
-               $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
-               -id $(INSTALL_LIB_DIR)/lib$(GLUT_LIB).$(GLUT_MAJOR).dylib \
-               $(GLUT_LIB_DEPS) $(OBJECTS)
-
-
-# glut pkgconfig file
-pcedit = sed \
-       -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
-       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
-       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
-       -e 's,@VERSION@,$(GLUT_MAJOR).$(GLUT_MINOR).$(GLUT_TINY),' \
-       -e 's,@GLUT_PC_REQ_PRIV@,$(GLUT_PC_REQ_PRIV),' \
-       -e 's,@GLUT_PC_LIB_PRIV@,$(GLUT_PC_LIB_PRIV),' \
-       -e 's,@GLUT_PC_CFLAGS@,$(GLUT_PC_CFLAGS),' \
-       -e 's,@GLUT_LIB@,$(GLUT_LIB),'
-glut.pc: glut.pc.in
-       $(pcedit) $< > $@
-
-install: glut.pc
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
-       $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL
-       $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
-       $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
-
-
-clean:
-       -rm -f *.o *~
-       -rm -f *.lo
-       -rm -f *.la
-       -rm -f *.pc
-       -rm -rf .libs
-       -rm -f depend depend.bak
-
-
-depend: $(SOURCES)
-       @ echo "running $(MKDEP)"
-       @ rm -f depend
-       @ touch depend
-       @ $(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(SOURCES) \
-               $(X11_INCLUDES) > /dev/null 
-
--include depend
diff --git a/src/glut/glx/Makefile.cygnus b/src/glut/glx/Makefile.cygnus
deleted file mode 100644 (file)
index 5d5fa69..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-# Makefile.cygnus for Cygnus-Win32 target
-# /Stephane Rehel, November 16 1997
-
-# Makefile for GLUT 3.7
-#
-# NOTICE:  The OpenGL Utility Toolkit (GLUT) distribution contains source
-# code published in a book titled "Programming OpenGL for the X Window
-# System" (ISBN: 0-201-48359-9) published by Addison-Wesley.  The
-# programs and associated files contained in the distribution were
-# developed by Mark J. Kilgard and are Copyright 1994, 1995, 1996 by Mark
-# J. Kilgard (unless otherwise noted).  The programs are not in the
-# public domain, but they are freely distributable without licensing
-# fees.  These programs are provided without guarantee or warrantee
-# expressed or implied.
-#
-# GLUT source included with Mesa with permission from Mark Kilgard.
-
-
-##### MACROS #####
-
-GLUT_MAJOR = 3
-GLUT_MINOR = 7
-GLUT_TINY = 0
-
-VPATH = RCS
-
-INCDIR = ../include
-LIBDIR = ../lib
-
-SOURCES = \
-       glut_8x13.c \
-       glut_9x15.c \
-       glut_bitmap.c \
-       glut_bwidth.c \
-       glut_cindex.c \
-       glut_cmap.c \
-       glut_cursor.c \
-       glut_dials.c \
-       glut_dstr.c \
-       glut_event.c \
-       glut_ext.c \
-       glut_fullscrn.c \
-       glut_get.c \
-       glut_hel10.c \
-       glut_hel12.c \
-       glut_hel18.c \
-       glut_init.c \
-       glut_input.c \
-       glut_mesa.c \
-       glut_modifier.c \
-       glut_mroman.c \
-       glut_overlay.c \
-       glut_roman.c \
-       glut_shapes.c \
-       glut_space.c \
-       glut_stroke.c \
-       glut_swap.c \
-       glut_swidth.c \
-       glut_tablet.c \
-       glut_teapot.c \
-       glut_tr10.c \
-       glut_tr24.c \
-       glut_util.c \
-       glut_vidresize.c \
-       glut_warp.c \
-       glut_win.c \
-       glut_winmisc.c \
-       win32_x11.c \
-       win32_glx.c \
-       win32_menu.c \
-       win32_util.c 
-
-OBJECTS = $(SOURCES:.c=.o)
-
-
-
-##### RULES #####
-
-.c.o:
-       $(CC) -c -I$(INCDIR) $(CFLAGS) $<
-
-
-
-##### TARGETS #####
-
-default:
-       @echo "Specify a target configuration"
-
-clean:
-       -rm *.o *~
-
-targets: $(LIBDIR)/$(GLUT_LIB)
-
-# Make the library
-$(LIBDIR)/$(GLUT_LIB): $(OBJECTS)
-       $(MAKELIB) $(GLUT_LIB) $(GLUT_MAJOR) $(GLUT_MINOR) $(GLUT_TINY) $(OBJECTS)
-       mv $(GLUT_LIB)* $(LIBDIR)
-
-include ../Make-config
-
-include depend
-
-
-
-#
-# Run 'make dep' to update the dependencies if you change what's included
-# by any source file.
-# 
-dep: $(SOURCES)
-       makedepend -fdepend -Y -I../include $(SOURCES)
diff --git a/src/glut/glx/Makefile.mgw b/src/glut/glx/Makefile.mgw
deleted file mode 100644 (file)
index 5e1fde0..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-# Mesa 3-D graphics library
-# Version:  5.1
-# 
-# Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
-# 
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-# 
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-# 
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-# MinGW core makefile v1.4 for Mesa
-#
-#  Copyright (C) 2002 - Daniel Borca
-#  Email : dborca@users.sourceforge.net
-#  Web   : http://www.geocities.com/dborca
-
-# MinGW core-glut makefile updated for Mesa 7.0
-#
-#  Updated : by Heromyth, on 2007-7-21
-#  Email   : zxpmyth@yahoo.com.cn
-#  Bugs    : 1) All the default settings work fine. But the setting X86=1 can't work. 
-#            The others havn't been tested yet.
-#            2) The generated DLLs are *not* compatible with the ones built
-#            with the other compilers like VC8, especially for GLUT. 
-#            3) Although more tests are needed, it can be used individually!
-
-
-#
-#  Available options:
-#
-#    Environment variables:
-#      CFLAGS
-#
-#      GLIDE           path to Glide3 SDK; used with FX.
-#                      default = $(TOP)/glide3
-#      FX=1            build for 3dfx Glide3. Note that this disables
-#                      compilation of most WMesa code and requires fxMesa.
-#                      As a consequence, you'll need the Win32 Glide3
-#                      library to build any application.
-#                      default = no
-#      ICD=1           build the installable client driver interface
-#                      (windows opengl driver interface)
-#                      default = no
-#      X86=1           optimize for x86 (if possible, use MMX, SSE, 3DNow).
-#                      default = no
-#
-#    Targets:
-#      all:            build GL
-#      clean:          remove object files
-#
-
-
-
-.PHONY: all clean
-.INTERMEDIATE: x86/gen_matypes.exe
-.SUFFIXES: .rc .res
-
-# Set this to the prefix of your build tools, i.e. mingw32-
-TOOLS_PREFIX = mingw32-
-
-TOP = ../../..
-
-LIBDIR = $(TOP)/lib
-
-LIB_NAME = glut32
-
-DLL_EXT = .dll
-IMP_EXT = .a
-LIB_PRE = lib
-STRIP = -s
-
-AR = ar
-ARFLAGS = crus
-DLLTOOL = dlltool
-
-GLUT_DLL = $(LIB_NAME)$(DLL_EXT)
-GLUT_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT)
-GLUT_DEF = $(LIB_NAME).def
-
-LDLIBS = -L$(LIBDIR) -lwinmm -lgdi32 -luser32 -lopengl32 -lglu32 
-LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at
-
-CFLAGS += -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DMESA -D_DLL
-CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include 
-
-CC = $(TOOLS_PREFIX)gcc
-CXX = $(TOOLS_PREFIX)g++
-CXXFLAGS = $(CFLAGS)
-
-AR = ar
-ARFLAGS = crus
-
-UNLINK = del $(subst /,\,$(1))
-ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
-UNLINK = $(RM) $(1)
-endif
-ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),)
-UNLINK = $(RM) $(1)
-endif
-
-HDRS = glutint.h glutstroke.h glutbitmap.h glutwin32.h stroke.h win32_glx.h win32_x11.h
-
-SRCS = \
-       glut_bitmap.c \
-       glut_bwidth.c \
-       glut_cindex.c \
-       glut_cmap.c \
-       glut_cursor.c \
-       glut_dials.c \
-       glut_dstr.c \
-       glut_event.c \
-       glut_ext.c \
-       glut_fcb.c \
-       glut_fullscrn.c \
-       glut_gamemode.c \
-       glut_get.c \
-       glut_init.c \
-       glut_input.c \
-       glut_joy.c \
-       glut_key.c \
-       glut_keyctrl.c \
-       glut_keyup.c \
-       glut_mesa.c \
-       glut_modifier.c \
-       glut_overlay.c \
-       glut_shapes.c \
-       glut_space.c \
-       glut_stroke.c \
-       glut_swap.c \
-       glut_swidth.c \
-       glut_tablet.c \
-       glut_teapot.c \
-       glut_util.c \
-       glut_vidresize.c \
-       glut_warp.c \
-       glut_win.c \
-       glut_winmisc.c \
-       win32_glx.c \
-       win32_menu.c \
-       win32_util.c \
-       win32_winproc.c \
-       win32_x11.c
-       
-
-SRCSSEMIGENS = \
-       glut_8x13.c \
-       glut_9x15.c \
-       glut_hel10.c \
-       glut_hel12.c \
-       glut_hel18.c \
-       glut_mroman.c \
-       glut_roman.c \
-       glut_tr10.c \
-       glut_tr24.c
-
-
-
-SOURCES = $(SRCS) $(SRCSSEMIGENS)
-
-OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
-
-.c.o:
-       $(CC) -o $@ $(CFLAGS) -c $<
-.cc.o:
-       $(CXX) -o $@ $(CXXFLAGS) -c $<
-
-
-all: $(LIBDIR) $(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP)
-
-$(LIBDIR):
-       mkdir -p $(LIBDIR)
-
-$(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
-       $(CXX) $(LDFLAGS) -o $(LIBDIR)/$(GLUT_DLL) $^ $(LDLIBS)
-       $(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GLUT_DEF) $^
-       $(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GLUT_IMP) --def $(LIBDIR)/$(GLUT_DEF) 
-
-clean:
-       -$(call UNLINK,*.o)
\ No newline at end of file
diff --git a/src/glut/glx/Makefile.sgi b/src/glut/glx/Makefile.sgi
deleted file mode 100644 (file)
index 9514c32..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-#! smake
-#
-# Copyright (c) Mark J. Kilgard, 1995, 1998.
-#
-include $(ROOT)/usr/include/make/commondefs
-
-# NOTE:  In my GLUT development tree, many of the C source files for
-# GLUT are generated.  For this reason, "make full_clobber" will remove
-# these generated C files, while "make clobber" will not.
-
-TOP = ../..
-
-TARGETS = libglut.a
-
-LN = ln -s
-MV = mv
-RM = -rm -rf
-
-HDRS = glutint.h glutstroke.h layerutil.h glutbitmap.h
-
-SRCS = \
-       glut_bitmap.c \
-       glut_bwidth.c \
-       glut_cindex.c \
-       glut_cmap.c \
-       glut_cursor.c \
-       glut_dials.c \
-       glut_dstr.c \
-       glut_event.c \
-       glut_ext.c \
-       glut_fbc.c \
-       glut_fullscrn.c \
-       glut_gamemode.c \
-       glut_get.c \
-       glut_glxext.c \
-       glut_init.c \
-       glut_input.c \
-       glut_joy.c \
-       glut_key.c \
-       glut_keyctrl.c \
-       glut_keyup.c \
-       glut_menu.c \
-       glut_menu2.c \
-       glut_mesa.c \
-       glut_modifier.c \
-       glut_overlay.c \
-       glut_shapes.c \
-       glut_space.c \
-       glut_stroke.c \
-       glut_swap.c \
-       glut_swidth.c \
-       glut_tablet.c \
-       glut_teapot.c \
-       glut_util.c \
-       glut_vidresize.c \
-       glut_warp.c \
-       glut_win.c \
-       glut_winmisc.c \
-       layerutil.c
-
-SRCSSEMIGENS = \
-       glut_8x13.c \
-       glut_9x15.c \
-       glut_hel10.c \
-       glut_hel12.c \
-       glut_hel18.c \
-       glut_mroman.c \
-       glut_roman.c \
-       glut_tr10.c \
-       glut_tr24.c
-
-OBJS = $(SRCS:.c=.o) $(SRCSSEMIGENS:.c=.o)
-OTHERGENS = y.tab.c y.tab.h strokegen.c strokegen.h strokelex.c
-OTHERSRCS = strokegen.y strokelex.l stroke.h
-FONTS = Roman.stroke MonoRoman.stroke
-
-# Uncomment the LCDEFS line below if you want to build a version of
-# libglut.a that avoids using the SGI "fast atoms" optimization
-# introduced in IRIX 6.3.  This optimization eliminates serveral X server
-# round-trips.  If you are building libglut.a on an IRIX 6.3 or later
-# machine and want a chance (no guarantees) that GLUT executables built
-# against your libglut.a will work on IRIX 6.2 machines, uncomment out
-# the LCDEFS line below.  Otherwise, you'll get a run-time message about
-# "attempted access to unresolvable symbol in XXX: _XSGIFastInternAtom"
-#LCDEFS = -DNO_FAST_ATOMS
-
-LCOPTS = -I$(TOP)/include -fullwarn 
-LWOFF = ,813,852,827,826
-LDIRT = *~ $(OTHERGENS) strokegen *.bak hardcopy glutsrc.ps capturexfont *.pure dstr dstr.c *.gen
-
-default: $(TARGETS)
-
-sinclude ObjectType.mk
-
-$(OBJS) : $(HDRS)
-
-libglut.a : $(OBJS)
-       $(RM) $@
-       $(AR) crl $@ $(OBJS)
-
-.ORDER : strokegen.h strokegen.c
-
-strokegen.h strokegen.c : strokegen.y
-       $(YACC) -d strokegen.y
-       $(MV) y.tab.c strokegen.c
-       $(MV) y.tab.h strokegen.h
-
-# avoid warnings when compiling lex generated code
-strokegen.o : strokegen.c
-       $(CC) $(CFLAGS) -woff 726,825,635,818,819,820,824,831,835,822,821,1167,1498,1116,1136,1174,1196,803 -c -MDupdate Makedepend strokegen.c
-
-strokelex.c : strokelex.l
-       $(LEX) strokelex.l
-       $(MV) lex.yy.c strokelex.c
-
-# avoid warnings when compiling lex generated code
-strokelex.o : strokelex.c
-       $(CC) $(CFLAGS) -woff 831,825,817,835,702,819,635,824,822,1167,1498,1110,1196,1174,803 -c -MDupdate Makedepend strokelex.c
-
-strokegen : strokegen.o strokelex.o
-       $(CC) -o $@ $(LDFLAGS) strokegen.o strokelex.o -ll
-
-capturexfont : capturexfont.o
-       $(CC) -o $@ $(LDFLAGS) capturexfont.o -lX11
-
-# glut_roman.c and glut_mroman.c are now checked in, but here are rules to generate them
-glut_roman.c.gen : Roman.stroke strokegen
-       ./strokegen -s glutStrokeRoman < Roman.stroke > $@
-glut_mroman.c.gen : MonoRoman.stroke strokegen
-       ./strokegen -s glutStrokeMonoRoman < MonoRoman.stroke > $@
-
-glutsrc.ps : $(SRCS)
-       $(RM) hardcopy
-       mkdir -p hardcopy
-       for i in $(SRCS) ;\
-       do \
-         grep -v CENTRY $$i | grep -v INDENT- > hardcopy/$$i; \
-       done
-       cd hardcopy ; enscript -p ../$@ -G -2r `echo $(SRCS) | fmt -1 | sort`
-       $(RM) hardcopy
-
-# The bitmap files can be generated using capturexfont, but because
-# they require a connection to an X server and potentially different
-# X servers have different fonts, these generated files are part
-# of the GLUT distribution.
-
-9_BY_15 = -misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1
-8_BY_13 = -misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1
-TR10 = -adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1
-TR24 = -adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1
-HEL10 = -adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1
-HEL12 = -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1
-HEL18 = -adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1
-
-semigens : capturexfont
-       ./capturexfont $(9_BY_15) glutBitmap9By15 > glut_9x15.c.gen
-       ./capturexfont $(8_BY_13) glutBitmap8By13 > glut_8x13.c.gen
-       ./capturexfont $(TR10) glutBitmapTimesRoman10 > glut_tr10.c.gen
-       ./capturexfont $(TR24) glutBitmapTimesRoman24 > glut_tr24.c.gen
-       ./capturexfont $(HEL10) glutBitmapHelvetica10 > glut_hel10.c.gen
-       ./capturexfont $(HEL12) glutBitmapHelvetica12 > glut_hel12.c.gen
-       ./capturexfont $(HEL18) glutBitmapHelvetica18 > glut_hel18.c.gen
-
-# unused test rule for test building 16-bit font
-JIS = -jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-0
-glut_jis.c : 
-       ./capturexfont $(JIS) glutBitmapJis > $@
-
-sources: $(SRCS)
-
-symcheck: libglut.a
-       -nm -Bo libglut.a | grep -v ' d ' | grep -v ' T glut' | grep -v ' D glut' | grep -v ' U ' | grep -v ' T __glut' | grep -v ' t ' | grep -v ' b ' | grep -v ' D __glut' | grep -v ' B __glut'
-
-dstr.c: glut_dstr.c
-       ln -s glut_dstr.c $@
-
-dstr: dstr.c glut_util.o glut_glxext.o
-       $(RM) $@
-       $(CC) -g -o $@ $(CFLAGS) -DTEST dstr.c glut_util.o glut_glxext.o -lGLU -lGL -lXext -lX11 -lm
-
-./glut.h : glut.h
-./glutint.h : glutint.h
-./glutstroke.h : glutstroke.h
-./strokegen.h : strokegen.h
-./stroke.h : stroke.h
-./layerutil.h : layerutil.h
-strokelex.o: strokelex.c strokegen.h
-
-include $(COMMONRULES)
diff --git a/src/glut/glx/Makefile.win b/src/glut/glx/Makefile.win
deleted file mode 100644 (file)
index 4ce7f6f..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-# Makefile for Win32
-
-!include <win32.mak>
-
-TOP = ..
-
-# NOTE: glut_menu.c and glut_glxext.c are NOT compiled into Win32 GLUT
-
-SRCS = glut_8x13.c glut_9x15.c glut_bitmap.c glut_bwidth.c glut_cindex.c glut_cmap.c glut_cursor.c glut_dials.c glut_dstr.c glut_event.c glut_ext.c glut_fbc.c glut_fullscrn.c glut_gamemode.c glut_get.c glut_hel10.c glut_hel12.c glut_hel18.c glut_init.c glut_input.c glut_joy.c glut_key.c glut_keyctrl.c glut_keyup.c glut_mesa.c glut_modifier.c glut_mroman.c glut_overlay.c glut_roman.c glut_shapes.c glut_space.c glut_stroke.c glut_swap.c glut_swidth.c glut_tablet.c glut_teapot.c glut_tr10.c glut_tr24.c glut_util.c glut_vidresize.c glut_warp.c glut_win.c glut_winmisc.c win32_glx.c win32_menu.c win32_util.c win32_winproc.c win32_x11.c
-
-all    : glutdll 
-
-!include "$(TOP)/mesawin32.mak"
-
-glutdll        : $(GLUTDLL)
-
-!IFDEF NODEBUG
-OPTIMIZE_CFLAGS = -DNDEBUG
-!ENDIF
-
-CFLAGS = $(cvarsdll) $(CFLAGS) $(OPTIMIZE_CFLAGS) -DMESA -DBUILD_GL32
-LFLAGS = $(dlllflags) $(lcommon) $(LFLAGS)
-
-OBJS   = $(SRCS:.c=.obj)
-MS_LIBS   = ../lib/$(MESALIB) ../lib/$(GLULIB) winmm.lib $(guilibsdll)
-SGI_LIBS   = $(SGI_OPENGL) $(SGI_GLU) winmm.lib $(guilibsdll)
-
-MesaGlut.dll : $(OBJS) glut.def
-       $(link) $(LFLAGS) -out:MesaGlut.dll -def:glut.def $(OBJS) $(MS_LIBS)
-       @echo "copying GLUT dynamic link library to lib directory..."
-       -copy $(GLUTDLL) ..\lib
-       @echo "copying GLUT import library to lib directory..."
-       -copy $(GLUTLIB) ..\lib
-
-glut.dll : $(OBJS) glut.def
-       $(link) $(LFLAGS) -out:glut.dll -def:glut.def $(OBJS) $(SGI_LIBS)
-
-install        : $(GLUTDLL)
-       @echo "copying GLUT dynamic link library to system directory..."
-       -copy $(GLUTDLL) $(DLLINSTALL)
-       @echo "copying GLUT header file to include directory..."
-       -copy ..\include\GL\glut.h $(INCLUDEINSTALL)
-       @echo "copying GLUT import library to library directory..."
-       -copy $(GLUTLIB) $(LIBINSTALL)
-
-.c.obj :
-       $(cc)   $(CFLAGS) -I . $*.c
-
-# explicit object dependencies for all source files
-
-win32_glx.obj: win32_glx.c win32_glx.h
-win32_x11.obj: win32_x11.c win32_x11.h
-win32_menu.obj: win32_menu.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h
-win32_util.obj: win32_util.c glutint.h ..\include\GL\glutf90.h
-win32_winproc.obj: win32_winproc.c glutint.h ..\include\GL\glutf90.h
-
-glut_mroman.obj: glut_mroman.c glutstroke.h glutint.h ..\include\GL\glutf90.h
-glut_roman.obj: glut_roman.c glutstroke.h glutint.h ..\include\GL\glutf90.h
-glut_hel12.obj: glut_hel12.c glutbitmap.h glutint.h ..\include\GL\glutf90.h
-glut_8x13.obj: glut_8x13.c glutbitmap.h glutint.h ..\include\GL\glutf90.h
-glut_hel18.obj: glut_hel18.c glutbitmap.h glutint.h ..\include\GL\glutf90.h
-glut_9x15.obj: glut_9x15.c glutbitmap.h glutint.h ..\include\GL\glutf90.h
-glut_tr10.obj: glut_tr10.c glutbitmap.h glutint.h ..\include\GL\glutf90.h
-glut_hel10.obj: glut_hel10.c glutbitmap.h glutint.h ..\include\GL\glutf90.h
-glut_tr24.obj: glut_tr24.c glutbitmap.h glutint.h ..\include\GL\glutf90.h
-
-glut_bitmap.obj: glut_bitmap.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_bwidth.obj: glut_bwidth.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_cindex.obj: glut_cindex.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_cmap.obj: glut_cmap.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_cursor.obj: glut_cursor.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_dials.obj: glut_dials.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_dstr.obj: glut_dstr.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_event.obj: glut_event.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_ext.obj: glut_ext.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_fullscrn.obj: glut_fullscrn.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_gamemode.obj: glut_gamemode.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_get.obj: glut_get.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_init.obj: glut_init.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_input.obj: glut_input.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_joy.obj: glut_joy.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_key.obj: glut_key.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_keyctrl.obj: glut_keyctrl.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_keyup.obj: glut_keyup.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_mesa.obj: glut_mesa.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_modifier.obj: glut_modifier.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_overlay.obj: glut_overlay.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_shapes.obj: glut_shapes.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_space.obj: glut_space.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_swap.obj: glut_swap.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_swidth.obj: glut_swidth.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_tablet.obj: glut_tablet.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_teapot.obj: glut_teapot.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_util.obj: glut_util.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_vidresize.obj: glut_vidresize.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_warp.obj: glut_warp.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-glut_win.obj: glut_win.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h
-glut_winmisc.obj: glut_winmisc.c glutint.h ..\include\GL\glutf90.h ..\include\GL\glut.h glutwin32.h win32_glx.h win32_x11.h
-
diff --git a/src/glut/glx/SConscript b/src/glut/glx/SConscript
deleted file mode 100644 (file)
index 9363b5c..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-Import('*')
-
-env = env.Clone()
-
-env.Replace(CPPDEFINES = [
-    'BUILD_GLUT32', 
-    'GLUT_BUILDING_LIB', 
-    'NDEBUG',
-    'GLUT_NO_WARNING_DISABLE',
-])
-
-env.AppendUnique(CPPPATH = [
-    '#/include',
-])
-
-sources = [
-    'glut_bitmap.c',
-    'glut_bwidth.c',
-    'glut_cindex.c',
-    'glut_cmap.c',
-    'glut_cursor.c',
-    'glut_dials.c',
-    'glut_dstr.c',
-    'glut_event.c',
-    'glut_ext.c',
-    'glut_fullscrn.c',
-    'glut_gamemode.c',
-    'glut_get.c',
-    'glut_init.c',
-    'glut_input.c',
-    'glut_joy.c',
-    'glut_key.c',
-    'glut_keyctrl.c',
-    'glut_keyup.c',
-    'glut_mesa.c',
-    'glut_modifier.c',
-    'glut_overlay.c',
-    'glut_ppm.c',
-    'glut_shapes.c',
-    'glut_space.c',
-    'glut_stroke.c',
-    'glut_swap.c',
-    'glut_swidth.c',
-    'glut_tablet.c',
-    'glut_teapot.c',
-    'glut_util.c',
-    'glut_vidresize.c',
-    'glut_warp.c',
-    'glut_win.c',
-    'glut_winmisc.c',
-    
-    'glut_8x13.c',
-    'glut_9x15.c',
-    'glut_hel10.c',
-    'glut_hel12.c',
-    'glut_hel18.c',
-    'glut_mroman.c',
-    'glut_roman.c',
-    'glut_tr10.c',
-    'glut_tr24.c',
-]
-
-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')
-else:
-    glut = env.FindIxes(glut, 'SHLIBPREFIX', 'SHLIBSUFFIX')
-
-Export('glut')
diff --git a/src/glut/glx/capturexfont.c b/src/glut/glx/capturexfont.c
deleted file mode 100644 (file)
index fd63fb7..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-/* capturexfont.c connects to an X server and downloads a
-   bitmap font from which a C source file is generated,
-   encoding  the font for GLUT's use. Example usage:
-   capturexfont.c 9x15 glutBitmap9By15 > glut_9x15.c */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <GL/gl.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#define MAX_GLYPHS_PER_GRAB 512  /* This is big enough for 2^9
-                                    glyph character sets */
-
-static void
-outputChar(int num, int width, int height,
-  int xoff, int yoff, int advance, int data)
-{
-  if (width == 0 || height == 0) {
-    printf("#ifdef _WIN32\n");
-    printf("/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with\n");
-    printf("   a height or width of zero does not advance the raster position\n");
-    printf("   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */\n");
-    printf("static const GLubyte ch%ddata[] = { 0x0 };\n", num);
-    printf("static const BitmapCharRec ch%d = {", num);
-    printf("%d,", 0);
-    printf("%d,", 0);
-    printf("%d,", xoff);
-    printf("%d,", yoff);
-    printf("%d,", advance);
-    printf("ch%ddata", num);
-    printf("};\n");
-    printf("#else\n");
-  }
-  printf("static const BitmapCharRec ch%d = {", num);
-  printf("%d,", width);
-  printf("%d,", height);
-  printf("%d,", xoff);
-  printf("%d,", yoff);
-  printf("%d,", advance);
-  if (data) {
-    printf("ch%ddata", num);
-  } else {
-    printf("0");
-  }
-  printf("};\n");
-  if (width == 0 || height == 0) {
-    printf("#endif\n");
-  }
-  printf("\n");
-}
-
-/* Can't just use isprint because it only works for the range
-   of ASCII characters (ie, TRUE for isascii) and capturexfont
-   might be run on 16-bit fonts. */
-#define PRINTABLE(ch)  (isascii(ch) ? isprint(ch) : 0)
-
-void
-captureXFont(Display * dpy, Font font, char *xfont, char *name)
-{
-  int first, last, count;
-  int cnt, len;
-  Pixmap offscreen;
-  Window drawable;
-  XFontStruct *fontinfo;
-  XImage *image;
-  GC xgc;
-  XGCValues values;
-  int width, height;
-  int i, j, k;
-  XCharStruct *charinfo;
-  XChar2b character;
-  GLubyte *bitmapData;
-  int x, y;
-  int spanLength;
-  int charWidth, charHeight, maxSpanLength, pixwidth;
-  int grabList[MAX_GLYPHS_PER_GRAB];
-  int glyphsPerGrab = MAX_GLYPHS_PER_GRAB;
-  int numToGrab;
-  int rows, pages, byte1, byte2, index;
-  int nullBitmap;
-
-  drawable = RootWindow(dpy, DefaultScreen(dpy));
-
-  fontinfo = XQueryFont(dpy, font);
-  pages = fontinfo->max_char_or_byte2 - fontinfo->min_char_or_byte2 + 1;
-  first = (fontinfo->min_byte1 << 8) + fontinfo->min_char_or_byte2;
-  last = (fontinfo->max_byte1 << 8) + fontinfo->max_char_or_byte2;
-  count = last - first + 1;
-
-  width = fontinfo->max_bounds.rbearing -
-    fontinfo->min_bounds.lbearing;
-  height = fontinfo->max_bounds.ascent +
-    fontinfo->max_bounds.descent;
-  /* 16-bit fonts have more than one row; indexing into
-     per_char is trickier. */
-  rows = fontinfo->max_byte1 - fontinfo->min_byte1 + 1;
-
-  maxSpanLength = (width + 7) / 8;
-  /* For portability reasons we don't use alloca for
-     bitmapData, but we could. */
-  bitmapData = malloc(height * maxSpanLength);
-  /* Be careful determining the width of the pixmap; the X
-     protocol allows pixmaps of width 2^16-1 (unsigned short
-     size) but drawing coordinates max out at 2^15-1 (signed
-     short size).  If the width is too large, we need to limit
-     the glyphs per grab. */
-  if ((glyphsPerGrab * 8 * maxSpanLength) >= (1 << 15)) {
-    glyphsPerGrab = (1 << 15) / (8 * maxSpanLength);
-  }
-  pixwidth = glyphsPerGrab * 8 * maxSpanLength;
-  offscreen = XCreatePixmap(dpy, drawable, pixwidth, height, 1);
-
-  values.font = font;
-  values.background = 0;
-  values.foreground = 0;
-  xgc = XCreateGC(dpy, offscreen,
-    GCFont | GCBackground | GCForeground, &values);
-  XFillRectangle(dpy, offscreen, xgc, 0, 0,
-    8 * maxSpanLength * glyphsPerGrab, height);
-  XSetForeground(dpy, xgc, 1);
-
-  numToGrab = 0;
-  if (fontinfo->per_char == NULL) {
-    charinfo = &(fontinfo->min_bounds);
-    charWidth = charinfo->rbearing - charinfo->lbearing;
-    charHeight = charinfo->ascent + charinfo->descent;
-    spanLength = (charWidth + 7) / 8;
-  }
-  printf("\n/* GENERATED FILE -- DO NOT MODIFY */\n\n");
-  printf("#include \"glutbitmap.h\"\n\n");
-  for (i = first; count; i++, count--) {
-    int undefined;
-    if (rows == 1) {
-      undefined = (fontinfo->min_char_or_byte2 > i ||
-        fontinfo->max_char_or_byte2 < i);
-    } else {
-      byte2 = i & 0xff;
-      byte1 = i >> 8;
-      undefined = (fontinfo->min_char_or_byte2 > byte2 ||
-        fontinfo->max_char_or_byte2 < byte2 ||
-        fontinfo->min_byte1 > byte1 ||
-        fontinfo->max_byte1 < byte1);
-
-    }
-    if (undefined) {
-      goto PossiblyDoGrab;
-    }
-    if (fontinfo->per_char != NULL) {
-      if (rows == 1) {
-        index = i - fontinfo->min_char_or_byte2;
-      } else {
-        byte2 = i & 0xff;
-        byte1 = i >> 8;
-        index =
-          (byte1 - fontinfo->min_byte1) * pages +
-          (byte2 - fontinfo->min_char_or_byte2);
-      }
-      charinfo = &(fontinfo->per_char[index]);
-      charWidth = charinfo->rbearing - charinfo->lbearing;
-      charHeight = charinfo->ascent + charinfo->descent;
-      if (charWidth == 0 || charHeight == 0) {
-        if (charinfo->width != 0) {
-          /* Still must move raster pos even if empty character 
-
-           */
-          outputChar(i, 0, 0, 0, 0, charinfo->width, 0);
-        }
-        goto PossiblyDoGrab;
-      }
-    }
-    grabList[numToGrab] = i;
-    character.byte2 = i & 255;
-    character.byte1 = i >> 8;
-
-    /* XXX We could use XDrawImageString16 which would also
-       paint the backing rectangle but X server bugs in some
-       scalable font rasterizers makes it more effective to do
-       XFillRectangles to clear the pixmap and then
-       XDrawImage16 for the text.  */
-    XDrawString16(dpy, offscreen, xgc,
-      -charinfo->lbearing + 8 * maxSpanLength * numToGrab,
-      charinfo->ascent, &character, 1);
-
-    numToGrab++;
-
-  PossiblyDoGrab:
-
-    if (numToGrab >= glyphsPerGrab || count == 1) {
-      image = XGetImage(dpy, offscreen,
-        0, 0, pixwidth, height, 1, XYPixmap);
-      for (j = numToGrab - 1; j >= 0; j--) {
-        if (fontinfo->per_char != NULL) {
-          byte2 = grabList[j] & 0xff;
-          byte1 = grabList[j] >> 8;
-          index =
-            (byte1 - fontinfo->min_byte1) * pages +
-            (byte2 - fontinfo->min_char_or_byte2);
-          charinfo = &(fontinfo->per_char[index]);
-          charWidth = charinfo->rbearing - charinfo->lbearing;
-          charHeight = charinfo->ascent + charinfo->descent;
-          spanLength = (charWidth + 7) / 8;
-        }
-        memset(bitmapData, 0, height * spanLength);
-        for (y = 0; y < charHeight; y++) {
-          for (x = 0; x < charWidth; x++) {
-            if (XGetPixel(image, j * maxSpanLength * 8 + x,
-                charHeight - 1 - y)) {
-              /* Little endian machines (such as DEC Alpha)
-                 could  benefit from reversing the bit order
-                 here and changing the GL_UNPACK_LSB_FIRST
-                 parameter in glutBitmapCharacter to GL_TRUE. */
-              bitmapData[y * spanLength + x / 8] |=
-                (1 << (7 - (x & 7)));
-            }
-          }
-        }
-        if (PRINTABLE(grabList[j])) {
-          printf("/* char: 0x%x '%c' */\n\n",
-            grabList[j], grabList[j]);
-        } else {
-          printf("/* char: 0x%x */\n\n", grabList[j]);
-        }
-
-        /* Determine if the bitmap is null. */
-        nullBitmap = 1;
-        len = (charinfo->ascent + charinfo->descent) *
-          ((charinfo->rbearing - charinfo->lbearing + 7) / 8);
-        cnt = 0;
-        while (cnt < len) {
-          for (k = 0; k < 16 && cnt < len; k++, cnt++) {
-            if (bitmapData[cnt] != 0) {
-              nullBitmap = 0;
-            }
-          }
-        }
-
-        if (!nullBitmap) {
-          printf("static const GLubyte ch%ddata[] = {\n", grabList[j]);
-          len = (charinfo->ascent + charinfo->descent) *
-            ((charinfo->rbearing - charinfo->lbearing + 7) / 8);
-          cnt = 0;
-          while (cnt < len) {
-            for (k = 0; k < 16 && cnt < len; k++, cnt++) {
-              printf("0x%x,", bitmapData[cnt]);
-            }
-            printf("\n");
-          }
-          printf("};\n\n");
-        } else {
-          charWidth = 0;
-          charHeight = 0;
-        }
-
-        outputChar(grabList[j], charWidth, charHeight,
-          -charinfo->lbearing, charinfo->descent,
-          charinfo->width, !nullBitmap);
-      }
-      XDestroyImage(image);
-      numToGrab = 0;
-      if (count > 0) {
-        XSetForeground(dpy, xgc, 0);
-        XFillRectangle(dpy, offscreen, xgc, 0, 0,
-          8 * maxSpanLength * glyphsPerGrab, height);
-        XSetForeground(dpy, xgc, 1);
-      }
-    }
-  }
-  XFreeGC(dpy, xgc);
-  XFreePixmap(dpy, offscreen);
-  /* For portability reasons we don't use alloca for
-     bitmapData, but we could. */
-  free(bitmapData);
-
-  printf("static const BitmapCharRec * const chars[] = {\n");
-  for (i = first; i <= last; i++) {
-    int undefined;
-    byte2 = i & 0xff;
-    byte1 = i >> 8;
-    undefined = (fontinfo->min_char_or_byte2 > byte2 ||
-      fontinfo->max_char_or_byte2 < byte2 ||
-      fontinfo->min_byte1 > byte1 ||
-      fontinfo->max_byte1 < byte1);
-    if (undefined) {
-      printf("0,\n");
-    } else {
-      if (fontinfo->per_char != NULL) {
-        if (rows == 1) {
-          index = i - fontinfo->min_char_or_byte2;
-        } else {
-          byte2 = i & 0xff;
-          byte1 = i >> 8;
-          index =
-            (byte1 - fontinfo->min_byte1) * pages +
-            (byte2 - fontinfo->min_char_or_byte2);
-        }
-        charinfo = &(fontinfo->per_char[index]);
-        charWidth = charinfo->rbearing - charinfo->lbearing;
-        charHeight = charinfo->ascent + charinfo->descent;
-        if (charWidth == 0 || charHeight == 0) {
-          if (charinfo->width == 0) {
-            printf("0,\n");
-            continue;
-          }
-        }
-      }
-      printf("&ch%d,\n", i);
-    }
-  }
-  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);
-  printf("%d,\n", first);
-  printf("chars\n");
-  printf("};\n\n");
-  XFreeFont(dpy, fontinfo);
-}
-
-int
-main(int argc, char **argv)
-{
-  Display *dpy;
-  Font font;
-
-  if (argc != 3) {
-    fprintf(stderr, "usage: capturexfont XFONT NAME\n");
-    exit(1);
-  }
-  dpy = XOpenDisplay(NULL);
-  if (dpy == NULL) {
-    fprintf(stderr, "capturexfont: could not open X display\n");
-    exit(1);
-  }
-  font = XLoadFont(dpy, argv[1]);
-  if (font == None) {
-    fprintf(stderr, "capturexfont: bad font\n");
-    exit(1);
-  }
-  captureXFont(dpy, font, argv[1], argv[2]);
-  XCloseDisplay(dpy);
-  return 0;
-}
diff --git a/src/glut/glx/fxglut.def b/src/glut/glx/fxglut.def
deleted file mode 100644 (file)
index 805a0c7..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-EXPORTS
-       glutInit
-       glutInitDisplayMode
-       glutInitDisplayString
-       glutInitWindowPosition
-       glutInitWindowSize
-       glutMainLoop
-       glutCreateWindow
-       glutCreateSubWindow
-       glutDestroyWindow
-       glutPostRedisplay
-       glutSwapBuffers
-       glutGetWindow
-       glutSetWindow
-       glutSetWindowTitle
-       glutSetIconTitle
-       glutPositionWindow
-       glutReshapeWindow
-       glutPopWindow
-       glutPushWindow
-       glutIconifyWindow
-       glutShowWindow
-       glutHideWindow
-       glutFullScreen
-       glutSetCursor
-       glutWarpPointer
-       glutEstablishOverlay
-       glutRemoveOverlay
-       glutUseLayer
-       glutPostOverlayRedisplay
-       glutShowOverlay
-       glutHideOverlay
-       glutCreateMenu
-       glutDestroyMenu
-       glutGetMenu
-       glutSetMenu
-       glutAddMenuEntry
-       glutAddSubMenu
-       glutChangeToMenuEntry
-       glutChangeToSubMenu
-       glutRemoveMenuItem
-       glutAttachMenu
-       glutDetachMenu
-       glutDisplayFunc
-       glutReshapeFunc
-       glutKeyboardFunc
-       glutMouseFunc
-       glutMotionFunc
-       glutPassiveMotionFunc
-       glutEntryFunc
-       glutVisibilityFunc
-       glutIdleFunc
-       glutTimerFunc
-       glutMenuStateFunc
-       glutSpecialFunc
-       glutSpaceballMotionFunc
-       glutSpaceballRotateFunc
-       glutSpaceballButtonFunc
-       glutButtonBoxFunc
-       glutDialsFunc
-       glutTabletMotionFunc
-       glutTabletButtonFunc
-       glutMenuStatusFunc
-       glutOverlayDisplayFunc
-       glutWindowStatusFunc
-       glutSetColor
-       glutGetColor
-       glutCopyColormap
-       glutGet
-       glutDeviceGet
-       glutExtensionSupported
-       glutGetModifiers
-       glutLayerGet
-       glutBitmapCharacter
-       glutBitmapWidth
-       glutStrokeCharacter
-       glutStrokeWidth
-       glutBitmapLength
-       glutStrokeLength
-       glutWireSphere
-       glutSolidSphere
-       glutWireCone
-       glutSolidCone
-       glutWireCube
-       glutSolidCube
-       glutWireTorus
-       glutSolidTorus
-       glutWireDodecahedron
-       glutSolidDodecahedron
-       glutWireTeapot
-       glutSolidTeapot
-       glutWireOctahedron
-       glutSolidOctahedron
-       glutWireTetrahedron
-       glutSolidTetrahedron
-       glutWireIcosahedron
-       glutSolidIcosahedron
-       glutVideoResizeGet
-       glutSetupVideoResizing
-       glutStopVideoResizing
-       glutVideoResize
-       glutVideoPan
-       glutReportErrors
diff --git a/src/glut/glx/glut.def b/src/glut/glx/glut.def
deleted file mode 100644 (file)
index 9001081..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-EXPORTS
-       glutAddMenuEntry
-       glutAddSubMenu
-       glutAttachMenu
-       glutBitmapCharacter
-       glutBitmapLength
-       glutBitmapWidth
-       glutButtonBoxFunc
-       glutChangeToMenuEntry
-       glutChangeToSubMenu
-       glutCopyColormap
-       glutCreateMenu
-       __glutCreateMenuWithExit
-       glutCreateSubWindow
-       glutCreateWindow
-       __glutCreateWindowWithExit
-       glutDestroyMenu
-       glutDestroyWindow
-       glutDetachMenu
-       glutDeviceGet
-       glutDialsFunc
-       glutDisplayFunc
-       glutEnterGameMode
-       glutEntryFunc
-       glutEstablishOverlay
-       glutExtensionSupported
-       glutForceJoystickFunc
-       glutFullScreen
-       glutGameModeGet
-       glutGameModeString
-       glutGet
-       glutGetColor
-       glutGetMenu
-       glutGetModifiers
-       glutGetWindow
-       glutHideOverlay
-       glutHideWindow
-       glutIconifyWindow
-       glutIdleFunc
-       glutIgnoreKeyRepeat
-       glutInit
-       __glutInitWithExit
-       glutInitDisplayMode
-       glutInitDisplayString
-       glutInitWindowPosition
-       glutInitWindowSize
-       glutJoystickFunc
-       glutKeyboardFunc
-       glutKeyboardUpFunc
-       glutLayerGet
-       glutLeaveGameMode
-       glutMainLoop
-       glutMenuStateFunc
-       glutMenuStatusFunc
-       glutMotionFunc
-       glutMouseFunc
-       glutOverlayDisplayFunc
-       glutPassiveMotionFunc
-       glutPopWindow
-       glutPositionWindow
-       glutPostOverlayRedisplay
-       glutPostRedisplay
-       glutPostWindowOverlayRedisplay
-       glutPostWindowRedisplay
-       glutPushWindow
-       glutRemoveMenuItem
-       glutRemoveOverlay
-       glutReportErrors
-       glutReshapeFunc
-       glutReshapeWindow
-       glutSetColor
-       glutSetCursor
-       glutSetIconTitle
-       glutSetKeyRepeat
-       glutSetMenu
-       glutSetWindow
-       glutSetWindowTitle
-       glutSetupVideoResizing
-       glutShowOverlay
-       glutShowWindow
-       glutSolidCone
-       glutSolidCube
-       glutSolidDodecahedron
-       glutSolidIcosahedron
-       glutSolidOctahedron
-       glutSolidSphere
-       glutSolidTeapot
-       glutSolidTetrahedron
-       glutSolidTorus
-       glutSpaceballButtonFunc
-       glutSpaceballMotionFunc
-       glutSpaceballRotateFunc
-       glutSpecialFunc
-       glutSpecialUpFunc
-       glutStopVideoResizing
-       glutStrokeCharacter
-       glutStrokeLength
-       glutStrokeWidth
-       glutSwapBuffers
-       glutTabletButtonFunc
-       glutTabletMotionFunc
-       glutTimerFunc
-       glutUseLayer
-       glutVideoPan
-       glutVideoResize
-       glutVideoResizeGet
-       glutVisibilityFunc
-       glutWarpPointer
-       glutWindowStatusFunc
-       glutWireCone
-       glutWireCube
-       glutWireDodecahedron
-       glutWireIcosahedron
-       glutWireOctahedron
-       glutWireSphere
-       glutWireTeapot
-       glutWireTetrahedron
-       glutWireTorus
-       glutStrokeRoman
-       glutBitmap9By15
-       glutBitmapHelvetica10
-       glutBitmapHelvetica18
-       glutBitmapTimesRoman24
-;    __glutSetFCB
-;    __glutGetFCB
diff --git a/src/glut/glx/glut.pc.in b/src/glut/glx/glut.pc.in
deleted file mode 100644 (file)
index 151dd0b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-prefix=@INSTALL_DIR@
-exec_prefix=${prefix}
-libdir=@INSTALL_LIB_DIR@
-includedir=@INSTALL_INC_DIR@
-
-Name: glut
-Description: Mesa OpenGL Utility Toolkit library
-Requires: gl glu
-Requires.private: @GLUT_PC_REQ_PRIV@
-Version: @VERSION@
-Libs: -L${libdir} -l@GLUT_LIB@
-Libs.private: @GLUT_PC_LIB_PRIV@
-Cflags: -I${includedir} @GLUT_PC_CFLAGS@
diff --git a/src/glut/glx/glut_8x13.c b/src/glut/glx/glut_8x13.c
deleted file mode 100644 (file)
index f4e18eb..0000000
+++ /dev/null
@@ -1,2074 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmap8By13 XXX
-#include "glutbitmap.h"
-#undef glutBitmap8By13
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch0data[] = { 0x0 };
-static const BitmapCharRec ch0 = {1,1,0,0,8,ch0data};
-#else
-static const BitmapCharRec ch0 = {0,0,0,0,8,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,8,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,8,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch127data[] = { 0x0 };
-static const BitmapCharRec ch127 = {1,1,0,0,8,ch127data};
-#else
-static const BitmapCharRec ch127 = {0,0,0,0,8,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,8,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,8,0};
-#endif
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch255 = {6,12,-1,2,8,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0x80,0x80,0xb8,0xc4,0x84,0x84,0xc4,0xb8,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {6,10,-1,2,8,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch253 = {6,12,-1,2,8,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch252 = {6,10,-1,0,8,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,0x0,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch251 = {6,10,-1,0,8,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch250 = {6,10,-1,0,8,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,0x0,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch249 = {6,10,-1,0,8,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0x80,0x78,0xc4,0xa4,0x94,0x8c,0x78,0x4,
-};
-
-static const BitmapCharRec ch248 = {6,8,-1,1,8,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x20,0x20,0x0,0xf8,0x0,0x20,0x20,
-};
-
-static const BitmapCharRec ch247 = {5,7,-1,-1,8,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch246 = {6,10,-1,0,8,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch245 = {6,10,-1,0,8,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch244 = {6,10,-1,0,8,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch243 = {6,10,-1,0,8,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x0,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch242 = {6,10,-1,0,8,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0x84,0x84,0x84,0x84,0xc4,0xb8,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch241 = {6,10,-1,0,8,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,0x8,0x50,0x30,0x48,
-};
-
-static const BitmapCharRec ch240 = {6,10,-1,0,8,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x0,0x50,0x50,
-};
-
-static const BitmapCharRec ch239 = {5,10,-1,0,8,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x0,0x90,0x60,
-};
-
-static const BitmapCharRec ch238 = {5,10,-1,0,8,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch237 = {5,10,-1,0,8,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch236 = {5,10,-1,0,8,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch235 = {6,10,-1,0,8,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,0x0,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch234 = {6,10,-1,0,8,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch233 = {6,10,-1,0,8,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,0x0,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch232 = {6,10,-1,0,8,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x20,0x10,0x78,0x84,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch231 = {6,8,-1,2,8,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x6c,0x92,0x90,0x7c,0x12,0x6c,
-};
-
-static const BitmapCharRec ch230 = {7,6,0,0,8,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x30,0x48,0x30,
-};
-
-static const BitmapCharRec ch229 = {6,10,-1,0,8,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch228 = {6,10,-1,0,8,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch227 = {6,10,-1,0,8,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch226 = {6,10,-1,0,8,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch225 = {6,10,-1,0,8,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,0x0,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch224 = {6,10,-1,0,8,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0x80,0xb8,0xc4,0x84,0x84,0xf8,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch223 = {6,9,-1,1,8,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0x80,0x80,0x80,0xf8,0x84,0x84,0x84,0xf8,0x80,
-};
-
-static const BitmapCharRec ch222 = {6,9,-1,0,8,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x20,0x20,0x20,0x20,0x50,0x88,0x88,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch221 = {5,10,-1,0,8,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch220 = {6,10,-1,0,8,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch219 = {6,10,-1,0,8,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch218 = {6,10,-1,0,8,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch217 = {6,10,-1,0,8,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x78,0xc4,0xa4,0xa4,0xa4,0x94,0x94,0x8c,0x78,0x4,
-};
-
-static const BitmapCharRec ch216 = {6,11,-1,1,8,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x84,0x48,0x30,0x30,0x48,0x84,
-};
-
-static const BitmapCharRec ch215 = {6,6,-1,-1,8,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch214 = {7,10,0,0,8,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch213 = {7,10,0,0,8,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x24,0x18,
-};
-
-static const BitmapCharRec ch212 = {7,10,0,0,8,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch211 = {7,10,0,0,8,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x8,0x10,
-};
-
-static const BitmapCharRec ch210 = {7,10,0,0,8,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0x82,0x86,0x8a,0x92,0xa2,0xc2,0x82,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch209 = {7,10,0,0,8,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0xfc,0x42,0x42,0x42,0xe2,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch208 = {7,9,0,0,8,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x50,0x50,
-};
-
-static const BitmapCharRec ch207 = {5,10,-1,0,8,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch206 = {5,10,-1,0,8,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch205 = {5,10,-1,0,8,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch204 = {5,10,-1,0,8,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xfc,0x80,0x80,0xf0,0x80,0x80,0xfc,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch203 = {6,10,-1,0,8,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xfc,0x80,0x80,0xf0,0x80,0x80,0xfc,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch202 = {6,10,-1,0,8,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xfc,0x80,0x80,0xf0,0x80,0x80,0xfc,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch201 = {6,10,-1,0,8,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xfc,0x80,0x80,0xf0,0x80,0x80,0xfc,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch200 = {6,10,-1,0,8,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x20,0x10,0x78,0x84,0x80,0x80,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch199 = {6,11,-1,2,8,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0x9e,0x90,0x90,0xf0,0x9c,0x90,0x90,0x90,0x6e,
-};
-
-static const BitmapCharRec ch198 = {7,9,0,0,8,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x30,0x48,0x30,
-};
-
-static const BitmapCharRec ch197 = {6,10,-1,0,8,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x48,0x48,
-};
-
-static const BitmapCharRec ch196 = {6,10,-1,0,8,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch195 = {6,10,-1,0,8,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x48,0x30,
-};
-
-static const BitmapCharRec ch194 = {6,10,-1,0,8,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch193 = {6,10,-1,0,8,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0x84,0x84,0xfc,0x84,0x84,0x48,0x30,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch192 = {6,10,-1,0,8,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x78,0x84,0x84,0x80,0x40,0x20,0x20,0x0,0x20,
-};
-
-static const BitmapCharRec ch191 = {6,9,-1,0,8,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x6,0x1a,0x12,0xa,0x66,0x92,0x10,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch190 = {7,10,0,0,8,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x1e,0x10,0xc,0x2,0xf2,0x4c,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch189 = {7,10,0,0,8,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x6,0x1a,0x12,0xa,0xe6,0x42,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch188 = {7,10,0,0,8,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0x90,0x48,0x24,0x12,0x24,0x48,0x90,
-};
-
-static const BitmapCharRec ch187 = {7,7,0,-1,8,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xf0,0x0,0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch186 = {4,6,-1,-3,8,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {3,6,-1,-4,8,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xc0,0x40,
-};
-
-static const BitmapCharRec ch184 = {2,2,-3,2,8,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,1,-3,-4,8,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,0x7c,
-};
-
-static const BitmapCharRec ch182 = {6,9,-1,0,8,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0xb4,0xcc,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch181 = {6,7,-1,1,8,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x40,
-};
-
-static const BitmapCharRec ch180 = {2,2,-3,-8,8,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0x60,0x90,0x10,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch179 = {4,6,-1,-4,8,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xf0,0x80,0x60,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch178 = {4,6,-1,-4,8,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xf8,0x0,0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch177 = {5,7,-1,-1,8,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,-2,-5,8,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch175 = {6,1,-1,-8,8,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x38,0x44,0xaa,0xb2,0xaa,0xaa,0x92,0x44,0x38,
-};
-
-static const BitmapCharRec ch174 = {7,9,0,-1,8,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch173 = {6,1,-1,-4,8,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x4,0x4,0x4,0xfc,
-};
-
-static const BitmapCharRec ch172 = {6,4,-1,-1,8,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x12,0x24,0x48,0x90,0x48,0x24,0x12,
-};
-
-static const BitmapCharRec ch171 = {7,7,0,-1,8,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xf8,0x0,0x78,0x88,0x78,0x8,0x70,
-};
-
-static const BitmapCharRec ch170 = {5,7,-1,-2,8,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x38,0x44,0x92,0xaa,0xa2,0xaa,0x92,0x44,0x38,
-};
-
-static const BitmapCharRec ch169 = {7,9,0,-1,8,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xd8,
-};
-
-static const BitmapCharRec ch168 = {5,1,-1,-8,8,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x60,0x90,0x10,0x60,0x90,0x90,0x60,0x80,0x90,0x60,
-};
-
-static const BitmapCharRec ch167 = {4,10,-2,0,8,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x80,0x0,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,9,-3,0,8,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x10,0x10,0x7c,0x10,0x7c,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch165 = {7,9,0,0,8,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x84,0x78,0x48,0x48,0x78,0x84,
-};
-
-static const BitmapCharRec ch164 = {6,6,-1,-1,8,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xdc,0x62,0x20,0x20,0x20,0x70,0x20,0x22,0x1c,
-};
-
-static const BitmapCharRec ch163 = {7,9,0,0,8,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x20,0x70,0xa8,0xa0,0xa0,0xa8,0x70,0x20,
-};
-
-static const BitmapCharRec ch162 = {5,8,-1,-1,8,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,9,-3,0,8,ch161data};
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x90,0xa8,0x48,
-};
-
-static const BitmapCharRec ch126 = {5,3,-1,-6,8,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xe0,0x10,0x10,0x20,0x18,0x20,0x10,0x10,0xe0,
-};
-
-static const BitmapCharRec ch125 = {5,9,-1,0,8,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,9,-3,0,8,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x38,0x40,0x40,0x20,0xc0,0x20,0x40,0x40,0x38,
-};
-
-static const BitmapCharRec ch123 = {5,9,-2,0,8,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xfc,0x40,0x20,0x10,0x8,0xfc,
-};
-
-static const BitmapCharRec ch122 = {6,6,-1,0,8,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch121 = {6,8,-1,2,8,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0x84,0x48,0x30,0x30,0x48,0x84,
-};
-
-static const BitmapCharRec ch120 = {6,6,-1,0,8,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x44,0xaa,0x92,0x92,0x82,0x82,
-};
-
-static const BitmapCharRec ch119 = {7,6,0,0,8,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x20,0x50,0x50,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch118 = {5,6,-1,0,8,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x74,0x88,0x88,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch117 = {6,6,-1,0,8,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x38,0x44,0x40,0x40,0x40,0xf8,0x40,0x40,
-};
-
-static const BitmapCharRec ch116 = {6,8,-1,0,8,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x78,0x84,0x18,0x60,0x84,0x78,
-};
-
-static const BitmapCharRec ch115 = {6,6,-1,0,8,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0x40,0x40,0x40,0x40,0x44,0xb8,
-};
-
-static const BitmapCharRec ch114 = {6,6,-1,0,8,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x4,0x4,0x4,0x74,0x8c,0x84,0x8c,0x74,
-};
-
-static const BitmapCharRec ch113 = {6,8,-1,2,8,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0x80,0x80,0x80,0xb8,0xc4,0x84,0xc4,0xb8,
-};
-
-static const BitmapCharRec ch112 = {6,8,-1,2,8,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x78,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch111 = {6,6,-1,0,8,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0x84,0x84,0x84,0x84,0xc4,0xb8,
-};
-
-static const BitmapCharRec ch110 = {6,6,-1,0,8,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0x82,0x92,0x92,0x92,0x92,0xec,
-};
-
-static const BitmapCharRec ch109 = {7,6,0,0,8,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x60,
-};
-
-static const BitmapCharRec ch108 = {5,9,-1,0,8,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x84,0x88,0x90,0xe0,0x90,0x88,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {6,9,-1,0,8,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x70,0x88,0x88,0x8,0x8,0x8,0x8,0x18,0x0,0x8,
-};
-
-static const BitmapCharRec ch106 = {5,10,-1,2,8,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x60,0x0,0x20,
-};
-
-static const BitmapCharRec ch105 = {5,8,-1,0,8,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0x84,0x84,0x84,0x84,0xc4,0xb8,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {6,9,-1,0,8,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x78,0x84,0x78,0x80,0x70,0x88,0x88,0x74,
-};
-
-static const BitmapCharRec ch103 = {6,8,-1,2,8,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x40,0x40,0x40,0x40,0xf8,0x40,0x40,0x44,0x38,
-};
-
-static const BitmapCharRec ch102 = {6,9,-1,0,8,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x78,0x84,0x80,0xfc,0x84,0x78,
-};
-
-static const BitmapCharRec ch101 = {6,6,-1,0,8,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x74,0x8c,0x84,0x84,0x8c,0x74,0x4,0x4,0x4,
-};
-
-static const BitmapCharRec ch100 = {6,9,-1,0,8,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x78,0x84,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch99 = {6,6,-1,0,8,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xb8,0xc4,0x84,0x84,0xc4,0xb8,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {6,9,-1,0,8,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x74,0x8c,0x84,0x7c,0x4,0x78,
-};
-
-static const BitmapCharRec ch97 = {6,6,-1,0,8,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0x10,0x60,0xe0,
-};
-
-static const BitmapCharRec ch96 = {4,3,-2,-6,8,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xfe,
-};
-
-static const BitmapCharRec ch95 = {7,1,0,1,8,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x88,0x50,0x20,
-};
-
-static const BitmapCharRec ch94 = {5,3,-1,-6,8,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xf0,
-};
-
-static const BitmapCharRec ch93 = {4,9,-1,0,8,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x2,0x2,0x4,0x8,0x10,0x20,0x40,0x80,0x80,
-};
-
-static const BitmapCharRec ch92 = {7,9,0,0,8,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xf0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xf0,
-};
-
-static const BitmapCharRec ch91 = {4,9,-2,0,8,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xfc,0x80,0x80,0x40,0x20,0x10,0x8,0x4,0xfc,
-};
-
-static const BitmapCharRec ch90 = {6,9,-1,0,8,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x10,0x10,0x10,0x10,0x10,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch89 = {7,9,0,0,8,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0x82,0x82,0x44,0x28,0x10,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch88 = {7,9,0,0,8,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x44,0xaa,0x92,0x92,0x92,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch87 = {7,9,0,0,8,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x28,0x28,0x28,0x44,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch86 = {7,9,0,0,8,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch85 = {6,9,-1,0,8,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xfe,
-};
-
-static const BitmapCharRec ch84 = {7,9,0,0,8,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x78,0x84,0x4,0x4,0x78,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch83 = {6,9,-1,0,8,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0x84,0x88,0x90,0xa0,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch82 = {6,9,-1,0,8,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x4,0x78,0x94,0xa4,0x84,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch81 = {6,10,-1,1,8,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0x80,0x80,0x80,0x80,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch80 = {6,9,-1,0,8,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch79 = {6,9,-1,0,8,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0x84,0x84,0x84,0x8c,0x94,0xa4,0xc4,0x84,0x84,
-};
-
-static const BitmapCharRec ch78 = {6,9,-1,0,8,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0x82,0x82,0x82,0x92,0x92,0xaa,0xc6,0x82,0x82,
-};
-
-static const BitmapCharRec ch77 = {7,9,0,0,8,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xfc,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch76 = {6,9,-1,0,8,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0x84,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x84,
-};
-
-static const BitmapCharRec ch75 = {6,9,-1,0,8,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x70,0x88,0x8,0x8,0x8,0x8,0x8,0x8,0x3c,
-};
-
-static const BitmapCharRec ch74 = {6,9,-1,0,8,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,
-};
-
-static const BitmapCharRec ch73 = {5,9,-1,0,8,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0x84,0x84,0x84,0x84,0xfc,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch72 = {6,9,-1,0,8,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x74,0x8c,0x84,0x9c,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch71 = {6,9,-1,0,8,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0x80,0x80,0x80,0x80,0xf0,0x80,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch70 = {6,9,-1,0,8,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xfc,0x80,0x80,0x80,0xf0,0x80,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch69 = {6,9,-1,0,8,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xfc,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch68 = {7,9,0,0,8,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x78,0x84,0x80,0x80,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch67 = {6,9,-1,0,8,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xfc,0x42,0x42,0x42,0x7c,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch66 = {7,9,0,0,8,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0x84,0x84,0x84,0xfc,0x84,0x84,0x84,0x48,0x30,
-};
-
-static const BitmapCharRec ch65 = {6,9,-1,0,8,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x78,0x80,0x94,0xac,0xa4,0x9c,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch64 = {6,9,-1,0,8,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x10,0x0,0x10,0x10,0x8,0x4,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch63 = {6,9,-1,0,8,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0x80,0x40,0x20,0x10,0x8,0x10,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch62 = {5,9,-1,0,8,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xfc,0x0,0x0,0xfc,
-};
-
-static const BitmapCharRec ch61 = {6,4,-1,-2,8,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x8,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x8,
-};
-
-static const BitmapCharRec ch60 = {5,9,-2,0,8,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x60,0x70,0x0,0x0,0x20,0x70,0x20,
-};
-
-static const BitmapCharRec ch59 = {4,8,-1,1,8,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0x40,0xe0,0x40,0x0,0x0,0x40,0xe0,0x40,
-};
-
-static const BitmapCharRec ch58 = {3,8,-2,1,8,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x70,0x8,0x4,0x4,0x74,0x8c,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch57 = {6,9,-1,0,8,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x78,0x84,0x84,0x84,0x78,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch56 = {6,9,-1,0,8,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x20,0x20,0x10,0x10,0x8,0x4,0xfc,
-};
-
-static const BitmapCharRec ch55 = {6,9,-1,0,8,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x78,0x84,0x84,0xc4,0xb8,0x80,0x80,0x40,0x38,
-};
-
-static const BitmapCharRec ch54 = {6,9,-1,0,8,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x78,0x84,0x4,0x4,0xc4,0xb8,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch53 = {6,9,-1,0,8,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x8,0x8,0xfc,0x88,0x88,0x48,0x28,0x18,0x8,
-};
-
-static const BitmapCharRec ch52 = {6,9,-1,0,8,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x78,0x84,0x4,0x4,0x38,0x10,0x8,0x4,0xfc,
-};
-
-static const BitmapCharRec ch51 = {6,9,-1,0,8,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xfc,0x80,0x40,0x30,0x8,0x4,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch50 = {6,9,-1,0,8,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xa0,0x60,0x20,
-};
-
-static const BitmapCharRec ch49 = {5,9,-1,0,8,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x30,0x48,0x84,0x84,0x84,0x84,0x84,0x48,0x30,
-};
-
-static const BitmapCharRec ch48 = {6,9,-1,0,8,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x80,0x40,0x20,0x10,0x8,0x4,0x2,0x2,
-};
-
-static const BitmapCharRec ch47 = {7,9,0,0,8,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0x40,0xe0,0x40,
-};
-
-static const BitmapCharRec ch46 = {3,3,-2,1,8,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch45 = {6,1,-1,-4,8,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x60,0x70,
-};
-
-static const BitmapCharRec ch44 = {4,3,-1,1,8,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch43 = {5,5,-1,-2,8,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0x48,0x30,0xfc,0x30,0x48,
-};
-
-static const BitmapCharRec ch42 = {6,5,-1,-2,8,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,9,-2,0,8,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,9,-3,0,8,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x60,0x70,
-};
-
-static const BitmapCharRec ch39 = {4,3,-1,-6,8,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x74,0x88,0x94,0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch38 = {6,7,-1,0,8,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x88,0x54,0x48,0x20,0x10,0x10,0x48,0xa4,0x44,
-};
-
-static const BitmapCharRec ch37 = {6,9,-1,0,8,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x20,0xf0,0x28,0x70,0xa0,0x78,0x20,
-};
-
-static const BitmapCharRec ch36 = {5,7,-1,-1,8,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x48,0x48,0xfc,0x48,0xfc,0x48,0x48,
-};
-
-static const BitmapCharRec ch35 = {6,7,-1,-1,8,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch34 = {4,3,-2,-6,8,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,9,-3,0,8,ch33data};
-
-/* char: 0x1f */
-
-static const GLubyte ch31data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch31 = {1,1,-3,-3,8,ch31data};
-
-/* char: 0x1e */
-
-static const GLubyte ch30data[] = {
-0xdc,0x62,0x20,0x20,0x20,0x70,0x20,0x22,0x1c,
-};
-
-static const BitmapCharRec ch30 = {7,9,0,0,8,ch30data};
-
-/* char: 0x1d */
-
-static const GLubyte ch29data[] = {
-0x80,0x40,0xfe,0x10,0xfe,0x4,0x2,
-};
-
-static const BitmapCharRec ch29 = {7,7,0,0,8,ch29data};
-
-/* char: 0x1c */
-
-static const GLubyte ch28data[] = {
-0x88,0x48,0x48,0x48,0x48,0xfc,
-};
-
-static const BitmapCharRec ch28 = {6,6,-1,0,8,ch28data};
-
-/* char: 0x1b */
-
-static const GLubyte ch27data[] = {
-0xfe,0x80,0x20,0x8,0x2,0x8,0x20,0x80,
-};
-
-static const BitmapCharRec ch27 = {7,8,0,0,8,ch27data};
-
-/* char: 0x1a */
-
-static const GLubyte ch26data[] = {
-0xfe,0x2,0x8,0x20,0x80,0x20,0x8,0x2,
-};
-
-static const BitmapCharRec ch26 = {7,8,0,0,8,ch26data};
-
-/* char: 0x19 */
-
-static const GLubyte ch25data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch25 = {1,13,-3,2,8,ch25data};
-
-/* char: 0x18 */
-
-static const GLubyte ch24data[] = {
-0x10,0x10,0x10,0x10,0x10,0xff,
-};
-
-static const BitmapCharRec ch24 = {8,6,0,2,8,ch24data};
-
-/* char: 0x17 */
-
-static const GLubyte ch23data[] = {
-0xff,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch23 = {8,8,0,-3,8,ch23data};
-
-/* char: 0x16 */
-
-static const GLubyte ch22data[] = {
-0x10,0x10,0x10,0x10,0x10,0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch22 = {4,13,0,2,8,ch22data};
-
-/* char: 0x15 */
-
-static const GLubyte ch21data[] = {
-0x80,0x80,0x80,0x80,0x80,0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch21 = {5,13,-3,2,8,ch21data};
-
-/* char: 0x14 */
-
-static const GLubyte ch20data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch20 = {8,1,0,1,8,ch20data};
-
-/* char: 0x13 */
-
-static const GLubyte ch19data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch19 = {8,1,0,-1,8,ch19data};
-
-/* char: 0x12 */
-
-static const GLubyte ch18data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch18 = {8,1,0,-3,8,ch18data};
-
-/* char: 0x11 */
-
-static const GLubyte ch17data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch17 = {8,1,0,-5,8,ch17data};
-
-/* char: 0x10 */
-
-static const GLubyte ch16data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch16 = {8,1,0,-7,8,ch16data};
-
-/* char: 0xf */
-
-static const GLubyte ch15data[] = {
-0x10,0x10,0x10,0x10,0x10,0xff,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch15 = {8,13,0,2,8,ch15data};
-
-/* char: 0xe */
-
-static const GLubyte ch14data[] = {
-0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch14 = {5,8,-3,-3,8,ch14data};
-
-/* char: 0xd */
-
-static const GLubyte ch13data[] = {
-0x80,0x80,0x80,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch13 = {5,6,-3,2,8,ch13data};
-
-/* char: 0xc */
-
-static const GLubyte ch12data[] = {
-0x10,0x10,0x10,0x10,0x10,0xf0,
-};
-
-static const BitmapCharRec ch12 = {4,6,0,2,8,ch12data};
-
-/* char: 0xb */
-
-static const GLubyte ch11data[] = {
-0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch11 = {4,8,0,-3,8,ch11data};
-
-/* char: 0xa */
-
-static const GLubyte ch10data[] = {
-0x8,0x8,0x8,0x8,0x3e,0x20,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch10 = {7,9,0,2,8,ch10data};
-
-/* char: 0x9 */
-
-static const GLubyte ch9data[] = {
-0x3e,0x20,0x20,0x20,0x88,0x98,0xa8,0xc8,0x88,
-};
-
-static const BitmapCharRec ch9 = {7,9,0,2,8,ch9data};
-
-/* char: 0x8 */
-
-static const GLubyte ch8data[] = {
-0xfe,0x10,0x10,0xfe,0x10,0x10,
-};
-
-static const BitmapCharRec ch8 = {7,6,0,0,8,ch8data};
-
-/* char: 0x7 */
-
-static const GLubyte ch7data[] = {
-0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch7 = {5,4,-1,-5,8,ch7data};
-
-/* char: 0x6 */
-
-static const GLubyte ch6data[] = {
-0x20,0x20,0x3c,0x20,0x3e,0xf8,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch6 = {7,9,0,2,8,ch6data};
-
-/* char: 0x5 */
-
-static const GLubyte ch5data[] = {
-0x22,0x22,0x3c,0x22,0x3c,0x78,0x80,0x80,0x78,
-};
-
-static const BitmapCharRec ch5 = {7,9,0,2,8,ch5data};
-
-/* char: 0x4 */
-
-static const GLubyte ch4data[] = {
-0x10,0x10,0x1c,0x10,0x9e,0x80,0xe0,0x80,0xf0,
-};
-
-static const BitmapCharRec ch4 = {7,9,0,2,8,ch4data};
-
-/* char: 0x3 */
-
-static const GLubyte ch3data[] = {
-0x8,0x8,0x8,0x3e,0x88,0x88,0xf8,0x88,0x88,
-};
-
-static const BitmapCharRec ch3 = {7,9,0,2,8,ch3data};
-
-/* char: 0x2 */
-
-static const GLubyte ch2data[] = {
-0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,
-};
-
-static const BitmapCharRec ch2 = {8,12,0,2,8,ch2data};
-
-/* char: 0x1 */
-
-static const GLubyte ch1data[] = {
-0x10,0x38,0x7c,0xfe,0x7c,0x38,0x10,
-};
-
-static const BitmapCharRec ch1 = {7,7,0,-1,8,ch1data};
-
-static const BitmapCharRec * const chars[] = {
-&ch0,
-&ch1,
-&ch2,
-&ch3,
-&ch4,
-&ch5,
-&ch6,
-&ch7,
-&ch8,
-&ch9,
-&ch10,
-&ch11,
-&ch12,
-&ch13,
-&ch14,
-&ch15,
-&ch16,
-&ch17,
-&ch18,
-&ch19,
-&ch20,
-&ch21,
-&ch22,
-&ch23,
-&ch24,
-&ch25,
-&ch26,
-&ch27,
-&ch28,
-&ch29,
-&ch30,
-&ch31,
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-&ch127,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-GLUTAPI const BitmapFontRec glutBitmap8By13;
-const BitmapFontRec glutBitmap8By13 = {
-"-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1",
-256,
-0,
-chars
-};
-
diff --git a/src/glut/glx/glut_9x15.c b/src/glut/glx/glut_9x15.c
deleted file mode 100644 (file)
index 7dbec12..0000000
+++ /dev/null
@@ -1,2076 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmap9By15 XXX
-#include "glutbitmap.h"
-#undef glutBitmap9By15
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch0data[] = { 0x0 };
-static const BitmapCharRec ch0 = {1,1,0,0,9,ch0data};
-#else
-static const BitmapCharRec ch0 = {0,0,0,0,9,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,9,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,9,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch127data[] = { 0x0 };
-static const BitmapCharRec ch127 = {1,1,0,0,9,ch127data};
-#else
-static const BitmapCharRec ch127 = {0,0,0,0,9,0};
-#endif
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,9,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,9,0};
-#endif
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch255 = {6,14,-1,3,9,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0x80,0x80,0x80,0xbc,0xc2,0x82,0x82,0x82,0xc2,0xbc,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {7,12,-1,3,9,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch253 = {6,14,-1,3,9,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch252 = {7,11,-1,0,9,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch251 = {7,11,-1,0,9,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch250 = {7,11,-1,0,9,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch249 = {7,11,-1,0,9,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0x80,0x7c,0xa2,0xa2,0x92,0x8a,0x8a,0x7c,0x2,
-};
-
-static const BitmapCharRec ch248 = {7,9,-1,1,9,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x10,0x38,0x10,0x0,0xfe,0x0,0x10,0x38,0x10,
-};
-
-static const BitmapCharRec ch247 = {7,9,-1,0,9,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch246 = {7,11,-1,0,9,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch245 = {7,11,-1,0,9,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch244 = {7,11,-1,0,9,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch243 = {7,11,-1,0,9,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch242 = {7,11,-1,0,9,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0x82,0x82,0x82,0x82,0x82,0xc2,0xbc,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch241 = {7,11,-1,0,9,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x8,0x50,0x30,0x48,
-};
-
-static const BitmapCharRec ch240 = {7,11,-1,0,9,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x50,0x50,
-};
-
-static const BitmapCharRec ch239 = {5,11,-2,0,9,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x90,0x60,
-};
-
-static const BitmapCharRec ch238 = {5,11,-2,0,9,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x60,0x10,
-};
-
-static const BitmapCharRec ch237 = {5,11,-2,0,9,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x30,0x40,
-};
-
-static const BitmapCharRec ch236 = {5,11,-2,0,9,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch235 = {7,11,-1,0,9,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,0x0,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch234 = {7,11,-1,0,9,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch233 = {7,11,-1,0,9,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,0x0,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch232 = {7,11,-1,0,9,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x30,0x48,0x18,0x7c,0x82,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch231 = {7,10,-1,3,9,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x6e,0x92,0x90,0x7c,0x12,0x92,0x6c,
-};
-
-static const BitmapCharRec ch230 = {7,7,-1,0,9,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x18,0x24,0x18,
-};
-
-static const BitmapCharRec ch229 = {7,11,-1,0,9,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch228 = {7,11,-1,0,9,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch227 = {7,11,-1,0,9,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch226 = {7,11,-1,0,9,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch225 = {7,11,-1,0,9,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,0x0,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch224 = {7,11,-1,0,9,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0x80,0xbc,0xc2,0x82,0x82,0xfc,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch223 = {7,9,-1,1,9,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0x80,0x80,0x80,0xfc,0x82,0x82,0x82,0xfc,0x80,0x80,
-};
-
-static const BitmapCharRec ch222 = {7,10,-1,0,9,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x10,0x10,0x10,0x10,0x28,0x44,0x82,0x82,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch221 = {7,11,-1,0,9,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch220 = {7,11,-1,0,9,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch219 = {7,11,-1,0,9,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch218 = {7,11,-1,0,9,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch217 = {7,11,-1,0,9,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x7c,0xc2,0xa2,0xa2,0x92,0x92,0x8a,0x8a,0x86,0x7c,0x2,
-};
-
-static const BitmapCharRec ch216 = {7,12,-1,1,9,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x82,0x44,0x28,0x10,0x28,0x44,0x82,
-};
-
-static const BitmapCharRec ch215 = {7,7,-1,-1,9,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch214 = {7,11,-1,0,9,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch213 = {7,11,-1,0,9,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch212 = {7,11,-1,0,9,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch211 = {7,11,-1,0,9,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch210 = {7,11,-1,0,9,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0x82,0x86,0x8a,0x92,0x92,0xa2,0xc2,0x82,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch209 = {7,11,-1,0,9,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0xfc,0x42,0x42,0x42,0x42,0xf2,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch208 = {7,10,-1,0,9,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x50,0x50,
-};
-
-static const BitmapCharRec ch207 = {5,11,-2,0,9,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x88,0x70,
-};
-
-static const BitmapCharRec ch206 = {5,11,-2,0,9,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x60,0x10,
-};
-
-static const BitmapCharRec ch205 = {5,11,-2,0,9,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,0x0,0x30,0x40,
-};
-
-static const BitmapCharRec ch204 = {5,11,-2,0,9,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xfe,0x40,0x40,0x40,0x78,0x40,0x40,0xfe,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch203 = {7,11,-1,0,9,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xfe,0x40,0x40,0x40,0x78,0x40,0x40,0xfe,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch202 = {7,11,-1,0,9,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xfe,0x40,0x40,0x40,0x78,0x40,0x40,0xfe,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch201 = {7,11,-1,0,9,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xfe,0x40,0x40,0x40,0x78,0x40,0x40,0xfe,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch200 = {7,11,-1,0,9,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x30,0x48,0x18,0x7c,0x82,0x80,0x80,0x80,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch199 = {7,13,-1,3,9,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0x9e,0x90,0x90,0x90,0xfc,0x90,0x90,0x90,0x90,0x6e,
-};
-
-static const BitmapCharRec ch198 = {7,10,-1,0,9,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x10,0x28,0x10,
-};
-
-static const BitmapCharRec ch197 = {7,11,-1,0,9,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x28,0x28,
-};
-
-static const BitmapCharRec ch196 = {7,11,-1,0,9,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch195 = {7,11,-1,0,9,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x44,0x38,
-};
-
-static const BitmapCharRec ch194 = {7,11,-1,0,9,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x30,0x8,
-};
-
-static const BitmapCharRec ch193 = {7,11,-1,0,9,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x44,0x38,0x0,0x18,0x20,
-};
-
-static const BitmapCharRec ch192 = {7,11,-1,0,9,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x7c,0x82,0x82,0x80,0x40,0x20,0x10,0x10,0x0,0x10,
-};
-
-static const BitmapCharRec ch191 = {7,10,-1,0,9,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x6,0x1a,0x12,0xa,0x66,0x92,0x10,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch190 = {7,10,-1,0,9,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x1e,0x10,0xc,0x2,0xf2,0x4c,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch189 = {7,10,-1,0,9,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x6,0x1a,0x12,0xa,0xe6,0x42,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch188 = {7,10,-1,0,9,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0x90,0x48,0x24,0x12,0x12,0x24,0x48,0x90,
-};
-
-static const BitmapCharRec ch187 = {7,8,-1,-1,9,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xf8,0x0,0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch186 = {5,6,-1,-5,9,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {3,6,-1,-4,9,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0x60,0x90,0x30,
-};
-
-static const BitmapCharRec ch184 = {4,3,-2,3,9,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,2,-4,-4,9,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0xa,0xa,0xa,0xa,0xa,0x7a,0x8a,0x8a,0x8a,0x7e,
-};
-
-static const BitmapCharRec ch182 = {7,10,-1,0,9,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0x80,0xba,0xc6,0x82,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch181 = {7,9,-1,2,9,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0xc0,0x20,
-};
-
-static const BitmapCharRec ch180 = {3,2,-3,-9,9,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0x60,0x90,0x10,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch179 = {4,6,-1,-4,9,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xf0,0x80,0x60,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch178 = {4,6,-1,-4,9,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xfe,0x0,0x10,0x10,0x10,0xfe,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch177 = {7,9,-1,-1,9,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,-3,-6,9,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch175 = {6,1,-1,-9,9,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x3c,0x42,0xa5,0xa9,0xbd,0xa5,0xb9,0x42,0x3c,
-};
-
-static const BitmapCharRec ch174 = {8,9,0,-1,9,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch173 = {6,1,-1,-4,9,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x4,0x4,0x4,0xfc,
-};
-
-static const BitmapCharRec ch172 = {6,4,-1,-2,9,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x12,0x24,0x48,0x90,0x90,0x48,0x24,0x12,
-};
-
-static const BitmapCharRec ch171 = {7,8,-1,-1,9,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xf8,0x0,0x78,0x90,0x70,0x90,0x60,
-};
-
-static const BitmapCharRec ch170 = {5,7,-3,-3,9,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x3c,0x42,0x99,0xa5,0xa1,0xa5,0x99,0x42,0x3c,
-};
-
-static const BitmapCharRec ch169 = {8,9,0,-1,9,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xa0,0xa0,
-};
-
-static const BitmapCharRec ch168 = {3,2,-3,-9,9,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x70,0x88,0x8,0x70,0x88,0x88,0x88,0x70,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch167 = {5,11,-2,1,9,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,11,-4,1,9,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x10,0x10,0x10,0x7c,0x10,0x7c,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch165 = {7,10,-1,0,9,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x82,0x7c,0x44,0x44,0x7c,0x82,
-};
-
-static const BitmapCharRec ch164 = {7,6,-1,-3,9,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0x5c,0xa2,0x60,0x20,0x20,0xf8,0x20,0x20,0x22,0x1c,
-};
-
-static const BitmapCharRec ch163 = {7,10,-1,0,9,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x40,0x78,0xa4,0xa0,0x90,0x94,0x78,0x8,
-};
-
-static const BitmapCharRec ch162 = {6,8,-1,0,9,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x80,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,11,-4,0,9,ch161data};
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x8c,0x92,0x62,
-};
-
-static const BitmapCharRec ch126 = {7,3,-1,-7,9,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xe0,0x10,0x10,0x10,0x20,0x18,0x18,0x20,0x10,0x10,0x10,0xe0,
-};
-
-static const BitmapCharRec ch125 = {5,12,-1,1,9,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,12,-4,1,9,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x38,0x40,0x40,0x40,0x20,0xc0,0xc0,0x20,0x40,0x40,0x40,0x38,
-};
-
-static const BitmapCharRec ch123 = {5,12,-3,1,9,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xfe,0x40,0x20,0x10,0x8,0x4,0xfe,
-};
-
-static const BitmapCharRec ch122 = {7,7,-1,0,9,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x78,0x84,0x4,0x74,0x8c,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch121 = {6,10,-1,3,9,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0x82,0x44,0x28,0x10,0x28,0x44,0x82,
-};
-
-static const BitmapCharRec ch120 = {7,7,-1,0,9,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x44,0xaa,0x92,0x92,0x92,0x82,0x82,
-};
-
-static const BitmapCharRec ch119 = {7,7,-1,0,9,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x10,0x28,0x28,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch118 = {7,7,-1,0,9,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x7a,0x84,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch117 = {7,7,-1,0,9,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x1c,0x22,0x20,0x20,0x20,0x20,0xfc,0x20,0x20,
-};
-
-static const BitmapCharRec ch116 = {7,9,-1,0,9,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x7c,0x82,0x2,0x7c,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch115 = {7,7,-1,0,9,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0x40,0x40,0x40,0x40,0x42,0x62,0x9c,
-};
-
-static const BitmapCharRec ch114 = {7,7,-1,0,9,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x2,0x2,0x2,0x7a,0x86,0x82,0x82,0x82,0x86,0x7a,
-};
-
-static const BitmapCharRec ch113 = {7,10,-1,3,9,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0x80,0x80,0x80,0xbc,0xc2,0x82,0x82,0x82,0xc2,0xbc,
-};
-
-static const BitmapCharRec ch112 = {7,10,-1,3,9,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch111 = {7,7,-1,0,9,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0x82,0x82,0x82,0x82,0x82,0xc2,0xbc,
-};
-
-static const BitmapCharRec ch110 = {7,7,-1,0,9,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0x82,0x92,0x92,0x92,0x92,0x92,0xec,
-};
-
-static const BitmapCharRec ch109 = {7,7,-1,0,9,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xe0,
-};
-
-static const BitmapCharRec ch108 = {5,10,-2,0,9,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x82,0x8c,0xb0,0xc0,0xb0,0x8c,0x82,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {7,10,-1,0,9,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x78,0x84,0x84,0x84,0x4,0x4,0x4,0x4,0x4,0x1c,0x0,0x0,0xc,
-};
-
-static const BitmapCharRec ch106 = {6,13,-1,3,9,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x60,
-};
-
-static const BitmapCharRec ch105 = {5,10,-2,0,9,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0x82,0x82,0x82,0x82,0x82,0xc2,0xbc,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {7,10,-1,0,9,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x7c,0x82,0x82,0x7c,0x80,0x78,0x84,0x84,0x84,0x7a,
-};
-
-static const BitmapCharRec ch103 = {7,10,-1,3,9,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x20,0x20,0x20,0x20,0xf8,0x20,0x20,0x22,0x22,0x1c,
-};
-
-static const BitmapCharRec ch102 = {7,10,-1,0,9,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x7c,0x80,0x80,0xfe,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch101 = {7,7,-1,0,9,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x7a,0x86,0x82,0x82,0x82,0x86,0x7a,0x2,0x2,0x2,
-};
-
-static const BitmapCharRec ch100 = {7,10,-1,0,9,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x7c,0x82,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch99 = {7,7,-1,0,9,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xbc,0xc2,0x82,0x82,0x82,0xc2,0xbc,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {7,10,-1,0,9,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x7a,0x86,0x82,0x7e,0x2,0x2,0x7c,
-};
-
-static const BitmapCharRec ch97 = {7,7,-1,0,9,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0x10,0x20,0x40,0xc0,
-};
-
-static const BitmapCharRec ch96 = {4,4,-3,-6,9,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xff,
-};
-
-static const BitmapCharRec ch95 = {8,1,0,1,9,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x82,0x44,0x28,0x10,
-};
-
-static const BitmapCharRec ch94 = {7,4,-1,-6,9,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xf0,
-};
-
-static const BitmapCharRec ch93 = {4,12,-2,1,9,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x2,0x4,0x4,0x8,0x10,0x10,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch92 = {7,10,-1,0,9,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xf0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xf0,
-};
-
-static const BitmapCharRec ch91 = {4,12,-3,1,9,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xfe,0x80,0x80,0x40,0x20,0x10,0x8,0x4,0x2,0xfe,
-};
-
-static const BitmapCharRec ch90 = {7,10,-1,0,9,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x10,0x10,0x10,0x10,0x10,0x10,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch89 = {7,10,-1,0,9,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0x82,0x82,0x44,0x28,0x10,0x10,0x28,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch88 = {7,10,-1,0,9,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x44,0xaa,0x92,0x92,0x92,0x92,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch87 = {7,10,-1,0,9,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x28,0x28,0x28,0x44,0x44,0x44,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch86 = {7,10,-1,0,9,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch85 = {7,10,-1,0,9,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xfe,
-};
-
-static const BitmapCharRec ch84 = {7,10,-1,0,9,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x7c,0x82,0x82,0x2,0xc,0x70,0x80,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch83 = {7,10,-1,0,9,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0x82,0x82,0x84,0x88,0x90,0xfc,0x82,0x82,0x82,0xfc,
-};
-
-static const BitmapCharRec ch82 = {7,10,-1,0,9,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x6,0x8,0x7c,0x92,0xa2,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch81 = {7,12,-1,2,9,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0x80,0x80,0x80,0x80,0x80,0xfc,0x82,0x82,0x82,0xfc,
-};
-
-static const BitmapCharRec ch80 = {7,10,-1,0,9,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch79 = {7,10,-1,0,9,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0x82,0x82,0x82,0x86,0x8a,0x92,0xa2,0xc2,0x82,0x82,
-};
-
-static const BitmapCharRec ch78 = {7,10,-1,0,9,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0x82,0x82,0x82,0x92,0x92,0xaa,0xaa,0xc6,0x82,0x82,
-};
-
-static const BitmapCharRec ch77 = {7,10,-1,0,9,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xfe,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch76 = {7,10,-1,0,9,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0x82,0x84,0x88,0x90,0xa0,0xe0,0x90,0x88,0x84,0x82,
-};
-
-static const BitmapCharRec ch75 = {7,10,-1,0,9,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x78,0x84,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x1e,
-};
-
-static const BitmapCharRec ch74 = {7,10,-1,0,9,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,
-};
-
-static const BitmapCharRec ch73 = {5,10,-2,0,9,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0x82,0x82,0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch72 = {7,10,-1,0,9,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x7c,0x82,0x82,0x82,0x8e,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch71 = {7,10,-1,0,9,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0x40,0x40,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0xfe,
-};
-
-static const BitmapCharRec ch70 = {7,10,-1,0,9,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xfe,0x40,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0xfe,
-};
-
-static const BitmapCharRec ch69 = {7,10,-1,0,9,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xfc,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch68 = {7,10,-1,0,9,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x7c,0x82,0x80,0x80,0x80,0x80,0x80,0x80,0x82,0x7c,
-};
-
-static const BitmapCharRec ch67 = {7,10,-1,0,9,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xfc,0x42,0x42,0x42,0x42,0x7c,0x42,0x42,0x42,0xfc,
-};
-
-static const BitmapCharRec ch66 = {7,10,-1,0,9,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x44,0x28,0x10,
-};
-
-static const BitmapCharRec ch65 = {7,10,-1,0,9,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x7c,0x80,0x80,0x9a,0xa6,0xa2,0x9e,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch64 = {7,10,-1,0,9,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x10,0x0,0x10,0x10,0x8,0x4,0x2,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch63 = {7,10,-1,0,9,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0x80,0x40,0x20,0x10,0x8,0x8,0x10,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch62 = {5,10,-2,0,9,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xfe,0x0,0x0,0xfe,
-};
-
-static const BitmapCharRec ch61 = {7,4,-1,-2,9,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x8,0x10,0x20,0x40,0x80,0x80,0x40,0x20,0x10,0x8,
-};
-
-static const BitmapCharRec ch60 = {5,10,-2,0,9,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x40,0x40,0xc0,0xc0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch59 = {2,10,-4,3,9,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0xc0,0xc0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch58 = {2,7,-4,0,9,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x78,0x4,0x2,0x2,0x7a,0x86,0x82,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch57 = {7,10,-1,0,9,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x38,0x44,0x82,0x82,0x44,0x38,0x44,0x82,0x44,0x38,
-};
-
-static const BitmapCharRec ch56 = {7,10,-1,0,9,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x20,0x20,0x10,0x8,0x4,0x2,0x2,0xfe,
-};
-
-static const BitmapCharRec ch55 = {7,10,-1,0,9,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x7c,0x82,0x82,0x82,0xc2,0xbc,0x80,0x80,0x40,0x3c,
-};
-
-static const BitmapCharRec ch54 = {7,10,-1,0,9,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x7c,0x82,0x2,0x2,0x2,0xc2,0xbc,0x80,0x80,0xfe,
-};
-
-static const BitmapCharRec ch53 = {7,10,-1,0,9,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x4,0x4,0x4,0xfe,0x84,0x44,0x24,0x14,0xc,0x4,
-};
-
-static const BitmapCharRec ch52 = {7,10,-1,0,9,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x7c,0x82,0x2,0x2,0x2,0x1c,0x8,0x4,0x2,0xfe,
-};
-
-static const BitmapCharRec ch51 = {7,10,-1,0,9,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xfe,0x80,0x40,0x30,0x8,0x4,0x2,0x82,0x82,0x7c,
-};
-
-static const BitmapCharRec ch50 = {7,10,-1,0,9,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0xfe,0x10,0x10,0x10,0x10,0x10,0x90,0x50,0x30,0x10,
-};
-
-static const BitmapCharRec ch49 = {7,10,-1,0,9,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x38,
-};
-
-static const BitmapCharRec ch48 = {7,10,-1,0,9,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x40,0x40,0x20,0x10,0x10,0x8,0x4,0x4,0x2,
-};
-
-static const BitmapCharRec ch47 = {7,10,-1,0,9,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch46 = {2,2,-4,0,9,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xfe,
-};
-
-static const BitmapCharRec ch45 = {7,1,-1,-4,9,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x40,0x40,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch44 = {2,5,-4,3,9,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x10,0x10,0x10,0xfe,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch43 = {7,7,-1,-1,9,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0x10,0x92,0x54,0x38,0x54,0x92,0x10,
-};
-
-static const BitmapCharRec ch42 = {7,7,-1,-1,9,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,12,-3,1,9,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,12,-3,1,9,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x40,0x20,0x30,
-};
-
-static const BitmapCharRec ch39 = {4,4,-3,-6,9,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x62,0x94,0x88,0x94,0x62,0x60,0x90,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch38 = {7,10,-1,0,9,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x84,0x4a,0x4a,0x24,0x10,0x10,0x48,0xa4,0xa4,0x42,
-};
-
-static const BitmapCharRec ch37 = {7,10,-1,0,9,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x10,0x7c,0x92,0x12,0x12,0x14,0x38,0x50,0x90,0x92,0x7c,0x10,
-};
-
-static const BitmapCharRec ch36 = {7,12,-1,1,9,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x48,0x48,0xfc,0x48,0x48,0xfc,0x48,0x48,
-};
-
-static const BitmapCharRec ch35 = {6,8,-1,-1,9,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch34 = {4,3,-3,-7,9,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x80,0x0,0x0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,11,-4,0,9,ch33data};
-
-/* char: 0x1f */
-
-static const GLubyte ch31data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch31 = {2,2,-4,-2,9,ch31data};
-
-/* char: 0x1e */
-
-static const GLubyte ch30data[] = {
-0x5c,0xa2,0x60,0x20,0x20,0xf8,0x20,0x20,0x22,0x1c,
-};
-
-static const BitmapCharRec ch30 = {7,10,-1,0,9,ch30data};
-
-/* char: 0x1d */
-
-static const GLubyte ch29data[] = {
-0x80,0x40,0xfe,0x10,0xfe,0x4,0x2,
-};
-
-static const BitmapCharRec ch29 = {7,7,-1,0,9,ch29data};
-
-/* char: 0x1c */
-
-static const GLubyte ch28data[] = {
-0x44,0x24,0x24,0x24,0x24,0x24,0xfe,
-};
-
-static const BitmapCharRec ch28 = {7,7,-1,0,9,ch28data};
-
-/* char: 0x1b */
-
-static const GLubyte ch27data[] = {
-0xfe,0x0,0x80,0x40,0x20,0x10,0x8,0x8,0x10,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch27 = {7,12,-1,2,9,ch27data};
-
-/* char: 0x1a */
-
-static const GLubyte ch26data[] = {
-0xfc,0x0,0x4,0x8,0x10,0x20,0x40,0x40,0x20,0x10,0x8,0x4,
-};
-
-static const BitmapCharRec ch26 = {6,12,-2,2,9,ch26data};
-
-/* char: 0x19 */
-
-static const GLubyte ch25data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch25 = {1,15,-4,3,9,ch25data};
-
-/* char: 0x18 */
-
-static const GLubyte ch24data[] = {
-0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0xff,0x80,
-};
-
-static const BitmapCharRec ch24 = {9,7,0,3,9,ch24data};
-
-/* char: 0x17 */
-
-static const GLubyte ch23data[] = {
-0xff,0x80,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,
-0x8,0x0,
-};
-
-static const BitmapCharRec ch23 = {9,9,0,-3,9,ch23data};
-
-/* char: 0x16 */
-
-static const GLubyte ch22data[] = {
-0x8,0x8,0x8,0x8,0x8,0x8,0xf8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,
-};
-
-static const BitmapCharRec ch22 = {5,15,0,3,9,ch22data};
-
-/* char: 0x15 */
-
-static const GLubyte ch21data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch21 = {5,15,-4,3,9,ch21data};
-
-/* char: 0x14 */
-
-static const GLubyte ch20data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch20 = {9,1,0,1,9,ch20data};
-
-/* char: 0x13 */
-
-static const GLubyte ch19data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch19 = {9,1,0,-1,9,ch19data};
-
-/* char: 0x12 */
-
-static const GLubyte ch18data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch18 = {9,1,0,-3,9,ch18data};
-
-/* char: 0x11 */
-
-static const GLubyte ch17data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch17 = {9,1,0,-5,9,ch17data};
-
-/* char: 0x10 */
-
-static const GLubyte ch16data[] = {
-0xff,0x80,
-};
-
-static const BitmapCharRec ch16 = {9,1,0,-7,9,ch16data};
-
-/* char: 0xf */
-
-static const GLubyte ch15data[] = {
-0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0xff,0x80,0x8,0x0,
-0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,0x8,0x0,
-};
-
-static const BitmapCharRec ch15 = {9,15,0,3,9,ch15data};
-
-/* char: 0xe */
-
-static const GLubyte ch14data[] = {
-0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch14 = {5,9,-4,-3,9,ch14data};
-
-/* char: 0xd */
-
-static const GLubyte ch13data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch13 = {5,7,-4,3,9,ch13data};
-
-/* char: 0xc */
-
-static const GLubyte ch12data[] = {
-0x8,0x8,0x8,0x8,0x8,0x8,0xf8,
-};
-
-static const BitmapCharRec ch12 = {5,7,0,3,9,ch12data};
-
-/* char: 0xb */
-
-static const GLubyte ch11data[] = {
-0xf8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,
-};
-
-static const BitmapCharRec ch11 = {5,9,0,-3,9,ch11data};
-
-/* char: 0xa */
-
-static const GLubyte ch10data[] = {
-0x8,0x8,0x8,0x8,0x3e,0x0,0x20,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch10 = {7,10,-1,2,9,ch10data};
-
-/* char: 0x9 */
-
-static const GLubyte ch9data[] = {
-0x3e,0x20,0x20,0x20,0x20,0x88,0x98,0xa8,0xc8,0x88,
-};
-
-static const BitmapCharRec ch9 = {7,10,-1,2,9,ch9data};
-
-/* char: 0x8 */
-
-static const GLubyte ch8data[] = {
-0xfe,0x10,0x10,0xfe,0x10,0x10,
-};
-
-static const BitmapCharRec ch8 = {7,6,-1,0,9,ch8data};
-
-/* char: 0x7 */
-
-static const GLubyte ch7data[] = {
-0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch7 = {5,4,-2,-6,9,ch7data};
-
-/* char: 0x6 */
-
-static const GLubyte ch6data[] = {
-0x20,0x20,0x3c,0x20,0x3e,0x0,0xf8,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch6 = {7,10,-1,2,9,ch6data};
-
-/* char: 0x5 */
-
-static const GLubyte ch5data[] = {
-0x22,0x22,0x3c,0x22,0x3c,0x0,0x78,0x80,0x80,0x78,
-};
-
-static const BitmapCharRec ch5 = {7,10,-1,2,9,ch5data};
-
-/* char: 0x4 */
-
-static const GLubyte ch4data[] = {
-0x10,0x10,0x1c,0x10,0x1e,0x80,0x80,0xe0,0x80,0xf0,
-};
-
-static const BitmapCharRec ch4 = {7,10,-1,2,9,ch4data};
-
-/* char: 0x3 */
-
-static const GLubyte ch3data[] = {
-0x8,0x8,0x8,0x3e,0x0,0x88,0x88,0xf8,0x88,0x88,
-};
-
-static const BitmapCharRec ch3 = {7,10,-1,2,9,ch3data};
-
-/* char: 0x2 */
-
-static const GLubyte ch2data[] = {
-0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,
-};
-
-static const BitmapCharRec ch2 = {8,14,0,3,9,ch2data};
-
-/* char: 0x1 */
-
-static const GLubyte ch1data[] = {
-0x10,0x38,0x7c,0xfe,0x7c,0x38,0x10,
-};
-
-static const BitmapCharRec ch1 = {7,7,-1,0,9,ch1data};
-
-static const BitmapCharRec * const chars[] = {
-&ch0,
-&ch1,
-&ch2,
-&ch3,
-&ch4,
-&ch5,
-&ch6,
-&ch7,
-&ch8,
-&ch9,
-&ch10,
-&ch11,
-&ch12,
-&ch13,
-&ch14,
-&ch15,
-&ch16,
-&ch17,
-&ch18,
-&ch19,
-&ch20,
-&ch21,
-&ch22,
-&ch23,
-&ch24,
-&ch25,
-&ch26,
-&ch27,
-&ch28,
-&ch29,
-&ch30,
-&ch31,
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-&ch127,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-GLUTAPI const BitmapFontRec glutBitmap9By15;
-const BitmapFontRec glutBitmap9By15 = {
-"-misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1",
-256,
-0,
-chars
-};
-
diff --git a/src/glut/glx/glut_bitmap.c b/src/glut/glx/glut_bitmap.c
deleted file mode 100644 (file)
index 8fec7f1..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-#include "glutbitmap.h"
-
-void GLUTAPIENTRY 
-glutBitmapCharacter(GLUTbitmapFont font, int c)
-{
-  const BitmapCharRec *ch;
-  BitmapFontPtr fontinfo;
-  GLint swapbytes, lsbfirst, rowlength;
-  GLint skiprows, skippixels, alignment;
-
-#if defined(_WIN32) || defined(GLUT_IMPORT_LIB)
-  fontinfo = (BitmapFontPtr) __glutFont(font);
-#else
-  fontinfo = (BitmapFontPtr) font;
-#endif
-
-  if (c < fontinfo->first ||
-    c >= fontinfo->first + fontinfo->num_chars)
-    return;
-  ch = fontinfo->ch[c - fontinfo->first];
-  if (ch) {
-    /* Save current modes. */
-    glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
-    glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
-    glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
-    glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
-    glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
-    glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
-    /* Little endian machines (DEC Alpha for example) could
-       benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
-       instead of GL_FALSE, but this would require changing the
-       generated bitmaps too. */
-    glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
-    glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
-    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
-    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
-    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
-      ch->advance, 0, ch->bitmap);
-    /* Restore saved modes. */
-    glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
-    glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
-    glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
-    glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
-    glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
-    glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
-  }
-}
diff --git a/src/glut/glx/glut_bwidth.c b/src/glut/glx/glut_bwidth.c
deleted file mode 100644 (file)
index f9cdb18..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-#include "glutbitmap.h"
-
-/* CENTRY */
-int GLUTAPIENTRY 
-glutBitmapWidth(GLUTbitmapFont font, int c)
-{
-  BitmapFontPtr fontinfo;
-  const BitmapCharRec *ch;
-
-#if defined(_WIN32) || defined(GLUT_IMPORT_LIB)
-  fontinfo = (BitmapFontPtr) __glutFont(font);
-#else
-  fontinfo = (BitmapFontPtr) font;
-#endif
-
-  if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars)
-    return 0;
-  ch = fontinfo->ch[c - fontinfo->first];
-  if (ch)
-    return ch->advance;
-  else
-    return 0;
-}
-
-int GLUTAPIENTRY 
-glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
-{
-  int c, length;
-  BitmapFontPtr fontinfo;
-  const BitmapCharRec *ch;
-
-#if defined(_WIN32) || defined(GLUT_IMPORT_LIB)
-  fontinfo = (BitmapFontPtr) __glutFont(font);
-#else
-  fontinfo = (BitmapFontPtr) font;
-#endif
-
-  length = 0;
-  for (; *string != '\0'; string++) {
-    c = *string;
-    if (c >= fontinfo->first && c < fontinfo->first + fontinfo->num_chars) {
-      ch = fontinfo->ch[c - fontinfo->first];
-      if (ch)
-        length += ch->advance;
-    }
-  }
-  return length;
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_cindex.c b/src/glut/glx/glut_cindex.c
deleted file mode 100644 (file)
index d0c12bf..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1996, 1997. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-#include "glutint.h"
-
-#define CLAMP(i) ((i) > 1.0 ? 1.0 : ((i) < 0.0 ? 0.0 : (i)))
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutSetColor(int ndx, GLfloat red, GLfloat green, GLfloat blue)
-{
-  GLUTcolormap *cmap, *newcmap;
-  XVisualInfo *vis;
-  XColor color;
-  int i;
-
-  if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
-    cmap = __glutCurrentWindow->colormap;
-    vis = __glutCurrentWindow->vis;
-  } else {
-    cmap = __glutCurrentWindow->overlay->colormap;
-    vis = __glutCurrentWindow->overlay->vis;
-    if (ndx == __glutCurrentWindow->overlay->transparentPixel) {
-      __glutWarning(
-        "glutSetColor: cannot set color of overlay transparent index %d\n",
-        ndx);
-      return;
-    }
-  }
-
-  if (!cmap) {
-    __glutWarning("glutSetColor: current window is RGBA");
-    return;
-  }
-#if defined(_WIN32)
-  if (ndx >= 256 ||     /* always assume 256 colors on Win32 */
-#else
-  if (ndx >= vis->visual->map_entries ||
-#endif
-    ndx < 0) {
-    __glutWarning("glutSetColor: index %d out of range", ndx);
-    return;
-  }
-  if (cmap->refcnt > 1) {
-    newcmap = __glutAssociateNewColormap(vis);
-    cmap->refcnt--;
-    /* Wouldn't it be nice if XCopyColormapAndFree could be
-       told not to free the old colormap's entries! */
-    for (i = cmap->size - 1; i >= 0; i--) {
-      if (i == ndx) {
-        /* We are going to set this cell shortly! */
-        continue;
-      }
-      if (cmap->cells[i].component[GLUT_RED] >= 0.0) {
-        color.pixel = i;
-        newcmap->cells[i].component[GLUT_RED] =
-          cmap->cells[i].component[GLUT_RED];
-        color.red = (GLfloat) 0xffff *
-          cmap->cells[i].component[GLUT_RED];
-        newcmap->cells[i].component[GLUT_GREEN] =
-          cmap->cells[i].component[GLUT_GREEN];
-        color.green = (GLfloat) 0xffff *
-          cmap->cells[i].component[GLUT_GREEN];
-        newcmap->cells[i].component[GLUT_BLUE] =
-          cmap->cells[i].component[GLUT_BLUE];
-        color.blue = (GLfloat) 0xffff *
-          cmap->cells[i].component[GLUT_BLUE];
-        color.flags = DoRed | DoGreen | DoBlue;
-#if defined(_WIN32)
-        if (IsWindowVisible(__glutCurrentWindow->win)) {
-          XHDC = __glutCurrentWindow->hdc;
-        } else {
-          XHDC = 0;
-        }
-#endif
-        XStoreColor(__glutDisplay, newcmap->cmap, &color);
-      } else {
-        /* Leave unallocated entries unallocated. */
-      }
-    }
-    cmap = newcmap;
-    if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
-      __glutCurrentWindow->colormap = cmap;
-      __glutCurrentWindow->cmap = cmap->cmap;
-    } else {
-      __glutCurrentWindow->overlay->colormap = cmap;
-      __glutCurrentWindow->overlay->cmap = cmap->cmap;
-    }
-    XSetWindowColormap(__glutDisplay,
-      __glutCurrentWindow->renderWin, cmap->cmap);
-
-#if !defined(_WIN32)
-    {
-      GLUTwindow *toplevel;
-
-      toplevel = __glutToplevelOf(__glutCurrentWindow);
-      if (toplevel->cmap != cmap->cmap) {
-        __glutPutOnWorkList(toplevel, GLUT_COLORMAP_WORK);
-      }
-    }
-#endif
-  }
-  color.pixel = ndx;
-  red = CLAMP(red);
-  cmap->cells[ndx].component[GLUT_RED] = red;
-  color.red = (GLfloat) 0xffff *red;
-  green = CLAMP(green);
-  cmap->cells[ndx].component[GLUT_GREEN] = green;
-  color.green = (GLfloat) 0xffff *green;
-  blue = CLAMP(blue);
-  cmap->cells[ndx].component[GLUT_BLUE] = blue;
-  color.blue = (GLfloat) 0xffff *blue;
-  color.flags = DoRed | DoGreen | DoBlue;
-#if defined(_WIN32)
-  if (IsWindowVisible(__glutCurrentWindow->win)) {
-    XHDC = __glutCurrentWindow->hdc;
-  } else {
-    XHDC = 0;
-  }
-#endif
-  XStoreColor(__glutDisplay, cmap->cmap, &color);
-}
-
-GLfloat GLUTAPIENTRY
-glutGetColor(int ndx, int comp)
-{
-  GLUTcolormap *colormap;
-  XVisualInfo *vis;
-
-  if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
-    colormap = __glutCurrentWindow->colormap;
-    vis = __glutCurrentWindow->vis;
-  } else {
-    colormap = __glutCurrentWindow->overlay->colormap;
-    vis = __glutCurrentWindow->overlay->vis;
-    if (ndx == __glutCurrentWindow->overlay->transparentPixel) {
-      __glutWarning("glutGetColor: requesting overlay transparent index %d\n",
-        ndx);
-      return -1.0;
-    }
-  }
-
-  if (!colormap) {
-    __glutWarning("glutGetColor: current window is RGBA");
-    return -1.0;
-  }
-#if defined(_WIN32)
-#define OUT_OF_RANGE_NDX(ndx) (ndx >= 256 || ndx < 0)
-#else
-#define OUT_OF_RANGE_NDX(ndx) (ndx >= vis->visual->map_entries || ndx < 0)
-#endif
-  if (OUT_OF_RANGE_NDX(ndx)) {
-    __glutWarning("glutGetColor: index %d out of range", ndx);
-    return -1.0;
-  }
-  return colormap->cells[ndx].component[comp];
-}
-
-void GLUTAPIENTRY
-glutCopyColormap(int winnum)
-{
-  GLUTwindow *window = __glutWindowList[winnum - 1];
-  GLUTcolormap *oldcmap, *newcmap;
-  XVisualInfo *dstvis;
-
-  if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
-    oldcmap = __glutCurrentWindow->colormap;
-    dstvis = __glutCurrentWindow->vis;
-    newcmap = window->colormap;
-  } else {
-    oldcmap = __glutCurrentWindow->overlay->colormap;
-    dstvis = __glutCurrentWindow->overlay->vis;
-    if (!window->overlay) {
-      __glutWarning("glutCopyColormap: window %d has no overlay", winnum);
-      return;
-    }
-    newcmap = window->overlay->colormap;
-  }
-
-  if (!oldcmap) {
-    __glutWarning("glutCopyColormap: destination colormap must be color index");
-    return;
-  }
-  if (!newcmap) {
-    __glutWarning(
-      "glutCopyColormap: source colormap of window %d must be color index",
-      winnum);
-    return;
-  }
-  if (newcmap == oldcmap) {
-    /* Source and destination are the same; now copy needed. */
-    return;
-  }
-#if !defined(_WIN32)
-  /* Play safe: compare visual IDs, not Visual*'s. */
-  if (newcmap->visual->visualid == oldcmap->visual->visualid) {
-#endif
-    /* Visuals match!  "Copy" by reference...  */
-    __glutFreeColormap(oldcmap);
-    newcmap->refcnt++;
-    if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
-      __glutCurrentWindow->colormap = newcmap;
-      __glutCurrentWindow->cmap = newcmap->cmap;
-    } else {
-      __glutCurrentWindow->overlay->colormap = newcmap;
-      __glutCurrentWindow->overlay->cmap = newcmap->cmap;
-    }
-    XSetWindowColormap(__glutDisplay, __glutCurrentWindow->renderWin,
-      newcmap->cmap);
-#if !defined(_WIN32)
-    __glutPutOnWorkList(__glutToplevelOf(window), GLUT_COLORMAP_WORK);
-  } else {
-    GLUTcolormap *copycmap;
-    XColor color;
-    int i, last;
-
-    /* Visuals different - need a distinct X colormap! */
-    copycmap = __glutAssociateNewColormap(dstvis);
-    /* Wouldn't it be nice if XCopyColormapAndFree could be
-       told not to free the old colormap's entries! */
-    last = newcmap->size;
-    if (last > copycmap->size) {
-      last = copycmap->size;
-    }
-    for (i = last - 1; i >= 0; i--) {
-      if (newcmap->cells[i].component[GLUT_RED] >= 0.0) {
-        color.pixel = i;
-        copycmap->cells[i].component[GLUT_RED] =
-          newcmap->cells[i].component[GLUT_RED];
-        color.red = (GLfloat) 0xffff *
-          newcmap->cells[i].component[GLUT_RED];
-        copycmap->cells[i].component[GLUT_GREEN] =
-          newcmap->cells[i].component[GLUT_GREEN];
-        color.green = (GLfloat) 0xffff *
-          newcmap->cells[i].component[GLUT_GREEN];
-        copycmap->cells[i].component[GLUT_BLUE] =
-          newcmap->cells[i].component[GLUT_BLUE];
-        color.blue = (GLfloat) 0xffff *
-          newcmap->cells[i].component[GLUT_BLUE];
-        color.flags = DoRed | DoGreen | DoBlue;
-        XStoreColor(__glutDisplay, copycmap->cmap, &color);
-      }
-    }
-  }
-#endif
-}
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_cmap.c b/src/glut/glx/glut_cmap.c
deleted file mode 100644 (file)
index e6cb742..0000000
+++ /dev/null
@@ -1,422 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1996, 1997.  */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>  /* SunOS multithreaded assert() needs <stdio.h>.  Lame. */
-#include <assert.h>
-#if !defined(_WIN32)
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>  /* for XA_RGB_DEFAULT_MAP atom */
-#if defined(__vms)
-#include <Xmu/StdCmap.h>  /* for XmuLookupStandardColormap */
-#else
-#include <X11/Xmu/StdCmap.h>  /* for XmuLookupStandardColormap */
-#endif
-#endif
-
-/* SGI optimization introduced in IRIX 6.3 to avoid X server
-   round trips for interning common X atoms. */
-#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
-#include <X11/SGIFastAtom.h>
-#else
-#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
-#endif
-
-#include "glutint.h"
-#include "layerutil.h"
-
-GLUTcolormap *__glutColormapList = NULL;
-
-GLUTcolormap *
-__glutAssociateNewColormap(XVisualInfo * vis)
-{
-  GLUTcolormap *cmap;
-  int transparentPixel, i;
-  unsigned long pixels[255];
-
-  cmap = (GLUTcolormap *) malloc(sizeof(GLUTcolormap));
-  if (!cmap)
-    __glutFatalError("out of memory.");
-#if defined(_WIN32)
-  pixels[0] = 0;        /* avoid compilation warnings on win32 */
-  cmap->visual = 0;
-  cmap->size = 256;     /* always assume 256 on Win32 */
-#else
-  cmap->visual = vis->visual;
-  cmap->size = vis->visual->map_entries;
-#endif
-  cmap->refcnt = 1;
-  cmap->cells = (GLUTcolorcell *)
-    malloc(sizeof(GLUTcolorcell) * cmap->size);
-  if (!cmap->cells)
-    __glutFatalError("out of memory.");
-  /* make all color cell entries be invalid */
-  for (i = cmap->size - 1; i >= 0; i--) {
-    cmap->cells[i].component[GLUT_RED] = -1.0;
-    cmap->cells[i].component[GLUT_GREEN] = -1.0;
-    cmap->cells[i].component[GLUT_BLUE] = -1.0;
-  }
-  transparentPixel = __glutGetTransparentPixel(__glutDisplay, vis);
-  if (transparentPixel == -1 || transparentPixel >= cmap->size) {
-
-    /* If there is no transparent pixel or if the transparent
-       pixel is outside the range of valid colormap cells (HP
-       can implement their overlays this smart way since their
-       transparent pixel is 255), we can AllocAll the colormap.
-       See note below.  */
-
-    cmap->cmap = XCreateColormap(__glutDisplay,
-      __glutRoot, cmap->visual, AllocAll);
-  } else {
-
-    /* On machines where zero (or some other value in the range
-       of 0 through map_entries-1), BadAlloc may be generated
-       when an AllocAll overlay colormap is allocated since the
-       transparent pixel precludes all the cells in the colormap
-       being allocated (the transparent pixel is pre-allocated).
-       So in this case, use XAllocColorCells to allocate
-       map_entries-1 pixels (that is, all but the transparent
-       pixel.  */
-
-#if defined(_WIN32)
-    cmap->cmap = XCreateColormap(__glutDisplay,
-      __glutRoot, 0, AllocNone);
-#else
-    cmap->cmap = XCreateColormap(__glutDisplay,
-      __glutRoot, vis->visual, AllocNone);
-    XAllocColorCells(__glutDisplay, cmap->cmap, False, 0, 0,
-      pixels, cmap->size - 1);
-#endif
-  }
-  cmap->next = __glutColormapList;
-  __glutColormapList = cmap;
-  return cmap;
-}
-
-static GLUTcolormap *
-associateColormap(XVisualInfo * vis)
-{
-#if !defined(_WIN32)
-  GLUTcolormap *cmap = __glutColormapList;
-
-  while (cmap != NULL) {
-    /* Play safe: compare visual IDs, not Visual*'s. */
-    if (cmap->visual->visualid == vis->visual->visualid) {
-      /* Already have created colormap for the visual. */
-      cmap->refcnt++;
-      return cmap;
-    }
-    cmap = cmap->next;
-  }
-#endif
-  return __glutAssociateNewColormap(vis);
-}
-
-void
-__glutSetupColormap(XVisualInfo * vi, GLUTcolormap ** colormap, Colormap * cmap)
-{
-#if defined(_WIN32)
-  if (vi->dwFlags & PFD_NEED_PALETTE || vi->iPixelType == PFD_TYPE_COLORINDEX) {
-    *colormap = associateColormap(vi);
-    *cmap = (*colormap)->cmap;
-  } else {
-    *colormap = NULL;
-    *cmap = 0;
-  }
-#else
-  Status status;
-  XStandardColormap *standardCmaps;
-  int i, numCmaps;
-  static Atom hpColorRecoveryAtom = -1;
-  int isRGB, visualClass, rc;
-
-#if defined(__cplusplus) || defined(c_plusplus)
-  visualClass = vi->c_class;
-#else
-  visualClass = vi->class;
-#endif
-  switch (visualClass) {
-  case PseudoColor:
-    /* Mesa might return a PseudoColor visual for RGB mode. */
-    rc = glXGetConfig(__glutDisplay, vi, GLX_RGBA, &isRGB);
-    if (rc == 0 && isRGB) {
-      /* Must be Mesa. */
-      *colormap = NULL;
-      if (MaxCmapsOfScreen(DefaultScreenOfDisplay(__glutDisplay)) == 1
-        && vi->visual == DefaultVisual(__glutDisplay, __glutScreen)) {
-        char *privateCmap = getenv("MESA_PRIVATE_CMAP");
-
-        if (privateCmap) {
-          /* User doesn't want to share colormaps. */
-          *cmap = XCreateColormap(__glutDisplay, __glutRoot,
-            vi->visual, AllocNone);
-        } else {
-          /* Share the root colormap. */
-          *cmap = DefaultColormap(__glutDisplay, __glutScreen);
-        }
-      } else {
-        /* Get our own PseudoColor colormap. */
-        *cmap = XCreateColormap(__glutDisplay, __glutRoot,
-          vi->visual, AllocNone);
-      }
-    } else {
-      /* CI mode, real GLX never returns a PseudoColor visual
-         for RGB mode. */
-      *colormap = associateColormap(vi);
-      *cmap = (*colormap)->cmap;
-    }
-    break;
-  case TrueColor:
-    *colormap = NULL;   /* NULL if RGBA */
-
-    /* Hewlett-Packard supports a feature called "HP Color
-       Recovery". Mesa has code to use HP Color Recovery.  For
-       Mesa to use this feature, the atom
-       _HP_RGB_SMOOTH_MAP_LIST must be defined on the root
-       window AND the colormap obtainable by XGetRGBColormaps
-       for that atom must be set on the window.  If that
-       colormap is not set, the output will look stripy. */
-
-    if (hpColorRecoveryAtom == -1) {
-      char *xvendor;
-
-#define VENDOR_HP "Hewlett-Packard"
-
-      /* Only makes sense to make XInternAtom round-trip if we
-         know that we are connected to an HP X server. */
-      xvendor = ServerVendor(__glutDisplay);
-      if (!strncmp(xvendor, VENDOR_HP, sizeof(VENDOR_HP) - 1)) {
-        hpColorRecoveryAtom = XInternAtom(__glutDisplay, "_HP_RGB_SMOOTH_MAP_LIST", True);
-      } else {
-        hpColorRecoveryAtom = None;
-      }
-    }
-    if (hpColorRecoveryAtom != None) {
-      status = XGetRGBColormaps(__glutDisplay, __glutRoot,
-        &standardCmaps, &numCmaps, hpColorRecoveryAtom);
-      if (status == 1) {
-        for (i = 0; i < numCmaps; i++) {
-          if (standardCmaps[i].visualid == vi->visualid) {
-            *cmap = standardCmaps[i].colormap;
-            XFree(standardCmaps);
-            return;
-          }
-        }
-        XFree(standardCmaps);
-      }
-    }
-#ifndef SOLARIS_2_4_BUG
-    /* Solaris 2.4 and 2.5 have a bug in their
-       XmuLookupStandardColormap implementations.  Please
-       compile your Solaris 2.4 or 2.5 version of GLUT with
-       -DSOLARIS_2_4_BUG to work around this bug. The symptom
-       of the bug is that programs will get a BadMatch error
-       from X_CreateWindow when creating a GLUT window because
-       Solaris 2.4 and 2.5 create a  corrupted RGB_DEFAULT_MAP
-       property.  Note that this workaround prevents Colormap
-       sharing between applications, perhaps leading
-       unnecessary colormap installations or colormap flashing.
-       Sun fixed this bug in Solaris 2.6. */
-    status = XmuLookupStandardColormap(__glutDisplay,
-      vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP,
-      /* replace */ False, /* retain */ True);
-    if (status == 1) {
-      status = XGetRGBColormaps(__glutDisplay, __glutRoot,
-        &standardCmaps, &numCmaps, XA_RGB_DEFAULT_MAP);
-      if (status == 1) {
-        for (i = 0; i < numCmaps; i++) {
-          if (standardCmaps[i].visualid == vi->visualid) {
-            *cmap = standardCmaps[i].colormap;
-            XFree(standardCmaps);
-            return;
-          }
-        }
-        XFree(standardCmaps);
-      }
-    }
-#endif
-    /* If no standard colormap but TrueColor, just make a
-       private one. */
-    /* XXX Should do a better job of internal sharing for
-       privately allocated TrueColor colormaps. */
-    *cmap = XCreateColormap(__glutDisplay, __glutRoot,
-      vi->visual, AllocNone);
-    break;
-  case DirectColor:
-    *colormap = NULL;   /* NULL if RGBA */
-    *cmap = XCreateColormap(__glutDisplay, __glutRoot,
-                            vi->visual, AllocAll);
-    if (vi->depth == 24) {
-      /* init the red, green, blue maps to linear ramps */
-      XColor xc[256];
-      int i;
-      for (i = 0; i < 256; i++) {
-        xc[i].pixel = (i << 16) | (i << 8) | i;
-        xc[i].red = (i << 8) | i;
-        xc[i].green = (i << 8) | i;
-        xc[i].blue = (i << 8) | i;
-        xc[i].flags = DoRed | DoGreen | DoBlue;
-      }
-      XStoreColors(__glutDisplay, *cmap, xc, 256);
-    }
-    else {
-       fprintf(stderr, "GLUT Error: DirectColor visuals other than 24-bits "
-               "not fully supported.\n");
-    }
-    break;
-  case StaticColor:
-  case StaticGray:
-  case GrayScale:
-    /* Mesa supports these visuals */
-    *colormap = NULL;
-    *cmap = XCreateColormap(__glutDisplay, __glutRoot,
-      vi->visual, AllocNone);
-    break;
-  default:
-    __glutFatalError(
-      "could not allocate colormap for visual type: %d.",
-      visualClass);
-  }
-  return;
-#endif
-}
-
-#if !defined(_WIN32)
-static int
-findColormaps(GLUTwindow * window,
-  Window * winlist, Colormap * cmaplist, int num, int max)
-{
-  GLUTwindow *child;
-  int i;
-
-  /* Do not allow more entries that maximum number of
-     colormaps! */
-  if (num >= max)
-    return num;
-  /* Is cmap for this window already on the list? */
-  for (i = 0; i < num; i++) {
-    if (cmaplist[i] == window->cmap)
-      goto normalColormapAlreadyListed;
-  }
-  /* Not found on the list; add colormap and window. */
-  winlist[num] = window->win;
-  cmaplist[num] = window->cmap;
-  num++;
-
-normalColormapAlreadyListed:
-
-  /* Repeat above but for the overlay colormap if there one. */
-  if (window->overlay) {
-    if (num >= max)
-      return num;
-    for (i = 0; i < num; i++) {
-      if (cmaplist[i] == window->overlay->cmap)
-        goto overlayColormapAlreadyListed;
-    }
-    winlist[num] = window->overlay->win;
-    cmaplist[num] = window->overlay->cmap;
-    num++;
-  }
-overlayColormapAlreadyListed:
-
-  /* Recursively search children. */
-  child = window->children;
-  while (child) {
-    num = findColormaps(child, winlist, cmaplist, num, max);
-    child = child->siblings;
-  }
-  return num;
-}
-
-void
-__glutEstablishColormapsProperty(GLUTwindow * window)
-{
-  /* this routine is strictly X.  Win32 doesn't need to do
-     anything of this sort (but has to do other wacky stuff
-     later). */
-  static Atom wmColormapWindows = None;
-  Window *winlist;
-  Colormap *cmaplist;
-  Status status;
-  int maxcmaps, num, i;
-
-  assert(!window->parent);
-  maxcmaps = MaxCmapsOfScreen(ScreenOfDisplay(__glutDisplay,
-      __glutScreen));
-  /* For portability reasons we don't use alloca for winlist
-     and cmaplist, but we could. */
-  winlist = (Window *) malloc(maxcmaps * sizeof(Window));
-  cmaplist = (Colormap *) malloc(maxcmaps * sizeof(Colormap));
-  for (i = 0; i < maxcmaps; i++) {
-    cmaplist[i] = 0;
-  }
-  num = findColormaps(window, winlist, cmaplist, 0, maxcmaps);
-  if (num < 2) {
-    /* Property no longer needed; remove it. */
-    wmColormapWindows = XSGIFastInternAtom(__glutDisplay,
-      "WM_COLORMAP_WINDOWS", SGI_XA_WM_COLORMAP_WINDOWS, False);
-    if (wmColormapWindows == None) {
-      __glutWarning("Could not intern X atom for WM_COLORMAP_WINDOWS.");
-      return;
-    }
-    XDeleteProperty(__glutDisplay, window->win, wmColormapWindows);
-  } else {
-    status = XSetWMColormapWindows(__glutDisplay, window->win,
-      winlist, num);
-    /* XSetWMColormapWindows should always work unless the
-       WM_COLORMAP_WINDOWS property cannot be intern'ed.  We
-       check to be safe. */
-    if (status == False)
-      __glutFatalError("XSetWMColormapWindows returned False.");
-  }
-  /* For portability reasons we don't use alloca for winlist
-     and cmaplist, but we could. */
-  free(winlist);
-  free(cmaplist);
-}
-
-GLUTwindow *
-__glutToplevelOf(GLUTwindow * window)
-{
-  while (window->parent) {
-    window = window->parent;
-  }
-  return window;
-}
-#endif
-
-void
-__glutFreeColormap(GLUTcolormap * cmap)
-{
-  GLUTcolormap *cur, **prev;
-
-  cmap->refcnt--;
-  if (cmap->refcnt == 0) {
-    /* remove from colormap list */
-    cur = __glutColormapList;
-    prev = &__glutColormapList;
-    while (cur) {
-      if (cur == cmap) {
-        *prev = cmap->next;
-        break;
-      }
-      prev = &(cur->next);
-      cur = cur->next;
-    }
-    /* actually free colormap */
-    XFreeColormap(__glutDisplay, cmap->cmap);
-    free(cmap->cells);
-    free(cmap);
-  }
-}
-
diff --git a/src/glut/glx/glut_cursor.c b/src/glut/glx/glut_cursor.c
deleted file mode 100644 (file)
index 797cb49..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1995, 1998. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-
-#if !defined(_WIN32)
-#include <X11/Xatom.h>  /* For XA_CURSOR */
-#include <X11/cursorfont.h>
-#endif
-
-typedef struct _CursorTable {
-#if defined(_WIN32)
-  char* glyph;
-#else
-  int glyph;
-#endif
-  Cursor cursor;
-} CursorTable;
-/* *INDENT-OFF* */
-
-static CursorTable cursorTable[] = {
-  {XC_arrow, None},              /* GLUT_CURSOR_RIGHT_ARROW */
-  {XC_top_left_arrow, None},     /* GLUT_CURSOR_LEFT_ARROW */
-  {XC_hand1, None},              /* GLUT_CURSOR_INFO */
-  {XC_pirate, None},             /* GLUT_CURSOR_DESTROY */
-  {XC_question_arrow, None},     /* GLUT_CURSOR_HELP */
-  {XC_exchange, None},           /* GLUT_CURSOR_CYCLE */
-  {XC_spraycan, None},           /* GLUT_CURSOR_SPRAY */
-  {XC_watch, None},              /* GLUT_CURSOR_WAIT */
-  {XC_xterm, None},              /* GLUT_CURSOR_TEXT */
-  {XC_crosshair, None},                  /* GLUT_CURSOR_CROSSHAIR */
-  {XC_sb_v_double_arrow, None},          /* GLUT_CURSOR_UP_DOWN */
-  {XC_sb_h_double_arrow, None},          /* GLUT_CURSOR_LEFT_RIGHT */
-  {XC_top_side, None},           /* GLUT_CURSOR_TOP_SIDE */
-  {XC_bottom_side, None},        /* GLUT_CURSOR_BOTTOM_SIDE */
-  {XC_left_side, None},                  /* GLUT_CURSOR_LEFT_SIDE */
-  {XC_right_side, None},         /* GLUT_CURSOR_RIGHT_SIDE */
-  {XC_top_left_corner, None},    /* GLUT_CURSOR_TOP_LEFT_CORNER */
-  {XC_top_right_corner, None},   /* GLUT_CURSOR_TOP_RIGHT_CORNER */
-  {XC_bottom_right_corner, None}, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
-  {XC_bottom_left_corner, None},  /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
-};
-/* *INDENT-ON* */
-
-#if !defined(_WIN32)
-static Cursor blankCursor = None;
-static Cursor fullCrosshairCusor = None;
-
-/* SGI X server's support a special property called the
-   _SGI_CROSSHAIR_CURSOR that when installed as a window's
-   cursor, becomes a full screen crosshair cursor.  SGI
-   has special cursor generation hardware for this case. */
-static Cursor
-getFullCrosshairCursor(void)
-{
-  Cursor cursor;
-  Atom crosshairAtom, actualType;
-  int rc, actualFormat;
-  unsigned long n, left;
-  unsigned char *value;
-
-  if (fullCrosshairCusor == None) {
-    crosshairAtom = XInternAtom(__glutDisplay,
-      "_SGI_CROSSHAIR_CURSOR", True);
-    if (crosshairAtom != None) {
-      value = 0;        /* Make compiler happy. */
-      rc = XGetWindowProperty(__glutDisplay, __glutRoot,
-        crosshairAtom, 0, 1, False, XA_CURSOR, &actualType,
-        &actualFormat, &n, &left, &value);
-      if (rc == Success && actualFormat == 32 && n >= 1) {
-        cursor = ((unsigned long *)value)[0];
-        XFree(value);
-        return cursor;
-      }
-    }
-  }
-  return XCreateFontCursor(__glutDisplay, XC_crosshair);
-}
-
-/* X11 forces you to create a blank cursor if you want
-   to disable the cursor. */
-static Cursor
-makeBlankCursor(void)
-{
-  static char data[1] =
-  {0};
-  Cursor cursor;
-  Pixmap blank;
-  XColor dummy;
-
-  blank = XCreateBitmapFromData(__glutDisplay, __glutRoot,
-    data, 1, 1);
-  if (blank == None)
-    __glutFatalError("out of memory.");
-  cursor = XCreatePixmapCursor(__glutDisplay, blank, blank,
-    &dummy, &dummy, 0, 0);
-  XFreePixmap(__glutDisplay, blank);
-
-  return cursor;
-}
-#endif /* !_WIN32 */
-
-/* Win32 and X11 use this same function to accomplish
-   fairly different tasks.  X11 lets you just define the
-   cursor for a window and the window system takes care
-   of making sure that the window's cursor is installed
-   when the mouse is in the window.  Win32 requires the
-   application to handle a WM_SETCURSOR message to install
-   the right cursor when windows are entered.  Think of
-   the Win32 __glutSetCursor (called from __glutWindowProc)
-   as "install cursor".  Think of the X11 __glutSetCursor
-   (called from glutSetCursor) as "define cursor". */
-void 
-__glutSetCursor(GLUTwindow *window)
-{
-  int cursor = window->cursor;
-  Cursor xcursor = 0;
-
-  if (cursor >= 0 &&
-    cursor < sizeof(cursorTable) / sizeof(cursorTable[0])) {
-    if (cursorTable[cursor].cursor == None) {
-      cursorTable[cursor].cursor = XCreateFontCursor(__glutDisplay,
-        cursorTable[cursor].glyph);
-    }
-    xcursor = cursorTable[cursor].cursor;
-  } else {
-    /* Special cases. */
-    switch (cursor) {
-    case GLUT_CURSOR_INHERIT:
-#if defined(_WIN32)
-      while (window->parent) {
-        window = window->parent;
-        if (window->cursor != GLUT_CURSOR_INHERIT) {
-          __glutSetCursor(window);
-          return;
-        }
-      }
-      /* XXX Default to an arrow cursor.  Is this
-         right or should we be letting the default
-         window proc be installing some system cursor? */
-      xcursor = cursorTable[0].cursor;
-      if (xcursor == NULL) {
-        xcursor =
-          cursorTable[0].cursor =
-          LoadCursor(NULL, cursorTable[0].glyph);
-      }
-#else
-      xcursor = None;
-#endif
-      break;
-    case GLUT_CURSOR_NONE:
-#if defined(_WIN32)
-      xcursor = NULL;
-#else
-      if (blankCursor == None) {
-        blankCursor = makeBlankCursor();
-      }
-      xcursor = blankCursor;
-#endif
-      break;
-    case GLUT_CURSOR_FULL_CROSSHAIR:
-#if defined(_WIN32)
-      xcursor = (HICON) IDC_CROSS;
-#else
-      if (fullCrosshairCusor == None) {
-        fullCrosshairCusor = getFullCrosshairCursor();
-      }
-      xcursor = fullCrosshairCusor;
-#endif
-      break;
-    }
-  }
-  XDefineCursor(__glutDisplay,
-    window->win, xcursor);
-  XFlush(__glutDisplay);
-}
-
-/* CENTRY */
-void GLUTAPIENTRY 
-glutSetCursor(int cursor)
-{
-#ifdef _WIN32
-  POINT point;
-
-  __glutCurrentWindow->cursor = cursor;
-  /* Are we in the window right now?  If so,
-     install the cursor. */
-  GetCursorPos(&point);
-  if (__glutCurrentWindow->win == WindowFromPoint(point)) {
-    __glutSetCursor(__glutCurrentWindow);
-  }
-#else
-  __glutCurrentWindow->cursor = cursor;
-  __glutSetCursor(__glutCurrentWindow);
-#endif
-}
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_dials.c b/src/glut/glx/glut_dials.c
deleted file mode 100644 (file)
index e015b91..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-
-void GLUTAPIENTRY 
-glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc)
-{
-  __glutCurrentWindow->buttonBox = buttonBoxFunc;
-  __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask;
-  __glutPutOnWorkList(__glutCurrentWindow,
-    GLUT_DEVICE_MASK_WORK);
-}
-
-void GLUTAPIENTRY 
-glutDialsFunc(GLUTdialsCB dialsFunc)
-{
-  __glutCurrentWindow->dials = dialsFunc;
-  __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask;
-  __glutPutOnWorkList(__glutCurrentWindow,
-    GLUT_DEVICE_MASK_WORK);
-}
diff --git a/src/glut/glx/glut_dstr.c b/src/glut/glx/glut_dstr.c
deleted file mode 100644 (file)
index 319930c..0000000
+++ /dev/null
@@ -1,1626 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "glutint.h"
-
-/* glxcaps matches the criteria macros listed in glutint.h, but
-   only list the first set (those that correspond to GLX visual
-   attributes). */
-static int glxcap[NUM_GLXCAPS] =
-{
-  GLX_RGBA,
-  GLX_BUFFER_SIZE,
-  GLX_DOUBLEBUFFER,
-  GLX_STEREO,
-  GLX_AUX_BUFFERS,
-  GLX_RED_SIZE,
-  GLX_GREEN_SIZE,
-  GLX_BLUE_SIZE,
-  GLX_ALPHA_SIZE,
-  GLX_DEPTH_SIZE,
-  GLX_STENCIL_SIZE,
-  GLX_ACCUM_RED_SIZE,
-  GLX_ACCUM_GREEN_SIZE,
-  GLX_ACCUM_BLUE_SIZE,
-  GLX_ACCUM_ALPHA_SIZE,
-  GLX_LEVEL,
-};
-
-#ifdef TEST
-
-#if !defined(_WIN32)
-char *__glutProgramName = "dstr";
-Display *__glutDisplay;
-int __glutScreen;
-XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle,
-  Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc) = NULL;
-char *__glutDisplayString = NULL;
-#endif
-static int verbose = 0;
-
-static char *compstr[] =
-{
-  "none", "=", "!=", "<=", ">=", ">", "<", "~"
-};
-static char *capstr[] =
-{
-  "rgba", "bufsize", "double", "stereo", "auxbufs", "red", "green", "blue", "alpha",
-  "depth", "stencil", "acred", "acgreen", "acblue", "acalpha", "level", "xvisual",
-  "transparent", "samples", "xstaticgray", "xgrayscale", "xstaticcolor", "xpseudocolor",
-  "xtruecolor", "xdirectcolor", "slow", "conformant", "num"
-};
-
-static void
-printCriteria(Criterion * criteria, int ncriteria)
-{
-  int i;
-  printf("Criteria: %d\n", ncriteria);
-  for (i = 0; i < ncriteria; i++) {
-    printf("  %s %s %d\n",
-      capstr[criteria[i].capability],
-      compstr[criteria[i].comparison],
-      criteria[i].value);
-  }
-}
-
-#endif /* TEST */
-
-static int isMesaGLX = -1;
-
-static int
-determineMesaGLX(void)
-{
-#ifdef GLX_VERSION_1_1
-  const char *vendor, *version, *ch;
-
-  vendor = glXGetClientString(__glutDisplay, GLX_VENDOR);
-  if (!strcmp(vendor, "Brian Paul")) {
-    version = glXGetClientString(__glutDisplay, GLX_VERSION);
-    for (ch = version; *ch != ' ' && *ch != '\0'; ch++);
-    for (; *ch == ' ' && *ch != '\0'; ch++);
-
-#define MESA_NAME "Mesa "  /* Trailing space is intentional. */
-
-    if (!strncmp(MESA_NAME, ch, sizeof(MESA_NAME) - 1)) {
-      return 1;
-    }
-  }
-#else
-  /* Recent versions for Mesa should support GLX 1.1 and
-     therefore glXGetClientString.  If we get into this case,
-     we would be compiling against a true OpenGL not supporting
-     GLX 1.1, and the resulting compiled library won't work well 
-     with Mesa then. */
-#endif
-  return 0;
-}
-
-static XVisualInfo **
-getMesaVisualList(int *n)
-{
-  XVisualInfo **vlist, *vinfo;
-  int attribs[23];
-  int i, x, cnt;
-
-  vlist = (XVisualInfo **) malloc((32 + 16) * sizeof(XVisualInfo *));
-  if (!vlist)
-    __glutFatalError("out of memory.");
-
-  cnt = 0;
-  for (i = 0; i < 32; i++) {
-    x = 0;
-    attribs[x] = GLX_RGBA;
-    x++;
-    attribs[x] = GLX_RED_SIZE;
-    x++;
-    attribs[x] = 1;
-    x++;
-    attribs[x] = GLX_GREEN_SIZE;
-    x++;
-    attribs[x] = 1;
-    x++;
-    attribs[x] = GLX_BLUE_SIZE;
-    x++;
-    attribs[x] = 1;
-    x++;
-    if (i & 1) {
-      attribs[x] = GLX_DEPTH_SIZE;
-      x++;
-      attribs[x] = 1;
-      x++;
-    }
-    if (i & 2) {
-      attribs[x] = GLX_STENCIL_SIZE;
-      x++;
-      attribs[x] = 1;
-      x++;
-    }
-    if (i & 4) {
-      attribs[x] = GLX_ACCUM_RED_SIZE;
-      x++;
-      attribs[x] = 1;
-      x++;
-      attribs[x] = GLX_ACCUM_GREEN_SIZE;
-      x++;
-      attribs[x] = 1;
-      x++;
-      attribs[x] = GLX_ACCUM_BLUE_SIZE;
-      x++;
-      attribs[x] = 1;
-      x++;
-    }
-    if (i & 8) {
-      attribs[x] = GLX_ALPHA_SIZE;
-      x++;
-      attribs[x] = 1;
-      x++;
-      if (i & 4) {
-        attribs[x] = GLX_ACCUM_ALPHA_SIZE;
-        x++;
-        attribs[x] = 1;
-        x++;
-      }
-    }
-    if (i & 16) {
-      attribs[x] = GLX_DOUBLEBUFFER;
-      x++;
-    }
-    attribs[x] = None;
-    x++;
-    assert(x <= sizeof(attribs) / sizeof(attribs[0]));
-    vinfo = glXChooseVisual(__glutDisplay, __glutScreen, attribs);
-    if (vinfo) {
-      vlist[cnt] = vinfo;
-      cnt++;
-    }
-  }
-  for (i = 0; i < 16; i++) {
-    x = 0;
-    if (i & 1) {
-      attribs[x] = GLX_DEPTH_SIZE;
-      x++;
-      attribs[x] = 1;
-      x++;
-    }
-    if (i & 2) {
-      attribs[x] = GLX_STENCIL_SIZE;
-      x++;
-      attribs[x] = 1;
-      x++;
-    }
-    if (i & 4) {
-      attribs[x] = GLX_DOUBLEBUFFER;
-      x++;
-    }
-    if (i & 8) {
-      attribs[x] = GLX_LEVEL;
-      x++;
-      attribs[x] = 1;
-      x++;
-#if defined(GLX_TRANSPARENT_TYPE_EXT) && defined(GLX_TRANSPARENT_INDEX_EXT)
-      attribs[x] = GLX_TRANSPARENT_TYPE_EXT;
-      x++;
-      attribs[x] = GLX_TRANSPARENT_INDEX_EXT;
-      x++;
-#endif
-    }
-    attribs[x] = None;
-    x++;
-    assert(x <= sizeof(attribs) / sizeof(attribs[0]));
-    vinfo = glXChooseVisual(__glutDisplay, __glutScreen, attribs);
-    if (vinfo) {
-      vlist[cnt] = vinfo;
-      cnt++;
-    }
-  }
-
-  *n = cnt;
-  return vlist;
-}
-
-static FrameBufferMode *
-loadVisuals(int *nitems_return)
-{
-  XVisualInfo *vinfo, **vlist, template;
-  FrameBufferMode *fbmodes, *mode;
-  int n, i, j, rc, glcapable;
-#if defined(GLX_VERSION_1_1) && (defined(GLX_SGIS_multisample) || defined(GLX_ARB_multisample))
-  int multisample;
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info)
-  int visual_info;
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_rating)
-  int visual_rating;
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-  int fbconfig;
-#endif
-
-  isMesaGLX = determineMesaGLX();
-  if (isMesaGLX) {
-    vlist = getMesaVisualList(&n);
-  } else {
-#if !defined(_WIN32)
-    template.screen = __glutScreen;
-    vinfo = XGetVisualInfo(__glutDisplay, VisualScreenMask, &template, &n);
-#else
-    vinfo = XGetVisualInfo(__glutDisplay, 0, &template, &n);
-#endif
-    if (vinfo == NULL) {
-      *nitems_return = 0;
-      return NULL;
-    }
-    assert(n > 0);
-
-    /* Make an array of XVisualInfo* pointers to help the Mesa
-       case because each glXChooseVisual call returns a
-       distinct XVisualInfo*, not a handy array like
-       XGetVisualInfo.  (Mesa expects us to return the _exact_
-       pointer returned by glXChooseVisual so we could not just
-       copy the returned structure.) */
-    vlist = (XVisualInfo **) malloc(n * sizeof(XVisualInfo *));
-    if (!vlist)
-      __glutFatalError("out of memory.");
-    for (i = 0; i < n; i++) {
-      vlist[i] = &vinfo[i];
-    }
-  }
-
-#if defined(GLX_VERSION_1_1) && (defined(GLX_SGIS_multisample) || defined(GLX_ARB_multisample))
-  multisample = __glutIsSupportedByGLX("GLX_SGIS_multisample") ||
-                __glutIsSupportedByGLX("GLX_ARB_multisample");
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info)
-  visual_info = __glutIsSupportedByGLX("GLX_EXT_visual_info");
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_rating)
-  visual_rating = __glutIsSupportedByGLX("GLX_EXT_visual_rating");
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-  fbconfig = __glutIsSupportedByGLX("GLX_SGIX_fbconfig");
-#endif
-
-  fbmodes = (FrameBufferMode *) malloc(n * sizeof(FrameBufferMode));
-  if (fbmodes == NULL) {
-    *nitems_return = -1;
-    free(vlist);
-    return NULL;
-  }
-  for (i = 0; i < n; i++) {
-    mode = &fbmodes[i];
-    mode->vi = vlist[i];
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-    mode->fbc = NULL;
-#endif
-    rc = glXGetConfig(__glutDisplay, vlist[i], GLX_USE_GL, &glcapable);
-    if (rc == 0 && glcapable) {
-      mode->valid = 1;  /* Assume the best until proven
-                           otherwise. */
-      for (j = 0; j < NUM_GLXCAPS; j++) {
-        rc = glXGetConfig(__glutDisplay, vlist[i], glxcap[j], &mode->cap[j]);
-        if (rc != 0) {
-          mode->valid = 0;
-        }
-      }
-#if defined(_WIN32)
-      mode->cap[XVISUAL] = ChoosePixelFormat(XHDC, vlist[i]);
-#else
-      mode->cap[XVISUAL] = (int) vlist[i]->visualid;
-#endif
-      mode->cap[XSTATICGRAY] = 0;
-      mode->cap[XGRAYSCALE] = 0;
-      mode->cap[XSTATICCOLOR] = 0;
-      mode->cap[XPSEUDOCOLOR] = 0;
-      mode->cap[XTRUECOLOR] = 0;
-      mode->cap[XDIRECTCOLOR] = 0;
-#if !defined(_WIN32)
-#if defined(__cplusplus) || defined(c_plusplus)
-      switch (vlist[i]->c_class) {
-#else
-      switch (vlist[i]->class) {
-#endif
-      case StaticGray:
-        mode->cap[XSTATICGRAY] = 1;
-        break;
-      case GrayScale:
-        mode->cap[XGRAYSCALE] = 1;
-        break;
-      case StaticColor:
-        mode->cap[XSTATICCOLOR] = 1;
-        break;
-      case PseudoColor:
-        mode->cap[XPSEUDOCOLOR] = 1;
-        break;
-      case TrueColor:
-        mode->cap[XTRUECOLOR] = 1;
-        break;
-      case DirectColor:
-        mode->cap[XDIRECTCOLOR] = 1;
-        break;
-      }
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_rating)
-      if (visual_rating) {
-        int rating;
-
-/* babcock@cs.montana.edu reported that DEC UNIX (OSF1) V4.0
-   564 for Alpha did not properly define GLX_VISUAL_CAVEAT_EXT
-   in <GL/glx.h> despite claiming to support
-   GLX_EXT_visual_rating. */
-#ifndef GLX_VISUAL_CAVEAT_EXT
-#define GLX_VISUAL_CAVEAT_EXT 0x20
-#endif
-
-        rc = glXGetConfig(__glutDisplay,
-         vlist[i], GLX_VISUAL_CAVEAT_EXT, &rating);
-        if (rc != 0) {
-          mode->cap[SLOW] = 0;
-          mode->cap[CONFORMANT] = 1;
-        } else {
-          switch (rating) {
-          case GLX_SLOW_VISUAL_EXT:
-            mode->cap[SLOW] = 1;
-            mode->cap[CONFORMANT] = 1;
-            break;
-
-/* IRIX 5.3 for the R10K Indigo2 may have shipped without this
-   properly defined in /usr/include/GL/glxtokens.h */
-#ifndef GLX_NON_CONFORMANT_VISUAL_EXT
-#define GLX_NON_CONFORMANT_VISUAL_EXT   0x800D
-#endif
-
-          case GLX_NON_CONFORMANT_VISUAL_EXT:
-            mode->cap[SLOW] = 0;
-            mode->cap[CONFORMANT] = 0;
-            break;
-          case GLX_NONE_EXT:
-          default:     /* XXX Hopefully this is a good default
-                           assumption. */
-            mode->cap[SLOW] = 0;
-            mode->cap[CONFORMANT] = 1;
-            break;
-          }
-        }
-      } else {
-        mode->cap[TRANSPARENT] = 0;
-      }
-#else
-      mode->cap[SLOW] = 0;
-      mode->cap[CONFORMANT] = 1;
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info)
-      if (visual_info) {
-        int transparent;
-
-/* babcock@cs.montana.edu reported that DEC UNIX (OSF1) V4.0
-   564 for Alpha did not properly define
-   GLX_TRANSPARENT_TYPE_EXT in <GL/glx.h> despite claiming to
-   support GLX_EXT_visual_info. */
-#ifndef GLX_TRANSPARENT_TYPE_EXT
-#define GLX_TRANSPARENT_TYPE_EXT 0x23
-#endif
-
-        rc = glXGetConfig(__glutDisplay,
-          vlist[i], GLX_TRANSPARENT_TYPE_EXT, &transparent);
-        if (rc != 0) {
-          mode->cap[TRANSPARENT] = 0;
-        } else {
-          mode->cap[TRANSPARENT] = (transparent != GLX_NONE_EXT);
-        }
-      } else {
-        mode->cap[TRANSPARENT] = 0;
-      }
-#else
-      mode->cap[TRANSPARENT] = 0;
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample)
-      if (multisample) {
-        rc = glXGetConfig(__glutDisplay,
-         vlist[i], GLX_SAMPLES_SGIS, &mode->cap[SAMPLES]);
-        if (rc != 0) {
-          mode->cap[SAMPLES] = 0;
-        }
-      } else {
-        mode->cap[SAMPLES] = 0;
-      }
-#else
-      mode->cap[SAMPLES] = 0;
-#endif
-    } else {
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-      if (fbconfig) {
-        GLXFBConfigSGIX fbc;
-        int fbconfigID, drawType, renderType;
-
-        fbc = __glut_glXGetFBConfigFromVisualSGIX(__glutDisplay, vlist[i]);
-        if (fbc) {
-          rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
-           GLX_FBCONFIG_ID_SGIX, &fbconfigID);
-          if ((rc == 0) && (fbconfigID != None)) {
-            rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
-             GLX_DRAWABLE_TYPE_SGIX, &drawType);
-            if ((rc == 0) && (drawType & GLX_WINDOW_BIT_SGIX)) {
-              rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay, fbc,
-               GLX_RENDER_TYPE_SGIX, &renderType);
-              if ((rc == 0) && (renderType & GLX_RGBA_BIT_SGIX)) {
-                mode->fbc = fbc;
-                mode->valid = 1;  /* Assume the best until
-                                     proven otherwise. */
-
-               assert(glxcap[0] == GLX_RGBA);
-                mode->cap[0] = 1;
-
-                /* Start with "j = 1" to skip the GLX_RGBA attribute. */
-                for (j = 1; j < NUM_GLXCAPS; j++) {
-                  rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay,
-                   fbc, glxcap[j], &mode->cap[j]);
-                  if (rc != 0) {
-                    mode->valid = 0;
-                  }
-                }
-
-                mode->cap[XVISUAL] = (int) vlist[i]->visualid;
-                mode->cap[XSTATICGRAY] = 0;
-                mode->cap[XGRAYSCALE] = 0;
-                mode->cap[XSTATICCOLOR] = 0;
-                mode->cap[XPSEUDOCOLOR] = 0;
-                mode->cap[XTRUECOLOR] = 0;
-                mode->cap[XDIRECTCOLOR] = 0;
-#if defined(__cplusplus) || defined(c_plusplus)
-                switch (vlist[i]->c_class) {
-#else
-                switch (vlist[i]->class) {
-#endif
-                case StaticGray:
-                  mode->cap[XSTATICGRAY] = 1;
-                  break;
-                case GrayScale:
-                  mode->cap[XGRAYSCALE] = 1;
-                  break;
-                case StaticColor:
-                  mode->cap[XSTATICCOLOR] = 1;
-                  break;
-                case PseudoColor:
-                  mode->cap[XPSEUDOCOLOR] = 1;
-                  break;
-                case TrueColor:
-                  mode->cap[XTRUECOLOR] = 1;
-                  break;
-                case DirectColor:
-                  mode->cap[XDIRECTCOLOR] = 1;
-                  break;
-                }
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_rating)
-                if (visual_rating) {
-                  int rating;
-
-/* babcock@cs.montana.edu reported that DEC UNIX (OSF1) V4.0
-   564 for Alpha did not properly define GLX_VISUAL_CAVEAT_EXT
-   in <GL/glx.h> despite claiming to support
-   GLX_EXT_visual_rating. */
-#ifndef GLX_VISUAL_CAVEAT_EXT
-#define GLX_VISUAL_CAVEAT_EXT 0x20
-#endif
-
-                  rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay,
-                   fbc, GLX_VISUAL_CAVEAT_EXT, &rating);
-                  if (rc != 0) {
-                    mode->cap[SLOW] = 0;
-                    mode->cap[CONFORMANT] = 1;
-                  } else {
-                    switch (rating) {
-                    case GLX_SLOW_VISUAL_EXT:
-                      mode->cap[SLOW] = 1;
-                      mode->cap[CONFORMANT] = 1;
-                      break;
-
-/* IRIX 5.3 for the R10K Indigo2 may have shipped without this
-   properly defined in /usr/include/GL/glxtokens.h */
-#ifndef GLX_NON_CONFORMANT_VISUAL_EXT
-#define GLX_NON_CONFORMANT_VISUAL_EXT   0x800D
-#endif
-
-                    case GLX_NON_CONFORMANT_VISUAL_EXT:
-                      mode->cap[SLOW] = 0;
-                      mode->cap[CONFORMANT] = 0;
-                      break;
-                    case GLX_NONE_EXT:
-                    default:  /* XXX Hopefully this is a good
-                                  default assumption. */
-                      mode->cap[SLOW] = 0;
-                      mode->cap[CONFORMANT] = 1;
-                      break;
-                    }
-                  }
-                } else {
-                  mode->cap[TRANSPARENT] = 0;
-                }
-#else
-                mode->cap[SLOW] = 0;
-                mode->cap[CONFORMANT] = 1;
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info)
-                if (visual_info) {
-                  int transparent;
-
-/* babcock@cs.montana.edu reported that DEC UNIX (OSF1) V4.0
-   564 for Alpha did not properly define
-   GLX_TRANSPARENT_TYPE_EXT in <GL/glx.h> despite claiming to
-   support GLX_EXT_visual_info. */
-#ifndef GLX_TRANSPARENT_TYPE_EXT
-#define GLX_TRANSPARENT_TYPE_EXT 0x23
-#endif
-
-                  rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay,
-                   fbc, GLX_TRANSPARENT_TYPE_EXT, &transparent);
-                  if (rc != 0) {
-                    mode->cap[TRANSPARENT] = 0;
-                  } else {
-                    mode->cap[TRANSPARENT] = (transparent != GLX_NONE_EXT);
-                  }
-                } else {
-                  mode->cap[TRANSPARENT] = 0;
-                }
-#else
-                mode->cap[TRANSPARENT] = 0;
-#endif
-#if defined(GLX_VERSION_1_1) && (defined(GLX_SGIS_multisample) || defined(GLX_ARB_multisample))
-                if (multisample) {
-                  rc = __glut_glXGetFBConfigAttribSGIX(__glutDisplay,
-                   fbc, GLX_SAMPLES_SGIS, &mode->cap[SAMPLES]);
-                  if (rc != 0) {
-                    mode->cap[SAMPLES] = 0;
-                  }
-                } else {
-                  mode->cap[SAMPLES] = 0;
-                }
-#else
-                mode->cap[SAMPLES] = 0;
-#endif
-
-              } else {
-                /* Fbconfig is not RGBA; GLUT only uses RGBA
-                   FBconfigs. */
-                /* XXX Code could be exteneded to handle color
-                   index FBconfigs, but seems a color index
-                   window-renderable FBconfig would also be
-                   advertised as an X visual. */
-                mode->valid = 0;
-              }
-            } else {
-              /* Fbconfig does not support window rendering;
-                 not a valid FBconfig for GLUT windows. */
-              mode->valid = 0;
-            }
-          } else {
-            /* FBconfig ID is None (zero); not a valid
-               FBconfig. */
-            mode->valid = 0;
-          }
-        } else {
-          /* FBconfig ID is None (zero); not a valid FBconfig. */
-          mode->valid = 0;
-        }
-      } else {
-        /* No SGIX_fbconfig GLX sever implementation support. */
-        mode->valid = 0;
-      }
-#else
-      /* No SGIX_fbconfig GLX extension API support. */
-      mode->valid = 0;
-#endif
-    }
-  }
-
-  free(vlist);
-  *nitems_return = n;
-  return fbmodes;
-}
-
-static XVisualInfo *
-findMatch(FrameBufferMode * fbmodes, int nfbmodes,
-  Criterion * criteria, int ncriteria, void **fbc)
-{
-  FrameBufferMode *found;
-  int *bestScore, *thisScore;
-  int i, j, numok, result = 0, worse, better;
-
-  found = NULL;
-  numok = 1;            /* "num" capability is indexed from 1,
-                           not 0. */
-
-  /* XXX alloca canidate. */
-  bestScore = (int *) malloc(ncriteria * sizeof(int));
-  if (!bestScore)
-    __glutFatalError("out of memory.");
-  for (j = 0; j < ncriteria; j++) {
-    /* Very negative number. */
-    bestScore[j] = -32768;
-  }
-
-  /* XXX alloca canidate. */
-  thisScore = (int *) malloc(ncriteria * sizeof(int));
-  if (!thisScore)
-    __glutFatalError("out of memory.");
-
-  for (i = 0; i < nfbmodes; i++) {
-    if (fbmodes[i].valid) {
-#ifdef TEST
-#if !defined(_WIN32)
-      if (verbose)
-        printf("Visual 0x%x\n", fbmodes[i].vi->visualid);
-#endif
-#endif
-
-      worse = 0;
-      better = 0;
-
-      for (j = 0; j < ncriteria; j++) {
-        int cap, cvalue, fbvalue;
-
-        cap = criteria[j].capability;
-        cvalue = criteria[j].value;
-        if (cap == NUM) {
-          fbvalue = numok;
-        } else {
-          fbvalue = fbmodes[i].cap[cap];
-        }
-#ifdef TEST
-        if (verbose)
-          printf("  %s %s %d to %d\n",
-            capstr[cap], compstr[criteria[j].comparison], cvalue, fbvalue);
-#endif
-        switch (criteria[j].comparison) {
-        case EQ:
-          result = cvalue == fbvalue;
-          thisScore[j] = 1;
-          break;
-        case NEQ:
-          result = cvalue != fbvalue;
-          thisScore[j] = 1;
-          break;
-        case LT:
-          result = fbvalue < cvalue;
-          thisScore[j] = fbvalue - cvalue;
-          break;
-        case GT:
-          result = fbvalue > cvalue;
-          thisScore[j] = fbvalue - cvalue;
-          break;
-        case LTE:
-          result = fbvalue <= cvalue;
-          thisScore[j] = fbvalue - cvalue;
-          break;
-        case GTE:
-          result = (fbvalue >= cvalue);
-          thisScore[j] = fbvalue - cvalue;
-          break;
-        case MIN:
-          result = fbvalue >= cvalue;
-          thisScore[j] = cvalue - fbvalue;
-          break;
-        }
-
-#ifdef TEST
-        if (verbose)
-          printf("                result=%d   score=%d   bestScore=%d\n", result, thisScore[j], bestScore[j]);
-#endif
-
-        if (result) {
-          if (better || thisScore[j] > bestScore[j]) {
-            better = 1;
-          } else if (thisScore[j] == bestScore[j]) {
-            /* Keep looking. */
-          } else {
-            goto nextFBM;
-          }
-        } else {
-          if (cap == NUM) {
-            worse = 1;
-          } else {
-            goto nextFBM;
-          }
-        }
-
-      }
-
-      if (better && !worse) {
-        found = &fbmodes[i];
-        for (j = 0; j < ncriteria; j++) {
-          bestScore[j] = thisScore[j];
-        }
-      }
-      numok++;
-
-    nextFBM:;
-
-    }
-  }
-  free(bestScore);
-  free(thisScore);
-  if (found) {
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-    *fbc = found->fbc;
-#endif
-    return found->vi;
-  } else {
-    return NULL;
-  }
-}
-
-static int
-parseCriteria(char *word, Criterion * criterion, int *mask,
-  Bool * allowDoubleAsSingle)
-{
-  char *cstr, *vstr, *response;
-  int comparator, value = 0;
-  int rgb, rgba, acc, acca, count, i;
-
-  cstr = strpbrk(word, "=><!~");
-  if (cstr) {
-    switch (cstr[0]) {
-    case '=':
-      comparator = EQ;
-      vstr = &cstr[1];
-      break;
-    case '~':
-      comparator = MIN;
-      vstr = &cstr[1];
-      break;
-    case '>':
-      if (cstr[1] == '=') {
-        comparator = GTE;
-        vstr = &cstr[2];
-      } else {
-        comparator = GT;
-        vstr = &cstr[1];
-      }
-      break;
-    case '<':
-      if (cstr[1] == '=') {
-        comparator = LTE;
-        vstr = &cstr[2];
-      } else {
-        comparator = LT;
-        vstr = &cstr[1];
-      }
-      break;
-    case '!':
-      if (cstr[1] == '=') {
-        comparator = NEQ;
-        vstr = &cstr[2];
-      } else {
-        return -1;
-      }
-      break;
-    default:
-      return -1;
-    }
-    value = (int) strtol(vstr, &response, 0);
-    if (response == vstr) {
-      /* Not a valid number. */
-      return -1;
-    }
-    *cstr = '\0';
-  } else {
-    comparator = NONE;
-  }
-  switch (word[0]) {
-  case 'a':
-    if (!strcmp(word, "alpha")) {
-      criterion[0].capability = ALPHA_SIZE;
-      if (comparator == NONE) {
-        criterion[0].comparison = GTE;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << RGBA);
-      *mask |= (1 << ALPHA_SIZE);
-      *mask |= (1 << RGBA_MODE);
-      return 1;
-    }
-    acca = !strcmp(word, "acca");
-    acc = !strcmp(word, "acc");
-    if (acc || acca) {
-      criterion[0].capability = ACCUM_RED_SIZE;
-      criterion[1].capability = ACCUM_GREEN_SIZE;
-      criterion[2].capability = ACCUM_BLUE_SIZE;
-      criterion[3].capability = ACCUM_ALPHA_SIZE;
-      if (acca) {
-        count = 4;
-      } else {
-        count = 3;
-        criterion[3].comparison = MIN;
-        criterion[3].value = 0;
-      }
-      if (comparator == NONE) {
-        comparator = GTE;
-        value = 8;
-      }
-      for (i = 0; i < count; i++) {
-        criterion[i].comparison = comparator;
-        criterion[i].value = value;
-      }
-      *mask |= (1 << ACCUM_RED_SIZE);
-      return 4;
-    }
-    if (!strcmp(word, "auxbufs")) {
-      criterion[0].capability = AUX_BUFFERS;
-      if (comparator == NONE) {
-        criterion[0].comparison = MIN;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << AUX_BUFFERS);
-      return 1;
-    }
-    return -1;
-  case 'b':
-    if (!strcmp(word, "blue")) {
-      criterion[0].capability = BLUE_SIZE;
-      if (comparator == NONE) {
-        criterion[0].comparison = GTE;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << RGBA);
-      *mask |= (1 << RGBA_MODE);
-      return 1;
-    }
-    if (!strcmp(word, "buffer")) {
-      criterion[0].capability = BUFFER_SIZE;
-      if (comparator == NONE) {
-        criterion[0].comparison = GTE;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      return 1;
-    }
-    return -1;
-  case 'c':
-    if (!strcmp(word, "conformant")) {
-      criterion[0].capability = CONFORMANT;
-      if (comparator == NONE) {
-        criterion[0].comparison = EQ;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << CONFORMANT);
-      return 1;
-    }
-    return -1;
-  case 'd':
-    if (!strcmp(word, "depth")) {
-      criterion[0].capability = DEPTH_SIZE;
-      if (comparator == NONE) {
-        criterion[0].comparison = GTE;
-        criterion[0].value = 12;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << DEPTH_SIZE);
-      return 1;
-    }
-    if (!strcmp(word, "double")) {
-      criterion[0].capability = DOUBLEBUFFER;
-      if (comparator == NONE) {
-        criterion[0].comparison = EQ;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << DOUBLEBUFFER);
-      return 1;
-    }
-    return -1;
-  case 'g':
-    if (!strcmp(word, "green")) {
-      criterion[0].capability = GREEN_SIZE;
-      if (comparator == NONE) {
-        criterion[0].comparison = GTE;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << RGBA);
-      *mask |= (1 << RGBA_MODE);
-      return 1;
-    }
-    return -1;
-  case 'i':
-    if (!strcmp(word, "index")) {
-      criterion[0].capability = RGBA;
-      criterion[0].comparison = EQ;
-      criterion[0].value = 0;
-      *mask |= (1 << RGBA);
-      *mask |= (1 << CI_MODE);
-      criterion[1].capability = BUFFER_SIZE;
-      if (comparator == NONE) {
-        criterion[1].comparison = GTE;
-        criterion[1].value = 1;
-      } else {
-        criterion[1].comparison = comparator;
-        criterion[1].value = value;
-      }
-      return 2;
-    }
-    return -1;
-  case 'l':
-    if (!strcmp(word, "luminance")) {
-      criterion[0].capability = RGBA;
-      criterion[0].comparison = EQ;
-      criterion[0].value = 1;
-
-      criterion[1].capability = RED_SIZE;
-      if (comparator == NONE) {
-        criterion[1].comparison = GTE;
-        criterion[1].value = 1;
-      } else {
-        criterion[1].comparison = comparator;
-        criterion[1].value = value;
-      }
-
-      criterion[2].capability = GREEN_SIZE;
-      criterion[2].comparison = EQ;
-      criterion[2].value = 0;
-
-      criterion[3].capability = BLUE_SIZE;
-      criterion[3].comparison = EQ;
-      criterion[3].value = 0;
-
-      *mask |= (1 << RGBA);
-      *mask |= (1 << RGBA_MODE);
-      *mask |= (1 << LUMINANCE_MODE);
-      return 4;
-    }
-    return -1;
-  case 'n':
-    if (!strcmp(word, "num")) {
-      criterion[0].capability = NUM;
-      if (comparator == NONE) {
-        return -1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-        return 1;
-      }
-    }
-    return -1;
-  case 'r':
-    if (!strcmp(word, "red")) {
-      criterion[0].capability = RED_SIZE;
-      if (comparator == NONE) {
-        criterion[0].comparison = GTE;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << RGBA);
-      *mask |= (1 << RGBA_MODE);
-      return 1;
-    }
-    rgba = !strcmp(word, "rgba");
-    rgb = !strcmp(word, "rgb");
-    if (rgb || rgba) {
-      criterion[0].capability = RGBA;
-      criterion[0].comparison = EQ;
-      criterion[0].value = 1;
-
-      criterion[1].capability = RED_SIZE;
-      criterion[2].capability = GREEN_SIZE;
-      criterion[3].capability = BLUE_SIZE;
-      criterion[4].capability = ALPHA_SIZE;
-      if (rgba) {
-        count = 5;
-      } else {
-        count = 4;
-        criterion[4].comparison = MIN;
-        criterion[4].value = 0;
-      }
-      if (comparator == NONE) {
-        comparator = GTE;
-        value = 1;
-      }
-      for (i = 1; i < count; i++) {
-        criterion[i].comparison = comparator;
-        criterion[i].value = value;
-      }
-      *mask |= (1 << RGBA);
-      *mask |= (1 << RGBA_MODE);
-      return 5;
-    }
-    return -1;
-  case 's':
-    if (!strcmp(word, "stencil")) {
-      criterion[0].capability = STENCIL_SIZE;
-      if (comparator == NONE) {
-        criterion[0].comparison = MIN;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << STENCIL_SIZE);
-      return 1;
-    }
-    if (!strcmp(word, "single")) {
-      criterion[0].capability = DOUBLEBUFFER;
-      if (comparator == NONE) {
-        criterion[0].comparison = EQ;
-        criterion[0].value = 0;
-        *allowDoubleAsSingle = True;
-        *mask |= (1 << DOUBLEBUFFER);
-        return 1;
-      } else {
-        return -1;
-      }
-    }
-    if (!strcmp(word, "stereo")) {
-      criterion[0].capability = STEREO;
-      if (comparator == NONE) {
-        criterion[0].comparison = EQ;
-        criterion[0].value = 1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << STEREO);
-      return 1;
-    }
-    if (!strcmp(word, "samples")) {
-      criterion[0].capability = SAMPLES;
-      if (comparator == NONE) {
-        criterion[0].comparison = LTE;
-        criterion[0].value = 4;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << SAMPLES);
-      return 1;
-    }
-    if (!strcmp(word, "slow")) {
-      criterion[0].capability = SLOW;
-      if (comparator == NONE) {
-        /* Just "slow" means permit fast visuals, but accept
-           slow ones in preference. Presumably the slow ones
-           must be higher quality or something else desirable. */
-        criterion[0].comparison = GTE;
-        criterion[0].value = 0;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-      }
-      *mask |= (1 << SLOW);
-      return 1;
-    }
-    return -1;
-#if defined(_WIN32)
-  case 'w':
-    if (!strcmp(word, "win32pfd")) {
-      criterion[0].capability = XVISUAL;
-      if (comparator == NONE) {
-        return -1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-        return 1;
-      }
-    }
-    return -1;
-#endif
-#if !defined(_WIN32)
-  case 'x':
-    if (!strcmp(word, "xvisual")) {
-      if (comparator == NONE) {
-        return -1;
-      } else {
-        criterion[0].capability = XVISUAL;
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-        /* Set everything in "mask" so that no default criteria
-           get used.  Assume the program really wants the
-           xvisual specified. */
-        *mask |= ~0;
-        return 1;
-      }
-    }
-    /* Be a little over-eager to fill in the comparison and
-       value so we won't have to replicate the code after each
-       string match. */
-    if (comparator == NONE) {
-      criterion[0].comparison = EQ;
-      criterion[0].value = 1;
-    } else {
-      criterion[0].comparison = comparator;
-      criterion[0].value = value;
-    }
-
-    if (!strcmp(word, "xstaticgray")) {
-      criterion[0].capability = XSTATICGRAY;
-      *mask |= (1 << XSTATICGRAY);  /* Indicates _any_ visual
-                                       class selected. */
-      return 1;
-    }
-    if (!strcmp(word, "xgrayscale")) {
-      criterion[0].capability = XGRAYSCALE;
-      *mask |= (1 << XSTATICGRAY);  /* Indicates _any_ visual
-                                       class selected. */
-      return 1;
-    }
-    if (!strcmp(word, "xstaticcolor")) {
-      criterion[0].capability = XSTATICCOLOR;
-      *mask |= (1 << XSTATICGRAY);  /* Indicates _any_ visual
-                                       class selected. */
-      return 1;
-    }
-    if (!strcmp(word, "xpseudocolor")) {
-      criterion[0].capability = XPSEUDOCOLOR;
-      *mask |= (1 << XSTATICGRAY);  /* Indicates _any_ visual
-                                       class selected. */
-      return 1;
-    }
-    if (!strcmp(word, "xtruecolor")) {
-      criterion[0].capability = XTRUECOLOR;
-      *mask |= (1 << XSTATICGRAY);  /* Indicates _any_ visual
-                                       class selected. */
-      return 1;
-    }
-    if (!strcmp(word, "xdirectcolor")) {
-      criterion[0].capability = XDIRECTCOLOR;
-      *mask |= (1 << XSTATICGRAY);  /* Indicates _any_ visual
-                                       class selected. */
-      return 1;
-    }
-    return -1;
-#endif
-  default:
-    return -1;
-  }
-}
-
-static Criterion *
-parseModeString(char *mode, int *ncriteria, Bool * allowDoubleAsSingle,
-  Criterion * requiredCriteria, int nRequired, int requiredMask)
-{
-  Criterion *criteria = NULL;
-  int n, mask, parsed, i;
-  char *copy, *word;
-
-  *allowDoubleAsSingle = False;
-  copy = __glutStrdup(mode);
-  /* Attempt to estimate how many criteria entries should be
-     needed. */
-  n = 0;
-  word = strtok(copy, " \t");
-  while (word) {
-    n++;
-    word = strtok(NULL, " \t");
-  }
-  /* Overestimate by 4 times ("rgba" might add four criteria
-     entries) plus add in possible defaults plus space for
-     required criteria. */
-  criteria = (Criterion *) malloc((4 * n + 30 + nRequired) * sizeof(Criterion));
-  if (!criteria) {
-    __glutFatalError("out of memory.");
-  }
-
-  /* Re-copy the copy of the mode string. */
-  strcpy(copy, mode);
-
-  /* First add the required criteria (these match at the
-     highest priority). Typically these will be used to force a
-     specific level (layer), transparency, and/or visual type. */
-  mask = requiredMask;
-  for (i = 0; i < nRequired; i++) {
-    criteria[i] = requiredCriteria[i];
-  }
-  n = nRequired;
-
-  word = strtok(copy, " \t");
-  while (word) {
-    parsed = parseCriteria(word, &criteria[n], &mask, allowDoubleAsSingle);
-    if (parsed >= 0) {
-      n += parsed;
-    } else {
-      __glutWarning("Unrecognized display string word: %s (ignoring)\n", word);
-    }
-    word = strtok(NULL, " \t");
-  }
-
-#if defined(GLX_VERSION_1_1) && (defined(GLX_SGIS_multisample) || defined(GLX_ARB_multisample))
-  if (__glutIsSupportedByGLX("GLX_SGIS_multisample") ||
-      __glutIsSupportedByGLX("GLX_ARB_multisample")) {
-    if (!(mask & (1 << SAMPLES))) {
-      criteria[n].capability = SAMPLES;
-      criteria[n].comparison = EQ;
-      criteria[n].value = 0;
-      n++;
-    } else {
-      /* Multisample visuals are marked nonconformant.  If
-         multisampling was requeste and no conformant
-         preference was set, assume that we will settle for a
-         non-conformant visual to get multisampling. */
-      if (!(mask & (1 << CONFORMANT))) {
-        criteria[n].capability = CONFORMANT;
-        criteria[n].comparison = MIN;
-        criteria[n].value = 0;
-        n++;
-        mask |= (1 << CONFORMANT);
-      }
-    }
-  }
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info)
-  if (__glutIsSupportedByGLX("GLX_EXT_visual_info")) {
-    if (!(mask & (1 << TRANSPARENT))) {
-      criteria[n].capability = TRANSPARENT;
-      criteria[n].comparison = EQ;
-      criteria[n].value = 0;
-      n++;
-    }
-  }
-#endif
-#if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_rating)
-  if (__glutIsSupportedByGLX("GLX_EXT_visual_rating")) {
-    if (!(mask & (1 << SLOW))) {
-      criteria[n].capability = SLOW;
-      criteria[n].comparison = EQ;
-      criteria[n].value = 0;
-      n++;
-    }
-    if (!(mask & (1 << CONFORMANT))) {
-      criteria[n].capability = CONFORMANT;
-      criteria[n].comparison = EQ;
-      criteria[n].value = 1;
-      n++;
-    }
-  }
-#endif
-  if (!(mask & (1 << ACCUM_RED_SIZE))) {
-    criteria[n].capability = ACCUM_RED_SIZE;
-    criteria[n].comparison = MIN;
-    criteria[n].value = 0;
-    criteria[n + 1].capability = ACCUM_GREEN_SIZE;
-    criteria[n + 1].comparison = MIN;
-    criteria[n + 1].value = 0;
-    criteria[n + 2].capability = ACCUM_BLUE_SIZE;
-    criteria[n + 2].comparison = MIN;
-    criteria[n + 2].value = 0;
-    criteria[n + 3].capability = ACCUM_ALPHA_SIZE;
-    criteria[n + 3].comparison = MIN;
-    criteria[n + 3].value = 0;
-    n += 4;
-  }
-  if (!(mask & (1 << AUX_BUFFERS))) {
-    criteria[n].capability = AUX_BUFFERS;
-    criteria[n].comparison = MIN;
-    criteria[n].value = 0;
-    n++;
-  }
-  if (!(mask & (1 << RGBA))) {
-    criteria[n].capability = RGBA;
-    criteria[n].comparison = EQ;
-    criteria[n].value = 1;
-    criteria[n + 1].capability = RED_SIZE;
-    criteria[n + 1].comparison = GTE;
-    criteria[n + 1].value = 1;
-    criteria[n + 2].capability = GREEN_SIZE;
-    criteria[n + 2].comparison = GTE;
-    criteria[n + 2].value = 1;
-    criteria[n + 3].capability = BLUE_SIZE;
-    criteria[n + 3].comparison = GTE;
-    criteria[n + 3].value = 1;
-    criteria[n + 4].capability = ALPHA_SIZE;
-    criteria[n + 4].comparison = MIN;
-    criteria[n + 4].value = 0;
-    n += 5;
-    mask |= (1 << RGBA_MODE);
-  }
-#if !defined(_WIN32)
-  if (!(mask & (1 << XSTATICGRAY))) {
-    assert(isMesaGLX != -1);
-    if ((mask & (1 << RGBA_MODE)) && !isMesaGLX) {
-      /* Normally, request an RGBA mode visual be TrueColor,
-         except in the case of Mesa where we trust Mesa (and
-         other code in GLUT) to handle any type of RGBA visual
-         reasonably. */
-      if (mask & (1 << LUMINANCE_MODE)) {
-       /* If RGBA luminance was requested, actually go for
-          a StaticGray visual. */
-        criteria[n].capability = XSTATICGRAY;
-      } else {
-        criteria[n].capability = XTRUECOLOR;
-      }
-      criteria[n].value = 1;
-      criteria[n].comparison = EQ;
-
-      n++;
-    }
-    if (mask & (1 << CI_MODE)) {
-      criteria[n].capability = XPSEUDOCOLOR;
-      criteria[n].value = 1;
-      criteria[n].comparison = EQ;
-      n++;
-    }
-  }
-#endif
-  if (!(mask & (1 << STEREO))) {
-    criteria[n].capability = STEREO;
-    criteria[n].comparison = EQ;
-    criteria[n].value = 0;
-    n++;
-  }
-  if (!(mask & (1 << DOUBLEBUFFER))) {
-    criteria[n].capability = DOUBLEBUFFER;
-    criteria[n].comparison = EQ;
-    criteria[n].value = 0;
-    *allowDoubleAsSingle = True;
-    n++;
-  }
-  if (!(mask & (1 << DEPTH_SIZE))) {
-    criteria[n].capability = DEPTH_SIZE;
-    criteria[n].comparison = MIN;
-    criteria[n].value = 0;
-    n++;
-  }
-  if (!(mask & (1 << STENCIL_SIZE))) {
-    criteria[n].capability = STENCIL_SIZE;
-    criteria[n].comparison = MIN;
-    criteria[n].value = 0;
-    n++;
-  }
-  if (!(mask & (1 << LEVEL))) {
-    criteria[n].capability = LEVEL;
-    criteria[n].comparison = EQ;
-    criteria[n].value = 0;
-    n++;
-  }
-  if (n) {
-    /* Since over-estimated the size needed; squeeze it down to
-       reality. */
-    criteria = (Criterion *) realloc(criteria, n * sizeof(Criterion));
-    if (!criteria) {
-      /* Should never happen since should be shrinking down! */
-      __glutFatalError("out of memory.");
-    }
-  } else {
-    /* For portability, avoid "realloc(ptr,0)" call. */
-    free(criteria);
-    criteria = NULL;
-  }
-
-  free(copy);
-  *ncriteria = n;
-  return criteria;
-}
-
-static FrameBufferMode *fbmodes = NULL;
-static int nfbmodes = 0;
-
-static XVisualInfo *
-getVisualInfoFromString(char *string, Bool * treatAsSingle,
-  Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc)
-{
-  Criterion *criteria;
-  XVisualInfo *visinfo;
-  Bool allowDoubleAsSingle;
-  int ncriteria, i;
-
-  if (!fbmodes) {
-    fbmodes = loadVisuals(&nfbmodes);
-  }
-  criteria = parseModeString(string, &ncriteria,
-    &allowDoubleAsSingle, requiredCriteria, nRequired, requiredMask);
-  if (criteria == NULL) {
-    __glutWarning("failed to parse mode string");
-    return NULL;
-  }
-#ifdef TEST
-  printCriteria(criteria, ncriteria);
-#endif
-  visinfo = findMatch(fbmodes, nfbmodes, criteria, ncriteria, fbc);
-  if (visinfo) {
-    *treatAsSingle = 0;
-  } else {
-    if (allowDoubleAsSingle) {
-      /* Rewrite criteria so that we now look for a double
-         buffered visual which will then get treated as a
-         single buffered visual. */
-      for (i = 0; i < ncriteria; i++) {
-        if (criteria[i].capability == DOUBLEBUFFER
-          && criteria[i].comparison == EQ
-          && criteria[i].value == 0) {
-          criteria[i].value = 1;
-        }
-      }
-      visinfo = findMatch(fbmodes, nfbmodes, criteria, ncriteria, fbc);
-      if (visinfo) {
-        *treatAsSingle = 1;
-      }
-    }
-  }
-  free(criteria);
-
-  if (visinfo) {
-#if defined(_WIN32)
-    /* We could have a valid pixel format for drawing to a
-       bitmap. However, we don't want to draw into a bitmap, we 
-       need one that can be used with a window, so make sure
-       that this is true. */
-    if (!(visinfo->dwFlags & PFD_DRAW_TO_WINDOW))
-      return NULL;
-#endif
-    return visinfo;
-  } else {
-    return NULL;
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutInitDisplayString(const char *string)
-{
-#ifdef _WIN32
-  XHDC = GetDC(GetDesktopWindow());
-#endif
-
-  __glutDetermineVisualFromString = getVisualInfoFromString;
-  if (__glutDisplayString) {
-    free(__glutDisplayString);
-  }
-  if (string) {
-    __glutDisplayString = __glutStrdup(string);
-    if (!__glutDisplayString)
-      __glutFatalError("out of memory.");
-  } else {
-    __glutDisplayString = NULL;
-  }
-}
-/* ENDCENTRY */
-
-#ifdef TEST
-
-Criterion requiredWindowCriteria[] =
-{
-  {LEVEL, EQ, 0},
-  {TRANSPARENT, EQ, 0}
-};
-int numRequiredWindowCriteria = sizeof(requiredWindowCriteria) / sizeof(Criterion);
-int requiredWindowCriteriaMask = (1 << LEVEL) | (1 << TRANSPARENT);
-
-Criterion requiredOverlayCriteria[] =
-{
-  {LEVEL, EQ, 1},
-  {TRANSPARENT, EQ, 1},
-  {XPSEUDOCOLOR, EQ, 1},
-  {RGBA, EQ, 0},
-  {BUFFER_SIZE, GTE, 1}
-};
-int numRequiredOverlayCriteria = sizeof(requiredOverlayCriteria) / sizeof(Criterion);
-int requiredOverlayCriteriaMask =
-(1 << LEVEL) | (1 << TRANSPARENT) | (1 << XSTATICGRAY) | (1 << RGBA) | (1 << CI_MODE);
-
-int
-main(int argc, char **argv)
-{
-  Display *dpy;
-  XVisualInfo *vinfo;
-  Bool treatAsSingle;
-  char *str, buffer[1024];
-  int tty = isatty(fileno(stdin));
-  int overlay = 0, showconfig = 0;
-  void *fbc;
-
-#if !defined(_WIN32)
-  dpy = XOpenDisplay(NULL);
-  if (dpy == NULL) {
-    printf("Could not connect to X server\n");
-    exit(1);
-  }
-  __glutDisplay = dpy;
-  __glutScreen = DefaultScreen(__glutDisplay);
-#endif
-  while (!feof(stdin)) {
-    if (tty)
-      printf("dstr> ");
-    str = fgets(buffer, 1023, stdin);
-    if (str) {
-      printf("\n");
-      if (!strcmp("v", str)) {
-        verbose = 1 - verbose;
-        printf("verbose = %d\n\n", verbose);
-      } else if (!strcmp("s", str)) {
-        showconfig = 1 - showconfig;
-        printf("showconfig = %d\n\n", showconfig);
-      } else if (!strcmp("o", str)) {
-        overlay = 1 - overlay;
-        printf("overlay = %d\n\n", overlay);
-      } else {
-        if (overlay) {
-          vinfo = getVisualInfoFromString(str, &treatAsSingle,
-            requiredOverlayCriteria, numRequiredOverlayCriteria, requiredOverlayCriteriaMask, &fbc);
-        } else {
-          vinfo = getVisualInfoFromString(str, &treatAsSingle,
-            requiredWindowCriteria, numRequiredWindowCriteria, requiredWindowCriteriaMask, &fbc);
-        }
-        if (vinfo) {
-          printf("\n");
-          if (!tty)
-            printf("Display string: %s", str);
-#ifdef _WIN32
-          printf("Visual = 0x%x\n", 0);
-#else
-          printf("Visual = 0x%x%s\n", vinfo->visualid, fbc ? " (needs FBC)" : "");
-#endif
-          if (treatAsSingle) {
-            printf("Treat as SINGLE.\n");
-          }
-          if (showconfig) {
-            int glxCapable, bufferSize, level, renderType, doubleBuffer,
-              stereo, auxBuffers, redSize, greenSize, blueSize,
-              alphaSize, depthSize, stencilSize, acRedSize, acGreenSize,
-              acBlueSize, acAlphaSize;
-
-            glXGetConfig(dpy, vinfo, GLX_BUFFER_SIZE, &bufferSize);
-            glXGetConfig(dpy, vinfo, GLX_LEVEL, &level);
-            glXGetConfig(dpy, vinfo, GLX_RGBA, &renderType);
-            glXGetConfig(dpy, vinfo, GLX_DOUBLEBUFFER, &doubleBuffer);
-            glXGetConfig(dpy, vinfo, GLX_STEREO, &stereo);
-            glXGetConfig(dpy, vinfo, GLX_AUX_BUFFERS, &auxBuffers);
-            glXGetConfig(dpy, vinfo, GLX_RED_SIZE, &redSize);
-            glXGetConfig(dpy, vinfo, GLX_GREEN_SIZE, &greenSize);
-            glXGetConfig(dpy, vinfo, GLX_BLUE_SIZE, &blueSize);
-            glXGetConfig(dpy, vinfo, GLX_ALPHA_SIZE, &alphaSize);
-            glXGetConfig(dpy, vinfo, GLX_DEPTH_SIZE, &depthSize);
-            glXGetConfig(dpy, vinfo, GLX_STENCIL_SIZE, &stencilSize);
-            glXGetConfig(dpy, vinfo, GLX_ACCUM_RED_SIZE, &acRedSize);
-            glXGetConfig(dpy, vinfo, GLX_ACCUM_GREEN_SIZE, &acGreenSize);
-            glXGetConfig(dpy, vinfo, GLX_ACCUM_BLUE_SIZE, &acBlueSize);
-            glXGetConfig(dpy, vinfo, GLX_ACCUM_ALPHA_SIZE, &acAlphaSize);
-            printf("RGBA = (%d, %d, %d, %d)\n", redSize, greenSize, blueSize, alphaSize);
-            printf("acc  = (%d, %d, %d, %d)\n", acRedSize, acGreenSize, acBlueSize, acAlphaSize);
-            printf("db   = %d\n", doubleBuffer);
-            printf("str  = %d\n", stereo);
-            printf("aux  = %d\n", auxBuffers);
-            printf("lvl  = %d\n", level);
-            printf("buf  = %d\n", bufferSize);
-            printf("rgba = %d\n", renderType);
-            printf("z    = %d\n", depthSize);
-            printf("s    = %d\n", stencilSize);
-          }
-        } else {
-          printf("\n");
-          printf("No match.\n");
-        }
-        printf("\n");
-      }
-    }
-  }
-  printf("\n");
-  return 0;
-}
-#endif
diff --git a/src/glut/glx/glut_event.c b/src/glut/glx/glut_event.c
deleted file mode 100644 (file)
index c450ee9..0000000
+++ /dev/null
@@ -1,1391 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1997, 1998. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <assert.h>
-#include <string.h>  /* Some FD_ZERO macros use memset without
-                        prototyping memset. */
-
-/* Much of the following #ifdef logic to include the proper
-   prototypes for the select system call is based on logic
-   from the X11R6.3 version of <X11/Xpoll.h>. */
-
-#if !defined(_WIN32)
-# ifdef __sgi
-#  include <bstring.h>    /* prototype for bzero used by FD_ZERO */
-# endif
-# if (defined(__FreeBSD__) || defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE)
-#  include <sys/select.h> /* select system call interface */
-#  ifdef luna
-#   include <sysent.h>
-#  endif
-# endif
-  /* AIX 4.2 fubar-ed <sys/select.h>, so go to heroic measures to get it */
-# if defined(AIXV4) && !defined(NFDBITS)
-#  include <sys/select.h>
-# endif
-#endif /* !_WIN32 */
-
-#include <sys/types.h>
-
-#if !defined(_WIN32)
-# if defined(__vms) && ( __VMS_VER < 70000000 )
-#  include <sys/time.h>
-# else
-#  ifndef __vms
-#   include <sys/time.h>
-#  endif
-# endif
-# include <unistd.h>
-# include <X11/Xlib.h>
-# include <X11/keysym.h>
-#else
-# ifdef __CYGWIN32__
-#  include <sys/time.h>
-# else
-#  include <sys/timeb.h>
-# endif
-# ifdef __hpux
-   /* XXX Bert Gijsbers <bert@mc.bio.uva.nl> reports that HP-UX
-      needs different keysyms for the End, Insert, and Delete keys
-      to work on an HP 715.  It would be better if HP generated
-      standard keysyms for standard keys. */
-#  include <X11/HPkeysym.h>
-# endif
-#endif /* !_WIN32 */
-
-#include "glutint.h"
-
-#if defined(__vms) && ( __VMS_VER < 70000000 )
-#include <ssdef.h>
-#include <psldef.h>
-extern int SYS$CLREF(int efn);
-extern int SYS$SETIMR(unsigned int efn, struct timeval6 *timeout, void *ast,
-  unsigned int request_id, unsigned int flags);
-extern int SYS$WFLOR(unsigned int efn, unsigned int mask);
-extern int SYS$CANTIM(unsigned int request_id, unsigned int mode);
-#endif /* __vms, VMs 6.2 or earlier */
-
-static GLUTtimer *freeTimerList = NULL;
-
-GLUTidleCB __glutIdleFunc = NULL;
-GLUTtimer *__glutTimerList = NULL;
-#ifdef SUPPORT_FORTRAN
-GLUTtimer *__glutNewTimer;
-#endif
-GLUTwindow *__glutWindowWorkList = NULL;
-GLUTmenu *__glutMappedMenu;
-GLUTmenu *__glutCurrentMenu = NULL;
-
-void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *);
-#if !defined(_WIN32)
-void (*__glutMenuItemEnterOrLeave)(GLUTmenuItem * item, int num, int type) = NULL;
-void (*__glutFinishMenu)(Window win, int x, int y);
-void (*__glutPaintMenu)(GLUTmenu * menu);
-void (*__glutStartMenu)(GLUTmenu * menu, GLUTwindow * window, int x, int y, int x_win, int y_win);
-GLUTmenu * (*__glutGetMenuByNum)(int menunum);
-GLUTmenuItem * (*__glutGetMenuItem)(GLUTmenu * menu, Window win, int *which);
-GLUTmenu * (*__glutGetMenu)(Window win);
-#endif
-
-Atom __glutMotifHints = None;
-/* Modifier mask of ~0 implies not in core input callback. */
-unsigned int __glutModifierMask = (unsigned int) ~0;
-int __glutWindowDamaged = 0;
-
-void GLUTAPIENTRY
-glutIdleFunc(GLUTidleCB idleFunc)
-{
-  __glutIdleFunc = idleFunc;
-}
-
-void GLUTAPIENTRY
-glutTimerFunc(unsigned int interval, GLUTtimerCB timerFunc, int value)
-{
-  GLUTtimer *timer, *other;
-  GLUTtimer **prevptr;
-#ifdef OLD_VMS
-   struct timeval6 now;
-#else
-   struct timeval now;
-#endif
-   
-  if (!timerFunc)
-    return;
-
-  if (freeTimerList) {
-    timer = freeTimerList;
-    freeTimerList = timer->next;
-  } else {
-    timer = (GLUTtimer *) malloc(sizeof(GLUTtimer));
-    if (!timer)
-      __glutFatalError("out of memory.");
-  }
-
-  timer->func = timerFunc;
-#if defined(__vms) && ( __VMS_VER < 70000000 )
-  /* VMS time is expressed in units of 100 ns */
-  timer->timeout.val = interval * TICKS_PER_MILLISECOND;
-#else
-  timer->timeout.tv_sec = (int) interval / 1000;
-  timer->timeout.tv_usec = (int) (interval % 1000) * 1000;
-#endif
-  timer->value = value;
-  timer->next = NULL;
-  GETTIMEOFDAY(&now);
-  ADD_TIME(timer->timeout, timer->timeout, now);
-  prevptr = &__glutTimerList;
-  other = *prevptr;
-  while (other && IS_AFTER(other->timeout, timer->timeout)) {
-    prevptr = &other->next;
-    other = *prevptr;
-  }
-  timer->next = other;
-#ifdef SUPPORT_FORTRAN
-  __glutNewTimer = timer;  /* for Fortran binding! */
-#endif
-  *prevptr = timer;
-}
-
-void
-handleTimeouts(void)
-{
-#ifdef OLD_VMS
-   struct timeval6 now;
-#else
-   struct timeval now;
-#endif
-   GLUTtimer *timer;
-
-  /* Assumption is that __glutTimerList is already determined
-     to be non-NULL. */
-  GETTIMEOFDAY(&now);
-  while (IS_AT_OR_AFTER(__glutTimerList->timeout, now)) {
-    timer = __glutTimerList;
-    /* call the timer function */
-    timer->func(timer->value);
-    /* remove from the linked list */
-    __glutTimerList = timer->next;
-    /* put this timer on the "free" list */
-    timer->next = freeTimerList;
-    freeTimerList = timer;
-
-    if (!__glutTimerList)
-      break;
-  }
-}
-
-void
-__glutPutOnWorkList(GLUTwindow * window, int workMask)
-{
-  if (window->workMask) {
-    /* Already on list; just OR in new workMask. */
-    window->workMask |= workMask;
-  } else {
-    /* Update work mask and add to window work list. */
-    window->workMask = workMask;
-    /* Assert that if the window does not have a
-       workMask already, the window should definitely
-       not be the head of the work list. */
-    assert(window != __glutWindowWorkList);
-    window->prevWorkWin = __glutWindowWorkList;
-    __glutWindowWorkList = window;
-  }
-}
-
-void
-__glutPostRedisplay(GLUTwindow * window, int layerMask)
-{
-  int shown = (layerMask & (GLUT_REDISPLAY_WORK | GLUT_REPAIR_WORK)) ?
-    window->shownState : window->overlay->shownState;
-
-  /* Post a redisplay if the window is visible (or the
-     visibility of the window is unknown, ie. window->visState
-     == -1) _and_ the layer is known to be shown. */
-  if (window->visState != GLUT_HIDDEN
-    && window->visState != GLUT_FULLY_COVERED && shown) {
-    __glutPutOnWorkList(window, layerMask);
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutPostRedisplay(void)
-{
-  __glutPostRedisplay(__glutCurrentWindow, GLUT_REDISPLAY_WORK);
-}
-
-/* The advantage of this routine is that it saves the cost of a
-   glutSetWindow call (entailing an expensive OpenGL context switch),
-   particularly useful when multiple windows need redisplays posted at
-   the same times.  See also glutPostWindowOverlayRedisplay. */
-void GLUTAPIENTRY
-glutPostWindowRedisplay(int win)
-{
-  __glutPostRedisplay(__glutWindowList[win - 1], GLUT_REDISPLAY_WORK);
-}
-
-/* ENDCENTRY */
-static GLUTeventParser *eventParserList = NULL;
-
-/* __glutRegisterEventParser allows another module to register
-   to intercept X events types not otherwise acted on by the
-   GLUT processEventsAndTimeouts routine.  The X Input
-   extension support code uses an event parser for handling X
-   Input extension events.  */
-
-void
-__glutRegisterEventParser(GLUTeventParser * parser)
-{
-  parser->next = eventParserList;
-  eventParserList = parser;
-}
-
-
-#if !defined(_WIN32)
-static void
-markWindowHidden(GLUTwindow * window)
-{
-  if (GLUT_HIDDEN != window->visState) {
-    GLUTwindow *child;
-
-    if (window->windowStatus) {
-      window->visState = GLUT_HIDDEN;
-      __glutSetWindow(window);
-      window->windowStatus(GLUT_HIDDEN);
-    }
-    /* An unmap is only reported on a single window; its
-       descendents need to know they are no longer visible. */
-    child = window->children;
-    while (child) {
-      markWindowHidden(child);
-      child = child->siblings;
-    }
-  }
-}
-
-static void
-purgeStaleWindow(Window win)
-{
-  GLUTstale **pEntry = &__glutStaleWindowList;
-  GLUTstale *entry = __glutStaleWindowList;
-
-  /* Tranverse singly-linked stale window list look for the
-     window ID. */
-  while (entry) {
-    if (entry->win == win) {
-      /* Found it; delete it. */
-      *pEntry = entry->next;
-      free(entry);
-      return;
-    } else {
-      pEntry = &entry->next;
-      entry = *pEntry;
-    }
-  }
-}
-
-/* Unlike XNextEvent, if a signal arrives,
-   interruptibleXNextEvent will return (with a zero return
-   value).  This helps GLUT drop out of XNextEvent if a signal
-   is delivered.  The intent is so that a GLUT program can call 
-   glutIdleFunc in a signal handler to register an idle func
-   and then immediately get dropped into the idle func (after
-   returning from the signal handler).  The idea is to make
-   GLUT's main loop reliably interruptible by signals. */
-static int
-interruptibleXNextEvent(Display * dpy, XEvent * event)
-{
-  fd_set fds;
-  int rc;
-
-  /* Flush X protocol since XPending does not do this
-     implicitly. */
-  XFlush(__glutDisplay);
-  for (;;) {
-    if (XPending(__glutDisplay)) {
-      XNextEvent(dpy, event);
-      return 1;
-    }
-#ifndef VMS
-    /* the combination ConectionNumber-select is buggy on VMS. Sometimes it
-     * fails. This part of the code hangs the program on VMS7.2. But even
-     * without it the program seems to run correctly.
-     * Note that this is a bug in the VMS/DECWindows run-time-libraries.
-     * Compaq engeneering does not want or is not able to make a fix.
-     * (last sentence is a quotation from Compaq when I reported the
-     * problem January 2000) */
-    FD_ZERO(&fds);
-    FD_SET(__glutConnectionFD, &fds);
-    rc = select(__glutConnectionFD + 1, &fds, NULL, NULL, NULL);
-    if (rc < 0) {
-      if (errno == EINTR) {
-        return 0;
-      } else {
-        __glutFatalError("select error.");
-      }
-    }
-#endif
-  }
-}
-
-#endif
-
-static void
-processEventsAndTimeouts(void)
-{
-  do {
-#if defined(_WIN32)
-    MSG event;
-
-    if(!GetMessage(&event, NULL, 0, 0))        /* bail if no more messages */
-      exit(0);
-    TranslateMessage(&event);          /* translate virtual-key messages */
-    DispatchMessage(&event);           /* call the window proc */
-    /* see win32_event.c for event (message) processing procedures */
-#else
-    static int mappedMenuButton;
-    GLUTeventParser *parser;
-    XEvent event, ahead;
-    GLUTwindow *window;
-    GLUTkeyboardCB keyboard;
-    GLUTspecialCB special;
-    int gotEvent, width, height;
-
-    gotEvent = interruptibleXNextEvent(__glutDisplay, &event);
-    if (gotEvent) {
-      switch (event.type) {
-      case MappingNotify:
-        XRefreshKeyboardMapping((XMappingEvent *) & event);
-        break;
-      case ConfigureNotify:
-        window = __glutGetWindow(event.xconfigure.window);
-        if (window) {
-          if (window->win != event.xconfigure.window) {
-            /* Ignore ConfigureNotify sent to the overlay
-               planes. GLUT could get here because overlays
-               select for StructureNotify events to receive
-               DestroyNotify. */
-            break;
-          }
-          width = event.xconfigure.width;
-          height = event.xconfigure.height;
-          if (width != window->width || height != window->height) {
-            if (window->overlay) {
-              XResizeWindow(__glutDisplay, window->overlay->win, width, height);
-            }
-            window->width = width;
-            window->height = height;
-            __glutSetWindow(window);
-            /* Do not execute OpenGL out of sequence with
-               respect to the XResizeWindow request! */
-            glXWaitX();
-            window->reshape(width, height);
-            window->forceReshape = False;
-            /* A reshape should be considered like posting a
-               repair; this is necessary for the "Mesa
-               glXSwapBuffers to repair damage" hack to operate
-               correctly.  Without it, there's not an initial
-               back buffer render from which to blit from when
-               damage happens to the window. */
-            __glutPostRedisplay(window, GLUT_REPAIR_WORK);
-          }
-        }
-        break;
-      case Expose:
-        /* compress expose events */
-        while (XEventsQueued(__glutDisplay, QueuedAfterReading)
-          > 0) {
-          XPeekEvent(__glutDisplay, &ahead);
-          if (ahead.type != Expose ||
-            ahead.xexpose.window != event.xexpose.window) {
-            break;
-          }
-          XNextEvent(__glutDisplay, &event);
-        }
-        if (event.xexpose.count == 0) {
-          GLUTmenu *menu;
-
-          if (__glutMappedMenu &&
-            (menu = __glutGetMenu(event.xexpose.window))) {
-            __glutPaintMenu(menu);
-          } else {
-            window = __glutGetWindow(event.xexpose.window);
-            if (window) {
-              if (window->win == event.xexpose.window) {
-                __glutPostRedisplay(window, GLUT_REPAIR_WORK);
-              } else if (window->overlay && window->overlay->win == event.xexpose.window) {
-                __glutPostRedisplay(window, GLUT_OVERLAY_REPAIR_WORK);
-              }
-            }
-          }
-        } else {
-          /* there are more exposes to read; wait to redisplay */
-        }
-        break;
-      case ButtonPress:
-      case ButtonRelease:
-        if (__glutMappedMenu && event.type == ButtonRelease
-          && mappedMenuButton == event.xbutton.button) {
-          /* Menu is currently popped up and its button is
-             released. */
-          __glutFinishMenu(event.xbutton.window, event.xbutton.x, event.xbutton.y);
-        } else {
-          window = __glutGetWindow(event.xbutton.window);
-          /* added button check for mice with > 3 buttons */
-          if (window) {
-            GLUTmenu *menu;
-           int menuNum;
-
-            if (event.xbutton.button <= GLUT_MAX_MENUS)
-              menuNum = window->menu[event.xbutton.button - 1];
-            else
-              menuNum = 0;
-
-            /* Make sure that __glutGetMenuByNum is only called if there
-              really is a menu present. */
-            if ((menuNum > 0) && (menu = __glutGetMenuByNum(menuNum))) {
-              if (event.type == ButtonPress && !__glutMappedMenu) {
-                __glutStartMenu(menu, window,
-                  event.xbutton.x_root, event.xbutton.y_root,
-                  event.xbutton.x, event.xbutton.y);
-                mappedMenuButton = event.xbutton.button;
-              } else {
-                /* Ignore a release of a button with a menu
-                   attatched to it when no menu is popped up,
-                   or ignore a press when another menu is
-                   already popped up. */
-              }
-            } else if (window->mouse) {
-              __glutSetWindow(window);
-              __glutModifierMask = event.xbutton.state;
-              window->mouse(event.xbutton.button - 1,
-                event.type == ButtonRelease ?
-                GLUT_UP : GLUT_DOWN,
-                event.xbutton.x, event.xbutton.y);
-              __glutModifierMask = ~0;
-            } else {
-              /* Stray mouse events.  Ignore. */
-            }
-          } else {
-            /* Window might have been destroyed and all the 
-               events for the window may not yet be received. */
-          }
-        }
-        break;
-      case MotionNotify:
-        if (!__glutMappedMenu) {
-          window = __glutGetWindow(event.xmotion.window);
-          if (window) {
-            /* If motion function registered _and_ buttons held 
-               * down, call motion function...  */
-            if (window->motion && event.xmotion.state &
-              (Button1Mask | Button2Mask | Button3Mask)) {
-              __glutSetWindow(window);
-              window->motion(event.xmotion.x, event.xmotion.y);
-            }
-            /* If passive motion function registered _and_
-               buttons not held down, call passive motion
-               function...  */
-            else if (window->passive &&
-                ((event.xmotion.state &
-                    (Button1Mask | Button2Mask | Button3Mask)) ==
-                0)) {
-              __glutSetWindow(window);
-              window->passive(event.xmotion.x,
-                event.xmotion.y);
-            }
-          }
-        } else {
-          /* Motion events are thrown away when a pop up menu
-             is active. */
-        }
-        break;
-      case KeyPress:
-      case KeyRelease:
-        window = __glutGetWindow(event.xkey.window);
-        if (!window) {
-          break;
-        }
-       if (event.type == KeyPress) {
-         keyboard = window->keyboard;
-       } else {
-
-         /* If we are ignoring auto repeated keys for this window,
-            check if the next event in the X event queue is a KeyPress
-            for the exact same key (and at the exact same time) as the
-            key being released.  The X11 protocol will send auto
-            repeated keys as such KeyRelease/KeyPress pairs. */
-
-         if (window->ignoreKeyRepeat) {
-           if (XEventsQueued(__glutDisplay, QueuedAfterReading)) {
-             XPeekEvent(__glutDisplay, &ahead);
-             if (ahead.type == KeyPress
-               && ahead.xkey.window == event.xkey.window
-               && ahead.xkey.keycode == event.xkey.keycode
-               && ahead.xkey.time == event.xkey.time) {
-               /* Pop off the repeated KeyPress and ignore
-                  the auto repeated KeyRelease/KeyPress pair. */
-               XNextEvent(__glutDisplay, &event);
-               break;
-             }
-           }
-         }
-         keyboard = window->keyboardUp;
-       }
-        if (keyboard) {
-          char tmp[1];
-          int rc;
-
-          rc = XLookupString(&event.xkey, tmp, sizeof(tmp),
-            NULL, NULL);
-          if (rc) {
-            __glutSetWindow(window);
-            __glutModifierMask = event.xkey.state;
-            keyboard(tmp[0],
-              event.xkey.x, event.xkey.y);
-            __glutModifierMask = ~0;
-            break;
-          }
-        }
-       if (event.type == KeyPress) {
-         special = window->special;
-        } else {
-         special = window->specialUp;
-       }
-        if (special) {
-          KeySym ks;
-          int key;
-
-/* Introduced in X11R6:  (Partial list of) Keypad Functions.  Define
-   in place in case compiling against an older pre-X11R6
-   X11/keysymdef.h file. */
-#ifndef XK_KP_Home
-#define XK_KP_Home              0xFF95
-#endif
-#ifndef XK_KP_Left
-#define XK_KP_Left              0xFF96
-#endif
-#ifndef XK_KP_Up
-#define XK_KP_Up                0xFF97
-#endif
-#ifndef XK_KP_Right
-#define XK_KP_Right             0xFF98
-#endif
-#ifndef XK_KP_Down
-#define XK_KP_Down              0xFF99
-#endif
-#ifndef XK_KP_Prior
-#define XK_KP_Prior             0xFF9A
-#endif
-#ifndef XK_KP_Next
-#define XK_KP_Next              0xFF9B
-#endif
-#ifndef XK_KP_End
-#define XK_KP_End               0xFF9C
-#endif
-#ifndef XK_KP_Insert
-#define XK_KP_Insert            0xFF9E
-#endif
-#ifndef XK_KP_Delete
-#define XK_KP_Delete            0xFF9F
-#endif
-
-          ks = XLookupKeysym((XKeyEvent *) & event, 0);
-          /* XXX Verbose, but makes no assumptions about keysym
-             layout. */
-          switch (ks) {
-/* *INDENT-OFF* */
-          /* function keys */
-          case XK_F1:    key = GLUT_KEY_F1; break;
-          case XK_F2:    key = GLUT_KEY_F2; break;
-          case XK_F3:    key = GLUT_KEY_F3; break;
-          case XK_F4:    key = GLUT_KEY_F4; break;
-          case XK_F5:    key = GLUT_KEY_F5; break;
-          case XK_F6:    key = GLUT_KEY_F6; break;
-          case XK_F7:    key = GLUT_KEY_F7; break;
-          case XK_F8:    key = GLUT_KEY_F8; break;
-          case XK_F9:    key = GLUT_KEY_F9; break;
-          case XK_F10:   key = GLUT_KEY_F10; break;
-          case XK_F11:   key = GLUT_KEY_F11; break;
-          case XK_F12:   key = GLUT_KEY_F12; break;
-          /* directional keys */
-         case XK_KP_Left:
-          case XK_Left:  key = GLUT_KEY_LEFT; break;
-         case XK_KP_Up: /* Introduced in X11R6. */
-          case XK_Up:    key = GLUT_KEY_UP; break;
-         case XK_KP_Right: /* Introduced in X11R6. */
-          case XK_Right: key = GLUT_KEY_RIGHT; break;
-         case XK_KP_Down: /* Introduced in X11R6. */
-          case XK_Down:  key = GLUT_KEY_DOWN; break;
-/* *INDENT-ON* */
-
-         case XK_KP_Prior: /* Introduced in X11R6. */
-          case XK_Prior:
-            /* XK_Prior same as X11R6's XK_Page_Up */
-            key = GLUT_KEY_PAGE_UP;
-            break;
-         case XK_KP_Next: /* Introduced in X11R6. */
-          case XK_Next:
-            /* XK_Next same as X11R6's XK_Page_Down */
-            key = GLUT_KEY_PAGE_DOWN;
-            break;
-         case XK_KP_Home: /* Introduced in X11R6. */
-          case XK_Home:
-            key = GLUT_KEY_HOME;
-            break;
-#ifdef __hpux
-          case XK_Select:
-#endif
-         case XK_KP_End: /* Introduced in X11R6. */
-          case XK_End:
-            key = GLUT_KEY_END;
-            break;
-#ifdef __hpux
-          case XK_InsertChar:
-#endif
-         case XK_KP_Insert: /* Introduced in X11R6. */
-          case XK_Insert:
-            key = GLUT_KEY_INSERT;
-            break;
-#ifdef __hpux
-          case XK_DeleteChar:
-#endif
-         case XK_KP_Delete: /* Introduced in X11R6. */
-            /* The Delete character is really an ASCII key. */
-            __glutSetWindow(window);
-            assert(keyboard);
-            keyboard(127,  /* ASCII Delete character. */
-              event.xkey.x, event.xkey.y);
-            goto skip;
-          default:
-            goto skip;
-          }
-          __glutSetWindow(window);
-          __glutModifierMask = event.xkey.state;
-          special(key, event.xkey.x, event.xkey.y);
-          __glutModifierMask = ~0;
-        skip:;
-        }
-        break;
-      case EnterNotify:
-      case LeaveNotify:
-        if (event.xcrossing.mode != NotifyNormal ||
-          event.xcrossing.detail == NotifyNonlinearVirtual ||
-          event.xcrossing.detail == NotifyVirtual) {
-
-          /* Careful to ignore Enter/LeaveNotify events that
-             come from the pop-up menu pointer grab and ungrab. 
-             Also, ignore "virtual" Enter/LeaveNotify events
-             since they represent the pointer passing through
-             the window hierarchy without actually entering or
-             leaving the actual real estate of a window.  */
-
-          break;
-        }
-        if (__glutMappedMenu) {
-          GLUTmenuItem *item;
-          int num;
-
-          item = __glutGetMenuItem(__glutMappedMenu,
-            event.xcrossing.window, &num);
-          if (item) {
-            __glutMenuItemEnterOrLeave(item, num, event.type);
-            break;
-          }
-        }
-        window = __glutGetWindow(event.xcrossing.window);
-        if (window) {
-          if (window->entry) {
-            if (event.type == EnterNotify) {
-
-              /* With overlays established, X can report two
-                 enter events for both the overlay and normal
-                 plane window. Do not generate a second enter
-                 callback if we reported one without an
-                 intervening leave. */
-
-              if (window->entryState != EnterNotify) {
-                int num = window->num;
-                Window xid = window->win;
-
-                window->entryState = EnterNotify;
-                __glutSetWindow(window);
-                window->entry(GLUT_ENTERED);
-
-                if (__glutMappedMenu) {
-
-                  /* Do not generate any passive motion events
-                     when menus are in use. */
-
-                } else {
-
-                  /* An EnterNotify event can result in a
-                     "compound" callback if a passive motion
-                     callback is also registered. In this case,
-                     be a little paranoid about the possibility
-                     the window could have been destroyed in the
-                     entry callback. */
-
-                  window = __glutWindowList[num];
-                  if (window && window->passive && window->win == xid) {
-                    __glutSetWindow(window);
-                    window->passive(event.xcrossing.x, event.xcrossing.y);
-                  }
-                }
-              }
-            } else {
-              if (window->entryState != LeaveNotify) {
-
-                /* When an overlay is established for a window
-                   already mapped and with the pointer in it,
-                   the X server will generate a leave/enter
-                   event pair as the pointer leaves (without
-                   moving) from the normal plane X window to
-                   the newly mapped overlay  X window (or vice
-                   versa). This enter/leave pair should not be
-                   reported to the GLUT program since the pair
-                   is a consequence of creating (or destroying) 
-                   the overlay, not an actual leave from the
-                   GLUT window. */
-
-                if (XEventsQueued(__glutDisplay, QueuedAfterReading)) {
-                  XPeekEvent(__glutDisplay, &ahead);
-                  if (ahead.type == EnterNotify &&
-                    __glutGetWindow(ahead.xcrossing.window) == window) {
-                    XNextEvent(__glutDisplay, &event);
-                    break;
-                  }
-                }
-                window->entryState = LeaveNotify;
-                __glutSetWindow(window);
-                window->entry(GLUT_LEFT);
-              }
-            }
-          } else if (window->passive) {
-            __glutSetWindow(window);
-            window->passive(event.xcrossing.x, event.xcrossing.y);
-          }
-        }
-        break;
-      case UnmapNotify:
-        /* MapNotify events are not needed to maintain
-           visibility state since VisibilityNotify events will
-           be delivered when a window becomes visible from
-           mapping.  However, VisibilityNotify events are not
-           delivered when a window is unmapped (for the window
-           or its children). */
-        window = __glutGetWindow(event.xunmap.window);
-        if (window) {
-          if (window->win != event.xconfigure.window) {
-            /* Ignore UnmapNotify sent to the overlay planes.
-               GLUT could get here because overlays select for
-               StructureNotify events to receive DestroyNotify. 
-             */
-            break;
-          }
-          markWindowHidden(window);
-        }
-        break;
-      case VisibilityNotify:
-        window = __glutGetWindow(event.xvisibility.window);
-        if (window) {
-          /* VisibilityUnobscured+1 = GLUT_FULLY_RETAINED,
-             VisibilityPartiallyObscured+1 =
-             GLUT_PARTIALLY_RETAINED, VisibilityFullyObscured+1 
-             =  GLUT_FULLY_COVERED. */
-          int visState = event.xvisibility.state + 1;
-
-          if (visState != window->visState) {
-            if (window->windowStatus) {
-              window->visState = visState;
-              __glutSetWindow(window);
-              window->windowStatus(visState);
-            }
-          }
-        }
-        break;
-      case ClientMessage:
-        if (event.xclient.data.l[0] == __glutWMDeleteWindow)
-          exit(0);
-        break;
-      case DestroyNotify:
-        purgeStaleWindow(event.xdestroywindow.window);
-        break;
-      case CirculateNotify:
-      case CreateNotify:
-      case GravityNotify:
-      case ReparentNotify:
-        /* Uninteresting to GLUT (but possible for GLUT to
-           receive). */
-        break;
-      default:
-        /* Pass events not directly handled by the GLUT main
-           event loop to any event parsers that have been
-           registered.  In this way, X Input extension events
-           are passed to the correct handler without forcing
-           all GLUT programs to support X Input event handling. 
-         */
-        parser = eventParserList;
-        while (parser) {
-          if (parser->func(&event))
-            break;
-          parser = parser->next;
-        }
-        break;
-      }
-    }
-#endif /* _WIN32 */
-    if (__glutTimerList) {
-      handleTimeouts();
-    }
-  }
-  while (XPending(__glutDisplay));
-}
-
-static void
-waitForSomething(void)
-{
-#if defined(__vms) && ( __VMS_VER < 70000000 )
-  static struct timeval6 zerotime =
-  {0};
-  unsigned int timer_efn;
-#define timer_id 'glut' /* random :-) number */
-  unsigned int wait_mask;
-#else
-  static struct timeval zerotime =
-  {0, 0};
-#if !defined(_WIN32)
-  fd_set fds;
-#endif
-#endif
-#ifdef OLD_VMS
-   struct timeval6 now, timeout, waittime;
-#else
-   struct timeval now, timeout, waittime;
-#endif
-#if !defined(_WIN32)
-  int rc;
-#endif
-
-  /* Flush X protocol since XPending does not do this
-     implicitly. */
-  XFlush(__glutDisplay);
-  if (XPending(__glutDisplay)) {
-    /* It is possible (but quite rare) that XFlush may have
-       needed to wait for a writable X connection file
-       descriptor, and in the process, may have had to read off
-       X protocol from the file descriptor. If XPending is true,
-       this case occured and we should avoid waiting in select
-       since X protocol buffered within Xlib is due to be
-       processed and potentially no more X protocol is on the
-       file descriptor, so we would risk waiting improperly in
-       select. */
-    goto immediatelyHandleXinput;
-  }
-#if defined(__vms) && ( __VMS_VER < 70000000 )
-  timeout = __glutTimerList->timeout;
-  GETTIMEOFDAY(&now);
-  wait_mask = 1 << (__glutConnectionFD & 31);
-  if (IS_AFTER(now, timeout)) {
-    /* We need an event flag for the timer. */
-    /* XXX The `right' way to do this is to use LIB$GET_EF, but
-       since it needs to be in the same cluster as the EFN for
-       the display, we will have hack it. */
-    timer_efn = __glutConnectionFD - 1;
-    if ((timer_efn / 32) != (__glutConnectionFD / 32)) {
-      timer_efn = __glutConnectionFD + 1;
-    }
-    rc = SYS$CLREF(timer_efn);
-    rc = SYS$SETIMR(timer_efn, &timeout, NULL, timer_id, 0);
-    wait_mask |= 1 << (timer_efn & 31);
-  } else {
-    timer_efn = 0;
-  }
-  rc = SYS$WFLOR(__glutConnectionFD, wait_mask);
-  if (timer_efn != 0 && SYS$CLREF(timer_efn) == SS$_WASCLR) {
-    rc = SYS$CANTIM(timer_id, PSL$C_USER);
-  }
-  /* XXX There does not seem to be checking of "rc" in the code
-     above.  Can any of the SYS$ routines above fail? */
-#else /* not vms6.2 or lower */
-#if !defined(_WIN32)
-  FD_ZERO(&fds);
-  FD_SET(__glutConnectionFD, &fds);
-#endif
-  timeout = __glutTimerList->timeout;
-  GETTIMEOFDAY(&now);
-  if (IS_AFTER(now, timeout)) {
-    TIMEDELTA(waittime, timeout, now);
-  } else {
-    waittime = zerotime;
-  }
-#if !defined(_WIN32)
-  rc = select(__glutConnectionFD + 1, &fds,
-    NULL, NULL, &waittime);
-  if (rc < 0 && errno != EINTR)
-    __glutFatalError("select error.");
-#else
-
-  MsgWaitForMultipleObjects(0, NULL, FALSE,
-    waittime.tv_sec*1000 + waittime.tv_usec/1000, QS_ALLINPUT);
-
-#endif
-#endif /* not vms6.2 or lower */
-  /* Without considering the cause of select unblocking, check
-     for pending X events and handle any timeouts (by calling
-     processEventsAndTimeouts).  We always look for X events
-     even if select returned with 0 (indicating a timeout);
-     otherwise we risk starving X event processing by continous
-     timeouts. */
-  if (XPending(__glutDisplay)) {
-  immediatelyHandleXinput:
-    processEventsAndTimeouts();
-  } else {
-    if (__glutTimerList)
-      handleTimeouts();
-  }
-}
-
-static void
-idleWait(void)
-{
-  if (XPending(__glutDisplay)) {
-    processEventsAndTimeouts();
-  } else {
-    if (__glutTimerList) {
-      handleTimeouts();
-    }
-  }
-  /* Make sure idle func still exists! */
-  if (__glutIdleFunc) {
-    __glutIdleFunc();
-  }
-}
-
-static GLUTwindow **beforeEnd;
-
-static GLUTwindow *
-processWindowWorkList(GLUTwindow * window)
-{
-  int workMask;
-
-  if (window->prevWorkWin) {
-    window->prevWorkWin = processWindowWorkList(window->prevWorkWin);
-  } else {
-    beforeEnd = &window->prevWorkWin;
-  }
-
-  /* Capture work mask for work that needs to be done to this
-     window, then clear the window's work mask (excepting the
-     dummy work bit, see below).  Then, process the captured
-     work mask.  This allows callbacks in the processing the
-     captured work mask to set the window's work mask for
-     subsequent processing. */
-
-  workMask = window->workMask;
-  assert((workMask & GLUT_DUMMY_WORK) == 0);
-
-  /* Set the dummy work bit, clearing all other bits, to
-     indicate that the window is currently on the window work
-     list _and_ that the window's work mask is currently being
-     processed.  This convinces __glutPutOnWorkList that this
-     window is on the work list still. */
-  window->workMask = GLUT_DUMMY_WORK;
-
-  /* Optimization: most of the time, the work to do is a
-     redisplay and not these other types of work.  Check for
-     the following cases as a group to before checking each one
-     individually one by one. This saves about 25 MIPS
-     instructions in the common redisplay only case. */
-  if (workMask & (GLUT_EVENT_MASK_WORK | GLUT_DEVICE_MASK_WORK |
-      GLUT_CONFIGURE_WORK | GLUT_COLORMAP_WORK | GLUT_MAP_WORK)) {
-#if !defined(_WIN32)
-    /* Be sure to set event mask BEFORE map window is done. */
-    if (workMask & GLUT_EVENT_MASK_WORK) {
-      long eventMask;
-
-      /* Make sure children are not propogating events this
-         window is selecting for.  Be sure to do this before
-         enabling events on the children's parent. */
-      if (window->children) {
-        GLUTwindow *child = window->children;
-        unsigned long attribMask = CWDontPropagate;
-        XSetWindowAttributes wa;
-
-        wa.do_not_propagate_mask = window->eventMask & GLUT_DONT_PROPAGATE_FILTER_MASK;
-        if (window->eventMask & GLUT_HACK_STOP_PROPAGATE_MASK) {
-          wa.event_mask = child->eventMask | (window->eventMask & GLUT_HACK_STOP_PROPAGATE_MASK);
-          attribMask |= CWEventMask;
-        }
-        do {
-          XChangeWindowAttributes(__glutDisplay, child->win,
-            attribMask, &wa);
-          child = child->siblings;
-        } while (child);
-      }
-      eventMask = window->eventMask;
-      if (window->parent && window->parent->eventMask & GLUT_HACK_STOP_PROPAGATE_MASK)
-        eventMask |= (window->parent->eventMask & GLUT_HACK_STOP_PROPAGATE_MASK);
-      XSelectInput(__glutDisplay, window->win, eventMask);
-      if (window->overlay)
-        XSelectInput(__glutDisplay, window->overlay->win,
-          window->eventMask & GLUT_OVERLAY_EVENT_FILTER_MASK);
-    }
-#endif /* !_WIN32 */
-    /* Be sure to set device mask BEFORE map window is done. */
-    if (workMask & GLUT_DEVICE_MASK_WORK) {
-      __glutUpdateInputDeviceMaskFunc(window);
-    }
-    /* Be sure to configure window BEFORE map window is done. */
-    if (workMask & GLUT_CONFIGURE_WORK) {
-#if defined(_WIN32)
-      RECT changes;
-      POINT point;
-      UINT flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER
-       | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER;
-
-      GetClientRect(window->win, &changes);
-      
-      /* If this window is a toplevel window, translate the 0,0 client
-         coordinate into a screen coordinate for proper placement. */
-      if (!window->parent) {
-        point.x = 0;
-        point.y = 0;
-        ClientToScreen(window->win, &point);
-        changes.left = point.x;
-        changes.top = point.y;
-      }
-      if (window->desiredConfMask & (CWX | CWY)) {
-        changes.left = window->desiredX;
-        changes.top = window->desiredY;
-       flags &= ~SWP_NOMOVE;
-      }
-      if (window->desiredConfMask & (CWWidth | CWHeight)) {
-        changes.right = changes.left + window->desiredWidth;
-        changes.bottom = changes.top + window->desiredHeight;
-       flags &= ~SWP_NOSIZE;
-       /* XXX If overlay exists, resize the overlay here, ie.
-          if (window->overlay) ... */
-      }
-      if (window->desiredConfMask & CWStackMode) {
-       flags &= ~SWP_NOZORDER;
-       /* XXX Overlay support might require something special here. */
-      }
-
-      /* Adjust the window rectangle because Win32 thinks that the x, y,
-         width & height are the WHOLE window (including decorations),
-         whereas GLUT treats the x, y, width & height as only the CLIENT
-         area of the window.  Only do this to top level windows
-         that are not in game mode (since game mode windows do
-         not have any decorations). */
-      if (!window->parent && window != __glutGameModeWindow) {
-        AdjustWindowRect(&changes,
-          WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
-          FALSE);
-      }
-
-      /* Do the repositioning, moving, and push/pop. */
-      SetWindowPos(window->win,
-        window->desiredStack == Above ? HWND_TOP : HWND_NOTOPMOST,
-        changes.left, changes.top,
-        changes.right - changes.left, changes.bottom - changes.top,
-        flags);
-
-      /* Zero out the mask. */
-      window->desiredConfMask = 0;
-
-      /* This hack causes the window to go back to the right position
-         when it is taken out of fullscreen mode. */
-      if (workMask & GLUT_FULL_SCREEN_WORK) {
-        window->desiredConfMask |= CWX | CWY;
-        window->desiredX = point.x;
-        window->desiredY = point.y;
-      }
-#else /* !_WIN32 */
-      XWindowChanges changes;
-
-      changes.x = window->desiredX;
-      changes.y = window->desiredY;
-      if (window->desiredConfMask & (CWWidth | CWHeight)) {
-        changes.width = window->desiredWidth;
-        changes.height = window->desiredHeight;
-        if (window->overlay)
-          XResizeWindow(__glutDisplay, window->overlay->win,
-            window->desiredWidth, window->desiredHeight);
-        if (__glutMotifHints != None) {
-          if (workMask & GLUT_FULL_SCREEN_WORK) {
-            MotifWmHints hints;
-
-            hints.flags = MWM_HINTS_DECORATIONS;
-            hints.decorations = 0;  /* Absolutely no
-                                       decorations. */
-            XChangeProperty(__glutDisplay, window->win,
-              __glutMotifHints, __glutMotifHints, 32,
-              PropModeReplace, (unsigned char *) &hints, 4);
-            if (workMask & GLUT_MAP_WORK) {
-              /* Handle case where glutFullScreen is called
-                 before the first time that the window is
-                 mapped. Some window managers will randomly or
-                 interactively position the window the first
-                 time it is mapped if the window's
-                 WM_NORMAL_HINTS property does not request an
-                 explicit position. We don't want any such
-                 window manager interaction when going
-                 fullscreen.  Overwrite the WM_NORMAL_HINTS
-                 property installed by glutCreateWindow's
-                 XSetWMProperties property with one explicitly
-                 requesting a fullscreen window. */
-              XSizeHints hints;
-
-              hints.flags = USPosition | USSize;
-              hints.x = 0;
-              hints.y = 0;
-              hints.width = window->desiredWidth;
-              hints.height = window->desiredHeight;
-              XSetWMNormalHints(__glutDisplay, window->win, &hints);
-            }
-          } else {
-            XDeleteProperty(__glutDisplay, window->win, __glutMotifHints);
-          }
-        }
-      }
-      if (window->desiredConfMask & CWStackMode) {
-        changes.stack_mode = window->desiredStack;
-        /* Do not let glutPushWindow push window beneath the
-           underlay. */
-        if (window->parent && window->parent->overlay
-          && window->desiredStack == Below) {
-          changes.stack_mode = Above;
-          changes.sibling = window->parent->overlay->win;
-          window->desiredConfMask |= CWSibling;
-        }
-      }
-      XConfigureWindow(__glutDisplay, window->win,
-        window->desiredConfMask, &changes);
-      window->desiredConfMask = 0;
-#endif
-    }
-#if !defined(_WIN32)
-    /* Be sure to establish the colormaps BEFORE map window is
-       done. */
-    if (workMask & GLUT_COLORMAP_WORK) {
-      __glutEstablishColormapsProperty(window);
-    }
-#endif
-    if (workMask & GLUT_MAP_WORK) {
-      switch (window->desiredMapState) {
-      case WithdrawnState:
-        if (window->parent) {
-          XUnmapWindow(__glutDisplay, window->win);
-        } else {
-          XWithdrawWindow(__glutDisplay, window->win,
-            __glutScreen);
-        }
-        window->shownState = 0;
-        break;
-      case NormalState:
-        XMapWindow(__glutDisplay, window->win);
-        window->shownState = 1;
-        break;
-#ifdef _WIN32
-      case GameModeState:  /* Not an Xlib value. */
-        ShowWindow(window->win, SW_SHOW);
-        window->shownState = 1;
-        break;
-#endif
-      case IconicState:
-        XIconifyWindow(__glutDisplay, window->win, __glutScreen);
-        window->shownState = 0;
-        break;
-      }
-    }
-  }
-  if (workMask & (GLUT_REDISPLAY_WORK | GLUT_OVERLAY_REDISPLAY_WORK | GLUT_REPAIR_WORK | GLUT_OVERLAY_REPAIR_WORK)) {
-    if (window->forceReshape) {
-      /* Guarantee that before a display callback is generated
-         for a window, a reshape callback must be generated. */
-      __glutSetWindow(window);
-      window->reshape(window->width, window->height);
-      window->forceReshape = False;
-
-      /* Setting the redisplay bit on the first reshape is
-         necessary to make the "Mesa glXSwapBuffers to repair
-         damage" hack operate correctly.  Without indicating a
-         redisplay is necessary, there's not an initial back
-         buffer render from which to blit from when damage
-         happens to the window. */
-      workMask |= GLUT_REDISPLAY_WORK;
-    }
-    /* The code below is more involved than otherwise necessary
-       because it is paranoid about the overlay or entire window
-       being removed or destroyed in the course of the callbacks.
-       Notice how the global __glutWindowDamaged is used to record
-       the layers' damage status.  See the code in glutLayerGet for
-       how __glutWindowDamaged is used. The  point is to not have to
-       update the "damaged" field after  the callback since the
-       window (or overlay) may be destroyed (or removed) when the
-       callback returns. */
-
-    if (window->overlay && window->overlay->display) {
-      int num = window->num;
-      Window xid = window->overlay ? window->overlay->win : None;
-
-      /* If an overlay display callback is registered, we
-         differentiate between a redisplay needed for the
-         overlay and/or normal plane.  If there is no overlay
-         display callback registered, we simply use the
-         standard display callback. */
-
-      if (workMask & (GLUT_REDISPLAY_WORK | GLUT_REPAIR_WORK)) {
-        if (__glutMesaSwapHackSupport) {
-          if (window->usedSwapBuffers) {
-            if ((workMask & (GLUT_REPAIR_WORK | GLUT_REDISPLAY_WORK)) == GLUT_REPAIR_WORK) {
-             SWAP_BUFFERS_WINDOW(window);
-              goto skippedDisplayCallback1;
-            }
-          }
-        }
-        /* Render to normal plane. */
-#ifdef _WIN32
-        window->renderDc = window->hdc;
-#endif
-        window->renderWin = window->win;
-        window->renderCtx = window->ctx;
-        __glutWindowDamaged = (workMask & GLUT_REPAIR_WORK);
-        __glutSetWindow(window);
-        window->usedSwapBuffers = 0;
-        window->display();
-        __glutWindowDamaged = 0;
-
-      skippedDisplayCallback1:;
-      }
-      if (workMask & (GLUT_OVERLAY_REDISPLAY_WORK | GLUT_OVERLAY_REPAIR_WORK)) {
-        window = __glutWindowList[num];
-        if (window && window->overlay &&
-          window->overlay->win == xid && window->overlay->display) {
-
-          /* Render to overlay. */
-#ifdef _WIN32
-          window->renderDc = window->overlay->hdc;
-#endif
-          window->renderWin = window->overlay->win;
-          window->renderCtx = window->overlay->ctx;
-          __glutWindowDamaged = (workMask & GLUT_OVERLAY_REPAIR_WORK);
-          __glutSetWindow(window);
-          window->overlay->display();
-          __glutWindowDamaged = 0;
-        } else {
-          /* Overlay may have since been destroyed or the
-             overlay callback may have been disabled during
-             normal display callback. */
-        }
-      }
-    } else {
-      if (__glutMesaSwapHackSupport) {
-        if (!window->overlay && window->usedSwapBuffers) {
-          if ((workMask & (GLUT_REPAIR_WORK | GLUT_REDISPLAY_WORK)) == GLUT_REPAIR_WORK) {
-           SWAP_BUFFERS_WINDOW(window);
-            goto skippedDisplayCallback2;
-          }
-        }
-      }
-      /* Render to normal plane (and possibly overlay). */
-      __glutWindowDamaged = (workMask & (GLUT_OVERLAY_REPAIR_WORK | GLUT_REPAIR_WORK));
-      __glutSetWindow(window);
-      window->usedSwapBuffers = 0;
-      window->display();
-      __glutWindowDamaged = 0;
-
-    skippedDisplayCallback2:;
-    }
-  }
-  /* Combine workMask with window->workMask to determine what
-     finish and debug work there is. */
-  assert(window);
-  workMask |= window->workMask;
-
-  if (workMask & GLUT_FINISH_WORK) {
-    /* Finish work makes sure a glFinish gets done to indirect
-       rendering contexts.  Indirect contexts tend to have much 
-       longer latency because lots of OpenGL extension requests 
-       can queue up in the X protocol stream. __glutSetWindow
-       is where the finish works gets queued for indirect
-       contexts. */
-    __glutSetWindow(window);
-#if !defined(_WIN32)
-    if (!window->isDirect)
-#endif
-    {
-       glFinish();
-    }
-  }
-  if (workMask & GLUT_DEBUG_WORK) {
-    __glutSetWindow(window);
-    glutReportErrors();
-  }
-  /* Strip out dummy, finish, and debug work bits. */
-  window->workMask &= ~(GLUT_DUMMY_WORK | GLUT_FINISH_WORK | GLUT_DEBUG_WORK);
-  if (window->workMask) {
-    /* Leave on work list. */
-    return window;
-  } else {
-    /* Remove current window from work list. */
-    return window->prevWorkWin;
-  }
-}
-
-static  /* X11 implementations do not need this global. */
-void
-__glutProcessWindowWorkLists(void)
-{
-  if (__glutWindowWorkList) {
-    GLUTwindow *remainder, *work;
-
-    work = __glutWindowWorkList;
-    __glutWindowWorkList = NULL;
-    if (work) {
-      remainder = processWindowWorkList(work);
-      if (remainder) {
-        *beforeEnd = __glutWindowWorkList;
-        __glutWindowWorkList = remainder;
-      }
-    }
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutMainLoop(void)
-{
-#if !defined(_WIN32)
-  if (!__glutDisplay)
-    __glutFatalUsage("main loop entered with out proper initialization.");
-#endif
-  if (!__glutWindowListSize)
-    __glutFatalUsage(
-      "main loop entered with no windows created.");
-  for (;;) {
-    __glutProcessWindowWorkLists();
-    if (__glutIdleFunc || __glutWindowWorkList) {
-      idleWait();
-    } else {
-      if (__glutTimerList) {
-        waitForSomething();
-      } else {
-        processEventsAndTimeouts();
-      }
-    }
-  }
-}
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_ext.c b/src/glut/glx/glut_ext.c
deleted file mode 100644 (file)
index 922a94b..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "glutint.h"
-
-/* CENTRY */
-int GLUTAPIENTRY 
-glutExtensionSupported(const char *extension)
-{
-  static const GLubyte *extensions = NULL;
-  const GLubyte *start;
-  GLubyte *where, *terminator;
-
-  /* Extension names should not have spaces. */
-  where = (GLubyte *) strchr(extension, ' ');
-  if (where || *extension == '\0')
-    return 0;
-
-  if (!extensions) {
-    extensions = glGetString(GL_EXTENSIONS);
-  }
-  /* It takes a bit of care to be fool-proof about parsing the
-     OpenGL extensions string.  Don't be fooled by sub-strings,
-     etc. */
-  start = extensions;
-  for (;;) {
-    /* If your application crashes in the strstr routine below,
-       you are probably calling glutExtensionSupported without
-       having a current window.  Calling glGetString without
-       a current OpenGL context has unpredictable results.
-       Please fix your program. */
-    where = (GLubyte *) strstr((const char *) start, extension);
-    if (!where)
-      break;
-    terminator = where + strlen(extension);
-    if (where == start || *(where - 1) == ' ') {
-      if (*terminator == ' ' || *terminator == '\0') {
-        return 1;
-      }
-    }
-    start = terminator;
-  }
-  return 0;
-}
-
-
-struct name_address_pair {
-   const char *name;
-   const GLUTproc address;
-};
-
-static struct name_address_pair glut_functions[] = {
-   { "glutInit", (const GLUTproc) glutInit },
-   { "glutInitDisplayMode", (const GLUTproc) glutInitDisplayMode },
-   { "glutInitDisplayString", (const GLUTproc) glutInitDisplayString },
-   { "glutInitWindowPosition", (const GLUTproc) glutInitWindowPosition },
-   { "glutInitWindowSize", (const GLUTproc) glutInitWindowSize },
-   { "glutMainLoop", (const GLUTproc) glutMainLoop },
-   { "glutCreateWindow", (const GLUTproc) glutCreateWindow },
-   { "glutCreateSubWindow", (const GLUTproc) glutCreateSubWindow },
-   { "glutDestroyWindow", (const GLUTproc) glutDestroyWindow },
-   { "glutPostRedisplay", (const GLUTproc) glutPostRedisplay },
-   { "glutPostWindowRedisplay", (const GLUTproc) glutPostWindowRedisplay },
-   { "glutSwapBuffers", (const GLUTproc) glutSwapBuffers },
-   { "glutGetWindow", (const GLUTproc) glutGetWindow },
-   { "glutSetWindow", (const GLUTproc) glutSetWindow },
-   { "glutSetWindowTitle", (const GLUTproc) glutSetWindowTitle },
-   { "glutSetIconTitle", (const GLUTproc) glutSetIconTitle },
-   { "glutPositionWindow", (const GLUTproc) glutPositionWindow },
-   { "glutReshapeWindow", (const GLUTproc) glutReshapeWindow },
-   { "glutPopWindow", (const GLUTproc) glutPopWindow },
-   { "glutPushWindow", (const GLUTproc) glutPushWindow },
-   { "glutIconifyWindow", (const GLUTproc) glutIconifyWindow },
-   { "glutShowWindow", (const GLUTproc) glutShowWindow },
-   { "glutHideWindow", (const GLUTproc) glutHideWindow },
-   { "glutFullScreen", (const GLUTproc) glutFullScreen },
-   { "glutSetCursor", (const GLUTproc) glutSetCursor },
-   { "glutWarpPointer", (const GLUTproc) glutWarpPointer },
-   { "glutEstablishOverlay", (const GLUTproc) glutEstablishOverlay },
-   { "glutRemoveOverlay", (const GLUTproc) glutRemoveOverlay },
-   { "glutUseLayer", (const GLUTproc) glutUseLayer },
-   { "glutPostOverlayRedisplay", (const GLUTproc) glutPostOverlayRedisplay },
-   { "glutPostWindowOverlayRedisplay", (const GLUTproc) glutPostWindowOverlayRedisplay },
-   { "glutShowOverlay", (const GLUTproc) glutShowOverlay },
-   { "glutHideOverlay", (const GLUTproc) glutHideOverlay },
-   { "glutCreateMenu", (const GLUTproc) glutCreateMenu },
-   { "glutDestroyMenu", (const GLUTproc) glutDestroyMenu },
-   { "glutGetMenu", (const GLUTproc) glutGetMenu },
-   { "glutSetMenu", (const GLUTproc) glutSetMenu },
-   { "glutAddMenuEntry", (const GLUTproc) glutAddMenuEntry },
-   { "glutAddSubMenu", (const GLUTproc) glutAddSubMenu },
-   { "glutChangeToMenuEntry", (const GLUTproc) glutChangeToMenuEntry },
-   { "glutChangeToSubMenu", (const GLUTproc) glutChangeToSubMenu },
-   { "glutRemoveMenuItem", (const GLUTproc) glutRemoveMenuItem },
-   { "glutAttachMenu", (const GLUTproc) glutAttachMenu },
-   { "glutDetachMenu", (const GLUTproc) glutDetachMenu },
-   { "glutDisplayFunc", (const GLUTproc) glutDisplayFunc },
-   { "glutReshapeFunc", (const GLUTproc) glutReshapeFunc },
-   { "glutKeyboardFunc", (const GLUTproc) glutKeyboardFunc },
-   { "glutMouseFunc", (const GLUTproc) glutMouseFunc },
-   { "glutMotionFunc", (const GLUTproc) glutMotionFunc },
-   { "glutPassiveMotionFunc", (const GLUTproc) glutPassiveMotionFunc },
-   { "glutEntryFunc", (const GLUTproc) glutEntryFunc },
-   { "glutVisibilityFunc", (const GLUTproc) glutVisibilityFunc },
-   { "glutIdleFunc", (const GLUTproc) glutIdleFunc },
-   { "glutTimerFunc", (const GLUTproc) glutTimerFunc },
-   { "glutMenuStateFunc", (const GLUTproc) glutMenuStateFunc },
-   { "glutSpecialFunc", (const GLUTproc) glutSpecialFunc },
-   { "glutSpaceballMotionFunc", (const GLUTproc) glutSpaceballMotionFunc },
-   { "glutSpaceballRotateFunc", (const GLUTproc) glutSpaceballRotateFunc },
-   { "glutSpaceballButtonFunc", (const GLUTproc) glutSpaceballButtonFunc },
-   { "glutButtonBoxFunc", (const GLUTproc) glutButtonBoxFunc },
-   { "glutDialsFunc", (const GLUTproc) glutDialsFunc },
-   { "glutTabletMotionFunc", (const GLUTproc) glutTabletMotionFunc },
-   { "glutTabletButtonFunc", (const GLUTproc) glutTabletButtonFunc },
-   { "glutMenuStatusFunc", (const GLUTproc) glutMenuStatusFunc },
-   { "glutOverlayDisplayFunc", (const GLUTproc) glutOverlayDisplayFunc },
-   { "glutWindowStatusFunc", (const GLUTproc) glutWindowStatusFunc },
-   { "glutKeyboardUpFunc", (const GLUTproc) glutKeyboardUpFunc },
-   { "glutSpecialUpFunc", (const GLUTproc) glutSpecialUpFunc },
-   { "glutJoystickFunc", (const GLUTproc) glutJoystickFunc },
-   { "glutSetColor", (const GLUTproc) glutSetColor },
-   { "glutGetColor", (const GLUTproc) glutGetColor },
-   { "glutCopyColormap", (const GLUTproc) glutCopyColormap },
-   { "glutGet", (const GLUTproc) glutGet },
-   { "glutDeviceGet", (const GLUTproc) glutDeviceGet },
-   { "glutExtensionSupported", (const GLUTproc) glutExtensionSupported },
-   { "glutGetModifiers", (const GLUTproc) glutGetModifiers },
-   { "glutLayerGet", (const GLUTproc) glutLayerGet },
-   { "glutGetProcAddress", (const GLUTproc) glutGetProcAddress },
-   { "glutBitmapCharacter", (const GLUTproc) glutBitmapCharacter },
-   { "glutBitmapWidth", (const GLUTproc) glutBitmapWidth },
-   { "glutStrokeCharacter", (const GLUTproc) glutStrokeCharacter },
-   { "glutStrokeWidth", (const GLUTproc) glutStrokeWidth },
-   { "glutBitmapLength", (const GLUTproc) glutBitmapLength },
-   { "glutStrokeLength", (const GLUTproc) glutStrokeLength },
-   { "glutWireSphere", (const GLUTproc) glutWireSphere },
-   { "glutSolidSphere", (const GLUTproc) glutSolidSphere },
-   { "glutWireCone", (const GLUTproc) glutWireCone },
-   { "glutSolidCone", (const GLUTproc) glutSolidCone },
-   { "glutWireCube", (const GLUTproc) glutWireCube },
-   { "glutSolidCube", (const GLUTproc) glutSolidCube },
-   { "glutWireTorus", (const GLUTproc) glutWireTorus },
-   { "glutSolidTorus", (const GLUTproc) glutSolidTorus },
-   { "glutWireDodecahedron", (const GLUTproc) glutWireDodecahedron },
-   { "glutSolidDodecahedron", (const GLUTproc) glutSolidDodecahedron },
-   { "glutWireTeapot", (const GLUTproc) glutWireTeapot },
-   { "glutSolidTeapot", (const GLUTproc) glutSolidTeapot },
-   { "glutWireOctahedron", (const GLUTproc) glutWireOctahedron },
-   { "glutSolidOctahedron", (const GLUTproc) glutSolidOctahedron },
-   { "glutWireTetrahedron", (const GLUTproc) glutWireTetrahedron },
-   { "glutSolidTetrahedron", (const GLUTproc) glutSolidTetrahedron },
-   { "glutWireIcosahedron", (const GLUTproc) glutWireIcosahedron },
-   { "glutSolidIcosahedron", (const GLUTproc) glutSolidIcosahedron },
-   { "glutVideoResizeGet", (const GLUTproc) glutVideoResizeGet },
-   { "glutSetupVideoResizing", (const GLUTproc) glutSetupVideoResizing },
-   { "glutStopVideoResizing", (const GLUTproc) glutStopVideoResizing },
-   { "glutVideoResize", (const GLUTproc) glutVideoResize },
-   { "glutVideoPan", (const GLUTproc) glutVideoPan },
-   { "glutReportErrors", (const GLUTproc) glutReportErrors },
-   { "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat },
-   { "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat },
-   { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc },
-   { "glutGameModeString", (const GLUTproc) glutGameModeString },
-   { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode },
-   { "glutLeaveGameMode", (const GLUTproc) glutLeaveGameMode },
-   { "glutGameModeGet", (const GLUTproc) glutGameModeGet },
-   { NULL, NULL }
-};   
-
-
-/* XXX This isn't an official GLUT function, yet */
-GLUTproc GLUTAPIENTRY 
-glutGetProcAddress(const char *procName)
-{
-   /* Try GLUT functions first */
-   int i;
-   for (i = 0; glut_functions[i].name; i++) {
-      if (strcmp(glut_functions[i].name, procName) == 0)
-         return glut_functions[i].address;
-   }
-
-   /* Try core GL functions */
-#if defined(_WIN32)
-  return (GLUTproc) wglGetProcAddress((LPCSTR) procName);
-#elif defined(GLX_ARB_get_proc_address)
-  return (GLUTproc) glXGetProcAddressARB((const GLubyte *) procName);
-#else
-  return NULL;
-#endif
-}
-
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_fcb.c b/src/glut/glx/glut_fcb.c
deleted file mode 100644 (file)
index c8a3422..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1998.  */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-/* I appreciate the guidance from William Mitchell
-   (mitchell@cam.nist.gov) in developing this friend interface
-   for use by the f90gl package.  See ../../README.fortran */
-
-#include "glutint.h"
-
-/* FCB stands for Fortran CallBack. */
-
-/* There is only one idleFunc, menuStateFunc, and menuStatusFunc, so they
-   can be saved in the wrappers for Fortran rather than the C structures. */
-
-/* Set a Fortran callback function. */
-
-void APIENTRY
-__glutSetFCB(int which, GLUTproc func)
-{
-#ifdef SUPPORT_FORTRAN
-  switch (which) {
-  case GLUT_FCB_DISPLAY:
-    __glutCurrentWindow->fdisplay = (GLUTdisplayFCB) func;
-    break;
-  case GLUT_FCB_RESHAPE:
-    __glutCurrentWindow->freshape = (GLUTreshapeFCB) func;
-    break;
-  case GLUT_FCB_MOUSE:
-    __glutCurrentWindow->fmouse = (GLUTmouseFCB) func;
-    break;
-  case GLUT_FCB_MOTION:
-    __glutCurrentWindow->fmotion = (GLUTmotionFCB) func;
-    break;
-  case GLUT_FCB_PASSIVE:
-    __glutCurrentWindow->fpassive = (GLUTpassiveFCB) func;
-    break;
-  case GLUT_FCB_ENTRY:
-    __glutCurrentWindow->fentry = (GLUTentryFCB) func;
-    break;
-  case GLUT_FCB_KEYBOARD:
-    __glutCurrentWindow->fkeyboard = (GLUTkeyboardFCB) func;
-    break;
-  case GLUT_FCB_KEYBOARD_UP:
-    __glutCurrentWindow->fkeyboardUp = (GLUTkeyboardFCB) func;
-    break;
-  case GLUT_FCB_WINDOW_STATUS:
-    __glutCurrentWindow->fwindowStatus = (GLUTwindowStatusFCB) func;
-    break;
-  case GLUT_FCB_VISIBILITY:
-    __glutCurrentWindow->fvisibility = (GLUTvisibilityFCB) func;
-    break;
-  case GLUT_FCB_SPECIAL:
-    __glutCurrentWindow->fspecial = (GLUTspecialFCB) func;
-    break;
-  case GLUT_FCB_SPECIAL_UP:
-    __glutCurrentWindow->fspecialUp = (GLUTspecialFCB) func;
-    break;
-  case GLUT_FCB_BUTTON_BOX:
-    __glutCurrentWindow->fbuttonBox = (GLUTbuttonBoxFCB) func;
-    break;
-  case GLUT_FCB_DIALS:
-    __glutCurrentWindow->fdials = (GLUTdialsFCB) func;
-    break;
-  case GLUT_FCB_SPACE_MOTION:
-    __glutCurrentWindow->fspaceMotion = (GLUTspaceMotionFCB) func;
-    break;
-  case GLUT_FCB_SPACE_ROTATE:
-    __glutCurrentWindow->fspaceRotate = (GLUTspaceRotateFCB) func;
-    break;
-  case GLUT_FCB_SPACE_BUTTON:
-    __glutCurrentWindow->fspaceButton = (GLUTspaceButtonFCB) func;
-    break;
-  case GLUT_FCB_TABLET_MOTION:
-    __glutCurrentWindow->ftabletMotion = (GLUTtabletMotionFCB) func;
-    break;
-  case GLUT_FCB_TABLET_BUTTON:
-    __glutCurrentWindow->ftabletButton = (GLUTtabletButtonFCB) func;
-    break;
-#ifdef _WIN32
-  case GLUT_FCB_JOYSTICK:
-    __glutCurrentWindow->fjoystick = (GLUTjoystickFCB) func;
-    break;
-#endif
-  case GLUT_FCB_OVERLAY_DISPLAY:
-    __glutCurrentWindow->overlay->fdisplay = (GLUTdisplayFCB) func;
-    break;
-  case GLUT_FCB_SELECT:
-    __glutCurrentMenu->fselect = (GLUTselectFCB) func;
-    break;
-  case GLUT_FCB_TIMER:
-    __glutNewTimer->ffunc = (GLUTtimerFCB) func;
-    break;
-  }
-#endif
-}
-
-/* Get a Fortran callback function. */
-
-GLUTproc APIENTRY
-__glutGetFCB(int which)
-{
-#ifdef SUPPORT_FORTRAN
-  switch (which) {
-  case GLUT_FCB_DISPLAY:
-    return __glutCurrentWindow->fdisplay;
-  case GLUT_FCB_RESHAPE:
-    return __glutCurrentWindow->freshape;
-  case GLUT_FCB_MOUSE:
-    return __glutCurrentWindow->fmouse;
-  case GLUT_FCB_MOTION:
-    return __glutCurrentWindow->fmotion;
-  case GLUT_FCB_PASSIVE:
-    return __glutCurrentWindow->fpassive;
-  case GLUT_FCB_ENTRY:
-    return __glutCurrentWindow->fentry;
-  case GLUT_FCB_KEYBOARD:
-    return __glutCurrentWindow->fkeyboard;
-  case GLUT_FCB_KEYBOARD_UP:
-    return __glutCurrentWindow->fkeyboardUp;
-  case GLUT_FCB_WINDOW_STATUS:
-    return __glutCurrentWindow->fwindowStatus;
-  case GLUT_FCB_VISIBILITY:
-    return __glutCurrentWindow->fvisibility;
-  case GLUT_FCB_SPECIAL:
-    return __glutCurrentWindow->fspecial;
-  case GLUT_FCB_SPECIAL_UP:
-    return __glutCurrentWindow->fspecialUp;
-  case GLUT_FCB_BUTTON_BOX:
-    return __glutCurrentWindow->fbuttonBox;
-  case GLUT_FCB_DIALS:
-    return __glutCurrentWindow->fdials;
-  case GLUT_FCB_SPACE_MOTION:
-    return __glutCurrentWindow->fspaceMotion;
-  case GLUT_FCB_SPACE_ROTATE:
-    return __glutCurrentWindow->fspaceRotate;
-  case GLUT_FCB_SPACE_BUTTON:
-    return __glutCurrentWindow->fspaceButton;
-  case GLUT_FCB_TABLET_MOTION:
-    return __glutCurrentWindow->ftabletMotion;
-  case GLUT_FCB_TABLET_BUTTON:
-    return __glutCurrentWindow->ftabletButton;
-  case GLUT_FCB_JOYSTICK:
-#ifdef _WIN32
-    return __glutCurrentWindow->fjoystick;
-#else
-    return NULL;
-#endif
-  case GLUT_FCB_OVERLAY_DISPLAY:
-    return __glutCurrentWindow->overlay->fdisplay;
-  case GLUT_FCB_SELECT:
-    return __glutCurrentMenu->fselect;
-  case GLUT_FCB_TIMER:
-     return __glutTimerList ? __glutTimerList->ffunc : NULL;
-  default:
-    return NULL;
-  }
-#else
-  return NULL;
-#endif
-}
diff --git a/src/glut/glx/glut_fullscrn.c b/src/glut/glx/glut_fullscrn.c
deleted file mode 100644 (file)
index 78a7a61..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1995, 1998. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdio.h>  /* SunOS multithreaded assert() needs <stdio.h>.  Lame. */
-#include <assert.h>
-
-#if !defined(_WIN32)
-#include <X11/Xlib.h>
-#endif
-
-/* SGI optimization introduced in IRIX 6.3 to avoid X server
-   round trips for interning common X atoms. */
-#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
-#include <X11/SGIFastAtom.h>
-#else
-#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
-#endif
-
-#include "glutint.h"
-
-/* CENTRY */
-void GLUTAPIENTRY 
-glutFullScreen(void)
-{
-  assert(!__glutCurrentWindow->parent);
-  IGNORE_IN_GAME_MODE();
-#if !defined(_WIN32)
-  if (__glutMotifHints == None) {
-    __glutMotifHints = XSGIFastInternAtom(__glutDisplay, "_MOTIF_WM_HINTS",
-      SGI_XA__MOTIF_WM_HINTS, 0);
-    if (__glutMotifHints == None) {
-      __glutWarning("Could not intern X atom for _MOTIF_WM_HINTS.");
-    }
-  }
-#endif
-
-  __glutCurrentWindow->desiredX = 0;
-  __glutCurrentWindow->desiredY = 0;
-  __glutCurrentWindow->desiredWidth = __glutScreenWidth;
-  __glutCurrentWindow->desiredHeight = __glutScreenHeight;
-  __glutCurrentWindow->desiredConfMask |= CWX | CWY | CWWidth | CWHeight;
-
-  __glutPutOnWorkList(__glutCurrentWindow,
-    GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK);
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_gamemode.c b/src/glut/glx/glut_gamemode.c
deleted file mode 100644 (file)
index 4a92099..0000000
+++ /dev/null
@@ -1,677 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1998. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "glutint.h"
-
-#ifndef _WIN32
-#include <X11/Xlib.h>
-
-/* SGI optimization introduced in IRIX 6.3 to avoid X server
-   round trips for interning common X atoms. */
-#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
-#include <X11/SGIFastAtom.h>
-#else
-#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
-#endif
-#endif  /* not _WIN32 */
-
-int __glutDisplaySettingsChanged = 0;
-static DisplayMode *dmodes, *currentDm = NULL;
-static int ndmodes = -1;
-GLUTwindow *__glutGameModeWindow = NULL;
-
-#ifdef TEST
-static char *compstr[] =
-{
-  "none", "=", "!=", "<=", ">=", ">", "<", "~"
-};
-static char *capstr[] =
-{
-  "width", "height", "bpp", "hertz", "num"
-};
-#endif
-
-void
-__glutCloseDownGameMode(void)
-{
-  if (__glutDisplaySettingsChanged) {
-#ifdef _WIN32
-    /* Assumes that display settings have been changed, that
-       is __glutDisplaySettingsChanged is true. */
-    ChangeDisplaySettings(NULL, 0);
-#endif
-    __glutDisplaySettingsChanged = 0;
-  }
-  __glutGameModeWindow = NULL;
-}
-
-void GLUTAPIENTRY
-glutLeaveGameMode(void)
-{
-  if (__glutGameModeWindow == NULL) {
-    __glutWarning("not in game mode so cannot leave game mode");
-    return;
-  }
-  __glutDestroyWindow(__glutGameModeWindow,
-    __glutGameModeWindow);
-  XFlush(__glutDisplay);
-  __glutGameModeWindow = NULL;
-}
-
-#ifdef _WIN32
-
-/* Same values as from MSDN's SetDisp.c example. */
-#define MIN_WIDTH 400
-#define MIN_FREQUENCY 60
-
-static void
-initGameModeSupport(void)
-{
-  DEVMODE dm;
-  DWORD mode;
-  int i;
-
-  if (ndmodes >= 0) {
-    /* ndmodes is initially -1 to indicate no
-       dmodes allocated yet. */
-    return;
-  }
-
-  /* Determine how many display modes there are. */
-  ndmodes = 0;
-  mode = 0;
-  while (EnumDisplaySettings(NULL, mode, &dm)) {
-    if (dm.dmPelsWidth >= MIN_WIDTH &&
-      (dm.dmDisplayFrequency == 0 ||
-      dm.dmDisplayFrequency >= MIN_FREQUENCY)) {
-      ndmodes++;
-    }
-    mode++;
-  }
-
-  /* Allocate memory for a list of all the display modes. */
-  dmodes = (DisplayMode*)
-    malloc(ndmodes * sizeof(DisplayMode));
-
-  /* Now that we know how many display modes to expect,
-     enumerate them again and save the information in
-     the list we allocated above. */
-  i = 0;
-  mode = 0;
-  while (EnumDisplaySettings(NULL, mode, &dm)) {
-    /* Try to reject any display settings that seem unplausible. */
-    if (dm.dmPelsWidth >= MIN_WIDTH &&
-      (dm.dmDisplayFrequency == 0 ||
-      dm.dmDisplayFrequency >= MIN_FREQUENCY)) {
-      dmodes[i].devmode = dm;
-      dmodes[i].valid = 1;  /* XXX Not used for now. */
-      dmodes[i].cap[DM_WIDTH] = dm.dmPelsWidth;
-      dmodes[i].cap[DM_HEIGHT] = dm.dmPelsHeight;
-      dmodes[i].cap[DM_PIXEL_DEPTH] = dm.dmBitsPerPel;
-      if (dm.dmDisplayFrequency == 0) {
-       /* Guess a reasonable guess. */
-       /* Lame Windows 95 version of EnumDisplaySettings. */
-        dmodes[i].cap[DM_HERTZ] = 60;
-      } else {
-       dmodes[i].cap[DM_HERTZ] = dm.dmDisplayFrequency;
-      }
-      i++;
-    }
-    mode++;
-  }
-
-  assert(i == ndmodes);
-}
-
-#else
-
-/* X Windows version of initGameModeSupport. */
-static void
-initGameModeSupport(void)
-{
-  if (ndmodes >= 0) {
-    /* ndmodes is initially -1 to indicate no
-       dmodes allocated yet. */
-    return;
-  }
-
-  /* Determine how many display modes there are. */
-  ndmodes = 0;
-}
-
-#endif
-
-/* This routine is based on similiar code in glut_dstr.c */
-static DisplayMode *
-findMatch(DisplayMode * dmodes, int ndmodes,
-  Criterion * criteria, int ncriteria)
-{
-  DisplayMode *found;
-  int *bestScore, *thisScore;
-  int i, j, numok, result = 0, worse, better;
-
-  found = NULL;
-  numok = 1;            /* "num" capability is indexed from 1,
-                           not 0. */
-
-  /* XXX alloca canidate. */
-  bestScore = (int *) malloc(ncriteria * sizeof(int));
-  if (!bestScore) {
-    __glutFatalError("out of memory.");
-  }
-  for (j = 0; j < ncriteria; j++) {
-    /* Very negative number. */
-    bestScore[j] = -32768;
-  }
-
-  /* XXX alloca canidate. */
-  thisScore = (int *) malloc(ncriteria * sizeof(int));
-  if (!thisScore) {
-    __glutFatalError("out of memory.");
-  }
-
-  for (i = 0; i < ndmodes; i++) {
-    if (dmodes[i].valid) {
-      worse = 0;
-      better = 0;
-
-      for (j = 0; j < ncriteria; j++) {
-        int cap, cvalue, dvalue;
-
-        cap = criteria[j].capability;
-        cvalue = criteria[j].value;
-        if (cap == NUM) {
-          dvalue = numok;
-        } else {
-          dvalue = dmodes[i].cap[cap];
-        }
-#ifdef TEST
-        if (verbose)
-          printf("  %s %s %d to %d\n",
-            capstr[cap], compstr[criteria[j].comparison], cvalue, dvalue);
-#endif
-        switch (criteria[j].comparison) {
-        case EQ:
-          result = cvalue == dvalue;
-          thisScore[j] = 1;
-          break;
-        case NEQ:
-          result = cvalue != dvalue;
-          thisScore[j] = 1;
-          break;
-        case LT:
-          result = dvalue < cvalue;
-          thisScore[j] = dvalue - cvalue;
-          break;
-        case GT:
-          result = dvalue > cvalue;
-          thisScore[j] = dvalue - cvalue;
-          break;
-        case LTE:
-          result = dvalue <= cvalue;
-          thisScore[j] = dvalue - cvalue;
-          break;
-        case GTE:
-          result = (dvalue >= cvalue);
-          thisScore[j] = dvalue - cvalue;
-          break;
-        case MIN:
-          result = dvalue >= cvalue;
-          thisScore[j] = cvalue - dvalue;
-          break;
-        }
-
-#ifdef TEST
-        if (verbose)
-          printf("                result=%d   score=%d   bestScore=%d\n", result, thisScore[j], bestScore[j]);
-#endif
-
-        if (result) {
-          if (better || thisScore[j] > bestScore[j]) {
-            better = 1;
-          } else if (thisScore[j] == bestScore[j]) {
-            /* Keep looking. */
-          } else {
-            goto nextDM;
-          }
-        } else {
-          if (cap == NUM) {
-            worse = 1;
-          } else {
-            goto nextDM;
-          }
-        }
-
-      }
-
-      if (better && !worse) {
-        found = &dmodes[i];
-        for (j = 0; j < ncriteria; j++) {
-          bestScore[j] = thisScore[j];
-        }
-      }
-      numok++;
-
-    nextDM:;
-
-    }
-  }
-  free(bestScore);
-  free(thisScore);
-  return found;
-}
-
-/**
- * Parses strings in the form of:
- *  800x600
- *  800x600:16
- *  800x600@60
- *  800x600:16@60
- *  @60
- *  :16
- *  :16@60
- * NOTE that @ before : is not parsed.
- */
-static int
-specialCaseParse(char *word, Criterion * criterion, int mask)
-{
-  char *xstr, *response;
-  int got;
-  int width, height, bpp, hertz;
-
-  switch(word[0]) {
-  case '0':
-  case '1':
-  case '2':
-  case '3':
-  case '4':
-  case '5':
-  case '6':
-  case '7':
-  case '8':
-  case '9':
-    /* The WWWxHHH case. */
-    if (mask & (1 << DM_WIDTH)) {
-      return -1;
-    }
-    xstr = strpbrk(&word[1], "x");
-    if (xstr) {
-      width = (int) strtol(word, &response, 0);
-      if (response == word || response[0] != 'x') {
-        /* Not a valid number OR needs to be followed by 'x'. */
-       return -1;
-      }
-      height = (int) strtol(&xstr[1], &response, 0);
-      if (response == &xstr[1]) {
-        /* Not a valid number. */
-       return -1;
-      }
-      criterion[0].capability = DM_WIDTH;
-      criterion[0].comparison = EQ;
-      criterion[0].value = width;
-      criterion[1].capability = DM_HEIGHT;
-      criterion[1].comparison = EQ;
-      criterion[1].value = height;
-      got = specialCaseParse(response,
-        &criterion[2], 1 << DM_WIDTH);
-      if (got >= 0) {
-        return got + 2;
-      } else {
-        return -1;
-      }
-    }
-    return -1;
-  case ':':
-    /* The :BPP case. */
-    if (mask & (1 << DM_PIXEL_DEPTH)) {
-      return -1;
-    }
-    bpp = (int) strtol(&word[1], &response, 0);
-    if (response == &word[1]) {
-      /* Not a valid number. */
-      return -1;
-    }
-    criterion[0].capability = DM_PIXEL_DEPTH;
-    criterion[0].comparison = EQ;
-    criterion[0].value = bpp;
-    got = specialCaseParse(response,
-      &criterion[1], 1 << DM_WIDTH | 1 << DM_PIXEL_DEPTH);
-    if (got >= 0) {
-      return got + 1;
-    } else {
-      return -1;
-    }
-  case '@':
-    /* The @HZ case. */
-    if (mask & (1 << DM_HERTZ)) {
-      return -1;
-    }
-    hertz = (int) strtol(&word[1], &response, 0);
-    if (response == &word[1]) {
-      /* Not a valid number. */
-      return -1;
-    }
-    criterion[0].capability = DM_HERTZ;
-    criterion[0].comparison = EQ;
-    criterion[0].value = hertz;
-    got = specialCaseParse(response,
-      &criterion[1], ~DM_HERTZ);
-    if (got >= 0) {
-      return got + 1;
-    } else {
-      return -1;
-    }
-  case '\0':
-    return 0;
-  }
-  return -1;
-}
-
-/* This routine is based on similiar code in glut_dstr.c */
-static int
-parseCriteria(char *word, Criterion * criterion)
-{
-  char *cstr, *vstr, *response;
-  int comparator, value = 0;
-
-  cstr = strpbrk(word, "=><!~");
-  if (cstr) {
-    switch (cstr[0]) {
-    case '=':
-      comparator = EQ;
-      vstr = &cstr[1];
-      break;
-    case '~':
-      comparator = MIN;
-      vstr = &cstr[1];
-      break;
-    case '>':
-      if (cstr[1] == '=') {
-        comparator = GTE;
-        vstr = &cstr[2];
-      } else {
-        comparator = GT;
-        vstr = &cstr[1];
-      }
-      break;
-    case '<':
-      if (cstr[1] == '=') {
-        comparator = LTE;
-        vstr = &cstr[2];
-      } else {
-        comparator = LT;
-        vstr = &cstr[1];
-      }
-      break;
-    case '!':
-      if (cstr[1] == '=') {
-        comparator = NEQ;
-        vstr = &cstr[2];
-      } else {
-        return -1;
-      }
-      break;
-    default:
-      return -1;
-    }
-    value = (int) strtol(vstr, &response, 0);
-    if (response == vstr) {
-      /* Not a valid number. */
-      return -1;
-    }
-    *cstr = '\0';
-  } else {
-    comparator = NONE;
-  }
-  switch (word[0]) {
-  case 'b':
-    if (!strcmp(word, "bpp")) {
-      criterion[0].capability = DM_PIXEL_DEPTH;
-      if (comparator == NONE) {
-        return -1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-        return 1;
-      }
-    }
-    return -1;
-  case 'h':
-    if (!strcmp(word, "height")) {
-      criterion[0].capability = DM_HEIGHT;
-      if (comparator == NONE) {
-        return -1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-        return 1;
-      }
-    }
-    if (!strcmp(word, "hertz")) {
-      criterion[0].capability = DM_HERTZ;
-      if (comparator == NONE) {
-        return -1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-        return 1;
-      }
-    }
-    return -1;
-  case 'n':
-    if (!strcmp(word, "num")) {
-      criterion[0].capability = DM_NUM;
-      if (comparator == NONE) {
-        return -1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-        return 1;
-      }
-    }
-    return -1;
-  case 'w':
-    if (!strcmp(word, "width")) {
-      criterion[0].capability = DM_WIDTH;
-      if (comparator == NONE) {
-        return -1;
-      } else {
-        criterion[0].comparison = comparator;
-        criterion[0].value = value;
-        return 1;
-      }
-    }
-    return -1;
-  }
-  if (comparator == NONE) {
-    return specialCaseParse(word, criterion, 0);
-  }
-  return -1;
-}
-
-/* This routine is based on similiar code in glut_dstr.c */
-static Criterion *
-parseDisplayString(const char *display, int *ncriteria)
-{
-  Criterion *criteria = NULL;
-  int n, parsed;
-  char *copy, *word;
-
-  copy = __glutStrdup(display);
-  /* Attempt to estimate how many criteria entries should be
-     needed. */
-  n = 0;
-  word = strtok(copy, " \t");
-  while (word) {
-    n++;
-    word = strtok(NULL, " \t");
-  }
-  /* Allocate number of words of criteria.  A word
-     could contain as many as four criteria in the
-     worst case.  Example: 800x600:16@60 */
-  criteria = (Criterion *) malloc(4 * n * sizeof(Criterion));
-  if (!criteria) {
-    __glutFatalError("out of memory.");
-  }
-
-  /* Re-copy the copy of the display string. */
-  strcpy(copy, display);
-
-  n = 0;
-  word = strtok(copy, " \t");
-  while (word) {
-    parsed = parseCriteria(word, &criteria[n]);
-    if (parsed >= 0) {
-      n += parsed;
-    } else {
-      __glutWarning("Unrecognized game mode string word: %s (ignoring)\n", word);
-    }
-    word = strtok(NULL, " \t");
-  }
-
-  free(copy);
-  *ncriteria = n;
-  return criteria;
-}
-
-void GLUTAPIENTRY
-glutGameModeString(const char *string)
-{
-  Criterion *criteria;
-  int ncriteria;
-
-  initGameModeSupport();
-  criteria = parseDisplayString(string, &ncriteria);
-  currentDm = findMatch(dmodes, ndmodes, criteria, ncriteria);
-  free(criteria);
-}
-
-int GLUTAPIENTRY
-glutEnterGameMode(void)
-{
-  GLUTwindow *window;
-  int width, height;
-  Window win;
-
-  if (__glutMappedMenu) {
-    __glutFatalUsage("entering game mode not allowed while menus in use");
-  }
-  if (__glutGameModeWindow) {
-    /* Already in game mode, so blow away game mode
-       window so apps can change resolutions. */
-    window = __glutGameModeWindow;
-    /* Setting the game mode window to NULL tricks
-       the window destroy code into not undoing the
-       screen display change since we plan on immediately
-       doing another mode change. */
-    __glutGameModeWindow = NULL;
-    __glutDestroyWindow(window, window);
-  }
-
-  /* Assume default screen size until we find out if we
-     can actually change the display settings. */
-  width = __glutScreenWidth;
-  height = __glutScreenHeight;
-
-  if (currentDm) {
-#ifdef _WIN32
-    LONG status;
-    static int registered = 0;
-
-    status = ChangeDisplaySettings(&currentDm->devmode,
-      CDS_FULLSCREEN);
-    if (status == DISP_CHANGE_SUCCESSFUL) {
-      __glutDisplaySettingsChanged = 1;
-      width = currentDm->cap[DM_WIDTH];
-      height = currentDm->cap[DM_HEIGHT];
-      if (!registered) {
-        atexit(__glutCloseDownGameMode);
-        registered = 1;
-      }
-    } else {
-      /* Switch back to default resolution. */
-      ChangeDisplaySettings(NULL, 0);
-    }
-#endif
-  }
-
-  window = __glutCreateWindow(NULL, 0, 0,
-    width, height, /* game mode */ 1);
-  win = window->win;
-
-#if !defined(_WIN32)
-  if (__glutMotifHints == None) {
-    __glutMotifHints = XSGIFastInternAtom(__glutDisplay, "_MOTIF_WM_HINTS",
-      SGI_XA__MOTIF_WM_HINTS, 0);
-    if (__glutMotifHints == None) {
-      __glutWarning("Could not intern X atom for _MOTIF_WM_HINTS.");
-    }
-  }
-
-  /* Game mode window is a toplevel window. */
-  XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1);
-#endif
-
-  /* Schedule the fullscreen property to be added and to
-     make sure the window is configured right.  Win32
-     doesn't need this. */
-  window->desiredX = 0;
-  window->desiredY = 0;
-  window->desiredWidth = width;
-  window->desiredHeight = height;
-  window->desiredConfMask |= CWX | CWY | CWWidth | CWHeight;
-#ifdef _WIN32
-  /* Win32 does not want to use GLUT_FULL_SCREEN_WORK
-     for game mode because we need to be maximizing
-     the window in game mode, not just sizing it to
-     take up the full screen.  The Win32-ness of game
-     mode happens when you pass 1 in the gameMode parameter
-     to __glutCreateWindow above.  A gameMode of creates
-     a WS_POPUP window, not a standard WS_OVERLAPPEDWINDOW
-     window.  WS_POPUP ensures the taskbar is hidden. */
-  __glutPutOnWorkList(window,
-    GLUT_CONFIGURE_WORK);
-#else
-  __glutPutOnWorkList(window,
-    GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK);
-#endif
-
-  __glutGameModeWindow = window;
-  return window->num + 1;
-}
-
-int GLUTAPIENTRY
-glutGameModeGet(GLenum mode)
-{
-  switch (mode) {
-  case GLUT_GAME_MODE_ACTIVE:
-    return __glutGameModeWindow != NULL;
-  case GLUT_GAME_MODE_POSSIBLE:
-    return currentDm != NULL;
-  case GLUT_GAME_MODE_WIDTH:
-    return currentDm ? currentDm->cap[DM_WIDTH] : -1;
-  case GLUT_GAME_MODE_HEIGHT:
-    return currentDm ? currentDm->cap[DM_HEIGHT] : -1;
-  case GLUT_GAME_MODE_PIXEL_DEPTH:
-    return currentDm ? currentDm->cap[DM_PIXEL_DEPTH] : -1;
-  case GLUT_GAME_MODE_REFRESH_RATE:
-    return currentDm ? currentDm->cap[DM_HERTZ] : -1;
-  case GLUT_GAME_MODE_DISPLAY_CHANGED:
-    return __glutDisplaySettingsChanged;
-  default:
-    return -1;
-  }
-}
diff --git a/src/glut/glx/glut_get.c b/src/glut/glx/glut_get.c
deleted file mode 100644 (file)
index 9c1ca6c..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <assert.h>
-#include <stdlib.h>  /* SunOS 4 needs NULL defined for GETTIMEOFDAY macro. */
-#include "glutint.h"
-
-/* CENTRY */
-int GLUTAPIENTRY 
-glutGet(GLenum param)
-{
-  Window win, root;
-  int x, y, value;
-  unsigned int width, height, border, depth;
-
-  switch (param) {
-  case GLUT_INIT_WINDOW_X:
-    return __glutInitX;
-  case GLUT_INIT_WINDOW_Y:
-    return __glutInitY;
-  case GLUT_INIT_WINDOW_WIDTH:
-    return __glutInitWidth;
-  case GLUT_INIT_WINDOW_HEIGHT:
-    return __glutInitHeight;
-  case GLUT_INIT_DISPLAY_MODE:
-    return __glutDisplayMode;
-  case GLUT_WINDOW_X:
-    XTranslateCoordinates(__glutDisplay, __glutCurrentWindow->win,
-      __glutRoot, 0, 0, &x, &y, &win);
-    return x;
-  case GLUT_WINDOW_Y:
-    XTranslateCoordinates(__glutDisplay, __glutCurrentWindow->win,
-      __glutRoot, 0, 0, &x, &y, &win);
-    return y;
-  case GLUT_WINDOW_WIDTH:
-    if (!__glutCurrentWindow->reshape) {
-      XGetGeometry(__glutDisplay, __glutCurrentWindow->win,
-        &root, &x, &y,
-        &width, &height, &border, &depth);
-      return width;
-    }
-    return __glutCurrentWindow->width;
-  case GLUT_WINDOW_HEIGHT:
-    if (!__glutCurrentWindow->reshape) {
-      XGetGeometry(__glutDisplay, __glutCurrentWindow->win,
-        &root, &x, &y,
-        &width, &height, &border, &depth);
-      return height;
-    }
-    return __glutCurrentWindow->height;
-
-#define GET_CONFIG(attrib) { \
-  if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) { \
-    glXGetConfig(__glutDisplay, __glutCurrentWindow->vis, \
-      attrib, &value); \
-  } else { \
-    glXGetConfig(__glutDisplay, __glutCurrentWindow->overlay->vis, \
-      attrib, &value); \
-  } \
-}
-
-  case GLUT_WINDOW_BUFFER_SIZE:
-    GET_CONFIG(GLX_BUFFER_SIZE);
-    return value;
-  case GLUT_WINDOW_STENCIL_SIZE:
-    GET_CONFIG(GLX_STENCIL_SIZE);
-    return value;
-  case GLUT_WINDOW_DEPTH_SIZE:
-    GET_CONFIG(GLX_DEPTH_SIZE);
-    return value;
-  case GLUT_WINDOW_RED_SIZE:
-    GET_CONFIG(GLX_RED_SIZE);
-    return value;
-  case GLUT_WINDOW_GREEN_SIZE:
-    GET_CONFIG(GLX_GREEN_SIZE);
-    return value;
-  case GLUT_WINDOW_BLUE_SIZE:
-    GET_CONFIG(GLX_BLUE_SIZE);
-    return value;
-  case GLUT_WINDOW_ALPHA_SIZE:
-    GET_CONFIG(GLX_ALPHA_SIZE);
-    return value;
-  case GLUT_WINDOW_ACCUM_RED_SIZE:
-    GET_CONFIG(GLX_ACCUM_RED_SIZE);
-    return value;
-  case GLUT_WINDOW_ACCUM_GREEN_SIZE:
-    GET_CONFIG(GLX_ACCUM_GREEN_SIZE);
-    return value;
-  case GLUT_WINDOW_ACCUM_BLUE_SIZE:
-    GET_CONFIG(GLX_ACCUM_BLUE_SIZE);
-    return value;
-  case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
-    GET_CONFIG(GLX_ACCUM_ALPHA_SIZE);
-    return value;
-  case GLUT_WINDOW_DOUBLEBUFFER:
-    GET_CONFIG(GLX_DOUBLEBUFFER);
-    return value;
-  case GLUT_WINDOW_RGBA:
-    GET_CONFIG(GLX_RGBA);
-    return value;
-  case GLUT_WINDOW_COLORMAP_SIZE:
-    GET_CONFIG(GLX_RGBA);
-    if (value) {
-      return 0;
-    } else {
-#if defined(_WIN32)
-      /* KLUDGE: we always assume 256 colors in CI mode on
-         Win32 */
-      return 256;
-#else
-      if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) { 
-        return __glutCurrentWindow->vis->visual->map_entries;
-      } else {
-        return __glutCurrentWindow->overlay->vis->visual->map_entries;
-      }
-#endif /* _WIN32 */
-    }
-  case GLUT_WINDOW_PARENT:
-    return __glutCurrentWindow->parent ?
-      __glutCurrentWindow->parent->num + 1 : 0;
-  case GLUT_WINDOW_NUM_CHILDREN:
-    {
-      int num = 0;
-      GLUTwindow *children = __glutCurrentWindow->children;
-
-      while (children) {
-        num++;
-        children = children->siblings;
-      }
-      return num;
-    }
-  case GLUT_WINDOW_NUM_SAMPLES:
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample)
-    if (__glutIsSupportedByGLX("GLX_SGIS_multisample")) {
-      GET_CONFIG(GLX_SAMPLES_SGIS);
-      return value;
-    } else {
-      return 0;
-    }
-#else
-    /* Independent of GLX server support, multisampling not
-       supported by GLX client-side. */
-    return 0;
-#endif
-  case GLUT_WINDOW_STEREO:
-    GET_CONFIG(GLX_STEREO);
-    return value;
-  case GLUT_WINDOW_CURSOR:
-    return __glutCurrentWindow->cursor;
-  case GLUT_SCREEN_WIDTH:
-    return DisplayWidth(__glutDisplay, __glutScreen);
-  case GLUT_SCREEN_HEIGHT:
-    return DisplayHeight(__glutDisplay, __glutScreen);
-  case GLUT_SCREEN_WIDTH_MM:
-    return DisplayWidthMM(__glutDisplay, __glutScreen);
-  case GLUT_SCREEN_HEIGHT_MM:
-    return DisplayHeightMM(__glutDisplay, __glutScreen);
-  case GLUT_MENU_NUM_ITEMS:
-    return __glutCurrentMenu->num;
-  case GLUT_DISPLAY_MODE_POSSIBLE:
-    {
-      XVisualInfo *vi;
-      Bool dummy, visAlloced;
-      void *fbc;
-
-#if defined(_WIN32)      
-      /* Our fake glXChooseVisual (which is called by
-         __glutDetermineVisual) needs an HDC to work with, so grab one
-         from the "root" window. */
-      XHDC = GetDC(GetDesktopWindow());
-#endif
-      vi = __glutDetermineWindowVisual(&dummy, &visAlloced, &fbc);
-#if defined(_WIN32)      
-      ReleaseDC(GetDesktopWindow(), XHDC);
-#endif
-      if (vi) {
-        if (visAlloced)
-          XFree(vi);
-        return 1;
-      }
-      return 0;
-    }
-  case GLUT_ELAPSED_TIME:
-    {
-#ifdef OLD_VMS
-       struct timeval6 elapsed, beginning, now;
-#else
-       struct timeval elapsed, beginning, now;
-#endif
-
-       __glutInitTime(&beginning);
-      GETTIMEOFDAY(&now);
-      TIMEDELTA(elapsed, now, beginning);
-      /* Return elapsed milliseconds. */
-#if defined(__vms) && ( __VMS_VER < 70000000 )
-      return (int) (elapsed.val / TICKS_PER_MILLISECOND);
-#else
-      return (int) ((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000));
-#endif
-    }
-  case GLUT_WINDOW_FORMAT_ID:
-#if defined(_WIN32)
-    return GetPixelFormat(__glutCurrentWindow->hdc);
-#else
-    if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
-      return (int) __glutCurrentWindow->vis->visualid;
-    } else {
-      return (int) __glutCurrentWindow->overlay->vis->visualid;
-    }
-#endif
-  default:
-    __glutWarning("invalid glutGet parameter: %d", param);
-    return -1;
-  }
-}
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_glxext.c b/src/glut/glx/glut_glxext.c
deleted file mode 100644 (file)
index 71b67e0..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-#include <string.h>
-#include "glutint.h"
-
-#if defined(GLX_VERSION_1_1)
-int
-__glutIsSupportedByGLX(char *extension)
-{
-  static const char *extensions = NULL;
-  const char *start;
-  char *where, *terminator;
-  int major, minor;
-
-  glXQueryVersion(__glutDisplay, &major, &minor);
-  /* Be careful not to call glXQueryExtensionsString if it
-     looks like the server doesn't support GLX 1.1.
-     Unfortunately, the original GLX 1.0 didn't have the notion
-     of GLX extensions. */
-  if ((major == 1 && minor >= 1) || (major > 1)) {
-    if (!extensions)
-      extensions = glXQueryExtensionsString(__glutDisplay, __glutScreen);
-    /* It takes a bit of care to be fool-proof about parsing
-       the GLX extensions string.  Don't be fooled by
-       sub-strings,  etc. */
-    start = extensions;
-    for (;;) {
-      where = strstr(start, extension);
-      if (!where)
-        return 0;
-      terminator = where + strlen(extension);
-      if (where == start || *(where - 1) == ' ') {
-        if (*terminator == ' ' || *terminator == '\0') {
-          return 1;
-        }
-      }
-      start = terminator;
-    }
-  }
-  return 0;
-}
-#endif
-
-
-
-/*
- * Wrapping of GLX extension functions.
- * Technically, we should do a runtime test to see if we've got the
- * glXGetProcAddressARB() function.  I think GLX_ARB_get_proc_address
- * is pretty widely supported now and any system that has
- * GLX_ARB_get_proc_address defined in its header files should be OK
- * at runtime.
- */
-
-int
-__glut_glXBindChannelToWindowSGIX(Display *dpy, int screen,
-                                  int channel, Window window)
-{
-#ifdef GLX_ARB_get_proc_address
-  typedef int (*glXBindChannelToWindowSGIX_t) (Display *, int, int, Window);
-  static glXBindChannelToWindowSGIX_t glXBindChannelToWindowSGIX_ptr = NULL;
-  if (!glXBindChannelToWindowSGIX_ptr) {
-    glXBindChannelToWindowSGIX_ptr = (glXBindChannelToWindowSGIX_t)
-      glXGetProcAddressARB((const GLubyte *) "glXBindChannelToWindowSGIX");
-  }
-  if (glXBindChannelToWindowSGIX_ptr)
-    return (*glXBindChannelToWindowSGIX_ptr)(dpy, screen, channel, window);
-  else
-    return 0;
-#elif defined(GLX_SGIX_video_resize)
-  return glXBindChannelToWindowSGIX(dpy, screen, channel, window);
-#else
-  return 0;
-#endif   
-}
-
-
-int
-__glut_glXChannelRectSGIX(Display *dpy, int screen, int channel,
-                          int x, int y, int w, int h)
-{
-#ifdef GLX_ARB_get_proc_address
-  typedef int (*glXChannelRectSGIX_t)(Display *, int, int, int, int, int, int);
-  static glXChannelRectSGIX_t glXChannelRectSGIX_ptr = NULL;
-  if (!glXChannelRectSGIX_ptr) {
-    glXChannelRectSGIX_ptr = (glXChannelRectSGIX_t)
-      glXGetProcAddressARB((const GLubyte *) "glXChannelRectSGIX");
-  }
-  if (glXChannelRectSGIX_ptr)
-    return (*glXChannelRectSGIX_ptr)(dpy, screen, channel, x, y, w, h);
-  else
-    return 0;
-#elif defined(GLX_SGIX_video_resize)
-  return glXChannelRectSGIX(dpy, screen, channel, x, y, w, h);
-#else
-  return 0;
-#endif   
-}
-
-
-int
-__glut_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel,
-                               int *x, int *y, int *w, int *h)
-{
-#ifdef GLX_ARB_get_proc_address
-  typedef int (*glXQueryChannelRectSGIX_t)(Display *, int, int,
-                                           int *, int *, int *, int *);
-  static glXQueryChannelRectSGIX_t glXQueryChannelRectSGIX_ptr = NULL;
-  if (!glXQueryChannelRectSGIX_ptr) {
-    glXQueryChannelRectSGIX_ptr = (glXQueryChannelRectSGIX_t)
-      glXGetProcAddressARB((const GLubyte *) "glXQueryChannelRectSGIX");
-  }
-  if (glXQueryChannelRectSGIX_ptr)
-    return (*glXQueryChannelRectSGIX_ptr)(dpy, screen, channel, x, y, w, h);
-  else
-    return 0;
-#elif defined(GLX_SGIX_video_resize)
-  return glXQueryChannelRectSGIX(dpy, screen, channel, x, y, w, h);
-#else
-  return 0;
-#endif   
-}
-
-
-int
-__glut_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel,
-                                 int *dx, int *dy, int *dw, int *dh)
-{
-#ifdef GLX_ARB_get_proc_address
-  typedef int (*glXQueryChannelDeltasSGIX_t)(Display *, int, int,
-                                             int *, int *, int *, int *);
-  static glXQueryChannelDeltasSGIX_t glXQueryChannelDeltasSGIX_ptr = NULL;
-  if (!glXQueryChannelDeltasSGIX_ptr) {
-    glXQueryChannelDeltasSGIX_ptr = (glXQueryChannelDeltasSGIX_t)
-      glXGetProcAddressARB((const GLubyte *) "glXQueryChannelDeltasSGIX");
-  }
-  if (glXQueryChannelDeltasSGIX_ptr)
-    return (*glXQueryChannelDeltasSGIX_ptr)(dpy, screen, channel,
-                                            dx, dy, dw, dh);
-  else
-    return 0;
-#elif defined(GLX_SGIX_video_resize)
-  return glXQueryChannelDeltasSGIX(dpy, screen, channel, dx, dy, dw, dh);
-#else
-  return 0;
-#endif   
-}
-
-
-int
-__glut_glXChannelRectSyncSGIX(Display *dpy, int screen,
-                              int channel, GLenum synctype)
-{
-#ifdef GLX_ARB_get_proc_address
-  typedef int (*glXChannelRectSyncSGIX_t)(Display *, int, int, GLenum);
-  static glXChannelRectSyncSGIX_t glXChannelRectSyncSGIX_ptr = NULL;
-  if (!glXChannelRectSyncSGIX_ptr) {
-    glXChannelRectSyncSGIX_ptr = (glXChannelRectSyncSGIX_t)
-      glXGetProcAddressARB((const GLubyte *) "glXChannelRectSyncSGIX");
-  }
-  if (glXChannelRectSyncSGIX_ptr)
-    return (*glXChannelRectSyncSGIX_ptr)(dpy, screen, channel, synctype);
-  else
-    return 0;
-#elif defined(GLX_SGIX_video_resize)
-  return glXChannelRectSyncSGIX(dpy, screen, channel, synctype);
-#else
-  return 0;
-#endif   
-}
-
-
-
-GLXContext
-__glut_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config,
-                                      int render_type, GLXContext share_list,
-                                      Bool direct)
-{
-#ifdef GLX_ARB_get_proc_address
-  typedef GLXContext (*glXCreateContextWithConfigSGIX_t)(Display *,
-                                 GLXFBConfigSGIX, int, GLXContext, Bool);
-  static glXCreateContextWithConfigSGIX_t glXCreateContextWithConfig_ptr = NULL;
-  if (!glXCreateContextWithConfig_ptr) {
-    glXCreateContextWithConfig_ptr = (glXCreateContextWithConfigSGIX_t)
-       glXGetProcAddressARB((const GLubyte *) "glXCreateContextWithConfigSGIX");
-  }
-  if (glXCreateContextWithConfig_ptr)
-    return (*glXCreateContextWithConfig_ptr)(dpy, config, render_type,
-                                             share_list, direct);
-  else
-    return 0;
-#elif defined(GLX_SGIX_fbconfig)
-  return glXCreateContextWithConfigSGIX(dpy, config, render_type,
-                                        share_list, direct);
-#else
-  return 0;
-#endif
-}
-
-
-int
-__glut_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config,
-                                int attribute, int *value)
-{
-#ifdef GLX_ARB_get_proc_address
-  typedef int (*glXGetFBConfigAttribSGIX_t)(Display *,
-                                            GLXFBConfigSGIX, int, int *);
-  static glXGetFBConfigAttribSGIX_t glXGetFBConfigAttrib_ptr = NULL;
-  if (!glXGetFBConfigAttrib_ptr) {
-    glXGetFBConfigAttrib_ptr = (glXGetFBConfigAttribSGIX_t)
-       glXGetProcAddressARB((const GLubyte *) "glXGetFBConfigAttribSGIX");
-  }
-  if (glXGetFBConfigAttrib_ptr)
-    return (*glXGetFBConfigAttrib_ptr)(dpy, config, attribute, value);
-  else
-    return 0;
-#elif defined(GLX_SGIX_fbconfig)
-  return glXGetFBConfigAttribSGIX(dpy, config, attribute, value);
-#else
-  return 0;
-#endif
-}
-
-
-GLXFBConfigSGIX
-__glut_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
-{
-#ifdef GLX_ARB_get_proc_address
-  typedef GLXFBConfigSGIX (*glXGetFBConfigFromVisualSGIX_t)(Display *,
-                                                            XVisualInfo *);
-  static glXGetFBConfigFromVisualSGIX_t glXGetFBConfigFromVisual_ptr = NULL;
-  if (!glXGetFBConfigFromVisual_ptr) {
-    glXGetFBConfigFromVisual_ptr = (glXGetFBConfigFromVisualSGIX_t)
-       glXGetProcAddressARB((const GLubyte *) "glXGetFBConfigFromVisualSGIX");
-  }
-  if (glXGetFBConfigFromVisual_ptr)
-    return (*glXGetFBConfigFromVisual_ptr)(dpy, vis);
-  else
-    return 0;
-#elif defined(GLX_SGIX_fbconfig)
-  return glXGetFBConfigFromVisualSGIX(dpy, vis);
-#else
-  return 0;
-#endif
-}
-
-
-
-
diff --git a/src/glut/glx/glut_hel10.c b/src/glut/glx/glut_hel10.c
deleted file mode 100644 (file)
index 3de1750..0000000
+++ /dev/null
@@ -1,1779 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapHelvetica10 XXX
-#include "glutbitmap.h"
-#undef glutBitmapHelvetica10
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x80,0x40,0x40,0x60,0xa0,0xa0,0x90,0x90,0x0,0x50,
-};
-
-static const BitmapCharRec ch255 = {4,10,0,2,5,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {5,10,0,2,6,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x80,0x40,0x40,0x60,0xa0,0xa0,0x90,0x90,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch253 = {4,11,0,2,5,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,0x0,0x50,
-};
-
-static const BitmapCharRec ch252 = {4,8,0,0,5,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch251 = {4,9,0,0,5,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch250 = {4,9,0,0,5,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch249 = {4,9,0,0,5,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0x70,0x88,0xc8,0xa8,0x98,0x74,
-};
-
-static const BitmapCharRec ch248 = {6,6,0,0,6,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x20,0x0,0xf8,0x0,0x20,
-};
-
-static const BitmapCharRec ch247 = {5,5,0,-1,6,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x50,
-};
-
-static const BitmapCharRec ch246 = {5,8,0,0,6,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch245 = {5,9,0,0,6,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch244 = {5,9,0,0,6,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch243 = {5,9,0,0,6,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch242 = {5,9,0,0,6,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0x90,0x90,0x90,0x90,0x90,0xe0,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch241 = {4,9,0,0,5,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x70,0x88,0x88,0x88,0x88,0x78,0x90,0x60,0x50,
-};
-
-static const BitmapCharRec ch240 = {5,9,0,0,6,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,
-};
-
-static const BitmapCharRec ch239 = {3,8,0,0,2,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch238 = {3,9,1,0,2,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x40,
-};
-
-static const BitmapCharRec ch237 = {2,9,0,0,2,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch236 = {2,9,1,0,2,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,0x0,0x50,
-};
-
-static const BitmapCharRec ch235 = {4,8,0,0,5,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch234 = {4,9,0,0,5,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch233 = {4,9,0,0,5,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch232 = {4,9,0,0,5,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x60,0x20,0x60,0x90,0x80,0x80,0x90,0x60,
-};
-
-static const BitmapCharRec ch231 = {4,8,0,2,5,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x6c,0x92,0x90,0x7e,0x12,0xec,
-};
-
-static const BitmapCharRec ch230 = {7,6,0,0,8,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x20,0x50,0x20,
-};
-
-static const BitmapCharRec ch229 = {5,9,0,0,5,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0x50,
-};
-
-static const BitmapCharRec ch228 = {5,8,0,0,5,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch227 = {5,9,0,0,5,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch226 = {5,9,0,0,5,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch225 = {5,9,0,0,5,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch224 = {5,9,0,0,5,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xa0,0x90,0x90,0x90,0xa0,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch223 = {4,8,0,0,5,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0x80,0x80,0xf0,0x88,0x88,0xf0,0x80,0x80,
-};
-
-static const BitmapCharRec ch222 = {5,8,-1,0,7,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x10,0x10,0x10,0x28,0x28,0x44,0x44,0x82,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch221 = {7,11,0,0,7,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x48,
-};
-
-static const BitmapCharRec ch220 = {6,10,-1,0,8,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch219 = {6,11,-1,0,8,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch218 = {6,11,-1,0,8,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch217 = {6,11,-1,0,8,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x78,0xc4,0xa4,0xa4,0x94,0x94,0x8c,0x78,0x4,
-};
-
-static const BitmapCharRec ch216 = {6,10,-1,1,8,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x88,0x50,0x20,0x50,0x88,
-};
-
-static const BitmapCharRec ch215 = {5,5,0,-1,6,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x48,
-};
-
-static const BitmapCharRec ch214 = {6,10,-1,0,8,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch213 = {6,11,-1,0,8,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch212 = {6,11,-1,0,8,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch211 = {6,11,-1,0,8,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch210 = {6,11,-1,0,8,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0x8c,0x8c,0x94,0x94,0xa4,0xa4,0xc4,0xc4,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch209 = {6,11,-1,0,8,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0x78,0x44,0x42,0x42,0xf2,0x42,0x44,0x78,
-};
-
-static const BitmapCharRec ch208 = {7,8,0,0,8,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,
-};
-
-static const BitmapCharRec ch207 = {3,10,0,0,3,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch206 = {3,11,0,0,3,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x40,
-};
-
-static const BitmapCharRec ch205 = {2,11,-1,0,3,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch204 = {2,11,0,0,3,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,0x0,0x50,
-};
-
-static const BitmapCharRec ch203 = {5,10,-1,0,7,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xf8,0x80,0x80,0xf8,0x80,0x80,0x80,0xf8,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch202 = {5,11,-1,0,7,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch201 = {5,11,-1,0,7,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch200 = {5,11,-1,0,7,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x30,0x10,0x78,0x84,0x80,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch199 = {6,10,-1,2,8,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0x8f,0x80,0x88,0x0,0x78,0x0,0x48,0x0,0x2f,0x80,0x28,0x0,0x18,0x0,0x1f,0x80,
-};
-
-static const BitmapCharRec ch198 = {9,8,0,0,10,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x10,0x28,0x10,
-};
-
-static const BitmapCharRec ch197 = {7,11,0,0,7,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x28,
-};
-
-static const BitmapCharRec ch196 = {7,10,0,0,7,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch195 = {7,11,0,0,7,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch194 = {7,11,0,0,7,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch193 = {7,11,0,0,7,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch192 = {7,11,0,0,7,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x60,0x90,0x80,0x40,0x20,0x20,0x0,0x20,
-};
-
-static const BitmapCharRec ch191 = {4,8,-1,2,6,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x21,0x0,0x17,0x80,0x13,0x0,0x9,0x0,0xc8,0x0,0x24,0x0,0x44,0x0,0xe2,0x0,
-};
-
-static const BitmapCharRec ch190 = {9,8,0,0,9,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x27,0x12,0x15,0xb,0x48,0x44,0xc4,0x42,
-};
-
-static const BitmapCharRec ch189 = {8,8,0,0,9,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x21,0x0,0x17,0x80,0x13,0x0,0x9,0x0,0x48,0x0,0x44,0x0,0xc4,0x0,0x42,0x0,
-};
-
-static const BitmapCharRec ch188 = {9,8,0,0,9,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0xa0,0x50,0x28,0x50,0xa0,
-};
-
-static const BitmapCharRec ch187 = {5,5,0,0,6,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xe0,0x0,0xe0,0xa0,0xe0,
-};
-
-static const BitmapCharRec ch186 = {3,5,0,-3,4,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {2,4,0,-3,3,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xc0,0x40,
-};
-
-static const BitmapCharRec ch184 = {2,2,0,2,3,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,1,0,-3,3,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x28,0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,0x7c,
-};
-
-static const BitmapCharRec ch182 = {6,10,0,2,6,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0x80,0xf0,0x90,0x90,0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch181 = {4,8,0,2,5,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x40,
-};
-
-static const BitmapCharRec ch180 = {2,2,0,-6,3,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0xc0,0x20,0x40,0xe0,
-};
-
-static const BitmapCharRec ch179 = {3,4,0,-3,3,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xe0,0x40,0xa0,0x60,
-};
-
-static const BitmapCharRec ch178 = {3,4,0,-3,3,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xf8,0x0,0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch177 = {5,7,0,0,6,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,0,-3,4,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xe0,
-};
-
-static const BitmapCharRec ch175 = {3,1,0,-7,3,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x38,0x44,0xaa,0xb2,0xba,0x44,0x38,
-};
-
-static const BitmapCharRec ch174 = {7,7,-1,0,9,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xe0,
-};
-
-static const BitmapCharRec ch173 = {3,1,0,-3,4,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x8,0x8,0xf8,
-};
-
-static const BitmapCharRec ch172 = {5,3,-1,-2,7,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x28,0x50,0xa0,0x50,0x28,
-};
-
-static const BitmapCharRec ch171 = {5,5,0,0,6,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xe0,0x0,0xa0,0x20,0xe0,
-};
-
-static const BitmapCharRec ch170 = {3,5,0,-3,4,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x38,0x44,0x9a,0xa2,0x9a,0x44,0x38,
-};
-
-static const BitmapCharRec ch169 = {7,7,-1,0,9,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xa0,
-};
-
-static const BitmapCharRec ch168 = {3,1,0,-7,3,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x70,0x88,0x18,0x70,0xc8,0x98,0x70,0xc0,0x88,0x70,
-};
-
-static const BitmapCharRec ch167 = {5,10,0,2,6,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x80,0x0,0x0,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,10,-1,2,3,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x20,0xf8,0x20,0xf8,0x50,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch165 = {5,8,0,0,6,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x90,0x60,0x90,0x90,0x60,0x90,
-};
-
-static const BitmapCharRec ch164 = {4,6,0,-1,5,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xb0,0x48,0x40,0x40,0xe0,0x40,0x48,0x30,
-};
-
-static const BitmapCharRec ch163 = {5,8,0,0,6,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x40,0x70,0xa8,0xa0,0xa0,0xa8,0x70,0x10,
-};
-
-static const BitmapCharRec ch162 = {5,8,0,1,6,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,8,-1,2,3,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,3,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,3,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x98,0x64,
-};
-
-static const BitmapCharRec ch126 = {6,2,0,-3,7,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0x80,0x40,0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch125 = {3,10,0,2,3,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,10,-1,2,3,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x20,0x40,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch123 = {3,10,0,2,3,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xf0,0x80,0x40,0x20,0x10,0xf0,
-};
-
-static const BitmapCharRec ch122 = {4,6,0,0,5,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x80,0x40,0x40,0x60,0xa0,0xa0,0x90,0x90,
-};
-
-static const BitmapCharRec ch121 = {4,8,0,2,5,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0x88,0x88,0x50,0x20,0x50,0x88,
-};
-
-static const BitmapCharRec ch120 = {5,6,0,0,6,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x28,0x28,0x54,0x54,0x92,0x92,
-};
-
-static const BitmapCharRec ch119 = {7,6,0,0,8,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x20,0x20,0x50,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch118 = {5,6,0,0,6,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x70,0x90,0x90,0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch117 = {4,6,0,0,5,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x60,0x40,0x40,0x40,0x40,0xe0,0x40,0x40,
-};
-
-static const BitmapCharRec ch116 = {3,8,0,0,4,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x60,0x90,0x10,0x60,0x90,0x60,
-};
-
-static const BitmapCharRec ch115 = {4,6,0,0,5,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0x80,0x80,0x80,0x80,0xc0,0xa0,
-};
-
-static const BitmapCharRec ch114 = {3,6,0,0,4,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x8,0x8,0x68,0x98,0x88,0x88,0x98,0x68,
-};
-
-static const BitmapCharRec ch113 = {5,8,0,2,6,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,0xb0,
-};
-
-static const BitmapCharRec ch112 = {5,8,0,2,6,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch111 = {5,6,0,0,6,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0x88,0x88,0x88,0x88,0xc8,0xb0,
-};
-
-static const BitmapCharRec ch110 = {5,6,0,0,6,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0x92,0x92,0x92,0x92,0x92,0xec,
-};
-
-static const BitmapCharRec ch109 = {7,6,0,0,8,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch108 = {1,8,0,0,2,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x90,0x90,0xa0,0xc0,0xa0,0x90,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {4,8,0,0,5,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch106 = {1,9,0,1,2,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch105 = {1,8,0,0,2,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0x88,0x88,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {5,8,0,0,6,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x70,0x8,0x68,0x98,0x88,0x88,0x98,0x68,
-};
-
-static const BitmapCharRec ch103 = {5,8,0,2,6,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x40,0x40,0x40,0x40,0x40,0xe0,0x40,0x30,
-};
-
-static const BitmapCharRec ch102 = {4,8,0,0,4,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x60,0x90,0x80,0xf0,0x90,0x60,
-};
-
-static const BitmapCharRec ch101 = {4,6,0,0,5,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x68,0x98,0x88,0x88,0x98,0x68,0x8,0x8,
-};
-
-static const BitmapCharRec ch100 = {5,8,0,0,6,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x60,0x90,0x80,0x80,0x90,0x60,
-};
-
-static const BitmapCharRec ch99 = {4,6,0,0,5,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xb0,0xc8,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {5,8,0,0,6,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x68,0x90,0x90,0x70,0x10,0xe0,
-};
-
-static const BitmapCharRec ch97 = {5,6,0,0,5,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0x80,0x80,0x40,
-};
-
-static const BitmapCharRec ch96 = {2,3,0,-5,3,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xfc,
-};
-
-static const BitmapCharRec ch95 = {6,1,0,2,6,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x88,0x50,0x50,0x20,0x20,
-};
-
-static const BitmapCharRec ch94 = {5,5,0,-3,6,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,
-};
-
-static const BitmapCharRec ch93 = {2,10,0,2,3,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x20,0x20,0x40,0x40,0x40,0x40,0x80,0x80,
-};
-
-static const BitmapCharRec ch92 = {3,8,0,0,3,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
-};
-
-static const BitmapCharRec ch91 = {2,10,-1,2,3,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xf8,0x80,0x40,0x20,0x20,0x10,0x8,0xf8,
-};
-
-static const BitmapCharRec ch90 = {5,8,-1,0,7,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x10,0x10,0x10,0x28,0x28,0x44,0x44,0x82,
-};
-
-static const BitmapCharRec ch89 = {7,8,0,0,7,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0x88,0x88,0x50,0x50,0x20,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch88 = {5,8,-1,0,7,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x22,0x0,0x22,0x0,0x22,0x0,0x55,0x0,0x49,0x0,0x49,0x0,0x88,0x80,0x88,0x80,
-};
-
-static const BitmapCharRec ch87 = {9,8,0,0,9,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x28,0x28,0x44,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch86 = {7,8,0,0,7,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch85 = {6,8,-1,0,8,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xf8,
-};
-
-static const BitmapCharRec ch84 = {5,8,0,0,5,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x70,0x88,0x88,0x8,0x70,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch83 = {5,8,-1,0,7,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0x88,0x88,0x88,0x88,0xf0,0x88,0x88,0xf0,
-};
-
-static const BitmapCharRec ch82 = {5,8,-1,0,7,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x2,0x7c,0x8c,0x94,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch81 = {7,9,-1,1,8,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0x80,0x80,0x80,0x80,0xf0,0x88,0x88,0xf0,
-};
-
-static const BitmapCharRec ch80 = {5,8,-1,0,7,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x78,
-};
-
-static const BitmapCharRec ch79 = {6,8,-1,0,8,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0x8c,0x8c,0x94,0x94,0xa4,0xa4,0xc4,0xc4,
-};
-
-static const BitmapCharRec ch78 = {6,8,-1,0,8,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0x92,0x92,0x92,0xaa,0xaa,0xc6,0xc6,0x82,
-};
-
-static const BitmapCharRec ch77 = {7,8,-1,0,9,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xf0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch76 = {4,8,-1,0,6,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0x88,0x88,0x90,0x90,0xe0,0xa0,0x90,0x88,
-};
-
-static const BitmapCharRec ch75 = {5,8,-1,0,7,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x60,0x90,0x10,0x10,0x10,0x10,0x10,0x10,
-};
-
-static const BitmapCharRec ch74 = {4,8,0,0,5,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch73 = {1,8,-1,0,3,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0x84,0x84,0x84,0x84,0xfc,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch72 = {6,8,-1,0,8,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x74,0x8c,0x84,0x8c,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch71 = {6,8,-1,0,8,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0x80,0x80,0x80,0x80,0xf0,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch70 = {5,8,-1,0,6,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch69 = {5,8,-1,0,7,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xf0,0x88,0x84,0x84,0x84,0x84,0x88,0xf0,
-};
-
-static const BitmapCharRec ch68 = {6,8,-1,0,8,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x78,0x84,0x80,0x80,0x80,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch67 = {6,8,-1,0,8,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xf0,0x88,0x88,0x88,0xf0,0x88,0x88,0xf0,
-};
-
-static const BitmapCharRec ch66 = {5,8,-1,0,7,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,
-};
-
-static const BitmapCharRec ch65 = {7,8,0,0,7,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x3e,0x0,0x40,0x0,0x9b,0x0,0xa4,0x80,0xa4,0x80,0xa2,0x40,0x92,0x40,0x4d,0x40,
-0x20,0x80,0x1f,0x0,
-};
-
-static const BitmapCharRec ch64 = {10,10,0,2,11,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x40,0x0,0x40,0x40,0x20,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch63 = {4,8,-1,0,6,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0x80,0x40,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch62 = {3,5,-1,-1,6,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xf0,0x0,0xf0,
-};
-
-static const BitmapCharRec ch61 = {4,3,0,-2,5,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x20,0x40,0x80,0x40,0x20,
-};
-
-static const BitmapCharRec ch60 = {3,5,-1,-1,6,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x40,0x40,0x0,0x0,0x0,0x0,0x40,
-};
-
-static const BitmapCharRec ch59 = {2,8,0,2,3,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0x80,0x0,0x0,0x0,0x0,0x80,
-};
-
-static const BitmapCharRec ch58 = {1,6,-1,0,3,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x70,0x88,0x8,0x68,0x98,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch57 = {5,8,0,0,6,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x70,0x88,0x88,0x88,0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch56 = {5,8,0,0,6,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x20,0x20,0x10,0x10,0x8,0xf8,
-};
-
-static const BitmapCharRec ch55 = {5,8,0,0,6,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x70,0x88,0x88,0xc8,0xb0,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch54 = {5,8,0,0,6,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x70,0x88,0x8,0x8,0xf0,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch53 = {5,8,0,0,6,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x10,0x10,0xf8,0x90,0x50,0x50,0x30,0x10,
-};
-
-static const BitmapCharRec ch52 = {5,8,0,0,6,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x70,0x88,0x8,0x8,0x30,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch51 = {5,8,0,0,6,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xf8,0x80,0x40,0x30,0x8,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch50 = {5,8,0,0,6,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch49 = {2,8,-1,0,6,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch48 = {5,8,0,0,6,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x80,0x40,0x40,0x40,0x40,0x20,0x20,
-};
-
-static const BitmapCharRec ch47 = {3,8,0,0,3,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch46 = {1,1,-1,0,3,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xf8,
-};
-
-static const BitmapCharRec ch45 = {5,1,-1,-3,7,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x40,0x40,
-};
-
-static const BitmapCharRec ch44 = {2,3,0,2,3,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch43 = {5,5,0,-1,6,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0xa0,0x40,0xa0,
-};
-
-static const BitmapCharRec ch42 = {3,3,0,-5,4,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,10,-1,2,4,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,10,0,2,4,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x40,0x40,
-};
-
-static const BitmapCharRec ch39 = {2,3,-1,-5,3,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x64,0x98,0x98,0xa4,0x60,0x50,0x50,0x20,
-};
-
-static const BitmapCharRec ch38 = {6,8,-1,0,8,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x26,0x29,0x16,0x10,0x8,0x68,0x94,0x64,
-};
-
-static const BitmapCharRec ch37 = {8,8,0,0,9,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x20,0x70,0xa8,0x28,0x70,0xa0,0xa8,0x70,0x20,
-};
-
-static const BitmapCharRec ch36 = {5,9,0,1,6,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x50,0x50,0xf8,0x28,0x7c,0x28,0x28,
-};
-
-static const BitmapCharRec ch35 = {6,7,0,0,6,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0xa0,0xa0,
-};
-
-static const BitmapCharRec ch34 = {3,2,-1,-6,4,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x0,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,8,-1,0,3,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {0,0,0,0,3,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,3,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-GLUTAPI const BitmapFontRec glutBitmapHelvetica10;
-const BitmapFontRec glutBitmapHelvetica10 = {
-"-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/glx/glut_hel12.c b/src/glut/glx/glut_hel12.c
deleted file mode 100644 (file)
index e6f1bbb..0000000
+++ /dev/null
@@ -1,1789 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapHelvetica12 XXX
-#include "glutbitmap.h"
-#undef glutBitmapHelvetica12
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0xc0,0x20,0x20,0x20,0x30,0x50,0x50,0x48,0x88,0x88,0x0,0x50,
-};
-
-static const BitmapCharRec ch255 = {5,12,-1,3,7,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0x80,0x80,0x80,0xb0,0xc8,0x88,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {5,12,-1,3,7,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x80,0x40,0x20,0x20,0x50,0x50,0x90,0x88,0x88,0x88,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch253 = {5,13,-1,3,7,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,0x0,0x50,
-};
-
-static const BitmapCharRec ch252 = {5,9,-1,0,7,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch251 = {5,10,-1,0,7,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch250 = {5,10,-1,0,7,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch249 = {5,10,-1,0,7,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0xb8,0x44,0x64,0x54,0x4c,0x44,0x3a,
-};
-
-static const BitmapCharRec ch248 = {7,7,0,0,7,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x20,0x0,0xf8,0x0,0x20,
-};
-
-static const BitmapCharRec ch247 = {5,5,-1,-1,7,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x50,
-};
-
-static const BitmapCharRec ch246 = {5,9,-1,0,7,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch245 = {5,10,-1,0,7,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch244 = {5,10,-1,0,7,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch243 = {5,10,-1,0,7,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch242 = {5,10,-1,0,7,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0x88,0x88,0x88,0x88,0x88,0xc8,0xb0,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch241 = {5,10,-1,0,7,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x70,0x88,0x88,0x88,0x88,0x78,0x8,0x50,0x30,0x68,
-};
-
-static const BitmapCharRec ch240 = {5,10,-1,0,7,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,
-};
-
-static const BitmapCharRec ch239 = {3,9,0,0,3,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch238 = {3,10,0,0,3,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x40,
-};
-
-static const BitmapCharRec ch237 = {2,10,-1,0,3,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch236 = {2,10,0,0,3,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,0x0,0x50,
-};
-
-static const BitmapCharRec ch235 = {5,9,-1,0,7,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch234 = {5,10,-1,0,7,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch233 = {5,10,-1,0,7,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch232 = {5,10,-1,0,7,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x60,0x10,0x20,0x70,0x88,0x80,0x80,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch231 = {5,10,-1,3,7,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x77,0x0,0x88,0x80,0x88,0x0,0x7f,0x80,0x8,0x80,0x88,0x80,0x77,0x0,
-};
-
-static const BitmapCharRec ch230 = {9,7,-1,0,11,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x30,0x48,0x30,
-};
-
-static const BitmapCharRec ch229 = {6,10,-1,0,7,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x50,
-};
-
-static const BitmapCharRec ch228 = {6,9,-1,0,7,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch227 = {6,10,-1,0,7,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch226 = {6,10,-1,0,7,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch225 = {6,10,-1,0,7,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch224 = {6,10,-1,0,7,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xb0,0x88,0x88,0x88,0xb0,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch223 = {5,9,-1,0,7,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0x80,0x80,0xf8,0x84,0x84,0x84,0xf8,0x80,0x80,
-};
-
-static const BitmapCharRec ch222 = {6,9,-1,0,8,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x10,0x10,0x10,0x10,0x28,0x44,0x44,0x82,0x82,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch221 = {7,12,-1,0,9,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x48,
-};
-
-static const BitmapCharRec ch220 = {6,11,-1,0,8,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch219 = {6,12,-1,0,8,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch218 = {6,12,-1,0,8,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch217 = {6,12,-1,0,8,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x0,0x5e,0x0,0x21,0x0,0x50,0x80,0x48,0x80,0x44,0x80,0x44,0x80,0x42,0x80,
-0x21,0x0,0x1e,0x80,0x0,0x40,
-};
-
-static const BitmapCharRec ch216 = {10,11,0,1,10,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x88,0x50,0x20,0x50,0x88,
-};
-
-static const BitmapCharRec ch215 = {5,5,-1,-1,7,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x24,
-};
-
-static const BitmapCharRec ch214 = {8,11,-1,0,10,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch213 = {8,12,-1,0,10,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x14,0x8,
-};
-
-static const BitmapCharRec ch212 = {8,12,-1,0,10,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x8,0x4,
-};
-
-static const BitmapCharRec ch211 = {8,12,-1,0,10,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,0x0,0x8,0x10,
-};
-
-static const BitmapCharRec ch210 = {8,12,-1,0,10,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0x82,0x86,0x8a,0x8a,0x92,0xa2,0xa2,0xc2,0x82,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch209 = {7,12,-1,0,9,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0x7c,0x42,0x41,0x41,0xf1,0x41,0x41,0x42,0x7c,
-};
-
-static const BitmapCharRec ch208 = {8,9,0,0,9,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,
-};
-
-static const BitmapCharRec ch207 = {3,11,0,0,3,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch206 = {3,12,0,0,3,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,0x40,
-};
-
-static const BitmapCharRec ch205 = {2,12,-1,0,3,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch204 = {2,12,0,0,3,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,0x0,0x28,
-};
-
-static const BitmapCharRec ch203 = {6,11,-1,0,8,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch202 = {6,12,-1,0,8,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch201 = {6,12,-1,0,8,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch200 = {6,12,-1,0,8,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x30,0x8,0x8,0x3c,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x3c,
-};
-
-static const BitmapCharRec ch199 = {7,12,-1,3,9,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0x8f,0x80,0x88,0x0,0x88,0x0,0x78,0x0,0x4f,0x80,0x48,0x0,0x28,0x0,0x28,0x0,
-0x1f,0x80,
-};
-
-static const BitmapCharRec ch198 = {9,9,-1,0,11,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x10,0x28,0x10,
-};
-
-static const BitmapCharRec ch197 = {7,12,-1,0,9,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x28,
-};
-
-static const BitmapCharRec ch196 = {7,11,-1,0,9,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch195 = {7,12,-1,0,9,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch194 = {7,12,-1,0,9,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch193 = {7,12,-1,0,9,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x10,0x10,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch192 = {7,12,-1,0,9,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x70,0x88,0x88,0x40,0x40,0x20,0x20,0x0,0x20,
-};
-
-static const BitmapCharRec ch191 = {5,9,-1,3,7,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x21,0x0,0x17,0x80,0x15,0x0,0xb,0x0,0xc9,0x0,0x24,0x0,0x44,0x0,0x22,0x0,
-0xe1,0x0,
-};
-
-static const BitmapCharRec ch190 = {9,9,0,0,10,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x47,0x80,0x22,0x0,0x11,0x0,0x14,0x80,0x4b,0x0,0x48,0x0,0x44,0x0,0xc2,0x0,
-0x41,0x0,
-};
-
-static const BitmapCharRec ch189 = {9,9,0,0,10,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x41,0x0,0x27,0x80,0x15,0x0,0x13,0x0,0x49,0x0,0x44,0x0,0x44,0x0,0xc2,0x0,
-0x41,0x0,
-};
-
-static const BitmapCharRec ch188 = {9,9,0,0,10,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0xa0,0x50,0x28,0x50,0xa0,
-};
-
-static const BitmapCharRec ch187 = {5,5,-1,-1,7,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xe0,0x0,0xe0,0xa0,0xe0,
-};
-
-static const BitmapCharRec ch186 = {3,5,-1,-4,5,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {2,5,-1,-3,4,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xc0,0x20,0x20,0x40,
-};
-
-static const BitmapCharRec ch184 = {3,4,0,3,3,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch183 = {1,1,-1,-3,3,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x28,0x28,0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,0x68,0x3c,
-};
-
-static const BitmapCharRec ch182 = {6,12,0,3,7,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0x80,0x80,0xe8,0x98,0x88,0x88,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch181 = {5,10,-1,3,7,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x40,
-};
-
-static const BitmapCharRec ch180 = {2,2,0,-8,2,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0xc0,0x20,0x40,0x20,0xe0,
-};
-
-static const BitmapCharRec ch179 = {3,5,0,-3,4,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xf0,0x40,0x20,0x90,0x60,
-};
-
-static const BitmapCharRec ch178 = {4,5,0,-3,4,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xf8,0x0,0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch177 = {5,7,-1,0,7,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,0,-4,5,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xf0,
-};
-
-static const BitmapCharRec ch175 = {4,1,0,-8,4,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x3e,0x0,0x41,0x0,0x94,0x80,0x94,0x80,0x98,0x80,0x94,0x80,0x9c,0x80,0x41,0x0,
-0x3e,0x0,
-};
-
-static const BitmapCharRec ch174 = {9,9,-1,0,11,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xf0,
-};
-
-static const BitmapCharRec ch173 = {4,1,0,-3,5,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x4,0x4,0x4,0xfc,
-};
-
-static const BitmapCharRec ch172 = {6,4,-1,-2,8,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x28,0x50,0xa0,0x50,0x28,
-};
-
-static const BitmapCharRec ch171 = {5,5,-1,-1,7,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xe0,0x0,0xa0,0x20,0xe0,
-};
-
-static const BitmapCharRec ch170 = {3,5,-1,-4,5,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x3e,0x0,0x41,0x0,0x9c,0x80,0xa2,0x80,0xa0,0x80,0xa2,0x80,0x9c,0x80,0x41,0x0,
-0x3e,0x0,
-};
-
-static const BitmapCharRec ch169 = {9,9,-1,0,11,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xa0,
-};
-
-static const BitmapCharRec ch168 = {3,1,0,-8,3,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x70,0x88,0x8,0x30,0x48,0x88,0x88,0x90,0x60,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch167 = {5,12,0,3,6,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,11,-1,2,3,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x20,0x20,0xf8,0x20,0xf8,0x20,0x50,0x88,0x88,
-};
-
-static const BitmapCharRec ch165 = {5,9,-1,0,7,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x84,0x78,0x48,0x48,0x78,0x84,
-};
-
-static const BitmapCharRec ch164 = {6,6,0,-1,7,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xb0,0x48,0x20,0x20,0xf0,0x40,0x40,0x48,0x30,
-};
-
-static const BitmapCharRec ch163 = {5,9,-1,0,7,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x40,0x70,0xc8,0xa0,0xa0,0xa0,0xa8,0x70,0x10,
-};
-
-static const BitmapCharRec ch162 = {5,9,-1,1,7,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,10,-1,3,3,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,4,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,4,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x98,0x64,
-};
-
-static const BitmapCharRec ch126 = {6,2,0,-3,7,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xc0,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0xc0,
-};
-
-static const BitmapCharRec ch125 = {4,12,0,3,4,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,12,-1,3,3,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x30,0x40,0x40,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x40,0x30,
-};
-
-static const BitmapCharRec ch123 = {4,12,0,3,4,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xf0,0x80,0x40,0x40,0x20,0x10,0xf0,
-};
-
-static const BitmapCharRec ch122 = {4,7,-1,0,6,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x80,0x40,0x20,0x20,0x50,0x50,0x90,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch121 = {5,10,-1,3,7,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0x84,0x84,0x48,0x30,0x30,0x48,0x84,
-};
-
-static const BitmapCharRec ch120 = {6,7,0,0,6,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x22,0x0,0x22,0x0,0x55,0x0,0x49,0x0,0x49,0x0,0x88,0x80,0x88,0x80,
-};
-
-static const BitmapCharRec ch119 = {9,7,0,0,9,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x20,0x20,0x50,0x50,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch118 = {5,7,-1,0,7,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x68,0x98,0x88,0x88,0x88,0x88,0x88,
-};
-
-static const BitmapCharRec ch117 = {5,7,-1,0,7,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x60,0x40,0x40,0x40,0x40,0x40,0xe0,0x40,0x40,
-};
-
-static const BitmapCharRec ch116 = {3,9,0,0,3,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x60,0x90,0x10,0x60,0x80,0x90,0x60,
-};
-
-static const BitmapCharRec ch115 = {4,7,-1,0,6,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0x80,0x80,0x80,0x80,0x80,0xc0,0xa0,
-};
-
-static const BitmapCharRec ch114 = {3,7,-1,0,4,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x8,0x8,0x8,0x68,0x98,0x88,0x88,0x88,0x98,0x68,
-};
-
-static const BitmapCharRec ch113 = {5,10,-1,3,7,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0x80,0x80,0x80,0xb0,0xc8,0x88,0x88,0x88,0xc8,0xb0,
-};
-
-static const BitmapCharRec ch112 = {5,10,-1,3,7,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch111 = {5,7,-1,0,7,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0x88,0x88,0x88,0x88,0x88,0xc8,0xb0,
-};
-
-static const BitmapCharRec ch110 = {5,7,-1,0,7,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0x92,0x92,0x92,0x92,0x92,0xda,0xa4,
-};
-
-static const BitmapCharRec ch109 = {7,7,-1,0,9,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch108 = {1,9,-1,0,3,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x88,0x90,0xa0,0xc0,0xc0,0xa0,0x90,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {5,9,-1,0,6,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x0,0x40,
-};
-
-static const BitmapCharRec ch106 = {2,12,0,3,3,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch105 = {1,9,-1,0,3,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0x88,0x88,0x88,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {5,9,-1,0,7,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x70,0x88,0x8,0x68,0x98,0x88,0x88,0x88,0x98,0x68,
-};
-
-static const BitmapCharRec ch103 = {5,10,-1,3,7,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x40,0x40,0x40,0x40,0x40,0x40,0xe0,0x40,0x30,
-};
-
-static const BitmapCharRec ch102 = {4,9,0,0,3,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x70,0x88,0x80,0xf8,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch101 = {5,7,-1,0,7,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x68,0x98,0x88,0x88,0x88,0x98,0x68,0x8,0x8,
-};
-
-static const BitmapCharRec ch100 = {5,9,-1,0,7,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x70,0x88,0x80,0x80,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch99 = {5,7,-1,0,7,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xb0,0xc8,0x88,0x88,0x88,0xc8,0xb0,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {5,9,-1,0,7,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x74,0x88,0x88,0x78,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch97 = {6,7,-1,0,7,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0xc0,0x80,0x40,
-};
-
-static const BitmapCharRec ch96 = {2,3,0,-6,3,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xfe,
-};
-
-static const BitmapCharRec ch95 = {7,1,0,2,7,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x88,0x50,0x20,
-};
-
-static const BitmapCharRec ch94 = {5,3,0,-5,6,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,
-};
-
-static const BitmapCharRec ch93 = {2,12,0,3,3,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x10,0x10,0x20,0x20,0x20,0x40,0x40,0x80,0x80,
-};
-
-static const BitmapCharRec ch92 = {4,9,0,0,4,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
-};
-
-static const BitmapCharRec ch91 = {2,12,-1,3,3,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xfe,0x80,0x40,0x20,0x10,0x8,0x4,0x2,0xfe,
-};
-
-static const BitmapCharRec ch90 = {7,9,-1,0,9,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x10,0x10,0x10,0x10,0x28,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch89 = {7,9,-1,0,9,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0x82,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x82,
-};
-
-static const BitmapCharRec ch88 = {7,9,-1,0,9,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x22,0x0,0x22,0x0,0x22,0x0,0x55,0x0,0x55,0x0,0x49,0x0,0x88,0x80,0x88,0x80,
-0x88,0x80,
-};
-
-static const BitmapCharRec ch87 = {9,9,-1,0,11,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x10,0x28,0x28,0x44,0x44,0x44,0x82,0x82,
-};
-
-static const BitmapCharRec ch86 = {7,9,-1,0,9,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x78,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
-};
-
-static const BitmapCharRec ch85 = {6,9,-1,0,8,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xfe,
-};
-
-static const BitmapCharRec ch84 = {7,9,0,0,7,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x78,0x84,0x84,0x4,0x18,0x60,0x80,0x84,0x78,
-};
-
-static const BitmapCharRec ch83 = {6,9,-1,0,8,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0x84,0x84,0x84,0x88,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch82 = {6,9,-1,0,8,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x3d,0x42,0x85,0x89,0x81,0x81,0x81,0x42,0x3c,
-};
-
-static const BitmapCharRec ch81 = {8,9,-1,0,10,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0x80,0x80,0x80,0x80,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch80 = {6,9,-1,0,8,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x3c,0x42,0x81,0x81,0x81,0x81,0x81,0x42,0x3c,
-};
-
-static const BitmapCharRec ch79 = {8,9,-1,0,10,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0x82,0x86,0x8a,0x8a,0x92,0xa2,0xa2,0xc2,0x82,
-};
-
-static const BitmapCharRec ch78 = {7,9,-1,0,9,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0x88,0x80,0x88,0x80,0x94,0x80,0x94,0x80,0xa2,0x80,0xa2,0x80,0xc1,0x80,0xc1,0x80,
-0x80,0x80,
-};
-
-static const BitmapCharRec ch77 = {9,9,-1,0,11,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xf8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch76 = {5,9,-1,0,7,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0x82,0x84,0x88,0x90,0xe0,0xa0,0x90,0x88,0x84,
-};
-
-static const BitmapCharRec ch75 = {7,9,-1,0,8,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x70,0x88,0x88,0x8,0x8,0x8,0x8,0x8,0x8,
-};
-
-static const BitmapCharRec ch74 = {5,9,-1,0,7,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch73 = {1,9,-1,0,3,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0x82,0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x82,
-};
-
-static const BitmapCharRec ch72 = {7,9,-1,0,9,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x3a,0x46,0x82,0x82,0x8e,0x80,0x80,0x42,0x3c,
-};
-
-static const BitmapCharRec ch71 = {7,9,-1,0,9,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0x80,0x80,0x80,0x80,0xf8,0x80,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch70 = {6,9,-1,0,8,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xfc,0x80,0x80,0x80,0xfc,0x80,0x80,0x80,0xfc,
-};
-
-static const BitmapCharRec ch69 = {6,9,-1,0,8,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xf8,0x84,0x82,0x82,0x82,0x82,0x82,0x84,0xf8,
-};
-
-static const BitmapCharRec ch68 = {7,9,-1,0,9,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x3c,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x3c,
-};
-
-static const BitmapCharRec ch67 = {7,9,-1,0,9,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xf8,0x84,0x84,0x84,0xf8,0x84,0x84,0x84,0xf8,
-};
-
-static const BitmapCharRec ch66 = {6,9,-1,0,8,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0x82,0x82,0x82,0x7c,0x44,0x44,0x28,0x28,0x10,
-};
-
-static const BitmapCharRec ch65 = {7,9,-1,0,9,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x3e,0x0,0x40,0x0,0x9b,0x0,0xa6,0x80,0xa2,0x40,0xa2,0x40,0x92,0x40,0x4d,0x40,
-0x60,0x80,0x1f,0x0,
-};
-
-static const BitmapCharRec ch64 = {10,10,-1,1,12,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x20,0x0,0x20,0x20,0x10,0x10,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch63 = {5,9,-1,0,7,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0xc0,0x30,0xc,0x30,0xc0,
-};
-
-static const BitmapCharRec ch62 = {6,5,-1,-1,7,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xf8,0x0,0xf8,
-};
-
-static const BitmapCharRec ch61 = {5,3,-1,-2,7,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0xc,0x30,0xc0,0x30,0xc,
-};
-
-static const BitmapCharRec ch60 = {6,5,0,-1,7,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x40,0x40,0x0,0x0,0x0,0x0,0x40,
-};
-
-static const BitmapCharRec ch59 = {2,8,0,2,3,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0x80,0x0,0x0,0x0,0x0,0x80,
-};
-
-static const BitmapCharRec ch58 = {1,6,-1,0,3,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x70,0x88,0x8,0x8,0x78,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch57 = {5,9,-1,0,7,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x70,0x88,0x88,0x88,0x88,0x70,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch56 = {5,9,-1,0,7,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x20,0x20,0x20,0x10,0x10,0x8,0xf8,
-};
-
-static const BitmapCharRec ch55 = {5,9,-1,0,7,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x70,0x88,0x88,0x88,0xc8,0xb0,0x80,0x88,0x70,
-};
-
-static const BitmapCharRec ch54 = {5,9,-1,0,7,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x70,0x88,0x88,0x8,0x8,0xf0,0x80,0x80,0xf8,
-};
-
-static const BitmapCharRec ch53 = {5,9,-1,0,7,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x8,0x8,0xfc,0x88,0x48,0x28,0x28,0x18,0x8,
-};
-
-static const BitmapCharRec ch52 = {6,9,0,0,7,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x70,0x88,0x88,0x8,0x8,0x30,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch51 = {5,9,-1,0,7,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xf8,0x80,0x80,0x40,0x20,0x10,0x8,0x88,0x70,
-};
-
-static const BitmapCharRec ch50 = {5,9,-1,0,7,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xe0,0x20,
-};
-
-static const BitmapCharRec ch49 = {3,9,-1,0,7,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x70,
-};
-
-static const BitmapCharRec ch48 = {5,9,-1,0,7,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x80,0x40,0x40,0x40,0x20,0x20,0x10,0x10,
-};
-
-static const BitmapCharRec ch47 = {4,9,0,0,4,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch46 = {1,1,-1,0,3,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xf8,
-};
-
-static const BitmapCharRec ch45 = {5,1,-1,-3,8,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x40,0x40,
-};
-
-static const BitmapCharRec ch44 = {2,3,-1,2,4,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch43 = {5,5,-1,-1,7,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0xa0,0x40,0xa0,
-};
-
-static const BitmapCharRec ch42 = {3,3,-1,-6,5,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,12,0,3,4,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,12,-1,3,4,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x40,0xc0,
-};
-
-static const BitmapCharRec ch39 = {2,3,-1,-6,3,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x72,0x8c,0x84,0x8a,0x50,0x30,0x48,0x48,0x30,
-};
-
-static const BitmapCharRec ch38 = {7,9,-1,0,9,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x23,0x0,0x14,0x80,0x14,0x80,0x13,0x0,0x8,0x0,0x68,0x0,0x94,0x0,0x94,0x0,
-0x62,0x0,
-};
-
-static const BitmapCharRec ch37 = {9,9,-1,0,11,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x20,0x70,0xa8,0xa8,0x28,0x70,0xa0,0xa8,0x70,0x20,
-};
-
-static const BitmapCharRec ch36 = {5,10,-1,1,7,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x50,0x50,0x50,0xfc,0x28,0xfc,0x28,0x28,
-};
-
-static const BitmapCharRec ch35 = {6,8,0,0,7,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0xa0,0xa0,0xa0,
-};
-
-static const BitmapCharRec ch34 = {3,3,-1,-6,5,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,9,-1,0,3,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,4,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,4,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-GLUTAPI const BitmapFontRec glutBitmapHelvetica12;
-const BitmapFontRec glutBitmapHelvetica12 = {
-"-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/glx/glut_hel18.c b/src/glut/glx/glut_hel18.c
deleted file mode 100644 (file)
index 3ddcefd..0000000
+++ /dev/null
@@ -1,1898 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapHelvetica18 XXX
-#include "glutbitmap.h"
-#undef glutBitmapHelvetica18
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,0x0,0x66,
-0x66,
-};
-
-static const BitmapCharRec ch255 = {8,17,-1,4,10,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,0xff,0x0,0xde,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0xc0,0x0,
-};
-
-static const BitmapCharRec ch254 = {9,18,-1,4,11,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,0x0,0x18,
-0xc,0x6,
-};
-
-static const BitmapCharRec ch253 = {8,18,-1,4,10,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x66,0x66,
-};
-
-static const BitmapCharRec ch252 = {8,13,-1,0,10,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x66,0x3c,0x18,
-};
-
-static const BitmapCharRec ch251 = {8,14,-1,0,10,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0x18,0xc,0x6,
-};
-
-static const BitmapCharRec ch250 = {8,14,-1,0,10,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x0,0xc,0x18,0x30,
-};
-
-static const BitmapCharRec ch249 = {8,14,-1,0,10,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0xce,0x0,0x7f,0x80,0x31,0x80,0x78,0xc0,0x6c,0xc0,0x66,0xc0,0x63,0xc0,0x31,0x80,
-0x3f,0xc0,0xe,0x60,
-};
-
-static const BitmapCharRec ch248 = {11,10,0,0,11,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x18,0x18,0x0,0xff,0xff,0x0,0x18,0x18,
-};
-
-static const BitmapCharRec ch247 = {8,8,-1,-1,10,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0x36,0x0,0x36,0x0,
-};
-
-static const BitmapCharRec ch246 = {9,13,-1,0,11,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0x26,0x0,0x2d,0x0,0x19,0x0,
-};
-
-static const BitmapCharRec ch245 = {9,14,-1,0,11,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0x33,0x0,0x1e,0x0,0xc,0x0,
-};
-
-static const BitmapCharRec ch244 = {9,14,-1,0,11,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0x18,0x0,0xc,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch243 = {9,14,-1,0,11,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x0,0x0,0xc,0x0,0x18,0x0,0x30,0x0,
-};
-
-static const BitmapCharRec ch242 = {9,14,-1,0,11,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,0x0,0x4c,0x5a,0x32,
-};
-
-static const BitmapCharRec ch241 = {8,14,-1,0,10,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,0x4c,0x0,0x38,0x0,0x36,0x0,0x60,0x0,
-};
-
-static const BitmapCharRec ch240 = {9,14,-1,0,11,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0xd8,0xd8,
-};
-
-static const BitmapCharRec ch239 = {5,13,0,0,4,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,0x78,0x30,
-};
-
-static const BitmapCharRec ch238 = {6,14,1,0,4,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0xc0,0x60,0x30,
-};
-
-static const BitmapCharRec ch237 = {4,14,0,0,4,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x0,0x30,0x60,0xc0,
-};
-
-static const BitmapCharRec ch236 = {4,14,0,0,4,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x36,0x36,
-};
-
-static const BitmapCharRec ch235 = {8,13,-1,0,10,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x66,0x3c,0x18,
-};
-
-static const BitmapCharRec ch234 = {8,14,-1,0,10,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x18,0xc,0x6,
-};
-
-static const BitmapCharRec ch233 = {8,14,-1,0,10,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,0x0,0x18,0x30,0x60,
-};
-
-static const BitmapCharRec ch232 = {8,14,-1,0,10,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x78,0x6c,0xc,0x38,0x3e,0x7f,0x63,0xc0,0xc0,0xc0,0xc0,0x63,0x7f,0x3e,
-};
-
-static const BitmapCharRec ch231 = {8,14,-1,4,10,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x75,0xe0,0xef,0xf8,0xc7,0x18,0xc6,0x0,0xe6,0x0,0x7f,0xf8,0xe,0x18,0xc6,0x18,
-0xef,0xf0,0x7d,0xe0,
-};
-
-static const BitmapCharRec ch230 = {13,10,-1,0,15,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x38,0x6c,0x6c,0x38,
-};
-
-static const BitmapCharRec ch229 = {7,14,-1,0,9,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x6c,0x6c,
-};
-
-static const BitmapCharRec ch228 = {7,13,-1,0,9,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x4c,0x5a,0x32,
-};
-
-static const BitmapCharRec ch227 = {7,14,-1,0,9,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x66,0x3c,0x18,
-};
-
-static const BitmapCharRec ch226 = {7,14,-1,0,9,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x30,0x18,0xc,
-};
-
-static const BitmapCharRec ch225 = {7,14,-1,0,9,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,0x0,0x18,0x30,0x60,
-};
-
-static const BitmapCharRec ch224 = {7,14,-1,0,9,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xdc,0xde,0xc6,0xc6,0xc6,0xc6,0xdc,0xdc,0xc6,0xc6,0xc6,0xc6,0x7c,0x38,
-};
-
-static const BitmapCharRec ch223 = {7,14,-1,0,9,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x80,0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc1,0xc0,0xff,0x80,0xff,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-};
-
-static const BitmapCharRec ch222 = {10,14,-1,0,12,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
-0x30,0xc0,0x30,0xc0,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,0x0,0x0,0x6,0x0,
-0x3,0x0,0x1,0x80,
-};
-
-static const BitmapCharRec ch221 = {12,18,-1,0,14,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x19,0x80,
-0x19,0x80,
-};
-
-static const BitmapCharRec ch220 = {11,17,-1,0,13,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x19,0x80,
-0xf,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch219 = {11,18,-1,0,13,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0xc,0x0,
-0x6,0x0,0x3,0x0,
-};
-
-static const BitmapCharRec ch218 = {11,18,-1,0,13,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0x0,0x0,0x6,0x0,
-0xc,0x0,0x18,0x0,
-};
-
-static const BitmapCharRec ch217 = {11,18,-1,0,13,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0xc7,0xc0,0xff,0xf0,0x78,0x38,0x38,0x18,0x6c,0x1c,0x6e,0xc,0x67,0xc,0x63,0x8c,
-0x61,0xcc,0x70,0xdc,0x30,0x78,0x38,0x38,0x1f,0xfc,0x7,0xcc,
-};
-
-static const BitmapCharRec ch216 = {14,14,0,0,15,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0xc0,0xc0,0x61,0x80,0x33,0x0,0x1e,0x0,0xc,0x0,0x1e,0x0,0x33,0x0,0x61,0x80,
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch215 = {10,9,0,0,10,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0xd,0x80,
-0xd,0x80,
-};
-
-static const BitmapCharRec ch214 = {13,17,-1,0,15,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x9,0x80,
-0xb,0x40,0x6,0x40,
-};
-
-static const BitmapCharRec ch213 = {13,18,-1,0,15,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0xc,0xc0,
-0x7,0x80,0x3,0x0,
-};
-
-static const BitmapCharRec ch212 = {13,18,-1,0,15,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x3,0x0,
-0x1,0x80,0x0,0xc0,
-};
-
-static const BitmapCharRec ch211 = {13,18,-1,0,15,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,0x0,0x0,0x3,0x0,
-0x6,0x0,0xc,0x0,
-};
-
-static const BitmapCharRec ch210 = {13,18,-1,0,15,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0xc0,0x60,0xc0,0xe0,0xc1,0xe0,0xc1,0xe0,0xc3,0x60,0xc6,0x60,0xc6,0x60,0xcc,0x60,
-0xcc,0x60,0xd8,0x60,0xd8,0x60,0xf0,0x60,0xe0,0x60,0xe0,0x60,0x0,0x0,0x13,0x0,
-0x16,0x80,0xc,0x80,
-};
-
-static const BitmapCharRec ch209 = {11,18,-1,0,13,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0x7f,0x80,0x7f,0xc0,0x60,0xe0,0x60,0x60,0x60,0x30,0x60,0x30,0xfc,0x30,0xfc,0x30,
-0x60,0x30,0x60,0x30,0x60,0x60,0x60,0xe0,0x7f,0xc0,0x7f,0x80,
-};
-
-static const BitmapCharRec ch208 = {12,14,0,0,13,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,
-0xcc,
-};
-
-static const BitmapCharRec ch207 = {6,17,0,0,6,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0xcc,
-0x78,0x30,
-};
-
-static const BitmapCharRec ch206 = {6,18,0,0,6,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0xc0,
-0x60,0x30,
-};
-
-static const BitmapCharRec ch205 = {4,18,-2,0,6,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0x30,
-0x60,0xc0,
-};
-
-static const BitmapCharRec ch204 = {4,18,0,0,6,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0x33,0x0,
-0x33,0x0,
-};
-
-static const BitmapCharRec ch203 = {9,17,-1,0,11,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0x33,0x0,
-0x1e,0x0,0xc,0x0,
-};
-
-static const BitmapCharRec ch202 = {9,18,-1,0,11,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0xc,0x0,
-0x6,0x0,0x3,0x0,
-};
-
-static const BitmapCharRec ch201 = {9,18,-1,0,11,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,0x0,0x0,0xc,0x0,
-0x18,0x0,0x30,0x0,
-};
-
-static const BitmapCharRec ch200 = {9,18,-1,0,11,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x1e,0x0,0x1b,0x0,0x3,0x0,0xe,0x0,0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,
-0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xe0,0x0,0x60,0x30,0x70,0x70,
-0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch199 = {12,18,-1,4,14,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0xc1,0xff,0xc1,0xff,0x61,0x80,0x61,0x80,0x7f,0x80,0x3f,0x80,0x31,0xfe,0x31,0xfe,
-0x19,0x80,0x19,0x80,0xd,0x80,0xd,0x80,0x7,0xff,0x7,0xff,
-};
-
-static const BitmapCharRec ch198 = {16,14,-1,0,18,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
-0x19,0x80,0xf,0x0,
-};
-
-static const BitmapCharRec ch197 = {12,18,0,0,12,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x19,0x80,
-0x19,0x80,
-};
-
-static const BitmapCharRec ch196 = {12,17,0,0,12,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x13,0x0,
-0x16,0x80,0xc,0x80,
-};
-
-static const BitmapCharRec ch195 = {12,18,0,0,12,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x19,0x80,
-0xf,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch194 = {12,18,0,0,12,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x6,0x0,
-0x3,0x0,0x1,0x80,
-};
-
-static const BitmapCharRec ch193 = {12,18,0,0,12,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x6,0x0,
-0xc,0x0,0x18,0x0,
-};
-
-static const BitmapCharRec ch192 = {12,18,0,0,12,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x7c,0xfe,0xc6,0xc6,0xe0,0x70,0x38,0x18,0x18,0x18,0x0,0x0,0x18,0x18,
-};
-
-static const BitmapCharRec ch191 = {7,14,-1,4,10,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x18,0x18,0x18,0x18,0xc,0xfc,0x6,0xd8,0x6,0x78,0x73,0x38,0xf9,0x18,0x99,0x88,
-0x30,0xc0,0x30,0xc0,0x98,0x60,0xf8,0x30,0x70,0x30,
-};
-
-static const BitmapCharRec ch190 = {14,13,0,0,15,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x30,0xf8,0x30,0xf8,0x18,0x60,0xc,0x30,0xc,0x18,0x66,0x98,0x62,0xf8,0x63,0x70,
-0x61,0x80,0x61,0x80,0xe0,0xc0,0xe0,0x60,0x60,0x60,
-};
-
-static const BitmapCharRec ch189 = {13,13,-1,0,15,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x30,0x30,0x30,0x30,0x19,0xf8,0xd,0xb0,0xc,0xf0,0x66,0x70,0x62,0x30,0x63,0x10,
-0x61,0x80,0x61,0x80,0xe0,0xc0,0xe0,0x60,0x60,0x60,
-};
-
-static const BitmapCharRec ch188 = {13,13,-1,0,15,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0x90,0xd8,0x6c,0x36,0x36,0x6c,0xd8,0x90,
-};
-
-static const BitmapCharRec ch187 = {7,8,-1,-1,9,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xf8,0x0,0x70,0xd8,0x88,0x88,0xd8,0x70,
-};
-
-static const BitmapCharRec ch186 = {5,8,-1,-6,7,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,
-};
-
-static const BitmapCharRec ch185 = {3,8,-1,-5,6,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xf0,0xd8,0x18,0x70,0x60,
-};
-
-static const BitmapCharRec ch184 = {5,5,0,4,5,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,2,-1,-4,4,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x32,0x72,0xf2,0xf2,0xf2,0xf2,
-0x72,0x3f,
-};
-
-static const BitmapCharRec ch182 = {8,18,-1,4,10,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0xc0,0xc0,0xc0,0xc0,0xdb,0xff,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch181 = {8,14,-1,4,10,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0xc0,0x60,0x30,
-};
-
-static const BitmapCharRec ch180 = {4,3,0,-11,4,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0x70,0xf8,0x98,0x30,0x30,0x98,0xf8,0x70,
-};
-
-static const BitmapCharRec ch179 = {5,8,0,-5,6,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xf8,0xf8,0x60,0x30,0x18,0x98,0xf8,0x70,
-};
-
-static const BitmapCharRec ch178 = {5,8,0,-5,6,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xff,0xff,0x0,0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,
-};
-
-static const BitmapCharRec ch177 = {8,11,-1,0,10,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x70,0xd8,0x88,0xd8,0x70,
-};
-
-static const BitmapCharRec ch176 = {5,5,-1,-8,7,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xf8,
-};
-
-static const BitmapCharRec ch175 = {5,1,0,-12,5,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0xf,0x80,0x30,0x60,0x40,0x10,0x48,0x50,0x88,0x88,0x89,0x8,0x8f,0x88,0x88,0x48,
-0x88,0x48,0x4f,0x90,0x40,0x10,0x30,0x60,0xf,0x80,
-};
-
-static const BitmapCharRec ch174 = {13,13,-1,0,14,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xf8,0xf8,
-};
-
-static const BitmapCharRec ch173 = {5,2,-1,-4,7,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x1,0x80,0x1,0x80,0x1,0x80,0xff,0x80,0xff,0x80,
-};
-
-static const BitmapCharRec ch172 = {9,5,-1,-3,11,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x12,0x36,0x6c,0xd8,0xd8,0x6c,0x36,0x12,
-};
-
-static const BitmapCharRec ch171 = {7,8,-1,-1,9,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xf8,0x0,0x68,0xd8,0x48,0x38,0xc8,0x70,
-};
-
-static const BitmapCharRec ch170 = {5,8,-1,-6,7,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0xf,0x80,0x30,0x60,0x40,0x10,0x47,0x10,0x88,0x88,0x90,0x8,0x90,0x8,0x90,0x8,
-0x88,0x88,0x47,0x10,0x40,0x10,0x30,0x60,0xf,0x80,
-};
-
-static const BitmapCharRec ch169 = {13,13,-1,0,15,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xd8,0xd8,
-};
-
-static const BitmapCharRec ch168 = {5,2,0,-11,6,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x3c,0x7e,0xc3,0xc3,0x7,0xe,0x3e,0x73,0xe3,0xc3,0xc7,0x6e,0x7c,0xf0,0xc3,0xc3,
-0x7e,0x3c,
-};
-
-static const BitmapCharRec ch167 = {8,18,-1,4,10,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0x0,0x0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch166 = {2,17,-1,3,4,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x18,0x18,0x18,0x18,0xff,0x18,0xff,0x3c,0x66,0x66,0x66,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch165 = {8,13,-1,0,10,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0xc3,0xff,0x66,0x66,0x66,0xff,0xc3,
-};
-
-static const BitmapCharRec ch164 = {8,7,-1,-3,10,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xdf,0x0,0xff,0x80,0x60,0x80,0x30,0x0,0x18,0x0,0x18,0x0,0x7e,0x0,0x30,0x0,
-0x60,0x0,0x61,0x80,0x61,0x80,0x3f,0x0,0x1e,0x0,
-};
-
-static const BitmapCharRec ch163 = {9,13,0,0,10,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x10,0x10,0x3e,0x7f,0x6b,0xc8,0xc8,0xc8,0xc8,0x6b,0x7f,0x3e,0x4,0x4,
-};
-
-static const BitmapCharRec ch162 = {8,14,-1,2,10,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x40,0x40,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch161 = {2,14,-2,4,6,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,5,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,5,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0xcc,0x7e,0x33,
-};
-
-static const BitmapCharRec ch126 = {8,3,-1,-4,10,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xc0,0x60,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0xc,0x18,0x30,0x30,0x30,0x30,0x30,
-0x60,0xc0,
-};
-
-static const BitmapCharRec ch125 = {6,18,0,4,6,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch124 = {2,18,-1,4,4,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0xc,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0xc0,0x60,0x30,0x30,0x30,0x30,0x30,
-0x18,0xc,
-};
-
-static const BitmapCharRec ch123 = {6,18,0,4,6,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xfe,0xfe,0xc0,0x60,0x30,0x18,0xc,0x6,0xfe,0xfe,
-};
-
-static const BitmapCharRec ch122 = {7,10,-1,0,9,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x70,0x70,0x18,0x18,0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch121 = {8,14,-1,4,10,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0xc3,0xe7,0x66,0x3c,0x18,0x18,0x3c,0x66,0xe7,0xc3,
-};
-
-static const BitmapCharRec ch120 = {8,10,-1,0,10,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x19,0x80,0x19,0x80,0x39,0xc0,0x29,0x40,0x69,0x60,0x66,0x60,0x66,0x60,0xc6,0x30,
-0xc6,0x30,0xc6,0x30,
-};
-
-static const BitmapCharRec ch119 = {12,10,-1,0,14,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x18,0x18,0x3c,0x24,0x66,0x66,0x66,0xc3,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch118 = {8,10,-1,0,10,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x73,0xfb,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,
-};
-
-static const BitmapCharRec ch117 = {8,10,-1,0,10,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x18,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0xfc,0xfc,0x30,0x30,0x30,
-};
-
-static const BitmapCharRec ch116 = {6,13,0,0,6,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0x78,0xfc,0xc6,0x6,0x3e,0xfc,0xc0,0xc6,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch115 = {7,10,-1,0,9,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xe0,0xd8,0xd8,
-};
-
-static const BitmapCharRec ch114 = {5,10,-1,0,6,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x80,0x7f,0x80,0x3d,0x80,
-};
-
-static const BitmapCharRec ch113 = {9,14,-1,4,11,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,0xff,0x0,0xde,0x0,
-};
-
-static const BitmapCharRec ch112 = {9,14,-1,4,11,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x3e,0x0,0x7f,0x0,0x63,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x0,
-0x7f,0x0,0x3e,0x0,
-};
-
-static const BitmapCharRec ch111 = {9,10,-1,0,11,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,
-};
-
-static const BitmapCharRec ch110 = {8,10,-1,0,10,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xc6,0x30,0xe7,0x30,
-0xde,0xf0,0xcc,0x60,
-};
-
-static const BitmapCharRec ch109 = {12,10,-1,0,14,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch108 = {2,14,-1,0,4,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0xc7,0xc6,0xce,0xcc,0xd8,0xf8,0xf0,0xd8,0xcc,0xc6,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch107 = {8,14,-1,0,9,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0xe0,0xf0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x0,0x0,
-0x30,0x30,
-};
-
-static const BitmapCharRec ch106 = {4,18,1,4,4,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch105 = {2,14,-1,0,4,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe3,0xdf,0xce,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch104 = {8,14,-1,0,10,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x1c,0x0,0x7f,0x0,0x63,0x0,0x1,0x80,0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0x61,0x80,0x7f,0x80,0x3d,0x80,
-};
-
-static const BitmapCharRec ch103 = {9,14,-1,4,11,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xfc,0xfc,0x30,0x30,0x3c,0x1c,
-};
-
-static const BitmapCharRec ch102 = {6,14,0,0,6,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x3c,0x7f,0xe3,0xc0,0xc0,0xff,0xc3,0xc3,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch101 = {8,10,-1,0,10,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x3d,0x80,0x7f,0x80,0x63,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x63,0x80,
-0x7f,0x80,0x3d,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,
-};
-
-static const BitmapCharRec ch100 = {9,14,-1,0,11,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x3e,0x7f,0x63,0xc0,0xc0,0xc0,0xc0,0x63,0x7f,0x3e,
-};
-
-static const BitmapCharRec ch99 = {8,10,-1,0,10,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xde,0x0,0xff,0x0,0xe3,0x0,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xe3,0x0,
-0xff,0x0,0xde,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-};
-
-static const BitmapCharRec ch98 = {9,14,-1,0,11,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x76,0xee,0xc6,0xc6,0xe6,0x7e,0xe,0xc6,0xee,0x7c,
-};
-
-static const BitmapCharRec ch97 = {7,10,-1,0,9,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0xc0,0xc0,0x80,0x80,0x40,
-};
-
-static const BitmapCharRec ch96 = {2,5,-1,-9,4,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xff,0xc0,0xff,0xc0,
-};
-
-static const BitmapCharRec ch95 = {10,2,0,4,10,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x82,0xc6,0x6c,0x38,0x10,
-};
-
-static const BitmapCharRec ch94 = {7,5,-1,-8,9,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xf0,0xf0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xf0,0xf0,
-};
-
-static const BitmapCharRec ch93 = {4,18,0,4,5,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x18,0x18,0x10,0x10,0x30,0x30,0x20,0x20,0x60,0x60,0x40,0x40,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch92 = {5,14,0,0,5,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xf0,0xf0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xf0,0xf0,
-};
-
-static const BitmapCharRec ch91 = {4,18,-1,4,5,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xff,0xc0,0xff,0xc0,0xc0,0x0,0x60,0x0,0x30,0x0,0x18,0x0,0x1c,0x0,0xc,0x0,
-0x6,0x0,0x3,0x0,0x1,0x80,0x0,0xc0,0xff,0xc0,0xff,0xc0,
-};
-
-static const BitmapCharRec ch90 = {10,14,-1,0,12,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0xf,0x0,0x19,0x80,
-0x30,0xc0,0x30,0xc0,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,
-};
-
-static const BitmapCharRec ch89 = {12,14,-1,0,14,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0xc0,0x60,0xe0,0xe0,0x60,0xc0,0x71,0xc0,0x31,0x80,0x1b,0x0,0xe,0x0,0xe,0x0,
-0x1b,0x0,0x31,0x80,0x71,0xc0,0x60,0xc0,0xe0,0xe0,0xc0,0x60,
-};
-
-static const BitmapCharRec ch88 = {11,14,-1,0,13,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x18,0x18,0x18,0x18,0x1c,0x38,0x34,0x2c,0x36,0x6c,0x36,0x6c,0x66,0x66,0x66,0x66,
-0x62,0x46,0x63,0xc6,0xc3,0xc3,0xc1,0x83,0xc1,0x83,0xc1,0x83,
-};
-
-static const BitmapCharRec ch87 = {16,14,-1,0,18,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x6,0x0,0xf,0x0,0xf,0x0,0x19,0x80,0x19,0x80,0x19,0x80,0x30,0xc0,0x30,0xc0,
-0x30,0xc0,0x60,0x60,0x60,0x60,0x60,0x60,0xc0,0x30,0xc0,0x30,
-};
-
-static const BitmapCharRec ch86 = {12,14,-1,0,14,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x1f,0x0,0x7f,0xc0,0x60,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-};
-
-static const BitmapCharRec ch85 = {11,14,-1,0,13,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,
-0xc,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0xff,0xc0,0xff,0xc0,
-};
-
-static const BitmapCharRec ch84 = {10,14,-1,0,12,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x3f,0x0,0x7f,0xc0,0xe0,0xe0,0xc0,0x60,0x0,0x60,0x0,0xe0,0x3,0xc0,0x1f,0x0,
-0x7c,0x0,0xe0,0x0,0xc0,0x60,0xe0,0xe0,0x7f,0xc0,0x1f,0x0,
-};
-
-static const BitmapCharRec ch83 = {11,14,-1,0,13,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0x80,0xc1,0x80,0xff,0x0,0xff,0x80,
-0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
-};
-
-static const BitmapCharRec ch82 = {10,14,-1,0,12,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x0,0x30,0xf,0xb0,0x3f,0xe0,0x70,0xf0,0x61,0xb0,0xe1,0xb8,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch81 = {13,15,-1,1,15,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x80,
-0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
-};
-
-static const BitmapCharRec ch80 = {10,14,-1,0,12,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x38,0xc0,0x18,0xc0,0x18,0xc0,0x18,
-0xc0,0x18,0xe0,0x38,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch79 = {13,14,-1,0,15,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0xc0,0x60,0xc0,0xe0,0xc1,0xe0,0xc1,0xe0,0xc3,0x60,0xc6,0x60,0xc6,0x60,0xcc,0x60,
-0xcc,0x60,0xd8,0x60,0xf0,0x60,0xf0,0x60,0xe0,0x60,0xc0,0x60,
-};
-
-static const BitmapCharRec ch78 = {11,14,-1,0,13,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0xc3,0xc,0xc3,0xc,0xc7,0x8c,0xc4,0x8c,0xcc,0xcc,0xcc,0xcc,0xd8,0x6c,0xd8,0x6c,
-0xf0,0x3c,0xf0,0x3c,0xe0,0x1c,0xe0,0x1c,0xc0,0xc,0xc0,0xc,
-};
-
-static const BitmapCharRec ch77 = {14,14,-1,0,16,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch76 = {8,14,-1,0,10,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0xc0,0x70,0xc0,0xe0,0xc1,0xc0,0xc3,0x80,0xc7,0x0,0xce,0x0,0xfc,0x0,0xf8,0x0,
-0xdc,0x0,0xce,0x0,0xc7,0x0,0xc3,0x80,0xc1,0xc0,0xc0,0xe0,
-};
-
-static const BitmapCharRec ch75 = {12,14,-1,0,13,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x3c,0x7e,0xe7,0xc3,0xc3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,
-};
-
-static const BitmapCharRec ch74 = {8,14,-1,0,10,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch73 = {2,14,-2,0,6,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xff,0xe0,0xff,0xe0,
-0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-};
-
-static const BitmapCharRec ch72 = {11,14,-1,0,13,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0xf,0xb0,0x3f,0xf0,0x70,0x70,0x60,0x30,0xe0,0x30,0xc1,0xf0,0xc1,0xf0,0xc0,0x0,
-0xc0,0x0,0xe0,0x30,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch71 = {12,14,-1,0,14,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,
-};
-
-static const BitmapCharRec ch70 = {9,14,-1,0,11,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xff,0x80,0xff,0x80,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x0,0xff,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,0xff,0x80,
-};
-
-static const BitmapCharRec ch69 = {9,14,-1,0,11,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xff,0x0,0xff,0x80,0xc1,0xc0,0xc0,0xc0,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,
-0xc0,0x60,0xc0,0x60,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
-};
-
-static const BitmapCharRec ch68 = {11,14,-1,0,13,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0xf,0x80,0x3f,0xe0,0x70,0x70,0x60,0x30,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0xe0,0x0,0x60,0x30,0x70,0x70,0x3f,0xe0,0xf,0x80,
-};
-
-static const BitmapCharRec ch67 = {12,14,-1,0,14,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xff,0x80,0xff,0xc0,0xc0,0xe0,0xc0,0x60,0xc0,0x60,0xc0,0xe0,0xff,0xc0,0xff,0x80,
-0xc1,0x80,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0xff,0x80,0xff,0x0,
-};
-
-static const BitmapCharRec ch66 = {11,14,-1,0,13,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0xc0,0x30,0xc0,0x30,0x60,0x60,0x60,0x60,0x7f,0xe0,0x3f,0xc0,0x30,0xc0,0x30,0xc0,
-0x19,0x80,0x19,0x80,0xf,0x0,0xf,0x0,0x6,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch65 = {12,14,0,0,12,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x7,0xe0,0x1f,0xf0,0x38,0x0,0x70,0x0,0x67,0x70,0xcf,0xf8,0xcc,0xcc,0xcc,0x66,
-0xcc,0x66,0xcc,0x63,0xc6,0x33,0x67,0x73,0x63,0xb3,0x30,0x6,0x1c,0xe,0xf,0xfc,
-0x3,0xf0,
-};
-
-static const BitmapCharRec ch64 = {16,17,-1,3,18,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x30,0x30,0x0,0x0,0x30,0x30,0x30,0x38,0x1c,0xe,0xc6,0xc6,0xfe,0x7c,
-};
-
-static const BitmapCharRec ch63 = {7,14,-1,0,10,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0xc0,0xf0,0x3c,0xe,0x3,0xe,0x3c,0xf0,0xc0,
-};
-
-static const BitmapCharRec ch62 = {8,9,-1,0,10,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xfe,0xfe,0x0,0x0,0xfe,0xfe,
-};
-
-static const BitmapCharRec ch61 = {7,6,-2,-2,11,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x3,0xf,0x3c,0x70,0xc0,0x70,0x3c,0xf,0x3,
-};
-
-static const BitmapCharRec ch60 = {8,9,-1,0,10,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x40,0x40,0xc0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch59 = {2,13,-1,3,5,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0xc0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch58 = {2,10,-1,0,5,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0x7c,0xfe,0xc6,0x3,0x3,0x3b,0x7f,0xc3,0xc3,0xc3,0xc7,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch57 = {8,13,-1,0,10,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x3c,0x7e,0xe7,0xc3,0xc3,0x66,0x7e,0x66,0xc3,0xc3,0xe7,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch56 = {8,13,-1,0,10,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x60,0x60,0x30,0x30,0x30,0x18,0x18,0xc,0xc,0x6,0x3,0xff,0xff,
-};
-
-static const BitmapCharRec ch55 = {8,13,-1,0,10,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x3c,0x7e,0xe3,0xc3,0xc3,0xc3,0xfe,0xdc,0xc0,0xc0,0x63,0x7f,0x3c,
-};
-
-static const BitmapCharRec ch54 = {8,13,-1,0,10,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x7c,0xfe,0xc7,0xc3,0x3,0x3,0xc7,0xfe,0xfc,0xc0,0xc0,0xfe,0xfe,
-};
-
-static const BitmapCharRec ch53 = {8,13,-1,0,10,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x3,0x0,0x3,0x0,0x3,0x0,0xff,0x80,0xff,0x80,0xc3,0x0,0x63,0x0,0x33,0x0,
-0x33,0x0,0x1b,0x0,0xf,0x0,0x7,0x0,0x3,0x0,
-};
-
-static const BitmapCharRec ch52 = {9,13,-1,0,10,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x3c,0x7e,0xc7,0xc3,0x3,0x7,0x1e,0x1c,0x6,0xc3,0xc3,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch51 = {8,13,-1,0,10,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xff,0xff,0xc0,0xe0,0x70,0x38,0x1c,0xe,0x7,0x3,0xc3,0xfe,0x3c,
-};
-
-static const BitmapCharRec ch50 = {8,13,-1,0,10,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0xf8,0x18,
-};
-
-static const BitmapCharRec ch49 = {5,13,-2,0,10,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x3c,0x7e,0x66,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x7e,0x3c,
-};
-
-static const BitmapCharRec ch48 = {8,13,-1,0,10,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0xc0,0xc0,0x40,0x40,0x60,0x60,0x20,0x20,0x30,0x30,0x10,0x10,0x18,0x18,
-};
-
-static const BitmapCharRec ch47 = {5,14,0,0,5,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch46 = {2,2,-1,0,5,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xff,0xff,
-};
-
-static const BitmapCharRec ch45 = {8,2,-1,-4,11,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x40,0x40,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch44 = {2,5,-1,3,5,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x18,0x18,0x18,0x18,0xff,0xff,0x18,0x18,0x18,0x18,
-};
-
-static const BitmapCharRec ch43 = {8,10,-1,0,10,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0x88,0x70,0x70,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch42 = {5,6,-1,-8,7,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0xc0,0x60,0x60,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0x60,
-0xc0,0x80,
-};
-
-static const BitmapCharRec ch41 = {4,18,-1,4,6,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x10,0x30,0x60,0x60,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x60,0x60,
-0x30,0x10,
-};
-
-static const BitmapCharRec ch40 = {4,18,-1,4,6,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x80,0x40,0x40,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch39 = {2,5,-1,-9,4,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x3c,0x70,0x7e,0xe0,0xe7,0xc0,0xc3,0x80,0xc3,0xc0,0xc6,0xc0,0xee,0xc0,0x7c,0x0,
-0x3c,0x0,0x66,0x0,0x66,0x0,0x7e,0x0,0x3c,0x0,
-};
-
-static const BitmapCharRec ch38 = {12,13,-1,0,13,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x18,0x78,0x18,0xfc,0xc,0xcc,0xc,0xcc,0x6,0xfc,0x6,0x78,0x3,0x0,0x7b,0x0,
-0xfd,0x80,0xcd,0x80,0xcc,0xc0,0xfc,0xc0,0x78,0x60,
-};
-
-static const BitmapCharRec ch37 = {14,13,-1,0,16,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x8,0x0,0x8,0x0,0x3e,0x0,0x7f,0x0,0xeb,0x80,0xc9,0x80,0x9,0x80,0xf,0x0,
-0x3e,0x0,0x78,0x0,0xe8,0x0,0xc8,0x0,0xcb,0x0,0x7f,0x0,0x3e,0x0,0x8,0x0,
-};
-
-static const BitmapCharRec ch36 = {9,16,-1,2,10,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x24,0x0,0x24,0x0,0x24,0x0,0xff,0x80,0xff,0x80,0x12,0x0,0x12,0x0,0x12,0x0,
-0x7f,0xc0,0x7f,0xc0,0x9,0x0,0x9,0x0,0x9,0x0,
-};
-
-static const BitmapCharRec ch35 = {10,13,0,0,10,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0x90,0x90,0xd8,0xd8,0xd8,
-};
-
-static const BitmapCharRec ch34 = {5,5,0,-9,5,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0xc0,0xc0,0x0,0x0,0x80,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch33 = {2,14,-2,0,6,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,5,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,5,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-GLUTAPI const BitmapFontRec glutBitmapHelvetica18;
-const BitmapFontRec glutBitmapHelvetica18 = {
-"-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/glx/glut_init.c b/src/glut/glx/glut_init.c
deleted file mode 100644 (file)
index 213819e..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#if !defined(_WIN32)
-#include <X11/Xlib.h>
-#endif
-
-/* SGI optimization introduced in IRIX 6.3 to avoid X server
-   round trips for interning common X atoms. */
-#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
-#include <X11/SGIFastAtom.h>
-#else
-#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
-#endif
-
-#include "glutint.h"
-
-/* GLUT inter-file variables */
-/* *INDENT-OFF* */
-char *__glutProgramName = NULL;
-int __glutArgc = 0;
-char **__glutArgv = NULL;
-char *__glutGeometry = NULL;
-Display *__glutDisplay = NULL;
-int __glutScreen;
-Window __glutRoot;
-int __glutScreenHeight;
-int __glutScreenWidth;
-GLboolean __glutIconic = GL_FALSE;
-GLboolean __glutDebug = GL_FALSE;
-unsigned int __glutDisplayMode =
-  GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH;
-char *__glutDisplayString = NULL;
-int __glutConnectionFD;
-XSizeHints __glutSizeHints;
-int __glutInitWidth = 300, __glutInitHeight = 300;
-int __glutInitX = -1, __glutInitY = -1;
-GLboolean __glutForceDirect = GL_FALSE,
-  __glutTryDirect = GL_TRUE;
-Atom __glutWMDeleteWindow;
-char *__glutPPMFile = NULL;
-/* *INDENT-ON* */
-
-#ifdef _WIN32
-void (__cdecl *__glutExitFunc)(int retval) = NULL;
-#endif
-
-static Bool synchronize = False;
-
-#if defined(_WIN32)
-
-#ifdef __BORLANDC__
-#include <float.h>  /* For masking floating point exceptions. */
-#endif
-
-void
-__glutOpenWin32Connection(char* display)
-{
-  static char *classname;
-  WNDCLASS  wc;
-  HINSTANCE hInstance = GetModuleHandle(NULL);
-  
-  /* Make sure we register the window only once. */
-  if(classname)
-    return;
-
-#ifdef __BORLANDC__
-  /* Under certain conditions (e.g. while rendering solid surfaces with
-     lighting enabled) Microsoft OpenGL libraries cause some illegal
-     operations like floating point overflow or division by zero. The
-     default behaviour of Microsoft compilers is to mask (ignore)
-     floating point exceptions, while Borland compilers do not.  The
-     following function of Borland RTL allows to mask exceptions.
-     Advice from Pier Giorgio Esposito (mc2172@mclink.it). */
-  _control87(MCW_EM,MCW_EM);
-#endif
-
-  classname = "GLUT";
-
-  /* Clear (important!) and then fill in the window class structure. */
-  memset(&wc, 0, sizeof(WNDCLASS));
-  wc.style         = CS_OWNDC;
-  wc.lpfnWndProc   = (WNDPROC)__glutWindowProc;
-  wc.hInstance     = hInstance;
-  wc.hIcon         = LoadIcon(hInstance, "GLUT_ICON");
-  wc.hCursor       = LoadCursor(hInstance, IDC_ARROW);
-  wc.hbrBackground = NULL;
-  wc.lpszMenuName  = NULL;
-  wc.lpszClassName = classname;
-
-  /* Fill in a default icon if one isn't specified as a resource. */
-  if(!wc.hIcon)
-    wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
-  
-  if(!RegisterClass(&wc)) {
-    __glutFatalError("RegisterClass() failed:"
-                    "Cannot register GLUT window class.");
-  }
-  __glutScreenWidth     = GetSystemMetrics(SM_CXSCREEN);
-  __glutScreenHeight    = GetSystemMetrics(SM_CYSCREEN);
-
-  /* Set the root window to NULL because windows creates a top-level
-     window when the parent is NULL.  X creates a top-level window
-     when the parent is the root window. */
-  __glutRoot            = NULL;
-
-  /* Set the display to 1 -- we shouldn't be using this anywhere
-     (except as an argument to X calls). */
-  __glutDisplay         = (Display*)1;
-
-  /* There isn't any concept of multiple screens in Win32, therefore,
-     we don't need to keep track of the screen we're on... it's always
-     the same one. */
-  __glutScreen          = 0;
-}
-#else /* !_WIN32 */
-void
-__glutOpenXConnection(char *display)
-{
-  int errorBase, eventBase;
-
-  __glutDisplay = XOpenDisplay(display);
-  if (!__glutDisplay)
-    __glutFatalError("could not open display: %s",
-      XDisplayName(display));
-  if (synchronize)
-    XSynchronize(__glutDisplay, True);
-  if (!glXQueryExtension(__glutDisplay, &errorBase, &eventBase))
-    __glutFatalError(
-      "OpenGL GLX extension not supported by display: %s",
-      XDisplayName(display));
-  __glutScreen = DefaultScreen(__glutDisplay);
-  __glutRoot = RootWindow(__glutDisplay, __glutScreen);
-  __glutScreenWidth = DisplayWidth(__glutDisplay, __glutScreen);
-  __glutScreenHeight = DisplayHeight(__glutDisplay,
-    __glutScreen);
-  __glutConnectionFD = ConnectionNumber(__glutDisplay);
-  __glutWMDeleteWindow = XSGIFastInternAtom(__glutDisplay,
-    "WM_DELETE_WINDOW", SGI_XA_WM_DELETE_WINDOW, False);
-}
-#endif /* _WIN32 */
-
-void
-#ifdef OLD_VMS
-  __glutInitTime(struct timeval6 *beginning)
-#else
-  __glutInitTime(struct timeval *beginning)
-#endif
-{
-  static int beenhere = 0;
-#ifdef OLD_VMS
-   static struct timeval6 genesis;
-#else
-   static struct timeval genesis;
-#endif
-   
-  if (!beenhere) {
-    GETTIMEOFDAY(&genesis);
-    beenhere = 1;
-  }
-  *beginning = genesis;
-}
-
-static void
-removeArgs(int *argcp, char **argv, int numToRemove)
-{
-  int i, j;
-
-  for (i = 0, j = numToRemove; argv[j]; i++, j++) {
-    argv[i] = argv[j];
-  }
-  argv[i] = NULL;
-  *argcp -= numToRemove;
-}
-
-void GLUTAPIENTRY 
-glutInit(int *argcp, char **argv)
-{
-  char *display = NULL;
-  char *str, *geometry = NULL;
-#ifdef OLD_VMS
-   struct timeval6 unused;
-#else
-   struct timeval unused;
-#endif
-   int i;
-
-  if (__glutDisplay) {
-    __glutWarning("glutInit being called a second time.");
-    return;
-  }
-  /* Determine temporary program name. */
-  str = strrchr(argv[0], '/');
-  if (str == NULL) {
-    __glutProgramName = argv[0];
-  } else {
-    __glutProgramName = str + 1;
-  }
-
-  /* Make private copy of command line arguments. */
-  __glutArgc = *argcp;
-  __glutArgv = (char **) malloc(__glutArgc * sizeof(char *));
-  if (!__glutArgv)
-    __glutFatalError("out of memory.");
-  for (i = 0; i < __glutArgc; i++) {
-    __glutArgv[i] = __glutStrdup(argv[i]);
-    if (!__glutArgv[i])
-      __glutFatalError("out of memory.");
-  }
-
-  /* determine permanent program name */
-  str = strrchr(__glutArgv[0], '/');
-  if (str == NULL) {
-    __glutProgramName = __glutArgv[0];
-  } else {
-    __glutProgramName = str + 1;
-  }
-
-  /* parse arguments for standard options */
-  for (i = 1; i < __glutArgc; i++) {
-    if (!strcmp(__glutArgv[i], "-display")) {
-#if defined(_WIN32)
-      __glutWarning("-display option not supported by Win32 GLUT.");
-#endif
-      if (++i >= __glutArgc) {
-        __glutFatalError(
-          "follow -display option with X display name.");
-      }
-      display = __glutArgv[i];
-      removeArgs(argcp, &argv[1], 2);
-    } else if (!strcmp(__glutArgv[i], "-geometry")) {
-      if (++i >= __glutArgc) {
-        __glutFatalError(
-          "follow -geometry option with geometry parameter.");
-      }
-      geometry = __glutArgv[i];
-      removeArgs(argcp, &argv[1], 2);
-    } else if (!strcmp(__glutArgv[i], "-direct")) {
-#if defined(_WIN32)
-      __glutWarning("-direct option not supported by Win32 GLUT.");
-#endif
-      if (!__glutTryDirect)
-        __glutFatalError(
-          "cannot force both direct and indirect rendering.");
-      __glutForceDirect = GL_TRUE;
-      removeArgs(argcp, &argv[1], 1);
-    } else if (!strcmp(__glutArgv[i], "-indirect")) {
-#if defined(_WIN32)
-      __glutWarning("-indirect option not supported by Win32 GLUT.");
-#endif
-      if (__glutForceDirect)
-        __glutFatalError(
-          "cannot force both direct and indirect rendering.");
-      __glutTryDirect = GL_FALSE;
-      removeArgs(argcp, &argv[1], 1);
-    } else if (!strcmp(__glutArgv[i], "-iconic")) {
-      __glutIconic = GL_TRUE;
-      removeArgs(argcp, &argv[1], 1);
-    } else if (!strcmp(__glutArgv[i], "-gldebug")) {
-      __glutDebug = GL_TRUE;
-      removeArgs(argcp, &argv[1], 1);
-    } else if (!strcmp(__glutArgv[i], "-sync")) {
-#if defined(_WIN32)
-      __glutWarning("-sync option not supported by Win32 GLUT.");
-#endif
-      synchronize = GL_TRUE;
-      removeArgs(argcp, &argv[1], 1);
-    } else {
-      /* Once unknown option encountered, stop command line
-         processing. */
-      break;
-    }
-  }
-#if defined(_WIN32)
-  __glutOpenWin32Connection(display);
-#else
-  __glutOpenXConnection(display);
-#endif
-  if (geometry) {
-    int flags, x, y, width, height;
-
-    /* Fix bogus "{width|height} may be used before set"
-       warning */
-    width = 0;
-    height = 0;
-
-    flags = XParseGeometry(geometry, &x, &y,
-      (unsigned int *) &width, (unsigned int *) &height);
-    if (WidthValue & flags) {
-      /* Careful because X does not allow zero or negative
-         width windows */
-      if (width > 0)
-        __glutInitWidth = width;
-    }
-    if (HeightValue & flags) {
-      /* Careful because X does not allow zero or negative
-         height windows */
-      if (height > 0)
-        __glutInitHeight = height;
-    }
-    glutInitWindowSize(__glutInitWidth, __glutInitHeight);
-    if (XValue & flags) {
-      if (XNegative & flags)
-        x = DisplayWidth(__glutDisplay, __glutScreen) +
-          x - __glutSizeHints.width;
-      /* Play safe: reject negative X locations */
-      if (x >= 0)
-        __glutInitX = x;
-    }
-    if (YValue & flags) {
-      if (YNegative & flags)
-        y = DisplayHeight(__glutDisplay, __glutScreen) +
-          y - __glutSizeHints.height;
-      /* Play safe: reject negative Y locations */
-      if (y >= 0)
-        __glutInitY = y;
-    }
-    glutInitWindowPosition(__glutInitX, __glutInitY);
-  }
-  __glutInitTime(&unused);
-
-  /* check if GLUT_FPS env var is set */
-  {
-     const char *fps = getenv("GLUT_FPS");
-     if (fps) {
-        sscanf(fps, "%d", &__glutFPS);
-        if (__glutFPS <= 0)
-           __glutFPS = 5000;  /* 5000 milliseconds */
-     }
-  }
-
-  /* check if GLUT_PPM_FILE env var is set */
-  __glutPPMFile = getenv("GLUT_PPM_FILE");
-}
-
-#ifdef _WIN32
-void GLUTAPIENTRY 
-__glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int))
-{
-  __glutExitFunc = exitfunc;
-  glutInit(argcp, argv);
-}
-#endif
-
-/* CENTRY */
-void GLUTAPIENTRY 
-glutInitWindowPosition(int x, int y)
-{
-  __glutInitX = x;
-  __glutInitY = y;
-  if (x >= 0 && y >= 0) {
-    __glutSizeHints.x = x;
-    __glutSizeHints.y = y;
-    __glutSizeHints.flags |= USPosition;
-  } else {
-    __glutSizeHints.flags &= ~USPosition;
-  }
-}
-
-void GLUTAPIENTRY 
-glutInitWindowSize(int width, int height)
-{
-  __glutInitWidth = width;
-  __glutInitHeight = height;
-  if (width > 0 && height > 0) {
-    __glutSizeHints.width = width;
-    __glutSizeHints.height = height;
-    __glutSizeHints.flags |= USSize;
-  } else {
-    __glutSizeHints.flags &= ~USSize;
-  }
-}
-
-void GLUTAPIENTRY 
-glutInitDisplayMode(unsigned int mask)
-{
-  __glutDisplayMode = mask;
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_input.c b/src/glut/glx/glut_input.c
deleted file mode 100644 (file)
index 53f9dc5..0000000
+++ /dev/null
@@ -1,644 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if !defined(_WIN32)
-#include <X11/Xlib.h>
-#if defined(__vms)
-#include <X11/XInput.h>
-#else
-#include <X11/extensions/XInput.h>
-#endif
-#include <X11/Xutil.h>
-#else
-#ifdef __MINGW32__
-#include <GL/gl.h>
-#endif
-#include <windows.h>
-#ifndef __CYGWIN32__
-#include <mmsystem.h>  /* Win32 Multimedia API header. */
-#endif
-#endif /* !_WIN32 */
-
-#include "glutint.h"
-
-int __glutNumDials = 0;
-int __glutNumSpaceballButtons = 0;
-int __glutNumButtonBoxButtons = 0;
-int __glutNumTabletButtons = 0;
-int __glutNumMouseButtons = 3;  /* Good guess. */
-XDevice *__glutTablet = NULL;
-XDevice *__glutDials = NULL;
-XDevice *__glutSpaceball = NULL;
-
-int __glutHasJoystick = 0;
-int __glutNumJoystickButtons = 0;
-int __glutNumJoystickAxes = 0;
-
-#if !defined(_WIN32)
-typedef struct _Range {
-  int min;
-  int range;
-} Range;
-
-#define NUM_SPACEBALL_AXIS     6
-#define NUM_TABLET_AXIS                2
-#define NUM_DIALS_AXIS         8
-
-Range __glutSpaceballRange[NUM_SPACEBALL_AXIS];
-Range __glutTabletRange[NUM_TABLET_AXIS];
-int *__glutDialsResolution;
-
-/* Safely assumes 0 is an illegal event type for X Input
-   extension events. */
-int __glutDeviceMotionNotify = 0;
-int __glutDeviceButtonPress = 0;
-int __glutDeviceButtonPressGrab = 0;
-int __glutDeviceButtonRelease = 0;
-int __glutDeviceStateNotify = 0;
-
-static int
-normalizeTabletPos(int axis, int rawValue)
-{
-  assert(rawValue >= __glutTabletRange[axis].min);
-  assert(rawValue <= __glutTabletRange[axis].min
-    + __glutTabletRange[axis].range);
-  /* Normalize rawValue to between 0 and 4000. */
-  return ((rawValue - __glutTabletRange[axis].min) * 4000) /
-    __glutTabletRange[axis].range;
-}
-
-static int
-normalizeDialAngle(int axis, int rawValue)
-{
-  /* XXX Assumption made that the resolution of the device is
-     number of clicks for one complete dial revolution.  This
-     is true for SGI's dial & button box. */
-  return (rawValue * 360.0) / __glutDialsResolution[axis];
-}
-
-static int
-normalizeSpaceballAngle(int axis, int rawValue)
-{
-  assert(rawValue >= __glutSpaceballRange[axis].min);
-  assert(rawValue <= __glutSpaceballRange[axis].min +
-    __glutSpaceballRange[axis].range);
-  /* Normalize rawValue to between -1800 and 1800. */
-  return ((rawValue - __glutSpaceballRange[axis].min) * 3600) /
-    __glutSpaceballRange[axis].range - 1800;
-}
-
-static int
-normalizeSpaceballDelta(int axis, int rawValue)
-{
-  assert(rawValue >= __glutSpaceballRange[axis].min);
-  assert(rawValue <= __glutSpaceballRange[axis].min +
-    __glutSpaceballRange[axis].range);
-  /* Normalize rawValue to between -1000 and 1000. */
-  return ((rawValue - __glutSpaceballRange[axis].min) * 2000) /
-    __glutSpaceballRange[axis].range - 1000;
-}
-
-static void
-queryTabletPos(GLUTwindow * window)
-{
-  XDeviceState *state;
-  XInputClass *any;
-  XValuatorState *v;
-  int i;
-
-  state = XQueryDeviceState(__glutDisplay, __glutTablet);
-  any = state->data;
-  for (i = 0; i < state->num_classes; i++) {
-#if defined(__cplusplus) || defined(c_plusplus)
-    switch (any->c_class) {
-#else
-    switch (any->class) {
-#endif
-    case ValuatorClass:
-      v = (XValuatorState *) any;
-      if (v->num_valuators < 2)
-        goto end;
-      if (window->tabletPos[0] == -1)
-        window->tabletPos[0] = normalizeTabletPos(0, v->valuators[0]);
-      if (window->tabletPos[1] == -1)
-        window->tabletPos[1] = normalizeTabletPos(1, v->valuators[1]);
-    }
-    any = (XInputClass *) ((char *) any + any->length);
-  }
-end:
-  XFreeDeviceState(state);
-}
-
-static void
-tabletPosChange(GLUTwindow * window, int first, int count, int *data)
-{
-  int i, value, genEvent = 0;
-
-  for (i = first; i < first + count; i++) {
-    switch (i) {
-    case 0:            /* X axis */
-    case 1:            /* Y axis */
-      value = normalizeTabletPos(i, data[i - first]);
-      if (value != window->tabletPos[i]) {
-        window->tabletPos[i] = value;
-        genEvent = 1;
-      }
-      break;
-    }
-  }
-  if (window->tabletPos[0] == -1 || window->tabletPos[1] == -1)
-    queryTabletPos(window);
-  if (genEvent)
-    window->tabletMotion(window->tabletPos[0], window->tabletPos[1]);
-}
-#endif /* !_WIN32 */
-
-static int
-__glutProcessDeviceEvents(XEvent * event)
-{
-#if !defined(_WIN32)
-  GLUTwindow *window;
-
-  /* XXX Ugly code fan out. */
-
-  /* Can't use switch/case since X Input event types are
-     dynamic. */
-
-  if (__glutDeviceMotionNotify && event->type == __glutDeviceMotionNotify) {
-    XDeviceMotionEvent *devmot = (XDeviceMotionEvent *) event;
-
-    window = __glutGetWindow(devmot->window);
-    if (window) {
-      if (__glutTablet
-        && devmot->deviceid == __glutTablet->device_id
-        && window->tabletMotion) {
-        tabletPosChange(window, devmot->first_axis, devmot->axes_count,
-          devmot->axis_data);
-      } else if (__glutDials
-          && devmot->deviceid == __glutDials->device_id
-        && window->dials) {
-        int i, first = devmot->first_axis, count = devmot->axes_count;
-
-        for (i = first; i < first + count; i++)
-          window->dials(i + 1,
-            normalizeDialAngle(i, devmot->axis_data[i - first]));
-      } else if (__glutSpaceball
-        && devmot->deviceid == __glutSpaceball->device_id) {
-        /* XXX Assume that space ball motion events come in as
-           all the first 6 axes.  Assume first 3 axes are XYZ
-           translations; second 3 axes are XYZ rotations. */
-        if (devmot->first_axis == 0 && devmot->axes_count == 6) {
-          if (window->spaceMotion)
-            window->spaceMotion(
-              normalizeSpaceballDelta(0, devmot->axis_data[0]),
-              normalizeSpaceballDelta(1, devmot->axis_data[1]),
-              normalizeSpaceballDelta(2, devmot->axis_data[2]));
-          if (window->spaceRotate)
-            window->spaceRotate(
-              normalizeSpaceballAngle(3, devmot->axis_data[3]),
-              normalizeSpaceballAngle(4, devmot->axis_data[4]),
-              normalizeSpaceballAngle(5, devmot->axis_data[5]));
-        }
-      }
-      return 1;
-    }
-  } else if (__glutDeviceButtonPress
-    && event->type == __glutDeviceButtonPress) {
-    XDeviceButtonEvent *devbtn = (XDeviceButtonEvent *) event;
-
-    window = __glutGetWindow(devbtn->window);
-    if (window) {
-      if (__glutTablet
-        && devbtn->deviceid == __glutTablet->device_id
-        && window->tabletButton
-        && devbtn->first_axis == 0
-        && devbtn->axes_count == 2) {
-        tabletPosChange(window, devbtn->first_axis, devbtn->axes_count,
-          devbtn->axis_data);
-        window->tabletButton(devbtn->button, GLUT_DOWN,
-          window->tabletPos[0], window->tabletPos[1]);
-      } else if (__glutDials
-          && devbtn->deviceid == __glutDials->device_id
-        && window->buttonBox) {
-        window->buttonBox(devbtn->button, GLUT_DOWN);
-      } else if (__glutSpaceball
-          && devbtn->deviceid == __glutSpaceball->device_id
-        && window->spaceButton) {
-        window->spaceButton(devbtn->button, GLUT_DOWN);
-      }
-      return 1;
-    }
-  } else if (__glutDeviceButtonRelease
-    && event->type == __glutDeviceButtonRelease) {
-    XDeviceButtonEvent *devbtn = (XDeviceButtonEvent *) event;
-
-    window = __glutGetWindow(devbtn->window);
-    if (window) {
-      if (__glutTablet
-        && devbtn->deviceid == __glutTablet->device_id
-        && window->tabletButton
-        && devbtn->first_axis == 0
-        && devbtn->axes_count == 2) {
-        tabletPosChange(window, devbtn->first_axis, devbtn->axes_count,
-          devbtn->axis_data);
-        window->tabletButton(devbtn->button, GLUT_UP,
-          window->tabletPos[0], window->tabletPos[1]);
-      } else if (__glutDials
-          && devbtn->deviceid == __glutDials->device_id
-        && window->buttonBox) {
-        window->buttonBox(devbtn->button, GLUT_UP);
-      } else if (__glutSpaceball
-          && devbtn->deviceid == __glutSpaceball->device_id
-        && window->spaceButton) {
-        window->spaceButton(devbtn->button, GLUT_UP);
-      }
-      return 1;
-    }
-  }
-#else
-  {
-    JOYINFOEX info;
-    JOYCAPS joyCaps;
-
-    memset(&info, 0, sizeof(JOYINFOEX)); 
-    info.dwSize = sizeof(JOYINFOEX); 
-    info.dwFlags = JOY_RETURNALL;
-
-    if (joyGetPosEx(JOYSTICKID1,&info) != JOYERR_NOERROR) {
-      __glutHasJoystick = 1;
-      joyGetDevCaps(JOYSTICKID1, &joyCaps, sizeof(joyCaps));
-      __glutNumJoystickButtons = joyCaps.wNumButtons;
-      __glutNumJoystickAxes = joyCaps.wNumAxes;
-    } else {
-      __glutHasJoystick = 0;
-      __glutNumJoystickButtons = 0;
-      __glutNumJoystickAxes = 0;
-    }
-  }
-#endif /* !_WIN32 */
-  return 0;
-}
-
-#if !defined(_WIN32)
-static GLUTeventParser eventParser =
-{__glutProcessDeviceEvents, NULL};
-
-static void
-addDeviceEventParser(void)
-{
-  static Bool been_here = False;
-
-  if (been_here)
-    return;
-  been_here = True;
-  __glutRegisterEventParser(&eventParser);
-}
-#endif
-
-static int
-probeDevices(void)
-{
-  static Bool been_here = False;
-  static int support;
-#if !defined(_WIN32)
-  XExtensionVersion *version;
-  XDeviceInfoPtr device_info, device;
-  XAnyClassPtr any;
-  XButtonInfoPtr b;
-  XValuatorInfoPtr v;
-  XAxisInfoPtr a;
-  int num_dev = 0, btns = 0, dials = 0;
-  int i, j, k;
-#endif /* !_WIN32 */
-
-  if (been_here) {
-    return support;
-  }
-  been_here = True;
-
-#if !defined(_WIN32)
-  version = XGetExtensionVersion(__glutDisplay, "XInputExtension");
-  /* Ugh.  XInput extension API forces annoying cast of a pointer
-     to a long so it can be compared with the NoSuchExtension
-     value (#defined to 1). */
-  if (version == NULL || ((long) version) == NoSuchExtension) {
-    support = 0;
-    return support;
-  }
-  XFree(version);
-  device_info = XListInputDevices(__glutDisplay, &num_dev);
-  if (device_info) {
-    for (i = 0; i < num_dev; i++) {
-      /* XXX These are SGI names for these devices;
-         unfortunately, no good standard exists for standard
-         types of X input extension devices. */
-
-      device = &device_info[i];
-      any = (XAnyClassPtr) device->inputclassinfo;
-
-      if (!__glutSpaceball && !strcmp(device->name, "spaceball")) {
-        v = NULL;
-        b = NULL;
-        for (j = 0; j < device->num_classes; j++) {
-#if defined(__cplusplus) || defined(c_plusplus)
-          switch (any->c_class) {
-#else
-          switch (any->class) {
-#endif
-          case ButtonClass:
-            b = (XButtonInfoPtr) any;
-            btns = b->num_buttons;
-            break;
-          case ValuatorClass:
-            v = (XValuatorInfoPtr) any;
-            /* Sanity check: at least 6 valuators? */
-            if (v->num_axes < NUM_SPACEBALL_AXIS)
-              goto skip_device;
-            a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
-            for (k = 0; k < NUM_SPACEBALL_AXIS; k++, a++) {
-              __glutSpaceballRange[k].min = a->min_value;
-              __glutSpaceballRange[k].range = a->max_value - a->min_value;
-            }
-            break;
-          }
-          any = (XAnyClassPtr) ((char *) any + any->length);
-        }
-        if (v) {
-          __glutSpaceball = XOpenDevice(__glutDisplay, device->id);
-          if (__glutSpaceball) {
-            __glutNumSpaceballButtons = btns;
-            addDeviceEventParser();
-          }
-        }
-      } else if (!__glutDials && !strcmp(device->name, "dial+buttons")) {
-        v = NULL;
-        b = NULL;
-        for (j = 0; j < device->num_classes; j++) {
-#if defined(__cplusplus) || defined(c_plusplus)
-          switch (any->c_class) {
-#else
-          switch (any->class) {
-#endif
-          case ButtonClass:
-            b = (XButtonInfoPtr) any;
-            btns = b->num_buttons;
-            break;
-          case ValuatorClass:
-            v = (XValuatorInfoPtr) any;
-            /* Sanity check: at least 8 valuators? */
-            if (v->num_axes < NUM_DIALS_AXIS)
-              goto skip_device;
-            dials = v->num_axes;
-            __glutDialsResolution = (int *) malloc(sizeof(int) * dials);
-            a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
-            for (k = 0; k < dials; k++, a++) {
-              __glutDialsResolution[k] = a->resolution;
-            }
-            break;
-          }
-          any = (XAnyClassPtr) ((char *) any + any->length);
-        }
-        if (v) {
-          __glutDials = XOpenDevice(__glutDisplay, device->id);
-          if (__glutDials) {
-            __glutNumButtonBoxButtons = btns;
-            __glutNumDials = dials;
-            addDeviceEventParser();
-          }
-        }
-      } else if (!__glutTablet && !strcmp(device->name, "tablet")) {
-        v = NULL;
-        b = NULL;
-        for (j = 0; j < device->num_classes; j++) {
-#if defined(__cplusplus) || defined(c_plusplus)
-          switch (any->c_class) {
-#else
-          switch (any->class) {
-#endif
-          case ButtonClass:
-            b = (XButtonInfoPtr) any;
-            btns = b->num_buttons;
-            break;
-          case ValuatorClass:
-            v = (XValuatorInfoPtr) any;
-            /* Sanity check: exactly 2 valuators? */
-            if (v->num_axes != NUM_TABLET_AXIS)
-              goto skip_device;
-            a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
-            for (k = 0; k < NUM_TABLET_AXIS; k++, a++) {
-              __glutTabletRange[k].min = a->min_value;
-              __glutTabletRange[k].range = a->max_value - a->min_value;
-            }
-            break;
-          }
-          any = (XAnyClassPtr) ((char *) any + any->length);
-        }
-        if (v) {
-          __glutTablet = XOpenDevice(__glutDisplay, device->id);
-          if (__glutTablet) {
-            __glutNumTabletButtons = btns;
-            addDeviceEventParser();
-          }
-        }
-      } else if (!strcmp(device->name, "mouse")) {
-        for (j = 0; j < device->num_classes; j++) {
-#if defined(__cplusplus) || defined(c_plusplus)
-          if (any->c_class == ButtonClass) {
-#else
-          if (any->class == ButtonClass) {
-#endif
-            b = (XButtonInfoPtr) any;
-            __glutNumMouseButtons = b->num_buttons;
-          }
-          any = (XAnyClassPtr) ((char *) any + any->length);
-        }
-      }
-    skip_device:;
-    }
-    XFreeDeviceList(device_info);
-  }
-#else /* _WIN32 */
-  __glutNumMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
-#endif /* !_WIN32 */
-  /* X Input extension might be supported, but only if there is
-     a tablet, dials, or spaceball do we claim devices are
-     supported. */
-  support = __glutTablet || __glutDials || __glutSpaceball;
-  return support;
-}
-
-void
-__glutUpdateInputDeviceMask(GLUTwindow * window)
-{
-#if !defined(_WIN32)
-  /* 5 (dial and buttons) + 5 (tablet locator and buttons) + 5
-     (Spaceball buttons and axis) = 15 */
-  XEventClass eventList[15];
-  int rc, numEvents;
-
-  rc = probeDevices();
-  if (rc) {
-    numEvents = 0;
-    if (__glutTablet) {
-      if (window->tabletMotion) {
-        DeviceMotionNotify(__glutTablet, __glutDeviceMotionNotify,
-          eventList[numEvents]);
-        numEvents++;
-      }
-      if (window->tabletButton) {
-        DeviceButtonPress(__glutTablet, __glutDeviceButtonPress,
-          eventList[numEvents]);
-        numEvents++;
-        DeviceButtonPressGrab(__glutTablet, __glutDeviceButtonPressGrab,
-          eventList[numEvents]);
-        numEvents++;
-        DeviceButtonRelease(__glutTablet, __glutDeviceButtonRelease,
-          eventList[numEvents]);
-        numEvents++;
-      }
-      if (window->tabletMotion || window->tabletButton) {
-        DeviceStateNotify(__glutTablet, __glutDeviceStateNotify,
-          eventList[numEvents]);
-        numEvents++;
-      }
-    }
-    if (__glutDials) {
-      if (window->dials) {
-        DeviceMotionNotify(__glutDials, __glutDeviceMotionNotify,
-          eventList[numEvents]);
-        numEvents++;
-      }
-      if (window->buttonBox) {
-        DeviceButtonPress(__glutDials, __glutDeviceButtonPress,
-          eventList[numEvents]);
-        numEvents++;
-        DeviceButtonPressGrab(__glutDials, __glutDeviceButtonPressGrab,
-          eventList[numEvents]);
-        numEvents++;
-        DeviceButtonRelease(__glutDials, __glutDeviceButtonRelease,
-          eventList[numEvents]);
-        numEvents++;
-      }
-      if (window->dials || window->buttonBox) {
-        DeviceStateNotify(__glutDials, __glutDeviceStateNotify,
-          eventList[numEvents]);
-        numEvents++;
-      }
-    }
-    if (__glutSpaceball) {
-      if (window->spaceMotion || window->spaceRotate) {
-        DeviceMotionNotify(__glutSpaceball, __glutDeviceMotionNotify,
-          eventList[numEvents]);
-        numEvents++;
-      }
-      if (window->spaceButton) {
-        DeviceButtonPress(__glutSpaceball, __glutDeviceButtonPress,
-          eventList[numEvents]);
-        numEvents++;
-        DeviceButtonPressGrab(__glutSpaceball, __glutDeviceButtonPressGrab,
-          eventList[numEvents]);
-        numEvents++;
-        DeviceButtonRelease(__glutSpaceball, __glutDeviceButtonRelease,
-          eventList[numEvents]);
-        numEvents++;
-      }
-      if (window->spaceMotion || window->spaceRotate || window->spaceButton) {
-        DeviceStateNotify(__glutSpaceball, __glutDeviceStateNotify,
-          eventList[numEvents]);
-        numEvents++;
-      }
-    }
-#if 0
-    if (window->children) {
-      GLUTwindow *child = window->children;
-
-      do {
-        XChangeDeviceDontPropagateList(__glutDisplay, child->win,
-          numEvents, eventList, AddToList);
-        child = child->siblings;
-      } while (child);
-    }
-#endif
-    XSelectExtensionEvent(__glutDisplay, window->win,
-      eventList, numEvents);
-    if (window->overlay) {
-      XSelectExtensionEvent(__glutDisplay, window->overlay->win,
-        eventList, numEvents);
-    }
-  } else {
-    /* X Input extension not supported; no chance for exotic
-       input devices. */
-  }
-#endif /* !_WIN32 */
-}
-
-/* CENTRY */
-int GLUTAPIENTRY
-glutDeviceGet(GLenum param)
-{
-  probeDevices();
-  switch (param) {
-  case GLUT_HAS_KEYBOARD:
-  case GLUT_HAS_MOUSE:
-    /* Assume window system always has mouse and keyboard. */
-    return 1;
-  case GLUT_HAS_SPACEBALL:
-    return __glutSpaceball != NULL;
-  case GLUT_HAS_DIAL_AND_BUTTON_BOX:
-    return __glutDials != NULL;
-  case GLUT_HAS_TABLET:
-    return __glutTablet != NULL;
-  case GLUT_NUM_MOUSE_BUTTONS:
-    return __glutNumMouseButtons;
-  case GLUT_NUM_SPACEBALL_BUTTONS:
-    return __glutNumSpaceballButtons;
-  case GLUT_NUM_BUTTON_BOX_BUTTONS:
-    return __glutNumButtonBoxButtons;
-  case GLUT_NUM_DIALS:
-    return __glutNumDials;
-  case GLUT_NUM_TABLET_BUTTONS:
-    return __glutNumTabletButtons;
-  case GLUT_DEVICE_IGNORE_KEY_REPEAT:
-    return __glutCurrentWindow->ignoreKeyRepeat;
-#ifndef _WIN32
-  case GLUT_DEVICE_KEY_REPEAT:
-    {
-      XKeyboardState state;
-
-      XGetKeyboardControl(__glutDisplay, &state);
-      return state.global_auto_repeat;
-    }
-  case GLUT_JOYSTICK_POLL_RATE:
-    return 0;
-#else
-  case GLUT_DEVICE_KEY_REPEAT:
-    /* Win32 cannot globally disable key repeat. */
-    return GLUT_KEY_REPEAT_ON;
-  case GLUT_JOYSTICK_POLL_RATE:
-    return __glutCurrentWindow->joyPollInterval;
-#endif
-  case GLUT_HAS_JOYSTICK:
-    return __glutHasJoystick;
-  case GLUT_JOYSTICK_BUTTONS:
-    return __glutNumJoystickButtons;
-  case GLUT_JOYSTICK_AXES:
-    return __glutNumJoystickAxes;
-  default:
-    __glutWarning("invalid glutDeviceGet parameter: %d", param);
-    return -1;
-  }
-}
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_joy.c b/src/glut/glx/glut_joy.c
deleted file mode 100644 (file)
index 5025607..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1997, 1998. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef _WIN32
-#ifdef __MINGW32__
-#include <GL/gl.h>
-#endif
-#include <windows.h>
-#ifndef __CYGWIN32__
-#include <mmsystem.h>  /* Win32 Multimedia API header. */
-#endif
-#endif
-
-#include "glutint.h"
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutJoystickFunc(GLUTjoystickCB joystickFunc, int pollInterval)
-{
-#ifdef _WIN32
-  if (joystickFunc && (pollInterval > 0)) {
-    if (__glutCurrentWindow->entryState == WM_SETFOCUS) {
-      MMRESULT result;
-
-      /* Capture joystick focus if current window has
-        focus now. */
-      result = joySetCapture(__glutCurrentWindow->win,
-        JOYSTICKID1, 0, TRUE);
-      if (result == JOYERR_NOERROR) {
-        (void) joySetThreshold(JOYSTICKID1, pollInterval);
-      }
-    }
-    __glutCurrentWindow->joyPollInterval = pollInterval;
-  } else {
-    /* Release joystick focus if current window has
-       focus now. */
-    if (__glutCurrentWindow->joystick
-      && (__glutCurrentWindow->joyPollInterval > 0)
-      && (__glutCurrentWindow->entryState == WM_SETFOCUS)) {
-      (void) joyReleaseCapture(JOYSTICKID1);
-    }
-    __glutCurrentWindow->joyPollInterval = 0;
-  }
-  __glutCurrentWindow->joystick = joystickFunc;
-#else
-  /* XXX No support currently for X11 joysticks. */
-#endif
-}
-
-void GLUTAPIENTRY
-glutForceJoystickFunc(void)
-{
-#ifdef _WIN32
-  if (__glutCurrentWindow->joystick) {
-    JOYINFOEX jix;
-    MMRESULT res;
-    int x, y, z;
-
-    /* Poll the joystick. */
-    jix.dwSize = sizeof(jix);
-    jix.dwFlags = JOY_RETURNALL;
-    res = joyGetPosEx(JOYSTICKID1,&jix);
-    if (res == JOYERR_NOERROR) {
-
-      /* Convert to int for scaling. */
-      x = jix.dwXpos;
-      y = jix.dwYpos;
-      z = jix.dwZpos;
-
-#define SCALE(v)  ((int) ((v - 32767)/32.768))
-
-      __glutCurrentWindow->joystick(jix.dwButtons,
-        SCALE(x), SCALE(y), SCALE(z));
-    }
-  }
-#else
-  /* XXX No support currently for X11 joysticks. */
-#endif
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_key.c b/src/glut/glx/glut_key.c
deleted file mode 100644 (file)
index 3e1f7e5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-
-#include "glutint.h"
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutKeyboardFunc(GLUTkeyboardCB keyboardFunc)
-{
-  __glutChangeWindowEventMask(KeyPressMask,
-    keyboardFunc != NULL || __glutCurrentWindow->special != NULL);
-  __glutCurrentWindow->keyboard = keyboardFunc;
-}
-
-void GLUTAPIENTRY
-glutSpecialFunc(GLUTspecialCB specialFunc)
-{
-  __glutChangeWindowEventMask(KeyPressMask,
-    specialFunc != NULL || __glutCurrentWindow->keyboard != NULL);
-  __glutCurrentWindow->special = specialFunc;
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_keyctrl.c b/src/glut/glx/glut_keyctrl.c
deleted file mode 100644 (file)
index c76912e..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1996, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutIgnoreKeyRepeat(int ignore)
-{
-  __glutCurrentWindow->ignoreKeyRepeat = ignore;
-}
-
-void GLUTAPIENTRY
-glutSetKeyRepeat(int repeatMode)
-{
-#if !defined(_WIN32)
-  XKeyboardControl values;
-
-  /* GLUT's repeatMode #define's match the Xlib API values. */
-  values.auto_repeat_mode = repeatMode;
-  XChangeKeyboardControl(__glutDisplay, KBAutoRepeatMode, &values);
-#endif
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_keyup.c b/src/glut/glx/glut_keyup.c
deleted file mode 100644 (file)
index ae97b2f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-
-#include "glutint.h"
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutKeyboardUpFunc(GLUTkeyboardCB keyboardUpFunc)
-{
-  __glutChangeWindowEventMask(KeyReleaseMask,
-    keyboardUpFunc != NULL || __glutCurrentWindow->specialUp != NULL);
-  __glutCurrentWindow->keyboardUp = keyboardUpFunc;
-}
-
-void GLUTAPIENTRY
-glutSpecialUpFunc(GLUTspecialCB specialUpFunc)
-{
-  __glutChangeWindowEventMask(KeyReleaseMask,
-    specialUpFunc != NULL || __glutCurrentWindow->keyboardUp != NULL);
-  __glutCurrentWindow->specialUp = specialUpFunc;
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_menu.c b/src/glut/glx/glut_menu.c
deleted file mode 100644 (file)
index d136823..0000000
+++ /dev/null
@@ -1,1023 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-/* The Win32 GLUT file win32_menu.c completely re-implements all
-   the menuing functionality implemented.  This file is used only by
-   the X Window System version of GLUT. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <assert.h>
-
-#include <unistd.h>
-#include <X11/Xlib.h>
-#include <X11/cursorfont.h>  /* for XC_arrow */
-
-#include "glutint.h"
-#include "layerutil.h"
-
-void (CDECL *__glutMenuStatusFunc) (int, int, int);
-GLUTmenuItem *__glutItemSelected;
-GLUTmenu **__glutMenuList = NULL;
-
-static int menuListSize = 0;
-static XFontStruct *menuFont = NULL;
-static Cursor menuCursor;
-static Colormap menuColormap;
-static Visual *menuVisual;
-static int menuDepth;
-static int fontHeight;
-static GC blackGC, grayGC, whiteGC;
-static unsigned long menuBlack, menuWhite, menuGray;
-static unsigned long useSaveUnders;
-
-/* A replacement for XAllocColor (originally by Brian Paul).
-   This  function should never fail to allocate a color.  When
-   XAllocColor fails, we return the nearest matching color.  If
-   we have to allocate many colors this function isn't a great
-   solution; the XQueryColors() could be done just once.  */
-static void
-noFaultXAllocColor(Display * dpy, Colormap cmap, int cmapSize,
-  XColor * color)
-{
-  XColor *ctable, subColor;
-  int i, bestmatch;
-  double mindist;       /* 3*2^16^2 exceeds 32-bit long int
-                           precision. */
-
-  for (;;) {
-    /* First try just using XAllocColor. */
-    if (XAllocColor(dpy, cmap, color)) {
-      return;
-    }
-
-    /* Retrieve color table entries. */
-    /* XXX alloca canidate. */
-    ctable = (XColor *) malloc(cmapSize * sizeof(XColor));
-    for (i = 0; i < cmapSize; i++)
-      ctable[i].pixel = i;
-    XQueryColors(dpy, cmap, ctable, cmapSize);
-
-    /* Find best match. */
-    bestmatch = -1;
-    mindist = 0.0;
-    for (i = 0; i < cmapSize; i++) {
-      double dr = (double) color->red - (double) ctable[i].red;
-      double dg = (double) color->green - (double) ctable[i].green;
-      double db = (double) color->blue - (double) ctable[i].blue;
-      double dist = dr * dr + dg * dg + db * db;
-      if (bestmatch < 0 || dist < mindist) {
-        bestmatch = i;
-        mindist = dist;
-      }
-    }
-
-    /* Return result. */
-    subColor.red = ctable[bestmatch].red;
-    subColor.green = ctable[bestmatch].green;
-    subColor.blue = ctable[bestmatch].blue;
-    free(ctable);
-    if (XAllocColor(dpy, cmap, &subColor)) {
-      *color = subColor;
-      return;
-    }
-    /* Extremely unlikely, but possibly color was deallocated
-       and reallocated by someone else before we could
-       XAllocColor the color cell we located.  If so, loop
-       again... */
-  }
-}
-
-static int
-ifSunCreator(void)
-{
-  char *xvendor, *glvendor, *renderer;
-  int isSunCreator = 0; /* Until proven that it is. */
-  int savedDisplayMode = 0;
-  char *savedDisplayString = 0;
-  GLUTwindow *window;
-
-#define VENDOR_SUN "Sun Microsystems"
-#define RENDERER_CREATOR "Creator"
-
-  /* Check the X vendor string first.  It is easier to check
-     than the OpenGL vendor and renderer strings since it
-     doesn't require a valid OpenGL rendering context.  Bail
-     early if not connected to a Sun. */
-  xvendor = ServerVendor(__glutDisplay);
-  if (!strncmp(xvendor, VENDOR_SUN, sizeof(VENDOR_SUN) - 1)) {
-
-    /* We need a valid current OpenGL rendering context to be
-       able to call glGetString successfully.  If there is not
-       a current window, set up a temporary one just to call
-       glGetString with (gag, expensive). */
-    if (__glutCurrentWindow) {
-      window = NULL;
-    } else {
-      savedDisplayMode = __glutDisplayMode;
-      savedDisplayString = __glutDisplayString;
-      __glutDisplayMode = GLUT_RGB | GLUT_SINGLE;
-      __glutDisplayString = NULL;
-      window = __glutCreateWindow(NULL, 0, 0, 1, 1, 0);
-    }
-
-    glvendor = (char *) glGetString(GL_VENDOR);
-    if (!strncmp(glvendor, VENDOR_SUN, sizeof(VENDOR_SUN) - 1)) {
-      renderer = (char *) glGetString(GL_RENDERER);
-      if (!strncmp(renderer, RENDERER_CREATOR, sizeof(RENDERER_CREATOR) - 1)) {
-        isSunCreator = 1;
-      }
-    }
-    /* Destroy the temporary window for glGetString if one
-       needed to be created. */
-    if (window) {
-      __glutDestroyWindow(window, window);
-      __glutDisplayMode = savedDisplayMode;
-      __glutDisplayString = savedDisplayString;
-    }
-  }
-  return isSunCreator;
-}
-
-static void
-menuVisualSetup(void)
-{
-  XLayerVisualInfo template, *visual, *overlayVisuals;
-  XColor color;
-  Status status;
-  Bool presumablyMesa;
-  int layer, nVisuals, i, dummy;
-  unsigned long *placeHolders = NULL;
-  int numPlaceHolders = 0;
-  Bool allocateHigh;
-
-  allocateHigh = ifSunCreator();
-
-  /* Start with the highest overlay layer and work down.  I
-     don't think any hardware has more than 3 overlay layers. */
-  for (layer = 3; layer > 0; layer--) {
-    template.layer = layer;
-    template.vinfo.screen = __glutScreen;
-    overlayVisuals = __glutXGetLayerVisualInfo(__glutDisplay,
-      VisualScreenMask | VisualLayerMask, &template, &nVisuals);
-    if (overlayVisuals) {
-      /* First, check if the default visual is in this layer.
-         If the default visual is in this layer, we try to use
-         it since it has pre-defined black and white pixels and 
-
-         using the default visual will probably minimize
-         colormap flashing problems. Suggested by Thomas Roell
-         (thomas@xig.com). */
-      for (i = 0; i < nVisuals; i++) {
-        visual = &overlayVisuals[i];
-        if (visual->vinfo.colormap_size >= 3) {
-          /* Compare visual IDs just to be safe. */
-          if (visual->vinfo.visual->visualid == DefaultVisual(__glutDisplay, __glutScreen)->visualid) {
-            /* Settle for default visual. */
-            menuVisual = DefaultVisual(__glutDisplay, __glutScreen);
-            menuDepth = DefaultDepth(__glutDisplay, __glutScreen);
-            menuColormap = DefaultColormap(__glutDisplay, __glutScreen);
-            menuBlack = BlackPixel(__glutDisplay, __glutScreen);
-            menuWhite = WhitePixel(__glutDisplay, __glutScreen);
-            color.red = color.green = color.blue = 0xaa00;
-            noFaultXAllocColor(__glutDisplay, menuColormap,
-              menuVisual->map_entries, &color);
-            menuGray = color.pixel;
-            useSaveUnders = 0;
-            XFree(overlayVisuals);
-            return;
-          }
-        }
-      }
-      for (i = 0; i < nVisuals; i++) {
-        visual = &overlayVisuals[i];
-        if (visual->vinfo.colormap_size >= 3) {
-          if (allocateHigh) {
-            /* For Sun's Creator graphics, try to force the
-               read-only colors to the high end of the colormap
-               by first allocating read-write place-holder cells
-               for all but the last three cells.  This helps
-               avoid colormap flashing problems. */
-            numPlaceHolders = visual->vinfo.colormap_size - 3;
-            if (numPlaceHolders > 0) {
-              placeHolders = (unsigned long *)
-                malloc(numPlaceHolders * sizeof(unsigned long));
-              /* A malloc failure would be harmless. */
-            }
-          }
-          menuColormap = XCreateColormap(__glutDisplay, __glutRoot,
-            visual->vinfo.visual, AllocNone);
-          if (placeHolders) {
-            /* Again for Sun's Creator graphics, do the actual
-               read-write place-holder cell allocation. */
-            status = XAllocColorCells(__glutDisplay, menuColormap, False, 0, 0,
-              placeHolders, numPlaceHolders);
-            if (!status) {
-              XFreeColormap(__glutDisplay, menuColormap);
-              free(placeHolders);
-              placeHolders = NULL;
-              continue;
-            }
-          }
-          /* Allocate overlay colormap cells in defined order:
-             gray, black, white to match the IRIS GL allocation
-             scheme.  Increases likelihood of less overlay
-             colormap flashing. */
-          /* XXX Nice if these 3 AllocColor's could be done in
-             one protocol round-trip. */
-          color.red = color.green = color.blue = 0xaa00;
-          status = XAllocColor(__glutDisplay,
-            menuColormap, &color);
-          if (!status) {
-            XFreeColormap(__glutDisplay, menuColormap);
-            if (placeHolders) {
-              free(placeHolders);
-              placeHolders = NULL;
-            }
-            continue;
-          }
-          menuGray = color.pixel;
-          color.red = color.green = color.blue = 0x0000;
-          status = XAllocColor(__glutDisplay,
-            menuColormap, &color);
-          if (!status) {
-            XFreeColormap(__glutDisplay, menuColormap);
-            if (placeHolders) {
-              free(placeHolders);
-              placeHolders = NULL;
-            }
-            continue;
-          }
-          menuBlack = color.pixel;
-          color.red = color.green = color.blue = 0xffff;
-          status = XAllocColor(__glutDisplay,
-            menuColormap, &color);
-          if (!status) {
-            XFreeColormap(__glutDisplay, menuColormap);
-            if (placeHolders) {
-              free(placeHolders);
-              placeHolders = NULL;
-            }
-            continue;
-          }
-          if (placeHolders) {
-            /* Now free the placeholder cells. */
-            XFreeColors(__glutDisplay, menuColormap,
-              placeHolders, numPlaceHolders, 0);
-            free(placeHolders);
-            placeHolders = NULL;
-          }
-          menuWhite = color.pixel;
-          menuVisual = visual->vinfo.visual;
-          menuDepth = visual->vinfo.depth;
-          /* If using overlays, do not request "save unders". */
-          useSaveUnders = 0;
-          XFree(overlayVisuals);
-          return;
-        }
-      }
-      XFree(overlayVisuals);
-    }
-  }
-  /* Settle for default visual. */
-  menuVisual = DefaultVisual(__glutDisplay, __glutScreen);
-  menuDepth = DefaultDepth(__glutDisplay, __glutScreen);
-  menuColormap = DefaultColormap(__glutDisplay, __glutScreen);
-  menuBlack = BlackPixel(__glutDisplay, __glutScreen);
-  menuWhite = WhitePixel(__glutDisplay, __glutScreen);
-  color.red = color.green = color.blue = 0xaa00;
-  noFaultXAllocColor(__glutDisplay, menuColormap,
-    menuVisual->map_entries, &color);
-  menuGray = color.pixel;
-
-  /* When no overlays are supported, we would like to use X
-     "save unders" to avoid exposes to windows obscured by
-     pop-up menus.  However, OpenGL's direct rendering support
-     means OpenGL interacts poorly with X backing store and
-     save unders.  X servers do not (in implementation
-     practice) redirect OpenGL rendering destined to obscured
-     window regions into backing store.
-
-     Implementation solutions exist for this problem, but they
-     are expensive and high-end OpenGL implementations
-     typically provide fast rendering and/or overlays to
-     obviate the problem associated of user interfaces (pop-up
-     menus) forcing redraws of complex normal plane scenes.
-     (See support for overlays pop-up menus above.)
-
-     Mesa 3D, however, does not support direct rendering.
-     Overlays are often unavailable to Mesa, and Mesa is also
-     relatively slow.  For these reasons, Mesa-rendering GLUT
-     programs can and should use X save unders.
-
-     Look for the GLX extension.  If _not_ supported, we are
-     presumably using Mesa so enable save unders. */
-
-  presumablyMesa = !XQueryExtension(__glutDisplay, "GLX",
-    &dummy, &dummy, &dummy);
-
-  if (presumablyMesa) {
-    useSaveUnders = CWSaveUnder;
-  } else {
-    useSaveUnders = 0;
-  }
-}
-
-static void
-menuSetup(void)
-{
-  if (menuFont) {
-    /* MenuFont overload to indicate menu initalization. */
-    return;
-  }
-  menuFont = XLoadQueryFont(__glutDisplay,
-    "-*-helvetica-bold-o-normal--14-*-*-*-p-*-iso8859-1");
-  if (!menuFont) {
-    /* Try back up font. */
-    menuFont = XLoadQueryFont(__glutDisplay, "fixed");
-  }
-  if (!menuFont) {
-    __glutFatalError("could not load font.");
-  }
-  menuVisualSetup();
-  fontHeight = menuFont->ascent + menuFont->descent;
-  menuCursor = XCreateFontCursor(__glutDisplay, XC_arrow);
-}
-
-static void
-menuGraphicsContextSetup(Window win)
-{
-  XGCValues gcvals;
-
-  if (blackGC != None) {
-    return;
-  }
-  gcvals.font = menuFont->fid;
-  gcvals.foreground = menuBlack;
-  blackGC = XCreateGC(__glutDisplay, win,
-    GCFont | GCForeground, &gcvals);
-  gcvals.foreground = menuGray;
-  grayGC = XCreateGC(__glutDisplay, win, GCForeground, &gcvals);
-  gcvals.foreground = menuWhite;
-  whiteGC = XCreateGC(__glutDisplay, win, GCForeground, &gcvals);
-}
-
-void
-__glutSetMenu(GLUTmenu * menu)
-{
-  __glutCurrentMenu = menu;
-}
-
-static void
-unmapMenu(GLUTmenu * menu)
-{
-  if (menu->cascade) {
-    unmapMenu(menu->cascade);
-    menu->cascade = NULL;
-  }
-  menu->anchor = NULL;
-  menu->highlighted = NULL;
-  XUnmapWindow(__glutDisplay, menu->win);
-}
-
-static void
-finishMenu(Window win, int x, int y)
-{
-  Window dummy;
-  int rc;
-
-  unmapMenu(__glutMappedMenu);
-  XUngrabPointer(__glutDisplay, CurrentTime);
-
-  /* Popping up an overlay popup menu will install its own
-     colormap.  If the window associated with the menu has an
-     overlay, install that window's overlay colormap so the
-     overlay isn't left using the popup menu's colormap. */
-  if (__glutMenuWindow->overlay) {
-    XInstallColormap(__glutDisplay,
-      __glutMenuWindow->overlay->colormap->cmap);
-  }
-
-  /* This XFlush is needed to to make sure the pointer is
-     really ungrabbed when the application's menu callback is
-     called. Otherwise, a deadlock might happen because the
-     application may try to read from an terminal window, but
-     yet the ungrab hasn't really happened since it hasn't been
-     flushed out. */
-  XFlush(__glutDisplay);
-
-  if (__glutMenuStatusFunc) {
-    if (win != __glutMenuWindow->win) {
-      /* The button release may have occurred in a window other
-         than the window requesting the pop-up menu (for
-         example, one of the submenu windows).  In this case, we
-         need to translate the coordinates into the coordinate
-         system of the window associated with the window. */
-      rc = XTranslateCoordinates(__glutDisplay, win, __glutMenuWindow->win,
-        x, y, &x, &y, &dummy);
-      assert(rc != False);  /* Will always be on same screen. */
-    }
-    __glutSetWindow(__glutMenuWindow);
-    __glutSetMenu(__glutMappedMenu);
-
-    /* Setting __glutMappedMenu to NULL permits operations that
-       change menus or destroy the menu window again. */
-    __glutMappedMenu = NULL;
-
-    __glutMenuStatusFunc(GLUT_MENU_NOT_IN_USE, x, y);
-  }
-  /* Setting __glutMappedMenu to NULL permits operations that
-     change menus or destroy the menu window again. */
-  __glutMappedMenu = NULL;
-
-  /* If an item is selected and it is not a submenu trigger,
-     generate menu callback. */
-  if (__glutItemSelected && !__glutItemSelected->isTrigger) {
-    __glutSetWindow(__glutMenuWindow);
-    /* When menu callback is triggered, current menu should be
-       set to the callback menu. */
-    __glutSetMenu(__glutItemSelected->menu);
-    __glutItemSelected->menu->select(
-      __glutItemSelected->value);
-  }
-  __glutMenuWindow = NULL;
-}
-
-#define MENU_BORDER 1
-#define MENU_GAP 2
-#define MENU_ARROW_GAP 6
-#define MENU_ARROW_WIDTH 8
-
-static void
-mapMenu(GLUTmenu * menu, int x, int y)
-{
-  XWindowChanges changes;
-  unsigned int mask;
-  int subMenuExtension, num;
-
-  /* If there are submenus, we need to provide extra space for
-     the submenu pull arrow.  */
-  if (menu->submenus > 0) {
-    subMenuExtension = MENU_ARROW_GAP + MENU_ARROW_WIDTH;
-  } else {
-    subMenuExtension = 0;
-  }
-
-  changes.stack_mode = Above;
-  mask = CWStackMode | CWX | CWY;
-  /* If the menu isn't managed (ie, validated so all the
-     InputOnly subwindows are the right size), do so.  */
-  if (!menu->managed) {
-    GLUTmenuItem *item;
-
-    item = menu->list;
-    num = menu->num;
-    while (item) {
-      XWindowChanges itemupdate;
-
-      itemupdate.y = (num - 1) * fontHeight + MENU_GAP;
-      itemupdate.width = menu->pixwidth;
-      itemupdate.width += subMenuExtension;
-      XConfigureWindow(__glutDisplay, item->win,
-        CWWidth | CWY, &itemupdate);
-      item = item->next;
-      num--;
-    }
-    menu->pixheight = MENU_GAP +
-      fontHeight * menu->num + MENU_GAP;
-    changes.height = menu->pixheight;
-    changes.width = MENU_GAP +
-      menu->pixwidth + subMenuExtension + MENU_GAP;
-    mask |= CWWidth | CWHeight;
-    menu->managed = True;
-  }
-  /* Make sure menu appears fully on screen. */
-  if (y + menu->pixheight >= __glutScreenHeight) {
-    changes.y = __glutScreenHeight - menu->pixheight;
-  } else {
-    changes.y = y;
-  }
-  if (x + menu->pixwidth + subMenuExtension >=
-    __glutScreenWidth) {
-    changes.x = __glutScreenWidth -
-      menu->pixwidth + subMenuExtension;
-  } else {
-    changes.x = x;
-  }
-
-  /* Rember where the menu is placed so submenus can be
-     properly placed relative to it. */
-  menu->x = changes.x;
-  menu->y = changes.y;
-
-  XConfigureWindow(__glutDisplay, menu->win, mask, &changes);
-  XInstallColormap(__glutDisplay, menuColormap);
-  /* XXX The XRaiseWindow below should not be necessary because
-     the XConfigureWindow requests an Above stack mode (same as
-     XRaiseWindow), but some Sun users complained this was still
-     necessary.  Probably some window manager or X server bug on
-     these machines?? */
-  XRaiseWindow(__glutDisplay, menu->win);
-  XMapWindow(__glutDisplay, menu->win);
-}
-
-static void
-startMenu(GLUTmenu * menu, GLUTwindow * window,
-  int x, int y, int x_win, int y_win)
-{
-  int grab;
-
-  assert(__glutMappedMenu == NULL);
-  grab = XGrabPointer(__glutDisplay, __glutRoot, True,
-    ButtonPressMask | ButtonReleaseMask,
-    GrabModeAsync, GrabModeAsync,
-    __glutRoot, menuCursor, CurrentTime);
-  if (grab != GrabSuccess) {
-    /* Somebody else has pointer grabbed, ignore menu
-       activation. */
-    return;
-  }
-  __glutMappedMenu = menu;
-  __glutMenuWindow = window;
-  __glutItemSelected = NULL;
-  if (__glutMenuStatusFunc) {
-    __glutSetMenu(menu);
-    __glutSetWindow(window);
-    __glutMenuStatusFunc(GLUT_MENU_IN_USE, x_win, y_win);
-  }
-  mapMenu(menu, x, y);
-}
-
-static void
-paintSubMenuArrow(Window win, int x, int y)
-{
-  XPoint p[5];
-
-  p[0].x = p[4].x = x;
-  p[0].y = p[4].y = y - menuFont->ascent + 1;
-  p[1].x = p[0].x + MENU_ARROW_WIDTH - 1;
-  p[1].y = p[0].y + (menuFont->ascent / 2) - 1;
-  p[2].x = p[1].x;
-  p[2].y = p[1].y + 1;
-  p[3].x = p[0].x;
-  p[3].y = p[0].y + menuFont->ascent - 2;
-  XFillPolygon(__glutDisplay, win,
-    whiteGC, p, 4, Convex, CoordModeOrigin);
-  XDrawLines(__glutDisplay, win, blackGC, p, 5, CoordModeOrigin);
-}
-
-static void
-paintMenuItem(GLUTmenuItem * item, int num)
-{
-  Window win = item->menu->win;
-  GC gc;
-  int y;
-  int subMenuExtension;
-
-  if (item->menu->submenus > 0) {
-    subMenuExtension = MENU_ARROW_GAP + MENU_ARROW_WIDTH;
-  } else {
-    subMenuExtension = 0;
-  }
-  if (item->menu->highlighted == item) {
-    gc = whiteGC;
-  } else {
-    gc = grayGC;
-  }
-  y = MENU_GAP + fontHeight * num - menuFont->descent;
-  XFillRectangle(__glutDisplay, win, gc,
-    MENU_GAP, y - fontHeight + menuFont->descent,
-    item->menu->pixwidth + subMenuExtension, fontHeight);
-  XDrawString(__glutDisplay, win, blackGC,
-    MENU_GAP, y, item->label, item->len);
-  if (item->isTrigger) {
-    paintSubMenuArrow(win,
-      item->menu->pixwidth + MENU_ARROW_GAP + 1, y);
-  }
-}
-
-static void
-paintMenu(GLUTmenu * menu)
-{
-  GLUTmenuItem *item;
-  int i = menu->num;
-  int y = MENU_GAP + fontHeight * i - menuFont->descent;
-
-  item = menu->list;
-  while (item) {
-    if (item->menu->highlighted == item) {
-      paintMenuItem(item, i);
-    } else {
-      /* Quick render of the menu item; assume background
-         already cleared to gray. */
-      XDrawString(__glutDisplay, menu->win, blackGC,
-        2, y, item->label, item->len);
-      if (item->isTrigger) {
-        paintSubMenuArrow(menu->win,
-          menu->pixwidth + MENU_ARROW_GAP + 1, y);
-      }
-    }
-    i--;
-    y -= fontHeight;
-    item = item->next;
-  }
-}
-
-static GLUTmenuItem *
-getMenuItem(GLUTmenu * menu, Window win, int *which)
-{
-  GLUTmenuItem *item;
-  int i;
-
-  if (menu->searched) {
-    __glutFatalError("submenu infinite loop detected");
-  }
-  menu->searched = True;
-  i = menu->num;
-  item = menu->list;
-  while (item) {
-    if (item->win == win) {
-      *which = i;
-      menu->searched = False;
-      return item;
-    }
-    if (item->isTrigger) {
-      GLUTmenuItem *subitem;
-
-      subitem = __glutGetMenuItem(__glutMenuList[item->value],
-        win, which);
-      if (subitem) {
-        menu->searched = False;
-        return subitem;
-      }
-    }
-    i--;
-    item = item->next;
-  }
-  menu->searched = False;
-  return NULL;
-}
-
-static int
-getMenuItemIndex(GLUTmenuItem * item)
-{
-  int count = 0;
-
-  while (item) {
-    count++;
-    item = item->next;
-  }
-  return count;
-}
-
-static GLUTmenu *
-getMenu(Window win)
-{
-  GLUTmenu *menu;
-
-  menu = __glutMappedMenu;
-  while (menu) {
-    if (win == menu->win) {
-      return menu;
-    }
-    menu = menu->cascade;
-  }
-  return NULL;
-}
-
-static GLUTmenu *
-getMenuByNum(int menunum)
-{
-  if (menunum < 1 || menunum > menuListSize) {
-    return NULL;
-  }
-  return __glutMenuList[menunum - 1];
-}
-
-static int
-getUnusedMenuSlot(void)
-{
-  int i;
-
-  /* Look for allocated, unused slot. */
-  for (i = 0; i < menuListSize; i++) {
-    if (!__glutMenuList[i]) {
-      return i;
-    }
-  }
-  /* Allocate a new slot. */
-  menuListSize++;
-  if (__glutMenuList) {
-    __glutMenuList = (GLUTmenu **)
-      realloc(__glutMenuList, menuListSize * sizeof(GLUTmenu *));
-  } else {
-    /* XXX Some realloc's do not correctly perform a malloc
-       when asked to perform a realloc on a NULL pointer,
-       though the ANSI C library spec requires this. */
-    __glutMenuList = (GLUTmenu **) malloc(sizeof(GLUTmenu *));
-  }
-  if (!__glutMenuList) {
-    __glutFatalError("out of memory.");
-  }
-  __glutMenuList[menuListSize - 1] = NULL;
-  return menuListSize - 1;
-}
-
-void
-__glutMenuModificationError(void)
-{
-  /* XXX Remove the warning after GLUT 3.0. */
-  __glutWarning("The following is a new check for GLUT 3.0; update your code.");
-  __glutFatalError("menu manipulation not allowed while menus in use.");
-}
-
-
-static void
-menuItemEnterOrLeave(GLUTmenuItem * item,
-  int num, int type)
-{
-  int alreadyUp = 0;
-
-  if (type == EnterNotify) {
-    GLUTmenuItem *prevItem = item->menu->highlighted;
-
-    if (prevItem && prevItem != item) {
-      /* If there's an already higlighted item in this menu
-         that is different from this one (we could be
-         re-entering an item with an already cascaded
-         submenu!), unhighlight the previous item. */
-      item->menu->highlighted = NULL;
-      paintMenuItem(prevItem, getMenuItemIndex(prevItem));
-    }
-    item->menu->highlighted = item;
-    __glutItemSelected = item;
-    if (item->menu->cascade) {
-      if (!item->isTrigger) {
-        /* Entered a menu item that is not a submenu trigger,
-           so pop down the current submenu cascade of this
-           menu.  */
-        unmapMenu(item->menu->cascade);
-        item->menu->cascade = NULL;
-      } else {
-        GLUTmenu *submenu = __glutMenuList[item->value];
-
-        if (submenu->anchor == item) {
-          /* We entered the submenu trigger for the submenu
-             that is already up, so don't take down the
-             submenu.  */
-          alreadyUp = 1;
-        } else {
-          /* Submenu already popped up for some other submenu
-             item of this menu; need to pop down that other
-             submenu cascade.  */
-          unmapMenu(item->menu->cascade);
-          item->menu->cascade = NULL;
-        }
-      }
-    }
-    if (!alreadyUp) {
-      /* Make sure the menu item gets painted with
-         highlighting. */
-      paintMenuItem(item, num);
-    } else {
-      /* If already up, should already be highlighted.  */
-    }
-  } else {
-    /* LeaveNotify: Handle leaving a menu item...  */
-    if (item->menu->cascade &&
-      item->menu->cascade->anchor == item) {
-      /* If there is a submenu casacaded from this item, do not
-         change the highlighting on this item upon leaving. */
-    } else {
-      /* Unhighlight this menu item.  */
-      item->menu->highlighted = NULL;
-      paintMenuItem(item, num);
-    }
-    __glutItemSelected = NULL;
-  }
-  if (item->isTrigger) {
-    if (type == EnterNotify && !alreadyUp) {
-      GLUTmenu *submenu = __glutMenuList[item->value];
-
-      mapMenu(submenu,
-        item->menu->x + item->menu->pixwidth +
-        MENU_ARROW_GAP + MENU_ARROW_WIDTH +
-        MENU_GAP + MENU_BORDER,
-        item->menu->y + fontHeight * (num - 1) + MENU_GAP);
-      item->menu->cascade = submenu;
-      submenu->anchor = item;
-    }
-  }
-}
-
-/* Installs callback functions for use by glut_event.c  The point
-   of this is so that GLUT's menu code only gets linked into
-   GLUT binaries (assuming a static library) if the GLUT menu
-   API is used. */
-static void
-installMenuCallbacks(void)
-{
-  __glutMenuItemEnterOrLeave = menuItemEnterOrLeave;
-  __glutFinishMenu = finishMenu;
-  __glutPaintMenu = paintMenu;
-  __glutStartMenu = startMenu;
-  __glutGetMenuByNum = getMenuByNum;
-  __glutGetMenu = getMenu;
-  __glutGetMenuItem = getMenuItem;
-}
-
-int GLUTAPIENTRY 
-glutCreateMenu(GLUTselectCB selectFunc)
-{
-  XSetWindowAttributes wa;
-  GLUTmenu *menu;
-  int menuid;
-
-  if (__glutMappedMenu) {
-    __glutMenuModificationError();
-  }
-  if (!__glutDisplay) {
-    __glutOpenXConnection(NULL);
-  }
-
-  installMenuCallbacks();
-
-  menuid = getUnusedMenuSlot();
-  menu = (GLUTmenu *) malloc(sizeof(GLUTmenu));
-  if (!menu) {
-    __glutFatalError("out of memory.");
-  }
-  menu->id = menuid;
-  menu->num = 0;
-  menu->submenus = 0;
-  menu->managed = False;
-  menu->searched = False;
-  menu->pixwidth = 0;
-  menu->select = selectFunc;
-  menu->list = NULL;
-  menu->cascade = NULL;
-  menu->highlighted = NULL;
-  menu->anchor = NULL;
-  menuSetup();
-  wa.override_redirect = True;
-  wa.background_pixel = menuGray;
-  wa.border_pixel = menuBlack;
-  wa.colormap = menuColormap;
-  wa.event_mask = StructureNotifyMask | ExposureMask |
-    ButtonPressMask | ButtonReleaseMask |
-    EnterWindowMask | LeaveWindowMask;
-  /* Save unders really only enabled if useSaveUnders is set to
-     CWSaveUnder, ie. using Mesa 3D.  See earlier comments. */
-  wa.save_under = True;
-  menu->win = XCreateWindow(__glutDisplay, __glutRoot,
-  /* Real position determined when mapped. */
-    0, 0,
-  /* Real size will be determined when menu is manged. */
-    1, 1,
-    MENU_BORDER, menuDepth, InputOutput, menuVisual,
-    CWOverrideRedirect | CWBackPixel | CWBorderPixel |
-    CWEventMask | CWColormap | useSaveUnders,
-    &wa);
-  menuGraphicsContextSetup(menu->win);
-  __glutMenuList[menuid] = menu;
-  __glutSetMenu(menu);
-  return menuid + 1;
-}
-
-/* CENTRY */
-int GLUTAPIENTRY 
-glutGetMenu(void)
-{
-  if (__glutCurrentMenu) {
-    return __glutCurrentMenu->id + 1;
-  } else {
-    return 0;
-  }
-}
-
-void GLUTAPIENTRY 
-glutSetMenu(int menuid)
-{
-  GLUTmenu *menu;
-
-  if (menuid < 1 || menuid > menuListSize) {
-    __glutWarning("glutSetMenu attempted on bogus menu.");
-    return;
-  }
-  menu = __glutMenuList[menuid - 1];
-  if (!menu) {
-    __glutWarning("glutSetMenu attempted on bogus menu.");
-    return;
-  }
-  __glutSetMenu(menu);
-}
-/* ENDCENTRY */
-
-void
-__glutSetMenuItem(GLUTmenuItem * item, const char *label,
-  int value, Bool isTrigger)
-{
-  GLUTmenu *menu;
-
-  menu = item->menu;
-  item->label = __glutStrdup(label);
-  if (!item->label) {
-    __glutFatalError("out of memory.");
-  }
-  item->isTrigger = isTrigger;
-  item->len = (int) strlen(label);
-  item->value = value;
-  item->pixwidth = XTextWidth(menuFont, label, item->len) + 4;
-  if (item->pixwidth > menu->pixwidth) {
-    menu->pixwidth = item->pixwidth;
-  }
-  menu->managed = False;
-}
-
-/* CENTRY */
-void GLUTAPIENTRY 
-glutAddMenuEntry(const char *label, int value)
-{
-  XSetWindowAttributes wa;
-  GLUTmenuItem *entry;
-
-  if (__glutMappedMenu) {
-    __glutMenuModificationError();
-  }
-  entry = (GLUTmenuItem *) malloc(sizeof(GLUTmenuItem));
-  if (!entry) {
-    __glutFatalError("out of memory.");
-  }
-  entry->menu = __glutCurrentMenu;
-  __glutSetMenuItem(entry, label, value, False);
-  wa.event_mask = EnterWindowMask | LeaveWindowMask;
-  entry->win = XCreateWindow(__glutDisplay,
-    __glutCurrentMenu->win, MENU_GAP,
-    __glutCurrentMenu->num * fontHeight + MENU_GAP,  /* x & y */
-    entry->pixwidth, fontHeight,  /* width & height */
-    0, CopyFromParent, InputOnly, CopyFromParent,
-    CWEventMask, &wa);
-  XMapWindow(__glutDisplay, entry->win);
-  __glutCurrentMenu->num++;
-  entry->next = __glutCurrentMenu->list;
-  __glutCurrentMenu->list = entry;
-}
-
-void GLUTAPIENTRY 
-glutAddSubMenu(const char *label, int menu)
-{
-  XSetWindowAttributes wa;
-  GLUTmenuItem *submenu;
-
-  if (__glutMappedMenu) {
-    __glutMenuModificationError();
-  }
-  submenu = (GLUTmenuItem *) malloc(sizeof(GLUTmenuItem));
-  if (!submenu) {
-    __glutFatalError("out of memory.");
-  }
-  __glutCurrentMenu->submenus++;
-  submenu->menu = __glutCurrentMenu;
-  __glutSetMenuItem(submenu, label, /* base 0 */ menu - 1, True);
-  wa.event_mask = EnterWindowMask | LeaveWindowMask;
-  submenu->win = XCreateWindow(__glutDisplay,
-    __glutCurrentMenu->win, MENU_GAP,
-    __glutCurrentMenu->num * fontHeight + MENU_GAP,  /* x & y */
-    submenu->pixwidth, fontHeight,  /* width & height */
-    0, CopyFromParent, InputOnly, CopyFromParent,
-    CWEventMask, &wa);
-  XMapWindow(__glutDisplay, submenu->win);
-  __glutCurrentMenu->num++;
-  submenu->next = __glutCurrentMenu->list;
-  __glutCurrentMenu->list = submenu;
-}
-
-void GLUTAPIENTRY 
-glutAttachMenu(int button)
-{
-  /* if button >= GLUT_MAX_MENUS, we'll go out of array bounds below */
-  if (button >= GLUT_MAX_MENUS) {
-    return;
-  }
-  if (__glutMappedMenu) {
-    __glutMenuModificationError();
-  }
-  installMenuCallbacks();
-  if (__glutCurrentWindow->menu[button] < 1) {
-    __glutCurrentWindow->buttonUses++;
-  }
-  __glutChangeWindowEventMask(
-    ButtonPressMask | ButtonReleaseMask, True);
-  __glutCurrentWindow->menu[button] = __glutCurrentMenu->id + 1;
-}
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_menu2.c b/src/glut/glx/glut_menu2.c
deleted file mode 100644 (file)
index 3a66101..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-/* glut_menu2.c implements the little used GLUT menu calls in
-   a distinct file from glut_menu.c for slim static linking. */
-
-/* The Win32 GLUT file win32_menu.c completely re-implements all
-   the menuing functionality implemented.  This file is used only by
-   the X Window System version of GLUT. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <assert.h>
-
-#include <X11/Xlib.h>
-
-#include "glutint.h"
-
-/* CENTRY */
-/* DEPRICATED, use glutMenuStatusFunc instead. */
-void GLUTAPIENTRY 
-glutMenuStateFunc(GLUTmenuStateCB menuStateFunc)
-{
-  __glutMenuStatusFunc = (GLUTmenuStatusCB) menuStateFunc;
-}
-
-void GLUTAPIENTRY 
-glutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc)
-{
-  __glutMenuStatusFunc = menuStatusFunc;
-}
-
-void GLUTAPIENTRY 
-glutDestroyMenu(int menunum)
-{
-  GLUTmenu *menu = __glutGetMenuByNum(menunum);
-  GLUTmenuItem *item, *next;
-
-  if (__glutMappedMenu)
-    __glutMenuModificationError();
-  assert(menu->id == menunum - 1);
-  XDestroySubwindows(__glutDisplay, menu->win);
-  XDestroyWindow(__glutDisplay, menu->win);
-  __glutMenuList[menunum - 1] = NULL;
-  /* free all menu entries */
-  item = menu->list;
-  while (item) {
-    assert(item->menu == menu);
-    next = item->next;
-    free(item->label);
-    free(item);
-    item = next;
-  }
-  if (__glutCurrentMenu == menu) {
-    __glutCurrentMenu = NULL;
-  }
-  free(menu);
-}
-
-void GLUTAPIENTRY 
-glutChangeToMenuEntry(int num, const char *label, int value)
-{
-  GLUTmenuItem *item;
-  int i;
-
-  if (__glutMappedMenu)
-    __glutMenuModificationError();
-  i = __glutCurrentMenu->num;
-  item = __glutCurrentMenu->list;
-  while (item) {
-    if (i == num) {
-      if (item->isTrigger) {
-        /* If changing a submenu trigger to a menu entry, we
-           need to account for submenus.  */
-        item->menu->submenus--;
-      }
-      free(item->label);
-      __glutSetMenuItem(item, label, value, False);
-      return;
-    }
-    i--;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-void GLUTAPIENTRY 
-glutChangeToSubMenu(int num, const char *label, int menu)
-{
-  GLUTmenuItem *item;
-  int i;
-
-  if (__glutMappedMenu)
-    __glutMenuModificationError();
-  i = __glutCurrentMenu->num;
-  item = __glutCurrentMenu->list;
-  while (item) {
-    if (i == num) {
-      if (!item->isTrigger) {
-        /* If changing a menu entry to as submenu trigger, we
-           need to account for submenus.  */
-        item->menu->submenus++;
-      }
-      free(item->label);
-      __glutSetMenuItem(item, label, /* base 0 */ menu - 1, True);
-      return;
-    }
-    i--;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-void GLUTAPIENTRY 
-glutRemoveMenuItem(int num)
-{
-  GLUTmenuItem *item, **prev, *remaining;
-  int pixwidth, i;
-
-  if (__glutMappedMenu)
-    __glutMenuModificationError();
-  i = __glutCurrentMenu->num;
-  prev = &__glutCurrentMenu->list;
-  item = __glutCurrentMenu->list;
-  /* If menu item is removed, the menu's pixwidth may need to
-     be recomputed. */
-  pixwidth = 1;
-  while (item) {
-    if (i == num) {
-      /* If this menu item's pixwidth is as wide as the menu's
-         pixwidth, removing this menu item will necessitate
-         shrinking the menu's pixwidth. */
-      if (item->pixwidth >= __glutCurrentMenu->pixwidth) {
-        /* Continue recalculating menu pixwidth, first skipping
-           the removed item. */
-        remaining = item->next;
-        while (remaining) {
-          if (remaining->pixwidth > pixwidth) {
-            pixwidth = remaining->pixwidth;
-          }
-          remaining = remaining->next;
-        }
-        __glutCurrentMenu->pixwidth = pixwidth;
-      }
-      __glutCurrentMenu->num--;
-      __glutCurrentMenu->managed = False;
-
-      /* Patch up menu's item list. */
-      *prev = item->next;
-
-      free(item->label);
-      free(item);
-      return;
-    }
-    if (item->pixwidth > pixwidth) {
-      pixwidth = item->pixwidth;
-    }
-    i--;
-    prev = &item->next;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-void GLUTAPIENTRY 
-glutDetachMenu(int button)
-{
-  if (__glutMappedMenu)
-    __glutMenuModificationError();
-  if (__glutCurrentWindow->menu[button] > 0) {
-    __glutCurrentWindow->buttonUses--;
-    __glutChangeWindowEventMask(ButtonPressMask | ButtonReleaseMask,
-      __glutCurrentWindow->buttonUses > 0);
-    __glutCurrentWindow->menu[button] = 0;
-  }
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_mesa.c b/src/glut/glx/glut_mesa.c
deleted file mode 100644 (file)
index 7e202fa..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1996. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-#include <string.h>
-#include "glutint.h"
-
-int __glutMesaSwapHackSupport = 0;  /* Not supported until
-                                       proven otherwise. */
-
-/* Use the "Mesa swap hack" if reasonable if and only if
-   MESA_SWAP_HACK is set to something whose first character is
-   not "N" or "n" AND "Brian Paul" is the vendor string AND
-   "Mesa X11"* (or "Mesa" for backward compatibility)  is the
-   renderer string.
-
-   Anyone who modifies Mesa so that glXSwapBuffers does not
-   simply blit the previously rendered back buffer should
-   change either their vendor or renderer string to avoid
-   confusing GLUT. */
-
-void
-__glutDetermineMesaSwapHackSupport(void)
-{
-  static int doneAlready = 0;
-  char *env, *vendor, *renderer;
-
-  if (doneAlready)
-    return;
-  env = getenv("MESA_SWAP_HACK");
-  if (env) {
-    if ((env[0] != 'n') && (env[0] != 'N')) {
-      vendor = (char *) glGetString(GL_VENDOR);
-      renderer = (char *) glGetString(GL_RENDERER);
-
-      /* Old versions of X11 Mesa uses the renderer string
-         "Mesa"; Brian plans to start using "Mesa X11" to
-         distinguish the X version of Mesa from other flavor
-         such as Windows or 3Dfx. */
-
-#define MESA_X11 "Mesa X11"
-
-      /* XXX At some point in the future, eliminate the
-         backward compatibility for the old "Mesa" renderer
-         string. */
-
-      if (!strcmp(vendor, "Brian Paul") && (!strcmp(renderer, "Mesa") ||
-          !strncmp(renderer, MESA_X11, sizeof(MESA_X11) - 1)))
-        __glutMesaSwapHackSupport = 1;
-    }
-  }
-  doneAlready = 1;
-}
diff --git a/src/glut/glx/glut_modifier.c b/src/glut/glx/glut_modifier.c
deleted file mode 100644 (file)
index 69fa5ab..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-
-/* CENTRY */
-int GLUTAPIENTRY
-glutGetModifiers(void)
-{
-  int modifiers;
-
-  if(__glutModifierMask == (unsigned int) ~0) {
-    __glutWarning(
-      "glutCurrentModifiers: do not call outside core input callback.");
-    return 0;
-  }
-  modifiers = 0;
-  if(__glutModifierMask & (ShiftMask|LockMask))
-    modifiers |= GLUT_ACTIVE_SHIFT;
-  if(__glutModifierMask & ControlMask)
-    modifiers |= GLUT_ACTIVE_CTRL;
-  if(__glutModifierMask & Mod1Mask)
-    modifiers |= GLUT_ACTIVE_ALT;
-  return modifiers;
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_mroman.c b/src/glut/glx/glut_mroman.c
deleted file mode 100644 (file)
index 08f879a..0000000
+++ /dev/null
@@ -1,2454 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutStrokeMonoRoman XXX
-#include "glutstroke.h"
-#undef glutStrokeMonoRoman
-
-/* char: 33 '!' */
-
-static const CoordRec char33_stroke0[] = {
-    { 52.381, 100 },
-    { 52.381, 33.3333 },
-};
-
-static const CoordRec char33_stroke1[] = {
-    { 52.381, 9.5238 },
-    { 47.6191, 4.7619 },
-    { 52.381, 0 },
-    { 57.1429, 4.7619 },
-    { 52.381, 9.5238 },
-};
-
-static const StrokeRec char33[] = {
-   { 2, char33_stroke0 },
-   { 5, char33_stroke1 },
-};
-
-/* char: 34 '"' */
-
-static const CoordRec char34_stroke0[] = {
-    { 33.3334, 100 },
-    { 33.3334, 66.6667 },
-};
-
-static const CoordRec char34_stroke1[] = {
-    { 71.4286, 100 },
-    { 71.4286, 66.6667 },
-};
-
-static const StrokeRec char34[] = {
-   { 2, char34_stroke0 },
-   { 2, char34_stroke1 },
-};
-
-/* char: 35 '#' */
-
-static const CoordRec char35_stroke0[] = {
-    { 54.7619, 119.048 },
-    { 21.4286, -33.3333 },
-};
-
-static const CoordRec char35_stroke1[] = {
-    { 83.3334, 119.048 },
-    { 50, -33.3333 },
-};
-
-static const CoordRec char35_stroke2[] = {
-    { 21.4286, 57.1429 },
-    { 88.0952, 57.1429 },
-};
-
-static const CoordRec char35_stroke3[] = {
-    { 16.6667, 28.5714 },
-    { 83.3334, 28.5714 },
-};
-
-static const StrokeRec char35[] = {
-   { 2, char35_stroke0 },
-   { 2, char35_stroke1 },
-   { 2, char35_stroke2 },
-   { 2, char35_stroke3 },
-};
-
-/* char: 36 '$' */
-
-static const CoordRec char36_stroke0[] = {
-    { 42.8571, 119.048 },
-    { 42.8571, -19.0476 },
-};
-
-static const CoordRec char36_stroke1[] = {
-    { 61.9047, 119.048 },
-    { 61.9047, -19.0476 },
-};
-
-static const CoordRec char36_stroke2[] = {
-    { 85.7143, 85.7143 },
-    { 76.1905, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-    { 28.5714, 95.2381 },
-    { 19.0476, 85.7143 },
-    { 19.0476, 76.1905 },
-    { 23.8095, 66.6667 },
-    { 28.5714, 61.9048 },
-    { 38.0952, 57.1429 },
-    { 66.6666, 47.619 },
-    { 76.1905, 42.8571 },
-    { 80.9524, 38.0952 },
-    { 85.7143, 28.5714 },
-    { 85.7143, 14.2857 },
-    { 76.1905, 4.7619 },
-    { 61.9047, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 19.0476, 14.2857 },
-};
-
-static const StrokeRec char36[] = {
-   { 2, char36_stroke0 },
-   { 2, char36_stroke1 },
-   { 20, char36_stroke2 },
-};
-
-/* char: 37 '%' */
-
-static const CoordRec char37_stroke0[] = {
-    { 95.2381, 100 },
-    { 9.5238, 0 },
-};
-
-static const CoordRec char37_stroke1[] = {
-    { 33.3333, 100 },
-    { 42.8571, 90.4762 },
-    { 42.8571, 80.9524 },
-    { 38.0952, 71.4286 },
-    { 28.5714, 66.6667 },
-    { 19.0476, 66.6667 },
-    { 9.5238, 76.1905 },
-    { 9.5238, 85.7143 },
-    { 14.2857, 95.2381 },
-    { 23.8095, 100 },
-    { 33.3333, 100 },
-    { 42.8571, 95.2381 },
-    { 57.1428, 90.4762 },
-    { 71.4286, 90.4762 },
-    { 85.7143, 95.2381 },
-    { 95.2381, 100 },
-};
-
-static const CoordRec char37_stroke2[] = {
-    { 76.1905, 33.3333 },
-    { 66.6667, 28.5714 },
-    { 61.9048, 19.0476 },
-    { 61.9048, 9.5238 },
-    { 71.4286, 0 },
-    { 80.9524, 0 },
-    { 90.4762, 4.7619 },
-    { 95.2381, 14.2857 },
-    { 95.2381, 23.8095 },
-    { 85.7143, 33.3333 },
-    { 76.1905, 33.3333 },
-};
-
-static const StrokeRec char37[] = {
-   { 2, char37_stroke0 },
-   { 16, char37_stroke1 },
-   { 11, char37_stroke2 },
-};
-
-/* char: 38 '&' */
-
-static const CoordRec char38_stroke0[] = {
-    { 100, 57.1429 },
-    { 100, 61.9048 },
-    { 95.2381, 66.6667 },
-    { 90.4762, 66.6667 },
-    { 85.7143, 61.9048 },
-    { 80.9524, 52.381 },
-    { 71.4286, 28.5714 },
-    { 61.9048, 14.2857 },
-    { 52.3809, 4.7619 },
-    { 42.8571, 0 },
-    { 23.8095, 0 },
-    { 14.2857, 4.7619 },
-    { 9.5238, 9.5238 },
-    { 4.7619, 19.0476 },
-    { 4.7619, 28.5714 },
-    { 9.5238, 38.0952 },
-    { 14.2857, 42.8571 },
-    { 47.619, 61.9048 },
-    { 52.3809, 66.6667 },
-    { 57.1429, 76.1905 },
-    { 57.1429, 85.7143 },
-    { 52.3809, 95.2381 },
-    { 42.8571, 100 },
-    { 33.3333, 95.2381 },
-    { 28.5714, 85.7143 },
-    { 28.5714, 76.1905 },
-    { 33.3333, 61.9048 },
-    { 42.8571, 47.619 },
-    { 66.6667, 14.2857 },
-    { 76.1905, 4.7619 },
-    { 85.7143, 0 },
-    { 95.2381, 0 },
-    { 100, 4.7619 },
-    { 100, 9.5238 },
-};
-
-static const StrokeRec char38[] = {
-   { 34, char38_stroke0 },
-};
-
-/* char: 39 ''' */
-
-static const CoordRec char39_stroke0[] = {
-    { 52.381, 100 },
-    { 52.381, 66.6667 },
-};
-
-static const StrokeRec char39[] = {
-   { 2, char39_stroke0 },
-};
-
-/* char: 40 '(' */
-
-static const CoordRec char40_stroke0[] = {
-    { 69.0476, 119.048 },
-    { 59.5238, 109.524 },
-    { 50, 95.2381 },
-    { 40.4762, 76.1905 },
-    { 35.7143, 52.381 },
-    { 35.7143, 33.3333 },
-    { 40.4762, 9.5238 },
-    { 50, -9.5238 },
-    { 59.5238, -23.8095 },
-    { 69.0476, -33.3333 },
-};
-
-static const StrokeRec char40[] = {
-   { 10, char40_stroke0 },
-};
-
-/* char: 41 ')' */
-
-static const CoordRec char41_stroke0[] = {
-    { 35.7143, 119.048 },
-    { 45.2381, 109.524 },
-    { 54.7619, 95.2381 },
-    { 64.2857, 76.1905 },
-    { 69.0476, 52.381 },
-    { 69.0476, 33.3333 },
-    { 64.2857, 9.5238 },
-    { 54.7619, -9.5238 },
-    { 45.2381, -23.8095 },
-    { 35.7143, -33.3333 },
-};
-
-static const StrokeRec char41[] = {
-   { 10, char41_stroke0 },
-};
-
-/* char: 42 '*' */
-
-static const CoordRec char42_stroke0[] = {
-    { 52.381, 71.4286 },
-    { 52.381, 14.2857 },
-};
-
-static const CoordRec char42_stroke1[] = {
-    { 28.5715, 57.1429 },
-    { 76.1905, 28.5714 },
-};
-
-static const CoordRec char42_stroke2[] = {
-    { 76.1905, 57.1429 },
-    { 28.5715, 28.5714 },
-};
-
-static const StrokeRec char42[] = {
-   { 2, char42_stroke0 },
-   { 2, char42_stroke1 },
-   { 2, char42_stroke2 },
-};
-
-/* char: 43 '+' */
-
-static const CoordRec char43_stroke0[] = {
-    { 52.3809, 85.7143 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char43_stroke1[] = {
-    { 9.5238, 42.8571 },
-    { 95.2381, 42.8571 },
-};
-
-static const StrokeRec char43[] = {
-   { 2, char43_stroke0 },
-   { 2, char43_stroke1 },
-};
-
-/* char: 44 ',' */
-
-static const CoordRec char44_stroke0[] = {
-    { 57.1429, 4.7619 },
-    { 52.381, 0 },
-    { 47.6191, 4.7619 },
-    { 52.381, 9.5238 },
-    { 57.1429, 4.7619 },
-    { 57.1429, -4.7619 },
-    { 52.381, -14.2857 },
-    { 47.6191, -19.0476 },
-};
-
-static const StrokeRec char44[] = {
-   { 8, char44_stroke0 },
-};
-
-/* char: 45 '-' */
-
-static const CoordRec char45_stroke0[] = {
-    { 9.5238, 42.8571 },
-    { 95.2381, 42.8571 },
-};
-
-static const StrokeRec char45[] = {
-   { 2, char45_stroke0 },
-};
-
-/* char: 46 '.' */
-
-static const CoordRec char46_stroke0[] = {
-    { 52.381, 9.5238 },
-    { 47.6191, 4.7619 },
-    { 52.381, 0 },
-    { 57.1429, 4.7619 },
-    { 52.381, 9.5238 },
-};
-
-static const StrokeRec char46[] = {
-   { 5, char46_stroke0 },
-};
-
-/* char: 47 '/' */
-
-static const CoordRec char47_stroke0[] = {
-    { 19.0476, -14.2857 },
-    { 85.7143, 100 },
-};
-
-static const StrokeRec char47[] = {
-   { 2, char47_stroke0 },
-};
-
-/* char: 48 '0' */
-
-static const CoordRec char48_stroke0[] = {
-    { 47.619, 100 },
-    { 33.3333, 95.2381 },
-    { 23.8095, 80.9524 },
-    { 19.0476, 57.1429 },
-    { 19.0476, 42.8571 },
-    { 23.8095, 19.0476 },
-    { 33.3333, 4.7619 },
-    { 47.619, 0 },
-    { 57.1428, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 19.0476 },
-    { 85.7143, 42.8571 },
-    { 85.7143, 57.1429 },
-    { 80.9524, 80.9524 },
-    { 71.4286, 95.2381 },
-    { 57.1428, 100 },
-    { 47.619, 100 },
-};
-
-static const StrokeRec char48[] = {
-   { 17, char48_stroke0 },
-};
-
-/* char: 49 '1' */
-
-static const CoordRec char49_stroke0[] = {
-    { 40.4762, 80.9524 },
-    { 50, 85.7143 },
-    { 64.2857, 100 },
-    { 64.2857, 0 },
-};
-
-static const StrokeRec char49[] = {
-   { 4, char49_stroke0 },
-};
-
-/* char: 50 '2' */
-
-static const CoordRec char50_stroke0[] = {
-    { 23.8095, 76.1905 },
-    { 23.8095, 80.9524 },
-    { 28.5714, 90.4762 },
-    { 33.3333, 95.2381 },
-    { 42.8571, 100 },
-    { 61.9047, 100 },
-    { 71.4286, 95.2381 },
-    { 76.1905, 90.4762 },
-    { 80.9524, 80.9524 },
-    { 80.9524, 71.4286 },
-    { 76.1905, 61.9048 },
-    { 66.6666, 47.619 },
-    { 19.0476, 0 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char50[] = {
-   { 14, char50_stroke0 },
-};
-
-/* char: 51 '3' */
-
-static const CoordRec char51_stroke0[] = {
-    { 28.5714, 100 },
-    { 80.9524, 100 },
-    { 52.3809, 61.9048 },
-    { 66.6666, 61.9048 },
-    { 76.1905, 57.1429 },
-    { 80.9524, 52.381 },
-    { 85.7143, 38.0952 },
-    { 85.7143, 28.5714 },
-    { 80.9524, 14.2857 },
-    { 71.4286, 4.7619 },
-    { 57.1428, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 23.8095, 9.5238 },
-    { 19.0476, 19.0476 },
-};
-
-static const StrokeRec char51[] = {
-   { 15, char51_stroke0 },
-};
-
-/* char: 52 '4' */
-
-static const CoordRec char52_stroke0[] = {
-    { 64.2857, 100 },
-    { 16.6667, 33.3333 },
-    { 88.0952, 33.3333 },
-};
-
-static const CoordRec char52_stroke1[] = {
-    { 64.2857, 100 },
-    { 64.2857, 0 },
-};
-
-static const StrokeRec char52[] = {
-   { 3, char52_stroke0 },
-   { 2, char52_stroke1 },
-};
-
-/* char: 53 '5' */
-
-static const CoordRec char53_stroke0[] = {
-    { 76.1905, 100 },
-    { 28.5714, 100 },
-    { 23.8095, 57.1429 },
-    { 28.5714, 61.9048 },
-    { 42.8571, 66.6667 },
-    { 57.1428, 66.6667 },
-    { 71.4286, 61.9048 },
-    { 80.9524, 52.381 },
-    { 85.7143, 38.0952 },
-    { 85.7143, 28.5714 },
-    { 80.9524, 14.2857 },
-    { 71.4286, 4.7619 },
-    { 57.1428, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 23.8095, 9.5238 },
-    { 19.0476, 19.0476 },
-};
-
-static const StrokeRec char53[] = {
-   { 17, char53_stroke0 },
-};
-
-/* char: 54 '6' */
-
-static const CoordRec char54_stroke0[] = {
-    { 78.5714, 85.7143 },
-    { 73.8096, 95.2381 },
-    { 59.5238, 100 },
-    { 50, 100 },
-    { 35.7143, 95.2381 },
-    { 26.1905, 80.9524 },
-    { 21.4286, 57.1429 },
-    { 21.4286, 33.3333 },
-    { 26.1905, 14.2857 },
-    { 35.7143, 4.7619 },
-    { 50, 0 },
-    { 54.7619, 0 },
-    { 69.0476, 4.7619 },
-    { 78.5714, 14.2857 },
-    { 83.3334, 28.5714 },
-    { 83.3334, 33.3333 },
-    { 78.5714, 47.619 },
-    { 69.0476, 57.1429 },
-    { 54.7619, 61.9048 },
-    { 50, 61.9048 },
-    { 35.7143, 57.1429 },
-    { 26.1905, 47.619 },
-    { 21.4286, 33.3333 },
-};
-
-static const StrokeRec char54[] = {
-   { 23, char54_stroke0 },
-};
-
-/* char: 55 '7' */
-
-static const CoordRec char55_stroke0[] = {
-    { 85.7143, 100 },
-    { 38.0952, 0 },
-};
-
-static const CoordRec char55_stroke1[] = {
-    { 19.0476, 100 },
-    { 85.7143, 100 },
-};
-
-static const StrokeRec char55[] = {
-   { 2, char55_stroke0 },
-   { 2, char55_stroke1 },
-};
-
-/* char: 56 '8' */
-
-static const CoordRec char56_stroke0[] = {
-    { 42.8571, 100 },
-    { 28.5714, 95.2381 },
-    { 23.8095, 85.7143 },
-    { 23.8095, 76.1905 },
-    { 28.5714, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 57.1428, 57.1429 },
-    { 71.4286, 52.381 },
-    { 80.9524, 42.8571 },
-    { 85.7143, 33.3333 },
-    { 85.7143, 19.0476 },
-    { 80.9524, 9.5238 },
-    { 76.1905, 4.7619 },
-    { 61.9047, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 23.8095, 9.5238 },
-    { 19.0476, 19.0476 },
-    { 19.0476, 33.3333 },
-    { 23.8095, 42.8571 },
-    { 33.3333, 52.381 },
-    { 47.619, 57.1429 },
-    { 66.6666, 61.9048 },
-    { 76.1905, 66.6667 },
-    { 80.9524, 76.1905 },
-    { 80.9524, 85.7143 },
-    { 76.1905, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-};
-
-static const StrokeRec char56[] = {
-   { 29, char56_stroke0 },
-};
-
-/* char: 57 '9' */
-
-static const CoordRec char57_stroke0[] = {
-    { 83.3334, 66.6667 },
-    { 78.5714, 52.381 },
-    { 69.0476, 42.8571 },
-    { 54.7619, 38.0952 },
-    { 50, 38.0952 },
-    { 35.7143, 42.8571 },
-    { 26.1905, 52.381 },
-    { 21.4286, 66.6667 },
-    { 21.4286, 71.4286 },
-    { 26.1905, 85.7143 },
-    { 35.7143, 95.2381 },
-    { 50, 100 },
-    { 54.7619, 100 },
-    { 69.0476, 95.2381 },
-    { 78.5714, 85.7143 },
-    { 83.3334, 66.6667 },
-    { 83.3334, 42.8571 },
-    { 78.5714, 19.0476 },
-    { 69.0476, 4.7619 },
-    { 54.7619, 0 },
-    { 45.2381, 0 },
-    { 30.9524, 4.7619 },
-    { 26.1905, 14.2857 },
-};
-
-static const StrokeRec char57[] = {
-   { 23, char57_stroke0 },
-};
-
-/* char: 58 ':' */
-
-static const CoordRec char58_stroke0[] = {
-    { 52.381, 66.6667 },
-    { 47.6191, 61.9048 },
-    { 52.381, 57.1429 },
-    { 57.1429, 61.9048 },
-    { 52.381, 66.6667 },
-};
-
-static const CoordRec char58_stroke1[] = {
-    { 52.381, 9.5238 },
-    { 47.6191, 4.7619 },
-    { 52.381, 0 },
-    { 57.1429, 4.7619 },
-    { 52.381, 9.5238 },
-};
-
-static const StrokeRec char58[] = {
-   { 5, char58_stroke0 },
-   { 5, char58_stroke1 },
-};
-
-/* char: 59 ';' */
-
-static const CoordRec char59_stroke0[] = {
-    { 52.381, 66.6667 },
-    { 47.6191, 61.9048 },
-    { 52.381, 57.1429 },
-    { 57.1429, 61.9048 },
-    { 52.381, 66.6667 },
-};
-
-static const CoordRec char59_stroke1[] = {
-    { 57.1429, 4.7619 },
-    { 52.381, 0 },
-    { 47.6191, 4.7619 },
-    { 52.381, 9.5238 },
-    { 57.1429, 4.7619 },
-    { 57.1429, -4.7619 },
-    { 52.381, -14.2857 },
-    { 47.6191, -19.0476 },
-};
-
-static const StrokeRec char59[] = {
-   { 5, char59_stroke0 },
-   { 8, char59_stroke1 },
-};
-
-/* char: 60 '<' */
-
-static const CoordRec char60_stroke0[] = {
-    { 90.4762, 85.7143 },
-    { 14.2857, 42.8571 },
-    { 90.4762, 0 },
-};
-
-static const StrokeRec char60[] = {
-   { 3, char60_stroke0 },
-};
-
-/* char: 61 '=' */
-
-static const CoordRec char61_stroke0[] = {
-    { 9.5238, 57.1429 },
-    { 95.2381, 57.1429 },
-};
-
-static const CoordRec char61_stroke1[] = {
-    { 9.5238, 28.5714 },
-    { 95.2381, 28.5714 },
-};
-
-static const StrokeRec char61[] = {
-   { 2, char61_stroke0 },
-   { 2, char61_stroke1 },
-};
-
-/* char: 62 '>' */
-
-static const CoordRec char62_stroke0[] = {
-    { 14.2857, 85.7143 },
-    { 90.4762, 42.8571 },
-    { 14.2857, 0 },
-};
-
-static const StrokeRec char62[] = {
-   { 3, char62_stroke0 },
-};
-
-/* char: 63 '?' */
-
-static const CoordRec char63_stroke0[] = {
-    { 23.8095, 76.1905 },
-    { 23.8095, 80.9524 },
-    { 28.5714, 90.4762 },
-    { 33.3333, 95.2381 },
-    { 42.8571, 100 },
-    { 61.9047, 100 },
-    { 71.4285, 95.2381 },
-    { 76.1905, 90.4762 },
-    { 80.9524, 80.9524 },
-    { 80.9524, 71.4286 },
-    { 76.1905, 61.9048 },
-    { 71.4285, 57.1429 },
-    { 52.3809, 47.619 },
-    { 52.3809, 33.3333 },
-};
-
-static const CoordRec char63_stroke1[] = {
-    { 52.3809, 9.5238 },
-    { 47.619, 4.7619 },
-    { 52.3809, 0 },
-    { 57.1428, 4.7619 },
-    { 52.3809, 9.5238 },
-};
-
-static const StrokeRec char63[] = {
-   { 14, char63_stroke0 },
-   { 5, char63_stroke1 },
-};
-
-/* char: 64 '@' */
-
-static const CoordRec char64_stroke0[] = {
-    { 64.2857, 52.381 },
-    { 54.7619, 57.1429 },
-    { 45.2381, 57.1429 },
-    { 40.4762, 47.619 },
-    { 40.4762, 42.8571 },
-    { 45.2381, 33.3333 },
-    { 54.7619, 33.3333 },
-    { 64.2857, 38.0952 },
-};
-
-static const CoordRec char64_stroke1[] = {
-    { 64.2857, 57.1429 },
-    { 64.2857, 38.0952 },
-    { 69.0476, 33.3333 },
-    { 78.5714, 33.3333 },
-    { 83.3334, 42.8571 },
-    { 83.3334, 47.619 },
-    { 78.5714, 61.9048 },
-    { 69.0476, 71.4286 },
-    { 54.7619, 76.1905 },
-    { 50, 76.1905 },
-    { 35.7143, 71.4286 },
-    { 26.1905, 61.9048 },
-    { 21.4286, 47.619 },
-    { 21.4286, 42.8571 },
-    { 26.1905, 28.5714 },
-    { 35.7143, 19.0476 },
-    { 50, 14.2857 },
-    { 54.7619, 14.2857 },
-    { 69.0476, 19.0476 },
-};
-
-static const StrokeRec char64[] = {
-   { 8, char64_stroke0 },
-   { 19, char64_stroke1 },
-};
-
-/* char: 65 'A' */
-
-static const CoordRec char65_stroke0[] = {
-    { 52.3809, 100 },
-    { 14.2857, 0 },
-};
-
-static const CoordRec char65_stroke1[] = {
-    { 52.3809, 100 },
-    { 90.4762, 0 },
-};
-
-static const CoordRec char65_stroke2[] = {
-    { 28.5714, 33.3333 },
-    { 76.1905, 33.3333 },
-};
-
-static const StrokeRec char65[] = {
-   { 2, char65_stroke0 },
-   { 2, char65_stroke1 },
-   { 2, char65_stroke2 },
-};
-
-/* char: 66 'B' */
-
-static const CoordRec char66_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char66_stroke1[] = {
-    { 19.0476, 100 },
-    { 61.9047, 100 },
-    { 76.1905, 95.2381 },
-    { 80.9524, 90.4762 },
-    { 85.7143, 80.9524 },
-    { 85.7143, 71.4286 },
-    { 80.9524, 61.9048 },
-    { 76.1905, 57.1429 },
-    { 61.9047, 52.381 },
-};
-
-static const CoordRec char66_stroke2[] = {
-    { 19.0476, 52.381 },
-    { 61.9047, 52.381 },
-    { 76.1905, 47.619 },
-    { 80.9524, 42.8571 },
-    { 85.7143, 33.3333 },
-    { 85.7143, 19.0476 },
-    { 80.9524, 9.5238 },
-    { 76.1905, 4.7619 },
-    { 61.9047, 0 },
-    { 19.0476, 0 },
-};
-
-static const StrokeRec char66[] = {
-   { 2, char66_stroke0 },
-   { 9, char66_stroke1 },
-   { 10, char66_stroke2 },
-};
-
-/* char: 67 'C' */
-
-static const CoordRec char67_stroke0[] = {
-    { 88.0952, 76.1905 },
-    { 83.3334, 85.7143 },
-    { 73.8096, 95.2381 },
-    { 64.2857, 100 },
-    { 45.2381, 100 },
-    { 35.7143, 95.2381 },
-    { 26.1905, 85.7143 },
-    { 21.4286, 76.1905 },
-    { 16.6667, 61.9048 },
-    { 16.6667, 38.0952 },
-    { 21.4286, 23.8095 },
-    { 26.1905, 14.2857 },
-    { 35.7143, 4.7619 },
-    { 45.2381, 0 },
-    { 64.2857, 0 },
-    { 73.8096, 4.7619 },
-    { 83.3334, 14.2857 },
-    { 88.0952, 23.8095 },
-};
-
-static const StrokeRec char67[] = {
-   { 18, char67_stroke0 },
-};
-
-/* char: 68 'D' */
-
-static const CoordRec char68_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char68_stroke1[] = {
-    { 19.0476, 100 },
-    { 52.3809, 100 },
-    { 66.6666, 95.2381 },
-    { 76.1905, 85.7143 },
-    { 80.9524, 76.1905 },
-    { 85.7143, 61.9048 },
-    { 85.7143, 38.0952 },
-    { 80.9524, 23.8095 },
-    { 76.1905, 14.2857 },
-    { 66.6666, 4.7619 },
-    { 52.3809, 0 },
-    { 19.0476, 0 },
-};
-
-static const StrokeRec char68[] = {
-   { 2, char68_stroke0 },
-   { 12, char68_stroke1 },
-};
-
-/* char: 69 'E' */
-
-static const CoordRec char69_stroke0[] = {
-    { 21.4286, 100 },
-    { 21.4286, 0 },
-};
-
-static const CoordRec char69_stroke1[] = {
-    { 21.4286, 100 },
-    { 83.3334, 100 },
-};
-
-static const CoordRec char69_stroke2[] = {
-    { 21.4286, 52.381 },
-    { 59.5238, 52.381 },
-};
-
-static const CoordRec char69_stroke3[] = {
-    { 21.4286, 0 },
-    { 83.3334, 0 },
-};
-
-static const StrokeRec char69[] = {
-   { 2, char69_stroke0 },
-   { 2, char69_stroke1 },
-   { 2, char69_stroke2 },
-   { 2, char69_stroke3 },
-};
-
-/* char: 70 'F' */
-
-static const CoordRec char70_stroke0[] = {
-    { 21.4286, 100 },
-    { 21.4286, 0 },
-};
-
-static const CoordRec char70_stroke1[] = {
-    { 21.4286, 100 },
-    { 83.3334, 100 },
-};
-
-static const CoordRec char70_stroke2[] = {
-    { 21.4286, 52.381 },
-    { 59.5238, 52.381 },
-};
-
-static const StrokeRec char70[] = {
-   { 2, char70_stroke0 },
-   { 2, char70_stroke1 },
-   { 2, char70_stroke2 },
-};
-
-/* char: 71 'G' */
-
-static const CoordRec char71_stroke0[] = {
-    { 88.0952, 76.1905 },
-    { 83.3334, 85.7143 },
-    { 73.8096, 95.2381 },
-    { 64.2857, 100 },
-    { 45.2381, 100 },
-    { 35.7143, 95.2381 },
-    { 26.1905, 85.7143 },
-    { 21.4286, 76.1905 },
-    { 16.6667, 61.9048 },
-    { 16.6667, 38.0952 },
-    { 21.4286, 23.8095 },
-    { 26.1905, 14.2857 },
-    { 35.7143, 4.7619 },
-    { 45.2381, 0 },
-    { 64.2857, 0 },
-    { 73.8096, 4.7619 },
-    { 83.3334, 14.2857 },
-    { 88.0952, 23.8095 },
-    { 88.0952, 38.0952 },
-};
-
-static const CoordRec char71_stroke1[] = {
-    { 64.2857, 38.0952 },
-    { 88.0952, 38.0952 },
-};
-
-static const StrokeRec char71[] = {
-   { 19, char71_stroke0 },
-   { 2, char71_stroke1 },
-};
-
-/* char: 72 'H' */
-
-static const CoordRec char72_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char72_stroke1[] = {
-    { 85.7143, 100 },
-    { 85.7143, 0 },
-};
-
-static const CoordRec char72_stroke2[] = {
-    { 19.0476, 52.381 },
-    { 85.7143, 52.381 },
-};
-
-static const StrokeRec char72[] = {
-   { 2, char72_stroke0 },
-   { 2, char72_stroke1 },
-   { 2, char72_stroke2 },
-};
-
-/* char: 73 'I' */
-
-static const CoordRec char73_stroke0[] = {
-    { 52.381, 100 },
-    { 52.381, 0 },
-};
-
-static const StrokeRec char73[] = {
-   { 2, char73_stroke0 },
-};
-
-/* char: 74 'J' */
-
-static const CoordRec char74_stroke0[] = {
-    { 76.1905, 100 },
-    { 76.1905, 23.8095 },
-    { 71.4286, 9.5238 },
-    { 66.6667, 4.7619 },
-    { 57.1429, 0 },
-    { 47.6191, 0 },
-    { 38.0953, 4.7619 },
-    { 33.3334, 9.5238 },
-    { 28.5715, 23.8095 },
-    { 28.5715, 33.3333 },
-};
-
-static const StrokeRec char74[] = {
-   { 10, char74_stroke0 },
-};
-
-/* char: 75 'K' */
-
-static const CoordRec char75_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char75_stroke1[] = {
-    { 85.7143, 100 },
-    { 19.0476, 33.3333 },
-};
-
-static const CoordRec char75_stroke2[] = {
-    { 42.8571, 57.1429 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char75[] = {
-   { 2, char75_stroke0 },
-   { 2, char75_stroke1 },
-   { 2, char75_stroke2 },
-};
-
-/* char: 76 'L' */
-
-static const CoordRec char76_stroke0[] = {
-    { 23.8095, 100 },
-    { 23.8095, 0 },
-};
-
-static const CoordRec char76_stroke1[] = {
-    { 23.8095, 0 },
-    { 80.9524, 0 },
-};
-
-static const StrokeRec char76[] = {
-   { 2, char76_stroke0 },
-   { 2, char76_stroke1 },
-};
-
-/* char: 77 'M' */
-
-static const CoordRec char77_stroke0[] = {
-    { 14.2857, 100 },
-    { 14.2857, 0 },
-};
-
-static const CoordRec char77_stroke1[] = {
-    { 14.2857, 100 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char77_stroke2[] = {
-    { 90.4762, 100 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char77_stroke3[] = {
-    { 90.4762, 100 },
-    { 90.4762, 0 },
-};
-
-static const StrokeRec char77[] = {
-   { 2, char77_stroke0 },
-   { 2, char77_stroke1 },
-   { 2, char77_stroke2 },
-   { 2, char77_stroke3 },
-};
-
-/* char: 78 'N' */
-
-static const CoordRec char78_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char78_stroke1[] = {
-    { 19.0476, 100 },
-    { 85.7143, 0 },
-};
-
-static const CoordRec char78_stroke2[] = {
-    { 85.7143, 100 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char78[] = {
-   { 2, char78_stroke0 },
-   { 2, char78_stroke1 },
-   { 2, char78_stroke2 },
-};
-
-/* char: 79 'O' */
-
-static const CoordRec char79_stroke0[] = {
-    { 42.8571, 100 },
-    { 33.3333, 95.2381 },
-    { 23.8095, 85.7143 },
-    { 19.0476, 76.1905 },
-    { 14.2857, 61.9048 },
-    { 14.2857, 38.0952 },
-    { 19.0476, 23.8095 },
-    { 23.8095, 14.2857 },
-    { 33.3333, 4.7619 },
-    { 42.8571, 0 },
-    { 61.9047, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 14.2857 },
-    { 85.7143, 23.8095 },
-    { 90.4762, 38.0952 },
-    { 90.4762, 61.9048 },
-    { 85.7143, 76.1905 },
-    { 80.9524, 85.7143 },
-    { 71.4286, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-};
-
-static const StrokeRec char79[] = {
-   { 21, char79_stroke0 },
-};
-
-/* char: 80 'P' */
-
-static const CoordRec char80_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char80_stroke1[] = {
-    { 19.0476, 100 },
-    { 61.9047, 100 },
-    { 76.1905, 95.2381 },
-    { 80.9524, 90.4762 },
-    { 85.7143, 80.9524 },
-    { 85.7143, 66.6667 },
-    { 80.9524, 57.1429 },
-    { 76.1905, 52.381 },
-    { 61.9047, 47.619 },
-    { 19.0476, 47.619 },
-};
-
-static const StrokeRec char80[] = {
-   { 2, char80_stroke0 },
-   { 10, char80_stroke1 },
-};
-
-/* char: 81 'Q' */
-
-static const CoordRec char81_stroke0[] = {
-    { 42.8571, 100 },
-    { 33.3333, 95.2381 },
-    { 23.8095, 85.7143 },
-    { 19.0476, 76.1905 },
-    { 14.2857, 61.9048 },
-    { 14.2857, 38.0952 },
-    { 19.0476, 23.8095 },
-    { 23.8095, 14.2857 },
-    { 33.3333, 4.7619 },
-    { 42.8571, 0 },
-    { 61.9047, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 14.2857 },
-    { 85.7143, 23.8095 },
-    { 90.4762, 38.0952 },
-    { 90.4762, 61.9048 },
-    { 85.7143, 76.1905 },
-    { 80.9524, 85.7143 },
-    { 71.4286, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-};
-
-static const CoordRec char81_stroke1[] = {
-    { 57.1428, 19.0476 },
-    { 85.7143, -9.5238 },
-};
-
-static const StrokeRec char81[] = {
-   { 21, char81_stroke0 },
-   { 2, char81_stroke1 },
-};
-
-/* char: 82 'R' */
-
-static const CoordRec char82_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char82_stroke1[] = {
-    { 19.0476, 100 },
-    { 61.9047, 100 },
-    { 76.1905, 95.2381 },
-    { 80.9524, 90.4762 },
-    { 85.7143, 80.9524 },
-    { 85.7143, 71.4286 },
-    { 80.9524, 61.9048 },
-    { 76.1905, 57.1429 },
-    { 61.9047, 52.381 },
-    { 19.0476, 52.381 },
-};
-
-static const CoordRec char82_stroke2[] = {
-    { 52.3809, 52.381 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char82[] = {
-   { 2, char82_stroke0 },
-   { 10, char82_stroke1 },
-   { 2, char82_stroke2 },
-};
-
-/* char: 83 'S' */
-
-static const CoordRec char83_stroke0[] = {
-    { 85.7143, 85.7143 },
-    { 76.1905, 95.2381 },
-    { 61.9047, 100 },
-    { 42.8571, 100 },
-    { 28.5714, 95.2381 },
-    { 19.0476, 85.7143 },
-    { 19.0476, 76.1905 },
-    { 23.8095, 66.6667 },
-    { 28.5714, 61.9048 },
-    { 38.0952, 57.1429 },
-    { 66.6666, 47.619 },
-    { 76.1905, 42.8571 },
-    { 80.9524, 38.0952 },
-    { 85.7143, 28.5714 },
-    { 85.7143, 14.2857 },
-    { 76.1905, 4.7619 },
-    { 61.9047, 0 },
-    { 42.8571, 0 },
-    { 28.5714, 4.7619 },
-    { 19.0476, 14.2857 },
-};
-
-static const StrokeRec char83[] = {
-   { 20, char83_stroke0 },
-};
-
-/* char: 84 'T' */
-
-static const CoordRec char84_stroke0[] = {
-    { 52.3809, 100 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char84_stroke1[] = {
-    { 19.0476, 100 },
-    { 85.7143, 100 },
-};
-
-static const StrokeRec char84[] = {
-   { 2, char84_stroke0 },
-   { 2, char84_stroke1 },
-};
-
-/* char: 85 'U' */
-
-static const CoordRec char85_stroke0[] = {
-    { 19.0476, 100 },
-    { 19.0476, 28.5714 },
-    { 23.8095, 14.2857 },
-    { 33.3333, 4.7619 },
-    { 47.619, 0 },
-    { 57.1428, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 14.2857 },
-    { 85.7143, 28.5714 },
-    { 85.7143, 100 },
-};
-
-static const StrokeRec char85[] = {
-   { 10, char85_stroke0 },
-};
-
-/* char: 86 'V' */
-
-static const CoordRec char86_stroke0[] = {
-    { 14.2857, 100 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char86_stroke1[] = {
-    { 90.4762, 100 },
-    { 52.3809, 0 },
-};
-
-static const StrokeRec char86[] = {
-   { 2, char86_stroke0 },
-   { 2, char86_stroke1 },
-};
-
-/* char: 87 'W' */
-
-static const CoordRec char87_stroke0[] = {
-    { 4.7619, 100 },
-    { 28.5714, 0 },
-};
-
-static const CoordRec char87_stroke1[] = {
-    { 52.3809, 100 },
-    { 28.5714, 0 },
-};
-
-static const CoordRec char87_stroke2[] = {
-    { 52.3809, 100 },
-    { 76.1905, 0 },
-};
-
-static const CoordRec char87_stroke3[] = {
-    { 100, 100 },
-    { 76.1905, 0 },
-};
-
-static const StrokeRec char87[] = {
-   { 2, char87_stroke0 },
-   { 2, char87_stroke1 },
-   { 2, char87_stroke2 },
-   { 2, char87_stroke3 },
-};
-
-/* char: 88 'X' */
-
-static const CoordRec char88_stroke0[] = {
-    { 19.0476, 100 },
-    { 85.7143, 0 },
-};
-
-static const CoordRec char88_stroke1[] = {
-    { 85.7143, 100 },
-    { 19.0476, 0 },
-};
-
-static const StrokeRec char88[] = {
-   { 2, char88_stroke0 },
-   { 2, char88_stroke1 },
-};
-
-/* char: 89 'Y' */
-
-static const CoordRec char89_stroke0[] = {
-    { 14.2857, 100 },
-    { 52.3809, 52.381 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char89_stroke1[] = {
-    { 90.4762, 100 },
-    { 52.3809, 52.381 },
-};
-
-static const StrokeRec char89[] = {
-   { 3, char89_stroke0 },
-   { 2, char89_stroke1 },
-};
-
-/* char: 90 'Z' */
-
-static const CoordRec char90_stroke0[] = {
-    { 85.7143, 100 },
-    { 19.0476, 0 },
-};
-
-static const CoordRec char90_stroke1[] = {
-    { 19.0476, 100 },
-    { 85.7143, 100 },
-};
-
-static const CoordRec char90_stroke2[] = {
-    { 19.0476, 0 },
-    { 85.7143, 0 },
-};
-
-static const StrokeRec char90[] = {
-   { 2, char90_stroke0 },
-   { 2, char90_stroke1 },
-   { 2, char90_stroke2 },
-};
-
-/* char: 91 '[' */
-
-static const CoordRec char91_stroke0[] = {
-    { 35.7143, 119.048 },
-    { 35.7143, -33.3333 },
-};
-
-static const CoordRec char91_stroke1[] = {
-    { 40.4762, 119.048 },
-    { 40.4762, -33.3333 },
-};
-
-static const CoordRec char91_stroke2[] = {
-    { 35.7143, 119.048 },
-    { 69.0476, 119.048 },
-};
-
-static const CoordRec char91_stroke3[] = {
-    { 35.7143, -33.3333 },
-    { 69.0476, -33.3333 },
-};
-
-static const StrokeRec char91[] = {
-   { 2, char91_stroke0 },
-   { 2, char91_stroke1 },
-   { 2, char91_stroke2 },
-   { 2, char91_stroke3 },
-};
-
-/* char: 92 '\' */
-
-static const CoordRec char92_stroke0[] = {
-    { 19.0476, 100 },
-    { 85.7143, -14.2857 },
-};
-
-static const StrokeRec char92[] = {
-   { 2, char92_stroke0 },
-};
-
-/* char: 93 ']' */
-
-static const CoordRec char93_stroke0[] = {
-    { 64.2857, 119.048 },
-    { 64.2857, -33.3333 },
-};
-
-static const CoordRec char93_stroke1[] = {
-    { 69.0476, 119.048 },
-    { 69.0476, -33.3333 },
-};
-
-static const CoordRec char93_stroke2[] = {
-    { 35.7143, 119.048 },
-    { 69.0476, 119.048 },
-};
-
-static const CoordRec char93_stroke3[] = {
-    { 35.7143, -33.3333 },
-    { 69.0476, -33.3333 },
-};
-
-static const StrokeRec char93[] = {
-   { 2, char93_stroke0 },
-   { 2, char93_stroke1 },
-   { 2, char93_stroke2 },
-   { 2, char93_stroke3 },
-};
-
-/* char: 94 '^' */
-
-static const CoordRec char94_stroke0[] = {
-    { 52.3809, 109.524 },
-    { 14.2857, 42.8571 },
-};
-
-static const CoordRec char94_stroke1[] = {
-    { 52.3809, 109.524 },
-    { 90.4762, 42.8571 },
-};
-
-static const StrokeRec char94[] = {
-   { 2, char94_stroke0 },
-   { 2, char94_stroke1 },
-};
-
-/* char: 95 '_' */
-
-static const CoordRec char95_stroke0[] = {
-    { 0, -33.3333 },
-    { 104.762, -33.3333 },
-    { 104.762, -28.5714 },
-    { 0, -28.5714 },
-    { 0, -33.3333 },
-};
-
-static const StrokeRec char95[] = {
-   { 5, char95_stroke0 },
-};
-
-/* char: 96 '`' */
-
-static const CoordRec char96_stroke0[] = {
-    { 42.8572, 100 },
-    { 66.6667, 71.4286 },
-};
-
-static const CoordRec char96_stroke1[] = {
-    { 42.8572, 100 },
-    { 38.0953, 95.2381 },
-    { 66.6667, 71.4286 },
-};
-
-static const StrokeRec char96[] = {
-   { 2, char96_stroke0 },
-   { 3, char96_stroke1 },
-};
-
-/* char: 97 'a' */
-
-static const CoordRec char97_stroke0[] = {
-    { 80.9524, 66.6667 },
-    { 80.9524, 0 },
-};
-
-static const CoordRec char97_stroke1[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char97[] = {
-   { 2, char97_stroke0 },
-   { 14, char97_stroke1 },
-};
-
-/* char: 98 'b' */
-
-static const CoordRec char98_stroke0[] = {
-    { 23.8095, 100 },
-    { 23.8095, 0 },
-};
-
-static const CoordRec char98_stroke1[] = {
-    { 23.8095, 52.381 },
-    { 33.3333, 61.9048 },
-    { 42.8571, 66.6667 },
-    { 57.1428, 66.6667 },
-    { 66.6666, 61.9048 },
-    { 76.1905, 52.381 },
-    { 80.9524, 38.0952 },
-    { 80.9524, 28.5714 },
-    { 76.1905, 14.2857 },
-    { 66.6666, 4.7619 },
-    { 57.1428, 0 },
-    { 42.8571, 0 },
-    { 33.3333, 4.7619 },
-    { 23.8095, 14.2857 },
-};
-
-static const StrokeRec char98[] = {
-   { 2, char98_stroke0 },
-   { 14, char98_stroke1 },
-};
-
-/* char: 99 'c' */
-
-static const CoordRec char99_stroke0[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char99[] = {
-   { 14, char99_stroke0 },
-};
-
-/* char: 100 'd' */
-
-static const CoordRec char100_stroke0[] = {
-    { 80.9524, 100 },
-    { 80.9524, 0 },
-};
-
-static const CoordRec char100_stroke1[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char100[] = {
-   { 2, char100_stroke0 },
-   { 14, char100_stroke1 },
-};
-
-/* char: 101 'e' */
-
-static const CoordRec char101_stroke0[] = {
-    { 23.8095, 38.0952 },
-    { 80.9524, 38.0952 },
-    { 80.9524, 47.619 },
-    { 76.1905, 57.1429 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char101[] = {
-   { 17, char101_stroke0 },
-};
-
-/* char: 102 'f' */
-
-static const CoordRec char102_stroke0[] = {
-    { 71.4286, 100 },
-    { 61.9048, 100 },
-    { 52.381, 95.2381 },
-    { 47.6191, 80.9524 },
-    { 47.6191, 0 },
-};
-
-static const CoordRec char102_stroke1[] = {
-    { 33.3334, 66.6667 },
-    { 66.6667, 66.6667 },
-};
-
-static const StrokeRec char102[] = {
-   { 5, char102_stroke0 },
-   { 2, char102_stroke1 },
-};
-
-/* char: 103 'g' */
-
-static const CoordRec char103_stroke0[] = {
-    { 80.9524, 66.6667 },
-    { 80.9524, -9.5238 },
-    { 76.1905, -23.8095 },
-    { 71.4285, -28.5714 },
-    { 61.9047, -33.3333 },
-    { 47.619, -33.3333 },
-    { 38.0952, -28.5714 },
-};
-
-static const CoordRec char103_stroke1[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char103[] = {
-   { 7, char103_stroke0 },
-   { 14, char103_stroke1 },
-};
-
-/* char: 104 'h' */
-
-static const CoordRec char104_stroke0[] = {
-    { 26.1905, 100 },
-    { 26.1905, 0 },
-};
-
-static const CoordRec char104_stroke1[] = {
-    { 26.1905, 47.619 },
-    { 40.4762, 61.9048 },
-    { 50, 66.6667 },
-    { 64.2857, 66.6667 },
-    { 73.8095, 61.9048 },
-    { 78.5715, 47.619 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char104[] = {
-   { 2, char104_stroke0 },
-   { 7, char104_stroke1 },
-};
-
-/* char: 105 'i' */
-
-static const CoordRec char105_stroke0[] = {
-    { 47.6191, 100 },
-    { 52.381, 95.2381 },
-    { 57.1429, 100 },
-    { 52.381, 104.762 },
-    { 47.6191, 100 },
-};
-
-static const CoordRec char105_stroke1[] = {
-    { 52.381, 66.6667 },
-    { 52.381, 0 },
-};
-
-static const StrokeRec char105[] = {
-   { 5, char105_stroke0 },
-   { 2, char105_stroke1 },
-};
-
-/* char: 106 'j' */
-
-static const CoordRec char106_stroke0[] = {
-    { 57.1429, 100 },
-    { 61.9048, 95.2381 },
-    { 66.6667, 100 },
-    { 61.9048, 104.762 },
-    { 57.1429, 100 },
-};
-
-static const CoordRec char106_stroke1[] = {
-    { 61.9048, 66.6667 },
-    { 61.9048, -14.2857 },
-    { 57.1429, -28.5714 },
-    { 47.6191, -33.3333 },
-    { 38.0953, -33.3333 },
-};
-
-static const StrokeRec char106[] = {
-   { 5, char106_stroke0 },
-   { 5, char106_stroke1 },
-};
-
-/* char: 107 'k' */
-
-static const CoordRec char107_stroke0[] = {
-    { 26.1905, 100 },
-    { 26.1905, 0 },
-};
-
-static const CoordRec char107_stroke1[] = {
-    { 73.8095, 66.6667 },
-    { 26.1905, 19.0476 },
-};
-
-static const CoordRec char107_stroke2[] = {
-    { 45.2381, 38.0952 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char107[] = {
-   { 2, char107_stroke0 },
-   { 2, char107_stroke1 },
-   { 2, char107_stroke2 },
-};
-
-/* char: 108 'l' */
-
-static const CoordRec char108_stroke0[] = {
-    { 52.381, 100 },
-    { 52.381, 0 },
-};
-
-static const StrokeRec char108[] = {
-   { 2, char108_stroke0 },
-};
-
-/* char: 109 'm' */
-
-static const CoordRec char109_stroke0[] = {
-    { 0, 66.6667 },
-    { 0, 0 },
-};
-
-static const CoordRec char109_stroke1[] = {
-    { 0, 47.619 },
-    { 14.2857, 61.9048 },
-    { 23.8095, 66.6667 },
-    { 38.0952, 66.6667 },
-    { 47.619, 61.9048 },
-    { 52.381, 47.619 },
-    { 52.381, 0 },
-};
-
-static const CoordRec char109_stroke2[] = {
-    { 52.381, 47.619 },
-    { 66.6667, 61.9048 },
-    { 76.1905, 66.6667 },
-    { 90.4762, 66.6667 },
-    { 100, 61.9048 },
-    { 104.762, 47.619 },
-    { 104.762, 0 },
-};
-
-static const StrokeRec char109[] = {
-   { 2, char109_stroke0 },
-   { 7, char109_stroke1 },
-   { 7, char109_stroke2 },
-};
-
-/* char: 110 'n' */
-
-static const CoordRec char110_stroke0[] = {
-    { 26.1905, 66.6667 },
-    { 26.1905, 0 },
-};
-
-static const CoordRec char110_stroke1[] = {
-    { 26.1905, 47.619 },
-    { 40.4762, 61.9048 },
-    { 50, 66.6667 },
-    { 64.2857, 66.6667 },
-    { 73.8095, 61.9048 },
-    { 78.5715, 47.619 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char110[] = {
-   { 2, char110_stroke0 },
-   { 7, char110_stroke1 },
-};
-
-/* char: 111 'o' */
-
-static const CoordRec char111_stroke0[] = {
-    { 45.2381, 66.6667 },
-    { 35.7143, 61.9048 },
-    { 26.1905, 52.381 },
-    { 21.4286, 38.0952 },
-    { 21.4286, 28.5714 },
-    { 26.1905, 14.2857 },
-    { 35.7143, 4.7619 },
-    { 45.2381, 0 },
-    { 59.5238, 0 },
-    { 69.0476, 4.7619 },
-    { 78.5714, 14.2857 },
-    { 83.3334, 28.5714 },
-    { 83.3334, 38.0952 },
-    { 78.5714, 52.381 },
-    { 69.0476, 61.9048 },
-    { 59.5238, 66.6667 },
-    { 45.2381, 66.6667 },
-};
-
-static const StrokeRec char111[] = {
-   { 17, char111_stroke0 },
-};
-
-/* char: 112 'p' */
-
-static const CoordRec char112_stroke0[] = {
-    { 23.8095, 66.6667 },
-    { 23.8095, -33.3333 },
-};
-
-static const CoordRec char112_stroke1[] = {
-    { 23.8095, 52.381 },
-    { 33.3333, 61.9048 },
-    { 42.8571, 66.6667 },
-    { 57.1428, 66.6667 },
-    { 66.6666, 61.9048 },
-    { 76.1905, 52.381 },
-    { 80.9524, 38.0952 },
-    { 80.9524, 28.5714 },
-    { 76.1905, 14.2857 },
-    { 66.6666, 4.7619 },
-    { 57.1428, 0 },
-    { 42.8571, 0 },
-    { 33.3333, 4.7619 },
-    { 23.8095, 14.2857 },
-};
-
-static const StrokeRec char112[] = {
-   { 2, char112_stroke0 },
-   { 14, char112_stroke1 },
-};
-
-/* char: 113 'q' */
-
-static const CoordRec char113_stroke0[] = {
-    { 80.9524, 66.6667 },
-    { 80.9524, -33.3333 },
-};
-
-static const CoordRec char113_stroke1[] = {
-    { 80.9524, 52.381 },
-    { 71.4285, 61.9048 },
-    { 61.9047, 66.6667 },
-    { 47.619, 66.6667 },
-    { 38.0952, 61.9048 },
-    { 28.5714, 52.381 },
-    { 23.8095, 38.0952 },
-    { 23.8095, 28.5714 },
-    { 28.5714, 14.2857 },
-    { 38.0952, 4.7619 },
-    { 47.619, 0 },
-    { 61.9047, 0 },
-    { 71.4285, 4.7619 },
-    { 80.9524, 14.2857 },
-};
-
-static const StrokeRec char113[] = {
-   { 2, char113_stroke0 },
-   { 14, char113_stroke1 },
-};
-
-/* char: 114 'r' */
-
-static const CoordRec char114_stroke0[] = {
-    { 33.3334, 66.6667 },
-    { 33.3334, 0 },
-};
-
-static const CoordRec char114_stroke1[] = {
-    { 33.3334, 38.0952 },
-    { 38.0953, 52.381 },
-    { 47.6191, 61.9048 },
-    { 57.1429, 66.6667 },
-    { 71.4286, 66.6667 },
-};
-
-static const StrokeRec char114[] = {
-   { 2, char114_stroke0 },
-   { 5, char114_stroke1 },
-};
-
-/* char: 115 's' */
-
-static const CoordRec char115_stroke0[] = {
-    { 78.5715, 52.381 },
-    { 73.8095, 61.9048 },
-    { 59.5238, 66.6667 },
-    { 45.2381, 66.6667 },
-    { 30.9524, 61.9048 },
-    { 26.1905, 52.381 },
-    { 30.9524, 42.8571 },
-    { 40.4762, 38.0952 },
-    { 64.2857, 33.3333 },
-    { 73.8095, 28.5714 },
-    { 78.5715, 19.0476 },
-    { 78.5715, 14.2857 },
-    { 73.8095, 4.7619 },
-    { 59.5238, 0 },
-    { 45.2381, 0 },
-    { 30.9524, 4.7619 },
-    { 26.1905, 14.2857 },
-};
-
-static const StrokeRec char115[] = {
-   { 17, char115_stroke0 },
-};
-
-/* char: 116 't' */
-
-static const CoordRec char116_stroke0[] = {
-    { 47.6191, 100 },
-    { 47.6191, 19.0476 },
-    { 52.381, 4.7619 },
-    { 61.9048, 0 },
-    { 71.4286, 0 },
-};
-
-static const CoordRec char116_stroke1[] = {
-    { 33.3334, 66.6667 },
-    { 66.6667, 66.6667 },
-};
-
-static const StrokeRec char116[] = {
-   { 5, char116_stroke0 },
-   { 2, char116_stroke1 },
-};
-
-/* char: 117 'u' */
-
-static const CoordRec char117_stroke0[] = {
-    { 26.1905, 66.6667 },
-    { 26.1905, 19.0476 },
-    { 30.9524, 4.7619 },
-    { 40.4762, 0 },
-    { 54.7619, 0 },
-    { 64.2857, 4.7619 },
-    { 78.5715, 19.0476 },
-};
-
-static const CoordRec char117_stroke1[] = {
-    { 78.5715, 66.6667 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char117[] = {
-   { 7, char117_stroke0 },
-   { 2, char117_stroke1 },
-};
-
-/* char: 118 'v' */
-
-static const CoordRec char118_stroke0[] = {
-    { 23.8095, 66.6667 },
-    { 52.3809, 0 },
-};
-
-static const CoordRec char118_stroke1[] = {
-    { 80.9524, 66.6667 },
-    { 52.3809, 0 },
-};
-
-static const StrokeRec char118[] = {
-   { 2, char118_stroke0 },
-   { 2, char118_stroke1 },
-};
-
-/* char: 119 'w' */
-
-static const CoordRec char119_stroke0[] = {
-    { 14.2857, 66.6667 },
-    { 33.3333, 0 },
-};
-
-static const CoordRec char119_stroke1[] = {
-    { 52.3809, 66.6667 },
-    { 33.3333, 0 },
-};
-
-static const CoordRec char119_stroke2[] = {
-    { 52.3809, 66.6667 },
-    { 71.4286, 0 },
-};
-
-static const CoordRec char119_stroke3[] = {
-    { 90.4762, 66.6667 },
-    { 71.4286, 0 },
-};
-
-static const StrokeRec char119[] = {
-   { 2, char119_stroke0 },
-   { 2, char119_stroke1 },
-   { 2, char119_stroke2 },
-   { 2, char119_stroke3 },
-};
-
-/* char: 120 'x' */
-
-static const CoordRec char120_stroke0[] = {
-    { 26.1905, 66.6667 },
-    { 78.5715, 0 },
-};
-
-static const CoordRec char120_stroke1[] = {
-    { 78.5715, 66.6667 },
-    { 26.1905, 0 },
-};
-
-static const StrokeRec char120[] = {
-   { 2, char120_stroke0 },
-   { 2, char120_stroke1 },
-};
-
-/* char: 121 'y' */
-
-static const CoordRec char121_stroke0[] = {
-    { 26.1905, 66.6667 },
-    { 54.7619, 0 },
-};
-
-static const CoordRec char121_stroke1[] = {
-    { 83.3334, 66.6667 },
-    { 54.7619, 0 },
-    { 45.2381, -19.0476 },
-    { 35.7143, -28.5714 },
-    { 26.1905, -33.3333 },
-    { 21.4286, -33.3333 },
-};
-
-static const StrokeRec char121[] = {
-   { 2, char121_stroke0 },
-   { 6, char121_stroke1 },
-};
-
-/* char: 122 'z' */
-
-static const CoordRec char122_stroke0[] = {
-    { 78.5715, 66.6667 },
-    { 26.1905, 0 },
-};
-
-static const CoordRec char122_stroke1[] = {
-    { 26.1905, 66.6667 },
-    { 78.5715, 66.6667 },
-};
-
-static const CoordRec char122_stroke2[] = {
-    { 26.1905, 0 },
-    { 78.5715, 0 },
-};
-
-static const StrokeRec char122[] = {
-   { 2, char122_stroke0 },
-   { 2, char122_stroke1 },
-   { 2, char122_stroke2 },
-};
-
-/* char: 123 '{' */
-
-static const CoordRec char123_stroke0[] = {
-    { 64.2857, 119.048 },
-    { 54.7619, 114.286 },
-    { 50, 109.524 },
-    { 45.2381, 100 },
-    { 45.2381, 90.4762 },
-    { 50, 80.9524 },
-    { 54.7619, 76.1905 },
-    { 59.5238, 66.6667 },
-    { 59.5238, 57.1429 },
-    { 50, 47.619 },
-};
-
-static const CoordRec char123_stroke1[] = {
-    { 54.7619, 114.286 },
-    { 50, 104.762 },
-    { 50, 95.2381 },
-    { 54.7619, 85.7143 },
-    { 59.5238, 80.9524 },
-    { 64.2857, 71.4286 },
-    { 64.2857, 61.9048 },
-    { 59.5238, 52.381 },
-    { 40.4762, 42.8571 },
-    { 59.5238, 33.3333 },
-    { 64.2857, 23.8095 },
-    { 64.2857, 14.2857 },
-    { 59.5238, 4.7619 },
-    { 54.7619, 0 },
-    { 50, -9.5238 },
-    { 50, -19.0476 },
-    { 54.7619, -28.5714 },
-};
-
-static const CoordRec char123_stroke2[] = {
-    { 50, 38.0952 },
-    { 59.5238, 28.5714 },
-    { 59.5238, 19.0476 },
-    { 54.7619, 9.5238 },
-    { 50, 4.7619 },
-    { 45.2381, -4.7619 },
-    { 45.2381, -14.2857 },
-    { 50, -23.8095 },
-    { 54.7619, -28.5714 },
-    { 64.2857, -33.3333 },
-};
-
-static const StrokeRec char123[] = {
-   { 10, char123_stroke0 },
-   { 17, char123_stroke1 },
-   { 10, char123_stroke2 },
-};
-
-/* char: 124 '|' */
-
-static const CoordRec char124_stroke0[] = {
-    { 52.381, 119.048 },
-    { 52.381, -33.3333 },
-};
-
-static const StrokeRec char124[] = {
-   { 2, char124_stroke0 },
-};
-
-/* char: 125 '}' */
-
-static const CoordRec char125_stroke0[] = {
-    { 40.4762, 119.048 },
-    { 50, 114.286 },
-    { 54.7619, 109.524 },
-    { 59.5238, 100 },
-    { 59.5238, 90.4762 },
-    { 54.7619, 80.9524 },
-    { 50, 76.1905 },
-    { 45.2381, 66.6667 },
-    { 45.2381, 57.1429 },
-    { 54.7619, 47.619 },
-};
-
-static const CoordRec char125_stroke1[] = {
-    { 50, 114.286 },
-    { 54.7619, 104.762 },
-    { 54.7619, 95.2381 },
-    { 50, 85.7143 },
-    { 45.2381, 80.9524 },
-    { 40.4762, 71.4286 },
-    { 40.4762, 61.9048 },
-    { 45.2381, 52.381 },
-    { 64.2857, 42.8571 },
-    { 45.2381, 33.3333 },
-    { 40.4762, 23.8095 },
-    { 40.4762, 14.2857 },
-    { 45.2381, 4.7619 },
-    { 50, 0 },
-    { 54.7619, -9.5238 },
-    { 54.7619, -19.0476 },
-    { 50, -28.5714 },
-};
-
-static const CoordRec char125_stroke2[] = {
-    { 54.7619, 38.0952 },
-    { 45.2381, 28.5714 },
-    { 45.2381, 19.0476 },
-    { 50, 9.5238 },
-    { 54.7619, 4.7619 },
-    { 59.5238, -4.7619 },
-    { 59.5238, -14.2857 },
-    { 54.7619, -23.8095 },
-    { 50, -28.5714 },
-    { 40.4762, -33.3333 },
-};
-
-static const StrokeRec char125[] = {
-   { 10, char125_stroke0 },
-   { 17, char125_stroke1 },
-   { 10, char125_stroke2 },
-};
-
-/* char: 126 '~' */
-
-static const CoordRec char126_stroke0[] = {
-    { 9.5238, 28.5714 },
-    { 9.5238, 38.0952 },
-    { 14.2857, 52.381 },
-    { 23.8095, 57.1429 },
-    { 33.3333, 57.1429 },
-    { 42.8571, 52.381 },
-    { 61.9048, 38.0952 },
-    { 71.4286, 33.3333 },
-    { 80.9524, 33.3333 },
-    { 90.4762, 38.0952 },
-    { 95.2381, 47.619 },
-};
-
-static const CoordRec char126_stroke1[] = {
-    { 9.5238, 38.0952 },
-    { 14.2857, 47.619 },
-    { 23.8095, 52.381 },
-    { 33.3333, 52.381 },
-    { 42.8571, 47.619 },
-    { 61.9048, 33.3333 },
-    { 71.4286, 28.5714 },
-    { 80.9524, 28.5714 },
-    { 90.4762, 33.3333 },
-    { 95.2381, 47.619 },
-    { 95.2381, 57.1429 },
-};
-
-static const StrokeRec char126[] = {
-   { 11, char126_stroke0 },
-   { 11, char126_stroke1 },
-};
-
-/* char: 127 */
-
-static const CoordRec char127_stroke0[] = {
-    { 71.4286, 100 },
-    { 33.3333, -33.3333 },
-};
-
-static const CoordRec char127_stroke1[] = {
-    { 47.619, 66.6667 },
-    { 33.3333, 61.9048 },
-    { 23.8095, 52.381 },
-    { 19.0476, 38.0952 },
-    { 19.0476, 23.8095 },
-    { 23.8095, 14.2857 },
-    { 33.3333, 4.7619 },
-    { 47.619, 0 },
-    { 57.1428, 0 },
-    { 71.4286, 4.7619 },
-    { 80.9524, 14.2857 },
-    { 85.7143, 28.5714 },
-    { 85.7143, 42.8571 },
-    { 80.9524, 52.381 },
-    { 71.4286, 61.9048 },
-    { 57.1428, 66.6667 },
-    { 47.619, 66.6667 },
-};
-
-static const StrokeRec char127[] = {
-   { 2, char127_stroke0 },
-   { 17, char127_stroke1 },
-};
-
-static const StrokeCharRec chars[] = {
-    { 0, /* char0 */ 0, 0, 0 },
-    { 0, /* char1 */ 0, 0, 0 },
-    { 0, /* char2 */ 0, 0, 0 },
-    { 0, /* char3 */ 0, 0, 0 },
-    { 0, /* char4 */ 0, 0, 0 },
-    { 0, /* char5 */ 0, 0, 0 },
-    { 0, /* char6 */ 0, 0, 0 },
-    { 0, /* char7 */ 0, 0, 0 },
-    { 0, /* char8 */ 0, 0, 0 },
-    { 0, /* char9 */ 0, 0, 0 },
-    { 0, /* char10 */ 0, 0, 0 },
-    { 0, /* char11 */ 0, 0, 0 },
-    { 0, /* char12 */ 0, 0, 0 },
-    { 0, /* char13 */ 0, 0, 0 },
-    { 0, /* char14 */ 0, 0, 0 },
-    { 0, /* char15 */ 0, 0, 0 },
-    { 0, /* char16 */ 0, 0, 0 },
-    { 0, /* char17 */ 0, 0, 0 },
-    { 0, /* char18 */ 0, 0, 0 },
-    { 0, /* char19 */ 0, 0, 0 },
-    { 0, /* char20 */ 0, 0, 0 },
-    { 0, /* char21 */ 0, 0, 0 },
-    { 0, /* char22 */ 0, 0, 0 },
-    { 0, /* char23 */ 0, 0, 0 },
-    { 0, /* char24 */ 0, 0, 0 },
-    { 0, /* char25 */ 0, 0, 0 },
-    { 0, /* char26 */ 0, 0, 0 },
-    { 0, /* char27 */ 0, 0, 0 },
-    { 0, /* char28 */ 0, 0, 0 },
-    { 0, /* char29 */ 0, 0, 0 },
-    { 0, /* char30 */ 0, 0, 0 },
-    { 0, /* char31 */ 0, 0, 0 },
-    { 0, /* char32 */ 0, 52.381, 104.762 },
-    { 2, char33, 52.381, 104.762 },
-    { 2, char34, 52.381, 104.762 },
-    { 4, char35, 52.381, 104.762 },
-    { 3, char36, 52.381, 104.762 },
-    { 3, char37, 52.381, 104.762 },
-    { 1, char38, 52.381, 104.762 },
-    { 1, char39, 52.381, 104.762 },
-    { 1, char40, 52.381, 104.762 },
-    { 1, char41, 52.381, 104.762 },
-    { 3, char42, 52.381, 104.762 },
-    { 2, char43, 52.381, 104.762 },
-    { 1, char44, 52.381, 104.762 },
-    { 1, char45, 52.381, 104.762 },
-    { 1, char46, 52.381, 104.762 },
-    { 1, char47, 52.381, 104.762 },
-    { 1, char48, 52.381, 104.762 },
-    { 1, char49, 52.381, 104.762 },
-    { 1, char50, 52.381, 104.762 },
-    { 1, char51, 52.381, 104.762 },
-    { 2, char52, 52.381, 104.762 },
-    { 1, char53, 52.381, 104.762 },
-    { 1, char54, 52.381, 104.762 },
-    { 2, char55, 52.381, 104.762 },
-    { 1, char56, 52.381, 104.762 },
-    { 1, char57, 52.381, 104.762 },
-    { 2, char58, 52.381, 104.762 },
-    { 2, char59, 52.381, 104.762 },
-    { 1, char60, 52.381, 104.762 },
-    { 2, char61, 52.381, 104.762 },
-    { 1, char62, 52.381, 104.762 },
-    { 2, char63, 52.381, 104.762 },
-    { 2, char64, 52.381, 104.762 },
-    { 3, char65, 52.381, 104.762 },
-    { 3, char66, 52.381, 104.762 },
-    { 1, char67, 52.381, 104.762 },
-    { 2, char68, 52.381, 104.762 },
-    { 4, char69, 52.381, 104.762 },
-    { 3, char70, 52.381, 104.762 },
-    { 2, char71, 52.381, 104.762 },
-    { 3, char72, 52.381, 104.762 },
-    { 1, char73, 52.381, 104.762 },
-    { 1, char74, 52.381, 104.762 },
-    { 3, char75, 52.381, 104.762 },
-    { 2, char76, 52.381, 104.762 },
-    { 4, char77, 52.381, 104.762 },
-    { 3, char78, 52.381, 104.762 },
-    { 1, char79, 52.381, 104.762 },
-    { 2, char80, 52.381, 104.762 },
-    { 2, char81, 52.381, 104.762 },
-    { 3, char82, 52.381, 104.762 },
-    { 1, char83, 52.381, 104.762 },
-    { 2, char84, 52.381, 104.762 },
-    { 1, char85, 52.381, 104.762 },
-    { 2, char86, 52.381, 104.762 },
-    { 4, char87, 52.381, 104.762 },
-    { 2, char88, 52.381, 104.762 },
-    { 2, char89, 52.381, 104.762 },
-    { 3, char90, 52.381, 104.762 },
-    { 4, char91, 52.381, 104.762 },
-    { 1, char92, 52.381, 104.762 },
-    { 4, char93, 52.381, 104.762 },
-    { 2, char94, 52.381, 104.762 },
-    { 1, char95, 52.381, 104.762 },
-    { 2, char96, 52.381, 104.762 },
-    { 2, char97, 52.381, 104.762 },
-    { 2, char98, 52.381, 104.762 },
-    { 1, char99, 52.381, 104.762 },
-    { 2, char100, 52.381, 104.762 },
-    { 1, char101, 52.381, 104.762 },
-    { 2, char102, 52.381, 104.762 },
-    { 2, char103, 52.381, 104.762 },
-    { 2, char104, 52.381, 104.762 },
-    { 2, char105, 52.381, 104.762 },
-    { 2, char106, 52.381, 104.762 },
-    { 3, char107, 52.381, 104.762 },
-    { 1, char108, 52.381, 104.762 },
-    { 3, char109, 52.381, 104.762 },
-    { 2, char110, 52.381, 104.762 },
-    { 1, char111, 52.381, 104.762 },
-    { 2, char112, 52.381, 104.762 },
-    { 2, char113, 52.381, 104.762 },
-    { 2, char114, 52.381, 104.762 },
-    { 1, char115, 52.381, 104.762 },
-    { 2, char116, 52.381, 104.762 },
-    { 2, char117, 52.381, 104.762 },
-    { 2, char118, 52.381, 104.762 },
-    { 4, char119, 52.381, 104.762 },
-    { 2, char120, 52.381, 104.762 },
-    { 2, char121, 52.381, 104.762 },
-    { 3, char122, 52.381, 104.762 },
-    { 3, char123, 52.381, 104.762 },
-    { 1, char124, 52.381, 104.762 },
-    { 3, char125, 52.381, 104.762 },
-    { 2, char126, 52.381, 104.762 },
-    { 2, char127, 52.381, 104.762 },
-};
-
-GLUTAPI const StrokeFontRec glutStrokeMonoRoman;
-const StrokeFontRec glutStrokeMonoRoman = { "Roman", 128, chars, 119.048, -33.3333 };
-
diff --git a/src/glut/glx/glut_overlay.c b/src/glut/glx/glut_overlay.c
deleted file mode 100644 (file)
index ce8e68d..0000000
+++ /dev/null
@@ -1,608 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1996, 1997.  */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#if !defined(_WIN32)
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#if defined (__vms)
-#include <Xmu/StdCmap.h>  /* for XmuLookupStandardColormap */
-#else
-#include <X11/Xmu/StdCmap.h>  /* for XmuLookupStandardColormap */
-#endif
-#endif /* !_WIN32 */
-
-#include "glutint.h"
-#include "layerutil.h"
-
-static Criterion requiredOverlayCriteria[] =
-{
-  {LEVEL, EQ, 1},       /* This entry gets poked in
-                           determineOverlayVisual. */
-  {TRANSPARENT, EQ, 1},
-  {XPSEUDOCOLOR, EQ, 1},
-  {RGBA, EQ, 0},
-  {BUFFER_SIZE, GTE, 1}
-};
-static int numRequiredOverlayCriteria = sizeof(requiredOverlayCriteria) / sizeof(Criterion);
-static int requiredOverlayCriteriaMask =
-(1 << LEVEL) | (1 << TRANSPARENT) | (1 << XSTATICGRAY) | (1 << RGBA) | (1 << CI_MODE);
-
-#if !defined(_WIN32)
-static int
-checkOverlayAcceptability(XVisualInfo * vi, unsigned int mode)
-{
-  int value;
-
-  /* Must support OpenGL. */
-  glXGetConfig(__glutDisplay, vi, GLX_USE_GL, &value);
-  if (!value)
-    return 1;
-
-  /* Must be color index. */
-  glXGetConfig(__glutDisplay, vi, GLX_RGBA, &value);
-  if (value)
-    return 1;
-
-  /* Must match single/double buffering request. */
-  glXGetConfig(__glutDisplay, vi, GLX_DOUBLEBUFFER, &value);
-  if (GLUT_WIND_IS_DOUBLE(mode) != (value != 0))
-    return 1;
-
-  /* Must match mono/stereo request. */
-  glXGetConfig(__glutDisplay, vi, GLX_STEREO, &value);
-  if (GLUT_WIND_IS_STEREO(mode) != (value != 0))
-    return 1;
-
-  /* Alpha and accumulation buffers incompatible with color
-     index. */
-  if (GLUT_WIND_HAS_ALPHA(mode) || GLUT_WIND_HAS_ACCUM(mode))
-    return 1;
-
-  /* Look for depth buffer if requested. */
-  glXGetConfig(__glutDisplay, vi, GLX_DEPTH_SIZE, &value);
-  if (GLUT_WIND_HAS_DEPTH(mode) && (value <= 0))
-    return 1;
-
-  /* Look for stencil buffer if requested. */
-  glXGetConfig(__glutDisplay, vi, GLX_STENCIL_SIZE, &value);
-  if (GLUT_WIND_HAS_STENCIL(mode) && (value <= 0))
-    return 1;
-
-#if defined(GLX_VERSION_1_1) && (defined(GLX_SGIS_multisample) || defined(GLX_ARB_multisample))
-  /* XXX Multisampled overlay color index??  Pretty unlikely. */
-  /* Look for multisampling if requested. */
-  if (__glutIsSupportedByGLX("GLX_SGIS_multisample") ||
-      __glutIsSupportedByGLX("GLX_ARB_multisample"))
-    glXGetConfig(__glutDisplay, vi, GLX_SAMPLES_SGIS, &value);
-  else
-    value = 0;
-  if (GLUT_WIND_IS_MULTISAMPLE(mode) && (value <= 0))
-    return 1;
-#endif
-
-  return 0;
-}
-#endif
-
-static XVisualInfo *
-getOverlayVisualInfoCI(unsigned int mode)
-{
-#if !defined(_WIN32)
-  XLayerVisualInfo *vi;
-  XLayerVisualInfo template;
-  XVisualInfo *goodVisual, *returnVisual;
-  int nitems, i, j, bad;
-
-  /* The GLX 1.0 glXChooseVisual is does not permit queries
-     based on pixel transparency (and GLX_BUFFER_SIZE uses
-     "smallest that meets" its requirement instead of "largest
-     that meets" that GLUT wants. So, GLUT implements its own
-     visual selection routine for color index overlays. */
-
-  /* Try three overlay layers. */
-  for (i = 1; i <= 3; i++) {
-    template.vinfo.screen = __glutScreen;
-    template.vinfo.class = PseudoColor;
-    template.layer = i;
-    template.type = TransparentPixel;
-    vi = __glutXGetLayerVisualInfo(__glutDisplay,
-      VisualTransparentType | VisualScreenMask | VisualClassMask | VisualLayerMask,
-      &template, &nitems);
-    if (vi) {
-      /* Check list for acceptable visual meeting requirements
-         of requested display mode. */
-      for (j = 0; j < nitems; j++) {
-        bad = checkOverlayAcceptability(&vi[j].vinfo, mode);
-        if (bad) {
-          /* Set vi[j].vinfo.visual to mark it unacceptable. */
-          vi[j].vinfo.visual = NULL;
-        }
-      }
-
-      /* Look through list to find deepest acceptable visual. */
-      goodVisual = NULL;
-      for (j = 0; j < nitems; j++) {
-        if (vi[j].vinfo.visual) {
-          if (goodVisual == NULL) {
-            goodVisual = &vi[j].vinfo;
-          } else {
-            if (goodVisual->depth < vi[j].vinfo.depth) {
-              goodVisual = &vi[j].vinfo;
-            }
-          }
-        }
-      }
-
-      /* If a visual is found, clean up and return the visual. */
-      if (goodVisual) {
-        returnVisual = (XVisualInfo *) malloc(sizeof(XVisualInfo));
-        if (returnVisual) {
-          *returnVisual = *goodVisual;
-        }
-        XFree(vi);
-        return returnVisual;
-      }
-      XFree(vi);
-    }
-  }
-#endif /* !_WIN32 */
-  return NULL;
-}
-
-/* ARGSUSED */
-static XVisualInfo *
-getOverlayVisualInfoRGB(unsigned int mode)
-{
-
-  /* XXX For now, transparent RGBA overlays are not supported
-     by GLUT.  RGBA overlays raise difficult questions about
-     what the transparent pixel (really color) value should be.
-
-     Color index overlay transparency is "easy" because the
-     transparent pixel value does not affect displayable colors
-     (except for stealing one color cell) since colors are
-     determined by indirection through a colormap, and because
-     it is uncommon for arbitrary pixel values in color index to
-     be "calculated" (as can occur with a host of RGBA operations
-     like lighting, blending, etc) so it is easy to avoid the
-     transparent pixel value.
-
-     Since it is typically easy to avoid the transparent pixel
-     value in color index mode, if GLUT tells the programmer what
-     pixel is transparent, then most program can easily avoid
-     generating that pixel value except when they intend
-     transparency.  GLUT returns whatever transparent pixel value
-     is provided by the system through glutGet(
-     GLUT_TRANSPARENT_INDEX).
-
-     Theory versus practice for RGBA overlay transparency: In
-     theory, the reasonable thing is enabling overlay transparency
-     when an overlay pixel's destination alpha is 0 because this
-     allows overlay transparency to be controlled via alpha and all
-     visibile colors are permited, but no hardware I am aware of
-     supports this practice (and it requires destination alpha which
-     is typically optional and quite uncommon for overlay windows!). 
-
-     In practice, the choice of  transparent pixel value is typically
-     "hardwired" into most graphics hardware to a single pixel value.
-     SGI hardware uses true black (0,0,0) without regard for the
-     destination alpha.  This is far from ideal because true black (a
-     common color that is easy to accidently generate) can not be
-     generated in an RGBA overlay. I am not sure what other vendors
-     do.
-
-     Pragmatically, most of the typical things you want to do in the
-     overlays can be done in color index (rubber banding, pop-up
-     menus, etc.).  One solution for GLUT would be to simply
-     "advertise" what RGB triple (or possibly RGBA quadruple or simply 
-     A alone) generates transparency.  The problem with this approach
-     is that it forces programmers to avoid whatever arbitrary color
-     various systems decide is transparent.  This is a difficult
-     burden to place on programmers that want to portably make use of
-     overlays.
-
-     To actually support transparent RGBA overlays, there are really
-     two reaonsable options.  ONE: Simply mandate that true black is
-     the RGBA overlay transparent color (what IRIS GL did).  This is
-     nice for programmers since only one option, nice for existing SGI 
-     hardware, bad for anyone (including SGI) who wants to improve
-     upon "true black" RGB transparency. 
-
-     Or TWO: Provide a set of queriable "transparency types" (like
-     "true black" or "alpha == 0" or "true white" or even a queriable
-     transparent color).  This is harder for programmers, OK for
-     existing SGI hardware, and it leaves open the issue of what other 
-     modes are reasonable.
-
-     Option TWO seems the more general approach, but since hardware
-     designers will likely only implement a single mode (this is a
-     scan out issue where bandwidth is pressing issue), codifying
-     multiple speculative approaches nobody may ever implement seems
-     silly.  And option ONE fiats a suboptimal solution.
-
-     Therefore, I defer any decision of how GLUT should support RGBA
-     overlay transparency and leave support for it unimplemented.
-     Nobody has been pressing me for RGBA overlay transparency (though 
-     people have requested color index overlay transparency
-     repeatedly).  Geez, if you read this far you are either really
-     bored or maybe actually  interested in this topic.  Anyway, if
-     you have ideas (particularly if you plan on implementing a
-     hardware scheme for RGBA overlay transparency), I'd be
-     interested.
-
-     For the record, SGI's expiremental Framebufer Configuration
-     experimental GLX extension uses option TWO.  Transparency modes
-     for "none" and "RGB" are defined (others could be defined later). 
-     What RGB value is the transparent one must be queried. 
-
-     I was hoping GLUT could have something that required less work
-     from the programmer to use portably. -mjk */
-
-  __glutWarning("RGBA overlays are not supported by GLUT (for now).");
-  return NULL;
-}
-
-static XVisualInfo *
-getOverlayVisualInfo(unsigned int mode)
-{
-  /* XXX GLUT_LUMINANCE not implemented for GLUT 3.0. */
-  if (GLUT_WIND_IS_LUMINANCE(mode))
-    return NULL;
-
-  if (GLUT_WIND_IS_RGB(mode))
-    return getOverlayVisualInfoRGB(mode);
-  else
-    return getOverlayVisualInfoCI(mode);
-}
-
-#if !defined(_WIN32)
-
-/* The GLUT overlay can come and go, and the overlay window has
-   a distinct X window ID.  Logically though, GLUT treats the
-   normal and overlay windows as a unified window.  In
-   particular, X input events typically go to the overlay window 
-   since it is "on top of" the normal window.  When an overlay
-   window ID is destroyed (due to glutRemoveOverlay or a call to 
-   glutEstablishOverlay when an overlay already exists), we
-   still keep track of the overlay window ID until we get back a 
-   DestroyNotify event for the overlay window. Otherwise, we
-   could lose track of X input events sent to a destroyed
-   overlay.  To avoid this, we keep the destroyed overlay window 
-   ID on a "stale window" list.  This lets us properly route X
-   input events generated on destroyed overlay windows to the
-   proper GLUT window. */
-static void
-addStaleWindow(GLUTwindow * window, Window win)
-{
-  GLUTstale *entry;
-
-  entry = (GLUTstale *) malloc(sizeof(GLUTstale));
-  if (!entry)
-    __glutFatalError("out of memory");
-  entry->window = window;
-  entry->win = win;
-  entry->next = __glutStaleWindowList;
-  __glutStaleWindowList = entry;
-}
-
-#endif
-
-void
-__glutFreeOverlay(GLUToverlay * overlay)
-{
-  if (overlay->visAlloced)
-    XFree(overlay->vis);
-  XDestroyWindow(__glutDisplay, overlay->win);
-  glXDestroyContext(__glutDisplay, overlay->ctx);
-  if (overlay->colormap) {
-    /* Only color index overlays have colormap data structure. */
-    __glutFreeColormap(overlay->colormap);
-  }
-  free(overlay);
-}
-
-static XVisualInfo *
-determineOverlayVisual(int *treatAsSingle, Bool * visAlloced, void **fbc)
-{
-  if (__glutDisplayString) {
-    XVisualInfo *vi;
-    int i;
-
-    /* __glutDisplayString should be NULL except if
-       glutInitDisplayString has been called to register a
-       different display string.  Calling glutInitDisplayString
-       means using a string instead of an integer mask determine 
-
-       the visual to use. Using the function pointer variable
-       __glutDetermineVisualFromString below avoids linking in
-       the code for implementing glutInitDisplayString (ie,
-       glut_dstr.o) unless glutInitDisplayString gets called by
-       the application. */
-
-    assert(__glutDetermineVisualFromString);
-
-    /* Try three overlay layers. */
-    *visAlloced = False;
-    *fbc = NULL;
-    for (i = 1; i <= 3; i++) {
-      requiredOverlayCriteria[0].value = i;
-      vi = __glutDetermineVisualFromString(__glutDisplayString, treatAsSingle,
-        requiredOverlayCriteria, numRequiredOverlayCriteria,
-        requiredOverlayCriteriaMask, fbc);
-      if (vi) {
-        return vi;
-      }
-    }
-    return NULL;
-  } else {
-    *visAlloced = True;
-    *fbc = NULL;
-    return __glutDetermineVisual(__glutDisplayMode,
-      treatAsSingle, getOverlayVisualInfo);
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutEstablishOverlay(void)
-{
-  GLUToverlay *overlay;
-  GLUTwindow *window;
-  XSetWindowAttributes wa;
-  void *fbc;
-
-  /* Register a routine to free an overlay with glut_win.c;
-     this keeps glut_win.c from pulling in all of
-     glut_overlay.c when no overlay functionality is used by
-     the application. */
-  __glutFreeOverlayFunc = __glutFreeOverlay;
-
-  window = __glutCurrentWindow;
-
-  /* Allow for an existant overlay to be re-established perhaps
-     if you wanted a different display mode. */
-  if (window->overlay) {
-#if !defined(_WIN32)
-    addStaleWindow(window, window->overlay->win);
-#endif
-    __glutFreeOverlay(window->overlay);
-  }
-  overlay = (GLUToverlay *) malloc(sizeof(GLUToverlay));
-  if (!overlay)
-    __glutFatalError("out of memory.");
-
-  overlay->vis = determineOverlayVisual(&overlay->treatAsSingle,
-    &overlay->visAlloced, &fbc);
-  if (!overlay->vis) {
-    __glutFatalError("lacks overlay support.");
-  }
-  overlay->ctx = NULL;
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-  if (fbc) {
-    window->ctx = __glut_glXCreateContextWithConfigSGIX(__glutDisplay, fbc,
-      GLX_RGBA_TYPE_SGIX, None, __glutTryDirect);
-  } else
-#endif
-  {
-    overlay->ctx = glXCreateContext(__glutDisplay, overlay->vis,
-      None, __glutTryDirect);
-  }
-  if (!overlay->ctx) {
-    __glutFatalError(
-      "failed to create overlay OpenGL rendering context.");
-  }
-#if !defined(_WIN32)
-  overlay->isDirect = glXIsDirect(__glutDisplay, overlay->ctx);
-  if (__glutForceDirect) {
-    if (!overlay->isDirect) {
-      __glutFatalError("direct rendering not possible.");
-    }
-  }
-#endif
-  __glutSetupColormap(overlay->vis, &overlay->colormap, &overlay->cmap);
-  overlay->transparentPixel = __glutGetTransparentPixel(__glutDisplay,
-    overlay->vis);
-  wa.colormap = overlay->cmap;
-  wa.background_pixel = overlay->transparentPixel;
-  wa.event_mask = window->eventMask & GLUT_OVERLAY_EVENT_FILTER_MASK;
-  wa.border_pixel = 0;
-#if defined(_WIN32)
-  /* XXX Overlays not supported in Win32 yet. */
-#else
-  overlay->win = XCreateWindow(__glutDisplay,
-    window->win,
-    0, 0, window->width, window->height, 0,
-    overlay->vis->depth, InputOutput, overlay->vis->visual,
-    CWBackPixel | CWBorderPixel | CWEventMask | CWColormap,
-    &wa);
-#endif
-  if (window->children) {
-    /* Overlay window must be lowered below any GLUT
-       subwindows. */
-    XLowerWindow(__glutDisplay, overlay->win);
-  }
-  XMapWindow(__glutDisplay, overlay->win);
-  overlay->shownState = 1;
-
-  overlay->display = NULL;
-
-  /* Make sure a reshape gets delivered. */
-  window->forceReshape = True;
-
-#if !defined(_WIN32)
-  __glutPutOnWorkList(__glutToplevelOf(window), GLUT_COLORMAP_WORK);
-#endif
-
-  window->overlay = overlay;
-  glutUseLayer(GLUT_OVERLAY);
-
-  if (overlay->treatAsSingle) {
-    glDrawBuffer(GL_FRONT);
-    glReadBuffer(GL_FRONT);
-  }
-}
-
-void GLUTAPIENTRY
-glutRemoveOverlay(void)
-{
-  GLUTwindow *window = __glutCurrentWindow;
-  GLUToverlay *overlay = __glutCurrentWindow->overlay;
-
-  if (!window->overlay)
-    return;
-
-  /* If using overlay, switch to the normal layer. */
-  if (window->renderWin == overlay->win) {
-    glutUseLayer(GLUT_NORMAL);
-  }
-#if !defined(_WIN32)
-  addStaleWindow(window, overlay->win);
-#endif
-  __glutFreeOverlay(overlay);
-  window->overlay = NULL;
-#if !defined(_WIN32)
-  __glutPutOnWorkList(__glutToplevelOf(window), GLUT_COLORMAP_WORK);
-#endif
-}
-
-void GLUTAPIENTRY
-glutUseLayer(GLenum layer)
-{
-  GLUTwindow *window = __glutCurrentWindow;
-
-  switch (layer) {
-  case GLUT_NORMAL:
-#ifdef _WIN32
-    window->renderDc = window->hdc;
-#endif
-    window->renderWin = window->win;
-    window->renderCtx = window->ctx;
-    break;
-  case GLUT_OVERLAY:
-    /* Did you crash here?  Calling glutUseLayer(GLUT_OVERLAY)
-       without an overlay established is erroneous.  Fix your
-       code. */
-#ifdef _WIN32
-    window->renderDc = window->overlay->hdc;
-#endif
-    window->renderWin = window->overlay->win;
-    window->renderCtx = window->overlay->ctx;
-    break;
-  default:
-    __glutWarning("glutUseLayer: unknown layer, %d.", layer);
-    break;
-  }
-  __glutSetWindow(window);
-}
-
-void GLUTAPIENTRY
-glutPostOverlayRedisplay(void)
-{
-  __glutPostRedisplay(__glutCurrentWindow, GLUT_OVERLAY_REDISPLAY_WORK);
-}
-
-/* The advantage of this routine is that it saves the cost of a
-   glutSetWindow call (entailing an expensive OpenGL context
-   switch), particularly useful when multiple windows need
-   redisplays posted at the same times. */
-void GLUTAPIENTRY
-glutPostWindowOverlayRedisplay(int win)
-{
-  __glutPostRedisplay(__glutWindowList[win - 1], GLUT_OVERLAY_REDISPLAY_WORK);
-}
-
-void GLUTAPIENTRY
-glutOverlayDisplayFunc(GLUTdisplayCB displayFunc)
-{
-  if (!__glutCurrentWindow->overlay) {
-    __glutWarning("glutOverlayDisplayFunc: window has no overlay established");
-    return;
-  }
-  __glutCurrentWindow->overlay->display = displayFunc;
-}
-
-void GLUTAPIENTRY
-glutHideOverlay(void)
-{
-  if (!__glutCurrentWindow->overlay) {
-    __glutWarning("glutHideOverlay: window has no overlay established");
-    return;
-  }
-  XUnmapWindow(__glutDisplay, __glutCurrentWindow->overlay->win);
-  __glutCurrentWindow->overlay->shownState = 0;
-}
-
-void GLUTAPIENTRY
-glutShowOverlay(void)
-{
-  if (!__glutCurrentWindow->overlay) {
-    __glutWarning("glutShowOverlay: window has no overlay established");
-    return;
-  }
-  XMapWindow(__glutDisplay, __glutCurrentWindow->overlay->win);
-  __glutCurrentWindow->overlay->shownState = 1;
-}
-
-int GLUTAPIENTRY
-glutLayerGet(GLenum param)
-{
-  switch (param) {
-  case GLUT_OVERLAY_POSSIBLE:
-    {
-      XVisualInfo *vi;
-      Bool dummy, visAlloced;
-      void *fbc;
-
-      vi = determineOverlayVisual(&dummy, &visAlloced, &fbc);
-      if (vi) {
-        if (visAlloced)
-          XFree(vi);
-        return 1;
-      }
-      return 0;
-    }
-  case GLUT_LAYER_IN_USE:
-    return __glutCurrentWindow->renderWin != __glutCurrentWindow->win;
-  case GLUT_HAS_OVERLAY:
-    return __glutCurrentWindow->overlay != NULL;
-  case GLUT_TRANSPARENT_INDEX:
-    if (__glutCurrentWindow->overlay) {
-      return __glutCurrentWindow->overlay->transparentPixel;
-    } else {
-      return -1;
-    }
-  case GLUT_NORMAL_DAMAGED:
-    /* __glutWindowDamaged is used so the damage state within
-       the window (or overlay belwo) can be cleared before
-       calling a display callback so on return, the state does
-       not have to be cleared (since upon return from the
-       callback the window could be destroyed (or layer
-       removed). */
-    return (__glutCurrentWindow->workMask & GLUT_REPAIR_WORK)
-      || __glutWindowDamaged;
-  case GLUT_OVERLAY_DAMAGED:
-    if (__glutCurrentWindow->overlay) {
-      return (__glutCurrentWindow->workMask & GLUT_OVERLAY_REPAIR_WORK)
-        || __glutWindowDamaged;
-    } else {
-      return -1;
-    }
-  default:
-    __glutWarning("invalid glutLayerGet param: %d", param);
-    return -1;
-  }
-}
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_ppm.c b/src/glut/glx/glut_ppm.c
deleted file mode 100644 (file)
index 49dca85..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * PPM file output
- * Brian Paul
- * 8 Dec 2008
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "glutint.h"
-
-
-static void
-write_ppm_file(const char *filename, const GLubyte *buffer,
-               int width, int height)
-{
-   const int binary = 1;
-   FILE *f = fopen( filename, "w" );
-   if (f) {
-      const GLubyte *ptr = buffer;
-      int i, x, y;
-      if (binary) {
-         fprintf(f,"P6\n");
-         fprintf(f,"# ppm-file created by GLUT\n");
-         fprintf(f,"%i %i\n", width, height);
-         fprintf(f,"255\n");
-         fclose(f);
-         f = fopen( filename, "ab" );  /* reopen in binary append mode */
-         for (y = height - 1; y >= 0; y--) {
-            for (x = 0; x < width; x++) {
-               i = (y * width + x) * 4;
-               fputc(ptr[i], f);   /* write red */
-               fputc(ptr[i+1], f); /* write green */
-               fputc(ptr[i+2], f); /* write blue */
-            }
-         }
-      }
-      else {
-         /*ASCII*/
-         int counter = 0;
-         fprintf(f,"P3\n");
-         fprintf(f,"# ascii ppm file created by GLUT\n");
-         fprintf(f,"%i %i\n", width, height);
-         fprintf(f,"255\n");
-         for (y = height - 1; y >= 0; y--) {
-            for (x = 0; x < width; x++) {
-               i = (y * width + x) * 4;
-               fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]);
-               counter++;
-               if (counter % 5 == 0)
-                  fprintf(f, "\n");
-            }
-         }
-      }
-      fclose(f);
-   }
-}
-
-
-/**
- * Called from SwapBuffers if the GLUT_PPM_FILE env var is set.
- */
-void __glutWritePPMFile(void)
-{
-   int w = glutGet(GLUT_WINDOW_WIDTH);
-   int h = glutGet(GLUT_WINDOW_HEIGHT);
-   GLubyte *buf;
-
-   assert(__glutPPMFile);
-
-   buf = (GLubyte *) malloc(w * h * 4);
-   if (buf) {
-      /* XXX save/restore pixel packing */
-      glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
-      write_ppm_file(__glutPPMFile, buf, w, h);
-      free(buf);
-   }
-
-   __glutPPMFile = NULL; /* only write one file */
-}
diff --git a/src/glut/glx/glut_roman.c b/src/glut/glx/glut_roman.c
deleted file mode 100644 (file)
index 95b9f81..0000000
+++ /dev/null
@@ -1,2454 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutStrokeRoman XXX
-#include "glutstroke.h"
-#undef glutStrokeRoman
-
-/* char: 33 '!' */
-
-static const CoordRec char33_stroke0[] = {
-    { 13.3819, 100 },
-    { 13.3819, 33.3333 },
-};
-
-static const CoordRec char33_stroke1[] = {
-    { 13.3819, 9.5238 },
-    { 8.62, 4.7619 },
-    { 13.3819, 0 },
-    { 18.1438, 4.7619 },
-    { 13.3819, 9.5238 },
-};
-
-static const StrokeRec char33[] = {
-   { 2, char33_stroke0 },
-   { 5, char33_stroke1 },
-};
-
-/* char: 34 '"' */
-
-static const CoordRec char34_stroke0[] = {
-    { 4.02, 100 },
-    { 4.02, 66.6667 },
-};
-
-static const CoordRec char34_stroke1[] = {
-    { 42.1152, 100 },
-    { 42.1152, 66.6667 },
-};
-
-static const StrokeRec char34[] = {
-   { 2, char34_stroke0 },
-   { 2, char34_stroke1 },
-};
-
-/* char: 35 '#' */
-
-static const CoordRec char35_stroke0[] = {
-    { 41.2952, 119.048 },
-    { 7.9619, -33.3333 },
-};
-
-static const CoordRec char35_stroke1[] = {
-    { 69.8667, 119.048 },
-    { 36.5333, -33.3333 },
-};
-
-static const CoordRec char35_stroke2[] = {
-    { 7.9619, 57.1429 },
-    { 74.6286, 57.1429 },
-};
-
-static const CoordRec char35_stroke3[] = {
-    { 3.2, 28.5714 },
-    { 69.8667, 28.5714 },
-};
-
-static const StrokeRec char35[] = {
-   { 2, char35_stroke0 },
-   { 2, char35_stroke1 },
-   { 2, char35_stroke2 },
-   { 2, char35_stroke3 },
-};
-
-/* char: 36 '$' */
-
-static const CoordRec char36_stroke0[] = {
-    { 28.6295, 119.048 },
-    { 28.6295, -19.0476 },
-};
-
-static const CoordRec char36_stroke1[] = {
-    { 47.6771, 119.048 },
-    { 47.6771, -19.0476 },
-};
-
-static const CoordRec char36_stroke2[] = {
-    { 71.4867, 85.7143 },
-    { 61.9629, 95.2381 },
-    { 47.6771, 100 },
-    { 28.6295, 100 },
-    { 14.3438, 95.2381 },
-    { 4.82, 85.7143 },
-    { 4.82, 76.1905 },
-    { 9.5819, 66.6667 },
-    { 14.3438, 61.9048 },
-    { 23.8676, 57.1429 },
-    { 52.439, 47.619 },
-    { 61.9629, 42.8571 },
-    { 66.7248, 38.0952 },
-    { 71.4867, 28.5714 },
-    { 71.4867, 14.2857 },
-    { 61.9629, 4.7619 },
-    { 47.6771, 0 },
-    { 28.6295, 0 },
-    { 14.3438, 4.7619 },
-    { 4.82, 14.2857 },
-};
-
-static const StrokeRec char36[] = {
-   { 2, char36_stroke0 },
-   { 2, char36_stroke1 },
-   { 20, char36_stroke2 },
-};
-
-/* char: 37 '%' */
-
-static const CoordRec char37_stroke0[] = {
-    { 92.0743, 100 },
-    { 6.36, 0 },
-};
-
-static const CoordRec char37_stroke1[] = {
-    { 30.1695, 100 },
-    { 39.6933, 90.4762 },
-    { 39.6933, 80.9524 },
-    { 34.9314, 71.4286 },
-    { 25.4076, 66.6667 },
-    { 15.8838, 66.6667 },
-    { 6.36, 76.1905 },
-    { 6.36, 85.7143 },
-    { 11.1219, 95.2381 },
-    { 20.6457, 100 },
-    { 30.1695, 100 },
-    { 39.6933, 95.2381 },
-    { 53.979, 90.4762 },
-    { 68.2648, 90.4762 },
-    { 82.5505, 95.2381 },
-    { 92.0743, 100 },
-};
-
-static const CoordRec char37_stroke2[] = {
-    { 73.0267, 33.3333 },
-    { 63.5029, 28.5714 },
-    { 58.741, 19.0476 },
-    { 58.741, 9.5238 },
-    { 68.2648, 0 },
-    { 77.7886, 0 },
-    { 87.3124, 4.7619 },
-    { 92.0743, 14.2857 },
-    { 92.0743, 23.8095 },
-    { 82.5505, 33.3333 },
-    { 73.0267, 33.3333 },
-};
-
-static const StrokeRec char37[] = {
-   { 2, char37_stroke0 },
-   { 16, char37_stroke1 },
-   { 11, char37_stroke2 },
-};
-
-/* char: 38 '&' */
-
-static const CoordRec char38_stroke0[] = {
-    { 101.218, 57.1429 },
-    { 101.218, 61.9048 },
-    { 96.4562, 66.6667 },
-    { 91.6943, 66.6667 },
-    { 86.9324, 61.9048 },
-    { 82.1705, 52.381 },
-    { 72.6467, 28.5714 },
-    { 63.1229, 14.2857 },
-    { 53.599, 4.7619 },
-    { 44.0752, 0 },
-    { 25.0276, 0 },
-    { 15.5038, 4.7619 },
-    { 10.7419, 9.5238 },
-    { 5.98, 19.0476 },
-    { 5.98, 28.5714 },
-    { 10.7419, 38.0952 },
-    { 15.5038, 42.8571 },
-    { 48.8371, 61.9048 },
-    { 53.599, 66.6667 },
-    { 58.361, 76.1905 },
-    { 58.361, 85.7143 },
-    { 53.599, 95.2381 },
-    { 44.0752, 100 },
-    { 34.5514, 95.2381 },
-    { 29.7895, 85.7143 },
-    { 29.7895, 76.1905 },
-    { 34.5514, 61.9048 },
-    { 44.0752, 47.619 },
-    { 67.8848, 14.2857 },
-    { 77.4086, 4.7619 },
-    { 86.9324, 0 },
-    { 96.4562, 0 },
-    { 101.218, 4.7619 },
-    { 101.218, 9.5238 },
-};
-
-static const StrokeRec char38[] = {
-   { 34, char38_stroke0 },
-};
-
-/* char: 39 ''' */
-
-static const CoordRec char39_stroke0[] = {
-    { 4.44, 100 },
-    { 4.44, 66.6667 },
-};
-
-static const StrokeRec char39[] = {
-   { 2, char39_stroke0 },
-};
-
-/* char: 40 '(' */
-
-static const CoordRec char40_stroke0[] = {
-    { 40.9133, 119.048 },
-    { 31.3895, 109.524 },
-    { 21.8657, 95.2381 },
-    { 12.3419, 76.1905 },
-    { 7.58, 52.381 },
-    { 7.58, 33.3333 },
-    { 12.3419, 9.5238 },
-    { 21.8657, -9.5238 },
-    { 31.3895, -23.8095 },
-    { 40.9133, -33.3333 },
-};
-
-static const StrokeRec char40[] = {
-   { 10, char40_stroke0 },
-};
-
-/* char: 41 ')' */
-
-static const CoordRec char41_stroke0[] = {
-    { 5.28, 119.048 },
-    { 14.8038, 109.524 },
-    { 24.3276, 95.2381 },
-    { 33.8514, 76.1905 },
-    { 38.6133, 52.381 },
-    { 38.6133, 33.3333 },
-    { 33.8514, 9.5238 },
-    { 24.3276, -9.5238 },
-    { 14.8038, -23.8095 },
-    { 5.28, -33.3333 },
-};
-
-static const StrokeRec char41[] = {
-   { 10, char41_stroke0 },
-};
-
-/* char: 42 '*' */
-
-static const CoordRec char42_stroke0[] = {
-    { 30.7695, 71.4286 },
-    { 30.7695, 14.2857 },
-};
-
-static const CoordRec char42_stroke1[] = {
-    { 6.96, 57.1429 },
-    { 54.579, 28.5714 },
-};
-
-static const CoordRec char42_stroke2[] = {
-    { 54.579, 57.1429 },
-    { 6.96, 28.5714 },
-};
-
-static const StrokeRec char42[] = {
-   { 2, char42_stroke0 },
-   { 2, char42_stroke1 },
-   { 2, char42_stroke2 },
-};
-
-/* char: 43 '+' */
-
-static const CoordRec char43_stroke0[] = {
-    { 48.8371, 85.7143 },
-    { 48.8371, 0 },
-};
-
-static const CoordRec char43_stroke1[] = {
-    { 5.98, 42.8571 },
-    { 91.6943, 42.8571 },
-};
-
-static const StrokeRec char43[] = {
-   { 2, char43_stroke0 },
-   { 2, char43_stroke1 },
-};
-
-/* char: 44 ',' */
-
-static const CoordRec char44_stroke0[] = {
-    { 18.2838, 4.7619 },
-    { 13.5219, 0 },
-    { 8.76, 4.7619 },
-    { 13.5219, 9.5238 },
-    { 18.2838, 4.7619 },
-    { 18.2838, -4.7619 },
-    { 13.5219, -14.2857 },
-    { 8.76, -19.0476 },
-};
-
-static const StrokeRec char44[] = {
-   { 8, char44_stroke0 },
-};
-
-/* char: 45 '-' */
-
-static const CoordRec char45_stroke0[] = {
-    { 7.38, 42.8571 },
-    { 93.0943, 42.8571 },
-};
-
-static const StrokeRec char45[] = {
-   { 2, char45_stroke0 },
-};
-
-/* char: 46 '.' */
-
-static const CoordRec char46_stroke0[] = {
-    { 13.1019, 9.5238 },
-    { 8.34, 4.7619 },
-    { 13.1019, 0 },
-    { 17.8638, 4.7619 },
-    { 13.1019, 9.5238 },
-};
-
-static const StrokeRec char46[] = {
-   { 5, char46_stroke0 },
-};
-
-/* char: 47 '/' */
-
-static const CoordRec char47_stroke0[] = {
-    { 7.24, -14.2857 },
-    { 73.9067, 100 },
-};
-
-static const StrokeRec char47[] = {
-   { 2, char47_stroke0 },
-};
-
-/* char: 48 '0' */
-
-static const CoordRec char48_stroke0[] = {
-    { 33.5514, 100 },
-    { 19.2657, 95.2381 },
-    { 9.7419, 80.9524 },
-    { 4.98, 57.1429 },
-    { 4.98, 42.8571 },
-    { 9.7419, 19.0476 },
-    { 19.2657, 4.7619 },
-    { 33.5514, 0 },
-    { 43.0752, 0 },
-    { 57.361, 4.7619 },
-    { 66.8848, 19.0476 },
-    { 71.6467, 42.8571 },
-    { 71.6467, 57.1429 },
-    { 66.8848, 80.9524 },
-    { 57.361, 95.2381 },
-    { 43.0752, 100 },
-    { 33.5514, 100 },
-};
-
-static const StrokeRec char48[] = {
-   { 17, char48_stroke0 },
-};
-
-/* char: 49 '1' */
-
-static const CoordRec char49_stroke0[] = {
-    { 11.82, 80.9524 },
-    { 21.3438, 85.7143 },
-    { 35.6295, 100 },
-    { 35.6295, 0 },
-};
-
-static const StrokeRec char49[] = {
-   { 4, char49_stroke0 },
-};
-
-/* char: 50 '2' */
-
-static const CoordRec char50_stroke0[] = {
-    { 10.1819, 76.1905 },
-    { 10.1819, 80.9524 },
-    { 14.9438, 90.4762 },
-    { 19.7057, 95.2381 },
-    { 29.2295, 100 },
-    { 48.2771, 100 },
-    { 57.801, 95.2381 },
-    { 62.5629, 90.4762 },
-    { 67.3248, 80.9524 },
-    { 67.3248, 71.4286 },
-    { 62.5629, 61.9048 },
-    { 53.039, 47.619 },
-    { 5.42, 0 },
-    { 72.0867, 0 },
-};
-
-static const StrokeRec char50[] = {
-   { 14, char50_stroke0 },
-};
-
-/* char: 51 '3' */
-
-static const CoordRec char51_stroke0[] = {
-    { 14.5238, 100 },
-    { 66.9048, 100 },
-    { 38.3333, 61.9048 },
-    { 52.619, 61.9048 },
-    { 62.1429, 57.1429 },
-    { 66.9048, 52.381 },
-    { 71.6667, 38.0952 },
-    { 71.6667, 28.5714 },
-    { 66.9048, 14.2857 },
-    { 57.381, 4.7619 },
-    { 43.0952, 0 },
-    { 28.8095, 0 },
-    { 14.5238, 4.7619 },
-    { 9.7619, 9.5238 },
-    { 5, 19.0476 },
-};
-
-static const StrokeRec char51[] = {
-   { 15, char51_stroke0 },
-};
-
-/* char: 52 '4' */
-
-static const CoordRec char52_stroke0[] = {
-    { 51.499, 100 },
-    { 3.88, 33.3333 },
-    { 75.3086, 33.3333 },
-};
-
-static const CoordRec char52_stroke1[] = {
-    { 51.499, 100 },
-    { 51.499, 0 },
-};
-
-static const StrokeRec char52[] = {
-   { 3, char52_stroke0 },
-   { 2, char52_stroke1 },
-};
-
-/* char: 53 '5' */
-
-static const CoordRec char53_stroke0[] = {
-    { 62.0029, 100 },
-    { 14.3838, 100 },
-    { 9.6219, 57.1429 },
-    { 14.3838, 61.9048 },
-    { 28.6695, 66.6667 },
-    { 42.9552, 66.6667 },
-    { 57.241, 61.9048 },
-    { 66.7648, 52.381 },
-    { 71.5267, 38.0952 },
-    { 71.5267, 28.5714 },
-    { 66.7648, 14.2857 },
-    { 57.241, 4.7619 },
-    { 42.9552, 0 },
-    { 28.6695, 0 },
-    { 14.3838, 4.7619 },
-    { 9.6219, 9.5238 },
-    { 4.86, 19.0476 },
-};
-
-static const StrokeRec char53[] = {
-   { 17, char53_stroke0 },
-};
-
-/* char: 54 '6' */
-
-static const CoordRec char54_stroke0[] = {
-    { 62.7229, 85.7143 },
-    { 57.961, 95.2381 },
-    { 43.6752, 100 },
-    { 34.1514, 100 },
-    { 19.8657, 95.2381 },
-    { 10.3419, 80.9524 },
-    { 5.58, 57.1429 },
-    { 5.58, 33.3333 },
-    { 10.3419, 14.2857 },
-    { 19.8657, 4.7619 },
-    { 34.1514, 0 },
-    { 38.9133, 0 },
-    { 53.199, 4.7619 },
-    { 62.7229, 14.2857 },
-    { 67.4848, 28.5714 },
-    { 67.4848, 33.3333 },
-    { 62.7229, 47.619 },
-    { 53.199, 57.1429 },
-    { 38.9133, 61.9048 },
-    { 34.1514, 61.9048 },
-    { 19.8657, 57.1429 },
-    { 10.3419, 47.619 },
-    { 5.58, 33.3333 },
-};
-
-static const StrokeRec char54[] = {
-   { 23, char54_stroke0 },
-};
-
-/* char: 55 '7' */
-
-static const CoordRec char55_stroke0[] = {
-    { 72.2267, 100 },
-    { 24.6076, 0 },
-};
-
-static const CoordRec char55_stroke1[] = {
-    { 5.56, 100 },
-    { 72.2267, 100 },
-};
-
-static const StrokeRec char55[] = {
-   { 2, char55_stroke0 },
-   { 2, char55_stroke1 },
-};
-
-/* char: 56 '8' */
-
-static const CoordRec char56_stroke0[] = {
-    { 29.4095, 100 },
-    { 15.1238, 95.2381 },
-    { 10.3619, 85.7143 },
-    { 10.3619, 76.1905 },
-    { 15.1238, 66.6667 },
-    { 24.6476, 61.9048 },
-    { 43.6952, 57.1429 },
-    { 57.981, 52.381 },
-    { 67.5048, 42.8571 },
-    { 72.2667, 33.3333 },
-    { 72.2667, 19.0476 },
-    { 67.5048, 9.5238 },
-    { 62.7429, 4.7619 },
-    { 48.4571, 0 },
-    { 29.4095, 0 },
-    { 15.1238, 4.7619 },
-    { 10.3619, 9.5238 },
-    { 5.6, 19.0476 },
-    { 5.6, 33.3333 },
-    { 10.3619, 42.8571 },
-    { 19.8857, 52.381 },
-    { 34.1714, 57.1429 },
-    { 53.219, 61.9048 },
-    { 62.7429, 66.6667 },
-    { 67.5048, 76.1905 },
-    { 67.5048, 85.7143 },
-    { 62.7429, 95.2381 },
-    { 48.4571, 100 },
-    { 29.4095, 100 },
-};
-
-static const StrokeRec char56[] = {
-   { 29, char56_stroke0 },
-};
-
-/* char: 57 '9' */
-
-static const CoordRec char57_stroke0[] = {
-    { 68.5048, 66.6667 },
-    { 63.7429, 52.381 },
-    { 54.219, 42.8571 },
-    { 39.9333, 38.0952 },
-    { 35.1714, 38.0952 },
-    { 20.8857, 42.8571 },
-    { 11.3619, 52.381 },
-    { 6.6, 66.6667 },
-    { 6.6, 71.4286 },
-    { 11.3619, 85.7143 },
-    { 20.8857, 95.2381 },
-    { 35.1714, 100 },
-    { 39.9333, 100 },
-    { 54.219, 95.2381 },
-    { 63.7429, 85.7143 },
-    { 68.5048, 66.6667 },
-    { 68.5048, 42.8571 },
-    { 63.7429, 19.0476 },
-    { 54.219, 4.7619 },
-    { 39.9333, 0 },
-    { 30.4095, 0 },
-    { 16.1238, 4.7619 },
-    { 11.3619, 14.2857 },
-};
-
-static const StrokeRec char57[] = {
-   { 23, char57_stroke0 },
-};
-
-/* char: 58 ':' */
-
-static const CoordRec char58_stroke0[] = {
-    { 14.0819, 66.6667 },
-    { 9.32, 61.9048 },
-    { 14.0819, 57.1429 },
-    { 18.8438, 61.9048 },
-    { 14.0819, 66.6667 },
-};
-
-static const CoordRec char58_stroke1[] = {
-    { 14.0819, 9.5238 },
-    { 9.32, 4.7619 },
-    { 14.0819, 0 },
-    { 18.8438, 4.7619 },
-    { 14.0819, 9.5238 },
-};
-
-static const StrokeRec char58[] = {
-   { 5, char58_stroke0 },
-   { 5, char58_stroke1 },
-};
-
-/* char: 59 ';' */
-
-static const CoordRec char59_stroke0[] = {
-    { 12.9619, 66.6667 },
-    { 8.2, 61.9048 },
-    { 12.9619, 57.1429 },
-    { 17.7238, 61.9048 },
-    { 12.9619, 66.6667 },
-};
-
-static const CoordRec char59_stroke1[] = {
-    { 17.7238, 4.7619 },
-    { 12.9619, 0 },
-    { 8.2, 4.7619 },
-    { 12.9619, 9.5238 },
-    { 17.7238, 4.7619 },
-    { 17.7238, -4.7619 },
-    { 12.9619, -14.2857 },
-    { 8.2, -19.0476 },
-};
-
-static const StrokeRec char59[] = {
-   { 5, char59_stroke0 },
-   { 8, char59_stroke1 },
-};
-
-/* char: 60 '<' */
-
-static const CoordRec char60_stroke0[] = {
-    { 79.2505, 85.7143 },
-    { 3.06, 42.8571 },
-    { 79.2505, 0 },
-};
-
-static const StrokeRec char60[] = {
-   { 3, char60_stroke0 },
-};
-
-/* char: 61 '=' */
-
-static const CoordRec char61_stroke0[] = {
-    { 5.7, 57.1429 },
-    { 91.4143, 57.1429 },
-};
-
-static const CoordRec char61_stroke1[] = {
-    { 5.7, 28.5714 },
-    { 91.4143, 28.5714 },
-};
-
-static const StrokeRec char61[] = {
-   { 2, char61_stroke0 },
-   { 2, char61_stroke1 },
-};
-
-/* char: 62 '>' */
-
-static const CoordRec char62_stroke0[] = {
-    { 2.78, 85.7143 },
-    { 78.9705, 42.8571 },
-    { 2.78, 0 },
-};
-
-static const StrokeRec char62[] = {
-   { 3, char62_stroke0 },
-};
-
-/* char: 63 '?' */
-
-static const CoordRec char63_stroke0[] = {
-    { 8.42, 76.1905 },
-    { 8.42, 80.9524 },
-    { 13.1819, 90.4762 },
-    { 17.9438, 95.2381 },
-    { 27.4676, 100 },
-    { 46.5152, 100 },
-    { 56.039, 95.2381 },
-    { 60.801, 90.4762 },
-    { 65.5629, 80.9524 },
-    { 65.5629, 71.4286 },
-    { 60.801, 61.9048 },
-    { 56.039, 57.1429 },
-    { 36.9914, 47.619 },
-    { 36.9914, 33.3333 },
-};
-
-static const CoordRec char63_stroke1[] = {
-    { 36.9914, 9.5238 },
-    { 32.2295, 4.7619 },
-    { 36.9914, 0 },
-    { 41.7533, 4.7619 },
-    { 36.9914, 9.5238 },
-};
-
-static const StrokeRec char63[] = {
-   { 14, char63_stroke0 },
-   { 5, char63_stroke1 },
-};
-
-/* char: 64 '@' */
-
-static const CoordRec char64_stroke0[] = {
-    { 49.2171, 52.381 },
-    { 39.6933, 57.1429 },
-    { 30.1695, 57.1429 },
-    { 25.4076, 47.619 },
-    { 25.4076, 42.8571 },
-    { 30.1695, 33.3333 },
-    { 39.6933, 33.3333 },
-    { 49.2171, 38.0952 },
-};
-
-static const CoordRec char64_stroke1[] = {
-    { 49.2171, 57.1429 },
-    { 49.2171, 38.0952 },
-    { 53.979, 33.3333 },
-    { 63.5029, 33.3333 },
-    { 68.2648, 42.8571 },
-    { 68.2648, 47.619 },
-    { 63.5029, 61.9048 },
-    { 53.979, 71.4286 },
-    { 39.6933, 76.1905 },
-    { 34.9314, 76.1905 },
-    { 20.6457, 71.4286 },
-    { 11.1219, 61.9048 },
-    { 6.36, 47.619 },
-    { 6.36, 42.8571 },
-    { 11.1219, 28.5714 },
-    { 20.6457, 19.0476 },
-    { 34.9314, 14.2857 },
-    { 39.6933, 14.2857 },
-    { 53.979, 19.0476 },
-};
-
-static const StrokeRec char64[] = {
-   { 8, char64_stroke0 },
-   { 19, char64_stroke1 },
-};
-
-/* char: 65 'A' */
-
-static const CoordRec char65_stroke0[] = {
-    { 40.5952, 100 },
-    { 2.5, 0 },
-};
-
-static const CoordRec char65_stroke1[] = {
-    { 40.5952, 100 },
-    { 78.6905, 0 },
-};
-
-static const CoordRec char65_stroke2[] = {
-    { 16.7857, 33.3333 },
-    { 64.4048, 33.3333 },
-};
-
-static const StrokeRec char65[] = {
-   { 2, char65_stroke0 },
-   { 2, char65_stroke1 },
-   { 2, char65_stroke2 },
-};
-
-/* char: 66 'B' */
-
-static const CoordRec char66_stroke0[] = {
-    { 11.42, 100 },
-    { 11.42, 0 },
-};
-
-static const CoordRec char66_stroke1[] = {
-    { 11.42, 100 },
-    { 54.2771, 100 },
-    { 68.5629, 95.2381 },
-    { 73.3248, 90.4762 },
-    { 78.0867, 80.9524 },
-    { 78.0867, 71.4286 },
-    { 73.3248, 61.9048 },
-    { 68.5629, 57.1429 },
-    { 54.2771, 52.381 },
-};
-
-static const CoordRec char66_stroke2[] = {
-    { 11.42, 52.381 },
-    { 54.2771, 52.381 },
-    { 68.5629, 47.619 },
-    { 73.3248, 42.8571 },
-    { 78.0867, 33.3333 },
-    { 78.0867, 19.0476 },
-    { 73.3248, 9.5238 },
-    { 68.5629, 4.7619 },
-    { 54.2771, 0 },
-    { 11.42, 0 },
-};
-
-static const StrokeRec char66[] = {
-   { 2, char66_stroke0 },
-   { 9, char66_stroke1 },
-   { 10, char66_stroke2 },
-};
-
-/* char: 67 'C' */
-
-static const CoordRec char67_stroke0[] = {
-    { 78.0886, 76.1905 },
-    { 73.3267, 85.7143 },
-    { 63.8029, 95.2381 },
-    { 54.279, 100 },
-    { 35.2314, 100 },
-    { 25.7076, 95.2381 },
-    { 16.1838, 85.7143 },
-    { 11.4219, 76.1905 },
-    { 6.66, 61.9048 },
-    { 6.66, 38.0952 },
-    { 11.4219, 23.8095 },
-    { 16.1838, 14.2857 },
-    { 25.7076, 4.7619 },
-    { 35.2314, 0 },
-    { 54.279, 0 },
-    { 63.8029, 4.7619 },
-    { 73.3267, 14.2857 },
-    { 78.0886, 23.8095 },
-};
-
-static const StrokeRec char67[] = {
-   { 18, char67_stroke0 },
-};
-
-/* char: 68 'D' */
-
-static const CoordRec char68_stroke0[] = {
-    { 11.96, 100 },
-    { 11.96, 0 },
-};
-
-static const CoordRec char68_stroke1[] = {
-    { 11.96, 100 },
-    { 45.2933, 100 },
-    { 59.579, 95.2381 },
-    { 69.1029, 85.7143 },
-    { 73.8648, 76.1905 },
-    { 78.6267, 61.9048 },
-    { 78.6267, 38.0952 },
-    { 73.8648, 23.8095 },
-    { 69.1029, 14.2857 },
-    { 59.579, 4.7619 },
-    { 45.2933, 0 },
-    { 11.96, 0 },
-};
-
-static const StrokeRec char68[] = {
-   { 2, char68_stroke0 },
-   { 12, char68_stroke1 },
-};
-
-/* char: 69 'E' */
-
-static const CoordRec char69_stroke0[] = {
-    { 11.42, 100 },
-    { 11.42, 0 },
-};
-
-static const CoordRec char69_stroke1[] = {
-    { 11.42, 100 },
-    { 73.3248, 100 },
-};
-
-static const CoordRec char69_stroke2[] = {
-    { 11.42, 52.381 },
-    { 49.5152, 52.381 },
-};
-
-static const CoordRec char69_stroke3[] = {
-    { 11.42, 0 },
-    { 73.3248, 0 },
-};
-
-static const StrokeRec char69[] = {
-   { 2, char69_stroke0 },
-   { 2, char69_stroke1 },
-   { 2, char69_stroke2 },
-   { 2, char69_stroke3 },
-};
-
-/* char: 70 'F' */
-
-static const CoordRec char70_stroke0[] = {
-    { 11.42, 100 },
-    { 11.42, 0 },
-};
-
-static const CoordRec char70_stroke1[] = {
-    { 11.42, 100 },
-    { 73.3248, 100 },
-};
-
-static const CoordRec char70_stroke2[] = {
-    { 11.42, 52.381 },
-    { 49.5152, 52.381 },
-};
-
-static const StrokeRec char70[] = {
-   { 2, char70_stroke0 },
-   { 2, char70_stroke1 },
-   { 2, char70_stroke2 },
-};
-
-/* char: 71 'G' */
-
-static const CoordRec char71_stroke0[] = {
-    { 78.4886, 76.1905 },
-    { 73.7267, 85.7143 },
-    { 64.2029, 95.2381 },
-    { 54.679, 100 },
-    { 35.6314, 100 },
-    { 26.1076, 95.2381 },
-    { 16.5838, 85.7143 },
-    { 11.8219, 76.1905 },
-    { 7.06, 61.9048 },
-    { 7.06, 38.0952 },
-    { 11.8219, 23.8095 },
-    { 16.5838, 14.2857 },
-    { 26.1076, 4.7619 },
-    { 35.6314, 0 },
-    { 54.679, 0 },
-    { 64.2029, 4.7619 },
-    { 73.7267, 14.2857 },
-    { 78.4886, 23.8095 },
-    { 78.4886, 38.0952 },
-};
-
-static const CoordRec char71_stroke1[] = {
-    { 54.679, 38.0952 },
-    { 78.4886, 38.0952 },
-};
-
-static const StrokeRec char71[] = {
-   { 19, char71_stroke0 },
-   { 2, char71_stroke1 },
-};
-
-/* char: 72 'H' */
-
-static const CoordRec char72_stroke0[] = {
-    { 11.42, 100 },
-    { 11.42, 0 },
-};
-
-static const CoordRec char72_stroke1[] = {
-    { 78.0867, 100 },
-    { 78.0867, 0 },
-};
-
-static const CoordRec char72_stroke2[] = {
-    { 11.42, 52.381 },
-    { 78.0867, 52.381 },
-};
-
-static const StrokeRec char72[] = {
-   { 2, char72_stroke0 },
-   { 2, char72_stroke1 },
-   { 2, char72_stroke2 },
-};
-
-/* char: 73 'I' */
-
-static const CoordRec char73_stroke0[] = {
-    { 10.86, 100 },
-    { 10.86, 0 },
-};
-
-static const StrokeRec char73[] = {
-   { 2, char73_stroke0 },
-};
-
-/* char: 74 'J' */
-
-static const CoordRec char74_stroke0[] = {
-    { 50.119, 100 },
-    { 50.119, 23.8095 },
-    { 45.3571, 9.5238 },
-    { 40.5952, 4.7619 },
-    { 31.0714, 0 },
-    { 21.5476, 0 },
-    { 12.0238, 4.7619 },
-    { 7.2619, 9.5238 },
-    { 2.5, 23.8095 },
-    { 2.5, 33.3333 },
-};
-
-static const StrokeRec char74[] = {
-   { 10, char74_stroke0 },
-};
-
-/* char: 75 'K' */
-
-static const CoordRec char75_stroke0[] = {
-    { 11.28, 100 },
-    { 11.28, 0 },
-};
-
-static const CoordRec char75_stroke1[] = {
-    { 77.9467, 100 },
-    { 11.28, 33.3333 },
-};
-
-static const CoordRec char75_stroke2[] = {
-    { 35.0895, 57.1429 },
-    { 77.9467, 0 },
-};
-
-static const StrokeRec char75[] = {
-   { 2, char75_stroke0 },
-   { 2, char75_stroke1 },
-   { 2, char75_stroke2 },
-};
-
-/* char: 76 'L' */
-
-static const CoordRec char76_stroke0[] = {
-    { 11.68, 100 },
-    { 11.68, 0 },
-};
-
-static const CoordRec char76_stroke1[] = {
-    { 11.68, 0 },
-    { 68.8229, 0 },
-};
-
-static const StrokeRec char76[] = {
-   { 2, char76_stroke0 },
-   { 2, char76_stroke1 },
-};
-
-/* char: 77 'M' */
-
-static const CoordRec char77_stroke0[] = {
-    { 10.86, 100 },
-    { 10.86, 0 },
-};
-
-static const CoordRec char77_stroke1[] = {
-    { 10.86, 100 },
-    { 48.9552, 0 },
-};
-
-static const CoordRec char77_stroke2[] = {
-    { 87.0505, 100 },
-    { 48.9552, 0 },
-};
-
-static const CoordRec char77_stroke3[] = {
-    { 87.0505, 100 },
-    { 87.0505, 0 },
-};
-
-static const StrokeRec char77[] = {
-   { 2, char77_stroke0 },
-   { 2, char77_stroke1 },
-   { 2, char77_stroke2 },
-   { 2, char77_stroke3 },
-};
-
-/* char: 78 'N' */
-
-static const CoordRec char78_stroke0[] = {
-    { 11.14, 100 },
-    { 11.14, 0 },
-};
-
-static const CoordRec char78_stroke1[] = {
-    { 11.14, 100 },
-    { 77.8067, 0 },
-};
-
-static const CoordRec char78_stroke2[] = {
-    { 77.8067, 100 },
-    { 77.8067, 0 },
-};
-
-static const StrokeRec char78[] = {
-   { 2, char78_stroke0 },
-   { 2, char78_stroke1 },
-   { 2, char78_stroke2 },
-};
-
-/* char: 79 'O' */
-
-static const CoordRec char79_stroke0[] = {
-    { 34.8114, 100 },
-    { 25.2876, 95.2381 },
-    { 15.7638, 85.7143 },
-    { 11.0019, 76.1905 },
-    { 6.24, 61.9048 },
-    { 6.24, 38.0952 },
-    { 11.0019, 23.8095 },
-    { 15.7638, 14.2857 },
-    { 25.2876, 4.7619 },
-    { 34.8114, 0 },
-    { 53.859, 0 },
-    { 63.3829, 4.7619 },
-    { 72.9067, 14.2857 },
-    { 77.6686, 23.8095 },
-    { 82.4305, 38.0952 },
-    { 82.4305, 61.9048 },
-    { 77.6686, 76.1905 },
-    { 72.9067, 85.7143 },
-    { 63.3829, 95.2381 },
-    { 53.859, 100 },
-    { 34.8114, 100 },
-};
-
-static const StrokeRec char79[] = {
-   { 21, char79_stroke0 },
-};
-
-/* char: 80 'P' */
-
-static const CoordRec char80_stroke0[] = {
-    { 12.1, 100 },
-    { 12.1, 0 },
-};
-
-static const CoordRec char80_stroke1[] = {
-    { 12.1, 100 },
-    { 54.9571, 100 },
-    { 69.2429, 95.2381 },
-    { 74.0048, 90.4762 },
-    { 78.7667, 80.9524 },
-    { 78.7667, 66.6667 },
-    { 74.0048, 57.1429 },
-    { 69.2429, 52.381 },
-    { 54.9571, 47.619 },
-    { 12.1, 47.619 },
-};
-
-static const StrokeRec char80[] = {
-   { 2, char80_stroke0 },
-   { 10, char80_stroke1 },
-};
-
-/* char: 81 'Q' */
-
-static const CoordRec char81_stroke0[] = {
-    { 33.8714, 100 },
-    { 24.3476, 95.2381 },
-    { 14.8238, 85.7143 },
-    { 10.0619, 76.1905 },
-    { 5.3, 61.9048 },
-    { 5.3, 38.0952 },
-    { 10.0619, 23.8095 },
-    { 14.8238, 14.2857 },
-    { 24.3476, 4.7619 },
-    { 33.8714, 0 },
-    { 52.919, 0 },
-    { 62.4429, 4.7619 },
-    { 71.9667, 14.2857 },
-    { 76.7286, 23.8095 },
-    { 81.4905, 38.0952 },
-    { 81.4905, 61.9048 },
-    { 76.7286, 76.1905 },
-    { 71.9667, 85.7143 },
-    { 62.4429, 95.2381 },
-    { 52.919, 100 },
-    { 33.8714, 100 },
-};
-
-static const CoordRec char81_stroke1[] = {
-    { 48.1571, 19.0476 },
-    { 76.7286, -9.5238 },
-};
-
-static const StrokeRec char81[] = {
-   { 21, char81_stroke0 },
-   { 2, char81_stroke1 },
-};
-
-/* char: 82 'R' */
-
-static const CoordRec char82_stroke0[] = {
-    { 11.68, 100 },
-    { 11.68, 0 },
-};
-
-static const CoordRec char82_stroke1[] = {
-    { 11.68, 100 },
-    { 54.5371, 100 },
-    { 68.8229, 95.2381 },
-    { 73.5848, 90.4762 },
-    { 78.3467, 80.9524 },
-    { 78.3467, 71.4286 },
-    { 73.5848, 61.9048 },
-    { 68.8229, 57.1429 },
-    { 54.5371, 52.381 },
-    { 11.68, 52.381 },
-};
-
-static const CoordRec char82_stroke2[] = {
-    { 45.0133, 52.381 },
-    { 78.3467, 0 },
-};
-
-static const StrokeRec char82[] = {
-   { 2, char82_stroke0 },
-   { 10, char82_stroke1 },
-   { 2, char82_stroke2 },
-};
-
-/* char: 83 'S' */
-
-static const CoordRec char83_stroke0[] = {
-    { 74.6667, 85.7143 },
-    { 65.1429, 95.2381 },
-    { 50.8571, 100 },
-    { 31.8095, 100 },
-    { 17.5238, 95.2381 },
-    { 8, 85.7143 },
-    { 8, 76.1905 },
-    { 12.7619, 66.6667 },
-    { 17.5238, 61.9048 },
-    { 27.0476, 57.1429 },
-    { 55.619, 47.619 },
-    { 65.1429, 42.8571 },
-    { 69.9048, 38.0952 },
-    { 74.6667, 28.5714 },
-    { 74.6667, 14.2857 },
-    { 65.1429, 4.7619 },
-    { 50.8571, 0 },
-    { 31.8095, 0 },
-    { 17.5238, 4.7619 },
-    { 8, 14.2857 },
-};
-
-static const StrokeRec char83[] = {
-   { 20, char83_stroke0 },
-};
-
-/* char: 84 'T' */
-
-static const CoordRec char84_stroke0[] = {
-    { 35.6933, 100 },
-    { 35.6933, 0 },
-};
-
-static const CoordRec char84_stroke1[] = {
-    { 2.36, 100 },
-    { 69.0267, 100 },
-};
-
-static const StrokeRec char84[] = {
-   { 2, char84_stroke0 },
-   { 2, char84_stroke1 },
-};
-
-/* char: 85 'U' */
-
-static const CoordRec char85_stroke0[] = {
-    { 11.54, 100 },
-    { 11.54, 28.5714 },
-    { 16.3019, 14.2857 },
-    { 25.8257, 4.7619 },
-    { 40.1114, 0 },
-    { 49.6352, 0 },
-    { 63.921, 4.7619 },
-    { 73.4448, 14.2857 },
-    { 78.2067, 28.5714 },
-    { 78.2067, 100 },
-};
-
-static const StrokeRec char85[] = {
-   { 10, char85_stroke0 },
-};
-
-/* char: 86 'V' */
-
-static const CoordRec char86_stroke0[] = {
-    { 2.36, 100 },
-    { 40.4552, 0 },
-};
-
-static const CoordRec char86_stroke1[] = {
-    { 78.5505, 100 },
-    { 40.4552, 0 },
-};
-
-static const StrokeRec char86[] = {
-   { 2, char86_stroke0 },
-   { 2, char86_stroke1 },
-};
-
-/* char: 87 'W' */
-
-static const CoordRec char87_stroke0[] = {
-    { 2.22, 100 },
-    { 26.0295, 0 },
-};
-
-static const CoordRec char87_stroke1[] = {
-    { 49.839, 100 },
-    { 26.0295, 0 },
-};
-
-static const CoordRec char87_stroke2[] = {
-    { 49.839, 100 },
-    { 73.6486, 0 },
-};
-
-static const CoordRec char87_stroke3[] = {
-    { 97.4581, 100 },
-    { 73.6486, 0 },
-};
-
-static const StrokeRec char87[] = {
-   { 2, char87_stroke0 },
-   { 2, char87_stroke1 },
-   { 2, char87_stroke2 },
-   { 2, char87_stroke3 },
-};
-
-/* char: 88 'X' */
-
-static const CoordRec char88_stroke0[] = {
-    { 2.5, 100 },
-    { 69.1667, 0 },
-};
-
-static const CoordRec char88_stroke1[] = {
-    { 69.1667, 100 },
-    { 2.5, 0 },
-};
-
-static const StrokeRec char88[] = {
-   { 2, char88_stroke0 },
-   { 2, char88_stroke1 },
-};
-
-/* char: 89 'Y' */
-
-static const CoordRec char89_stroke0[] = {
-    { 1.52, 100 },
-    { 39.6152, 52.381 },
-    { 39.6152, 0 },
-};
-
-static const CoordRec char89_stroke1[] = {
-    { 77.7105, 100 },
-    { 39.6152, 52.381 },
-};
-
-static const StrokeRec char89[] = {
-   { 3, char89_stroke0 },
-   { 2, char89_stroke1 },
-};
-
-/* char: 90 'Z' */
-
-static const CoordRec char90_stroke0[] = {
-    { 69.1667, 100 },
-    { 2.5, 0 },
-};
-
-static const CoordRec char90_stroke1[] = {
-    { 2.5, 100 },
-    { 69.1667, 100 },
-};
-
-static const CoordRec char90_stroke2[] = {
-    { 2.5, 0 },
-    { 69.1667, 0 },
-};
-
-static const StrokeRec char90[] = {
-   { 2, char90_stroke0 },
-   { 2, char90_stroke1 },
-   { 2, char90_stroke2 },
-};
-
-/* char: 91 '[' */
-
-static const CoordRec char91_stroke0[] = {
-    { 7.78, 119.048 },
-    { 7.78, -33.3333 },
-};
-
-static const CoordRec char91_stroke1[] = {
-    { 12.5419, 119.048 },
-    { 12.5419, -33.3333 },
-};
-
-static const CoordRec char91_stroke2[] = {
-    { 7.78, 119.048 },
-    { 41.1133, 119.048 },
-};
-
-static const CoordRec char91_stroke3[] = {
-    { 7.78, -33.3333 },
-    { 41.1133, -33.3333 },
-};
-
-static const StrokeRec char91[] = {
-   { 2, char91_stroke0 },
-   { 2, char91_stroke1 },
-   { 2, char91_stroke2 },
-   { 2, char91_stroke3 },
-};
-
-/* char: 92 '\' */
-
-static const CoordRec char92_stroke0[] = {
-    { 5.84, 100 },
-    { 72.5067, -14.2857 },
-};
-
-static const StrokeRec char92[] = {
-   { 2, char92_stroke0 },
-};
-
-/* char: 93 ']' */
-
-static const CoordRec char93_stroke0[] = {
-    { 33.0114, 119.048 },
-    { 33.0114, -33.3333 },
-};
-
-static const CoordRec char93_stroke1[] = {
-    { 37.7733, 119.048 },
-    { 37.7733, -33.3333 },
-};
-
-static const CoordRec char93_stroke2[] = {
-    { 4.44, 119.048 },
-    { 37.7733, 119.048 },
-};
-
-static const CoordRec char93_stroke3[] = {
-    { 4.44, -33.3333 },
-    { 37.7733, -33.3333 },
-};
-
-static const StrokeRec char93[] = {
-   { 2, char93_stroke0 },
-   { 2, char93_stroke1 },
-   { 2, char93_stroke2 },
-   { 2, char93_stroke3 },
-};
-
-/* char: 94 '^' */
-
-static const CoordRec char94_stroke0[] = {
-    { 44.0752, 109.524 },
-    { 5.98, 42.8571 },
-};
-
-static const CoordRec char94_stroke1[] = {
-    { 44.0752, 109.524 },
-    { 82.1705, 42.8571 },
-};
-
-static const StrokeRec char94[] = {
-   { 2, char94_stroke0 },
-   { 2, char94_stroke1 },
-};
-
-/* char: 95 '_' */
-
-static const CoordRec char95_stroke0[] = {
-    { -1.1, -33.3333 },
-    { 103.662, -33.3333 },
-    { 103.662, -28.5714 },
-    { -1.1, -28.5714 },
-    { -1.1, -33.3333 },
-};
-
-static const StrokeRec char95[] = {
-   { 5, char95_stroke0 },
-};
-
-/* char: 96 '`' */
-
-static const CoordRec char96_stroke0[] = {
-    { 33.0219, 100 },
-    { 56.8314, 71.4286 },
-};
-
-static const CoordRec char96_stroke1[] = {
-    { 33.0219, 100 },
-    { 28.26, 95.2381 },
-    { 56.8314, 71.4286 },
-};
-
-static const StrokeRec char96[] = {
-   { 2, char96_stroke0 },
-   { 3, char96_stroke1 },
-};
-
-/* char: 97 'a' */
-
-static const CoordRec char97_stroke0[] = {
-    { 63.8229, 66.6667 },
-    { 63.8229, 0 },
-};
-
-static const CoordRec char97_stroke1[] = {
-    { 63.8229, 52.381 },
-    { 54.299, 61.9048 },
-    { 44.7752, 66.6667 },
-    { 30.4895, 66.6667 },
-    { 20.9657, 61.9048 },
-    { 11.4419, 52.381 },
-    { 6.68, 38.0952 },
-    { 6.68, 28.5714 },
-    { 11.4419, 14.2857 },
-    { 20.9657, 4.7619 },
-    { 30.4895, 0 },
-    { 44.7752, 0 },
-    { 54.299, 4.7619 },
-    { 63.8229, 14.2857 },
-};
-
-static const StrokeRec char97[] = {
-   { 2, char97_stroke0 },
-   { 14, char97_stroke1 },
-};
-
-/* char: 98 'b' */
-
-static const CoordRec char98_stroke0[] = {
-    { 8.76, 100 },
-    { 8.76, 0 },
-};
-
-static const CoordRec char98_stroke1[] = {
-    { 8.76, 52.381 },
-    { 18.2838, 61.9048 },
-    { 27.8076, 66.6667 },
-    { 42.0933, 66.6667 },
-    { 51.6171, 61.9048 },
-    { 61.141, 52.381 },
-    { 65.9029, 38.0952 },
-    { 65.9029, 28.5714 },
-    { 61.141, 14.2857 },
-    { 51.6171, 4.7619 },
-    { 42.0933, 0 },
-    { 27.8076, 0 },
-    { 18.2838, 4.7619 },
-    { 8.76, 14.2857 },
-};
-
-static const StrokeRec char98[] = {
-   { 2, char98_stroke0 },
-   { 14, char98_stroke1 },
-};
-
-/* char: 99 'c' */
-
-static const CoordRec char99_stroke0[] = {
-    { 62.6629, 52.381 },
-    { 53.139, 61.9048 },
-    { 43.6152, 66.6667 },
-    { 29.3295, 66.6667 },
-    { 19.8057, 61.9048 },
-    { 10.2819, 52.381 },
-    { 5.52, 38.0952 },
-    { 5.52, 28.5714 },
-    { 10.2819, 14.2857 },
-    { 19.8057, 4.7619 },
-    { 29.3295, 0 },
-    { 43.6152, 0 },
-    { 53.139, 4.7619 },
-    { 62.6629, 14.2857 },
-};
-
-static const StrokeRec char99[] = {
-   { 14, char99_stroke0 },
-};
-
-/* char: 100 'd' */
-
-static const CoordRec char100_stroke0[] = {
-    { 61.7829, 100 },
-    { 61.7829, 0 },
-};
-
-static const CoordRec char100_stroke1[] = {
-    { 61.7829, 52.381 },
-    { 52.259, 61.9048 },
-    { 42.7352, 66.6667 },
-    { 28.4495, 66.6667 },
-    { 18.9257, 61.9048 },
-    { 9.4019, 52.381 },
-    { 4.64, 38.0952 },
-    { 4.64, 28.5714 },
-    { 9.4019, 14.2857 },
-    { 18.9257, 4.7619 },
-    { 28.4495, 0 },
-    { 42.7352, 0 },
-    { 52.259, 4.7619 },
-    { 61.7829, 14.2857 },
-};
-
-static const StrokeRec char100[] = {
-   { 2, char100_stroke0 },
-   { 14, char100_stroke1 },
-};
-
-/* char: 101 'e' */
-
-static const CoordRec char101_stroke0[] = {
-    { 5.72, 38.0952 },
-    { 62.8629, 38.0952 },
-    { 62.8629, 47.619 },
-    { 58.101, 57.1429 },
-    { 53.339, 61.9048 },
-    { 43.8152, 66.6667 },
-    { 29.5295, 66.6667 },
-    { 20.0057, 61.9048 },
-    { 10.4819, 52.381 },
-    { 5.72, 38.0952 },
-    { 5.72, 28.5714 },
-    { 10.4819, 14.2857 },
-    { 20.0057, 4.7619 },
-    { 29.5295, 0 },
-    { 43.8152, 0 },
-    { 53.339, 4.7619 },
-    { 62.8629, 14.2857 },
-};
-
-static const StrokeRec char101[] = {
-   { 17, char101_stroke0 },
-};
-
-/* char: 102 'f' */
-
-static const CoordRec char102_stroke0[] = {
-    { 38.7752, 100 },
-    { 29.2514, 100 },
-    { 19.7276, 95.2381 },
-    { 14.9657, 80.9524 },
-    { 14.9657, 0 },
-};
-
-static const CoordRec char102_stroke1[] = {
-    { 0.68, 66.6667 },
-    { 34.0133, 66.6667 },
-};
-
-static const StrokeRec char102[] = {
-   { 5, char102_stroke0 },
-   { 2, char102_stroke1 },
-};
-
-/* char: 103 'g' */
-
-static const CoordRec char103_stroke0[] = {
-    { 62.5029, 66.6667 },
-    { 62.5029, -9.5238 },
-    { 57.741, -23.8095 },
-    { 52.979, -28.5714 },
-    { 43.4552, -33.3333 },
-    { 29.1695, -33.3333 },
-    { 19.6457, -28.5714 },
-};
-
-static const CoordRec char103_stroke1[] = {
-    { 62.5029, 52.381 },
-    { 52.979, 61.9048 },
-    { 43.4552, 66.6667 },
-    { 29.1695, 66.6667 },
-    { 19.6457, 61.9048 },
-    { 10.1219, 52.381 },
-    { 5.36, 38.0952 },
-    { 5.36, 28.5714 },
-    { 10.1219, 14.2857 },
-    { 19.6457, 4.7619 },
-    { 29.1695, 0 },
-    { 43.4552, 0 },
-    { 52.979, 4.7619 },
-    { 62.5029, 14.2857 },
-};
-
-static const StrokeRec char103[] = {
-   { 7, char103_stroke0 },
-   { 14, char103_stroke1 },
-};
-
-/* char: 104 'h' */
-
-static const CoordRec char104_stroke0[] = {
-    { 9.6, 100 },
-    { 9.6, 0 },
-};
-
-static const CoordRec char104_stroke1[] = {
-    { 9.6, 47.619 },
-    { 23.8857, 61.9048 },
-    { 33.4095, 66.6667 },
-    { 47.6952, 66.6667 },
-    { 57.219, 61.9048 },
-    { 61.981, 47.619 },
-    { 61.981, 0 },
-};
-
-static const StrokeRec char104[] = {
-   { 2, char104_stroke0 },
-   { 7, char104_stroke1 },
-};
-
-/* char: 105 'i' */
-
-static const CoordRec char105_stroke0[] = {
-    { 10.02, 100 },
-    { 14.7819, 95.2381 },
-    { 19.5438, 100 },
-    { 14.7819, 104.762 },
-    { 10.02, 100 },
-};
-
-static const CoordRec char105_stroke1[] = {
-    { 14.7819, 66.6667 },
-    { 14.7819, 0 },
-};
-
-static const StrokeRec char105[] = {
-   { 5, char105_stroke0 },
-   { 2, char105_stroke1 },
-};
-
-/* char: 106 'j' */
-
-static const CoordRec char106_stroke0[] = {
-    { 17.3876, 100 },
-    { 22.1495, 95.2381 },
-    { 26.9114, 100 },
-    { 22.1495, 104.762 },
-    { 17.3876, 100 },
-};
-
-static const CoordRec char106_stroke1[] = {
-    { 22.1495, 66.6667 },
-    { 22.1495, -14.2857 },
-    { 17.3876, -28.5714 },
-    { 7.8638, -33.3333 },
-    { -1.66, -33.3333 },
-};
-
-static const StrokeRec char106[] = {
-   { 5, char106_stroke0 },
-   { 5, char106_stroke1 },
-};
-
-/* char: 107 'k' */
-
-static const CoordRec char107_stroke0[] = {
-    { 9.6, 100 },
-    { 9.6, 0 },
-};
-
-static const CoordRec char107_stroke1[] = {
-    { 57.219, 66.6667 },
-    { 9.6, 19.0476 },
-};
-
-static const CoordRec char107_stroke2[] = {
-    { 28.6476, 38.0952 },
-    { 61.981, 0 },
-};
-
-static const StrokeRec char107[] = {
-   { 2, char107_stroke0 },
-   { 2, char107_stroke1 },
-   { 2, char107_stroke2 },
-};
-
-/* char: 108 'l' */
-
-static const CoordRec char108_stroke0[] = {
-    { 10.02, 100 },
-    { 10.02, 0 },
-};
-
-static const StrokeRec char108[] = {
-   { 2, char108_stroke0 },
-};
-
-/* char: 109 'm' */
-
-static const CoordRec char109_stroke0[] = {
-    { 9.6, 66.6667 },
-    { 9.6, 0 },
-};
-
-static const CoordRec char109_stroke1[] = {
-    { 9.6, 47.619 },
-    { 23.8857, 61.9048 },
-    { 33.4095, 66.6667 },
-    { 47.6952, 66.6667 },
-    { 57.219, 61.9048 },
-    { 61.981, 47.619 },
-    { 61.981, 0 },
-};
-
-static const CoordRec char109_stroke2[] = {
-    { 61.981, 47.619 },
-    { 76.2667, 61.9048 },
-    { 85.7905, 66.6667 },
-    { 100.076, 66.6667 },
-    { 109.6, 61.9048 },
-    { 114.362, 47.619 },
-    { 114.362, 0 },
-};
-
-static const StrokeRec char109[] = {
-   { 2, char109_stroke0 },
-   { 7, char109_stroke1 },
-   { 7, char109_stroke2 },
-};
-
-/* char: 110 'n' */
-
-static const CoordRec char110_stroke0[] = {
-    { 9.18, 66.6667 },
-    { 9.18, 0 },
-};
-
-static const CoordRec char110_stroke1[] = {
-    { 9.18, 47.619 },
-    { 23.4657, 61.9048 },
-    { 32.9895, 66.6667 },
-    { 47.2752, 66.6667 },
-    { 56.799, 61.9048 },
-    { 61.561, 47.619 },
-    { 61.561, 0 },
-};
-
-static const StrokeRec char110[] = {
-   { 2, char110_stroke0 },
-   { 7, char110_stroke1 },
-};
-
-/* char: 111 'o' */
-
-static const CoordRec char111_stroke0[] = {
-    { 28.7895, 66.6667 },
-    { 19.2657, 61.9048 },
-    { 9.7419, 52.381 },
-    { 4.98, 38.0952 },
-    { 4.98, 28.5714 },
-    { 9.7419, 14.2857 },
-    { 19.2657, 4.7619 },
-    { 28.7895, 0 },
-    { 43.0752, 0 },
-    { 52.599, 4.7619 },
-    { 62.1229, 14.2857 },
-    { 66.8848, 28.5714 },
-    { 66.8848, 38.0952 },
-    { 62.1229, 52.381 },
-    { 52.599, 61.9048 },
-    { 43.0752, 66.6667 },
-    { 28.7895, 66.6667 },
-};
-
-static const StrokeRec char111[] = {
-   { 17, char111_stroke0 },
-};
-
-/* char: 112 'p' */
-
-static const CoordRec char112_stroke0[] = {
-    { 9.46, 66.6667 },
-    { 9.46, -33.3333 },
-};
-
-static const CoordRec char112_stroke1[] = {
-    { 9.46, 52.381 },
-    { 18.9838, 61.9048 },
-    { 28.5076, 66.6667 },
-    { 42.7933, 66.6667 },
-    { 52.3171, 61.9048 },
-    { 61.841, 52.381 },
-    { 66.6029, 38.0952 },
-    { 66.6029, 28.5714 },
-    { 61.841, 14.2857 },
-    { 52.3171, 4.7619 },
-    { 42.7933, 0 },
-    { 28.5076, 0 },
-    { 18.9838, 4.7619 },
-    { 9.46, 14.2857 },
-};
-
-static const StrokeRec char112[] = {
-   { 2, char112_stroke0 },
-   { 14, char112_stroke1 },
-};
-
-/* char: 113 'q' */
-
-static const CoordRec char113_stroke0[] = {
-    { 61.9829, 66.6667 },
-    { 61.9829, -33.3333 },
-};
-
-static const CoordRec char113_stroke1[] = {
-    { 61.9829, 52.381 },
-    { 52.459, 61.9048 },
-    { 42.9352, 66.6667 },
-    { 28.6495, 66.6667 },
-    { 19.1257, 61.9048 },
-    { 9.6019, 52.381 },
-    { 4.84, 38.0952 },
-    { 4.84, 28.5714 },
-    { 9.6019, 14.2857 },
-    { 19.1257, 4.7619 },
-    { 28.6495, 0 },
-    { 42.9352, 0 },
-    { 52.459, 4.7619 },
-    { 61.9829, 14.2857 },
-};
-
-static const StrokeRec char113[] = {
-   { 2, char113_stroke0 },
-   { 14, char113_stroke1 },
-};
-
-/* char: 114 'r' */
-
-static const CoordRec char114_stroke0[] = {
-    { 9.46, 66.6667 },
-    { 9.46, 0 },
-};
-
-static const CoordRec char114_stroke1[] = {
-    { 9.46, 38.0952 },
-    { 14.2219, 52.381 },
-    { 23.7457, 61.9048 },
-    { 33.2695, 66.6667 },
-    { 47.5552, 66.6667 },
-};
-
-static const StrokeRec char114[] = {
-   { 2, char114_stroke0 },
-   { 5, char114_stroke1 },
-};
-
-/* char: 115 's' */
-
-static const CoordRec char115_stroke0[] = {
-    { 57.081, 52.381 },
-    { 52.319, 61.9048 },
-    { 38.0333, 66.6667 },
-    { 23.7476, 66.6667 },
-    { 9.4619, 61.9048 },
-    { 4.7, 52.381 },
-    { 9.4619, 42.8571 },
-    { 18.9857, 38.0952 },
-    { 42.7952, 33.3333 },
-    { 52.319, 28.5714 },
-    { 57.081, 19.0476 },
-    { 57.081, 14.2857 },
-    { 52.319, 4.7619 },
-    { 38.0333, 0 },
-    { 23.7476, 0 },
-    { 9.4619, 4.7619 },
-    { 4.7, 14.2857 },
-};
-
-static const StrokeRec char115[] = {
-   { 17, char115_stroke0 },
-};
-
-/* char: 116 't' */
-
-static const CoordRec char116_stroke0[] = {
-    { 14.8257, 100 },
-    { 14.8257, 19.0476 },
-    { 19.5876, 4.7619 },
-    { 29.1114, 0 },
-    { 38.6352, 0 },
-};
-
-static const CoordRec char116_stroke1[] = {
-    { 0.54, 66.6667 },
-    { 33.8733, 66.6667 },
-};
-
-static const StrokeRec char116[] = {
-   { 5, char116_stroke0 },
-   { 2, char116_stroke1 },
-};
-
-/* char: 117 'u' */
-
-static const CoordRec char117_stroke0[] = {
-    { 9.46, 66.6667 },
-    { 9.46, 19.0476 },
-    { 14.2219, 4.7619 },
-    { 23.7457, 0 },
-    { 38.0314, 0 },
-    { 47.5552, 4.7619 },
-    { 61.841, 19.0476 },
-};
-
-static const CoordRec char117_stroke1[] = {
-    { 61.841, 66.6667 },
-    { 61.841, 0 },
-};
-
-static const StrokeRec char117[] = {
-   { 7, char117_stroke0 },
-   { 2, char117_stroke1 },
-};
-
-/* char: 118 'v' */
-
-static const CoordRec char118_stroke0[] = {
-    { 1.8, 66.6667 },
-    { 30.3714, 0 },
-};
-
-static const CoordRec char118_stroke1[] = {
-    { 58.9429, 66.6667 },
-    { 30.3714, 0 },
-};
-
-static const StrokeRec char118[] = {
-   { 2, char118_stroke0 },
-   { 2, char118_stroke1 },
-};
-
-/* char: 119 'w' */
-
-static const CoordRec char119_stroke0[] = {
-    { 2.5, 66.6667 },
-    { 21.5476, 0 },
-};
-
-static const CoordRec char119_stroke1[] = {
-    { 40.5952, 66.6667 },
-    { 21.5476, 0 },
-};
-
-static const CoordRec char119_stroke2[] = {
-    { 40.5952, 66.6667 },
-    { 59.6429, 0 },
-};
-
-static const CoordRec char119_stroke3[] = {
-    { 78.6905, 66.6667 },
-    { 59.6429, 0 },
-};
-
-static const StrokeRec char119[] = {
-   { 2, char119_stroke0 },
-   { 2, char119_stroke1 },
-   { 2, char119_stroke2 },
-   { 2, char119_stroke3 },
-};
-
-/* char: 120 'x' */
-
-static const CoordRec char120_stroke0[] = {
-    { 1.66, 66.6667 },
-    { 54.041, 0 },
-};
-
-static const CoordRec char120_stroke1[] = {
-    { 54.041, 66.6667 },
-    { 1.66, 0 },
-};
-
-static const StrokeRec char120[] = {
-   { 2, char120_stroke0 },
-   { 2, char120_stroke1 },
-};
-
-/* char: 121 'y' */
-
-static const CoordRec char121_stroke0[] = {
-    { 6.5619, 66.6667 },
-    { 35.1333, 0 },
-};
-
-static const CoordRec char121_stroke1[] = {
-    { 63.7048, 66.6667 },
-    { 35.1333, 0 },
-    { 25.6095, -19.0476 },
-    { 16.0857, -28.5714 },
-    { 6.5619, -33.3333 },
-    { 1.8, -33.3333 },
-};
-
-static const StrokeRec char121[] = {
-   { 2, char121_stroke0 },
-   { 6, char121_stroke1 },
-};
-
-/* char: 122 'z' */
-
-static const CoordRec char122_stroke0[] = {
-    { 56.821, 66.6667 },
-    { 4.44, 0 },
-};
-
-static const CoordRec char122_stroke1[] = {
-    { 4.44, 66.6667 },
-    { 56.821, 66.6667 },
-};
-
-static const CoordRec char122_stroke2[] = {
-    { 4.44, 0 },
-    { 56.821, 0 },
-};
-
-static const StrokeRec char122[] = {
-   { 2, char122_stroke0 },
-   { 2, char122_stroke1 },
-   { 2, char122_stroke2 },
-};
-
-/* char: 123 '{' */
-
-static const CoordRec char123_stroke0[] = {
-    { 31.1895, 119.048 },
-    { 21.6657, 114.286 },
-    { 16.9038, 109.524 },
-    { 12.1419, 100 },
-    { 12.1419, 90.4762 },
-    { 16.9038, 80.9524 },
-    { 21.6657, 76.1905 },
-    { 26.4276, 66.6667 },
-    { 26.4276, 57.1429 },
-    { 16.9038, 47.619 },
-};
-
-static const CoordRec char123_stroke1[] = {
-    { 21.6657, 114.286 },
-    { 16.9038, 104.762 },
-    { 16.9038, 95.2381 },
-    { 21.6657, 85.7143 },
-    { 26.4276, 80.9524 },
-    { 31.1895, 71.4286 },
-    { 31.1895, 61.9048 },
-    { 26.4276, 52.381 },
-    { 7.38, 42.8571 },
-    { 26.4276, 33.3333 },
-    { 31.1895, 23.8095 },
-    { 31.1895, 14.2857 },
-    { 26.4276, 4.7619 },
-    { 21.6657, 0 },
-    { 16.9038, -9.5238 },
-    { 16.9038, -19.0476 },
-    { 21.6657, -28.5714 },
-};
-
-static const CoordRec char123_stroke2[] = {
-    { 16.9038, 38.0952 },
-    { 26.4276, 28.5714 },
-    { 26.4276, 19.0476 },
-    { 21.6657, 9.5238 },
-    { 16.9038, 4.7619 },
-    { 12.1419, -4.7619 },
-    { 12.1419, -14.2857 },
-    { 16.9038, -23.8095 },
-    { 21.6657, -28.5714 },
-    { 31.1895, -33.3333 },
-};
-
-static const StrokeRec char123[] = {
-   { 10, char123_stroke0 },
-   { 17, char123_stroke1 },
-   { 10, char123_stroke2 },
-};
-
-/* char: 124 '|' */
-
-static const CoordRec char124_stroke0[] = {
-    { 11.54, 119.048 },
-    { 11.54, -33.3333 },
-};
-
-static const StrokeRec char124[] = {
-   { 2, char124_stroke0 },
-};
-
-/* char: 125 '}' */
-
-static const CoordRec char125_stroke0[] = {
-    { 9.18, 119.048 },
-    { 18.7038, 114.286 },
-    { 23.4657, 109.524 },
-    { 28.2276, 100 },
-    { 28.2276, 90.4762 },
-    { 23.4657, 80.9524 },
-    { 18.7038, 76.1905 },
-    { 13.9419, 66.6667 },
-    { 13.9419, 57.1429 },
-    { 23.4657, 47.619 },
-};
-
-static const CoordRec char125_stroke1[] = {
-    { 18.7038, 114.286 },
-    { 23.4657, 104.762 },
-    { 23.4657, 95.2381 },
-    { 18.7038, 85.7143 },
-    { 13.9419, 80.9524 },
-    { 9.18, 71.4286 },
-    { 9.18, 61.9048 },
-    { 13.9419, 52.381 },
-    { 32.9895, 42.8571 },
-    { 13.9419, 33.3333 },
-    { 9.18, 23.8095 },
-    { 9.18, 14.2857 },
-    { 13.9419, 4.7619 },
-    { 18.7038, 0 },
-    { 23.4657, -9.5238 },
-    { 23.4657, -19.0476 },
-    { 18.7038, -28.5714 },
-};
-
-static const CoordRec char125_stroke2[] = {
-    { 23.4657, 38.0952 },
-    { 13.9419, 28.5714 },
-    { 13.9419, 19.0476 },
-    { 18.7038, 9.5238 },
-    { 23.4657, 4.7619 },
-    { 28.2276, -4.7619 },
-    { 28.2276, -14.2857 },
-    { 23.4657, -23.8095 },
-    { 18.7038, -28.5714 },
-    { 9.18, -33.3333 },
-};
-
-static const StrokeRec char125[] = {
-   { 10, char125_stroke0 },
-   { 17, char125_stroke1 },
-   { 10, char125_stroke2 },
-};
-
-/* char: 126 '~' */
-
-static const CoordRec char126_stroke0[] = {
-    { 2.92, 28.5714 },
-    { 2.92, 38.0952 },
-    { 7.6819, 52.381 },
-    { 17.2057, 57.1429 },
-    { 26.7295, 57.1429 },
-    { 36.2533, 52.381 },
-    { 55.301, 38.0952 },
-    { 64.8248, 33.3333 },
-    { 74.3486, 33.3333 },
-    { 83.8724, 38.0952 },
-    { 88.6343, 47.619 },
-};
-
-static const CoordRec char126_stroke1[] = {
-    { 2.92, 38.0952 },
-    { 7.6819, 47.619 },
-    { 17.2057, 52.381 },
-    { 26.7295, 52.381 },
-    { 36.2533, 47.619 },
-    { 55.301, 33.3333 },
-    { 64.8248, 28.5714 },
-    { 74.3486, 28.5714 },
-    { 83.8724, 33.3333 },
-    { 88.6343, 47.619 },
-    { 88.6343, 57.1429 },
-};
-
-static const StrokeRec char126[] = {
-   { 11, char126_stroke0 },
-   { 11, char126_stroke1 },
-};
-
-/* char: 127 */
-
-static const CoordRec char127_stroke0[] = {
-    { 52.381, 100 },
-    { 14.2857, -33.3333 },
-};
-
-static const CoordRec char127_stroke1[] = {
-    { 28.5714, 66.6667 },
-    { 14.2857, 61.9048 },
-    { 4.7619, 52.381 },
-    { 0, 38.0952 },
-    { 0, 23.8095 },
-    { 4.7619, 14.2857 },
-    { 14.2857, 4.7619 },
-    { 28.5714, 0 },
-    { 38.0952, 0 },
-    { 52.381, 4.7619 },
-    { 61.9048, 14.2857 },
-    { 66.6667, 28.5714 },
-    { 66.6667, 42.8571 },
-    { 61.9048, 52.381 },
-    { 52.381, 61.9048 },
-    { 38.0952, 66.6667 },
-    { 28.5714, 66.6667 },
-};
-
-static const StrokeRec char127[] = {
-   { 2, char127_stroke0 },
-   { 17, char127_stroke1 },
-};
-
-static const StrokeCharRec chars[] = {
-    { 0, /* char0 */ 0, 0, 0 },
-    { 0, /* char1 */ 0, 0, 0 },
-    { 0, /* char2 */ 0, 0, 0 },
-    { 0, /* char3 */ 0, 0, 0 },
-    { 0, /* char4 */ 0, 0, 0 },
-    { 0, /* char5 */ 0, 0, 0 },
-    { 0, /* char6 */ 0, 0, 0 },
-    { 0, /* char7 */ 0, 0, 0 },
-    { 0, /* char8 */ 0, 0, 0 },
-    { 0, /* char9 */ 0, 0, 0 },
-    { 0, /* char10 */ 0, 0, 0 },
-    { 0, /* char11 */ 0, 0, 0 },
-    { 0, /* char12 */ 0, 0, 0 },
-    { 0, /* char13 */ 0, 0, 0 },
-    { 0, /* char14 */ 0, 0, 0 },
-    { 0, /* char15 */ 0, 0, 0 },
-    { 0, /* char16 */ 0, 0, 0 },
-    { 0, /* char17 */ 0, 0, 0 },
-    { 0, /* char18 */ 0, 0, 0 },
-    { 0, /* char19 */ 0, 0, 0 },
-    { 0, /* char20 */ 0, 0, 0 },
-    { 0, /* char21 */ 0, 0, 0 },
-    { 0, /* char22 */ 0, 0, 0 },
-    { 0, /* char23 */ 0, 0, 0 },
-    { 0, /* char24 */ 0, 0, 0 },
-    { 0, /* char25 */ 0, 0, 0 },
-    { 0, /* char26 */ 0, 0, 0 },
-    { 0, /* char27 */ 0, 0, 0 },
-    { 0, /* char28 */ 0, 0, 0 },
-    { 0, /* char29 */ 0, 0, 0 },
-    { 0, /* char30 */ 0, 0, 0 },
-    { 0, /* char31 */ 0, 0, 0 },
-    { 0, /* char32 */ 0, 52.381, 104.762 },
-    { 2, char33, 13.3819, 26.6238 },
-    { 2, char34, 23.0676, 51.4352 },
-    { 4, char35, 36.5333, 79.4886 },
-    { 3, char36, 38.1533, 76.2067 },
-    { 3, char37, 49.2171, 96.5743 },
-    { 1, char38, 53.599, 101.758 },
-    { 1, char39, 4.44, 13.62 },
-    { 1, char40, 21.8657, 47.1733 },
-    { 1, char41, 24.3276, 47.5333 },
-    { 3, char42, 30.7695, 59.439 },
-    { 2, char43, 48.8371, 97.2543 },
-    { 1, char44, 13.5219, 26.0638 },
-    { 1, char45, 50.2371, 100.754 },
-    { 1, char46, 13.1019, 26.4838 },
-    { 1, char47, 40.5733, 82.1067 },
-    { 1, char48, 38.3133, 77.0667 },
-    { 1, char49, 30.8676, 66.5295 },
-    { 1, char50, 38.7533, 77.6467 },
-    { 1, char51, 38.3333, 77.0467 },
-    { 2, char52, 37.2133, 80.1686 },
-    { 1, char53, 38.1933, 77.6867 },
-    { 1, char54, 34.1514, 73.8048 },
-    { 2, char55, 38.8933, 77.2267 },
-    { 1, char56, 38.9333, 77.6667 },
-    { 1, char57, 39.9333, 74.0648 },
-    { 2, char58, 14.0819, 26.2238 },
-    { 2, char59, 12.9619, 26.3038 },
-    { 1, char60, 41.1552, 81.6105 },
-    { 2, char61, 48.5571, 97.2543 },
-    { 1, char62, 40.8752, 81.6105 },
-    { 2, char63, 36.9914, 73.9029 },
-    { 2, char64, 34.9314, 74.3648 },
-    { 3, char65, 40.5952, 80.4905 },
-    { 3, char66, 44.7533, 83.6267 },
-    { 1, char67, 39.9933, 84.4886 },
-    { 2, char68, 45.2933, 85.2867 },
-    { 4, char69, 39.9914, 78.1848 },
-    { 3, char70, 39.9914, 78.7448 },
-    { 2, char71, 40.3933, 89.7686 },
-    { 3, char72, 44.7533, 89.0867 },
-    { 1, char73, 10.86, 21.3 },
-    { 1, char74, 31.0714, 59.999 },
-    { 3, char75, 44.6133, 79.3267 },
-    { 2, char76, 40.2514, 71.3229 },
-    { 4, char77, 48.9552, 97.2105 },
-    { 3, char78, 44.4733, 88.8067 },
-    { 1, char79, 44.3352, 88.8305 },
-    { 2, char80, 45.4333, 85.6667 },
-    { 2, char81, 43.3952, 88.0905 },
-    { 3, char82, 45.0133, 82.3667 },
-    { 1, char83, 41.3333, 80.8267 },
-    { 2, char84, 35.6933, 71.9467 },
-    { 1, char85, 44.8733, 89.4867 },
-    { 2, char86, 40.4552, 81.6105 },
-    { 4, char87, 49.839, 100.518 },
-    { 2, char88, 35.8333, 72.3667 },
-    { 2, char89, 39.6152, 79.6505 },
-    { 3, char90, 35.8333, 73.7467 },
-    { 4, char91, 22.0657, 46.1133 },
-    { 1, char92, 39.1733, 78.2067 },
-    { 4, char93, 23.4876, 46.3933 },
-    { 2, char94, 44.0752, 90.2305 },
-    { 1, char95, 51.281, 104.062 },
-    { 2, char96, 42.5457, 83.5714 },
-    { 2, char97, 35.2514, 66.6029 },
-    { 2, char98, 37.3314, 70.4629 },
-    { 1, char99, 34.0914, 68.9229 },
-    { 2, char100, 33.2114, 70.2629 },
-    { 1, char101, 34.2914, 68.5229 },
-    { 2, char102, 14.9657, 38.6552 },
-    { 2, char103, 33.9314, 70.9829 },
-    { 2, char104, 33.4095, 71.021 },
-    { 2, char105, 14.7819, 28.8638 },
-    { 2, char106, 17.3876, 36.2314 },
-    { 3, char107, 33.4095, 62.521 },
-    { 1, char108, 10.02, 19.34 },
-    { 3, char109, 61.981, 123.962 },
-    { 2, char110, 32.9895, 70.881 },
-    { 1, char111, 33.5514, 71.7448 },
-    { 2, char112, 38.0314, 70.8029 },
-    { 2, char113, 33.4114, 70.7429 },
-    { 2, char114, 23.7457, 49.4952 },
-    { 1, char115, 28.5095, 62.321 },
-    { 2, char116, 14.8257, 39.3152 },
-    { 2, char117, 33.2695, 71.161 },
-    { 2, char118, 30.3714, 60.6029 },
-    { 4, char119, 40.5952, 80.4905 },
-    { 2, char120, 25.4695, 56.401 },
-    { 2, char121, 35.1333, 66.0648 },
-    { 3, char122, 28.2495, 61.821 },
-    { 3, char123, 21.6657, 41.6295 },
-    { 1, char124, 11.54, 23.78 },
-    { 3, char125, 18.7038, 41.4695 },
-    { 2, char126, 45.7771, 91.2743 },
-    { 2, char127, 33.3333, 66.6667 },
-};
-
-GLUTAPI const StrokeFontRec glutStrokeRoman;
-const StrokeFontRec glutStrokeRoman = { "Roman", 128, chars, 119.048, -33.3333 };
-
diff --git a/src/glut/glx/glut_shapes.c b/src/glut/glx/glut_shapes.c
deleted file mode 100644 (file)
index 20e2102..0000000
+++ /dev/null
@@ -1,596 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
-
-/**
-(c) Copyright 1993, Silicon Graphics, Inc.
-
-ALL RIGHTS RESERVED
-
-Permission to use, copy, modify, and distribute this software
-for any purpose and without fee is hereby granted, provided
-that the above copyright notice appear in all copies and that
-both the copyright notice and this permission notice appear in
-supporting documentation, and that the name of Silicon
-Graphics, Inc. not be used in advertising or publicity
-pertaining to distribution of the software without specific,
-written prior permission.
-
-THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
-"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
-OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  IN NO
-EVENT SHALL SILICON GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE
-ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
-INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
-SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
-NOT SILICON GRAPHICS, INC.  HAS BEEN ADVISED OF THE POSSIBILITY
-OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
-US Government Users Restricted Rights
-
-Use, duplication, or disclosure by the Government is subject to
-restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
-(c)(1)(ii) of the Rights in Technical Data and Computer
-Software clause at DFARS 252.227-7013 and/or in similar or
-successor clauses in the FAR or the DOD or NASA FAR
-Supplement.  Unpublished-- rights reserved under the copyright
-laws of the United States.  Contractor/manufacturer is Silicon
-Graphics, Inc., 2011 N.  Shoreline Blvd., Mountain View, CA
-94039-7311.
-
-OpenGL(TM) is a trademark of Silicon Graphics, Inc.
-*/
-
-#include <math.h>
-#include "glutint.h"
-
-/* Some <math.h> files do not define M_PI... */
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-static GLUquadricObj *quadObj;
-
-#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }
-
-static void
-initQuadObj(void)
-{
-  quadObj = gluNewQuadric();
-  if (!quadObj)
-    __glutFatalError("out of memory.");
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
-{
-  QUAD_OBJ_INIT();
-  gluQuadricDrawStyle(quadObj, GLU_LINE);
-  gluQuadricNormals(quadObj, GLU_SMOOTH);
-  /* If we ever changed/used the texture or orientation state
-     of quadObj, we'd need to change it to the defaults here
-     with gluQuadricTexture and/or gluQuadricOrientation. */
-  gluSphere(quadObj, radius, slices, stacks);
-}
-
-void GLUTAPIENTRY
-glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
-{
-  QUAD_OBJ_INIT();
-  gluQuadricDrawStyle(quadObj, GLU_FILL);
-  gluQuadricNormals(quadObj, GLU_SMOOTH);
-  /* If we ever changed/used the texture or orientation state
-     of quadObj, we'd need to change it to the defaults here
-     with gluQuadricTexture and/or gluQuadricOrientation. */
-  gluSphere(quadObj, radius, slices, stacks);
-}
-
-void GLUTAPIENTRY
-glutWireCone(GLdouble base, GLdouble height,
-  GLint slices, GLint stacks)
-{
-  QUAD_OBJ_INIT();
-  gluQuadricDrawStyle(quadObj, GLU_LINE);
-  gluQuadricNormals(quadObj, GLU_SMOOTH);
-  /* If we ever changed/used the texture or orientation state
-     of quadObj, we'd need to change it to the defaults here
-     with gluQuadricTexture and/or gluQuadricOrientation. */
-  gluCylinder(quadObj, base, 0.0, height, slices, stacks);
-}
-
-void GLUTAPIENTRY
-glutSolidCone(GLdouble base, GLdouble height,
-  GLint slices, GLint stacks)
-{
-  QUAD_OBJ_INIT();
-  gluQuadricDrawStyle(quadObj, GLU_FILL);
-  gluQuadricNormals(quadObj, GLU_SMOOTH);
-  /* If we ever changed/used the texture or orientation state
-     of quadObj, we'd need to change it to the defaults here
-     with gluQuadricTexture and/or gluQuadricOrientation. */
-  gluCylinder(quadObj, base, 0.0, height, slices, stacks);
-}
-
-/* ENDCENTRY */
-
-static void
-drawBox(GLfloat size, GLenum type)
-{
-  static GLfloat n[6][3] =
-  {
-    {-1.0, 0.0, 0.0},
-    {0.0, 1.0, 0.0},
-    {1.0, 0.0, 0.0},
-    {0.0, -1.0, 0.0},
-    {0.0, 0.0, 1.0},
-    {0.0, 0.0, -1.0}
-  };
-  static GLint faces[6][4] =
-  {
-    {0, 1, 2, 3},
-    {3, 2, 6, 7},
-    {7, 6, 5, 4},
-    {4, 5, 1, 0},
-    {5, 6, 2, 1},
-    {7, 4, 0, 3}
-  };
-  GLfloat v[8][3];
-  GLint i;
-
-  v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
-  v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
-  v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
-  v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
-  v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
-  v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
-
-  for (i = 5; i >= 0; i--) {
-    glBegin(type);
-    glNormal3fv(&n[i][0]);
-    glVertex3fv(&v[faces[i][0]][0]);
-    glVertex3fv(&v[faces[i][1]][0]);
-    glVertex3fv(&v[faces[i][2]][0]);
-    glVertex3fv(&v[faces[i][3]][0]);
-    glEnd();
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutWireCube(GLdouble size)
-{
-  drawBox(size, GL_LINE_LOOP);
-}
-
-void GLUTAPIENTRY
-glutSolidCube(GLdouble size)
-{
-  drawBox(size, GL_QUADS);
-}
-
-/* ENDCENTRY */
-
-static void
-doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
-{
-  int i, j;
-  GLfloat theta, phi, theta1;
-  GLfloat cosTheta, sinTheta;
-  GLfloat cosTheta1, sinTheta1;
-  GLfloat ringDelta, sideDelta;
-
-  ringDelta = 2.0 * M_PI / rings;
-  sideDelta = 2.0 * M_PI / nsides;
-
-  theta = 0.0;
-  cosTheta = 1.0;
-  sinTheta = 0.0;
-  for (i = rings - 1; i >= 0; i--) {
-    theta1 = theta + ringDelta;
-    cosTheta1 = cos(theta1);
-    sinTheta1 = sin(theta1);
-    glBegin(GL_QUAD_STRIP);
-    phi = 0.0;
-    for (j = nsides; j >= 0; j--) {
-      GLfloat cosPhi, sinPhi, dist;
-
-      phi += sideDelta;
-      cosPhi = cos(phi);
-      sinPhi = sin(phi);
-      dist = R + r * cosPhi;
-
-      glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
-      glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
-      glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
-      glVertex3f(cosTheta * dist, -sinTheta * dist,  r * sinPhi);
-    }
-    glEnd();
-    theta = theta1;
-    cosTheta = cosTheta1;
-    sinTheta = sinTheta1;
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
-  GLint nsides, GLint rings)
-{
-  glPushAttrib(GL_POLYGON_BIT);
-  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-  doughnut(innerRadius, outerRadius, nsides, rings);
-  glPopAttrib();
-}
-
-void GLUTAPIENTRY
-glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius,
-  GLint nsides, GLint rings)
-{
-  doughnut(innerRadius, outerRadius, nsides, rings);
-}
-
-/* ENDCENTRY */
-
-static GLfloat dodec[20][3];
-
-static void
-initDodecahedron(void)
-{
-  GLfloat alpha, beta;
-
-  alpha = sqrt(2.0 / (3.0 + sqrt(5.0)));
-  beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) -
-    2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0))));
-  /* *INDENT-OFF* */
-  dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;
-  dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;
-  dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;
-  dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;
-  dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;
-  dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;
-  dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;
-  dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;
-  dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;
-  dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;
-  dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;
-  dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;
-  dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;
-  dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;
-  dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;
-  dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;
-  dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;
-  dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;
-  dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;
-  dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;
-  /* *INDENT-ON* */
-
-}
-
-#define DIFF3(_a,_b,_c) { \
-    (_c)[0] = (_a)[0] - (_b)[0]; \
-    (_c)[1] = (_a)[1] - (_b)[1]; \
-    (_c)[2] = (_a)[2] - (_b)[2]; \
-}
-
-static void
-crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])
-{
-  GLfloat p[3];         /* in case prod == v1 or v2 */
-
-  p[0] = v1[1] * v2[2] - v2[1] * v1[2];
-  p[1] = v1[2] * v2[0] - v2[2] * v1[0];
-  p[2] = v1[0] * v2[1] - v2[0] * v1[1];
-  prod[0] = p[0];
-  prod[1] = p[1];
-  prod[2] = p[2];
-}
-
-static void
-normalize(GLfloat v[3])
-{
-  GLfloat d;
-
-  d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
-  if (d == 0.0) {
-    __glutWarning("normalize: zero length vector");
-    v[0] = d = 1.0;
-  }
-  d = 1 / d;
-  v[0] *= d;
-  v[1] *= d;
-  v[2] *= d;
-}
-
-static void
-pentagon(int a, int b, int c, int d, int e, GLenum shadeType)
-{
-  GLfloat n0[3], d1[3], d2[3];
-
-  DIFF3(dodec[a], dodec[b], d1);
-  DIFF3(dodec[b], dodec[c], d2);
-  crossprod(d1, d2, n0);
-  normalize(n0);
-
-  glBegin(shadeType);
-  glNormal3fv(n0);
-  glVertex3fv(&dodec[a][0]);
-  glVertex3fv(&dodec[b][0]);
-  glVertex3fv(&dodec[c][0]);
-  glVertex3fv(&dodec[d][0]);
-  glVertex3fv(&dodec[e][0]);
-  glEnd();
-}
-
-static void
-dodecahedron(GLenum type)
-{
-  static int inited = 0;
-
-  if (inited == 0) {
-    inited = 1;
-    initDodecahedron();
-  }
-  pentagon(0, 1, 9, 16, 5, type);
-  pentagon(1, 0, 3, 18, 7, type);
-  pentagon(1, 7, 11, 10, 9, type);
-  pentagon(11, 7, 18, 19, 6, type);
-  pentagon(8, 17, 16, 9, 10, type);
-  pentagon(2, 14, 15, 6, 19, type);
-  pentagon(2, 13, 12, 4, 14, type);
-  pentagon(2, 19, 18, 3, 13, type);
-  pentagon(3, 0, 5, 12, 13, type);
-  pentagon(6, 15, 8, 10, 11, type);
-  pentagon(4, 17, 8, 15, 14, type);
-  pentagon(4, 12, 5, 16, 17, type);
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutWireDodecahedron(void)
-{
-  dodecahedron(GL_LINE_LOOP);
-}
-
-void GLUTAPIENTRY
-glutSolidDodecahedron(void)
-{
-  dodecahedron(GL_TRIANGLE_FAN);
-}
-
-/* ENDCENTRY */
-
-static void
-recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,
-  GLenum shadeType)
-{
-  GLfloat q0[3], q1[3];
-
-  DIFF3(n1, n2, q0);
-  DIFF3(n2, n3, q1);
-  crossprod(q0, q1, q1);
-  normalize(q1);
-
-  glBegin(shadeType);
-  glNormal3fv(q1);
-  glVertex3fv(n1);
-  glVertex3fv(n2);
-  glVertex3fv(n3);
-  glEnd();
-}
-
-static void
-subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2,
-  GLenum shadeType)
-{
-  int depth;
-  GLfloat w0[3], w1[3], w2[3];
-  GLfloat l;
-  int i, j, k, n;
-
-  depth = 1;
-  for (i = 0; i < depth; i++) {
-    for (j = 0; i + j < depth; j++) {
-      k = depth - i - j;
-      for (n = 0; n < 3; n++) {
-        w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;
-        w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])
-          / depth;
-        w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])
-          / depth;
-      }
-      l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);
-      w0[0] /= l;
-      w0[1] /= l;
-      w0[2] /= l;
-      l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);
-      w1[0] /= l;
-      w1[1] /= l;
-      w1[2] /= l;
-      l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);
-      w2[0] /= l;
-      w2[1] /= l;
-      w2[2] /= l;
-      recorditem(w1, w0, w2, shadeType);
-    }
-  }
-}
-
-static void
-drawtriangle(int i, GLfloat data[][3], int ndx[][3],
-  GLenum shadeType)
-{
-  GLfloat *x0, *x1, *x2;
-
-  x0 = data[ndx[i][0]];
-  x1 = data[ndx[i][1]];
-  x2 = data[ndx[i][2]];
-  subdivide(x0, x1, x2, shadeType);
-}
-
-/* octahedron data: The octahedron produced is centered at the
-   origin and has radius 1.0 */
-static GLfloat odata[6][3] =
-{
-  {1.0, 0.0, 0.0},
-  {-1.0, 0.0, 0.0},
-  {0.0, 1.0, 0.0},
-  {0.0, -1.0, 0.0},
-  {0.0, 0.0, 1.0},
-  {0.0, 0.0, -1.0}
-};
-
-static int ondex[8][3] =
-{
-  {0, 4, 2},
-  {1, 2, 4},
-  {0, 3, 4},
-  {1, 4, 3},
-  {0, 2, 5},
-  {1, 5, 2},
-  {0, 5, 3},
-  {1, 3, 5}
-};
-
-static void
-octahedron(GLenum shadeType)
-{
-  int i;
-
-  for (i = 7; i >= 0; i--) {
-    drawtriangle(i, odata, ondex, shadeType);
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutWireOctahedron(void)
-{
-  octahedron(GL_LINE_LOOP);
-}
-
-void GLUTAPIENTRY
-glutSolidOctahedron(void)
-{
-  octahedron(GL_TRIANGLES);
-}
-
-/* ENDCENTRY */
-
-/* icosahedron data: These numbers are rigged to make an
-   icosahedron of radius 1.0 */
-
-#define X .525731112119133606
-#define Z .850650808352039932
-
-static GLfloat idata[12][3] =
-{
-  {-X, 0, Z},
-  {X, 0, Z},
-  {-X, 0, -Z},
-  {X, 0, -Z},
-  {0, Z, X},
-  {0, Z, -X},
-  {0, -Z, X},
-  {0, -Z, -X},
-  {Z, X, 0},
-  {-Z, X, 0},
-  {Z, -X, 0},
-  {-Z, -X, 0}
-};
-
-static int index[20][3] =
-{
-  {0, 4, 1},
-  {0, 9, 4},
-  {9, 5, 4},
-  {4, 5, 8},
-  {4, 8, 1},
-  {8, 10, 1},
-  {8, 3, 10},
-  {5, 3, 8},
-  {5, 2, 3},
-  {2, 7, 3},
-  {7, 10, 3},
-  {7, 6, 10},
-  {7, 11, 6},
-  {11, 0, 6},
-  {0, 1, 6},
-  {6, 1, 10},
-  {9, 0, 11},
-  {9, 11, 2},
-  {9, 2, 5},
-  {7, 2, 11},
-};
-
-static void
-icosahedron(GLenum shadeType)
-{
-  int i;
-
-  for (i = 19; i >= 0; i--) {
-    drawtriangle(i, idata, index, shadeType);
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutWireIcosahedron(void)
-{
-  icosahedron(GL_LINE_LOOP);
-}
-
-void GLUTAPIENTRY
-glutSolidIcosahedron(void)
-{
-  icosahedron(GL_TRIANGLES);
-}
-
-/* ENDCENTRY */
-
-/* tetrahedron data: */
-
-#define T       1.73205080756887729
-
-static GLfloat tdata[4][3] =
-{
-  {T, T, T},
-  {T, -T, -T},
-  {-T, T, -T},
-  {-T, -T, T}
-};
-
-static int tndex[4][3] =
-{
-  {0, 1, 3},
-  {2, 1, 0},
-  {3, 2, 0},
-  {1, 2, 3}
-};
-
-static void
-tetrahedron(GLenum shadeType)
-{
-  int i;
-
-  for (i = 3; i >= 0; i--)
-    drawtriangle(i, tdata, tndex, shadeType);
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutWireTetrahedron(void)
-{
-  tetrahedron(GL_LINE_LOOP);
-}
-
-void GLUTAPIENTRY
-glutSolidTetrahedron(void)
-{
-  tetrahedron(GL_TRIANGLES);
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_space.c b/src/glut/glx/glut_space.c
deleted file mode 100644 (file)
index cde6ea7..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-
-void GLUTAPIENTRY 
-glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc)
-{
-  __glutCurrentWindow->spaceMotion = spaceMotionFunc;
-  __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask;
-  __glutPutOnWorkList(__glutCurrentWindow,
-    GLUT_DEVICE_MASK_WORK);
-}
-
-void GLUTAPIENTRY 
-glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc)
-{
-  __glutCurrentWindow->spaceRotate = spaceRotateFunc;
-  __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask;
-  __glutPutOnWorkList(__glutCurrentWindow,
-    GLUT_DEVICE_MASK_WORK);
-}
-
-void GLUTAPIENTRY 
-glutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc)
-{
-  __glutCurrentWindow->spaceButton = spaceButtonFunc;
-  __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask;
-  __glutPutOnWorkList(__glutCurrentWindow,
-    GLUT_DEVICE_MASK_WORK);
-}
diff --git a/src/glut/glx/glut_stroke.c b/src/glut/glx/glut_stroke.c
deleted file mode 100644 (file)
index 7569012..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-#include "glutstroke.h"
-
-void GLUTAPIENTRY 
-glutStrokeCharacter(GLUTstrokeFont font, int c)
-{
-  const StrokeCharRec *ch;
-  const StrokeRec *stroke;
-  const CoordRec *coord;
-  StrokeFontPtr fontinfo;
-  int i, j;
-
-
-#if defined(_WIN32) || defined(GLUT_IMPORT_LIB)
-  fontinfo = (StrokeFontPtr) __glutFont(font);
-#else
-  fontinfo = (StrokeFontPtr) font;
-#endif
-
-  if (c < 0 || c >= fontinfo->num_chars)
-    return;
-  ch = &(fontinfo->ch[c]);
-  if (ch) {
-    for (i = ch->num_strokes, stroke = ch->stroke;
-      i > 0; i--, stroke++) {
-      glBegin(GL_LINE_STRIP);
-      for (j = stroke->num_coords, coord = stroke->coord;
-        j > 0; j--, coord++) {
-        glVertex2f(coord->x, coord->y);
-      }
-      glEnd();
-    }
-    glTranslatef(ch->right, 0.0, 0.0);
-  }
-}
diff --git a/src/glut/glx/glut_swap.c b/src/glut/glx/glut_swap.c
deleted file mode 100644 (file)
index 07a2da8..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997.  */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdio.h>
-#include "glutint.h"
-
-GLint __glutFPS = 0;
-GLint __glutSwapCount = 0;
-GLint __glutSwapTime = 0;
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutSwapBuffers(void)
-{
-  GLUTwindow *window = __glutCurrentWindow;
-
-  if (__glutPPMFile) {
-     __glutWritePPMFile();
-  }
-
-  if (window->renderWin == window->win) {
-    if (__glutCurrentWindow->treatAsSingle) {
-      /* Pretend the double buffered window is single buffered,
-         so treat glutSwapBuffers as a no-op. */
-      return;
-    }
-  } else {
-    if (__glutCurrentWindow->overlay->treatAsSingle) {
-      /* Pretend the double buffered overlay is single
-         buffered, so treat glutSwapBuffers as a no-op. */
-      return;
-    }
-  }
-
-  /* For the MESA_SWAP_HACK. */
-  window->usedSwapBuffers = 1;
-
-  SWAP_BUFFERS_LAYER(__glutCurrentWindow);
-
-  /* I considered putting the window being swapped on the
-     GLUT_FINISH_WORK work list because you could call
-     glutSwapBuffers from an idle callback which doesn't call
-     __glutSetWindow which normally adds indirect rendering
-     windows to the GLUT_FINISH_WORK work list.  Not being put
-     on the list could lead to the buffering up of multiple
-     redisplays and buffer swaps and hamper interactivity.  I
-     consider this an application bug due to not using
-     glutPostRedisplay to trigger redraws.  If
-     glutPostRedisplay were used, __glutSetWindow would be
-     called and a glFinish to throttle buffering would occur. */
-
-  if (__glutFPS) {
-     GLint t = glutGet(GLUT_ELAPSED_TIME);
-     __glutSwapCount++;
-     if (__glutSwapTime == 0)
-        __glutSwapTime = t;
-     else if (t - __glutSwapTime > __glutFPS) {
-        float time = 0.001 * (t - __glutSwapTime);
-        float fps = (float) __glutSwapCount / time;
-        fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n",
-                __glutSwapCount, time, fps);
-        __glutSwapTime = t;
-        __glutSwapCount = 0;
-     }
-  }
-}
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_swidth.c b/src/glut/glx/glut_swidth.c
deleted file mode 100644 (file)
index 4717bbf..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1995. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-#include "glutstroke.h"
-
-/* CENTRY */
-int GLUTAPIENTRY 
-glutStrokeWidth(GLUTstrokeFont font, int c)
-{
-  StrokeFontPtr fontinfo;
-  const StrokeCharRec *ch;
-
-#if defined(_WIN32) || defined(GLUT_IMPORT_LIB)
-  fontinfo = (StrokeFontPtr) __glutFont(font);
-#else
-  fontinfo = (StrokeFontPtr) font;
-#endif
-
-  if (c < 0 || c >= fontinfo->num_chars)
-    return 0;
-  ch = &(fontinfo->ch[c]);
-  if (ch)
-    return ch->right;
-  else
-    return 0;
-}
-
-int GLUTAPIENTRY 
-glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
-{
-  int c, length;
-  StrokeFontPtr fontinfo;
-  const StrokeCharRec *ch;
-
-#if defined(_WIN32) || defined(GLUT_IMPORT_LIB)
-  fontinfo = (StrokeFontPtr) __glutFont(font);
-#else
-  fontinfo = (StrokeFontPtr) font;
-#endif
-
-  length = 0;
-  for (; *string != '\0'; string++) {
-    c = *string;
-    if (c >= 0 && c < fontinfo->num_chars) {
-      ch = &(fontinfo->ch[c]);
-      if (ch)
-        length += ch->right;
-    }
-  }
-  return length;
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_tablet.c b/src/glut/glx/glut_tablet.c
deleted file mode 100644 (file)
index 80c6828..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-
-#include "glutint.h"
-
-void GLUTAPIENTRY 
-glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc)
-{
-  __glutCurrentWindow->tabletMotion = tabletMotionFunc;
-  __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask;
-  __glutPutOnWorkList(__glutCurrentWindow,
-    GLUT_DEVICE_MASK_WORK);
-  /* If deinstalling callback, invalidate tablet position. */
-  if (tabletMotionFunc == NULL) {
-    __glutCurrentWindow->tabletPos[0] = -1;
-    __glutCurrentWindow->tabletPos[1] = -1;
-  }
-}
-
-void GLUTAPIENTRY 
-glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc)
-{
-  __glutCurrentWindow->tabletButton = tabletButtonFunc;
-  __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask;
-  __glutPutOnWorkList(__glutCurrentWindow,
-    GLUT_DEVICE_MASK_WORK);
-}
diff --git a/src/glut/glx/glut_teapot.c b/src/glut/glx/glut_teapot.c
deleted file mode 100644 (file)
index ff46d96..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/**
-(c) Copyright 1993, Silicon Graphics, Inc.
-
-ALL RIGHTS RESERVED
-
-Permission to use, copy, modify, and distribute this software
-for any purpose and without fee is hereby granted, provided
-that the above copyright notice appear in all copies and that
-both the copyright notice and this permission notice appear in
-supporting documentation, and that the name of Silicon
-Graphics, Inc. not be used in advertising or publicity
-pertaining to distribution of the software without specific,
-written prior permission.
-
-THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
-"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
-OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  IN NO
-EVENT SHALL SILICON GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE
-ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
-INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
-SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
-NOT SILICON GRAPHICS, INC.  HAS BEEN ADVISED OF THE POSSIBILITY
-OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
-US Government Users Restricted Rights
-
-Use, duplication, or disclosure by the Government is subject to
-restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
-(c)(1)(ii) of the Rights in Technical Data and Computer
-Software clause at DFARS 252.227-7013 and/or in similar or
-successor clauses in the FAR or the DOD or NASA FAR
-Supplement.  Unpublished-- rights reserved under the copyright
-laws of the United States.  Contractor/manufacturer is Silicon
-Graphics, Inc., 2011 N.  Shoreline Blvd., Mountain View, CA
-94039-7311.
-
-OpenGL(TM) is a trademark of Silicon Graphics, Inc.
-*/
-
-#include "glutint.h"
-
-/* Rim, body, lid, and bottom data must be reflected in x and
-   y; handle and spout data across the y axis only.  */
-
-static int patchdata[][16] =
-{
-    /* rim */
-  {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
-    12, 13, 14, 15},
-    /* body */
-  {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
-    24, 25, 26, 27},
-  {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
-    37, 38, 39, 40},
-    /* lid */
-  {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
-    101, 0, 1, 2, 3,},
-  {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
-    113, 114, 115, 116, 117},
-    /* bottom */
-  {118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
-    125, 120, 40, 39, 38, 37},
-    /* handle */
-  {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
-    53, 54, 55, 56},
-  {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
-    28, 65, 66, 67},
-    /* spout */
-  {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
-    80, 81, 82, 83},
-  {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
-    92, 93, 94, 95}
-};
-/* *INDENT-OFF* */
-
-static float cpdata[][3] =
-{
-    {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,
-    -0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
-    {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,
-    0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,
-    2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,
-    2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},
-    {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,
-    1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
-    {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,
-    0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,
-    0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},
-    {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},
-    {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,
-    -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,
-    -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,
-    2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,
-    2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,
-    2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},
-    {-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,
-    -0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,
-    1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,
-    -0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,
-    1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,
-    0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,
-    0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
-    {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,
-    -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,
-    2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
-    {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
-    {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
-    {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,
-    3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,
-    3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,
-    -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,
-    2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,
-    2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,
-    2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},
-    {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,
-    -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,
-    0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
-    {0.84, -1.5, 0.075}
-};
-
-static float tex[2][2][2] =
-{
-  { {0, 0},
-    {1, 0}},
-  { {0, 1},
-    {1, 1}}
-};
-
-/* *INDENT-ON* */
-
-static void
-teapot(GLint grid, GLdouble scale, GLenum type)
-{
-  float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
-  long i, j, k, l;
-
-  glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
-  glEnable(GL_AUTO_NORMAL);
-  glEnable(GL_NORMALIZE);
-  glEnable(GL_MAP2_VERTEX_3);
-  glEnable(GL_MAP2_TEXTURE_COORD_2);
-  glPushMatrix();
-  glRotatef(270.0, 1.0, 0.0, 0.0);
-  glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
-  glTranslatef(0.0, 0.0, -1.5);
-  for (i = 0; i < 10; i++) {
-    for (j = 0; j < 4; j++) {
-      for (k = 0; k < 4; k++) {
-        for (l = 0; l < 3; l++) {
-          p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
-          q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
-          if (l == 1)
-            q[j][k][l] *= -1.0;
-          if (i < 6) {
-            r[j][k][l] =
-              cpdata[patchdata[i][j * 4 + (3 - k)]][l];
-            if (l == 0)
-              r[j][k][l] *= -1.0;
-            s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
-            if (l == 0)
-              s[j][k][l] *= -1.0;
-            if (l == 1)
-              s[j][k][l] *= -1.0;
-          }
-        }
-      }
-    }
-    glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
-      &tex[0][0][0]);
-    glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
-      &p[0][0][0]);
-    glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
-    glEvalMesh2(type, 0, grid, 0, grid);
-    glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
-      &q[0][0][0]);
-    glEvalMesh2(type, 0, grid, 0, grid);
-    if (i < 6) {
-      glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
-        &r[0][0][0]);
-      glEvalMesh2(type, 0, grid, 0, grid);
-      glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
-        &s[0][0][0]);
-      glEvalMesh2(type, 0, grid, 0, grid);
-    }
-  }
-  glPopMatrix();
-  glPopAttrib();
-}
-
-/* CENTRY */
-void GLUTAPIENTRY 
-glutSolidTeapot(GLdouble scale)
-{
-  teapot(7, scale, GL_FILL);
-}
-
-void GLUTAPIENTRY 
-glutWireTeapot(GLdouble scale)
-{
-  teapot(10, scale, GL_LINE);
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_tr10.c b/src/glut/glx/glut_tr10.c
deleted file mode 100644 (file)
index dbf5ebd..0000000
+++ /dev/null
@@ -1,1778 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapTimesRoman10 XXX
-#include "glutbitmap.h"
-#undef glutBitmapTimesRoman10
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0x80,0xc0,0x40,0x60,0xa0,0x90,0xb8,0x0,0xa0,
-};
-
-static const BitmapCharRec ch255 = {5,9,0,2,5,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0xc0,0x80,0xe0,0x90,0x90,0x90,0xe0,0x80,0x80,
-};
-
-static const BitmapCharRec ch254 = {4,9,0,2,5,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0x80,0xc0,0x40,0x60,0xa0,0x90,0xb8,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch253 = {5,10,0,2,5,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x68,0x90,0x90,0x90,0x90,0x0,0x50,
-};
-
-static const BitmapCharRec ch252 = {5,7,0,0,5,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x68,0x90,0x90,0x90,0x90,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch251 = {5,8,0,0,5,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x68,0x90,0x90,0x90,0x90,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch250 = {5,8,0,0,5,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x68,0x90,0x90,0x90,0x90,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch249 = {5,8,0,0,5,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0x80,0x70,0x48,0x48,0x48,0x38,0x4,
-};
-
-static const BitmapCharRec ch248 = {6,7,1,1,5,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x20,0x0,0xf8,0x0,0x20,
-};
-
-static const BitmapCharRec ch247 = {5,5,0,0,6,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0xa0,
-};
-
-static const BitmapCharRec ch246 = {4,7,0,0,5,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch245 = {4,8,0,0,5,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch244 = {4,8,0,0,5,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch243 = {4,8,0,0,5,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x60,0x90,0x90,0x90,0x60,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch242 = {4,8,0,0,5,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0xd8,0x90,0x90,0x90,0xe0,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch241 = {5,8,0,0,5,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x60,0x90,0x90,0x90,0x70,0xa0,0x70,0x40,
-};
-
-static const BitmapCharRec ch240 = {4,8,0,0,5,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x0,0xa0,
-};
-
-static const BitmapCharRec ch239 = {3,7,0,0,4,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch238 = {3,8,0,0,4,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch237 = {3,8,0,0,4,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0xe0,0x40,0x40,0x40,0xc0,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch236 = {3,8,0,0,4,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x60,0x80,0xc0,0xa0,0x60,0x0,0xa0,
-};
-
-static const BitmapCharRec ch235 = {3,7,0,0,4,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x60,0x80,0xc0,0xa0,0x60,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch234 = {3,8,0,0,4,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x60,0x80,0xc0,0xa0,0x60,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch233 = {3,8,0,0,4,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x60,0x80,0xc0,0xa0,0x60,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch232 = {3,8,0,0,4,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0xc0,0x20,0x40,0x60,0x80,0x80,0x80,0x60,
-};
-
-static const BitmapCharRec ch231 = {3,8,0,3,4,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0xd8,0xa0,0x70,0x28,0xd8,
-};
-
-static const BitmapCharRec ch230 = {5,5,0,0,6,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x40,0xa0,0x40,
-};
-
-static const BitmapCharRec ch229 = {3,8,0,0,4,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0xa0,
-};
-
-static const BitmapCharRec ch228 = {3,7,0,0,4,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch227 = {4,8,0,0,4,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch226 = {3,8,0,0,4,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch225 = {3,8,0,0,4,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch224 = {3,8,0,0,4,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xe0,0x50,0x50,0x60,0x50,0x50,0x20,
-};
-
-static const BitmapCharRec ch223 = {4,7,0,0,5,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0xe0,0x40,0x70,0x48,0x70,0x40,0xe0,
-};
-
-static const BitmapCharRec ch222 = {5,7,0,0,6,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x38,0x10,0x10,0x28,0x28,0x44,0xee,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch221 = {7,10,0,0,8,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,0x0,0x28,
-};
-
-static const BitmapCharRec ch220 = {7,9,0,0,8,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch219 = {7,10,0,0,8,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch218 = {7,10,0,0,8,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch217 = {7,10,0,0,8,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x80,0x7c,0x66,0x52,0x52,0x4a,0x66,0x3e,0x1,
-};
-
-static const BitmapCharRec ch216 = {8,9,0,1,8,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x88,0x50,0x20,0x50,0x88,
-};
-
-static const BitmapCharRec ch215 = {5,5,0,0,6,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x50,
-};
-
-static const BitmapCharRec ch214 = {6,9,0,0,7,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch213 = {6,10,0,0,7,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch212 = {6,10,0,0,7,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch211 = {6,10,0,0,7,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch210 = {6,10,0,0,7,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0xe4,0x4c,0x4c,0x54,0x54,0x64,0xee,0x0,0x50,0x28,
-};
-
-static const BitmapCharRec ch209 = {7,10,0,0,8,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0xf8,0x4c,0x44,0xe4,0x44,0x4c,0xf8,
-};
-
-static const BitmapCharRec ch208 = {6,7,0,0,7,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,0x0,0xa0,
-};
-
-static const BitmapCharRec ch207 = {3,9,0,0,4,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,0x0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch206 = {3,10,0,0,4,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,0x0,0x40,0x20,
-};
-
-static const BitmapCharRec ch205 = {3,10,0,0,4,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,0x0,0x40,0x80,
-};
-
-static const BitmapCharRec ch204 = {3,10,0,0,4,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,0x0,0x50,
-};
-
-static const BitmapCharRec ch203 = {5,9,0,0,6,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,0x0,0x50,0x20,
-};
-
-static const BitmapCharRec ch202 = {5,10,0,0,6,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,0x0,0x20,0x10,
-};
-
-static const BitmapCharRec ch201 = {5,10,0,0,6,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,0x0,0x20,0x40,
-};
-
-static const BitmapCharRec ch200 = {5,10,0,0,6,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x60,0x10,0x20,0x78,0xc4,0x80,0x80,0x80,0xc4,0x7c,
-};
-
-static const BitmapCharRec ch199 = {6,10,0,3,7,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0xef,0x49,0x78,0x2e,0x28,0x39,0x1f,
-};
-
-static const BitmapCharRec ch198 = {8,7,0,0,9,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x10,0x28,0x10,
-};
-
-static const BitmapCharRec ch197 = {7,10,0,0,8,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x28,
-};
-
-static const BitmapCharRec ch196 = {7,9,0,0,8,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x28,0x14,
-};
-
-static const BitmapCharRec ch195 = {7,10,0,0,8,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x28,0x10,
-};
-
-static const BitmapCharRec ch194 = {7,10,0,0,8,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x10,0x8,
-};
-
-static const BitmapCharRec ch193 = {7,10,0,0,8,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,0x0,0x10,0x20,
-};
-
-static const BitmapCharRec ch192 = {7,10,0,0,8,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0xe0,0xa0,0x80,0x40,0x40,0x0,0x40,
-};
-
-static const BitmapCharRec ch191 = {3,7,0,2,4,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x44,0x3e,0x2c,0xd4,0x28,0x48,0xe4,
-};
-
-static const BitmapCharRec ch190 = {7,7,0,0,8,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x4e,0x24,0x2a,0xf6,0x48,0xc8,0x44,
-};
-
-static const BitmapCharRec ch189 = {7,7,0,0,8,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x44,0x3e,0x2c,0xf4,0x48,0xc8,0x44,
-};
-
-static const BitmapCharRec ch188 = {7,7,0,0,8,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0xa0,0x50,0x50,0xa0,
-};
-
-static const BitmapCharRec ch187 = {4,4,0,-1,5,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xe0,0x0,0x40,0xa0,0x40,
-};
-
-static const BitmapCharRec ch186 = {3,5,0,-2,4,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0xe0,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch185 = {3,4,0,-3,3,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0xc0,0x20,0x40,
-};
-
-static const BitmapCharRec ch184 = {3,3,0,3,4,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch183 = {1,1,0,-2,2,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,0x7c,
-};
-
-static const BitmapCharRec ch182 = {6,9,0,2,6,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x80,0x80,0xe8,0x90,0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch181 = {5,7,0,2,5,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x40,
-};
-
-static const BitmapCharRec ch180 = {2,2,0,-5,3,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0xc0,0x20,0x40,0xe0,
-};
-
-static const BitmapCharRec ch179 = {3,4,0,-3,3,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xe0,0x40,0xa0,0x60,
-};
-
-static const BitmapCharRec ch178 = {3,4,0,-3,3,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xf8,0x0,0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch177 = {5,7,0,0,6,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch176 = {4,4,0,-3,4,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xe0,
-};
-
-static const BitmapCharRec ch175 = {3,1,0,-6,4,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x38,0x44,0xaa,0xb2,0xba,0x44,0x38,
-};
-
-static const BitmapCharRec ch174 = {7,7,-1,0,9,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xe0,
-};
-
-static const BitmapCharRec ch173 = {3,1,0,-2,4,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x8,0x8,0xf8,
-};
-
-static const BitmapCharRec ch172 = {5,3,-1,-1,7,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x50,0xa0,0xa0,0x50,
-};
-
-static const BitmapCharRec ch171 = {4,4,0,-1,5,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0xe0,0x0,0xa0,0x20,0xc0,
-};
-
-static const BitmapCharRec ch170 = {3,5,0,-2,4,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x38,0x44,0x9a,0xa2,0x9a,0x44,0x38,
-};
-
-static const BitmapCharRec ch169 = {7,7,-1,0,9,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xa0,
-};
-
-static const BitmapCharRec ch168 = {3,1,-1,-6,5,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0xe0,0x90,0x20,0x50,0x90,0xa0,0x40,0x90,0x70,
-};
-
-static const BitmapCharRec ch167 = {4,9,0,1,5,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0x80,0x80,0x80,0x0,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch166 = {1,7,0,0,2,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0x70,0x20,0xf8,0x20,0xd8,0x50,0x88,
-};
-
-static const BitmapCharRec ch165 = {5,7,0,0,5,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0x88,0x70,0x50,0x50,0x70,0x88,
-};
-
-static const BitmapCharRec ch164 = {5,6,0,-1,5,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xf0,0xc8,0x40,0xe0,0x40,0x50,0x30,
-};
-
-static const BitmapCharRec ch163 = {5,7,0,0,5,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x80,0xe0,0x90,0x80,0x90,0x70,0x10,
-};
-
-static const BitmapCharRec ch162 = {4,7,0,1,5,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0x80,0x80,0x80,0x80,0x80,0x0,0x80,
-};
-
-static const BitmapCharRec ch161 = {1,7,-1,2,3,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,2,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,2,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x98,0x64,
-};
-
-static const BitmapCharRec ch126 = {6,2,0,-2,7,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0x80,0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch125 = {3,9,0,2,4,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch124 = {1,9,0,2,2,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x20,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch123 = {3,9,0,2,4,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xf0,0x90,0x40,0x20,0xf0,
-};
-
-static const BitmapCharRec ch122 = {4,5,0,0,5,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0x40,0x40,0x20,0x30,0x50,0x48,0xdc,
-};
-
-static const BitmapCharRec ch121 = {6,7,1,2,5,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0xd8,0x50,0x20,0x50,0xd8,
-};
-
-static const BitmapCharRec ch120 = {5,5,0,0,6,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x28,0x6c,0x54,0x92,0xdb,
-};
-
-static const BitmapCharRec ch119 = {8,5,0,0,8,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x20,0x60,0x50,0x90,0xd8,
-};
-
-static const BitmapCharRec ch118 = {5,5,0,0,5,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x68,0x90,0x90,0x90,0x90,
-};
-
-static const BitmapCharRec ch117 = {5,5,0,0,5,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x30,0x40,0x40,0x40,0xe0,0x40,
-};
-
-static const BitmapCharRec ch116 = {4,6,0,0,4,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0xe0,0x20,0x60,0x80,0xe0,
-};
-
-static const BitmapCharRec ch115 = {3,5,0,0,4,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0xe0,0x40,0x40,0x60,0xa0,
-};
-
-static const BitmapCharRec ch114 = {3,5,0,0,4,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x38,0x10,0x70,0x90,0x90,0x90,0x70,
-};
-
-static const BitmapCharRec ch113 = {5,7,0,2,5,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0xc0,0x80,0xe0,0x90,0x90,0x90,0xe0,
-};
-
-static const BitmapCharRec ch112 = {4,7,0,2,5,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x60,0x90,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch111 = {4,5,0,0,5,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0xd8,0x90,0x90,0x90,0xe0,
-};
-
-static const BitmapCharRec ch110 = {5,5,0,0,5,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0xdb,0x92,0x92,0x92,0xec,
-};
-
-static const BitmapCharRec ch109 = {8,5,0,0,8,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xc0,
-};
-
-static const BitmapCharRec ch108 = {3,7,0,0,4,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0x98,0x90,0xe0,0xa0,0x90,0x80,0x80,
-};
-
-static const BitmapCharRec ch107 = {5,7,0,0,5,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0x80,0x40,0x40,0x40,0x40,0x40,0xc0,0x0,0x40,
-};
-
-static const BitmapCharRec ch106 = {2,9,0,2,3,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0x40,0x40,0x40,0x40,0xc0,0x0,0x40,
-};
-
-static const BitmapCharRec ch105 = {2,7,0,0,3,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0xd8,0x90,0x90,0x90,0xe0,0x80,0x80,
-};
-
-static const BitmapCharRec ch104 = {5,7,0,0,5,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0xe0,0x90,0x60,0x40,0xa0,0xa0,0x70,
-};
-
-static const BitmapCharRec ch103 = {4,7,0,2,5,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0xe0,0x40,0x40,0x40,0xe0,0x40,0x30,
-};
-
-static const BitmapCharRec ch102 = {4,7,0,0,4,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x60,0x80,0xc0,0xa0,0x60,
-};
-
-static const BitmapCharRec ch101 = {3,5,0,0,4,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x68,0x90,0x90,0x90,0x70,0x10,0x30,
-};
-
-static const BitmapCharRec ch100 = {5,7,0,0,5,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x60,0x80,0x80,0x80,0x60,
-};
-
-static const BitmapCharRec ch99 = {3,5,0,0,4,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0xe0,0x90,0x90,0x90,0xe0,0x80,0x80,
-};
-
-static const BitmapCharRec ch98 = {4,7,0,0,5,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0xe0,0xa0,0x60,0x20,0xc0,
-};
-
-static const BitmapCharRec ch97 = {3,5,0,0,4,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0xc0,0x80,
-};
-
-static const BitmapCharRec ch96 = {2,2,0,-5,3,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xf8,
-};
-
-static const BitmapCharRec ch95 = {5,1,0,3,5,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0xa0,0xa0,0x40,
-};
-
-static const BitmapCharRec ch94 = {3,3,-1,-4,5,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,
-};
-
-static const BitmapCharRec ch93 = {2,9,0,2,3,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x20,0x20,0x40,0x40,0x40,0x80,0x80,
-};
-
-static const BitmapCharRec ch92 = {3,7,0,0,3,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
-};
-
-static const BitmapCharRec ch91 = {2,9,0,2,3,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xf8,0x88,0x40,0x20,0x10,0x88,0xf8,
-};
-
-static const BitmapCharRec ch90 = {5,7,0,0,6,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x38,0x10,0x10,0x28,0x28,0x44,0xee,
-};
-
-static const BitmapCharRec ch89 = {7,7,0,0,8,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0xee,0x44,0x28,0x10,0x28,0x44,0xee,
-};
-
-static const BitmapCharRec ch88 = {7,7,0,0,8,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x22,0x0,0x22,0x0,0x55,0x0,0x55,0x0,0xc9,0x80,0x88,0x80,0xdd,0xc0,
-};
-
-static const BitmapCharRec ch87 = {10,7,0,0,10,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x10,0x10,0x28,0x28,0x6c,0x44,0xee,
-};
-
-static const BitmapCharRec ch86 = {7,7,0,0,8,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x38,0x6c,0x44,0x44,0x44,0x44,0xee,
-};
-
-static const BitmapCharRec ch85 = {7,7,0,0,8,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0x70,0x20,0x20,0x20,0x20,0xa8,0xf8,
-};
-
-static const BitmapCharRec ch84 = {5,7,0,0,6,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0xe0,0x90,0x10,0x60,0xc0,0x90,0x70,
-};
-
-static const BitmapCharRec ch83 = {4,7,0,0,5,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0xec,0x48,0x50,0x70,0x48,0x48,0xf0,
-};
-
-static const BitmapCharRec ch82 = {6,7,0,0,7,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0xc,0x18,0x70,0xcc,0x84,0x84,0x84,0xcc,0x78,
-};
-
-static const BitmapCharRec ch81 = {6,9,0,2,7,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0xe0,0x40,0x40,0x70,0x48,0x48,0xf0,
-};
-
-static const BitmapCharRec ch80 = {5,7,0,0,6,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x78,0xcc,0x84,0x84,0x84,0xcc,0x78,
-};
-
-static const BitmapCharRec ch79 = {6,7,0,0,7,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0xe4,0x4c,0x4c,0x54,0x54,0x64,0xee,
-};
-
-static const BitmapCharRec ch78 = {7,7,0,0,8,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0xeb,0x80,0x49,0x0,0x55,0x0,0x55,0x0,0x63,0x0,0x63,0x0,0xe3,0x80,
-};
-
-static const BitmapCharRec ch77 = {9,7,0,0,10,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xf8,0x48,0x40,0x40,0x40,0x40,0xe0,
-};
-
-static const BitmapCharRec ch76 = {5,7,0,0,6,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0xec,0x48,0x50,0x60,0x50,0x48,0xec,
-};
-
-static const BitmapCharRec ch75 = {6,7,0,0,7,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0xc0,0xa0,0x20,0x20,0x20,0x20,0x70,
-};
-
-static const BitmapCharRec ch74 = {4,7,0,0,4,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xe0,0x40,0x40,0x40,0x40,0x40,0xe0,
-};
-
-static const BitmapCharRec ch73 = {3,7,0,0,4,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0xee,0x44,0x44,0x7c,0x44,0x44,0xee,
-};
-
-static const BitmapCharRec ch72 = {7,7,0,0,8,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x78,0xc4,0x84,0x9c,0x80,0xc4,0x7c,
-};
-
-static const BitmapCharRec ch71 = {6,7,0,0,7,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0xe0,0x40,0x40,0x70,0x40,0x48,0xf8,
-};
-
-static const BitmapCharRec ch70 = {5,7,0,0,6,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xf8,0x48,0x40,0x70,0x40,0x48,0xf8,
-};
-
-static const BitmapCharRec ch69 = {5,7,0,0,6,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xf8,0x4c,0x44,0x44,0x44,0x4c,0xf8,
-};
-
-static const BitmapCharRec ch68 = {6,7,0,0,7,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x78,0xc4,0x80,0x80,0x80,0xc4,0x7c,
-};
-
-static const BitmapCharRec ch67 = {6,7,0,0,7,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xf0,0x48,0x48,0x70,0x48,0x48,0xf0,
-};
-
-static const BitmapCharRec ch66 = {5,7,0,0,6,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0xee,0x44,0x7c,0x28,0x28,0x38,0x10,
-};
-
-static const BitmapCharRec ch65 = {7,7,0,0,8,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x3e,0x40,0x92,0xad,0xa5,0xa5,0x9d,0x42,0x3c,
-};
-
-static const BitmapCharRec ch64 = {8,9,0,2,9,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x40,0x0,0x40,0x40,0x20,0xa0,0xe0,
-};
-
-static const BitmapCharRec ch63 = {3,7,0,0,4,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0x80,0x40,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch62 = {3,5,0,0,5,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xf8,0x0,0xf8,
-};
-
-static const BitmapCharRec ch61 = {5,3,0,-1,6,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x20,0x40,0x80,0x40,0x20,
-};
-
-static const BitmapCharRec ch60 = {3,5,-1,0,5,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0x80,0x80,0x80,0x0,0x0,0x0,0x80,
-};
-
-static const BitmapCharRec ch59 = {1,7,-1,2,3,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0x80,0x0,0x0,0x0,0x80,
-};
-
-static const BitmapCharRec ch58 = {1,5,-1,0,3,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0xc0,0x20,0x70,0x90,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch57 = {4,7,0,0,5,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x60,0x90,0x90,0x60,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch56 = {4,7,0,0,5,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x40,0x40,0x40,0x20,0x20,0x90,0xf0,
-};
-
-static const BitmapCharRec ch55 = {4,7,0,0,5,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x60,0x90,0x90,0x90,0xe0,0x40,0x30,
-};
-
-static const BitmapCharRec ch54 = {4,7,0,0,5,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0xe0,0x90,0x10,0x10,0xe0,0x40,0x70,
-};
-
-static const BitmapCharRec ch53 = {4,7,0,0,5,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x10,0x10,0xf8,0x90,0x50,0x30,0x10,
-};
-
-static const BitmapCharRec ch52 = {5,7,0,0,5,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0xe0,0x10,0x10,0x60,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch51 = {4,7,0,0,5,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xf0,0x40,0x20,0x20,0x10,0x90,0x60,
-};
-
-static const BitmapCharRec ch50 = {4,7,0,0,5,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0xe0,0x40,0x40,0x40,0x40,0xc0,0x40,
-};
-
-static const BitmapCharRec ch49 = {3,7,-1,0,5,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x60,0x90,0x90,0x90,0x90,0x90,0x60,
-};
-
-static const BitmapCharRec ch48 = {4,7,0,0,5,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0x80,0x80,0x40,0x40,0x40,0x20,0x20,
-};
-
-static const BitmapCharRec ch47 = {3,7,0,0,3,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0x80,
-};
-
-static const BitmapCharRec ch46 = {1,1,-1,0,3,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xf0,
-};
-
-static const BitmapCharRec ch45 = {4,1,-1,-2,7,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch44 = {1,3,-1,2,3,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x20,0x20,0xf8,0x20,0x20,
-};
-
-static const BitmapCharRec ch43 = {5,5,0,0,6,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0xa0,0x40,0xa0,
-};
-
-static const BitmapCharRec ch42 = {3,3,0,-4,5,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {3,9,0,2,4,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x20,0x40,0x40,0x80,0x80,0x80,0x40,0x40,0x20,
-};
-
-static const BitmapCharRec ch40 = {3,9,0,2,4,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0x40,0xc0,
-};
-
-static const BitmapCharRec ch39 = {2,2,0,-5,3,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x76,0x8d,0x98,0x74,0x6e,0x50,0x30,
-};
-
-static const BitmapCharRec ch38 = {8,7,0,0,8,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x44,0x2a,0x2a,0x56,0xa8,0xa4,0x7e,
-};
-
-static const BitmapCharRec ch37 = {7,7,0,0,8,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x20,0xe0,0x90,0x10,0x60,0x80,0x90,0x70,0x20,
-};
-
-static const BitmapCharRec ch36 = {4,9,0,1,5,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x50,0x50,0xf8,0x50,0xf8,0x50,0x50,
-};
-
-static const BitmapCharRec ch35 = {5,7,0,0,5,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0xa0,0xa0,
-};
-
-static const BitmapCharRec ch34 = {3,2,0,-5,4,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0x80,0x0,0x80,0x80,0x80,0x80,0x80,
-};
-
-static const BitmapCharRec ch33 = {1,7,-1,0,3,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,2,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,2,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-GLUTAPI const BitmapFontRec glutBitmapTimesRoman10;
-const BitmapFontRec glutBitmapTimesRoman10 = {
-"-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/glx/glut_tr24.c b/src/glut/glx/glut_tr24.c
deleted file mode 100644 (file)
index 5db9d36..0000000
+++ /dev/null
@@ -1,2061 +0,0 @@
-
-/* GENERATED FILE -- DO NOT MODIFY */
-
-#define glutBitmapTimesRoman24 XXX
-#include "glutbitmap.h"
-#undef glutBitmapTimesRoman24
-
-/* char: 0xff */
-
-static const GLubyte ch255data[] = {
-0xe0,0x0,0xf0,0x0,0x18,0x0,0x8,0x0,0xc,0x0,0x4,0x0,0xe,0x0,0xe,0x0,
-0x1a,0x0,0x19,0x0,0x19,0x0,0x31,0x0,0x30,0x80,0x30,0x80,0x60,0x80,0x60,0xc0,
-0xf1,0xe0,0x0,0x0,0x0,0x0,0x33,0x0,0x33,0x0,
-};
-
-static const BitmapCharRec ch255 = {11,21,0,5,11,ch255data};
-
-/* char: 0xfe */
-
-static const GLubyte ch254data[] = {
-0xf0,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x6e,0x0,0x73,0x80,0x61,0x80,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x61,0x80,0x73,0x80,
-0x6e,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0xe0,0x0,
-};
-
-static const BitmapCharRec ch254 = {10,22,-1,5,12,ch254data};
-
-/* char: 0xfd */
-
-static const GLubyte ch253data[] = {
-0xe0,0x0,0xf0,0x0,0x18,0x0,0x8,0x0,0xc,0x0,0x4,0x0,0xe,0x0,0xe,0x0,
-0x1a,0x0,0x19,0x0,0x19,0x0,0x31,0x0,0x30,0x80,0x30,0x80,0x60,0x80,0x60,0xc0,
-0xf1,0xe0,0x0,0x0,0x8,0x0,0x6,0x0,0x3,0x80,0x1,0x80,
-};
-
-static const BitmapCharRec ch253 = {11,22,0,5,11,ch253data};
-
-/* char: 0xfc */
-
-static const GLubyte ch252data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,0x0,0x0,0x0,0x0,0x33,0x0,0x33,0x0,
-};
-
-static const BitmapCharRec ch252 = {11,16,-1,0,13,ch252data};
-
-/* char: 0xfb */
-
-static const GLubyte ch251data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,0x0,0x0,0x21,0x0,0x12,0x0,0x1e,0x0,
-0xc,0x0,
-};
-
-static const BitmapCharRec ch251 = {11,17,-1,0,13,ch251data};
-
-/* char: 0xfa */
-
-static const GLubyte ch250data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,0x0,0x0,0x8,0x0,0x6,0x0,0x3,0x80,
-0x1,0x80,
-};
-
-static const BitmapCharRec ch250 = {11,17,-1,0,13,ch250data};
-
-/* char: 0xf9 */
-
-static const GLubyte ch249data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,0x0,0x0,0x2,0x0,0xc,0x0,0x38,0x0,
-0x30,0x0,
-};
-
-static const BitmapCharRec ch249 = {11,17,-1,0,13,ch249data};
-
-/* char: 0xf8 */
-
-static const GLubyte ch248data[] = {
-0xc0,0x0,0xde,0x0,0x73,0x80,0x71,0x80,0xd0,0xc0,0xd8,0xc0,0xc8,0xc0,0xcc,0xc0,
-0xc4,0xc0,0xc6,0xc0,0x63,0x80,0x73,0x80,0x1e,0xc0,0x0,0xc0,
-};
-
-static const BitmapCharRec ch248 = {10,14,-1,1,12,ch248data};
-
-/* char: 0xf7 */
-
-static const GLubyte ch247data[] = {
-0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x0,0xff,0xf0,0xff,0xf0,0x0,0x0,0x0,0x0,
-0x6,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch247 = {12,10,-1,-2,14,ch247data};
-
-/* char: 0xf6 */
-
-static const GLubyte ch246data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x0,0x0,0x33,0x0,0x33,0x0,
-};
-
-static const BitmapCharRec ch246 = {10,16,-1,0,12,ch246data};
-
-/* char: 0xf5 */
-
-static const GLubyte ch245data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x0,0x0,0x27,0x0,0x1c,0x80,
-};
-
-static const BitmapCharRec ch245 = {10,16,-1,0,12,ch245data};
-
-/* char: 0xf4 */
-
-static const GLubyte ch244data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x21,0x0,0x12,0x0,0x1e,0x0,
-0xc,0x0,
-};
-
-static const BitmapCharRec ch244 = {10,17,-1,0,12,ch244data};
-
-/* char: 0xf3 */
-
-static const GLubyte ch243data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x8,0x0,0x6,0x0,0x3,0x80,
-0x1,0x80,
-};
-
-static const BitmapCharRec ch243 = {10,17,-1,0,12,ch243data};
-
-/* char: 0xf2 */
-
-static const GLubyte ch242data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,0x0,0x0,0x2,0x0,0xc,0x0,0x38,0x0,
-0x30,0x0,
-};
-
-static const BitmapCharRec ch242 = {10,17,-1,0,12,ch242data};
-
-/* char: 0xf1 */
-
-static const GLubyte ch241data[] = {
-0xf1,0xe0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x71,0xc0,0x6f,0x80,0xe7,0x0,0x0,0x0,0x0,0x0,0x27,0x0,0x1c,0x80,
-};
-
-static const BitmapCharRec ch241 = {11,16,-1,0,13,ch241data};
-
-/* char: 0xf0 */
-
-static const GLubyte ch240data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1f,0x0,0xc6,0x0,0x3c,0x0,0x1e,0x0,0x71,0x80,
-0xc0,0x0,
-};
-
-static const BitmapCharRec ch240 = {10,17,-1,0,12,ch240data};
-
-/* char: 0xef */
-
-static const GLubyte ch239data[] = {
-0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x70,0x0,0x0,0xcc,0xcc,
-};
-
-static const BitmapCharRec ch239 = {6,16,0,0,6,ch239data};
-
-/* char: 0xee */
-
-static const GLubyte ch238data[] = {
-0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x70,0x0,0x84,0x48,0x78,
-0x30,
-};
-
-static const BitmapCharRec ch238 = {6,17,0,0,6,ch238data};
-
-/* char: 0xed */
-
-static const GLubyte ch237data[] = {
-0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0x0,0x80,0x60,0x38,
-0x18,
-};
-
-static const BitmapCharRec ch237 = {5,17,-1,0,6,ch237data};
-
-/* char: 0xec */
-
-static const GLubyte ch236data[] = {
-0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x70,0x0,0x8,0x30,0xe0,
-0xc0,
-};
-
-static const BitmapCharRec ch236 = {5,17,0,0,6,ch236data};
-
-/* char: 0xeb */
-
-static const GLubyte ch235data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,0x0,0x0,0x0,0x0,0x33,0x0,0x33,0x0,
-};
-
-static const BitmapCharRec ch235 = {9,16,-1,0,11,ch235data};
-
-/* char: 0xea */
-
-static const GLubyte ch234data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,0x0,0x0,0x21,0x0,0x12,0x0,0x1e,0x0,
-0xc,0x0,
-};
-
-static const BitmapCharRec ch234 = {9,17,-1,0,11,ch234data};
-
-/* char: 0xe9 */
-
-static const GLubyte ch233data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,0x0,0x0,0x10,0x0,0xc,0x0,0x7,0x0,
-0x3,0x0,
-};
-
-static const BitmapCharRec ch233 = {9,17,-1,0,11,ch233data};
-
-/* char: 0xe8 */
-
-static const GLubyte ch232data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,0x0,0x0,0x4,0x0,0x18,0x0,0x70,0x0,
-0x60,0x0,
-};
-
-static const BitmapCharRec ch232 = {9,17,-1,0,11,ch232data};
-
-/* char: 0xe7 */
-
-static const GLubyte ch231data[] = {
-0x3c,0x0,0x66,0x0,0x6,0x0,0x1e,0x0,0x18,0x0,0x8,0x0,0x1e,0x0,0x7f,0x0,
-0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0x41,0x80,
-0x63,0x80,0x1f,0x0,
-};
-
-static const BitmapCharRec ch231 = {9,18,-1,6,11,ch231data};
-
-/* char: 0xe6 */
-
-static const GLubyte ch230data[] = {
-0x70,0xf0,0xfb,0xf8,0xc7,0x84,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0xfc,
-0x3,0xc,0x63,0xc,0x67,0x98,0x3c,0xf0,
-};
-
-static const BitmapCharRec ch230 = {14,12,-1,0,16,ch230data};
-
-/* char: 0xe5 */
-
-static const GLubyte ch229data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x1c,0x0,0x22,0x0,0x22,0x0,
-0x1c,0x0,
-};
-
-static const BitmapCharRec ch229 = {9,17,-1,0,11,ch229data};
-
-/* char: 0xe4 */
-
-static const GLubyte ch228data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x66,0x0,0x66,0x0,
-};
-
-static const BitmapCharRec ch228 = {9,16,-1,0,11,ch228data};
-
-/* char: 0xe3 */
-
-static const GLubyte ch227data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x5c,0x0,0x3a,0x0,
-};
-
-static const BitmapCharRec ch227 = {9,16,-1,0,11,ch227data};
-
-/* char: 0xe2 */
-
-static const GLubyte ch226data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x42,0x0,0x24,0x0,0x3c,0x0,
-0x18,0x0,
-};
-
-static const BitmapCharRec ch226 = {9,17,-1,0,11,ch226data};
-
-/* char: 0xe1 */
-
-static const GLubyte ch225data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x10,0x0,0xc,0x0,0x7,0x0,
-0x3,0x0,
-};
-
-static const BitmapCharRec ch225 = {9,17,-1,0,11,ch225data};
-
-/* char: 0xe0 */
-
-static const GLubyte ch224data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,0x0,0x0,0x4,0x0,0x18,0x0,0x70,0x0,
-0x60,0x0,
-};
-
-static const BitmapCharRec ch224 = {9,17,-1,0,11,ch224data};
-
-/* char: 0xdf */
-
-static const GLubyte ch223data[] = {
-0xe7,0x0,0x6c,0x80,0x6c,0xc0,0x60,0xc0,0x60,0xc0,0x61,0xc0,0x61,0x80,0x63,0x80,
-0x67,0x0,0x6c,0x0,0x63,0x0,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x0,
-0x1e,0x0,
-};
-
-static const BitmapCharRec ch223 = {10,17,-1,0,12,ch223data};
-
-/* char: 0xde */
-
-static const GLubyte ch222data[] = {
-0xfc,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x3f,0xc0,0x30,0x70,0x30,0x30,0x30,0x18,
-0x30,0x18,0x30,0x18,0x30,0x30,0x30,0x70,0x3f,0xc0,0x30,0x0,0x30,0x0,0x30,0x0,
-0xfc,0x0,
-};
-
-static const BitmapCharRec ch222 = {13,17,-1,0,15,ch222data};
-
-/* char: 0xdd */
-
-static const GLubyte ch221data[] = {
-0x7,0xe0,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x3,0xc0,
-0x3,0x40,0x6,0x60,0x6,0x20,0xc,0x30,0x1c,0x10,0x18,0x18,0x38,0x8,0x30,0xc,
-0xfc,0x3f,0x0,0x0,0x1,0x0,0x0,0xc0,0x0,0x70,0x0,0x30,
-};
-
-static const BitmapCharRec ch221 = {16,22,0,0,16,ch221data};
-
-/* char: 0xdc */
-
-static const GLubyte ch220data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,0x0,0x0,0x0,0x0,0x6,0x30,0x6,0x30,
-};
-
-static const BitmapCharRec ch220 = {16,21,-1,0,18,ch220data};
-
-/* char: 0xdb */
-
-static const GLubyte ch219data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,0x0,0x0,0x8,0x10,0x6,0x60,0x3,0xc0,0x1,0x80,
-};
-
-static const BitmapCharRec ch219 = {16,22,-1,0,18,ch219data};
-
-/* char: 0xda */
-
-static const GLubyte ch218data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,0x0,0x0,0x1,0x0,0x0,0xc0,0x0,0x70,0x0,0x30,
-};
-
-static const BitmapCharRec ch218 = {16,22,-1,0,18,ch218data};
-
-/* char: 0xd9 */
-
-static const GLubyte ch217data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,0x0,0x0,0x0,0x40,0x1,0x80,0x7,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch217 = {16,22,-1,0,18,ch217data};
-
-/* char: 0xd8 */
-
-static const GLubyte ch216data[] = {
-0x20,0x0,0x27,0xe0,0x1c,0x38,0x38,0x1c,0x68,0x6,0x64,0x6,0xc2,0x3,0xc2,0x3,
-0xc1,0x3,0xc1,0x3,0xc0,0x83,0xc0,0x83,0xc0,0x43,0x60,0x46,0x60,0x26,0x38,0x1c,
-0x1c,0x38,0x7,0xe4,0x0,0x4,
-};
-
-static const BitmapCharRec ch216 = {16,19,-1,1,18,ch216data};
-
-/* char: 0xd7 */
-
-static const GLubyte ch215data[] = {
-0x80,0x40,0xc0,0xc0,0x61,0x80,0x33,0x0,0x1e,0x0,0xc,0x0,0x1e,0x0,0x33,0x0,
-0x61,0x80,0xc0,0xc0,0x80,0x40,
-};
-
-static const BitmapCharRec ch215 = {10,11,-2,-1,14,ch215data};
-
-/* char: 0xd6 */
-
-static const GLubyte ch214data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x0,0x0,0x6,0x60,0x6,0x60,
-};
-
-static const BitmapCharRec ch214 = {16,21,-1,0,18,ch214data};
-
-/* char: 0xd5 */
-
-static const GLubyte ch213data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x0,0x0,0x4,0xe0,0x3,0x90,
-};
-
-static const BitmapCharRec ch213 = {16,21,-1,0,18,ch213data};
-
-/* char: 0xd4 */
-
-static const GLubyte ch212data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x8,0x10,0x6,0x60,0x3,0xc0,0x1,0x80,
-};
-
-static const BitmapCharRec ch212 = {16,22,-1,0,18,ch212data};
-
-/* char: 0xd3 */
-
-static const GLubyte ch211data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x1,0x0,0x0,0xc0,0x0,0x70,0x0,0x30,
-};
-
-static const BitmapCharRec ch211 = {16,22,-1,0,18,ch211data};
-
-/* char: 0xd2 */
-
-static const GLubyte ch210data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,0x0,0x0,0x0,0x40,0x1,0x80,0x7,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch210 = {16,22,-1,0,18,ch210data};
-
-/* char: 0xd1 */
-
-static const GLubyte ch209data[] = {
-0xf8,0xc,0x20,0x1c,0x20,0x1c,0x20,0x34,0x20,0x64,0x20,0x64,0x20,0xc4,0x21,0x84,
-0x21,0x84,0x23,0x4,0x26,0x4,0x26,0x4,0x2c,0x4,0x38,0x4,0x38,0x4,0x30,0x4,
-0xf0,0x1f,0x0,0x0,0x0,0x0,0x4,0xe0,0x3,0x90,
-};
-
-static const BitmapCharRec ch209 = {16,21,-1,0,18,ch209data};
-
-/* char: 0xd0 */
-
-static const GLubyte ch208data[] = {
-0x7f,0xe0,0x18,0x38,0x18,0x1c,0x18,0x6,0x18,0x6,0x18,0x3,0x18,0x3,0x18,0x3,
-0xff,0x3,0x18,0x3,0x18,0x3,0x18,0x3,0x18,0x6,0x18,0x6,0x18,0x1c,0x18,0x38,
-0x7f,0xe0,
-};
-
-static const BitmapCharRec ch208 = {16,17,0,0,17,ch208data};
-
-/* char: 0xcf */
-
-static const GLubyte ch207data[] = {
-0xfc,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xfc,0x0,0x0,0xcc,0xcc,
-};
-
-static const BitmapCharRec ch207 = {6,21,-1,0,8,ch207data};
-
-/* char: 0xce */
-
-static const GLubyte ch206data[] = {
-0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
-0x7e,0x0,0x81,0x66,0x3c,0x18,
-};
-
-static const BitmapCharRec ch206 = {8,22,-1,0,8,ch206data};
-
-/* char: 0xcd */
-
-static const GLubyte ch205data[] = {
-0xfc,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xfc,0x0,0x40,0x30,0x1c,0xc,
-};
-
-static const BitmapCharRec ch205 = {6,22,-1,0,8,ch205data};
-
-/* char: 0xcc */
-
-static const GLubyte ch204data[] = {
-0xfc,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xfc,0x0,0x8,0x30,0xe0,0xc0,
-};
-
-static const BitmapCharRec ch204 = {6,22,-1,0,8,ch204data};
-
-/* char: 0xcb */
-
-static const GLubyte ch203data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,0x0,0x0,0x0,0x0,0x19,0x80,0x19,0x80,
-};
-
-static const BitmapCharRec ch203 = {13,21,-1,0,15,ch203data};
-
-/* char: 0xca */
-
-static const GLubyte ch202data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,0x0,0x0,0x10,0x20,0xc,0xc0,0x7,0x80,0x3,0x0,
-};
-
-static const BitmapCharRec ch202 = {13,22,-1,0,15,ch202data};
-
-/* char: 0xc9 */
-
-static const GLubyte ch201data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,0x0,0x0,0x4,0x0,0x3,0x0,0x1,0xc0,0x0,0xc0,
-};
-
-static const BitmapCharRec ch201 = {13,22,-1,0,15,ch201data};
-
-/* char: 0xc8 */
-
-static const GLubyte ch200data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,0x0,0x0,0x1,0x0,0x6,0x0,0x1c,0x0,0x18,0x0,
-};
-
-static const BitmapCharRec ch200 = {13,22,-1,0,15,ch200data};
-
-/* char: 0xc7 */
-
-static const GLubyte ch199data[] = {
-0x7,0x80,0xc,0xc0,0x0,0xc0,0x3,0xc0,0x3,0x0,0x1,0x0,0x7,0xe0,0x1e,0x38,
-0x38,0x8,0x60,0x4,0x60,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0xc0,0x0,0x60,0x4,0x60,0x4,0x38,0xc,0x1c,0x3c,0x7,0xe4,
-};
-
-static const BitmapCharRec ch199 = {14,23,-1,6,16,ch199data};
-
-/* char: 0xc6 */
-
-static const GLubyte ch198data[] = {
-0xf9,0xff,0xf0,0x30,0x60,0x30,0x10,0x60,0x10,0x10,0x60,0x10,0x18,0x60,0x0,0x8,
-0x60,0x0,0xf,0xe0,0x80,0xc,0x60,0x80,0x4,0x7f,0x80,0x4,0x60,0x80,0x6,0x60,
-0x80,0x2,0x60,0x0,0x2,0x60,0x0,0x1,0x60,0x20,0x1,0x60,0x20,0x1,0xe0,0x60,
-0x3,0xff,0xe0,
-};
-
-static const BitmapCharRec ch198 = {20,17,0,0,21,ch198data};
-
-/* char: 0xc5 */
-
-static const GLubyte ch197data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x1,0xc0,0x0,0x2,0x20,0x0,0x2,0x20,0x0,0x1,0xc0,0x0,
-};
-
-static const BitmapCharRec ch197 = {17,21,0,0,17,ch197data};
-
-/* char: 0xc4 */
-
-static const GLubyte ch196data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x30,0x0,0x6,0x30,0x0,
-};
-
-static const BitmapCharRec ch196 = {17,21,0,0,17,ch196data};
-
-/* char: 0xc3 */
-
-static const GLubyte ch195data[] = {
-0xfc,0x1f,0x80,0x30,0x7,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0xe0,0x0,0x3,0x90,0x0,
-};
-
-static const BitmapCharRec ch195 = {17,21,0,0,17,ch195data};
-
-/* char: 0xc2 */
-
-static const GLubyte ch194data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x8,0x10,0x0,0x6,0x60,0x0,0x3,0xc0,0x0,0x1,
-0x80,0x0,
-};
-
-static const BitmapCharRec ch194 = {17,22,0,0,17,ch194data};
-
-/* char: 0xc1 */
-
-static const GLubyte ch193data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0xc0,0x0,0x0,0x70,0x0,0x0,
-0x30,0x0,
-};
-
-static const BitmapCharRec ch193 = {17,22,0,0,17,ch193data};
-
-/* char: 0xc0 */
-
-static const GLubyte ch192data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x20,0x0,0x0,0xc0,0x0,0x3,0x80,0x0,0x3,
-0x0,0x0,
-};
-
-static const BitmapCharRec ch192 = {17,22,0,0,17,ch192data};
-
-/* char: 0xbf */
-
-static const GLubyte ch191data[] = {
-0x3e,0x63,0xc1,0xc3,0xc3,0xe0,0x70,0x30,0x38,0x18,0x18,0x8,0x8,0x0,0x0,0xc,
-0xc,
-};
-
-static const BitmapCharRec ch191 = {8,17,-1,5,11,ch191data};
-
-/* char: 0xbe */
-
-static const GLubyte ch190data[] = {
-0x18,0x2,0x0,0x8,0x2,0x0,0xc,0x7f,0x80,0x4,0x22,0x0,0x6,0x32,0x0,0x3,
-0x12,0x0,0x1,0xa,0x0,0x71,0x8e,0x0,0x88,0x86,0x0,0x8c,0xc2,0x0,0xc,0x60,
-0x0,0x8,0x20,0x0,0x30,0x30,0x0,0x8,0x10,0x0,0x8c,0x18,0x0,0x4c,0xc,0x0,
-0x38,0x4,0x0,
-};
-
-static const BitmapCharRec ch190 = {17,17,0,0,18,ch190data};
-
-/* char: 0xbd */
-
-static const GLubyte ch189data[] = {
-0x30,0x7e,0x10,0x22,0x18,0x10,0x8,0x18,0xc,0x8,0x6,0x4,0x2,0x6,0xfb,0x46,
-0x21,0x26,0x21,0x9c,0x20,0xc0,0x20,0x40,0x20,0x60,0x20,0x20,0xa0,0x30,0x60,0x18,
-0x20,0x8,
-};
-
-static const BitmapCharRec ch189 = {15,17,-1,0,18,ch189data};
-
-/* char: 0xbc */
-
-static const GLubyte ch188data[] = {
-0x30,0x4,0x10,0x4,0x18,0xff,0x8,0x44,0xc,0x64,0x6,0x24,0x2,0x14,0xfb,0x1c,
-0x21,0xc,0x21,0x84,0x20,0xc0,0x20,0x40,0x20,0x60,0x20,0x20,0xa0,0x30,0x60,0x18,
-0x20,0x8,
-};
-
-static const BitmapCharRec ch188 = {16,17,-1,0,18,ch188data};
-
-/* char: 0xbb */
-
-static const GLubyte ch187data[] = {
-0x88,0x0,0xcc,0x0,0x66,0x0,0x33,0x0,0x19,0x80,0x19,0x80,0x33,0x0,0x66,0x0,
-0xcc,0x0,0x88,0x0,
-};
-
-static const BitmapCharRec ch187 = {9,10,-2,-1,12,ch187data};
-
-/* char: 0xba */
-
-static const GLubyte ch186data[] = {
-0xfc,0x0,0x78,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,
-};
-
-static const BitmapCharRec ch186 = {6,9,-1,-8,8,ch186data};
-
-/* char: 0xb9 */
-
-static const GLubyte ch185data[] = {
-0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0xa0,0x60,0x20,
-};
-
-static const BitmapCharRec ch185 = {5,10,-1,-7,7,ch185data};
-
-/* char: 0xb8 */
-
-static const GLubyte ch184data[] = {
-0x78,0xcc,0xc,0x3c,0x30,0x10,
-};
-
-static const BitmapCharRec ch184 = {6,6,-1,6,8,ch184data};
-
-/* char: 0xb7 */
-
-static const GLubyte ch183data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch183 = {2,2,-2,-6,6,ch183data};
-
-/* char: 0xb6 */
-
-static const GLubyte ch182data[] = {
-0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,
-0x9,0x0,0x9,0x0,0x9,0x0,0x19,0x0,0x39,0x0,0x79,0x0,0x79,0x0,0xf9,0x0,
-0xf9,0x0,0xf9,0x0,0x79,0x0,0x79,0x0,0x39,0x0,0x1f,0x80,
-};
-
-static const BitmapCharRec ch182 = {9,22,-1,5,11,ch182data};
-
-/* char: 0xb5 */
-
-static const GLubyte ch181data[] = {
-0x40,0x0,0xe0,0x0,0xc0,0x0,0x40,0x0,0x40,0x0,0x5c,0xe0,0x7e,0xc0,0x71,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0xe1,0xc0,
-};
-
-static const BitmapCharRec ch181 = {11,17,-1,5,13,ch181data};
-
-/* char: 0xb4 */
-
-static const GLubyte ch180data[] = {
-0x80,0x60,0x38,0x18,
-};
-
-static const BitmapCharRec ch180 = {5,4,-2,-13,8,ch180data};
-
-/* char: 0xb3 */
-
-static const GLubyte ch179data[] = {
-0x70,0x88,0x8c,0xc,0x8,0x30,0x8,0x8c,0x4c,0x38,
-};
-
-static const BitmapCharRec ch179 = {6,10,0,-7,7,ch179data};
-
-/* char: 0xb2 */
-
-static const GLubyte ch178data[] = {
-0xfc,0x44,0x20,0x30,0x10,0x8,0xc,0x8c,0x4c,0x38,
-};
-
-static const BitmapCharRec ch178 = {6,10,0,-7,7,ch178data};
-
-/* char: 0xb1 */
-
-static const GLubyte ch177data[] = {
-0xff,0xf0,0xff,0xf0,0x0,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-0xff,0xf0,0xff,0xf0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch177 = {12,15,-1,0,14,ch177data};
-
-/* char: 0xb0 */
-
-static const GLubyte ch176data[] = {
-0x38,0x44,0x82,0x82,0x82,0x44,0x38,
-};
-
-static const BitmapCharRec ch176 = {7,7,-1,-10,9,ch176data};
-
-/* char: 0xaf */
-
-static const GLubyte ch175data[] = {
-0xfc,0xfc,
-};
-
-static const BitmapCharRec ch175 = {6,2,-1,-14,8,ch175data};
-
-/* char: 0xae */
-
-static const GLubyte ch174data[] = {
-0x7,0xf0,0x0,0x1c,0x1c,0x0,0x30,0x6,0x0,0x60,0x3,0x0,0x47,0x19,0x0,0xc2,
-0x31,0x80,0x82,0x20,0x80,0x82,0x40,0x80,0x83,0xe0,0x80,0x82,0x30,0x80,0x82,0x10,
-0x80,0xc2,0x11,0x80,0x42,0x31,0x0,0x67,0xe3,0x0,0x30,0x6,0x0,0x1c,0x1c,0x0,
-0x7,0xf0,0x0,
-};
-
-static const BitmapCharRec ch174 = {17,17,-1,0,19,ch174data};
-
-/* char: 0xad */
-
-static const GLubyte ch173data[] = {
-0xfe,0xfe,
-};
-
-static const BitmapCharRec ch173 = {7,2,-1,-5,9,ch173data};
-
-/* char: 0xac */
-
-static const GLubyte ch172data[] = {
-0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0xff,0xf0,0xff,0xf0,
-};
-
-static const BitmapCharRec ch172 = {12,7,-1,-3,14,ch172data};
-
-/* char: 0xab */
-
-static const GLubyte ch171data[] = {
-0x8,0x80,0x19,0x80,0x33,0x0,0x66,0x0,0xcc,0x0,0xcc,0x0,0x66,0x0,0x33,0x0,
-0x19,0x80,0x8,0x80,
-};
-
-static const BitmapCharRec ch171 = {9,10,-2,-1,13,ch171data};
-
-/* char: 0xaa */
-
-static const GLubyte ch170data[] = {
-0x7e,0x0,0x76,0xcc,0xcc,0x7c,0xc,0xcc,0x78,
-};
-
-static const BitmapCharRec ch170 = {7,9,0,-8,8,ch170data};
-
-/* char: 0xa9 */
-
-static const GLubyte ch169data[] = {
-0x7,0xf0,0x0,0x1c,0x1c,0x0,0x30,0x6,0x0,0x61,0xc3,0x0,0x47,0x71,0x0,0xc4,
-0x19,0x80,0x8c,0x0,0x80,0x88,0x0,0x80,0x88,0x0,0x80,0x88,0x0,0x80,0x8c,0x0,
-0x80,0xc4,0x19,0x80,0x47,0x31,0x0,0x61,0xe3,0x0,0x30,0x6,0x0,0x1c,0x1c,0x0,
-0x7,0xf0,0x0,
-};
-
-static const BitmapCharRec ch169 = {17,17,-1,0,19,ch169data};
-
-/* char: 0xa8 */
-
-static const GLubyte ch168data[] = {
-0xcc,0xcc,
-};
-
-static const BitmapCharRec ch168 = {6,2,-1,-14,8,ch168data};
-
-/* char: 0xa7 */
-
-static const GLubyte ch167data[] = {
-0x38,0x64,0x62,0x6,0xe,0x1c,0x38,0x74,0xe2,0xc3,0x83,0x87,0x4e,0x3c,0x38,0x70,
-0x60,0x46,0x26,0x1c,
-};
-
-static const BitmapCharRec ch167 = {8,20,-2,2,12,ch167data};
-
-/* char: 0xa6 */
-
-static const GLubyte ch166data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0x0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch166 = {2,17,-2,0,6,ch166data};
-
-/* char: 0xa5 */
-
-static const GLubyte ch165data[] = {
-0xf,0xc0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x1f,0xe0,0x3,0x0,0x1f,0xe0,
-0x3,0x0,0x7,0x80,0xc,0x80,0xc,0xc0,0x18,0x40,0x18,0x60,0x30,0x20,0x70,0x30,
-0xf8,0x7c,
-};
-
-static const BitmapCharRec ch165 = {14,17,0,0,14,ch165data};
-
-/* char: 0xa4 */
-
-static const GLubyte ch164data[] = {
-0xc0,0x60,0xee,0xe0,0x7f,0xc0,0x31,0x80,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x31,0x80,0x7f,0xc0,0xee,0xe0,0xc0,0x60,
-};
-
-static const BitmapCharRec ch164 = {11,12,-1,-3,13,ch164data};
-
-/* char: 0xa3 */
-
-static const GLubyte ch163data[] = {
-0xe7,0x80,0xbe,0xc0,0x78,0x40,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,
-0x30,0x0,0xfc,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x31,0x80,0x19,0x80,
-0xf,0x0,
-};
-
-static const BitmapCharRec ch163 = {10,17,-1,0,12,ch163data};
-
-/* char: 0xa2 */
-
-static const GLubyte ch162data[] = {
-0x40,0x0,0x40,0x0,0x3e,0x0,0x7f,0x0,0x70,0x80,0xd0,0x0,0xc8,0x0,0xc8,0x0,
-0xc8,0x0,0xc4,0x0,0xc4,0x0,0x43,0x80,0x63,0x80,0x1f,0x0,0x1,0x0,0x1,0x0,
-};
-
-static const BitmapCharRec ch162 = {9,16,-1,2,12,ch162data};
-
-/* char: 0xa1 */
-
-static const GLubyte ch161data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x0,0x0,0x0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch161 = {2,17,-4,5,8,ch161data};
-
-/* char: 0xa0 */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch160data[] = { 0x0 };
-static const BitmapCharRec ch160 = {1,1,0,0,6,ch160data};
-#else
-static const BitmapCharRec ch160 = {0,0,0,0,6,0};
-#endif
-
-/* char: 0x7e '~' */
-
-static const GLubyte ch126data[] = {
-0x83,0x80,0xc7,0xc0,0x7c,0x60,0x38,0x20,
-};
-
-static const BitmapCharRec ch126 = {11,4,-1,-5,13,ch126data};
-
-/* char: 0x7d '}' */
-
-static const GLubyte ch125data[] = {
-0xe0,0x30,0x18,0x18,0x18,0x18,0x18,0x18,0x8,0xc,0x4,0x3,0x4,0xc,0x8,0x18,
-0x18,0x18,0x18,0x18,0x30,0xe0,
-};
-
-static const BitmapCharRec ch125 = {8,22,-1,5,10,ch125data};
-
-/* char: 0x7c '|' */
-
-static const GLubyte ch124data[] = {
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch124 = {2,17,-2,0,6,ch124data};
-
-/* char: 0x7b '{' */
-
-static const GLubyte ch123data[] = {
-0x7,0xc,0x18,0x18,0x18,0x18,0x18,0x18,0x10,0x30,0x20,0xc0,0x20,0x30,0x10,0x18,
-0x18,0x18,0x18,0x18,0xc,0x7,
-};
-
-static const BitmapCharRec ch123 = {8,22,-1,5,10,ch123data};
-
-/* char: 0x7a 'z' */
-
-static const GLubyte ch122data[] = {
-0xff,0xc3,0x61,0x70,0x30,0x38,0x18,0x1c,0xe,0x86,0xc3,0xff,
-};
-
-static const BitmapCharRec ch122 = {8,12,-1,0,10,ch122data};
-
-/* char: 0x79 'y' */
-
-static const GLubyte ch121data[] = {
-0xe0,0x0,0xf0,0x0,0x18,0x0,0x8,0x0,0xc,0x0,0x4,0x0,0xe,0x0,0xe,0x0,
-0x1a,0x0,0x19,0x0,0x19,0x0,0x31,0x0,0x30,0x80,0x30,0x80,0x60,0x80,0x60,0xc0,
-0xf1,0xe0,
-};
-
-static const BitmapCharRec ch121 = {11,17,0,5,11,ch121data};
-
-/* char: 0x78 'x' */
-
-static const GLubyte ch120data[] = {
-0xf1,0xe0,0x60,0xc0,0x21,0x80,0x33,0x80,0x1b,0x0,0xe,0x0,0xc,0x0,0x1a,0x0,
-0x39,0x0,0x31,0x80,0x60,0xc0,0xf1,0xe0,
-};
-
-static const BitmapCharRec ch120 = {11,12,-1,0,13,ch120data};
-
-/* char: 0x77 'w' */
-
-static const GLubyte ch119data[] = {
-0x4,0x10,0x0,0xe,0x38,0x0,0xe,0x38,0x0,0x1a,0x28,0x0,0x1a,0x64,0x0,0x19,
-0x64,0x0,0x31,0x64,0x0,0x30,0xc2,0x0,0x30,0xc2,0x0,0x60,0xc2,0x0,0x60,0xc3,
-0x0,0xf1,0xe7,0x80,
-};
-
-static const BitmapCharRec ch119 = {17,12,0,0,17,ch119data};
-
-/* char: 0x76 'v' */
-
-static const GLubyte ch118data[] = {
-0x4,0x0,0xe,0x0,0xe,0x0,0x1a,0x0,0x19,0x0,0x19,0x0,0x31,0x0,0x30,0x80,
-0x30,0x80,0x60,0x80,0x60,0xc0,0xf1,0xe0,
-};
-
-static const BitmapCharRec ch118 = {11,12,0,0,11,ch118data};
-
-/* char: 0x75 'u' */
-
-static const GLubyte ch117data[] = {
-0x1c,0xe0,0x3e,0xc0,0x71,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0xe1,0xc0,
-};
-
-static const BitmapCharRec ch117 = {11,12,-1,0,13,ch117data};
-
-/* char: 0x74 't' */
-
-static const GLubyte ch116data[] = {
-0x1c,0x32,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xfe,0x70,0x30,0x10,
-};
-
-static const BitmapCharRec ch116 = {7,15,0,0,7,ch116data};
-
-/* char: 0x73 's' */
-
-static const GLubyte ch115data[] = {
-0xf8,0xc6,0x83,0x3,0x7,0x1e,0x7c,0x70,0xe0,0xc2,0x66,0x3e,
-};
-
-static const BitmapCharRec ch115 = {8,12,-1,0,10,ch115data};
-
-/* char: 0x72 'r' */
-
-static const GLubyte ch114data[] = {
-0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x76,0x6e,0xe6,
-};
-
-static const BitmapCharRec ch114 = {7,12,-1,0,8,ch114data};
-
-/* char: 0x71 'q' */
-
-static const GLubyte ch113data[] = {
-0x3,0xc0,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1d,0x80,0x73,0x80,0x61,0x80,
-0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0x61,0x80,0x73,0x80,
-0x1d,0x80,
-};
-
-static const BitmapCharRec ch113 = {10,17,-1,5,12,ch113data};
-
-/* char: 0x70 'p' */
-
-static const GLubyte ch112data[] = {
-0xf0,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x6e,0x0,0x73,0x80,0x61,0x80,
-0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x61,0x80,0x73,0x80,
-0xee,0x0,
-};
-
-static const BitmapCharRec ch112 = {10,17,-1,5,12,ch112data};
-
-/* char: 0x6f 'o' */
-
-static const GLubyte ch111data[] = {
-0x1e,0x0,0x73,0x80,0x61,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0x61,0x80,0x73,0x80,0x1e,0x0,
-};
-
-static const BitmapCharRec ch111 = {10,12,-1,0,12,ch111data};
-
-/* char: 0x6e 'n' */
-
-static const GLubyte ch110data[] = {
-0xf1,0xe0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x71,0xc0,0x6f,0x80,0xe7,0x0,
-};
-
-static const BitmapCharRec ch110 = {11,12,-1,0,13,ch110data};
-
-/* char: 0x6d 'm' */
-
-static const GLubyte ch109data[] = {
-0xf1,0xe3,0xc0,0x60,0xc1,0x80,0x60,0xc1,0x80,0x60,0xc1,0x80,0x60,0xc1,0x80,0x60,
-0xc1,0x80,0x60,0xc1,0x80,0x60,0xc1,0x80,0x60,0xc1,0x80,0x71,0xe3,0x80,0x6f,0x9f,
-0x0,0xe7,0xe,0x0,
-};
-
-static const BitmapCharRec ch109 = {18,12,-1,0,20,ch109data};
-
-/* char: 0x6c 'l' */
-
-static const GLubyte ch108data[] = {
-0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
-0xe0,
-};
-
-static const BitmapCharRec ch108 = {4,17,-1,0,6,ch108data};
-
-/* char: 0x6b 'k' */
-
-static const GLubyte ch107data[] = {
-0xf3,0xe0,0x61,0xc0,0x63,0x80,0x67,0x0,0x6e,0x0,0x6c,0x0,0x78,0x0,0x68,0x0,
-0x64,0x0,0x66,0x0,0x63,0x0,0x67,0xc0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,
-0xe0,0x0,
-};
-
-static const BitmapCharRec ch107 = {11,17,-1,0,12,ch107data};
-
-/* char: 0x6a 'j' */
-
-static const GLubyte ch106data[] = {
-0xc0,0xe0,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0x70,0x0,0x0,0x0,0x30,0x30,
-};
-
-static const BitmapCharRec ch106 = {4,22,0,5,6,ch106data};
-
-/* char: 0x69 'i' */
-
-static const GLubyte ch105data[] = {
-0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0x0,0x0,0x0,0x60,
-0x60,
-};
-
-static const BitmapCharRec ch105 = {4,17,-1,0,6,ch105data};
-
-/* char: 0x68 'h' */
-
-static const GLubyte ch104data[] = {
-0xf1,0xe0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x71,0xc0,0x6f,0x80,0x67,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,
-0xe0,0x0,
-};
-
-static const BitmapCharRec ch104 = {11,17,-1,0,13,ch104data};
-
-/* char: 0x67 'g' */
-
-static const GLubyte ch103data[] = {
-0x3f,0x0,0xf1,0xc0,0xc0,0x60,0xc0,0x20,0x60,0x60,0x3f,0xc0,0x7f,0x0,0x60,0x0,
-0x30,0x0,0x3e,0x0,0x33,0x0,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x0,
-0x1f,0xc0,
-};
-
-static const BitmapCharRec ch103 = {11,17,-1,5,12,ch103data};
-
-/* char: 0x66 'f' */
-
-static const GLubyte ch102data[] = {
-0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xfe,0x30,0x30,0x30,0x16,
-0xe,
-};
-
-static const BitmapCharRec ch102 = {7,17,0,0,7,ch102data};
-
-/* char: 0x65 'e' */
-
-static const GLubyte ch101data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xff,0x80,
-0xc1,0x80,0x41,0x80,0x63,0x0,0x1e,0x0,
-};
-
-static const BitmapCharRec ch101 = {9,12,-1,0,11,ch101data};
-
-/* char: 0x64 'd' */
-
-static const GLubyte ch100data[] = {
-0x1e,0xc0,0x73,0x80,0x61,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,0xc1,0x80,
-0xc1,0x80,0x61,0x80,0x73,0x80,0x1d,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,
-0x3,0x80,
-};
-
-static const BitmapCharRec ch100 = {10,17,-1,0,12,ch100data};
-
-/* char: 0x63 'c' */
-
-static const GLubyte ch99data[] = {
-0x1e,0x0,0x7f,0x0,0x70,0x80,0xe0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0x41,0x80,0x63,0x80,0x1f,0x0,
-};
-
-static const BitmapCharRec ch99 = {9,12,-1,0,11,ch99data};
-
-/* char: 0x62 'b' */
-
-static const GLubyte ch98data[] = {
-0x5e,0x0,0x73,0x80,0x61,0x80,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,0x60,0xc0,
-0x60,0xc0,0x61,0x80,0x73,0x80,0x6e,0x0,0x60,0x0,0x60,0x0,0x60,0x0,0x60,0x0,
-0xe0,0x0,
-};
-
-static const BitmapCharRec ch98 = {10,17,-1,0,12,ch98data};
-
-/* char: 0x61 'a' */
-
-static const GLubyte ch97data[] = {
-0x71,0x80,0xfb,0x0,0xc7,0x0,0xc3,0x0,0xc3,0x0,0x63,0x0,0x3b,0x0,0xf,0x0,
-0x3,0x0,0x63,0x0,0x67,0x0,0x3e,0x0,
-};
-
-static const BitmapCharRec ch97 = {9,12,-1,0,11,ch97data};
-
-/* char: 0x60 '`' */
-
-static const GLubyte ch96data[] = {
-0x60,0xe0,0x80,0xc0,0x60,
-};
-
-static const BitmapCharRec ch96 = {3,5,-2,-12,7,ch96data};
-
-/* char: 0x5f '_' */
-
-static const GLubyte ch95data[] = {
-0xff,0xf8,0xff,0xf8,
-};
-
-static const BitmapCharRec ch95 = {13,2,0,5,13,ch95data};
-
-/* char: 0x5e '^' */
-
-static const GLubyte ch94data[] = {
-0x80,0x80,0xc1,0x80,0x41,0x0,0x63,0x0,0x22,0x0,0x36,0x0,0x14,0x0,0x1c,0x0,
-0x8,0x0,
-};
-
-static const BitmapCharRec ch94 = {9,9,-1,-8,11,ch94data};
-
-/* char: 0x5d ']' */
-
-static const GLubyte ch93data[] = {
-0xf8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
-0x18,0x18,0x18,0x18,0xf8,
-};
-
-static const BitmapCharRec ch93 = {5,21,-1,4,8,ch93data};
-
-/* char: 0x5c '\' */
-
-static const GLubyte ch92data[] = {
-0x6,0x6,0x4,0xc,0xc,0x8,0x18,0x18,0x10,0x30,0x30,0x20,0x60,0x60,0x40,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch92 = {7,17,0,0,7,ch92data};
-
-/* char: 0x5b '[' */
-
-static const GLubyte ch91data[] = {
-0xf8,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0xc0,0xc0,0xf8,
-};
-
-static const BitmapCharRec ch91 = {5,21,-2,4,8,ch91data};
-
-/* char: 0x5a 'Z' */
-
-static const GLubyte ch90data[] = {
-0xff,0xf8,0xe0,0x18,0x70,0x8,0x30,0x8,0x38,0x0,0x18,0x0,0x1c,0x0,0xe,0x0,
-0x6,0x0,0x7,0x0,0x3,0x0,0x3,0x80,0x1,0xc0,0x80,0xc0,0x80,0xe0,0xc0,0x70,
-0xff,0xf0,
-};
-
-static const BitmapCharRec ch90 = {13,17,-1,0,15,ch90data};
-
-/* char: 0x59 'Y' */
-
-static const GLubyte ch89data[] = {
-0x7,0xe0,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x1,0x80,0x3,0xc0,
-0x3,0x40,0x6,0x60,0x6,0x20,0xc,0x30,0x1c,0x10,0x18,0x18,0x38,0x8,0x30,0xc,
-0xfc,0x3f,
-};
-
-static const BitmapCharRec ch89 = {16,17,0,0,16,ch89data};
-
-/* char: 0x58 'X' */
-
-static const GLubyte ch88data[] = {
-0xfc,0xf,0xc0,0x30,0x3,0x80,0x18,0x7,0x0,0x8,0xe,0x0,0x4,0xc,0x0,0x6,
-0x18,0x0,0x2,0x38,0x0,0x1,0x70,0x0,0x0,0xe0,0x0,0x0,0xc0,0x0,0x1,0xc0,
-0x0,0x3,0xa0,0x0,0x3,0x10,0x0,0x6,0x8,0x0,0xe,0xc,0x0,0x1c,0x6,0x0,
-0x7e,0xf,0x80,
-};
-
-static const BitmapCharRec ch88 = {18,17,0,0,18,ch88data};
-
-/* char: 0x57 'W' */
-
-static const GLubyte ch87data[] = {
-0x1,0x83,0x0,0x1,0x83,0x0,0x1,0x83,0x80,0x3,0x87,0x80,0x3,0x46,0x80,0x3,
-0x46,0xc0,0x6,0x46,0x40,0x6,0x4c,0x40,0x6,0x4c,0x60,0xc,0x2c,0x60,0xc,0x2c,
-0x20,0x18,0x2c,0x20,0x18,0x18,0x30,0x18,0x18,0x10,0x30,0x18,0x10,0x30,0x18,0x18,
-0xfc,0x7e,0x7e,
-};
-
-static const BitmapCharRec ch87 = {23,17,0,0,23,ch87data};
-
-/* char: 0x56 'V' */
-
-static const GLubyte ch86data[] = {
-0x1,0x80,0x0,0x1,0x80,0x0,0x1,0x80,0x0,0x3,0xc0,0x0,0x3,0x40,0x0,0x3,
-0x60,0x0,0x6,0x20,0x0,0x6,0x20,0x0,0x6,0x30,0x0,0xc,0x10,0x0,0xc,0x18,
-0x0,0x18,0x8,0x0,0x18,0x8,0x0,0x18,0xc,0x0,0x30,0x4,0x0,0x30,0x6,0x0,
-0xfc,0x1f,0x80,
-};
-
-static const BitmapCharRec ch86 = {17,17,0,0,17,ch86data};
-
-/* char: 0x55 'U' */
-
-static const GLubyte ch85data[] = {
-0x7,0xe0,0x1c,0x30,0x18,0x8,0x30,0x8,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,0x30,0x4,
-0xfc,0x1f,
-};
-
-static const BitmapCharRec ch85 = {16,17,-1,0,18,ch85data};
-
-/* char: 0x54 'T' */
-
-static const GLubyte ch84data[] = {
-0xf,0xc0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,
-0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0x83,0x4,0x83,0x4,0xc3,0xc,
-0xff,0xfc,
-};
-
-static const BitmapCharRec ch84 = {14,17,-1,0,16,ch84data};
-
-/* char: 0x53 'S' */
-
-static const GLubyte ch83data[] = {
-0x9e,0x0,0xf1,0x80,0xc0,0xc0,0x80,0x60,0x80,0x60,0x0,0x60,0x0,0xe0,0x3,0xc0,
-0xf,0x80,0x1e,0x0,0x78,0x0,0xe0,0x0,0xc0,0x40,0xc0,0x40,0xc0,0xc0,0x63,0xc0,
-0x1e,0x40,
-};
-
-static const BitmapCharRec ch83 = {11,17,-1,0,13,ch83data};
-
-/* char: 0x52 'R' */
-
-static const GLubyte ch82data[] = {
-0xfc,0x1e,0x30,0x1c,0x30,0x38,0x30,0x70,0x30,0x60,0x30,0xc0,0x31,0xc0,0x33,0x80,
-0x3f,0xc0,0x30,0x70,0x30,0x30,0x30,0x38,0x30,0x18,0x30,0x38,0x30,0x30,0x30,0x70,
-0xff,0xc0,
-};
-
-static const BitmapCharRec ch82 = {15,17,-1,0,16,ch82data};
-
-/* char: 0x51 'Q' */
-
-static const GLubyte ch81data[] = {
-0x0,0xf,0x0,0x38,0x0,0x70,0x0,0xe0,0x1,0xc0,0x7,0xe0,0x1c,0x38,0x38,0x1c,
-0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,0x7,0xe0,
-};
-
-static const BitmapCharRec ch81 = {16,22,-1,5,18,ch81data};
-
-/* char: 0x50 'P' */
-
-static const GLubyte ch80data[] = {
-0xfc,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,
-0x3f,0xc0,0x30,0x70,0x30,0x30,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x30,0x30,0x70,
-0xff,0xc0,
-};
-
-static const BitmapCharRec ch80 = {13,17,-1,0,15,ch80data};
-
-/* char: 0x4f 'O' */
-
-static const GLubyte ch79data[] = {
-0x7,0xe0,0x1c,0x38,0x38,0x1c,0x60,0x6,0x60,0x6,0xc0,0x3,0xc0,0x3,0xc0,0x3,
-0xc0,0x3,0xc0,0x3,0xc0,0x3,0xc0,0x3,0x60,0x6,0x60,0x6,0x38,0x1c,0x1c,0x38,
-0x7,0xe0,
-};
-
-static const BitmapCharRec ch79 = {16,17,-1,0,18,ch79data};
-
-/* char: 0x4e 'N' */
-
-static const GLubyte ch78data[] = {
-0xf8,0xc,0x20,0x1c,0x20,0x1c,0x20,0x34,0x20,0x64,0x20,0x64,0x20,0xc4,0x21,0x84,
-0x21,0x84,0x23,0x4,0x26,0x4,0x26,0x4,0x2c,0x4,0x38,0x4,0x38,0x4,0x30,0x4,
-0xf0,0x1f,
-};
-
-static const BitmapCharRec ch78 = {16,17,-1,0,18,ch78data};
-
-/* char: 0x4d 'M' */
-
-static const GLubyte ch77data[] = {
-0xf8,0x21,0xf8,0x20,0x60,0x60,0x20,0x60,0x60,0x20,0xd0,0x60,0x20,0xd0,0x60,0x21,
-0x88,0x60,0x21,0x88,0x60,0x23,0x8,0x60,0x23,0x4,0x60,0x26,0x4,0x60,0x26,0x2,
-0x60,0x2c,0x2,0x60,0x2c,0x2,0x60,0x38,0x1,0x60,0x38,0x1,0x60,0x30,0x0,0xe0,
-0xf0,0x0,0xf8,
-};
-
-static const BitmapCharRec ch77 = {21,17,-1,0,22,ch77data};
-
-/* char: 0x4c 'L' */
-
-static const GLubyte ch76data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,
-0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,
-0xfc,0x0,
-};
-
-static const BitmapCharRec ch76 = {13,17,-1,0,14,ch76data};
-
-/* char: 0x4b 'K' */
-
-static const GLubyte ch75data[] = {
-0xfc,0x1f,0x30,0xe,0x30,0x1c,0x30,0x38,0x30,0x70,0x30,0xe0,0x31,0xc0,0x33,0x80,
-0x3f,0x0,0x3e,0x0,0x33,0x0,0x31,0x80,0x30,0xc0,0x30,0x60,0x30,0x30,0x30,0x18,
-0xfc,0x7e,
-};
-
-static const BitmapCharRec ch75 = {16,17,-1,0,17,ch75data};
-
-/* char: 0x4a 'J' */
-
-static const GLubyte ch74data[] = {
-0x78,0x0,0xcc,0x0,0xc6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-0x1f,0x80,
-};
-
-static const BitmapCharRec ch74 = {9,17,-1,0,11,ch74data};
-
-/* char: 0x49 'I' */
-
-static const GLubyte ch73data[] = {
-0xfc,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
-0xfc,
-};
-
-static const BitmapCharRec ch73 = {6,17,-1,0,8,ch73data};
-
-/* char: 0x48 'H' */
-
-static const GLubyte ch72data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,
-0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x3f,0xfe,0x0,0x30,0x6,0x0,0x30,0x6,
-0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,0x30,0x6,0x0,
-0xfc,0x1f,0x80,
-};
-
-static const BitmapCharRec ch72 = {17,17,-1,0,19,ch72data};
-
-/* char: 0x47 'G' */
-
-static const GLubyte ch71data[] = {
-0x7,0xe0,0x1e,0x38,0x38,0x1c,0x60,0xc,0x60,0xc,0xc0,0xc,0xc0,0xc,0xc0,0x3f,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0x60,0x4,0x60,0x4,0x38,0xc,0x1c,0x3c,
-0x7,0xe4,
-};
-
-static const BitmapCharRec ch71 = {16,17,-1,0,18,ch71data};
-
-/* char: 0x46 'F' */
-
-static const GLubyte ch70data[] = {
-0xfc,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x0,0x30,0x20,0x30,0x20,
-0x3f,0xe0,0x30,0x20,0x30,0x20,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,
-};
-
-static const BitmapCharRec ch70 = {12,17,-1,0,14,ch70data};
-
-/* char: 0x45 'E' */
-
-static const GLubyte ch69data[] = {
-0xff,0xf8,0x30,0x18,0x30,0x8,0x30,0x8,0x30,0x0,0x30,0x0,0x30,0x40,0x30,0x40,
-0x3f,0xc0,0x30,0x40,0x30,0x40,0x30,0x0,0x30,0x0,0x30,0x10,0x30,0x10,0x30,0x30,
-0xff,0xf0,
-};
-
-static const BitmapCharRec ch69 = {13,17,-1,0,15,ch69data};
-
-/* char: 0x44 'D' */
-
-static const GLubyte ch68data[] = {
-0xff,0xc0,0x30,0x70,0x30,0x38,0x30,0xc,0x30,0xc,0x30,0x6,0x30,0x6,0x30,0x6,
-0x30,0x6,0x30,0x6,0x30,0x6,0x30,0x6,0x30,0xc,0x30,0xc,0x30,0x38,0x30,0x70,
-0xff,0xc0,
-};
-
-static const BitmapCharRec ch68 = {15,17,-1,0,17,ch68data};
-
-/* char: 0x43 'C' */
-
-static const GLubyte ch67data[] = {
-0x7,0xe0,0x1e,0x38,0x38,0x8,0x60,0x4,0x60,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,
-0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0x60,0x4,0x60,0x4,0x38,0xc,0x1c,0x3c,
-0x7,0xe4,
-};
-
-static const BitmapCharRec ch67 = {14,17,-1,0,16,ch67data};
-
-/* char: 0x42 'B' */
-
-static const GLubyte ch66data[] = {
-0xff,0xe0,0x30,0x78,0x30,0x18,0x30,0xc,0x30,0xc,0x30,0xc,0x30,0x18,0x30,0x38,
-0x3f,0xe0,0x30,0x40,0x30,0x30,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x30,0x30,0x70,
-0xff,0xc0,
-};
-
-static const BitmapCharRec ch66 = {14,17,-1,0,16,ch66data};
-
-/* char: 0x41 'A' */
-
-static const GLubyte ch65data[] = {
-0xfc,0x1f,0x80,0x30,0x6,0x0,0x10,0x6,0x0,0x10,0xc,0x0,0x18,0xc,0x0,0x8,
-0xc,0x0,0xf,0xf8,0x0,0xc,0x18,0x0,0x4,0x18,0x0,0x4,0x30,0x0,0x6,0x30,
-0x0,0x2,0x30,0x0,0x2,0x60,0x0,0x1,0x60,0x0,0x1,0xc0,0x0,0x1,0xc0,0x0,
-0x0,0x80,0x0,
-};
-
-static const BitmapCharRec ch65 = {17,17,0,0,17,ch65data};
-
-/* char: 0x40 '@' */
-
-static const GLubyte ch64data[] = {
-0x3,0xf0,0x0,0xe,0xc,0x0,0x18,0x0,0x0,0x30,0x0,0x0,0x61,0xde,0x0,0x63,
-0x7b,0x0,0xc6,0x39,0x80,0xc6,0x18,0x80,0xc6,0x18,0xc0,0xc6,0x18,0x40,0xc6,0xc,
-0x40,0xc3,0xc,0x40,0xc3,0x8c,0x40,0xe1,0xfc,0x40,0x60,0xec,0xc0,0x70,0x0,0x80,
-0x38,0x1,0x80,0x1c,0x3,0x0,0xf,0xe,0x0,0x3,0xf8,0x0,
-};
-
-static const BitmapCharRec ch64 = {18,20,-2,3,22,ch64data};
-
-/* char: 0x3f '?' */
-
-static const GLubyte ch63data[] = {
-0x30,0x30,0x0,0x0,0x10,0x10,0x10,0x18,0x18,0xc,0xe,0x7,0xc3,0xc3,0x83,0xc6,
-0x7c,
-};
-
-static const BitmapCharRec ch63 = {8,17,-2,0,11,ch63data};
-
-/* char: 0x3e '>' */
-
-static const GLubyte ch62data[] = {
-0xc0,0x0,0x70,0x0,0x1c,0x0,0x7,0x0,0x1,0xc0,0x0,0x60,0x1,0xc0,0x7,0x0,
-0x1c,0x0,0x70,0x0,0xc0,0x0,
-};
-
-static const BitmapCharRec ch62 = {11,11,-1,-1,13,ch62data};
-
-/* char: 0x3d '=' */
-
-static const GLubyte ch61data[] = {
-0xff,0xf0,0xff,0xf0,0x0,0x0,0x0,0x0,0xff,0xf0,0xff,0xf0,
-};
-
-static const BitmapCharRec ch61 = {12,6,-1,-4,14,ch61data};
-
-/* char: 0x3c '<' */
-
-static const GLubyte ch60data[] = {
-0x0,0x60,0x1,0xc0,0x7,0x0,0x1c,0x0,0x70,0x0,0xc0,0x0,0x70,0x0,0x1c,0x0,
-0x7,0x0,0x1,0xc0,0x0,0x60,
-};
-
-static const BitmapCharRec ch60 = {11,11,-1,-1,13,ch60data};
-
-/* char: 0x3b ';' */
-
-static const GLubyte ch59data[] = {
-0xc0,0x60,0x20,0xe0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch59 = {3,14,-2,3,7,ch59data};
-
-/* char: 0x3a ':' */
-
-static const GLubyte ch58data[] = {
-0xc0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xc0,
-};
-
-static const BitmapCharRec ch58 = {2,11,-2,0,6,ch58data};
-
-/* char: 0x39 '9' */
-
-static const GLubyte ch57data[] = {
-0xf0,0x0,0x1c,0x0,0x6,0x0,0x3,0x0,0x3,0x80,0x1,0x80,0x1d,0x80,0x73,0xc0,
-0x61,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0x61,0x80,0x77,0x80,
-0x1e,0x0,
-};
-
-static const BitmapCharRec ch57 = {10,17,-1,0,12,ch57data};
-
-/* char: 0x38 '8' */
-
-static const GLubyte ch56data[] = {
-0x1e,0x0,0x73,0x80,0xe1,0x80,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x41,0xc0,0x61,0x80,
-0x37,0x0,0x1e,0x0,0x1e,0x0,0x33,0x0,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x0,
-0x1e,0x0,
-};
-
-static const BitmapCharRec ch56 = {10,17,-1,0,12,ch56data};
-
-/* char: 0x37 '7' */
-
-static const GLubyte ch55data[] = {
-0x18,0x0,0x18,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0x4,0x0,0x6,0x0,0x6,0x0,
-0x2,0x0,0x3,0x0,0x3,0x0,0x1,0x0,0x1,0x80,0x81,0x80,0xc0,0xc0,0xff,0xc0,
-0x7f,0xc0,
-};
-
-static const BitmapCharRec ch55 = {10,17,-1,0,12,ch55data};
-
-/* char: 0x36 '6' */
-
-static const GLubyte ch54data[] = {
-0x1e,0x0,0x7b,0x80,0x61,0x80,0xe0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc1,0x80,0xf3,0x80,0xee,0x0,0x60,0x0,0x70,0x0,0x30,0x0,0x18,0x0,0xe,0x0,
-0x3,0xc0,
-};
-
-static const BitmapCharRec ch54 = {10,17,-1,0,12,ch54data};
-
-/* char: 0x35 '5' */
-
-static const GLubyte ch53data[] = {
-0x7e,0x0,0xe3,0x80,0xc1,0x80,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x0,0xc0,0x1,0xc0,
-0x3,0x80,0xf,0x80,0x7e,0x0,0x78,0x0,0x60,0x0,0x20,0x0,0x20,0x0,0x1f,0x80,
-0x1f,0xc0,
-};
-
-static const BitmapCharRec ch53 = {10,17,-1,0,12,ch53data};
-
-/* char: 0x34 '4' */
-
-static const GLubyte ch52data[] = {
-0x3,0x0,0x3,0x0,0x3,0x0,0x3,0x0,0xff,0xc0,0xff,0xc0,0xc3,0x0,0x43,0x0,
-0x63,0x0,0x23,0x0,0x33,0x0,0x13,0x0,0x1b,0x0,0xb,0x0,0x7,0x0,0x7,0x0,
-0x3,0x0,
-};
-
-static const BitmapCharRec ch52 = {10,17,-1,0,12,ch52data};
-
-/* char: 0x33 '3' */
-
-static const GLubyte ch51data[] = {
-0x78,0x0,0xe6,0x0,0xc3,0x0,0x1,0x0,0x1,0x80,0x1,0x80,0x1,0x80,0x3,0x80,
-0x7,0x0,0x1e,0x0,0xc,0x0,0x6,0x0,0x83,0x0,0x83,0x0,0x47,0x0,0x7e,0x0,
-0x1c,0x0,
-};
-
-static const BitmapCharRec ch51 = {9,17,-1,0,12,ch51data};
-
-/* char: 0x32 '2' */
-
-static const GLubyte ch50data[] = {
-0xff,0x80,0xff,0xc0,0x60,0x40,0x30,0x0,0x18,0x0,0xc,0x0,0x4,0x0,0x6,0x0,
-0x3,0x0,0x3,0x0,0x1,0x80,0x1,0x80,0x81,0x80,0x81,0x80,0x43,0x80,0x7f,0x0,
-0x1c,0x0,
-};
-
-static const BitmapCharRec ch50 = {10,17,-1,0,12,ch50data};
-
-/* char: 0x31 '1' */
-
-static const GLubyte ch49data[] = {
-0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x78,0x18,
-0x8,
-};
-
-static const BitmapCharRec ch49 = {8,17,-2,0,12,ch49data};
-
-/* char: 0x30 '0' */
-
-static const GLubyte ch48data[] = {
-0x1e,0x0,0x33,0x0,0x61,0x80,0x61,0x80,0xe1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x61,0x80,0x61,0x80,0x33,0x0,
-0x1e,0x0,
-};
-
-static const BitmapCharRec ch48 = {10,17,-1,0,12,ch48data};
-
-/* char: 0x2f '/' */
-
-static const GLubyte ch47data[] = {
-0xc0,0xc0,0xc0,0x60,0x60,0x20,0x30,0x30,0x10,0x18,0x18,0x8,0xc,0xc,0x4,0x6,
-0x6,0x3,0x3,0x3,
-};
-
-static const BitmapCharRec ch47 = {8,20,1,3,7,ch47data};
-
-/* char: 0x2e '.' */
-
-static const GLubyte ch46data[] = {
-0xc0,0xc0,
-};
-
-static const BitmapCharRec ch46 = {2,2,-2,0,6,ch46data};
-
-/* char: 0x2d '-' */
-
-static const GLubyte ch45data[] = {
-0xff,0xf0,0xff,0xf0,
-};
-
-static const BitmapCharRec ch45 = {12,2,-1,-6,14,ch45data};
-
-/* char: 0x2c ',' */
-
-static const GLubyte ch44data[] = {
-0xc0,0x60,0x20,0xe0,0xc0,
-};
-
-static const BitmapCharRec ch44 = {3,5,-2,3,7,ch44data};
-
-/* char: 0x2b '+' */
-
-static const GLubyte ch43data[] = {
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,0xff,0xf0,0xff,0xf0,0x6,0x0,
-0x6,0x0,0x6,0x0,0x6,0x0,0x6,0x0,
-};
-
-static const BitmapCharRec ch43 = {12,12,-1,-1,14,ch43data};
-
-/* char: 0x2a '*' */
-
-static const GLubyte ch42data[] = {
-0x8,0x0,0x1c,0x0,0xc9,0x80,0xeb,0x80,0x1c,0x0,0xeb,0x80,0xc9,0x80,0x1c,0x0,
-0x8,0x0,
-};
-
-static const BitmapCharRec ch42 = {9,9,-2,-8,12,ch42data};
-
-/* char: 0x29 ')' */
-
-static const GLubyte ch41data[] = {
-0x80,0x40,0x20,0x30,0x10,0x18,0x18,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0x18,
-0x18,0x10,0x30,0x20,0x40,0x80,
-};
-
-static const BitmapCharRec ch41 = {6,22,-1,5,8,ch41data};
-
-/* char: 0x28 '(' */
-
-static const GLubyte ch40data[] = {
-0x4,0x8,0x10,0x30,0x20,0x60,0x60,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x60,
-0x60,0x20,0x30,0x10,0x8,0x4,
-};
-
-static const BitmapCharRec ch40 = {6,22,-1,5,8,ch40data};
-
-/* char: 0x27 ''' */
-
-static const GLubyte ch39data[] = {
-0xc0,0x60,0x20,0xe0,0xc0,
-};
-
-static const BitmapCharRec ch39 = {3,5,-3,-12,8,ch39data};
-
-/* char: 0x26 '&' */
-
-static const GLubyte ch38data[] = {
-0x3c,0x3c,0x7f,0x7e,0xe1,0xe1,0xc0,0xc0,0xc1,0xc0,0xc1,0xa0,0x63,0x20,0x37,0x10,
-0x1e,0x18,0xe,0x3e,0xf,0x0,0x1d,0x80,0x18,0xc0,0x18,0x40,0x18,0x40,0xc,0xc0,
-0x7,0x80,
-};
-
-static const BitmapCharRec ch38 = {16,17,-1,0,18,ch38data};
-
-/* char: 0x25 '%' */
-
-static const GLubyte ch37data[] = {
-0x30,0x3c,0x0,0x18,0x72,0x0,0xc,0x61,0x0,0x4,0x60,0x80,0x6,0x60,0x80,0x3,
-0x30,0x80,0x1,0x19,0x80,0x1,0x8f,0x0,0x78,0xc0,0x0,0xe4,0x40,0x0,0xc2,0x60,
-0x0,0xc1,0x30,0x0,0xc1,0x10,0x0,0x61,0x18,0x0,0x33,0xfc,0x0,0x1e,0xc,0x0,
-};
-
-static const BitmapCharRec ch37 = {17,16,-1,0,19,ch37data};
-
-/* char: 0x24 '$' */
-
-static const GLubyte ch36data[] = {
-0x4,0x0,0x4,0x0,0x3f,0x0,0xe5,0xc0,0xc4,0xc0,0x84,0x60,0x84,0x60,0x4,0x60,
-0x4,0xe0,0x7,0xc0,0x7,0x80,0x1e,0x0,0x3c,0x0,0x74,0x0,0x64,0x0,0x64,0x20,
-0x64,0x60,0x34,0xe0,0x1f,0x80,0x4,0x0,0x4,0x0,
-};
-
-static const BitmapCharRec ch36 = {11,21,0,2,12,ch36data};
-
-/* char: 0x23 '#' */
-
-static const GLubyte ch35data[] = {
-0x22,0x0,0x22,0x0,0x22,0x0,0x22,0x0,0x22,0x0,0xff,0xc0,0xff,0xc0,0x11,0x0,
-0x11,0x0,0x11,0x0,0x7f,0xe0,0x7f,0xe0,0x8,0x80,0x8,0x80,0x8,0x80,0x8,0x80,
-0x8,0x80,
-};
-
-static const BitmapCharRec ch35 = {11,17,-1,0,13,ch35data};
-
-/* char: 0x22 '"' */
-
-static const GLubyte ch34data[] = {
-0x88,0xcc,0xcc,0xcc,0xcc,
-};
-
-static const BitmapCharRec ch34 = {6,5,-1,-12,10,ch34data};
-
-/* char: 0x21 '!' */
-
-static const GLubyte ch33data[] = {
-0xc0,0xc0,0x0,0x0,0x0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
-0xc0,
-};
-
-static const BitmapCharRec ch33 = {2,17,-3,0,8,ch33data};
-
-/* char: 0x20 ' ' */
-
-#ifdef _WIN32
-/* XXX Work around Microsoft OpenGL 1.1 bug where glBitmap with
-   a height or width of zero does not advance the raster position
-   as specified by OpenGL. (Cosmo OpenGL does not have this bug.) */
-static const GLubyte ch32data[] = { 0x0 };
-static const BitmapCharRec ch32 = {1,1,0,0,6,ch32data};
-#else
-static const BitmapCharRec ch32 = {0,0,0,0,6,0};
-#endif
-
-static const BitmapCharRec * const chars[] = {
-&ch32,
-&ch33,
-&ch34,
-&ch35,
-&ch36,
-&ch37,
-&ch38,
-&ch39,
-&ch40,
-&ch41,
-&ch42,
-&ch43,
-&ch44,
-&ch45,
-&ch46,
-&ch47,
-&ch48,
-&ch49,
-&ch50,
-&ch51,
-&ch52,
-&ch53,
-&ch54,
-&ch55,
-&ch56,
-&ch57,
-&ch58,
-&ch59,
-&ch60,
-&ch61,
-&ch62,
-&ch63,
-&ch64,
-&ch65,
-&ch66,
-&ch67,
-&ch68,
-&ch69,
-&ch70,
-&ch71,
-&ch72,
-&ch73,
-&ch74,
-&ch75,
-&ch76,
-&ch77,
-&ch78,
-&ch79,
-&ch80,
-&ch81,
-&ch82,
-&ch83,
-&ch84,
-&ch85,
-&ch86,
-&ch87,
-&ch88,
-&ch89,
-&ch90,
-&ch91,
-&ch92,
-&ch93,
-&ch94,
-&ch95,
-&ch96,
-&ch97,
-&ch98,
-&ch99,
-&ch100,
-&ch101,
-&ch102,
-&ch103,
-&ch104,
-&ch105,
-&ch106,
-&ch107,
-&ch108,
-&ch109,
-&ch110,
-&ch111,
-&ch112,
-&ch113,
-&ch114,
-&ch115,
-&ch116,
-&ch117,
-&ch118,
-&ch119,
-&ch120,
-&ch121,
-&ch122,
-&ch123,
-&ch124,
-&ch125,
-&ch126,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-0,
-&ch160,
-&ch161,
-&ch162,
-&ch163,
-&ch164,
-&ch165,
-&ch166,
-&ch167,
-&ch168,
-&ch169,
-&ch170,
-&ch171,
-&ch172,
-&ch173,
-&ch174,
-&ch175,
-&ch176,
-&ch177,
-&ch178,
-&ch179,
-&ch180,
-&ch181,
-&ch182,
-&ch183,
-&ch184,
-&ch185,
-&ch186,
-&ch187,
-&ch188,
-&ch189,
-&ch190,
-&ch191,
-&ch192,
-&ch193,
-&ch194,
-&ch195,
-&ch196,
-&ch197,
-&ch198,
-&ch199,
-&ch200,
-&ch201,
-&ch202,
-&ch203,
-&ch204,
-&ch205,
-&ch206,
-&ch207,
-&ch208,
-&ch209,
-&ch210,
-&ch211,
-&ch212,
-&ch213,
-&ch214,
-&ch215,
-&ch216,
-&ch217,
-&ch218,
-&ch219,
-&ch220,
-&ch221,
-&ch222,
-&ch223,
-&ch224,
-&ch225,
-&ch226,
-&ch227,
-&ch228,
-&ch229,
-&ch230,
-&ch231,
-&ch232,
-&ch233,
-&ch234,
-&ch235,
-&ch236,
-&ch237,
-&ch238,
-&ch239,
-&ch240,
-&ch241,
-&ch242,
-&ch243,
-&ch244,
-&ch245,
-&ch246,
-&ch247,
-&ch248,
-&ch249,
-&ch250,
-&ch251,
-&ch252,
-&ch253,
-&ch254,
-&ch255,
-};
-
-GLUTAPI const BitmapFontRec glutBitmapTimesRoman24;
-const BitmapFontRec glutBitmapTimesRoman24 = {
-"-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
-224,
-32,
-chars
-};
-
diff --git a/src/glut/glx/glut_util.c b/src/glut/glx/glut_util.c
deleted file mode 100644 (file)
index 4ebac64..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "glutint.h"
-
-/* strdup is actually not a standard ANSI C or POSIX routine
-   so implement a private one for GLUT.  OpenVMS does not have a
-   strdup; Linux's standard libc doesn't declare strdup by default
-   (unless BSD or SVID interfaces are requested). */
-char *
-__glutStrdup(const char *string)
-{
-  char *copy;
-
-  copy = (char*) malloc(strlen(string) + 1);
-  if (copy == NULL)
-    return NULL;
-  strcpy(copy, string);
-  return copy;
-}
-
-void
-__glutWarning(char *format,...)
-{
-  va_list args;
-
-  va_start(args, format);
-  fprintf(stderr, "GLUT: Warning in %s: ",
-    __glutProgramName ? __glutProgramName : "(unamed)");
-  vfprintf(stderr, format, args);
-  va_end(args);
-  putc('\n', stderr);
-}
-
-/* CENTRY */
-void GLUTAPIENTRY 
-glutReportErrors(void)
-{
-  GLenum error;
-
-  while ((error = glGetError()) != GL_NO_ERROR)
-    __glutWarning("GL error: %s", gluErrorString(error));
-}
-/* ENDCENTRY */
-
-void
-__glutFatalError(char *format,...)
-{
-  va_list args;
-
-  va_start(args, format);
-  fprintf(stderr, "GLUT: Fatal Error in %s: ",
-    __glutProgramName ? __glutProgramName : "(unamed)");
-  vfprintf(stderr, format, args);
-  va_end(args);
-  putc('\n', stderr);
-#ifdef _WIN32
-  if (__glutExitFunc) {
-    __glutExitFunc(1);
-  }
-#endif
-  exit(1);
-}
-
-void
-__glutFatalUsage(char *format,...)
-{
-  va_list args;
-
-  va_start(args, format);
-  fprintf(stderr, "GLUT: Fatal API Usage in %s: ",
-    __glutProgramName ? __glutProgramName : "(unamed)");
-  vfprintf(stderr, format, args);
-  va_end(args);
-  putc('\n', stderr);
-  abort();
-}
diff --git a/src/glut/glx/glut_vidresize.c b/src/glut/glx/glut_vidresize.c
deleted file mode 100644 (file)
index 5993e83..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1996. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-
-#ifdef __sgi
-#include <dlfcn.h>
-#endif
-
-#include "glutint.h"
-
-/* Grumble.  The IRIX 6.3 and early IRIX 6.4 OpenGL headers
-   support the video resize extension, but failed to define
-   GLX_SGIX_video_resize. */
-#if 0
-#ifdef GLX_SYNC_FRAME_SGIX
-#define GLX_SGIX_video_resize 1
-#endif
-#endif
-
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-static int canVideoResize = -1;
-static int videoResizeChannel;
-#else
-static int canVideoResize = 0;
-#endif
-static int videoResizeInUse = 0;
-static int dx = -1, dy = -1, dw = -1, dh = -1;
-
-/* XXX Note that IRIX 6.2, 6.3, and some 6.4 versions have a
-   bug where programs seg-fault when they attempt video
-   resizing from an indirect OpenGL context (either local or
-   over a network). */
-
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-
-static volatile int errorCaught;
-
-/* ARGSUSED */
-static int
-catchXSGIvcErrors(Display * dpy, XErrorEvent * event)
-{
-  errorCaught = 1;
-  return 0;
-}
-#endif
-
-/* CENTRY */
-int GLUTAPIENTRY 
-glutVideoResizeGet(GLenum param)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (canVideoResize < 0) {
-    canVideoResize = __glutIsSupportedByGLX("GLX_SGIX_video_resize");
-    if (canVideoResize) {
-#if defined(__sgi) && __sgi
-      /* This is a hack because IRIX 6.2, 6.3, and some 6.4
-         versions were released with GLX_SGIX_video_resize
-         being advertised by the X server though the video
-         resize extension is not actually supported.  We try to
-         determine if the libGL.so we are using actually has a
-         video resize entrypoint before we try to use the
-         feature. */
-      void (*func) (void);
-      void *glxDso = dlopen("libGL.so", RTLD_LAZY);
-
-      func = (void (*)(void)) dlsym(glxDso, "glXQueryChannelDeltasSGIX");
-      if (!func) {
-        canVideoResize = 0;
-      } else
-#endif
-      {
-        char *channelString;
-        int (*handler) (Display *, XErrorEvent *);
-
-        channelString = getenv("GLUT_VIDEO_RESIZE_CHANNEL");
-        videoResizeChannel = channelString ? atoi(channelString) : 0;
-
-        /* Work around another annoying problem with SGI's
-           GLX_SGIX_video_resize implementation.  Early IRIX
-           6.4 OpenGL's advertise the extension and have the
-           video resize API, but an XSGIvc X protocol errors
-           result trying to use the API.  Set up an error
-           handler to intercept what would otherwise be a fatal
-           error.  If an error was recieved, do not report that
-           video resize is possible. */
-        handler = XSetErrorHandler(catchXSGIvcErrors);
-
-        errorCaught = 0;
-
-#if defined(GLX_GLXEXT_PROTOTYPES)
-#endif
-
-        __glut_glXQueryChannelDeltasSGIX(__glutDisplay, __glutScreen,
-          videoResizeChannel, &dx, &dy, &dw, &dh);
-
-        /* glXQueryChannelDeltasSGIX is an inherent X server
-           round-trip so we know we will have gotten either the
-           correct reply or and error by this time. */
-        XSetErrorHandler(handler);
-
-        /* Still yet another work around.  In IRIX 6.4 betas,
-           glXQueryChannelDeltasSGIX will return as if it
-           succeeded, but the values are filled with junk.
-           Watch to make sure the delta variables really make
-           sense. */
-        if (errorCaught ||
-          dx < 0 || dy < 0 || dw < 0 || dh < 0 ||
-          dx > 2048 || dy > 2048 || dw > 2048 || dh > 2048) {
-          canVideoResize = 0;
-        }
-      }
-    }
-  }
-#endif /* GLX_SGIX_video_resize */
-
-  switch (param) {
-  case GLUT_VIDEO_RESIZE_POSSIBLE:
-    return canVideoResize;
-  case GLUT_VIDEO_RESIZE_IN_USE:
-    return videoResizeInUse;
-  case GLUT_VIDEO_RESIZE_X_DELTA:
-    return dx;
-  case GLUT_VIDEO_RESIZE_Y_DELTA:
-    return dy;
-  case GLUT_VIDEO_RESIZE_WIDTH_DELTA:
-    return dw;
-  case GLUT_VIDEO_RESIZE_HEIGHT_DELTA:
-    return dh;
-  case GLUT_VIDEO_RESIZE_X:
-  case GLUT_VIDEO_RESIZE_Y:
-  case GLUT_VIDEO_RESIZE_WIDTH:
-  case GLUT_VIDEO_RESIZE_HEIGHT:
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-    if (videoResizeInUse) {
-      int x, y, width, height;
-
-      __glut_glXQueryChannelRectSGIX(__glutDisplay, __glutScreen,
-        videoResizeChannel, &x, &y, &width, &height);
-      switch (param) {
-      case GLUT_VIDEO_RESIZE_X:
-        return x;
-      case GLUT_VIDEO_RESIZE_Y:
-        return y;
-      case GLUT_VIDEO_RESIZE_WIDTH:
-        return width;
-      case GLUT_VIDEO_RESIZE_HEIGHT:
-        return height;
-      }
-    }
-#endif
-    return -1;
-  default:
-    __glutWarning("invalid glutVideoResizeGet parameter: %d", param);
-    return -1;
-  }
-}
-
-void GLUTAPIENTRY 
-glutSetupVideoResizing(void)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
-    __glut_glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, __glutCurrentWindow->win);
-    videoResizeInUse = 1;
-  } else
-#endif
-    __glutFatalError("glutEstablishVideoResizing: video resizing not possible.\n");
-}
-
-void GLUTAPIENTRY 
-glutStopVideoResizing(void)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
-    if (videoResizeInUse) {
-      __glut_glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
-        videoResizeChannel, None);
-      videoResizeInUse = 0;
-    }
-  }
-#endif
-}
-
-/* ARGSUSED */
-void GLUTAPIENTRY 
-glutVideoResize(int x, int y, int width, int height)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (videoResizeInUse) {
-#ifdef GLX_SYNC_SWAP_SGIX
-    /* glXChannelRectSyncSGIX introduced in a patch to IRIX
-       6.2; the original unpatched IRIX 6.2 behavior is always
-       GLX_SYNC_SWAP_SGIX. */
-    __glut_glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, GLX_SYNC_SWAP_SGIX);
-#endif
-    __glut_glXChannelRectSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, x, y, width, height);
-  }
-#endif
-}
-
-/* ARGSUSED */
-void GLUTAPIENTRY 
-glutVideoPan(int x, int y, int width, int height)
-{
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
-  if (videoResizeInUse) {
-#ifdef GLX_SYNC_FRAME_SGIX
-    /* glXChannelRectSyncSGIX introduced in a patch to IRIX
-       6.2; the original unpatched IRIX 6.2 behavior is always
-       GLX_SYNC_SWAP_SGIX.  We just ignore that we cannot
-       accomplish GLX_SYNC_FRAME_SGIX on IRIX unpatched 6.2;
-       this means you'd need a glutSwapBuffers to actually
-       realize the video resize. */
-    __glut_glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, GLX_SYNC_FRAME_SGIX);
-#endif
-    __glut_glXChannelRectSGIX(__glutDisplay, __glutScreen,
-      videoResizeChannel, x, y, width, height);
-  }
-#endif
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_warp.c b/src/glut/glx/glut_warp.c
deleted file mode 100644 (file)
index 3d48655..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1996, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "glutint.h"
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutWarpPointer(int x, int y)
-{
-  XWarpPointer(__glutDisplay, None, __glutCurrentWindow->win,
-    0, 0, 0, 0, x, y);
-  XFlush(__glutDisplay);
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glut_win.c b/src/glut/glx/glut_win.c
deleted file mode 100644 (file)
index 18554b3..0000000
+++ /dev/null
@@ -1,1035 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997.  */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#if !defined(_WIN32)
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#endif
-
-#include "glutint.h"
-
-GLUTwindow *__glutCurrentWindow = NULL;
-GLUTwindow **__glutWindowList = NULL;
-int __glutWindowListSize = 0;
-#if !defined(_WIN32)
-GLUTstale *__glutStaleWindowList = NULL;
-#endif
-GLUTwindow *__glutMenuWindow = NULL;
-
-void (*__glutFreeOverlayFunc) (GLUToverlay *);
-XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle,
-  Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc) = NULL;
-
-static Criterion requiredWindowCriteria[] =
-{
-  {LEVEL, EQ, 0},
-  {TRANSPARENT, EQ, 0}
-};
-static int numRequiredWindowCriteria = sizeof(requiredWindowCriteria) / sizeof(Criterion);
-static int requiredWindowCriteriaMask = (1 << LEVEL) | (1 << TRANSPARENT);
-
-static void
-cleanWindowWorkList(GLUTwindow * window)
-{
-  GLUTwindow **pEntry = &__glutWindowWorkList;
-  GLUTwindow *entry = __glutWindowWorkList;
-
-  /* Tranverse singly-linked window work list look for the
-     window. */
-  while (entry) {
-    if (entry == window) {
-      /* Found it; delete it. */
-      *pEntry = entry->prevWorkWin;
-      return;
-    } else {
-      pEntry = &entry->prevWorkWin;
-      entry = *pEntry;
-    }
-  }
-}
-
-#if !defined(_WIN32)
-
-static void
-cleanStaleWindowList(GLUTwindow * window)
-{
-  GLUTstale **pEntry = &__glutStaleWindowList;
-  GLUTstale *entry = __glutStaleWindowList;
-
-  /* Tranverse singly-linked stale window list look for the
-     window ID. */
-  while (entry) {
-    if (entry->window == window) {
-      /* Found it; delete it. */
-      *pEntry = entry->next;
-      free(entry);
-      return;
-    } else {
-      pEntry = &entry->next;
-      entry = *pEntry;
-    }
-  }
-}
-
-#endif
-
-static GLUTwindow *__glutWindowCache = NULL;
-
-GLUTwindow *
-__glutGetWindow(Window win)
-{
-  int i;
-
-  /* Does win belong to the last window ID looked up? */
-  if (__glutWindowCache && (win == __glutWindowCache->win ||
-      (__glutWindowCache->overlay && win ==
-        __glutWindowCache->overlay->win))) {
-    return
-      __glutWindowCache;
-  }
-  /* Otherwise scan the window list looking for the window ID. */
-  for (i = 0; i < __glutWindowListSize; i++) {
-    if (__glutWindowList[i]) {
-      if (win == __glutWindowList[i]->win) {
-        __glutWindowCache = __glutWindowList[i];
-        return __glutWindowCache;
-      }
-      if (__glutWindowList[i]->overlay) {
-        if (win == __glutWindowList[i]->overlay->win) {
-          __glutWindowCache = __glutWindowList[i];
-          return __glutWindowCache;
-        }
-      }
-    }
-  }
-#if !defined(_WIN32)
-  {
-    GLUTstale *entry;
-
-    /* Scan through destroyed overlay window IDs for which no
-       DestroyNotify has yet been received. */
-    for (entry = __glutStaleWindowList; entry; entry = entry->next) {
-      if (entry->win == win)
-        return entry->window;
-    }
-  }
-#endif
-  return NULL;
-}
-
-/* CENTRY */
-int GLUTAPIENTRY
-glutGetWindow(void)
-{
-  if (__glutCurrentWindow) {
-    return __glutCurrentWindow->num + 1;
-  } else {
-    return 0;
-  }
-}
-/* ENDCENTRY */
-
-void
-__glutSetWindow(GLUTwindow * window)
-{
-  /* It is tempting to try to short-circuit the call to
-     glXMakeCurrent if we "know" we are going to make current
-     to a window we are already current to.  In fact, this
-     assumption breaks when GLUT is expected to integrated with
-     other OpenGL windowing APIs that also make current to
-     OpenGL contexts.  Since glXMakeCurrent short-circuits the
-     "already bound" case, GLUT avoids the temptation to do so
-     too. */
-  __glutCurrentWindow = window;
-
-  MAKE_CURRENT_LAYER(__glutCurrentWindow);
-
-#if !defined(_WIN32)
-  /* We should be careful to force a finish between each
-     iteration through the GLUT main loop if indirect OpenGL 
-     contexts are in use; indirect contexts tend to have  much
-     longer latency because lots of OpenGL extension requests
-     can queue up in the X protocol stream.  We accomplish this
-     by posting GLUT_FINISH_WORK to be done. */
-  if (!__glutCurrentWindow->isDirect)
-    __glutPutOnWorkList(__glutCurrentWindow, GLUT_FINISH_WORK);
-#endif
-
-  /* If debugging is enabled, we'll want to check this window
-     for any OpenGL errors every iteration through the GLUT
-     main loop.  To accomplish this, we post the
-     GLUT_DEBUG_WORK to be done on this window. */
-  if (__glutDebug) {
-    __glutPutOnWorkList(__glutCurrentWindow, GLUT_DEBUG_WORK);
-  }
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutSetWindow(int win)
-{
-  GLUTwindow *window;
-
-  if (win < 1 || win > __glutWindowListSize) {
-    __glutWarning("glutSetWindow attempted on bogus window.");
-    return;
-  }
-  window = __glutWindowList[win - 1];
-  if (!window) {
-    __glutWarning("glutSetWindow attempted on bogus window.");
-    return;
-  }
-  __glutSetWindow(window);
-}
-/* ENDCENTRY */
-
-static int
-getUnusedWindowSlot(void)
-{
-  int i;
-
-  /* Look for allocated, unused slot. */
-  for (i = 0; i < __glutWindowListSize; i++) {
-    if (!__glutWindowList[i]) {
-      return i;
-    }
-  }
-  /* Allocate a new slot. */
-  __glutWindowListSize++;
-  if (__glutWindowList) {
-    __glutWindowList = (GLUTwindow **)
-      realloc(__glutWindowList,
-      __glutWindowListSize * sizeof(GLUTwindow *));
-  } else {
-    /* XXX Some realloc's do not correctly perform a malloc
-       when asked to perform a realloc on a NULL pointer,
-       though the ANSI C library spec requires this. */
-    __glutWindowList = (GLUTwindow **)
-      malloc(sizeof(GLUTwindow *));
-  }
-  if (!__glutWindowList)
-    __glutFatalError("out of memory.");
-  __glutWindowList[__glutWindowListSize - 1] = NULL;
-  return __glutWindowListSize - 1;
-}
-
-static XVisualInfo *
-getVisualInfoCI(unsigned int mode)
-{
-  static int bufSizeList[] =
-  {16, 12, 8, 4, 2, 1, 0};
-  XVisualInfo *vi;
-  int list[32];
-  int i, n = 0;
-
-  /* Should not be looking at display mode mask if
-     __glutDisplayString is non-NULL. */
-  assert(!__glutDisplayString);
-
-  list[n++] = GLX_BUFFER_SIZE;
-  list[n++] = 1;
-  if (GLUT_WIND_IS_DOUBLE(mode)) {
-    list[n++] = GLX_DOUBLEBUFFER;
-  }
-  if (GLUT_WIND_IS_STEREO(mode)) {
-    list[n++] = GLX_STEREO;
-  }
-  if (GLUT_WIND_HAS_DEPTH(mode)) {
-    list[n++] = GLX_DEPTH_SIZE;
-    list[n++] = 1;
-  }
-  if (GLUT_WIND_HAS_STENCIL(mode)) {
-    list[n++] = GLX_STENCIL_SIZE;
-    list[n++] = 1;
-  }
-  list[n] = (int) None; /* terminate list */
-
-  /* glXChooseVisual specify GLX_BUFFER_SIZE prefers the
-     "smallest index buffer of at least the specified size".
-     This would be reasonable if GLUT allowed the user to
-     specify the required buffe size, but GLUT's display mode
-     is too simplistic (easy to use?). GLUT should try to find
-     the "largest".  So start with a large buffer size and
-     shrink until we find a matching one that exists. */
-
-  for (i = 0; bufSizeList[i]; i++) {
-    /* XXX Assumes list[1] is where GLX_BUFFER_SIZE parameter
-       is. */
-    list[1] = bufSizeList[i];
-    vi = glXChooseVisual(__glutDisplay,
-      __glutScreen, list);
-    if (vi)
-      return vi;
-  }
-  return NULL;
-}
-
-static XVisualInfo *
-getVisualInfoRGB(unsigned int mode)
-{
-  int list[32];
-  int n = 0;
-
-  /* Should not be looking at display mode mask if
-     __glutDisplayString is non-NULL. */
-  assert(!__glutDisplayString);
-
-  /* XXX Would a caching mechanism to minize the calls to
-     glXChooseVisual? You'd have to reference count
-     XVisualInfo* pointers.  Would also have to properly
-     interact with glutInitDisplayString. */
-
-  list[n++] = GLX_RGBA;
-  list[n++] = GLX_RED_SIZE;
-  list[n++] = 1;
-  list[n++] = GLX_GREEN_SIZE;
-  list[n++] = 1;
-  list[n++] = GLX_BLUE_SIZE;
-  list[n++] = 1;
-  if (GLUT_WIND_HAS_ALPHA(mode)) {
-    list[n++] = GLX_ALPHA_SIZE;
-    list[n++] = 1;
-  }
-  if (GLUT_WIND_IS_DOUBLE(mode)) {
-    list[n++] = GLX_DOUBLEBUFFER;
-  }
-  if (GLUT_WIND_IS_STEREO(mode)) {
-    list[n++] = GLX_STEREO;
-  }
-  if (GLUT_WIND_HAS_DEPTH(mode)) {
-    list[n++] = GLX_DEPTH_SIZE;
-    list[n++] = 1;
-  }
-  if (GLUT_WIND_HAS_STENCIL(mode)) {
-    list[n++] = GLX_STENCIL_SIZE;
-    list[n++] = 1;
-  }
-  if (GLUT_WIND_HAS_ACCUM(mode)) {
-    list[n++] = GLX_ACCUM_RED_SIZE;
-    list[n++] = 1;
-    list[n++] = GLX_ACCUM_GREEN_SIZE;
-    list[n++] = 1;
-    list[n++] = GLX_ACCUM_BLUE_SIZE;
-    list[n++] = 1;
-    if (GLUT_WIND_HAS_ALPHA(mode)) {
-      list[n++] = GLX_ACCUM_ALPHA_SIZE;
-      list[n++] = 1;
-    }
-  }
-#if defined(GLX_VERSION_1_1) && (defined(GLX_SGIS_multisample) || defined(GLX_ARB_multisample))
-  if (GLUT_WIND_IS_MULTISAMPLE(mode)) {
-    if (!__glutIsSupportedByGLX("GLX_SGIS_multisample") &&
-        !__glutIsSupportedByGLX("GLX_ARB_multisample"))
-      return NULL;
-#if defined(GLX_ARB_multisample)
-    list[n++] = GLX_SAMPLES_ARB;
-#elif defined(GLX_SGIS_multisample)
-    list[n++] = GLX_SAMPLES_SGIS;
-#endif
-    /* XXX Is 4 a reasonable minimum acceptable number of
-       samples? */
-    list[n++] = 4;
-  }
-#endif
-  list[n] = (int) None; /* terminate list */
-
-  return glXChooseVisual(__glutDisplay,
-    __glutScreen, list);
-}
-
-#ifndef VisualIDMask
-#define VisualIDMask 0
-#endif
-
-static XVisualInfo *
-getVisualInfoID(int id)
-{
-   XVisualInfo temp;
-   int count;
-#if !defined(_WIN32)
-   temp.visualid = id;
-#endif
-   return XGetVisualInfo(__glutDisplay, VisualIDMask, &temp, &count);
-}
-
-
-XVisualInfo *
-__glutGetVisualInfo(unsigned int mode)
-{
-  char *visStr;
-  /* XXX GLUT_LUMINANCE not implemented for GLUT 3.0. */
-  if (GLUT_WIND_IS_LUMINANCE(mode))
-    return NULL;
-
-  visStr = getenv("GLUT_FORCE_VISUAL");
-  if (visStr) {
-     int id = atoi(visStr);
-     return getVisualInfoID(id);
-  }
-
-  if (GLUT_WIND_IS_RGB(mode))
-    return getVisualInfoRGB(mode);
-  else
-    return getVisualInfoCI(mode);
-}
-
-XVisualInfo *
-__glutDetermineVisual(
-  unsigned int displayMode,
-  Bool * treatAsSingle,
-  XVisualInfo * (getVisualInfo) (unsigned int))
-{
-  XVisualInfo *vis;
-
-  /* Should not be looking at display mode mask if
-     __glutDisplayString is non-NULL. */
-  assert(!__glutDisplayString);
-
-  *treatAsSingle = GLUT_WIND_IS_SINGLE(displayMode);
-  vis = getVisualInfo(displayMode);
-  if (!vis) {
-    /* Fallback cases when can't get exactly what was asked
-       for... */
-    if (GLUT_WIND_IS_SINGLE(displayMode)) {
-      /* If we can't find a single buffered visual, try looking
-         for a double buffered visual.  We can treat a double
-         buffered visual as a single buffer visual by changing
-         the draw buffer to GL_FRONT and treating any swap
-         buffers as no-ops. */
-      displayMode |= GLUT_DOUBLE;
-      vis = getVisualInfo(displayMode);
-      *treatAsSingle = True;
-    }
-    if (!vis && GLUT_WIND_IS_MULTISAMPLE(displayMode)) {
-      /* If we can't seem to get multisampling (ie, not Reality
-         Engine class graphics!), go without multisampling.  It
-         is up to the application to query how many multisamples
-         were allocated (0 equals no multisampling) if the
-         application is going to use multisampling for more than
-         just antialiasing. */
-      displayMode &= ~GLUT_MULTISAMPLE;
-      vis = getVisualInfo(displayMode);
-    }
-  }
-  return vis;
-}
-
-static void GLUTCALLBACK
-__glutDefaultDisplay(void)
-{
-  /* XXX Remove the warning after GLUT 3.0. */
-  __glutWarning("The following is a new check for GLUT 3.0; update your code.");
-  __glutFatalError(
-    "redisplay needed for window %d, but no display callback.",
-    __glutCurrentWindow->num + 1);
-}
-
-void GLUTCALLBACK
-__glutDefaultReshape(int width, int height)
-{
-  GLUToverlay *overlay;
-
-  /* Adjust the viewport of the window (and overlay if one
-     exists). */
-  MAKE_CURRENT_WINDOW(__glutCurrentWindow);
-  glViewport(0, 0, (GLsizei) width, (GLsizei) height);
-  overlay = __glutCurrentWindow->overlay;
-  if (overlay) {
-    MAKE_CURRENT_OVERLAY(overlay);
-    glViewport(0, 0, (GLsizei) width, (GLsizei) height);
-  }
-  /* Make sure we are current to the current layer (application
-     should be able to count on the current layer not changing
-     unless the application explicitly calls glutUseLayer). */
-  MAKE_CURRENT_LAYER(__glutCurrentWindow);
-}
-
-XVisualInfo *
-__glutDetermineWindowVisual(Bool * treatAsSingle, Bool * visAlloced, void **fbc)
-{
-  if (__glutDisplayString) {
-
-    /* __glutDisplayString should be NULL except if
-       glutInitDisplayString has been called to register a
-       different display string.  Calling glutInitDisplayString
-       means using a string instead of an integer mask determine
-       the visual to use. Using the function pointer variable
-       __glutDetermineVisualFromString below avoids linking in
-       the code for implementing glutInitDisplayString (ie,
-       glut_dstr.o) unless glutInitDisplayString gets called by
-       the application. */
-
-    assert(__glutDetermineVisualFromString);
-    *visAlloced = False;
-    *fbc = NULL;
-    return __glutDetermineVisualFromString(__glutDisplayString, treatAsSingle,
-      requiredWindowCriteria, numRequiredWindowCriteria, requiredWindowCriteriaMask, fbc);
-  } else {
-    *visAlloced = True;
-    *fbc = NULL;
-    return __glutDetermineVisual(__glutDisplayMode,
-      treatAsSingle, __glutGetVisualInfo);
-  }
-}
-
-/* ARGSUSED5 */  /* Only Win32 uses gameMode parameter. */
-GLUTwindow *
-__glutCreateWindow(GLUTwindow * parent,
-  int x, int y, int width, int height, int gameMode)
-{
-  GLUTwindow *window;
-  XSetWindowAttributes wa;
-  unsigned long attribMask;
-  int winnum;
-  int i;
-  void *fbc;
-
-#if defined(_WIN32)
-  WNDCLASS wc;
-  int style;
-
-  if (!GetClassInfo(GetModuleHandle(NULL), "GLUT", &wc)) {
-    __glutOpenWin32Connection(NULL);
-  }
-#else
-  if (!__glutDisplay) {
-    __glutOpenXConnection(NULL);
-  }
-#endif
-  if (__glutGameModeWindow) {
-    __glutFatalError("cannot create windows in game mode.");
-  }
-  winnum = getUnusedWindowSlot();
-  window = (GLUTwindow *) malloc(sizeof(GLUTwindow));
-  if (!window) {
-    __glutFatalError("out of memory.");
-  }
-  window->num = winnum;
-
-#if !defined(_WIN32)
-  window->vis = __glutDetermineWindowVisual(&window->treatAsSingle,
-    &window->visAlloced, &fbc);
-  if (!window->vis) {
-    __glutFatalError(
-      "visual with necessary capabilities not found.");
-  }
-  __glutSetupColormap(window->vis, &window->colormap, &window->cmap);
-#endif
-  window->eventMask = StructureNotifyMask | ExposureMask;
-
-  attribMask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
-  wa.background_pixmap = None;
-  wa.border_pixel = 0;
-  wa.colormap = window->cmap;
-  wa.event_mask = window->eventMask;
-  if (parent) {
-    if (parent->eventMask & GLUT_HACK_STOP_PROPAGATE_MASK)
-      wa.event_mask |= GLUT_HACK_STOP_PROPAGATE_MASK;
-    attribMask |= CWDontPropagate;
-    wa.do_not_propagate_mask = parent->eventMask & GLUT_DONT_PROPAGATE_FILTER_MASK;
-  } else {
-    wa.do_not_propagate_mask = 0;
-  }
-
-  /* Stash width and height before Win32's __glutAdjustCoords
-     possibly overwrites the values. */
-  window->width = width;
-  window->height = height;
-  window->forceReshape = True;
-  window->ignoreKeyRepeat = False;
-
-#if defined(_WIN32)
-  __glutAdjustCoords(parent ? parent->win : NULL,
-    &x, &y, &width, &height);
-  if (parent) {
-    style = WS_CHILD;
-  } else {
-    if (gameMode) {
-      /* Game mode window should be a WS_POPUP window to
-         ensure that the taskbar is hidden by it.  A standard
-         WS_OVERLAPPEDWINDOW does not hide the task bar. */
-      style = WS_POPUP | WS_MAXIMIZE;
-    } else {
-      /* A standard toplevel window with borders and such. */
-      style = WS_OVERLAPPEDWINDOW;
-    }
-  }
-  window->win = CreateWindow("GLUT", "GLUT",
-    WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style,
-    x, y, width, height, parent ? parent->win : __glutRoot,
-    NULL, GetModuleHandle(NULL), 0);
-  window->hdc = GetDC(window->win);
-  /* Must set the XHDC for fake glXChooseVisual & fake
-     glXCreateContext & fake XAllocColorCells. */
-  XHDC = window->hdc;
-  window->vis = __glutDetermineWindowVisual(&window->treatAsSingle,
-    &window->visAlloced, &fbc);
-  if (!window->vis) {
-    __glutFatalError(
-      "pixel format with necessary capabilities not found.");
-  }
-  if (!SetPixelFormat(window->hdc,
-      ChoosePixelFormat(window->hdc, window->vis),
-      window->vis)) {
-    __glutFatalError("SetPixelFormat failed during window create.");
-  }
-  __glutSetupColormap(window->vis, &window->colormap, &window->cmap);
-  /* Make sure subwindows get a windowStatus callback. */
-  if (parent) {
-    PostMessage(parent->win, WM_ACTIVATE, 0, 0);
-  }
-  window->renderDc = window->hdc;
-#else
-  window->win = XCreateWindow(__glutDisplay,
-    parent == NULL ? __glutRoot : parent->win,
-    x, y, width, height, 0,
-    window->vis->depth, InputOutput, window->vis->visual,
-    attribMask, &wa);
-#endif
-  window->renderWin = window->win;
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-  if (fbc) {
-    window->ctx = __glut_glXCreateContextWithConfigSGIX(__glutDisplay, fbc,
-      GLX_RGBA_TYPE_SGIX, None, __glutTryDirect);
-  } else
-#endif
-  {
-    window->ctx = glXCreateContext(__glutDisplay, window->vis,
-      None, __glutTryDirect);
-  }
-  if (!window->ctx) {
-    __glutFatalError(
-      "failed to create OpenGL rendering context.");
-  }
-  window->renderCtx = window->ctx;
-#if !defined(_WIN32)
-  window->isDirect = glXIsDirect(__glutDisplay, window->ctx);
-  if (__glutForceDirect) {
-    if (!window->isDirect)
-      __glutFatalError("direct rendering not possible.");
-  }
-#endif
-
-  window->parent = parent;
-  if (parent) {
-    window->siblings = parent->children;
-    parent->children = window;
-  } else {
-    window->siblings = NULL;
-  }
-  window->overlay = NULL;
-  window->children = NULL;
-  window->display = __glutDefaultDisplay;
-  window->reshape = __glutDefaultReshape;
-  window->mouse = NULL;
-  window->motion = NULL;
-  window->passive = NULL;
-  window->entry = NULL;
-  window->keyboard = NULL;
-  window->keyboardUp = NULL;
-  window->windowStatus = NULL;
-  window->visibility = NULL;
-  window->special = NULL;
-  window->specialUp = NULL;
-  window->buttonBox = NULL;
-  window->dials = NULL;
-  window->spaceMotion = NULL;
-  window->spaceRotate = NULL;
-  window->spaceButton = NULL;
-  window->tabletMotion = NULL;
-  window->tabletButton = NULL;
-#ifdef _WIN32
-  window->joystick = NULL;
-  window->joyPollInterval = 0;
-#endif
-  window->tabletPos[0] = -1;
-  window->tabletPos[1] = -1;
-  window->shownState = 0;
-  window->visState = -1;  /* not VisibilityUnobscured,
-                             VisibilityPartiallyObscured, or
-                             VisibilityFullyObscured */
-  window->entryState = -1;  /* not EnterNotify or LeaveNotify */
-
-  window->desiredConfMask = 0;
-  window->buttonUses = 0;
-  window->cursor = GLUT_CURSOR_INHERIT;
-
-  /* Setup window to be mapped when glutMainLoop starts. */
-  window->workMask = GLUT_MAP_WORK;
-#ifdef _WIN32
-  if (gameMode) {
-    /* When mapping a game mode window, just show
-       the window.  We have already created the game
-       mode window with a maximize flag at creation
-       time.  Doing a ShowWindow(window->win, SW_SHOWNORMAL)
-       would be wrong for a game mode window since it
-       would unmaximize the window. */
-    window->desiredMapState = GameModeState;
-  } else {
-    window->desiredMapState = NormalState;
-  }
-#else
-  window->desiredMapState = NormalState;
-#endif
-  window->prevWorkWin = __glutWindowWorkList;
-  __glutWindowWorkList = window;
-
-  /* Initially, no menus attached. */
-  for (i = 0; i < GLUT_MAX_MENUS; i++) {
-    window->menu[i] = 0;
-  }
-
-  /* Add this new window to the window list. */
-  __glutWindowList[winnum] = window;
-
-  /* Make the new window the current window. */
-  __glutSetWindow(window);
-
-  __glutDetermineMesaSwapHackSupport();
-
-  if (window->treatAsSingle) {
-    /* We do this because either the window really is single
-       buffered (in which case this is redundant, but harmless,
-       because this is the initial single-buffered context
-       state); or we are treating a double buffered window as a
-       single-buffered window because the system does not appear
-       to export any suitable single- buffered visuals (in which
-       the following are necessary). */
-    glDrawBuffer(GL_FRONT);
-    glReadBuffer(GL_FRONT);
-  }
-  return window;
-}
-
-/* CENTRY */
-int GLUTAPIENTRY
-glutCreateWindow(const char *title)
-{
-  static int firstWindow = 1;
-  GLUTwindow *window;
-#if !defined(_WIN32)
-  XWMHints *wmHints;
-#endif
-  Window win;
-  XTextProperty textprop;
-
-  if (__glutGameModeWindow) {
-    __glutFatalError("cannot create windows in game mode.");
-  }
-  window = __glutCreateWindow(NULL,
-    __glutSizeHints.x, __glutSizeHints.y,
-    __glutInitWidth, __glutInitHeight,
-    /* not game mode */ 0);
-  win = window->win;
-  /* Setup ICCCM properties. */
-  textprop.value = (unsigned char *) title;
-  textprop.encoding = XA_STRING;
-  textprop.format = 8;
-  textprop.nitems = strlen(title);
-#if defined(_WIN32)
-  SetWindowText(win, title);
-  if (__glutIconic) {
-    window->desiredMapState = IconicState;
-  }
-#else
-  wmHints = XAllocWMHints();
-  wmHints->initial_state =
-    __glutIconic ? IconicState : NormalState;
-  wmHints->flags = StateHint;
-  XSetWMProperties(__glutDisplay, win, &textprop, &textprop,
-  /* Only put WM_COMMAND property on first window. */
-    firstWindow ? __glutArgv : NULL,
-    firstWindow ? __glutArgc : 0,
-    &__glutSizeHints, wmHints, NULL);
-  XFree(wmHints);
-  XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1);
-#endif
-  firstWindow = 0;
-  return window->num + 1;
-}
-
-#ifdef _WIN32
-int GLUTAPIENTRY
-__glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int))
-{
-  __glutExitFunc = exitfunc;
-  return glutCreateWindow(title);
-}
-#endif
-
-int GLUTAPIENTRY
-glutCreateSubWindow(int win, int x, int y, int width, int height)
-{
-  GLUTwindow *window;
-
-  window = __glutCreateWindow(__glutWindowList[win - 1],
-    x, y, width, height, /* not game mode */ 0);
-#if !defined(_WIN32)
-  {
-    GLUTwindow *toplevel;
-
-    toplevel = __glutToplevelOf(window);
-    if (toplevel->cmap != window->cmap) {
-      __glutPutOnWorkList(toplevel, GLUT_COLORMAP_WORK);
-    }
-  }
-#endif
-  return window->num + 1;
-}
-/* ENDCENTRY */
-
-void
-__glutDestroyWindow(GLUTwindow * window,
-  GLUTwindow * initialWindow)
-{
-  GLUTwindow **prev, *cur, *parent, *siblings;
-
-  /* Recursively destroy any children. */
-  cur = window->children;
-  while (cur) {
-    siblings = cur->siblings;
-    __glutDestroyWindow(cur, initialWindow);
-    cur = siblings;
-  }
-  /* Remove from parent's children list (only necessary for
-     non-initial windows and subwindows!). */
-  parent = window->parent;
-  if (parent && parent == initialWindow->parent) {
-    prev = &parent->children;
-    cur = parent->children;
-    while (cur) {
-      if (cur == window) {
-        *prev = cur->siblings;
-        break;
-      }
-      prev = &(cur->siblings);
-      cur = cur->siblings;
-    }
-  }
-  /* Unbind if bound to this window. */
-  if (window == __glutCurrentWindow) {
-    UNMAKE_CURRENT();
-    __glutCurrentWindow = NULL;
-  }
-  /* Begin tearing down window itself. */
-  if (window->overlay) {
-    __glutFreeOverlayFunc(window->overlay);
-  }
-  XDestroyWindow(__glutDisplay, window->win);
-  glXDestroyContext(__glutDisplay, window->ctx);
-  if (window->colormap) {
-    /* Only color index windows have colormap data structure. */
-    __glutFreeColormap(window->colormap);
-  }
-  /* NULLing the __glutWindowList helps detect is a window
-     instance has been destroyed, given a window number. */
-  __glutWindowList[window->num] = NULL;
-
-  /* Cleanup data structures that might contain window. */
-  cleanWindowWorkList(window);
-#if !defined(_WIN32)
-  cleanStaleWindowList(window);
-#endif
-  /* Remove window from the "get window cache" if it is there. */
-  if (__glutWindowCache == window)
-    __glutWindowCache = NULL;
-
-  if (window->visAlloced) {
-    /* Only free XVisualInfo* gotten from glXChooseVisual. */
-    XFree(window->vis);
-  }
-
-  if (window == __glutGameModeWindow) {
-    /* Destroying the game mode window should implicitly
-       have GLUT leave game mode. */
-    __glutCloseDownGameMode();
-  }
-
-  free(window);
-}
-
-/* CENTRY */
-void GLUTAPIENTRY
-glutDestroyWindow(int win)
-{
-  GLUTwindow *window = __glutWindowList[win - 1];
-
-  if (__glutMappedMenu && __glutMenuWindow == window) {
-    __glutFatalUsage("destroying menu window not allowed while menus in use");
-  }
-#if !defined(_WIN32)
-  /* If not a toplevel window... */
-  if (window->parent) {
-    /* Destroying subwindows may change colormap requirements;
-       recalculate toplevel window's WM_COLORMAP_WINDOWS
-       property. */
-    __glutPutOnWorkList(__glutToplevelOf(window->parent),
-      GLUT_COLORMAP_WORK);
-  }
-#endif
-  __glutDestroyWindow(window, window);
-  XFlush(__glutDisplay);
-}
-/* ENDCENTRY */
-
-void
-__glutChangeWindowEventMask(long eventMask, Bool add)
-{
-  if (add) {
-    /* Add eventMask to window's event mask. */
-    if ((__glutCurrentWindow->eventMask & eventMask) !=
-      eventMask) {
-      __glutCurrentWindow->eventMask |= eventMask;
-      __glutPutOnWorkList(__glutCurrentWindow,
-        GLUT_EVENT_MASK_WORK);
-    }
-  } else {
-    /* Remove eventMask from window's event mask. */
-    if (__glutCurrentWindow->eventMask & eventMask) {
-      __glutCurrentWindow->eventMask &= ~eventMask;
-      __glutPutOnWorkList(__glutCurrentWindow,
-        GLUT_EVENT_MASK_WORK);
-    }
-  }
-}
-
-void GLUTAPIENTRY
-glutDisplayFunc(GLUTdisplayCB displayFunc)
-{
-  /* XXX Remove the warning after GLUT 3.0. */
-  if (!displayFunc)
-    __glutFatalError("NULL display callback not allowed in GLUT 3.0; update your code.");
-  __glutCurrentWindow->display = displayFunc;
-}
-
-void GLUTAPIENTRY
-glutMouseFunc(GLUTmouseCB mouseFunc)
-{
-  if (__glutCurrentWindow->mouse) {
-    if (!mouseFunc) {
-      /* Previous mouseFunc being disabled. */
-      __glutCurrentWindow->buttonUses--;
-      __glutChangeWindowEventMask(
-        ButtonPressMask | ButtonReleaseMask,
-        __glutCurrentWindow->buttonUses > 0);
-    }
-  } else {
-    if (mouseFunc) {
-      /* Previously no mouseFunc, new one being installed. */
-      __glutCurrentWindow->buttonUses++;
-      __glutChangeWindowEventMask(
-        ButtonPressMask | ButtonReleaseMask, True);
-    }
-  }
-  __glutCurrentWindow->mouse = mouseFunc;
-}
-
-void GLUTAPIENTRY
-glutMotionFunc(GLUTmotionCB motionFunc)
-{
-  /* Hack.  Some window managers (4Dwm by default) will mask
-     motion events if the client is not selecting for button
-     press and release events. So we select for press and
-     release events too (being careful to use reference
-     counting).  */
-  if (__glutCurrentWindow->motion) {
-    if (!motionFunc) {
-      /* previous mouseFunc being disabled */
-      __glutCurrentWindow->buttonUses--;
-      __glutChangeWindowEventMask(
-        ButtonPressMask | ButtonReleaseMask,
-        __glutCurrentWindow->buttonUses > 0);
-    }
-  } else {
-    if (motionFunc) {
-      /* Previously no mouseFunc, new one being installed. */
-      __glutCurrentWindow->buttonUses++;
-      __glutChangeWindowEventMask(
-        ButtonPressMask | ButtonReleaseMask, True);
-    }
-  }
-  /* Real work of selecting for passive mouse motion.  */
-  __glutChangeWindowEventMask(
-    Button1MotionMask | Button2MotionMask | Button3MotionMask,
-    motionFunc != NULL);
-  __glutCurrentWindow->motion = motionFunc;
-}
-
-void GLUTAPIENTRY
-glutPassiveMotionFunc(GLUTpassiveCB passiveMotionFunc)
-{
-  __glutChangeWindowEventMask(PointerMotionMask,
-    passiveMotionFunc != NULL);
-
-  /* Passive motion also requires watching enters and leaves so
-     that a fake passive motion event can be generated on an
-     enter. */
-  __glutChangeWindowEventMask(EnterWindowMask | LeaveWindowMask,
-    __glutCurrentWindow->entry != NULL || passiveMotionFunc != NULL);
-
-  __glutCurrentWindow->passive = passiveMotionFunc;
-}
-
-void GLUTAPIENTRY
-glutEntryFunc(GLUTentryCB entryFunc)
-{
-  __glutChangeWindowEventMask(EnterWindowMask | LeaveWindowMask,
-    entryFunc != NULL || __glutCurrentWindow->passive);
-  __glutCurrentWindow->entry = entryFunc;
-  if (!entryFunc) {
-    __glutCurrentWindow->entryState = -1;
-  }
-}
-
-void GLUTAPIENTRY
-glutWindowStatusFunc(GLUTwindowStatusCB windowStatusFunc)
-{
-  __glutChangeWindowEventMask(VisibilityChangeMask,
-    windowStatusFunc != NULL);
-  __glutCurrentWindow->windowStatus = windowStatusFunc;
-  if (!windowStatusFunc) {
-    /* Make state invalid. */
-    __glutCurrentWindow->visState = -1;
-  }
-}
-
-static void GLUTCALLBACK
-visibilityHelper(int status)
-{
-  if (status == GLUT_HIDDEN || status == GLUT_FULLY_COVERED)
-    __glutCurrentWindow->visibility(GLUT_NOT_VISIBLE);
-  else
-    __glutCurrentWindow->visibility(GLUT_VISIBLE);
-}
-
-void GLUTAPIENTRY
-glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
-{
-  __glutCurrentWindow->visibility = visibilityFunc;
-  if (visibilityFunc)
-    glutWindowStatusFunc(visibilityHelper);
-  else
-    glutWindowStatusFunc(NULL);
-}
-
-void GLUTAPIENTRY
-glutReshapeFunc(GLUTreshapeCB reshapeFunc)
-{
-  if (reshapeFunc) {
-    __glutCurrentWindow->reshape = reshapeFunc;
-  } else {
-    __glutCurrentWindow->reshape = __glutDefaultReshape;
-  }
-}
diff --git a/src/glut/glx/glut_winmisc.c b/src/glut/glx/glut_winmisc.c
deleted file mode 100644 (file)
index 0fc4c80..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994.  */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#if !defined(_WIN32)
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>  /* for XA_STRING atom */
-#endif
-
-#include "glutint.h"
-
-/* CENTRY */
-void GLUTAPIENTRY 
-glutSetWindowTitle(const char *title)
-{
-  XTextProperty textprop;
-
-  assert(!__glutCurrentWindow->parent);
-  IGNORE_IN_GAME_MODE();
-  textprop.value = (unsigned char *) title;
-  textprop.encoding = XA_STRING;
-  textprop.format = 8;
-  textprop.nitems = strlen(title);
-  XSetWMName(__glutDisplay,
-    __glutCurrentWindow->win, &textprop);
-  XFlush(__glutDisplay);
-}
-
-void GLUTAPIENTRY 
-glutSetIconTitle(const char *title)
-{
-  XTextProperty textprop;
-
-  assert(!__glutCurrentWindow->parent);
-  IGNORE_IN_GAME_MODE();
-  textprop.value = (unsigned char *) title;
-  textprop.encoding = XA_STRING;
-  textprop.format = 8;
-  textprop.nitems = strlen(title);
-  XSetWMIconName(__glutDisplay,
-    __glutCurrentWindow->win, &textprop);
-  XFlush(__glutDisplay);
-}
-
-void GLUTAPIENTRY 
-glutPositionWindow(int x, int y)
-{
-  IGNORE_IN_GAME_MODE();
-  __glutCurrentWindow->desiredX = x;
-  __glutCurrentWindow->desiredY = y;
-  __glutCurrentWindow->desiredConfMask |= CWX | CWY;
-  __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
-}
-
-void GLUTAPIENTRY 
-glutReshapeWindow(int w, int h)
-{
-  IGNORE_IN_GAME_MODE();
-  if (w <= 0 || h <= 0)
-    __glutWarning("glutReshapeWindow: non-positive width or height not allowed");
-
-  __glutCurrentWindow->desiredWidth = w;
-  __glutCurrentWindow->desiredHeight = h;
-  __glutCurrentWindow->desiredConfMask |= CWWidth | CWHeight;
-  __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
-}
-
-void GLUTAPIENTRY 
-glutPopWindow(void)
-{
-  IGNORE_IN_GAME_MODE();
-  __glutCurrentWindow->desiredStack = Above;
-  __glutCurrentWindow->desiredConfMask |= CWStackMode;
-  __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
-}
-
-void GLUTAPIENTRY 
-glutPushWindow(void)
-{
-  IGNORE_IN_GAME_MODE();
-  __glutCurrentWindow->desiredStack = Below;
-  __glutCurrentWindow->desiredConfMask |= CWStackMode;
-  __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
-}
-
-void GLUTAPIENTRY 
-glutIconifyWindow(void)
-{
-  IGNORE_IN_GAME_MODE();
-  assert(!__glutCurrentWindow->parent);
-  __glutCurrentWindow->desiredMapState = IconicState;
-  __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
-}
-
-void GLUTAPIENTRY 
-glutShowWindow(void)
-{
-  IGNORE_IN_GAME_MODE();
-  __glutCurrentWindow->desiredMapState = NormalState;
-  __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
-}
-
-void GLUTAPIENTRY 
-glutHideWindow(void)
-{
-  IGNORE_IN_GAME_MODE();
-  __glutCurrentWindow->desiredMapState = WithdrawnState;
-  __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
-}
-
-/* ENDCENTRY */
diff --git a/src/glut/glx/glutbitmap.h b/src/glut/glx/glutbitmap.h
deleted file mode 100644 (file)
index 9584bb1..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __glutbitmap_h__
-#define __glutbitmap_h__
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1998. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#define GLUT_NO_LIB_PRAGMA  /* Avoid auto library linking when building
-                               the GLUT library itself. */
-#include <GL/glut.h>
-
-typedef struct {
-  const GLsizei width;
-  const GLsizei height;
-  const GLfloat xorig;
-  const GLfloat yorig;
-  const GLfloat advance;
-  const GLubyte *bitmap;
-} BitmapCharRec, *BitmapCharPtr;
-
-typedef struct {
-  const char *name;
-  const int num_chars;
-  const int first;
-  const BitmapCharRec * const *ch;
-} BitmapFontRec, *BitmapFontPtr;
-
-typedef void *GLUTbitmapFont;
-
-#endif /* __glutbitmap_h__ */
diff --git a/src/glut/glx/glutint.h b/src/glut/glx/glutint.h
deleted file mode 100644 (file)
index ba30af6..0000000
+++ /dev/null
@@ -1,798 +0,0 @@
-#ifndef __glutint_h__
-#define __glutint_h__
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#if defined(__CYGWIN32__)
-#include <sys/time.h>
-#endif
-
-#define SUPPORT_FORTRAN  /* With GLUT 3.7, everyone supports Fortran. */
-
-#if defined(_WIN32)
-#include "glutwin32.h"
-#else
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#define GLX_GLXEXT_PROTOTYPES
-#include <GL/glx.h>
-#endif
-
-#ifndef GLUT_BUILDING_LIB
-#define GLUT_BUILDING_LIB  /* Building the GLUT library itself. */
-#endif
-
-#include <GL/glut.h>
-
-#ifndef _WIN32
-/* added by BrianP: */
-#ifndef APIENTRY
-#define APIENTRY GLAPIENTRY
-#endif
-#define __cdecl GLAPIENTRY
-#define CDECL GLAPIENTRY
-#endif
-
-/* GLUT_BUILDING_LIB is used by <GL/glut.h> to 1) not #pragma link
-   with the GLUT library, and 2) avoid the Win32 atexit hack. */
-
-#ifdef SUPPORT_FORTRAN
-#include <GL/glutf90.h>
-#endif
-
-#ifdef __vms
-#if ( __VMS_VER < 70000000 )
-#define OLD_VMS
-struct timeval6 {
-  __int64 val;
-};
-extern int sys$gettim(struct timeval6 *);
-#else
-#include <time.h>
-#endif
-#else
-#include <sys/types.h>
-#if !defined(_WIN32) || defined(__CYGWIN32__)
-#include <sys/time.h>
-#else
-#include <winsock.h>
-#endif
-#endif
-#if defined(__vms) && ( __VMS_VER < 70000000 )
-
-/* For VMS6.2 or lower :
-   One TICK on VMS is 100 nanoseconds; 0.1 microseconds or
-   0.0001 milliseconds. This means that there are 0.01
-   ticks/ns, 10 ticks/us, 10,000 ticks/ms and 10,000,000
-   ticks/second. */
-
-#define TICKS_PER_MILLISECOND 10000
-#define TICKS_PER_SECOND      10000000
-
-#define GETTIMEOFDAY(_x) (void) sys$gettim (_x);
-
-#define ADD_TIME(dest, src1, src2) { \
-  (dest).val = (src1).val + (src2).val; \
-}
-
-#define TIMEDELTA(dest, src1, src2) { \
-  (dest).val = (src1).val - (src2).val; \
-}
-
-#define IS_AFTER(t1, t2) ((t2).val > (t1).val)
-
-#define IS_AT_OR_AFTER(t1, t2) ((t2).val >= (t1).val)
-
-#else
-#if defined(SVR4) && !defined(sun)  /* Sun claims SVR4, but
-                                       wants 2 args. */
-#define GETTIMEOFDAY(_x) gettimeofday(_x)
-#else
-#define GETTIMEOFDAY(_x) gettimeofday(_x, NULL)
-#endif
-#define ADD_TIME(dest, src1, src2) { \
-  if(((dest).tv_usec = \
-    (src1).tv_usec + (src2).tv_usec) >= 1000000) { \
-    (dest).tv_usec -= 1000000; \
-    (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1; \
-  } else { \
-    (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \
-    if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
-      (dest).tv_sec --;(dest).tv_usec += 1000000; \
-    } \
-  } \
-}
-#define TIMEDELTA(dest, src1, src2) { \
-  if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \
-    (dest).tv_usec += 1000000; \
-    (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
-  } else { \
-     (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
-  } \
-}
-#define IS_AFTER(t1, t2) \
-  (((t2).tv_sec > (t1).tv_sec) || \
-  (((t2).tv_sec == (t1).tv_sec) && \
-  ((t2).tv_usec > (t1).tv_usec)))
-#define IS_AT_OR_AFTER(t1, t2) \
-  (((t2).tv_sec > (t1).tv_sec) || \
-  (((t2).tv_sec == (t1).tv_sec) && \
-  ((t2).tv_usec >= (t1).tv_usec)))
-#endif
-
-#define IGNORE_IN_GAME_MODE() \
-  { if (__glutGameModeWindow) return; }
-
-#define GLUT_WIND_IS_RGB(x)         (((x) & GLUT_INDEX) == 0)
-#define GLUT_WIND_IS_INDEX(x)       (((x) & GLUT_INDEX) != 0)
-#define GLUT_WIND_IS_SINGLE(x)      (((x) & GLUT_DOUBLE) == 0)
-#define GLUT_WIND_IS_DOUBLE(x)      (((x) & GLUT_DOUBLE) != 0)
-#define GLUT_WIND_HAS_ACCUM(x)      (((x) & GLUT_ACCUM) != 0)
-#define GLUT_WIND_HAS_ALPHA(x)      (((x) & GLUT_ALPHA) != 0)
-#define GLUT_WIND_HAS_DEPTH(x)      (((x) & GLUT_DEPTH) != 0)
-#define GLUT_WIND_HAS_STENCIL(x)    (((x) & GLUT_STENCIL) != 0)
-#define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0)
-#define GLUT_WIND_IS_STEREO(x)      (((x) & GLUT_STEREO) != 0)
-#define GLUT_WIND_IS_LUMINANCE(x)   (((x) & GLUT_LUMINANCE) != 0)
-#define GLUT_MAP_WORK               (1 << 0)
-#define GLUT_EVENT_MASK_WORK        (1 << 1)
-#define GLUT_REDISPLAY_WORK         (1 << 2)
-#define GLUT_CONFIGURE_WORK         (1 << 3)
-#define GLUT_COLORMAP_WORK          (1 << 4)
-#define GLUT_DEVICE_MASK_WORK      (1 << 5)
-#define GLUT_FINISH_WORK           (1 << 6)
-#define GLUT_DEBUG_WORK                    (1 << 7)
-#define GLUT_DUMMY_WORK                    (1 << 8)
-#define GLUT_FULL_SCREEN_WORK       (1 << 9)
-#define GLUT_OVERLAY_REDISPLAY_WORK (1 << 10)
-#define GLUT_REPAIR_WORK            (1 << 11)
-#define GLUT_OVERLAY_REPAIR_WORK    (1 << 12)
-
-/* Frame buffer capability macros and types. */
-#define RGBA                    0
-#define BUFFER_SIZE             1
-#define DOUBLEBUFFER            2
-#define STEREO                  3
-#define AUX_BUFFERS             4
-#define RED_SIZE                5  /* Used as mask bit for
-                                      "color selected". */
-#define GREEN_SIZE              6
-#define BLUE_SIZE               7
-#define ALPHA_SIZE              8
-#define DEPTH_SIZE              9
-#define STENCIL_SIZE            10
-#define ACCUM_RED_SIZE          11  /* Used as mask bit for
-                                       "acc selected". */
-#define ACCUM_GREEN_SIZE        12
-#define ACCUM_BLUE_SIZE         13
-#define ACCUM_ALPHA_SIZE        14
-#define LEVEL                   15
-
-#define NUM_GLXCAPS             (LEVEL + 1)
-
-#define XVISUAL                 (NUM_GLXCAPS + 0)
-#define TRANSPARENT             (NUM_GLXCAPS + 1)
-#define SAMPLES                 (NUM_GLXCAPS + 2)
-#define XSTATICGRAY             (NUM_GLXCAPS + 3)  /* Used as
-                                                      mask bit
-                                                      for "any
-                                                      visual type
-                                                      selected". */
-#define XGRAYSCALE              (NUM_GLXCAPS + 4)
-#define XSTATICCOLOR            (NUM_GLXCAPS + 5)
-#define XPSEUDOCOLOR            (NUM_GLXCAPS + 6)
-#define XTRUECOLOR              (NUM_GLXCAPS + 7)
-#define XDIRECTCOLOR            (NUM_GLXCAPS + 8)
-#define SLOW                    (NUM_GLXCAPS + 9)
-#define CONFORMANT              (NUM_GLXCAPS + 10)
-
-#define NUM_CAPS                (NUM_GLXCAPS + 11)
-
-/* Frame buffer capablities that don't have a corresponding
-   FrameBufferMode entry.  These get used as mask bits. */
-#define NUM                     (NUM_CAPS + 0)
-#define RGBA_MODE               (NUM_CAPS + 1)
-#define CI_MODE                 (NUM_CAPS + 2)
-#define LUMINANCE_MODE         (NUM_CAPS + 3)
-
-#define NONE                   0
-#define EQ                     1
-#define NEQ                    2
-#define LTE                    3
-#define GTE                    4
-#define GT                     5
-#define LT                     6
-#define MIN                    7
-
-typedef struct _Criterion {
-  int capability;
-  int comparison;
-  int value;
-} Criterion;
-
-typedef struct _FrameBufferMode {
-  XVisualInfo *vi;
-#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
-
-  /* fbc is non-NULL when the XVisualInfo* is not OpenGL-capable
-     (ie, GLX_USE_GL is false), but the SGIX_fbconfig extension shows
-     the visual's fbconfig is OpenGL-capable.  The reason for this is typically
-     an RGBA luminance fbconfig such as 16-bit StaticGray that could
-     not be advertised as a GLX visual since StaticGray visuals are
-     required (by the GLX specification) to be color index.  The
-     SGIX_fbconfig allows StaticGray visuals to instead advertised as
-     fbconfigs that can provide RGBA luminance support. */
-
-  GLXFBConfigSGIX fbc;
-#endif
-  int valid;
-  int cap[NUM_CAPS];
-} FrameBufferMode;
-
-/* DisplayMode capability macros for game mode. */
-#define DM_WIDTH        0  /* "width" */
-#define DM_HEIGHT       1  /* "height" */
-#define DM_PIXEL_DEPTH  2  /* "bpp" (bits per pixel) */
-#define DM_HERTZ        3  /* "hertz" */
-#define DM_NUM          4  /* "num" */
-
-#define NUM_DM_CAPS     (DM_NUM+1)
-
-typedef struct _DisplayMode {
-#ifdef _WIN32
-  DEVMODE devmode;
-#else
-  /* XXX The X Window System does not have a standard
-     mechanism for display setting changes.  On SGI
-     systems, GLUT could use the XSGIvc (SGI X video
-     control extension).  Perhaps this can be done in
-     a future release of GLUT. */
-#endif
-  int valid;
-  int cap[NUM_DM_CAPS];
-} DisplayMode;
-
-/* GLUT  function types */
-typedef void (GLUTCALLBACK *GLUTdisplayCB) (void);
-typedef void (GLUTCALLBACK *GLUTreshapeCB) (int, int);
-typedef void (GLUTCALLBACK *GLUTkeyboardCB) (unsigned char, int, int);
-typedef void (GLUTCALLBACK *GLUTmouseCB) (int, int, int, int);
-typedef void (GLUTCALLBACK *GLUTmotionCB) (int, int);
-typedef void (GLUTCALLBACK *GLUTpassiveCB) (int, int);
-typedef void (GLUTCALLBACK *GLUTentryCB) (int);
-typedef void (GLUTCALLBACK *GLUTvisibilityCB) (int);
-typedef void (GLUTCALLBACK *GLUTwindowStatusCB) (int);
-typedef void (GLUTCALLBACK *GLUTidleCB) (void);
-typedef void (GLUTCALLBACK *GLUTtimerCB) (int);
-typedef void (GLUTCALLBACK *GLUTmenuStateCB) (int);  /* DEPRICATED. */
-typedef void (GLUTCALLBACK *GLUTmenuStatusCB) (int, int, int);
-typedef void (GLUTCALLBACK *GLUTselectCB) (int);
-typedef void (GLUTCALLBACK *GLUTspecialCB) (int, int, int);
-typedef void (GLUTCALLBACK *GLUTspaceMotionCB) (int, int, int);
-typedef void (GLUTCALLBACK *GLUTspaceRotateCB) (int, int, int);
-typedef void (GLUTCALLBACK *GLUTspaceButtonCB) (int, int);
-typedef void (GLUTCALLBACK *GLUTdialsCB) (int, int);
-typedef void (GLUTCALLBACK *GLUTbuttonBoxCB) (int, int);
-typedef void (GLUTCALLBACK *GLUTtabletMotionCB) (int, int);
-typedef void (GLUTCALLBACK *GLUTtabletButtonCB) (int, int, int, int);
-typedef void (GLUTCALLBACK *GLUTjoystickCB) (unsigned int buttonMask, int x, int y, int z);
-
-typedef struct _GLUTcolorcell GLUTcolorcell;
-struct _GLUTcolorcell {
-  /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */
-  GLfloat component[3];
-};
-
-typedef struct _GLUTcolormap GLUTcolormap;
-struct _GLUTcolormap {
-  Visual *visual;       /* visual of the colormap */
-  Colormap cmap;        /* X colormap ID */
-  int refcnt;           /* number of windows using colormap */
-  int size;             /* number of cells in colormap */
-  int transparent;      /* transparent pixel, or -1 if opaque */
-  GLUTcolorcell *cells; /* array of cells */
-  GLUTcolormap *next;   /* next colormap in list */
-};
-
-typedef struct _GLUTwindow GLUTwindow;
-typedef struct _GLUToverlay GLUToverlay;
-struct _GLUTwindow {
-  int num;              /* Small integer window id (0-based). */
-
-  /* Window system related state. */
-#if defined(_WIN32)
-  int pf;               /* Pixel format. */
-  HDC hdc;              /* Window's Win32 device context. */
-#endif
-  Window win;           /* X window for GLUT window */
-  GLXContext ctx;       /* OpenGL context GLUT glut window */
-  XVisualInfo *vis;     /* visual for window */
-  Bool visAlloced;      /* if vis needs deallocate on destroy */
-  Colormap cmap;        /* RGB colormap for window; None if CI */
-  GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
-  GLUToverlay *overlay; /* overlay; NULL if no overlay */
-#if defined(_WIN32)
-  HDC renderDc;         /* Win32's device context for rendering. */
-#endif
-  Window renderWin;     /* X window for rendering (might be
-                           overlay) */
-  GLXContext renderCtx; /* OpenGL context for rendering (might
-                           be overlay) */
-  /* GLUT settable or visible window state. */
-  int width;            /* window width in pixels */
-  int height;           /* window height in pixels */
-  int cursor;           /* cursor name */
-  int visState;         /* visibility state (-1 is unknown) */
-  int shownState;       /* if window mapped */
-  int entryState;       /* entry state (-1 is unknown) */
-#define GLUT_MAX_MENUS              3
-
-  int menu[GLUT_MAX_MENUS];  /* attatched menu nums */
-  /* Window relationship state. */
-  GLUTwindow *parent;   /* parent window */
-  GLUTwindow *children; /* list of children */
-  GLUTwindow *siblings; /* list of siblings */
-  /* Misc. non-API visible (hidden) state. */
-  Bool treatAsSingle;   /* treat this window as single-buffered
-                           (it might be "fake" though) */
-  Bool forceReshape;    /* force reshape before display */
-#if !defined(_WIN32)
-  Bool isDirect;        /* if direct context (X11 only) */
-#endif
-  Bool usedSwapBuffers; /* if swap buffers used last display */
-  long eventMask;       /* mask of X events selected for */
-  int buttonUses;       /* number of button uses, ref cnt */
-  int tabletPos[2];     /* tablet position (-1 is invalid) */
-  /* Work list related state. */
-  unsigned int workMask;  /* mask of window work to be done */
-  GLUTwindow *prevWorkWin;  /* link list of windows to work on */
-  Bool desiredMapState; /* how to mapped window if on map work
-                           list */
-  Bool ignoreKeyRepeat;  /* if window ignores autorepeat */
-  int desiredConfMask;  /* mask of desired window configuration
-                         */
-  int desiredX;         /* desired X location */
-  int desiredY;         /* desired Y location */
-  int desiredWidth;     /* desired window width */
-  int desiredHeight;    /* desired window height */
-  int desiredStack;     /* desired window stack */
-  /* Per-window callbacks. */
-  GLUTdisplayCB display;  /* redraw */
-  GLUTreshapeCB reshape;  /* resize (width,height) */
-  GLUTmouseCB mouse;    /* mouse (button,state,x,y) */
-  GLUTmotionCB motion;  /* motion (x,y) */
-  GLUTpassiveCB passive;  /* passive motion (x,y) */
-  GLUTentryCB entry;    /* window entry/exit (state) */
-  GLUTkeyboardCB keyboard;  /* keyboard (ASCII,x,y) */
-  GLUTkeyboardCB keyboardUp;  /* keyboard up (ASCII,x,y) */
-  GLUTwindowStatusCB windowStatus;  /* window status */
-  GLUTvisibilityCB visibility;  /* visibility */
-  GLUTspecialCB special;  /* special key */
-  GLUTspecialCB specialUp;  /* special up key */
-  GLUTbuttonBoxCB buttonBox;  /* button box */
-  GLUTdialsCB dials;    /* dials */
-  GLUTspaceMotionCB spaceMotion;  /* Spaceball motion */
-  GLUTspaceRotateCB spaceRotate;  /* Spaceball rotate */
-  GLUTspaceButtonCB spaceButton;  /* Spaceball button */
-  GLUTtabletMotionCB tabletMotion;  /* tablet motion */
-  GLUTtabletButtonCB tabletButton;  /* tablet button */
-#ifdef _WIN32
-  GLUTjoystickCB joystick;  /* joystick */
-  int joyPollInterval; /* joystick polling interval */
-#endif
-#ifdef SUPPORT_FORTRAN
-  GLUTdisplayFCB fdisplay;  /* Fortran display  */
-  GLUTreshapeFCB freshape;  /* Fortran reshape  */
-  GLUTmouseFCB fmouse;  /* Fortran mouse  */
-  GLUTmotionFCB fmotion;  /* Fortran motion  */
-  GLUTpassiveFCB fpassive;  /* Fortran passive  */
-  GLUTentryFCB fentry;  /* Fortran entry  */
-  GLUTkeyboardFCB fkeyboard;  /* Fortran keyboard  */
-  GLUTkeyboardFCB fkeyboardUp;  /* Fortran keyboard up */
-  GLUTwindowStatusFCB fwindowStatus;  /* Fortran window status */
-  GLUTvisibilityFCB fvisibility;  /* Fortran visibility */
-  GLUTspecialFCB fspecial;  /* special key */
-  GLUTspecialFCB fspecialUp;  /* special key up */
-  GLUTbuttonBoxFCB fbuttonBox;  /* button box */
-  GLUTdialsFCB fdials;  /* dials */
-  GLUTspaceMotionFCB fspaceMotion;  /* Spaceball motion */
-  GLUTspaceRotateFCB fspaceRotate;  /* Spaceball rotate */
-  GLUTspaceButtonFCB fspaceButton;  /* Spaceball button */
-  GLUTtabletMotionFCB ftabletMotion;  /* tablet motion */
-  GLUTtabletButtonFCB ftabletButton;  /* tablet button */
-#ifdef _WIN32
-  GLUTjoystickFCB fjoystick;  /* joystick */
-#endif
-#endif
-};
-
-struct _GLUToverlay {
-#if defined(_WIN32)
-  int pf;
-  HDC hdc;
-#endif
-  Window win;
-  GLXContext ctx;
-  XVisualInfo *vis;     /* visual for window */
-  Bool visAlloced;      /* if vis needs deallocate on destroy */
-  Colormap cmap;        /* RGB colormap for window; None if CI */
-  GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
-  int shownState;       /* if overlay window mapped */
-  Bool treatAsSingle;   /* treat as single-buffered */
-#if !defined(_WIN32)
-  Bool isDirect;        /* if direct context */
-#endif
-  int transparentPixel; /* transparent pixel value */
-  GLUTdisplayCB display;  /* redraw  */
-#ifdef SUPPORT_FORTRAN
-  GLUTdisplayFCB fdisplay;  /* redraw  */
-#endif
-};
-
-typedef struct _GLUTstale GLUTstale;
-struct _GLUTstale {
-  GLUTwindow *window;
-  Window win;
-  GLUTstale *next;
-};
-
-extern GLUTstale *__glutStaleWindowList;
-
-#define GLUT_OVERLAY_EVENT_FILTER_MASK \
-  (ExposureMask | \
-  StructureNotifyMask | \
-  EnterWindowMask | \
-  LeaveWindowMask)
-#define GLUT_DONT_PROPAGATE_FILTER_MASK \
-  (ButtonReleaseMask | \
-  ButtonPressMask | \
-  KeyPressMask | \
-  KeyReleaseMask | \
-  PointerMotionMask | \
-  Button1MotionMask | \
-  Button2MotionMask | \
-  Button3MotionMask)
-#define GLUT_HACK_STOP_PROPAGATE_MASK \
-  (KeyPressMask | \
-  KeyReleaseMask)
-
-typedef struct _GLUTmenu GLUTmenu;
-typedef struct _GLUTmenuItem GLUTmenuItem;
-struct _GLUTmenu {
-  int id;               /* small integer menu id (0-based) */
-  Window win;           /* X window for the menu */
-  GLUTselectCB select;  /*  function of menu */
-  GLUTmenuItem *list;   /* list of menu entries */
-  int num;              /* number of entries */
-#if !defined(_WIN32)
-  Bool managed;         /* are the InputOnly windows size
-                           validated? */
-  Bool searched;       /* help detect menu loops */
-  int pixheight;        /* height of menu in pixels */
-  int pixwidth;         /* width of menu in pixels */
-#endif
-  int submenus;         /* number of submenu entries */
-  GLUTmenuItem *highlighted;  /* pointer to highlighted menu
-                                 entry, NULL not highlighted */
-  GLUTmenu *cascade;    /* currently cascading this menu  */
-  GLUTmenuItem *anchor; /* currently anchored to this entry */
-  int x;                /* current x origin relative to the
-                           root window */
-  int y;                /* current y origin relative to the
-                           root window */
-#ifdef SUPPORT_FORTRAN
-  GLUTselectFCB fselect;  /*  function of menu */
-#endif
-};
-
-struct _GLUTmenuItem {
-  Window win;           /* InputOnly X window for entry */
-  GLUTmenu *menu;       /* menu entry belongs to */
-  Bool isTrigger;       /* is a submenu trigger? */
-  int value;            /* value to return for selecting this
-                           entry; doubles as submenu id
-                           (0-base) if submenu trigger */
-#if defined(_WIN32)
-  UINT unique;          /* unique menu item id (Win32 only) */
-#endif
-  char *label;          /* __glutStrdup'ed label string */
-  int len;              /* length of label string */
-  int pixwidth;         /* width of X window in pixels */
-  GLUTmenuItem *next;   /* next menu entry on list for menu */
-};
-
-typedef struct _GLUTtimer GLUTtimer;
-struct _GLUTtimer {
-  GLUTtimer *next;      /* list of timers */
-#ifdef OLD_VMS
-   struct timeval6 timeout;  /* time to be called */
-#else
-   struct timeval timeout;  /* time to be called */
-#endif
-   GLUTtimerCB func;     /* timer  (value) */
-  int value;            /*  return value */
-#ifdef SUPPORT_FORTRAN
-  GLUTtimerFCB ffunc;   /* Fortran timer  */
-#endif
-};
-
-typedef struct _GLUTeventParser GLUTeventParser;
-struct _GLUTeventParser {
-  int (*func) (XEvent *);
-  GLUTeventParser *next;
-};
-
-/* Declarations to implement glutFullScreen support with
-   mwm/4Dwm. */
-
-/* The following X property format is defined in Motif 1.1's
-   Xm/MwmUtils.h, but GLUT should not depend on that header
-   file. Note: Motif 1.2 expanded this structure with
-   uninteresting fields (to GLUT) so just stick with the
-   smaller Motif 1.1 structure. */
-typedef struct {
-#define MWM_HINTS_DECORATIONS   2
-  long flags;
-  long functions;
-  long decorations;
-  long input_mode;
-} MotifWmHints;
-
-/* Make current and buffer swap macros. */
-#ifdef _WIN32
-#define MAKE_CURRENT_LAYER(window)                                    \
-  {                                                                   \
-    HGLRC currentContext = wglGetCurrentContext();                    \
-    HDC currentDc = wglGetCurrentDC();                                \
-                                                                      \
-    if (currentContext != window->renderCtx                           \
-      || currentDc != window->renderDc) {                             \
-      wglMakeCurrent(window->renderDc, window->renderCtx);            \
-    }                                                                 \
-  }
-#define MAKE_CURRENT_WINDOW(window)                                   \
-  {                                                                   \
-    HGLRC currentContext = wglGetCurrentContext();                    \
-    HDC currentDc = wglGetCurrentDC();                                \
-                                                                      \
-    if (currentContext != window->ctx || currentDc != window->hdc) {  \
-      wglMakeCurrent(window->hdc, window->ctx);                       \
-    }                                                                 \
-  }
-#define MAKE_CURRENT_OVERLAY(overlay) \
-  wglMakeCurrent(overlay->hdc, overlay->ctx)
-#define UNMAKE_CURRENT() \
-  wglMakeCurrent(NULL, NULL)
-#define SWAP_BUFFERS_WINDOW(window) \
-  SwapBuffers(window->hdc)
-#define SWAP_BUFFERS_LAYER(window) \
-  SwapBuffers(window->renderDc)
-#else
-#define MAKE_CURRENT_LAYER(window) \
-  glXMakeCurrent(__glutDisplay, window->renderWin, window->renderCtx)
-#define MAKE_CURRENT_WINDOW(window) \
-  glXMakeCurrent(__glutDisplay, window->win, window->ctx)
-#define MAKE_CURRENT_OVERLAY(overlay) \
-  glXMakeCurrent(__glutDisplay, overlay->win, overlay->ctx)
-#define UNMAKE_CURRENT() \
-  glXMakeCurrent(__glutDisplay, None, NULL)
-#define SWAP_BUFFERS_WINDOW(window) \
-  glXSwapBuffers(__glutDisplay, window->win)
-#define SWAP_BUFFERS_LAYER(window) \
-  glXSwapBuffers(__glutDisplay, window->renderWin)
-#endif
-
-/* private variables from glut_event.c */
-extern GLUTwindow *__glutWindowWorkList;
-extern int __glutWindowDamaged;
-#ifdef SUPPORT_FORTRAN
-extern GLUTtimer *__glutTimerList;
-extern GLUTtimer *__glutNewTimer;
-#endif
-extern GLUTmenu *__glutMappedMenu;
-
-extern void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *);
-#if !defined(_WIN32)
-extern void (*__glutMenuItemEnterOrLeave)(GLUTmenuItem * item,
-  int num, int type);
-extern void (*__glutFinishMenu)(Window win, int x, int y);
-extern void (*__glutPaintMenu)(GLUTmenu * menu);
-extern void (*__glutStartMenu)(GLUTmenu * menu,
-  GLUTwindow * window, int x, int y, int x_win, int y_win);
-extern GLUTmenu * (*__glutGetMenuByNum)(int menunum);
-extern GLUTmenuItem * (*__glutGetMenuItem)(GLUTmenu * menu,
-  Window win, int *which);
-extern GLUTmenu * (*__glutGetMenu)(Window win);
-#endif
-
-/* private variables from glut_init.c */
-extern Atom __glutWMDeleteWindow;
-extern Display *__glutDisplay;
-extern unsigned int __glutDisplayMode;
-extern char *__glutDisplayString;
-extern XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle,
-  Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc);
-extern GLboolean __glutDebug;
-extern GLboolean __glutForceDirect;
-extern GLboolean __glutIconic;
-extern GLboolean __glutTryDirect;
-extern Window __glutRoot;
-extern XSizeHints __glutSizeHints;
-extern char **__glutArgv;
-extern char *__glutProgramName;
-extern int __glutArgc;
-extern int __glutConnectionFD;
-extern int __glutInitHeight;
-extern int __glutInitWidth;
-extern int __glutInitX;
-extern int __glutInitY;
-extern int __glutScreen;
-extern int __glutScreenHeight;
-extern int __glutScreenWidth;
-extern Atom __glutMotifHints;
-extern unsigned int __glutModifierMask;
-#ifdef _WIN32
-extern void (__cdecl *__glutExitFunc)(int retval);
-#endif
-extern char *__glutPPMFile;
-
-/* private variables from glut_menu.c */
-extern GLUTmenuItem *__glutItemSelected;
-extern GLUTmenu **__glutMenuList;
-extern void (GLUTCALLBACK *__glutMenuStatusFunc) (int, int, int);
-extern void __glutMenuModificationError(void);
-extern void __glutSetMenuItem(GLUTmenuItem * item,
-  const char *label, int value, Bool isTrigger);
-
-/* private variables from glut_win.c */
-extern GLUTwindow **__glutWindowList;
-extern GLUTwindow *__glutCurrentWindow;
-extern GLUTwindow *__glutMenuWindow;
-extern GLUTmenu *__glutCurrentMenu;
-extern int __glutWindowListSize;
-extern void (*__glutFreeOverlayFunc) (GLUToverlay *);
-extern void __glutFreeOverlay(GLUToverlay * overlay);
-extern XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle,
-  Bool * visAlloced, void **fbc);
-
-/* private variables from glut_ppm.c */
-extern void __glutWritePPMFile(void);
-
-/* private variables from glut_mesa.c */
-extern int __glutMesaSwapHackSupport;
-
-/* private variables from glut_gamemode.c */
-extern GLUTwindow *__glutGameModeWindow;
-
-/* private routines from glut_cindex.c */
-extern GLUTcolormap * __glutAssociateNewColormap(XVisualInfo * vis);
-extern void __glutFreeColormap(GLUTcolormap *);
-
-/* private routines from glut_cmap.c */
-extern void __glutSetupColormap(
-  XVisualInfo * vi,
-  GLUTcolormap ** colormap,
-  Colormap * cmap);
-#if !defined(_WIN32)
-extern void __glutEstablishColormapsProperty(
-  GLUTwindow * window);
-extern GLUTwindow *__glutToplevelOf(GLUTwindow * window);
-#endif
-
-/* private routines from glut_cursor.c */
-extern void __glutSetCursor(GLUTwindow *window);
-
-/* private routines from glut_event.c */
-extern void __glutPutOnWorkList(GLUTwindow * window,
-  int work_mask);
-extern void __glutRegisterEventParser(GLUTeventParser * parser);
-extern void __glutPostRedisplay(GLUTwindow * window, int layerMask);
-extern void handleTimeouts(void);
-
-/* private routines from glut_init.c */
-#if !defined(_WIN32)
-extern void __glutOpenXConnection(char *display);
-#else
-extern void __glutOpenWin32Connection(char *display);
-#endif
-#ifdef OLD_VMS
-extern void __glutInitTime(struct timeval6 *beginning);
-#else
-extern void __glutInitTime(struct timeval *beginning);
-#endif
-
-/* private routines for glut_menu.c (or win32_menu.c) */
-#if defined(_WIN32)
-extern GLUTmenu *__glutGetMenu(Window win);
-extern GLUTmenu *__glutGetMenuByNum(int menunum);
-extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu,
-  Window win, int *which);
-extern void __glutStartMenu(GLUTmenu * menu,
-  GLUTwindow * window, int x, int y, int x_win, int y_win);
-extern void __glutFinishMenu(Window win, int x, int y);
-#endif
-extern void __glutSetMenu(GLUTmenu * menu);
-
-/* private routines from glut_util.c */
-extern char * __glutStrdup(const char *string);
-extern void __glutWarning(char *format,...);
-extern void __glutFatalError(char *format,...);
-extern void __glutFatalUsage(char *format,...);
-
-/* private routines from glut_win.c */
-extern GLUTwindow *__glutGetWindow(Window win);
-extern void __glutChangeWindowEventMask(long mask, Bool add);
-extern XVisualInfo *__glutDetermineVisual(
-  unsigned int mode,
-  Bool * fakeSingle,
-  XVisualInfo * (getVisualInfo) (unsigned int));
-extern XVisualInfo *__glutGetVisualInfo(unsigned int mode);
-extern void __glutSetWindow(GLUTwindow * window);
-extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc,
-  int callingConvention);
-extern void GLUTCALLBACK __glutDefaultReshape(int, int);
-extern GLUTwindow *__glutCreateWindow(
-  GLUTwindow * parent,
-  int x, int y, int width, int height, int gamemode);
-extern void __glutDestroyWindow(
-  GLUTwindow * window,
-  GLUTwindow * initialWindow);
-
-#if !defined(_WIN32)
-/* private routines from glut_glxext.c */
-extern int __glutIsSupportedByGLX(char *);
-extern int __glut_glXBindChannelToWindowSGIX(Display *dpy, int screen,
-                                             int channel, Window window);
-extern int __glut_glXChannelRectSGIX(Display *dpy, int screen, int channel,
-                                     int x, int y, int w, int h);
-extern int __glut_glXQueryChannelRectSGIX(Display *dpy, int screen,
-                                          int channel, int *x, int *y,
-                                          int *w, int *h);
-extern int __glut_glXQueryChannelDeltasSGIX(Display *dpy, int screen,
-                                            int channel, int *dx, int *dy,
-                                            int *dw, int *dh);
-extern int __glut_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel,
-                                         GLenum synctype);
-extern GLXContext __glut_glXCreateContextWithConfigSGIX(Display *dpy,
-                                                        GLXFBConfigSGIX config,
-                                                        int render_type,
-                                                        GLXContext share_list,
-                                                        Bool direct);
-extern int __glut_glXGetFBConfigAttribSGIX(Display *dpy,
-                                           GLXFBConfigSGIX config,
-                                           int attribute,
-                                           int *value);
-extern GLXFBConfigSGIX __glut_glXGetFBConfigFromVisualSGIX(Display *dpy,
-                                                           XVisualInfo *vis);
-#endif
-
-/* private routines from glut_input.c */
-extern void  __glutUpdateInputDeviceMask(GLUTwindow * window);
-
-/* private routines from glut_mesa.c */
-extern void __glutDetermineMesaSwapHackSupport(void);
-
-/* private routines from glut_gameglut.c */
-extern void __glutCloseDownGameMode(void);
-
-/* private variables from glut_swap.c (BrianP) */
-extern GLint __glutFPS;
-extern GLint __glutSwapCount;
-extern GLint __glutSwapTime;
-
-#if defined(_WIN32)
-/* private routines from win32_*.c */
-extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l);
-extern HDC XHDC;
-#endif
-
-
-#endif /* __glutint_h__ */
diff --git a/src/glut/glx/glutstroke.h b/src/glut/glx/glutstroke.h
deleted file mode 100644 (file)
index d6eac7a..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef __glutstroke_h__
-#define __glutstroke_h__
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#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. */
-#endif
-
-typedef struct {
-  float x;
-  float y;
-} CoordRec, *CoordPtr;
-
-typedef struct {
-  int num_coords;
-  const CoordRec *coord;
-} StrokeRec, *StrokePtr;
-
-typedef struct {
-  int num_strokes;
-  const StrokeRec *stroke;
-  float center;
-  float right;
-} StrokeCharRec, *StrokeCharPtr;
-
-typedef struct {
-  const char *name;
-  int num_chars;
-  const StrokeCharRec *ch;
-  float top;
-  float bottom;
-} StrokeFontRec, *StrokeFontPtr;
-
-typedef void *GLUTstrokeFont;
-
-#endif /* __glutstroke_h__ */
diff --git a/src/glut/glx/glutwin32.h b/src/glut/glx/glutwin32.h
deleted file mode 100644 (file)
index 01db99f..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-#ifndef __glutwin32_h__
-#define __glutwin32_h__
-
-/* Copyright (c) Nate Robins, 1997. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include "win32_x11.h"
-#include "win32_glx.h"
-
-/* We have to undef some things because Microsoft likes to pollute the
-   global namespace. */
-#undef TRANSPARENT
-
-/* Win32 "equivalent" cursors - eventually, the X glyphs should be
-   converted to Win32 cursors -- then they will look the same */
-#define XC_arrow               IDC_ARROW
-#define XC_top_left_arrow      IDC_ARROW
-#define XC_hand1               IDC_SIZEALL
-#define XC_pirate              IDC_NO
-#define XC_question_arrow      IDC_HELP
-#define XC_exchange            IDC_NO
-#define XC_spraycan            IDC_SIZEALL
-#define XC_watch               IDC_WAIT
-#define XC_xterm               IDC_IBEAM
-#define XC_crosshair           IDC_CROSS
-#define XC_sb_v_double_arrow   IDC_SIZENS
-#define XC_sb_h_double_arrow   IDC_SIZEWE
-#define XC_top_side            IDC_UPARROW
-#define XC_bottom_side         IDC_SIZENS
-#define XC_left_side           IDC_SIZEWE
-#define XC_right_side          IDC_SIZEWE
-#define XC_top_left_corner     IDC_SIZENWSE
-#define XC_top_right_corner    IDC_SIZENESW
-#define XC_bottom_right_corner IDC_SIZENWSE
-#define XC_bottom_left_corner  IDC_SIZENESW
-
-#define XA_STRING 0
-
-/* Private routines from win32_util.c */
-#ifndef __CYGWIN32__
-struct timeval;
-extern int gettimeofday(struct timeval* tp, void* tzp);
-#endif
-extern void *__glutFont(void *font);
-extern int __glutGetTransparentPixel(Display *dpy, XVisualInfo *vinfo);
-extern void __glutAdjustCoords(Window parent, int *x, int *y, int *width, int *height);
-
-
-/* Cygwin B20.1 misses the following definitions */
-#ifdef __CYGWIN32__
-
-/* from winuser.h */
-#define CDS_FULLSCREEN 4
-
-/* from mmsystem.h */
-#define WINMMAPI __declspec(dllimport)
-typedef UINT MMRESULT;
-
-#define MM_JOY1MOVE 0x3A0
-#define MM_JOY1ZMOVE 0x3A2
-#define MM_JOY1BUTTONDOWN 0x3B5
-#define MM_JOY1BUTTONUP 0x3B7
-
-#define JOYERR_NOERROR 0
-#define JOYERR_PARMS 165
-
-#define JOY_RETURNALL 0x000000ffl
-
-#define JOYSTICKID1 0
-
-typedef struct joyinfoex_tag {
-    DWORD dwSize;                /* size of structure */
-    DWORD dwFlags;               /* flags to indicate what to return */
-    DWORD dwXpos;                /* x position */
-    DWORD dwYpos;                /* y position */
-    DWORD dwZpos;                /* z position */
-    DWORD dwRpos;                /* rudder/4th axis position */
-    DWORD dwUpos;                /* 5th axis position */
-    DWORD dwVpos;                /* 6th axis position */
-    DWORD dwButtons;             /* button states */
-    DWORD dwButtonNumber;        /* current button number pressed */
-    DWORD dwPOV;                 /* point of view state */
-    DWORD dwReserved1;           /* reserved for communication between winmm & driver */
-    DWORD dwReserved2;           /* reserved for future expansion */
-} JOYINFOEX, *PJOYINFOEX, /* NEAR */ *NPJOYINFOEX, /* FAR */ *LPJOYINFOEX;
-
-WINMMAPI MMRESULT WINAPI joyGetPosEx( UINT uJoyID, LPJOYINFOEX pji);
-WINMMAPI MMRESULT WINAPI joyReleaseCapture( UINT uJoyID);
-WINMMAPI MMRESULT WINAPI joySetCapture( HWND hwnd, UINT uJoyID, UINT uPeriod, BOOL fChanged);
-WINMMAPI MMRESULT WINAPI joySetThreshold( UINT uJoyID, UINT uThreshold);
-
-#endif
-
-#endif /* __glutwin32_h__ */
diff --git a/src/glut/glx/layerutil.c b/src/glut/glx/layerutil.c
deleted file mode 100644 (file)
index 36d43e5..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1993, 1994. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-/* Based on XLayerUtil.c: Revision: 1.5 */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "layerutil.h"
-
-/* SGI optimization introduced in IRIX 6.3 to avoid X server
-   round trips for interning common X atoms. */
-#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
-#include <X11/SGIFastAtom.h>
-#else
-#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
-#endif
-
-static Bool layersRead = False;
-static OverlayInfo **overlayInfoPerScreen;
-static unsigned long *numOverlaysPerScreen;
-
-static void
-findServerOverlayVisualsInfo(Display * dpy)
-{
-  static Atom overlayVisualsAtom;
-  Atom actualType;
-  Status status;
-  unsigned long sizeData, bytesLeft;
-  Window root;
-  int actualFormat, numScreens, i;
-
-  if (layersRead == False) {
-    overlayVisualsAtom = XSGIFastInternAtom(dpy,
-      "SERVER_OVERLAY_VISUALS", SGI_XA_SERVER_OVERLAY_VISUALS, True);
-    if (overlayVisualsAtom != None) {
-      numScreens = ScreenCount(dpy);
-      overlayInfoPerScreen = (OverlayInfo **)
-        malloc(numScreens * sizeof(OverlayInfo *));
-      numOverlaysPerScreen = (unsigned long *)
-        malloc(numScreens * sizeof(unsigned long));
-      if (overlayInfoPerScreen != NULL &&
-        numOverlaysPerScreen != NULL) {
-        for (i = 0; i < numScreens; i++) {
-          root = RootWindow(dpy, i);
-          status = XGetWindowProperty(dpy, root,
-            overlayVisualsAtom, 0L, (long) 10000, False,
-            overlayVisualsAtom, &actualType, &actualFormat,
-            &sizeData, &bytesLeft,
-            (unsigned char **) &overlayInfoPerScreen[i]);
-          if (status != Success ||
-            actualType != overlayVisualsAtom ||
-            actualFormat != 32 || sizeData < 4)
-            numOverlaysPerScreen[i] = 0;
-          else
-            /* Four 32-bit quantities per
-               SERVER_OVERLAY_VISUALS entry. */
-            numOverlaysPerScreen[i] = sizeData / 4;
-        }
-        layersRead = True;
-      } else {
-        if (overlayInfoPerScreen != NULL)
-          free(overlayInfoPerScreen);
-        if (numOverlaysPerScreen != NULL)
-          free(numOverlaysPerScreen);
-      }
-    }
-  }
-}
-
-int
-__glutGetTransparentPixel(Display * dpy, XVisualInfo * vinfo)
-{
-  int i, screen = vinfo->screen;
-  OverlayInfo *overlayInfo;
-
-  findServerOverlayVisualsInfo(dpy);
-  if (layersRead) {
-    for (i = 0; i < numOverlaysPerScreen[screen]; i++) {
-      overlayInfo = &overlayInfoPerScreen[screen][i];
-      if (vinfo->visualid == overlayInfo->overlay_visual) {
-        if (overlayInfo->transparent_type == TransparentPixel) {
-          return (int) overlayInfo->value;
-        } else {
-          return -1;
-        }
-      }
-    }
-  }
-  return -1;
-}
-
-XLayerVisualInfo *
-__glutXGetLayerVisualInfo(Display * dpy, long lvinfo_mask,
-  XLayerVisualInfo * lvinfo_template, int *nitems_return)
-{
-  XVisualInfo *vinfo;
-  XLayerVisualInfo *layerInfo;
-  int numVisuals, count, i, j;
-
-  vinfo = XGetVisualInfo(dpy, lvinfo_mask & VisualAllMask,
-    &lvinfo_template->vinfo, nitems_return);
-  if (vinfo == NULL)
-    return NULL;
-  numVisuals = *nitems_return;
-  findServerOverlayVisualsInfo(dpy);
-  layerInfo = (XLayerVisualInfo *)
-    malloc(numVisuals * sizeof(XLayerVisualInfo));
-  if (layerInfo == NULL) {
-    XFree(vinfo);
-    return NULL;
-  }
-  count = 0;
-  for (i = 0; i < numVisuals; i++) {
-    XVisualInfo *pVinfo = &vinfo[i];
-    int screen = pVinfo->screen;
-    OverlayInfo *overlayInfo = NULL;
-
-    overlayInfo = NULL;
-    if (layersRead) {
-      for (j = 0; j < numOverlaysPerScreen[screen]; j++)
-        if (pVinfo->visualid ==
-          overlayInfoPerScreen[screen][j].overlay_visual) {
-          overlayInfo = &overlayInfoPerScreen[screen][j];
-          break;
-        }
-    }
-    if (lvinfo_mask & VisualLayerMask) {
-      if (overlayInfo == NULL) {
-        if (lvinfo_template->layer != 0)
-          continue;
-      } else if (lvinfo_template->layer != overlayInfo->layer)
-        continue;
-    }
-    if (lvinfo_mask & VisualTransparentType) {
-      if (overlayInfo == NULL) {
-        if (lvinfo_template->type != None)
-          continue;
-      } else if (lvinfo_template->type !=
-        overlayInfo->transparent_type)
-        continue;
-    }
-    if (lvinfo_mask & VisualTransparentValue) {
-      if (overlayInfo == NULL)
-        /* Non-overlay visuals have no sense of
-           TransparentValue. */
-        continue;
-      else if (lvinfo_template->value != overlayInfo->value)
-        continue;
-    }
-    layerInfo[count].vinfo = *pVinfo;
-    if (overlayInfo == NULL) {
-      layerInfo[count].layer = 0;
-      layerInfo[count].type = None;
-      layerInfo[count].value = 0;  /* meaningless */
-    } else {
-      layerInfo[count].layer = overlayInfo->layer;
-      layerInfo[count].type = overlayInfo->transparent_type;
-      layerInfo[count].value = overlayInfo->value;
-    }
-    count++;
-  }
-  XFree(vinfo);
-  *nitems_return = count;
-  if (count == 0) {
-    XFree(layerInfo);
-    return NULL;
-  } else
-    return layerInfo;
-}
-
-#if 0                   /* Unused by GLUT. */
-Status
-__glutXMatchLayerVisualInfo(Display * dpy, int screen,
-  int depth, int visualClass, int layer,
-  XLayerVisualInfo * lvinfo_return)
-{
-  XLayerVisualInfo *lvinfo;
-  XLayerVisualInfo lvinfoTemplate;
-  int nitems;
-
-  lvinfoTemplate.vinfo.screen = screen;
-  lvinfoTemplate.vinfo.depth = depth;
-#if defined(__cplusplus) || defined(c_plusplus)
-  lvinfoTemplate.vinfo.c_class = visualClass;
-#else
-  lvinfoTemplate.vinfo.class = visualClass;
-#endif
-  lvinfoTemplate.layer = layer;
-  lvinfo = __glutXGetLayerVisualInfo(dpy,
-    VisualScreenMask | VisualDepthMask |
-    VisualClassMask | VisualLayerMask,
-    &lvinfoTemplate, &nitems);
-  if (lvinfo != NULL && nitems > 0) {
-    *lvinfo_return = *lvinfo;
-    return 1;
-  } else
-    return 0;
-}
-#endif
diff --git a/src/glut/glx/layerutil.h b/src/glut/glx/layerutil.h
deleted file mode 100644 (file)
index 8f580af..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef __layerutil_h__
-#define __layerutil_h__
-
-/* Copyright (c) Mark J. Kilgard, 1993, 1994. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-/* Based on XLayerUtil.h: Revision: 1.3 */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#if !defined(_WIN32)
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xmd.h>
-#endif /* !_WIN32 */
-
-/* Transparent type values */
-/* None                       0 */
-#define TransparentPixel      1
-#define TransparentMask       2
-
-/* layered visual info template flags */
-#define VisualLayerMask                0x200
-#define VisualTransparentType  0x400
-#define VisualTransparentValue 0x800
-#define VisualAllLayerMask     0xFFF
-
-/* layered visual info structure */
-typedef struct _XLayerVisualInfo {
-  XVisualInfo vinfo;
-  long layer;
-  long type;
-  unsigned long value;
-} XLayerVisualInfo;
-
-/* SERVER_OVERLAY_VISUALS property element */
-typedef struct _OverlayInfo {
-  /* Avoid 64-bit portability problems by being careful to use
-     longs due to the way XGetWindowProperty is specified. Note
-     that these parameters are passed as CARD32s over X
-     protocol. */
-  long overlay_visual;
-  long transparent_type;
-  long value;
-  long layer;
-} OverlayInfo;
-
-extern int __glutGetTransparentPixel(Display *, XVisualInfo *);
-extern XLayerVisualInfo *__glutXGetLayerVisualInfo(Display *,
-  long, XLayerVisualInfo *, int *);
-extern Status __glutXMatchLayerVisualInfo(Display *,
-  int, int, int, int, XLayerVisualInfo *);
-
-#endif /* __layerutil_h__ */
diff --git a/src/glut/glx/stroke.h b/src/glut/glx/stroke.h
deleted file mode 100644 (file)
index 602b2fa..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-
-/*****************************************************************
-Copyright (c) 1989,1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the names of Sun Microsystems,
-the X Consortium, and MIT not be used in advertising or publicity 
-pertaining to distribution of the software without specific, written 
-prior permission.  
-
-SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
-SHALL SUN MICROSYSTEMS 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 WFONT_INCLUDED
-#define WFONT_INCLUDED
-
-#define WFONT_MAGIC    0x813
-#define WFONT_MAGIC_PLUS 0x715
-#define WFONT_MAGIC_PEX 0x70686e74
-#define START_PROPS 0x100
-#define START_DISPATCH(_num_props)  (START_PROPS + 160 * _num_props)
-#define START_PATH(_num_ch_, _num_props)  (START_DISPATCH(_num_props) + sizeof(Dispatch) * _num_ch_)
-#define NUM_DISPATCH   128
-
-typedef struct {
-  unsigned short x;
-  unsigned short y;
-} Path_point2dpx;
-
-typedef struct {
-  float x;
-  float y;
-} Path_point2df;
-
-typedef struct {
-  int x;
-  int y;
-  int z;
-} Path_point3di;
-
-typedef struct {
-  float x;
-  float y;
-  float z;
-} Path_point3df;
-
-typedef struct {
-  float x;
-  float y;
-  float z;
-  float w;
-} Path_point4df;
-
-typedef union {
-  Path_point2dpx *pt2dpx;
-  Path_point2df *pt2df;
-  Path_point3di *pt3di;
-  Path_point3df *pt3df;
-  Path_point4df *pt4df;
-} Path_pt_ptr;
-
-typedef enum {
-  PATH_2DF,
-  PATH_2DPX,
-  PATH_3DF,
-  PATH_3DI,
-  PATH_4DF
-} Path_type;
-
-typedef struct {
-  int n_pts;                    /* number of points in the subpath */
-  Path_pt_ptr pts;              /* pointer to them */
-  int closed;                   /* true if the subpath is closed */
-  int dcmp_flag;                /* flag for pgon dcmp, pgon type 
-                                 * and dcmped triangle type */
-} Path_subpath;
-
-typedef struct {
-  Path_type type;               /* type of vertices in this path */
-  int n_subpaths;               /* number of subpaths */
-  int n_vertices;               /* total number of vertices */
-  Path_subpath *subpaths;       /* array of subpaths */
-} Path;
-
-typedef Path *Path_handle;
-
-typedef struct {
-  char propname[80];            /* font property name */
-  char propvalue[80];           /* font property value */
-} Property;
-
-typedef struct {
-  int magic;                    /* magic number */
-  char name[80];                /* name of this font */
-  float top,                    /* extreme values */
-    bottom, max_width;
-  int num_ch;                   /* no. of fonts in the set */
-  int num_props;                /* no. of font properties */
-  Property *properties;         /* array of properties */
-} Font_header;
-
-typedef struct {
-  float center,                 /* center of the character */
-    right;                      /* right edge */
-  long offset;                  /* offset in the file of the character
-                                 * * description */
-} Dispatch;
-
-typedef struct {
-  float center, right;
-  Path strokes;
-} Ch_font;
-
-typedef struct {
-  char name[80];
-  float top, bottom, max_width;
-  int num_ch;                   /* # characters in the font */
-  Ch_font **ch_data;
-} Phg_font;
-
-#endif /*WFONT_INCLUDED */
diff --git a/src/glut/glx/win32_glx.c b/src/glut/glx/win32_glx.c
deleted file mode 100644 (file)
index 3522e60..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-
-/* Copyright (c) Nate Robins, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-#include <stdio.h>
-#include "glutint.h"
-#include "win32_glx.h"
-
-/* global current HDC */
-extern HDC XHDC;
-
-GLXContext
-glXCreateContext(Display * display, XVisualInfo * visinfo,
-  GLXContext share, Bool direct)
-{
-  /* KLUDGE: GLX really expects a display pointer to be passed
-     in as the first parameter, but Win32 needs an HDC instead,
-     so BE SURE that the global XHDC is set before calling this
-     routine. */
-  HGLRC context;
-
-  context = wglCreateContext(XHDC);
-
-#if 0
-  /* XXX GLUT doesn't support it now, so don't worry about display list
-     and texture object sharing. */
-  if (share) {
-    wglShareLists(share, context);
-  }
-#endif
-
-  /* Since direct rendering is implicit, the direct flag is
-     ignored. */
-
-  return context;
-}
-
-int
-glXGetConfig(Display * display, XVisualInfo * visual, int attrib, int *value)
-{
-  if (!visual)
-    return GLX_BAD_VISUAL;
-
-  switch (attrib) {
-  case GLX_USE_GL:
-    if (visual->dwFlags & (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW)) {
-      /* XXX Brad's Matrix Millenium II has problems creating
-         color index windows in 24-bit mode (lead to GDI crash)
-         and 32-bit mode (lead to black window).  The cColorBits
-         filed of the PIXELFORMATDESCRIPTOR returned claims to
-         have 24 and 32 bits respectively of color indices. 2^24
-         and 2^32 are ridiculously huge writable colormaps.
-         Assume that if we get back a color index
-         PIXELFORMATDESCRIPTOR with 24 or more bits, the
-         PIXELFORMATDESCRIPTOR doesn't really work and skip it.
-         -mjk */
-      if (visual->iPixelType == PFD_TYPE_COLORINDEX
-        && visual->cColorBits >= 24) {
-        *value = 0;
-      } else {
-       *value = 1;
-      }
-    } else {
-      *value = 0;
-    }
-    break;
-  case GLX_BUFFER_SIZE:
-    /* KLUDGE: if we're RGBA, return the number of bits/pixel,
-       otherwise, return 8 (we guessed at 256 colors in CI
-       mode). */
-    if (visual->iPixelType == PFD_TYPE_RGBA)
-      *value = visual->cColorBits;
-    else
-      *value = 8;
-    break;
-  case GLX_LEVEL:
-    /* The bReserved flag of the pfd contains the
-       overlay/underlay info. */
-    *value = visual->bReserved;
-    break;
-  case GLX_RGBA:
-    *value = visual->iPixelType == PFD_TYPE_RGBA;
-    break;
-  case GLX_DOUBLEBUFFER:
-    *value = visual->dwFlags & PFD_DOUBLEBUFFER;
-    break;
-  case GLX_STEREO:
-    *value = visual->dwFlags & PFD_STEREO;
-    break;
-  case GLX_AUX_BUFFERS:
-    *value = visual->cAuxBuffers;
-    break;
-  case GLX_RED_SIZE:
-    *value = visual->cRedBits;
-    break;
-  case GLX_GREEN_SIZE:
-    *value = visual->cGreenBits;
-    break;
-  case GLX_BLUE_SIZE:
-    *value = visual->cBlueBits;
-    break;
-  case GLX_ALPHA_SIZE:
-    *value = visual->cAlphaBits;
-    break;
-  case GLX_DEPTH_SIZE:
-    *value = visual->cDepthBits;
-    break;
-  case GLX_STENCIL_SIZE:
-    *value = visual->cStencilBits;
-    break;
-  case GLX_ACCUM_RED_SIZE:
-    *value = visual->cAccumRedBits;
-    break;
-  case GLX_ACCUM_GREEN_SIZE:
-    *value = visual->cAccumGreenBits;
-    break;
-  case GLX_ACCUM_BLUE_SIZE:
-    *value = visual->cAccumBlueBits;
-    break;
-  case GLX_ACCUM_ALPHA_SIZE:
-    *value = visual->cAccumAlphaBits;
-    break;
-  default:
-    return GLX_BAD_ATTRIB;
-  }
-  return 0;
-}
-
-XVisualInfo *
-glXChooseVisual(Display * display, int screen, int *attribList)
-{
-  /* KLUDGE: since we need the HDC, MAKE SURE to set XHDC
-     before calling this routine. */
-
-  int *p = attribList;
-  int pf;
-  PIXELFORMATDESCRIPTOR pfd;
-  PIXELFORMATDESCRIPTOR *match = NULL;
-  int stereo = 0;
-
-  /* Avoid seg-faults. */
-  if (!p)
-    return NULL;
-
-  memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
-  pfd.nSize = (sizeof(PIXELFORMATDESCRIPTOR));
-  pfd.nVersion = 1;
-
-  /* Defaults. */
-  pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
-  pfd.iPixelType = PFD_TYPE_COLORINDEX;
-  pfd.cColorBits = 32;
-  pfd.cDepthBits = 0;
-
-  while (*p) {
-    switch (*p) {
-    case GLX_USE_GL:
-      pfd.dwFlags |= PFD_SUPPORT_OPENGL;
-      break;
-    case GLX_BUFFER_SIZE:
-      pfd.cColorBits = *(++p);
-      break;
-    case GLX_LEVEL:
-      /* the bReserved flag of the pfd contains the
-         overlay/underlay info. */
-      pfd.bReserved = *(++p);
-      break;
-    case GLX_RGBA:
-      pfd.iPixelType = PFD_TYPE_RGBA;
-      break;
-    case GLX_DOUBLEBUFFER:
-      pfd.dwFlags |= PFD_DOUBLEBUFFER;
-      break;
-    case GLX_STEREO:
-      stereo = 1;
-      pfd.dwFlags |= PFD_STEREO;
-      break;
-    case GLX_AUX_BUFFERS:
-      pfd.cAuxBuffers = *(++p);
-      break;
-    case GLX_RED_SIZE:
-      pfd.cRedBits = 8; /* Try to get the maximum. */
-      ++p;
-      break;
-    case GLX_GREEN_SIZE:
-      pfd.cGreenBits = 8;
-      ++p;
-      break;
-    case GLX_BLUE_SIZE:
-      pfd.cBlueBits = 8;
-      ++p;
-      break;
-    case GLX_ALPHA_SIZE:
-      pfd.cAlphaBits = 8;
-      ++p;
-      break;
-    case GLX_DEPTH_SIZE:
-      pfd.cDepthBits = 32;
-      ++p;
-      break;
-    case GLX_STENCIL_SIZE:
-      pfd.cStencilBits = *(++p);
-      break;
-    case GLX_ACCUM_RED_SIZE:
-    case GLX_ACCUM_GREEN_SIZE:
-    case GLX_ACCUM_BLUE_SIZE:
-    case GLX_ACCUM_ALPHA_SIZE:
-      /* I believe that WGL only used the cAccumRedBits,
-        cAccumBlueBits, cAccumGreenBits, and cAccumAlphaBits fields
-        when returning info about the accumulation buffer precision.
-        Only cAccumBits is used for requesting an accumulation
-        buffer. */
-      pfd.cAccumBits = 1;
-      ++p;
-      break;
-    }
-    ++p;
-  }
-
-  /* Let Win32 choose one for us. */
-  pf = ChoosePixelFormat(XHDC, &pfd);
-  if (pf > 0) {
-    match = (PIXELFORMATDESCRIPTOR *) malloc(sizeof(PIXELFORMATDESCRIPTOR));
-    DescribePixelFormat(XHDC, pf, sizeof(PIXELFORMATDESCRIPTOR), match);
-
-    /* ChoosePixelFormat is dumb in that it will return a pixel
-       format that doesn't have stereo even if it was requested
-       so we need to make sure that if stereo was selected, we
-       got it. */
-    if (stereo) {
-      if (!(match->dwFlags & PFD_STEREO)) {
-        free(match);
-       return NULL;
-      }
-    }
-    /* XXX Brad's Matrix Millenium II has problems creating
-       color index windows in 24-bit mode (lead to GDI crash)
-       and 32-bit mode (lead to black window).  The cColorBits
-       filed of the PIXELFORMATDESCRIPTOR returned claims to
-       have 24 and 32 bits respectively of color indices. 2^24
-       and 2^32 are ridiculously huge writable colormaps.
-       Assume that if we get back a color index
-       PIXELFORMATDESCRIPTOR with 24 or more bits, the
-       PIXELFORMATDESCRIPTOR doesn't really work and skip it.
-       -mjk */
-    if (match->iPixelType == PFD_TYPE_COLORINDEX
-      && match->cColorBits >= 24) {
-      free(match);
-      return NULL;
-    }
-  }
-  return match;
-}
diff --git a/src/glut/glx/win32_glx.h b/src/glut/glx/win32_glx.h
deleted file mode 100644 (file)
index d3630e7..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef __win32_glx_h__
-#define __win32_glx_h__
-
-/* Copyright (c) Nate Robins, 1997. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include "win32_x11.h"
-
-/* Type definitions (conversions). */
-typedef HGLRC GLXContext;
-
-#define GLX_USE_GL              1       /* support GLX rendering */
-#define GLX_BUFFER_SIZE         2       /* depth of the color buffer */
-#define GLX_LEVEL               3       /* level in plane stacking */
-#define GLX_RGBA                4       /* true if RGBA mode */
-#define GLX_DOUBLEBUFFER        5       /* double buffering supported */
-#define GLX_STEREO              6       /* stereo buffering supported */
-#define GLX_AUX_BUFFERS         7       /* number of aux buffers */
-#define GLX_RED_SIZE            8       /* number of red component bits */
-#define GLX_GREEN_SIZE          9       /* number of green component bits */
-#define GLX_BLUE_SIZE           10      /* number of blue component bits */
-#define GLX_ALPHA_SIZE          11      /* number of alpha component bits */
-#define GLX_DEPTH_SIZE          12      /* number of depth bits */
-#define GLX_STENCIL_SIZE        13      /* number of stencil bits */
-#define GLX_ACCUM_RED_SIZE      14      /* number of red accum bits */
-#define GLX_ACCUM_GREEN_SIZE    15      /* number of green accum bits */
-#define GLX_ACCUM_BLUE_SIZE     16      /* number of blue accum bits */
-#define GLX_ACCUM_ALPHA_SIZE    17      /* number of alpha accum bits */
-
-#define GLX_BAD_ATTRIB  2
-#define GLX_BAD_VISUAL  4
-
-/* Functions emulated by macros. */
-
-#define glXDestroyContext(display, context) \
-  wglDeleteContext(context)
-
-/* Function prototypes. */
-
-extern GLXContext glXCreateContext(
-  Display* display,
-  XVisualInfo* visinfo,
-  GLXContext share,
-  Bool direct);
-extern int glXGetConfig(
-  Display* display,
-  XVisualInfo* visual,
-  int attrib,
-  int* value);
-extern XVisualInfo* glXChooseVisual(
-  Display* display,
-  int screen,
-  int* attribList);
-
-#endif /* __win32_glx_h__ */
diff --git a/src/glut/glx/win32_menu.c b/src/glut/glx/win32_menu.c
deleted file mode 100644 (file)
index 12feb41..0000000
+++ /dev/null
@@ -1,529 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
-/* Copyright (c) Nate Robins, 1997. */
-
-/* This program is freely distributable without licensing fees
-   and is provided without guarantee or warrantee expressed or
-   implied. This program is -not- in the public domain. */
-
-/* This file completely re-implements glut_menu.c and glut_menu2.c
-   for Win32.  Note that neither glut_menu.c nor glut_menu2.c are
-   compiled into Win32 GLUT. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <assert.h>
-
-#include "glutint.h"
-
-void (GLUTCALLBACK *__glutMenuStatusFunc) (int, int, int);
-GLUTmenuItem *__glutItemSelected;
-unsigned __glutMenuButton;
-
-static GLUTmenu **menuList = NULL;
-static int menuListSize = 0;
-static UINT uniqueMenuHandler = 1;
-
-/* DEPRICATED, use glutMenuStatusFunc instead. */
-void GLUTAPIENTRY
-glutMenuStateFunc(GLUTmenuStateCB menuStateFunc)
-{
-  __glutMenuStatusFunc = (GLUTmenuStatusCB) menuStateFunc;
-}
-
-void GLUTAPIENTRY
-glutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc)
-{
-  __glutMenuStatusFunc = menuStatusFunc;
-}
-
-void
-__glutSetMenu(GLUTmenu * menu)
-{
-  __glutCurrentMenu = menu;
-}
-
-static void
-unmapMenu(GLUTmenu * menu)
-{
-  if (menu->cascade) {
-    unmapMenu(menu->cascade);
-    menu->cascade = NULL;
-  }
-  menu->anchor = NULL;
-  menu->highlighted = NULL;
-}
-
-void
-__glutFinishMenu(Window win, int x, int y)
-{
-
-  unmapMenu(__glutMappedMenu);
-
-  /* XXX Put in a GdiFlush just in case.  Probably unnecessary. -mjk  */
-  GdiFlush();
-
-  if (__glutMenuStatusFunc) {
-    __glutSetWindow(__glutMenuWindow);
-    __glutSetMenu(__glutMappedMenu);
-
-    /* Setting __glutMappedMenu to NULL permits operations that
-       change menus or destroy the menu window again. */
-    __glutMappedMenu = NULL;
-
-    __glutMenuStatusFunc(GLUT_MENU_NOT_IN_USE, x, y);
-  }
-  /* Setting __glutMappedMenu to NULL permits operations that
-     change menus or destroy the menu window again. */
-  __glutMappedMenu = NULL;
-
-  /* If an item is selected and it is not a submenu trigger,
-     generate menu callback. */
-  if (__glutItemSelected && !__glutItemSelected->isTrigger) {
-    __glutSetWindow(__glutMenuWindow);
-    /* When menu callback is triggered, current menu should be
-       set to the callback menu. */
-    __glutSetMenu(__glutItemSelected->menu);
-    __glutItemSelected->menu->select(__glutItemSelected->value);
-  }
-  __glutMenuWindow = NULL;
-}
-
-static void
-mapMenu(GLUTmenu * menu, int x, int y)
-{
-  TrackPopupMenu((HMENU) menu->win, TPM_LEFTALIGN |
-    ((__glutMenuButton == TPM_RIGHTBUTTON) ? TPM_RIGHTBUTTON : TPM_LEFTBUTTON),
-    x, y, 0, __glutCurrentWindow->win, NULL);
-}
-
-void
-__glutStartMenu(GLUTmenu * menu, GLUTwindow * window,
-               int x, int y, int x_win, int y_win)
-{
-  assert(__glutMappedMenu == NULL);
-  __glutMappedMenu = menu;
-  __glutMenuWindow = window;
-  __glutItemSelected = NULL;
-  if (__glutMenuStatusFunc) {
-    __glutSetMenu(menu);
-    __glutSetWindow(window);
-    __glutMenuStatusFunc(GLUT_MENU_IN_USE, x_win, y_win);
-  }
-  mapMenu(menu, x, y);
-}
-
-GLUTmenuItem *
-__glutGetUniqueMenuItem(GLUTmenu * menu, UINT unique)
-{
-  GLUTmenuItem *item;
-  int i;
-
-  i = menu->num;
-  item = menu->list;
-  while (item) {
-    if (item->unique == unique) {
-      return item;
-    }
-    if (item->isTrigger) {
-      GLUTmenuItem *subitem;
-      subitem = __glutGetUniqueMenuItem(menuList[item->value], unique);
-      if (subitem) {
-        return subitem;
-      }
-    }
-    i--;
-    item = item->next;
-  }
-  return NULL;
-}
-
-GLUTmenuItem *
-__glutGetMenuItem(GLUTmenu * menu, Window win, int *which)
-{
-  GLUTmenuItem *item;
-  int i;
-
-  i = menu->num;
-  item = menu->list;
-  while (item) {
-    if (item->win == win) {
-      *which = i;
-      return item;
-    }
-    if (item->isTrigger) {
-      GLUTmenuItem *subitem;
-
-      subitem = __glutGetMenuItem(menuList[item->value],
-        win, which);
-      if (subitem) {
-        return subitem;
-      }
-    }
-    i--;
-    item = item->next;
-  }
-  return NULL;
-}
-
-GLUTmenu *
-__glutGetMenu(Window win)
-{
-  GLUTmenu *menu;
-
-  menu = __glutMappedMenu;
-  while (menu) {
-    if (win == menu->win) {
-      return menu;
-    }
-    menu = menu->cascade;
-  }
-  return NULL;
-}
-
-GLUTmenu *
-__glutGetMenuByNum(int menunum)
-{
-  if (menunum < 1 || menunum > menuListSize) {
-    return NULL;
-  }
-  return menuList[menunum - 1];
-}
-
-static int
-getUnusedMenuSlot(void)
-{
-  int i;
-
-  /* Look for allocated, unused slot. */
-  for (i = 0; i < menuListSize; i++) {
-    if (!menuList[i]) {
-      return i;
-    }
-  }
-  /* Allocate a new slot. */
-  menuListSize++;
-  if (menuList) {
-    menuList = (GLUTmenu **)
-      realloc(menuList, menuListSize * sizeof(GLUTmenu *));
-  } else {
-    /* XXX Some realloc's do not correctly perform a malloc
-       when asked to perform a realloc on a NULL pointer,
-       though the ANSI C library spec requires this. */
-    menuList = (GLUTmenu **) malloc(sizeof(GLUTmenu *));
-  }
-  if (!menuList) {
-    __glutFatalError("out of memory.");
-  }
-  menuList[menuListSize - 1] = NULL;
-  return menuListSize - 1;
-}
-
-static void
-menuModificationError(void)
-{
-  /* XXX Remove the warning after GLUT 3.0. */
-  __glutWarning("The following is a new check for GLUT 3.0; update your code.");
-  __glutFatalError("menu manipulation not allowed while menus in use.");
-}
-
-int GLUTAPIENTRY
-glutCreateMenu(GLUTselectCB selectFunc)
-{
-  GLUTmenu *menu;
-  int menuid;
-
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  menuid = getUnusedMenuSlot();
-  menu = (GLUTmenu *) malloc(sizeof(GLUTmenu));
-  if (!menu) {
-    __glutFatalError("out of memory.");
-  }
-  menu->id = menuid;
-  menu->num = 0;
-  menu->submenus = 0;
-  menu->select = selectFunc;
-  menu->list = NULL;
-  menu->cascade = NULL;
-  menu->highlighted = NULL;
-  menu->anchor = NULL;
-  menu->win = (HWND) CreatePopupMenu();
-  menuList[menuid] = menu;
-  __glutSetMenu(menu);
-  return menuid + 1;
-}
-
-int GLUTAPIENTRY
-__glutCreateMenuWithExit(GLUTselectCB selectFunc, void (__cdecl *exitfunc)(int))
-{
-  __glutExitFunc = exitfunc;
-  return glutCreateMenu(selectFunc);
-}
-
-void GLUTAPIENTRY
-glutDestroyMenu(int menunum)
-{
-  GLUTmenu *menu = __glutGetMenuByNum(menunum);
-  GLUTmenuItem *item, *next;
-
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  assert(menu->id == menunum - 1);
-  DestroyMenu( (HMENU) menu->win);
-  menuList[menunum - 1] = NULL;
-  /* free all menu entries */
-  item = menu->list;
-  while (item) {
-    assert(item->menu == menu);
-    next = item->next;
-    free(item->label);
-    free(item);
-    item = next;
-  }
-  if (__glutCurrentMenu == menu) {
-    __glutCurrentMenu = NULL;
-  }
-  free(menu);
-}
-
-int GLUTAPIENTRY
-glutGetMenu(void)
-{
-  if (__glutCurrentMenu) {
-    return __glutCurrentMenu->id + 1;
-  } else {
-    return 0;
-  }
-}
-
-void GLUTAPIENTRY
-glutSetMenu(int menuid)
-{
-  GLUTmenu *menu;
-
-  if (menuid < 1 || menuid > menuListSize) {
-    __glutWarning("glutSetMenu attempted on bogus menu.");
-    return;
-  }
-  menu = menuList[menuid - 1];
-  if (!menu) {
-    __glutWarning("glutSetMenu attempted on bogus menu.");
-    return;
-  }
-  __glutSetMenu(menu);
-}
-
-static void
-setMenuItem(GLUTmenuItem * item, const char *label,
-           int value, Bool isTrigger)
-{
-  GLUTmenu *menu;
-
-  menu = item->menu;
-  item->label = __glutStrdup(label);
-  if (!item->label) {
-    __glutFatalError("out of memory.");
-  }
-  item->isTrigger = isTrigger;
-  item->len = (int) strlen(label);
-  item->value = value;
-  item->unique = uniqueMenuHandler++;
-  if (isTrigger) {
-    AppendMenu((HMENU) menu->win, MF_POPUP, (UINT)item->win, label);
-  } else {
-    AppendMenu((HMENU) menu->win, MF_STRING, item->unique, label);
-  }
-}
-
-void GLUTAPIENTRY
-glutAddMenuEntry(const char *label, int value)
-{
-  GLUTmenuItem *entry;
-
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  entry = (GLUTmenuItem *) malloc(sizeof(GLUTmenuItem));
-  if (!entry) {
-    __glutFatalError("out of memory.");
-  }
-  entry->menu = __glutCurrentMenu;
-  setMenuItem(entry, label, value, FALSE);
-  __glutCurrentMenu->num++;
-  entry->next = __glutCurrentMenu->list;
-  __glutCurrentMenu->list = entry;
-}
-
-void GLUTAPIENTRY
-glutAddSubMenu(const char *label, int menu)
-{
-  GLUTmenuItem *submenu;
-  GLUTmenu     *popupmenu;
-
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  submenu = (GLUTmenuItem *) malloc(sizeof(GLUTmenuItem));
-  if (!submenu) {
-    __glutFatalError("out of memory.");
-  }
-  __glutCurrentMenu->submenus++;
-  submenu->menu = __glutCurrentMenu;
-  popupmenu = __glutGetMenuByNum(menu);
-  if (popupmenu) {
-    submenu->win = popupmenu->win;
-  }
-  setMenuItem(submenu, label, /* base 0 */ menu - 1, TRUE);
-  __glutCurrentMenu->num++;
-  submenu->next = __glutCurrentMenu->list;
-  __glutCurrentMenu->list = submenu;
-}
-
-void GLUTAPIENTRY
-glutChangeToMenuEntry(int num, const char *label, int value)
-{
-  GLUTmenuItem *item;
-  int i;
-
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  i = __glutCurrentMenu->num;
-  item = __glutCurrentMenu->list;
-  while (item) {
-    if (i == num) {
-      if (item->isTrigger) {
-        /* If changing a submenu trigger to a menu entry, we
-           need to account for submenus.  */
-        item->menu->submenus--;
-       /* Nuke the Win32 menu. */
-       DestroyMenu((HMENU) item->win);
-      }
-      free(item->label);
-
-      item->label = strdup(label);
-      if (!item->label)
-       __glutFatalError("out of memory");
-      item->isTrigger = FALSE;
-      item->len = (int) strlen(label);
-      item->value = value;
-      item->unique = uniqueMenuHandler++;
-      ModifyMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1,
-        MF_BYPOSITION | MFT_STRING, item->unique, label);
-
-      return;
-    }
-    i--;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-void GLUTAPIENTRY
-glutChangeToSubMenu(int num, const char *label, int menu)
-{
-  GLUTmenu *popupmenu;
-  GLUTmenuItem *item;
-  int i;
-
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  i = __glutCurrentMenu->num;
-  item = __glutCurrentMenu->list;
-  while (item) {
-    if (i == num) {
-      if (!item->isTrigger) {
-        /* If changing a menu entry to as submenu trigger, we
-           need to account for submenus.  */
-        item->menu->submenus++;
-       item->win = (HWND) CreatePopupMenu();
-      }
-      free(item->label);
-      
-      item->label = strdup(label);
-      if (!item->label)
-       __glutFatalError("out of memory");
-      item->isTrigger = TRUE;
-      item->len = (int) strlen(label);
-      item->value = menu - 1;
-      item->unique = uniqueMenuHandler++;
-      popupmenu = __glutGetMenuByNum(menu);
-      if (popupmenu)
-       item->win = popupmenu->win;
-      ModifyMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1,
-        MF_BYPOSITION | MF_POPUP, (UINT) item->win, label);
-      return;
-    }
-    i--;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-void GLUTAPIENTRY
-glutRemoveMenuItem(int num)
-{
-  GLUTmenuItem *item, **prev;
-  int i;
-
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  i = __glutCurrentMenu->num;
-  prev = &__glutCurrentMenu->list;
-  item = __glutCurrentMenu->list;
-  while (item) {
-    if (i == num) {
-      /* Found the menu item in list to remove. */
-      __glutCurrentMenu->num--;
-
-      /* Patch up menu's item list. */
-      *prev = item->next;
-
-      RemoveMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1, MF_BYPOSITION);
-
-      free(item->label);
-      free(item);
-      return;
-    }
-    i--;
-    prev = &item->next;
-    item = item->next;
-  }
-  __glutWarning("Current menu has no %d item.", num);
-}
-
-void GLUTAPIENTRY
-glutAttachMenu(int button)
-{
-  if (__glutCurrentWindow == __glutGameModeWindow) {
-    __glutWarning("cannot attach menus in game mode.");
-    return;
-  }
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  if (__glutCurrentWindow->menu[button] < 1) {
-    __glutCurrentWindow->buttonUses++;
-  }
-  __glutCurrentWindow->menu[button] = __glutCurrentMenu->id + 1;
-}
-
-void GLUTAPIENTRY
-glutDetachMenu(int button)
-{
-  if (__glutMappedMenu) {
-    menuModificationError();
-  }
-  if (__glutCurrentWindow->menu[button] > 0) {
-    __glutCurrentWindow->buttonUses--;
-    __glutCurrentWindow->menu[button] = 0;
-  }
-}
-
diff --git a/src/glut/glx/win32_util.c b/src/glut/glx/win32_util.c
deleted file mode 100644 (file)
index 25af48a..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-
-/* Copyright (c) Nate Robins, 1997. */
-
-/* portions Copyright (c) Mark Kilgard, 1997, 1998. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-
-#include "glutint.h"
-#include "glutstroke.h"
-#include "glutbitmap.h"
-#include <sys/timeb.h>
-
-/* The following added by Paul Garceau <pgarceau@teleport.com> */
-#if defined(__MINGW32__)
-#include <GL/gl.h>
-#include <time.h>
-#include <windows.h>
-struct timeval;
-#endif
-
-extern StrokeFontRec glutStrokeRoman, glutStrokeMonoRoman;
-extern BitmapFontRec glutBitmap8By13, glutBitmap9By15, glutBitmapTimesRoman10, glutBitmapTimesRoman24, glutBitmapHelvetica10, glutBitmapHelvetica12, glutBitmapHelvetica18;
-
-#ifndef __CYGWIN32__
-int
-gettimeofday(struct timeval* tp, void* tzp)
-{
-  struct timeb tb;
-
-  ftime(&tb);
-  tp->tv_sec = tb.time;
-  tp->tv_usec = tb.millitm * 1000;
-
-  /* 0 indicates that the call succeeded. */
-  return 0;
-}
-#endif
-
-/* To get around the fact that Microsoft DLLs only allow functions
-   to be exported and now data addresses (as Unix DSOs support), the
-   GLUT API constants such as GLUT_STROKE_ROMAN have to get passed
-   through a case statement to get mapped to the actual data structure
-   address. */
-void*
-__glutFont(void *font)
-{
-  switch((int)font) {
-  case (int)GLUT_STROKE_ROMAN:
-    return &glutStrokeRoman;
-  case (int)GLUT_STROKE_MONO_ROMAN:
-    return &glutStrokeMonoRoman;
-  case (int)GLUT_BITMAP_9_BY_15:
-    return &glutBitmap9By15;
-  case (int)GLUT_BITMAP_8_BY_13:
-    return &glutBitmap8By13;
-  case (int)GLUT_BITMAP_TIMES_ROMAN_10:
-    return &glutBitmapTimesRoman10;
-  case (int)GLUT_BITMAP_TIMES_ROMAN_24:
-    return &glutBitmapTimesRoman24;
-  case (int)GLUT_BITMAP_HELVETICA_10:
-    return &glutBitmapHelvetica10;
-  case (int)GLUT_BITMAP_HELVETICA_12:
-    return &glutBitmapHelvetica12;
-  case (int)GLUT_BITMAP_HELVETICA_18:
-    return &glutBitmapHelvetica18;
-  }
-  __glutFatalError("font not found.");
-  /* NOTREACHED */
-  return NULL; /* MSVC compiler complains if there is no return at all */
-}
-
-int
-__glutGetTransparentPixel(Display * dpy, XVisualInfo * vinfo)
-{
-  /* the transparent pixel on Win32 is always index number 0.  So if
-     we put this routine in this file, we can avoid compiling the
-     whole of layerutil.c which is where this routine normally comes
-     from. */
-  return 0;
-}
-
-void
-__glutAdjustCoords(Window parent, int* x, int* y, int* width, int* height)
-{
-  RECT rect;
-
-  /* adjust the window rectangle because Win32 thinks that the x, y,
-     width & height are the WHOLE window (including decorations),
-     whereas GLUT treats the x, y, width & height as only the CLIENT
-     area of the window. */
-  rect.left = *x; rect.top = *y;
-  rect.right = *x + *width; rect.bottom = *y + *height;
-
-  /* must adjust the coordinates according to the correct style
-     because depending on the style, there may or may not be
-     borders. */
-  AdjustWindowRect(&rect, WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
-                  (parent ? WS_CHILD : WS_OVERLAPPEDWINDOW),
-                  FALSE);
-  /* FALSE in the third parameter = window has no menu bar */
-
-  /* readjust if the x and y are offscreen */
-  if(rect.left < 0) {
-    *x = 0;
-  } else {
-    *x = rect.left;
-  }
-  
-  if(rect.top < 0) {
-    *y = 0;
-  } else {
-    *y = rect.top;
-  }
-
-  *width = rect.right - rect.left;     /* adjusted width */
-  *height = rect.bottom - rect.top;    /* adjusted height */
-}
-
diff --git a/src/glut/glx/win32_winproc.c b/src/glut/glx/win32_winproc.c
deleted file mode 100644 (file)
index 1b3a297..0000000
+++ /dev/null
@@ -1,792 +0,0 @@
-
-/* Copyright (c) Nate Robins, 1997. */
-/* portions Copyright (c) Mark Kilgard, 1997, 1998. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-
-#include "glutint.h"
-#include <sys/timeb.h>
-#ifdef __MINGW32__
-#include <ctype.h>
-#endif
-
-#if defined(_WIN32) && !defined(__CYGWIN32__)
-#include <mmsystem.h>  /* Win32 Multimedia API header. */
-#endif
-
-extern unsigned __glutMenuButton;
-extern GLUTidleCB __glutIdleFunc;
-extern GLUTtimer *__glutTimerList;
-extern GLUTmenuItem *__glutGetUniqueMenuItem(GLUTmenu * menu, UINT unique);
-static HMENU __glutHMenu;
-
-static void
-updateWindowState(GLUTwindow *window, int visState)
-{
-  GLUTwindow* child;
-
-  /* XXX shownState and visState are the same in Win32. */
-  window->shownState = visState;
-  if (visState != window->visState) {
-    if (window->windowStatus) {
-      window->visState = visState;
-      __glutSetWindow(window);
-      window->windowStatus(visState);
-    }
-  }
-  /* Since Win32 only sends an activate for the toplevel window,
-     update the visibility for all the child windows. */
-  child = window->children;
-  while (child) {
-    updateWindowState(child, visState);
-    child = child->siblings;
-  }
-}
-
-LONG WINAPI
-__glutWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{ 
-  POINT         point;                 /* Point structure. */
-  PAINTSTRUCT   ps;                    /* Paint structure. */
-  LPMINMAXINFO  minmax;                        /* Minimum/maximum info structure. */
-  GLUTwindow*   window;                        /* GLUT window associated with message. */
-  GLUTmenu*     menu;                  /* GLUT menu associated with message. */
-  int x, y, width, height, key;
-  int button = -1;
-
-  switch(msg) {
-  case WM_CREATE:
-    return 0;
-  case WM_CLOSE:
-    if (__glutExitFunc) {
-      __glutExitFunc(0);
-    }
-    exit(0);
-    break;
-#if 0
-  case WM_DESTROY:
-    /* XXX NVidia's NT OpenGL can have problems closing down
-       its OpenGL internal data structures if we just allow
-       the process to terminate without unbinding and deleting
-       the windows context.  Apparently, DirectDraw unloads
-       before OPENGL32.DLL in the close down sequence, but
-       NVidia's NT OpenGL needs DirectDraw to close down its
-       data structures. */
-    window = __glutGetWindow(hwnd);
-    if (window) {
-      if (window->ctx) {
-        wglMakeCurrent(NULL, NULL);
-        wglDeleteContext(window->ctx);
-      }
-    }
-    return 0;
-#endif
-  case WM_PAINT:
-    window = __glutGetWindow(hwnd);
-    if (window) {
-      BeginPaint(hwnd, &ps);           /* Must have this for some Win32 reason. */
-      EndPaint(hwnd, &ps);
-      if (window->win == hwnd) {
-       __glutPostRedisplay(window, GLUT_REPAIR_WORK);
-      } else if (window->overlay && window->overlay->win == hwnd) {
-       __glutPostRedisplay(window, GLUT_OVERLAY_REPAIR_WORK);
-      }
-    }
-    return 0;
-
-  case WM_SYSKEYUP:
-  case WM_KEYUP:
-    window = __glutGetWindow(hwnd);
-    if (!window) {
-      break;
-    }
-    /* Win32 is dumb and sends these messages only to the parent
-       window.  Therefore, find out if we're in a child window and
-       call the child windows keyboard callback if we are. */
-    if (window->parent) {
-      GetCursorPos(&point);
-      ScreenToClient(hwnd, &point);
-      hwnd = ChildWindowFromPoint(hwnd, point);
-      window = __glutGetWindow(hwnd);
-    }
-    if (window->specialUp || window->keyboardUp) {
-      GetCursorPos(&point);
-      ScreenToClient(window->win, &point);
-      __glutSetWindow(window);
-      __glutModifierMask = 0;
-      if (GetKeyState(VK_SHIFT) < 0)  /* < 0 = high order bit is on */
-       __glutModifierMask |= ShiftMask;
-      if (GetKeyState(VK_SHIFT) < 0)  /* < 0 = high order bit is on */
-       __glutModifierMask |= ControlMask;
-      if (GetKeyState(VK_MENU) < 0)
-       __glutModifierMask |= Mod1Mask;
-      switch (wParam) {
-      /* *INDENT-OFF* */
-      case VK_F1:     key = GLUT_KEY_F1; break;
-      case VK_F2:     key = GLUT_KEY_F2; break;
-      case VK_F3:     key = GLUT_KEY_F3; break;
-      case VK_F4:     key = GLUT_KEY_F4; break;
-      case VK_F5:     key = GLUT_KEY_F5; break;
-      case VK_F6:     key = GLUT_KEY_F6; break;
-      case VK_F7:     key = GLUT_KEY_F7; break;
-      case VK_F8:     key = GLUT_KEY_F8; break;
-      case VK_F9:     key = GLUT_KEY_F9; break;
-      case VK_F10:    key = GLUT_KEY_F10; break;
-      case VK_F11:    key = GLUT_KEY_F11; break;
-      case VK_F12:    key = GLUT_KEY_F12; break;
-      case VK_LEFT:   key = GLUT_KEY_LEFT; break;
-      case VK_UP:     key = GLUT_KEY_UP; break;
-      case VK_RIGHT:  key = GLUT_KEY_RIGHT; break;
-      case VK_DOWN:   key = GLUT_KEY_DOWN; break;
-      case VK_PRIOR:  key = GLUT_KEY_PAGE_UP; break;
-      case VK_NEXT:   key = GLUT_KEY_PAGE_DOWN; break;
-      case VK_HOME:   key = GLUT_KEY_HOME; break;
-      case VK_END:    key = GLUT_KEY_END; break;
-      case VK_INSERT: key = GLUT_KEY_INSERT; break;
-      case VK_DELETE:
-        /* Delete is an ASCII character. */
-       if (window->keyboardUp) {
-         window->keyboardUp((unsigned char) 127, point.x, point.y);
-       }
-       return 0;
-      /* *INDENT-ON* */
-      default:
-       if (window->keyboardUp) {
-         key = MapVirtualKey(wParam, 2);  /* Map to ASCII. */
-         if (isascii(key) && (key != 0)) {
-
-           /* XXX Attempt to determine modified ASCII character
-              is quite incomplete.  Digits, symbols, CapsLock,
-              Ctrl, and numeric keypad are all ignored.  Fix this. */
-
-           if (!(__glutModifierMask & ShiftMask))
-             key = tolower(key);
-           window->keyboardUp((unsigned char) key, point.x, point.y);
-          }
-        }
-       __glutModifierMask = (unsigned int) ~0;
-       return 0;
-      }
-      if (window->specialUp) {
-        window->specialUp(key, point.x, point.y);
-      }
-      __glutModifierMask = (unsigned int) ~0;
-    }
-    return 0;
-
-  case WM_SYSCHAR:
-  case WM_CHAR:
-    window = __glutGetWindow(hwnd);
-    if (!window) {
-      break;
-    }
-
-    /* Bit 30 of lParam is set if key already held down.  If
-       we are ignoring auto repeated key strokes for the window, bail. */
-    if (window->ignoreKeyRepeat && (lParam & (1 << 30)) ) {
-      break;
-    }
-
-    /* Win32 is dumb and sends these messages only to the parent
-       window.  Therefore, find out if we're in a child window and
-       call the child windows keyboard callback if we are. */
-    if (window->parent) {
-       GetCursorPos(&point);
-       ScreenToClient(hwnd, &point);
-       hwnd = ChildWindowFromPoint(hwnd, point);
-       window = __glutGetWindow(hwnd);
-    }
-    if (window->keyboard) {
-      GetCursorPos(&point);
-      ScreenToClient(window->win, &point);
-      __glutSetWindow(window);
-      __glutModifierMask = 0;
-      if (GetKeyState(VK_SHIFT) < 0)   /* < 0 = high order bit is on */
-       __glutModifierMask |= ShiftMask;
-      if (GetKeyState(VK_CONTROL) < 0)
-       __glutModifierMask |= ControlMask;
-      if (GetKeyState(VK_MENU) < 0)
-       __glutModifierMask |= Mod1Mask;
-      window->keyboard((unsigned char)wParam, point.x, point.y);
-      __glutModifierMask = (unsigned int) ~0;
-    }
-    return 0;
-
-  case WM_SYSKEYDOWN:
-  case WM_KEYDOWN:
-    window = __glutGetWindow(hwnd);
-    if (!window) {
-      break;
-    }
-
-    /* Bit 30 of lParam is set if key already held down.  If
-       we are ignoring auto repeated key strokes for the window, bail. */
-    if (window->ignoreKeyRepeat && (lParam & (1 << 30)) ) {
-      break;
-    }
-
-    /* Win32 is dumb and sends these messages only to the parent
-       window.  Therefore, find out if we're in a child window and
-       call the child windows keyboard callback if we are. */
-    if (window->parent) {
-       GetCursorPos(&point);
-       ScreenToClient(hwnd, &point);
-       hwnd = ChildWindowFromPoint(hwnd, point);
-       window = __glutGetWindow(hwnd);
-    }
-    if (window->special) {
-      switch (wParam) {
-       /* *INDENT-OFF* */
-       /* function keys */
-       case VK_F1:     key = GLUT_KEY_F1; break;
-       case VK_F2:     key = GLUT_KEY_F2; break;
-       case VK_F3:     key = GLUT_KEY_F3; break;
-       case VK_F4:     key = GLUT_KEY_F4; break;
-       case VK_F5:     key = GLUT_KEY_F5; break;
-       case VK_F6:     key = GLUT_KEY_F6; break;
-       case VK_F7:     key = GLUT_KEY_F7; break;
-       case VK_F8:     key = GLUT_KEY_F8; break;
-       case VK_F9:     key = GLUT_KEY_F9; break;
-       case VK_F10:    key = GLUT_KEY_F10; break;
-       case VK_F11:    key = GLUT_KEY_F11; break;
-       case VK_F12:    key = GLUT_KEY_F12; break;
-       /* directional keys */
-       case VK_LEFT:   key = GLUT_KEY_LEFT; break;
-       case VK_UP:     key = GLUT_KEY_UP; break;
-       case VK_RIGHT:  key = GLUT_KEY_RIGHT; break;
-       case VK_DOWN:   key = GLUT_KEY_DOWN; break;
-       /* *INDENT-ON* */
-
-       case VK_PRIOR:
-         /* VK_PRIOR is Win32's Page Up */
-         key = GLUT_KEY_PAGE_UP;
-         break;
-       case VK_NEXT:
-         /* VK_NEXT is Win32's Page Down */
-         key = GLUT_KEY_PAGE_DOWN;
-         break;
-       case VK_HOME:
-         key = GLUT_KEY_HOME;
-         break;
-       case VK_END:
-         key = GLUT_KEY_END;
-         break;
-       case VK_INSERT:
-         key = GLUT_KEY_INSERT;
-         break;
-        case VK_DELETE:
-         goto handleDelete;
-       default:
-         goto defproc;
-      }
-      GetCursorPos(&point);
-      ScreenToClient(window->win, &point);
-      __glutSetWindow(window);
-      __glutModifierMask = 0;
-      if (GetKeyState(VK_SHIFT) < 0)   /* < 0 = high order bit is on */
-       __glutModifierMask |= ShiftMask;
-      if (GetKeyState(VK_CONTROL) < 0)
-       __glutModifierMask |= ControlMask;
-      if (GetKeyState(VK_MENU) < 0)
-       __glutModifierMask |= Mod1Mask;
-      window->special(key, point.x, point.y);
-      __glutModifierMask = (unsigned int) ~0;
-    } else if (window->keyboard) {
-      /* Specially handle any keys that match ASCII values but
-         do not generate Windows WM_SYSCHAR or WM_CHAR messages. */
-      switch (wParam) {
-      case VK_DELETE:
-      handleDelete:
-        /* Delete is an ASCII character. */
-        GetCursorPos(&point);
-        ScreenToClient(window->win, &point);
-        __glutSetWindow(window);
-        __glutModifierMask = 0;
-        if (GetKeyState(VK_SHIFT) < 0) /* < 0 = high order bit is on */
-          __glutModifierMask |= ShiftMask;
-        if (GetKeyState(VK_CONTROL) < 0)
-          __glutModifierMask |= ControlMask;
-        if (GetKeyState(VK_MENU) < 0)
-          __glutModifierMask |= Mod1Mask;
-       window->keyboard((unsigned char) 127, point.x, point.y);
-        __glutModifierMask = (unsigned int) ~0;
-       return 0;
-      default:
-        /* Let the following WM_SYSCHAR or WM_CHAR message generate
-          the keyboard callback. */
-        break;
-      }
-    }
-    return 0;
-
-  case WM_LBUTTONDOWN:
-    button = GLUT_LEFT_BUTTON;
-  case WM_MBUTTONDOWN:
-    if (button < 0)
-      button = GLUT_MIDDLE_BUTTON;
-  case WM_RBUTTONDOWN:
-    if (button < 0)
-      button = GLUT_RIGHT_BUTTON;
-    
-    /* finish the menu if we get a button down message (user must have
-       cancelled the menu). */
-    if (__glutMappedMenu) {
-      /* TODO: take this out once the menu on middle mouse stuff works
-        properly. */
-      if (button == GLUT_MIDDLE_BUTTON)
-       return 0;
-      GetCursorPos(&point);
-      ScreenToClient(hwnd, &point);
-      __glutItemSelected = NULL;
-      __glutFinishMenu(hwnd, point.x, point.y);
-      return 0;
-    }
-
-    /* set the capture so we can get mouse events outside the window */
-    SetCapture(hwnd);
-
-    /* Win32 doesn't return the same numbers as X does when the mouse
-       goes beyond the upper or left side of the window.  roll the
-       Win32's 0..2^16 pointer co-ord range to 0 +/- 2^15. */
-    x = LOWORD(lParam);
-    y = HIWORD(lParam);
-    if(x & 1 << 15) x -= (1 << 16);
-    if(y & 1 << 15) y -= (1 << 16);
-       
-    window = __glutGetWindow(hwnd);
-    if (window) {
-      menu = __glutGetMenuByNum(window->menu[button]);
-      if (menu) {
-       point.x = LOWORD(lParam); point.y = HIWORD(lParam);
-       ClientToScreen(window->win, &point);
-       __glutMenuButton = button == GLUT_RIGHT_BUTTON ? TPM_RIGHTBUTTON :
-                           button == GLUT_LEFT_BUTTON  ? TPM_LEFTBUTTON :
-                           0x0001;
-       __glutStartMenu(menu, window, point.x, point.y, x, y);
-      } else if (window->mouse) {
-       
-        __glutSetWindow(window);
-       __glutModifierMask = 0;
-       if (GetKeyState(VK_SHIFT) < 0)  /* < 0 = high order bit is on. */
-         __glutModifierMask |= ShiftMask;
-       if (GetKeyState(VK_CONTROL) < 0)
-         __glutModifierMask |= ControlMask;
-       if (GetKeyState(VK_MENU) < 0)
-         __glutModifierMask |= Mod1Mask;
-       window->mouse(button, GLUT_DOWN, x, y);
-       __glutModifierMask = (unsigned int)~0;
-      } else {
-       /* Stray mouse events.  Ignore. */
-      }
-    }
-    return 0;
-
-  case WM_LBUTTONUP:
-    button = GLUT_LEFT_BUTTON;
-  case WM_MBUTTONUP:
-    if (button < 0)
-      button = GLUT_MIDDLE_BUTTON;
-  case WM_RBUTTONUP:
-    if (button < 0)
-      button = GLUT_RIGHT_BUTTON;
-
-    /* Bail out if we're processing a menu. */
-    if (__glutMappedMenu) {
-      GetCursorPos(&point);
-      ScreenToClient(hwnd, &point);
-      /* if we're getting the middle button up signal, then something
-        on the menu was selected. */
-      if (button == GLUT_MIDDLE_BUTTON) {
-       return 0;
-       /* For some reason, the code below always returns -1 even
-          though the point IS IN THE ITEM!  Therefore, just bail out if
-          we get a middle mouse up.  The user must select using the
-          left mouse button.  Stupid Win32. */
-#if 0
-       int item = MenuItemFromPoint(hwnd, __glutHMenu, point);
-       if (item != -1)
-         __glutItemSelected = (GLUTmenuItem*)GetMenuItemID(__glutHMenu, item);
-       else
-         __glutItemSelected = NULL;
-       __glutFinishMenu(hwnd, point.x, point.y);
-#endif
-      } else {
-       __glutItemSelected = NULL;
-       __glutFinishMenu(hwnd, point.x, point.y);
-      }
-      return 0;
-    }
-
-    /* Release the mouse capture. */
-    ReleaseCapture();
-
-    window = __glutGetWindow(hwnd);
-    if (window && window->mouse) {
-      /* Win32 doesn't return the same numbers as X does when the
-        mouse goes beyond the upper or left side of the window.  roll
-        the Win32's 0..2^16 pointer co-ord range to 0 +/- 2^15. */
-      x = LOWORD(lParam);
-      y = HIWORD(lParam);
-      if(x & 1 << 15) x -= (1 << 16);
-      if(y & 1 << 15) y -= (1 << 16);
-      
-      __glutSetWindow(window);
-      __glutModifierMask = 0;
-      if (GetKeyState(VK_SHIFT) < 0)   /* < 0 = high order bit is on */
-       __glutModifierMask |= ShiftMask;
-      if (GetKeyState(VK_CONTROL) < 0)
-       __glutModifierMask |= ControlMask;
-      if (GetKeyState(VK_MENU) < 0)
-       __glutModifierMask |= Mod1Mask;
-      window->mouse(button, GLUT_UP, x, y);
-      __glutModifierMask = (unsigned int)~0;
-    } else {
-      /* Window might have been destroyed and all the 
-        events for the window may not yet be received. */
-    }
-    return 0;
-
-  case WM_ENTERMENULOOP:
-    /* KLUDGE: create a timer that fires every 100 ms when we start a
-       menu so that we can still process the idle & timer events (that
-       way, the timers will fire during a menu pick and so will the
-       idle func. */
-    SetTimer(hwnd, 1, 1, NULL);
-    return 0;
-
-  case WM_TIMER:
-#if 0
-    /* If the timer id is 2, then this is the timer that is set up in
-       the main glut message processing loop, and we don't want to do
-       anything but acknowledge that we got it.  It is used to prevent
-       CPU spiking when an idle function is installed. */
-    if (wParam == 2)
-      return 0;
-#endif
-
-    /* only worry about the idle function and the timeouts, since
-       these are the only events we expect to process during
-       processing of a menu. */
-    /* we no longer process the idle functions (as outlined in the
-       README), since drawing can't be done until the menu has
-       finished...it's pretty lame when the animation goes on, but
-       doesn't update, so you get this weird jerkiness. */
-#if 0    
-     if (__glutIdleFunc)
-       __glutIdleFunc();
-#endif
-    if (__glutTimerList)
-      handleTimeouts();
-    return 0;
-
-  case WM_EXITMENULOOP:
-    /* nuke the above created timer...we don't need it anymore, since
-       the menu is gone now. */
-    KillTimer(hwnd, 1);
-    return 0;
-
-  case WM_MENUSELECT:
-    if (lParam != 0)
-      __glutHMenu = (HMENU)lParam;
-    return 0;
-
-  case WM_COMMAND:
-    if (__glutMappedMenu) {
-      if (GetSubMenu(__glutHMenu, LOWORD(wParam)))
-       __glutItemSelected = NULL;
-      else
-       __glutItemSelected = 
-         __glutGetUniqueMenuItem(__glutMappedMenu, LOWORD(wParam));
-      GetCursorPos(&point);
-      ScreenToClient(hwnd, &point);
-      __glutFinishMenu(hwnd, point.x, point.y);
-    } 
-    return 0;
-
-  case WM_MOUSEMOVE:
-    if (!__glutMappedMenu) {
-      window = __glutGetWindow(hwnd);
-      if (window) {
-          /* If motion function registered _and_ buttons held *
-             down, call motion function...  */
-       x = LOWORD(lParam);
-       y = HIWORD(lParam);
-
-       /* Win32 doesn't return the same numbers as X does when the
-          mouse goes beyond the upper or left side of the window.
-          roll the Win32's 0..2^16 pointer co-ord range to 0..+/-2^15. */
-       if(x & 1 << 15) x -= (1 << 16);
-       if(y & 1 << 15) y -= (1 << 16);
-
-       if (window->motion && wParam &
-            (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
-         __glutSetWindow(window);
-         window->motion(x, y);
-       }
-       /* If passive motion function registered _and_
-          buttons not held down, call passive motion
-          function...  */
-       else if (window->passive &&
-                ((wParam &
-                  (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) ==
-                 0)) {
-         __glutSetWindow(window);
-         window->passive(x, y);
-       }
-      }
-    } else {
-      /* Motion events are thrown away when a pop up menu is
-        active. */
-    }
-    return 0;
-
-  case WM_GETMINMAXINFO:
-    /* this voodoo is brought to you by Win32 (again).  It allows the
-       window to be bigger than the screen, and smaller than 100x100
-       (although it doesn't seem to help the y minimum). */
-    minmax = (LPMINMAXINFO)lParam;
-#if 0
-    /* These two lines are disabled to fix incorrect handling of
-     * window maximization on Vista.  See bug 23182.
-     */
-    minmax->ptMaxSize.x = __glutScreenWidth;
-    minmax->ptMaxSize.y = __glutScreenHeight;
-#endif
-    minmax->ptMinTrackSize.x = 0;
-    minmax->ptMinTrackSize.y = 0;
-    minmax->ptMaxTrackSize.x = __glutScreenWidth + 
-      GetSystemMetrics(SM_CXSIZE) * 2;
-    minmax->ptMaxTrackSize.y = __glutScreenHeight + 
-      GetSystemMetrics(SM_CXSIZE) * 2 + GetSystemMetrics(SM_CYCAPTION);
-    return 0;
-
-  case WM_SIZE:
-    window = __glutGetWindow(hwnd);
-    if (window) {
-      width = LOWORD(lParam);
-      height = HIWORD(lParam);
-      if (width != window->width || height != window->height) {
-#if 0  /* Win32 GLUT does not support overlays for now. */
-       if (window->overlay) {
-         XResizeWindow(__glutDisplay, window->overlay->win, width, height);
-       }
-#endif
-       window->width = width;
-       window->height = height;
-       __glutSetWindow(window);
-       /* Do not execute OpenGL out of sequence with respect
-          to the SetWindowPos request! */
-       GdiFlush();
-       window->reshape(width, height);
-       window->forceReshape = FALSE;
-       /* A reshape should be considered like posting a
-          repair request. */
-       __glutPostRedisplay(window, GLUT_REPAIR_WORK);
-      }
-    }
-    return 0;
-
-  case WM_SETCURSOR:
-    /* If the cursor is not in the client area, then we want to send
-       this message to the default window procedure ('cause its
-       probably in the border or title, and we don't handle that
-       cursor.  otherwise, set our cursor.  Win32 makes us set the
-       cursor every time the mouse moves (DUMB!). */
-    if(LOWORD(lParam) != HTCLIENT) {
-      goto defproc;
-    }
-    window = __glutGetWindow(hwnd);
-    if (window) {
-      __glutSetCursor(window);
-    }
-    /* TODO: check out the info in DevStudio on WM_SETCURSOR in the
-       DefaultAction section. */
-    return 1;
-
-  case WM_SETFOCUS:
-    window = __glutGetWindow(hwnd);
-    if (window) {
-      window->entryState = WM_SETFOCUS;
-      if (window->entry) {
-       __glutSetWindow(window);
-       window->entry(GLUT_ENTERED);
-       /* XXX Generation of fake passive notify?  See how much
-          work the X11 code does to support fake passive notify
-          callbacks. */
-      }
-      if (window->joystick && __glutCurrentWindow) {
-        if (__glutCurrentWindow->joyPollInterval > 0) {
-         MMRESULT result;
-
-         /* Because Win32 will only let one window capture the
-            joystick at a time, we must capture it when we get the
-            focus and release it when we lose the focus. */
-         result = joySetCapture(__glutCurrentWindow->win,
-           JOYSTICKID1, 0, TRUE);
-         if (result != JOYERR_NOERROR) {
-           return 0;
-          }
-         (void) joySetThreshold(JOYSTICKID1,
-            __glutCurrentWindow->joyPollInterval);
-        }
-      }
-    }
-    return 0;
-
-  case WM_KILLFOCUS:
-    window = __glutGetWindow(hwnd);
-    if (window) {
-      window->entryState = WM_KILLFOCUS;
-      if (window->entry) {
-       __glutSetWindow(window);
-       window->entry(GLUT_LEFT);
-      }
-      if (window->joystick && __glutCurrentWindow) {
-       if (__glutCurrentWindow->joyPollInterval > 0) {
-         /* Because Win32 will only let one window capture the
-            joystick at a time, we must capture it when we get the
-            focus and release it when we lose the focus. */
-           (void) joyReleaseCapture(JOYSTICKID1);
-        }
-      }
-    }
-    return 0;
-  case WM_ACTIVATE:
-    window = __glutGetWindow(hwnd);
-    /* Make sure we re-select the correct palette if needed. */
-    if (LOWORD(wParam)) {
-      PostMessage(hwnd, WM_PALETTECHANGED, 0, 0);
-    }
-    if (window) {
-      int visState;
-
-      /* HIWORD(wParam) is the minimized flag. */
-      visState = !HIWORD(wParam);
-      updateWindowState(window, visState);
-    }
-    return 0;
-
-  /* Colour Palette Management */
-  case WM_PALETTECHANGED:
-    if (hwnd == (HWND)wParam) {
-      /* Don't respond to the message that we sent! */
-      break;
-    }
-    /* fall through to WM_QUERYNEWPALETTE */
-
-  case WM_QUERYNEWPALETTE:
-    window = __glutGetWindow(hwnd);
-    if (window && window->colormap) {
-      UnrealizeObject(window->colormap->cmap);
-      SelectPalette(window->hdc, window->colormap->cmap, FALSE);
-      RealizePalette(window->hdc);
-      return TRUE;
-    }
-    return FALSE;
-
-  case MM_JOY1MOVE:
-  case MM_JOY1ZMOVE:
-    window = __glutGetWindow(hwnd);
-    if (window->joystick) {
-      JOYINFOEX jix;
-      int x, y, z;
-
-      /* Because WIN32 only supports messages for X, Y, and Z
-         translations, we must poll for the rest */
-      jix.dwSize = sizeof(jix);
-      jix.dwFlags = JOY_RETURNALL;
-      joyGetPosEx(JOYSTICKID1,&jix);
-
-#define SCALE(v)  ((int) ((v - 32767)/32.768))
-
-      /* Convert to integer for scaling. */
-      x = jix.dwXpos;
-      y = jix.dwYpos;
-      z = jix.dwZpos;
-      window->joystick(jix.dwButtons, SCALE(x), SCALE(y), SCALE(z));
-
-      return TRUE;
-    }
-    return FALSE;
-  case MM_JOY1BUTTONDOWN:
-  case MM_JOY1BUTTONUP:
-    window = __glutGetWindow(hwnd);
-    if (window->joystick) {
-      JOYINFOEX jix;
-
-      /* Because WIN32 only supports messages for X, Y, and Z
-         translations, we must poll for the rest */
-      jix.dwSize = sizeof(jix);
-      jix.dwFlags = JOY_RETURNALL;
-      joyGetPosEx(JOYSTICKID1,&jix);
-
-      return TRUE;
-    }
-    return FALSE;
-
-#if 0
-  /* Miscellaneous messages (don't really need to enumerate them,
-     but it's good to know what you're not getting sometimes). */
-  case WM_DISPLAYCHANGE:
-    break;
-  case WM_NCHITTEST:
-    /* This event is generated by every mouse move event. */
-    goto defproc;
-  case WM_NCMOUSEMOVE:
-    goto defproc;
-  case WM_NCACTIVATE:
-    goto defproc;
-  case WM_NCPAINT:
-    goto defproc;
-  case WM_NCCALCSIZE:
-    goto defproc;
-  case WM_NCCREATE:
-    goto defproc;
-  case WM_NCDESTROY:
-    goto defproc;
-  case WM_NCLBUTTONDOWN:
-    goto defproc;
-  case WM_SETTEXT:
-    goto defproc;
-  case WM_GETTEXT:
-    goto defproc;
-  case WM_ACTIVATEAPP:
-    goto defproc;
-  case WM_GETICON:
-    goto defproc;
-  case WM_ERASEBKGND:
-    goto defproc;
-  case WM_WINDOWPOSCHANGING:
-    goto defproc;
-  case WM_WINDOWPOSCHANGED:
-    goto defproc;
-  case WM_MOUSEACTIVATE:
-    goto defproc;
-  case WM_SHOWWINDOW:
-    goto defproc;
-  case WM_MOVING:
-    goto defproc;
-  case WM_MOVE:
-    goto defproc;
-  case WM_KEYUP:
-    goto defproc;
-  case WM_CAPTURECHANGED:
-    goto defproc;
-  case WM_SYSCOMMAND:
-    goto defproc;
-  case WM_ENTERSIZEMOVE:
-    goto defproc;
-  case WM_ENTERIDLE:
-    goto defproc;
-#endif
-
-  default: 
-    goto defproc;
-  }
-
-defproc:    
-  return DefWindowProc(hwnd, msg, wParam, lParam); 
-} 
diff --git a/src/glut/glx/win32_x11.c b/src/glut/glx/win32_x11.c
deleted file mode 100644 (file)
index d00ccdb..0000000
+++ /dev/null
@@ -1,399 +0,0 @@
-
-/* Copyright (c) Nate Robins, 1997. */
-/* portions Copyright (c) Mark Kilgard, 1998. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-
-#include "glutint.h"
-
-/* global variable that must be set for some functions to operate
-   correctly. */
-HDC XHDC;
-
-XVisualInfo*
-XGetVisualInfo(Display* display, long mask, XVisualInfo* template, int* nitems)
-{
-  /* KLUDGE: this function needs XHDC to be set to the HDC currently
-     being operated on before it is invoked! */
-
-  PIXELFORMATDESCRIPTOR* pfds;
-  int i, n;
-
-  n = DescribePixelFormat(XHDC, 0, 0, NULL);
-  pfds = (PIXELFORMATDESCRIPTOR*)malloc(sizeof(PIXELFORMATDESCRIPTOR) * n);
-  memset(pfds, 0, sizeof(PIXELFORMATDESCRIPTOR) * n);
-  
-  for (i = 0; i < n; i++) {
-    DescribePixelFormat(XHDC, i + 1, sizeof(PIXELFORMATDESCRIPTOR), &pfds[i]);
-  }
-
-  *nitems = n;
-  return pfds;
-}
-
-Colormap
-XCreateColormap(Display* display, Window root, Visual* visual, int alloc)
-{
-  /* KLUDGE: this function needs XHDC to be set to the HDC currently
-     being operated on before it is invoked! */
-
-  PIXELFORMATDESCRIPTOR pfd;
-  LOGPALETTE *logical;
-  HPALETTE    palette;
-  int n;
-
-  /* grab the pixel format */
-  memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
-  DescribePixelFormat(XHDC, GetPixelFormat(XHDC), 
-                     sizeof(PIXELFORMATDESCRIPTOR), &pfd);
-
-  if (!(pfd.dwFlags & PFD_NEED_PALETTE ||
-      pfd.iPixelType == PFD_TYPE_COLORINDEX))
-  {
-    return 0;
-  }
-
-  n = 1 << pfd.cColorBits;
-
-  /* allocate a bunch of memory for the logical palette (assume 256
-     colors in a Win32 palette */
-  logical = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) +
-                               sizeof(PALETTEENTRY) * n);
-  memset(logical, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n);
-
-  /* set the entries in the logical palette */
-  logical->palVersion = 0x300;
-  logical->palNumEntries = n;
-
-  /* start with a copy of the current system palette */
-  GetSystemPaletteEntries(XHDC, 0, 256, &logical->palPalEntry[0]);
-    
-  if (pfd.iPixelType == PFD_TYPE_RGBA) {
-    int redMask = (1 << pfd.cRedBits) - 1;
-    int greenMask = (1 << pfd.cGreenBits) - 1;
-    int blueMask = (1 << pfd.cBlueBits) - 1;
-    int i;
-
-    /* fill in an RGBA color palette */
-    for (i = 0; i < n; ++i) {
-      logical->palPalEntry[i].peRed = 
-       (((i >> pfd.cRedShift)   & redMask)   * 255) / redMask;
-      logical->palPalEntry[i].peGreen = 
-       (((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
-       logical->palPalEntry[i].peBlue = 
-       (((i >> pfd.cBlueShift)  & blueMask)  * 255) / blueMask;
-      logical->palPalEntry[i].peFlags = 0;
-    }
-  }
-
-  palette = CreatePalette(logical);
-  free(logical);
-
-  SelectPalette(XHDC, palette, FALSE);
-  RealizePalette(XHDC);
-
-  return palette;
-}
-
-void
-XAllocColorCells(Display* display, Colormap colormap, Bool contig, 
-                unsigned long plane_masks_return[], unsigned int nplanes,
-                unsigned long pixels_return[], unsigned int npixels)
-{
-  /* NOP -- we did all the allocating in XCreateColormap! */
-}
-
-void
-XStoreColor(Display* display, Colormap colormap, XColor* color)
-{
-  /* KLUDGE: set XHDC to 0 if the palette should NOT be realized after
-     setting the color.  set XHDC to the correct HDC if it should. */
-
-  PALETTEENTRY pe;
-
-  /* X11 stores color from 0-65535, Win32 expects them to be 0-256, so
-     twiddle the bits ( / 256). */
-  pe.peRed = color->red / 256;
-  pe.peGreen = color->green / 256;
-  pe.peBlue = color->blue / 256;
-
-  /* make sure we use this flag, otherwise the colors might get mapped
-     to another place in the colormap, and when we glIndex() that
-     color, it may have moved (argh!!) */
-  pe.peFlags = PC_NOCOLLAPSE;
-
-  /* the pixel field of the XColor structure is the index into the
-     colormap */
-  SetPaletteEntries(colormap, color->pixel, 1, &pe);
-
-  if (XHDC) {
-    UnrealizeObject(colormap);
-    SelectPalette(XHDC, colormap, FALSE);
-    RealizePalette(XHDC);
-  }
-}
-
-void
-XSetWindowColormap(Display* display, Window window, Colormap colormap)
-{
-  HDC hdc = GetDC(window);
-
-  /* if the third parameter is FALSE, the logical colormap is copied
-     into the device palette when the application is in the
-     foreground, if it is TRUE, the colors are mapped into the current
-     palette in the best possible way. */
-  SelectPalette(hdc, colormap, FALSE);
-  RealizePalette(hdc);
-
-  /* note that we don't have to release the DC, since our window class
-     uses the WC_OWNDC flag! */
-}
-
-Bool
-XTranslateCoordinates(Display *display, Window src, Window dst, 
-                     int src_x, int src_y, 
-                     int* dest_x_return, int* dest_y_return,
-                     Window* child_return)
-{
-  /* KLUDGE: this isn't really a translate coordinates into some other
-  windows coordinate system...it only translates coordinates into the
-  root window (screen) coordinate system. */
-
-  POINT point;
-
-  point.x = src_x;
-  point.y = src_y;
-
-  ClientToScreen(src, &point);
-
-  *dest_x_return = point.x;
-  *dest_y_return = point.y;
-
-  /* just to make compilers happy...we don't use the return value. */
-  return True;
-}
-
-Status
-XGetGeometry(Display* display, Window window, Window* root_return, 
-            int* x_return, int* y_return, 
-            unsigned int* width_return, unsigned int* height_return,
-            unsigned int *border_width_return, unsigned int* depth_return)
-{
-  /* KLUDGE: doesn't return the border_width or depth or root, x & y
-     are in screen coordinates. */
-
-  RECT rect;
-  POINT point;
-
-  GetClientRect(window, &rect);
-
-  point.x = 0;
-  point.y = 0;
-  ClientToScreen(window, &point);
-
-  *x_return = point.x;
-  *y_return = point.y;
-  *width_return = rect.right;
-  *height_return = rect.bottom;
-
-  /* just to make compilers happy...we don't use the return value. */
-  return 1;  
-}
-
-int
-DisplayWidthMM(Display* display, int screen)
-{
-  int width;
-  HWND hwnd = GetDesktopWindow();
-  HDC hdc = GetDC(hwnd);
-  
-  width = GetDeviceCaps(hdc, HORZSIZE);
-
-  /* make sure to release this DC (it's the desktops, not ours) */
-  ReleaseDC(hwnd, hdc);
-
-  return width;
-}
-
-int
-DisplayHeightMM(Display* display, int screen)
-{
-  int height;
-  HWND hwnd = GetDesktopWindow();
-  HDC hdc = GetDC(hwnd);
-  
-  height = GetDeviceCaps(hdc, VERTSIZE);
-
-  /* make sure to release this DC (it's the desktops, not ours) */
-  ReleaseDC(hwnd, hdc);
-
-  return height;
-}
-
-void
-XWarpPointer(Display* display, Window src, Window dst, 
-            int src_x, int src_y, int src_width, int src_height,
-            int dst_x, int dst_y)
-{
-  /* KLUDGE: this isn't really a warp pointer into some other windows
-  coordinate system...it only warps the pointer into the root window
-  (screen) coordinate system. */
-
-  POINT point;
-
-  point.x = dst_x;
-  point.y = dst_y;
-  ClientToScreen(dst, &point);
-
-  SetCursorPos(point.x, point.y);
-}
-
-int
-XPending(Display* display)
-{
-  /* similar functionality...I don't think that it is exact, but this
-     will have to do. */
-  MSG msg;
-
-  return PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
-}
-
-/* the following function was stolen from the X sources as indicated. */
-
-/* Copyright   Massachusetts Institute of Technology  1985, 1986, 1987 */
-
-/*
-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 M.I.T. not be used in advertising or
-publicity pertaining to distribution of the software without specific,
-written prior permission.  M.I.T. makes no representations about the
-suitability of this software for any purpose.  It is provided "as is"
-without express or implied warranty.
-*/
-
-/*
- *    XParseGeometry parses strings of the form
- *   "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
- *   width, height, xoffset, and yoffset are unsigned integers.
- *   Example:  "=80x24+300-49"
- *   The equal sign is optional.
- *   It returns a bitmask that indicates which of the four values
- *   were actually found in the string.  For each value found,
- *   the corresponding argument is updated;  for each value
- *   not found, the corresponding argument is left unchanged. 
- */
-
-static int
-ReadInteger(char *string, char **NextString)
-{
-    register int Result = 0;
-    int Sign = 1;
-    
-    if (*string == '+')
-       string++;
-    else if (*string == '-')
-    {
-       string++;
-       Sign = -1;
-    }
-    for (; (*string >= '0') && (*string <= '9'); string++)
-    {
-       Result = (Result * 10) + (*string - '0');
-    }
-    *NextString = string;
-    if (Sign >= 0)
-       return (Result);
-    else
-       return (-Result);
-}
-
-int XParseGeometry(char *string, int *x, int *y, unsigned int *width, unsigned int *height)
-{
-       int mask = NoValue;
-       register char *strind;
-       unsigned int tempWidth, tempHeight;
-       int tempX, tempY;
-       char *nextCharacter;
-
-       if ( (string == NULL) || (*string == '\0')) return(mask);
-       if (*string == '=')
-               string++;  /* ignore possible '=' at beg of geometry spec */
-
-       strind = (char *)string;
-       if (*strind != '+' && *strind != '-' && *strind != 'x') {
-               tempWidth = ReadInteger(strind, &nextCharacter);
-               if (strind == nextCharacter) 
-                   return (0);
-               strind = nextCharacter;
-               mask |= WidthValue;
-       }
-
-       if (*strind == 'x' || *strind == 'X') { 
-               strind++;
-               tempHeight = ReadInteger(strind, &nextCharacter);
-               if (strind == nextCharacter)
-                   return (0);
-               strind = nextCharacter;
-               mask |= HeightValue;
-       }
-
-       if ((*strind == '+') || (*strind == '-')) {
-               if (*strind == '-') {
-                       strind++;
-                       tempX = -ReadInteger(strind, &nextCharacter);
-                       if (strind == nextCharacter)
-                           return (0);
-                       strind = nextCharacter;
-                       mask |= XNegative;
-
-               }
-               else
-               {       strind++;
-                       tempX = ReadInteger(strind, &nextCharacter);
-                       if (strind == nextCharacter)
-                           return(0);
-                       strind = nextCharacter;
-               }
-               mask |= XValue;
-               if ((*strind == '+') || (*strind == '-')) {
-                       if (*strind == '-') {
-                               strind++;
-                               tempY = -ReadInteger(strind, &nextCharacter);
-                               if (strind == nextCharacter)
-                                   return(0);
-                               strind = nextCharacter;
-                               mask |= YNegative;
-
-                       }
-                       else
-                       {
-                               strind++;
-                               tempY = ReadInteger(strind, &nextCharacter);
-                               if (strind == nextCharacter)
-                                   return(0);
-                               strind = nextCharacter;
-                       }
-                       mask |= YValue;
-               }
-       }
-       
-       /* If strind isn't at the end of the string the it's an invalid
-               geometry specification. */
-
-       if (*strind != '\0') return (0);
-
-       if (mask & XValue)
-           *x = tempX;
-       if (mask & YValue)
-           *y = tempY;
-       if (mask & WidthValue)
-            *width = tempWidth;
-       if (mask & HeightValue)
-            *height = tempHeight;
-       return (mask);
-}
diff --git a/src/glut/glx/win32_x11.h b/src/glut/glx/win32_x11.h
deleted file mode 100644 (file)
index daf065e..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-#ifndef __win32_x11_h__
-#define __win32_x11_h__
-
-/* Copyright (c) Nate Robins, 1997. */
-
-/* This program is freely distributable without licensing fees 
-   and is provided without guarantee or warrantee expressed or 
-   implied. This program is -not- in the public domain. */
-#ifdef __MINGW32__
-#include <GL/gl.h>
-#endif
-#include <stdlib.h>
-#include <windows.h>
-
-/* These definitions are missing from windows.h */
-
-
-/* Type definitions (conversions) */
-typedef int Visual;                    /* Win32 equivalent of X11 type */
-typedef HWND Window;
-typedef HPALETTE Colormap;
-typedef PIXELFORMATDESCRIPTOR XVisualInfo;
-typedef BOOL Bool;
-typedef MSG XEvent;
-typedef HDC Display;
-typedef HCURSOR Cursor;
-
-typedef int Atom;                      /* dummies */
-typedef int XDevice;
-typedef int Status;
-
-#define True  TRUE                     /* Win32 equivalents of X11 booleans */
-#define False FALSE
-
-#define None                 0L        /* universal null resource or null atom */
-
-/* Input Event Masks. Used as event-mask window attribute and as arguments
-   to Grab requests.  Not to be confused with event names.  */
-
-#define NoEventMask                    0L
-#define KeyPressMask                   (1L<<0)  
-#define KeyReleaseMask                 (1L<<1)  
-#define ButtonPressMask                        (1L<<2)  
-#define ButtonReleaseMask              (1L<<3)  
-#define EnterWindowMask                        (1L<<4)  
-#define LeaveWindowMask                        (1L<<5)  
-#define PointerMotionMask              (1L<<6)  
-#define PointerMotionHintMask          (1L<<7)  
-#define Button1MotionMask              (1L<<8)  
-#define Button2MotionMask              (1L<<9)  
-#define Button3MotionMask              (1L<<10) 
-#define Button4MotionMask              (1L<<11) 
-#define Button5MotionMask              (1L<<12) 
-#define ButtonMotionMask               (1L<<13) 
-#define KeymapStateMask                        (1L<<14)
-#define ExposureMask                   (1L<<15) 
-#define VisibilityChangeMask           (1L<<16) 
-#define StructureNotifyMask            (1L<<17) 
-#define ResizeRedirectMask             (1L<<18) 
-#define SubstructureNotifyMask         (1L<<19) 
-#define SubstructureRedirectMask       (1L<<20) 
-#define FocusChangeMask                        (1L<<21) 
-#define PropertyChangeMask             (1L<<22) 
-#define ColormapChangeMask             (1L<<23) 
-#define OwnerGrabButtonMask            (1L<<24) 
-
-/* Key masks. Used as modifiers to GrabButton and GrabKey, results of
-   QueryPointer, state in various key-, mouse-, and button-related
-   events. */
-
-#define ShiftMask              (1<<0)
-#define LockMask               (1<<1)
-#define ControlMask            (1<<2)
-#define Mod1Mask               (1<<3)
-#define Mod2Mask               (1<<4)
-#define Mod3Mask               (1<<5)
-#define Mod4Mask               (1<<6)
-#define Mod5Mask               (1<<7)
-
-/* Window classes used by CreateWindow */
-/* Note that CopyFromParent is already defined as 0 above */
-
-#define InputOutput            1
-#define InputOnly              2
-
-/* Window attributes for CreateWindow and ChangeWindowAttributes */
-
-#define CWBackPixmap           (1L<<0)
-#define CWBackPixel            (1L<<1)
-#define CWBorderPixmap         (1L<<2)
-#define CWBorderPixel           (1L<<3)
-#define CWBitGravity           (1L<<4)
-#define CWWinGravity           (1L<<5)
-#define CWBackingStore          (1L<<6)
-#define CWBackingPlanes                (1L<<7)
-#define CWBackingPixel         (1L<<8)
-#define CWOverrideRedirect     (1L<<9)
-#define CWSaveUnder            (1L<<10)
-#define CWEventMask            (1L<<11)
-#define CWDontPropagate                (1L<<12)
-#define CWColormap             (1L<<13)
-#define CWCursor               (1L<<14)
-
-/* ConfigureWindow structure */
-
-#define CWX                    (1<<0)
-#define CWY                    (1<<1)
-#define CWWidth                        (1<<2)
-#define CWHeight               (1<<3)
-#define CWBorderWidth          (1<<4)
-#define CWSibling              (1<<5)
-#define CWStackMode            (1<<6)
-
-
-/* Used in GetWindowAttributes reply */
-
-#define IsUnmapped             0
-#define IsUnviewable           1
-#define IsViewable             2
-
-/* Window stacking method (in configureWindow) */
-
-#define Above                   0
-#define Below                   1
-#define TopIf                   2
-#define BottomIf                3
-#define Opposite                4
-
-/* For CreateColormap */
-
-#define AllocNone              0       /* create map with no entries */
-#define AllocAll               1       /* allocate entire map writeable */
-
-
-/* Flags used in StoreNamedColor, StoreColors */
-
-#define DoRed                  (1<<0)
-#define DoGreen                        (1<<1)
-#define DoBlue                 (1<<2)
-
-/* 
- * Bitmask returned by XParseGeometry().  Each bit tells if the corresponding
- * value (x, y, width, height) was found in the parsed string.
- */
-#define NoValue                0x0000
-#define XValue         0x0001
-#define YValue         0x0002
-#define WidthValue     0x0004
-#define HeightValue    0x0008
-#define AllValues      0x000F
-#define XNegative      0x0010
-#define YNegative      0x0020
-
-/* flags argument in size hints */
-#define USPosition     (1L << 0) /* user specified x, y */
-#define USSize         (1L << 1) /* user specified width, height */
-
-/* definitions for initial window state */
-#define WithdrawnState 0       /* for windows that are not mapped */
-#define NormalState 1  /* most applications want to start this way */
-#define IconicState 3  /* application wants to start as an icon */
-#define GameModeState 4  /* Win32 GLUT only (not in Xlib!). */
-
-/* Type definitions */
-
-typedef struct {
-    unsigned int background_pixmap;    /* background pixmap */
-    unsigned long background_pixel;    /* background pixel */
-    unsigned long border_pixel;        /* border pixel value */
-    long event_mask;           /* set of events that should be saved */
-    long do_not_propagate_mask;        /* set of events that should not propagate */
-    Bool override_redirect;       /* boolean value for override-redirect */
-    Colormap colormap;            /* color map to be associated with window */
-} XSetWindowAttributes;
-
-typedef struct {
-  unsigned long pixel;
-  unsigned short red, green, blue;
-  char flags;  /* do_red, do_green, do_blue */
-} XColor;
-
-typedef struct {
-  unsigned char *value;           /* same as Property routines */
-  Atom encoding;          /* prop type */
-  int format;             /* prop data format: 8, 16, or 32 */
-  unsigned long nitems;           /* number of data items in value */
-} XTextProperty;
-
-typedef struct {
-  long flags;          /* marks which fields in this structure are defined */
-  int x, y;            /* obsolete for new window mgrs, but clients */
-  int width, height;   /* should set so old wm's don't mess up */
-} XSizeHints;
-
-/* Functions emulated by macros. */
-
-#define XFreeColormap(display, colormap) \
-  DeleteObject(colormap)
-
-#define XCreateFontCursor(display, shape) \
-  LoadCursor(NULL, shape)
-
-#define XDefineCursor(display, window, cursor) \
-  SetCursor(cursor)
-
-#define XFlush(display) \
-  /* Nothing. */
-
-#define DisplayWidth(display, screen) \
-  GetSystemMetrics(SM_CXSCREEN)
-
-#define DisplayHeight(display, screen) \
-  GetSystemMetrics(SM_CYSCREEN)
-
-#define XMapWindow(display, window) \
-  ShowWindow(window, SW_SHOWNORMAL)
-
-#define XUnmapWindow(display, window) \
-  ShowWindow(window, SW_HIDE)
-
-#define XIconifyWindow(display, window, screen) \
-  ShowWindow(window, SW_MINIMIZE)
-
-#define XWithdrawWindow(display, window, screen) \
-  ShowWindow(window, SW_HIDE)
-
-#define XLowerWindow(display, window) \
-  SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
-
-#define XSetWMName(display, window, tp) \
-  SetWindowText(window, (const char *)(tp)->value)
-
-/* There really isn't a way to set the icon name separate from the
-   windows name in Win32, so, just set the windows name. */
-#define XSetWMIconName(display, window, tp) \
-  XSetWMName(display, window, tp)
-
-#define XDestroyWindow(display, window) \
-  DestroyWindow(window)
-
-/* Anything that needs to be freed was allocated with malloc in our
-   fake X windows library for Win32, so free it with plain old
-   free(). */
-#define XFree(data) \
-  free(data)
-
-/* Nothing to be done for this...the pointer is always 'ungrabbed'
-   in Win32. */
-#define XUngrabPointer(display, time) \
-  /* Nothing. */
-
-/* Function prototypes. */
-
-extern XVisualInfo* XGetVisualInfo(
-  Display* display,
-  long mask,
-  XVisualInfo* ttemplate,  /* Avoid class with C++ keyword. */
-  int*nitems);
-
-extern Colormap XCreateColormap(
-  Display* display,
-  Window root,
-  Visual* visual,
-  int alloc);
-
-extern void XAllocColorCells(
-  Display* display,
-  Colormap colormap,
-  Bool contig, 
-  unsigned long plane_masks_return[],
-  unsigned int nplanes,
-  unsigned long pixels_return[],
-  unsigned int npixels);
-
-extern void XStoreColor(
-  Display* display,
-  Colormap colormap,
-  XColor* color);
-
-extern void XSetWindowColormap(
-  Display* display,
-  Window window,
-  Colormap colormap);
-
-extern Bool XTranslateCoordinates(
-  Display *display,
-  Window src, Window dst, 
-  int src_x, int src_y, 
-  int* dest_x_return, int* dest_y_return,
-  Window* child_return);
-
-extern Status XGetGeometry(
-  Display* display,
-  Window window,
-  Window* root_return, 
-  int* x_return, int* y_return, 
-  unsigned int* width_return, unsigned int* height_return,
-  unsigned int *border_width_return,
-  unsigned int* depth_return);
-
-extern int DisplayWidthMM(
-  Display* display,
-  int screen);
-
-extern int DisplayHeightMM(
-  Display* display,
-  int screen);
-
-extern void XWarpPointer(
-  Display* display,
-  Window src, Window dst, 
-  int src_x, int src_y,
-  int src_width, int src_height, 
-  int dst_x, int dst_y);
-
-extern int XParseGeometry(
-  char* string,
-  int* x, int* y, 
-  unsigned int* width, unsigned int* height);
-
-extern int XPending(
-  Display* display);
-
-#endif /* __win32_x11_h__ */
index cd631b4..b9711c2 100644 (file)
 typedef struct _GLwMDrawingAreaClassRec        *GLwMDrawingAreaWidgetClass;
 typedef struct _GLwMDrawingAreaRec     *GLwMDrawingAreaWidget;
 
-extern WidgetClass glwMDrawingAreaWidgetClass;
+GLAPI WidgetClass glwMDrawingAreaWidgetClass;
 
 
 #else 
@@ -144,7 +144,7 @@ extern WidgetClass glwMDrawingAreaWidgetClass;
 typedef struct _GLwDrawingAreaClassRec *GLwDrawingAreaWidgetClass;
 typedef struct _GLwDrawingAreaRec      *GLwDrawingAreaWidget;
 
-extern WidgetClass glwDrawingAreaWidgetClass;
+GLAPI WidgetClass glwDrawingAreaWidgetClass;
 
 
 #endif
@@ -177,8 +177,8 @@ extern "C" {
 #endif
 
 /* front ends to glXMakeCurrent and glXSwapBuffers */
-extern void GLwDrawingAreaMakeCurrent(Widget w,GLXContext ctx);
-extern void GLwDrawingAreaSwapBuffers(Widget w);
+GLAPI void GLwDrawingAreaMakeCurrent(Widget w,GLXContext ctx);
+GLAPI void GLwDrawingAreaSwapBuffers(Widget w);
 
 #ifdef __GLX_MOTIF
 #ifdef _NO_PROTO
index f121701..4ff21b4 100644 (file)
@@ -59,7 +59,7 @@ typedef struct _GLwMDrawingAreaClassRec {
   } GLwMDrawingAreaClassRec;
 
 
-extern GLwMDrawingAreaClassRec glwMDrawingAreaClassRec;
+GLAPI GLwMDrawingAreaClassRec glwMDrawingAreaClassRec;
 
 
 /* XT */
@@ -70,7 +70,7 @@ typedef struct _GLwDrawingAreaClassRec {
   GLwDrawingAreaClassPart     glwDrawingArea_class;
   } GLwDrawingAreaClassRec;
 
-extern GLwDrawingAreaClassRec glwDrawingAreaClassRec;
+GLAPI GLwDrawingAreaClassRec glwDrawingAreaClassRec;
 
 
 #endif 
diff --git a/src/glx/SConscript b/src/glx/SConscript
new file mode 100644 (file)
index 0000000..afef337
--- /dev/null
@@ -0,0 +1,85 @@
+Import('*')
+
+if env['platform'] == 'windows':
+    Return()
+
+env = env.Clone()
+
+env.Prepend(CPPPATH = [
+       '#include',
+       '#include/GL/internal',
+       '#src/mesa',
+       '#src/mapi',
+       '#src/mapi/glapi',
+       #$(LIBDRM_CFLAGS)
+       #$(DRI2PROTO_CFLAGS)
+       #$(GLPROTO_CFLAGS)
+       #$(X11_INCLUDES)
+])
+
+env.Append(CPPDEFINES = [
+    '_REENTRANT',
+    #('DEFAULT_DRIVER_DIR', 'DRI_DRIVER_SEARCH_DIR')
+])
+
+env.Prepend(LIBS = [
+    glapi
+])
+
+env.PkgUseModules('X11')
+env.PkgUseModules('DRM')
+
+if env['HAVE_XF86VIDMODE']:
+    env.Append(CPPDEFINES = ['XF86VIDMODE'])
+    env.PkgUseModules('XF86VIDMODE')
+
+if False: # XXX: SHARED_GLAPI
+    env.Append(CPPDEFINES = ['GLX_SHARED_GLAPI'])
+
+sources = [
+    'clientattrib.c',
+    'compsize.c',
+    'eval.c',
+    'glxconfig.c',
+    'glxcmds.c',
+    'glxcurrent.c',
+    'glxext.c',
+    'glxextensions.c',
+    'indirect_glx.c',
+    'indirect.c',
+    'indirect_init.c',
+    'indirect_size.c',
+    'indirect_window_pos.c',
+    'indirect_texture_compression.c',
+    'indirect_transpose_matrix.c',
+    'indirect_vertex_array.c',
+    'indirect_vertex_program.c',
+    'pixel.c',
+    'pixelstore.c',
+    'render2.c',
+    'renderpix.c',
+    'single2.c',
+    'singlepix.c',
+    'vertarr.c',
+    'xfont.c',
+    'glx_pbuffer.c',
+    'glx_query.c',
+    'drisw_glx.c',
+    'dri_common.c',
+    'dri_glx.c',
+    'XF86dri.c',
+    'glxhash.c',
+    'dri2_glx.c',
+    'dri2.c',
+    'applegl_glx.c',
+]
+
+libgl = env.SharedLibrary(
+    target ='GL',
+    source = sources,
+)
+
+libgl = env.InstallSharedLibrary(libgl, version=(1, 2))
+
+env.Alias('glx', libgl)
+env.Alias('libgl', libgl)
index c27f7d1..6868d28 100644 (file)
@@ -46,6 +46,7 @@ SOURCES = \
        ../glxcurrent.c \
        ../glxext.c \
        ../glxextensions.c \
+       ../glxhash.c \
        glxreply.c \
        ../pixel.c \
        ../xfont.c \
index 0c89f46..34f726e 100644 (file)
 
 #include "apple_glx.h"
 #include "apple_xgl_api.h"
-
-#ifndef OPENGL_FRAMEWORK_PATH
-#define OPENGL_FRAMEWORK_PATH "/System/Library/Frameworks/OpenGL.framework/OpenGL"
-#endif
+#include "apple_cgl.h"
 
 struct _glapi_table * __ogl_framework_api = NULL;
 struct _glapi_table * __applegl_api = NULL;
 
 void apple_glapi_set_dispatch(void) {
-    static void *handle;
-    const char *opengl_framework_path;
-
     if(__applegl_api)  {
         _glapi_set_dispatch(__applegl_api);
         return;
     }
 
-    opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
-    if (!opengl_framework_path) {
-        opengl_framework_path = OPENGL_FRAMEWORK_PATH;
-    }
-
-    (void) dlerror();            /*drain dlerror */
-    handle = dlopen(opengl_framework_path, RTLD_LOCAL);
-
-    if (!handle) {
-        fprintf(stderr, "error: unable to dlopen %s : %s\n",
-                opengl_framework_path, dlerror());
-        abort();
-    }
-
-    __ogl_framework_api = _glapi_create_table_from_handle(handle, "gl");
+    __ogl_framework_api = _glapi_create_table_from_handle(apple_cgl_get_dl_handle(), "gl");
     assert(__ogl_framework_api);
 
     __applegl_api = malloc(sizeof(struct _glapi_table));
index 4bf4672..8766c88 100644 (file)
 #if defined(GLX_USE_APPLEGL)
 
 #include <stdbool.h>
+#include <dlfcn.h>
 
 #include "glxclient.h"
 #include "apple_glx_context.h"
 #include "apple_glx.h"
+#include "apple_cgl.h"
 #include "glx_error.h"
 
 static void
@@ -82,6 +84,12 @@ applegl_wait_x(struct glx_context *gc)
    apple_glx_waitx(dpy, gc->driContext);
 }
 
+static void *
+applegl_get_proc_address(const char *symbol)
+{
+   return dlsym(apple_cgl_get_dl_handle(), symbol);
+}
+
 static const struct glx_context_vtable applegl_context_vtable = {
    applegl_destroy_context,
    applegl_bind_context,
@@ -91,6 +99,7 @@ static const struct glx_context_vtable applegl_context_vtable = {
    DRI_glXUseXFont,
    NULL, /* bind_tex_image, */
    NULL, /* release_tex_image, */
+   applegl_get_proc_address,
 };
 
 struct glx_context *
index adfd3d1..229840d 100644 (file)
@@ -88,6 +88,7 @@ static Bool
 DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
 {
    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+   struct glx_drawable *glxDraw;
 
    XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
@@ -97,7 +98,10 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
    case DRI2_BufferSwapComplete:
    {
       GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
-      xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire;
+      xDRI2BufferSwapComplete2 *awire = (xDRI2BufferSwapComplete2 *)wire;
+      __GLXDRIdrawable *pdraw;
+
+      pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
 
       /* Ignore swap events if we're not looking for them */
       aevent->type = dri2GetSwapEventType(dpy, awire->drawable);
@@ -124,7 +128,13 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
       }
       aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
       aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
-      aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo;
+
+      glxDraw = GetGLXDrawable(dpy, pdraw->drawable);
+      if (awire->sbc < glxDraw->lastEventSbc)
+        glxDraw->eventSbcWrap += 0x100000000;
+      glxDraw->lastEventSbc = awire->sbc;
+      aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
+
       return True;
    }
 #endif
index 506754c..80e4da3 100644 (file)
@@ -143,6 +143,8 @@ dri2_bind_context(struct glx_context *context, struct glx_context *old,
    pdraw = (struct dri2_drawable *) driFetchDrawable(context, draw);
    pread = (struct dri2_drawable *) driFetchDrawable(context, read);
 
+   driReleaseDrawables(&pcp->base);
+
    if (pdraw == NULL || pread == NULL)
       return GLXBadDrawable;
 
@@ -170,9 +172,6 @@ dri2_unbind_context(struct glx_context *context, struct glx_context *new)
    struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
 
    (*psc->core->unbindContext) (pcp->driContext);
-
-   if (context == new)
-      driReleaseDrawables(&pcp->base);
 }
 
 static struct glx_context *
@@ -768,6 +767,7 @@ static const struct glx_context_vtable dri2_context_vtable = {
    DRI_glXUseXFont,
    dri2_bind_tex_image,
    dri2_release_tex_image,
+   NULL, /* get_proc_address */
 };
 
 static void
index 06a73e4..e7dba5a 100644 (file)
@@ -369,8 +369,10 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
    if (priv->drawHash == NULL)
       return NULL;
 
-   if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0)
+   if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) {
+      pdraw->refcount ++;
       return pdraw;
+   }
 
    pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
                                           glxDrawable, gc->config);
@@ -378,6 +380,7 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
       (*pdraw->destroyDrawable) (pdraw);
       return NULL;
    }
+   pdraw->refcount = 1;
 
    return pdraw;
 }
@@ -385,7 +388,7 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
 _X_HIDDEN void
 driReleaseDrawables(struct glx_context *gc)
 {
-   struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
+   const struct glx_display *priv = gc->psc->display;
    __GLXDRIdrawable *pdraw;
 
    if (priv == NULL)
@@ -394,19 +397,28 @@ driReleaseDrawables(struct glx_context *gc)
    if (__glxHashLookup(priv->drawHash,
                       gc->currentDrawable, (void *) &pdraw) == 0) {
       if (pdraw->drawable == pdraw->xDrawable) {
-        (*pdraw->destroyDrawable)(pdraw);
-        __glxHashDelete(priv->drawHash, gc->currentDrawable);
+        pdraw->refcount --;
+        if (pdraw->refcount == 0) {
+           (*pdraw->destroyDrawable)(pdraw);
+           __glxHashDelete(priv->drawHash, gc->currentDrawable);
+        }
       }
    }
 
-   if (gc->currentDrawable != gc->currentReadable &&
-       __glxHashLookup(priv->drawHash,
+   if (__glxHashLookup(priv->drawHash,
                       gc->currentReadable, (void *) &pdraw) == 0) {
       if (pdraw->drawable == pdraw->xDrawable) {
-        (*pdraw->destroyDrawable)(pdraw);
-        __glxHashDelete(priv->drawHash, gc->currentReadable);
+        pdraw->refcount --;
+        if (pdraw->refcount == 0) {
+           (*pdraw->destroyDrawable)(pdraw);
+           __glxHashDelete(priv->drawHash, gc->currentReadable);
+        }
       }
    }
+
+   gc->currentDrawable = None;
+   gc->currentReadable = None;
+
 }
 
 #endif /* GLX_DIRECT_RENDERING */
index ff027dc..6f3b2b8 100644 (file)
@@ -503,6 +503,8 @@ dri_destroy_context(struct glx_context * context)
    struct dri_context *pcp = (struct dri_context *) context;
    struct dri_screen *psc = (struct dri_screen *) context->psc;
 
+   driReleaseDrawables(&pcp->base);
+
    if (context->xid)
       glx_send_destroy_context(psc->base.dpy, context->xid);
 
@@ -526,6 +528,8 @@ dri_bind_context(struct glx_context *context, struct glx_context *old,
    pdraw = (struct dri_drawable *) driFetchDrawable(context, draw);
    pread = (struct dri_drawable *) driFetchDrawable(context, read);
 
+   driReleaseDrawables(&pcp->base);
+
    if (pdraw == NULL || pread == NULL)
       return GLXBadDrawable;
 
@@ -543,8 +547,6 @@ dri_unbind_context(struct glx_context *context, struct glx_context *new)
    struct dri_screen *psc = (struct dri_screen *) pcp->base.psc;
 
    (*psc->core->unbindContext) (pcp->driContext);
-
-   driReleaseDrawables(&pcp->base);
 }
 
 static const struct glx_context_vtable dri_context_vtable = {
@@ -556,6 +558,7 @@ static const struct glx_context_vtable dri_context_vtable = {
    DRI_glXUseXFont,
    NULL,
    NULL,
+   NULL, /* get_proc_address */
 };
 
 static struct glx_context *
index 2eaa3c5..7bd6450 100644 (file)
@@ -100,6 +100,13 @@ XCreateDrawable(struct drisw_drawable * pdp,
                               32,                     /* bitmap_pad */
                               0);                     /* bytes_per_line */
 
+  /**
+   * swrast does not handle 24-bit depth with 24 bpp, so let X do the
+   * the conversion for us.
+   */
+  if (pdp->ximage->bits_per_pixel == 24)
+     pdp->ximage->bits_per_pixel = 32;
+
    return True;
 }
 
@@ -242,6 +249,8 @@ drisw_destroy_context(struct glx_context *context)
    struct drisw_context *pcp = (struct drisw_context *) context;
    struct drisw_screen *psc = (struct drisw_screen *) context->psc;
 
+   driReleaseDrawables(&pcp->base);
+
    if (context->xid)
       glx_send_destroy_context(psc->base.dpy, context->xid);
 
@@ -264,6 +273,8 @@ drisw_bind_context(struct glx_context *context, struct glx_context *old,
    pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw);
    pread = (struct drisw_drawable *) driFetchDrawable(context, read);
 
+   driReleaseDrawables(&pcp->base);
+
    if (pdraw == NULL || pread == NULL)
       return GLXBadDrawable;
 
@@ -281,8 +292,6 @@ drisw_unbind_context(struct glx_context *context, struct glx_context *new)
    struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
 
    (*psc->core->unbindContext) (pcp->driContext);
-
-   driReleaseDrawables(&pcp->base);
 }
 
 static const struct glx_context_vtable drisw_context_vtable = {
@@ -294,6 +303,7 @@ static const struct glx_context_vtable drisw_context_vtable = {
    DRI_glXUseXFont,
    NULL,
    NULL,
+   NULL, /* get_proc_address */
 };
 
 static struct glx_context *
@@ -359,10 +369,6 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable,
 
    const __DRIswrastExtension *swrast = psc->swrast;
 
-   /* Old dri can't handle GLX 1.3+ drawable constructors. */
-   if (xDrawable != drawable)
-      return NULL;
-
    pdp = Xmalloc(sizeof(*pdp));
    if (!pdp)
       return NULL;
@@ -426,9 +432,6 @@ driOpenSwrast(void)
    if (driver == NULL)
       driver = driOpenDriver("swrast");
 
-   if (driver == NULL)
-      driver = driOpenDriver("swrastg");
-
    return driver;
 }
 
index 1f4c0f3..6738252 100644 (file)
@@ -187,7 +187,7 @@ determineTextureFormat(const int *attribs, int numAttribs)
    return 0;
 }
 
-static void
+static GLboolean
 CreateDRIDrawable(Display *dpy, struct glx_config *config,
                  XID drawable, XID glxdrawable,
                  const int *attrib_list, size_t num_attribs)
@@ -198,22 +198,24 @@ CreateDRIDrawable(Display *dpy, struct glx_config *config,
 
    psc = priv->screens[config->screen];
    if (psc->driScreen == NULL)
-      return;
+      return GL_TRUE;
 
    pdraw = psc->driScreen->createDrawable(psc, drawable,
                                          glxdrawable, config);
    if (pdraw == NULL) {
       fprintf(stderr, "failed to create drawable\n");
-      return;
+      return GL_FALSE;
    }
 
    if (__glxHashInsert(priv->drawHash, glxdrawable, pdraw)) {
       (*pdraw->destroyDrawable) (pdraw);
-      return; /* FIXME: Check what we're supposed to do here... */
+      return GL_FALSE;
    }
 
    pdraw->textureTarget = determineTextureTarget(attrib_list, num_attribs);
    pdraw->textureFormat = determineTextureFormat(attrib_list, num_attribs);
+
+   return GL_TRUE;
 }
 
 static void
@@ -234,11 +236,12 @@ DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable)
 
 #else
 
-static void
+static GLboolean
 CreateDRIDrawable(Display *dpy, const struct glx_config * fbconfig,
                  XID drawable, XID glxdrawable,
                  const int *attrib_list, size_t num_attribs)
 {
+    return GL_FALSE;
 }
 
 static void
@@ -364,6 +367,27 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
    return 0;
 }
 
+static void
+protocolDestroyDrawable(Display *dpy, GLXDrawable drawable, CARD32 glxCode)
+{
+   xGLXDestroyPbufferReq *req;
+   CARD8 opcode;
+
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return;
+
+   LockDisplay(dpy);
+
+   GetReq(GLXDestroyPbuffer, req);
+   req->reqType = opcode;
+   req->glxCode = glxCode;
+   req->pbuffer = (GLXPbuffer) drawable;
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+}
+
 /**
  * Create a non-pbuffer GLX drawable.
  */
@@ -372,6 +396,7 @@ CreateDrawable(Display *dpy, struct glx_config *config,
                Drawable drawable, const int *attrib_list, CARD8 glxCode)
 {
    xGLXCreateWindowReq *req;
+   struct glx_drawable *glxDraw;
    CARD32 *data;
    unsigned int i;
    CARD8 opcode;
@@ -387,6 +412,10 @@ CreateDrawable(Display *dpy, struct glx_config *config,
    if (!opcode)
       return None;
 
+   glxDraw = Xmalloc(sizeof(*glxDraw));
+   if (!glxDraw)
+      return None;
+
    LockDisplay(dpy);
    GetReqExtra(GLXCreateWindow, 8 * i, req);
    data = (CARD32 *) (req + 1);
@@ -405,7 +434,19 @@ CreateDrawable(Display *dpy, struct glx_config *config,
    UnlockDisplay(dpy);
    SyncHandle();
 
-   CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i);
+   if (InitGLXDrawable(dpy, glxDraw, drawable, xid)) {
+      free(glxDraw);
+      return None;
+   }
+
+   if (!CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i)) {
+      if (glxCode == X_GLXCreatePixmap)
+         glxCode = X_GLXDestroyPixmap;
+      else
+         glxCode = X_GLXDestroyWindow;
+      protocolDestroyDrawable(dpy, xid, glxCode);
+      xid = None;
+   }
 
    return xid;
 }
@@ -417,28 +458,13 @@ CreateDrawable(Display *dpy, struct glx_config *config,
 static void
 DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode)
 {
-   xGLXDestroyPbufferReq *req;
-   CARD8 opcode;
-
    if ((dpy == NULL) || (drawable == 0)) {
       return;
    }
 
+   protocolDestroyDrawable(dpy, drawable, glxCode);
 
-   opcode = __glXSetupForCommand(dpy);
-   if (!opcode)
-      return;
-
-   LockDisplay(dpy);
-
-   GetReq(GLXDestroyPbuffer, req);
-   req->reqType = opcode;
-   req->glxCode = glxCode;
-   req->pbuffer = (GLXPbuffer) drawable;
-
-   UnlockDisplay(dpy);
-   SyncHandle();
-
+   DestroyGLXDrawable(dpy, drawable);
    DestroyDRIDrawable(dpy, drawable, GL_FALSE);
 
    return;
@@ -466,6 +492,7 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
    CARD8 opcode;
    unsigned int i;
    Pixmap pixmap;
+   GLboolean glx_1_3 = GL_FALSE;
 
    i = 0;
    if (attrib_list) {
@@ -484,6 +511,8 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
       xGLXCreatePbufferReq *req;
       unsigned int extra = (size_in_attribs) ? 0 : 2;
 
+      glx_1_3 = GL_TRUE;
+
       GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req);
       data = (CARD32 *) (req + 1);
 
@@ -528,7 +557,12 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
    pixmap = XCreatePixmap(dpy, RootWindow(dpy, config->screen),
                          width, height, config->rgbBits);
 
-   CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i);
+   if (!CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i)) {
+      CARD32 o = glx_1_3 ? X_GLXDestroyPbuffer : X_GLXvop_DestroyGLXPbufferSGIX;
+      XFreePixmap(dpy, pixmap);
+      protocolDestroyDrawable(dpy, id, o);
+      id = None;
+   }
 
    return id;
 }
index fa2e2d3..f915426 100644 (file)
@@ -138,6 +138,7 @@ struct __GLXDRIdrawableRec
    GLenum textureTarget;
    GLenum textureFormat;        /* EXT_texture_from_pixmap support */
    unsigned long eventMask;
+   int refcount;
 };
 
 /*
@@ -223,7 +224,7 @@ struct glx_context_vtable {
                          GLXDrawable drawable,
                          int buffer, const int *attrib_list);
    void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer);
-   
+   void * (*get_proc_address)(const char *symbol);
 };
 
 extern void
@@ -566,6 +567,8 @@ struct glx_display
      */
    struct glx_screen **screens;
 
+   __glxHashTable *glXDrawHash;
+
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
    __glxHashTable *drawHash;
 
@@ -578,6 +581,14 @@ struct glx_display
 #endif
 };
 
+struct glx_drawable {
+   XID xDrawable;
+   XID drawable;
+
+   uint32_t lastEventSbc;
+   int64_t eventSbcWrap;
+};
+
 extern int
 glx_screen_init(struct glx_screen *psc,
                int screen, struct glx_display * priv);
@@ -783,6 +794,12 @@ extern int
 applegl_create_display(struct glx_display *display);
 #endif
 
+
+extern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable);
+extern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw,
+                          XID xDrawable, GLXDrawable drawable);
+extern void DestroyGLXDrawable(Display *dpy, GLXDrawable drawable);
+
 extern struct glx_context dummyContext;
 
 extern struct glx_screen *
index cd8bc97..fc0a079 100644 (file)
@@ -90,6 +90,51 @@ GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable)
 
 #endif
 
+_X_HIDDEN struct glx_drawable *
+GetGLXDrawable(Display *dpy, GLXDrawable drawable)
+{
+   struct glx_display *priv = __glXInitialize(dpy);
+   struct glx_drawable *glxDraw;
+
+   if (priv == NULL)
+      return NULL;
+
+   if (__glxHashLookup(priv->glXDrawHash, drawable, (void *) &glxDraw) == 0)
+      return glxDraw;
+
+   return NULL;
+}
+
+_X_HIDDEN int
+InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw, XID xDrawable,
+               GLXDrawable drawable)
+{
+   struct glx_display *priv = __glXInitialize(dpy);
+
+   if (!priv)
+      return -1;
+
+   glxDraw->xDrawable = xDrawable;
+   glxDraw->drawable = drawable;
+   glxDraw->lastEventSbc = 0;
+   glxDraw->eventSbcWrap = 0;
+
+   return __glxHashInsert(priv->glXDrawHash, drawable, glxDraw);
+}
+
+_X_HIDDEN void
+DestroyGLXDrawable(Display *dpy, GLXDrawable drawable)
+{
+   struct glx_display *priv = __glXInitialize(dpy);
+   struct glx_drawable *glxDraw;
+
+   if (!priv)
+      return;
+
+   glxDraw = GetGLXDrawable(dpy, drawable);
+   __glxHashDelete(priv->glXDrawHash, drawable);
+   free(glxDraw);
+}
 
 /**
  * Get the GLX per-screen data structure associated with a GLX context.
@@ -354,8 +399,9 @@ glx_send_destroy_context(Display *dpy, XID xid)
 /*
 ** Destroy the named context
 */
-static void
-DestroyContext(Display * dpy, GLXContext ctx)
+
+_X_EXPORT void
+glXDestroyContext(Display * dpy, GLXContext ctx)
 {
    struct glx_context *gc = (struct glx_context *) ctx;
 
@@ -380,12 +426,6 @@ DestroyContext(Display * dpy, GLXContext ctx)
    gc->vtable->destroy(gc);
 }
 
-_X_EXPORT void
-glXDestroyContext(Display * dpy, GLXContext gc)
-{
-   DestroyContext(dpy, gc);
-}
-
 /*
 ** Return the major and minor version #s for the GLX extension
 */
@@ -613,6 +653,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
    return pixmap;
 #else
    xGLXCreateGLXPixmapReq *req;
+   struct glx_drawable *glxDraw;
    GLXPixmap xid;
    CARD8 opcode;
 
@@ -621,6 +662,10 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
       return None;
    }
 
+   glxDraw = Xmalloc(sizeof(*glxDraw));
+   if (!glxDraw)
+      return None;
+
    /* Send the glXCreateGLXPixmap request */
    LockDisplay(dpy);
    GetReq(GLXCreateGLXPixmap, req);
@@ -633,6 +678,11 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
    UnlockDisplay(dpy);
    SyncHandle();
 
+   if (InitGLXDrawable(dpy, glxDraw, pixmap, req->glxpixmap)) {
+      free(glxDraw);
+      return None;
+   }
+
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
    do {
       /* FIXME: Maybe delay __DRIdrawable creation until the drawable
@@ -645,19 +695,33 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
 
       psc = priv->screens[vis->screen];
       if (psc->driScreen == NULL)
-         break;
+         return xid;
+
       config = glx_config_find_visual(psc->visuals, vis->visualid);
       pdraw = psc->driScreen->createDrawable(psc, pixmap, xid, config);
       if (pdraw == NULL) {
          fprintf(stderr, "failed to create pixmap\n");
+         xid = None;
          break;
       }
 
       if (__glxHashInsert(priv->drawHash, xid, pdraw)) {
          (*pdraw->destroyDrawable) (pdraw);
-         return None;           /* FIXME: Check what we're supposed to do here... */
+         xid = None;
+         break;
       }
    } while (0);
+
+   if (xid == None) {
+      xGLXDestroyGLXPixmapReq *dreq;
+      LockDisplay(dpy);
+      GetReq(GLXDestroyGLXPixmap, dreq);
+      dreq->reqType = opcode;
+      dreq->glxCode = X_GLXDestroyGLXPixmap;
+      dreq->glxpixmap = xid;
+      UnlockDisplay(dpy);
+      SyncHandle();
+   }
 #endif
 
    return xid;
@@ -691,6 +755,8 @@ glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
    UnlockDisplay(dpy);
    SyncHandle();
 
+   DestroyGLXDrawable(dpy, glxpixmap);
+
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
    {
       struct glx_display *const priv = __glXInitialize(dpy);
@@ -1479,12 +1545,9 @@ _X_EXPORT GLXContextID glXGetContextIDEXT(const GLXContext ctx_user)
    return ctx->xid;
 }
 
-_X_EXPORT void
-glXFreeContextEXT(Display * dpy, GLXContext ctx)
-{
-   DestroyContext(dpy, ctx);
-}
-
+_X_EXPORT
+GLX_ALIAS_VOID(glXFreeContextEXT, (Display *dpy, GLXContext ctx), (dpy, ctx),
+              glXDestroyContext);
 
 _X_EXPORT GLXFBConfig *
 glXChooseFBConfig(Display * dpy, int screen,
@@ -2521,6 +2584,12 @@ _X_EXPORT void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
 #endif
       if (!f)
          f = (gl_function) _glapi_get_proc_address((const char *) procName);
+      if (!f) {
+         struct glx_context *gc = __glXGetCurrentContext();
+      
+         if (gc != NULL && gc->vtable->get_proc_address != NULL)
+            f = gc->vtable->get_proc_address((const char *) procName);
+      }
    }
    return f;
 }
index 064fd71..c92a2fd 100644 (file)
@@ -212,7 +212,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
 {
    struct glx_context *gc = (struct glx_context *) gc_user;
    struct glx_context *oldGC = __glXGetCurrentContext();
-   int ret = Success;
 
    /* XXX: If this is left out, then libGL ends up not having this
     * symbol, and drivers using it fail to load.  Compare the
@@ -255,37 +254,45 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
       if (--oldGC->thread_refcount == 0) {
         oldGC->vtable->unbind(oldGC, gc);
         oldGC->currentDpy = 0;
-        oldGC->currentDrawable = None;
-        oldGC->currentReadable = None;
-
-        if (oldGC->xid == None && oldGC != gc) {
-           /* We are switching away from a context that was
-            * previously destroyed, so we need to free the memory
-            * for the old handle. */
-           oldGC->vtable->destroy(oldGC);
-        }
       }
    }
 
    if (gc) {
-      if (gc->thread_refcount++ == 0) {
-        gc->currentDpy = dpy;
-        gc->currentDrawable = draw;
-        gc->currentReadable = read;
+      /* Attempt to bind the context.  We do this before mucking with
+       * gc and __glXSetCurrentContext to properly handle our state in
+       * case of an error.
+       *
+       * If an error occurs, set the Null context since we've already
+       * blown away our old context.  The caller is responsible for
+       * figuring out how to handle setting a valid context.
+       */
+      if (gc->vtable->bind(gc, oldGC, draw, read) != Success) {
+         __glXSetCurrentContextNull();
+         __glXUnlock();
+         __glXGenerateError(dpy, None, GLXBadContext, X_GLXMakeContextCurrent);
+         return GL_FALSE;
       }
+
+      if (gc->thread_refcount == 0) {
+         gc->currentDpy = dpy;
+         gc->currentDrawable = draw;
+         gc->currentReadable = read;
+      }
+      gc->thread_refcount++;
       __glXSetCurrentContext(gc);
-      ret = gc->vtable->bind(gc, oldGC, draw, read);
    } else {
       __glXSetCurrentContextNull();
    }
 
-   __glXUnlock();
-
-   if (ret) {
-      __glXGenerateError(dpy, None, ret, X_GLXMakeContextCurrent);
-      return GL_FALSE;
+   if (oldGC->thread_refcount == 0 && oldGC != &dummyContext && oldGC->xid == None) {
+      /* We are switching away from a context that was
+       * previously destroyed, so we need to free the memory
+       * for the old handle. */
+      oldGC->vtable->destroy(oldGC);
    }
 
+   __glXUnlock();
+
    return GL_TRUE;
 }
 
index 73c3327..8254544 100644 (file)
@@ -133,12 +133,20 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
    case GLX_BufferSwapComplete:
    {
       GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
-      xGLXBufferSwapComplete *awire = (xGLXBufferSwapComplete *)wire;
+      xGLXBufferSwapComplete2 *awire = (xGLXBufferSwapComplete2 *)wire;
+      struct glx_drawable *glxDraw = GetGLXDrawable(dpy, awire->drawable);
       aevent->event_type = awire->event_type;
       aevent->drawable = awire->drawable;
       aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
       aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
-      aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo;
+
+      if (!glxDraw)
+        return False;
+
+      if (awire->sbc < glxDraw->lastEventSbc)
+        glxDraw->eventSbcWrap += 0x100000000;
+      glxDraw->lastEventSbc = awire->sbc;
+      aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
       return True;
    }
    default:
@@ -227,6 +235,8 @@ glx_display_free(struct glx_display *priv)
    if (priv->serverGLXversion)
       Xfree((char *) priv->serverGLXversion);
 
+   __glxHashDestroy(priv->glXDrawHash);
+
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
    __glxHashDestroy(priv->drawHash);
 
@@ -250,24 +260,19 @@ glx_display_free(struct glx_display *priv)
 static int
 __glXCloseDisplay(Display * dpy, XExtCodes * codes)
 {
-   struct glx_display *priv, **prev, *next;
+   struct glx_display *priv, **prev;
 
    _XLockMutex(_Xglobal_lock);
    prev = &glx_displays;
    for (priv = glx_displays; priv; prev = &priv->next, priv = priv->next) {
       if (priv->dpy == dpy) {
+         *prev = priv->next;
         break;
       }
    }
+   _XUnlockMutex(_Xglobal_lock);
 
-   /* Only remove the display from the list after it's destroyed. The cleanup
-    * code (e.g. driReleaseDrawables()) ends up calling __glXInitialize(),
-    * which would create a new glx_display while we're trying to destroy this
-    * one. */
-   next = priv->next;
    glx_display_free(priv);
-   *prev = next;
-   _XUnlockMutex(_Xglobal_lock);
 
    return 1;
 }
@@ -847,6 +852,8 @@ __glXInitialize(Display * dpy)
    XESetCloseDisplay(dpy, dpyPriv->codes->extension, __glXCloseDisplay);
    XESetErrorString (dpy, dpyPriv->codes->extension,__glXErrorString);
 
+   dpyPriv->glXDrawHash = __glxHashCreate();
+
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
    glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
    glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
index b4f16c7..7b542dd 100644 (file)
@@ -335,6 +335,7 @@ static const struct glx_context_vtable indirect_context_vtable = {
    indirect_use_x_font,
    indirect_bind_tex_image,
    indirect_release_tex_image,
+   NULL, /* get_proc_address */
 };
 
 /**
index 276b216..a776474 100644 (file)
@@ -52,30 +52,23 @@ if env['platform'] != 'winddk':
     if env['gcc'] and env['platform'] != 'windows':
         if env['machine'] == 'x86':
             env.Append(CPPDEFINES = [
-                'USE_X86_ASM', 
-                'USE_MMX_ASM',
-                'USE_3DNOW_ASM',
-                'USE_SSE_ASM',
+                'USE_X86_ASM',
             ])
             glapi_sources += [
                 'glapi_x86.S',
             ]
         elif env['machine'] == 'x86_64':
             env.Append(CPPDEFINES = [
-                'USE_X86_64_ASM', 
+                'USE_X86_64_ASM',
             ])
             glapi_sources += [
                 'glapi_x86-64.S'
             ]
-        elif env['machine'] == 'ppc':
+        elif env['machine'] == 'sparc':
             env.Append(CPPDEFINES = [
-                'USE_PPC_ASM', 
-                'USE_VMX_ASM', 
+                'USE_SPARC_ASM',
             ])
             glapi_sources += [
-            ]
-        elif env['machine'] == 'sparc':
-            glapi_sources += [
                 'glapi_sparc.S'
             ]
         else:
index ca9a101..d9e540f 100644 (file)
@@ -38,7 +38,7 @@
         <param name="texture" type="GLuint"/>
         <param name="level" type="GLint"/>
     </function>
-    <function name="FramebufferTextureLayerARB" alias="FramebufferTextureLayer">
+    <function name="FramebufferTextureLayerARB" alias="FramebufferTextureLayerEXT">
         <param name="target" type="GLenum"/>
         <param name="attachment" type="GLenum"/>
         <param name="texture" type="GLuint"/>
index a903a26..88f31b6 100644 (file)
@@ -12,11 +12,10 @@ DRICORE_OBJ_DIR := objs-dricore
 include sources.mak
 
 # adjust object dirs
+DRICORE_OBJECTS := $(addprefix $(DRICORE_OBJ_DIR)/, $(MESA_OBJECTS))
 MESA_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_OBJECTS))
 MESA_GALLIUM_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS))
 
-DRICORE_OBJECTS := $(addprefix $(DRICORE_OBJ_DIR)/, $(MESA_OBJECTS))
-
 # define preprocessor flags
 MESA_CPPFLAGS := $(API_DEFINES) $(DEFINES)
 
@@ -124,6 +123,8 @@ depend: $(ALL_SOURCES)
        @ touch depend
        @$(MKDEP) $(MKDEP_OPTIONS) -p$(MESA_OBJ_DIR)/ $(MESA_CPPFLAGS) \
                $(ALL_SOURCES) > /dev/null 2>/dev/null
+       @$(MKDEP) $(MKDEP_OPTIONS) -a -p$(DRICORE_OBJ_DIR)/ $(MESA_CPPFLAGS) \
+               $(ALL_SOURCES) > /dev/null 2>/dev/null
 
 ######################################################################
 # Installation rules
index 8ab129d..7663026 100644 (file)
@@ -95,8 +95,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->TexSubImage2D = _mesa_store_texsubimage2d;
    driver->TexSubImage3D = _mesa_store_texsubimage3d;
    driver->GetTexImage = _mesa_get_teximage;
-   driver->CopyTexImage1D = _mesa_meta_CopyTexImage1D;
-   driver->CopyTexImage2D = _mesa_meta_CopyTexImage2D;
    driver->CopyTexSubImage1D = _mesa_meta_CopyTexSubImage1D;
    driver->CopyTexSubImage2D = _mesa_meta_CopyTexSubImage2D;
    driver->CopyTexSubImage3D = _mesa_meta_CopyTexSubImage3D;
index 0e58aec..f9b4755 100644 (file)
@@ -62,6 +62,7 @@
 #include "main/teximage.h"
 #include "main/texparam.h"
 #include "main/texstate.h"
+#include "main/uniforms.h"
 #include "main/varray.h"
 #include "main/viewport.h"
 #include "program/program.h"
 #define META_SCISSOR         0x100
 #define META_SHADER          0x200
 #define META_STENCIL_TEST    0x400
-#define META_TRANSFORM       0x800 /**< modelview, projection, clip planes */
+#define META_TRANSFORM       0x800 /**< modelview/projection matrix state */
 #define META_TEXTURE        0x1000
 #define META_VERTEX         0x2000
 #define META_VIEWPORT       0x4000
 #define META_CLAMP_FRAGMENT_COLOR 0x8000
 #define META_CLAMP_VERTEX_COLOR 0x10000
 #define META_CONDITIONAL_RENDER 0x20000
+#define META_CLIP          0x40000
 /*@}*/
 
 
@@ -164,6 +166,8 @@ struct save_state
    GLfloat ModelviewMatrix[16];
    GLfloat ProjectionMatrix[16];
    GLfloat TextureMatrix[16];
+
+   /** META_CLIP */
    GLbitfield ClipPlanesEnabled;
 
    /** META_TEXTURE */
@@ -235,6 +239,8 @@ struct clear_state
 {
    GLuint ArrayObj;
    GLuint VBO;
+   GLuint ShaderProg;
+   GLint ColorLocation;
 };
 
 
@@ -544,6 +550,9 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
       _mesa_Ortho(0.0, ctx->DrawBuffer->Width,
                   0.0, ctx->DrawBuffer->Height,
                   -1.0, 1.0);
+   }
+
+   if (state & META_CLIP) {
       save->ClipPlanesEnabled = ctx->Transform.ClipPlanesEnabled;
       if (ctx->Transform.ClipPlanesEnabled) {
          GLuint i;
@@ -843,7 +852,9 @@ _mesa_meta_end(struct gl_context *ctx)
       _mesa_LoadMatrixf(save->ProjectionMatrix);
 
       _mesa_MatrixMode(save->MatrixMode);
+   }
 
+   if (state & META_CLIP) {
       if (save->ClipPlanesEnabled) {
          GLuint i;
          for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
@@ -1589,10 +1600,166 @@ _mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers)
    _mesa_meta_end(ctx);
 }
 
+static void
+meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
+{
+   const char *vs_source =
+      "attribute vec4 position;\n"
+      "void main()\n"
+      "{\n"
+      "   gl_Position = position;\n"
+      "}\n";
+   const char *fs_source =
+      "uniform vec4 color;\n"
+      "void main()\n"
+      "{\n"
+      "   gl_FragColor = color;\n"
+      "}\n";
+   GLuint vs, fs;
+
+   if (clear->ArrayObj != 0)
+      return;
+
+   /* create vertex array object */
+   _mesa_GenVertexArrays(1, &clear->ArrayObj);
+   _mesa_BindVertexArray(clear->ArrayObj);
+
+   /* create vertex array buffer */
+   _mesa_GenBuffersARB(1, &clear->VBO);
+   _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO);
+
+   /* setup vertex arrays */
+   _mesa_VertexAttribPointerARB(0, 3, GL_FLOAT, GL_FALSE, 0, (void *)0);
+   _mesa_EnableVertexAttribArrayARB(0);
+
+   vs = _mesa_CreateShaderObjectARB(GL_VERTEX_SHADER);
+   _mesa_ShaderSourceARB(vs, 1, &vs_source, NULL);
+   _mesa_CompileShaderARB(vs);
+
+   fs = _mesa_CreateShaderObjectARB(GL_FRAGMENT_SHADER);
+   _mesa_ShaderSourceARB(fs, 1, &fs_source, NULL);
+   _mesa_CompileShaderARB(fs);
+
+   clear->ShaderProg = _mesa_CreateProgramObjectARB();
+   _mesa_AttachShader(clear->ShaderProg, fs);
+   _mesa_AttachShader(clear->ShaderProg, vs);
+   _mesa_BindAttribLocationARB(clear->ShaderProg, 0, "position");
+   _mesa_LinkProgramARB(clear->ShaderProg);
+
+   clear->ColorLocation = _mesa_GetUniformLocationARB(clear->ShaderProg,
+                                                     "color");
+}
+
+/**
+ * Meta implementation of ctx->Driver.Clear() in terms of polygon rendering.
+ */
+void
+_mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers)
+{
+   struct clear_state *clear = &ctx->Meta->Clear;
+   GLbitfield metaSave;
+   const GLuint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const float x0 = ((float)fb->_Xmin / fb->Width)  * 2.0f - 1.0f;
+   const float y0 = ((float)fb->_Ymin / fb->Height) * 2.0f - 1.0f;
+   const float x1 = ((float)fb->_Xmax / fb->Width)  * 2.0f - 1.0f;
+   const float y1 = ((float)fb->_Ymax / fb->Height) * 2.0f - 1.0f;
+   const float z = -invert_z(ctx->Depth.Clear);
+   struct vertex {
+      GLfloat x, y, z;
+   } verts[4];
+
+   metaSave = (META_ALPHA_TEST |
+              META_BLEND |
+              META_DEPTH_TEST |
+              META_RASTERIZATION |
+              META_SHADER |
+              META_STENCIL_TEST |
+              META_VERTEX |
+              META_VIEWPORT |
+              META_CLIP |
+              META_CLAMP_FRAGMENT_COLOR);
+
+   if (!(buffers & BUFFER_BITS_COLOR)) {
+      /* We'll use colormask to disable color writes.  Otherwise,
+       * respect color mask
+       */
+      metaSave |= META_COLOR_MASK;
+   }
+
+   _mesa_meta_begin(ctx, metaSave);
+
+   meta_glsl_clear_init(ctx, clear);
+
+   _mesa_UseProgramObjectARB(clear->ShaderProg);
+   _mesa_Uniform4fvARB(clear->ColorLocation, 1,
+                      ctx->Color.ClearColorUnclamped);
+
+   _mesa_BindVertexArray(clear->ArrayObj);
+   _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO);
+
+   /* GL_COLOR_BUFFER_BIT */
+   if (buffers & BUFFER_BITS_COLOR) {
+      /* leave colormask, glDrawBuffer state as-is */
+
+      /* Clears never have the color clamped. */
+      _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE);
+   }
+   else {
+      ASSERT(metaSave & META_COLOR_MASK);
+      _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+   }
+
+   /* GL_DEPTH_BUFFER_BIT */
+   if (buffers & BUFFER_BIT_DEPTH) {
+      _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_TRUE);
+      _mesa_DepthFunc(GL_ALWAYS);
+      _mesa_DepthMask(GL_TRUE);
+   }
+   else {
+      assert(!ctx->Depth.Test);
+   }
+
+   /* GL_STENCIL_BUFFER_BIT */
+   if (buffers & BUFFER_BIT_STENCIL) {
+      _mesa_set_enable(ctx, GL_STENCIL_TEST, GL_TRUE);
+      _mesa_StencilOpSeparate(GL_FRONT_AND_BACK,
+                              GL_REPLACE, GL_REPLACE, GL_REPLACE);
+      _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS,
+                                ctx->Stencil.Clear & stencilMax,
+                                ctx->Stencil.WriteMask[0]);
+   }
+   else {
+      assert(!ctx->Stencil.Enabled);
+   }
+
+   /* vertex positions */
+   verts[0].x = x0;
+   verts[0].y = y0;
+   verts[0].z = z;
+   verts[1].x = x1;
+   verts[1].y = y0;
+   verts[1].z = z;
+   verts[2].x = x1;
+   verts[2].y = y1;
+   verts[2].z = z;
+   verts[3].x = x0;
+   verts[3].y = y1;
+   verts[3].z = z;
+
+   /* upload new vertex data */
+   _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
+                      GL_DYNAMIC_DRAW_ARB);
+
+   /* draw quad */
+   _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+   _mesa_meta_end(ctx);
+}
 
 /**
  * Meta implementation of ctx->Driver.CopyPixels() in terms
- * of texture mapping and polygon rendering.
+ * of texture mapping and polygon rendering and GLSL shaders.
  */
 void
 _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
@@ -1625,6 +1792,7 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
                           META_SHADER |
                           META_TEXTURE |
                           META_TRANSFORM |
+                          META_CLIP |
                           META_VERTEX |
                           META_VIEWPORT));
 
@@ -1946,6 +2114,7 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
                           META_SHADER |
                           META_TEXTURE |
                           META_TRANSFORM |
+                          META_CLIP |
                           META_VERTEX |
                           META_VIEWPORT |
                          META_CLAMP_FRAGMENT_COLOR |
@@ -2155,6 +2324,7 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
                           META_SHADER |
                           META_TEXTURE |
                           META_TRANSFORM |
+                          META_CLIP |
                           META_VERTEX |
                           META_VIEWPORT));
 
@@ -2678,119 +2848,6 @@ get_temp_image_type(struct gl_context *ctx, GLenum baseFormat)
 
 
 /**
- * Helper for _mesa_meta_CopyTexImage1/2D() functions.
- * Have to be careful with locking and meta state for pixel transfer.
- */
-static void
-copy_tex_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
-               GLenum internalFormat, GLint x, GLint y,
-               GLsizei width, GLsizei height, GLint border)
-{
-   struct gl_texture_object *texObj;
-   struct gl_texture_image *texImage;
-   GLenum format, type;
-   GLint bpp;
-   void *buf;
-   struct gl_renderbuffer *read_rb = ctx->ReadBuffer->_ColorReadBuffer;
-
-   texObj = _mesa_get_current_tex_object(ctx, target);
-   texImage = _mesa_get_tex_image(ctx, texObj, target, level);
-
-   /* Choose format/type for temporary image buffer */
-   format = _mesa_base_tex_format(ctx, internalFormat);
-
-   if (format == GL_LUMINANCE &&
-       _mesa_get_format_base_format(read_rb->Format) != GL_LUMINANCE) {
-      /* The glReadPixels() path will convert RGB to luminance by
-       * summing R+G+B.  glCopyTexImage() is supposed to behave as
-       * glCopyPixels, which doesn't do that change, and instead
-       * leaves it up to glTexImage which converts RGB to luminance by
-       * just taking the R channel.  To avoid glReadPixels() trashing
-       * our data, use RGBA for our temporary image.
-       */
-      format = GL_RGBA;
-   }
-
-   type = get_temp_image_type(ctx, format);
-   bpp = _mesa_bytes_per_pixel(format, type);
-   if (bpp <= 0) {
-      _mesa_problem(ctx, "Bad bpp in meta copy_tex_image()");
-      return;
-   }
-
-   /*
-    * Alloc image buffer (XXX could use a PBO)
-    */
-   buf = malloc(width * height * bpp);
-   if (!buf) {
-      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
-      return;
-   }
-
-   _mesa_unlock_texture(ctx, texObj); /* need to unlock first */
-
-   /*
-    * Read image from framebuffer (disable pixel transfer ops)
-    */
-   _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER);
-   ctx->Driver.ReadPixels(ctx, x, y, width, height,
-                         format, type, &ctx->Pack, buf);
-   _mesa_meta_end(ctx);
-
-   if (texImage->Data) {
-      ctx->Driver.FreeTexImageData(ctx, texImage);
-   }
-
-   /* The texture's format was already chosen in _mesa_CopyTexImage() */
-   ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
-
-   /*
-    * Store texture data (with pixel transfer ops)
-    */
-   _mesa_meta_begin(ctx, META_PIXEL_STORE);
-
-   _mesa_update_state(ctx); /* to update pixel transfer state */
-
-   if (target == GL_TEXTURE_1D) {
-      ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
-                             width, border, format, type,
-                             buf, &ctx->Unpack, texObj, texImage);
-   }
-   else {
-      ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
-                             width, height, border, format, type,
-                             buf, &ctx->Unpack, texObj, texImage);
-   }
-   _mesa_meta_end(ctx);
-
-   _mesa_lock_texture(ctx, texObj); /* re-lock */
-
-   free(buf);
-}
-
-
-void
-_mesa_meta_CopyTexImage1D(struct gl_context *ctx, GLenum target, GLint level,
-                          GLenum internalFormat, GLint x, GLint y,
-                          GLsizei width, GLint border)
-{
-   copy_tex_image(ctx, 1, target, level, internalFormat, x, y,
-                  width, 1, border);
-}
-
-
-void
-_mesa_meta_CopyTexImage2D(struct gl_context *ctx, GLenum target, GLint level,
-                          GLenum internalFormat, GLint x, GLint y,
-                          GLsizei width, GLsizei height, GLint border)
-{
-   copy_tex_image(ctx, 2, target, level, internalFormat, x, y,
-                  width, height, border);
-}
-
-
-
-/**
  * Helper for _mesa_meta_CopyTexSubImage1/2/3D() functions.
  * Have to be careful with locking and meta state for pixel transfer.
  */
@@ -2812,6 +2869,16 @@ copy_tex_sub_image(struct gl_context *ctx,
 
    /* Choose format/type for temporary image buffer */
    format = _mesa_get_format_base_format(texImage->TexFormat);
+   if (format == GL_LUMINANCE ||
+       format == GL_LUMINANCE_ALPHA ||
+       format == GL_INTENSITY) {
+      /* We don't want to use GL_LUMINANCE, GL_INTENSITY, etc. for the
+       * temp image buffer because glReadPixels will do L=R+G+B which is
+       * not what we want (should be L=R).
+       */
+      format = GL_RGBA;
+   }
+
    type = get_temp_image_type(ctx, format);
    bpp = _mesa_bytes_per_pixel(format, type);
    if (bpp <= 0) {
index b0797d3..95b4b55 100644 (file)
@@ -43,6 +43,9 @@ extern void
 _mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers);
 
 extern void
+_mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers);
+
+extern void
 _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
                       GLsizei width, GLsizei height,
                       GLint dstx, GLint dsty, GLenum type);
@@ -69,16 +72,6 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
                           struct gl_texture_object *texObj);
 
 extern void
-_mesa_meta_CopyTexImage1D(struct gl_context *ctx, GLenum target, GLint level,
-                          GLenum internalFormat, GLint x, GLint y,
-                          GLsizei width, GLint border);
-
-extern void
-_mesa_meta_CopyTexImage2D(struct gl_context *ctx, GLenum target, GLint level,
-                          GLenum internalFormat, GLint x, GLint y,
-                          GLsizei width, GLsizei height, GLint border);
-
-extern void
 _mesa_meta_CopyTexSubImage1D(struct gl_context *ctx, GLenum target, GLint level,
                              GLint xoffset,
                              GLint x, GLint y, GLsizei width);
index 0226b38..77967ac 100644 (file)
@@ -765,9 +765,9 @@ static void parseDeviceAttr (struct OptConfData *data, const XML_Char **attr) {
 /** \brief Parse attributes of an application element. */
 static void parseAppAttr (struct OptConfData *data, const XML_Char **attr) {
     GLuint i;
-    const XML_Char *name = NULL, *exec = NULL;
+    const XML_Char *exec = NULL;
     for (i = 0; attr[i]; i += 2) {
-       if (!strcmp (attr[i], "name")) name = attr[i+1];
+       if (!strcmp (attr[i], "name")) /* not needed here */;
        else if (!strcmp (attr[i], "executable")) exec = attr[i+1];
        else XML_WARNING("unknown application attribute: %s.", attr[i]);
     }
index abfb32b..d22118b 100644 (file)
@@ -33,6 +33,7 @@
 #include "tnl/t_pipeline.h"
 #include "intel_span.h"
 #include "intel_tris.h"
+#include "../glsl/ralloc.h"
 
 /***************************************
  * Mesa's Driver Functions
@@ -53,7 +54,7 @@ i830CreateContext(const struct gl_config * mesaVis,
                   void *sharedContextPrivate)
 {
    struct dd_function_table functions;
-   struct i830_context *i830 = CALLOC_STRUCT(i830_context);
+   struct i830_context *i830 = rzalloc(NULL, struct i830_context);
    struct intel_context *intel = &i830->intel;
    struct gl_context *ctx = &intel->ctx;
    if (!i830)
index d4af5e5..71ce44f 100644 (file)
@@ -76,7 +76,8 @@ translate_texture_format(GLuint mesa_format)
    case MESA_FORMAT_RGBA_DXT5:
       return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
    default:
-      fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format);
+      fprintf(stderr, "%s: bad image format %s\n", __FUNCTION__,
+             _mesa_get_format_name(mesa_format));
       abort();
       return 0;
    }
index 08ea287..6d43726 100644 (file)
 #include "intel_regions.h"
 #include "intel_tris.h"
 #include "intel_fbo.h"
+#include "intel_buffers.h"
+#include "tnl/tnl.h"
 #include "tnl/t_context.h"
 #include "tnl/t_vertex.h"
+#include "swrast_setup/swrast_setup.h"
+#include "main/renderbuffer.h"
+#include "main/framebuffer.h"
 
 #define FILE_DEBUG_FLAG DEBUG_STATE
 
@@ -616,11 +621,9 @@ i830_set_draw_region(struct intel_context *intel,
    uint32_t draw_x, draw_y;
 
    if (state->draw_region != color_regions[0]) {
-      intel_region_release(&state->draw_region);
       intel_region_reference(&state->draw_region, color_regions[0]);
    }
    if (state->depth_region != depth_region) {
-      intel_region_release(&state->depth_region);
       intel_region_reference(&state->depth_region, depth_region);
    }
 
@@ -695,6 +698,159 @@ i830_set_draw_region(struct intel_context *intel,
    I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
 }
 
+/**
+ * Update the hardware state for drawing into a window or framebuffer object.
+ *
+ * Called by glDrawBuffer, glBindFramebufferEXT, MakeCurrent, and other
+ * places within the driver.
+ *
+ * Basically, this needs to be called any time the current framebuffer
+ * changes, the renderbuffers change, or we need to draw into different
+ * color buffers.
+ */
+static void
+i830_update_draw_buffer(struct intel_context *intel)
+{
+   struct gl_context *ctx = &intel->ctx;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   struct intel_region *colorRegions[MAX_DRAW_BUFFERS], *depthRegion = NULL;
+   struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
+   bool fb_has_hiz = intel_framebuffer_has_hiz(fb);
+
+   if (!fb) {
+      /* this can happen during the initial context initialization */
+      return;
+   }
+
+   irbDepth = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+   irbStencil = intel_get_renderbuffer(fb, BUFFER_STENCIL);
+
+   /* Do this here, not core Mesa, since this function is called from
+    * many places within the driver.
+    */
+   if (ctx->NewState & _NEW_BUFFERS) {
+      /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
+      _mesa_update_framebuffer(ctx);
+      /* this updates the DrawBuffer's Width/Height if it's a FBO */
+      _mesa_update_draw_buffer_bounds(ctx);
+   }
+
+   if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      /* this may occur when we're called by glBindFrameBuffer() during
+       * the process of someone setting up renderbuffers, etc.
+       */
+      /*_mesa_debug(ctx, "DrawBuffer: incomplete user FBO\n");*/
+      return;
+   }
+
+   /* 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->Width > ctx->Const.MaxRenderbufferSize)
+       || (fb->Height > ctx->Const.MaxRenderbufferSize)
+       || (fb->_NumColorDrawBuffers == 0)) {
+      /* writing to 0  */
+      colorRegions[0] = NULL;
+   }
+   else if (fb->_NumColorDrawBuffers > 1) {
+       int i;
+       struct intel_renderbuffer *irb;
+
+       for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+           irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
+           colorRegions[i] = irb ? irb->region : NULL;
+       }
+   }
+   else {
+      /* Get the intel_renderbuffer for the single colorbuffer we're drawing
+       * into.
+       */
+      if (fb->Name == 0) {
+        /* drawing to window system buffer */
+        if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)
+           colorRegions[0] = intel_get_rb_region(fb, BUFFER_FRONT_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;
+      }
+   }
+
+   if (!colorRegions[0]) {
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE);
+   }
+   else {
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE);
+   }
+
+   /* Check for depth fallback. */
+   if (irbDepth && irbDepth->region) {
+      assert(!fb_has_hiz || irbDepth->Base.Format != MESA_FORMAT_S8_Z24);
+      FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+      depthRegion = irbDepth->region;
+   } else if (irbDepth && !irbDepth->region) {
+      FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_TRUE);
+      depthRegion = NULL;
+   } else { /* !irbDepth */
+      /* No fallback is needed because there is no depth buffer. */
+      FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+      depthRegion = NULL;
+   }
+
+   /* Check for stencil fallback. */
+   if (irbStencil && irbStencil->region) {
+      assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
+      FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+   } else if (irbStencil && !irbStencil->region) {
+      FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_TRUE);
+   } else { /* !irbStencil */
+      /* No fallback is needed because there is no stencil buffer. */
+      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
+       && irbStencil->Base.Format == MESA_FORMAT_S8_Z24) {
+      depthRegion = irbStencil->region;
+   }
+
+   /*
+    * Update depth and stencil test state
+    */
+   ctx->Driver.Enable(ctx, GL_DEPTH_TEST,
+                     (ctx->Depth.Test && fb->Visual.depthBits > 0));
+   ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
+                     (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));
+
+   intel->vtbl.set_draw_region(intel, colorRegions, depthRegion,
+                               fb->_NumColorDrawBuffers);
+   intel->NewGLState |= _NEW_BUFFERS;
+
+   /* update viewport since it depends on window size */
+   intelCalcViewport(ctx);
+
+   /* Set state we know depends on drawable parameters:
+    */
+   ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                      ctx->Scissor.Width, ctx->Scissor.Height);
+
+   ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far);
+
+   /* Update culling direction which changes depending on the
+    * orientation of the buffer:
+    */
+   ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
+}
+
 /* This isn't really handled at the moment.
  */
 static void
@@ -715,6 +871,12 @@ i830_assert_not_dirty( struct intel_context *intel )
 static void
 i830_invalidate_state(struct intel_context *intel, GLuint new_state)
 {
+   struct gl_context *ctx = &intel->ctx;
+
+   _swsetup_InvalidateState(ctx, new_state);
+   _tnl_InvalidateState(ctx, new_state);
+   _tnl_invalidate_vertex_state(ctx, new_state);
+
    if (new_state & _NEW_LIGHT)
       i830_update_provoking_vertex(&intel->ctx);
 }
@@ -728,6 +890,7 @@ i830InitVtbl(struct i830_context *i830)
    i830->intel.vtbl.new_batch = i830_new_batch;
    i830->intel.vtbl.reduced_primitive_state = i830_reduced_primitive_state;
    i830->intel.vtbl.set_draw_region = i830_set_draw_region;
+   i830->intel.vtbl.update_draw_buffer = i830_update_draw_buffer;
    i830->intel.vtbl.update_texture_state = i830UpdateTextureState;
    i830->intel.vtbl.render_start = i830_render_start;
    i830->intel.vtbl.render_prevalidate = i830_render_prevalidate;
index f02f2d7..11bee14 100644 (file)
@@ -36,6 +36,7 @@
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "tnl/tnl.h"
+#include "../glsl/ralloc.h"
 
 #include "i915_reg.h"
 #include "i915_program.h"
@@ -97,8 +98,7 @@ i915CreateContext(int api,
                   void *sharedContextPrivate)
 {
    struct dd_function_table functions;
-   struct i915_context *i915 =
-      (struct i915_context *) CALLOC_STRUCT(i915_context);
+   struct i915_context *i915 = rzalloc(NULL, struct i915_context);
    struct intel_context *intel = &i915->intel;
    struct gl_context *ctx = &intel->ctx;
 
index b67ebb9..32050ce 100644 (file)
@@ -210,6 +210,7 @@ get_result_vector(struct i915_fragment_program *p,
    case PROGRAM_OUTPUT:
       switch (inst->DstReg.Index) {
       case FRAG_RESULT_COLOR:
+      case FRAG_RESULT_DATA0:
          return UREG(REG_TYPE_OC, 0);
       case FRAG_RESULT_DEPTH:
          p->depth_written = 1;
@@ -302,7 +303,7 @@ do {                                                                        \
 /* 
  * TODO: consider moving this into core 
  */
-static void calc_live_regs( struct i915_fragment_program *p )
+static bool calc_live_regs( struct i915_fragment_program *p )
 {
     const struct gl_fragment_program *program = &p->FragProg;
     GLuint regsUsed = 0xffff0000;
@@ -316,6 +317,9 @@ static void calc_live_regs( struct i915_fragment_program *p )
 
         /* Register is written to: unmark as live for this and preceeding ops */ 
         if (inst->DstReg.File == PROGRAM_TEMPORARY) {
+           if (inst->DstReg.Index > 16)
+              return false;
+
             live_components[inst->DstReg.Index] &= ~inst->DstReg.WriteMask;
             if (live_components[inst->DstReg.Index] == 0)
                 regsUsed &= ~(1 << inst->DstReg.Index);
@@ -326,6 +330,9 @@ static void calc_live_regs( struct i915_fragment_program *p )
             if (inst->SrcReg[a].File == PROGRAM_TEMPORARY) {
                 unsigned c;
 
+               if (inst->SrcReg[a].Index > 16)
+                  return false;
+
                 regsUsed |= 1 << inst->SrcReg[a].Index;
 
                 for (c = 0; c < 4; c++) {
@@ -339,6 +346,8 @@ static void calc_live_regs( struct i915_fragment_program *p )
 
         p->usedRegs[i] = regsUsed;
     }
+
+    return true;
 }
 
 static GLuint get_live_regs( struct i915_fragment_program *p, 
@@ -393,7 +402,10 @@ upload_program(struct i915_fragment_program *p)
 
    /* Not always needed:
     */
-   calc_live_regs(p);
+   if (!calc_live_regs(p)) {
+      i915_program_error(p, "Could not allocate registers");
+      return;
+   }
 
    while (1) {
       GLuint src0, src1, src2, flags;
@@ -1341,11 +1353,10 @@ i915ValidateFragmentProgram(struct i915_context *i915)
 
    intel->vertex_attr_count = 0;
    intel->wpos_offset = 0;
-   intel->wpos_size = 0;
    intel->coloroffset = 0;
    intel->specoffset = 0;
 
-   if (inputsRead & FRAG_BITS_TEX_ANY) {
+   if (inputsRead & FRAG_BITS_TEX_ANY || p->wpos_tex != -1) {
       EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16);
    }
    else {
@@ -1384,17 +1395,15 @@ i915ValidateFragmentProgram(struct i915_context *i915)
          EMIT_ATTR(_TNL_ATTRIB_GENERIC0 + i, EMIT_SZ(sz), 0, sz * 4);
       }
       else if (i == p->wpos_tex) {
-
+        int wpos_size = 4 * sizeof(float);
          /* If WPOS is required, duplicate the XYZ position data in an
           * unused texture coordinate:
           */
          s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK);
-         s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(3));
+         s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(wpos_size));
 
          intel->wpos_offset = offset;
-         intel->wpos_size = 3 * sizeof(GLuint);
-
-         EMIT_PAD(intel->wpos_size);
+         EMIT_PAD(wpos_size);
       }
    }
 
index 507adf1..0a600d3 100644 (file)
@@ -442,14 +442,16 @@ i915_emit_param4fv(struct i915_fragment_program * p, const GLfloat * values)
 void
 i915_program_error(struct i915_fragment_program *p, const char *fmt, ...)
 {
-   va_list args;
+   if (unlikely((INTEL_DEBUG & (DEBUG_WM | DEBUG_FALLBACKS)) != 0)) {
+      va_list args;
 
-   fprintf(stderr, "i915_program_error: ");
-   va_start(args, fmt);
-   vfprintf(stderr, fmt, args);
-   va_end(args);
+      fprintf(stderr, "i915_program_error: ");
+      va_start(args, fmt);
+      vfprintf(stderr, fmt, args);
+      va_end(args);
 
-   fprintf(stderr, "\n");
+      fprintf(stderr, "\n");
+   }
    p->error = 1;
 }
 
@@ -538,7 +540,6 @@ i915_upload_program(struct i915_context *i915,
 {
    GLuint program_size = p->csr - p->program;
    GLuint decl_size = p->decl - p->declarations;
-   GLuint nr;
 
    if (p->error)
       return;
@@ -555,33 +556,33 @@ i915_upload_program(struct i915_context *i915,
       i915->state.ProgramSize = decl_size + program_size;
    }
 
-   nr = p->nr_constants;
-   if (i915->state.ConstantSize != 2 + nr*4 ||
-       memcmp(i915->state.Constant + 2,
-             p->constant, 4*sizeof(int)*nr)) {
-      if (nr) {
-        I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 1);
-        I915_STATECHANGE(i915, I915_UPLOAD_CONSTANTS);
-
-        i915->state.Constant[0] = _3DSTATE_PIXEL_SHADER_CONSTANTS | (nr * 4);
-        i915->state.Constant[1] = (1 << nr) -1;
-
-        memcpy(&i915->state.Constant[2], p->constant, 4 * sizeof(int) * nr);
-        i915->state.ConstantSize = 2 + nr * 4;
-
-        if (0) {
-           GLuint i;
-           for (i = 0; i < nr; i++) {
-              fprintf(stderr, "const[%d]: %f %f %f %f\n", i,
-                      p->constant[i][0],
-                      p->constant[i][1], p->constant[i][2], p->constant[i][3]);
-           }
-        }
-      }
-      else {
-        I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 0);
+   /* Always seemed to get a failure if I used memcmp() to
+    * shortcircuit this state upload.  Needs further investigation?
+    */
+   if (p->nr_constants) {
+      GLuint nr = p->nr_constants;
+
+      I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 1);
+      I915_STATECHANGE(i915, I915_UPLOAD_CONSTANTS);
+
+      i915->state.Constant[0] = _3DSTATE_PIXEL_SHADER_CONSTANTS | ((nr) * 4);
+      i915->state.Constant[1] = (1 << (nr - 1)) | ((1 << (nr - 1)) - 1);
+
+      memcpy(&i915->state.Constant[2], p->constant, 4 * sizeof(int) * (nr));
+      i915->state.ConstantSize = 2 + (nr) * 4;
+
+      if (0) {
+         GLuint i;
+         for (i = 0; i < nr; i++) {
+            fprintf(stderr, "const[%d]: %f %f %f %f\n", i,
+                    p->constant[i][0],
+                    p->constant[i][1], p->constant[i][2], p->constant[i][3]);
+         }
       }
    }
+   else {
+      I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 0);
+   }
 
    p->on_hardware = 1;
 }
index 99212ad..2b35ed7 100644 (file)
@@ -375,6 +375,9 @@ i915DepthMask(struct gl_context * ctx, GLboolean flag)
 
    DBG("%s flag (%d)\n", __FUNCTION__, flag);
 
+   if (!ctx->DrawBuffer || !ctx->DrawBuffer->Visual.depthBits)
+      flag = false;
+
    dw = i915->state.Ctx[I915_CTXREG_LIS6];
    if (flag && ctx->Depth.Test)
       dw |= S6_DEPTH_WRITE_ENABLE;
@@ -398,31 +401,26 @@ void
 intelCalcViewport(struct gl_context * ctx)
 {
    struct intel_context *intel = intel_context(ctx);
-   const GLfloat *v = ctx->Viewport._WindowMap.m;
-   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
-   GLfloat *m = intel->ViewportMatrix.m;
-   GLfloat yScale, yBias;
-
-   if (ctx->DrawBuffer->Name) {
-      /* User created FBO */
-      /* y=0=bottom */
-      yScale = 1.0;
-      yBias = 0.0;
-   }
-   else {
-      /* window buffer, y=0=top */
-      yScale = -1.0;
-      yBias = ctx->DrawBuffer->Height;
-   }
-
-   m[MAT_SX] = v[MAT_SX];
-   m[MAT_TX] = v[MAT_TX];
 
-   m[MAT_SY] = v[MAT_SY] * yScale;
-   m[MAT_TY] = v[MAT_TY] * yScale + yBias;
-
-   m[MAT_SZ] = v[MAT_SZ] * depthScale;
-   m[MAT_TZ] = v[MAT_TZ] * depthScale;
+   if (ctx->DrawBuffer->Name == 0) {
+      _math_matrix_viewport(&intel->ViewportMatrix,
+                           ctx->Viewport.X,
+                           ctx->DrawBuffer->Height - ctx->Viewport.Y,
+                           ctx->Viewport.Width,
+                           -ctx->Viewport.Height,
+                           ctx->Viewport.Near,
+                           ctx->Viewport.Far,
+                           1.0);
+   } else {
+      _math_matrix_viewport(&intel->ViewportMatrix,
+                           ctx->Viewport.X,
+                           ctx->Viewport.Y,
+                           ctx->Viewport.Width,
+                           ctx->Viewport.Height,
+                           ctx->Viewport.Near,
+                           ctx->Viewport.Far,
+                           1.0);
+   }
 }
 
 
@@ -797,6 +795,10 @@ i915Enable(struct gl_context * ctx, GLenum cap, GLboolean state)
 
    case GL_DEPTH_TEST:
       dw = i915->state.Ctx[I915_CTXREG_LIS6];
+
+      if (!ctx->DrawBuffer || !ctx->DrawBuffer->Visual.depthBits)
+        state = false;
+
       if (state)
          dw |= S6_DEPTH_TEST_ENABLE;
       else
@@ -836,27 +838,17 @@ i915Enable(struct gl_context * ctx, GLenum cap, GLboolean state)
       break;
 
    case GL_STENCIL_TEST:
-      {
-         GLboolean hw_stencil = GL_FALSE;
-         if (ctx->DrawBuffer) {
-            struct intel_renderbuffer *irbStencil
-               = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
-            hw_stencil = (irbStencil && irbStencil->region);
-         }
-         if (hw_stencil) {
-           dw = i915->state.Ctx[I915_CTXREG_LIS5];
-            if (state)
-               dw |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE);
-            else
-               dw &= ~(S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE);
-           if (dw != i915->state.Ctx[I915_CTXREG_LIS5]) {
-              i915->state.Ctx[I915_CTXREG_LIS5] = dw;
-              I915_STATECHANGE(i915, I915_UPLOAD_CTX);
-           }
-         }
-         else {
-            FALLBACK(&i915->intel, I915_FALLBACK_STENCIL, state);
-         }
+      if (!ctx->DrawBuffer || !ctx->DrawBuffer->Visual.stencilBits)
+        state = false;
+
+      dw = i915->state.Ctx[I915_CTXREG_LIS5];
+      if (state)
+        dw |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE);
+      else
+        dw &= ~(S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE);
+      if (dw != i915->state.Ctx[I915_CTXREG_LIS5]) {
+        i915->state.Ctx[I915_CTXREG_LIS5] = dw;
+        I915_STATECHANGE(i915, I915_UPLOAD_CTX);
       }
       break;
 
index 6e45121..e6a4711 100644 (file)
@@ -219,9 +219,9 @@ i915_miptree_layout_2d(struct intel_context *intel,
                                   width, height, 1);
 
       if (mt->compressed)
-        img_height = MAX2(1, height / 4);
+        img_height = ALIGN(height, 4) / 4;
       else
-        img_height = (MAX2(2, height) + 1) & ~1;
+        img_height = ALIGN(height, 2);
 
       mt->total_height += img_height;
 
index bcf42d5..7cd6820 100644 (file)
@@ -82,6 +82,7 @@ translate_texture_format(gl_format mesa_format, GLenum DepthMode)
    case MESA_FORMAT_RGBA_DXT5:
       return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
    case MESA_FORMAT_S8_Z24:
+   case MESA_FORMAT_X8_Z24:
       if (DepthMode == GL_ALPHA)
         return (MAPSURF_32BIT | MT_32BIT_x8A24);
       else if (DepthMode == GL_INTENSITY)
@@ -89,7 +90,8 @@ translate_texture_format(gl_format mesa_format, GLenum DepthMode)
       else
         return (MAPSURF_32BIT | MT_32BIT_x8L24);
    default:
-      fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format);
+      fprintf(stderr, "%s: bad image format %s\n", __FUNCTION__,
+             _mesa_get_format_name(mesa_format));
       abort();
       return 0;
    }
index baff49b..495426a 100644 (file)
 #include "main/imports.h"
 #include "main/macros.h"
 #include "main/colormac.h"
+#include "main/renderbuffer.h"
+#include "main/framebuffer.h"
 
+#include "tnl/tnl.h"
 #include "tnl/t_context.h"
 #include "tnl/t_vertex.h"
+#include "swrast_setup/swrast_setup.h"
 
 #include "intel_batchbuffer.h"
 #include "intel_regions.h"
 #include "intel_tris.h"
 #include "intel_fbo.h"
+#include "intel_buffers.h"
 
 #include "i915_reg.h"
 #include "i915_context.h"
@@ -313,7 +318,8 @@ i915_emit_state(struct intel_context *intel)
 
    aper_array[aper_count++] = intel->batch.bo;
    if (dirty & I915_UPLOAD_BUFFERS) {
-      aper_array[aper_count++] = state->draw_region->buffer;
+      if (state->draw_region)
+        aper_array[aper_count++] = state->draw_region->buffer;
       if (state->depth_region)
         aper_array[aper_count++] = state->depth_region->buffer;
    }
@@ -383,23 +389,27 @@ i915_emit_state(struct intel_context *intel)
       if (INTEL_DEBUG & DEBUG_STATE)
          fprintf(stderr, "I915_UPLOAD_BUFFERS:\n");
 
-      count = 14;
+      count = 17;
       if (state->Buffer[I915_DESTREG_DRAWRECT0] != MI_NOOP)
          count++;
-      if (state->depth_region)
-         count += 3;
 
       BEGIN_BATCH(count);
       OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR0]);
       OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR1]);
-      OUT_RELOC(state->draw_region->buffer,
-               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
+      if (state->draw_region) {
+        OUT_RELOC(state->draw_region->buffer,
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
+      } else {
+        OUT_BATCH(0);
+      }
 
+      OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR0]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR1]);
       if (state->depth_region) {
-         OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR0]);
-         OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR1]);
          OUT_RELOC(state->depth_region->buffer,
                   I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
+      } else {
+        OUT_BATCH(0);
       }
 
       OUT_BATCH(state->Buffer[I915_DESTREG_DV0]);
@@ -527,6 +537,12 @@ i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region,
         if (region->tiling == I915_TILING_Y)
            state[1] |= BUF_3D_TILE_WALK_Y;
       }
+   } else {
+      /* Fill in a default pitch, since 0 is invalid.  We'll be
+       * setting the buffer offset to 0 and not referencing the
+       * buffer, so the pitch could really be any valid value.
+       */
+      state[1] |= BUF_3D_PITCH(4096);
    }
 }
 
@@ -568,11 +584,9 @@ i915_set_draw_region(struct intel_context *intel,
    uint32_t draw_x, draw_y, draw_offset;
 
    if (state->draw_region != color_regions[0]) {
-      intel_region_release(&state->draw_region);
       intel_region_reference(&state->draw_region, color_regions[0]);
    }
    if (state->depth_region != depth_region) {
-      intel_region_release(&state->depth_region);
       intel_region_reference(&state->depth_region, depth_region);
    }
 
@@ -593,6 +607,8 @@ i915_set_draw_region(struct intel_context *intel,
             LOD_PRECLAMP_OGL | TEX_DEFAULT_COLOR_OGL);
    if (irb != NULL) {
       value |= i915_render_target_format_for_mesa_format[irb->Base.Format];
+   } else {
+      value |= DV_PF_8888;
    }
 
    /* This isn't quite safe, thus being hidden behind an option.  When changing
@@ -667,7 +683,142 @@ i915_set_draw_region(struct intel_context *intel,
    I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS);
 }
 
+static void
+i915_update_color_write_enable(struct i915_context *i915, bool enable)
+{
+   uint32_t dw = i915->state.Ctx[I915_CTXREG_LIS6];
+   if (enable)
+      dw |= S6_COLOR_WRITE_ENABLE;
+   else
+      dw &= ~S6_COLOR_WRITE_ENABLE;
+   if (dw != i915->state.Ctx[I915_CTXREG_LIS6]) {
+      I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+      i915->state.Ctx[I915_CTXREG_LIS6] = dw;
+   }
+}
 
+/**
+ * Update the hardware state for drawing into a window or framebuffer object.
+ *
+ * Called by glDrawBuffer, glBindFramebufferEXT, MakeCurrent, and other
+ * places within the driver.
+ *
+ * Basically, this needs to be called any time the current framebuffer
+ * changes, the renderbuffers change, or we need to draw into different
+ * color buffers.
+ */
+static void
+i915_update_draw_buffer(struct intel_context *intel)
+{
+   struct i915_context *i915 = (struct i915_context *)intel;
+   struct gl_context *ctx = &intel->ctx;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   struct intel_region *colorRegion = NULL, *depthRegion = NULL;
+   struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
+   bool fb_has_hiz = intel_framebuffer_has_hiz(fb);
+
+   if (!fb) {
+      /* this can happen during the initial context initialization */
+      return;
+   }
+
+   irbDepth = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+   irbStencil = intel_get_renderbuffer(fb, BUFFER_STENCIL);
+
+   /* Do this here, not core Mesa, since this function is called from
+    * many places within the driver.
+    */
+   if (ctx->NewState & _NEW_BUFFERS) {
+      /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
+      _mesa_update_framebuffer(ctx);
+      /* this updates the DrawBuffer's Width/Height if it's a FBO */
+      _mesa_update_draw_buffer_bounds(ctx);
+   }
+
+   if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      /* this may occur when we're called by glBindFrameBuffer() during
+       * the process of someone setting up renderbuffers, etc.
+       */
+      /*_mesa_debug(ctx, "DrawBuffer: incomplete user FBO\n");*/
+      return;
+   }
+
+   /* How many color buffers are we drawing into?
+    *
+    * If there is more than one drawbuffer (GL_FRONT_AND_BACK), or the
+    * drawbuffers are too big, we have to fallback to software.
+    */
+   if ((fb->Width > ctx->Const.MaxRenderbufferSize)
+       || (fb->Height > ctx->Const.MaxRenderbufferSize)) {
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, true);
+   } else if (fb->_NumColorDrawBuffers > 1) {
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, true);
+   } else {
+      struct intel_renderbuffer *irb;
+      irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
+      colorRegion = irb ? irb->region : NULL;
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, false);
+   }
+
+   /* Check for depth fallback. */
+   if (irbDepth && irbDepth->region) {
+      assert(!fb_has_hiz || irbDepth->Base.Format != MESA_FORMAT_S8_Z24);
+      FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+      depthRegion = irbDepth->region;
+   } else if (irbDepth && !irbDepth->region) {
+      FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_TRUE);
+      depthRegion = NULL;
+   } else { /* !irbDepth */
+      /* No fallback is needed because there is no depth buffer. */
+      FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+      depthRegion = NULL;
+   }
+
+   /* Check for stencil fallback. */
+   if (irbStencil && irbStencil->region) {
+      assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
+      FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+   } else if (irbStencil && !irbStencil->region) {
+      FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_TRUE);
+   } else { /* !irbStencil */
+      /* No fallback is needed because there is no stencil buffer. */
+      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
+       && irbStencil->Base.Format == MESA_FORMAT_S8_Z24) {
+      depthRegion = irbStencil->region;
+   }
+
+   /*
+    * Update depth and stencil test state
+    */
+   ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
+   ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
+
+   i915_update_color_write_enable(i915, colorRegion != NULL);
+
+   intel->vtbl.set_draw_region(intel, &colorRegion, depthRegion,
+                               fb->_NumColorDrawBuffers);
+   intel->NewGLState |= _NEW_BUFFERS;
+
+   /* update viewport since it depends on window size */
+   intelCalcViewport(ctx);
+
+   /* Set state we know depends on drawable parameters:
+    */
+   ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                      ctx->Scissor.Width, ctx->Scissor.Height);
+   ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far);
+
+   /* Update culling direction which changes depending on the
+    * orientation of the buffer:
+    */
+   ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
+}
 
 static void
 i915_new_batch(struct intel_context *intel)
@@ -703,6 +854,16 @@ i915_is_hiz_depth_format(struct intel_context *intel,
    return false;
 }
 
+static void
+i915_invalidate_state(struct intel_context *intel, GLuint new_state)
+{
+   struct gl_context *ctx = &intel->ctx;
+
+   _swsetup_InvalidateState(ctx, new_state);
+   _tnl_InvalidateState(ctx, new_state);
+   _tnl_invalidate_vertex_state(ctx, new_state);
+}
+
 void
 i915InitVtbl(struct i915_context *i915)
 {
@@ -714,9 +875,11 @@ i915InitVtbl(struct i915_context *i915)
    i915->intel.vtbl.render_start = i915_render_start;
    i915->intel.vtbl.render_prevalidate = i915_render_prevalidate;
    i915->intel.vtbl.set_draw_region = i915_set_draw_region;
+   i915->intel.vtbl.update_draw_buffer = i915_update_draw_buffer;
    i915->intel.vtbl.update_texture_state = i915UpdateTextureState;
    i915->intel.vtbl.assert_not_dirty = i915_assert_not_dirty;
    i915->intel.vtbl.finish_batch = intel_finish_vb;
+   i915->intel.vtbl.invalidate_state = i915_invalidate_state;
    i915->intel.vtbl.render_target_supported = i915_render_target_supported;
    i915->intel.vtbl.is_hiz_depth_format = i915_is_hiz_depth_format;
 }
index 7bcb72f..a5eab07 100644 (file)
@@ -484,28 +484,33 @@ intel_atten_point(struct intel_context *intel, intelVertexPtr v0)
  *                Fixup for I915 WPOS texture coordinate                *
  ***********************************************************************/
 
+static void
+intel_emit_fragcoord(struct intel_context *intel, intelVertexPtr v)
+{
+   struct gl_context *ctx = &intel->ctx;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   GLuint offset = intel->wpos_offset;
+   float *vertex_position = (float *)v;
+   float *fragcoord = (float *)((char *)v + offset);
+
+   fragcoord[0] = vertex_position[0];
+
+   if (fb->Name)
+      fragcoord[1] = vertex_position[1];
+   else
+      fragcoord[1] = fb->Height - vertex_position[1];
 
+   fragcoord[2] = vertex_position[2];
+   fragcoord[3] = vertex_position[3];
+}
 
 static void
 intel_wpos_triangle(struct intel_context *intel,
                     intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2)
 {
-   const struct gl_framebuffer *fb = intel->ctx.DrawBuffer;
-   GLuint offset = intel->wpos_offset;
-   GLuint size = intel->wpos_size;
-   GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
-   GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
-   GLfloat *v2_wpos = (GLfloat *)((char *)v2 + offset);
-
-   __memcpy(v0_wpos, v0, size);
-   __memcpy(v1_wpos, v1, size);
-   __memcpy(v2_wpos, v2, size);
-
-   if (!fb->Name) {
-      v0_wpos[1] = -v0_wpos[1] + fb->Height;
-      v1_wpos[1] = -v1_wpos[1] + fb->Height;
-      v2_wpos[1] = -v2_wpos[1] + fb->Height;
-   }
+   intel_emit_fragcoord(intel, v0);
+   intel_emit_fragcoord(intel, v1);
+   intel_emit_fragcoord(intel, v2);
 
    intel_draw_triangle(intel, v0, v1, v2);
 }
@@ -515,20 +520,8 @@ static void
 intel_wpos_line(struct intel_context *intel,
                 intelVertexPtr v0, intelVertexPtr v1)
 {
-   const struct gl_framebuffer *fb = intel->ctx.DrawBuffer;
-   GLuint offset = intel->wpos_offset;
-   GLuint size = intel->wpos_size;
-   GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
-   GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
-
-   __memcpy(v0_wpos, v0, size);
-   __memcpy(v1_wpos, v1, size);
-
-   if (!fb->Name) {
-      v0_wpos[1] = -v0_wpos[1] + fb->Height;
-      v1_wpos[1] = -v1_wpos[1] + fb->Height;
-   }
-
+   intel_emit_fragcoord(intel, v0);
+   intel_emit_fragcoord(intel, v1);
    intel_draw_line(intel, v0, v1);
 }
 
@@ -536,16 +529,7 @@ intel_wpos_line(struct intel_context *intel,
 static void
 intel_wpos_point(struct intel_context *intel, intelVertexPtr v0)
 {
-   const struct gl_framebuffer *fb = intel->ctx.DrawBuffer;
-   GLuint offset = intel->wpos_offset;
-   GLuint size = intel->wpos_size;
-   GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
-
-   __memcpy(v0_wpos, v0, size);
-
-   if (!fb->Name)
-      v0_wpos[1] = -v0_wpos[1] + fb->Height;
-
+   intel_emit_fragcoord(intel, v0);
    intel_draw_point(intel, v0);
 }
 
@@ -1078,6 +1062,13 @@ intelRunPipeline(struct gl_context * ctx)
    if (ctx->NewState)
       _mesa_update_state_locked(ctx);
 
+   /* We need to get this done before we start the pipeline, or a
+    * change in the INTEL_FALLBACK() of its intel_draw_buffers() call
+    * while the pipeline is running will result in mismatched swrast
+    * map/unmaps, and later assertion failures.
+    */
+   intel_prepare_render(intel);
+
    if (intel->NewGLState) {
       if (intel->NewGLState & _NEW_TEXTURE) {
          intel->vtbl.update_texture_state(intel);
@@ -1092,7 +1083,9 @@ intelRunPipeline(struct gl_context * ctx)
    }
 
    intel_map_vertex_shader_textures(ctx);
+   intel->tnl_pipeline_running = true;
    _tnl_run_pipeline(ctx);
+   intel->tnl_pipeline_running = false;
    intel_unmap_vertex_shader_textures(ctx);
 
    _mesa_unlock_context_textures(ctx);
@@ -1228,6 +1221,8 @@ intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode)
    if (mode) {
       intel->Fallback |= bit;
       if (oldfallback == 0) {
+        assert(!intel->tnl_pipeline_running);
+
          intel_flush(ctx);
          if (INTEL_DEBUG & DEBUG_FALLBACKS)
             fprintf(stderr, "ENTER FALLBACK %x: %s\n",
@@ -1239,6 +1234,8 @@ intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode)
    else {
       intel->Fallback &= ~bit;
       if (oldfallback == bit) {
+        assert(!intel->tnl_pipeline_running);
+
          _swrast_flush(ctx);
          if (INTEL_DEBUG & DEBUG_FALLBACKS)
             fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString(bit));
index 94b8c20..9c26150 100644 (file)
@@ -43,7 +43,8 @@ prepare_cc_vp(struct brw_context *brw)
    struct gl_context *ctx = &brw->intel.ctx;
    struct brw_cc_viewport *ccv;
 
-   ccv = brw_state_batch(brw, sizeof(*ccv), 32, &brw->cc.vp_offset);
+   ccv = brw_state_batch(brw, AUB_TRACE_CC_VP_STATE,
+                        sizeof(*ccv), 32, &brw->cc.vp_offset);
 
    /* _NEW_TRANSOFORM */
    if (ctx->Transform.DepthClamp) {
@@ -98,7 +99,8 @@ static void upload_cc_unit(struct brw_context *brw)
    struct gl_context *ctx = &brw->intel.ctx;
    struct brw_cc_unit_state *cc;
 
-   cc = brw_state_batch(brw, sizeof(*cc), 64, &brw->cc.state_offset);
+   cc = brw_state_batch(brw, AUB_TRACE_CC_STATE,
+                       sizeof(*cc), 64, &brw->cc.state_offset);
    memset(cc, 0, sizeof(*cc));
 
    /* _NEW_STENCIL */
index c7d428b..d82206b 100644 (file)
@@ -146,15 +146,12 @@ static void compile_clip_prog( struct brw_context *brw,
       printf("\n");
    }
 
-   /* Upload
-    */
-   drm_intel_bo_unreference(brw->clip.prog_bo);
-   brw->clip.prog_bo = brw_upload_cache(&brw->cache,
-                                       BRW_CLIP_PROG,
-                                       &c.key, sizeof(c.key),
-                                       program, program_size,
-                                       &c.prog_data, sizeof(c.prog_data),
-                                       &brw->clip.prog_data);
+   brw_upload_cache(&brw->cache,
+                   BRW_CLIP_PROG,
+                   &c.key, sizeof(c.key),
+                   program, program_size,
+                   &c.prog_data, sizeof(c.prog_data),
+                   &brw->clip.prog_offset, &brw->clip.prog_data);
    ralloc_free(mem_ctx);
 }
 
@@ -271,12 +268,11 @@ static void upload_clip_prog(struct brw_context *brw)
       }
    }
 
-   drm_intel_bo_unreference(brw->clip.prog_bo);
-   brw->clip.prog_bo = brw_search_cache(&brw->cache, BRW_CLIP_PROG,
-                                       &key, sizeof(key),
-                                       &brw->clip.prog_data);
-   if (brw->clip.prog_bo == NULL)
+   if (!brw_search_cache(&brw->cache, BRW_CLIP_PROG,
+                        &key, sizeof(key),
+                        &brw->clip.prog_offset, &brw->clip.prog_data)) {
       compile_clip_prog( brw, &key );
+   }
 }
 
 
index 6015c8c..31fbadf 100644 (file)
@@ -40,14 +40,19 @@ brw_prepare_clip_unit(struct brw_context *brw)
    struct gl_context *ctx = &intel->ctx;
    struct brw_clip_unit_state *clip;
 
-   clip = brw_state_batch(brw, sizeof(*clip), 32, &brw->clip.state_offset);
+   clip = brw_state_batch(brw, AUB_TRACE_CLIP_STATE,
+                         sizeof(*clip), 32, &brw->clip.state_offset);
    memset(clip, 0, sizeof(*clip));
 
-   /* CACHE_NEW_CLIP_PROG */
+   /* BRW_NEW_PROGRAM_CACHE | CACHE_NEW_CLIP_PROG */
    clip->thread0.grf_reg_count = (ALIGN(brw->clip.prog_data->total_grf, 16) /
                                 16 - 1);
-   /* reloc */
-   clip->thread0.kernel_start_pointer = brw->clip.prog_bo->offset >> 6;
+   clip->thread0.kernel_start_pointer =
+      brw_program_reloc(brw,
+                       brw->clip.state_offset +
+                       offsetof(struct brw_clip_unit_state, thread0),
+                       brw->clip.prog_offset +
+                       (clip->thread0.grf_reg_count << 1)) >> 6;
 
    clip->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
    clip->thread1.single_program_flow = 1;
@@ -110,14 +115,6 @@ brw_prepare_clip_unit(struct brw_context *brw)
    clip->viewport_ymin = -1;
    clip->viewport_ymax = 1;
 
-   /* Emit clip program relocation */
-   assert(brw->clip.prog_bo);
-   drm_intel_bo_emit_reloc(intel->batch.bo,
-                          (brw->clip.state_offset +
-                           offsetof(struct brw_clip_unit_state, thread0)),
-                          brw->clip.prog_bo, clip->thread0.grf_reg_count << 1,
-                          I915_GEM_DOMAIN_INSTRUCTION, 0);
-
    brw->state.dirty.cache |= CACHE_NEW_CLIP_UNIT;
 }
 
@@ -125,6 +122,7 @@ const struct brw_tracked_state brw_clip_unit = {
    .dirty = {
       .mesa  = _NEW_TRANSFORM,
       .brw   = (BRW_NEW_BATCH |
+               BRW_NEW_PROGRAM_CACHE |
                BRW_NEW_CURBE_OFFSETS |
                BRW_NEW_URB_FENCE),
       .cache = CACHE_NEW_CLIP_PROG
index d6a99ab..e00e248 100644 (file)
@@ -40,6 +40,7 @@
 #include "brw_state.h"
 #include "intel_span.h"
 #include "tnl/t_pipeline.h"
+#include "../glsl/ralloc.h"
 
 /***************************************
  * Mesa's Driver Functions
@@ -59,7 +60,7 @@ GLboolean brwCreateContext( int api,
                            void *sharedContextPrivate)
 {
    struct dd_function_table functions;
-   struct brw_context *brw = (struct brw_context *) CALLOC_STRUCT(brw_context);
+   struct brw_context *brw = rzalloc(NULL, struct brw_context);
    struct intel_context *intel = &brw->intel;
    struct gl_context *ctx = &intel->ctx;
    unsigned i;
@@ -165,7 +166,7 @@ GLboolean brwCreateContext( int api,
        ctx->Const.QuadsFollowProvokingVertexConvention = GL_FALSE;
 
    if (intel->is_g4x || intel->gen >= 5) {
-      brw->CMD_VF_STATISTICS = CMD_VF_STATISTICS_GM45;
+      brw->CMD_VF_STATISTICS = GM45_3DSTATE_VF_STATISTICS;
       brw->CMD_PIPELINE_SELECT = CMD_PIPELINE_SELECT_GM45;
       brw->has_surface_tile_offset = GL_TRUE;
       if (intel->gen < 6)
@@ -173,7 +174,7 @@ GLboolean brwCreateContext( int api,
       brw->has_aa_line_parameters = GL_TRUE;
       brw->has_pln = GL_TRUE;
   } else {
-      brw->CMD_VF_STATISTICS = CMD_VF_STATISTICS_965;
+      brw->CMD_VF_STATISTICS = GEN4_3DSTATE_VF_STATISTICS;
       brw->CMD_PIPELINE_SELECT = CMD_PIPELINE_SELECT_965;
    }
 
@@ -240,6 +241,8 @@ GLboolean brwCreateContext( int api,
 
    brw->emit_state_always = 0;
 
+   intel->batch.need_workaround_flush = true;
+
    ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
    ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
 
index 621b6f8..471015c 100644 (file)
@@ -142,7 +142,9 @@ enum brw_state_id {
    BRW_STATE_NR_VS_SURFACES,
    BRW_STATE_INDEX_BUFFER,
    BRW_STATE_VS_CONSTBUF,
-   BRW_STATE_WM_CONSTBUF
+   BRW_STATE_WM_CONSTBUF,
+   BRW_STATE_PROGRAM_CACHE,
+   BRW_STATE_STATE_BASE_ADDRESS,
 };
 
 #define BRW_NEW_URB_FENCE               (1 << BRW_STATE_URB_FENCE)
@@ -172,6 +174,8 @@ enum brw_state_id {
 #define BRW_NEW_INDEX_BUFFER           (1 << BRW_STATE_INDEX_BUFFER)
 #define BRW_NEW_VS_CONSTBUF            (1 << BRW_STATE_VS_CONSTBUF)
 #define BRW_NEW_WM_CONSTBUF            (1 << BRW_STATE_WM_CONSTBUF)
+#define BRW_NEW_PROGRAM_CACHE          (1 << BRW_STATE_PROGRAM_CACHE)
+#define BRW_NEW_STATE_BASE_ADDRESS     (1 << BRW_STATE_STATE_BASE_ADDRESS)
 
 struct brw_state_flags {
    /** State update flags signalled by mesa internals */
@@ -184,6 +188,31 @@ struct brw_state_flags {
    GLuint cache;
 };
 
+enum state_struct_type {
+   AUB_TRACE_VS_STATE =                        1,
+   AUB_TRACE_GS_STATE =                        2,
+   AUB_TRACE_CLIP_STATE =              3,
+   AUB_TRACE_SF_STATE =                        4,
+   AUB_TRACE_WM_STATE =                        5,
+   AUB_TRACE_CC_STATE =                        6,
+   AUB_TRACE_CLIP_VP_STATE =           7,
+   AUB_TRACE_SF_VP_STATE =             8,
+   AUB_TRACE_CC_VP_STATE =             0x9,
+   AUB_TRACE_SAMPLER_STATE =           0xa,
+   AUB_TRACE_KERNEL_INSTRUCTIONS =     0xb,
+   AUB_TRACE_SCRATCH_SPACE =           0xc,
+   AUB_TRACE_SAMPLER_DEFAULT_COLOR =    0xd,
+
+   AUB_TRACE_SCISSOR_STATE =           0x15,
+   AUB_TRACE_BLEND_STATE =             0x16,
+   AUB_TRACE_DEPTH_STENCIL_STATE =     0x17,
+
+   /* Not written to .aub files the same way the structures above are. */
+   AUB_TRACE_NO_TYPE =                 0x100,
+   AUB_TRACE_BINDING_TABLE =           0x101,
+   AUB_TRACE_SURFACE_STATE =           0x102,
+   AUB_TRACE_VS_CONSTANTS =            0x103,
+};
 
 /** Subclass of Mesa vertex program */
 struct brw_vertex_program {
@@ -363,9 +392,11 @@ struct brw_cache_item {
    /** 32-bit hash of the key data */
    GLuint hash;
    GLuint key_size;            /* for variable-sized keys */
+   GLuint aux_size;
    const void *key;
 
-   drm_intel_bo *bo;
+   uint32_t offset;
+   uint32_t size;
 
    struct brw_cache_item *next;
 };   
@@ -376,14 +407,11 @@ struct brw_cache {
    struct brw_context *brw;
 
    struct brw_cache_item **items;
+   drm_intel_bo *bo;
    GLuint size, n_items;
 
-   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.
-    */
-   drm_intel_bo *last_bo[BRW_MAX_CACHE];
+   uint32_t next_offset;
+   bool bo_used_by_gpu;
 };
 
 
@@ -634,8 +662,9 @@ struct brw_context
       struct brw_vs_prog_data *prog_data;
       int8_t *constant_map; /* variable array following prog_data */
 
-      drm_intel_bo *prog_bo;
       drm_intel_bo *const_bo;
+      /** Offset in the program cache to the VS program */
+      uint32_t prog_offset;
       uint32_t state_offset;
 
       /** Binding table of pointers to surf_bo entries */
@@ -651,14 +680,16 @@ struct brw_context
       struct brw_gs_prog_data *prog_data;
 
       GLboolean prog_active;
+      /** Offset in the program cache to the CLIP program pre-gen6 */
+      uint32_t prog_offset;
       uint32_t state_offset;
-      drm_intel_bo *prog_bo;
    } gs;
 
    struct {
       struct brw_clip_prog_data *prog_data;
 
-      drm_intel_bo *prog_bo;
+      /** Offset in the program cache to the CLIP program pre-gen6 */
+      uint32_t prog_offset;
 
       /* Offset in the batch to the CLIP state on pre-gen6. */
       uint32_t state_offset;
@@ -673,7 +704,8 @@ struct brw_context
    struct {
       struct brw_sf_prog_data *prog_data;
 
-      drm_intel_bo *prog_bo;
+      /** Offset in the program cache to the CLIP program pre-gen6 */
+      uint32_t prog_offset;
       uint32_t state_offset;
       uint32_t vp_offset;
    } sf;
@@ -700,12 +732,14 @@ struct brw_context
       GLuint sampler_count;
       uint32_t sampler_offset;
 
+      /** Offset in the program cache to the WM program */
+      uint32_t prog_offset;
+
       /** Binding table of pointers to surf_bo entries */
       uint32_t bind_bo_offset;
       uint32_t surf_offset[BRW_WM_MAX_SURF];
       uint32_t state_offset; /* offset in batchbuffer to pre-gen6 WM state */
 
-      drm_intel_bo *prog_bo;
       drm_intel_bo *const_bo; /* pull constant buffer. */
       /**
        * This is offset in the batch to the push constants on gen6.
@@ -717,9 +751,6 @@ struct brw_context
 
 
    struct {
-      /* gen4 */
-      drm_intel_bo *prog_bo;
-
       uint32_t state_offset;
       uint32_t blend_state_offset;
       uint32_t depth_stencil_state_offset;
@@ -738,6 +769,14 @@ struct brw_context
 
    int num_prepare_atoms, num_emit_atoms;
    struct brw_tracked_state prepare_atoms[64], emit_atoms[64];
+
+   /* If (INTEL_DEBUG & DEBUG_BATCH) */
+   struct {
+      uint32_t offset;
+      uint32_t size;
+      enum state_struct_type type;
+   } *state_batch_list;
+   int state_batch_count;
 };
 
 
@@ -874,6 +913,26 @@ brw_register_blocks(int reg_count)
    return ALIGN(reg_count, 16) / 16 - 1;
 }
 
+static inline uint32_t
+brw_program_reloc(struct brw_context *brw, uint32_t state_offset,
+                 uint32_t prog_offset)
+{
+   struct intel_context *intel = &brw->intel;
+
+   if (intel->gen >= 5) {
+      /* Using state base address. */
+      return prog_offset;
+   }
+
+   drm_intel_bo_emit_reloc(intel->batch.bo,
+                          state_offset,
+                          brw->cache.bo,
+                          prog_offset,
+                          I915_GEM_DOMAIN_INSTRUCTION, 0);
+
+   return brw->cache.bo->offset + prog_offset;
+}
+
 GLboolean brw_do_cubemap_normalize(struct exec_list *instructions);
 
 #endif
index 6d41b1e..0a3027d 100644 (file)
 #define CMD_CONST_BUFFER              0x6002
 
 #define CMD_STATE_BASE_ADDRESS        0x6101
-#define CMD_STATE_INSN_POINTER        0x6102
+#define CMD_STATE_SIP                 0x6102
 #define CMD_PIPELINE_SELECT_965       0x6104
 #define CMD_PIPELINE_SELECT_GM45      0x6904
 
 #define _3DSTATE_SAMPLER_STATE_POINTERS_GS     0x782E /* GEN7+ */
 #define _3DSTATE_SAMPLER_STATE_POINTERS_PS     0x782F /* GEN7+ */
 
-#define CMD_VERTEX_BUFFER             0x7808
+#define _3DSTATE_VERTEX_BUFFERS       0x7808
 # define BRW_VB0_INDEX_SHIFT           27
 # define GEN6_VB0_INDEX_SHIFT          26
 # define BRW_VB0_ACCESS_VERTEXDATA     (0 << 26)
 # define GEN7_VB0_ADDRESS_MODIFYENABLE  (1 << 14)
 # define BRW_VB0_PITCH_SHIFT           0
 
-#define CMD_VERTEX_ELEMENT            0x7809
+#define _3DSTATE_VERTEX_ELEMENTS      0x7809
 # define BRW_VE0_INDEX_SHIFT           27
 # define GEN6_VE0_INDEX_SHIFT          26
 # define BRW_VE0_FORMAT_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 GEN4_3DSTATE_VF_STATISTICS             0x780b
+#define GM45_3DSTATE_VF_STATISTICS             0x680b
 #define _3DSTATE_CC_STATE_POINTERS             0x780e /* GEN6+ */
 #define _3DSTATE_BLEND_STATE_POINTERS          0x7824 /* GEN7+ */
 #define _3DSTATE_DEPTH_STENCIL_STATE_POINTERS  0x7825 /* GEN7+ */
index 6144f0a..bdb5b67 100644 (file)
@@ -177,6 +177,8 @@ static void brw_emit_prim(struct brw_context *brw,
    OUT_BATCH(base_vertex_location);
    ADVANCE_BATCH();
 
+   intel->batch.need_workaround_flush = true;
+
    if (intel->always_flush_cache) {
       intel_batchbuffer_emit_mi_flush(intel);
    }
@@ -434,6 +436,7 @@ void brw_draw_prims( struct gl_context *ctx,
     */
    if (!retval) {
        _swsetup_Wakeup(ctx);
+       _tnl_wakeup(ctx);
       _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
    }
 
index c6e5395..56a46ce 100644 (file)
@@ -278,6 +278,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->intel.ctx;
    struct intel_context *intel = intel_context(ctx);
+   /* CACHE_NEW_VS_PROG */
    GLbitfield vs_inputs = brw->vs.prog_data->inputs_read;
    const unsigned char *ptr = NULL;
    GLuint interleaved = 0, total_size = 0;
@@ -499,6 +500,8 @@ static void brw_prepare_vertices(struct brw_context *brw)
            break;
 
         d = brw->vb.buffers[i].offset - brw->vb.current_buffers[i].offset;
+        if (d < 0)
+           break;
         if (i == 0)
            delta = d / brw->vb.current_buffers[i].stride;
         if (delta * brw->vb.current_buffers[i].stride != d)
@@ -539,7 +542,7 @@ static void brw_emit_vertices(struct brw_context *brw)
     */
    if (brw->vb.nr_enabled == 0) {
       BEGIN_BATCH(3);
-      OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | 1);
+      OUT_BATCH((_3DSTATE_VERTEX_ELEMENTS << 16) | 1);
       if (intel->gen >= 6) {
         OUT_BATCH((0 << GEN6_VE0_INDEX_SHIFT) |
                   GEN6_VE0_VALID |
@@ -564,7 +567,7 @@ static void brw_emit_vertices(struct brw_context *brw)
 
    if (brw->vb.nr_buffers) {
       BEGIN_BATCH(1 + 4*brw->vb.nr_buffers);
-      OUT_BATCH((CMD_VERTEX_BUFFER << 16) | (4*brw->vb.nr_buffers - 1));
+      OUT_BATCH((_3DSTATE_VERTEX_BUFFERS << 16) | (4*brw->vb.nr_buffers - 1));
       for (i = 0; i < brw->vb.nr_buffers; i++) {
         struct brw_vertex_buffer *buffer = &brw->vb.buffers[i];
         uint32_t dw0;
@@ -595,7 +598,7 @@ static void brw_emit_vertices(struct brw_context *brw)
    }
 
    BEGIN_BATCH(1 + brw->vb.nr_enabled * 2);
-   OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | (2*brw->vb.nr_enabled - 1));
+   OUT_BATCH((_3DSTATE_VERTEX_ELEMENTS << 16) | (2*brw->vb.nr_enabled - 1));
    for (i = 0; i < brw->vb.nr_enabled; i++) {
       struct brw_vertex_element *input = brw->vb.enabled[i];
       uint32_t format = get_surface_type(input->glarray->Type,
@@ -646,7 +649,7 @@ const struct brw_tracked_state brw_vertices = {
    .dirty = {
       .mesa = 0,
       .brw = BRW_NEW_BATCH | BRW_NEW_VERTICES,
-      .cache = 0,
+      .cache = CACHE_NEW_VS_PROG,
    },
    .prepare = brw_prepare_vertices,
    .emit = brw_emit_vertices,
index 31f76f8..02041b3 100644 (file)
@@ -463,9 +463,21 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
         } else {
            /* Perspective interpolation case. */
            for (unsigned int k = 0; k < type->vector_elements; k++) {
-              struct brw_reg interp = interp_reg(location, k);
-              emit(FS_OPCODE_LINTERP, attr,
-                   this->delta_x, this->delta_y, fs_reg(interp));
+              /* FINISHME: At some point we probably want to push
+               * this farther by giving similar treatment to the
+               * other potentially constant components of the
+               * attribute, as well as making brw_vs_constval.c
+               * handle varyings other than gl_TexCoord.
+               */
+              if (location >= FRAG_ATTRIB_TEX0 &&
+                  location <= FRAG_ATTRIB_TEX7 &&
+                  k == 3 && !(c->key.proj_attrib_mask & (1 << location))) {
+                 emit(BRW_OPCODE_MOV, attr, fs_reg(1.0f));
+              } else {
+                 struct brw_reg interp = interp_reg(location, k);
+                 emit(FS_OPCODE_LINTERP, attr,
+                      this->delta_x, this->delta_y, fs_reg(interp));
+              }
               attr.reg_offset++;
            }
 
@@ -621,8 +633,8 @@ fs_visitor::assign_curb_setup()
    }
 
    /* Map the offsets in the UNIFORM file to fixed HW regs. */
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       for (unsigned int i = 0; i < 3; i++) {
         if (inst->src[i].file == UNIFORM) {
@@ -684,8 +696,8 @@ fs_visitor::assign_urb_setup()
    /* Offset all the urb_setup[] index by the actual position of the
     * setup regs, now that the location of the constants has been chosen.
     */
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       if (inst->opcode == FS_OPCODE_LINTERP) {
         assert(inst->src[2].file == FIXED_HW_REG);
@@ -739,8 +751,8 @@ fs_visitor::split_virtual_grfs()
       split_grf[this->delta_x.reg] = false;
    }
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       /* Texturing produces 4 contiguous registers, so no splitting. */
       if (inst->is_tex()) {
@@ -763,8 +775,8 @@ fs_visitor::split_virtual_grfs()
       }
    }
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       if (inst->dst.file == GRF &&
          split_grf[inst->dst.reg] &&
@@ -815,8 +827,8 @@ fs_visitor::setup_pull_constants()
    int pull_uniform_base = max_uniform_components;
    int pull_uniform_count = c->prog_data.nr_params - pull_uniform_base;
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       for (int i = 0; i < 3; i++) {
         if (inst->src[i].file != UNIFORM)
@@ -871,8 +883,8 @@ fs_visitor::calculate_live_intervals()
    }
 
    int ip = 0;
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       if (inst->opcode == BRW_OPCODE_DO) {
         if (loop_depth++ == 0)
@@ -945,8 +957,8 @@ fs_visitor::propagate_constants()
 
    calculate_live_intervals();
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       if (inst->opcode != BRW_OPCODE_MOV ||
          inst->predicated ||
@@ -965,11 +977,9 @@ fs_visitor::propagate_constants()
       /* Found a move of a constant to a GRF.  Find anything else using the GRF
        * before it's written, and replace it with the constant if we can.
        */
-      exec_list_iterator scan_iter = iter;
-      scan_iter.next();
-      for (; scan_iter.has_next(); scan_iter.next()) {
-        fs_inst *scan_inst = (fs_inst *)scan_iter.get();
-
+      for (fs_inst *scan_inst = (fs_inst *)inst->next;
+          !scan_inst->is_tail_sentinel();
+          scan_inst = (fs_inst *)scan_inst->next) {
         if (scan_inst->opcode == BRW_OPCODE_DO ||
             scan_inst->opcode == BRW_OPCODE_WHILE ||
             scan_inst->opcode == BRW_OPCODE_ELSE ||
@@ -1046,6 +1056,21 @@ fs_visitor::propagate_constants()
                  progress = true;
               }
               break;
+
+           case FS_OPCODE_RCP:
+              /* The hardware doesn't do math on immediate values
+               * (because why are you doing that, seriously?), but
+               * the correct answer is to just constant fold it
+               * anyway.
+               */
+              assert(i == 0);
+              if (inst->src[0].imm.f != 0.0f) {
+                 scan_inst->opcode = BRW_OPCODE_MOV;
+                 scan_inst->src[0] = inst->src[0];
+                 scan_inst->src[0].imm.f = 1.0f / scan_inst->src[0].imm.f;
+                 progress = true;
+              }
+              break;
            }
         }
 
@@ -1063,6 +1088,47 @@ fs_visitor::propagate_constants()
 
    return progress;
 }
+
+
+/**
+ * Attempts to move immediate constants into the immediate
+ * constant slot of following instructions.
+ *
+ * Immediate constants are a bit tricky -- they have to be in the last
+ * operand slot, you can't do abs/negate on them,
+ */
+
+bool
+fs_visitor::opt_algebraic()
+{
+   bool progress = false;
+
+   calculate_live_intervals();
+
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
+
+      switch (inst->opcode) {
+      case BRW_OPCODE_MUL:
+        if (inst->src[1].file != IMM)
+           continue;
+
+        /* a * 1.0 = a */
+        if (inst->src[1].type == BRW_REGISTER_TYPE_F &&
+            inst->src[1].imm.f == 1.0) {
+           inst->opcode = BRW_OPCODE_MOV;
+           inst->src[1] = reg_undef;
+           progress = true;
+           break;
+        }
+
+        break;
+      }
+   }
+
+   return progress;
+}
+
 /**
  * Must be called after calculate_live_intervales() to remove unused
  * writes to registers -- register allocation will fail otherwise
@@ -1077,8 +1143,8 @@ fs_visitor::dead_code_eliminate()
 
    calculate_live_intervals();
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list_safe(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       if (inst->dst.file == GRF && this->virtual_grf_use[inst->dst.reg] <= pc) {
         inst->remove();
@@ -1101,8 +1167,8 @@ fs_visitor::register_coalesce()
    int if_depth = 0;
    int loop_depth = 0;
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list_safe(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       /* Make sure that we dominate the instructions we're going to
        * scan for interfering with our coalescing, or we won't have
@@ -1130,7 +1196,8 @@ fs_visitor::register_coalesce()
       if (inst->opcode != BRW_OPCODE_MOV ||
          inst->predicated ||
          inst->saturate ||
-         inst->dst.file != GRF || inst->src[0].file != GRF ||
+         inst->dst.file != GRF || (inst->src[0].file != GRF &&
+                                   inst->src[0].file != UNIFORM)||
          inst->dst.type != inst->src[0].type)
         continue;
 
@@ -1141,11 +1208,10 @@ fs_visitor::register_coalesce()
        * program.
        */
       bool interfered = false;
-      exec_list_iterator scan_iter = iter;
-      scan_iter.next();
-      for (; scan_iter.has_next(); scan_iter.next()) {
-        fs_inst *scan_inst = (fs_inst *)scan_iter.get();
 
+      for (fs_inst *scan_inst = (fs_inst *)inst->next;
+          !scan_inst->is_tail_sentinel();
+          scan_inst = (fs_inst *)scan_inst->next) {
         if (scan_inst->dst.file == GRF) {
            if (scan_inst->dst.reg == inst->dst.reg &&
                (scan_inst->dst.reg_offset == inst->dst.reg_offset ||
@@ -1153,7 +1219,8 @@ fs_visitor::register_coalesce()
               interfered = true;
               break;
            }
-           if (scan_inst->dst.reg == inst->src[0].reg &&
+           if (inst->src[0].file == GRF &&
+               scan_inst->dst.reg == inst->src[0].reg &&
                (scan_inst->dst.reg_offset == inst->src[0].reg_offset ||
                 scan_inst->is_tex())) {
               interfered = true;
@@ -1161,10 +1228,13 @@ fs_visitor::register_coalesce()
            }
         }
 
-        /* The gen6 MATH instruction can't handle source modifiers, so avoid
-         * coalescing those for now.  We should do something more specific.
+        /* The gen6 MATH instruction can't handle source modifiers or
+         * unusual register regions, so avoid coalescing those for
+         * now.  We should do something more specific.
          */
-        if (intel->gen >= 6 && scan_inst->is_math() && has_source_modifiers) {
+        if (intel->gen >= 6 &&
+            scan_inst->is_math() &&
+            (has_source_modifiers || inst->src[0].file == UNIFORM)) {
            interfered = true;
            break;
         }
@@ -1176,19 +1246,17 @@ fs_visitor::register_coalesce()
       /* Rewrite the later usage to point at the source of the move to
        * be removed.
        */
-      for (exec_list_iterator scan_iter = iter; scan_iter.has_next();
-          scan_iter.next()) {
-        fs_inst *scan_inst = (fs_inst *)scan_iter.get();
-
+      for (fs_inst *scan_inst = inst;
+          !scan_inst->is_tail_sentinel();
+          scan_inst = (fs_inst *)scan_inst->next) {
         for (int i = 0; i < 3; i++) {
            if (scan_inst->src[i].file == GRF &&
                scan_inst->src[i].reg == inst->dst.reg &&
                scan_inst->src[i].reg_offset == inst->dst.reg_offset) {
-              scan_inst->src[i].reg = inst->src[0].reg;
-              scan_inst->src[i].reg_offset = inst->src[0].reg_offset;
-              scan_inst->src[i].abs |= inst->src[0].abs;
-              scan_inst->src[i].negate ^= inst->src[0].negate;
-              scan_inst->src[i].smear = inst->src[0].smear;
+              fs_reg new_src = inst->src[0];
+              new_src.negate ^= scan_inst->src[i].negate;
+              new_src.abs |= scan_inst->src[i].abs;
+              scan_inst->src[i] = new_src;
            }
         }
       }
@@ -1212,8 +1280,8 @@ fs_visitor::compute_to_mrf()
 
    calculate_live_intervals();
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list_safe(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       int ip = next_ip;
       next_ip++;
@@ -1392,8 +1460,8 @@ fs_visitor::remove_duplicate_mrf_writes()
 
    memset(last_mrf_move, 0, sizeof(last_mrf_move));
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list_safe(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       switch (inst->opcode) {
       case BRW_OPCODE_DO:
@@ -1527,12 +1595,14 @@ fs_visitor::run()
       /* Generate FS IR for main().  (the visitor only descends into
        * functions called "main").
        */
-      foreach_iter(exec_list_iterator, iter, *shader->ir) {
-        ir_instruction *ir = (ir_instruction *)iter.get();
+      foreach_list(node, &*shader->ir) {
+        ir_instruction *ir = (ir_instruction *)node;
         base_ir = ir;
         this->result = reg_undef;
         ir->accept(this);
       }
+      if (failed)
+        return false;
 
       emit_fb_writes();
 
@@ -1548,6 +1618,7 @@ fs_visitor::run()
         progress = remove_duplicate_mrf_writes() || progress;
 
         progress = propagate_constants() || progress;
+        progress = opt_algebraic() || progress;
         progress = register_coalesce() || progress;
         progress = compute_to_mrf() || progress;
         progress = dead_code_eliminate() || progress;
@@ -1684,6 +1755,9 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
    key.clamp_fragment_color = true;
 
    for (int i = 0; i < BRW_MAX_TEX_UNIT; i++) {
+      if (fp->Base.ShadowSamplers & (1 << i))
+        key.compare_funcs[i] = GL_LESS;
+
       /* FINISHME: depth compares might use (0,0,0,W) for example */
       key.tex_swizzles[i] = SWIZZLE_XYZW;
    }
@@ -1697,14 +1771,12 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
 
    key.program_string_id = bfp->id;
 
-   drm_intel_bo *old_prog_bo = brw->wm.prog_bo;
+   uint32_t old_prog_offset = brw->wm.prog_offset;
    struct brw_wm_prog_data *old_prog_data = brw->wm.prog_data;
-   brw->wm.prog_bo = NULL;
 
    bool success = do_wm_prog(brw, prog, bfp, &key);
 
-   drm_intel_bo_unreference(brw->wm.prog_bo);
-   brw->wm.prog_bo = old_prog_bo;
+   brw->wm.prog_offset = old_prog_offset;
    brw->wm.prog_data = old_prog_data;
 
    return success;
index 7570dda..89d6cda 100644 (file)
@@ -441,6 +441,8 @@ public:
    void visit(ir_function *ir);
    void visit(ir_function_signature *ir);
 
+   void swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler);
+
    fs_inst *emit(fs_inst inst);
 
    fs_inst *emit(int opcode)
@@ -483,6 +485,7 @@ public:
    void setup_pull_constants();
    void calculate_live_intervals();
    bool propagate_constants();
+   bool opt_algebraic();
    bool register_coalesce();
    bool compute_to_mrf();
    bool dead_code_eliminate();
index 7f3f528..46677a6 100644 (file)
@@ -191,6 +191,8 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir)
    case ir_unop_log:
    case ir_unop_exp2:
    case ir_unop_log2:
+   case ir_unop_i2u:
+   case ir_unop_u2i:
    case ir_unop_f2i:
    case ir_unop_i2f:
    case ir_unop_f2b:
index 6b7c434..9fb0153 100644 (file)
@@ -59,7 +59,8 @@ fs_visitor::generate_fb_write(fs_inst *inst)
 
         if (inst->target > 0) {
            /* Set the render target index for choosing BLEND_STATE. */
-           brw_MOV(p, retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE, 0, 2),
+           brw_MOV(p, retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE,
+                                          inst->base_mrf, 2),
                              BRW_REGISTER_TYPE_UD),
                    brw_imm_ud(inst->target));
         }
@@ -273,7 +274,8 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
         }
         break;
       case FS_OPCODE_TXD:
-        assert(!"TXD isn't supported on gen5+ yet.");
+        /* There is no sample_d_c message; comparisons are done manually */
+        msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS;
         break;
       }
    } else {
@@ -311,7 +313,9 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
         }
         break;
       case FS_OPCODE_TXD:
-        assert(!"TXD isn't supported on gen4 yet.");
+        /* There is no sample_d_c message; comparisons are done manually */
+        assert(inst->mlen == 7 || inst->mlen == 10);
+        msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS;
         break;
       }
    }
@@ -605,8 +609,8 @@ fs_visitor::generate_code()
             prog->Name, c->dispatch_width);
    }
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
       struct brw_reg src[3], dst;
 
       if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
index f88b131..78daa49 100644 (file)
@@ -75,8 +75,8 @@ fs_visitor::assign_regs_trivial()
    last_grf = hw_reg_mapping[i - 1] + (this->virtual_grf_sizes[i - 1] *
                                       reg_width);
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       assign_reg(hw_reg_mapping, &inst->dst, reg_width);
       assign_reg(hw_reg_mapping, &inst->src[0], reg_width);
@@ -101,7 +101,6 @@ fs_visitor::assign_regs()
     * for reg_width == 2.
     */
    int reg_width = c->dispatch_width / 8;
-   int last_grf = 0;
    int hw_reg_mapping[this->virtual_grf_next + 1];
    int first_assigned_grf = ALIGN(this->first_non_payload_grf, reg_width);
    int base_reg_count = (BRW_MAX_GRF - first_assigned_grf) / reg_width;
@@ -263,6 +262,7 @@ fs_visitor::assign_regs()
     * regs in the register classes back down to real hardware reg
     * numbers.
     */
+   this->grf_used = first_assigned_grf;
    hw_reg_mapping[0] = 0; /* unused */
    for (int i = 1; i < this->virtual_grf_next; i++) {
       int reg = ra_get_node_reg(g, i);
@@ -278,20 +278,19 @@ fs_visitor::assign_regs()
 
       assert(hw_reg >= 0);
       hw_reg_mapping[i] = first_assigned_grf + hw_reg * reg_width;
-      last_grf = MAX2(last_grf,
-                     hw_reg_mapping[i] + this->virtual_grf_sizes[i] - 1);
+      this->grf_used = MAX2(this->grf_used,
+                           hw_reg_mapping[i] + this->virtual_grf_sizes[i] *
+                           reg_width);
    }
 
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       assign_reg(hw_reg_mapping, &inst->dst, reg_width);
       assign_reg(hw_reg_mapping, &inst->src[0], reg_width);
       assign_reg(hw_reg_mapping, &inst->src[1], reg_width);
    }
 
-   this->grf_used = last_grf + reg_width;
-
    ralloc_free(g);
    ralloc_free(regs);
 
@@ -337,8 +336,8 @@ fs_visitor::choose_spill_reg(struct ra_graph *g)
     * spill/unspill we'll have to do, and guess that the insides of
     * loops run 10 times.
     */
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       for (unsigned int i = 0; i < 3; i++) {
         if (inst->src[i].file == GRF) {
@@ -395,8 +394,8 @@ fs_visitor::spill_reg(int spill_reg)
     * virtual grf of the same size.  For most instructions, though, we
     * could just spill/unspill the GRF being accessed.
     */
-   foreach_iter(exec_list_iterator, iter, this->instructions) {
-      fs_inst *inst = (fs_inst *)iter.get();
+   foreach_list(node, &this->instructions) {
+      fs_inst *inst = (fs_inst *)node;
 
       for (unsigned int i = 0; i < 3; i++) {
         if (inst->src[i].file == GRF &&
index d8218c2..9ec3f50 100644 (file)
@@ -283,8 +283,8 @@ instruction_scheduler::calculate_deps()
    memset(last_mrf_write, 0, sizeof(last_mrf_write));
 
    /* top-to-bottom dependencies: RAW and WAW. */
-   foreach_iter(exec_list_iterator, iter, instructions) {
-      schedule_node *n = (schedule_node *)iter.get();
+   foreach_list(node, &instructions) {
+      schedule_node *n = (schedule_node *)node;
       fs_inst *inst = n->inst;
 
       /* read-after-write deps. */
@@ -437,8 +437,8 @@ instruction_scheduler::schedule_instructions(fs_inst *next_block_header)
    int time = 0;
 
    /* Remove non-DAG heads from the list. */
-   foreach_iter(exec_list_iterator, iter, instructions) {
-      schedule_node *n = (schedule_node *)iter.get();
+   foreach_list_safe(node, &instructions) {
+      schedule_node *n = (schedule_node *)node;
       if (n->parent_count != 0)
         n->remove();
    }
@@ -447,8 +447,8 @@ instruction_scheduler::schedule_instructions(fs_inst *next_block_header)
       schedule_node *chosen = NULL;
       int chosen_time = 0;
 
-      foreach_iter(exec_list_iterator, iter, instructions) {
-        schedule_node *n = (schedule_node *)iter.get();
+      foreach_list(node, &instructions) {
+        schedule_node *n = (schedule_node *)node;
 
         if (!chosen || n->unblocked_time < chosen_time) {
            chosen = n;
@@ -490,8 +490,8 @@ instruction_scheduler::schedule_instructions(fs_inst *next_block_header)
        * progress until the first is done.
        */
       if (chosen->inst->is_math()) {
-        foreach_iter(exec_list_iterator, iter, instructions) {
-           schedule_node *n = (schedule_node *)iter.get();
+        foreach_list(node, &instructions) {
+           schedule_node *n = (schedule_node *)node;
 
            if (n->inst->is_math())
               n->unblocked_time = MAX2(n->unblocked_time,
index 530ffa2..a9a60c2 100644 (file)
@@ -122,8 +122,8 @@ ir_vector_reference_visitor::get_variable_entry(ir_variable *var)
       break;
    }
 
-   foreach_iter(exec_list_iterator, iter, this->variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+   foreach_list(node, &this->variable_list) {
+      variable_entry *entry = (variable_entry *)node;
       if (entry->var == var)
         return entry;
    }
@@ -222,8 +222,8 @@ ir_vector_splitting_visitor::get_splitting_entry(ir_variable *var)
    if (!var->type->is_vector())
       return NULL;
 
-   foreach_iter(exec_list_iterator, iter, *this->variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+   foreach_list(node, &*this->variable_list) {
+      variable_entry *entry = (variable_entry *)node;
       if (entry->var == var) {
         return entry;
       }
@@ -341,8 +341,8 @@ brw_do_vector_splitting(exec_list *instructions)
    visit_list_elements(&refs, instructions);
 
    /* Trim out variables we can't split. */
-   foreach_iter(exec_list_iterator, iter, refs.variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+   foreach_list_safe(node, &refs.variable_list) {
+      variable_entry *entry = (variable_entry *)node;
 
       if (debug) {
         printf("vector %s@%p: decl %d, whole_access %d\n",
@@ -363,8 +363,8 @@ brw_do_vector_splitting(exec_list *instructions)
    /* Replace the decls of the vectors to be split with their split
     * components.
     */
-   foreach_iter(exec_list_iterator, iter, refs.variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+   foreach_list(node, &refs.variable_list) {
+      variable_entry *entry = (variable_entry *)node;
       const struct glsl_type *type;
       type = glsl_type::get_instance(entry->var->type->base_type, 1, 1);
 
index b485787..2b769cc 100644 (file)
@@ -349,6 +349,14 @@ fs_visitor::visit(ir_expression *ir)
       emit_math(FS_OPCODE_RSQ, this->result, op[0]);
       break;
 
+   case ir_unop_i2u:
+      op[0].type = BRW_REGISTER_TYPE_UD;
+      this->result = op[0];
+      break;
+   case ir_unop_u2i:
+      op[0].type = BRW_REGISTER_TYPE_D;
+      this->result = op[0];
+      break;
    case ir_unop_i2f:
    case ir_unop_b2f:
    case ir_unop_b2i:
@@ -549,7 +557,7 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate,
    /* g0 header. */
    mlen = 1;
 
-   if (ir->shadow_comparitor) {
+   if (ir->shadow_comparitor && ir->op != ir_txd) {
       for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
         fs_inst *inst = emit(BRW_OPCODE_MOV,
                              fs_reg(MRF, base_mrf + mlen + i), coordinate);
@@ -595,7 +603,46 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate,
       /* gen4's SIMD8 sampler always has the slots for u,v,r present. */
       mlen += 3;
    } else if (ir->op == ir_txd) {
-      assert(!"TXD isn't supported on gen4 yet.");
+      this->result = reg_undef;
+      ir->lod_info.grad.dPdx->accept(this);
+      fs_reg dPdx = this->result;
+
+      this->result = reg_undef;
+      ir->lod_info.grad.dPdy->accept(this);
+      fs_reg dPdy = this->result;
+
+      for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i), coordinate);
+        coordinate.reg_offset++;
+      }
+      /* the slots for u and v are always present, but r is optional */
+      mlen += MAX2(ir->coordinate->type->vector_elements, 2);
+
+      /*  P   = u, v, r
+       * dPdx = dudx, dvdx, drdx
+       * dPdy = dudy, dvdy, drdy
+       *
+       * 1-arg: Does not exist.
+       *
+       * 2-arg: dudx   dvdx   dudy   dvdy
+       *        dPdx.x dPdx.y dPdy.x dPdy.y
+       *        m4     m5     m6     m7
+       *
+       * 3-arg: dudx   dvdx   drdx   dudy   dvdy   drdy
+       *        dPdx.x dPdx.y dPdx.z dPdy.x dPdy.y dPdy.z
+       *        m5     m6     m7     m8     m9     m10
+       */
+      for (int i = 0; i < ir->lod_info.grad.dPdx->type->vector_elements; i++) {
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), dPdx);
+        dPdx.reg_offset++;
+      }
+      mlen += MAX2(ir->lod_info.grad.dPdx->type->vector_elements, 2);
+
+      for (int i = 0; i < ir->lod_info.grad.dPdy->type->vector_elements; i++) {
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), dPdy);
+        dPdy.reg_offset++;
+      }
+      mlen += MAX2(ir->lod_info.grad.dPdy->type->vector_elements, 2);
    } else {
       /* Oh joy.  gen4 doesn't have SIMD8 non-shadow-compare bias/lod
        * instructions.  We'll need to do SIMD16 here.
@@ -709,7 +756,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
    }
    mlen += ir->coordinate->type->vector_elements * reg_width;
 
-   if (ir->shadow_comparitor) {
+   if (ir->shadow_comparitor && ir->op != ir_txd) {
       mlen = MAX2(mlen, header_present + 4 * reg_width);
 
       this->result = reg_undef;
@@ -742,7 +789,39 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
 
       inst = emit(FS_OPCODE_TXL, dst);
       break;
-   case ir_txd:
+   case ir_txd: {
+      this->result = reg_undef;
+      ir->lod_info.grad.dPdx->accept(this);
+      fs_reg dPdx = this->result;
+
+      this->result = reg_undef;
+      ir->lod_info.grad.dPdy->accept(this);
+      fs_reg dPdy = this->result;
+
+      mlen = MAX2(mlen, header_present + 4 * reg_width); /* skip over 'ai' */
+
+      /**
+       *  P   =  u,    v,    r
+       * dPdx = dudx, dvdx, drdx
+       * dPdy = dudy, dvdy, drdy
+       *
+       * Load up these values:
+       * - dudx   dudy   dvdx   dvdy   drdx   drdy
+       * - dPdx.x dPdy.x dPdx.y dPdy.y dPdx.z dPdy.z
+       */
+      for (int i = 0; i < ir->lod_info.grad.dPdx->type->vector_elements; i++) {
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), dPdx);
+        dPdx.reg_offset++;
+        mlen += reg_width;
+
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), dPdy);
+        dPdy.reg_offset++;
+        mlen += reg_width;
+      }
+
+      inst = emit(FS_OPCODE_TXD, dst);
+      break;
+   }
    case ir_txf:
       assert(!"GLSL 1.30 features unsupported");
       break;
@@ -776,7 +855,8 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
       base_mrf--;
    }
 
-   if (ir->shadow_comparitor) {
+   if (ir->shadow_comparitor && ir->op != ir_txd) {
+      this->result = reg_undef;
       ir->shadow_comparitor->accept(this);
       emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result);
       mlen += reg_width;
@@ -787,29 +867,65 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
    case ir_tex:
       break;
    case ir_txb:
+      this->result = reg_undef;
       ir->lod_info.bias->accept(this);
       emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result);
       mlen += reg_width;
       break;
    case ir_txl:
+      this->result = reg_undef;
       ir->lod_info.lod->accept(this);
       emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result);
       mlen += reg_width;
       break;
-   case ir_txd:
+   case ir_txd: {
+      if (c->dispatch_width == 16)
+        fail("Gen7 does not support sample_d/sample_d_c in SIMD16 mode.");
+
+      this->result = reg_undef;
+      ir->lod_info.grad.dPdx->accept(this);
+      fs_reg dPdx = this->result;
+
+      this->result = reg_undef;
+      ir->lod_info.grad.dPdy->accept(this);
+      fs_reg dPdy = this->result;
+
+      /* Load dPdx and the coordinate together:
+       * [hdr], [ref], x, dPdx.x, dPdy.x, y, dPdx.y, dPdy.y, z, dPdx.z, dPdy.z
+       */
+      for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+        fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
+                             coordinate);
+        if (i < 3 && c->key.gl_clamp_mask[i] & (1 << sampler))
+           inst->saturate = true;
+        coordinate.reg_offset++;
+        mlen += reg_width;
+
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), dPdx);
+        dPdx.reg_offset++;
+        mlen += reg_width;
+
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), dPdy);
+        dPdy.reg_offset++;
+        mlen += reg_width;
+      }
+      break;
+   }
    case ir_txf:
       assert(!"GLSL 1.30 features unsupported");
       break;
    }
 
-   /* Set up the coordinate */
-   for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
-      fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
-                          coordinate);
-      if (i < 3 && c->key.gl_clamp_mask[i] & (1 << sampler))
-        inst->saturate = true;
-      coordinate.reg_offset++;
-      mlen += reg_width;
+   /* Set up the coordinate (except for TXD where it was done earlier) */
+   if (ir->op != ir_txd) {
+      for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+        fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
+                             coordinate);
+        if (i < 3 && c->key.gl_clamp_mask[i] & (1 << sampler))
+           inst->saturate = true;
+        coordinate.reg_offset++;
+        mlen += reg_width;
+      }
    }
 
    /* Generate the SEND */
@@ -835,9 +951,24 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
 void
 fs_visitor::visit(ir_texture *ir)
 {
-   int sampler;
    fs_inst *inst = NULL;
 
+   int sampler = _mesa_get_sampler_uniform_value(ir->sampler, prog, &fp->Base);
+   sampler = fp->Base.SamplerUnits[sampler];
+
+   /* Our hardware doesn't have a sample_d_c message, so shadow compares
+    * for textureGrad/TXD need to be emulated with instructions.
+    */
+   bool hw_compare_supported = ir->op != ir_txd;
+   if (ir->shadow_comparitor && !hw_compare_supported) {
+      assert(c->key.compare_funcs[sampler] != GL_NONE);
+      /* No need to even sample for GL_ALWAYS or GL_NEVER...bail early */
+      if (c->key.compare_funcs[sampler] == GL_ALWAYS)
+        return swizzle_result(ir, fs_reg(1.0f), sampler);
+      else if (c->key.compare_funcs[sampler] == GL_NEVER)
+        return swizzle_result(ir, fs_reg(0.0f), sampler);
+   }
+
    this->result = reg_undef;
    ir->coordinate->accept(this);
    fs_reg coordinate = this->result;
@@ -876,11 +1007,6 @@ fs_visitor::visit(ir_texture *ir)
    /* Should be lowered by do_lower_texture_projection */
    assert(!ir->projector);
 
-   sampler = _mesa_get_sampler_uniform_value(ir->sampler,
-                                            prog,
-                                            &fp->Base);
-   sampler = fp->Base.SamplerUnits[sampler];
-
    /* The 965 requires the EU to do the normalization of GL rectangle
     * texture coordinates.  We use the program parameter state
     * tracking to get the scaling factor.
@@ -951,20 +1077,70 @@ fs_visitor::visit(ir_texture *ir)
 
    inst->sampler = sampler;
 
-   this->result = dst;
+   if (ir->shadow_comparitor) {
+      if (hw_compare_supported) {
+        inst->shadow_compare = true;
+      } else {
+        this->result = reg_undef;
+        ir->shadow_comparitor->accept(this);
+        fs_reg ref = this->result;
+
+        fs_reg value = dst;
+        dst = fs_reg(this, glsl_type::vec4_type);
+
+        /* FINISHME: This needs to be done pre-filtering. */
+
+        uint32_t conditional = 0;
+        switch (c->key.compare_funcs[sampler]) {
+        /* GL_ALWAYS and GL_NEVER were handled at the top of the function */
+        case GL_LESS:     conditional = BRW_CONDITIONAL_L;   break;
+        case GL_GREATER:  conditional = BRW_CONDITIONAL_G;   break;
+        case GL_LEQUAL:   conditional = BRW_CONDITIONAL_LE;  break;
+        case GL_GEQUAL:   conditional = BRW_CONDITIONAL_GE;  break;
+        case GL_EQUAL:    conditional = BRW_CONDITIONAL_EQ;  break;
+        case GL_NOTEQUAL: conditional = BRW_CONDITIONAL_NEQ; break;
+        default: assert(!"Should not get here: bad shadow compare function");
+        }
+
+        /* Use conditional moves to load 0 or 1 as the result */
+        this->current_annotation = "manual shadow comparison";
+        for (int i = 0; i < 4; i++) {
+           inst = emit(BRW_OPCODE_MOV, dst, fs_reg(0.0f));
+
+           inst = emit(BRW_OPCODE_CMP, reg_null_f, ref, value);
+           inst->conditional_mod = conditional;
 
-   if (ir->shadow_comparitor)
-      inst->shadow_compare = true;
+           inst = emit(BRW_OPCODE_MOV, dst, fs_reg(1.0f));
+           inst->predicated = true;
+
+           dst.reg_offset++;
+           value.reg_offset++;
+        }
+        dst.reg_offset = 0;
+      }
+   }
+
+   swizzle_result(ir, dst, sampler);
+}
+
+/**
+ * Swizzle the result of a texture result.  This is necessary for
+ * EXT_texture_swizzle as well as DEPTH_TEXTURE_MODE for shadow comparisons.
+ */
+void
+fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler)
+{
+   this->result = orig_val;
 
    if (ir->type == glsl_type::float_type) {
       /* Ignore DEPTH_TEXTURE_MODE swizzling. */
       assert(ir->sampler->type->sampler_shadow);
-   } else if (c->key.tex_swizzles[inst->sampler] != SWIZZLE_NOOP) {
-      fs_reg swizzle_dst = fs_reg(this, glsl_type::vec4_type);
+   } else if (c->key.tex_swizzles[sampler] != SWIZZLE_NOOP) {
+      fs_reg swizzled_result = fs_reg(this, glsl_type::vec4_type);
 
       for (int i = 0; i < 4; i++) {
-        int swiz = GET_SWZ(c->key.tex_swizzles[inst->sampler], i);
-        fs_reg l = swizzle_dst;
+        int swiz = GET_SWZ(c->key.tex_swizzles[sampler], i);
+        fs_reg l = swizzled_result;
         l.reg_offset += i;
 
         if (swiz == SWIZZLE_ZERO) {
@@ -972,12 +1148,12 @@ fs_visitor::visit(ir_texture *ir)
         } else if (swiz == SWIZZLE_ONE) {
            emit(BRW_OPCODE_MOV, l, fs_reg(1.0f));
         } else {
-           fs_reg r = dst;
-           r.reg_offset += GET_SWZ(c->key.tex_swizzles[inst->sampler], i);
+           fs_reg r = orig_val;
+           r.reg_offset += GET_SWZ(c->key.tex_swizzles[sampler], i);
            emit(BRW_OPCODE_MOV, l, r);
         }
       }
-      this->result = swizzle_dst;
+      this->result = swizzled_result;
    }
 }
 
@@ -1301,8 +1477,8 @@ fs_visitor::visit(ir_if *ir)
       inst->predicated = true;
    }
 
-   foreach_iter(exec_list_iterator, iter, ir->then_instructions) {
-      ir_instruction *ir = (ir_instruction *)iter.get();
+   foreach_list(node, &ir->then_instructions) {
+      ir_instruction *ir = (ir_instruction *)node;
       this->base_ir = ir;
       this->result = reg_undef;
       ir->accept(this);
@@ -1311,8 +1487,8 @@ fs_visitor::visit(ir_if *ir)
    if (!ir->else_instructions.is_empty()) {
       emit(BRW_OPCODE_ELSE);
 
-      foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
-        ir_instruction *ir = (ir_instruction *)iter.get();
+      foreach_list(node, &ir->else_instructions) {
+        ir_instruction *ir = (ir_instruction *)node;
         this->base_ir = ir;
         this->result = reg_undef;
         ir->accept(this);
@@ -1362,8 +1538,8 @@ fs_visitor::visit(ir_loop *ir)
       inst->predicated = true;
    }
 
-   foreach_iter(exec_list_iterator, iter, ir->body_instructions) {
-      ir_instruction *ir = (ir_instruction *)iter.get();
+   foreach_list(node, &ir->body_instructions) {
+      ir_instruction *ir = (ir_instruction *)node;
 
       this->base_ir = ir;
       this->result = reg_undef;
@@ -1419,8 +1595,8 @@ fs_visitor::visit(ir_function *ir)
 
       assert(sig);
 
-      foreach_iter(exec_list_iterator, iter, sig->body) {
-        ir_instruction *ir = (ir_instruction *)iter.get();
+      foreach_list(node, &sig->body) {
+        ir_instruction *ir = (ir_instruction *)node;
         this->base_ir = ir;
         this->result = reg_undef;
         ir->accept(this);
@@ -1466,7 +1642,7 @@ fs_visitor::emit_dummy_fs()
 
    fs_inst *write;
    write = emit(FS_OPCODE_FB_WRITE, fs_reg(0), fs_reg(0));
-   write->base_mrf = 0;
+   write->base_mrf = 2;
 }
 
 /* The register location here is relative to the start of the URB
@@ -1569,6 +1745,7 @@ void
 fs_visitor::emit_color_write(int index, int first_color_mrf, fs_reg color)
 {
    int reg_width = c->dispatch_width / 8;
+   fs_inst *inst;
 
    if (c->dispatch_width == 8 || intel->gen == 6) {
       /* SIMD8 write looks like:
@@ -1587,8 +1764,10 @@ fs_visitor::emit_color_write(int index, int first_color_mrf, fs_reg color)
        * m + 6: a0
        * m + 7: a1
        */
-      emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index * reg_width),
-          color);
+      inst = emit(BRW_OPCODE_MOV,
+                 fs_reg(MRF, first_color_mrf + index * reg_width),
+                 color);
+      inst->saturate = c->key.clamp_fragment_color;
    } else {
       /* pre-gen6 SIMD16 single source DP write looks like:
        * m + 0: r0
@@ -1606,16 +1785,22 @@ fs_visitor::emit_color_write(int index, int first_color_mrf, fs_reg color)
          * usual destination + 1 for the second half we get
          * destination + 4.
          */
-        emit(BRW_OPCODE_MOV,
-             fs_reg(MRF, BRW_MRF_COMPR4 + first_color_mrf + index), color);
+        inst = emit(BRW_OPCODE_MOV,
+                    fs_reg(MRF, BRW_MRF_COMPR4 + first_color_mrf + index),
+                    color);
+        inst->saturate = c->key.clamp_fragment_color;
       } else {
         push_force_uncompressed();
-        emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index), color);
+        inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index),
+                    color);
+        inst->saturate = c->key.clamp_fragment_color;
         pop_force_uncompressed();
 
         push_force_sechalf();
         color.sechalf = true;
-        emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index + 4), color);
+        inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, first_color_mrf + index + 4),
+                    color);
+        inst->saturate = c->key.clamp_fragment_color;
         pop_force_sechalf();
         color.sechalf = false;
       }
@@ -1627,7 +1812,8 @@ fs_visitor::emit_fb_writes()
 {
    this->current_annotation = "FB write header";
    GLboolean header_present = GL_TRUE;
-   int nr = 0;
+   int base_mrf = 2;
+   int nr = base_mrf;
    int reg_width = c->dispatch_width / 8;
 
    if (intel->gen >= 6 &&
@@ -1637,7 +1823,7 @@ fs_visitor::emit_fb_writes()
    }
 
    if (header_present) {
-      /* m0, m1 header */
+      /* m2, m3 header */
       nr += 2;
    }
 
@@ -1706,8 +1892,8 @@ fs_visitor::emit_fb_writes()
 
       fs_inst *inst = emit(FS_OPCODE_FB_WRITE);
       inst->target = target;
-      inst->base_mrf = 0;
-      inst->mlen = nr;
+      inst->base_mrf = base_mrf;
+      inst->mlen = nr - base_mrf;
       if (target == c->key.nr_color_regions - 1)
         inst->eot = true;
       inst->header_present = header_present;
@@ -1724,8 +1910,8 @@ fs_visitor::emit_fb_writes()
       }
 
       fs_inst *inst = emit(FS_OPCODE_FB_WRITE);
-      inst->base_mrf = 0;
-      inst->mlen = nr;
+      inst->base_mrf = base_mrf;
+      inst->mlen = nr - base_mrf;
       inst->eot = true;
       inst->header_present = header_present;
    }
index 001cd62..3171e97 100644 (file)
@@ -121,14 +121,11 @@ static void compile_gs_prog( struct brw_context *brw,
       printf("\n");
     }
 
-   /* Upload
-    */
-   drm_intel_bo_unreference(brw->gs.prog_bo);
-   brw->gs.prog_bo = brw_upload_cache(&brw->cache, BRW_GS_PROG,
-                                     &c.key, sizeof(c.key),
-                                     program, program_size,
-                                     &c.prog_data, sizeof(c.prog_data),
-                                     &brw->gs.prog_data);
+   brw_upload_cache(&brw->cache, BRW_GS_PROG,
+                   &c.key, sizeof(c.key),
+                   program, program_size,
+                   &c.prog_data, sizeof(c.prog_data),
+                   &brw->gs.prog_offset, &brw->gs.prog_data);
    ralloc_free(mem_ctx);
 }
 
@@ -189,15 +186,12 @@ static void prepare_gs_prog(struct brw_context *brw)
       brw->gs.prog_active = key.need_gs_prog;
    }
 
-   drm_intel_bo_unreference(brw->gs.prog_bo);
-   brw->gs.prog_bo = NULL;
-
    if (brw->gs.prog_active) {
-      brw->gs.prog_bo = brw_search_cache(&brw->cache, BRW_GS_PROG,
-                                        &key, sizeof(key),
-                                        &brw->gs.prog_data);
-      if (brw->gs.prog_bo == NULL)
+      if (!brw_search_cache(&brw->cache, BRW_GS_PROG,
+                           &key, sizeof(key),
+                           &brw->gs.prog_offset, &brw->gs.prog_data)) {
         compile_gs_prog( brw, &key );
+      }
    }
 }
 
index 542874b..e0309e7 100644 (file)
@@ -41,16 +41,22 @@ brw_prepare_gs_unit(struct brw_context *brw)
    struct intel_context *intel = &brw->intel;
    struct brw_gs_unit_state *gs;
 
-   gs = brw_state_batch(brw, sizeof(*gs), 32, &brw->gs.state_offset);
+   gs = brw_state_batch(brw, AUB_TRACE_GS_STATE,
+                       sizeof(*gs), 32, &brw->gs.state_offset);
 
    memset(gs, 0, sizeof(*gs));
 
-   /* CACHE_NEW_GS_PROG */
+   /* BRW_NEW_PROGRAM_CACHE | CACHE_NEW_GS_PROG */
    if (brw->gs.prog_active) {
       gs->thread0.grf_reg_count = (ALIGN(brw->gs.prog_data->total_grf, 16) /
                                   16 - 1);
-      /* reloc */
-      gs->thread0.kernel_start_pointer = brw->gs.prog_bo->offset >> 6;
+
+      gs->thread0.kernel_start_pointer =
+        brw_program_reloc(brw,
+                          brw->gs.state_offset +
+                          offsetof(struct brw_gs_unit_state, thread0),
+                          brw->gs.prog_offset +
+                          (gs->thread0.grf_reg_count << 1)) >> 6;
 
       gs->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
       gs->thread1.single_program_flow = 1;
@@ -69,13 +75,6 @@ brw_prepare_gs_unit(struct brw_context *brw)
         gs->thread4.max_threads = 1;
       else
         gs->thread4.max_threads = 0;
-
-      /* Emit GS program relocation */
-      drm_intel_bo_emit_reloc(intel->batch.bo,
-                             (brw->gs.state_offset +
-                              offsetof(struct brw_gs_unit_state, thread0)),
-                             brw->gs.prog_bo, gs->thread0.grf_reg_count << 1,
-                             I915_GEM_DOMAIN_INSTRUCTION, 0);
    }
 
    if (intel->gen == 5)
@@ -91,6 +90,7 @@ const struct brw_tracked_state brw_gs_unit = {
    .dirty = {
       .mesa  = 0,
       .brw   = (BRW_NEW_BATCH |
+               BRW_NEW_PROGRAM_CACHE |
                BRW_NEW_CURBE_OFFSETS |
                BRW_NEW_URB_FENCE),
       .cache = CACHE_NEW_GS_PROG
index 2b5ec8a..f7e6e7c 100644 (file)
@@ -46,7 +46,7 @@ static void upload_drawing_rect(struct brw_context *brw)
    struct gl_context *ctx = &intel->ctx;
 
    BEGIN_BATCH(4);
-   OUT_BATCH(_3DSTATE_DRAWRECT_INFO_I965);
+   OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2));
    OUT_BATCH(0); /* xmin, ymin */
    OUT_BATCH(((ctx->DrawBuffer->Width - 1) & 0xffff) |
            ((ctx->DrawBuffer->Height - 1) << 16));
@@ -87,10 +87,11 @@ static void upload_binding_table_pointers(struct brw_context *brw)
 const struct brw_tracked_state brw_binding_table_pointers = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_BATCH
-          | BRW_NEW_VS_BINDING_TABLE
-          | BRW_NEW_GS_BINDING_TABLE
-          | BRW_NEW_PS_BINDING_TABLE,
+      .brw = (BRW_NEW_BATCH |
+             BRW_NEW_STATE_BASE_ADDRESS |
+             BRW_NEW_VS_BINDING_TABLE |
+             BRW_NEW_GS_BINDING_TABLE |
+             BRW_NEW_PS_BINDING_TABLE),
       .cache = 0,
    },
    .emit = upload_binding_table_pointers,
@@ -122,10 +123,11 @@ static void upload_gen6_binding_table_pointers(struct brw_context *brw)
 const struct brw_tracked_state gen6_binding_table_pointers = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_BATCH
-          | BRW_NEW_VS_BINDING_TABLE
-          | BRW_NEW_GS_BINDING_TABLE
-          | BRW_NEW_PS_BINDING_TABLE,
+      .brw = (BRW_NEW_BATCH |
+             BRW_NEW_STATE_BASE_ADDRESS |
+             BRW_NEW_VS_BINDING_TABLE |
+             BRW_NEW_GS_BINDING_TABLE |
+             BRW_NEW_PS_BINDING_TABLE),
       .cache = 0,
    },
    .emit = upload_gen6_binding_table_pointers,
@@ -180,7 +182,9 @@ static void upload_psp_urb_cbs(struct brw_context *brw )
 const struct brw_tracked_state brw_psp_urb_cbs = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_URB_FENCE | BRW_NEW_BATCH,
+      .brw = (BRW_NEW_URB_FENCE |
+             BRW_NEW_BATCH |
+             BRW_NEW_STATE_BASE_ADDRESS),
       .cache = (CACHE_NEW_VS_UNIT | 
                CACHE_NEW_GS_UNIT | 
                CACHE_NEW_GS_PROG | 
@@ -219,6 +223,12 @@ static void emit_depthbuffer(struct brw_context *brw)
    struct intel_region *hiz_region = depth_irb ? depth_irb->hiz_region : NULL;
    unsigned int len;
 
+   /* 3DSTATE_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER are both
+    * non-pipelined state that will need the PIPE_CONTROL workaround.
+    */
+   if (intel->gen == 6)
+      intel_emit_post_sync_nonzero_flush(intel);
+
    /*
     * If either depth or stencil buffer has packed depth/stencil format,
     * then don't use separate stencil. Emit only a depth buffer.
@@ -355,26 +365,48 @@ static void emit_depthbuffer(struct brw_context *brw)
       ADVANCE_BATCH();
    }
 
-   /* Emit hiz buffer. */
    if (hiz_region || stencil_irb) {
-      BEGIN_BATCH(3);
-      OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));
-      OUT_BATCH(hiz_region->pitch * hiz_region->cpp - 1);
-      OUT_RELOC(hiz_region->buffer,
-               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-               0);
-      ADVANCE_BATCH();
-   }
+      /*
+       * In the 3DSTATE_DEPTH_BUFFER batch emitted above, the 'separate
+       * stencil enable' and 'hiz enable' bits were set. Therefore we must
+       * emit 3DSTATE_HIER_DEPTH_BUFFER and 3DSTATE_STENCIL_BUFFER. Even if
+       * there is no stencil buffer, 3DSTATE_STENCIL_BUFFER must be emitted;
+       * failure to do so causes hangs on gen5 and a stall on gen6.
+       */
 
-   /* Emit stencil buffer. */
-   if (hiz_region || stencil_irb) {
-      BEGIN_BATCH(3);
-      OUT_BATCH((_3DSTATE_STENCIL_BUFFER << 16) | (3 - 2));
-      OUT_BATCH(stencil_irb->region->pitch * stencil_irb->region->cpp - 1);
-      OUT_RELOC(stencil_irb->region->buffer,
-               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-               0);
-      ADVANCE_BATCH();
+      /* Emit hiz buffer. */
+      if (hiz_region) {
+        BEGIN_BATCH(3);
+        OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));
+        OUT_BATCH(hiz_region->pitch * hiz_region->cpp - 1);
+        OUT_RELOC(hiz_region->buffer,
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+                  0);
+        ADVANCE_BATCH();
+      } else {
+        BEGIN_BATCH(3);
+        OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));
+        OUT_BATCH(0);
+        OUT_BATCH(0);
+        ADVANCE_BATCH();
+      }
+
+      /* Emit stencil buffer. */
+      if (stencil_irb) {
+        BEGIN_BATCH(3);
+        OUT_BATCH((_3DSTATE_STENCIL_BUFFER << 16) | (3 - 2));
+        OUT_BATCH(stencil_irb->region->pitch * stencil_irb->region->cpp - 1);
+        OUT_RELOC(stencil_irb->region->buffer,
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+                  0);
+        ADVANCE_BATCH();
+      } else {
+        BEGIN_BATCH(3);
+        OUT_BATCH((_3DSTATE_STENCIL_BUFFER << 16) | (3 - 2));
+        OUT_BATCH(0);
+        OUT_BATCH(0);
+        ADVANCE_BATCH();
+      }
    }
 
    /*
@@ -386,6 +418,9 @@ static void emit_depthbuffer(struct brw_context *brw)
     *     when HiZ is enabled and the DEPTH_BUFFER_STATE changes.
     */
    if (intel->gen >= 6 || hiz_region) {
+      if (intel->gen == 6)
+        intel_emit_post_sync_nonzero_flush(intel);
+
       BEGIN_BATCH(2);
       OUT_BATCH(_3DSTATE_CLEAR_PARAMS << 16 | (2 - 2));
       OUT_BATCH(0);
@@ -418,6 +453,9 @@ static void upload_polygon_stipple(struct brw_context *brw)
    if (!ctx->Polygon.StippleFlag)
       return;
 
+   if (intel->gen == 6)
+      intel_emit_post_sync_nonzero_flush(intel);
+
    BEGIN_BATCH(33);
    OUT_BATCH(_3DSTATE_POLY_STIPPLE_PATTERN << 16 | (33 - 2));
 
@@ -461,6 +499,9 @@ static void upload_polygon_stipple_offset(struct brw_context *brw)
    if (!ctx->Polygon.StippleFlag)
       return;
 
+   if (intel->gen == 6)
+      intel_emit_post_sync_nonzero_flush(intel);
+
    BEGIN_BATCH(2);
    OUT_BATCH(_3DSTATE_POLY_STIPPLE_OFFSET << 16 | (2-2));
 
@@ -501,6 +542,9 @@ static void upload_aa_line_parameters(struct brw_context *brw)
    if (!ctx->Line.SmoothFlag || !brw->has_aa_line_parameters)
       return;
 
+   if (intel->gen == 6)
+      intel_emit_post_sync_nonzero_flush(intel);
+
    OUT_BATCH(_3DSTATE_AA_LINE_PARAMETERS << 16 | (3 - 2));
    /* use legacy aa line coverage computation */
    OUT_BATCH(0);
@@ -531,6 +575,9 @@ static void upload_line_stipple(struct brw_context *brw)
    if (!ctx->Line.StippleFlag)
       return;
 
+   if (intel->gen == 6)
+      intel_emit_post_sync_nonzero_flush(intel);
+
    BEGIN_BATCH(3);
    OUT_BATCH(_3DSTATE_LINE_STIPPLE_PATTERN << 16 | (3 - 2));
    OUT_BATCH(ctx->Line.StipplePattern);
@@ -558,28 +605,21 @@ static void upload_invarient_state( struct brw_context *brw )
 {
    struct intel_context *intel = &brw->intel;
 
-   {
-      /* 0x61040000  Pipeline Select */
-      /*     PipelineSelect            : 0 */
-      struct brw_pipeline_select ps;
+   /* 3DSTATE_SIP, 3DSTATE_MULTISAMPLE, etc. are nonpipelined. */
+   if (intel->gen == 6)
+      intel_emit_post_sync_nonzero_flush(intel);
 
-      memset(&ps, 0, sizeof(ps));
-      ps.header.opcode = brw->CMD_PIPELINE_SELECT;
-      ps.header.pipeline_select = 0;
-      BRW_BATCH_STRUCT(brw, &ps);
-   }
+   /* Select the 3D pipeline (as opposed to media) */
+   BEGIN_BATCH(1);
+   OUT_BATCH(brw->CMD_PIPELINE_SELECT << 16 | 0);
+   ADVANCE_BATCH();
 
    if (intel->gen < 6) {
-      struct brw_global_depth_offset_clamp gdo;
-      memset(&gdo, 0, sizeof(gdo));
-
-      /* Disable depth offset clamping. 
-       */
-      gdo.header.opcode = _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP;
-      gdo.header.length = sizeof(gdo)/4 - 2;
-      gdo.depth_offset_clamp = 0.0;
-
-      BRW_BATCH_STRUCT(brw, &gdo);
+      /* Disable depth offset clamping. */
+      BEGIN_BATCH(2);
+      OUT_BATCH(_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP << 16 | (2 - 2));
+      OUT_BATCH_F(0.0);
+      ADVANCE_BATCH();
    }
 
    if (intel->gen >= 6) {
@@ -612,29 +652,15 @@ static void upload_invarient_state( struct brw_context *brw )
       }
    }
 
-   /* 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);
-   }
-
-
-   {
-      struct brw_vf_statistics vfs;
-      memset(&vfs, 0, sizeof(vfs));
-
-      vfs.opcode = brw->CMD_VF_STATISTICS;
-      if (unlikely(INTEL_DEBUG & DEBUG_STATS))
-        vfs.statistics_enable = 1; 
+   BEGIN_BATCH(2);
+   OUT_BATCH(CMD_STATE_SIP << 16 | (2 - 2));
+   OUT_BATCH(0);
+   ADVANCE_BATCH();
 
-      BRW_BATCH_STRUCT(brw, &vfs);
-   }
+   BEGIN_BATCH(1);
+   OUT_BATCH(brw->CMD_VF_STATISTICS << 16 |
+            (unlikely(INTEL_DEBUG & DEBUG_STATS) ? 1 : 0));
+   ADVANCE_BATCH();
 }
 
 const struct brw_tracked_state brw_invarient_state = {
@@ -660,7 +686,19 @@ static void upload_state_base_address( struct brw_context *brw )
 {
    struct intel_context *intel = &brw->intel;
 
+   /* FINISHME: According to section 3.6.1 "STATE_BASE_ADDRESS" of
+    * vol1a of the G45 PRM, MI_FLUSH with the ISC invalidate should be
+    * programmed prior to STATE_BASE_ADDRESS.
+    *
+    * However, given that the instruction SBA (general state base
+    * address) on this chipset is always set to 0 across X and GL,
+    * maybe this isn't required for us in particular.
+    */
+
    if (intel->gen >= 6) {
+      if (intel->gen == 6)
+        intel_emit_post_sync_nonzero_flush(intel);
+
        BEGIN_BATCH(10);
        OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (10 - 2));
        /* General state base address: stateless DP read/write requests */
@@ -684,7 +722,9 @@ static void upload_state_base_address( struct brw_context *brw )
                                   I915_GEM_DOMAIN_INSTRUCTION), 0, 1);
 
        OUT_BATCH(1); /* Indirect object base address: MEDIA_OBJECT data */
-       OUT_BATCH(1); /* Instruction base address: shader kernels (incl. SIP) */
+       OUT_RELOC(brw->cache.bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
+                1); /* Instruction base address: shader kernels (incl. SIP) */
+
        OUT_BATCH(1); /* General state upper bound */
        OUT_BATCH(1); /* Dynamic state upper bound */
        OUT_BATCH(1); /* Indirect object upper bound */
@@ -697,7 +737,8 @@ static void upload_state_base_address( struct brw_context *brw )
        OUT_RELOC(intel->batch.bo, I915_GEM_DOMAIN_SAMPLER, 0,
                 1); /* Surface state base address */
        OUT_BATCH(1); /* Indirect object base address */
-       OUT_BATCH(1); /* Instruction base address */
+       OUT_RELOC(brw->cache.bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
+                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 */
@@ -713,12 +754,37 @@ static void upload_state_base_address( struct brw_context *brw )
        OUT_BATCH(1); /* Indirect object upper bound */
        ADVANCE_BATCH();
    }
+
+   /* According to section 3.6.1 of VOL1 of the 965 PRM,
+    * STATE_BASE_ADDRESS updates require a reissue of:
+    *
+    * 3DSTATE_PIPELINE_POINTERS
+    * 3DSTATE_BINDING_TABLE_POINTERS
+    * MEDIA_STATE_POINTERS
+    *
+    * and this continues through Ironlake.  The Sandy Bridge PRM, vol
+    * 1 part 1 says that the folowing packets must be reissued:
+    *
+    * 3DSTATE_CC_POINTERS
+    * 3DSTATE_BINDING_TABLE_POINTERS
+    * 3DSTATE_SAMPLER_STATE_POINTERS
+    * 3DSTATE_VIEWPORT_STATE_POINTERS
+    * MEDIA_STATE_POINTERS
+    *
+    * Those are always reissued following SBA updates anyway (new
+    * batch time), except in the case of the program cache BO
+    * changing.  Having a separate state flag makes the sequence more
+    * obvious.
+    */
+
+   brw->state.dirty.brw |= BRW_NEW_STATE_BASE_ADDRESS;
 }
 
 const struct brw_tracked_state brw_state_base_address = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_BATCH,
+      .brw = (BRW_NEW_BATCH |
+             BRW_NEW_PROGRAM_CACHE),
       .cache = 0,
    },
    .emit = upload_state_base_address
index c222777..fca30a7 100644 (file)
@@ -120,14 +120,11 @@ static void compile_sf_prog( struct brw_context *brw,
       printf("\n");
    }
 
-   /* Upload
-    */
-   drm_intel_bo_unreference(brw->sf.prog_bo);
-   brw->sf.prog_bo = brw_upload_cache(&brw->cache, BRW_SF_PROG,
-                                     &c.key, sizeof(c.key),
-                                     program, program_size,
-                                     &c.prog_data, sizeof(c.prog_data),
-                                     &brw->sf.prog_data);
+   brw_upload_cache(&brw->cache, BRW_SF_PROG,
+                   &c.key, sizeof(c.key),
+                   program, program_size,
+                   &c.prog_data, sizeof(c.prog_data),
+                   &brw->sf.prog_offset, &brw->sf.prog_data);
    ralloc_free(mem_ctx);
 }
 
@@ -191,12 +188,11 @@ static void upload_sf_prog(struct brw_context *brw)
       key.frontface_ccw = (ctx->Polygon.FrontFace == GL_CCW) ^ (ctx->DrawBuffer->Name != 0);
    }
 
-   drm_intel_bo_unreference(brw->sf.prog_bo);
-   brw->sf.prog_bo = brw_search_cache(&brw->cache, BRW_SF_PROG,
-                                     &key, sizeof(key),
-                                     &brw->sf.prog_data);
-   if (brw->sf.prog_bo == NULL)
+   if (!brw_search_cache(&brw->cache, BRW_SF_PROG,
+                        &key, sizeof(key),
+                        &brw->sf.prog_offset, &brw->sf.prog_data)) {
       compile_sf_prog( brw, &key );
+   }
 }
 
 
index 78b22c4..9201be7 100644 (file)
@@ -46,7 +46,8 @@ static void upload_sf_vp(struct brw_context *brw)
    const GLboolean render_to_fbo = (ctx->DrawBuffer->Name != 0);
    const GLfloat *v = ctx->Viewport._WindowMap.m;
 
-   sfv = brw_state_batch(brw, sizeof(*sfv), 32, &brw->sf.vp_offset);
+   sfv = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
+                        sizeof(*sfv), 32, &brw->sf.vp_offset);
    memset(sfv, 0, sizeof(*sfv));
 
    if (render_to_fbo) {
@@ -129,13 +130,19 @@ static void upload_sf_unit( struct brw_context *brw )
    int chipset_max_threads;
    bool render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0;
 
-   sf = brw_state_batch(brw, sizeof(*sf), 64, &brw->sf.state_offset);
+   sf = brw_state_batch(brw, AUB_TRACE_SF_STATE,
+                       sizeof(*sf), 64, &brw->sf.state_offset);
 
    memset(sf, 0, sizeof(*sf));
 
-   /* CACHE_NEW_SF_PROG */
+   /* BRW_NEW_PROGRAM_CACHE | CACHE_NEW_SF_PROG */
    sf->thread0.grf_reg_count = ALIGN(brw->sf.prog_data->total_grf, 16) / 16 - 1;
-   sf->thread0.kernel_start_pointer = brw->sf.prog_bo->offset >> 6; /* reloc */
+   sf->thread0.kernel_start_pointer =
+      brw_program_reloc(brw,
+                       brw->sf.state_offset +
+                       offsetof(struct brw_sf_unit_state, thread0),
+                       brw->sf.prog_offset +
+                       (sf->thread0.grf_reg_count << 1)) >> 6;
 
    sf->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
 
@@ -282,11 +289,6 @@ static void upload_sf_unit( struct brw_context *brw )
    /* STATE_PREFETCH command description describes this state as being
     * something loaded through the GPE (L2 ISC), so it's INSTRUCTION domain.
     */
-   /* Emit SF program relocation */
-   drm_intel_bo_emit_reloc(bo, (brw->sf.state_offset +
-                               offsetof(struct brw_sf_unit_state, thread0)),
-                          brw->sf.prog_bo, sf->thread0.grf_reg_count << 1,
-                          I915_GEM_DOMAIN_INSTRUCTION, 0);
 
    /* Emit SF viewport relocation */
    drm_intel_bo_emit_reloc(bo, (brw->sf.state_offset +
@@ -308,6 +310,7 @@ const struct brw_tracked_state brw_sf_unit = {
                _NEW_SCISSOR |
                _NEW_BUFFERS),
       .brw   = (BRW_NEW_BATCH |
+               BRW_NEW_PROGRAM_CACHE |
                BRW_NEW_URB_FENCE),
       .cache = (CACHE_NEW_SF_VP |
                CACHE_NEW_SF_PROG)
index 544ef7d..cede4e5 100644 (file)
@@ -145,21 +145,21 @@ void brw_clear_validated_bos(struct brw_context *brw);
  * brw_state_cache.c
  */
 
-drm_intel_bo *brw_upload_cache(struct brw_cache *cache,
-                              enum brw_cache_id cache_id,
-                              const void *key,
-                              GLuint key_sz,
-                              const void *data,
-                              GLuint data_sz,
-                              const void *aux,
-                              GLuint aux_sz,
-                              void *aux_return);
-
-drm_intel_bo *brw_search_cache( struct brw_cache *cache,
-                         enum brw_cache_id cache_id,
-                         const void *key,
-                         GLuint key_size,
-                         void *aux_return);
+void brw_upload_cache(struct brw_cache *cache,
+                     enum brw_cache_id cache_id,
+                     const void *key,
+                     GLuint key_sz,
+                     const void *data,
+                     GLuint data_sz,
+                     const void *aux,
+                     GLuint aux_sz,
+                     uint32_t *out_offset, void *out_aux);
+
+bool brw_search_cache(struct brw_cache *cache,
+                     enum brw_cache_id cache_id,
+                     const void *key,
+                     GLuint key_size,
+                     uint32_t *inout_offset, void *out_aux);
 void brw_state_cache_check_size( struct brw_context *brw );
 
 void brw_init_caches( struct brw_context *brw );
@@ -172,6 +172,7 @@ void brw_destroy_caches( struct brw_context *brw );
                                                        sizeof(*(s)), false)
 
 void *brw_state_batch(struct brw_context *brw,
+                     enum state_struct_type type,
                      int size,
                      int alignment,
                      uint32_t *out_offset);
index 213c7a3..5a983c3 100644 (file)
 #include "brw_state.h"
 #include "intel_batchbuffer.h"
 #include "main/imports.h"
+#include "../glsl/ralloc.h"
+
+static void
+brw_track_state_batch(struct brw_context *brw,
+                     enum state_struct_type type,
+                     uint32_t offset,
+                     int size)
+{
+   struct intel_batchbuffer *batch = &brw->intel.batch;
+
+   if (!brw->state_batch_list) {
+      /* Our structs are always aligned to at least 32 bytes, so
+       * our array doesn't need to be any larger
+       */
+      brw->state_batch_list = ralloc_size(brw, sizeof(*brw->state_batch_list) *
+                                         batch->bo->size / 32);
+   }
+
+   brw->state_batch_list[brw->state_batch_count].offset = offset;
+   brw->state_batch_list[brw->state_batch_count].size = size;
+   brw->state_batch_list[brw->state_batch_count].type = type;
+   brw->state_batch_count++;
+}
 
 /**
  * Allocates a block of space in the batchbuffer for indirect state.
@@ -49,6 +72,7 @@
  */
 void *
 brw_state_batch(struct brw_context *brw,
+               enum state_struct_type type,
                int size,
                int alignment,
                uint32_t *out_offset)
@@ -71,6 +95,9 @@ brw_state_batch(struct brw_context *brw,
 
    batch->state_batch_offset = offset;
 
+   if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
+      brw_track_state_batch(brw, type, offset, size);
+
    *out_offset = offset;
    return batch->map + (offset>>2);
 }
index f13a41f..3988625 100644 (file)
@@ -45,6 +45,7 @@
  */
 
 #include "main/imports.h"
+#include "intel_batchbuffer.h"
 #include "brw_state.h"
 
 #define FILE_DEBUG_FLAG DEBUG_STATE
@@ -67,23 +68,6 @@ hash_key(struct brw_cache_item *item)
    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,
-                 drm_intel_bo *bo)
-{
-   if (bo == cache->last_bo[cache_id])
-      return; /* no change */
-
-   drm_intel_bo_unreference(cache->last_bo[cache_id]);
-   cache->last_bo[cache_id] = bo;
-   drm_intel_bo_reference(cache->last_bo[cache_id]);
-   cache->brw->state.dirty.cache |= 1 << cache_id;
-}
-
 static int
 brw_cache_item_equals(const struct brw_cache_item *a,
                      const struct brw_cache_item *b)
@@ -145,12 +129,13 @@ rehash(struct brw_cache *cache)
 /**
  * Returns the buffer object matching cache_id and key, or NULL.
  */
-drm_intel_bo *
+bool
 brw_search_cache(struct brw_cache *cache,
                  enum brw_cache_id cache_id,
                  const void *key, GLuint key_size,
-                 void *aux_return)
+                 uint32_t *inout_offset, void *out_aux)
 {
+   struct brw_context *brw = cache->brw;
    struct brw_cache_item *item;
    struct brw_cache_item lookup;
    GLuint hash;
@@ -164,19 +149,116 @@ brw_search_cache(struct brw_cache *cache,
    item = search_cache(cache, hash, &lookup);
 
    if (item == NULL)
-      return NULL;
+      return false;
 
-   if (aux_return)
-      *(void **)aux_return = (void *)((char *)item->key + item->key_size);
+   *(void **)out_aux = ((char *)item->key + item->key_size);
 
-   update_cache_last(cache, cache_id, item->bo);
+   if (item->offset != *inout_offset) {
+      brw->state.dirty.cache |= (1 << cache_id);
+      *inout_offset = item->offset;
+   }
 
-   drm_intel_bo_reference(item->bo);
-   return item->bo;
+   return true;
 }
 
+static void
+brw_cache_new_bo(struct brw_cache *cache, uint32_t new_size)
+{
+   struct brw_context *brw = cache->brw;
+   struct intel_context *intel = &brw->intel;
+   drm_intel_bo *new_bo;
+
+   new_bo = drm_intel_bo_alloc(intel->bufmgr, "program cache", new_size, 64);
+
+   /* Copy any existing data that needs to be saved. */
+   if (cache->next_offset != 0) {
+      drm_intel_bo_map(cache->bo, false);
+      drm_intel_bo_subdata(new_bo, 0, cache->next_offset, cache->bo->virtual);
+      drm_intel_bo_unmap(cache->bo);
+   }
+
+   drm_intel_bo_unreference(cache->bo);
+   cache->bo = new_bo;
+   cache->bo_used_by_gpu = false;
+
+   /* Since we have a new BO in place, we need to signal the units
+    * that depend on it (state base address on gen5+, or unit state before).
+    */
+   brw->state.dirty.brw |= BRW_NEW_PROGRAM_CACHE;
+}
+
+/**
+ * Attempts to find an item in the cache with identical data and aux
+ * data to use
+ */
+static bool
+brw_try_upload_using_copy(struct brw_cache *cache,
+                         struct brw_cache_item *result_item,
+                         const void *data,
+                         const void *aux)
+{
+   int i;
+   struct brw_cache_item *item;
+
+   for (i = 0; i < cache->size; i++) {
+      for (item = cache->items[i]; item; item = item->next) {
+        const void *item_aux = item->key + item->key_size;
+        int ret;
+
+        if (item->cache_id != result_item->cache_id ||
+            item->size != result_item->size ||
+            item->aux_size != result_item->aux_size) {
+           continue;
+        }
+
+        if (memcmp(item_aux, aux, item->aux_size) != 0) {
+           continue;
+        }
+
+        drm_intel_bo_map(cache->bo, false);
+        ret = memcmp(cache->bo->virtual + item->offset, data, item->size);
+        drm_intel_bo_unmap(cache->bo);
+        if (ret)
+           continue;
+
+        result_item->offset = item->offset;
+
+        return true;
+      }
+   }
+
+   return false;
+}
+
+static void
+brw_upload_item_data(struct brw_cache *cache,
+                    struct brw_cache_item *item,
+                    const void *data)
+{
+   /* Allocate space in the cache BO for our new program. */
+   if (cache->next_offset + item->size > cache->bo->size) {
+      uint32_t new_size = cache->bo->size * 2;
+
+      while (cache->next_offset + item->size > new_size)
+        new_size *= 2;
+
+      brw_cache_new_bo(cache, new_size);
+   }
+
+   /* If we would block on writing to an in-use program BO, just
+    * recreate it.
+    */
+   if (cache->bo_used_by_gpu) {
+      brw_cache_new_bo(cache, cache->bo->size);
+   }
+
+   item->offset = cache->next_offset;
+
+   /* Programs are always 64-byte aligned, so set up the next one now */
+   cache->next_offset = ALIGN(item->offset + item->size, 64);
+}
 
-drm_intel_bo *
+void
 brw_upload_cache(struct brw_cache *cache,
                 enum brw_cache_id cache_id,
                 const void *key,
@@ -185,23 +267,31 @@ brw_upload_cache(struct brw_cache *cache,
                 GLuint data_size,
                 const void *aux,
                 GLuint aux_size,
-                void *aux_return)
+                uint32_t *out_offset,
+                void *out_aux)
 {
    struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item);
    GLuint hash;
    void *tmp;
-   drm_intel_bo *bo;
 
    item->cache_id = cache_id;
+   item->size = data_size;
    item->key = key;
    item->key_size = key_size;
+   item->aux_size = aux_size;
    hash = hash_key(item);
    item->hash = hash;
 
-   /* Create the buffer object to contain the data */
-   bo = drm_intel_bo_alloc(cache->brw->intel.bufmgr,
-                          cache->name[cache_id], data_size, 1 << 6);
-
+   /* If we can find a matching prog/prog_data combo in the cache
+    * already, then reuse the existing stuff.  This will mean not
+    * flagging CACHE_NEW_* when transitioning between the two
+    * equivalent hash keys.  This is notably useful for programs
+    * generating shaders at runtime, where multiple shaders may
+    * compile to the thing in our backend.
+    */
+   if (!brw_try_upload_using_copy(cache, item, data, aux)) {
+      brw_upload_item_data(cache, item, data);
+   }
 
    /* Set up the memory containing the key and aux_data */
    tmp = malloc(key_size + aux_size);
@@ -211,9 +301,6 @@ brw_upload_cache(struct brw_cache *cache,
 
    item->key = tmp;
 
-   item->bo = bo;
-   drm_intel_bo_reference(bo);
-
    if (cache->n_items > cache->size * 1.5)
       rehash(cache);
 
@@ -222,34 +309,18 @@ brw_upload_cache(struct brw_cache *cache,
    cache->items[hash] = item;
    cache->n_items++;
 
-   if (aux_return) {
-      *(void **)aux_return = (void *)((char *)item->key + item->key_size);
-   }
-
-   DBG("upload %s: %d bytes to cache id %d\n",
-       cache->name[cache_id],
-       data_size, cache_id);
-
    /* Copy data to the buffer */
-   drm_intel_bo_subdata(bo, 0, data_size, data);
-
-   update_cache_last(cache, cache_id, bo);
+   drm_intel_bo_subdata(cache->bo, item->offset, data_size, data);
 
-   return bo;
-}
-
-static void
-brw_init_cache_id(struct brw_cache *cache,
-                  const char *name,
-                  enum brw_cache_id id)
-{
-   cache->name[id] = strdup(name);
+   *out_offset = item->offset;
+   *(void **)out_aux = (void *)((char *)item->key + item->key_size);
+   cache->brw->state.dirty.cache |= 1 << cache_id;
 }
 
-
 void
 brw_init_caches(struct brw_context *brw)
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_cache *cache = &brw->cache;
 
    cache->brw = brw;
@@ -259,36 +330,15 @@ brw_init_caches(struct brw_context *brw)
    cache->items = (struct brw_cache_item **)
       calloc(1, cache->size * sizeof(struct brw_cache_item));
 
-   brw_init_cache_id(cache, "CC_VP", BRW_CC_VP);
-   brw_init_cache_id(cache, "CC_UNIT", BRW_CC_UNIT);
-   brw_init_cache_id(cache, "WM_PROG", BRW_WM_PROG);
-   brw_init_cache_id(cache, "SAMPLER", BRW_SAMPLER);
-   brw_init_cache_id(cache, "WM_UNIT", BRW_WM_UNIT);
-   brw_init_cache_id(cache, "SF_PROG", BRW_SF_PROG);
-   brw_init_cache_id(cache, "SF_VP", BRW_SF_VP);
-
-   brw_init_cache_id(cache, "SF_UNIT", BRW_SF_UNIT);
-
-   brw_init_cache_id(cache, "VS_UNIT", BRW_VS_UNIT);
-
-   brw_init_cache_id(cache, "VS_PROG", BRW_VS_PROG);
-
-   brw_init_cache_id(cache, "CLIP_UNIT", BRW_CLIP_UNIT);
-
-   brw_init_cache_id(cache, "CLIP_PROG", BRW_CLIP_PROG);
-   brw_init_cache_id(cache, "CLIP_VP", BRW_CLIP_VP);
-
-   brw_init_cache_id(cache, "GS_UNIT", BRW_GS_UNIT);
-
-   brw_init_cache_id(cache, "GS_PROG", BRW_GS_PROG);
-   brw_init_cache_id(cache, "BLEND_STATE", BRW_BLEND_STATE);
-   brw_init_cache_id(cache, "COLOR_CALC_STATE", BRW_COLOR_CALC_STATE);
-   brw_init_cache_id(cache, "DEPTH_STENCIL_STATE", BRW_DEPTH_STENCIL_STATE);
+   cache->bo = drm_intel_bo_alloc(intel->bufmgr,
+                                 "program cache",
+                                 4096, 64);
 }
 
 static void
 brw_clear_cache(struct brw_context *brw, struct brw_cache *cache)
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_cache_item *c, *next;
    GLuint i;
 
@@ -297,7 +347,6 @@ brw_clear_cache(struct brw_context *brw, struct brw_cache *cache)
    for (i = 0; i < cache->size; i++) {
       for (c = cache->items[i]; c; c = next) {
         next = c->next;
-        drm_intel_bo_unreference(c->bo);
         free((void *)c->key);
         free(c);
       }
@@ -306,9 +355,18 @@ brw_clear_cache(struct brw_context *brw, struct brw_cache *cache)
 
    cache->n_items = 0;
 
+   /* Start putting programs into the start of the BO again, since
+    * we'll never find the old results.
+    */
+   cache->next_offset = 0;
+
+   /* We need to make sure that the programs get regenerated, since
+    * any offsets leftover in brw_context will no longer be valid.
+    */
    brw->state.dirty.mesa |= ~0;
    brw->state.dirty.brw |= ~0;
    brw->state.dirty.cache |= ~0;
+   intel_batchbuffer_flush(intel);
 }
 
 void
@@ -325,15 +383,10 @@ brw_state_cache_check_size(struct brw_context *brw)
 static void
 brw_destroy_cache(struct brw_context *brw, struct brw_cache *cache)
 {
-   GLuint i;
 
    DBG("%s\n", __FUNCTION__);
 
    brw_clear_cache(brw, cache);
-   for (i = 0; i < BRW_MAX_CACHE; i++) {
-      drm_intel_bo_unreference(cache->last_bo[i]);
-      free(cache->name[i]);
-   }
    free(cache->items);
    cache->items = NULL;
    cache->size = 0;
index ff06cb3..b9e5cc1 100644 (file)
 #include "brw_context.h"
 #include "brw_defines.h"
 
-/**
- * Prints out a header, the contents, and the message associated with
- * the hardware state data given.
- *
- * \param name Name of the state object
- * \param data Pointer to the base of the state object
- * \param hw_offset Hardware offset of the base of the state data.
- * \param index Index of the DWORD being output.
- */
 static void
-state_out(const char *name, void *data, uint32_t hw_offset, int index,
-         char *fmt, ...)
-{
-    va_list va;
+batch_out(struct brw_context *brw, const char *name, uint32_t offset,
+         int index, char *fmt, ...) PRINTFLIKE(5, 6);
 
-    fprintf(stderr, "%8s: 0x%08x: 0x%08x: ",
-           name, hw_offset + index * 4, ((uint32_t *)data)[index]);
-    va_start(va, fmt);
-    vfprintf(stderr, fmt, va);
-    va_end(va);
-}
-
-/** Generic, undecoded state buffer debug printout */
 static void
-state_struct_out(const char *name, drm_intel_bo *buffer,
-                unsigned int offset, unsigned int size)
+batch_out(struct brw_context *brw, const char *name, uint32_t offset,
+         int index, char *fmt, ...)
 {
-   int i;
-
-   if (buffer == NULL)
-      return;
-
-   drm_intel_bo_map(buffer, GL_FALSE);
-   for (i = 0; i < size / 4; i++) {
-      state_out(name, buffer->virtual + offset, buffer->offset + offset, i,
-               "dword %d\n", i);
-   }
-   drm_intel_bo_unmap(buffer);
+   struct intel_context *intel = &brw->intel;
+   uint32_t *data = intel->batch.bo->virtual + offset;
+   va_list va;
+
+   fprintf(stderr, "0x%08x:      0x%08x: %8s: ",
+          offset + index * 4, data[index], name);
+   va_start(va, fmt);
+   vfprintf(stderr, fmt, va);
+   va_end(va);
 }
 
 static const char *
@@ -98,397 +77,537 @@ get_965_surface_format(unsigned int surface_format)
     }
 }
 
-static void dump_wm_surface_state(struct brw_context *brw)
+static void dump_vs_state(struct brw_context *brw, uint32_t offset)
 {
-   dri_bo *bo;
-   GLubyte *base;
-   int i;
+   struct intel_context *intel = &brw->intel;
+   const char *name = "VS_STATE";
+   struct brw_vs_unit_state *vs = intel->batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0, "thread0\n");
+   batch_out(brw, name, offset, 1, "thread1\n");
+   batch_out(brw, name, offset, 2, "thread2\n");
+   batch_out(brw, name, offset, 3, "thread3\n");
+   batch_out(brw, name, offset, 4, "thread4: %d threads\n",
+            vs->thread4.max_threads + 1);
+   batch_out(brw, name, offset, 5, "vs5\n");
+   batch_out(brw, name, offset, 6, "vs6\n");
+}
+
+static void dump_gs_state(struct brw_context *brw, uint32_t offset)
+{
+   struct intel_context *intel = &brw->intel;
+   const char *name = "GS_STATE";
+   struct brw_gs_unit_state *gs = intel->batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0, "thread0\n");
+   batch_out(brw, name, offset, 1, "thread1\n");
+   batch_out(brw, name, offset, 2, "thread2\n");
+   batch_out(brw, name, offset, 3, "thread3\n");
+   batch_out(brw, name, offset, 4, "thread4: %d threads\n",
+            gs->thread4.max_threads + 1);
+   batch_out(brw, name, offset, 5, "vs5\n");
+   batch_out(brw, name, offset, 6, "vs6\n");
+}
 
-   bo = brw->intel.batch.bo;
-   drm_intel_bo_map(bo, GL_FALSE);
-   base = bo->virtual;
+static void dump_clip_state(struct brw_context *brw, uint32_t offset)
+{
+   struct intel_context *intel = &brw->intel;
+   const char *name = "CLIP_STATE";
+   struct brw_clip_unit_state *clip = intel->batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0, "thread0\n");
+   batch_out(brw, name, offset, 1, "thread1\n");
+   batch_out(brw, name, offset, 2, "thread2\n");
+   batch_out(brw, name, offset, 3, "thread3\n");
+   batch_out(brw, name, offset, 4, "thread4: %d threads\n",
+            clip->thread4.max_threads + 1);
+   batch_out(brw, name, offset, 5, "clip5\n");
+   batch_out(brw, name, offset, 6, "clip6\n");
+   batch_out(brw, name, offset, 7, "vp xmin %f\n", clip->viewport_xmin);
+   batch_out(brw, name, offset, 8, "vp xmax %f\n", clip->viewport_xmax);
+   batch_out(brw, name, offset, 9, "vp ymin %f\n", clip->viewport_ymin);
+   batch_out(brw, name, offset, 10, "vp ymax %f\n", clip->viewport_ymax);
+}
 
-   for (i = 0; i < brw->wm.nr_surfaces; i++) {
-      unsigned int surfoff;
-      uint32_t *surf;
-      char name[20];
+static void dump_sf_state(struct brw_context *brw, uint32_t offset)
+{
+   struct intel_context *intel = &brw->intel;
+   const char *name = "SF_STATE";
+   struct brw_sf_unit_state *sf = intel->batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0, "thread0\n");
+   batch_out(brw, name, offset, 1, "thread1\n");
+   batch_out(brw, name, offset, 2, "thread2\n");
+   batch_out(brw, name, offset, 3, "thread3\n");
+   batch_out(brw, name, offset, 4, "thread4: %d threads\n",
+            sf->thread4.max_threads + 1);
+   batch_out(brw, name, offset, 5, "sf5: viewport offset\n");
+   batch_out(brw, name, offset, 6, "sf6\n");
+   batch_out(brw, name, offset, 7, "sf7\n");
+}
 
-      if (brw->wm.surf_offset[i] == 0) {
-        fprintf(stderr, "WM SURF%d: NULL\n", i);
-        continue;
-      }
-      surfoff = bo->offset + brw->wm.surf_offset[i];
-      surf = (uint32_t *)(base + brw->wm.surf_offset[i]);
-
-      sprintf(name, "WM SURF%d", i);
-      state_out(name, surf, surfoff, 0, "%s %s\n",
-               get_965_surfacetype(GET_FIELD(surf[0], BRW_SURFACE_TYPE)),
-               get_965_surface_format(GET_FIELD(surf[0], BRW_SURFACE_FORMAT)));
-      state_out(name, surf, surfoff, 1, "offset\n");
-      state_out(name, surf, surfoff, 2, "%dx%d size, %d mips\n",
-               GET_FIELD(surf[2], BRW_SURFACE_WIDTH) + 1,
-               GET_FIELD(surf[2], BRW_SURFACE_HEIGHT) + 1);
-      state_out(name, surf, surfoff, 3, "pitch %d, %s tiled\n",
-               GET_FIELD(surf[3], BRW_SURFACE_PITCH) + 1,
-               (surf[3] & BRW_SURFACE_TILED) ?
-               ((surf[3] & BRW_SURFACE_TILED_Y) ? "Y" : "X") : "not");
-      state_out(name, surf, surfoff, 4, "mip base %d\n",
-               GET_FIELD(surf[4], BRW_SURFACE_MIN_LOD));
-      state_out(name, surf, surfoff, 5, "x,y offset: %d,%d\n",
-               GET_FIELD(surf[5], BRW_SURFACE_X_OFFSET),
-               GET_FIELD(surf[5], BRW_SURFACE_Y_OFFSET));
-   }
-   drm_intel_bo_unmap(bo);
+static void dump_wm_state(struct brw_context *brw, uint32_t offset)
+{
+   struct intel_context *intel = &brw->intel;
+   const char *name = "WM_STATE";
+   struct brw_wm_unit_state *wm = intel->batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0, "thread0\n");
+   batch_out(brw, name, offset, 1, "thread1\n");
+   batch_out(brw, name, offset, 2, "thread2\n");
+   batch_out(brw, name, offset, 3, "thread3\n");
+   batch_out(brw, name, offset, 4, "wm4\n");
+   batch_out(brw, name, offset, 5, "wm5: %s%s%s%s%s%s, %d threads\n",
+            wm->wm5.enable_8_pix ? "8pix" : "",
+            wm->wm5.enable_16_pix ? "16pix" : "",
+            wm->wm5.program_uses_depth ? ", uses depth" : "",
+            wm->wm5.program_computes_depth ? ", computes depth" : "",
+            wm->wm5.program_uses_killpixel ? ", kills" : "",
+            wm->wm5.thread_dispatch_enable ? "" : ", no dispatch",
+            wm->wm5.max_threads + 1);
+   batch_out(brw, name, offset, 6, "depth offset constant %f\n",
+            wm->global_depth_offset_constant);
+   batch_out(brw, name, offset, 7, "depth offset scale %f\n",
+            wm->global_depth_offset_scale);
+   batch_out(brw, name, offset, 8, "wm8: kernel 1 (gen5+)\n");
+   batch_out(brw, name, offset, 9, "wm9: kernel 2 (gen5+)\n");
+   batch_out(brw, name, offset, 10, "wm10: kernel 3 (gen5+)\n");
 }
 
-static void dump_gen7_surface_state(struct brw_context *brw)
+static void dump_surface_state(struct brw_context *brw, uint32_t offset)
 {
-   dri_bo *bo;
-   GLubyte *base;
-   int i;
+   const char *name = "SURF";
+   uint32_t *surf = brw->intel.batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0, "%s %s\n",
+            get_965_surfacetype(GET_FIELD(surf[0], BRW_SURFACE_TYPE)),
+            get_965_surface_format(GET_FIELD(surf[0], BRW_SURFACE_FORMAT)));
+   batch_out(brw, name, offset, 1, "offset\n");
+   batch_out(brw, name, offset, 2, "%dx%d size, %d mips\n",
+            GET_FIELD(surf[2], BRW_SURFACE_WIDTH) + 1,
+            GET_FIELD(surf[2], BRW_SURFACE_HEIGHT) + 1,
+            GET_FIELD(surf[2], BRW_SURFACE_LOD));
+   batch_out(brw, name, offset, 3, "pitch %d, %s tiled\n",
+            GET_FIELD(surf[3], BRW_SURFACE_PITCH) + 1,
+            (surf[3] & BRW_SURFACE_TILED) ?
+            ((surf[3] & BRW_SURFACE_TILED_Y) ? "Y" : "X") : "not");
+   batch_out(brw, name, offset, 4, "mip base %d\n",
+            GET_FIELD(surf[4], BRW_SURFACE_MIN_LOD));
+   batch_out(brw, name, offset, 5, "x,y offset: %d,%d\n",
+            GET_FIELD(surf[5], BRW_SURFACE_X_OFFSET),
+            GET_FIELD(surf[5], BRW_SURFACE_Y_OFFSET));
+}
 
-   bo = brw->intel.batch.bo;
-   drm_intel_bo_map(bo, GL_FALSE);
-   base = bo->virtual;
+static void dump_gen7_surface_state(struct brw_context *brw, uint32_t offset)
+{
+   const char *name = "SURF";
+   struct gen7_surface_state *surf = brw->intel.batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0, "%s %s\n",
+            get_965_surfacetype(surf->ss0.surface_type),
+            get_965_surface_format(surf->ss0.surface_format));
+   batch_out(brw, name, offset, 1, "offset\n");
+   batch_out(brw, name, offset, 2, "%dx%d size, %d mips\n",
+            surf->ss2.width + 1, surf->ss2.height + 1, surf->ss5.mip_count);
+   batch_out(brw, name, offset, 3, "pitch %d, %stiled\n",
+            surf->ss3.pitch + 1, surf->ss0.tiled_surface ? "" : "not ");
+   batch_out(brw, name, offset, 4, "mip base %d\n",
+            surf->ss5.min_lod);
+   batch_out(brw, name, offset, 5, "x,y offset: %d,%d\n",
+            surf->ss5.x_offset, surf->ss5.y_offset);
+}
 
-   for (i = 0; i < brw->wm.nr_surfaces; i++) {
-      unsigned int surfoff;
-      struct gen7_surface_state *surf;
-      char name[20];
+static void
+dump_sdc(struct brw_context *brw, uint32_t offset)
+{
+   const char *name = "SDC";
+   struct intel_context *intel = &brw->intel;
 
-      if (brw->wm.surf_offset[i] == 0) {
-        fprintf(stderr, "WM SURF%d: NULL\n", i);
-        continue;
-      }
-      surfoff = bo->offset + brw->wm.surf_offset[i];
-      surf = (struct gen7_surface_state *) (base + brw->wm.surf_offset[i]);
-
-      sprintf(name, "WM SURF%d", i);
-      state_out(name, surf, surfoff, 0, "%s %s\n",
-               get_965_surfacetype(surf->ss0.surface_type),
-               get_965_surface_format(surf->ss0.surface_format));
-      state_out(name, surf, surfoff, 1, "offset\n");
-      state_out(name, surf, surfoff, 2, "%dx%d size, %d mips\n",
-               surf->ss2.width + 1, surf->ss2.height + 1, surf->ss5.mip_count);
-      state_out(name, surf, surfoff, 3, "pitch %d, %stiled\n",
-               surf->ss3.pitch + 1, surf->ss0.tiled_surface ? "" : "not ");
-      state_out(name, surf, surfoff, 4, "mip base %d\n",
-               surf->ss5.min_lod);
-      state_out(name, surf, surfoff, 5, "x,y offset: %d,%d\n",
-               surf->ss5.x_offset, surf->ss5.y_offset);
+   if (intel->gen >= 5 && intel->gen <= 6) {
+      struct gen5_sampler_default_color *sdc = (intel->batch.bo->virtual +
+                                               offset);
+      batch_out(brw, name, offset, 0, "unorm rgba\n");
+      batch_out(brw, name, offset, 1, "r %f\n", sdc->f[0]);
+      batch_out(brw, name, offset, 2, "b %f\n", sdc->f[1]);
+      batch_out(brw, name, offset, 3, "g %f\n", sdc->f[2]);
+      batch_out(brw, name, offset, 4, "a %f\n", sdc->f[3]);
+      batch_out(brw, name, offset, 5, "half float rg\n");
+      batch_out(brw, name, offset, 6, "half float ba\n");
+      batch_out(brw, name, offset, 7, "u16 rg\n");
+      batch_out(brw, name, offset, 8, "u16 ba\n");
+      batch_out(brw, name, offset, 9, "s16 rg\n");
+      batch_out(brw, name, offset, 10, "s16 ba\n");
+      batch_out(brw, name, offset, 11, "s8 rgba\n");
+   } else {
+      struct brw_sampler_default_color *sdc = (intel->batch.bo->virtual +
+                                              offset);
+      batch_out(brw, name, offset, 0, "r %f\n", sdc->color[0]);
+      batch_out(brw, name, offset, 1, "g %f\n", sdc->color[1]);
+      batch_out(brw, name, offset, 2, "b %f\n", sdc->color[2]);
+      batch_out(brw, name, offset, 3, "a %f\n", sdc->color[3]);
    }
-   drm_intel_bo_unmap(bo);
 }
 
-static void dump_wm_sampler_state(struct brw_context *brw)
+static void dump_sampler_state(struct brw_context *brw,
+                              uint32_t offset, uint32_t size)
 {
    struct intel_context *intel = &brw->intel;
-   struct gl_context *ctx = &brw->intel.ctx;
    int i;
+   struct brw_sampler_state *samp = intel->batch.bo->virtual + offset;
 
    assert(intel->gen < 7);
 
-   drm_intel_bo_map(intel->batch.bo, GL_FALSE);
-   for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
-      unsigned int offset;
-      uint32_t sdc_offset;
-      struct brw_sampler_state *samp;
+   for (i = 0; i < size / sizeof(*samp); i++) {
       char name[20];
 
-      if (!ctx->Texture.Unit[i]._ReallyEnabled) {
-        fprintf(stderr, "WM SAMP%d: disabled\n", i);
-        continue;
-      }
-
-      offset = (intel->batch.bo->offset +
-               brw->wm.sampler_offset +
-               i * sizeof(struct brw_sampler_state));
-      samp = (struct brw_sampler_state *)(intel->batch.bo->virtual +
-                                         brw->wm.sampler_offset +
-                                         i * sizeof(struct brw_sampler_state));
-
       sprintf(name, "WM SAMP%d", i);
-      state_out(name, samp, offset, 0, "filtering\n");
-      state_out(name, samp, offset, 1, "wrapping, lod\n");
-      state_out(name, samp, offset, 2, "default color pointer\n");
-      state_out(name, samp, offset, 3, "chroma key, aniso\n");
-
-      sprintf(name, " WM SDC%d", i);
-
-      sdc_offset = intel->batch.bo->offset + brw->wm.sdc_offset[i];
-      if (intel->gen >= 5) {
-        struct gen5_sampler_default_color *sdc = (intel->batch.bo->virtual +
-                                                  brw->wm.sdc_offset[i]);
-        state_out(name, sdc, sdc_offset, 0, "unorm rgba\n");
-        state_out(name, sdc, sdc_offset, 1, "r %f\n", sdc->f[0]);
-        state_out(name, sdc, sdc_offset, 2, "b %f\n", sdc->f[1]);
-        state_out(name, sdc, sdc_offset, 3, "g %f\n", sdc->f[2]);
-        state_out(name, sdc, sdc_offset, 4, "a %f\n", sdc->f[3]);
-        state_out(name, sdc, sdc_offset, 5, "half float rg\n");
-        state_out(name, sdc, sdc_offset, 6, "half float ba\n");
-        state_out(name, sdc, sdc_offset, 7, "u16 rg\n");
-        state_out(name, sdc, sdc_offset, 8, "u16 ba\n");
-        state_out(name, sdc, sdc_offset, 9, "s16 rg\n");
-        state_out(name, sdc, sdc_offset, 10, "s16 ba\n");
-        state_out(name, sdc, sdc_offset, 11, "s8 rgba\n");
-      } else {
-        struct brw_sampler_default_color *sdc = (intel->batch.bo->virtual +
-                                                 brw->wm.sdc_offset[i]);
-        state_out(name, sdc, sdc_offset, 0, "r %f\n", sdc->color[0]);
-        state_out(name, sdc, sdc_offset, 1, "g %f\n", sdc->color[1]);
-        state_out(name, sdc, sdc_offset, 2, "b %f\n", sdc->color[2]);
-        state_out(name, sdc, sdc_offset, 3, "a %f\n", sdc->color[3]);
-      }
+      batch_out(brw, name, offset, 0, "filtering\n");
+      batch_out(brw, name, offset, 1, "wrapping, lod\n");
+      batch_out(brw, name, offset, 2, "default color pointer\n");
+      batch_out(brw, name, offset, 3, "chroma key, aniso\n");
+
+      samp++;
+      offset += sizeof(*samp);
    }
-   drm_intel_bo_unmap(intel->batch.bo);
 }
 
-static void dump_gen7_sampler_state(struct brw_context *brw)
+static void dump_gen7_sampler_state(struct brw_context *brw,
+                                   uint32_t offset, uint32_t size)
 {
    struct intel_context *intel = &brw->intel;
-   struct gl_context *ctx = &brw->intel.ctx;
+   struct gen7_sampler_state *samp = intel->batch.bo->virtual + offset;
    int i;
 
    assert(intel->gen >= 7);
 
-   drm_intel_bo_map(intel->batch.bo, GL_FALSE);
-   for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
-      unsigned int offset;
-      uint32_t sdc_offset;
-      struct gen7_sampler_state *samp;
+   for (i = 0; i < size / sizeof(*samp); i++) {
       char name[20];
 
-      if (!ctx->Texture.Unit[i]._ReallyEnabled) {
-        fprintf(stderr, "WM SAMP%d: disabled\n", i);
-        continue;
-      }
-
-      offset = (intel->batch.bo->offset +
-               brw->wm.sampler_offset +
-               i * sizeof(struct gen7_sampler_state));
-      samp = (struct gen7_sampler_state *)
-            (intel->batch.bo->virtual + brw->wm.sampler_offset +
-             i * sizeof(struct gen7_sampler_state));
-
       sprintf(name, "WM SAMP%d", i);
-      state_out(name, samp, offset, 0, "filtering\n");
-      state_out(name, samp, offset, 1, "wrapping, lod\n");
-      state_out(name, samp, offset, 2, "default color pointer\n");
-      state_out(name, samp, offset, 3, "chroma key, aniso\n");
-
-      sprintf(name, " WM SDC%d", i);
-
-      sdc_offset = intel->batch.bo->offset + brw->wm.sdc_offset[i];
-      struct brw_sampler_default_color *sdc =
-        intel->batch.bo->virtual + brw->wm.sdc_offset[i];
-      state_out(name, sdc, sdc_offset, 0, "r %f\n", sdc->color[0]);
-      state_out(name, sdc, sdc_offset, 1, "g %f\n", sdc->color[1]);
-      state_out(name, sdc, sdc_offset, 2, "b %f\n", sdc->color[2]);
-      state_out(name, sdc, sdc_offset, 3, "a %f\n", sdc->color[3]);
+      batch_out(brw, name, offset, 0, "filtering\n");
+      batch_out(brw, name, offset, 1, "wrapping, lod\n");
+      batch_out(brw, name, offset, 2, "default color pointer\n");
+      batch_out(brw, name, offset, 3, "chroma key, aniso\n");
+
+      samp++;
+      offset += sizeof(*samp);
    }
    drm_intel_bo_unmap(intel->batch.bo);
 }
 
 
-static void dump_sf_viewport_state(struct brw_context *brw)
+static void dump_sf_viewport_state(struct brw_context *brw,
+                                  uint32_t offset)
 {
    struct intel_context *intel = &brw->intel;
    const char *name = "SF VP";
-   struct brw_sf_viewport *vp;
-   uint32_t vp_off;
+   struct brw_sf_viewport *vp = intel->batch.bo->virtual + offset;
 
    assert(intel->gen < 7);
 
-   drm_intel_bo_map(intel->batch.bo, GL_FALSE);
-
-   vp = intel->batch.bo->virtual + brw->sf.vp_offset;
-   vp_off = intel->batch.bo->offset + brw->sf.vp_offset;
-
-   state_out(name, vp, vp_off, 0, "m00 = %f\n", vp->viewport.m00);
-   state_out(name, vp, vp_off, 1, "m11 = %f\n", vp->viewport.m11);
-   state_out(name, vp, vp_off, 2, "m22 = %f\n", vp->viewport.m22);
-   state_out(name, vp, vp_off, 3, "m30 = %f\n", vp->viewport.m30);
-   state_out(name, vp, vp_off, 4, "m31 = %f\n", vp->viewport.m31);
-   state_out(name, vp, vp_off, 5, "m32 = %f\n", vp->viewport.m32);
+   batch_out(brw, name, offset, 0, "m00 = %f\n", vp->viewport.m00);
+   batch_out(brw, name, offset, 1, "m11 = %f\n", vp->viewport.m11);
+   batch_out(brw, name, offset, 2, "m22 = %f\n", vp->viewport.m22);
+   batch_out(brw, name, offset, 3, "m30 = %f\n", vp->viewport.m30);
+   batch_out(brw, name, offset, 4, "m31 = %f\n", vp->viewport.m31);
+   batch_out(brw, name, offset, 5, "m32 = %f\n", vp->viewport.m32);
 
-   state_out(name, vp, vp_off, 6, "top left = %d,%d\n",
+   batch_out(brw, name, offset, 6, "top left = %d,%d\n",
             vp->scissor.xmin, vp->scissor.ymin);
-   state_out(name, vp, vp_off, 7, "bottom right = %d,%d\n",
+   batch_out(brw, name, offset, 7, "bottom right = %d,%d\n",
             vp->scissor.xmax, vp->scissor.ymax);
-
-   drm_intel_bo_unmap(intel->batch.bo);
 }
 
-static void dump_clip_viewport_state(struct brw_context *brw)
+static void dump_clip_viewport_state(struct brw_context *brw,
+                                    uint32_t offset)
 {
    struct intel_context *intel = &brw->intel;
    const char *name = "CLIP VP";
-   struct brw_clipper_viewport *vp;
-   uint32_t vp_off;
+   struct brw_clipper_viewport *vp = intel->batch.bo->virtual + offset;
 
    assert(intel->gen < 7);
 
-   drm_intel_bo_map(intel->batch.bo, GL_FALSE);
-
-   vp = intel->batch.bo->virtual + brw->clip.vp_offset;
-   vp_off = intel->batch.bo->offset + brw->clip.vp_offset;
-
-   state_out(name, vp, vp_off, 0, "xmin = %f\n", vp->xmin);
-   state_out(name, vp, vp_off, 1, "xmax = %f\n", vp->xmax);
-   state_out(name, vp, vp_off, 2, "ymin = %f\n", vp->ymin);
-   state_out(name, vp, vp_off, 3, "ymax = %f\n", vp->ymax);
-   drm_intel_bo_unmap(intel->batch.bo);
+   batch_out(brw, name, offset, 0, "xmin = %f\n", vp->xmin);
+   batch_out(brw, name, offset, 1, "xmax = %f\n", vp->xmax);
+   batch_out(brw, name, offset, 2, "ymin = %f\n", vp->ymin);
+   batch_out(brw, name, offset, 3, "ymax = %f\n", vp->ymax);
 }
 
-static void dump_sf_clip_viewport_state(struct brw_context *brw)
+static void dump_sf_clip_viewport_state(struct brw_context *brw,
+                                       uint32_t offset)
 {
    struct intel_context *intel = &brw->intel;
    const char *name = "SF_CLIP VP";
-   struct gen7_sf_clip_viewport *vp;
-   uint32_t vp_off;
+   struct gen7_sf_clip_viewport *vp = intel->batch.bo->virtual + offset;
 
    assert(intel->gen >= 7);
 
-   drm_intel_bo_map(intel->batch.bo, GL_FALSE);
-
-   vp = intel->batch.bo->virtual + brw->sf.vp_offset;
-   vp_off = intel->batch.bo->offset + brw->sf.vp_offset;
-
-   state_out(name, vp, vp_off, 0, "m00 = %f\n", vp->viewport.m00);
-   state_out(name, vp, vp_off, 1, "m11 = %f\n", vp->viewport.m11);
-   state_out(name, vp, vp_off, 2, "m22 = %f\n", vp->viewport.m22);
-   state_out(name, vp, vp_off, 3, "m30 = %f\n", vp->viewport.m30);
-   state_out(name, vp, vp_off, 4, "m31 = %f\n", vp->viewport.m31);
-   state_out(name, vp, vp_off, 5, "m32 = %f\n", vp->viewport.m32);
-   state_out(name, vp, vp_off, 6, "guardband xmin = %f\n", vp->guardband.xmin);
-   state_out(name, vp, vp_off, 7, "guardband xmax = %f\n", vp->guardband.xmax);
-   state_out(name, vp, vp_off, 8, "guardband ymin = %f\n", vp->guardband.ymin);
-   state_out(name, vp, vp_off, 9, "guardband ymax = %f\n", vp->guardband.ymax);
-   drm_intel_bo_unmap(intel->batch.bo);
+   batch_out(brw, name, offset, 0, "m00 = %f\n", vp->viewport.m00);
+   batch_out(brw, name, offset, 1, "m11 = %f\n", vp->viewport.m11);
+   batch_out(brw, name, offset, 2, "m22 = %f\n", vp->viewport.m22);
+   batch_out(brw, name, offset, 3, "m30 = %f\n", vp->viewport.m30);
+   batch_out(brw, name, offset, 4, "m31 = %f\n", vp->viewport.m31);
+   batch_out(brw, name, offset, 5, "m32 = %f\n", vp->viewport.m32);
+   batch_out(brw, name, offset, 6, "guardband xmin = %f\n", vp->guardband.xmin);
+   batch_out(brw, name, offset, 7, "guardband xmax = %f\n", vp->guardband.xmax);
+   batch_out(brw, name, offset, 8, "guardband ymin = %f\n", vp->guardband.ymin);
+   batch_out(brw, name, offset, 9, "guardband ymax = %f\n", vp->guardband.ymax);
 }
 
 
-static void dump_cc_viewport_state(struct brw_context *brw)
+static void dump_cc_viewport_state(struct brw_context *brw, uint32_t offset)
 {
-   struct intel_context *intel = &brw->intel;
    const char *name = "CC VP";
-   struct brw_cc_viewport *vp;
-   uint32_t vp_off;
-
-   drm_intel_bo_map(intel->batch.bo, GL_FALSE);
+   struct brw_cc_viewport *vp = brw->intel.batch.bo->virtual + offset;
 
-   vp = intel->batch.bo->virtual + brw->cc.vp_offset;
-   vp_off = intel->batch.bo->offset + brw->cc.vp_offset;
+   batch_out(brw, name, offset, 0, "min_depth = %f\n", vp->min_depth);
+   batch_out(brw, name, offset, 1, "max_depth = %f\n", vp->max_depth);
+}
 
-   state_out(name, vp, vp_off, 0, "min_depth = %f\n", vp->min_depth);
-   state_out(name, vp, vp_off, 1, "max_depth = %f\n", vp->max_depth);
-   drm_intel_bo_unmap(intel->batch.bo);
+static void dump_depth_stencil_state(struct brw_context *brw, uint32_t offset)
+{
+   const char *name = "D_S";
+   struct gen6_depth_stencil_state *ds = brw->intel.batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0,
+            "stencil %sable, func %d, write %sable\n",
+            ds->ds0.stencil_enable ? "en" : "dis",
+            ds->ds0.stencil_func,
+            ds->ds0.stencil_write_enable ? "en" : "dis");
+   batch_out(brw, name, offset, 1,
+            "stencil test mask 0x%x, write mask 0x%x\n",
+            ds->ds1.stencil_test_mask, ds->ds1.stencil_write_mask);
+   batch_out(brw, name, offset, 2,
+            "depth test %sable, func %d, write %sable\n",
+            ds->ds2.depth_test_enable ? "en" : "dis",
+            ds->ds2.depth_test_func,
+            ds->ds2.depth_write_enable ? "en" : "dis");
 }
 
-static void dump_depth_stencil_state(struct brw_context *brw)
+static void dump_cc_state_gen4(struct brw_context *brw, uint32_t offset)
 {
-   struct intel_context *intel = &brw->intel;
-   const char *name = "DEPTH STENCIL";
-   struct gen6_depth_stencil_state *ds;
-   uint32_t ds_off;
-
-   drm_intel_bo_map(intel->batch.bo, GL_FALSE);
-
-   ds = intel->batch.bo->virtual + brw->cc.depth_stencil_state_offset;
-   ds_off = intel->batch.bo->offset + brw->cc.depth_stencil_state_offset;
-
-   state_out(name, ds, ds_off, 0, "stencil %sable, func %d, write %sable\n",
-               ds->ds0.stencil_enable ? "en" : "dis",
-               ds->ds0.stencil_func,
-               ds->ds0.stencil_write_enable ? "en" : "dis");
-   state_out(name, ds, ds_off, 1, "stencil test mask 0x%x, write mask 0x%x\n",
-               ds->ds1.stencil_test_mask, ds->ds1.stencil_write_mask);
-   state_out(name, ds, ds_off, 2, "depth test %sable, func %d, write %sable\n",
-               ds->ds2.depth_test_enable ? "en" : "dis",
-               ds->ds2.depth_test_func,
-               ds->ds2.depth_write_enable ? "en" : "dis");
-   drm_intel_bo_unmap(intel->batch.bo);
+   const char *name = "CC";
+
+   batch_out(brw, name, offset, 0, "cc0\n");
+   batch_out(brw, name, offset, 1, "cc1\n");
+   batch_out(brw, name, offset, 2, "cc2\n");
+   batch_out(brw, name, offset, 3, "cc3\n");
+   batch_out(brw, name, offset, 4, "cc4: viewport offset\n");
+   batch_out(brw, name, offset, 5, "cc5\n");
+   batch_out(brw, name, offset, 6, "cc6\n");
+   batch_out(brw, name, offset, 7, "cc7\n");
 }
 
-static void dump_cc_state(struct brw_context *brw)
+static void dump_cc_state_gen6(struct brw_context *brw, uint32_t offset)
 {
    const char *name = "CC";
-   struct gen6_color_calc_state *cc;
-   uint32_t cc_off;
-   dri_bo *bo = brw->intel.batch.bo;
-
-   if (brw->cc.state_offset == 0)
-       return;
-
-   drm_intel_bo_map(bo, GL_FALSE);
-   cc = bo->virtual + brw->cc.state_offset;
-   cc_off = bo->offset + brw->cc.state_offset;
-
-   state_out(name, cc, cc_off, 0, "alpha test format %s, round disable %d, stencil ref %d,"
-               "bf stencil ref %d\n",
-               cc->cc0.alpha_test_format ? "FLOAT32" : "UNORM8",
-               cc->cc0.round_disable,
-               cc->cc0.stencil_ref,
-               cc->cc0.bf_stencil_ref);
-   state_out(name, cc, cc_off, 1, "\n");
-   state_out(name, cc, cc_off, 2, "constant red %f\n", cc->constant_r);
-   state_out(name, cc, cc_off, 3, "constant green %f\n", cc->constant_g);
-   state_out(name, cc, cc_off, 4, "constant blue %f\n", cc->constant_b);
-   state_out(name, cc, cc_off, 5, "constant alpha %f\n", cc->constant_a);
-   
-   drm_intel_bo_unmap(bo);
+   struct gen6_color_calc_state *cc = brw->intel.batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0,
+            "alpha test format %s, round disable %d, stencil ref %d, "
+            "bf stencil ref %d\n",
+            cc->cc0.alpha_test_format ? "FLOAT32" : "UNORM8",
+            cc->cc0.round_disable,
+            cc->cc0.stencil_ref,
+            cc->cc0.bf_stencil_ref);
+   batch_out(brw, name, offset, 1, "\n");
+   batch_out(brw, name, offset, 2, "constant red %f\n", cc->constant_r);
+   batch_out(brw, name, offset, 3, "constant green %f\n", cc->constant_g);
+   batch_out(brw, name, offset, 4, "constant blue %f\n", cc->constant_b);
+   batch_out(brw, name, offset, 5, "constant alpha %f\n", cc->constant_a);
+}
 
+static void dump_blend_state(struct brw_context *brw, uint32_t offset)
+{
+   const char *name = "BLEND";
+
+   batch_out(brw, name, offset, 0, "\n");
+   batch_out(brw, name, offset, 1, "\n");
 }
 
-static void dump_blend_state(struct brw_context *brw)
+static void
+dump_scissor(struct brw_context *brw, uint32_t offset)
 {
+   const char *name = "SCISSOR";
    struct intel_context *intel = &brw->intel;
-   const char *name = "BLEND";
-   struct gen6_blend_state *blend;
-   uint32_t blend_off;
+   struct gen6_scissor_rect *scissor = intel->batch.bo->virtual + offset;
+
+   batch_out(brw, name, offset, 0, "xmin %d, ymin %d\n",
+            scissor->xmin, scissor->ymin);
+   batch_out(brw, name, offset, 1, "xmax %d, ymax %d\n",
+            scissor->xmax, scissor->ymax);
+}
 
-   drm_intel_bo_map(intel->batch.bo, GL_FALSE);
+static void
+dump_vs_constants(struct brw_context *brw, uint32_t offset, uint32_t size)
+{
+   const char *name = "VS_CONST";
+   struct intel_context *intel = &brw->intel;
+   uint32_t *as_uint = intel->batch.bo->virtual + offset;
+   float *as_float = intel->batch.bo->virtual + offset;
+   int i;
 
-   blend = intel->batch.bo->virtual + brw->cc.blend_state_offset;
-   blend_off = intel->batch.bo->offset + brw->cc.blend_state_offset;
+   for (i = 0; i < size / 4; i += 4) {
+      batch_out(brw, name, offset, i, "%3d: (% f % f % f % f) (0x%08x 0x%08x 0x%08x 0x%08x)\n",
+               i / 4,
+               as_float[i], as_float[i + 1], as_float[i + 2], as_float[i + 3],
+               as_uint[i], as_uint[i + 1], as_uint[i + 2], as_uint[i + 3]);
+   }
+}
 
-   state_out(name, blend, blend_off, 0, "\n");
-   state_out(name, blend, blend_off, 1, "\n");
+static void dump_binding_table(struct brw_context *brw, uint32_t offset,
+                              uint32_t size)
+{
+   char name[20];
+   int i;
+   uint32_t *data = brw->intel.batch.bo->virtual + offset;
 
-   drm_intel_bo_unmap(intel->batch.bo);
+   for (i = 0; i < size / 4; i++) {
+      if (data[i] == 0)
+        continue;
 
+      sprintf(name, "BIND%d", i);
+      batch_out(brw, name, offset, i, "surface state address\n");
+   }
 }
 
-static void brw_debug_prog(const char *name, drm_intel_bo *prog)
+static void
+dump_prog_cache(struct brw_context *brw)
 {
-   unsigned int i;
+   struct intel_context *intel = &brw->intel;
+   struct brw_cache *cache = &brw->cache;
+   unsigned int b, i;
    uint32_t *data;
 
-   if (prog == NULL)
-      return;
+   drm_intel_bo_map(brw->cache.bo, false);
+
+   for (b = 0; b < cache->size; b++) {
+      struct brw_cache_item *item;
+
+      for (item = cache->items[b]; item; item = item->next) {
+        const char *name;
+        uint32_t offset = item->offset;
+
+        data = brw->cache.bo->virtual + item->offset;
+
+        switch (item->cache_id) {
+        case BRW_VS_PROG:
+           name = "VS kernel";
+           break;
+        case BRW_GS_PROG:
+           name = "GS kernel";
+           break;
+        case BRW_CLIP_PROG:
+           name = "CLIP kernel";
+           break;
+        case BRW_SF_PROG:
+           name = "SF kernel";
+           break;
+        case BRW_WM_PROG:
+           name = "WM kernel";
+           break;
+        default:
+           name = "unknown";
+           break;
+        }
+
+        for (i = 0; i < item->size / 4 / 4; i++) {
+           fprintf(stderr, "0x%08x: %8s: 0x%08x 0x%08x 0x%08x 0x%08x ",
+                   offset + i * 4 * 4,
+                   name,
+                   data[i * 4], data[i * 4 + 1], data[i * 4 + 2], data[i * 4 + 3]);
+
+           brw_disasm(stderr, (void *)(data + i * 4), intel->gen);
+        }
+      }
+   }
+
+   drm_intel_bo_unmap(brw->cache.bo);
+}
 
-   drm_intel_bo_map(prog, GL_FALSE);
+static void
+dump_state_batch(struct brw_context *brw)
+{
+   struct intel_context *intel = &brw->intel;
+   int i;
 
-   data = prog->virtual;
+   for (i = 0; i < brw->state_batch_count; i++) {
+      uint32_t offset = brw->state_batch_list[i].offset;
+      uint32_t size = brw->state_batch_list[i].size;
 
-   for (i = 0; i < prog->size / 4 / 4; i++) {
-      fprintf(stderr, "%8s: 0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
-             name, (unsigned int)prog->offset + i * 4 * 4,
-             data[i * 4], data[i * 4 + 1], data[i * 4 + 2], data[i * 4 + 3]);
-      /* Stop at the end of the program.  It'd be nice to keep track of the actual
-       * intended program size instead of guessing like this.
-       */
-      if (data[i * 4 + 0] == 0 &&
-         data[i * 4 + 1] == 0 &&
-         data[i * 4 + 2] == 0 &&
-         data[i * 4 + 3] == 0)
+      switch (brw->state_batch_list[i].type) {
+      case AUB_TRACE_VS_STATE:
+        dump_vs_state(brw, offset);
+        break;
+      case AUB_TRACE_GS_STATE:
+        dump_gs_state(brw, offset);
+        break;
+      case AUB_TRACE_CLIP_STATE:
+        dump_clip_state(brw, offset);
+        break;
+      case AUB_TRACE_SF_STATE:
+        dump_sf_state(brw, offset);
+        break;
+      case AUB_TRACE_WM_STATE:
+        dump_wm_state(brw, offset);
+        break;
+      case AUB_TRACE_CLIP_VP_STATE:
+        dump_clip_viewport_state(brw, offset);
+        break;
+      case AUB_TRACE_SF_VP_STATE:
+        if (intel->gen >= 7) {
+           dump_sf_clip_viewport_state(brw, offset);
+        } else {
+           dump_sf_viewport_state(brw, offset);
+        }
+        break;
+      case AUB_TRACE_CC_VP_STATE:
+        dump_cc_viewport_state(brw, offset);
+        break;
+      case AUB_TRACE_DEPTH_STENCIL_STATE:
+        dump_depth_stencil_state(brw, offset);
+        break;
+      case AUB_TRACE_CC_STATE:
+        if (intel->gen >= 6)
+           dump_cc_state_gen6(brw, offset);
+        else
+           dump_cc_state_gen4(brw, offset);
+        break;
+      case AUB_TRACE_BLEND_STATE:
+        dump_blend_state(brw, offset);
+        break;
+      case AUB_TRACE_BINDING_TABLE:
+        dump_binding_table(brw, offset, size);
         break;
+      case AUB_TRACE_SURFACE_STATE:
+        if (intel->gen < 7) {
+           dump_surface_state(brw, offset);
+        } else {
+           dump_gen7_surface_state(brw, offset);
+        }
+        break;
+      case AUB_TRACE_SAMPLER_STATE:
+        if (intel->gen < 7) {
+           dump_sampler_state(brw, offset, size);
+        } else {
+           dump_gen7_sampler_state(brw, offset, size);
+        }
+        break;
+      case AUB_TRACE_SAMPLER_DEFAULT_COLOR:
+        dump_sdc(brw, offset);
+        break;
+      case AUB_TRACE_SCISSOR_STATE:
+        dump_scissor(brw, offset);
+        break;
+      case AUB_TRACE_VS_CONSTANTS:
+        dump_vs_constants(brw, offset, size);
+        break;
+      default:
+        break;
+      }
    }
-
-   drm_intel_bo_unmap(prog);
 }
 
-
 /**
  * Print additional debug information associated with the batchbuffer
  * when DEBUG_BATCH is set.
@@ -503,49 +622,10 @@ void brw_debug_batch(struct intel_context *intel)
 {
    struct brw_context *brw = brw_context(&intel->ctx);
 
-   state_struct_out("WM bind",
-                   brw->intel.batch.bo,
-                   brw->wm.bind_bo_offset,
-                   4 * brw->wm.nr_surfaces);
-   if (intel->gen < 7) {
-      dump_wm_surface_state(brw);
-      dump_wm_sampler_state(brw);
-   } else {
-      dump_gen7_surface_state(brw);
-      dump_gen7_sampler_state(brw);
-   }
-
-   if (intel->gen < 6)
-       state_struct_out("VS", intel->batch.bo, brw->vs.state_offset,
-                       sizeof(struct brw_vs_unit_state));
-   brw_debug_prog("VS prog", brw->vs.prog_bo);
-
-   if (intel->gen < 6)
-       state_struct_out("GS", intel->batch.bo, brw->gs.state_offset,
-                       sizeof(struct brw_gs_unit_state));
-   brw_debug_prog("GS prog", brw->gs.prog_bo);
+   drm_intel_bo_map(intel->batch.bo, false);
+   dump_state_batch(brw);
+   drm_intel_bo_unmap(intel->batch.bo);
 
-   if (intel->gen < 6) {
-      state_struct_out("SF", intel->batch.bo, brw->sf.state_offset,
-                      sizeof(struct brw_sf_unit_state));
-      brw_debug_prog("SF prog", brw->sf.prog_bo);
-   }
-   if (intel->gen >= 7)
-      dump_sf_clip_viewport_state(brw);
-   else
-      dump_sf_viewport_state(brw);
-   if (intel->gen == 6)
-      dump_clip_viewport_state(brw);
-
-   if (intel->gen < 6)
-       state_struct_out("WM", intel->batch.bo, brw->wm.state_offset,
-                       sizeof(struct brw_wm_unit_state));
-   brw_debug_prog("WM prog", brw->wm.prog_bo);
-
-   if (intel->gen >= 6) {
-       dump_cc_viewport_state(brw);
-       dump_depth_stencil_state(brw);
-       dump_cc_state(brw);
-       dump_blend_state(brw);
-   }
+   if (0)
+      dump_prog_cache(brw);
 }
index 6a4c112..76ffa0d 100644 (file)
@@ -47,11 +47,11 @@ static const struct brw_tracked_state *gen4_atoms[] =
    &brw_check_fallback,
 
    &brw_wm_input_sizes,
-   &brw_vs_prog,
-   &brw_gs_prog, 
-   &brw_clip_prog, 
-   &brw_sf_prog,
-   &brw_wm_prog,
+   &brw_vs_prog, /* must do before GS prog, state base address. */
+   &brw_gs_prog, /* must do before state base address */
+   &brw_clip_prog, /* must do before state base address */
+   &brw_sf_prog, /* must do before state base address */
+   &brw_wm_prog, /* must do before state base address */
 
    /* 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
@@ -110,9 +110,9 @@ static const struct brw_tracked_state *gen6_atoms[] =
    &brw_check_fallback,
 
    &brw_wm_input_sizes,
-   &brw_vs_prog,
-   &brw_gs_prog,
-   &brw_wm_prog,
+   &brw_vs_prog, /* must do before state base address */
+   &brw_gs_prog, /* must do before state base address */
+   &brw_wm_prog, /* must do before state base address */
 
    &gen6_clip_vp,
    &gen6_sf_vp,
@@ -365,6 +365,7 @@ static struct dirty_bit_map brw_bits[] = {
    DEFINE_BIT(BRW_NEW_PRIMITIVE),
    DEFINE_BIT(BRW_NEW_CONTEXT),
    DEFINE_BIT(BRW_NEW_WM_INPUT_DIMENSIONS),
+   DEFINE_BIT(BRW_NEW_PROGRAM_CACHE),
    DEFINE_BIT(BRW_NEW_PSP),
    DEFINE_BIT(BRW_NEW_WM_SURFACES),
    DEFINE_BIT(BRW_NEW_INDICES),
@@ -378,6 +379,7 @@ static struct dirty_bit_map brw_bits[] = {
    DEFINE_BIT(BRW_NEW_VS_BINDING_TABLE),
    DEFINE_BIT(BRW_NEW_GS_BINDING_TABLE),
    DEFINE_BIT(BRW_NEW_PS_BINDING_TABLE),
+   DEFINE_BIT(BRW_NEW_STATE_BASE_ADDRESS),
    {0, 0, 0}
 };
 
index 7b9cdba..e1947d5 100644 (file)
 /** 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;   
-};
-
 /* These seem to be passed around as function args, so it works out
  * better to keep them as #defines:
  */
@@ -88,314 +48,6 @@ struct brw_3d_control
 #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_slope: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
@@ -428,102 +80,6 @@ struct brw_urb_fence
    } 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:
  */
 
@@ -1327,12 +883,6 @@ struct brw_vertex_element_state
 
 #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;
index f462f32..46a417a 100644 (file)
@@ -60,7 +60,7 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
           * given in Volume 1 of the BSpec.
           */
          h0 = ALIGN(mt->height0, align_h);
-         h1 = ALIGN(minify(h0), align_h);
+         h1 = ALIGN(minify(mt->height0), align_h);
          qpitch = (h0 + h1 + (intel->gen >= 7 ? 12 : 11) * align_h);
           if (mt->compressed)
             qpitch /= 4;
index 80d5e78..a9ad531 100644 (file)
@@ -105,12 +105,11 @@ static void do_vs_prog( struct brw_context *brw,
    /* constant_map */
    aux_size += c.vp->program.Base.Parameters->NumParameters;
 
-   drm_intel_bo_unreference(brw->vs.prog_bo);
-   brw->vs.prog_bo = brw_upload_cache(&brw->cache, BRW_VS_PROG,
-                                     &c.key, sizeof(c.key),
-                                     program, program_size,
-                                     &c.prog_data, aux_size,
-                                     &brw->vs.prog_data);
+   brw_upload_cache(&brw->cache, BRW_VS_PROG,
+                   &c.key, sizeof(c.key),
+                   program, program_size,
+                   &c.prog_data, aux_size,
+                   &brw->vs.prog_offset, &brw->vs.prog_data);
    ralloc_free(mem_ctx);
 }
 
@@ -153,14 +152,11 @@ static void brw_upload_vs_prog(struct brw_context *brw)
       }
    }
 
-   /* Make an early check for the key.
-    */
-   drm_intel_bo_unreference(brw->vs.prog_bo);
-   brw->vs.prog_bo = brw_search_cache(&brw->cache, BRW_VS_PROG,
-                                     &key, sizeof(key),
-                                     &brw->vs.prog_data);
-   if (brw->vs.prog_bo == NULL)
+   if (!brw_search_cache(&brw->cache, BRW_VS_PROG,
+                        &key, sizeof(key),
+                        &brw->vs.prog_offset, &brw->vs.prog_data)) {
       do_vs_prog(brw, vp, &key);
+   }
    brw->vs.constant_map = ((int8_t *)brw->vs.prog_data +
                           sizeof(*brw->vs.prog_data));
 }
index 9fdfebe..47cc0a7 100644 (file)
@@ -194,19 +194,11 @@ static void calc_wm_input_sizes( struct brw_context *brw )
    /* BRW_NEW_VERTEX_PROGRAM */
    const struct brw_vertex_program *vp =
       brw_vertex_program_const(brw->vertex_program);
-   /* BRW_NEW_FRAGMENT_PROGRAM */
-   struct gl_shader_program *prog = ctx->Shader.CurrentFragmentProgram;
    /* BRW_NEW_INPUT_DIMENSIONS */
    struct tracker t;
    GLuint insn;
    GLuint i;
 
-   /* If we're going to go through brw_fs.cpp, we don't end up using
-    * brw->wm.input_size_masks.
-    */
-   if (prog && prog->_LinkedShaders[MESA_SHADER_FRAGMENT])
-      return;
-
    memset(&t, 0, sizeof(t));
 
    /* _NEW_LIGHT */
@@ -246,9 +238,7 @@ static void calc_wm_input_sizes( struct brw_context *brw )
 const struct brw_tracked_state brw_wm_input_sizes = {
    .dirty = {
       .mesa  = _NEW_LIGHT,
-      .brw   = (BRW_NEW_FRAGMENT_PROGRAM |
-               BRW_NEW_VERTEX_PROGRAM |
-               BRW_NEW_INPUT_DIMENSIONS),
+      .brw   = BRW_NEW_VERTEX_PROGRAM | BRW_NEW_INPUT_DIMENSIONS,
       .cache = 0
    },
    .prepare = calc_wm_input_sizes
index 2fa04a1..dbabb44 100644 (file)
@@ -1635,7 +1635,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
            else
               m = brw_message_reg(4);
 
-           brw_DP4(p, brw_writemask(m, (1 << (i & 7))),pos, c->userplane[i]);
+           brw_DP4(p, brw_writemask(m, (1 << (i & 3))),pos, c->userplane[i]);
         }
       }
    } else if ((c->prog_data.outputs_written &
@@ -1821,6 +1821,9 @@ accumulator_contains(struct brw_vs_compile *c, struct brw_reg val)
    if (val.address_mode != BRW_ADDRESS_DIRECT)
       return GL_FALSE;
 
+   if (val.negate || val.abs)
+      return GL_FALSE;
+
    switch (prev_insn->header.opcode) {
    case BRW_OPCODE_MOV:
    case BRW_OPCODE_MAC:
@@ -1980,9 +1983,22 @@ void brw_vs_emit(struct brw_vs_compile *c )
              const struct prog_src_register *src = &inst->SrcReg[i];
              index = src->Index;
              file = src->File; 
-             if (file == PROGRAM_OUTPUT && c->output_regs[index].used_in_src)
-                 args[i] = c->output_regs[index].reg;
-             else
+             if (file == PROGRAM_OUTPUT && c->output_regs[index].used_in_src) {
+                /* Can't just make get_arg "do the right thing" here because
+                 * other callers of get_arg and get_src_reg don't expect any
+                 * special behavior for the c->output_regs[index].used_in_src
+                 * case.
+                 */
+                args[i] = c->output_regs[index].reg;
+                args[i].dw1.bits.swizzle =
+                   BRW_SWIZZLE4(GET_SWZ(src->Swizzle, 0),
+                                GET_SWZ(src->Swizzle, 1),
+                                GET_SWZ(src->Swizzle, 2),
+                                GET_SWZ(src->Swizzle, 3));
+
+                /* Note this is ok for non-swizzle ARB_vp instructions */
+                args[i].negate = src->Negate ? 1 : 0;
+             } else
                   args[i] = get_arg(c, inst, i);
          }
 
@@ -1993,7 +2009,11 @@ void brw_vs_emit(struct brw_vs_compile *c )
       index = inst->DstReg.Index;
       file = inst->DstReg.File;
       if (file == PROGRAM_OUTPUT && c->output_regs[index].used_in_src)
-         dst = c->output_regs[index].reg;
+        /* Can't just make get_dst "do the right thing" here because other
+         * callers of get_dst don't expect any special behavior for the
+         * c->output_regs[index].used_in_src case.
+         */
+        dst = brw_writemask(c->output_regs[index].reg, inst->DstReg.WriteMask);
       else
          dst = get_dst(c, inst->DstReg);
 
index 1eee5b7..fc4373a 100644 (file)
 #include "brw_defines.h"
 #include "main/macros.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
 brw_prepare_vs_unit(struct brw_context *brw)
 {
@@ -55,12 +43,19 @@ brw_prepare_vs_unit(struct brw_context *brw)
    struct gl_context *ctx = &intel->ctx;
    struct brw_vs_unit_state *vs;
 
-   vs = brw_state_batch(brw, sizeof(*vs), 32, &brw->vs.state_offset);
+   vs = brw_state_batch(brw, AUB_TRACE_VS_STATE,
+                       sizeof(*vs), 32, &brw->vs.state_offset);
    memset(vs, 0, sizeof(*vs));
 
-   /* CACHE_NEW_VS_PROG */
-   vs->thread0.kernel_start_pointer = brw->vs.prog_bo->offset >> 6; /* reloc */
+   /* BRW_NEW_PROGRAM_CACHE | CACHE_NEW_VS_PROG */
    vs->thread0.grf_reg_count = ALIGN(brw->vs.prog_data->total_grf, 16) / 16 - 1;
+   vs->thread0.kernel_start_pointer =
+      brw_program_reloc(brw,
+                       brw->vs.state_offset +
+                       offsetof(struct brw_vs_unit_state, thread0),
+                       brw->vs.prog_offset +
+                       (vs->thread0.grf_reg_count << 1)) >> 6;
+
    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,
@@ -152,13 +147,6 @@ brw_prepare_vs_unit(struct brw_context *brw)
     */
    vs->vs6.vs_enable = 1;
 
-   /* Emit VS program relocation */
-   drm_intel_bo_emit_reloc(intel->batch.bo, (brw->vs.state_offset +
-                                            offsetof(struct brw_vs_unit_state,
-                                                     thread0)),
-                          brw->vs.prog_bo, vs->thread0.grf_reg_count << 1,
-                          I915_GEM_DOMAIN_INSTRUCTION, 0);
-
    brw->state.dirty.cache |= CACHE_NEW_VS_UNIT;
 }
 
@@ -166,6 +154,7 @@ const struct brw_tracked_state brw_vs_unit = {
    .dirty = {
       .mesa  = _NEW_TRANSFORM,
       .brw   = (BRW_NEW_BATCH |
+               BRW_NEW_PROGRAM_CACHE |
                BRW_NEW_CURBE_OFFSETS |
                 BRW_NEW_NR_VS_SURFACES |
                BRW_NEW_URB_FENCE),
index 611f633..f9ee4d1 100644 (file)
@@ -182,7 +182,8 @@ static void upload_vs_surfaces(struct brw_context *brw)
    /* Might want to calculate nr_surfaces first, to avoid taking up so much
     * space for the binding table. (once we have vs samplers)
     */
-   bind = brw_state_batch(brw, sizeof(uint32_t) * BRW_VS_MAX_SURF,
+   bind = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         sizeof(uint32_t) * BRW_VS_MAX_SURF,
                          32, &brw->vs.bind_bo_offset);
 
    for (i = 0; i < BRW_VS_MAX_SURF; i++) {
index 69650e1..40360b2 100644 (file)
 #include "main/imports.h"
 #include "main/macros.h"
 #include "main/colormac.h"
+#include "main/renderbuffer.h"
+#include "main/framebuffer.h"
 
 #include "intel_batchbuffer.h" 
 #include "intel_regions.h" 
+#include "intel_fbo.h"
 
 #include "brw_context.h"
 #include "brw_defines.h"
@@ -69,30 +72,108 @@ static void brw_destroy_context( struct intel_context *intel )
    ralloc_free(brw->wm.compile_data);
 
    dri_bo_release(&brw->curbe.curbe_bo);
-   dri_bo_release(&brw->vs.prog_bo);
    dri_bo_release(&brw->vs.const_bo);
-   dri_bo_release(&brw->gs.prog_bo);
-   dri_bo_release(&brw->clip.prog_bo);
-   dri_bo_release(&brw->sf.prog_bo);
-   dri_bo_release(&brw->wm.prog_bo);
    dri_bo_release(&brw->wm.const_bo);
-   dri_bo_release(&brw->cc.prog_bo);
 
    free(brw->curbe.last_buf);
    free(brw->curbe.next_buf);
 }
 
-
 /**
- * called from intelDrawBuffer()
+ * Update the hardware state for drawing into a window or framebuffer object.
+ *
+ * Called by glDrawBuffer, glBindFramebufferEXT, MakeCurrent, and other
+ * places within the driver.
+ *
+ * Basically, this needs to be called any time the current framebuffer
+ * changes, the renderbuffers change, or we need to draw into different
+ * color buffers.
  */
-static void brw_set_draw_region( struct intel_context *intel, 
-                                 struct intel_region *color_regions[],
-                                 struct intel_region *depth_region,
-                                 GLuint num_color_regions)
+static void
+brw_update_draw_buffer(struct intel_context *intel)
 {
-}
+   struct gl_context *ctx = &intel->ctx;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
+   bool fb_has_hiz = intel_framebuffer_has_hiz(fb);
+
+   if (!fb) {
+      /* this can happen during the initial context initialization */
+      return;
+   }
 
+   /*
+    * If intel_context is using separate stencil, but the depth attachment
+    * (gl_framebuffer.Attachment[BUFFER_DEPTH]) has a packed depth/stencil
+    * format, then we must install the real depth buffer at fb->_DepthBuffer
+    * and set fb->_DepthBuffer->Wrapped before calling _mesa_update_framebuffer.
+    * Otherwise, _mesa_update_framebuffer will create and install a swras
+    * depth wrapper instead.
+    *
+    * Ditto for stencil.
+    */
+   irbDepth = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+   if (irbDepth && irbDepth->Base.Format == MESA_FORMAT_X8_Z24) {
+      _mesa_reference_renderbuffer(&fb->_DepthBuffer, &irbDepth->Base);
+      irbDepth->Base.Wrapped = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+   }
+
+   irbStencil = intel_get_renderbuffer(fb, BUFFER_STENCIL);
+   if (irbStencil && irbStencil->Base.Format == MESA_FORMAT_S8) {
+      _mesa_reference_renderbuffer(&fb->_StencilBuffer, &irbStencil->Base);
+      irbStencil->Base.Wrapped = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+   }
+
+   /* Do this here, not core Mesa, since this function is called from
+    * many places within the driver.
+    */
+   if (ctx->NewState & _NEW_BUFFERS) {
+      /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
+      _mesa_update_framebuffer(ctx);
+      /* this updates the DrawBuffer's Width/Height if it's a FBO */
+      _mesa_update_draw_buffer_bounds(ctx);
+   }
+
+   if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      /* this may occur when we're called by glBindFrameBuffer() during
+       * the process of someone setting up renderbuffers, etc.
+       */
+      /*_mesa_debug(ctx, "DrawBuffer: incomplete user FBO\n");*/
+      return;
+   }
+
+   /* Check some stencil invariants.  These should probably be in
+    * emit_depthbuffer().
+    */
+   if (irbStencil && irbStencil->region) {
+      if (!intel->has_separate_stencil)
+        assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
+      if (fb_has_hiz || intel->must_use_separate_stencil)
+        assert(irbStencil->Base.Format == MESA_FORMAT_S8);
+      if (irbStencil->Base.Format == MESA_FORMAT_S8)
+        assert(intel->has_separate_stencil);
+   }
+
+   /* Mesa's Stencil._Enabled field is updated when
+    * _NEW_BUFFERS | _NEW_STENCIL, but i965 code assumes that the value
+    * only changes with _NEW_STENCIL (which seems sensible).  So flag it
+    * here since this is the _NEW_BUFFERS path.
+    */
+   intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL);
+
+   /* The driver uses this in places that need to look up
+    * renderbuffers' buffer objects.
+    */
+   intel->NewGLState |= _NEW_BUFFERS;
+
+   /* update viewport/scissor since it depends on window size */
+   intel->NewGLState |= _NEW_VIEWPORT | _NEW_SCISSOR;
+
+   /* Update culling direction which changes depending on the
+    * orientation of the buffer:
+    */
+   intel->NewGLState |= _NEW_POLYGON;
+}
 
 /**
  * called from intel_batchbuffer_flush and children before sending a
@@ -122,13 +203,23 @@ static void brw_new_batch( struct intel_context *intel )
     * 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.brw |= BRW_NEW_CONTEXT | BRW_NEW_BATCH;
 
-   brw->state.dirty.mesa |= ~0;
-   brw->state.dirty.brw |= ~0;
-   brw->state.dirty.cache |= ~0;
+   /* Assume that the last command before the start of our batch was a
+    * primitive, for safety.
+    */
+   intel->batch.need_workaround_flush = true;
+
+   brw->state_batch_count = 0;
 
    brw->vb.nr_current_buffers = 0;
+   brw->ib.type = -1;
+
+   /* Mark that the current program cache BO has been used by the GPU.
+    * It will be reallocated if we need to put new programs in for the
+    * next batch.
+    */
+   brw->cache.bo_used_by_gpu = true;
 }
 
 static void brw_invalidate_state( struct intel_context *intel, GLuint new_state )
@@ -159,7 +250,7 @@ void brwInitVtbl( struct brw_context *brw )
    brw->intel.vtbl.new_batch = brw_new_batch;
    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.update_draw_buffer = brw_update_draw_buffer;
    brw->intel.vtbl.debug_batch = brw_debug_batch;
    brw->intel.vtbl.render_target_supported = brw_render_target_supported;
    brw->intel.vtbl.is_hiz_depth_format = brw_is_hiz_depth_format;
index 1aebd12..b0dfdd5 100644 (file)
@@ -273,12 +273,11 @@ bool do_wm_prog(struct brw_context *brw,
     */
    program = brw_get_program(&c->func, &program_size);
 
-   drm_intel_bo_unreference(brw->wm.prog_bo);
-   brw->wm.prog_bo = brw_upload_cache(&brw->cache, BRW_WM_PROG,
-                                     &c->key, sizeof(c->key),
-                                     program, program_size,
-                                     &c->prog_data, sizeof(c->prog_data),
-                                     &brw->wm.prog_data);
+   brw_upload_cache(&brw->cache, BRW_WM_PROG,
+                   &c->key, sizeof(c->key),
+                   program, program_size,
+                   &c->prog_data, sizeof(c->prog_data),
+                   &brw->wm.prog_offset, &brw->wm.prog_data);
 
    return true;
 }
@@ -389,6 +388,8 @@ static void brw_wm_populate_key( struct brw_context *brw,
          * all 4 channels.
          */
         if (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+           key->compare_funcs[i] = sampler->CompareFunc;
+
            if (sampler->DepthMode == GL_ALPHA) {
               swizzles[0] = SWIZZLE_ZERO;
               swizzles[1] = SWIZZLE_ZERO;
@@ -477,13 +478,9 @@ static void brw_prepare_wm_prog(struct brw_context *brw)
 
    brw_wm_populate_key(brw, &key);
 
-   /* Make an early check for the key.
-    */
-   drm_intel_bo_unreference(brw->wm.prog_bo);
-   brw->wm.prog_bo = brw_search_cache(&brw->cache, BRW_WM_PROG,
-                                     &key, sizeof(key),
-                                     &brw->wm.prog_data);
-   if (brw->wm.prog_bo == NULL) {
+   if (!brw_search_cache(&brw->cache, BRW_WM_PROG,
+                        &key, sizeof(key),
+                        &brw->wm.prog_offset, &brw->wm.prog_data)) {
       bool success = do_wm_prog(brw, ctx->Shader.CurrentFragmentProgram, fp,
                                &key);
       assert(success);
index e244b55..29082c1 100644 (file)
@@ -68,6 +68,18 @@ struct brw_wm_prog_key {
    GLuint clamp_fragment_color:1;
    GLuint line_aa:2;
 
+   /**
+    * Per-sampler comparison functions:
+    *
+    * If comparison mode is GL_COMPARE_R_TO_TEXTURE, then this is set to one
+    * of GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL,
+    * GL_GEQUAL, or GL_ALWAYS.  Otherwise (comparison mode is GL_NONE), this
+    * field is irrelevant so it's left as GL_NONE (0).
+    *
+    * While this is a GLenum, all possible values fit in 16-bits.
+    */
+   uint16_t compare_funcs[BRW_MAX_TEX_UNIT];
+
    GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */
    GLuint yuvtex_mask:16;
    GLuint yuvtex_swap_mask:16; /* UV swaped */
index f61757a..6ea4a7d 100644 (file)
@@ -1094,9 +1094,16 @@ void emit_tex(struct brw_wm_compile *c,
    if (intel->gen < 5 && c->dispatch_width == 8)
       nr_texcoords = 3;
 
-   /* For shadow comparisons, we have to supply u,v,r. */
-   if (shadow)
-      nr_texcoords = 3;
+   if (shadow) {
+      if (intel->gen < 7) {
+        /* For shadow comparisons, we have to supply u,v,r. */
+        nr_texcoords = 3;
+      } else {
+        /* On Ivybridge, the shadow comparitor comes first. Just load it. */
+        brw_MOV(p, brw_message_reg(cur_mrf), arg[2]);
+        cur_mrf += mrf_per_channel;
+      }
+   }
 
    /* Emit the texcoords. */
    for (i = 0; i < nr_texcoords; i++) {
@@ -1113,7 +1120,7 @@ void emit_tex(struct brw_wm_compile *c,
    }
 
    /* Fill in the shadow comparison reference value. */
-   if (shadow) {
+   if (shadow && intel->gen < 7) {
       if (intel->gen >= 5) {
         /* Fill in the cube map array index value. */
         brw_MOV(p, brw_message_reg(cur_mrf), brw_imm_f(0));
index 59dcda7..7cd3eda 100644 (file)
@@ -563,13 +563,14 @@ static void precalc_dst( struct brw_wm_compile *c,
    struct prog_src_register src0 = inst->SrcReg[0];
    struct prog_src_register src1 = inst->SrcReg[1];
    struct prog_dst_register dst = inst->DstReg;
-   
+   struct prog_dst_register temp = get_temp(c);
+
    if (dst.WriteMask & WRITEMASK_Y) {      
       /* dst.y = mul src0.y, src1.y
        */
       emit_op(c,
              OPCODE_MUL,
-             dst_mask(dst, WRITEMASK_Y),
+             dst_mask(temp, WRITEMASK_Y),
              inst->SaturateMode,
              src0,
              src1,
@@ -584,7 +585,7 @@ static void precalc_dst( struct brw_wm_compile *c,
        */
       swz = emit_op(c,
                    OPCODE_SWZ,
-                   dst_mask(dst, WRITEMASK_XZ),
+                   dst_mask(temp, WRITEMASK_XZ),
                    inst->SaturateMode,
                    src_swizzle(src0, SWIZZLE_ONE, z, z, z),
                    src_undef(),
@@ -597,12 +598,26 @@ static void precalc_dst( struct brw_wm_compile *c,
        */
       emit_op(c,
              OPCODE_MOV,
-             dst_mask(dst, WRITEMASK_W),
+             dst_mask(temp, WRITEMASK_W),
              inst->SaturateMode,
              src1,
              src_undef(),
              src_undef());
    }
+
+   /* This will get optimized out in general, but it ensures that we
+    * don't overwrite src operands in our channel-wise splitting
+    * above.  See piglit fp-dst-aliasing-[12].
+    */
+   emit_op(c,
+          OPCODE_MOV,
+          dst,
+          0,
+          src_reg_from_dst(temp),
+          src_undef(),
+          src_undef());
+
+   release_temp(c, temp);
 }
 
 
@@ -611,7 +626,17 @@ static void precalc_lit( struct brw_wm_compile *c,
 {
    struct prog_src_register src0 = inst->SrcReg[0];
    struct prog_dst_register dst = inst->DstReg;
-   
+
+   if (dst.WriteMask & WRITEMASK_YZ) {
+      emit_op(c,
+             OPCODE_LIT,
+             dst_mask(dst, WRITEMASK_YZ),
+             inst->SaturateMode,
+             src0,
+             src_undef(),
+             src_undef());
+   }
+
    if (dst.WriteMask & WRITEMASK_XW) {
       struct prog_instruction *swz;
 
@@ -627,16 +652,6 @@ static void precalc_lit( struct brw_wm_compile *c,
       /* Avoid letting the negation flag of src0 affect our 1 constant. */
       swz->SrcReg[0].Negate = NEGATE_NONE;
    }
-
-   if (dst.WriteMask & WRITEMASK_YZ) {
-      emit_op(c,
-             OPCODE_LIT,
-             dst_mask(dst, WRITEMASK_YZ),
-             inst->SaturateMode,
-             src0,
-             src_undef(),
-             src_undef());
-   }
 }
 
 
index 5de39aa..9814613 100644 (file)
@@ -108,7 +108,8 @@ upload_default_color(struct brw_context *brw, struct gl_sampler_object *sampler,
    if (intel->gen == 5 || intel->gen == 6) {
       struct gen5_sampler_default_color *sdc;
 
-      sdc = brw_state_batch(brw, sizeof(*sdc), 32, &brw->wm.sdc_offset[unit]);
+      sdc = brw_state_batch(brw, AUB_TRACE_SAMPLER_DEFAULT_COLOR,
+                           sizeof(*sdc), 32, &brw->wm.sdc_offset[unit]);
 
       memset(sdc, 0, sizeof(*sdc));
 
@@ -144,7 +145,8 @@ upload_default_color(struct brw_context *brw, struct gl_sampler_object *sampler,
    } else {
       struct brw_sampler_default_color *sdc;
 
-      sdc = brw_state_batch(brw, sizeof(*sdc), 32, &brw->wm.sdc_offset[unit]);
+      sdc = brw_state_batch(brw, AUB_TRACE_SAMPLER_DEFAULT_COLOR,
+                           sizeof(*sdc), 32, &brw->wm.sdc_offset[unit]);
 
       COPY_4V(sdc->color, color);
    }
@@ -326,7 +328,8 @@ prepare_wm_samplers(struct brw_context *brw)
    if (brw->wm.sampler_count == 0)
       return;
 
-   samplers = brw_state_batch(brw, brw->wm.sampler_count * sizeof(*samplers),
+   samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
+                             brw->wm.sampler_count * sizeof(*samplers),
                              32, &brw->wm.sampler_offset);
    memset(samplers, 0, brw->wm.sampler_count * sizeof(*samplers));
 
index ef98f81..c820ce4 100644 (file)
@@ -78,7 +78,8 @@ brw_prepare_wm_unit(struct brw_context *brw)
    const struct gl_fragment_program *fp = brw->fragment_program;
    struct brw_wm_unit_state *wm;
 
-   wm = brw_state_batch(brw, sizeof(*wm), 32, &brw->wm.state_offset);
+   wm = brw_state_batch(brw, AUB_TRACE_WM_STATE,
+                       sizeof(*wm), 32, &brw->wm.state_offset);
    memset(wm, 0, sizeof(*wm));
 
    if (brw->wm.prog_data->prog_offset_16) {
@@ -90,13 +91,25 @@ brw_prepare_wm_unit(struct brw_context *brw)
             brw->wm.prog_data->first_curbe_grf_16);
    }
 
-   /* CACHE_NEW_WM_PROG */
+   /* BRW_NEW_PROGRAM_CACHE | CACHE_NEW_WM_PROG */
    wm->thread0.grf_reg_count = brw->wm.prog_data->reg_blocks;
    wm->wm9.grf_reg_count_2 = brw->wm.prog_data->reg_blocks_16;
-   wm->thread0.kernel_start_pointer = brw->wm.prog_bo->offset >> 6; /* reloc */
-   /* reloc */
-   wm->wm9.kernel_start_pointer_2 = (brw->wm.prog_bo->offset +
-                                    brw->wm.prog_data->prog_offset_16) >> 6;
+
+   wm->thread0.kernel_start_pointer =
+      brw_program_reloc(brw,
+                       brw->wm.state_offset +
+                       offsetof(struct brw_wm_unit_state, thread0),
+                       brw->wm.prog_offset +
+                       (wm->thread0.grf_reg_count << 1)) >> 6;
+
+   wm->wm9.kernel_start_pointer_2 =
+      brw_program_reloc(brw,
+                       brw->wm.state_offset +
+                       offsetof(struct brw_wm_unit_state, wm9),
+                       brw->wm.prog_offset +
+                       brw->wm.prog_data->prog_offset_16 +
+                       (wm->wm9.grf_reg_count_2 << 1)) >> 6;
+
    wm->thread1.depth_coef_urb_read_offset = 1;
    wm->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
 
@@ -214,23 +227,6 @@ brw_prepare_wm_unit(struct brw_context *brw)
    if (unlikely(INTEL_DEBUG & DEBUG_STATS) || intel->stats_wm)
       wm->wm4.stats_enable = 1;
 
-   /* Emit WM program relocation */
-   drm_intel_bo_emit_reloc(intel->batch.bo,
-                          brw->wm.state_offset +
-                          offsetof(struct brw_wm_unit_state, thread0),
-                          brw->wm.prog_bo, wm->thread0.grf_reg_count << 1,
-                          I915_GEM_DOMAIN_INSTRUCTION, 0);
-
-   if (brw->wm.prog_data->prog_offset_16) {
-      drm_intel_bo_emit_reloc(intel->batch.bo,
-                             brw->wm.state_offset +
-                             offsetof(struct brw_wm_unit_state, wm9),
-                             brw->wm.prog_bo,
-                             ((wm->wm9.grf_reg_count_2 << 1) +
-                              brw->wm.prog_data->prog_offset_16),
-                             I915_GEM_DOMAIN_INSTRUCTION, 0);
-   }
-
    /* Emit scratch space relocation */
    if (brw->wm.prog_data->total_scratch != 0) {
       drm_intel_bo_emit_reloc(intel->batch.bo,
@@ -265,6 +261,7 @@ const struct brw_tracked_state brw_wm_unit = {
               _NEW_BUFFERS),
 
       .brw = (BRW_NEW_BATCH |
+             BRW_NEW_PROGRAM_CACHE |
              BRW_NEW_FRAGMENT_PROGRAM |
              BRW_NEW_CURBE_OFFSETS |
              BRW_NEW_NR_WM_SURFACES),
index ac8005d..fb4fb14 100644 (file)
@@ -73,7 +73,7 @@ translate_tex_target(GLenum target)
 uint32_t
 brw_format_for_mesa_format(gl_format mesa_format)
 {
-   uint32_t table[MESA_FORMAT_COUNT] =
+   static const uint32_t table[MESA_FORMAT_COUNT] =
    {
       [MESA_FORMAT_L8] = BRW_SURFACEFORMAT_L8_UNORM,
       [MESA_FORMAT_I8] = BRW_SURFACEFORMAT_I8_UNORM,
@@ -226,7 +226,8 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
    const GLuint surf_index = SURF_INDEX_TEXTURE(unit);
    uint32_t *surf;
 
-   surf = brw_state_batch(brw, 6 * 4, 32, &brw->wm.surf_offset[surf_index]);
+   surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         6 * 4, 32, &brw->wm.surf_offset[surf_index]);
 
    surf[0] = (translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
              BRW_SURFACE_MIPMAPLAYOUT_BELOW << BRW_SURFACE_MIPLAYOUT_SHIFT |
@@ -272,7 +273,8 @@ brw_create_constant_surface(struct brw_context *brw,
    const GLint w = width - 1;
    uint32_t *surf;
 
-   surf = brw_state_batch(brw, 6 * 4, 32, out_offset);
+   surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         6 * 4, 32, out_offset);
 
    surf[0] = (BRW_SURFACE_BUFFER << BRW_SURFACE_TYPE_SHIFT |
              BRW_SURFACE_MIPMAPLAYOUT_BELOW << BRW_SURFACE_MIPLAYOUT_SHIFT |
@@ -404,7 +406,8 @@ brw_update_null_renderbuffer_surface(struct brw_context *brw, unsigned int unit)
    struct intel_context *intel = &brw->intel;
    uint32_t *surf;
 
-   surf = brw_state_batch(brw, 6 * 4, 32, &brw->wm.surf_offset[unit]);
+   surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         6 * 4, 32, &brw->wm.surf_offset[unit]);
 
    surf[0] = (BRW_SURFACE_NULL << BRW_SURFACE_TYPE_SHIFT |
              BRW_SURFACEFORMAT_B8G8R8A8_UNORM << BRW_SURFACE_FORMAT_SHIFT);
@@ -439,7 +442,8 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
    uint32_t tile_x, tile_y;
    uint32_t format = 0;
 
-   surf = brw_state_batch(brw, 6 * 4, 32, &brw->wm.surf_offset[unit]);
+   surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         6 * 4, 32, &brw->wm.surf_offset[unit]);
 
    switch (irb->Base.Format) {
    case MESA_FORMAT_XRGB8888:
@@ -637,7 +641,8 @@ brw_wm_upload_binding_table(struct brw_context *brw)
    /* Might want to calculate nr_surfaces first, to avoid taking up so much
     * space for the binding table.
     */
-   bind = brw_state_batch(brw, sizeof(uint32_t) * BRW_WM_MAX_SURF,
+   bind = brw_state_batch(brw, AUB_TRACE_BINDING_TABLE,
+                         sizeof(uint32_t) * BRW_WM_MAX_SURF,
                          32, &brw->wm.bind_bo_offset);
 
    for (i = 0; i < BRW_WM_MAX_SURF; i++) {
index 2b16d6c..41d13ad 100644 (file)
@@ -51,7 +51,8 @@ prepare_blend_state(struct brw_context *brw)
       nr_draw_buffers = 1;
 
    size = sizeof(*blend) * nr_draw_buffers;
-   blend = brw_state_batch(brw, size, 64, &brw->cc.blend_state_offset);
+   blend = brw_state_batch(brw, AUB_TRACE_BLEND_STATE,
+                          size, 64, &brw->cc.blend_state_offset);
 
    memset(blend, 0, size);
 
@@ -139,7 +140,8 @@ gen6_prepare_color_calc_state(struct brw_context *brw)
    struct gl_context *ctx = &brw->intel.ctx;
    struct gen6_color_calc_state *cc;
 
-   cc = brw_state_batch(brw, sizeof(*cc), 64, &brw->cc.state_offset);
+   cc = brw_state_batch(brw, AUB_TRACE_CC_STATE,
+                       sizeof(*cc), 64, &brw->cc.state_offset);
    memset(cc, 0, sizeof(*cc));
 
    /* _NEW_COLOR */
@@ -183,7 +185,8 @@ static void upload_cc_state_pointers(struct brw_context *brw)
 const struct brw_tracked_state gen6_cc_state_pointers = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_BATCH,
+      .brw = (BRW_NEW_BATCH |
+             BRW_NEW_STATE_BASE_ADDRESS),
       .cache = (CACHE_NEW_BLEND_STATE |
                CACHE_NEW_COLOR_CALC_STATE |
                CACHE_NEW_DEPTH_STENCIL_STATE)
index 775e1ce..5d14147 100644 (file)
@@ -34,7 +34,8 @@ gen6_prepare_depth_stencil_state(struct brw_context *brw)
    struct gl_context *ctx = &brw->intel.ctx;
    struct gen6_depth_stencil_state *ds;
 
-   ds = brw_state_batch(brw, sizeof(*ds), 64,
+   ds = brw_state_batch(brw, AUB_TRACE_DEPTH_STENCIL_STATE,
+                       sizeof(*ds), 64,
                        &brw->cc.depth_stencil_state_offset);
    memset(ds, 0, sizeof(*ds));
 
index c1d0a73..d29f029 100644 (file)
@@ -45,7 +45,7 @@ upload_gs_state(struct brw_context *brw)
    ADVANCE_BATCH();
 
    // GS should never be used on Gen6.  Disable it.
-   assert(brw->gs.prog_bo == NULL);
+   assert(!brw->gs.prog_active);
    BEGIN_BATCH(7);
    OUT_BATCH(_3DSTATE_GS << 16 | (7 - 2));
    OUT_BATCH(0); /* prog_bo */
@@ -65,8 +65,7 @@ upload_gs_state(struct brw_context *brw)
 const struct brw_tracked_state gen6_gs_state = {
    .dirty = {
       .mesa  = _NEW_TRANSFORM,
-      .brw   = (BRW_NEW_CURBE_OFFSETS |
-               BRW_NEW_URB_FENCE |
+      .brw   = (BRW_NEW_URB_FENCE |
                BRW_NEW_CONTEXT),
       .cache = CACHE_NEW_GS_PROG
    },
index 4cdec69..8932687 100644 (file)
@@ -50,7 +50,8 @@ upload_sampler_state_pointers(struct brw_context *brw)
 const struct brw_tracked_state gen6_sampler_state = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_BATCH,
+      .brw = (BRW_NEW_BATCH |
+             BRW_NEW_STATE_BASE_ADDRESS),
       .cache = CACHE_NEW_SAMPLER
    },
    .emit = upload_sampler_state_pointers,
index fad3ca0..dc73b10 100644 (file)
@@ -31,7 +31,7 @@
 #include "intel_batchbuffer.h"
 
 static void
-gen6_prepare_scissor_state(struct brw_context *brw)
+gen6_upload_scissor_state(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
    struct gl_context *ctx = &intel->ctx;
@@ -39,7 +39,8 @@ gen6_prepare_scissor_state(struct brw_context *brw)
    struct gen6_scissor_rect *scissor;
    uint32_t scissor_state_offset;
 
-   scissor = brw_state_batch(brw, sizeof(*scissor), 32, &scissor_state_offset);
+   scissor = brw_state_batch(brw, AUB_TRACE_SCISSOR_STATE,
+                            sizeof(*scissor), 32, &scissor_state_offset);
 
    /* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT */
 
@@ -89,5 +90,5 @@ const struct brw_tracked_state gen6_scissor_state = {
       .brw = BRW_NEW_BATCH,
       .cache = 0,
    },
-   .prepare = gen6_prepare_scissor_state,
+   .emit = gen6_upload_scissor_state,
 };
index 62645a6..b410511 100644 (file)
@@ -64,7 +64,7 @@ upload_urb(struct brw_context *brw)
    assert(brw->urb.nr_vs_entries % 4 == 0);
    assert(brw->urb.nr_gs_entries % 4 == 0);
    /* GS requirement */
-   assert(!brw->gs.prog_bo || brw->urb.vs_size < 5);
+   assert(!brw->gs.prog_active || brw->urb.vs_size < 5);
 
    BEGIN_BATCH(3);
    OUT_BATCH(_3DSTATE_URB << 16 | (3 - 2));
index 4116bdb..a4bfa54 100644 (file)
@@ -43,7 +43,8 @@ prepare_clip_vp(struct brw_context *brw)
 {
    struct brw_clipper_viewport *vp;
 
-   vp = brw_state_batch(brw, sizeof(*vp), 32, &brw->clip.vp_offset);
+   vp = brw_state_batch(brw, AUB_TRACE_CLIP_VP_STATE,
+                       sizeof(*vp), 32, &brw->clip.vp_offset);
 
    vp->xmin = -1.0;
    vp->xmax = 1.0;
@@ -72,7 +73,8 @@ prepare_sf_vp(struct brw_context *brw)
    const GLboolean render_to_fbo = (ctx->DrawBuffer->Name != 0);
    const GLfloat *v = ctx->Viewport._WindowMap.m;
 
-   sfv = brw_state_batch(brw, sizeof(*sfv), 32, &brw->sf.vp_offset);
+   sfv = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
+                        sizeof(*sfv), 32, &brw->sf.vp_offset);
    memset(sfv, 0, sizeof(*sfv));
 
    /* _NEW_BUFFERS */
@@ -122,7 +124,8 @@ static void upload_viewport_state_pointers(struct brw_context *brw)
 const struct brw_tracked_state gen6_viewport_state = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_BATCH,
+      .brw = (BRW_NEW_BATCH |
+             BRW_NEW_STATE_BASE_ADDRESS),
       .cache = (CACHE_NEW_CLIP_VP |
                CACHE_NEW_SF_VP |
                CACHE_NEW_CC_VP)
index b46368e..e704544 100644 (file)
@@ -60,7 +60,7 @@ gen6_prepare_vs_push_constants(struct brw_context *brw)
       float *param;
       int i;
 
-      param = brw_state_batch(brw,
+      param = brw_state_batch(brw, AUB_TRACE_VS_CONSTANTS,
                              (MAX_CLIP_PLANES + nr_params) *
                              4 * sizeof(float),
                              32, &brw->vs.push_const_offset);
@@ -110,7 +110,7 @@ const struct brw_tracked_state gen6_vs_constants = {
       .mesa  = _NEW_TRANSFORM | _NEW_PROGRAM_CONSTANTS,
       .brw   = (BRW_NEW_BATCH |
                BRW_NEW_VERTEX_PROGRAM),
-      .cache = 0,
+      .cache = CACHE_NEW_VS_PROG,
    },
    .prepare = gen6_prepare_vs_push_constants,
 };
@@ -147,7 +147,7 @@ upload_vs_state(struct brw_context *brw)
 
    BEGIN_BATCH(6);
    OUT_BATCH(_3DSTATE_VS << 16 | (6 - 2));
-   OUT_RELOC(brw->vs.prog_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   OUT_BATCH(brw->vs.prog_offset);
    OUT_BATCH((0 << GEN6_VS_SAMPLER_COUNT_SHIFT) |
             GEN6_VS_FLOATING_POINT_MODE_ALT |
             (brw->vs.nr_surfaces << GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
@@ -160,13 +160,38 @@ upload_vs_state(struct brw_context *brw)
             GEN6_VS_STATISTICS_ENABLE |
             GEN6_VS_ENABLE);
    ADVANCE_BATCH();
+
+   /* Based on my reading of the simulator, the VS constants don't get
+    * pulled into the VS FF unit until an appropriate pipeline flush
+    * happens, and instead the 3DSTATE_CONSTANT_VS packet just adds
+    * references to them into a little FIFO.  The flushes are common,
+    * but don't reliably happen between this and a 3DPRIMITIVE, causing
+    * the primitive to use the wrong constants.  Then the FIFO
+    * containing the constant setup gets added to again on the next
+    * constants change, and eventually when a flush does happen the
+    * unit is overwhelmed by constant changes and dies.
+    *
+    * To avoid this, send a PIPE_CONTROL down the line that will
+    * update the unit immediately loading the constants.  The flush
+    * type bits here were those set by the STATE_BASE_ADDRESS whose
+    * move in a82a43e8d99e1715dd11c9c091b5ab734079b6a6 triggered the
+    * bug reports that led to this workaround, and may be more than
+    * what is strictly required to avoid the issue.
+    */
+   BEGIN_BATCH(4);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(PIPE_CONTROL_DEPTH_STALL |
+            PIPE_CONTROL_INSTRUCTION_FLUSH |
+            PIPE_CONTROL_STATE_CACHE_INVALIDATE);
+   OUT_BATCH(0); /* address */
+   OUT_BATCH(0); /* write data */
+   ADVANCE_BATCH();
 }
 
 const struct brw_tracked_state gen6_vs_state = {
    .dirty = {
       .mesa  = _NEW_TRANSFORM | _NEW_PROGRAM_CONSTANTS,
-      .brw   = (BRW_NEW_CURBE_OFFSETS |
-                BRW_NEW_NR_VS_SURFACES |
+      .brw   = (BRW_NEW_NR_VS_SURFACES |
                BRW_NEW_URB_FENCE |
                BRW_NEW_CONTEXT |
                BRW_NEW_VERTEX_PROGRAM |
index 43e651d..185da9c 100644 (file)
@@ -39,6 +39,7 @@ gen6_prepare_wm_push_constants(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
    struct gl_context *ctx = &intel->ctx;
+   /* BRW_NEW_FRAGMENT_PROGRAM */
    const struct brw_fragment_program *fp =
       brw_fragment_program_const(brw->fragment_program);
 
@@ -48,11 +49,12 @@ gen6_prepare_wm_push_constants(struct brw_context *brw)
    /* XXX: Should this happen somewhere before to get our state flag set? */
    _mesa_load_state_parameters(ctx, fp->program.Base.Parameters);
 
+   /* CACHE_NEW_VS_PROG */
    if (brw->wm.prog_data->nr_params != 0) {
       float *constants;
       unsigned int i;
 
-      constants = brw_state_batch(brw,
+      constants = brw_state_batch(brw, AUB_TRACE_NO_TYPE,
                                  brw->wm.prog_data->nr_params *
                                  sizeof(float),
                                  32, &brw->wm.push_const_offset);
@@ -83,7 +85,7 @@ const struct brw_tracked_state gen6_wm_constants = {
       .mesa  = _NEW_PROGRAM_CONSTANTS,
       .brw   = (BRW_NEW_BATCH |
                BRW_NEW_FRAGMENT_PROGRAM),
-      .cache = 0,
+      .cache = CACHE_NEW_VS_PROG,
    },
    .prepare = gen6_prepare_wm_push_constants,
 };
@@ -97,7 +99,7 @@ upload_wm_state(struct brw_context *brw)
       brw_fragment_program_const(brw->fragment_program);
    uint32_t dw2, dw4, dw5, dw6;
 
-   /* CACHE_NEW_WM_PROG */
+    /* CACHE_NEW_WM_PROG */
    if (brw->wm.prog_data->nr_params == 0) {
       /* Disable the push constant buffers. */
       BEGIN_BATCH(5);
@@ -157,7 +159,7 @@ upload_wm_state(struct brw_context *brw)
    if (ctx->Line.StippleFlag)
       dw5 |= GEN6_WM_LINE_STIPPLE_ENABLE;
 
-   /* _NEW_POLYGONSTIPPLE */
+   /* _NEW_POLYGON */
    if (ctx->Polygon.StippleFlag)
       dw5 |= GEN6_WM_POLYGON_STIPPLE_ENABLE;
 
@@ -183,7 +185,7 @@ upload_wm_state(struct brw_context *brw)
 
    BEGIN_BATCH(9);
    OUT_BATCH(_3DSTATE_WM << 16 | (9 - 2));
-   OUT_RELOC(brw->wm.prog_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   OUT_BATCH(brw->wm.prog_offset);
    OUT_BATCH(dw2);
    if (brw->wm.prog_data->total_scratch) {
       OUT_RELOC(brw->wm.scratch_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
@@ -195,21 +197,19 @@ upload_wm_state(struct brw_context *brw)
    OUT_BATCH(dw5);
    OUT_BATCH(dw6);
    OUT_BATCH(0); /* kernel 1 pointer */
-   if (brw->wm.prog_data->prog_offset_16) {
-      OUT_RELOC(brw->wm.prog_bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
-               brw->wm.prog_data->prog_offset_16);
-   } else {
-      OUT_BATCH(0); /* kernel 2 pointer */
-   }
+   /* kernel 2 pointer */
+   OUT_BATCH(brw->wm.prog_offset + brw->wm.prog_data->prog_offset_16);
    ADVANCE_BATCH();
 }
 
 const struct brw_tracked_state gen6_wm_state = {
    .dirty = {
-      .mesa  = (_NEW_LINE | _NEW_POLYGONSTIPPLE | _NEW_COLOR | _NEW_BUFFERS |
-               _NEW_PROGRAM_CONSTANTS | _NEW_POLYGON),
-      .brw   = (BRW_NEW_CURBE_OFFSETS |
-               BRW_NEW_FRAGMENT_PROGRAM |
+      .mesa  = (_NEW_LINE |
+               _NEW_COLOR |
+               _NEW_BUFFERS |
+               _NEW_PROGRAM_CONSTANTS |
+               _NEW_POLYGON),
+      .brw   = (BRW_NEW_FRAGMENT_PROGRAM |
                 BRW_NEW_NR_WM_SURFACES |
                BRW_NEW_URB_FENCE |
                BRW_NEW_BATCH),
index 4e94617..a44d315 100644 (file)
@@ -31,7 +31,7 @@ disable_stages(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
 
-   assert(brw->gs.prog_bo == NULL);
+   assert(!brw->gs.prog_active);
 
    /* Disable the Geometry Shader (GS) Unit */
    BEGIN_BATCH(7);
index 95f6fbf..e787c21 100644 (file)
@@ -183,7 +183,8 @@ gen7_prepare_samplers(struct brw_context *brw)
    if (brw->wm.sampler_count == 0)
       return;
 
-   samplers = brw_state_batch(brw, brw->wm.sampler_count * sizeof(*samplers),
+   samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
+                             brw->wm.sampler_count * sizeof(*samplers),
                              32, &brw->wm.sampler_offset);
    memset(samplers, 0, brw->wm.sampler_count * sizeof(*samplers));
 
index 99efe96..0f97cea 100644 (file)
@@ -39,11 +39,12 @@ upload_sbe_state(struct brw_context *brw)
    uint32_t num_outputs = brw_count_bits(brw->fragment_program->Base.InputsRead);
    uint32_t dw1, dw10, dw11;
    int i;
-   int attr = 0;
+   int attr = 0, input_index = 0;
    /* _NEW_TRANSFORM */
    int urb_start = ctx->Transform.ClipPlanesEnabled ? 2 : 1;
    /* _NEW_LIGHT */
    int two_side_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide);
+   uint16_t attr_overrides[FRAG_ATTRIB_MAX];
 
    /* FINISHME: Attribute Swizzle Control Mode? */
    dw1 =
@@ -57,12 +58,6 @@ upload_sbe_state(struct brw_context *brw)
       dw1 |= GEN6_SF_POINT_SPRITE_LOWERLEFT;
 
    dw10 = 0;
-   if (ctx->Point.PointSprite) {
-       for (i = 0; i < 8; i++) {
-          if (ctx->Point.CoordReplace[i])
-              dw10 |= (1 << i);
-       }
-   }
 
    /* _NEW_LIGHT (flat shading) */
    dw11 = 0;
@@ -71,30 +66,43 @@ upload_sbe_state(struct brw_context *brw)
                 ((brw->fragment_program->Base.InputsRead & FRAG_BIT_WPOS) ? 0 : 1));
    }
 
+   /* Create the mapping from the FS inputs we produce to the VS outputs
+    * they source from.
+    */
+   for (; attr < FRAG_ATTRIB_MAX; attr++) {
+      if (!(brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)))
+        continue;
+
+      if (ctx->Point.PointSprite &&
+         attr >= FRAG_ATTRIB_TEX0 && attr <= FRAG_ATTRIB_TEX7 &&
+         ctx->Point.CoordReplace[attr - FRAG_ATTRIB_TEX0]) {
+        dw10 |= (1 << input_index);
+      }
+
+      if (attr == FRAG_ATTRIB_PNTC)
+        dw10 |= (1 << input_index);
+
+      /* The hardware can only do the overrides on 16 overrides at a
+       * time, and the other up to 16 have to be lined up so that the
+       * input index = the output index.  We'll need to do some
+       * tweaking to make sure that's the case.
+       */
+      assert(input_index < 16 || attr == input_index);
+
+      attr_overrides[input_index++] = get_attr_override(brw, attr,
+                                                       two_side_color);
+   }
+
+   for (; attr < FRAG_ATTRIB_MAX; attr++)
+      attr_overrides[input_index++] = 0;
+
    BEGIN_BATCH(14);
    OUT_BATCH(_3DSTATE_SBE << 16 | (14 - 2));
    OUT_BATCH(dw1);
 
    /* Output dwords 2 through 9 */
    for (i = 0; i < 8; i++) {
-      uint32_t attr_overrides = 0;
-
-      for (; attr < 64; attr++) {
-        if (brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)) {
-           attr_overrides |= get_attr_override(brw, attr, two_side_color);
-           attr++;
-           break;
-        }
-      }
-
-      for (; attr < 64; attr++) {
-        if (brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr)) {
-           attr_overrides |= get_attr_override(brw, attr, two_side_color) << 16;
-           attr++;
-           break;
-        }
-      }
-      OUT_BATCH(attr_overrides);
+      OUT_BATCH(attr_overrides[i * 2] | attr_overrides[i * 2 + 1] << 16);
    }
 
    OUT_BATCH(dw10); /* point sprite texcoord bitmask */
index 3a61469..2b650e9 100644 (file)
@@ -78,7 +78,7 @@ upload_urb(struct brw_context *brw)
    assert(brw->urb.nr_vs_entries % 8 == 0);
    assert(brw->urb.nr_gs_entries % 8 == 0);
    /* GS requirement */
-   assert(!brw->gs.prog_bo);
+   assert(!brw->gs.prog_active);
 
    BEGIN_BATCH(2);
    OUT_BATCH(_3DSTATE_PUSH_CONSTANT_ALLOC_VS << 16 | (2 - 2));
index 838ad3a..e9aacd5 100644 (file)
@@ -36,7 +36,8 @@ prepare_sf_clip_viewport(struct brw_context *brw)
    const GLfloat *v = ctx->Viewport._WindowMap.m;
    struct gen7_sf_clip_viewport *vp;
 
-   vp = brw_state_batch(brw, sizeof(vp), 64, &brw->sf.vp_offset);
+   vp = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
+                       sizeof(vp), 64, &brw->sf.vp_offset);
    /* Also assign to clip.vp_offset in case something uses it. */
    brw->clip.vp_offset = brw->sf.vp_offset;
 
index ae7a1d6..0fad3d2 100644 (file)
@@ -67,7 +67,7 @@ upload_vs_state(struct brw_context *brw)
 
    BEGIN_BATCH(6);
    OUT_BATCH(_3DSTATE_VS << 16 | (6 - 2));
-   OUT_RELOC(brw->vs.prog_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   OUT_BATCH(brw->vs.prog_offset);
    OUT_BATCH((0 << GEN6_VS_SAMPLER_COUNT_SHIFT) |
             GEN6_VS_FLOATING_POINT_MODE_ALT |
             (brw->vs.nr_surfaces << GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
index 6a64eb8..a102ca7 100644 (file)
@@ -36,6 +36,7 @@ gen7_prepare_wm_constants(struct brw_context *brw)
 {
    struct intel_context *intel = &brw->intel;
    struct gl_context *ctx = &intel->ctx;
+   /* BRW_NEW_FRAGMENT_PROGRAM */
    const struct brw_fragment_program *fp =
       brw_fragment_program_const(brw->fragment_program);
 
@@ -45,12 +46,12 @@ gen7_prepare_wm_constants(struct brw_context *brw)
    /* XXX: Should this happen somewhere before to get our state flag set? */
    _mesa_load_state_parameters(ctx, fp->program.Base.Parameters);
 
-   /* BRW_NEW_FRAGMENT_PROGRAM */
+   /* CACHE_NEW_WM_PROG */
    if (brw->wm.prog_data->nr_params != 0) {
       float *constants;
       unsigned int i;
 
-      constants = brw_state_batch(brw,
+      constants = brw_state_batch(brw, AUB_TRACE_NO_TYPE,
                                  brw->wm.prog_data->nr_params *
                                  sizeof(float),
                                  32, &brw->wm.push_const_offset);
@@ -80,7 +81,7 @@ const struct brw_tracked_state gen7_wm_constants = {
    .dirty = {
       .mesa  = _NEW_PROGRAM_CONSTANTS,
       .brw   = (BRW_NEW_BATCH | BRW_NEW_FRAGMENT_PROGRAM),
-      .cache = 0,
+      .cache = CACHE_NEW_WM_PROG,
    },
    .prepare = gen7_prepare_wm_constants,
 };
@@ -104,7 +105,7 @@ upload_wm_state(struct brw_context *brw)
    if (ctx->Line.StippleFlag)
       dw1 |= GEN7_WM_LINE_STIPPLE_ENABLE;
 
-   /* _NEW_POLYGONSTIPPLE */
+   /* _NEW_POLYGON */
    if (ctx->Polygon.StippleFlag)
       dw1 |= GEN7_WM_POLYGON_STIPPLE_ENABLE;
 
@@ -137,11 +138,9 @@ upload_wm_state(struct brw_context *brw)
 
 const struct brw_tracked_state gen7_wm_state = {
    .dirty = {
-      .mesa  = (_NEW_LINE | _NEW_POLYGON | _NEW_POLYGONSTIPPLE |
+      .mesa  = (_NEW_LINE | _NEW_POLYGON |
                _NEW_COLOR | _NEW_BUFFERS),
-      .brw   = (BRW_NEW_CURBE_OFFSETS |
-               BRW_NEW_FRAGMENT_PROGRAM |
-                BRW_NEW_NR_WM_SURFACES |
+      .brw   = (BRW_NEW_FRAGMENT_PROGRAM |
                BRW_NEW_URB_FENCE |
                BRW_NEW_BATCH),
       .cache = 0,
@@ -227,25 +226,19 @@ upload_ps_state(struct brw_context *brw)
 
    BEGIN_BATCH(8);
    OUT_BATCH(_3DSTATE_PS << 16 | (8 - 2));
-   OUT_RELOC(brw->wm.prog_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   OUT_BATCH(brw->wm.prog_offset);
    OUT_BATCH(dw2);
    OUT_BATCH(0); /* scratch space base offset */
    OUT_BATCH(dw4);
    OUT_BATCH(dw5);
    OUT_BATCH(0); /* kernel 1 pointer */
-   if (brw->wm.prog_data->prog_offset_16) {
-      OUT_RELOC(brw->wm.prog_bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
-               brw->wm.prog_data->prog_offset_16);
-   } else {
-      OUT_BATCH(0); /* kernel 2 pointer */
-   }
+   OUT_BATCH(brw->wm.prog_offset + brw->wm.prog_data->prog_offset_16);
    ADVANCE_BATCH();
 }
 
 const struct brw_tracked_state gen7_ps_state = {
    .dirty = {
-      .mesa  = (_NEW_LINE | _NEW_POLYGON | _NEW_POLYGONSTIPPLE |
-               _NEW_PROGRAM_CONSTANTS),
+      .mesa  = _NEW_PROGRAM_CONSTANTS,
       .brw   = (BRW_NEW_CURBE_OFFSETS |
                BRW_NEW_FRAGMENT_PROGRAM |
                 BRW_NEW_NR_WM_SURFACES |
index 9994b67..4add1a6 100644 (file)
@@ -65,8 +65,8 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint unit)
    const GLuint surf_index = SURF_INDEX_TEXTURE(unit);
    struct gen7_surface_state *surf;
 
-   surf = brw_state_batch(brw, sizeof(*surf), 32,
-                        &brw->wm.surf_offset[surf_index]);
+   surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         sizeof(*surf), 32, &brw->wm.surf_offset[surf_index]);
    memset(surf, 0, sizeof(*surf));
 
    surf->ss0.surface_type = translate_tex_target(tObj->Target);
@@ -135,7 +135,8 @@ gen7_create_constant_surface(struct brw_context *brw,
    const GLint w = width - 1;
    struct gen7_surface_state *surf;
 
-   surf = brw_state_batch(brw, sizeof(*surf), 32, out_offset);
+   surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         sizeof(*surf), 32, out_offset);
    memset(surf, 0, sizeof(*surf));
 
    surf->ss0.surface_type = BRW_SURFACE_BUFFER;
@@ -210,8 +211,8 @@ gen7_update_null_renderbuffer_surface(struct brw_context *brw, unsigned unit)
 {
    struct gen7_surface_state *surf;
 
-   surf = brw_state_batch(brw, sizeof(*surf), 32,
-                        &brw->wm.surf_offset[unit]);
+   surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         sizeof(*surf), 32, &brw->wm.surf_offset[unit]);
    memset(surf, 0, sizeof(*surf));
 
    surf->ss0.surface_type = BRW_SURFACE_NULL;
@@ -235,8 +236,8 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
    struct gen7_surface_state *surf;
    uint32_t tile_x, tile_y;
 
-   surf = brw_state_batch(brw, sizeof(*surf), 32,
-                         &brw->wm.surf_offset[unit]);
+   surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         sizeof(*surf), 32, &brw->wm.surf_offset[unit]);
    memset(surf, 0, sizeof(*surf));
 
    switch (irb->Base.Format) {
index 77edc3a..db4343b 100644 (file)
@@ -53,6 +53,22 @@ static void clear_cache( struct intel_context *intel )
 }
 
 void
+intel_batchbuffer_init(struct intel_context *intel)
+{
+   intel_batchbuffer_reset(intel);
+
+   if (intel->gen == 6) {
+      /* We can't just use brw_state_batch to get a chunk of space for
+       * the gen6 workaround because it involves actually writing to
+       * the buffer, and the kernel doesn't let us write to the batch.
+       */
+      intel->batch.workaround_bo = drm_intel_bo_alloc(intel->bufmgr,
+                                                     "gen6 workaround",
+                                                     4096, 4096);
+   }
+}
+
+void
 intel_batchbuffer_reset(struct intel_context *intel)
 {
    if (intel->batch.last_bo != NULL) {
@@ -76,6 +92,7 @@ intel_batchbuffer_free(struct intel_context *intel)
 {
    drm_intel_bo_unreference(intel->batch.last_bo);
    drm_intel_bo_unreference(intel->batch.bo);
+   drm_intel_bo_unreference(intel->batch.workaround_bo);
    clear_cache(intel);
 }
 
@@ -110,9 +127,11 @@ do_flush_locked(struct intel_context *intel)
    }
 
    if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) {
-      intel_decode(batch->map, batch->used,
+      drm_intel_bo_map(batch->bo, false);
+      intel_decode(batch->bo->virtual, batch->used,
                   batch->bo->offset,
                   intel->intelScreen->deviceID, GL_TRUE);
+      drm_intel_bo_unmap(batch->bo);
 
       if (intel->vtbl.debug_batch != NULL)
         intel->vtbl.debug_batch(intel);
@@ -276,6 +295,68 @@ emit:
    item->header = intel->batch.emit;
 }
 
+/**
+ * Emits a PIPE_CONTROL with a non-zero post-sync operation, for
+ * implementing two workarounds on gen6.  From section 1.4.7.1
+ * "PIPE_CONTROL" of the Sandy Bridge PRM volume 2 part 1:
+ *
+ * [DevSNB-C+{W/A}] Before any depth stall flush (including those
+ * produced by non-pipelined state commands), software needs to first
+ * send a PIPE_CONTROL with no bits set except Post-Sync Operation !=
+ * 0.
+ *
+ * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache Flush Enable
+ * =1, a PIPE_CONTROL with any non-zero post-sync-op is required.
+ *
+ * And the workaround for these two requires this workaround first:
+ *
+ * [Dev-SNB{W/A}]: Pipe-control with CS-stall bit set must be sent
+ * BEFORE the pipe-control with a post-sync op and no write-cache
+ * flushes.
+ *
+ * And this last workaround is tricky because of the requirements on
+ * that bit.  From section 1.4.7.2.3 "Stall" of the Sandy Bridge PRM
+ * volume 2 part 1:
+ *
+ *     "1 of the following must also be set:
+ *      - Render Target Cache Flush Enable ([12] of DW1)
+ *      - Depth Cache Flush Enable ([0] of DW1)
+ *      - Stall at Pixel Scoreboard ([1] of DW1)
+ *      - Depth Stall ([13] of DW1)
+ *      - Post-Sync Operation ([13] of DW1)
+ *      - Notify Enable ([8] of DW1)"
+ *
+ * The cache flushes require the workaround flush that triggered this
+ * one, so we can't use it.  Depth stall would trigger the same.
+ * Post-sync nonzero is what triggered this second workaround, so we
+ * can't use that one either.  Notify enable is IRQs, which aren't
+ * really our business.  That leaves only stall at scoreboard.
+ */
+void
+intel_emit_post_sync_nonzero_flush(struct intel_context *intel)
+{
+   if (!intel->batch.need_workaround_flush)
+      return;
+
+   BEGIN_BATCH(4);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(PIPE_CONTROL_CS_STALL |
+            PIPE_CONTROL_STALL_AT_SCOREBOARD);
+   OUT_BATCH(0); /* address */
+   OUT_BATCH(0); /* write data */
+   ADVANCE_BATCH();
+
+   BEGIN_BATCH(4);
+   OUT_BATCH(_3DSTATE_PIPE_CONTROL);
+   OUT_BATCH(PIPE_CONTROL_WRITE_IMMEDIATE);
+   OUT_RELOC(intel->batch.workaround_bo,
+            I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0);
+   OUT_BATCH(0); /* write data */
+   ADVANCE_BATCH();
+
+   intel->batch.need_workaround_flush = false;
+}
+
 /* 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.
@@ -294,19 +375,22 @@ intel_batchbuffer_emit_mi_flush(struct intel_context *intel)
         OUT_BATCH(0);
         ADVANCE_BATCH();
       } else {
-        BEGIN_BATCH(8);
-        /* XXX workaround: issue any post sync != 0 before write
-         * cache flush = 1
-         */
-        OUT_BATCH(_3DSTATE_PIPE_CONTROL);
-        OUT_BATCH(PIPE_CONTROL_WRITE_IMMEDIATE);
-        OUT_BATCH(0); /* write address */
-        OUT_BATCH(0); /* write data */
+        if (intel->gen == 6) {
+           /* Hardware workaround: SNB B-Spec says:
+            *
+            * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache
+            * Flush Enable =1, a PIPE_CONTROL with any non-zero
+            * post-sync-op is required.
+            */
+           intel_emit_post_sync_nonzero_flush(intel);
+        }
 
+        BEGIN_BATCH(4);
         OUT_BATCH(_3DSTATE_PIPE_CONTROL);
         OUT_BATCH(PIPE_CONTROL_INSTRUCTION_FLUSH |
                   PIPE_CONTROL_WRITE_FLUSH |
                   PIPE_CONTROL_DEPTH_CACHE_FLUSH |
+                  PIPE_CONTROL_TC_FLUSH |
                   PIPE_CONTROL_NO_WRITE);
         OUT_BATCH(0); /* write address */
         OUT_BATCH(0); /* write data */
index a0a5c98..fb4134d 100644 (file)
@@ -9,6 +9,7 @@
 
 #define BATCH_RESERVED 16
 
+void intel_batchbuffer_init(struct intel_context *intel);
 void intel_batchbuffer_reset(struct intel_context *intel);
 void intel_batchbuffer_free(struct intel_context *intel);
 
@@ -38,6 +39,7 @@ GLboolean intel_batchbuffer_emit_reloc_fenced(struct intel_context *intel,
                                              uint32_t write_domain,
                                              uint32_t offset);
 void intel_batchbuffer_emit_mi_flush(struct intel_context *intel);
+void intel_emit_post_sync_nonzero_flush(struct intel_context *intel);
 
 static INLINE uint32_t float_as_int(float f)
 {
index 7eb50ed..fccdcbd 100644 (file)
@@ -28,7 +28,9 @@
 #include "intel_context.h"
 #include "intel_buffers.h"
 #include "intel_fbo.h"
+
 #include "main/framebuffer.h"
+#include "main/renderbuffer.h"
 
 /**
  * Return pointer to current color drawing region, or NULL.
@@ -76,197 +78,6 @@ intel_check_front_buffer_rendering(struct intel_context *intel)
    }
 }
 
-
-/**
- * Update the hardware state for drawing into a window or framebuffer object.
- *
- * Called by glDrawBuffer, glBindFramebufferEXT, MakeCurrent, and other
- * places within the driver.
- *
- * Basically, this needs to be called any time the current framebuffer
- * changes, the renderbuffers change, or we need to draw into different
- * color buffers.
- */
-void
-intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_region *colorRegions[MAX_DRAW_BUFFERS], *depthRegion = NULL;
-   struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
-   bool fb_has_hiz = intel_framebuffer_has_hiz(fb);
-
-   if (!fb) {
-      /* this can happen during the initial context initialization */
-      return;
-   }
-
-   /* Do this here, not core Mesa, since this function is called from
-    * many places within the driver.
-    */
-   if (ctx->NewState & _NEW_BUFFERS) {
-      /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
-      _mesa_update_framebuffer(ctx);
-      /* this updates the DrawBuffer's Width/Height if it's a FBO */
-      _mesa_update_draw_buffer_bounds(ctx);
-   }
-
-   if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
-      /* this may occur when we're called by glBindFrameBuffer() during
-       * the process of someone setting up renderbuffers, etc.
-       */
-      /*_mesa_debug(ctx, "DrawBuffer: incomplete user FBO\n");*/
-      return;
-   }
-
-   /* 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->Width > ctx->Const.MaxRenderbufferSize)
-       || (fb->Height > ctx->Const.MaxRenderbufferSize)
-       || (fb->_NumColorDrawBuffers == 0)) {
-      /* writing to 0  */
-      colorRegions[0] = NULL;
-   }
-   else if (fb->_NumColorDrawBuffers > 1) {
-       int i;
-       struct intel_renderbuffer *irb;
-
-       for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
-           irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
-           colorRegions[i] = irb ? irb->region : NULL;
-       }
-   }
-   else {
-      /* Get the intel_renderbuffer for the single colorbuffer we're drawing
-       * into.
-       */
-      if (fb->Name == 0) {
-        /* drawing to window system buffer */
-        if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)
-           colorRegions[0] = intel_get_rb_region(fb, BUFFER_FRONT_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;
-      }
-   }
-
-   if (!colorRegions[0]) {
-      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE);
-   }
-   else {
-      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE);
-   }
-
-   /***
-    *** Get depth buffer region and check if we need a software fallback.
-    ***/
-   if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) {
-      irbDepth = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
-      if (irbDepth && irbDepth->region) {
-        assert(!fb_has_hiz || irbDepth->Base.Format != MESA_FORMAT_S8_Z24);
-         FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
-         depthRegion = irbDepth->region;
-      }
-      else {
-         FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_TRUE);
-         depthRegion = NULL;
-      }
-   }
-   else {
-      /* not using depth buffer */
-      FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
-      depthRegion = NULL;
-   }
-
-   /***
-    *** Stencil buffer
-    ***/
-   if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
-      irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
-      if (irbStencil && irbStencil->region) {
-        if (!intel->has_separate_stencil)
-           assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
-        if (fb_has_hiz || intel->must_use_separate_stencil)
-           assert(irbStencil->Base.Format == MESA_FORMAT_S8);
-        if (irbStencil->Base.Format == MESA_FORMAT_S8)
-           assert(intel->has_separate_stencil);
-         FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
-      }
-      else {
-         FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_TRUE);
-      }
-   }
-   else {
-      /* XXX FBO: instead of FALSE, pass ctx->Stencil._Enabled ??? */
-      FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
-   }
-
-   /* 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
-       && irbStencil->Base.Format == MESA_FORMAT_S8_Z24) {
-      depthRegion = irbStencil->region;
-   }
-
-   /*
-    * Update depth and stencil test state
-    */
-   if (ctx->Driver.Enable) {
-      ctx->Driver.Enable(ctx, GL_DEPTH_TEST,
-                         (ctx->Depth.Test && fb->Visual.depthBits > 0));
-      ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
-                         (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));
-   }
-   else {
-      /* Mesa's Stencil._Enabled field is updated when
-       * _NEW_BUFFERS | _NEW_STENCIL, but i965 code assumes that the value
-       * only changes with _NEW_STENCIL (which seems sensible).  So flag it
-       * here since this is the _NEW_BUFFERS path.
-       */
-      intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL);
-   }
-
-   intel->vtbl.set_draw_region(intel, colorRegions, depthRegion, 
-                               fb->_NumColorDrawBuffers);
-   intel->NewGLState |= _NEW_BUFFERS;
-
-   /* update viewport since it depends on window size */
-#ifdef I915
-   intelCalcViewport(ctx);
-#else
-   intel->NewGLState |= _NEW_VIEWPORT;
-#endif
-   /* Set state we know depends on drawable parameters:
-    */
-   if (ctx->Driver.Scissor)
-      ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                         ctx->Scissor.Width, ctx->Scissor.Height);
-   intel->NewGLState |= _NEW_SCISSOR;
-
-   if (ctx->Driver.DepthRange)
-      ctx->Driver.DepthRange(ctx,
-                            ctx->Viewport.Near,
-                            ctx->Viewport.Far);
-
-   /* Update culling direction which changes depending on the
-    * orientation of the buffer:
-    */
-   if (ctx->Driver.FrontFace)
-      ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
-   else
-      intel->NewGLState |= _NEW_POLYGON;
-}
-
-
 static void
 intelDrawBuffer(struct gl_context * ctx, GLenum mode)
 {
index 2d4613b..a7e7797 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "dri_util.h"
 #include "drm.h"
+#include "intel_context.h"
 
 struct intel_context;
 struct intel_framebuffer;
@@ -41,7 +42,13 @@ 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(struct gl_context * ctx, struct gl_framebuffer *fb);
+static inline void
+intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
+{
+   struct intel_context *intel = intel_context(ctx);
+
+   intel->vtbl.update_draw_buffer(intel);
+}
 
 extern void intelInitBufferFuncs(struct dd_function_table *functions);
 
index 5a96232..76d33f9 100644 (file)
@@ -116,14 +116,13 @@ intelClear(struct gl_context *ctx, GLbitfield mask)
    }
 
    /* HW color buffers (front, back, aux, generic FBO, etc) */
-   if (colorMask == ~0) {
+   if (intel->gen < 6 && colorMask == ~0) {
       /* clear all R,G,B,A */
-      /* XXX FBO: need to check if colorbuffers are software RBOs! */
       blit_mask |= (mask & BUFFER_BITS_COLOR);
    }
    else {
       /* glColorMask in effect */
-      tri_mask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT));
+      tri_mask |= (mask & BUFFER_BITS_COLOR);
    }
 
    /* Make sure we have up to date buffers before we start looking at
@@ -144,6 +143,12 @@ intelClear(struct gl_context *ctx, GLbitfield mask)
             */
             tri_mask |= BUFFER_BIT_STENCIL;
          }
+        else if (intel->has_separate_stencil &&
+              stencilRegion->tiling == I915_TILING_NONE) {
+           /* The stencil buffer is actually W tiled, which the hardware
+            * cannot blit to. */
+           tri_mask |= BUFFER_BIT_STENCIL;
+        }
          else {
             /* clearing all stencil bits, use blitting */
             blit_mask |= BUFFER_BIT_STENCIL;
@@ -183,7 +188,10 @@ intelClear(struct gl_context *ctx, GLbitfield mask)
 
    if (tri_mask) {
       debug_mask("tri", tri_mask);
-      _mesa_meta_Clear(&intel->ctx, tri_mask);
+      if (ctx->Extensions.ARB_fragment_shader)
+        _mesa_meta_glsl_Clear(&intel->ctx, tri_mask);
+      else
+        _mesa_meta_Clear(&intel->ctx, tri_mask);
    }
 }
 
index 0c2ba41..fe8be08 100644 (file)
@@ -56,7 +56,7 @@
 
 #include "drirenderbuffer.h"
 #include "utils.h"
-
+#include "../glsl/ralloc.h"
 
 #ifndef INTEL_DEBUG
 int INTEL_DEBUG = (0);
@@ -504,10 +504,7 @@ intelInvalidateState(struct gl_context * ctx, GLuint new_state)
     struct intel_context *intel = intel_context(ctx);
 
    _swrast_InvalidateState(ctx, new_state);
-   _swsetup_InvalidateState(ctx, new_state);
    _vbo_InvalidateState(ctx, new_state);
-   _tnl_InvalidateState(ctx, new_state);
-   _tnl_invalidate_vertex_state(ctx, new_state);
 
    intel->NewGLState |= new_state;
 
@@ -663,8 +660,8 @@ intelInitContext(struct intel_context *intel,
       ctx->TextureFormatSupported[MESA_FORMAT_AL1616] = GL_TRUE;
 
    /* Depth and stencil */
-   ctx->TextureFormatSupported[MESA_FORMAT_S8_Z24] = !intel->must_use_separate_stencil;
-   ctx->TextureFormatSupported[MESA_FORMAT_X8_Z24] = intel->has_separate_stencil;
+   ctx->TextureFormatSupported[MESA_FORMAT_S8_Z24] = GL_TRUE;
+   ctx->TextureFormatSupported[MESA_FORMAT_X8_Z24] = GL_TRUE;
    ctx->TextureFormatSupported[MESA_FORMAT_S8] = intel->has_separate_stencil;
 
    /*
@@ -854,7 +851,7 @@ intelInitContext(struct intel_context *intel,
    if (INTEL_DEBUG & DEBUG_BUFMGR)
       dri_bufmgr_set_debug(intel->bufmgr, GL_TRUE);
 
-   intel_batchbuffer_reset(intel);
+   intel_batchbuffer_init(intel);
 
    intel_fbo_init(intel);
 
@@ -925,7 +922,9 @@ intelDestroyContext(__DRIcontext * driContextPriv)
       /* free the Mesa context */
       _mesa_free_context_data(&intel->ctx);
 
-      FREE(intel);
+      _math_matrix_dtr(&intel->ViewportMatrix);
+
+      ralloc_free(intel);
       driContextPriv->driverPrivate = NULL;
    }
 }
@@ -1115,7 +1114,6 @@ intel_query_dri2_buffers_no_separate_stencil(struct intel_context *intel,
  *
  * \see intel_update_renderbuffers()
  * \see intel_region_alloc_for_handle()
- * \see intel_renderbuffer_set_region()
  */
 static void
 intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
@@ -1127,7 +1125,6 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
    assert(!intel->must_use_separate_stencil);
 
    struct gl_framebuffer *fb = drawable->driverPrivate;
-   struct intel_region *region = NULL;
    struct intel_renderbuffer *depth_rb = NULL;
 
    if (!rb)
@@ -1154,20 +1151,18 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
       if (unlikely(INTEL_DEBUG & DEBUG_DRI)) {
         fprintf(stderr, "(reusing depth buffer as stencil)\n");
       }
-      intel_region_reference(&region, depth_rb->region);
+      intel_region_reference(&rb->region, depth_rb->region);
    } else {
-      region = intel_region_alloc_for_handle(intel->intelScreen,
-                                            buffer->cpp,
-                                            drawable->w,
-                                            drawable->h,
-                                            buffer->pitch / buffer->cpp,
-                                            buffer->name,
-                                            buffer_name);
+      intel_region_release(&rb->region);
+      rb->region = intel_region_alloc_for_handle(intel->intelScreen,
+                                                buffer->cpp,
+                                                drawable->w,
+                                                drawable->h,
+                                                buffer->pitch / buffer->cpp,
+                                                buffer->name,
+                                                buffer_name);
    }
 
-   intel_renderbuffer_set_region(intel, rb, region);
-   intel_region_release(&region);
-
    if (buffer->attachment == __DRI_BUFFER_DEPTH_STENCIL) {
       struct intel_renderbuffer *stencil_rb =
         intel_get_renderbuffer(fb, BUFFER_STENCIL);
@@ -1175,10 +1170,10 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
       if (!stencil_rb)
         return;
 
-      if (stencil_rb->region && stencil_rb->region->name == buffer->name)
-        return;
-
-      intel_renderbuffer_set_region(intel, stencil_rb, region);
+      /* The rb passed in is the BUFFER_DEPTH attachment, and we need
+       * to associate this region to BUFFER_STENCIL as well.
+       */
+      intel_region_reference(&stencil_rb->region, rb->region);
    }
 }
 
@@ -1303,7 +1298,6 @@ intel_query_dri2_buffers_with_separate_stencil(struct intel_context *intel,
  *
  * \see intel_update_renderbuffers()
  * \see intel_region_alloc_for_handle()
- * \see intel_renderbuffer_set_region()
  * \see enum intel_dri2_has_hiz
  */
 static void
@@ -1363,9 +1357,9 @@ intel_process_dri2_buffer_with_separate_stencil(struct intel_context *intel,
                                    buffer_name);
 
    if (buffer->attachment == __DRI_BUFFER_HIZ) {
-      intel_renderbuffer_set_hiz_region(intel, rb, region);
+      intel_region_reference(&rb->hiz_region, region);
    } else {
-      intel_renderbuffer_set_region(intel, rb, region);
+      intel_region_reference(&rb->region, region);
    }
 
    intel_region_release(&region);
@@ -1445,7 +1439,12 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,
       assert(stencil_rb->Base.Format == MESA_FORMAT_S8);
       assert(depth_rb && depth_rb->Base.Format == MESA_FORMAT_X8_Z24);
 
-      if (stencil_rb->region->tiling == I915_TILING_Y) {
+      if (stencil_rb->region->tiling == I915_TILING_NONE) {
+        /*
+         * The stencil buffer is actually W tiled. The region's tiling is
+         * I915_TILING_NONE, however, because the GTT is incapable of W
+         * fencing.
+         */
         intel->intelScreen->dri2_has_hiz = INTEL_DRI2_HAS_HIZ_TRUE;
         return;
       } else {
@@ -1514,12 +1513,10 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,
                                             / depth_stencil_buffer->cpp,
                                          depth_stencil_buffer->name,
                                          "dri2 depth / stencil buffer");
-        intel_renderbuffer_set_region(intel,
-                                      intel_get_renderbuffer(fb, BUFFER_DEPTH),
-                                      region);
-        intel_renderbuffer_set_region(intel,
-                                      intel_get_renderbuffer(fb, BUFFER_STENCIL),
-                                      region);
+        intel_region_reference(&intel_get_renderbuffer(fb, BUFFER_DEPTH)->region,
+                               region);
+        intel_region_reference(&intel_get_renderbuffer(fb, BUFFER_STENCIL)->region,
+                               region);
         intel_region_release(&region);
       }
    }
@@ -1535,7 +1532,7 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,
        * Presently, however, no verification or clean up is necessary, and
        * execution should not reach here. If the framebuffer still has a hiz
        * region, then we have already set dri2_has_hiz to true after
-       * confirming above that the stencil buffer is Y tiled.
+       * confirming above that the stencil buffer is W tiled.
        */
       assert(0);
    }
index 80dee4e..b7989dd 100644 (file)
@@ -136,6 +136,7 @@ struct intel_context
                                struct intel_region * draw_regions[],
                                struct intel_region * depth_region,
                               GLuint num_regions);
+      void (*update_draw_buffer)(struct intel_context *intel);
 
       void (*reduced_primitive_state) (struct intel_context * intel,
                                        GLenum rprim);
@@ -181,6 +182,9 @@ struct intel_context
       drm_intel_bo *bo;
       /** Last BO submitted to the hardware.  Used for glFinish(). */
       drm_intel_bo *last_bo;
+      /** BO for post-sync nonzero writes for gen6 workaround. */
+      drm_intel_bo *workaround_bo;
+      bool need_workaround_flush;
 
       struct cached_batch_item *cached_items;
 
@@ -196,6 +200,7 @@ struct intel_context
    drm_intel_bo *first_post_swapbuffers_batch;
    GLboolean need_throttle;
    GLboolean no_batch_wrap;
+   bool tnl_pipeline_running; /**< Set while i915's _tnl_run_pipeline. */
 
    struct
    {
@@ -225,7 +230,6 @@ struct intel_context
    GLuint coloroffset;
    GLuint specoffset;
    GLuint wpos_offset;
-   GLuint wpos_size;
 
    struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
    GLuint vertex_attr_count;
index 3fd987a..64c996c 100644 (file)
@@ -172,6 +172,7 @@ static const struct dri_extension brw_extensions[] = {
    { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions },
    { "GL_ARB_point_sprite",              NULL },
    { "GL_ARB_seamless_cube_map",          NULL },
+   { "GL_ARB_shader_texture_lod",         NULL },
    { "GL_ARB_shadow",                     NULL },
 #ifdef TEXTURE_FLOAT_ENABLED
    { "GL_ARB_texture_float",              NULL },
index e7c23f0..65ad621 100644 (file)
@@ -70,18 +70,15 @@ intel_new_framebuffer(struct gl_context * ctx, GLuint name)
 static void
 intel_delete_renderbuffer(struct gl_renderbuffer *rb)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct intel_context *intel = intel_context(ctx);
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
    ASSERT(irb);
 
-   if (intel && irb->region) {
-      intel_region_release(&irb->region);
-   }
-   if (intel && irb->hiz_region) {
-      intel_region_release(&irb->hiz_region);
-   }
+   intel_region_release(&irb->region);
+   intel_region_release(&irb->hiz_region);
+
+   _mesa_reference_renderbuffer(&irb->wrapped_depth, NULL);
+   _mesa_reference_renderbuffer(&irb->wrapped_stencil, NULL);
 
    free(irb);
 }
@@ -105,7 +102,7 @@ intel_get_pointer(struct gl_context * ctx, struct gl_renderbuffer *rb,
  * Called via glRenderbufferStorageEXT() to set the format and allocate
  * storage for a user-created renderbuffer.
  */
-static GLboolean
+GLboolean
 intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
                                  GLenum internalFormat,
                                  GLuint width, GLuint height)
@@ -141,6 +138,8 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
       break;
    }
 
+   rb->Width = width;
+   rb->Height = height;
    rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
    rb->DataType = intel_mesa_format_to_rb_datatype(rb->Format);
    cpp = _mesa_get_format_bytes(rb->Format);
@@ -174,6 +173,9 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
 
    if (irb->Base.Format == MESA_FORMAT_S8) {
       /*
+       * The stencil buffer is W tiled. However, we request from the kernel a
+       * non-tiled buffer because the GTT is incapable of W fencing.
+       *
        * The stencil buffer has quirky pitch requirements.  From Vol 2a,
        * 11.5.6.2.1 3DSTATE_STENCIL_BUFFER, field "Surface Pitch":
        *    The pitch must be set to 2x the value computed based on width, as
@@ -181,41 +183,71 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
        * To accomplish this, we resort to the nasty hack of doubling the drm
        * region's cpp and halving its height.
        *
-       * If we neglect to double the pitch, then drm_intel_gem_bo_map_gtt()
-       * maps the memory incorrectly.
+       * If we neglect to double the pitch, then render corruption occurs.
        */
       irb->region = intel_region_alloc(intel->intelScreen,
-                                      I915_TILING_Y,
+                                      I915_TILING_NONE,
                                       cpp * 2,
-                                      width,
-                                      height / 2,
+                                      ALIGN(width, 64),
+                                      ALIGN((height + 1) / 2, 64),
                                       GL_TRUE);
+      if (!irb->region)
+       return false;
+
+   } else if (irb->Base.Format == MESA_FORMAT_S8_Z24
+             && intel->must_use_separate_stencil) {
+
+      bool ok = true;
+      struct gl_renderbuffer *depth_rb;
+      struct gl_renderbuffer *stencil_rb;
+
+      depth_rb = intel_create_wrapped_renderbuffer(ctx, width, height,
+                                                  MESA_FORMAT_X8_Z24);
+      stencil_rb = intel_create_wrapped_renderbuffer(ctx, width, height,
+                                                    MESA_FORMAT_S8);
+      ok = depth_rb && stencil_rb;
+      ok = ok && intel_alloc_renderbuffer_storage(ctx, depth_rb,
+                                                 depth_rb->InternalFormat,
+                                                 width, height);
+      ok = ok && intel_alloc_renderbuffer_storage(ctx, stencil_rb,
+                                                 stencil_rb->InternalFormat,
+                                                 width, height);
+
+      if (!ok) {
+        if (depth_rb) {
+           intel_delete_renderbuffer(depth_rb);
+        }
+        if (stencil_rb) {
+           intel_delete_renderbuffer(stencil_rb);
+        }
+        return false;
+      }
+
+      depth_rb->Wrapped = rb;
+      stencil_rb->Wrapped = rb;
+      _mesa_reference_renderbuffer(&irb->wrapped_depth, depth_rb);
+      _mesa_reference_renderbuffer(&irb->wrapped_stencil, stencil_rb);
+
    } else {
       irb->region = intel_region_alloc(intel->intelScreen, tiling, cpp,
                                       width, height, GL_TRUE);
-   }
-
-   if (!irb->region)
-      return GL_FALSE;       /* out of memory? */
-
-   ASSERT(irb->region->buffer);
-
-   if (intel->vtbl.is_hiz_depth_format(intel, rb->Format)) {
-      irb->hiz_region = intel_region_alloc(intel->intelScreen,
-                                           I915_TILING_Y,
-                                           irb->region->cpp,
-                                           irb->region->width,
-                                           irb->region->height,
-                                           GL_TRUE);
-      if (!irb->hiz_region) {
-         intel_region_release(&irb->region);
-         return GL_FALSE;
+      if (!irb->region)
+        return false;
+
+      if (intel->vtbl.is_hiz_depth_format(intel, rb->Format)) {
+        irb->hiz_region = intel_region_alloc(intel->intelScreen,
+                                             I915_TILING_Y,
+                                             irb->region->cpp,
+                                             irb->region->width,
+                                             irb->region->height,
+                                             GL_TRUE);
+        if (!irb->hiz_region) {
+           intel_region_release(&irb->region);
+           return false;
+        }
       }
    }
 
-   rb->Width = width;
-   rb->Height = height;
-
    return GL_TRUE;
 }
 
@@ -238,8 +270,6 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
       return;
 
    irb = intel_renderbuffer(rb);
-   if (irb->region)
-      intel_region_release(&irb->region);
    intel_region_reference(&irb->region, image->region);
 
    rb->InternalFormat = image->internal_format;
@@ -306,33 +336,6 @@ intel_nop_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
    return GL_FALSE;
 }
 
-
-void
-intel_renderbuffer_set_region(struct intel_context *intel,
-                             struct intel_renderbuffer *rb,
-                             struct intel_region *region)
-{
-   struct intel_region *old;
-
-   old = rb->region;
-   rb->region = NULL;
-   intel_region_reference(&rb->region, region);
-   intel_region_release(&old);
-}
-
-
-void
-intel_renderbuffer_set_hiz_region(struct intel_context *intel,
-                                 struct intel_renderbuffer *rb,
-                                 struct intel_region *region)
-{
-   struct intel_region *old = rb->hiz_region;
-   rb->hiz_region = NULL;
-   intel_region_reference(&rb->hiz_region, region);
-   intel_region_release(&old);
-}
-
-
 /**
  * Create a new intel_renderbuffer which corresponds to an on-screen window,
  * not a user-created renderbuffer.
@@ -366,6 +369,37 @@ intel_create_renderbuffer(gl_format format)
 }
 
 
+struct gl_renderbuffer*
+intel_create_wrapped_renderbuffer(struct gl_context * ctx,
+                                 int width, int height,
+                                 gl_format format)
+{
+   /*
+    * The name here is irrelevant, as long as its nonzero, because the
+    * renderbuffer never gets entered into Mesa's renderbuffer hash table.
+    */
+   GLuint name = ~0;
+
+   struct intel_renderbuffer *irb = CALLOC_STRUCT(intel_renderbuffer);
+   if (!irb) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+      return NULL;
+   }
+
+   struct gl_renderbuffer *rb = &irb->Base;
+   _mesa_init_renderbuffer(rb, name);
+   rb->ClassID = INTEL_RB_CLASS;
+   rb->_BaseFormat = _mesa_get_format_base_format(format);
+   rb->Format = format;
+   rb->InternalFormat = rb->_BaseFormat;
+   rb->DataType = intel_mesa_format_to_rb_datatype(format);
+   rb->Width = width;
+   rb->Height = height;
+
+   return rb;
+}
+
+
 /**
  * Create a new renderbuffer object.
  * Typically called via glBindRenderbufferEXT().
@@ -427,6 +461,10 @@ intel_framebuffer_renderbuffer(struct gl_context * ctx,
    intel_draw_buffer(ctx, fb);
 }
 
+static bool
+intel_update_tex_wrapper_regions(struct intel_context *intel,
+                                struct intel_renderbuffer *irb,
+                                struct intel_texture_image *intel_image);
 
 static GLboolean
 intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb, 
@@ -453,21 +491,63 @@ intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb,
    irb->Base.Delete = intel_delete_renderbuffer;
    irb->Base.AllocStorage = intel_nop_alloc_storage;
 
+   if (intel_image->stencil_rb) {
+      /*  The tex image has packed depth/stencil format, but is using separate
+       * stencil. */
+
+      bool ok;
+      struct intel_renderbuffer *depth_irb =
+        intel_renderbuffer(intel_image->depth_rb);
+
+      /* Update the hiz region if necessary. */
+      ok =  intel_update_tex_wrapper_regions(intel, depth_irb, intel_image);
+      if (!ok) {
+        return false;
+      }
+
+      /* The tex image shares its embedded depth and stencil renderbuffers with
+       * the renderbuffer wrapper. */
+      if (irb->wrapped_depth != intel_image->depth_rb) {
+        _mesa_reference_renderbuffer(&irb->wrapped_depth,
+                                     intel_image->depth_rb);
+      }
+      if (irb->wrapped_stencil != intel_image->stencil_rb) {
+        _mesa_reference_renderbuffer(&irb->wrapped_stencil,
+                                     intel_image->stencil_rb);
+      }
+
+      return true;
+
+   } else {
+      return intel_update_tex_wrapper_regions(intel, irb, intel_image);
+   }
+}
+
+/**
+ * FIXME: The handling of the hiz region is broken for mipmapped depth textures
+ * FIXME: because intel_finalize_mipmap_tree is unaware of it.
+ */
+static bool
+intel_update_tex_wrapper_regions(struct intel_context *intel,
+                                struct intel_renderbuffer *irb,
+                                struct intel_texture_image *intel_image)
+{
+   struct gl_renderbuffer *rb = &irb->Base;
+
    /* Point the renderbuffer's region to the texture's region. */
    if (irb->region != intel_image->mt->region) {
-      intel_region_release(&irb->region);
       intel_region_reference(&irb->region, intel_image->mt->region);
    }
 
    /* Allocate the texture's hiz region if necessary. */
-   if (intel->vtbl.is_hiz_depth_format(intel, texImage->TexFormat)
+   if (intel->vtbl.is_hiz_depth_format(intel, rb->Format)
        && !intel_image->mt->hiz_region) {
       intel_image->mt->hiz_region =
          intel_region_alloc(intel->intelScreen,
                             I915_TILING_Y,
-                            _mesa_get_format_bytes(texImage->TexFormat),
-                            texImage->Width,
-                            texImage->Height,
+                            _mesa_get_format_bytes(rb->Format),
+                            rb->Width,
+                            rb->Height,
                             GL_TRUE);
       if (!intel_image->mt->hiz_region)
          return GL_FALSE;
@@ -475,7 +555,6 @@ intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb,
 
    /* Point the renderbuffer's hiz region to the texture's hiz region. */
    if (irb->hiz_region != intel_image->mt->hiz_region) {
-      intel_region_release(&irb->hiz_region);
       intel_region_reference(&irb->hiz_region, intel_image->mt->hiz_region);
    }
 
@@ -512,12 +591,11 @@ intel_wrap_texture(struct gl_context * ctx, struct gl_texture_image *texImage)
    return irb;
 }
 
-static void
+void
 intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb,
                                   struct intel_texture_image *intel_image,
                                   int zoffset)
 {
-   struct intel_mipmap_tree *mt = intel_image->mt;
    unsigned int dst_x, dst_y;
 
    /* compute offset of the particular 2D image within the texture region */
@@ -527,7 +605,6 @@ intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb,
                                  zoffset,
                                  &dst_x, &dst_y);
 
-   irb->draw_offset = (dst_y * mt->region->pitch + dst_x) * mt->cpp;
    irb->draw_x = dst_x;
    irb->draw_y = dst_y;
 }
@@ -568,6 +645,22 @@ intel_renderbuffer_tile_offsets(struct intel_renderbuffer *irb,
    }
 }
 
+#ifndef I915
+static bool
+need_tile_offset_workaround(struct brw_context *brw,
+                           struct intel_renderbuffer *irb)
+{
+   uint32_t tile_x, tile_y;
+
+   if (brw->has_surface_tile_offset)
+      return false;
+
+   intel_renderbuffer_tile_offsets(irb, &tile_x, &tile_y);
+
+   return tile_x != 0 || tile_y != 0;
+}
+#endif
+
 /**
  * Called by glFramebufferTexture[123]DEXT() (and other places) to
  * prepare for rendering into texture memory.  This might be called
@@ -621,8 +714,7 @@ intel_render_texture(struct gl_context * ctx,
    intel_image->used_as_render_target = GL_TRUE;
 
 #ifndef I915
-   if (!brw_context(ctx)->has_surface_tile_offset &&
-       (irb->draw_offset & 4095) != 0) {
+   if (need_tile_offset_workaround(brw_context(ctx), irb)) {
       /* Original gen4 hardware couldn't draw to a non-tile-aligned
        * destination in a miptree unless you actually setup your
        * renderbuffer as a miptree and used the fragile
@@ -653,7 +745,6 @@ intel_render_texture(struct gl_context * ctx,
       intel_image->mt = new_mt;
       intel_renderbuffer_set_draw_offset(irb, intel_image, att->Zoffset);
 
-      intel_region_release(&irb->region);
       intel_region_reference(&irb->region, intel_image->mt->region);
    }
 #endif
@@ -707,29 +798,21 @@ intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
     * The depth and stencil renderbuffers are the same renderbuffer or wrap
     * the same texture.
     */
-   bool depth_stencil_are_same;
-   if (depthRb && stencilRb && depthRb == stencilRb)
-      depth_stencil_are_same = true;
-   else if (depthRb && stencilRb && depthRb != stencilRb
-           && (fb->Attachment[BUFFER_DEPTH].Type == GL_TEXTURE)
-           && (fb->Attachment[BUFFER_STENCIL].Type == GL_TEXTURE)
-           && (fb->Attachment[BUFFER_DEPTH].Texture->Name
-               == fb->Attachment[BUFFER_STENCIL].Texture->Name))
-      depth_stencil_are_same = true;
-   else
-      depth_stencil_are_same = false;
-
-   bool fb_has_combined_depth_stencil_format =
-     (depthRb && depthRb->Base.Format == MESA_FORMAT_S8_Z24) ||
-     (stencilRb && stencilRb->Base.Format == MESA_FORMAT_S8_Z24);
-
-   bool fb_has_hiz = intel_framebuffer_has_hiz(fb);
-
-   if ((intel->must_use_separate_stencil || fb_has_hiz)
-        && (depth_stencil_are_same || fb_has_combined_depth_stencil_format)) {
-      fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
-   } else if (!intel->has_separate_stencil && depthRb && stencilRb && !depth_stencil_are_same) {
-      fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+   if (depthRb && stencilRb) {
+      bool depth_stencil_are_same;
+      if (depthRb == stencilRb)
+        depth_stencil_are_same = true;
+      else if ((fb->Attachment[BUFFER_DEPTH].Type == GL_TEXTURE) &&
+              (fb->Attachment[BUFFER_STENCIL].Type == GL_TEXTURE) &&
+              (fb->Attachment[BUFFER_DEPTH].Texture->Name ==
+               fb->Attachment[BUFFER_STENCIL].Texture->Name))
+        depth_stencil_are_same = true;
+      else
+        depth_stencil_are_same = false;
+
+      if (!intel->has_separate_stencil && !depth_stencil_are_same) {
+        fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+      }
    }
 
    for (i = 0; i < Elements(fb->Attachment); i++) {
index 509f588..2487994 100644 (file)
@@ -33,6 +33,7 @@
 #include "intel_screen.h"
 
 struct intel_context;
+struct intel_texture_image;
 
 /**
  * Intel renderbuffer, derived from gl_renderbuffer.
@@ -45,7 +46,18 @@ struct intel_renderbuffer
    /** Only used by depth renderbuffers for which HiZ is enabled. */
    struct intel_region *hiz_region;
 
-   GLuint draw_offset; /**< Offset of drawing address within the region */
+   /**
+    * \name Packed depth/stencil unwrappers
+    *
+    * If the intel_context is using separate stencil and this renderbuffer has
+    * a a packed depth/stencil format, then wrapped_depth and wrapped_stencil
+    * are the real renderbuffers.
+    */
+   struct gl_renderbuffer *wrapped_depth;
+   struct gl_renderbuffer *wrapped_stencil;
+
+   /** \} */
+
    GLuint draw_x, draw_y; /**< Offset of drawing within the region */
 };
 
@@ -76,15 +88,47 @@ intel_renderbuffer(struct gl_renderbuffer *rb)
 
 
 /**
- * Return a framebuffer's renderbuffer, named by a BUFFER_x index.
+ * \brief Return the framebuffer attachment specified by attIndex.
+ *
+ * If the framebuffer lacks the specified attachment, then return null.
+ *
+ * If the attached renderbuffer is a wrapper, then return wrapped
+ * renderbuffer.
  */
 static INLINE struct intel_renderbuffer *
-intel_get_renderbuffer(struct gl_framebuffer *fb, int attIndex)
+intel_get_renderbuffer(struct gl_framebuffer *fb, gl_buffer_index attIndex)
 {
-   if (attIndex >= 0)
-      return intel_renderbuffer(fb->Attachment[attIndex].Renderbuffer);
-   else
+   struct gl_renderbuffer *rb;
+   struct intel_renderbuffer *irb;
+
+   /* XXX: Who passes -1 to intel_get_renderbuffer? */
+   if (attIndex < 0)
+      return NULL;
+
+   rb = fb->Attachment[attIndex].Renderbuffer;
+   if (!rb)
+      return NULL;
+
+   irb = intel_renderbuffer(rb);
+   if (!irb)
       return NULL;
+
+   switch (attIndex) {
+   case BUFFER_DEPTH:
+      if (irb->wrapped_depth) {
+        irb = intel_renderbuffer(irb->wrapped_depth);
+      }
+      break;
+   case BUFFER_STENCIL:
+      if (irb->wrapped_stencil) {
+        irb = intel_renderbuffer(irb->wrapped_stencil);
+      }
+      break;
+   default:
+      break;
+   }
+
+   return irb;
 }
 
 /**
@@ -110,21 +154,19 @@ intel_framebuffer_has_hiz(struct gl_framebuffer *fb)
    return intel_framebuffer_get_hiz_region(fb) != NULL;
 }
 
-
-extern void
-intel_renderbuffer_set_region(struct intel_context *intel,
-                             struct intel_renderbuffer *irb,
-                             struct intel_region *region);
-
-extern void
-intel_renderbuffer_set_hiz_region(struct intel_context *intel,
-                                 struct intel_renderbuffer *rb,
-                                 struct intel_region *region);
-
-
 extern struct intel_renderbuffer *
 intel_create_renderbuffer(gl_format format);
 
+struct gl_renderbuffer*
+intel_create_wrapped_renderbuffer(struct gl_context * ctx,
+                                 int width, int height,
+                                 gl_format format);
+
+GLboolean
+intel_alloc_renderbuffer_storage(struct gl_context * ctx,
+                                struct gl_renderbuffer *rb,
+                                 GLenum internalFormat,
+                                 GLuint width, GLuint height);
 
 extern void
 intel_fbo_init(struct intel_context *intel);
@@ -133,6 +175,11 @@ intel_fbo_init(struct intel_context *intel);
 extern void
 intel_flip_renderbuffers(struct gl_framebuffer *fb);
 
+void
+intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb,
+                                  struct intel_texture_image *intel_image,
+                                  int zoffset);
+
 uint32_t
 intel_renderbuffer_tile_offsets(struct intel_renderbuffer *irb,
                                uint32_t *tile_x,
index 64c7acc..86d0ef2 100644 (file)
@@ -175,7 +175,7 @@ do_blit_bitmap( struct gl_context *ctx,
                const GLubyte *bitmap )
 {
    struct intel_context *intel = intel_context(ctx);
-   struct intel_region *dst = intel_drawbuf_region(intel);
+   struct intel_region *dst;
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    GLfloat tmpColor[4];
    GLubyte ubcolor[4];
@@ -198,6 +198,9 @@ do_blit_bitmap( struct gl_context *ctx,
       return GL_FALSE;
    }
 
+   intel_prepare_render(intel);
+   dst = intel_drawbuf_region(intel);
+
    if (!dst)
        return GL_FALSE;
 
@@ -226,8 +229,6 @@ do_blit_bitmap( struct gl_context *ctx,
    if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
       return GL_FALSE;
 
-   intel_prepare_render(intel);
-
    /* Clip to buffer bounds and scissor. */
    if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
                             fb->_Xmax, fb->_Ymax,
index 5258699..a98a669 100644 (file)
@@ -49,7 +49,6 @@
 #define I1_LOAD_S(n)                      (1<<(4+n))
 
 #define _3DSTATE_DRAWRECT_INFO         (CMD_3D | (0x1d<<24) | (0x80<<16) | 0x3)
-#define _3DSTATE_DRAWRECT_INFO_I965    (CMD_3D | (3 << 27) | (1 << 24) | 0x2)
 
 /** @{
  *
@@ -76,6 +75,7 @@
 #define PIPE_CONTROL_VF_CACHE_INVALIDATE       (1 << 4)
 #define PIPE_CONTROL_CONST_CACHE_INVALIDATE    (1 << 3)
 #define PIPE_CONTROL_STATE_CACHE_INVALIDATE    (1 << 2)
+#define PIPE_CONTROL_STALL_AT_SCOREBOARD       (1 << 1)
 #define PIPE_CONTROL_DEPTH_CACHE_FLUSH         (1 << 0)
 #define PIPE_CONTROL_PPGTT_WRITE       (0 << 2)
 #define PIPE_CONTROL_GLOBAL_GTT_WRITE  (1 << 2)
index a4da1ce..4c4945c 100644 (file)
@@ -264,12 +264,15 @@ intel_region_alloc_for_handle(struct intel_screen *screen,
 void
 intel_region_reference(struct intel_region **dst, struct intel_region *src)
 {
-   if (src)
-      _DBG("%s %p %d\n", __FUNCTION__, src, src->refcount);
+   _DBG("%s: %p(%d) -> %p(%d)\n", __FUNCTION__,
+       *dst, *dst ? (*dst)->refcount : 0, src, src ? src->refcount : 0);
 
-   assert(*dst == NULL);
-   if (src) {
-      src->refcount++;
+   if (src != *dst) {
+      if (*dst)
+        intel_region_release(dst);
+
+      if (src)
+         src->refcount++;
       *dst = src;
    }
 }
index e915ca0..bd8d574 100644 (file)
@@ -282,13 +282,37 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
    }
 }
 
+static __DRIimage *
+intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
+{
+   __DRIimage *image;
+
+   image = CALLOC(sizeof *image);
+   if (image == NULL)
+      return NULL;
+
+   intel_region_reference(&image->region, orig_image->region);
+   if (image->region == NULL) {
+      FREE(image);
+      return NULL;
+   }
+
+   image->internal_format = orig_image->internal_format;
+   image->format          = orig_image->format;
+   image->data_type       = orig_image->data_type;
+   image->data            = loaderPrivate;
+   
+   return image;
+}
+
 static struct __DRIimageExtensionRec intelImageExtension = {
     { __DRI_IMAGE, __DRI_IMAGE_VERSION },
     intel_create_image_from_name,
     intel_create_image_from_renderbuffer,
     intel_destroy_image,
     intel_create_image,
-    intel_query_image
+    intel_query_image,
+    intel_dup_image
 };
 
 static const __DRIextension *intelScreenExtensions[] = {
index b2013af..9dd6a52 100644 (file)
  * x8_z24 and s8).
  *
  * Eventually, intel_update_renderbuffers() makes a DRI2 request for
- * DRI2BufferStencil and DRI2BufferHiz. If the returned buffers are Y tiled,
- * then we joyfully set intel_screen.dri2_has_hiz to true and continue as if
- * nothing happend.
+ * DRI2BufferStencil and DRI2BufferHiz. If the stencil buffer's tiling is
+ * I915_TILING_NONE [1], then we joyfully set intel_screen.dri2_has_hiz to
+ * true and continue as if nothing happend.
+ *
+ * [1] The stencil buffer is actually W tiled. However, we request from the
+ *     kernel a non-tiled buffer because the GTT is incapable of W fencing.
  *
  * If the buffers are X tiled, however, the handshake has failed and we must
  * clean up.
index 9343f40..2e1c80c 100644 (file)
@@ -131,38 +131,84 @@ intel_set_span_functions(struct intel_context *intel,
    int miny = 0;                                                       \
    int maxx = rb->Width;                                               \
    int maxy = rb->Height;                                              \
-   int stride = rb->RowStride;                                         \
-   uint8_t *buf = rb->Data;                                            \
+                                                                       \
+   /*                                                                  \
+    * Here we ignore rb->Data and rb->RowStride as set by              \
+    * intelSpanRenderStart. Since intel_offset_S8 decodes the W tile   \
+    * manually, the region's *real* base address and stride is         \
+    * required.                                                                \
+    */                                                                 \
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);            \
+   uint8_t *buf = irb->region->buffer->virtual;                                \
+   unsigned stride = irb->region->pitch;                               \
+   unsigned height = 2 * irb->region->height;                          \
+   bool flip = rb->Name == 0;                                          \
+   int y_scale = flip ? -1 : 1;                                                \
+   int y_bias = flip ? (height - 1) : 0;                               \
 
-/* Don't flip y. */
 #undef Y_FLIP
-#define Y_FLIP(y) y
+#define Y_FLIP(y) (y_scale * (y) + y_bias)
 
 /**
  * \brief Get pointer offset into stencil buffer.
  *
- * The stencil buffer interleaves two rows into one. Yay for crazy hardware.
- * The table below demonstrates how the pointer arithmetic behaves for a buffer
- * with positive stride (s=stride).
- *
- *     x    | y     | byte offset
- *     --------------------------
- *     0    | 0     | 0
- *     0    | 0     | 1
- *     1    | 0     | 2
- *     1    | 1     | 3
- *     ...  | ...   | ...
- *     0    | 2     | s
- *     0    | 3     | s + 1
- *     1    | 2     | s + 2
- *     1    | 3     | s + 3
+ * The stencil buffer is W tiled. Since the GTT is incapable of W fencing, we
+ * must decode the tile's layout in software.
  *
+ * See
+ *   - PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.2.1 W-Major Tile
+ *     Format.
+ *   - PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.3 Tiling Algorithm
  *
+ * Even though the returned offset is always positive, the return type is
+ * signed due to
+ *    commit e8b1c6d6f55f5be3bef25084fdd8b6127517e137
+ *    mesa: Fix return type of  _mesa_get_format_bytes() (#37351)
  */
 static inline intptr_t
-intel_offset_S8(int stride, GLint x, GLint y)
+intel_offset_S8(uint32_t stride, uint32_t x, uint32_t y)
 {
-   return 2 * ((y / 2) * stride + x) + y % 2;
+   uint32_t tile_size = 4096;
+   uint32_t tile_width = 64;
+   uint32_t tile_height = 64;
+   uint32_t row_size = 64 * stride;
+
+   uint32_t tile_x = x / tile_width;
+   uint32_t tile_y = y / tile_height;
+
+   /* The byte's address relative to the tile's base addres. */
+   uint32_t byte_x = x % tile_width;
+   uint32_t byte_y = y % tile_height;
+
+   uintptr_t u = tile_y * row_size
+               + tile_x * tile_size
+               + 512 * (byte_x / 8)
+               +  64 * (byte_y / 8)
+               +  32 * ((byte_y / 4) % 2)
+               +  16 * ((byte_x / 4) % 2)
+               +   8 * ((byte_y / 2) % 2)
+               +   4 * ((byte_x / 2) % 2)
+               +   2 * (byte_y % 2)
+               +   1 * (byte_x % 2);
+
+   /*
+    * Errata for Gen5:
+    *
+    * An additional offset is needed which is not documented in the PRM.
+    *
+    * if ((byte_x / 8) % 2 == 1) {
+    *    if ((byte_y / 8) % 2) == 0) {
+    *       u += 64;
+    *    } else {
+    *       u -= 64;
+    *    }
+    * }
+    *
+    * The offset is expressed more tersely as
+    * u += ((int) x & 0x8) * (8 - (((int) y & 0x8) << 1));
+    */
+
+   return u;
 }
 
 #define WRITE_STENCIL(x, y, src)  buf[intel_offset_S8(stride, x, y)] = src;
@@ -177,7 +223,15 @@ intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
 {
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
-   if (irb == NULL || irb->region == NULL)
+   if (!irb)
+      return;
+
+   if (irb->wrapped_depth)
+      intel_renderbuffer_map(intel, irb->wrapped_depth);
+   if (irb->wrapped_stencil)
+      intel_renderbuffer_map(intel, irb->wrapped_stencil);
+
+   if (!irb->region)
       return;
 
    drm_intel_gem_bo_map_gtt(irb->region->buffer);
@@ -206,7 +260,15 @@ intel_renderbuffer_unmap(struct intel_context *intel,
 {
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
-   if (irb == NULL || irb->region == NULL)
+   if (!irb)
+      return;
+
+   if (irb->wrapped_depth)
+      intel_renderbuffer_unmap(intel, irb->wrapped_depth);
+   if (irb->wrapped_stencil)
+      intel_renderbuffer_unmap(intel, irb->wrapped_stencil);
+
+   if (!irb->region)
       return;
 
    drm_intel_gem_bo_unmap_gtt(irb->region->buffer);
index 32e1fb7..21c4a1d 100644 (file)
@@ -1,4 +1,5 @@
 #include "swrast/swrast.h"
+#include "main/renderbuffer.h"
 #include "main/texobj.h"
 #include "main/teximage.h"
 #include "main/mipmap.h"
@@ -59,6 +60,14 @@ intelFreeTextureImageData(struct gl_context * ctx, struct gl_texture_image *texI
       _mesa_free_texmemory(texImage->Data);
       texImage->Data = NULL;
    }
+
+   if (intelImage->depth_rb) {
+      _mesa_reference_renderbuffer(&intelImage->depth_rb, NULL);
+   }
+
+   if (intelImage->stencil_rb) {
+      _mesa_reference_renderbuffer(&intelImage->stencil_rb, NULL);
+   }
 }
 
 /**
index eda07a4..e89e91d 100644 (file)
@@ -55,15 +55,11 @@ get_teximage_readbuffer(struct intel_context *intel, GLenum internalFormat)
    DBG("%s %s\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(internalFormat));
 
-   switch (internalFormat) {
-   case GL_DEPTH_COMPONENT:
-   case GL_DEPTH_COMPONENT16:
-   case GL_DEPTH24_STENCIL8_EXT:
-   case GL_DEPTH_STENCIL_EXT:
+   if (_mesa_is_depth_format(internalFormat) ||
+       _mesa_is_depthstencil_format(internalFormat))
       return intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH);
-   default:
-      return intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
-   }
+
+   return intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
 }
 
 
@@ -168,101 +164,6 @@ intel_copy_texsubimage(struct intel_context *intel,
 
 
 static void
-intelCopyTexImage1D(struct gl_context * ctx, GLenum target, GLint level,
-                    GLenum internalFormat,
-                    GLint x, GLint y, GLsizei width, 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, height;
-
-   if (border)
-      goto fail;
-
-   /* Setup or redefine the texture object, mipmap tree and texture
-    * image.  Don't populate yet.  
-    */
-   ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
-                          width, border,
-                          GL_RGBA, CHAN_TYPE, NULL,
-                          &ctx->DefaultPacking, texObj, texImage);
-   srcx = x;
-   srcy = y;
-   dstx = 0;
-   dsty = 0;
-   height = 1;
-   if (!_mesa_clip_copytexsubimage(ctx,
-                                  &dstx, &dsty,
-                                  &srcx, &srcy,
-                                  &width, &height))
-      return;
-
-   if (!intel_copy_texsubimage(intel_context(ctx), target,
-                               intel_texture_image(texImage),
-                               internalFormat, 0, 0, x, y, width, height))
-      goto fail;
-
-   return;
-
- fail:
-   fallback_debug("%s - fallback to swrast\n", __FUNCTION__);
-   _mesa_meta_CopyTexImage1D(ctx, target, level, internalFormat, x, y,
-                             width, border);
-}
-
-
-static void
-intelCopyTexImage2D(struct gl_context * 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 (!intel_copy_texsubimage(intel_context(ctx), target,
-                               intel_texture_image(texImage),
-                               internalFormat, 0, 0, x, y, width, height))
-      goto fail;
-
-   return;
-
- fail:
-   fallback_debug("%s - fallback to swrast\n", __FUNCTION__);
-   _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y,
-                             width, height, border);
-}
-
-
-static void
 intelCopyTexSubImage1D(struct gl_context * ctx, GLenum target, GLint level,
                        GLint xoffset, GLint x, GLint y, GLsizei width)
 {
@@ -316,8 +217,6 @@ intelCopyTexSubImage2D(struct gl_context * ctx, GLenum target, GLint level,
 void
 intelInitTextureCopyImageFuncs(struct dd_function_table *functions)
 {
-   functions->CopyTexImage1D = intelCopyTexImage1D;
-   functions->CopyTexImage2D = intelCopyTexImage2D;
    functions->CopyTexSubImage1D = intelCopyTexSubImage1D;
    functions->CopyTexSubImage2D = intelCopyTexSubImage2D;
 }
index 90d4117..1f8b885 100644 (file)
@@ -8,6 +8,7 @@
 #include "main/context.h"
 #include "main/formats.h"
 #include "main/pbo.h"
+#include "main/renderbuffer.h"
 #include "main/texcompress.h"
 #include "main/texstore.h"
 #include "main/texgetimage.h"
@@ -21,6 +22,7 @@
 #include "intel_tex.h"
 #include "intel_blit.h"
 #include "intel_fbo.h"
+#include "intel_span.h"
 
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
@@ -118,25 +120,6 @@ intel_miptree_create_for_teximage(struct intel_context *intel,
                               expect_accelerated_upload);
 }
 
-
-
-
-static GLuint
-target_to_face(GLenum target)
-{
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
-      return ((GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
-   default:
-      return 0;
-   }
-}
-
 /* There are actually quite a few combinations this will work for,
  * more than what I've listed here.
  */
@@ -277,6 +260,130 @@ try_pbo_zcopy(struct intel_context *intel,
    return GL_TRUE;
 }
 
+/**
+ * \param scatter Scatter if true. Gather if false.
+ *
+ * \see intel_tex_image_x8z24_scatter
+ * \see intel_tex_image_x8z24_gather
+ */
+static void
+intel_tex_image_s8z24_scattergather(struct intel_context *intel,
+                                   struct intel_texture_image *intel_image,
+                                   bool scatter)
+{
+   struct gl_context *ctx = &intel->ctx;
+   struct gl_renderbuffer *depth_rb = intel_image->depth_rb;
+   struct gl_renderbuffer *stencil_rb = intel_image->stencil_rb;
+
+   int w = intel_image->base.Width;
+   int h = intel_image->base.Height;
+
+   uint32_t depth_row[w];
+   uint8_t stencil_row[w];
+
+   intel_renderbuffer_map(intel, depth_rb);
+   intel_renderbuffer_map(intel, stencil_rb);
+
+   if (scatter) {
+      for (int y = 0; y < h; ++y) {
+        depth_rb->GetRow(ctx, depth_rb, w, 0, y, depth_row);
+        for (int x = 0; x < w; ++x) {
+           stencil_row[x] = depth_row[x] >> 24;
+        }
+        stencil_rb->PutRow(ctx, stencil_rb, w, 0, y, stencil_row, NULL);
+      }
+   } else { /* gather */
+      for (int y = 0; y < h; ++y) {
+        depth_rb->GetRow(ctx, depth_rb, w, 0, y, depth_row);
+        stencil_rb->GetRow(ctx, stencil_rb, w, 0, y, stencil_row);
+        for (int x = 0; x < w; ++x) {
+           uint32_t s8_x24 = stencil_row[x] << 24;
+           uint32_t x8_z24 = depth_row[x] & 0x00ffffff;
+           depth_row[x] = s8_x24 | x8_z24;
+        }
+        depth_rb->PutRow(ctx, depth_rb, w, 0, y, depth_row, NULL);
+      }
+   }
+
+   intel_renderbuffer_unmap(intel, depth_rb);
+   intel_renderbuffer_unmap(intel, stencil_rb);
+}
+
+/**
+ * Copy the x8 bits from intel_image->depth_rb to intel_image->stencil_rb.
+ */
+static void
+intel_tex_image_s8z24_scatter(struct intel_context *intel,
+                             struct intel_texture_image *intel_image)
+{
+   intel_tex_image_s8z24_scattergather(intel, intel_image, true);
+}
+
+/**
+ * Copy the data in intel_image->stencil_rb to the x8 bits in
+ * intel_image->depth_rb.
+ */
+static void
+intel_tex_image_s8z24_gather(struct intel_context *intel,
+                            struct intel_texture_image *intel_image)
+{
+   intel_tex_image_s8z24_scattergather(intel, intel_image, false);
+}
+
+static bool
+intel_tex_image_s8z24_create_renderbuffers(struct intel_context *intel,
+                                          struct intel_texture_image *image)
+{
+   struct gl_context *ctx = &intel->ctx;
+
+   bool ok = true;
+   int width = image->base.Width;
+   int height = image->base.Height;
+   struct gl_renderbuffer *drb;
+   struct gl_renderbuffer *srb;
+   struct intel_renderbuffer *idrb;
+   struct intel_renderbuffer *isrb;
+
+   assert(intel->has_separate_stencil);
+   assert(image->base.TexFormat == MESA_FORMAT_S8_Z24);
+   assert(image->mt != NULL);
+
+   drb = intel_create_wrapped_renderbuffer(ctx, width, height,
+                                          MESA_FORMAT_X8_Z24);
+   srb = intel_create_wrapped_renderbuffer(ctx, width, height,
+                                          MESA_FORMAT_S8);
+
+   if (!drb || !srb) {
+      if (drb) {
+        drb->Delete(drb);
+      }
+      if (srb) {
+        srb->Delete(srb);
+      }
+      return false;
+   }
+
+   idrb = intel_renderbuffer(drb);
+   isrb = intel_renderbuffer(srb);
+
+   intel_region_reference(&idrb->region, image->mt->region);
+   ok = intel_alloc_renderbuffer_storage(ctx, srb, GL_STENCIL_INDEX8,
+                                        width, height);
+
+   if (!ok) {
+      drb->Delete(drb);
+      srb->Delete(srb);
+      return false;
+   }
+
+   intel_renderbuffer_set_draw_offset(idrb, image, 0);
+   intel_renderbuffer_set_draw_offset(isrb, image, 0);
+
+   _mesa_reference_renderbuffer(&image->depth_rb, drb);
+   _mesa_reference_renderbuffer(&image->stencil_rb, srb);
+
+   return true;
+}
 
 static void
 intelTexImage(struct gl_context * ctx,
@@ -300,7 +407,7 @@ intelTexImage(struct gl_context * 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);
 
-   intelImage->face = target_to_face(target);
+   intelImage->face = _mesa_tex_target_to_face(target);
    intelImage->level = level;
 
    if (_mesa_is_format_compressed(texImage->TexFormat)) {
@@ -314,18 +421,7 @@ intelTexImage(struct gl_context * ctx,
       }
    }
 
-   /* Release the reference to a potentially orphaned buffer.   
-    * Release any old malloced memory.
-    */
-   if (intelImage->mt) {
-      intel_miptree_release(intel, &intelImage->mt);
-      assert(!texImage->Data);
-   }
-   else if (texImage->Data) {
-      _mesa_free_texmemory(texImage->Data);
-      texImage->Data = NULL;
-   }
-
+   ctx->Driver.FreeTexImageData(ctx, texImage);
    assert(!intelImage->mt);
 
    if (intelObj->mt &&
@@ -484,6 +580,12 @@ intelTexImage(struct gl_context * ctx,
 
    _mesa_unmap_teximage_pbo(ctx, unpack);
 
+   if (intel->must_use_separate_stencil
+       && texImage->TexFormat == MESA_FORMAT_S8_Z24) {
+      intel_tex_image_s8z24_create_renderbuffers(intel, intelImage);
+      intel_tex_image_s8z24_scatter(intel, intelImage);
+   }
+
    if (intelImage->mt) {
       if (pixels != NULL)
          intel_miptree_image_unmap(intel, intelImage->mt);
@@ -600,6 +702,14 @@ intel_get_tex_image(struct gl_context * ctx, GLenum target, GLint level,
       assert(intelImage->base.Data);
    }
 
+   if (intelImage->stencil_rb) {
+      /*
+       * The texture has packed depth/stencil format, but uses separate
+       * stencil. The texture's embedded stencil buffer contains the real
+       * stencil data, so copy that into the miptree.
+       */
+      intel_tex_image_s8z24_gather(intel, intelImage);
+   }
 
    if (compressed) {
       _mesa_get_compressed_teximage(ctx, target, level, pixels,
@@ -706,7 +816,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
                              rb->region->width, rb->region->height, 1,
                              0, internalFormat, texFormat);
 
-   intelImage->face = target_to_face(target);
+   intelImage->face = _mesa_tex_target_to_face(target);
    intelImage->level = level;
    texImage->RowStride = rb->region->pitch;
    intel_miptree_reference(&intelImage->mt, intelObj->mt);
@@ -764,7 +874,7 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
                              image->region->width, image->region->height, 1,
                              0, image->internal_format, image->format);
 
-   intelImage->face = target_to_face(target);
+   intelImage->face = _mesa_tex_target_to_face(target);
    intelImage->level = 0;
    texImage->RowStride = image->region->pitch;
    intel_miptree_reference(&intelImage->mt, intelObj->mt);
index e93ef4a..a9ae2ec 100644 (file)
@@ -63,6 +63,36 @@ struct intel_texture_image
     */
    struct intel_mipmap_tree *mt;
    GLboolean used_as_render_target;
+
+   /**
+    * \name Renderbuffers for faking packed depth/stencil
+    *
+    * These renderbuffers are non-null only if the intel_context is using
+    * separate stencil and this texture has a packed depth/stencil format. When
+    * glFramebufferTexture is called on this image, the resultant renderbuffer
+    * wrapper reuses these renderbuffers as its own.
+    *
+    * \see intel_wrap_texture
+    * \see intel_tex_image_s8z24_create_renderbuffers
+    * \see intel_tex_image_s8z24_scatter
+    * \see intel_tex_image_s8z24_gather
+    *
+    * \{
+    */
+
+   /**
+    * The depth buffer has format X8_Z24. The x8 bits are undefined unless
+    * intel_tex_image_s8z24_gather has been immediately called. The depth buffer
+    * resuses the image miptree's region and hiz_region as its own.
+    */
+   struct gl_renderbuffer *depth_rb;
+
+   /**
+    * The stencil buffer has format S8 and keeps its data in its own region.
+    */
+   struct gl_renderbuffer *stencil_rb;
+
+   /** \} */
 };
 
 static INLINE struct intel_texture_object *
index 20fb447..6134650 100644 (file)
@@ -99,7 +99,7 @@ get_hw_format(int type)
        case GL_UNSIGNED_SHORT:
                return NV10_3D_VTXBUF_FMT_TYPE_V16_SNORM;
        case GL_UNSIGNED_BYTE:
-               return NV10_3D_VTXBUF_FMT_TYPE_B8G8R8A8_UNORM;
+               return NV10_3D_VTXBUF_FMT_TYPE_U8_UNORM;
        default:
                assert(0);
        }
index 931a9ec..a512c9d 100644 (file)
@@ -47,9 +47,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #define insert_at_tail_if(atom_list, atom) \
    do { \
-      struct radeon_state_atom* __atom = (atom); \
-      if (__atom->check) \
-        insert_at_tail((atom_list), __atom); \
+      struct radeon_state_atom* current_atom = (atom); \
+      if (current_atom->check) \
+        insert_at_tail((atom_list), current_atom); \
    } while(0)
 
 void r200SetUpAtomList( r200ContextPtr rmesa )
index 02201cb..44a794d 100644 (file)
@@ -185,7 +185,6 @@ static void r200Clear( struct gl_context *ctx, GLbitfield mask )
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
    GLuint flags = 0;
-   GLuint color_mask = 0;
    GLuint orig_mask = mask;
 
    if ( R200_DEBUG & RADEON_IOCTL ) {
@@ -206,13 +205,11 @@ static void r200Clear( struct gl_context *ctx, GLbitfield mask )
 
    if ( mask & BUFFER_BIT_FRONT_LEFT ) {
       flags |= RADEON_FRONT;
-      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
       mask &= ~BUFFER_BIT_FRONT_LEFT;
    }
 
    if ( mask & BUFFER_BIT_BACK_LEFT ) {
       flags |= RADEON_BACK;
-      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
       mask &= ~BUFFER_BIT_BACK_LEFT;
    }
 
index d42e8f1..91e77f9 100644 (file)
@@ -527,7 +527,6 @@ void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *fu
    functions->CompressedTexSubImage2D  = radeonCompressedTexSubImage2D;
 
    if (radeon->radeonScreen->kernel_mm) {
-      functions->CopyTexImage2D = radeonCopyTexImage2D;
       functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
    }
 
index 7adf9ad..8c9bd6d 100644 (file)
@@ -773,18 +773,12 @@ void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
        struct radeon_renderbuffer *rb;
        radeon_texture_image *rImage;
        radeonContextPtr radeon;
-       r200ContextPtr rmesa;
        struct radeon_framebuffer *rfb;
        radeonTexObjPtr t;
        uint32_t pitch_val;
-       uint32_t internalFormat, format;
        gl_format texFormat;
 
-       format = GL_UNSIGNED_BYTE;
-       internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4);
-
        radeon = pDRICtx->driverPrivate;
-       rmesa = pDRICtx->driverPrivate;
 
        rfb = dPriv->driverPrivate;
         texUnit = &radeon->glCtx->Texture.Unit[radeon->glCtx->Texture.CurrentUnit];
index b0deb75..a8decac 100644 (file)
@@ -687,7 +687,7 @@ static void get_readers_for_single_write(
        struct rc_instruction * tmp;
        unsigned int branch_depth = 0;
        struct rc_instruction * endloop = NULL;
-       unsigned int abort_on_read_at_endloop;
+       unsigned int abort_on_read_at_endloop = 0;
        struct get_readers_callback_data * d = userdata;
 
        d->ReaderData->Writer = writer;
index ac73608..39dcb21 100644 (file)
@@ -560,32 +560,30 @@ static int peephole_add_presub_add(
        struct radeon_compiler * c,
        struct rc_instruction * inst_add)
 {
-       struct rc_src_register * src0 = NULL;
-       struct rc_src_register * src1 = NULL;
-       unsigned int i;
-
-       if (!is_presub_candidate(c, inst_add))
-               return 0;
+       unsigned dstmask = inst_add->U.I.DstReg.WriteMask;
+        unsigned src0_neg = inst_add->U.I.SrcReg[0].Negate & dstmask;
+        unsigned src1_neg = inst_add->U.I.SrcReg[1].Negate & dstmask;
 
        if (inst_add->U.I.SrcReg[0].Swizzle != inst_add->U.I.SrcReg[1].Swizzle)
                return 0;
 
-       /* src0 and src1 can't have absolute values only one can be negative and they must be all negative or all positive. */
-       for (i = 0; i < 2; i++) {
-               if (inst_add->U.I.SrcReg[i].Abs)
-                       return 0;
-               if ((inst_add->U.I.SrcReg[i].Negate
-                                       & inst_add->U.I.DstReg.WriteMask) ==
-                                               inst_add->U.I.DstReg.WriteMask) {
-                       src0 = &inst_add->U.I.SrcReg[i];
-               } else if (!src1) {
-                       src1 = &inst_add->U.I.SrcReg[i];
-               } else {
-                       src0 = &inst_add->U.I.SrcReg[i];
-               }
-       }
+       /* src0 and src1 can't have absolute values */
+       if (inst_add->U.I.SrcReg[0].Abs || inst_add->U.I.SrcReg[1].Abs)
+               return 0;
+
+       /* presub_replace_add() assumes only one is negative */
+       if (inst_add->U.I.SrcReg[0].Negate && inst_add->U.I.SrcReg[1].Negate)
+               return 0;
+
+        /* if src0 is negative, at least all bits of dstmask have to be set */
+        if (inst_add->U.I.SrcReg[0].Negate && src0_neg != dstmask)
+               return 0;
 
-       if (!src1)
+        /* if src1 is negative, at least all bits of dstmask have to be set */
+        if (inst_add->U.I.SrcReg[1].Negate && src1_neg != dstmask)
+               return 0;
+
+       if (!is_presub_candidate(c, inst_add))
                return 0;
 
        if (presub_helper(c, inst_add, RC_PRESUB_ADD, presub_replace_add)) {
@@ -618,7 +616,7 @@ static void presub_replace_inv(
  * of the add instruction must have the constatnt 1 swizzle.  This function
  * does not check const registers to see if their value is 1.0, so it should
  * be called after the constant_folding optimization.
- * @return 
+ * @return
  *     0 if the ADD instruction is still part of the program.
  *     1 if the ADD instruction is no longer part of the program.
  */
index 590d9af..93d8fe1 100644 (file)
@@ -379,7 +379,6 @@ void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *fun
        functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
 
        if (radeon->radeonScreen->kernel_mm) {
-               functions->CopyTexImage2D = radeonCopyTexImage2D;
                functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
        }
 
index e24ad6f..e4388a0 100644 (file)
@@ -427,13 +427,8 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
        struct radeon_framebuffer *rfb;
        radeonTexObjPtr t;
        uint32_t pitch_val;
-       uint32_t internalFormat, type, format;
        gl_format texFormat;
 
-       type = GL_BGRA;
-       format = GL_UNSIGNED_BYTE;
-       internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4);
-
        radeon = pDRICtx->driverPrivate;
        rmesa = pDRICtx->driverPrivate;
 
index 33a5f27..d240a21 100644 (file)
@@ -1288,19 +1288,12 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur
        struct radeon_renderbuffer *rb;
        radeon_texture_image *rImage;
        radeonContextPtr radeon;
-       context_t *rmesa;
        struct radeon_framebuffer *rfb;
        radeonTexObjPtr t;
        uint32_t pitch_val;
-       uint32_t internalFormat, type, format;
        gl_format texFormat;
 
-       type = GL_BGRA;
-       format = GL_UNSIGNED_BYTE;
-       internalFormat = (glx_texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4);
-
        radeon = pDRICtx->driverPrivate;
-       rmesa = pDRICtx->driverPrivate;
 
        rfb = dPriv->driverPrivate;
         texUnit = &radeon->glCtx->Texture.Unit[radeon->glCtx->Texture.CurrentUnit];
@@ -1688,7 +1681,6 @@ void evergreenInitTextureFuncs(radeonContextPtr radeon, struct dd_function_table
        functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
 
        if (radeon->radeonScreen->kernel_mm) {
-               functions->CopyTexImage2D = radeonCopyTexImage2D;
                functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
        }
 
index ce2f777..74f048b 100644 (file)
@@ -259,13 +259,11 @@ 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*)csi->csm;
     struct r600_cs_reloc_legacy *relocs;
     int i, j, r;
 
     uint32_t offset_dw = 0;
 
-    csm = (struct r600_cs_manager_legacy*)csi->csm;
     relocs = (struct r600_cs_reloc_legacy *)csi->relocs;
 restart:
     for (i = 0; i < csi->crelocs; i++) {
index eb7ed30..3efa1d1 100644 (file)
@@ -470,7 +470,6 @@ void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *fun
        functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
 
        if (radeon->radeonScreen->kernel_mm) {
-               functions->CopyTexImage2D = radeonCopyTexImage2D;
                functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
        }
 
index 949db29..65fae71 100644 (file)
@@ -1141,13 +1141,8 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
        struct radeon_framebuffer *rfb;
        radeonTexObjPtr t;
        uint32_t pitch_val;
-       uint32_t internalFormat, type, format;
         gl_format texFormat;
 
-       type = GL_BGRA;
-       format = GL_UNSIGNED_BYTE;
-       internalFormat = (glx_texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4);
-
        radeon = pDRICtx->driverPrivate;
        rmesa = pDRICtx->driverPrivate;
 
index 2bd3b62..0f7a7a4 100644 (file)
@@ -329,7 +329,7 @@ static void r700RunRenderPrimitiveImmediate(struct gl_context * ctx, int start,
 {
     context_t *context = R700_CONTEXT(ctx);
     BATCH_LOCALS(&context->radeon);
-    int type, i;
+    int type;
     uint32_t num_indices, total_emit = 0;
     uint32_t vgt_draw_initiator = 0;
     uint32_t vgt_index_type     = 0;
@@ -370,22 +370,7 @@ static void r700RunRenderPrimitiveImmediate(struct gl_context * ctx, int start,
     vgt_num_indices = num_indices;
     SETfield(vgt_draw_initiator, DI_MAJOR_MODE_0, MAJOR_MODE_shift, MAJOR_MODE_mask);
 
-    if (start == 0)
-    {
-       SETfield(vgt_draw_initiator, DI_SRC_SEL_AUTO_INDEX, SOURCE_SELECT_shift, SOURCE_SELECT_mask);
-    }
-    else
-    {
-       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_SRC_SEL_AUTO_INDEX, SOURCE_SELECT_shift, SOURCE_SELECT_mask);
 
     total_emit +=   3 /* VGT_PRIMITIVE_TYPE */
                  + 2 /* VGT_INDEX_TYPE */
@@ -406,45 +391,13 @@ static void r700RunRenderPrimitiveImmediate(struct gl_context * ctx, int start,
     /* offset */
     R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_CTL_CONST, 2));
     R600_OUT_BATCH(mmSQ_VTX_BASE_VTX_LOC - ASIC_CTL_CONST_BASE_INDEX);
-    R600_OUT_BATCH(0); //VTX_BASE_VTX_LOC
+    R600_OUT_BATCH(start); //VTX_BASE_VTX_LOC
     R600_OUT_BATCH(0); //VTX_START_INST_LOC
     // draw packet
-    if(start == 0)
-    {
-        R600_OUT_BATCH(CP_PACKET3(R600_IT_DRAW_INDEX_AUTO, 1));
-        R600_OUT_BATCH(vgt_num_indices);
-        R600_OUT_BATCH(vgt_draw_initiator);
-    }
-    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);
-           }
-       }
-       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));
-               }
-           }
-       }
-    }
+    
+    R600_OUT_BATCH(CP_PACKET3(R600_IT_DRAW_INDEX_AUTO, 1));
+    R600_OUT_BATCH(vgt_num_indices);
+    R600_OUT_BATCH(vgt_draw_initiator);
 
     END_BATCH();
     COMMIT_BATCH();
@@ -469,12 +422,7 @@ static GLuint r700PredictRenderSize(struct gl_context* ctx,
     else {
            for (i = 0; i < nr_prims; ++i)
            {
-                   if (prim[i].start == 0)
-                           dwords += 14;
-                   else if (prim[i].count > 0xffff)
-                           dwords += prim[i].count + 14;
-                   else
-                           dwords += ((prim[i].count + 1) / 2) + 14;
+               dwords += 14;
            }
     }
 
index bfc307c..e7a6623 100644 (file)
@@ -436,7 +436,6 @@ void radeonCopyBuffer( __DRIdrawable *dPriv,
                       const drm_clip_rect_t      *rect)
 {
        radeonContextPtr rmesa;
-       struct radeon_framebuffer *rfb;
        GLint nbox, i, ret;
 
        assert(dPriv);
@@ -447,8 +446,6 @@ void radeonCopyBuffer( __DRIdrawable *dPriv,
 
        LOCK_HARDWARE(rmesa);
 
-       rfb = dPriv->driverPrivate;
-
        if ( RADEON_DEBUG & RADEON_IOCTL ) {
                fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *) rmesa->glCtx );
        }
@@ -527,8 +524,6 @@ static GLboolean radeonPageFlip( __DRIdrawable *dPriv )
 {
        radeonContextPtr radeon;
        GLint ret;
-       __DRIscreen *psp;
-       struct radeon_renderbuffer *rrb;
        struct radeon_framebuffer *rfb;
 
        assert(dPriv);
@@ -537,9 +532,6 @@ static GLboolean radeonPageFlip( __DRIdrawable *dPriv )
 
        radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
        rfb = dPriv->driverPrivate;
-       rrb = (void *)rfb->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
-
-       psp = dPriv->driScreenPriv;
 
        LOCK_HARDWARE(radeon);
 
index bf8925f..c08b794 100644 (file)
@@ -515,7 +515,6 @@ void radeon_prepare_render(radeonContextPtr radeon)
     __DRIcontext *driContext = radeon->dri.context;
     __DRIdrawable *drawable;
     __DRIscreen *screen;
-    struct radeon_framebuffer *draw;
 
     screen = driContext->driScreenPriv;
     if (!screen->dri2.loader)
@@ -527,7 +526,6 @@ void radeon_prepare_render(radeonContextPtr radeon)
            radeon_update_renderbuffers(driContext, drawable, GL_FALSE);
 
        /* Intel driver does the equivalent of this, no clue if it is needed:*/
-       draw = drawable->driverPrivate;
        radeon_draw_buffer(radeon->glCtx, radeon->glCtx->DrawBuffer);
 
        driContext->dri2.draw_stamp = drawable->dri2.stamp;
index c2722a4..5595b70 100644 (file)
@@ -218,11 +218,9 @@ static int cs_end(struct radeon_cs_int *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;
     int i, j, r;
 
-    csm = (struct cs_manager_legacy*)cs->csm;
     relocs = (struct cs_reloc_legacy *)cs->relocs;
 restart:
     for (i = 0; i < cs->crelocs; i++) 
index a91d872..c23e9c2 100644 (file)
@@ -560,7 +560,6 @@ static void radeonClear( struct gl_context *ctx, GLbitfield mask )
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    __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)) {
@@ -582,13 +581,11 @@ static void radeonClear( struct gl_context *ctx, GLbitfield mask )
 
    if ( mask & BUFFER_BIT_FRONT_LEFT ) {
       flags |= RADEON_FRONT;
-      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
       mask &= ~BUFFER_BIT_FRONT_LEFT;
    }
 
    if ( mask & BUFFER_BIT_BACK_LEFT ) {
       flags |= RADEON_BACK;
-      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
       mask &= ~BUFFER_BIT_BACK_LEFT;
    }
 
index 7b6bd36..ae8a212 100644 (file)
@@ -114,16 +114,6 @@ void radeon_lock_hardware(radeonContextPtr radeon
                )
 {
        char ret = 0;
-       struct radeon_framebuffer *rfb = NULL;
-       struct radeon_renderbuffer *rrb = NULL;
-
-       if (radeon_get_drawable(radeon)) {
-               rfb = radeon_get_drawable(radeon)->driverPrivate;
-
-               if (rfb)
-                       rrb = radeon_get_renderbuffer(&rfb->base,
-                                                     rfb->base._ColorDrawBufferIndexes[0]);
-       }
 
        if (!radeon->radeonScreen->driScreen->dri2.enabled) {
                if (ATOMIC_INC_AND_FETCH(radeon->dri.hwLockCount) > 1)
index c5ddb6d..583a644 100644 (file)
@@ -1217,6 +1217,7 @@ static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
    case PCI_CHIP_TURKS_6750:
    case PCI_CHIP_TURKS_6758:
    case PCI_CHIP_TURKS_6759:
+   case PCI_CHIP_TURKS_675F:
        screen->chip_family = CHIP_FAMILY_TURKS;
        screen->chip_flags = RADEON_CHIPSET_TCL;
        break;
@@ -1231,6 +1232,7 @@ static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
    case PCI_CHIP_CAICOS_6767:
    case PCI_CHIP_CAICOS_6768:
    case PCI_CHIP_CAICOS_6770:
+   case PCI_CHIP_CAICOS_6778:
    case PCI_CHIP_CAICOS_6779:
        screen->chip_family = CHIP_FAMILY_CAICOS;
        screen->chip_flags = RADEON_CHIPSET_TCL;
@@ -1739,6 +1741,9 @@ radeonCreateScreen2(__DRIscreen *sPriv)
                           case 1:
                                   screen->num_banks = 8;
                                   break;
+                          case 2:
+                                  screen->num_banks = 16;
+                                  break;
                           default:
                                   fprintf(stderr, "bad banks\n");
                                   break;
index 25a8ddf..a0b5506 100644 (file)
@@ -455,7 +455,6 @@ void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *
    functions->CompressedTexSubImage2D  = radeonCompressedTexSubImage2D;
 
    if (radeon->radeonScreen->kernel_mm) {
-      functions->CopyTexImage2D = radeonCopyTexImage2D;
       functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
    }
 
index f14dfa2..94ff3c4 100644 (file)
@@ -141,61 +141,6 @@ do_copy_texsubimage(struct gl_context *ctx,
 }
 
 void
-radeonCopyTexImage2D(struct gl_context *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;
-
-    radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-    radeon_prepare_render(radeon);
-
-    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:
-    radeon_print(RADEON_FALLBACKS, RADEON_NORMAL,
-                 "Falling back to sw for glCopyTexImage2D (internalFormat %s, border %d)\n",
-                 _mesa_lookup_enum_by_nr(internalFormat), border);
-
-    _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y,
-                              width, height, border);
-}
-
-void
 radeonCopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
                         GLint xoffset, GLint yoffset,
                         GLint x, GLint y,
index 9ba98e3..4303093 100644 (file)
@@ -648,18 +648,12 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form
        struct radeon_renderbuffer *rb;
        radeon_texture_image *rImage;
        radeonContextPtr radeon;
-       r100ContextPtr rmesa;
        struct radeon_framebuffer *rfb;
        radeonTexObjPtr t;
        uint32_t pitch_val;
-       uint32_t internalFormat, format;
        gl_format texFormat;
 
-       format = GL_UNSIGNED_BYTE;
-       internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? GL_RGB : GL_RGBA);
-
        radeon = pDRICtx->driverPrivate;
-       rmesa = pDRICtx->driverPrivate;
 
        rfb = dPriv->driverPrivate;
         texUnit = _mesa_get_current_tex_unit(radeon->glCtx);
@@ -1018,7 +1012,7 @@ static GLboolean radeon_validate_texgen( struct gl_context *ctx, GLuint unit )
 static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int unit)
 {
    const struct gl_texture_image *firstImage;
-   GLint log2Width, log2Height, log2Depth, texelBytes;
+   GLint log2Width, log2Height, texelBytes;
 
    if ( t->bo ) {
        return GL_TRUE;
@@ -1033,7 +1027,6 @@ static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int
 
    log2Width  = firstImage->WidthLog2;
    log2Height = firstImage->HeightLog2;
-   log2Depth  = firstImage->DepthLog2;
    texelBytes = _mesa_get_format_bytes(firstImage->TexFormat);
 
    if (!t->image_override) {
index 538a07f..6fc06d9 100644 (file)
@@ -126,11 +126,6 @@ void radeonGetCompressedTexImage(struct gl_context *ctx, GLenum target, GLint le
                                 struct gl_texture_object *texObj,
                                 struct gl_texture_image *texImage);
 
-void radeonCopyTexImage2D(struct gl_context *ctx, GLenum target, GLint level,
-                       GLenum internalFormat,
-                       GLint x, GLint y, GLsizei width, GLsizei height,
-                       GLint border);
-
 void radeonCopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
                        GLint xoffset, GLint yoffset,
                        GLint x, GLint y,
index 48657b4..1f5fc33 100644 (file)
@@ -1097,12 +1097,16 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
             parselist++;
             break;
          case GLX_FBCONFIG_ID:
+         case GLX_VISUAL_ID:
             if (!fbConfig)
                return NULL;
             parselist++;
             desiredVisualID = *parselist++;
             break;
          case GLX_X_RENDERABLE:
+         case GLX_MAX_PBUFFER_WIDTH:
+         case GLX_MAX_PBUFFER_HEIGHT:
+         case GLX_MAX_PBUFFER_PIXELS:
             if (!fbConfig)
                return NULL;
             parselist += 2;
index 26d7819..b83369d 100644 (file)
@@ -269,6 +269,71 @@ _mesa_IsProgramARB(GLuint id)
       return GL_FALSE;
 }
 
+static GLboolean
+get_local_param_pointer(struct gl_context *ctx, const char *func,
+                       GLenum target, GLuint index, GLfloat **param)
+{
+   struct gl_program *prog;
+   GLuint maxParams;
+
+   if (target == GL_VERTEX_PROGRAM_ARB
+       && ctx->Extensions.ARB_vertex_program) {
+      prog = &(ctx->VertexProgram.Current->Base);
+      maxParams = ctx->Const.VertexProgram.MaxLocalParams;
+   }
+   else if (target == GL_FRAGMENT_PROGRAM_ARB
+            && ctx->Extensions.ARB_fragment_program) {
+      prog = &(ctx->FragmentProgram.Current->Base);
+      maxParams = ctx->Const.FragmentProgram.MaxLocalParams;
+   }
+   else if (target == GL_FRAGMENT_PROGRAM_NV
+            && ctx->Extensions.NV_fragment_program) {
+      prog = &(ctx->FragmentProgram.Current->Base);
+      maxParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+   }
+   else {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "%s(target)", func);
+      return GL_FALSE;
+   }
+
+   if (index >= maxParams) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
+      return GL_FALSE;
+   }
+
+   *param = prog->LocalParams[index];
+   return GL_TRUE;
+}
+
+
+static GLboolean
+get_env_param_pointer(struct gl_context *ctx, const char *func,
+                     GLenum target, GLuint index, GLfloat **param)
+{
+   if (target == GL_FRAGMENT_PROGRAM_ARB
+       && ctx->Extensions.ARB_fragment_program) {
+      if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
+         return GL_FALSE;
+      }
+      *param = ctx->FragmentProgram.Parameters[index];
+      return GL_TRUE;
+   }
+   else if (target == GL_VERTEX_PROGRAM_ARB &&
+           (ctx->Extensions.ARB_vertex_program ||
+            ctx->Extensions.NV_vertex_program)) {
+      if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
+         return GL_FALSE;
+      }
+      *param = ctx->VertexProgram.Parameters[index];
+      return GL_TRUE;
+   } else {
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);
+      return GL_FALSE;
+   }
+}
 
 void GLAPIENTRY
 _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
@@ -383,30 +448,16 @@ void GLAPIENTRY
 _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
                                GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 {
+   GLfloat *param;
+
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
-   if (target == GL_FRAGMENT_PROGRAM_ARB
-       && ctx->Extensions.ARB_fragment_program) {
-      if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
-         return;
-      }
-      ASSIGN_4V(ctx->FragmentProgram.Parameters[index], x, y, z, w);
-   }
-   else if (target == GL_VERTEX_PROGRAM_ARB /* == GL_VERTEX_PROGRAM_NV */
-       && (ctx->Extensions.ARB_vertex_program || ctx->Extensions.NV_vertex_program)) {
-      if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
-         return;
-      }
-      ASSIGN_4V(ctx->VertexProgram.Parameters[index], x, y, z, w);
-   }
-   else {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter(target)");
-      return;
+   if (get_env_param_pointer(ctx, "glProgramEnvParameter",
+                            target, index, &param)) {
+      ASSIGN_4V(param, x, y, z, w);
    }
 }
 
@@ -422,32 +473,16 @@ void GLAPIENTRY
 _mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
                                 const GLfloat *params)
 {
+   GLfloat *param;
+
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
-   if (target == GL_FRAGMENT_PROGRAM_ARB
-       && ctx->Extensions.ARB_fragment_program) {
-      if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)");
-         return;
-      }
-      memcpy(ctx->FragmentProgram.Parameters[index], params,
-             4 * sizeof(GLfloat));
-   }
-   else if (target == GL_VERTEX_PROGRAM_ARB /* == GL_VERTEX_PROGRAM_NV */
-       && (ctx->Extensions.ARB_vertex_program || ctx->Extensions.NV_vertex_program)) {
-      if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)");
-         return;
-      }
-      memcpy(ctx->VertexProgram.Parameters[index], params,
-             4 * sizeof(GLfloat));
-   }
-   else {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter4fv(target)");
-      return;
+   if (get_env_param_pointer(ctx, "glProgramEnvParameter4fv",
+                             target, index, &param)) {
+      memcpy(param, params, 4 * sizeof(GLfloat));
    }
 }
 
@@ -496,14 +531,11 @@ _mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index,
                                   GLdouble *params)
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLfloat fparams[4];
+   GLfloat *fparam;
 
-   _mesa_GetProgramEnvParameterfvARB(target, index, fparams);
-   if (ctx->ErrorValue == GL_NO_ERROR) {
-      params[0] = fparams[0];
-      params[1] = fparams[1];
-      params[2] = fparams[2];
-      params[3] = fparams[3];
+   if (get_env_param_pointer(ctx, "glGetProgramEnvParameterdv",
+                            target, index, &fparam)) {
+      COPY_4V(params, fparam);
    }
 }
 
@@ -512,29 +544,15 @@ void GLAPIENTRY
 _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index, 
                                   GLfloat *params)
 {
+   GLfloat *param;
+
    GET_CURRENT_CONTEXT(ctx);
 
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (target == GL_FRAGMENT_PROGRAM_ARB
-       && ctx->Extensions.ARB_fragment_program) {
-      if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
-         return;
-      }
-      COPY_4V(params, ctx->FragmentProgram.Parameters[index]);
-   }
-   else if (target == GL_VERTEX_PROGRAM_ARB
-       && ctx->Extensions.ARB_vertex_program) {
-      if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
-         return;
-      }
-      COPY_4V(params, ctx->VertexProgram.Parameters[index]);
-   }
-   else {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramEnvParameter(target)");
-      return;
+   if (get_env_param_pointer(ctx, "glGetProgramEnvParameterfv",
+                             target, index, &param)) {
+      COPY_4V(params, param);
    }
 }
 
@@ -547,39 +565,16 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
                                  GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_program *prog;
+   GLfloat *param;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
 
-   if ((target == GL_FRAGMENT_PROGRAM_NV
-        && ctx->Extensions.NV_fragment_program) ||
-       (target == GL_FRAGMENT_PROGRAM_ARB
-        && ctx->Extensions.ARB_fragment_program)) {
-      if (index >= ctx->Const.FragmentProgram.MaxLocalParams) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
-         return;
-      }
-      prog = &(ctx->FragmentProgram.Current->Base);
-   }
-   else if (target == GL_VERTEX_PROGRAM_ARB
-            && ctx->Extensions.ARB_vertex_program) {
-      if (index >= ctx->Const.VertexProgram.MaxLocalParams) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
-         return;
-      }
-      prog = &(ctx->VertexProgram.Current->Base);
+   if (get_local_param_pointer(ctx, "glProgramLocalParameterARB",
+                              target, index, &param)) {
+      ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
+      ASSIGN_4V(param, x, y, z, w);
    }
-   else {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB");
-      return;
-   }
-
-   ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
-   prog->LocalParams[index][0] = x;
-   prog->LocalParams[index][1] = y;
-   prog->LocalParams[index][2] = z;
-   prog->LocalParams[index][3] = w;
 }
 
 
@@ -667,41 +662,14 @@ void GLAPIENTRY
 _mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index,
                                     GLfloat *params)
 {
-   const struct gl_program *prog;
-   GLuint maxParams;
+   GLfloat *param;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (target == GL_VERTEX_PROGRAM_ARB
-       && ctx->Extensions.ARB_vertex_program) {
-      prog = &(ctx->VertexProgram.Current->Base);
-      maxParams = ctx->Const.VertexProgram.MaxLocalParams;
-   }
-   else if (target == GL_FRAGMENT_PROGRAM_ARB
-            && ctx->Extensions.ARB_fragment_program) {
-      prog = &(ctx->FragmentProgram.Current->Base);
-      maxParams = ctx->Const.FragmentProgram.MaxLocalParams;
-   }
-   else if (target == GL_FRAGMENT_PROGRAM_NV
-            && ctx->Extensions.NV_fragment_program) {
-      prog = &(ctx->FragmentProgram.Current->Base);
-      maxParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
-   }
-   else {
-      _mesa_error(ctx, GL_INVALID_ENUM,
-                  "glGetProgramLocalParameterARB(target)");
-      return;
-   }
-
-   if (index >= maxParams) {
-      _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glGetProgramLocalParameterARB(index)");
-      return;
+   if (get_local_param_pointer(ctx, "glProgramLocalParameters4fvEXT",
+                               target, index, &param)) {
+      COPY_4V(params, param);
    }
-
-   ASSERT(prog);
-   ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
-   COPY_4V(params, prog->LocalParams[index]);
 }
 
 
@@ -712,12 +680,13 @@ void GLAPIENTRY
 _mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index,
                                     GLdouble *params)
 {
+   GLfloat *param;
    GET_CURRENT_CONTEXT(ctx);
-   GLfloat floatParams[4];
-   ASSIGN_4V(floatParams, 0.0F, 0.0F, 0.0F, 0.0F);
-   _mesa_GetProgramLocalParameterfvARB(target, index, floatParams);
-   if (ctx->ErrorValue == GL_NO_ERROR) {
-      COPY_4V(params, floatParams);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (get_local_param_pointer(ctx, "glProgramLocalParameters4fvEXT",
+                               target, index, &param)) {
+      COPY_4V(params, param);
    }
 }
 
index 3e28d34..c52358e 100644 (file)
@@ -241,15 +241,14 @@ _mesa_delete_buffer_object(struct gl_context *ctx,
 
 /**
  * Set ptr to bufObj w/ reference counting.
+ * This is normally only called from the _mesa_reference_buffer_object() macro
+ * when there's a real pointer change.
  */
 void
-_mesa_reference_buffer_object(struct gl_context *ctx,
-                              struct gl_buffer_object **ptr,
-                              struct gl_buffer_object *bufObj)
+_mesa_reference_buffer_object_(struct gl_context *ctx,
+                               struct gl_buffer_object **ptr,
+                               struct gl_buffer_object *bufObj)
 {
-   if (*ptr == bufObj)
-      return;
-
    if (*ptr) {
       /* Unreference the old buffer */
       GLboolean deleteFlag = GL_FALSE;
index 91fa073..f82e414 100644 (file)
@@ -75,9 +75,19 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
                                GLuint name, GLenum target );
 
 extern void
+_mesa_reference_buffer_object_(struct gl_context *ctx,
+                               struct gl_buffer_object **ptr,
+                               struct gl_buffer_object *bufObj);
+
+static INLINE void
 _mesa_reference_buffer_object(struct gl_context *ctx,
                               struct gl_buffer_object **ptr,
-                              struct gl_buffer_object *bufObj);
+                              struct gl_buffer_object *bufObj)
+{
+   if (*ptr != bufObj)
+      _mesa_reference_buffer_object_(ctx, ptr, bufObj);
+}
+
 
 extern void
 _mesa_init_buffer_object_functions(struct dd_function_table *driver);
index 63f53e2..a75c9c2 100644 (file)
@@ -462,6 +462,27 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
 
 
 /**
+ * Update the current drawbuffer's _ColorDrawBufferIndex[] list, etc.
+ * from the context's Color.DrawBuffer[] state.
+ * Use when changing contexts.
+ */
+void
+_mesa_update_draw_buffers(struct gl_context *ctx)
+{
+   GLenum buffers[MAX_DRAW_BUFFERS];
+   GLuint i;
+
+   /* should be a window system FBO */
+   assert(ctx->DrawBuffer->Name == 0);
+
+   for (i = 0; i < ctx->Const.MaxDrawBuffers; i++)
+      buffers[i] = ctx->Color.DrawBuffer[i];
+
+   _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL);
+}
+
+
+/**
  * Like \sa _mesa_drawbuffers(), this is a helper function for setting
  * GL_READ_BUFFER state in the context and current FBO.
  * \param ctx  the rendering context
index 1404112..8083bc3 100644 (file)
@@ -50,6 +50,10 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
 extern void
 _mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex);
 
+extern void
+_mesa_update_draw_buffers(struct gl_context *ctx);
+
+
 extern void GLAPIENTRY
 _mesa_ReadBuffer( GLenum mode );
 
index 743841b..d736fdf 100644 (file)
@@ -139,26 +139,28 @@ extern "C" {
 /**
  * Function inlining
  */
-#if defined(__GNUC__)
-#  define INLINE __inline__
-#elif defined(__MSC__)
-#  define INLINE __inline
-#elif defined(_MSC_VER)
-#  define INLINE __inline
-#elif defined(__ICL)
-#  define INLINE __inline
-#elif defined(__INTEL_COMPILER)
-#  define INLINE inline
-#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
-#  define INLINE __inline
-#elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
-#  define INLINE inline
-#  define __inline inline
-#  define __inline__ inline
-#elif (__STDC_VERSION__ >= 199901L) /* C99 */
-#  define INLINE inline
-#else
-#  define INLINE
+#ifndef INLINE
+#  if defined(__GNUC__)
+#    define INLINE __inline__
+#  elif defined(__MSC__)
+#    define INLINE __inline
+#  elif defined(_MSC_VER)
+#    define INLINE __inline
+#  elif defined(__ICL)
+#    define INLINE __inline
+#  elif defined(__INTEL_COMPILER)
+#    define INLINE inline
+#  elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
+#    define INLINE __inline
+#  elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
+#    define INLINE inline
+#    define __inline inline
+#    define __inline__ inline
+#  elif (__STDC_VERSION__ >= 199901L) /* C99 */
+#    define INLINE inline
+#  else
+#    define INLINE
+#  endif
 #endif
 
 
index ea13bdd..b83a5d6 100644 (file)
@@ -1430,7 +1430,8 @@ _mesa_make_current( struct gl_context *newCtx,
    }
 
    if (curCtx && 
-      (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && /* make sure this context is valid for flushing */
+      (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
+       /* make sure this context is valid for flushing */
       curCtx != newCtx)
       _mesa_flush(curCtx);
 
@@ -1445,8 +1446,6 @@ _mesa_make_current( struct gl_context *newCtx,
       _glapi_set_dispatch(newCtx->CurrentDispatch);
 
       if (drawBuffer && readBuffer) {
-        /* TODO: check if newCtx and buffer's visual match??? */
-
          ASSERT(drawBuffer->Name == 0);
          ASSERT(readBuffer->Name == 0);
          _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer);
@@ -1457,23 +1456,12 @@ _mesa_make_current( struct gl_context *newCtx,
           * or not bound to a user-created FBO.
           */
          if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
-            /* KW: merge conflict here, revisit. 
-             */
-            /* fix up the fb fields - these will end up wrong otherwise
-             * if the DRIdrawable changes, and everything relies on them.
-             * This is a bit messy (same as needed in _mesa_BindFramebufferEXT)
-             */
-            unsigned int i;
-            GLenum buffers[MAX_DRAW_BUFFERS];
-
             _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
-
-            for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) {
-               buffers[i] = newCtx->Color.DrawBuffer[i];
-            }
-
-            _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers,
-                              buffers, NULL);
+            /* Update the FBO's list of drawbuffers/renderbuffers.
+             * For winsys FBOs this comes from the GL state (which may have
+             * changed since the last time this FBO was bound).
+             */
+            _mesa_update_draw_buffers(newCtx);
          }
          if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
             _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
index 9fe6d52..e0c5844 100644 (file)
@@ -189,31 +189,22 @@ struct dd_function_table {
    /*@{*/
 
    /**
-    * Choose texture format.
-    * 
-    * This is called by the \c _mesa_store_tex[sub]image[123]d() fallback
-    * functions.  The driver should examine \p internalFormat and return a
-    * gl_format value.
+    * Choose actual hardware texture format given the user-provided source
+    * image format and type and the desired internal format.  In some
+    * cases, srcFormat and srcType can be GL_NONE.
+    * Called by glTexImage(), etc.
     */
    GLuint (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat,
                                      GLenum srcFormat, GLenum srcType );
 
    /**
-    * Called by glTexImage1D().
-    * 
-    * \param target user specified.
-    * \param format user specified.
-    * \param type user specified.
-    * \param pixels user specified.
-    * \param packing indicates the image packing of pixels.
+    * Called by glTexImage1D().  Simply copy the source texture data into the
+    * destination texture memory.  The gl_texture_image fields, etc. will be
+    * fully initialized.
+    * The parameters are the same as glTexImage1D(), plus:
+    * \param packing describes how to unpack the source data.
     * \param texObj is the target texture object.
-    * \param texImage is the target texture image.  It will have the texture \p
-    * width, \p height, \p depth, \p border and \p internalFormat information.
-    * 
-    * \p retainInternalCopy is returned by this function and indicates whether
-    * core Mesa should keep an internal copy of the texture image.
-    *
-    * Drivers should call a fallback routine from texstore.c if needed.
+    * \param texImage is the target texture image.
     */
    void (*TexImage1D)( struct gl_context *ctx, GLenum target, GLint level,
                        GLint internalFormat,
@@ -250,25 +241,9 @@ struct dd_function_table {
                        struct gl_texture_image *texImage );
 
    /**
-    * Called by glTexSubImage1D().
-    *
-    * \param target user specified.
-    * \param level user specified.
-    * \param xoffset user specified.
-    * \param yoffset user specified.
-    * \param zoffset user specified.
-    * \param width user specified.
-    * \param height user specified.
-    * \param depth user specified.
-    * \param format user specified.
-    * \param type user specified.
-    * \param pixels user specified.
-    * \param packing indicates the image packing of pixels.
-    * \param texObj is the target texture object.
-    * \param texImage is the target texture image.  It will have the texture \p
-    * width, \p height, \p border and \p internalFormat information.
-    *
-    * The driver should use a fallback routine from texstore.c if needed.
+    * Called by glTexSubImage1D().  Replace a subset of the target texture
+    * with new texel data.
+    * \sa dd_function_table::TexImage1D.
     */
    void (*TexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level,
                           GLint xoffset, GLsizei width,
@@ -315,24 +290,6 @@ struct dd_function_table {
                         struct gl_texture_image *texImage );
 
    /**
-    * Called by glCopyTexImage1D().
-    * 
-    * Drivers should use a fallback routine from texstore.c if needed.
-    */
-   void (*CopyTexImage1D)( struct gl_context *ctx, GLenum target, GLint level,
-                           GLenum internalFormat, GLint x, GLint y,
-                           GLsizei width, GLint border );
-
-   /**
-    * Called by glCopyTexImage2D().
-    * 
-    * Drivers should use a fallback routine from texstore.c if needed.
-    */
-   void (*CopyTexImage2D)( struct gl_context *ctx, GLenum target, GLint level,
-                           GLenum internalFormat, GLint x, GLint y,
-                           GLsizei width, GLsizei height, GLint border );
-
-   /**
     * Called by glCopyTexSubImage1D().
     * 
     * Drivers should use a fallback routine from texstore.c if needed.
index ab62c97..40d6c96 100644 (file)
@@ -63,7 +63,8 @@ static void
 delete_wrapper(struct gl_renderbuffer *rb)
 {
    ASSERT(rb->Format == MESA_FORMAT_S8 ||
-          rb->Format == MESA_FORMAT_X8_Z24);
+          rb->Format == MESA_FORMAT_X8_Z24 ||
+          rb->Format == MESA_FORMAT_Z32_FLOAT);
    _mesa_reference_renderbuffer(&rb->Wrapped, NULL);
    free(rb);
 }
@@ -393,6 +394,217 @@ _mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
 }
 
 
+static void
+get_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+             GLint x, GLint y, void *values)
+{
+   struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+   GLfloat temp[MAX_WIDTH*2];
+   GLfloat *dst = (GLfloat *) values;
+   const GLfloat *src = (const GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+   GLuint i;
+   ASSERT(z32frb->DataType == GL_FLOAT);
+   ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   if (!src) {
+      dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+      src = temp;
+   }
+   for (i = 0; i < count; i++) {
+      dst[i] = src[i*2];
+   }
+}
+
+static void
+get_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+                const GLint x[], const GLint y[], void *values)
+{
+   struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+   GLfloat temp[MAX_WIDTH*2];
+   GLfloat *dst = (GLfloat *) values;
+   GLuint i;
+   ASSERT(z32frb->DataType == GL_FLOAT);
+   ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   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*2];
+   }
+}
+
+static void
+put_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+             GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+   struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+   const GLfloat *src = (const GLfloat *) values;
+   GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+   ASSERT(z32frb->DataType == GL_FLOAT);
+   ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   if (dst) {
+      /* direct access */
+      GLuint i;
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            dst[i*2] = src[i];
+         }
+      }
+   }
+   else {
+      /* get, modify, put */
+      GLfloat temp[MAX_WIDTH*2];
+      GLuint i;
+      dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            temp[i*2] = src[i];
+         }
+      }
+      dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
+   }
+}
+
+static void
+put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+                  GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+   struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+   GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+   ASSERT(z32frb->DataType == GL_FLOAT);
+   ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   if (dst) {
+      /* direct access */
+      GLuint i;
+      const GLfloat val = *(GLfloat*)value;
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            dst[i*2] = val;
+         }
+      }
+   }
+   else {
+      /* get, modify, put */
+      GLfloat temp[MAX_WIDTH*2];
+      GLuint i;
+      const GLfloat val = *(GLfloat *)value;
+      dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            temp[i*2] = val;
+         }
+      }
+      dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
+   }
+}
+
+static void
+put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+                const GLint x[], const GLint y[],
+                const void *values, const GLubyte *mask)
+{
+   struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+   const GLfloat *src = (const GLfloat *) values;
+   ASSERT(z32frb->DataType == GL_FLOAT);
+   ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
+      /* direct access */
+      GLuint i;
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+            *dst = src[i];
+         }
+      }
+   }
+   else {
+      /* get, modify, put */
+      GLfloat temp[MAX_WIDTH*2];
+      GLuint i;
+      dsrb->GetValues(ctx, dsrb, count, x, y, temp);
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            temp[i*2] = src[i];
+         }
+      }
+      dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
+   }
+}
+
+static void
+put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb,
+                     GLuint count, const GLint x[], const GLint y[],
+                     const void *value, const GLubyte *mask)
+{
+   struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+   GLfloat temp[MAX_WIDTH*2];
+   GLuint i;
+   const GLfloat val = *(GLfloat *)value;
+   ASSERT(z32frb->DataType == GL_FLOAT);
+   ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+   ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   /* get, modify, put */
+   dsrb->GetValues(ctx, dsrb, count, x, y, temp);
+   for (i = 0; i < count; i++) {
+      if (!mask || mask[i]) {
+         temp[i*2] = val;
+      }
+   }
+   dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
+}
+
+
+/**
+ * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like
+ * a depth renderbuffer.
+ * \return new depth renderbuffer
+ */
+struct gl_renderbuffer *
+_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
+                                    struct gl_renderbuffer *dsrb)
+{
+   struct gl_renderbuffer *z32frb;
+
+   ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+
+   z32frb = ctx->Driver.NewRenderbuffer(ctx, 0);
+   if (!z32frb)
+      return NULL;
+
+   /* NOTE: need to do manual refcounting here */
+   z32frb->Wrapped = dsrb;
+   dsrb->RefCount++;
+
+   z32frb->Name = dsrb->Name;
+   z32frb->RefCount = 0;
+   z32frb->Width = dsrb->Width;
+   z32frb->Height = dsrb->Height;
+   z32frb->RowStride = dsrb->RowStride;
+   z32frb->InternalFormat = GL_DEPTH_COMPONENT32F;
+   z32frb->Format = MESA_FORMAT_Z32_FLOAT;
+   z32frb->_BaseFormat = GL_DEPTH_COMPONENT;
+   z32frb->DataType = GL_FLOAT;
+   z32frb->Data = NULL;
+   z32frb->Delete = delete_wrapper;
+   z32frb->AllocStorage = alloc_wrapper_storage;
+   z32frb->GetPointer = nop_get_pointer;
+   z32frb->GetRow = get_row_z32f;
+   z32frb->GetValues = get_values_z32f;
+   z32frb->PutRow = put_row_z32f;
+   z32frb->PutRowRGB = NULL;
+   z32frb->PutMonoRow = put_mono_row_z32f;
+   z32frb->PutValues = put_values_z32f;
+   z32frb->PutMonoValues = put_mono_values_z32f;
+
+   return z32frb;
+}
+
+
 /*======================================================================
  * Stencil wrapper around depth/stencil renderbuffer
  */
@@ -402,16 +614,22 @@ get_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
            GLint x, GLint y, void *values)
 {
    struct gl_renderbuffer *dsrb = s8rb->Wrapped;
-   GLuint temp[MAX_WIDTH], i;
+   GLuint temp[MAX_WIDTH*2], i;
    GLubyte *dst = (GLubyte *) values;
    const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
    ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+          dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
    if (!src) {
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
       src = temp;
    }
-   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+   if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+      for (i = 0; i < count; i++) {
+         dst[i] = src[i*2+1] & 0xff;
+      }
+   }
+   else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
       for (i = 0; i < count; i++) {
          dst[i] = src[i] & 0xff;
       }
@@ -429,14 +647,20 @@ get_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count
               const GLint x[], const GLint y[], void *values)
 {
    struct gl_renderbuffer *dsrb = s8rb->Wrapped;
-   GLuint temp[MAX_WIDTH], i;
+   GLuint temp[MAX_WIDTH*2], i;
    GLubyte *dst = (GLubyte *) values;
    ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+          dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
    ASSERT(count <= MAX_WIDTH);
    /* don't bother trying direct access */
    dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+   if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+      for (i = 0; i < count; i++) {
+         dst[i] = temp[i*2+1] & 0xff;
+      }
+   }
+   else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
       for (i = 0; i < count; i++) {
          dst[i] = temp[i] & 0xff;
       }
@@ -457,11 +681,19 @@ put_row_s8(struct gl_context *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->DataType == GL_UNSIGNED_INT_24_8_EXT);
+   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+          dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
    if (dst) {
       /* direct access */
       GLuint i;
-      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i*2+1] = src[i];
+            }
+         }
+      }
+      else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
          for (i = 0; i < count; i++) {
             if (!mask || mask[i]) {
                dst[i] = (dst[i] & 0xffffff00) | src[i];
@@ -479,9 +711,16 @@ put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
    }
    else {
       /* get, modify, put */
-      GLuint temp[MAX_WIDTH], i;
+      GLuint temp[MAX_WIDTH*2], i;
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
-      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i*2+1] = src[i];
+            }
+         }
+      }
+      else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
          for (i = 0; i < count; i++) {
             if (!mask || mask[i]) {
                temp[i] = (temp[i] & 0xffffff00) | src[i];
@@ -508,11 +747,19 @@ put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint cou
    const GLubyte val = *((GLubyte *) value);
    GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
    ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
-   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+          dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
    if (dst) {
       /* direct access */
       GLuint i;
-      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               dst[i*2+1] = val;
+            }
+         }
+      }
+      else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
          for (i = 0; i < count; i++) {
             if (!mask || mask[i]) {
                dst[i] = (dst[i] & 0xffffff00) | val;
@@ -530,9 +777,16 @@ put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint cou
    }
    else {
       /* get, modify, put */
-      GLuint temp[MAX_WIDTH], i;
+      GLuint temp[MAX_WIDTH*2], i;
       dsrb->GetRow(ctx, dsrb, count, x, y, temp);
-      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i*2+1] = val;
+            }
+         }
+      }
+      else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
          for (i = 0; i < count; i++) {
             if (!mask || mask[i]) {
                temp[i] = (temp[i] & 0xffffff00) | val;
@@ -559,11 +813,20 @@ put_values_s8(struct gl_context *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->DataType == GL_UNSIGNED_INT_24_8_EXT);
+   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+          dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
    if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
       /* direct access */
       GLuint i;
-      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+               dst[1] = src[i];
+            }
+         }
+      }
+      else 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]);
@@ -583,9 +846,16 @@ put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count
    }
    else {
       /* get, modify, put */
-      GLuint temp[MAX_WIDTH], i;
+      GLuint temp[MAX_WIDTH*2], i;
       dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-      if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+      if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+         for (i = 0; i < count; i++) {
+            if (!mask || mask[i]) {
+               temp[i*2+1] = src[i];
+            }
+         }
+      }
+      else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
          for (i = 0; i < count; i++) {
             if (!mask || mask[i]) {
                temp[i] = (temp[i] & 0xffffff00) | src[i];
@@ -610,11 +880,18 @@ put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint
                    const void *value, const GLubyte *mask)
 {
    struct gl_renderbuffer *dsrb = s8rb->Wrapped;
-   GLuint temp[MAX_WIDTH], i;
+   GLuint temp[MAX_WIDTH*2], i;
    const GLubyte val = *((GLubyte *) value);
    /* get, modify, put */
    dsrb->GetValues(ctx, dsrb, count, x, y, temp);
-   if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+   if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+      for (i = 0; i < count; i++) {
+         if (!mask || mask[i]) {
+            temp[i*2+1] = val;
+         }
+      }
+   }
+   else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
       for (i = 0; i < count; i++) {
          if (!mask || mask[i]) {
             temp[i] = (temp[i] & 0xffffff00) | val;
@@ -644,8 +921,10 @@ _mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer
    struct gl_renderbuffer *s8rb;
 
    ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
-          dsrb->Format == MESA_FORMAT_S8_Z24);
-   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+          dsrb->Format == MESA_FORMAT_S8_Z24 ||
+          dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+   ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+          dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
    s8rb = ctx->Driver.NewRenderbuffer(ctx, 0);
    if (!s8rb)
index ef63c5d..b47a2e4 100644 (file)
@@ -34,6 +34,11 @@ _mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
 
 
 extern struct gl_renderbuffer *
+_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
+                                    struct gl_renderbuffer *dsrb);
+
+
+extern struct gl_renderbuffer *
 _mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx,
                                   struct gl_renderbuffer *dsrb);
 
index 958f5a6..f928239 100644 (file)
@@ -7542,32 +7542,32 @@ execute_list(struct gl_context *ctx, GLuint list)
             break;
          case OPCODE_CLEAR_BUFFER_IV:
             {
-               GLint value[4];
+               /*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));*/
+               CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/
             }
             break;
          case OPCODE_CLEAR_BUFFER_UIV:
             {
-               GLuint value[4];
+               /*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));*/
+               CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/
             }
             break;
          case OPCODE_CLEAR_BUFFER_FV:
             {
-               GLfloat value[4];
+               /*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));*/
+               CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));*/
             }
             break;
          case OPCODE_CLEAR_BUFFER_FI:
index aac8b9c..3ba4df6 100644 (file)
@@ -5,7 +5,6 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  7.0.3
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
@@ -560,7 +559,6 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          ctx->Polygon.OffsetLine = state;
          break;
       case GL_POLYGON_OFFSET_FILL:
-         /*case GL_POLYGON_OFFSET_EXT:*/
          if (ctx->Polygon.OffsetFill == state)
             return;
          FLUSH_VERTICES(ctx, _NEW_POLYGON);
@@ -643,9 +641,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          break;
 #endif
 
-      /*
-       * CLIENT STATE!!!
-       */
+      /* client-side state */
       case GL_VERTEX_ARRAY:
       case GL_NORMAL_ARRAY:
       case GL_COLOR_ARRAY:
@@ -1174,7 +1170,6 @@ _mesa_IsEnabled( GLenum cap )
       case GL_POLYGON_OFFSET_LINE:
         return ctx->Polygon.OffsetLine;
       case GL_POLYGON_OFFSET_FILL:
-      /*case GL_POLYGON_OFFSET_EXT:*/
         return ctx->Polygon.OffsetFill;
       case GL_RESCALE_NORMAL_EXT:
          return ctx->Transform.RescaleNormals;
@@ -1213,9 +1208,7 @@ _mesa_IsEnabled( GLenum cap )
          }
 #endif
 
-      /*
-       * CLIENT STATE!!!
-       */
+      /* client-side state */
       case GL_VERTEX_ARRAY:
          return (ctx->Array.ArrayObj->Vertex.Enabled != 0);
       case GL_NORMAL_ARRAY:
index 2230b26..82eb7fb 100644 (file)
@@ -78,9 +78,32 @@ static struct gl_renderbuffer DummyRenderbuffer;
 static struct gl_framebuffer IncompleteFramebuffer;
 
 
-#define IS_CUBE_FACE(TARGET) \
-   ((TARGET) >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && \
-    (TARGET) <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
+static INLINE GLboolean
+is_cube_face(GLenum target)
+{
+   return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
+           target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
+}
+
+
+/**
+ * Is the given FBO a user-created FBO?
+ */
+static INLINE GLboolean
+is_user_fbo(const struct gl_framebuffer *fb)
+{
+   return fb->Name != 0;
+}
+
+
+/**
+ * Is the given FBO a window system FBO (like an X window)?
+ */
+static INLINE GLboolean
+is_winsys_fbo(const struct gl_framebuffer *fb)
+{
+   return fb->Name == 0;
+}
 
 
 static void
@@ -196,7 +219,7 @@ _mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
 {
    GLuint i;
 
-   assert(fb->Name > 0);
+   assert(is_user_fbo(fb));
 
    switch (attachment) {
    case GL_COLOR_ATTACHMENT0_EXT:
@@ -244,7 +267,7 @@ static struct gl_renderbuffer_attachment *
 _mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
                          GLenum attachment)
 {
-   assert(fb->Name == 0);
+   assert(is_winsys_fbo(fb));
 
    switch (attachment) {
    case GL_FRONT_LEFT:
@@ -669,7 +692,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
    GLint i;
    GLuint j;
 
-   assert(fb->Name != 0);
+   assert(is_user_fbo(fb));
 
    numImages = 0;
    fb->Width = 0;
@@ -968,10 +991,11 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers)
                _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
             }
 
-            if (ctx->DrawBuffer->Name) {
+            if (is_user_fbo(ctx->DrawBuffer)) {
                detach_renderbuffer(ctx, ctx->DrawBuffer, rb);
             }
-            if (ctx->ReadBuffer->Name && ctx->ReadBuffer != ctx->DrawBuffer) {
+            if (is_user_fbo(ctx->ReadBuffer)
+                && ctx->ReadBuffer != ctx->DrawBuffer) {
                detach_renderbuffer(ctx, ctx->ReadBuffer, rb);
             }
 
@@ -1107,6 +1131,16 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
          return GL_DEPTH_STENCIL_EXT;
       else
          return 0;
+   case GL_DEPTH_COMPONENT32F:
+      if (ctx->Extensions.ARB_depth_buffer_float)
+         return GL_DEPTH_COMPONENT;
+      else
+         return 0;
+   case GL_DEPTH32F_STENCIL8:
+      if (ctx->Extensions.ARB_depth_buffer_float)
+         return GL_DEPTH_STENCIL;
+      else
+         return 0;
    case GL_RED:
    case GL_R8:
    case GL_R16:
@@ -1203,7 +1237,7 @@ invalidate_rb(GLuint key, void *data, void *userData)
    struct gl_renderbuffer *rb = (struct gl_renderbuffer *) userData;
 
    /* If this is a user-created FBO */
-   if (fb->Name) {
+   if (is_user_fbo(fb)) {
       GLuint i;
       for (i = 0; i < BUFFER_COUNT; i++) {
          struct gl_renderbuffer_attachment *att = fb->Attachment + i;
@@ -1532,7 +1566,7 @@ check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
    GLuint i;
    ASSERT(ctx->Driver.RenderTexture);
 
-   if (fb->Name == 0)
+   if (is_winsys_fbo(fb))
       return; /* can't render to texture with winsys framebuffers */
 
    for (i = 0; i < BUFFER_COUNT; i++) {
@@ -1552,7 +1586,7 @@ check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
 static void
 check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
 {
-   if (fb->Name == 0)
+   if (is_winsys_fbo(fb))
       return; /* can't render to texture with winsys framebuffers */
 
    if (ctx->Driver.FinishRenderTexture) {
@@ -1805,7 +1839,7 @@ _mesa_CheckFramebufferStatusEXT(GLenum target)
       return 0;
    }
 
-   if (buffer->Name == 0) {
+   if (is_winsys_fbo(buffer)) {
       /* The window system / default framebuffer is always complete */
       return GL_FRAMEBUFFER_COMPLETE_EXT;
    }
@@ -1843,7 +1877,7 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
    }
 
    /* check framebuffer binding */
-   if (fb->Name == 0) {
+   if (is_winsys_fbo(fb)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glFramebufferTexture%sEXT", caller);
       return;
@@ -1866,7 +1900,7 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
          }
          else {
             err = (texObj->Target == GL_TEXTURE_CUBE_MAP)
-                ? !IS_CUBE_FACE(textarget)
+                ? !is_cube_face(textarget)
                 : (texObj->Target != textarget);
          }
       }
@@ -1970,7 +2004,7 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
    if ((texture != 0) &&
        (textarget != GL_TEXTURE_2D) &&
        (textarget != GL_TEXTURE_RECTANGLE_ARB) &&
-       (!IS_CUBE_FACE(textarget))) {
+       (!is_cube_face(textarget))) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glFramebufferTexture2DEXT(textarget=0x%x)", textarget);
       return;
@@ -2034,7 +2068,7 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
       return;
    }
 
-   if (fb->Name == 0) {
+   if (is_winsys_fbo(fb)) {
       /* Can't attach new renderbuffers to a window system framebuffer */
       _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT");
       return;
@@ -2100,10 +2134,14 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
 {
    const struct gl_renderbuffer_attachment *att;
    struct gl_framebuffer *buffer;
+   GLenum err;
    GET_CURRENT_CONTEXT(ctx);
 
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
+   /* The error differs in GL andd GLES. */
+   err = ctx->API == API_OPENGL ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
+
    buffer = get_framebuffer_target(ctx, target);
    if (!buffer) {
       _mesa_error(ctx, GL_INVALID_ENUM,
@@ -2111,7 +2149,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
       return;
    }
 
-   if (buffer->Name == 0) {
+   if (is_winsys_fbo(buffer)) {
       /* the default / window-system FBO */
       att = _mesa_get_fb0_attachment(ctx, buffer, attachment);
    }
@@ -2143,7 +2181,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
 
    switch (pname) {
    case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
-      *params = buffer->Name == 0 ? GL_FRAMEBUFFER_DEFAULT : att->Type;
+      *params = is_winsys_fbo(buffer) ? GL_FRAMEBUFFER_DEFAULT : att->Type;
       return;
    case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
       if (att->Type == GL_RENDERBUFFER_EXT) {
@@ -2154,7 +2192,12 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
       }
       else {
          assert(att->Type == GL_NONE);
-         *params = 0;
+         if (ctx->API == API_OPENGL) {
+            *params = 0;
+         } else {
+            _mesa_error(ctx, GL_INVALID_ENUM,
+                        "glGetFramebufferAttachmentParameterivEXT(pname)");
+         }
       }
       return;
    case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT:
@@ -2162,7 +2205,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
         *params = att->TextureLevel;
       }
       else if (att->Type == GL_NONE) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
+         _mesa_error(ctx, err,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else {
@@ -2180,7 +2223,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
          }
       }
       else if (att->Type == GL_NONE) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
+         _mesa_error(ctx, err,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else {
@@ -2198,7 +2241,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
          }
       }
       else if (att->Type == GL_NONE) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
+         _mesa_error(ctx, err,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else {
@@ -2212,7 +2255,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else if (att->Type == GL_NONE) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
+         _mesa_error(ctx, err,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else {
@@ -2233,7 +2276,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
          return;
       }
       else if (att->Type == GL_NONE) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
+         _mesa_error(ctx, err,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else {
@@ -2242,6 +2285,15 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
             /* special cases */
             *params = GL_INDEX;
          }
+         else if (format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+            /* depends on the attachment parameter */
+            if (attachment == GL_STENCIL_ATTACHMENT) {
+               *params = GL_INDEX;
+            }
+            else {
+               *params = GL_FLOAT;
+            }
+         }
          else {
             *params = _mesa_get_format_datatype(format);
          }
@@ -2258,7 +2310,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else if (att->Type == GL_NONE) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
+         _mesa_error(ctx, err,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else if (att->Texture) {
@@ -2560,6 +2612,10 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
       }
    }
 
+   if (!mask) {
+      return;
+   }
+
    ASSERT(ctx->Driver.BlitFramebuffer);
    ctx->Driver.BlitFramebuffer(ctx,
                                srcX0, srcY0, srcX1, srcY1,
index fcb089f..597ec1e 100644 (file)
@@ -64,7 +64,7 @@ _mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
       _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" );
       return;
    }
-   if (!buffer) {
+   if (!buffer && size > 0) {
       _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" );
       ctx->Feedback.BufferSize = 0;
       return;
index 2ccbaf8..7cc1721 100644 (file)
@@ -330,8 +330,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
       /* _NEW_RENDERMODE */
       fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0);
    }
-   else if (!(vertexProgram || vertexShader) ||
-            !ctx->VertexProgram._Current) {
+   else if (!(vertexProgram || vertexShader)) {
       /* Fixed function vertex logic */
       /* _NEW_ARRAY */
       GLbitfield varying_inputs = ctx->varying_vp_inputs;
index e88ba43..f9298d2 100644 (file)
@@ -1091,6 +1091,25 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       0, 0, 0, 0, 0,
       1, 1, 4
    },
+   /* ARB_depth_buffer_float */
+   {
+      MESA_FORMAT_Z32_FLOAT,       /* Name */
+      "MESA_FORMAT_Z32_FLOAT",     /* StrName */
+      GL_DEPTH_COMPONENT,          /* BaseFormat */
+      GL_FLOAT,                    /* 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_Z32_FLOAT_X24S8, /* Name */
+      "MESA_FORMAT_Z32_FLOAT_X24S8", /* StrName */
+      GL_DEPTH_STENCIL,            /* BaseFormat */
+      GL_NONE /* XXX */,           /* DataType */
+      0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
+      0, 0, 0, 32, 8,              /* Lum/Int/Index/Depth/StencilBits */
+      1, 1, 8                      /* BlockWidth/Height,Bytes */
+   },
 };
 
 
@@ -1466,7 +1485,9 @@ _mesa_test_formats(void)
              info->DataType == GL_SIGNED_NORMALIZED ||
              info->DataType == GL_UNSIGNED_INT ||
              info->DataType == GL_INT ||
-             info->DataType == GL_FLOAT);
+             info->DataType == GL_FLOAT ||
+             /* Z32_FLOAT_X24S8 has DataType of GL_NONE */
+             info->DataType == GL_NONE);
 
       if (info->BaseFormat == GL_RGB) {
          assert(info->RedBits > 0);
@@ -1654,6 +1675,16 @@ _mesa_format_to_type_and_comps(gl_format format,
       *comps = 1;
       return;
 
+   case MESA_FORMAT_Z32_FLOAT:
+      *datatype = GL_FLOAT;
+      *comps = 1;
+      return;
+
+   case MESA_FORMAT_Z32_FLOAT_X24S8:
+      *datatype = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+      *comps = 1;
+      return;
+
    case MESA_FORMAT_DUDV8:
       *datatype = GL_BYTE;
       *comps = 2;
index 0640bbc..5b8c017 100644 (file)
@@ -209,6 +209,9 @@ typedef enum
    MESA_FORMAT_RGB9_E5_FLOAT,
    MESA_FORMAT_R11_G11_B10_FLOAT,
 
+   MESA_FORMAT_Z32_FLOAT,
+   MESA_FORMAT_Z32_FLOAT_X24S8,
+
    MESA_FORMAT_COUNT
 } gl_format;
 
index 66c9bd9..23fa1b2 100644 (file)
@@ -232,17 +232,13 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb)
 
 /**
  * Set *ptr to point to fb, with refcounting and locking.
+ * This is normally only called from the _mesa_reference_framebuffer() macro
+ * when there's a real pointer change.
  */
 void
-_mesa_reference_framebuffer(struct gl_framebuffer **ptr,
-                            struct gl_framebuffer *fb)
+_mesa_reference_framebuffer_(struct gl_framebuffer **ptr,
+                             struct gl_framebuffer *fb)
 {
-   assert(ptr);
-   if (*ptr == fb) {
-      /* no change */
-      return;
-   }
-
    if (*ptr) {
       /* unreference old renderbuffer */
       GLboolean deleteFlag = GL_FALSE;
@@ -552,6 +548,7 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
             fb->Visual.rgbBits = fb->Visual.redBits
                + fb->Visual.greenBits + fb->Visual.blueBits;
             fb->Visual.samples = rb->NumSamples;
+            fb->Visual.sampleBuffers = rb->NumSamples > 0 ? 1 : 0;
             if (_mesa_get_format_color_encoding(fmt) == GL_SRGB)
                 fb->Visual.sRGBCapable = ctx->Const.sRGBCapable;
             break;
@@ -631,8 +628,14 @@ _mesa_update_depth_buffer(struct gl_context *ctx,
           || fb->_DepthBuffer->Wrapped != depthRb
           || _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);
+         struct gl_renderbuffer *wrapper;
+
+         if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+            wrapper = _mesa_new_z32f_renderbuffer_wrapper(ctx, depthRb);
+         }
+         else {
+            wrapper = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
+         }
          _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper);
          ASSERT(fb->_DepthBuffer->Wrapped == depthRb);
       }
index c3bd638..b2b29a7 100644 (file)
@@ -51,8 +51,16 @@ extern void
 _mesa_free_framebuffer_data(struct gl_framebuffer *buffer);
 
 extern void
+_mesa_reference_framebuffer_(struct gl_framebuffer **ptr,
+                             struct gl_framebuffer *fb);
+
+static INLINE void
 _mesa_reference_framebuffer(struct gl_framebuffer **ptr,
-                            struct gl_framebuffer *fb);
+                            struct gl_framebuffer *fb)
+{
+   if (*ptr != fb)
+      _mesa_reference_framebuffer_(ptr, fb);
+}
 
 extern void
 _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
index 0492e15..d32c68a 100644 (file)
@@ -1569,11 +1569,11 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
       break;
 
    case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
-      v->value_int = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE);
+      v->value_int = _mesa_get_compressed_formats(ctx, NULL);
       break;
    case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
       v->value_int_n.n = 
-        _mesa_get_compressed_formats(ctx, v->value_int_n.ints, GL_FALSE);
+        _mesa_get_compressed_formats(ctx, v->value_int_n.ints);
       ASSERT(v->value_int_n.n <= 100);
       break;
 
index 6d7bc73..37127dc 100644 (file)
@@ -84,6 +84,7 @@ _mesa_type_is_packed(GLenum type)
    case GL_UNSIGNED_INT_24_8_EXT:
    case GL_UNSIGNED_INT_5_9_9_9_REV:
    case GL_UNSIGNED_INT_10F_11F_11F_REV:
+   case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
       return GL_TRUE;
    }
 
@@ -228,6 +229,8 @@ _mesa_sizeof_packed_type( GLenum type )
          return sizeof(GLuint);
       case GL_UNSIGNED_INT_10F_11F_11F_REV:
          return sizeof(GLuint);
+      case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+         return 8;
       default:
          return -1;
    }
@@ -379,6 +382,11 @@ _mesa_bytes_per_pixel( GLenum format, GLenum type )
             return sizeof(GLuint);
          else
             return -1;
+      case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+         if (format == GL_DEPTH_STENCIL)
+            return 8;
+         else
+            return -1;
       default:
          return -1;
    }
@@ -531,8 +539,10 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
          else
             return GL_FALSE;
       case GL_DEPTH_STENCIL_EXT:
-         if (ctx->Extensions.EXT_packed_depth_stencil
-             && type == GL_UNSIGNED_INT_24_8_EXT)
+         if ((ctx->Extensions.EXT_packed_depth_stencil &&
+              type == GL_UNSIGNED_INT_24_8_EXT) ||
+             (ctx->Extensions.ARB_depth_buffer_float &&
+              type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV))
             return GL_TRUE;
          else
             return GL_FALSE;
@@ -884,6 +894,7 @@ _mesa_is_depth_format(GLenum format)
       case GL_DEPTH_COMPONENT16:
       case GL_DEPTH_COMPONENT24:
       case GL_DEPTH_COMPONENT32:
+      case GL_DEPTH_COMPONENT32F:
          return GL_TRUE;
       default:
          return GL_FALSE;
@@ -931,6 +942,7 @@ _mesa_is_depthstencil_format(GLenum format)
    switch (format) {
       case GL_DEPTH24_STENCIL8_EXT:
       case GL_DEPTH_STENCIL_EXT:
+      case GL_DEPTH32F_STENCIL8:
          return GL_TRUE;
       default:
          return GL_FALSE;
@@ -956,6 +968,8 @@ _mesa_is_depth_or_stencil_format(GLenum format)
       case GL_STENCIL_INDEX16_EXT:
       case GL_DEPTH_STENCIL_EXT:
       case GL_DEPTH24_STENCIL8_EXT:
+      case GL_DEPTH_COMPONENT32F:
+      case GL_DEPTH32F_STENCIL8:
          return GL_TRUE;
       default:
          return GL_FALSE;
index f2724db..8a811cb 100644 (file)
@@ -706,6 +706,17 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth,
       }
    }
 
+   else if (datatype == GL_FLOAT_32_UNSIGNED_INT_24_8_REV && comps == 1) {
+      GLuint i, j, k;
+      const GLfloat *rowA = (const GLfloat *) srcRowA;
+      const GLfloat *rowB = (const GLfloat *) srcRowB;
+      GLfloat *dst = (GLfloat *) dstRow;
+      for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+           i++, j += colStride, k += colStride) {
+         dst[i*2] = (rowA[j*2] + rowA[k*2] + rowB[j*2] + rowB[k*2]) * 0.25F;
+      }
+   }
+
    else {
       _mesa_problem(NULL, "bad format in do_row()");
    }
@@ -1341,6 +1352,15 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth,
       }
    }
 
+   else if (datatype == GL_FLOAT_32_UNSIGNED_INT_24_8_REV && comps == 1) {
+      DECLARE_ROW_POINTERS(GLfloat, 2);
+
+      for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+           i++, j += colStride, k += colStride) {
+         FILTER_F_3D(0);
+      }
+   }
+
    else {
       _mesa_problem(NULL, "bad format in do_row()");
    }
index eb2efc8..b881183 100644 (file)
@@ -1435,8 +1435,7 @@ struct gl_texgen
 
 /**
  * Texture unit state.  Contains enable flags, texture environment/function/
- * combiners, texgen state, pointers to current texture objects and
- * post-filter color tables.
+ * combiners, texgen state, and pointers to current texture objects.
  */
 struct gl_texture_unit
 {
@@ -1857,7 +1856,7 @@ struct gl_program
    GLbitfield SystemValuesRead;   /**< Bitmask of SYSTEM_VALUE_x inputs used */
    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 */
+   GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];  /**< TEXTURE_x_BIT bitmask */
    GLbitfield SamplersUsed;   /**< Bitfield of which samplers are used */
    GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
 
index d6470e3..7de1d05 100644 (file)
@@ -1971,7 +1971,8 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
           srcType == GL_INT ||
           srcType == GL_UNSIGNED_INT_24_8_EXT ||
           srcType == GL_HALF_FLOAT_ARB ||
-          srcType == GL_FLOAT);
+          srcType == GL_FLOAT ||
+          srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
    switch (srcType) {
       case GL_BITMAP:
@@ -2142,6 +2143,23 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
             }
          }
          break;
+      case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+         {
+            GLuint i;
+            const GLuint *s = (const GLuint *) src;
+            if (unpack->SwapBytes) {
+               for (i = 0; i < n; i++) {
+                  GLuint value = s[i*2+1];
+                  SWAP4BYTE(value);
+                  indexes[i] = value & 0xff;  /* lower 8 bits */
+               }
+            }
+            else {
+               for (i = 0; i < n; i++)
+                  indexes[i] = s[i*2+1] & 0xff;  /* lower 8 bits */
+            }
+         }
+         break;
 
       default:
          _mesa_problem(NULL, "bad srcType in extract_uint_indexes");
@@ -4412,11 +4430,13 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
           srcType == GL_INT ||
           srcType == GL_UNSIGNED_INT_24_8_EXT ||
           srcType == GL_HALF_FLOAT_ARB ||
-          srcType == GL_FLOAT);
+          srcType == GL_FLOAT ||
+          srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
    ASSERT(dstType == GL_UNSIGNED_BYTE ||
           dstType == GL_UNSIGNED_SHORT ||
-          dstType == GL_UNSIGNED_INT);
+          dstType == GL_UNSIGNED_INT ||
+          dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
    /* only shift and offset apply to stencil */
    transferOps &= IMAGE_SHIFT_OFFSET_BIT;
@@ -4488,6 +4508,15 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
          case GL_UNSIGNED_INT:
             memcpy(dest, indexes, n * sizeof(GLuint));
             break;
+         case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+            {
+               GLuint *dst = (GLuint *) dest;
+               GLuint i;
+               for (i = 0; i < n; i++) {
+                  dst[i*2+1] = indexes[i] & 0xff; /* lower 8 bits */
+               }
+            }
+            break;
          default:
             _mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span");
       }
@@ -4683,7 +4712,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
                          GLenum srcType, const GLvoid *source,
                          const struct gl_pixelstore_attrib *srcPacking )
 {
-   GLfloat *depthTemp, *depthValues;
+   GLfloat *depthTemp = NULL, *depthValues;
    GLboolean needClamp = GL_FALSE;
 
    /* Look for special cases first.
@@ -4729,16 +4758,16 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
 
    /* general case path follows */
 
-   depthTemp = (GLfloat *) malloc(n * sizeof(GLfloat));
-   if (!depthTemp) {
-      _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
-      return;
-   }
-
    if (dstType == GL_FLOAT) {
       depthValues = (GLfloat *) dest;
    }
    else {
+      depthTemp = (GLfloat *) malloc(n * sizeof(GLfloat));
+      if (!depthTemp) {
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
+         return;
+      }
+
       depthValues = depthTemp;
    }
 
@@ -4782,6 +4811,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
                 }
                 zValues[i] = value & 0xffffff00;
             }
+            free(depthTemp);
             return;
          }
          else {
@@ -4797,6 +4827,20 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
             }
          }
          break;
+      case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+         {
+            GLuint i;
+            const GLfloat *src = (const GLfloat *)source;
+            for (i = 0; i < n; i++) {
+               GLfloat value = src[i * 2];
+               if (srcPacking->SwapBytes) {
+                  SWAP4BYTE(value);
+               }
+               depthValues[i] = value;
+            }
+            needClamp = GL_TRUE;
+         }
+         break;
       case GL_FLOAT:
          DEPTH_VALUES(GLfloat, 1*);
          needClamp = GL_TRUE;
@@ -4873,9 +4917,18 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
          zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax);
       }
    }
+   else if (dstType == GL_FLOAT) {
+      /* Nothing to do. depthValues is pointing to dest. */
+   }
+   else if (dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV) {
+      GLfloat *zValues = (GLfloat*) dest;
+      GLuint i;
+      for (i = 0; i < n; i++) {
+         zValues[i*2] = depthValues[i];
+      }
+   }
    else {
-      ASSERT(dstType == GL_FLOAT);
-      /*ASSERT(depthMax == 1.0F);*/
+      ASSERT(0);
    }
 
    free(depthTemp);
@@ -5003,10 +5056,11 @@ _mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest,
 
 
 /**
- * Pack depth and stencil values as GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8.
+ * Pack depth and stencil values as GL_DEPTH_STENCIL (GL_UNSIGNED_INT_24_8 etc)
  */
 void
-_mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest,
+_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
+                              GLenum dstType, GLuint *dest,
                               const GLfloat *depthVals,
                               const GLstencil *stencilVals,
                               const struct gl_pixelstore_attrib *dstPacking)
@@ -5036,9 +5090,19 @@ _mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest,
       stencilVals = stencilCopy;
    }
 
-   for (i = 0; i < n; i++) {
-      GLuint z = (GLuint) (depthVals[i] * 0xffffff);
-      dest[i] = (z << 8) | (stencilVals[i] & 0xff);
+   switch (dstType) {
+   case GL_UNSIGNED_INT_24_8:
+      for (i = 0; i < n; i++) {
+         GLuint z = (GLuint) (depthVals[i] * 0xffffff);
+         dest[i] = (z << 8) | (stencilVals[i] & 0xff);
+      }
+      break;
+   case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+      for (i = 0; i < n; i++) {
+         ((GLfloat*)dest)[i*2] = depthVals[i];
+         dest[i*2+1] = stencilVals[i] & 0xff;
+      }
+      break;
    }
 
    if (dstPacking->SwapBytes) {
index 78238ea..00aab40 100644 (file)
@@ -130,8 +130,8 @@ _mesa_pack_depth_span(struct gl_context *ctx, GLuint n, GLvoid *dest,
 
 
 extern void
-_mesa_pack_depth_stencil_span(struct gl_context *ctx,
-                              GLuint n, GLuint *dest,
+_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
+                              GLenum dstType, GLuint *dest,
                               const GLfloat *depthVals,
                               const GLstencil *stencilVals,
                               const struct gl_pixelstore_attrib *dstPacking);
index 0331a8c..84c5b22 100644 (file)
@@ -61,6 +61,14 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
       return GL_TRUE;
    }
 
+   if (ctx->Extensions.ARB_depth_buffer_float
+       && type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV
+       && format != GL_DEPTH_STENCIL_EXT) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
+      return GL_TRUE;
+   }
+
    /* basic combinations test */
    if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
       _mesa_error(ctx, GL_INVALID_ENUM,
@@ -142,10 +150,23 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
       }
       break;
    case GL_DEPTH_STENCIL_EXT:
-      if (!ctx->Extensions.EXT_packed_depth_stencil ||
-          type != GL_UNSIGNED_INT_24_8_EXT) {
-         _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
-         return GL_TRUE;
+      /* Check validity of the type first. */
+      switch (type) {
+         case GL_UNSIGNED_INT_24_8_EXT:
+            if (!ctx->Extensions.EXT_packed_depth_stencil) {
+               _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+               return GL_TRUE;
+            }
+            break;
+         case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+            if (!ctx->Extensions.ARB_depth_buffer_float) {
+               _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+               return GL_TRUE;
+            }
+            break;
+         default:
+            _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+            return GL_TRUE;
       }
       if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) ||
           (reading && !_mesa_source_buffer_exists(ctx, format))) {
index fa884c0..70011e6 100644 (file)
@@ -66,6 +66,9 @@ get_datatype_bytes(struct gl_renderbuffer *rb)
    int component_size;
 
    switch (rb->DataType) {
+   case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+      component_size = 8;
+      break;
    case GL_FLOAT:
    case GL_UNSIGNED_INT:
    case GL_UNSIGNED_INT_24_8_EXT:
@@ -2527,17 +2530,13 @@ _mesa_remove_renderbuffer(struct gl_framebuffer *fb,
  * Set *ptr to point to rb.  If *ptr points to another renderbuffer,
  * dereference that buffer first.  The new renderbuffer's refcount will
  * be incremented.  The old renderbuffer's refcount will be decremented.
+ * This is normally only called from the _mesa_reference_renderbuffer() macro
+ * when there's a real pointer change.
  */
 void
-_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
-                             struct gl_renderbuffer *rb)
+_mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr,
+                              struct gl_renderbuffer *rb)
 {
-   assert(ptr);
-   if (*ptr == rb) {
-      /* no change */
-      return;
-   }
-
    if (*ptr) {
       /* Unreference the old renderbuffer */
       GLboolean deleteFlag = GL_FALSE;
@@ -2567,26 +2566,3 @@ _mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
       *ptr = rb;
    }
 }
-
-
-/**
- * Create a new combined depth/stencil renderbuffer for implementing
- * the GL_EXT_packed_depth_stencil extension.
- * \return new depth/stencil renderbuffer
- */
-struct gl_renderbuffer *
-_mesa_new_depthstencil_renderbuffer(struct gl_context *ctx, GLuint name)
-{
-   struct gl_renderbuffer *dsrb;
-
-   dsrb = _mesa_new_renderbuffer(ctx, name);
-   if (!dsrb)
-      return NULL;
-
-   /* init fields not covered by _mesa_new_renderbuffer() */
-   dsrb->InternalFormat = GL_DEPTH24_STENCIL8_EXT;
-   dsrb->Format = MESA_FORMAT_Z24_S8;
-   dsrb->AllocStorage = _mesa_soft_renderbuffer_storage;
-
-   return dsrb;
-}
index 39d9b30..f9329d5 100644 (file)
@@ -105,11 +105,17 @@ _mesa_remove_renderbuffer(struct gl_framebuffer *fb,
                           gl_buffer_index bufferName);
 
 extern void
-_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
-                             struct gl_renderbuffer *rb);
+_mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr,
+                              struct gl_renderbuffer *rb);
 
-extern struct gl_renderbuffer *
-_mesa_new_depthstencil_renderbuffer(struct gl_context *ctx, GLuint name);
+static INLINE void
+_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
+                             struct gl_renderbuffer *rb)
+{
+   if (*ptr != rb)
+      _mesa_reference_renderbuffer_(ptr, rb);
+}
+      
 
 
 #endif /* RENDERBUFFER_H */
index f7774fd..8f8d87b 100644 (file)
@@ -251,7 +251,7 @@ _mesa_BindSampler(GLuint unit, GLuint sampler)
    struct gl_sampler_object *sampObj;
    GET_CURRENT_CONTEXT(ctx);
 
-   if (unit >= ctx->Const.MaxTextureImageUnits) {
+   if (unit >= ctx->Const.MaxCombinedTextureImageUnits) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glBindSampler(unit %u)", unit);
       return;
    }
index b58e30d..8df25c3 100644 (file)
@@ -1032,7 +1032,7 @@ validate_samplers(const struct gl_program *prog, char *errMsg)
       "TEXTURE_2D",
       "TEXTURE_1D",
    };
-   GLint targetUsed[MAX_TEXTURE_IMAGE_UNITS];
+   GLint targetUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
    GLbitfield samplersUsed = prog->SamplersUsed;
    GLuint i;
 
@@ -1050,7 +1050,7 @@ validate_samplers(const struct gl_program *prog, char *errMsg)
       gl_texture_index target;
       GLint sampler = _mesa_ffs(samplersUsed) - 1;
       assert(sampler >= 0);
-      assert(sampler < MAX_TEXTURE_IMAGE_UNITS);
+      assert(sampler < Elements(prog->SamplerUnits));
       unit = prog->SamplerUnits[sampler];
       target = prog->SamplerTargets[sampler];
       if (targetUsed[unit] != -1 && targetUsed[unit] != (int) target) {
index 33d91ad..f128648 100644 (file)
@@ -244,6 +244,8 @@ _mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog
    prog->Geom.InputType = GL_TRIANGLES;
    prog->Geom.OutputType = GL_TRIANGLE_STRIP;
 #endif
+
+   prog->InfoLog = ralloc_strdup(prog, "");
 }
 
 /**
@@ -283,6 +285,10 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
       _mesa_free_parameter_list(shProg->Varying);
       shProg->Varying = NULL;
    }
+
+   assert(shProg->InfoLog != NULL);
+   ralloc_free(shProg->InfoLog);
+   shProg->InfoLog = ralloc_strdup(shProg, "");
 }
 
 
@@ -317,11 +323,6 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
       shProg->Shaders = NULL;
    }
 
-   if (shProg->InfoLog) {
-      ralloc_free(shProg->InfoLog);
-      shProg->InfoLog = NULL;
-   }
-
    /* Transform feedback varying vars */
    for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) {
       free(shProg->TransformFeedback.VaryingNames[i]);
index 4696dbb..7ad50bc 100644 (file)
@@ -192,7 +192,10 @@ update_arrays( struct gl_context *ctx )
 static void
 update_program_enables(struct gl_context *ctx)
 {
-   /* These _Enabled flags indicate if the program is enabled AND valid. */
+   /* These _Enabled flags indicate if the user-defined ARB/NV vertex/fragment
+    * program is enabled AND valid.  Similarly for ATI fragment shaders.
+    * GLSL shaders not relevant here.
+    */
    ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
       && ctx->VertexProgram.Current->Base.Instructions;
    ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
@@ -203,11 +206,12 @@ update_program_enables(struct gl_context *ctx)
 
 
 /**
- * Update vertex/fragment program state.  In particular, update these fields:
- *   ctx->VertexProgram._Current
- *   ctx->VertexProgram._TnlProgram,
- * These point to the highest priority enabled vertex/fragment program or are
- * NULL if fixed-function processing is to be done.
+ * Update the ctx->Vertex/Geometry/FragmentProgram._Current pointers to point
+ * to the current/active programs.  Then call ctx->Driver.BindProgram() to
+ * tell the driver which programs to use.
+ *
+ * Programs may come from 3 sources: GLSL shaders, ARB/NV_vertex/fragment
+ * programs or programs derived from fixed-function state.
  *
  * This function needs to be called after texture state validation in case
  * we're generating a fragment program from fixed-function texture state.
@@ -243,34 +247,33 @@ update_program(struct gl_context *ctx)
     */
 
    if (fsProg && fsProg->LinkStatus && fsProg->FragmentProgram) {
-      /* Use shader programs */
+      /* Use GLSL fragment shader */
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
                                fsProg->FragmentProgram);
    }
    else if (ctx->FragmentProgram._Enabled) {
-      /* use user-defined vertex program */
+      /* Use user-defined fragment program */
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
                                ctx->FragmentProgram.Current);
    }
    else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
-      /* Use fragment program generated from fixed-function state.
-       */
+      /* Use fragment program generated from fixed-function state */
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
                                _mesa_get_fixed_func_fragment_program(ctx));
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
                                ctx->FragmentProgram._Current);
    }
    else {
-      /* no fragment program */
+      /* No fragment program */
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
    }
 
    if (gsProg && gsProg->LinkStatus && gsProg->GeometryProgram) {
-      /* Use shader programs */
+      /* Use GLSL geometry shader */
       _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current,
                                gsProg->GeometryProgram);
    } else {
-      /* no fragment program */
+      /* No geometry program */
       _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL);
    }
 
@@ -279,18 +282,17 @@ update_program(struct gl_context *ctx)
     * fragprog inputs.
     */
    if (vsProg && vsProg->LinkStatus && vsProg->VertexProgram) {
-      /* Use shader programs */
+      /* Use GLSL vertex shader */
       _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
-                            vsProg->VertexProgram);
+                               vsProg->VertexProgram);
    }
    else if (ctx->VertexProgram._Enabled) {
-      /* use user-defined vertex program */
+      /* Use user-defined vertex program */
       _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
                                ctx->VertexProgram.Current);
    }
    else if (ctx->VertexProgram._MaintainTnlProgram) {
-      /* Use vertex program generated from fixed-function state.
-       */
+      /* Use vertex program generated from fixed-function state */
       _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
                                _mesa_get_fixed_func_vertex_program(ctx));
       _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram,
@@ -416,29 +418,44 @@ update_color(struct gl_context *ctx)
    ctx->Color._LogicOpEnabled = _mesa_rgba_logicop_enabled(ctx);
 }
 
+
+/**
+ * Update the ctx->Color._ClampFragmentColor field
+ */
 static void
 update_clamp_fragment_color(struct gl_context *ctx)
 {
-   if(ctx->Color.ClampFragmentColor == GL_FIXED_ONLY_ARB)
-      ctx->Color._ClampFragmentColor = !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode;
+   if (ctx->Color.ClampFragmentColor == GL_FIXED_ONLY_ARB)
+      ctx->Color._ClampFragmentColor =
+         !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode;
    else
       ctx->Color._ClampFragmentColor = ctx->Color.ClampFragmentColor;
 }
 
+
+/**
+ * Update the ctx->Color._ClampVertexColor field
+ */
 static void
 update_clamp_vertex_color(struct gl_context *ctx)
 {
-   if(ctx->Light.ClampVertexColor == GL_FIXED_ONLY_ARB)
-      ctx->Light._ClampVertexColor = !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode;
+   if (ctx->Light.ClampVertexColor == GL_FIXED_ONLY_ARB)
+      ctx->Light._ClampVertexColor =
+         !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode;
    else
       ctx->Light._ClampVertexColor = ctx->Light.ClampVertexColor;
 }
 
+
+/**
+ * Update the ctx->Color._ClampReadColor field
+ */
 static void
 update_clamp_read_color(struct gl_context *ctx)
 {
-   if(ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB)
-      ctx->Color._ClampReadColor = !ctx->ReadBuffer || !ctx->ReadBuffer->Visual.floatMode;
+   if (ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB)
+      ctx->Color._ClampReadColor =
+         !ctx->ReadBuffer || !ctx->ReadBuffer->Visual.floatMode;
    else
       ctx->Color._ClampReadColor = ctx->Color.ClampReadColor;
 }
index d820ae9..42bd1ee 100644 (file)
 
 
 /**
+ * Get the GL base format of a specified GL compressed texture format
+ *
+ * From page 232 of the OpenGL 3.3 (Compatiblity Profile) spec:
+ *
+ *     "Compressed Internal Format      Base Internal Format    Type
+ *     ---------------------------     --------------------    ---------
+ *     COMPRESSED_ALPHA                ALPHA                   Generic
+ *     COMPRESSED_LUMINANCE            LUMINANCE               Generic
+ *     COMPRESSED_LUMINANCE_ALPHA      LUMINANCE_ALPHA         Generic
+ *     COMPRESSED_INTENSITY            INTENSITY               Generic
+ *     COMPRESSED_RED                  RED                     Generic
+ *     COMPRESSED_RG                   RG                      Generic
+ *     COMPRESSED_RGB                  RGB                     Generic
+ *     COMPRESSED_RGBA                 RGBA                    Generic
+ *     COMPRESSED_SRGB                 RGB                     Generic
+ *     COMPRESSED_SRGB_ALPHA           RGBA                    Generic
+ *     COMPRESSED_SLUMINANCE           LUMINANCE               Generic
+ *     COMPRESSED_SLUMINANCE_ALPHA     LUMINANCE_ALPHA         Generic
+ *     COMPRESSED_RED_RGTC1            RED                     Specific
+ *     COMPRESSED_SIGNED_RED_RGTC1     RED                     Specific
+ *     COMPRESSED_RG_RGTC2             RG                      Specific
+ *     COMPRESSED_SIGNED_RG_RGTC2      RG                      Specific"
+ *
+ * \return
+ * The base format of \c format if \c format is a compressed format (either
+ * generic or specific.  Otherwise 0 is returned.
+ */
+GLenum
+_mesa_gl_compressed_format_base_format(GLenum format)
+{
+   switch (format) {
+   case GL_COMPRESSED_RED:
+   case GL_COMPRESSED_RED_RGTC1:
+   case GL_COMPRESSED_SIGNED_RED_RGTC1:
+      return GL_RED;
+
+   case GL_COMPRESSED_RG:
+   case GL_COMPRESSED_RG_RGTC2:
+   case GL_COMPRESSED_SIGNED_RG_RGTC2:
+      return GL_RG;
+
+   case GL_COMPRESSED_RGB:
+   case GL_COMPRESSED_SRGB:
+   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+   case GL_COMPRESSED_RGB_FXT1_3DFX:
+   case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+      return GL_RGB;
+
+   case GL_COMPRESSED_RGBA:
+   case GL_COMPRESSED_SRGB_ALPHA:
+   case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB:
+   case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB:
+   case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB:
+   case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB:
+   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+   case GL_COMPRESSED_RGBA_FXT1_3DFX:
+   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 GL_RGBA;
+
+   case GL_COMPRESSED_ALPHA:
+      return GL_ALPHA;
+
+   case GL_COMPRESSED_LUMINANCE:
+   case GL_COMPRESSED_SLUMINANCE:
+   case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+   case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+      return GL_LUMINANCE;
+
+   case GL_COMPRESSED_LUMINANCE_ALPHA:
+   case GL_COMPRESSED_SLUMINANCE_ALPHA:
+   case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+   case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+   case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+      return GL_LUMINANCE_ALPHA;
+
+   case GL_COMPRESSED_INTENSITY:
+      return GL_INTENSITY;
+
+   default:
+      return 0;
+   }
+}
+
+/**
  * Return list of (and count of) all specific texture compression
  * formats that are supported.
  *
+ * Some formats are \b not returned by this function.  The
+ * \c GL_COMPRESSED_TEXTURE_FORMATS query only returns formats that are
+ * "suitable for general-purpose usage."  All texture compression extensions
+ * have taken this to mean either linear RGB or linear RGBA.
+ *
+ * The GL_ARB_texture_compress_rgtc spec says:
+ *
+ *    "19) Should the GL_NUM_COMPRESSED_TEXTURE_FORMATS and
+ *        GL_COMPRESSED_TEXTURE_FORMATS queries return the RGTC formats?
+ *
+ *        RESOLVED:  No.
+ *
+ *        The OpenGL 2.1 specification says "The only values returned
+ *        by this query [GL_COMPRESSED_TEXTURE_FORMATS"] are those
+ *        corresponding to formats suitable for general-purpose usage.
+ *        The renderer will not enumerate formats with restrictions that
+ *        need to be specifically understood prior to use."
+ *
+ *        Compressed textures with just red or red-green components are
+ *        not general-purpose so should not be returned by these queries
+ *        because they have restrictions.
+ *
+ *        Applications that seek to use the RGTC formats should do so
+ *        by looking for this extension's name in the string returned by
+ *        glGetString(GL_EXTENSIONS) rather than
+ *        what GL_NUM_COMPRESSED_TEXTURE_FORMATS and
+ *        GL_COMPRESSED_TEXTURE_FORMATS return."
+ *
+ * There is nearly identical wording in the GL_EXT_texture_compression_rgtc
+ * spec.
+ *
+ * The GL_EXT_texture_rRGB spec says:
+ *
+ *    "22) Should the new COMPRESSED_SRGB_* formats be listed in an
+ *        implementation's GL_COMPRESSED_TEXTURE_FORMATS list?
+ *
+ *        RESOLVED:  No.  Section 3.8.1 says formats listed by
+ *        GL_COMPRESSED_TEXTURE_FORMATS are "suitable for general-purpose
+ *        usage."  The non-linear distribution of red, green, and
+ *        blue for these sRGB compressed formats makes them not really
+ *        general-purpose."
+ *
+ * The GL_EXT_texture_compression_latc spec says:
+ *
+ *    "16) Should the GL_NUM_COMPRESSED_TEXTURE_FORMATS and
+ *        GL_COMPRESSED_TEXTURE_FORMATS queries return the LATC formats?
+ *
+ *        RESOLVED:  No.
+ *
+ *        The OpenGL 2.1 specification says "The only values returned
+ *        by this query [GL_COMPRESSED_TEXTURE_FORMATS"] are those
+ *        corresponding to formats suitable for general-purpose usage.
+ *        The renderer will not enumerate formats with restrictions that
+ *        need to be specifically understood prior to use."
+ *
+ *        Historically, OpenGL implementation have advertised the RGB and
+ *        RGBA versions of the S3TC extensions compressed format tokens
+ *        through this mechanism.
+ *
+ *        The specification is not sufficiently clear about what "suitable
+ *        for general-purpose usage" means.  Historically that seems to mean
+ *        unsigned RGB or unsigned RGBA.  The DXT1 format supporting alpha
+ *        (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) is not exposed in the list (at
+ *        least for NVIDIA drivers) because the alpha is always 1.0 expect
+ *        when it is 0.0 when RGB is required to be black.  NVIDIA's even
+ *        limits itself to true linear RGB or RGBA formats, specifically
+ *        not including EXT_texture_sRGB's sRGB S3TC compressed formats.
+ *
+ *        Adding luminance and luminance-alpha texture formats (and
+ *        certainly signed versions of luminance and luminance-alpha
+ *        formats!) invites potential comptaibility problems with old
+ *        applications using this mechanism since old applications are
+ *        unlikely to expect non-RGB or non-RGBA formats to be advertised
+ *        through this mechanism.  However no specific misinteractions
+ *        with old applications is known.
+ *
+ *        Applications that seek to use the LATC formats should do so
+ *        by looking for this extension's name in the string returned by
+ *        glGetString(GL_EXTENSIONS) rather than
+ *        what GL_NUM_COMPRESSED_TEXTURE_FORMATS and
+ *        GL_COMPRESSED_TEXTURE_FORMATS return."
+ *
+ * There is no formal spec for GL_ATI_texture_compression_3dc.  Since the
+ * formats added by this extension are luminance-alpha formats, it is
+ * reasonable to expect them to follow the same rules as
+ * GL_EXT_texture_compression_latc.  At the very least, Catalyst 11.6 does not
+ * expose the 3dc formats through this mechanism.
+ *
  * \param ctx  the GL context
  * \param formats  the resulting format list (may be NULL).
- * \param all  if true return all formats, even those with  some kind
- *             of restrictions/limitations (See GL_ARB_texture_compression
- *             spec for more info).
  *
  * \return number of formats.
  */
 GLuint
-_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean all)
+_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
 {
    GLuint n = 0;
    if (ctx->Extensions.TDFX_texture_compression_FXT1) {
@@ -64,24 +237,15 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean a
          n += 2;
       }
    }
-   /* don't return RGTC - ARB_texture_compression_rgtc query 19 */
+
    if (ctx->Extensions.EXT_texture_compression_s3tc) {
       if (formats) {
          formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
-         /* This format has some restrictions/limitations and so should
-          * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query.
-          * Specifically, all transparent pixels become black.  NVIDIA
-          * omits this format too.
-          */
-         if (all)
-             formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
          formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
          formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
       }
       else {
          n += 3;
-         if (all)
-             n += 1;
       }
    }
    if (ctx->Extensions.S3_s3tc) {
@@ -95,19 +259,6 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean a
          n += 4;
       }
    }
-#if FEATURE_EXT_texture_sRGB
-   if (ctx->Extensions.EXT_texture_sRGB) {
-      if (formats) {
-         formats[n++] = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
-         formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
-         formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
-         formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
-      }
-      else {
-         n += 4;
-      }
-   }
-#endif /* FEATURE_EXT_texture_sRGB */
    return n;
 
 #if FEATURE_ES1 || FEATURE_ES2
index 19b08bb..375cf90 100644 (file)
@@ -33,8 +33,11 @@ struct gl_context;
 
 #if _HAVE_FULL_GL
 
+extern GLenum
+_mesa_gl_compressed_format_base_format(GLenum format);
+
 extern GLuint
-_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean all);
+_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats);
 
 extern gl_format
 _mesa_glenum_to_compressed_format(GLenum format);
index 9228e35..c0d0f37 100644 (file)
@@ -419,7 +419,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
-      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
    if (ctx->Texture.CurrentUnit >= maxUnit) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)");
       return;
@@ -748,7 +748,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
-      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
    if (ctx->Texture.CurrentUnit >= maxUnit) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)");
       return;
@@ -817,7 +817,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
-      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
    if (ctx->Texture.CurrentUnit >= maxUnit) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)");
       return;
index 6716ce1..72283eb 100644 (file)
@@ -913,6 +913,20 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_2d_r11_g11_b10f,
       fetch_texel_3d_r11_g11_b10f,
       store_texel_r11_g11_b10f
+   },
+   {
+      MESA_FORMAT_Z32_FLOAT,
+      fetch_texel_1d_f_r_f32, /* Reuse the R32F functions. */
+      fetch_texel_2d_f_r_f32,
+      fetch_texel_3d_f_r_f32,
+      store_texel_r_f32
+   },
+   {
+      MESA_FORMAT_Z32_FLOAT_X24S8,
+      fetch_texel_1d_z32f_x24s8,
+      fetch_texel_2d_z32f_x24s8,
+      fetch_texel_3d_z32f_x24s8,
+      store_texel_z32f_x24s8
    }
 };
 
index e6fd81d..d170adf 100644 (file)
@@ -2287,7 +2287,8 @@ static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
    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(texImage->TexFormat == MESA_FORMAT_Z24_S8 ||
+         texImage->TexFormat == MESA_FORMAT_Z24_X8);
    ASSERT(texel[0] >= 0.0F);
    ASSERT(texel[0] <= 1.0F);
 }
@@ -2314,7 +2315,8 @@ static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
    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(texImage->TexFormat == MESA_FORMAT_S8_Z24 ||
+         texImage->TexFormat == MESA_FORMAT_X8_Z24);
    ASSERT(texel[0] >= 0.0F);
    ASSERT(texel[0] <= 1.0F);
 }
@@ -2374,6 +2376,29 @@ static void store_texel_r11_g11_b10f(struct gl_texture_image *texImage,
 #endif
 
 
+/* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/
+
+static void FETCH(z32f_x24s8)(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] = src[0];
+   texel[GCOMP] = 0.0F;
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_z32f_x24s8(struct gl_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLfloat *src = (const GLfloat *) texel;
+   GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+   dst[0] = src[0];
+}
+#endif
+
+
 #undef TEXEL_ADDR
 #undef DIM
 #undef FETCH
index 8cbb021..c919a74 100644 (file)
@@ -416,6 +416,19 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
       }
    }
 
+   if (ctx->Extensions.ARB_depth_buffer_float) {
+      switch (internalFormat) {
+         case GL_DEPTH_COMPONENT32F:
+            ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT]);
+            return MESA_FORMAT_Z32_FLOAT;
+         case GL_DEPTH32F_STENCIL8:
+            ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_X24S8]);
+            return MESA_FORMAT_Z32_FLOAT_X24S8;
+         default:
+            ; /* fallthrough */
+      }
+   }
+
    if (ctx->Extensions.ATI_envmap_bumpmap) {
       switch (internalFormat) {
          case GL_DUDV_ATI:
index 0827cb8..27717cf 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * mesa 3-D graphics library
- * Version:  7.6
+ * Mesa 3-D graphics library
  *
  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
@@ -556,8 +555,6 @@ _mesa_tex_target_to_face(GLenum target)
  * \param target texture target.
  * \param level image level.
  * \param texImage texture image.
- * 
- * This was basically prompted by the introduction of cube maps.
  */
 void
 _mesa_set_tex_image(struct gl_texture_object *tObj,
@@ -709,15 +706,13 @@ get_proxy_target(GLenum target)
 
 /**
  * Get the texture object that corresponds to the target of the given
- * texture unit.
+ * texture unit.  The target should have already been checked for validity.
  *
  * \param ctx GL context.
  * \param texUnit texture unit.
  * \param target texture target.
  *
  * \return pointer to the texture object on success, or NULL on failure.
- * 
- * \sa gl_texture_unit.
  */
 struct gl_texture_object *
 _mesa_select_tex_object(struct gl_context *ctx,
@@ -1685,11 +1680,15 @@ texture_error_check( struct gl_context *ctx,
 
    /* additional checks for depth textures */
    if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) {
-      /* Only 1D, 2D and rectangular textures supported, not 3D or cubes */
+      /* Only 1D, 2D, rect and array textures supported, not 3D or cubes */
       if (target != GL_TEXTURE_1D &&
           target != GL_PROXY_TEXTURE_1D &&
           target != GL_TEXTURE_2D &&
           target != GL_PROXY_TEXTURE_2D &&
+          target != GL_TEXTURE_1D_ARRAY &&
+          target != GL_PROXY_TEXTURE_1D_ARRAY &&
+          target != GL_TEXTURE_2D_ARRAY &&
+          target != GL_PROXY_TEXTURE_2D_ARRAY &&
           target != GL_TEXTURE_RECTANGLE_ARB &&
           target != GL_PROXY_TEXTURE_RECTANGLE_ARB) {
          if (!isProxy)
@@ -2793,29 +2792,43 @@ copyteximage(struct gl_context *ctx, GLuint dims,
         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
       }
       else {
-         gl_format texFormat;
-
-         if (texImage->Data) {
-            ctx->Driver.FreeTexImageData( ctx, texImage );
-         }
+         /* choose actual hw format */
+         gl_format texFormat = _mesa_choose_texture_format(ctx, texObj,
+                                                           target, level,
+                                                           internalFormat,
+                                                           GL_NONE, GL_NONE);
 
-         ASSERT(texImage->Data == NULL);
+         if (legal_texture_size(ctx, texFormat, width, height, 1)) {
+            GLint srcX = x, srcY = y, dstX = 0, dstY = 0;
 
-         texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
-                                                 internalFormat, GL_NONE,
-                                                 GL_NONE);
+            /* Free old texture image */
+            ctx->Driver.FreeTexImageData(ctx, texImage);
 
-         if (legal_texture_size(ctx, texFormat, width, height, 1)) {
             _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
                                        border, internalFormat, texFormat);
 
-            ASSERT(ctx->Driver.CopyTexImage2D);
-            if (dims == 1)
-               ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat,
-                                          x, y, width, border);
-            else
-               ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat,
-                                          x, y, width, height, border);
+            /* Allocate texture memory (no pixel data yet) */
+            if (dims == 1) {
+               ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
+                                      width, border, GL_NONE, GL_NONE, NULL,
+                                      &ctx->Unpack, texObj, texImage);
+            }
+            else {
+               ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
+                                      width, height, border, GL_NONE, GL_NONE,
+                                      NULL, &ctx->Unpack, texObj, texImage);
+            }
+
+            if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY,
+                                           &width, &height)) {
+               if (dims == 1)
+                  ctx->Driver.CopyTexSubImage1D(ctx, target, level, dstX,
+                                                srcX, srcY, width);
+                                                
+               else
+                  ctx->Driver.CopyTexSubImage2D(ctx, target, level, dstX, dstY,
+                                                srcX, srcY, width, height);
+            }
 
             check_gen_mipmap(ctx, target, texObj, level);
 
@@ -2826,6 +2839,7 @@ copyteximage(struct gl_context *ctx, GLuint dims,
             ctx->NewState |= _NEW_TEXTURE;
          }
          else {
+            /* probably too large of image */
             _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
          }
       }
@@ -3270,7 +3284,7 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
                                           border, imageSize, &reason);
 
    if (error) {
-      _mesa_error(ctx, error, "glTexImage2D(%s)", reason);
+      _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason);
       return;
    }
 
index fdf1281..3021716 100644 (file)
@@ -325,16 +325,14 @@ valid_texture_object(const struct gl_texture_object *tex)
  * Reference (or unreference) a texture object.
  * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero).
  * If 'tex' is non-null, increment its refcount.
+ * This is normally only called from the _mesa_reference_texobj() macro
+ * when there's a real pointer change.
  */
 void
-_mesa_reference_texobj(struct gl_texture_object **ptr,
-                       struct gl_texture_object *tex)
+_mesa_reference_texobj_(struct gl_texture_object **ptr,
+                        struct gl_texture_object *tex)
 {
    assert(ptr);
-   if (*ptr == tex) {
-      /* no change */
-      return;
-   }
 
    if (*ptr) {
       /* Unreference the old texture */
@@ -879,6 +877,8 @@ unbind_texobj_from_fbo(struct gl_context *ctx,
          for (j = 0; j < BUFFER_COUNT; j++) {
             if (fb->Attachment[j].Type == GL_TEXTURE &&
                 fb->Attachment[j].Texture == texObj) {
+              /* Vertices are already flushed by _mesa_DeleteTextures */
+              ctx->NewState |= _NEW_BUFFERS;
                _mesa_remove_attachment(ctx, fb->Attachment + j);         
             }
          }
@@ -897,7 +897,7 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
 {
    GLuint u, tex;
 
-   for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
+   for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
       struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
       for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
          if (texObj == unit->CurrentTex[tex]) {
index 476a175..1faae6f 100644 (file)
@@ -32,6 +32,7 @@
 #define TEXTOBJ_H
 
 
+#include "compiler.h"
 #include "glheader.h"
 
 struct gl_context;
@@ -64,8 +65,17 @@ _mesa_clear_texture_object(struct gl_context *ctx,
                            struct gl_texture_object *obj);
 
 extern void
+_mesa_reference_texobj_(struct gl_texture_object **ptr,
+                        struct gl_texture_object *tex);
+
+static INLINE void
 _mesa_reference_texobj(struct gl_texture_object **ptr,
-                       struct gl_texture_object *tex);
+                       struct gl_texture_object *tex)
+{
+   if (*ptr != tex)
+      _mesa_reference_texobj_(ptr, tex);
+}
+
 
 extern void
 _mesa_test_texobj_completeness( const struct gl_context *ctx,
index 4b9dcb5..bbbb306 100644 (file)
@@ -888,7 +888,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
    texObj = _mesa_select_tex_object(ctx, texUnit, target);
 
    img = _mesa_select_tex_image(ctx, texObj, target, level);
-   if (!img || !img->TexFormat) {
+   if (!img || img->TexFormat == MESA_FORMAT_NONE) {
       /* undefined texture image */
       if (pname == GL_TEXTURE_COMPONENTS)
          *params = 1;
@@ -915,9 +915,23 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
             *params = _mesa_compressed_format_to_glenum(ctx, texFormat);
          }
          else {
-            /* return the user's requested internal format */
-            *params = img->InternalFormat;
-         }
+           /* If the true internal format is not compressed but the user
+            * requested a generic compressed format, we have to return the
+            * generic base format that matches.
+            *
+            * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec:
+            *
+            *     "If no specific compressed format is available,
+            *     internalformat is instead replaced by the corresponding base
+            *     internal format."
+            *
+            * Otherwise just return the user's requested internal format
+            */
+           const GLenum f =
+              _mesa_gl_compressed_format_base_format(img->InternalFormat);
+
+           *params = (f != 0) ? f : img->InternalFormat;
+        }
          break;
       case GL_TEXTURE_BORDER:
          *params = img->Border;
@@ -980,28 +994,21 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
             *params = 0;
          break;
       case GL_TEXTURE_DEPTH_SIZE_ARB:
-         if (ctx->Extensions.ARB_depth_texture)
-            *params = _mesa_get_format_bits(texFormat, pname);
-         else
+         if (!ctx->Extensions.ARB_depth_texture)
             goto invalid_pname;
+         *params = _mesa_get_format_bits(texFormat, pname);
          break;
       case GL_TEXTURE_STENCIL_SIZE_EXT:
-         if (ctx->Extensions.EXT_packed_depth_stencil ||
-             ctx->Extensions.ARB_framebuffer_object) {
-            *params = _mesa_get_format_bits(texFormat, pname);
-         }
-         else {
+         if (!ctx->Extensions.EXT_packed_depth_stencil &&
+             !ctx->Extensions.ARB_framebuffer_object)
             goto invalid_pname;
-         }
+         *params = _mesa_get_format_bits(texFormat, pname);
          break;
       case GL_TEXTURE_SHARED_SIZE:
-         if (ctx->VersionMajor >= 3 ||
-             ctx->Extensions.EXT_texture_shared_exponent) {
-            *params = texFormat == MESA_FORMAT_RGB9_E5_FLOAT ? 5 : 0;
-         }
-         else {
+         if (ctx->VersionMajor < 3 &&
+             !ctx->Extensions.EXT_texture_shared_exponent)
             goto invalid_pname;
-         }
+         *params = texFormat == MESA_FORMAT_RGB9_E5_FLOAT ? 5 : 0;
          break;
 
       /* GL_ARB_texture_compression */
@@ -1022,67 +1029,46 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
 
       /* GL_ARB_texture_float */
       case GL_TEXTURE_RED_TYPE_ARB:
-         if (ctx->Extensions.ARB_texture_float) {
-            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ?
-               _mesa_get_format_datatype(texFormat) : GL_NONE;
-         }
-         else {
+         if (!ctx->Extensions.ARB_texture_float)
             goto invalid_pname;
-         }
+         *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ?
+            _mesa_get_format_datatype(texFormat) : GL_NONE;
          break;
       case GL_TEXTURE_GREEN_TYPE_ARB:
-         if (ctx->Extensions.ARB_texture_float) {
-            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ?
-               _mesa_get_format_datatype(texFormat) : GL_NONE;
-         }
-         else {
+         if (!ctx->Extensions.ARB_texture_float)
             goto invalid_pname;
-         }
+         *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ?
+            _mesa_get_format_datatype(texFormat) : GL_NONE;
          break;
       case GL_TEXTURE_BLUE_TYPE_ARB:
-         if (ctx->Extensions.ARB_texture_float) {
-            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ?
-               _mesa_get_format_datatype(texFormat) : GL_NONE;
-         }
-         else {
+         if (!ctx->Extensions.ARB_texture_float)
             goto invalid_pname;
-         }
+         *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ?
+            _mesa_get_format_datatype(texFormat) : GL_NONE;
          break;
       case GL_TEXTURE_ALPHA_TYPE_ARB:
-         if (ctx->Extensions.ARB_texture_float) {
-            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ?
-               _mesa_get_format_datatype(texFormat) : GL_NONE;
-         }
-         else {
+         if (!ctx->Extensions.ARB_texture_float)
             goto invalid_pname;
-         }
+         *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ?
+            _mesa_get_format_datatype(texFormat) : GL_NONE;
          break;
       case GL_TEXTURE_LUMINANCE_TYPE_ARB:
-         if (ctx->Extensions.ARB_texture_float) {
-            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ?
-               _mesa_get_format_datatype(texFormat) : GL_NONE;
-         }
-         else {
+         if (!ctx->Extensions.ARB_texture_float)
             goto invalid_pname;
-         }
+         *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ?
+            _mesa_get_format_datatype(texFormat) : GL_NONE;
          break;
       case GL_TEXTURE_INTENSITY_TYPE_ARB:
-         if (ctx->Extensions.ARB_texture_float) {
-            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ?
-               _mesa_get_format_datatype(texFormat) : GL_NONE;
-         }
-         else {
+         if (!ctx->Extensions.ARB_texture_float)
             goto invalid_pname;
-         }
+         *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ?
+            _mesa_get_format_datatype(texFormat) : GL_NONE;
          break;
       case GL_TEXTURE_DEPTH_TYPE_ARB:
-         if (ctx->Extensions.ARB_texture_float) {
-            *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ?
-               _mesa_get_format_datatype(texFormat) : GL_NONE;
-         }
-         else {
+         if (!ctx->Extensions.ARB_texture_float)
             goto invalid_pname;
-         }
+         *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ?
+            _mesa_get_format_datatype(texFormat) : GL_NONE;
          break;
 
       default:
@@ -1104,7 +1090,6 @@ void GLAPIENTRY
 _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
 {
    struct gl_texture_object *obj;
-   GLboolean error = GL_FALSE;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
@@ -1130,17 +1115,15 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
          *params = ENUM_TO_FLOAT(obj->Sampler.WrapR);
          break;
       case GL_TEXTURE_BORDER_COLOR:
-         if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
+         if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
             _mesa_update_state_locked(ctx);
-         if(ctx->Color._ClampFragmentColor)
-         {
+         if (ctx->Color._ClampFragmentColor) {
             params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
             params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
             params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F);
             params[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F);
          }
-         else
-         {
+         else {
             params[0] = obj->Sampler.BorderColor.f[0];
             params[1] = obj->Sampler.BorderColor.f[1];
             params[2] = obj->Sampler.BorderColor.f[2];
@@ -1148,14 +1131,8 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
          }
          break;
       case GL_TEXTURE_RESIDENT:
-         {
-            GLboolean resident;
-            if (ctx->Driver.IsTextureResident)
-               resident = ctx->Driver.IsTextureResident(ctx, obj);
-            else
-               resident = GL_TRUE;
-            *params = ENUM_TO_FLOAT(resident);
-         }
+         *params = ctx->Driver.IsTextureResident ?
+            ctx->Driver.IsTextureResident(ctx, obj) : 1.0F;
          break;
       case GL_TEXTURE_PRIORITY:
          *params = obj->Priority;
@@ -1173,49 +1150,37 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
          *params = (GLfloat) obj->MaxLevel;
          break;
       case GL_TEXTURE_MAX_ANISOTROPY_EXT:
-         if (ctx->Extensions.EXT_texture_filter_anisotropic) {
-            *params = obj->Sampler.MaxAnisotropy;
-         }
-        else
-           error = GL_TRUE;
+         if (!ctx->Extensions.EXT_texture_filter_anisotropic)
+            goto invalid_pname;
+         *params = obj->Sampler.MaxAnisotropy;
          break;
       case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
-         if (ctx->Extensions.ARB_shadow_ambient) {
-            *params = obj->Sampler.CompareFailValue;
-         }
-        else 
-           error = GL_TRUE;
+         if (!ctx->Extensions.ARB_shadow_ambient)
+            goto invalid_pname;
+         *params = obj->Sampler.CompareFailValue;
          break;
       case GL_GENERATE_MIPMAP_SGIS:
         *params = (GLfloat) obj->GenerateMipmap;
          break;
       case GL_TEXTURE_COMPARE_MODE_ARB:
-         if (ctx->Extensions.ARB_shadow) {
-            *params = (GLfloat) obj->Sampler.CompareMode;
-         }
-        else 
-           error = GL_TRUE;
+         if (!ctx->Extensions.ARB_shadow)
+            goto invalid_pname;
+         *params = (GLfloat) obj->Sampler.CompareMode;
          break;
       case GL_TEXTURE_COMPARE_FUNC_ARB:
-         if (ctx->Extensions.ARB_shadow) {
-            *params = (GLfloat) obj->Sampler.CompareFunc;
-         }
-        else 
-           error = GL_TRUE;
+         if (!ctx->Extensions.ARB_shadow)
+            goto invalid_pname;
+         *params = (GLfloat) obj->Sampler.CompareFunc;
          break;
       case GL_DEPTH_TEXTURE_MODE_ARB:
-         if (ctx->Extensions.ARB_depth_texture) {
-            *params = (GLfloat) obj->Sampler.DepthMode;
-         }
-        else 
-           error = GL_TRUE;
+         if (!ctx->Extensions.ARB_depth_texture)
+            goto invalid_pname;
+         *params = (GLfloat) obj->Sampler.DepthMode;
          break;
       case GL_TEXTURE_LOD_BIAS:
-         if (ctx->Extensions.EXT_texture_lod_bias) {
-            *params = obj->Sampler.LodBias;
-         }
-        else 
-           error = GL_TRUE;
+         if (!ctx->Extensions.EXT_texture_lod_bias)
+            goto invalid_pname;
+         *params = obj->Sampler.LodBias;
          break;
 #if FEATURE_OES_draw_texture
       case GL_TEXTURE_CROP_RECT_OES:
@@ -1230,45 +1195,40 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
       case GL_TEXTURE_SWIZZLE_G_EXT:
       case GL_TEXTURE_SWIZZLE_B_EXT:
       case GL_TEXTURE_SWIZZLE_A_EXT:
-         if (ctx->Extensions.EXT_texture_swizzle) {
-            GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT;
-            *params = (GLfloat) obj->Swizzle[comp];
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.EXT_texture_swizzle)
+            goto invalid_pname;
+         *params = (GLfloat) obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT];
          break;
 
       case GL_TEXTURE_SWIZZLE_RGBA_EXT:
-         if (ctx->Extensions.EXT_texture_swizzle) {
+         if (!ctx->Extensions.EXT_texture_swizzle) {
+            goto invalid_pname;
+         }
+         else {
             GLuint comp;
             for (comp = 0; comp < 4; comp++) {
                params[comp] = (GLfloat) obj->Swizzle[comp];
             }
          }
-         else {
-            error = GL_TRUE;
-         }
          break;
 
       case GL_TEXTURE_CUBE_MAP_SEAMLESS:
-      if (ctx->Extensions.AMD_seamless_cubemap_per_texture) {
+         if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
+            goto invalid_pname;
          *params = (GLfloat) obj->Sampler.CubeMapSeamless;
-      }
-      else {
-         error = GL_TRUE;
-      }
+         break;
 
       default:
-        error = GL_TRUE;
-        break;
+         goto invalid_pname;
    }
 
-   if (error)
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)",
-                 pname);
+   /* no error if we get here */
+   _mesa_unlock_texture(ctx, obj);
+   return;
 
+invalid_pname:
    _mesa_unlock_texture(ctx, obj);
+   _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname);
 }
 
 
@@ -1276,13 +1236,12 @@ void GLAPIENTRY
 _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
 {
    struct gl_texture_object *obj;
-   GLboolean error = GL_FALSE;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-    obj = get_texobj(ctx, target, GL_TRUE);
-    if (!obj)
-       return;
+   obj = get_texobj(ctx, target, GL_TRUE);
+   if (!obj)
+      return;
 
    _mesa_lock_texture(ctx, obj);
    switch (pname) {
@@ -1315,14 +1274,8 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
          }
          break;;
       case GL_TEXTURE_RESIDENT:
-         {
-            GLboolean resident;
-            if (ctx->Driver.IsTextureResident)
-               resident = ctx->Driver.IsTextureResident(ctx, obj);
-            else
-               resident = GL_TRUE;
-            *params = (GLint) resident;
-         }
+         *params = ctx->Driver.IsTextureResident ?
+            ctx->Driver.IsTextureResident(ctx, obj) : 1;
          break;;
       case GL_TEXTURE_PRIORITY:
          *params = FLOAT_TO_INT(obj->Priority);
@@ -1340,55 +1293,37 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
          *params = obj->MaxLevel;
          break;;
       case GL_TEXTURE_MAX_ANISOTROPY_EXT:
-         if (ctx->Extensions.EXT_texture_filter_anisotropic) {
-            *params = (GLint) obj->Sampler.MaxAnisotropy;
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.EXT_texture_filter_anisotropic)
+            goto invalid_pname;
+         *params = (GLint) obj->Sampler.MaxAnisotropy;
          break;
       case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
-         if (ctx->Extensions.ARB_shadow_ambient) {
-            *params = (GLint) FLOAT_TO_INT(obj->Sampler.CompareFailValue);
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.ARB_shadow_ambient)
+            goto invalid_pname;
+         *params = (GLint) FLOAT_TO_INT(obj->Sampler.CompareFailValue);
          break;
       case GL_GENERATE_MIPMAP_SGIS:
         *params = (GLint) obj->GenerateMipmap;
          break;
       case GL_TEXTURE_COMPARE_MODE_ARB:
-         if (ctx->Extensions.ARB_shadow) {
-            *params = (GLint) obj->Sampler.CompareMode;
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.ARB_shadow)
+            goto invalid_pname;
+         *params = (GLint) obj->Sampler.CompareMode;
          break;
       case GL_TEXTURE_COMPARE_FUNC_ARB:
-         if (ctx->Extensions.ARB_shadow) {
-            *params = (GLint) obj->Sampler.CompareFunc;
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.ARB_shadow)
+            goto invalid_pname;
+         *params = (GLint) obj->Sampler.CompareFunc;
          break;
       case GL_DEPTH_TEXTURE_MODE_ARB:
-         if (ctx->Extensions.ARB_depth_texture) {
-            *params = (GLint) obj->Sampler.DepthMode;
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.ARB_depth_texture)
+            goto invalid_pname;
+         *params = (GLint) obj->Sampler.DepthMode;
          break;
       case GL_TEXTURE_LOD_BIAS:
-         if (ctx->Extensions.EXT_texture_lod_bias) {
-            *params = (GLint) obj->Sampler.LodBias;
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.EXT_texture_lod_bias)
+            goto invalid_pname;
+         *params = (GLint) obj->Sampler.LodBias;
          break;
 #if FEATURE_OES_draw_texture
       case GL_TEXTURE_CROP_RECT_OES:
@@ -1402,41 +1337,34 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
       case GL_TEXTURE_SWIZZLE_G_EXT:
       case GL_TEXTURE_SWIZZLE_B_EXT:
       case GL_TEXTURE_SWIZZLE_A_EXT:
-         if (ctx->Extensions.EXT_texture_swizzle) {
-            GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT;
-            *params = obj->Swizzle[comp];
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.EXT_texture_swizzle)
+            goto invalid_pname;
+         *params = obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT];
          break;
 
       case GL_TEXTURE_SWIZZLE_RGBA_EXT:
-         if (ctx->Extensions.EXT_texture_swizzle) {
-            COPY_4V(params, obj->Swizzle);
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.EXT_texture_swizzle)
+            goto invalid_pname;
+         COPY_4V(params, obj->Swizzle);
          break;
 
       case GL_TEXTURE_CUBE_MAP_SEAMLESS:
-         if (ctx->Extensions.AMD_seamless_cubemap_per_texture) {
-            *params = (GLint) obj->Sampler.CubeMapSeamless;
-         }
-         else {
-            error = GL_TRUE;
-         }
+         if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
+            goto invalid_pname;
+         *params = (GLint) obj->Sampler.CubeMapSeamless;
+         break;
 
       default:
-         ; /* silence warnings */
+         goto invalid_pname;
    }
 
-   if (error)
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)",
-                 pname);
+   /* no error if we get here */
+   _mesa_unlock_texture(ctx, obj);
+   return;
 
+invalid_pname:
    _mesa_unlock_texture(ctx, obj);
+   _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname);
 }
 
 
@@ -1449,6 +1377,8 @@ _mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params)
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    texObj = get_texobj(ctx, target, GL_TRUE);
+   if (!texObj)
+      return;
    
    switch (pname) {
    case GL_TEXTURE_BORDER_COLOR:
@@ -1469,6 +1399,8 @@ _mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params)
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    texObj = get_texobj(ctx, target, GL_TRUE);
+   if (!texObj)
+      return;
    
    switch (pname) {
    case GL_TEXTURE_BORDER_COLOR:
index 6da3e4e..c4aeaa8 100644 (file)
@@ -1002,15 +1002,17 @@ memcpy_texture(struct gl_context *ctx,
 
 
 /**
- * Store a 32-bit integer depth component texture image.
+ * Store a 32-bit integer or float depth component texture image.
  */
 static GLboolean
 _mesa_texstore_z32(TEXSTORE_PARAMS)
 {
    const GLuint depthScale = 0xffffffff;
    const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+   const GLenum dstType = _mesa_get_format_datatype(dstFormat);
    (void) dims;
-   ASSERT(dstFormat == MESA_FORMAT_Z32);
+   ASSERT(dstFormat == MESA_FORMAT_Z32 ||
+          dstFormat == MESA_FORMAT_Z32_FLOAT);
    ASSERT(texelBytes == sizeof(GLuint));
 
    if (ctx->Pixel.DepthScale == 1.0f &&
@@ -1018,7 +1020,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
        !srcPacking->SwapBytes &&
        baseInternalFormat == GL_DEPTH_COMPONENT &&
        srcFormat == GL_DEPTH_COMPONENT &&
-       srcType == GL_UNSIGNED_INT) {
+       srcType == dstType) {
       /* simple memcpy path */
       memcpy_texture(ctx, dims,
                      dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
@@ -1039,7 +1041,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
             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,
+                                    dstType, dstRow,
                                     depthScale, srcType, src, srcPacking);
             dstRow += dstRowStride;
          }
@@ -3303,15 +3305,16 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
 {
    const GLuint depthScale = 0xffffff;
    const GLint srcRowStride
-      = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
-      / sizeof(GLuint);
+      = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
    GLint img, row;
 
    ASSERT(dstFormat == MESA_FORMAT_Z24_S8);
-   ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT);
+   ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT ||
+          srcFormat == GL_DEPTH_COMPONENT ||
+          srcFormat == GL_STENCIL_INDEX);
    ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT);
 
-   if (srcFormat != GL_DEPTH_COMPONENT && ctx->Pixel.DepthScale == 1.0f &&
+   if (srcFormat == GL_DEPTH_STENCIL && ctx->Pixel.DepthScale == 1.0f &&
        ctx->Pixel.DepthBias == 0.0f &&
        !srcPacking->SwapBytes) {
       /* simple path */
@@ -3322,15 +3325,16 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
                      srcWidth, srcHeight, srcDepth, srcFormat, srcType,
                      srcAddr, srcPacking);
    }
-   else if (srcFormat == GL_DEPTH_COMPONENT) {
+   else if (srcFormat == GL_DEPTH_COMPONENT ||
+            srcFormat == GL_STENCIL_INDEX) {
       /* In case we only upload depth we need to preserve the stencil */
       for (img = 0; img < srcDepth; img++) {
         GLuint *dstRow = (GLuint *) dstAddr
             + dstImageOffsets[dstZoffset + img]
             + dstYoffset * dstRowStride / sizeof(GLuint)
             + dstXoffset;
-         const GLuint *src
-            = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
+         const GLubyte *src
+            = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
                   srcWidth, srcHeight,
                   srcFormat, srcType,
                   img, 0, 0);
@@ -3387,8 +3391,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
 {
    const GLuint depthScale = 0xffffff;
    const GLint srcRowStride
-      = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
-      / sizeof(GLuint);
+      = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
    GLint img, row;
 
    ASSERT(dstFormat == MESA_FORMAT_S8_Z24);
@@ -3403,8 +3406,8 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
         + dstImageOffsets[dstZoffset + img]
         + dstYoffset * dstRowStride / sizeof(GLuint)
         + dstXoffset;
-      const GLuint *src
-        = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
+      const GLubyte *src
+        = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
                                                srcWidth, srcHeight,
                                                srcFormat, srcType,
                                                img, 0, 0);
@@ -3476,8 +3479,7 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
    }
    else {
       const GLint srcRowStride
-        = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
-        / sizeof(GLuint);
+        = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
       GLint img, row;
       
       for (img = 0; img < srcDepth; img++) {
@@ -3485,8 +3487,8 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
             + dstImageOffsets[dstZoffset + img]
             + dstYoffset * dstRowStride / sizeof(GLuint)
             + dstXoffset;
-         const GLuint *src
-            = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
+         const GLubyte *src
+            = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
                                                    srcWidth, srcHeight,
                                                    srcFormat, srcType,
                                                    img, 0, 0);
@@ -4285,6 +4287,72 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS)
 }
 
 
+static GLboolean
+_mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
+{
+   ASSERT(dstFormat == MESA_FORMAT_Z32_FLOAT_X24S8);
+   ASSERT(srcFormat == GL_DEPTH_STENCIL ||
+          srcFormat == GL_DEPTH_COMPONENT ||
+          srcFormat == GL_STENCIL_INDEX);
+   ASSERT(srcFormat != GL_DEPTH_STENCIL ||
+          srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+
+   if (srcFormat == GL_DEPTH_STENCIL &&
+       ctx->Pixel.DepthScale == 1.0f &&
+       ctx->Pixel.DepthBias == 0.0f &&
+       !srcPacking->SwapBytes) {
+      /* simple path */
+      memcpy_texture(ctx, dims,
+                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+                     dstRowStride,
+                     dstImageOffsets,
+                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+                     srcAddr, srcPacking);
+   }
+   else if (srcFormat == GL_DEPTH_COMPONENT ||
+            srcFormat == GL_STENCIL_INDEX) {
+      GLint img, row;
+      const GLint srcRowStride
+         = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
+         / sizeof(uint64_t);
+
+      /* In case we only upload depth we need to preserve the stencil */
+      for (img = 0; img < srcDepth; img++) {
+         uint64_t *dstRow = (uint64_t *) dstAddr
+            + dstImageOffsets[dstZoffset + img]
+            + dstYoffset * dstRowStride / sizeof(uint64_t)
+            + dstXoffset;
+         const uint64_t *src
+            = (const uint64_t *) _mesa_image_address(dims, srcPacking, srcAddr,
+                  srcWidth, srcHeight,
+                  srcFormat, srcType,
+                  img, 0, 0);
+         for (row = 0; row < srcHeight; row++) {
+            /* The unpack functions with:
+             *    dstType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV
+             * only write their own dword, so the other dword (stencil
+             * or depth) is preserved. */
+            if (srcFormat != GL_STENCIL_INDEX)
+               _mesa_unpack_depth_span(ctx, srcWidth,
+                                       GL_FLOAT_32_UNSIGNED_INT_24_8_REV, /* dst type */
+                                       dstRow, /* dst addr */
+                                       1.0f, srcType, src, srcPacking);
+
+            if (srcFormat != GL_DEPTH_COMPONENT)
+               _mesa_unpack_stencil_span(ctx, srcWidth,
+                                         GL_FLOAT_32_UNSIGNED_INT_24_8_REV, /* dst type */
+                                         dstRow, /* dst addr */
+                                         srcType, src, srcPacking,
+                                         ctx->_ImageTransferState);
+
+            src += srcRowStride;
+            dstRow += dstRowStride / sizeof(uint64_t);
+         }
+      }
+   }
+   return GL_TRUE;
+}
+
 
 /**
  * Table mapping MESA_FORMAT_* to _mesa_texstore_*()
@@ -4419,6 +4487,9 @@ texstore_funcs[MESA_FORMAT_COUNT] =
 
    { MESA_FORMAT_RGB9_E5_FLOAT, _mesa_texstore_rgb9_e5 },
    { MESA_FORMAT_R11_G11_B10_FLOAT, _mesa_texstore_r11_g11_b10f },
+
+   { MESA_FORMAT_Z32_FLOAT, _mesa_texstore_z32 },
+   { MESA_FORMAT_Z32_FLOAT_X24S8, _mesa_texstore_z32f_x24s8 },
 };
 
 
@@ -4506,8 +4577,7 @@ texture_row_stride(const struct gl_texture_image *texImage)
 
 
 /**
- * This is the software fallback for Driver.TexImage1D()
- * and Driver.CopyTexImage1D().
+ * This is the software fallback for Driver.TexImage1D().
  * \sa _mesa_store_teximage2d()
  */
 void
@@ -4558,8 +4628,7 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
 
 
 /**
- * This is the software fallback for Driver.TexImage2D()
- * and Driver.CopyTexImage2D().
+ * This is the software fallback for Driver.TexImage2D().
  *
  * This function is oriented toward storing images in main memory, rather
  * than VRAM.  Device driver's can easily plug in their own replacement.
@@ -4613,8 +4682,7 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
 
 
 /**
- * This is the software fallback for Driver.TexImage3D()
- * and Driver.CopyTexImage3D().
+ * This is the software fallback for Driver.TexImage3D().
  * \sa _mesa_store_teximage2d()
  */
 void
index ce4863f..1329af4 100644 (file)
@@ -582,7 +582,7 @@ _mesa_update_shader_textures_used(struct gl_program *prog)
       if (prog->SamplersUsed & (1 << s)) {
          GLuint unit = prog->SamplerUnits[s];
          GLuint tgt = prog->SamplerTargets[s];
-         assert(unit < MAX_TEXTURE_IMAGE_UNITS);
+         assert(unit < Elements(prog->TexturesUsed));
          assert(tgt < NUM_TEXTURE_TARGETS);
          prog->TexturesUsed[unit] |= (1 << tgt);
       }
@@ -676,7 +676,7 @@ set_program_uniform(struct gl_context *ctx, struct gl_program *program,
          GLuint texUnit = ((GLuint *) values)[i];
 
          /* check that the sampler (tex unit index) is legal */
-         if (texUnit >= ctx->Const.MaxTextureImageUnits) {
+         if (texUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
             _mesa_error(ctx, GL_INVALID_VALUE,
                         "glUniform1(invalid sampler/tex unit index for '%s')",
                         param->Name);
index 2e63358..0a0512c 100644 (file)
@@ -33,9 +33,9 @@ struct gl_context;
 
 /* Mesa version */
 #define MESA_MAJOR 7
-#define MESA_MINOR 11
+#define MESA_MINOR 12
 #define MESA_PATCH 0
-#define MESA_VERSION_STRING "7.11-devel"
+#define MESA_VERSION_STRING "7.12-devel"
 
 /* To make version comparison easy */
 #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
index f274927..debadb9 100644 (file)
@@ -134,7 +134,7 @@ src_reg::src_reg(dst_reg reg)
    this->index = reg.index;
    this->swizzle = SWIZZLE_XYZW;
    this->negate = 0;
-   this->reladdr = NULL;
+   this->reladdr = reg.reladdr;
 }
 
 dst_reg::dst_reg(src_reg reg)
@@ -331,20 +331,6 @@ dst_reg undef_dst = dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP);
 
 dst_reg address_reg = dst_reg(PROGRAM_ADDRESS, WRITEMASK_X);
 
-static void
-fail_link(struct gl_shader_program *prog, const char *fmt, ...) PRINTFLIKE(2, 3);
-
-static void
-fail_link(struct gl_shader_program *prog, const char *fmt, ...)
-{
-   va_list args;
-   va_start(args, fmt);
-   ralloc_vasprintf_append(&prog->InfoLog, fmt, args);
-   va_end(args);
-
-   prog->LinkStatus = GL_FALSE;
-}
-
 static int
 swizzle_for_size(int size)
 {
@@ -789,10 +775,11 @@ ir_to_mesa_visitor::visit(ir_variable *ir)
 
       if (storage->file == PROGRAM_TEMPORARY &&
          dst.index != storage->index + (int) ir->num_state_slots) {
-        fail_link(this->shader_program,
-                  "failed to load builtin uniform `%s'  (%d/%d regs loaded)\n",
-                  ir->name, dst.index - storage->index,
-                  type_size(ir->type));
+        linker_error(this->shader_program,
+                     "failed to load builtin uniform `%s' "
+                     "(%d/%d regs loaded)\n",
+                     ir->name, dst.index - storage->index,
+                     type_size(ir->type));
       }
    }
 }
@@ -803,48 +790,44 @@ ir_to_mesa_visitor::visit(ir_loop *ir)
    ir_dereference_variable *counter = NULL;
 
    if (ir->counter != NULL)
-      counter = new(ir) ir_dereference_variable(ir->counter);
+      counter = new(mem_ctx) ir_dereference_variable(ir->counter);
 
    if (ir->from != NULL) {
       assert(ir->counter != NULL);
 
-      ir_assignment *a = new(ir) ir_assignment(counter, ir->from, NULL);
+      ir_assignment *a =
+       new(mem_ctx) ir_assignment(counter, ir->from, NULL);
 
       a->accept(this);
-      delete a;
    }
 
    emit(NULL, OPCODE_BGNLOOP);
 
    if (ir->to) {
       ir_expression *e =
-        new(ir) ir_expression(ir->cmp, glsl_type::bool_type,
-                              counter, ir->to);
-      ir_if *if_stmt =  new(ir) ir_if(e);
+        new(mem_ctx) ir_expression(ir->cmp, glsl_type::bool_type,
+                                         counter, ir->to);
+      ir_if *if_stmt =  new(mem_ctx) ir_if(e);
 
-      ir_loop_jump *brk = new(ir) ir_loop_jump(ir_loop_jump::jump_break);
+      ir_loop_jump *brk =
+       new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_break);
 
       if_stmt->then_instructions.push_tail(brk);
 
       if_stmt->accept(this);
-
-      delete if_stmt;
-      delete e;
-      delete brk;
    }
 
    visit_exec_list(&ir->body_instructions, this);
 
    if (ir->increment) {
       ir_expression *e =
-        new(ir) ir_expression(ir_binop_add, counter->type,
-                              counter, ir->increment);
+        new(mem_ctx) ir_expression(ir_binop_add, counter->type,
+                                         counter, ir->increment);
 
-      ir_assignment *a = new(ir) ir_assignment(counter, e, NULL);
+      ir_assignment *a =
+       new(mem_ctx) ir_assignment(counter, e, NULL);
 
       a->accept(this);
-      delete a;
-      delete e;
    }
 
    emit(NULL, OPCODE_ENDLOOP);
@@ -1296,8 +1279,11 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       emit_scalar(ir, OPCODE_RSQ, result_dst, op[0]);
       break;
    case ir_unop_i2f:
+   case ir_unop_u2f:
    case ir_unop_b2f:
    case ir_unop_b2i:
+   case ir_unop_i2u:
+   case ir_unop_u2i:
       /* Mesa IR lacks types, ints are stored as truncated floats. */
       result_src = op[0];
       break;
@@ -1335,7 +1321,6 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       break;
 
    case ir_unop_bit_not:
-   case ir_unop_u2f:
    case ir_binop_lshift:
    case ir_binop_rshift:
    case ir_binop_bit_and:
@@ -1417,9 +1402,9 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
       case ir_var_in:
       case ir_var_inout:
         /* The linker assigns locations for varyings and attributes,
-         * including deprecated builtins (like gl_Color), user-assign
-         * generic attributes (glBindVertexLocation), and
-         * user-defined varyings.
+         * including deprecated builtins (like gl_Color),
+         * user-assigned generic attributes (glBindVertexLocation),
+         * and user-defined varyings.
          *
          * FINISHME: We would hit this path for function arguments.  Fix!
          */
@@ -1498,6 +1483,18 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir)
              this->result, src_reg_for_float(element_size));
       }
 
+      /* If there was already a relative address register involved, add the
+       * new and the old together to get the new offset.
+       */
+      if (src.reladdr != NULL)  {
+        src_reg accum_reg = get_temp(glsl_type::float_type);
+
+        emit(ir, OPCODE_ADD, dst_reg(accum_reg),
+             index_reg, *src.reladdr);
+
+        index_reg = accum_reg;
+      }
+
       src.reladdr = ralloc(mem_ctx, src_reg);
       memcpy(src.reladdr, &index_reg, sizeof(index_reg));
    }
@@ -2403,29 +2400,32 @@ check_resources(const struct gl_context *ctx,
    case GL_VERTEX_PROGRAM_ARB:
       if (_mesa_bitcount(prog->SamplersUsed) >
           ctx->Const.MaxVertexTextureImageUnits) {
-         fail_link(shader_program, "Too many vertex shader texture samplers");
+         linker_error(shader_program,
+                     "Too many vertex shader texture samplers");
       }
       if (prog->Parameters->NumParameters > MAX_UNIFORMS) {
-         fail_link(shader_program, "Too many vertex shader constants");
+         linker_error(shader_program, "Too many vertex shader constants");
       }
       break;
    case MESA_GEOMETRY_PROGRAM:
       if (_mesa_bitcount(prog->SamplersUsed) >
           ctx->Const.MaxGeometryTextureImageUnits) {
-         fail_link(shader_program, "Too many geometry shader texture samplers");
+         linker_error(shader_program,
+                     "Too many geometry shader texture samplers");
       }
       if (prog->Parameters->NumParameters >
           MAX_GEOMETRY_UNIFORM_COMPONENTS / 4) {
-         fail_link(shader_program, "Too many geometry shader constants");
+         linker_error(shader_program, "Too many geometry shader constants");
       }
       break;
    case GL_FRAGMENT_PROGRAM_ARB:
       if (_mesa_bitcount(prog->SamplersUsed) >
           ctx->Const.MaxTextureImageUnits) {
-         fail_link(shader_program, "Too many fragment shader texture samplers");
+         linker_error(shader_program,
+                     "Too many fragment shader texture samplers");
       }
       if (prog->Parameters->NumParameters > MAX_UNIFORMS) {
-         fail_link(shader_program, "Too many fragment shader constants");
+         linker_error(shader_program, "Too many fragment shader constants");
       }
       break;
    default:
@@ -2540,9 +2540,10 @@ add_uniforms_to_parameters_list(struct gl_shader_program *shader_program,
          * from _mesa_add_uniform) has to match what the linker chose.
          */
         if (index != parameter_index) {
-           fail_link(shader_program, "Allocation of uniform `%s' to target "
-                     "failed (%d vs %d)\n",
-                     uniform->Name, index, parameter_index);
+           linker_error(shader_program,
+                        "Allocation of uniform `%s' to target failed "
+                        "(%d vs %d)\n",
+                        uniform->Name, index, parameter_index);
         }
       }
    }
@@ -2575,8 +2576,8 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
    int loc = _mesa_get_uniform_location(ctx, shader_program, name);
 
    if (loc == -1) {
-      fail_link(shader_program,
-               "Couldn't find uniform for initializer %s\n", name);
+      linker_error(shader_program,
+                  "Couldn't find uniform for initializer %s\n", name);
       return;
    }
 
@@ -2976,11 +2977,31 @@ get_mesa_program(struct gl_context *ctx,
          if (mesa_inst->SrcReg[src].RelAddr)
             prog->IndirectRegisterFiles |= 1 << mesa_inst->SrcReg[src].File;
 
-      if (options->EmitNoIfs && mesa_inst->Opcode == OPCODE_IF) {
-        fail_link(shader_program, "Couldn't flatten if statement\n");
-      }
-
       switch (mesa_inst->Opcode) {
+      case OPCODE_IF:
+        if (options->EmitNoIfs) {
+           linker_warning(shader_program,
+                          "Couldn't flatten if-statement.  "
+                          "This will likely result in software "
+                          "rasterization.\n");
+        }
+        break;
+      case OPCODE_BGNLOOP:
+        if (options->EmitNoLoops) {
+           linker_warning(shader_program,
+                          "Couldn't unroll loop.  "
+                          "This will likely result in software "
+                          "rasterization.\n");
+        }
+        break;
+      case OPCODE_CONT:
+        if (options->EmitNoCont) {
+           linker_warning(shader_program,
+                          "Couldn't lower continue-statement.  "
+                          "This will likely result in software "
+                          "rasterization.\n");
+        }
+        break;
       case OPCODE_BGNSUB:
         inst->function->inst = i;
         mesa_inst->Comment = strdup(inst->function->sig->function_name());
@@ -3248,7 +3269,7 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 
    for (i = 0; i < prog->NumShaders; i++) {
       if (!prog->Shaders[i]->CompileStatus) {
-        fail_link(prog, "linking with uncompiled shader");
+        linker_error(prog, "linking with uncompiled shader");
         prog->LinkStatus = GL_FALSE;
       }
    }
index 11debc4..f4a7a63 100644 (file)
@@ -1304,6 +1304,9 @@ _mesa_simplify_cmp(struct gl_program * program)
          assert(inst->DstReg.Index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
          prevWriteMask = tempWrites[inst->DstReg.Index];
          tempWrites[inst->DstReg.Index] |= inst->DstReg.WriteMask;
+      } else {
+         /* No other register type can be a destination register. */
+         continue;
       }
 
       /* For a CMP to be considered a conditional write, the destination
@@ -1316,6 +1319,15 @@ _mesa_simplify_cmp(struct gl_program * program)
 
          inst->Opcode = OPCODE_MOV;
          inst->SrcReg[0] = inst->SrcReg[1];
+
+        /* Unused operands are expected to have the file set to
+         * PROGRAM_UNDEFINED.  This is how _mesa_init_instructions initializes
+         * all of the sources.
+         */
+        inst->SrcReg[1].File = PROGRAM_UNDEFINED;
+        inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
+        inst->SrcReg[2].File = PROGRAM_UNDEFINED;
+        inst->SrcReg[2].Swizzle = SWIZZLE_NOOP;
       }
    }
    if (dbg) {
index 4f2b627..ecff234 100644 (file)
@@ -422,12 +422,15 @@ _mesa_lookup_program(struct gl_context *ctx, GLuint id)
 
 /**
  * Reference counting for vertex/fragment programs
+ * This is normally only called from the _mesa_reference_program() macro
+ * when there's a real pointer change.
  */
 void
-_mesa_reference_program(struct gl_context *ctx,
-                        struct gl_program **ptr,
-                        struct gl_program *prog)
+_mesa_reference_program_(struct gl_context *ctx,
+                         struct gl_program **ptr,
+                         struct gl_program *prog)
 {
+#ifndef NDEBUG
    assert(ptr);
    if (*ptr && prog) {
       /* sanity check */
@@ -439,9 +442,8 @@ _mesa_reference_program(struct gl_context *ctx,
       else if ((*ptr)->Target == MESA_GEOMETRY_PROGRAM)
          ASSERT(prog->Target == MESA_GEOMETRY_PROGRAM);
    }
-   if (*ptr == prog) {
-      return;  /* no change */
-   }
+#endif
+
    if (*ptr) {
       GLboolean deleteFlag;
 
index ce37b95..0f32a6a 100644 (file)
@@ -89,9 +89,18 @@ extern struct gl_program *
 _mesa_lookup_program(struct gl_context *ctx, GLuint id);
 
 extern void
+_mesa_reference_program_(struct gl_context *ctx,
+                         struct gl_program **ptr,
+                         struct gl_program *prog);
+
+static INLINE void
 _mesa_reference_program(struct gl_context *ctx,
                         struct gl_program **ptr,
-                        struct gl_program *prog);
+                        struct gl_program *prog)
+{
+   if (*ptr != prog)
+      _mesa_reference_program_(ctx, ptr, prog);
+}
 
 static INLINE void
 _mesa_reference_vertprog(struct gl_context *ctx,
index 800a9f1..3115a25 100644 (file)
@@ -221,9 +221,9 @@ update_single_texture(struct st_context *st, struct pipe_sampler_view **sampler_
 
       if ((samp->sRGBDecode == GL_SKIP_DECODE_EXT) &&
          (_mesa_get_format_color_encoding(texFormat) == GL_SRGB)) {
-        /* don't do sRGB->RGB conversion.  Interpret the texture
-         * texture data as linear values.
-         */
+         /* Don't do sRGB->RGB conversion.  Interpret the texture data as
+          * linear values.
+          */
         const gl_format linearFormat =
            _mesa_get_srgb_format_linear(texFormat);
         firstImageFormat = st_mesa_format_to_pipe_format(linearFormat);
index f0750b5..beb5e7c 100644 (file)
@@ -351,8 +351,8 @@ setup_bitmap_vertex_data(struct st_context *st, bool normalized,
 
    if(!normalized)
    {
-      sRight = width;
-      tBot = height;
+      sRight = (GLfloat) width;
+      tBot = (GLfloat) height;
    }
 
    /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
@@ -404,7 +404,7 @@ setup_bitmap_vertex_data(struct st_context *st, bool normalized,
    /* same for all verts: */
    for (i = 0; i < 4; i++) {
       st->bitmap.vertices[i][0][2] = z;
-      st->bitmap.vertices[i][0][3] = 1.0;
+      st->bitmap.vertices[i][0][3] = 1.0f;
       st->bitmap.vertices[i][1][0] = color[0];
       st->bitmap.vertices[i][1][1] = color[1];
       st->bitmap.vertices[i][1][2] = color[2];
@@ -536,7 +536,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
    cso_set_vertex_elements(cso, 3, st->velems_util_draw);
 
    /* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */
-   z = z * 2.0 - 1.0;
+   z = z * 2.0f - 1.0f;
 
    /* draw textured quad */
    offset = setup_bitmap_vertex_data(st,
index 416be19..626db12 100644 (file)
@@ -62,6 +62,82 @@ st_destroy_blit(struct st_context *st)
 #if FEATURE_EXT_framebuffer_blit
 
 static void
+st_BlitFramebuffer_resolve(struct gl_context *ctx,
+                           GLbitfield mask,
+                           struct pipe_resolve_info *info)
+{
+   const GLbitfield depthStencil = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
+
+   struct st_context *st = st_context(ctx);
+
+   struct st_renderbuffer *srcRb, *dstRb;
+
+   if (mask & GL_COLOR_BUFFER_BIT) {
+      srcRb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
+      dstRb = st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
+
+      info->mask = PIPE_MASK_RGBA;
+
+      info->src.res = srcRb->texture;
+      info->src.layer = srcRb->surface->u.tex.first_layer;
+      info->dst.res = dstRb->texture;
+      info->dst.level = dstRb->surface->u.tex.level;
+      info->dst.layer = dstRb->surface->u.tex.first_layer;
+
+      st->pipe->resource_resolve(st->pipe, info);
+   }
+
+   if (mask & depthStencil) {
+      struct gl_renderbuffer_attachment *srcDepth, *srcStencil;
+      struct gl_renderbuffer_attachment *dstDepth, *dstStencil;
+      boolean combined;
+
+      srcDepth = &ctx->ReadBuffer->Attachment[BUFFER_DEPTH];
+      dstDepth = &ctx->DrawBuffer->Attachment[BUFFER_DEPTH];
+      srcStencil = &ctx->ReadBuffer->Attachment[BUFFER_STENCIL];
+      dstStencil = &ctx->DrawBuffer->Attachment[BUFFER_STENCIL];
+
+      combined =
+         st_is_depth_stencil_combined(srcDepth, srcStencil) &&
+         st_is_depth_stencil_combined(dstDepth, dstStencil);
+
+      if ((mask & GL_DEPTH_BUFFER_BIT) || combined) {
+         /* resolve depth and, if combined and requested, stencil as well */
+         srcRb = st_renderbuffer(srcDepth->Renderbuffer);
+         dstRb = st_renderbuffer(dstDepth->Renderbuffer);
+
+         info->mask = (mask & GL_DEPTH_BUFFER_BIT) ? PIPE_MASK_Z : 0;
+         if (combined && (mask & GL_STENCIL_BUFFER_BIT))
+            info->mask |= PIPE_MASK_S;
+
+         info->src.res = srcRb->texture;
+         info->src.layer = srcRb->surface->u.tex.first_layer;
+         info->dst.res = dstRb->texture;
+         info->dst.level = dstRb->surface->u.tex.level;
+         info->dst.layer = dstRb->surface->u.tex.first_layer;
+
+         st->pipe->resource_resolve(st->pipe, info);
+      }
+
+      if (mask & GL_STENCIL_BUFFER_BIT) {
+         /* resolve separate stencil buffer */
+         srcRb = st_renderbuffer(srcStencil->Renderbuffer);
+         dstRb = st_renderbuffer(dstStencil->Renderbuffer);
+
+         info->mask = PIPE_MASK_S;
+
+         info->src.res = srcRb->texture;
+         info->src.layer = srcRb->surface->u.tex.first_layer;
+         info->dst.res = dstRb->texture;
+         info->dst.level = dstRb->surface->u.tex.level;
+         info->dst.layer = dstRb->surface->u.tex.first_layer;
+
+         st->pipe->resource_resolve(st->pipe, info);
+      }
+   }
+}
+
+static void
 st_BlitFramebuffer(struct gl_context *ctx,
                    GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
                    GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
@@ -95,6 +171,42 @@ st_BlitFramebuffer(struct gl_context *ctx,
       srcY1 = readFB->Height - srcY1;
    }
 
+   /* Disable conditional rendering. */
+   if (st->render_condition) {
+      st->pipe->render_condition(st->pipe, NULL, 0);
+   }
+
+   if (readFB->Visual.sampleBuffers > drawFB->Visual.sampleBuffers) {
+      struct pipe_resolve_info info;
+
+      if (dstX0 < dstX1) {
+         info.dst.x0 = dstX0;
+         info.dst.x1 = dstX1;
+         info.src.x0 = srcX0;
+         info.src.x1 = srcX1;
+      } else {
+         info.dst.x0 = dstX1;
+         info.dst.x1 = dstX0;
+         info.src.x0 = srcX1;
+         info.src.x1 = srcX0;
+      }
+      if (dstY0 < dstY1) {
+         info.dst.y0 = dstY0;
+         info.dst.y1 = dstY1;
+         info.src.y0 = srcY0;
+         info.src.y1 = srcY1;
+      } else {
+         info.dst.y0 = dstY1;
+         info.dst.y1 = dstY0;
+         info.src.y0 = srcY1;
+         info.src.y1 = srcY0;
+      }
+
+      st_BlitFramebuffer_resolve(ctx, mask, &info); /* filter doesn't apply */
+
+      goto done;
+   }
+
    if (srcY0 > srcY1 && dstY0 > dstY1) {
       /* Both src and dst are upside down.  Swap Y to make it
        * right-side up to increase odds of using a fast path.
@@ -109,11 +221,6 @@ st_BlitFramebuffer(struct gl_context *ctx,
       dstY1 = tmp;
    }
 
-   /* Disable conditional rendering. */
-   if (st->render_condition) {
-      st->pipe->render_condition(st->pipe, NULL, 0);
-   }
-
    if (mask & GL_COLOR_BUFFER_BIT) {
       struct gl_renderbuffer_attachment *srcAtt =
          &readFB->Attachment[readFB->_ColorReadBufferIndex];
index 181fedd..117000b 100644 (file)
@@ -381,7 +381,8 @@ check_clear_depth_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuff
 
    assert(rb->Format == MESA_FORMAT_S8 ||
           rb->Format == MESA_FORMAT_Z24_S8 ||
-          rb->Format == MESA_FORMAT_S8_Z24);
+          rb->Format == MESA_FORMAT_S8_Z24 ||
+          rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
 
    if (ctx->Scissor.Enabled &&
        (ctx->Scissor.X != 0 ||
@@ -436,7 +437,8 @@ check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb
 
    assert(rb->Format == MESA_FORMAT_S8 ||
           rb->Format == MESA_FORMAT_Z24_S8 ||
-          rb->Format == MESA_FORMAT_S8_Z24);
+          rb->Format == MESA_FORMAT_S8_Z24 ||
+          rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
 
    if (maskStencil) 
       return GL_TRUE;
index 64c6c11..1ced560 100644 (file)
@@ -41,6 +41,7 @@
 #include "st_context.h"
 #include "st_cb_queryobj.h"
 #include "st_cb_condrender.h"
+#include "st_cb_bitmap.h"
 
 
 /**
@@ -55,6 +56,8 @@ st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
    struct pipe_context *pipe = st->pipe;
    uint m;
 
+   st_flush_bitmap_cache(st);
+
    switch (mode) {
    case GL_QUERY_WAIT:
       m = PIPE_RENDER_COND_WAIT;
@@ -90,6 +93,8 @@ st_EndConditionalRender(struct gl_context *ctx, struct gl_query_object *q)
    struct pipe_context *pipe = st->pipe;
    (void) q;
 
+   st_flush_bitmap_cache(st);
+
    pipe->render_condition(pipe, NULL, 0);
    st->render_condition = NULL;
 }
index 0c4dc23..390c518 100644 (file)
@@ -317,26 +317,6 @@ make_passthrough_vertex_shader(struct st_context *st,
 
 
 /**
- * Return a texture base format for drawing/copying an image
- * of the given format.
- */
-static GLenum
-base_format(GLenum format)
-{
-   switch (format) {
-   case GL_DEPTH_COMPONENT:
-      return GL_DEPTH_COMPONENT;
-   case GL_DEPTH_STENCIL:
-      return GL_DEPTH_STENCIL;
-   case GL_STENCIL_INDEX:
-      return GL_STENCIL_INDEX;
-   default:
-      return GL_RGBA;
-   }
-}
-
-
-/**
  * Return a texture internalFormat for drawing/copying an image
  * of the given format and type.
  */
@@ -345,11 +325,36 @@ internal_format(struct gl_context *ctx, GLenum format, GLenum type)
 {
    switch (format) {
    case GL_DEPTH_COMPONENT:
-      return GL_DEPTH_COMPONENT;
+      switch (type) {
+      case GL_UNSIGNED_SHORT:
+         return GL_DEPTH_COMPONENT16;
+
+      case GL_UNSIGNED_INT:
+         return GL_DEPTH_COMPONENT32;
+
+      case GL_FLOAT:
+         if (ctx->Extensions.ARB_depth_buffer_float)
+            return GL_DEPTH_COMPONENT32F;
+         else
+            return GL_DEPTH_COMPONENT;
+
+      default:
+         return GL_DEPTH_COMPONENT;
+      }
+
    case GL_DEPTH_STENCIL:
-      return GL_DEPTH_STENCIL;
+      switch (type) {
+      case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+         return GL_DEPTH32F_STENCIL8;
+
+      case GL_UNSIGNED_INT_24_8:
+      default:
+         return GL_DEPTH24_STENCIL8;
+      }
+
    case GL_STENCIL_INDEX:
       return GL_STENCIL_INDEX;
+
    default:
       if (_mesa_is_integer_format(format)) {
          switch (type) {
@@ -856,6 +861,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
       for (row = 0; row < height; row++) {
          GLubyte sValues[MAX_WIDTH];
          GLuint zValues[MAX_WIDTH];
+         GLfloat *zValuesFloat = (GLfloat*)zValues;
          GLenum destType = GL_UNSIGNED_BYTE;
          const GLvoid *source = _mesa_image_address2d(&clippedUnpack, pixels,
                                                       width, height,
@@ -866,7 +872,11 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
                                    ctx->_ImageTransferState);
 
          if (format == GL_DEPTH_STENCIL) {
-            _mesa_unpack_depth_span(ctx, spanWidth, GL_UNSIGNED_INT, zValues,
+            GLenum ztype =
+               pt->resource->format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED ?
+               GL_FLOAT : GL_UNSIGNED_INT;
+
+            _mesa_unpack_depth_span(ctx, spanWidth, ztype, zValues,
                                     (1 << 24) - 1, type, source,
                                     &clippedUnpack);
          }
@@ -931,6 +941,26 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
                   }
                }
                break;
+            case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+               if (format == GL_DEPTH_STENCIL) {
+                  uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
+                  GLfloat *destf = (GLfloat*)dest;
+                  GLint k;
+                  assert(usage == PIPE_TRANSFER_WRITE);
+                  for (k = 0; k < spanWidth; k++) {
+                     destf[k*2] = zValuesFloat[k];
+                     dest[k*2+1] = sValues[k] & 0xff;
+                  }
+               }
+               else {
+                  uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
+                  GLint k;
+                  assert(usage == PIPE_TRANSFER_READ_WRITE);
+                  for (k = 0; k < spanWidth; k++) {
+                     dest[k*2+1] = sValues[k] & 0xff;
+                  }
+               }
+               break;
             default:
                assert(0);
             }
@@ -1018,7 +1048,6 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
    GLboolean write_stencil = GL_FALSE, write_depth = GL_FALSE;
    struct pipe_sampler_view *sv[2];
    int num_sampler_view = 1;
-   enum pipe_format stencil_format = PIPE_FORMAT_NONE;
    struct st_fp_variant *fpv;
 
    if (format == GL_DEPTH_STENCIL)
@@ -1028,23 +1057,12 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
    else if (format == GL_DEPTH_COMPONENT)
       write_depth = GL_TRUE;
 
-   if (write_stencil) {
-      enum pipe_format tex_format;
-      /* can we write to stencil if not fallback */
-      if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_SHADER_STENCIL_EXPORT))
-        goto stencil_fallback;
-      
-      tex_format = st_choose_format(st->pipe->screen, base_format(format),
-                                    PIPE_TEXTURE_2D,
-                                   0, PIPE_BIND_SAMPLER_VIEW);
-      if (tex_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
-        stencil_format = PIPE_FORMAT_X24S8_USCALED;
-      else if (tex_format == PIPE_FORMAT_S8_USCALED_Z24_UNORM)
-        stencil_format = PIPE_FORMAT_S8X24_USCALED;
-      else
-        stencil_format = PIPE_FORMAT_S8_USCALED;
-      if (stencil_format == PIPE_FORMAT_NONE)
-        goto stencil_fallback;
+   if (write_stencil &&
+       !pipe->screen->get_param(pipe->screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
+      /* software fallback */
+      draw_stencil_pixels(ctx, x, y, width, height, format, type,
+                          unpack, pixels);
+      return;
    }
 
    /* Mesa state should be up to date by now */
@@ -1089,7 +1107,32 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
          sv[0] = st_create_texture_sampler_view(st->pipe, pt);
 
          if (sv[0]) {
-           if (write_stencil) {
+            /* Create a second sampler view to read stencil.
+             * The stencil is written using the shader stencil export
+             * functionality. */
+            if (write_stencil) {
+               enum pipe_format stencil_format = PIPE_FORMAT_NONE;
+
+               switch (pt->format) {
+               case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               case PIPE_FORMAT_X24S8_USCALED:
+                  stencil_format = PIPE_FORMAT_X24S8_USCALED;
+                  break;
+               case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+               case PIPE_FORMAT_S8X24_USCALED:
+                  stencil_format = PIPE_FORMAT_S8X24_USCALED;
+                  break;
+               case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+               case PIPE_FORMAT_X32_S8X24_USCALED:
+                  stencil_format = PIPE_FORMAT_X32_S8X24_USCALED;
+                  break;
+               case PIPE_FORMAT_S8_USCALED:
+                  stencil_format = PIPE_FORMAT_S8_USCALED;
+                  break;
+               default:
+                  assert(0);
+               }
+
               sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
                                                              stencil_format);
               num_sampler_view++;
@@ -1110,11 +1153,6 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
          pipe_resource_reference(&pt, NULL);
       }
    }
-   return;
-
-stencil_fallback:
-   draw_stencil_pixels(ctx, x, y, width, height, format, type,
-                      unpack, pixels);
 }
 
 
@@ -1231,6 +1269,18 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
          assert(usage == PIPE_TRANSFER_WRITE);
          memcpy(dst, src, width);
          break;
+      case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+         {
+            uint *dst4 = (uint *) dst;
+            int j;
+            dst4++;
+            assert(usage == PIPE_TRANSFER_READ_WRITE);
+            for (j = 0; j < width; j++) {
+               *dst4 = src[j] & 0xff;
+               dst4 += 2;
+            }
+         }
+         break;
       default:
          assert(0);
       }
@@ -1443,13 +1493,14 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
       /* srcFormat can't be used as a texture format */
       if (type == GL_DEPTH) {
          texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT,
-                                      st->internal_target, sample_count,
-                                      PIPE_BIND_DEPTH_STENCIL);
+                                      GL_NONE, GL_NONE, st->internal_target,
+                                     sample_count, PIPE_BIND_DEPTH_STENCIL);
          assert(texFormat != PIPE_FORMAT_NONE);
       }
       else {
          /* default color format */
-         texFormat = st_choose_format(screen, GL_RGBA, st->internal_target,
+         texFormat = st_choose_format(screen, GL_RGBA,
+                                      GL_NONE, GL_NONE, st->internal_target,
                                       sample_count, PIPE_BIND_SAMPLER_VIEW);
          assert(texFormat != PIPE_FORMAT_NONE);
       }
index d0ac253..0574996 100644 (file)
@@ -41,6 +41,7 @@
 #include "pipe/p_defines.h"
 #include "st_context.h"
 #include "st_cb_queryobj.h"
+#include "st_cb_bitmap.h"
 
 
 #if FEATURE_queryobj
@@ -83,6 +84,8 @@ st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
    struct st_query_object *stq = st_query_object(q);
    unsigned type;
 
+   st_flush_bitmap_cache(st_context(ctx));
+
    /* convert GL query type to Gallium query type */
    switch (q->Target) {
    case GL_ANY_SAMPLES_PASSED:
@@ -128,6 +131,8 @@ st_EndQuery(struct gl_context *ctx, struct gl_query_object *q)
    struct pipe_context *pipe = st_context(ctx)->pipe;
    struct st_query_object *stq = st_query_object(q);
 
+   st_flush_bitmap_cache(st_context(ctx));
+
    pipe->end_query(pipe, stq->pq);
 }
 
index 67926e3..e2b29fe 100644 (file)
@@ -151,6 +151,24 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
             }
          }
          break;
+      case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+         if (format == GL_DEPTH_STENCIL) {
+            const uint *src = (uint *) (stmap + srcY * pt->stride);
+            const GLfloat *srcf = (const GLfloat*)src;
+            GLint k;
+            for (k = 0; k < width; k++) {
+               zValues[k] = srcf[k*2];
+               sValues[k] = src[k*2+1] & 0xff;
+            }
+         }
+         else {
+            const uint *src = (uint *) (stmap + srcY * pt->stride);
+            GLint k;
+            for (k = 0; k < width; k++) {
+               sValues[k] = src[k*2+1] & 0xff;
+            }
+         }
+         break;
       default:
          assert(0);
       }
@@ -159,7 +177,7 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
       dest = _mesa_image_address2d(packing, pixels, width, height,
                                    format, type, j, 0);
       if (format == GL_DEPTH_STENCIL) {
-         _mesa_pack_depth_stencil_span(ctx, width, dest,
+         _mesa_pack_depth_stencil_span(ctx, width, type, dest,
                                        zValues, sValues, packing);
       }
       else {
@@ -568,6 +586,31 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
             dst += dstStride;
          }
       }
+      else if (pformat == PIPE_FORMAT_Z32_FLOAT) {
+         for (i = 0; i < height; i++) {
+            GLfloat zfloat[MAX_WIDTH];
+            pipe_get_tile_raw(pipe, trans, 0, y, width, 1, zfloat, 0);
+            y += yStep;
+            _mesa_pack_depth_span(ctx, width, dst, type,
+                                  zfloat, &clippedPacking);
+            dst += dstStride;
+         }
+      }
+      else if (pformat == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) {
+         assert(format == GL_DEPTH_COMPONENT);
+         for (i = 0; i < height; i++) {
+            GLfloat zfloat[MAX_WIDTH];    /* Z32 */
+            GLfloat zfloat2[MAX_WIDTH*2]; /* Z32X32 */
+            pipe_get_tile_raw(pipe, trans, 0, y, width, 1, zfloat2, 0);
+            y += yStep;
+            for (j = 0; j < width; j++) {
+               zfloat[j] = zfloat2[j*2];
+            }
+            _mesa_pack_depth_span(ctx, width, dst, type,
+                                  zfloat, &clippedPacking);
+            dst += dstStride;
+         }
+      }
       else {
          /* RGBA format */
          /* Do a row at a time to flip image data vertically */
index 88f6290..25f08aa 100644 (file)
@@ -842,7 +842,7 @@ decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level,
    else {
       /* format translation via floats */
       GLuint row;
-      enum pipe_format format = util_format_linear(dst_texture->format);
+      enum pipe_format pformat = util_format_linear(dst_texture->format);
       for (row = 0; row < height; row++) {
          const GLbitfield transferOps = 0x0; /* bypassed for glGetTexImage() */
          GLfloat rgba[4 * MAX_WIDTH];
@@ -854,7 +854,7 @@ decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level,
 
          /* get float[4] rgba row from surface */
          pipe_get_tile_rgba_format(pipe, tex_xfer, 0, row, width, 1,
-                                   format, rgba);
+                                   pformat, rgba);
 
          _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format,
                                     type, dest, &ctx->Pack, transferOps);
@@ -1241,7 +1241,8 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level,
 
    src_trans = pipe_get_transfer(pipe,
                                  strb->texture,
-                                 0, 0,
+                                 strb->rtt_level,
+                                 strb->rtt_face + strb->rtt_slice,
                                  PIPE_TRANSFER_READ,
                                  srcX, srcY,
                                  width, height);
@@ -1465,34 +1466,6 @@ st_copy_texsubimage(struct gl_context *ctx,
       depth/stencil samples per pixel? Need some transfer clarifications. */
    assert(sample_count < 2);
 
-   if (srcX < 0) {
-      width -= -srcX;
-      destX += -srcX;
-      srcX = 0;
-   }
-
-   if (srcY < 0) {
-      height -= -srcY;
-      destY += -srcY;
-      srcY = 0;
-   }
-
-   if (destX < 0) {
-      width -= -destX;
-      srcX += -destX;
-      destX = 0;
-   }
-
-   if (destY < 0) {
-      height -= -destY;
-      srcY += -destY;
-      destY = 0;
-   }
-
-   if (width < 0 || height < 0)
-      return;
-
-
    assert(strb);
    assert(strb->surface);
    assert(stImage->pt);
@@ -1609,59 +1582,6 @@ st_copy_texsubimage(struct gl_context *ctx,
 
 
 static void
-st_CopyTexImage1D(struct gl_context * ctx, GLenum target, GLint level,
-                  GLenum internalFormat,
-                  GLint x, GLint y, GLsizei width, GLint border)
-{
-   struct gl_texture_unit *texUnit =
-      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-   struct gl_texture_object *texObj =
-      _mesa_select_tex_object(ctx, texUnit, target);
-   struct gl_texture_image *texImage =
-      _mesa_select_tex_image(ctx, texObj, target, level);
-
-   /* Setup or redefine the texture object, texture and texture
-    * image.  Don't populate yet.  
-    */
-   ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
-                          width, border,
-                          GL_RGBA, CHAN_TYPE, NULL,
-                          &ctx->DefaultPacking, texObj, texImage);
-
-   st_copy_texsubimage(ctx, target, level,
-                       0, 0, 0,  /* destX,Y,Z */
-                       x, y, width, 1);  /* src X, Y, size */
-}
-
-
-static void
-st_CopyTexImage2D(struct gl_context * ctx, GLenum target, GLint level,
-                  GLenum internalFormat,
-                  GLint x, GLint y, GLsizei width, GLsizei height,
-                  GLint border)
-{
-   struct gl_texture_unit *texUnit =
-      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-   struct gl_texture_object *texObj =
-      _mesa_select_tex_object(ctx, texUnit, target);
-   struct gl_texture_image *texImage =
-      _mesa_select_tex_image(ctx, texObj, target, level);
-
-   /* Setup or redefine the texture object, texture and texture
-    * image.  Don't populate yet.  
-    */
-   ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
-                          width, height, border,
-                          GL_RGBA, CHAN_TYPE, NULL,
-                          &ctx->DefaultPacking, texObj, texImage);
-
-   st_copy_texsubimage(ctx, target, level,
-                       0, 0, 0,  /* destX,Y,Z */
-                       x, y, width, height);  /* src X, Y, size */
-}
-
-
-static void
 st_CopyTexSubImage1D(struct gl_context * ctx, GLenum target, GLint level,
                      GLint xoffset, GLint x, GLint y, GLsizei width)
 {
@@ -1946,8 +1866,6 @@ st_init_texture_functions(struct dd_function_table *functions)
    functions->CompressedTexSubImage1D = st_CompressedTexSubImage1D;
    functions->CompressedTexSubImage2D = st_CompressedTexSubImage2D;
    functions->CompressedTexSubImage3D = st_CompressedTexSubImage3D;
-   functions->CopyTexImage1D = st_CopyTexImage1D;
-   functions->CopyTexImage2D = st_CopyTexImage2D;
    functions->CopyTexSubImage1D = st_CopyTexSubImage1D;
    functions->CopyTexSubImage2D = st_CopyTexSubImage2D;
    functions->CopyTexSubImage3D = st_CopyTexSubImage3D;
index 049755e..d4742eb 100644 (file)
@@ -56,13 +56,20 @@ static void st_viewport(struct gl_context * ctx, GLint x, GLint y,
    if (!st->invalidate_on_gl_viewport)
       return;
 
+   /*
+    * Normally we'd want the state tracker manager to mark the drawables
+    * invalid only when needed. This will force the state tracker manager
+    * to revalidate the drawable, rather than just update the context with
+    * the latest cached drawable info.
+    */
+
    stdraw = st_ws_framebuffer(st->ctx->DrawBuffer);
    stread = st_ws_framebuffer(st->ctx->ReadBuffer);
 
-   if (stdraw)
-      p_atomic_set(&stdraw->revalidate, TRUE);
-   if (stread && stread != stdraw)
-      p_atomic_set(&stread->revalidate, TRUE);
+   if (stdraw && stdraw->iface)
+      stdraw->iface_stamp = p_atomic_read(&stdraw->iface->stamp) - 1;
+   if (stread && stread != stdraw && stread->iface)
+      stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1;
 }
 
 void st_init_viewport_functions(struct dd_function_table *functions)
index 6eddbfc..6d4bc54 100644 (file)
@@ -179,6 +179,9 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
    st_init_driver_functions(&funcs);
 
    ctx = _mesa_create_context(api, visual, shareCtx, &funcs, NULL);
+   if (!ctx) {
+      return NULL;
+   }
 
    /* XXX: need a capability bit in gallium to query if the pipe
     * driver prefers DP4 or MUL/MAD for vertex transformation.
index ff20703..0a32202 100644 (file)
@@ -204,6 +204,9 @@ struct st_context
    /* Active render condition. */
    struct pipe_query *render_condition;
    unsigned condition_mode;
+
+   int32_t draw_stamp;
+   int32_t read_stamp;
 };
 
 
@@ -227,7 +230,8 @@ struct st_framebuffer
    struct st_framebuffer_iface *iface;
    enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
    unsigned num_statts;
-   int32_t revalidate;
+   int32_t stamp;
+   int32_t iface_stamp;
 };
 
 
index fac0ab7..5040c6f 100644 (file)
@@ -233,6 +233,22 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
 }
 
 
+/**
+ * This is very similar to vbo_all_varyings_in_vbos() but we test
+ * the stride.  See bug 38626.
+ */
+static GLboolean
+all_varyings_in_vbos(const struct gl_client_array *arrays[])
+{
+   GLuint i;
+   
+   for (i = 0; i < VERT_ATTRIB_MAX; i++)
+      if (arrays[i]->StrideB && !_mesa_is_bufferobj(arrays[i]->BufferObj))
+        return GL_FALSE;
+
+   return GL_TRUE;
+}
+
 
 /**
  * Examine the active arrays to determine if we have interleaved
@@ -648,7 +664,7 @@ st_draw_vbo(struct gl_context *ctx,
    if (ib) {
       /* Gallium probably doesn't want this in some cases. */
       if (!index_bounds_valid)
-         if (!vbo_all_varyings_in_vbos(arrays))
+         if (!all_varyings_in_vbos(arrays))
             vbo_get_minmax_index(ctx, prims, ib, &min_index, &max_index);
 
       for (i = 0; i < nr_prims; i++) {
index d3aebe5..8e90093 100644 (file)
@@ -208,6 +208,15 @@ void st_init_limits(struct st_context *st)
 }
 
 
+static GLboolean st_get_s3tc_override(void)
+{
+   const char *override = _mesa_getenv("force_s3tc_enable");
+   if (override && !strcmp(override, "true"))
+      return GL_TRUE;
+   return GL_FALSE;
+}
+
+
 /**
  * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine
  * which GL extensions are supported.
@@ -219,6 +228,7 @@ void st_init_extensions(struct st_context *st)
 {
    struct pipe_screen *screen = st->pipe->screen;
    struct gl_context *ctx = st->ctx;
+   int i;
 
    /*
     * Extensions that are supported by all Gallium drivers:
@@ -426,7 +436,7 @@ void st_init_extensions(struct st_context *st)
    if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
                                    PIPE_TEXTURE_2D, 0,
                                    PIPE_BIND_SAMPLER_VIEW) &&
-       ctx->Mesa_DXTn) {
+       (ctx->Mesa_DXTn || st_get_s3tc_override())) {
       ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
       ctx->Extensions.S3_s3tc = GL_TRUE;
    }
@@ -596,6 +606,16 @@ void st_init_extensions(struct st_context *st)
       ctx->Extensions.EXT_packed_float = GL_TRUE;
    }
 
+   /* Maximum sample count. */
+   for (i = 16; i > 0; --i) {
+      if (screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_UNORM,
+                                      PIPE_TEXTURE_2D, i,
+                                      PIPE_BIND_RENDER_TARGET)) {
+         ctx->Const.MaxSamples = i;
+         break;
+      }
+   }
+
    if (screen->get_param(screen, PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE)) {
       ctx->Extensions.ARB_seamless_cube_map = GL_TRUE;
       ctx->Extensions.AMD_seamless_cubemap_per_texture = GL_TRUE;
@@ -607,4 +627,15 @@ void st_init_extensions(struct st_context *st)
    if (screen->get_param(screen, PIPE_CAP_SM3)) {
       ctx->Extensions.ARB_shader_texture_lod = GL_TRUE;
    }
+
+   if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_DEPTH_STENCIL |
+                                   PIPE_BIND_SAMPLER_VIEW) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_DEPTH_STENCIL |
+                                   PIPE_BIND_SAMPLER_VIEW)) {
+      ctx->Extensions.ARB_depth_buffer_float = GL_TRUE;
+   }
 }
index 3583571..bd4f086 100644 (file)
@@ -68,42 +68,70 @@ GLenum
 st_format_datatype(enum pipe_format format)
 {
    const struct util_format_description *desc;
+   int i;
 
    desc = util_format_description(format);
    assert(desc);
 
+   /* Find the first non-VOID channel. */
+   for (i = 0; i < 4; i++) {
+       if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
+           break;
+       }
+   }
+
    if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) {
       if (format == PIPE_FORMAT_B5G5R5A1_UNORM ||
           format == PIPE_FORMAT_B5G6R5_UNORM) {
          return GL_UNSIGNED_SHORT;
       }
+      else if (format == PIPE_FORMAT_R11G11B10_FLOAT ||
+               format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
+         return GL_FLOAT;
+      }
       else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
                format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
                format == PIPE_FORMAT_Z24X8_UNORM ||
                format == PIPE_FORMAT_X8Z24_UNORM) {
          return GL_UNSIGNED_INT_24_8;
       }
+      else if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) {
+         return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+      }
       else {
          const GLuint size = format_max_bits(format);
+
+         assert(i < 4);
+         if (i == 4)
+            return GL_NONE;
+
          if (size == 8) {
-            if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+            if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
                return GL_UNSIGNED_BYTE;
             else
                return GL_BYTE;
          }
          else if (size == 16) {
-            if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+            if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+               return GL_HALF_FLOAT;
+            if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
                return GL_UNSIGNED_SHORT;
             else
                return GL_SHORT;
          }
-         else {
-            assert( size <= 32 );
-            if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+         else if (size <= 32) {
+            if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+               return GL_FLOAT;
+            if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
                return GL_UNSIGNED_INT;
             else
                return GL_INT;
          }
+         else {
+            assert(size == 64);
+            assert(desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT);
+            return GL_DOUBLE;
+         }
       }
    }
    else if (format == PIPE_FORMAT_UYVY) {
@@ -180,6 +208,10 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
       return PIPE_FORMAT_Z24X8_UNORM;
    case MESA_FORMAT_S8:
       return PIPE_FORMAT_S8_USCALED;
+   case MESA_FORMAT_Z32_FLOAT:
+      return PIPE_FORMAT_Z32_FLOAT;
+   case MESA_FORMAT_Z32_FLOAT_X24S8:
+      return PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED;
    case MESA_FORMAT_YCBCR:
       return PIPE_FORMAT_UYVY;
 #if FEATURE_texture_s3tc
@@ -402,6 +434,10 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
       return MESA_FORMAT_X8_Z24;
    case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
       return MESA_FORMAT_S8_Z24;
+   case PIPE_FORMAT_Z32_FLOAT:
+      return MESA_FORMAT_Z32_FLOAT;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      return MESA_FORMAT_Z32_FLOAT_X24S8;
 
    case PIPE_FORMAT_UYVY:
       return MESA_FORMAT_YCBCR;
@@ -608,7 +644,7 @@ struct format_mapping
  * Multiple GL enums might map to multiple pipe_formats.
  * The first pipe format in the list that's supported is the one that's chosen.
  */
-static struct format_mapping format_map[] = {
+static const struct format_mapping format_map[] = {
    /* Basic RGB, RGBA formats */
    {
       { GL_RGB10, GL_RGB10_A2, 0 },
@@ -616,7 +652,7 @@ static struct format_mapping format_map[] = {
    },
    {
       { 4, GL_RGBA, GL_RGBA8, 0 },
-      { DEFAULT_RGBA_FORMATS, 0 }
+      { PIPE_FORMAT_R8G8B8A8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_BGRA, 0 },
@@ -624,7 +660,7 @@ static struct format_mapping format_map[] = {
    },
    {
       { 3, GL_RGB, GL_RGB8, 0 },
-      { DEFAULT_RGB_FORMATS, 0 }
+      { DEFAULT_RGB_FORMATS }
    },
    {
       { GL_RGB12, GL_RGB16, GL_RGBA12, GL_RGBA16, 0 },
@@ -759,6 +795,10 @@ static struct format_mapping format_map[] = {
       { GL_DEPTH_COMPONENT, 0 },
       { DEFAULT_DEPTH_FORMATS }
    },
+   {
+      { GL_DEPTH_COMPONENT32F, 0 },
+      { PIPE_FORMAT_Z32_FLOAT, 0 }
+   },
 
    /* stencil formats */
    {
@@ -775,6 +815,10 @@ static struct format_mapping format_map[] = {
       { GL_DEPTH_STENCIL_EXT, GL_DEPTH24_STENCIL8_EXT, 0 },
       { PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_S8_USCALED_Z24_UNORM, 0 }
    },
+   {
+      { GL_DEPTH32F_STENCIL8, 0 },
+      { PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, 0 }
+   },
 
    /* sRGB formats */
    {
@@ -1108,7 +1152,7 @@ static struct format_mapping format_map[] = {
  * Return first supported format from the given list.
  */
 static enum pipe_format
-find_supported_format(struct pipe_screen *screen, 
+find_supported_format(struct pipe_screen *screen,
                       const enum pipe_format formats[],
                       enum pipe_texture_target target,
                       unsigned sample_count,
@@ -1124,6 +1168,91 @@ find_supported_format(struct pipe_screen *screen,
    return PIPE_FORMAT_NONE;
 }
 
+struct exact_format_mapping
+{
+   GLenum format;
+   GLenum type;
+   enum pipe_format pformat;
+};
+
+static const struct exact_format_mapping rgba8888_tbl[] =
+{
+   { GL_RGBA,     GL_UNSIGNED_INT_8_8_8_8,        PIPE_FORMAT_A8B8G8R8_UNORM },
+   { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV,    PIPE_FORMAT_A8B8G8R8_UNORM },
+   { GL_RGBA,     GL_UNSIGNED_INT_8_8_8_8_REV,    PIPE_FORMAT_R8G8B8A8_UNORM },
+   { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8,        PIPE_FORMAT_R8G8B8A8_UNORM },
+   { GL_BGRA,     GL_UNSIGNED_INT_8_8_8_8,        PIPE_FORMAT_A8R8G8B8_UNORM },
+   { GL_BGRA,     GL_UNSIGNED_INT_8_8_8_8_REV,    PIPE_FORMAT_B8G8R8A8_UNORM },
+   { GL_RGBA,     GL_UNSIGNED_BYTE,               PIPE_FORMAT_R8G8B8A8_UNORM },
+   { GL_ABGR_EXT, GL_UNSIGNED_BYTE,               PIPE_FORMAT_A8B8G8R8_UNORM },
+   { GL_BGRA,     GL_UNSIGNED_BYTE,               PIPE_FORMAT_B8G8R8A8_UNORM },
+   { 0,           0,                              0                          }
+};
+
+static const struct exact_format_mapping rgbx8888_tbl[] =
+{
+   { GL_BGRA,     GL_UNSIGNED_INT_8_8_8_8,        PIPE_FORMAT_X8R8G8B8_UNORM },
+   { GL_BGRA,     GL_UNSIGNED_INT_8_8_8_8_REV,    PIPE_FORMAT_B8G8R8X8_UNORM },
+   { GL_BGRA,     GL_UNSIGNED_BYTE,               PIPE_FORMAT_B8G8R8X8_UNORM },
+   /* No Mesa formats for these Gallium formats:
+   { GL_RGBA,     GL_UNSIGNED_INT_8_8_8_8,        PIPE_FORMAT_X8B8G8R8_UNORM },
+   { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV,    PIPE_FORMAT_X8B8G8R8_UNORM },
+   { GL_RGBA,     GL_UNSIGNED_INT_8_8_8_8_REV,    PIPE_FORMAT_R8G8B8X8_UNORM },
+   { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8,        PIPE_FORMAT_R8G8B8X8_UNORM },
+   { GL_RGBA,     GL_UNSIGNED_BYTE,               PIPE_FORMAT_R8G8B8X8_UNORM },
+   { GL_ABGR_EXT, GL_UNSIGNED_BYTE,               PIPE_FORMAT_X8B8G8R8_UNORM },
+   */
+   { 0,           0,                              0                          }
+};
+
+static const struct exact_format_mapping rgba1010102_tbl[] =
+{
+   { GL_BGRA,     GL_UNSIGNED_INT_2_10_10_10_REV, PIPE_FORMAT_B10G10R10A2_UNORM },
+   /* No Mesa formats for these Gallium formats:
+   { GL_RGBA,     GL_UNSIGNED_INT_2_10_10_10_REV, PIPE_FORMAT_R10G10B10A2_UNORM },
+   { GL_ABGR_EXT, GL_UNSIGNED_INT_10_10_10_2,     PIPE_FORMAT_R10G10B10A2_UNORM },
+   { GL_ABGR_EXT, GL_UNSIGNED_INT,                PIPE_FORMAT_R10G10B10A2_UNORM },
+   */
+   { 0,           0,                              0                             }
+};
+
+/**
+ * If there is an exact pipe_format match for {internalFormat, format, type}
+ * return that, otherwise return PIPE_FORMAT_NONE so we can do fuzzy matching.
+ */
+static enum pipe_format
+find_exact_format(GLint internalFormat, GLenum format, GLenum type)
+{
+   uint i;
+   const struct exact_format_mapping* tbl;
+
+   if (format == GL_NONE || type == GL_NONE)
+      return PIPE_FORMAT_NONE;
+
+   switch (internalFormat) {
+   case 4:
+   case GL_RGBA:
+   case GL_RGBA8:
+      tbl = rgba8888_tbl;
+      break;
+   case 3:
+   case GL_RGB:
+   case GL_RGB8:
+      tbl = rgbx8888_tbl;
+      break;
+   case GL_RGB10_A2:
+      tbl = rgba1010102_tbl;
+      break;
+   default:
+      return PIPE_FORMAT_NONE;
+   }
+
+   for (i = 0; tbl[i].format; i++)
+      if (tbl[i].format == format && tbl[i].type == type)
+         return tbl[i].pformat;
+
+   return PIPE_FORMAT_NONE;
+}
 
 /**
  * Given an OpenGL internalFormat value for a texture or surface, return
@@ -1140,11 +1269,13 @@ find_supported_format(struct pipe_screen *screen,
  */
 enum pipe_format
 st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
+                 GLenum format, GLenum type,
                  enum pipe_texture_target target, unsigned sample_count,
                  unsigned bindings)
 {
    GET_CURRENT_CONTEXT(ctx); /* XXX this should be a function parameter */
    int i, j;
+   enum pipe_format pf;
 
    /* can't render to compressed formats at this time */
    if (_mesa_is_compressed_format(ctx, internalFormat)
@@ -1152,6 +1283,13 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
       return PIPE_FORMAT_NONE;
    }
 
+   /* search for exact matches */
+   pf = find_exact_format(internalFormat, format, type);
+   if (pf != PIPE_FORMAT_NONE &&
+       screen->is_format_supported(screen, pf,
+                                   target, sample_count, bindings))
+      return pf;
+
    /* search table for internalFormat */
    for (i = 0; i < Elements(format_map); i++) {
       const struct format_mapping *mapping = &format_map[i];
@@ -1183,14 +1321,11 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
       usage = PIPE_BIND_DEPTH_STENCIL;
    else
       usage = PIPE_BIND_RENDER_TARGET;
-   return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D,
+   return st_choose_format(screen, internalFormat, GL_NONE, GL_NONE, PIPE_TEXTURE_2D,
                            sample_count, usage);
 }
 
 
-/**
- * Called via ctx->Driver.chooseTextureFormat().
- */
 gl_format
 st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
                                  GLenum format, GLenum type, GLboolean renderable)
@@ -1206,20 +1341,19 @@ st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
     * that in advance.  Specify potential render target flags now.
     */
    bindings = PIPE_BIND_SAMPLER_VIEW;
-   if (renderable == GL_TRUE) {
-      if (_mesa_is_depth_format(internalFormat) ||
-         _mesa_is_depth_or_stencil_format(internalFormat))
+   if (renderable) {
+      if (_mesa_is_depth_or_stencil_format(internalFormat))
         bindings |= PIPE_BIND_DEPTH_STENCIL;
-      else 
+      else
         bindings |= PIPE_BIND_RENDER_TARGET;
    }
 
-   pFormat = st_choose_format(screen, internalFormat,
+   pFormat = st_choose_format(screen, internalFormat, format, type,
                               PIPE_TEXTURE_2D, 0, bindings);
 
    if (pFormat == PIPE_FORMAT_NONE) {
       /* try choosing format again, this time without render target bindings */
-      pFormat = st_choose_format(screen, internalFormat,
+      pFormat = st_choose_format(screen, internalFormat, format, type,
                                  PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
    }
 
@@ -1231,6 +1365,10 @@ st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
    return st_pipe_format_to_mesa_format(pFormat);
 }
 
+
+/**
+ * Called via ctx->Driver.ChooseTextureFormat().
+ */
 gl_format
 st_ChooseTextureFormat(struct gl_context *ctx, GLint internalFormat,
                        GLenum format, GLenum type)
index 0fb570f..1c1f596 100644 (file)
@@ -52,8 +52,9 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
 
 extern enum pipe_format
 st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
+                 GLenum format, GLenum type,
                  enum pipe_texture_target target, unsigned sample_count,
-                 unsigned tex_usage);
+                 unsigned bindings);
 
 extern enum pipe_format
 st_choose_renderbuffer_format(struct pipe_screen *screen,
index b5f4253..9c6a7ed 100644 (file)
@@ -1505,6 +1505,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
          emit(ir, TGSI_OPCODE_I2F, result_dst, op[0]);
          break;
       }
+   case ir_unop_i2u:
+   case ir_unop_u2i:
+      /* Converting between signed and unsigned integers is a no-op. */
    case ir_unop_b2i:
       /* Booleans are stored as integers (or floats in GLSL 1.20 and lower). */
       result_src = op[0];
index a68544d..d5228d3 100644 (file)
@@ -139,23 +139,64 @@ buffer_index_to_attachment(gl_buffer_index index)
 }
 
 /**
+ * Make sure a context picks up the latest cached state of the
+ * drawables it binds to.
+ */
+static void
+st_context_validate(struct st_context *st,
+                    struct st_framebuffer *stdraw,
+                    struct st_framebuffer *stread)
+{
+    if (stdraw && stdraw->stamp != st->draw_stamp) {
+       st->dirty.st |= ST_NEW_FRAMEBUFFER;
+       _mesa_resize_framebuffer(st->ctx, &stdraw->Base,
+                                stdraw->Base.Width,
+                                stdraw->Base.Height);
+       st->draw_stamp = stdraw->stamp;
+    }
+
+    if (stread && stread->stamp != st->read_stamp) {
+       if (stread != stdraw) {
+          st->dirty.st |= ST_NEW_FRAMEBUFFER;
+          _mesa_resize_framebuffer(st->ctx, &stread->Base,
+                                   stread->Base.Width,
+                                   stread->Base.Height);
+       }
+       st->read_stamp = stread->stamp;
+    }
+}
+
+/**
  * Validate a framebuffer to make sure up-to-date pipe_textures are used.
+ * The context we need to pass in is s dummy context needed only to be
+ * able to get a pipe context to create pipe surfaces, and to have a
+ * context to call _mesa_resize_framebuffer():
+ * (That should probably be rethought, since those surfaces become
+ * drawable state, not context state, and can be freed by another pipe
+ * context).
  */
 static void
-st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
+st_framebuffer_validate(struct st_framebuffer *stfb,
+                        struct st_context *st)
 {
-   struct pipe_context *pipe = st->pipe;
    struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
    uint width, height;
    unsigned i;
    boolean changed = FALSE;
+   int32_t new_stamp = p_atomic_read(&stfb->iface->stamp);
 
-   if (!p_atomic_read(&stfb->revalidate))
+   if (stfb->iface_stamp == new_stamp)
       return;
 
    /* validate the fb */
-   if (!stfb->iface->validate(stfb->iface, stfb->statts, stfb->num_statts, textures))
-      return;
+   do {
+      if (!stfb->iface->validate(stfb->iface, stfb->statts,
+                                stfb->num_statts, textures))
+        return;
+
+      stfb->iface_stamp = new_stamp;
+      new_stamp = p_atomic_read(&stfb->iface->stamp);
+   } while(stfb->iface_stamp != new_stamp);
 
    width = stfb->Base.Width;
    height = stfb->Base.Height;
@@ -184,7 +225,7 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
       memset(&surf_tmpl, 0, sizeof(surf_tmpl));
       u_surface_default_template(&surf_tmpl, textures[i],
                                  PIPE_BIND_RENDER_TARGET);
-      ps = pipe->create_surface(pipe, textures[i], &surf_tmpl);
+      ps = st->pipe->create_surface(st->pipe, textures[i], &surf_tmpl);
       if (ps) {
          pipe_surface_reference(&strb->surface, ps);
          pipe_resource_reference(&strb->texture, ps->texture);
@@ -204,14 +245,9 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
    }
 
    if (changed) {
-      st->dirty.st |= ST_NEW_FRAMEBUFFER;
+      ++stfb->stamp;
       _mesa_resize_framebuffer(st->ctx, &stfb->Base, width, height);
-
-      assert(stfb->Base.Width == width);
-      assert(stfb->Base.Height == height);
    }
-
-   p_atomic_set(&stfb->revalidate, FALSE);
 }
 
 /**
@@ -236,8 +272,7 @@ st_framebuffer_update_attachments(struct st_framebuffer *stfb)
           st_visual_have_buffers(stfb->iface->visual, 1 << statt))
          stfb->statts[stfb->num_statts++] = statt;
    }
-
-   p_atomic_set(&stfb->revalidate, TRUE);
+   stfb->stamp++;
 }
 
 /**
@@ -443,6 +478,7 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi)
          &stfb->Base._ColorReadBufferIndex);
 
    stfb->iface = stfbi;
+   stfb->iface_stamp = p_atomic_read(&stfbi->stamp) - 1;
 
    /* add the color buffer */
    idx = stfb->Base._ColorDrawBufferIndexes[0];
@@ -454,6 +490,7 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi)
    st_framebuffer_add_renderbuffer(stfb, BUFFER_DEPTH);
    st_framebuffer_add_renderbuffer(stfb, BUFFER_ACCUM);
 
+   stfb->stamp = 0;
    st_framebuffer_update_attachments(stfb);
 
    stfb->Base.Initialized = GL_TRUE;
@@ -473,31 +510,6 @@ st_framebuffer_reference(struct st_framebuffer **ptr,
 }
 
 static void
-st_context_notify_invalid_framebuffer(struct st_context_iface *stctxi,
-                                      struct st_framebuffer_iface *stfbi)
-{
-   struct st_context *st = (struct st_context *) stctxi;
-   struct st_framebuffer *stfb;
-
-   /* either draw or read winsys fb */
-   stfb = st_ws_framebuffer(st->ctx->WinSysDrawBuffer);
-   if (!stfb || stfb->iface != stfbi)
-      stfb = st_ws_framebuffer(st->ctx->WinSysReadBuffer);
-
-   if (stfb && stfb->iface == stfbi) {
-      p_atomic_set(&stfb->revalidate, TRUE);
-   }
-   else {
-      /* This function is probably getting called when we've detected a
-       * change in a window's size but the currently bound context is
-       * not bound to that window.
-       * If the st_framebuffer_iface structure had a pointer to the
-       * corresponding st_framebuffer we'd be able to handle this.
-       */
-   }
-}
-
-static void
 st_context_flush(struct st_context_iface *stctxi, unsigned flags,
                  struct pipe_fence_handle **fence)
 {
@@ -575,7 +587,7 @@ st_context_teximage(struct st_context_iface *stctxi,
          internalFormat = GL_RGB;
 
       texFormat = st_ChooseTextureFormat(ctx, internalFormat,
-                                         GL_RGBA, GL_UNSIGNED_BYTE);
+                                         GL_BGRA, GL_UNSIGNED_BYTE);
 
       _mesa_init_teximage_fields(ctx, target, texImage,
                                  tex->width0, tex->height0, 1, 0,
@@ -696,8 +708,6 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
       smapi->get_param(smapi, ST_MANAGER_BROKEN_INVALIDATE);
 
    st->iface.destroy = st_context_destroy;
-   st->iface.notify_invalid_framebuffer =
-      st_context_notify_invalid_framebuffer;
    st->iface.flush = st_context_flush;
    st->iface.teximage = st_context_teximage;
    st->iface.copy = st_context_copy;
@@ -707,38 +717,58 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
    return &st->iface;
 }
 
+static struct st_context_iface *
+st_api_get_current(struct st_api *stapi)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct st_context *st = (ctx) ? ctx->st : NULL;
+
+   return (st) ? &st->iface : NULL;
+}
+
+static struct st_framebuffer *
+st_framebuffer_reuse_or_create(struct gl_framebuffer *fb,
+                               struct st_framebuffer_iface *stfbi)
+{
+   struct st_framebuffer *cur = st_ws_framebuffer(fb), *stfb = NULL;
+
+   if (cur && cur->iface == stfbi) {
+      /* reuse the current stfb */
+      st_framebuffer_reference(&stfb, cur);
+   }
+   else {
+      /* create a new one */
+      stfb = st_framebuffer_create(stfbi);
+   }
+
+   return stfb;
+}
+
 static boolean
 st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
                     struct st_framebuffer_iface *stdrawi,
                     struct st_framebuffer_iface *streadi)
 {
    struct st_context *st = (struct st_context *) stctxi;
-   struct st_framebuffer *stdraw, *stread, *stfb;
+   struct st_framebuffer *stdraw, *stread;
    boolean ret;
 
    _glapi_check_multithread();
 
    if (st) {
-      /* reuse/create the draw fb */
-      stfb = st_ws_framebuffer(st->ctx->WinSysDrawBuffer);
-      if (stfb && stfb->iface == stdrawi) {
-         stdraw = NULL;
-         st_framebuffer_reference(&stdraw, stfb);
+      /* reuse or create the draw fb */
+      stdraw = st_framebuffer_reuse_or_create(st->ctx->WinSysDrawBuffer,
+                                              stdrawi);
+      if (streadi != stdrawi) {
+         /* do the same for the read fb */
+         stread = st_framebuffer_reuse_or_create(st->ctx->WinSysReadBuffer,
+                                                 streadi);
       }
       else {
-         stdraw = st_framebuffer_create(stdrawi);
-      }
-
-      /* reuse/create the read fb */
-      stfb = st_ws_framebuffer(st->ctx->WinSysReadBuffer);
-      if (!stfb || stfb->iface != streadi)
-         stfb = stdraw;
-      if (stfb && stfb->iface == streadi) {
          stread = NULL;
-         st_framebuffer_reference(&stread, stfb);
-      }
-      else {
-         stread = st_framebuffer_create(streadi);
+         /* reuse the draw fb for the read fb */
+         if (stdraw)
+            st_framebuffer_reference(&stread, stdraw);
       }
 
       if (stdraw && stread) {
@@ -757,6 +787,10 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
          }
 
          ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base);
+
+         st->draw_stamp = stdraw->stamp - 1;
+         st->read_stamp = stread->stamp - 1;
+         st_context_validate(st, stdraw, stread);
       }
       else {
          struct gl_framebuffer *incomplete = _mesa_get_incomplete_framebuffer();
@@ -773,15 +807,6 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
    return ret;
 }
 
-static struct st_context_iface *
-st_api_get_current(struct st_api *stapi)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   struct st_context *st = (ctx) ? ctx->st : NULL;
-
-   return (st) ? &st->iface : NULL;
-}
-
 static st_proc_t
 st_api_get_proc_address(struct st_api *stapi, const char *procname)
 {
@@ -857,6 +882,8 @@ st_manager_validate_framebuffers(struct st_context *st)
       st_framebuffer_validate(stdraw, st);
    if (stread && stread != stdraw)
       st_framebuffer_validate(stread, st);
+
+   st_context_validate(st, stdraw, stread);
 }
 
 /**
@@ -891,6 +918,15 @@ st_manager_add_color_renderbuffer(struct st_context *st,
       return FALSE;
 
    st_framebuffer_update_attachments(stfb);
+
+   /*
+    * Force a call to the state tracker manager to validate the
+    * new renderbuffer. It might be that there is a window system
+    * renderbuffer available.
+    */
+   if(stfb->iface)
+      stfb->iface_stamp = p_atomic_read(&stfb->iface->stamp) - 1;
+
    st_invalidate_state(st->ctx, _NEW_BUFFERS);
 
    return TRUE;
index 6d39512..ca01d2e 100644 (file)
@@ -613,7 +613,6 @@ st_translate_fragment_program(struct st_context *st,
 
    if (!stfp->tgsi.tokens) {
       /* need to translate Mesa instructions to TGSI now */
-      enum pipe_error error;
       struct ureg_program *ureg;
       GLboolean write_all = st_prepare_fragment_program(st->ctx, stfp);
       
@@ -633,38 +632,38 @@ st_translate_fragment_program(struct st_context *st,
          ureg_property_fs_color0_writes_all_cbufs(ureg, 1);
 
       if (stfp->glsl_to_tgsi)
-         error = st_translate_program(st->ctx,
-                                      TGSI_PROCESSOR_FRAGMENT,
-                                      ureg,
-                                      stfp->glsl_to_tgsi,
-                                      &stfp->Base.Base,
-                                      /* inputs */
-                                      stfp->num_inputs,
-                                      stfp->input_to_index,
-                                      stfp->input_semantic_name,
-                                      stfp->input_semantic_index,
-                                      stfp->interp_mode,
-                                      /* outputs */
-                                      stfp->num_outputs,
-                                      stfp->result_to_output,
-                                      stfp->output_semantic_name,
-                                      stfp->output_semantic_index, FALSE );
+         st_translate_program(st->ctx,
+                              TGSI_PROCESSOR_FRAGMENT,
+                              ureg,
+                              stfp->glsl_to_tgsi,
+                              &stfp->Base.Base,
+                              /* inputs */
+                              stfp->num_inputs,
+                              stfp->input_to_index,
+                              stfp->input_semantic_name,
+                              stfp->input_semantic_index,
+                              stfp->interp_mode,
+                              /* outputs */
+                              stfp->num_outputs,
+                              stfp->result_to_output,
+                              stfp->output_semantic_name,
+                              stfp->output_semantic_index, FALSE );
       else
-         error = st_translate_mesa_program(st->ctx,
-                                           TGSI_PROCESSOR_FRAGMENT,
-                                           ureg,
-                                           &stfp->Base.Base,
-                                           /* inputs */
-                                           stfp->num_inputs,
-                                           stfp->input_to_index,
-                                           stfp->input_semantic_name,
-                                           stfp->input_semantic_index,
-                                           stfp->interp_mode,
-                                           /* outputs */
-                                           stfp->num_outputs,
-                                           stfp->result_to_output,
-                                           stfp->output_semantic_name,
-                                           stfp->output_semantic_index, FALSE );
+         st_translate_mesa_program(st->ctx,
+                                   TGSI_PROCESSOR_FRAGMENT,
+                                   ureg,
+                                   &stfp->Base.Base,
+                                   /* inputs */
+                                   stfp->num_inputs,
+                                   stfp->input_to_index,
+                                   stfp->input_semantic_name,
+                                   stfp->input_semantic_index,
+                                   stfp->interp_mode,
+                                   /* outputs */
+                                   stfp->num_outputs,
+                                   stfp->result_to_output,
+                                   stfp->output_semantic_name,
+                                   stfp->output_semantic_index, FALSE );
 
       stfp->tgsi.tokens = ureg_get_tokens( ureg, NULL );
       ureg_destroy( ureg );
@@ -731,7 +730,6 @@ st_translate_geometry_program(struct st_context *st,
    GLuint inputMapping[GEOM_ATTRIB_MAX];
    GLuint outputMapping[GEOM_RESULT_MAX];
    struct pipe_context *pipe = st->pipe;
-   enum pipe_error error;
    GLuint attr;
    const GLbitfield inputsRead = stgp->Base.Base.InputsRead;
    GLuint vslot = 0;
@@ -938,22 +936,22 @@ st_translate_geometry_program(struct st_context *st,
    ureg_property_gs_output_prim(ureg, stgp->Base.OutputType);
    ureg_property_gs_max_vertices(ureg, stgp->Base.VerticesOut);
 
-   error = st_translate_mesa_program(st->ctx,
-                                     TGSI_PROCESSOR_GEOMETRY,
-                                     ureg,
-                                     &stgp->Base.Base,
-                                     /* inputs */
-                                     gs_num_inputs,
-                                     inputMapping,
-                                     stgp->input_semantic_name,
-                                     stgp->input_semantic_index,
-                                     NULL,
-                                     /* outputs */
-                                     gs_num_outputs,
-                                     outputMapping,
-                                     gs_output_semantic_name,
-                                     gs_output_semantic_index,
-                                     FALSE);
+   st_translate_mesa_program(st->ctx,
+                             TGSI_PROCESSOR_GEOMETRY,
+                             ureg,
+                             &stgp->Base.Base,
+                             /* inputs */
+                             gs_num_inputs,
+                             inputMapping,
+                             stgp->input_semantic_name,
+                             stgp->input_semantic_index,
+                             NULL,
+                             /* outputs */
+                             gs_num_outputs,
+                             outputMapping,
+                             gs_output_semantic_name,
+                             gs_output_semantic_index,
+                             FALSE);
 
    stgp->num_inputs = gs_num_inputs;
    stgp->tgsi.tokens = ureg_get_tokens( ureg, NULL );
index d8ba3ac..0e857fd 100644 (file)
@@ -407,7 +407,7 @@ st_create_color_map_texture(struct gl_context *ctx)
    const uint texSize = 256; /* simple, and usually perfect */
 
    /* find an RGBA texture format */
-   format = st_choose_format(pipe->screen, GL_RGBA,
+   format = st_choose_format(pipe->screen, GL_RGBA, GL_NONE, GL_NONE,
                              PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
 
    /* create texture for color map/table */
index 3516a41..7f53f19 100644 (file)
@@ -568,9 +568,6 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
    };
    GLint i;
 
-   if (!ctx->DrawBuffer->_NumColorDrawBuffers)
-      return;
-
    if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
                         &dstX0, &dstY0, &dstX1, &dstY1)) {
       return;
index 214f2ea..66ca392 100644 (file)
@@ -446,7 +446,7 @@ read_depth_stencil_pixels(struct gl_context *ctx,
             GLfloat depthVals[MAX_WIDTH];
             _swrast_read_depth_span_float(ctx, depthRb, width, x, y + i,
                                           depthVals);
-            _mesa_pack_depth_stencil_span(ctx, width, depthStencilDst,
+            _mesa_pack_depth_stencil_span(ctx, width, type, depthStencilDst,
                                           depthVals, stencilVals, packing);
          }
       }
index f81de3c..db102ac 100644 (file)
@@ -961,17 +961,6 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output)
 static INLINE void
 shade_texture_span(struct gl_context *ctx, SWspan *span)
 {
-   GLbitfield inputsRead;
-
-   /* Determine which fragment attributes are actually needed */
-   if (ctx->FragmentProgram._Current) {
-      inputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
-   }
-   else {
-      /* XXX we could be a bit smarter about this */
-      inputsRead = ~0;
-   }
-
    if (ctx->FragmentProgram._Current ||
        ctx->ATIFragmentShader._Enabled) {
       /* programmable shading */
index 7959337..b908d5a 100644 (file)
@@ -972,13 +972,13 @@ static void GLAPIENTRY
 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)
+   if (MESA_VERBOSE & VERBOSE_DRAW) {
+      GET_CURRENT_CONTEXT(ctx);
       _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);
index 9068ae2..1de290f 100644 (file)
@@ -78,8 +78,7 @@ GLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] )
    GLuint i;
    
    for (i = 0; i < VERT_ATTRIB_MAX; i++)
-      if (arrays[i]->StrideB &&
-         arrays[i]->BufferObj->Name == 0)
+      if (arrays[i]->BufferObj->Name == 0)
         return GL_FALSE;
 
    return GL_TRUE;
@@ -90,8 +89,7 @@ GLboolean vbo_any_varyings_in_vbos( const struct gl_client_array *arrays[] )
    GLuint i;
 
    for (i = 0; i < VERT_ATTRIB_MAX; i++)
-      if (arrays[i]->StrideB &&
-         arrays[i]->BufferObj->Name != 0)
+      if (arrays[i]->BufferObj->Name != 0)
         return GL_TRUE;
 
    return GL_FALSE;