Merge remote branch 'origin/master' into gallium_draw_llvm
authorZack Rusin <zackr@vmware.com>
Wed, 31 Mar 2010 01:10:33 +0000 (21:10 -0400)
committerZack Rusin <zackr@vmware.com>
Wed, 31 Mar 2010 01:10:33 +0000 (21:10 -0400)
729 files changed:
Makefile
SConstruct
configs/autoconf.in
configs/default
configs/linux-cell
configs/linux-dri
configs/linux-llvm
configs/linux-opengl-es
configure.ac
docs/GL3.txt
docs/egl.html
docs/news.html
docs/relnotes-7.7.1.html
docs/relnotes-7.8.html
docs/shading.html
include/GL/gl_mangle.h
include/GL/internal/dri_interface.h
progs/SConscript
progs/demos/dissolve.c
progs/egl/Makefile
progs/gallium/python/samples/tri.py
progs/gallium/raw/SConscript [new file with mode: 0644]
progs/gallium/raw/clear.c [new file with mode: 0644]
progs/gallium/trivial/.gitignore [new file with mode: 0644]
progs/gallium/trivial/Makefile [new file with mode: 0644]
progs/gallium/trivial/quad-tex.c [new file with mode: 0644]
progs/gallium/trivial/tri.c [new file with mode: 0644]
progs/glsl/Makefile
progs/glsl/SConscript
progs/glsl/fsraytrace.c [new file with mode: 0644]
progs/glsl/vsraytrace.c [new file with mode: 0644]
progs/samples/copy.c
progs/samples/loadppm.c
progs/tests/Makefile
progs/tests/SConscript
progs/tests/cva_huge.c [new file with mode: 0644]
progs/tests/stencil_twoside.c
progs/trivial/tri-stencil.c
progs/xdemos/Makefile
src/egl/main/eglcontext.c
src/gallium/Makefile.template
src/gallium/SConscript
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript
src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/cso_cache/cso_context.h
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c
src/gallium/auxiliary/draw/draw_pipe_vbuf.c
src/gallium/auxiliary/draw/draw_pt_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
src/gallium/auxiliary/draw/draw_vertex.c
src/gallium/auxiliary/draw/draw_vertex.h
src/gallium/auxiliary/draw/draw_vs_aos_io.c
src/gallium/auxiliary/gallivm/lp_bld.h [new file with mode: 0644]
src/gallium/auxiliary/gallivm/lp_bld_alpha.h
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_arit.h
src/gallium/auxiliary/gallivm/lp_bld_blend.h
src/gallium/auxiliary/gallivm/lp_bld_const.c
src/gallium/auxiliary/gallivm/lp_bld_const.h
src/gallium/auxiliary/gallivm/lp_bld_conv.c
src/gallium/auxiliary/gallivm/lp_bld_conv.h
src/gallium/auxiliary/gallivm/lp_bld_debug.h
src/gallium/auxiliary/gallivm/lp_bld_depth.c
src/gallium/auxiliary/gallivm/lp_bld_depth.h
src/gallium/auxiliary/gallivm/lp_bld_flow.h
src/gallium/auxiliary/gallivm/lp_bld_format.h
src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
src/gallium/auxiliary/gallivm/lp_bld_interp.c
src/gallium/auxiliary/gallivm/lp_bld_interp.h
src/gallium/auxiliary/gallivm/lp_bld_intr.h
src/gallium/auxiliary/gallivm/lp_bld_logic.c
src/gallium/auxiliary/gallivm/lp_bld_logic.h
src/gallium/auxiliary/gallivm/lp_bld_pack.c
src/gallium/auxiliary/gallivm/lp_bld_pack.h
src/gallium/auxiliary/gallivm/lp_bld_printf.c [new file with mode: 0644]
src/gallium/auxiliary/gallivm/lp_bld_printf.h [new file with mode: 0644]
src/gallium/auxiliary/gallivm/lp_bld_sample.c
src/gallium/auxiliary/gallivm/lp_bld_sample.h
src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
src/gallium/auxiliary/gallivm/lp_bld_struct.h
src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
src/gallium/auxiliary/gallivm/lp_bld_swizzle.h
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
src/gallium/auxiliary/gallivm/lp_bld_type.h
src/gallium/auxiliary/os/os_llvm.h [deleted file]
src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
src/gallium/auxiliary/rtasm/rtasm_x86sse.c
src/gallium/auxiliary/rtasm/rtasm_x86sse.h
src/gallium/auxiliary/tgsi/tgsi_text.c
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_blit.h
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/auxiliary/util/u_format.csv
src/gallium/auxiliary/util/u_format.h
src/gallium/auxiliary/util/u_format_tests.c
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/auxiliary/util/u_gen_mipmap.h
src/gallium/auxiliary/util/u_inlines.h
src/gallium/auxiliary/util/u_pack_color.h
src/gallium/auxiliary/util/u_sampler.c [new file with mode: 0644]
src/gallium/auxiliary/util/u_sampler.h [new file with mode: 0644]
src/gallium/auxiliary/util/u_tile.c
src/gallium/auxiliary/util/u_tile.h
src/gallium/docs/d3d11ddi.txt [new file with mode: 0644]
src/gallium/docs/source/context.rst
src/gallium/docs/source/cso/rasterizer.rst
src/gallium/docs/source/cso/velems.rst
src/gallium/drivers/cell/ppu/cell_context.h
src/gallium/drivers/cell/ppu/cell_pipe_state.c
src/gallium/drivers/cell/ppu/cell_screen.c
src/gallium/drivers/cell/ppu/cell_texture.c
src/gallium/drivers/failover/fo_context.h
src/gallium/drivers/failover/fo_state.c
src/gallium/drivers/failover/fo_state_emit.c
src/gallium/drivers/i915/i915_batch.h
src/gallium/drivers/i915/i915_batchbuffer.h [new file with mode: 0644]
src/gallium/drivers/i915/i915_blit.c
src/gallium/drivers/i915/i915_blit.h
src/gallium/drivers/i915/i915_buffer.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_debug.c
src/gallium/drivers/i915/i915_debug.h
src/gallium/drivers/i915/i915_prim_emit.c
src/gallium/drivers/i915/i915_prim_vbuf.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_immediate.c
src/gallium/drivers/i915/i915_state_sampler.c
src/gallium/drivers/i915/i915_texture.c
src/gallium/drivers/i915/i915_winsys.h [new file with mode: 0644]
src/gallium/drivers/i915/intel_batchbuffer.h [deleted file]
src/gallium/drivers/i915/intel_winsys.h [deleted file]
src/gallium/drivers/i965/SConscript
src/gallium/drivers/i965/brw_context.c
src/gallium/drivers/i965/brw_context.h
src/gallium/drivers/i965/brw_pipe_sampler.c
src/gallium/drivers/i965/brw_screen_texture.c
src/gallium/drivers/i965/brw_wm.c
src/gallium/drivers/i965/brw_wm_sampler_state.c
src/gallium/drivers/i965/brw_wm_surface_state.c
src/gallium/drivers/identity/SConscript
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/identity/id_drm.c
src/gallium/drivers/identity/id_objects.h
src/gallium/drivers/llvmpipe/Makefile
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_fence.c
src/gallium/drivers/llvmpipe/lp_fence.h
src/gallium/drivers/llvmpipe/lp_flush.c
src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_rast.h
src/gallium/drivers/llvmpipe/lp_rast_priv.h
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_screen.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup.h
src/gallium/drivers/llvmpipe/lp_setup_context.h
src/gallium/drivers/llvmpipe/lp_setup_tri.c
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/llvmpipe/lp_test.h
src/gallium/drivers/llvmpipe/lp_test_format.c
src/gallium/drivers/llvmpipe/lp_test_printf.c [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_tex_sample.h
src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/nv50/nv50_clear.c
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_program.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_screen.h
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/nv50/nv50_texture.h
src/gallium/drivers/nvfx/nv30_fragtex.c
src/gallium/drivers/nvfx/nv40_fragtex.c
src/gallium/drivers/nvfx/nvfx_context.h
src/gallium/drivers/nvfx/nvfx_draw.c
src/gallium/drivers/nvfx/nvfx_fragprog.c
src/gallium/drivers/nvfx/nvfx_miptree.c
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/nvfx/nvfx_screen.h
src/gallium/drivers/nvfx/nvfx_state.c
src/gallium/drivers/nvfx/nvfx_state_viewport.c
src/gallium/drivers/nvfx/nvfx_transfer.c
src/gallium/drivers/nvfx/nvfx_vbo.c
src/gallium/drivers/r300/SConscript
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_chipset.c
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_cs.h
src/gallium/drivers/r300/r300_debug.c
src/gallium/drivers/r300/r300_defines.h [new file with mode: 0644]
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_fs.c
src/gallium/drivers/r300/r300_query.c
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.c
src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r300/r300_state_inlines.h
src/gallium/drivers/r300/r300_state_invariant.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_tgsi_to_rc.c
src/gallium/drivers/r300/r300_vs.c
src/gallium/drivers/r300/r300_winsys.h
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_flush.c
src/gallium/drivers/softpipe/sp_quad_depth_test.c
src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h [new file with mode: 0644]
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_state.h
src/gallium/drivers/softpipe/sp_state_fs.c
src/gallium/drivers/softpipe/sp_state_sampler.c
src/gallium/drivers/softpipe/sp_tex_tile_cache.c
src/gallium/drivers/softpipe/sp_tex_tile_cache.h
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_sampler.c
src/gallium/drivers/svga/svga_screen_texture.c
src/gallium/drivers/svga/svga_state_constants.c
src/gallium/drivers/svga/svga_state_fs.c
src/gallium/drivers/svga/svga_state_tss.c
src/gallium/drivers/sw/Makefile [new file with mode: 0644]
src/gallium/drivers/sw/SConscript [new file with mode: 0644]
src/gallium/drivers/sw/sw.c [new file with mode: 0644]
src/gallium/drivers/sw/sw_public.h [new file with mode: 0644]
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_context.h
src/gallium/drivers/trace/tr_rbug.c
src/gallium/drivers/trace/tr_texture.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_state.h
src/gallium/include/state_tracker/dri1_api.h
src/gallium/include/state_tracker/drisw_api.h [new file with mode: 0644]
src/gallium/include/state_tracker/drm_api.h
src/gallium/include/state_tracker/graw.h [new file with mode: 0644]
src/gallium/include/state_tracker/st_api.h [new file with mode: 0644]
src/gallium/include/state_tracker/sw_winsys.h
src/gallium/state_trackers/dri/Makefile
src/gallium/state_trackers/dri/SConscript
src/gallium/state_trackers/dri/common/dri1_helper.c [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri1_helper.h [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_context.c [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_context.h [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_drawable.c [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_drawable.h [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_screen.c [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_screen.h [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_st_api.c [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_st_api.h [new file with mode: 0644]
src/gallium/state_trackers/dri/common/dri_wrapper.h [new file with mode: 0644]
src/gallium/state_trackers/dri/dri_context.c [deleted file]
src/gallium/state_trackers/dri/dri_context.h [deleted file]
src/gallium/state_trackers/dri/dri_drawable.c [deleted file]
src/gallium/state_trackers/dri/dri_drawable.h [deleted file]
src/gallium/state_trackers/dri/dri_extensions.c [deleted file]
src/gallium/state_trackers/dri/dri_screen.c [deleted file]
src/gallium/state_trackers/dri/dri_screen.h [deleted file]
src/gallium/state_trackers/dri/drm/Makefile [new file with mode: 0644]
src/gallium/state_trackers/dri/drm/SConscript [new file with mode: 0644]
src/gallium/state_trackers/dri/drm/dri1.c [new file with mode: 0644]
src/gallium/state_trackers/dri/drm/dri1.h [new file with mode: 0644]
src/gallium/state_trackers/dri/drm/dri1_helper.c [new symlink]
src/gallium/state_trackers/dri/drm/dri2.c [new file with mode: 0644]
src/gallium/state_trackers/dri/drm/dri2.h [new file with mode: 0644]
src/gallium/state_trackers/dri/drm/dri_context.c [new symlink]
src/gallium/state_trackers/dri/drm/dri_drawable.c [new symlink]
src/gallium/state_trackers/dri/drm/dri_screen.c [new symlink]
src/gallium/state_trackers/dri/drm/dri_st_api.c [new symlink]
src/gallium/state_trackers/dri/sw/Makefile [new file with mode: 0644]
src/gallium/state_trackers/dri/sw/SConscript [new file with mode: 0644]
src/gallium/state_trackers/dri/sw/dri1_helper.c [new symlink]
src/gallium/state_trackers/dri/sw/dri_context.c [new symlink]
src/gallium/state_trackers/dri/sw/dri_drawable.c [new symlink]
src/gallium/state_trackers/dri/sw/dri_screen.c [new symlink]
src/gallium/state_trackers/dri/sw/dri_st_api.c [new symlink]
src/gallium/state_trackers/dri/sw/drisw.c [new file with mode: 0644]
src/gallium/state_trackers/dri/sw/drisw.h [new file with mode: 0644]
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_st.c [new file with mode: 0644]
src/gallium/state_trackers/egl/common/egl_g3d_st.h [new file with mode: 0644]
src/gallium/state_trackers/egl/common/egl_st.c [deleted file]
src/gallium/state_trackers/egl/common/egl_st.h [deleted file]
src/gallium/state_trackers/egl/common/st_public_tmp.h [deleted file]
src/gallium/state_trackers/es/Makefile
src/gallium/state_trackers/es/st_es1.c
src/gallium/state_trackers/es/st_es2.c
src/gallium/state_trackers/glx/xlib/Makefile
src/gallium/state_trackers/glx/xlib/SConscript
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_api.h
src/gallium/state_trackers/glx/xlib/xm_public.h
src/gallium/state_trackers/glx/xlib/xm_st.c [new file with mode: 0644]
src/gallium/state_trackers/glx/xlib/xm_st.h [new file with mode: 0644]
src/gallium/state_trackers/python/SConscript
src/gallium/state_trackers/python/gallium.i
src/gallium/state_trackers/python/p_context.i
src/gallium/state_trackers/python/p_texture.i
src/gallium/state_trackers/python/st_device.c
src/gallium/state_trackers/python/st_device.h
src/gallium/state_trackers/python/st_sample.c
src/gallium/state_trackers/python/st_sample.h
src/gallium/state_trackers/python/st_softpipe_winsys.c
src/gallium/state_trackers/vega/Makefile
src/gallium/state_trackers/vega/api_context.c
src/gallium/state_trackers/vega/api_filters.c
src/gallium/state_trackers/vega/api_masks.c
src/gallium/state_trackers/vega/image.c
src/gallium/state_trackers/vega/image.h
src/gallium/state_trackers/vega/mask.c
src/gallium/state_trackers/vega/mask.h
src/gallium/state_trackers/vega/paint.c
src/gallium/state_trackers/vega/paint.h
src/gallium/state_trackers/vega/renderer.c
src/gallium/state_trackers/vega/renderer.h
src/gallium/state_trackers/vega/shader.c
src/gallium/state_trackers/vega/vg_context.c
src/gallium/state_trackers/vega/vg_context.h
src/gallium/state_trackers/vega/vg_manager.c [new file with mode: 0644]
src/gallium/state_trackers/vega/vg_manager.h [new file with mode: 0644]
src/gallium/state_trackers/vega/vg_tracker.c
src/gallium/state_trackers/xorg/xorg_composite.c
src/gallium/state_trackers/xorg/xorg_exa.c
src/gallium/state_trackers/xorg/xorg_exa.h
src/gallium/state_trackers/xorg/xorg_renderer.c
src/gallium/state_trackers/xorg/xorg_renderer.h
src/gallium/state_trackers/xorg/xorg_xv.c
src/gallium/targets/Makefile.dri [new file with mode: 0644]
src/gallium/targets/Makefile.egl [new file with mode: 0644]
src/gallium/targets/SConscript
src/gallium/targets/SConscript.dri [new file with mode: 0644]
src/gallium/targets/dri-i915/Makefile [new file with mode: 0644]
src/gallium/targets/dri-i915/SConscript [new file with mode: 0644]
src/gallium/targets/dri-i915/dummy.c [new file with mode: 0644]
src/gallium/targets/dri-i965/Makefile [new file with mode: 0644]
src/gallium/targets/dri-i965/SConscript [new file with mode: 0644]
src/gallium/targets/dri-i965/dummy.c [new file with mode: 0644]
src/gallium/targets/dri-nouveau/Makefile [new file with mode: 0644]
src/gallium/targets/dri-radeong/Makefile [new file with mode: 0644]
src/gallium/targets/dri-radeong/SConscript [new file with mode: 0644]
src/gallium/targets/dri-radeong/dummy.c [new file with mode: 0644]
src/gallium/targets/dri-swrast/Makefile [new file with mode: 0644]
src/gallium/targets/dri-swrast/SConscript [new file with mode: 0644]
src/gallium/targets/dri-swrast/swrast_drm_api.c [new file with mode: 0644]
src/gallium/targets/dri-vmwgfx/Makefile [new file with mode: 0644]
src/gallium/targets/dri-vmwgfx/SConscript [new file with mode: 0644]
src/gallium/targets/dri-vmwgfx/dummy.c [new file with mode: 0644]
src/gallium/targets/egl-i915/Makefile [new file with mode: 0644]
src/gallium/targets/egl-i915/dummy.c [new file with mode: 0644]
src/gallium/targets/egl-i965/Makefile [new file with mode: 0644]
src/gallium/targets/egl-i965/dummy.c [new file with mode: 0644]
src/gallium/targets/egl-nouveau/Makefile [new file with mode: 0644]
src/gallium/targets/egl-nouveau/dummy.c [new file with mode: 0644]
src/gallium/targets/egl-radeon/Makefile [new file with mode: 0644]
src/gallium/targets/egl-radeon/dummy.c [new file with mode: 0644]
src/gallium/targets/egl-swrast/Makefile [new file with mode: 0644]
src/gallium/targets/egl-swrast/swrast_glue.c [new file with mode: 0644]
src/gallium/targets/egl-vmwgfx/Makefile [new file with mode: 0644]
src/gallium/targets/egl-vmwgfx/dummy.c [new file with mode: 0644]
src/gallium/targets/graw-xlib/SConscript [new file with mode: 0644]
src/gallium/targets/graw-xlib/graw.h [new file with mode: 0644]
src/gallium/targets/graw-xlib/graw_xlib.c [new file with mode: 0644]
src/gallium/targets/libgl-gdi/SConscript
src/gallium/targets/libgl-xlib/Makefile
src/gallium/targets/libgl-xlib/xlib.c
src/gallium/targets/xorg-i915/Makefile [new file with mode: 0644]
src/gallium/targets/xorg-i915/intel_xorg.c [new file with mode: 0644]
src/gallium/targets/xorg-i965/Makefile [new file with mode: 0644]
src/gallium/targets/xorg-i965/intel_xorg.c [new file with mode: 0644]
src/gallium/targets/xorg-nouveau/Makefile [new file with mode: 0644]
src/gallium/targets/xorg-nouveau/nouveau_xorg.c [new file with mode: 0644]
src/gallium/targets/xorg-radeon/Makefile [new file with mode: 0644]
src/gallium/targets/xorg-radeon/radeon_xorg.c [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/Makefile [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/SConscript [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/vmw_driver.h [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/vmw_hook.h [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/vmw_screen.c [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/vmw_video.c [new file with mode: 0644]
src/gallium/targets/xorg-vmwgfx/vmw_xorg.c [new file with mode: 0644]
src/gallium/winsys/SConscript
src/gallium/winsys/drm/Makefile [deleted file]
src/gallium/winsys/drm/Makefile.egl [deleted file]
src/gallium/winsys/drm/Makefile.template [deleted file]
src/gallium/winsys/drm/SConscript [deleted file]
src/gallium/winsys/drm/i965/Makefile [deleted file]
src/gallium/winsys/drm/i965/SConscript [deleted file]
src/gallium/winsys/drm/i965/dri/Makefile [deleted file]
src/gallium/winsys/drm/i965/dri/SConscript [deleted file]
src/gallium/winsys/drm/i965/egl/Makefile [deleted file]
src/gallium/winsys/drm/i965/egl/dummy.c [deleted file]
src/gallium/winsys/drm/i965/gem/Makefile [deleted file]
src/gallium/winsys/drm/i965/gem/SConscript [deleted file]
src/gallium/winsys/drm/i965/gem/i965_drm_api.c [deleted file]
src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c [deleted file]
src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h [deleted file]
src/gallium/winsys/drm/i965/xlib/Makefile [deleted file]
src/gallium/winsys/drm/i965/xlib/xlib_i965.c [deleted file]
src/gallium/winsys/drm/i965/xorg/Makefile [deleted file]
src/gallium/winsys/drm/i965/xorg/intel_xorg.c [deleted file]
src/gallium/winsys/drm/intel/Makefile [deleted file]
src/gallium/winsys/drm/intel/SConscript [deleted file]
src/gallium/winsys/drm/intel/dri/Makefile [deleted file]
src/gallium/winsys/drm/intel/dri/SConscript [deleted file]
src/gallium/winsys/drm/intel/egl/Makefile [deleted file]
src/gallium/winsys/drm/intel/egl/dummy.c [deleted file]
src/gallium/winsys/drm/intel/gem/Makefile [deleted file]
src/gallium/winsys/drm/intel/gem/SConscript [deleted file]
src/gallium/winsys/drm/intel/gem/intel_drm_api.c [deleted file]
src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c [deleted file]
src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c [deleted file]
src/gallium/winsys/drm/intel/gem/intel_drm_fence.c [deleted file]
src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h [deleted file]
src/gallium/winsys/drm/intel/xorg/Makefile [deleted file]
src/gallium/winsys/drm/intel/xorg/intel_xorg.c [deleted file]
src/gallium/winsys/drm/nouveau/Makefile [deleted file]
src/gallium/winsys/drm/nouveau/dri/Makefile [deleted file]
src/gallium/winsys/drm/nouveau/drm/Makefile [deleted file]
src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h [deleted file]
src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c [deleted file]
src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h [deleted file]
src/gallium/winsys/drm/nouveau/egl/Makefile [deleted file]
src/gallium/winsys/drm/nouveau/egl/dummy.c [deleted file]
src/gallium/winsys/drm/nouveau/xorg/Makefile [deleted file]
src/gallium/winsys/drm/nouveau/xorg/nouveau_xorg.c [deleted file]
src/gallium/winsys/drm/radeon/Makefile [deleted file]
src/gallium/winsys/drm/radeon/SConscript [deleted file]
src/gallium/winsys/drm/radeon/core/Makefile [deleted file]
src/gallium/winsys/drm/radeon/core/SConscript [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_buffer.c [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_buffer.h [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_drm.c [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_drm.h [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_r300.c [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_r300.h [deleted file]
src/gallium/winsys/drm/radeon/core/radeon_winsys.h [deleted file]
src/gallium/winsys/drm/radeon/dri/Makefile [deleted file]
src/gallium/winsys/drm/radeon/dri/SConscript [deleted file]
src/gallium/winsys/drm/radeon/egl/Makefile [deleted file]
src/gallium/winsys/drm/radeon/egl/dummy.c [deleted file]
src/gallium/winsys/drm/radeon/xorg/Makefile [deleted file]
src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c [deleted file]
src/gallium/winsys/drm/swrast/Makefile [deleted file]
src/gallium/winsys/drm/swrast/core/Makefile [deleted file]
src/gallium/winsys/drm/swrast/core/swrast_drm_api.c [deleted file]
src/gallium/winsys/drm/swrast/egl/Makefile [deleted file]
src/gallium/winsys/drm/swrast/egl/dummy.c [deleted file]
src/gallium/winsys/drm/vmware/Makefile [deleted file]
src/gallium/winsys/drm/vmware/SConscript [deleted file]
src/gallium/winsys/drm/vmware/core/Makefile [deleted file]
src/gallium/winsys/drm/vmware/core/SConscript [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_buffer.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_buffer.h [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_context.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_context.h [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_fence.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_fence.h [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_screen.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_screen.h [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_surface.c [deleted file]
src/gallium/winsys/drm/vmware/core/vmw_surface.h [deleted file]
src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h [deleted file]
src/gallium/winsys/drm/vmware/dri/Makefile [deleted file]
src/gallium/winsys/drm/vmware/dri/SConscript [deleted file]
src/gallium/winsys/drm/vmware/egl/Makefile [deleted file]
src/gallium/winsys/drm/vmware/egl/dummy.c [deleted file]
src/gallium/winsys/drm/vmware/xorg/Makefile [deleted file]
src/gallium/winsys/drm/vmware/xorg/SConscript [deleted file]
src/gallium/winsys/drm/vmware/xorg/vmw_driver.h [deleted file]
src/gallium/winsys/drm/vmware/xorg/vmw_hook.h [deleted file]
src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c [deleted file]
src/gallium/winsys/drm/vmware/xorg/vmw_screen.c [deleted file]
src/gallium/winsys/drm/vmware/xorg/vmw_video.c [deleted file]
src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c [deleted file]
src/gallium/winsys/gdi/SConscript [deleted file]
src/gallium/winsys/gdi/gdi_sw_winsys.c [deleted file]
src/gallium/winsys/gdi/gdi_sw_winsys.h [deleted file]
src/gallium/winsys/i915/drm/Makefile [new file with mode: 0644]
src/gallium/winsys/i915/drm/SConscript [new file with mode: 0644]
src/gallium/winsys/i915/drm/i915_drm_api.c [new file with mode: 0644]
src/gallium/winsys/i915/drm/i915_drm_batchbuffer.c [new file with mode: 0644]
src/gallium/winsys/i915/drm/i915_drm_buffer.c [new file with mode: 0644]
src/gallium/winsys/i915/drm/i915_drm_fence.c [new file with mode: 0644]
src/gallium/winsys/i915/drm/i915_drm_winsys.h [new file with mode: 0644]
src/gallium/winsys/i965/drm/Makefile [new file with mode: 0644]
src/gallium/winsys/i965/drm/SConscript [new file with mode: 0644]
src/gallium/winsys/i965/drm/i965_drm_api.c [new file with mode: 0644]
src/gallium/winsys/i965/drm/i965_drm_buffer.c [new file with mode: 0644]
src/gallium/winsys/i965/drm/i965_drm_winsys.h [new file with mode: 0644]
src/gallium/winsys/i965/xlib/Makefile [new file with mode: 0644]
src/gallium/winsys/i965/xlib/xlib_i965.c [new file with mode: 0644]
src/gallium/winsys/nouveau/drm/Makefile [new file with mode: 0644]
src/gallium/winsys/nouveau/drm/nouveau_dri.h [new file with mode: 0644]
src/gallium/winsys/nouveau/drm/nouveau_drm_api.c [new file with mode: 0644]
src/gallium/winsys/nouveau/drm/nouveau_drm_api.h [new file with mode: 0644]
src/gallium/winsys/null/Makefile [deleted file]
src/gallium/winsys/null/SConscript [deleted file]
src/gallium/winsys/null/null_sw_winsys.c [deleted file]
src/gallium/winsys/null/null_sw_winsys.h [deleted file]
src/gallium/winsys/radeon/drm/Makefile [new file with mode: 0644]
src/gallium/winsys/radeon/drm/SConscript [new file with mode: 0644]
src/gallium/winsys/radeon/drm/radeon_buffer.h [new file with mode: 0644]
src/gallium/winsys/radeon/drm/radeon_drm.c [new file with mode: 0644]
src/gallium/winsys/radeon/drm/radeon_drm.h [new file with mode: 0644]
src/gallium/winsys/radeon/drm/radeon_drm_buffer.c [new file with mode: 0644]
src/gallium/winsys/radeon/drm/radeon_r300.c [new file with mode: 0644]
src/gallium/winsys/radeon/drm/radeon_r300.h [new file with mode: 0644]
src/gallium/winsys/radeon/drm/radeon_winsys.h [new file with mode: 0644]
src/gallium/winsys/svga/drm/Makefile [new file with mode: 0644]
src/gallium/winsys/svga/drm/SConscript [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_buffer.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_buffer.h [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_context.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_context.h [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_fence.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_fence.h [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_screen.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_screen.h [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_screen_dri.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_screen_ioctl.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_screen_pools.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_screen_svga.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_surface.c [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmw_surface.h [new file with mode: 0644]
src/gallium/winsys/svga/drm/vmwgfx_drm.h [new file with mode: 0644]
src/gallium/winsys/sw/Makefile [new file with mode: 0644]
src/gallium/winsys/sw/dri/Makefile [new file with mode: 0644]
src/gallium/winsys/sw/dri/SConscript [new file with mode: 0644]
src/gallium/winsys/sw/dri/dri_sw_winsys.c [new file with mode: 0644]
src/gallium/winsys/sw/dri/dri_sw_winsys.h [new file with mode: 0644]
src/gallium/winsys/sw/drm/Makefile [new file with mode: 0644]
src/gallium/winsys/sw/drm/sw_drm_api.c [new file with mode: 0644]
src/gallium/winsys/sw/drm/sw_drm_api.h [new file with mode: 0644]
src/gallium/winsys/sw/gdi/SConscript [new file with mode: 0644]
src/gallium/winsys/sw/gdi/gdi_sw_winsys.c [new file with mode: 0644]
src/gallium/winsys/sw/gdi/gdi_sw_winsys.h [new file with mode: 0644]
src/gallium/winsys/sw/null/Makefile [new file with mode: 0644]
src/gallium/winsys/sw/null/SConscript [new file with mode: 0644]
src/gallium/winsys/sw/null/null_sw_winsys.c [new file with mode: 0644]
src/gallium/winsys/sw/null/null_sw_winsys.h [new file with mode: 0644]
src/gallium/winsys/sw/wrapper/Makefile [new file with mode: 0644]
src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c [new file with mode: 0644]
src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.h [new file with mode: 0644]
src/gallium/winsys/sw/xlib/Makefile [new file with mode: 0644]
src/gallium/winsys/sw/xlib/SConscript [new file with mode: 0644]
src/gallium/winsys/sw/xlib/xlib_sw_winsys.c [new file with mode: 0644]
src/gallium/winsys/xlib/Makefile [deleted file]
src/gallium/winsys/xlib/SConscript [deleted file]
src/gallium/winsys/xlib/xlib_sw_winsys.c [deleted file]
src/glx/dri2.c
src/glx/dri2_glx.c
src/glx/drisw_glx.c
src/glx/glxcmds.c
src/mesa/SConscript
src/mesa/drivers/common/meta.c
src/mesa/drivers/dri/Makefile.template
src/mesa/drivers/dri/common/dri_sw.c [deleted file]
src/mesa/drivers/dri/common/dri_sw.h [deleted file]
src/mesa/drivers/dri/common/dri_test.c [new file with mode: 0644]
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h
src/mesa/drivers/dri/common/drisw_util.c [new file with mode: 0644]
src/mesa/drivers/dri/common/drisw_util.h [new file with mode: 0644]
src/mesa/drivers/dri/i915/i830_texstate.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/intel_tris.c
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_disasm.c
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/brw_vs_emit.c
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/brw_wm_emit.c
src/mesa/drivers/dri/i965/brw_wm_glsl.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/gen6_clip_state.c
src/mesa/drivers/dri/i965/gen6_gs_state.c
src/mesa/drivers/dri/i965/gen6_vs_state.c
src/mesa/drivers/dri/intel/intel_blit.c
src/mesa/drivers/dri/intel/intel_buffers.c
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_context.h
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.h
src/mesa/drivers/dri/intel/intel_pixel_copy.c
src/mesa/drivers/dri/intel/intel_reg.h
src/mesa/drivers/dri/intel/intel_regions.c
src/mesa/drivers/dri/intel/intel_regions.h
src/mesa/drivers/dri/intel/intel_screen.c
src/mesa/drivers/dri/intel/intel_span.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_layout.c
src/mesa/drivers/dri/nouveau/nouveau_context.c
src/mesa/drivers/dri/nouveau/nouveau_driver.c
src/mesa/drivers/dri/nouveau/nouveau_fbo.c
src/mesa/drivers/dri/nouveau/nouveau_gldefs.h
src/mesa/drivers/dri/nouveau/nouveau_render.h
src/mesa/drivers/dri/nouveau/nouveau_render_t.c
src/mesa/drivers/dri/nouveau/nouveau_span.c
src/mesa/drivers/dri/nouveau/nouveau_state.c
src/mesa/drivers/dri/nouveau/nouveau_state.h
src/mesa/drivers/dri/nouveau/nouveau_texture.c
src/mesa/drivers/dri/nouveau/nouveau_texture.h
src/mesa/drivers/dri/nouveau/nouveau_util.h
src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
src/mesa/drivers/dri/nouveau/nv04_context.c
src/mesa/drivers/dri/nouveau/nv10_context.c
src/mesa/drivers/dri/nouveau/nv10_driver.h
src/mesa/drivers/dri/nouveau/nv10_state_fb.c
src/mesa/drivers/dri/nouveau/nv10_state_tex.c
src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
src/mesa/drivers/dri/nouveau/nv20_context.c
src/mesa/drivers/dri/nouveau/nv20_driver.h
src/mesa/drivers/dri/nouveau/nv20_state_fb.c
src/mesa/drivers/dri/nouveau/nv20_state_tex.c
src/mesa/drivers/dri/nouveau/nv20_state_tnl.c
src/mesa/drivers/dri/r200/r200_cmdbuf.c
src/mesa/drivers/dri/r200/r200_state.c
src/mesa/drivers/dri/r200/r200_tcl.c
src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c
src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_fragprog_common.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_vertprog.c
src/mesa/drivers/dri/r600/r700_state.c
src/mesa/drivers/dri/radeon/radeon_dma.c
src/mesa/drivers/dri/radeon/radeon_state.c
src/mesa/drivers/dri/swrast/Makefile
src/mesa/drivers/dri/swrast/swrast.c
src/mesa/drivers/dri/swrast/swrast_priv.h
src/mesa/drivers/dri/swrast/swrast_span.c
src/mesa/drivers/dri/swrast/swrast_spantemp.h
src/mesa/drivers/glslcompiler/Makefile
src/mesa/drivers/glslcompiler/glslcompiler.c
src/mesa/drivers/x11/glxapi.c
src/mesa/es/Makefile
src/mesa/es/main/mfeatures_es1.h [deleted file]
src/mesa/es/main/mfeatures_es2.h [deleted file]
src/mesa/es/main/stubs.c
src/mesa/glapi/gen/gl_x86_asm.py
src/mesa/glapi/glapi_entrypoint.c
src/mesa/glapi/glapi_execmem.c
src/mesa/glapi/glapi_nop.c
src/mesa/glapi/glapi_priv.h
src/mesa/main/bufferobj.c
src/mesa/main/context.c
src/mesa/main/debug.c
src/mesa/main/extensions.c
src/mesa/main/fbobject.c
src/mesa/main/get.c
src/mesa/main/get_gen.py
src/mesa/main/hash.c
src/mesa/main/image.h
src/mesa/main/imports.c
src/mesa/main/imports.h
src/mesa/main/matrix.c
src/mesa/main/mfeatures.h
src/mesa/main/mtypes.h
src/mesa/main/texparam.c
src/mesa/shader/lex.yy.c
src/mesa/shader/nvfragparse.c
src/mesa/shader/program_lexer.l
src/mesa/shader/slang/library/slang_common_builtin.gc
src/mesa/shader/slang/slang_compile.c
src/mesa/sources.mak
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom_framebuffer.c
src/mesa/state_tracker/st_atom_pixeltransfer.c
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_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_fbo.h
src/mesa/state_tracker/st_cb_flush.c
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_framebuffer.c
src/mesa/state_tracker/st_gen_mipmap.c
src/mesa/state_tracker/st_manager.c [new file with mode: 0644]
src/mesa/state_tracker/st_manager.h [new file with mode: 0644]
src/mesa/state_tracker/st_texture.c
src/mesa/state_tracker/st_texture.h
src/mesa/swrast/s_aatriangle.c
src/mesa/swrast/s_clear.c
src/mesa/swrast/s_texfilter.c
src/mesa/vbo/vbo_split_copy.c
src/mesa/x86/glapi_x86.S
windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj

index 4a81312046830ed00bc884de52bb37d52c1591c4..e0d852e534ef590a62c3792b201211437d263dd0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -243,7 +243,6 @@ MAIN_FILES = \
        $(DIRECTORY)/src/mesa/shader/descrip.mms                        \
        $(DIRECTORY)/src/mesa/shader/slang/*.[ch]                       \
        $(DIRECTORY)/src/mesa/shader/slang/descrip.mms                  \
-       $(DIRECTORY)/src/mesa/shader/slang/library/*.[ch]               \
        $(DIRECTORY)/src/mesa/shader/slang/library/*.gc                 \
        $(DIRECTORY)/src/mesa/shader/slang/library/Makefile             \
        $(DIRECTORY)/src/mesa/swrast/*.[ch]                             \
@@ -324,6 +323,7 @@ GALLIUM_FILES = \
        $(DIRECTORY)/src/gallium/*/Makefile                             \
        $(DIRECTORY)/src/gallium/*/SConscript                           \
        $(DIRECTORY)/src/gallium/*/*/Makefile                           \
+       $(DIRECTORY)/src/gallium/*/*/Makefile.egl                       \
        $(DIRECTORY)/src/gallium/*/*/Makefile.template                  \
        $(DIRECTORY)/src/gallium/*/*/SConscript                         \
        $(DIRECTORY)/src/gallium/*/*/*.[ch]                             \
@@ -379,15 +379,6 @@ SGI_GLU_FILES = \
        $(DIRECTORY)/src/glu/sgi/libtess/*.[ch]                         \
        $(DIRECTORY)/src/glu/sgi/libutil/*.[ch]
 
-MESA_GLU_FILES = \
-       $(DIRECTORY)/src/glu/mesa/README[12]            \
-       $(DIRECTORY)/src/glu/mesa/Makefile*             \
-       $(DIRECTORY)/src/glu/mesa/descrip.mms           \
-       $(DIRECTORY)/src/glu/mesa/mms_depend            \
-       $(DIRECTORY)/src/glu/mesa/*.def                 \
-       $(DIRECTORY)/src/glu/mesa/depend                \
-       $(DIRECTORY)/src/glu/mesa/*.[ch]
-
 GLW_FILES = \
        $(DIRECTORY)/src/glw/*.[ch]                     \
        $(DIRECTORY)/src/glw/Makefile*                  \
@@ -416,6 +407,14 @@ DEMO_FILES = \
        $(DIRECTORY)/progs/demos/*.cxx                  \
        $(DIRECTORY)/progs/demos/*.dat                  \
        $(DIRECTORY)/progs/demos/README                 \
+       $(DIRECTORY)/progs/egl/Makefile                 \
+       $(DIRECTORY)/progs/egl/*.[ch]                   \
+       $(DIRECTORY)/progs/es1/*/Makefile               \
+       $(DIRECTORY)/progs/es1/*/*.[ch]                 \
+       $(DIRECTORY)/progs/es2/*/Makefile               \
+       $(DIRECTORY)/progs/es2/*/*.[ch]                 \
+       $(DIRECTORY)/progs/openvg/*/Makefile            \
+       $(DIRECTORY)/progs/openvg/*/*.[ch]              \
        $(DIRECTORY)/progs/fbdev/Makefile               \
        $(DIRECTORY)/progs/fbdev/glfbdevtest.c          \
        $(DIRECTORY)/progs/objviewer/*.[ch]             \
@@ -450,11 +449,7 @@ GLUT_FILES = \
        $(DIRECTORY)/src/glut/glx/*.[ch]                \
        $(DIRECTORY)/src/glut/beos/*.[ch]               \
        $(DIRECTORY)/src/glut/beos/*.cpp                \
-       $(DIRECTORY)/src/glut/beos/Makefile             \
-       $(DIRECTORY)/src/glut/fbdev/Makefile            \
-       $(DIRECTORY)/src/glut/fbdev/*[ch]               \
-       $(DIRECTORY)/src/glut/mini/*[ch]                \
-       $(DIRECTORY)/src/glut/mini/glut.pc.in           \
+       $(DIRECTORY)/src/glut/beos/Makefile
 
 DEPEND_FILES = \
        $(TOP)/src/mesa/depend          \
index 6ed44ddd0677181de86101896643b6404dd879fc..5d44b6efde625f73ed9d104562c461f861f99cc9 100644 (file)
@@ -52,7 +52,7 @@ opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statet
 opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
                      ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe']))
 opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
-                     ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
+                     ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib']))
 
 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
 
index f50fb7dd0935ffd0aafaaedb11e672ae0c89a55e..b6cc9b3b73edda9449e7bbf9969947e3889c3c01 100644 (file)
@@ -24,8 +24,8 @@ RADEON_CFLAGS = @RADEON_CFLAGS@
 RADEON_LDFLAGS = @RADEON_LDFLAGS@
 INTEL_LIBS = @INTEL_LIBS@
 INTEL_CFLAGS = @INTEL_CFLAGS@
-X_LIBS = @X_LIBS@
-X_CFLAGS = @X_CFLAGS@
+X11_LIBS = @X11_LIBS@
+X11_CFLAGS = @X11_CFLAGS@
 
 # Assembler
 MESA_ASM_SOURCES = @MESA_ASM_SOURCES@
@@ -76,7 +76,6 @@ GALLIUM_DIRS = @GALLIUM_DIRS@
 GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@
 GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@
 GALLIUM_TARGET_DIRS = @GALLIUM_TARGET_DIRS@
-GALLIUM_WINSYS_DRM_DIRS = @GALLIUM_WINSYS_DRM_DIRS@
 GALLIUM_STATE_TRACKERS_DIRS = @GALLIUM_STATE_TRACKERS_DIRS@
 GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
index 8fbf8dd219a0cb4d0e2e4f6c33391b80092c7941..77a9898775c9ec1c1672bee321469d222450a422 100644 (file)
@@ -100,9 +100,8 @@ GALLIUM_DIRS = auxiliary drivers state_trackers
 GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
 GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
-GALLIUM_WINSYS_DIRS = null xlib drm
+GALLIUM_WINSYS_DIRS = sw sw/xlib
 GALLIUM_TARGET_DIRS = libgl-xlib
-GALLIUM_WINSYS_DRM_DIRS = swrast
 GALLIUM_STATE_TRACKERS_DIRS = glx vega
 
 # native displays EGL should support
index 306b9e01f47a4eafc2c87ba9ce8fee3c10af6052..0908dba9e05660b0f9e6c20a1a25c1b4d0de78c7 100644 (file)
@@ -6,7 +6,7 @@ CONFIG_NAME = linux-cell
 
 
 # Omiting other gallium drivers:
-GALLIUM_DRIVERS_DIRS = cell softpipe trace
+GALLIUM_DRIVERS_DIRS = cell softpipe trace identity
 
 
 # Compiler and flags
index d362fd8b377bd393e5d4ac1d23452547cba0ba6b..e21a3e9594364e3c32643ab253b4173a0d9b8a7b 100644 (file)
@@ -58,9 +58,8 @@ PROGRAM_DIRS := egl $(PROGRAM_DIRS)
 EGL_DRIVERS_DIRS = glx
 
 DRIVER_DIRS = dri
-GALLIUM_WINSYS_DIRS = null xlib drm
-GALLIUM_TARGET_DIRS =
-GALLIUM_WINSYS_DRM_DIRS = vmware intel i965
+GALLIUM_WINSYS_DIRS = sw sw/xlib drm/vmware drm/intel drm/i965
+GALLIUM_TARGET_DIRS = egl-swrast
 GALLIUM_STATE_TRACKERS_DIRS = egl
 
 DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \
index 27e082ebf7e2b85b37144e03b6d830edd4762327..3a15f1d6d8bab8c0cbe726bd2f8cb6249e783c67 100644 (file)
@@ -10,7 +10,7 @@ CONFIG_NAME = linux-llvm
 GALLIUM_DRIVERS_DIRS += llvmpipe
 
 OPT_FLAGS = -O3 -ansi -pedantic
-ARCH_FLAGS = -m32 -mmmx -msse -msse2 -mstackrealign
+ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign
 
 DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DDRAW_LLVM -DHAVE_UDIS86
 
@@ -24,6 +24,8 @@ ifeq ($(LLVM_VERSION),)
   MESA_LLVM=0
 else
   MESA_LLVM=1
+  HAVE_LLVM := 0x0$(subst .,0,$(LLVM_VERSION:svn=))
+  DEFINES += -DHAVE_LLVM=$(HAVE_LLVM)
 #  $(info Using LLVM version: $(LLVM_VERSION))
 endif
 
index 76054aad14e25160a5d2ecdb9b91b30dd033d459..32fe40fb848f6072a33221c61b3036fae0af20b0 100644 (file)
@@ -24,5 +24,5 @@ GALLIUM_STATE_TRACKERS_DIRS = es
 # build egl_x11_{swrast,i915}.so
 GALLIUM_DRIVERS_DIRS += trace i915
 GALLIUM_STATE_TRACKERS_DIRS += egl
-GALLIUM_WINSYS_DIRS += drm
-GALLIUM_WINSYS_DRM_DIRS += intel swrast
+GALLIUM_WINSYS_DIRS += drm/intel
+GALLIUM_TARGET_DIRS += egl-swrast egl-i915
index 0f51097ef623427b03ef3437f6579e40592d90d4..f2e87f4d4c2c102f6fe2263ccf8d5fc706a71feb 100644 (file)
@@ -461,21 +461,20 @@ SRC_DIRS="glew"
 GLU_DIRS="sgi"
 GALLIUM_DIRS="auxiliary drivers state_trackers"
 GALLIUM_TARGET_DIRS=""
-GALLIUM_WINSYS_DIRS=""
-GALLIUM_WINSYS_DRM_DIRS=""
+GALLIUM_WINSYS_DIRS="sw"
 GALLIUM_DRIVERS_DIRS="softpipe failover trace identity"
 GALLIUM_STATE_TRACKERS_DIRS=""
 
 case "$mesa_driver" in
 xlib)
     DRIVER_DIRS="x11"
-    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib"
+    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
     GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS libgl-xlib"
     ;;
 dri)
     SRC_DIRS="$SRC_DIRS glx"
     DRIVER_DIRS="dri"
-    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib drm"
+    GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib sw/dri sw/drm"
     ;;
 osmesa)
     DRIVER_DIRS="osmesa"
@@ -487,7 +486,6 @@ AC_SUBST([DRIVER_DIRS])
 AC_SUBST([GALLIUM_DIRS])
 AC_SUBST([GALLIUM_TARGET_DIRS])
 AC_SUBST([GALLIUM_WINSYS_DIRS])
-AC_SUBST([GALLIUM_WINSYS_DRM_DIRS])
 AC_SUBST([GALLIUM_DRIVERS_DIRS])
 AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
 
@@ -548,9 +546,13 @@ else
 fi
 dnl Use the autoconf macro if no pkg-config files
 if test "$x11_pkgconfig" = yes; then
-    PKG_CHECK_MODULES([X], [x11])
+    PKG_CHECK_MODULES([X11], [x11])
 else
     AC_PATH_XTRA
+    test -z "$X11_CFLAGS" && X11_CFLAGS="$X_CFLAGS"
+    test -z "$X11_LIBS" && X11_LIBS="$X_LIBS -lX11"
+    AC_SUBST([X11_CFLAGS])
+    AC_SUBST([X11_LIBS])
 fi
 
 dnl Try to tell the user that the --x-* options are only used when
@@ -1178,7 +1180,7 @@ AC_ARG_ENABLE([gallium],
     [enable_gallium="$enableval"],
     [enable_gallium=yes])
 if test "x$enable_gallium" = xyes; then
-    SRC_DIRS="$SRC_DIRS gallium gallium/winsys"
+    SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets"
 fi
 
 dnl
@@ -1203,13 +1205,15 @@ yes)
         ;;
     dri)
         GALLIUM_STATE_TRACKERS_DIRS="dri"
+        HAVE_ST_DRI="yes"
         if test "x$enable_egl" = xyes; then
             GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
+            HAVE_ST_EGL="yes"
         fi
         # 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_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
-            HAVE_XORG="no")
+            HAVE_ST_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
+            HAVE_ST_XORG="no")
         ;;
     esac
     ;;
@@ -1221,15 +1225,22 @@ yes)
             AC_MSG_ERROR([state tracker '$tracker' doesn't exist])
 
         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([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED])
             PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED])
-            HAVE_XORG="yes"
+            HAVE_ST_XORG="yes"
             ;;
         es)
             # mesa/es is required to build es state tracker
@@ -1241,7 +1252,7 @@ yes)
     ;;
 esac
 
-if test "x$HAVE_XORG" = xyes; then
+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")
@@ -1305,6 +1316,25 @@ AC_ARG_WITH([max-height],
            [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
 )
 
+dnl
+dnl Gallium helper functions
+dnl
+gallium_check_st() {
+    if test "x$HAVE_ST_DRI" = xyes || test "x$HAVE_ST_EGL" = xyes || test "x$HAVE_ST_XORG" = xyes; then
+         GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS $1"
+    fi
+    if test "x$HAVE_ST_DRI" = xyes && test "x$2" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $2"
+    fi
+    if test "x$HAVE_ST_EGL" = xyes && test "x$3" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3"
+    fi
+    if test "x$HAVE_ST_XORG" = xyes && test "x$4" != x; then
+         GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $4"
+    fi
+}
+
+
 dnl
 dnl Gallium SVGA configuration
 dnl
@@ -1314,8 +1344,8 @@ AC_ARG_ENABLE([gallium-svga],
     [enable_gallium_svga="$enableval"],
     [enable_gallium_svga=auto])
 if test "x$enable_gallium_svga" = xyes; then
-    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS vmware"
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
+    gallium_check_st "svga/drm" "dri-vmwgfx" "egl-vmwgfx" "xorg-vmwgfx"
 elif test "x$enable_gallium_svga" = xauto; then
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
 fi
@@ -1329,8 +1359,8 @@ AC_ARG_ENABLE([gallium-intel],
     [enable_gallium_intel="$enableval"],
     [enable_gallium_intel=auto])
 if test "x$enable_gallium_intel" = xyes; then
-    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel i965"
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965"
+    gallium_check_st "i915/drm i965/drm" "dri-i915 dri-i965" "egl-i915 egl-i965" "xorg-i915 xorg-i965"
 elif test "x$enable_gallium_intel" = xauto; then
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915 i965"
 fi
@@ -1344,8 +1374,8 @@ AC_ARG_ENABLE([gallium-radeon],
     [enable_gallium_radeon="$enableval"],
     [enable_gallium_radeon=auto])
 if test "x$enable_gallium_radeon" = xyes; then
-    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS radeon"
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
+    gallium_check_st "radeon/drm" "dri-radeong" "egl-radeon" "xorg-radeon"
 elif test "x$enable_gallium_radeon" = xauto; then
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
 fi
@@ -1359,8 +1389,8 @@ AC_ARG_ENABLE([gallium-nouveau],
     [enable_gallium_nouveau="$enableval"],
     [enable_gallium_nouveau=no])
 if test "x$enable_gallium_nouveau" = xyes; then
-    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau"
     GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50"
+    gallium_check_st "nouveau/drm" "dri-nouveau" "egl-nouveau" "xorg-nouveau"
 fi
 
 dnl
@@ -1368,11 +1398,16 @@ dnl Gallium swrast configuration
 dnl
 AC_ARG_ENABLE([gallium-swrast],
     [AS_HELP_STRING([--enable-gallium-swrast],
-        [build gallium swrast @<:@default=disabled@:>@])],
+        [build gallium swrast @<:@default=auto@:>@])],
     [enable_gallium_swrast="$enableval"],
     [enable_gallium_swrast=auto])
-if test "x$enable_gallium_swrast" = xyes; then
-    GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS swrast"
+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$HAVE_ST_EGL" = xyes; then
+        GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-swrast"
+    fi
 fi
 
 dnl prepend CORE_DIRS to SRC_DIRS
@@ -1430,7 +1465,6 @@ if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then
     echo "        Gallium dirs:    $GALLIUM_DIRS"
     echo "        Target dirs:     $GALLIUM_TARGET_DIRS"
     echo "        Winsys dirs:     $GALLIUM_WINSYS_DIRS"
-    echo "        Winsys drm dirs:$GALLIUM_WINSYS_DRM_DIRS"
     echo "        Driver dirs:     $GALLIUM_DRIVERS_DIRS"
     echo "        Trackers dirs:   $GALLIUM_STATE_TRACKERS_DIRS"
 else
index 889edefbce17f5b4b9e4f17e3286ca1e8017fea5..a485878af2d1003b7f72b0aab61b78cd2df3c938 100644 (file)
@@ -16,6 +16,7 @@ GLSL changes (GL_EXT_gpu_shader4, etc)                not started
 Conditional rendering (GL_NV_conditional_render)      DONE (swrast & softpipe)
 Map buffer subranges (GL_APPLE_flush_buffer_range)    not started
 Float textures, renderbuffers                         some infrastructure done
+ (incl. GL_EXT_packed_float, GL_EXT_shared_exponent)
 Framebuffer objects (GL_EXT_framebuffer_object)       DONE
 Half-float                                            some infrastructure done
 Multisample blit                                      DONE
index 55907f6cfac2dfb8bfa60aa98ce708eecc9e58a1..e960309fc475957f7202030cd4bec314649e95b0 100644 (file)
@@ -106,11 +106,11 @@ noted that the classic <code>libGL</code> is not a state tracker and cannot be
 used with EGL (unless the EGL driver in use is <code>egl_glx</code>).  To build
 the OpenGL state tracker, one may append <code>glx</code> to
 <code>--with-state-trackers</code> and manually build
-<code>src/gallium/winsys/xlib/</code>.</p>
+<code>src/gallium/targets/libgl-xlib/</code>.</p>
 
 <h2>Use EGL</h2>
 
-<p> The demos for OpenGL ES and OpenVG can be found in <code>progs/es1/</code>,
+<p>The demos for OpenGL ES and OpenVG can be found in <code>progs/es1/</code>,
 <code>progs/es2/</code> and <code>progs/openvg/</code>.  You can use them to
 test your build.  For example,</p>
 
index 0a0be715c1be226181a9822eaf55c50fc67d7399..4e4b6976a88c5d61849325420c90a74770f53998 100644 (file)
 
 <H1>News</H1>
 
+
+<h2>March 28, 2010</h2>
+<p>
+<a href="relnotes-7.7.1.html">Mesa 7.7.1</a> is released.  This is a bug-fix
+release fixing issues found in the 7.7 release.
+</p>
+<p>
+Also, <a href="relnotes-7.8.html">Mesa 7.8</a> is released.  This is a new
+development release.
+</p>
+
+
+
 <h2>December 21, 2009</h2>
 <p>
 <a href="relnotes-7.6.1.html">Mesa 7.6.1</a> is released.  This is a bug-fix
index c3d42c1d546da95823e6ea98bf29da1f84a46837..00b36714cb58355df6e5ea73641dce56a5385e7b 100644 (file)
@@ -8,7 +8,7 @@
 
 <body bgcolor="#eeeeee">
 
-<H1>Mesa 7.7.1 Release Notes / date tbd</H1>
+<H1>Mesa 7.7.1 Release Notes / March 28, 2010</H1>
 
 <p>
 Mesa 7.7.1 is a bug-fix release.
@@ -26,16 +26,18 @@ for DRI hardware acceleration.
 
 <h2>MD5 checksums</h2>
 <pre>
-tbd
+3ab0638cfa7ce8157337a229cf0db2c4  MesaLib-7.7.1.tar.gz
+46664d99e03f1e3ac078a7fea02af115  MesaLib-7.7.1.tar.bz2
+4e73ba8abb59aff79485eb95d7cefff7  MesaLib-7.7.1.zip
+bf1b108983995f7a712cf3343df1c918  MesaDemos-7.7.1.tar.gz
+aeb39645d80d656e0adebaa09e5bcd03  MesaDemos-7.7.1.tar.bz2
+01c49b7454fd292244eaf8bdc6ed8cf0  MesaDemos-7.7.1.zip
+37ec6386693dcb6dc770d1efd63a7a93  MesaGLUT-7.7.1.tar.gz
+1e16c85282f843791a21f7bc7b6a1ca8  MesaGLUT-7.7.1.tar.bz2
+d352c9e36a8e4d1059f4abc017b131e0  MesaGLUT-7.7.1.zip
 </pre>
 
 
-<h2>New features</h2>
-<ul>
-<li>tbd
-</ul>
-
-
 <h2>Bug fixes</h2>
 <ul>
 <li>Assorted fixes to VMware SVGA gallium driver.
@@ -45,6 +47,12 @@ tbd
 <li>Gallium SSE codegen for XPD didn't always work.
 <li>Fixed Windows build.
 <li>Fixed broken glMultiDrawElements().
+<li>Silence bogus GL errors generated in glxinfo.
+<li>Fixed several render to texture bugs.
+<li>Assorted bug fixes in Mesa/Gallium state tracker including
+    glCopy/DrawPixels() to FBOs.
+<li>Assorted fixes to Gallium drivers.
+<li>Fixed broken glPush/PopClientAttrib() for vertex arrays in GLX code.
 </ul>
 
 
index ebe3d498b5762a9c060a66701981dde32f3b274f..1fed087d79b7e8d0ac7cad3fa648f881a4df337e 100644 (file)
@@ -8,7 +8,7 @@
 
 <body bgcolor="#eeeeee">
 
-<H1>Mesa 7.8 Release Notes / date TBD</H1>
+<H1>Mesa 7.8 Release Notes / March 28, 2010</H1>
 
 <p>
 Mesa 7.8 is a new development release.
@@ -28,7 +28,15 @@ for DRI hardware acceleration.
 
 <h2>MD5 checksums</h2>
 <pre>
-tbd
+5fcfde5383eccb3e9fd665f08a0ea59b  MesaLib-7.8.tar.gz
+85cb891eecb89aae4fdd3499cccd934b  MesaLib-7.8.tar.bz2
+754f39593006effc1c8ec3c27c2f1296  MesaLib-7.8.zip
+c3869c29fa6c3dbdd763f7428d271e12  MesaDemos-7.8.tar.gz
+9fe8ec184c7f78691e43c4c0a7f97d56  MesaDemos-7.8.tar.bz2
+063a96947f7b83d4ad789c6cf291b184  MesaDemos-7.8.zip
+5f4246756b7daaddb4fb3f970cad1e28  MesaGLUT-7.8.tar.gz
+ca7048a4aa7a437dcc84cc2c7d731336  MesaGLUT-7.8.tar.bz2
+b54581aeb79b585b158d6a32f94feff2  MesaGLUT-7.8.zip
 </pre>
 
 
index bd02335a803d0ccd4bb9512c9b8bc0b59e0f1f16..750884cf36c448c8acfb7fd98edb0d0d70bfa5e7 100644 (file)
@@ -14,10 +14,6 @@ This page describes the features and status of Mesa's support for the
 OpenGL Shading Language</a>.
 </p>
 
-<p>
-Last updated on 15 December 2008.
-</p>
-
 <p>
 Contents
 </p>
index b292840f917d94ab33733fd21102f9f09443a68d..43d2e896b0b2ec1f2aceb363d54da077b25af6c4 100644 (file)
 #define glEdgeFlagPointerListIBM               MANGLE(EdgeFlagPointerListIBM)
 #define glEdgeFlagPointer              MANGLE(EdgeFlagPointer)
 #define glEdgeFlagv            MANGLE(EdgeFlagv)
+#define glEGLImageTargetRenderbufferStorageOES         MANGLE(EGLImageTargetRenderbufferStorageOES)
+#define glEGLImageTargetTexture2DOES           MANGLE(EGLImageTargetTexture2DOES)
 #define glElementPointerAPPLE          MANGLE(ElementPointerAPPLE)
 #define glElementPointerATI            MANGLE(ElementPointerATI)
 #define glEnableClientStateIndexedEXT          MANGLE(EnableClientStateIndexedEXT)
index 1d4e82e154a4dd93a8b90f2ac0b91979dacff937..fa9b7c4bf2197ad09e6bbfd6c292e1cc8d1bcd0f 100644 (file)
 #define DRI_INTERFACE_H
 
 /* For archs with no drm.h */
-#if !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__GNU__)
+#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__)
+#ifndef __NOT_HAVE_DRM_H
+#define __NOT_HAVE_DRM_H
+#endif
+#endif
+
+#ifndef __NOT_HAVE_DRM_H
 #include <drm.h>
 #else
 typedef unsigned int drm_context_t;
@@ -410,15 +416,15 @@ struct __DRIswrastLoaderExtensionRec {
      * Put image to drawable
      */
     void (*putImage)(__DRIdrawable *drawable, int op,
-                    int x, int y, int width, int height, char *data,
-                    void *loaderPrivate);
+                    int x, int y, int width, int height,
+                    char *data, void *loaderPrivate);
 
     /**
-     * Get image from drawable
+     * Get image from readable
      */
-    void (*getImage)(__DRIdrawable *drawable,
-                    int x, int y, int width, int height, char *data,
-                    void *loaderPrivate);
+    void (*getImage)(__DRIdrawable *readable,
+                    int x, int y, int width, int height,
+                    char *data, void *loaderPrivate);
 };
 
 /**
index aa6640cf7a6f1b660aeddbaae25cc594b7142cc5..a90e13b4cb484e9ea057e0fade8ac741503ec9e4 100644 (file)
@@ -56,4 +56,5 @@ SConscript([
     'wgl/SConscript',
     'perf/SConscript',
     'gallium/unit/SConscript',
+#   'gallium/raw/SConscript',
 ])
index 0b8df1bb66916edbd4c73d7c9598178cac579c4c..8ab5242d91ce6488d874e6af597c6ae23b20de34 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Dissolve between two images using randomized stencil buffer
+ * Dissolve between two images using randomized/patterned stencil buffer
  * and varying stencil ref.
  *
  * Brian Paul
@@ -9,6 +9,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <math.h>
 #include <GL/glut.h>
 #include "readtex.h"
@@ -28,6 +29,8 @@ static GLfloat ScaleX[2], ScaleY[2];
 
 static GLubyte StencilRef = 0;
 
+static int Mode = 0;
+
 
 static void
 Idle(void)
@@ -38,13 +41,114 @@ Idle(void)
 
 
 static void
-RandomizeStencilBuffer(void)
+FillRandomPixels(GLubyte *b)
 {
-   GLubyte *b = malloc(WinWidth * WinHeight);
    int i;
    for (i = 0; i < WinWidth * WinHeight; i++) {
       b[i] = rand() & 0xff;
    }
+}
+
+
+static void
+FillRandomRects(GLubyte *b)
+{
+   int i;
+
+   memset(b, 0, WinWidth * WinHeight);
+
+   for (i = 0; i < 256; i++) {
+      int x = rand() % WinWidth;
+      int y = rand() % WinHeight;
+      int w = rand() % 60;
+      int h = rand() % 60;
+      int ix, iy;
+
+      if (x + w > WinWidth)
+         w = WinWidth - x;
+      if (y + h > WinHeight)
+         h = WinHeight - y;
+
+      for (iy = 0; iy < h; iy++) {
+         for (ix = 0; ix < w; ix++) {
+            int p = (y + iy) * WinWidth + x + ix;
+            b[p] = i;
+         }
+      }
+   }
+}
+
+
+static void
+FillWipe(GLubyte *b)
+{
+   int iy, ix;
+
+   memset(b, 0, WinWidth * WinHeight);
+
+   for (iy = 0; iy < WinHeight; iy++) {
+      for (ix = 0; ix < WinWidth; ix++) {
+         int p = iy * WinWidth + ix;
+         b[p] = 2 * ix + iy / 2;
+      }
+   }
+}
+
+
+static void
+FillMoire(GLubyte *b)
+{
+   int iy, ix;
+
+   memset(b, 0, WinWidth * WinHeight);
+
+   for (iy = 0; iy < WinHeight; iy++) {
+      for (ix = 0; ix < WinWidth; ix++) {
+         int p = iy * WinWidth + ix;
+         b[p] = (ix / 2) * (ix / 2) - (iy / 2) * (iy / 2);
+      }
+   }
+}
+
+
+static void
+FillWaves(GLubyte *b)
+{
+   int iy, ix;
+
+   memset(b, 0, WinWidth * WinHeight);
+
+   for (iy = 0; iy < WinHeight; iy++) {
+      for (ix = 0; ix < WinWidth; ix++) {
+         int p = iy * WinWidth + ix;
+         float x = 8.0 * 3.1415 * ix / (float) WinWidth;
+         b[p] = (int) (25.0 * sin(x) ) - iy*2;
+      }
+   }
+}
+
+
+typedef void (*FillFunc)(GLubyte *b);
+
+
+static FillFunc Funcs[] = {
+   FillRandomPixels,
+   FillRandomRects,
+   FillWipe,
+   FillMoire,
+   FillWaves
+};
+
+#define NUM_MODES (sizeof(Funcs) / sizeof(Funcs[0]))
+
+
+
+static void
+InitStencilBuffer(void)
+{
+   GLubyte *b = malloc(WinWidth * WinHeight);
+
+   Funcs[Mode](b);
 
    glStencilFunc(GL_ALWAYS, 0, ~0);
    glPixelZoom(1.0, 1.0);
@@ -54,7 +158,6 @@ RandomizeStencilBuffer(void)
 }
 
 
-
 static void
 Draw(void)
 {
@@ -85,7 +188,7 @@ Reshape(int width, int height)
    glLoadIdentity();
    glTranslatef(0.0, 0.0, -15.0);
 
-   RandomizeStencilBuffer();
+   InitStencilBuffer();
 
    ScaleX[0] = (float) width / ImgWidth[0];
    ScaleY[0] = (float) height / ImgHeight[0];
@@ -102,12 +205,26 @@ Key(unsigned char key, int x, int y)
    (void) y;
    switch (key) {
    case 'a':
+   case ' ':
       Anim = !Anim;
       if (Anim)
          glutIdleFunc(Idle);
       else
          glutIdleFunc(NULL);
       break;
+   case 'i':
+      InitStencilBuffer();
+      break;
+   case '-':
+      StencilRef--;
+      break;
+   case '+':
+      StencilRef++;
+      break;
+   case 'm':
+      Mode = (Mode + 1) % NUM_MODES;
+      InitStencilBuffer();
+      break;
    case 27:
       glutDestroyWindow(Win);
       exit(0);
@@ -143,8 +260,8 @@ Init(void)
 int
 main(int argc, char *argv[])
 {
-   glutInit(&argc, argv);
    glutInitWindowSize(WinWidth, WinHeight);
+   glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
    Win = glutCreateWindow(argv[0]);
    glutReshapeFunc(Reshape);
@@ -153,6 +270,14 @@ main(int argc, char *argv[])
    if (Anim)
       glutIdleFunc(Idle);
    Init();
+
+   printf("Keys:\n");
+   printf("  a/SPACE  toggle animation\n");
+   printf("  +/-      single step\n");
+   printf("  i        re-init pattern\n");
+   printf("  m        change pattern/dissolve mode\n");
+   printf("  ESC      exit\n");
+
    glutMainLoop();
    return 0;
 }
index 5f51104fed6fbc6d3bda0f8d852e260fbf49180a..890240f9a3898a9ee85170a3f98c49224968fe9a 100644 (file)
@@ -57,13 +57,13 @@ peglgears: peglgears.o $(HEADERS) $(LIB_DEP)
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) -lm
 
 xeglgears: xeglgears.o $(HEADERS) $(LIB_DEP)
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X_LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS)
 
 xeglthreads: xeglthreads.o $(HEADERS) $(LIB_DEP)
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X_LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lpthread -lm $(X11_LIBS)
 
 xegl_tri: xegl_tri.o $(HEADERS) $(LIB_DEP)
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X_LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS)
 
 clean:
        -rm -f *.o *~
index d7fbdb10ac3f5e143c1fc981fd28fa515e2b4dee..9f6d787dcb263889226d76a6c64b1e83ef1cfc7c 100644 (file)
 from gallium import *
 
 
-def make_image(surface):
-    data = surface.get_tile_rgba8(0, 0, surface.width, surface.height)
+def make_image(ctx, surface):
+    data = ctx.surface_read_rgba8(surface, 0, 0, surface.width, surface.height)
 
     import Image
     outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1)
     return outimage
 
-def save_image(filename, surface):
-    outimage = make_image(surface)
+def save_image(ctx, surface, filename):
+    outimage = make_image(ctx, surface)
     outimage.save(filename, "PNG")
 
-def show_image(surface):
-    outimage = make_image(surface)
+def show_image(ctx, surface):
+    outimage = make_image(ctx, surface)
     
     import Tkinter as tk
     from PIL import Image, ImageTk
@@ -216,10 +216,10 @@ def test(dev):
 
     ctx.flush()
     
-    show_image(cbuf)
-    #show_image(zbuf)
-    #save_image('cbuf.png', cbuf)
-    #save_image('zbuf.png', zbuf)
+    show_image(ctx, cbuf)
+    show_image(ctx, zbuf)
+    save_image(ctx, cbuf, 'cbuf.png')
+    save_image(ctx, zbuf, 'zbuf.png')
 
 
 
diff --git a/progs/gallium/raw/SConscript b/progs/gallium/raw/SConscript
new file mode 100644 (file)
index 0000000..073b979
--- /dev/null
@@ -0,0 +1,17 @@
+Import('*')
+
+env = env.Clone()
+
+env.Prepend(LIBPATH = [graw.dir])
+env.Prepend(LIBS = [graw.name])
+
+progs = [
+    'clear'
+]
+
+for prog in progs:
+    env.Program(
+        target = prog,
+        source = prog + '.c',
+    )
+
diff --git a/progs/gallium/raw/clear.c b/progs/gallium/raw/clear.c
new file mode 100644 (file)
index 0000000..5ef5254
--- /dev/null
@@ -0,0 +1,95 @@
+/* Display a cleared blue window.  This demo has no dependencies on
+ * any utility code, just the graw interface and gallium.
+ */
+
+#include "state_tracker/graw.h"
+#include "pipe/p_screen.h"
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include <unistd.h>             /* for sleep() */
+
+#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
+
+enum pipe_format formats[] = {
+   PIPE_FORMAT_R8G8B8A8_UNORM,
+   PIPE_FORMAT_B8G8R8A8_UNORM,
+   PIPE_FORMAT_NONE
+};
+
+static const int WIDTH = 300;
+static const int HEIGHT = 300;
+
+int main( int argc, char *argv[] )
+{
+   struct pipe_screen *screen;
+   struct pipe_context *pipe;
+   struct pipe_surface *surf;
+   struct pipe_framebuffer_state fb;
+   struct pipe_texture *tex, templat;
+   void *window = NULL;
+   float clear_color[4] = {1,0,1,1};
+   int i;
+
+   screen = graw_init();
+   if (screen == NULL)
+      exit(1);
+
+   for (i = 0; 
+        window == NULL && formats[i] != PIPE_FORMAT_NONE;
+        i++) {
+      
+      window = graw_create_window(0,0,300,300, formats[i]);
+   }
+   
+   if (window == NULL)
+      exit(2);
+   
+   pipe = screen->context_create(screen, NULL);
+   if (pipe == NULL)
+      exit(3);
+
+   templat.target = PIPE_TEXTURE_2D;
+   templat.format = formats[i];
+   templat.width0 = WIDTH;
+   templat.height0 = HEIGHT;
+   templat.depth0 = 1;
+   templat.last_level = 0;
+   templat.nr_samples = 1;
+   templat.tex_usage = (PIPE_TEXTURE_USAGE_RENDER_TARGET |
+                        PIPE_TEXTURE_USAGE_DISPLAY_TARGET);
+   
+   tex = screen->texture_create(screen,
+                                &templat);
+   if (tex == NULL)
+      exit(4);
+
+   surf = screen->get_tex_surface(screen, tex, 0, 0, 0,
+                                  PIPE_TEXTURE_USAGE_RENDER_TARGET |
+                                  PIPE_TEXTURE_USAGE_DISPLAY_TARGET);
+   if (surf == NULL)
+      exit(5);
+
+   memset(&fb, 0, sizeof fb);
+   fb.nr_cbufs = 1;
+   fb.width = WIDTH;
+   fb.height = HEIGHT;
+   fb.cbufs[0] = surf;
+
+   pipe->set_framebuffer_state(pipe, &fb);
+   pipe->clear(pipe, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+   pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+   /* At the moment, libgraw includes/makes available all the symbols
+    * from gallium/auxiliary, including these debug helpers.  Will
+    * eventually want to bless some of these paths, and lock the
+    * others down so they aren't accessible from test programs.
+    */
+   if (0)
+      debug_dump_surface_bmp(pipe, "result.bmp", surf);
+
+   screen->flush_frontbuffer(screen, surf, window);
+
+   sleep(100);
+   return 0;
+}
diff --git a/progs/gallium/trivial/.gitignore b/progs/gallium/trivial/.gitignore
new file mode 100644 (file)
index 0000000..af6cded
--- /dev/null
@@ -0,0 +1,3 @@
+tri
+quad-tex
+result.bmp
diff --git a/progs/gallium/trivial/Makefile b/progs/gallium/trivial/Makefile
new file mode 100644 (file)
index 0000000..2b8af1a
--- /dev/null
@@ -0,0 +1,44 @@
+# progs/gallium/simple/Makefile
+
+TOP = ../../..
+include $(TOP)/configs/current
+
+INCLUDES = \
+       -I. \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/winsys \
+       $(PROG_INCLUDES)
+
+LINKS = \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/winsys/sw/null/libws_null.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(GALLIUM_AUXILIARIES) \
+       $(PROG_LINKS)
+
+SOURCES = \
+       tri.c \
+       quad-tex.c
+
+OBJECTS = $(SOURCES:.c=.o)
+
+PROGS = $(OBJECTS:.o=)
+
+##### TARGETS #####
+
+default: $(PROGS)
+
+clean:
+       -rm -f $(PROGS)
+       -rm -f *.o
+       -rm -f result.bmp
+
+##### RULES #####
+
+$(OBJECTS): %.o: %.c
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(PROG_DEFINES) $< -o $@
+
+$(PROGS): %: %.o
+       $(CC) $(LDFLAGS) $< $(LINKS) -lm -lpthread -o $@
diff --git a/progs/gallium/trivial/quad-tex.c b/progs/gallium/trivial/quad-tex.c
new file mode 100644 (file)
index 0000000..553f558
--- /dev/null
@@ -0,0 +1,346 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2010 Jakob Bornecrantz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#define USE_TRACE 0
+#define WIDTH 300
+#define HEIGHT 300
+#define NEAR 30
+#define FAR 1000
+#define FLIP 0
+
+/* pipe_*_state structs */
+#include "pipe/p_state.h"
+/* pipe_context */
+#include "pipe/p_context.h"
+/* pipe_screen */
+#include "pipe/p_screen.h"
+/* PIPE_* */
+#include "pipe/p_defines.h"
+/* TGSI_SEMANTIC_{POSITION|GENERIC} */
+#include "pipe/p_shader_tokens.h"
+/* pipe_buffer_* helpers */
+#include "util/u_inlines.h"
+
+/* constant state object helper */
+#include "cso_cache/cso_context.h"
+
+/* u_sampler_view_default_template */
+#include "util/u_sampler.h"
+/* debug_dump_surface_bmp */
+#include "util/u_debug.h"
+/* util_draw_vertex_buffer helper */
+#include "util/u_draw_quad.h"
+/* FREE & CALLOC_STRUCT */
+#include "util/u_memory.h"
+/* util_make_[fragment|vertex]_passthrough_shader */
+#include "util/u_simple_shaders.h"
+
+/* softpipe software driver */
+#include "softpipe/sp_public.h"
+
+/* null software winsys */
+#include "sw/null/null_sw_winsys.h"
+
+/* traceing support see src/gallium/drivers/trace/README for more info. */
+#if USE_TRACE
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+#endif
+
+struct program
+{
+       struct pipe_screen *screen;
+       struct pipe_context *pipe;
+       struct cso_context *cso;
+
+       struct pipe_blend_state blend;
+       struct pipe_depth_stencil_alpha_state depthstencil;
+       struct pipe_rasterizer_state rasterizer;
+       struct pipe_sampler_state sampler;
+       struct pipe_viewport_state viewport;
+       struct pipe_framebuffer_state framebuffer;
+       struct pipe_vertex_element velem[2];
+
+       void *vs;
+       void *fs;
+
+       float clear_color[4];
+
+       struct pipe_buffer *vbuf;
+       struct pipe_texture *target;
+       struct pipe_texture *tex;
+       struct pipe_sampler_view *view;
+};
+
+static void init_prog(struct program *p)
+{
+       /* create the software rasterizer */
+       p->screen = softpipe_create_screen(null_sw_create());
+#if USE_TRACE
+       p->screen = trace_screen_create(p->screen);
+#endif
+       p->pipe = p->screen->context_create(p->screen, NULL);
+       p->cso = cso_create_context(p->pipe);
+
+       /* set clear color */
+       p->clear_color[0] = 0.3;
+       p->clear_color[1] = 0.1;
+       p->clear_color[2] = 0.3;
+       p->clear_color[3] = 1.0;
+
+       /* vertex buffer */
+       {
+               float vertices[4][2][4] = {
+                       {
+                               { 0.9f, 0.9f, 0.0f, 1.0f },
+                               { 1.0f, 1.0f, 0.0f, 1.0f }
+                       },
+                       {
+                               { -0.9f, 0.9f, 0.0f, 1.0f },
+                               {  0.0f, 1.0f, 0.0f, 1.0f }
+                       },
+                       {
+                               { -0.9f, -0.9f, 0.0f, 1.0f },
+                               {  0.0f,  0.0f, 1.0f, 1.0f }
+                       },
+                       {
+                               { 0.9f, -0.9f, 0.0f, 1.0f },
+                               { 1.0f,  0.0f, 1.0f, 1.0f }
+                       }
+               };
+
+               p->vbuf = pipe_buffer_create(p->screen, 16, PIPE_BUFFER_USAGE_VERTEX, sizeof(vertices));
+               pipe_buffer_write(p->screen, p->vbuf, 0, sizeof(vertices), vertices);
+       }
+
+       /* render target texture */
+       {
+               struct pipe_texture tmplt;
+               memset(&tmplt, 0, sizeof(tmplt));
+               tmplt.target = PIPE_TEXTURE_2D;
+               tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */
+               tmplt.width0 = WIDTH;
+               tmplt.height0 = HEIGHT;
+               tmplt.depth0 = 1;
+               tmplt.last_level = 0;
+               tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+
+               p->target = p->screen->texture_create(p->screen, &tmplt);
+       }
+
+       /* sampler texture */
+       {
+               uint32_t *ptr;
+               struct pipe_transfer *t;
+               struct pipe_texture t_tmplt;
+               struct pipe_sampler_view v_tmplt;
+
+               memset(&t_tmplt, 0, sizeof(t_tmplt));
+               t_tmplt.target = PIPE_TEXTURE_2D;
+               t_tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */
+               t_tmplt.width0 = 2;
+               t_tmplt.height0 = 2;
+               t_tmplt.depth0 = 1;
+               t_tmplt.last_level = 0;
+               t_tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+
+               p->tex = p->screen->texture_create(p->screen, &t_tmplt);
+
+               t = p->pipe->get_tex_transfer(p->pipe, p->tex,
+                                             0, 0, 0, /* face, level, zslice */
+                                             PIPE_TRANSFER_WRITE,
+                                             0, 0, 2, 2); /* x, y, width, height */
+
+               ptr = p->pipe->transfer_map(p->pipe, t);
+               ptr[0] = 0xffff0000;
+               ptr[1] = 0xff0000ff;
+               ptr[2] = 0xff00ff00;
+               ptr[3] = 0xffffff00;
+               p->pipe->transfer_unmap(p->pipe, t);
+
+               p->pipe->tex_transfer_destroy(p->pipe, t);
+
+               u_sampler_view_default_template(&v_tmplt, p->tex, p->tex->format);
+
+               p->view = p->pipe->create_sampler_view(p->pipe, p->tex, &v_tmplt);
+       }
+
+       /* disabled blending/masking */
+       memset(&p->blend, 0, sizeof(p->blend));
+       p->blend.rt[0].colormask = PIPE_MASK_RGBA;
+
+       /* no-op depth/stencil/alpha */
+       memset(&p->depthstencil, 0, sizeof(p->depthstencil));
+
+       /* rasterizer */
+       memset(&p->rasterizer, 0, sizeof(p->rasterizer));
+       p->rasterizer.front_winding = PIPE_WINDING_CW;
+       p->rasterizer.cull_mode = PIPE_WINDING_NONE;
+       p->rasterizer.gl_rasterization_rules = 1;
+
+       /* sampler */
+       memset(&p->sampler, 0, sizeof(p->sampler));
+       p->sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+       p->sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+       p->sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+       p->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+       p->sampler.min_img_filter = PIPE_TEX_MIPFILTER_LINEAR;
+       p->sampler.mag_img_filter = PIPE_TEX_MIPFILTER_LINEAR;
+       p->sampler.normalized_coords = 1;
+
+       /* drawing destination */
+       memset(&p->framebuffer, 0, sizeof(p->framebuffer));
+       p->framebuffer.width = WIDTH;
+       p->framebuffer.height = HEIGHT;
+       p->framebuffer.nr_cbufs = 1;
+       p->framebuffer.cbufs[0] = p->screen->get_tex_surface(p->screen, p->target, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+
+       /* viewport, depth isn't really needed */
+       {
+               float x = 0;
+               float y = 0;
+               float z = FAR;
+               float half_width = (float)WIDTH / 2.0f;
+               float half_height = (float)HEIGHT / 2.0f;
+               float half_depth = ((float)FAR - (float)NEAR) / 2.0f;
+               float scale, bias;
+
+               if (FLIP) {
+                       scale = -1.0f;
+                       bias = (float)HEIGHT;
+               } else {
+                       scale = 1.0f;
+                       bias = 0.0f;
+               }
+
+               p->viewport.scale[0] = half_width;
+               p->viewport.scale[1] = half_height * scale;
+               p->viewport.scale[2] = half_depth;
+               p->viewport.scale[3] = 1.0f;
+
+               p->viewport.translate[0] = half_width + x;
+               p->viewport.translate[1] = (half_height + y) * scale + bias;
+               p->viewport.translate[2] = half_depth + z;
+               p->viewport.translate[3] = 0.0f;
+       }
+
+       /* vertex elements state */
+       memset(p->velem, 0, sizeof(p->velem));
+       p->velem[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */
+       p->velem[0].instance_divisor = 0;
+       p->velem[0].vertex_buffer_index = 0;
+       p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+
+       p->velem[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */
+       p->velem[1].instance_divisor = 0;
+       p->velem[1].vertex_buffer_index = 0;
+       p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+
+       /* vertex shader */
+       {
+               const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+                                               TGSI_SEMANTIC_GENERIC };
+               const uint semantic_indexes[] = { 0, 0 };
+               p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes);
+       }
+
+       /* fragment shader */
+       p->fs = util_make_fragment_tex_shader(p->pipe, TGSI_TEXTURE_2D);
+}
+
+static void close_prog(struct program *p)
+{
+       /* unset bound textures as well */
+       cso_set_fragment_sampler_views(p->cso, 0, NULL);
+
+       /* unset all state */
+       cso_release_all(p->cso);
+
+       p->pipe->delete_vs_state(p->pipe, p->vs);
+       p->pipe->delete_fs_state(p->pipe, p->fs);
+
+       pipe_surface_reference(&p->framebuffer.cbufs[0], NULL);
+       pipe_sampler_view_reference(&p->view, NULL);
+       pipe_texture_reference(&p->target, NULL);
+       pipe_texture_reference(&p->tex, NULL);
+       pipe_buffer_reference(&p->vbuf, NULL);
+
+       cso_destroy_context(p->cso);
+       p->pipe->destroy(p->pipe);
+       p->screen->destroy(p->screen);
+
+       FREE(p);
+}
+
+static void draw(struct program *p)
+{
+       /* set the render target */
+       cso_set_framebuffer(p->cso, &p->framebuffer);
+
+       /* clear the render target */
+       p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0);
+
+       /* set misc state we care about */
+       cso_set_blend(p->cso, &p->blend);
+       cso_set_depth_stencil_alpha(p->cso, &p->depthstencil);
+       cso_set_rasterizer(p->cso, &p->rasterizer);
+       cso_set_viewport(p->cso, &p->viewport);
+
+       /* sampler */
+       cso_single_sampler(p->cso, 0, &p->sampler);
+       cso_single_sampler_done(p->cso);
+
+       /* texture sampler view */
+       cso_set_fragment_sampler_views(p->cso, 1, &p->view);
+
+       /* shaders */
+       cso_set_fragment_shader_handle(p->cso, p->fs);
+       cso_set_vertex_shader_handle(p->cso, p->vs);
+
+       /* vertex element data */
+       cso_set_vertex_elements(p->cso, 2, p->velem);
+
+       util_draw_vertex_buffer(p->pipe,
+                               p->vbuf, 0,
+                               PIPE_PRIM_QUADS,
+                               4,  /* verts */
+                               2); /* attribs/vert */
+
+       p->pipe->flush(p->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+       debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]);
+}
+
+int main(int argc, char** argv)
+{
+       struct program *p = CALLOC_STRUCT(program);
+
+       init_prog(p);
+       draw(p);
+       close_prog(p);
+
+       return 0;
+}
diff --git a/progs/gallium/trivial/tri.c b/progs/gallium/trivial/tri.c
new file mode 100644 (file)
index 0000000..cae1bdb
--- /dev/null
@@ -0,0 +1,278 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2010 Jakob Bornecrantz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#define USE_TRACE 0
+#define WIDTH 300
+#define HEIGHT 300
+#define NEAR 30
+#define FAR 1000
+#define FLIP 0
+
+/* pipe_*_state structs */
+#include "pipe/p_state.h"
+/* pipe_context */
+#include "pipe/p_context.h"
+/* pipe_screen */
+#include "pipe/p_screen.h"
+/* PIPE_* */
+#include "pipe/p_defines.h"
+/* TGSI_SEMANTIC_{POSITION|GENERIC} */
+#include "pipe/p_shader_tokens.h"
+/* pipe_buffer_* helpers */
+#include "util/u_inlines.h"
+
+/* constant state object helper */
+#include "cso_cache/cso_context.h"
+
+/* debug_dump_surface_bmp */
+#include "util/u_debug.h"
+/* util_draw_vertex_buffer helper */
+#include "util/u_draw_quad.h"
+/* FREE & CALLOC_STRUCT */
+#include "util/u_memory.h"
+/* util_make_[fragment|vertex]_passthrough_shader */
+#include "util/u_simple_shaders.h"
+
+/* softpipe software driver */
+#include "softpipe/sp_public.h"
+
+/* null software winsys */
+#include "sw/null/null_sw_winsys.h"
+
+/* traceing support see src/gallium/drivers/trace/README for more info. */
+#if USE_TRACE
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+#endif
+
+struct program
+{
+       struct pipe_screen *screen;
+       struct pipe_context *pipe;
+       struct cso_context *cso;
+
+       struct pipe_blend_state blend;
+       struct pipe_depth_stencil_alpha_state depthstencil;
+       struct pipe_rasterizer_state rasterizer;
+       struct pipe_viewport_state viewport;
+       struct pipe_framebuffer_state framebuffer;
+       struct pipe_vertex_element velem[2];
+
+       void *vs;
+       void *fs;
+
+       float clear_color[4];
+
+       struct pipe_buffer *vbuf;
+       struct pipe_texture *target;
+};
+
+static void init_prog(struct program *p)
+{
+       /* create the software rasterizer */
+       p->screen = softpipe_create_screen(null_sw_create());
+#if USE_TRACE
+       p->screen = trace_screen_create(p->screen);
+#endif
+       p->pipe = p->screen->context_create(p->screen, NULL);
+       p->cso = cso_create_context(p->pipe);
+
+       /* set clear color */
+       p->clear_color[0] = 0.3;
+       p->clear_color[1] = 0.1;
+       p->clear_color[2] = 0.3;
+       p->clear_color[3] = 1.0;
+
+       /* vertex buffer */
+       {
+               float vertices[4][2][4] = {
+                       {
+                               { 0.0f, -0.9f, 0.0f, 1.0f },
+                               { 1.0f, 0.0f, 0.0f, 1.0f }
+                       },
+                       {
+                               { -0.9f, 0.9f, 0.0f, 1.0f },
+                               { 0.0f, 1.0f, 0.0f, 1.0f }
+                       },
+                       {
+                               { 0.9f, 0.9f, 0.0f, 1.0f },
+                               { 0.0f, 0.0f, 1.0f, 1.0f }
+                       }
+               };
+
+               p->vbuf = pipe_buffer_create(p->screen, 16, PIPE_BUFFER_USAGE_VERTEX, sizeof(vertices));
+               pipe_buffer_write(p->screen, p->vbuf, 0, sizeof(vertices), vertices);
+       }
+
+       /* render target texture */
+       {
+               struct pipe_texture tmplt;
+               memset(&tmplt, 0, sizeof(tmplt));
+               tmplt.target = PIPE_TEXTURE_2D;
+               tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */
+               tmplt.width0 = WIDTH;
+               tmplt.height0 = HEIGHT;
+               tmplt.depth0 = 1;
+               tmplt.last_level = 0;
+               tmplt.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+
+               p->target = p->screen->texture_create(p->screen, &tmplt);
+       }
+
+       /* disabled blending/masking */
+       memset(&p->blend, 0, sizeof(p->blend));
+       p->blend.rt[0].colormask = PIPE_MASK_RGBA;
+
+       /* no-op depth/stencil/alpha */
+       memset(&p->depthstencil, 0, sizeof(p->depthstencil));
+
+       /* rasterizer */
+       memset(&p->rasterizer, 0, sizeof(p->rasterizer));
+       p->rasterizer.front_winding = PIPE_WINDING_CW;
+       p->rasterizer.cull_mode = PIPE_WINDING_NONE;
+       p->rasterizer.gl_rasterization_rules = 1;
+
+       /* drawing destination */
+       memset(&p->framebuffer, 0, sizeof(p->framebuffer));
+       p->framebuffer.width = WIDTH;
+       p->framebuffer.height = HEIGHT;
+       p->framebuffer.nr_cbufs = 1;
+       p->framebuffer.cbufs[0] = p->screen->get_tex_surface(p->screen, p->target, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+
+       /* viewport, depth isn't really needed */
+       {
+               float x = 0;
+               float y = 0;
+               float z = FAR;
+               float half_width = (float)WIDTH / 2.0f;
+               float half_height = (float)HEIGHT / 2.0f;
+               float half_depth = ((float)FAR - (float)NEAR) / 2.0f;
+               float scale, bias;
+
+               if (FLIP) {
+                       scale = -1.0f;
+                       bias = (float)HEIGHT;
+               } else {
+                       scale = 1.0f;
+                       bias = 0.0f;
+               }
+
+               p->viewport.scale[0] = half_width;
+               p->viewport.scale[1] = half_height * scale;
+               p->viewport.scale[2] = half_depth;
+               p->viewport.scale[3] = 1.0f;
+
+               p->viewport.translate[0] = half_width + x;
+               p->viewport.translate[1] = (half_height + y) * scale + bias;
+               p->viewport.translate[2] = half_depth + z;
+               p->viewport.translate[3] = 0.0f;
+       }
+
+       /* vertex elements state */
+       memset(p->velem, 0, sizeof(p->velem));
+       p->velem[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */
+       p->velem[0].instance_divisor = 0;
+       p->velem[0].vertex_buffer_index = 0;
+       p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+
+       p->velem[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */
+       p->velem[1].instance_divisor = 0;
+       p->velem[1].vertex_buffer_index = 0;
+       p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+
+       /* vertex shader */
+       {
+                       const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+                                                       TGSI_SEMANTIC_COLOR };
+                       const uint semantic_indexes[] = { 0, 0 };
+                       p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes);
+       }
+
+       /* fragment shader */
+       p->fs = util_make_fragment_passthrough_shader(p->pipe);
+}
+
+static void close_prog(struct program *p)
+{
+       /* unset all state */
+       cso_release_all(p->cso);
+
+       p->pipe->delete_vs_state(p->pipe, p->vs);
+       p->pipe->delete_fs_state(p->pipe, p->fs);
+
+       pipe_surface_reference(&p->framebuffer.cbufs[0], NULL);
+       pipe_texture_reference(&p->target, NULL);
+       pipe_buffer_reference(&p->vbuf, NULL);
+
+       cso_destroy_context(p->cso);
+       p->pipe->destroy(p->pipe);
+       p->screen->destroy(p->screen);
+
+       FREE(p);
+}
+
+static void draw(struct program *p)
+{
+       /* set the render target */
+       cso_set_framebuffer(p->cso, &p->framebuffer);
+
+       /* clear the render target */
+       p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0);
+
+       /* set misc state we care about */
+       cso_set_blend(p->cso, &p->blend);
+       cso_set_depth_stencil_alpha(p->cso, &p->depthstencil);
+       cso_set_rasterizer(p->cso, &p->rasterizer);
+       cso_set_viewport(p->cso, &p->viewport);
+
+       /* shaders */
+       cso_set_fragment_shader_handle(p->cso, p->fs);
+       cso_set_vertex_shader_handle(p->cso, p->vs);
+
+       /* vertex element data */
+       cso_set_vertex_elements(p->cso, 2, p->velem);
+
+       util_draw_vertex_buffer(p->pipe,
+                               p->vbuf, 0,
+                               PIPE_PRIM_TRIANGLES,
+                               3,  /* verts */
+                               2); /* attribs/vert */
+
+       p->pipe->flush(p->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+       debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]);
+}
+
+int main(int argc, char** argv)
+{
+       struct program *p = CALLOC_STRUCT(program);
+
+       init_prog(p);
+       draw(p);
+       close_prog(p);
+
+       return 0;
+}
index 3b5a5959aeebd2a5a70f054f63e74f927638e563..6030c8002f5054dead4d3244e2969d40af97bc96 100644 (file)
@@ -26,6 +26,7 @@ PROG_SOURCES = \
        convolutions.c \
        deriv.c \
        fragcoord.c \
+       fsraytrace.c \
        identity.c \
        linktest.c \
        mandelbrot.c \
@@ -46,7 +47,8 @@ PROG_SOURCES = \
        trirast.c \
        twoside.c \
        vert-or-frag-only.c \
-       vert-tex.c
+       vert-tex.c \
+       vsraytrace.c
 
 UTIL_HEADERS = \
        extfuncs.h \
index 8f2ebcf69c42619ca85f96d5a2533334e784845b..02884e5a7102e2af1a0aefdb885205fda01b2ff9 100644 (file)
@@ -8,6 +8,7 @@ progs = [
       'convolutions',
       'deriv',
       'fragcoord',
+      'fsraytrace',
       'identity',
       'linktest',
       'mandelbrot',
@@ -27,6 +28,7 @@ progs = [
       'twoside',
       'vert-or-frag-only',
       'vert-tex',
+      'vsraytrace',
 ]
 
 for prog in progs:
diff --git a/progs/glsl/fsraytrace.c b/progs/glsl/fsraytrace.c
new file mode 100644 (file)
index 0000000..af72a99
--- /dev/null
@@ -0,0 +1,412 @@
+/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*- */
+/*
+  Copyright (c) 2010 Kristóf Ralovich
+
+  Permission is hereby granted, free of charge, to any person obtaining a copy
+  of this software and associated documentation files (the "Software"), to deal
+  in the Software without restriction, including without limitation the rights
+  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+  copies of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included in
+  all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdio.h>
+#include <stdlib.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+#include "shaderutil.h"
+#include <math.h>
+
+static int Win;
+static int WinWidth = 512, WinHeight = 512;
+static int mouseGrabbed = 0;
+static GLuint vertShader;
+static GLuint fragShader;
+static GLuint program;
+static float rot[9] = {1,0,0,  0,1,0,   0,0,1};
+
+static const char* vsSource =
+  "varying vec2 rayDir;                                                \n"
+  "                                                                    \n"
+  "void main()                                                         \n"
+  "{                                                                   \n"
+  "  rayDir = gl_MultiTexCoord0.xy - vec2(0.5,0.5);                    \n"
+  "  gl_Position = gl_ProjectionMatrix * gl_Vertex;                    \n"
+  "}\n";
+
+static const char* fsSource =
+  "const float INF     = 9999.9;                                       \n"
+  "const float EPSILON = 0.00001;                                      \n"
+  "const vec3 lightPos = vec3(0.0, 8.0, 1.0);                          \n"
+  "const vec4 backgroundColor = vec4(0.2,0.3,0.4,1);                   \n"
+  "                                                                    \n"
+  "varying vec2 rayDir;                                                \n"
+  "                                                                    \n"
+  "uniform mat3 rot;                                                   \n"
+  "                                                                    \n"
+  "struct Ray                                                          \n"
+  "{                                                                   \n"
+  "vec3 orig;                                                          \n"
+  "vec3 dir;                                                           \n"
+  "};                                                                  \n"
+  "                                                                    \n"
+  "struct Sphere                                                       \n"
+  "{                                                                   \n"
+  "  vec3 c;                                                           \n"
+  "  float r;                                                          \n"
+  "};                                                                  \n"
+  "                                                                    \n"
+  "struct Isec                                                         \n"
+  "{                                                                   \n"
+  "  float t;                                                          \n"
+  "  int idx;                                                          \n"
+  "  vec3 hit;                                                         \n"
+  "  vec3 n;                                                           \n"
+  "};                                                                  \n"
+  "                                                                    \n"
+#ifdef __APPLE__
+  "Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 );                \n"
+  "Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 );               \n"
+  "Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 );                \n"
+  "Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 );                \n"
+#else
+  "const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 );          \n"
+  "const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 );         \n"
+  "const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 );          \n"
+  "const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 );          \n"
+#endif
+  "                                                                    \n"
+  "// Mesa intel gen4 generates \"unsupported IR in fragment shader 13\" for\n"
+  "// sqrt, let's work around.                                         \n"
+  "float                                                               \n"
+  "sqrt_hack(float f2)                                                 \n"
+  "{                                                                   \n"
+  "  vec3 v = vec3(f2,0.0,0.0);                                        \n"
+  "  return length(v);                                                 \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "void                                                                \n"
+  "intersect(const in Ray ray,                                         \n"
+  "          const in Sphere sph,                                      \n"
+  "          const in int idx,                                         \n"
+  "          inout Isec isec)                                          \n"
+  "{                                                                   \n"
+  "  // Project both o and the sphere to the plane perpendicular to d  \n"
+  "  // and containing c. Let x be the point where the ray intersects  \n"
+  "  // the plane. If |x-c| < r, the ray intersects the sphere.        \n"
+  "  vec3 o = ray.orig;                                                \n"
+  "  vec3 d = ray.dir;                                                 \n"
+  "  vec3 n = -d;                                                      \n"
+  "  vec3 c = sph.c;                                                   \n"
+  "  float r = sph.r;                                                  \n"
+  "  float t = dot(c-o,n)/dot(n,d);                                    \n"
+  "  vec3 x = o+d*t;                                                   \n"
+  "  float e = length(x-c);                                            \n"
+  "  if(e > r)                                                         \n"
+  "  {                                                                 \n"
+  "    // no intersection                                              \n"
+  "    return;                                                         \n"
+  "  }                                                                 \n"
+  "                                                                    \n"
+  "  // Apply Pythagorean theorem on the (intersection,x,c) triangle   \n"
+  "  // to get the distance between c and the intersection.            \n"
+  "#ifndef BUGGY_INTEL_GEN4_GLSL                                       \n"
+  "  float f = sqrt(r*r - e*e);                                        \n"
+  "#else                                                               \n"
+  "  float f = sqrt_hack(r*r - e*e);                                   \n"
+  "#endif                                                              \n"
+  "  float dist = t - f;                                               \n"
+  "  if(dist < 0.0)                                                    \n"
+  "  {                                                                 \n"
+  "    // inside the sphere                                            \n"
+  "    return;                                                         \n"
+  "  }                                                                 \n"
+  "                                                                    \n"
+  "  if(dist < EPSILON)                                                \n"
+  "    return;                                                         \n"
+  "                                                                    \n"
+  "  if(dist > isec.t)                                                 \n"
+  "    return;                                                         \n"
+  "                                                                    \n"
+  "  isec.t = dist;                                                    \n"
+  "  isec.idx = idx;                                                   \n"
+  "                                                                    \n"
+  "  isec.hit  = ray.orig + ray.dir * isec.t;                          \n"
+  "  isec.n = (isec.hit - c) / r;                                      \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "Isec                                                                \n"
+  "intersect(const in Ray ray,                                         \n"
+  "          const in float max_t /*= INF*/)                           \n"
+  "{                                                                   \n"
+  "  Isec nearest;                                                     \n"
+  "  nearest.t = max_t;                                                \n"
+  "  nearest.idx = -1;                                                 \n"
+  "                                                                    \n"
+  "  intersect(ray, spheres0, 0, nearest);                             \n"
+  "  intersect(ray, spheres1, 1, nearest);                             \n"
+  "  intersect(ray, spheres2, 2, nearest);                             \n"
+  "  intersect(ray, spheres3, 3, nearest);                             \n"
+  "                                                                    \n"
+  "  return nearest;                                                   \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "vec4                                                                \n"
+  "idx2color(const in int idx)                                         \n"
+  "{                                                                   \n"
+  "  vec4 diff;                                                        \n"
+  "  if(idx == 0)                                                      \n"
+  "    diff = vec4(1.0, 0.0, 0.0, 0.0);                                \n"
+  "  else if(idx == 1)                                                 \n"
+  "    diff = vec4(0.0, 1.0, 0.0, 0.0);                                \n"
+  "  else if(idx == 2)                                                 \n"
+  "    diff = vec4(0.0, 0.0, 1.0, 0.0);                                \n"
+  "  else if(idx == 3)                                                 \n"
+  "    diff = vec4(1.0, 1.0, 0.0, 0.0);                                \n"
+  "  return diff;                                                      \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "vec4                                                                \n"
+  "trace0(const in Ray ray)                                            \n"
+  "{                                                                   \n"
+  "  Isec isec = intersect(ray, INF);                                  \n"
+  "                                                                    \n"
+  "  if(isec.idx == -1)                                                \n"
+  "  {                                                                 \n"
+  "    return backgroundColor;                                         \n"
+  "  }                                                                 \n"
+  "                                                                    \n"
+  "  vec4 diff = idx2color(isec.idx);                                  \n"
+  "                                                                    \n"
+  "  vec3 N = isec.n;                                                  \n"
+  "  vec3 L = normalize(lightPos-isec.hit);                            \n"
+  "  vec3 camera_dir = normalize(ray.orig - isec.hit);                 \n"
+  "  return dot(N,L)*diff + pow(                                       \n"
+  "    clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0);             \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "vec4                                                                \n"
+  "trace1(const in Ray ray)                                            \n"
+  "{                                                                   \n"
+  "  Isec isec = intersect(ray, INF);                                  \n"
+  "                                                                    \n"
+  "  if(isec.idx == -1)                                                \n"
+  "  {                                                                 \n"
+  "    return backgroundColor;                                         \n"
+  "  }                                                                 \n"
+  "                                                                    \n"
+  "  Ray reflRay = Ray(isec.hit, reflect(ray.dir, isec.n));            \n"
+  "                                                                    \n"
+  "  vec4 reflCol = trace0(reflRay);                                   \n"
+  "                                                                    \n"
+  "  vec4 diff = idx2color(isec.idx) + reflCol;                        \n"
+  "                                                                    \n"
+  "  vec3 N = isec.n;                                                  \n"
+  "  vec3 L = normalize(lightPos-isec.hit);                            \n"
+  "  vec3 camera_dir = normalize(ray.orig - isec.hit);                 \n"
+  "  return dot(N,L)*diff + pow(                                       \n"
+  "    clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0);             \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "void main()                                                         \n"
+  "{                                                                   \n"
+  "  const float z = -0.5;                                             \n"
+  "  const vec3 cameraPos = vec3(0,0,3);                               \n"
+  "  Ray r = Ray(cameraPos, normalize(vec3(rayDir, z) * rot));         \n"
+  "  gl_FragColor = trace1(r);                                         \n"
+  "}\n";
+
+static
+float
+deg2rad(const float degree)
+{
+  return( degree * 0.017453292519943295769236907684886F);
+}
+
+static void
+rotate_xy(float* mat3, const float degreesAroundX, const float degreesAroundY)
+{
+  const float rad1 = deg2rad(degreesAroundX);
+  const float c1 = cosf(rad1);
+  const float s1 = sinf(rad1);
+  const float rad2 = deg2rad(degreesAroundY);
+  const float c2 = cosf(rad2);
+  const float s2 = sinf(rad2);
+  mat3[0] = c2;    mat3[3] = 0.0F; mat3[6] = s2;
+  mat3[1] = s1*s2; mat3[4] = c1;   mat3[7] = -s1*c2;
+  mat3[2] = -c1*s2;mat3[5] = s1;   mat3[8] = c1*c2;
+}
+
+static void
+identity(float* mat3)
+{
+  mat3[0] = 1.0F; mat3[3] = 0.0F; mat3[6] = 0.0F;
+  mat3[1] = 0.0F; mat3[4] = 1.0F; mat3[7] = 0.0F;
+  mat3[2] = 0.0F; mat3[5] = 0.0F; mat3[8] = 1.0F;
+}
+
+static void
+Draw(void)
+{
+  GLint location = glGetUniformLocation(program, "rot");
+  static const float m = -10.F;
+  static const float p =  10.F;
+  static const float d = -0.5F;
+
+  glUseProgram(program);
+  glUniformMatrix3fv(location, 1, 0, rot);
+
+  glBegin(GL_QUADS);
+  {
+    glTexCoord2f(0.0F, 0.0F); glVertex3f(m, m, d);
+    glTexCoord2f(1.0F, 0.0F); glVertex3f(p, m, d);
+    glTexCoord2f(1.0F, 1.0F); glVertex3f(p, p, d);
+    glTexCoord2f(0.0F, 1.0F); glVertex3f(m, p, d);
+  }
+  glEnd();
+  glUseProgram(0);
+
+  glutSwapBuffers();
+
+  {
+    static int frames = 0;
+    static int t0 = 0;
+    static int t1 = 0;
+    float dt;
+    frames++;
+    t1 = glutGet(GLUT_ELAPSED_TIME);
+    dt = (float)(t1-t0)/1000.0F;
+    if(dt >= 5.0F)
+    {
+      float fps = (float)frames / dt;
+      printf("%f FPS (%d frames in %f seconds)\n", fps, frames, dt);
+      frames = 0;
+      t0 = t1;
+    }
+  }
+}
+
+
+static void
+Reshape(int width, int height)
+{
+  WinWidth = width;
+  WinHeight = height;
+  glViewport(0, 0, width, height);
+  glMatrixMode(GL_PROJECTION);
+  glLoadIdentity();
+  glOrtho(-10, 10, -10, 10, -1, 1);
+  glMatrixMode(GL_MODELVIEW);
+  glLoadIdentity();
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+  (void) x;
+  (void) y;
+  switch (key) {
+  case 27:
+    glutDestroyWindow(Win);
+    exit(0);
+    break;
+  }
+  glutPostRedisplay();
+}
+
+
+static
+void
+drag(int x, int y)
+{
+  float scale = 1.5F;
+  if(mouseGrabbed)
+  {
+    static GLfloat xRot = 0, yRot = 0;
+    xRot = (float)(x - WinWidth/2) / scale;
+    yRot = (float)(y - WinHeight/2) / scale;
+    identity(rot);
+    rotate_xy(rot, yRot, xRot);
+    glutPostRedisplay();
+  }
+}
+
+
+static
+void
+mouse(int button, int state, int x, int y)
+{
+  mouseGrabbed = (state == GLUT_DOWN);
+}
+
+
+static void
+Init(void)
+{
+  glDisable(GL_DEPTH_TEST);
+
+  if(!ShadersSupported())
+  {
+    fprintf(stderr, "Shaders are not supported!\n");
+    exit(-1);
+  }
+
+  vertShader = CompileShaderText(GL_VERTEX_SHADER, vsSource);
+  fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fsSource);
+  program = LinkShaders(vertShader, fragShader);
+  glUseProgram(0);
+
+  if(glGetError() != 0)
+  {
+    fprintf(stderr, "Shaders were not loaded!\n");
+    exit(-1);
+  }
+
+  if(!glIsShader(vertShader))
+  {
+    fprintf(stderr, "Vertex shader failed!\n");
+    exit(-1);
+  }
+
+  if(!glIsProgram(program))
+  {
+    fprintf(stderr, "Shader program failed!\n");
+    exit(-1);
+  }
+
+  printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+}
+
+
+int
+main(int argc, char *argv[])
+{
+  glutInitWindowSize(WinWidth, WinHeight);
+  glutInit(&argc, argv);
+  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+  Win = glutCreateWindow(argv[0]);
+  glewInit();
+  glutReshapeFunc(Reshape);
+  glutKeyboardFunc(Key);
+  glutDisplayFunc(Draw);
+  glutMouseFunc(mouse);
+  glutMotionFunc(drag);
+  glutIdleFunc(Draw);
+  Init();
+  glutMainLoop();
+  return 0;
+}
+
diff --git a/progs/glsl/vsraytrace.c b/progs/glsl/vsraytrace.c
new file mode 100644 (file)
index 0000000..64d9288
--- /dev/null
@@ -0,0 +1,401 @@
+/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*- */
+/*
+  Copyright (c) 2010 Kristóf Ralovich
+
+  Permission is hereby granted, free of charge, to any person obtaining a copy
+  of this software and associated documentation files (the "Software"), to deal
+  in the Software without restriction, including without limitation the rights
+  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+  copies of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included in
+  all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdio.h>
+#include <stdlib.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+#include "shaderutil.h"
+#include <math.h>
+
+static int Win;
+static int WinWidth = 256, WinHeight = 256;
+static GLboolean mouseGrabbed = GL_FALSE;
+static GLuint vertShader;
+static GLuint program;
+float rot[9] = {1,0,0,  0,1,0,   0,0,1};
+
+static const char* vsSource =
+  "const float INF     = 9999.9;                                       \n"
+  "const float EPSILON = 0.00001;                                      \n"
+  "const vec3 lightPos = vec3(0.0, 8.0, 1.0);                          \n"
+  "const vec4 backgroundColor = vec4(0.2,0.3,0.4,1);                   \n"
+  "                                                                    \n"
+  "uniform mat3 rot;                                                   \n"
+  "                                                                    \n"
+  "struct Ray                                                          \n"
+  "{                                                                   \n"
+  "vec3 orig;                                                          \n"
+  "vec3 dir;                                                           \n"
+  "};                                                                  \n"
+  "                                                                    \n"
+  "struct Sphere                                                       \n"
+  "{                                                                   \n"
+  "  vec3 c;                                                           \n"
+  "  float r;                                                          \n"
+  "};                                                                  \n"
+  "                                                                    \n"
+  "struct Isec                                                         \n"
+  "{                                                                   \n"
+  "  float t;                                                          \n"
+  "  int idx;                                                          \n"
+  "  vec3 hit;                                                         \n"
+  "  vec3 n;                                                           \n"
+  "};                                                                  \n"
+  "                                                                    \n"
+#ifdef __APPLE__
+  "Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 );                \n"
+  "Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 );               \n"
+  "Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 );                \n"
+  "Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 );                \n"
+#else
+  "const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 );          \n"
+  "const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 );         \n"
+  "const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 );          \n"
+  "const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 );          \n"
+#endif
+  "                                                                    \n"
+  "// Mesa intel gen4 generates \"unsupported IR in fragment shader 13\" for\n"
+  "// sqrt, let's work around.                                         \n"
+  "float                                                               \n"
+  "sqrt_hack(float f2)                                                 \n"
+  "{                                                                   \n"
+  "  vec3 v = vec3(f2,0.0,0.0);                                        \n"
+  "  return length(v);                                                 \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "void                                                                \n"
+  "intersect(const in Ray ray,                                         \n"
+  "          const in Sphere sph,                                      \n"
+  "          const in int idx,                                         \n"
+  "          inout Isec isec)                                          \n"
+  "{                                                                   \n"
+  "  // Project both o and the sphere to the plane perpendicular to d  \n"
+  "  // and containing c. Let x be the point where the ray intersects  \n"
+  "  // the plane. If |x-c| < r, the ray intersects the sphere.        \n"
+  "  vec3 o = ray.orig;                                                \n"
+  "  vec3 d = ray.dir;                                                 \n"
+  "  vec3 n = -d;                                                      \n"
+  "  vec3 c = sph.c;                                                   \n"
+  "  float r = sph.r;                                                  \n"
+  "  float t = dot(c-o,n)/dot(n,d);                                    \n"
+  "  vec3 x = o+d*t;                                                   \n"
+  "  float e = length(x-c);                                            \n"
+  "  if(e > r)                                                         \n"
+  "  {                                                                 \n"
+  "    // no intersection                                              \n"
+  "    return;                                                         \n"
+  "  }                                                                 \n"
+  "                                                                    \n"
+  "  // Apply Pythagorean theorem on the (intersection,x,c) triangle   \n"
+  "  // to get the distance between c and the intersection.            \n"
+  "#define BUGGY_INTEL_GEN4_GLSL 1                                     \n"
+  "#ifndef BUGGY_INTEL_GEN4_GLSL                                       \n"
+  "  float f = sqrt(r*r - e*e);                                        \n"
+  "#else                                                               \n"
+  "  float f = sqrt_hack(r*r - e*e);                                   \n"
+  "#endif                                                              \n"
+  "  float dist = t - f;                                               \n"
+  "  if(dist < 0.0)                                                    \n"
+  "  {                                                                 \n"
+  "    // inside the sphere                                            \n"
+  "    return;                                                         \n"
+  "  }                                                                 \n"
+  "                                                                    \n"
+  "  if(dist < EPSILON)                                                \n"
+  "    return;                                                         \n"
+  "                                                                    \n"
+  "  if(dist > isec.t)                                                 \n"
+  "    return;                                                         \n"
+  "                                                                    \n"
+  "  isec.t = dist;                                                    \n"
+  "  isec.idx = idx;                                                   \n"
+  "                                                                    \n"
+  "  isec.hit  = ray.orig + ray.dir * isec.t;                          \n"
+  "  isec.n = (isec.hit - c) / r;                                      \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "Isec                                                                \n"
+  "intersect(const in Ray ray,                                         \n"
+  "          const in float max_t /*= INF*/)                           \n"
+  "{                                                                   \n"
+  "  Isec nearest;                                                     \n"
+  "  nearest.t = max_t;                                                \n"
+  "  nearest.idx = -1;                                                 \n"
+  "                                                                    \n"
+  "  intersect(ray, spheres0, 0, nearest);                             \n"
+  "  intersect(ray, spheres1, 1, nearest);                             \n"
+  "  intersect(ray, spheres2, 2, nearest);                             \n"
+  "  intersect(ray, spheres3, 3, nearest);                             \n"
+  "                                                                    \n"
+  "  return nearest;                                                   \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "vec4                                                                \n"
+  "idx2color(const in int idx)                                         \n"
+  "{                                                                   \n"
+  "  vec4 diff;                                                        \n"
+  "  if(idx == 0)                                                      \n"
+  "    diff = vec4(1.0, 0.0, 0.0, 0.0);                                \n"
+  "  else if(idx == 1)                                                 \n"
+  "    diff = vec4(0.0, 1.0, 0.0, 0.0);                                \n"
+  "  else if(idx == 2)                                                 \n"
+  "    diff = vec4(0.0, 0.0, 1.0, 0.0);                                \n"
+  "  else if(idx == 3)                                                 \n"
+  "    diff = vec4(1.0, 1.0, 0.0, 0.0);                                \n"
+  "  return diff;                                                      \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "vec4                                                                \n"
+  "trace0(const in Ray ray)                                            \n"
+  "{                                                                   \n"
+  "  Isec isec = intersect(ray, INF);                                  \n"
+  "                                                                    \n"
+  "  if(isec.idx == -1)                                                \n"
+  "  {                                                                 \n"
+  "    return backgroundColor;                                         \n"
+  "  }                                                                 \n"
+  "                                                                    \n"
+  "  vec4 diff = idx2color(isec.idx);                                  \n"
+  "                                                                    \n"
+  "  vec3 N = isec.n;                                                  \n"
+  "  vec3 L = normalize(lightPos-isec.hit);                            \n"
+  "  vec3 camera_dir = normalize(ray.orig - isec.hit);                 \n"
+  "  return dot(N,L)*diff + pow(                                       \n"
+  "    clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0);             \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "vec4                                                                \n"
+  "trace1(const in Ray ray)                                            \n"
+  "{                                                                   \n"
+  "  Isec isec = intersect(ray, INF);                                  \n"
+  "                                                                    \n"
+  "  if(isec.idx == -1)                                                \n"
+  "  {                                                                 \n"
+  "    return backgroundColor;                                         \n"
+  "  }                                                                 \n"
+  "                                                                    \n"
+  "  Ray reflRay = Ray(isec.hit, reflect(ray.dir, isec.n));            \n"
+  "                                                                    \n"
+  "  vec4 reflCol = trace0(reflRay);                                   \n"
+  "                                                                    \n"
+  "  vec4 diff = idx2color(isec.idx) + reflCol;                        \n"
+  "                                                                    \n"
+  "  vec3 N = isec.n;                                                  \n"
+  "  vec3 L = normalize(lightPos-isec.hit);                            \n"
+  "  vec3 camera_dir = normalize(ray.orig - isec.hit);                 \n"
+  "  return dot(N,L)*diff + pow(                                       \n"
+  "    clamp(dot(reflect(-L,N),camera_dir),0.0,1.0),16.0);             \n"
+  "}                                                                   \n"
+  "                                                                    \n"
+  "void main()                                                         \n"
+  "{                                                                   \n"
+  "  const vec3 cameraPos = vec3(0,0,3);                               \n"
+  "  vec3 rayDir = normalize(vec3(gl_Vertex.x, gl_Vertex.y, -1.0) * rot);\n"
+  "  Ray ray = Ray(cameraPos, rayDir);                                 \n"
+  "  gl_Position = gl_Vertex;                                          \n"
+  "  gl_FrontColor = trace1(ray);                                      \n"
+  "}\n";
+
+
+static
+float
+deg2rad(const float degree)
+{
+  return( degree * 0.017453292519943295769236907684886F);
+}
+
+static void
+rotate_xy(float* mat3, const float degreesAroundX, const float degreesAroundY)
+{
+  const float rad1 = deg2rad(degreesAroundX);
+  const float c1 = cosf(rad1);
+  const float s1 = sinf(rad1);
+  const float rad2 = deg2rad(degreesAroundY);
+  const float c2 = cosf(rad2);
+  const float s2 = sinf(rad2);
+  mat3[0] = c2;    mat3[3] = 0.0F; mat3[6] = s2;
+  mat3[1] = s1*s2; mat3[4] = c1;   mat3[7] = -s1*c2;
+  mat3[2] = -c1*s2;mat3[5] = s1;   mat3[8] = c1*c2;
+}
+
+static void
+identity(float* mat3)
+{
+  mat3[0] = 1.0F; mat3[3] = 0.0F; mat3[6] = 0.0F;
+  mat3[1] = 0.0F; mat3[4] = 1.0F; mat3[7] = 0.0F;
+  mat3[2] = 0.0F; mat3[5] = 0.0F; mat3[8] = 1.0F;
+}
+
+static void
+Draw(void)
+{
+  const float w = 0.5F * WinWidth;
+  const float h = 0.5F * WinHeight;
+  int x,y;
+
+  GLint location = glGetUniformLocation(program, "rot");
+
+  glUseProgram(program);
+  glUniformMatrix3fv(location, 1, 0, rot);
+  glBegin(GL_POINTS);
+  for(y = 0; y < WinHeight; y++)
+  {
+    for(x = 0; x < WinWidth; x++)
+    {
+      const float posx = x / w - 1.0F;
+      const float posy = y / h - 1.0F;
+      glVertex2f(posx, posy);
+    }
+  }
+  glEnd();
+  glUseProgram(0);
+
+  glutSwapBuffers();
+
+  {
+    static int frames = 0;
+    static int t0 = 0;
+    static int t1 = 0;
+    float dt;
+    frames++;
+    t1 = glutGet(GLUT_ELAPSED_TIME);
+    dt = (float)(t1-t0)/1000.0F;
+    if (dt >= 5.0F)
+    {
+      float fps = (float)frames / dt;
+      printf("%f FPS (%d frames in %f seconds)\n", fps, frames, dt);
+      frames = 0;
+      t0 = t1;
+    }
+  }
+}
+
+
+static void
+Reshape(int width, int height)
+{
+  WinWidth = width;
+  WinHeight = height;
+  glViewport(0, 0, width, height);
+  glMatrixMode(GL_PROJECTION);
+  glLoadIdentity();
+  glMatrixMode(GL_MODELVIEW);
+  glLoadIdentity();
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+  if(key == 27)
+  {
+    glutDestroyWindow(Win);
+    exit(0);
+  }
+  glutPostRedisplay();
+}
+
+
+static
+void
+drag(int x, int y)
+{
+  float scale = 1.5F;
+  if(mouseGrabbed)
+  {
+    static GLfloat xRot = 0, yRot = 0;
+    xRot = (float)(x - WinWidth/2) / scale;
+    yRot = (float)(y - WinHeight/2) / scale;
+    identity(rot);
+    rotate_xy(rot, yRot, xRot);
+    glutPostRedisplay();
+  }
+}
+
+
+static
+void
+mouse(int button, int state, int x, int y)
+{
+  mouseGrabbed = (state == GLUT_DOWN);
+}
+
+
+static void
+Init(void)
+{
+  glDisable(GL_DEPTH_TEST);
+
+  if(!ShadersSupported())
+  {
+    fprintf(stderr, "Shaders are not supported!\n");
+    exit(-1);
+  }
+
+  vertShader = CompileShaderText(GL_VERTEX_SHADER, vsSource);
+  program = LinkShaders(vertShader, 0);
+  glUseProgram(0);
+
+  if(glGetError() != 0)
+  {
+    fprintf(stderr, "Shaders were not loaded!\n");
+    exit(-1);
+  }
+
+  if(!glIsShader(vertShader))
+  {
+    fprintf(stderr, "Vertex shader failed!\n");
+    exit(-1);
+  }
+
+  if(!glIsProgram(program))
+  {
+    fprintf(stderr, "Shader program failed!\n");
+    exit(-1);
+  }
+
+  printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+}
+
+
+int
+main(int argc, char *argv[])
+{
+  glutInitWindowSize(WinWidth, WinHeight);
+  glutInit(&argc, argv);
+  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+  Win = glutCreateWindow(argv[0]);
+  glewInit();
+  glutReshapeFunc(Reshape);
+  glutKeyboardFunc(Key);
+  glutDisplayFunc(Draw);
+  glutIdleFunc(Draw);
+  glutMouseFunc(mouse);
+  glutMotionFunc(drag);
+  Init();
+  glutMainLoop();
+  return 0;
+}
+
index 391c637d6fa6a955144091b64ebca52f406a4e57..353a3a2e1a21e96e2f5d8cb1a7dc3c8829be63bc 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <GL/glew.h>
 #include <GL/glut.h>
 
 
@@ -35,7 +36,6 @@ GLint windW, windH;
 
 char *fileName = 0;
 PPMImage *image;
-float point[3];
 float zoom;
 GLint x, y;
 
@@ -97,27 +97,27 @@ static void Mouse(int button, int state, int mouseX, int mouseY)
 
 static void Draw(void)
 {
+    GLint src[3], dst[3];
 
     glClear(GL_COLOR_BUFFER_BIT);
 
-    point[0] = (windW / 2) - (image->sizeX / 2);
-    point[1] = (windH / 2) - (image->sizeY / 2);
-    point[2] = 0;
-    glRasterPos3fv(point);
+    src[0] = (int) ((windW / 2.0) - (image->sizeX / 2.0));
+    src[1] = (int) ((windH / 2.0) - (image->sizeY / 2.0));
+    src[2] = 0;
+    glWindowPos3ivARB(src);
 
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
     glPixelZoom(1.0, 1.0);
     glDrawPixels(image->sizeX, image->sizeY, GL_RGB, GL_UNSIGNED_BYTE,
                 image->data);
 
-    point[0] = (float)x;
-    point[1] = windH - (float)y;
-    point[2] = 0.0;
-    glRasterPos3fv(point);
+    dst[0] = x;
+    dst[1] = windH - y;
+    dst[2] = 0;
+    glWindowPos3ivARB(dst);
 
     glPixelZoom(zoom, zoom);
-    glCopyPixels((windW/2)-(image->sizeX/2),
-                (windH/2)-(image->sizeY/2),
+    glCopyPixels(src[0], src[1],
                 image->sizeX, image->sizeY, GL_COLOR);
 
     glFlush();
@@ -170,8 +170,8 @@ int main(int argc, char **argv)
 
     image = LoadPPM(fileName);
 
-    windW = 300;
-    windH = 300;
+    windW = 2*300;
+    windH = 2*300;
     glutInitWindowPosition(0, 0); glutInitWindowSize( windW, windH);
 
     type = GLUT_RGB;
@@ -182,6 +182,7 @@ int main(int argc, char **argv)
        exit(1);
     }
 
+    glewInit();
     Init();
 
     glutReshapeFunc(Reshape);
index be056d62940503949a0bea7e58d73c58ed0d366b..adae9b491e49ee74c9062ad93cd3f0ccdf68047a 100644 (file)
@@ -9,7 +9,7 @@ static PPMImage *LoadPPM(const char *filename)
     char buff[16];
     PPMImage *result;
     FILE *fp;
-    int maxval;
+    int maxval, w, h;
 
     fp = fopen(filename, "rb");
     if (!fp)
@@ -37,11 +37,13 @@ static PPMImage *LoadPPM(const char *filename)
        exit(1);
     }
 
-    if (fscanf(fp, "%lu %lu", &result->sizeX, &result->sizeY) != 2)
+    if (fscanf(fp, "%d %d", &w, &h) != 2)
     {
        fprintf(stderr, "Error loading image `%s'\n", filename);
        exit(1);
     }
+    result->sizeX = w;
+    result->sizeY = h;
 
     if (fscanf(fp, "%d", &maxval) != 1)
     {
index 67efc3b7a9c620cc952c8b8405321a5d703c0120..6bb0249e171ad9c9f6032366f43b28b0123fa47b 100644 (file)
@@ -41,6 +41,7 @@ SOURCES = \
        copypixrate.c \
        crossbar.c \
        cva.c \
+       cva_huge.c \
        cylwrap.c \
        drawbuffers.c \
        drawbuffers2.c \
index 3580ba914dbade0bf071b86879626f039964beae..037a0c35dad1f603145ed19af0949f516b0233c1 100644 (file)
@@ -9,7 +9,6 @@ glx_progs = [
     'getprocaddress',
     'jkrahntest',
     'sharedtex',
-    'texcompress2',
     'texobjshare',
 ]
 
@@ -45,6 +44,7 @@ progs = [
     'copypixrate',
     'crossbar',
     'cva',
+    'cva_huge',
     'cylwrap',
     'drawbuffers',
     'drawbuffers2',
diff --git a/progs/tests/cva_huge.c b/progs/tests/cva_huge.c
new file mode 100644 (file)
index 0000000..88ec2af
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright Â© 2010 Pauli Nieminen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ */
+
+
+/*
+ * Test case for huge cva arrays. Mesa code has to split this to multiple VBOs
+ * which had memory access error.
+ * This test case doesn't render incorrectly but valgrind showed the memory
+ * access error.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stddef.h>    /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#define GL_GLEXT_LEGACY
+#include <GL/glut.h>
+
+GLfloat *verts;
+
+GLubyte *color;
+
+GLuint *indices;
+
+#define rows 1000 /* Create 1000x1000 vertex grid */
+#define row_width 5000.0
+#define grid_depth -50.0
+GLuint nr_verts_in_row = rows; 
+GLuint nr_indices_in_strip = rows * 2;
+
+GLboolean double_buffer;
+GLboolean compiled = GL_TRUE;
+
+static void generate_verts( void )
+{
+       unsigned x, y;
+       GLfloat step = row_width /(GLfloat)(nr_verts_in_row - 1); 
+       verts = malloc(sizeof(verts[0]) * 4 * nr_verts_in_row * nr_verts_in_row);
+
+       for (y = 0; y < nr_verts_in_row; ++y) {
+               for (x = 0; x < nr_verts_in_row; ++x) {
+                       unsigned idx = 4*(x + y * nr_verts_in_row);
+                       verts[idx + 0] = step * x - row_width/2.0;
+                       verts[idx + 1] = step * y - row_width/2.0;
+                       /* deep enough not to be vissible */
+                       verts[idx + 2] = grid_depth;
+                       verts[idx + 3] = 0.0;
+               }
+       }
+       glVertexPointer( 3, GL_FLOAT, sizeof(verts[0])*4, verts );
+}
+
+static void generate_colors( void )
+{
+       unsigned x, y;
+       GLfloat step = 255.0/(GLfloat)(nr_verts_in_row - 1);
+       color = malloc(sizeof(color[0]) * 4 * nr_verts_in_row * nr_verts_in_row);
+
+       for (y = 0; y < nr_verts_in_row; ++y) {
+               for (x = 0; x < nr_verts_in_row; ++x) {
+                       unsigned idx = 4*(x + y * nr_verts_in_row);
+                       color[idx + 0] = (GLubyte)(step * x);
+                       color[idx + 1] = 0x00;
+                       color[idx + 2] = (GLubyte)(step * y);
+                       color[idx + 3] = 0x00;
+               }
+       }
+       glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color );
+}
+
+static void generate_indices( void )
+{
+       unsigned strip, i;
+
+       /* indice size * number of strips * number of indices in strip */
+       indices = malloc(sizeof(indices[0]) * (nr_verts_in_row - 1) *
+                       (nr_indices_in_strip));
+
+       for (strip = 0; strip < nr_verts_in_row - 1; strip += 2) {
+               for (i = 0; i < nr_indices_in_strip; i+=2) {
+                       unsigned idx = i + strip * nr_indices_in_strip;
+                       unsigned idx2 = (nr_indices_in_strip - i - 2) + (strip +
+                                       1) * (nr_indices_in_strip);
+                       indices[idx + 1] = i/2 + strip*nr_verts_in_row;
+                       indices[idx] = i/2 + (strip + 1)*nr_verts_in_row;
+                       if (strip + 1 < nr_verts_in_row - 1) {
+                               indices[idx2] = i/2 + (strip + 1)*nr_verts_in_row;
+                               indices[idx2 + 1] = i/2 + (strip + 2)*nr_verts_in_row;
+                       }
+               }
+       }
+}
+
+static void init( void )
+{
+
+
+       generate_verts();
+       generate_colors();
+       generate_indices();
+
+       glClearColor( 0.0, 0.0, 0.0, 0.0 );
+       glShadeModel( GL_SMOOTH );
+
+       glEnableClientState( GL_VERTEX_ARRAY );
+       glEnableClientState( GL_COLOR_ARRAY );
+
+       glMatrixMode( GL_PROJECTION );
+       glLoadIdentity();
+       glFrustum( -100.0, 100.0, -100.0, 100.0, 1.0, 100.0 );
+       glMatrixMode( GL_MODELVIEW );
+       glLoadIdentity();
+
+#ifdef GL_EXT_compiled_vertex_array
+       if ( compiled ) {
+               glLockArraysEXT( 0, rows * rows );
+       }
+#endif
+}
+
+static void display( void )
+{
+       glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+       glDrawElements( GL_TRIANGLE_STRIP, nr_indices_in_strip * (nr_verts_in_row - 1) , GL_UNSIGNED_INT, indices );
+
+       if ( double_buffer )
+               glutSwapBuffers();
+       else
+               glFlush();
+}
+
+static void keyboard( unsigned char key, int x, int y )
+{
+       switch ( key ) {
+       case 27:
+               exit( 0 );
+               break;
+       }
+
+       glutPostRedisplay();
+}
+
+static GLboolean args( int argc, char **argv )
+{
+    GLint i;
+
+    double_buffer = GL_TRUE;
+
+    for ( i = 1 ; i < argc ; i++ ) {
+       if ( strcmp( argv[i], "-sb" ) == 0 ) {
+           double_buffer = GL_FALSE;
+       } else if ( strcmp( argv[i], "-db" ) == 0 ) {
+           double_buffer = GL_TRUE;
+       } else {
+           fprintf( stderr, "%s (Bad option).\n", argv[i] );
+           return GL_FALSE;
+       }
+    }
+    return GL_TRUE;
+}
+
+int main( int argc, char **argv )
+{
+   GLenum type;
+   char *string;
+   double version;
+
+   glutInit( &argc, argv );
+
+   if ( args( argc, argv ) == GL_FALSE ) {
+      exit( 1 );
+   }
+
+   type = GLUT_RGB | GLUT_DEPTH;
+   type |= ( double_buffer ) ? GLUT_DOUBLE : GLUT_SINGLE;
+
+   glutInitDisplayMode( type );
+   glutInitWindowSize( 250, 250 );
+   glutInitWindowPosition( 100, 100 );
+   glutCreateWindow( "CVA Test" );
+
+   /* Make sure the server supports GL 1.2 vertex arrays.
+    */
+   string = (char *) glGetString( GL_VERSION );
+
+   version = atof(string);
+   if ( version < 1.2 ) {
+      fprintf( stderr, "This program requires OpenGL 1.2 vertex arrays.\n" );
+      exit( -1 );
+   }
+
+   /* See if the server supports compiled vertex arrays.
+    */
+   string = (char *) glGetString( GL_EXTENSIONS );
+
+   if ( !strstr( string, "GL_EXT_compiled_vertex_array" ) ) {
+      fprintf( stderr, "Compiled vertex arrays not supported by this renderer.\n" );
+      compiled = GL_FALSE;
+   }
+
+   init();
+
+   glutDisplayFunc( display );
+   glutKeyboardFunc( keyboard );
+   glutMainLoop();
+
+   return 0;
+}
index 7d871e5877fa9336cd32fb988034c665fe58d6d1..1010139a20ec5cf9ab65fea4a2c1fe684229451c 100644 (file)
@@ -26,7 +26,7 @@
  * \file stencil_twoside.c
  * 
  * Simple test of GL_ATI_separate_stencil (or the OGL 2.0 equivalent) functionality.
- * Four squares are drawn
+ * Five squares (or six if stencil wrap is available) are drawn
  * with different stencil modes, but all should be rendered with the same
  * final color.
  */
@@ -37,7 +37,7 @@
 #include <GL/glut.h>
 
 static int use20syntax = 1;
-static int Width = 550;
+static int Width = 650;
 static int Height = 200;
 static const GLfloat Near = 5.0, Far = 25.0;
 
@@ -70,7 +70,7 @@ static void Display( void )
     */
 
    glDisable(GL_STENCIL_TEST);
-   glTranslatef(-6.0, 0, 0);
+   glTranslatef(-7.0, 0, 0);
    glBegin(GL_QUADS);
    glColor3f( 0.5, 0.5, 0.5 );
    glVertex2f(-1, -1);
@@ -85,6 +85,9 @@ static void Display( void )
    /* Draw the first two squares using incr for the affected face
     */
 
+   /*************************************************************************
+    * 2nd square
+    */
    if (use20syntax) {
       stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
       stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
@@ -98,8 +101,8 @@ static void Display( void )
    glTranslatef(3.0, 0, 0);
    glBegin(GL_QUADS);
    glColor3f( 0.9, 0.9, 0.9 );
-   /* this should be front facing */
    for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+      /* this should be front facing */
       glVertex2f(-1, -1);
       glVertex2f( 1, -1);
       glVertex2f( 1,  1);
@@ -107,6 +110,7 @@ static void Display( void )
    }
    glEnd();
 
+   /* stencil vals should be equal to max_stencil */
    glStencilFunc(GL_EQUAL, max_stencil, ~0);
    glBegin(GL_QUADS);
    glColor3f( 0.5, 0.5, 0.5 );
@@ -116,6 +120,9 @@ static void Display( void )
    glVertex2f(-1,  1);
    glEnd();
 
+   /*************************************************************************
+    * 3rd square
+    */
    if (use20syntax) {
       stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
       stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
@@ -129,9 +136,8 @@ static void Display( void )
    glTranslatef(3.0, 0, 0);
    glBegin(GL_QUADS);
    glColor3f( 0.9, 0.9, 0.9 );
-
-   /* this should be back facing */
    for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+      /* this should be back facing */
       glVertex2f(-1, -1);
       glVertex2f(-1,  1);
       glVertex2f( 1,  1);
@@ -139,6 +145,7 @@ static void Display( void )
    }
    glEnd();
 
+   /* stencil vals should be equal to max_stencil */
    glStencilFunc(GL_EQUAL, max_stencil, ~0);
    glBegin(GL_QUADS);
    glColor3f( 0.5, 0.5, 0.5 );
@@ -148,6 +155,9 @@ static void Display( void )
    glVertex2f(-1,  1);
    glEnd();
 
+   /*************************************************************************
+    * 4th square
+    */
    if (use20syntax) {
       stencil_func_separate(GL_FRONT, GL_NEVER, 0, ~0);
       stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
@@ -161,15 +171,13 @@ static void Display( void )
    glTranslatef(3.0, 0, 0);
    glBegin(GL_QUADS);
    glColor3f( 0.9, 0.9, 0.9 );
-
-   /* this should be back facing */
    for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
-   /* this should be back facing */
+      /* this should be back facing */
       glVertex2f(-1, -1);
       glVertex2f(-1,  1);
       glVertex2f( 1,  1);
       glVertex2f( 1, -1);
-   /* this should be front facing */
+      /* this should be front facing */
       glVertex2f(-1, -1);
       glVertex2f( 1, -1);
       glVertex2f( 1,  1);
@@ -177,6 +185,7 @@ static void Display( void )
    }
    glEnd();
 
+   /* stencil vals should be equal to max_stencil */
    glStencilFunc(GL_EQUAL, max_stencil, ~0);
    glBegin(GL_QUADS);
    glColor3f( 0.5, 0.5, 0.5 );
@@ -186,6 +195,9 @@ static void Display( void )
    glVertex2f(-1,  1);
    glEnd();
 
+   /*************************************************************************
+    * 5th square
+    */
    if (use20syntax) {
       stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
       stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
@@ -193,21 +205,19 @@ static void Display( void )
    else {
       stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
    }
-   stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR);
-   stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR);
+   stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR);
+   stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR);
 
    glTranslatef(3.0, 0, 0);
    glBegin(GL_QUADS);
    glColor3f( 0.9, 0.9, 0.9 );
-
-   /* this should be back facing */
    for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
-   /* this should be back facing */
+      /* this should be back facing */
       glVertex2f(-1, -1);
       glVertex2f(-1,  1);
       glVertex2f( 1,  1);
       glVertex2f( 1, -1);
-   /* this should be front facing */
+      /* this should be front facing */
       glVertex2f(-1, -1);
       glVertex2f( 1, -1);
       glVertex2f( 1,  1);
@@ -224,6 +234,47 @@ static void Display( void )
    glVertex2f(-1,  1);
    glEnd();
 
+   /*************************************************************************
+    * 6th square
+    */
+   if (glutExtensionSupported("GL_EXT_stencil_wrap")) {
+      if (use20syntax) {
+         stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
+         stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+      }
+      else {
+         stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
+      }
+      stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP);
+      stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP);
+
+      glTranslatef(3.0, 0, 0);
+      glBegin(GL_QUADS);
+      glColor3f( 0.9, 0.9, 0.9 );
+      for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+         /* this should be back facing */
+         glVertex2f(-1, -1);
+         glVertex2f(-1,  1);
+         glVertex2f( 1,  1);
+         glVertex2f( 1, -1);
+         /* this should be front facing */
+         glVertex2f(-1, -1);
+         glVertex2f( 1, -1);
+         glVertex2f( 1,  1);
+         glVertex2f(-1,  1);
+      }
+      glEnd();
+
+      glStencilFunc(GL_EQUAL, 260 - 255, ~0);
+      glBegin(GL_QUADS);
+      glColor3f( 0.5, 0.5, 0.5 );
+      glVertex2f(-1, -1);
+      glVertex2f( 1, -1);
+      glVertex2f( 1,  1);
+      glVertex2f(-1,  1);
+      glEnd();
+   }
+
    glPopMatrix();
 
    glutSwapBuffers();
@@ -278,7 +329,7 @@ static void Init( void )
    stencil_func_separate_ati = (PFNGLSTENCILFUNCSEPARATEATIPROC) glutGetProcAddress( "glStencilFuncSeparateATI" );
    stencil_op_separate = (PFNGLSTENCILOPSEPARATEPROC) glutGetProcAddress( "glStencilOpSeparate" );
 
-   printf("\nAll 5 squares should be the same color.\n");
+   printf("\nAll 5 (or 6) squares should be the same color.\n");
 }
 
 
index 9f68bca9149f95339600eee36c4099c08e1a0377..d66b68c415aadb8041db98df3efb8739d55e8622 100644 (file)
@@ -77,6 +77,7 @@ static void Draw(void)
    glStencilFunc(GL_ALWAYS, 1, 1);
    glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
 
+   /* red triangle (setting stencil to 1) */
    glColor3ub(200, 0, 0);
    glBegin(GL_POLYGON);        
    glVertex3i(-4, -4, 0);
@@ -88,6 +89,7 @@ static void Draw(void)
    glStencilFunc(GL_EQUAL, 1, 1);
    glStencilOp(GL_INCR, GL_KEEP, GL_DECR);
 
+   /* green quad (if over red, decr stencil to 0, else incr to 1) */
    glColor3ub(0, 200, 0);
    glBegin(GL_POLYGON);
    glVertex3i(3, 3, 0);
@@ -101,6 +103,7 @@ static void Draw(void)
    glStencilFunc(GL_EQUAL, 1, 1);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
 
+   /* blue quad (where stencil == 1) */
    glColor3ub(0, 0, 200);
    glBegin(GL_POLYGON);
    glVertex3f(2.5, 2.5, 0);
index f81aafe00f629c5a3c378f0dad4216708efd616b..660c540657a7f2ae729ca9f4664e11810b99aaa0 100644 (file)
@@ -9,7 +9,7 @@ INCDIR = $(TOP)/include
 LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
 # Add X11 and pthread libs to satisfy GNU gold.
-APP_LIB_DEPS += $(X_LIBS) -lpthread
+APP_LIB_DEPS += $(X11_LIBS) -lpthread
 
 LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
 
index 012d8dfe1f4d78ae62bf98272239b9512b42ea4d..5e831aab33221faa53f11e51b2920359bf7a9913 100644 (file)
@@ -212,21 +212,35 @@ _eglBindContextToSurfaces(_EGLContext *ctx,
                           _EGLSurface **draw, _EGLSurface **read)
 {
    _EGLSurface *newDraw = *draw, *newRead = *read;
+   _EGLContext *oldCtx;
 
-   if (newDraw->CurrentContext)
-      newDraw->CurrentContext->DrawSurface = NULL;
-   newDraw->CurrentContext = ctx;
+   oldCtx = newDraw->CurrentContext;
+   if (ctx != oldCtx) {
+      if (oldCtx) {
+         assert(*draw == oldCtx->DrawSurface);
+         oldCtx->DrawSurface = NULL;
+      }
+      if (ctx) {
+         *draw = ctx->DrawSurface;
+         ctx->DrawSurface = newDraw;
+      }
 
-   if (newRead->CurrentContext)
-      newRead->CurrentContext->ReadSurface = NULL;
-   newRead->CurrentContext = ctx;
+      newDraw->CurrentContext = ctx;
+   }
 
-   if (ctx) {
-      *draw = ctx->DrawSurface;
-      ctx->DrawSurface = newDraw;
+   if (newRead != newDraw)
+      oldCtx = newRead->CurrentContext;
+   if (ctx != oldCtx) {
+      if (oldCtx) {
+         assert(*read == oldCtx->ReadSurface);
+         oldCtx->ReadSurface = NULL;
+      }
+      if (ctx) {
+         *read = ctx->ReadSurface;
+         ctx->ReadSurface = newRead;
+      }
 
-      *read = ctx->ReadSurface;
-      ctx->ReadSurface = newRead;
+      newRead->CurrentContext = ctx;
    }
 }
 
@@ -246,15 +260,14 @@ _eglBindContextToThread(_EGLContext *ctx, _EGLThreadInfo *t)
       _eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex;
 
    oldCtx = t->CurrentContexts[apiIndex];
-   if (ctx == oldCtx)
-      return NULL;
+   if (ctx != oldCtx) {
+      if (oldCtx)
+         oldCtx->Binding = NULL;
+      if (ctx)
+         ctx->Binding = t;
 
-   if (oldCtx)
-      oldCtx->Binding = NULL;
-   if (ctx)
-      ctx->Binding = t;
-
-   t->CurrentContexts[apiIndex] = ctx;
+      t->CurrentContexts[apiIndex] = ctx;
+   }
 
    return oldCtx;
 }
@@ -352,7 +365,7 @@ _eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read)
       _eglBindContextToSurfaces(newCtx, draw, read);
 
    /* unbind the old context from its binding surfaces */
-   if (oldCtx) {
+   if (oldCtx && oldCtx != newCtx) {
       /*
        * If the new context replaces some old context, the new one should not
        * be current before the replacement and it should not be bound to any
index 91a9b54b3628b72f0867938283a199869fd86a66..b5a9938c74093637d272f2e277a592f36f9213f3 100644 (file)
@@ -26,7 +26,7 @@ INCLUDES = \
 
 ##### TARGETS #####
 
-default: depend lib$(LIBNAME).a
+default: depend lib$(LIBNAME).a $(PROGS)
 
 lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template
        $(MKLIB) -o $(LIBNAME) -static $(OBJECTS) $(EXTRA_OBJECTS)
@@ -36,13 +36,16 @@ depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURC
        touch depend
        $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null
 
+$(PROGS): % : %.o
+       $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group  $(LIBS) -Wl,--end-group
+
 # Emacs tags
 tags:
        etags `find . -name \*.[ch]` `find $(TOP)/src/gallium/include -name \*.h`
 
 # Remove .o and backup files
 clean:
-       rm -f $(OBJECTS) $(GENERATED_SOURCES) lib$(LIBNAME).a depend depend.bak
+       rm -f $(OBJECTS) $(GENERATED_SOURCES) $(PROGS) lib$(LIBNAME).a depend depend.bak
 
 # Dummy target
 install:
index c833d83e65b947f5653ecb4bd53fd3826f43c36c..b8c04f72379c0cfbbb7d2bf1ba4c36d790ef5059 100644 (file)
@@ -8,7 +8,7 @@ for driver in env['drivers']:
        SConscript(os.path.join('drivers', driver, 'SConscript'))
 
 # Needed by some state trackers
-SConscript('winsys/null/SConscript')
+SConscript('winsys/sw/null/SConscript')
 
 SConscript('state_trackers/python/SConscript')
 if platform != 'embedded':
index 0ac18426d97e736248540482d1a633c68f779297..452eceb7f4fa80cc372d92558c741892e53525ab 100644 (file)
@@ -119,6 +119,7 @@ C_SOURCES = \
        util/u_mm.c \
        util/u_rect.c \
        util/u_ringbuffer.c \
+       util/u_sampler.c \
        util/u_simple_shaders.c \
        util/u_snprintf.c \
        util/u_surface.c \
@@ -127,13 +128,15 @@ C_SOURCES = \
        util/u_timed_winsys.c \
        util/u_upload_mgr.c \
        util/u_simple_screen.c \
-       vl/vl_bitstream_parser.c \
-       vl/vl_mpeg12_mc_renderer.c \
-       vl/vl_compositor.c \
-       vl/vl_csc.c \
-       vl/vl_shader_build.c \
        target-helpers/wrap_screen.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 \
+
 GALLIVM_SOURCES = \
         gallivm/lp_bld_alpha.c \
         gallivm/lp_bld_arit.c \
@@ -152,6 +155,7 @@ GALLIVM_SOURCES = \
         gallivm/lp_bld_intr.c \
         gallivm/lp_bld_logic.c \
         gallivm/lp_bld_pack.c \
+        gallivm/lp_bld_printf.c \
         gallivm/lp_bld_sample.c \
         gallivm/lp_bld_sample_soa.c \
         gallivm/lp_bld_struct.c \
index b234b2f5f4ec93ad3928b7d68a64cd5f65020e6b..d0785bce16ba916ff8f9cf8ed816f9148556e469 100644 (file)
@@ -162,6 +162,7 @@ source = [
     'util/u_mm.c',
     'util/u_rect.c',
     'util/u_ringbuffer.c',
+    'util/u_sampler.c',
     'util/u_simple_shaders.c',
     'util/u_snprintf.c',
     'util/u_surface.c',
@@ -170,11 +171,12 @@ source = [
     'util/u_timed_winsys.c',
     'util/u_upload_mgr.c',
     'util/u_simple_screen.c',
-    'vl/vl_bitstream_parser.c',
-    'vl/vl_mpeg12_mc_renderer.c',
-    'vl/vl_compositor.c',
-    'vl/vl_csc.c',
-    'vl/vl_shader_build.c',
+    # 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',
     'target-helpers/wrap_screen.c',
 ]
 
@@ -198,6 +200,7 @@ if drawllvm:
     'gallivm/lp_bld_logic.c',
     'gallivm/lp_bld_init.cpp',
     'gallivm/lp_bld_pack.c',
+    'gallivm/lp_bld_printf.c',
     'gallivm/lp_bld_sample.c',
     'gallivm/lp_bld_sample_soa.c',
     'gallivm/lp_bld_struct.c',
index 6500891a10cb6cae31ca45bcfb1c2edfb702e97c..6fd4bd36428058173a4e28526bdb7fef80282d6e 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "pipe/p_state.h"
 #include "util/u_inlines.h"
+#include "util/u_math.h"
 #include "util/u_memory.h"
 #include "tgsi/tgsi_parse.h"
 
@@ -69,17 +70,17 @@ struct cso_context {
    unsigned nr_vertex_samplers_saved;
    void *vertex_samplers_saved[PIPE_MAX_VERTEX_SAMPLERS];
 
-   struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
-   uint nr_textures;
+   uint nr_fragment_sampler_views;
+   struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
 
-   struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
-   uint nr_vertex_textures;
+   uint nr_vertex_sampler_views;
+   struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
 
-   uint nr_textures_saved;
-   struct pipe_texture *textures_saved[PIPE_MAX_SAMPLERS];
+   uint nr_fragment_sampler_views_saved;
+   struct pipe_sampler_view *fragment_sampler_views_saved[PIPE_MAX_SAMPLERS];
 
-   uint nr_vertex_textures_saved;
-   struct pipe_texture *vertex_textures_saved[PIPE_MAX_SAMPLERS];
+   uint nr_vertex_sampler_views_saved;
+   struct pipe_sampler_view *vertex_sampler_views_saved[PIPE_MAX_VERTEX_SAMPLERS];
 
    /** Current and saved state.
     * The saved state is used as a 1-deep stack.
@@ -293,13 +294,13 @@ void cso_release_all( struct cso_context *ctx )
    }
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      pipe_texture_reference(&ctx->textures[i], NULL);
-      pipe_texture_reference(&ctx->textures_saved[i], NULL);
+      pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL);
+      pipe_sampler_view_reference(&ctx->fragment_sampler_views_saved[i], NULL);
    }
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      pipe_texture_reference(&ctx->vertex_textures[i], NULL);
-      pipe_texture_reference(&ctx->vertex_textures_saved[i], NULL);
+      pipe_sampler_view_reference(&ctx->vertex_sampler_views[i], NULL);
+      pipe_sampler_view_reference(&ctx->vertex_sampler_views_saved[i], NULL);
    }
 
    free_framebuffer_state(&ctx->fb);
@@ -616,114 +617,6 @@ cso_restore_vertex_samplers(struct cso_context *ctx)
 }
 
 
-enum pipe_error cso_set_sampler_textures( struct cso_context *ctx,
-                                          uint count,
-                                          struct pipe_texture **textures )
-{
-   uint i;
-
-   ctx->nr_textures = count;
-
-   for (i = 0; i < count; i++)
-      pipe_texture_reference(&ctx->textures[i], textures[i]);
-   for ( ; i < PIPE_MAX_SAMPLERS; i++)
-      pipe_texture_reference(&ctx->textures[i], NULL);
-
-   ctx->pipe->set_fragment_sampler_textures(ctx->pipe, count, textures);
-
-   return PIPE_OK;
-}
-
-void cso_save_sampler_textures( struct cso_context *ctx )
-{
-   uint i;
-
-   ctx->nr_textures_saved = ctx->nr_textures;
-   for (i = 0; i < ctx->nr_textures; i++) {
-      assert(!ctx->textures_saved[i]);
-      pipe_texture_reference(&ctx->textures_saved[i], ctx->textures[i]);
-   }
-}
-
-void cso_restore_sampler_textures( struct cso_context *ctx )
-{
-   uint i;
-
-   ctx->nr_textures = ctx->nr_textures_saved;
-
-   for (i = 0; i < ctx->nr_textures; i++) {
-      pipe_texture_reference(&ctx->textures[i], NULL);
-      ctx->textures[i] = ctx->textures_saved[i];
-      ctx->textures_saved[i] = NULL;
-   }
-   for ( ; i < PIPE_MAX_SAMPLERS; i++)
-      pipe_texture_reference(&ctx->textures[i], NULL);
-
-   ctx->pipe->set_fragment_sampler_textures(ctx->pipe, ctx->nr_textures, ctx->textures);
-
-   ctx->nr_textures_saved = 0;
-}
-
-
-
-enum pipe_error
-cso_set_vertex_sampler_textures(struct cso_context *ctx,
-                                uint count,
-                                struct pipe_texture **textures)
-{
-   uint i;
-
-   ctx->nr_vertex_textures = count;
-
-   for (i = 0; i < count; i++) {
-      pipe_texture_reference(&ctx->vertex_textures[i], textures[i]);
-   }
-   for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      pipe_texture_reference(&ctx->vertex_textures[i], NULL);
-   }
-
-   ctx->pipe->set_vertex_sampler_textures(ctx->pipe, count, textures);
-
-   return PIPE_OK;
-}
-
-void
-cso_save_vertex_sampler_textures(struct cso_context *ctx)
-{
-   uint i;
-
-   ctx->nr_vertex_textures_saved = ctx->nr_vertex_textures;
-   for (i = 0; i < ctx->nr_vertex_textures; i++) {
-      assert(!ctx->vertex_textures_saved[i]);
-      pipe_texture_reference(&ctx->vertex_textures_saved[i], ctx->vertex_textures[i]);
-   }
-}
-
-void
-cso_restore_vertex_sampler_textures(struct cso_context *ctx)
-{
-   uint i;
-
-   ctx->nr_vertex_textures = ctx->nr_vertex_textures_saved;
-
-   for (i = 0; i < ctx->nr_vertex_textures; i++) {
-      pipe_texture_reference(&ctx->vertex_textures[i], NULL);
-      ctx->vertex_textures[i] = ctx->vertex_textures_saved[i];
-      ctx->vertex_textures_saved[i] = NULL;
-   }
-   for ( ; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      pipe_texture_reference(&ctx->vertex_textures[i], NULL);
-   }
-
-   ctx->pipe->set_vertex_sampler_textures(ctx->pipe,
-                                          ctx->nr_vertex_textures,
-                                          ctx->vertex_textures);
-
-   ctx->nr_vertex_textures_saved = 0;
-}
-
-
-
 enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx,
                                             const struct pipe_depth_stencil_alpha_state *templ)
 {
@@ -1261,3 +1154,122 @@ void cso_restore_vertex_elements(struct cso_context *ctx)
    }
    ctx->velements_saved = NULL;
 }
+
+/* fragment sampler view state */
+
+void
+cso_set_fragment_sampler_views(struct cso_context *cso,
+                               uint count,
+                               struct pipe_sampler_view **views)
+{
+   uint i;
+
+   for (i = 0; i < count; i++) {
+      pipe_sampler_view_reference(&cso->fragment_sampler_views[i], views[i]);
+   }
+   for (; i < cso->nr_fragment_sampler_views; i++) {
+      pipe_sampler_view_reference(&cso->fragment_sampler_views[i], NULL);
+   }
+
+   cso->pipe->set_fragment_sampler_views(cso->pipe,
+                                         MAX2(count, cso->nr_fragment_sampler_views),
+                                         cso->fragment_sampler_views);
+
+   cso->nr_fragment_sampler_views = count;
+}
+
+void
+cso_save_fragment_sampler_views(struct cso_context *cso)
+{
+   uint i;
+
+   cso->nr_fragment_sampler_views_saved = cso->nr_fragment_sampler_views;
+
+   for (i = 0; i < cso->nr_fragment_sampler_views; i++) {
+      assert(!cso->fragment_sampler_views_saved[i]);
+
+      pipe_sampler_view_reference(&cso->fragment_sampler_views_saved[i],
+                                  cso->fragment_sampler_views[i]);
+   }
+}
+
+void
+cso_restore_fragment_sampler_views(struct cso_context *cso)
+{
+   uint i;
+
+   for (i = 0; i < cso->nr_fragment_sampler_views_saved; i++) {
+      pipe_sampler_view_reference(&cso->fragment_sampler_views[i], cso->fragment_sampler_views_saved[i]);
+      pipe_sampler_view_reference(&cso->fragment_sampler_views_saved[i], NULL);
+   }
+   for (; i < cso->nr_fragment_sampler_views; i++) {
+      pipe_sampler_view_reference(&cso->fragment_sampler_views[i], NULL);
+   }
+
+   cso->pipe->set_fragment_sampler_views(cso->pipe,
+                                         MAX2(cso->nr_fragment_sampler_views, cso->nr_fragment_sampler_views_saved),
+                                         cso->fragment_sampler_views);
+
+   cso->nr_fragment_sampler_views = cso->nr_fragment_sampler_views_saved;
+   cso->nr_fragment_sampler_views_saved = 0;
+}
+
+
+/* vertex sampler view state */
+
+void
+cso_set_vertex_sampler_views(struct cso_context *cso,
+                             uint count,
+                             struct pipe_sampler_view **views)
+{
+   uint i;
+
+   for (i = 0; i < count; i++) {
+      pipe_sampler_view_reference(&cso->vertex_sampler_views[i], views[i]);
+   }
+   for (; i < cso->nr_vertex_sampler_views; i++) {
+      pipe_sampler_view_reference(&cso->vertex_sampler_views[i], NULL);
+   }
+
+   cso->pipe->set_vertex_sampler_views(cso->pipe,
+                                       MAX2(count, cso->nr_vertex_sampler_views),
+                                       cso->vertex_sampler_views);
+
+   cso->nr_vertex_sampler_views = count;
+}
+
+void
+cso_save_vertex_sampler_views(struct cso_context *cso)
+{
+   uint i;
+
+   cso->nr_vertex_sampler_views_saved = cso->nr_vertex_sampler_views;
+
+   for (i = 0; i < cso->nr_vertex_sampler_views; i++) {
+      assert(!cso->vertex_sampler_views_saved[i]);
+
+      pipe_sampler_view_reference(&cso->vertex_sampler_views_saved[i],
+                                  cso->vertex_sampler_views[i]);
+   }
+}
+
+void
+cso_restore_vertex_sampler_views(struct cso_context *cso)
+{
+   uint i;
+
+   for (i = 0; i < cso->nr_vertex_sampler_views_saved; i++) {
+      pipe_sampler_view_reference(&cso->vertex_sampler_views[i], cso->vertex_sampler_views_saved[i]);
+      pipe_sampler_view_reference(&cso->vertex_sampler_views_saved[i], NULL);
+   }
+   for (; i < cso->nr_vertex_sampler_views; i++) {
+      pipe_sampler_view_reference(&cso->vertex_sampler_views[i], NULL);
+   }
+
+   cso->pipe->set_vertex_sampler_views(cso->pipe,
+                                       MAX2(cso->nr_vertex_sampler_views, cso->nr_vertex_sampler_views_saved),
+                                       cso->vertex_sampler_views);
+
+   cso->nr_vertex_sampler_views = cso->nr_vertex_sampler_views_saved;
+   cso->nr_vertex_sampler_views_saved = 0;
+}
index 9c16abd28dd483738ff6d424e625dd12a6dce334..d6bcb1fe8f761efa44d4b5f5844822187288703d 100644 (file)
@@ -103,25 +103,6 @@ void
 cso_single_vertex_sampler_done(struct cso_context *cso);
 
 
-
-enum pipe_error cso_set_sampler_textures( struct cso_context *cso,
-                                          uint count,
-                                          struct pipe_texture **textures );
-void cso_save_sampler_textures( struct cso_context *cso );
-void cso_restore_sampler_textures( struct cso_context *cso );
-
-
-
-enum pipe_error
-cso_set_vertex_sampler_textures(struct cso_context *cso,
-                                uint count,
-                                struct pipe_texture **textures);
-void
-cso_save_vertex_sampler_textures(struct cso_context *cso);
-void
-cso_restore_vertex_sampler_textures(struct cso_context *cso);
-
-
 enum pipe_error cso_set_vertex_elements(struct cso_context *ctx,
                                         unsigned count,
                                         const struct pipe_vertex_element *states);
@@ -198,6 +179,34 @@ void
 cso_restore_clip(struct cso_context *cso);
 
 
+/* fragment sampler view state */
+
+void
+cso_set_fragment_sampler_views(struct cso_context *cso,
+                               uint count,
+                               struct pipe_sampler_view **views);
+
+void
+cso_save_fragment_sampler_views(struct cso_context *cso);
+
+void
+cso_restore_fragment_sampler_views(struct cso_context *cso);
+
+
+/* vertex sampler view state */
+
+void
+cso_set_vertex_sampler_views(struct cso_context *cso,
+                             uint count,
+                             struct pipe_sampler_view **views);
+
+void
+cso_save_vertex_sampler_views(struct cso_context *cso);
+
+void
+cso_restore_vertex_sampler_views(struct cso_context *cso);
+
+
 #ifdef __cplusplus
 }
 #endif
index 1c07ab13654a5ff4fa5b6aef9ec4e553765d5161..f4615064e655e66a9eb2415af4bba4182de519eb 100644 (file)
@@ -40,6 +40,7 @@
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_sampler.h"
 
 #include "tgsi/tgsi_transform.h"
 #include "tgsi/tgsi_dump.h"
@@ -88,8 +89,9 @@ struct aaline_stage
 
    void *sampler_cso;
    struct pipe_texture *texture;
+   struct pipe_sampler_view *sampler_view;
    uint num_samplers;
-   uint num_textures;
+   uint num_sampler_views;
 
 
    /*
@@ -98,7 +100,7 @@ struct aaline_stage
    struct aaline_fragment_shader *fs;
    struct {
       void *sampler[PIPE_MAX_SAMPLERS];
-      struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+      struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
    } state;
 
    /*
@@ -111,8 +113,9 @@ struct aaline_stage
 
    void (*driver_bind_sampler_states)(struct pipe_context *, unsigned,
                                       void **);
-   void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
-                                       struct pipe_texture **);
+   void (*driver_set_sampler_views)(struct pipe_context *,
+                                    unsigned,
+                                    struct pipe_sampler_view **);
 
    struct pipe_context *pipe;
 };
@@ -394,6 +397,7 @@ aaline_create_texture(struct aaline_stage *aaline)
    struct pipe_context *pipe = aaline->pipe;
    struct pipe_screen *screen = pipe->screen;
    struct pipe_texture texTemp;
+   struct pipe_sampler_view viewTempl;
    uint level;
 
    memset(&texTemp, 0, sizeof(texTemp));
@@ -408,6 +412,16 @@ aaline_create_texture(struct aaline_stage *aaline)
    if (!aaline->texture)
       return FALSE;
 
+   u_sampler_view_default_template(&viewTempl,
+                                   aaline->texture,
+                                   aaline->texture->format);
+   aaline->sampler_view = pipe->create_sampler_view(pipe,
+                                                    aaline->texture,
+                                                    &viewTempl);
+   if (!aaline->sampler_view) {
+      return FALSE;
+   }
+
    /* Fill in mipmap images.
     * Basically each level is solid opaque, except for the outermost
     * texels which are zero.  Special case the 1x1 and 2x2 levels.
@@ -669,16 +683,16 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
 
    /* how many samplers? */
    /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
-   num_samplers = MAX2(aaline->num_textures, aaline->num_samplers);
+   num_samplers = MAX2(aaline->num_sampler_views, aaline->num_samplers);
    num_samplers = MAX2(num_samplers, aaline->fs->sampler_unit + 1);
 
    aaline->state.sampler[aaline->fs->sampler_unit] = aaline->sampler_cso;
-   pipe_texture_reference(&aaline->state.texture[aaline->fs->sampler_unit],
-                          aaline->texture);
+   pipe_sampler_view_reference(&aaline->state.sampler_views[aaline->fs->sampler_unit],
+                               aaline->sampler_view);
 
    draw->suspend_flushing = TRUE;
    aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler);
-   aaline->driver_set_sampler_textures(pipe, num_samplers, aaline->state.texture);
+   aaline->driver_set_sampler_views(pipe, num_samplers, aaline->state.sampler_views);
    draw->suspend_flushing = FALSE;
 
    /* now really draw first line */
@@ -702,8 +716,9 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
    aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
    aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
                                       aaline->state.sampler);
-   aaline->driver_set_sampler_textures(pipe, aaline->num_textures,
-                                       aaline->state.texture);
+   aaline->driver_set_sampler_views(pipe,
+                                    aaline->num_sampler_views,
+                                    aaline->state.sampler_views);
    draw->suspend_flushing = FALSE;
 
    draw->extra_shader_outputs.slot = 0;
@@ -724,7 +739,7 @@ aaline_destroy(struct draw_stage *stage)
    uint i;
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      pipe_texture_reference(&aaline->state.texture[i], NULL);
+      pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL);
    }
 
    if (aaline->sampler_cso)
@@ -733,6 +748,10 @@ aaline_destroy(struct draw_stage *stage)
    if (aaline->texture)
       pipe_texture_reference(&aaline->texture, NULL);
 
+   if (aaline->sampler_view) {
+      pipe_sampler_view_reference(&aaline->sampler_view, NULL);
+   }
+
    draw_free_temp_verts( stage );
 
    FREE( stage );
@@ -844,23 +863,24 @@ aaline_bind_sampler_states(struct pipe_context *pipe,
 
 
 static void
-aaline_set_sampler_textures(struct pipe_context *pipe,
-                            unsigned num, struct pipe_texture **texture)
+aaline_set_sampler_views(struct pipe_context *pipe,
+                         unsigned num,
+                         struct pipe_sampler_view **views)
 {
    struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
    uint i;
 
    /* save current */
    for (i = 0; i < num; i++) {
-      pipe_texture_reference(&aaline->state.texture[i], texture[i]);
+      pipe_sampler_view_reference(&aaline->state.sampler_views[i], views[i]);
    }
    for ( ; i < PIPE_MAX_SAMPLERS; i++) {
-      pipe_texture_reference(&aaline->state.texture[i], NULL);
+      pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL);
    }
-   aaline->num_textures = num;
+   aaline->num_sampler_views = num;
 
    /* pass-through */
-   aaline->driver_set_sampler_textures(aaline->pipe, num, texture);
+   aaline->driver_set_sampler_views(aaline->pipe, num, views);
 }
 
 
@@ -898,7 +918,7 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
    aaline->driver_delete_fs_state = pipe->delete_fs_state;
 
    aaline->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
-   aaline->driver_set_sampler_textures = pipe->set_fragment_sampler_textures;
+   aaline->driver_set_sampler_views = pipe->set_fragment_sampler_views;
 
    /* override the driver's functions */
    pipe->create_fs_state = aaline_create_fs_state;
@@ -906,7 +926,7 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
    pipe->delete_fs_state = aaline_delete_fs_state;
 
    pipe->bind_fragment_sampler_states = aaline_bind_sampler_states;
-   pipe->set_fragment_sampler_textures = aaline_set_sampler_textures;
+   pipe->set_fragment_sampler_views = aaline_set_sampler_views;
    
    /* Install once everything is known to be OK:
     */
index 38c22bf4e941c9a5fcf8493cde92b831d9597f37..794fd81d70f120436bf24df8cfebf1d84e697e22 100644 (file)
@@ -42,6 +42,7 @@
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_sampler.h"
 
 #include "tgsi/tgsi_transform.h"
 #include "tgsi/tgsi_dump.h"
@@ -75,8 +76,9 @@ struct pstip_stage
 
    void *sampler_cso;
    struct pipe_texture *texture;
+   struct pipe_sampler_view *sampler_view;
    uint num_samplers;
-   uint num_textures;
+   uint num_sampler_views;
 
    /*
     * Currently bound state
@@ -84,7 +86,7 @@ struct pstip_stage
    struct pstip_fragment_shader *fs;
    struct {
       void *samplers[PIPE_MAX_SAMPLERS];
-      struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
+      struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
       const struct pipe_poly_stipple *stipple;
    } state;
 
@@ -98,8 +100,9 @@ struct pstip_stage
 
    void (*driver_bind_sampler_states)(struct pipe_context *, unsigned, void **);
 
-   void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
-                                       struct pipe_texture **);
+   void (*driver_set_sampler_views)(struct pipe_context *,
+                                    unsigned,
+                                    struct pipe_sampler_view **);
 
    void (*driver_set_polygon_stipple)(struct pipe_context *,
                                       const struct pipe_poly_stipple *);
@@ -424,6 +427,7 @@ pstip_create_texture(struct pstip_stage *pstip)
    struct pipe_context *pipe = pstip->pipe;
    struct pipe_screen *screen = pipe->screen;
    struct pipe_texture texTemp;
+   struct pipe_sampler_view viewTempl;
 
    memset(&texTemp, 0, sizeof(texTemp));
    texTemp.target = PIPE_TEXTURE_2D;
@@ -437,6 +441,16 @@ pstip_create_texture(struct pstip_stage *pstip)
    if (pstip->texture == NULL)
       return FALSE;
 
+   u_sampler_view_default_template(&viewTempl,
+                                   pstip->texture,
+                                   pstip->texture->format);
+   pstip->sampler_view = pipe->create_sampler_view(pipe,
+                                                   pstip->texture,
+                                                   &viewTempl);
+   if (!pstip->sampler_view) {
+      return FALSE;
+   }
+
    return TRUE;
 }
 
@@ -515,19 +529,19 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
 
    /* how many samplers? */
    /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
-   num_samplers = MAX2(pstip->num_textures, pstip->num_samplers);
+   num_samplers = MAX2(pstip->num_sampler_views, pstip->num_samplers);
    num_samplers = MAX2(num_samplers, pstip->fs->sampler_unit + 1);
 
    /* plug in our sampler, texture */
    pstip->state.samplers[pstip->fs->sampler_unit] = pstip->sampler_cso;
-   pipe_texture_reference(&pstip->state.textures[pstip->fs->sampler_unit],
-                          pstip->texture);
+   pipe_sampler_view_reference(&pstip->state.sampler_views[pstip->fs->sampler_unit],
+                               pstip->sampler_view);
 
    assert(num_samplers <= PIPE_MAX_SAMPLERS);
 
    draw->suspend_flushing = TRUE;
    pstip->driver_bind_sampler_states(pipe, num_samplers, pstip->state.samplers);
-   pstip->driver_set_sampler_textures(pipe, num_samplers, pstip->state.textures);
+   pstip->driver_set_sampler_views(pipe, num_samplers, pstip->state.sampler_views);
    draw->suspend_flushing = FALSE;
 
    /* now really draw first triangle */
@@ -551,8 +565,9 @@ pstip_flush(struct draw_stage *stage, unsigned flags)
    pstip->driver_bind_fs_state(pipe, pstip->fs->driver_fs);
    pstip->driver_bind_sampler_states(pipe, pstip->num_samplers,
                                      pstip->state.samplers);
-   pstip->driver_set_sampler_textures(pipe, pstip->num_textures,
-                                      pstip->state.textures);
+   pstip->driver_set_sampler_views(pipe,
+                                   pstip->num_sampler_views,
+                                   pstip->state.sampler_views);
    draw->suspend_flushing = FALSE;
 }
 
@@ -571,13 +586,17 @@ pstip_destroy(struct draw_stage *stage)
    uint i;
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      pipe_texture_reference(&pstip->state.textures[i], NULL);
+      pipe_sampler_view_reference(&pstip->state.sampler_views[i], NULL);
    }
 
    pstip->pipe->delete_sampler_state(pstip->pipe, pstip->sampler_cso);
 
    pipe_texture_reference(&pstip->texture, NULL);
 
+   if (pstip->sampler_view) {
+      pipe_sampler_view_reference(&pstip->sampler_view, NULL);
+   }
+
    draw_free_temp_verts( stage );
    FREE( stage );
 }
@@ -682,24 +701,25 @@ pstip_bind_sampler_states(struct pipe_context *pipe,
 
 
 static void
-pstip_set_sampler_textures(struct pipe_context *pipe,
-                           unsigned num, struct pipe_texture **texture)
+pstip_set_sampler_views(struct pipe_context *pipe,
+                        unsigned num,
+                        struct pipe_sampler_view **views)
 {
    struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
    uint i;
 
    /* save current */
    for (i = 0; i < num; i++) {
-      pipe_texture_reference(&pstip->state.textures[i], texture[i]);
+      pipe_sampler_view_reference(&pstip->state.sampler_views[i], views[i]);
    }
    for (; i < PIPE_MAX_SAMPLERS; i++) {
-      pipe_texture_reference(&pstip->state.textures[i], NULL);
+      pipe_sampler_view_reference(&pstip->state.sampler_views[i], NULL);
    }
 
-   pstip->num_textures = num;
+   pstip->num_sampler_views = num;
 
    /* pass-through */
-   pstip->driver_set_sampler_textures(pstip->pipe, num, texture);
+   pstip->driver_set_sampler_views(pstip->pipe, num, views);
 }
 
 
@@ -756,7 +776,7 @@ draw_install_pstipple_stage(struct draw_context *draw,
    pstip->driver_delete_fs_state = pipe->delete_fs_state;
 
    pstip->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
-   pstip->driver_set_sampler_textures = pipe->set_fragment_sampler_textures;
+   pstip->driver_set_sampler_views = pipe->set_fragment_sampler_views;
    pstip->driver_set_polygon_stipple = pipe->set_polygon_stipple;
 
    /* override the driver's functions */
@@ -765,7 +785,7 @@ draw_install_pstipple_stage(struct draw_context *draw,
    pipe->delete_fs_state = pstip_delete_fs_state;
 
    pipe->bind_fragment_sampler_states = pstip_bind_sampler_states;
-   pipe->set_fragment_sampler_textures = pstip_set_sampler_textures;
+   pipe->set_fragment_sampler_views = pstip_set_sampler_views;
    pipe->set_polygon_stipple = pstip_set_polygon_stipple;
 
    return TRUE;
index 27099579618f2ccf367a86b88bd9249f7207549c..1c7db0005a95099a87044e164213e2a06d551ccf 100644 (file)
@@ -238,38 +238,15 @@ vbuf_start_prim( struct vbuf_stage *vbuf, uint prim )
       unsigned output_format;
       unsigned src_offset = (vbuf->vinfo->attrib[i].src_index * 4 * sizeof(float) );
 
-      switch (vbuf->vinfo->attrib[i].emit) {
-      case EMIT_4F:
-        output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-        emit_sz = 4 * sizeof(float);
-        break;
-      case EMIT_3F:
-        output_format = PIPE_FORMAT_R32G32B32_FLOAT;
-        emit_sz = 3 * sizeof(float);
-        break;
-      case EMIT_2F:
-        output_format = PIPE_FORMAT_R32G32_FLOAT;
-        emit_sz = 2 * sizeof(float);
-        break;
-      case EMIT_1F:
-        output_format = PIPE_FORMAT_R32_FLOAT;
-        emit_sz = 1 * sizeof(float);
-        break;
-      case EMIT_1F_PSIZE:
-        output_format = PIPE_FORMAT_R32_FLOAT;
-        emit_sz = 1 * sizeof(float);
+      output_format = draw_translate_vinfo_format(vbuf->vinfo->attrib[i].emit);
+      emit_sz = draw_translate_vinfo_size(vbuf->vinfo->attrib[i].emit);
+
+      /* doesn't handle EMIT_OMIT */
+      assert(emit_sz != 0);
+
+      if (vbuf->vinfo->attrib[i].emit == EMIT_1F_PSIZE) {
         src_buffer = 1;
         src_offset = 0;
-        break;
-      case EMIT_4UB:
-        output_format = PIPE_FORMAT_A8R8G8B8_UNORM;
-        emit_sz = 4 * sizeof(ubyte);
-         break;
-      default:
-        assert(0);
-        output_format = PIPE_FORMAT_NONE;
-        emit_sz = 0;
-        break;
       }
 
       hw_key.element[i].type = TRANSLATE_ELEMENT_NORMAL;
index ae357b512262ccf08584a6eb7fdda863766e2553..a7917f54b048257be04dcbe1aa6cda69d6bcff2d 100644 (file)
@@ -86,40 +86,15 @@ void draw_pt_emit_prepare( struct pt_emit *emit,
       unsigned output_format;
       unsigned src_offset = (vinfo->attrib[i].src_index * 4 * sizeof(float) );
 
+      output_format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
+      emit_sz = draw_translate_vinfo_size(vinfo->attrib[i].emit);
 
-         
-      switch (vinfo->attrib[i].emit) {
-      case EMIT_4F:
-        output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-        emit_sz = 4 * sizeof(float);
-        break;
-      case EMIT_3F:
-        output_format = PIPE_FORMAT_R32G32B32_FLOAT;
-        emit_sz = 3 * sizeof(float);
-        break;
-      case EMIT_2F:
-        output_format = PIPE_FORMAT_R32G32_FLOAT;
-        emit_sz = 2 * sizeof(float);
-        break;
-      case EMIT_1F:
-        output_format = PIPE_FORMAT_R32_FLOAT;
-        emit_sz = 1 * sizeof(float);
-        break;
-      case EMIT_1F_PSIZE:
-        output_format = PIPE_FORMAT_R32_FLOAT;
-        emit_sz = 1 * sizeof(float);
+      /* doesn't handle EMIT_OMIT */
+      assert(emit_sz != 0);
+
+      if (vinfo->attrib[i].emit == EMIT_1F_PSIZE) {
         src_buffer = 1;
         src_offset = 0;
-        break;
-      case EMIT_4UB:
-        output_format = PIPE_FORMAT_A8R8G8B8_UNORM;
-        emit_sz = 4 * sizeof(ubyte);
-         break;
-      default:
-        assert(0);
-        output_format = PIPE_FORMAT_NONE;
-        emit_sz = 0;
-        break;
       }
 
       hw_key.element[i].type = TRANSLATE_ELEMENT_NORMAL;
index 2a604470e9afadac15f21ab9141a68138822c9d2..1994ddf2bcc45c0e7d81fdcab75e3d9d02b04dea 100644 (file)
@@ -129,41 +129,16 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
       unsigned input_offset = src->src_offset;
       unsigned output_format;
 
-      switch (vinfo->attrib[i].emit) {
-      case EMIT_4UB:
-        output_format = PIPE_FORMAT_R8G8B8A8_UNORM;
-        emit_sz = 4 * sizeof(unsigned char);
-         break;
-      case EMIT_4F:
-        output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-        emit_sz = 4 * sizeof(float);
-         break;
-      case EMIT_3F:
-        output_format = PIPE_FORMAT_R32G32B32_FLOAT;
-        emit_sz = 3 * sizeof(float);
-         break;
-      case EMIT_2F:
-        output_format = PIPE_FORMAT_R32G32_FLOAT;
-        emit_sz = 2 * sizeof(float);
-         break;
-      case EMIT_1F:
-        output_format = PIPE_FORMAT_R32_FLOAT;
-        emit_sz = 1 * sizeof(float);
-         break;
-      case EMIT_1F_PSIZE:
+      output_format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
+      emit_sz = draw_translate_vinfo_size(vinfo->attrib[i].emit);
+
+      if (vinfo->attrib[i].emit == EMIT_OMIT)
+        continue;
+
+      if (vinfo->attrib[i].emit == EMIT_1F_PSIZE) {
         input_format = PIPE_FORMAT_R32_FLOAT;
         input_buffer = draw->pt.nr_vertex_buffers;
         input_offset = 0;
-        output_format = PIPE_FORMAT_R32_FLOAT;
-        emit_sz = 1 * sizeof(float);
-         break;
-      case EMIT_OMIT:
-         continue;
-      default:
-         assert(0);
-        output_format = PIPE_FORMAT_NONE;
-        emit_sz = 0;
-        continue;
       }
 
       key.element[i].type = TRANSLATE_ELEMENT_NORMAL;
index 1aecb510777330e04a042433601e73c16c151e7f..389e2b105e56aa962c4730d995f48f49c94e232e 100644 (file)
@@ -130,31 +130,10 @@ static void fse_prepare( struct draw_pt_middle_end *middle,
       unsigned dst_offset = 0;
 
       for (i = 0; i < vinfo->num_attribs; i++) {
-         unsigned emit_sz = 0;
-
-         switch (vinfo->attrib[i].emit) {
-         case EMIT_4F:
-            emit_sz = 4 * sizeof(float);
-            break;
-         case EMIT_3F:
-            emit_sz = 3 * sizeof(float);
-            break;
-         case EMIT_2F:
-            emit_sz = 2 * sizeof(float);
-            break;
-         case EMIT_1F:
-            emit_sz = 1 * sizeof(float);
-            break;
-         case EMIT_1F_PSIZE:
-            emit_sz = 1 * sizeof(float);
-            break;
-         case EMIT_4UB:
-            emit_sz = 4 * sizeof(ubyte);
-            break;
-         default:
-            assert(0);
-            break;
-         }
+         unsigned emit_sz = draw_translate_vinfo_size(vinfo->attrib[i].emit);
+
+         /* doesn't handle EMIT_OMIT */
+         assert(emit_sz != 0);
 
          /* The elements in the key correspond to vertex shader output
           * numbers, not to positions in the hw vertex description --
index 3214213e44526e27063b9c62b1fc0b3b01cedd1f..a4f5e882c0a9137f5c5b467becfaab798cf16e54 100644 (file)
@@ -48,30 +48,12 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
    uint i;
 
    vinfo->size = 0;
-   for (i = 0; i < vinfo->num_attribs; i++) {
-      switch (vinfo->attrib[i].emit) {
-      case EMIT_OMIT:
-         break;
-      case EMIT_4UB:
-         /* fall-through */
-      case EMIT_1F_PSIZE:
-         /* fall-through */
-      case EMIT_1F:
-         vinfo->size += 1;
-         break;
-      case EMIT_2F:
-         vinfo->size += 2;
-         break;
-      case EMIT_3F:
-         vinfo->size += 3;
-         break;
-      case EMIT_4F:
-         vinfo->size += 4;
-         break;
-      default:
-         assert(0);
-      }
-   }
+   for (i = 0; i < vinfo->num_attribs; i++)
+      vinfo->size += draw_translate_vinfo_size(vinfo->attrib[i].emit);
+
+   assert(vinfo->size % 4 == 0);
+   /* in dwords */
+   vinfo->size /= 4;
 }
 
 
@@ -120,6 +102,13 @@ draw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data)
          debug_printf("%u ", *data++);
          debug_printf("%u ", *data++);
          break;
+      case EMIT_4UB_BGRA:
+         debug_printf("EMIT_4UB_BGRA:\t");
+         debug_printf("%u ", *data++);
+         debug_printf("%u ", *data++);
+         debug_printf("%u ", *data++);
+         debug_printf("%u ", *data++);
+         break;
       default:
          assert(0);
       }
index 8c3c7befbc76795d3030637092e35df99245ec41..ca272371267a957aab5f23dbd11892ca03c1515a 100644 (file)
@@ -54,7 +54,8 @@ enum attrib_emit {
    EMIT_2F,
    EMIT_3F,
    EMIT_4F,
-   EMIT_4UB  /**< XXX may need variations for RGBA vs BGRA, etc */
+   EMIT_4UB, /**< is RGBA like the rest */
+   EMIT_4UB_BGRA
 };
 
 
@@ -141,9 +142,11 @@ void draw_dump_emitted_vertex(const struct vertex_info *vinfo,
                               const uint8_t *data);
 
 
-static INLINE unsigned draw_translate_vinfo_format(unsigned format )
+static INLINE unsigned draw_translate_vinfo_format(enum attrib_emit emit)
 {
-   switch (format) {
+   switch (emit) {
+   case EMIT_OMIT:
+      return PIPE_FORMAT_NONE;
    case EMIT_1F:
    case EMIT_1F_PSIZE:
       return PIPE_FORMAT_R32_FLOAT;
@@ -155,10 +158,36 @@ static INLINE unsigned draw_translate_vinfo_format(unsigned format )
       return PIPE_FORMAT_R32G32B32A32_FLOAT;
    case EMIT_4UB:
       return PIPE_FORMAT_R8G8B8A8_UNORM;
+   case EMIT_4UB_BGRA:
+      return PIPE_FORMAT_B8G8R8A8_UNORM;
    default:
+      assert(!"unexpected format");
       return PIPE_FORMAT_NONE;
    }
 }
 
+static INLINE unsigned draw_translate_vinfo_size(enum attrib_emit emit)
+{
+   switch (emit) {
+   case EMIT_OMIT:
+      return 0;
+   case EMIT_1F:
+   case EMIT_1F_PSIZE:
+      return 1 * sizeof(float);
+   case EMIT_2F:
+      return 2 * sizeof(float);
+   case EMIT_3F:
+      return 3 * sizeof(float);
+   case EMIT_4F:
+      return 4 * sizeof(float);
+   case EMIT_4UB:
+      return 4 * sizeof(unsigned char);
+   case EMIT_4UB_BGRA:
+      return 4 * sizeof(unsigned char);
+   default:
+      assert(!"unexpected format");
+      return 0;
+   }
+}
 
 #endif /* DRAW_VERTEX_H */
index ece1ddde0cbadcc88ec9e10fe2aa49a88263c7b2..8f8bbe7cb88265c46e7be26786085856cce1d86b 100644 (file)
@@ -401,13 +401,11 @@ static boolean emit_output( struct aos_compilation *cp,
       emit_store_R32G32B32A32(cp, ptr, dataXMM);
       break;
    case EMIT_4UB:
-      if (1) {
-         emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W));
-         emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
-      }
-      else {
-         emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
-      }
+      emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
+      break;
+   case EMIT_4UB_BGRA:
+      emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W));
+      emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
       break;
    default:
       AOS_ERROR(cp, "unhandled output format");
diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h
new file mode 100644 (file)
index 0000000..70a4960
--- /dev/null
@@ -0,0 +1,47 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Wrapper for LLVM header file #includes.
+ */
+
+
+#ifndef LP_BLD_H
+#define LP_BLD_H
+
+
+#include <llvm-c/Core.h>  
+
+
+/** Set version to 0 if missing to avoid #ifdef HAVE_LLVM everywhere */
+#ifndef HAVE_LLVM
+#define HAVE_LLVM 0x0207
+#endif
+
+
+#endif /* LP_BLD_H */
index fe3cedcc48c759f1d979ff95ffbfaff381479179..0f99fec65eda520391d7165a3ceb73ae333c99d4 100644 (file)
@@ -35,7 +35,7 @@
 #define LP_BLD_ALPHA_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 struct pipe_alpha_state;
 struct lp_type;
index 233a36669d4f13fc1484a7e308fcc7c80548854f..8e8fcccf564ead77eae89145de1df7bbd7946622 100644 (file)
@@ -361,12 +361,12 @@ lp_build_mul_u8n(LLVMBuilderRef builder,
    LLVMValueRef c8;
    LLVMValueRef ab;
 
-   c8 = lp_build_int_const_scalar(i16_type, 8);
+   c8 = lp_build_const_int_vec(i16_type, 8);
    
 #if 0
    
    /* a*b/255 ~= (a*(b + 1)) >> 256 */
-   b = LLVMBuildAdd(builder, b, lp_build_int_const_scalar(i16_type, 1), "");
+   b = LLVMBuildAdd(builder, b, lp_build_const_int_vec(i16_type, 1), "");
    ab = LLVMBuildMul(builder, a, b, "");
 
 #else
@@ -374,7 +374,7 @@ lp_build_mul_u8n(LLVMBuilderRef builder,
    /* ab/255 ~= (ab + (ab >> 8) + 0x80) >> 8 */
    ab = LLVMBuildMul(builder, a, b, "");
    ab = LLVMBuildAdd(builder, ab, LLVMBuildLShr(builder, ab, c8, ""), "");
-   ab = LLVMBuildAdd(builder, ab, lp_build_int_const_scalar(i16_type, 0x80), "");
+   ab = LLVMBuildAdd(builder, ab, lp_build_const_int_vec(i16_type, 0x80), "");
 
 #endif
    
@@ -429,7 +429,7 @@ lp_build_mul(struct lp_build_context *bld,
    }
 
    if(type.fixed)
-      shift = lp_build_int_const_scalar(type, type.width/2);
+      shift = lp_build_const_int_vec(type, type.width/2);
    else
       shift = NULL;
 
@@ -491,7 +491,7 @@ lp_build_mul_imm(struct lp_build_context *bld,
           * for Inf and NaN.
           */
          unsigned mantissa = lp_mantissa(bld->type);
-         factor = lp_build_int_const_scalar(bld->type, (unsigned long long)shift << mantissa);
+         factor = lp_build_const_int_vec(bld->type, (unsigned long long)shift << mantissa);
          a = LLVMBuildBitCast(bld->builder, a, lp_build_int_vec_type(bld->type), "");
          a = LLVMBuildAdd(bld->builder, a, factor, "");
          a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(bld->type), "");
@@ -499,12 +499,12 @@ lp_build_mul_imm(struct lp_build_context *bld,
 #endif
       }
       else {
-         factor = lp_build_const_scalar(bld->type, shift);
+         factor = lp_build_const_vec(bld->type, shift);
          return LLVMBuildShl(bld->builder, a, factor, "");
       }
    }
 
-   factor = lp_build_const_scalar(bld->type, (double)b);
+   factor = lp_build_const_vec(bld->type, (double)b);
    return lp_build_mul(bld, a, factor);
 }
 
@@ -567,7 +567,7 @@ lp_build_lerp(struct lp_build_context *bld,
        * but it will be wrong for other uses. Basically we need a more
        * powerful lp_type, capable of further distinguishing the values
        * interpretation from the value storage. */
-      res = LLVMBuildAnd(bld->builder, res, lp_build_int_const_scalar(bld->type, (1 << bld->type.width/2) - 1), "");
+      res = LLVMBuildAnd(bld->builder, res, lp_build_const_int_vec(bld->type, (1 << bld->type.width/2) - 1), "");
 
    return res;
 }
@@ -689,7 +689,7 @@ lp_build_abs(struct lp_build_context *bld,
          /* vector of floats */
          LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
          unsigned long long absMask = ~(1ULL << (type.width - 1));
-         LLVMValueRef mask = lp_build_int_const_scalar(type, ((unsigned long long) absMask));
+         LLVMValueRef mask = lp_build_const_int_vec(type, ((unsigned long long) absMask));
          a = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
          a = LLVMBuildAnd(bld->builder, a, mask, "");
          a = LLVMBuildBitCast(bld->builder, a, vec_type, "");
@@ -751,7 +751,7 @@ lp_build_sgn(struct lp_build_context *bld,
          /* vector */
          int_type = lp_build_int_vec_type(type);
          vec_type = lp_build_vec_type(type);
-         mask = lp_build_int_const_scalar(type, maskBit);
+         mask = lp_build_const_int_vec(type, maskBit);
       }
 
       /* Take the sign bit and add it to 1 constant */
@@ -763,7 +763,7 @@ lp_build_sgn(struct lp_build_context *bld,
    }
    else
    {
-      LLVMValueRef minus_one = lp_build_const_scalar(type, -1.0);
+      LLVMValueRef minus_one = lp_build_const_vec(type, -1.0);
       cond = lp_build_cmp(bld, PIPE_FUNC_GREATER, a, bld->zero);
       res = lp_build_select(bld, cond, bld->one, minus_one);
    }
@@ -789,8 +789,8 @@ lp_build_set_sign(struct lp_build_context *bld,
    const struct lp_type type = bld->type;
    LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
    LLVMTypeRef vec_type = lp_build_vec_type(type);
-   LLVMValueRef shift = lp_build_int_const_scalar(type, type.width - 1);
-   LLVMValueRef mask = lp_build_int_const_scalar(type,
+   LLVMValueRef shift = lp_build_const_int_vec(type, type.width - 1);
+   LLVMValueRef mask = lp_build_const_int_vec(type,
                              ~((unsigned long long) 1 << (type.width - 1)));
    LLVMValueRef val, res;
 
@@ -1034,7 +1034,7 @@ lp_build_iround(struct lp_build_context *bld,
    }
    else {
       LLVMTypeRef vec_type = lp_build_vec_type(type);
-      LLVMValueRef mask = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.width - 1));
+      LLVMValueRef mask = lp_build_const_int_vec(type, (unsigned long long)1 << (type.width - 1));
       LLVMValueRef sign;
       LLVMValueRef half;
 
@@ -1043,7 +1043,7 @@ lp_build_iround(struct lp_build_context *bld,
       sign = LLVMBuildAnd(bld->builder, sign, mask, "");
 
       /* sign * 0.5 */
-      half = lp_build_const_scalar(type, 0.5);
+      half = lp_build_const_vec(type, 0.5);
       half = LLVMBuildBitCast(bld->builder, half, int_vec_type, "");
       half = LLVMBuildOr(bld->builder, sign, half, "");
       half = LLVMBuildBitCast(bld->builder, half, vec_type, "");
@@ -1086,18 +1086,18 @@ lp_build_ifloor(struct lp_build_context *bld,
       /* Take the sign bit and add it to 1 constant */
       LLVMTypeRef vec_type = lp_build_vec_type(type);
       unsigned mantissa = lp_mantissa(type);
-      LLVMValueRef mask = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.width - 1));
+      LLVMValueRef mask = lp_build_const_int_vec(type, (unsigned long long)1 << (type.width - 1));
       LLVMValueRef sign;
       LLVMValueRef offset;
 
       /* sign = a < 0 ? ~0 : 0 */
       sign = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
       sign = LLVMBuildAnd(bld->builder, sign, mask, "");
-      sign = LLVMBuildAShr(bld->builder, sign, lp_build_int_const_scalar(type, type.width - 1), "");
+      sign = LLVMBuildAShr(bld->builder, sign, lp_build_const_int_vec(type, type.width - 1), "");
       lp_build_name(sign, "floor.sign");
 
       /* offset = -0.99999(9)f */
-      offset = lp_build_const_scalar(type, -(double)(((unsigned long long)1 << mantissa) - 1)/((unsigned long long)1 << mantissa));
+      offset = lp_build_const_vec(type, -(double)(((unsigned long long)1 << mantissa) - 1)/((unsigned long long)1 << mantissa));
       offset = LLVMConstBitCast(offset, int_vec_type);
 
       /* offset = a < 0 ? -0.99999(9)f : 0.0f */
@@ -1268,7 +1268,7 @@ lp_build_exp(struct lp_build_context *bld,
              LLVMValueRef x)
 {
    /* log2(e) = 1/log(2) */
-   LLVMValueRef log2e = lp_build_const_scalar(bld->type, 1.4426950408889634);
+   LLVMValueRef log2e = lp_build_const_vec(bld->type, 1.4426950408889634);
 
    return lp_build_mul(bld, log2e, lp_build_exp2(bld, x));
 }
@@ -1282,7 +1282,7 @@ lp_build_log(struct lp_build_context *bld,
              LLVMValueRef x)
 {
    /* log(2) */
-   LLVMValueRef log2 = lp_build_const_scalar(bld->type, 0.69314718055994529);
+   LLVMValueRef log2 = lp_build_const_vec(bld->type, 0.69314718055994529);
 
    return lp_build_mul(bld, log2, lp_build_exp2(bld, x));
 }
@@ -1318,7 +1318,7 @@ lp_build_polynomial(struct lp_build_context *bld,
       if (type.length == 1)
          coeff = LLVMConstReal(float_type, coeffs[i]);
       else
-         coeff = lp_build_const_scalar(type, coeffs[i]);
+         coeff = lp_build_const_vec(type, coeffs[i]);
 
       if(res)
          res = lp_build_add(bld, coeff, lp_build_mul(bld, x, res));
@@ -1375,11 +1375,11 @@ lp_build_exp2_approx(struct lp_build_context *bld,
 
       assert(type.floating && type.width == 32);
 
-      x = lp_build_min(bld, x, lp_build_const_scalar(type,  129.0));
-      x = lp_build_max(bld, x, lp_build_const_scalar(type, -126.99999));
+      x = lp_build_min(bld, x, lp_build_const_vec(type,  129.0));
+      x = lp_build_max(bld, x, lp_build_const_vec(type, -126.99999));
 
       /* ipart = int(x - 0.5) */
-      ipart = LLVMBuildSub(bld->builder, x, lp_build_const_scalar(type, 0.5f), "");
+      ipart = LLVMBuildSub(bld->builder, x, lp_build_const_vec(type, 0.5f), "");
       ipart = LLVMBuildFPToSI(bld->builder, ipart, int_vec_type, "");
 
       /* fpart = x - ipart */
@@ -1389,8 +1389,8 @@ lp_build_exp2_approx(struct lp_build_context *bld,
 
    if(p_exp2_int_part || p_exp2) {
       /* expipart = (float) (1 << ipart) */
-      expipart = LLVMBuildAdd(bld->builder, ipart, lp_build_int_const_scalar(type, 127), "");
-      expipart = LLVMBuildShl(bld->builder, expipart, lp_build_int_const_scalar(type, 23), "");
+      expipart = LLVMBuildAdd(bld->builder, ipart, lp_build_const_int_vec(type, 127), "");
+      expipart = LLVMBuildShl(bld->builder, expipart, lp_build_const_int_vec(type, 23), "");
       expipart = LLVMBuildBitCast(bld->builder, expipart, vec_type, "");
    }
 
@@ -1456,8 +1456,8 @@ lp_build_log2_approx(struct lp_build_context *bld,
    LLVMTypeRef vec_type = lp_build_vec_type(type);
    LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
 
-   LLVMValueRef expmask = lp_build_int_const_scalar(type, 0x7f800000);
-   LLVMValueRef mantmask = lp_build_int_const_scalar(type, 0x007fffff);
+   LLVMValueRef expmask = lp_build_const_int_vec(type, 0x7f800000);
+   LLVMValueRef mantmask = lp_build_const_int_vec(type, 0x007fffff);
    LLVMValueRef one = LLVMConstBitCast(bld->one, int_vec_type);
 
    LLVMValueRef i = NULL;
@@ -1482,8 +1482,8 @@ lp_build_log2_approx(struct lp_build_context *bld,
    }
 
    if(p_floor_log2 || p_log2) {
-      logexp = LLVMBuildLShr(bld->builder, exp, lp_build_int_const_scalar(type, 23), "");
-      logexp = LLVMBuildSub(bld->builder, logexp, lp_build_int_const_scalar(type, 127), "");
+      logexp = LLVMBuildLShr(bld->builder, exp, lp_build_const_int_vec(type, 23), "");
+      logexp = LLVMBuildSub(bld->builder, logexp, lp_build_const_int_vec(type, 127), "");
       logexp = LLVMBuildSIToFP(bld->builder, logexp, vec_type, "");
    }
 
index 7a10fe1220968a5b75133cce00d77af972124ac2..31efa9921ce61739397bc9db585485006ea2ab5b 100644 (file)
@@ -37,7 +37,7 @@
 #define LP_BLD_ARIT_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 
 struct lp_type;
index 5a9e1c1fb2fccc53c96eba905ec53151cf167d6b..ebbdb1a604c679aed7427ba9a1b3fd6e1ba2e496 100644 (file)
@@ -40,7 +40,7 @@
  * for a standalone example.
  */
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
  
 #include "pipe/p_format.h"
 
index 8a275fa72f386d46c299dd4b0968ab4052e12284..57843e9a60ce909e230aac77bf284710801c853b 100644 (file)
@@ -263,7 +263,7 @@ lp_build_one(struct lp_type type)
       if(type.sign)
          /* TODO: Unfortunately this caused "Tried to create a shift operation
           * on a non-integer type!" */
-         vec = LLVMConstLShr(vec, lp_build_int_const_scalar(type, 1));
+         vec = LLVMConstLShr(vec, lp_build_const_int_vec(type, 1));
 #endif
 
       return vec;
@@ -283,8 +283,8 @@ lp_build_one(struct lp_type type)
  * Build constant-valued vector from a scalar value.
  */
 LLVMValueRef
-lp_build_const_scalar(struct lp_type type,
-                      double val)
+lp_build_const_vec(struct lp_type type,
+                   double val)
 {
    LLVMTypeRef elem_type = lp_build_elem_type(type);
    LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
@@ -309,7 +309,7 @@ lp_build_const_scalar(struct lp_type type,
 
 
 LLVMValueRef
-lp_build_int_const_scalar(struct lp_type type,
+lp_build_const_int_vec(struct lp_type type,
                           long long val)
 {
    LLVMTypeRef elem_type = lp_build_int_elem_type(type);
index 40786361031e5e15863bf337e4662923d189166f..9ca2f0664ebe88f1bdf9607a403d2f227b0b4582 100644 (file)
@@ -37,9 +37,9 @@
 #define LP_BLD_CONST_H
 
 
-#include "os/os_llvm.h"
+#include "pipe/p_compiler.h"
+#include "gallivm/lp_bld.h"
 
-#include <pipe/p_compiler.h>
 
 
 struct lp_type;
@@ -85,13 +85,11 @@ lp_build_one(struct lp_type type);
 
 
 LLVMValueRef
-lp_build_const_scalar(struct lp_type type,
-                      double val);
+lp_build_const_vec(struct lp_type type, double val);
 
 
 LLVMValueRef
-lp_build_int_const_scalar(struct lp_type type,
-                          long long val);
+lp_build_const_int_vec(struct lp_type type, long long val);
 
 
 LLVMValueRef
index f77cf78721315b89c98c80e4ce823fe8f0bc49dc..3f7f2ebde9ce700b99e88e50ae0b8249b43ebb97 100644 (file)
@@ -114,13 +114,13 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
    scale = (double)mask/ubound;
    bias = (double)((unsigned long long)1 << (mantissa - n));
 
-   res = LLVMBuildMul(builder, src, lp_build_const_scalar(src_type, scale), "");
-   res = LLVMBuildAdd(builder, res, lp_build_const_scalar(src_type, bias), "");
+   res = LLVMBuildMul(builder, src, lp_build_const_vec(src_type, scale), "");
+   res = LLVMBuildAdd(builder, res, lp_build_const_vec(src_type, bias), "");
    res = LLVMBuildBitCast(builder, res, int_vec_type, "");
 
    if(dst_width > n) {
       int shift = dst_width - n;
-      res = LLVMBuildShl(builder, res, lp_build_int_const_scalar(src_type, shift), "");
+      res = LLVMBuildShl(builder, res, lp_build_const_int_vec(src_type, shift), "");
 
       /* TODO: Fill in the empty lower bits for additional precision? */
       /* YES: this fixes progs/trivial/tri-z-eq.c.
@@ -130,21 +130,21 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
 #if 0
       {
          LLVMValueRef msb;
-         msb = LLVMBuildLShr(builder, res, lp_build_int_const_scalar(src_type, dst_width - 1), "");
-         msb = LLVMBuildShl(builder, msb, lp_build_int_const_scalar(src_type, shift), "");
-         msb = LLVMBuildSub(builder, msb, lp_build_int_const_scalar(src_type, 1), "");
+         msb = LLVMBuildLShr(builder, res, lp_build_const_int_vec(src_type, dst_width - 1), "");
+         msb = LLVMBuildShl(builder, msb, lp_build_const_int_vec(src_type, shift), "");
+         msb = LLVMBuildSub(builder, msb, lp_build_const_int_vec(src_type, 1), "");
          res = LLVMBuildOr(builder, res, msb, "");
       }
 #elif 0
       while(shift > 0) {
-         res = LLVMBuildOr(builder, res, LLVMBuildLShr(builder, res, lp_build_int_const_scalar(src_type, n), ""), "");
+         res = LLVMBuildOr(builder, res, LLVMBuildLShr(builder, res, lp_build_const_int_vec(src_type, n), ""), "");
          shift -= n;
          n *= 2;
       }
 #endif
    }
    else
-      res = LLVMBuildAnd(builder, res, lp_build_int_const_scalar(src_type, mask), "");
+      res = LLVMBuildAnd(builder, res, lp_build_const_int_vec(src_type, mask), "");
 
    return res;
 }
@@ -183,10 +183,10 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
 
    if(src_width > mantissa) {
       int shift = src_width - mantissa;
-      res = LLVMBuildLShr(builder, res, lp_build_int_const_scalar(dst_type, shift), "");
+      res = LLVMBuildLShr(builder, res, lp_build_const_int_vec(dst_type, shift), "");
    }
 
-   bias_ = lp_build_const_scalar(dst_type, bias);
+   bias_ = lp_build_const_vec(dst_type, bias);
 
    res = LLVMBuildOr(builder,
                      res,
@@ -195,7 +195,7 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
    res = LLVMBuildBitCast(builder, res, vec_type, "");
 
    res = LLVMBuildSub(builder, res, bias_, "");
-   res = LLVMBuildMul(builder, res, lp_build_const_scalar(dst_type, scale), "");
+   res = LLVMBuildMul(builder, res, lp_build_const_vec(dst_type, scale), "");
 
    return res;
 }
@@ -251,7 +251,7 @@ lp_build_conv(LLVMBuilderRef builder,
          if(dst_min == 0.0)
             thres = bld.zero;
          else
-            thres = lp_build_const_scalar(src_type, dst_min);
+            thres = lp_build_const_vec(src_type, dst_min);
          for(i = 0; i < num_tmps; ++i)
             tmp[i] = lp_build_max(&bld, tmp[i], thres);
       }
@@ -260,7 +260,7 @@ lp_build_conv(LLVMBuilderRef builder,
          if(dst_max == 1.0)
             thres = bld.one;
          else
-            thres = lp_build_const_scalar(src_type, dst_max);
+            thres = lp_build_const_vec(src_type, dst_max);
          for(i = 0; i < num_tmps; ++i)
             tmp[i] = lp_build_min(&bld, tmp[i], thres);
       }
@@ -288,7 +288,7 @@ lp_build_conv(LLVMBuilderRef builder,
          LLVMTypeRef tmp_vec_type;
 
          if (dst_scale != 1.0) {
-            LLVMValueRef scale = lp_build_const_scalar(tmp_type, dst_scale);
+            LLVMValueRef scale = lp_build_const_vec(tmp_type, dst_scale);
             for(i = 0; i < num_tmps; ++i)
                tmp[i] = LLVMBuildMul(builder, tmp[i], scale, "");
          }
@@ -315,7 +315,7 @@ lp_build_conv(LLVMBuilderRef builder,
 
       /* FIXME: compensate different offsets too */
       if(src_shift > dst_shift) {
-         LLVMValueRef shift = lp_build_int_const_scalar(tmp_type, src_shift - dst_shift);
+         LLVMValueRef shift = lp_build_const_int_vec(tmp_type, src_shift - dst_shift);
          for(i = 0; i < num_tmps; ++i)
             if(src_type.sign)
                tmp[i] = LLVMBuildAShr(builder, tmp[i], shift, "");
@@ -388,7 +388,7 @@ lp_build_conv(LLVMBuilderRef builder,
           }
 
           if (src_scale != 1.0) {
-             LLVMValueRef scale = lp_build_const_scalar(tmp_type, 1.0/src_scale);
+             LLVMValueRef scale = lp_build_const_vec(tmp_type, 1.0/src_scale);
              for(i = 0; i < num_tmps; ++i)
                 tmp[i] = LLVMBuildMul(builder, tmp[i], scale, "");
           }
@@ -400,7 +400,7 @@ lp_build_conv(LLVMBuilderRef builder,
 
        /* FIXME: compensate different offsets too */
        if(src_shift < dst_shift) {
-          LLVMValueRef shift = lp_build_int_const_scalar(tmp_type, dst_shift - src_shift);
+          LLVMValueRef shift = lp_build_const_int_vec(tmp_type, dst_shift - src_shift);
           for(i = 0; i < num_tmps; ++i)
              tmp[i] = LLVMBuildShl(builder, tmp[i], shift, "");
        }
index 78e8155ff73a4c5e186eb5430fb291c663a57060..628831c3adab720fae2dced62cecb7411128f67b 100644 (file)
@@ -37,7 +37,7 @@
 #define LP_BLD_CONV_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 
 struct lp_type;
index 441ad94786f96e91a23461d4666e97143a3d4528..7b010cbdb0986d728aafc3c236ce98747b7a5b14 100644 (file)
@@ -30,7 +30,7 @@
 #define LP_BLD_DEBUG_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 #include "pipe/p_compiler.h"
 #include "util/u_string.h"
index f08f8eb6d8b9c457b3179a74285e5f4f7dfc3bfc..4ce1a27a061efb628471c923f79b5a07491093c4 100644 (file)
  *  Z31 Z32 Z41 Z42 Z33 Z34 Z43 Z44 ...
  *  ... ... ... ... ... ... ... ... ...
  *
- * FIXME: Code generate stencil test
+ *
+ * Stencil test:
+ * Two-sided stencil test is supported but probably not as efficient as
+ * it could be.  Currently, we use if/then/else constructs to do the
+ * operations for front vs. back-facing polygons.  We could probably do
+ * both the front and back arithmetic then use a Select() instruction to
+ * choose the result depending on polyon orientation.  We'd have to
+ * measure performance both ways and see which is better.
  *
  * @author Jose Fonseca <jfonseca@vmware.com>
  */
 #include "util/u_format.h"
 
 #include "lp_bld_type.h"
+#include "lp_bld_arit.h"
 #include "lp_bld_const.h"
 #include "lp_bld_logic.h"
 #include "lp_bld_flow.h"
 #include "lp_bld_debug.h"
 #include "lp_bld_depth.h"
+#include "lp_bld_swizzle.h"
+
+
+/** Used to select fields from pipe_stencil_state */
+enum stencil_op {
+   S_FAIL_OP,
+   Z_FAIL_OP,
+   Z_PASS_OP
+};
+
+
+
+/**
+ * Do the stencil test comparison (compare FB stencil values against ref value).
+ * This will be used twice when generating two-sided stencil code.
+ * \param stencil  the front/back stencil state
+ * \param stencilRef  the stencil reference value, replicated as a vector
+ * \param stencilVals  vector of stencil values from framebuffer
+ * \return vector mask of pass/fail values (~0 or 0)
+ */
+static LLVMValueRef
+lp_build_stencil_test_single(struct lp_build_context *bld,
+                             const struct pipe_stencil_state *stencil,
+                             LLVMValueRef stencilRef,
+                             LLVMValueRef stencilVals)
+{
+   const unsigned stencilMax = 255; /* XXX fix */
+   struct lp_type type = bld->type;
+   LLVMValueRef res;
+
+   assert(type.sign);
+
+   assert(stencil->enabled);
+
+   if (stencil->valuemask != stencilMax) {
+      /* compute stencilRef = stencilRef & valuemask */
+      LLVMValueRef valuemask = lp_build_const_int_vec(type, stencil->valuemask);
+      stencilRef = LLVMBuildAnd(bld->builder, stencilRef, valuemask, "");
+      /* compute stencilVals = stencilVals & valuemask */
+      stencilVals = LLVMBuildAnd(bld->builder, stencilVals, valuemask, "");
+   }
+
+   res = lp_build_cmp(bld, stencil->func, stencilVals, stencilRef);
+
+   return res;
+}
+
+
+/**
+ * Do the one or two-sided stencil test comparison.
+ * \sa lp_build_stencil_test_single
+ * \param face  an integer indicating front (+) or back (-) facing polygon.
+ *              If NULL, assume front-facing.
+ */
+static LLVMValueRef
+lp_build_stencil_test(struct lp_build_context *bld,
+                      const struct pipe_stencil_state stencil[2],
+                      LLVMValueRef stencilRefs[2],
+                      LLVMValueRef stencilVals,
+                      LLVMValueRef face)
+{
+   LLVMValueRef res;
+
+   assert(stencil[0].enabled);
+
+   if (stencil[1].enabled && face) {
+      /* do two-sided test */
+      struct lp_build_flow_context *flow_ctx;
+      struct lp_build_if_state if_ctx;
+      LLVMValueRef front_facing;
+      LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0);
+      LLVMValueRef result = bld->undef;
+
+      flow_ctx = lp_build_flow_create(bld->builder);
+      lp_build_flow_scope_begin(flow_ctx);
+
+      lp_build_flow_scope_declare(flow_ctx, &result);
+
+      /* front_facing = face > 0.0 */
+      front_facing = LLVMBuildFCmp(bld->builder, LLVMRealUGT, face, zero, "");
+
+      lp_build_if(&if_ctx, flow_ctx, bld->builder, front_facing);
+      {
+         result = lp_build_stencil_test_single(bld, &stencil[0],
+                                               stencilRefs[0], stencilVals);
+      }
+      lp_build_else(&if_ctx);
+      {
+         result = lp_build_stencil_test_single(bld, &stencil[1],
+                                               stencilRefs[1], stencilVals);
+      }
+      lp_build_endif(&if_ctx);
+
+      lp_build_flow_scope_end(flow_ctx);
+      lp_build_flow_destroy(flow_ctx);
+
+      res = result;
+   }
+   else {
+      /* do single-side test */
+      res = lp_build_stencil_test_single(bld, &stencil[0],
+                                         stencilRefs[0], stencilVals);
+   }
+
+   return res;
+}
+
+
+/**
+ * Apply the stencil operator (add/sub/keep/etc) to the given vector
+ * of stencil values.
+ * \return  new stencil values vector
+ */
+static LLVMValueRef
+lp_build_stencil_op_single(struct lp_build_context *bld,
+                           const struct pipe_stencil_state *stencil,
+                           enum stencil_op op,
+                           LLVMValueRef stencilRef,
+                           LLVMValueRef stencilVals,
+                           LLVMValueRef mask)
+
+{
+   const unsigned stencilMax = 255; /* XXX fix */
+   struct lp_type type = bld->type;
+   LLVMValueRef res;
+   LLVMValueRef max = lp_build_const_int_vec(type, stencilMax);
+   unsigned stencil_op;
+
+   assert(type.sign);
+
+   switch (op) {
+   case S_FAIL_OP:
+      stencil_op = stencil->fail_op;
+      break;
+   case Z_FAIL_OP:
+      stencil_op = stencil->zfail_op;
+      break;
+   case Z_PASS_OP:
+      stencil_op = stencil->zpass_op;
+      break;
+   default:
+      assert(0 && "Invalid stencil_op mode");
+      stencil_op = PIPE_STENCIL_OP_KEEP;
+   }
+
+   switch (stencil_op) {
+   case PIPE_STENCIL_OP_KEEP:
+      res = stencilVals;
+      /* we can return early for this case */
+      return res;
+   case PIPE_STENCIL_OP_ZERO:
+      res = bld->zero;
+      break;
+   case PIPE_STENCIL_OP_REPLACE:
+      res = stencilRef;
+      break;
+   case PIPE_STENCIL_OP_INCR:
+      res = lp_build_add(bld, stencilVals, bld->one);
+      res = lp_build_min(bld, res, max);
+      break;
+   case PIPE_STENCIL_OP_DECR:
+      res = lp_build_sub(bld, stencilVals, bld->one);
+      res = lp_build_max(bld, res, bld->zero);
+      break;
+   case PIPE_STENCIL_OP_INCR_WRAP:
+      res = lp_build_add(bld, stencilVals, bld->one);
+      res = LLVMBuildAnd(bld->builder, res, max, "");
+      break;
+   case PIPE_STENCIL_OP_DECR_WRAP:
+      res = lp_build_sub(bld, stencilVals, bld->one);
+      res = LLVMBuildAnd(bld->builder, res, max, "");
+      break;
+   case PIPE_STENCIL_OP_INVERT:
+      res = LLVMBuildNot(bld->builder, stencilVals, "");
+      res = LLVMBuildAnd(bld->builder, res, max, "");
+      break;
+   default:
+      assert(0 && "bad stencil op mode");
+      res = NULL;
+   }
+
+   if (stencil->writemask != stencilMax) {
+      /* compute res = (res & mask) | (stencilVals & ~mask) */
+      LLVMValueRef mask = lp_build_const_int_vec(type, stencil->writemask);
+      LLVMValueRef cmask = LLVMBuildNot(bld->builder, mask, "notWritemask");
+      LLVMValueRef t1 = LLVMBuildAnd(bld->builder, res, mask, "t1");
+      LLVMValueRef t2 = LLVMBuildAnd(bld->builder, stencilVals, cmask, "t2");
+      res = LLVMBuildOr(bld->builder, t1, t2, "t1_or_t2");
+   }
+
+   /* only the update the vector elements enabled by 'mask' */
+   res = lp_build_select(bld, mask, res, stencilVals);
+
+   return res;
+}
+
+
+/**
+ * Do the one or two-sided stencil test op/update.
+ */
+static LLVMValueRef
+lp_build_stencil_op(struct lp_build_context *bld,
+                    const struct pipe_stencil_state stencil[2],
+                    enum stencil_op op,
+                    LLVMValueRef stencilRefs[2],
+                    LLVMValueRef stencilVals,
+                    LLVMValueRef mask,
+                    LLVMValueRef face)
+
+{
+   assert(stencil[0].enabled);
+
+   if (stencil[1].enabled && face) {
+      /* do two-sided op */
+      struct lp_build_flow_context *flow_ctx;
+      struct lp_build_if_state if_ctx;
+      LLVMValueRef front_facing;
+      LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0);
+      LLVMValueRef result = bld->undef;
+
+      flow_ctx = lp_build_flow_create(bld->builder);
+      lp_build_flow_scope_begin(flow_ctx);
+
+      lp_build_flow_scope_declare(flow_ctx, &result);
+
+      /* front_facing = face > 0.0 */
+      front_facing = LLVMBuildFCmp(bld->builder, LLVMRealUGT, face, zero, "");
+
+      lp_build_if(&if_ctx, flow_ctx, bld->builder, front_facing);
+      {
+         result = lp_build_stencil_op_single(bld, &stencil[0], op,
+                                             stencilRefs[0], stencilVals, mask);
+      }
+      lp_build_else(&if_ctx);
+      {
+         result = lp_build_stencil_op_single(bld, &stencil[1], op,
+                                             stencilRefs[1], stencilVals, mask);
+      }
+      lp_build_endif(&if_ctx);
+
+      lp_build_flow_scope_end(flow_ctx);
+      lp_build_flow_destroy(flow_ctx);
+
+      return result;
+   }
+   else {
+      /* do single-sided op */
+      return lp_build_stencil_op_single(bld, &stencil[0], op,
+                                        stencilRefs[0], stencilVals, mask);
+   }
+}
+
 
 
 /**
@@ -109,105 +369,303 @@ lp_depth_type(const struct util_format_description *format_desc,
 
 
 /**
- * Depth test.
+ * Compute bitmask and bit shift to apply to the incoming fragment Z values
+ * and the Z buffer values needed before doing the Z comparison.
+ *
+ * Note that we leave the Z bits in the position that we find them
+ * in the Z buffer (typically 0xffffff00 or 0x00ffffff).  That lets us
+ * get by with fewer bit twiddling steps.
  */
-void
-lp_build_depth_test(LLVMBuilderRef builder,
-                    const struct pipe_depth_state *state,
-                    struct lp_type type,
-                    const struct util_format_description *format_desc,
-                    struct lp_build_mask_context *mask,
-                    LLVMValueRef src,
-                    LLVMValueRef dst_ptr)
+static boolean
+get_z_shift_and_mask(const struct util_format_description *format_desc,
+                     unsigned *shift, unsigned *mask)
 {
-   struct lp_build_context bld;
+   const unsigned total_bits = format_desc->block.bits;
    unsigned z_swizzle;
-   LLVMValueRef dst;
-   LLVMValueRef z_bitmask = NULL;
-   LLVMValueRef test;
-
-   if(!state->enabled)
-      return;
-
+   int chan;
+   unsigned padding_left, padding_right;
+   
    assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS);
    assert(format_desc->block.width == 1);
    assert(format_desc->block.height == 1);
 
    z_swizzle = format_desc->swizzle[0];
-   if(z_swizzle == UTIL_FORMAT_SWIZZLE_NONE)
-      return;
 
-   /* Sanity checking */
-   assert(z_swizzle < 4);
-   assert(format_desc->block.bits == type.width);
-   if(type.floating) {
-      assert(z_swizzle == 0);
-      assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_FLOAT);
-      assert(format_desc->channel[z_swizzle].size == format_desc->block.bits);
+   if (z_swizzle == UTIL_FORMAT_SWIZZLE_NONE)
+      return FALSE;
+
+   padding_right = 0;
+   for (chan = 0; chan < z_swizzle; ++chan)
+      padding_right += format_desc->channel[chan].size;
+
+   padding_left =
+      total_bits - (padding_right + format_desc->channel[z_swizzle].size);
+
+   if (padding_left || padding_right) {
+      unsigned long long mask_left = (1ULL << (total_bits - padding_left)) - 1;
+      unsigned long long mask_right = (1ULL << (padding_right)) - 1;
+      *mask = mask_left ^ mask_right;
    }
    else {
-      assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED);
-      assert(format_desc->channel[z_swizzle].normalized);
-      assert(!type.fixed);
-      assert(!type.sign);
-      assert(type.norm);
+      *mask = 0xffffffff;
+   }
+
+   *shift = padding_left;
+
+   return TRUE;
+}
+
+
+/**
+ * Compute bitmask and bit shift to apply to the framebuffer pixel values
+ * to put the stencil bits in the least significant position.
+ * (i.e. 0x000000ff)
+ */
+static boolean
+get_s_shift_and_mask(const struct util_format_description *format_desc,
+                     unsigned *shift, unsigned *mask)
+{
+   unsigned s_swizzle;
+   int chan, sz;
+
+   s_swizzle = format_desc->swizzle[1];
+
+   if (s_swizzle == UTIL_FORMAT_SWIZZLE_NONE)
+      return FALSE;
+
+   *shift = 0;
+   for (chan = 0; chan < s_swizzle; chan++)
+      *shift += format_desc->channel[chan].size;
+
+   sz = format_desc->channel[s_swizzle].size;
+   *mask = (1U << sz) - 1U;
+
+   return TRUE;
+}
+
+
+
+/**
+ * Generate code for performing depth and/or stencil tests.
+ * We operate on a vector of values (typically a 2x2 quad).
+ *
+ * \param depth  the depth test state
+ * \param stencil  the front/back stencil state
+ * \param type  the data type of the fragment depth/stencil values
+ * \param format_desc  description of the depth/stencil surface
+ * \param mask  the alive/dead pixel mask for the quad (vector)
+ * \param stencil_refs  the front/back stencil ref values (scalar)
+ * \param z_src  the incoming depth/stencil values (a 2x2 quad)
+ * \param zs_dst_ptr  pointer to depth/stencil values in framebuffer
+ * \param facing  contains float value indicating front/back facing polygon
+ */
+void
+lp_build_depth_stencil_test(LLVMBuilderRef builder,
+                            const struct pipe_depth_state *depth,
+                            const struct pipe_stencil_state stencil[2],
+                            struct lp_type type,
+                            const struct util_format_description *format_desc,
+                            struct lp_build_mask_context *mask,
+                            LLVMValueRef stencil_refs[2],
+                            LLVMValueRef z_src,
+                            LLVMValueRef zs_dst_ptr,
+                            LLVMValueRef face)
+{
+   struct lp_build_context bld;
+   struct lp_build_context sbld;
+   struct lp_type s_type;
+   LLVMValueRef zs_dst, z_dst = NULL;
+   LLVMValueRef stencil_vals = NULL;
+   LLVMValueRef z_bitmask = NULL, stencil_shift = NULL;
+   LLVMValueRef z_pass = NULL, s_pass_mask = NULL;
+   LLVMValueRef orig_mask = mask->value;
+
+   /* Sanity checking */
+   {
+      const unsigned z_swizzle = format_desc->swizzle[0];
+      const unsigned s_swizzle = format_desc->swizzle[1];
+
+      assert(z_swizzle != UTIL_FORMAT_SWIZZLE_NONE ||
+             s_swizzle != UTIL_FORMAT_SWIZZLE_NONE);
+
+      assert(depth->enabled || stencil[0].enabled);
+
+      assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS);
+      assert(format_desc->block.width == 1);
+      assert(format_desc->block.height == 1);
+
+      if (stencil[0].enabled) {
+         assert(format_desc->format == PIPE_FORMAT_Z24S8_UNORM ||
+                format_desc->format == PIPE_FORMAT_S8Z24_UNORM);
+      }
+
+      assert(z_swizzle < 4);
+      assert(format_desc->block.bits == type.width);
+      if (type.floating) {
+         assert(z_swizzle == 0);
+         assert(format_desc->channel[z_swizzle].type ==
+                UTIL_FORMAT_TYPE_FLOAT);
+         assert(format_desc->channel[z_swizzle].size ==
+                format_desc->block.bits);
+      }
+      else {
+         assert(format_desc->channel[z_swizzle].type ==
+                UTIL_FORMAT_TYPE_UNSIGNED);
+         assert(format_desc->channel[z_swizzle].normalized);
+         assert(!type.fixed);
+         assert(!type.sign);
+         assert(type.norm);
+      }
    }
 
-   /* Setup build context */
+
+   /* Setup build context for Z vals */
    lp_build_context_init(&bld, builder, type);
 
-   dst = LLVMBuildLoad(builder, dst_ptr, "");
+   /* Setup build context for stencil vals */
+   s_type = lp_type_int_vec(type.width);
+   lp_build_context_init(&sbld, builder, s_type);
+
+   /* Load current z/stencil value from z/stencil buffer */
+   zs_dst = LLVMBuildLoad(builder, zs_dst_ptr, "");
+
+   lp_build_name(zs_dst, "zsbufval");
 
-   lp_build_name(dst, "zsbuf");
 
-   /* Align the source depth bits with the destination's, and mask out any
-    * stencil or padding bits from both */
-   if(format_desc->channel[z_swizzle].size == format_desc->block.bits) {
-      assert(z_swizzle == 0);
-      /* nothing to do */
+   /* Compute and apply the Z/stencil bitmasks and shifts.
+    */
+   {
+      unsigned z_shift, z_mask;
+      unsigned s_shift, s_mask;
+
+      if (get_z_shift_and_mask(format_desc, &z_shift, &z_mask)) {
+         if (z_shift) {
+            LLVMValueRef shift = lp_build_const_int_vec(type, z_shift);
+            z_src = LLVMBuildLShr(builder, z_src, shift, "");
+         }
+
+         if (z_mask != 0xffffffff) {
+            LLVMValueRef mask = lp_build_const_int_vec(type, z_mask);
+            z_src = LLVMBuildAnd(builder, z_src, mask, "");
+            z_dst = LLVMBuildAnd(builder, zs_dst, mask, "");
+            z_bitmask = mask;  /* used below */
+         }
+         else {
+            z_dst = zs_dst;
+         }
+
+         lp_build_name(z_dst, "zsbuf.z");
+      }
+
+      if (get_s_shift_and_mask(format_desc, &s_shift, &s_mask)) {
+         if (s_shift) {
+            LLVMValueRef shift = lp_build_const_int_vec(type, s_shift);
+            stencil_vals = LLVMBuildLShr(builder, zs_dst, shift, "");
+            stencil_shift = shift;  /* used below */
+         }
+         else {
+            stencil_vals = zs_dst;
+         }
+
+         if (s_mask != 0xffffffff) {
+            LLVMValueRef mask = lp_build_const_int_vec(type, s_mask);
+            stencil_vals = LLVMBuildAnd(builder, stencil_vals, mask, "");
+         }
+
+         lp_build_name(stencil_vals, "stencil");
+      }
    }
-   else {
-      unsigned padding_left;
-      unsigned padding_right;
-      unsigned chan;
-
-      assert(format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN);
-      assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED);
-      assert(format_desc->channel[z_swizzle].size <= format_desc->block.bits);
-      assert(format_desc->channel[z_swizzle].normalized);
-
-      padding_right = 0;
-      for(chan = 0; chan < z_swizzle; ++chan)
-         padding_right += format_desc->channel[chan].size;
-      padding_left = format_desc->block.bits -
-                     (padding_right + format_desc->channel[z_swizzle].size);
-
-      if(padding_left || padding_right) {
-         const unsigned long long mask_left = ((unsigned long long)1 << (format_desc->block.bits - padding_left)) - 1;
-         const unsigned long long mask_right = ((unsigned long long)1 << (padding_right)) - 1;
-         z_bitmask = lp_build_int_const_scalar(type, mask_left ^ mask_right);
+
+
+   if (stencil[0].enabled) {
+      /* convert scalar stencil refs into vectors */
+      stencil_refs[0] = lp_build_broadcast_scalar(&bld, stencil_refs[0]);
+      stencil_refs[1] = lp_build_broadcast_scalar(&bld, stencil_refs[1]);
+
+      s_pass_mask = lp_build_stencil_test(&sbld, stencil,
+                                          stencil_refs, stencil_vals, face);
+
+      /* apply stencil-fail operator */
+      {
+         LLVMValueRef s_fail_mask = lp_build_andc(&bld, orig_mask, s_pass_mask);
+         stencil_vals = lp_build_stencil_op(&sbld, stencil, S_FAIL_OP,
+                                            stencil_refs, stencil_vals,
+                                            s_fail_mask, face);
+      }
+   }
+
+   if (depth->enabled) {
+      /* compare src Z to dst Z, returning 'pass' mask */
+      z_pass = lp_build_cmp(&bld, depth->func, z_src, z_dst);
+
+      if (!stencil[0].enabled) {
+         /* We can potentially skip all remaining operations here, but only
+          * if stencil is disabled because we still need to update the stencil
+          * buffer values.  Don't need to update Z buffer values.
+          */
+         lp_build_mask_update(mask, z_pass);
+      }
+
+      if (depth->writemask) {
+         if(z_bitmask)
+            z_bitmask = LLVMBuildAnd(builder, mask->value, z_bitmask, "");
+         else
+            z_bitmask = mask->value;
+
+         z_dst = lp_build_select(&bld, z_bitmask, z_src, z_dst);
       }
 
-      if(padding_left)
-         src = LLVMBuildLShr(builder, src, lp_build_int_const_scalar(type, padding_left), "");
-      if(padding_right)
-         src = LLVMBuildAnd(builder, src, z_bitmask, "");
-      if(padding_left || padding_right)
-         dst = LLVMBuildAnd(builder, dst, z_bitmask, "");
+      if (stencil[0].enabled) {
+         /* update stencil buffer values according to z pass/fail result */
+         LLVMValueRef z_fail_mask, z_pass_mask;
+
+         /* apply Z-fail operator */
+         z_fail_mask = lp_build_andc(&bld, orig_mask, z_pass);
+         stencil_vals = lp_build_stencil_op(&sbld, stencil, Z_FAIL_OP,
+                                            stencil_refs, stencil_vals,
+                                            z_fail_mask, face);
+
+         /* apply Z-pass operator */
+         z_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, z_pass, "");
+         stencil_vals = lp_build_stencil_op(&sbld, stencil, Z_PASS_OP,
+                                            stencil_refs, stencil_vals,
+                                            z_pass_mask, face);
+      }
+   }
+   else {
+      /* No depth test: apply Z-pass operator to stencil buffer values which
+       * passed the stencil test.
+       */
+      s_pass_mask = LLVMBuildAnd(bld.builder, orig_mask, s_pass_mask, "");
+      stencil_vals = lp_build_stencil_op(&sbld, stencil, Z_PASS_OP,
+                                         stencil_refs, stencil_vals,
+                                         s_pass_mask, face);
    }
 
-   lp_build_name(dst, "zsbuf.z");
+   /* The Z bits are already in the right place but we may need to shift the
+    * stencil bits before ORing Z with Stencil to make the final pixel value.
+    */
+   if (stencil_vals && stencil_shift)
+      stencil_vals = LLVMBuildShl(bld.builder, stencil_vals,
+                                  stencil_shift, "");
 
-   test = lp_build_cmp(&bld, state->func, src, dst);
-   lp_build_mask_update(mask, test);
+   /* Finally, merge/store the z/stencil values */
+   if ((depth->enabled && depth->writemask) ||
+       (stencil[0].enabled && stencil[0].writemask)) {
 
-   if(state->writemask) {
-      if(z_bitmask)
-         z_bitmask = LLVMBuildAnd(builder, mask->value, z_bitmask, "");
+      if (z_dst && stencil_vals)
+         zs_dst = LLVMBuildOr(bld.builder, z_dst, stencil_vals, "");
+      else if (z_dst)
+         zs_dst = z_dst;
       else
-         z_bitmask = mask->value;
+         zs_dst = stencil_vals;
 
-      dst = lp_build_select(&bld, z_bitmask, src, dst);
-      LLVMBuildStore(builder, dst, dst_ptr);
+      LLVMBuildStore(builder, zs_dst, zs_dst_ptr);
    }
+
+   if (s_pass_mask)
+      lp_build_mask_update(mask, s_pass_mask);
+
+   if (depth->enabled && stencil[0].enabled)
+      lp_build_mask_update(mask, z_pass);
 }
index 8be80024ae8154a7f972427fb569adaa8616b033..27dd46b625daff4e2f607af521d6d7f1efa3da33 100644 (file)
@@ -36,7 +36,7 @@
 #define LP_BLD_DEPTH_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
  
 struct pipe_depth_state;
@@ -51,13 +51,16 @@ lp_depth_type(const struct util_format_description *format_desc,
 
 
 void
-lp_build_depth_test(LLVMBuilderRef builder,
-                    const struct pipe_depth_state *state,
-                    struct lp_type type,
-                    const struct util_format_description *format_desc,
-                    struct lp_build_mask_context *mask,
-                    LLVMValueRef src,
-                    LLVMValueRef dst_ptr);
+lp_build_depth_stencil_test(LLVMBuilderRef builder,
+                            const struct pipe_depth_state *depth,
+                            const struct pipe_stencil_state stencil[2],
+                            struct lp_type type,
+                            const struct util_format_description *format_desc,
+                            struct lp_build_mask_context *mask,
+                            LLVMValueRef stencil_refs[2],
+                            LLVMValueRef zs_src,
+                            LLVMValueRef zs_dst_ptr,
+                            LLVMValueRef facing);
 
 
 #endif /* !LP_BLD_DEPTH_H */
index e15883654919bff1e8882685970c99c5c07eace4..c2b50e1b6020fc1fb7d4759e38aac8728239313c 100644 (file)
@@ -35,7 +35,7 @@
 #define LP_BLD_FLOW_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 
 struct lp_type;
index 8972c0dc1784c5b810be64ebbc1874e729c1cb8a..73ab6de3f21f7b8e45a4b194e6c1600fea201958 100644 (file)
@@ -34,7 +34,7 @@
  * Pixel format helpers.
  */
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 #include "pipe/p_format.h"
 
index abb27e4c3284dde69fb69bf344e56494a663c2f5..45ee4b12ced5facc761b70ab48f5f5667c89b1ef 100644 (file)
@@ -114,10 +114,10 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
       case UTIL_FORMAT_TYPE_UNSIGNED:
          if(type.floating) {
             if(start)
-               input = LLVMBuildLShr(builder, input, lp_build_int_const_scalar(type, start), "");
+               input = LLVMBuildLShr(builder, input, lp_build_const_int_vec(type, start), "");
             if(stop < format_desc->block.bits) {
                unsigned mask = ((unsigned long long)1 << width) - 1;
-               input = LLVMBuildAnd(builder, input, lp_build_int_const_scalar(type, mask), "");
+               input = LLVMBuildAnd(builder, input, lp_build_const_int_vec(type, mask), "");
             }
 
             if(format_desc->channel[chan].normalized)
index 2fc894017d8f450a73f6f637da90dc293575ed07..09efb1612178cfbc446905d3277191bffc3878e9 100644 (file)
@@ -289,17 +289,17 @@ pos_update(struct lp_build_interp_soa_context *bld, int quad_index)
       /* top-right or bottom-right quad in block */
       /* build x += xstep */
       x = lp_build_add(&bld->base, x,
-                       lp_build_const_scalar(bld->base.type, xstep));
+                       lp_build_const_vec(bld->base.type, xstep));
    }
 
    if (quad_index == 2) {
       /* bottom-left quad in block */
       /* build y += ystep */
       y = lp_build_add(&bld->base, y,
-                       lp_build_const_scalar(bld->base.type, ystep));
+                       lp_build_const_vec(bld->base.type, ystep));
       /* build x -= xstep */
       x = lp_build_sub(&bld->base, x,
-                       lp_build_const_scalar(bld->base.type, xstep));
+                       lp_build_const_vec(bld->base.type, xstep));
    }
 
    lp_build_name(x, "pos.x");
index 177b5e943ee9552886b8184da72fce34fe03ed6f..a4937bbb04851a36b6a2a9b8a814fb4bb900f718 100644 (file)
@@ -41,7 +41,7 @@
 #define LP_BLD_INTERP_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 #include "tgsi/tgsi_exec.h"
 
index 7d5506c73381e098f74528f85d543dbcd71d039b..977f7673228a0ba262cbbfb17c5b6bf0cadaeda8 100644 (file)
@@ -37,7 +37,7 @@
 #define LP_BLD_INTR_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 
 /**
index f3df3dd138804ea4a0b82cc2b382b1308c686ad1..a3b697011626daba23662bd98a41f695d6ce3c17 100644 (file)
@@ -193,7 +193,7 @@ lp_build_compare(LLVMBuilderRef builder,
          if(table[func].gt &&
             ((type.width == 8 && type.sign) ||
              (type.width != 8 && !type.sign))) {
-            LLVMValueRef msb = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.width - 1));
+            LLVMValueRef msb = lp_build_const_int_vec(type, (unsigned long long)1 << (type.width - 1));
             a = LLVMBuildXor(builder, a, msb, "");
             b = LLVMBuildXor(builder, b, msb, "");
          }
@@ -483,3 +483,13 @@ lp_build_alloca(struct lp_build_context *bld)
       return LLVMBuildAlloca(bld->builder, lp_build_elem_type(type), "");
    }
 }
+
+
+/** Return (a & ~b) */
+LLVMValueRef
+lp_build_andc(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
+{
+   b = LLVMBuildNot(bld->builder, b, "");
+   b = LLVMBuildAnd(bld->builder, a, b, "");
+   return b;
+}
index b54ec13b7018fd8600655722bd8daf56a2e6ff1d..00a8c750196d0a62c246fb16ab32acbba3a49f67 100644 (file)
@@ -37,7 +37,7 @@
 #define LP_BLD_LOGIC_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 #include "pipe/p_defines.h" /* For PIPE_FUNC_xxx */
 
@@ -79,4 +79,9 @@ lp_build_select_aos(struct lp_build_context *bld,
 LLVMValueRef
 lp_build_alloca(struct lp_build_context *bld);
 
+
+LLVMValueRef
+lp_build_andc(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b);
+
+
 #endif /* !LP_BLD_LOGIC_H */
index 23398f41f9945ecde045a0c6203311d0cf283713..2daa8a3b58212114724062ad7be3d3647bba9877 100644 (file)
@@ -164,7 +164,7 @@ lp_build_unpack2(LLVMBuilderRef builder,
 
    if(dst_type.sign && src_type.sign) {
       /* Replicate the sign bit in the most significant bits */
-      msb = LLVMBuildAShr(builder, src, lp_build_int_const_scalar(src_type, src_type.width - 1), "");
+      msb = LLVMBuildAShr(builder, src, lp_build_const_int_vec(src_type, src_type.width - 1), "");
    }
    else
       /* Most significant bits always zero */
@@ -361,7 +361,7 @@ lp_build_packs2(LLVMBuilderRef builder,
    if(clamp) {
       struct lp_build_context bld;
       unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width;
-      LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1);
+      LLVMValueRef dst_max = lp_build_const_int_vec(src_type, ((unsigned long long)1 << dst_bits) - 1);
       lp_build_context_init(&bld, builder, src_type);
       lo = lp_build_min(&bld, lo, dst_max);
       hi = lp_build_min(&bld, hi, dst_max);
index 346a17d5803a4d442b787601f1dae22fed8a4cec..41adeed220c7d8fd6cbb226ea963542dedc43857 100644 (file)
@@ -37,7 +37,7 @@
 #define LP_BLD_PACK_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 
 struct lp_type;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
new file mode 100644 (file)
index 0000000..78c9ec7
--- /dev/null
@@ -0,0 +1,113 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdio.h>
+
+#include "util/u_debug.h"
+#include "util/u_memory.h"
+#include "lp_bld_printf.h"
+
+
+static int
+lp_get_printf_arg_count(const char *fmt)
+{
+   int count =0;
+   const char *p = fmt;
+   int c;
+
+   while ((c = *p++)) {
+      if (c != '%')
+         continue;
+      switch (*p) {
+         case '\0':
+           continue;
+         case '%':
+           p++;
+           continue;
+        case '.':
+           if (p[1] == '*' && p[2] == 's') {
+              count += 2;
+              p += 3;
+               continue;
+           }
+        default:
+           count ++;
+      }
+   }
+   return count;
+}
+
+LLVMValueRef 
+lp_build_const_string_variable(LLVMModuleRef module, const char *str, int len)
+{
+   LLVMValueRef string = LLVMAddGlobal(module, LLVMArrayType(LLVMInt8Type(), len + 1), "");
+   LLVMSetGlobalConstant(string, TRUE);
+   LLVMSetLinkage(string, LLVMInternalLinkage);
+   LLVMSetInitializer(string, LLVMConstString(str, len + 1, TRUE));
+   return string;
+}
+
+/**
+ * lp_build_printf.
+ *
+ * Build printf call in LLVM IR. The output goes to stdout.
+ * The additional variable arguments need to have type
+ * LLVMValueRef.
+ */
+LLVMValueRef
+lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...)
+{
+   va_list arglist;
+   int i = 0;
+   int argcount = lp_get_printf_arg_count(fmt);
+   LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder)));
+   LLVMValueRef params[50];
+   LLVMValueRef fmtarg = lp_build_const_string_variable(module, fmt, strlen(fmt) + 1);
+   LLVMValueRef int0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
+   LLVMValueRef index[2];
+   LLVMValueRef func_printf = LLVMGetNamedFunction(module, "printf");
+
+   assert(Elements(params) >= argcount + 1);
+
+   index[0] = index[1] = int0;
+
+   if (!func_printf) {
+      LLVMTypeRef printf_type = LLVMFunctionType(LLVMIntType(32), NULL, 0, 1);
+      func_printf = LLVMAddFunction(module, "printf", printf_type);
+   }
+
+   params[0] = LLVMBuildGEP(builder, fmtarg, index, 2, "");
+
+   va_start(arglist, fmt);
+   for (i = 1; i <= argcount; i++)
+      params[i] = va_arg(arglist, LLVMValueRef);
+   va_end(arglist);
+
+   return LLVMBuildCall(builder, func_printf, params, argcount + 1, "");
+}
+
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.h b/src/gallium/auxiliary/gallivm/lp_bld_printf.h
new file mode 100644 (file)
index 0000000..83bd8f1
--- /dev/null
@@ -0,0 +1,39 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef LP_BLD_PRINTF_H
+#define LP_BLD_PRINTF_H
+
+
+#include "pipe/p_compiler.h"
+#include "lp_bld.h"
+
+LLVMValueRef lp_build_const_string_variable(LLVMModuleRef module, const char *str, int len);
+LLVMValueRef lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...);
+
+#endif
+
index 2f74aa5e00a1f4d3fab3412f003d362b0721ed2f..bb76ad4c6bfcd1a1088059a9e55211688ee1ea93 100644 (file)
@@ -173,7 +173,7 @@ lp_build_sample_offset(struct lp_build_context *bld,
    LLVMValueRef x_stride;
    LLVMValueRef offset;
 
-   x_stride = lp_build_const_scalar(bld->type, format_desc->block.bits/8);
+   x_stride = lp_build_const_vec(bld->type, format_desc->block.bits/8);
 
    if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
       LLVMValueRef x_lo, x_hi;
@@ -195,9 +195,9 @@ lp_build_sample_offset(struct lp_build_context *bld,
       y_hi = LLVMBuildLShr(bld->builder, y, bld->one, "");
 
       x_stride_lo = x_stride;
-      y_stride_lo = lp_build_const_scalar(bld->type, 2*format_desc->block.bits/8);
+      y_stride_lo = lp_build_const_vec(bld->type, 2*format_desc->block.bits/8);
 
-      x_stride_hi = lp_build_const_scalar(bld->type, 4*format_desc->block.bits/8);
+      x_stride_hi = lp_build_const_vec(bld->type, 4*format_desc->block.bits/8);
       y_stride_hi = LLVMBuildShl(bld->builder, y_stride, bld->one, "");
 
       x_offset_lo = lp_build_mul(bld, x_lo, x_stride_lo);
index 7f08bfaac1f8de6d7b5de62bb411027744a3f384..92f3c57435a137a368d72dc457f99a99e2e5b4ef 100644 (file)
@@ -36,7 +36,7 @@
 #define LP_BLD_SAMPLE_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 struct pipe_texture;
 struct pipe_sampler_state;
index 9741dbb389c831fbd4071f83a548e955a6cb8254..995c016b9ddada4d47a3436cf3c40ca84a4db0eb 100644 (file)
@@ -292,7 +292,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
       int chan;
       for (chan = 0; chan < 4; chan++) {
          LLVMValueRef border_chan =
-            lp_build_const_scalar(bld->texel_type,
+            lp_build_const_vec(bld->texel_type,
                                   bld->static_state->border_color[chan]);
          texel[chan] = lp_build_select(&bld->texel_bld, use_border,
                                        border_chan, texel[chan]);
@@ -457,8 +457,8 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
    struct lp_build_context *coord_bld = &bld->coord_bld;
    struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
    struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld;
-   LLVMValueRef two = lp_build_const_scalar(coord_bld->type, 2.0);
-   LLVMValueRef half = lp_build_const_scalar(coord_bld->type, 0.5);
+   LLVMValueRef two = lp_build_const_vec(coord_bld->type, 2.0);
+   LLVMValueRef half = lp_build_const_vec(coord_bld->type, 0.5);
    LLVMValueRef length_f = lp_build_int_to_float(coord_bld, length);
    LLVMValueRef length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one);
    LLVMValueRef length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one);
@@ -512,7 +512,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
       else {
          LLVMValueRef min, max;
          /* clamp to [0.5, length - 0.5] */
-         min = lp_build_const_scalar(coord_bld->type, 0.5F);
+         min = lp_build_const_vec(coord_bld->type, 0.5F);
          max = lp_build_sub(coord_bld, length_f, min);
          coord = lp_build_clamp(coord_bld, coord, min, max);
       }
@@ -533,7 +533,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
          if (bld->static_state->normalized_coords) {
             /* min = -1.0 / (2 * length) = -0.5 / length */
             min = lp_build_mul(coord_bld,
-                               lp_build_const_scalar(coord_bld->type, -0.5F),
+                               lp_build_const_vec(coord_bld->type, -0.5F),
                                lp_build_rcp(coord_bld, length_f));
             /* max = 1.0 - min */
             max = lp_build_sub(coord_bld, coord_bld->one, min);
@@ -545,7 +545,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
          }
          else {
             /* clamp to [-0.5, length + 0.5] */
-            min = lp_build_const_scalar(coord_bld->type, -0.5F);
+            min = lp_build_const_vec(coord_bld->type, -0.5F);
             max = lp_build_sub(coord_bld, length_f, min);
             coord = lp_build_clamp(coord_bld, coord, min, max);
             coord = lp_build_sub(coord_bld, coord, half);
@@ -620,7 +620,7 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld,
          LLVMValueRef min, max;
          /* min = -1.0 / (2 * length) = -0.5 / length */
          min = lp_build_mul(coord_bld,
-                            lp_build_const_scalar(coord_bld->type, -0.5F),
+                            lp_build_const_vec(coord_bld->type, -0.5F),
                             lp_build_rcp(coord_bld, length_f));
          /* max = 1.0 - min */
          max = lp_build_sub(coord_bld, coord_bld->one, min);
@@ -665,7 +665,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld,
    struct lp_build_context *coord_bld = &bld->coord_bld;
    struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
    struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld;
-   LLVMValueRef two = lp_build_const_scalar(coord_bld->type, 2.0);
+   LLVMValueRef two = lp_build_const_vec(coord_bld->type, 2.0);
    LLVMValueRef length_f = lp_build_int_to_float(coord_bld, length);
    LLVMValueRef length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one);
    LLVMValueRef length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one);
@@ -708,7 +708,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld,
          }
          else {
             /* clamp to [0.5, length - 0.5] */
-            min = lp_build_const_scalar(coord_bld->type, 0.5F);
+            min = lp_build_const_vec(coord_bld->type, 0.5F);
             max = lp_build_sub(coord_bld, length_f, min);
          }
          /* coord = clamp(coord, min, max) */
@@ -724,7 +724,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld,
          if (bld->static_state->normalized_coords) {
             /* min = -1.0 / (2 * length) = -0.5 / length */
             min = lp_build_mul(coord_bld,
-                               lp_build_const_scalar(coord_bld->type, -0.5F),
+                               lp_build_const_vec(coord_bld->type, -0.5F),
                                lp_build_rcp(coord_bld, length_f));
             /* max = length - min */
             max = lp_build_sub(coord_bld, length_f, min);
@@ -733,7 +733,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld,
          }
          else {
             /* clamp to [-0.5, length + 0.5] */
-            min = lp_build_const_scalar(coord_bld->type, -0.5F);
+            min = lp_build_const_vec(coord_bld->type, -0.5F);
             max = lp_build_sub(coord_bld, length_f, min);
          }
          /* coord = clamp(coord, min, max) */
@@ -1226,7 +1226,7 @@ static LLVMValueRef
 lp_build_cube_ima(struct lp_build_context *coord_bld, LLVMValueRef coord)
 {
    /* ima = -0.5 / abs(coord); */
-   LLVMValueRef negHalf = lp_build_const_scalar(coord_bld->type, -0.5);
+   LLVMValueRef negHalf = lp_build_const_vec(coord_bld->type, -0.5);
    LLVMValueRef absCoord = lp_build_abs(coord_bld, coord);
    LLVMValueRef ima = lp_build_mul(coord_bld, negHalf,
                                    lp_build_rcp(coord_bld, absCoord));
@@ -1246,7 +1246,7 @@ lp_build_cube_coord(struct lp_build_context *coord_bld,
                     LLVMValueRef coord, LLVMValueRef ima)
 {
    /* return negate(coord) * ima * sign + 0.5; */
-   LLVMValueRef half = lp_build_const_scalar(coord_bld->type, 0.5);
+   LLVMValueRef half = lp_build_const_vec(coord_bld->type, 0.5);
    LLVMValueRef res;
 
    assert(negate_coord == +1 || negate_coord == -1);
@@ -1708,7 +1708,7 @@ lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder,
                           LLVMValueRef packed,
                           LLVMValueRef *rgba)
 {
-   LLVMValueRef mask = lp_build_int_const_scalar(dst_type, 0xff);
+   LLVMValueRef mask = lp_build_const_int_vec(dst_type, 0xff);
    unsigned chan;
 
    /* Decode the input vector components */
@@ -1720,7 +1720,7 @@ lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder,
       input = packed;
 
       if(start)
-         input = LLVMBuildLShr(builder, input, lp_build_int_const_scalar(dst_type, start), "");
+         input = LLVMBuildLShr(builder, input, lp_build_const_int_vec(dst_type, start), "");
 
       if(stop < 32)
          input = LLVMBuildAnd(builder, input, mask, "");
@@ -1782,17 +1782,17 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld,
    t = LLVMBuildFPToSI(builder, t, i32_vec_type, "");
 
    /* subtract 0.5 (add -128) */
-   i32_c128 = lp_build_int_const_scalar(i32.type, -128);
+   i32_c128 = lp_build_const_int_vec(i32.type, -128);
    s = LLVMBuildAdd(builder, s, i32_c128, "");
    t = LLVMBuildAdd(builder, t, i32_c128, "");
 
    /* compute floor (shift right 8) */
-   i32_c8 = lp_build_int_const_scalar(i32.type, 8);
+   i32_c8 = lp_build_const_int_vec(i32.type, 8);
    s_ipart = LLVMBuildAShr(builder, s, i32_c8, "");
    t_ipart = LLVMBuildAShr(builder, t, i32_c8, "");
 
    /* compute fractional part (AND with 0xff) */
-   i32_c255 = lp_build_int_const_scalar(i32.type, 255);
+   i32_c255 = lp_build_const_int_vec(i32.type, 255);
    s_fpart = LLVMBuildAnd(builder, s, i32_c255, "");
    t_fpart = LLVMBuildAnd(builder, t, i32_c255, "");
 
@@ -1959,7 +1959,7 @@ lp_build_sample_compare(struct lp_build_sample_context *bld,
    }
 
    assert(res);
-   res = lp_build_mul(texel_bld, res, lp_build_const_scalar(texel_bld->type, 0.25));
+   res = lp_build_mul(texel_bld, res, lp_build_const_vec(texel_bld->type, 0.25));
 
    /* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */
    for(chan = 0; chan < 3; ++chan)
index 34478c10f514c85fae48832aa35c354ea1fc994a..147336edb4b3c60c18cd0771c5ef7df25fb2648c 100644 (file)
@@ -37,7 +37,7 @@
 #define LP_BLD_STRUCT_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 #include <llvm-c/Target.h>
 
 #include "util/u_debug.h"
index 64e81f7b1fed4b0babfdb37cb6df49f7908ac503..278c838eaca5fb63a4c531ebe1a379b5cfae68bb 100644 (file)
@@ -144,9 +144,9 @@ lp_build_broadcast_aos(struct lp_build_context *bld,
 #endif
 
          if(shift > 0)
-            tmp = LLVMBuildLShr(bld->builder, a, lp_build_int_const_scalar(type4, shift*type.width), "");
+            tmp = LLVMBuildLShr(bld->builder, a, lp_build_const_int_vec(type4, shift*type.width), "");
          if(shift < 0)
-            tmp = LLVMBuildShl(bld->builder, a, lp_build_int_const_scalar(type4, -shift*type.width), "");
+            tmp = LLVMBuildShl(bld->builder, a, lp_build_const_int_vec(type4, -shift*type.width), "");
 
          assert(tmp);
          if(tmp)
index 57b5cc079f24dc6bc2671df92eee37d3c52de1f0..138ca620e63468b5079e982d9846a0c1a924655a 100644 (file)
@@ -37,7 +37,7 @@
 #define LP_BLD_SWIZZLE_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 
 struct lp_type;
index 0f2f8a65b1049fe3c56e55e6a43df879c66949a1..63b938bfa98421b4ac7e0a583aff3caad44e9cf3 100644 (file)
@@ -35,7 +35,7 @@
 #ifndef LP_BLD_TGSI_H
 #define LP_BLD_TGSI_H
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 
 struct tgsi_token;
index 5ec59d636cb868d54a34e966bb3527119d4edf1d..8901e656aed290c4f527c1663d960300349a36b8 100644 (file)
@@ -475,7 +475,7 @@ emit_store(
       break;
 
    case TGSI_SAT_MINUS_PLUS_ONE:
-      value = lp_build_max(&bld->base, value, lp_build_const_scalar(bld->base.type, -1.0));
+      value = lp_build_max(&bld->base, value, lp_build_const_vec(bld->base.type, -1.0));
       value = lp_build_min(&bld->base, value, bld->base.one);
       break;
 
@@ -651,32 +651,40 @@ emit_declaration(
    unsigned first = decl->Range.First;
    unsigned last = decl->Range.Last;
    unsigned idx, i;
+   LLVMBasicBlockRef current_block =
+      LLVMGetInsertBlock(bld->base.builder);
+   LLVMBasicBlockRef first_block =
+      LLVMGetEntryBasicBlock(
+         LLVMGetBasicBlockParent(current_block));
+   LLVMValueRef first_inst =
+      LLVMGetFirstInstruction(first_block);
+
+   /* we want alloca's to be the first instruction
+    * in the function so we need to rewind the builder
+    * to the very beginning */
+   LLVMPositionBuilderBefore(bld->base.builder,
+                             first_inst);
 
    for (idx = first; idx <= last; ++idx) {
-      boolean ok;
-
       switch (decl->Declaration.File) {
       case TGSI_FILE_TEMPORARY:
          for (i = 0; i < NUM_CHANNELS; i++)
             bld->temps[idx][i] = lp_build_alloca(&bld->base);
-         ok = TRUE;
          break;
 
       case TGSI_FILE_OUTPUT:
          for (i = 0; i < NUM_CHANNELS; i++)
             bld->outputs[idx][i] = lp_build_alloca(&bld->base);
-         ok = TRUE;
          break;
 
       default:
          /* don't need to declare other vars */
-         ok = TRUE;
+         break;
       }
-
-      if (!ok)
-         return FALSE;
    }
 
+   LLVMPositionBuilderAtEnd(bld->base.builder,
+                            current_block);
    return TRUE;
 }
 
@@ -996,7 +1004,7 @@ emit_instruction(
          src0 = emit_fetch( bld, inst, 0, chan_index );
          src1 = emit_fetch( bld, inst, 1, chan_index );
          src2 = emit_fetch( bld, inst, 2, chan_index );
-         tmp1 = lp_build_const_scalar(bld->base.type, 0.5);
+         tmp1 = lp_build_const_vec(bld->base.type, 0.5);
          tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_GREATER, src2, tmp1);
          dst0[chan_index] = lp_build_select( &bld->base, tmp0, src0, src1 );
       }
@@ -1713,7 +1721,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
             assert(num_immediates < LP_MAX_IMMEDIATES);
             for( i = 0; i < size; ++i )
                bld.immediates[num_immediates][i] =
-                  lp_build_const_scalar(type, parse.FullToken.FullImmediate.u[i].Float);
+                  lp_build_const_vec(type, parse.FullToken.FullImmediate.u[i].Float);
             for( i = size; i < 4; ++i )
                bld.immediates[num_immediates][i] = bld.base.undef;
             num_immediates++;
index 5b351476ac2062197f73376a85b1b2be289eba24..cd59d2faa662a0d60fb888016921ecd7d0e3bb7e 100644 (file)
@@ -37,9 +37,9 @@
 #define LP_BLD_TYPE_H
 
 
-#include "os/os_llvm.h"
+#include "pipe/p_compiler.h"
+#include "gallivm/lp_bld.h"
 
-#include <pipe/p_compiler.h>
 
 
 /**
diff --git a/src/gallium/auxiliary/os/os_llvm.h b/src/gallium/auxiliary/os/os_llvm.h
deleted file mode 100644 (file)
index d5edfbf..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * @file
- * Wrapper for LLVM header file #includes.
- */
-
-
-#ifndef OS_LLVM_H
-#define OS_LLVM_H
-
-
-#include <llvm-c/Core.h>  
-
-
-/** Set version to 0 if missing to avoid #ifdef HAVE_LLVM everywhere */
-#ifndef HAVE_LLVM
-#define HAVE_LLVM 0x0
-#endif
-
-
-#endif /* OS_LLVM_H */
index 86f9266c95ff2490362debf12fda1f5b1672ca6d..0f2ae05daedf8552548eeb066db3c56628f1b543 100644 (file)
@@ -227,6 +227,8 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
                           pb_size size,
                           const struct pb_desc *desc)
 {
+   void *map;
+
    if(buf->base.base.size < size)
       return FALSE;
 
@@ -239,6 +241,13 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
    
    if(!pb_check_usage(desc->usage, buf->base.base.usage))
       return FALSE;
+
+   map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_DONTBLOCK);
+   if (!map) {
+      return FALSE;
+   }
+
+   pb_unmap(buf->buffer);
    
    return TRUE;
 }
index f675427d987b51e08440e5a433c914aeba389887..7595214bdf25ee5a610a1282789c1abe5fd82721 100644 (file)
@@ -87,7 +87,7 @@ void x86_print_reg( struct x86_reg reg )
       foo++;                                    \
    if  (*foo)                                   \
       foo++;                                    \
-   debug_printf( "\n% 4x% 15s ", p->csr - p->store, foo );             \
+   debug_printf( "\n%4x %14s ", p->csr - p->store, foo );             \
 } while (0)
 
 #define DUMP_I( I ) do {                        \
index f7612d416a0556ca49ef629aa326e32d25130445..319b836ffb1bb777dd6c936f74547e27bdc1fdbb 100644 (file)
@@ -102,7 +102,7 @@ enum sse_cc {
 #define cc_Z  cc_E
 #define cc_NZ cc_NE
 
-/* Begin/end/retreive function creation:
+/* Begin/end/retrieve function creation:
  */
 
 
@@ -311,8 +311,8 @@ void x87_fucom( struct x86_function *p, struct x86_reg arg );
 
 
 
-/* Retreive a reference to one of the function arguments, taking into
- * account any push/pop activity.  Note - doesn't track explict
+/* Retrieve a reference to one of the function arguments, taking into
+ * account any push/pop activity.  Note - doesn't track explicit
  * manipulation of ESP by other instructions.
  */
 struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg );
index f918151daaabd0f11ca542d8c188c0e706554280..0b468a9184e0eb8251d36187bce799dc31109dfd 100644 (file)
@@ -55,7 +55,7 @@ static boolean is_digit_alpha_underscore( const char *cur )
    return is_digit( cur ) || is_alpha_underscore( cur );
 }
 
-static boolean uprcase( char c )
+static char uprcase( char c )
 {
    if (c >= 'a' && c <= 'z')
       return c += 'A' - 'a';
@@ -76,7 +76,7 @@ streq_nocase_uprcase(const char *str1,
       str1++;
       str2++;
    }
-   return TRUE;
+   return *str1 == 0 && *str2 == 0;
 }
 
 static boolean str_match_no_case( const char **pcur, const char *str )
index 4d0737ccd3d03ed0fea6b2ca22b739b4d672c6ab..cd95f85b63bddfcbe6efba61658c481b9e69d239 100644 (file)
@@ -45,6 +45,7 @@
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_sampler.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_surface.h"
 #include "util/u_rect.h"
@@ -280,6 +281,7 @@ regions_overlap(int srcX0, int srcY0,
 void
 util_blit_pixels_writemask(struct blit_state *ctx,
                            struct pipe_surface *src,
+                           struct pipe_sampler_view *src_sampler_view,
                            int srcX0, int srcY0,
                            int srcX1, int srcY1,
                            struct pipe_surface *dst,
@@ -290,7 +292,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
 {
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_screen *screen = pipe->screen;
-   struct pipe_texture *tex = NULL;
+   struct pipe_sampler_view *sampler_view = NULL;
    struct pipe_framebuffer_state fb;
    const int srcW = abs(srcX1 - srcX0);
    const int srcH = abs(srcY1 - srcY0);
@@ -345,6 +347,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
        src->texture->last_level != 0)
    {
       struct pipe_texture texTemp;
+      struct pipe_texture *tex;
+      struct pipe_sampler_view sv_templ;
       struct pipe_surface *texSurf;
       const int srcLeft = MIN2(srcX0, srcX1);
       const int srcTop = MIN2(srcY0, srcY1);
@@ -376,6 +380,14 @@ util_blit_pixels_writemask(struct blit_state *ctx,
       if (!tex)
          return;
 
+      u_sampler_view_default_template(&sv_templ, tex, tex->format);
+
+      sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, tex, &sv_templ);
+      if (!sampler_view) {
+         pipe_texture_reference(&tex, NULL);
+         return;
+      }
+
       texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, 
                                         PIPE_BUFFER_USAGE_GPU_WRITE);
 
@@ -399,22 +411,25 @@ util_blit_pixels_writemask(struct blit_state *ctx,
       s1 = 1.0f;
       t0 = 0.0f;
       t1 = 1.0f;
+
+      pipe_texture_reference(&tex, NULL);
    }
    else {
-      pipe_texture_reference(&tex, src->texture);
-      s0 = srcX0 / (float)tex->width0;
-      s1 = srcX1 / (float)tex->width0;
-      t0 = srcY0 / (float)tex->height0;
-      t1 = srcY1 / (float)tex->height0;
+      pipe_sampler_view_reference(&sampler_view, src_sampler_view);
+      s0 = srcX0 / (float)src->texture->width0;
+      s1 = srcX1 / (float)src->texture->width0;
+      t0 = srcY0 / (float)src->texture->height0;
+      t1 = srcY1 / (float)src->texture->height0;
    }
 
+   
 
    /* save state (restored below) */
    cso_save_blend(ctx->cso);
    cso_save_depth_stencil_alpha(ctx->cso);
    cso_save_rasterizer(ctx->cso);
    cso_save_samplers(ctx->cso);
-   cso_save_sampler_textures(ctx->cso);
+   cso_save_fragment_sampler_views(ctx->cso);
    cso_save_viewport(ctx->cso);
    cso_save_framebuffer(ctx->cso);
    cso_save_fragment_shader(ctx->cso);
@@ -447,7 +462,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
    cso_set_viewport(ctx->cso, &ctx->viewport);
 
    /* texture */
-   cso_set_sampler_textures(ctx->cso, 1, &tex);
+   cso_set_fragment_sampler_views(ctx->cso, 1, &sampler_view);
 
    if (ctx->fs[writemask] == NULL)
       ctx->fs[writemask] =
@@ -486,7 +501,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
    cso_restore_depth_stencil_alpha(ctx->cso);
    cso_restore_rasterizer(ctx->cso);
    cso_restore_samplers(ctx->cso);
-   cso_restore_sampler_textures(ctx->cso);
+   cso_restore_fragment_sampler_views(ctx->cso);
    cso_restore_viewport(ctx->cso);
    cso_restore_framebuffer(ctx->cso);
    cso_restore_fragment_shader(ctx->cso);
@@ -494,13 +509,14 @@ util_blit_pixels_writemask(struct blit_state *ctx,
    cso_restore_clip(ctx->cso);
    cso_restore_vertex_elements(ctx->cso);
 
-   pipe_texture_reference(&tex, NULL);
+   pipe_sampler_view_reference(&sampler_view, NULL);
 }
 
 
 void
 util_blit_pixels(struct blit_state *ctx,
                  struct pipe_surface *src,
+                 struct pipe_sampler_view *src_sampler_view,
                  int srcX0, int srcY0,
                  int srcX1, int srcY1,
                  struct pipe_surface *dst,
@@ -508,7 +524,7 @@ util_blit_pixels(struct blit_state *ctx,
                  int dstX1, int dstY1,
                  float z, uint filter )
 {
-   util_blit_pixels_writemask( ctx, src, 
+   util_blit_pixels_writemask( ctx, src, src_sampler_view,
                                srcX0, srcY0,
                                srcX1, srcY1,
                                dst,
@@ -539,21 +555,23 @@ void util_blit_flush( struct blit_state *ctx )
  */
 void
 util_blit_pixels_tex(struct blit_state *ctx,
-                 struct pipe_texture *tex,
-                 int srcX0, int srcY0,
-                 int srcX1, int srcY1,
-                 struct pipe_surface *dst,
-                 int dstX0, int dstY0,
-                 int dstX1, int dstY1,
-                 float z, uint filter)
+                     struct pipe_sampler_view *src_sampler_view,
+                     int srcX0, int srcY0,
+                     int srcX1, int srcY1,
+                     struct pipe_surface *dst,
+                     int dstX0, int dstY0,
+                     int dstX1, int dstY1,
+                     float z, uint filter)
 {
    struct pipe_framebuffer_state fb;
    float s0, t0, s1, t1;
    unsigned offset;
+   struct pipe_texture *tex = src_sampler_view->texture;
 
    assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
           filter == PIPE_TEX_MIPFILTER_LINEAR);
 
+   assert(tex);
    assert(tex->width0 != 0);
    assert(tex->height0 != 0);
 
@@ -572,7 +590,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
    cso_save_depth_stencil_alpha(ctx->cso);
    cso_save_rasterizer(ctx->cso);
    cso_save_samplers(ctx->cso);
-   cso_save_sampler_textures(ctx->cso);
+   cso_save_fragment_sampler_views(ctx->cso);
    cso_save_framebuffer(ctx->cso);
    cso_save_fragment_shader(ctx->cso);
    cso_save_vertex_shader(ctx->cso);
@@ -604,7 +622,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
    cso_set_viewport(ctx->cso, &ctx->viewport);
 
    /* texture */
-   cso_set_sampler_textures(ctx->cso, 1, &tex);
+   cso_set_fragment_sampler_views(ctx->cso, 1, &src_sampler_view);
 
    /* shaders */
    cso_set_fragment_shader_handle(ctx->cso, ctx->fs[TGSI_WRITEMASK_XYZW]);
@@ -638,7 +656,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
    cso_restore_depth_stencil_alpha(ctx->cso);
    cso_restore_rasterizer(ctx->cso);
    cso_restore_samplers(ctx->cso);
-   cso_restore_sampler_textures(ctx->cso);
+   cso_restore_fragment_sampler_views(ctx->cso);
    cso_restore_framebuffer(ctx->cso);
    cso_restore_fragment_shader(ctx->cso);
    cso_restore_vertex_shader(ctx->cso);
index a102021529e8209e42e1f4070a2c7b6e3bc97b94..1ebe65b4558b6208ba268c2100da28aa3839094b 100644 (file)
@@ -53,6 +53,7 @@ util_destroy_blit(struct blit_state *ctx);
 extern void
 util_blit_pixels(struct blit_state *ctx,
                  struct pipe_surface *src,
+                 struct pipe_sampler_view *src_sampler_view,
                  int srcX0, int srcY0,
                  int srcX1, int srcY1,
                  struct pipe_surface *dst,
@@ -63,6 +64,7 @@ util_blit_pixels(struct blit_state *ctx,
 void
 util_blit_pixels_writemask(struct blit_state *ctx,
                            struct pipe_surface *src,
+                           struct pipe_sampler_view *src_sampler_view,
                            int srcX0, int srcY0,
                            int srcX1, int srcY1,
                            struct pipe_surface *dst,
@@ -73,7 +75,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
 
 extern void
 util_blit_pixels_tex(struct blit_state *ctx,
-                     struct pipe_texture *tex,
+                     struct pipe_sampler_view *src_sampler_view,
                      int srcX0, int srcY0,
                      int srcX1, int srcY1,
                      struct pipe_surface *dst,
index 36d582491f36e3390c358e34e147c9acd4a949ef..1692987e8e300241ce5ae65b8e995b78204667b6 100644 (file)
@@ -45,6 +45,7 @@
 #include "util/u_draw_quad.h"
 #include "util/u_pack_color.h"
 #include "util/u_rect.h"
+#include "util/u_sampler.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_texture.h"
 
@@ -96,6 +97,8 @@ struct blitter_context_priv
    /* Rasterizer state. */
    void *rs_state;
 
+   struct pipe_sampler_view *sampler_view;
+
    /* Viewport state. */
    struct pipe_viewport_state viewport;
 
@@ -127,7 +130,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
    ctx->blitter.saved_vs = INVALID_PTR;
    ctx->blitter.saved_velem_state = INVALID_PTR;
    ctx->blitter.saved_fb_state.nr_cbufs = ~0;
-   ctx->blitter.saved_num_textures = ~0;
+   ctx->blitter.saved_num_sampler_views = ~0;
    ctx->blitter.saved_num_sampler_states = ~0;
 
    /* blend state objects */
@@ -252,6 +255,10 @@ void util_blitter_destroy(struct blitter_context *blitter)
       if (ctx->sampler_state[i])
          pipe->delete_sampler_state(pipe, ctx->sampler_state[i]);
 
+   if (ctx->sampler_view) {
+      pipe_sampler_view_reference(&ctx->sampler_view, NULL);
+   }
+
    pipe_buffer_reference(&ctx->vbuf, NULL);
    FREE(ctx);
 }
@@ -305,11 +312,11 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
       ctx->blitter.saved_num_sampler_states = ~0;
    }
 
-   if (ctx->blitter.saved_num_textures != ~0) {
-      pipe->set_fragment_sampler_textures(pipe,
-                                          ctx->blitter.saved_num_textures,
-                                          ctx->blitter.saved_textures);
-      ctx->blitter.saved_num_textures = ~0;
+   if (ctx->blitter.saved_num_sampler_views != ~0) {
+      pipe->set_fragment_sampler_views(pipe,
+                                       ctx->blitter.saved_num_sampler_views,
+                                       ctx->blitter.saved_sampler_views);
+      ctx->blitter.saved_num_sampler_views = ~0;
    }
 }
 
@@ -621,9 +628,10 @@ static void util_blitter_do_copy(struct blitter_context *blitter,
    struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_framebuffer_state fb_state;
+   struct pipe_sampler_view viewTempl, *view;
 
    assert(blitter->saved_fb_state.nr_cbufs != ~0);
-   assert(blitter->saved_num_textures != ~0);
+   assert(blitter->saved_num_sampler_views != ~0);
    assert(blitter->saved_num_sampler_states != ~0);
    assert(src->texture->target < PIPE_MAX_TEXTURE_TYPES);
 
@@ -651,12 +659,24 @@ static void util_blitter_do_copy(struct blitter_context *blitter,
       fb_state.zsbuf = 0;
    }
 
+   u_sampler_view_default_template(&viewTempl,
+                                   src->texture,
+                                   src->texture->format);
+   view = pipe->create_sampler_view(pipe,
+                                    src->texture,
+                                    &viewTempl);
+
+   if (ctx->sampler_view) {
+      pipe_sampler_view_reference(&ctx->sampler_view, NULL);
+   }
+   ctx->sampler_view = view;
+
    pipe->bind_rasterizer_state(pipe, ctx->rs_state);
    pipe->bind_vs_state(pipe, ctx->vs_tex);
    pipe->bind_fragment_sampler_states(pipe, 1,
       blitter_get_sampler_state(ctx, src->level));
    pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
-   pipe->set_fragment_sampler_textures(pipe, 1, &src->texture);
+   pipe->set_fragment_sampler_views(pipe, 1, &view);
    pipe->set_framebuffer_state(pipe, &fb_state);
 
    /* set texture coordinates */
index ecafdabafae79ffa3431ca9d78d3bf79c350c8e0..2ad7201a29d96a5abdd010999bd1a3d066b3df30 100644 (file)
@@ -53,10 +53,10 @@ struct blitter_context
    struct pipe_clip_state saved_clip;
 
    int saved_num_sampler_states;
-   void *saved_sampler_states[32];
+   void *saved_sampler_states[PIPE_MAX_SAMPLERS];
 
-   int saved_num_textures;
-   struct pipe_texture *saved_textures[32]; /* is 32 enough? */
+   int saved_num_sampler_views;
+   struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS];
 };
 
 /**
@@ -242,17 +242,17 @@ void util_blitter_save_fragment_sampler_states(
           num_sampler_states * sizeof(void *));
 }
 
-static INLINE
-void util_blitter_save_fragment_sampler_textures(
-                  struct blitter_context *blitter,
-                  int num_textures,
-                  struct pipe_texture **textures)
+static INLINE void
+util_blitter_save_fragment_sampler_views(struct blitter_context *blitter,
+                                         int num_views,
+                                         struct pipe_sampler_view **views)
 {
-   assert(num_textures <= Elements(blitter->saved_textures));
+   assert(num_views <= Elements(blitter->saved_sampler_views));
 
-   blitter->saved_num_textures = num_textures;
-   memcpy(blitter->saved_textures, textures,
-          num_textures * sizeof(struct pipe_texture *));
+   blitter->saved_num_sampler_views = num_views;
+   memcpy(blitter->saved_sampler_views,
+          views,
+          num_views * sizeof(struct pipe_sampler_view *));
 }
 
 #ifdef __cplusplus
index 96a0fa65507635cf37e0319e91cf3d860fdc5cee..d819bbbde1c373f37a6d2fae32d9e64de45ed842 100644 (file)
@@ -47,9 +47,9 @@
 # - color space: rgb, yub, sz
 #
 # See also:
-# - http://msdn.microsoft.com/en-us/library/ee416489.aspx (D3D9)
-# - http://msdn.microsoft.com/en-us/library/ee415668.aspx (D3D9 -> D3D10)
-# - http://msdn.microsoft.com/en-us/library/ee418116.aspx (D3D10)
+# - http://msdn.microsoft.com/en-us/library/bb172558.aspx (D3D9)
+# - http://msdn.microsoft.com/en-us/library/bb205073.aspx#mapping_texture_formats (D3D9 -> D3D10)
+# - http://msdn.microsoft.com/en-us/library/bb173059.aspx (D3D10)
 #
 # Note that GL doesn't really specify the layout of internal formats. See
 # OpenGL 2.1 specification, Table 3.16, on the "Correspondence of sized
@@ -63,6 +63,7 @@ PIPE_FORMAT_A8R8G8B8_UNORM        , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, r
 PIPE_FORMAT_X8R8G8B8_UNORM        , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb
 PIPE_FORMAT_A8B8G8R8_UNORM        , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb
 PIPE_FORMAT_X8B8G8R8_UNORM        , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb
+PIPE_FORMAT_B5G5R5X1_UNORM        , plain, 1, 1, un5 , un5 , un5 , un1 , zyx1, rgb
 PIPE_FORMAT_B5G5R5A1_UNORM        , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
 PIPE_FORMAT_B4G4R4A4_UNORM        , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
 PIPE_FORMAT_B5G6R5_UNORM          , plain, 1, 1, un5 , un6 , un5 ,     , zyx1, rgb
@@ -109,14 +110,18 @@ PIPE_FORMAT_UYVY                 , subsampled, 2, 1, x32 ,     ,     ,     , xyz
 PIPE_FORMAT_YUYV                 , subsampled, 2, 1, x32 ,     ,     ,     , xyz1, yuv
 
 # Compressed formats
-PIPE_FORMAT_DXT1_RGB              , compressed, 4, 4, x64 ,     ,     ,     , xyz1, rgb
-PIPE_FORMAT_DXT1_RGBA             , compressed, 4, 4, x64 ,     ,     ,     , xyzw, rgb
-PIPE_FORMAT_DXT3_RGBA             , compressed, 4, 4, x128,     ,     ,     , xyzw, rgb
-PIPE_FORMAT_DXT5_RGBA             , compressed, 4, 4, x128,     ,     ,     , xyzw, rgb
-PIPE_FORMAT_DXT1_SRGB             , compressed, 4, 4, x64 ,     ,     ,     , xyz1, srgb
-PIPE_FORMAT_DXT1_SRGBA            , compressed, 4, 4, x64 ,     ,     ,     , xyzw, srgb
-PIPE_FORMAT_DXT3_SRGBA            , compressed, 4, 4, x128,     ,     ,     , xyzw, srgb
-PIPE_FORMAT_DXT5_SRGBA            , compressed, 4, 4, x128,     ,     ,     , xyzw, srgb
+# - http://en.wikipedia.org/wiki/S3_Texture_Compression
+# - http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt
+# - http://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
+# - http://msdn.microsoft.com/en-us/library/bb694531.aspx
+PIPE_FORMAT_DXT1_RGB              , s3tc, 4, 4, x64 ,     ,     ,     , xyz1, rgb
+PIPE_FORMAT_DXT1_RGBA             , s3tc, 4, 4, x64 ,     ,     ,     , xyzw, rgb
+PIPE_FORMAT_DXT3_RGBA             , s3tc, 4, 4, x128,     ,     ,     , xyzw, rgb
+PIPE_FORMAT_DXT5_RGBA             , s3tc, 4, 4, x128,     ,     ,     , xyzw, rgb
+PIPE_FORMAT_DXT1_SRGB             , s3tc, 4, 4, x64 ,     ,     ,     , xyz1, srgb
+PIPE_FORMAT_DXT1_SRGBA            , s3tc, 4, 4, x64 ,     ,     ,     , xyzw, srgb
+PIPE_FORMAT_DXT3_SRGBA            , s3tc, 4, 4, x128,     ,     ,     , xyzw, srgb
+PIPE_FORMAT_DXT5_SRGBA            , s3tc, 4, 4, x128,     ,     ,     , xyzw, srgb
 
 # Straightforward D3D10-like formats (also used for 
 # vertex buffer element description)
index c08fdcafcc8deca38f5013e5570924687f15c070..98d4b98ebb5835f9dfccacba54d5c40fcfaeb2df 100644 (file)
@@ -56,15 +56,23 @@ enum util_format_layout {
     *
     * This is for formats like YV12 where there is less than one sample per
     * pixel.
-    *
-    * XXX: This could actually b
     */
    UTIL_FORMAT_LAYOUT_SUBSAMPLED = 3,
 
    /**
-    * An unspecified compression algorithm.
+    * S3 Texture Compression formats.
+    */
+   UTIL_FORMAT_LAYOUT_S3TC = 4,
+
+   /**
+    * Red-Green Texture Compression formats.
+    */
+   UTIL_FORMAT_LAYOUT_RGTC = 5,
+
+   /**
+    * Everything else that doesn't fit in any of the above layouts.
     */
-   UTIL_FORMAT_LAYOUT_COMPRESSED = 4
+   UTIL_FORMAT_LAYOUT_OTHER = 6
 };
 
 
@@ -210,7 +218,7 @@ util_format_name(enum pipe_format format)
 }
 
 static INLINE boolean 
-util_format_is_compressed(enum pipe_format format)
+util_format_is_s3tc(enum pipe_format format)
 {
    const struct util_format_description *desc = util_format_description(format);
 
@@ -219,7 +227,7 @@ util_format_is_compressed(enum pipe_format format)
       return FALSE;
    }
 
-   return desc->layout == UTIL_FORMAT_LAYOUT_COMPRESSED ? TRUE : FALSE;
+   return desc->layout == UTIL_FORMAT_LAYOUT_S3TC ? TRUE : FALSE;
 }
 
 static INLINE boolean 
index 182a4740448d887ede733a5478a4798e0109abd7..9d6debcd8c754b8855f2469079377abed24dc2ec 100644 (file)
@@ -120,6 +120,13 @@ util_format_test_cases[] =
     * 16-bit rendertarget formats
     */
 
+   {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}},
+   {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}},
+   {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}},
+   {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 0.0}},
+   {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x8000), {0.0, 0.0, 0.0, 1.0}},
+   {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}},
+
    {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}},
    {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}},
    {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}},
index 5c51b53d7bd7091e4cd629714480dfea64a336cf..509d38754f528988891f2e73c793674930c98a63 100644 (file)
@@ -938,6 +938,7 @@ format_to_type_comps(enum pipe_format pformat,
       *datatype = DTYPE_UBYTE;
       *comps = 4;
       return;
+   case PIPE_FORMAT_B5G5R5X1_UNORM:
    case PIPE_FORMAT_B5G5R5A1_UNORM:
       *datatype = DTYPE_USHORT_1_5_5_5_REV;
       *comps = 4;
@@ -1460,7 +1461,7 @@ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx )
  * Generate mipmap images.  It's assumed all needed texture memory is
  * already allocated.
  *
- * \param p the texture to generate mipmap levels for
+ * \param psv  the sampler view to the texture to generate mipmap levels for
  * \param face  which cube face to generate mipmaps for (0 for non-cube maps)
  * \param baseLevel  the first mipmap level to use as a src
  * \param lastLevel  the last mipmap level to generate
@@ -1469,12 +1470,13 @@ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx )
  */
 void
 util_gen_mipmap(struct gen_mipmap_state *ctx,
-                struct pipe_texture *pt,
+                struct pipe_sampler_view *psv,
                 uint face, uint baseLevel, uint lastLevel, uint filter)
 {
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_screen *screen = pipe->screen;
    struct pipe_framebuffer_state fb;
+   struct pipe_texture *pt = psv->texture;
    void *fs = (pt->target == PIPE_TEXTURE_CUBE) ? ctx->fsCube : ctx->fs2d;
    uint dstLevel;
    uint zslice = 0;
@@ -1492,7 +1494,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
           filter == PIPE_TEX_FILTER_NEAREST);
 
    /* check if we can render in the texture's format */
-   if (!screen->is_format_supported(screen, pt->format, PIPE_TEXTURE_2D,
+   if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D,
                                     PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
       fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel);
       return;
@@ -1503,7 +1505,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_save_depth_stencil_alpha(ctx->cso);
    cso_save_rasterizer(ctx->cso);
    cso_save_samplers(ctx->cso);
-   cso_save_sampler_textures(ctx->cso);
+   cso_save_fragment_sampler_views(ctx->cso);
    cso_save_framebuffer(ctx->cso);
    cso_save_fragment_shader(ctx->cso);
    cso_save_vertex_shader(ctx->cso);
@@ -1572,7 +1574,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
       cso_single_sampler(ctx->cso, 0, &ctx->sampler);
       cso_single_sampler_done(ctx->cso);
 
-      cso_set_sampler_textures(ctx->cso, 1, &pt);
+      cso_set_fragment_sampler_views(ctx->cso, 1, &psv);
 
       /* quad coords in clip coords */
       offset = set_vertex_data(ctx,
@@ -1597,7 +1599,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_restore_depth_stencil_alpha(ctx->cso);
    cso_restore_rasterizer(ctx->cso);
    cso_restore_samplers(ctx->cso);
-   cso_restore_sampler_textures(ctx->cso);
+   cso_restore_fragment_sampler_views(ctx->cso);
    cso_restore_framebuffer(ctx->cso);
    cso_restore_fragment_shader(ctx->cso);
    cso_restore_vertex_shader(ctx->cso);
index 54608f9466dafc108eebbfd7685cd108e8bd3466..35ac9daeaa20eb5d5f87523ef5ab5068761f9ea7 100644 (file)
@@ -59,7 +59,7 @@ util_gen_mipmap_flush( struct gen_mipmap_state *ctx );
 
 extern void
 util_gen_mipmap(struct gen_mipmap_state *ctx,
-                struct pipe_texture *pt,
+                struct pipe_sampler_view *psv,
                 uint face, uint baseLevel, uint lastLevel, uint filter);
 
 
index e7255e3baa8bfcdf5f31f4a0adb9110bd6fa4c31..e22ab188e113897bccde250b759c76f36ab20bb3 100644 (file)
@@ -120,6 +120,16 @@ pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
    *ptr = tex;
 }
 
+static INLINE void
+pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_view *view)
+{
+   struct pipe_sampler_view *old_view = *ptr;
+
+   if (pipe_reference(&(*ptr)->reference, &view->reference))
+      old_view->context->sampler_view_destroy(old_view->context, old_view);
+   *ptr = view;
+}
+
 
 /*
  * Convenience wrappers for screen buffer functions.
index 50f1b1670b683f5f8f1c1ad21fc04f87adbc0daf..c5fd7a6783e256977b25c60d66c6b63d885a47a6 100644 (file)
@@ -92,6 +92,11 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
          uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
       }
       return;
+   case PIPE_FORMAT_B5G5R5X1_UNORM:
+      {
+         uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
+      }
+      return;
    case PIPE_FORMAT_B5G5R5A1_UNORM:
       {
          uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
@@ -216,6 +221,15 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
          *a = (ubyte) 0xff;
       }
       return;
+   case PIPE_FORMAT_B5G5R5X1_UNORM:
+      {
+         ushort p = uc->us;
+         *r = (ubyte) (((p >>  7) & 0xf8) | ((p >> 12) & 0x7));
+         *g = (ubyte) (((p >>  2) & 0xf8) | ((p >>  7) & 0x7));
+         *b = (ubyte) (((p <<  3) & 0xf8) | ((p >>  2) & 0x7));
+         *a = (ubyte) 0xff;
+      }
+      return;
    case PIPE_FORMAT_B5G5R5A1_UNORM:
       {
          ushort p = uc->us;
@@ -361,6 +375,11 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color *
          uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
       }
       return;
+   case PIPE_FORMAT_B5G5R5X1_UNORM:
+      {
+         uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
+      }
+      return;
    case PIPE_FORMAT_B5G5R5A1_UNORM:
       {
          uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
diff --git a/src/gallium/auxiliary/util/u_sampler.c b/src/gallium/auxiliary/util/u_sampler.c
new file mode 100644 (file)
index 0000000..4d8f861
--- /dev/null
@@ -0,0 +1,100 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "u_format.h"
+#include "u_sampler.h"
+
+
+static void
+default_template(struct pipe_sampler_view *view,
+                 const struct pipe_texture *texture,
+                 enum pipe_format format,
+                 unsigned expand_green_blue)
+{
+   /* XXX: Check if format is compatible with texture->format.
+    */
+
+   view->format = format;
+   view->first_level = 0;
+   view->last_level = texture->last_level;
+   view->swizzle_r = PIPE_SWIZZLE_RED;
+   view->swizzle_g = PIPE_SWIZZLE_GREEN;
+   view->swizzle_b = PIPE_SWIZZLE_BLUE;
+   view->swizzle_a = PIPE_SWIZZLE_ALPHA;
+
+   /* Override default green and blue component expansion to the requested
+    * one.
+    *
+    * Gallium expands nonexistent components to (0,0,0,1), DX9 expands
+    * to (1,1,1,1).  Since alpha is always expanded to 1, and red is
+    * always present, we only really care about green and blue
+    * components.
+    *
+    * To make it look less hackish, one would have to add
+    * UTIL_FORMAT_SWIZZLE_EXPAND to indicate components for expansion
+    * and then override without exceptions or favoring one component
+    * over another.
+    */
+   if (format != PIPE_FORMAT_A8_UNORM) {
+      const struct util_format_description *desc = util_format_description(format);
+
+      assert(desc);
+      if (desc) {
+         if (desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_0) {
+            view->swizzle_g = expand_green_blue;
+         }
+         if (desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_0) {
+            view->swizzle_b = expand_green_blue;
+         }
+      }
+   }
+}
+
+void
+u_sampler_view_default_template(struct pipe_sampler_view *view,
+                                const struct pipe_texture *texture,
+                                enum pipe_format format)
+{
+   /* Expand to (0, 0, 0, 1) */
+   default_template(view,
+                    texture,
+                    format,
+                    PIPE_SWIZZLE_ZERO);
+}
+
+void
+u_sampler_view_default_dx9_template(struct pipe_sampler_view *view,
+                                    const struct pipe_texture *texture,
+                                    enum pipe_format format)
+{
+   /* Expand to (1, 1, 1, 1) */
+   default_template(view,
+                    texture,
+                    format,
+                    PIPE_SWIZZLE_ONE);
+}
diff --git a/src/gallium/auxiliary/util/u_sampler.h b/src/gallium/auxiliary/util/u_sampler.h
new file mode 100644 (file)
index 0000000..bdd061c
--- /dev/null
@@ -0,0 +1,57 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef U_SAMPLER_H
+#define U_SAMPLER_H
+
+
+#include "pipe/p_defines.h"
+#include "pipe/p_format.h"
+#include "pipe/p_state.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void
+u_sampler_view_default_template(struct pipe_sampler_view *view,
+                                const struct pipe_texture *texture,
+                                enum pipe_format format);
+
+void
+u_sampler_view_default_dx9_template(struct pipe_sampler_view *view,
+                                    const struct pipe_texture *texture,
+                                    enum pipe_format format);
+
+
+#ifdef __cplusplus
+} /* extern "C" { */
+#endif
+
+#endif /* U_SAMPLER_H */
index e445895efc593fec711dcd4ecc4a5a4475ff1f3b..09b2382733d2c20651ee48b883b71114d12e7a5c 100644 (file)
@@ -295,6 +295,55 @@ r8g8b8a8_put_tile_rgba(unsigned *dst,
 }
 
 
+/*** PIPE_FORMAT_B5G5R5X1_UNORM ***/
+
+static void
+x1r5g5b5_get_tile_rgba(const ushort *src,
+                       unsigned w, unsigned h,
+                       float *p,
+                       unsigned dst_stride)
+{
+   unsigned i, j;
+
+   for (i = 0; i < h; i++) {
+      float *pRow = p;
+      for (j = 0; j < w; j++, pRow += 4) {
+         const ushort pixel = *src++;
+         pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f);
+         pRow[1] = ((pixel >>  5) & 0x1f) * (1.0f / 31.0f);
+         pRow[2] = ((pixel      ) & 0x1f) * (1.0f / 31.0f);
+         pRow[3] = 1.0f;
+      }
+      p += dst_stride;
+   }
+}
+
+
+static void
+x1r5g5b5_put_tile_rgba(ushort *dst,
+                       unsigned w, unsigned h,
+                       const float *p,
+                       unsigned src_stride)
+{
+   unsigned i, j;
+
+   for (i = 0; i < h; i++) {
+      const float *pRow = p;
+      for (j = 0; j < w; j++, pRow += 4) {
+         unsigned r, g, b;
+         r = float_to_ubyte(pRow[0]);
+         g = float_to_ubyte(pRow[1]);
+         b = float_to_ubyte(pRow[2]);
+         r = r >> 3;  /* 5 bits */
+         g = g >> 3;  /* 5 bits */
+         b = b >> 3;  /* 5 bits */
+         *dst++ = (1 << 15) | (r << 10) | (g << 5) | b;
+      }
+      p += src_stride;
+   }
+}
+
+
 /*** PIPE_FORMAT_B5G5R5A1_UNORM ***/
 
 static void
@@ -1174,6 +1223,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
    case PIPE_FORMAT_A8B8G8R8_UNORM:
       r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
       break;
+   case PIPE_FORMAT_B5G5R5X1_UNORM:
+      x1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
+      break;
    case PIPE_FORMAT_B5G5R5A1_UNORM:
       a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
       break;
@@ -1274,6 +1326,69 @@ pipe_get_tile_rgba(struct pipe_context *pipe,
 }
 
 
+void
+pipe_get_tile_swizzle(struct pipe_context *pipe,
+                     struct pipe_transfer *pt,
+                      uint x,
+                      uint y,
+                      uint w,
+                      uint h,
+                      uint swizzle_r,
+                      uint swizzle_g,
+                      uint swizzle_b,
+                      uint swizzle_a,
+                      enum pipe_format format,
+                      float *p)
+{
+   unsigned dst_stride = w * 4;
+   void *packed;
+   uint i;
+   float rgba01[6];
+
+   if (pipe_clip_tile(x, y, &w, &h, pt)) {
+      return;
+   }
+
+   packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
+   if (!packed) {
+      return;
+   }
+
+   if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) {
+      assert((x & 1) == 0);
+   }
+
+   pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+
+   pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
+
+   FREE(packed);
+
+   if (swizzle_r == PIPE_SWIZZLE_RED &&
+       swizzle_g == PIPE_SWIZZLE_GREEN &&
+       swizzle_b == PIPE_SWIZZLE_BLUE &&
+       swizzle_a == PIPE_SWIZZLE_ALPHA) {
+      /* no-op, skip */
+      return;
+   }
+
+   rgba01[PIPE_SWIZZLE_ZERO] = 0.0f;
+   rgba01[PIPE_SWIZZLE_ONE] = 1.0f;
+
+   for (i = 0; i < w * h; i++) {
+      rgba01[PIPE_SWIZZLE_RED] = p[0];
+      rgba01[PIPE_SWIZZLE_GREEN] = p[1];
+      rgba01[PIPE_SWIZZLE_BLUE] = p[2];
+      rgba01[PIPE_SWIZZLE_ALPHA] = p[3];
+
+      *p++ = rgba01[swizzle_r];
+      *p++ = rgba01[swizzle_g];
+      *p++ = rgba01[swizzle_b];
+      *p++ = rgba01[swizzle_a];
+   }
+}
+
+
 void
 pipe_put_tile_rgba(struct pipe_context *pipe,
                    struct pipe_transfer *pt,
@@ -1305,6 +1420,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
    case PIPE_FORMAT_A8B8G8R8_UNORM:
       r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
       break;
+   case PIPE_FORMAT_B5G5R5X1_UNORM:
+      x1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
+      break;
    case PIPE_FORMAT_B5G5R5A1_UNORM:
       a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
       break;
index 8329087cfa6f0da649be66e4f2d60fc9a97dcbd8..1d8ce7d8cbc3f7402812e9eeed33776a16be883a 100644 (file)
@@ -74,6 +74,20 @@ pipe_get_tile_rgba(struct pipe_context *pipe,
                    uint x, uint y, uint w, uint h,
                    float *p);
 
+void
+pipe_get_tile_swizzle(struct pipe_context *pipe,
+                     struct pipe_transfer *pt,
+                      uint x,
+                      uint y,
+                      uint w,
+                      uint h,
+                      uint swizzle_r,
+                      uint swizzle_g,
+                      uint swizzle_b,
+                      uint swizzle_a,
+                      enum pipe_format format,
+                      float *p);
+
 void
 pipe_put_tile_rgba(struct pipe_context *pipe,
                    struct pipe_transfer *pt,
diff --git a/src/gallium/docs/d3d11ddi.txt b/src/gallium/docs/d3d11ddi.txt
new file mode 100644 (file)
index 0000000..0baf268
--- /dev/null
@@ -0,0 +1,492 @@
+This document compares the D3D10/D3D11 device driver interface with Gallium.
+It is written from the perspective of a developer implementing a D3D10/D3D11 driver as a Gallium state tracker.
+
+Note that naming and other cosmetic differences are not noted, since they don't really matter and would severely clutter the document.
+Gallium/OpenGL terminology is used in preference to D3D terminology.
+
+NOTE: this document tries to be complete but most likely isn't fully complete and also not fully correct: please submit patches if you spot anything incorrect
+
+Also note that this is specifically for the DirectX 10/11 Windows Vista/7 DDI interfaces.
+DirectX 9 has both user-mode (for Vista) and kernel mode (pre-Vista) interfaces, but they are significantly different from Gallium due to the presence of a lot of fixed function functionality.
+
+The user-visible DirectX 10/11 interfaces are distinct from the kernel DDI, but they match very closely.
+
+* Accessing Microsoft documentation
+
+See http://msdn.microsoft.com/en-us/library/dd445501.aspx ("D3D11DDI_DEVICEFUNCS") for D3D documentation.
+
+Also see http://download.microsoft.com/download/f/2/d/f2d5ee2c-b7ba-4cd0-9686-b6508b5479a1/direct3d10_web.pdf ("The Direct3D 10 System" by David Blythe) for an introduction to Direct3D 10 and the rationale for its design.
+
+The Windows Driver Kit contains the actual headers, as well as shader bytecode documentation.
+
+To get the headers from Linux, run the following, in a dedicated directory:
+wget http://download.microsoft.com/download/4/A/2/4A25C7D5-EFBE-4182-B6A9-AE6850409A78/GRMWDK_EN_7600_1.ISO
+sudo mount -o loop GRMWDK_EN_7600_1.ISO /mnt/tmp
+cabextract -x /mnt/tmp/wdk/headers_cab001.cab
+rename 's/^_(.*)_[0-9]*$/$1/' *
+sudo umount /mnt/tmp
+
+d3d10umddi.h contains the DDI interface analyzed in this document: note that it is much easier to read this online on MSDN.
+d3d{10,11}TokenizedProgramFormat.hpp contains the shader bytecode definitions: this is not available on MSDN.
+d3d9types.h contains DX9 shader bytecode, and DX9 types
+d3dumddi.h contains the DirectX 9 DDI interface
+
+* Glossary
+
+BC1: DXT1
+BC2: DXT3
+BC3: DXT5
+BC5: RGTC
+BC6H: BPTC float
+BC7: BPTC
+CS = compute shader: OpenCL-like shader
+DS = domain shader: tessellation evaluation shader
+HS = hull shader: tessellation control shader
+IA = input assembler: primitive assembly
+Input layout: vertex elements
+OM = output merger: blender
+PS = pixel shader: fragment shader
+Primitive topology: primitive type
+Resource: buffer or texture
+Shader resource (view): sampler view
+SO = stream out: transform feedback
+Unordered access view: view supporting random read/write access (usually from compute shaders)
+
+* Legend
+
+-: features D3D11 has and Gallium lacks
++: features Gallium has and D3D11 lacks
+!: differences between D3D11 and Gallium
+*: possible improvements to Gallium
+>: references to comparisons of special enumerations
+#: comment
+
+* Gallium functions with no direct D3D10/D3D11 equivalent
+
+clear
+       + Gallium supports clearing both render targets and depth/stencil with a single call
+
+draw_range_elements
+       + Gallium supports indexed draw with explicit range
+
+fence_signalled
+fence_finish
+       + D3D10/D3D11 don't appear to support explicit fencing; queries can often substitute though, and flushing is supported
+
+set_clip_state
+       + Gallium supports fixed function user clip planes, D3D10/D3D11 only support using the vertex shader for them
+
+set_polygon_stipple
+       + Gallium supports polygon stipple
+
+surface_fill
+       + Gallium supports subrectangle fills of surfaces, D3D10 only supports full clears of views
+
+* DirectX 10/11 DDI functions and Gallium equivalents
+
+AbandonCommandList (D3D11 only)
+       - Gallium does not support deferred contexts
+
+CalcPrivateBlendStateSize
+CalcPrivateDepthStencilStateSize
+CalcPrivateDepthStencilViewSize
+CalcPrivateElementLayoutSize
+CalcPrivateGeometryShaderWithStreamOutput
+CalcPrivateOpenedResourceSize
+CalcPrivateQuerySize
+CalcPrivateRasterizerStateSize
+CalcPrivateRenderTargetViewSize
+CalcPrivateResourceSize
+CalcPrivateSamplerSize
+CalcPrivateShaderResourceViewSize
+CalcPrivateShaderSize
+CalcDeferredContextHandleSize (D3D11 only)
+CalcPrivateCommandListSize (D3D11 only)
+CalcPrivateDeferredContextSize (D3D11 only)
+CalcPrivateTessellationShaderSize (D3D11 only)
+CalcPrivateUnorderedAccessViewSize (D3D11 only)
+       ! D3D11 allocates private objects itself, using the size computed here
+       * Gallium could do something similar to be able to put the private data inline into state tracker objects: this would allow them to fit in the same cacheline and improve performance
+
+CheckDeferredContextHandleSizes (D3D11 only)
+       - Gallium does not support deferred contexts
+
+CheckFormatSupport -> screen->is_format_supported
+       ! Gallium passes usages to this function, D3D11 returns them
+       - Gallium does not differentiate between blendable and non-blendable render targets
+       - Gallium lacks multisampled-texture and multisampled-render-target usages
+
+CheckMultisampleQualityLevels
+       * could merge this with is_format_supported
+       - Gallium lacks multisampling support
+
+CommandListExecute (D3D11 only)
+       - Gallium does not support command lists
+
+CopyStructureCount (D3D11 only)
+       - Gallium does not support unordered access views (views that can be written to arbitrarily from compute shaders)
+
+ClearDepthStencilView -> clear
+ClearRenderTargetView -> clear
+       # D3D11 is not totally clear about whether this applies to any view or only a "currently-bound view"
+       + Gallium allows to clear both depth/stencil and render target(s) in a single operation
+       + Gallium supports double-precision depth values (but not rgba values!)
+       * May want to also support double-precision rgba or use "float" for "depth"
+
+ClearUnorderedAccessViewFloat (D3D11 only)
+ClearUnorderedAccessViewUint (D3D11 only)
+       - Gallium does not support unordered access views (views that can be written to arbitrarily from compute shaders)
+
+CreateBlendState (extended in D3D10.1) -> create_blend_state
+       # D3D10 does not support per-RT blending, only D3D10.1 does
+       - Gallium lacks alpha-to-coverage
+       + Gallium supports logic ops
+       + Gallium supports dithering
+       + Gallium supports using the broadcast alpha component of the blend constant color
+
+CreateCommandList (D3D11 only)
+       - Gallium does not support command lists
+
+CreateComputeShader (D3D11 only)
+       - Gallium does not support compute shaders
+
+CreateDeferredContext (D3D11 only)
+       - Gallium does not support deferred contexts
+
+CreateDomainShader (D3D11 only)
+       - Gallium does not support domain shaders
+
+CreateHullShader (D3D11 only)
+       - Gallium does not support hull shaders
+
+CreateUnorderedAccessView (D3D11 only)
+       - Gallium does not support unordered access views
+
+CreateDepthStencilState -> create_depth_stencil_alpha_state
+       ! D3D11 has both a global stencil enable, and front/back enables; Gallium has only front/back enables
+       + Gallium has per-face writemask/valuemasks, D3D11 uses the same value for back and front
+       + Gallium supports the alpha test, which D3D11 lacks
+
+CreateDepthStencilView -> get_tex_surface
+CreateRenderTargetView -> get_tex_surface
+       ! Gallium merges depthstencil and rendertarget views into pipe_surface, which also doubles as a 2D surface abstraction
+       - lack of texture array support
+       - lack of render-to-buffer support
+       + Gallium supports using 3D texture zslices as a depth/stencil buffer (in theory)
+
+CreateElementLayout -> create_vertex_elements_state
+       ! D3D11 allows sparse vertex elements (via InputRegister); in Gallium they must be specified sequentially
+       ! D3D11 has an extra flag (InputSlotClass) that is the same as instance_divisor == 0
+
+CreateGeometryShader -> create_gs_state
+CreateGeometryShaderWithStreamOutput -> create_gs_state
+CreatePixelShader -> create_fs_state
+CreateVertexShader -> create_vs_state
+       > bytecode is different (see D3d10tokenizedprogramformat.hpp)
+       ! D3D11 describes input/outputs separately from bytecode; Gallium has the tgsi_scan.c module to extract it from TGSI
+       @ TODO: look into DirectX 10/11 semantics specification and bytecode
+
+CheckCounter
+CheckCounterInfo
+CreateQuery -> create_query
+       - Gallium only supports occlusion, primitives generated and primitives emitted queries
+       ! D3D11 implements fences with "event" queries
+       * TIMESTAMP could be implemented as an additional fields for other queries: some cards have hardware support for exactly this
+       * OCCLUSIONPREDICATE is required for the OpenGL v2 occlusion query functionality
+       * others are performance counters, we may want them but they are not critical
+
+CreateRasterizerState
+       - Gallium lacks clamping of polygon offset depth biases
+       - Gallium lacks support to disable depth clipping
+       - Gallium lacks multisampling
+       + Gallium, like OpenGL, supports PIPE_POLYGON_MODE_POINT
+       + Gallium, like OpenGL, supports per-face polygon fill modes
+       + Gallium, like OpenGL, supports culling everything
+       + Gallium, like OpenGL, supports two-side lighting; D3D11 only has the facing attribute
+       + Gallium, like OpenGL, supports per-fill-mode polygon offset enables
+       + Gallium, like OpenGL, supports polygon smoothing
+       + Gallium, like OpenGL, supports polygon stipple
+       + Gallium, like OpenGL, supports point smoothing
+       + Gallium, like OpenGL, supports point sprites
+       + Gallium supports specifying point quad rasterization
+       + Gallium, like OpenGL, supports per-point point size
+       + Gallium, like OpenGL, supports line smoothing
+       + Gallium, like OpenGL, supports line stipple
+       + Gallium supports line last pixel rule specification
+       + Gallium, like OpenGL, supports provoking vertex convention
+       + Gallium supports D3D9 rasterization rules
+       + Gallium supports fixed line width
+       + Gallium supports fixed point size
+
+CreateResource -> texture_create or buffer_create
+       ! D3D11 passes the dimensions of all mipmap levels to the create call, while Gallium has an implicit floor(x/2) rule
+       # Note that hardware often has the implicit rule, so the D3D11 interface seems to make little sense
+       # Also, the D3D11 API does not allow the user to specify mipmap sizes, so this really seems a dubious decision on Microsoft's part
+       - D3D11 supports specifying initial data to write in the resource
+       - Gallium lacks support for stream output buffer usage
+       - Gallium does not support unordered access buffers
+       ! D3D11 specifies mapping flags (i.e. read/write/discard);:it's unclear what they are used for here
+       - D3D11 supports odd things in the D3D10_DDI_RESOURCE_MISC_FLAG enum (D3D10_DDI_RESOURCE_MISC_DISCARD_ON_PRESENT, D3D11_DDI_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS, D3D11_DDI_RESOURCE_MISC_BUFFER_STRUCTURED)
+       - Gallium does not support indirect draw call parameter buffers
+       - Gallium lacks multisampling
+       - Gallium lacks array textures
+       ! D3D11 supports specifying hardware modes and other stuff here for scanout resources
+       + Gallium allows specifying minimum buffer alignment
+       ! D3D11 implements cube maps as 2D array textures
+
+CreateSampler
+       - D3D11 supports a monochrome convolution filter for "text filtering"
+       + Gallium supports non-normalized coordinates
+       + Gallium supports CLAMP, MIRROR_CLAMP and MIRROR_CLAMP_TO_BORDER
+       + Gallium supports setting min/max/mip filters and anisotropy independently
+
+CreateShaderResourceView (extended in D3D10.1) -> create_sampler_view
+       - Gallium lacks sampler views over buffers
+       - Gallium lacks texture arrays, and cube map views over texture arrays
+       + Gallium supports specifying a swizzle
+       ! D3D11 implements "cube views" as views into a 2D array texture
+
+CsSetConstantBuffers (D3D11 only)
+CsSetSamplers (D3D11 only)
+CsSetShader (D3D11 only)
+CsSetShaderResources (D3D11 only)
+CsSetShaderWithIfaces (D3D11 only)
+CsSetUnorderedAccessViews (D3D11 only)
+       - Gallium does not support compute shaders
+
+DestroyBlendState
+DestroyCommandList (D3D11 only)
+DestroyDepthStencilState
+DestroyDepthStencilView
+DestroyDevice
+DestroyElementLayout
+DestroyQuery
+DestroyRasterizerState
+DestroyRenderTargetView
+DestroyResource
+DestroySampler
+DestroyShader
+DestroyShaderResourceView
+DestroyUnorderedAccessView (D3D11 only)
+       # these are trivial
+
+Dispatch (D3D11 only)
+       - Gallium does not support compute shaders
+
+DispatchIndirect (D3D11 only)
+       - Gallium does not support compute shaders
+
+Draw -> draw_arrays
+       ! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better
+
+DrawAuto
+       - Gallium lacks stream out and DrawAuto
+
+DrawIndexed -> draw_elements
+       ! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better
+       * may want to add a separate set_index_buffer
+       - Gallium lacks base vertex for indexed draw calls
+       + D3D11 lacks draw_range_elements functionality, which is required for OpenGL
+
+DrawIndexedInstanced -> draw_elements_instanced
+       ! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better
+       * may want to add a separate set_index_buffer
+       - Gallium lacks base vertex for indexed draw calls
+
+DrawIndexedInstancedIndirect (D3D11 only) -> call draw_elements_instanced multiple times in software
+       # this allows to use an hardware buffer to specify the parameters for multiple draw_elements_instanced calls
+       - Gallium does not support draw call parameter buffers and indirect draw
+
+DrawInstanced -> draw_arrays_instanced
+       ! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better
+
+DrawInstancedIndirect (D3D11 only) -> call draw_arrays_instanced multiple times in software
+       # this allows to use an hardware buffer to specify the parameters for multiple draw_arrays_instanced calls
+       - Gallium does not support draw call parameter buffers and indirect draws
+
+DsSetConstantBuffers (D3D11 only)
+DsSetSamplers (D3D11 only)
+DsSetShader (D3D11 only)
+DsSetShaderResources (D3D11 only)
+DsSetShaderWithIfaces (D3D11 only)
+       - Gallium does not support domain shaders
+
+Flush -> flush
+       ! Gallium supports fencing and several kinds of flushing here, D3D11 just has a dumb glFlush-like function
+
+GenMips
+       - Gallium lacks a mipmap generation interface, and does this manually with the 3D engine
+       * it may be useful to add a mipmap generation interface, since the hardware (especially older cards) may have a better way than using the 3D engine
+
+GsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_GEOMETRY, i, phBuffers[i])
+
+GsSetSamplers
+       - Gallium does not support sampling in geometry shaders
+
+GsSetShader -> bind_gs_state
+
+GsSetShaderWithIfaces (D3D11 only)
+       - Gallium does not support shader interfaces
+
+GsSetShaderResources
+       - Gallium does not support sampling in geometry shaders
+
+HsSetConstantBuffers (D3D11 only)
+HsSetSamplers (D3D11 only)
+HsSetShader (D3D11 only)
+HsSetShaderResources (D3D11 only)
+HsSetShaderWithIfaces (D3D11 only)
+       - Gallium does not support hull shaders
+
+IaSetIndexBuffer
+       ! Gallium passes this to the draw_elements or draw_elements_instanced calls
+       + Gallium supports 8-bit indices
+       ! the D3D11 interface allows index-size-unaligned byte offsets into index buffers; it's not clear whether they actually work
+
+IaSetInputLayout -> bind_vertex_elements_state
+
+IaSetTopology
+       ! Gallium passes the topology = primitive type to the draw calls
+       * may want to add an interface for this
+       - Gallium lacks support for DirectX 11 tessellated primitives
+       + Gallium supports line loops, triangle fans, quads, quad strips and polygons
+
+IaSetVertexBuffers -> set_vertex_buffers
+       + Gallium allows to specify a max_index here
+       - Gallium only allows setting all vertex buffers at once, while D3D11 supports setting a subset
+
+OpenResource -> texture_from_handle
+
+PsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_FRAGMENT, i, phBuffers[i])
+       * may want to split into fragment/vertex-specific versions
+
+PsSetSamplers -> bind_fragment_sampler_states
+       * may want to allow binding subsets instead of all at once
+
+PsSetShader -> bind_fs_state
+
+PsSetShaderWithIfaces (D3D11 only)
+       - Gallium does not support shader interfaces
+
+PsSetShaderResources -> set_fragment_sampler_views
+       * may want to allow binding subsets instead of all at once
+
+QueryBegin -> begin_query
+
+QueryEnd -> end_query
+
+QueryGetData -> get_query_result
+       - D3D11 supports reading an arbitrary data chunk for query results, Gallium only supports reading a 64-bit integer
+       + D3D11 doesn't seem to support actually waiting for the query result (?!)
+       - D3D11 supports optionally not flushing command buffers here and instead returning DXGI_DDI_ERR_WASSTILLDRAWING
+
+RecycleCommandList (D3D11 only)
+RecycleCreateCommandList (D3D11 only)
+RecycleDestroyCommandList (D3D11 only)
+       - Gallium does not support command lists
+
+RecycleCreateDeferredContext (D3D11 only)
+       - Gallium does not support deferred contexts
+
+RelocateDeviceFuncs
+       - Gallium does not support moving pipe_context, while D3D11 seems to, using this
+
+ResetPrimitiveID (D3D10.1+ only, #ifdef D3D10PSGP)
+       # used to do vertex processing on the GPU on Intel G45 chipsets when it is faster this way (see www.intel.com/Assets/PDF/whitepaper/322931.pdf)
+       # presumably this resets the primitive id system value
+       - Gallium does not support vertex pipeline bypass anymore
+
+ResourceCopy
+ResourceCopyRegion
+ResourceConvert (D3D10.1+ only)
+ResourceConvertRegion (D3D10.1+ only)
+       -> surface_copy
+       - Gallium does not support hardware buffer copies
+       - Gallium does not support copying 3D texture subregions in a single call
+
+ResourceIsStagingBusy -> is_texture_referenced, is_buffer_referenced
+       - Gallium does not support checking reference for a whole texture, but only a specific surface
+
+ResourceReadAfterWriteHazard
+       ! Gallium specifies hides this, except for the render and texture caches
+
+ResourceResolveSubresource
+       - Gallium does not support multisample sample resolution
+
+ResourceMap
+ResourceUnmap
+DynamicConstantBufferMapDiscard
+DynamicConstantBufferUnmap
+DynamicIABufferMapDiscard
+DynamicIABufferMapNoOverwrite
+DynamicIABufferUnmap
+DynamicResourceMapDiscard
+DynamicResourceUnmap
+StagingResourceMap
+StagingResourceUnmap
+       -> buffer_map / buffer_unmap
+       -> transfer functions
+       ! Gallium and D3D have different semantics for transfers
+       * D3D separates vertex/index buffers from constant buffers
+       ! D3D separates some buffer flags into specialized calls
+
+ResourceUpdateSubresourceUP -> transfer functionality, transfer_inline_write in gallium-resources
+DefaultConstantBufferUpdateSubresourceUP -> transfer functionality, transfer_inline_write in gallium-resources
+
+SetBlendState -> bind_blend_state and set_blend_color
+       ! D3D11 fuses bind_blend_state and set_blend_color in a single function
+       - Gallium lacks the sample mask
+
+SetDepthStencilState -> bind_depth_stencil_alpha_state and set_stencil_ref
+       ! D3D11 fuses bind_depth_stencil_alpha_state and set_stencil_ref in a single function
+
+SetPredication -> render_condition
+       # here both D3D11 and Gallium seem very limited (hardware is too, probably though)
+       # ideally, we should support nested conditional rendering, as well as more complex tests (checking for an arbitrary range, after an AND with arbitrary mask )
+       # of couse, hardware support is probably as limited as OpenGL/D3D11
+       + Gallium, like NV_conditional_render, supports by-region and wait flags
+       - D3D11 supports predication conditional on being equal any value (along with occlusion predicates); Gallium only supports on non-zero
+
+SetRasterizerState -> bind_rasterizer_state
+
+SetRenderTargets (extended in D3D11) -> set_framebuffer_state
+       ! Gallium passed a width/height here, D3D11 does not
+       ! Gallium lacks ClearTargets (but this is redundant and the driver can trivially compute this if desired)
+       - Gallium does not support unordered access views
+       - Gallium does not support geometry shader selection of texture array image / 3D texture zslice
+
+SetResourceMinLOD (D3D11 only)
+       - Gallium does not support min lod directly on textures
+
+SetScissorRects
+       - Gallium lacks support for multiple geometry-shader-selectable scissor rectangles D3D11 has
+
+SetTextFilterSize
+       - Gallium lacks support for text filters
+
+SetVertexPipelineOutput (D3D10.1+ only)
+       # used to do vertex processing on the GPU on Intel G45 chipsets when it is faster this way (see www.intel.com/Assets/PDF/whitepaper/322931.pdf)
+       - Gallium does not support vertex pipeline bypass anymore
+
+SetViewports
+       - Gallium lacks support for multiple geometry-shader-selectable viewports D3D11 has
+
+ShaderResourceViewReadAfterWriteHazard -> flush(PIPE_FLUSH_RENDER_CACHE)
+       - Gallium does not support specifying this per-render-target/view
+
+SoSetTargets
+       - Gallium does not support stream out
+
+VsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_VERTEX, i, phBuffers[i])
+       * may want to split into fragment/vertex-specific versions
+
+VsSetSamplers -> bind_vertex_sampler_states
+       * may want to allow binding subsets instead of all at once
+
+VsSetShader -> bind_vs_state
+
+VsSetShaderWithIfaces (D3D11 only)
+       - Gallium does not support shader interfaces
+
+VsSetShaderResources  -> set_fragment_sampler_views
+       * may want to allow binding subsets instead of all at once
index 4608e97adbb18ee0241bcfab37769bbb6c7c7db7..2b0941010b05c47361786b654051e4c06a3c50d3 100644 (file)
@@ -40,8 +40,7 @@ buffers, surfaces) are bound to the driver.
   are mostly restricted to the first one right now).
 
 * ``set_framebuffer_state``
-* ``set_fragment_sampler_textures``
-* ``set_vertex_sampler_textures``
+
 * ``set_vertex_buffers``
 
 
@@ -51,6 +50,7 @@ Non-CSO State
 These pieces of state are too small, variable, and/or trivial to have CSO
 objects. They all follow simple, one-method binding calls, e.g.
 ``set_blend_color``.
+
 * ``set_stencil_ref`` sets the stencil front and back reference values
   which are used as comparison values in stencil test.
 * ``set_blend_color``
@@ -63,6 +63,41 @@ objects. They all follow simple, one-method binding calls, e.g.
 * ``set_viewport_state``
 
 
+Sampler Views
+^^^^^^^^^^^^^
+
+These are the means to bind textures to shader stages. To create one, specify
+its format, swizzle and LOD range in sampler view template.
+
+If texture format is different than template format, it is said the texture
+is being cast to another format. Casting can be done only between compatible
+formats, that is formats that have matching component order and sizes.
+
+Swizzle fields specify they way in which fetched texel components are placed
+in the result register. For example, ``swizzle_r`` specifies what is going to be
+placed in first component of result register.
+
+The ``first_level`` and ``last_level`` fields of sampler view template specify
+the LOD range the texture is going to be constrained to.
+
+* ``set_fragment_sampler_views`` binds an array of sampler views to
+  fragment shader stage. Every binding point acquires a reference
+  to a respective sampler view and releases a reference to the previous
+  sampler view.
+
+* ``set_vertex_sampler_views`` binds an array of sampler views to vertex
+  shader stage. Every binding point acquires a reference to a respective
+  sampler view and releases a reference to the previous sampler view.
+
+* ``create_sampler_view`` creates a new sampler view. ``texture`` is associated
+  with the sampler view which results in sampler view holding a reference
+  to the texture. Format specified in template must be compatible
+  with texture format.
+
+* ``sampler_view_destroy`` destroys a sampler view and releases its reference
+  to associated texture.
+
+
 Clearing
 ^^^^^^^^
 
index ccd9136a2ebfbea41fede28117d043b0aa3309b4..e8dc82964fae73c3efdc96337bf3377b5650026e 100644 (file)
@@ -7,7 +7,7 @@ The rasterizer state controls the rendering of points, lines and triangles.
 Attributes include polygon culling state, line width, line stipple,
 multisample state, scissoring and flat/smooth shading.
 
-Members
+Shading
 -------
 
 flatshade
@@ -46,6 +46,49 @@ There are several important exceptions to the specification of this rule.
   second vertex, not the first. This permits each segment of the fan to have
   a different color.
 
+Points
+------
+
+sprite_coord_enable
+^^^^^^^^^^^^^^^^^^^
+
+Specifies if a texture unit has its texture coordinates replaced or not. This
+is a packed bitfield containing the enable for all texcoords -- if all bits
+are zero, point sprites are effectively disabled. If any bit is set, then
+point_smooth and point_quad_rasterization are ignored; point smoothing is
+disabled and points are always rasterized as quads. If enabled, the four
+vertices of the resulting quad will be assigned texture coordinates,
+according to sprite_coord_mode.
+
+sprite_coord_mode
+^^^^^^^^^^^^^^^^^
+
+Specifies how the value for each shader output should be computed when drawing
+point sprites. For PIPE_SPRITE_COORD_LOWER_LEFT, the lower-left vertex will
+have coordinates (0,0,0,1). For PIPE_SPRITE_COORD_UPPER_LEFT, the upper-left
+vertex will have coordinates (0,0,0,1).
+This state is used by :ref:`Draw` to generate texcoords.
+
+.. note::
+
+    When geometry shaders are available, a special geometry shader could be
+    used instead of this functionality, to convert incoming points into quads
+    with the proper texture coordinates.
+
+point_quad_rasterization
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Determines if points should be rasterized as quads or points. Certain APIs,
+like Direct3D, always use quad rasterization for points, regardless of
+whether point sprites are enabled or not. If this state is enabled, point
+smoothing and antialiasing are disabled, and sprite coordinates are not
+generated.
+
+.. note::
+
+   Some renderers always internally translate points into quads; this state
+   still affects those renderers by overriding other rasterization state.
+
 Other Members
 ^^^^^^^^^^^^^
 
@@ -107,37 +150,6 @@ point_size_per_vertex
     Whether vertices have a point size element.
 point_size
     The size of points, if not specified per-vertex.
-sprite_coord_enable
-    Specifies if a coord has its texture coordinates replaced or not. This
-    is a packed bitfield containing the enable for all coords - if all are 0
-    point sprites are effectively disabled, though points may still be
-    rendered slightly different according to point_quad_rasterization.
-    If any coord is non-zero, point_smooth should be disabled, and
-    point_quad_rasterization enabled.
-    If enabled, the four vertices of the resulting quad will be assigned
-    texture coordinates, according to sprite_coord_mode.
-sprite_coord_mode
-    Specifies how the value for each shader output should be computed when
-    drawing sprites, for each coord which has sprite_coord_enable set.
-    For PIPE_SPRITE_COORD_LOWER_LEFT, the lower left vertex will have
-    coordinate (0,0,0,1).
-    For PIPE_SPRITE_COORD_UPPER_LEFT, the upper-left vertex will have
-    coordinate (0,0,0,1).
-    This state is needed by :ref:`Draw` because that's where each
-    point vertex is converted into four quad vertices.  There's no other
-    place to emit the new vertex texture coordinates which are required for
-    sprite rendering.
-    Note that when geometry shaders are available, this state could be
-    removed.  A special geometry shader defined by the state tracker could
-    convert the incoming points into quads with the proper texture coords.
-point_quad_rasterization
-    This determines if points should be rasterized as quads or points.
-    d3d always uses quad rasterization for points, regardless if point sprites
-    are enabled or not, but OGL has different rules. If point_quad_rasterization
-    is set, point_smooth should be disabled, and points will be rendered as
-    squares even if multisample is enabled.
-    sprite_coord_enable should be zero if point_quad_rasterization is not
-    enabled.
 
 scissor
     Whether the scissor test is enabled.
index 8e758fae1033aa55d55b23aee10923acd1a1562f..92cde014fb8c8d726b374b174805ad5c1efda8bc 100644 (file)
@@ -1,4 +1,4 @@
-.. _vertex,elements
+.. _vertexelements:
 
 Vertex Elements
 ===============
index 28f80b82cd590d3336ff5274066e9c780c5a093f..f7e2284445d5879b6439c0a7e0baba5254c6c37c 100644 (file)
@@ -97,7 +97,7 @@ struct cell_velems_state
 {
    unsigned count;
    struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
-}
+};
 
 /**
  * Per-context state, subclass of pipe_context.
@@ -127,6 +127,7 @@ struct cell_context
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
    struct cell_texture *texture[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
    uint num_textures;
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
index dce10ae7f863c0a4e2c83e1c66afe0a51d43b1af..059ce8597bcf9883fd4a26564d803a4b1d81eb9e 100644 (file)
@@ -257,8 +257,9 @@ cell_delete_sampler_state(struct pipe_context *pipe,
 
 
 static void
-cell_set_sampler_textures(struct pipe_context *pipe,
-                          unsigned num, struct pipe_texture **texture)
+cell_set_fragment_sampler_views(struct pipe_context *pipe,
+                                unsigned num,
+                                struct pipe_sampler_view **views)
 {
    struct cell_context *cell = cell_context(pipe);
    uint i, changed = 0x0;
@@ -266,10 +267,14 @@ cell_set_sampler_textures(struct pipe_context *pipe,
    assert(num <= CELL_MAX_SAMPLERS);
 
    for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
-      struct cell_texture *new_tex = cell_texture(i < num ? texture[i] : NULL);
-      struct cell_texture *old_tex = cell->texture[i];
-      if (old_tex != new_tex) {
+      struct pipe_sampler_view *new_view = i < num ? views[i] : NULL;
+      struct pipe_sampler_view *old_view = cell->fragment_sampler_views[i];
 
+      if (old_view != new_view) {
+         struct pipe_texture *new_tex = new_view ? new_view->texture : NULL;
+
+         pipe_sampler_view_reference(&cell->fragment_sampler_views[i],
+                                     views[i]);
          pipe_texture_reference((struct pipe_texture **) &cell->texture[i],
                                 (struct pipe_texture *) new_tex);
 
@@ -286,6 +291,34 @@ cell_set_sampler_textures(struct pipe_context *pipe,
 }
 
 
+static struct pipe_sampler_view *
+cell_create_sampler_view(struct pipe_context *pipe,
+                         struct pipe_texture *texture,
+                         const struct pipe_sampler_view *templ)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
+
+   return view;
+}
+
+
+static void
+cell_sampler_view_destroy(struct pipe_context *pipe,
+                          struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
+}
+
+
 /**
  * Map color and z/stencil framebuffer surfaces.
  */
@@ -409,7 +442,9 @@ cell_init_state_functions(struct cell_context *cell)
    cell->pipe.bind_fragment_sampler_states = cell_bind_sampler_states;
    cell->pipe.delete_sampler_state = cell_delete_sampler_state;
 
-   cell->pipe.set_fragment_sampler_textures = cell_set_sampler_textures;
+   cell->pipe.set_fragment_sampler_views = cell_set_fragment_sampler_views;
+   cell->pipe.create_sampler_view = cell_create_sampler_view;
+   cell->pipe.sampler_view_destroy = cell_sampler_view_destroy;
 
    cell->pipe.create_depth_stencil_alpha_state = cell_create_depth_stencil_alpha_state;
    cell->pipe.bind_depth_stencil_alpha_state   = cell_bind_depth_stencil_alpha_state;
index 31fd963d19a15f9d9ce9c4eac0391cf6f8fd559c..42045744060a09f420f6b0e09c7f3286c87e2f8d 100644 (file)
@@ -97,6 +97,8 @@ cell_get_param(struct pipe_screen *screen, int param)
    case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
    case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
       return 0;
+   case PIPE_CAP_BLEND_EQUATION_SEPARATE:
+      return 1;
    default:
       return 0;
    }
@@ -136,20 +138,23 @@ cell_is_format_supported( struct pipe_screen *screen,
                           unsigned tex_usage, 
                           unsigned geom_flags )
 {
-   struct sw_winsys *winsys = cell_screen(screen)->winsys;
-
-   if (format == PIPE_FORMAT_DXT5_RGBA ||
-       format == PIPE_FORMAT_A8B8G8R8_SRGB)
-      return FALSE;
-
-   if (tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
-      if (!winsys->is_displaytarget_format_supported(winsys, format))
+   if (tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                    PIPE_TEXTURE_USAGE_SCANOUT |
+                    PIPE_TEXTURE_USAGE_SHARED)) {
+      if (!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
          return FALSE;
    }
 
-   /* This is often a lie.  Pull in logic from llvmpipe to fix.
-    */
-   return TRUE;
+   /* only a few formats are known to work at this time */
+   switch (format) {
+   case PIPE_FORMAT_Z24S8_UNORM:
+   case PIPE_FORMAT_Z24X8_UNORM:
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
+   case PIPE_FORMAT_I8_UNORM:
+      return TRUE;
+   default:
+      return FALSE;
+   }
 }
 
 
index c65c3b4f88522bb6c211470c83362439947f3578..5b169afaf88005ea6541f253c16ec67277cf1ec2 100644 (file)
@@ -105,6 +105,7 @@ cell_displaytarget_layout(struct pipe_screen *screen,
    /* Round up the surface size to a multiple of the tile size?
     */
    ct->dt = winsys->displaytarget_create(winsys,
+                                          ct->base->tex_usage,
                                           ct->base.format,
                                           ct->base.width0, 
                                           ct->base.height0,
index 4a754465bbe9f88e8930e072cafde99a49ce8a1c..73031321d98d00360dd103a32e0bf02db83d17e2 100644 (file)
@@ -47,7 +47,7 @@
 #define FO_NEW_ALPHA_TEST      0x100
 #define FO_NEW_DEPTH_STENCIL   0x200
 #define FO_NEW_SAMPLER         0x400
-#define FO_NEW_TEXTURE         0x800
+#define FO_NEW_SAMPLER_VIEW    0x800
 #define FO_NEW_VERTEX          0x2000
 #define FO_NEW_VERTEX_SHADER   0x4000
 #define FO_NEW_BLEND_COLOR     0x8000
@@ -65,6 +65,13 @@ struct fo_state {
    void *sw_state;
    void *hw_state;
 };
+
+struct fo_sampler_view {
+   struct pipe_sampler_view base;
+   struct pipe_sampler_view *sw;
+   struct pipe_sampler_view *hw;
+};
+
 struct failover_context {
    struct pipe_context pipe;  /**< base class */
 
@@ -86,8 +93,6 @@ struct failover_context {
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
 
@@ -98,12 +103,15 @@ struct failover_context {
    void *sw_vertex_sampler_state[PIPE_MAX_VERTEX_SAMPLERS];
    void *hw_vertex_sampler_state[PIPE_MAX_VERTEX_SAMPLERS];
 
+   struct fo_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
+   struct fo_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
+   unsigned num_fragment_sampler_views;
+   unsigned num_vertex_sampler_views;
+
    unsigned dirty;
 
    unsigned num_samplers;
    unsigned num_vertex_samplers;
-   unsigned num_textures;
-   unsigned num_vertex_textures;
 
    unsigned mode;
    struct pipe_context *hw;
index 0247fb803b297baa6d12b8d9f8ca894b72cd5c1d..25c6273570520ee98e434be680e51efb7de38e0e 100644 (file)
@@ -447,60 +447,96 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler)
 }
 
 
+static struct pipe_sampler_view *
+failover_create_sampler_view(struct pipe_context *pipe,
+                             struct pipe_texture *texture,
+                             const struct pipe_sampler_view *templ)
+{
+   struct fo_sampler_view *view = malloc(sizeof(struct fo_sampler_view));
+   struct failover_context *failover = failover_context(pipe);
+
+   view->sw = failover->sw->create_sampler_view(failover->sw, texture, templ);
+   view->hw = failover->hw->create_sampler_view(failover->hw, texture, templ);
+
+   view->base = *templ;
+   view->base.reference.count = 1;
+   view->base.texture = NULL;
+   pipe_texture_reference(&view->base.texture, texture);
+   view->base.context = pipe;
+
+   return &view->base;
+}
+
+static void
+failover_sampler_view_destroy(struct pipe_context *pipe,
+                              struct pipe_sampler_view *view)
+{
+   struct fo_sampler_view *fo_view = (struct fo_sampler_view *)view;
+   struct failover_context *failover = failover_context(pipe);
+
+   failover->sw->sampler_view_destroy(failover->sw, fo_view->sw);
+   failover->hw->sampler_view_destroy(failover->hw, fo_view->hw);
+
+   pipe_texture_reference(&fo_view->base.texture, NULL);
+   free(fo_view);
+}
+
 static void
-failover_set_fragment_sampler_textures(struct pipe_context *pipe,
-                                       unsigned num,
-                                       struct pipe_texture **texture)
+failover_set_fragment_sampler_views(struct pipe_context *pipe,
+                                    unsigned num,
+                                    struct pipe_sampler_view **views)
 {
    struct failover_context *failover = failover_context(pipe);
+   struct pipe_sampler_view *hw_views[PIPE_MAX_SAMPLERS];
    uint i;
 
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == failover->num_textures &&
-       !memcmp(failover->texture, texture, num * sizeof(struct pipe_texture *)))
+   if (num == failover->num_fragment_sampler_views &&
+       !memcmp(failover->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
       return;
-   for (i = 0; i < num; i++)
-      pipe_texture_reference((struct pipe_texture **) &failover->texture[i],
-                             texture[i]);
-   for (i = num; i < failover->num_textures; i++)
-      pipe_texture_reference((struct pipe_texture **) &failover->texture[i],
-                             NULL);
-   failover->dirty |= FO_NEW_TEXTURE;
-   failover->num_textures = num;
-   failover->sw->set_fragment_sampler_textures( failover->sw, num, texture );
-   failover->hw->set_fragment_sampler_textures( failover->hw, num, texture );
+   for (i = 0; i < num; i++) {
+      struct fo_sampler_view *fo_view = (struct fo_sampler_view *)views[i];
+
+      pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->fragment_sampler_views[i], views[i]);
+      hw_views[i] = fo_view->hw;
+   }
+   for (i = num; i < failover->num_fragment_sampler_views; i++)
+      pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->fragment_sampler_views[i], NULL);
+   failover->dirty |= FO_NEW_SAMPLER_VIEW;
+   failover->num_fragment_sampler_views = num;
+   failover->hw->set_fragment_sampler_views(failover->hw, num, hw_views);
 }
 
 
 static void
-failover_set_vertex_sampler_textures(struct pipe_context *pipe,
-                                     unsigned num_textures,
-                                     struct pipe_texture **textures)
+failover_set_vertex_sampler_views(struct pipe_context *pipe,
+                                  unsigned num,
+                                  struct pipe_sampler_view **views)
 {
    struct failover_context *failover = failover_context(pipe);
+   struct pipe_sampler_view *hw_views[PIPE_MAX_VERTEX_SAMPLERS];
    uint i;
 
-   assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS);
+   assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
 
    /* Check for no-op */
-   if (num_textures == failover->num_vertex_textures &&
-       !memcmp(failover->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) {
+   if (num == failover->num_vertex_sampler_views &&
+       !memcmp(failover->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
       return;
    }
-   for (i = 0; i < num_textures; i++) {
-      pipe_texture_reference((struct pipe_texture **)&failover->vertex_textures[i],
-                             textures[i]);
-   }
-   for (i = num_textures; i < failover->num_vertex_textures; i++) {
-      pipe_texture_reference((struct pipe_texture **)&failover->vertex_textures[i],
-                             NULL);
+   for (i = 0; i < num; i++) {
+      struct fo_sampler_view *fo_view = (struct fo_sampler_view *)views[i];
+
+      pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], views[i]);
+      hw_views[i] = fo_view->hw;
    }
-   failover->dirty |= FO_NEW_TEXTURE;
-   failover->num_vertex_textures = num_textures;
-   failover->sw->set_vertex_sampler_textures(failover->sw, num_textures, textures);
-   failover->hw->set_vertex_sampler_textures(failover->hw, num_textures, textures);
+   for (i = num; i < failover->num_vertex_sampler_views; i++)
+      pipe_sampler_view_reference((struct pipe_sampler_view **)&failover->vertex_sampler_views[i], NULL);
+   failover->dirty |= FO_NEW_SAMPLER_VIEW;
+   failover->num_vertex_sampler_views = num;
+   failover->hw->set_vertex_sampler_views(failover->hw, num, hw_views);
 }
 
 
@@ -580,9 +616,11 @@ failover_init_state_functions( struct failover_context *failover )
    failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
    failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
    failover->pipe.set_scissor_state = failover_set_scissor_state;
-   failover->pipe.set_fragment_sampler_textures = failover_set_fragment_sampler_textures;
-   failover->pipe.set_vertex_sampler_textures = failover_set_vertex_sampler_textures;
+   failover->pipe.set_fragment_sampler_views = failover_set_fragment_sampler_views;
+   failover->pipe.set_vertex_sampler_views = failover_set_vertex_sampler_views;
    failover->pipe.set_viewport_state = failover_set_viewport_state;
    failover->pipe.set_vertex_buffers = failover_set_vertex_buffers;
    failover->pipe.set_constant_buffer = failover_set_constant_buffer;
+   failover->pipe.create_sampler_view = failover_create_sampler_view;
+   failover->pipe.sampler_view_destroy = failover_sampler_view_destroy;
 }
index 09ca19449713229a997072a7e82636b4fcd5b950..42bd6929a7fbe3433d66d9cbc31a28a589148b3c 100644 (file)
@@ -106,12 +106,24 @@ failover_state_emit( struct failover_context *failover )
                                                failover->sw_vertex_sampler_state);
    }
 
-   if (failover->dirty & FO_NEW_TEXTURE) {
-      failover->sw->set_fragment_sampler_textures( failover->sw, failover->num_textures, 
-                                                   failover->texture );
-      failover->sw->set_vertex_sampler_textures(failover->sw,
-                                                failover->num_vertex_textures, 
-                                                failover->vertex_textures);
+   if (failover->dirty & FO_NEW_SAMPLER_VIEW) {
+      struct pipe_sampler_view *fragment_views[PIPE_MAX_SAMPLERS];
+      struct pipe_sampler_view *vertex_views[PIPE_MAX_VERTEX_SAMPLERS];
+      uint i;
+
+      for (i = 0; i < failover->num_fragment_sampler_views; i++) {
+         fragment_views[i] = failover->fragment_sampler_views[i]->sw;
+      }
+      failover->sw->set_fragment_sampler_views(failover->sw,
+                                               failover->num_fragment_sampler_views,
+                                               fragment_views);
+
+      for (i = 0; i < failover->num_vertex_sampler_views; i++) {
+         vertex_views[i] = failover->vertex_sampler_views[i]->sw;
+      }
+      failover->sw->set_vertex_sampler_views(failover->sw,
+                                             failover->num_vertex_sampler_views,
+                                             vertex_views);
    }
 
    if (failover->dirty & FO_NEW_VERTEX_BUFFER) {
index b813784723fc7d00e096a28fbd2a81421b388f32..f0086695d16f5cde235c71885f0c8d1885574d4b 100644 (file)
 #ifndef I915_BATCH_H
 #define I915_BATCH_H
 
-#include "intel_batchbuffer.h"
+#include "i915_batchbuffer.h"
 
 #define BEGIN_BATCH(dwords, relocs) \
-   (intel_batchbuffer_check(i915->batch, dwords, relocs))
+   (i915_winsys_batchbuffer_check(i915->batch, dwords, relocs))
 
 #define OUT_BATCH(dword) \
-   intel_batchbuffer_dword(i915->batch, dword)
+   i915_winsys_batchbuffer_dword(i915->batch, dword)
 
 #define OUT_RELOC(buf, usage, offset) \
-   intel_batchbuffer_reloc(i915->batch, buf, usage, offset)
+   i915_winsys_batchbuffer_reloc(i915->batch, buf, usage, offset)
 
 #define FLUSH_BATCH(fence) do {                 \
-   intel_batchbuffer_flush(i915->batch, fence); \
+   i915_winsys_batchbuffer_flush(i915->batch, fence); \
    i915->hardware_dirty = ~0;                   \
 } while (0)
 
diff --git a/src/gallium/drivers/i915/i915_batchbuffer.h b/src/gallium/drivers/i915/i915_batchbuffer.h
new file mode 100644 (file)
index 0000000..27ccaa6
--- /dev/null
@@ -0,0 +1,87 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef I915_BATCHBUFFER_H
+#define I915_BATCHBUFFER_H
+
+#include "i915_winsys.h"
+
+static INLINE boolean
+i915_winsys_batchbuffer_check(struct i915_winsys_batchbuffer *batch,
+                              size_t dwords,
+                              size_t relocs)
+{
+   return dwords * 4 <= batch->size - (batch->ptr - batch->map) &&
+          relocs <= (batch->max_relocs - batch->relocs);
+}
+
+static INLINE size_t
+i915_winsys_batchbuffer_space(struct i915_winsys_batchbuffer *batch)
+{
+   return batch->size - (batch->ptr - batch->map);
+}
+
+static INLINE void
+i915_winsys_batchbuffer_dword(struct i915_winsys_batchbuffer *batch,
+                              unsigned dword)
+{
+   if (i915_winsys_batchbuffer_space(batch) < 4)
+      return;
+
+   *(unsigned *)batch->ptr = dword;
+   batch->ptr += 4;
+}
+
+static INLINE void
+i915_winsys_batchbuffer_write(struct i915_winsys_batchbuffer *batch,
+                       void *data,
+                       size_t size)
+{
+   if (i915_winsys_batchbuffer_space(batch) < size)
+      return;
+
+   memcpy(data, batch->ptr, size);
+   batch->ptr += size;
+}
+
+static INLINE int
+i915_winsys_batchbuffer_reloc(struct i915_winsys_batchbuffer *batch,
+                              struct i915_winsys_buffer *buffer,
+                              enum i915_winsys_buffer_usage usage,
+                              size_t offset)
+{
+   return batch->iws->batchbuffer_reloc(batch, buffer, usage, offset);
+}
+
+static INLINE void
+i915_winsys_batchbuffer_flush(struct i915_winsys_batchbuffer *batch,
+                              struct pipe_fence_handle **fence)
+{
+   batch->iws->batchbuffer_flush(batch, fence);
+}
+
+#endif
index 83dfc3352881d6dc5dcb01d0c6b6d5585c6c6bb1..533fa81219b062d9158f9ee4c50020807867b172 100644 (file)
@@ -37,7 +37,7 @@ void
 i915_fill_blit(struct i915_context *i915,
                unsigned cpp,
                unsigned short dst_pitch,
-               struct intel_buffer *dst_buffer,
+               struct i915_winsys_buffer *dst_buffer,
                unsigned dst_offset,
                short x, short y, 
                short w, short h, 
@@ -77,7 +77,7 @@ i915_fill_blit(struct i915_context *i915,
    OUT_BATCH(BR13);
    OUT_BATCH((y << 16) | x);
    OUT_BATCH(((y + h) << 16) | (x + w));
-   OUT_RELOC(dst_buffer, INTEL_USAGE_2D_TARGET, dst_offset);
+   OUT_RELOC(dst_buffer, I915_USAGE_2D_TARGET, dst_offset);
    OUT_BATCH(color);
    FLUSH_BATCH(NULL);
 }
@@ -87,10 +87,10 @@ i915_copy_blit(struct i915_context *i915,
                unsigned do_flip,
                unsigned cpp,
                unsigned short src_pitch,
-               struct intel_buffer *src_buffer,
+               struct i915_winsys_buffer *src_buffer,
                unsigned src_offset,
                unsigned short dst_pitch,
-               struct intel_buffer *dst_buffer,
+               struct i915_winsys_buffer *dst_buffer,
                unsigned dst_offset,
                short src_x, short src_y,
                short dst_x, short dst_y, 
@@ -143,9 +143,9 @@ i915_copy_blit(struct i915_context *i915,
    OUT_BATCH(BR13);
    OUT_BATCH((dst_y << 16) | dst_x);
    OUT_BATCH((dst_y2 << 16) | dst_x2);
-   OUT_RELOC(dst_buffer, INTEL_USAGE_2D_TARGET, dst_offset);
+   OUT_RELOC(dst_buffer, I915_USAGE_2D_TARGET, dst_offset);
    OUT_BATCH((src_y << 16) | src_x);
    OUT_BATCH(((int) src_pitch & 0xffff));
-   OUT_RELOC(src_buffer, INTEL_USAGE_2D_SOURCE, src_offset);
+   OUT_RELOC(src_buffer, I915_USAGE_2D_SOURCE, src_offset);
    FLUSH_BATCH(NULL);
 }
index 8ce3220cfd9cb8a8881ab5645a9018f06bd2818d..db576ed4c901564714bf55b6c1653ca9bdedb5c0 100644 (file)
@@ -34,10 +34,10 @@ extern void i915_copy_blit(struct i915_context *i915,
                            unsigned do_flip,
                            unsigned cpp,
                            unsigned short src_pitch,
-                           struct intel_buffer *src_buffer,
+                           struct i915_winsys_buffer *src_buffer,
                            unsigned src_offset,
                            unsigned short dst_pitch,
-                           struct intel_buffer *dst_buffer,
+                           struct i915_winsys_buffer *dst_buffer,
                            unsigned dst_offset,
                            short srcx, short srcy,
                            short dstx, short dsty,
@@ -46,7 +46,7 @@ extern void i915_copy_blit(struct i915_context *i915,
 extern void i915_fill_blit(struct i915_context *i915,
                            unsigned cpp,
                            unsigned short dst_pitch,
-                           struct intel_buffer *dst_buffer,
+                           struct i915_winsys_buffer *dst_buffer,
                            unsigned dst_offset,
                            short x, short y,
                            short w, short h, unsigned color);
index 0f76a59e93aff69bf777bfcba7d17f519b0092e6..1247de320d456d7ef171a0f61032583ca86d84a8 100644 (file)
 #include "i915_screen.h"
 #include "i915_buffer.h"
 
-struct intel_buffer;
+struct i915_winsys_buffer;
 
 struct i915_buffer
 {
    struct pipe_buffer base;
 
-   struct intel_buffer *ibuf; /** hw buffer */
+   struct i915_winsys_buffer *ibuf; /** hw buffer */
 
    void *data; /**< user and malloc data */
    boolean own; /**< we own the data incase of malloc */
index 039165b63f53506517dcb9e3558be0169ea0f407..8df4dce86538c614a543039cb0084af5c7b5a43b 100644 (file)
@@ -38,9 +38,9 @@
 #include "tgsi/tgsi_scan.h"
 
 
-struct intel_winsys;
-struct intel_buffer;
-struct intel_batchbuffer;
+struct i915_winsys;
+struct i915_winsys_buffer;
+struct i915_winsys_batchbuffer;
 
 
 #define I915_TEX_UNITS 8
@@ -219,14 +219,14 @@ struct i915_texture {
 
    /* The data is held here:
     */
-   struct intel_buffer *buffer;
+   struct i915_winsys_buffer *buffer;
 };
 
 struct i915_context
 {
    struct pipe_context base;
 
-   struct intel_winsys *iws;
+   struct i915_winsys *iws;
 
    struct draw_context *draw;
 
@@ -247,20 +247,20 @@ struct i915_context
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   struct i915_texture *texture[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
 
    unsigned dirty;
 
    unsigned num_samplers;
-   unsigned num_textures;
+   unsigned num_fragment_sampler_views;
    unsigned num_vertex_buffers;
 
-   struct intel_batchbuffer *batch;
+   struct i915_winsys_batchbuffer *batch;
 
    /** Vertex buffer */
-   struct intel_buffer *vbo;
+   struct i915_winsys_buffer *vbo;
    size_t vbo_offset;
    unsigned vbo_flushed;
 
@@ -283,7 +283,7 @@ struct i915_context
 #define I915_NEW_ALPHA_TEST    0x100
 #define I915_NEW_DEPTH_STENCIL 0x200
 #define I915_NEW_SAMPLER       0x400
-#define I915_NEW_TEXTURE       0x800
+#define I915_NEW_SAMPLER_VIEW  0x800
 #define I915_NEW_CONSTANTS     0x1000
 #define I915_NEW_VBO           0x2000
 #define I915_NEW_VS            0x4000
index 237654d26b2ec9e67656cbcc1306dd07356b8d15..663fac3055cf2c100724b29f8abb216345d4e27e 100644 (file)
@@ -863,7 +863,7 @@ static boolean i915_debug_packet( struct debug_stream *stream )
 
 
 void
-i915_dump_batchbuffer( struct intel_batchbuffer *batch )
+i915_dump_batchbuffer( struct i915_winsys_batchbuffer *batch )
 {
    struct debug_stream stream;
    unsigned *start = (unsigned*)batch->map;
index 8f7484797de749f0d3f7bf40e821ade18ee7fa3a..67b8d9c2f6316ff9acf2424260e789a574d32866 100644 (file)
@@ -104,9 +104,9 @@ I915_DBG(
 #endif
 
 
-struct intel_batchbuffer;
+struct i915_winsys_batchbuffer;
 
-void i915_dump_batchbuffer( struct intel_batchbuffer *i915 );
+void i915_dump_batchbuffer( struct i915_winsys_batchbuffer *i915 );
 
 void i915_debug_init( struct i915_context *i915 );
 
index d9a5c40ab9785fd900e56e3b5d81ccde67a27a1f..dd997e2cf482905cfeccc49eb9e978436e2078d2 100644 (file)
@@ -102,6 +102,13 @@ emit_hw_vertex( struct i915_context *i915,
          count += 4;
          break;
       case EMIT_4UB:
+         OUT_BATCH( pack_ub4(float_to_ubyte( attrib[0] ),
+                             float_to_ubyte( attrib[1] ),
+                             float_to_ubyte( attrib[2] ),
+                             float_to_ubyte( attrib[3] )) );
+         count += 1;
+         break;
+      case EMIT_4UB_BGRA:
          OUT_BATCH( pack_ub4(float_to_ubyte( attrib[2] ),
                              float_to_ubyte( attrib[1] ),
                              float_to_ubyte( attrib[0] ),
index cad4109ee6b1816b68d7e7b0752f31b62442edc3..df9e68af4fcd4fb882b885ddfb86b99250449315 100644 (file)
@@ -76,7 +76,7 @@ struct i915_vbuf_render {
    unsigned fallback;
 
    /* Stuff for the vbo */
-   struct intel_buffer *vbo;
+   struct i915_winsys_buffer *vbo;
    size_t vbo_size; /**< current size of allocated buffer */
    size_t vbo_alloc_size; /**< minimum buffer size to allocate */
    size_t vbo_offset;
@@ -141,7 +141,7 @@ static void
 i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size)
 {
    struct i915_context *i915 = i915_render->i915;
-   struct intel_winsys *iws = i915->iws;
+   struct i915_winsys *iws = i915->iws;
 
    if (i915_render->vbo) {
 #ifdef VBUF_USE_FIFO
@@ -172,7 +172,7 @@ i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size)
    if (i915_render->vbo_size != i915_render->pool_buffer_size) {
       i915_render->pool_not_used = TRUE;
       i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
-            INTEL_NEW_VERTEX);
+            I915_NEW_VERTEX);
    } else {
       i915_render->pool_not_used = FALSE;
 
@@ -185,7 +185,7 @@ i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size)
    }
 #else
    i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size,
-                                         64, INTEL_NEW_VERTEX);
+                                         64, I915_NEW_VERTEX);
 #endif
 }
 
@@ -225,7 +225,7 @@ i915_vbuf_render_map_vertices(struct vbuf_render *render)
 {
    struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
    struct i915_context *i915 = i915_render->i915;
-   struct intel_winsys *iws = i915->iws;
+   struct i915_winsys *iws = i915->iws;
 
    if (i915->vbo_flushed)
       debug_printf("%s bad vbo flush occured stalling on hw\n", __FUNCTION__);
@@ -246,7 +246,7 @@ i915_vbuf_render_unmap_vertices(struct vbuf_render *render,
 {
    struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
    struct i915_context *i915 = i915_render->i915;
-   struct intel_winsys *iws = i915->iws;
+   struct i915_winsys *iws = i915->iws;
 
    i915_render->vbo_max_used = MAX2(i915_render->vbo_max_used, i915_render->vertex_size * (max_index + 1));
 #ifdef VBUF_MAP_BUFFER
@@ -621,7 +621,7 @@ static struct vbuf_render *
 i915_vbuf_render_create(struct i915_context *i915)
 {
    struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render);
-   struct intel_winsys *iws = i915->iws;
+   struct i915_winsys *iws = i915->iws;
    int i;
 
    i915_render->i915 = i915;
@@ -662,7 +662,7 @@ i915_vbuf_render_create(struct i915_context *i915)
    for (i = 0; i < 6; i++)
       u_fifo_add(i915_render->pool_fifo,
                  iws->buffer_create(iws, i915_render->pool_buffer_size, 64,
-                                    INTEL_NEW_VERTEX));
+                                    I915_NEW_VERTEX));
 #else
    (void)i;
    (void)iws;
index e5bf4a20bd0e97f7b0f1c996371fae52fb63ac2d..53ef6e50f6c9ea373b7a619fba01408c5222fa60 100644 (file)
@@ -35,7 +35,7 @@
 #include "i915_screen.h"
 #include "i915_buffer.h"
 #include "i915_texture.h"
-#include "intel_winsys.h"
+#include "i915_winsys.h"
 
 
 /*
@@ -165,8 +165,12 @@ i915_is_format_supported(struct pipe_screen *screen,
                          unsigned geom_flags)
 {
    static const enum pipe_format tex_supported[] = {
-      PIPE_FORMAT_A8B8G8R8_UNORM,
       PIPE_FORMAT_B8G8R8A8_UNORM,
+      PIPE_FORMAT_B8G8R8X8_UNORM,
+      PIPE_FORMAT_R8G8B8A8_UNORM,
+#if 0
+      PIPE_FORMAT_R8G8B8X8_UNORM,
+#endif
       PIPE_FORMAT_B5G6R5_UNORM,
       PIPE_FORMAT_L8_UNORM,
       PIPE_FORMAT_A8_UNORM,
@@ -256,7 +260,7 @@ i915_destroy_screen(struct pipe_screen *screen)
  * Create a new i915_screen object
  */
 struct pipe_screen *
-i915_create_screen(struct intel_winsys *iws, uint pci_id)
+i915_create_screen(struct i915_winsys *iws, uint pci_id)
 {
    struct i915_screen *is = CALLOC_STRUCT(i915_screen);
 
index 5126485caa7ec367bf192a521ebefc51b1092393..7f9e02fc0f6eb444a457808f792e1edf367c1654 100644 (file)
@@ -32,7 +32,7 @@
 #include "pipe/p_screen.h"
 
 
-struct intel_winsys;
+struct i915_winsys;
 
 
 /**
@@ -42,7 +42,7 @@ struct i915_screen
 {
    struct pipe_screen base;
 
-   struct intel_winsys *iws;
+   struct i915_winsys *iws;
 
    boolean is_i945;
    uint pci_id;
index 377d8425a5cb11238969c7fe30ed63b76fddff78..0f7395246cce356cead9945a5093828ff9829847 100644 (file)
@@ -560,9 +560,9 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
 }
 
 
-static void i915_set_sampler_textures(struct pipe_context *pipe,
-                                      unsigned num,
-                                      struct pipe_texture **texture)
+static void i915_set_fragment_sampler_views(struct pipe_context *pipe,
+                                            unsigned num,
+                                            struct pipe_sampler_view **views)
 {
    struct i915_context *i915 = i915_context(pipe);
    uint i;
@@ -570,27 +570,54 @@ static void i915_set_sampler_textures(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == i915->num_textures &&
-       !memcmp(i915->texture, texture, num * sizeof(struct pipe_texture *)))
+   if (num == i915->num_fragment_sampler_views &&
+       !memcmp(i915->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
       return;
 
    /* Fixes wrong texture in texobj with VBUF */
    draw_flush(i915->draw);
 
    for (i = 0; i < num; i++)
-      pipe_texture_reference((struct pipe_texture **) &i915->texture[i],
-                             texture[i]);
+      pipe_sampler_view_reference(&i915->fragment_sampler_views[i],
+                                  views[i]);
 
-   for (i = num; i < i915->num_textures; i++)
-      pipe_texture_reference((struct pipe_texture **) &i915->texture[i],
-                             NULL);
+   for (i = num; i < i915->num_fragment_sampler_views; i++)
+      pipe_sampler_view_reference(&i915->fragment_sampler_views[i],
+                                  NULL);
 
-   i915->num_textures = num;
+   i915->num_fragment_sampler_views = num;
 
-   i915->dirty |= I915_NEW_TEXTURE;
+   i915->dirty |= I915_NEW_SAMPLER_VIEW;
 }
 
 
+static struct pipe_sampler_view *
+i915_create_sampler_view(struct pipe_context *pipe,
+                         struct pipe_texture *texture,
+                         const struct pipe_sampler_view *templ)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
+
+   return view;
+}
+
+
+static void
+i915_sampler_view_destroy(struct pipe_context *pipe,
+                          struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
+}
+
 
 static void i915_set_framebuffer_state(struct pipe_context *pipe,
                                       const struct pipe_framebuffer_state *fb)
@@ -818,7 +845,9 @@ i915_init_state_functions( struct i915_context *i915 )
 
    i915->base.set_polygon_stipple = i915_set_polygon_stipple;
    i915->base.set_scissor_state = i915_set_scissor_state;
-   i915->base.set_fragment_sampler_textures = i915_set_sampler_textures;
+   i915->base.set_fragment_sampler_views = i915_set_fragment_sampler_views;
+   i915->base.create_sampler_view = i915_create_sampler_view;
+   i915->base.sampler_view_destroy = i915_sampler_view_destroy;
    i915->base.set_viewport_state = i915_set_viewport_state;
    i915->base.set_vertex_buffers = i915_set_vertex_buffers;
 }
index f5b0e9f011eb79d9dd8896ace3e38c5a0df2a8f1..4da46772b5d8e049b806214b37e3b58c54474a97 100644 (file)
@@ -101,14 +101,14 @@ static void calculate_vertex_layout( struct i915_context *i915 )
    /* primary color */
    if (colors[0]) {
       src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 0);
-      draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src);
+      draw_emit_vertex_attr(&vinfo, EMIT_4UB_BGRA, colorInterp, src);
       vinfo.hwfmt[0] |= S4_VFMT_COLOR;
    }
 
    /* secondary color */
    if (colors[1]) {
       src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 1);
-      draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src);
+      draw_emit_vertex_attr(&vinfo, EMIT_4UB_BGRA, colorInterp, src);
       vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG;
    }
 
@@ -157,10 +157,10 @@ void i915_update_derived( struct i915_context *i915 )
    if (i915->dirty & (I915_NEW_RASTERIZER | I915_NEW_FS | I915_NEW_VS))
       calculate_vertex_layout( i915 );
 
-   if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_TEXTURE))
+   if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_SAMPLER_VIEW))
       i915_update_samplers(i915);
 
-   if (i915->dirty & I915_NEW_TEXTURE)
+   if (i915->dirty & I915_NEW_SAMPLER_VIEW)
       i915_update_textures(i915);
 
    if (i915->dirty)
index 51f0ef12bafce595d70f1cfdd56ee0db17cc0828..04a3924aaf711031f3e4512dca6ddde2d5355396 100644 (file)
@@ -182,7 +182,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
       
       if(i915->vbo)
          OUT_RELOC(i915->vbo,
-                   INTEL_USAGE_VERTEX,
+                   I915_USAGE_VERTEX,
                    i915->current.immediate[I915_IMMEDIATE_S0]);
       else
          /* FIXME: we should not do this */
@@ -226,7 +226,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
                    ctile);
 
          OUT_RELOC(tex->buffer,
-                   INTEL_USAGE_RENDER,
+                   I915_USAGE_RENDER,
                    cbuf_surface->offset);
       }
 
@@ -250,7 +250,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
                    ztile);
 
          OUT_RELOC(tex->buffer,
-                   INTEL_USAGE_RENDER,
+                   I915_USAGE_RENDER,
                    depth_surface->offset);
       }
    
@@ -290,13 +290,14 @@ i915_emit_hardware_state(struct i915_context *i915 )
             OUT_BATCH(enabled);
             for (unit = 0; unit < I915_TEX_UNITS; unit++) {
                if (enabled & (1 << unit)) {
-                  struct intel_buffer *buf = i915->texture[unit]->buffer;
+                  struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+                  struct i915_winsys_buffer *buf = texture->buffer;
                   uint offset = 0;
                   assert(buf);
 
                   count++;
 
-                  OUT_RELOC(buf, INTEL_USAGE_SAMPLER, offset);
+                  OUT_RELOC(buf, I915_USAGE_SAMPLER, offset);
                   OUT_BATCH(i915->current.texbuffer[unit][0]); /* MS3 */
                   OUT_BATCH(i915->current.texbuffer[unit][1]); /* MS4 */
                }
index d2c6f1514342a5d39da5c3d33538a17c6100ae91..8cec699285c6afe956aa5482836bcec9e94d81a3 100644 (file)
@@ -52,11 +52,11 @@ static void upload_S0S1(struct i915_context *i915)
 {
    unsigned LIS0, LIS1;
 
-   /* INTEL_NEW_VBO */
+   /* I915_NEW_VBO */
    /* TODO: re-use vertex buffers here? */
    LIS0 = i915->vbo_offset;
 
-   /* INTEL_NEW_VERTEX_SIZE -- do this where the vertex size is calculated! 
+   /* I915_NEW_VERTEX_SIZE -- do this where the vertex size is calculated! 
     */
    {
       unsigned vertex_size = i915->current.vertex_info.size;
@@ -65,7 +65,7 @@ static void upload_S0S1(struct i915_context *i915)
              (vertex_size << 16));
    }
 
-   /* INTEL_NEW_VBO */
+   /* I915_NEW_VBO */
    /* TODO: use a vertex generation number to track vbo changes */
    if (1 ||
        i915->current.immediate[I915_IMMEDIATE_S0] != LIS0 ||
index 9813290b51bcde45eaa97180655a73da98c0ae92..4c326561cb9ab860348a9469d83106928251a6a7 100644 (file)
@@ -144,20 +144,22 @@ void i915_update_samplers( struct i915_context *i915 )
    i915->current.sampler_enable_nr = 0;
    i915->current.sampler_enable_flags = 0x0;
 
-   for (unit = 0; unit < i915->num_textures && unit < i915->num_samplers;
+   for (unit = 0; unit < i915->num_fragment_sampler_views && unit < i915->num_samplers;
         unit++) {
       /* determine unit enable/disable by looking for a bound texture */
       /* could also examine the fragment program? */
-      if (i915->texture[unit]) {
+      if (i915->fragment_sampler_views[unit]) {
+         struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+
         update_sampler( i915,
                         unit,
                         i915->sampler[unit],       /* sampler state */
-                        i915->texture[unit],        /* texture */
+                        texture,                    /* texture */
                         i915->current.sampler[unit] /* the result */
                         );
         i915_update_texture( i915,
                              unit,
-                             i915->texture[unit],          /* texture */
+                             texture,                      /* texture */
                              i915->sampler[unit],          /* sampler state */
                              i915->current.texbuffer[unit] );
 
@@ -190,6 +192,14 @@ translate_texture_format(enum pipe_format pipeFormat)
       return MAPSURF_16BIT | MT_16BIT_ARGB4444;
    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:
@@ -281,14 +291,16 @@ i915_update_textures(struct i915_context *i915)
 {
    uint unit;
 
-   for (unit = 0; unit < i915->num_textures && unit < i915->num_samplers;
+   for (unit = 0; unit < i915->num_fragment_sampler_views && unit < i915->num_samplers;
         unit++) {
       /* determine unit enable/disable by looking for a bound texture */
       /* could also examine the fragment program? */
-      if (i915->texture[unit]) {
+      if (i915->fragment_sampler_views[unit]) {
+         struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+
         i915_update_texture( i915,
                              unit,
-                             i915->texture[unit],          /* texture */
+                             texture,                      /* texture */
                              i915->sampler[unit],          /* sampler state */
                              i915->current.texbuffer[unit] );
       }
index b252fb5330cc402faed2fa7981c2d1c0659475ff..8c405c2443e36147d7e5de211c301a530543fba6 100644 (file)
@@ -41,7 +41,7 @@
 #include "i915_context.h"
 #include "i915_texture.h"
 #include "i915_screen.h"
-#include "intel_winsys.h"
+#include "i915_winsys.h"
 
 
 /*
@@ -162,7 +162,7 @@ i915_scanout_layout(struct i915_texture *tex)
    if (pt->width0 >= 240) {
       tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
       tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
-      tex->hw_tiled = INTEL_TILE_X;
+      tex->hw_tiled = I915_TILE_X;
    } else if (pt->width0 == 64 && pt->height0 == 64) {
       tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
       tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
@@ -200,7 +200,7 @@ i915_display_target_layout(struct i915_texture *tex)
 
    tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
    tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
-   tex->hw_tiled = INTEL_TILE_X;
+   tex->hw_tiled = I915_TILE_X;
 
    debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
       pt->width0, pt->height0, util_format_get_blocksize(pt->format),
@@ -617,7 +617,7 @@ i915_texture_create(struct pipe_screen *screen,
                     const struct pipe_texture *templat)
 {
    struct i915_screen *is = i915_screen(screen);
-   struct intel_winsys *iws = is->iws;
+   struct i915_winsys *iws = is->iws;
    struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
    size_t tex_size;
    unsigned buf_usage = 0;
@@ -643,9 +643,9 @@ i915_texture_create(struct pipe_screen *screen,
 
    /* for scanouts and cursors, cursors arn't scanouts */
    if (templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT && templat->width0 != 64)
-      buf_usage = INTEL_NEW_SCANOUT;
+      buf_usage = I915_NEW_SCANOUT;
    else
-      buf_usage = INTEL_NEW_TEXTURE;
+      buf_usage = I915_NEW_TEXTURE;
 
    tex->buffer = iws->buffer_create(iws, tex_size, 64, buf_usage);
    if (!tex->buffer)
@@ -653,7 +653,7 @@ i915_texture_create(struct pipe_screen *screen,
 
    /* setup any hw fences */
    if (tex->hw_tiled) {
-      assert(tex->sw_tiled == INTEL_TILE_NONE);
+      assert(tex->sw_tiled == I915_TILE_NONE);
       iws->buffer_set_fence_reg(iws, tex->buffer, tex->stride, tex->hw_tiled);
    }
 
@@ -679,8 +679,8 @@ i915_texture_from_handle(struct pipe_screen * screen,
 {
    struct i915_screen *is = i915_screen(screen);
    struct i915_texture *tex;
-   struct intel_winsys *iws = is->iws;
-   struct intel_buffer *buffer;
+   struct i915_winsys *iws = is->iws;
+   struct i915_winsys_buffer *buffer;
    unsigned stride;
 
    assert(screen);
@@ -719,7 +719,7 @@ i915_texture_get_handle(struct pipe_screen * screen,
 {
    struct i915_screen *is = i915_screen(screen);
    struct i915_texture *tex = (struct i915_texture *)texture;
-   struct intel_winsys *iws = is->iws;
+   struct i915_winsys *iws = is->iws;
 
    return iws->buffer_get_handle(iws, tex->buffer, whandle, tex->stride);
 }
@@ -729,7 +729,7 @@ static void
 i915_texture_destroy(struct pipe_texture *pt)
 {
    struct i915_texture *tex = (struct i915_texture *)pt;
-   struct intel_winsys *iws = i915_screen(pt->screen)->iws;
+   struct i915_winsys *iws = i915_screen(pt->screen)->iws;
    uint i;
 
    /*
@@ -841,7 +841,7 @@ i915_transfer_map(struct pipe_context *pipe,
                   struct pipe_transfer *transfer)
 {
    struct i915_texture *tex = (struct i915_texture *)transfer->texture;
-   struct intel_winsys *iws = i915_screen(tex->base.screen)->iws;
+   struct i915_winsys *iws = i915_screen(tex->base.screen)->iws;
    char *map;
    boolean write = FALSE;
    enum pipe_format format = tex->base.format;
@@ -863,7 +863,7 @@ i915_transfer_unmap(struct pipe_context *pipe,
                     struct pipe_transfer *transfer)
 {
    struct i915_texture *tex = (struct i915_texture *)transfer->texture;
-   struct intel_winsys *iws = i915_screen(tex->base.screen)->iws;
+   struct i915_winsys *iws = i915_screen(tex->base.screen)->iws;
    iws->buffer_unmap(iws, tex->buffer);
 }
 
diff --git a/src/gallium/drivers/i915/i915_winsys.h b/src/gallium/drivers/i915/i915_winsys.h
new file mode 100644 (file)
index 0000000..246e95b
--- /dev/null
@@ -0,0 +1,230 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 Jakob Bornecrantz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef I915_WINSYS_H
+#define I915_WINSYS_H
+
+#include "pipe/p_compiler.h"
+
+struct i915_winsys;
+struct i915_winsys_buffer;
+struct i915_winsys_batchbuffer;
+struct pipe_texture;
+struct pipe_fence_handle;
+struct winsys_handle;
+
+enum i915_winsys_buffer_usage
+{
+   /* use on textures */
+   I915_USAGE_RENDER    = 0x01,
+   I915_USAGE_SAMPLER   = 0x02,
+   I915_USAGE_2D_TARGET = 0x04,
+   I915_USAGE_2D_SOURCE = 0x08,
+   /* use on vertex */
+   I915_USAGE_VERTEX    = 0x10
+};
+
+enum i915_winsys_buffer_type
+{
+   I915_NEW_TEXTURE,
+   I915_NEW_SCANOUT, /**< a texture used for scanning out from */
+   I915_NEW_VERTEX
+};
+
+enum i915_winsys_buffer_tile
+{
+   I915_TILE_NONE,
+   I915_TILE_X,
+   I915_TILE_Y
+};
+
+struct i915_winsys_batchbuffer {
+
+   struct i915_winsys *iws;
+
+   /**
+    * Values exported to speed up the writing the batchbuffer,
+    * instead of having to go trough a accesor function for
+    * each dword written.
+    */
+   /*{@*/
+   uint8_t *map;
+   uint8_t *ptr;
+   size_t size;
+
+   size_t relocs;
+   size_t max_relocs;
+   /*@}*/
+};
+
+struct i915_winsys {
+
+   /**
+    * Batchbuffer functions.
+    */
+   /*@{*/
+   /**
+    * Create a new batchbuffer.
+    */
+   struct i915_winsys_batchbuffer *
+      (*batchbuffer_create)(struct i915_winsys *iws);
+
+   /**
+    * Emit a relocation to a buffer.
+    * Target position in batchbuffer is the same as ptr.
+    *
+    * @batch
+    * @reloc buffer address to be inserted into target.
+    * @usage how is the hardware going to use the buffer.
+    * @offset add this to the reloc buffers address
+    * @target buffer where to write the address, null for batchbuffer.
+    */
+   int (*batchbuffer_reloc)(struct i915_winsys_batchbuffer *batch,
+                            struct i915_winsys_buffer *reloc,
+                            enum i915_winsys_buffer_usage usage,
+                            unsigned offset);
+
+   /**
+    * Flush a bufferbatch.
+    */
+   void (*batchbuffer_flush)(struct i915_winsys_batchbuffer *batch,
+                             struct pipe_fence_handle **fence);
+
+   /**
+    * Destroy a batchbuffer.
+    */
+   void (*batchbuffer_destroy)(struct i915_winsys_batchbuffer *batch);
+   /*@}*/
+
+
+   /**
+    * Buffer functions.
+    */
+   /*@{*/
+   /**
+    * Create a buffer.
+    */
+   struct i915_winsys_buffer *
+      (*buffer_create)(struct i915_winsys *iws,
+                       unsigned size, unsigned alignment,
+                       enum i915_winsys_buffer_type type);
+
+   /**
+    * Creates a buffer from a handle.
+    * Used to implement pipe_screen::texture_from_handle.
+    * Also provides the stride information needed for the
+    * texture via the stride argument.
+    */
+   struct i915_winsys_buffer *
+      (*buffer_from_handle)(struct i915_winsys *iws,
+                            struct winsys_handle *whandle,
+                            unsigned *stride);
+
+   /**
+    * Used to implement pipe_screen::texture_get_handle.
+    * The winsys might need the stride information.
+    */
+   boolean (*buffer_get_handle)(struct i915_winsys *iws,
+                                struct i915_winsys_buffer *buffer,
+                                struct winsys_handle *whandle,
+                                unsigned stride);
+
+   /**
+    * Fence a buffer with a fence reg.
+    * Not to be confused with pipe_fence_handle.
+    */
+   int (*buffer_set_fence_reg)(struct i915_winsys *iws,
+                               struct i915_winsys_buffer *buffer,
+                               unsigned stride,
+                               enum i915_winsys_buffer_tile tile);
+
+   /**
+    * Map a buffer.
+    */
+   void *(*buffer_map)(struct i915_winsys *iws,
+                       struct i915_winsys_buffer *buffer,
+                       boolean write);
+
+   /**
+    * Unmap a buffer.
+    */
+   void (*buffer_unmap)(struct i915_winsys *iws,
+                        struct i915_winsys_buffer *buffer);
+
+   /**
+    * Write to a buffer.
+    *
+    * Arguments follows pipe_buffer_write.
+    */
+   int (*buffer_write)(struct i915_winsys *iws,
+                       struct i915_winsys_buffer *dst,
+                       size_t offset,
+                       size_t size,
+                       const void *data);
+
+   void (*buffer_destroy)(struct i915_winsys *iws,
+                          struct i915_winsys_buffer *buffer);
+   /*@}*/
+
+
+   /**
+    * Fence functions.
+    */
+   /*@{*/
+   /**
+    * Reference fence and set ptr to fence.
+    */
+   void (*fence_reference)(struct i915_winsys *iws,
+                           struct pipe_fence_handle **ptr,
+                           struct pipe_fence_handle *fence);
+
+   /**
+    * Check if a fence has finished.
+    */
+   int (*fence_signalled)(struct i915_winsys *iws,
+                          struct pipe_fence_handle *fence);
+
+   /**
+    * Wait on a fence to finish.
+    */
+   int (*fence_finish)(struct i915_winsys *iws,
+                       struct pipe_fence_handle *fence);
+   /*@}*/
+
+
+   /**
+    * Destroy the winsys.
+    */
+   void (*destroy)(struct i915_winsys *iws);
+};
+
+
+/**
+ * Create i915 pipe_screen.
+ */
+struct pipe_screen *i915_create_screen(struct i915_winsys *iws, unsigned pci_id);
+
+
+#endif
diff --git a/src/gallium/drivers/i915/intel_batchbuffer.h b/src/gallium/drivers/i915/intel_batchbuffer.h
deleted file mode 100644 (file)
index db12dfd..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-#ifndef INTEL_BATCH_H
-#define INTEL_BATCH_H
-
-#include "intel_winsys.h"
-
-static INLINE boolean
-intel_batchbuffer_check(struct intel_batchbuffer *batch,
-                        size_t dwords,
-                        size_t relocs)
-{
-   return dwords * 4 <= batch->size - (batch->ptr - batch->map) &&
-          relocs <= (batch->max_relocs - batch->relocs);
-}
-
-static INLINE size_t
-intel_batchbuffer_space(struct intel_batchbuffer *batch)
-{
-   return batch->size - (batch->ptr - batch->map);
-}
-
-static INLINE void
-intel_batchbuffer_dword(struct intel_batchbuffer *batch,
-                        unsigned dword)
-{
-   if (intel_batchbuffer_space(batch) < 4)
-      return;
-
-   *(unsigned *)batch->ptr = dword;
-   batch->ptr += 4;
-}
-
-static INLINE void
-intel_batchbuffer_write(struct intel_batchbuffer *batch,
-                        void *data,
-                        size_t size)
-{
-   if (intel_batchbuffer_space(batch) < size)
-      return;
-
-   memcpy(data, batch->ptr, size);
-   batch->ptr += size;
-}
-
-static INLINE int
-intel_batchbuffer_reloc(struct intel_batchbuffer *batch,
-                        struct intel_buffer *buffer,
-                        enum intel_buffer_usage usage,
-                        size_t offset)
-{
-   return batch->iws->batchbuffer_reloc(batch, buffer, usage, offset);
-}
-
-static INLINE void
-intel_batchbuffer_flush(struct intel_batchbuffer *batch,
-                        struct pipe_fence_handle **fence)
-{
-   batch->iws->batchbuffer_flush(batch, fence);
-}
-
-#endif
diff --git a/src/gallium/drivers/i915/intel_winsys.h b/src/gallium/drivers/i915/intel_winsys.h
deleted file mode 100644 (file)
index 00fd0c1..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/**************************************************************************
- *
- * Copyright Â© 2009 Jakob Bornecrantz
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_WINSYS_H
-#define INTEL_WINSYS_H
-
-#include "pipe/p_compiler.h"
-
-struct intel_winsys;
-struct intel_buffer;
-struct intel_batchbuffer;
-struct pipe_texture;
-struct pipe_fence_handle;
-struct winsys_handle;
-
-enum intel_buffer_usage
-{
-   /* use on textures */
-   INTEL_USAGE_RENDER    = 0x01,
-   INTEL_USAGE_SAMPLER   = 0x02,
-   INTEL_USAGE_2D_TARGET = 0x04,
-   INTEL_USAGE_2D_SOURCE = 0x08,
-   /* use on vertex */
-   INTEL_USAGE_VERTEX    = 0x10
-};
-
-enum intel_buffer_type
-{
-   INTEL_NEW_TEXTURE,
-   INTEL_NEW_SCANOUT, /**< a texture used for scanning out from */
-   INTEL_NEW_VERTEX
-};
-
-enum intel_buffer_tile
-{
-   INTEL_TILE_NONE,
-   INTEL_TILE_X,
-   INTEL_TILE_Y
-};
-
-struct intel_batchbuffer {
-
-   struct intel_winsys *iws;
-
-   /**
-    * Values exported to speed up the writing the batchbuffer,
-    * instead of having to go trough a accesor function for
-    * each dword written.
-    */
-   /*{@*/
-   uint8_t *map;
-   uint8_t *ptr;
-   size_t size;
-
-   size_t relocs;
-   size_t max_relocs;
-   /*@}*/
-};
-
-struct intel_winsys {
-
-   /**
-    * Batchbuffer functions.
-    */
-   /*@{*/
-   /**
-    * Create a new batchbuffer.
-    */
-   struct intel_batchbuffer *(*batchbuffer_create)(struct intel_winsys *iws);
-
-   /**
-    * Emit a relocation to a buffer.
-    * Target position in batchbuffer is the same as ptr.
-    *
-    * @batch
-    * @reloc buffer address to be inserted into target.
-    * @usage how is the hardware going to use the buffer.
-    * @offset add this to the reloc buffers address
-    * @target buffer where to write the address, null for batchbuffer.
-    */
-   int (*batchbuffer_reloc)(struct intel_batchbuffer *batch,
-                            struct intel_buffer *reloc,
-                            enum intel_buffer_usage usage,
-                            unsigned offset);
-
-   /**
-    * Flush a bufferbatch.
-    */
-   void (*batchbuffer_flush)(struct intel_batchbuffer *batch,
-                             struct pipe_fence_handle **fence);
-
-   /**
-    * Destroy a batchbuffer.
-    */
-   void (*batchbuffer_destroy)(struct intel_batchbuffer *batch);
-   /*@}*/
-
-
-   /**
-    * Buffer functions.
-    */
-   /*@{*/
-   /**
-    * Create a buffer.
-    */
-   struct intel_buffer *(*buffer_create)(struct intel_winsys *iws,
-                                         unsigned size, unsigned alignment,
-                                         enum intel_buffer_type type);
-
-   /**
-    * Creates a buffer from a handle.
-    * Used to implement pipe_screen::texture_from_handle.
-    * Also provides the stride information needed for the
-    * texture via the stride argument.
-    */
-   struct intel_buffer *(*buffer_from_handle)(struct intel_winsys *iws,
-                                              struct winsys_handle *whandle,
-                                              unsigned *stride);
-
-   /**
-    * Used to implement pipe_screen::texture_get_handle.
-    * The winsys might need the stride information.
-    */
-   boolean (*buffer_get_handle)(struct intel_winsys *iws,
-                                struct intel_buffer *buffer,
-                                struct winsys_handle *whandle,
-                                unsigned stride);
-
-   /**
-    * Fence a buffer with a fence reg.
-    * Not to be confused with pipe_fence_handle.
-    */
-   int (*buffer_set_fence_reg)(struct intel_winsys *iws,
-                               struct intel_buffer *buffer,
-                               unsigned stride,
-                               enum intel_buffer_tile tile);
-
-   /**
-    * Map a buffer.
-    */
-   void *(*buffer_map)(struct intel_winsys *iws,
-                       struct intel_buffer *buffer,
-                       boolean write);
-
-   /**
-    * Unmap a buffer.
-    */
-   void (*buffer_unmap)(struct intel_winsys *iws,
-                        struct intel_buffer *buffer);
-
-   /**
-    * Write to a buffer.
-    *
-    * Arguments follows pipe_buffer_write.
-    */
-   int (*buffer_write)(struct intel_winsys *iws,
-                       struct intel_buffer *dst,
-                       size_t offset,
-                       size_t size,
-                       const void *data);
-
-   void (*buffer_destroy)(struct intel_winsys *iws,
-                          struct intel_buffer *buffer);
-   /*@}*/
-
-
-   /**
-    * Fence functions.
-    */
-   /*@{*/
-   /**
-    * Reference fence and set ptr to fence.
-    */
-   void (*fence_reference)(struct intel_winsys *iws,
-                           struct pipe_fence_handle **ptr,
-                           struct pipe_fence_handle *fence);
-
-   /**
-    * Check if a fence has finished.
-    */
-   int (*fence_signalled)(struct intel_winsys *iws,
-                          struct pipe_fence_handle *fence);
-
-   /**
-    * Wait on a fence to finish.
-    */
-   int (*fence_finish)(struct intel_winsys *iws,
-                       struct pipe_fence_handle *fence);
-   /*@}*/
-
-
-   /**
-    * Destroy the winsys.
-    */
-   void (*destroy)(struct intel_winsys *iws);
-};
-
-
-/**
- * Create i915 pipe_screen.
- */
-struct pipe_screen *i915_create_screen(struct intel_winsys *iws, unsigned pci_id);
-
-
-#endif
index 9c2faaf4b49ae835ed59af8cc7aae69174eb2977..d900ea25968ad3219519d9571489829ee9ab5353 100644 (file)
@@ -58,6 +58,7 @@ i965 = env.ConvenienceLibrary(
                'brw_vs_emit.c',
                'brw_vs_state.c',
                'brw_vs_surface_state.c',
+               'brw_winsys_debug.c',
                'brw_wm.c',
 #              'brw_wm_constant_buffer.c',
                'brw_wm_debug.c',
index 3dbe2b91308a9198f8c25ddbd9c7a2bfa78794bb..4bcdcdd17ebe055605f92478e673096d11254e47 100644 (file)
@@ -118,6 +118,7 @@ struct pipe_context *brw_create_context(struct pipe_screen *screen,
    brw->sws = brw_screen(screen)->sws;
    brw->chipset = brw_screen(screen)->chipset;
 
+   brw_tex_init( brw );
    brw_pipe_blend_init( brw );
    brw_pipe_depth_stencil_init( brw );
    brw_pipe_framebuffer_init( brw );
index f5b1a06576bd1dda50f535e6dd8173bc0832c8f2..dab881fea2468e52a1d1e532738ed67f88be41eb 100644 (file)
@@ -551,9 +551,9 @@ struct brw_context
       const struct brw_sampler *sampler[PIPE_MAX_SAMPLERS];
       unsigned num_samplers;
 
-      struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+      struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
       struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
-      unsigned num_textures;
+      unsigned num_fragment_sampler_views;
       unsigned num_vertex_buffers;
 
       struct pipe_scissor_state scissor;
index c7c0e2ae95ea3f916ee551d703ae37d560c5ab6f..d2aa2bc9f3579d9669ac5e7fdd83de87373479b0 100644 (file)
@@ -183,26 +183,26 @@ static void brw_delete_sampler_state(struct pipe_context *pipe,
    FREE(cso);
 }
 
-static void brw_set_sampler_textures(struct pipe_context *pipe,
-                                    unsigned num,
-                                    struct pipe_texture **texture)
+static void brw_set_fragment_sampler_views(struct pipe_context *pipe,
+                                           unsigned num,
+                                           struct pipe_sampler_view **views)
 {
    struct brw_context *brw = brw_context(pipe);
    int i;
 
    for (i = 0; i < num; i++)
-      pipe_texture_reference(&brw->curr.texture[i], texture[i]);
+      pipe_sampler_view_reference(&brw->curr.fragment_sampler_views[i], views[i]);
 
-   for (i = num; i < brw->curr.num_textures; i++)
-      pipe_texture_reference(&brw->curr.texture[i], NULL);
+   for (i = num; i < brw->curr.num_fragment_sampler_views; i++)
+      pipe_sampler_view_reference(&brw->curr.fragment_sampler_views[i], NULL);
 
-   brw->curr.num_textures = num;
+   brw->curr.num_fragment_sampler_views = num;
    brw->state.dirty.mesa |= PIPE_NEW_BOUND_TEXTURES;
 }
 
-static void brw_set_vertex_sampler_textures(struct pipe_context *pipe,
-                                            unsigned num,
-                                            struct pipe_texture **texture)
+static void brw_set_vertex_sampler_views(struct pipe_context *pipe,
+                                         unsigned num,
+                                         struct pipe_sampler_view **views)
 {
 }
 
@@ -212,17 +212,47 @@ static void brw_bind_vertex_sampler_state(struct pipe_context *pipe,
 }
 
 
+static struct pipe_sampler_view *
+brw_create_sampler_view(struct pipe_context *pipe,
+                        struct pipe_texture *texture,
+                        const struct pipe_sampler_view *templ)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
+
+   return view;
+}
+
+
+static void
+brw_sampler_view_destroy(struct pipe_context *pipe,
+                         struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
+}
+
+
 void brw_pipe_sampler_init( struct brw_context *brw )
 {
    brw->base.create_sampler_state = brw_create_sampler_state;
    brw->base.delete_sampler_state = brw_delete_sampler_state;
 
-   brw->base.set_fragment_sampler_textures = brw_set_sampler_textures;
+   brw->base.set_fragment_sampler_views = brw_set_fragment_sampler_views;
    brw->base.bind_fragment_sampler_states = brw_bind_sampler_state;
 
-   brw->base.set_vertex_sampler_textures = brw_set_vertex_sampler_textures;
+   brw->base.set_vertex_sampler_views = brw_set_vertex_sampler_views;
    brw->base.bind_vertex_sampler_states = brw_bind_vertex_sampler_state;
 
+   brw->base.create_sampler_view = brw_create_sampler_view;
+   brw->base.sampler_view_destroy = brw_sampler_view_destroy;
 }
 void brw_pipe_sampler_cleanup( struct brw_context *brw )
 {
index cadcb7cee2a33142cb84a2c8cc9f3be5abc2a4ca..f9f17bdabac917d448739dc588efd8a06db013d9 100644 (file)
@@ -206,7 +206,7 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
    /* XXX: compressed textures need special treatment here
     */
    tex->cpp = util_format_get_blocksize(tex->base.format);
-   tex->compressed = util_format_is_compressed(tex->base.format);
+   tex->compressed = util_format_is_s3tc(tex->base.format);
 
    make_empty_list(&tex->views[0]);
    make_empty_list(&tex->views[1]);
@@ -321,7 +321,7 @@ brw_texture_from_handle(struct pipe_screen *screen,
        templ->depth0 != 1)
       return NULL;
 
-   if (util_format_is_compressed(templ->format))
+   if (util_format_is_s3tc(templ->format))
       return NULL;
 
    tex = CALLOC_STRUCT(brw_texture);
index dfb718e64fe7d6b0991d8c289615faca233b5885..7ed2378ec04710df8b34834ba5a776223cc72912 100644 (file)
@@ -251,8 +251,8 @@ static void brw_wm_populate_key( struct brw_context *brw,
 
 
    /* PIPE_NEW_BOUND_TEXTURES */
-   for (i = 0; i < brw->curr.num_textures; i++) {
-      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+   for (i = 0; i < brw->curr.num_fragment_sampler_views; i++) {
+      const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture);
         
       if (tex->base.format == PIPE_FORMAT_UYVY)
         key->yuvtex_mask |= 1 << i;
index 6a6086fc51b3a172f3be2a6eee948e1716d0bcba..3f18062c584dc8129ee29f10c34e3a21ec197ebf 100644 (file)
@@ -78,11 +78,11 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
 
    memset(key, 0, sizeof(*key));
 
-   key->sampler_count = MIN2(brw->curr.num_textures,
+   key->sampler_count = MIN2(brw->curr.num_fragment_sampler_views,
                            brw->curr.num_samplers);
 
    for (i = 0; i < key->sampler_count; i++) {
-      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+      const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture);
       const struct brw_sampler *sampler = brw->curr.sampler[i];
       struct brw_sampler_state *entry = &key->sampler[i];
 
@@ -122,12 +122,12 @@ static enum pipe_error
 brw_wm_sampler_update_default_colors(struct brw_context *brw)
 {
    enum pipe_error ret;
-   int nr = MIN2(brw->curr.num_textures,
+   int nr = MIN2(brw->curr.num_fragment_sampler_views,
                 brw->curr.num_samplers);
    int i;
 
    for (i = 0; i < nr; i++) {
-      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+      const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture);
       const struct brw_sampler *sampler = brw->curr.sampler[i];
       const float *bc;
       float bordercolor[4] = {
index b01a7f194b7e8d8c5ff11e525e8e60b09127983b..2368ae3f808947cdd2d3f77a291a218551e9e082 100644 (file)
@@ -242,9 +242,9 @@ static enum pipe_error prepare_wm_surfaces(struct brw_context *brw )
 
    /* PIPE_NEW_TEXTURE 
     */
-   for (i = 0; i < brw->curr.num_textures; i++) {
+   for (i = 0; i < brw->curr.num_fragment_sampler_views; i++) {
       ret = brw_update_texture_surface(brw, 
-                                       brw_texture(brw->curr.texture[i]),
+                                       brw_texture(brw->curr.fragment_sampler_views[i]->texture),
                                        &brw->wm.surf_bo[BTI_TEXTURE(i)]);
       if (ret)
          return ret;
@@ -261,7 +261,7 @@ static enum pipe_error prepare_wm_surfaces(struct brw_context *brw )
       bo_reference(&brw->wm.surf_bo[BTI_FRAGMENT_CONSTANTS], NULL);      
 
    /* XXX: no pipe_max_textures define?? */
-   for (i = brw->curr.num_textures; i < PIPE_MAX_SAMPLERS; i++)
+   for (i = brw->curr.num_fragment_sampler_views; i < PIPE_MAX_SAMPLERS; i++)
       bo_reference(&brw->wm.surf_bo[BTI_TEXTURE(i)], NULL);
 
    if (brw->wm.nr_surfaces != nr_surfaces) {
index 7f079dd0a8b8e3642a2878d73997badf71e9a1b5..2a68891c2844d9f3f4c51ee803dc54f4374981cd 100644 (file)
@@ -5,9 +5,10 @@ env = env.Clone()
 identity = env.ConvenienceLibrary(
        target = 'identity',
        source = [
-               'id_screen.c',
                'id_context.c',
+               'id_drm.c',
                'id_objects.c',
+               'id_screen.c',
        ])
 
 Export('identity')
index 26770d6b1e9ff1bf598e520cc2564ca1573402e1..00a542215ad2add658ce97fc44c107ced63ed843 100644 (file)
@@ -528,53 +528,49 @@ identity_set_viewport_state(struct pipe_context *_pipe,
 }
 
 static void
-identity_set_fragment_sampler_textures(struct pipe_context *_pipe,
-                                       unsigned num_textures,
-                                       struct pipe_texture **_textures)
+identity_set_fragment_sampler_views(struct pipe_context *_pipe,
+                                    unsigned num,
+                                    struct pipe_sampler_view **_views)
 {
    struct identity_context *id_pipe = identity_context(_pipe);
    struct pipe_context *pipe = id_pipe->pipe;
-   struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS];
-   struct pipe_texture **textures = NULL;
+   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view **views = NULL;
    unsigned i;
 
-   if (_textures) {
-      for (i = 0; i < num_textures; i++)
-         unwrapped_textures[i] = identity_texture_unwrap(_textures[i]);
+   if (_views) {
+      for (i = 0; i < num; i++)
+         unwrapped_views[i] = identity_sampler_view_unwrap(_views[i]);
       for (; i < PIPE_MAX_SAMPLERS; i++)
-         unwrapped_textures[i] = NULL;
+         unwrapped_views[i] = NULL;
 
-      textures = unwrapped_textures;
+      views = unwrapped_views;
    }
 
-   pipe->set_fragment_sampler_textures(pipe,
-                                       num_textures,
-                                       textures);
+   pipe->set_fragment_sampler_views(pipe, num, views);
 }
 
 static void
-identity_set_vertex_sampler_textures(struct pipe_context *_pipe,
-                                     unsigned num_textures,
-                                     struct pipe_texture **_textures)
+identity_set_vertex_sampler_views(struct pipe_context *_pipe,
+                                  unsigned num,
+                                  struct pipe_sampler_view **_views)
 {
    struct identity_context *id_pipe = identity_context(_pipe);
    struct pipe_context *pipe = id_pipe->pipe;
-   struct pipe_texture *unwrapped_textures[PIPE_MAX_VERTEX_SAMPLERS];
-   struct pipe_texture **textures = NULL;
+   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view **views = NULL;
    unsigned i;
 
-   if (_textures) {
-      for (i = 0; i < num_textures; i++)
-         unwrapped_textures[i] = identity_texture_unwrap(_textures[i]);
+   if (_views) {
+      for (i = 0; i < num; i++)
+         unwrapped_views[i] = identity_sampler_view_unwrap(_views[i]);
       for (; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
-         unwrapped_textures[i] = NULL;
+         unwrapped_views[i] = NULL;
 
-      textures = unwrapped_textures;
+      views = unwrapped_views;
    }
 
-   pipe->set_vertex_sampler_textures(pipe,
-                                     num_textures,
-                                     textures);
+   pipe->set_vertex_sampler_views(pipe, num, views);
 }
 
 static void
@@ -711,6 +707,45 @@ identity_is_buffer_referenced(struct pipe_context *_pipe,
                                      buffer);
 }
 
+static struct pipe_sampler_view *
+identity_create_sampler_view(struct pipe_context *pipe,
+                             struct pipe_texture *texture,
+                             const struct pipe_sampler_view *templ)
+{
+   struct identity_context *id_pipe = identity_context(pipe);
+   struct identity_texture *id_texture = identity_texture(texture);
+   struct pipe_context *pipe_unwrapped = id_pipe->pipe;
+   struct pipe_texture *texture_unwrapped = id_texture->texture;
+   struct identity_sampler_view *view = malloc(sizeof(struct identity_sampler_view));
+
+   view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped,
+                                                            texture_unwrapped,
+                                                            templ);
+
+   view->base = *templ;
+   view->base.reference.count = 1;
+   view->base.texture = NULL;
+   pipe_texture_reference(&view->base.texture, texture);
+   view->base.context = pipe;
+
+   return &view->base;
+}
+
+static void
+identity_sampler_view_destroy(struct pipe_context *pipe,
+                              struct pipe_sampler_view *view)
+{
+   struct identity_context *id_pipe = identity_context(pipe);
+   struct identity_sampler_view *id_view = identity_sampler_view(view);
+   struct pipe_context *pipe_unwrapped = id_pipe->pipe;
+   struct pipe_sampler_view *view_unwrapped = id_view->sampler_view;
+
+   pipe_unwrapped->sampler_view_destroy(pipe_unwrapped,
+                                        view_unwrapped);
+
+   pipe_texture_reference(&view->texture, NULL);
+   free(view);
+}
 
 
 static struct pipe_transfer *
@@ -836,8 +871,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.set_polygon_stipple = identity_set_polygon_stipple;
    id_pipe->base.set_scissor_state = identity_set_scissor_state;
    id_pipe->base.set_viewport_state = identity_set_viewport_state;
-   id_pipe->base.set_fragment_sampler_textures = identity_set_fragment_sampler_textures;
-   id_pipe->base.set_vertex_sampler_textures = identity_set_vertex_sampler_textures;
+   id_pipe->base.set_fragment_sampler_views = identity_set_fragment_sampler_views;
+   id_pipe->base.set_vertex_sampler_views = identity_set_vertex_sampler_views;
    id_pipe->base.set_vertex_buffers = identity_set_vertex_buffers;
    id_pipe->base.surface_copy = identity_surface_copy;
    id_pipe->base.surface_fill = identity_surface_fill;
@@ -845,6 +880,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.flush = identity_flush;
    id_pipe->base.is_texture_referenced = identity_is_texture_referenced;
    id_pipe->base.is_buffer_referenced = identity_is_buffer_referenced;
+   id_pipe->base.create_sampler_view = identity_create_sampler_view;
+   id_pipe->base.sampler_view_destroy = identity_sampler_view_destroy;
    id_pipe->base.get_tex_transfer = identity_context_get_tex_transfer;
    id_pipe->base.tex_transfer_destroy = identity_context_tex_transfer_destroy;
    id_pipe->base.transfer_map = identity_context_transfer_map;
index 936ccc444a8b67a7ca534a12d55658a01627fe26..26920fed08d5c39435194c8038404625e5fd744c 100644 (file)
@@ -31,7 +31,6 @@
 #include "id_drm.h"
 #include "id_screen.h"
 #include "id_public.h"
-#include "id_screen.h"
 #include "id_objects.h"
 
 struct identity_drm_api
index 7333ecfb7fb7370217577282889d19a6b7e238e7..9a07ebe8d725c471667cafa72ded9ab5b2bd2824 100644 (file)
@@ -53,6 +53,14 @@ struct identity_texture
 };
 
 
+struct identity_sampler_view
+{
+   struct pipe_sampler_view base;
+
+   struct pipe_sampler_view *sampler_view;
+};
+
+
 struct identity_surface
 {
    struct pipe_surface base;
@@ -96,6 +104,15 @@ identity_texture(struct pipe_texture *_texture)
    return (struct identity_texture *)_texture;
 }
 
+static INLINE struct identity_sampler_view *
+identity_sampler_view(struct pipe_sampler_view *_sampler_view)
+{
+   if (!_sampler_view) {
+      return NULL;
+   }
+   return (struct identity_sampler_view *)_sampler_view;
+}
+
 static INLINE struct identity_surface *
 identity_surface(struct pipe_surface *_surface)
 {
@@ -140,6 +157,15 @@ identity_texture_unwrap(struct pipe_texture *_texture)
    return identity_texture(_texture)->texture;
 }
 
+static INLINE struct pipe_sampler_view *
+identity_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view)
+{
+   if (!_sampler_view) {
+      return NULL;
+   }
+   return identity_sampler_view(_sampler_view)->sampler_view;
+}
+
 static INLINE struct pipe_surface *
 identity_surface_unwrap(struct pipe_surface *_surface)
 {
index 89c06ea3ad7bce0ac8d2b4f1ee815bbcacdbb28c..b37c6754c0839dd6192b53bb6fb6a467d01cf668 100644 (file)
@@ -42,6 +42,11 @@ C_SOURCES = \
 
 CPP_SOURCES = \
 
+PROGS := lp_test_format        \
+        lp_test_blend  \
+        lp_test_conv   \
+        lp_test_printf
+
 
 include ../../Makefile.template
 
@@ -49,13 +54,7 @@ lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxil
        python lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@
 
 
-testprogs := lp_test_format    \
-            lp_test_blend      \
-            lp_test_conv
-
-LIBS += $(GL_LIB_DEPS) -L. -lllvmpipe -L../../auxiliary/ -lgallium
+LIBS += $(GL_LIB_DEPS) -L../../auxiliary/ -lgallium
 
-#$(testprogs): lp_test_% : lp_test_%.o lp_test_main.o libllvmpipe.a
-#      $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group  $(LIBS) -Wl,--end-group
+$(PROGS): lp_test_main.o
 
-#default: $(testprogs)
index e0676c80a258dfa3f1f5558f6492bd7b54aef062..383e4b0614d29bc61d46c06b806de0e9ebff1264 100644 (file)
@@ -69,11 +69,11 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
    pipe_surface_reference(&llvmpipe->framebuffer.zsbuf, NULL);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      pipe_texture_reference(&llvmpipe->texture[i], NULL);
+      pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], NULL);
    }
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      pipe_texture_reference(&llvmpipe->vertex_textures[i], NULL);
+      pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], NULL);
    }
 
    for (i = 0; i < Elements(llvmpipe->constants); i++) {
@@ -158,8 +158,10 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv )
    llvmpipe->pipe.set_framebuffer_state = llvmpipe_set_framebuffer_state;
    llvmpipe->pipe.set_polygon_stipple = llvmpipe_set_polygon_stipple;
    llvmpipe->pipe.set_scissor_state = llvmpipe_set_scissor_state;
-   llvmpipe->pipe.set_fragment_sampler_textures = llvmpipe_set_sampler_textures;
-   llvmpipe->pipe.set_vertex_sampler_textures = llvmpipe_set_vertex_sampler_textures;
+   llvmpipe->pipe.set_fragment_sampler_views = llvmpipe_set_fragment_sampler_views;
+   llvmpipe->pipe.set_vertex_sampler_views = llvmpipe_set_vertex_sampler_views;
+   llvmpipe->pipe.create_sampler_view = llvmpipe_create_sampler_view;
+   llvmpipe->pipe.sampler_view_destroy = llvmpipe_sampler_view_destroy;
    llvmpipe->pipe.set_viewport_state = llvmpipe_set_viewport_state;
 
    llvmpipe->pipe.set_vertex_buffers = llvmpipe_set_vertex_buffers;
index f391871b0eeccc619a2e1dece1d68abdc41ff962..71f991049e5acfeec60a4a2c1ffa296e7db8f475 100644 (file)
@@ -69,15 +69,15 @@ struct llvmpipe_context {
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
 
    unsigned num_samplers;
-   unsigned num_textures;
+   unsigned num_fragment_sampler_views;
    unsigned num_vertex_samplers;
-   unsigned num_vertex_textures;
+   unsigned num_vertex_sampler_views;
    unsigned num_vertex_buffers;
 
    unsigned dirty; /**< Mask of LP_NEW_x flags */
index 525c117f316592690bc89f515641ac34ab21852a..00dc3eab6b1e838b6e7a9c0a2040c1eb25ce4047 100644 (file)
@@ -29,6 +29,7 @@
 #include "pipe/p_screen.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
+#include "lp_debug.h"
 #include "lp_fence.h"
 
 
@@ -99,6 +100,21 @@ llvmpipe_fence_finish(struct pipe_screen *screen,
 }
 
 
+void
+lp_fence_signal(struct lp_fence *fence)
+{
+   pipe_mutex_lock(fence->mutex);
+
+   fence->count++;
+   assert(fence->count <= fence->rank);
+
+   LP_DBG(DEBUG_RAST, "%s count=%u rank=%u\n", __FUNCTION__,
+          fence->count, fence->rank);
+
+   pipe_condvar_signal(fence->signalled);
+
+   pipe_mutex_unlock(fence->mutex);
+}
 
 
 void
index c90e6de423ba41d73d0003be98ab41f7ed2fb94d..d9270f5784acb7ed5c5b61471d4ea52d9a7b3dca 100644 (file)
@@ -53,6 +53,10 @@ struct lp_fence *
 lp_fence_create(unsigned rank);
 
 
+void
+lp_fence_signal(struct lp_fence *fence);
+
+
 void
 llvmpipe_init_screen_fence_funcs(struct pipe_screen *screen);
 
index 636d72a9bb8f0f7a80cb0a46e0cee9013c9f69c4..782669a1e773d7e9f45e81f5d9c363d1e9410cd4 100644 (file)
@@ -111,7 +111,6 @@ llvmpipe_flush_texture(struct pipe_context *pipe,
                        boolean cpu_access,
                        boolean do_not_flush)
 {
-   struct pipe_fence_handle *last_fence = NULL;
    unsigned referenced;
 
    referenced = pipe->is_texture_referenced(pipe, texture, face, level);
@@ -142,7 +141,7 @@ llvmpipe_flush_texture(struct pipe_context *pipe,
 
          pipe->flush(pipe, flush_flags, &fence);
 
-         if (last_fence) {
+         if (fence) {
             pipe->screen->fence_finish(pipe->screen, fence, 0);
             pipe->screen->fence_reference(pipe->screen, &fence, NULL);
          }
index 5887613120d83a0596b25d1518df5ceb63854bb5..927e472ff26a20240147b31301dc084027245a9a 100644 (file)
@@ -91,36 +91,53 @@ lp_jit_init_globals(struct llvmpipe_screen *screen)
 
    /* struct lp_jit_context */
    {
-      LLVMTypeRef elem_types[8];
+      LLVMTypeRef elem_types[LP_JIT_CTX_COUNT];
       LLVMTypeRef context_type;
 
-      elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */
-      elem_types[1] = LLVMFloatType();                     /* alpha_ref_value */      elem_types[2] = LLVMFloatType();                     /* scissor_xmin */
-      elem_types[3] = LLVMFloatType();                     /* scissor_ymin */
-      elem_types[4] = LLVMFloatType();                     /* scissor_xmax */
-      elem_types[5] = LLVMFloatType();                     /* scissor_ymax */
-      elem_types[6] = LLVMPointerType(LLVMInt8Type(), 0);  /* blend_color */
-      elem_types[7] = LLVMArrayType(texture_type, PIPE_MAX_SAMPLERS); /* textures */
+      elem_types[LP_JIT_CTX_CONSTANTS] = LLVMPointerType(LLVMFloatType(), 0);
+      elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] = LLVMInt32Type();
+      elem_types[LP_JIT_CTX_STENCIL_REF_BACK] = LLVMInt32Type();
+      elem_types[LP_JIT_CTX_SCISSOR_XMIN] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_SCISSOR_YMIN] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_SCISSOR_XMAX] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_SCISSOR_YMAX] = LLVMFloatType();
+      elem_types[LP_JIT_CTX_BLEND_COLOR] = LLVMPointerType(LLVMInt8Type(), 0);
+      elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
+                                                      PIPE_MAX_SAMPLERS);
 
       context_type = LLVMStructType(elem_types, Elements(elem_types), 0);
 
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
-                             screen->target, context_type, 0);
+                             screen->target, context_type,
+                             LP_JIT_CTX_CONSTANTS);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
-                             screen->target, context_type, 1);
+                             screen->target, context_type,
+                             LP_JIT_CTX_ALPHA_REF);
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_front,
+                             screen->target, context_type,
+                             LP_JIT_CTX_STENCIL_REF_FRONT);
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_back,
+                             screen->target, context_type,
+                             LP_JIT_CTX_STENCIL_REF_BACK);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin,
-                             screen->target, context_type, 2);
+                             screen->target, context_type,
+                             LP_JIT_CTX_SCISSOR_XMIN);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymin,
-                             screen->target, context_type, 3);
+                             screen->target, context_type,
+                             LP_JIT_CTX_SCISSOR_YMIN);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmax,
-                             screen->target, context_type, 4);
+                             screen->target, context_type,
+                             LP_JIT_CTX_SCISSOR_XMAX);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_ymax,
-                             screen->target, context_type, 5);
+                             screen->target, context_type,
+                             LP_JIT_CTX_SCISSOR_YMAX);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, blend_color,
-                             screen->target, context_type, 6);
+                             screen->target, context_type,
+                             LP_JIT_CTX_BLEND_COLOR);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures,
                              screen->target, context_type,
-                             LP_JIT_CONTEXT_TEXTURES_INDEX);
+                             LP_JIT_CTX_TEXTURES);
       LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
                            screen->target, context_type);
 
index 13167ae3bf4edbc4e05a260242238a52d7c45c97..4930ff02e6bf9e53765170d15b35a37338d65514 100644 (file)
@@ -84,6 +84,8 @@ struct lp_jit_context
 
    float alpha_ref_value;
 
+   uint32_t stencil_ref_front, stencil_ref_back;
+
    /** floats, not ints */
    float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax;
 
@@ -94,37 +96,66 @@ struct lp_jit_context
 };
 
 
+/**
+ * These enum values must match the position of the fields in the
+ * lp_jit_context struct above.
+ */
+enum {
+   LP_JIT_CTX_CONSTANTS = 0,
+   LP_JIT_CTX_ALPHA_REF,
+   LP_JIT_CTX_STENCIL_REF_FRONT,
+   LP_JIT_CTX_STENCIL_REF_BACK,
+   LP_JIT_CTX_SCISSOR_XMIN,
+   LP_JIT_CTX_SCISSOR_YMIN,
+   LP_JIT_CTX_SCISSOR_XMAX,
+   LP_JIT_CTX_SCISSOR_YMAX,
+   LP_JIT_CTX_BLEND_COLOR,
+   LP_JIT_CTX_TEXTURES,
+   LP_JIT_CTX_COUNT
+};
+
+
 #define lp_jit_context_constants(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 0, "constants")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_CONSTANTS, "constants")
 
 #define lp_jit_context_alpha_ref_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 1, "alpha_ref_value")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
+
+#define lp_jit_context_stencil_ref_front_value(_builder, _ptr) \
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF_FRONT, "stencil_ref_front")
+
+#define lp_jit_context_stencil_ref_back_value(_builder, _ptr) \
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF_BACK, "stencil_ref_back")
 
 #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 2, "scissor_xmin")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMIN, "scissor_xmin")
 
 #define lp_jit_context_scissor_ymin_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 3, "scissor_ymin")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_YMIN, "scissor_ymin")
 
 #define lp_jit_context_scissor_xmax_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 4, "scissor_xmax")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMAX, "scissor_xmax")
 
 #define lp_jit_context_scissor_ymax_value(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 5, "scissor_ymax")
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_YMAX, "scissor_ymax")
 
 #define lp_jit_context_blend_color(_builder, _ptr) \
-   lp_build_struct_get(_builder, _ptr, 6, "blend_color")
-
-#define LP_JIT_CONTEXT_TEXTURES_INDEX 7
+   lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_BLEND_COLOR, "blend_color")
 
 #define lp_jit_context_textures(_builder, _ptr) \
-   lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES_INDEX, "textures")
+   lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES, "textures")
+
+
+/** Indexes into jit_function[] array */
+#define RAST_WHOLE 0
+#define RAST_EDGE_TEST 1
 
 
 typedef void
 (*lp_jit_frag_func)(const struct lp_jit_context *context,
                     uint32_t x,
                     uint32_t y,
+                    float facing,
                     const void *a0,
                     const void *dadx,
                     const void *dady,
index 81ea11a16b6ea6a2a26d69d7ee095679471d34e2..8352f175598bd12c7552c6002f473cbe05fe40e1 100644 (file)
@@ -189,7 +189,7 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task,
 
    LP_DBG(DEBUG_RAST, "%s 0x%x\n", __FUNCTION__, arg.clear_zstencil);
 
-   assert(rast->zsbuf.map);
+   /*assert(rast->zsbuf.map);*/
    if (!rast->zsbuf.map)
       return;
 
@@ -312,15 +312,16 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
          depth = lp_rast_depth_pointer(rast, tile_x + x, tile_y + y);
 
          /* run shader */
-         state->jit_function[0]( &state->jit_context,
-                                 tile_x + x, tile_y + y,
-                                 inputs->a0,
-                                 inputs->dadx,
-                                 inputs->dady,
-                                 color,
-                                 depth,
-                                 INT_MIN, INT_MIN, INT_MIN,
-                                 NULL, NULL, NULL );
+         state->jit_function[RAST_WHOLE]( &state->jit_context,
+                                          tile_x + x, tile_y + y,
+                                          inputs->facing,
+                                          inputs->a0,
+                                          inputs->dadx,
+                                          inputs->dady,
+                                          color,
+                                          depth,
+                                          INT_MIN, INT_MIN, INT_MIN,
+                                          NULL, NULL, NULL );
       }
    }
 }
@@ -375,15 +376,18 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task,
    assert(lp_check_alignment(inputs->step[2], 16));
 
    /* run shader */
-   state->jit_function[1]( &state->jit_context,
-                        x, y,
-                        inputs->a0,
-                        inputs->dadx,
-                        inputs->dady,
-                        color,
-                        depth,
-                        c1, c2, c3,
-                        inputs->step[0], inputs->step[1], inputs->step[2]);
+   state->jit_function[RAST_EDGE_TEST]( &state->jit_context,
+                                        x, y,
+                                        inputs->facing,
+                                        inputs->a0,
+                                        inputs->dadx,
+                                        inputs->dady,
+                                        color,
+                                        depth,
+                                        c1, c2, c3,
+                                        inputs->step[0],
+                                        inputs->step[1],
+                                        inputs->step[2]);
 }
 
 
@@ -487,18 +491,7 @@ lp_rast_fence(struct lp_rasterizer_task *task,
               const union lp_rast_cmd_arg arg)
 {
    struct lp_fence *fence = arg.fence;
-
-   pipe_mutex_lock( fence->mutex );
-
-   fence->count++;
-   assert(fence->count <= fence->rank);
-
-   LP_DBG(DEBUG_RAST, "%s count=%u rank=%u\n", __FUNCTION__,
-          fence->count, fence->rank);
-
-   pipe_condvar_signal( fence->signalled );
-
-   pipe_mutex_unlock( fence->mutex );
+   lp_fence_signal(fence);
 }
 
 
index 303f6e3f7e4db10300450a476aac8e596bda9033..ae838f3fbef6ca70d9a6befd038792b67cb83c64 100644 (file)
@@ -82,6 +82,8 @@ struct lp_rast_state {
  * These pointers point into the bin data buffer.
  */
 struct lp_rast_shader_inputs {
+   float facing;     /** Positive for front-facing, negative for back-facing */
+
    float (*a0)[4];
    float (*dadx)[4];
    float (*dady)[4];
index 39bf2c25879f3c6511c137f37c47afb4ecb6d01b..6ee9bcaae3ad493f57e3dfe8e1beb142b4eee35f 100644 (file)
@@ -195,6 +195,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
    /* run shader */
    state->jit_function[0]( &state->jit_context,
                            x, y,
+                           inputs->facing,
                            inputs->a0,
                            inputs->dadx,
                            inputs->dady,
index 5093f58bb19736d11f829428cda482f1006d37bc..f1bbc2092c432d9e72462bd1f4b65f674acd8dc6 100644 (file)
@@ -204,8 +204,10 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
          return FALSE;
    }
 
-   if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
-      if(!winsys->is_displaytarget_format_supported(winsys, format))
+   if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                   PIPE_TEXTURE_USAGE_SCANOUT |
+                   PIPE_TEXTURE_USAGE_SHARED)) {
+      if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
          return FALSE;
    }
 
index d977f98cfaa658e11e2f2e390f6b2cca021a0eb1..af25e043cc97d386cbcc949ca5d69bc88a351545 100644 (file)
@@ -34,7 +34,7 @@
 #ifndef LP_SCREEN_H
 #define LP_SCREEN_H
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 #include <llvm-c/ExecutionEngine.h>
 
 #include "pipe/p_screen.h"
index 16128c34c80878cf4384522d9b17df3abebe8847..76a8b87a3095168e6d8ada7274e8408bd14b09b3 100644 (file)
@@ -401,6 +401,20 @@ lp_setup_set_alpha_ref_value( struct lp_setup_context *setup,
    }
 }
 
+void
+lp_setup_set_stencil_ref_values( struct lp_setup_context *setup,
+                                 const ubyte refs[2] )
+{
+   LP_DBG(DEBUG_SETUP, "%s %d %d\n", __FUNCTION__, refs[0], refs[1]);
+
+   if (setup->fs.current.jit_context.stencil_ref_front != refs[0] ||
+       setup->fs.current.jit_context.stencil_ref_back != refs[1]) {
+      setup->fs.current.jit_context.stencil_ref_front = refs[0];
+      setup->fs.current.jit_context.stencil_ref_back = refs[1];
+      setup->dirty |= LP_SETUP_NEW_FS;
+   }
+}
+
 void
 lp_setup_set_blend_color( struct lp_setup_context *setup,
                           const struct pipe_blend_color *blend_color )
@@ -450,11 +464,12 @@ lp_setup_set_vertex_info( struct lp_setup_context *setup,
 
 
 /**
- * Called during state validation when LP_NEW_TEXTURE is set.
+ * Called during state validation when LP_NEW_SAMPLER_VIEW is set.
  */
 void
-lp_setup_set_sampler_textures( struct lp_setup_context *setup,
-                               unsigned num, struct pipe_texture **texture)
+lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
+                                    unsigned num,
+                                    struct pipe_sampler_view **views)
 {
    unsigned i;
 
@@ -463,9 +478,10 @@ lp_setup_set_sampler_textures( struct lp_setup_context *setup,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      struct pipe_texture *tex = i < num ? texture[i] : NULL;
+      struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      if(tex) {
+      if(view) {
+         struct pipe_texture *tex = view->texture;
          struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex);
          struct lp_jit_texture *jit_tex;
          jit_tex = &setup->fs.current.jit_context.textures[i];
@@ -473,6 +489,12 @@ lp_setup_set_sampler_textures( struct lp_setup_context *setup,
          jit_tex->height = tex->height0;
          jit_tex->depth = tex->depth0;
          jit_tex->last_level = tex->last_level;
+
+         /* We're referencing the texture's internal data, so save a
+          * reference to it.
+          */
+         pipe_texture_reference(&setup->fs.current_tex[i], tex);
+
          if (!lp_tex->dt) {
             /* regular texture - setup array of mipmap level pointers */
             int j;
@@ -495,12 +517,6 @@ lp_setup_set_sampler_textures( struct lp_setup_context *setup,
             jit_tex->row_stride[0] = lp_tex->stride[0];
             assert(jit_tex->data[0]);
          }
-
-         /* the scene references this texture */
-         {
-            struct lp_scene *scene = lp_setup_get_current_scene(setup);
-            lp_scene_texture_reference(scene, tex);
-         }
       }
    }
 
@@ -635,6 +651,7 @@ lp_setup_update_state( struct lp_setup_context *setup )
           * the new, current state.  So allocate a new lp_rast_state object
           * and append it to the bin's setup data buffer.
           */
+         uint i;
          struct lp_rast_state *stored =
             (struct lp_rast_state *) lp_scene_alloc(scene, sizeof *stored);
          if(stored) {
@@ -648,6 +665,14 @@ lp_setup_update_state( struct lp_setup_context *setup )
                                        lp_rast_set_state, 
                                        lp_rast_arg_state(setup->fs.stored) );
          }
+
+         /* The scene now references the textures in the rasterization
+          * state record.  Note that now.
+          */
+         for (i = 0; i < Elements(setup->fs.current_tex); i++) {
+            if (setup->fs.current_tex[i])
+               lp_scene_texture_reference(scene, setup->fs.current_tex[i]);
+         }
       }
    }
 
@@ -663,8 +688,14 @@ lp_setup_update_state( struct lp_setup_context *setup )
 void 
 lp_setup_destroy( struct lp_setup_context *setup )
 {
+   uint i;
+
    reset_context( setup );
 
+   for (i = 0; i < Elements(setup->fs.current_tex); i++) {
+      pipe_texture_reference(&setup->fs.current_tex[i], NULL);
+   }
+
    pipe_buffer_reference(&setup->constants.current, NULL);
 
    /* free the scenes in the 'empty' queue */
index be1bf96f12d5719945a2f81cc8cec12ec322264c..dbfc1bf8d4cab1808f29486b10c5055ec47aeba0 100644 (file)
@@ -112,6 +112,10 @@ void
 lp_setup_set_alpha_ref_value( struct lp_setup_context *setup,
                               float alpha_ref_value );
 
+void
+lp_setup_set_stencil_ref_values( struct lp_setup_context *setup,
+                                 const ubyte refs[2] );
+
 void
 lp_setup_set_blend_color( struct lp_setup_context *setup,
                           const struct pipe_blend_color *blend_color );
@@ -121,8 +125,9 @@ lp_setup_set_scissor( struct lp_setup_context *setup,
                       const struct pipe_scissor_state *scissor );
 
 void
-lp_setup_set_sampler_textures( struct lp_setup_context *setup,
-                               unsigned num, struct pipe_texture **texture);
+lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
+                                    unsigned num,
+                                    struct pipe_sampler_view **views);
 
 unsigned
 lp_setup_is_texture_referenced( const struct lp_setup_context *setup,
index 464fb369840260bd92205ec132dd45187dee1bd1..ca0dafab62782c323e046448a77158e7dd938716 100644 (file)
@@ -111,6 +111,7 @@ struct lp_setup_context
 
       const struct lp_rast_state *stored; /**< what's in the scene */
       struct lp_rast_state current;  /**< currently set state */
+      struct pipe_texture *current_tex[PIPE_MAX_SAMPLERS];
    } fs;
 
    /** fragment shader constants */
index ac6264dc73ec58a09e773690050be4bb0f6c26bc..ce689d3d568ca7c3794764a139ae8fffe74e1a5b 100644 (file)
@@ -361,6 +361,8 @@ do_triangle_ccw(struct lp_setup_context *setup,
     */
    setup_tri_coefficients( setup, tri, oneoverarea, v1, v2, v3, frontfacing );
 
+   tri->inputs.facing = frontfacing ? 1.0F : -1.0F;
+
    /* half-edge constants, will be interated over the whole render target.
     */
    tri->c1 = tri->dy12 * x1 - tri->dx12 * y1;
index a5a1a72074258b71cb86cd4661a3257ff9b227c9..74ebf90d5803d928d676087a6aa8ac7850553126 100644 (file)
@@ -31,7 +31,7 @@
 #ifndef LP_STATE_H
 #define LP_STATE_H
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 #include "pipe/p_state.h"
 #include "tgsi/tgsi_scan.h"
@@ -50,7 +50,7 @@
 #define LP_NEW_DEPTH_STENCIL_ALPHA 0x100
 #define LP_NEW_CONSTANTS     0x200
 #define LP_NEW_SAMPLER       0x400
-#define LP_NEW_TEXTURE       0x800
+#define LP_NEW_SAMPLER_VIEW  0x800
 #define LP_NEW_VERTEX        0x1000
 #define LP_NEW_VS            0x2000
 #define LP_NEW_QUERY         0x4000
@@ -67,6 +67,7 @@ struct lp_fragment_shader;
 struct lp_fragment_shader_variant_key
 {
    struct pipe_depth_state depth;
+   struct pipe_stencil_state stencil[2];
    struct pipe_alpha_state alpha;
    struct pipe_blend_state blend;
    enum pipe_format zsbuf_format;
@@ -192,14 +193,23 @@ void llvmpipe_set_polygon_stipple( struct pipe_context *,
 void llvmpipe_set_scissor_state( struct pipe_context *,
                                  const struct pipe_scissor_state * );
 
-void llvmpipe_set_sampler_textures( struct pipe_context *,
-                                    unsigned num,
-                                    struct pipe_texture ** );
+void llvmpipe_set_fragment_sampler_views(struct pipe_context *,
+                                         unsigned num,
+                                         struct pipe_sampler_view **);
 
 void
-llvmpipe_set_vertex_sampler_textures(struct pipe_context *,
-                                     unsigned num_textures,
-                                     struct pipe_texture **);
+llvmpipe_set_vertex_sampler_views(struct pipe_context *,
+                                  unsigned num,
+                                  struct pipe_sampler_view **);
+
+struct pipe_sampler_view *
+llvmpipe_create_sampler_view(struct pipe_context *pipe,
+                            struct pipe_texture *texture,
+                            const struct pipe_sampler_view *templ);
+
+void
+llvmpipe_sampler_view_destroy(struct pipe_context *pipe,
+                              struct pipe_sampler_view *view);
 
 void llvmpipe_set_viewport_state( struct pipe_context *,
                                   const struct pipe_viewport_state * );
index bdd906e1a73922c9291bb2cd6d354b2e04d0bb17..777871638f65345fdda204fc0568a0e5500c09dd 100644 (file)
@@ -150,7 +150,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
     */
    if (llvmpipe->tex_timestamp != lp_screen->timestamp) {
       llvmpipe->tex_timestamp = lp_screen->timestamp;
-      llvmpipe->dirty |= LP_NEW_TEXTURE;
+      llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
    }
       
    if (llvmpipe->dirty & (LP_NEW_RASTERIZER |
@@ -164,7 +164,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
                           LP_NEW_DEPTH_STENCIL_ALPHA |
                           LP_NEW_RASTERIZER |
                           LP_NEW_SAMPLER |
-                          LP_NEW_TEXTURE))
+                          LP_NEW_SAMPLER_VIEW))
       llvmpipe_update_fs( llvmpipe );
 
    if (llvmpipe->dirty & LP_NEW_BLEND_COLOR)
@@ -174,18 +174,21 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
    if (llvmpipe->dirty & LP_NEW_SCISSOR)
       lp_setup_set_scissor(llvmpipe->setup, &llvmpipe->scissor);
 
-   if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA)
+   if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA) {
       lp_setup_set_alpha_ref_value(llvmpipe->setup, 
                                    llvmpipe->depth_stencil->alpha.ref_value);
+      lp_setup_set_stencil_ref_values(llvmpipe->setup,
+                                      llvmpipe->stencil_ref.ref_value);
+   }
 
    if (llvmpipe->dirty & LP_NEW_CONSTANTS)
       lp_setup_set_fs_constants(llvmpipe->setup, 
                                 llvmpipe->constants[PIPE_SHADER_FRAGMENT]);
 
-   if (llvmpipe->dirty & LP_NEW_TEXTURE)
-      lp_setup_set_sampler_textures(llvmpipe->setup, 
-                                    llvmpipe->num_textures,
-                                    llvmpipe->texture);
+   if (llvmpipe->dirty & LP_NEW_SAMPLER_VIEW)
+      lp_setup_set_fragment_sampler_views(llvmpipe->setup, 
+                                          llvmpipe->num_fragment_sampler_views,
+                                          llvmpipe->fragment_sampler_views);
 
    llvmpipe->dirty = 0;
 }
index 9a8de0edfdaadfb026b05c3e58e7609077810306..7bbf348e0b84bc4fbffe2af68a4263d67e134286 100644 (file)
@@ -138,20 +138,22 @@ generate_pos0(LLVMBuilderRef builder,
 
 
 /**
- * Generate the depth test.
+ * Generate the depth /stencil test code.
  */
 static void
-generate_depth(LLVMBuilderRef builder,
-               const struct lp_fragment_shader_variant_key *key,
-               struct lp_type src_type,
-               struct lp_build_mask_context *mask,
-               LLVMValueRef src,
-               LLVMValueRef dst_ptr)
+generate_depth_stencil(LLVMBuilderRef builder,
+                       const struct lp_fragment_shader_variant_key *key,
+                       struct lp_type src_type,
+                       struct lp_build_mask_context *mask,
+                       LLVMValueRef stencil_refs[2],
+                       LLVMValueRef src,
+                       LLVMValueRef dst_ptr,
+                       LLVMValueRef facing)
 {
    const struct util_format_description *format_desc;
    struct lp_type dst_type;
 
-   if(!key->depth.enabled)
+   if (!key->depth.enabled && !key->stencil[0].enabled && !key->stencil[1].enabled)
       return;
 
    format_desc = util_format_description(key->zsbuf_format);
@@ -178,19 +180,22 @@ generate_depth(LLVMBuilderRef builder,
    assert(dst_type.width == src_type.width);
    assert(dst_type.length == src_type.length);
 
+   /* Convert fragment Z from float to integer */
    lp_build_conv(builder, src_type, dst_type, &src, 1, &src, 1);
 
    dst_ptr = LLVMBuildBitCast(builder,
                               dst_ptr,
                               LLVMPointerType(lp_build_vec_type(dst_type), 0), "");
-
-   lp_build_depth_test(builder,
-                       &key->depth,
-                       dst_type,
-                       format_desc,
-                       mask,
-                       src,
-                       dst_ptr);
+   lp_build_depth_stencil_test(builder,
+                               &key->depth,
+                               key->stencil,
+                               dst_type,
+                               format_desc,
+                               mask,
+                               stencil_refs,
+                               src,
+                               dst_ptr,
+                               facing);
 }
 
 
@@ -252,7 +257,7 @@ generate_tri_edge_mask(LLVMBuilderRef builder,
                                    LLVMConstInt(LLVMInt32Type(), INT_MIN, 0),
                                    "");
 
-      in_out_mask = lp_build_int_const_scalar(i32_type, ~0);
+      in_out_mask = lp_build_const_int_vec(i32_type, ~0);
 
 
       lp_build_flow_scope_declare(flow, &in_out_mask);
@@ -367,7 +372,7 @@ build_int32_vec_const(int value)
    i32_type.norm = FALSE;     /* values are not normalized */
    i32_type.width = 32;       /* 32-bit int values */
    i32_type.length = 4;       /* 4 elements per vector */
-   return lp_build_int_const_scalar(i32_type, value);
+   return lp_build_const_int_vec(i32_type, value);
 }
 
 
@@ -390,6 +395,7 @@ generate_fs(struct llvmpipe_context *lp,
             LLVMValueRef *pmask,
             LLVMValueRef (*color)[4],
             LLVMValueRef depth_ptr,
+            LLVMValueRef facing,
             unsigned do_tri_test,
             LLVMValueRef c0,
             LLVMValueRef c1,
@@ -405,15 +411,19 @@ generate_fs(struct llvmpipe_context *lp,
    LLVMValueRef consts_ptr;
    LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
    LLVMValueRef z = interp->pos[2];
+   LLVMValueRef stencil_refs[2];
    struct lp_build_flow_context *flow;
    struct lp_build_mask_context mask;
-   boolean early_depth_test;
+   boolean early_depth_stencil_test;
    unsigned attrib;
    unsigned chan;
    unsigned cbuf;
 
    assert(i < 4);
 
+   stencil_refs[0] = lp_jit_context_stencil_ref_front_value(builder, context_ptr);
+   stencil_refs[1] = lp_jit_context_stencil_ref_back_value(builder, context_ptr);
+
    elem_type = lp_build_elem_type(type);
    vec_type = lp_build_vec_type(type);
    int_vec_type = lp_build_int_vec_type(type);
@@ -453,16 +463,16 @@ generate_fs(struct llvmpipe_context *lp,
       lp_build_mask_update(&mask, smask);
    }
 
-   early_depth_test =
-      key->depth.enabled &&
+   early_depth_stencil_test =
+      (key->depth.enabled || key->stencil[0].enabled) &&
       !key->alpha.enabled &&
       !shader->info.uses_kill &&
       !shader->info.writes_z;
 
-   if(early_depth_test)
-      generate_depth(builder, key,
-                     type, &mask,
-                     z, depth_ptr);
+   if (early_depth_stencil_test)
+      generate_depth_stencil(builder, key,
+                             type, &mask,
+                             stencil_refs, z, depth_ptr, facing);
 
    lp_build_tgsi_soa(builder, tokens, type, &mask,
                      consts_ptr, interp->pos, interp->inputs,
@@ -506,10 +516,10 @@ generate_fs(struct llvmpipe_context *lp,
       }
    }
 
-   if(!early_depth_test)
-      generate_depth(builder, key,
-                     type, &mask,
-                     z, depth_ptr);
+   if (!early_depth_stencil_test)
+      generate_depth_stencil(builder, key,
+                             type, &mask,
+                             stencil_refs, z, depth_ptr, facing);
 
    lp_build_mask_end(&mask);
 
@@ -585,6 +595,20 @@ generate_blend(const struct pipe_blend_state *blend,
 }
 
 
+/** casting function to avoid compiler warnings */
+static lp_jit_frag_func
+cast_voidptr_to_lp_jit_frag_func(void *p)
+{
+   union {
+      void *v;
+      lp_jit_frag_func f;
+   } tmp;
+   assert(sizeof(tmp.v) == sizeof(tmp.f));
+   tmp.v = p;
+   return tmp.f;
+}
+
+
 /**
  * Generate the runtime callable function for the whole fragment pipeline.
  * Note that the function which we generate operates on a block of 16
@@ -606,7 +630,7 @@ generate_fragment(struct llvmpipe_context *lp,
    LLVMTypeRef fs_int_vec_type;
    LLVMTypeRef blend_vec_type;
    LLVMTypeRef blend_int_vec_type;
-   LLVMTypeRef arg_types[14];
+   LLVMTypeRef arg_types[15];
    LLVMTypeRef func_type;
    LLVMTypeRef int32_vec4_type = lp_build_int32_vec4_type();
    LLVMValueRef context_ptr;
@@ -629,6 +653,7 @@ generate_fragment(struct llvmpipe_context *lp,
    LLVMValueRef blend_mask;
    LLVMValueRef blend_in_color[NUM_CHANNELS];
    LLVMValueRef function;
+   LLVMValueRef facing;
    unsigned num_fs;
    unsigned i;
    unsigned chan;
@@ -668,20 +693,21 @@ generate_fragment(struct llvmpipe_context *lp,
    arg_types[0] = screen->context_ptr_type;            /* context */
    arg_types[1] = LLVMInt32Type();                     /* x */
    arg_types[2] = LLVMInt32Type();                     /* y */
-   arg_types[3] = LLVMPointerType(fs_elem_type, 0);    /* a0 */
-   arg_types[4] = LLVMPointerType(fs_elem_type, 0);    /* dadx */
-   arg_types[5] = LLVMPointerType(fs_elem_type, 0);    /* dady */
-   arg_types[6] = LLVMPointerType(LLVMPointerType(blend_vec_type, 0), 0);  /* color */
-   arg_types[7] = LLVMPointerType(fs_int_vec_type, 0); /* depth */
-   arg_types[8] = LLVMInt32Type();                     /* c0 */
-   arg_types[9] = LLVMInt32Type();                     /* c1 */
-   arg_types[10] = LLVMInt32Type();                    /* c2 */
+   arg_types[3] = LLVMFloatType();                     /* facing */
+   arg_types[4] = LLVMPointerType(fs_elem_type, 0);    /* a0 */
+   arg_types[5] = LLVMPointerType(fs_elem_type, 0);    /* dadx */
+   arg_types[6] = LLVMPointerType(fs_elem_type, 0);    /* dady */
+   arg_types[7] = LLVMPointerType(LLVMPointerType(blend_vec_type, 0), 0);  /* color */
+   arg_types[8] = LLVMPointerType(fs_int_vec_type, 0); /* depth */
+   arg_types[9] = LLVMInt32Type();                     /* c0 */
+   arg_types[10] = LLVMInt32Type();                    /* c1 */
+   arg_types[11] = LLVMInt32Type();                    /* c2 */
    /* Note: the step arrays are built as int32[16] but we interpret
     * them here as int32_vec4[4].
     */
-   arg_types[11] = LLVMPointerType(int32_vec4_type, 0);/* step0 */
-   arg_types[12] = LLVMPointerType(int32_vec4_type, 0);/* step1 */
-   arg_types[13] = LLVMPointerType(int32_vec4_type, 0);/* step2 */
+   arg_types[12] = LLVMPointerType(int32_vec4_type, 0);/* step0 */
+   arg_types[13] = LLVMPointerType(int32_vec4_type, 0);/* step1 */
+   arg_types[14] = LLVMPointerType(int32_vec4_type, 0);/* step2 */
 
    func_type = LLVMFunctionType(LLVMVoidType(), arg_types, Elements(arg_types), 0);
 
@@ -701,17 +727,18 @@ generate_fragment(struct llvmpipe_context *lp,
    context_ptr  = LLVMGetParam(function, 0);
    x            = LLVMGetParam(function, 1);
    y            = LLVMGetParam(function, 2);
-   a0_ptr       = LLVMGetParam(function, 3);
-   dadx_ptr     = LLVMGetParam(function, 4);
-   dady_ptr     = LLVMGetParam(function, 5);
-   color_ptr_ptr = LLVMGetParam(function, 6);
-   depth_ptr    = LLVMGetParam(function, 7);
-   c0           = LLVMGetParam(function, 8);
-   c1           = LLVMGetParam(function, 9);
-   c2           = LLVMGetParam(function, 10);
-   step0_ptr    = LLVMGetParam(function, 11);
-   step1_ptr    = LLVMGetParam(function, 12);
-   step2_ptr    = LLVMGetParam(function, 13);
+   facing       = LLVMGetParam(function, 3);
+   a0_ptr       = LLVMGetParam(function, 4);
+   dadx_ptr     = LLVMGetParam(function, 5);
+   dady_ptr     = LLVMGetParam(function, 6);
+   color_ptr_ptr = LLVMGetParam(function, 7);
+   depth_ptr    = LLVMGetParam(function, 8);
+   c0           = LLVMGetParam(function, 9);
+   c1           = LLVMGetParam(function, 10);
+   c2           = LLVMGetParam(function, 11);
+   step0_ptr    = LLVMGetParam(function, 12);
+   step1_ptr    = LLVMGetParam(function, 13);
+   step2_ptr    = LLVMGetParam(function, 14);
 
    lp_build_name(context_ptr, "context");
    lp_build_name(x, "x");
@@ -770,6 +797,7 @@ generate_fragment(struct llvmpipe_context *lp,
                   &fs_mask[i], /* output */
                   out_color,
                   depth_ptr_i,
+                  facing,
                   do_tri_test,
                   c0, c1, c2,
                   step0_ptr, step1_ptr, step2_ptr);
@@ -845,10 +873,14 @@ generate_fragment(struct llvmpipe_context *lp,
    /*
     * Translate the LLVM IR into machine code.
     */
-   variant->jit_function[do_tri_test] = (lp_jit_frag_func)LLVMGetPointerToGlobal(screen->engine, function);
+   {
+      void *f = LLVMGetPointerToGlobal(screen->engine, function);
+
+      variant->jit_function[do_tri_test] = cast_voidptr_to_lp_jit_frag_func(f);
 
-   if (LP_DEBUG & DEBUG_ASM)
-      lp_disassemble(variant->jit_function[do_tri_test]);
+      if (LP_DEBUG & DEBUG_ASM)
+         lp_disassemble(f);
+   }
 }
 
 
@@ -1054,10 +1086,15 @@ make_variant_key(struct llvmpipe_context *lp,
 
    memset(key, 0, sizeof *key);
 
-   if(lp->framebuffer.zsbuf &&
-      lp->depth_stencil->depth.enabled) {
-      key->zsbuf_format = lp->framebuffer.zsbuf->format;
-      memcpy(&key->depth, &lp->depth_stencil->depth, sizeof key->depth);
+   if (lp->framebuffer.zsbuf) {
+      if (lp->depth_stencil->depth.enabled) {
+         key->zsbuf_format = lp->framebuffer.zsbuf->format;
+         memcpy(&key->depth, &lp->depth_stencil->depth, sizeof key->depth);
+      }
+      if (lp->depth_stencil->stencil[0].enabled) {
+         key->zsbuf_format = lp->framebuffer.zsbuf->format;
+         memcpy(&key->stencil, &lp->depth_stencil->stencil, sizeof key->stencil);
+      }
    }
 
    key->alpha.enabled = lp->depth_stencil->alpha.enabled;
@@ -1094,7 +1131,7 @@ make_variant_key(struct llvmpipe_context *lp,
 
    for(i = 0; i < PIPE_MAX_SAMPLERS; ++i)
       if(shader->info.file_mask[TGSI_FILE_SAMPLER] & (1 << i))
-         lp_sampler_static_state(&key->sampler[i], lp->texture[i], lp->sampler[i]);
+         lp_sampler_static_state(&key->sampler[i], lp->fragment_sampler_views[i]->texture, lp->sampler[i]);
 }
 
 
@@ -1140,6 +1177,7 @@ llvmpipe_update_fs(struct llvmpipe_context *lp)
    opaque = !key.blend.logicop_enable &&
             !key.blend.rt[0].blend_enable &&
             key.blend.rt[0].colormask == 0xf &&
+            !key.stencil[0].enabled &&
             !key.alpha.enabled &&
             !key.depth.enabled &&
             !key.scissor &&
@@ -1147,7 +1185,7 @@ llvmpipe_update_fs(struct llvmpipe_context *lp)
             ? TRUE : FALSE;
 
    lp_setup_set_fs_functions(lp->setup, 
-                             shader->current->jit_function[0],
-                             shader->current->jit_function[1],
+                             shader->current->jit_function[RAST_WHOLE],
+                             shader->current->jit_function[RAST_EDGE_TEST],
                              opaque);
 }
index b30a0757768fe78f8ad23d95e8b5971a43a56df5..2645441b58c9460a108bd296dffeab45687d2394 100644 (file)
@@ -105,8 +105,9 @@ llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
 
 
 void
-llvmpipe_set_sampler_textures(struct pipe_context *pipe,
-                              unsigned num, struct pipe_texture **texture)
+llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe,
+                                    unsigned num,
+                                    struct pipe_sampler_view **views)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    uint i;
@@ -114,51 +115,79 @@ llvmpipe_set_sampler_textures(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == llvmpipe->num_textures &&
-       !memcmp(llvmpipe->texture, texture, num * sizeof(struct pipe_texture *)))
+   if (num == llvmpipe->num_fragment_sampler_views &&
+       !memcmp(llvmpipe->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
       return;
 
    draw_flush(llvmpipe->draw);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      struct pipe_texture *tex = i < num ? texture[i] : NULL;
+      struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      pipe_texture_reference(&llvmpipe->texture[i], tex);
+      pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], view);
    }
 
-   llvmpipe->num_textures = num;
+   llvmpipe->num_fragment_sampler_views = num;
 
-   llvmpipe->dirty |= LP_NEW_TEXTURE;
+   llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
 }
 
 
 void
-llvmpipe_set_vertex_sampler_textures(struct pipe_context *pipe,
-                                     unsigned num_textures,
-                                     struct pipe_texture **textures)
+llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe,
+                                  unsigned num,
+                                  struct pipe_sampler_view **views)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    uint i;
 
-   assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS);
+   assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
 
    /* Check for no-op */
-   if (num_textures == llvmpipe->num_vertex_textures &&
-       !memcmp(llvmpipe->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) {
+   if (num == llvmpipe->num_vertex_sampler_views &&
+       !memcmp(llvmpipe->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
       return;
    }
 
    draw_flush(llvmpipe->draw);
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      struct pipe_texture *tex = i < num_textures ? textures[i] : NULL;
+      struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      pipe_texture_reference(&llvmpipe->vertex_textures[i], tex);
+      pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], view);
    }
 
-   llvmpipe->num_vertex_textures = num_textures;
+   llvmpipe->num_vertex_sampler_views = num;
 
-   llvmpipe->dirty |= LP_NEW_TEXTURE;
+   llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
+}
+
+
+struct pipe_sampler_view *
+llvmpipe_create_sampler_view(struct pipe_context *pipe,
+                            struct pipe_texture *texture,
+                            const struct pipe_sampler_view *templ)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
+
+   return view;
+}
+
+
+void
+llvmpipe_sampler_view_destroy(struct pipe_context *pipe,
+                              struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
 }
 
 
index 1df9897898806d1b6b00c520e9093ab2c5d6f1ca..338a04a4878a407ae9c8c69943196b90c41ecea3 100644 (file)
@@ -41,7 +41,7 @@
 #include <stdio.h>
 #include <float.h>
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 #include <llvm-c/Analysis.h>
 #include <llvm-c/ExecutionEngine.h>
 #include <llvm-c/Target.h>
index 2c4d7fb6e1456239bdac55e3854f2f727713abe8..fb595893bd012c6dd2d6107396bc5274d89e0e62 100644 (file)
@@ -29,7 +29,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 #include <llvm-c/Analysis.h>
 #include <llvm-c/ExecutionEngine.h>
 #include <llvm-c/Target.h>
diff --git a/src/gallium/drivers/llvmpipe/lp_test_printf.c b/src/gallium/drivers/llvmpipe/lp_test_printf.c
new file mode 100644 (file)
index 0000000..e5e5925
--- /dev/null
@@ -0,0 +1,162 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 <stdlib.h>
+#include <stdio.h>
+
+#include "gallivm/lp_bld.h"
+#include "gallivm/lp_bld_printf.h"
+
+#include <llvm-c/Analysis.h>
+#include <llvm-c/ExecutionEngine.h>
+#include <llvm-c/Target.h>
+#include <llvm-c/Transforms/Scalar.h>
+
+#include "lp_test.h"
+
+
+struct printf_test_case {
+};
+
+void
+write_tsv_header(FILE *fp)
+{
+   fprintf(fp,
+           "result\t"
+           "format\n");
+
+   fflush(fp);
+}
+
+
+
+typedef void (*test_printf_t)(int i);
+
+static LLVMValueRef
+add_printf_test(LLVMModuleRef module)
+{
+   LLVMTypeRef args[1] = { LLVMIntType(32) };
+   LLVMValueRef func = LLVMAddFunction(module, "test_printf", LLVMFunctionType(LLVMVoidType(), args, 1, 0));
+   LLVMBuilderRef builder = LLVMCreateBuilder();
+   LLVMBasicBlockRef block = LLVMAppendBasicBlock(func, "entry");
+
+   LLVMSetFunctionCallConv(func, LLVMCCallConv);
+
+   LLVMPositionBuilderAtEnd(builder, block);
+   lp_build_printf(builder, "hello, world\n");
+   lp_build_printf(builder, "print 5 6: %d %d\n", LLVMConstInt(LLVMInt32Type(), 5, 0),
+                               LLVMConstInt(LLVMInt32Type(), 6, 0));
+   LLVMBuildRetVoid(builder);
+   LLVMDisposeBuilder(builder);
+   return func;
+}
+
+
+PIPE_ALIGN_STACK
+static boolean
+test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase)
+{
+   LLVMModuleRef module = NULL;
+   LLVMValueRef test = NULL;
+   LLVMExecutionEngineRef engine = NULL;
+   LLVMModuleProviderRef provider = NULL;
+   LLVMPassManagerRef pass = NULL;
+   char *error = NULL;
+   test_printf_t test_printf;
+   float unpacked[4];
+   unsigned packed;
+   boolean success = TRUE;
+
+   module = LLVMModuleCreateWithName("test");
+
+   test = add_printf_test(module);
+
+   if(LLVMVerifyModule(module, LLVMPrintMessageAction, &error)) {
+      LLVMDumpModule(module);
+      abort();
+   }
+   LLVMDisposeMessage(error);
+
+   provider = LLVMCreateModuleProviderForExistingModule(module);
+   if (LLVMCreateJITCompiler(&engine, provider, 1, &error)) {
+      fprintf(stderr, "%s\n", error);
+      LLVMDisposeMessage(error);
+      abort();
+   }
+
+#if 0
+   pass = LLVMCreatePassManager();
+   LLVMAddTargetData(LLVMGetExecutionEngineTargetData(engine), pass);
+   /* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
+    * but there are more on SVN. */
+   LLVMAddConstantPropagationPass(pass);
+   LLVMAddInstructionCombiningPass(pass);
+   LLVMAddPromoteMemoryToRegisterPass(pass);
+   LLVMAddGVNPass(pass);
+   LLVMAddCFGSimplificationPass(pass);
+   LLVMRunPassManager(pass, module);
+#else
+   (void)pass;
+#endif
+
+   test_printf = (test_printf_t)LLVMGetPointerToGlobal(engine, test);
+
+   memset(unpacked, 0, sizeof unpacked);
+   packed = 0;
+
+
+   // LLVMDumpModule(module);
+
+   test_printf(0);
+
+   LLVMFreeMachineCodeForFunction(engine, test);
+
+   LLVMDisposeExecutionEngine(engine);
+   if(pass)
+      LLVMDisposePassManager(pass);
+
+   return success;
+}
+
+
+boolean
+test_all(unsigned verbose, FILE *fp)
+{
+   bool success = TRUE;
+
+   test_printf(verbose, fp, NULL);
+
+   return success;
+}
+
+
+boolean
+test_some(unsigned verbose, FILE *fp, unsigned long n)
+{
+   return test_all(verbose, fp);
+}
index 799df182b6a0552be0e1bc849ad0289e184303b7..1228a831f3bd3731cc82c89523e9919f1b393fce 100644 (file)
@@ -29,7 +29,7 @@
 #define LP_TEX_SAMPLE_H
 
 
-#include "os/os_llvm.h"
+#include "gallivm/lp_bld.h"
 
 
 struct lp_sampler_static_state;
index 662508af61a32e97e4f0564e973b622915413fbb..4715cfe4f62a8d58cc749cbd0f0986cd68b5fb83 100644 (file)
@@ -105,7 +105,7 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base,
    /* context[0] */
    indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
    /* context[0].textures */
-   indices[1] = LLVMConstInt(LLVMInt32Type(), LP_JIT_CONTEXT_TEXTURES_INDEX, 0);
+   indices[1] = LLVMConstInt(LLVMInt32Type(), LP_JIT_CTX_TEXTURES, 0);
    /* context[0].textures[unit] */
    indices[2] = LLVMConstInt(LLVMInt32Type(), unit, 0);
    /* context[0].textures[unit].member */
index 9a85a42897d0dc5ca16c5da5263a89f12cc996c1..8137f29af52d2194c65c9a5bb0ee851bb98eb044 100644 (file)
@@ -103,6 +103,7 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
    unsigned height = align(lpt->base.height0, TILE_SIZE);
 
    lpt->dt = winsys->displaytarget_create(winsys,
+                                          lpt->base.tex_usage,
                                           lpt->base.format,
                                           width, height,
                                           16,
@@ -250,6 +251,51 @@ llvmpipe_texture_unmap(struct pipe_texture *texture,
 }
 
 
+static struct pipe_texture *
+llvmpipe_texture_from_handle(struct pipe_screen *screen,
+                             const struct pipe_texture *template,
+                             struct winsys_handle *whandle)
+{
+   struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
+   struct llvmpipe_texture *lpt = CALLOC_STRUCT(llvmpipe_texture);
+   if (!lpt)
+      return NULL;
+
+   lpt->base = *template;
+   pipe_reference_init(&lpt->base.reference, 1);
+   lpt->base.screen = screen;
+
+   lpt->dt = winsys->displaytarget_from_handle(winsys,
+                                               template,
+                                               whandle,
+                                               &lpt->stride[0]);
+   if (!lpt->dt)
+      goto fail;
+
+   return &lpt->base;
+
+ fail:
+   FREE(lpt);
+   return NULL;
+}
+
+
+static boolean
+llvmpipe_texture_get_handle(struct pipe_screen *screen,
+                            struct pipe_texture *pt,
+                            struct winsys_handle *whandle)
+{
+   struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
+   struct llvmpipe_texture *lpt = llvmpipe_texture(pt);
+
+   assert(lpt->dt);
+   if (!lpt->dt)
+      return FALSE;
+
+   return winsys->displaytarget_get_handle(winsys, lpt->dt, whandle);
+}
+
+
 static struct pipe_surface *
 llvmpipe_get_tex_surface(struct pipe_screen *screen,
                          struct pipe_texture *pt,
@@ -418,6 +464,8 @@ llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen)
 {
    screen->texture_create = llvmpipe_texture_create;
    screen->texture_destroy = llvmpipe_texture_destroy;
+   screen->texture_from_handle = llvmpipe_texture_from_handle;
+   screen->texture_get_handle = llvmpipe_texture_get_handle;
 
    screen->get_tex_surface = llvmpipe_get_tex_surface;
    screen->tex_surface_destroy = llvmpipe_tex_surface_destroy;
index 8afc95c9fc6b7942ce9e5bd974244f240861fffb..5447904e9ca11a7babff49b33e438335ba3cfbb8 100644 (file)
@@ -35,7 +35,10 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct pipe_framebuffer_state *fb = &nv50->framebuffer;
        unsigned mode = 0, i;
+       const unsigned dirty = nv50->dirty;
 
+       /* don't need NEW_BLEND, NV50TCL_COLOR_MASK doesn't affect CLEAR_BUFFERS */
+       nv50->dirty &= NV50_NEW_FRAMEBUFFER | NV50_NEW_SCISSOR;
        if (!nv50_state_validate(nv50, 64))
                return;
 
@@ -64,5 +67,6 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
                BEGIN_RING(chan, tesla, NV50TCL_CLEAR_BUFFERS, 1);
                OUT_RING  (chan, (i << 6) | 0x3c);
        }
+       nv50->dirty = dirty;
 }
 
index 1743f6fb3941e5d0bdfd5ef2d97af844177164c6..bc7831d9aca4c7fa599d82c5ac3556a1afaf5dda 100644 (file)
@@ -72,12 +72,23 @@ struct nv50_sampler_stateobj {
        unsigned tsc[8];
 };
 
+struct nv50_sampler_view {
+       struct pipe_sampler_view pipe;
+       uint32_t tic[8];
+};
+
 struct nv50_vtxelt_stateobj {
        struct pipe_vertex_element pipe[16];
        unsigned num_elements;
        uint32_t hw[16];
 };
 
+static INLINE struct nv50_sampler_view *
+nv50_sampler_view(struct pipe_sampler_view *view)
+{
+       return (struct nv50_sampler_view *)view;
+}
+
 static INLINE unsigned
 get_tile_height(uint32_t tile_mode)
 {
@@ -126,7 +137,7 @@ struct nv50_state {
        struct nouveau_stateobj *hw[64];
        uint64_t hw_dirty;
 
-       unsigned miptree_nr[PIPE_SHADER_TYPES];
+       unsigned sampler_view_nr[3];
        struct nouveau_stateobj *vtxbuf;
        struct nouveau_stateobj *vtxattr;
        unsigned vtxelt_nr;
@@ -158,10 +169,10 @@ struct nv50_context {
        struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
        unsigned vtxbuf_nr;
        struct nv50_vtxelt_stateobj *vtxelt;
-       struct nv50_sampler_stateobj *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
-       unsigned sampler_nr[PIPE_SHADER_TYPES];
-       struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
-       unsigned miptree_nr[PIPE_SHADER_TYPES];
+       struct nv50_sampler_stateobj *sampler[3][PIPE_MAX_SAMPLERS];
+       unsigned sampler_nr[3];
+       struct pipe_sampler_view *sampler_views[3][PIPE_MAX_SAMPLERS];
+       unsigned sampler_view_nr[3];
 
        unsigned vbo_fifo;
 };
@@ -243,6 +254,7 @@ extern void nv50_so_init_sifc(struct nv50_context *nv50,
                              unsigned offset, unsigned size);
 
 /* nv50_tex.c */
+extern boolean nv50_tex_construct(struct nv50_sampler_view *view);
 extern void nv50_tex_relocs(struct nv50_context *);
 extern struct nouveau_stateobj *nv50_tex_validate(struct nv50_context *);
 
index c857816b31a70a2cad7063aba3a1a3c78fa3d89c..d7e06c93272d5bfcc026258dffa08abdc9b5dca0 100644 (file)
@@ -3762,7 +3762,7 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                        p->cfg.in[n].hw = rid = aid;
                        i = p->cfg.in[n].id;
 
-                       if (p->info.input_semantic_name[n] ==
+                       if (p->info.input_semantic_name[i] ==
                            TGSI_SEMANTIC_FACE) {
                                load_frontfacing(pc, &pc->attr[i * 4]);
                                continue;
index adf0d3b3741b3420dfdb9ec87711f56e9ac679cd..1a4606d9e25fa4d5863e999db8ffc255372e6641 100644 (file)
@@ -109,7 +109,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param)
        case PIPE_CAP_TWO_SIDED_STENCIL:
                return 1;
        case PIPE_CAP_GLSL:
-               return 0;
+               return 1;
        case PIPE_CAP_ANISOTROPIC_FILTER:
                return 1;
        case PIPE_CAP_POINT_SPRITE:
@@ -190,8 +190,6 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
                nouveau_bo_ref(NULL, &screen->tic);
        if (screen->tsc)
                nouveau_bo_ref(NULL, &screen->tsc);
-       if (screen->static_init)
-               so_ref(NULL, &screen->static_init);
 
        nouveau_notifier_free(&screen->sync);
        nouveau_grobj_free(&screen->tesla);
@@ -204,16 +202,65 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
        FREE(screen);
 }
 
+#define BGN_RELOC(ch, bo, gr, m, n, fl) \
+   OUT_RELOC(ch, bo, (n << 18) | (gr->subc << 13) | m, fl, 0, 0)
+
+void
+nv50_screen_relocs(struct nv50_screen *screen)
+{
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *tesla = screen->tesla;
+       unsigned i;
+       const unsigned rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_DUMMY;
+
+       MARK_RING (chan, 28, 26);
+
+       /* cause grobj autobind */
+       BEGIN_RING(chan, tesla, 0x0100, 1);
+       OUT_RING  (chan, 0);
+
+       BGN_RELOC (chan, screen->tic, tesla, NV50TCL_TIC_ADDRESS_HIGH, 2, rl);
+       OUT_RELOCh(chan, screen->tic, 0, rl);
+       OUT_RELOCl(chan, screen->tic, 0, rl);
+
+       BGN_RELOC (chan, screen->tsc, tesla, NV50TCL_TSC_ADDRESS_HIGH, 2, rl);
+       OUT_RELOCh(chan, screen->tsc, 0, rl);
+       OUT_RELOCl(chan, screen->tsc, 0, rl);
+
+       BGN_RELOC (chan, screen->constbuf_misc[0],
+                  tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl);
+       OUT_RELOCh(chan, screen->constbuf_misc[0], 0, rl);
+       OUT_RELOCl(chan, screen->constbuf_misc[0], 0, rl);
+       OUT_RELOC (chan, screen->constbuf_misc[0],
+                  (NV50_CB_PMISC << 16) | 0x0200, rl, 0, 0);
+
+       BGN_RELOC (chan, screen->constbuf_misc[0],
+                  tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl);
+       OUT_RELOCh(chan, screen->constbuf_misc[0], 0x200, rl);
+       OUT_RELOCl(chan, screen->constbuf_misc[0], 0x200, rl);
+       OUT_RELOC (chan, screen->constbuf_misc[0],
+                  (NV50_CB_AUX << 16) | 0x0200, rl, 0, 0);
+
+       for (i = 0; i < 3; ++i) {
+               BGN_RELOC (chan, screen->constbuf_parm[i],
+                          tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl);
+               OUT_RELOCh(chan, screen->constbuf_parm[i], 0, rl);
+               OUT_RELOCl(chan, screen->constbuf_parm[i], 0, rl);
+               OUT_RELOC (chan, screen->constbuf_parm[i],
+                          ((NV50_CB_PVP + i) << 16) | 0x0800, rl, 0, 0);
+       }
+}
+
 struct pipe_screen *
 nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
        struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen);
        struct nouveau_channel *chan;
        struct pipe_screen *pscreen;
-       struct nouveau_stateobj *so;
        unsigned chipset = dev->chipset;
        unsigned tesla_class = 0;
        int ret, i;
+       const unsigned rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD;
 
        if (!screen)
                return NULL;
@@ -296,64 +343,58 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
        }
 
        /* Static M2MF init */
-       so = so_new(1, 3, 0);
-       so_method(so, screen->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3);
-       so_data  (so, screen->sync->handle);
-       so_data  (so, chan->vram->handle);
-       so_data  (so, chan->vram->handle);
-       so_emit(chan, so);
-       so_ref (NULL, &so);
+       BEGIN_RING(chan, screen->m2mf,
+                  NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3);
+       OUT_RING  (chan, screen->sync->handle);
+       OUT_RING  (chan, chan->vram->handle);
+       OUT_RING  (chan, chan->vram->handle);
 
        /* Static 2D init */
-       so = so_new(4, 7, 0);
-       so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4);
-       so_data  (so, screen->sync->handle);
-       so_data  (so, chan->vram->handle);
-       so_data  (so, chan->vram->handle);
-       so_data  (so, chan->vram->handle);
-       so_method(so, screen->eng2d, NV50_2D_OPERATION, 1);
-       so_data  (so, NV50_2D_OPERATION_SRCCOPY);
-       so_method(so, screen->eng2d, NV50_2D_CLIP_ENABLE, 1);
-       so_data  (so, 0);
-       so_method(so, screen->eng2d, 0x0888, 1);
-       so_data  (so, 1);
-       so_emit(chan, so);
-       so_ref(NULL, &so);
+       BEGIN_RING(chan, screen->eng2d, NV50_2D_DMA_NOTIFY, 4);
+       OUT_RING  (chan, screen->sync->handle);
+       OUT_RING  (chan, chan->vram->handle);
+       OUT_RING  (chan, chan->vram->handle);
+       OUT_RING  (chan, chan->vram->handle);
+       BEGIN_RING(chan, screen->eng2d, NV50_2D_OPERATION, 1);
+       OUT_RING  (chan, NV50_2D_OPERATION_SRCCOPY);
+       BEGIN_RING(chan, screen->eng2d, NV50_2D_CLIP_ENABLE, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, screen->eng2d, 0x0888, 1);
+       OUT_RING  (chan, 1);
 
        /* Static tesla init */
-       so = so_new(47, 95, 24);
-
-       so_method(so, screen->tesla, NV50TCL_COND_MODE, 1);
-       so_data  (so, NV50TCL_COND_MODE_ALWAYS);
-       so_method(so, screen->tesla, NV50TCL_DMA_NOTIFY, 1);
-       so_data  (so, screen->sync->handle);
-       so_method(so, screen->tesla, NV50TCL_DMA_ZETA, 11);
+       BEGIN_RING(chan, screen->tesla, NV50TCL_COND_MODE, 1);
+       OUT_RING  (chan, NV50TCL_COND_MODE_ALWAYS);
+       BEGIN_RING(chan, screen->tesla, NV50TCL_DMA_NOTIFY, 1);
+       OUT_RING  (chan, screen->sync->handle);
+       BEGIN_RING(chan, screen->tesla, NV50TCL_DMA_ZETA, 11);
        for (i = 0; i < 11; i++)
-               so_data(so, chan->vram->handle);
-       so_method(so, screen->tesla, NV50TCL_DMA_COLOR(0),
-                                    NV50TCL_DMA_COLOR__SIZE);
+               OUT_RING  (chan, chan->vram->handle);
+       BEGIN_RING(chan, screen->tesla,
+                  NV50TCL_DMA_COLOR(0), NV50TCL_DMA_COLOR__SIZE);
        for (i = 0; i < NV50TCL_DMA_COLOR__SIZE; i++)
-               so_data(so, chan->vram->handle);
-       so_method(so, screen->tesla, NV50TCL_RT_CONTROL, 1);
-       so_data  (so, 1);
+               OUT_RING  (chan, chan->vram->handle);
+
+       BEGIN_RING(chan, screen->tesla, NV50TCL_RT_CONTROL, 1);
+       OUT_RING  (chan, 1);
 
        /* activate all 32 lanes (threads) in a warp */
-       so_method(so, screen->tesla, NV50TCL_WARP_HALVES, 1);
-       so_data  (so, 0x2);
-       so_method(so, screen->tesla, 0x1400, 1);
-       so_data  (so, 0xf);
+       BEGIN_RING(chan, screen->tesla, NV50TCL_WARP_HALVES, 1);
+       OUT_RING  (chan, 2);
+       BEGIN_RING(chan, screen->tesla, 0x1400, 1);
+       OUT_RING  (chan, 0xf);
 
        /* max TIC (bits 4:8) & TSC (ignored) bindings, per program type */
        for (i = 0; i < 3; ++i) {
-               so_method(so, screen->tesla, NV50TCL_TEX_LIMITS(i), 1);
-               so_data  (so, 0x54);
+               BEGIN_RING(chan, screen->tesla, NV50TCL_TEX_LIMITS(i), 1);
+               OUT_RING  (chan, 0x54);
        }
 
        /* origin is top left (set to 1 for bottom left) */
-       so_method(so, screen->tesla, NV50TCL_Y_ORIGIN_BOTTOM, 1);
-       so_data  (so, 0);
-       so_method(so, screen->tesla, NV50TCL_VP_REG_ALLOC_RESULT, 1);
-       so_data  (so, 8);
+       BEGIN_RING(chan, screen->tesla, NV50TCL_Y_ORIGIN_BOTTOM, 1);
+       OUT_RING  (chan, 0);
+       BEGIN_RING(chan, screen->tesla, NV50TCL_VP_REG_ALLOC_RESULT, 1);
+       OUT_RING  (chan, 8);
 
        /* constant buffers for immediates and VP/FP parameters */
        ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (32 * 4) * 4,
@@ -362,6 +403,14 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                nv50_screen_destroy(pscreen);
                return NULL;
        }
+       BEGIN_RING(chan, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
+       OUT_RELOCh(chan, screen->constbuf_misc[0], 0, rl);
+       OUT_RELOCl(chan, screen->constbuf_misc[0], 0, rl);
+       OUT_RING  (chan, (NV50_CB_PMISC << 16) | 0x0200);
+       BEGIN_RING(chan, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
+       OUT_RELOCh(chan, screen->constbuf_misc[0], 0x200, rl);
+       OUT_RELOCl(chan, screen->constbuf_misc[0], 0x200, rl);
+       OUT_RING  (chan, (NV50_CB_AUX << 16) | 0x0200);
 
        for (i = 0; i < 3; i++) {
                ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (256 * 4) * 4,
@@ -370,6 +419,10 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                        nv50_screen_destroy(pscreen);
                        return NULL;
                }
+               BEGIN_RING(chan, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
+               OUT_RELOCh(chan, screen->constbuf_parm[i], 0, rl);
+               OUT_RELOCl(chan, screen->constbuf_parm[i], 0, rl);
+               OUT_RING  (chan, ((NV50_CB_PVP + i) << 16) | 0x0800);
        }
 
        if (nouveau_resource_init(&screen->immd_heap[0], 0, 128) ||
@@ -381,118 +434,67 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                return NULL;
        }
 
-       /*
-       // map constant buffers:
-       //  B = buffer ID (maybe more than 1 byte)
-       //  N = CB index used in shader instruction
-       //  P = program type (0 = VP, 2 = GP, 3 = FP)
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x000BBNP1);
-       */
-
-       so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, (NV50_CB_PMISC << 16) | 0x00000200);
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x00000001 | (NV50_CB_PMISC << 12));
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x00000021 | (NV50_CB_PMISC << 12));
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x00000031 | (NV50_CB_PMISC << 12));
-
-       /* bind auxiliary constbuf to immediate data bo */
-       so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->constbuf_misc[0], (128 * 4) * 4,
-                 NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->constbuf_misc[0], (128 * 4) * 4,
-                 NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, (NV50_CB_AUX << 16) | 0x00000200);
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x00000201 | (NV50_CB_AUX << 12));
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x00000221 | (NV50_CB_AUX << 12));
-
-       so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->constbuf_parm[PIPE_SHADER_VERTEX], 0,
-                 NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->constbuf_parm[PIPE_SHADER_VERTEX], 0,
-                 NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, (NV50_CB_PVP << 16) | 0x00000800);
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x00000101 | (NV50_CB_PVP << 12));
-
-       so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->constbuf_parm[PIPE_SHADER_GEOMETRY], 0,
-                 NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->constbuf_parm[PIPE_SHADER_GEOMETRY], 0,
-                 NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, (NV50_CB_PGP << 16) | 0x00000800);
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x00000121 | (NV50_CB_PGP << 12));
-
-       so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->constbuf_parm[PIPE_SHADER_FRAGMENT], 0,
-                 NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->constbuf_parm[PIPE_SHADER_FRAGMENT], 0,
-                 NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, (NV50_CB_PFP << 16) | 0x00000800);
-       so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
-       so_data  (so, 0x00000131 | (NV50_CB_PFP << 12));
-
-       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, PIPE_SHADER_TYPES*32*32,
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 3 * 32 * (8 * 4),
                             &screen->tic);
        if (ret) {
                nv50_screen_destroy(pscreen);
                return NULL;
        }
+       BEGIN_RING(chan, screen->tesla, NV50TCL_TIC_ADDRESS_HIGH, 3);
+       OUT_RELOCh(chan, screen->tic, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
+       OUT_RELOCl(chan, screen->tic, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
+       OUT_RING  (chan, 3 * 32 - 1);
 
-       so_method(so, screen->tesla, NV50TCL_TIC_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, PIPE_SHADER_TYPES * 32 - 1);
-
-       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, PIPE_SHADER_TYPES*32*32,
+       ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 3 * 32 * (8 * 4),
                             &screen->tsc);
        if (ret) {
                nv50_screen_destroy(pscreen);
                return NULL;
        }
-
-       so_method(so, screen->tesla, NV50TCL_TSC_ADDRESS_HIGH, 3);
-       so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
-       so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
-       so_data  (so, 0x00000000); /* ignored if TSC_LINKED (0x1234) = 1 */
-
+       BEGIN_RING(chan, screen->tesla, NV50TCL_TSC_ADDRESS_HIGH, 3);
+       OUT_RELOCh(chan, screen->tsc, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
+       OUT_RELOCl(chan, screen->tsc, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
+       OUT_RING  (chan, 0); /* ignored if TSC_LINKED (0x1234) == 1 */
+
+       /* map constant buffers:
+        *  B = buffer ID (maybe more than 1 byte)
+        *  N = CB index used in shader instruction
+        *  P = program type (0 = VP, 2 = GP, 3 = FP)
+        * SET_PROGRAM_CB = 0x000BBNP1
+        */
+       BEGIN_RING_NI(chan, screen->tesla, NV50TCL_SET_PROGRAM_CB, 8);
+       /* bind immediate buffer */
+       OUT_RING  (chan, 0x001 | (NV50_CB_PMISC << 12));
+       OUT_RING  (chan, 0x021 | (NV50_CB_PMISC << 12));
+       OUT_RING  (chan, 0x031 | (NV50_CB_PMISC << 12));
+       /* bind auxiliary constbuf to immediate data bo */
+       OUT_RING  (chan, 0x201 | (NV50_CB_AUX << 12));
+       OUT_RING  (chan, 0x221 | (NV50_CB_AUX << 12));
+       /* bind parameter buffers */
+       OUT_RING  (chan, 0x101 | (NV50_CB_PVP << 12));
+       OUT_RING  (chan, 0x121 | (NV50_CB_PGP << 12));
+       OUT_RING  (chan, 0x131 | (NV50_CB_PFP << 12));
 
        /* Vertex array limits - max them out */
        for (i = 0; i < 16; i++) {
-               so_method(so, screen->tesla, NV50TCL_VERTEX_ARRAY_LIMIT_HIGH(i), 2);
-               so_data  (so, 0x000000ff);
-               so_data  (so, 0xffffffff);
+               BEGIN_RING(chan, screen->tesla,
+                          NV50TCL_VERTEX_ARRAY_LIMIT_HIGH(i), 2);
+               OUT_RING  (chan, 0x000000ff);
+               OUT_RING  (chan, 0xffffffff);
        }
 
-       so_method(so, screen->tesla, NV50TCL_DEPTH_RANGE_NEAR(0), 2);
-       so_data  (so, fui(0.0));
-       so_data  (so, fui(1.0));
+       BEGIN_RING(chan, screen->tesla, NV50TCL_DEPTH_RANGE_NEAR(0), 2);
+       OUT_RINGf (chan, 0.0f);
+       OUT_RINGf (chan, 1.0f);
 
        /* no dynamic combination of TIC & TSC entries => only BIND_TIC used */
-       so_method(so, screen->tesla, NV50TCL_LINKED_TSC, 1);
-       so_data  (so, 1);
+       BEGIN_RING(chan, screen->tesla, NV50TCL_LINKED_TSC, 1);
+       OUT_RING  (chan, 1);
 
-       so_method(so, screen->tesla, NV50TCL_EDGEFLAG_ENABLE, 1);
-       so_data  (so, 1); /* default edgeflag to TRUE */
+       BEGIN_RING(chan, screen->tesla, NV50TCL_EDGEFLAG_ENABLE, 1);
+       OUT_RING  (chan, 1); /* default edgeflag to TRUE */
 
-       so_emit(chan, so);
-       so_ref (so, &screen->static_init);
-       so_ref (NULL, &so);
-       nouveau_pushbuf_flush(chan, 0);
+       FIRE_RING (chan);
 
        screen->force_push = debug_get_bool_option("NV50_ALWAYS_PUSH", FALSE);
        return pscreen;
index ec19ea655b1ba8d40cf2ad8f2765a6c9f94a7ed1..15bd4eed3994cad8412562b1b812971f03167569 100644 (file)
@@ -27,8 +27,6 @@ struct nv50_screen {
        struct nouveau_bo *tic;
        struct nouveau_bo *tsc;
 
-       struct nouveau_stateobj *static_init;
-
        boolean force_push;
 };
 
@@ -38,4 +36,6 @@ nv50_screen(struct pipe_screen *screen)
        return (struct nv50_screen *)screen;
 }
 
+extern void nv50_screen_relocs(struct nv50_screen *);
+
 #endif
index b0e5552eff45957a838f7c47c2dfa4f2a25cc8af..c16280892850e218954c9ff75ac687bf8c3a0723 100644 (file)
@@ -238,6 +238,9 @@ nv50_sampler_state_create(struct pipe_context *pipe,
        return (void *)sso;
 }
 
+/* type == 0 for VPs, 1 for GPs, 2 for FPs, which is how the
+ * relevant tesla methods are indexed (NV50TCL_BIND_TSC etc.)
+ */
 static INLINE void
 nv50_sampler_state_bind(struct pipe_context *pipe, unsigned type,
                        unsigned nr, void **sampler)
@@ -253,13 +256,13 @@ nv50_sampler_state_bind(struct pipe_context *pipe, unsigned type,
 static void
 nv50_vp_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **s)
 {
-       nv50_sampler_state_bind(pipe, PIPE_SHADER_VERTEX, nr, s);
+       nv50_sampler_state_bind(pipe, 0, nr, s);
 }
 
 static void
 nv50_fp_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **s)
 {
-       nv50_sampler_state_bind(pipe, PIPE_SHADER_FRAGMENT, nr, s);
+       nv50_sampler_state_bind(pipe, 2, nr, s);
 }
 
 static void
@@ -269,35 +272,69 @@ nv50_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
 }
 
 static INLINE void
-nv50_set_sampler_texture(struct pipe_context *pipe, unsigned type,
-                        unsigned nr, struct pipe_texture **pt)
+nv50_set_sampler_views(struct pipe_context *pipe, unsigned p,
+                      unsigned nr,
+                      struct pipe_sampler_view **views)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
        unsigned i;
 
        for (i = 0; i < nr; i++)
-               pipe_texture_reference((void *)&nv50->miptree[type][i], pt[i]);
-       for (i = nr; i < nv50->miptree_nr[type]; i++)
-               pipe_texture_reference((void *)&nv50->miptree[type][i], NULL);
+               pipe_sampler_view_reference(&nv50->sampler_views[p][i],
+                                           views[i]);
+
+       for (i = nr; i < nv50->sampler_view_nr[p]; i++)
+               pipe_sampler_view_reference(&nv50->sampler_views[p][i], NULL);
 
-       nv50->miptree_nr[type] = nr;
+       nv50->sampler_view_nr[p] = nr;
        nv50->dirty |= NV50_NEW_TEXTURE;
 }
 
 static void
-nv50_set_vp_sampler_textures(struct pipe_context *pipe,
-                            unsigned nr, struct pipe_texture **pt)
+nv50_set_vp_sampler_views(struct pipe_context *pipe,
+                         unsigned nr,
+                         struct pipe_sampler_view **views)
 {
-       nv50_set_sampler_texture(pipe, PIPE_SHADER_VERTEX, nr, pt);
+       nv50_set_sampler_views(pipe, 0, nr, views);
 }
 
 static void
-nv50_set_fp_sampler_textures(struct pipe_context *pipe,
-                            unsigned nr, struct pipe_texture **pt)
+nv50_set_fp_sampler_views(struct pipe_context *pipe,
+                         unsigned nr,
+                         struct pipe_sampler_view **views)
 {
-       nv50_set_sampler_texture(pipe, PIPE_SHADER_FRAGMENT, nr, pt);
+       nv50_set_sampler_views(pipe, 2, nr, views);
 }
 
+static void
+nv50_sampler_view_destroy(struct pipe_context *pipe,
+                         struct pipe_sampler_view *view)
+{
+       pipe_texture_reference(&view->texture, NULL);
+       FREE(nv50_sampler_view(view));
+}
+
+static struct pipe_sampler_view *
+nv50_create_sampler_view(struct pipe_context *pipe,
+                        struct pipe_texture *texture,
+                        const struct pipe_sampler_view *templ)
+{
+       struct nv50_sampler_view *view = CALLOC_STRUCT(nv50_sampler_view);
+
+       view->pipe = *templ;
+       view->pipe.reference.count = 1;
+       view->pipe.texture = NULL;
+       pipe_texture_reference(&view->pipe.texture, texture);
+       view->pipe.context = pipe;
+
+       if (!nv50_tex_construct(view)) {
+               nv50_sampler_view_destroy(pipe, &view->pipe);
+               return NULL;
+       }
+       return &view->pipe;
+}
+
+
 static void *
 nv50_rasterizer_state_create(struct pipe_context *pipe,
                             const struct pipe_rasterizer_state *cso)
@@ -765,8 +802,10 @@ nv50_init_state_functions(struct nv50_context *nv50)
        nv50->pipe.delete_sampler_state = nv50_sampler_state_delete;
        nv50->pipe.bind_fragment_sampler_states = nv50_fp_sampler_state_bind;
        nv50->pipe.bind_vertex_sampler_states   = nv50_vp_sampler_state_bind;
-       nv50->pipe.set_fragment_sampler_textures = nv50_set_fp_sampler_textures;
-       nv50->pipe.set_vertex_sampler_textures   = nv50_set_vp_sampler_textures;
+       nv50->pipe.set_fragment_sampler_views = nv50_set_fp_sampler_views;
+       nv50->pipe.set_vertex_sampler_views   = nv50_set_vp_sampler_views;
+       nv50->pipe.create_sampler_view = nv50_create_sampler_view;
+       nv50->pipe.sampler_view_destroy = nv50_sampler_view_destroy;
 
        nv50->pipe.create_rasterizer_state = nv50_rasterizer_state_create;
        nv50->pipe.bind_rasterizer_state = nv50_rasterizer_state_bind;
index 2c8e7ca7982cbd273c6fdd49d94e638fbab437b2..b7e355283c8ae8fe4910eef5e81a2ec7d2e6fe69 100644 (file)
@@ -310,15 +310,13 @@ validate_sampler(struct nv50_context *nv50)
        struct nouveau_stateobj *so;
        unsigned nr = 0, i;
 
-       for (i = 0; i < PIPE_SHADER_TYPES; ++i)
+       for (i = 0; i < 3; ++i)
                nr += nv50->sampler_nr[i];
 
-       so = so_new(1 + 5 * PIPE_SHADER_TYPES,
-                   1 + 19 * PIPE_SHADER_TYPES + nr * 8,
-                   PIPE_SHADER_TYPES * 2);
+       so = so_new(1 + 5 * 3, 1 + 19 * 3 + nr * 8, 3 * 2);
 
-       nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX);
-       nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT);
+       nv50_validate_samplers(nv50, so, 0); /* VP */
+       nv50_validate_samplers(nv50, so, 2); /* FP */
 
        so_method(so, tesla, 0x1334, 1); /* flush TSC */
        so_data  (so, 0);
@@ -437,7 +435,7 @@ nv50_state_validate(struct nv50_context *nv50, unsigned wait_dwords)
        so_emit_reloc_markers(chan, nv50->state.hw[3]); /* vp */
        so_emit_reloc_markers(chan, nv50->state.hw[4]); /* fp */
        so_emit_reloc_markers(chan, nv50->state.hw[17]); /* vb */
-       so_emit_reloc_markers(chan, nv50->screen->static_init);
+       nv50_screen_relocs(nv50->screen);
 
        /* No idea.. */
        BEGIN_RING(chan, tesla, 0x142c, 1);
index cabd148bc5bfe6f6d6d6093266e9a062787c098e..6467c48a32a55f80340dc8b7f11d61bdc00a3bdd 100644 (file)
@@ -28,6 +28,7 @@
 #include "util/u_inlines.h"
 
 #include "util/u_tile.h"
+#include "util/u_format.h"
 
 static INLINE int
 nv50_format(enum pipe_format format)
@@ -37,10 +38,35 @@ nv50_format(enum pipe_format format)
                return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM;
        case PIPE_FORMAT_B8G8R8X8_UNORM:
                return NV50_2D_DST_FORMAT_X8R8G8B8_UNORM;
+       case PIPE_FORMAT_B8G8R8A8_SRGB:
+               return NV50_2D_DST_FORMAT_A8R8G8B8_SRGB;
+       case PIPE_FORMAT_B8G8R8X8_SRGB:
+               return NV50_2D_DST_FORMAT_X8R8G8B8_SRGB;
        case PIPE_FORMAT_B5G6R5_UNORM:
                return NV50_2D_DST_FORMAT_R5G6B5_UNORM;
+       case PIPE_FORMAT_B5G5R5A1_UNORM:
+               return NV50_2D_DST_FORMAT_A1R5G5B5_UNORM;
        case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_L8_UNORM:
                return NV50_2D_DST_FORMAT_R8_UNORM;
+       case PIPE_FORMAT_R32G32B32A32_FLOAT:
+               return NV50_2D_DST_FORMAT_R32G32B32A32_FLOAT;
+       case PIPE_FORMAT_R32G32B32_FLOAT:
+               return NV50_2D_DST_FORMAT_R32G32B32X32_FLOAT;
+       case PIPE_FORMAT_Z32_FLOAT:
+               return NV50_2D_DST_FORMAT_R32_FLOAT;
+
+       /* only because we require src format == dst format: */
+       case PIPE_FORMAT_R16G16_SNORM:
+       case PIPE_FORMAT_R16G16_UNORM:
+       case PIPE_FORMAT_S8Z24_UNORM:
+       case PIPE_FORMAT_Z24S8_UNORM:
+               return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM;
+       case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_B4G4R4A4_UNORM:
+               return NV50_2D_DST_FORMAT_R16_UNORM;
+
        default:
                return -1;
        }
@@ -57,8 +83,11 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
        int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD);
 
        format = nv50_format(ps->format);
-       if (format < 0)
+       if (format < 0) {
+               NOUVEAU_ERR("invalid/unsupported surface format: %s\n",
+                           util_format_name(ps->format));
                return 1;
+       }
 
        if (!bo->tile_flags) {
                MARK_RING (chan, 9, 2); /* flush on lack of space or relocs */
index 4c48b12cd87b377b24a061b47c74276fcbf3c558..85ab947c0063eae6afb15cf51f4246e0db618100 100644 (file)
 #include "util/u_format.h"
 
 #define _MIXED(pf, t0, t1, t2, t3, cr, cg, cb, ca, f)          \
-{                                                              \
-       PIPE_FORMAT_##pf,                                       \
+[PIPE_FORMAT_##pf] = (                                         \
        NV50TIC_0_0_MAPR_##cr | NV50TIC_0_0_TYPER_##t0 |        \
        NV50TIC_0_0_MAPG_##cg | NV50TIC_0_0_TYPEG_##t1 |        \
        NV50TIC_0_0_MAPB_##cb | NV50TIC_0_0_TYPEB_##t2 |        \
        NV50TIC_0_0_MAPA_##ca | NV50TIC_0_0_TYPEA_##t3 |        \
-       NV50TIC_0_0_FMT_##f                                     \
-}
+       NV50TIC_0_0_FMT_##f)
 
 #define _(pf, t, cr, cg, cb, ca, f) _MIXED(pf, t, t, t, t, cr, cg, cb, ca, f)
 
-struct nv50_texture_format {
-       enum pipe_format pf;
-       uint32_t hw;
-};
-
-#define NV50_TEX_FORMAT_LIST_SIZE \
-       (sizeof(nv50_tex_format_list) / sizeof(struct nv50_texture_format))
-
-static const struct nv50_texture_format nv50_tex_format_list[] =
+static const uint32_t nv50_texture_formats[PIPE_FORMAT_COUNT] =
 {
        _(B8G8R8A8_UNORM, UNORM, C2, C1, C0, C3,  8_8_8_8),
        _(B8G8R8A8_SRGB,  UNORM, C2, C1, C0, C3,  8_8_8_8),
@@ -60,10 +50,12 @@ static const struct nv50_texture_format nv50_tex_format_list[] =
        _(B5G6R5_UNORM, UNORM, C2, C1, C0, ONE, 5_6_5),
 
        _(L8_UNORM, UNORM, C0, C0, C0, ONE, 8),
+       _(L8_SRGB,  UNORM, C0, C0, C0, ONE, 8),
        _(A8_UNORM, UNORM, ZERO, ZERO, ZERO, C0, 8),
        _(I8_UNORM, UNORM, C0, C0, C0, C0, 8),
 
        _(L8A8_UNORM, UNORM, C0, C0, C0, C1, 8_8),
+       _(L8A8_SRGB,  UNORM, C0, C0, C0, C1, 8_8),
 
        _(DXT1_RGB, UNORM, C0, C1, C2, ONE, DXT1),
        _(DXT1_RGBA, UNORM, C0, C1, C2, C3, DXT1),
@@ -81,117 +73,143 @@ static const struct nv50_texture_format nv50_tex_format_list[] =
        _(R16G16_UNORM, UNORM, C0, C1, ZERO, ONE, 16_16),
 
        _MIXED(Z32_FLOAT, FLOAT, UINT, UINT, UINT, C0, C0, C0, ONE, 32_DEPTH)
-
 };
 
 #undef _
 #undef _MIXED
 
-static int
-nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
-                  struct nv50_miptree *mt, int unit, unsigned p)
+static INLINE uint32_t
+nv50_tic_swizzle(uint32_t tc, unsigned swz)
+{
+       switch (swz) {
+       case PIPE_SWIZZLE_RED:
+               return (tc & NV50TIC_0_0_MAPR_MASK) >> NV50TIC_0_0_MAPR_SHIFT;
+       case PIPE_SWIZZLE_GREEN:
+               return (tc & NV50TIC_0_0_MAPG_MASK) >> NV50TIC_0_0_MAPG_SHIFT;
+       case PIPE_SWIZZLE_BLUE:
+               return (tc & NV50TIC_0_0_MAPB_MASK) >> NV50TIC_0_0_MAPB_SHIFT;
+       case PIPE_SWIZZLE_ALPHA:
+               return (tc & NV50TIC_0_0_MAPA_MASK) >> NV50TIC_0_0_MAPA_SHIFT;
+       case PIPE_SWIZZLE_ONE:
+               return 7;
+       case PIPE_SWIZZLE_ZERO:
+       default:
+               return 0;
+       }
+}
+
+boolean
+nv50_tex_construct(struct nv50_sampler_view *view)
 {
-       unsigned i;
-       uint32_t mode;
        const struct util_format_description *desc;
+       struct nv50_miptree *mt = nv50_miptree(view->pipe.texture);
+       uint32_t swz[4], *tic = view->tic;
 
-       for (i = 0; i < NV50_TEX_FORMAT_LIST_SIZE; i++)
-               if (nv50_tex_format_list[i].pf == mt->base.base.format)
-                       break;
-       if (i == NV50_TEX_FORMAT_LIST_SIZE)
-                return 1;
-
-       if (nv50->sampler[p][unit]->normalized)
-               mode = 0x50001000 | (1 << 31);
-       else {
-               mode = 0x50001000 | (7 << 14);
-               assert(mt->base.base.target == PIPE_TEXTURE_2D);
-       }
+       tic[0] = nv50_texture_formats[view->pipe.format];
 
-       mode |= ((mt->base.bo->tile_mode & 0x0f) << 22) |
-               ((mt->base.bo->tile_mode & 0xf0) << 21);
+       swz[0] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_r);
+       swz[1] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_g);
+       swz[2] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_b);
+       swz[3] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_a);
+       view->tic[0] = (tic[0] &  ~NV50TIC_0_0_SWIZZLE_MASK) |
+               (swz[0] << NV50TIC_0_0_MAPR_SHIFT) |
+               (swz[1] << NV50TIC_0_0_MAPG_SHIFT) |
+               (swz[2] << NV50TIC_0_0_MAPB_SHIFT) |
+               (swz[3] << NV50TIC_0_0_MAPA_SHIFT);
 
-       desc = util_format_description(mt->base.base.format);
-       assert(desc);
+       tic[2] = 0x50001000;
+       tic[2] |= ((mt->base.bo->tile_mode & 0x0f) << 22) |
+                 ((mt->base.bo->tile_mode & 0xf0) << 21);
 
+       desc = util_format_description(mt->base.base.format);
        if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
-               mode |= 0x0400;
+               tic[2] |= NV50TIC_0_2_COLORSPACE_SRGB;
 
        switch (mt->base.base.target) {
        case PIPE_TEXTURE_1D:
+               tic[2] |= NV50TIC_0_2_TARGET_1D;
                break;
        case PIPE_TEXTURE_2D:
-               mode |= (1 << 14);
+               tic[2] |= NV50TIC_0_2_TARGET_2D;
                break;
        case PIPE_TEXTURE_3D:
-               mode |= (2 << 14);
+               tic[2] |= NV50TIC_0_2_TARGET_3D;
                break;
        case PIPE_TEXTURE_CUBE:
-               mode |= (3 << 14);
+               tic[2] |= NV50TIC_0_2_TARGET_CUBE;
                break;
        default:
-               assert(!"unsupported texture target");
-               break;
+               NOUVEAU_ERR("invalid texture target: %d\n",
+                           mt->base.base.target);
+               return FALSE;
        }
 
-       so_data (so, nv50_tex_format_list[i].hw);
-       so_reloc(so, mt->base.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
-                NOUVEAU_BO_RD, 0, 0);
-       so_data (so, mode);
-       so_data (so, 0x00300000);
-       so_data (so, mt->base.base.width0 | (1 << 31));
-       so_data (so, (mt->base.base.last_level << 28) |
-                (mt->base.base.depth0 << 16) | mt->base.base.height0);
-       so_data (so, 0x03000000);
-       so_data (so, mt->base.base.last_level << 4);
-
-       return 0;
-}
+       tic[3] = 0x00300000;
+
+       tic[4] = (1 << 31) | mt->base.base.width0;
+       tic[5] = (mt->base.base.last_level << 28) |
+               (mt->base.base.depth0 << 16) | mt->base.base.height0;
+
+       tic[6] = 0x03000000;
 
-#ifndef NV50TCL_BIND_TIC
-#define NV50TCL_BIND_TIC(n) (0x1448 + 8 * n)
-#endif
+       tic[7] = (view->pipe.last_level << 4) | view->pipe.first_level;
+
+       return TRUE;
+}
 
-static boolean
+static int
 nv50_validate_textures(struct nv50_context *nv50, struct nouveau_stateobj *so,
                       unsigned p)
 {
-       static const unsigned p_remap[PIPE_SHADER_TYPES] = { 0, 2, 1 };
-
        struct nouveau_grobj *eng2d = nv50->screen->eng2d;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
-       unsigned unit, j, p_hw = p_remap[p];
+       unsigned unit, j;
+
+       const unsigned rll = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW;
+       const unsigned rlh = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH
+               | NOUVEAU_BO_OR;
 
        nv50_so_init_sifc(nv50, so, nv50->screen->tic, NOUVEAU_BO_VRAM,
-                         p * (32 * 8 * 4), nv50->miptree_nr[p] * 8 * 4);
+                         p * (32 * 8 * 4), nv50->sampler_view_nr[p] * 8 * 4);
 
-       for (unit = 0; unit < nv50->miptree_nr[p]; ++unit) {
-               struct nv50_miptree *mt = nv50->miptree[p][unit];
+       for (unit = 0; unit < nv50->sampler_view_nr[p]; ++unit) {
+               struct nv50_sampler_view *view =
+                       nv50_sampler_view(nv50->sampler_views[p][unit]);
 
                so_method(so, eng2d, NV50_2D_SIFC_DATA | (2 << 29), 8);
-               if (mt) {
-                       if (nv50_tex_construct(nv50, so, mt, unit, p))
-                               return FALSE;
+               if (view) {
+                       uint32_t tic2 = view->tic[2];
+                       struct nv50_miptree *mt =
+                               nv50_miptree(view->pipe.texture);
+
+                       if (nv50->sampler[p][unit]->normalized)
+                               tic2 |= NV50TIC_0_2_NORMALIZED_COORDS;
+
+                       so_data  (so, view->tic[0]);
+                       so_reloc (so, mt->base.bo, 0, rll, 0, 0);
+                       so_reloc (so, mt->base.bo, 0, rlh, tic2, tic2);
+                       so_datap (so, &view->tic[3], 5);
+
                        /* Set TEX insn $t src binding $unit in program type p
                         * to TIC, TSC entry (32 * p + unit), mark valid (1).
                         */
-                       so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1);
+                       so_method(so, tesla, NV50TCL_BIND_TIC(p), 1);
                        so_data  (so, ((32 * p + unit) << 9) | (unit << 1) | 1);
                } else {
                        for (j = 0; j < 8; ++j)
                                so_data(so, 0);
-                       so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1);
+                       so_method(so, tesla, NV50TCL_BIND_TIC(p), 1);
                        so_data  (so, (unit << 1) | 0);
                }
        }
 
-       for (; unit < nv50->state.miptree_nr[p]; unit++) {
+       for (; unit < nv50->state.sampler_view_nr[p]; unit++) {
                /* Make other bindings invalid. */
-               so_method(so, tesla, NV50TCL_BIND_TIC(p_hw), 1);
+               so_method(so, tesla, NV50TCL_BIND_TIC(p), 1);
                so_data  (so, (unit << 1) | 0);
        }
 
-       nv50->state.miptree_nr[p] = nv50->miptree_nr[p];
+       nv50->state.sampler_view_nr[p] = nv50->sampler_view_nr[p];
        return TRUE;
 }
 
@@ -202,23 +220,25 @@ nv50_tex_relocs(struct nv50_context *nv50)
        int p, unit;
 
        p = PIPE_SHADER_FRAGMENT;
-       for (unit = 0; unit < nv50->miptree_nr[p]; unit++) {
-               if (!nv50->miptree[p][unit])
+       for (unit = 0; unit < nv50->sampler_view_nr[p]; unit++) {
+               struct pipe_sampler_view *view = nv50->sampler_views[p][unit];
+               if (!view)
                        continue;
                nouveau_reloc_emit(chan, nv50->screen->tic,
                                   ((p * 32) + unit) * 32, NULL,
-                                  nv50->miptree[p][unit]->base.bo, 0, 0,
+                                  nv50_miptree(view->texture)->base.bo, 0, 0,
                                   NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
                                   NOUVEAU_BO_RD, 0, 0);
        }
 
        p = PIPE_SHADER_VERTEX;
-       for (unit = 0; unit < nv50->miptree_nr[p]; unit++) {
-               if (!nv50->miptree[p][unit])
+       for (unit = 0; unit < nv50->sampler_view_nr[p]; unit++) {
+               struct pipe_sampler_view *view = nv50->sampler_views[p][unit];
+               if (!view)
                        continue;
                nouveau_reloc_emit(chan, nv50->screen->tic,
                                   ((p * 32) + unit) * 32, NULL,
-                                  nv50->miptree[p][unit]->base.bo, 0, 0,
+                                  nv50_miptree(view->texture)->base.bo, 0, 0,
                                   NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
                                   NOUVEAU_BO_RD, 0, 0);
        }
@@ -229,21 +249,23 @@ nv50_tex_validate(struct nv50_context *nv50)
 {
        struct nouveau_stateobj *so;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
-       unsigned p, start, push, nrlc;
-
-       for (nrlc = 0, start = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) {
-               start += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]);
-               push += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]);
-               nrlc += nv50->miptree_nr[p];
+       unsigned p, m = 0, d = 0, r = 0;
+
+       for (p = 0; p < 3; ++p) {
+               unsigned nr = MAX2(nv50->sampler_view_nr[p],
+                                  nv50->state.sampler_view_nr[p]);
+               m += nr;
+               d += nr;
+               r += nv50->sampler_view_nr[p];
        }
-       start = start * 2 + 4 * PIPE_SHADER_TYPES + 2;
-       push = push * 9 + 19 * PIPE_SHADER_TYPES + 2;
-       nrlc = nrlc * 2 + 2 * PIPE_SHADER_TYPES;
+       m = m * 2 + 3 * 4 + 1;
+       d = d * 9 + 3 * 19 + 1;
+       r = r * 2 + 3 * 2;
 
-       so = so_new(start, push, nrlc);
+       so = so_new(m, d, r);
 
-       if (nv50_validate_textures(nv50, so, PIPE_SHADER_VERTEX) == FALSE ||
-           nv50_validate_textures(nv50, so, PIPE_SHADER_FRAGMENT) == FALSE) {
+       if (nv50_validate_textures(nv50, so, 0) == FALSE ||
+           nv50_validate_textures(nv50, so, 2) == FALSE) {
                so_ref(NULL, &so);
 
                NOUVEAU_ERR("failed tex validate\n");
index b870302019a80359d63eba90e176d5e4045f2ee2..3475d3e432643519cca7aa2c2b55469386933e9a 100644 (file)
@@ -7,7 +7,9 @@
  */
 
 /* Texture image control block */
+#define NV50TIC_0_0_SWIZZLE_MASK                                  0x3ffc0000
 #define NV50TIC_0_0_MAPA_MASK                                     0x38000000
+#define NV50TIC_0_0_MAPA_SHIFT                                            27
 #define NV50TIC_0_0_MAPA_ZERO                                     0x00000000
 #define NV50TIC_0_0_MAPA_C0                                       0x10000000
 #define NV50TIC_0_0_MAPA_C1                                       0x18000000
@@ -15,6 +17,7 @@
 #define NV50TIC_0_0_MAPA_C3                                       0x28000000
 #define NV50TIC_0_0_MAPA_ONE                                      0x38000000
 #define NV50TIC_0_0_MAPB_MASK                                     0x07000000
+#define NV50TIC_0_0_MAPB_SHIFT                                            24
 #define NV50TIC_0_0_MAPB_ZERO                                     0x00000000
 #define NV50TIC_0_0_MAPB_C0                                       0x02000000
 #define NV50TIC_0_0_MAPB_C1                                       0x03000000
@@ -22,6 +25,7 @@
 #define NV50TIC_0_0_MAPB_C3                                       0x05000000
 #define NV50TIC_0_0_MAPB_ONE                                      0x07000000
 #define NV50TIC_0_0_MAPG_MASK                                     0x00e00000
+#define NV50TIC_0_0_MAPG_SHIFT                                            21
 #define NV50TIC_0_0_MAPG_ZERO                                     0x00000000
 #define NV50TIC_0_0_MAPG_C0                                       0x00400000
 #define NV50TIC_0_0_MAPG_C1                                       0x00600000
@@ -29,6 +33,7 @@
 #define NV50TIC_0_0_MAPG_C3                                       0x00a00000
 #define NV50TIC_0_0_MAPG_ONE                                      0x00e00000
 #define NV50TIC_0_0_MAPR_MASK                                     0x001c0000
+#define NV50TIC_0_0_MAPR_SHIFT                                            18
 #define NV50TIC_0_0_MAPR_ZERO                                     0x00000000
 #define NV50TIC_0_0_MAPR_C0                                       0x00080000
 #define NV50TIC_0_0_MAPR_C1                                       0x000c0000
 #define NV50TIC_0_1_OFFSET_LOW_MASK                               0xffffffff
 #define NV50TIC_0_1_OFFSET_LOW_SHIFT                                       0
 
-#define NV50TIC_0_2_UNKNOWN_MASK                                  0xffffffff
+#define NV50TIC_0_2_COLORSPACE_SRGB                               0x00000400
+#define NV50TIC_0_2_TARGET_1D                                     0x00000000
+#define NV50TIC_0_2_TARGET_2D                                     0x00004000
+#define NV50TIC_0_2_TARGET_3D                                     0x00008000
+#define NV50TIC_0_2_TARGET_CUBE                                   0x0000c000
+#define NV50TIC_0_2_TARGET_1D_ARRAY                               0x00010000
+#define NV50TIC_0_2_TARGET_2D_ARRAY                               0x00014000
+#define NV50TIC_0_2_TARGET_BUFFER                                 0x00018000
+#define NV50TIC_0_2_TARGET_RECT                                   0x0001c000
+/* #define NV50TIC_0_0_TILE_MODE_LINEAR                           0x00040000 */
+#define NV50TIC_0_2_TILE_MODE_Y_MASK                              0x01c00000
+#define NV50TIC_0_2_TILE_MODE_Y_SHIFT                                     22
+#define NV50TIC_0_2_TILE_MODE_Z_MASK                              0x0e000000
+#define NV50TIC_0_2_TILE_MODE_Z_SHIFT                                     25
+#define NV50TIC_0_2_NORMALIZED_COORDS                             0x80000000
 
 #define NV50TIC_0_3_UNKNOWN_MASK                                  0xffffffff
 
 #define NV50TIC_0_4_WIDTH_MASK                                    0x0000ffff
 #define NV50TIC_0_4_WIDTH_SHIFT                                            0
 
-#define NV50TIC_0_5_DEPTH_MASK                                    0xffff0000
+#define NV50TIC_0_5_LAST_LEVEL_MASK                               0xf0000000
+#define NV50TIC_0_5_LAST_LEVEL_SHIFT                                      28
+#define NV50TIC_0_5_DEPTH_MASK                                    0x0fff0000
 #define NV50TIC_0_5_DEPTH_SHIFT                                           16
 #define NV50TIC_0_5_HEIGHT_MASK                                   0x0000ffff
 #define NV50TIC_0_5_HEIGHT_SHIFT                                           0
-
 #define NV50TIC_0_6_UNKNOWN_MASK                                  0xffffffff
 
-#define NV50TIC_0_7_OFFSET_HIGH_MASK                              0xffffffff
-#define NV50TIC_0_7_OFFSET_HIGH_SHIFT                                      0
+#define NV50TIC_0_7_BASE_LEVEL_MASK                               0x0000000f
+#define NV50TIC_0_7_BASE_LEVEL_SHIFT                                       0
+#define NV50TIC_0_7_MAX_LEVEL_MASK                                0x000000f0
+#define NV50TIC_0_7_MAX_LEVEL_SHIFT                                        4
 
 /* Texture sampler control block */
 #define NV50TSC_1_0_WRAPS_MASK                                   0x00000007
index 2b56f4549218c3f12fbf51b6dc1009f8c3767e78..54e47574c4de5e27d1999e83ee1afb69fc2eb51b 100644 (file)
@@ -91,7 +91,7 @@ struct nouveau_stateobj *
 nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
 {
        struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
-       struct nvfx_miptree *nv30mt = nvfx->tex_miptree[unit];
+       struct nvfx_miptree *nv30mt = (struct nvfx_miptree *)nvfx->fragment_sampler_views[unit]->texture;
        struct pipe_texture *pt = &nv30mt->base;
        struct nouveau_bo *bo = nouveau_bo(nv30mt->buffer);
        struct nv30_texture_format *tf;
index 5889b5e40d5f1bc3d4e26760239fbf01d4232326..05506e2809916d1335125beb038c256f6afbc818 100644 (file)
@@ -109,7 +109,7 @@ struct nouveau_stateobj *
 nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
 {
        struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
-       struct nvfx_miptree *nv40mt = nvfx->tex_miptree[unit];
+       struct nvfx_miptree *nv40mt = (struct nvfx_miptree *)nvfx->fragment_sampler_views[unit]->texture;
        struct nouveau_bo *bo = nouveau_bo(nv40mt->buffer);
        struct pipe_texture *pt = &nv40mt->base;
        struct nv40_texture_format *tf;
index 5eed8a560e59b3c9901280e499be7a344a9f0c4a..ab7225cf6c343c3957f64421cbd49e1d9d8e895b 100644 (file)
@@ -158,7 +158,7 @@ struct nvfx_context {
        struct pipe_buffer *idxbuf;
        unsigned idxbuf_format;
        struct nvfx_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
-       struct nvfx_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
+       struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
        unsigned nr_samplers;
        unsigned nr_textures;
        unsigned dirty_samplers;
index 5379b29efd11db676089b6b54a385fb3c5f40d4e..68e50a36479dec593cf3718b7c23254fbcc5d0ef 100644 (file)
@@ -79,6 +79,12 @@ nvfx_render_vertex(struct nvfx_context *nvfx, const struct vertex_header *v)
                                            float_to_ubyte(v->data[idx][1]),
                                            float_to_ubyte(v->data[idx][2]),
                                            float_to_ubyte(v->data[idx][3])));
+               case EMIT_4UB_BGRA:
+                       BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4UB(hw), 1);
+                       OUT_RING  (chan, pack_ub4(float_to_ubyte(v->data[idx][2]),
+                                           float_to_ubyte(v->data[idx][1]),
+                                           float_to_ubyte(v->data[idx][0]),
+                                           float_to_ubyte(v->data[idx][3])));
                        break;
                default:
                        assert(0);
index 76351430f44e46838cb7becfb8952a4daf63b457..b9c91cec8ce986e6ba29c2676b0db1ba3cd5a285 100644 (file)
@@ -803,7 +803,8 @@ nvfx_fragprog_translate(struct nvfx_context *nvfx,
                fp->fp_control |= fpc->num_regs << NV40TCL_FP_CONTROL_TEMP_COUNT_SHIFT;
 
        /* Terminate final instruction */
-       fp->insn[fpc->inst_offset] |= 0x00000001;
+       if(fp->insn)
+                fp->insn[fpc->inst_offset] |= 0x00000001;
 
        /* Append NOP + END instruction, may or may not be necessary. */
        fpc->inst_offset = fp->insn_len;
index 0f5ed61aab74002c6569179108c32829404d50f0..9de25175e78add1dc25f1ed28bf2a3996b7c5b10 100644 (file)
@@ -67,6 +67,9 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
        struct nvfx_miptree *mt;
        unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
                             NOUVEAU_BUFFER_USAGE_TEXTURE;
+       static int no_swizzle = -1;
+       if(no_swizzle < 0)
+               no_swizzle = debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE);
 
        mt = MALLOC(sizeof(struct nvfx_miptree));
        if (!mt)
@@ -106,7 +109,7 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
                case PIPE_FORMAT_B8G8R8X8_UNORM:
                case PIPE_FORMAT_R16_SNORM:
                {
-                       if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE))
+                       if (no_swizzle)
                                mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
                        break;
                }
index 8138715cc7d1899e39d71af677e9c40d132d73f1..f7f39218944b7dbd87d9fb8cf4c67ac1d1a5f1b4 100644 (file)
@@ -68,11 +68,9 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, int param)
        case PIPE_CAP_BLEND_EQUATION_SEPARATE:
                return !!screen->is_nv4x;
        case NOUVEAU_CAP_HW_VTXBUF:
-               /* TODO: this is almost surely wrong */
-               return !!screen->is_nv4x;
+               return 0;
        case NOUVEAU_CAP_HW_IDXBUF:
-               /* TODO: this is also almost surely wrong */
-               return screen->is_nv4x && screen->eng3d->grclass == NV40TCL;
+               return 0;
        case PIPE_CAP_MAX_COMBINED_SAMPLERS:
                return 16;
        case PIPE_CAP_INDEP_BLEND_ENABLE:
@@ -295,6 +293,36 @@ static void nv40_screen_init(struct nvfx_screen *screen, struct nouveau_stateobj
        so_data  (so, 0x00000001);
 }
 
+static void
+nvfx_screen_init_buffer_functions(struct nvfx_screen* screen)
+{
+       int vram_hack_default = 0;
+       int vram_hack;
+       // TODO: this is a bit of a guess; also add other cards that may need this hack.
+       // It may also depend on the specific card or the AGP/PCIe chipset.
+       if(screen->base.device->chipset == 0x47 /* G70 */
+               || screen->base.device->chipset == 0x49 /* G71 */
+               || screen->base.device->chipset == 0x46 /* G72 */
+               )
+               vram_hack_default = 1;
+       vram_hack = debug_get_bool_option("NOUVEAU_VTXIDX_IN_VRAM", vram_hack_default);
+
+#ifdef DEBUG
+       if(!vram_hack)
+       {
+               fprintf(stderr, "Some systems may experience graphics corruption due to randomly misplaced vertices.\n"
+                       "If this is happening, export NOUVEAU_VTXIDX_IN_VRAM=1 may reduce or eliminate the problem\n");
+       }
+       else
+       {
+               fprintf(stderr, "A performance reducing hack is being used to help avoid graphics corruption.\n"
+                       "You can try export NOUVEAU_VTXIDX_IN_VRAM=0 to disable it.\n");
+       }
+#endif
+
+       screen->vertex_buffer_flags = vram_hack ? NOUVEAU_BO_VRAM : NOUVEAU_BO_GART;
+}
+
 struct pipe_screen *
 nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 {
@@ -352,6 +380,7 @@ nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
                return NULL;
        }
 
+       nvfx_screen_init_buffer_functions(screen);
        nvfx_screen_init_miptree_functions(pscreen);
 
        ret = nouveau_grobj_alloc(chan, 0xbeef3097, eng3d_class, &screen->eng3d);
index c0b4b9899dd501b3a69c3e4ca44abd8f41b51128..baa848c47aaedf6dd3a9db95dd5c5ea0807fea83 100644 (file)
@@ -12,6 +12,7 @@ struct nvfx_screen {
        struct nvfx_context *cur_ctx;
 
        unsigned is_nv4x; /* either 0 or ~0 */
+       int vertex_buffer_flags;
 
        /* HW graphics objects */
        struct nv04_surface_2d *eng2d;
index 88a9d01c509b3b56d179ba54a784f611662f5fd4..ecaa0dcb16a872476825a38d9f7e9627ef093c7a 100644 (file)
@@ -137,21 +137,22 @@ nvfx_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
 }
 
 static void
-nvfx_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
-                        struct pipe_texture **miptree)
+nvfx_set_fragment_sampler_views(struct pipe_context *pipe,
+                               unsigned nr,
+                               struct pipe_sampler_view **views)
 {
        struct nvfx_context *nvfx = nvfx_context(pipe);
        unsigned unit;
 
        for (unit = 0; unit < nr; unit++) {
-               pipe_texture_reference((struct pipe_texture **)
-                                      &nvfx->tex_miptree[unit], miptree[unit]);
+               pipe_sampler_view_reference(&nvfx->fragment_sampler_views[unit],
+                                            views[unit]);
                nvfx->dirty_samplers |= (1 << unit);
        }
 
        for (unit = nr; unit < nvfx->nr_textures; unit++) {
-               pipe_texture_reference((struct pipe_texture **)
-                                      &nvfx->tex_miptree[unit], NULL);
+               pipe_sampler_view_reference(&nvfx->fragment_sampler_views[unit],
+                                            NULL);
                nvfx->dirty_samplers |= (1 << unit);
        }
 
@@ -159,6 +160,34 @@ nvfx_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
        nvfx->dirty |= NVFX_NEW_SAMPLER;
 }
 
+
+static struct pipe_sampler_view *
+nvfx_create_sampler_view(struct pipe_context *pipe,
+                        struct pipe_texture *texture,
+                        const struct pipe_sampler_view *templ)
+{
+       struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+       if (view) {
+               *view = *templ;
+               view->reference.count = 1;
+               view->texture = NULL;
+               pipe_texture_reference(&view->texture, texture);
+               view->context = pipe;
+       }
+
+       return view;
+}
+
+
+static void
+nvfx_sampler_view_destroy(struct pipe_context *pipe,
+                         struct pipe_sampler_view *view)
+{
+       pipe_texture_reference(&view->texture, NULL);
+       FREE(view);
+}
+
 static void *
 nvfx_rasterizer_state_create(struct pipe_context *pipe,
                             const struct pipe_rasterizer_state *cso)
@@ -581,7 +610,9 @@ nvfx_init_state_functions(struct nvfx_context *nvfx)
        nvfx->pipe.create_sampler_state = nvfx_sampler_state_create;
        nvfx->pipe.bind_fragment_sampler_states = nvfx_sampler_state_bind;
        nvfx->pipe.delete_sampler_state = nvfx_sampler_state_delete;
-       nvfx->pipe.set_fragment_sampler_textures = nvfx_set_sampler_texture;
+       nvfx->pipe.set_fragment_sampler_views = nvfx_set_fragment_sampler_views;
+        nvfx->pipe.create_sampler_view = nvfx_create_sampler_view;
+        nvfx->pipe.sampler_view_destroy = nvfx_sampler_view_destroy;
 
        nvfx->pipe.create_rasterizer_state = nvfx_rasterizer_state_create;
        nvfx->pipe.bind_rasterizer_state = nvfx_rasterizer_state_bind;
index 82e0e9220b080f53aa42eace400c57c928e2edd0..ec730e3a9e982cd6bbcdba967e6898f62459e5dc 100644 (file)
@@ -1,15 +1,16 @@
 #include "nvfx_context.h"
 
+/* Having this depend on FB and RAST looks wrong, but it seems
+   necessary to make this work on nv3x
+   TODO: find the right fix
+*/
+
 static boolean
 nvfx_state_viewport_validate(struct nvfx_context *nvfx)
 {
        struct pipe_viewport_state *vpt = &nvfx->viewport;
        struct nouveau_stateobj *so;
 
-       if (nvfx->state.hw[NVFX_STATE_VIEWPORT] &&
-           !(nvfx->dirty & NVFX_NEW_VIEWPORT))
-               return FALSE;
-
        so = so_new(2, 9, 0);
        so_method(so, nvfx->screen->eng3d,
                  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
@@ -45,7 +46,7 @@ nvfx_state_viewport_validate(struct nvfx_context *nvfx)
 struct nvfx_state_entry nvfx_state_viewport = {
        .validate = nvfx_state_viewport_validate,
        .dirty = {
-               .pipe = NVFX_NEW_VIEWPORT,
+               .pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_FB | NVFX_NEW_RAST,
                .hw = NVFX_STATE_VIEWPORT
        }
 };
index 409b354d5823f6dde7370297ec08a34f44ad8533..1c250e9fe4494449077f5b2c8fbdd9f5954507ac 100644 (file)
@@ -33,15 +33,18 @@ nvfx_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned h
 }
 
 static struct pipe_transfer *
-nvfx_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
+nvfx_transfer_new(struct pipe_context *pipe, struct pipe_texture *pt,
                  unsigned face, unsigned level, unsigned zslice,
                  enum pipe_transfer_usage usage,
                  unsigned x, unsigned y, unsigned w, unsigned h)
 {
-        struct pipe_screen *pscreen = pcontext->screen;
+       struct pipe_screen *pscreen = pipe->screen;
        struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
        struct nvfx_transfer *tx;
        struct pipe_texture tx_tex_template, *tx_tex;
+       static int no_transfer = -1;
+       if(no_transfer < 0)
+               no_transfer = debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/);
 
        tx = CALLOC_STRUCT(nvfx_transfer);
        if (!tx)
@@ -59,8 +62,7 @@ nvfx_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
        tx->base.zslice = zslice;
 
        /* Direct access to texture */
-       if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC ||
-            debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) &&
+       if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC || no_transfer) &&
            pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
        {
                tx->direct = true;
@@ -118,13 +120,13 @@ nvfx_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
 }
 
 static void
-nvfx_transfer_del(struct pipe_context *pcontext,
+nvfx_transfer_del(struct pipe_context *pipe,
                   struct pipe_transfer *ptx)
 {
        struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
 
        if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
-               struct pipe_screen *pscreen = pcontext->screen;
+               struct pipe_screen *pscreen = pipe->screen;
                struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
                struct pipe_surface *dst;
 
@@ -147,9 +149,9 @@ nvfx_transfer_del(struct pipe_context *pcontext,
 }
 
 static void *
-nvfx_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
+nvfx_transfer_map(struct pipe_context *pipe, struct pipe_transfer *ptx)
 {
-        struct pipe_screen *pscreen = pcontext->screen;
+       struct pipe_screen *pscreen = pipe->screen;
        struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
        struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
        struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
@@ -163,9 +165,9 @@ nvfx_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
 }
 
 static void
-nvfx_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
+nvfx_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *ptx)
 {
-       struct pipe_screen *pscreen = pcontext->screen;
+       struct pipe_screen *pscreen = pipe->screen;
        struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
        struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
 
index 257087f8f636e7b507ce1eda5c5167cedc5f147b..c26536b0e77ca7ed824491068834d6c0599077ef 100644 (file)
@@ -495,7 +495,7 @@ nvfx_vbo_validate(struct nvfx_context *nvfx)
        struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
        struct pipe_buffer *ib = nvfx->idxbuf;
        unsigned ib_format = nvfx->idxbuf_format;
-       unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
+       unsigned vb_flags = nvfx->screen->vertex_buffer_flags | NOUVEAU_BO_RD;
        int hw;
 
        vtxbuf = so_new(3, 17, 18);
index 27b2e30993280cc8b648fb4f9a629f588402af15..221878c1c0c4a528d2548ee28cddac961f26682d 100644 (file)
@@ -24,6 +24,7 @@ r300 = env.ConvenienceLibrary(
         'r300_query.c',
         'r300_render.c',
         'r300_screen.c',
+        'r300_screen_buffer.c',
         'r300_state.c',
         'r300_state_derived.c',
         'r300_state_invariant.c',
index b7ad6b2020608169d2939ef541537aa1945e3585..bcdf950df9cfcba70332c7d5871174218a3c6707 100644 (file)
@@ -113,9 +113,9 @@ static void r300_hw_copy(struct pipe_context* pipe,
     util_blitter_save_fragment_sampler_states(
         r300->blitter, state->sampler_count, (void**)state->sampler_states);
 
-    util_blitter_save_fragment_sampler_textures(
+    util_blitter_save_fragment_sampler_views(
         r300->blitter, state->texture_count,
-        (struct pipe_texture**)state->textures);
+        state->fragment_sampler_views);
 
     /* Do a copy */
     util_blitter_copy(r300->blitter,
@@ -149,6 +149,9 @@ void r300_surface_copy(struct pipe_context* pipe,
             case 4:
                 new_format = PIPE_FORMAT_B8G8R8A8_UNORM;
                 break;
+            case 8:
+                new_format = PIPE_FORMAT_R16G16B16A16_UNORM;
+                break;
             default:
                 debug_printf("r300: surface_copy: Unhandled format: %s. Falling back to software.\n"
                              "r300: surface_copy: Software fallback doesn't work for tiled textures.\n",
index 92de297ef1d5c332833ca6accf1219e3f014075c..417198626352bc2a78044a6773cf2555668e8720 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "util/u_debug.h"
 
+#include <stdio.h>
+
 /* r300_chipset: A file all to itself for deducing the various properties of
  * Radeons. */
 
@@ -365,8 +367,7 @@ void r300_parse_chipset(struct r300_capabilities* caps)
             break;
 
         default:
-            debug_printf("r300: Warning: Unknown chipset 0x%x\n",
-                caps->pci_id);
-            break;
+            fprintf(stderr, "r300: Warning: Unknown chipset 0x%x\n",
+                    caps->pci_id);
     }
 }
index d994a46ccfe9b1d8b98437db546ae6505d308fc0..4b470b2c6af3b7eca0379751ab564998fb6e6b01 100644 (file)
 #include "r300_query.h"
 #include "r300_render.h"
 #include "r300_screen.h"
+#include "r300_screen_buffer.h"
 #include "r300_state_invariant.h"
-#include "r300_texture.h"
 #include "r300_transfer.h"
-
-#include "radeon_winsys.h"
+#include "r300_winsys.h"
 
 static void r300_destroy_context(struct pipe_context* context)
 {
@@ -72,29 +71,23 @@ static void r300_destroy_context(struct pipe_context* context)
 }
 
 static unsigned int
-r300_is_texture_referenced(struct pipe_context *pipe,
+r300_is_texture_referenced(struct pipe_context *context,
                            struct pipe_texture *texture,
                            unsigned face, unsigned level)
 {
-    return 0;
+    struct r300_context* r300 = r300_context(context);
+    struct r300_texture* tex = (struct r300_texture*)texture;
+
+    return r300->rws->is_buffer_referenced(r300->rws, tex->buffer);
 }
 
 static unsigned int
-r300_is_buffer_referenced(struct pipe_context *pipe,
+r300_is_buffer_referenced(struct pipe_context *context,
                           struct pipe_buffer *buf)
 {
-    /* This only checks to see whether actual hardware buffers are
-     * referenced. Since we use managed BOs and transfers, it's actually not
-     * possible for pipe_buffers to ever reference the actual hardware, so
-     * buffers are never referenced. 
-     */
-
-    /* XXX: that doesn't make sense given that
-     * r300_is_texture_referenced is implemented on top of this
-     * function and hardware can certainly refer to textures
-     * directly...
-     */
-    return 0;
+    struct r300_context* r300 = r300_context(context);
+
+    return r300_buffer_is_referenced(r300, buf);
 }
 
 static void r300_flush_cb(void *data)
@@ -204,7 +197,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 
     /* Open up the OQ BO. */
     r300->oqbo = screen->buffer_create(screen, 4096,
-            PIPE_BUFFER_USAGE_VERTEX, 4096);
+            PIPE_BUFFER_USAGE_PIXEL, 4096);
     make_empty_list(&r300->query_list);
 
     r300_init_flush_functions(r300);
index db2f74e0745241d07e1b69c08f2bc8a804a39d0b..0a82484e89d6dd937998adfe7ebe793909a9c15c 100644 (file)
@@ -30,6 +30,7 @@
 #include "pipe/p_context.h"
 #include "util/u_inlines.h"
 
+#include "r300_defines.h"
 #include "r300_screen.h"
 
 struct u_upload_mgr;
@@ -125,8 +126,6 @@ struct r300_texture_format_state {
     uint32_t format2; /* R300_TX_FORMAT2: 0x4500 */
 };
 
-#define R300_MAX_TEXTURE_LEVELS 13
-
 struct r300_texture_fb_state {
     /* Colorbuffer. */
     uint32_t colorpitch[R300_MAX_TEXTURE_LEVELS]; /* R300_RB3D_COLORPITCH[0-3]*/
@@ -139,7 +138,7 @@ struct r300_texture_fb_state {
 
 struct r300_textures_state {
     /* Textures. */
-    struct r300_texture *textures[8];
+    struct pipe_sampler_view *fragment_sampler_views[8];
     int texture_count;
     /* Sampler states. */
     struct r300_sampler_state *sampler_states[8];
@@ -185,12 +184,6 @@ struct r300_ztop_state {
     uint32_t z_buffer_top;      /* R300_ZB_ZTOP: 0x4f14 */
 };
 
-#define R300_NEW_FRAGMENT_SHADER 0x00000020
-#define R300_NEW_FRAGMENT_SHADER_CONSTANTS    0x00000040
-#define R300_NEW_VERTEX_SHADER_CONSTANTS    0x10000000
-#define R300_NEW_QUERY           0x40000000
-#define R300_NEW_KITCHEN_SINK    0x7fffffff
-
 /* The next several objects are not pure Radeon state; they inherit from
  * various Gallium classes. */
 
@@ -228,12 +221,6 @@ struct r300_query {
     struct r300_query* next;
 };
 
-enum r300_buffer_tiling {
-    R300_BUFFER_LINEAR = 0,
-    R300_BUFFER_TILED,
-    R300_BUFFER_SQUARETILED
-};
-
 struct r300_texture {
     /* Parent class */
     struct pipe_texture tex;
@@ -422,7 +409,7 @@ static INLINE void CTX_DBG(struct r300_context * ctx, unsigned flags,
     if (CTX_DBG_ON(ctx, flags)) {
         va_list va;
         va_start(va, fmt);
-        debug_vprintf(fmt, va);
+        vfprintf(stderr, fmt, va);
         va_end(va);
     }
 }
@@ -431,4 +418,3 @@ static INLINE void CTX_DBG(struct r300_context * ctx, unsigned flags,
 #define DBG     CTX_DBG
 
 #endif /* R300_CONTEXT_H */
-
index ad07efbffdbef9168fae852c5f47c1f84050f113..456b2ec7b922a52e6f2f458ea95dd4e043cffa7f 100644 (file)
@@ -26,8 +26,7 @@
 #include "util/u_math.h"
 
 #include "r300_reg.h"
-
-#include "radeon_winsys.h"
+#include "r300_winsys.h"
 
 /* Yes, I know macros are ugly. However, they are much prettier than the code
  * that they neatly hide away, and don't have the cost of function setup,so
index d6177577c8df09abbd76bfe2c82e781618fd302c..016e8d6606114dd0d97dcda8cb179352a88d4427 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "r300_context.h"
 
+#include <stdio.h>
 
 struct debug_option {
     const char * name;
@@ -69,7 +70,7 @@ void r300_init_debug(struct r300_screen * screen)
             }
 
             if (!opt->name) {
-                debug_printf("Unknown debug option: %s\n", options);
+                fprintf(stderr, "Unknown debug option: %s\n", options);
                 printhint = TRUE;
             }
 
@@ -81,10 +82,13 @@ void r300_init_debug(struct r300_screen * screen)
     }
 
     if (printhint || screen->debug & DBG_HELP) {
-        debug_printf("You can enable debug output by setting the RADEON_DEBUG environment variable\n"
-                     "to a comma-separated list of debug options. Available options are:\n");
+        fprintf(stderr, "You can enable debug output by setting "
+                        "the RADEON_DEBUG environment variable\n"
+                        "to a comma-separated list of debug options. "
+                        "Available options are:\n");
+
         for(opt = debug_options; opt->name; ++opt) {
-            debug_printf("    %s: %s\n", opt->name, opt->description);
+            fprintf(stderr, "    %s: %s\n", opt->name, opt->description);
         }
     }
 }
diff --git a/src/gallium/drivers/r300/r300_defines.h b/src/gallium/drivers/r300/r300_defines.h
new file mode 100644 (file)
index 0000000..2e04876
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2010 Marek Olšák <maraeo@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_DEFINES_H
+#define R300_DEFINES_H
+
+#include "pipe/p_defines.h"
+
+#define R300_MAX_TEXTURE_LEVELS         13
+#define R300_MAX_DRAW_VBO_SIZE          (1024 * 1024)
+
+#define R300_TEXTURE_USAGE_TRANSFER     PIPE_TEXTURE_USAGE_CUSTOM
+
+/* Non-atom dirty state flags. */
+#define R300_NEW_FRAGMENT_SHADER                0x00000020
+#define R300_NEW_FRAGMENT_SHADER_CONSTANTS      0x00000040
+#define R300_NEW_VERTEX_SHADER_CONSTANTS        0x10000000
+#define R300_NEW_QUERY                          0x40000000
+#define R300_NEW_KITCHEN_SINK                   0x7fffffff
+
+/* Tiling flags. */
+enum r300_buffer_tiling {
+    R300_BUFFER_LINEAR = 0,
+    R300_BUFFER_TILED,
+    R300_BUFFER_SQUARETILED
+};
+
+#endif
index d8c64dd90019bbf2b69ccbf37fb71cede8d4a3a6..15bcf8907f3c5734a97c30e46b7e2d9fb4cf27a4 100644 (file)
@@ -33,7 +33,6 @@
 #include "r300_fs.h"
 #include "r300_screen.h"
 #include "r300_screen_buffer.h"
-#include "r300_state_inlines.h"
 #include "r300_vs.h"
 
 void r300_emit_blend_state(struct r300_context* r300,
@@ -146,10 +145,8 @@ static const float * get_shader_constant(
     struct rc_constant * constant,
     struct r300_constant_buffer * externals)
 {
-    struct r300_viewport_state* viewport =
-        (struct r300_viewport_state*)r300->viewport_state.state;
-    struct r300_textures_state* texstate =
-        (struct r300_textures_state*)r300->textures_state.state;
+    struct r300_viewport_state* viewport = r300->viewport_state.state;
+    struct r300_textures_state* texstate = r300->textures_state.state;
     static float vec[4] = { 0.0, 0.0, 0.0, 1.0 };
     struct pipe_texture *tex;
 
@@ -165,7 +162,7 @@ static const float * get_shader_constant(
                 /* Factor for converting rectangle coords to
                  * normalized coords. Should only show up on non-r500. */
                 case RC_STATE_R300_TEXRECT_FACTOR:
-                    tex = &texstate->textures[constant->u.State[1]]->tex;
+                    tex = texstate->fragment_sampler_views[constant->u.State[1]]->texture;
                     vec[0] = 1.0 / tex->width0;
                     vec[1] = 1.0 / tex->height0;
                     break;
@@ -189,13 +186,13 @@ static const float * get_shader_constant(
                     break;
 
                 default:
-                    debug_printf("r300: Implementation error: "
+                    fprintf(stderr, "r300: Implementation error: "
                         "Unknown RC_CONSTANT type %d\n", constant->u.State[0]);
             }
             break;
 
         default:
-            debug_printf("r300: Implementation error: "
+            fprintf(stderr, "r300: Implementation error: "
                 "Unhandled constant type %d\n", constant->Type);
     }
 
@@ -517,9 +514,9 @@ static void r300_emit_query_finish(struct r300_context *r300,
                     0, RADEON_GEM_DOMAIN_GTT, 0);
             break;
         default:
-            debug_printf("r300: Implementation error: Chipset reports %d"
+            fprintf(stderr, "r300: Implementation error: Chipset reports %d"
                     " pixel pipes!\n", caps->num_frag_pipes);
-            assert(0);
+            abort();
     }
 
     /* And, finally, reset it to normal... */
@@ -749,8 +746,9 @@ void r300_emit_textures_state(struct r300_context *r300,
             OUT_CS_REG(R300_TX_FORMAT2_0 + (i * 4), texstate->format[2]);
 
             OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (i * 4), 1);
-            OUT_CS_TEX_RELOC(allstate->textures[i], texstate->tile_config,
-                         RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0);
+            OUT_CS_TEX_RELOC((struct r300_texture *)allstate->fragment_sampler_views[i]->texture,
+                             texstate->tile_config,
+                             RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0);
         }
     }
     END_CS;
@@ -893,12 +891,6 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
 
     CS_LOCALS(r300);
 
-    if (!r300screen->caps->has_tcl) {
-        debug_printf("r300: Implementation error: emit_vs_state called,"
-                " but has_tcl is FALSE!\n");
-        return;
-    }
-
     BEGIN_CS(size);
     /* R300_VAP_PVS_CODE_CNTL_0
      * R300_VAP_PVS_CONST_CNTL
@@ -928,28 +920,19 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
 void r300_emit_vs_constant_buffer(struct r300_context* r300,
                                   struct rc_constant_list* constants)
 {
-    int i;
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
+    unsigned i;
     CS_LOCALS(r300);
 
-    if (!r300screen->caps->has_tcl) {
-        debug_printf("r300: Implementation error: emit_vs_constant_buffer called,"
-        " but has_tcl is FALSE!\n");
-        return;
-    }
-
-    if (constants->Count == 0)
-        return;
-
     BEGIN_CS(constants->Count * 4 + 3);
     OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
                (r300screen->caps->is_r500 ?
                R500_PVS_CONST_START : R300_PVS_CONST_START));
     OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, constants->Count * 4);
     for (i = 0; i < constants->Count; i++) {
-        const float * data = get_shader_constant(r300,
-                                                 &constants->Constants[i],
-                                                 &r300->shader_constants[PIPE_SHADER_VERTEX]);
+        const float *data = get_shader_constant(r300,
+                                                &constants->Constants[i],
+                                                &r300->shader_constants[PIPE_SHADER_VERTEX]);
         OUT_CS_32F(data[0]);
         OUT_CS_32F(data[1]);
         OUT_CS_32F(data[2]);
@@ -1043,9 +1026,11 @@ validate:
     }
     /* ...textures... */
     for (i = 0; i < texstate->count; i++) {
-        tex = texstate->textures[i];
-        if (!tex || !texstate->sampler_states[i])
+        if (!(texstate->tx_enable & (1 << i))) {
             continue;
+        }
+
+        tex = (struct r300_texture*)texstate->fragment_sampler_views[i]->texture;
         if (!r300_add_texture(r300->rws, tex,
                              RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
             r300->context.flush(&r300->context, 0, NULL);
@@ -1092,8 +1077,8 @@ validate:
         r300->context.flush(&r300->context, 0, NULL);
         if (invalid) {
             /* Well, hell. */
-            debug_printf("r300: Stuck in validation loop, gonna quit now.");
-            exit(1);
+            fprintf(stderr, "r300: Stuck in validation loop, gonna quit now.\n");
+            abort();
         }
         invalid = TRUE;
         goto validate;
@@ -1158,7 +1143,9 @@ void r300_emit_dirty_state(struct r300_context* r300)
 
     if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) {
         struct r300_vertex_shader* vs = r300->vs_state.state;
-        r300_emit_vs_constant_buffer(r300, &vs->code.constants);
+        if (vs->code.constants.Count) {
+            r300_emit_vs_constant_buffer(r300, &vs->code.constants);
+        }
         r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS;
     }
 
index 9e71e61c303593efe8f106c1264dafa592f327ef..e23fef8c9f7df42a5ac2a9be76e478fc4e1e38f4 100644 (file)
@@ -204,9 +204,8 @@ static void r300_translate_fragment_shader(
     r3xx_compile_fragment_program(&compiler);
     if (compiler.Base.Error) {
         /* XXX failover maybe? */
-        DBG(r300, DBG_FP, "r300: Error compiling fragment program: %s\n",
-            compiler.Base.ErrorMsg);
-        assert(0);
+        fprintf(stderr, "r300 FP: Compiler Error:\n%s",
+                compiler.Base.ErrorMsg);
         abort();
     }
 
index ca00b043c51d85dab138eb1998387d688154ce9e..f8b52d593d526baaef487d2c6cc590dfacc99717 100644 (file)
@@ -30,6 +30,8 @@
 #include "r300_query.h"
 #include "r300_reg.h"
 
+#include <stdio.h>
+
 static struct pipe_query *r300_create_query(struct pipe_context *pipe,
                                             unsigned query_type)
 {
@@ -97,8 +99,10 @@ static void r300_end_query(struct pipe_context* pipe,
                           struct pipe_query* query)
 {
     struct r300_context* r300 = r300_context(pipe);
+    struct r300_query* q = (struct r300_query*)query;
 
     r300_emit_query_end(r300);
+    q->begin_emitted = false;
     r300->query_current = NULL;
 }
 
@@ -135,8 +139,8 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
         if (*map == ~0U) {
             /* Looks like our results aren't ready yet. */
             if (wait) {
-                debug_printf("r300: Despite waiting, OQ results haven't"
-                        come in yet.\n");
+                fprintf(stderr, "r300: Despite waiting, OQ results haven't "
+                                "come in yet.\n");
             }
             temp = ~0U;
             break;
index 47100c83b0b7cd5457d5fa69f2808d290e518bb9..1fb7eac2b344f9b5ef0abf4c754f21d614793f4e 100644 (file)
@@ -41,9 +41,6 @@
 #include "r300_render.h"
 #include "r300_state_derived.h"
 
-/* r300_render: Vertex and index buffer primitive emission. */
-#define R300_MAX_VBO_SIZE  (1024 * 1024)
-
 /* XXX The DRM rejects VAP_ALT_NUM_VERTICES.. */
 //#define ENABLE_ALT_NUM_VERTS
 
@@ -141,7 +138,7 @@ static boolean immd_is_good_idea(struct r300_context *r300,
     unsigned vertex_element_count = r300->velems->count;
     unsigned i, vbi;
 
-    if (count > 4) {
+    if (count > 10) {
         return FALSE;
     }
 
@@ -155,8 +152,7 @@ static boolean immd_is_good_idea(struct r300_context *r300,
         if (!checked[vbi]) {
             vbuf = &r300->vertex_buffer[vbi];
 
-            if (r300_buffer_is_referenced(r300,
-                                         vbuf->buffer)) {
+            if (r300_buffer_is_referenced(r300, vbuf->buffer)) {
                 /* It's a very bad idea to map it... */
                 return FALSE;
             }
@@ -304,10 +300,9 @@ static void r300_emit_draw_elements(struct r300_context *r300,
 #endif
     CS_LOCALS(r300);
 
-    assert((start * indexSize) % 4 == 0);
     assert(count < (1 << 24));
 
-    maxIndex = MIN3(maxIndex, r300->vertex_buffer_max_index, count - minIndex);
+    maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index);
 
     DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n",
         count, minIndex, maxIndex);
@@ -354,6 +349,7 @@ static void r300_emit_draw_elements(struct r300_context *r300,
 
 static void r300_shorten_ubyte_elts(struct r300_context* r300,
                                     struct pipe_buffer** elts,
+                                    unsigned start,
                                     unsigned count)
 {
     struct pipe_screen* screen = r300->context.screen;
@@ -371,6 +367,8 @@ static void r300_shorten_ubyte_elts(struct r300_context* r300,
     in_map = pipe_buffer_map(screen, *elts, PIPE_BUFFER_USAGE_CPU_READ);
     out_map = pipe_buffer_map(screen, new_elts, PIPE_BUFFER_USAGE_CPU_WRITE);
 
+    in_map += start;
+
     for (i = 0; i < count; i++) {
         *out_map = (unsigned short)*in_map;
         in_map++;
@@ -383,6 +381,32 @@ static void r300_shorten_ubyte_elts(struct r300_context* r300,
     *elts = new_elts;
 }
 
+static void r300_align_ushort_elts(struct r300_context *r300,
+                                   struct pipe_buffer **elts,
+                                   unsigned start, unsigned count)
+{
+    struct pipe_screen* screen = r300->context.screen;
+    struct pipe_buffer* new_elts;
+    unsigned short *in_map;
+    unsigned short *out_map;
+
+    new_elts = screen->buffer_create(screen, 32,
+                                     PIPE_BUFFER_USAGE_INDEX |
+                                     PIPE_BUFFER_USAGE_CPU_WRITE |
+                                     PIPE_BUFFER_USAGE_GPU_READ,
+                                     2 * count);
+
+    in_map = pipe_buffer_map(screen, *elts, PIPE_BUFFER_USAGE_CPU_READ);
+    out_map = pipe_buffer_map(screen, new_elts, PIPE_BUFFER_USAGE_CPU_WRITE);
+
+    memcpy(out_map, in_map+start, 2 * count);
+
+    pipe_buffer_unmap(screen, *elts);
+    pipe_buffer_unmap(screen, new_elts);
+
+    *elts = new_elts;
+}
+
 /* This is the fast-path drawing & emission for HW TCL. */
 void r300_draw_range_elements(struct pipe_context* pipe,
                               struct pipe_buffer* indexBuffer,
@@ -408,8 +432,12 @@ void r300_draw_range_elements(struct pipe_context* pipe,
     }
 
     if (indexSize == 1) {
-        r300_shorten_ubyte_elts(r300, &indexBuffer, count);
+        r300_shorten_ubyte_elts(r300, &indexBuffer, start, count);
         indexSize = 2;
+        start = 0;
+    } else if (indexSize == 2 && start % 2 != 0) {
+        r300_align_ushort_elts(r300, &indexBuffer, start, count);
+        start = 0;
     }
 
     r300_update_derived_state(r300);
@@ -541,13 +569,6 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe,
 
     draw_set_mapped_element_buffer(r300->draw, 0, NULL);
 
-    draw_set_mapped_constant_buffer(r300->draw,
-                                   PIPE_SHADER_VERTEX,
-                                    0,
-                                   r300->shader_constants[PIPE_SHADER_VERTEX].constants,
-                                   r300->shader_constants[PIPE_SHADER_VERTEX].count *
-                (sizeof(float) * 4));
-
     draw_arrays(r300->draw, mode, start, count);
 
     for (i = 0; i < r300->vertex_buffer_count; i++) {
@@ -586,13 +607,6 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe,
     draw_set_mapped_element_buffer_range(r300->draw, indexSize,
                                          minIndex, maxIndex, indices);
 
-    draw_set_mapped_constant_buffer(r300->draw,
-                                   PIPE_SHADER_VERTEX,
-                                    0,
-            r300->shader_constants[PIPE_SHADER_VERTEX].constants,
-            r300->shader_constants[PIPE_SHADER_VERTEX].count *
-                (sizeof(float) * 4));
-
     draw_arrays(r300->draw, mode, start, count);
 
     for (i = 0; i < r300->vertex_buffer_count; i++) {
@@ -658,9 +672,9 @@ static boolean r300_render_allocate_vertices(struct vbuf_render* render,
         r300render->vbo = pipe_buffer_create(screen,
                                              64,
                                              PIPE_BUFFER_USAGE_VERTEX,
-                                             R300_MAX_VBO_SIZE);
+                                             R300_MAX_DRAW_VBO_SIZE);
         r300render->vbo_offset = 0;
-        r300render->vbo_size = R300_MAX_VBO_SIZE;
+        r300render->vbo_size = R300_MAX_DRAW_VBO_SIZE;
     }
 
     r300render->vertex_size = vertex_size;
index 3e31688f8e8a1092bc39c5f233e3c2d11f59f724..e46f836dd2c0601e5f1b2d5f8aef8b46376e9258 100644 (file)
 
 #include "r300_context.h"
 #include "r300_texture.h"
-
-#include "radeon_winsys.h"
-
 #include "r300_screen_buffer.h"
+#include "r300_winsys.h"
 
 /* Return the identifier behind whom the brave coders responsible for this
  * amalgamation of code, sweat, and duct tape, routinely obscure their names.
@@ -166,7 +164,7 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
         case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
             return 0;
         default:
-            debug_printf("r300: Implementation error: Bad param %d\n",
+            fprintf(stderr, "r300: Implementation error: Bad param %d\n",
                 param);
             return 0;
     }
@@ -195,7 +193,7 @@ static float r300_get_paramf(struct pipe_screen* pscreen, int param)
         case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
             return 16.0f;
         default:
-            debug_printf("r300: Implementation error: Bad paramf %d\n",
+            fprintf(stderr, "r300: Implementation error: Bad paramf %d\n",
                 param);
             return 0.0f;
     }
@@ -214,7 +212,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
     boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM;
 
     if (target >= PIPE_MAX_TEXTURE_TYPES) {
-        debug_printf("r300: Implementation error: Received bogus texture "
+        fprintf(stderr, "r300: Implementation error: Received bogus texture "
             "target %d in %s\n", target, __FUNCTION__);
         return FALSE;
     }
index 1ccc0bfb7a57557a1a106506410b69d0bc60c4d5..1cf8b7452d729acce2b80a783e2bf1e0cde68e9b 100644 (file)
@@ -28,9 +28,7 @@
 
 #include "r300_chipset.h"
 
-#define R300_TEXTURE_USAGE_TRANSFER PIPE_TEXTURE_USAGE_CUSTOM
-
-struct radeon_winsys;
+#include <stdio.h>
 
 struct r300_screen {
     /* Parent class */
@@ -84,7 +82,7 @@ static INLINE void SCREEN_DBG(struct r300_screen * screen, unsigned flags,
     if (SCREEN_DBG_ON(screen, flags)) {
         va_list va;
         va_start(va, fmt);
-        debug_vprintf(fmt, va);
+        vfprintf(stderr, fmt, va);
         va_end(va);
     }
 }
index b97d0d76a4a1f652c63061d735a989a327c85550..a1cd48ee730a82c201ac922e716da40a456fc973 100644 (file)
@@ -237,7 +237,7 @@ r300_buffer_map_range(struct pipe_screen *screen,
        }
     }
 just_map:
-    map = rws->buffer_map(rws, rbuf->buf, usage | R300_USAGE_FLAG_DONT_SYNC);
+    map = rws->buffer_map(rws, rbuf->buf, usage);
    
     return map;
 }
index 712e9280e3c402d46c81caea0fa211b9e9eaac33..39e05583dd47dcb26eebd181274a23344cc231f6 100644 (file)
@@ -38,8 +38,7 @@
 #include "r300_state_inlines.h"
 #include "r300_fs.h"
 #include "r300_vs.h"
-
-#include "radeon_winsys.h"
+#include "r300_winsys.h"
 
 /* r300_state: Functions used to intialize state context by translating
  * Gallium state objects into semi-native r300 state objects. */
@@ -528,8 +527,8 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
         if (tex) {
             r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
                                             tex->pitch[0],
-                                            tex->microtile != 0,
-                                            tex->macrotile != 0);
+                                            tex->microtile,
+                                            tex->macrotile);
         }
     }
     if (old_state->zsbuf &&
@@ -540,8 +539,8 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
         if (tex) {
             r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
                                             tex->pitch[0],
-                                            tex->microtile != 0,
-                                            tex->macrotile != 0);
+                                            tex->microtile,
+                                            tex->macrotile);
         }
     }
 
@@ -552,8 +551,8 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
 
         r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
                                         tex->pitch[level],
-                                        tex->microtile != 0,
-                                        tex->mip_macrotile[level] != 0);
+                                        tex->microtile,
+                                        tex->mip_macrotile[level]);
     }
     if (new_state->zsbuf) {
         tex = (struct r300_texture*)new_state->zsbuf->texture;
@@ -561,8 +560,8 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
 
         r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
                                         tex->pitch[level],
-                                        tex->microtile != 0,
-                                        tex->mip_macrotile[level] != 0);
+                                        tex->microtile,
+                                        tex->mip_macrotile[level]);
     }
 }
 
@@ -576,9 +575,8 @@ static void
     unsigned max_width, max_height;
     uint32_t zbuffer_bpp = 0;
 
-
     if (state->nr_cbufs > 4) {
-        debug_printf("r300: Implementation error: Too many MRTs in %s, "
+        fprintf(stderr, "r300: Implementation error: Too many MRTs in %s, "
             "refusing to bind framebuffer state!\n", __FUNCTION__);
         return;
     }
@@ -592,7 +590,7 @@ static void
     }
 
     if (state->width > max_width || state->height > max_height) {
-        debug_printf("r300: Implementation error: Render targets are too "
+        fprintf(stderr, "r300: Implementation error: Render targets are too "
         "big in %s, refusing to bind framebuffer state!\n", __FUNCTION__);
         return;
     }
@@ -933,13 +931,14 @@ static void r300_delete_sampler_state(struct pipe_context* pipe, void* state)
     FREE(state);
 }
 
-static void r300_set_sampler_textures(struct pipe_context* pipe,
-                                      unsigned count,
-                                      struct pipe_texture** texture)
+static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
+                                            unsigned count,
+                                            struct pipe_sampler_view** views)
 {
     struct r300_context* r300 = r300_context(pipe);
     struct r300_textures_state* state =
         (struct r300_textures_state*)r300->textures_state.state;
+    struct r300_texture *texture;
     unsigned i;
     boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500;
     boolean dirty_tex = FALSE;
@@ -950,13 +949,20 @@ static void r300_set_sampler_textures(struct pipe_context* pipe,
     }
 
     for (i = 0; i < count; i++) {
-        if (state->textures[i] != (struct r300_texture*)texture[i]) {
-            pipe_texture_reference((struct pipe_texture**)&state->textures[i],
-                                   texture[i]);
+        if (state->fragment_sampler_views[i] != views[i]) {
+            pipe_sampler_view_reference(&state->fragment_sampler_views[i],
+                                        views[i]);
+
+            if (!views[i]) {
+                continue;
+            }
+
+            /* A new sampler view (= texture)... */
             dirty_tex = TRUE;
 
             /* R300-specific - set the texrect factor in the fragment shader */
-            if (!is_r500 && state->textures[i]->is_npot) {
+            texture = (struct r300_texture *)views[i]->texture;
+            if (!is_r500 && texture->is_npot) {
                 /* XXX It would be nice to re-emit just 1 constant,
                  * XXX not all of them */
                 r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
@@ -965,9 +971,9 @@ static void r300_set_sampler_textures(struct pipe_context* pipe,
     }
 
     for (i = count; i < 8; i++) {
-        if (state->textures[i]) {
-            pipe_texture_reference((struct pipe_texture**)&state->textures[i],
-                NULL);
+        if (state->fragment_sampler_views[i]) {
+            pipe_sampler_view_reference(&state->fragment_sampler_views[i],
+                                        NULL);
         }
     }
 
@@ -980,6 +986,32 @@ static void r300_set_sampler_textures(struct pipe_context* pipe,
     }
 }
 
+static struct pipe_sampler_view *
+r300_create_sampler_view(struct pipe_context *pipe,
+                         struct pipe_texture *texture,
+                         const struct pipe_sampler_view *templ)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
+
+   return view;
+}
+
+static void
+r300_sampler_view_destroy(struct pipe_context *pipe,
+                          struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
+}
+
 static void r300_set_scissor_state(struct pipe_context* pipe,
                                    const struct pipe_scissor_state* state)
 {
@@ -1041,117 +1073,71 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
                                     const struct pipe_vertex_buffer* buffers)
 {
     struct r300_context* r300 = r300_context(pipe);
-    int i;
-    unsigned max_index = (1 << 24) - 1;
-    boolean any_user_buffer = false;
+    struct pipe_vertex_buffer *vbo;
+    unsigned i, max_index = (1 << 24) - 1;
+    boolean any_user_buffer = FALSE;
 
     if (count == r300->vertex_buffer_count &&
-       memcmp(r300->vertex_buffer, buffers, count * sizeof(buffers[0])) == 0)
+        memcmp(r300->vertex_buffer, buffers,
+            sizeof(struct pipe_vertex_buffer) * count) == 0) {
         return;
+    }
 
+    /* Check if the stride is aligned to the size of DWORD. */
     for (i = 0; i < count; i++) {
-       pipe_buffer_reference(&r300->vertex_buffer[i].buffer, buffers[i].buffer);
-       if (r300_buffer_is_user_buffer(buffers[i].buffer))
-           any_user_buffer = true;
-        max_index = MIN2(buffers[i].max_index, max_index);
+        if (buffers[i].buffer) {
+            if (buffers[i].stride % 4 != 0) {
+                // XXX Shouldn't we align the buffer?
+                fprintf(stderr, "r300_set_vertex_buffers: "
+                        "Unaligned buffer stride %i isn't supported.\n",
+                        buffers[i].stride);
+                assert(0);
+                abort();
+            }
+        }
     }
 
-    for ( ; i < r300->vertex_buffer_count; i++)
-       pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL);
-
-    memcpy(r300->vertex_buffer, buffers,
-          sizeof(struct pipe_vertex_buffer) * count);
+    for (i = 0; i < count; i++) {
+        /* Why, yes, I AM casting away constness. How did you know? */
+        vbo = (struct pipe_vertex_buffer*)&buffers[i];
 
-    r300->vertex_buffer_count = count;
-    r300->vertex_buffer_max_index = max_index;
-    r300->any_user_vbs = any_user_buffer;
+        /* Reference our buffer. */
+        pipe_buffer_reference(&r300->vertex_buffer[i].buffer, vbo->buffer);
 
-    if (r300->draw) {
-        draw_flush(r300->draw);
-        draw_set_vertex_buffers(r300->draw, count, buffers);
-    }
-}
-
-static boolean r300_validate_aos(struct r300_context *r300)
-{
-    struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
-    struct pipe_vertex_element *velem = r300->velems->velem;
-    int i;
-
-    /* Check if formats and strides are aligned to the size of DWORD. */
-    for (i = 0; i < r300->velems->count; i++) {
-        if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 ||
-            util_format_get_blocksize(velem[i].src_format) % 4 != 0) {
-            return FALSE;
+        /* Skip NULL buffers */
+        if (!buffers[i].buffer) {
+            continue;
         }
-    }
-    return TRUE;
-}
 
-static void r300_draw_emit_attrib(struct r300_context* r300,
-                                  enum attrib_emit emit,
-                                  enum interp_mode interp,
-                                  int index)
-{
-    struct r300_vertex_shader* vs = r300->vs_state.state;
-    struct tgsi_shader_info* info = &vs->info;
-    int output;
-
-    output = draw_find_shader_output(r300->draw,
-                                     info->output_semantic_name[index],
-                                     info->output_semantic_index[index]);
-    draw_emit_vertex_attr(&r300->vertex_info, emit, interp, output);
-}
+        if (r300_buffer_is_user_buffer(vbo->buffer)) {
+            any_user_buffer = TRUE;
+        }
 
-static void r300_draw_emit_all_attribs(struct r300_context* r300)
-{
-    struct r300_vertex_shader* vs = r300->vs_state.state;
-    struct r300_shader_semantics* vs_outputs = &vs->outputs;
-    int i, gen_count;
-
-    /* Position. */
-    if (vs_outputs->pos != ATTR_UNUSED) {
-        r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
-                              vs_outputs->pos);
-    } else {
-        assert(0);
-    }
+        if (vbo->max_index == ~0) {
+            /* Bogus value from broken state tracker; hax it. */
+            vbo->max_index =
+                (vbo->buffer->size - vbo->buffer_offset) / vbo->stride;
+        }
 
-    /* Point size. */
-    if (vs_outputs->psize != ATTR_UNUSED) {
-        r300_draw_emit_attrib(r300, EMIT_1F_PSIZE, INTERP_POS,
-                              vs_outputs->psize);
+        max_index = MIN2(vbo->max_index, max_index);
     }
 
-    /* Colors. */
-    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
-        if (vs_outputs->color[i] != ATTR_UNUSED) {
-            r300_draw_emit_attrib(r300, EMIT_4F, INTERP_LINEAR,
-                                  vs_outputs->color[i]);
-        }
+    for (; i < r300->vertex_buffer_count; i++) {
+        /* Dereference any old buffers. */
+        pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL);
     }
 
-    /* XXX Back-face colors. */
+    memcpy(r300->vertex_buffer, buffers,
+        sizeof(struct pipe_vertex_buffer) * count);
 
-    /* Texture coordinates. */
-    gen_count = 0;
-    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
-        if (vs_outputs->generic[i] != ATTR_UNUSED) {
-            r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
-                                  vs_outputs->generic[i]);
-            gen_count++;
-        }
-    }
+    r300->vertex_buffer_count = count;
+    r300->vertex_buffer_max_index = max_index;
+    r300->any_user_vbs = any_user_buffer;
 
-    /* Fog coordinates. */
-    if (vs_outputs->fog != ATTR_UNUSED) {
-        r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
-                              vs_outputs->fog);
-        gen_count++;
+    if (r300->draw) {
+        draw_flush(r300->draw);
+        draw_set_vertex_buffers(r300->draw, count, buffers);
     }
-
-    /* XXX magic */
-    assert(gen_count <= 8);
 }
 
 /* Update the PSC tables. */
@@ -1193,70 +1179,13 @@ static void r300_vertex_psc(struct r300_vertex_element_state *velems)
     vstream->count = (i >> 1) + 1;
 }
 
-/* Update the PSC tables for SW TCL, using Draw. */
-static void r300_swtcl_vertex_psc(struct r300_context *r300,
-                                  struct r300_vertex_element_state *velems)
-{
-    struct r300_vertex_stream_state *vstream = &velems->vertex_stream;
-    struct r300_vertex_shader* vs = r300->vs_state.state;
-    struct vertex_info* vinfo = &r300->vertex_info;
-    uint16_t type, swizzle;
-    enum pipe_format format;
-    unsigned i, attrib_count;
-    int* vs_output_tab = vs->stream_loc_notcl;
-
-    /* For each Draw attribute, route it to the fragment shader according
-     * to the vs_output_tab. */
-    attrib_count = vinfo->num_attribs;
-    DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count);
-    for (i = 0; i < attrib_count; i++) {
-        DBG(r300, DBG_DRAW, "r300: attrib: offset %d, interp %d, size %d,"
-               " vs_output_tab %d\n", vinfo->attrib[i].src_index,
-               vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit,
-               vs_output_tab[i]);
-    }
-
-    for (i = 0; i < attrib_count; i++) {
-        /* Make sure we have a proper destination for our attribute. */
-        assert(vs_output_tab[i] != -1);
-
-        format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
-
-        /* Obtain the type of data in this attribute. */
-        type = r300_translate_vertex_data_type(format) |
-            vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT;
-
-        /* Obtain the swizzle for this attribute. Note that the default
-         * swizzle in the hardware is not XYZW! */
-        swizzle = r300_translate_vertex_data_swizzle(format);
-
-        /* Add the attribute to the PSC table. */
-        if (i & 1) {
-            vstream->vap_prog_stream_cntl[i >> 1] |= type << 16;
-            vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16;
-        } else {
-            vstream->vap_prog_stream_cntl[i >> 1] |= type;
-            vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle;
-        }
-    }
-
-    /* Set the last vector in the PSC. */
-    if (i) {
-        i -= 1;
-    }
-    vstream->vap_prog_stream_cntl[i >> 1] |=
-        (R300_LAST_VEC << (i & 1 ? 16 : 0));
-
-    vstream->count = (i >> 1) + 1;
-}
-
 static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
                                                unsigned count,
                                                const struct pipe_vertex_element* attribs)
 {
-    struct r300_context *r300 = r300_context(pipe);
     struct r300_screen* r300screen = r300_screen(pipe->screen);
     struct r300_vertex_element_state *velems;
+    unsigned i, size;
 
     assert(count <= PIPE_MAX_ATTRIBS);
     velems = CALLOC_STRUCT(r300_vertex_element_state);
@@ -1265,12 +1194,21 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
         memcpy(velems->velem, attribs, sizeof(struct pipe_vertex_element) * count);
 
         if (r300screen->caps->has_tcl) {
+            /* Check if the format is aligned to the size of DWORD. */
+            for (i = 0; i < count; i++) {
+                size = util_format_get_blocksize(attribs[i].src_format);
+
+                if (size % 4 != 0) {
+                    /* XXX Shouldn't we align the format? */
+                    fprintf(stderr, "r300_create_vertex_elements_state: "
+                            "Unaligned format %s:%i isn't supported\n",
+                            util_format_name(attribs[i].src_format), size);
+                    assert(0);
+                    abort();
+                }
+            }
+
             r300_vertex_psc(velems);
-        } else {
-            memset(&r300->vertex_info, 0, sizeof(struct vertex_info));
-            r300_draw_emit_all_attribs(r300);
-            draw_compute_vertex_size(&r300->vertex_info);
-            r300_swtcl_vertex_psc(r300, velems);
         }
     }
     return velems;
@@ -1293,12 +1231,6 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe,
         draw_set_vertex_elements(r300->draw, velems->count, velems->velem);
     }
 
-    if (!r300_validate_aos(r300)) {
-        /* XXX We should fallback using draw. */
-        assert(0);
-        abort();
-    }
-
     UPDATE_STATE(&velems->vertex_stream, r300->vertex_stream_state);
     r300->vertex_stream_state.size = (1 + velems->vertex_stream.count) * 2;
 }
@@ -1419,7 +1351,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
 
     /* XXX Subtract immediates and RC_STATE_* variables. */
     if (buf->size > (sizeof(float) * 4 * max_size)) {
-        debug_printf("r300: Max size of the constant buffer is "
+        fprintf(stderr, "r300: Max size of the constant buffer is "
                       "%i*4 floats.\n", max_size);
         abort();
     }
@@ -1432,10 +1364,14 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
         if (r300screen->caps->has_tcl) {
             r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS;
             r300->pvs_flush.dirty = TRUE;
+        } else if (r300->draw) {
+            draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX,
+                0, r300->shader_constants[PIPE_SHADER_VERTEX].constants,
+                buf->size);
         }
-    }
-    else if (shader == PIPE_SHADER_FRAGMENT)
+    } else if (shader == PIPE_SHADER_FRAGMENT) {
         r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
+    }
 }
 
 void r300_init_state_functions(struct r300_context* r300)
@@ -1473,7 +1409,9 @@ void r300_init_state_functions(struct r300_context* r300)
     r300->context.bind_vertex_sampler_states = r300_lacks_vertex_textures;
     r300->context.delete_sampler_state = r300_delete_sampler_state;
 
-    r300->context.set_fragment_sampler_textures = r300_set_sampler_textures;
+    r300->context.set_fragment_sampler_views = r300_set_fragment_sampler_views;
+    r300->context.create_sampler_view = r300_create_sampler_view;
+    r300->context.sampler_view_destroy = r300_sampler_view_destroy;
 
     r300->context.set_scissor_state = r300_set_scissor_state;
 
index 6b9f61acd7bcfc95279bb23b328c101c6ca1080b..bc5431c802da721366b9e3893ca6646dcc289b13 100644 (file)
 /* r300_state_derived: Various bits of state which are dependent upon
  * currently bound CSO data. */
 
+static void r300_draw_emit_attrib(struct r300_context* r300,
+                                  enum attrib_emit emit,
+                                  enum interp_mode interp,
+                                  int index)
+{
+    struct r300_vertex_shader* vs = r300->vs_state.state;
+    struct tgsi_shader_info* info = &vs->info;
+    int output;
+
+    output = draw_find_shader_output(r300->draw,
+                                     info->output_semantic_name[index],
+                                     info->output_semantic_index[index]);
+    draw_emit_vertex_attr(&r300->vertex_info, emit, interp, output);
+}
+
+static void r300_draw_emit_all_attribs(struct r300_context* r300)
+{
+    struct r300_vertex_shader* vs = r300->vs_state.state;
+    struct r300_shader_semantics* vs_outputs = &vs->outputs;
+    int i, gen_count;
+
+    /* Position. */
+    if (vs_outputs->pos != ATTR_UNUSED) {
+        r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
+                              vs_outputs->pos);
+    } else {
+        assert(0);
+    }
+
+    /* Point size. */
+    if (vs_outputs->psize != ATTR_UNUSED) {
+        r300_draw_emit_attrib(r300, EMIT_1F_PSIZE, INTERP_POS,
+                              vs_outputs->psize);
+    }
+
+    /* Colors. */
+    for (i = 0; i < ATTR_COLOR_COUNT; i++) {
+        if (vs_outputs->color[i] != ATTR_UNUSED) {
+            r300_draw_emit_attrib(r300, EMIT_4F, INTERP_LINEAR,
+                                  vs_outputs->color[i]);
+        }
+    }
+
+    /* XXX Back-face colors. */
+
+    /* Texture coordinates. */
+    gen_count = 0;
+    for (i = 0; i < ATTR_GENERIC_COUNT; i++) {
+        if (vs_outputs->generic[i] != ATTR_UNUSED) {
+            r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
+                                  vs_outputs->generic[i]);
+            gen_count++;
+        }
+    }
+
+    /* Fog coordinates. */
+    if (vs_outputs->fog != ATTR_UNUSED) {
+        r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE,
+                              vs_outputs->fog);
+        gen_count++;
+    }
+
+    /* XXX magic */
+    assert(gen_count <= 8);
+}
+
+/* Update the PSC tables for SW TCL, using Draw. */
+static void r300_swtcl_vertex_psc(struct r300_context *r300)
+{
+    struct r300_vertex_stream_state *vstream = r300->vertex_stream_state.state;
+    struct r300_vertex_shader* vs = r300->vs_state.state;
+    struct vertex_info* vinfo = &r300->vertex_info;
+    uint16_t type, swizzle;
+    enum pipe_format format;
+    unsigned i, attrib_count;
+    int* vs_output_tab = vs->stream_loc_notcl;
+
+    /* XXX hax */
+    memset(vstream, 0, sizeof(struct r300_vertex_stream_state));
+
+    /* For each Draw attribute, route it to the fragment shader according
+     * to the vs_output_tab. */
+    attrib_count = vinfo->num_attribs;
+    DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count);
+    for (i = 0; i < attrib_count; i++) {
+        DBG(r300, DBG_DRAW, "r300: attrib: offset %d, interp %d, size %d,"
+               " vs_output_tab %d\n", vinfo->attrib[i].src_index,
+               vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit,
+               vs_output_tab[i]);
+
+        /* Make sure we have a proper destination for our attribute. */
+        assert(vs_output_tab[i] != -1);
+
+        format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
+
+        /* Obtain the type of data in this attribute. */
+        type = r300_translate_vertex_data_type(format) |
+            vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT;
+
+        /* Obtain the swizzle for this attribute. Note that the default
+         * swizzle in the hardware is not XYZW! */
+        swizzle = r300_translate_vertex_data_swizzle(format);
+
+        /* Add the attribute to the PSC table. */
+        if (i & 1) {
+            vstream->vap_prog_stream_cntl[i >> 1] |= type << 16;
+            vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16;
+        } else {
+            vstream->vap_prog_stream_cntl[i >> 1] |= type;
+            vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle;
+        }
+    }
+
+    /* Set the last vector in the PSC. */
+    if (i) {
+        i -= 1;
+    }
+    vstream->vap_prog_stream_cntl[i >> 1] |=
+        (R300_LAST_VEC << (i & 1 ? 16 : 0));
+
+    vstream->count = (i >> 1) + 1;
+    r300->vertex_stream_state.dirty = TRUE;
+    r300->vertex_stream_state.size = (1 + vstream->count) * 2;
+}
+
 static void r300_rs_col(struct r300_rs_block* rs, int id, int ptr,
                         boolean swizzle_0001)
 {
@@ -332,20 +457,25 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
         (struct r300_textures_state*)r300->textures_state.state;
     struct r300_texture_sampler_state *texstate;
     struct r300_sampler_state *sampler;
+    struct pipe_sampler_view *view;
     struct r300_texture *tex;
     unsigned min_level, max_level, i, size;
     unsigned count = MIN2(state->texture_count, state->sampler_count);
 
     state->tx_enable = 0;
+    state->count = 0;
     size = 2;
 
     for (i = 0; i < count; i++) {
-        if (state->textures[i] && state->sampler_states[i]) {
+        if (state->fragment_sampler_views[i] && state->sampler_states[i]) {
             state->tx_enable |= 1 << i;
 
-            tex = state->textures[i];
+            view = state->fragment_sampler_views[i];
+            tex = (struct r300_texture *)view->texture;
             sampler = state->sampler_states[i];
 
+            assert(view->format == tex->tex.format);
+
             texstate = &state->regs[i];
             memcpy(texstate->format, &tex->state, sizeof(uint32_t)*3);
             texstate->filter[0] = sampler->filter0;
@@ -367,8 +497,10 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
             } else {
                 /* determine min/max levels */
                 /* the MAX_MIP level is the largest (finest) one */
-                max_level = MIN2(sampler->max_lod, tex->tex.last_level);
-                min_level = MIN2(sampler->min_lod, max_level);
+                max_level = MIN3(sampler->max_lod + view->first_level,
+                                 tex->tex.last_level, view->last_level);
+                min_level = MIN2(sampler->min_lod + view->first_level,
+                                 max_level);
                 texstate->format[0] |= R300_TX_NUM_LEVELS(max_level);
                 texstate->filter[0] |= R300_TX_MAX_MIP_LEVEL(min_level);
             }
@@ -393,5 +525,12 @@ void r300_update_derived_state(struct r300_context* r300)
         r300_merge_textures_and_samplers(r300);
     }
 
+    if (r300->draw) {
+        memset(&r300->vertex_info, 0, sizeof(struct vertex_info));
+        r300_draw_emit_all_attribs(r300);
+        draw_compute_vertex_size(&r300->vertex_info);
+        r300_swtcl_vertex_psc(r300);
+    }
+
     r300_update_ztop(r300);
 }
index 8485d4f8f9470dc8bff96a9357c49561fd928f46..02d09c008c8f27222017d786181cb6d937262dff 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "r300_reg.h"
 
+#include <stdio.h>
+
 /* Some maths. These should probably find their way to u_math, if needed. */
 
 static INLINE int pack_float_16_6x(float f) {
@@ -54,7 +56,7 @@ static INLINE uint32_t r300_translate_blend_function(int blend_func)
         case PIPE_BLEND_MAX:
             return R300_COMB_FCN_MAX;
         default:
-            debug_printf("r300: Unknown blend function %d\n", blend_func);
+            fprintf(stderr, "r300: Unknown blend function %d\n", blend_func);
             assert(0);
             break;
     }
@@ -100,13 +102,13 @@ static INLINE uint32_t r300_translate_blend_factor(int blend_fact)
         case PIPE_BLENDFACTOR_SRC1_ALPHA:
         case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
         case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
-            debug_printf("r300: Implementation error: "
+            fprintf(stderr, "r300: Implementation error: "
                 "Bad blend factor %d not supported!\n", blend_fact);
             assert(0);
             break;
 
         default:
-            debug_printf("r300: Unknown blend factor %d\n", blend_fact);
+            fprintf(stderr, "r300: Unknown blend factor %d\n", blend_fact);
             assert(0);
             break;
     }
@@ -135,7 +137,7 @@ static INLINE uint32_t r300_translate_depth_stencil_function(int zs_func)
         case PIPE_FUNC_ALWAYS:
             return R300_ZS_ALWAYS;
         default:
-            debug_printf("r300: Unknown depth/stencil function %d\n",
+            fprintf(stderr, "r300: Unknown depth/stencil function %d\n",
                 zs_func);
             assert(0);
             break;
@@ -163,7 +165,7 @@ static INLINE uint32_t r300_translate_stencil_op(int s_op)
         case PIPE_STENCIL_OP_INVERT:
             return R300_ZS_INVERT;
         default:
-            debug_printf("r300: Unknown stencil op %d", s_op);
+            fprintf(stderr, "r300: Unknown stencil op %d", s_op);
             assert(0);
             break;
     }
@@ -190,7 +192,7 @@ static INLINE uint32_t r300_translate_alpha_function(int alpha_func)
         case PIPE_FUNC_ALWAYS:
             return R300_FG_ALPHA_FUNC_ALWAYS;
         default:
-            debug_printf("r300: Unknown alpha function %d", alpha_func);
+            fprintf(stderr, "r300: Unknown alpha function %d", alpha_func);
             assert(0);
             break;
     }
@@ -209,7 +211,7 @@ r300_translate_polygon_mode_front(unsigned mode) {
             return R300_GA_POLY_MODE_FRONT_PTYPE_POINT;
 
         default:
-            debug_printf("r300: Bad polygon mode %i in %s\n", mode,
+            fprintf(stderr, "r300: Bad polygon mode %i in %s\n", mode,
                 __FUNCTION__);
             return R300_GA_POLY_MODE_FRONT_PTYPE_TRI;
     }
@@ -227,7 +229,7 @@ r300_translate_polygon_mode_back(unsigned mode) {
             return R300_GA_POLY_MODE_BACK_PTYPE_POINT;
 
         default:
-            debug_printf("r300: Bad polygon mode %i in %s\n", mode,
+            fprintf(stderr, "r300: Bad polygon mode %i in %s\n", mode,
                 __FUNCTION__);
             return R300_GA_POLY_MODE_BACK_PTYPE_TRI;
     }
@@ -255,7 +257,7 @@ static INLINE uint32_t r300_translate_wrap(int wrap)
         case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
             return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
         default:
-            debug_printf("r300: Unknown texture wrap %d", wrap);
+            fprintf(stderr, "r300: Unknown texture wrap %d", wrap);
             assert(0);
             return 0;
     }
@@ -276,7 +278,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip,
             retval |= R300_TX_MIN_FILTER_LINEAR;
             break;
         default:
-            debug_printf("r300: Unknown texture filter %d\n", min);
+            fprintf(stderr, "r300: Unknown texture filter %d\n", min);
             assert(0);
             break;
         }
@@ -288,7 +290,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip,
             retval |= R300_TX_MAG_FILTER_LINEAR;
             break;
         default:
-            debug_printf("r300: Unknown texture filter %d\n", mag);
+            fprintf(stderr, "r300: Unknown texture filter %d\n", mag);
             assert(0);
             break;
         }
@@ -304,7 +306,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip,
             retval |= R300_TX_MIN_FILTER_MIP_LINEAR;
             break;
         default:
-            debug_printf("r300: Unknown texture filter %d\n", mip);
+            fprintf(stderr, "r300: Unknown texture filter %d\n", mip);
             assert(0);
             break;
     }
@@ -370,7 +372,7 @@ r300_translate_vertex_data_type(enum pipe_format format) {
     desc = util_format_description(format);
 
     if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
-        debug_printf("r300: Bad format %s in %s:%d\n", util_format_name(format),
+        fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format),
             __FUNCTION__, __LINE__);
         assert(0);
     }
@@ -391,7 +393,7 @@ r300_translate_vertex_data_type(enum pipe_format format) {
                     result = R300_DATA_TYPE_FLOAT_1 + (components - 1);
                     break;
                 default:
-                    debug_printf("r300: Bad format %s in %s:%d\n",
+                    fprintf(stderr, "r300: Bad format %s in %s:%d\n",
                         util_format_name(format), __FUNCTION__, __LINE__);
                     assert(0);
             }
@@ -412,15 +414,15 @@ r300_translate_vertex_data_type(enum pipe_format format) {
                     }
                     break;
                 default:
-                    debug_printf("r300: Bad format %s in %s:%d\n",
+                    fprintf(stderr, "r300: Bad format %s in %s:%d\n",
                         util_format_name(format), __FUNCTION__, __LINE__);
-                    debug_printf("r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n",
+                    fprintf(stderr, "r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n",
                         util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0));
                     assert(0);
             }
             break;
         default:
-            debug_printf("r300: Bad format %s in %s:%d\n",
+            fprintf(stderr, "r300: Bad format %s in %s:%d\n",
                 util_format_name(format), __FUNCTION__, __LINE__);
             assert(0);
     }
@@ -442,7 +444,7 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) {
     assert(format);
 
     if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
-        debug_printf("r300: Bad format %s in %s:%d\n",
+        fprintf(stderr, "r300: Bad format %s in %s:%d\n",
             util_format_name(format), __FUNCTION__, __LINE__);
         return 0;
     }
index 4a2c68269b1003bad0b139c9800f2a3619ba6720..88ae75bb816b16941bd2ad95aa619101cc6630d6 100644 (file)
@@ -127,7 +127,7 @@ void r300_emit_invariant_state(struct r300_context* r300,
     OUT_CS_REG(R300_ZB_HIZ_PITCH, 0x00000000);
 
     /* XXX */
-    OUT_CS_REG(R300_SC_CLIP_RULE, 0xaaaa);
+    OUT_CS_REG(R300_SC_CLIP_RULE, 0xFFFF);
 
     END_CS;
 }
index 7c7656068bba99e3391d395008cf92b08c6bb6e8..22ccadfe3ddf09008485c6d27be4494db8508439 100644 (file)
@@ -31,8 +31,7 @@
 #include "r300_texture.h"
 #include "r300_screen.h"
 #include "r300_state_inlines.h"
-
-#include "radeon_winsys.h"
+#include "r300_winsys.h"
 
 #define TILE_WIDTH 0
 #define TILE_HEIGHT 1
@@ -46,6 +45,18 @@ static const unsigned microblock_table[5][3][2] = {
     {{ 2, 1}, {0, 0}, {0, 0}}  /* 128 bits per pixel */
 };
 
+/* Return true for non-compressed and non-YUV formats. */
+static boolean r300_format_is_plain(enum pipe_format format)
+{
+    const struct util_format_description *desc = util_format_description(format);
+
+    if (!format) {
+        return FALSE;
+    }
+
+    return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN;
+}
+
 /* Translate a pipe_format into a useful texture format for sampling.
  *
  * Some special formats are translated directly using R300_EASY_TX_FORMAT,
@@ -148,7 +159,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
     }
 
     /* Compressed formats. */
-    if (desc->layout == UTIL_FORMAT_LAYOUT_COMPRESSED) {
+    if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
         switch (format) {
             case PIPE_FORMAT_DXT1_RGB:
             case PIPE_FORMAT_DXT1_RGBA:
@@ -302,7 +313,6 @@ static uint32_t r300_translate_colorformat(enum pipe_format format)
         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 R300_COLOR_FORMAT_I8;
@@ -311,24 +321,19 @@ static uint32_t r300_translate_colorformat(enum pipe_format format)
         case PIPE_FORMAT_B5G6R5_UNORM:
             return R300_COLOR_FORMAT_RGB565;
         case PIPE_FORMAT_B5G5R5A1_UNORM:
+        case PIPE_FORMAT_B5G5R5X1_UNORM:
             return R300_COLOR_FORMAT_ARGB1555;
         case PIPE_FORMAT_B4G4R4A4_UNORM:
             return R300_COLOR_FORMAT_ARGB4444;
 
         /* 32-bit buffers. */
         case PIPE_FORMAT_B8G8R8A8_UNORM:
-        case PIPE_FORMAT_B8G8R8A8_SRGB:
         case PIPE_FORMAT_B8G8R8X8_UNORM:
-        case PIPE_FORMAT_B8G8R8X8_SRGB:
         case PIPE_FORMAT_A8R8G8B8_UNORM:
-        case PIPE_FORMAT_A8R8G8B8_SRGB:
         case PIPE_FORMAT_X8R8G8B8_UNORM:
-        case PIPE_FORMAT_X8R8G8B8_SRGB:
         case PIPE_FORMAT_A8B8G8R8_UNORM:
         case PIPE_FORMAT_R8G8B8A8_SNORM:
-        case PIPE_FORMAT_A8B8G8R8_SRGB:
         case PIPE_FORMAT_X8B8G8R8_UNORM:
-        case PIPE_FORMAT_X8B8G8R8_SRGB:
         case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
             return R300_COLOR_FORMAT_ARGB8888;
         case PIPE_FORMAT_R10G10B10A2_UNORM:
@@ -393,12 +398,7 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format)
     desc = util_format_description(format);
 
     /* Specifies how the shader output is written to the fog unit. */
-    if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
-        /* The gamma correction causes precision loss so we need
-         * higher precision to maintain reasonable quality.
-         * It has nothing to do with the colorbuffer format. */
-        modifier |= R300_US_OUT_FMT_C4_10_GAMMA;
-    } else if (desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT) {
+    if (desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT) {
         if (desc->channel[0].size == 32) {
             modifier |= R300_US_OUT_FMT_C4_32_FP;
         } else {
@@ -428,46 +428,39 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format)
             return modifier | R300_C2_SEL_A;
         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 modifier | R300_C2_SEL_R;
 
-        /* ARGB 32-bit outputs. */
+        /* BGRA outputs. */
         case PIPE_FORMAT_B5G6R5_UNORM:
         case PIPE_FORMAT_B5G5R5A1_UNORM:
+        case PIPE_FORMAT_B5G5R5X1_UNORM:
         case PIPE_FORMAT_B4G4R4A4_UNORM:
         case PIPE_FORMAT_B8G8R8A8_UNORM:
-        case PIPE_FORMAT_B8G8R8A8_SRGB:
         case PIPE_FORMAT_B8G8R8X8_UNORM:
-        case PIPE_FORMAT_B8G8R8X8_SRGB:
             return modifier |
                 R300_C0_SEL_B | R300_C1_SEL_G |
                 R300_C2_SEL_R | R300_C3_SEL_A;
 
-        /* BGRA 32-bit outputs. */
+        /* ARGB outputs. */
         case PIPE_FORMAT_A8R8G8B8_UNORM:
-        case PIPE_FORMAT_A8R8G8B8_SRGB:
         case PIPE_FORMAT_X8R8G8B8_UNORM:
-        case PIPE_FORMAT_X8R8G8B8_SRGB:
             return modifier |
                 R300_C0_SEL_A | R300_C1_SEL_R |
                 R300_C2_SEL_G | R300_C3_SEL_B;
 
-        /* RGBA 32-bit outputs. */
+        /* ABGR outputs. */
         case PIPE_FORMAT_A8B8G8R8_UNORM:
-        case PIPE_FORMAT_R8G8B8A8_SNORM:
-        case PIPE_FORMAT_A8B8G8R8_SRGB:
         case PIPE_FORMAT_X8B8G8R8_UNORM:
-        case PIPE_FORMAT_X8B8G8R8_SRGB:
             return modifier |
                 R300_C0_SEL_A | R300_C1_SEL_B |
                 R300_C2_SEL_G | R300_C3_SEL_R;
 
-        /* ABGR 32-bit outputs. */
+        /* RGBA outputs. */
+        case PIPE_FORMAT_R8G8B8A8_SNORM:
         case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
         case PIPE_FORMAT_R10G10B10A2_UNORM:
-        /* RGBA high precision outputs (same swizzles as ABGR low precision) */
         case PIPE_FORMAT_R16G16B16A16_UNORM:
         case PIPE_FORMAT_R16G16B16A16_SNORM:
         //case PIPE_FORMAT_R16G16B16A16_FLOAT: /* not in pipe_format */
@@ -658,7 +651,7 @@ unsigned r300_texture_get_stride(struct r300_screen* screen,
 
     width = u_minify(tex->tex.width0, level);
 
-    if (!util_format_is_compressed(tex->tex.format)) {
+    if (r300_format_is_plain(tex->tex.format)) {
         tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH,
                                                 tex->mip_macrotile[level]);
         width = align(width, tile_width);
@@ -676,7 +669,7 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex,
 
     height = u_minify(tex->tex.height0, level);
 
-    if (!util_format_is_compressed(tex->tex.format)) {
+    if (r300_format_is_plain(tex->tex.format)) {
         tile_height = r300_texture_get_tile_size(tex, TILE_HEIGHT,
                                                  tex->mip_macrotile[level]);
         height = align(height, tile_height);
@@ -699,7 +692,8 @@ static void r300_setup_miptree(struct r300_screen* screen,
         /* Let's see if this miplevel can be macrotiled. */
         tex->mip_macrotile[i] =
             (tex->macrotile == R300_BUFFER_TILED &&
-             r300_texture_macro_switch(tex, i, rv350_mode, TILE_WIDTH)) ?
+             r300_texture_macro_switch(tex, i, rv350_mode, TILE_WIDTH) &&
+             r300_texture_macro_switch(tex, i, rv350_mode, TILE_HEIGHT)) ?
              R300_BUFFER_TILED : R300_BUFFER_LINEAR;
 
         stride = r300_texture_get_stride(screen, tex, i);
@@ -733,10 +727,11 @@ static void r300_setup_flags(struct r300_texture* tex)
 static void r300_setup_tiling(struct pipe_screen *screen,
                               struct r300_texture *tex)
 {
+    struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
     enum pipe_format format = tex->tex.format;
     boolean rv350_mode = r300_screen(screen)->caps->family >= CHIP_FAMILY_RV350;
 
-    if (util_format_is_compressed(format)) {
+    if (!r300_format_is_plain(format)) {
         return;
     }
 
@@ -752,12 +747,12 @@ static void r300_setup_tiling(struct pipe_screen *screen,
             tex->microtile = R300_BUFFER_TILED;
             break;
 
-        /* XXX Square-tiling doesn't work with kernel older than 2.6.34,
-         * XXX need to check the DRM version */
-        /*case 2:
+        case 2:
         case 8:
-            tex->microtile = R300_BUFFER_SQUARETILED;
-            break;*/
+            if (rws->get_value(rws, R300_VID_SQUARE_TILING_SUPPORT)) {
+                tex->microtile = R300_BUFFER_SQUARETILED;
+            }
+            break;
     }
 
     /* Set macrotiling. */
@@ -795,8 +790,8 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen,
                                     tex->size);
     rws->buffer_set_tiling(rws, tex->buffer,
                           tex->pitch[0],
-                          tex->microtile != R300_BUFFER_LINEAR,
-                          tex->macrotile != R300_BUFFER_LINEAR);
+                          tex->microtile,
+                          tex->macrotile);
 
     if (!tex->buffer) {
         FREE(tex);
index aff4ddd4e23f9a8bb4a2479aa3a81bfe2746ddfe..3b3802ee2b231bd28e188cf2f4f13756955b3e60 100644 (file)
 #include "radeon_compiler.h"
 #include "radeon_program.h"
 
+#include "tgsi/tgsi_info.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_scan.h"
 #include "tgsi/tgsi_util.h"
 
-#include "util/u_debug.h"
-
 static unsigned translate_opcode(unsigned opcode)
 {
     switch(opcode) {
@@ -145,7 +144,7 @@ static unsigned translate_opcode(unsigned opcode)
         case TGSI_OPCODE_KIL: return RC_OPCODE_KIL;
     }
 
-    debug_printf("r300: Unknown TGSI/RC opcode: %i\n", opcode);
+    fprintf(stderr, "r300: Unknown TGSI/RC opcode: %s\n", tgsi_get_opcode_name(opcode));
     return RC_OPCODE_ILLEGAL_OPCODE;
 }
 
@@ -272,9 +271,6 @@ static void transform_instruction(struct tgsi_to_rc * ttr, struct tgsi_full_inst
     struct rc_instruction * dst;
     int i;
 
-    if (src->Instruction.Opcode == TGSI_OPCODE_END)
-        return;
-
     dst = rc_insert_new_instruction(ttr->compiler, ttr->compiler->Program.Instructions.Prev);
     dst->U.I.Opcode = translate_opcode(src->Instruction.Opcode);
     dst->U.I.SaturateMode = translate_saturate(src->Instruction.Saturate);
@@ -333,6 +329,7 @@ static void handle_immediate(struct tgsi_to_rc * ttr,
 void r300_tgsi_to_rc(struct tgsi_to_rc * ttr,
                      const struct tgsi_token * tokens)
 {
+    struct tgsi_full_instruction *inst;
     struct tgsi_parse_context parser;
     unsigned imm_index = 0;
     int i;
@@ -367,7 +364,15 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr,
                 imm_index++;
                 break;
             case TGSI_TOKEN_TYPE_INSTRUCTION:
-                transform_instruction(ttr, &parser.FullToken.FullInstruction);
+                inst = &parser.FullToken.FullInstruction;
+                /* This hack with the RET opcode woudn't work with
+                 * conditionals. */
+                if (inst->Instruction.Opcode == TGSI_OPCODE_END ||
+                    inst->Instruction.Opcode == TGSI_OPCODE_RET) {
+                    break;
+                }
+
+                transform_instruction(ttr, inst);
                 break;
         }
     }
index bd6b95dccbae0acdeccad5823edc140587801b4b..d5690caa68e32ab5a02467fbbec306d4b9f490e9 100644 (file)
@@ -299,7 +299,7 @@ void r300_translate_vertex_shader(struct r300_context* r300,
     r3xx_compile_vertex_program(&compiler);
     if (compiler.Base.Error) {
         /* XXX We should fallback using Draw. */
-        fprintf(stderr, "r300 VP: Compiler error\n");
+        fprintf(stderr, "r300 VP: Compiler error:\n%s", compiler.Base.ErrorMsg);
         abort();
     }
 
index e5183a8239c9d74d9d585177abe74df344845645..acfa5dbeb9c020214a0fc1cc0f68a8549b748832 100644 (file)
@@ -30,6 +30,8 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
 
+#include "r300_defines.h"
+
 struct r300_winsys_screen;
 
 /* Creates a new r300 screen. */
@@ -47,10 +49,9 @@ enum r300_value_id {
     R300_VID_PCI_ID,
     R300_VID_GB_PIPES,
     R300_VID_Z_PIPES,
+    R300_VID_SQUARE_TILING_SUPPORT
 };
 
-#define R300_USAGE_FLAG_DONT_SYNC (1 << 17)
-
 struct r300_winsys_screen {
     void (*destroy)(struct r300_winsys_screen *ws);
     
@@ -148,8 +149,8 @@ struct r300_winsys_screen {
     void (*buffer_set_tiling)(struct r300_winsys_screen *winsys,
                               struct r300_winsys_buffer *buffer,
                               uint32_t pitch,
-                              boolean microtiled,
-                              boolean macrotiled);
+                              enum r300_buffer_tiling microtiled,
+                              enum r300_buffer_tiling macrotiled);
 
     uint32_t (*get_value)(struct r300_winsys_screen *winsys,
                          enum r300_value_id vid);
index de92a0cd2c73ce3635000756905f01408caaa05f..937a573092f376a93001e63d9a3eda146c97e985 100644 (file)
@@ -104,12 +104,12 @@ softpipe_destroy( struct pipe_context *pipe )
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
       sp_destroy_tex_tile_cache(softpipe->tex_cache[i]);
-      pipe_texture_reference(&softpipe->texture[i], NULL);
+      pipe_sampler_view_reference(&softpipe->sampler_views[i], NULL);
    }
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
       sp_destroy_tex_tile_cache(softpipe->vertex_tex_cache[i]);
-      pipe_texture_reference(&softpipe->vertex_textures[i], NULL);
+      pipe_sampler_view_reference(&softpipe->vertex_sampler_views[i], NULL);
    }
 
    for (i = 0; i < PIPE_SHADER_TYPES; i++) {
@@ -257,8 +257,10 @@ softpipe_create_context( struct pipe_screen *screen,
    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
    softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
    softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
-   softpipe->pipe.set_fragment_sampler_textures = softpipe_set_sampler_textures;
-   softpipe->pipe.set_vertex_sampler_textures = softpipe_set_vertex_sampler_textures;
+   softpipe->pipe.set_fragment_sampler_views = softpipe_set_sampler_views;
+   softpipe->pipe.set_vertex_sampler_views = softpipe_set_vertex_sampler_views;
+   softpipe->pipe.create_sampler_view = softpipe_create_sampler_view;
+   softpipe->pipe.sampler_view_destroy = softpipe_sampler_view_destroy;
    softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
 
    softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers;
index 9a8158e6a22978f47bdcbe213cbc8ee25f7efd4c..75e03c8ae6b179b9587a9e14a3ab53f45de93b8d 100644 (file)
@@ -70,15 +70,15 @@ struct softpipe_context {
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
 
    unsigned num_samplers;
-   unsigned num_textures;
+   unsigned num_sampler_views;
    unsigned num_vertex_samplers;
-   unsigned num_vertex_textures;
+   unsigned num_vertex_sampler_views;
    unsigned num_vertex_buffers;
 
    unsigned dirty; /**< Mask of SP_NEW_x flags */
index 3d76af4d8cb8993e072bb703cb129f318db289c7..508fe8f764d06aabb1b4e8102a3128041d85a4f6 100644 (file)
@@ -50,10 +50,10 @@ softpipe_flush( struct pipe_context *pipe,
    draw_flush(softpipe->draw);
 
    if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
-      for (i = 0; i < softpipe->num_textures; i++) {
+      for (i = 0; i < softpipe->num_sampler_views; i++) {
          sp_flush_tex_tile_cache(softpipe->tex_cache[i]);
       }
-      for (i = 0; i < softpipe->num_vertex_textures; i++) {
+      for (i = 0; i < softpipe->num_vertex_sampler_views; i++) {
          sp_flush_tex_tile_cache(softpipe->vertex_tex_cache[i]);
       }
    }
index 4815a0d49f1d202e176ae1055b1066aa757217f6..17cd5b82072e698c091317095ae1bf170d78a4bc 100644 (file)
@@ -1,6 +1,7 @@
 /**************************************************************************
  * 
  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2010 VMware, Inc.
  * All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +19,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -26,7 +27,7 @@
  **************************************************************************/
 
 /**
- * \brief  Quad depth testing
+ * \brief  Quad depth / stencil testing
  */
 
 #include "pipe/p_defines.h"
@@ -96,7 +97,9 @@ get_depth_stencil_values( struct depth_data *data,
    }
 }
 
-/* If the shader has not been run, interpolate the depth values
+
+/**
+ * If the shader has not been run, interpolate the depth values
  * ourselves.
  */
 static void
@@ -115,6 +118,9 @@ interpolate_quad_depth( struct quad_header *quad )
 }
 
 
+/**
+ * Compute the depth_data::qzzzz[] values from the float fragment Z values.
+ */
 static void
 convert_quad_depth( struct depth_data *data, 
                     const struct quad_header *quad )
@@ -173,6 +179,9 @@ convert_quad_depth( struct depth_data *data,
 
 
 
+/**
+ * Write data->bzzzz[] values and data->stencilVals into the Z/stencil buffer.
+ */
 static void
 write_depth_stencil_values( struct depth_data *data,
                             struct quad_header *quad )
@@ -225,7 +234,6 @@ write_depth_stencil_values( struct depth_data *data,
 
 
 
-
 /** Only 8-bit stencil supported */
 #define STENCIL_MAX 0xff
 
@@ -408,12 +416,11 @@ apply_stencil_op(struct depth_data *data,
 
    
 
-/*
+/**
  * To increase efficiency, we should probably have multiple versions
  * of this function that are specifically for Z16, Z32 and FP Z buffers.
  * Try to effectively do that with codegen...
  */
-
 static boolean
 depth_test_quad(struct quad_stage *qs, 
                 struct depth_data *data,
@@ -523,7 +530,6 @@ depth_stencil_test_quad(struct quad_stage *qs,
    wrtMask = softpipe->depth_stencil->stencil[face].writemask;
    valMask = softpipe->depth_stencil->stencil[face].valuemask;
 
-
    /* do the stencil test first */
    {
       unsigned passMask, failMask;
@@ -563,7 +569,7 @@ depth_stencil_test_quad(struct quad_stage *qs,
 
 
 #define ALPHATEST( FUNC, COMP )                                         \
-   static int                                                          \
+   static int                                                           \
    alpha_test_quads_##FUNC( struct quad_stage *qs,                      \
                            struct quad_header *quads[],                 \
                            unsigned nr )                                \
@@ -629,6 +635,7 @@ alpha_test_quads(struct quad_stage *qs,
    }
 }
 
+
 static unsigned mask_count[16] = 
 {
    0,                           /* 0x0 */
@@ -665,6 +672,9 @@ get_depth_bits(struct quad_stage *qs)
 
 
 
+/**
+ * General depth/stencil test function.  Used when there's no fast-path.
+ */
 static void
 depth_test_quads_fallback(struct quad_stage *qs, 
                           struct quad_header *quads[],
@@ -712,7 +722,6 @@ depth_test_quads_fallback(struct quad_stage *qs,
                write_depth_stencil_values(&data, quads[i]);
          }
 
-
          quads[pass++] = quads[i];
       }
 
@@ -730,169 +739,36 @@ depth_test_quads_fallback(struct quad_stage *qs,
 
 
 /**
- * Special-case Z testing for 16-bit Zbuffer, PIPE_FUNC_LESS and
- * Z buffer writes enabled.
- *
- * NOTE: there's no guarantee that the quads are sequentially side by
- * side.  The fragment shader may have culled some quads, etc.  Sliver
- * triangles may generate non-sequential quads.
- */
-static void
-depth_interp_z16_less_write(struct quad_stage *qs, 
-                            struct quad_header *quads[],
-                            unsigned nr)
-{
-   unsigned i, pass = 0;
-   const unsigned ix = quads[0]->input.x0;
-   const unsigned iy = quads[0]->input.y0;
-   const float fx = (float) ix;
-   const float fy = (float) iy;
-   const float dzdx = quads[0]->posCoef->dadx[2];
-   const float dzdy = quads[0]->posCoef->dady[2];
-   const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy;
-   struct softpipe_cached_tile *tile;
-   ushort (*depth16)[TILE_SIZE];
-   ushort init_idepth[4], idepth[4], depth_step;
-   const float scale = 65535.0;
-
-   /* compute scaled depth of the four pixels in first quad */
-   init_idepth[0] = (ushort)((z0) * scale);
-   init_idepth[1] = (ushort)((z0 + dzdx) * scale);
-   init_idepth[2] = (ushort)((z0 + dzdy) * scale);
-   init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale);
-
-   depth_step = (ushort)(dzdx * scale);
-
-   tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy);
-
-   for (i = 0; i < nr; i++) {
-      const unsigned outmask = quads[i]->inout.mask;
-      const int dx = quads[i]->input.x0 - ix;
-      unsigned mask = 0;
-
-      /* compute depth for this quad */
-      idepth[0] = init_idepth[0] + dx * depth_step;
-      idepth[1] = init_idepth[1] + dx * depth_step;
-      idepth[2] = init_idepth[2] + dx * depth_step;
-      idepth[3] = init_idepth[3] + dx * depth_step;
-
-      depth16 = (ushort (*)[TILE_SIZE])
-         &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE];
-
-      if ((outmask & 1) && idepth[0] < depth16[0][0]) {
-         depth16[0][0] = idepth[0];
-         mask |= (1 << 0);
-      }
-
-      if ((outmask & 2) && idepth[1] < depth16[0][1]) {
-         depth16[0][1] = idepth[1];
-         mask |= (1 << 1);
-      }
-
-      if ((outmask & 4) && idepth[2] < depth16[1][0]) {
-         depth16[1][0] = idepth[2];
-         mask |= (1 << 2);
-      }
-
-      if ((outmask & 8) && idepth[3] < depth16[1][1]) {
-         depth16[1][1] = idepth[3];
-         mask |= (1 << 3);
-      }
-
-      quads[i]->inout.mask = mask;
-      if (quads[i]->inout.mask)
-         quads[pass++] = quads[i];
-   }
-
-   if (pass)
-      qs->next->run(qs->next, quads, pass);
-
-}
-
-
-/**
- * Special-case Z testing for 16-bit Zbuffer, PIPE_FUNC_LEQUAL and
- * Z buffer writes enabled.
- *
- * NOTE: there's no guarantee that the quads are sequentially side by
- * side.  The fragment shader may have culled some quads, etc.  Sliver
- * triangles may generate non-sequential quads.
+ * Special-case Z testing for 16-bit Zbuffer and Z buffer writes enabled.
  */
-static void
-depth_interp_z16_lequal_write(struct quad_stage *qs, 
-                            struct quad_header *quads[],
-                            unsigned nr)
-{
-   unsigned i, pass = 0;
-   const unsigned ix = quads[0]->input.x0;
-   const unsigned iy = quads[0]->input.y0;
-   const float fx = (float) ix;
-   const float fy = (float) iy;
-   const float dzdx = quads[0]->posCoef->dadx[2];
-   const float dzdy = quads[0]->posCoef->dady[2];
-   const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy;
-   struct softpipe_cached_tile *tile;
-   ushort (*depth16)[TILE_SIZE];
-   ushort init_idepth[4], idepth[4], depth_step;
-   const float scale = 65535.0;
-
-   /* compute scaled depth of the four pixels in first quad */
-   init_idepth[0] = (ushort)((z0) * scale);
-   init_idepth[1] = (ushort)((z0 + dzdx) * scale);
-   init_idepth[2] = (ushort)((z0 + dzdy) * scale);
-   init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale);
-
-   depth_step = (ushort)(dzdx * scale);
 
-   tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy);
-
-   for (i = 0; i < nr; i++) {
-      const unsigned outmask = quads[i]->inout.mask;
-      const int dx = quads[i]->input.x0 - ix;
-      unsigned mask = 0;
-      
-      /* compute depth for this quad */
-      idepth[0] = init_idepth[0] + dx * depth_step;
-      idepth[1] = init_idepth[1] + dx * depth_step;
-      idepth[2] = init_idepth[2] + dx * depth_step;
-      idepth[3] = init_idepth[3] + dx * depth_step;
-
-      depth16 = (ushort (*)[TILE_SIZE])
-         &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE];
-
-      if ((outmask & 1) && idepth[0] <= depth16[0][0]) {
-         depth16[0][0] = idepth[0];
-         mask |= (1 << 0);
-      }
-
-      if ((outmask & 2) && idepth[1] <= depth16[0][1]) {
-         depth16[0][1] = idepth[1];
-         mask |= (1 << 1);
-      }
-
-      if ((outmask & 4) && idepth[2] <= depth16[1][0]) {
-         depth16[1][0] = idepth[2];
-         mask |= (1 << 2);
-      }
-
-      if ((outmask & 8) && idepth[3] <= depth16[1][1]) {
-         depth16[1][1] = idepth[3];
-         mask |= (1 << 3);
-      }
+#define NAME depth_interp_z16_less_write
+#define OPERATOR <
+#include "sp_quad_depth_test_tmp.h"
 
-      depth16 = (ushort (*)[TILE_SIZE]) &depth16[0][2];
+#define NAME depth_interp_z16_equal_write
+#define OPERATOR ==
+#include "sp_quad_depth_test_tmp.h"
 
-      quads[i]->inout.mask = mask;
-      if (quads[i]->inout.mask)
-         quads[pass++] = quads[i];
-   }
+#define NAME depth_interp_z16_lequal_write
+#define OPERATOR <=
+#include "sp_quad_depth_test_tmp.h"
 
-   if (pass)
-      qs->next->run(qs->next, quads, pass);
+#define NAME depth_interp_z16_greater_write
+#define OPERATOR >
+#include "sp_quad_depth_test_tmp.h"
 
-}
+#define NAME depth_interp_z16_notequal_write
+#define OPERATOR !=
+#include "sp_quad_depth_test_tmp.h"
 
+#define NAME depth_interp_z16_gequal_write
+#define OPERATOR >=
+#include "sp_quad_depth_test_tmp.h"
 
+#define NAME depth_interp_z16_always_write
+#define ALWAYS 1
+#include "sp_quad_depth_test_tmp.h"
 
 
 
@@ -926,6 +802,10 @@ choose_depth_test(struct quad_stage *qs,
 
    boolean occlusion = qs->softpipe->active_query_count;
 
+   /* default */
+   qs->run = depth_test_quads_fallback;
+
+   /* look for special cases */
    if (!alpha &&
        !depth &&
        !stencil) {
@@ -938,57 +818,62 @@ choose_depth_test(struct quad_stage *qs,
             !occlusion &&
             !stencil) 
    {
-      switch (depthfunc) {
-      case PIPE_FUNC_LESS:
-         switch (qs->softpipe->framebuffer.zsbuf->format) {
-         case PIPE_FORMAT_Z16_UNORM:
+      if (qs->softpipe->framebuffer.zsbuf->format == PIPE_FORMAT_Z16_UNORM) {
+         switch (depthfunc) {
+         case PIPE_FUNC_NEVER:
+            qs->run = depth_test_quads_fallback;
+            break;
+         case PIPE_FUNC_LESS:
             qs->run = depth_interp_z16_less_write;
             break;
-         default:
-            qs->run = depth_test_quads_fallback;
+         case PIPE_FUNC_EQUAL:
+            qs->run = depth_interp_z16_equal_write;
             break;
-         }
-         break;
-      case PIPE_FUNC_LEQUAL:
-         switch (qs->softpipe->framebuffer.zsbuf->format) {
-         case PIPE_FORMAT_Z16_UNORM:
+         case PIPE_FUNC_LEQUAL:
             qs->run = depth_interp_z16_lequal_write;
             break;
+         case PIPE_FUNC_GREATER:
+            qs->run = depth_interp_z16_greater_write;
+            break;
+         case PIPE_FUNC_NOTEQUAL:
+            qs->run = depth_interp_z16_notequal_write;
+            break;
+         case PIPE_FUNC_GEQUAL:
+            qs->run = depth_interp_z16_gequal_write;
+            break;
+         case PIPE_FUNC_ALWAYS:
+            qs->run = depth_interp_z16_always_write;
+            break;
          default:
             qs->run = depth_test_quads_fallback;
             break;
          }
-         break;
-      default:
-         qs->run = depth_test_quads_fallback;
       }
    }
-   else {
-      qs->run = depth_test_quads_fallback;
-   }
-
 
+   /* next quad/fragment stage */
    qs->run( qs, quads, nr );
 }
 
 
 
-
-
-static void depth_test_begin(struct quad_stage *qs)
+static void
+depth_test_begin(struct quad_stage *qs)
 {
    qs->run = choose_depth_test;
    qs->next->begin(qs->next);
 }
 
 
-static void depth_test_destroy(struct quad_stage *qs)
+static void
+depth_test_destroy(struct quad_stage *qs)
 {
    FREE( qs );
 }
 
 
-struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe )
+struct quad_stage *
+sp_quad_depth_test_stage(struct softpipe_context *softpipe)
 {
    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
 
diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h b/src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h
new file mode 100644 (file)
index 0000000..25af415
--- /dev/null
@@ -0,0 +1,147 @@
+/**************************************************************************
+ * 
+ * Copyright 2010 VMware, Inc.  All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+
+/*
+ * Template for generating Z test functions
+ * Only PIPE_FORMAT_Z16_UNORM supported at this time.
+ */
+
+
+#ifndef NAME
+#error "NAME is not defined!"
+#endif
+
+#if !defined(OPERATOR) && !defined(ALWAYS)
+#error "neither OPERATOR nor ALWAYS is defined!"
+#endif
+
+
+/*
+ * NOTE: there's no guarantee that the quads are sequentially side by
+ * side.  The fragment shader may have culled some quads, etc.  Sliver
+ * triangles may generate non-sequential quads.
+ */
+static void
+NAME(struct quad_stage *qs, 
+     struct quad_header *quads[],
+     unsigned nr)
+{
+   unsigned i, pass = 0;
+   const unsigned ix = quads[0]->input.x0;
+   const unsigned iy = quads[0]->input.y0;
+   const float fx = (float) ix;
+   const float fy = (float) iy;
+   const float dzdx = quads[0]->posCoef->dadx[2];
+   const float dzdy = quads[0]->posCoef->dady[2];
+   const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy;
+   struct softpipe_cached_tile *tile;
+   ushort (*depth16)[TILE_SIZE];
+   ushort init_idepth[4], idepth[4], depth_step;
+   const float scale = 65535.0;
+
+   /* compute scaled depth of the four pixels in first quad */
+   init_idepth[0] = (ushort)((z0) * scale);
+   init_idepth[1] = (ushort)((z0 + dzdx) * scale);
+   init_idepth[2] = (ushort)((z0 + dzdy) * scale);
+   init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale);
+
+   depth_step = (ushort)(dzdx * scale);
+
+   tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy);
+
+   for (i = 0; i < nr; i++) {
+      const unsigned outmask = quads[i]->inout.mask;
+      const int dx = quads[i]->input.x0 - ix;
+      unsigned mask = 0;
+      
+      /* compute depth for this quad */
+      idepth[0] = init_idepth[0] + dx * depth_step;
+      idepth[1] = init_idepth[1] + dx * depth_step;
+      idepth[2] = init_idepth[2] + dx * depth_step;
+      idepth[3] = init_idepth[3] + dx * depth_step;
+
+      depth16 = (ushort (*)[TILE_SIZE])
+         &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE];
+
+#ifdef ALWAYS
+      if (outmask & 1) {
+         depth16[0][0] = idepth[0];
+         mask |= (1 << 0);
+      }
+
+      if (outmask & 2) {
+         depth16[0][1] = idepth[1];
+         mask |= (1 << 1);
+      }
+
+      if (outmask & 4) {
+         depth16[1][0] = idepth[2];
+         mask |= (1 << 2);
+      }
+
+      if (outmask & 8) {
+         depth16[1][1] = idepth[3];
+         mask |= (1 << 3);
+      }
+#else
+      /* Note: OPERATOR appears here: */
+      if ((outmask & 1) && (idepth[0] OPERATOR depth16[0][0])) {
+         depth16[0][0] = idepth[0];
+         mask |= (1 << 0);
+      }
+
+      if ((outmask & 2) && (idepth[1] OPERATOR depth16[0][1])) {
+         depth16[0][1] = idepth[1];
+         mask |= (1 << 1);
+      }
+
+      if ((outmask & 4) && (idepth[2] OPERATOR depth16[1][0])) {
+         depth16[1][0] = idepth[2];
+         mask |= (1 << 2);
+      }
+
+      if ((outmask & 8) && (idepth[3] OPERATOR depth16[1][1])) {
+         depth16[1][1] = idepth[3];
+         mask |= (1 << 3);
+      }
+#endif
+
+      depth16 = (ushort (*)[TILE_SIZE]) &depth16[0][2];
+
+      quads[i]->inout.mask = mask;
+      if (quads[i]->inout.mask)
+         quads[pass++] = quads[i];
+   }
+
+   if (pass)
+      qs->next->run(qs->next, quads, pass);
+}
+
+
+#undef NAME
+#undef OPERATOR
+#undef ALWAYS
index d62bfa3d633fde5acf99c4c0847dddb191a5028c..757dc86128417480f8e6f6fbb63e41efb7f49af4 100644 (file)
@@ -173,8 +173,10 @@ softpipe_is_format_supported( struct pipe_screen *screen,
       break;
    }
 
-   if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
-      if(!winsys->is_displaytarget_format_supported(winsys, format))
+   if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                   PIPE_TEXTURE_USAGE_SCANOUT |
+                   PIPE_TEXTURE_USAGE_SHARED)) {
+      if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
          return FALSE;
    }
 
index 6b01c0f4d722b13a80b724d245a896850d8f175a..ade96b0fd4c7abbfab9ac036d82bc8396233509e 100644 (file)
@@ -177,14 +177,23 @@ void softpipe_set_polygon_stipple( struct pipe_context *,
 void softpipe_set_scissor_state( struct pipe_context *,
                                  const struct pipe_scissor_state * );
 
-void softpipe_set_sampler_textures( struct pipe_context *,
-                                    unsigned num,
-                                    struct pipe_texture ** );
+void softpipe_set_sampler_views( struct pipe_context *,
+                                 unsigned num,
+                                 struct pipe_sampler_view ** );
 
 void
-softpipe_set_vertex_sampler_textures(struct pipe_context *,
-                                     unsigned num_textures,
-                                     struct pipe_texture **);
+softpipe_set_vertex_sampler_views(struct pipe_context *,
+                                  unsigned num,
+                                  struct pipe_sampler_view **);
+
+struct pipe_sampler_view *
+softpipe_create_sampler_view(struct pipe_context *pipe,
+                             struct pipe_texture *texture,
+                             const struct pipe_sampler_view *templ);
+
+void
+softpipe_sampler_view_destroy(struct pipe_context *pipe,
+                              struct pipe_sampler_view *view);
 
 void softpipe_set_viewport_state( struct pipe_context *,
                                   const struct pipe_viewport_state * );
index 2b089c2831642108d13fd71528d4c5abaa12703b..d6f3229bed78b1c5d5f346e42a44b4c780238071 100644 (file)
@@ -181,9 +181,8 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
    /* note: reference counting */
    pipe_buffer_reference(&softpipe->constants[shader][index], constants);
 
-   if(shader == PIPE_SHADER_VERTEX) {
-      draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, index,
-                                      data, size);
+   if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) {
+      draw_set_mapped_constant_buffer(softpipe->draw, shader, index, data, size);
    }
 
    softpipe->mapped_constants[shader][index] = data;
index ceb4e338f1a5b4c893387975d5c8cf21ed14ecd0..d501952bba9e5846830cd723952ea82e74fd65c9 100644 (file)
@@ -121,9 +121,38 @@ softpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
 }
 
 
+struct pipe_sampler_view *
+softpipe_create_sampler_view(struct pipe_context *pipe,
+                             struct pipe_texture *texture,
+                             const struct pipe_sampler_view *templ)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
+
+   return view;
+}
+
+
 void
-softpipe_set_sampler_textures(struct pipe_context *pipe,
-                              unsigned num, struct pipe_texture **texture)
+softpipe_sampler_view_destroy(struct pipe_context *pipe,
+                              struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
+}
+
+
+void
+softpipe_set_sampler_views(struct pipe_context *pipe,
+                           unsigned num,
+                           struct pipe_sampler_view **views)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
    uint i;
@@ -131,51 +160,51 @@ softpipe_set_sampler_textures(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == softpipe->num_textures &&
-       !memcmp(softpipe->texture, texture, num * sizeof(struct pipe_texture *)))
+   if (num == softpipe->num_sampler_views &&
+       !memcmp(softpipe->sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
       return;
 
    draw_flush(softpipe->draw);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      struct pipe_texture *tex = i < num ? texture[i] : NULL;
+      struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      pipe_texture_reference(&softpipe->texture[i], tex);
-      sp_tex_tile_cache_set_texture(softpipe->tex_cache[i], tex);
+      pipe_sampler_view_reference(&softpipe->sampler_views[i], view);
+      sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[i], view);
    }
 
-   softpipe->num_textures = num;
+   softpipe->num_sampler_views = num;
 
    softpipe->dirty |= SP_NEW_TEXTURE;
 }
 
 
 void
-softpipe_set_vertex_sampler_textures(struct pipe_context *pipe,
-                                     unsigned num_textures,
-                                     struct pipe_texture **textures)
+softpipe_set_vertex_sampler_views(struct pipe_context *pipe,
+                                  unsigned num,
+                                  struct pipe_sampler_view **views)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
    uint i;
 
-   assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS);
+   assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
 
    /* Check for no-op */
-   if (num_textures == softpipe->num_vertex_textures &&
-       !memcmp(softpipe->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) {
+   if (num == softpipe->num_vertex_sampler_views &&
+       !memcmp(softpipe->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
       return;
    }
 
    draw_flush(softpipe->draw);
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      struct pipe_texture *tex = i < num_textures ? textures[i] : NULL;
+      struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      pipe_texture_reference(&softpipe->vertex_textures[i], tex);
-      sp_tex_tile_cache_set_texture(softpipe->vertex_tex_cache[i], tex);
+      pipe_sampler_view_reference(&softpipe->vertex_sampler_views[i], view);
+      sp_tex_tile_cache_set_sampler_view(softpipe->vertex_tex_cache[i], view);
    }
 
-   softpipe->num_vertex_textures = num_textures;
+   softpipe->num_vertex_sampler_views = num;
 
    softpipe->dirty |= SP_NEW_TEXTURE;
 }
@@ -245,29 +274,41 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe)
     */
    for (i = 0; i <= softpipe->vs->max_sampler; i++) {
       if (softpipe->vertex_samplers[i]) {
+         struct pipe_texture *texture = NULL;
+
+         if (softpipe->vertex_sampler_views[i]) {
+            texture = softpipe->vertex_sampler_views[i]->texture;
+         }
+
          softpipe->tgsi.vert_samplers_list[i] = 
             get_sampler_varient( i,
-                                sp_sampler(softpipe->vertex_samplers[i]),
-                                softpipe->vertex_textures[i],
+                                 sp_sampler(softpipe->vertex_samplers[i]),
+                                 texture,
                                  TGSI_PROCESSOR_VERTEX );
 
          sp_sampler_varient_bind_texture( softpipe->tgsi.vert_samplers_list[i], 
-                                         softpipe->vertex_tex_cache[i],
-                                         softpipe->vertex_textures[i] );
+                                          softpipe->vertex_tex_cache[i],
+                                          texture );
       }
    }
 
    for (i = 0; i <= softpipe->fs->info.file_max[TGSI_FILE_SAMPLER]; i++) {
       if (softpipe->sampler[i]) {
+         struct pipe_texture *texture = NULL;
+
+         if (softpipe->sampler_views[i]) {
+            texture = softpipe->sampler_views[i]->texture;
+         }
+
          softpipe->tgsi.frag_samplers_list[i] =
             get_sampler_varient( i,
                                  sp_sampler(softpipe->sampler[i]),
-                                 softpipe->texture[i],
+                                 texture,
                                  TGSI_PROCESSOR_FRAGMENT );
 
          sp_sampler_varient_bind_texture( softpipe->tgsi.frag_samplers_list[i], 
                                           softpipe->tex_cache[i],
-                                          softpipe->texture[i] );
+                                          texture );
       }
    }
 }
index e3a5e37ce442c3973c9d0cf78e49c1d7a6758f09..6594514c38f0ae0de1397e0c6dc5e413b2b1166b 100644 (file)
@@ -116,12 +116,13 @@ sp_tex_tile_cache_validate_texture(struct softpipe_tex_tile_cache *tc)
 }
 
 /**
- * Specify the texture to cache.
+ * Specify the sampler view to cache.
  */
 void
-sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc,
-                          struct pipe_texture *texture)
+sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
+                                   struct pipe_sampler_view *view)
 {
+   struct pipe_texture *texture = view ? view->texture : NULL;
    uint i;
 
    assert(!tc->transfer);
@@ -139,6 +140,14 @@ sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc,
          tc->tex_trans = NULL;
       }
 
+      if (view) {
+         tc->swizzle_r = view->swizzle_r;
+         tc->swizzle_g = view->swizzle_g;
+         tc->swizzle_b = view->swizzle_b;
+         tc->swizzle_a = view->swizzle_a;
+         tc->format = view->format;
+      }
+
       /* mark as entries as invalid/empty */
       /* XXX we should try to avoid this when the teximage hasn't changed */
       for (i = 0; i < NUM_ENTRIES; i++) {
@@ -251,12 +260,18 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
       }
 
       /* get tile from the transfer (view into texture) */
-      pipe_get_tile_rgba(tc->pipe,
-                         tc->tex_trans,
-                         addr.bits.x * TILE_SIZE, 
-                         addr.bits.y * TILE_SIZE,
-                         TILE_SIZE, TILE_SIZE,
-                         (float *) tile->data.color);
+      pipe_get_tile_swizzle(tc->pipe,
+                           tc->tex_trans,
+                            addr.bits.x * TILE_SIZE, 
+                            addr.bits.y * TILE_SIZE,
+                            TILE_SIZE,
+                            TILE_SIZE,
+                            tc->swizzle_r,
+                            tc->swizzle_g,
+                            tc->swizzle_b,
+                            tc->swizzle_a,
+                            tc->format,
+                            (float *) tile->data.color);
       tile->addr = addr;
    }
 
index b11639725875793d6867ee4d50acbbd29e64c244..12ae7ba12d62a91928266913ff6a94a14bc81214 100644 (file)
@@ -83,6 +83,12 @@ struct softpipe_tex_tile_cache
    void *tex_trans_map;
    int tex_face, tex_level, tex_z;
 
+   unsigned swizzle_r;
+   unsigned swizzle_g;
+   unsigned swizzle_b;
+   unsigned swizzle_a;
+   unsigned format;
+
    struct softpipe_tex_cached_tile *last_tile;  /**< most recently retrieved tile */
 };
 
@@ -101,8 +107,8 @@ extern void
 sp_tex_tile_cache_unmap_transfers(struct softpipe_tex_tile_cache *tc);
 
 extern void
-sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc,
-                          struct pipe_texture *texture);
+sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
+                                   struct pipe_sampler_view *view);
 
 void
 sp_tex_tile_cache_validate_texture(struct softpipe_tex_tile_cache *tc);
index 2aff6118f4187e9d19fff99f27cc1dc6d91b137e..f4983b7c8e8c508af8eaa999ca9e17095822e835 100644 (file)
@@ -91,6 +91,7 @@ softpipe_displaytarget_layout(struct pipe_screen *screen,
    /* Round up the surface size to a multiple of the tile size?
     */
    spt->dt = winsys->displaytarget_create(winsys,
+                                          spt->base.tex_usage,
                                           spt->base.format,
                                           spt->base.width0, 
                                           spt->base.height0,
@@ -139,8 +140,6 @@ softpipe_texture_create(struct pipe_screen *screen,
 }
 
 
-
-
 static void
 softpipe_texture_destroy(struct pipe_texture *pt)
 {
@@ -161,6 +160,55 @@ softpipe_texture_destroy(struct pipe_texture *pt)
 }
 
 
+static struct pipe_texture *
+softpipe_texture_from_handle(struct pipe_screen *screen,
+                             const struct pipe_texture *template,
+                             struct winsys_handle *whandle)
+{
+   struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
+   struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture);
+   if (!spt)
+      return NULL;
+
+   spt->base = *template;
+   pipe_reference_init(&spt->base.reference, 1);
+   spt->base.screen = screen;
+
+   spt->pot = (util_is_power_of_two(template->width0) &&
+               util_is_power_of_two(template->height0) &&
+               util_is_power_of_two(template->depth0));
+
+   spt->dt = winsys->displaytarget_from_handle(winsys,
+                                               template,
+                                               whandle,
+                                               &spt->stride[0]);
+   if (!spt->dt)
+      goto fail;
+
+   return &spt->base;
+
+ fail:
+   FREE(spt);
+   return NULL;
+}
+
+
+static boolean
+softpipe_texture_get_handle(struct pipe_screen *screen,
+                            struct pipe_texture *pt,
+                            struct winsys_handle *whandle)
+{
+   struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
+   struct softpipe_texture *spt = softpipe_texture(pt);
+
+   assert(spt->dt);
+   if (!spt->dt)
+      return FALSE;
+
+   return winsys->displaytarget_get_handle(winsys, spt->dt, whandle);
+}
+
+
 /**
  * Get a pipe_surface "view" into a texture.
  */
@@ -461,6 +509,8 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
 {
    screen->texture_create = softpipe_texture_create;
    screen->texture_destroy = softpipe_texture_destroy;
+   screen->texture_from_handle = softpipe_texture_from_handle;
+   screen->texture_get_handle = softpipe_texture_get_handle;
 
    screen->get_tex_surface = softpipe_get_tex_surface;
    screen->tex_surface_destroy = softpipe_tex_surface_destroy;
index 791d30edc0ec85b30c84e52f9c51655f17e1a454..1f66437dfe1aa033cccddfa6c333886bd6a9cb06 100644 (file)
@@ -185,7 +185,7 @@ struct svga_state
    const struct svga_sampler_state *sampler[PIPE_MAX_SAMPLERS];
    const struct svga_velems_state *velems;
 
-   struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; /* or texture ID's? */
+   struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; /* or texture ID's? */
    struct svga_fragment_shader *fs;
    struct svga_vertex_shader *vs;
 
@@ -208,7 +208,7 @@ struct svga_state
    struct pipe_viewport_state viewport;
 
    unsigned num_samplers;
-   unsigned num_textures;
+   unsigned num_sampler_views;
    unsigned num_vertex_buffers;
    unsigned reduced_prim;
 
index 1a8ef296cac09eb4064c994f184e26fdcd76d620..82d525ca33f90fe93492f4b5ed6a7ad730c756c9 100644 (file)
@@ -176,9 +176,36 @@ static void svga_delete_sampler_state(struct pipe_context *pipe,
 }
 
 
-static void svga_set_sampler_textures(struct pipe_context *pipe,
-                                      unsigned num,
-                                      struct pipe_texture **texture)
+static struct pipe_sampler_view *
+svga_create_sampler_view(struct pipe_context *pipe,
+                         struct pipe_texture *texture,
+                         const struct pipe_sampler_view *templ)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
+
+   return view;
+}
+
+
+static void
+svga_sampler_view_destroy(struct pipe_context *pipe,
+                          struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
+}
+
+static void svga_set_sampler_views(struct pipe_context *pipe,
+                                   unsigned num,
+                                   struct pipe_sampler_view **views)
 {
    struct svga_context *svga = svga_context(pipe);
    unsigned flag_1d = 0;
@@ -188,31 +215,31 @@ static void svga_set_sampler_textures(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == svga->curr.num_textures &&
-       !memcmp(svga->curr.texture, texture, num * sizeof(struct pipe_texture *))) {
+   if (num == svga->curr.num_sampler_views &&
+       !memcmp(svga->curr.sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
       if (0) debug_printf("texture noop\n");
       return;
    }
 
    for (i = 0; i < num; i++) {
-      pipe_texture_reference(&svga->curr.texture[i],
-                             texture[i]);
+      pipe_sampler_view_reference(&svga->curr.sampler_views[i],
+                                  views[i]);
 
-      if (!texture[i])
+      if (!views[i])
          continue;
 
-      if (texture[i]->format == PIPE_FORMAT_B8G8R8A8_SRGB)
+      if (views[i]->texture->format == PIPE_FORMAT_B8G8R8A8_SRGB)
          flag_srgb |= 1 << i;
 
-      if (texture[i]->target == PIPE_TEXTURE_1D)
+      if (views[i]->texture->target == PIPE_TEXTURE_1D)
          flag_1d |= 1 << i;
    }
 
-   for (i = num; i < svga->curr.num_textures; i++)
-      pipe_texture_reference(&svga->curr.texture[i],
-                             NULL);
+   for (i = num; i < svga->curr.num_sampler_views; i++)
+      pipe_sampler_view_reference(&svga->curr.sampler_views[i],
+                                  NULL);
 
-   svga->curr.num_textures = num;
+   svga->curr.num_sampler_views = num;
    svga->dirty |= SVGA_NEW_TEXTURE_BINDING;
 
    if (flag_srgb != svga->curr.tex_flags.flag_srgb ||
@@ -231,7 +258,9 @@ void svga_init_sampler_functions( struct svga_context *svga )
    svga->pipe.create_sampler_state = svga_create_sampler_state;
    svga->pipe.bind_fragment_sampler_states = svga_bind_sampler_states;
    svga->pipe.delete_sampler_state = svga_delete_sampler_state;
-   svga->pipe.set_fragment_sampler_textures = svga_set_sampler_textures;
+   svga->pipe.set_fragment_sampler_views = svga_set_sampler_views;
+   svga->pipe.create_sampler_view = svga_create_sampler_view;
+   svga->pipe.sampler_view_destroy = svga_sampler_view_destroy;
 }
 
 
index 4a058eda885a129c636f4198148cc108cc764aab..70d3a8a46ae67d45f7f5a540d6da2424cc51513c 100644 (file)
@@ -330,7 +330,7 @@ svga_texture_create(struct pipe_screen *screen,
     */
 #if 0
    if((templat->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) &&
-      !util_format_is_compressed(templat->format))
+      !util_format_is_s3tc(templat->format))
       tex->key.flags |= SVGA3D_SURFACE_HINT_RENDERTARGET;
 #endif
    
@@ -969,7 +969,7 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
       if (min_lod == 0 && max_lod >= pt->last_level)
          view = FALSE;
 
-      if (util_format_is_compressed(pt->format) && view) {
+      if (util_format_is_s3tc(pt->format) && view) {
          format = svga_translate_format_render(pt->format);
       }
 
index bb92f818eaee28c1fc84676376f0da1bd0f5e7a9..493f78a99089e1c87e0c30fa12edd3c115d4cced 100644 (file)
@@ -137,7 +137,7 @@ static int emit_fs_consts( struct svga_context *svga,
 
       for (i = 0; i < key->num_textures; i++) {
          if (key->tex[i].unnormalized) {
-            struct pipe_texture *tex = svga->curr.texture[i];
+            struct pipe_texture *tex = svga->curr.sampler_views[i]->texture;
             float data[4];
 
             data[0] = 1.0 / (float)tex->width0;
index 2973444d0ab084e8b89cd86a477a573599f9daa3..1310fd9825fa8a71d7f686cf0107fce422b331c7 100644 (file)
@@ -158,10 +158,11 @@ static int make_fs_key( const struct svga_context *svga,
     *
     * SVGA_NEW_TEXTURE_BINDING | SVGA_NEW_SAMPLER
     */
-   for (i = 0; i < svga->curr.num_textures; i++) {
-      if (svga->curr.texture[i]) {
+   for (i = 0; i < svga->curr.num_sampler_views; i++) {
+      if (svga->curr.sampler_views[i]) {
          assert(svga->curr.sampler[i]);
-         key->tex[i].texture_target = svga->curr.texture[i]->target;
+         assert(svga->curr.sampler_views[i]->texture);
+         key->tex[i].texture_target = svga->curr.sampler_views[i]->texture->target;
          if (!svga->curr.sampler[i]->normalized_coords) {
             key->tex[i].width_height_idx = idx++;
             key->tex[i].unnormalized = TRUE;
@@ -169,7 +170,7 @@ static int make_fs_key( const struct svga_context *svga,
          }
       }
    }
-   key->num_textures = svga->curr.num_textures;
+   key->num_textures = svga->curr.num_sampler_views;
 
    idx = 0;
    for (i = 0; i < svga->curr.num_samplers; ++i) {
index 17b47859781823a6204f41bf3b84e341c6abc64c..c08ec7c2e8cf92f52b8d64257da0ed8911c9bcc2 100644 (file)
 void svga_cleanup_tss_binding(struct svga_context *svga)
 {
    int i;
-   unsigned count = MAX2( svga->curr.num_textures,
+   unsigned count = MAX2( svga->curr.num_sampler_views,
                           svga->state.hw_draw.num_views );
 
    for (i = 0; i < count; i++) {
       struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
 
       svga_sampler_view_reference(&view->v, NULL);
-      pipe_texture_reference( &svga->curr.texture[i], NULL );
+      pipe_sampler_view_reference( &svga->curr.sampler_views[i], NULL );
       pipe_texture_reference( &view->texture, NULL );
 
       view->dirty = 1;
@@ -57,7 +57,7 @@ update_tss_binding(struct svga_context *svga,
                    unsigned dirty )
 {
    unsigned i;
-   unsigned count = MAX2( svga->curr.num_textures,
+   unsigned count = MAX2( svga->curr.num_sampler_views,
                           svga->state.hw_draw.num_views );
    unsigned min_lod;
    unsigned max_lod;
@@ -77,30 +77,32 @@ update_tss_binding(struct svga_context *svga,
    for (i = 0; i < count; i++) {
       const struct svga_sampler_state *s = svga->curr.sampler[i];
       struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
+      struct pipe_texture *texture = NULL;
 
       /* get min max lod */
-      if (svga->curr.texture[i]) {
+      if (svga->curr.sampler_views[i]) {
          min_lod = MAX2(s->view_min_lod, 0);
-         max_lod = MIN2(s->view_max_lod, svga->curr.texture[i]->last_level);
+         max_lod = MIN2(s->view_max_lod, svga->curr.sampler_views[i]->texture->last_level);
+         texture = svga->curr.sampler_views[i]->texture;
       } else {
          min_lod = 0;
          max_lod = 0;
       }
 
-      if (view->texture != svga->curr.texture[i] ||
+      if (view->texture != texture ||
           view->min_lod != min_lod ||
           view->max_lod != max_lod) {
 
          svga_sampler_view_reference(&view->v, NULL);
-         pipe_texture_reference( &view->texture, svga->curr.texture[i] );
+         pipe_texture_reference( &view->texture, texture );
 
          view->dirty = TRUE;
          view->min_lod = min_lod;
          view->max_lod = max_lod;
 
-         if (svga->curr.texture[i])
+         if (texture)
             view->v = svga_get_tex_sampler_view(&svga->pipe, 
-                                                svga->curr.texture[i]
+                                                texture
                                                 min_lod,
                                                 max_lod);
       }
@@ -115,7 +117,7 @@ update_tss_binding(struct svga_context *svga,
       }
    }
 
-   svga->state.hw_draw.num_views = svga->curr.num_textures;
+   svga->state.hw_draw.num_views = svga->curr.num_sampler_views;
 
    if (queue.bind_count) {
       SVGA3dTextureState *ts;
diff --git a/src/gallium/drivers/sw/Makefile b/src/gallium/drivers/sw/Makefile
new file mode 100644 (file)
index 0000000..2713a62
--- /dev/null
@@ -0,0 +1,10 @@
+# Meta-driver which combines whichever software rasterizers have been
+# built into a single convenience library.
+
+TOP = ../../../..
+include $(TOP)/configs/current
+
+C_SOURCES = \
+       sw.c
+
+include ../../Makefile.template
diff --git a/src/gallium/drivers/sw/SConscript b/src/gallium/drivers/sw/SConscript
new file mode 100644 (file)
index 0000000..6fbbdf3
--- /dev/null
@@ -0,0 +1,42 @@
+#######################################################################
+# SConscript for swrast convenience library
+#
+# This is a meta-driver which consists of any and all of the software
+# rasterizers into a single driver.  A software rasterizer is defined
+# as any driver which takes an sw_winsys pointer as the only argument
+# to create_screen.
+#
+# XXX: unfortunately users of this driver still need to link in any
+# extra libraries needed for the particular driver (eg llvm for
+# llvmpipe).  Not sure how to get around this.
+
+Import('*')
+
+if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']):
+    print 'warning: no supported pipe driver: skipping build of sw meta-driver'
+    Return()
+
+env = env.Clone()
+
+if 'softpipe' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
+    env.Prepend(LIBS = [softpipe])
+
+if 'llvmpipe' in env['drivers']:
+    env.Tool('llvm')
+    if 'LLVM_VERSION' in env:
+        env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+        env.Tool('udis86')
+        env.Prepend(LIBS = [llvmpipe])
+    
+if 'cell' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_CELL')
+    env.Prepend(LIBS = [cell])
+
+sw = env.ConvenienceLibrary(
+       target = 'sw',
+       source = [
+               'sw.c',
+               ]
+    )
+    Export('sw')
diff --git a/src/gallium/drivers/sw/sw.c b/src/gallium/drivers/sw/sw.c
new file mode 100644 (file)
index 0000000..9f156df
--- /dev/null
@@ -0,0 +1,59 @@
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+#include "target-helpers/wrap_screen.h"
+#include "sw_public.h"
+#include "state_tracker/sw_winsys.h"
+
+
+/* Helper function to choose and instantiate one of the software rasterizers:
+ * cell, llvmpipe, softpipe.
+ */
+
+#ifdef GALLIUM_SOFTPIPE
+#include "softpipe/sp_public.h"
+#endif
+
+#ifdef GALLIUM_LLVMPIPE
+#include "llvmpipe/lp_public.h"
+#endif
+
+#ifdef GALLIUM_CELL
+#include "cell/ppu/cell_public.h"
+#endif
+
+struct pipe_screen *
+swrast_create_screen(struct sw_winsys *winsys)
+{
+   const char *default_driver;
+   const char *driver;
+   struct pipe_screen *screen = NULL;
+
+#if defined(GALLIUM_CELL)
+   default_driver = "cell";
+#elif defined(GALLIUM_LLVMPIPE)
+   default_driver = "llvmpipe";
+#elif defined(GALLIUM_SOFTPIPE)
+   default_driver = "softpipe";
+#else
+   default_driver = "";
+#endif
+
+   driver = debug_get_option("GALLIUM_DRIVER", default_driver);
+
+#if defined(GALLIUM_CELL)
+   if (screen == NULL && strcmp(driver, "cell") == 0)
+      screen = cell_create_screen( winsys );
+#endif
+
+#if defined(GALLIUM_LLVMPIPE)
+   if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
+      screen = llvmpipe_create_screen( winsys );
+#endif
+
+#if defined(GALLIUM_SOFTPIPE)
+   if (screen == NULL)
+      screen = softpipe_create_screen( winsys );
+#endif
+
+   return screen;
+}
diff --git a/src/gallium/drivers/sw/sw_public.h b/src/gallium/drivers/sw/sw_public.h
new file mode 100644 (file)
index 0000000..7085c5c
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef SW_PUBLIC_H
+#define SW_PUBLIC_H
+
+/* A convenience library, primarily to isolate the logic required to
+ * figure out which if any software rasterizers have been built and
+ * select between them.
+ */
+struct sw_winsys;
+
+struct pipe_screen *
+swrast_create_screen(struct sw_winsys *winsys);
+
+#endif
index b7e6bbac68ec2411ad2c04f266ca0ec10c8dd11f..5c24bd1f7dfcc3316ecdbd61c49ef4b10d0cdb35 100644 (file)
@@ -25,6 +25,7 @@
  *
  **************************************************************************/
 
+#include "util/u_inlines.h"
 #include "util/u_memory.h"
 #include "util/u_simple_list.h"
 #include "util/u_format.h"
@@ -114,7 +115,7 @@ trace_context_draw_block(struct trace_context *tr_ctx, int flag)
                    (void *) tr_ctx->draw_rule.fs, (void *) tr_ctx->curr.fs,
                    (void *) tr_ctx->draw_rule.vs, (void *) tr_ctx->curr.vs,
                    (void *) tr_ctx->draw_rule.surf, 0,
-                   (void *) tr_ctx->draw_rule.tex, 0);
+                   (void *) tr_ctx->draw_rule.sampler_view, 0);
       if (tr_ctx->draw_rule.fs &&
           tr_ctx->draw_rule.fs == tr_ctx->curr.fs)
          block = TRUE;
@@ -128,12 +129,12 @@ trace_context_draw_block(struct trace_context *tr_ctx, int flag)
          for (k = 0; k < tr_ctx->curr.nr_cbufs; k++)
             if (tr_ctx->draw_rule.surf == tr_ctx->curr.cbufs[k])
                block = TRUE;
-      if (tr_ctx->draw_rule.tex) {
-         for (k = 0; k < tr_ctx->curr.num_texs; k++)
-            if (tr_ctx->draw_rule.tex == tr_ctx->curr.tex[k])
+      if (tr_ctx->draw_rule.sampler_view) {
+         for (k = 0; k < tr_ctx->curr.num_sampler_views; k++)
+            if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.sampler_views[k])
                block = TRUE;
-         for (k = 0; k < tr_ctx->curr.num_vert_texs; k++) {
-            if (tr_ctx->draw_rule.tex == tr_ctx->curr.vert_tex[k]) {
+         for (k = 0; k < tr_ctx->curr.num_vert_sampler_views; k++) {
+            if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.vert_sampler_views[k]) {
                block = TRUE;
             }
          }
@@ -1015,63 +1016,119 @@ trace_context_set_viewport_state(struct pipe_context *_pipe,
 }
 
 
+static struct pipe_sampler_view *
+trace_create_sampler_view(struct pipe_context *_pipe,
+                          struct pipe_texture *_texture,
+                          const struct pipe_sampler_view *templ)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct trace_texture *tr_tex = trace_texture(_texture);
+   struct pipe_context *pipe = tr_ctx->pipe;
+   struct pipe_texture *texture = tr_tex->texture;
+   struct trace_sampler_view *result = CALLOC_STRUCT(trace_sampler_view);
+
+   trace_dump_call_begin("pipe_context", "create_sampler_view");
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(ptr, texture);
+   trace_dump_arg(ptr, templ);
+
+   result->sampler_view = pipe->create_sampler_view(pipe, texture, templ);
+
+   result->base = *templ;
+   result->base.reference.count = 1;
+   result->base.texture = NULL;
+   pipe_texture_reference(&result->base.texture, _texture);
+   result->base.context = _pipe;
+
+   trace_dump_ret(ptr, result);
+
+   trace_dump_call_end();
+
+   return &result->base;
+}
+
+
+static void
+trace_sampler_view_destroy(struct pipe_context *_pipe,
+                           struct pipe_sampler_view *_view)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct trace_sampler_view *tr_view = trace_sampler_view(_view);
+   struct pipe_context *pipe = tr_ctx->pipe;
+   struct pipe_sampler_view *view = tr_view->sampler_view;
+
+   trace_dump_call_begin("pipe_context", "sampler_view_destroy");
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(ptr, view);
+
+   pipe->sampler_view_destroy(pipe, view);
+
+   trace_dump_call_end();
+
+   pipe_texture_reference(&_view->texture, NULL);
+   FREE(_view);
+}
+
+
 static INLINE void
-trace_context_set_fragment_sampler_textures(struct pipe_context *_pipe,
-                                            unsigned num_textures,
-                                            struct pipe_texture **textures)
+trace_context_set_fragment_sampler_views(struct pipe_context *_pipe,
+                                         unsigned num,
+                                         struct pipe_sampler_view **views)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
-   struct trace_texture *tr_tex;
+   struct trace_sampler_view *tr_view;
    struct pipe_context *pipe = tr_ctx->pipe;
-   struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
    unsigned i;
 
-   tr_ctx->curr.num_texs = num_textures;
-   for(i = 0; i < num_textures; ++i) {
-      tr_tex = trace_texture(textures[i]);
-      tr_ctx->curr.tex[i] = tr_tex;
-      unwrapped_textures[i] = tr_tex ? tr_tex->texture : NULL;
+   tr_ctx->curr.num_sampler_views = num;
+   for(i = 0; i < num; ++i) {
+      tr_view = trace_sampler_view(views[i]);
+      tr_ctx->curr.sampler_views[i] = tr_view;
+      unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
    }
-   textures = unwrapped_textures;
+   views = unwrapped_views;
 
-   trace_dump_call_begin("pipe_context", "set_fragment_sampler_textures");
+   trace_dump_call_begin("pipe_context", "set_fragment_sampler_views");
 
    trace_dump_arg(ptr, pipe);
-   trace_dump_arg(uint, num_textures);
-   trace_dump_arg_array(ptr, textures, num_textures);
+   trace_dump_arg(uint, num);
+   trace_dump_arg_array(ptr, views, num);
 
-   pipe->set_fragment_sampler_textures(pipe, num_textures, textures);
+   pipe->set_fragment_sampler_views(pipe, num, views);
 
    trace_dump_call_end();
 }
 
 
 static INLINE void
-trace_context_set_vertex_sampler_textures(struct pipe_context *_pipe,
-                                          unsigned num_textures,
-                                          struct pipe_texture **textures)
+trace_context_set_vertex_sampler_views(struct pipe_context *_pipe,
+                                       unsigned num,
+                                       struct pipe_sampler_view **views)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
-   struct trace_texture *tr_tex;
+   struct trace_sampler_view *tr_view;
    struct pipe_context *pipe = tr_ctx->pipe;
-   struct pipe_texture *unwrapped_textures[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
    unsigned i;
 
-   tr_ctx->curr.num_vert_texs = num_textures;
-   for(i = 0; i < num_textures; ++i) {
-      tr_tex = trace_texture(textures[i]);
-      tr_ctx->curr.vert_tex[i] = tr_tex;
-      unwrapped_textures[i] = tr_tex ? tr_tex->texture : NULL;
+   tr_ctx->curr.num_vert_sampler_views = num;
+   for(i = 0; i < num; ++i) {
+      tr_view = trace_sampler_view(views[i]);
+      tr_ctx->curr.vert_sampler_views[i] = tr_view;
+      unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
    }
-   textures = unwrapped_textures;
+   views = unwrapped_views;
 
-   trace_dump_call_begin("pipe_context", "set_vertex_sampler_textures");
+   trace_dump_call_begin("pipe_context", "set_vertex_sampler_views");
 
    trace_dump_arg(ptr, pipe);
-   trace_dump_arg(uint, num_textures);
-   trace_dump_arg_array(ptr, textures, num_textures);
+   trace_dump_arg(uint, num);
+   trace_dump_arg_array(ptr, views, num);
 
-   pipe->set_vertex_sampler_textures(pipe, num_textures, textures);
+   pipe->set_vertex_sampler_views(pipe, num, views);
 
    trace_dump_call_end();
 }
@@ -1487,8 +1544,10 @@ trace_context_create(struct trace_screen *tr_scr,
    tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple;
    tr_ctx->base.set_scissor_state = trace_context_set_scissor_state;
    tr_ctx->base.set_viewport_state = trace_context_set_viewport_state;
-   tr_ctx->base.set_fragment_sampler_textures = trace_context_set_fragment_sampler_textures;
-   tr_ctx->base.set_vertex_sampler_textures = trace_context_set_vertex_sampler_textures;
+   tr_ctx->base.set_fragment_sampler_views = trace_context_set_fragment_sampler_views;
+   tr_ctx->base.set_vertex_sampler_views = trace_context_set_vertex_sampler_views;
+   tr_ctx->base.create_sampler_view = trace_create_sampler_view;
+   tr_ctx->base.sampler_view_destroy = trace_sampler_view_destroy;
    tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers;
    if (pipe->surface_copy)
       tr_ctx->base.surface_copy = trace_context_surface_copy;
index 142842324857db3b6d1b174eed8085fbcc6445c1..feec9b6bbf32d605d9a032aa54ae6f75c9d0a33e 100644 (file)
@@ -53,11 +53,11 @@ struct trace_context
       struct trace_shader *fs;
       struct trace_shader *vs;
 
-      struct trace_texture *tex[PIPE_MAX_SAMPLERS];
-      unsigned num_texs;
+      struct trace_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
+      unsigned num_sampler_views;
 
-      struct trace_texture *vert_tex[PIPE_MAX_VERTEX_SAMPLERS];
-      unsigned num_vert_texs;
+      struct trace_sampler_view *vert_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
+      unsigned num_vert_sampler_views;
 
       unsigned nr_cbufs;
       struct trace_texture *cbufs[PIPE_MAX_COLOR_BUFS];
@@ -68,7 +68,7 @@ struct trace_context
       struct trace_shader *fs;
       struct trace_shader *vs;
 
-      struct trace_texture *tex;
+      struct trace_sampler_view *sampler_view;
       struct trace_texture *surf;
 
       int blocker;
index f4f17566fd34b6e5447fbc8463ec5f8509142830..53ab8c686d8ab416a325b4a8643f5479eb422429 100644 (file)
@@ -313,12 +313,12 @@ trace_rbug_context_info(struct trace_rbug *tr_rbug, struct rbug_header *header,
    for (i = 0; i < tr_ctx->curr.nr_cbufs; i++)
       cbufs[i] = VOID2U64(tr_ctx->curr.cbufs[i]);
 
-   for (i = 0; i < tr_ctx->curr.num_texs; i++)
-      texs[i] = VOID2U64(tr_ctx->curr.tex[i]);
+   for (i = 0; i < tr_ctx->curr.num_sampler_views; i++)
+      texs[i] = VOID2U64(tr_ctx->curr.sampler_views[i]);
 
    rbug_send_context_info_reply(tr_rbug->con, serial,
                                 VOID2U64(tr_ctx->curr.vs), VOID2U64(tr_ctx->curr.fs),
-                                texs, tr_ctx->curr.num_texs,
+                                texs, tr_ctx->curr.num_sampler_views,
                                 cbufs, tr_ctx->curr.nr_cbufs,
                                 VOID2U64(tr_ctx->curr.zsbuf),
                                 tr_ctx->draw_blocker, tr_ctx->draw_blocked, NULL);
@@ -444,7 +444,7 @@ trace_rbug_context_draw_rule(struct trace_rbug *tr_rbug, struct rbug_header *hea
    pipe_mutex_lock(tr_ctx->draw_mutex);
    tr_ctx->draw_rule.vs = U642VOID(rule->vertex);
    tr_ctx->draw_rule.fs = U642VOID(rule->fragment);
-   tr_ctx->draw_rule.tex = U642VOID(rule->texture);
+   tr_ctx->draw_rule.sampler_view = U642VOID(rule->texture);
    tr_ctx->draw_rule.surf = U642VOID(rule->surface);
    tr_ctx->draw_rule.blocker = rule->block;
    tr_ctx->draw_blocker |= RBUG_BLOCK_RULE;
index 4dc95308a79eda1c69b3fe688d7ac67399f81941..66250465e44db827b8bd5a7049c42fd2b2999c56 100644 (file)
@@ -56,6 +56,14 @@ struct trace_surface
 };
 
 
+struct trace_sampler_view
+{
+   struct pipe_sampler_view base;
+
+   struct pipe_sampler_view *sampler_view;
+};
+
+
 struct trace_transfer
 {
    struct pipe_transfer base;
@@ -89,6 +97,15 @@ trace_surface(struct pipe_surface *surface)
 }
 
 
+static INLINE struct trace_sampler_view *
+trace_sampler_view(struct pipe_sampler_view *sampler_view)
+{
+   if (!sampler_view)
+      return NULL;
+   return (struct trace_sampler_view *)sampler_view;
+}
+
+
 static INLINE struct trace_transfer *
 trace_transfer(struct pipe_transfer *transfer)
 {
index a7f12fb81e16513c092264857efcdb5874bb9af5..d1b734a9f9a3247f72d84c03320e2fe90d80d814 100644 (file)
@@ -214,13 +214,13 @@ struct pipe_context {
    void (*set_viewport_state)( struct pipe_context *,
                                const struct pipe_viewport_state * );
 
-   void (*set_fragment_sampler_textures)(struct pipe_context *,
-                                         unsigned num_textures,
-                                         struct pipe_texture **);
+   void (*set_fragment_sampler_views)(struct pipe_context *,
+                                      unsigned num_views,
+                                      struct pipe_sampler_view **);
 
-   void (*set_vertex_sampler_textures)(struct pipe_context *,
-                                       unsigned num_textures,
-                                       struct pipe_texture **);
+   void (*set_vertex_sampler_views)(struct pipe_context *,
+                                    unsigned num_views,
+                                    struct pipe_sampler_view **);
 
    void (*set_vertex_buffers)( struct pipe_context *,
                                unsigned num_buffers,
@@ -307,6 +307,15 @@ struct pipe_context {
    unsigned int (*is_buffer_referenced)(struct pipe_context *pipe,
                                        struct pipe_buffer *buf);
 
+   /**
+    * Create a view on a texture to be used by a shader stage.
+    */
+   struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx,
+                                                     struct pipe_texture *texture,
+                                                     const struct pipe_sampler_view *templat);
+
+   void (*sampler_view_destroy)(struct pipe_context *ctx,
+                                struct pipe_sampler_view *view);
 
 
    /**
index 5c97dc87e828e89a29748b60727db3ae78c8703d..c1e291b9da4518cd6c3edbdba9c032be90b68a61 100644 (file)
@@ -369,6 +369,17 @@ enum pipe_transfer_usage {
 #define PIPE_SPRITE_COORD_LOWER_LEFT 1
 
 
+/**
+ * Texture swizzles
+ */
+#define PIPE_SWIZZLE_RED   0
+#define PIPE_SWIZZLE_GREEN 1
+#define PIPE_SWIZZLE_BLUE  2
+#define PIPE_SWIZZLE_ALPHA 3
+#define PIPE_SWIZZLE_ZERO  4
+#define PIPE_SWIZZLE_ONE   5
+
+
 /**
  * Implementation capabilities/limits which are queried through
  * pipe_screen::get_param() and pipe_screen::get_paramf().
index cbf3273ec8d9269d620f643aaa20456ffef1864d..ba2985f4491779fd28f5a09402e80da881c33e1e 100644 (file)
@@ -157,6 +157,7 @@ enum pipe_format {
    PIPE_FORMAT_DXT5_SRGBA            = 109,
 
    PIPE_FORMAT_A8B8G8R8_UNORM        = 110,
+   PIPE_FORMAT_B5G5R5X1_UNORM        = 111,
 
    PIPE_FORMAT_COUNT
 };
index 3a97d888ce63fbc1b441aeb9175d689a3016d86b..11072407d93b78b0685bfd7c85cc89b69011ab78 100644 (file)
@@ -299,6 +299,24 @@ struct pipe_surface
 };
 
 
+/**
+ * A view into a texture that can be bound to a shader stage.
+ */
+struct pipe_sampler_view
+{
+   struct pipe_reference reference;
+   enum pipe_format format;      /**< typed PIPE_FORMAT_x */
+   struct pipe_texture *texture; /**< texture into which this is a view  */
+   struct pipe_context *context; /**< context this view belongs to */
+   unsigned first_level:8;       /**< first mipmap level */
+   unsigned last_level:8;        /**< last mipmap level */
+   unsigned swizzle_r:3;         /**< PIPE_SWIZZLE_x for red component */
+   unsigned swizzle_g:3;         /**< PIPE_SWIZZLE_x for green component */
+   unsigned swizzle_b:3;         /**< PIPE_SWIZZLE_x for blue component */
+   unsigned swizzle_a:3;         /**< PIPE_SWIZZLE_x for alpha component */
+};
+
+
 /**
  * Transfer object.  For data transfer to/from a texture.
  */
index b173ba3683d5588bbba8527ef804b41caa55bca7..bb1cd6d1d821ff4422f6788b76f6657b882d2dda 100644 (file)
@@ -7,14 +7,14 @@
 
 #include "state_tracker/drm_api.h"
 
-#include <drm.h>
-
 struct pipe_screen;
 struct pipe_winsys;
 struct pipe_buffer;
 struct pipe_context;
 struct pipe_texture;
 
+struct drm_clip_rect;
+
 struct dri1_api_version
 {
    int major;
@@ -31,8 +31,8 @@ struct dri1_api_lock_funcs
 {
    void (*lock) (struct pipe_context * pipe);
    void (*unlock) (struct pipe_context * locked_pipe);
-      boolean(*is_locked) (struct pipe_context * locked_pipe);
-      boolean(*is_lock_lost) (struct pipe_context * locked_pipe);
+   boolean(*is_locked) (struct pipe_context * locked_pipe);
+   boolean(*is_lock_lost) (struct pipe_context * locked_pipe);
    void (*clear_lost_lock) (struct pipe_context * locked_pipe);
 };
 
diff --git a/src/gallium/include/state_tracker/drisw_api.h b/src/gallium/include/state_tracker/drisw_api.h
new file mode 100644 (file)
index 0000000..c6adebb
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef _DRISW_API_H_
+#define _DRISW_API_H_
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_screen.h"
+#include "pipe/p_format.h"
+
+#include "state_tracker/drm_api.h"
+
+struct pipe_screen;
+struct pipe_winsys;
+struct pipe_buffer;
+struct pipe_context;
+struct pipe_texture;
+
+struct dri_drawable;
+
+/**
+ * This callback struct is intended for the winsys to call the loader.
+ */
+
+struct drisw_loader_funcs
+{
+   void (*put_image) (struct dri_drawable *dri_drawable,
+                      void *data, unsigned width, unsigned height);
+};
+
+struct drisw_create_screen_arg
+{
+   struct drm_create_screen_arg base;
+
+   struct drisw_loader_funcs *lf;
+};
+
+#endif
index fe7ef253ef0e86305be04068338295d018453c2d..9780cf250b84681c14633360df6db9d0360101b3 100644 (file)
@@ -13,6 +13,7 @@ struct pipe_texture;
 enum drm_create_screen_mode {
        DRM_CREATE_NORMAL = 0,
        DRM_CREATE_DRI1,
+       DRM_CREATE_DRISW,
        DRM_CREATE_DRIVER = 1024,
        DRM_CREATE_MAX
 };
diff --git a/src/gallium/include/state_tracker/graw.h b/src/gallium/include/state_tracker/graw.h
new file mode 100644 (file)
index 0000000..a58e18e
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef GALLIUM_RAW_H
+#define GALLIUM_RAW_H
+
+/* This is an API for exercising gallium functionality in a
+ * platform-neutral fashion.  Whatever platform integration is
+ * necessary to implement this interface is orchestrated by the
+ * individual target building this entity.
+ *
+ * For instance, the graw-xlib target includes code to implent these
+ * interfaces on top of the X window system.
+ *
+ * Programs using this interface may additionally benefit from some of
+ * the utilities currently in the libgallium.a library, especially
+ * those for parsing text representations of TGSI shaders.
+ */
+
+#include "pipe/p_format.h"
+
+struct pipe_screen;
+
+struct pipe_screen *graw_init( void );
+
+/* Returns a handle to be used with flush_frontbuffer()/present().
+ *
+ * Query format support with screen::is_format_supported and usage
+ * XXX.
+ */
+void *graw_create_window( int x,
+                          int y,
+                          unsigned width,
+                          unsigned height,
+                          enum pipe_format format );
+
+void graw_destroy_window( void *handle );
+
+#endif
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
new file mode 100644 (file)
index 0000000..70ad215
--- /dev/null
@@ -0,0 +1,407 @@
+/**********************************************************
+ * Copyright 2010 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * 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 _ST_API_H_
+#define _ST_API_H_
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+
+/**
+ * \file API for communication between state trackers and state tracker
+ * managers.
+ *
+ * While both are state tackers, we use the term state tracker for rendering
+ * APIs such as OpenGL or OpenVG, and state tracker manager for window system
+ * APIs such as EGL or GLX in this file.
+ *
+ * This file defines an API to be implemented by both state trackers and state
+ * tracker managers.
+ */
+
+/**
+ * The entry points of the state trackers.
+ */
+#define ST_MODULE_OPENGL_SYMBOL      "st_module_OpenGL"
+#define ST_MODULE_OPENGL_ES1_SYMBOL  "st_module_OpenGL_ES1"
+#define ST_MODULE_OPENGL_ES2_SYMBOL  "st_module_OpenGL_ES2"
+#define ST_MODULE_OPENVG_SYMBOL      "st_module_OpenVG"
+
+/**
+ * The supported rendering API of a state tracker.
+ */
+enum st_api_type {
+   ST_API_OPENGL,
+   ST_API_OPENGL_ES1,
+   ST_API_OPENGL_ES2,
+   ST_API_OPENVG,
+
+   ST_API_COUNT
+};
+
+/**
+ * Used in st_context_iface->teximage.
+ */
+enum st_texture_type {
+   ST_TEXTURE_1D,
+   ST_TEXTURE_2D,
+   ST_TEXTURE_3D,
+   ST_TEXTURE_RECT,
+};
+
+/**
+ * Available attachments of framebuffer.
+ */
+enum st_attachment_type {
+   ST_ATTACHMENT_FRONT_LEFT,
+   ST_ATTACHMENT_BACK_LEFT,
+   ST_ATTACHMENT_FRONT_RIGHT,
+   ST_ATTACHMENT_BACK_RIGHT,
+   ST_ATTACHMENT_DEPTH_STENCIL,
+   ST_ATTACHMENT_ACCUM,
+   ST_ATTACHMENT_SAMPLE,
+
+   ST_ATTACHMENT_COUNT,
+   ST_ATTACHMENT_INVALID = -1
+};
+
+/* for buffer_mask in st_visual */
+#define ST_ATTACHMENT_FRONT_LEFT_MASK     (1 << ST_ATTACHMENT_FRONT_LEFT)
+#define ST_ATTACHMENT_BACK_LEFT_MASK      (1 << ST_ATTACHMENT_BACK_LEFT)
+#define ST_ATTACHMENT_FRONT_RIGHT_MASK    (1 << ST_ATTACHMENT_FRONT_RIGHT)
+#define ST_ATTACHMENT_BACK_RIGHT_MASK     (1 << ST_ATTACHMENT_BACK_RIGHT)
+#define ST_ATTACHMENT_DEPTH_STENCIL_MASK  (1 << ST_ATTACHMENT_DEPTH_STENCIL)
+#define ST_ATTACHMENT_ACCUM_MASK          (1 << ST_ATTACHMENT_ACCUM)
+#define ST_ATTACHMENT_SAMPLE_MASK         (1 << ST_ATTACHMENT_SAMPLE)
+
+/**
+ * Enumerations of state tracker context resources.
+ */
+enum st_context_resource_type {
+   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_2D,
+   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_3D,
+   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_X,
+   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_X,
+   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Y,
+   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
+   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Z,
+   ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
+   ST_CONTEXT_RESOURCE_OPENGL_RENDERBUFFER,
+   ST_CONTEXT_RESOURCE_OPENVG_PARENT_IMAGE,
+};
+
+/**
+ * The return type of st_api->get_proc_address.
+ */
+typedef void (*st_proc_t)(void);
+
+struct pipe_context;
+struct pipe_texture;
+struct pipe_fence_handle;
+
+/**
+ * Used in st_context_iface->get_resource_for_egl_image.
+ */
+struct st_context_resource
+{
+   /* these fields are filled by the caller */
+   enum st_context_resource_type type;
+   void *resource;
+
+   /* this is owned by the caller */
+   struct pipe_texture *texture;
+};
+
+/**
+ * Used in st_manager_iface->get_egl_image.
+ */
+struct st_egl_image
+{
+   /* these fields are filled by the caller */
+   struct st_context_iface *stctxi;
+   void *egl_image;
+
+   /* this is owned by the caller */
+   struct pipe_texture *texture;
+
+   unsigned face;
+   unsigned level;
+   unsigned zslice;
+};
+
+/**
+ * Represent the visual of a framebuffer.
+ */
+struct st_visual
+{
+   /**
+    * Available buffers.  Tested with ST_FRAMEBUFFER_*_MASK.
+    */
+   unsigned buffer_mask;
+
+   /**
+    * Buffer formats.  The formats are always set even when the buffer is
+    * not available.
+    */
+   enum pipe_format color_format;
+   enum pipe_format depth_stencil_format;
+   enum pipe_format accum_format;
+   int samples;
+
+   /**
+    * Desired render buffer.
+    */
+   enum st_attachment_type render_buffer;
+};
+
+/**
+ * Represent a windowing system drawable.
+ *
+ * The framebuffer is implemented by the state tracker manager and
+ * used by the state trackers.
+ *
+ * Instead of the winsys pokeing into the API context to figure
+ * out what buffers that might be needed in the future by the API
+ * context, it calls into the framebuffer to get the textures.
+ *
+ * This structure along with the notify_invalid_framebuffer
+ * allows framebuffers to be shared between different threads
+ * but at the same make the API context free from thread
+ * syncronisation primitves, with the exception of a small
+ * atomic flag used for notification of framebuffer dirty status.
+ *
+ * The thread syncronisation is put inside the framebuffer
+ * and only called once the framebuffer has become dirty.
+ */
+struct st_framebuffer_iface
+{
+   /**
+    * Available for the state tracker manager to use.
+    */
+   void *st_manager_private;
+
+   /**
+    * The visual of a framebuffer.
+    */
+   const struct st_visual *visual;
+
+   /**
+    * Flush the front buffer.
+    *
+    * On some window systems, changes to the front buffers are not immediately
+    * visible.  They need to be flushed.
+    *
+    * @att is one of the front buffer attachments.
+    */
+   boolean (*flush_front)(struct st_framebuffer_iface *stfbi,
+                          enum st_attachment_type statt);
+
+   /**
+    * The state tracker asks for the textures it needs.
+    *
+    * It should try to only ask for attachments that it currently renders
+    * to, thus allowing the winsys to delay the allocation of textures not
+    * needed. For example front buffer attachments are not needed if you
+    * only do back buffer rendering.
+    *
+    * The implementor of this function needs to also ensure
+    * thread safty as this call might be done from multiple threads.
+    *
+    * The returned textures are owned by the caller.  They should be
+    * unreferenced when no longer used.  If this function is called multiple
+    * times with different sets of attachments, those buffers not included in
+    * the last call might be destroyed.  This behavior might change in the
+    * future.
+    */
+   boolean (*validate)(struct st_framebuffer_iface *stfbi,
+                       const enum st_attachment_type *statts,
+                       unsigned count,
+                       struct pipe_texture **out);
+};
+
+/**
+ * Represent a rendering context.
+ *
+ * This entity is created from st_api and used by the state tracker manager.
+ */
+struct st_context_iface
+{
+   /**
+    * Available for the state tracker and the manager to use.
+    */
+   void *st_context_private;
+   void *st_manager_private;
+
+   /**
+    * Destroy the context.
+    */
+   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,
+                 struct pipe_fence_handle **fence);
+
+   /**
+    * Replace the texture image of a texture object at the specified level.
+    *
+    * This function is optional.
+    */
+   boolean (*teximage)(struct st_context_iface *stctxi, enum st_texture_type target,
+                       int level, enum pipe_format internal_format,
+                       struct pipe_texture *tex, boolean mipmap);
+
+   /**
+    * Used to implement glXCopyContext.
+    */
+   void (*copy)(struct st_context_iface *stctxi,
+                struct st_context_iface *stsrci, unsigned mask);
+
+   /**
+    * Look up and return the info of a resource for EGLImage.
+    *
+    * This function is optional.
+    */
+   boolean (*get_resource_for_egl_image)(struct st_context_iface *stctxi,
+                                         struct st_context_resource *stres);
+};
+
+
+/**
+ * Represent a state tracker manager.
+ *
+ * This interface is implemented by the state tracker manager.  It corresponds
+ * to a "display" in the window system.
+ */
+struct st_manager
+{
+   struct pipe_screen *screen;
+
+   /**
+    * Look up and return the info of an EGLImage.
+    *
+    * This function is optional.
+    */
+   boolean (*get_egl_image)(struct st_manager *smapi,
+                            struct st_egl_image *stimg);
+};
+
+/**
+ * Represent a rendering API such as OpenGL or OpenVG.
+ *
+ * Implemented by the state tracker and used by the state tracker manager.
+ */
+struct st_api
+{
+   /**
+    * Destroy the API.
+    */
+   void (*destroy)(struct st_api *stapi);
+
+   /**
+    * Return an API entry point.
+    *
+    * For GL this is the same as _glapi_get_proc_address.
+    */
+   st_proc_t (*get_proc_address)(struct st_api *stapi, const char *procname);
+
+   /**
+    * Return true if the visual is supported by the state tracker.
+    */
+   boolean (*is_visual_supported)(struct st_api *stapi,
+                                  const struct st_visual *visual);
+
+   /**
+    * Create a rendering context.
+    */
+   struct st_context_iface *(*create_context)(struct st_api *stapi,
+                                              struct st_manager *smapi,
+                                              const struct st_visual *visual,
+                                              struct st_context_iface *stsharei);
+
+   /**
+    * Bind the context to the calling thread with draw and read as drawables.
+    *
+    * The framebuffers might have different visuals than the context does.
+    */
+   boolean (*make_current)(struct st_api *stapi,
+                           struct st_context_iface *stctxi,
+                           struct st_framebuffer_iface *stdrawi,
+                           struct st_framebuffer_iface *streadi);
+
+   /**
+    * Get the currently bound context in the calling thread.
+    */
+   struct st_context_iface *(*get_current)(struct st_api *stapi);
+};
+
+/**
+ * Represent a state tracker.
+ *
+ * This is the entry point of a state tracker.
+ */
+struct st_module
+{
+   enum st_api_type api;
+   struct st_api *(*create_api)(void);
+};
+
+/**
+ * Return true if the visual has the specified buffers.
+ */
+static INLINE boolean
+st_visual_have_buffers(const struct st_visual *visual, unsigned mask)
+{
+   return ((visual->buffer_mask & mask) == mask);
+}
+
+/* these symbols may need to be dynamically lookup up */
+extern PUBLIC const struct st_module st_module_OpenGL;
+extern PUBLIC const struct st_module st_module_OpenGL_ES1;
+extern PUBLIC const struct st_module st_module_OpenGL_ES2;
+extern PUBLIC const struct st_module st_module_OpenVG;
+
+#endif /* _ST_API_H_ */
index 0de98bbc1c9b8e34c6ee7ee5373654d8fc08fefd..a87650dc77dbcfaf11bc48897722b165a05e7a69 100644 (file)
@@ -44,8 +44,10 @@ extern "C" {
 #endif
 
 
+struct winsys_handle;
 struct pipe_screen;
 struct pipe_context;
+struct pipe_texture;
 
 
 /**
@@ -68,6 +70,7 @@ struct sw_winsys
 
    boolean
    (*is_displaytarget_format_supported)( struct sw_winsys *ws,
+                                         unsigned tex_usage,
                                          enum pipe_format format );
    
    /**
@@ -83,11 +86,29 @@ struct sw_winsys
     */
    struct sw_displaytarget *
    (*displaytarget_create)( struct sw_winsys *ws,
+                            unsigned tex_usage,
                             enum pipe_format format,
                             unsigned width, unsigned height,
                             unsigned alignment,
                             unsigned *stride );
 
+   /**
+    * Used to implement texture_from_handle.
+    */
+   struct sw_displaytarget *
+   (*displaytarget_from_handle)( struct sw_winsys *ws,
+                                 const struct pipe_texture *templat,
+                                 struct winsys_handle *whandle,
+                                 unsigned *stride );
+
+   /**
+    * Used to implement texture_get_handle.
+    */
+   boolean
+   (*displaytarget_get_handle)( struct sw_winsys *ws,
+                                struct sw_displaytarget *dt,
+                                struct winsys_handle *whandle );
+
    /**
     * \param flags  bitmask of PIPE_BUFFER_USAGE_x flags
     */
index ef8f19709ab242e497bb80210fd138e54c222362..72e70577b3d57cb9311b50b46cfc500c61bd9041 100644 (file)
@@ -1,28 +1,12 @@
+# src/gallium/state_trackers/dri/Makefile
 TOP = ../../../..
 include $(TOP)/configs/current
 
-LIBNAME = dridrm
+SUBDIRS = drm sw
 
-LIBRARY_INCLUDES = \
-       -I$(TOP)/include \
-       -I$(TOP)/src/mesa \
-       -I$(TOP)/src/mesa/drivers/dri/common \
-       -I$(TOP)/src/mesa/main \
-         $(shell pkg-config --cflags-only-I libdrm)
-
-
-C_SOURCES = \
-       dri_context.c \
-       dri_screen.c \
-       dri_drawable.c \
-       dri_extensions.c
-
-#      $(TOP)/src/mesa/drivers/dri/common/utils.c \
-       $(TOP)/src/mesa/drivers/dri/common/vblank.c \
-       $(TOP)/src/mesa/drivers/dri/common/dri_util.c \
-       $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \
-       $(TOP)/src/mesa/drivers/common/driverfuncs.c \
-       $(TOP)/src/mesa/drivers/dri/common/texmem.c \
-       $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c
-
-include ../../Makefile.template
+default install clean:
+       @for dir in $(SUBDIRS) ; do \
+               if [ -d $$dir ] ; then \
+                       (cd $$dir && $(MAKE) $@) || exit 1; \
+               fi \
+       done
index ce2c27359742db6e46872c9096a34cf24189ae00..aba60fb8c5bb324044ce652f2dd2691d1b4d7f19 100644 (file)
@@ -1,23 +1,6 @@
-#######################################################################
-# SConscript for dri state_tracker
-
 Import('*')
 
-if env['dri']:
-
-    env = env.Clone()
-
-    env.Append(CPPPATH = [
-        '#/src/mesa',
-       '#/src/mesa/drivers/dri/common',
-    ])
-
-    st_dri = env.ConvenienceLibrary(
-       target = 'st_dri',
-       source = [ 'dri_context.c',
-               'dri_drawable.c',
-               'dri_extensions.c',
-               'dri_screen.c',
-               ]
-    )
-    Export('st_dri')
+SConscript([
+       'sw/SConscript',
+       'drm/SConscript',
+])
diff --git a/src/gallium/state_trackers/dri/common/dri1_helper.c b/src/gallium/state_trackers/dri/common/dri1_helper.c
new file mode 100644 (file)
index 0000000..7eeb868
--- /dev/null
@@ -0,0 +1,129 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Management of pipe objects (surface / pipe / fences) used by DRI1 and DRISW.
+ *
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "util/u_inlines.h"
+#include "pipe/p_context.h"
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+#include "dri1_helper.h"
+
+struct pipe_fence_handle *
+dri1_swap_fences_pop_front(struct dri_drawable *draw)
+{
+   struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
+   struct pipe_fence_handle *fence = NULL;
+
+   if (draw->cur_fences >= draw->desired_fences) {
+      screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]);
+      screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
+      --draw->cur_fences;
+      draw->tail &= DRI_SWAP_FENCES_MASK;
+   }
+   return fence;
+}
+
+void
+dri1_swap_fences_push_back(struct dri_drawable *draw,
+                           struct pipe_fence_handle *fence)
+{
+   struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
+
+   if (!fence)
+      return;
+
+   if (draw->cur_fences < DRI_SWAP_FENCES_MAX) {
+      draw->cur_fences++;
+      screen->fence_reference(screen, &draw->swap_fences[draw->head++],
+                             fence);
+      draw->head &= DRI_SWAP_FENCES_MASK;
+   }
+}
+
+void
+dri1_swap_fences_clear(struct dri_drawable *drawable)
+{
+   struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
+   struct pipe_fence_handle *fence;
+
+   while (drawable->cur_fences) {
+      fence = dri1_swap_fences_pop_front(drawable);
+      screen->fence_reference(screen, &fence, NULL);
+   }
+}
+
+struct pipe_surface *
+dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex)
+{
+   struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen;
+   struct pipe_surface *psurf = drawable->dri1_surface;
+
+   if (!psurf || psurf->texture != ptex) {
+      pipe_surface_reference(&drawable->dri1_surface, NULL);
+
+      drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen,
+            ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
+
+      psurf = drawable->dri1_surface;
+   }
+
+   return psurf;
+}
+
+void
+dri1_destroy_pipe_surface(struct dri_drawable *drawable)
+{
+   pipe_surface_reference(&drawable->dri1_surface, NULL);
+}
+
+struct pipe_context *
+dri1_get_pipe_context(struct dri_screen *screen)
+{
+   struct pipe_context *pipe = screen->dri1_pipe;
+
+   if (!pipe) {
+      screen->dri1_pipe =
+         screen->pipe_screen->context_create(screen->pipe_screen, NULL);
+      pipe = screen->dri1_pipe;
+   }
+
+   return pipe;
+}
+
+void
+dri1_destroy_pipe_context(struct dri_screen *screen)
+{
+   if (screen->dri1_pipe)
+      screen->dri1_pipe->destroy(screen->dri1_pipe);
+}
diff --git a/src/gallium/state_trackers/dri/common/dri1_helper.h b/src/gallium/state_trackers/dri/common/dri1_helper.h
new file mode 100644 (file)
index 0000000..3254b7f
--- /dev/null
@@ -0,0 +1,61 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#ifndef DRI1_HELPER_H
+#define DRI1_HELPER_H
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+
+struct pipe_fence_handle *
+dri1_swap_fences_pop_front(struct dri_drawable *draw);
+
+void
+dri1_swap_fences_push_back(struct dri_drawable *draw,
+                           struct pipe_fence_handle *fence);
+
+void
+dri1_swap_fences_clear(struct dri_drawable *drawable);
+
+struct pipe_surface *
+dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex);
+
+void
+dri1_destroy_pipe_surface(struct dri_drawable *drawable);
+
+struct pipe_context *
+dri1_get_pipe_context(struct dri_screen *screen);
+
+void
+dri1_destroy_pipe_context(struct dri_screen *screen);
+
+#endif /* DRI1_HELPER_H */
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
new file mode 100644 (file)
index 0000000..f14f413
--- /dev/null
@@ -0,0 +1,186 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "utils.h"
+
+#include "dri_screen.h"
+#include "dri_drawable.h"
+#include "dri_context.h"
+#include "dri_st_api.h"
+
+#include "pipe/p_context.h"
+#include "state_tracker/st_context.h"
+
+static void
+dri_init_extensions(struct dri_context *ctx)
+{
+   struct st_context *st = (struct st_context *) ctx->st;
+
+   /* New extensions should be added in mesa/state_tracker/st_extensions.c
+    * and not in this file. */
+   driInitExtensions(st->ctx, NULL, GL_FALSE);
+}
+
+GLboolean
+dri_create_context(const __GLcontextModes * visual,
+                  __DRIcontext * cPriv, void *sharedContextPrivate)
+{
+   struct st_api *stapi = dri_get_st_api();
+   __DRIscreen *sPriv = cPriv->driScreenPriv;
+   struct dri_screen *screen = dri_screen(sPriv);
+   struct dri_context *ctx = NULL;
+   struct st_context_iface *st_share = NULL;
+   struct st_visual stvis;
+
+   if (sharedContextPrivate) {
+      st_share = ((struct dri_context *)sharedContextPrivate)->st;
+   }
+
+   ctx = CALLOC_STRUCT(dri_context);
+   if (ctx == NULL)
+      goto fail;
+
+   cPriv->driverPrivate = ctx;
+   ctx->cPriv = cPriv;
+   ctx->sPriv = sPriv;
+   ctx->lock = screen->drmLock;
+
+   driParseConfigFiles(&ctx->optionCache,
+                      &screen->optionCache, sPriv->myNum, "dri");
+
+   dri_fill_st_visual(&stvis, screen, visual);
+   ctx->st = stapi->create_context(stapi, screen->smapi, &stvis, st_share);
+   if (ctx->st == NULL)
+      goto fail;
+   ctx->st->st_manager_private = (void *) ctx;
+
+   dri_init_extensions(ctx);
+
+   return GL_TRUE;
+
+ fail:
+   if (ctx && ctx->st)
+      ctx->st->destroy(ctx->st);
+
+   FREE(ctx);
+   return FALSE;
+}
+
+void
+dri_destroy_context(__DRIcontext * cPriv)
+{
+   struct dri_context *ctx = dri_context(cPriv);
+
+   /* note: we are freeing values and nothing more because
+    * driParseConfigFiles allocated values only - the rest
+    * is owned by screen optionCache.
+    */
+   FREE(ctx->optionCache.values);
+
+   /* No particular reason to wait for command completion before
+    * destroying a context, but it is probably worthwhile flushing it
+    * to avoid having to add code elsewhere to cope with flushing a
+    * partially destroyed context.
+    */
+   ctx->st->flush(ctx->st, 0, NULL);
+   ctx->st->destroy(ctx->st);
+
+   FREE(ctx);
+}
+
+GLboolean
+dri_unbind_context(__DRIcontext * cPriv)
+{
+   struct st_api *stapi = dri_get_st_api();
+
+   if (cPriv) {
+      struct dri_context *ctx = dri_context(cPriv);
+
+      if (--ctx->bind_count == 0) {
+         if (ctx->st == stapi->get_current(stapi)) {
+            ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+            stapi->make_current(stapi, NULL, NULL, NULL);
+         }
+      }
+   }
+
+   return GL_TRUE;
+}
+
+GLboolean
+dri_make_current(__DRIcontext * cPriv,
+                __DRIdrawable * driDrawPriv,
+                __DRIdrawable * driReadPriv)
+{
+   struct st_api *stapi = dri_get_st_api();
+
+   if (cPriv) {
+      struct dri_context *ctx = dri_context(cPriv);
+      struct dri_drawable *draw = dri_drawable(driDrawPriv);
+      struct dri_drawable *read = dri_drawable(driReadPriv);
+      struct st_context_iface *old_st;
+
+      old_st = stapi->get_current(stapi);
+      if (old_st && old_st != ctx->st)
+        ctx->st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+      ++ctx->bind_count;
+
+      if (ctx->dPriv != driDrawPriv) {
+        ctx->dPriv = driDrawPriv;
+         draw->texture_stamp = driDrawPriv->lastStamp - 1;
+      }
+      if (ctx->rPriv != driReadPriv) {
+        ctx->rPriv = driReadPriv;
+         read->texture_stamp = driReadPriv->lastStamp - 1;
+      }
+
+      stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb);
+   }
+   else {
+      stapi->make_current(stapi, NULL, NULL, NULL);
+   }
+
+   return GL_TRUE;
+}
+
+struct dri_context *
+dri_get_current(void)
+{
+   struct st_api *stapi = dri_get_st_api();
+   struct st_context_iface *st;
+
+   st = stapi->get_current(stapi);
+
+   return (struct dri_context *) (st) ? st->st_manager_private : NULL;
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/common/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h
new file mode 100644 (file)
index 0000000..5946188
--- /dev/null
@@ -0,0 +1,92 @@
+/**************************************************************************
+ *
+ * Copyright (C) 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#ifndef DRI_CONTEXT_H
+#define DRI_CONTEXT_H
+
+#include "pipe/p_compiler.h"
+#include "dri_wrapper.h"
+
+struct pipe_context;
+struct pipe_fence;
+struct st_context;
+struct dri_drawable;
+
+struct dri_context
+{
+   /* dri */
+   __DRIscreen *sPriv;
+   __DRIcontext *cPriv;
+   __DRIdrawable *dPriv;
+   __DRIdrawable *rPriv;
+
+   driOptionCache optionCache;
+
+   drmLock *lock;
+   boolean isLocked;
+   boolean stLostLock;
+   boolean wsLostLock;
+
+   unsigned int bind_count;
+
+   /* gallium */
+   struct st_context_iface *st;
+};
+
+static INLINE struct dri_context *
+dri_context(__DRIcontext * driContextPriv)
+{
+   return (struct dri_context *)driContextPriv->driverPrivate;
+}
+
+/***********************************************************************
+ * dri_context.c
+ */
+void dri_destroy_context(__DRIcontext * driContextPriv);
+
+boolean dri_unbind_context(__DRIcontext * driContextPriv);
+
+boolean
+dri_make_current(__DRIcontext * driContextPriv,
+                __DRIdrawable * driDrawPriv,
+                __DRIdrawable * driReadPriv);
+
+struct dri_context *
+dri_get_current(void);
+
+boolean
+dri_create_context(const __GLcontextModes * visual,
+                  __DRIcontext * driContextPriv,
+                  void *sharedContextPrivate);
+
+#endif
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c
new file mode 100644 (file)
index 0000000..75b4cc5
--- /dev/null
@@ -0,0 +1,94 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+#include "dri_st_api.h"
+#include "dri1_helper.h"
+
+#include "pipe/p_screen.h"
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+/**
+ * This is called when we need to set up GL rendering to a new X window.
+ */
+boolean
+dri_create_buffer(__DRIscreen * sPriv,
+                 __DRIdrawable * dPriv,
+                 const __GLcontextModes * visual, boolean isPixmap)
+{
+   struct dri_screen *screen = sPriv->private;
+   struct dri_drawable *drawable = NULL;
+
+   if (isPixmap)
+      goto fail;                      /* not implemented */
+
+   drawable = CALLOC_STRUCT(dri_drawable);
+   if (drawable == NULL)
+      goto fail;
+
+   dri_fill_st_visual(&drawable->stvis, screen, visual);
+   drawable->stfb = dri_create_st_framebuffer(drawable);
+   if (drawable->stfb == NULL)
+      goto fail;
+
+   drawable->sPriv = sPriv;
+   drawable->dPriv = dPriv;
+   dPriv->driverPrivate = (void *)drawable;
+
+   drawable->desired_fences = 2;
+
+   return GL_TRUE;
+fail:
+   FREE(drawable);
+   return GL_FALSE;
+}
+
+void
+dri_destroy_buffer(__DRIdrawable * dPriv)
+{
+   struct dri_drawable *drawable = dri_drawable(dPriv);
+
+   dri1_swap_fences_clear(drawable);
+
+   dri1_destroy_pipe_surface(drawable);
+
+   dri_destroy_st_framebuffer(drawable->stfb);
+
+   drawable->desired_fences = 0;
+
+   FREE(drawable);
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h
new file mode 100644 (file)
index 0000000..98abeb9
--- /dev/null
@@ -0,0 +1,89 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef DRI_DRAWABLE_H
+#define DRI_DRAWABLE_H
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "state_tracker/st_api.h"
+
+struct pipe_surface;
+struct pipe_fence_handle;
+struct st_framebuffer;
+struct dri_context;
+
+#define DRI_SWAP_FENCES_MAX  8
+#define DRI_SWAP_FENCES_MASK 7
+
+struct dri_drawable
+{
+   /* dri */
+   __DRIdrawable *dPriv;
+   __DRIscreen *sPriv;
+
+   /* gallium */
+   struct st_framebuffer_iface *stfb;
+   struct st_visual stvis;
+
+   __DRIbuffer old[8];
+   unsigned old_num;
+   unsigned old_w;
+   unsigned old_h;
+
+   struct pipe_texture *textures[ST_ATTACHMENT_COUNT];
+   unsigned int texture_mask, texture_stamp;
+
+   struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX];
+   unsigned int head;
+   unsigned int tail;
+   unsigned int desired_fences;
+   unsigned int cur_fences;
+
+   /* used only by DRI1 */
+   struct pipe_surface *dri1_surface;
+};
+
+static INLINE struct dri_drawable *
+dri_drawable(__DRIdrawable * driDrawPriv)
+{
+   return (struct dri_drawable *)driDrawPriv->driverPrivate;
+}
+
+/***********************************************************************
+ * dri_drawable.c
+ */
+boolean
+dri_create_buffer(__DRIscreen * sPriv,
+                 __DRIdrawable * dPriv,
+                 const __GLcontextModes * visual, boolean isPixmap);
+
+void dri_destroy_buffer(__DRIdrawable * dPriv);
+
+#endif
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c
new file mode 100644 (file)
index 0000000..821c1de
--- /dev/null
@@ -0,0 +1,381 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL 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.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "utils.h"
+#ifndef __NOT_HAVE_DRM_H
+#include "vblank.h"
+#endif
+#include "xmlpool.h"
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+#include "dri_st_api.h"
+#include "dri1_helper.h"
+#ifndef __NOT_HAVE_DRM_H
+#include "dri1.h"
+#include "dri2.h"
+#else
+#include "drisw.h"
+#endif
+
+#include "util/u_inlines.h"
+#include "pipe/p_screen.h"
+#include "pipe/p_format.h"
+
+#include "util/u_debug.h"
+
+PUBLIC const char __driConfigOptions[] =
+   DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
+   DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+   DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+   DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
+/* DRI_CONF_FORCE_S3TC_ENABLE(false) */
+   DRI_CONF_ALLOW_LARGE_TEXTURES(1)
+   DRI_CONF_SECTION_END DRI_CONF_END;
+
+static const uint __driNConfigOptions = 3;
+
+static const __DRIconfig **
+dri_fill_in_modes(struct dri_screen *screen,
+                 unsigned pixel_bits)
+{
+   __DRIconfig **configs = NULL;
+   __DRIconfig **configs_r5g6b5 = NULL;
+   __DRIconfig **configs_a8r8g8b8 = NULL;
+   __DRIconfig **configs_x8r8g8b8 = NULL;
+   unsigned num_modes;
+   uint8_t depth_bits_array[5];
+   uint8_t stencil_bits_array[5];
+   uint8_t msaa_samples_array[2];
+   unsigned depth_buffer_factor;
+   unsigned back_buffer_factor;
+   unsigned msaa_samples_factor;
+   struct pipe_screen *p_screen = screen->pipe_screen;
+   boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8;
+   boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32;
+
+   static const GLenum back_buffer_modes[] = {
+      GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+   };
+
+   depth_bits_array[0] = 0;
+   stencil_bits_array[0] = 0;
+   depth_buffer_factor = 1;
+
+   pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,
+                                           PIPE_TEXTURE_2D,
+                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+   pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,
+                                           PIPE_TEXTURE_2D,
+                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+   pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM,
+                                           PIPE_TEXTURE_2D,
+                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+   pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM,
+                                           PIPE_TEXTURE_2D,
+                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+   pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
+                                              PIPE_TEXTURE_2D,
+                                              PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
+   pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
+                                              PIPE_TEXTURE_2D,
+                                              PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
+   pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
+                                            PIPE_TEXTURE_2D,
+                                            PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
+
+   /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
+   if (dri_with_format(screen->sPriv)) {
+      pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
+                                             PIPE_TEXTURE_2D,
+                                             PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+      pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
+                                             PIPE_TEXTURE_2D,
+                                             PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+   } else {
+      pf_z16 = FALSE;
+      pf_z32 = FALSE;
+   }
+
+   if (pf_z16) {
+      depth_bits_array[depth_buffer_factor] = 16;
+      stencil_bits_array[depth_buffer_factor++] = 0;
+   }
+   if (pf_x8z24 || pf_z24x8) {
+      depth_bits_array[depth_buffer_factor] = 24;
+      stencil_bits_array[depth_buffer_factor++] = 0;
+      screen->d_depth_bits_last = pf_x8z24;
+   }
+   if (pf_s8z24 || pf_z24s8) {
+      depth_bits_array[depth_buffer_factor] = 24;
+      stencil_bits_array[depth_buffer_factor++] = 8;
+      screen->sd_depth_bits_last = pf_s8z24;
+   }
+   if (pf_z32) {
+      depth_bits_array[depth_buffer_factor] = 32;
+      stencil_bits_array[depth_buffer_factor++] = 0;
+   }
+
+   msaa_samples_array[0] = 0;
+   msaa_samples_array[1] = 4;
+   back_buffer_factor = 3;
+   msaa_samples_factor = 2;
+
+   num_modes =
+      depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
+
+   if (pf_r5g6b5)
+      configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
+                                        depth_bits_array, stencil_bits_array,
+                                        depth_buffer_factor, back_buffer_modes,
+                                        back_buffer_factor,
+                                        msaa_samples_array, msaa_samples_factor,
+                                        GL_TRUE);
+
+   if (pf_a8r8g8b8)
+      configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+                                          depth_bits_array,
+                                          stencil_bits_array,
+                                          depth_buffer_factor,
+                                          back_buffer_modes,
+                                          back_buffer_factor,
+                                          msaa_samples_array,
+                                          msaa_samples_factor,
+                                          GL_TRUE);
+
+   if (pf_x8r8g8b8)
+      configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
+                                          depth_bits_array,
+                                          stencil_bits_array,
+                                          depth_buffer_factor,
+                                          back_buffer_modes,
+                                          back_buffer_factor,
+                                          msaa_samples_array,
+                                          msaa_samples_factor,
+                                          GL_TRUE);
+
+   if (pixel_bits == 16) {
+      configs = configs_r5g6b5;
+      if (configs_a8r8g8b8)
+         configs = configs ? driConcatConfigs(configs, configs_a8r8g8b8) : configs_a8r8g8b8;
+      if (configs_x8r8g8b8)
+        configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
+   } else {
+      configs = configs_a8r8g8b8;
+      if (configs_x8r8g8b8)
+        configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
+      if (configs_r5g6b5)
+         configs = configs ? driConcatConfigs(configs, configs_r5g6b5) : configs_r5g6b5;
+   }
+
+   if (configs == NULL) {
+      debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__);
+      return NULL;
+   }
+
+   return (const __DRIconfig **)configs;
+}
+
+/**
+ * Roughly the converse of dri_fill_in_modes.
+ */
+void
+dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
+                   const __GLcontextModes *mode)
+{
+   memset(stvis, 0, sizeof(*stvis));
+
+   stvis->samples = mode->samples;
+   stvis->render_buffer = ST_ATTACHMENT_INVALID;
+
+   if (mode->redBits == 8) {
+      if (mode->alphaBits == 8)
+         stvis->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+      else
+         stvis->color_format = PIPE_FORMAT_B8G8R8X8_UNORM;
+   } else {
+      stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM;
+   }
+
+   switch (mode->depthBits) {
+   default:
+   case 0:
+      stvis->depth_stencil_format = PIPE_FORMAT_NONE;
+      break;
+   case 16:
+      stvis->depth_stencil_format = PIPE_FORMAT_Z16_UNORM;
+      break;
+   case 24:
+      if (mode->stencilBits == 0) {
+        stvis->depth_stencil_format = (screen->d_depth_bits_last) ?
+                                          PIPE_FORMAT_Z24X8_UNORM:
+                                          PIPE_FORMAT_X8Z24_UNORM;
+      } else {
+        stvis->depth_stencil_format = (screen->sd_depth_bits_last) ?
+                                          PIPE_FORMAT_Z24S8_UNORM:
+                                          PIPE_FORMAT_S8Z24_UNORM;
+      }
+      break;
+   case 32:
+      stvis->depth_stencil_format = PIPE_FORMAT_Z32_UNORM;
+      break;
+   }
+
+   stvis->accum_format = (mode->haveAccumBuffer) ?
+      PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE;
+
+   stvis->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK;
+   if (mode->doubleBufferMode)
+      stvis->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
+   if (mode->stereoMode) {
+      stvis->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK;
+      if (mode->doubleBufferMode)
+         stvis->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
+   }
+
+   if (mode->haveDepthBuffer || mode->haveStencilBuffer)
+      stvis->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK;
+   /* let the state tracker allocate the accum buffer */
+}
+
+#ifndef __NOT_HAVE_DRM_H
+
+/**
+ * Get information about previous buffer swaps.
+ */
+static int
+dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo)
+{
+   if (dPriv == NULL || dPriv->driverPrivate == NULL || sInfo == NULL)
+      return -1;
+   else
+      return 0;
+}
+
+#endif
+
+static void
+dri_destroy_option_cache(struct dri_screen * screen)
+{
+   int i;
+
+   for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) {
+      FREE(screen->optionCache.info[i].name);
+      FREE(screen->optionCache.info[i].ranges);
+   }
+
+   FREE(screen->optionCache.info);
+   FREE(screen->optionCache.values);
+}
+
+void
+dri_destroy_screen_helper(struct dri_screen * screen)
+{
+   dri1_destroy_pipe_context(screen);
+
+   if (screen->smapi)
+      dri_destroy_st_manager(screen->smapi);
+
+   if (screen->pipe_screen)
+      screen->pipe_screen->destroy(screen->pipe_screen);
+
+   dri_destroy_option_cache(screen);
+}
+
+static void
+dri_destroy_screen(__DRIscreen * sPriv)
+{
+   struct dri_screen *screen = dri_screen(sPriv);
+
+   dri_destroy_screen_helper(screen);
+
+   FREE(screen);
+   sPriv->private = NULL;
+   sPriv->extensions = NULL;
+}
+
+const __DRIconfig **
+dri_init_screen_helper(struct dri_screen *screen,
+                       struct drm_create_screen_arg *arg,
+                       unsigned pixel_bits)
+{
+   screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, arg);
+   if (!screen->pipe_screen) {
+      debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
+      return NULL;
+   }
+
+   screen->smapi = dri_create_st_manager(screen);
+   if (!screen->smapi)
+      return NULL;
+
+   driParseOptionInfo(&screen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
+
+   return dri_fill_in_modes(screen, pixel_bits);
+}
+
+/**
+ * DRI driver virtual function table.
+ *
+ * DRI versions differ in their implementation of init_screen and swap_buffers.
+ */
+const struct __DriverAPIRec driDriverAPI = {
+   .DestroyScreen = dri_destroy_screen,
+   .CreateContext = dri_create_context,
+   .DestroyContext = dri_destroy_context,
+   .CreateBuffer = dri_create_buffer,
+   .DestroyBuffer = dri_destroy_buffer,
+   .MakeCurrent = dri_make_current,
+   .UnbindContext = dri_unbind_context,
+
+#ifndef __NOT_HAVE_DRM_H
+
+   .GetSwapInfo = dri_get_swap_info,
+   .GetDrawableMSC = driDrawableGetMSC32,
+   .WaitForMSC = driWaitForMSC32,
+   .InitScreen2 = dri2_init_screen,
+
+   .InitScreen = dri1_init_screen,
+   .SwapBuffers = dri1_swap_buffers,
+   .CopySubBuffer = dri1_copy_sub_buffer,
+
+#else
+
+   .InitScreen = drisw_init_screen,
+   .SwapBuffers = drisw_swap_buffers,
+
+#endif
+
+};
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h
new file mode 100644 (file)
index 0000000..e77bce1
--- /dev/null
@@ -0,0 +1,115 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL 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.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#ifndef DRI_SCREEN_H
+#define DRI_SCREEN_H
+
+#include "dri_wrapper.h"
+#include "xmlconfig.h"
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+#include "state_tracker/st_api.h"
+#include "state_tracker/drm_api.h"
+
+struct dri_screen
+{
+   /* dri */
+   __DRIscreen *sPriv;
+
+   /**
+    * Configuration cache with default values for all contexts
+    */
+   driOptionCache optionCache;
+
+   /* drm */
+   int fd;
+   drmLock *drmLock;
+
+   /* gallium */
+   struct drm_api *api;
+   struct pipe_winsys *pipe_winsys;
+   struct pipe_screen *pipe_screen;
+   boolean d_depth_bits_last;
+   boolean sd_depth_bits_last;
+   boolean auto_fake_front;
+
+   struct st_manager *smapi;
+
+   /* used only by DRI1 */
+   struct pipe_context *dri1_pipe;
+};
+
+/** cast wrapper */
+static INLINE struct dri_screen *
+dri_screen(__DRIscreen * sPriv)
+{
+   return (struct dri_screen *)sPriv->private;
+}
+
+#ifndef __NOT_HAVE_DRM_H
+
+static INLINE boolean
+dri_with_format(__DRIscreen * sPriv)
+{
+   const __DRIdri2LoaderExtension *loader = sPriv->dri2.loader;
+
+   return loader
+       && (loader->base.version >= 3)
+       && (loader->getBuffersWithFormat != NULL);
+}
+
+#else
+
+static INLINE boolean
+dri_with_format(__DRIscreen * sPriv)
+{
+   return TRUE;
+}
+
+#endif
+
+void
+dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
+                   const __GLcontextModes *mode);
+
+const __DRIconfig **
+dri_init_screen_helper(struct dri_screen *screen,
+                       struct drm_create_screen_arg *arg,
+                       unsigned pixel_bits);
+
+void
+dri_destroy_screen_helper(struct dri_screen * screen);
+
+#endif
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c
new file mode 100644 (file)
index 0000000..7ba7ec3
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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_memory.h"
+#include "util/u_inlines.h"
+#include "util/u_format.h"
+#include "util/u_debug.h"
+#include "state_tracker/st_manager.h" /* for st_manager_create_api */
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+#include "dri_st_api.h"
+#include "dri1_helper.h"
+#ifndef __NOT_HAVE_DRM_H
+#include "dri1.h"
+#include "dri2.h"
+#else
+#include "drisw.h"
+#endif
+
+static boolean
+dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
+                            const enum st_attachment_type *statts,
+                            unsigned count,
+                            struct pipe_texture **out)
+{
+   struct dri_drawable *drawable =
+      (struct dri_drawable *) stfbi->st_manager_private;
+   unsigned statt_mask, new_mask;
+   boolean new_stamp;
+   int i;
+
+   statt_mask = 0x0;
+   for (i = 0; i < count; i++)
+      statt_mask |= (1 << statts[i]);
+
+   /* record newly allocated textures */
+   new_mask = (statt_mask & ~drawable->texture_mask);
+
+   /*
+    * dPriv->pStamp is the server stamp.  It should be accessed with a lock, at
+    * least for DRI1.  dPriv->lastStamp is the client stamp.  It has the value
+    * of the server stamp when last checked.
+    */
+   new_stamp = (drawable->texture_stamp != drawable->dPriv->lastStamp);
+
+   if (new_stamp || new_mask) {
+
+#ifndef __NOT_HAVE_DRM_H
+      if (__dri1_api_hooks) {
+         dri1_allocate_textures(drawable, statt_mask);
+      }
+      else {
+         dri2_allocate_textures(drawable, statts, count);
+      }
+#else
+      if (new_stamp)
+         drisw_update_drawable_info(drawable);
+
+      drisw_allocate_textures(drawable, statt_mask);
+#endif
+
+      /* add existing textures */
+      for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+         if (drawable->textures[i])
+            statt_mask |= (1 << i);
+      }
+
+      drawable->texture_stamp = drawable->dPriv->lastStamp;
+      drawable->texture_mask = statt_mask;
+   }
+
+   if (!out)
+      return TRUE;
+
+   for (i = 0; i < count; i++) {
+      out[i] = NULL;
+      pipe_texture_reference(&out[i], drawable->textures[statts[i]]);
+   }
+
+   return TRUE;
+}
+
+static boolean
+dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
+                               enum st_attachment_type statt)
+{
+   struct dri_drawable *drawable =
+      (struct dri_drawable *) stfbi->st_manager_private;
+
+#ifndef __NOT_HAVE_DRM_H
+   if (__dri1_api_hooks) {
+      dri1_flush_frontbuffer(drawable, statt);
+   }
+   else {
+      dri2_flush_frontbuffer(drawable, statt);
+   }
+#else
+   drisw_flush_frontbuffer(drawable, statt);
+#endif
+
+   return TRUE;
+}
+
+/**
+ * Create a framebuffer from the given drawable.
+ */
+struct st_framebuffer_iface *
+dri_create_st_framebuffer(struct dri_drawable *drawable)
+{
+   struct st_framebuffer_iface *stfbi;
+
+   stfbi = CALLOC_STRUCT(st_framebuffer_iface);
+   if (stfbi) {
+      stfbi->visual = &drawable->stvis;
+      stfbi->flush_front = dri_st_framebuffer_flush_front;
+      stfbi->validate = dri_st_framebuffer_validate;
+      stfbi->st_manager_private = (void *) drawable;
+   }
+
+   return stfbi;
+}
+
+/**
+ * Destroy a framebuffer.
+ */
+void
+dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
+{
+   struct dri_drawable *drawable =
+      (struct dri_drawable *) stfbi->st_manager_private;
+   int i;
+
+   for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+      pipe_texture_reference(&drawable->textures[i], NULL);
+
+   FREE(stfbi);
+}
+
+/**
+ * Validate the texture at an attachment.  Allocate the texture if it does not
+ * exist.
+ */
+void
+dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi,
+                                enum st_attachment_type statt)
+{
+   struct dri_drawable *drawable =
+      (struct dri_drawable *) stfbi->st_manager_private;
+   enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
+   unsigned i, count = 0;
+
+   /* check if buffer already exists */
+   if (drawable->texture_mask & (1 << statt))
+      return;
+
+   /* make sure DRI2 does not destroy existing buffers */
+   for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+      if (drawable->texture_mask & (1 << i)) {
+         statts[count++] = i;
+      }
+   }
+   statts[count++] = statt;
+
+   drawable->texture_stamp = drawable->dPriv->lastStamp - 1;
+
+   stfbi->validate(stfbi, statts, count, NULL);
+}
+
+/**
+ * Reference counted st_api.
+ */
+static struct {
+   int32_t refcnt;
+   struct st_api *stapi;
+} dri_st_api;
+
+/**
+ * Add a reference to the st_api of the state tracker.
+ */
+static void
+_dri_get_st_api(void)
+{
+   p_atomic_inc(&dri_st_api.refcnt);
+   if (p_atomic_read(&dri_st_api.refcnt) == 1)
+      dri_st_api.stapi = st_manager_create_api();
+}
+
+/**
+ * Remove a reference to the st_api of the state tracker.
+ */
+static void
+_dri_put_st_api(void)
+{
+   struct st_api *stapi = dri_st_api.stapi;
+
+   if (p_atomic_dec_zero(&dri_st_api.refcnt)) {
+      stapi->destroy(dri_st_api.stapi);
+      dri_st_api.stapi = NULL;
+   }
+}
+
+/**
+ * Create a state tracker manager from the given screen.
+ */
+struct st_manager *
+dri_create_st_manager(struct dri_screen *screen)
+{
+   struct st_manager *smapi;
+
+   smapi = CALLOC_STRUCT(st_manager);
+   if (smapi) {
+      smapi->screen = screen->pipe_screen;
+      _dri_get_st_api();
+   }
+
+   return smapi;
+}
+
+/**
+ * Destroy a state tracker manager.
+ */
+void
+dri_destroy_st_manager(struct st_manager *smapi)
+{
+   _dri_put_st_api();
+   FREE(smapi);
+}
+
+/**
+ * Return the st_api of OpenGL state tracker.
+ */
+struct st_api *
+dri_get_st_api(void)
+{
+   assert(dri_st_api.stapi);
+   return dri_st_api.stapi;
+}
diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.h b/src/gallium/state_trackers/dri/common/dri_st_api.h
new file mode 100644 (file)
index 0000000..99a217b
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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>
+ */
+
+#ifndef _DRI_ST_API_H_
+#define _DRI_ST_API_H_
+
+#include "state_tracker/st_api.h"
+
+struct dri_screen;
+struct dri_drawable;
+
+struct st_api *
+dri_get_st_api(void);
+
+struct st_manager *
+dri_create_st_manager(struct dri_screen *screen);
+
+void
+dri_destroy_st_manager(struct st_manager *smapi);
+
+struct st_framebuffer_iface *
+dri_create_st_framebuffer(struct dri_drawable *drawable);
+
+void
+dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi);
+
+void
+dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi,
+                                enum st_attachment_type statt);
+
+#endif /* _DRI_ST_API_H_ */
diff --git a/src/gallium/state_trackers/dri/common/dri_wrapper.h b/src/gallium/state_trackers/dri/common/dri_wrapper.h
new file mode 100644 (file)
index 0000000..141ba02
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef DRI_WRAPPER_H
+#define DRI_WRAPPER_H
+
+#ifndef __NOT_HAVE_DRM_H
+#include "dri_util.h"
+#else
+#include "drisw_util.h"
+#endif
+
+#endif
diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
deleted file mode 100644 (file)
index 2f991c3..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Author: Keith Whitwell <keithw@vmware.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- */
-
-#include "dri_screen.h"
-
-#include "dri_drawable.h"
-#include "state_tracker/drm_api.h"
-#include "state_tracker/dri1_api.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "pipe/p_context.h"
-
-#include "dri_context.h"
-
-#include "util/u_memory.h"
-
-GLboolean
-dri_create_context(const __GLcontextModes * visual,
-                  __DRIcontext * cPriv, void *sharedContextPrivate)
-{
-   __DRIscreen *sPriv = cPriv->driScreenPriv;
-   struct dri_screen *screen = dri_screen(sPriv);
-   struct dri_context *ctx = NULL;
-   struct st_context *st_share = NULL;
-
-   if (sharedContextPrivate) {
-      st_share = ((struct dri_context *)sharedContextPrivate)->st;
-   }
-
-   ctx = CALLOC_STRUCT(dri_context);
-   if (ctx == NULL)
-      goto fail;
-
-   cPriv->driverPrivate = ctx;
-   ctx->cPriv = cPriv;
-   ctx->sPriv = sPriv;
-   ctx->lock = screen->drmLock;
-   ctx->d_stamp = -1;
-   ctx->r_stamp = -1;
-
-   driParseConfigFiles(&ctx->optionCache,
-                      &screen->optionCache, sPriv->myNum, "dri");
-
-   ctx->pipe = screen->pipe_screen->context_create( screen->pipe_screen,
-                                                   ctx );
-
-   if (ctx->pipe == NULL)
-      goto fail;
-
-   ctx->st = st_create_context(ctx->pipe, visual, st_share);
-   if (ctx->st == NULL)
-      goto fail;
-
-   dri_init_extensions(ctx);
-
-   return GL_TRUE;
-
- fail:
-   if (ctx && ctx->st)
-      st_destroy_context(ctx->st);
-
-   if (ctx && ctx->pipe)
-      ctx->pipe->destroy(ctx->pipe);
-
-   FREE(ctx);
-   return FALSE;
-}
-
-void
-dri_destroy_context(__DRIcontext * cPriv)
-{
-   struct dri_context *ctx = dri_context(cPriv);
-
-   /* note: we are freeing values and nothing more because
-    * driParseConfigFiles allocated values only - the rest
-    * is owned by screen optionCache.
-    */
-   FREE(ctx->optionCache.values);
-
-   /* No particular reason to wait for command completion before
-    * destroying a context, but it is probably worthwhile flushing it
-    * to avoid having to add code elsewhere to cope with flushing a
-    * partially destroyed context.
-    */
-   st_flush(ctx->st, 0, NULL);
-
-   /* Also frees ctx->pipe?
-    */
-   st_destroy_context(ctx->st);
-
-   FREE(ctx);
-}
-
-GLboolean
-dri_unbind_context(__DRIcontext * cPriv)
-{
-   if (cPriv) {
-      struct dri_context *ctx = dri_context(cPriv);
-
-      if (--ctx->bind_count == 0) {
-        if (ctx->st && ctx->st == st_get_current()) {
-           st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-           st_make_current(NULL, NULL, NULL, NULL);
-        }
-      }
-   }
-
-   return GL_TRUE;
-}
-
-GLboolean
-dri_make_current(__DRIcontext * cPriv,
-                __DRIdrawable * driDrawPriv,
-                __DRIdrawable * driReadPriv)
-{
-   if (cPriv) {
-      struct dri_context *ctx = dri_context(cPriv);
-      struct dri_drawable *draw = dri_drawable(driDrawPriv);
-      struct dri_drawable *read = dri_drawable(driReadPriv);
-      struct st_context *old_st = st_get_current();
-
-      if (old_st && old_st != ctx->st)
-        st_flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
-
-      ++ctx->bind_count;
-
-      if (ctx->dPriv != driDrawPriv) {
-        ctx->dPriv = driDrawPriv;
-        ctx->d_stamp = driDrawPriv->lastStamp - 1;
-      }
-      if (ctx->rPriv != driReadPriv) {
-        ctx->rPriv = driReadPriv;
-        ctx->r_stamp = driReadPriv->lastStamp - 1;
-      }
-
-      /* DRI co-state tracker currently overrides flush_frontbuffer.
-       * When this is fixed, will need to pass the drawable in the
-       * fourth parameter here so that when Mesa calls
-       * flush_frontbuffer directly (in front-buffer rendering), it
-       * will have access to the drawable argument:
-       */
-      st_make_current(ctx->st, draw->stfb, read->stfb, NULL);
-
-      if (__dri1_api_hooks) {
-        dri1_update_drawables(ctx, draw, read);
-      } else {
-        dri_update_buffer(ctx->pipe->screen,
-                          ctx->pipe->priv);
-      }
-   } else {
-      st_make_current(NULL, NULL, NULL, NULL);
-   }
-
-   return GL_TRUE;
-}
-
-static void
-st_dri_lock(struct pipe_context *pipe)
-{
-   dri_lock((struct dri_context *)pipe->priv);
-}
-
-static void
-st_dri_unlock(struct pipe_context *pipe)
-{
-   dri_unlock((struct dri_context *)pipe->priv);
-}
-
-static boolean
-st_dri_is_locked(struct pipe_context *pipe)
-{
-   return ((struct dri_context *)pipe->priv)->isLocked;
-}
-
-static boolean
-st_dri_lost_lock(struct pipe_context *pipe)
-{
-   return ((struct dri_context *)pipe->priv)->wsLostLock;
-}
-
-static void
-st_dri_clear_lost_lock(struct pipe_context *pipe)
-{
-   ((struct dri_context *)pipe->priv)->wsLostLock = FALSE;
-}
-
-struct dri1_api_lock_funcs dri1_lf = {
-   .lock = st_dri_lock,
-   .unlock = st_dri_unlock,
-   .is_locked = st_dri_is_locked,
-   .is_lock_lost = st_dri_lost_lock,
-   .clear_lost_lock = st_dri_clear_lost_lock
-};
-
-/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h
deleted file mode 100644 (file)
index 13f4974..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/**************************************************************************
- *
- * Copyright (C) 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
- *
- **************************************************************************/
-/*
- * Author: Keith Whitwell <keithw@vmware.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- */
-
-#ifndef DRI_CONTEXT_H
-#define DRI_CONTEXT_H
-
-#include "pipe/p_compiler.h"
-#include "drm.h"
-#include "dri_util.h"
-
-struct pipe_context;
-struct pipe_fence;
-struct st_context;
-struct dri_drawable;
-
-struct dri_context
-{
-   /* dri */
-   __DRIscreen *sPriv;
-   __DRIcontext *cPriv;
-   __DRIdrawable *dPriv;
-   __DRIdrawable *rPriv;
-
-   driOptionCache optionCache;
-
-   unsigned int d_stamp;
-   unsigned int r_stamp;
-
-   drmLock *lock;
-   boolean isLocked;
-   boolean stLostLock;
-   boolean wsLostLock;
-
-   unsigned int bind_count;
-
-   /* gallium */
-   struct st_context *st;
-   struct pipe_context *pipe;
-};
-
-static INLINE struct dri_context *
-dri_context(__DRIcontext * driContextPriv)
-{
-   return (struct dri_context *)driContextPriv->driverPrivate;
-}
-
-static INLINE void
-dri_lock(struct dri_context *ctx)
-{
-   drm_context_t hw_context = ctx->cPriv->hHWContext;
-   char ret = 0;
-
-   DRM_CAS(ctx->lock, hw_context, DRM_LOCK_HELD | hw_context, ret);
-   if (ret) {
-      drmGetLock(ctx->sPriv->fd, hw_context, 0);
-      ctx->stLostLock = TRUE;
-      ctx->wsLostLock = TRUE;
-   }
-   ctx->isLocked = TRUE;
-}
-
-static INLINE void
-dri_unlock(struct dri_context *ctx)
-{
-   ctx->isLocked = FALSE;
-   DRM_UNLOCK(ctx->sPriv->fd, ctx->lock, ctx->cPriv->hHWContext);
-}
-
-/***********************************************************************
- * dri_context.c
- */
-extern struct dri1_api_lock_funcs dri1_lf;
-
-void dri_destroy_context(__DRIcontext * driContextPriv);
-
-boolean dri_unbind_context(__DRIcontext * driContextPriv);
-
-boolean
-dri_make_current(__DRIcontext * driContextPriv,
-                __DRIdrawable * driDrawPriv,
-                __DRIdrawable * driReadPriv);
-
-boolean
-dri_create_context(const __GLcontextModes * visual,
-                  __DRIcontext * driContextPriv,
-                  void *sharedContextPrivate);
-
-/***********************************************************************
- * dri_extensions.c
- */
-void dri_init_extensions(struct dri_context *ctx);
-
-#endif
-
-/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
deleted file mode 100644 (file)
index 4584738..0000000
+++ /dev/null
@@ -1,765 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Author: Keith Whitwell <keithw@vmware.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- */
-
-#include "dri_screen.h"
-#include "dri_context.h"
-#include "dri_drawable.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_screen.h"
-#include "main/mtypes.h"
-#include "main/renderbuffer.h"
-#include "state_tracker/drm_api.h"
-#include "state_tracker/dri1_api.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_cb_fbo.h"
-
-#include "util/u_format.h"
-#include "util/u_memory.h"
-#include "util/u_rect.h"
-#include "util/u_inlines.h"
-static struct pipe_surface *
-dri_surface_from_handle(struct drm_api *api,
-                       struct pipe_screen *screen,
-                       unsigned handle,
-                       enum pipe_format format,
-                       unsigned width, unsigned height, unsigned pitch)
-{
-   struct pipe_surface *surface = NULL;
-   struct pipe_texture *texture = NULL;
-   struct pipe_texture templat;
-   struct winsys_handle whandle;
-
-   memset(&templat, 0, sizeof(templat));
-   templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
-   templat.target = PIPE_TEXTURE_2D;
-   templat.last_level = 0;
-   templat.depth0 = 1;
-   templat.format = format;
-   templat.width0 = width;
-   templat.height0 = height;
-
-   memset(&whandle, 0, sizeof(whandle));
-   whandle.handle = handle;
-   whandle.stride = pitch;
-
-   texture = screen->texture_from_handle(screen, &templat, &whandle);
-
-   if (!texture) {
-      debug_printf("%s: Failed to blanket the buffer with a texture\n", __func__);
-      return NULL;
-   }
-
-   surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
-                                    PIPE_BUFFER_USAGE_GPU_READ |
-                                    PIPE_BUFFER_USAGE_GPU_WRITE);
-
-   /* we don't need the texture from this point on */
-   pipe_texture_reference(&texture, NULL);
-   return surface;
-}
-
-/**
- * Pixmaps have will have the same name of fake front and front.
- */
-static boolean
-dri2_check_if_pixmap(__DRIbuffer *buffers, int count)
-{
-   boolean found = FALSE;
-   boolean is_pixmap = FALSE;
-   unsigned name;
-   int i;
-
-   for (i = 0; i < count; i++) {
-      switch (buffers[i].attachment) {
-      case __DRI_BUFFER_FRONT_LEFT:
-      case __DRI_BUFFER_FAKE_FRONT_LEFT:
-         if (found) {
-            is_pixmap = buffers[i].name == name;
-         } else {
-            name = buffers[i].name;
-            found = TRUE;
-         }
-      default:
-        continue;
-      }
-   }
-
-   return is_pixmap;
-}
-
-/**
- * This will be called a drawable is known to have been resized.
- */
-void
-dri_get_buffers(__DRIdrawable * dPriv)
-{
-
-   struct dri_drawable *drawable = dri_drawable(dPriv);
-   struct pipe_surface *surface = NULL;
-   struct dri_screen *st_screen = dri_screen(drawable->sPriv);
-   struct pipe_screen *screen = st_screen->pipe_screen;
-   __DRIbuffer *buffers = NULL;
-   __DRIscreen *dri_screen = drawable->sPriv;
-   __DRIdrawable *dri_drawable = drawable->dPriv;
-   struct drm_api *api = st_screen->api;
-   boolean have_depth = FALSE;
-   int i, count;
-
-   if ((dri_screen->dri2.loader
-        && (dri_screen->dri2.loader->base.version > 2)
-        && (dri_screen->dri2.loader->getBuffersWithFormat != NULL))) {
-      buffers = (*dri_screen->dri2.loader->getBuffersWithFormat)
-                (dri_drawable, &dri_drawable->w, &dri_drawable->h,
-                 drawable->attachments, drawable->num_attachments,
-                 &count, dri_drawable->loaderPrivate);
-   } else {
-      assert(dri_screen->dri2.loader);
-      buffers = (*dri_screen->dri2.loader->getBuffers) (dri_drawable,
-                                                        &dri_drawable->w,
-                                                        &dri_drawable->h,
-                                                        drawable->attachments,
-                                                        drawable->
-                                                        num_attachments, &count,
-                                                        dri_drawable->
-                                                        loaderPrivate);
-   }
-
-   if (buffers == NULL) {
-      return;
-   }
-
-   /* set one cliprect to cover the whole dri_drawable */
-   dri_drawable->x = 0;
-   dri_drawable->y = 0;
-   dri_drawable->backX = 0;
-   dri_drawable->backY = 0;
-   dri_drawable->numClipRects = 1;
-   dri_drawable->pClipRects[0].x1 = 0;
-   dri_drawable->pClipRects[0].y1 = 0;
-   dri_drawable->pClipRects[0].x2 = dri_drawable->w;
-   dri_drawable->pClipRects[0].y2 = dri_drawable->h;
-   dri_drawable->numBackClipRects = 1;
-   dri_drawable->pBackClipRects[0].x1 = 0;
-   dri_drawable->pBackClipRects[0].y1 = 0;
-   dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
-   dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
-
-   if (drawable->old_num == count &&
-       drawable->old_w == dri_drawable->w &&
-       drawable->old_h == dri_drawable->h &&
-       memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) {
-       return;
-   } else {
-      drawable->old_num = count;
-      drawable->old_w = dri_drawable->w;
-      drawable->old_h = dri_drawable->h;
-      memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count);
-   }
-
-   drawable->is_pixmap = dri2_check_if_pixmap(buffers, count);
-
-   for (i = 0; i < count; i++) {
-      enum pipe_format format = 0;
-      int index = 0;
-
-      switch (buffers[i].attachment) {
-      case __DRI_BUFFER_FRONT_LEFT:
-        if (!st_screen->auto_fake_front)
-           continue;
-        /* fallthrough */
-      case __DRI_BUFFER_FAKE_FRONT_LEFT:
-        index = ST_SURFACE_FRONT_LEFT;
-        format = drawable->color_format;
-        break;
-      case __DRI_BUFFER_BACK_LEFT:
-        index = ST_SURFACE_BACK_LEFT;
-        format = drawable->color_format;
-        break;
-      case __DRI_BUFFER_DEPTH:
-      case __DRI_BUFFER_DEPTH_STENCIL:
-      case __DRI_BUFFER_STENCIL:
-        index = ST_SURFACE_DEPTH;
-        format = drawable->depth_stencil_format;
-        break;
-      case __DRI_BUFFER_ACCUM:
-      default:
-        assert(0);
-      }
-
-      if (index == ST_SURFACE_DEPTH) {
-        if (have_depth)
-           continue;
-        else
-           have_depth = TRUE;
-      }
-
-      surface = dri_surface_from_handle(api,
-                                       screen,
-                                       buffers[i].name,
-                                       format,
-                                       dri_drawable->w,
-                                       dri_drawable->h, buffers[i].pitch);
-
-      switch (buffers[i].attachment) {
-      case __DRI_BUFFER_FRONT_LEFT:
-      case __DRI_BUFFER_FAKE_FRONT_LEFT:
-      case __DRI_BUFFER_BACK_LEFT:
-        drawable->color_format = surface->format;
-        break;
-      case __DRI_BUFFER_DEPTH:
-      case __DRI_BUFFER_DEPTH_STENCIL:
-      case __DRI_BUFFER_STENCIL:
-        drawable->depth_stencil_format = surface->format;
-        break;
-      case __DRI_BUFFER_ACCUM:
-      default:
-        assert(0);
-      }
-
-      st_set_framebuffer_surface(drawable->stfb, index, surface);
-      pipe_surface_reference(&surface, NULL);
-   }
-   /* this needed, or else the state tracker fails to pick the new buffers */
-   st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h);
-}
-
-/**
- * These are used for GLX_EXT_texture_from_pixmap
- */
-void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
-                          GLint format, __DRIdrawable *dPriv)
-{
-   struct dri_drawable *drawable = dri_drawable(dPriv);
-   struct pipe_surface *ps;
-
-   if (!drawable->stfb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
-      struct gl_renderbuffer *rb =
-         st_new_renderbuffer_fb(drawable->color_format, 0 /*XXX*/, FALSE);
-      _mesa_add_renderbuffer(&drawable->stfb->Base, BUFFER_FRONT_LEFT, rb);
-   }
-
-   dri_get_buffers(drawable->dPriv);
-   st_get_framebuffer_surface(drawable->stfb, ST_SURFACE_FRONT_LEFT, &ps);
-
-   if (!ps)
-      return;
-
-   st_bind_texture_surface(ps, target == GL_TEXTURE_2D ? ST_TEXTURE_2D :
-                           ST_TEXTURE_RECT, 0, drawable->color_format);
-}
-
-void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
-                         __DRIdrawable *dPriv)
-{
-   dri2_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
-}
-
-void
-dri_update_buffer(struct pipe_screen *screen, void *context_private)
-{
-   struct dri_context *ctx = (struct dri_context *)context_private;
-
-   if (ctx->d_stamp == *ctx->dPriv->pStamp &&
-       ctx->r_stamp == *ctx->rPriv->pStamp)
-      return;
-
-   ctx->d_stamp = *ctx->dPriv->pStamp;
-   ctx->r_stamp = *ctx->rPriv->pStamp;
-
-   /* Ask the X server for new renderbuffers. */
-   dri_get_buffers(ctx->dPriv);
-   if (ctx->dPriv != ctx->rPriv)
-      dri_get_buffers(ctx->rPriv);
-
-}
-
-void
-dri_flush_frontbuffer(struct pipe_screen *screen,
-                     struct pipe_surface *surf, void *context_private)
-{
-   struct dri_context *ctx = (struct dri_context *)context_private;
-   struct dri_drawable *drawable = dri_drawable(ctx->dPriv);
-   __DRIdrawable *dri_drawable = ctx->dPriv;
-   __DRIscreen *dri_screen = ctx->sPriv;
-
-   /* XXX Does this function get called with DRI1? */
-
-   if (ctx->dPriv == NULL) {
-      debug_printf("%s: no drawable bound to context\n", __func__);
-      return;
-   }
-
-#if 0
-   /* TODO if rendering to pixmaps is slow enable this code. */
-   if (drawable->is_pixmap)
-      return;
-#else
-   (void)drawable;
-#endif
-
-   (*dri_screen->dri2.loader->flushFrontBuffer)(dri_drawable,
-                                               dri_drawable->loaderPrivate);
-}
-
-/**
- * This is called when we need to set up GL rendering to a new X window.
- */
-boolean
-dri_create_buffer(__DRIscreen * sPriv,
-                 __DRIdrawable * dPriv,
-                 const __GLcontextModes * visual, boolean isPixmap)
-{
-   struct dri_screen *screen = sPriv->private;
-   struct dri_drawable *drawable = NULL;
-   int i;
-
-   if (isPixmap)
-      goto fail;                      /* not implemented */
-
-   drawable = CALLOC_STRUCT(dri_drawable);
-   if (drawable == NULL)
-      goto fail;
-
-   if (visual->redBits == 8) {
-      if (visual->alphaBits == 8)
-         drawable->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
-      else
-         drawable->color_format = PIPE_FORMAT_B8G8R8X8_UNORM;
-   } else {
-      drawable->color_format = PIPE_FORMAT_B5G6R5_UNORM;
-   }
-
-   switch(visual->depthBits) {
-   default:
-   case 0:
-      drawable->depth_stencil_format = PIPE_FORMAT_NONE;
-      break;
-   case 16:
-      drawable->depth_stencil_format = PIPE_FORMAT_Z16_UNORM;
-      break;
-   case 24:
-      if (visual->stencilBits == 0) {
-        drawable->depth_stencil_format = (screen->d_depth_bits_last) ?
-                                          PIPE_FORMAT_Z24X8_UNORM:
-                                          PIPE_FORMAT_X8Z24_UNORM;
-      } else {
-        drawable->depth_stencil_format = (screen->sd_depth_bits_last) ?
-                                          PIPE_FORMAT_Z24S8_UNORM:
-                                          PIPE_FORMAT_S8Z24_UNORM;
-      }
-      break;
-   case 32:
-      drawable->depth_stencil_format = PIPE_FORMAT_Z32_UNORM;
-      break;
-   }
-
-   drawable->stfb = st_create_framebuffer(visual,
-                                         drawable->color_format,
-                                         drawable->depth_stencil_format,
-                                         drawable->depth_stencil_format,
-                                         dPriv->w,
-                                         dPriv->h, (void *)drawable);
-   if (drawable->stfb == NULL)
-      goto fail;
-
-   drawable->sPriv = sPriv;
-   drawable->dPriv = dPriv;
-   dPriv->driverPrivate = (void *)drawable;
-
-   /* setup dri2 buffers information */
-   /* TODO incase of double buffer visual, delay fake creation */
-   i = 0;
-   if (sPriv->dri2.loader
-       && (sPriv->dri2.loader->base.version > 2)
-       && (sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
-      drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-      drawable->attachments[i++] = visual->rgbBits;
-      if (!screen->auto_fake_front)  {
-         drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
-         drawable->attachments[i++] = visual->rgbBits;
-      }
-      if (visual->doubleBufferMode) {
-         drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-         drawable->attachments[i++] = visual->rgbBits;
-      }
-      if (visual->depthBits && visual->stencilBits) {
-         drawable->attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
-         drawable->attachments[i++] = visual->depthBits + visual->stencilBits;
-      } else if (visual->depthBits) {
-         drawable->attachments[i++] = __DRI_BUFFER_DEPTH;
-         drawable->attachments[i++] = visual->depthBits;
-      } else if (visual->stencilBits) {
-         drawable->attachments[i++] = __DRI_BUFFER_STENCIL;
-         drawable->attachments[i++] = visual->stencilBits;
-      }
-      drawable->num_attachments = i / 2;
-   } else {
-      drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-      if (!screen->auto_fake_front)
-         drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
-      if (visual->doubleBufferMode)
-         drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-      if (visual->depthBits && visual->stencilBits)
-         drawable->attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
-      else if (visual->depthBits)
-         drawable->attachments[i++] = __DRI_BUFFER_DEPTH;
-      else if (visual->stencilBits)
-         drawable->attachments[i++] = __DRI_BUFFER_STENCIL;
-      drawable->num_attachments = i;
-   }
-
-   drawable->desired_fences = 2;
-
-   return GL_TRUE;
-fail:
-   FREE(drawable);
-   return GL_FALSE;
-}
-
-static struct pipe_fence_handle *
-dri_swap_fences_pop_front(struct dri_drawable *draw)
-{
-   struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
-   struct pipe_fence_handle *fence = NULL;
-
-   if (draw->cur_fences >= draw->desired_fences) {
-      screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]);
-      screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
-      --draw->cur_fences;
-      draw->tail &= DRI_SWAP_FENCES_MASK;
-   }
-   return fence;
-}
-
-static void
-dri_swap_fences_push_back(struct dri_drawable *draw,
-                         struct pipe_fence_handle *fence)
-{
-   struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
-
-   if (!fence)
-      return;
-
-   if (draw->cur_fences < DRI_SWAP_FENCES_MAX) {
-      draw->cur_fences++;
-      screen->fence_reference(screen, &draw->swap_fences[draw->head++],
-                             fence);
-      draw->head &= DRI_SWAP_FENCES_MASK;
-   }
-}
-
-void
-dri_destroy_buffer(__DRIdrawable * dPriv)
-{
-   struct dri_drawable *drawable = dri_drawable(dPriv);
-   struct pipe_fence_handle *fence;
-   struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
-
-   st_unreference_framebuffer(drawable->stfb);
-   drawable->desired_fences = 0;
-   while (drawable->cur_fences) {
-      fence = dri_swap_fences_pop_front(drawable);
-      screen->fence_reference(screen, &fence, NULL);
-   }
-
-   FREE(drawable);
-}
-
-static void
-dri1_update_drawables_locked(struct dri_context *ctx,
-                            __DRIdrawable * driDrawPriv,
-                            __DRIdrawable * driReadPriv)
-{
-   if (ctx->stLostLock) {
-      ctx->stLostLock = FALSE;
-      if (driDrawPriv == driReadPriv)
-        DRI_VALIDATE_DRAWABLE_INFO(ctx->sPriv, driDrawPriv);
-      else
-        DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv,
-                                        driReadPriv);
-   }
-}
-
-/**
- * This ensures all contexts which bind to a drawable pick up the
- * drawable change and signal new buffer state.
- * Calling st_resize_framebuffer for each context may seem like overkill,
- * but no new buffers will actually be allocated if the dimensions don't
- * change.
- */
-
-static void
-dri1_propagate_drawable_change(struct dri_context *ctx)
-{
-   __DRIdrawable *dPriv = ctx->dPriv;
-   __DRIdrawable *rPriv = ctx->rPriv;
-   boolean flushed = FALSE;
-
-   if (dPriv && ctx->d_stamp != dPriv->lastStamp) {
-
-      st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-      flushed = TRUE;
-      ctx->d_stamp = dPriv->lastStamp;
-      st_resize_framebuffer(dri_drawable(dPriv)->stfb, dPriv->w, dPriv->h);
-
-   }
-
-   if (rPriv && dPriv != rPriv && ctx->r_stamp != rPriv->lastStamp) {
-
-      if (!flushed)
-        st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-      ctx->r_stamp = rPriv->lastStamp;
-      st_resize_framebuffer(dri_drawable(rPriv)->stfb, rPriv->w, rPriv->h);
-
-   } else if (rPriv && dPriv == rPriv) {
-
-      ctx->r_stamp = ctx->d_stamp;
-
-   }
-}
-
-void
-dri1_update_drawables(struct dri_context *ctx,
-                     struct dri_drawable *draw, struct dri_drawable *read)
-{
-   dri_lock(ctx);
-   dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv);
-   dri_unlock(ctx);
-
-   dri1_propagate_drawable_change(ctx);
-}
-
-static INLINE boolean
-dri1_intersect_src_bbox(struct drm_clip_rect *dst,
-                       int dst_x,
-                       int dst_y,
-                       const struct drm_clip_rect *src,
-                       const struct drm_clip_rect *bbox)
-{
-   int xy1;
-   int xy2;
-
-   xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
-      (int)bbox->x1 + dst_x;
-   xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
-      (int)bbox->x2 + dst_x;
-   if (xy1 >= xy2 || xy1 < 0)
-      return FALSE;
-
-   dst->x1 = xy1;
-   dst->x2 = xy2;
-
-   xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
-      (int)bbox->y1 + dst_y;
-   xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
-      (int)bbox->y2 + dst_y;
-   if (xy1 >= xy2 || xy1 < 0)
-      return FALSE;
-
-   dst->y1 = xy1;
-   dst->y2 = xy2;
-   return TRUE;
-}
-
-static void
-dri1_swap_copy(struct dri_context *ctx,
-              struct pipe_surface *dst,
-              struct pipe_surface *src,
-              __DRIdrawable * dPriv, const struct drm_clip_rect *bbox)
-{
-   struct pipe_context *pipe = ctx->pipe;
-   struct drm_clip_rect clip;
-   struct drm_clip_rect *cur;
-   int i;
-
-   cur = dPriv->pClipRects;
-
-   for (i = 0; i < dPriv->numClipRects; ++i) {
-      if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) {
-         if (pipe->surface_copy) {
-            pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
-                               src,
-                               (int)clip.x1 - dPriv->x,
-                               (int)clip.y1 - dPriv->y,
-                               clip.x2 - clip.x1, clip.y2 - clip.y1);
-         } else {
-            util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1,
-                              src,
-                              (int)clip.x1 - dPriv->x,
-                              (int)clip.y1 - dPriv->y,
-                              clip.x2 - clip.x1, clip.y2 - clip.y1);
-         }
-      }
-   }
-}
-
-static void
-dri1_copy_to_front(struct dri_context *ctx,
-                  struct pipe_surface *surf,
-                  __DRIdrawable * dPriv,
-                  const struct drm_clip_rect *sub_box,
-                  struct pipe_fence_handle **fence)
-{
-   struct pipe_context *pipe = ctx->pipe;
-   boolean save_lost_lock;
-   uint cur_w;
-   uint cur_h;
-   struct drm_clip_rect bbox;
-   boolean visible = TRUE;
-
-   *fence = NULL;
-
-   dri_lock(ctx);
-   save_lost_lock = ctx->stLostLock;
-   dri1_update_drawables_locked(ctx, dPriv, dPriv);
-   st_get_framebuffer_dimensions(dri_drawable(dPriv)->stfb, &cur_w, &cur_h);
-
-   bbox.x1 = 0;
-   bbox.x2 = cur_w;
-   bbox.y1 = 0;
-   bbox.y2 = cur_h;
-
-   if (sub_box)
-      visible = dri1_intersect_src_bbox(&bbox, 0, 0, &bbox, sub_box);
-
-   if (visible && __dri1_api_hooks->present_locked) {
-
-      __dri1_api_hooks->present_locked(pipe,
-                                      surf,
-                                      dPriv->pClipRects,
-                                      dPriv->numClipRects,
-                                      dPriv->x, dPriv->y, &bbox, fence);
-
-   } else if (visible && __dri1_api_hooks->front_srf_locked) {
-
-      struct pipe_surface *front = __dri1_api_hooks->front_srf_locked(pipe);
-
-      if (front)
-        dri1_swap_copy(ctx, front, surf, dPriv, &bbox);
-
-      st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence);
-   }
-
-   ctx->stLostLock = save_lost_lock;
-
-   /**
-    * FIXME: Revisit this: Update drawables on copy_sub_buffer ?
-    */
-
-   if (!sub_box)
-      dri1_update_drawables_locked(ctx, ctx->dPriv, ctx->rPriv);
-
-   dri_unlock(ctx);
-   dri1_propagate_drawable_change(ctx);
-}
-
-void
-dri1_flush_frontbuffer(struct pipe_screen *screen,
-                      struct pipe_surface *surf, void *context_private)
-{
-   struct dri_context *ctx = (struct dri_context *)context_private;
-   struct pipe_fence_handle *dummy_fence;
-
-   dri1_copy_to_front(ctx, surf, ctx->dPriv, NULL, &dummy_fence);
-   screen->fence_reference(screen, &dummy_fence, NULL);
-
-   /**
-    * FIXME: Do we need swap throttling here?
-    */
-}
-
-void
-dri_swap_buffers(__DRIdrawable * dPriv)
-{
-   struct dri_context *ctx;
-   struct pipe_surface *back_surf;
-   struct dri_drawable *draw = dri_drawable(dPriv);
-   struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
-   struct pipe_fence_handle *fence;
-   struct st_context *st = st_get_current();
-
-   assert(__dri1_api_hooks != NULL);
-
-   if (!st)
-      return;                         /* For now */
-
-   ctx = (struct dri_context *)st->pipe->priv;
-
-   st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf);
-   if (back_surf) {
-      st_notify_swapbuffers(draw->stfb);
-      st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-      fence = dri_swap_fences_pop_front(draw);
-      if (fence) {
-        (void)screen->fence_finish(screen, fence, 0);
-        screen->fence_reference(screen, &fence, NULL);
-      }
-      dri1_copy_to_front(ctx, back_surf, dPriv, NULL, &fence);
-      dri_swap_fences_push_back(draw, fence);
-      screen->fence_reference(screen, &fence, NULL);
-   }
-}
-
-void
-dri_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h)
-{
-   struct pipe_screen *screen = dri_screen(dPriv->driScreenPriv)->pipe_screen;
-   struct drm_clip_rect sub_bbox;
-   struct dri_context *ctx;
-   struct pipe_surface *back_surf;
-   struct dri_drawable *draw = dri_drawable(dPriv);
-   struct pipe_fence_handle *dummy_fence;
-   struct st_context *st = st_get_current();
-
-   assert(__dri1_api_hooks != NULL);
-
-   if (!st)
-      return;
-
-   ctx = (struct dri_context *)st->pipe->priv;
-
-   sub_bbox.x1 = x;
-   sub_bbox.x2 = x + w;
-   sub_bbox.y1 = y;
-   sub_bbox.y2 = y + h;
-
-   st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf);
-   if (back_surf) {
-      st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-      dri1_copy_to_front(ctx, back_surf, dPriv, &sub_bbox, &dummy_fence);
-      screen->fence_reference(screen, &dummy_fence, NULL);
-   }
-}
-
-/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h
deleted file mode 100644 (file)
index 8bc59cb..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef DRI_DRAWABLE_H
-#define DRI_DRAWABLE_H
-
-#include "pipe/p_compiler.h"
-
-struct pipe_surface;
-struct pipe_fence_handle;
-struct st_framebuffer;
-struct dri_context;
-
-#define DRI_SWAP_FENCES_MAX  8
-#define DRI_SWAP_FENCES_MASK 7
-
-struct dri_drawable
-{
-   /* dri */
-   __DRIdrawable *dPriv;
-   __DRIscreen *sPriv;
-
-   unsigned attachments[8];
-   unsigned num_attachments;
-
-   boolean is_pixmap;
-
-   __DRIbuffer old[8];
-   unsigned old_num;
-   unsigned old_w;
-   unsigned old_h;
-
-   /* gallium */
-   struct st_framebuffer *stfb;
-   struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX];
-   unsigned int head;
-   unsigned int tail;
-   unsigned int desired_fences;
-   unsigned int cur_fences;
-
-   enum pipe_format color_format;
-   enum pipe_format depth_stencil_format;
-};
-
-static INLINE struct dri_drawable *
-dri_drawable(__DRIdrawable * driDrawPriv)
-{
-   return (struct dri_drawable *)driDrawPriv->driverPrivate;
-}
-
-/***********************************************************************
- * dri_drawable.c
- */
-boolean
-dri_create_buffer(__DRIscreen * sPriv,
-                 __DRIdrawable * dPriv,
-                 const __GLcontextModes * visual, boolean isPixmap);
-
-void
-dri_update_buffer(struct pipe_screen *screen, void *context_private);
-
-void
-dri_flush_frontbuffer(struct pipe_screen *screen,
-                     struct pipe_surface *surf, void *context_private);
-
-void dri_swap_buffers(__DRIdrawable * dPriv);
-
-void
-dri_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h);
-
-void dri_get_buffers(__DRIdrawable * dPriv);
-
-void dri_destroy_buffer(__DRIdrawable * dPriv);
-
-void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
-                          GLint glx_texture_format, __DRIdrawable *dPriv);
-
-void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
-                         __DRIdrawable *dPriv);
-
-void
-dri1_update_drawables(struct dri_context *ctx,
-                     struct dri_drawable *draw, struct dri_drawable *read);
-
-void
-dri1_flush_frontbuffer(struct pipe_screen *screen,
-                      struct pipe_surface *surf, void *context_private);
-#endif
-
-/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c
deleted file mode 100644 (file)
index 800677a..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Author: Keith Whitwell <keithw@vmware.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- */
-
-#include "dri_screen.h"
-#include "dri_context.h"
-#include "state_tracker/st_context.h"
-
-#include "utils.h"
-
-void
-dri_init_extensions(struct dri_context *ctx)
-{
-   /* New extensions should be added in mesa/state_tracker/st_extensions.c
-    * and not in this file. */
-   driInitExtensions(ctx->st->ctx, NULL, GL_FALSE);
-}
-
-/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
deleted file mode 100644 (file)
index 7ccad8f..0000000
+++ /dev/null
@@ -1,403 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Author: Keith Whitwell <keithw@vmware.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- */
-
-#include "utils.h"
-#include "vblank.h"
-#include "xmlpool.h"
-
-#include "dri_screen.h"
-#include "dri_context.h"
-#include "dri_drawable.h"
-
-#include "pipe/p_screen.h"
-#include "pipe/p_format.h"
-#include "state_tracker/drm_api.h"
-#include "state_tracker/dri1_api.h"
-
-#include "util/u_debug.h"
-
-PUBLIC const char __driConfigOptions[] =
-   DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
-   DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
-   DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
-   DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
-    /*DRI_CONF_FORCE_S3TC_ENABLE(false) */
-   DRI_CONF_ALLOW_LARGE_TEXTURES(1)
-   DRI_CONF_SECTION_END DRI_CONF_END;
-
-   const uint __driNConfigOptions = 3;
-
-static const __DRItexBufferExtension dri2TexBufferExtension = {
-    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
-   dri2_set_tex_buffer,
-   dri2_set_tex_buffer2,
-};
-
-static void
-dri2_flush_drawable(__DRIdrawable *draw)
-{
-}
-
-static const __DRI2flushExtension dri2FlushExtension = {
-    { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
-    dri2_flush_drawable,
-    dri2InvalidateDrawable,
-};
-
-   static const __DRIextension *dri_screen_extensions[] = {
-      &driReadDrawableExtension,
-      &driCopySubBufferExtension.base,
-      &driSwapControlExtension.base,
-      &driFrameTrackingExtension.base,
-      &driMediaStreamCounterExtension.base,
-      &dri2TexBufferExtension.base,
-      &dri2FlushExtension.base,
-      NULL
-   };
-
-struct dri1_api *__dri1_api_hooks = NULL;
-
-static const __DRIconfig **
-dri_fill_in_modes(struct dri_screen *screen,
-                 unsigned pixel_bits)
-{
-   __DRIconfig **configs = NULL;
-   __DRIconfig **configs_r5g6b5 = NULL;
-   __DRIconfig **configs_a8r8g8b8 = NULL;
-   __DRIconfig **configs_x8r8g8b8 = NULL;
-   unsigned num_modes;
-   uint8_t depth_bits_array[5];
-   uint8_t stencil_bits_array[5];
-   uint8_t msaa_samples_array[2];
-   unsigned depth_buffer_factor;
-   unsigned back_buffer_factor;
-   unsigned msaa_samples_factor;
-   struct pipe_screen *p_screen = screen->pipe_screen;
-   boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8;
-   boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32;
-
-   static const GLenum back_buffer_modes[] = {
-      GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
-   };
-
-   depth_bits_array[0] = 0;
-   stencil_bits_array[0] = 0;
-   depth_buffer_factor = 1;
-
-   pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,
-                                           PIPE_TEXTURE_2D,
-                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
-   pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,
-                                           PIPE_TEXTURE_2D,
-                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
-   pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM,
-                                           PIPE_TEXTURE_2D,
-                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
-   pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM,
-                                           PIPE_TEXTURE_2D,
-                                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
-   pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
-                                              PIPE_TEXTURE_2D,
-                                              PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
-   pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
-                                              PIPE_TEXTURE_2D,
-                                              PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
-   pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
-                                            PIPE_TEXTURE_2D,
-                                            PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
-
-   /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
-   if (screen->sPriv->dri2.loader &&
-       (screen->sPriv->dri2.loader->base.version > 2) &&
-       (screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
-      pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
-                                             PIPE_TEXTURE_2D,
-                                             PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
-      pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
-                                             PIPE_TEXTURE_2D,
-                                             PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
-   } else {
-      pf_z16 = FALSE;
-      pf_z32 = FALSE;
-   }
-
-   if (pf_z16) {
-      depth_bits_array[depth_buffer_factor] = 16;
-      stencil_bits_array[depth_buffer_factor++] = 0;
-   }
-   if (pf_x8z24 || pf_z24x8) {
-      depth_bits_array[depth_buffer_factor] = 24;
-      stencil_bits_array[depth_buffer_factor++] = 0;
-      screen->d_depth_bits_last = pf_x8z24;
-   }
-   if (pf_s8z24 || pf_z24s8) {
-      depth_bits_array[depth_buffer_factor] = 24;
-      stencil_bits_array[depth_buffer_factor++] = 8;
-      screen->sd_depth_bits_last = pf_s8z24;
-   }
-   if (pf_z32) {
-      depth_bits_array[depth_buffer_factor] = 32;
-      stencil_bits_array[depth_buffer_factor++] = 0;
-   }
-
-   msaa_samples_array[0] = 0;
-   msaa_samples_array[1] = 4;
-   back_buffer_factor = 3;
-   msaa_samples_factor = 2;
-
-   num_modes =
-      depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
-
-   if (pf_r5g6b5)
-      configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-                                        depth_bits_array, stencil_bits_array,
-                                        depth_buffer_factor, back_buffer_modes,
-                                        back_buffer_factor,
-                                        msaa_samples_array, msaa_samples_factor,
-                                        GL_TRUE);
-
-   if (pf_a8r8g8b8)
-      configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
-                                          depth_bits_array,
-                                          stencil_bits_array,
-                                          depth_buffer_factor,
-                                          back_buffer_modes,
-                                          back_buffer_factor,
-                                          msaa_samples_array,
-                                          msaa_samples_factor,
-                                          GL_TRUE);
-
-   if (pf_x8r8g8b8)
-      configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
-                                          depth_bits_array,
-                                          stencil_bits_array,
-                                          depth_buffer_factor,
-                                          back_buffer_modes,
-                                          back_buffer_factor,
-                                          msaa_samples_array,
-                                          msaa_samples_factor,
-                                          GL_TRUE);
-
-   if (pixel_bits == 16) {
-      configs = configs_r5g6b5;
-      if (configs_a8r8g8b8)
-         configs = configs ? driConcatConfigs(configs, configs_a8r8g8b8) : configs_a8r8g8b8;
-      if (configs_x8r8g8b8)
-        configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
-   } else {
-      configs = configs_a8r8g8b8;
-      if (configs_x8r8g8b8)
-        configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
-      if (configs_r5g6b5)
-         configs = configs ? driConcatConfigs(configs, configs_r5g6b5) : configs_r5g6b5;
-   }
-
-   if (configs == NULL) {
-      debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__);
-      return NULL;
-   }
-
-   return (const __DRIconfig **)configs;
-}
-
-/**
- * Get information about previous buffer swaps.
- */
-static int
-dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo)
-{
-   if (dPriv == NULL || dPriv->driverPrivate == NULL || sInfo == NULL)
-      return -1;
-   else
-      return 0;
-}
-
-static INLINE void
-dri_copy_version(struct dri1_api_version *dst,
-                const struct __DRIversionRec *src)
-{
-   dst->major = src->major;
-   dst->minor = src->minor;
-   dst->patch_level = src->patch;
-}
-
-static const __DRIconfig **
-dri_init_screen(__DRIscreen * sPriv)
-{
-   struct dri_screen *screen;
-   const __DRIconfig **configs;
-   struct dri1_create_screen_arg arg;
-
-   screen = CALLOC_STRUCT(dri_screen);
-   if (!screen)
-      return NULL;
-
-   screen->api = drm_api_create();
-   screen->sPriv = sPriv;
-   screen->fd = sPriv->fd;
-   screen->drmLock = (drmLock *) & sPriv->pSAREA->lock;
-
-   sPriv->private = (void *)screen;
-   sPriv->extensions = dri_screen_extensions;
-
-   arg.base.mode = DRM_CREATE_DRI1;
-   arg.lf = &dri1_lf;
-   arg.ddx_info = sPriv->pDevPriv;
-   arg.ddx_info_size = sPriv->devPrivSize;
-   arg.sarea = sPriv->pSAREA;
-   dri_copy_version(&arg.ddx_version, &sPriv->ddx_version);
-   dri_copy_version(&arg.dri_version, &sPriv->dri_version);
-   dri_copy_version(&arg.drm_version, &sPriv->drm_version);
-   arg.api = NULL;
-
-   screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg.base);
-
-   if (!screen->pipe_screen || !arg.api) {
-      debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__);
-      goto out_no_screen;
-   }
-
-   __dri1_api_hooks = arg.api;
-
-   screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer;
-   driParseOptionInfo(&screen->optionCache,
-                     __driConfigOptions, __driNConfigOptions);
-
-   /**
-    * FIXME: If the driver supports format conversion swapbuffer blits, we might
-    * want to support other color bit depths than the server is currently
-    * using.
-    */
-
-   configs = dri_fill_in_modes(screen, sPriv->fbBPP);
-   if (!configs)
-      goto out_no_configs;
-
-   return configs;
- out_no_configs:
-   screen->pipe_screen->destroy(screen->pipe_screen);
- out_no_screen:
-   FREE(screen);
-   return NULL;
-}
-
-/**
- * This is the driver specific part of the createNewScreen entry point.
- *
- * Returns the __GLcontextModes supported by this driver.
- */
-static const __DRIconfig **
-dri_init_screen2(__DRIscreen * sPriv)
-{
-   struct dri_screen *screen;
-   struct drm_create_screen_arg arg;
-   const __DRIdri2LoaderExtension *dri2_ext =
-     sPriv->dri2.loader;
-
-   screen = CALLOC_STRUCT(dri_screen);
-   if (!screen)
-      goto fail;
-
-   screen->api = drm_api_create();
-   screen->sPriv = sPriv;
-   screen->fd = sPriv->fd;
-   sPriv->private = (void *)screen;
-   sPriv->extensions = dri_screen_extensions;
-   arg.mode = DRM_CREATE_NORMAL;
-
-   screen->pipe_screen = screen->api->create_screen(screen->api, screen->fd, &arg);
-   if (!screen->pipe_screen) {
-      debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
-      goto fail;
-   }
-
-   /* We need to hook in here */
-   screen->pipe_screen->update_buffer = dri_update_buffer;
-   screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer;
-
-   driParseOptionInfo(&screen->optionCache,
-                     __driConfigOptions, __driNConfigOptions);
-
-   screen->auto_fake_front = dri2_ext->base.version >= 3 &&
-      dri2_ext->getBuffersWithFormat != NULL;
-
-   return dri_fill_in_modes(screen, 32);
- fail:
-   return NULL;
-}
-
-static void
-dri_destroy_screen(__DRIscreen * sPriv)
-{
-   struct dri_screen *screen = dri_screen(sPriv);
-   int i;
-
-   screen->pipe_screen->destroy(screen->pipe_screen);
-   
-   for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) {
-      FREE(screen->optionCache.info[i].name);
-      FREE(screen->optionCache.info[i].ranges);
-   }
-
-   FREE(screen->optionCache.info);
-   FREE(screen->optionCache.values);
-
-   FREE(screen);
-   sPriv->private = NULL;
-}
-
-PUBLIC const struct __DriverAPIRec driDriverAPI = {
-   .InitScreen = dri_init_screen,
-   .DestroyScreen = dri_destroy_screen,
-   .CreateContext = dri_create_context,
-   .DestroyContext = dri_destroy_context,
-   .CreateBuffer = dri_create_buffer,
-   .DestroyBuffer = dri_destroy_buffer,
-   .SwapBuffers = dri_swap_buffers,
-   .MakeCurrent = dri_make_current,
-   .UnbindContext = dri_unbind_context,
-   .GetSwapInfo = dri_get_swap_info,
-   .GetDrawableMSC = driDrawableGetMSC32,
-   .WaitForMSC = driWaitForMSC32,
-   .CopySubBuffer = dri_copy_sub_buffer,
-   .InitScreen = dri_init_screen,
-   .InitScreen2 = dri_init_screen2,
-};
-
-/* This is the table of extensions that the loader will dlsym() for. */
-PUBLIC const __DRIextension *__driDriverExtensions[] = {
-    &driCoreExtension.base,
-    &driLegacyExtension.base,
-    &driDRI2Extension.base,
-    NULL
-};
-
-/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h
deleted file mode 100644 (file)
index 75a0ee4..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Author: Keith Whitwell <keithw@vmware.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- */
-
-#ifndef DRI_SCREEN_H
-#define DRI_SCREEN_H
-
-#include "dri_util.h"
-#include "xmlconfig.h"
-
-#include "pipe/p_compiler.h"
-
-#include "state_tracker/dri1_api.h"
-
-struct dri_screen
-{
-   /* dri */
-   __DRIscreen *sPriv;
-
-   /**
-    * Configuration cache with default values for all contexts
-    */
-   driOptionCache optionCache;
-
-   /* drm */
-   int fd;
-   drmLock *drmLock;
-
-   /* gallium */
-   struct drm_api *api;
-   struct pipe_winsys *pipe_winsys;
-   struct pipe_screen *pipe_screen;
-   boolean d_depth_bits_last;
-   boolean sd_depth_bits_last;
-   boolean auto_fake_front;
-};
-
-/** cast wrapper */
-static INLINE struct dri_screen *
-dri_screen(__DRIscreen * sPriv)
-{
-   return (struct dri_screen *)sPriv->private;
-}
-
-/***********************************************************************
- * dri_screen.c
- */
-
-extern struct dri1_api *__dri1_api_hooks;
-
-#endif
-
-/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile
new file mode 100644 (file)
index 0000000..7a236da
--- /dev/null
@@ -0,0 +1,32 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = dridrm
+
+LIBRARY_INCLUDES = \
+       -I$(TOP)/include \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/src/gallium/state_trackers/dri/common \
+       -I$(TOP)/src/mesa/drivers/dri/common \
+       -I$(TOP)/src/mesa/main \
+         $(shell pkg-config --cflags-only-I libdrm)
+
+
+C_SOURCES = \
+       dri_context.c \
+       dri_screen.c \
+       dri_drawable.c \
+       dri_st_api.c \
+       dri1_helper.c \
+       dri1.c \
+       dri2.c
+
+#      $(TOP)/src/mesa/drivers/dri/common/utils.c \
+       $(TOP)/src/mesa/drivers/dri/common/vblank.c \
+       $(TOP)/src/mesa/drivers/dri/common/dri_util.c \
+       $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \
+       $(TOP)/src/mesa/drivers/common/driverfuncs.c \
+       $(TOP)/src/mesa/drivers/dri/common/texmem.c \
+       $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c
+
+include ../../../Makefile.template
diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript
new file mode 100644 (file)
index 0000000..b9726ee
--- /dev/null
@@ -0,0 +1,27 @@
+#######################################################################
+# SConscript for dri state_tracker
+
+Import('*')
+
+if env['dri']:
+
+    env = env.Clone()
+
+    env.Append(CPPPATH = [
+        '#/src/mesa',
+       '#/src/gallium/state_trackers/dri/common',
+       '#/src/mesa/drivers/dri/common',
+    ])
+
+    st_dri = env.ConvenienceLibrary(
+       target = 'st_dri',
+       source = [ 'dri_context.c',
+               'dri_drawable.c',
+               'dri_screen.c',
+               'dri_st_api.c',
+               'dri1_helper.c',
+               'dri1.c',
+               'dri2.c',
+               ]
+    )
+    Export('st_dri')
diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c
new file mode 100644 (file)
index 0000000..cca7cd8
--- /dev/null
@@ -0,0 +1,522 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+/* XXX DRI1 is untested after the switch to st_api.h */
+
+#include "util/u_memory.h"
+#include "util/u_rect.h"
+#include "util/u_inlines.h"
+#include "pipe/p_context.h"
+#include "state_tracker/dri1_api.h"
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+#include "dri_st_api.h"
+#include "dri1_helper.h"
+#include "dri1.h"
+
+static INLINE void
+dri1_lock(struct dri_context *ctx)
+{
+   drm_context_t hw_context = ctx->cPriv->hHWContext;
+   char ret = 0;
+
+   DRM_CAS(ctx->lock, hw_context, DRM_LOCK_HELD | hw_context, ret);
+   if (ret) {
+      drmGetLock(ctx->sPriv->fd, hw_context, 0);
+      ctx->stLostLock = TRUE;
+      ctx->wsLostLock = TRUE;
+   }
+   ctx->isLocked = TRUE;
+}
+
+static INLINE void
+dri1_unlock(struct dri_context *ctx)
+{
+   ctx->isLocked = FALSE;
+   DRM_UNLOCK(ctx->sPriv->fd, ctx->lock, ctx->cPriv->hHWContext);
+}
+
+static void
+dri1_update_drawables_locked(struct dri_context *ctx,
+                            __DRIdrawable * driDrawPriv,
+                            __DRIdrawable * driReadPriv)
+{
+   if (ctx->stLostLock) {
+      ctx->stLostLock = FALSE;
+      if (driDrawPriv == driReadPriv)
+        DRI_VALIDATE_DRAWABLE_INFO(ctx->sPriv, driDrawPriv);
+      else
+        DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv,
+                                        driReadPriv);
+   }
+}
+
+/**
+ * This ensures all contexts which bind to a drawable pick up the
+ * drawable change and signal new buffer state.
+ */
+static void
+dri1_propagate_drawable_change(struct dri_context *ctx)
+{
+   __DRIdrawable *dPriv = ctx->dPriv;
+   __DRIdrawable *rPriv = ctx->rPriv;
+   struct dri_drawable *draw = dri_drawable(dPriv);
+   struct dri_drawable *read = dri_drawable(rPriv);
+   boolean flushed = FALSE;
+
+   if (dPriv && draw->texture_stamp != dPriv->lastStamp) {
+      ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+      flushed = TRUE;
+      ctx->st->notify_invalid_framebuffer(ctx->st, draw->stfb);
+   }
+
+   if (rPriv && dPriv != rPriv && read->texture_stamp != rPriv->lastStamp) {
+      if (!flushed)
+        ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+      ctx->st->notify_invalid_framebuffer(ctx->st, read->stfb);
+   }
+}
+
+static INLINE boolean
+dri1_intersect_src_bbox(struct drm_clip_rect *dst,
+                       int dst_x,
+                       int dst_y,
+                       const struct drm_clip_rect *src,
+                       const struct drm_clip_rect *bbox)
+{
+   int xy1;
+   int xy2;
+
+   xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
+      (int)bbox->x1 + dst_x;
+   xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
+      (int)bbox->x2 + dst_x;
+   if (xy1 >= xy2 || xy1 < 0)
+      return FALSE;
+
+   dst->x1 = xy1;
+   dst->x2 = xy2;
+
+   xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
+      (int)bbox->y1 + dst_y;
+   xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
+      (int)bbox->y2 + dst_y;
+   if (xy1 >= xy2 || xy1 < 0)
+      return FALSE;
+
+   dst->y1 = xy1;
+   dst->y2 = xy2;
+   return TRUE;
+}
+
+static void
+dri1_swap_copy(struct pipe_context *pipe,
+              struct pipe_surface *dst,
+              struct pipe_surface *src,
+              __DRIdrawable * dPriv, const struct drm_clip_rect *bbox)
+{
+   struct drm_clip_rect clip;
+   struct drm_clip_rect *cur;
+   int i;
+
+   cur = dPriv->pClipRects;
+
+   for (i = 0; i < dPriv->numClipRects; ++i) {
+      if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) {
+         if (pipe->surface_copy) {
+            pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
+                               src,
+                               (int)clip.x1 - dPriv->x,
+                               (int)clip.y1 - dPriv->y,
+                               clip.x2 - clip.x1, clip.y2 - clip.y1);
+         } else {
+            util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1,
+                              src,
+                              (int)clip.x1 - dPriv->x,
+                              (int)clip.y1 - dPriv->y,
+                              clip.x2 - clip.x1, clip.y2 - clip.y1);
+         }
+      }
+   }
+}
+
+static void
+dri1_present_texture_locked(__DRIdrawable * dPriv,
+                            struct pipe_texture *ptex,
+                            const struct drm_clip_rect *sub_box,
+                            struct pipe_fence_handle **fence)
+{
+   struct dri_drawable *drawable = dri_drawable(dPriv);
+   struct dri_screen *screen = dri_screen(drawable->sPriv);
+   struct pipe_context *pipe;
+   struct pipe_surface *psurf;
+   struct drm_clip_rect bbox;
+   boolean visible = TRUE;
+
+   *fence = NULL;
+
+   bbox.x1 = 0;
+   bbox.x2 = ptex->width0;
+   bbox.y1 = 0;
+   bbox.y2 = ptex->height0;
+
+   if (sub_box)
+      visible = dri1_intersect_src_bbox(&bbox, 0, 0, &bbox, sub_box);
+   if (!visible)
+      return;
+
+   pipe = dri1_get_pipe_context(screen);
+   psurf = dri1_get_pipe_surface(drawable, ptex);
+   if (!pipe || !psurf)
+      return;
+
+   if (__dri1_api_hooks->present_locked) {
+      __dri1_api_hooks->present_locked(pipe, psurf,
+                                       dPriv->pClipRects, dPriv->numClipRects,
+                                       dPriv->x, dPriv->y, &bbox, fence);
+   } else if (__dri1_api_hooks->front_srf_locked) {
+      struct pipe_surface *front = __dri1_api_hooks->front_srf_locked(pipe);
+
+      if (front)
+         dri1_swap_copy(pipe, front, psurf, dPriv, &bbox);
+
+      pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, fence);
+   }
+}
+
+static void
+dri1_copy_to_front(struct dri_context *ctx,
+                  struct pipe_texture *ptex,
+                  __DRIdrawable * dPriv,
+                  const struct drm_clip_rect *sub_box,
+                  struct pipe_fence_handle **fence)
+{
+   boolean save_lost_lock;
+
+   dri1_lock(ctx);
+   save_lost_lock = ctx->stLostLock;
+   dri1_update_drawables_locked(ctx, dPriv, dPriv);
+
+   dri1_present_texture_locked(dPriv, ptex, sub_box, fence);
+
+   ctx->stLostLock = save_lost_lock;
+
+   /**
+    * FIXME: Revisit this: Update drawables on copy_sub_buffer ?
+    */
+
+   if (!sub_box)
+      dri1_update_drawables_locked(ctx, ctx->dPriv, ctx->rPriv);
+
+   dri1_unlock(ctx);
+   dri1_propagate_drawable_change(ctx);
+}
+
+/*
+ * Backend functions for st_framebuffer interface and swap_buffers.
+ */
+
+void
+dri1_flush_frontbuffer(struct dri_drawable *draw,
+                       enum st_attachment_type statt)
+{
+   struct dri_context *ctx = dri_get_current();
+   struct dri_screen *screen = dri_screen(draw->sPriv);
+   struct pipe_screen *pipe_screen = screen->pipe_screen;
+   struct pipe_fence_handle *dummy_fence;
+   struct pipe_texture *ptex;
+
+   if (!ctx)
+      return;                         /* For now */
+
+   ptex = draw->textures[statt];
+   if (ptex) {
+      dri1_copy_to_front(ctx, ptex, ctx->dPriv, NULL, &dummy_fence);
+      pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL);
+   }
+
+   /**
+    * FIXME: Do we need swap throttling here?
+    */
+}
+
+void
+dri1_swap_buffers(__DRIdrawable * dPriv)
+{
+   struct dri_context *ctx = dri_get_current();
+   struct dri_drawable *draw = dri_drawable(dPriv);
+   struct dri_screen *screen = dri_screen(draw->sPriv);
+   struct pipe_screen *pipe_screen = screen->pipe_screen;
+   struct pipe_fence_handle *fence;
+   struct pipe_texture *ptex;
+
+   assert(__dri1_api_hooks != NULL);
+
+   if (!ctx)
+      return;                         /* For now */
+
+   ptex = draw->textures[ST_ATTACHMENT_BACK_LEFT];
+   if (ptex) {
+      ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+      fence = dri1_swap_fences_pop_front(draw);
+      if (fence) {
+        (void)pipe_screen->fence_finish(pipe_screen, fence, 0);
+        pipe_screen->fence_reference(pipe_screen, &fence, NULL);
+      }
+      dri1_copy_to_front(ctx, ptex, dPriv, NULL, &fence);
+      dri1_swap_fences_push_back(draw, fence);
+      pipe_screen->fence_reference(pipe_screen, &fence, NULL);
+   }
+}
+
+void
+dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h)
+{
+   struct dri_context *ctx = dri_get_current();
+   struct dri_screen *screen = dri_screen(dPriv->driScreenPriv);
+   struct pipe_screen *pipe_screen = screen->pipe_screen;
+   struct drm_clip_rect sub_bbox;
+   struct dri_drawable *draw = dri_drawable(dPriv);
+   struct pipe_fence_handle *dummy_fence;
+   struct pipe_texture *ptex;
+
+   assert(__dri1_api_hooks != NULL);
+
+   if (!ctx)
+      return;
+
+   sub_bbox.x1 = x;
+   sub_bbox.x2 = x + w;
+   sub_bbox.y1 = y;
+   sub_bbox.y2 = y + h;
+
+   ptex = draw->textures[ST_ATTACHMENT_BACK_LEFT];
+   if (ptex) {
+      ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+      dri1_copy_to_front(ctx, ptex, dPriv, &sub_bbox, &dummy_fence);
+      pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL);
+   }
+}
+
+/**
+ * Allocate framebuffer attachments.
+ *
+ * During fixed-size operation, the function keeps allocating new attachments
+ * as they are requested. Unused attachments are not removed, not until the
+ * framebuffer is resized or destroyed.
+ */
+void
+dri1_allocate_textures(struct dri_drawable *drawable,
+                       unsigned mask)
+{
+   struct dri_screen *screen = dri_screen(drawable->sPriv);
+   struct pipe_texture templ;
+   unsigned width, height;
+   boolean resized;
+   int i;
+
+   width  = drawable->dPriv->w;
+   height = drawable->dPriv->h;
+
+   resized = (drawable->old_w != width ||
+              drawable->old_h != height);
+
+   /* remove outdated textures */
+   if (resized) {
+      for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+         pipe_texture_reference(&drawable->textures[i], NULL);
+   }
+
+   memset(&templ, 0, sizeof(templ));
+   templ.target = PIPE_TEXTURE_2D;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
+   templ.last_level = 0;
+
+   for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+      enum pipe_format format;
+      unsigned tex_usage;
+
+      /* the texture already exists or not requested */
+      if (drawable->textures[i] || !(mask & (1 << i))) {
+         continue;
+      }
+
+      switch (i) {
+      case ST_ATTACHMENT_FRONT_LEFT:
+      case ST_ATTACHMENT_BACK_LEFT:
+      case ST_ATTACHMENT_FRONT_RIGHT:
+      case ST_ATTACHMENT_BACK_RIGHT:
+         format = drawable->stvis.color_format;
+         tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                     PIPE_TEXTURE_USAGE_RENDER_TARGET;
+         break;
+      case ST_ATTACHMENT_DEPTH_STENCIL:
+         format = drawable->stvis.depth_stencil_format;
+         tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+         break;
+      default:
+         format = PIPE_FORMAT_NONE;
+         break;
+      }
+
+      if (format != PIPE_FORMAT_NONE) {
+         templ.format = format;
+         templ.tex_usage = tex_usage;
+
+         drawable->textures[i] =
+            screen->pipe_screen->texture_create(screen->pipe_screen, &templ);
+      }
+   }
+
+   drawable->old_w = width;
+   drawable->old_h = height;
+}
+
+/*
+ * Backend function for init_screen.
+ */
+
+static const __DRIextension *dri1_screen_extensions[] = {
+   &driReadDrawableExtension,
+   &driCopySubBufferExtension.base,
+   &driSwapControlExtension.base,
+   &driFrameTrackingExtension.base,
+   &driMediaStreamCounterExtension.base,
+   NULL
+};
+
+static void
+st_dri_lock(struct pipe_context *pipe)
+{
+   dri1_lock((struct dri_context *)pipe->priv);
+}
+
+static void
+st_dri_unlock(struct pipe_context *pipe)
+{
+   dri1_unlock((struct dri_context *)pipe->priv);
+}
+
+static boolean
+st_dri_is_locked(struct pipe_context *pipe)
+{
+   return ((struct dri_context *)pipe->priv)->isLocked;
+}
+
+static boolean
+st_dri_lost_lock(struct pipe_context *pipe)
+{
+   return ((struct dri_context *)pipe->priv)->wsLostLock;
+}
+
+static void
+st_dri_clear_lost_lock(struct pipe_context *pipe)
+{
+   ((struct dri_context *)pipe->priv)->wsLostLock = FALSE;
+}
+
+static struct dri1_api_lock_funcs dri1_lf = {
+   .lock = st_dri_lock,
+   .unlock = st_dri_unlock,
+   .is_locked = st_dri_is_locked,
+   .is_lock_lost = st_dri_lost_lock,
+   .clear_lost_lock = st_dri_clear_lost_lock
+};
+
+static INLINE void
+dri1_copy_version(struct dri1_api_version *dst,
+                 const struct __DRIversionRec *src)
+{
+   dst->major = src->major;
+   dst->minor = src->minor;
+   dst->patch_level = src->patch;
+}
+
+struct dri1_api *__dri1_api_hooks = NULL;
+
+const __DRIconfig **
+dri1_init_screen(__DRIscreen * sPriv)
+{
+   const __DRIconfig **configs;
+   struct dri_screen *screen;
+   struct dri1_create_screen_arg arg;
+
+   screen = CALLOC_STRUCT(dri_screen);
+   if (!screen)
+      return NULL;
+
+   screen->api = drm_api_create();
+   screen->sPriv = sPriv;
+   screen->fd = sPriv->fd;
+   screen->drmLock = (drmLock *) & sPriv->pSAREA->lock;
+
+   sPriv->private = (void *)screen;
+   sPriv->extensions = dri1_screen_extensions;
+
+   arg.base.mode = DRM_CREATE_DRI1;
+   arg.lf = &dri1_lf;
+   arg.ddx_info = sPriv->pDevPriv;
+   arg.ddx_info_size = sPriv->devPrivSize;
+   arg.sarea = sPriv->pSAREA;
+   dri1_copy_version(&arg.ddx_version, &sPriv->ddx_version);
+   dri1_copy_version(&arg.dri_version, &sPriv->dri_version);
+   dri1_copy_version(&arg.drm_version, &sPriv->drm_version);
+   arg.api = NULL;
+
+   /**
+    * FIXME: If the driver supports format conversion swapbuffer blits, we might
+    * want to support other color bit depths than the server is currently
+    * using.
+    */
+
+   configs = dri_init_screen_helper(screen, &arg.base, sPriv->fbBPP);
+   if (!configs)
+      goto fail;
+
+   if (!arg.api) {
+      debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__);
+      goto fail;
+   }
+
+   __dri1_api_hooks = arg.api;
+
+   return configs;
+fail:
+   if (configs)
+      FREE(configs);
+   dri_destroy_screen_helper(screen);
+   FREE(screen);
+   return NULL;
+}
diff --git a/src/gallium/state_trackers/dri/drm/dri1.h b/src/gallium/state_trackers/dri/drm/dri1.h
new file mode 100644 (file)
index 0000000..f7441f9
--- /dev/null
@@ -0,0 +1,59 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#ifndef DRI1_H
+#define DRI1_H
+
+#include "dri_context.h"
+#include "dri_drawable.h"
+
+#include "state_tracker/st_api.h"
+#include "dri_wrapper.h"
+
+extern struct dri1_api *__dri1_api_hooks;
+
+const __DRIconfig **
+dri1_init_screen(__DRIscreen * sPriv);
+
+void
+dri1_flush_frontbuffer(struct dri_drawable *drawable,
+                       enum st_attachment_type statt);
+
+void
+dri1_allocate_textures(struct dri_drawable *drawable,
+                       unsigned mask);
+
+void dri1_swap_buffers(__DRIdrawable * dPriv);
+
+void
+dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h);
+
+#endif /* DRI1_H */
diff --git a/src/gallium/state_trackers/dri/drm/dri1_helper.c b/src/gallium/state_trackers/dri/drm/dri1_helper.c
new file mode 120000 (symlink)
index 0000000..c45ebf5
--- /dev/null
@@ -0,0 +1 @@
+../common/dri1_helper.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
new file mode 100644 (file)
index 0000000..c632f0f
--- /dev/null
@@ -0,0 +1,416 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.9
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Keith Whitwell <keithw@vmware.com>
+ *    Jakob Bornecrantz <wallbraker@gmail.com>
+ *    Chia-I Wu <olv@lunarg.com>
+ */
+
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+#include "util/u_format.h"
+#include "util/u_debug.h"
+#include "state_tracker/drm_api.h"
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+#include "dri_st_api.h"
+#include "dri2.h"
+
+/**
+ * DRI2 flush extension.
+ */
+static void
+dri2_flush_drawable(__DRIdrawable *draw)
+{
+}
+
+static void
+dri2_invalidate_drawable(__DRIdrawable *dPriv)
+{
+   struct dri_drawable *drawable = dri_drawable(dPriv);
+   struct dri_context *ctx = dri_context(dPriv->driContextPriv);
+
+   dri2InvalidateDrawable(dPriv);
+   drawable->dPriv->lastStamp = *drawable->dPriv->pStamp;
+
+   if (ctx)
+      ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb);
+}
+
+static const __DRI2flushExtension dri2FlushExtension = {
+    { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
+    dri2_flush_drawable,
+    dri2_invalidate_drawable,
+};
+
+/**
+ * These are used for GLX_EXT_texture_from_pixmap
+ */
+static void
+dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
+                     GLint format, __DRIdrawable *dPriv)
+{
+   struct dri_context *ctx = dri_context(pDRICtx);
+   struct dri_drawable *drawable = dri_drawable(dPriv);
+   struct pipe_texture *pt;
+
+   dri_st_framebuffer_validate_att(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT);
+
+   pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
+
+   if (pt) {
+      ctx->st->teximage(ctx->st,
+            (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT,
+            0, drawable->stvis.color_format, pt, FALSE);
+   }
+}
+
+static void
+dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
+                    __DRIdrawable *dPriv)
+{
+   dri2_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
+}
+
+static const __DRItexBufferExtension dri2TexBufferExtension = {
+    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+   dri2_set_tex_buffer,
+   dri2_set_tex_buffer2,
+};
+
+/**
+ * Get the format of an attachment.
+ */
+static INLINE enum pipe_format
+dri2_drawable_get_format(struct dri_drawable *drawable,
+                         enum st_attachment_type statt)
+{
+   enum pipe_format format;
+
+   switch (statt) {
+   case ST_ATTACHMENT_FRONT_LEFT:
+   case ST_ATTACHMENT_BACK_LEFT:
+   case ST_ATTACHMENT_FRONT_RIGHT:
+   case ST_ATTACHMENT_BACK_RIGHT:
+      format = drawable->stvis.color_format;
+      break;
+   case ST_ATTACHMENT_DEPTH_STENCIL:
+      format = drawable->stvis.depth_stencil_format;
+      break;
+   default:
+      format = PIPE_FORMAT_NONE;
+      break;
+   }
+
+   return format;
+}
+
+/**
+ * Retrieve __DRIbuffer from the DRI loader.
+ */
+static __DRIbuffer *
+dri2_drawable_get_buffers(struct dri_drawable *drawable,
+                          const enum st_attachment_type *statts,
+                          unsigned *count)
+{
+   __DRIdrawable *dri_drawable = drawable->dPriv;
+   struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader;
+   boolean with_format;
+   __DRIbuffer *buffers;
+   int num_buffers;
+   unsigned attachments[10];
+   unsigned num_attachments, i;
+
+   assert(loader);
+   with_format = dri_with_format(drawable->sPriv);
+
+   num_attachments = 0;
+
+   /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */
+   if (!with_format)
+      attachments[num_attachments++] = __DRI_BUFFER_FRONT_LEFT;
+
+   for (i = 0; i < *count; i++) {
+      enum pipe_format format;
+      int att, bpp;
+
+      format = dri2_drawable_get_format(drawable, statts[i]);
+      if (format == PIPE_FORMAT_NONE)
+         continue;
+
+      switch (statts[i]) {
+      case ST_ATTACHMENT_FRONT_LEFT:
+         /* already added */
+         if (!with_format)
+            continue;
+         att = __DRI_BUFFER_FRONT_LEFT;
+         break;
+      case ST_ATTACHMENT_BACK_LEFT:
+         att = __DRI_BUFFER_BACK_LEFT;
+         break;
+      case ST_ATTACHMENT_FRONT_RIGHT:
+         att = __DRI_BUFFER_FRONT_RIGHT;
+         break;
+      case ST_ATTACHMENT_BACK_RIGHT:
+         att = __DRI_BUFFER_BACK_RIGHT;
+         break;
+      case ST_ATTACHMENT_DEPTH_STENCIL:
+         att = __DRI_BUFFER_DEPTH_STENCIL;
+         break;
+      default:
+         att = -1;
+         break;
+      }
+
+      bpp = util_format_get_blocksizebits(format);
+
+      if (att >= 0) {
+         attachments[num_attachments++] = att;
+         if (with_format) {
+            attachments[num_attachments++] = bpp;
+         }
+      }
+   }
+
+   if (with_format) {
+      num_attachments /= 2;
+      buffers = loader->getBuffersWithFormat(dri_drawable,
+            &dri_drawable->w, &dri_drawable->h,
+            attachments, num_attachments,
+            &num_buffers, dri_drawable->loaderPrivate);
+   }
+   else {
+      buffers = loader->getBuffers(dri_drawable,
+            &dri_drawable->w, &dri_drawable->h,
+            attachments, num_attachments,
+            &num_buffers, dri_drawable->loaderPrivate);
+   }
+
+   if (buffers) {
+      /* set one cliprect to cover the whole dri_drawable */
+      dri_drawable->x = 0;
+      dri_drawable->y = 0;
+      dri_drawable->backX = 0;
+      dri_drawable->backY = 0;
+      dri_drawable->numClipRects = 1;
+      dri_drawable->pClipRects[0].x1 = 0;
+      dri_drawable->pClipRects[0].y1 = 0;
+      dri_drawable->pClipRects[0].x2 = dri_drawable->w;
+      dri_drawable->pClipRects[0].y2 = dri_drawable->h;
+      dri_drawable->numBackClipRects = 1;
+      dri_drawable->pBackClipRects[0].x1 = 0;
+      dri_drawable->pBackClipRects[0].y1 = 0;
+      dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
+      dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
+
+      *count = num_buffers;
+   }
+
+   return buffers;
+}
+
+/**
+ * Process __DRIbuffer and convert them into pipe_textures.
+ */
+static void
+dri2_drawable_process_buffers(struct dri_drawable *drawable,
+                              __DRIbuffer *buffers, unsigned count)
+{
+   struct dri_screen *screen = dri_screen(drawable->sPriv);
+   __DRIdrawable *dri_drawable = drawable->dPriv;
+   struct pipe_texture templ;
+   struct winsys_handle whandle;
+   boolean have_depth = FALSE;
+   unsigned i;
+
+   if (drawable->old_num == count &&
+       drawable->old_w == dri_drawable->w &&
+       drawable->old_h == dri_drawable->h &&
+       memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0)
+      return;
+
+   for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+      pipe_texture_reference(&drawable->textures[i], NULL);
+
+   memset(&templ, 0, sizeof(templ));
+   templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+   templ.target = PIPE_TEXTURE_2D;
+   templ.last_level = 0;
+   templ.width0 = dri_drawable->w;
+   templ.height0 = dri_drawable->h;
+   templ.depth0 = 1;
+
+   memset(&whandle, 0, sizeof(whandle));
+
+   for (i = 0; i < count; i++) {
+      __DRIbuffer *buf = &buffers[i];
+      enum st_attachment_type statt;
+      enum pipe_format format;
+
+      switch (buf->attachment) {
+      case __DRI_BUFFER_FRONT_LEFT:
+         if (!screen->auto_fake_front) {
+            statt = ST_ATTACHMENT_INVALID;
+            break;
+         }
+         /* fallthrough */
+      case __DRI_BUFFER_FAKE_FRONT_LEFT:
+         statt = ST_ATTACHMENT_FRONT_LEFT;
+         break;
+      case __DRI_BUFFER_BACK_LEFT:
+         statt = ST_ATTACHMENT_BACK_LEFT;
+         break;
+      case __DRI_BUFFER_DEPTH:
+      case __DRI_BUFFER_DEPTH_STENCIL:
+      case __DRI_BUFFER_STENCIL:
+         /* use only the first depth/stencil buffer */
+         if (!have_depth) {
+            have_depth = TRUE;
+            statt = ST_ATTACHMENT_DEPTH_STENCIL;
+         }
+         else {
+            statt = ST_ATTACHMENT_INVALID;
+         }
+         break;
+      default:
+         statt = ST_ATTACHMENT_INVALID;
+         break;
+      }
+
+      format = dri2_drawable_get_format(drawable, statt);
+      if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE)
+         continue;
+
+      templ.format = format;
+      whandle.handle = buf->name;
+      whandle.stride = buf->pitch;
+
+      drawable->textures[statt] =
+         screen->pipe_screen->texture_from_handle(screen->pipe_screen,
+               &templ, &whandle);
+   }
+
+   drawable->old_num = count;
+   drawable->old_w = dri_drawable->w;
+   drawable->old_h = dri_drawable->h;
+   memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count);
+}
+
+/*
+ * Backend functions for st_framebuffer interface.
+ */
+
+void
+dri2_allocate_textures(struct dri_drawable *drawable,
+                       const enum st_attachment_type *statts,
+                       unsigned count)
+{
+   __DRIbuffer *buffers;
+   unsigned num_buffers = count;
+
+   buffers = dri2_drawable_get_buffers(drawable, statts, &num_buffers);
+   dri2_drawable_process_buffers(drawable, buffers, num_buffers);
+}
+
+void
+dri2_flush_frontbuffer(struct dri_drawable *drawable,
+                       enum st_attachment_type statt)
+{
+   __DRIdrawable *dri_drawable = drawable->dPriv;
+   struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader;
+
+   if (loader->flushFrontBuffer == NULL)
+      return;
+
+   if (statt == ST_ATTACHMENT_FRONT_LEFT) {
+      loader->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate);
+   }
+}
+
+/*
+ * Backend function init_screen.
+ */
+
+static const __DRIextension *dri_screen_extensions[] = {
+   &driReadDrawableExtension,
+   &driCopySubBufferExtension.base,
+   &driSwapControlExtension.base,
+   &driFrameTrackingExtension.base,
+   &driMediaStreamCounterExtension.base,
+   &dri2TexBufferExtension.base,
+   &dri2FlushExtension.base,
+   NULL
+};
+
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ *
+ * Returns the __GLcontextModes supported by this driver.
+ */
+const __DRIconfig **
+dri2_init_screen(__DRIscreen * sPriv)
+{
+   const __DRIconfig **configs;
+   struct dri_screen *screen;
+   struct drm_create_screen_arg arg;
+
+   screen = CALLOC_STRUCT(dri_screen);
+   if (!screen)
+      return NULL;
+
+   screen->api = drm_api_create();
+   screen->sPriv = sPriv;
+   screen->fd = sPriv->fd;
+
+   sPriv->private = (void *)screen;
+   sPriv->extensions = dri_screen_extensions;
+
+   arg.mode = DRM_CREATE_NORMAL;
+
+   configs = dri_init_screen_helper(screen, &arg, 32);
+   if (!configs)
+      goto fail;
+
+   screen->auto_fake_front = dri_with_format(sPriv);
+
+   return configs;
+fail:
+   dri_destroy_screen_helper(screen);
+   FREE(screen);
+   return NULL;
+}
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    &driDRI2Extension.base,
+    NULL
+};
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/drm/dri2.h b/src/gallium/state_trackers/dri/drm/dri2.h
new file mode 100644 (file)
index 0000000..3799634
--- /dev/null
@@ -0,0 +1,46 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef DRI2_H
+#define DRI2_H
+
+#include "dri_drawable.h"
+#include "dri_wrapper.h"
+
+const __DRIconfig **
+dri2_init_screen(__DRIscreen * sPriv);
+
+void
+dri2_flush_frontbuffer(struct dri_drawable *drawable,
+                       enum st_attachment_type statt);
+
+void
+dri2_allocate_textures(struct dri_drawable *drawable,
+                       const enum st_attachment_type *statts,
+                       unsigned count);
+
+#endif /* DRI2_H */
diff --git a/src/gallium/state_trackers/dri/drm/dri_context.c b/src/gallium/state_trackers/dri/drm/dri_context.c
new file mode 120000 (symlink)
index 0000000..5cfbbae
--- /dev/null
@@ -0,0 +1 @@
+../common/dri_context.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/drm/dri_drawable.c b/src/gallium/state_trackers/dri/drm/dri_drawable.c
new file mode 120000 (symlink)
index 0000000..0fc19be
--- /dev/null
@@ -0,0 +1 @@
+../common/dri_drawable.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/drm/dri_screen.c b/src/gallium/state_trackers/dri/drm/dri_screen.c
new file mode 120000 (symlink)
index 0000000..847f651
--- /dev/null
@@ -0,0 +1 @@
+../common/dri_screen.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/drm/dri_st_api.c b/src/gallium/state_trackers/dri/drm/dri_st_api.c
new file mode 120000 (symlink)
index 0000000..a8f6bd0
--- /dev/null
@@ -0,0 +1 @@
+../common/dri_st_api.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/sw/Makefile b/src/gallium/state_trackers/dri/sw/Makefile
new file mode 100644 (file)
index 0000000..18d7aab
--- /dev/null
@@ -0,0 +1,26 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = drisw
+
+LIBRARY_DEFINES = -D__NOT_HAVE_DRM_H
+
+LIBRARY_INCLUDES = \
+       -I../dri \
+       -I$(TOP)/include \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/src/gallium/state_trackers/dri/common \
+       -I$(TOP)/src/mesa/drivers/dri/common \
+       -I$(TOP)/src/mesa/main \
+       -D__NOT_HAVE_DRM_H
+
+
+C_SOURCES = \
+       dri_context.c \
+       dri_screen.c \
+       dri_drawable.c \
+       dri_st_api.c \
+       dri1_helper.c \
+       drisw.c
+
+include ../../../Makefile.template
diff --git a/src/gallium/state_trackers/dri/sw/SConscript b/src/gallium/state_trackers/dri/sw/SConscript
new file mode 100644 (file)
index 0000000..c97124c
--- /dev/null
@@ -0,0 +1,28 @@
+#######################################################################
+# SConscript for dri state_tracker
+
+Import('*')
+
+if env['dri']:
+
+    env = env.Clone()
+
+    env.Append(CPPPATH = [
+        '#/src/mesa',
+       '#/src/gallium/state_trackers/dri/common',
+       '#/src/mesa/drivers/dri/common',
+    ])
+
+    env.Append(CPPDEFINES = [('__NOT_HAVE_DRM_H', '1')])
+
+    st_drisw = env.ConvenienceLibrary(
+       target = 'st_drisw',
+       source = [ 'dri_context.c',
+               'dri_drawable.c',
+               'dri_screen.c',
+               'dri_st_api.c',
+               'dri1_helper.c',
+               'drisw.c',
+               ]
+    )
+    Export('st_drisw')
diff --git a/src/gallium/state_trackers/dri/sw/dri1_helper.c b/src/gallium/state_trackers/dri/sw/dri1_helper.c
new file mode 120000 (symlink)
index 0000000..c45ebf5
--- /dev/null
@@ -0,0 +1 @@
+../common/dri1_helper.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/sw/dri_context.c b/src/gallium/state_trackers/dri/sw/dri_context.c
new file mode 120000 (symlink)
index 0000000..5cfbbae
--- /dev/null
@@ -0,0 +1 @@
+../common/dri_context.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/sw/dri_drawable.c b/src/gallium/state_trackers/dri/sw/dri_drawable.c
new file mode 120000 (symlink)
index 0000000..0fc19be
--- /dev/null
@@ -0,0 +1 @@
+../common/dri_drawable.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/sw/dri_screen.c b/src/gallium/state_trackers/dri/sw/dri_screen.c
new file mode 120000 (symlink)
index 0000000..847f651
--- /dev/null
@@ -0,0 +1 @@
+../common/dri_screen.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/sw/dri_st_api.c b/src/gallium/state_trackers/dri/sw/dri_st_api.c
new file mode 120000 (symlink)
index 0000000..a8f6bd0
--- /dev/null
@@ -0,0 +1 @@
+../common/dri_st_api.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
new file mode 100644 (file)
index 0000000..42fa789
--- /dev/null
@@ -0,0 +1,298 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL 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.
+ *
+ **************************************************************************/
+
+/* TODO:
+ *
+ * xshm / texture_from_pixmap / EGLImage:
+ *
+ * Allow the loaders to use the XSHM extension. It probably requires callbacks
+ * for createImage/destroyImage similar to DRI2 getBuffers.
+ */
+
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+#include "pipe/p_context.h"
+#include "state_tracker/drisw_api.h"
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+#include "dri1_helper.h"
+#include "drisw.h"
+
+
+static INLINE void
+get_drawable_info(__DRIdrawable *dPriv, int *w, int *h)
+{
+   __DRIscreen *sPriv = dPriv->driScreenPriv;
+   const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader;
+   int x, y;
+
+   loader->getDrawableInfo(dPriv,
+                           &x, &y, w, h,
+                           dPriv->loaderPrivate);
+}
+
+static INLINE void
+put_image(__DRIdrawable *dPriv, void *data, unsigned width, unsigned height)
+{
+   __DRIscreen *sPriv = dPriv->driScreenPriv;
+   const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader;
+
+   loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP,
+                    0, 0, width, height,
+                    data, dPriv->loaderPrivate);
+}
+
+void
+drisw_update_drawable_info(struct dri_drawable *drawable)
+{
+   __DRIdrawable *dPriv = drawable->dPriv;
+
+   get_drawable_info(dPriv, &dPriv->w, &dPriv->h);
+}
+
+static void
+drisw_put_image(struct dri_drawable *drawable,
+                void *data, unsigned width, unsigned height)
+{
+   __DRIdrawable *dPriv = drawable->dPriv;
+
+   put_image(dPriv, data, width, height);
+}
+
+static INLINE void
+drisw_present_texture(__DRIdrawable *dPriv,
+                      struct pipe_texture *ptex)
+{
+   struct dri_drawable *drawable = dri_drawable(dPriv);
+   struct dri_screen *screen = dri_screen(drawable->sPriv);
+   struct pipe_surface *psurf;
+
+   psurf = dri1_get_pipe_surface(drawable, ptex);
+   if (!psurf)
+      return;
+
+   screen->pipe_screen->flush_frontbuffer(screen->pipe_screen, psurf, drawable);
+}
+
+static INLINE void
+drisw_invalidate_drawable(__DRIdrawable *dPriv)
+{
+   struct dri_context *ctx = dri_get_current();
+   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->stfb);
+}
+
+static INLINE void
+drisw_copy_to_front(__DRIdrawable * dPriv,
+                    struct pipe_texture *ptex)
+{
+   drisw_present_texture(dPriv, ptex);
+
+   drisw_invalidate_drawable(dPriv);
+}
+
+/*
+ * Backend functions for st_framebuffer interface and swap_buffers.
+ */
+
+void
+drisw_swap_buffers(__DRIdrawable *dPriv)
+{
+   struct dri_context *ctx = dri_get_current();
+   struct dri_drawable *drawable = dri_drawable(dPriv);
+   struct pipe_texture *ptex;
+
+   if (!ctx)
+      return;
+
+   ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
+
+   if (ptex) {
+      ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+      drisw_copy_to_front(dPriv, ptex);
+   }
+}
+
+void
+drisw_flush_frontbuffer(struct dri_drawable *drawable,
+                        enum st_attachment_type statt)
+{
+   struct dri_context *ctx = dri_get_current();
+   struct pipe_texture *ptex;
+
+   if (!ctx)
+      return;
+
+   ptex = drawable->textures[statt];
+
+   if (ptex) {
+      drisw_copy_to_front(ctx->dPriv, ptex);
+   }
+}
+
+/**
+ * Allocate framebuffer attachments.
+ *
+ * During fixed-size operation, the function keeps allocating new attachments
+ * as they are requested. Unused attachments are not removed, not until the
+ * framebuffer is resized or destroyed.
+ *
+ * It should be possible for DRI1 and DRISW to share this function, but it
+ * seems a better seperation and safer for each DRI version to provide its own
+ * function.
+ */
+void
+drisw_allocate_textures(struct dri_drawable *drawable,
+                        unsigned mask)
+{
+   struct dri_screen *screen = dri_screen(drawable->sPriv);
+   struct pipe_texture templ;
+   unsigned width, height;
+   boolean resized;
+   int i;
+
+   width  = drawable->dPriv->w;
+   height = drawable->dPriv->h;
+
+   resized = (drawable->old_w != width ||
+              drawable->old_h != height);
+
+   /* remove outdated textures */
+   if (resized) {
+      for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+         pipe_texture_reference(&drawable->textures[i], NULL);
+   }
+
+   memset(&templ, 0, sizeof(templ));
+   templ.target = PIPE_TEXTURE_2D;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
+   templ.last_level = 0;
+
+   for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+      enum pipe_format format;
+      unsigned tex_usage;
+
+      /* the texture already exists or not requested */
+      if (drawable->textures[i] || !(mask & (1 << i))) {
+         continue;
+      }
+
+      switch (i) {
+      case ST_ATTACHMENT_FRONT_LEFT:
+      case ST_ATTACHMENT_BACK_LEFT:
+      case ST_ATTACHMENT_FRONT_RIGHT:
+      case ST_ATTACHMENT_BACK_RIGHT:
+         format = drawable->stvis.color_format;
+         tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                     PIPE_TEXTURE_USAGE_RENDER_TARGET;
+         break;
+      case ST_ATTACHMENT_DEPTH_STENCIL:
+         format = drawable->stvis.depth_stencil_format;
+         tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+         break;
+      default:
+         format = PIPE_FORMAT_NONE;
+         break;
+      }
+
+      if (format != PIPE_FORMAT_NONE) {
+         templ.format = format;
+         templ.tex_usage = tex_usage;
+
+         drawable->textures[i] =
+            screen->pipe_screen->texture_create(screen->pipe_screen, &templ);
+      }
+   }
+
+   drawable->old_w = width;
+   drawable->old_h = height;
+}
+
+/*
+ * Backend function for init_screen.
+ */
+
+static const __DRIextension *drisw_screen_extensions[] = {
+   NULL
+};
+
+static struct drisw_loader_funcs drisw_lf = {
+   .put_image = drisw_put_image
+};
+
+const __DRIconfig **
+drisw_init_screen(__DRIscreen * sPriv)
+{
+   const __DRIconfig **configs;
+   struct dri_screen *screen;
+   struct drisw_create_screen_arg arg;
+
+   screen = CALLOC_STRUCT(dri_screen);
+   if (!screen)
+      return NULL;
+
+   screen->api = drm_api_create();
+   screen->sPriv = sPriv;
+   screen->fd = -1;
+
+   sPriv->private = (void *)screen;
+   sPriv->extensions = drisw_screen_extensions;
+
+   arg.base.mode = DRM_CREATE_DRISW;
+   arg.lf = &drisw_lf;
+
+   configs = dri_init_screen_helper(screen, &arg.base, 32);
+   if (!configs)
+      goto fail;
+
+   return configs;
+fail:
+   dri_destroy_screen_helper(screen);
+   FREE(screen);
+   return NULL;
+}
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driSWRastExtension.base,
+    NULL
+};
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/sw/drisw.h b/src/gallium/state_trackers/dri/sw/drisw.h
new file mode 100644 (file)
index 0000000..c0c874f
--- /dev/null
@@ -0,0 +1,54 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef DRISW_H
+#define DRISW_H
+
+#include "dri_context.h"
+#include "dri_drawable.h"
+
+#include "state_tracker/st_api.h"
+#include "dri_wrapper.h"
+
+const __DRIconfig **
+drisw_init_screen(__DRIscreen * sPriv);
+
+void
+drisw_update_drawable_info(struct dri_drawable *drawable);
+
+void
+drisw_flush_frontbuffer(struct dri_drawable *drawable,
+                        enum st_attachment_type statt);
+
+void
+drisw_allocate_textures(struct dri_drawable *drawable,
+                        unsigned mask);
+
+void drisw_swap_buffers(__DRIdrawable * dPriv);
+
+#endif /* DRISW_H */
index e4972d493d6cf43d085c87f22011f478c672916f..5eabe10558a87795f48839b22e2b7f503442106d 100644 (file)
 
 #include "native.h"
 #include "egl_g3d.h"
+#include "egl_g3d_st.h"
 #include "egl_g3d_image.h"
-#include "egl_st.h"
-
-/**
- * Validate the draw/read surfaces of the context.
- */
-static void
-egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx)
-{
-   struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
-   struct pipe_screen *screen = gdpy->native->screen;
-   struct egl_g3d_context *gctx = egl_g3d_context(ctx);
-   const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = {
-      ST_SURFACE_FRONT_LEFT,
-      ST_SURFACE_BACK_LEFT,
-      ST_SURFACE_FRONT_RIGHT,
-      ST_SURFACE_BACK_RIGHT,
-   };
-   EGLint num_surfaces, s;
-
-   /* validate draw and/or read buffers */
-   num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2;
-   for (s = 0; s < num_surfaces; s++) {
-      struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
-      struct egl_g3d_surface *gsurf;
-      struct egl_g3d_buffer *gbuf;
-      EGLint att;
-
-      if (s == 0) {
-         gsurf = egl_g3d_surface(gctx->base.DrawSurface);
-         gbuf = &gctx->draw;
-      }
-      else {
-         gsurf = egl_g3d_surface(gctx->base.ReadSurface);
-         gbuf = &gctx->read;
-      }
-
-      if (!gctx->force_validate) {
-         unsigned int seq_num;
-
-         gsurf->native->validate(gsurf->native, gbuf->attachment_mask,
-               &seq_num, NULL, NULL, NULL);
-         /* skip validation */
-         if (gsurf->sequence_number == seq_num)
-            continue;
-      }
-
-      pipe_surface_reference(&gsurf->render_surface, NULL);
-      memset(textures, 0, sizeof(textures));
-
-      gsurf->native->validate(gsurf->native, gbuf->attachment_mask,
-            &gsurf->sequence_number, textures,
-            &gsurf->base.Width, &gsurf->base.Height);
-      for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
-         struct pipe_texture *pt = textures[att];
-         struct pipe_surface *ps;
-
-         if (native_attachment_mask_test(gbuf->attachment_mask, att) && pt) {
-            ps = screen->get_tex_surface(screen, pt, 0, 0, 0,
-                  PIPE_BUFFER_USAGE_GPU_READ |
-                  PIPE_BUFFER_USAGE_GPU_WRITE);
-            gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb,
-                  st_att_map[att], ps);
-
-            if (gsurf->render_att == att)
-               pipe_surface_reference(&gsurf->render_surface, ps);
-
-            pipe_surface_reference(&ps, NULL);
-            pipe_texture_reference(&pt, NULL);
-         }
-      }
-
-      gctx->stapi->st_resize_framebuffer(gbuf->st_fb,
-            gsurf->base.Width, gsurf->base.Height);
-   }
-
-   gctx->force_validate = EGL_FALSE;
-
-}
-
-/**
- * Create a st_framebuffer.
- */
-static struct st_framebuffer *
-create_framebuffer(_EGLContext *ctx, _EGLSurface *surf)
-{
-   struct egl_g3d_context *gctx = egl_g3d_context(ctx);
-   struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
-   struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config);
-
-   return gctx->stapi->st_create_framebuffer(&gconf->native->mode,
-         gconf->native->color_format, gconf->native->depth_format,
-         gconf->native->stencil_format,
-         gsurf->base.Width, gsurf->base.Height, &gsurf->base);
-}
-
-/**
- * Update the attachments of draw/read surfaces.
- */
-static void
-egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx)
-{
-   struct egl_g3d_context *gctx = egl_g3d_context(ctx);
-   EGLint s;
-
-   /* route draw and read buffers' attachments */
-   for (s = 0; s < 2; s++) {
-      struct egl_g3d_surface *gsurf;
-      struct egl_g3d_buffer *gbuf;
-
-      if (s == 0) {
-         gsurf = egl_g3d_surface(gctx->base.DrawSurface);
-         gbuf = &gctx->draw;
-      }
-      else {
-         gsurf = egl_g3d_surface(gctx->base.ReadSurface);
-         gbuf = &gctx->read;
-      }
-
-      gbuf->attachment_mask = (1 << gsurf->render_att);
-
-      /* FIXME OpenGL defaults to draw the front or back buffer when the
-       * context is single-buffered or double-buffered respectively.  In EGL,
-       * however, the buffer to be drawn is determined by the surface, instead
-       * of the context.  As a result, rendering to a pixmap surface with a
-       * double-buffered context does not work as expected.
-       *
-       * gctx->stapi->st_draw_front_buffer(gctx->st_ctx, natt ==
-       *    NATIVE_ATTACHMENT_FRONT_LEFT);
-       */
-
-      /*
-       * FIXME If the back buffer is asked for here, and the front buffer is
-       * later needed by the client API (e.g. glDrawBuffer is called to draw
-       * the front buffer), it will create a new pipe texture and draw there.
-       * One fix is to ask for both buffers here, but it would be a waste if
-       * the front buffer is never used.  A better fix is to add a callback to
-       * the pipe screen with context private (just like flush_frontbuffer).
-       */
-   }
-}
-
-/**
- * Reallocate the context's framebuffers after draw/read surfaces change.
- */
-static EGLBoolean
-egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx)
-{
-   struct egl_g3d_context *gctx = egl_g3d_context(ctx);
-   struct egl_g3d_surface *gdraw = egl_g3d_surface(gctx->base.DrawSurface);
-   struct egl_g3d_surface *gread = egl_g3d_surface(gctx->base.ReadSurface);
-
-   /* unreference the old framebuffers */
-   if (gctx->draw.st_fb) {
-      EGLBoolean is_equal = (gctx->draw.st_fb == gctx->read.st_fb);
-      void *priv;
-
-      priv = gctx->stapi->st_framebuffer_private(gctx->draw.st_fb);
-      if (!gdraw || priv != (void *) &gdraw->base) {
-         gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb);
-         gctx->draw.st_fb = NULL;
-         gctx->draw.attachment_mask = 0x0;
-      }
-
-      if (is_equal) {
-         gctx->read.st_fb = NULL;
-         gctx->draw.attachment_mask = 0x0;
-      }
-      else {
-         priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb);
-         if (!gread || priv != (void *) &gread->base) {
-            gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb);
-            gctx->read.st_fb = NULL;
-            gctx->draw.attachment_mask = 0x0;
-         }
-      }
-   }
-
-   if (!gdraw)
-      return EGL_TRUE;
-
-   /* create the draw fb */
-   if (!gctx->draw.st_fb) {
-      gctx->draw.st_fb = create_framebuffer(&gctx->base, &gdraw->base);
-      if (!gctx->draw.st_fb)
-         return EGL_FALSE;
-   }
-
-   /* create the read fb */
-   if (!gctx->read.st_fb) {
-      if (gread != gdraw) {
-         gctx->read.st_fb = create_framebuffer(&gctx->base, &gread->base);
-         if (!gctx->read.st_fb) {
-            gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb);
-            gctx->draw.st_fb = NULL;
-            return EGL_FALSE;
-         }
-      }
-      else {
-         /* there is no st_reference_framebuffer... */
-         gctx->read.st_fb = gctx->draw.st_fb;
-      }
-   }
-
-   egl_g3d_route_context(dpy, &gctx->base);
-   gctx->force_validate = EGL_TRUE;
-
-   return EGL_TRUE;
-}
 
 /**
  * Return the state tracker for the given context.
  */
-static const struct egl_g3d_st *
+static struct st_api *
 egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx)
 {
    struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
-   const struct egl_g3d_st *stapi;
+   struct st_api *stapi;
    EGLint idx = -1;
 
    switch (ctx->ClientAPI) {
    case EGL_OPENGL_ES_API:
       switch (ctx->ClientVersion) {
       case 1:
-         idx = EGL_G3D_ST_OPENGL_ES;
+         idx = ST_API_OPENGL_ES1;
          break;
       case 2:
-         idx = EGL_G3D_ST_OPENGL_ES2;
+         idx = ST_API_OPENGL_ES2;
          break;
       default:
          _eglLog(_EGL_WARNING, "unknown client version %d",
@@ -272,10 +65,10 @@ egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx)
       }
       break;
    case EGL_OPENVG_API:
-      idx = EGL_G3D_ST_OPENVG;
+      idx = ST_API_OPENVG;
       break;
    case EGL_OPENGL_API:
-      idx = EGL_G3D_ST_OPENGL;
+      idx = ST_API_OPENGL;
       break;
    default:
       _eglLog(_EGL_WARNING, "unknown client API 0x%04x", ctx->ClientAPI);
@@ -299,10 +92,10 @@ egl_g3d_init_st(_EGLDriver *drv)
    if (gdrv->api_mask)
       return;
 
-   for (i = 0; i < NUM_EGL_G3D_STS; i++) {
-      gdrv->stapis[i] = egl_g3d_get_st(i);
+   for (i = 0; i < ST_API_COUNT; i++) {
+      gdrv->stapis[i] = egl_g3d_create_st_api(i);
       if (gdrv->stapis[i])
-         gdrv->api_mask |= gdrv->stapis[i]->api_bit;
+         gdrv->api_mask |= egl_g3d_st_api_bit(i);
    }
 
    if (gdrv->api_mask)
@@ -351,35 +144,6 @@ egl_g3d_destroy_probe(_EGLDriver *drv, _EGLDisplay *dpy)
    }
 }
 
-/**
- * Return an API mask that consists of the state trackers that supports the
- * given mode.
- *
- * FIXME add st_is_mode_supported()?
- */
-static EGLint
-get_mode_api_mask(const __GLcontextModes *mode, EGLint api_mask)
-{
-   EGLint check;
-
-   /* OpenGL ES 1.x and 2.x are checked together */
-   check = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT;
-   if (api_mask & check) {
-      /* this is required by EGL, not by OpenGL ES */
-      if (mode->drawableType & GLX_WINDOW_BIT && !mode->doubleBufferMode)
-         api_mask &= ~check;
-   }
-
-   check = EGL_OPENVG_BIT;
-   if (api_mask & check) {
-      /* vega st needs the depth/stencil rb */
-      if (!mode->depthBits && !mode->stencilBits)
-         api_mask &= ~check;
-   }
-
-   return api_mask;
-}
-
 #ifdef EGL_MESA_screen_surface
 
 static void
@@ -443,19 +207,89 @@ egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy)
 
 #endif /* EGL_MESA_screen_surface */
 
+/**
+ * Initialize an EGL config from the native config.
+ */
+static EGLBoolean
+egl_g3d_init_config(_EGLDriver *drv, _EGLDisplay *dpy,
+                    _EGLConfig *conf, const struct native_config *nconf)
+{
+   struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
+   struct egl_g3d_config *gconf = egl_g3d_config(conf);
+   const __GLcontextModes *mode = &nconf->mode;
+   EGLint buffer_mask, api_mask;
+   EGLBoolean valid;
+   EGLint i;
+
+   buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK;
+   if (mode->doubleBufferMode)
+      buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
+   if (mode->stereoMode) {
+      buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK;
+      if (mode->doubleBufferMode)
+         buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
+   }
+
+   gconf->stvis.buffer_mask = buffer_mask;
+   gconf->stvis.color_format = nconf->color_format;
+   gconf->stvis.depth_stencil_format = nconf->depth_format;
+   gconf->stvis.accum_format = PIPE_FORMAT_NONE;
+   gconf->stvis.samples = 0;
+
+   gconf->stvis.render_buffer = (buffer_mask & ST_ATTACHMENT_BACK_LEFT) ?
+      ST_ATTACHMENT_BACK_LEFT : ST_ATTACHMENT_FRONT_LEFT;
+
+   api_mask = 0;
+   for (i = 0; i < ST_API_COUNT; i++) {
+      struct st_api *stapi = gdrv->stapis[i];
+      if (stapi) {
+         if (stapi->is_visual_supported(stapi, &gconf->stvis))
+            api_mask |= egl_g3d_st_api_bit(i);
+      }
+   }
+   /* this is required by EGL, not by OpenGL ES */
+   if ((mode->drawableType & GLX_WINDOW_BIT) && !mode->doubleBufferMode)
+      api_mask &= ~(EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT);
+
+   if (!api_mask) {
+      _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x",
+            mode->visualID);
+   }
+
+   valid = _eglConfigFromContextModesRec(&gconf->base,
+         mode, api_mask, api_mask);
+   if (valid) {
+#ifdef EGL_MESA_screen_surface
+      /* check if scanout surface bit is set */
+      if (nconf->scanout_bit) {
+         EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE);
+         val |= EGL_SCREEN_BIT_MESA;
+         SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val);
+      }
+#endif
+      valid = _eglValidateConfig(&gconf->base, EGL_FALSE);
+   }
+   if (!valid) {
+      _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", mode->visualID);
+      return EGL_FALSE;
+   }
+
+   gconf->native = nconf;
+
+   return EGL_TRUE;
+}
+
 /**
  * Add configs to display and return the next config ID.
  */
 static EGLint
 egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id)
 {
-   struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
    struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
    const struct native_config **native_configs;
    int num_configs, i;
 
-   native_configs = gdpy->native->get_configs(gdpy->native,
-         &num_configs);
+   native_configs = gdpy->native->get_configs(gdpy->native, &num_configs);
    if (!num_configs) {
       if (native_configs)
          free(native_configs);
@@ -463,61 +297,25 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id)
    }
 
    for (i = 0; i < num_configs; i++) {
-      EGLint api_mask;
       struct egl_g3d_config *gconf;
-      EGLBoolean valid;
 
       gconf = CALLOC_STRUCT(egl_g3d_config);
-      if (!gconf)
-         continue;
-
-      _eglInitConfig(&gconf->base, dpy, id);
-
-      api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask);
-      if (!api_mask) {
-         _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x",
-               native_configs[i]->mode.visualID);
-      }
-
-      valid = _eglConfigFromContextModesRec(&gconf->base,
-            &native_configs[i]->mode, api_mask, api_mask);
-      if (valid) {
-#ifdef EGL_MESA_screen_surface
-         /* check if scanout surface bit is set */
-         if (native_configs[i]->scanout_bit) {
-            EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE);
-            val |= EGL_SCREEN_BIT_MESA;
-            SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val);
+      if (gconf) {
+         _eglInitConfig(&gconf->base, dpy, id);
+         if (!egl_g3d_init_config(drv, dpy, &gconf->base, native_configs[i])) {
+            free(gconf);
+            continue;
          }
-#endif
-         valid = _eglValidateConfig(&gconf->base, EGL_FALSE);
-      }
-      if (!valid) {
-         _eglLog(_EGL_DEBUG, "skip invalid config 0x%x",
-               native_configs[i]->mode.visualID);
-         free(gconf);
-         continue;
-      }
 
-      gconf->native = native_configs[i];
-      _eglAddConfig(dpy, &gconf->base);
-      id++;
+         _eglAddConfig(dpy, &gconf->base);
+         id++;
+      }
    }
 
    free(native_configs);
    return id;
 }
 
-/**
- * Re-validate the context.
- */
-static void
-egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private)
-{
-   struct egl_g3d_context *gctx = egl_g3d_context(context_private);
-   egl_g3d_validate_context(gctx->base.Resource.Display, &gctx->base);
-}
-
 static void
 egl_g3d_invalid_surface(struct native_display *ndpy,
                         struct native_surface *nsurf,
@@ -525,11 +323,15 @@ 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 = egl_g3d_context(gsurf->base.CurrentContext);
-
-   /* set force_validate to skip an unnecessary check */
+   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->force_validate = TRUE;
+      gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi, gsurf->stfbi);
 }
 
 static struct native_event_handler egl_g3d_native_event_handler = {
@@ -545,6 +347,9 @@ egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
    _eglReleaseDisplayResources(drv, dpy);
    _eglCleanupDisplay(dpy);
 
+   if (gdpy->pipe)
+      gdpy->pipe->destroy(gdpy->pipe);
+
    if (dpy->Screens) {
       for (i = 0; i < dpy->NumScreens; i++) {
          struct egl_g3d_screen *gscr = egl_g3d_screen(dpy->Screens[i]);
@@ -554,6 +359,9 @@ egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
       free(dpy->Screens);
    }
 
+   if (gdpy->smapi)
+      egl_g3d_destroy_st_manager(gdpy->smapi);
+
    if (gdpy->native)
       gdpy->native->destroy(gdpy->native);
 
@@ -588,11 +396,17 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
    }
 
    gdpy->native->user_data = (void *) dpy;
-   gdpy->native->screen->update_buffer = egl_g3d_update_buffer;
 
    egl_g3d_init_st(&gdrv->base);
    dpy->ClientAPIsMask = gdrv->api_mask;
 
+   gdpy->smapi = egl_g3d_create_st_manager(dpy);
+   if (!gdpy->smapi) {
+      _eglError(EGL_NOT_INITIALIZED,
+            "eglInitialize(failed to create st manager)");
+      goto fail;
+   }
+
 #ifdef EGL_MESA_screen_surface
    /* enable MESA_screen_surface before adding (and validating) configs */
    if (gdpy->native->modeset) {
@@ -629,7 +443,6 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
    struct egl_g3d_context *gshare = egl_g3d_context(share);
    struct egl_g3d_config *gconf = egl_g3d_config(conf);
    struct egl_g3d_context *gctx;
-   const __GLcontextModes *mode;
 
    gctx = CALLOC_STRUCT(egl_g3d_context);
    if (!gctx) {
@@ -648,24 +461,14 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
       return NULL;
    }
 
-   mode = &gconf->native->mode;
-
-   gctx->pipe = gdpy->native->screen->context_create(
-      gdpy->native->screen,
-      (void *) &gctx->base);
-
-   if (!gctx->pipe) {
+   gctx->stctxi = gctx->stapi->create_context(gctx->stapi, gdpy->smapi,
+         &gconf->stvis, (gshare) ? gshare->stctxi : NULL);
+   if (!gctx->stctxi) {
       free(gctx);
       return NULL;
    }
 
-   gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode,
-                        (gshare) ? gshare->st_ctx : NULL);
-   if (!gctx->st_ctx) {
-      gctx->pipe->destroy(gctx->pipe);
-      free(gctx);
-      return NULL;
-   }
+   gctx->stctxi->st_manager_private = (void *) &gctx->base;
 
    return &gctx->base;
 }
@@ -682,9 +485,7 @@ destroy_context(_EGLDisplay *dpy, _EGLContext *ctx)
    if (!dpy->Initialized)
       _eglLog(_EGL_FATAL, "destroy a context with an unitialized display");
 
-   egl_g3d_realloc_context(dpy, &gctx->base);
-   /* it will destroy the associated pipe context */
-   gctx->stapi->st_destroy_context(gctx->st_ctx);
+   gctx->stctxi->destroy(gctx->stctxi);
 
    free(gctx);
 }
@@ -786,14 +587,20 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
       return NULL;
    }
 
+   gsurf->stvis = gconf->stvis;
+   if (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER)
+      gsurf->stvis.render_buffer = ST_ATTACHMENT_FRONT_LEFT;
+
+   gsurf->stfbi = egl_g3d_create_st_framebuffer(&gsurf->base);
+   if (!gsurf->stfbi) {
+      gsurf->native->destroy(gsurf->native);
+      free(gsurf);
+      return NULL;
+   }
+
    nsurf->user_data = &gsurf->base;
    gsurf->native = nsurf;
 
-   gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER) ?
-      NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT;
-   if (!gconf->native->mode.doubleBufferMode)
-      gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT;
-
    return &gsurf->base;
 }
 
@@ -849,7 +656,8 @@ destroy_surface(_EGLDisplay *dpy, _EGLSurface *surf)
    if (!dpy->Initialized)
       _eglLog(_EGL_FATAL, "destroy a surface with an unitialized display");
 
-   pipe_surface_reference(&gsurf->render_surface, NULL);
+   pipe_texture_reference(&gsurf->render_texture, NULL);
+   egl_g3d_destroy_st_framebuffer(gsurf->stfbi);
    gsurf->native->destroy(gsurf->native);
    free(gsurf);
 }
@@ -868,6 +676,7 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy,
 {
    struct egl_g3d_context *gctx = egl_g3d_context(ctx);
    struct egl_g3d_surface *gdraw = egl_g3d_surface(draw);
+   struct egl_g3d_surface *gread = egl_g3d_surface(read);
    struct egl_g3d_context *old_gctx;
    EGLBoolean ok = EGL_TRUE;
 
@@ -878,39 +687,29 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy,
 
    if (old_gctx) {
       /* flush old context */
-      old_gctx->stapi->st_flush(old_gctx->st_ctx,
+      old_gctx->stctxi->flush(old_gctx->stctxi,
             PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
-
-      /*
-       * The old context is no longer current, and egl_g3d_realloc_context()
-       * should be called to destroy the framebuffers.  However, it is possible
-       * that it will be made current again with the same draw/read surfaces.
-       * It might be better to keep it around.
-       */
    }
 
    if (gctx) {
-      ok = egl_g3d_realloc_context(dpy, &gctx->base);
+      ok = gctx->stapi->make_current(gctx->stapi, gctx->stctxi,
+            (gdraw) ? gdraw->stfbi : NULL, (gread) ? gread->stfbi : NULL);
       if (ok) {
-         /* XXX: need to pass the winsys argument for
-          * flush_frontbuffer in the fourth parameter here:
-          */
-         ok = gctx->stapi->st_make_current(gctx->st_ctx,
-                                           gctx->draw.st_fb,
-                                           gctx->read.st_fb,
-                                           NULL);
-         if (ok) {
-            egl_g3d_validate_context(dpy, &gctx->base);
-            if (gdraw->base.Type == EGL_WINDOW_BIT) {
-               gctx->base.WindowRenderBuffer =
-                  (gdraw->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) ?
-                  EGL_SINGLE_BUFFER : EGL_BACK_BUFFER;
-            }
+         gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi, gdraw->stfbi);
+         if (gread != gdraw) {
+            gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi,
+                  gread->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;
          }
       }
    }
    else if (old_gctx) {
-      ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL, NULL);
+      ok = old_gctx->stapi->make_current(old_gctx->stapi, NULL, NULL, NULL);
       old_gctx->base.WindowRenderBuffer = EGL_NONE;
    }
 
@@ -937,15 +736,17 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
       return EGL_TRUE;
 
    /* or when the surface is single-buffered */
-   if (gsurf->render_att == NATIVE_ATTACHMENT_FRONT_LEFT)
+   if (gsurf->stvis.render_buffer == ST_ATTACHMENT_FRONT_LEFT)
       return EGL_TRUE;
 
    if (ctx && ctx->DrawSurface == surf)
       gctx = egl_g3d_context(ctx);
 
    /* flush if the surface is current */
-   if (gctx)
-      gctx->stapi->st_notify_swapbuffers(gctx->draw.st_fb);
+   if (gctx) {
+      gctx->stctxi->flush(gctx->stctxi,
+            PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
+   }
 
    return gsurf->native->swap_buffers(gsurf->native);
 }
@@ -985,7 +786,7 @@ get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf,
       return NULL;
 
    psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt],
-         0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE);
+         0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
    pipe_texture_reference(&textures[natt], NULL);
 
    return psurf;
@@ -1003,7 +804,7 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
    struct pipe_screen *screen = gdpy->native->screen;
    struct pipe_surface *psurf;
 
-   if (!gsurf->render_surface)
+   if (!gsurf->render_texture)
       return EGL_TRUE;
 
    gconf = egl_g3d_config(egl_g3d_find_pixmap_config(dpy, target));
@@ -1018,26 +819,33 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
    /* flush if the surface is current */
    if (ctx && ctx->DrawSurface == &gsurf->base) {
       struct egl_g3d_context *gctx = egl_g3d_context(ctx);
-      gctx->stapi->st_flush(gctx->st_ctx,
+      gctx->stctxi->flush(gctx->stctxi,
             PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
    }
 
+   /* create a pipe context to copy surfaces */
+   if (!gdpy->pipe) {
+      gdpy->pipe =
+         gdpy->native->screen->context_create(gdpy->native->screen, NULL);
+      if (!gdpy->pipe)
+         return EGL_FALSE;
+   }
+
    psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
    if (psurf) {
-      struct pipe_context pipe;
+      struct pipe_surface *psrc;
 
-      /**
-       * XXX This is hacky.  If we might allow the EGLDisplay to create a pipe
-       * context of its own and use the blitter context for this.
-       */
-      memset(&pipe, 0, sizeof(pipe));
-      pipe.screen = screen;
+      psrc = screen->get_tex_surface(screen, gsurf->render_texture,
+            0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
+      if (psrc) {
+         gdpy->pipe->surface_copy(gdpy->pipe, psurf, 0, 0,
+               psrc, 0, 0, psurf->width, psurf->height);
+         pipe_surface_reference(&psrc, NULL);
 
-      util_surface_copy(&pipe, FALSE, psurf, 0, 0,
-            gsurf->render_surface, 0, 0, psurf->width, psurf->height);
+         nsurf->flush_frontbuffer(nsurf);
+      }
 
       pipe_surface_reference(&psurf, NULL);
-      nsurf->flush_frontbuffer(nsurf);
    }
 
    nsurf->destroy(nsurf);
@@ -1048,8 +856,16 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
 static EGLBoolean
 egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
 {
+   struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
    struct egl_g3d_context *gctx = egl_g3d_context(ctx);
-   gctx->stapi->st_finish(gctx->st_ctx);
+   struct pipe_screen *screen = gdpy->native->screen;
+   struct pipe_fence_handle *fence = NULL;
+
+   gctx->stctxi->flush(gctx->stctxi,
+         PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
+   screen->fence_finish(screen, fence, 0);
+   screen->fence_reference(screen, &fence, NULL);
+
    return EGL_TRUE;
 }
 
@@ -1079,10 +895,10 @@ egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname)
    /* in case this is called before a display is initialized */
    egl_g3d_init_st(&gdrv->base);
 
-   for (i = 0; i < NUM_EGL_G3D_STS; i++) {
-      const struct egl_g3d_st *stapi = gdrv->stapis[i];
+   for (i = 0; i < ST_API_COUNT; i++) {
+      struct st_api *stapi = gdrv->stapis[i];
       if (stapi) {
-         proc = (_EGLProc) stapi->st_get_proc_address(procname);
+         proc = (_EGLProc) stapi->get_proc_address(stapi, procname);
          if (proc)
             return proc;
       }
@@ -1098,8 +914,8 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,
    struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
    _EGLContext *es1 = _eglGetAPIContext(EGL_OPENGL_ES_API);
    struct egl_g3d_context *gctx;
-   enum pipe_format target_format;
-   int target;
+   enum pipe_format internal_format;
+   enum st_texture_type target;
 
    if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT)
       return _eglError(EGL_BAD_SURFACE, "eglBindTexImage");
@@ -1110,10 +926,10 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,
 
    switch (gsurf->base.TextureFormat) {
    case EGL_TEXTURE_RGB:
-      target_format = PIPE_FORMAT_R8G8B8_UNORM;
+      internal_format = PIPE_FORMAT_R8G8B8_UNORM;
       break;
    case EGL_TEXTURE_RGBA:
-      target_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+      internal_format = PIPE_FORMAT_B8G8R8A8_UNORM;
       break;
    default:
       return _eglError(EGL_BAD_MATCH, "eglBindTexImage");
@@ -1129,21 +945,24 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,
 
    if (!es1)
       return EGL_TRUE;
-   if (!gsurf->render_surface)
+   if (!gsurf->render_texture)
       return EGL_FALSE;
 
    /* flush properly if the surface is bound */
    if (gsurf->base.CurrentContext) {
       gctx = egl_g3d_context(gsurf->base.CurrentContext);
-      gctx->stapi->st_flush(gctx->st_ctx,
+      gctx->stctxi->flush(gctx->stctxi,
             PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
    }
 
    gctx = egl_g3d_context(es1);
-   gctx->stapi->st_bind_texture_surface(gsurf->render_surface,
-         target, gsurf->base.MipmapLevel, target_format);
-
-   gsurf->base.BoundToTexture = EGL_TRUE;
+   if (gctx->stctxi->teximage) {
+      if (!gctx->stctxi->teximage(gctx->stctxi, target,
+               gsurf->base.MipmapLevel, internal_format,
+               gsurf->render_texture, gsurf->base.MipmapTexture))
+         return EGL_FALSE;
+      gsurf->base.BoundToTexture = EGL_TRUE;
+   }
 
    return EGL_TRUE;
 }
@@ -1160,14 +979,15 @@ egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,
    if (buffer != EGL_BACK_BUFFER)
       return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage");
 
-   if (gsurf->render_surface) {
+   if (gsurf->render_texture) {
       _EGLContext *ctx = _eglGetAPIContext(EGL_OPENGL_ES_API);
       struct egl_g3d_context *gctx = egl_g3d_context(ctx);
 
       /* what if the context the surface binds to is no longer current? */
-      if (gctx)
-         gctx->stapi->st_unbind_texture_surface(gsurf->render_surface,
-               ST_TEXTURE_2D, gsurf->base.MipmapLevel);
+      if (gctx) {
+         gctx->stctxi->teximage(gctx->stctxi, ST_TEXTURE_2D,
+               gsurf->base.MipmapLevel, PIPE_FORMAT_NONE, NULL, FALSE);
+      }
    }
 
    gsurf->base.BoundToTexture = EGL_FALSE;
@@ -1279,6 +1099,12 @@ static void
 egl_g3d_unload(_EGLDriver *drv)
 {
    struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
+   EGLint i;
+
+   for (i = 0; i < ST_API_COUNT; i++) {
+      if (gdrv->stapis[i])
+         gdrv->stapis[i]->destroy(gdrv->stapis[i]);
+   }
 
    egl_g3d_destroy_probe(drv, NULL);
    free(gdrv);
index e3e55e46d3b586053fdb379175ae277012ae9d14..2788f1bf4ac4e7a90d6953f21d75978a751b9927 100644 (file)
 #include "eglmode.h"
 
 #include "native.h"
-#include "egl_st.h"
+#include "egl_g3d_st.h"
 
 struct egl_g3d_driver {
    _EGLDriver base;
-   const struct egl_g3d_st *stapis[NUM_EGL_G3D_STS];
+   struct st_api *stapis[ST_API_COUNT];
    EGLint api_mask;
 
    EGLint probe_key;
@@ -51,35 +51,34 @@ struct egl_g3d_driver {
 
 struct egl_g3d_display {
    struct native_display *native;
-};
 
-struct egl_g3d_buffer {
-   struct st_framebuffer *st_fb;
-   uint attachment_mask;
+   struct st_manager *smapi;
+   struct pipe_context *pipe;
 };
 
 struct egl_g3d_context {
    _EGLContext base;
 
-   const struct egl_g3d_st *stapi;
-   struct pipe_context *pipe;
+   struct st_api *stapi;
 
-   struct st_context *st_ctx;
-   EGLBoolean force_validate;
-   struct egl_g3d_buffer draw, read;
+   struct st_context_iface *stctxi;
 };
 
 struct egl_g3d_surface {
    _EGLSurface base;
+
+   struct st_visual stvis;
+   struct st_framebuffer_iface *stfbi;
+
    struct native_surface *native;
-   enum native_attachment render_att;
-   struct pipe_surface *render_surface;
+   struct pipe_texture *render_texture;
    unsigned int sequence_number;
 };
 
 struct egl_g3d_config {
    _EGLConfig base;
    const struct native_config *native;
+   struct st_visual stvis;
 };
 
 struct egl_g3d_image {
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
new file mode 100644 (file)
index 0000000..3609409
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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_memory.h"
+#include "util/u_inlines.h"
+#include "util/u_dl.h"
+#include "eglimage.h"
+#include "eglmutex.h"
+
+#include "egl_g3d.h"
+#include "egl_g3d_st.h"
+
+struct egl_g3d_st_manager {
+   struct st_manager base;
+   _EGLDisplay *display;
+};
+
+static INLINE struct egl_g3d_st_manager *
+egl_g3d_st_manager(struct st_manager *smapi)
+{
+   return (struct egl_g3d_st_manager *) smapi;
+}
+
+struct st_api *
+egl_g3d_create_st_api(enum st_api_type api)
+{
+   const char *stmod_name;
+   struct util_dl_library *lib;
+   const struct st_module *mod;
+
+   switch (api) {
+   case ST_API_OPENGL:
+      stmod_name = ST_MODULE_OPENGL_SYMBOL;
+      break;
+   case ST_API_OPENGL_ES1:
+      stmod_name = ST_MODULE_OPENGL_ES1_SYMBOL;
+      break;
+   case ST_API_OPENGL_ES2:
+      stmod_name = ST_MODULE_OPENGL_ES2_SYMBOL;
+      break;
+   case ST_API_OPENVG:
+      stmod_name = ST_MODULE_OPENVG_SYMBOL;
+      break;
+   default:
+      stmod_name = NULL;
+      break;
+   }
+   if (!stmod_name)
+      return NULL;
+
+   mod = NULL;
+   lib = util_dl_open(NULL);
+   if (lib) {
+      mod = (const struct st_module *)
+         util_dl_get_proc_address(lib, stmod_name);
+      util_dl_close(lib);
+   }
+   if (!mod || mod->api != api)
+      return NULL;
+
+   return mod->create_api();
+}
+
+struct st_manager *
+egl_g3d_create_st_manager(_EGLDisplay *dpy)
+{
+   struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+   struct egl_g3d_st_manager *gsmapi;
+
+   gsmapi = CALLOC_STRUCT(egl_g3d_st_manager);
+   if (gsmapi) {
+      gsmapi->display = dpy;
+
+      gsmapi->base.screen = gdpy->native->screen;
+   }
+
+   return &gsmapi->base;;
+}
+
+void
+egl_g3d_destroy_st_manager(struct st_manager *smapi)
+{
+   struct egl_g3d_st_manager *gsmapi = egl_g3d_st_manager(smapi);
+   free(gsmapi);
+}
+
+static boolean
+egl_g3d_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
+                                   enum st_attachment_type statt)
+{
+   _EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private;
+   struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+
+   return gsurf->native->flush_frontbuffer(gsurf->native);
+}
+
+static boolean 
+egl_g3d_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
+                                const enum st_attachment_type *statts,
+                                unsigned count,
+                                struct pipe_texture **out)
+{
+   _EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private;
+   struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+   struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+   uint attachment_mask = 0;
+   unsigned i;
+
+   for (i = 0; i < count; i++) {
+      int natt;
+
+      switch (statts[i]) {
+      case ST_ATTACHMENT_FRONT_LEFT:
+         natt = NATIVE_ATTACHMENT_FRONT_LEFT;
+         break;
+      case ST_ATTACHMENT_BACK_LEFT:
+         natt = NATIVE_ATTACHMENT_BACK_LEFT;
+         break;
+      case ST_ATTACHMENT_FRONT_RIGHT:
+         natt = NATIVE_ATTACHMENT_FRONT_RIGHT;
+         break;
+      case ST_ATTACHMENT_BACK_RIGHT:
+         natt = NATIVE_ATTACHMENT_BACK_RIGHT;
+      default:
+         natt = -1;
+         break;
+      }
+
+      if (natt >= 0)
+         attachment_mask |= 1 << natt;
+   }
+
+   if (!gsurf->native->validate(gsurf->native, attachment_mask,
+         &gsurf->sequence_number, textures, &gsurf->base.Width,
+         &gsurf->base.Height))
+      return FALSE;
+
+   for (i = 0; i < count; i++) {
+      struct pipe_texture *tex;
+      int natt;
+
+      switch (statts[i]) {
+      case ST_ATTACHMENT_FRONT_LEFT:
+         natt = NATIVE_ATTACHMENT_FRONT_LEFT;
+         break;
+      case ST_ATTACHMENT_BACK_LEFT:
+         natt = NATIVE_ATTACHMENT_BACK_LEFT;
+         break;
+      case ST_ATTACHMENT_FRONT_RIGHT:
+         natt = NATIVE_ATTACHMENT_FRONT_RIGHT;
+         break;
+      case ST_ATTACHMENT_BACK_RIGHT:
+         natt = NATIVE_ATTACHMENT_BACK_RIGHT;
+         break;
+      default:
+         natt = -1;
+         break;
+      }
+
+      if (natt >= 0) {
+         tex = textures[natt];
+
+         if (statts[i] == stfbi->visual->render_buffer)
+            pipe_texture_reference(&gsurf->render_texture, tex);
+
+         if (attachment_mask & (1 << natt)) {
+            /* transfer the ownership to the caller */
+            out[i] = tex;
+            attachment_mask &= ~(1 << natt);
+         }
+         else {
+            /* the attachment is listed more than once */
+            pipe_texture_reference(&out[i], tex);
+         }
+      }
+   }
+
+   return TRUE;
+}
+
+struct st_framebuffer_iface *
+egl_g3d_create_st_framebuffer(_EGLSurface *surf)
+{
+   struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+   struct st_framebuffer_iface *stfbi;
+
+   stfbi = CALLOC_STRUCT(st_framebuffer_iface);
+   if (!stfbi)
+      return NULL;
+
+   stfbi->visual = &gsurf->stvis;
+   stfbi->flush_front = egl_g3d_st_framebuffer_flush_front;
+   stfbi->validate = egl_g3d_st_framebuffer_validate;
+   stfbi->st_manager_private = (void *) &gsurf->base;
+
+   return stfbi;
+}
+
+void
+egl_g3d_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
+{
+   free(stfbi);
+}
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.h b/src/gallium/state_trackers/egl/common/egl_g3d_st.h
new file mode 100644 (file)
index 0000000..ea8b406
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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>
+ */
+
+#ifndef _EGL_G3D_ST_H_
+#define _EGL_G3D_ST_H_
+
+#include "pipe/p_compiler.h"
+#include "state_tracker/st_api.h"
+#include "egltypedefs.h"
+
+struct st_api *
+egl_g3d_create_st_api(enum st_api_type api);
+
+struct st_manager *
+egl_g3d_create_st_manager(_EGLDisplay *dpy);
+
+void
+egl_g3d_destroy_st_manager(struct st_manager *smapi);
+
+struct st_framebuffer_iface *
+egl_g3d_create_st_framebuffer(_EGLSurface *surf);
+
+void
+egl_g3d_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi);
+
+/**
+ * Return the EGL_<api>_BIT of the st api.
+ */
+static INLINE int
+egl_g3d_st_api_bit(enum st_api_type api)
+{
+   int bit;
+
+   switch (api) {
+   case ST_API_OPENGL:
+      bit = EGL_OPENGL_BIT;
+      break;
+   case ST_API_OPENGL_ES1:
+      bit = EGL_OPENGL_ES_BIT;
+      break;
+   case ST_API_OPENGL_ES2:
+      bit = EGL_OPENGL_ES2_BIT;
+      break;
+   case ST_API_OPENVG:
+      bit = EGL_OPENVG_BIT;
+      break;
+   default:
+      bit = 0;
+      break;
+   }
+
+   return bit;
+}
+
+#endif /* _EGL_G3D_ST_H_ */
diff --git a/src/gallium/state_trackers/egl/common/egl_st.c b/src/gallium/state_trackers/egl/common/egl_st.c
deleted file mode 100644 (file)
index a88ff91..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  7.8
- *
- * Copyright (C) 2009-2010 Chia-I Wu <olv@0xlab.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <dlfcn.h>
-#include "pipe/p_compiler.h"
-#include "util/u_memory.h"
-#include "egllog.h"
-#include "EGL/egl.h" /* for EGL_api_BIT */
-
-#include "egl_st.h"
-
-#ifndef HAVE_DLADDR
-#define HAVE_DLADDR 1
-#endif
-
-#if HAVE_DLADDR
-
-static const char *
-egl_g3d_st_names[] = {
-#define ST_PUBLIC(name, ...) #name,
-#include "st_public_tmp.h"
-   NULL
-};
-
-static boolean
-egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym)
-{
-   st_proc *procs = (st_proc *) stapi;
-   void *handle;
-   Dl_info info;
-   const char **name;
-
-   if (!dladdr(sym, &info))
-      return FALSE;
-   handle = dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE);
-   if (!handle)
-      return FALSE;
-
-   for (name = egl_g3d_st_names; *name; name++) {
-      st_proc proc = (st_proc) dlsym(handle, *name);
-      if (!proc) {
-         _eglLog(_EGL_WARNING, "%s is missing in %s", *name, info.dli_fname);
-         memset(stapi, 0, sizeof(*stapi));
-         dlclose(handle);
-         return FALSE;
-      }
-      *procs++ = proc;
-   }
-
-   dlclose(handle);
-   return TRUE;
-}
-
-#else /* HAVE_DLADDR */
-
-static boolean
-egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym)
-{
-#define ST_PUBLIC(name, ...) stapi->name = name;
-#include "st_public_tmp.h"
-   return TRUE;
-}
-
-#endif /* HAVE_DLADDR */
-
-static boolean
-egl_g3d_init_st(struct egl_g3d_st *stapi, const char *api)
-{
-   void *handle, *sym;
-   boolean res = FALSE;
-
-   /* already initialized */
-   if (stapi->st_notify_swapbuffers != NULL)
-      return TRUE;
-
-   handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
-   if (!handle)
-      return FALSE;
-
-   sym = dlsym(handle, api);
-   if (sym && egl_g3d_fill_st(stapi, sym))
-      res = TRUE;
-
-   dlclose(handle);
-   return res;
-}
-
-static struct {
-   const char *symbol;
-   EGLint api_bit;
-} egl_g3d_st_info[NUM_EGL_G3D_STS] = {
-   { "st_api_OpenGL_ES1",  EGL_OPENGL_ES_BIT },
-   { "st_api_OpenVG",      EGL_OPENVG_BIT },
-   { "st_api_OpenGL_ES2",  EGL_OPENGL_ES2_BIT },
-   { "st_api_OpenGL",      EGL_OPENGL_BIT },
-};
-
-const struct egl_g3d_st *
-egl_g3d_get_st(enum egl_g3d_st_api api)
-{
-   static struct egl_g3d_st all_trackers[NUM_EGL_G3D_STS];
-
-   if (egl_g3d_init_st(&all_trackers[api], egl_g3d_st_info[api].symbol)) {
-      all_trackers[api].api_bit = egl_g3d_st_info[api].api_bit;
-      return &all_trackers[api];
-   }
-   else {
-      return NULL;
-   }
-}
diff --git a/src/gallium/state_trackers/egl/common/egl_st.h b/src/gallium/state_trackers/egl/common/egl_st.h
deleted file mode 100644 (file)
index 8fb464b..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  7.8
- *
- * Copyright (C) 2009-2010 Chia-I Wu <olv@0xlab.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _EGL_ST_H_
-#define _EGL_ST_H_
-
-#include "GL/gl.h" /* for GL types */
-#include "GL/internal/glcore.h"  /* for __GLcontextModes */
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-
-/* avoid calling st functions directly */
-#if 1
-
-#define ST_SURFACE_FRONT_LEFT   0
-#define ST_SURFACE_BACK_LEFT    1
-#define ST_SURFACE_FRONT_RIGHT  2
-#define ST_SURFACE_BACK_RIGHT   3
-
-#define ST_TEXTURE_2D    0x2
-
-struct st_context;
-struct st_framebuffer;
-typedef void (*st_proc)();
-
-#else
-#include "state_tracker/st_public.h"
-#endif
-
-/* remember to update egl_g3d_get_st() when update the enums */
-enum egl_g3d_st_api {
-   EGL_G3D_ST_OPENGL_ES = 0,
-   EGL_G3D_ST_OPENVG,
-   EGL_G3D_ST_OPENGL_ES2,
-   EGL_G3D_ST_OPENGL,
-
-   NUM_EGL_G3D_STS
-};
-
-struct egl_g3d_st {
-#define ST_PUBLIC(name, ret, ...) ret (*name)(__VA_ARGS__);
-#include "st_public_tmp.h"
-   /* fields must be added here */
-   EGLint api_bit;
-};
-
-const struct egl_g3d_st *
-egl_g3d_get_st(enum egl_g3d_st_api api);
-
-#endif /* _EGL_ST_H_ */
diff --git a/src/gallium/state_trackers/egl/common/st_public_tmp.h b/src/gallium/state_trackers/egl/common/st_public_tmp.h
deleted file mode 100644 (file)
index 562dd68..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-ST_PUBLIC(st_create_context,              struct st_context *,       struct pipe_context *pipe, const __GLcontextModes *visual, struct st_context *share)
-ST_PUBLIC(st_destroy_context,             void,                      struct st_context *st)
-ST_PUBLIC(st_copy_context_state,          void,                      struct st_context *dst, struct st_context *src, uint mask)
-ST_PUBLIC(st_create_framebuffer,          struct st_framebuffer *,   const __GLcontextModes *visual, enum pipe_format colorFormat, enum pipe_format depthFormat, enum pipe_format stencilFormat, uint width, uint height, void *privateData)
-ST_PUBLIC(st_resize_framebuffer,          void,                      struct st_framebuffer *stfb, uint width, uint height)
-ST_PUBLIC(st_set_framebuffer_surface,     void,                      struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf)
-ST_PUBLIC(st_get_framebuffer_dimensions,  void,                      struct st_framebuffer *stfb, uint *width, uint *height)
-ST_PUBLIC(st_get_framebuffer_surface,     int,                       struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface **surface)
-ST_PUBLIC(st_get_framebuffer_texture,     int,                       struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture)
-ST_PUBLIC(st_framebuffer_private,         void *,                    struct st_framebuffer *stfb)
-ST_PUBLIC(st_unreference_framebuffer,     void,                      struct st_framebuffer *stfb)
-ST_PUBLIC(st_make_current,                GLboolean,                 struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read, void *winsys_drawable_handle)
-ST_PUBLIC(st_get_current,                 struct st_context *,       void)
-ST_PUBLIC(st_flush,                       void,                      struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence)
-ST_PUBLIC(st_finish,                      void,                      struct st_context *st)
-ST_PUBLIC(st_notify_swapbuffers,          void,                      struct st_framebuffer *stfb)
-ST_PUBLIC(st_bind_texture_surface,        int,                       struct pipe_surface *ps, int target, int level, enum pipe_format format)
-ST_PUBLIC(st_unbind_texture_surface,      int,                       struct pipe_surface *ps, int target, int level)
-ST_PUBLIC(st_get_proc_address,            st_proc,                   const char *procname)
-#undef ST_PUBLIC
index b03655127190fbc8efcf718981f32be10adc3d97..089d4411675c76c17650e8d38fda675cf244061c 100644 (file)
@@ -38,6 +38,8 @@ SYS_LIBS = -lm -pthread
 
 
 INCLUDE_DIRS = \
+       -I$(TOP)/include \
+       -I$(TOP)/src/mesa \
        -I$(TOP)/src/gallium/include
 
 .c.o:
index 25bc53b21eb660d34b649f582e7e3975796379a2..4e89e06b34cdd00a851a19ea1c9afff0bfdf1fb1 100644 (file)
@@ -1,3 +1,8 @@
-#include "pipe/p_compiler.h"
+#include "state_tracker/st_manager.h"
 
 PUBLIC const int st_api_OpenGL_ES1 = 1;
+
+PUBLIC const struct st_module st_module_OpenGL_ES1 = {
+   .api = ST_API_OPENGL_ES1,
+   .create_api = st_manager_create_api
+};
index 171ea62b97ff03c556d2bce7bfe64c79ebf04972..82e88b176ac2663c60e1aa601b8798a5c52d1733 100644 (file)
@@ -1,3 +1,8 @@
-#include "pipe/p_compiler.h"
+#include "state_tracker/st_manager.h"
 
 PUBLIC const int st_api_OpenGL_ES2 = 1;
+
+PUBLIC const struct st_module st_module_OpenGL_ES2 = {
+   .api = ST_API_OPENGL_ES2,
+   .create_api = st_manager_create_api
+};
index 8c7cc524dfc393e07441b1ba2059ed5bfce12da0..35509fd708ba7a818a155915ec7ae03057b0dce7 100644 (file)
@@ -6,12 +6,13 @@ LIBNAME = xlib
 LIBRARY_INCLUDES = \
        -I$(TOP)/include \
        -I$(TOP)/src/mesa \
-       $(X_CFLAGS)
+       $(X11_CFLAGS)
 
 C_SOURCES = \
        glx_api.c \
        glx_getproc.c \
        glx_usefont.c \
-       xm_api.c
+       xm_api.c \
+       xm_st.c
 
 include ../../../Makefile.template
index bb202351509251ec44a2d203aa335e31c3a5d69b..d6c16ad2f52eb9c965f82e04da79ffc3a3a25743 100644 (file)
@@ -20,6 +20,7 @@ if env['platform'] == 'linux' \
                'glx_getproc.c',
                'glx_usefont.c',
                'xm_api.c',
+               'xm_st.c',
                ]
     )
     Export('st_xlib')
index 2454585850008fc23e8a4e4e1c532eab97af3052..eb8d6a1933397b3295f5e6bf2afc1ab85c7a40cb 100644 (file)
 
 #include "xm_api.h"
 #include "main/context.h"
-#include "main/config.h"
 #include "main/macros.h"
 #include "main/imports.h"
 #include "main/version.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
 
 
 /* This indicates the client-side GLX API and GLX encoder version. */
@@ -1304,7 +1301,7 @@ glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
    if (MakeCurrent_PrevContext == src) {
       _mesa_Flush();
    }
-   st_copy_context_state( xm_src->st, xm_dst->st, (GLuint) mask );
+   XMesaCopyContext(xm_src, xm_dst, mask);
 }
 
 
@@ -1761,6 +1758,10 @@ glXGetFBConfigs( Display *dpy, int screen, int *nelements )
       }
       for (i = 0; i < *nelements; i++) {
          results[i] = create_glx_visual(dpy, visuals + i);
+         if (!results[i]) {
+            *nelements = i;
+            break;
+         }
       }
       return (GLXFBConfig *) results;
    }
index f4d7133d2ff1ed5ada9efeb4ef8ebb0fc7019124..fd03d3c46a418d7ab96f332f12b29d0daf79e164 100644 (file)
 #endif
 
 #include "xm_api.h"
-#include "main/context.h"
-#include "main/framebuffer.h"
+#include "xm_st.h"
 
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
+#include "main/context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 #include "pipe/p_context.h"
  * global.
  */
 static struct xm_driver driver;
+static struct st_api *stapi;
 
 void xmesa_set_driver( const struct xm_driver *templ )
 {
    driver = *templ;
+   stapi = driver.create_st_api();
 }
 
-/**
- * Global X driver lock
+
+/*
+ * XXX replace this with a linked list, or better yet, try to attach the
+ * gallium/mesa extra bits to the X Display object with XAddExtension().
  */
-pipe_mutex _xmesa_lock;
+#define MAX_DISPLAYS 10
+static struct xmesa_display Displays[MAX_DISPLAYS];
+static int NumDisplays = 0;
+
+
+static XMesaDisplay
+xmesa_init_display( Display *display )
+{
+   pipe_static_mutex(init_mutex);
+   XMesaDisplay xmdpy;
+   int i;
+
+   pipe_mutex_lock(init_mutex);
+
+   /* Look for XMesaDisplay which corresponds to 'display' */
+   for (i = 0; i < NumDisplays; i++) {
+      if (Displays[i].display == display) {
+         /* Found it */
+         pipe_mutex_unlock(init_mutex);
+         return &Displays[i];
+      }
+   }
+
+   /* Create new XMesaDisplay */
+
+   assert(NumDisplays < MAX_DISPLAYS);
+   xmdpy = &Displays[NumDisplays];
+   NumDisplays++;
+
+   if (!xmdpy->display && display) {
+      xmdpy->display = display;
+      xmdpy->screen = driver.create_pipe_screen(display);
+      xmdpy->smapi = CALLOC_STRUCT(st_manager);
+      if (xmdpy->smapi)
+         xmdpy->smapi->screen = xmdpy->screen;
+
+      if (xmdpy->screen && xmdpy->smapi) {
+         pipe_mutex_init(xmdpy->mutex);
+      }
+      else {
+         if (xmdpy->screen) {
+            xmdpy->screen->destroy(xmdpy->screen);
+            xmdpy->screen = NULL;
+         }
+         if (xmdpy->smapi) {
+            FREE(xmdpy->smapi);
+            xmdpy->smapi = NULL;
+         }
 
-static struct pipe_screen *screen = NULL;
+         xmdpy->display = NULL;
+      }
+   }
+   if (!xmdpy->display || xmdpy->display != display)
+      xmdpy = NULL;
+
+   pipe_mutex_unlock(init_mutex);
 
+   return xmdpy;
+}
 
 /**********************************************************************/
 /*****                     X Utility Functions                    *****/
@@ -194,12 +251,13 @@ void
 xmesa_get_window_size(Display *dpy, XMesaBuffer b,
                       GLuint *width, GLuint *height)
 {
+   XMesaDisplay xmdpy = xmesa_init_display(dpy);
    Status stat;
 
-   pipe_mutex_lock(_xmesa_lock);
+   pipe_mutex_lock(xmdpy->mutex);
    XSync(b->xm_visual->display, 0); /* added for Chromium */
    stat = get_drawable_size(dpy, b->ws.drawable, width, height);
-   pipe_mutex_unlock(_xmesa_lock);
+   pipe_mutex_unlock(xmdpy->mutex);
 
    if (!stat) {
       /* probably querying a window that's recently been destroyed */
@@ -269,53 +327,51 @@ choose_pixel_format(XMesaVisual v)
       return PIPE_FORMAT_B5G6R5_UNORM;
    }
 
-   assert(0);
-   return 0;
+   return PIPE_FORMAT_NONE;
 }
 
 
-
 /**
- * Query the default gallium screen for a Z/Stencil format that
- * at least matches the given depthBits and stencilBits.
+ * Choose a depth/stencil format that satisfies the given depth and
+ * stencil sizes.
  */
-static void
-xmesa_choose_z_stencil_format(int depthBits, int stencilBits,
-                              enum pipe_format *depthFormat,
-                              enum pipe_format *stencilFormat)
+static enum pipe_format
+choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil)
 {
    const enum pipe_texture_target target = PIPE_TEXTURE_2D;
    const unsigned tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
    const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE |
                                 PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO);
-   static enum pipe_format formats[] = {
-      PIPE_FORMAT_S8Z24_UNORM,
-      PIPE_FORMAT_Z24S8_UNORM,
-      PIPE_FORMAT_Z16_UNORM,
-      PIPE_FORMAT_Z32_UNORM
-   };
-   int i;
+   enum pipe_format formats[8], fmt;
+   int count, i;
 
-   assert(screen);
+   count = 0;
 
-   *depthFormat = *stencilFormat = PIPE_FORMAT_NONE;
+   if (depth <= 16 && stencil == 0) {
+      formats[count++] = PIPE_FORMAT_Z16_UNORM;
+   }
+   if (depth <= 24 && stencil == 0) {
+      formats[count++] = PIPE_FORMAT_X8Z24_UNORM;
+      formats[count++] = PIPE_FORMAT_Z24X8_UNORM;
+   }
+   if (depth <= 24 && stencil <= 8) {
+      formats[count++] = PIPE_FORMAT_S8Z24_UNORM;
+      formats[count++] = PIPE_FORMAT_Z24S8_UNORM;
+   }
+   if (depth <= 32 && stencil == 0) {
+      formats[count++] = PIPE_FORMAT_Z32_UNORM;
+   }
 
-   /* search for supported format */
-   for (i = 0; i < Elements(formats); i++) {
-      if (screen->is_format_supported(screen, formats[i],
+   fmt = PIPE_FORMAT_NONE;
+   for (i = 0; i < count; i++) {
+      if (xmdpy->screen->is_format_supported(xmdpy->screen, formats[i],
                                       target, tex_usage, geom_flags)) {
-         *depthFormat = formats[i];
+         fmt = formats[i];
          break;
       }
    }
 
-   if (stencilBits) {
-      *stencilFormat = *depthFormat;
-   }
-
-   /* XXX we should check that he chosen format has at least as many bits
-    * as what was requested.
-    */
+   return fmt;
 }
 
 
@@ -324,7 +380,7 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits,
 /*****                Linked list of XMesaBuffers                 *****/
 /**********************************************************************/
 
-XMesaBuffer XMesaBufferList = NULL;
+static XMesaBuffer XMesaBufferList = NULL;
 
 
 /**
@@ -342,13 +398,15 @@ static XMesaBuffer
 create_xmesa_buffer(Drawable d, BufferType type,
                     XMesaVisual vis, Colormap cmap)
 {
+   XMesaDisplay xmdpy = xmesa_init_display(vis->display);
    XMesaBuffer b;
-   GLframebuffer *fb;
-   enum pipe_format colorFormat, depthFormat, stencilFormat;
    uint width, height;
 
    ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER);
 
+   if (!xmdpy)
+      return NULL;
+
    b = (XMesaBuffer) CALLOC_STRUCT(xmesa_buffer);
    if (!b)
       return NULL;
@@ -361,24 +419,12 @@ create_xmesa_buffer(Drawable d, BufferType type,
    b->type = type;
    b->cmap = cmap;
 
-   /* determine PIPE_FORMATs for buffers */
-   colorFormat = choose_pixel_format(vis);
-
-   xmesa_choose_z_stencil_format(vis->mesa_visual.depthBits,
-                                 vis->mesa_visual.stencilBits,
-                                 &depthFormat, &stencilFormat);
-
-
    get_drawable_size(vis->display, d, &width, &height);
 
    /*
     * Create framebuffer, but we'll plug in our own renderbuffers below.
     */
-   b->stfb = st_create_framebuffer(&vis->mesa_visual,
-                                   colorFormat, depthFormat, stencilFormat,
-                                   width, height,
-                                   (void *) b);
-   fb = &b->stfb->Base;
+   b->stfb = xmesa_create_st_framebuffer(xmdpy, b);
 
    /* GLX_EXT_texture_from_pixmap */
    b->TextureTarget = 0;
@@ -422,24 +468,21 @@ xmesa_free_buffer(XMesaBuffer buffer)
 
    for (b = XMesaBufferList; b; b = b->Next) {
       if (b == buffer) {
-         struct gl_framebuffer *fb = &buffer->stfb->Base;
-
          /* unlink buffer from list */
          if (prev)
             prev->Next = buffer->Next;
          else
             XMesaBufferList = buffer->Next;
 
-         /* mark as delete pending */
-         fb->DeletePending = GL_TRUE;
-
          /* Since the X window for the XMesaBuffer is going away, we don't
           * want to dereference this pointer in the future.
           */
          b->ws.drawable = 0;
 
-         /* Unreference.  If count = zero we'll really delete the buffer */
-         _mesa_reference_framebuffer(&fb, NULL);
+         /* XXX we should move the buffer to a delete-pending list and destroy
+          * the buffer until it is no longer current.
+          */
+         xmesa_destroy_st_framebuffer(buffer->stfb);
 
          free(buffer);
 
@@ -596,10 +639,12 @@ XMesaVisual XMesaCreateVisual( Display *display,
                                GLint level,
                                GLint visualCaveat )
 {
+   XMesaDisplay xmdpy = xmesa_init_display(display);
    XMesaVisual v;
    GLint red_bits, green_bits, blue_bits, alpha_bits;
 
-   xmesa_init( display );
+   if (!xmdpy)
+      return NULL;
 
    /* For debugging only */
    if (_mesa_getenv("MESA_XSYNC")) {
@@ -681,6 +726,32 @@ XMesaVisual XMesaCreateVisual( Display *display,
                             accum_blue_size, accum_alpha_size,
                             0 );
 
+   v->stvis.buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK;
+   if (db_flag)
+      v->stvis.buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
+   if (stereo_flag) {
+      v->stvis.buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK;
+      if (db_flag)
+         v->stvis.buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
+   }
+
+   v->stvis.color_format = choose_pixel_format(v);
+   if (v->stvis.color_format == PIPE_FORMAT_NONE) {
+      FREE(v->visinfo);
+      FREE(v);
+      return NULL;
+   }
+
+   v->stvis.depth_stencil_format =
+      choose_depth_stencil_format(xmdpy, depth_size, stencil_size);
+
+   v->stvis.accum_format = (accum_red_size +
+         accum_green_size + accum_blue_size + accum_alpha_size) ?
+      PIPE_FORMAT_R16G16B16A16_SNORM : PIPE_FORMAT_NONE;
+
+   v->stvis.samples = num_samples;
+   v->stvis.render_buffer = ST_ATTACHMENT_INVALID;
+
    /* XXX minor hack */
    v->mesa_visual.level = level;
    return v;
@@ -696,17 +767,12 @@ void XMesaDestroyVisual( XMesaVisual v )
 
 
 /**
- * Do one-time initializations.
+ * Do per-display initializations.
  */
 void
 xmesa_init( Display *display )
 {
-   static GLboolean firstTime = GL_TRUE;
-   if (firstTime) {
-      pipe_mutex_init(_xmesa_lock);
-      screen = driver.create_pipe_screen( display );
-      firstTime = GL_FALSE;
-   }
+   xmesa_init_display(display);
 }
 
 
@@ -720,51 +786,33 @@ xmesa_init( Display *display )
 PUBLIC
 XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
 {
-   struct pipe_context *pipe = NULL;
+   XMesaDisplay xmdpy = xmesa_init_display(v->display);
    XMesaContext c;
-   GLcontext *mesaCtx;
-   uint pf;
 
-   xmesa_init( v->display );
+   if (!xmdpy)
+      return NULL;
 
    /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */
    c = (XMesaContext) CALLOC_STRUCT(xmesa_context);
    if (!c)
       return NULL;
 
-   pf = choose_pixel_format(v);
-   assert(pf);
-
    c->xm_visual = v;
    c->xm_buffer = NULL;   /* set later by XMesaMakeCurrent */
    c->xm_read_buffer = NULL;
 
-   if (screen == NULL)
-      goto fail;
-
-   /* Trace screen knows how to properly wrap context creation in the
-    * wrapped screen, so nothing special to do here:
-    */
-   pipe = screen->context_create(screen, (void *) c);
-   if (pipe == NULL)
-      goto fail;
-
-   c->st = st_create_context(pipe, 
-                             &v->mesa_visual,
-                             share_list ? share_list->st : NULL);
+   c->st = stapi->create_context(stapi, xmdpy->smapi,
+         &v->stvis, (share_list) ? share_list->st : NULL);
    if (c->st == NULL)
       goto fail;
 
-   mesaCtx = c->st->ctx;
-   c->st->ctx->DriverCtx = c;
+   c->st->st_manager_private = (void *) c;
 
    return c;
 
 fail:
    if (c->st)
-      st_destroy_context(c->st);
-   else if (pipe)
-      pipe->destroy(pipe);
+      c->st->destroy(c->st);
 
    free(c);
    return NULL;
@@ -775,7 +823,7 @@ fail:
 PUBLIC
 void XMesaDestroyContext( XMesaContext c )
 {
-   st_destroy_context(c->st);
+   c->st->destroy(c->st);
 
    /* FIXME: We should destroy the screen here, but if we do so, surfaces may 
     * outlive it, causing segfaults
@@ -881,7 +929,6 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p,
 {
    GET_CURRENT_CONTEXT(ctx);
    XMesaBuffer b;
-   GLuint width, height;
 
    assert(v);
 
@@ -889,19 +936,18 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p,
    if (!b)
       return NULL;
 
-   /* get pixmap size, update framebuffer/renderbuffer dims */
-   xmesa_get_window_size(v->display, b, &width, &height);
-   _mesa_resize_framebuffer(NULL, &(b->stfb->Base), width, height);
+   /* get pixmap size */
+   xmesa_get_window_size(v->display, b, &b->width, &b->height);
 
    if (target == 0) {
       /* examine dims */
       if (ctx->Extensions.ARB_texture_non_power_of_two) {
          target = GLX_TEXTURE_2D_EXT;
       }
-      else if (   _mesa_bitcount(width)  == 1
-               && _mesa_bitcount(height) == 1) {
+      else if (   _mesa_bitcount(b->width)  == 1
+               && _mesa_bitcount(b->height) == 1) {
          /* power of two size */
-         if (height == 1) {
+         if (b->height == 1) {
             target = GLX_TEXTURE_1D_EXT;
          }
          else {
@@ -974,23 +1020,20 @@ XMesaDestroyBuffer(XMesaBuffer b)
 
 
 /**
- * Query the current window size and update the corresponding GLframebuffer
- * and all attached renderbuffers.
- * Called when:
- *  1. the first time a buffer is bound to a context.
- *  2. SwapBuffers.  XXX probabaly from xm_flush_frontbuffer() too...
- * Note: it's possible (and legal) for xmctx to be NULL.  That can happen
- * when resizing a buffer when no rendering context is bound.
+ * Query the current drawable size and notify the binding context.
  */
 void
-xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer)
+xmesa_check_buffer_size(XMesaBuffer b)
 {
-   GLuint width, height;
-   xmesa_get_window_size(drawBuffer->xm_visual->display, drawBuffer, &width, &height);
-   st_resize_framebuffer(drawBuffer->stfb, width, height);
-}
+   XMesaContext xmctx = XMesaGetCurrentContext();
 
+   if (b->type == PBUFFER)
+      return;
 
+   xmesa_get_window_size(b->xm_visual->display, b, &b->width, &b->height);
+   if (xmctx && xmctx->xm_buffer == b)
+      xmctx->st->notify_invalid_framebuffer(xmctx->st, b->stfb);
+}
 
 
 /*
@@ -1017,22 +1060,21 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
          c->xm_read_buffer == readBuffer)
         return GL_TRUE;
 
+      xmesa_check_buffer_size(drawBuffer);
+      if (readBuffer != drawBuffer)
+         xmesa_check_buffer_size(readBuffer);
+
       c->xm_buffer = drawBuffer;
       c->xm_read_buffer = readBuffer;
 
-      st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb, 
-                      &drawBuffer->ws);
-
-      xmesa_check_and_update_buffer_size(c, drawBuffer);
-      if (readBuffer != drawBuffer)
-         xmesa_check_and_update_buffer_size(c, readBuffer);
+      stapi->make_current(stapi, c->st, drawBuffer->stfb, readBuffer->stfb);
 
       /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
       drawBuffer->wasCurrent = GL_TRUE;
    }
    else {
       /* Detach */
-      st_make_current( NULL, NULL, NULL, NULL );
+      stapi->make_current(stapi, NULL, NULL, NULL);
 
    }
    return GL_TRUE;
@@ -1051,14 +1093,8 @@ GLboolean XMesaUnbindContext( XMesaContext c )
 
 XMesaContext XMesaGetCurrentContext( void )
 {
-   GET_CURRENT_CONTEXT(ctx);
-   if (ctx) {
-      XMesaContext xmesa = xmesa_context(ctx);
-      return xmesa;
-   }
-   else {
-      return 0;
-   }
+   struct st_context_iface *st = stapi->get_current(stapi);
+   return (XMesaContext) (st) ? st->st_manager_private : NULL;
 }
 
 
@@ -1070,17 +1106,17 @@ XMesaContext XMesaGetCurrentContext( void )
 PUBLIC
 void XMesaSwapBuffers( XMesaBuffer b )
 {
-   struct pipe_surface *frontLeftSurf;
-
-   st_swapbuffers(b->stfb, &frontLeftSurf, NULL);
-
-   if (frontLeftSurf) {
-      screen->flush_frontbuffer( screen,
-                                 frontLeftSurf, 
-                                 &b->ws );
+   XMesaContext xmctx = XMesaGetCurrentContext();
+
+   if (xmctx && xmctx->xm_buffer == b) {
+      xmctx->st->flush( xmctx->st,
+            PIPE_FLUSH_RENDER_CACHE | 
+            PIPE_FLUSH_SWAPBUFFERS |
+            PIPE_FLUSH_FRAME,
+            NULL);
    }
 
-   xmesa_check_and_update_buffer_size(NULL, b);
+   xmesa_swap_st_framebuffer(b->stfb);
 }
 
 
@@ -1090,21 +1126,9 @@ void XMesaSwapBuffers( XMesaBuffer b )
  */
 void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
 {
-   struct pipe_surface *surf_front;
-   struct pipe_surface *surf_back;
-   struct pipe_context *pipe = NULL; /* XXX fix */
-
-   st_get_framebuffer_surface(b->stfb, ST_SURFACE_FRONT_LEFT, &surf_front);
-   st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT, &surf_back);
-
-   if (!surf_front || !surf_back)
-      return;
-
-   assert(pipe);
-   pipe->surface_copy(pipe,
-                      surf_front, x, y,  /* dest */
-                      surf_back, x, y,   /* src */
-                      width, height);
+   xmesa_copy_st_framebuffer(b->stfb,
+         ST_ATTACHMENT_BACK_LEFT, ST_ATTACHMENT_FRONT_LEFT,
+         x, y, width, height);
 }
 
 
@@ -1112,7 +1136,14 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
 void XMesaFlush( XMesaContext c )
 {
    if (c && c->xm_visual->display) {
-      st_finish(c->st);
+      XMesaDisplay xmdpy = xmesa_init_display(c->xm_visual->display);
+      struct pipe_fence_handle *fence = NULL;
+
+      c->st->flush(c->st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
+      if (fence) {
+         xmdpy->screen->fence_finish(xmdpy->screen, fence, 0);
+         xmdpy->screen->fence_reference(xmdpy->screen, &fence, NULL);
+      }
       XSync( c->xm_visual->display, False );
    }
 }
@@ -1186,3 +1217,10 @@ XMesaReleaseTexImage(Display *dpy, XMesaBuffer drawable, int buffer)
 {
 }
 
+
+void
+XMesaCopyContext(XMesaContext src, XMesaContext dst, unsigned long mask)
+{
+   if (dst->st->copy)
+      dst->st->copy(dst->st, src->st, mask);
+}
index de47064b410a5e3238bf261aa9830a0be10adb40..4f2c8a6e6a9a8ddf25d9a1db3e159d99f421e56e 100644 (file)
@@ -58,8 +58,7 @@ and create a window, you must do the following to use the X/Mesa interface:
 
 
 #include "main/mtypes.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
+#include "state_tracker/st_api.h"
 #include "os/os_thread.h"
 
 #include "state_tracker/xlib_sw_winsys.h"
@@ -68,11 +67,22 @@ and create a window, you must do the following to use the X/Mesa interface:
 # include <X11/Xlibint.h>
 # include <X11/Xutil.h>
 
+typedef struct xmesa_display *XMesaDisplay;
 typedef struct xmesa_buffer *XMesaBuffer;
 typedef struct xmesa_context *XMesaContext;
 typedef struct xmesa_visual *XMesaVisual;
 
 
+struct xmesa_display {
+   pipe_mutex mutex;
+
+   Display *display;
+   struct pipe_screen *screen;
+   struct st_manager *smapi;
+
+   struct pipe_context *pipe;
+};
+
 
 /*
  * Create a new X/Mesa visual.
@@ -258,16 +268,13 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p,
                                int format, int target, int mipmap);
 
 
+extern void
+XMesaCopyContext(XMesaContext src, XMesaContext dst, unsigned long mask);
 
 
 /***********************************************************************
  */
 
-extern pipe_mutex _xmesa_lock;
-
-extern struct xmesa_buffer *XMesaBufferList;
-
-
 /**
  * Visual inforation, derived from GLvisual.
  * Basically corresponds to an XVisualInfo.
@@ -280,6 +287,8 @@ struct xmesa_visual {
    GLint BitsPerPixel;         /* True bits per pixel for XImages */
 
    GLboolean ximage_flag;      /* Use XImage for back buffer (not pixmap)? */
+
+   struct st_visual stvis;
 };
 
 
@@ -288,7 +297,7 @@ struct xmesa_visual {
  * Basically corresponds to a GLXContext.
  */
 struct xmesa_context {
-   struct st_context *st;
+   struct st_context_iface *st;
    XMesaVisual xm_visual;      /** pixel format info */
    XMesaBuffer xm_buffer;      /** current drawbuffer */
    XMesaBuffer xm_read_buffer;  /** current readbuffer */
@@ -311,7 +320,7 @@ typedef enum {
  * Basically corresponds to a GLXDrawable.
  */
 struct xmesa_buffer {
-   struct st_framebuffer *stfb;
+   struct st_framebuffer_iface *stfb;
    struct xlib_drawable ws;
 
    GLboolean wasCurrent;       /* was ever the current buffer? */
@@ -335,33 +344,15 @@ struct xmesa_buffer {
    GLint TextureMipmap; /** 0 or 1 */
 
    struct xmesa_buffer *Next;  /* Linked list pointer: */
-};
-
-
-
-/** cast wrapper */
-static INLINE XMesaContext
-xmesa_context(GLcontext *ctx)
-{
-   return (XMesaContext) ctx->DriverCtx;
-}
 
+   unsigned width, height;
+};
 
-/** cast wrapper */
-static INLINE XMesaBuffer
-xmesa_buffer(GLframebuffer *fb)
-{
-   struct st_framebuffer *stfb = (struct st_framebuffer *) fb;
-   return (XMesaBuffer) st_framebuffer_private(stfb);
-}
 
 
 extern void
 xmesa_init(Display *dpy);
 
-extern void
-xmesa_delete_framebuffer(struct gl_framebuffer *fb);
-
 extern XMesaBuffer
 xmesa_find_buffer(Display *dpy, Colormap cmap, XMesaBuffer notThis);
 
@@ -370,7 +361,7 @@ xmesa_get_window_size(Display *dpy, XMesaBuffer b,
                       GLuint *width, GLuint *height);
 
 extern void
-xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
+xmesa_check_buffer_size(XMesaBuffer b);
 
 extern void
 xmesa_destroy_buffers_on_display(Display *dpy);
@@ -378,13 +369,13 @@ xmesa_destroy_buffers_on_display(Display *dpy);
 static INLINE GLuint
 xmesa_buffer_width(XMesaBuffer b)
 {
-   return b->stfb->Base.Width;
+   return b->width;
 }
 
 static INLINE GLuint
 xmesa_buffer_height(XMesaBuffer b)
 {
-   return b->stfb->Base.Height;
+   return b->height;
 }
 
 
index ac6a8ffb27ab059f8fccb6e4a9bdd816b9fc95f8..950eb21521f981881216e8ada427172bf29f120a 100644 (file)
  * 
  **************************************************************************/
 
-#ifndef XM_WINSYS_H
-#define XM_WINSYS_H
+#ifndef XM_PUBLIC_H
+#define XM_PUBLIC_H
 
-struct xm_driver;
+#include <X11/Xlib.h>
+
+struct pipe_screen;
+struct st_api;
 
 /* This is the driver interface required by the glx/xlib state tracker. 
  */
 struct xm_driver {
    struct pipe_screen *(*create_pipe_screen)( Display *display );
+   struct st_api *(*create_st_api)( void );
 };
 
 extern void
 xmesa_set_driver( const struct xm_driver *driver );
 
 
-#endif
+#endif /* XM_PUBLIC_H */
diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c
new file mode 100644 (file)
index 0000000..b6ed7e8
--- /dev/null
@@ -0,0 +1,332 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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_memory.h"
+#include "util/u_inlines.h"
+
+#include "xm_api.h"
+#include "xm_st.h"
+
+struct xmesa_st_framebuffer {
+   XMesaDisplay display;
+   XMesaBuffer buffer;
+   struct pipe_screen *screen;
+
+   struct st_visual stvis;
+
+   unsigned texture_width, texture_height, texture_mask;
+   struct pipe_texture *textures[ST_ATTACHMENT_COUNT];
+
+   struct pipe_surface *display_surface;
+};
+
+static INLINE struct xmesa_st_framebuffer *
+xmesa_st_framebuffer(struct st_framebuffer_iface *stfbi)
+{
+   return (struct xmesa_st_framebuffer *) stfbi->st_manager_private;
+}
+
+/**
+ * Display an attachment to the xlib_drawable of the framebuffer.
+ */
+static boolean
+xmesa_st_framebuffer_display(struct st_framebuffer_iface *stfbi,
+                             enum st_attachment_type statt)
+{
+   struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
+   struct pipe_texture *ptex = xstfb->textures[statt];
+   struct pipe_surface *psurf;
+
+   if (!ptex)
+      return TRUE;
+
+   psurf = xstfb->display_surface;
+   /* (re)allocate the surface for the texture to be displayed */
+   if (!psurf || psurf->texture != ptex) {
+      pipe_surface_reference(&xstfb->display_surface, NULL);
+
+      psurf = xstfb->screen->get_tex_surface(xstfb->screen,
+            ptex, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ);
+      if (!psurf)
+         return FALSE;
+
+      xstfb->display_surface = psurf;
+   }
+
+   xstfb->screen->flush_frontbuffer(xstfb->screen, psurf, &xstfb->buffer->ws);
+
+   return TRUE;
+}
+
+/**
+ * Copy the contents between the attachments.
+ */
+static void
+xmesa_st_framebuffer_copy_textures(struct st_framebuffer_iface *stfbi,
+                                   enum st_attachment_type src_statt,
+                                   enum st_attachment_type dst_statt,
+                                   unsigned x, unsigned y,
+                                   unsigned width, unsigned height)
+{
+   struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
+   struct pipe_texture *src_ptex = xstfb->textures[src_statt];
+   struct pipe_texture *dst_ptex = xstfb->textures[dst_statt];
+   struct pipe_surface *src, *dst;
+   struct pipe_context *pipe;
+
+   if (!src_ptex || !dst_ptex)
+      return;
+
+   pipe = xstfb->display->pipe;
+   if (!pipe) {
+      pipe = xstfb->screen->context_create(xstfb->screen, NULL);
+      if (!pipe)
+         return;
+      xstfb->display->pipe = pipe;
+   }
+
+   src = xstfb->screen->get_tex_surface(xstfb->screen,
+         src_ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
+   dst = xstfb->screen->get_tex_surface(xstfb->screen,
+         dst_ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+
+   if (src && dst)
+      pipe->surface_copy(pipe, dst, x, y, src, x, y, width, height);
+
+   pipe_surface_reference(&src, NULL);
+   pipe_surface_reference(&dst, NULL);
+}
+
+/**
+ * Remove outdated textures and create the requested ones.
+ */
+static void
+xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
+                                       unsigned width, unsigned height,
+                                       unsigned mask)
+{
+   struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
+   struct pipe_texture templ;
+   unsigned i;
+
+   /* remove outdated textures */
+   if (xstfb->texture_width != width || xstfb->texture_height != height) {
+      for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+         pipe_texture_reference(&xstfb->textures[i], NULL);
+   }
+
+   memset(&templ, 0, sizeof(templ));
+   templ.target = PIPE_TEXTURE_2D;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
+   templ.last_level = 0;
+
+   for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+      enum pipe_format format;
+      unsigned tex_usage;
+
+      /* the texture already exists or not requested */
+      if (xstfb->textures[i] || !(mask & (1 << i))) {
+         /* remember the texture */
+         if (xstfb->textures[i])
+            mask |= (1 << i);
+         continue;
+      }
+
+      switch (i) {
+      case ST_ATTACHMENT_FRONT_LEFT:
+      case ST_ATTACHMENT_BACK_LEFT:
+      case ST_ATTACHMENT_FRONT_RIGHT:
+      case ST_ATTACHMENT_BACK_RIGHT:
+         format = xstfb->stvis.color_format;
+         tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                     PIPE_TEXTURE_USAGE_RENDER_TARGET;
+         break;
+      case ST_ATTACHMENT_DEPTH_STENCIL:
+         format = xstfb->stvis.depth_stencil_format;
+         tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+         break;
+      default:
+         format = PIPE_FORMAT_NONE;
+         break;
+      }
+
+      if (format != PIPE_FORMAT_NONE) {
+         templ.format = format;
+         templ.tex_usage = tex_usage;
+
+         xstfb->textures[i] =
+            xstfb->screen->texture_create(xstfb->screen, &templ);
+      }
+   }
+
+   xstfb->texture_width = width;
+   xstfb->texture_height = height;
+   xstfb->texture_mask = mask;
+}
+
+static boolean 
+xmesa_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
+                              const enum st_attachment_type *statts,
+                              unsigned count,
+                              struct pipe_texture **out)
+{
+   struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
+   unsigned statt_mask, new_mask, i;
+   boolean resized;
+
+   statt_mask = 0x0;
+   for (i = 0; i < count; i++)
+      statt_mask |= 1 << statts[i];
+   /* record newly allocated textures */
+   new_mask = statt_mask & ~xstfb->texture_mask;
+
+   resized = (xstfb->buffer->width != xstfb->texture_width ||
+              xstfb->buffer->height != xstfb->texture_height);
+
+   /* revalidate textures */
+   if (resized || new_mask) {
+      xmesa_st_framebuffer_validate_textures(stfbi,
+            xstfb->buffer->width, xstfb->buffer->height, statt_mask);
+
+      if (!resized) {
+         enum st_attachment_type back, front;
+
+         back = ST_ATTACHMENT_BACK_LEFT;
+         front = ST_ATTACHMENT_FRONT_LEFT;
+         /* copy the contents if front is newly allocated and back is not */
+         if ((statt_mask & (1 << back)) &&
+             (new_mask & (1 << front)) &&
+             !(new_mask & (1 << back))) {
+            xmesa_st_framebuffer_copy_textures(stfbi, back, front,
+                  0, 0, xstfb->texture_width, xstfb->texture_height);
+         }
+      }
+   }
+
+   for (i = 0; i < count; i++) {
+      out[i] = NULL;
+      pipe_texture_reference(&out[i], xstfb->textures[statts[i]]);
+   }
+
+   return TRUE;
+}
+
+static boolean
+xmesa_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
+                                 enum st_attachment_type statt)
+{
+   struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
+   boolean ret;
+
+   ret = xmesa_st_framebuffer_display(stfbi, statt);
+   if (ret)
+      xmesa_check_buffer_size(xstfb->buffer);
+
+   return ret;
+}
+
+struct st_framebuffer_iface *
+xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b)
+{
+   struct st_framebuffer_iface *stfbi;
+   struct xmesa_st_framebuffer *xstfb;
+
+   assert(xmdpy->display == b->xm_visual->display);
+
+   stfbi = CALLOC_STRUCT(st_framebuffer_iface);
+   xstfb = CALLOC_STRUCT(xmesa_st_framebuffer);
+   if (!stfbi || !xstfb) {
+      if (stfbi)
+         FREE(stfbi);
+      if (xstfb)
+         FREE(xstfb);
+      return NULL;
+   }
+
+   xstfb->display = xmdpy;
+   xstfb->buffer = b;
+   xstfb->screen = xmdpy->screen;
+   xstfb->stvis = b->xm_visual->stvis;
+
+   stfbi->visual = &xstfb->stvis;
+   stfbi->flush_front = xmesa_st_framebuffer_flush_front;
+   stfbi->validate = xmesa_st_framebuffer_validate;
+   stfbi->st_manager_private = (void *) xstfb;
+
+   return stfbi;
+}
+
+void
+xmesa_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
+{
+   struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
+   int i;
+
+   pipe_surface_reference(&xstfb->display_surface, NULL);
+
+   for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+      pipe_texture_reference(&xstfb->textures[i], NULL);
+
+   FREE(xstfb);
+   FREE(stfbi);
+}
+
+void
+xmesa_swap_st_framebuffer(struct st_framebuffer_iface *stfbi)
+{
+   struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
+   boolean ret;
+
+   ret = xmesa_st_framebuffer_display(stfbi, ST_ATTACHMENT_BACK_LEFT);
+   if (ret) {
+      struct pipe_texture **front, **back, *tmp;
+
+      front = &xstfb->textures[ST_ATTACHMENT_FRONT_LEFT];
+      back = &xstfb->textures[ST_ATTACHMENT_BACK_LEFT];
+      /* swap textures only if the front texture has been allocated */
+      if (*front) {
+         tmp = *front;
+         *front = *back;
+         *back = tmp;
+      }
+
+      xmesa_check_buffer_size(xstfb->buffer);
+   }
+}
+
+void
+xmesa_copy_st_framebuffer(struct st_framebuffer_iface *stfbi,
+                          enum st_attachment_type src,
+                          enum st_attachment_type dst,
+                          int x, int y, int w, int h)
+{
+   xmesa_st_framebuffer_copy_textures(stfbi, src, dst, x, y, w, h);
+   if (dst == ST_ATTACHMENT_FRONT_LEFT)
+      xmesa_st_framebuffer_display(stfbi, dst);
+}
diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.h b/src/gallium/state_trackers/glx/xlib/xm_st.h
new file mode 100644 (file)
index 0000000..396495c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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>
+ */
+
+#ifndef _XM_ST_H_
+#define _XM_ST_H_
+
+#include "pipe/p_compiler.h"
+#include "state_tracker/st_api.h"
+
+#include "xm_api.h"
+
+struct st_framebuffer_iface *
+xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b);
+
+void
+xmesa_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi);
+
+void
+xmesa_swap_st_framebuffer(struct st_framebuffer_iface *stfbi);
+
+void
+xmesa_copy_st_framebuffer(struct st_framebuffer_iface *stfbi,
+                          enum st_attachment_type src,
+                          enum st_attachment_type dst,
+                          int x, int y, int w, int h);
+
+#endif /* _XM_ST_H_ */
index d0d141fd2496299b02ba3b3a01b8493e40ce6308..781f54bf2b9036f09ab95554ee28c8fe3f144c0b 100644 (file)
@@ -3,8 +3,7 @@ import os.path
 
 Import('*')
 
-if 'python' in env['statetrackers'] and 0:
-    # FIXME: Disable python state tracker until transfers are done by contexts  
+if 'python' in env['statetrackers']:
 
     env = env.Clone()
     
index ffb084e358b10b2e7806e2fc01e27f55d23dce40..632d71ccbee73659d5c084f36ea951a32c18f6c1 100644 (file)
@@ -49,6 +49,7 @@
 #include "util/u_format.h"
 #include "util/u_dump.h"
 #include "util/u_memory.h"
+#include "util/u_sampler.h"
 #include "cso_cache/cso_context.h"
 #include "tgsi/tgsi_text.h"
 #include "tgsi/tgsi_dump.h"
index 5c44462e80fc42553bbbebdfa1ae5af34be7431b..bccaeead015656eba309f5f8b7c5ecb261a55b81 100644 (file)
@@ -169,22 +169,39 @@ struct st_context {
 
    void set_fragment_sampler_texture(unsigned index,
                                      struct pipe_texture *texture) {
+      struct pipe_sampler_view templ;
+
       if(!texture)
          texture = $self->default_texture;
-      pipe_texture_reference(&$self->fragment_sampler_textures[index], texture);
-      $self->pipe->set_fragment_sampler_textures($self->pipe,
-                                                 PIPE_MAX_SAMPLERS,
-                                                 $self->fragment_sampler_textures);
+      pipe_sampler_view_reference(&$self->fragment_sampler_views[index], NULL);
+      u_sampler_view_default_template(&templ,
+                                      texture,
+                                      texture->format);
+      $self->fragment_sampler_views[index] = $self->pipe->create_sampler_view($self->pipe,
+                                                                              texture,
+                                                                              &templ);
+      $self->pipe->set_fragment_sampler_views($self->pipe,
+                                              PIPE_MAX_SAMPLERS,
+                                              $self->fragment_sampler_views);
    }
 
    void set_vertex_sampler_texture(unsigned index,
                                    struct pipe_texture *texture) {
+      struct pipe_sampler_view templ;
+
       if(!texture)
          texture = $self->default_texture;
-      pipe_texture_reference(&$self->vertex_sampler_textures[index], texture);
-      $self->pipe->set_vertex_sampler_textures($self->pipe,
-                                               PIPE_MAX_VERTEX_SAMPLERS,
-                                               $self->vertex_sampler_textures);
+      pipe_sampler_view_reference(&$self->vertex_sampler_views[index], NULL);
+      u_sampler_view_default_template(&templ,
+                                      texture,
+                                      texture->format);
+      $self->vertex_sampler_views[index] = $self->pipe->create_sampler_view($self->pipe,
+                                                                            texture,
+                                                                            &templ);
+      
+      $self->pipe->set_vertex_sampler_views($self->pipe,
+                                            PIPE_MAX_VERTEX_SAMPLERS,
+                                            $self->vertex_sampler_views);
    }
 
    void set_vertex_buffer(unsigned index,
@@ -263,8 +280,11 @@ struct st_context {
       struct pipe_context *pipe = $self->pipe;
       struct pipe_screen *screen = pipe->screen;
       struct pipe_buffer *vbuf;
+      struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
+      struct pipe_vertex_buffer vbuffer;
       float *map;
       unsigned size;
+      unsigned i;
 
       size = num_verts * num_attribs * 4 * sizeof(float);
 
@@ -280,15 +300,44 @@ struct st_context {
          goto error2;
       memcpy(map, vertices, size);
       pipe_buffer_unmap(screen, vbuf);
-      
-      util_draw_vertex_buffer(pipe, vbuf, 0, prim, num_verts, num_attribs);
-      
+
+      cso_save_vertex_elements($self->cso);
+
+      /* tell pipe about the vertex attributes */
+      for (i = 0; i < num_attribs; i++) {
+         velements[i].src_offset = i * 4 * sizeof(float);
+         velements[i].instance_divisor = 0;
+         velements[i].vertex_buffer_index = 0;
+         velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+      }
+      cso_set_vertex_elements($self->cso, num_attribs, velements);
+
+      /* tell pipe about the vertex buffer */
+      memset(&vbuffer, 0, sizeof(vbuffer));
+      vbuffer.buffer = vbuf;
+      vbuffer.stride = num_attribs * 4 * sizeof(float);  /* vertex size */
+      vbuffer.buffer_offset = 0;
+      vbuffer.max_index = num_verts - 1;
+      pipe->set_vertex_buffers(pipe, 1, &vbuffer);
+
+      /* draw */
+      pipe->draw_arrays(pipe, prim, 0, num_verts);
+
+      cso_restore_vertex_elements($self->cso);
+
 error2:
       pipe_buffer_reference(&vbuf, NULL);
 error1:
       ;
    }
    
+   void
+   clear(unsigned buffers, const float *rgba, double depth = 0.0f,
+         unsigned stencil = 0)
+   {
+      $self->pipe->clear($self->pipe, buffers, rgba, depth, stencil);
+   }
+
    void
    flush(unsigned flags = 0) {
       struct pipe_fence_handle *fence = NULL; 
@@ -345,10 +394,253 @@ error1:
       pipe_surface_reference(&_dst, NULL);
    }
 
-   void clear(unsigned buffers, const float *rgba, double depth = 0.0f,
-              unsigned stencil = 0)
+   %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
+   void
+   surface_read_raw(struct st_surface *surface,
+                    unsigned x, unsigned y, unsigned w, unsigned h,
+                    char **STRING, int *LENGTH)
    {
-      $self->pipe->clear($self->pipe, buffers, rgba, depth, stencil);
+      struct pipe_texture *texture = surface->texture;
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_transfer *transfer;
+      unsigned stride;
+
+      stride = util_format_get_stride(texture->format, w);
+      *LENGTH = util_format_get_nblocksy(texture->format, h) * stride;
+      *STRING = (char *) malloc(*LENGTH);
+      if(!*STRING)
+         return;
+
+      transfer = pipe->get_tex_transfer(pipe,
+                                          surface->texture,
+                                          surface->face,
+                                          surface->level,
+                                          surface->zslice,
+                                          PIPE_TRANSFER_READ,
+                                          x, y, w, h);
+      if(transfer) {
+         pipe_get_tile_raw(pipe, transfer, 0, 0, w, h, *STRING, stride);
+         pipe->tex_transfer_destroy(pipe, transfer);
+      }
+   }
+
+   %cstring_input_binary(const char *STRING, unsigned LENGTH);
+   void
+   surface_write_raw(struct st_surface *surface,
+                     unsigned x, unsigned y, unsigned w, unsigned h,
+                     const char *STRING, unsigned LENGTH, unsigned stride = 0)
+   {
+      struct pipe_texture *texture = surface->texture;
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_transfer *transfer;
+
+      if(stride == 0)
+         stride = util_format_get_stride(texture->format, w);
+
+      if(LENGTH < util_format_get_nblocksy(texture->format, h) * stride)
+         SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
+
+      transfer = pipe->get_tex_transfer(pipe,
+                                          surface->texture,
+                                          surface->face,
+                                          surface->level,
+                                          surface->zslice,
+                                          PIPE_TRANSFER_WRITE,
+                                          x, y, w, h);
+      if(!transfer)
+         SWIG_exception(SWIG_MemoryError, "couldn't initiate transfer");
+
+      pipe_put_tile_raw(pipe, transfer, 0, 0, w, h, STRING, stride);
+      pipe->tex_transfer_destroy(pipe, transfer);
+
+   fail:
+      return;
+   }
+
+   void
+   surface_read_rgba(struct st_surface *surface,
+                     unsigned x, unsigned y, unsigned w, unsigned h,
+                     float *rgba)
+   {
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_transfer *transfer;
+      transfer = pipe->get_tex_transfer(pipe,
+                                          surface->texture,
+                                          surface->face,
+                                          surface->level,
+                                          surface->zslice,
+                                          PIPE_TRANSFER_READ,
+                                          x, y, w, h);
+      if(transfer) {
+         pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba);
+         pipe->tex_transfer_destroy(pipe, transfer);
+      }
+   }
+
+   void
+   surface_write_rgba(struct st_surface *surface,
+                      unsigned x, unsigned y, unsigned w, unsigned h,
+                      const float *rgba)
+   {
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_transfer *transfer;
+      transfer = pipe->get_tex_transfer(pipe,
+                                          surface->texture,
+                                          surface->face,
+                                          surface->level,
+                                          surface->zslice,
+                                          PIPE_TRANSFER_WRITE,
+                                          x, y, w, h);
+      if(transfer) {
+         pipe_put_tile_rgba(pipe, transfer, 0, 0, w, h, rgba);
+         pipe->tex_transfer_destroy(pipe, transfer);
+      }
+   }
+
+   %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
+   void
+   surface_read_rgba8(struct st_surface *surface,
+                      unsigned x, unsigned y, unsigned w, unsigned h,
+                      char **STRING, int *LENGTH)
+   {
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_transfer *transfer;
+      float *rgba;
+      unsigned char *rgba8;
+      unsigned i, j, k;
+
+      *LENGTH = 0;
+      *STRING = NULL;
+
+      if (!surface)
+         return;
+
+      *LENGTH = h*w*4;
+      *STRING = (char *) malloc(*LENGTH);
+      if(!*STRING)
+         return;
+
+      rgba = malloc(h*w*4*sizeof(float));
+      if(!rgba)
+         return;
+
+      rgba8 = (unsigned char *) *STRING;
+
+      transfer = pipe->get_tex_transfer(pipe,
+                                          surface->texture,
+                                          surface->face,
+                                          surface->level,
+                                          surface->zslice,
+                                          PIPE_TRANSFER_READ,
+                                          x, y,
+                                          w, h);
+      if(transfer) {
+         pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba);
+         for(j = 0; j < h; ++j) {
+            for(i = 0; i < w; ++i)
+               for(k = 0; k <4; ++k)
+                  rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[j*w*4 + i*4 + k]);
+         }
+         pipe->tex_transfer_destroy(pipe, transfer);
+      }
+
+      free(rgba);
+   }
+
+   void
+   surface_read_z(struct st_surface *surface,
+                  unsigned x, unsigned y, unsigned w, unsigned h,
+                  unsigned *z)
+   {
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_transfer *transfer;
+      transfer = pipe->get_tex_transfer(pipe,
+                                          surface->texture,
+                                          surface->face,
+                                          surface->level,
+                                          surface->zslice,
+                                          PIPE_TRANSFER_READ,
+                                          x, y, w, h);
+      if(transfer) {
+         pipe_get_tile_z(pipe, transfer, 0, 0, w, h, z);
+         pipe->tex_transfer_destroy(pipe, transfer);
+      }
+   }
+
+   void
+   surface_write_z(struct st_surface *surface,
+                   unsigned x, unsigned y, unsigned w, unsigned h,
+                   const unsigned *z)
+   {
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_transfer *transfer;
+      transfer = pipe->get_tex_transfer(pipe,
+                                          surface->texture,
+                                          surface->face,
+                                          surface->level,
+                                          surface->zslice,
+                                          PIPE_TRANSFER_WRITE,
+                                          x, y, w, h);
+      if(transfer) {
+         pipe_put_tile_z(pipe, transfer, 0, 0, w, h, z);
+         pipe->tex_transfer_destroy(pipe, transfer);
+      }
+   }
+
+   void
+   surface_sample_rgba(struct st_surface *surface,
+                       float *rgba)
+   {
+      st_sample_surface($self->pipe, surface, rgba);
+   }
+
+   unsigned
+   surface_compare_rgba(struct st_surface *surface,
+                        unsigned x, unsigned y, unsigned w, unsigned h,
+                        const float *rgba, float tol = 0.0)
+   {
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_transfer *transfer;
+      float *rgba2;
+      const float *p1;
+      const float *p2;
+      unsigned i, j, n;
+
+      rgba2 = MALLOC(h*w*4*sizeof(float));
+      if(!rgba2)
+         return ~0;
+
+      transfer = pipe->get_tex_transfer(pipe,
+                                          surface->texture,
+                                          surface->face,
+                                          surface->level,
+                                          surface->zslice,
+                                          PIPE_TRANSFER_READ,
+                                          x, y, w, h);
+      if(!transfer) {
+         FREE(rgba2);
+         return ~0;
+      }
+
+      pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba2);
+      pipe->tex_transfer_destroy(pipe, transfer);
+
+      p1 = rgba;
+      p2 = rgba2;
+      n = 0;
+      for(i = h*w; i; --i) {
+         unsigned differs = 0;
+         for(j = 4; j; --j) {
+            float delta = *p2++ - *p1++;
+            if (delta < -tol || delta > tol)
+                differs = 1;
+         }
+         n += differs;
+      }
+
+      FREE(rgba2);
+
+      return n;
    }
 
 };
index 761587dc533bbd4b24350a63570026789ec7f02b..923a6285289cd6adc9b6a935434175804ff0ee9c 100644 (file)
@@ -124,234 +124,6 @@ struct st_surface
       FREE($self);
    }
    
-   %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
-   void get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH)
-   {
-      struct pipe_texture *texture = $self->texture;
-      struct pipe_screen *screen = texture->screen;
-      struct pipe_transfer *transfer;
-      unsigned stride;
-
-      stride = util_format_get_stride(texture->format, w);
-      *LENGTH = util_format_get_nblocksy(texture->format, h) * stride;
-      *STRING = (char *) malloc(*LENGTH);
-      if(!*STRING)
-         return;
-
-      transfer = screen->get_tex_transfer(screen,
-                                          $self->texture,
-                                          $self->face,
-                                          $self->level,
-                                          $self->zslice,
-                                          PIPE_TRANSFER_READ,
-                                          x, y, w, h);
-      if(transfer) {
-         pipe_get_tile_raw(transfer, 0, 0, w, h, *STRING, stride);
-         screen->tex_transfer_destroy(transfer);
-      }
-   }
-
-   %cstring_input_binary(const char *STRING, unsigned LENGTH);
-   void put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const char *STRING, unsigned LENGTH, unsigned stride = 0)
-   {
-      struct pipe_texture *texture = $self->texture;
-      struct pipe_screen *screen = texture->screen;
-      struct pipe_transfer *transfer;
-     
-      if(stride == 0)
-         stride = util_format_get_stride(texture->format, w);
-      
-      if(LENGTH < util_format_get_nblocksy(texture->format, h) * stride)
-         SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
-         
-      transfer = screen->get_tex_transfer(screen,
-                                          $self->texture,
-                                          $self->face,
-                                          $self->level,
-                                          $self->zslice,
-                                          PIPE_TRANSFER_WRITE,
-                                          x, y, w, h);
-      if(!transfer)
-         SWIG_exception(SWIG_MemoryError, "couldn't initiate transfer");
-         
-      pipe_put_tile_raw(transfer, 0, 0, w, h, STRING, stride);
-      screen->tex_transfer_destroy(transfer);
-
-   fail:
-      return;
-   }
-
-   void
-   get_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, float *rgba) 
-   {
-      struct pipe_screen *screen = $self->texture->screen;
-      struct pipe_transfer *transfer;
-      transfer = screen->get_tex_transfer(screen,
-                                          $self->texture,
-                                          $self->face,
-                                          $self->level,
-                                          $self->zslice,
-                                          PIPE_TRANSFER_READ,
-                                          x, y, w, h);
-      if(transfer) {
-         pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba);
-         screen->tex_transfer_destroy(transfer);
-      }
-   }
-
-   void
-   put_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba)
-   {
-      struct pipe_screen *screen = $self->texture->screen;
-      struct pipe_transfer *transfer;
-      transfer = screen->get_tex_transfer(screen,
-                                          $self->texture,
-                                          $self->face,
-                                          $self->level,
-                                          $self->zslice,
-                                          PIPE_TRANSFER_WRITE,
-                                          x, y, w, h);
-      if(transfer) {
-         pipe_put_tile_rgba(transfer, 0, 0, w, h, rgba);
-         screen->tex_transfer_destroy(transfer);
-      }
-   }
-
-   %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
-   void
-   get_tile_rgba8(unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) 
-   {
-      struct pipe_screen *screen = $self->texture->screen;
-      struct pipe_transfer *transfer;
-      float *rgba;
-      unsigned char *rgba8;
-      unsigned i, j, k;
-
-      *LENGTH = 0;
-      *STRING = NULL;
-      
-      if (!$self)
-         return;
-
-      *LENGTH = h*w*4;
-      *STRING = (char *) malloc(*LENGTH);
-      if(!*STRING)
-         return;
-      
-      rgba = malloc(h*w*4*sizeof(float));
-      if(!rgba)
-         return;
-      
-      rgba8 = (unsigned char *) *STRING;
-
-      transfer = screen->get_tex_transfer(screen,
-                                          $self->texture,
-                                          $self->face,
-                                          $self->level,
-                                          $self->zslice,
-                                          PIPE_TRANSFER_READ,
-                                          x, y,
-                                          w, h);
-      if(transfer) {
-         pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba);
-         for(j = 0; j < h; ++j) {
-            for(i = 0; i < w; ++i)
-               for(k = 0; k <4; ++k)
-                  rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[j*w*4 + i*4 + k]);
-         }
-         screen->tex_transfer_destroy(transfer);
-      }
-      
-      free(rgba);
-   }
-
-   void
-   get_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, unsigned *z)
-   {
-      struct pipe_screen *screen = $self->texture->screen;
-      struct pipe_transfer *transfer;
-      transfer = screen->get_tex_transfer(screen,
-                                          $self->texture,
-                                          $self->face,
-                                          $self->level,
-                                          $self->zslice,
-                                          PIPE_TRANSFER_READ,
-                                          x, y, w, h);
-      if(transfer) {
-         pipe_get_tile_z(transfer, 0, 0, w, h, z);
-         screen->tex_transfer_destroy(transfer);
-      }
-   }
-
-   void
-   put_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, const unsigned *z)
-   {
-      struct pipe_screen *screen = $self->texture->screen;
-      struct pipe_transfer *transfer;
-      transfer = screen->get_tex_transfer(screen,
-                                          $self->texture,
-                                          $self->face,
-                                          $self->level,
-                                          $self->zslice,
-                                          PIPE_TRANSFER_WRITE,
-                                          x, y, w, h);
-      if(transfer) {
-         pipe_put_tile_z(transfer, 0, 0, w, h, z);
-         screen->tex_transfer_destroy(transfer);
-      }
-   }
-   
-   void
-   sample_rgba(float *rgba) {
-      st_sample_surface($self, rgba);
-   }
-   
-   unsigned
-   compare_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba, float tol = 0.0) 
-   {
-      struct pipe_screen *screen = $self->texture->screen;
-      struct pipe_transfer *transfer;
-      float *rgba2;
-      const float *p1;
-      const float *p2;
-      unsigned i, j, n;
-      
-      rgba2 = MALLOC(h*w*4*sizeof(float));
-      if(!rgba2)
-         return ~0;
-
-      transfer = screen->get_tex_transfer(screen,
-                                          $self->texture,
-                                          $self->face,
-                                          $self->level,
-                                          $self->zslice,
-                                          PIPE_TRANSFER_READ,
-                                          x, y, w, h);
-      if(!transfer) {
-         FREE(rgba2);
-         return ~0;
-      }
-
-      pipe_get_tile_rgba(transfer, 0, 0, w, h, rgba2);
-      screen->tex_transfer_destroy(transfer);
-
-      p1 = rgba;
-      p2 = rgba2;
-      n = 0;
-      for(i = h*w; i; --i) {
-         unsigned differs = 0;
-         for(j = 4; j; --j) {
-            float delta = *p2++ - *p1++;
-            if (delta < -tol || delta > tol)
-                differs = 1;
-         }
-         n += differs;
-      }
-      
-      FREE(rgba2);
-      
-      return n;
-   }
 
 };
 
index 335e8e7f0d854c1d6dc7b8a3443c47d0d6b29ad5..44d65e3fc1e3b29c0c4375959260bb92ef90d111 100644 (file)
 #include "pipe/p_shader_tokens.h"
 #include "util/u_inlines.h"
 #include "cso_cache/cso_context.h"
+#include "util/u_inlines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_sampler.h"
 #include "util/u_simple_shaders.h"
 #include "trace/tr_public.h"
 
@@ -124,9 +126,9 @@ st_context_destroy(struct st_context *st_ctx)
          st_ctx->pipe->destroy(st_ctx->pipe);
       
       for(i = 0; i < PIPE_MAX_SAMPLERS; ++i)
-         pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], NULL);
+         pipe_sampler_view_reference(&st_ctx->fragment_sampler_views[i], NULL);
       for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
-         pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], NULL);
+         pipe_sampler_view_reference(&st_ctx->vertex_sampler_views[i], NULL);
       pipe_texture_reference(&st_ctx->default_texture, NULL);
 
       FREE(st_ctx);
@@ -227,9 +229,12 @@ st_context_create(struct st_device *st_dev)
 
    /* default textures */
    {
+      struct pipe_context *pipe = st_ctx->pipe;
       struct pipe_screen *screen = st_dev->screen;
       struct pipe_texture templat;
       struct pipe_transfer *transfer;
+      struct pipe_sampler_view view_templ;
+      struct pipe_sampler_view *view;
       unsigned i;
 
       memset( &templat, 0, sizeof( templat ) );
@@ -242,31 +247,44 @@ st_context_create(struct st_device *st_dev)
    
       st_ctx->default_texture = screen->texture_create( screen, &templat );
       if(st_ctx->default_texture) {
-         transfer = screen->get_tex_transfer(screen,
-                                             st_ctx->default_texture,
-                                             0, 0, 0,
-                                             PIPE_TRANSFER_WRITE,
-                                             0, 0,
-                                             st_ctx->default_texture->width0,
-                                             st_ctx->default_texture->height0);
+         transfer = pipe->get_tex_transfer(pipe,
+                                       st_ctx->default_texture,
+                                       0, 0, 0,
+                                       PIPE_TRANSFER_WRITE,
+                                       0, 0,
+                                       st_ctx->default_texture->width0,
+                                       st_ctx->default_texture->height0);
          if (transfer) {
             uint32_t *map;
-            map = (uint32_t *) screen->transfer_map(screen, transfer);
+            map = (uint32_t *) pipe->transfer_map(pipe, transfer);
             if(map) {
                *map = 0x00000000;
-               screen->transfer_unmap(screen, transfer);
+               pipe->transfer_unmap(pipe, transfer);
             }
-            screen->tex_transfer_destroy(transfer);
+            pipe->tex_transfer_destroy(pipe, transfer);
          }
       }
-   
+
+      u_sampler_view_default_template(&view_templ,
+                                      st_ctx->default_texture,
+                                      st_ctx->default_texture->format);
+      view = st_ctx->pipe->create_sampler_view(st_ctx->pipe,
+                                               st_ctx->default_texture,
+                                               &view_templ);
+
       for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
-         pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], st_ctx->default_texture);
+         pipe_sampler_view_reference(&st_ctx->fragment_sampler_views[i], view);
       for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
-         pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], st_ctx->default_texture);
-      
-      cso_set_sampler_textures(st_ctx->cso, PIPE_MAX_SAMPLERS, st_ctx->fragment_sampler_textures);
-      cso_set_vertex_sampler_textures(st_ctx->cso, PIPE_MAX_VERTEX_SAMPLERS, st_ctx->vertex_sampler_textures);
+         pipe_sampler_view_reference(&st_ctx->vertex_sampler_views[i], view);
+
+      st_ctx->pipe->set_fragment_sampler_views(st_ctx->pipe,
+                                               PIPE_MAX_SAMPLERS,
+                                               st_ctx->fragment_sampler_views);
+      st_ctx->pipe->set_vertex_sampler_views(st_ctx->pipe,
+                                             PIPE_MAX_VERTEX_SAMPLERS,
+                                             st_ctx->vertex_sampler_views);
+
+      pipe_sampler_view_reference(&view, NULL);
    }
    
    /* vertex shader */
index 6ec7409b11d48ec338ff649feb40e303eec3b733..dcd0dc6e2737beb57a3ae2aa04a0cc4fabfcfdd2 100644 (file)
@@ -60,8 +60,8 @@ struct st_context
    void *gs;
 
    struct pipe_texture *default_texture;
-   struct pipe_texture *fragment_sampler_textures[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *vertex_sampler_textures[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
    
    unsigned num_vertex_buffers;
    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
index e18081534613bfaf74c27c4956bc0618b410f266..e2c1e0601747d25ba934afda5a28c3c74c76882d 100644 (file)
@@ -523,29 +523,30 @@ st_sample_pixel_block(enum pipe_format format,
 
 
 void
-st_sample_surface(struct st_surface *surface, float *rgba) 
+st_sample_surface(struct pipe_context *pipe,
+                  struct st_surface *surface,
+                  float *rgba)
 {
    struct pipe_texture *texture = surface->texture;
-   struct pipe_screen *screen = texture->screen;
    unsigned width = u_minify(texture->width0, surface->level);
    unsigned height = u_minify(texture->height0, surface->level);
    uint rgba_stride = width * 4;
    struct pipe_transfer *transfer;
    void *raw;
 
-   transfer = screen->get_tex_transfer(screen,
-                                       surface->texture,
-                                       surface->face,
-                                       surface->level,
-                                       surface->zslice,
-                                       PIPE_TRANSFER_WRITE,
-                                       0, 0,
-                                       width,
-                                       height);
+   transfer = pipe->get_tex_transfer(pipe,
+                                     surface->texture,
+                                     surface->face,
+                                     surface->level,
+                                     surface->zslice,
+                                     PIPE_TRANSFER_WRITE,
+                                     0, 0,
+                                     width,
+                                     height);
    if (!transfer)
       return;
 
-   raw = screen->transfer_map(screen, transfer);
+   raw = pipe->transfer_map(pipe, transfer);
    if (raw) {
       enum pipe_format format = texture->format;
       uint x, y;
@@ -567,8 +568,8 @@ st_sample_surface(struct st_surface *surface, float *rgba)
          }
       }
 
-      screen->transfer_unmap(screen, transfer);
+      pipe->transfer_unmap(pipe, transfer);
    }
    
-   screen->tex_transfer_destroy(transfer);
+   pipe->tex_transfer_destroy(pipe, transfer);
 }
index 888114d3021d899c76f564fb92f9cc26442dbedc..6fb8417add8895c1738314548c34e23ae8827129 100644 (file)
@@ -32,6 +32,9 @@
 
 #include "pipe/p_format.h"
 
+struct pipe_context;
+struct st_surface;
+
 
 void 
 st_sample_pixel_block(enum pipe_format format,
@@ -40,7 +43,9 @@ st_sample_pixel_block(enum pipe_format format,
                       unsigned w, unsigned h);
 
 void
-st_sample_surface(struct st_surface *surface, float *rgba);
+st_sample_surface(struct pipe_context *pipe,
+                  struct st_surface *surface,
+                  float *rgba);
 
 
 #endif /* ST_SAMPLE_H_ */
index 985374190c3dd4efc6cb25a90e2ef96ccb70f5c0..0a332aaa9f1a3a3c6749e5abe84ddb95c0e1717e 100644 (file)
@@ -30,7 +30,7 @@
 #include "softpipe/sp_public.h"
 #include "llvmpipe/lp_public.h"
 #include "state_tracker/sw_winsys.h"
-#include "null/null_sw_winsys.h"
+#include "sw/null/null_sw_winsys.h"
 #include "st_winsys.h"
 
 
index 7f04b2aa8327a328e9a2614b2f2c9c87ee47481d..7c315de8271a9b676728ebc2185faa3bdd18bec1 100644 (file)
@@ -25,6 +25,7 @@ VG_SOURCES = \
            api_transform.c \
            vgu.c        \
            vg_context.c \
+           vg_manager.c \
            vg_state.c   \
            vg_tracker.c \
            vg_translate.c \
index 47db102dd2de37c4fe3b036dd089e49eb16a9f2f..eb2fbe26e7fc9dc1881675df74f869bb2d1924b2 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "VG/openvg.h"
 
+#include "vg_manager.h"
 #include "vg_context.h"
 
 #include "pipe/p_context.h"
@@ -55,6 +56,8 @@ void vgFlush(void)
 
    pipe = ctx->pipe;
    pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+   vg_manager_flush_frontbuffer(ctx);
 }
 
 void vgFinish(void)
index 18e2cc1f2501fa96050d1f43b5df29867b41f0ae..a643f38624fd709da57c3fcaa18a949a8e841885 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "util/u_format.h"
 #include "util/u_memory.h"
+#include "util/u_sampler.h"
 
 
 #include "asm_filters.h"
@@ -53,7 +54,7 @@ struct filter_info {
    const void *const_buffer;
    VGint const_buffer_len;
    VGTilingMode tiling_mode;
-   struct pipe_texture *extra_texture;
+   struct pipe_sampler_view *extra_texture_view;
 };
 
 static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx,
@@ -91,13 +92,35 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx,
    return tex;
 }
 
+static INLINE struct pipe_sampler_view *create_texture_1d_view(struct vg_context *ctx,
+                                                               const VGuint *color_data,
+                                                               const VGint color_data_len)
+{
+   struct pipe_context *pipe = ctx->pipe;
+   struct pipe_texture *texture;
+   struct pipe_sampler_view view_templ;
+   struct pipe_sampler_view *view;
+
+   texture = create_texture_1d(ctx, color_data, color_data_len);
+
+   if (!texture)
+      return NULL;
+
+   u_sampler_view_default_template(&view_templ, texture, texture->format);
+   view = pipe->create_sampler_view(pipe, texture, &view_templ);
+   /* want the texture to go away if the view is freed */
+   pipe_texture_reference(&texture, NULL);
+
+   return view;
+}
+
 static INLINE struct pipe_surface * setup_framebuffer(struct vg_image *dst)
 {
    struct vg_context *ctx = vg_current_context();
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_framebuffer_state fb;
    struct pipe_surface *dst_surf = pipe->screen->get_tex_surface(
-      pipe->screen, dst->texture, 0, 0, 0,
+      pipe->screen, dst->sampler_view->texture, 0, 0, 0,
       PIPE_BUFFER_USAGE_GPU_WRITE);
 
    /* drawing dest */
@@ -168,7 +191,7 @@ static void setup_constant_buffer(struct vg_context *ctx, const void *buffer,
 static void setup_samplers(struct vg_context *ctx, struct filter_info *info)
 {
    struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
    struct pipe_sampler_state sampler[3];
    int num_samplers = 0;
    int num_textures = 0;
@@ -177,10 +200,10 @@ static void setup_samplers(struct vg_context *ctx, struct filter_info *info)
    samplers[1] = NULL;
    samplers[2] = NULL;
    samplers[3] = NULL;
-   textures[0] = NULL;
-   textures[1] = NULL;
-   textures[2] = NULL;
-   textures[3] = NULL;
+   sampler_views[0] = NULL;
+   sampler_views[1] = NULL;
+   sampler_views[2] = NULL;
+   sampler_views[3] = NULL;
 
    memset(&sampler[0], 0, sizeof(struct pipe_sampler_state));
    sampler[0].wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
@@ -215,21 +238,21 @@ static void setup_samplers(struct vg_context *ctx, struct filter_info *info)
    }
 
    samplers[0] = &sampler[0];
-   textures[0] = info->src->texture;
+   sampler_views[0] = info->src->sampler_view;
    ++num_samplers;
    ++num_textures;
 
-   if (info->extra_texture) {
+   if (info->extra_texture_view) {
       memcpy(&sampler[1], &sampler[0], sizeof(struct pipe_sampler_state));
       samplers[1] = &sampler[1];
-      textures[1] = info->extra_texture;
+      sampler_views[1] = info->extra_texture_view;
       ++num_samplers;
       ++num_textures;
    }
 
 
    cso_set_samplers(ctx->cso_context, num_samplers, (const struct pipe_sampler_state **)samplers);
-   cso_set_sampler_textures(ctx->cso_context, num_textures, textures);
+   cso_set_fragment_sampler_views(ctx->cso_context, num_textures, sampler_views);
 }
 
 static struct vg_shader * setup_color_matrix(struct vg_context *ctx, void *user_data)
@@ -308,7 +331,7 @@ static void execute_filter(struct vg_context *ctx,
    cso_save_viewport(ctx->cso_context);
    cso_save_blend(ctx->cso_context);
    cso_save_samplers(ctx->cso_context);
-   cso_save_sampler_textures(ctx->cso_context);
+   cso_save_fragment_sampler_views(ctx->cso_context);
 
    dst_surf = setup_framebuffer(info->dst);
    setup_viewport(info->dst);
@@ -318,7 +341,7 @@ static void execute_filter(struct vg_context *ctx,
    setup_samplers(ctx, info);
 
    renderer_draw_texture(ctx->renderer,
-                         info->src->texture,
+                         info->src->sampler_view->texture,
                          info->dst->x, info->dst->y,
                          info->dst->x + info->dst->width,
                          info->dst->y + info->dst->height,
@@ -331,7 +354,7 @@ static void execute_filter(struct vg_context *ctx,
    cso_restore_viewport(ctx->cso_context);
    cso_restore_blend(ctx->cso_context);
    cso_restore_samplers(ctx->cso_context);
-   cso_restore_sampler_textures(ctx->cso_context);
+   cso_restore_fragment_sampler_views(ctx->cso_context);
 
    vg_shader_destroy(ctx, shader);
 
@@ -369,7 +392,7 @@ void vgColorMatrix(VGImage dst, VGImage src,
    info.const_buffer = matrix;
    info.const_buffer_len = 20 * sizeof(VGfloat);
    info.tiling_mode = VG_TILE_PAD;
-   info.extra_texture = 0;
+   info.extra_texture_view = NULL;
    execute_filter(ctx, &info);
 }
 
@@ -479,7 +502,7 @@ void vgConvolve(VGImage dst, VGImage src,
    info.const_buffer = buffer;
    info.const_buffer_len = buffer_len * sizeof(VGfloat);
    info.tiling_mode = tilingMode;
-   info.extra_texture = 0;
+   info.extra_texture_view = NULL;
    execute_filter(ctx, &info);
 
    free(buffer);
@@ -669,7 +692,7 @@ void vgGaussianBlur(VGImage dst, VGImage src,
    info.const_buffer = buffer;
    info.const_buffer_len = buffer_len * sizeof(VGfloat);
    info.tiling_mode = tilingMode;
-   info.extra_texture = 0;
+   info.extra_texture_view = NULL;
    execute_filter(ctx, &info);
 
    free(buffer);
@@ -688,7 +711,7 @@ void vgLookup(VGImage dst, VGImage src,
    struct vg_image *d, *s;
    VGuint color_data[256];
    VGint i;
-   struct pipe_texture *lut_texture;
+   struct pipe_sampler_view *lut_texture_view;
    VGfloat buffer[4];
    struct filter_info info;
 
@@ -714,7 +737,7 @@ void vgLookup(VGImage dst, VGImage src,
       color_data[i] = blueLUT[i] << 24 | greenLUT[i] << 16 |
                       redLUT[i]  <<  8 | alphaLUT[i];
    }
-   lut_texture = create_texture_1d(ctx, color_data, 255);
+   lut_texture_view = create_texture_1d_view(ctx, color_data, 255);
 
    buffer[0] = 0.f;
    buffer[1] = 0.f;
@@ -728,11 +751,11 @@ void vgLookup(VGImage dst, VGImage src,
    info.const_buffer = buffer;
    info.const_buffer_len = 4 * sizeof(VGfloat);
    info.tiling_mode = VG_TILE_PAD;
-   info.extra_texture = lut_texture;
+   info.extra_texture_view = lut_texture_view;
 
    execute_filter(ctx, &info);
 
-   pipe_texture_reference(&lut_texture, NULL);
+   pipe_sampler_view_reference(&lut_texture_view, NULL);
 }
 
 void vgLookupSingle(VGImage dst, VGImage src,
@@ -743,7 +766,7 @@ void vgLookupSingle(VGImage dst, VGImage src,
 {
    struct vg_context *ctx = vg_current_context();
    struct vg_image *d, *s;
-   struct pipe_texture *lut_texture;
+   struct pipe_sampler_view *lut_texture_view;
    VGfloat buffer[4];
    struct filter_info info;
    VGuint color_data[256];
@@ -783,7 +806,7 @@ void vgLookupSingle(VGImage dst, VGImage src,
       color_data[i] = blue << 24 | green << 16 |
                       red  <<  8 | alpha;
    }
-   lut_texture = create_texture_1d(ctx, color_data, 256);
+   lut_texture_view = create_texture_1d_view(ctx, color_data, 256);
 
    buffer[0] = 0.f;
    buffer[1] = 0.f;
@@ -797,9 +820,9 @@ void vgLookupSingle(VGImage dst, VGImage src,
    info.const_buffer = buffer;
    info.const_buffer_len = 4 * sizeof(VGfloat);
    info.tiling_mode = VG_TILE_PAD;
-   info.extra_texture = lut_texture;
+   info.extra_texture_view = lut_texture_view;
 
    execute_filter(ctx, &info);
 
-   pipe_texture_reference(&lut_texture, NULL);
+   pipe_sampler_view_reference(&lut_texture_view, NULL);
 }
index 7eb5ea1f07829eefcd7b6acdfbf6fa93c3012bc2..2f2d925252d5a26b8c9124b803dac59c3a44795a 100644 (file)
@@ -117,10 +117,6 @@ clear_with_quad(struct vg_context *st, float x0, float y0,
      x1, y1);
    */
 
-   if (st->pipe->screen && st->pipe->screen->update_buffer)
-      st->pipe->screen->update_buffer( st->pipe->screen,
-                                       st->pipe->priv );
-
    cso_save_blend(st->cso_context);
    cso_save_rasterizer(st->cso_context);
    cso_save_fragment_shader(st->cso_context);
index a71579cd2642807d095a879107b6886c30434a92..c3268a84a602cf6fc76ff7ec563d4ebae0b5fce1 100644 (file)
@@ -43,6 +43,7 @@
 #include "util/u_tile.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
+#include "util/u_sampler.h"
 
 static enum pipe_format vg_format_to_pipe(VGImageFormat format)
 {
@@ -81,7 +82,7 @@ static INLINE void vg_sync_size(VGfloat *src_loc, VGfloat *dst_loc)
 
 static void vg_copy_texture(struct vg_context *ctx,
                             struct pipe_texture *dst, VGint dx, VGint dy,
-                            struct pipe_texture *src, VGint sx, VGint sy,
+                            struct pipe_sampler_view *src, VGint sx, VGint sy,
                             VGint width, VGint height)
 {
    VGfloat dst_loc[4], src_loc[4];
@@ -103,8 +104,8 @@ static void vg_copy_texture(struct vg_context *ctx,
    src_loc[3] = height;
    src_bounds[0] = 0.f;
    src_bounds[1] = 0.f;
-   src_bounds[2] = src->width0;
-   src_bounds[3] = src->height0;
+   src_bounds[2] = src->texture->width0;
+   src_bounds[3] = src->texture->height0;
 
    vg_bound_rect(src_loc, src_bounds, src_shift);
    vg_bound_rect(dst_loc, dst_bounds, dst_shift);
@@ -218,7 +219,7 @@ void vg_copy_surface(struct vg_context *ctx,
 
 static struct pipe_texture *image_texture(struct vg_image *img)
 {
-   struct pipe_texture *tex = img->texture;
+   struct pipe_texture *tex = img->sampler_view->texture;
    return tex;
 }
 
@@ -247,9 +248,12 @@ struct vg_image * image_create(VGImageFormat format,
                                VGint width, VGint height)
 {
    struct vg_context *ctx = vg_current_context();
+   struct pipe_context *pipe = ctx->pipe;
    struct vg_image *image = CALLOC_STRUCT(vg_image);
    enum pipe_format pformat = vg_format_to_pipe(format);
    struct pipe_texture pt, *newtex;
+   struct pipe_sampler_view view_templ;
+   struct pipe_sampler_view *view;
    struct pipe_screen *screen = ctx->pipe->screen;
 
    vg_init_object(&image->base, ctx, VG_OBJECT_IMAGE);
@@ -281,7 +285,12 @@ struct vg_image * image_create(VGImageFormat format,
 
    debug_assert(newtex);
 
-   image->texture = newtex;
+   u_sampler_view_default_template(&view_templ, newtex, newtex->format);
+   view = pipe->create_sampler_view(pipe, newtex, &view_templ);
+   /* want the texture to go away if the view is freed */
+   pipe_texture_reference(&newtex, NULL);
+
+   image->sampler_view = view;
 
    vg_context_add_object(ctx, VG_OBJECT_IMAGE, image);
 
@@ -345,7 +354,7 @@ void image_destroy(struct vg_image *img)
       array_destroy(img->children_array);
    }
 
-   pipe_texture_reference(&img->texture, NULL);
+   pipe_sampler_view_reference(&img->sampler_view, NULL);
    free(img);
 }
 
@@ -444,7 +453,7 @@ void image_get_sub_data(struct vg_image * image,
    {
       struct pipe_transfer *transfer =
          pipe->get_tex_transfer(pipe,
-                                  image->texture,  0, 0, 0,
+                                  image->sampler_view->texture,  0, 0, 0,
                                   PIPE_TRANSFER_READ,
                                   0, 0,
                                   image->x + image->width,
@@ -478,9 +487,9 @@ struct vg_image * image_child_image(struct vg_image *parent,
    image->width = width;
    image->height = height;
    image->parent = parent;
-   image->texture = 0;
-   pipe_texture_reference(&image->texture,
-                          parent->texture);
+   image->sampler_view = NULL;
+   pipe_sampler_view_reference(&image->sampler_view,
+                               parent->sampler_view);
 
    image->sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
    image->sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
@@ -514,8 +523,8 @@ void image_copy(struct vg_image *dst, VGint dx, VGint dy,
    }
    /* make sure rendering has completed */
    ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-   vg_copy_texture(ctx, dst->texture, dst->x + dx, dst->y + dy,
-                   src->texture, src->x + sx, src->y + sy, width, height);
+   vg_copy_texture(ctx, dst->sampler_view->texture, dst->x + dx, dst->y + dy,
+                   src->sampler_view, src->x + sx, src->y + sy, width, height);
 }
 
 void image_draw(struct vg_image *img)
@@ -624,12 +633,12 @@ VGboolean vg_image_overlaps(struct vg_image *dst,
 }
 
 VGint image_bind_samplers(struct vg_image *img, struct pipe_sampler_state **samplers,
-                          struct pipe_texture **textures)
+                          struct pipe_sampler_view **sampler_views)
 {
    img->sampler.min_img_filter = image_sampler_filter(img->base.ctx);
    img->sampler.mag_img_filter = image_sampler_filter(img->base.ctx);
    samplers[3] = &img->sampler;
-   textures[3] = img->texture;
+   sampler_views[3] = img->sampler_view;
    return 1;
 }
 
index 78e17cffa649abf185821e3c1e9f686bbf5befbf..805b35fab9f0f203e4a5923c7c025e9d6d578bff 100644 (file)
@@ -43,7 +43,7 @@ struct vg_image {
 
    struct vg_image *parent;
 
-   struct pipe_texture *texture;
+   struct pipe_sampler_view *sampler_view;
    struct pipe_sampler_state sampler;
 
    struct array *children_array;
@@ -89,7 +89,7 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy,
                       VGint width, VGint height);
 
 VGint image_bind_samplers(struct vg_image *dst, struct pipe_sampler_state **samplers,
-                          struct pipe_texture **textures);
+                          struct pipe_sampler_view **sampler_views);
 
 VGboolean vg_image_overlaps(struct vg_image *dst,
                             struct vg_image *src);
index 839dc19a3b837f5fef1ee42d3c152e1e40cb67ea..316ea7a9c959cfaa0d8ec51f38d24a9472d810ef 100644 (file)
@@ -45,7 +45,7 @@ struct vg_mask_layer {
    VGint width;
    VGint height;
 
-   struct pipe_texture *texture;
+   struct pipe_sampler_view *sampler_view;
 };
 
 static INLINE struct pipe_surface *
@@ -54,7 +54,7 @@ alpha_mask_surface(struct vg_context *ctx, int usage)
    struct pipe_screen *screen = ctx->pipe->screen;
    struct st_framebuffer *stfb = ctx->draw_buffer;
    return screen->get_tex_surface(screen,
-                                  stfb->alpha_mask,
+                                  stfb->alpha_mask_view->texture,
                                   0, 0, 0,
                                   usage);
 }
@@ -284,35 +284,33 @@ static void setup_mask_operation(VGMaskOperation operation)
    cso_set_fragment_shader_handle(ctx->cso_context, shader);
 }
 
-static void setup_mask_samplers(struct pipe_texture *umask)
+static void setup_mask_samplers(struct pipe_sampler_view *umask)
 {
    struct vg_context *ctx = vg_current_context();
    struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
    struct st_framebuffer *fb_buffers = ctx->draw_buffer;
-   struct pipe_texture *uprev = NULL;
+   struct pipe_sampler_view *uprev = NULL;
    struct pipe_sampler_state sampler;
 
-   uprev = fb_buffers->blend_texture;
+   uprev = fb_buffers->blend_texture_view;
    sampler = ctx->mask.sampler;
    sampler.normalized_coords = 1;
 
    samplers[0] = NULL;
    samplers[1] = NULL;
-   samplers[2] = NULL;
-   textures[0] = NULL;
-   textures[1] = NULL;
-   textures[2] = NULL;
+   sampler_views[0] = NULL;
+   sampler_views[1] = NULL;
 
    samplers[0] = &sampler;
    samplers[1] = &ctx->mask.sampler;
 
-   textures[0] = umask;
-   textures[1] = uprev;
+   sampler_views[0] = umask;
+   sampler_views[1] = uprev;
 
    cso_set_samplers(ctx->cso_context, 2,
                     (const struct pipe_sampler_state **)samplers);
-   cso_set_sampler_textures(ctx->cso_context, 2, textures);
+   cso_set_fragment_sampler_views(ctx->cso_context, 2, sampler_views);
 }
 
 
@@ -411,12 +409,13 @@ static void surface_fill(struct pipe_surface *surf,
 }
 
 
-static void mask_using_texture(struct pipe_texture *texture,
+static void mask_using_texture(struct pipe_sampler_view *sampler_view,
                                VGMaskOperation operation,
                                VGint x, VGint y,
                                VGint width, VGint height)
 {
    struct vg_context *ctx = vg_current_context();
+   struct pipe_texture *texture = sampler_view->texture;
    struct pipe_surface *surface =
       alpha_mask_surface(ctx, PIPE_BUFFER_USAGE_GPU_WRITE);
    VGint offsets[4], loc[4];
@@ -439,13 +438,13 @@ static void mask_using_texture(struct pipe_texture *texture,
    vg_prepare_blend_surface_from_mask(ctx);
 
    cso_save_samplers(ctx->cso_context);
-   cso_save_sampler_textures(ctx->cso_context);
+   cso_save_fragment_sampler_views(ctx->cso_context);
    cso_save_framebuffer(ctx->cso_context);
    cso_save_blend(ctx->cso_context);
    cso_save_fragment_shader(ctx->cso_context);
    cso_save_viewport(ctx->cso_context);
 
-   setup_mask_samplers(texture);
+   setup_mask_samplers(sampler_view);
    setup_mask_blend();
    setup_mask_operation(operation);
    setup_mask_framebuffer(surface, surface->width, surface->height);
@@ -463,7 +462,7 @@ static void mask_using_texture(struct pipe_texture *texture,
    cso_restore_framebuffer(ctx->cso_context);
    cso_restore_fragment_shader(ctx->cso_context);
    cso_restore_samplers(ctx->cso_context);
-   cso_restore_sampler_textures(ctx->cso_context);
+   cso_restore_fragment_sampler_views(ctx->cso_context);
    cso_restore_viewport(ctx->cso_context);
 
    pipe_surface_reference(&surface, NULL);
@@ -484,7 +483,11 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height)
 
    {
       struct pipe_texture pt;
+      struct pipe_context *pipe = ctx->pipe;
       struct pipe_screen *screen = ctx->pipe->screen;
+      struct pipe_sampler_view view_templ;
+      struct pipe_sampler_view *view = NULL;
+      struct pipe_texture *texture;
 
       memset(&pt, 0, sizeof(pt));
       pt.target = PIPE_TEXTURE_2D;
@@ -496,7 +499,14 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height)
       pt.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
       pt.compressed = 0;
 
-      mask->texture = screen->texture_create(screen, &pt);
+      texture = screen->texture_create(screen, &pt);
+
+      if (texture) {
+         u_sampler_view_default_template(&view_templ, texture, texture->format);
+         view = pipe->create_sampler_view(pipe, texture, &view_templ);
+      }
+      pipe_texture_reference(&texture, NULL);
+      mask->sampler_view = view;
    }
 
    vg_context_add_object(ctx, VG_OBJECT_MASK, mask);
@@ -525,7 +535,7 @@ void mask_layer_fill(struct vg_mask_layer *layer,
    alpha_color[3] = value;
 
    surface = ctx->pipe->screen->get_tex_surface(
-      ctx->pipe->screen, layer->texture,
+      ctx->pipe->screen, layer->sampler_view->texture,
       0, 0, 0,
       PIPE_BUFFER_USAGE_GPU_WRITE);
 
@@ -545,10 +555,10 @@ void mask_copy(struct vg_mask_layer *layer,
     struct st_framebuffer *fb_buffers = ctx->draw_buffer;
 
     renderer_copy_texture(ctx->renderer,
-                          layer->texture,
+                          layer->sampler_view,
                           sx, sy,
                           sx + width, sy + height,
-                          fb_buffers->alpha_mask,
+                          fb_buffers->alpha_mask_view->texture,
                           dx, dy,
                           dx + width, dy + height);
 }
@@ -562,7 +572,7 @@ static void mask_layer_render_to(struct vg_mask_layer *layer,
    struct pipe_screen *screen = ctx->pipe->screen;
    struct pipe_surface *surface;
 
-   surface = screen->get_tex_surface(screen, layer->texture,  0, 0, 0,
+   surface = screen->get_tex_surface(screen, layer->sampler_view->texture,  0, 0, 0,
                                      PIPE_BUFFER_USAGE_GPU_WRITE);
 
    cso_save_framebuffer(ctx->cso_context);
@@ -604,8 +614,8 @@ void mask_render_to(struct path *path,
    struct vg_mask_layer *temp_layer;
    VGint width, height;
 
-   width = fb_buffers->alpha_mask->width0;
-   height = fb_buffers->alpha_mask->width0;
+   width = fb_buffers->alpha_mask_view->texture->width0;
+   height = fb_buffers->alpha_mask_view->texture->width0;
 
    temp_layer = mask_layer_create(width, height);
 
@@ -622,7 +632,7 @@ void mask_using_layer(struct vg_mask_layer *layer,
                       VGint x, VGint y,
                       VGint width, VGint height)
 {
-   mask_using_texture(layer->texture, operation,
+   mask_using_texture(layer->sampler_view, operation,
                       x, y, width, height);
 }
 
@@ -644,7 +654,7 @@ void mask_using_image(struct vg_image *image,
                       VGint x, VGint y,
                       VGint width, VGint height)
 {
-   mask_using_texture(image->texture, operation,
+   mask_using_texture(image->sampler_view, operation,
                       x, y, width, height);
 }
 
@@ -672,7 +682,7 @@ void mask_fill(VGint x, VGint y, VGint width, VGint height,
 }
 
 VGint mask_bind_samplers(struct pipe_sampler_state **samplers,
-                         struct pipe_texture **textures)
+                         struct pipe_sampler_view **sampler_views)
 {
    struct vg_context *ctx = vg_current_context();
 
@@ -680,7 +690,7 @@ VGint mask_bind_samplers(struct pipe_sampler_state **samplers,
       struct st_framebuffer *fb_buffers = ctx->draw_buffer;
 
       samplers[1] = &ctx->mask.sampler;
-      textures[1] = fb_buffers->alpha_mask;
+      sampler_views[1] = fb_buffers->alpha_mask_view;
       return 1;
    } else
       return 0;
index 5eaaede0e3a5b6c167b7b06839fe8b50d2eaaa74..4feacbefda8ca92de7ff57427f7dc6cd12ee842a 100644 (file)
@@ -63,6 +63,6 @@ void mask_fill(VGint x, VGint y,
                VGfloat value);
 
 VGint mask_bind_samplers(struct pipe_sampler_state **samplers,
-                         struct pipe_texture **textures);
+                         struct pipe_sampler_view **sampler_views);
 
 #endif
index dc56b8c5f3b8094b418a8f27a360981954f61d77..508e1863a5796f59c21b436d4e25d8e51836e6e7 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
+#include "util/u_sampler.h"
 
 #include "cso_cache/cso_context.h"
 
@@ -61,7 +62,7 @@ struct vg_paint {
          VGfloat vals[5];
          VGint valsi[5];
       } radial;
-      struct pipe_texture *texture;
+      struct pipe_sampler_view *sampler_view;
       struct pipe_sampler_state sampler;
 
       VGfloat *ramp_stops;
@@ -72,7 +73,7 @@ struct vg_paint {
    } gradient;
 
    struct {
-      struct pipe_texture *texture;
+      struct pipe_sampler_view *sampler_view;
       VGTilingMode tiling_mode;
       struct pipe_sampler_state sampler;
    } pattern;
@@ -173,6 +174,26 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p)
    return tex;
 }
 
+static INLINE struct pipe_sampler_view *create_gradient_sampler_view(struct vg_paint *p)
+{
+   struct pipe_context *pipe = p->base.ctx->pipe;
+   struct pipe_texture *texture;
+   struct pipe_sampler_view view_templ;
+   struct pipe_sampler_view *view;
+
+   texture = create_gradient_texture(p);
+
+   if (!texture)
+      return NULL;
+
+   u_sampler_view_default_template(&view_templ, texture, texture->format);
+   view = pipe->create_sampler_view(pipe, texture, &view_templ);
+   /* want the texture to go away if the view is freed */
+   pipe_texture_reference(&texture, NULL);
+
+   return view;
+}
+
 struct vg_paint * paint_create(struct vg_context *ctx)
 {
    struct vg_paint *paint = CALLOC_STRUCT(vg_paint);
@@ -207,8 +228,9 @@ struct vg_paint * paint_create(struct vg_context *ctx)
 void paint_destroy(struct vg_paint *paint)
 {
    struct vg_context *ctx = paint->base.ctx;
-   if (paint->pattern.texture)
-      pipe_texture_reference(&paint->pattern.texture, NULL);
+   pipe_sampler_view_reference(&paint->gradient.sampler_view, NULL);
+   if (paint->pattern.sampler_view)
+      pipe_sampler_view_reference(&paint->pattern.sampler_view, NULL);
    if (ctx)
       vg_context_remove_object(ctx, VG_OBJECT_PAINT, paint);
 
@@ -329,8 +351,8 @@ static INLINE void  paint_pattern_buffer(struct vg_paint *paint, void *buffer)
 
    map[4] = 0.f;
    map[5] = 1.f;
-   map[6] = paint->pattern.texture->width0;
-   map[7] = paint->pattern.texture->height0;
+   map[6] = paint->pattern.sampler_view->texture->width0;
+   map[7] = paint->pattern.sampler_view->texture->height0;
    {
       struct matrix mat;
       memcpy(&mat, &ctx->state.vg.fill_paint_to_user_matrix,
@@ -394,12 +416,12 @@ void paint_set_ramp_stops(struct vg_paint *paint, const VGfloat *stops,
    create_gradient_data(stops, num / 5, paint->gradient.color_data,
                         1024);
 
-   if (paint->gradient.texture) {
-      pipe_texture_reference(&paint->gradient.texture, NULL);
-      paint->gradient.texture = 0;
+   if (paint->gradient.sampler_view) {
+      pipe_sampler_view_reference(&paint->gradient.sampler_view, NULL);
+      paint->gradient.sampler_view = NULL;
    }
 
-   paint->gradient.texture = create_gradient_texture(paint);
+   paint->gradient.sampler_view = create_gradient_sampler_view(paint);
 }
 
 void paint_set_colori(struct vg_paint *p,
@@ -459,12 +481,12 @@ void paint_set_radial_gradient(struct vg_paint *paint,
 void paint_set_pattern(struct vg_paint *paint,
                        struct vg_image *img)
 {
-   if (paint->pattern.texture)
-      pipe_texture_reference(&paint->pattern.texture, NULL);
+   if (paint->pattern.sampler_view)
+      pipe_sampler_view_reference(&paint->pattern.sampler_view, NULL);
 
-   paint->pattern.texture = 0;
-   pipe_texture_reference(&paint->pattern.texture,
-                          img->texture);
+   paint->pattern.sampler_view = NULL;
+   pipe_sampler_view_reference(&paint->pattern.sampler_view,
+                               img->sampler_view);
 }
 
 void paint_set_pattern_tiling(struct vg_paint *paint,
@@ -611,18 +633,18 @@ VGTilingMode paint_pattern_tiling(struct vg_paint *paint)
 }
 
 VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **samplers,
-                          struct pipe_texture **textures)
+                          struct pipe_sampler_view **sampler_views)
 {
    struct vg_context *ctx = vg_current_context();
 
    switch(paint->type) {
    case VG_PAINT_TYPE_LINEAR_GRADIENT:
    case VG_PAINT_TYPE_RADIAL_GRADIENT: {
-      if (paint->gradient.texture) {
+      if (paint->gradient.sampler_view) {
          paint->gradient.sampler.min_img_filter = image_sampler_filter(ctx);
          paint->gradient.sampler.mag_img_filter = image_sampler_filter(ctx);
          samplers[0] = &paint->gradient.sampler;
-         textures[0] = paint->gradient.texture;
+         sampler_views[0] = paint->gradient.sampler_view;
          return 1;
       }
    }
@@ -634,7 +656,7 @@ VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **sa
       paint->pattern.sampler.min_img_filter = image_sampler_filter(ctx);
       paint->pattern.sampler.mag_img_filter = image_sampler_filter(ctx);
       samplers[0] = &paint->pattern.sampler;
-      textures[0] = paint->pattern.texture;
+      sampler_views[0] = paint->pattern.sampler_view;
       return 1;
    }
       break;
@@ -647,7 +669,7 @@ VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **sa
 void paint_resolve_type(struct vg_paint *paint)
 {
    if (paint->type == VG_PAINT_TYPE_PATTERN &&
-       !paint->pattern.texture) {
+       !paint->pattern.sampler_view) {
       paint->type = VG_PAINT_TYPE_COLOR;
    }
 }
index 999b5c167cad7f64ec016800f7ee283eee2aa8ba..9ea67c4b1e6f0fdb1656d1b53cac7db8fe709fc3 100644 (file)
@@ -108,7 +108,7 @@ VGboolean paint_color_ramp_premultiplied(struct vg_paint *paint);
 
 
 VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **samplers,
-                          struct pipe_texture **textures);
+                          struct pipe_sampler_view **sampler_views);
 
 VGint paint_constant_buffer_size(struct vg_paint *paint);
 void paint_fill_constant_buffer(struct vg_paint *paint,
index 47e8b470a11c94f881c11a1de257061170157234..2bb4c8bc756651149cc4d7fa06a4227370f90c6d 100644 (file)
@@ -39,6 +39,7 @@
 #include "util/u_simple_shaders.h"
 #include "util/u_memory.h"
 #include "util/u_rect.h"
+#include "util/u_sampler.h"
 
 #include "cso_cache/cso_context.h"
 
@@ -263,7 +264,7 @@ void renderer_draw_texture(struct renderer *r,
 }
 
 void renderer_copy_texture(struct renderer *ctx,
-                           struct pipe_texture *src,
+                           struct pipe_sampler_view *src,
                            VGfloat sx1, VGfloat sy1,
                            VGfloat sx2, VGfloat sy2,
                            struct pipe_texture *dst,
@@ -272,6 +273,7 @@ void renderer_copy_texture(struct renderer *ctx,
 {
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_screen *screen = pipe->screen;
+   struct pipe_texture *tex = src->texture;
    struct pipe_buffer *buf;
    struct pipe_surface *dst_surf = screen->get_tex_surface(
       screen, dst, 0, 0, 0,
@@ -279,8 +281,8 @@ void renderer_copy_texture(struct renderer *ctx,
    struct pipe_framebuffer_state fb;
    float s0, t0, s1, t1;
 
-   assert(src->width0 != 0);
-   assert(src->height0 != 0);
+   assert(tex->width0 != 0);
+   assert(tex->height0 != 0);
    assert(dst->width0 != 0);
    assert(dst->height0 != 0);
 
@@ -290,10 +292,10 @@ void renderer_copy_texture(struct renderer *ctx,
 #endif
 
 #if 1
-   s0 = sx1 / src->width0;
-   s1 = sx2 / src->width0;
-   t0 = sy1 / src->height0;
-   t1 = sy2 / src->height0;
+   s0 = sx1 / tex->width0;
+   s1 = sx2 / tex->width0;
+   t0 = sy1 / tex->height0;
+   t1 = sy2 / tex->height0;
 #else
    s0 = 0;
    s1 = 1;
@@ -307,7 +309,7 @@ void renderer_copy_texture(struct renderer *ctx,
    /* save state (restored below) */
    cso_save_blend(ctx->cso);
    cso_save_samplers(ctx->cso);
-   cso_save_sampler_textures(ctx->cso);
+   cso_save_fragment_sampler_views(ctx->cso);
    cso_save_framebuffer(ctx->cso);
    cso_save_fragment_shader(ctx->cso);
    cso_save_vertex_shader(ctx->cso);
@@ -345,7 +347,7 @@ void renderer_copy_texture(struct renderer *ctx,
    vg_set_viewport(ctx->owner, VEGA_Y0_TOP);
 
    /* texture */
-   cso_set_sampler_textures(ctx->cso, 1, &src);
+   cso_set_fragment_sampler_views(ctx->cso, 1, &src);
 
    /* shaders */
    cso_set_vertex_shader_handle(ctx->cso, vg_texture_vs(ctx->owner));
@@ -385,7 +387,7 @@ void renderer_copy_texture(struct renderer *ctx,
    /* restore state we changed */
    cso_restore_blend(ctx->cso);
    cso_restore_samplers(ctx->cso);
-   cso_restore_sampler_textures(ctx->cso);
+   cso_restore_fragment_sampler_views(ctx->cso);
    cso_restore_framebuffer(ctx->cso);
    cso_restore_vertex_shader(ctx->cso);
    cso_restore_fragment_shader(ctx->cso);
@@ -406,6 +408,8 @@ void renderer_copy_surface(struct renderer *ctx,
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_screen *screen = pipe->screen;
    struct pipe_buffer *buf;
+   struct pipe_sampler_view view_templ;
+   struct pipe_sampler_view *view;
    struct pipe_texture texTemp, *tex;
    struct pipe_surface *texSurf;
    struct pipe_framebuffer_state fb;
@@ -457,6 +461,12 @@ void renderer_copy_surface(struct renderer *ctx,
    if (!tex)
       return;
 
+   u_sampler_view_default_template(&view_templ, tex, tex->format);
+   view = pipe->create_sampler_view(pipe, tex, &view_templ);
+
+   if (!view)
+      return;
+
    texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0,
                                      PIPE_BUFFER_USAGE_GPU_WRITE);
 
@@ -479,7 +489,7 @@ void renderer_copy_surface(struct renderer *ctx,
    /* save state (restored below) */
    cso_save_blend(ctx->cso);
    cso_save_samplers(ctx->cso);
-   cso_save_sampler_textures(ctx->cso);
+   cso_save_fragment_sampler_views(ctx->cso);
    cso_save_framebuffer(ctx->cso);
    cso_save_fragment_shader(ctx->cso);
    cso_save_vertex_shader(ctx->cso);
@@ -515,7 +525,7 @@ void renderer_copy_surface(struct renderer *ctx,
    }
 
    /* texture */
-   cso_set_sampler_textures(ctx->cso, 1, &tex);
+   cso_set_fragment_sampler_views(ctx->cso, 1, &view);
 
    /* shaders */
    cso_set_fragment_shader_handle(ctx->cso, ctx->fs);
@@ -552,13 +562,14 @@ void renderer_copy_surface(struct renderer *ctx,
    /* restore state we changed */
    cso_restore_blend(ctx->cso);
    cso_restore_samplers(ctx->cso);
-   cso_restore_sampler_textures(ctx->cso);
+   cso_restore_fragment_sampler_views(ctx->cso);
    cso_restore_framebuffer(ctx->cso);
    cso_restore_fragment_shader(ctx->cso);
    cso_restore_vertex_shader(ctx->cso);
    cso_restore_viewport(ctx->cso);
 
    pipe_texture_reference(&tex, NULL);
+   pipe_sampler_view_reference(&view, NULL);
 }
 
 void renderer_texture_quad(struct renderer *r,
index 990cd32c3139f92cfe735af3c1fe2d440ae7b87a..03366f13614f419b4ace2caaedca396f4cea0bfd 100644 (file)
@@ -33,6 +33,7 @@ struct renderer;
 
 struct vg_context;
 struct pipe_texture;
+struct pipe_sampler_view;
 struct pipe_surface;
 
 struct renderer *renderer_create(struct vg_context *owner);
@@ -57,7 +58,7 @@ void renderer_texture_quad(struct renderer *,
                            VGfloat x3, VGfloat y3,
                            VGfloat x4, VGfloat y4);
 void renderer_copy_texture(struct renderer *r,
-                           struct pipe_texture *src,
+                           struct pipe_sampler_view *src,
                            VGfloat sx1, VGfloat sy1,
                            VGfloat sx2, VGfloat sy2,
                            struct pipe_texture *dst,
index 0e71a507bff2565cc8337f91c7260809ac0bd642..f2ec24c57ff219b59d1f108443818954bee2459c 100644 (file)
@@ -119,7 +119,7 @@ static void setup_constant_buffer(struct shader *shader)
 
 static VGint blend_bind_samplers(struct vg_context *ctx,
                                  struct pipe_sampler_state **samplers,
-                                 struct pipe_texture **textures)
+                                 struct pipe_sampler_view **sampler_views)
 {
    VGBlendMode bmode = ctx->state.vg.blend_mode;
 
@@ -132,15 +132,15 @@ static VGint blend_bind_samplers(struct vg_context *ctx,
       vg_prepare_blend_surface(ctx);
 
       samplers[2] = &ctx->blend_sampler;
-      textures[2] = stfb->blend_texture;
+      sampler_views[2] = stfb->blend_texture_view;
 
-      if (!samplers[0] || !textures[0]) {
+      if (!samplers[0] || !sampler_views[0]) {
          samplers[0] = samplers[2];
-         textures[0] = textures[2];
+         sampler_views[0] = sampler_views[2];
       }
-      if (!samplers[1] || !textures[1]) {
+      if (!samplers[1] || !sampler_views[1]) {
          samplers[1] = samplers[0];
-         textures[1] = textures[0];
+         sampler_views[1] = sampler_views[0];
       }
 
       return 1;
@@ -151,7 +151,7 @@ static VGint blend_bind_samplers(struct vg_context *ctx,
 static void setup_samplers(struct shader *shader)
 {
    struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
    struct vg_context *ctx = shader->context;
    /* a little wonky: we use the num as a boolean that just says
     * whether any sampler/textures have been set. the actual numbering
@@ -167,20 +167,20 @@ static void setup_samplers(struct shader *shader)
    samplers[1] = NULL;
    samplers[2] = NULL;
    samplers[3] = NULL;
-   textures[0] = NULL;
-   textures[1] = NULL;
-   textures[2] = NULL;
-   textures[3] = NULL;
-
-   num += paint_bind_samplers(shader->paint, samplers, textures);
-   num += mask_bind_samplers(samplers, textures);
-   num += blend_bind_samplers(ctx, samplers, textures);
+   sampler_views[0] = NULL;
+   sampler_views[1] = NULL;
+   sampler_views[2] = NULL;
+   sampler_views[3] = NULL;
+
+   num += paint_bind_samplers(shader->paint, samplers, sampler_views);
+   num += mask_bind_samplers(samplers, sampler_views);
+   num += blend_bind_samplers(ctx, samplers, sampler_views);
    if (shader->drawing_image && shader->image)
-      num += image_bind_samplers(shader->image, samplers, textures);
+      num += image_bind_samplers(shader->image, samplers, sampler_views);
 
    if (num) {
       cso_set_samplers(ctx->cso_context, 4, (const struct pipe_sampler_state **)samplers);
-      cso_set_sampler_textures(ctx->cso_context, 4, textures);
+      cso_set_fragment_sampler_views(ctx->cso_context, 4, sampler_views);
    }
 }
 
index 170391ec03117d5e9f1e59ca809ea81acc226775..11ebbbe54449402528e5f4e6d8cb93db9c41271f 100644 (file)
@@ -32,6 +32,7 @@
 #include "shader.h"
 #include "asm_util.h"
 #include "st_inlines.h"
+#include "vg_manager.h"
 
 #include "pipe/p_context.h"
 #include "util/u_inlines.h"
@@ -42,6 +43,7 @@
 #include "util/u_simple_shaders.h"
 #include "util/u_memory.h"
 #include "util/u_blit.h"
+#include "util/u_sampler.h"
 
 struct vg_context *_vg_context = 0;
 
@@ -305,6 +307,8 @@ static void update_clip_state(struct vg_context *ctx)
 
 void vg_validate_state(struct vg_context *ctx)
 {
+   vg_manager_validate_framebuffer(ctx);
+
    if ((ctx->state.dirty & BLEND_DIRTY)) {
       struct pipe_blend_state *blend = &ctx->state.g3d.blend;
       memset(blend, 0, sizeof(struct pipe_blend_state));
@@ -433,19 +437,24 @@ void vg_prepare_blend_surface(struct vg_context *ctx)
 {
    struct pipe_surface *dest_surface = NULL;
    struct pipe_context *pipe = ctx->pipe;
+   struct pipe_sampler_view *view;
+   struct pipe_sampler_view view_templ;
    struct st_framebuffer *stfb = ctx->draw_buffer;
    struct st_renderbuffer *strb = stfb->strb;
 
    /* first finish all pending rendering */
    vgFinish();
 
+   u_sampler_view_default_template(&view_templ, strb->texture, strb->texture->format);
+   view = pipe->create_sampler_view(pipe, strb->texture, &view_templ);
+
    dest_surface = pipe->screen->get_tex_surface(pipe->screen,
-                                                stfb->blend_texture,
+                                                stfb->blend_texture_view->texture,
                                                 0, 0, 0,
                                                 PIPE_BUFFER_USAGE_GPU_WRITE);
    /* flip it, because we want to use it as a sampler */
    util_blit_pixels_tex(ctx->blit,
-                        strb->texture,
+                        view,
                         0, strb->height,
                         strb->width, 0,
                         dest_surface,
@@ -458,6 +467,8 @@ void vg_prepare_blend_surface(struct vg_context *ctx)
 
    /* make sure it's complete */
    vgFinish();
+
+   pipe_sampler_view_reference(&view, NULL);
 }
 
 
@@ -474,13 +485,13 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx)
    vgFinish();
 
    dest_surface = pipe->screen->get_tex_surface(pipe->screen,
-                                                stfb->blend_texture,
+                                                stfb->blend_texture_view->texture,
                                                 0, 0, 0,
                                                 PIPE_BUFFER_USAGE_GPU_WRITE);
 
    /* flip it, because we want to use it as a sampler */
    util_blit_pixels_tex(ctx->blit,
-                        stfb->alpha_mask,
+                        stfb->alpha_mask_view,
                         0, strb->height,
                         strb->width, 0,
                         dest_surface,
index 804e9e76d77e2799a33732f348cc7dd3eefb07ed..c9e36d7d7679c8bfd0729ceffca0686b7154d2ec 100644 (file)
@@ -33,6 +33,7 @@
 #include "pipe/p_state.h"
 #include "util/u_pointer.h"
 #include "util/u_math.h"
+#include "state_tracker/st_api.h"
 
 #include "cso_cache/cso_hash.h"
 #include "cso_cache/cso_context.h"
@@ -54,9 +55,13 @@ struct st_framebuffer {
    struct st_renderbuffer *strb;
    struct st_renderbuffer *dsrb;
 
-   struct pipe_texture *alpha_mask;
+   struct pipe_sampler_view *alpha_mask_view;
 
-   struct pipe_texture *blend_texture;
+   struct pipe_sampler_view *blend_texture_view;
+
+
+   struct st_framebuffer_iface *iface;
+   enum st_attachment_type strb_att;
 
    void *privateData;
 };
@@ -84,6 +89,8 @@ enum dirty_state {
 
 struct vg_context
 {
+   struct st_context_iface iface;
+
    struct pipe_context *pipe;
 
    struct {
@@ -101,6 +108,7 @@ struct vg_context
    VGErrorCode _error;
 
    struct st_framebuffer *draw_buffer;
+   int32_t draw_buffer_invalid;
 
    struct cso_hash *owned_objects[VG_OBJECT_LAST];
 
diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c
new file mode 100644 (file)
index 0000000..25c2e85
--- /dev/null
@@ -0,0 +1,373 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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 "state_tracker/st_api.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_screen.h"
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+
+#include "vg_manager.h"
+#include "vg_context.h"
+#include "vg_tracker.h" /* for st_resize_framebuffer */
+#include "image.h"
+
+/**
+ * Flush the front buffer if the current context renders to the front buffer.
+ */
+void
+vg_manager_flush_frontbuffer(struct vg_context *ctx)
+{
+   struct st_framebuffer *stfb = ctx->draw_buffer;
+
+   if (!stfb)
+      return;
+
+   /* st_public.h is used */
+   if (!stfb->iface) {
+      struct pipe_screen *screen = ctx->pipe->screen;
+      if (screen->flush_frontbuffer) {
+         screen->flush_frontbuffer(screen,
+               stfb->strb->surface, ctx->pipe->priv);
+      }
+      return;
+   }
+
+   switch (stfb->strb_att) {
+   case ST_ATTACHMENT_FRONT_LEFT:
+   case ST_ATTACHMENT_FRONT_RIGHT:
+      stfb->iface->flush_front(stfb->iface, stfb->strb_att);
+      break;
+   default:
+      break;
+   }
+}
+
+/**
+ * Re-validate the framebuffer.
+ */
+void
+vg_manager_validate_framebuffer(struct vg_context *ctx)
+{
+   struct pipe_screen *screen = ctx->pipe->screen;
+   struct st_framebuffer *stfb = ctx->draw_buffer;
+   struct st_renderbuffer *rb;
+   struct pipe_texture *pt;
+
+   /* no binding surface */
+   if (!stfb)
+      return;
+
+   /* st_public.h is used */
+   if (!stfb->iface) {
+      struct pipe_screen *screen = ctx->pipe->screen;
+      if (screen->update_buffer)
+         screen->update_buffer(screen, ctx->pipe->priv);
+      return;
+   }
+
+   if (!p_atomic_read(&ctx->draw_buffer_invalid))
+      return;
+
+   /* validate the fb */
+   if (!stfb->iface->validate(stfb->iface, &stfb->strb_att, 1, &pt) || !pt)
+      return;
+
+   rb = stfb->strb;
+   if (rb->texture == pt) {
+      pipe_texture_reference(&pt, NULL);
+      return;
+   }
+
+   /* unreference existing ones */
+   pipe_surface_reference(&rb->surface, NULL);
+   pipe_texture_reference(&rb->texture, NULL);
+
+   rb->texture = pt;
+   rb->surface = screen->get_tex_surface(screen, rb->texture, 0, 0, 0,
+         PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE);
+
+   rb->width = rb->surface->width;
+   rb->height = rb->surface->height;
+
+   st_resize_framebuffer(stfb, rb->width, rb->height);
+
+   p_atomic_set(&ctx->draw_buffer_invalid, FALSE);
+}
+
+
+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);
+}
+
+static void
+vg_context_flush(struct st_context_iface *stctxi, unsigned flags,
+                 struct pipe_fence_handle **fence)
+{
+   struct vg_context *ctx = (struct vg_context *) stctxi;
+   ctx->pipe->flush(ctx->pipe, flags, fence);
+   if (flags & PIPE_FLUSH_RENDER_CACHE)
+      vg_manager_flush_frontbuffer(ctx);
+}
+
+static void
+vg_context_destroy(struct st_context_iface *stctxi)
+{
+   struct vg_context *ctx = (struct vg_context *) stctxi;
+   vg_destroy_context(ctx);
+}
+
+static struct st_context_iface *
+vg_api_create_context(struct st_api *stapi, struct st_manager *smapi,
+                      const struct st_visual *visual,
+                      struct st_context_iface *shared_stctxi)
+{
+   struct vg_context *shared_ctx = (struct vg_context *) shared_stctxi;
+   struct vg_context *ctx;
+   struct pipe_context *pipe;
+
+   pipe = smapi->screen->context_create(smapi->screen, NULL);
+   if (!pipe)
+      return NULL;
+   ctx = vg_create_context(pipe, NULL, shared_ctx);
+   if (!ctx) {
+      pipe->destroy(pipe);
+      return NULL;
+   }
+
+   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;
+   ctx->iface.copy = NULL;
+
+   ctx->iface.st_context_private = (void *) smapi;
+
+   return &ctx->iface;
+}
+
+static struct st_renderbuffer *
+create_renderbuffer(enum pipe_format format)
+{
+   struct st_renderbuffer *strb;
+
+   strb = CALLOC_STRUCT(st_renderbuffer);
+   if (strb)
+      strb->format = format;
+
+   return strb;
+}
+
+static void
+destroy_renderbuffer(struct st_renderbuffer *strb)
+{
+   pipe_surface_reference(&strb->surface, NULL);
+   pipe_texture_reference(&strb->texture, NULL);
+   free(strb);
+}
+
+/**
+ * Decide the buffer to render to.
+ */
+static enum st_attachment_type
+choose_attachment(struct st_framebuffer_iface *stfbi)
+{
+   enum st_attachment_type statt;
+
+   statt = stfbi->visual->render_buffer;
+   if (statt != ST_ATTACHMENT_INVALID) {
+      /* use the buffer given by the visual, unless it is unavailable */
+      if (!st_visual_have_buffers(stfbi->visual, 1 << statt)) {
+         switch (statt) {
+         case ST_ATTACHMENT_BACK_LEFT:
+            statt = ST_ATTACHMENT_FRONT_LEFT;
+            break;
+         case ST_ATTACHMENT_BACK_RIGHT:
+            statt = ST_ATTACHMENT_FRONT_RIGHT;
+            break;
+         default:
+            break;
+         }
+
+         if (!st_visual_have_buffers(stfbi->visual, 1 << statt))
+            statt = ST_ATTACHMENT_INVALID;
+      }
+   }
+
+   return statt;
+}
+
+/**
+ * Bind the context to the given framebuffers.
+ */
+static boolean
+vg_context_bind_framebuffers(struct st_context_iface *stctxi,
+                             struct st_framebuffer_iface *stdrawi,
+                             struct st_framebuffer_iface *streadi)
+{
+   struct vg_context *ctx = (struct vg_context *) stctxi;
+   struct st_framebuffer *stfb;
+   enum st_attachment_type strb_att;
+
+   /* the draw and read framebuffers must be the same */
+   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) {
+      stfb = ctx->draw_buffer;
+
+      /* free the existing fb */
+      if (!stdrawi ||
+          stfb->strb_att != strb_att ||
+          stfb->strb->format != stdrawi->visual->color_format ||
+          stfb->dsrb->format != stdrawi->visual->depth_stencil_format) {
+         destroy_renderbuffer(stfb->strb);
+         destroy_renderbuffer(stfb->dsrb);
+         free(stfb);
+
+         ctx->draw_buffer = NULL;
+      }
+   }
+
+   if (!stdrawi)
+      return TRUE;
+
+   if (strb_att == ST_ATTACHMENT_INVALID)
+      return FALSE;
+
+   /* create a new fb */
+   if (!ctx->draw_buffer) {
+      stfb = CALLOC_STRUCT(st_framebuffer);
+      if (!stfb)
+         return FALSE;
+
+      stfb->strb = create_renderbuffer(stdrawi->visual->color_format);
+      if (!stfb->strb) {
+         free(stfb);
+         return FALSE;
+      }
+
+      stfb->dsrb = create_renderbuffer(stdrawi->visual->depth_stencil_format);
+      if (!stfb->dsrb) {
+         free(stfb->strb);
+         free(stfb);
+         return FALSE;
+      }
+
+      stfb->width = 0;
+      stfb->height = 0;
+      stfb->strb_att = strb_att;
+
+      ctx->draw_buffer = stfb;
+   }
+
+   ctx->draw_buffer->iface = stdrawi;
+
+   return TRUE;
+}
+
+static boolean
+vg_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
+                    struct st_framebuffer_iface *stdrawi,
+                    struct st_framebuffer_iface *streadi)
+{
+   struct vg_context *ctx = (struct vg_context *) stctxi;
+
+   if (stctxi)
+      vg_context_bind_framebuffers(stctxi, stdrawi, streadi);
+   vg_set_current_context(ctx);
+
+   return TRUE;
+}
+
+static struct st_context_iface *
+vg_api_get_current(struct st_api *stapi)
+{
+   struct vg_context *ctx = vg_current_context();
+
+   return (ctx) ? &ctx->iface : NULL;
+}
+
+static boolean
+vg_api_is_visual_supported(struct st_api *stapi,
+                           const struct st_visual *visual)
+{
+   /* the impl requires a depth/stencil buffer */
+   if (visual->depth_stencil_format == PIPE_FORMAT_NONE)
+      return FALSE;
+
+   return TRUE;
+}
+
+static st_proc_t
+vg_api_get_proc_address(struct st_api *stapi, const char *procname)
+{
+   /* TODO */
+   return (st_proc_t) NULL;
+}
+
+static void
+vg_api_destroy(struct st_api *stapi)
+{
+   free(stapi);
+}
+
+static struct st_api *
+vg_module_create_api(void)
+{
+   struct st_api *stapi;
+
+   stapi = CALLOC_STRUCT(st_api);
+   if (stapi) {
+      stapi->destroy = vg_api_destroy;
+      stapi->get_proc_address = vg_api_get_proc_address;
+      stapi->is_visual_supported = vg_api_is_visual_supported;
+
+      stapi->create_context = vg_api_create_context;
+      stapi->make_current = vg_api_make_current;
+      stapi->get_current = vg_api_get_current;
+   }
+
+   return stapi;
+}
+
+PUBLIC const struct st_module st_module_OpenVG = {
+   .api = ST_API_OPENVG,
+   .create_api = vg_module_create_api,
+};
diff --git a/src/gallium/state_trackers/vega/vg_manager.h b/src/gallium/state_trackers/vega/vg_manager.h
new file mode 100644 (file)
index 0000000..1a276c0
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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>
+ */
+
+#ifndef VG_MANAGER_H
+#define VG_MANAGER_H
+
+#include "state_tracker/st_api.h"
+#include "vg_context.h"
+
+void
+vg_manager_flush_frontbuffer(struct vg_context *ctx);
+
+void
+vg_manager_validate_framebuffer(struct vg_context *ctx);
+
+#endif /* VG_MANAGER_H */
index ea5c2ce41f6f2df40d284fd86ec79b93fc5ad74e..f438e34087e71a87ad674fb6d957ffddedd50b2b 100644 (file)
@@ -32,6 +32,7 @@
 #include "util/u_inlines.h"
 #include "pipe/p_screen.h"
 #include "util/u_format.h"
+#include "util/u_sampler.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
 #include "util/u_rect.h"
@@ -41,7 +42,7 @@ PUBLIC const int st_api_OpenVG = 1;
 
 static struct pipe_texture *
 create_texture(struct pipe_context *pipe, enum pipe_format format,
-               VGint width, VGint height)
+                    VGint width, VGint height)
 {
    struct pipe_texture templ;
 
@@ -71,6 +72,27 @@ create_texture(struct pipe_context *pipe, enum pipe_format format,
    return pipe->screen->texture_create(pipe->screen, &templ);
 }
 
+static struct pipe_sampler_view *
+create_tex_and_view(struct pipe_context *pipe, enum pipe_format format,
+                    VGint width, VGint height)
+{
+   struct pipe_texture *texture;
+   struct pipe_sampler_view view_templ;
+   struct pipe_sampler_view *view;
+
+   texture = create_texture(pipe, format, width, height);
+
+   if (!texture)
+      return NULL;
+
+   u_sampler_view_default_template(&view_templ, texture, texture->format);
+   view = pipe->create_sampler_view(pipe, texture, &view_templ);
+   /* want the texture to go away if the view is freed */
+   pipe_texture_reference(&texture, NULL);
+
+   return view;
+}
+
 /**
  * Allocate a renderbuffer for a an on-screen window (not a user-created
  * renderbuffer).  The window system code determines the format.
@@ -115,8 +137,8 @@ st_renderbuffer_alloc_storage(struct vg_context * ctx,
    surface_usage = (PIPE_BUFFER_USAGE_GPU_READ  |
                     PIPE_BUFFER_USAGE_GPU_WRITE);
 
-   strb->texture = create_texture(pipe, strb->format,
-                                  width, height);
+   strb->texture = create_texture(pipe, strb->format, width, height);
+
 
    if (!strb->texture)
       return FALSE;
@@ -191,7 +213,7 @@ struct st_framebuffer * st_create_framebuffer(const void *visual,
       /*### currently we always allocate it but it's possible it's
         not necessary if EGL_ALPHA_MASK_SIZE was 0
       */
-      stfb->alpha_mask = 0;
+      stfb->alpha_mask_view = NULL;
 
       stfb->width = width;
       stfb->height = height;
@@ -206,19 +228,19 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
                                  uint width, uint height)
 {
    struct pipe_context *pipe = ctx->pipe;
-   struct pipe_texture *old_texture = stfb->alpha_mask;
+   struct pipe_sampler_view *old_sampler_view = stfb->alpha_mask_view;
 
    /*
      we use PIPE_FORMAT_B8G8R8A8_UNORM because we want to render to
      this texture and use it as a sampler, so while this wastes some
      space it makes both of those a lot simpler
    */
-   stfb->alpha_mask =
-      create_texture(pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height);
+   stfb->alpha_mask_view =
+      create_tex_and_view(pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height);
 
-   if (!stfb->alpha_mask) {
-      if (old_texture)
-         pipe_texture_reference(&old_texture, NULL);
+   if (!stfb->alpha_mask_view) {
+      if (old_sampler_view)
+         pipe_sampler_view_reference(&old_sampler_view, NULL);
       return;
    }
 
@@ -228,15 +250,15 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
    mask_fill(0, 0, width, height, 1.f);
 
    /* if we had an old surface copy it over */
-   if (old_texture) {
+   if (old_sampler_view) {
       struct pipe_surface *surface = pipe->screen->get_tex_surface(
          pipe->screen,
-         stfb->alpha_mask,
+         stfb->alpha_mask_view->texture,
          0, 0, 0,
          PIPE_BUFFER_USAGE_GPU_WRITE);
       struct pipe_surface *old_surface = pipe->screen->get_tex_surface(
          pipe->screen,
-         old_texture,
+         old_sampler_view->texture,
          0, 0, 0,
          PIPE_BUFFER_USAGE_GPU_READ);
       if (pipe->surface_copy) {
@@ -264,8 +286,8 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
 
    /* Free the old texture
     */
-   if (old_texture)
-      pipe_texture_reference(&old_texture, NULL);
+   if (old_sampler_view)
+      pipe_sampler_view_reference(&old_sampler_view, NULL);
 }
 
 void st_resize_framebuffer(struct st_framebuffer *stfb,
@@ -326,9 +348,9 @@ void st_resize_framebuffer(struct st_framebuffer *stfb,
 
    setup_new_alpha_mask(ctx, stfb, width, height);
 
-   pipe_texture_reference( &stfb->blend_texture, NULL );
-   stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM,
-                                        width, height);
+   pipe_sampler_view_reference( &stfb->blend_texture_view, NULL );
+   stfb->blend_texture_view = create_tex_and_view(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM,
+                                                  width, height);
 }
 
 void st_set_framebuffer_surface(struct st_framebuffer *stfb,
index 715a5e7b943e3b50128c49a798f775bfb62d7127..4ff48026e50a73a79ada4b3492ea8262a6741772 100644 (file)
@@ -4,6 +4,7 @@
 #include "xorg_exa_tgsi.h"
 
 #include "cso_cache/cso_context.h"
+#include "util/u_sampler.h"
 
 
 /*XXX also in Xrender.h but the including it here breaks compilition */
@@ -356,6 +357,9 @@ bind_samplers(struct exa_context *exa, int op,
 {
    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 = exa->pipe;
 
    exa->num_bound_samplers = 0;
 
@@ -366,7 +370,7 @@ bind_samplers(struct exa_context *exa, int op,
       if (exa->has_solid_color) {
          debug_assert(!"solid color with textures");
          samplers[0] = NULL;
-         exa->bound_textures[0] = NULL;
+         pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL);
       } else {
          unsigned src_wrap = render_repeat_to_gallium(
             pSrcPicture->repeatType);
@@ -381,8 +385,13 @@ bind_samplers(struct exa_context *exa, int op,
          src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
          src_sampler.normalized_coords = 1;
          samplers[0] = &src_sampler;
-         exa->bound_textures[0] = pSrc->tex;
          exa->num_bound_samplers = 1;
+         u_sampler_view_default_template(&view_templ,
+                                         pSrc->tex,
+                                         pSrc->tex->format);
+         src_view = pipe->create_sampler_view(pipe, pSrc->tex, &view_templ);
+         pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL);
+         exa->bound_sampler_views[0] = src_view;
       }
    }
 
@@ -400,14 +409,19 @@ bind_samplers(struct exa_context *exa, int op,
       src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
       mask_sampler.normalized_coords = 1;
       samplers[1] = &mask_sampler;
-      exa->bound_textures[1] = pMask->tex;
       exa->num_bound_samplers = 2;
+      u_sampler_view_default_template(&view_templ,
+                                      pMask->tex,
+                                      pMask->tex->format);
+      src_view = pipe->create_sampler_view(pipe, pMask->tex, &view_templ);
+      pipe_sampler_view_reference(&exa->bound_sampler_views[1], NULL);
+      exa->bound_sampler_views[1] = src_view;
    }
 
    cso_set_samplers(exa->renderer->cso, exa->num_bound_samplers,
                     (const struct pipe_sampler_state **)samplers);
-   cso_set_sampler_textures(exa->renderer->cso, exa->num_bound_samplers,
-                            exa->bound_textures);
+   cso_set_fragment_sampler_views(exa->renderer->cso, exa->num_bound_samplers,
+                                  exa->bound_sampler_views);
 }
 
 
@@ -476,7 +490,6 @@ boolean xorg_composite_bind_state(struct exa_context *exa,
       renderer_begin_solid(exa->renderer);
    } else {
       renderer_begin_textures(exa->renderer,
-                              exa->bound_textures,
                               exa->num_bound_samplers);
    }
 
@@ -506,7 +519,7 @@ void xorg_composite(struct exa_context *exa,
 
       renderer_texture(exa->renderer,
                        pos, width, height,
-                       exa->bound_textures,
+                       exa->bound_sampler_views,
                        exa->num_bound_samplers,
                        src_matrix, mask_matrix);
    }
@@ -538,7 +551,7 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
                              pixmap->width, pixmap->height);
    bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL);
    cso_set_samplers(exa->renderer->cso, 0, NULL);
-   cso_set_sampler_textures(exa->renderer->cso, 0, NULL);
+   cso_set_fragment_sampler_views(exa->renderer->cso, 0, NULL);
 
    shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits);
    cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs);
index bdec0e254fa781b8190858e02e9b574de0221289..76e6411bb8cb842e5641b5b5401e41550ba0dc88 100644 (file)
@@ -975,6 +975,9 @@ xorg_exa_close(ScrnInfoPtr pScrn)
    modesettingPtr ms = modesettingPTR(pScrn);
    struct exa_context *exa = ms->exa;
 
+   pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL);
+   pipe_sampler_view_reference(&exa->bound_sampler_views[1], NULL);
+
    renderer_destroy(exa->renderer);
 
    if (exa->pipe)
index f2cefe23b99df79aafe6728d124bf6ffc2a0b167..41b19061599e6ca65dc3d19efd8042e05bed04a5 100644 (file)
@@ -18,7 +18,7 @@ struct exa_context
    struct pipe_screen *scrn;
    struct xorg_renderer *renderer;
 
-   struct pipe_texture *bound_textures[MAX_EXA_SAMPLERS];
+   struct pipe_sampler_view *bound_sampler_views[MAX_EXA_SAMPLERS];
    int num_bound_samplers;
 
    float solid_color[4];
index 1eb926360b9d0182bca36b4787f004bfb8de0913..81b0dcf656f9789f47b20e66a27ab00b92aba654 100644 (file)
@@ -8,6 +8,7 @@
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_rect.h"
+#include "util/u_sampler.h"
 
 #include "util/u_inlines.h"
 
@@ -482,8 +483,17 @@ void renderer_copy_prepare(struct xorg_renderer *r,
                              dst_surface->width,
                              dst_surface->height);
 
-   /* texture */
-   cso_set_sampler_textures(r->cso, 1, &src_texture);
+   /* 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 */
    shader = xorg_shaders_get(r->shaders,
@@ -655,7 +665,6 @@ void renderer_draw_flush(struct xorg_renderer *r)
 }
 
 void renderer_begin_textures(struct xorg_renderer *r,
-                             struct pipe_texture **textures,
                              int num_textures)
 {
    r->attrs_per_vertex = 1 + num_textures;
@@ -665,7 +674,7 @@ void renderer_begin_textures(struct xorg_renderer *r,
 void renderer_texture(struct xorg_renderer *r,
                       int *pos,
                       int width, int height,
-                      struct pipe_texture **textures,
+                      struct pipe_sampler_view **sampler_view,
                       int num_textures,
                       float *src_matrix,
                       float *mask_matrix)
@@ -693,7 +702,7 @@ void renderer_texture(struct xorg_renderer *r,
                        pos[0], pos[1], /* src */
                        pos[4], pos[5], /* dst */
                        width, height,
-                       textures[0], src_matrix);
+                       sampler_view[0]->texture, src_matrix);
       break;
    case 3:
       renderer_draw_conditional(r, 4 * 12);
@@ -702,7 +711,7 @@ void renderer_texture(struct xorg_renderer *r,
                        pos[2], pos[3], /* mask */
                        pos[4], pos[5], /* dst */
                        width, height,
-                       textures[0], textures[1],
+                       sampler_view[0]->texture, sampler_view[1]->texture,
                        src_matrix, mask_matrix);
       break;
    default:
index 3d006287199a0828ab42939f2f431e9e3ba5257f..cc5802e79b2400ed51f10982bd138a24a8df23e6 100644 (file)
@@ -65,12 +65,12 @@ void renderer_solid(struct xorg_renderer *r,
                     float *color);
 
 void renderer_begin_textures(struct xorg_renderer *r,
-                             struct pipe_texture **textures,
                              int num_textures);
+
 void renderer_texture(struct xorg_renderer *r,
                       int *pos,
                       int width, int height,
-                      struct pipe_texture **textures,
+                      struct pipe_sampler_view **textures,
                       int num_textures,
                       float *src_matrix,
                       float *mask_matrix);
index 5a195cb482de7cf73e36a5227a83b6599f884057..5efda6837dea5dcf7a67e250011b9306fe15d7c6 100644 (file)
@@ -9,6 +9,7 @@
 #include "xorg_exa_tgsi.h"
 
 #include "cso_cache/cso_context.h"
+#include "util/u_sampler.h"
 
 #include "pipe/p_screen.h"
 
@@ -91,6 +92,7 @@ struct xorg_xv_port_priv {
    /* juggle two sets of seperate Y, U and V
     * textures */
    struct pipe_texture *yuv[2][3];
+   struct pipe_sampler_view *yuv_views[2][3];
 };
 
 
@@ -180,32 +182,60 @@ static int
 check_yuv_textures(struct xorg_xv_port_priv *priv,  int width, int height)
 {
    struct pipe_texture **dst = priv->yuv[priv->current_set];
+   struct pipe_sampler_view **dst_view = priv->yuv_views[priv->current_set];
+   struct pipe_sampler_view view_templ;
+   struct pipe_context *pipe = priv->r->pipe;
+
    if (!dst[0] ||
        dst[0]->width0 != width ||
        dst[0]->height0 != height) {
       pipe_texture_reference(&dst[0], NULL);
+      pipe_sampler_view_reference(&dst_view[0], NULL);
    }
    if (!dst[1] ||
        dst[1]->width0 != width ||
        dst[1]->height0 != height) {
       pipe_texture_reference(&dst[1], NULL);
+      pipe_sampler_view_reference(&dst_view[1], NULL);
    }
    if (!dst[2] ||
        dst[2]->width0 != width ||
        dst[2]->height0 != height) {
       pipe_texture_reference(&dst[2], NULL);
+      pipe_sampler_view_reference(&dst_view[2], NULL);
    }
 
-   if (!dst[0])
+   if (!dst[0]) {
       dst[0] = create_component_texture(priv->r->pipe, width, height);
+      if (dst[0]) {
+         u_sampler_view_default_template(&view_templ,
+                                         dst[0],
+                                         dst[0]->format);
+         dst_view[0] = pipe->create_sampler_view(pipe, dst[0], &view_templ);
+      }
+   }
 
-   if (!dst[1])
+   if (!dst[1]) {
       dst[1] = create_component_texture(priv->r->pipe, width, height);
+      if (dst[1]) {
+         u_sampler_view_default_template(&view_templ,
+                                         dst[1],
+                                         dst[1]->format);
+         dst_view[1] = pipe->create_sampler_view(pipe, dst[1], &view_templ);
+      }
+   }
 
-   if (!dst[2])
+   if (!dst[2]) {
       dst[2] = create_component_texture(priv->r->pipe, width, height);
+      if (dst[2]) {
+         u_sampler_view_default_template(&view_templ,
+                                      dst[2],
+                                      dst[2]->format);
+         dst_view[2] = pipe->create_sampler_view(pipe, dst[2], &view_templ);
+      }
+   }
 
-   if (!dst[0] || !dst[1] || !dst[2])
+   if (!dst[0] || !dst[1] || !dst[2] || !dst_view[0] || !dst_view[1] || !dst_view[2] )
       return BadAlloc;
 
    return Success;
@@ -450,6 +480,7 @@ bind_samplers(struct xorg_xv_port_priv *port)
    struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
    struct pipe_sampler_state sampler;
    struct pipe_texture **dst = port->yuv[port->current_set];
+   struct pipe_sampler_view **dst_views = port->yuv_views[port->current_set];
 
    memset(&sampler, 0, sizeof(struct pipe_sampler_state));
 
@@ -469,8 +500,7 @@ bind_samplers(struct xorg_xv_port_priv *port)
 
    cso_set_samplers(port->r->cso, 3,
                     (const struct pipe_sampler_state **)samplers);
-   cso_set_sampler_textures(port->r->cso, 3,
-                            dst);
+   cso_set_fragment_sampler_views(port->r->cso, 3, dst_views);
 }
 
 static int
diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
new file mode 100644 (file)
index 0000000..6d9b81a
--- /dev/null
@@ -0,0 +1,105 @@
+# -*-makefile-*-
+
+MESA_MODULES = \
+       $(TOP)/src/mesa/libmesagallium.a \
+       $(GALLIUM_AUXILIARIES)
+
+COMMON_GALLIUM_SOURCES = \
+        $(TOP)/src/mesa/drivers/dri/common/utils.c \
+        $(TOP)/src/mesa/drivers/dri/common/vblank.c \
+        $(TOP)/src/mesa/drivers/dri/common/dri_util.c \
+        $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c
+
+COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \
+        $(TOP)/src/mesa/drivers/common/driverfuncs.c \
+        $(TOP)/src/mesa/drivers/dri/common/texmem.c \
+        $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c
+
+COMMON_BM_SOURCES = \
+       $(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \
+       $(TOP)/src/mesa/drivers/dri/common/dri_drmpool.c
+
+INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES)
+
+OBJECTS = \
+       $(C_SOURCES:.c=.o) \
+       $(ASM_SOURCES:.S=.o) 
+
+
+### Include directories
+SHARED_INCLUDES = \
+       -I. \
+       -I$(TOP)/src/mesa/drivers/dri/common \
+       -Iserver \
+       -I$(TOP)/include \
+       -I$(TOP)/include/GL/internal \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/winsys/common \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/src/mesa/main \
+       -I$(TOP)/src/mesa/glapi \
+       -I$(TOP)/src/mesa/math \
+       -I$(TOP)/src/mesa/transform \
+       -I$(TOP)/src/mesa/shader \
+       -I$(TOP)/src/mesa/swrast \
+       -I$(TOP)/src/mesa/swrast_setup \
+       -I$(TOP)/src/egl/main \
+       -I$(TOP)/src/egl/drivers/dri \
+       $(LIBDRM_CFLAGS)
+
+
+##### RULES #####
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
+
+.S.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
+
+$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \
+               $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o
+       $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               $(OBJECTS) $(PIPE_DRIVERS) \
+                -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
+                 $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
+       $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
+       @rm -f $@.test
+       mv -f $@.tmp $@
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
+       $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
+
+depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_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 */*.o *~ *.so *~ server/*.o $(SYMLINKS)
+       -rm -f depend depend.bak
+
+
+install: $(LIBNAME)
+       $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+
+
+include depend
diff --git a/src/gallium/targets/Makefile.egl b/src/gallium/targets/Makefile.egl
new file mode 100644 (file)
index 0000000..9265e2e
--- /dev/null
@@ -0,0 +1,70 @@
+# src/gallium/winsys/drm/Makefile.egl
+
+# The driver Makefile should define
+#
+#   EGL_DRIVER_NAME, the name of the driver
+#   EGL_DRIVER_SOURCES, the sources of the driver
+#   EGL_DRIVER_LIBS, extra libraries needed by the driver
+#   EGL_DRIVER_PIPES, the pipe drivers of the driver
+#
+# before including this file.
+
+EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o)
+
+common_LIBS = -ldrm -lm -ldl
+
+# ximage backend calls gallium_wrap_screen, which requires libidentity.a and
+# libtrace.a
+x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \
+        $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \
+        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+        $(TOP)/src/gallium/drivers/identity/libidentity.a \
+        $(TOP)/src/gallium/drivers/trace/libtrace.a
+
+x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes
+
+kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a
+kms_LIBS = $(common_LIBS)
+
+##### RULES #####
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so)
+
+EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(TOP)/$(LIB_DIR)/$(drv))
+
+default: $(EGL_DISPLAY_LIBS)
+
+$(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so
+       $(INSTALL) $< $(TOP)/$(LIB_DIR)
+
+define mklib-egl
+$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+       $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \
+       -Wl,--start-group $($(1)_ST) $(EGL_DRIVER_PIPES) \
+       $(GALLIUM_AUXILIARIES) -Wl,--end-group \
+       $($(1)_LIBS) $(EGL_DRIVER_LIBS)
+endef
+
+egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile
+       $(call mklib-egl,x11)
+
+egl_kms_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(kms_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile
+       $(call mklib-egl,kms)
+
+clean:
+       -rm -f $(EGL_DRIVER_OBJECTS)
+       -rm -f $(EGL_DISPLAY_DRIVERS)
+
+install: $(EGL_DISPLAY_LIBS)
+       $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
+       for lib in $(EGL_DISPLAY_LIBS); do \
+               $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
+       done
+
+depend:
index df62fc65fb77bac4e1cfe07e4eb8acbe71afb475..1292d4f619334037543ae834e76aecc552fde0a8 100644 (file)
@@ -1,9 +1,4 @@
 Import('*')
-
-#if env['dri']:
-#      SConscript([
-#              'drm/SConscript',
-#      ])
        
 if 'xlib' in env['winsys']:
        SConscript([
@@ -14,3 +9,19 @@ if 'gdi' in env['winsys']:
        SConscript([
                'libgl-gdi/SConscript',
        ])
+
+if 'graw-xlib' in env['winsys']:
+       SConscript([
+               'graw-xlib/SConscript',
+       ])
+
+if env['dri']:
+       SConscript([
+               'SConscript.dri'
+       ])
+
+if 'xorg' in env['statetrackers']:
+       if 'vmware' in env['winsys']:
+               SConscript([
+                       'xorg-vmwgfx/SConscript',
+               ])
diff --git a/src/gallium/targets/SConscript.dri b/src/gallium/targets/SConscript.dri
new file mode 100644 (file)
index 0000000..210af13
--- /dev/null
@@ -0,0 +1,96 @@
+###################################
+# SConcscript file for dri targets
+
+Import('*')
+
+drienv = env.Clone()
+
+drienv.Replace(CPPPATH = [
+       '#src/mesa/drivers/dri/common',
+       '#include',
+       '#include/GL/internal',
+       '#src/gallium/include',
+       '#src/gallium/auxiliary',
+       '#src/gallium/drivers',
+       '#src/mesa',
+       '#src/mesa/main',
+       '#src/mesa/glapi',
+       '#src/mesa/math',
+       '#src/mesa/transform',
+       '#src/mesa/shader',
+       '#src/mesa/swrast',
+       '#src/mesa/swrast_setup',
+       '#src/egl/main',
+       '#src/egl/drivers/dri',
+])
+
+drienv.ParseConfig('pkg-config --cflags --libs libdrm')
+
+dri_common_utils = drienv.SharedObject(
+       target = 'utils.o',
+       source = '#src/mesa/drivers/dri/common/utils.c'
+)
+
+dri_common_xmlconfig = drienv.SharedObject(
+       target = 'xmlconfig.o',
+       source = '#src/mesa/drivers/dri/common/xmlconfig.c'
+)
+
+dri_common_vblank = drienv.SharedObject(
+       target = 'vblank.o',
+       source = '#src/mesa/drivers/dri/common/vblank.c'
+)
+
+dri_common_dri_util = drienv.SharedObject(
+       target = 'dri_util.o',
+       source = '#src/mesa/drivers/dri/common/dri_util.c'
+)
+
+dri_common_drisw_util = drienv.SharedObject(
+       target = 'drisw_util.o',
+       source = '#src/mesa/drivers/dri/common/drisw_util.c'
+)
+
+
+COMMON_DRI_SW_OBJECTS = [
+       dri_common_utils,
+       dri_common_xmlconfig,
+       dri_common_drisw_util,
+]
+
+COMMON_DRI_DRM_OBJECTS = [
+       dri_common_utils,
+       dri_common_xmlconfig,
+       dri_common_vblank,
+       dri_common_dri_util,
+]
+
+Export([
+       'drienv',
+       'COMMON_DRI_SW_OBJECTS',
+       'COMMON_DRI_DRM_OBJECTS',
+])
+
+SConscript([
+       'dri-swrast/SConscript',
+])
+
+if 'vmware' in env['winsys']:
+       SConscript([
+               'dri-vmwgfx/SConscript',
+       ])
+
+if 'i915' in env['winsys']:
+       SConscript([
+               'dri-i915/SConscript',
+       ])
+
+if 'i965' in env['winsys']:
+       SConscript([
+               'dri-i965/SConscript',
+       ])
+
+if 'radeon' in env['winsys']:
+       SConscript([
+               'dri-radeong/SConscript',
+       ])
diff --git a/src/gallium/targets/dri-i915/Makefile b/src/gallium/targets/dri-i915/Makefile
new file mode 100644 (file)
index 0000000..50a8e11
--- /dev/null
@@ -0,0 +1,22 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i915_dri.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
+       $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/drivers/identity/libidentity.a \
+       $(TOP)/src/gallium/drivers/i915/libi915.a
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+include ../Makefile.dri
+
+DRI_LIB_DEPS += -ldrm_intel
+
+symlinks:
diff --git a/src/gallium/targets/dri-i915/SConscript b/src/gallium/targets/dri-i915/SConscript
new file mode 100644 (file)
index 0000000..2fcc802
--- /dev/null
@@ -0,0 +1,26 @@
+Import('*')
+
+if not 'i915' in env['drivers']:
+    print 'warning: i915 pipe driver not built skipping i915_dri.so'
+    Return()
+
+env = drienv.Clone()
+
+env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
+
+env.Prepend(LIBS = [
+    st_dri,
+    i915drm,
+    i915,
+    trace,
+    mesa,
+    glsl,
+    gallium,
+    COMMON_DRI_DRM_OBJECTS
+])
+
+env.LoadableModule(
+    target = 'i915_dri.so',
+    source = 'dummy.c',
+    SHLIBPREFIX = '',
+)
diff --git a/src/gallium/targets/dri-i915/dummy.c b/src/gallium/targets/dri-i915/dummy.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/gallium/targets/dri-i965/Makefile b/src/gallium/targets/dri-i965/Makefile
new file mode 100644 (file)
index 0000000..e267ba3
--- /dev/null
@@ -0,0 +1,24 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i965_dri.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
+       $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \
+       $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/drivers/identity/libidentity.a \
+       $(TOP)/src/gallium/drivers/i965/libi965.a
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+include ../Makefile.dri
+
+DRI_LIB_DEPS += -ldrm_intel
+
+symlinks:
diff --git a/src/gallium/targets/dri-i965/SConscript b/src/gallium/targets/dri-i965/SConscript
new file mode 100644 (file)
index 0000000..eb9e6cd
--- /dev/null
@@ -0,0 +1,26 @@
+Import('*')
+
+if not 'i965' in env['drivers']:
+    print 'warning: i965 pipe driver not built skipping i965_dri.so'
+    Return()
+
+env = drienv.Clone()
+
+env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
+
+env.Prepend(LIBS = [
+    st_dri,
+    i965drm,
+    i965,
+    trace,
+    mesa,
+    glsl,
+    gallium,
+    COMMON_DRI_DRM_OBJECTS
+])
+
+env.LoadableModule(
+    target = 'i965_dri.so',
+    source = 'dummy.c',
+    SHLIBPREFIX = '',
+)
diff --git a/src/gallium/targets/dri-i965/dummy.c b/src/gallium/targets/dri-i965/dummy.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/gallium/targets/dri-nouveau/Makefile b/src/gallium/targets/dri-nouveau/Makefile
new file mode 100644 (file)
index 0000000..74d352c
--- /dev/null
@@ -0,0 +1,21 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = nouveau_dri.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.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/nouveau/libnouveau.a
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+include ../Makefile.dri
+
+DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
+
+symlinks:
diff --git a/src/gallium/targets/dri-radeong/Makefile b/src/gallium/targets/dri-radeong/Makefile
new file mode 100644 (file)
index 0000000..66dd392
--- /dev/null
@@ -0,0 +1,21 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = radeong_dri.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.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/drivers/r300/libr300.a
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+include ../Makefile.dri
+
+DRI_LIB_DEPS += -ldrm_radeon
+
+symlinks:
diff --git a/src/gallium/targets/dri-radeong/SConscript b/src/gallium/targets/dri-radeong/SConscript
new file mode 100644 (file)
index 0000000..d926c27
--- /dev/null
@@ -0,0 +1,26 @@
+Import('*')
+
+if not 'r300' in env['drivers']:
+    print 'warning: r300 pipe driver not built skipping radeong_dri.so'
+    Return()
+
+env = drienv.Clone()
+
+env.ParseConfig('pkg-config --cflags --libs libdrm_radeon')
+
+env.Prepend(LIBS = [
+    st_dri,
+    radeonwinsys,
+    r300,
+    trace,
+    mesa,
+    glsl,
+    gallium,
+    COMMON_DRI_DRM_OBJECTS
+])
+
+env.SharedLibrary(
+    target ='radeon_dri.so',
+    source = 'dummy.c',
+    SHLIBPREFIX = '',
+)
diff --git a/src/gallium/targets/dri-radeong/dummy.c b/src/gallium/targets/dri-radeong/dummy.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/gallium/targets/dri-swrast/Makefile b/src/gallium/targets/dri-swrast/Makefile
new file mode 100644 (file)
index 0000000..fcfd690
--- /dev/null
@@ -0,0 +1,30 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = swrastg_dri.so
+
+DRIVER_DEFINES = -D__NOT_HAVE_DRM_H -DGALLIUM_SOFTPIPE
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/sw/libdrisw.a \
+       $(TOP)/src/gallium/winsys/sw/dri/libswdri.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+
+SWRAST_COMMON_GALLIUM_SOURCES = \
+       $(TOP)/src/mesa/drivers/dri/common/utils.c \
+       $(TOP)/src/mesa/drivers/dri/common/drisw_util.c \
+       $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c
+
+C_SOURCES = \
+       swrast_drm_api.c \
+       $(SWRAST_COMMON_GALLIUM_SOURCES) \
+       $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.dri
+
+INCLUDES += \
+       -I$(TOP)/src/gallium/winsys/sw/dri
+
+symlinks:
diff --git a/src/gallium/targets/dri-swrast/SConscript b/src/gallium/targets/dri-swrast/SConscript
new file mode 100644 (file)
index 0000000..94ff99a
--- /dev/null
@@ -0,0 +1,42 @@
+Import('*')
+
+if not set(('softpipe', 'llvmpipe')).intersection(env['drivers']):
+    print 'warning: no supported pipe driver: skipping build of swrastg_dri.so'
+    Return()
+
+env = drienv.Clone()
+
+env.Append(CPPPATH = [
+    '#/src/gallium/winsys/sw/dri',
+])
+
+env.Prepend(LIBS = [
+    st_drisw,
+    ws_dri,
+    trace,
+    mesa,
+    glsl,
+    gallium,
+    COMMON_DRI_SW_OBJECTS
+])
+
+if 'softpipe' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
+    env.Prepend(LIBS = [softpipe])
+
+if 'llvmpipe' in env['drivers']:
+    env.Tool('llvm')
+    if 'LLVM_VERSION' in env:
+        env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+        env.Tool('udis86')
+        env.Prepend(LIBS = [llvmpipe])
+
+swrastg_sources = [
+    'swrast_drm_api.c'
+]
+
+env.LoadableModule(
+    target ='swrastg_dri.so',
+    source = swrastg_sources,
+    SHLIBPREFIX = '',
+)
diff --git a/src/gallium/targets/dri-swrast/swrast_drm_api.c b/src/gallium/targets/dri-swrast/swrast_drm_api.c
new file mode 100644 (file)
index 0000000..99c2554
--- /dev/null
@@ -0,0 +1,147 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "pipe/p_compiler.h"
+#include "util/u_memory.h"
+#include "state_tracker/drm_api.h"
+#include "state_tracker/sw_winsys.h"
+#include "dri_sw_winsys.h"
+
+/* Copied from targets/libgl-xlib */
+
+#ifdef GALLIUM_SOFTPIPE
+#include "softpipe/sp_public.h"
+#endif
+
+#ifdef GALLIUM_LLVMPIPE
+#include "llvmpipe/lp_public.h"
+#endif
+
+#ifdef GALLIUM_CELL
+#include "cell/ppu/cell_public.h"
+#endif
+
+static struct pipe_screen *
+swrast_create_screen(struct sw_winsys *winsys)
+{
+   const char *default_driver;
+   const char *driver;
+   struct pipe_screen *screen = NULL;
+
+#if defined(GALLIUM_CELL)
+   default_driver = "cell";
+#elif defined(GALLIUM_LLVMPIPE)
+   default_driver = "llvmpipe";
+#elif defined(GALLIUM_SOFTPIPE)
+   default_driver = "softpipe";
+#else
+   default_driver = "";
+#endif
+
+   driver = debug_get_option("GALLIUM_DRIVER", default_driver);
+
+#if defined(GALLIUM_CELL)
+   if (screen == NULL && strcmp(driver, "cell") == 0)
+      screen = cell_create_screen( winsys );
+#elif defined(GALLIUM_LLVMPIPE)
+   if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
+      screen = llvmpipe_create_screen( winsys );
+#elif defined(GALLIUM_SOFTPIPE)
+   if (screen == NULL)
+      screen = softpipe_create_screen( winsys );
+
+   (void) driver;
+#else
+   (void) driver;
+#endif
+
+   return screen;
+}
+
+static struct pipe_screen *
+swrast_drm_create_screen(struct drm_api *api,
+                         int drmFD,
+                         struct drm_create_screen_arg *arg)
+{
+   struct sw_winsys *winsys = NULL;
+   struct pipe_screen *screen = NULL;
+   struct drisw_create_screen_arg *drisw;
+
+   (void) drmFD;
+
+   if (arg != NULL) {
+      switch(arg->mode) {
+      case DRM_CREATE_DRISW:
+         drisw = (struct drisw_create_screen_arg *)arg;
+         break;
+      default:
+         return NULL;
+      }
+   }
+   else {
+      return NULL;
+   }
+
+   winsys = dri_create_sw_winsys(drisw->lf);
+   if (winsys == NULL)
+      return NULL;
+
+   screen = swrast_create_screen(winsys);
+   if (!screen)
+      goto fail;
+
+   return screen;
+
+fail:
+   if (winsys)
+      winsys->destroy(winsys);
+
+   return NULL;
+}
+
+static void
+swrast_drm_api_destroy(struct drm_api *api)
+{
+   return;
+}
+
+static struct drm_api swrast_drm_api =
+{
+   .name = "swrast",
+   .driver_name = "swrast",
+   .create_screen = swrast_drm_create_screen,
+   .destroy = swrast_drm_api_destroy,
+};
+
+struct drm_api *
+drm_api_create()
+{
+   return &swrast_drm_api;
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/targets/dri-vmwgfx/Makefile b/src/gallium/targets/dri-vmwgfx/Makefile
new file mode 100644 (file)
index 0000000..4b002e8
--- /dev/null
@@ -0,0 +1,17 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = vmwgfx_dri.so
+
+PIPE_DRIVERS = \
+       $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
+       $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a
+
+C_SOURCES = \
+       $(COMMON_GALLIUM_SOURCES)
+
+include ../Makefile.dri
+
+symlinks:
diff --git a/src/gallium/targets/dri-vmwgfx/SConscript b/src/gallium/targets/dri-vmwgfx/SConscript
new file mode 100644 (file)
index 0000000..6a1f882
--- /dev/null
@@ -0,0 +1,24 @@
+Import('*')
+
+if not 'svga' in env['drivers']:
+    print 'warning: svga pipe driver not built skipping vmwgfx_dri.so'
+    Return()
+
+env = drienv.Clone()
+
+env.Prepend(LIBS = [
+    st_dri,
+    svgadrm,
+    svga,
+    trace,
+    mesa,
+    glsl,
+    gallium,
+    COMMON_DRI_DRM_OBJECTS
+])
+
+env.LoadableModule(
+    target = 'vmwgfx_dri.so',
+    source = 'dummy.c',
+    SHLIBPREFIX = '',
+)
diff --git a/src/gallium/targets/dri-vmwgfx/dummy.c b/src/gallium/targets/dri-vmwgfx/dummy.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/gallium/targets/egl-i915/Makefile b/src/gallium/targets/egl-i915/Makefile
new file mode 100644 (file)
index 0000000..02258fb
--- /dev/null
@@ -0,0 +1,13 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+EGL_DRIVER_NAME = i915
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS = -ldrm_intel
+
+EGL_DRIVER_PIPES = \
+       $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/i915/libi915.a
+
+include ../Makefile.egl
diff --git a/src/gallium/targets/egl-i915/dummy.c b/src/gallium/targets/egl-i915/dummy.c
new file mode 100644 (file)
index 0000000..3181d0b
--- /dev/null
@@ -0,0 +1,3 @@
+/* A poor man's --whole-archive for EGL drivers */
+void *_eglMain(void *);
+void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-i965/Makefile b/src/gallium/targets/egl-i965/Makefile
new file mode 100644 (file)
index 0000000..fad56ef
--- /dev/null
@@ -0,0 +1,16 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+EGL_DRIVER_NAME = i965
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS = -ldrm_intel
+
+EGL_DRIVER_PIPES = \
+       $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/i965/libi965.a \
+       $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \
+       $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+
+include ../Makefile.egl
diff --git a/src/gallium/targets/egl-i965/dummy.c b/src/gallium/targets/egl-i965/dummy.c
new file mode 100644 (file)
index 0000000..3181d0b
--- /dev/null
@@ -0,0 +1,3 @@
+/* A poor man's --whole-archive for EGL drivers */
+void *_eglMain(void *);
+void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-nouveau/Makefile b/src/gallium/targets/egl-nouveau/Makefile
new file mode 100644 (file)
index 0000000..e3fa893
--- /dev/null
@@ -0,0 +1,14 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+EGL_DRIVER_NAME = nouveau
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS = -ldrm_nouveau
+
+EGL_DRIVER_PIPES = \
+       $(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/nouveau/libnouveau.a
+
+include ../Makefile.egl
diff --git a/src/gallium/targets/egl-nouveau/dummy.c b/src/gallium/targets/egl-nouveau/dummy.c
new file mode 100644 (file)
index 0000000..3181d0b
--- /dev/null
@@ -0,0 +1,3 @@
+/* A poor man's --whole-archive for EGL drivers */
+void *_eglMain(void *);
+void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-radeon/Makefile b/src/gallium/targets/egl-radeon/Makefile
new file mode 100644 (file)
index 0000000..8daadb5
--- /dev/null
@@ -0,0 +1,13 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+EGL_DRIVER_NAME = radeon
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS = -ldrm_radeon
+
+EGL_DRIVER_PIPES = \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/r300/libr300.a
+
+include ../Makefile.egl
diff --git a/src/gallium/targets/egl-radeon/dummy.c b/src/gallium/targets/egl-radeon/dummy.c
new file mode 100644 (file)
index 0000000..3181d0b
--- /dev/null
@@ -0,0 +1,3 @@
+/* A poor man's --whole-archive for EGL drivers */
+void *_eglMain(void *);
+void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-swrast/Makefile b/src/gallium/targets/egl-swrast/Makefile
new file mode 100644 (file)
index 0000000..7d4f505
--- /dev/null
@@ -0,0 +1,12 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+# Do propperly
+CFLAGS+="-I$(TOP)/src/gallium/include"
+
+EGL_DRIVER_NAME = swrast
+EGL_DRIVER_SOURCES = swrast_glue.c
+EGL_DRIVER_LIBS =
+EGL_DRIVER_PIPES =
+
+include ../Makefile.egl
diff --git a/src/gallium/targets/egl-swrast/swrast_glue.c b/src/gallium/targets/egl-swrast/swrast_glue.c
new file mode 100644 (file)
index 0000000..9db8089
--- /dev/null
@@ -0,0 +1,17 @@
+#include "state_tracker/drm_api.h"
+
+static struct drm_api swrast_drm_api =
+{
+   .name = "swrast",
+};
+
+struct drm_api *
+drm_api_create()
+{
+   (void) swrast_drm_api;
+   return NULL;
+}
+
+/* A poor man's --whole-archive for EGL drivers */
+void *_eglMain(void *);
+void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/egl-vmwgfx/Makefile b/src/gallium/targets/egl-vmwgfx/Makefile
new file mode 100644 (file)
index 0000000..5f9385f
--- /dev/null
@@ -0,0 +1,13 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+EGL_DRIVER_NAME = vmwgfx
+EGL_DRIVER_SOURCES = dummy.c
+EGL_DRIVER_LIBS =
+
+EGL_DRIVER_PIPES = \
+       $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a
+
+include ../Makefile.egl
diff --git a/src/gallium/targets/egl-vmwgfx/dummy.c b/src/gallium/targets/egl-vmwgfx/dummy.c
new file mode 100644 (file)
index 0000000..3181d0b
--- /dev/null
@@ -0,0 +1,3 @@
+/* A poor man's --whole-archive for EGL drivers */
+void *_eglMain(void *);
+void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/targets/graw-xlib/SConscript b/src/gallium/targets/graw-xlib/SConscript
new file mode 100644 (file)
index 0000000..24cea92
--- /dev/null
@@ -0,0 +1,57 @@
+#######################################################################
+# SConscript for xlib winsys
+
+Import('*')
+
+if env['platform'] != 'linux':
+    Return()
+
+if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']):
+    print 'warning: no supported pipe driver: skipping build of xlib libGL.so'
+    Return()
+
+env = env.Clone()
+
+env.Prepend(LIBS = [
+    ws_xlib,
+    trace,
+    identity,
+#    gallium,
+])
+
+env.Append(CPPPATH = [
+    '#src/gallium/drivers',
+])
+
+
+sources = [
+    'graw_xlib.c',
+]
+
+if 'softpipe' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
+    env.Prepend(LIBS = [softpipe])
+
+if 'llvmpipe' in env['drivers']:
+    env.Tool('llvm')
+    if 'LLVM_VERSION' in env:
+        env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+        env.Tool('udis86')
+        env.Prepend(LIBS = [llvmpipe])
+
+# Need this for trace, identity drivers referenced by
+# gallium_wrap_screen().
+#
+env.Prepend(LIBS = [gallium])
+
+# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
+graw = env.SharedLibrary(
+    target ='graw',
+    source = sources,
+)
+
+env.InstallSharedLibrary(graw, version=(1, 0))
+
+graw = env.FindIxes(graw, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+
+Export('graw')
diff --git a/src/gallium/targets/graw-xlib/graw.h b/src/gallium/targets/graw-xlib/graw.h
new file mode 100644 (file)
index 0000000..a58e18e
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef GALLIUM_RAW_H
+#define GALLIUM_RAW_H
+
+/* This is an API for exercising gallium functionality in a
+ * platform-neutral fashion.  Whatever platform integration is
+ * necessary to implement this interface is orchestrated by the
+ * individual target building this entity.
+ *
+ * For instance, the graw-xlib target includes code to implent these
+ * interfaces on top of the X window system.
+ *
+ * Programs using this interface may additionally benefit from some of
+ * the utilities currently in the libgallium.a library, especially
+ * those for parsing text representations of TGSI shaders.
+ */
+
+#include "pipe/p_format.h"
+
+struct pipe_screen;
+
+struct pipe_screen *graw_init( void );
+
+/* Returns a handle to be used with flush_frontbuffer()/present().
+ *
+ * Query format support with screen::is_format_supported and usage
+ * XXX.
+ */
+void *graw_create_window( int x,
+                          int y,
+                          unsigned width,
+                          unsigned height,
+                          enum pipe_format format );
+
+void graw_destroy_window( void *handle );
+
+#endif
diff --git a/src/gallium/targets/graw-xlib/graw_xlib.c b/src/gallium/targets/graw-xlib/graw_xlib.c
new file mode 100644 (file)
index 0000000..fb8ef9d
--- /dev/null
@@ -0,0 +1,181 @@
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+#include "util/u_memory.h"
+#include "target-helpers/wrap_screen.h"
+#include "state_tracker/xlib_sw_winsys.h"
+
+#ifdef GALLIUM_SOFTPIPE
+#include "softpipe/sp_public.h"
+#endif
+
+#ifdef GALLIUM_LLVMPIPE
+#include "llvmpipe/lp_public.h"
+#endif
+
+/* Haven't figured out a decent way to build the helper code yet -
+ * #include it here temporarily.
+ */
+#include "sw/sw_public.h"
+#include "sw/sw.c"
+
+#include "graw.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+static struct {
+   Display *display;
+} graw;
+
+
+struct pipe_screen *
+graw_init( void )
+{
+   const char *default_driver;
+   const char *driver;
+   struct pipe_screen *screen = NULL;
+   struct sw_winsys *winsys = NULL;
+
+   graw.display = XOpenDisplay(NULL);
+   if (graw.display == NULL)
+      return NULL;
+
+   /* Create the underlying winsys, which performs presents to Xlib
+    * drawables:
+    */
+   winsys = xlib_create_sw_winsys( graw.display );
+   if (winsys == NULL)
+      return NULL;
+
+#if defined(GALLIUM_LLVMPIPE)
+   default_driver = "llvmpipe";
+#elif defined(GALLIUM_SOFTPIPE)
+   default_driver = "softpipe";
+#else
+   default_driver = "";
+#endif
+
+   driver = debug_get_option("GALLIUM_DRIVER", default_driver);
+
+#if defined(GALLIUM_LLVMPIPE)
+   if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
+      screen = llvmpipe_create_screen( winsys );
+#endif
+
+#if defined(GALLIUM_SOFTPIPE)
+   if (screen == NULL)
+      screen = softpipe_create_screen( winsys );
+#endif
+
+   /* Inject any wrapping layers we want to here:
+    */
+   return gallium_wrap_screen( screen );
+}
+
+
+
+
+void *
+graw_create_window( int x,
+                    int y,
+                    unsigned width,
+                    unsigned height,
+                    enum pipe_format format )
+{
+   struct xlib_drawable *handle = NULL;
+   XSetWindowAttributes attr;
+   Window root;
+   Window win = 0;
+   XVisualInfo templat, *visinfo = NULL;
+   unsigned mask;
+   int n;
+   int scrnum;
+
+
+   scrnum = DefaultScreen( graw.display );
+   root = RootWindow( graw.display, scrnum );
+
+
+   if (format != PIPE_FORMAT_R8G8B8A8_UNORM)
+      goto fail;
+
+   if (graw.display == NULL)
+      goto fail;
+
+   handle = CALLOC_STRUCT(xlib_drawable);
+   if (handle == NULL)
+      goto fail;
+
+
+   mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
+   templat.screen = DefaultScreen(graw.display);
+   templat.depth = 32;
+   templat.class = TrueColor;
+
+   visinfo = XGetVisualInfo(graw.display, mask, &templat, &n);
+   if (!visinfo) {
+      printf("Error: couldn't get an RGB, Double-buffered visual\n");
+      exit(1);
+   }
+
+   /* window attributes */
+   attr.background_pixel = 0;
+   attr.border_pixel = 0;
+   attr.colormap = XCreateColormap( graw.display, root, visinfo->visual, AllocNone);
+   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+   /* XXX this is a bad way to get a borderless window! */
+   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+   win = XCreateWindow( graw.display, root, x, y, width, height,
+                       0, visinfo->depth, InputOutput,
+                       visinfo->visual, mask, &attr );
+
+
+   /* set hints and properties */
+   {
+      char *name = NULL;
+      XSizeHints sizehints;
+      sizehints.x = x;
+      sizehints.y = y;
+      sizehints.width  = width;
+      sizehints.height = height;
+      sizehints.flags = USSize | USPosition;
+      XSetNormalHints(graw.display, win, &sizehints);
+      XSetStandardProperties(graw.display, win, name, name,
+                              None, (char **)NULL, 0, &sizehints);
+   }
+
+   XFree(visinfo);
+   XMapWindow(graw.display, win);
+   while (1) {
+      XEvent e;
+      XNextEvent( graw.display, &e );
+      if (e.type == MapNotify && e.xmap.window == win) {
+        break;
+      }
+   }
+   
+   handle->visual = visinfo->visual;
+   handle->drawable = (Drawable)win;
+   handle->depth = visinfo->depth;
+   return (void *)handle;
+
+fail:
+   FREE(handle);
+   XFree(visinfo);
+
+   if (win)
+      XDestroyWindow(graw.display, win);
+
+   return NULL;
+}
+
+
+void
+graw_destroy_window( void *xlib_drawable )
+{
+}
+
index 57704440ce7a027aa3af90a952a3f8a6bb31dc0a..21b4eb2abee034d33757a54d05eb22968285fdb8 100644 (file)
@@ -9,6 +9,7 @@ if env['platform'] == 'windows':
 
     env.Append(CPPPATH = [
         '#src/gallium/state_trackers/wgl',
+        '#src/gallium/winsys/sw',
     ])
 
     env.Append(LIBS = [
index 5a4e035c2eba92e135455260493283fe4f2a22bf..6cd00cad45896a5d69100dc3a880d39a1610124b 100644 (file)
@@ -38,7 +38,7 @@ XLIB_TARGET_OBJECTS = $(XLIB_TARGET_SOURCES:.c=.o)
 LIBS = \
        $(GALLIUM_DRIVERS) \
        $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \
-       $(TOP)/src/gallium/winsys/xlib/libws_xlib.a \
+       $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \
        $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/identity/libidentity.a \
        $(TOP)/src/mesa/libglapi.a \
index 05dc8db57d97969969801516912f11711d6eeaa0..48e5bdff4293387af85f97184747a50a2c9a0168 100644 (file)
  *   Keith Whitwell
  */
 #include "pipe/p_compiler.h"
-#include "state_tracker/xlib_sw_winsys.h"
 #include "util/u_debug.h"
-#include "softpipe/sp_public.h"
-#include "llvmpipe/lp_public.h"
-#include "cell/ppu/cell_public.h"
 #include "target-helpers/wrap_screen.h"
+#include "state_tracker/xlib_sw_winsys.h"
 #include "xm_public.h"
 
+#include "state_tracker/st_manager.h"
+
 /* advertise OpenGL support */
 PUBLIC const int st_api_OpenGL = 1;
 
+PUBLIC const struct st_module st_module_OpenGL = {
+   .api = ST_API_OPENGL,
+   .create_api = st_manager_create_api
+};
 
-/* Helper function to build a subset of a driver stack consisting of
- * one of the software rasterizers (cell, llvmpipe, softpipe) and the
- * xlib winsys.
+/* Helper function to choose and instantiate one of the software rasterizers:
+ * cell, llvmpipe, softpipe.
  *
  * This function could be shared, but currently causes headaches for
  * the build systems, particularly scons if we try.  Long term, want
@@ -53,37 +55,85 @@ PUBLIC const int st_api_OpenGL = 1;
  * GALLIUM_CELL, etc.  Scons already eliminates those #defines, so
  * things that are painful for it now are likely to be painful for
  * other build systems in the future.
+ *
+ * Copies (full or partial):
+ *    targets/libgl-xlib
+ *    targets/graw-xlib
+ *    targets/dri-swrast
+ *    winsys/sw/drm
+ *    drivers/sw
+ *
  */
+
+#ifdef GALLIUM_SOFTPIPE
+#include "softpipe/sp_public.h"
+#endif
+
+#ifdef GALLIUM_LLVMPIPE
+#include "llvmpipe/lp_public.h"
+#endif
+
+#ifdef GALLIUM_CELL
+#include "cell/ppu/cell_public.h"
+#endif
+
 static struct pipe_screen *
-swrast_xlib_create_screen( Display *display )
+swrast_create_screen(struct sw_winsys *winsys)
 {
-   struct sw_winsys *winsys;
+   const char *default_driver;
+   const char *driver;
    struct pipe_screen *screen = NULL;
 
-   /* Create the underlying winsys, which performs presents to Xlib
-    * drawables:
-    */
-   winsys = xlib_create_sw_winsys( display );
-   if (winsys == NULL)
-      return NULL;
+#if defined(GALLIUM_CELL)
+   default_driver = "cell";
+#elif defined(GALLIUM_LLVMPIPE)
+   default_driver = "llvmpipe";
+#elif defined(GALLIUM_SOFTPIPE)
+   default_driver = "softpipe";
+#else
+   default_driver = "";
+#endif
+
+   driver = debug_get_option("GALLIUM_DRIVER", default_driver);
 
-   /* Create a software rasterizer on top of that winsys:
-    */
 #if defined(GALLIUM_CELL)
-   if (screen == NULL &&
-       !debug_get_bool_option("GALLIUM_NO_CELL", FALSE))
+   if (screen == NULL && strcmp(driver, "cell") == 0)
       screen = cell_create_screen( winsys );
 #endif
 
 #if defined(GALLIUM_LLVMPIPE)
-   if (screen == NULL &&
-       !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE))
+   if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
       screen = llvmpipe_create_screen( winsys );
 #endif
 
+#if defined(GALLIUM_SOFTPIPE)
    if (screen == NULL)
       screen = softpipe_create_screen( winsys );
+#endif
 
+   return screen;
+}
+
+/* Helper function to build a subset of a driver stack consisting of
+ * one of the software rasterizers (cell, llvmpipe, softpipe) and the
+ * xlib winsys.
+ */
+static struct pipe_screen *
+swrast_xlib_create_screen( Display *display )
+{
+   struct sw_winsys *winsys;
+   struct pipe_screen *screen = NULL;
+
+   /* Create the underlying winsys, which performs presents to Xlib
+    * drawables:
+    */
+   winsys = xlib_create_sw_winsys( display );
+   if (winsys == NULL)
+      return NULL;
+
+   /* Create a software rasterizer on top of that winsys:
+    */
+   screen = swrast_create_screen( winsys );
    if (screen == NULL)
       goto fail;
 
@@ -98,9 +148,10 @@ fail:
    return NULL;
 }
 
-struct xm_driver xlib_driver = 
+static struct xm_driver xlib_driver = 
 {
    .create_pipe_screen = swrast_xlib_create_screen,
+   .create_st_api = st_manager_create_api,
 };
 
 
diff --git a/src/gallium/targets/xorg-i915/Makefile b/src/gallium/targets/xorg-i915/Makefile
new file mode 100644 (file)
index 0000000..52a9e97
--- /dev/null
@@ -0,0 +1,57 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+TARGET     = modesetting_drv.so
+CFILES     = $(wildcard ./*.c)
+OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
+
+INCLUDES = \
+       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
+       -I$(TOP)/src/gallium/winsys/drm/intel/gem \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/include \
+       -I$(TOP)/src/egl/main
+
+LIBS = \
+       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
+       $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
+       $(TOP)/src/gallium/drivers/i915/libi915.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(GALLIUM_AUXILIARIES)
+
+DRIVER_DEFINES = \
+       -DHAVE_CONFIG_H
+
+
+#############################################
+
+
+
+all default: $(TARGET)
+
+$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS)
+       $(TOP)/bin/mklib -noprefix -o $@ \
+       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
+
+clean:
+       rm -rf $(OBJECTS) $(TARGET)
+
+install:
+       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+
+##############################################
+
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
+
+
+##############################################
+
+.PHONY = all clean install
diff --git a/src/gallium/targets/xorg-i915/intel_xorg.c b/src/gallium/targets/xorg-i915/intel_xorg.c
new file mode 100644 (file)
index 0000000..08f3b08
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "../../state_trackers/xorg/xorg_winsys.h"
+
+static void intel_xorg_identify(int flags);
+static Bool intel_xorg_pci_probe(DriverPtr driver,
+                                int entity_num,
+                                struct pci_device *device,
+                                intptr_t match_data);
+
+static const struct pci_id_match intel_xorg_device_match[] = {
+    {0x8086, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
+    {0, 0, 0},
+};
+
+static SymTabRec intel_xorg_chipsets[] = {
+    {PCI_MATCH_ANY, "Intel Graphics Device"},
+    {-1, NULL}
+};
+
+static PciChipsets intel_xorg_pci_devices[] = {
+    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
+    {-1, -1, NULL}
+};
+
+static XF86ModuleVersionInfo intel_xorg_version = {
+    "modesetting",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    0, 1, 0, /* major, minor, patch */
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+    1,
+    "modesetting",
+    intel_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    intel_xorg_device_match,
+    intel_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(intel_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+    &intel_xorg_version,
+    intel_xorg_setup,
+    NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+       setupDone = 1;
+       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+       /*
+        * The return value must be non-NULL on success even though there
+        * is no TearDownProc.
+        */
+       return (pointer) 1;
+    } else {
+       if (errmaj)
+           *errmaj = LDR_ONCEONLY;
+       return NULL;
+    }
+}
+
+static void
+intel_xorg_identify(int flags)
+{
+    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+                     intel_xorg_chipsets);
+}
+
+static Bool
+intel_xorg_pci_probe(DriverPtr driver,
+         int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
+                              NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+       scrn->driverVersion = 1;
+       scrn->driverName = "i915";
+       scrn->name = "modesetting";
+       scrn->Probe = NULL;
+
+       entity = xf86GetEntityInfo(entity_num);
+
+       /* Use all the functions from the xorg tracker */
+       xorg_tracker_set_functions(scrn);
+    }
+    return scrn != NULL;
+}
diff --git a/src/gallium/targets/xorg-i965/Makefile b/src/gallium/targets/xorg-i965/Makefile
new file mode 100644 (file)
index 0000000..104a143
--- /dev/null
@@ -0,0 +1,48 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+TARGET     = i965g_drv.so
+CFILES     = $(wildcard ./*.c)
+OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
+
+CFLAGS = -DHAVE_CONFIG_H \
+         -g -Wall -Wimplicit-function-declaration -fPIC \
+         $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
+         -I$(TOP)/src/gallium/include \
+         -I$(TOP)/src/gallium/drivers \
+         -I$(TOP)/src/gallium/auxiliary \
+         -I$(TOP)/src/mesa \
+         -I$(TOP)/include \
+         -I$(TOP)/src/egl/main
+
+LIBS = \
+       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
+       $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
+       $(TOP)/src/gallium/drivers/i965/libi965.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(GALLIUM_AUXILIARIES)
+
+TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
+#############################################
+
+all default: $(TARGET) $(TARGET_STAGING)
+
+$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS)
+       $(TOP)/bin/mklib -noprefix -o $@ \
+       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+
+clean:
+       rm -rf $(OBJECTS) $(TARGET)
+
+install:
+       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+.PHONY = all clean install
diff --git a/src/gallium/targets/xorg-i965/intel_xorg.c b/src/gallium/targets/xorg-i965/intel_xorg.c
new file mode 100644 (file)
index 0000000..f4608f0
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "../../state_trackers/xorg/xorg_winsys.h"
+
+static void intel_xorg_identify(int flags);
+static Bool intel_xorg_pci_probe(DriverPtr driver,
+                                int entity_num,
+                                struct pci_device *device,
+                                intptr_t match_data);
+
+static const struct pci_id_match intel_xorg_device_match[] = {
+    {0x8086, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
+    {0, 0, 0},
+};
+
+static SymTabRec intel_xorg_chipsets[] = {
+    {PCI_MATCH_ANY, "Intel Graphics Device"},
+    {-1, NULL}
+};
+
+static PciChipsets intel_xorg_pci_devices[] = {
+    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
+    {-1, -1, NULL}
+};
+
+static XF86ModuleVersionInfo intel_xorg_version = {
+    "modesetting",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    0, 1, 0, /* major, minor, patch */
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+    1,
+    "modesetting",
+    intel_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    intel_xorg_device_match,
+    intel_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(intel_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+    &intel_xorg_version,
+    intel_xorg_setup,
+    NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+       setupDone = 1;
+       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+       /*
+        * The return value must be non-NULL on success even though there
+        * is no TearDownProc.
+        */
+       return (pointer) 1;
+    } else {
+       if (errmaj)
+           *errmaj = LDR_ONCEONLY;
+       return NULL;
+    }
+}
+
+static void
+intel_xorg_identify(int flags)
+{
+    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+                     intel_xorg_chipsets);
+}
+
+static Bool
+intel_xorg_pci_probe(DriverPtr driver,
+         int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
+                              NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+       scrn->driverVersion = 1;
+       scrn->driverName = "i965";
+       scrn->name = "modesetting";
+       scrn->Probe = NULL;
+
+       entity = xf86GetEntityInfo(entity_num);
+
+       /* Use all the functions from the xorg tracker */
+       xorg_tracker_set_functions(scrn);
+    }
+    return scrn != NULL;
+}
diff --git a/src/gallium/targets/xorg-nouveau/Makefile b/src/gallium/targets/xorg-nouveau/Makefile
new file mode 100644 (file)
index 0000000..b514b57
--- /dev/null
@@ -0,0 +1,56 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+TARGET     = modesetting_drv.so
+CFILES     = $(wildcard ./*.c)
+OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
+
+INCLUDES = \
+       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/include \
+       -I$(TOP)/src/egl/main
+
+LIBS = \
+       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.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/nouveau/libnouveau.a \
+       $(GALLIUM_AUXILIARIES)
+
+DRIVER_DEFINES = \
+       -DHAVE_CONFIG_H
+
+
+#############################################
+
+
+
+all default: $(TARGET)
+
+$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS)
+       $(TOP)/bin/mklib -noprefix -o $@ \
+       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_nouveau
+
+clean:
+       rm -rf $(OBJECTS) $(TARGET)
+
+install:
+       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+
+##############################################
+
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
+
+
+##############################################
+
+.PHONY = all clean install
diff --git a/src/gallium/targets/xorg-nouveau/nouveau_xorg.c b/src/gallium/targets/xorg-nouveau/nouveau_xorg.c
new file mode 100644 (file)
index 0000000..699af09
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "../../state_trackers/xorg/xorg_winsys.h"
+
+static void nouveau_xorg_identify(int flags);
+static Bool nouveau_xorg_pci_probe(DriverPtr driver, int entity_num,
+                                  struct pci_device *device,
+                                  intptr_t match_data);
+
+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",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    0, 1, 0, /* major, minor, patch */
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+    1,
+    "modesetting",
+    nouveau_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    nouveau_xorg_device_match,
+    nouveau_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(nouveau_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+    &nouveau_xorg_version,
+    nouveau_xorg_setup,
+    NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+nouveau_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+       setupDone = 1;
+       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+       /*
+        * The return value must be non-NULL on success even though there
+        * is no TearDownProc.
+        */
+       return (pointer) 1;
+    } else {
+       if (errmaj)
+           *errmaj = LDR_ONCEONLY;
+       return NULL;
+    }
+}
+
+static void
+nouveau_xorg_identify(int flags)
+{
+    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+                     nouveau_xorg_chipsets);
+}
+
+static Bool
+nouveau_xorg_pci_probe(DriverPtr driver,
+         int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, nouveau_xorg_pci_devices,
+                              NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+       scrn->driverVersion = 1;
+       scrn->driverName = "i915";
+       scrn->name = "modesetting";
+       scrn->Probe = NULL;
+
+       entity = xf86GetEntityInfo(entity_num);
+
+       /* Use all the functions from the xorg tracker */
+       xorg_tracker_set_functions(scrn);
+    }
+    return scrn != NULL;
+}
diff --git a/src/gallium/targets/xorg-radeon/Makefile b/src/gallium/targets/xorg-radeon/Makefile
new file mode 100644 (file)
index 0000000..cd32914
--- /dev/null
@@ -0,0 +1,48 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+TARGET     = radeong_drv.so
+CFILES     = $(wildcard ./*.c)
+OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
+
+CFLAGS = -DHAVE_CONFIG_H \
+         -g -Wall -Wimplicit-function-declaration -fPIC \
+         $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
+         -I$(TOP)/src/gallium/include \
+         -I$(TOP)/src/gallium/drivers \
+         -I$(TOP)/src/gallium/auxiliary \
+         -I${TOP}/src/mesa \
+         -I$(TOP)/include \
+         -I$(TOP)/src/egl/main
+
+LIBS = \
+       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
+       $(TOP)/src/gallium/drivers/r300/libr300.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(GALLIUM_AUXILIARIES)
+
+TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
+#############################################
+
+all default: $(TARGET) $(TARGET_STAGING)
+
+$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS)
+       $(TOP)/bin/mklib -noprefix -o $@ \
+       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_radeon
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+
+clean:
+       rm -rf $(OBJECTS) $(TARGET)
+
+install:
+       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+.PHONY = all clean install
diff --git a/src/gallium/targets/xorg-radeon/radeon_xorg.c b/src/gallium/targets/xorg-radeon/radeon_xorg.c
new file mode 100644 (file)
index 0000000..0d6aa56
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ * Author: Corbin Simpson <MostAwesomedude@gmail.com>
+ *
+ */
+
+#include "../../state_trackers/xorg/xorg_winsys.h"
+
+static void radeon_xorg_identify(int flags);
+static Bool radeon_xorg_pci_probe(DriverPtr driver,
+                                int entity_num,
+                                struct pci_device *device,
+                                intptr_t match_data);
+
+static const struct pci_id_match radeon_xorg_device_match[] = {
+    {0x1002, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
+    {0, 0, 0},
+};
+
+static SymTabRec radeon_xorg_chipsets[] = {
+    {PCI_MATCH_ANY, "ATI/AMD Radeon Graphics Chipset"},
+    {-1, NULL}
+};
+
+static PciChipsets radeon_xorg_pci_devices[] = {
+    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
+    {-1, -1, NULL}
+};
+
+static XF86ModuleVersionInfo radeon_xorg_version = {
+    "radeong",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    0, 1, 0, /* major, minor, patch */
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec radeong = {
+    1,
+    "radeong",
+    radeon_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    radeon_xorg_device_match,
+    radeon_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(radeon_xorg_setup);
+
+_X_EXPORT XF86ModuleData radeongModuleData = {
+    &radeon_xorg_version,
+    radeon_xorg_setup,
+    NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+radeon_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+       setupDone = 1;
+       xf86AddDriver(&radeong, module, HaveDriverFuncs);
+
+       /*
+        * The return value must be non-NULL on success even though there
+        * is no TearDownProc.
+        */
+       return (pointer) 1;
+    } else {
+       if (errmaj)
+           *errmaj = LDR_ONCEONLY;
+       return NULL;
+    }
+}
+
+static void
+radeon_xorg_identify(int flags)
+{
+    xf86PrintChipsets("radeong", "Driver for Radeon Gallium with KMS",
+                     radeon_xorg_chipsets);
+}
+
+static Bool
+radeon_xorg_pci_probe(DriverPtr driver,
+         int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, radeon_xorg_pci_devices,
+                              NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+       scrn->driverVersion = 1;
+       scrn->driverName = "radeong";
+       scrn->name = "radeong";
+       scrn->Probe = NULL;
+
+       entity = xf86GetEntityInfo(entity_num);
+
+       /* Use all the functions from the xorg tracker */
+       xorg_tracker_set_functions(scrn);
+    }
+    return scrn != NULL;
+}
diff --git a/src/gallium/targets/xorg-vmwgfx/Makefile b/src/gallium/targets/xorg-vmwgfx/Makefile
new file mode 100644 (file)
index 0000000..12bc307
--- /dev/null
@@ -0,0 +1,70 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+TARGET = vmwgfx_drv.so
+
+CFILES = \
+       vmw_xorg.c \
+       vmw_video.c \
+       vmw_ioctl.c \
+       vmw_screen.c
+
+OBJECTS = $(patsubst %.c,%.o,$(CFILES))
+
+INCLUDES = \
+       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I$(TOP)/src/gallium
+
+LIBS = \
+       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
+       $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/svga/libsvga.a \
+       $(GALLIUM_AUXILIARIES)
+
+LINKS = \
+       $(shell pkg-config --libs --silence-errors libkms) \
+       $(shell pkg-config --libs libdrm)
+
+DRIVER_DEFINES = \
+       -std=gnu99 \
+       -DHAVE_CONFIG_H
+
+TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
+
+#############################################
+
+
+
+all default: $(TARGET) $(TARGET_STAGING)
+
+$(TARGET): $(OBJECTS) Makefile $(LIBS)
+       $(MKLIB) -noprefix -o $@ $(OBJECTS) $(LIBS) $(LINKS)
+
+$(TOP)/$(LIB_DIR)/gallium:
+       mkdir -p $@
+
+$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
+
+clean:
+       rm -rf $(OBJECTS) $(TARGET)
+
+install:
+       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+
+##############################################
+
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
+
+
+##############################################
+
+.PHONY = all clean install
diff --git a/src/gallium/targets/xorg-vmwgfx/SConscript b/src/gallium/targets/xorg-vmwgfx/SConscript
new file mode 100644 (file)
index 0000000..b63ab99
--- /dev/null
@@ -0,0 +1,61 @@
+import os.path
+
+Import('*')
+
+if not 'svga' in env['drivers']:
+    print 'warning: svga pipe driver not built skipping vmwgfx_drv.so'
+    Return()
+
+if env['platform'] == 'linux':
+
+       env = env.Clone()
+
+       env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server')
+
+       env.Prepend(CPPPATH = [
+               '#/include',
+               '#/src/gallium',
+               '#/src/mesa',
+               '#/src/gallium/drivers/svga',
+               '#/src/gallium/drivers/svga/include',
+       ])
+
+       env.Append(CPPDEFINES = [
+       ])
+
+       if env['gcc']:
+               env.Append(CPPDEFINES = [
+                       'HAVE_STDINT_H',
+                       'HAVE_SYS_TYPES_H',
+               ])
+
+       env.Append(CFLAGS = [
+               '-std=gnu99',
+               '-D_FILE_OFFSET_BITS=64',
+       ])
+
+       env.Prepend(LIBPATH = [
+       ])
+
+       env.Prepend(LIBS = [
+               trace,
+               st_xorg,
+               svgadrm,
+               svga,
+                gallium,
+       ])
+
+       sources = [
+               'vmw_ioctl.c',
+               'vmw_screen.c',
+               'vmw_video.c',
+               'vmw_xorg.c',
+       ]
+
+       # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
+       env.LoadableModule(
+               target ='vmwgfx_drv.so',
+               source = sources,
+               LIBS = env['LIBS'],
+               SHLIBPREFIX = '',
+       )
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_driver.h b/src/gallium/targets/xorg-vmwgfx/vmw_driver.h
new file mode 100644 (file)
index 0000000..ba754b5
--- /dev/null
@@ -0,0 +1,103 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the shared resources for VMware Xorg driver
+ * that sits ontop of the Xorg State Traker.
+ *
+ * It is initialized in vmw_screen.c.
+ *
+ * @author Jakob Bornecrantz <jakob@vmware.com>
+ */
+
+#ifndef VMW_DRIVER_H_
+#define VMW_DRIVER_H_
+
+#include "state_trackers/xorg/xorg_tracker.h"
+
+struct vmw_dma_buffer;
+
+struct vmw_customizer
+{
+    CustomizerRec base;
+    ScrnInfoPtr pScrn;
+
+    int fd;
+
+    void *cursor_priv;
+
+    /* vmw_video.c */
+    void *video_priv;
+};
+
+static INLINE struct vmw_customizer *
+vmw_customizer(CustomizerPtr cust)
+{
+    return cust ? (struct vmw_customizer *) cust : NULL;
+}
+
+
+/***********************************************************************
+ * vmw_video.c
+ */
+
+Bool vmw_video_init(struct vmw_customizer *vmw);
+
+Bool vmw_video_close(struct vmw_customizer *vmw);
+
+void vmw_video_stop_all(struct vmw_customizer *vmw);
+
+
+/***********************************************************************
+ * vmw_ioctl.c
+ */
+
+int vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot);
+
+struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_customizer *vmw,
+                                               uint32_t size,
+                                               unsigned *handle);
+
+void * vmw_ioctl_buffer_map(struct vmw_customizer *vmw,
+                           struct vmw_dma_buffer *buf);
+
+void vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw,
+                           struct vmw_dma_buffer *buf);
+
+void vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw,
+                             struct vmw_dma_buffer *buf);
+
+int vmw_ioctl_supports_streams(struct vmw_customizer *vmw);
+
+int vmw_ioctl_num_streams(struct vmw_customizer *vmw,
+                         uint32_t *ntot, uint32_t *nfree);
+
+int vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id);
+
+int vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out);
+
+
+#endif
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_hook.h b/src/gallium/targets/xorg-vmwgfx/vmw_hook.h
new file mode 100644 (file)
index 0000000..224a2d9
--- /dev/null
@@ -0,0 +1,39 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#ifndef VMW_HOOK_H_
+#define VMW_HOOK_H_
+
+#include "state_trackers/xorg/xorg_winsys.h"
+
+
+/***********************************************************************
+ * vmw_screen.c
+ */
+
+void vmw_screen_set_functions(ScrnInfoPtr pScrn);
+
+
+#endif
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c b/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c
new file mode 100644 (file)
index 0000000..96ee4ff
--- /dev/null
@@ -0,0 +1,242 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the functions for creating dma buffers by calling
+ * the kernel via driver specific ioctls.
+ *
+ * @author Jakob Bornecrantz <jakob@vmware.com>
+ */
+
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H 1
+#endif
+#define _FILE_OFFSET_BITS 64
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/mman.h>
+#include "xf86drm.h"
+#include "../../winsys/svga/drm/vmwgfx_drm.h"
+
+#include "vmw_driver.h"
+#include "util/u_debug.h"
+
+struct vmw_dma_buffer
+{
+    void *data;
+    unsigned handle;
+    uint64_t map_handle;
+    unsigned map_count;
+    uint32_t size;
+};
+
+static int
+vmw_ioctl_get_param(struct vmw_customizer *vmw, uint32_t param, uint64_t *out)
+{
+    struct drm_vmw_getparam_arg gp_arg;
+    int ret;
+
+    memset(&gp_arg, 0, sizeof(gp_arg));
+    gp_arg.param = param;
+    ret = drmCommandWriteRead(vmw->fd, DRM_VMW_GET_PARAM,
+           &gp_arg, sizeof(gp_arg));
+
+    if (ret == 0) {
+       *out = gp_arg.value;
+    }
+
+    return ret;
+}
+
+int
+vmw_ioctl_supports_streams(struct vmw_customizer *vmw)
+{
+    uint64_t value;
+    int ret;
+
+    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_STREAMS, &value);
+    if (ret)
+       return ret;
+
+    return value ? 0 : -ENOSYS;
+}
+
+int
+vmw_ioctl_num_streams(struct vmw_customizer *vmw,
+                     uint32_t *ntot, uint32_t *nfree)
+{
+    uint64_t v1, v2;
+    int ret;
+
+    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_STREAMS, &v1);
+    if (ret)
+       return ret;
+
+    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_FREE_STREAMS, &v2);
+    if (ret)
+       return ret;
+
+    *ntot = (uint32_t)v1;
+    *nfree = (uint32_t)v2;
+
+    return 0;
+}
+
+int
+vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out)
+{
+    struct drm_vmw_stream_arg s_arg;
+    int ret;
+
+    ret = drmCommandRead(vmw->fd, DRM_VMW_CLAIM_STREAM,
+                        &s_arg, sizeof(s_arg));
+
+    if (ret)
+       return -1;
+
+    *out = s_arg.stream_id;
+    return 0;
+}
+
+int
+vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id)
+{
+    struct drm_vmw_stream_arg s_arg;
+    int ret;
+
+    memset(&s_arg, 0, sizeof(s_arg));
+    s_arg.stream_id = stream_id;
+
+    ret = drmCommandRead(vmw->fd, DRM_VMW_CLAIM_STREAM,
+                        &s_arg, sizeof(s_arg));
+
+    return 0;
+}
+
+int
+vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot)
+{
+    struct drm_vmw_cursor_bypass_arg arg;
+    int ret;
+
+    memset(&arg, 0, sizeof(arg));
+    arg.flags = DRM_VMW_CURSOR_BYPASS_ALL;
+    arg.xhot = xhot;
+    arg.yhot = yhot;
+
+    ret = drmCommandWrite(vmw->fd, DRM_VMW_CURSOR_BYPASS,
+                         &arg, sizeof(arg));
+
+    return ret;
+}
+
+struct vmw_dma_buffer *
+vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *handle)
+{
+    struct vmw_dma_buffer *buf;
+    union drm_vmw_alloc_dmabuf_arg arg;
+    struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
+    struct drm_vmw_dmabuf_rep *rep = &arg.rep;
+    int ret;
+
+    buf = xcalloc(1, sizeof(*buf));
+    if (!buf)
+       goto err;
+
+    memset(&arg, 0, sizeof(arg));
+    req->size = size;
+    do {
+       ret = drmCommandWriteRead(vmw->fd, DRM_VMW_ALLOC_DMABUF, &arg, sizeof(arg));
+    } while (ret == -ERESTART);
+
+    if (ret) {
+       debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
+       goto err_free;
+    }
+
+
+    buf->data = NULL;
+    buf->handle = rep->handle;
+    buf->map_handle = rep->map_handle;
+    buf->map_count = 0;
+    buf->size = size;
+
+    *handle = rep->handle;
+
+    return buf;
+
+err_free:
+    xfree(buf);
+err:
+    return NULL;
+}
+
+void
+vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
+{ 
+    struct drm_vmw_unref_dmabuf_arg arg; 
+
+    if (buf->data) { 
+       munmap(buf->data, buf->size); 
+       buf->data = NULL; 
+    } 
+
+    memset(&arg, 0, sizeof(arg)); 
+    arg.handle = buf->handle; 
+    drmCommandWrite(vmw->fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg)); 
+
+    xfree(buf); 
+} 
+
+void *
+vmw_ioctl_buffer_map(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
+{
+    void *map;
+
+    if (buf->data == NULL) {
+       map = mmap(NULL, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+                  vmw->fd, buf->map_handle);
+       if (map == MAP_FAILED) {
+           debug_printf("%s: Map failed.\n", __FUNCTION__);
+           return NULL;
+       }
+
+       buf->data = map;
+    }
+
+    ++buf->map_count;
+
+    return buf->data;
+}
+
+void
+vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
+{
+    --buf->map_count;
+}
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
new file mode 100644 (file)
index 0000000..f43f91e
--- /dev/null
@@ -0,0 +1,178 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the init code for the VMware Xorg driver.
+ *
+ * @author Jakob Bornecrantz <jakob@vmware.com>
+ */
+
+#include "vmw_hook.h"
+#include "vmw_driver.h"
+
+#include "cursorstr.h"
+
+/* modified version of crtc functions */
+xf86CrtcFuncsRec vmw_screen_crtc_funcs;
+
+static void
+vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image)
+{
+    struct vmw_customizer *vmw =
+       vmw_customizer(xorg_customizer(crtc->scrn));
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+    xf86CrtcFuncsPtr funcs = vmw->cursor_priv;
+    CursorPtr c = config->cursor;
+
+    /* Run the ioctl before uploading the image */
+    vmw_ioctl_cursor_bypass(vmw, c->bits->xhot, c->bits->yhot);
+
+    funcs->load_cursor_argb(crtc, image);
+}
+
+static void
+vmw_screen_cursor_init(struct vmw_customizer *vmw)
+{
+    ScrnInfoPtr pScrn = vmw->pScrn;
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int i;
+
+    /* XXX assume that all crtc's have the same function struct */
+
+    /* Save old struct need to call the old functions as well */
+    vmw->cursor_priv = (void*)(config->crtc[0]->funcs);
+    memcpy(&vmw_screen_crtc_funcs, vmw->cursor_priv, sizeof(xf86CrtcFuncsRec));
+    vmw_screen_crtc_funcs.load_cursor_argb = vmw_screen_cursor_load_argb;
+
+    for (i = 0; i < config->num_crtc; i++)
+       config->crtc[i]->funcs = &vmw_screen_crtc_funcs;
+}
+
+static void
+vmw_screen_cursor_close(struct vmw_customizer *vmw)
+{
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(vmw->pScrn);
+    int i;
+
+    vmw_ioctl_cursor_bypass(vmw, 0, 0);
+
+    for (i = 0; i < config->num_crtc; i++)
+       config->crtc[i]->funcs = vmw->cursor_priv;
+}
+
+static Bool
+vmw_screen_init(CustomizerPtr cust, int fd)
+{
+    struct vmw_customizer *vmw = vmw_customizer(cust);
+
+    vmw->fd = fd;
+    vmw_screen_cursor_init(vmw);
+
+    /* if gallium is used then we don't need to do anything more. */
+    if (xorg_has_gallium(vmw->pScrn))
+       return TRUE;
+
+    vmw_video_init(vmw);
+
+    return TRUE;
+}
+
+static Bool
+vmw_screen_close(CustomizerPtr cust)
+{
+    struct vmw_customizer *vmw = vmw_customizer(cust);
+
+    if (!vmw)
+       return TRUE;
+
+    vmw_screen_cursor_close(vmw);
+
+    vmw_video_close(vmw);
+
+    return TRUE;
+}
+
+static Bool
+vmw_screen_enter_vt(CustomizerPtr cust)
+{
+    debug_printf("%s: enter\n", __func__);
+
+    return TRUE;
+}
+
+static Bool
+vmw_screen_leave_vt(CustomizerPtr cust)
+{
+    struct vmw_customizer *vmw = vmw_customizer(cust);
+
+    debug_printf("%s: enter\n", __func__);
+
+    vmw_video_stop_all(vmw);
+
+    return TRUE;
+}
+
+/*
+ * Functions for setting up hooks into the xorg state tracker
+ */
+
+static Bool (*vmw_screen_pre_init_saved)(ScrnInfoPtr pScrn, int flags) = NULL;
+
+static Bool
+vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
+{
+    struct vmw_customizer *vmw;
+    CustomizerPtr cust;
+
+    vmw = xnfcalloc(1, sizeof(*vmw));
+    if (!vmw)
+       return FALSE;
+
+    cust = &vmw->base;
+
+    cust->winsys_screen_init = vmw_screen_init;
+    cust->winsys_screen_close = vmw_screen_close;
+    cust->winsys_enter_vt = vmw_screen_enter_vt;
+    cust->winsys_leave_vt = vmw_screen_leave_vt;
+    vmw->pScrn = pScrn;
+
+    pScrn->driverPrivate = cust;
+
+    pScrn->PreInit = vmw_screen_pre_init_saved;
+    if (!pScrn->PreInit(pScrn, flags))
+       return FALSE;
+
+    return TRUE;
+}
+
+void
+vmw_screen_set_functions(ScrnInfoPtr pScrn)
+{
+    assert(!vmw_screen_pre_init_saved);
+
+    vmw_screen_pre_init_saved = pScrn->PreInit;
+    pScrn->PreInit = vmw_screen_pre_init;
+}
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_video.c b/src/gallium/targets/xorg-vmwgfx/vmw_video.c
new file mode 100644 (file)
index 0000000..eced60d
--- /dev/null
@@ -0,0 +1,1072 @@
+/*
+ * Copyright 2007 by VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * vmwarevideo.c --
+ *
+ *      Xv extension support.
+ *      See http://www.xfree86.org/current/DESIGN16.html
+ *
+ */
+
+
+#include "xf86xv.h"
+#include "fourcc.h"
+
+#include "pipe/p_compiler.h"
+/*
+ * We can't incude svga_types.h due to conflicting types for Bool.
+ */
+typedef int64_t int64;
+typedef uint64_t uint64;
+
+typedef int32_t int32;
+typedef uint32_t uint32;
+
+typedef int16_t int16;
+typedef uint16_t uint16;
+
+typedef int8_t int8;
+typedef uint8_t uint8;
+
+#include "svga/include/svga_reg.h"
+#include "svga/include/svga_escape.h"
+#include "svga/include/svga_overlay.h"
+
+#include "vmw_driver.h"
+
+#include <X11/extensions/Xv.h>
+
+#include "xf86drm.h"
+#include "../../winsys/svga/drm/vmwgfx_drm.h"
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+/*
+ * Number of videos that can be played simultaneously
+ */
+#define VMWARE_VID_NUM_PORTS 1
+
+/*
+ * Using a dark shade as the default colorKey
+ */
+#define VMWARE_VIDEO_COLORKEY 0x100701
+
+/*
+ * Maximum dimensions
+ */
+#define VMWARE_VID_MAX_WIDTH    2048
+#define VMWARE_VID_MAX_HEIGHT   2048
+
+#define VMWARE_VID_NUM_ENCODINGS 1
+static XF86VideoEncodingRec vmwareVideoEncodings[] =
+{
+    {
+       0,
+       "XV_IMAGE",
+       VMWARE_VID_MAX_WIDTH, VMWARE_VID_MAX_HEIGHT,
+       {1, 1}
+    }
+};
+
+#define VMWARE_VID_NUM_FORMATS 2
+static XF86VideoFormatRec vmwareVideoFormats[] =
+{
+    { 16, TrueColor},
+    { 24, TrueColor}
+};
+
+#define VMWARE_VID_NUM_IMAGES 3
+static XF86ImageRec vmwareVideoImages[] =
+{
+    XVIMAGE_YV12,
+    XVIMAGE_YUY2,
+    XVIMAGE_UYVY
+};
+
+#define VMWARE_VID_NUM_ATTRIBUTES 2
+static XF86AttributeRec vmwareVideoAttributes[] =
+{
+    {
+        XvGettable | XvSettable,
+        0x000000,
+        0xffffff,
+        "XV_COLORKEY"
+    },
+    {
+        XvGettable | XvSettable,
+        0,
+        1,
+        "XV_AUTOPAINT_COLORKEY"
+    }
+};
+
+/*
+ * Video frames are stored in a circular list of buffers.
+ * Must be power or two, See vmw_video_port_play.
+ */
+#define VMWARE_VID_NUM_BUFFERS 1
+
+/*
+ * Defines the structure used to hold and pass video data to the host
+ */
+struct vmw_video_buffer
+{
+    unsigned handle;
+    int size;
+    void *data;
+    void *extra_data;
+    struct vmw_dma_buffer *buf;
+};
+
+
+/**
+ * Structure representing a single video stream, aka port.
+ *
+ * Ports maps one to one to a SVGA stream. Port is just
+ * what Xv calls a SVGA stream.
+ */
+struct vmw_video_port
+{
+    /*
+     * Function prototype same as XvPutImage.
+     *
+     * This is either set to vmw_video_port_init or vmw_video_port_play.
+     * At init this function is set to port_init. In port_init we set it
+     * to port_play and call it, after initializing the struct.
+     */
+    int (*play)(ScrnInfoPtr, struct vmw_video_port *,
+                short, short, short, short, short,
+                short, short, short, int, unsigned char*,
+                short, short, RegionPtr);
+
+    /* values to go into the SVGAOverlayUnit */
+    uint32 streamId;
+    uint32 colorKey;
+    uint32 flags;
+
+    /* round robin of buffers */
+    unsigned currBuf;
+    struct vmw_video_buffer bufs[VMWARE_VID_NUM_BUFFERS];
+
+    /* properties that applies to all buffers */
+    int size;
+    int pitches[3];
+    int offsets[3];
+
+    /* things for X */
+    RegionRec clipBoxes;
+    Bool isAutoPaintColorkey;
+};
+
+
+/**
+ * Structure holding all the infromation for video.
+ */
+struct vmw_video_private
+{
+    int fd;
+
+    /** ports */
+    struct vmw_video_port port[VMWARE_VID_NUM_PORTS];
+
+    /** Used to store port pointers pointers */
+    DevUnion port_ptr[VMWARE_VID_NUM_PORTS];
+};
+
+
+/*
+ * Callback functions exported to Xv, prefixed with vmw_xv_*.
+ */
+static int vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
+                            short drw_x, short drw_y, short src_w, short src_h,
+                            short drw_w, short drw_h, int image,
+                            unsigned char *buf, short width, short height,
+                            Bool sync, RegionPtr clipBoxes, pointer data,
+                            DrawablePtr dst);
+static void vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool Cleanup);
+static int vmw_xv_query_image_attributes(ScrnInfoPtr pScrn, int format,
+                                         unsigned short *width,
+                                         unsigned short *height, int *pitches,
+                                         int *offsets);
+static int vmw_xv_set_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+                                     INT32 value, pointer data);
+static int vmw_xv_get_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+                                     INT32 *value, pointer data);
+static void vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
+                                short vid_w, short vid_h, short drw_w,
+                                short drw_h, unsigned int *p_w,
+                                unsigned int *p_h, pointer data);
+
+
+/*
+ * Local functions.
+ */
+static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw);
+
+static int vmw_video_port_init(ScrnInfoPtr pScrn,
+                               struct vmw_video_port *port,
+                               short src_x, short src_y, short drw_x,
+                               short drw_y, short src_w, short src_h,
+                               short drw_w, short drw_h, int format,
+                               unsigned char *buf, short width,
+                               short height, RegionPtr clipBoxes);
+static int vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+                               short src_x, short src_y, short drw_x,
+                               short drw_y, short src_w, short src_h,
+                               short drw_w, short drw_h, int format,
+                               unsigned char *buf, short width,
+                               short height, RegionPtr clipBoxes);
+static void vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port);
+
+static int vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size,
+                                  struct vmw_video_buffer *out);
+static int vmw_video_buffer_free(struct vmw_customizer *vmw,
+                                 struct vmw_video_buffer *out);
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_init --
+ *
+ *    Initializes Xv support.
+ *
+ * Results:
+ *    TRUE on success, FALSE on error.
+ *
+ * Side effects:
+ *    Xv support is initialized. Memory is allocated for all supported
+ *    video streams.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+vmw_video_init(struct vmw_customizer *vmw)
+{
+    ScrnInfoPtr pScrn = vmw->pScrn;
+    ScreenPtr pScreen = pScrn->pScreen;
+    XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL;
+    XF86VideoAdaptorPtr newAdaptor = NULL;
+    int numAdaptors;
+    unsigned int ntot, nfree;
+
+    debug_printf("%s: enter\n", __func__);
+
+    if (vmw_ioctl_num_streams(vmw, &ntot, &nfree) != 0) {
+        debug_printf("No stream ioctl support\n");
+        return FALSE;
+    }
+
+    if (nfree == 0) {
+        debug_printf("No free streams\n");
+        return FALSE;
+    }
+
+    numAdaptors = xf86XVListGenericAdaptors(pScrn, &overlayAdaptors);
+
+    newAdaptor = vmw_video_init_adaptor(pScrn, vmw);
+    if (!newAdaptor) {
+        debug_printf("Failed to initialize Xv extension\n");
+        return FALSE;
+    }
+
+    if (!numAdaptors) {
+        numAdaptors = 1;
+        overlayAdaptors = &newAdaptor;
+    } else {
+         newAdaptors = xalloc((numAdaptors + 1) *
+                              sizeof(XF86VideoAdaptorPtr*));
+         if (!newAdaptors) {
+            xf86XVFreeVideoAdaptorRec(newAdaptor);
+            return FALSE;
+         }
+
+         memcpy(newAdaptors, overlayAdaptors,
+                numAdaptors * sizeof(XF86VideoAdaptorPtr));
+         newAdaptors[numAdaptors++] = newAdaptor;
+         overlayAdaptors = newAdaptors;
+    }
+
+    if (!xf86XVScreenInit(pScreen, overlayAdaptors, numAdaptors)) {
+        debug_printf("Failed to initialize Xv extension\n");
+        xf86XVFreeVideoAdaptorRec(newAdaptor);
+        return FALSE;
+    }
+
+    if (newAdaptors) {
+        xfree(newAdaptors);
+    }
+
+    debug_printf("Initialized VMware Xv extension successfully\n");
+
+    return TRUE;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_close --
+ *
+ *    Unitializes video.
+ *
+ * Results:
+ *    TRUE.
+ *
+ * Side effects:
+ *    vmw->video_priv = NULL
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+vmw_video_close(struct vmw_customizer *vmw)
+{
+    ScrnInfoPtr pScrn = vmw->pScrn;
+    struct vmw_video_private *video;
+    int i;
+
+    debug_printf("%s: enter\n", __func__);
+
+    video = vmw->video_priv;
+    if (!video)
+       return TRUE;
+
+    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
+       /* make sure the port is stoped as well */
+       vmw_xv_stop_video(pScrn, &video->port[i], TRUE);
+       vmw_ioctl_unref_stream(vmw, video->port[i].streamId);
+    }
+
+    /* XXX: I'm sure this function is missing code for turning off Xv */
+
+    free(vmw->video_priv);
+    vmw->video_priv = NULL;
+
+    return TRUE;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_stop_all --
+ *
+ *    Stop all video streams from playing.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    All buffers are freed.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void vmw_video_stop_all(struct vmw_customizer *vmw)
+{
+    ScrnInfoPtr pScrn = vmw->pScrn;
+    struct vmw_video_private *video = vmw->video_priv;
+    int i;
+
+    debug_printf("%s: enter\n", __func__);
+
+    if (!video)
+       return;
+
+    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
+       vmw_xv_stop_video(pScrn, &video->port[i], TRUE);
+    }
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_init_adaptor --
+ *
+ *    Initializes a XF86VideoAdaptor structure with the capabilities and
+ *    functions supported by this video driver.
+ *
+ * Results:
+ *    On success initialized XF86VideoAdaptor struct or NULL on error
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static XF86VideoAdaptorPtr
+vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw)
+{
+    XF86VideoAdaptorPtr adaptor;
+    struct vmw_video_private *video;
+    int i;
+
+    debug_printf("%s: enter \n", __func__);
+
+    adaptor = xf86XVAllocateVideoAdaptorRec(pScrn);
+    if (!adaptor) {
+        debug_printf("Not enough memory\n");
+        return NULL;
+    }
+
+    video = xcalloc(1, sizeof(*video));
+    if (!video) {
+        debug_printf("Not enough memory.\n");
+        xf86XVFreeVideoAdaptorRec(adaptor);
+        return NULL;
+    }
+
+    vmw->video_priv = video;
+
+    adaptor->type = XvInputMask | XvImageMask | XvWindowMask;
+    adaptor->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+    adaptor->name = "VMware Video Engine";
+    adaptor->nEncodings = VMWARE_VID_NUM_ENCODINGS;
+    adaptor->pEncodings = vmwareVideoEncodings;
+    adaptor->nFormats = VMWARE_VID_NUM_FORMATS;
+    adaptor->pFormats = vmwareVideoFormats;
+    adaptor->nPorts = VMWARE_VID_NUM_PORTS;
+    adaptor->pPortPrivates = video->port_ptr;
+
+    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
+        vmw_ioctl_claim_stream(vmw, &video->port[i].streamId);
+        video->port[i].play = vmw_video_port_init;
+        video->port[i].flags = SVGA_VIDEO_FLAG_COLORKEY;
+        video->port[i].colorKey = VMWARE_VIDEO_COLORKEY;
+        video->port[i].isAutoPaintColorkey = TRUE;
+        adaptor->pPortPrivates[i].ptr = &video->port[i];
+    }
+
+    adaptor->nAttributes = VMWARE_VID_NUM_ATTRIBUTES;
+    adaptor->pAttributes = vmwareVideoAttributes;
+
+    adaptor->nImages = VMWARE_VID_NUM_IMAGES;
+    adaptor->pImages = vmwareVideoImages;
+
+    adaptor->PutVideo = NULL;
+    adaptor->PutStill = NULL;
+    adaptor->GetVideo = NULL;
+    adaptor->GetStill = NULL;
+    adaptor->StopVideo = vmw_xv_stop_video;
+    adaptor->SetPortAttribute = vmw_xv_set_port_attribute;
+    adaptor->GetPortAttribute = vmw_xv_get_port_attribute;
+    adaptor->QueryBestSize = vmw_xv_query_best_size;
+    adaptor->PutImage = vmw_xv_put_image;
+    adaptor->QueryImageAttributes = vmw_xv_query_image_attributes;
+
+    debug_printf("%s: done %p\n", __func__, adaptor);
+
+    return adaptor;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_init --
+ *
+ *    Initializes a video stream in response to the first PutImage() on a
+ *    video stream. The process goes as follows:
+ *    - Figure out characteristics according to format
+ *    - Allocate offscreen memory
+ *    - Pass on video to Play() functions
+ *
+ * Results:
+ *    Success or XvBadAlloc on failure.
+ *
+ * Side effects:
+ *    Video stream is initialized and its first frame sent to the host
+ *    (done by VideoPlay() function called at the end)
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+                    short src_x, short src_y, short drw_x,
+                    short drw_y, short src_w, short src_h,
+                    short drw_w, short drw_h, int format,
+                    unsigned char *buf, short width,
+                    short height, RegionPtr clipBoxes)
+{
+    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
+    unsigned short w, h;
+    int i, ret;
+
+    debug_printf("\t%s: id %d, format %d\n", __func__, port->streamId, format);
+
+    w = width;
+    h = height;
+    /* init all the format attributes, used for buffers */
+    port->size = vmw_xv_query_image_attributes(pScrn, format, &w, &h,
+                                               port->pitches, port->offsets);
+
+    if (port->size == -1)
+        return XvBadAlloc;
+
+    port->play = vmw_video_port_play;
+
+    for (i = 0; i < VMWARE_VID_NUM_BUFFERS; ++i) {
+       ret = vmw_video_buffer_alloc(vmw, port->size, &port->bufs[i]);
+       if (ret != Success)
+           break;
+    }
+
+    /* Free all allocated buffers on failure */
+    if (ret != Success) {
+       for (--i; i >= 0; --i) {
+           vmw_video_buffer_free(vmw, &port->bufs[i]);
+       }
+       return ret;
+    }
+
+    port->currBuf = 0;
+
+    REGION_COPY(pScrn->pScreen, &port->clipBoxes, clipBoxes);
+
+    if (port->isAutoPaintColorkey)
+        xf86XVFillKeyHelper(pScrn->pScreen, port->colorKey, clipBoxes);
+
+    return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w, src_h,
+                      drw_w, drw_h, format, buf, width, height, clipBoxes);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_play --
+ *
+ *    Sends all the attributes associated with the video frame using the
+ *    FIFO ESCAPE mechanism to the host.
+ *
+ * Results:
+ *    Always returns Success.
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+                    short src_x, short src_y, short drw_x,
+                    short drw_y, short src_w, short src_h,
+                    short drw_w, short drw_h, int format,
+                    unsigned char *buf, short width,
+                    short height, RegionPtr clipBoxes)
+{
+    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
+    struct drm_vmw_control_stream_arg arg;
+    unsigned short w, h;
+    int size;
+    int ret;
+
+    debug_printf("\t%s: enter\n", __func__);
+
+    w = width;
+    h = height;
+
+    /* we don't update the ports size */
+    size = vmw_xv_query_image_attributes(pScrn, format, &w, &h,
+                                         port->pitches, port->offsets);
+
+    if (size > port->size) {
+        debug_printf("\t%s: Increase in size of Xv video frame streamId:%d.\n",
+                     __func__, port->streamId);
+        vmw_xv_stop_video(pScrn, port, TRUE);
+        return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w,
+                          src_h, drw_w, drw_h, format, buf, width, height,
+                          clipBoxes);
+    }
+
+    memcpy(port->bufs[port->currBuf].data, buf, port->size);
+
+    memset(&arg, 0, sizeof(arg));
+
+    arg.stream_id = port->streamId;
+    arg.enabled = TRUE;
+    arg.flags = port->flags;
+    arg.color_key = port->colorKey;
+    arg.handle = port->bufs[port->currBuf].handle;
+    arg.format = format;
+    arg.size = port->size;
+    arg.width = w;
+    arg.height = h;
+    arg.src.x = src_x;
+    arg.src.y = src_y;
+    arg.src.w = src_w;
+    arg.src.h = src_h;
+    arg.dst.x = drw_x;
+    arg.dst.y = drw_y;
+    arg.dst.w = drw_w;
+    arg.dst.h = drw_h;
+    arg.pitch[0] = port->pitches[0];
+    arg.pitch[1] = port->pitches[1];
+    arg.pitch[2] = port->pitches[2];
+    arg.offset = 0;
+
+    /*
+     *  Update the clipList and paint the colorkey, if required.
+     */
+    if (!REGION_EQUAL(pScrn->pScreen, &port->clipBoxes, clipBoxes)) {
+        REGION_COPY(pScrn->pScreen, &port->clipBoxes, clipBoxes);
+        if (port->isAutoPaintColorkey) {
+            xf86XVFillKeyHelper(pScrn->pScreen, port->colorKey, clipBoxes);
+        }
+    }
+
+    ret = drmCommandWrite(vmw->fd, DRM_VMW_CONTROL_STREAM, &arg, sizeof(arg));
+    if (ret) {
+       vmw_video_port_cleanup(pScrn, port);
+       return XvBadAlloc;
+    }
+
+    if (++(port->currBuf) >= VMWARE_VID_NUM_BUFFERS)
+       port->currBuf = 0;
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_cleanup --
+ *
+ *    Frees up all resources (if any) taken by a video stream.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    Same as above.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port)
+{
+    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
+    uint32 id, colorKey, flags;
+    Bool isAutoPaintColorkey;
+    int i;
+
+    debug_printf("\t%s: enter\n", __func__);
+
+    for (i = 0; i < VMWARE_VID_NUM_BUFFERS; i++) {
+       vmw_video_buffer_free(vmw, &port->bufs[i]);
+    }
+
+    /*
+     * reset stream for next video
+     */
+    id = port->streamId;
+    colorKey = port->colorKey;
+    flags = port->flags;
+    isAutoPaintColorkey = port->isAutoPaintColorkey;
+
+    memset(port, 0, sizeof(*port));
+
+    port->streamId = id;
+    port->play = vmw_video_port_init;
+    port->colorKey = colorKey;
+    port->flags = flags;
+    port->isAutoPaintColorkey = isAutoPaintColorkey;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_buffer_alloc --
+ *
+ *    Allocates and map a kernel buffer to be used as data storage.
+ *
+ * Results:
+ *    XvBadAlloc on failure, otherwise Success.
+ *
+ * Side effects:
+ *    Calls into the kernel, sets members of out.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size,
+                       struct vmw_video_buffer *out)
+{
+    out->buf = vmw_ioctl_buffer_create(vmw, size, &out->handle);
+    if (!out->buf)
+       return XvBadAlloc;
+
+    out->data = vmw_ioctl_buffer_map(vmw, out->buf);
+    if (!out->data) {
+       vmw_ioctl_buffer_destroy(vmw, out->buf);
+
+       out->handle = 0;
+       out->buf = NULL;
+
+       return XvBadAlloc;
+    }
+
+    out->size = size;
+    out->extra_data = xcalloc(1, size);
+
+    debug_printf("\t\t%s: allocated buffer %p of size %i\n", __func__, out, size);
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_buffer_free --
+ *
+ *    Frees and unmaps an allocated kernel buffer.
+ *
+ * Results:
+ *    Success.
+ *
+ * Side effects:
+ *    Calls into the kernel, sets members of out to 0.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_buffer_free(struct vmw_customizer *vmw,
+                      struct vmw_video_buffer *out)
+{
+    if (out->size == 0)
+       return Success;
+
+    xfree(out->extra_data);
+    vmw_ioctl_buffer_unmap(vmw, out->buf);
+    vmw_ioctl_buffer_destroy(vmw, out->buf);
+
+    out->buf = NULL;
+    out->data = NULL;
+    out->handle = 0;
+    out->size = 0;
+
+    debug_printf("\t\t%s: freed buffer %p\n", __func__, out);
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_put_image --
+ *
+ *    Main video playback function. It copies the passed data which is in
+ *    the specified format (e.g. FOURCC_YV12) into the overlay.
+ *
+ *    If sync is TRUE the driver should not return from this
+ *    function until it is through reading the data from buf.
+ *
+ * Results:
+ *    Success or XvBadAlloc on failure
+ *
+ * Side effects:
+ *    Video port will be played(initialized if 1st frame) on success
+ *    or will fail on error.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
+                 short drw_x, short drw_y, short src_w, short src_h,
+                 short drw_w, short drw_h, int format,
+                 unsigned char *buf, short width, short height,
+                 Bool sync, RegionPtr clipBoxes, pointer data,
+                 DrawablePtr dst)
+{
+    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
+    struct vmw_video_port *port = data;
+
+    debug_printf("%s: enter (%u, %u) (%ux%u) (%u, %u) (%ux%u) (%ux%u)\n", __func__,
+                src_x, src_y, src_w, src_h,
+                drw_x, drw_y, drw_w, drw_h,
+                width, height);
+
+    if (!vmw->video_priv)
+        return XvBadAlloc;
+
+    return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w, src_h,
+                      drw_w, drw_h, format, buf, width, height, clipBoxes);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_stop_video --
+ *
+ *    Called when we should stop playing video for a particular stream. If
+ *    Cleanup is FALSE, the "stop" operation is only temporary, and thus we
+ *    don't do anything. If Cleanup is TRUE we kill the video port by
+ *    sending a message to the host and freeing up the stream.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    See above.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
+{
+    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
+    struct vmw_video_port *port = data;
+    struct drm_vmw_control_stream_arg arg;
+    int ret;
+
+    debug_printf("%s: cleanup is %s\n", __func__, cleanup ? "TRUE" : "FALSE");
+
+    if (!vmw->video_priv)
+        return;
+
+    if (!cleanup)
+        return;
+
+
+    memset(&arg, 0, sizeof(arg));
+    arg.stream_id = port->streamId;
+    arg.enabled = FALSE;
+
+    ret = drmCommandWrite(vmw->fd, DRM_VMW_CONTROL_STREAM, &arg, sizeof(arg));
+    assert(ret == 0);
+
+    vmw_video_port_cleanup(pScrn, port);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_query_image_attributes --
+ *
+ *    From the spec: This function is called to let the driver specify how data
+ *    for a particular image of size width by height should be stored.
+ *    Sometimes only the size and corrected width and height are needed. In
+ *    that case pitches and offsets are NULL.
+ *
+ * Results:
+ *    The size of the memory required for the image, or -1 on error.
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_query_image_attributes(ScrnInfoPtr pScrn, int format,
+                              unsigned short *width, unsigned short *height,
+                              int *pitches, int *offsets)
+{
+    INT32 size, tmp;
+
+    if (*width > VMWARE_VID_MAX_WIDTH) {
+        *width = VMWARE_VID_MAX_WIDTH;
+    }
+    if (*height > VMWARE_VID_MAX_HEIGHT) {
+        *height = VMWARE_VID_MAX_HEIGHT;
+    }
+
+    *width = (*width + 1) & ~1;
+    if (offsets != NULL) {
+        offsets[0] = 0;
+    }
+
+    switch (format) {
+       case FOURCC_YV12:
+           *height = (*height + 1) & ~1;
+           size = (*width + 3) & ~3;
+           if (pitches) {
+               pitches[0] = size;
+           }
+           size *= *height;
+           if (offsets) {
+               offsets[1] = size;
+           }
+           tmp = ((*width >> 1) + 3) & ~3;
+           if (pitches) {
+                pitches[1] = pitches[2] = tmp;
+           }
+           tmp *= (*height >> 1);
+           size += tmp;
+           if (offsets) {
+               offsets[2] = size;
+           }
+           size += tmp;
+           break;
+       case FOURCC_UYVY:
+       case FOURCC_YUY2:
+           size = *width * 2;
+           if (pitches) {
+               pitches[0] = size;
+           }
+           size *= *height;
+           break;
+       default:
+           debug_printf("Query for invalid video format %d\n", format);
+           return -1;
+    }
+    return size;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_set_port_attribute --
+ *
+ *    From the spec: A port may have particular attributes such as colorKey, hue,
+ *    saturation, brightness or contrast. Xv clients set these
+ *    attribute values by sending attribute strings (Atoms) to the server.
+ *
+ * Results:
+ *    Success if the attribute exists and XvBadAlloc otherwise.
+ *
+ * Side effects:
+ *    The respective attribute gets the new value.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_set_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+                          INT32 value, pointer data)
+{
+    struct vmw_video_port *port = data;
+    Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
+    Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
+
+    if (attribute == xvColorKey) {
+        debug_printf("%s: Set colorkey:0x%x\n", __func__, (unsigned)value);
+        port->colorKey = value;
+    } else if (attribute == xvAutoPaint) {
+        debug_printf("%s: Set autoPaint: %s\n", __func__, value? "TRUE": "FALSE");
+        port->isAutoPaintColorkey = value;
+    } else {
+        return XvBadAlloc;
+    }
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_get_port_attribute --
+ *
+ *    From the spec: A port may have particular attributes such as hue,
+ *    saturation, brightness or contrast. Xv clients get these
+ *    attribute values by sending attribute strings (Atoms) to the server
+ *
+ * Results:
+ *    Success if the attribute exists and XvBadAlloc otherwise.
+ *
+ * Side effects:
+ *    "value" contains the requested attribute on success.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_get_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+                          INT32 *value, pointer data)
+{
+    struct vmw_video_port *port = data;
+    Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
+    Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
+
+    if (attribute == xvColorKey) {
+        *value = port->colorKey;
+    } else if (attribute == xvAutoPaint) {
+        *value = port->isAutoPaintColorkey;
+    } else {
+        return XvBadAlloc;
+    }
+
+    return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_query_best_size --
+ *
+ *    From the spec: QueryBestSize provides the client with a way to query what
+ *    the destination dimensions would end up being if they were to request
+ *    that an area vid_w by vid_h from the video stream be scaled to rectangle
+ *    of drw_w by drw_h on the screen. Since it is not expected that all
+ *    hardware will be able to get the target dimensions exactly, it is
+ *    important that the driver provide this function.
+ *
+ *    This function seems to never be called, but to be on the safe side
+ *    we apply the same logic that QueryImageAttributes has for width
+ *    and height.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
+                       short vid_w, short vid_h, short drw_w,
+                       short drw_h, unsigned int *p_w,
+                       unsigned int *p_h, pointer data)
+{
+    *p_w = (drw_w + 1) & ~1;
+    *p_h = drw_h;
+
+    return;
+}
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_xorg.c b/src/gallium/targets/xorg-vmwgfx/vmw_xorg.c
new file mode 100644 (file)
index 0000000..87aad25
--- /dev/null
@@ -0,0 +1,191 @@
+/**********************************************************
+ * Copyright 2008-2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Glue file for Xorg State Tracker.
+ *
+ * @author Alan Hourihane <alanh@tungstengraphics.com>
+ * @author Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "vmw_hook.h"
+
+
+/*
+ * Defines and modinfo
+ */
+
+#define VMWGFX_DRIVER_NAME "vmwgfx"
+
+#define VMW_STRING_INNER(s) #s
+#define VMW_STRING(str) VMW_STRING_INNER(str)
+
+#define VMWGFX_VERSION_MAJOR 11
+#define VMWGFX_VERSION_MINOR 0
+#define VMWGFX_VERSION_PATCH 0
+#define VMWGFX_VERSION_STRING_MAJOR VMW_STRING(VMWGFX_VERSION_MAJOR)
+#define VMWGFX_VERSION_STRING_MINOR VMW_STRING(VMWGFX_VERSION_MINOR)
+#define VMWGFX_VERSION_STRING_PATCH VMW_STRING(VMWGFX_VERSION_PATCH)
+
+#define VMWGFX_DRIVER_VERSION \
+   (VMWGFX_VERSION_MAJOR * 65536 + VMWGFX_VERSION_MINOR * 256 + VMWGFX_VERSION_PATCH)
+#define VMWGFX_DRIVER_VERSION_STRING \
+    VMWGFX_VERSION_STRING_MAJOR "." VMWGFX_VERSION_STRING_MINOR \
+    "." VMWGFX_VERSION_STRING_PATCH
+
+/*
+ * Standard four digit version string expected by VMware Tools installer.
+ * As the driver's version is only  {major, minor, patchlevel}, simply append an
+ * extra zero for the fourth digit.
+ */
+#ifdef __GNUC__
+_X_EXPORT const char vmwgfx_drv_modinfo[] __attribute__((section(".modinfo"),unused)) =
+    "version=" VMWGFX_DRIVER_VERSION_STRING ".0";
+#endif
+
+static void vmw_xorg_identify(int flags);
+_X_EXPORT Bool vmw_xorg_pci_probe(DriverPtr driver,
+                                 int entity_num,
+                                 struct pci_device *device,
+                                 intptr_t match_data);
+
+
+/*
+ * Tables
+ */
+
+static const struct pci_id_match vmw_xorg_device_match[] = {
+    {0x15ad, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
+    {0, 0, 0, 0, 0, 0, 0},
+};
+
+static SymTabRec vmw_xorg_chipsets[] = {
+    {PCI_MATCH_ANY, "VMware SVGA Device"},
+    {-1, NULL}
+};
+
+static PciChipsets vmw_xorg_pci_devices[] = {
+    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
+    {-1, -1, NULL}
+};
+
+static XF86ModuleVersionInfo vmw_xorg_version = {
+    VMWGFX_DRIVER_NAME,
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    VMWGFX_VERSION_MAJOR, VMWGFX_VERSION_MINOR, VMWGFX_VERSION_PATCH,
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec vmwgfx = {
+    1,
+    VMWGFX_DRIVER_NAME,
+    vmw_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    vmw_xorg_device_match,
+    vmw_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(vmw_xorg_setup);
+
+_X_EXPORT XF86ModuleData vmwgfxModuleData = {
+    &vmw_xorg_version,
+    vmw_xorg_setup,
+    NULL
+};
+
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+vmw_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+       setupDone = 1;
+       xf86AddDriver(&vmwgfx, module, HaveDriverFuncs);
+
+       /*
+        * The return value must be non-NULL on success even though there
+        * is no TearDownProc.
+        */
+       return (pointer) 1;
+    } else {
+       if (errmaj)
+           *errmaj = LDR_ONCEONLY;
+       return NULL;
+    }
+}
+
+static void
+vmw_xorg_identify(int flags)
+{
+    xf86PrintChipsets("vmwgfx", "Driver for VMware SVGA device",
+                     vmw_xorg_chipsets);
+}
+
+_X_EXPORT Bool
+vmw_xorg_pci_probe(DriverPtr driver,
+         int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, vmw_xorg_pci_devices,
+                              NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+       scrn->driverVersion = 1;
+       scrn->driverName = "vmwgfx";
+       scrn->name = "vmwgfx";
+       scrn->Probe = NULL;
+
+       entity = xf86GetEntityInfo(entity_num);
+
+       /* Use all the functions from the xorg tracker */
+       xorg_tracker_set_functions(scrn);
+
+       vmw_screen_set_functions(scrn);
+    }
+    return scrn != NULL;
+}
index 30c3378dfff432dac799422690b4f2f5f98300c3..2013ee97c1c37751b66a5d5efd4c877dc79f1b93 100644 (file)
@@ -1,16 +1,36 @@
 Import('*')
 
-if env['dri']:
-       SConscript([
-               'drm/SConscript',
-       ])
-       
 if 'xlib' in env['winsys']:
        SConscript([
-               'xlib/SConscript',
+               'sw/xlib/SConscript',
        ])
 
 if 'gdi' in env['winsys']:
        SConscript([
-               'gdi/SConscript',
+               'sw/gdi/SConscript',
        ])
+
+if env['dri']:
+       SConscript([
+               'sw/dri/SConscript',
+       ])
+
+       if 'vmware' in env['winsys']:
+               SConscript([
+                       'svga/drm/SConscript',
+               ])
+
+       if 'i915' in env['winsys']:
+               SConscript([
+                       'i915/drm/SConscript',
+               ])
+
+       if 'i965' in env['winsys']:
+               SConscript([
+                       'i965/drm/SConscript',
+               ])
+
+       if 'radeon' in env['winsys']:
+               SConscript([
+                       'radeon/drm/SConscript',
+               ])
diff --git a/src/gallium/winsys/drm/Makefile b/src/gallium/winsys/drm/Makefile
deleted file mode 100644 (file)
index fee0191..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/Makefile
-TOP = ../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = $(GALLIUM_WINSYS_DRM_DIRS)
-
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl
deleted file mode 100644 (file)
index bc5dd3a..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-# src/gallium/winsys/drm/Makefile.egl
-
-# The driver Makefile should define
-#
-#   EGL_DRIVER_NAME, the name of the driver
-#   EGL_DRIVER_SOURCES, the sources of the driver
-#   EGL_DRIVER_LIBS, extra libraries needed by the driver
-#   EGL_DRIVER_PIPES, the pipe drivers of the driver
-#
-# before including this file.
-
-EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o)
-
-common_LIBS = -ldrm -lm -ldl
-
-x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \
-        $(TOP)/src/gallium/winsys/xlib/libws_xlib.a
-x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes
-
-kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a
-kms_LIBS = $(common_LIBS)
-
-##### RULES #####
-
-.c.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so)
-
-EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(TOP)/$(LIB_DIR)/$(drv))
-
-default: $(EGL_DISPLAY_LIBS)
-
-$(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so
-       $(INSTALL) $< $(TOP)/$(LIB_DIR)
-
-define mklib-egl
-$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-       $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \
-       -Wl,--start-group $($(1)_ST) $(EGL_DRIVER_PIPES) \
-       $(GALLIUM_AUXILIARIES) -Wl,--end-group \
-       $($(1)_LIBS) $(EGL_DRIVER_LIBS)
-endef
-
-egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile
-       $(call mklib-egl,x11)
-
-egl_kms_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(kms_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile
-       $(call mklib-egl,kms)
-
-clean:
-       -rm -f $(EGL_DRIVER_OBJECTS)
-       -rm -f $(EGL_DISPLAY_DRIVERS)
-
-install: $(EGL_DISPLAY_LIBS)
-       $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
-       for lib in $(EGL_DISPLAY_LIBS); do \
-               $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
-       done
-
-depend:
diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template
deleted file mode 100644 (file)
index f4cc0de..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-# -*-makefile-*-
-
-MESA_MODULES = \
-       $(TOP)/src/mesa/libmesagallium.a \
-       $(GALLIUM_AUXILIARIES)
-
-COMMON_GALLIUM_SOURCES = \
-        $(TOP)/src/mesa/drivers/dri/common/utils.c \
-        $(TOP)/src/mesa/drivers/dri/common/vblank.c \
-        $(TOP)/src/mesa/drivers/dri/common/dri_util.c \
-        $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c
-
-COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \
-        $(TOP)/src/mesa/drivers/common/driverfuncs.c \
-        $(TOP)/src/mesa/drivers/dri/common/texmem.c \
-        $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c
-
-COMMON_BM_SOURCES = \
-       $(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \
-       $(TOP)/src/mesa/drivers/dri/common/dri_drmpool.c
-
-INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES)
-
-OBJECTS = \
-       $(C_SOURCES:.c=.o) \
-       $(ASM_SOURCES:.S=.o) 
-
-
-### Include directories
-SHARED_INCLUDES = \
-       -I. \
-       -I$(TOP)/src/mesa/drivers/dri/common \
-       -Iserver \
-       -I$(TOP)/include \
-       -I$(TOP)/include/GL/internal \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/auxiliary \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/winsys/common \
-       -I$(TOP)/src/mesa \
-       -I$(TOP)/src/mesa/main \
-       -I$(TOP)/src/mesa/glapi \
-       -I$(TOP)/src/mesa/math \
-       -I$(TOP)/src/mesa/transform \
-       -I$(TOP)/src/mesa/shader \
-       -I$(TOP)/src/mesa/swrast \
-       -I$(TOP)/src/mesa/swrast_setup \
-       -I$(TOP)/src/egl/main \
-       -I$(TOP)/src/egl/drivers/dri \
-       $(LIBDRM_CFLAGS)
-
-
-##### RULES #####
-
-.c.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
-
-$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \
-               $(TOP)/src/mesa/drivers/dri/Makefile.template
-       $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-               $(OBJECTS) $(PIPE_DRIVERS) \
-                -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
-                 $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
-
-$(TOP)/$(LIB_DIR)/gallium:
-       mkdir -p $@
-
-$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
-       $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
-
-depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
-       rm -f depend
-       touch depend
-       $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_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 */*.o *~ *.so *~ server/*.o $(SYMLINKS)
-       -rm -f depend depend.bak
-
-
-install: $(LIBNAME)
-       $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
-       $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
-
-
-include depend
diff --git a/src/gallium/winsys/drm/SConscript b/src/gallium/winsys/drm/SConscript
deleted file mode 100644 (file)
index 66b73a8..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-Import('*')
-
-if env['dri']:
-
-       drienv = env.Clone()
-
-       drienv.Replace(CPPPATH = [
-               '#src/mesa/drivers/dri/common',
-               '#include',
-               '#include/GL/internal',
-               '#src/gallium/include',
-               '#src/gallium/auxiliary',
-               '#src/gallium/drivers',
-               '#src/mesa',
-               '#src/mesa/main',
-               '#src/mesa/glapi',
-               '#src/mesa/math',
-               '#src/mesa/transform',
-               '#src/mesa/shader',
-               '#src/mesa/swrast',
-               '#src/mesa/swrast_setup',
-               '#src/egl/main',
-               '#src/egl/drivers/dri',
-       ])
-
-       drienv.ParseConfig('pkg-config --cflags --libs libdrm')
-
-       COMMON_GALLIUM_SOURCES = [
-               '#src/mesa/drivers/dri/common/utils.c',
-               '#src/mesa/drivers/dri/common/vblank.c',
-               '#src/mesa/drivers/dri/common/dri_util.c',
-               '#src/mesa/drivers/dri/common/xmlconfig.c',
-       ]
-
-       COMMON_BM_SOURCES = [
-               '#src/mesa/drivers/dri/common/dri_bufmgr.c',
-               '#src/mesa/drivers/dri/common/dri_drmpool.c',
-       ]
-
-       Export([
-               'drienv',
-               'COMMON_GALLIUM_SOURCES',
-               'COMMON_BM_SOURCES',
-       ])
-
-       # TODO: Installation
-       #install: $(LIBNAME)
-       #       $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
-       #       $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
-
-       if 'vmware' in env['winsys']:
-               SConscript([
-                       'vmware/SConscript',
-               ])
-
-       if 'intel' in env['winsys']:
-               SConscript([
-                       'intel/SConscript',
-               ])
-
-       if 'i965' in env['winsys']:
-               SConscript([
-                       'i965/SConscript',
-               ])
-
-       if 'radeon' in env['winsys']:
-               SConscript([
-                       'radeon/SConscript',
-               ])
diff --git a/src/gallium/winsys/drm/i965/Makefile b/src/gallium/winsys/drm/i965/Makefile
deleted file mode 100644 (file)
index d8feef6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/intel/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS)
-
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
diff --git a/src/gallium/winsys/drm/i965/SConscript b/src/gallium/winsys/drm/i965/SConscript
deleted file mode 100644 (file)
index 50d7b75..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-Import('*')
-
-SConscript(['gem/SConscript',])
-
-if 'mesa' in env['statetrackers']:
-
-    SConscript(['dri/SConscript'])
diff --git a/src/gallium/winsys/drm/i965/dri/Makefile b/src/gallium/winsys/drm/i965/dri/Makefile
deleted file mode 100644 (file)
index f7e81ee..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i965_dri.so
-
-PIPE_DRIVERS = \
-       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
-       $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/drivers/identity/libidentity.a \
-       $(TOP)/src/gallium/drivers/i965/libi965.a
-
-
-DRIVER_SOURCES =
-
-C_SOURCES = \
-       $(COMMON_GALLIUM_SOURCES) \
-       $(DRIVER_SOURCES)
-
-include ../../Makefile.template
-
-DRI_LIB_DEPS += -ldrm_intel
-
-symlinks: $(TOP)/$(LIB_DIR)/gallium
-       @rm -f $(TOP)/$(LIB_DIR)/gallium/i965_dri.so
diff --git a/src/gallium/winsys/drm/i965/dri/SConscript b/src/gallium/winsys/drm/i965/dri/SConscript
deleted file mode 100644 (file)
index a99533f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
-
-drivers = [
-    st_dri,
-    i965drm,
-    i965,
-    trace,
-]
-
-env.LoadableModule(
-    target ='i965_dri.so',
-    source = COMMON_GALLIUM_SOURCES,
-    LIBS = drivers + mesa + gallium + env['LIBS'],
-    SHLIBPREFIX = '',
-)
diff --git a/src/gallium/winsys/drm/i965/egl/Makefile b/src/gallium/winsys/drm/i965/egl/Makefile
deleted file mode 100644 (file)
index 1c13258..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = i965
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS = -ldrm_intel
-
-EGL_DRIVER_PIPES = \
-       $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/i965/libi965.a
-
-include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/i965/egl/dummy.c b/src/gallium/winsys/drm/i965/egl/dummy.c
deleted file mode 100644 (file)
index 3181d0b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/winsys/drm/i965/gem/Makefile b/src/gallium/winsys/drm/i965/gem/Makefile
deleted file mode 100644 (file)
index 6a7497b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i965drm
-
-C_SOURCES = \
-       i965_drm_buffer.c \
-       i965_drm_api.c
-
-LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
-
-LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
-
-include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/i965/gem/SConscript b/src/gallium/winsys/drm/i965/gem/SConscript
deleted file mode 100644 (file)
index 6256ec6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-i965drm_sources = [
-    'i965_drm_api.c',
-    'i965_drm_buffer.c',
-]
-
-i965drm = env.ConvenienceLibrary(
-    target ='i965drm',
-    source = i965drm_sources,
-)
-
-Export('i965drm')
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
deleted file mode 100644 (file)
index 21e8230..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-
-#include <stdio.h>
-#include "state_tracker/drm_api.h"
-
-#include "i965_drm_winsys.h"
-#include "util/u_memory.h"
-
-#include "i965/brw_context.h"        /* XXX: shouldn't be doing this */
-#include "i965/brw_screen.h"         /* XXX: shouldn't be doing this */
-
-#include "trace/tr_drm.h"
-
-/*
- * Helper functions
- */
-
-
-static void
-i965_libdrm_get_device_id(unsigned int *device_id)
-{
-   char path[512];
-   FILE *file;
-   void *shutup_gcc;
-
-   /*
-    * FIXME: Fix this up to use a drm ioctl or whatever.
-    */
-
-   snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
-   file = fopen(path, "r");
-   if (!file) {
-      return;
-   }
-
-   shutup_gcc = fgets(path, sizeof(path), file);
-   sscanf(path, "%x", device_id);
-   fclose(file);
-}
-
-static void
-i965_libdrm_winsys_destroy(struct brw_winsys_screen *iws)
-{
-   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(iws);
-
-   if (BRW_DUMP)
-      debug_printf("%s\n", __FUNCTION__);
-
-   drm_intel_bufmgr_destroy(idws->gem);
-
-   FREE(idws);
-}
-
-static struct pipe_screen *
-i965_libdrm_create_screen(struct drm_api *api, int drmFD,
-                          struct drm_create_screen_arg *arg)
-{
-   struct i965_libdrm_winsys *idws;
-   unsigned int deviceID;
-
-   debug_printf("%s\n", __FUNCTION__);
-
-   if (arg != NULL) {
-      switch(arg->mode) {
-      case DRM_CREATE_NORMAL:
-         break;
-      default:
-         return NULL;
-      }
-   }
-
-   idws = CALLOC_STRUCT(i965_libdrm_winsys);
-   if (!idws)
-      return NULL;
-
-   i965_libdrm_get_device_id(&deviceID);
-
-   i965_libdrm_winsys_init_buffer_functions(idws);
-
-   idws->fd = drmFD;
-   idws->id = deviceID;
-
-   idws->base.destroy = i965_libdrm_winsys_destroy;
-
-   idws->gem = drm_intel_bufmgr_gem_init(idws->fd, BRW_BATCH_SIZE);
-   drm_intel_bufmgr_gem_enable_reuse(idws->gem);
-
-   idws->send_cmd = !debug_get_bool_option("BRW_NO_HW", FALSE);
-
-   return brw_create_screen(&idws->base, deviceID);
-}
-
-
-static void
-destroy(struct drm_api *api)
-{
-   if (BRW_DUMP)
-      debug_printf("%s\n", __FUNCTION__);
-
-}
-
-struct drm_api i965_libdrm_api =
-{
-   .name = "i965",
-   .create_screen = i965_libdrm_create_screen,
-   .destroy = destroy,
-};
-
-struct drm_api *
-drm_api_create()
-{
-   return trace_drm_create(&i965_libdrm_api);
-}
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
deleted file mode 100644 (file)
index 33a1749..0000000
+++ /dev/null
@@ -1,503 +0,0 @@
-
-#include "state_tracker/drm_api.h"
-#include "i965_drm_winsys.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-
-#include "i915_drm.h"
-#include "intel_bufmgr.h"
-
-
-
-const char *names[BRW_BUFFER_TYPE_MAX] = {
-   "TEXTURE",
-   "SCANOUT",
-   "VERTEX",
-   "CURBE",
-   "QUERY",
-   "SHADER_CONSTANTS",
-   "WM_SCRATCH",
-   "BATCH",
-   "GENERAL_STATE",
-   "SURFACE_STATE",
-   "PIXEL",
-   "GENERIC",
-};
-
-const char *usages[BRW_USAGE_MAX] = {
-   "STATE",
-   "QUERY_RESULT",
-   "RENDER_TARGET",
-   "DEPTH_BUFFER",
-   "BLIT_SOURCE",
-   "BLIT_DEST",
-   "SAMPLER",
-   "VERTEX",
-   "SCRATCH"
-};
-
-
-const char *data_types[BRW_DATA_MAX] =
-{
-   "GS: CC_VP",
-   "GS: CC_UNIT",
-   "GS: WM_PROG",
-   "GS: SAMPLER_DEFAULT_COLOR",
-   "GS: SAMPLER",
-   "GS: WM_UNIT",
-   "GS: SF_PROG",
-   "GS: SF_VP",
-   "GS: SF_UNIT",
-   "GS: VS_UNIT",
-   "GS: VS_PROG",
-   "GS: GS_UNIT",
-   "GS: GS_PROG",
-   "GS: CLIP_VP",
-   "GS: CLIP_UNIT",
-   "GS: CLIP_PROG",
-   "SS: SURFACE",
-   "SS: SURF_BIND",
-   "CONSTANT DATA",
-   "BATCH DATA",
-   "(untyped)"
-};
-
-static enum pipe_error 
-i965_libdrm_bo_alloc(struct brw_winsys_screen *sws,
-                     enum brw_buffer_type type,
-                     unsigned size,
-                     unsigned alignment,
-                     struct brw_winsys_buffer **bo_out)
-{
-   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
-   struct i965_libdrm_buffer *buf;
-
-   if (BRW_DUMP)
-      debug_printf("%s type %s sz %d align %d\n",
-                  __FUNCTION__, names[type], size, alignment );
-
-   buf = CALLOC_STRUCT(i965_libdrm_buffer);
-   if (!buf)
-      return PIPE_ERROR_OUT_OF_MEMORY;
-
-   switch (type) {
-   case BRW_BUFFER_TYPE_TEXTURE:
-/* case BRW_BUFFER_TYPE_SCANOUT:*/
-   case BRW_BUFFER_TYPE_VERTEX:
-   case BRW_BUFFER_TYPE_CURBE:
-   case BRW_BUFFER_TYPE_QUERY:
-   case BRW_BUFFER_TYPE_SHADER_CONSTANTS:
-   case BRW_BUFFER_TYPE_SHADER_SCRATCH:
-   case BRW_BUFFER_TYPE_BATCH:
-   case BRW_BUFFER_TYPE_GENERAL_STATE:
-   case BRW_BUFFER_TYPE_SURFACE_STATE:
-   case BRW_BUFFER_TYPE_PIXEL:
-   case BRW_BUFFER_TYPE_GENERIC:
-      break;
-   case BRW_BUFFER_TYPE_SCANOUT:
-      buf->map_gtt = TRUE;
-      break;
-   default:
-      assert(0);
-      break;
-   }
-
-   buf->bo = drm_intel_bo_alloc(idws->gem, 
-                                names[type], 
-                                size, 
-                                alignment);
-
-   if (!buf->bo)
-      goto err;
-
-   pipe_reference_init(&buf->base.reference, 1);
-   buf->base.size = size;
-   buf->base.sws = sws;
-
-   *bo_out = &buf->base;
-   return PIPE_OK;
-
-err:
-   assert(0);
-   FREE(buf);
-   return PIPE_ERROR_OUT_OF_MEMORY;
-}
-
-static enum pipe_error
-i965_libdrm_bo_from_handle(struct brw_winsys_screen *sws,
-                           struct winsys_handle *whandle,
-                           unsigned *stride,
-                           unsigned *tile,
-                           struct brw_winsys_buffer **bo_out)
-{
-   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
-   struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer);
-   uint32_t swizzle = 0;
-
-   if (BRW_DUMP)
-      debug_printf("%s\n", __FUNCTION__);
-
-   if (!buf)
-      return PIPE_ERROR_OUT_OF_MEMORY;
-
-   pipe_reference_init(&buf->base.reference, 1);
-   buf->bo = drm_intel_bo_gem_create_from_name(idws->gem, "FROM_HANDLE", whandle->handle);
-   buf->base.size = buf->bo->size;
-   buf->base.sws = &idws->base;
-   buf->flinked = TRUE;
-   buf->flink = whandle->handle;
-
-
-   if (!buf->bo)
-      goto err;
-
-   drm_intel_bo_get_tiling(buf->bo, &buf->tiling, &swizzle);
-   if (buf->tiling != 0)
-      buf->map_gtt = TRUE;
-
-   *tile = buf->tiling;
-   *stride = whandle->stride;
-
-   *bo_out = &buf->base;
-   return PIPE_OK;
-
-err:
-   FREE(buf);
-   return PIPE_ERROR_OUT_OF_MEMORY;
-}
-
-static enum pipe_error
-i965_libdrm_bo_get_handle(struct brw_winsys_buffer *buffer,
-                          struct winsys_handle *whandle,
-                          unsigned stride)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-
-   if (BRW_DUMP)
-      debug_printf("%s\n", __FUNCTION__);
-
-   if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
-      if (!buf->flinked) {
-         if (drm_intel_bo_flink(buf->bo, &buf->flink))
-            return PIPE_ERROR_BAD_INPUT;
-         buf->flinked = TRUE;
-      }
-
-      whandle->handle = buf->flink;
-   } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
-      whandle->handle = buf->bo->handle;
-   } else {
-      assert(!"unknown usage");
-      return PIPE_ERROR_BAD_INPUT;
-   }
-
-   whandle->stride = stride;
-   return PIPE_OK;
-}
-
-static void 
-i965_libdrm_bo_destroy(struct brw_winsys_buffer *buffer)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-
-   if (BRW_DUMP)
-      debug_printf("%s\n", __FUNCTION__);
-
-   drm_intel_bo_unreference(buf->bo);
-   FREE(buffer);
-}
-
-static enum pipe_error
-i965_libdrm_bo_emit_reloc(struct brw_winsys_buffer *buffer,
-                          enum brw_buffer_usage usage,
-                          unsigned delta,
-                          unsigned offset,
-                          struct brw_winsys_buffer *buffer2)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-   struct i965_libdrm_buffer *buf2 = i965_libdrm_buffer(buffer2);
-   int read, write;
-   int ret;
-
-   if (BRW_DUMP)
-      debug_printf("%s buf %p offset %x delta %x buf2 %p/%s/%s\n",
-                  __FUNCTION__, (void *)buffer, 
-                  offset, delta,
-                  (void *)buffer2, names[buf2->data_type], usages[usage]);
-
-   switch (usage) {
-   case BRW_USAGE_STATE:
-      read = I915_GEM_DOMAIN_INSTRUCTION;
-      write = 0;
-      break;
-   case BRW_USAGE_QUERY_RESULT:
-      read = I915_GEM_DOMAIN_INSTRUCTION;
-      write = I915_GEM_DOMAIN_INSTRUCTION;
-      break;
-   case BRW_USAGE_RENDER_TARGET:
-      read = I915_GEM_DOMAIN_RENDER;
-      write = 0;
-      break;
-   case BRW_USAGE_DEPTH_BUFFER:
-      read = I915_GEM_DOMAIN_RENDER;
-      write = I915_GEM_DOMAIN_RENDER;
-      break;
-   case BRW_USAGE_BLIT_SOURCE:
-      read = 0;
-      write = I915_GEM_DOMAIN_RENDER;
-      break;
-   case BRW_USAGE_BLIT_DEST:
-      read = I915_GEM_DOMAIN_RENDER;
-      write = I915_GEM_DOMAIN_RENDER;
-      break;
-   case BRW_USAGE_SAMPLER:
-      read = I915_GEM_DOMAIN_SAMPLER;
-      write = 0;
-      break;
-   case BRW_USAGE_VERTEX:
-      read = I915_GEM_DOMAIN_VERTEX;
-      write = 0;
-      break;
-   case BRW_USAGE_SCRATCH:
-      read = 0;
-      write = 0;
-      break;
-   default:
-      assert(0);
-      return -1;
-   }
-
-   /* Needed??
-   ((uint32_t *)buf->bo->virtual)[offset/4] = (delta +
-                                              buf2->bo->offset);
-    */
-
-   ret = dri_bo_emit_reloc( buf->bo, read, write, delta, offset, buf2->bo );
-   if (ret)
-      return -1;
-
-   return 0;
-}
-
-static enum pipe_error 
-i965_libdrm_bo_exec(struct brw_winsys_buffer *buffer,
-                    unsigned bytes_used)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
-   int ret;
-
-   if (BRW_DUMP)
-      debug_printf("execute buffer %p, bytes %d\n", (void *)buffer, bytes_used);
-
-   if (idws->send_cmd) {
-      ret = dri_bo_exec(buf->bo, bytes_used, NULL, 0, 0);
-      if (ret)
-         return PIPE_ERROR;
-   }
-
-   return PIPE_OK;
-}
-
-static enum pipe_error
-i965_libdrm_bo_subdata(struct brw_winsys_buffer *buffer,
-                       enum brw_buffer_data_type data_type,
-                       size_t offset,
-                       size_t size,
-                       const void *data,
-                       const struct brw_winsys_reloc *reloc,
-                       unsigned nr_reloc)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
-   int ret, i;
-
-   (void)data_type;
-
-   if (BRW_DUMP)
-      debug_printf("%s buf %p off %d sz %d %s relocs: %d\n", 
-                  __FUNCTION__, 
-                  (void *)buffer, offset, size, 
-                  data_types[data_type],
-                  nr_reloc);
-
-   if (BRW_DUMP)
-      brw_dump_data( idws->id,
-                    data_type,
-                    buf->bo->offset + offset, 
-                    data, size );
-
-   /* XXX: use bo_map_gtt/memcpy/unmap_gtt under some circumstances???
-    */
-   ret = drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
-   if (ret)
-      return PIPE_ERROR;
-  
-   for (i = 0; i < nr_reloc; i++) {
-      i965_libdrm_bo_emit_reloc(buffer, reloc[i].usage, reloc[i].delta,
-                                reloc[i].offset, reloc[i].bo);
-   }
-
-   return PIPE_OK;
-}
-
-static boolean 
-i965_libdrm_bo_is_busy(struct brw_winsys_buffer *buffer)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-   boolean ret;
-
-   if (BRW_DUMP)
-      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
-
-   ret = drm_intel_bo_busy(buf->bo);
-
-   if (BRW_DUMP)
-      debug_printf("  --> %d\n", ret);
-
-   return ret;
-}
-
-static boolean 
-i965_libdrm_bo_references(struct brw_winsys_buffer *a,
-                          struct brw_winsys_buffer *b)
-{
-   struct i965_libdrm_buffer *bufa = i965_libdrm_buffer(a);
-   struct i965_libdrm_buffer *bufb = i965_libdrm_buffer(b);
-   boolean ret;
-
-   if (BRW_DUMP)
-      debug_printf("%s %p %p\n", __FUNCTION__, (void *)a, (void *)b);
-
-   ret = drm_intel_bo_references(bufa->bo, bufb->bo);
-
-   if (BRW_DUMP)
-      debug_printf("  --> %d\n", ret);
-
-   return ret;
-}
-
-/* XXX: couldn't this be handled by returning true/false on
- * bo_emit_reloc?
- */
-static enum pipe_error
-i965_libdrm_check_aperture_space(struct brw_winsys_screen *iws,
-                                 struct brw_winsys_buffer **buffers,
-                                 unsigned count)
-{
-   static drm_intel_bo *bos[128];
-   int i;
-   int ret;
-
-   if (BRW_DUMP)
-      debug_printf("%s\n", __FUNCTION__);
-
-   if (count > Elements(bos)) {
-      assert(0);
-      return FALSE;
-   }
-
-   for (i = 0; i < count; i++)
-      bos[i] = i965_libdrm_buffer(buffers[i])->bo;
-
-   /* XXX: converting from ??? to pipe_error:
-    */
-   ret = dri_bufmgr_check_aperture_space(bos, count);
-
-   if (BRW_DUMP)
-      debug_printf("  --> %d (ok == %d)\n", ret, PIPE_OK);
-
-   return ret;
-}
-
-static void *
-i965_libdrm_bo_map(struct brw_winsys_buffer *buffer,
-                   enum brw_buffer_data_type data_type,
-                   unsigned offset,
-                   unsigned length,
-                   boolean write,
-                   boolean discard,
-                   boolean flush_explicit)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-   int ret;
-
-
-   if (BRW_DUMP)
-      debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer, 
-                  write ? "read/write" : "read",
-                  write ? data_types[data_type] : "");
-
-   if (!buf->map_count) {
-      if (buf->map_gtt) {
-         ret = drm_intel_gem_bo_map_gtt(buf->bo);
-         if (ret)
-            return NULL;
-      }
-      else {
-         ret = drm_intel_bo_map(buf->bo, write);
-         if (ret)
-            return NULL;
-      }
-   }
-
-   buf->data_type = data_type;
-   buf->map_count++;
-   return buf->bo->virtual;
-}
-
-static void
-i965_libdrm_bo_flush_range(struct brw_winsys_buffer *buffer,
-                           unsigned offset,
-                           unsigned length)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
-
-   if (BRW_DUMP)
-      debug_printf("%s %s offset %d len %d\n", __FUNCTION__,
-                  data_types[buf->data_type],
-                  offset, length);
-
-   if (BRW_DUMP)
-      brw_dump_data( idws->id,
-                    buf->data_type,
-                    buf->bo->offset + offset, 
-                    buf->bo->virtual + offset, 
-                    length );
-}
-
-static void 
-i965_libdrm_bo_unmap(struct brw_winsys_buffer *buffer)
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-
-   if (BRW_DUMP)
-      debug_printf("%s\n", __FUNCTION__);
-
-   if (--buf->map_count > 0)
-      return;
-
-   if (buf->map_gtt)
-      drm_intel_gem_bo_unmap_gtt(buf->bo);
-   else
-      drm_intel_bo_unmap(buf->bo);
-}
-
-void
-i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws)
-{
-   idws->base.bo_alloc             = i965_libdrm_bo_alloc;
-   idws->base.bo_from_handle       = i965_libdrm_bo_from_handle;
-   idws->base.bo_get_handle        = i965_libdrm_bo_get_handle;
-   idws->base.bo_destroy           = i965_libdrm_bo_destroy;
-   idws->base.bo_emit_reloc        = i965_libdrm_bo_emit_reloc;
-   idws->base.bo_exec              = i965_libdrm_bo_exec;
-   idws->base.bo_subdata           = i965_libdrm_bo_subdata;
-   idws->base.bo_is_busy           = i965_libdrm_bo_is_busy;
-   idws->base.bo_references        = i965_libdrm_bo_references;
-   idws->base.check_aperture_space = i965_libdrm_check_aperture_space;
-   idws->base.bo_map               = i965_libdrm_bo_map;
-   idws->base.bo_flush_range       = i965_libdrm_bo_flush_range;
-   idws->base.bo_unmap             = i965_libdrm_bo_unmap;
-}
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h b/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h
deleted file mode 100644 (file)
index c6a7d4a..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-
-#ifndef INTEL_DRM_WINSYS_H
-#define INTEL_DRM_WINSYS_H
-
-#include "i965/brw_winsys.h"
-
-#include "drm.h"
-#include "intel_bufmgr.h"
-
-
-
-/*
- * Winsys
- */
-
-
-struct i965_libdrm_winsys
-{
-   struct brw_winsys_screen base;
-   drm_intel_bufmgr *gem;
-
-   boolean send_cmd;
-
-   int fd; /**< Drm file discriptor */
-
-   unsigned id;
-};
-
-static INLINE struct i965_libdrm_winsys *
-i965_libdrm_winsys(struct brw_winsys_screen *iws)
-{
-   return (struct i965_libdrm_winsys *)iws;
-}
-
-struct i965_libdrm_winsys *i965_libdrm_winsys_create(int fd, unsigned pci_id);
-
-void i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws);
-
-
-/* Buffer.  
- */
-struct i965_libdrm_buffer {
-   struct brw_winsys_buffer base;
-
-   drm_intel_bo *bo;
-
-   void *ptr;
-   unsigned map_count;
-   unsigned data_type;         /* valid while mapped */
-   unsigned tiling;
-
-   boolean map_gtt;
-   boolean flinked;
-   unsigned flink;
-};
-
-static INLINE struct i965_libdrm_buffer *
-i965_libdrm_buffer(struct brw_winsys_buffer *buffer)
-{
-   return (struct i965_libdrm_buffer *)buffer;
-}
-
-
-#endif
diff --git a/src/gallium/winsys/drm/i965/xlib/Makefile b/src/gallium/winsys/drm/i965/xlib/Makefile
deleted file mode 100644 (file)
index 0efa0ca..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-# src/gallium/winsys/xlib/Makefile
-
-# This makefile produces a "stand-alone" libGL.so which is based on
-# Xlib (no DRI HW acceleration)
-
-
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-
-GL_MAJOR = 1
-GL_MINOR = 5
-GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
-
-
-INCLUDE_DIRS = \
-       -I$(TOP)/include \
-       -I$(TOP)/src/mesa \
-       -I$(TOP)/src/mesa/main \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/drivers/i965 \
-       -I$(TOP)/src/gallium/drivers/i965/include \
-       -I$(TOP)/src/gallium/state_trackers/glx/xlib \
-       -I$(TOP)/src/gallium/auxiliary \
-       -I/usr/include/drm
-
-XLIB_WINSYS_SOURCES = \
-       xlib_i965.c \
-
-
-
-XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
-
-
-
-LIBS = \
-       $(TOP)/src/gallium/drivers/i965/libi965.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \
-       $(TOP)/src/mesa/libglapi.a \
-       $(TOP)/src/mesa/libmesagallium.a \
-       $(GALLIUM_AUXILIARIES) 
-
-#      $(TOP)/src/gallium/drivers/i965/lib/libi9xx.a \
-
-.SUFFIXES : .cpp
-
-.c.o:
-       $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@
-
-.cpp.o:
-       $(CXX) -c $(INCLUDE_DIRS) $(DEFINES) $(CXXFLAGS) $< -o $@
-
-
-
-default: $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME)
-
-$(TOP)/$(LIB_DIR)/gallium:
-       @ mkdir -p $(TOP)/$(LIB_DIR)/gallium
-
-# Make the libGL.so library
-$(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS) Makefile
-       $(TOP)/bin/mklib -o $(GL_LIB) \
-               -linker "$(CC)" \
-               -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
-               -install $(TOP)/$(LIB_DIR)/gallium \
-               $(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \
-               -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS)
-
-
-depend: $(XLIB_WINSYS_SOURCES)
-       @ echo "running $(MKDEP)"
-       @ rm -f depend  # workaround oops on gutsy?!?
-       @ touch depend
-       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_WINSYS_SOURCES) \
-               > /dev/null 2>/dev/null
-
-
-install: default
-       $(INSTALL) -d $(INSTALL_DIR)/include/GL
-       $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
-       @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
-               $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
-       fi
-
-
-# Emacs tags
-tags:
-       etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
-
-clean:
-       -rm -f *.o
-
-
-include depend
diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
deleted file mode 100644 (file)
index 063e9f6..0000000
+++ /dev/null
@@ -1,503 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell
- *   Brian Paul
- */
-
-
-#include "util/u_memory.h"
-#include "util/u_math.h"
-#include "pipe/p_error.h"
-#include "pipe/p_context.h"
-
-#include "xm_public.h"
-
-#include "i965/brw_winsys.h"
-#include "i965/brw_screen.h"
-#include "i965/brw_reg.h"
-#include "i965/brw_structs_dump.h"
-
-#define MAX_VRAM (128*1024*1024)
-
-
-
-extern int brw_disasm (FILE *file, 
-                       const struct brw_instruction *inst,
-                       unsigned count );
-
-extern int intel_decode(const uint32_t *data, 
-                        int count,
-                        uint32_t hw_offset,
-                        uint32_t devid);
-
-struct xlib_brw_buffer
-{
-   struct brw_winsys_buffer base;
-   char *virtual;
-   unsigned offset;
-   unsigned type;
-   int map_count;
-   boolean modified;
-};
-
-
-/**
- * Subclass of brw_winsys_screen for Xlib winsys
- */
-struct xlib_brw_winsys
-{
-   struct brw_winsys_screen base;
-   struct brw_chipset chipset;
-
-   unsigned size;
-   unsigned used;
-};
-
-static struct xlib_brw_winsys *
-xlib_brw_winsys( struct brw_winsys_screen *screen )
-{
-   return (struct xlib_brw_winsys *)screen;
-}
-
-
-static struct xlib_brw_buffer *
-xlib_brw_buffer( struct brw_winsys_buffer *buffer )
-{
-   return (struct xlib_brw_buffer *)buffer;
-}
-
-
-
-const char *names[BRW_BUFFER_TYPE_MAX] = {
-   "TEXTURE",
-   "SCANOUT",
-   "VERTEX",
-   "CURBE",
-   "QUERY",
-   "SHADER_CONSTANTS",
-   "WM_SCRATCH",
-   "BATCH",
-   "GENERAL_STATE",
-   "SURFACE_STATE",
-   "PIXEL",
-   "GENERIC",
-};
-
-const char *usages[BRW_USAGE_MAX] = {
-   "STATE",
-   "QUERY_RESULT",
-   "RENDER_TARGET",
-   "DEPTH_BUFFER",
-   "BLIT_SOURCE",
-   "BLIT_DEST",
-   "SAMPLER",
-   "VERTEX",
-   "SCRATCH"
-};
-
-
-const char *data_types[BRW_DATA_MAX] =
-{
-   "GS: CC_VP",
-   "GS: CC_UNIT",
-   "GS: WM_PROG",
-   "GS: SAMPLER_DEFAULT_COLOR",
-   "GS: SAMPLER",
-   "GS: WM_UNIT",
-   "GS: SF_PROG",
-   "GS: SF_VP",
-   "GS: SF_UNIT",
-   "GS: VS_UNIT",
-   "GS: VS_PROG",
-   "GS: GS_UNIT",
-   "GS: GS_PROG",
-   "GS: CLIP_VP",
-   "GS: CLIP_UNIT",
-   "GS: CLIP_PROG",
-   "SS: SURFACE",
-   "SS: SURF_BIND",
-   "CONSTANT DATA",
-   "BATCH DATA",
-   "(untyped)"
-};
-
-
-static enum pipe_error
-xlib_brw_bo_alloc( struct brw_winsys_screen *sws,
-                   enum brw_buffer_type type,
-                   unsigned size,
-                   unsigned alignment,
-                   struct brw_winsys_buffer **bo_out )
-{
-   struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
-   struct xlib_brw_buffer *buf;
-
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s type %s sz %d align %d\n",
-                   __FUNCTION__, names[type], size, alignment );
-
-   buf = CALLOC_STRUCT(xlib_brw_buffer);
-   if (!buf)
-      return PIPE_ERROR_OUT_OF_MEMORY;
-
-   pipe_reference_init(&buf->base.reference, 1);
-
-   buf->offset = align(xbw->used, alignment);
-   buf->type = type;
-   buf->virtual = MALLOC(size);
-   buf->base.size = size;
-   buf->base.sws = sws;
-
-   xbw->used = align(xbw->used, alignment) + size;
-   if (xbw->used > MAX_VRAM)
-      goto err;
-
-   /* XXX: possibly rentrant call to bo_destroy:
-    */
-   bo_reference(bo_out, &buf->base);
-   return PIPE_OK;
-
-err:
-   assert(0);
-   FREE(buf->virtual);
-   FREE(buf);
-   return PIPE_ERROR_OUT_OF_MEMORY;
-}
-
-static void 
-xlib_brw_bo_destroy( struct brw_winsys_buffer *buffer )
-{
-   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-
-   FREE(buf);
-}
-
-static int 
-xlib_brw_bo_emit_reloc( struct brw_winsys_buffer *buffer,
-                        enum brw_buffer_usage usage,
-                        unsigned delta,
-                        unsigned offset,
-                        struct brw_winsys_buffer *buffer2)
-{
-   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-   struct xlib_brw_buffer *buf2 = xlib_brw_buffer(buffer2);
-
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s buf %p offset %x val %x + %x buf2 %p/%s/%s\n",
-                   __FUNCTION__, (void *)buffer, offset,
-                   buf2->offset, delta,
-                   (void *)buffer2, names[buf2->type], usages[usage]);
-
-   *(uint32_t *)(buf->virtual + offset) = buf2->offset + delta;
-
-   return 0;
-}
-
-static int 
-xlib_brw_bo_exec( struct brw_winsys_buffer *buffer,
-                    unsigned bytes_used )
-{
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("execute buffer %p, bytes %d\n", (void *)buffer, bytes_used);
-
-   return 0;
-}
-
-
-
-
-static int
-xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
-                    enum brw_buffer_data_type data_type,
-                    size_t offset,
-                    size_t size,
-                    const void *data,
-                    const struct brw_winsys_reloc *reloc,
-                    unsigned nr_relocs)
-{
-   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-   struct xlib_brw_winsys *xbw = xlib_brw_winsys(buffer->sws);
-   unsigned i;
-
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s buf %p off %d sz %d %s relocs: %d\n", 
-                   __FUNCTION__, 
-                   (void *)buffer, offset, size, 
-                   data_types[data_type],
-                   nr_relocs);
-
-   assert(buf->base.size >= offset + size);
-   memcpy(buf->virtual + offset, data, size);
-
-   /* Apply the relocations:
-    */
-   for (i = 0; i < nr_relocs; i++) {
-      if (BRW_DEBUG & DEBUG_WINSYS)
-         debug_printf("\treloc[%d] usage %s off %d value %x+%x\n", 
-                      i, usages[reloc[i].usage], reloc[i].offset,
-                      xlib_brw_buffer(reloc[i].bo)->offset, reloc[i].delta);
-
-      *(unsigned *)(buf->virtual + offset + reloc[i].offset) = 
-         xlib_brw_buffer(reloc[i].bo)->offset + reloc[i].delta;
-   }
-
-   if (BRW_DUMP)
-      brw_dump_data( xbw->chipset.pci_id,
-                    data_type,
-                    buf->offset + offset, 
-                    buf->virtual + offset, size );
-
-
-   return 0;
-}
-
-
-static boolean 
-xlib_brw_bo_is_busy(struct brw_winsys_buffer *buffer)
-{
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
-   return TRUE;
-}
-
-static boolean 
-xlib_brw_bo_references(struct brw_winsys_buffer *a,
-                         struct brw_winsys_buffer *b)
-{
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s %p %p\n", __FUNCTION__, (void *)a, (void *)b);
-   return TRUE;
-}
-
-static enum pipe_error
-xlib_brw_check_aperture_space( struct brw_winsys_screen *iws,
-                                struct brw_winsys_buffer **buffers,
-                                unsigned count )
-{
-   unsigned tot_size = 0;
-   unsigned i;
-
-   for (i = 0; i < count; i++)
-      tot_size += buffers[i]->size;
-
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s %d bufs, tot_size: %d kb\n", 
-                   __FUNCTION__, count, 
-                   (tot_size + 1023) / 1024);
-
-   return PIPE_OK;
-}
-
-static void *
-xlib_brw_bo_map(struct brw_winsys_buffer *buffer,
-                enum brw_buffer_data_type data_type,
-                unsigned offset,
-                unsigned length,
-                boolean write,
-                boolean discard,
-                boolean explicit)
-{
-   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer, 
-                   write ? "read/write" : "read",
-                   write ? data_types[data_type] : "");
-
-   if (write)
-      buf->modified = 1;
-
-   buf->map_count++;
-   return buf->virtual;
-}
-
-
-static void
-xlib_brw_bo_flush_range( struct brw_winsys_buffer *buffer,
-                         unsigned offset,
-                         unsigned length )
-{
-}
-
-
-static void 
-xlib_brw_bo_unmap(struct brw_winsys_buffer *buffer)
-{
-   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
-
-   --buf->map_count;
-   assert(buf->map_count >= 0);
-
-   if (buf->map_count == 0 &&
-       buf->modified) {
-
-      buf->modified = 0;
-      
-      /* Consider dumping new buffer contents here, using the
-       * flush-range info to minimize verbosity.
-       */
-   }
-}
-
-
-static void
-xlib_brw_bo_wait_idle( struct brw_winsys_buffer *buffer )
-{
-}
-
-
-static void
-xlib_brw_winsys_destroy( struct brw_winsys_screen *sws )
-{
-   struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
-
-   FREE(xbw);
-}
-
-static struct brw_winsys_screen *
-xlib_create_brw_winsys_screen( void )
-{
-   struct xlib_brw_winsys *ws;
-
-   ws = CALLOC_STRUCT(xlib_brw_winsys);
-   if (!ws)
-      return NULL;
-
-   ws->used = 0;
-
-   ws->base.destroy              = xlib_brw_winsys_destroy;
-   ws->base.bo_alloc             = xlib_brw_bo_alloc;
-   ws->base.bo_destroy           = xlib_brw_bo_destroy;
-   ws->base.bo_emit_reloc        = xlib_brw_bo_emit_reloc;
-   ws->base.bo_exec              = xlib_brw_bo_exec;
-   ws->base.bo_subdata           = xlib_brw_bo_subdata;
-   ws->base.bo_is_busy           = xlib_brw_bo_is_busy;
-   ws->base.bo_references        = xlib_brw_bo_references;
-   ws->base.check_aperture_space = xlib_brw_check_aperture_space;
-   ws->base.bo_map               = xlib_brw_bo_map;
-   ws->base.bo_flush_range       = xlib_brw_bo_flush_range;
-   ws->base.bo_unmap             = xlib_brw_bo_unmap;
-   ws->base.bo_wait_idle         = xlib_brw_bo_wait_idle;
-
-   return &ws->base;
-}
-
-
-/***********************************************************************
- * Implementation of Xlib co-state-tracker's winsys interface
- */
-
-static void
-xlib_i965_display_surface(struct xmesa_buffer *xm_buffer,
-                          struct pipe_surface *surf)
-{
-   struct brw_surface *surface = brw_surface(surf);
-   struct xlib_brw_buffer *bo = xlib_brw_buffer(surface->bo);
-
-   if (BRW_DEBUG & DEBUG_WINSYS)
-      debug_printf("%s offset %x+%x sz %dx%d\n", __FUNCTION__, 
-                   bo->offset,
-                   surface->draw_offset,
-                   surf->width,
-                   surf->height);
-}
-
-static void
-xlib_i965_flush_frontbuffer(struct pipe_screen *screen,
-                           struct pipe_surface *surf,
-                           void *context_private)
-{
-   xlib_i965_display_surface(NULL, surf);
-}
-
-
-static struct pipe_screen *
-xlib_create_i965_screen( void )
-{
-   struct brw_winsys_screen *winsys;
-   struct pipe_screen *screen;
-
-   winsys = xlib_create_brw_winsys_screen();
-   if (winsys == NULL)
-      return NULL;
-
-   screen = brw_create_screen(winsys, PCI_CHIP_GM45_GM);
-   if (screen == NULL)
-      goto fail;
-
-   xlib_brw_winsys(winsys)->chipset = brw_screen(screen)->chipset;
-
-   screen->flush_frontbuffer = xlib_i965_flush_frontbuffer;
-   return screen;
-
-fail:
-   if (winsys)
-      winsys->destroy( winsys );
-
-   return NULL;
-}
-
-
-
-
-
-struct xm_driver xlib_i965_driver = 
-{
-   .create_pipe_screen = xlib_create_i965_screen,
-   .display_surface = xlib_i965_display_surface
-};
-
-
-/* Register this driver at library load: 
- */
-static void _init( void ) __attribute__((constructor));
-static void _init( void )
-{
-   xmesa_set_driver( &xlib_i965_driver );
-}
-
-
-
-/***********************************************************************
- *
- * Butt-ugly hack to convince the linker not to throw away public GL
- * symbols (they are all referenced from getprocaddress, I guess).
- */
-extern void (*linker_foo(const unsigned char *procName))();
-extern void (*glXGetProcAddress(const unsigned char *procName))();
-
-extern void (*linker_foo(const unsigned char *procName))()
-{
-   return glXGetProcAddress(procName);
-}
diff --git a/src/gallium/winsys/drm/i965/xorg/Makefile b/src/gallium/winsys/drm/i965/xorg/Makefile
deleted file mode 100644 (file)
index c25726b..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-TOP        = ../../../../../..
-
-
-GALLIUMDIR = $(TOP)/src/gallium
-
-TARGET     = i965g_drv.so
-
-CFILES     = $(wildcard ./*.c)
-
-include ${TOP}/configs/current
-
-OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
-
-CFLAGS = -DHAVE_CONFIG_H \
-         -g -Wall -Wimplicit-function-declaration -fPIC \
-         $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
-         -I${GALLIUMDIR}/include \
-         -I${GALLIUMDIR}/drivers \
-         -I${GALLIUMDIR}/auxiliary \
-         -I${TOP}/src/mesa \
-         -I$(TOP)/include \
-         -I$(TOP)/src/egl/main
-
-LIBS = \
-       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
-       $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \
-       $(TOP)/src/gallium/drivers/i965/libi965.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(GALLIUM_AUXILIARIES)
-
-TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
-#############################################
-
-all default: $(TARGET) $(TARGET_STAGING)
-
-$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS)
-       $(TOP)/bin/mklib -noprefix -o $@ \
-       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
-
-$(TOP)/$(LIB_DIR)/gallium:
-       mkdir -p $@
-
-$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
-       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
-
-clean:
-       rm -rf $(OBJECTS) $(TARGET)
-
-install:
-       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-
-.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/i965/xorg/intel_xorg.c b/src/gallium/winsys/drm/i965/xorg/intel_xorg.c
deleted file mode 100644 (file)
index ac691cb..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Author: Alan Hourihane <alanh@tungstengraphics.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- *
- */
-
-#include "../../../../state_trackers/xorg/xorg_winsys.h"
-
-static void intel_xorg_identify(int flags);
-static Bool intel_xorg_pci_probe(DriverPtr driver,
-                                int entity_num,
-                                struct pci_device *device,
-                                intptr_t match_data);
-
-static const struct pci_id_match intel_xorg_device_match[] = {
-    {0x8086, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
-    {0, 0, 0},
-};
-
-static SymTabRec intel_xorg_chipsets[] = {
-    {PCI_MATCH_ANY, "Intel Graphics Device"},
-    {-1, NULL}
-};
-
-static PciChipsets intel_xorg_pci_devices[] = {
-    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
-    {-1, -1, NULL}
-};
-
-static XF86ModuleVersionInfo intel_xorg_version = {
-    "modesetting",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    0, 1, 0, /* major, minor, patch */
-    ABI_CLASS_VIDEODRV,
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_VIDEODRV,
-    {0, 0, 0, 0}
-};
-
-/*
- * Xorg driver exported structures
- */
-
-_X_EXPORT DriverRec modesetting = {
-    1,
-    "modesetting",
-    intel_xorg_identify,
-    NULL,
-    xorg_tracker_available_options,
-    NULL,
-    0,
-    NULL,
-    intel_xorg_device_match,
-    intel_xorg_pci_probe
-};
-
-static MODULESETUPPROTO(intel_xorg_setup);
-
-_X_EXPORT XF86ModuleData modesettingModuleData = {
-    &intel_xorg_version,
-    intel_xorg_setup,
-    NULL
-};
-
-/*
- * Xorg driver functions
- */
-
-static pointer
-intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = 0;
-
-    /* This module should be loaded only once, but check to be sure.
-     */
-    if (!setupDone) {
-       setupDone = 1;
-       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
-
-       /*
-        * The return value must be non-NULL on success even though there
-        * is no TearDownProc.
-        */
-       return (pointer) 1;
-    } else {
-       if (errmaj)
-           *errmaj = LDR_ONCEONLY;
-       return NULL;
-    }
-}
-
-static void
-intel_xorg_identify(int flags)
-{
-    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
-                     intel_xorg_chipsets);
-}
-
-static Bool
-intel_xorg_pci_probe(DriverPtr driver,
-         int entity_num, struct pci_device *device, intptr_t match_data)
-{
-    ScrnInfoPtr scrn = NULL;
-    EntityInfoPtr entity;
-
-    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
-                              NULL, NULL, NULL, NULL, NULL);
-    if (scrn != NULL) {
-       scrn->driverVersion = 1;
-       scrn->driverName = "i965";
-       scrn->name = "modesetting";
-       scrn->Probe = NULL;
-
-       entity = xf86GetEntityInfo(entity_num);
-
-       /* Use all the functions from the xorg tracker */
-       xorg_tracker_set_functions(scrn);
-    }
-    return scrn != NULL;
-}
diff --git a/src/gallium/winsys/drm/intel/Makefile b/src/gallium/winsys/drm/intel/Makefile
deleted file mode 100644 (file)
index d8feef6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/intel/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS)
-
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
diff --git a/src/gallium/winsys/drm/intel/SConscript b/src/gallium/winsys/drm/intel/SConscript
deleted file mode 100644 (file)
index 50d7b75..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-Import('*')
-
-SConscript(['gem/SConscript',])
-
-if 'mesa' in env['statetrackers']:
-
-    SConscript(['dri/SConscript'])
diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile
deleted file mode 100644 (file)
index 26aae41..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i915_dri.so
-
-PIPE_DRIVERS = \
-       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
-       $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/drivers/identity/libidentity.a \
-       $(TOP)/src/gallium/drivers/i915/libi915.a
-
-
-DRIVER_SOURCES =
-
-C_SOURCES = \
-       $(COMMON_GALLIUM_SOURCES) \
-       $(DRIVER_SOURCES)
-
-include ../../Makefile.template
-
-DRI_LIB_DEPS += -ldrm_intel
-
-symlinks: $(TOP)/$(LIB_DIR)/gallium
-       @rm -f $(TOP)/$(LIB_DIR)/gallium/i965_dri.so
diff --git a/src/gallium/winsys/drm/intel/dri/SConscript b/src/gallium/winsys/drm/intel/dri/SConscript
deleted file mode 100644 (file)
index 0df841d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
-
-env.Prepend(LIBS = [
-    st_dri,
-    inteldrm,
-    i915,
-    trace,
-    mesa,
-    glsl,
-    gallium
-])
-
-env.LoadableModule(
-    target ='i915_dri.so',
-    source = COMMON_GALLIUM_SOURCES,
-    SHLIBPREFIX = '',
-)
diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile
deleted file mode 100644 (file)
index 60d675c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = i915
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS = -ldrm_intel
-
-EGL_DRIVER_PIPES = \
-       $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/i915/libi915.a
-
-include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/intel/egl/dummy.c b/src/gallium/winsys/drm/intel/egl/dummy.c
deleted file mode 100644 (file)
index 3181d0b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/winsys/drm/intel/gem/Makefile b/src/gallium/winsys/drm/intel/gem/Makefile
deleted file mode 100644 (file)
index 0d6d4e3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = inteldrm
-
-C_SOURCES = \
-       intel_drm_batchbuffer.c \
-       intel_drm_buffer.c \
-       intel_drm_fence.c \
-       intel_drm_api.c
-
-LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
-
-LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
-
-include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/intel/gem/SConscript b/src/gallium/winsys/drm/intel/gem/SConscript
deleted file mode 100644 (file)
index 26717f3..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-inteldrm_sources = [
-    'intel_drm_api.c',
-    'intel_drm_batchbuffer.c',
-    'intel_drm_buffer.c',
-    'intel_drm_fence.c',
-]
-
-inteldrm = env.ConvenienceLibrary(
-    target ='inteldrm',
-    source = inteldrm_sources,
-)
-
-Export('inteldrm')
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
deleted file mode 100644 (file)
index e3b980a..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <stdio.h>
-
-#include "state_tracker/drm_api.h"
-
-#include "intel_drm_winsys.h"
-#include "util/u_memory.h"
-
-#include "i915/i915_context.h"
-#include "i915/i915_screen.h"
-
-#include "trace/tr_drm.h"
-
-/*
- * Helper functions
- */
-
-
-static void
-intel_drm_get_device_id(unsigned int *device_id)
-{
-   char path[512];
-   FILE *file;
-   void *shutup_gcc;
-
-   /*
-    * FIXME: Fix this up to use a drm ioctl or whatever.
-    */
-
-   snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
-   file = fopen(path, "r");
-   if (!file) {
-      return;
-   }
-
-   shutup_gcc = fgets(path, sizeof(path), file);
-   (void) shutup_gcc;
-   sscanf(path, "%x", device_id);
-   fclose(file);
-}
-
-static void
-intel_drm_winsys_destroy(struct intel_winsys *iws)
-{
-   struct intel_drm_winsys *idws = intel_drm_winsys(iws);
-
-   drm_intel_bufmgr_destroy(idws->pools.gem);
-
-   FREE(idws);
-}
-
-static struct pipe_screen *
-intel_drm_create_screen(struct drm_api *api, int drmFD,
-                        struct drm_create_screen_arg *arg)
-{
-   struct intel_drm_winsys *idws;
-   unsigned int deviceID;
-
-   if (arg != NULL) {
-      switch(arg->mode) {
-      case DRM_CREATE_NORMAL:
-         break;
-      default:
-         return NULL;
-      }
-   }
-
-   idws = CALLOC_STRUCT(intel_drm_winsys);
-   if (!idws)
-      return NULL;
-
-   intel_drm_get_device_id(&deviceID);
-
-   intel_drm_winsys_init_batchbuffer_functions(idws);
-   intel_drm_winsys_init_buffer_functions(idws);
-   intel_drm_winsys_init_fence_functions(idws);
-
-   idws->fd = drmFD;
-   idws->id = deviceID;
-   idws->max_batch_size = 16 * 4096;
-
-   idws->base.destroy = intel_drm_winsys_destroy;
-
-   idws->pools.gem = drm_intel_bufmgr_gem_init(idws->fd, idws->max_batch_size);
-   drm_intel_bufmgr_gem_enable_reuse(idws->pools.gem);
-
-   idws->dump_cmd = debug_get_bool_option("INTEL_DUMP_CMD", FALSE);
-
-   return i915_create_screen(&idws->base, deviceID);
-}
-
-static void
-destroy(struct drm_api *api)
-{
-
-}
-
-struct drm_api intel_drm_api =
-{
-   .name = "i915",
-   .driver_name = "i915",
-   .create_screen = intel_drm_create_screen,
-   .destroy = destroy,
-};
-
-struct drm_api *
-drm_api_create()
-{
-   return trace_drm_create(&intel_drm_api);
-}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c b/src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c
deleted file mode 100644 (file)
index 5b4dafc..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-
-#include "intel_drm_winsys.h"
-#include "util/u_memory.h"
-
-#include "i915_drm.h"
-
-#define BATCH_RESERVED 16
-
-#define INTEL_DEFAULT_RELOCS 100
-#define INTEL_MAX_RELOCS 400
-
-#define INTEL_BATCH_NO_CLIPRECTS 0x1
-#define INTEL_BATCH_CLIPRECTS    0x2
-
-#undef INTEL_RUN_SYNC
-#undef INTEL_MAP_BATCHBUFFER
-#undef INTEL_MAP_GTT
-#define INTEL_ALWAYS_FLUSH
-
-struct intel_drm_batchbuffer
-{
-   struct intel_batchbuffer base;
-
-   size_t actual_size;
-
-   drm_intel_bo *bo;
-};
-
-static INLINE struct intel_drm_batchbuffer *
-intel_drm_batchbuffer(struct intel_batchbuffer *batch)
-{
-   return (struct intel_drm_batchbuffer *)batch;
-}
-
-static void
-intel_drm_batchbuffer_reset(struct intel_drm_batchbuffer *batch)
-{
-   struct intel_drm_winsys *idws = intel_drm_winsys(batch->base.iws);
-   int ret;
-
-   if (batch->bo)
-      drm_intel_bo_unreference(batch->bo);
-   batch->bo = drm_intel_bo_alloc(idws->pools.gem,
-                                  "gallium3d_batchbuffer",
-                                  batch->actual_size,
-                                  4096);
-
-#ifdef INTEL_MAP_BATCHBUFFER
-#ifdef INTEL_MAP_GTT
-   ret = drm_intel_gem_bo_map_gtt(batch->bo);
-#else
-   ret = drm_intel_bo_map(batch->bo, TRUE);
-#endif
-   assert(ret == 0);
-   batch->base.map = batch->bo->virtual;
-#else
-   (void)ret;
-#endif
-
-   memset(batch->base.map, 0, batch->actual_size);
-   batch->base.ptr = batch->base.map;
-   batch->base.size = batch->actual_size - BATCH_RESERVED;
-   batch->base.relocs = 0;
-}
-
-static struct intel_batchbuffer *
-intel_drm_batchbuffer_create(struct intel_winsys *iws)
-{
-   struct intel_drm_winsys *idws = intel_drm_winsys(iws);
-   struct intel_drm_batchbuffer *batch = CALLOC_STRUCT(intel_drm_batchbuffer);
-
-   batch->actual_size = idws->max_batch_size;
-
-#ifdef INTEL_MAP_BATCHBUFFER
-   batch->base.map = NULL;
-#else
-   batch->base.map = MALLOC(batch->actual_size);
-#endif
-   batch->base.ptr = NULL;
-   batch->base.size = 0;
-
-   batch->base.relocs = 0;
-   batch->base.max_relocs = 300;/*INTEL_DEFAULT_RELOCS;*/
-
-   batch->base.iws = iws;
-
-   intel_drm_batchbuffer_reset(batch);
-
-   return &batch->base;
-}
-
-static int
-intel_drm_batchbuffer_reloc(struct intel_batchbuffer *ibatch,
-                            struct intel_buffer *buffer,
-                            enum intel_buffer_usage usage,
-                            unsigned pre_add)
-{
-   struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch);
-   unsigned write_domain = 0;
-   unsigned read_domain = 0;
-   unsigned offset;
-   int ret = 0;
-
-   assert(batch->base.relocs < batch->base.max_relocs);
-
-   if (usage == INTEL_USAGE_SAMPLER) {
-      write_domain = 0;
-      read_domain = I915_GEM_DOMAIN_SAMPLER;
-
-   } else if (usage == INTEL_USAGE_RENDER) {
-      write_domain = I915_GEM_DOMAIN_RENDER;
-      read_domain = I915_GEM_DOMAIN_RENDER;
-
-   } else if (usage == INTEL_USAGE_2D_TARGET) {
-      write_domain = I915_GEM_DOMAIN_RENDER;
-      read_domain = I915_GEM_DOMAIN_RENDER;
-
-   } else if (usage == INTEL_USAGE_2D_SOURCE) {
-      write_domain = 0;
-      read_domain = I915_GEM_DOMAIN_RENDER;
-
-   } else if (usage == INTEL_USAGE_VERTEX) {
-      write_domain = 0;
-      read_domain = I915_GEM_DOMAIN_VERTEX;
-
-   } else {
-      assert(0);
-      return -1;
-   }
-
-   offset = (unsigned)(batch->base.ptr - batch->base.map);
-
-   ret = drm_intel_bo_emit_reloc(batch->bo, offset,
-                                 intel_bo(buffer), pre_add,
-                                 read_domain,
-                                 write_domain);
-
-   ((uint32_t*)batch->base.ptr)[0] = intel_bo(buffer)->offset + pre_add;
-   batch->base.ptr += 4;
-
-   if (!ret)
-      batch->base.relocs++;
-
-   return ret;
-}
-
-static void
-intel_drm_batchbuffer_flush(struct intel_batchbuffer *ibatch,
-                            struct pipe_fence_handle **fence)
-{
-   struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch);
-   unsigned used = 0;
-   int ret = 0;
-   int i;
-
-   assert(intel_batchbuffer_space(ibatch) >= 0);
-
-   used = batch->base.ptr - batch->base.map;
-   assert((used & 3) == 0);
-
-
-#ifdef INTEL_ALWAYS_FLUSH
-   /* MI_FLUSH | FLUSH_MAP_CACHE */
-   intel_batchbuffer_dword(ibatch, (0x4<<23)|(1<<0));
-   used += 4;
-#endif
-
-   if ((used & 4) == 0) {
-      /* MI_NOOP */
-      intel_batchbuffer_dword(ibatch, 0);
-   }
-   /* MI_BATCH_BUFFER_END */
-   intel_batchbuffer_dword(ibatch, (0xA<<23));
-
-   used = batch->base.ptr - batch->base.map;
-   assert((used & 4) == 0);
-
-#ifdef INTEL_MAP_BATCHBUFFER
-#ifdef INTEL_MAP_GTT
-   drm_intel_gem_bo_unmap_gtt(batch->bo);
-#else
-   drm_intel_bo_unmap(batch->bo);
-#endif
-#else
-   drm_intel_bo_subdata(batch->bo, 0, used, batch->base.map);
-#endif
-
-   /* Do the sending to HW */
-   ret = drm_intel_bo_exec(batch->bo, used, NULL, 0, 0);
-   assert(ret == 0);
-
-   if (intel_drm_winsys(ibatch->iws)->dump_cmd) {
-      unsigned *ptr;
-      drm_intel_bo_map(batch->bo, FALSE);
-      ptr = (unsigned*)batch->bo->virtual;
-
-      debug_printf("%s:\n", __func__);
-      for (i = 0; i < used / 4; i++, ptr++) {
-         debug_printf("\t%08x:    %08x\n", i*4, *ptr);
-      }
-
-      drm_intel_bo_unmap(batch->bo);
-   } else {
-#ifdef INTEL_RUN_SYNC
-      drm_intel_bo_map(batch->bo, FALSE);
-      drm_intel_bo_unmap(batch->bo);
-#endif
-   }
-
-   if (fence) {
-      ibatch->iws->fence_reference(ibatch->iws, fence, NULL);
-
-#ifdef INTEL_RUN_SYNC
-      /* we run synced to GPU so just pass null */
-      (*fence) = intel_drm_fence_create(NULL);
-#else
-      (*fence) = intel_drm_fence_create(batch->bo);
-#endif
-   }
-
-   intel_drm_batchbuffer_reset(batch);
-}
-
-static void
-intel_drm_batchbuffer_destroy(struct intel_batchbuffer *ibatch)
-{
-   struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch);
-
-   if (batch->bo)
-      drm_intel_bo_unreference(batch->bo);
-
-#ifndef INTEL_MAP_BATCHBUFFER
-   FREE(batch->base.map);
-#endif
-   FREE(batch);
-}
-
-void intel_drm_winsys_init_batchbuffer_functions(struct intel_drm_winsys *idws)
-{
-   idws->base.batchbuffer_create = intel_drm_batchbuffer_create;
-   idws->base.batchbuffer_reloc = intel_drm_batchbuffer_reloc;
-   idws->base.batchbuffer_flush = intel_drm_batchbuffer_flush;
-   idws->base.batchbuffer_destroy = intel_drm_batchbuffer_destroy;
-}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c b/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c
deleted file mode 100644 (file)
index cb4f92a..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-
-#include "state_tracker/drm_api.h"
-#include "intel_drm_winsys.h"
-#include "util/u_memory.h"
-
-#include "i915_drm.h"
-
-static struct intel_buffer *
-intel_drm_buffer_create(struct intel_winsys *iws,
-                        unsigned size, unsigned alignment,
-                        enum intel_buffer_type type)
-{
-   struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer);
-   struct intel_drm_winsys *idws = intel_drm_winsys(iws);
-   drm_intel_bufmgr *pool;
-   char *name;
-
-   if (!buf)
-      return NULL;
-
-   buf->magic = 0xDEAD1337;
-   buf->flinked = FALSE;
-   buf->flink = 0;
-   buf->map_gtt = FALSE;
-
-   if (type == INTEL_NEW_TEXTURE) {
-      name = "gallium3d_texture";
-      pool = idws->pools.gem;
-   } else if (type == INTEL_NEW_VERTEX) {
-      name = "gallium3d_vertex";
-      pool = idws->pools.gem;
-      buf->map_gtt = TRUE;
-   } else if (type == INTEL_NEW_SCANOUT) {
-      name = "gallium3d_scanout";
-      pool = idws->pools.gem;
-      buf->map_gtt = TRUE;
-   } else {
-      assert(0);
-      name = "gallium3d_unknown";
-      pool = idws->pools.gem;
-   }
-
-   buf->bo = drm_intel_bo_alloc(pool, name, size, alignment);
-
-   if (!buf->bo)
-      goto err;
-
-   return (struct intel_buffer *)buf;
-
-err:
-   assert(0);
-   FREE(buf);
-   return NULL;
-}
-
-static struct intel_buffer *
-intel_drm_buffer_from_handle(struct intel_winsys *iws,
-                             struct winsys_handle *whandle,
-                             unsigned *stride)
-{
-   struct intel_drm_winsys *idws = intel_drm_winsys(iws);
-   struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer);
-   uint32_t tile = 0, swizzle = 0;
-
-   if (!buf)
-      return NULL;
-
-   buf->magic = 0xDEAD1337;
-   buf->bo = drm_intel_bo_gem_create_from_name(idws->pools.gem, "gallium3d_from_handle", whandle->handle);
-   buf->flinked = TRUE;
-   buf->flink = whandle->handle;
-
-   if (!buf->bo)
-      goto err;
-
-   drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle);
-   if (tile != INTEL_TILE_NONE)
-      buf->map_gtt = TRUE;
-
-   *stride = whandle->stride;
-
-   return (struct intel_buffer *)buf;
-
-err:
-   FREE(buf);
-   return NULL;
-}
-
-static boolean
-intel_drm_buffer_get_handle(struct intel_winsys *iws,
-                            struct intel_buffer *buffer,
-                            struct winsys_handle *whandle,
-                            unsigned stride)
-{
-   struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
-
-   if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
-      if (!buf->flinked) {
-         if (drm_intel_bo_flink(buf->bo, &buf->flink))
-            return FALSE;
-         buf->flinked = TRUE;
-      }
-
-      whandle->handle = buf->flink;
-   } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
-      whandle->handle = buf->bo->handle;
-   } else {
-      assert(!"unknown usage");
-      return FALSE;
-   }
-
-   whandle->stride = stride;
-   return TRUE;
-}
-
-static int
-intel_drm_buffer_set_fence_reg(struct intel_winsys *iws,
-                               struct intel_buffer *buffer,
-                               unsigned stride,
-                               enum intel_buffer_tile tile)
-{
-   struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
-   assert(I915_TILING_NONE == INTEL_TILE_NONE);
-   assert(I915_TILING_X == INTEL_TILE_X);
-   assert(I915_TILING_Y == INTEL_TILE_Y);
-
-   if (tile != INTEL_TILE_NONE) {
-      assert(buf->map_count == 0);
-      buf->map_gtt = TRUE;
-   }
-
-   return drm_intel_bo_set_tiling(buf->bo, &tile, stride);
-}
-
-static void *
-intel_drm_buffer_map(struct intel_winsys *iws,
-                     struct intel_buffer *buffer,
-                     boolean write)
-{
-   struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
-   drm_intel_bo *bo = intel_bo(buffer);
-   int ret = 0;
-
-   assert(bo);
-
-   if (buf->map_count)
-      goto out;
-
-   if (buf->map_gtt)
-      ret = drm_intel_gem_bo_map_gtt(bo);
-   else
-      ret = drm_intel_bo_map(bo, write);
-
-   buf->ptr = bo->virtual;
-
-   assert(ret == 0);
-out:
-   if (ret)
-      return NULL;
-
-   buf->map_count++;
-   return buf->ptr;
-}
-
-static void
-intel_drm_buffer_unmap(struct intel_winsys *iws,
-                       struct intel_buffer *buffer)
-{
-   struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
-
-   if (--buf->map_count)
-      return;
-
-   if (buf->map_gtt)
-      drm_intel_gem_bo_unmap_gtt(intel_bo(buffer));
-   else
-      drm_intel_bo_unmap(intel_bo(buffer));
-}
-
-static int
-intel_drm_buffer_write(struct intel_winsys *iws,
-                       struct intel_buffer *buffer,
-                       size_t offset,
-                       size_t size,
-                       const void *data)
-{
-   struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
-
-   return drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
-}
-
-static void
-intel_drm_buffer_destroy(struct intel_winsys *iws,
-                         struct intel_buffer *buffer)
-{
-   drm_intel_bo_unreference(intel_bo(buffer));
-
-#ifdef DEBUG
-   intel_drm_buffer(buffer)->magic = 0;
-   intel_drm_buffer(buffer)->bo = NULL;
-#endif
-
-   FREE(buffer);
-}
-
-void
-intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws)
-{
-   idws->base.buffer_create = intel_drm_buffer_create;
-   idws->base.buffer_from_handle = intel_drm_buffer_from_handle;
-   idws->base.buffer_get_handle = intel_drm_buffer_get_handle;
-   idws->base.buffer_set_fence_reg = intel_drm_buffer_set_fence_reg;
-   idws->base.buffer_map = intel_drm_buffer_map;
-   idws->base.buffer_unmap = intel_drm_buffer_unmap;
-   idws->base.buffer_write = intel_drm_buffer_write;
-   idws->base.buffer_destroy = intel_drm_buffer_destroy;
-}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c b/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
deleted file mode 100644 (file)
index 102faed..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-
-#include "intel_drm_winsys.h"
-#include "util/u_memory.h"
-#include "util/u_atomic.h"
-#include "util/u_inlines.h"
-
-/**
- * Because gem does not have fence's we have to create our own fences.
- *
- * They work by keeping the batchbuffer around and checking if that has
- * been idled. If bo is NULL fence has expired.
- */
-struct intel_drm_fence
-{
-   struct pipe_reference reference;
-   drm_intel_bo *bo;
-};
-
-
-struct pipe_fence_handle *
-intel_drm_fence_create(drm_intel_bo *bo)
-{
-   struct intel_drm_fence *fence = CALLOC_STRUCT(intel_drm_fence);
-
-   pipe_reference_init(&fence->reference, 1);
-   /* bo is null if fence already expired */
-   if (bo) {
-      drm_intel_bo_reference(bo);
-      fence->bo = bo;
-   }
-
-   return (struct pipe_fence_handle *)fence;
-}
-
-static void
-intel_drm_fence_reference(struct intel_winsys *iws,
-                          struct pipe_fence_handle **ptr,
-                          struct pipe_fence_handle *fence)
-{
-   struct intel_drm_fence *old = (struct intel_drm_fence *)*ptr;
-   struct intel_drm_fence *f = (struct intel_drm_fence *)fence;
-
-   if (pipe_reference(&((struct intel_drm_fence *)(*ptr))->reference, &f->reference)) {
-      if (old->bo)
-         drm_intel_bo_unreference(old->bo);
-      FREE(old);
-   }
-   *ptr = fence;
-}
-
-static int
-intel_drm_fence_signalled(struct intel_winsys *iws,
-                          struct pipe_fence_handle *fence)
-{
-   assert(0);
-
-   return 0;
-}
-
-static int
-intel_drm_fence_finish(struct intel_winsys *iws,
-                       struct pipe_fence_handle *fence)
-{
-   struct intel_drm_fence *f = (struct intel_drm_fence *)fence;
-
-   /* fence already expired */
-   if (!f->bo)
-      return 0;
-
-   drm_intel_bo_wait_rendering(f->bo);
-   drm_intel_bo_unreference(f->bo);
-   f->bo = NULL;
-
-   return 0;
-}
-
-void
-intel_drm_winsys_init_fence_functions(struct intel_drm_winsys *idws)
-{
-   idws->base.fence_reference = intel_drm_fence_reference;
-   idws->base.fence_signalled = intel_drm_fence_signalled;
-   idws->base.fence_finish = intel_drm_fence_finish;
-}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h b/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h
deleted file mode 100644 (file)
index 9786ee9..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-
-#ifndef INTEL_DRM_WINSYS_H
-#define INTEL_DRM_WINSYS_H
-
-#include "i915/intel_batchbuffer.h"
-
-#include "drm.h"
-#include "intel_bufmgr.h"
-
-
-/*
- * Winsys
- */
-
-
-struct intel_drm_winsys
-{
-   struct intel_winsys base;
-
-   boolean dump_cmd;
-
-   int fd; /**< Drm file discriptor */
-
-   unsigned id;
-
-   size_t max_batch_size;
-
-   struct {
-      drm_intel_bufmgr *gem;
-   } pools;
-};
-
-static INLINE struct intel_drm_winsys *
-intel_drm_winsys(struct intel_winsys *iws)
-{
-   return (struct intel_drm_winsys *)iws;
-}
-
-struct intel_drm_winsys * intel_drm_winsys_create(int fd, unsigned pci_id);
-struct pipe_fence_handle * intel_drm_fence_create(drm_intel_bo *bo);
-
-void intel_drm_winsys_init_batchbuffer_functions(struct intel_drm_winsys *idws);
-void intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws);
-void intel_drm_winsys_init_fence_functions(struct intel_drm_winsys *idws);
-
-
-/*
- * Buffer
- */
-
-
-struct intel_drm_buffer {
-   unsigned magic;
-
-   drm_intel_bo *bo;
-
-   void *ptr;
-   unsigned map_count;
-   boolean map_gtt;
-
-   boolean flinked;
-   unsigned flink;
-};
-
-static INLINE struct intel_drm_buffer *
-intel_drm_buffer(struct intel_buffer *buffer)
-{
-   return (struct intel_drm_buffer *)buffer;
-}
-
-static INLINE drm_intel_bo *
-intel_bo(struct intel_buffer *buffer)
-{
-   return intel_drm_buffer(buffer)->bo;
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile
deleted file mode 100644 (file)
index 14c2462..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-TARGET     = modesetting_drv.so
-CFILES     = $(wildcard ./*.c)
-OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
-TOP        = ../../../../../..
-
-include $(TOP)/configs/current
-
-INCLUDES = \
-       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
-       -I../gem \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/auxiliary \
-       -I$(TOP)/src/mesa \
-       -I$(TOP)/include \
-       -I$(TOP)/src/egl/main
-
-LIBS = \
-       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
-       $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \
-       $(TOP)/src/gallium/drivers/i915/libi915.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(GALLIUM_AUXILIARIES)
-
-DRIVER_DEFINES = \
-       -DHAVE_CONFIG_H
-
-
-#############################################
-
-
-
-all default: $(TARGET)
-
-$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS)
-       $(TOP)/bin/mklib -noprefix -o $@ \
-       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
-
-clean:
-       rm -rf $(OBJECTS) $(TARGET)
-
-install:
-       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-
-
-##############################################
-
-
-.c.o:
-       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
-
-
-##############################################
-
-.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_xorg.c b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c
deleted file mode 100644 (file)
index 369dc35..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Author: Alan Hourihane <alanh@tungstengraphics.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- *
- */
-
-#include "../../../../state_trackers/xorg/xorg_winsys.h"
-
-static void intel_xorg_identify(int flags);
-static Bool intel_xorg_pci_probe(DriverPtr driver,
-                                int entity_num,
-                                struct pci_device *device,
-                                intptr_t match_data);
-
-static const struct pci_id_match intel_xorg_device_match[] = {
-    {0x8086, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
-    {0, 0, 0},
-};
-
-static SymTabRec intel_xorg_chipsets[] = {
-    {PCI_MATCH_ANY, "Intel Graphics Device"},
-    {-1, NULL}
-};
-
-static PciChipsets intel_xorg_pci_devices[] = {
-    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
-    {-1, -1, NULL}
-};
-
-static XF86ModuleVersionInfo intel_xorg_version = {
-    "modesetting",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    0, 1, 0, /* major, minor, patch */
-    ABI_CLASS_VIDEODRV,
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_VIDEODRV,
-    {0, 0, 0, 0}
-};
-
-/*
- * Xorg driver exported structures
- */
-
-_X_EXPORT DriverRec modesetting = {
-    1,
-    "modesetting",
-    intel_xorg_identify,
-    NULL,
-    xorg_tracker_available_options,
-    NULL,
-    0,
-    NULL,
-    intel_xorg_device_match,
-    intel_xorg_pci_probe
-};
-
-static MODULESETUPPROTO(intel_xorg_setup);
-
-_X_EXPORT XF86ModuleData modesettingModuleData = {
-    &intel_xorg_version,
-    intel_xorg_setup,
-    NULL
-};
-
-/*
- * Xorg driver functions
- */
-
-static pointer
-intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = 0;
-
-    /* This module should be loaded only once, but check to be sure.
-     */
-    if (!setupDone) {
-       setupDone = 1;
-       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
-
-       /*
-        * The return value must be non-NULL on success even though there
-        * is no TearDownProc.
-        */
-       return (pointer) 1;
-    } else {
-       if (errmaj)
-           *errmaj = LDR_ONCEONLY;
-       return NULL;
-    }
-}
-
-static void
-intel_xorg_identify(int flags)
-{
-    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
-                     intel_xorg_chipsets);
-}
-
-static Bool
-intel_xorg_pci_probe(DriverPtr driver,
-         int entity_num, struct pci_device *device, intptr_t match_data)
-{
-    ScrnInfoPtr scrn = NULL;
-    EntityInfoPtr entity;
-
-    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
-                              NULL, NULL, NULL, NULL, NULL);
-    if (scrn != NULL) {
-       scrn->driverVersion = 1;
-       scrn->driverName = "i915";
-       scrn->name = "modesetting";
-       scrn->Probe = NULL;
-
-       entity = xf86GetEntityInfo(entity_num);
-
-       /* Use all the functions from the xorg tracker */
-       xorg_tracker_set_functions(scrn);
-    }
-    return scrn != NULL;
-}
diff --git a/src/gallium/winsys/drm/nouveau/Makefile b/src/gallium/winsys/drm/nouveau/Makefile
deleted file mode 100644 (file)
index 6c9cbef..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/nouveau/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = drm $(GALLIUM_STATE_TRACKERS_DIRS)
-
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile
deleted file mode 100644 (file)
index 50ac3f2..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nouveau_dri.so
-
-PIPE_DRIVERS = \
-       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
-       $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
-       $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
-       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
-       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
-
-DRIVER_SOURCES =
-
-C_SOURCES = \
-       $(COMMON_GALLIUM_SOURCES) \
-       $(DRIVER_SOURCES)
-
-include ../../Makefile.template
-
-DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
-
-symlinks:
diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile
deleted file mode 100644 (file)
index 54c3b26..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nouveaudrm
-
-C_SOURCES = nouveau_drm_api.c
-
-LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I)
-LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
-
-include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h
deleted file mode 100644 (file)
index 1207c2d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _NOUVEAU_DRI_
-#define _NOUVEAU_DRI_
-
-#include "xf86drm.h"
-#include "drm.h"
-#include "nouveau_drm.h"
-
-struct nouveau_dri {
-       uint32_t device_id;     /**< \brief PCI device ID */
-       uint32_t width;         /**< \brief width in pixels of display */
-       uint32_t height;        /**< \brief height in scanlines of display */
-       uint32_t depth;         /**< \brief depth of display (8, 15, 16, 24) */
-       uint32_t bpp;           /**< \brief bit depth of display (8, 16, 24, 32) */
-
-       uint32_t bus_type;      /**< \brief ths bus type */
-       uint32_t bus_mode;      /**< \brief bus mode (used for AGP, maybe also for PCI-E ?) */
-
-       uint32_t front_offset;  /**< \brief front buffer offset */
-       uint32_t front_pitch;   /**< \brief front buffer pitch */
-       uint32_t back_offset;   /**< \brief private back buffer offset */
-       uint32_t back_pitch;    /**< \brief private back buffer pitch */
-       uint32_t depth_offset;  /**< \brief private depth buffer offset */
-       uint32_t depth_pitch;   /**< \brief private depth buffer pitch */
-
-};
-
-#endif
-
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
deleted file mode 100644 (file)
index 716d4ba..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "util/u_format.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-
-#include "nouveau_drm_api.h"
-
-#include "nouveau_drmif.h"
-#include "nouveau_channel.h"
-#include "nouveau_bo.h"
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_screen.h"
-
-static struct pipe_surface *
-dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen,
-                        unsigned handle, enum pipe_format format,
-                        unsigned width, unsigned height, unsigned pitch)
-{
-       struct pipe_surface *ps = NULL;
-       struct pipe_texture *pt = NULL;
-       struct pipe_texture tmpl;
-       struct winsys_handle whandle;
-
-       memset(&tmpl, 0, sizeof(tmpl));
-       tmpl.tex_usage = PIPE_TEXTURE_USAGE_SCANOUT;
-       tmpl.target = PIPE_TEXTURE_2D;
-       tmpl.last_level = 0;
-       tmpl.depth0 = 1;
-       tmpl.format = format;
-       tmpl.width0 = width;
-       tmpl.height0 = height;
-
-       memset(&whandle, 0, sizeof(whandle));
-       whandle.stride = pitch;
-       whandle.handle = handle;
-
-       pt = pscreen->texture_from_handle(pscreen, &tmpl, &whandle);
-       if (!pt)
-               return NULL;
-
-       ps = pscreen->get_tex_surface(pscreen, pt, 0, 0, 0,
-                                     PIPE_BUFFER_USAGE_GPU_READ |
-                                     PIPE_BUFFER_USAGE_GPU_WRITE);
-
-       /* we don't need the texture from this point on */
-       pipe_texture_reference(&pt, NULL);
-       return ps;
-}
-
-static struct pipe_surface *
-nouveau_dri1_front_surface(struct pipe_context *pipe)
-{
-       return nouveau_winsys_screen(pipe->screen)->front;
-}
-
-static struct dri1_api nouveau_dri1_api = {
-       nouveau_dri1_front_surface,
-};
-
-static void
-nouveau_drm_destroy_winsys(struct pipe_winsys *s)
-{
-       struct nouveau_winsys *nv_winsys = nouveau_winsys(s);
-       struct nouveau_screen *nv_screen= nouveau_screen(nv_winsys->pscreen);
-       nouveau_device_close(&nv_screen->device);
-       FREE(nv_winsys);
-}
-
-static struct pipe_screen *
-nouveau_drm_create_screen(struct drm_api *api, int fd,
-                         struct drm_create_screen_arg *arg)
-{
-       struct dri1_create_screen_arg *dri1 = (void *)arg;
-       struct nouveau_winsys *nvws;
-       struct pipe_winsys *ws;
-       struct nouveau_device *dev = NULL;
-       struct pipe_screen *(*init)(struct pipe_winsys *,
-                                   struct nouveau_device *);
-       int ret;
-
-       ret = nouveau_device_open_existing(&dev, 0, fd, 0);
-       if (ret)
-               return NULL;
-
-       switch (dev->chipset & 0xf0) {
-       case 0x30:
-       case 0x40:
-       case 0x60:
-               init = nvfx_screen_create;
-               break;
-       case 0x50:
-       case 0x80:
-       case 0x90:
-       case 0xa0:
-               init = nv50_screen_create;
-               break;
-       default:
-               debug_printf("%s: unknown chipset nv%02x\n", __func__,
-                            dev->chipset);
-               return NULL;
-       }
-
-       nvws = CALLOC_STRUCT(nouveau_winsys);
-       if (!nvws) {
-               nouveau_device_close(&dev);
-               return NULL;
-       }
-       ws = &nvws->base;
-       ws->destroy = nouveau_drm_destroy_winsys;
-
-       nvws->pscreen = init(ws, dev);
-       if (!nvws->pscreen) {
-               ws->destroy(ws);
-               return NULL;
-       }
-
-       if (arg && arg->mode == DRM_CREATE_DRI1) {
-               struct nouveau_dri *nvdri = dri1->ddx_info;
-               enum pipe_format format;
-
-               if (nvdri->bpp == 16)
-                       format = PIPE_FORMAT_B5G6R5_UNORM;
-               else
-                       format = PIPE_FORMAT_B8G8R8A8_UNORM;
-
-               nvws->front = dri_surface_from_handle(api, nvws->pscreen,
-                                                     nvdri->front_offset,
-                                                     format, nvdri->width,
-                                                     nvdri->height,
-                                                     nvdri->front_pitch *
-                                                     (nvdri->bpp / 8));
-               if (!nvws->front) {
-                       debug_printf("%s: error referencing front buffer\n",
-                                    __func__);
-                       ws->destroy(ws);
-                       return NULL;
-               }
-
-               dri1->api = &nouveau_dri1_api;
-       }
-
-       return nvws->pscreen;
-}
-
-struct drm_api drm_api_hooks = {
-       .name = "nouveau",
-       .driver_name = "nouveau",
-       .create_screen = nouveau_drm_create_screen,
-};
-
-struct drm_api *
-drm_api_create() {
-       return &drm_api_hooks;
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
deleted file mode 100644 (file)
index a91aad7..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __NOUVEAU_DRM_API_H__
-#define __NOUVEAU_DRM_API_H__
-
-#include "state_tracker/drm_api.h"
-#include "state_tracker/dri1_api.h"
-
-#include "util/u_simple_screen.h"
-
-#include "nouveau_dri.h"
-
-struct nouveau_winsys {
-       struct pipe_winsys base;
-
-       struct pipe_screen *pscreen;
-
-       struct pipe_surface *front;
-};
-
-static INLINE struct nouveau_winsys *
-nouveau_winsys(struct pipe_winsys *ws)
-{
-       return (struct nouveau_winsys *)ws;
-}
-
-static INLINE struct nouveau_winsys *
-nouveau_winsys_screen(struct pipe_screen *pscreen)
-{
-       return nouveau_winsys(pscreen->winsys);
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile
deleted file mode 100644 (file)
index 47d1127..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = nouveau
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS = -ldrm_nouveau
-
-EGL_DRIVER_PIPES = \
-       $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
-       $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
-       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
-       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
-
-include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/nouveau/egl/dummy.c b/src/gallium/winsys/drm/nouveau/egl/dummy.c
deleted file mode 100644 (file)
index 3181d0b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/winsys/drm/nouveau/xorg/Makefile b/src/gallium/winsys/drm/nouveau/xorg/Makefile
deleted file mode 100644 (file)
index f7f6fe1..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-TARGET     = modesetting_drv.so
-CFILES     = $(wildcard ./*.c)
-OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
-TOP        = ../../../../../..
-
-include $(TOP)/configs/current
-
-INCLUDES = \
-       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
-       -I../gem \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/auxiliary \
-       -I$(TOP)/src/mesa \
-       -I$(TOP)/include \
-       -I$(TOP)/src/egl/main
-
-LIBS = \
-       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
-       $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
-       $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
-       $(TOP)/src/gallium/drivers/nv50/libnv50.a \
-       $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
-       $(GALLIUM_AUXILIARIES)
-
-DRIVER_DEFINES = \
-       -DHAVE_CONFIG_H
-
-
-#############################################
-
-
-
-all default: $(TARGET)
-
-$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS)
-       $(TOP)/bin/mklib -noprefix -o $@ \
-       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_nouveau
-
-clean:
-       rm -rf $(OBJECTS) $(TARGET)
-
-install:
-       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-
-
-##############################################
-
-
-.c.o:
-       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
-
-
-##############################################
-
-.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/nouveau/xorg/nouveau_xorg.c b/src/gallium/winsys/drm/nouveau/xorg/nouveau_xorg.c
deleted file mode 100644 (file)
index a669b30..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Author: Alan Hourihane <alanh@tungstengraphics.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- *
- */
-
-#include "../../../../state_trackers/xorg/xorg_winsys.h"
-
-static void nouveau_xorg_identify(int flags);
-static Bool nouveau_xorg_pci_probe(DriverPtr driver, int entity_num,
-                                  struct pci_device *device,
-                                  intptr_t match_data);
-
-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",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    0, 1, 0, /* major, minor, patch */
-    ABI_CLASS_VIDEODRV,
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_VIDEODRV,
-    {0, 0, 0, 0}
-};
-
-/*
- * Xorg driver exported structures
- */
-
-_X_EXPORT DriverRec modesetting = {
-    1,
-    "modesetting",
-    nouveau_xorg_identify,
-    NULL,
-    xorg_tracker_available_options,
-    NULL,
-    0,
-    NULL,
-    nouveau_xorg_device_match,
-    nouveau_xorg_pci_probe
-};
-
-static MODULESETUPPROTO(nouveau_xorg_setup);
-
-_X_EXPORT XF86ModuleData modesettingModuleData = {
-    &nouveau_xorg_version,
-    nouveau_xorg_setup,
-    NULL
-};
-
-/*
- * Xorg driver functions
- */
-
-static pointer
-nouveau_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = 0;
-
-    /* This module should be loaded only once, but check to be sure.
-     */
-    if (!setupDone) {
-       setupDone = 1;
-       xf86AddDriver(&modesetting, module, HaveDriverFuncs);
-
-       /*
-        * The return value must be non-NULL on success even though there
-        * is no TearDownProc.
-        */
-       return (pointer) 1;
-    } else {
-       if (errmaj)
-           *errmaj = LDR_ONCEONLY;
-       return NULL;
-    }
-}
-
-static void
-nouveau_xorg_identify(int flags)
-{
-    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
-                     nouveau_xorg_chipsets);
-}
-
-static Bool
-nouveau_xorg_pci_probe(DriverPtr driver,
-         int entity_num, struct pci_device *device, intptr_t match_data)
-{
-    ScrnInfoPtr scrn = NULL;
-    EntityInfoPtr entity;
-
-    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, nouveau_xorg_pci_devices,
-                              NULL, NULL, NULL, NULL, NULL);
-    if (scrn != NULL) {
-       scrn->driverVersion = 1;
-       scrn->driverName = "i915";
-       scrn->name = "modesetting";
-       scrn->Probe = NULL;
-
-       entity = xf86GetEntityInfo(entity_num);
-
-       /* Use all the functions from the xorg tracker */
-       xorg_tracker_set_functions(scrn);
-    }
-    return scrn != NULL;
-}
diff --git a/src/gallium/winsys/drm/radeon/Makefile b/src/gallium/winsys/drm/radeon/Makefile
deleted file mode 100644 (file)
index bacdf3d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/radeon/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
-
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
diff --git a/src/gallium/winsys/drm/radeon/SConscript b/src/gallium/winsys/drm/radeon/SConscript
deleted file mode 100644 (file)
index b2dfd50..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-Import('*')
-
-SConscript(['core/SConscript',])
-
-if 'mesa' in env['statetrackers']:
-
-    SConscript(['dri/SConscript'])
diff --git a/src/gallium/winsys/drm/radeon/core/Makefile b/src/gallium/winsys/drm/radeon/core/Makefile
deleted file mode 100644 (file)
index 13bbbf7..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = radeonwinsys
-
-C_SOURCES = \
-       radeon_drm_buffer.c \
-       radeon_drm.c \
-       radeon_r300.c
-
-LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/r300 \
-                  $(shell pkg-config libdrm --cflags-only-I)
-
-include ../../../../Makefile.template
-
-symlinks:
diff --git a/src/gallium/winsys/drm/radeon/core/SConscript b/src/gallium/winsys/drm/radeon/core/SConscript
deleted file mode 100644 (file)
index f4e9c39..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-radeon_sources = [
-    'radeon_buffer.c',
-    'radeon_drm.c',
-    'radeon_r300.c',
-]
-
-env.Append(CPPPATH = '#/src/gallium/drivers/r300')
-
-radeonwinsys = env.ConvenienceLibrary(
-    target ='radeonwinsys',
-    source = radeon_sources,
-)
-
-Export('radeonwinsys')
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
deleted file mode 100644 (file)
index 25b58b2..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright Â© 2008 Jérôme Glisse
- *             2009 Corbin Simpson
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- *      Jérôme Glisse <glisse@freedesktop.org>
- *      Corbin Simpson <MostAwesomeDude@gmail.com>
- */
-
-#include "radeon_buffer.h"
-#include "radeon_drm.h"
-
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-
-#include "radeon_bo_gem.h"
-#include <X11/Xutil.h>
-
-struct radeon_vl_context
-{
-    Display *display;
-    int screen;
-    Drawable drawable;
-};
-
-static const char *radeon_get_name(struct pipe_winsys *ws)
-{
-    return "Radeon/GEM+KMS";
-}
-
-static uint32_t radeon_domain_from_usage(unsigned usage)
-{
-    uint32_t domain = 0;
-
-    if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
-        domain |= RADEON_GEM_DOMAIN_VRAM;
-    }
-    if (usage & PIPE_BUFFER_USAGE_PIXEL) {
-        domain |= RADEON_GEM_DOMAIN_VRAM;
-    }
-    if (usage & PIPE_BUFFER_USAGE_VERTEX) {
-        domain |= RADEON_GEM_DOMAIN_GTT;
-    }
-    if (usage & PIPE_BUFFER_USAGE_INDEX) {
-        domain |= RADEON_GEM_DOMAIN_GTT;
-    }
-
-    return domain;
-}
-
-static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
-                                                unsigned alignment,
-                                                unsigned usage,
-                                                unsigned size)
-{
-    struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws;
-    struct radeon_pipe_buffer *radeon_buffer;
-    struct pb_desc desc;
-    uint32_t domain;
-
-    radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
-    if (radeon_buffer == NULL) {
-        return NULL;
-    }
-
-    pipe_reference_init(&radeon_buffer->base.reference, 1);
-    radeon_buffer->base.alignment = alignment;
-    radeon_buffer->base.usage = usage;
-    radeon_buffer->base.size = size;
-
-    if (usage & PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) {
-        /* Don't bother allocating a BO, as it'll never get to the card. */
-        desc.alignment = alignment;
-        desc.usage = usage;
-        radeon_buffer->pb = pb_malloc_buffer_create(size, &desc);
-        return &radeon_buffer->base;
-    }
-
-    domain = radeon_domain_from_usage(usage);
-
-    radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size,
-            alignment, domain, 0);
-    if (radeon_buffer->bo == NULL) {
-        FREE(radeon_buffer);
-        return NULL;
-    }
-    return &radeon_buffer->base;
-}
-
-static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
-                                                     void *ptr,
-                                                     unsigned bytes)
-{
-    struct radeon_pipe_buffer *radeon_buffer;
-
-    radeon_buffer =
-        (struct radeon_pipe_buffer*)radeon_buffer_create(ws, 0, 0, bytes);
-    if (radeon_buffer == NULL) {
-        return NULL;
-    }
-    radeon_bo_map(radeon_buffer->bo, 1);
-    memcpy(radeon_buffer->bo->ptr, ptr, bytes);
-    radeon_bo_unmap(radeon_buffer->bo);
-    return &radeon_buffer->base;
-}
-
-static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws,
-                                                        unsigned width,
-                                                        unsigned height,
-                                                        enum pipe_format format,
-                                                        unsigned usage,
-                                                        unsigned tex_usage,
-                                                        unsigned *stride)
-{
-    /* Radeons enjoy things in multiples of 32. */
-    /* XXX this can be 32 when POT */
-    const unsigned alignment = 64;
-    unsigned nblocksy, size;
-
-    nblocksy = util_format_get_nblocksy(format, height);
-    *stride = align(util_format_get_stride(format, width), alignment);
-    size = *stride * nblocksy;
-
-    return radeon_buffer_create(ws, 64, usage, size);
-}
-
-static void radeon_buffer_del(struct pipe_buffer *buffer)
-{
-    struct radeon_pipe_buffer *radeon_buffer =
-        (struct radeon_pipe_buffer*)buffer;
-
-    if (radeon_buffer->pb) {
-        pipe_reference_init(&radeon_buffer->pb->base.reference, 0);
-        pb_destroy(radeon_buffer->pb);
-    }
-
-    if (radeon_buffer->bo) {
-        radeon_bo_unref(radeon_buffer->bo);
-    }
-
-    FREE(radeon_buffer);
-}
-
-static void *radeon_buffer_map(struct pipe_winsys *ws,
-                               struct pipe_buffer *buffer,
-                               unsigned flags)
-{
-    struct radeon_winsys_priv *priv = ((struct radeon_winsys *)ws)->priv;
-    struct radeon_pipe_buffer *radeon_buffer =
-        (struct radeon_pipe_buffer*)buffer;
-    int write = 0;
-
-    if (radeon_buffer->pb) {
-        return pb_map(radeon_buffer->pb, flags);
-    }
-
-    if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
-        uint32_t domain;
-
-        if (radeon_bo_is_busy(radeon_buffer->bo, &domain))
-            return NULL;
-    }
-
-    if (radeon_bo_is_referenced_by_cs(radeon_buffer->bo, priv->cs)) {
-        priv->flush_cb(priv->flush_data);
-    }
-
-    if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
-        write = 1;
-    }
-
-    if (radeon_bo_map(radeon_buffer->bo, write)) {
-        return NULL;
-    }
-
-    return radeon_buffer->bo->ptr;
-}
-
-static void radeon_buffer_unmap(struct pipe_winsys *ws,
-                                struct pipe_buffer *buffer)
-{
-    struct radeon_pipe_buffer *radeon_buffer =
-        (struct radeon_pipe_buffer*)buffer;
-
-    if (radeon_buffer->pb) {
-        pb_unmap(radeon_buffer->pb);
-    } else {
-        radeon_bo_unmap(radeon_buffer->bo);
-    }
-}
-
-static boolean radeon_is_buffer_referenced(struct radeon_winsys *ws,
-                                           struct pipe_buffer *buffer)
-{
-    struct radeon_pipe_buffer *radeon_buffer =
-        (struct radeon_pipe_buffer*)buffer;
-    uint32_t domain;
-
-    /* Referenced by CS or HW. */
-    return radeon_bo_is_referenced_by_cs(radeon_buffer->bo, ws->priv->cs) ||
-           radeon_bo_is_busy(radeon_buffer->bo, &domain);
-}
-
-static void radeon_buffer_set_tiling(struct radeon_winsys *ws,
-                                     struct pipe_buffer *buffer,
-                                     uint32_t pitch,
-                                     boolean microtiled,
-                                     boolean macrotiled)
-{
-    struct radeon_winsys_priv *priv = ((struct radeon_winsys *)ws)->priv;
-    struct radeon_pipe_buffer *radeon_buffer =
-        (struct radeon_pipe_buffer*)buffer;
-    uint32_t flags = 0, old_flags, old_pitch;
-
-    if (microtiled) {
-        flags |= RADEON_BO_FLAGS_MICRO_TILE;
-    }
-    if (macrotiled) {
-        flags |= RADEON_BO_FLAGS_MACRO_TILE;
-    }
-
-    radeon_bo_get_tiling(radeon_buffer->bo, &old_flags, &old_pitch);
-
-    if (flags != old_flags || pitch != old_pitch) {
-        /* Tiling determines how DRM treats the buffer data.
-         * We must flush CS when changing it if the buffer is referenced. */
-        if (radeon_bo_is_referenced_by_cs(radeon_buffer->bo, priv->cs)) {
-            priv->flush_cb(priv->flush_data);
-        }
-
-        radeon_bo_set_tiling(radeon_buffer->bo, flags, pitch);
-    }
-}
-
-static void radeon_fence_reference(struct pipe_winsys *ws,
-                                   struct pipe_fence_handle **ptr,
-                                   struct pipe_fence_handle *pfence)
-{
-}
-
-static int radeon_fence_signalled(struct pipe_winsys *ws,
-                                  struct pipe_fence_handle *pfence,
-                                  unsigned flag)
-{
-    return 1;
-}
-
-static int radeon_fence_finish(struct pipe_winsys *ws,
-                               struct pipe_fence_handle *pfence,
-                               unsigned flag)
-{
-    return 0;
-}
-
-/* Create a buffer from a handle. */
-static struct pipe_buffer* radeon_buffer_from_handle(struct radeon_winsys *radeon_ws,
-                                                     struct pipe_screen *screen,
-                                                     struct winsys_handle *whandle,
-                                                     unsigned *stride)
-{
-    struct radeon_bo_manager* bom = radeon_ws->priv->bom;
-    struct radeon_pipe_buffer* radeon_buffer;
-    struct radeon_bo* bo = NULL;
-
-    bo = radeon_bo_open(bom, whandle->handle, 0, 0, 0, 0);
-    if (bo == NULL) {
-        return NULL;
-    }
-
-    radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
-    if (radeon_buffer == NULL) {
-        radeon_bo_unref(bo);
-        return NULL;
-    }
-
-    pipe_reference_init(&radeon_buffer->base.reference, 1);
-    radeon_buffer->base.screen = screen;
-    radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
-    radeon_buffer->bo = bo;
-
-    *stride = whandle->stride;
-
-    return &radeon_buffer->base;
-}
-
-static boolean radeon_buffer_get_handle(struct radeon_winsys *radeon_ws,
-                                        struct pipe_buffer *buffer,
-                                        unsigned stride,
-                                        struct winsys_handle *whandle)
-{
-    int retval, fd;
-    struct drm_gem_flink flink;
-    struct radeon_pipe_buffer* radeon_buffer;
-
-    radeon_buffer = (struct radeon_pipe_buffer*)buffer;
-
-
-    if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
-        if (!radeon_buffer->flinked) {
-            fd = radeon_ws->priv->fd;
-
-            flink.handle = radeon_buffer->bo->handle;
-
-            retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
-            if (retval) {
-                debug_printf("radeon: DRM_IOCTL_GEM_FLINK failed, error %d\n",
-                             retval);
-                return FALSE;
-            }
-
-            radeon_buffer->flink = flink.name;
-            radeon_buffer->flinked = TRUE;
-        }
-
-        whandle->handle = radeon_buffer->flink;
-    } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
-        whandle->handle = ((struct radeon_pipe_buffer*)buffer)->bo->handle;
-    }
-    whandle->stride = stride;
-
-    return TRUE;
-}
-
-struct radeon_winsys* radeon_pipe_winsys(int fd)
-{
-    struct radeon_winsys* radeon_ws;
-
-    radeon_ws = CALLOC_STRUCT(radeon_winsys);
-    if (radeon_ws == NULL) {
-        return NULL;
-    }
-
-    radeon_ws->priv = CALLOC_STRUCT(radeon_winsys_priv);
-    if (radeon_ws->priv == NULL) {
-        FREE(radeon_ws);
-        return NULL;
-    }
-
-    radeon_ws->priv->fd = fd;
-    radeon_ws->priv->bom = radeon_bo_manager_gem_ctor(fd);
-
-    radeon_ws->base.flush_frontbuffer = NULL; /* overriden by co-state tracker */
-
-    radeon_ws->base.buffer_create = radeon_buffer_create;
-    radeon_ws->base.user_buffer_create = radeon_buffer_user_create;
-    radeon_ws->base.surface_buffer_create = radeon_surface_buffer_create;
-    radeon_ws->base.buffer_map = radeon_buffer_map;
-    radeon_ws->base.buffer_unmap = radeon_buffer_unmap;
-    radeon_ws->base.buffer_destroy = radeon_buffer_del;
-
-    radeon_ws->base.fence_reference = radeon_fence_reference;
-    radeon_ws->base.fence_signalled = radeon_fence_signalled;
-    radeon_ws->base.fence_finish = radeon_fence_finish;
-
-    radeon_ws->base.get_name = radeon_get_name;
-
-    radeon_ws->buffer_set_tiling = radeon_buffer_set_tiling;
-    radeon_ws->buffer_from_handle = radeon_buffer_from_handle;
-    radeon_ws->buffer_get_handle = radeon_buffer_get_handle;
-
-    radeon_ws->is_buffer_referenced = radeon_is_buffer_referenced;
-
-    return radeon_ws;
-}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
deleted file mode 100644 (file)
index e1fcfcf..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright Â© 2008 Jérôme Glisse
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- *      Jérôme Glisse <glisse@freedesktop.org>
- */
-#ifndef RADEON_BUFFER_H
-#define RADEON_BUFFER_H
-
-#include <stdio.h>
-
-#include "pipe/p_defines.h"
-#include "util/u_inlines.h"
-
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-
-#include "radeon_bo.h"
-#include "radeon_cs.h"
-
-#include "radeon_winsys.h"
-
-
-#define RADEON_MAX_BOS 24
-
-static INLINE struct pb_buffer *
-radeon_pb_buffer(struct r300_winsys_buffer *buffer)
-{
-    return (struct pb_buffer *)buffer;
-}
-
-static INLINE struct r300_winsys_buffer *
-radeon_libdrm_winsys_buffer(struct pb_buffer *buffer)
-{
-    return (struct r300_winsys_buffer *)buffer;
-}
-
-struct pb_manager *
-radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws);
-
-boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf,
-                                    uint32_t rd, uint32_t wd);
-
-
-void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
-                                  uint32_t rd, uint32_t wd,
-                                  uint32_t flags);
-
-struct radeon_libdrm_winsys* radeon_pipe_winsys(int fd);
-
-struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
-                                                             uint32_t handle);
-
-void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch);
-
-void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr);
-
-boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
-                                    struct winsys_handle *whandle);
-
-boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf);
-#endif
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
deleted file mode 100644 (file)
index d70173e..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright Â© 2009 Corbin Simpson
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- *      Corbin Simpson <MostAwesomeDude@gmail.com>
- *      Joakim Sindholt <opensource@zhasha.com>
- */
-
-#include "radeon_drm.h"
-#include "radeon_r300.h"
-#include "radeon_buffer.h"
-
-#include "r300_winsys.h"
-#include "trace/tr_drm.h"
-
-#include "util/u_memory.h"
-
-#include "xf86drm.h"
-#include <sys/ioctl.h>
-
-static struct radeon_libdrm_winsys *
-radeon_winsys_create(int fd)
-{
-    struct radeon_libdrm_winsys *rws;
-
-    rws = CALLOC_STRUCT(radeon_libdrm_winsys);
-    if (rws == NULL) {
-        return NULL;
-    }
-
-    rws->fd = fd;
-    return rws;
-}
-
-/* Helper function to do the ioctls needed for setup and init. */
-static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys)
-{
-    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.
-     * This is also for some features.
-     *
-     * Then, the PCI ID. This is essential and should return usable numbers
-     * for all Radeons. If this fails, we probably got handed an FD for some
-     * non-Radeon card.
-     *
-     * The GB and Z pipe requests should always succeed, but they might not
-     * return sensical values for all chipsets, but that's alright because
-     * the pipe drivers already know that.
-     *
-     * The GEM info is actually bogus on the kernel side, as well as our side
-     * (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because
-     * we don't actually use the info for anything yet. */
-
-    version = drmGetVersion(fd);
-    if (version->version_major != 2) {
-        fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
-                "only compatible with 2.x.x\n", __FUNCTION__,
-                version->version_major, version->version_minor,
-                version->version_patchlevel);
-        drmFreeVersion(version);
-        exit(1);
-    }
-
-    info.request = RADEON_INFO_DEVICE_ID;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
-    if (retval) {
-        fprintf(stderr, "%s: Failed to get PCI ID, "
-                "error number %d\n", __FUNCTION__, retval);
-        exit(1);
-    }
-    winsys->pci_id = target;
-
-    info.request = RADEON_INFO_NUM_GB_PIPES;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
-    if (retval) {
-        fprintf(stderr, "%s: Failed to get GB pipe count, "
-                "error number %d\n", __FUNCTION__, retval);
-        exit(1);
-    }
-    winsys->gb_pipes = target;
-
-    info.request = RADEON_INFO_NUM_Z_PIPES;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
-    if (retval) {
-        fprintf(stderr, "%s: Failed to get Z pipe count, "
-                "error number %d\n", __FUNCTION__, retval);
-        exit(1);
-    }
-    winsys->z_pipes = target;
-
-    retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO,
-            &gem_info, sizeof(gem_info));
-    if (retval) {
-        fprintf(stderr, "%s: Failed to get MM info, error number %d\n",
-                __FUNCTION__, retval);
-        exit(1);
-    }
-    winsys->gart_size = gem_info.gart_size;
-    winsys->vram_size = gem_info.vram_size;
-
-    debug_printf("radeon: Successfully grabbed chipset info from kernel!\n"
-                 "radeon: DRM version: %d.%d.%d ID: 0x%04x GB: %d Z: %d\n"
-                 "radeon: GART size: %d MB VRAM size: %d MB\n",
-                 version->version_major, version->version_minor,
-                 version->version_patchlevel, winsys->pci_id,
-                 winsys->gb_pipes, winsys->z_pipes,
-                 winsys->gart_size / 1024 / 1024,
-                 winsys->vram_size / 1024 / 1024);
-
-    drmFreeVersion(version);
-}
-
-/* Create a pipe_screen. */
-struct pipe_screen* radeon_create_screen(struct drm_api* api,
-                                         int drmFB,
-                                         struct drm_create_screen_arg *arg)
-{
-    struct radeon_libdrm_winsys* rws; 
-    boolean ret;
-
-    rws = radeon_winsys_create(drmFB);
-    if (!rws)
-       return NULL;
-
-    do_ioctls(drmFB, rws);
-
-    /* The state tracker can organize a softpipe fallback if no hw
-     * driver is found.
-     */
-    if (is_r3xx(rws->pci_id)) {
-        ret = radeon_setup_winsys(drmFB, rws);
-       if (ret == FALSE)
-           goto fail;
-        return r300_create_screen(&rws->base);
-    }
-
-fail:
-    FREE(rws);
-    return NULL;
-}
-
-static void radeon_drm_api_destroy(struct drm_api *api)
-{
-    return;
-}
-
-struct drm_api drm_api_hooks = {
-    .name = "radeon",
-    .driver_name = "radeon",
-    .create_screen = radeon_create_screen,
-    .destroy = radeon_drm_api_destroy,
-};
-
-struct drm_api* drm_api_create()
-{
-#ifdef DEBUG
-    return trace_drm_create(&drm_api_hooks);
-#else
-    return &drm_api_hooks;
-#endif
-}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
deleted file mode 100644 (file)
index 2dc077c..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* 
- * Copyright Â© 2009 Corbin Simpson
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- *      Corbin Simpson <MostAwesomeDude@gmail.com>
- */
-#ifndef RADEON_DRM_H
-#define RADEON_DRM_H
-
-#include "state_tracker/drm_api.h"
-
-
-struct pipe_screen* radeon_create_screen(struct drm_api* api,
-                                         int drmFB,
-                                        struct drm_create_screen_arg *arg);
-
-boolean radeon_buffer_from_texture(struct drm_api* api,
-                                   struct pipe_screen* screen,
-                                   struct pipe_texture* texture,
-                                   struct pipe_buffer** buffer,
-                                   unsigned* stride);
-
-boolean radeon_handle_from_buffer(struct drm_api* api,
-                                  struct pipe_screen* screen,
-                                  struct pipe_buffer* buffer,
-                                  unsigned* handle);
-
-boolean radeon_global_handle_from_buffer(struct drm_api* api,
-                                         struct pipe_screen* screen,
-                                         struct pipe_buffer* buffer,
-                                         unsigned* handle);
-
-void radeon_destroy_drm_api(struct drm_api* api);
-
-/* Guess at whether this chipset should use r300g.
- *
- * I believe that this check is valid, but I haven't been exhaustive. */
-static INLINE boolean is_r3xx(int pciid)
-{
-    return (pciid > 0x3150) && (pciid < 0x796f);
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c
deleted file mode 100644 (file)
index cc56a2b..0000000
+++ /dev/null
@@ -1,368 +0,0 @@
-
-#include <sys/ioctl.h>
-#include "radeon_drm.h"
-#include "radeon_bo_gem.h"
-#include "radeon_cs_gem.h"
-#include "radeon_buffer.h"
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_simple_list.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-
-#include "radeon_winsys.h"
-struct radeon_drm_bufmgr;
-
-struct radeon_drm_buffer {
-    struct pb_buffer base;
-    struct radeon_drm_bufmgr *mgr;
-
-    struct radeon_bo *bo;
-
-    boolean flinked;
-    uint32_t flink;
-
-    boolean mapped;
-    struct radeon_drm_buffer *next, *prev;
-};
-
-extern const struct pb_vtbl radeon_drm_buffer_vtbl;
-
-
-static INLINE struct radeon_drm_buffer *
-radeon_drm_buffer(struct pb_buffer *buf)
-{
-    assert(buf);
-    assert(buf->vtbl == &radeon_drm_buffer_vtbl);
-    return (struct radeon_drm_buffer *)buf;
-}
-
-struct radeon_drm_bufmgr {
-    struct pb_manager base;
-    struct radeon_libdrm_winsys *rws;
-    struct radeon_drm_buffer buffer_map_list;
-};
-
-static INLINE struct radeon_drm_bufmgr *
-radeon_drm_bufmgr(struct pb_manager *mgr)
-{
-    assert(mgr);
-    return (struct radeon_drm_bufmgr *)mgr;
-}
-
-static void
-radeon_drm_buffer_destroy(struct pb_buffer *_buf)
-{
-    struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
-
-    if (buf->mapped) {
-       remove_from_list(buf);
-       radeon_bo_unmap(buf->bo);
-       buf->mapped = false;
-    }
-    radeon_bo_unref(buf->bo);
-
-    FREE(buf);
-}
-
-static void *
-radeon_drm_buffer_map(struct pb_buffer *_buf,
-                     unsigned flags)
-{
-    struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
-    int write;
-
-    if (buf->mapped)
-       return buf->bo->ptr;
-    
-    if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
-        uint32_t domain;
-
-        if (radeon_bo_is_busy(buf->bo, &domain))
-            return NULL;
-    }
-
-
-    if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) {
-        buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data);
-    }
-
-    if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
-        write = 1;
-    }
-
-    if (radeon_bo_map(buf->bo, write)) {
-        return NULL;
-    }
-    buf->mapped = true;
-    insert_at_tail(&buf->mgr->buffer_map_list, buf);
-    return buf->bo->ptr;
-}
-
-static void
-radeon_drm_buffer_unmap(struct pb_buffer *_buf)
-{
-    (void)_buf;
-}
-
-static void
-radeon_drm_buffer_get_base_buffer(struct pb_buffer *buf,
-                                 struct pb_buffer **base_buf,
-                                 unsigned *offset)
-{
-    *base_buf = buf;
-    *offset = 0;
-}
-
-
-static enum pipe_error
-radeon_drm_buffer_validate(struct pb_buffer *_buf, 
-                          struct pb_validate *vl,
-                          unsigned flags)
-{
-   /* Always pinned */
-   return PIPE_OK;
-}
-
-static void
-radeon_drm_buffer_fence(struct pb_buffer *buf,
-                       struct pipe_fence_handle *fence)
-{
-}
-
-const struct pb_vtbl radeon_drm_buffer_vtbl = {
-    radeon_drm_buffer_destroy,
-    radeon_drm_buffer_map,
-    radeon_drm_buffer_unmap,
-    radeon_drm_buffer_validate,
-    radeon_drm_buffer_fence,
-    radeon_drm_buffer_get_base_buffer,
-};
-
-
-static uint32_t radeon_domain_from_usage(unsigned usage)
-{
-    uint32_t domain = 0;
-
-    if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
-        domain |= RADEON_GEM_DOMAIN_VRAM;
-    }
-    if (usage & PIPE_BUFFER_USAGE_PIXEL) {
-        domain |= RADEON_GEM_DOMAIN_VRAM;
-    }
-    if (usage & PIPE_BUFFER_USAGE_VERTEX) {
-        domain |= RADEON_GEM_DOMAIN_GTT;
-    }
-    if (usage & PIPE_BUFFER_USAGE_INDEX) {
-        domain |= RADEON_GEM_DOMAIN_GTT;
-    }
-
-    return domain;
-}
-
-struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
-                                                             uint32_t handle)
-{
-    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
-    struct radeon_libdrm_winsys *rws = mgr->rws;
-    struct radeon_drm_buffer *buf;
-    struct radeon_bo *bo;
-
-    bo = radeon_bo_open(rws->bom, handle, 0,
-                       0, 0, 0);
-    if (bo == NULL)
-       return NULL;
-
-    buf = CALLOC_STRUCT(radeon_drm_buffer);
-    if (!buf) {
-       radeon_bo_unref(bo);
-       return NULL;
-    }
-
-    make_empty_list(buf);
-
-    pipe_reference_init(&buf->base.base.reference, 1);
-    buf->base.base.alignment = 0;
-    buf->base.base.usage = PIPE_BUFFER_USAGE_PIXEL;
-    buf->base.base.size = 0;
-    buf->base.vtbl = &radeon_drm_buffer_vtbl;
-    buf->mgr = mgr;
-
-    buf->bo = bo;
-
-    return &buf->base;
-}
-
-static struct pb_buffer *
-radeon_drm_bufmgr_create_buffer(struct pb_manager *_mgr,
-                               pb_size size,
-                               const struct pb_desc *desc)
-{
-    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
-    struct radeon_libdrm_winsys *rws = mgr->rws;
-    struct radeon_drm_buffer *buf;
-    uint32_t domain;
-
-    buf = CALLOC_STRUCT(radeon_drm_buffer);
-    if (!buf)
-       goto error1;
-
-    pipe_reference_init(&buf->base.base.reference, 1);
-    buf->base.base.alignment = desc->alignment;
-    buf->base.base.usage = desc->usage;
-    buf->base.base.size = size;
-    buf->base.vtbl = &radeon_drm_buffer_vtbl;
-    buf->mgr = mgr;
-
-    make_empty_list(buf);
-    domain = radeon_domain_from_usage(desc->usage);
-    buf->bo = radeon_bo_open(rws->bom, 0, size,
-                            desc->alignment, domain, 0);
-    if (buf->bo == NULL)
-       goto error2;
-
-    return &buf->base;
-
- error2:
-    FREE(buf);
- error1:
-    return NULL; 
-}
-
-static void
-radeon_drm_bufmgr_flush(struct pb_manager *mgr)
-{
-    /* NOP */
-}
-
-static void
-radeon_drm_bufmgr_destroy(struct pb_manager *_mgr)
-{
-    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
-    FREE(mgr);
-}
-
-struct pb_manager *
-radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws)
-{
-    struct radeon_drm_bufmgr *mgr;
-
-    mgr = CALLOC_STRUCT(radeon_drm_bufmgr);
-    if (!mgr)
-       return NULL;
-
-    mgr->base.destroy = radeon_drm_bufmgr_destroy;
-    mgr->base.create_buffer = radeon_drm_bufmgr_create_buffer;
-    mgr->base.flush = radeon_drm_bufmgr_flush;
-
-    mgr->rws = rws;
-    make_empty_list(&mgr->buffer_map_list);
-    return &mgr->base;
-}
-
-static struct radeon_drm_buffer *get_drm_buffer(struct pb_buffer *_buf)
-{
-    struct radeon_drm_buffer *buf;
-    if (_buf->vtbl == &radeon_drm_buffer_vtbl) {
-        buf = radeon_drm_buffer(_buf);
-    } else {
-       struct pb_buffer *base_buf;
-       pb_size offset;
-       pb_get_base_buffer(_buf, &base_buf, &offset);
-
-       buf = radeon_drm_buffer(base_buf);
-    }
-    return buf;
-}
-
-boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
-                                    struct winsys_handle *whandle)
-{
-    int retval, fd;
-    struct drm_gem_flink flink;
-    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
-    if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
-       if (!buf->flinked) {
-           fd = buf->mgr->rws->fd;
-           flink.handle = buf->bo->handle;
-
-           retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
-           if (retval) {
-               return false;
-           }
-
-           buf->flinked = TRUE;
-           buf->flink = flink.name;
-       }
-       whandle->handle = buf->flink;
-    } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
-       whandle->handle = buf->bo->handle;
-    }
-    return TRUE;
-}
-                                          
-
-void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch)
-{
-    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
-    uint32_t flags = 0;
-
-    if (microtiled)
-       flags |= RADEON_BO_FLAGS_MICRO_TILE;
-    if (macrotiled)
-       flags |= RADEON_BO_FLAGS_MACRO_TILE;
-
-    radeon_bo_set_tiling(buf->bo, flags, pitch);
-
-}
-
-boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf,
-                                    uint32_t rd, uint32_t wd)
-{
-    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
-    radeon_cs_space_add_persistent_bo(buf->mgr->rws->cs, buf->bo,
-                                         rd, wd);
-    return true;
-}
-
-void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
-                                  uint32_t rd, uint32_t wd,
-                                  uint32_t flags)
-{
-    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
-    int retval;
-
-    retval = radeon_cs_write_reloc(buf->mgr->rws->cs,
-                                  buf->bo, rd, wd, flags);
-    if (retval) {
-        debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
-                    buf, rd, wd, flags);
-    }
-}
-
-boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf)
-{
-    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
-    uint32_t domain;
-
-    return (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs) ||
-           radeon_bo_is_busy(buf->bo, &domain));
-}
-                                           
-
-void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr)
-{
-    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
-    struct radeon_drm_buffer *rpb, *t_rpb;
-
-    foreach_s(rpb, t_rpb, &mgr->buffer_map_list) {
-       rpb->mapped = 0;
-       radeon_bo_unmap(rpb->bo);
-       remove_from_list(rpb);
-    }
-
-    make_empty_list(&mgr->buffer_map_list);
-
-    
-}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
deleted file mode 100644 (file)
index 5b82a77..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#include "radeon_r300.h"
-#include "radeon_buffer.h"
-
-#include "radeon_bo_gem.h"
-#include "radeon_cs_gem.h"
-#include "state_tracker/drm_api.h"
-
-static struct r300_winsys_buffer *
-radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws,
-                                unsigned alignment,
-                                unsigned usage,
-                                unsigned size)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    struct pb_desc desc;
-    struct pb_manager *provider;
-    struct pb_buffer *buffer;
-
-    memset(&desc, 0, sizeof(desc));
-    desc.alignment = alignment;
-    desc.usage = usage;
-
-    if (usage & PIPE_BUFFER_USAGE_CONSTANT)
-        provider = ws->mman;
-    else
-        provider = ws->kman;
-    buffer = provider->create_buffer(provider, size, &desc);
-    if (!buffer)
-       return NULL;
-
-    return radeon_libdrm_winsys_buffer(buffer);
-}
-
-static void radeon_r300_winsys_buffer_destroy(struct r300_winsys_buffer *buf)
-{
-    struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
-    pb_destroy(_buf);
-}
-static void radeon_r300_winsys_buffer_set_tiling(struct r300_winsys_screen *rws,
-                                                 struct r300_winsys_buffer *buf,
-                                                 uint32_t pitch,
-                                                 boolean microtiled,
-                                                 boolean macrotiled)
-{
-    struct pb_buffer *_buf = radeon_pb_buffer(buf);
-    radeon_drm_bufmgr_set_tiling(_buf, microtiled, macrotiled, pitch);
-}
-
-static void *radeon_r300_winsys_buffer_map(struct r300_winsys_screen *ws,
-                                          struct r300_winsys_buffer *buf,
-                                          unsigned usage)
-{
-    struct pb_buffer *_buf = radeon_pb_buffer(buf);
-    
-    return pb_map(_buf, usage);
-}
-
-static void radeon_r300_winsys_buffer_unmap(struct r300_winsys_screen *ws,
-                                           struct r300_winsys_buffer *buf)
-{
-    struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
-    pb_unmap(_buf);
-}
-
-static void radeon_r300_winsys_buffer_reference(struct r300_winsys_screen *rws,
-                                               struct r300_winsys_buffer **pdst,
-                                               struct r300_winsys_buffer *src)
-{
-    struct pb_buffer *_src = radeon_pb_buffer(src);
-    struct pb_buffer *_dst = radeon_pb_buffer(*pdst);
-
-    pb_reference(&_dst, _src);
-
-    *pdst = radeon_libdrm_winsys_buffer(_dst);
-}
-
-static boolean radeon_r300_winsys_is_buffer_referenced(struct r300_winsys_screen *rws,
-                                                      struct r300_winsys_buffer *buf)
-{
-    struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
-    return radeon_drm_bufmgr_is_buffer_referenced(_buf);
-}
-
-static struct r300_winsys_buffer *radeon_r300_winsys_buffer_from_handle(struct r300_winsys_screen *rws,
-                                                                       struct pipe_screen *screen,
-                                                                       struct winsys_handle *whandle,
-                                                                       unsigned *stride)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    struct pb_buffer *_buf;
-
-    _buf = radeon_drm_bufmgr_create_buffer_from_handle(ws->kman, whandle->handle);
-    *stride = whandle->stride;
-    return radeon_libdrm_winsys_buffer(_buf);
-}
-
-static boolean radeon_r300_winsys_buffer_get_handle(struct r300_winsys_screen *rws,
-                                                   struct r300_winsys_buffer *buffer,
-                                                   unsigned stride,
-                                                   struct winsys_handle *whandle)
-{
-    struct pb_buffer *_buf = radeon_pb_buffer(buffer);
-    boolean ret;
-    ret = radeon_drm_bufmgr_get_handle(_buf, whandle);
-    if (ret)
-       whandle->stride = stride;
-    return ret;
-}
-
-static void radeon_set_flush_cb(struct r300_winsys_screen *rws,
-                                void (*flush_cb)(void *),
-                                void *data)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    ws->flush_cb = flush_cb;
-    ws->flush_data = data;
-    radeon_cs_space_set_flush(ws->cs, flush_cb, data);
-}
-
-static boolean radeon_add_buffer(struct r300_winsys_screen *rws,
-                                 struct r300_winsys_buffer *buf,
-                                 uint32_t rd,
-                                 uint32_t wd)
-{
-    struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
-    return radeon_drm_bufmgr_add_buffer(_buf, rd, wd);
-}
-
-static boolean radeon_validate(struct r300_winsys_screen *rws)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    if (radeon_cs_space_check(ws->cs) < 0) {
-        return FALSE;
-    }
-
-    /* Things are fine, we can proceed as normal. */
-    return TRUE;
-}
-
-static boolean radeon_check_cs(struct r300_winsys_screen *rws, int size)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    struct radeon_cs *cs = ws->cs;
-
-    return radeon_validate(rws) && cs->cdw + size <= cs->ndw;
-}
-
-static void radeon_begin_cs(struct r300_winsys_screen *rws,
-                            int size,
-                            const char* file,
-                            const char* function,
-                            int line)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    radeon_cs_begin(ws->cs, size, file, function, line);
-}
-
-static void radeon_write_cs_dword(struct r300_winsys_screen *rws,
-                                  uint32_t dword)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    radeon_cs_write_dword(ws->cs, dword);
-}
-
-static void radeon_write_cs_reloc(struct r300_winsys_screen *rws,
-                                  struct r300_winsys_buffer *buf,
-                                  uint32_t rd,
-                                  uint32_t wd,
-                                  uint32_t flags)
-{
-    struct pb_buffer *_buf = radeon_pb_buffer(buf);
-    radeon_drm_bufmgr_write_reloc(_buf, rd, wd, flags);
-}
-
-static void radeon_reset_bos(struct r300_winsys_screen *rws)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    radeon_cs_space_reset_bos(ws->cs);
-}
-
-static void radeon_end_cs(struct r300_winsys_screen *rws,
-                          const char* file,
-                          const char* function,
-                          int line)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    radeon_cs_end(ws->cs, file, function, line);
-}
-
-static void radeon_flush_cs(struct r300_winsys_screen *rws)
-{
-    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
-    int retval;
-
-    /* Don't flush a zero-sized CS. */
-    if (!ws->cs->cdw) {
-        return;
-    }
-
-    radeon_drm_bufmgr_flush_maps(ws->kman);
-    /* Emit the CS. */
-    retval = radeon_cs_emit(ws->cs);
-    if (retval) {
-        debug_printf("radeon: Bad CS, dumping...\n");
-        radeon_cs_print(ws->cs, stderr);
-    }
-
-    /* Reset CS.
-     * Someday, when we care about performance, we should really find a way
-     * to rotate between two or three CS objects so that the GPU can be
-     * spinning through one CS while another one is being filled. */
-    radeon_cs_erase(ws->cs);
-}
-
-static uint32_t radeon_get_value(struct r300_winsys_screen *rws,
-                            enum r300_value_id id)
-{
-    struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
-
-    switch(id) {
-    case R300_VID_PCI_ID:
-       return ws->pci_id;
-    case R300_VID_GB_PIPES:
-       return ws->gb_pipes;
-    case R300_VID_Z_PIPES:
-       return ws->z_pipes;
-    }
-    return 0;
-}
-
-static void
-radeon_winsys_destroy(struct r300_winsys_screen *rws)
-{
-    struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
-    radeon_cs_destroy(ws->cs);
-
-    ws->kman->destroy(ws->kman);
-    ws->mman->destroy(ws->mman);
-
-    radeon_bo_manager_gem_dtor(ws->bom);
-    radeon_cs_manager_gem_dtor(ws->csm);
-}
-
-boolean
-radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws)
-{
-    
-    ws->csm = radeon_cs_manager_gem_ctor(fd);
-    if (!ws->csm)
-       goto fail;
-    ws->bom = radeon_bo_manager_gem_ctor(fd);
-    if (!ws->bom)
-       goto fail;
-    ws->kman = radeon_drm_bufmgr_create(ws);
-    if (!ws->kman)
-       goto fail;
-
-    ws->mman = pb_malloc_bufmgr_create();
-    if (!ws->mman)
-       goto fail;
-
-    /* Size limit on IBs is 64 kibibytes. */
-    ws->cs = radeon_cs_create(ws->csm, 1024 * 64 / 4);
-    if (!ws->cs)
-       goto fail;
-    radeon_cs_set_limit(ws->cs,
-            RADEON_GEM_DOMAIN_GTT, ws->gart_size);
-    radeon_cs_set_limit(ws->cs,
-            RADEON_GEM_DOMAIN_VRAM, ws->vram_size);
-
-    ws->base.add_buffer = radeon_add_buffer;
-    ws->base.validate = radeon_validate;
-    ws->base.destroy = radeon_winsys_destroy;
-    ws->base.check_cs = radeon_check_cs;
-    ws->base.begin_cs = radeon_begin_cs;
-    ws->base.write_cs_dword = radeon_write_cs_dword;
-    ws->base.write_cs_reloc = radeon_write_cs_reloc;
-    ws->base.end_cs = radeon_end_cs;
-    ws->base.flush_cs = radeon_flush_cs;
-    ws->base.reset_bos = radeon_reset_bos;
-    ws->base.set_flush_cb = radeon_set_flush_cb;
-    ws->base.get_value = radeon_get_value;
-
-    ws->base.buffer_create = radeon_r300_winsys_buffer_create;
-    ws->base.buffer_destroy = radeon_r300_winsys_buffer_destroy;
-    ws->base.buffer_set_tiling = radeon_r300_winsys_buffer_set_tiling;
-    ws->base.buffer_map = radeon_r300_winsys_buffer_map;
-    ws->base.buffer_unmap = radeon_r300_winsys_buffer_unmap;
-    ws->base.buffer_reference = radeon_r300_winsys_buffer_reference;
-    ws->base.buffer_from_handle = radeon_r300_winsys_buffer_from_handle;
-    ws->base.buffer_get_handle = radeon_r300_winsys_buffer_get_handle;
-    ws->base.is_buffer_referenced = radeon_r300_winsys_is_buffer_referenced;
-    return TRUE;
-
-fail:
-    if (ws->csm)
-       radeon_cs_manager_gem_dtor(ws->csm);
-
-    if (ws->bom)
-       radeon_bo_manager_gem_dtor(ws->bom);
-
-
-    if (ws->kman)
-       ws->kman->destroy(ws->kman);
-    if (ws->mman)
-       ws->mman->destroy(ws->mman);
-
-    if (ws->cs)
-       radeon_cs_destroy(ws->cs);
-    return FALSE;
-}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h
deleted file mode 100644 (file)
index 2703464..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#ifndef RADEON_R300_H
-#define RADEON_R300_H
-
-#include "radeon_winsys.h"
-
-boolean radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* winsys);
-
-#endif /* RADEON_R300_H */
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
deleted file mode 100644 (file)
index 16cc701..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright Â© 2009 Corbin Simpson
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- *      Corbin Simpson <MostAwesomeDude@gmail.com>
- */
-#ifndef RADEON_WINSYS_H
-#define RADEON_WINSYS_H
-
-#include "r300_winsys.h"
-
-struct radeon_libdrm_winsys {
-    /* Parent class. */
-    struct r300_winsys_screen base;
-
-    struct pb_manager *kman;
-
-    struct pb_manager *mman;
-
-    /* PCI ID */
-    uint32_t pci_id;
-
-    /* GB pipe count */
-    uint32_t gb_pipes;
-
-    /* Z pipe count (rv530 only) */
-    uint32_t z_pipes;
-
-    /* GART size. */
-    uint32_t gart_size;
-
-    /* VRAM size. */
-    uint32_t vram_size;
-
-    /* DRM FD */
-    int fd;
-
-    /* Radeon BO manager. */
-    struct radeon_bo_manager *bom;
-
-    /* Radeon CS manager. */
-    struct radeon_cs_manager *csm;
-
-    /* Current CS. */
-    struct radeon_cs *cs;
-
-    /* Flush CB */
-    void (*flush_cb)(void *);
-    void *flush_data;
-};
-
-static INLINE struct radeon_libdrm_winsys *
-radeon_winsys_screen(struct r300_winsys_screen *base)
-{
-  return (struct radeon_libdrm_winsys *)base;
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile
deleted file mode 100644 (file)
index d75f7dd..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = radeong_dri.so
-
-PIPE_DRIVERS = \
-       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
-       $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/r300/libr300.a
-
-C_SOURCES = \
-       $(COMMON_GALLIUM_SOURCES) \
-       $(DRIVER_SOURCES)
-
-ASM_SOURCES = 
-
-include ../../Makefile.template
-
-DRI_LIB_DEPS += -ldrm_radeon
-
-symlinks:
diff --git a/src/gallium/winsys/drm/radeon/dri/SConscript b/src/gallium/winsys/drm/radeon/dri/SConscript
deleted file mode 100644 (file)
index c4989d1..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-env.ParseConfig('pkg-config --cflags --libs libdrm_radeon')
-
-drivers = [
-    trace,
-    softpipe,
-    r300
-]
-
-env.SharedLibrary(
-    target ='radeon_dri.so',
-    source = COMMON_GALLIUM_SOURCES,
-    LIBS = st_dri + radeonwinsys + mesa + drivers + gallium + env['LIBS'],
-)
diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile
deleted file mode 100644 (file)
index cd4f9b2..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = radeon
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS = -ldrm_radeon
-
-EGL_DRIVER_PIPES = \
-       $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/r300/libr300.a
-
-include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/radeon/egl/dummy.c b/src/gallium/winsys/drm/radeon/egl/dummy.c
deleted file mode 100644 (file)
index 3181d0b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/winsys/drm/radeon/xorg/Makefile b/src/gallium/winsys/drm/radeon/xorg/Makefile
deleted file mode 100644 (file)
index 0eb1b39..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-TOP        = ../../../../../..
-
-
-GALLIUMDIR = $(TOP)/src/gallium
-
-TARGET     = radeong_drv.so
-
-CFILES     = $(wildcard ./*.c)
-
-include ${TOP}/configs/current
-
-OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
-
-CFLAGS = -DHAVE_CONFIG_H \
-         -g -Wall -Wimplicit-function-declaration -fPIC \
-         $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
-         -I${GALLIUMDIR}/include \
-         -I${GALLIUMDIR}/drivers \
-         -I${GALLIUMDIR}/auxiliary \
-         -I${TOP}/src/mesa \
-         -I$(TOP)/include \
-         -I$(TOP)/src/egl/main
-
-LIBS = \
-       $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a \
-       $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \
-       $(TOP)/src/gallium/drivers/r300/libr300.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(GALLIUM_AUXILIARIES)
-
-TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
-#############################################
-
-all default: $(TARGET) $(TARGET_STAGING)
-
-$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS)
-       $(TOP)/bin/mklib -noprefix -o $@ \
-       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_radeon
-
-$(TOP)/$(LIB_DIR)/gallium:
-       mkdir -p $@
-
-$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
-       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
-
-clean:
-       rm -rf $(OBJECTS) $(TARGET)
-
-install:
-       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-
-.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c
deleted file mode 100644 (file)
index bb76cc0..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Author: Alan Hourihane <alanh@tungstengraphics.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- * Author: Corbin Simpson <MostAwesomedude@gmail.com>
- *
- */
-
-#include "../../../../state_trackers/xorg/xorg_winsys.h"
-
-static void radeon_xorg_identify(int flags);
-static Bool radeon_xorg_pci_probe(DriverPtr driver,
-                                int entity_num,
-                                struct pci_device *device,
-                                intptr_t match_data);
-
-static const struct pci_id_match radeon_xorg_device_match[] = {
-    {0x1002, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
-    {0, 0, 0},
-};
-
-static SymTabRec radeon_xorg_chipsets[] = {
-    {PCI_MATCH_ANY, "ATI/AMD Radeon Graphics Chipset"},
-    {-1, NULL}
-};
-
-static PciChipsets radeon_xorg_pci_devices[] = {
-    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
-    {-1, -1, NULL}
-};
-
-static XF86ModuleVersionInfo radeon_xorg_version = {
-    "radeong",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    0, 1, 0, /* major, minor, patch */
-    ABI_CLASS_VIDEODRV,
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_VIDEODRV,
-    {0, 0, 0, 0}
-};
-
-/*
- * Xorg driver exported structures
- */
-
-_X_EXPORT DriverRec radeong = {
-    1,
-    "radeong",
-    radeon_xorg_identify,
-    NULL,
-    xorg_tracker_available_options,
-    NULL,
-    0,
-    NULL,
-    radeon_xorg_device_match,
-    radeon_xorg_pci_probe
-};
-
-static MODULESETUPPROTO(radeon_xorg_setup);
-
-_X_EXPORT XF86ModuleData radeongModuleData = {
-    &radeon_xorg_version,
-    radeon_xorg_setup,
-    NULL
-};
-
-/*
- * Xorg driver functions
- */
-
-static pointer
-radeon_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = 0;
-
-    /* This module should be loaded only once, but check to be sure.
-     */
-    if (!setupDone) {
-       setupDone = 1;
-       xf86AddDriver(&radeong, module, HaveDriverFuncs);
-
-       /*
-        * The return value must be non-NULL on success even though there
-        * is no TearDownProc.
-        */
-       return (pointer) 1;
-    } else {
-       if (errmaj)
-           *errmaj = LDR_ONCEONLY;
-       return NULL;
-    }
-}
-
-static void
-radeon_xorg_identify(int flags)
-{
-    xf86PrintChipsets("radeong", "Driver for Radeon Gallium with KMS",
-                     radeon_xorg_chipsets);
-}
-
-static Bool
-radeon_xorg_pci_probe(DriverPtr driver,
-         int entity_num, struct pci_device *device, intptr_t match_data)
-{
-    ScrnInfoPtr scrn = NULL;
-    EntityInfoPtr entity;
-
-    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, radeon_xorg_pci_devices,
-                              NULL, NULL, NULL, NULL, NULL);
-    if (scrn != NULL) {
-       scrn->driverVersion = 1;
-       scrn->driverName = "radeong";
-       scrn->name = "radeong";
-       scrn->Probe = NULL;
-
-       entity = xf86GetEntityInfo(entity_num);
-
-       /* Use all the functions from the xorg tracker */
-       xorg_tracker_set_functions(scrn);
-    }
-    return scrn != NULL;
-}
diff --git a/src/gallium/winsys/drm/swrast/Makefile b/src/gallium/winsys/drm/swrast/Makefile
deleted file mode 100644 (file)
index 363b895..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/swrast/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
-
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
diff --git a/src/gallium/winsys/drm/swrast/core/Makefile b/src/gallium/winsys/drm/swrast/core/Makefile
deleted file mode 100644 (file)
index 93931ae..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# src/gallium/winsys/drm/swrast/core/Makefile
-
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = swrastdrm
-
-C_SOURCES = swrast_drm_api.c
-
-include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c b/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c
deleted file mode 100644 (file)
index 8c9f80e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "state_tracker/drm_api.h"
-
-static struct drm_api swrast_drm_api =
-{
-   .name = "swrast",
-};
-
-struct drm_api *
-drm_api_create()
-{
-   (void) swrast_drm_api;
-   return NULL;
-}
diff --git a/src/gallium/winsys/drm/swrast/egl/Makefile b/src/gallium/winsys/drm/swrast/egl/Makefile
deleted file mode 100644 (file)
index 26fe2d2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = swrast
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS =
-
-EGL_DRIVER_PIPES = \
-       $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
-
-include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/swrast/egl/dummy.c b/src/gallium/winsys/drm/swrast/egl/dummy.c
deleted file mode 100644 (file)
index 3181d0b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/winsys/drm/vmware/Makefile b/src/gallium/winsys/drm/vmware/Makefile
deleted file mode 100644 (file)
index 2ae6dea..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/vmware/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
-
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
diff --git a/src/gallium/winsys/drm/vmware/SConscript b/src/gallium/winsys/drm/vmware/SConscript
deleted file mode 100644 (file)
index 06e6d5b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Import('*')
-
-SConscript(['core/SConscript',])
-
-if 'mesa' in env['statetrackers']:
-
-    SConscript(['dri/SConscript'])
-
-if 'xorg' in env['statetrackers']:
-
-    SConscript(['xorg/SConscript'])
diff --git a/src/gallium/winsys/drm/vmware/core/Makefile b/src/gallium/winsys/drm/vmware/core/Makefile
deleted file mode 100644 (file)
index a52957c..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = svgadrm
-
-C_SOURCES = \
-        vmw_buffer.c \
-        vmw_context.c  \
-        vmw_fence.c  \
-        vmw_screen.c  \
-        vmw_screen_dri.c  \
-        vmw_screen_ioctl.c  \
-        vmw_screen_pools.c  \
-        vmw_screen_svga.c  \
-        vmw_surface.c
-
-LIBRARY_INCLUDES = \
-       -I$(TOP)/src/gallium/drivers/svga \
-       -I$(TOP)/src/gallium/drivers/svga/include \
-       -I$(GALLIUM)/src/mesa/drivers/dri/common \
-       -I$(GALLIUM)/include \
-       -I$(GALLIUM)/include/GL/internal \
-       -I$(GALLIUM)/src/mesa \
-       -I$(GALLIUM)/src/mesa/main \
-       -I$(GALLIUM)/src/mesa/glapi \
-       -I$(GALLIUM)/src/egl/main \
-       -I$(GALLIUM)/src/egl/drivers/dri \
-       $(shell pkg-config libdrm --cflags-only-I)
-
-LIBRARY_DEFINES = \
-       -std=gnu99 -fvisibility=hidden \
-       -DHAVE_STDINT_H -D_FILE_OFFSET_BITS=64 \
-       $(shell pkg-config libdrm --cflags-only-other)
-
-include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/vmware/core/SConscript b/src/gallium/winsys/drm/vmware/core/SConscript
deleted file mode 100644 (file)
index edaf945..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-Import('*')
-
-env = env.Clone()
-
-if env['gcc']:
-       env.Append(CCFLAGS = ['-fvisibility=hidden'])
-       env.Append(CPPDEFINES = [
-               'HAVE_STDINT_H', 
-               'HAVE_SYS_TYPES_H',
-                '-D_FILE_OFFSET_BITS=64',
-       ])
-       
-env.Prepend(CPPPATH = [
-       'include',
-        '#/src/gallium/drivers/svga',
-        '#/src/gallium/drivers/svga/include',
-])
-
-env.Append(CPPDEFINES = [
-])
-
-sources = [
-        'vmw_buffer.c',
-        'vmw_context.c',
-        'vmw_fence.c',
-        'vmw_screen.c',
-        'vmw_screen_dri.c',
-        'vmw_screen_ioctl.c',
-        'vmw_screen_pools.c',
-        'vmw_screen_svga.c',
-        'vmw_surface.c',
-]
-
-svgadrm = env.ConvenienceLibrary(
-       target = 'svgadrm',
-       source = sources,
-)
-
-Export('svgadrm')
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c b/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
deleted file mode 100644 (file)
index eca174a..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- * SVGA buffer manager for Guest Memory Regions (GMRs).
- * 
- * GMRs are used for pixel and vertex data upload/download to/from the virtual
- * SVGA hardware. There is a limited number of GMRs available, and 
- * creating/destroying them is also a slow operation so we must suballocate 
- * them.
- * 
- * This file implements a pipebuffer library's buffer manager, so that we can
- * use pipepbuffer's suballocation, fencing, and debugging facilities with GMRs. 
- * 
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#include "svga_cmd.h"
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-
-#include "svga_winsys.h"
-
-#include "vmw_screen.h"
-#include "vmw_buffer.h"
-
-
-struct vmw_gmr_bufmgr;
-
-
-struct vmw_gmr_buffer
-{
-   struct pb_buffer base;
-   
-   struct vmw_gmr_bufmgr *mgr;
-   
-   struct vmw_region *region;
-   void *map;
-   
-#ifdef DEBUG
-   struct pipe_fence_handle *last_fence;
-#endif
-};
-
-
-extern const struct pb_vtbl vmw_gmr_buffer_vtbl;
-
-
-static INLINE struct vmw_gmr_buffer *
-vmw_gmr_buffer(struct pb_buffer *buf)
-{
-   assert(buf);
-   assert(buf->vtbl == &vmw_gmr_buffer_vtbl);
-   return (struct vmw_gmr_buffer *)buf;
-}
-
-
-struct vmw_gmr_bufmgr
-{
-   struct pb_manager base;
-   
-   struct vmw_winsys_screen *vws;
-};
-
-
-static INLINE struct vmw_gmr_bufmgr *
-vmw_gmr_bufmgr(struct pb_manager *mgr)
-{
-   assert(mgr);
-   return (struct vmw_gmr_bufmgr *)mgr;
-}
-
-
-static void
-vmw_gmr_buffer_destroy(struct pb_buffer *_buf)
-{
-   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
-
-#ifdef DEBUG
-   if(buf->last_fence) {
-      struct svga_winsys_screen *sws = &buf->mgr->vws->base;
-      assert(sws->fence_signalled(sws, buf->last_fence, 0) == 0);
-   }
-#endif
-
-   vmw_ioctl_region_unmap(buf->region);
-   
-   vmw_ioctl_region_destroy(buf->region);
-
-   FREE(buf);
-}
-
-
-static void *
-vmw_gmr_buffer_map(struct pb_buffer *_buf,
-               unsigned flags)
-{
-   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
-   return buf->map;
-}
-
-
-static void
-vmw_gmr_buffer_unmap(struct pb_buffer *_buf)
-{
-   /* Do nothing */
-   (void)_buf;
-}
-
-
-static void
-vmw_gmr_buffer_get_base_buffer(struct pb_buffer *buf,
-                           struct pb_buffer **base_buf,
-                           unsigned *offset)
-{
-   *base_buf = buf;
-   *offset = 0;
-}
-
-
-static enum pipe_error
-vmw_gmr_buffer_validate( struct pb_buffer *_buf, 
-                         struct pb_validate *vl,
-                         unsigned flags )
-{
-   /* Always pinned */
-   return PIPE_OK;
-}
-
-
-static void
-vmw_gmr_buffer_fence( struct pb_buffer *_buf, 
-                      struct pipe_fence_handle *fence )
-{
-   /* We don't need to do anything, as the pipebuffer library
-    * will take care of delaying the destruction of fenced buffers */  
-#ifdef DEBUG
-   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
-   if(fence)
-      buf->last_fence = fence;
-#endif
-}
-
-
-const struct pb_vtbl vmw_gmr_buffer_vtbl = {
-   vmw_gmr_buffer_destroy,
-   vmw_gmr_buffer_map,
-   vmw_gmr_buffer_unmap,
-   vmw_gmr_buffer_validate,
-   vmw_gmr_buffer_fence,
-   vmw_gmr_buffer_get_base_buffer
-};
-
-
-static struct pb_buffer *
-vmw_gmr_bufmgr_create_buffer(struct pb_manager *_mgr,
-                         pb_size size,
-                         const struct pb_desc *desc) 
-{
-   struct vmw_gmr_bufmgr *mgr = vmw_gmr_bufmgr(_mgr);
-   struct vmw_winsys_screen *vws = mgr->vws;
-   struct vmw_gmr_buffer *buf;
-   
-   buf = CALLOC_STRUCT(vmw_gmr_buffer);
-   if(!buf)
-      goto error1;
-
-   pipe_reference_init(&buf->base.base.reference, 1);
-   buf->base.base.alignment = desc->alignment;
-   buf->base.base.usage = desc->usage;
-   buf->base.base.size = size;
-   buf->base.vtbl = &vmw_gmr_buffer_vtbl;
-   buf->mgr = mgr;
-
-   buf->region = vmw_ioctl_region_create(vws, size);
-   if(!buf->region)
-      goto error2;
-        
-   buf->map = vmw_ioctl_region_map(buf->region);
-   if(!buf->map)
-      goto error3;
-
-   return &buf->base;
-
-error3:
-   vmw_ioctl_region_destroy(buf->region);
-error2:
-   FREE(buf);
-error1:
-   return NULL;
-}
-
-
-static void
-vmw_gmr_bufmgr_flush(struct pb_manager *mgr) 
-{
-   /* No-op */
-}
-
-
-static void
-vmw_gmr_bufmgr_destroy(struct pb_manager *_mgr) 
-{
-   struct vmw_gmr_bufmgr *mgr = vmw_gmr_bufmgr(_mgr);
-   FREE(mgr);
-}
-
-
-struct pb_manager *
-vmw_gmr_bufmgr_create(struct vmw_winsys_screen *vws) 
-{
-   struct vmw_gmr_bufmgr *mgr;
-   
-   mgr = CALLOC_STRUCT(vmw_gmr_bufmgr);
-   if(!mgr)
-      return NULL;
-
-   mgr->base.destroy = vmw_gmr_bufmgr_destroy;
-   mgr->base.create_buffer = vmw_gmr_bufmgr_create_buffer;
-   mgr->base.flush = vmw_gmr_bufmgr_flush;
-   
-   mgr->vws = vws;
-   
-   return &mgr->base;
-}
-
-
-boolean
-vmw_gmr_bufmgr_region_ptr(struct pb_buffer *buf, 
-                          struct SVGAGuestPtr *ptr)
-{
-   struct pb_buffer *base_buf;
-   unsigned offset = 0;
-   struct vmw_gmr_buffer *gmr_buf;
-   
-   pb_get_base_buffer( buf, &base_buf, &offset );
-   
-   gmr_buf = vmw_gmr_buffer(base_buf);
-   if(!gmr_buf)
-      return FALSE;
-   
-   *ptr = vmw_ioctl_region_ptr(gmr_buf->region);
-   
-   ptr->offset += offset;
-   
-   return TRUE;
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h b/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
deleted file mode 100644 (file)
index 41fb447..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-
-#ifndef VMW_BUFFER_H_
-#define VMW_BUFFER_H_
-
-#include <assert.h>
-#include "pipe/p_compiler.h"
-
-struct SVGAGuestPtr;
-struct pb_buffer;
-struct pb_manager;
-struct svga_winsys_buffer;
-struct svga_winsys_surface;
-struct vmw_winsys_screen;
-
-
-static INLINE struct pb_buffer *
-vmw_pb_buffer(struct svga_winsys_buffer *buffer)
-{
-   assert(buffer);
-   return (struct pb_buffer *)buffer;
-}
-
-
-static INLINE struct svga_winsys_buffer *
-vmw_svga_winsys_buffer(struct pb_buffer *buffer)
-{
-   assert(buffer);
-   return (struct svga_winsys_buffer *)buffer;
-}
-
-
-struct pb_manager *
-vmw_gmr_bufmgr_create(struct vmw_winsys_screen *vws);
-
-boolean
-vmw_gmr_bufmgr_region_ptr(struct pb_buffer *buf, 
-                          struct SVGAGuestPtr *ptr);
-
-
-#endif /* VMW_BUFFER_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.c b/src/gallium/winsys/drm/vmware/core/vmw_context.c
deleted file mode 100644 (file)
index 90ffc48..0000000
+++ /dev/null
@@ -1,382 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-
-#include "svga_cmd.h"
-
-#include "util/u_debug.h"
-#include "util/u_memory.h"
-#include "util/u_debug_stack.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_validate.h"
-
-#include "svga_winsys.h"
-#include "vmw_context.h"
-#include "vmw_screen.h"
-#include "vmw_buffer.h"
-#include "vmw_surface.h"
-#include "vmw_fence.h"
-
-#define VMW_COMMAND_SIZE (64*1024)
-#define VMW_SURFACE_RELOCS (1024)
-#define VMW_REGION_RELOCS (512)
-
-#define VMW_MUST_FLUSH_STACK 8
-
-struct vmw_region_relocation
-{
-   struct SVGAGuestPtr *where;
-   struct pb_buffer *buffer;
-   /* TODO: put offset info inside where */
-   uint32 offset;
-};
-
-struct vmw_svga_winsys_context
-{
-   struct svga_winsys_context base;
-
-   struct vmw_winsys_screen *vws;
-
-#ifdef DEBUG
-   boolean must_flush;
-   struct debug_stack_frame must_flush_stack[VMW_MUST_FLUSH_STACK];
-#endif
-
-   struct {
-      uint8_t buffer[VMW_COMMAND_SIZE];
-      uint32_t size;
-      uint32_t used;
-      uint32_t reserved;
-   } command;
-
-   struct {
-      struct vmw_svga_winsys_surface *handles[VMW_SURFACE_RELOCS];
-      uint32_t size;
-      uint32_t used;
-      uint32_t staged;
-      uint32_t reserved;
-   } surface;
-   
-   struct {
-      struct vmw_region_relocation relocs[VMW_REGION_RELOCS];
-      uint32_t size;
-      uint32_t used;
-      uint32_t staged;
-      uint32_t reserved;
-   } region;
-
-   struct pb_validate *validate;
-
-   uint32_t last_fence;
-
-   /**
-    * The amount of GMR that is referred by the commands currently batched
-    * in the context.
-    */
-   uint32_t seen_regions;
-
-   /**
-    * Whether this context should fail to reserve more commands, not because it
-    * ran out of command space, but because a substantial ammount of GMR was
-    * referred.
-    */
-   boolean preemptive_flush;
-};
-
-
-static INLINE struct vmw_svga_winsys_context *
-vmw_svga_winsys_context(struct svga_winsys_context *swc)
-{
-   assert(swc);
-   return (struct vmw_svga_winsys_context *)swc;
-}
-
-
-static enum pipe_error
-vmw_swc_flush(struct svga_winsys_context *swc,
-              struct pipe_fence_handle **pfence)
-{
-   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
-   struct pipe_fence_handle *fence = NULL;
-   unsigned i;
-   enum pipe_error ret;
-
-   ret = pb_validate_validate(vswc->validate);
-   assert(ret == PIPE_OK);
-   if(ret == PIPE_OK) {
-   
-      /* Apply relocations */
-      for(i = 0; i < vswc->region.used; ++i) {
-         struct vmw_region_relocation *reloc = &vswc->region.relocs[i];
-         struct SVGAGuestPtr ptr;
-
-         if(!vmw_gmr_bufmgr_region_ptr(reloc->buffer, &ptr))
-            assert(0);
-
-         ptr.offset += reloc->offset;
-
-         *reloc->where = ptr;
-      }
-
-      if (vswc->command.used)
-         vmw_ioctl_command(vswc->vws,
-                           vswc->command.buffer,
-                           vswc->command.used,
-                           &vswc->last_fence);
-
-      fence = vmw_pipe_fence(vswc->last_fence);
-
-      pb_validate_fence(vswc->validate, fence);
-   }
-
-   vswc->command.used = 0;
-   vswc->command.reserved = 0;
-
-   for(i = 0; i < vswc->surface.used + vswc->surface.staged; ++i) {
-      struct vmw_svga_winsys_surface *vsurf =
-        vswc->surface.handles[i];
-      p_atomic_dec(&vsurf->validated);
-      vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
-   }
-
-   vswc->surface.used = 0;
-   vswc->surface.reserved = 0;
-
-   for(i = 0; i < vswc->region.used + vswc->region.staged; ++i) {
-      pb_reference(&vswc->region.relocs[i].buffer, NULL);
-   }
-
-   vswc->region.used = 0;
-   vswc->region.reserved = 0;
-
-#ifdef DEBUG
-   vswc->must_flush = FALSE;
-#endif
-   vswc->preemptive_flush = FALSE;
-   vswc->seen_regions = 0;
-
-   if(pfence)
-      *pfence = fence;
-
-   return ret;
-}
-
-
-static void *
-vmw_swc_reserve(struct svga_winsys_context *swc,
-                uint32_t nr_bytes, uint32_t nr_relocs )
-{
-   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
-
-#ifdef DEBUG
-   /* Check if somebody forgot to check the previous failure */
-   if(vswc->must_flush) {
-      debug_printf("Forgot to flush:\n");
-      debug_backtrace_dump(vswc->must_flush_stack, VMW_MUST_FLUSH_STACK);
-      assert(!vswc->must_flush);
-   }
-#endif
-
-   assert(nr_bytes <= vswc->command.size);
-   if(nr_bytes > vswc->command.size)
-      return NULL;
-
-   if(vswc->preemptive_flush ||
-      vswc->command.used + nr_bytes > vswc->command.size ||
-      vswc->surface.used + nr_relocs > vswc->surface.size ||
-      vswc->region.used + nr_relocs > vswc->region.size) {
-#ifdef DEBUG
-      vswc->must_flush = TRUE;
-      debug_backtrace_capture(vswc->must_flush_stack, 1,
-                              VMW_MUST_FLUSH_STACK);
-#endif
-      return NULL;
-   }
-
-   assert(vswc->command.used + nr_bytes <= vswc->command.size);
-   assert(vswc->surface.used + nr_relocs <= vswc->surface.size);
-   assert(vswc->region.used + nr_relocs <= vswc->region.size);
-   
-   vswc->command.reserved = nr_bytes;
-   vswc->surface.reserved = nr_relocs;
-   vswc->surface.staged = 0;
-   vswc->region.reserved = nr_relocs;
-   vswc->region.staged = 0;
-   
-   return vswc->command.buffer + vswc->command.used;
-}
-
-
-static void
-vmw_swc_surface_relocation(struct svga_winsys_context *swc,
-                           uint32 *where,
-                           struct svga_winsys_surface *surface,
-                           unsigned flags)
-{
-   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
-   struct vmw_svga_winsys_surface *vsurf;
-
-   if(!surface) {
-      *where = SVGA3D_INVALID_ID;
-      return;
-   }
-
-   assert(vswc->surface.staged < vswc->surface.reserved);
-
-   vsurf = vmw_svga_winsys_surface(surface);
-
-   *where = vsurf->sid;
-
-   vmw_svga_winsys_surface_reference(&vswc->surface.handles[vswc->surface.used + vswc->surface.staged], vsurf);
-   p_atomic_inc(&vsurf->validated);
-   ++vswc->surface.staged;
-}
-
-
-static void
-vmw_swc_region_relocation(struct svga_winsys_context *swc,
-                          struct SVGAGuestPtr *where,
-                          struct svga_winsys_buffer *buffer,
-                          uint32 offset,
-                          unsigned flags)
-{
-   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
-   struct vmw_region_relocation *reloc;
-   enum pipe_error ret;
-   
-   assert(vswc->region.staged < vswc->region.reserved);
-
-   reloc = &vswc->region.relocs[vswc->region.used + vswc->region.staged];
-   reloc->where = where;
-   pb_reference(&reloc->buffer, vmw_pb_buffer(buffer));
-   reloc->offset = offset;
-
-   ++vswc->region.staged;
-
-   ret = pb_validate_add_buffer(vswc->validate, reloc->buffer, flags);
-   /* TODO: Update pipebuffer to reserve buffers and not fail here */
-   assert(ret == PIPE_OK);
-
-   /*
-    * Flush preemptively the FIFO commands to keep the GMR working set within
-    * the GMR pool size.
-    *
-    * This is necessary for applications like SPECviewperf that generate huge
-    * amounts of immediate vertex data, so that we don't pile up too much of
-    * that vertex data neither in the guest nor in the host.
-    *
-    * Note that in the current implementation if a region is referred twice in
-    * a command stream, it will be accounted twice. We could detect repeated
-    * regions and count only once, but there is no incentive to do that, since
-    * regions are typically short-lived; always referred in a single command;
-    * and at the worst we just flush the commands a bit sooner, which for the
-    * SVGA virtual device it's not a performance issue since flushing commands
-    * to the FIFO won't cause flushing in the host.
-    */
-   vswc->seen_regions += reloc->buffer->base.size;
-   if(vswc->seen_regions >= VMW_GMR_POOL_SIZE/2)
-      vswc->preemptive_flush = TRUE;
-}
-
-
-static void
-vmw_swc_commit(struct svga_winsys_context *swc)
-{
-   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
-
-   assert(vswc->command.reserved);
-   assert(vswc->command.used + vswc->command.reserved <= vswc->command.size);
-   vswc->command.used += vswc->command.reserved;
-   vswc->command.reserved = 0;
-
-   assert(vswc->surface.staged <= vswc->surface.reserved);
-   assert(vswc->surface.used + vswc->surface.staged <= vswc->surface.size);
-   vswc->surface.used += vswc->surface.staged;
-   vswc->surface.staged = 0;
-   vswc->surface.reserved = 0;
-
-   assert(vswc->region.staged <= vswc->region.reserved);
-   assert(vswc->region.used + vswc->region.staged <= vswc->region.size);
-   vswc->region.used += vswc->region.staged;
-   vswc->region.staged = 0;
-   vswc->region.reserved = 0;
-}
-
-
-static void
-vmw_swc_destroy(struct svga_winsys_context *swc)
-{
-   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
-   unsigned i;
-
-   for(i = 0; i < vswc->region.used; ++i) {
-      pb_reference(&vswc->region.relocs[i].buffer, NULL);
-   }
-
-   for(i = 0; i < vswc->surface.used; ++i) {
-      p_atomic_dec(&vswc->surface.handles[i]->validated);
-      vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
-   }
-   pb_validate_destroy(vswc->validate);
-   vmw_ioctl_context_destroy(vswc->vws, swc->cid);
-   FREE(vswc);
-}
-
-
-struct svga_winsys_context *
-vmw_svga_winsys_context_create(struct svga_winsys_screen *sws)
-{
-   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-   struct vmw_svga_winsys_context *vswc;
-
-   vswc = CALLOC_STRUCT(vmw_svga_winsys_context);
-   if(!vswc)
-      return NULL;
-
-   vswc->base.destroy = vmw_swc_destroy;
-   vswc->base.reserve = vmw_swc_reserve;
-   vswc->base.surface_relocation = vmw_swc_surface_relocation;
-   vswc->base.region_relocation = vmw_swc_region_relocation;
-   vswc->base.commit = vmw_swc_commit;
-   vswc->base.flush = vmw_swc_flush;
-
-   vswc->base.cid = vmw_ioctl_context_create(vws);
-
-   vswc->vws = vws;
-
-   vswc->command.size = VMW_COMMAND_SIZE;
-   vswc->surface.size = VMW_SURFACE_RELOCS;
-   vswc->region.size = VMW_REGION_RELOCS;
-
-   vswc->validate = pb_validate_create();
-   if(!vswc->validate) {
-      FREE(vswc);
-      return NULL;
-   }
-
-   return &vswc->base;
-}
-
-
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.h b/src/gallium/winsys/drm/vmware/core/vmw_context.h
deleted file mode 100644 (file)
index d4884d2..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#ifndef VMW_CONTEXT_H_
-#define VMW_CONTEXT_H_
-
-#include "pipe/p_compiler.h"
-
-struct svga_winsys_screen;
-struct svga_winsys_context;
-struct pipe_context;
-struct pipe_screen;
-
-#define VMW_DEBUG 0
-
-#if VMW_DEBUG
-#define vmw_printf debug_printf
-#define VMW_FUNC  debug_printf("%s\n", __FUNCTION__)
-#else
-#define VMW_FUNC
-#define vmw_printf(...)
-#endif
-
-
-struct svga_winsys_context *
-vmw_svga_winsys_context_create(struct svga_winsys_screen *sws);
-
-
-#endif /* VMW_CONTEXT_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_fence.c b/src/gallium/winsys/drm/vmware/core/vmw_fence.c
deleted file mode 100644 (file)
index 873dd51..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-
-#include "util/u_memory.h"
-#include "pipebuffer/pb_buffer_fenced.h"
-
-#include "vmw_screen.h"
-#include "vmw_fence.h"
-
-
-
-struct vmw_fence_ops 
-{
-   struct pb_fence_ops base;
-
-   struct vmw_winsys_screen *vws;
-};
-
-
-static INLINE struct vmw_fence_ops *
-vmw_fence_ops(struct pb_fence_ops *ops)
-{
-   assert(ops);
-   return (struct vmw_fence_ops *)ops;
-}
-
-
-static void
-vmw_fence_ops_fence_reference(struct pb_fence_ops *ops,
-                              struct pipe_fence_handle **ptr,
-                              struct pipe_fence_handle *fence)
-{
-   *ptr = fence;
-}
-
-
-static int
-vmw_fence_ops_fence_signalled(struct pb_fence_ops *ops,
-                              struct pipe_fence_handle *fence,
-                              unsigned flag)
-{
-   struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
-   (void)flag;
-   return vmw_ioctl_fence_signalled(vws, vmw_fence(fence));
-}
-
-
-static int
-vmw_fence_ops_fence_finish(struct pb_fence_ops *ops,
-                           struct pipe_fence_handle *fence,
-                           unsigned flag)
-{
-   struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
-   (void)flag;
-   return vmw_ioctl_fence_finish(vws, vmw_fence(fence));
-}
-
-
-static void
-vmw_fence_ops_destroy(struct pb_fence_ops *ops)
-{
-   FREE(ops);
-}
-
-
-struct pb_fence_ops *
-vmw_fence_ops_create(struct vmw_winsys_screen *vws) 
-{
-   struct vmw_fence_ops *ops;
-
-   ops = CALLOC_STRUCT(vmw_fence_ops);
-   if(!ops)
-      return NULL;
-
-   ops->base.destroy = &vmw_fence_ops_destroy;
-   ops->base.fence_reference = &vmw_fence_ops_fence_reference;
-   ops->base.fence_signalled = &vmw_fence_ops_fence_signalled;
-   ops->base.fence_finish = &vmw_fence_ops_fence_finish;
-
-   ops->vws = vws;
-
-   return &ops->base;
-}
-
-
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_fence.h b/src/gallium/winsys/drm/vmware/core/vmw_fence.h
deleted file mode 100644 (file)
index 5357b4f..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-
-#ifndef VMW_FENCE_H_
-#define VMW_FENCE_H_
-
-
-#include "pipe/p_compiler.h"
-
-
-struct pipe_fence_handle;
-struct pb_fence_ops;
-struct vmw_winsys_screen;
-
-
-/** Cast from a pipe_fence_handle pointer into a SVGA fence */
-static INLINE uint32_t
-vmw_fence( struct pipe_fence_handle *fence )
-{
-   return (uint32_t)(uintptr_t)fence;
-}
-
-
-/** Cast from a SVGA fence number to pipe_fence_handle pointer */
-static INLINE struct pipe_fence_handle *
-vmw_pipe_fence( uint32_t fence )
-{
-   return (struct pipe_fence_handle *)(uintptr_t)fence;
-}
-
-
-struct pb_fence_ops *
-vmw_fence_ops_create(struct vmw_winsys_screen *vws); 
-
-
-#endif /* VMW_FENCE_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.c b/src/gallium/winsys/drm/vmware/core/vmw_screen.c
deleted file mode 100644 (file)
index 6cc9b38..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-
-#include "vmw_screen.h"
-
-#include "vmw_context.h"
-
-#include "util/u_memory.h"
-#include "pipe/p_compiler.h"
-
-
-/* Called from vmw_drm_create_screen(), creates and initializes the
- * vmw_winsys_screen structure, which is the main entity in this
- * module.
- */
-struct vmw_winsys_screen *
-vmw_winsys_create( int fd, boolean use_old_scanout_flag )
-{
-   struct vmw_winsys_screen *vws = CALLOC_STRUCT(vmw_winsys_screen);
-   if (!vws)
-      goto out_no_vws;
-
-   vws->ioctl.drm_fd = fd;
-   vws->use_old_scanout_flag = use_old_scanout_flag;
-   debug_printf("%s: use_old_scanout_flag == %s\n", __FUNCTION__,
-               use_old_scanout_flag ? "true" : "false");
-
-   if (!vmw_ioctl_init(vws))
-      goto out_no_ioctl;
-
-   if(!vmw_pools_init(vws))
-      goto out_no_pools;
-
-   if (!vmw_winsys_screen_init_svga(vws))
-      goto out_no_svga;
-
-   return vws;
-out_no_svga:
-   vmw_pools_cleanup(vws);
-out_no_pools:
-   vmw_ioctl_cleanup(vws);
-out_no_ioctl:
-   FREE(vws);
-out_no_vws:
-   return NULL;
-}
-
-void
-vmw_winsys_destroy(struct vmw_winsys_screen *vws)
-{
-   vmw_pools_cleanup(vws);
-   vmw_ioctl_cleanup(vws);
-   FREE(vws);
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.h b/src/gallium/winsys/drm/vmware/core/vmw_screen.h
deleted file mode 100644 (file)
index d3f2c2c..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- * Common definitions for the VMware SVGA winsys.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#ifndef VMW_SCREEN_H_
-#define VMW_SCREEN_H_
-
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-#include "svga_winsys.h"
-
-
-#define VMW_GMR_POOL_SIZE (16*1024*1024)
-
-
-struct pb_manager;
-struct vmw_region;
-
-
-struct vmw_winsys_screen
-{
-   struct svga_winsys_screen base;
-
-   boolean use_old_scanout_flag;
-
-   struct {
-      volatile uint32_t *fifo_map;
-      uint64_t last_fence;
-      int drm_fd;
-   } ioctl;
-
-   struct {
-      struct pb_manager *gmr;
-      struct pb_manager *gmr_mm;
-      struct pb_manager *gmr_fenced;
-   } pools;
-};
-
-
-static INLINE struct vmw_winsys_screen *
-vmw_winsys_screen(struct svga_winsys_screen *base)
-{
-   return (struct vmw_winsys_screen *)base;
-}
-
-/*  */
-uint32
-vmw_ioctl_context_create(struct vmw_winsys_screen *vws);
-
-void
-vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws,
-                          uint32 cid);
-
-uint32
-vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
-                              SVGA3dSurfaceFlags flags,
-                              SVGA3dSurfaceFormat format,
-                              SVGA3dSize size,
-                              uint32 numFaces,
-                              uint32 numMipLevels);
-
-void
-vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws,
-                          uint32 sid);
-
-void
-vmw_ioctl_command(struct vmw_winsys_screen *vws,
-                       void *commands,
-                       uint32_t size,
-                       uint32_t *fence);
-
-struct vmw_region *
-vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size);
-
-void
-vmw_ioctl_region_destroy(struct vmw_region *region);
-
-struct SVGAGuestPtr
-vmw_ioctl_region_ptr(struct vmw_region *region);
-
-void *
-vmw_ioctl_region_map(struct vmw_region *region);
-void
-vmw_ioctl_region_unmap(struct vmw_region *region);
-
-
-int
-vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
-                       uint32_t fence);
-
-int
-vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
-                          uint32_t fence);
-
-
-/* Initialize parts of vmw_winsys_screen at startup:
- */
-boolean vmw_ioctl_init(struct vmw_winsys_screen *vws);
-boolean vmw_pools_init(struct vmw_winsys_screen *vws);
-boolean vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws);
-
-void vmw_ioctl_cleanup(struct vmw_winsys_screen *vws);
-void vmw_pools_cleanup(struct vmw_winsys_screen *vws);
-
-struct vmw_winsys_screen *vmw_winsys_create(int fd, boolean use_old_scanout_flag);
-void vmw_winsys_destroy(struct vmw_winsys_screen *sws);
-
-
-#endif /* VMW_SCREEN_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
deleted file mode 100644 (file)
index 657544d..0000000
+++ /dev/null
@@ -1,373 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-
-#include "pipe/p_compiler.h"
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_format.h"
-#include "vmw_screen.h"
-
-#include "trace/tr_drm.h"
-
-#include "vmw_screen.h"
-#include "vmw_surface.h"
-#include "vmw_fence.h"
-#include "vmw_context.h"
-
-#include <state_tracker/dri1_api.h>
-#include <state_tracker/drm_api.h>
-#include <vmwgfx_drm.h>
-#include <xf86drm.h>
-
-#include <stdio.h>
-
-static struct svga_winsys_surface *
-vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
-                           struct winsys_handle *whandle,
-                           SVGA3dSurfaceFormat *format);
-static boolean
-vmw_drm_surface_get_handle(struct svga_winsys_screen *sws,
-                          struct svga_winsys_surface *surface,
-                          unsigned stride,
-                          struct winsys_handle *whandle);
-
-static struct dri1_api dri1_api_hooks;
-static struct dri1_api_version ddx_required = { 0, 1, 0 };
-static struct dri1_api_version ddx_compat = { 0, 0, 0 };
-static struct dri1_api_version dri_required = { 4, 0, 0 };
-static struct dri1_api_version dri_compat = { 4, 0, 0 };
-static struct dri1_api_version drm_required = { 1, 0, 0 };
-static struct dri1_api_version drm_compat = { 1, 0, 0 };
-static struct dri1_api_version drm_scanout = { 0, 9, 0 };
-
-static boolean
-vmw_dri1_check_version(const struct dri1_api_version *cur,
-                      const struct dri1_api_version *required,
-                      const struct dri1_api_version *compat,
-                      const char component[])
-{
-   if (cur->major > required->major && cur->major <= compat->major)
-      return TRUE;
-   if (cur->major == required->major && cur->minor >= required->minor)
-      return TRUE;
-
-   fprintf(stderr, "%s version failure.\n", component);
-   fprintf(stderr, "%s version is %d.%d.%d and this driver can only work\n"
-          "with versions %d.%d.x through %d.x.x.\n",
-          component,
-          cur->major,
-          cur->minor,
-          cur->patch_level, required->major, required->minor, compat->major);
-   return FALSE;
-}
-
-/* This is actually the entrypoint to the entire driver, called by the
- * libGL (or EGL, or ...) code via the drm_api_hooks table at the
- * bottom of the file.
- */
-static struct pipe_screen *
-vmw_drm_create_screen(struct drm_api *drm_api,
-                      int fd,
-                      struct drm_create_screen_arg *arg)
-{
-   struct vmw_winsys_screen *vws;
-   struct pipe_screen *screen;
-   struct dri1_create_screen_arg *dri1;
-   boolean use_old_scanout_flag = FALSE;
-
-   if (!arg || arg->mode == DRM_CREATE_NORMAL) {
-      struct dri1_api_version drm_ver;
-      drmVersionPtr ver;
-
-      ver = drmGetVersion(fd);
-      if (ver == NULL)
-        return NULL;
-
-      drm_ver.major = ver->version_major;
-      drm_ver.minor = ver->version_minor;
-      drm_ver.patch_level = 0; /* ??? */
-
-      drmFreeVersion(ver);
-      if (!vmw_dri1_check_version(&drm_ver, &drm_required,
-                                 &drm_compat, "vmwgfx drm driver"))
-        return NULL;
-
-      if (!vmw_dri1_check_version(&drm_ver, &drm_scanout,
-                                 &drm_compat, "use old scanout field (not a error)"))
-         use_old_scanout_flag = TRUE;
-   }
-
-   if (arg != NULL) {
-      switch (arg->mode) {
-      case DRM_CREATE_NORMAL:
-        break;
-      case DRM_CREATE_DRI1:
-        dri1 = (struct dri1_create_screen_arg *)arg;
-        if (!vmw_dri1_check_version(&dri1->ddx_version, &ddx_required,
-                                    &ddx_compat, "ddx - driver api"))
-           return NULL;
-        if (!vmw_dri1_check_version(&dri1->dri_version, &dri_required,
-                                    &dri_compat, "dri info"))
-           return NULL;
-        if (!vmw_dri1_check_version(&dri1->drm_version, &drm_required,
-                                    &drm_compat, "vmwgfx drm driver"))
-           return NULL;
-        if (!vmw_dri1_check_version(&dri1->drm_version, &drm_scanout,
-                                    &drm_compat, "use old scanout field (not a error)"))
-           use_old_scanout_flag = TRUE;
-        dri1->api = &dri1_api_hooks;
-#if 0
-        break;
-#else
-        assert(!"No dri 1 support for now\n");
-        return NULL;
-#endif
-      default:
-        return NULL;
-      }
-   }
-
-   vws = vmw_winsys_create( fd, use_old_scanout_flag );
-   if (!vws)
-      goto out_no_vws;
-
-   /* XXX do this properly */
-   vws->base.surface_from_handle = vmw_drm_surface_from_handle;
-   vws->base.surface_get_handle = vmw_drm_surface_get_handle;
-
-   screen = svga_screen_create( &vws->base );
-   if (!screen)
-      goto out_no_screen;
-
-   return screen;
-
-   /* Failure cases:
-    */
-out_no_screen:
-   vmw_winsys_destroy( vws );
-
-out_no_vws:
-   return NULL;
-}
-
-static INLINE boolean
-vmw_dri1_intersect_src_bbox(struct drm_clip_rect *dst,
-                           int dst_x,
-                           int dst_y,
-                           const struct drm_clip_rect *src,
-                           const struct drm_clip_rect *bbox)
-{
-   int xy1;
-   int xy2;
-
-   xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
-      (int)bbox->x1 + dst_x;
-   xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
-      (int)bbox->x2 + dst_x;
-   if (xy1 >= xy2 || xy1 < 0)
-      return FALSE;
-
-   dst->x1 = xy1;
-   dst->x2 = xy2;
-
-   xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
-      (int)bbox->y1 + dst_y;
-   xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
-      (int)bbox->y2 + dst_y;
-   if (xy1 >= xy2 || xy1 < 0)
-      return FALSE;
-
-   dst->y1 = xy1;
-   dst->y2 = xy2;
-   return TRUE;
-}
-
-/**
- * No fancy get-surface-from-sarea stuff here.
- * Just use the present blit.
- */
-
-static void
-vmw_dri1_present_locked(struct pipe_context *locked_pipe,
-                       struct pipe_surface *surf,
-                       const struct drm_clip_rect *rect,
-                       unsigned int num_clip,
-                       int x_draw, int y_draw,
-                       const struct drm_clip_rect *bbox,
-                       struct pipe_fence_handle **p_fence)
-{
-#if 0
-   struct svga_winsys_surface *srf =
-      svga_screen_texture_get_winsys_surface(surf->texture);
-   struct vmw_svga_winsys_surface *vsrf = vmw_svga_winsys_surface(srf);
-   struct vmw_winsys_screen *vws =
-      vmw_winsys_screen(svga_winsys_screen(locked_pipe->screen));
-   struct drm_clip_rect clip;
-   int i;
-   struct
-   {
-      SVGA3dCmdHeader header;
-      SVGA3dCmdPresent body;
-      SVGA3dCopyRect rect;
-   } cmd;
-   boolean visible = FALSE;
-   uint32_t fence_seq = 0;
-
-   VMW_FUNC;
-   cmd.header.id = SVGA_3D_CMD_PRESENT;
-   cmd.header.size = sizeof cmd.body + sizeof cmd.rect;
-   cmd.body.sid = vsrf->sid;
-
-   for (i = 0; i < num_clip; ++i) {
-      if (!vmw_dri1_intersect_src_bbox(&clip, x_draw, y_draw, rect++, bbox))
-        continue;
-
-      cmd.rect.x = clip.x1;
-      cmd.rect.y = clip.y1;
-      cmd.rect.w = clip.x2 - clip.x1;
-      cmd.rect.h = clip.y2 - clip.y1;
-      cmd.rect.srcx = (int)clip.x1 - x_draw;
-      cmd.rect.srcy = (int)clip.y1 - y_draw;
-
-      vmw_printf("%s: Clip %d x %d y %d w %d h %d srcx %d srcy %d\n",
-                  __FUNCTION__,
-                  i,
-                  cmd.rect.x,
-                  cmd.rect.y,
-                  cmd.rect.w, cmd.rect.h, cmd.rect.srcx, cmd.rect.srcy);
-
-      vmw_ioctl_command(vws, &cmd, sizeof cmd.header + cmd.header.size,
-                        &fence_seq);
-      visible = TRUE;
-   }
-
-   *p_fence = (visible) ? vmw_pipe_fence(fence_seq) : NULL;
-   vmw_svga_winsys_surface_reference(&vsrf, NULL);
-#else
-   assert(!"No dri 1 support for now\n");
-#endif
-}
-
-static struct svga_winsys_surface *
-vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
-                           struct winsys_handle *whandle,
-                           SVGA3dSurfaceFormat *format)
-{
-    struct vmw_svga_winsys_surface *vsrf;
-    struct svga_winsys_surface *ssrf;
-    struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-    union drm_vmw_surface_reference_arg arg;
-    struct drm_vmw_surface_arg *req = &arg.req;
-    struct drm_vmw_surface_create_req *rep = &arg.rep;
-    int ret;
-    int i;
-
-    /**
-     * The vmware device specific handle is the hardware SID.
-     * FIXME: We probably want to move this to the ioctl implementations.
-     */
-
-    memset(&arg, 0, sizeof(arg));
-    req->sid = whandle->handle;
-
-    ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_REF_SURFACE,
-                             &arg, sizeof(arg));
-
-    if (ret) {
-       fprintf(stderr, "Failed referencing shared surface. SID %d.\n"
-               "Error %d (%s).\n",
-               whandle->handle, ret, strerror(-ret));
-       return NULL;
-    }
-
-    if (rep->mip_levels[0] != 1) {
-       fprintf(stderr, "Incorrect number of mipmap levels on shared surface."
-               " SID %d, levels %d\n",
-               whandle->handle, rep->mip_levels[0]);
-       goto out_mip;
-    }
-
-    for (i=1; i < DRM_VMW_MAX_SURFACE_FACES; ++i) {
-       if (rep->mip_levels[i] != 0) {
-           fprintf(stderr, "Incorrect number of faces levels on shared surface."
-                   " SID %d, face %d present.\n",
-                   whandle->handle, i);
-           goto out_mip;
-       }
-    }
-
-    vsrf = CALLOC_STRUCT(vmw_svga_winsys_surface);
-    if (!vsrf)
-       goto out_mip;
-
-    pipe_reference_init(&vsrf->refcnt, 1);
-    p_atomic_set(&vsrf->validated, 0);
-    vsrf->screen = vws;
-    vsrf->sid = whandle->handle;
-    ssrf = svga_winsys_surface(vsrf);
-    *format = rep->format;
-
-    return ssrf;
-
-out_mip:
-    vmw_ioctl_surface_destroy(vws, whandle->handle);
-    return NULL;
-}
-
-static boolean
-vmw_drm_surface_get_handle(struct svga_winsys_screen *sws,
-                          struct svga_winsys_surface *surface,
-                          unsigned stride,
-                          struct winsys_handle *whandle)
-{
-    struct vmw_svga_winsys_surface *vsrf;
-
-    if (!surface)
-       return FALSE;
-
-    vsrf = vmw_svga_winsys_surface(surface);
-    whandle->handle = vsrf->sid;
-    whandle->stride = stride;
-
-    return TRUE;
-}
-
-
-static struct dri1_api dri1_api_hooks = {
-   .front_srf_locked = NULL,
-   .present_locked = vmw_dri1_present_locked
-};
-
-static struct drm_api vmw_drm_api_hooks = {
-   .name = "vmwgfx",
-   .driver_name = "vmwgfx",
-   .create_screen = vmw_drm_create_screen,
-};
-
-struct drm_api* drm_api_create()
-{
-   return trace_drm_create(&vmw_drm_api_hooks);
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c
deleted file mode 100644 (file)
index 5d81fa8..0000000
+++ /dev/null
@@ -1,529 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- *
- * Wrappers for DRM ioctl functionlaity used by the rest of the vmw
- * drm winsys.
- *
- * Based on svgaicd_escape.c
- */
-
-
-#include "svga_cmd.h"
-#include "util/u_memory.h"
-#include "util/u_math.h"
-#include "svgadump/svga_dump.h"
-#include "vmw_screen.h"
-#include "vmw_context.h"
-#include "xf86drm.h"
-#include "vmwgfx_drm.h"
-
-#include <sys/mman.h>
-#include <errno.h>
-#include <unistd.h>
-
-struct vmw_region
-{
-   SVGAGuestPtr ptr;
-   uint32_t handle;
-   uint64_t map_handle;
-   void *data;
-   uint32_t map_count;
-   int drm_fd;
-   uint32_t size;
-};
-
-/* XXX: This isn't a real hardware flag, but just a hack for kernel to
- * know about primary surfaces. In newer versions of the kernel
- * interface the driver uses a special field.
- */
-#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
-
-static void
-vmw_check_last_cmd(struct vmw_winsys_screen *vws)
-{
-   static uint32_t buffer[16384];
-   struct drm_vmw_fifo_debug_arg arg;
-   int ret;
-
-   return;
-   memset(&arg, 0, sizeof(arg));
-   arg.debug_buffer = (unsigned long)buffer;
-   arg.debug_buffer_size = 65536;
-
-   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_FIFO_DEBUG,
-                            &arg, sizeof(arg));
-
-   if (ret) {
-      debug_printf("%s Ioctl error: \"%s\".\n", __FUNCTION__, strerror(-ret));
-      return;
-   }
-
-   if (arg.did_not_fit) {
-      debug_printf("%s Command did not fit completely.\n", __FUNCTION__);
-   }
-
-   svga_dump_commands(buffer, arg.used_size);
-}
-
-static void
-vmw_ioctl_fifo_unmap(struct vmw_winsys_screen *vws, void *mapping)
-{
-   VMW_FUNC;
-   (void)munmap(mapping, getpagesize());
-}
-
-
-static void *
-vmw_ioctl_fifo_map(struct vmw_winsys_screen *vws,
-                   uint32_t fifo_offset )
-{
-   void *map;
-
-   VMW_FUNC;
-
-   map = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED,
-             vws->ioctl.drm_fd, fifo_offset);
-
-   if (map == MAP_FAILED) {
-      debug_printf("Map failed %s\n", strerror(errno));
-      return NULL;
-   }
-
-   vmw_printf("Fifo (min) is 0x%08x\n", ((uint32_t *) map)[SVGA_FIFO_MIN]);
-
-   return map;
-}
-
-uint32
-vmw_ioctl_context_create(struct vmw_winsys_screen *vws)
-{
-   struct drm_vmw_context_arg c_arg;
-   int ret;
-
-   VMW_FUNC;
-
-   ret = drmCommandRead(vws->ioctl.drm_fd, DRM_VMW_CREATE_CONTEXT,
-                       &c_arg, sizeof(c_arg));
-
-   if (ret)
-      return -1;
-
-   vmw_check_last_cmd(vws);
-   vmw_printf("Context id is %d\n", c_arg.cid);
-
-   return c_arg.cid;
-}
-
-void
-vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws, uint32 cid)
-{
-   struct drm_vmw_context_arg c_arg;
-
-   VMW_FUNC;
-
-   memset(&c_arg, 0, sizeof(c_arg));
-   c_arg.cid = cid;
-
-   (void)drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_UNREF_CONTEXT,
-                        &c_arg, sizeof(c_arg));
-
-   vmw_check_last_cmd(vws);
-}
-
-uint32
-vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
-                             SVGA3dSurfaceFlags flags,
-                             SVGA3dSurfaceFormat format,
-                             SVGA3dSize size,
-                             uint32_t numFaces, uint32_t numMipLevels)
-{
-   union drm_vmw_surface_create_arg s_arg;
-   struct drm_vmw_surface_create_req *req = &s_arg.req;
-   struct drm_vmw_surface_arg *rep = &s_arg.rep;
-   struct drm_vmw_size sizes[DRM_VMW_MAX_SURFACE_FACES*
-                            DRM_VMW_MAX_MIP_LEVELS];
-   struct drm_vmw_size *cur_size;
-   uint32_t iFace;
-   uint32_t iMipLevel;
-   int ret;
-
-   vmw_printf("%s flags %d format %d\n", __FUNCTION__, flags, format);
-
-   memset(&s_arg, 0, sizeof(s_arg));
-   if (vws->use_old_scanout_flag &&
-       (flags & SVGA3D_SURFACE_HINT_SCANOUT)) {
-      req->flags = (uint32_t) flags;
-      req->scanout = false;
-   } else if (flags & SVGA3D_SURFACE_HINT_SCANOUT) {
-      req->flags = (uint32_t) (flags & ~SVGA3D_SURFACE_HINT_SCANOUT);
-      req->scanout = true;
-   } else {
-      req->flags = (uint32_t) flags;
-      req->scanout = false;
-   }
-   req->format = (uint32_t) format;
-   req->shareable = 1;
-
-   assert(numFaces * numMipLevels < DRM_VMW_MAX_SURFACE_FACES*
-         DRM_VMW_MAX_MIP_LEVELS);
-   cur_size = sizes;
-   for (iFace = 0; iFace < numFaces; ++iFace) {
-      SVGA3dSize mipSize = size;
-
-      req->mip_levels[iFace] = numMipLevels;
-      for (iMipLevel = 0; iMipLevel < numMipLevels; ++iMipLevel) {
-        cur_size->width = mipSize.width;
-        cur_size->height = mipSize.height;
-        cur_size->depth = mipSize.depth;
-        mipSize.width = MAX2(mipSize.width >> 1, 1);
-        mipSize.height = MAX2(mipSize.height >> 1, 1);
-        mipSize.depth = MAX2(mipSize.depth >> 1, 1);
-        cur_size++;
-      }
-   }
-   for (iFace = numFaces; iFace < SVGA3D_MAX_SURFACE_FACES; ++iFace) {
-      req->mip_levels[iFace] = 0;
-   }
-
-   req->size_addr = (unsigned long)&sizes;
-
-   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_CREATE_SURFACE,
-                            &s_arg, sizeof(s_arg));
-
-   if (ret)
-      return -1;
-
-   vmw_printf("Surface id is %d\n", rep->sid);
-   vmw_check_last_cmd(vws);
-
-   return rep->sid;
-}
-
-void
-vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws, uint32 sid)
-{
-   struct drm_vmw_surface_arg s_arg;
-
-   VMW_FUNC;
-
-   memset(&s_arg, 0, sizeof(s_arg));
-   s_arg.sid = sid;
-
-   (void)drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_UNREF_SURFACE,
-                        &s_arg, sizeof(s_arg));
-   vmw_check_last_cmd(vws);
-
-}
-
-void
-vmw_ioctl_command(struct vmw_winsys_screen *vws, void *commands, uint32_t size,
-                      uint32_t * pfence)
-{
-   struct drm_vmw_execbuf_arg arg;
-   struct drm_vmw_fence_rep rep;
-   int ret;
-
-#ifdef DEBUG
-   {
-      static boolean firsttime = TRUE;
-      static boolean debug = FALSE;
-      static boolean skip = FALSE;
-      if (firsttime) {
-         debug = debug_get_bool_option("SVGA_DUMP_CMD", FALSE);
-         skip = debug_get_bool_option("SVGA_SKIP_CMD", FALSE);
-      }
-      if (debug) {
-         VMW_FUNC;
-         svga_dump_commands(commands, size);
-      }
-      firsttime = FALSE;
-      if (skip) {
-         size = 0;
-      }
-   }
-#endif
-
-   memset(&arg, 0, sizeof(arg));
-   memset(&rep, 0, sizeof(rep));
-
-   rep.error = -EFAULT;
-   arg.fence_rep = (unsigned long)&rep;
-   arg.commands = (unsigned long)commands;
-   arg.command_size = size;
-
-   do {
-       ret = drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_EXECBUF, &arg, sizeof(arg));
-   } while(ret == -ERESTART);
-   if (ret) {
-      debug_printf("%s error %s.\n", __FUNCTION__, strerror(-ret));
-   }
-   if (rep.error) {
-
-      /*
-       * Kernel has synced and put the last fence sequence in the FIFO
-       * register.
-       */
-
-      if (rep.error == -EFAULT)
-        rep.fence_seq = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
-
-      debug_printf("%s Fence error %s.\n", __FUNCTION__,
-                  strerror(-rep.error));
-   }
-
-   vws->ioctl.last_fence = rep.fence_seq;
-
-   if (pfence)
-      *pfence = rep.fence_seq;
-   vmw_check_last_cmd(vws);
-
-}
-
-
-struct vmw_region *
-vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size)
-{
-   struct vmw_region *region;
-   union drm_vmw_alloc_dmabuf_arg arg;
-   struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
-   struct drm_vmw_dmabuf_rep *rep = &arg.rep;
-   int ret;
-
-   vmw_printf("%s: size = %u\n", __FUNCTION__, size);
-
-   region = CALLOC_STRUCT(vmw_region);
-   if (!region)
-      goto out_err1;
-
-   memset(&arg, 0, sizeof(arg));
-   req->size = size;
-   do {
-      ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_ALLOC_DMABUF, &arg,
-                               sizeof(arg));
-   } while (ret == -ERESTART);
-
-   if (ret) {
-      debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
-      goto out_err1;
-   }
-
-   region->ptr.gmrId = rep->cur_gmr_id;
-   region->ptr.offset = rep->cur_gmr_offset;
-   region->data = NULL;
-   region->handle = rep->handle;
-   region->map_handle = rep->map_handle;
-   region->map_count = 0;
-   region->size = size;
-   region->drm_fd = vws->ioctl.drm_fd;
-
-   vmw_printf("   gmrId = %u, offset = %u\n",
-              region->ptr.gmrId, region->ptr.offset);
-
-   return region;
-
- out_err1:
-   FREE(region);
-   return NULL;
-}
-
-void
-vmw_ioctl_region_destroy(struct vmw_region *region)
-{
-   struct drm_vmw_unref_dmabuf_arg arg;
-
-   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
-              region->ptr.gmrId, region->ptr.offset);
-
-   if (region->data) {
-      munmap(region->data, region->size);
-      region->data = NULL;
-   }
-
-   memset(&arg, 0, sizeof(arg));
-   arg.handle = region->handle;
-   drmCommandWrite(region->drm_fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
-
-   FREE(region);
-}
-
-SVGAGuestPtr
-vmw_ioctl_region_ptr(struct vmw_region *region)
-{
-   return region->ptr;
-}
-
-void *
-vmw_ioctl_region_map(struct vmw_region *region)
-{
-   void *map;
-
-   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
-              region->ptr.gmrId, region->ptr.offset);
-
-   if (region->data == NULL) {
-      map = mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED,
-                region->drm_fd, region->map_handle);
-      if (map == MAP_FAILED) {
-        debug_printf("%s: Map failed.\n", __FUNCTION__);
-        return NULL;
-      }
-
-      region->data = map;
-   }
-
-   ++region->map_count;
-
-   return region->data;
-}
-
-void
-vmw_ioctl_region_unmap(struct vmw_region *region)
-{
-   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
-              region->ptr.gmrId, region->ptr.offset);
-   --region->map_count;
-}
-
-
-int
-vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
-                          uint32_t fence)
-{
-   uint32_t expected;
-   uint32_t current;
-   
-   assert(fence);
-   if(!fence)
-      return 0;
-   
-   expected = fence;
-   current = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
-   
-   if ((int32)(current - expected) >= 0)
-      return 0; /* fence passed */
-   else
-      return -1;
-}
-
-
-static void
-vmw_ioctl_sync(struct vmw_winsys_screen *vws, 
-                   uint32_t fence)
-{
-   uint32_t cur_fence;
-   struct drm_vmw_fence_wait_arg arg;
-   int ret;
-
-   vmw_printf("%s: fence = %lu\n", __FUNCTION__,
-              (unsigned long)fence);
-
-   cur_fence = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
-   vmw_printf("%s: Fence id read is 0x%08x\n", __FUNCTION__,
-              (unsigned int)cur_fence);
-
-   if ((cur_fence - fence) < (1 << 24))
-      return;
-
-   memset(&arg, 0, sizeof(arg));
-   arg.sequence = fence;
-
-   do {
-       ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_FENCE_WAIT, &arg,
-                                sizeof(arg));
-   } while (ret == -ERESTART);
-}
-
-
-int
-vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
-                       uint32_t fence)
-{
-   assert(fence);
-   
-   if(fence) {
-      if(vmw_ioctl_fence_signalled(vws, fence) != 0) {
-         vmw_ioctl_sync(vws, fence);
-      }
-   }
-   
-   return 0;
-}
-
-
-boolean
-vmw_ioctl_init(struct vmw_winsys_screen *vws)
-{
-   struct drm_vmw_getparam_arg gp_arg;
-   int ret;
-
-   VMW_FUNC;
-
-   memset(&gp_arg, 0, sizeof(gp_arg));
-   gp_arg.param = DRM_VMW_PARAM_3D;
-   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
-                            &gp_arg, sizeof(gp_arg));
-   if (ret || gp_arg.value == 0) {
-      debug_printf("No 3D enabled (%i, %s)\n", ret, strerror(-ret));
-      goto out_err1;
-   }
-
-   memset(&gp_arg, 0, sizeof(gp_arg));
-   gp_arg.param = DRM_VMW_PARAM_FIFO_OFFSET;
-   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
-                            &gp_arg, sizeof(gp_arg));
-
-   if (ret) {
-      debug_printf("GET_PARAM on %d returned %d: %s\n",
-                  vws->ioctl.drm_fd, ret, strerror(-ret));
-      goto out_err1;
-   }
-
-   vmw_printf("Offset to map is 0x%08llx\n",
-              (unsigned long long)gp_arg.value);
-
-   vws->ioctl.fifo_map = vmw_ioctl_fifo_map(vws, gp_arg.value);
-   if (vws->ioctl.fifo_map == NULL)
-      goto out_err1;
-
-   vmw_printf("%s OK\n", __FUNCTION__);
-   return TRUE;
-
- out_err1:
-   debug_printf("%s Failed\n", __FUNCTION__);
-   return FALSE;
-}
-
-
-
-void
-vmw_ioctl_cleanup(struct vmw_winsys_screen *vws)
-{
-   VMW_FUNC;
-
-   vmw_ioctl_fifo_unmap(vws, (void *)vws->ioctl.fifo_map);
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c
deleted file mode 100644 (file)
index b9823d7..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-
-#include "vmw_screen.h"
-
-#include "vmw_buffer.h"
-#include "vmw_fence.h"
-
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-
-void
-vmw_pools_cleanup(struct vmw_winsys_screen *vws)
-{
-   if(vws->pools.gmr_fenced)
-      vws->pools.gmr_fenced->destroy(vws->pools.gmr_fenced);
-
-   /* gmr_mm pool is already destroyed above */
-
-   if(vws->pools.gmr)
-      vws->pools.gmr->destroy(vws->pools.gmr);
-}
-
-
-boolean
-vmw_pools_init(struct vmw_winsys_screen *vws)
-{
-   vws->pools.gmr = vmw_gmr_bufmgr_create(vws);
-   if(!vws->pools.gmr)
-      goto error;
-
-   vws->pools.gmr_mm = mm_bufmgr_create(vws->pools.gmr,
-                                        VMW_GMR_POOL_SIZE,
-                                        12 /* 4096 alignment */);
-   if(!vws->pools.gmr_mm)
-      goto error;
-
-   /*
-    * GMR buffers are typically shortlived, but it's possible that at a given
-    * instance a buffer is mapped. So to avoid stalling we tell pipebuffer to
-    * forbid creation of buffers beyond half the GMR pool size,
-    *
-    * XXX: It is unclear weather we want to limit the total amount of temporary
-    * malloc memory used to backup unvalidated GMR buffers. On one hand it is
-    * preferrable to fail an allocation than exhausting the guest memory with
-    * temporary data, but on the other hand it is possible that a stupid
-    * application creates large vertex buffers and does not use them for a long
-    * time -- since the svga pipe driver only emits the DMA uploads when a
-    * buffer is used for drawing this would effectively disabling swapping GMR
-    * buffers to memory. So far, the preemptively flush already seems to keep
-    * total allocated memory within relatively small numbers, so we don't
-    * limit.
-    */
-   vws->pools.gmr_fenced = fenced_bufmgr_create(
-      vws->pools.gmr_mm,
-      vmw_fence_ops_create(vws),
-      VMW_GMR_POOL_SIZE/2,
-      ~0);
-
-#ifdef DEBUG
-   vws->pools.gmr_fenced = pb_debug_manager_create(vws->pools.gmr_fenced,
-                                                  4096,
-                                                  4096);
-#endif
-   if(!vws->pools.gmr_fenced)
-      goto error;
-
-   return TRUE;
-
-error:
-   vmw_pools_cleanup(vws);
-   return FALSE;
-}
-
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
deleted file mode 100644 (file)
index 2b4e80f..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- * This file implements the SVGA interface into this winsys, defined
- * in drivers/svga/svga_winsys.h.
- *
- * @author Keith Whitwell
- * @author Jose Fonseca
- */
-
-
-#include "svga_cmd.h"
-#include "svga3d_caps.h"
-
-#include "util/u_inlines.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-#include "svga_winsys.h"
-#include "vmw_context.h"
-#include "vmw_screen.h"
-#include "vmw_surface.h"
-#include "vmw_buffer.h"
-#include "vmw_fence.h"
-
-
-static struct svga_winsys_buffer *
-vmw_svga_winsys_buffer_create(struct svga_winsys_screen *sws,
-                              unsigned alignment,
-                              unsigned usage,
-                              unsigned size)
-{
-   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-   struct pb_desc desc;
-   struct pb_manager *provider;
-   struct pb_buffer *buffer;
-
-   memset(&desc, 0, sizeof desc);
-   desc.alignment = alignment;
-   desc.usage = usage;
-
-   provider = vws->pools.gmr_fenced;
-
-   assert(provider);
-   buffer = provider->create_buffer(provider, size, &desc);
-   if(!buffer)
-      return NULL;
-
-   return vmw_svga_winsys_buffer(buffer);
-}
-
-
-static void *
-vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,
-                           struct svga_winsys_buffer *buf,
-                           unsigned flags)
-{
-   (void)sws;
-   return pb_map(vmw_pb_buffer(buf), flags);
-}
-
-
-static void
-vmw_svga_winsys_buffer_unmap(struct svga_winsys_screen *sws,
-                             struct svga_winsys_buffer *buf)
-{
-   (void)sws;
-   pb_unmap(vmw_pb_buffer(buf));
-}
-
-
-static void
-vmw_svga_winsys_buffer_destroy(struct svga_winsys_screen *sws,
-                               struct svga_winsys_buffer *buf)
-{
-   struct pb_buffer *pbuf = vmw_pb_buffer(buf);
-   (void)sws;
-   pb_reference(&pbuf, NULL);
-}
-
-
-static void
-vmw_svga_winsys_fence_reference(struct svga_winsys_screen *sws,
-                                struct pipe_fence_handle **pdst,
-                                struct pipe_fence_handle *src)
-{
-   (void)sws;
-   *pdst = src;
-}
-
-
-static int
-vmw_svga_winsys_fence_signalled(struct svga_winsys_screen *sws,
-                                struct pipe_fence_handle *fence,
-                                unsigned flag)
-{
-   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-   (void)flag;
-   return vmw_ioctl_fence_signalled(vws, vmw_fence(fence));
-}
-
-
-static int
-vmw_svga_winsys_fence_finish(struct svga_winsys_screen *sws,
-                             struct pipe_fence_handle *fence,
-                             unsigned flag)
-{
-   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-   (void)flag;
-   return vmw_ioctl_fence_finish(vws, vmw_fence(fence));
-}
-
-
-
-static struct svga_winsys_surface *
-vmw_svga_winsys_surface_create(struct svga_winsys_screen *sws,
-                               SVGA3dSurfaceFlags flags,
-                               SVGA3dSurfaceFormat format,
-                               SVGA3dSize size,
-                               uint32 numFaces,
-                               uint32 numMipLevels)
-{
-   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-   struct vmw_svga_winsys_surface *surface;
-
-   surface = CALLOC_STRUCT(vmw_svga_winsys_surface);
-   if(!surface)
-      goto no_surface;
-
-   pipe_reference_init(&surface->refcnt, 1);
-   p_atomic_set(&surface->validated, 0);
-   surface->screen = vws;
-   surface->sid = vmw_ioctl_surface_create(vws,
-                                           flags, format, size,
-                                           numFaces, numMipLevels);
-   if(surface->sid == SVGA3D_INVALID_ID)
-      goto no_sid;
-
-   return svga_winsys_surface(surface);
-
-no_sid:
-   FREE(surface);
-no_surface:
-   return NULL;
-}
-
-
-static boolean
-vmw_svga_winsys_surface_is_flushed(struct svga_winsys_screen *sws,
-                                   struct svga_winsys_surface *surface)
-{
-   struct vmw_svga_winsys_surface *vsurf = vmw_svga_winsys_surface(surface);
-   return (p_atomic_read(&vsurf->validated) == 0);
-}
-
-
-static void
-vmw_svga_winsys_surface_ref(struct svga_winsys_screen *sws,
-                           struct svga_winsys_surface **pDst,
-                           struct svga_winsys_surface *src)
-{
-   struct vmw_svga_winsys_surface *d_vsurf = vmw_svga_winsys_surface(*pDst);
-   struct vmw_svga_winsys_surface *s_vsurf = vmw_svga_winsys_surface(src);
-
-   vmw_svga_winsys_surface_reference(&d_vsurf, s_vsurf);
-   *pDst = svga_winsys_surface(d_vsurf);
-}
-
-
-static void
-vmw_svga_winsys_destroy(struct svga_winsys_screen *sws)
-{
-   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-
-   vmw_winsys_destroy(vws);
-}
-
-
-static boolean
-vmw_svga_winsys_get_cap(struct svga_winsys_screen *sws,
-                        SVGA3dDevCapIndex index,
-                        SVGA3dDevCapResult *result)
-{
-   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-   const uint32 *capsBlock;
-   const SVGA3dCapsRecord *capsRecord = NULL;
-   uint32 offset;
-   const SVGA3dCapPair *capArray;
-   int numCaps, first, last;
-
-   if(!vws->ioctl.fifo_map)
-      return FALSE;
-
-   if(vws->ioctl.fifo_map[SVGA_FIFO_3D_HWVERSION] < SVGA3D_HWVERSION_WS6_B1)
-      return FALSE;
-
-   /*
-    * Search linearly through the caps block records for the specified type.
-    */
-   capsBlock = (const uint32 *)&vws->ioctl.fifo_map[SVGA_FIFO_3D_CAPS];
-   for (offset = 0; capsBlock[offset] != 0; offset += capsBlock[offset]) {
-      const SVGA3dCapsRecord *record;
-      assert(offset < SVGA_FIFO_3D_CAPS_SIZE);
-      record = (const SVGA3dCapsRecord *) (capsBlock + offset);
-      if ((record->header.type >= SVGA3DCAPS_RECORD_DEVCAPS_MIN) &&
-          (record->header.type <= SVGA3DCAPS_RECORD_DEVCAPS_MAX) &&
-          (!capsRecord || (record->header.type > capsRecord->header.type))) {
-         capsRecord = record;
-      }
-   }
-
-   if(!capsRecord)
-      return FALSE;
-
-   /*
-    * Calculate the number of caps from the size of the record.
-    */
-   capArray = (const SVGA3dCapPair *) capsRecord->data;
-   numCaps = (int) ((capsRecord->header.length * sizeof(uint32) -
-                     sizeof capsRecord->header) / (2 * sizeof(uint32)));
-
-   /*
-    * Binary-search for the cap with the specified index.
-    */
-   for (first = 0, last = numCaps - 1; first <= last; ) {
-      int mid = (first + last) / 2;
-
-      if ((SVGA3dDevCapIndex) capArray[mid][0] == index) {
-         /*
-          * Found it.
-          */
-         result->u = capArray[mid][1];
-         return TRUE;
-      }
-
-      /*
-       * Divide and conquer.
-       */
-      if ((SVGA3dDevCapIndex) capArray[mid][0] > index) {
-         last = mid - 1;
-      } else {
-         first = mid + 1;
-      }
-   }
-
-   return FALSE;
-}
-
-
-boolean
-vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws)
-{
-   vws->base.destroy = vmw_svga_winsys_destroy;
-   vws->base.get_cap = vmw_svga_winsys_get_cap;
-   vws->base.context_create = vmw_svga_winsys_context_create;
-   vws->base.surface_create = vmw_svga_winsys_surface_create;
-   vws->base.surface_is_flushed = vmw_svga_winsys_surface_is_flushed;
-   vws->base.surface_reference = vmw_svga_winsys_surface_ref;
-   vws->base.buffer_create = vmw_svga_winsys_buffer_create;
-   vws->base.buffer_map = vmw_svga_winsys_buffer_map;
-   vws->base.buffer_unmap = vmw_svga_winsys_buffer_unmap;
-   vws->base.buffer_destroy = vmw_svga_winsys_buffer_destroy;
-   vws->base.fence_reference = vmw_svga_winsys_fence_reference;
-   vws->base.fence_signalled = vmw_svga_winsys_fence_signalled;
-   vws->base.fence_finish = vmw_svga_winsys_fence_finish;
-
-   return TRUE;
-}
-
-
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.c b/src/gallium/winsys/drm/vmware/core/vmw_surface.c
deleted file mode 100644 (file)
index 5f1b9ad..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-
-#include "svga_cmd.h"
-#include "util/u_debug.h"
-#include "util/u_memory.h"
-
-#include "vmw_surface.h"
-#include "vmw_screen.h"
-
-void
-vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
-                                  struct vmw_svga_winsys_surface *src)
-{
-   struct pipe_reference *src_ref;
-   struct pipe_reference *dst_ref;
-   struct vmw_svga_winsys_surface *dst;
-
-   if(pdst == NULL || *pdst == src)
-      return;
-
-   dst = *pdst;
-
-   src_ref = src ? &src->refcnt : NULL;
-   dst_ref = dst ? &dst->refcnt : NULL;
-
-   if (pipe_reference(dst_ref, src_ref)) {
-      vmw_ioctl_surface_destroy(dst->screen, dst->sid);
-#ifdef DEBUG
-      /* to detect dangling pointers */
-      assert(p_atomic_read(&dst->validated) == 0);
-      dst->sid = SVGA3D_INVALID_ID;
-#endif
-      FREE(dst);
-   }
-
-   *pdst = src;
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.h b/src/gallium/winsys/drm/vmware/core/vmw_surface.h
deleted file mode 100644 (file)
index 3d61595..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- * Surfaces for VMware SVGA winsys.
- * 
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#ifndef VMW_SURFACE_H_
-#define VMW_SURFACE_H_
-
-
-#include "pipe/p_compiler.h"
-#include "util/u_atomic.h"
-#include "util/u_inlines.h"
-
-#define VMW_MAX_PRESENTS 3
-
-
-
-struct vmw_svga_winsys_surface
-{
-   int32_t validated; /* atomic */
-   struct pipe_reference refcnt;
-
-   struct vmw_winsys_screen *screen;
-   uint32_t sid;
-
-   /* FIXME: make this thread safe */
-   unsigned next_present_no;
-   uint32_t present_fences[VMW_MAX_PRESENTS];
-};
-
-
-static INLINE struct svga_winsys_surface *
-svga_winsys_surface(struct vmw_svga_winsys_surface *surf)
-{
-   assert(!surf || surf->sid != SVGA3D_INVALID_ID);
-   return (struct svga_winsys_surface *)surf;
-}
-
-
-static INLINE struct vmw_svga_winsys_surface *
-vmw_svga_winsys_surface(struct svga_winsys_surface *surf)
-{
-   return (struct vmw_svga_winsys_surface *)surf;
-}
-
-
-void
-vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
-                                  struct vmw_svga_winsys_surface *src);
-
-#endif /* VMW_SURFACE_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
deleted file mode 100644 (file)
index 47914bd..0000000
+++ /dev/null
@@ -1,545 +0,0 @@
-/**************************************************************************
- *
- * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef __VMWGFX_DRM_H__
-#define __VMWGFX_DRM_H__
-
-#define DRM_VMW_MAX_SURFACE_FACES 6
-#define DRM_VMW_MAX_MIP_LEVELS 24
-
-#define DRM_VMW_EXT_NAME_LEN 128
-
-#define DRM_VMW_GET_PARAM            0
-#define DRM_VMW_ALLOC_DMABUF         1
-#define DRM_VMW_UNREF_DMABUF         2
-#define DRM_VMW_CURSOR_BYPASS        3
-/* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
-#define DRM_VMW_CONTROL_STREAM       4
-#define DRM_VMW_CLAIM_STREAM         5
-#define DRM_VMW_UNREF_STREAM         6
-/* guarded by DRM_VMW_PARAM_3D == 1 */
-#define DRM_VMW_CREATE_CONTEXT       7
-#define DRM_VMW_UNREF_CONTEXT        8
-#define DRM_VMW_CREATE_SURFACE       9
-#define DRM_VMW_UNREF_SURFACE        10
-#define DRM_VMW_REF_SURFACE          11
-#define DRM_VMW_EXECBUF              12
-#define DRM_VMW_FIFO_DEBUG           13
-#define DRM_VMW_FENCE_WAIT           14
-
-
-/*************************************************************************/
-/**
- * DRM_VMW_GET_PARAM - get device information.
- *
- * DRM_VMW_PARAM_FIFO_OFFSET:
- * Offset to use to map the first page of the FIFO read-only.
- * The fifo is mapped using the mmap() system call on the drm device.
- *
- * DRM_VMW_PARAM_OVERLAY_IOCTL:
- * Does the driver support the overlay ioctl.
- */
-
-#define DRM_VMW_PARAM_NUM_STREAMS      0
-#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
-#define DRM_VMW_PARAM_3D               2
-#define DRM_VMW_PARAM_FIFO_OFFSET      3
-#define DRM_VMW_PARAM_HW_CAPS          4
-#define DRM_VMW_PARAM_FIFO_CAPS        5
-
-/**
- * struct drm_vmw_getparam_arg
- *
- * @value: Returned value. //Out
- * @param: Parameter to query. //In.
- *
- * Argument to the DRM_VMW_GET_PARAM Ioctl.
- */
-
-struct drm_vmw_getparam_arg {
-       uint64_t value;
-       uint32_t param;
-       uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CREATE_CONTEXT - Create a host context.
- *
- * Allocates a device unique context id, and queues a create context command
- * for the host. Does not wait for host completion.
- */
-
-/**
- * struct drm_vmw_context_arg
- *
- * @cid: Device unique context ID.
- *
- * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
- * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
- */
-
-struct drm_vmw_context_arg {
-       int32_t cid;
-       uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_CONTEXT - Create a host context.
- *
- * Frees a global context id, and queues a destroy host command for the host.
- * Does not wait for host completion. The context ID can be used directly
- * in the command stream and shows up as the same context ID on the host.
- */
-
-/*************************************************************************/
-/**
- * DRM_VMW_CREATE_SURFACE - Create a host suface.
- *
- * Allocates a device unique surface id, and queues a create surface command
- * for the host. Does not wait for host completion. The surface ID can be
- * used directly in the command stream and shows up as the same surface
- * ID on the host.
- */
-
-/**
- * struct drm_wmv_surface_create_req
- *
- * @flags: Surface flags as understood by the host.
- * @format: Surface format as understood by the host.
- * @mip_levels: Number of mip levels for each face.
- * An unused face should have 0 encoded.
- * @size_addr: Address of a user-space array of sruct drm_vmw_size
- * cast to an uint64_t for 32-64 bit compatibility.
- * The size of the array should equal the total number of mipmap levels.
- * @shareable: Boolean whether other clients (as identified by file descriptors)
- * may reference this surface.
- * @scanout: Boolean whether the surface is intended to be used as a
- * scanout.
- *
- * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
- * Output data from the DRM_VMW_REF_SURFACE Ioctl.
- */
-
-struct drm_vmw_surface_create_req {
-       uint32_t flags;
-       uint32_t format;
-       uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
-       uint64_t size_addr;
-       int32_t shareable;
-       int32_t scanout;
-};
-
-/**
- * struct drm_wmv_surface_arg
- *
- * @sid: Surface id of created surface or surface to destroy or reference.
- *
- * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
- * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
- * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
- */
-
-struct drm_vmw_surface_arg {
-       int32_t sid;
-       uint32_t pad64;
-};
-
-/**
- * struct drm_vmw_size ioctl.
- *
- * @width - mip level width
- * @height - mip level height
- * @depth - mip level depth
- *
- * Description of a mip level.
- * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
- */
-
-struct drm_vmw_size {
-       uint32_t width;
-       uint32_t height;
-       uint32_t depth;
-       uint32_t pad64;
-};
-
-/**
- * union drm_vmw_surface_create_arg
- *
- * @rep: Output data as described above.
- * @req: Input data as described above.
- *
- * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
- */
-
-union drm_vmw_surface_create_arg {
-       struct drm_vmw_surface_arg rep;
-       struct drm_vmw_surface_create_req req;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_REF_SURFACE - Reference a host surface.
- *
- * Puts a reference on a host surface with a give sid, as previously
- * returned by the DRM_VMW_CREATE_SURFACE ioctl.
- * A reference will make sure the surface isn't destroyed while we hold
- * it and will allow the calling client to use the surface ID in the command
- * stream.
- *
- * On successful return, the Ioctl returns the surface information given
- * in the DRM_VMW_CREATE_SURFACE ioctl.
- */
-
-/**
- * union drm_vmw_surface_reference_arg
- *
- * @rep: Output data as described above.
- * @req: Input data as described above.
- *
- * Argument to the DRM_VMW_REF_SURFACE Ioctl.
- */
-
-union drm_vmw_surface_reference_arg {
-       struct drm_vmw_surface_create_req rep;
-       struct drm_vmw_surface_arg req;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
- *
- * Clear a reference previously put on a host surface.
- * When all references are gone, including the one implicitly placed
- * on creation,
- * a destroy surface command will be queued for the host.
- * Does not wait for completion.
- */
-
-/*************************************************************************/
-/**
- * DRM_VMW_EXECBUF
- *
- * Submit a command buffer for execution on the host, and return a
- * fence sequence that when signaled, indicates that the command buffer has
- * executed.
- */
-
-/**
- * struct drm_vmw_execbuf_arg
- *
- * @commands: User-space address of a command buffer cast to an uint64_t.
- * @command-size: Size in bytes of the command buffer.
- * @throttle-us: Sleep until software is less than @throttle_us
- * microseconds ahead of hardware. The driver may round this value
- * to the nearest kernel tick.
- * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
- * uint64_t.
- * @version: Allows expanding the execbuf ioctl parameters without breaking
- * backwards compatibility, since user-space will always tell the kernel
- * which version it uses.
- * @flags: Execbuf flags. None currently.
- *
- * Argument to the DRM_VMW_EXECBUF Ioctl.
- */
-
-#define DRM_VMW_EXECBUF_VERSION 0
-
-struct drm_vmw_execbuf_arg {
-       uint64_t commands;
-       uint32_t command_size;
-       uint32_t throttle_us;
-       uint64_t fence_rep;
-        uint32_t version;
-        uint32_t flags;
-};
-
-/**
- * struct drm_vmw_fence_rep
- *
- * @fence_seq: Fence sequence associated with a command submission.
- * @error: This member should've been set to -EFAULT on submission.
- * The following actions should be take on completion:
- * error == -EFAULT: Fence communication failed. The host is synchronized.
- * Use the last fence id read from the FIFO fence register.
- * error != 0 && error != -EFAULT:
- * Fence submission failed. The host is synchronized. Use the fence_seq member.
- * error == 0: All is OK, The host may not be synchronized.
- * Use the fence_seq member.
- *
- * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
- */
-
-struct drm_vmw_fence_rep {
-       uint64_t fence_seq;
-       int32_t error;
-       uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_ALLOC_DMABUF
- *
- * Allocate a DMA buffer that is visible also to the host.
- * NOTE: The buffer is
- * identified by a handle and an offset, which are private to the guest, but
- * useable in the command stream. The guest kernel may translate these
- * and patch up the command stream accordingly. In the future, the offset may
- * be zero at all times, or it may disappear from the interface before it is
- * fixed.
- *
- * The DMA buffer may stay user-space mapped in the guest at all times,
- * and is thus suitable for sub-allocation.
- *
- * DMA buffers are mapped using the mmap() syscall on the drm device.
- */
-
-/**
- * struct drm_vmw_alloc_dmabuf_req
- *
- * @size: Required minimum size of the buffer.
- *
- * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
- */
-
-struct drm_vmw_alloc_dmabuf_req {
-       uint32_t size;
-       uint32_t pad64;
-};
-
-/**
- * struct drm_vmw_dmabuf_rep
- *
- * @map_handle: Offset to use in the mmap() call used to map the buffer.
- * @handle: Handle unique to this buffer. Used for unreferencing.
- * @cur_gmr_id: GMR id to use in the command stream when this buffer is
- * referenced. See not above.
- * @cur_gmr_offset: Offset to use in the command stream when this buffer is
- * referenced. See note above.
- *
- * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
- */
-
-struct drm_vmw_dmabuf_rep {
-       uint64_t map_handle;
-       uint32_t handle;
-       uint32_t cur_gmr_id;
-       uint32_t cur_gmr_offset;
-       uint32_t pad64;
-};
-
-/**
- * union drm_vmw_dmabuf_arg
- *
- * @req: Input data as described above.
- * @rep: Output data as described above.
- *
- * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
- */
-
-union drm_vmw_alloc_dmabuf_arg {
-       struct drm_vmw_alloc_dmabuf_req req;
-       struct drm_vmw_dmabuf_rep rep;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
- *
- */
-
-/**
- * struct drm_vmw_unref_dmabuf_arg
- *
- * @handle: Handle indicating what buffer to free. Obtained from the
- * DRM_VMW_ALLOC_DMABUF Ioctl.
- *
- * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
- */
-
-struct drm_vmw_unref_dmabuf_arg {
-       uint32_t handle;
-       uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
- *
- * This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
- */
-
-/**
- * struct drm_vmw_fifo_debug_arg
- *
- * @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
- * @debug_buffer_size: Size in bytes of debug buffer //In
- * @used_size: Number of bytes copied to the buffer // Out
- * @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
- *
- * Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
- */
-
-struct drm_vmw_fifo_debug_arg {
-       uint64_t debug_buffer;
-       uint32_t debug_buffer_size;
-       uint32_t used_size;
-       int32_t did_not_fit;
-       uint32_t pad64;
-};
-
-struct drm_vmw_fence_wait_arg {
-       uint64_t sequence;
-       uint64_t kernel_cookie;
-       int32_t cookie_valid;
-       int32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
- *
- * This IOCTL controls the overlay units of the svga device.
- * The SVGA overlay units does not work like regular hardware units in
- * that they do not automaticaly read back the contents of the given dma
- * buffer. But instead only read back for each call to this ioctl, and
- * at any point between this call being made and a following call that
- * either changes the buffer or disables the stream.
- */
-
-/**
- * struct drm_vmw_rect
- *
- * Defines a rectangle. Used in the overlay ioctl to define
- * source and destination rectangle.
- */
-
-struct drm_vmw_rect {
-       int32_t x;
-       int32_t y;
-       uint32_t w;
-       uint32_t h;
-};
-
-/**
- * struct drm_vmw_control_stream_arg
- *
- * @stream_id: Stearm to control
- * @enabled: If false all following arguments are ignored.
- * @handle: Handle to buffer for getting data from.
- * @format: Format of the overlay as understood by the host.
- * @width: Width of the overlay.
- * @height: Height of the overlay.
- * @size: Size of the overlay in bytes.
- * @pitch: Array of pitches, the two last are only used for YUV12 formats.
- * @offset: Offset from start of dma buffer to overlay.
- * @src: Source rect, must be within the defined area above.
- * @dst: Destination rect, x and y may be negative.
- *
- * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
- */
-
-struct drm_vmw_control_stream_arg {
-       uint32_t stream_id;
-       uint32_t enabled;
-
-       uint32_t flags;
-       uint32_t color_key;
-
-       uint32_t handle;
-       uint32_t offset;
-       int32_t format;
-       uint32_t size;
-       uint32_t width;
-       uint32_t height;
-       uint32_t pitch[3];
-
-       uint32_t pad64;
-       struct drm_vmw_rect src;
-       struct drm_vmw_rect dst;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
- *
- */
-
-#define DRM_VMW_CURSOR_BYPASS_ALL    (1 << 0)
-#define DRM_VMW_CURSOR_BYPASS_FLAGS       (1)
-
-/**
- * struct drm_vmw_cursor_bypass_arg
- *
- * @flags: Flags.
- * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
- * @xpos: X position of cursor.
- * @ypos: Y position of cursor.
- * @xhot: X hotspot.
- * @yhot: Y hotspot.
- *
- * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
- */
-
-struct drm_vmw_cursor_bypass_arg {
-       uint32_t flags;
-       uint32_t crtc_id;
-       int32_t xpos;
-       int32_t ypos;
-       int32_t xhot;
-       int32_t yhot;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CLAIM_STREAM - Claim a single stream.
- */
-
-/**
- * struct drm_vmw_context_arg
- *
- * @stream_id: Device unique context ID.
- *
- * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
- * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
- */
-
-struct drm_vmw_stream_arg {
-       uint32_t stream_id;
-       uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_STREAM - Unclaim a stream.
- *
- * Return a single stream that was claimed by this process. Also makes
- * sure that the stream has been stopped.
- */
-
-#endif
diff --git a/src/gallium/winsys/drm/vmware/dri/Makefile b/src/gallium/winsys/drm/vmware/dri/Makefile
deleted file mode 100644 (file)
index 8a39e23..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = vmwgfx_dri.so
-
-PIPE_DRIVERS = \
-       $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
-       $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/svga/libsvga.a
-
-C_SOURCES = \
-       $(COMMON_GALLIUM_SOURCES)
-
-include ../../Makefile.template
-
-symlinks:
diff --git a/src/gallium/winsys/drm/vmware/dri/SConscript b/src/gallium/winsys/drm/vmware/dri/SConscript
deleted file mode 100644 (file)
index d26d0cd..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-import os
-import os.path
-
-Import('*')
-
-if env['platform'] == 'linux':
-
-   if env['dri']:
-      env = env.Clone()
-
-      sources = [
-        '#/src/mesa/drivers/dri/common/utils.c',
-        '#/src/mesa/drivers/dri/common/vblank.c',
-        '#/src/mesa/drivers/dri/common/dri_util.c',
-        '#/src/mesa/drivers/dri/common/xmlconfig.c',
-         ]
-   
-      
-      env.ParseConfig('pkg-config --cflags --libs libdrm')
-      
-      env.Prepend(CPPPATH = [
-            '#/src/mesa/state_tracker',
-            '#/src/mesa/drivers/dri/common',
-            '#/src/mesa/main',
-            '#/src/mesa/glapi',
-            '#/src/mesa',
-            '#/include',
-            '#/src/gallium/drivers/svga',
-            '#/src/gallium/drivers/svga/include',
-            ])
-      
-      env.Append(CPPDEFINES = [
-            'HAVE_STDINT_H', 
-            'HAVE_SYS_TYPES_H',
-            ])
-
-      env.Append(CFLAGS = [
-            '-std=gnu99',
-            '-D_FILE_OFFSET_BITS=64',
-            ])
-      
-      env.Prepend(LIBPATH = [
-            ])
-      
-      env.Prepend(LIBS = [
-            trace,
-            st_dri,
-            svgadrm,
-            svga,
-            mesa,
-            glsl,
-            gallium,
-            ])
-      
-      # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
-      env.LoadableModule(
-         target ='vmwgfx_dri.so',
-         source = sources,
-         LIBS = env['LIBS'],
-         SHLIBPREFIX = '',
-         )
-      
-
diff --git a/src/gallium/winsys/drm/vmware/egl/Makefile b/src/gallium/winsys/drm/vmware/egl/Makefile
deleted file mode 100644 (file)
index a3e7313..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-EGL_DRIVER_NAME = vmwgfx
-EGL_DRIVER_SOURCES = dummy.c
-EGL_DRIVER_LIBS =
-
-EGL_DRIVER_PIPES = \
-       $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \
-       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/svga/libsvga.a
-
-include ../../Makefile.egl
diff --git a/src/gallium/winsys/drm/vmware/egl/dummy.c b/src/gallium/winsys/drm/vmware/egl/dummy.c
deleted file mode 100644 (file)
index 3181d0b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* A poor man's --whole-archive for EGL drivers */
-void *_eglMain(void *);
-void *_eglWholeArchive = (void *) _eglMain;
diff --git a/src/gallium/winsys/drm/vmware/xorg/Makefile b/src/gallium/winsys/drm/vmware/xorg/Makefile
deleted file mode 100644 (file)
index 49e28ae..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-TOP        = ../../../../../..
-
-include $(TOP)/configs/current
-
-TARGET = vmwgfx_drv.so
-
-CFILES = \
-       vmw_xorg.c \
-       vmw_video.c \
-       vmw_ioctl.c \
-       vmw_screen.c
-
-OBJECTS = $(patsubst %.c,%.o,$(CFILES))
-
-INCLUDES = \
-       $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/auxiliary \
-       -I$(TOP)/src/gallium
-
-LIBS = \
-       $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
-       $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \
-       $(TOP)/src/gallium/drivers/trace/libtrace.a \
-       $(TOP)/src/gallium/drivers/svga/libsvga.a \
-       $(GALLIUM_AUXILIARIES)
-
-LINKS = \
-       $(shell pkg-config --libs --silence-errors libkms) \
-       $(shell pkg-config --libs libdrm)
-
-DRIVER_DEFINES = \
-       -std=gnu99 \
-       -DHAVE_CONFIG_H
-
-TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
-
-#############################################
-
-
-
-all default: $(TARGET) $(TARGET_STAGING)
-
-$(TARGET): $(OBJECTS) Makefile $(LIBS)
-       $(MKLIB) -noprefix -o $@ $(OBJECTS) $(LIBS) $(LINKS)
-
-$(TOP)/$(LIB_DIR)/gallium:
-       mkdir -p $@
-
-$(TARGET_STAGING): $(TARGET) $(TOP)/$(LIB_DIR)/gallium
-       $(INSTALL) $(TARGET) $(TOP)/$(LIB_DIR)/gallium
-
-clean:
-       rm -rf $(OBJECTS) $(TARGET)
-
-install:
-       $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-       $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
-
-
-##############################################
-
-
-.c.o:
-       $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@
-
-
-##############################################
-
-.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/vmware/xorg/SConscript b/src/gallium/winsys/drm/vmware/xorg/SConscript
deleted file mode 100644 (file)
index 1e5d8ff..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-import os.path
-
-Import('*')
-
-if env['platform'] == 'linux':
-
-       env = env.Clone()
-
-       env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server')
-
-       env.Prepend(CPPPATH = [
-               '#/include',
-               '#/src/gallium',
-               '#/src/mesa',
-               '#/src/gallium/drivers/svga',
-               '#/src/gallium/drivers/svga/include',
-       ])
-
-       env.Append(CPPDEFINES = [
-       ])
-
-       if env['gcc']:
-               env.Append(CPPDEFINES = [
-                       'HAVE_STDINT_H',
-                       'HAVE_SYS_TYPES_H',
-               ])
-
-       env.Append(CFLAGS = [
-               '-std=gnu99',
-               '-D_FILE_OFFSET_BITS=64',
-       ])
-
-       env.Prepend(LIBPATH = [
-       ])
-
-       env.Prepend(LIBS = [
-               trace,
-               st_xorg,
-               svgadrm,
-               svga,
-                gallium,
-       ])
-
-       sources = [
-               'vmw_ioctl.c',
-               'vmw_screen.c',
-               'vmw_video.c',
-               'vmw_xorg.c',
-       ]
-
-       # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
-       env.LoadableModule(
-               target ='vmwgfx_drv.so',
-               source = sources,
-               LIBS = env['LIBS'],
-               SHLIBPREFIX = '',
-       )
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h
deleted file mode 100644 (file)
index ba754b5..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- * Contains the shared resources for VMware Xorg driver
- * that sits ontop of the Xorg State Traker.
- *
- * It is initialized in vmw_screen.c.
- *
- * @author Jakob Bornecrantz <jakob@vmware.com>
- */
-
-#ifndef VMW_DRIVER_H_
-#define VMW_DRIVER_H_
-
-#include "state_trackers/xorg/xorg_tracker.h"
-
-struct vmw_dma_buffer;
-
-struct vmw_customizer
-{
-    CustomizerRec base;
-    ScrnInfoPtr pScrn;
-
-    int fd;
-
-    void *cursor_priv;
-
-    /* vmw_video.c */
-    void *video_priv;
-};
-
-static INLINE struct vmw_customizer *
-vmw_customizer(CustomizerPtr cust)
-{
-    return cust ? (struct vmw_customizer *) cust : NULL;
-}
-
-
-/***********************************************************************
- * vmw_video.c
- */
-
-Bool vmw_video_init(struct vmw_customizer *vmw);
-
-Bool vmw_video_close(struct vmw_customizer *vmw);
-
-void vmw_video_stop_all(struct vmw_customizer *vmw);
-
-
-/***********************************************************************
- * vmw_ioctl.c
- */
-
-int vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot);
-
-struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_customizer *vmw,
-                                               uint32_t size,
-                                               unsigned *handle);
-
-void * vmw_ioctl_buffer_map(struct vmw_customizer *vmw,
-                           struct vmw_dma_buffer *buf);
-
-void vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw,
-                           struct vmw_dma_buffer *buf);
-
-void vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw,
-                             struct vmw_dma_buffer *buf);
-
-int vmw_ioctl_supports_streams(struct vmw_customizer *vmw);
-
-int vmw_ioctl_num_streams(struct vmw_customizer *vmw,
-                         uint32_t *ntot, uint32_t *nfree);
-
-int vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id);
-
-int vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out);
-
-
-#endif
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_hook.h b/src/gallium/winsys/drm/vmware/xorg/vmw_hook.h
deleted file mode 100644 (file)
index 224a2d9..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-#ifndef VMW_HOOK_H_
-#define VMW_HOOK_H_
-
-#include "state_trackers/xorg/xorg_winsys.h"
-
-
-/***********************************************************************
- * vmw_screen.c
- */
-
-void vmw_screen_set_functions(ScrnInfoPtr pScrn);
-
-
-#endif
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c
deleted file mode 100644 (file)
index 521578a..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- * Contains the functions for creating dma buffers by calling
- * the kernel via driver specific ioctls.
- *
- * @author Jakob Bornecrantz <jakob@vmware.com>
- */
-
-#ifndef HAVE_STDINT_H
-#define HAVE_STDINT_H 1
-#endif
-#define _FILE_OFFSET_BITS 64
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/mman.h>
-#include "xf86drm.h"
-#include "../core/vmwgfx_drm.h"
-
-#include "vmw_driver.h"
-#include "util/u_debug.h"
-
-struct vmw_dma_buffer
-{
-    void *data;
-    unsigned handle;
-    uint64_t map_handle;
-    unsigned map_count;
-    uint32_t size;
-};
-
-static int
-vmw_ioctl_get_param(struct vmw_customizer *vmw, uint32_t param, uint64_t *out)
-{
-    struct drm_vmw_getparam_arg gp_arg;
-    int ret;
-
-    memset(&gp_arg, 0, sizeof(gp_arg));
-    gp_arg.param = param;
-    ret = drmCommandWriteRead(vmw->fd, DRM_VMW_GET_PARAM,
-           &gp_arg, sizeof(gp_arg));
-
-    if (ret == 0) {
-       *out = gp_arg.value;
-    }
-
-    return ret;
-}
-
-int
-vmw_ioctl_supports_streams(struct vmw_customizer *vmw)
-{
-    uint64_t value;
-    int ret;
-
-    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_STREAMS, &value);
-    if (ret)
-       return ret;
-
-    return value ? 0 : -ENOSYS;
-}
-
-int
-vmw_ioctl_num_streams(struct vmw_customizer *vmw,
-                     uint32_t *ntot, uint32_t *nfree)
-{
-    uint64_t v1, v2;
-    int ret;
-
-    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_STREAMS, &v1);
-    if (ret)
-       return ret;
-
-    ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_FREE_STREAMS, &v2);
-    if (ret)
-       return ret;
-
-    *ntot = (uint32_t)v1;
-    *nfree = (uint32_t)v2;
-
-    return 0;
-}
-
-int
-vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out)
-{
-    struct drm_vmw_stream_arg s_arg;
-    int ret;
-
-    ret = drmCommandRead(vmw->fd, DRM_VMW_CLAIM_STREAM,
-                        &s_arg, sizeof(s_arg));
-
-    if (ret)
-       return -1;
-
-    *out = s_arg.stream_id;
-    return 0;
-}
-
-int
-vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id)
-{
-    struct drm_vmw_stream_arg s_arg;
-    int ret;
-
-    memset(&s_arg, 0, sizeof(s_arg));
-    s_arg.stream_id = stream_id;
-
-    ret = drmCommandRead(vmw->fd, DRM_VMW_CLAIM_STREAM,
-                        &s_arg, sizeof(s_arg));
-
-    return 0;
-}
-
-int
-vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot)
-{
-    struct drm_vmw_cursor_bypass_arg arg;
-    int ret;
-
-    memset(&arg, 0, sizeof(arg));
-    arg.flags = DRM_VMW_CURSOR_BYPASS_ALL;
-    arg.xhot = xhot;
-    arg.yhot = yhot;
-
-    ret = drmCommandWrite(vmw->fd, DRM_VMW_CURSOR_BYPASS,
-                         &arg, sizeof(arg));
-
-    return ret;
-}
-
-struct vmw_dma_buffer *
-vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *handle)
-{
-    struct vmw_dma_buffer *buf;
-    union drm_vmw_alloc_dmabuf_arg arg;
-    struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
-    struct drm_vmw_dmabuf_rep *rep = &arg.rep;
-    int ret;
-
-    buf = xcalloc(1, sizeof(*buf));
-    if (!buf)
-       goto err;
-
-    memset(&arg, 0, sizeof(arg));
-    req->size = size;
-    do {
-       ret = drmCommandWriteRead(vmw->fd, DRM_VMW_ALLOC_DMABUF, &arg, sizeof(arg));
-    } while (ret == -ERESTART);
-
-    if (ret) {
-       debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
-       goto err_free;
-    }
-
-
-    buf->data = NULL;
-    buf->handle = rep->handle;
-    buf->map_handle = rep->map_handle;
-    buf->map_count = 0;
-    buf->size = size;
-
-    *handle = rep->handle;
-
-    return buf;
-
-err_free:
-    xfree(buf);
-err:
-    return NULL;
-}
-
-void
-vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
-{ 
-    struct drm_vmw_unref_dmabuf_arg arg; 
-
-    if (buf->data) { 
-       munmap(buf->data, buf->size); 
-       buf->data = NULL; 
-    } 
-
-    memset(&arg, 0, sizeof(arg)); 
-    arg.handle = buf->handle; 
-    drmCommandWrite(vmw->fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg)); 
-
-    xfree(buf); 
-} 
-
-void *
-vmw_ioctl_buffer_map(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
-{
-    void *map;
-
-    if (buf->data == NULL) {
-       map = mmap(NULL, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED,
-                  vmw->fd, buf->map_handle);
-       if (map == MAP_FAILED) {
-           debug_printf("%s: Map failed.\n", __FUNCTION__);
-           return NULL;
-       }
-
-       buf->data = map;
-    }
-
-    ++buf->map_count;
-
-    return buf->data;
-}
-
-void
-vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
-{
-    --buf->map_count;
-}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c
deleted file mode 100644 (file)
index f43f91e..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- * Contains the init code for the VMware Xorg driver.
- *
- * @author Jakob Bornecrantz <jakob@vmware.com>
- */
-
-#include "vmw_hook.h"
-#include "vmw_driver.h"
-
-#include "cursorstr.h"
-
-/* modified version of crtc functions */
-xf86CrtcFuncsRec vmw_screen_crtc_funcs;
-
-static void
-vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image)
-{
-    struct vmw_customizer *vmw =
-       vmw_customizer(xorg_customizer(crtc->scrn));
-    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-    xf86CrtcFuncsPtr funcs = vmw->cursor_priv;
-    CursorPtr c = config->cursor;
-
-    /* Run the ioctl before uploading the image */
-    vmw_ioctl_cursor_bypass(vmw, c->bits->xhot, c->bits->yhot);
-
-    funcs->load_cursor_argb(crtc, image);
-}
-
-static void
-vmw_screen_cursor_init(struct vmw_customizer *vmw)
-{
-    ScrnInfoPtr pScrn = vmw->pScrn;
-    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-    int i;
-
-    /* XXX assume that all crtc's have the same function struct */
-
-    /* Save old struct need to call the old functions as well */
-    vmw->cursor_priv = (void*)(config->crtc[0]->funcs);
-    memcpy(&vmw_screen_crtc_funcs, vmw->cursor_priv, sizeof(xf86CrtcFuncsRec));
-    vmw_screen_crtc_funcs.load_cursor_argb = vmw_screen_cursor_load_argb;
-
-    for (i = 0; i < config->num_crtc; i++)
-       config->crtc[i]->funcs = &vmw_screen_crtc_funcs;
-}
-
-static void
-vmw_screen_cursor_close(struct vmw_customizer *vmw)
-{
-    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(vmw->pScrn);
-    int i;
-
-    vmw_ioctl_cursor_bypass(vmw, 0, 0);
-
-    for (i = 0; i < config->num_crtc; i++)
-       config->crtc[i]->funcs = vmw->cursor_priv;
-}
-
-static Bool
-vmw_screen_init(CustomizerPtr cust, int fd)
-{
-    struct vmw_customizer *vmw = vmw_customizer(cust);
-
-    vmw->fd = fd;
-    vmw_screen_cursor_init(vmw);
-
-    /* if gallium is used then we don't need to do anything more. */
-    if (xorg_has_gallium(vmw->pScrn))
-       return TRUE;
-
-    vmw_video_init(vmw);
-
-    return TRUE;
-}
-
-static Bool
-vmw_screen_close(CustomizerPtr cust)
-{
-    struct vmw_customizer *vmw = vmw_customizer(cust);
-
-    if (!vmw)
-       return TRUE;
-
-    vmw_screen_cursor_close(vmw);
-
-    vmw_video_close(vmw);
-
-    return TRUE;
-}
-
-static Bool
-vmw_screen_enter_vt(CustomizerPtr cust)
-{
-    debug_printf("%s: enter\n", __func__);
-
-    return TRUE;
-}
-
-static Bool
-vmw_screen_leave_vt(CustomizerPtr cust)
-{
-    struct vmw_customizer *vmw = vmw_customizer(cust);
-
-    debug_printf("%s: enter\n", __func__);
-
-    vmw_video_stop_all(vmw);
-
-    return TRUE;
-}
-
-/*
- * Functions for setting up hooks into the xorg state tracker
- */
-
-static Bool (*vmw_screen_pre_init_saved)(ScrnInfoPtr pScrn, int flags) = NULL;
-
-static Bool
-vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
-{
-    struct vmw_customizer *vmw;
-    CustomizerPtr cust;
-
-    vmw = xnfcalloc(1, sizeof(*vmw));
-    if (!vmw)
-       return FALSE;
-
-    cust = &vmw->base;
-
-    cust->winsys_screen_init = vmw_screen_init;
-    cust->winsys_screen_close = vmw_screen_close;
-    cust->winsys_enter_vt = vmw_screen_enter_vt;
-    cust->winsys_leave_vt = vmw_screen_leave_vt;
-    vmw->pScrn = pScrn;
-
-    pScrn->driverPrivate = cust;
-
-    pScrn->PreInit = vmw_screen_pre_init_saved;
-    if (!pScrn->PreInit(pScrn, flags))
-       return FALSE;
-
-    return TRUE;
-}
-
-void
-vmw_screen_set_functions(ScrnInfoPtr pScrn)
-{
-    assert(!vmw_screen_pre_init_saved);
-
-    vmw_screen_pre_init_saved = pScrn->PreInit;
-    pScrn->PreInit = vmw_screen_pre_init;
-}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
deleted file mode 100644 (file)
index de28f06..0000000
+++ /dev/null
@@ -1,1072 +0,0 @@
-/*
- * Copyright 2007 by VMware, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * vmwarevideo.c --
- *
- *      Xv extension support.
- *      See http://www.xfree86.org/current/DESIGN16.html
- *
- */
-
-
-#include "xf86xv.h"
-#include "fourcc.h"
-
-#include "pipe/p_compiler.h"
-/*
- * We can't incude svga_types.h due to conflicting types for Bool.
- */
-typedef int64_t int64;
-typedef uint64_t uint64;
-
-typedef int32_t int32;
-typedef uint32_t uint32;
-
-typedef int16_t int16;
-typedef uint16_t uint16;
-
-typedef int8_t int8;
-typedef uint8_t uint8;
-
-#include "svga/include/svga_reg.h"
-#include "svga/include/svga_escape.h"
-#include "svga/include/svga_overlay.h"
-
-#include "vmw_driver.h"
-
-#include <X11/extensions/Xv.h>
-
-#include "xf86drm.h"
-#include "../core/vmwgfx_drm.h"
-
-#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
-
-/*
- * Number of videos that can be played simultaneously
- */
-#define VMWARE_VID_NUM_PORTS 1
-
-/*
- * Using a dark shade as the default colorKey
- */
-#define VMWARE_VIDEO_COLORKEY 0x100701
-
-/*
- * Maximum dimensions
- */
-#define VMWARE_VID_MAX_WIDTH    2048
-#define VMWARE_VID_MAX_HEIGHT   2048
-
-#define VMWARE_VID_NUM_ENCODINGS 1
-static XF86VideoEncodingRec vmwareVideoEncodings[] =
-{
-    {
-       0,
-       "XV_IMAGE",
-       VMWARE_VID_MAX_WIDTH, VMWARE_VID_MAX_HEIGHT,
-       {1, 1}
-    }
-};
-
-#define VMWARE_VID_NUM_FORMATS 2
-static XF86VideoFormatRec vmwareVideoFormats[] =
-{
-    { 16, TrueColor},
-    { 24, TrueColor}
-};
-
-#define VMWARE_VID_NUM_IMAGES 3
-static XF86ImageRec vmwareVideoImages[] =
-{
-    XVIMAGE_YV12,
-    XVIMAGE_YUY2,
-    XVIMAGE_UYVY
-};
-
-#define VMWARE_VID_NUM_ATTRIBUTES 2
-static XF86AttributeRec vmwareVideoAttributes[] =
-{
-    {
-        XvGettable | XvSettable,
-        0x000000,
-        0xffffff,
-        "XV_COLORKEY"
-    },
-    {
-        XvGettable | XvSettable,
-        0,
-        1,
-        "XV_AUTOPAINT_COLORKEY"
-    }
-};
-
-/*
- * Video frames are stored in a circular list of buffers.
- * Must be power or two, See vmw_video_port_play.
- */
-#define VMWARE_VID_NUM_BUFFERS 1
-
-/*
- * Defines the structure used to hold and pass video data to the host
- */
-struct vmw_video_buffer
-{
-    unsigned handle;
-    int size;
-    void *data;
-    void *extra_data;
-    struct vmw_dma_buffer *buf;
-};
-
-
-/**
- * Structure representing a single video stream, aka port.
- *
- * Ports maps one to one to a SVGA stream. Port is just
- * what Xv calls a SVGA stream.
- */
-struct vmw_video_port
-{
-    /*
-     * Function prototype same as XvPutImage.
-     *
-     * This is either set to vmw_video_port_init or vmw_video_port_play.
-     * At init this function is set to port_init. In port_init we set it
-     * to port_play and call it, after initializing the struct.
-     */
-    int (*play)(ScrnInfoPtr, struct vmw_video_port *,
-                short, short, short, short, short,
-                short, short, short, int, unsigned char*,
-                short, short, RegionPtr);
-
-    /* values to go into the SVGAOverlayUnit */
-    uint32 streamId;
-    uint32 colorKey;
-    uint32 flags;
-
-    /* round robin of buffers */
-    unsigned currBuf;
-    struct vmw_video_buffer bufs[VMWARE_VID_NUM_BUFFERS];
-
-    /* properties that applies to all buffers */
-    int size;
-    int pitches[3];
-    int offsets[3];
-
-    /* things for X */
-    RegionRec clipBoxes;
-    Bool isAutoPaintColorkey;
-};
-
-
-/**
- * Structure holding all the infromation for video.
- */
-struct vmw_video_private
-{
-    int fd;
-
-    /** ports */
-    struct vmw_video_port port[VMWARE_VID_NUM_PORTS];
-
-    /** Used to store port pointers pointers */
-    DevUnion port_ptr[VMWARE_VID_NUM_PORTS];
-};
-
-
-/*
- * Callback functions exported to Xv, prefixed with vmw_xv_*.
- */
-static int vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
-                            short drw_x, short drw_y, short src_w, short src_h,
-                            short drw_w, short drw_h, int image,
-                            unsigned char *buf, short width, short height,
-                            Bool sync, RegionPtr clipBoxes, pointer data,
-                            DrawablePtr dst);
-static void vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool Cleanup);
-static int vmw_xv_query_image_attributes(ScrnInfoPtr pScrn, int format,
-                                         unsigned short *width,
-                                         unsigned short *height, int *pitches,
-                                         int *offsets);
-static int vmw_xv_set_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
-                                     INT32 value, pointer data);
-static int vmw_xv_get_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
-                                     INT32 *value, pointer data);
-static void vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
-                                short vid_w, short vid_h, short drw_w,
-                                short drw_h, unsigned int *p_w,
-                                unsigned int *p_h, pointer data);
-
-
-/*
- * Local functions.
- */
-static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw);
-
-static int vmw_video_port_init(ScrnInfoPtr pScrn,
-                               struct vmw_video_port *port,
-                               short src_x, short src_y, short drw_x,
-                               short drw_y, short src_w, short src_h,
-                               short drw_w, short drw_h, int format,
-                               unsigned char *buf, short width,
-                               short height, RegionPtr clipBoxes);
-static int vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
-                               short src_x, short src_y, short drw_x,
-                               short drw_y, short src_w, short src_h,
-                               short drw_w, short drw_h, int format,
-                               unsigned char *buf, short width,
-                               short height, RegionPtr clipBoxes);
-static void vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port);
-
-static int vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size,
-                                  struct vmw_video_buffer *out);
-static int vmw_video_buffer_free(struct vmw_customizer *vmw,
-                                 struct vmw_video_buffer *out);
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_init --
- *
- *    Initializes Xv support.
- *
- * Results:
- *    TRUE on success, FALSE on error.
- *
- * Side effects:
- *    Xv support is initialized. Memory is allocated for all supported
- *    video streams.
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-vmw_video_init(struct vmw_customizer *vmw)
-{
-    ScrnInfoPtr pScrn = vmw->pScrn;
-    ScreenPtr pScreen = pScrn->pScreen;
-    XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL;
-    XF86VideoAdaptorPtr newAdaptor = NULL;
-    int numAdaptors;
-    unsigned int ntot, nfree;
-
-    debug_printf("%s: enter\n", __func__);
-
-    if (vmw_ioctl_num_streams(vmw, &ntot, &nfree) != 0) {
-        debug_printf("No stream ioctl support\n");
-        return FALSE;
-    }
-
-    if (nfree == 0) {
-        debug_printf("No free streams\n");
-        return FALSE;
-    }
-
-    numAdaptors = xf86XVListGenericAdaptors(pScrn, &overlayAdaptors);
-
-    newAdaptor = vmw_video_init_adaptor(pScrn, vmw);
-    if (!newAdaptor) {
-        debug_printf("Failed to initialize Xv extension\n");
-        return FALSE;
-    }
-
-    if (!numAdaptors) {
-        numAdaptors = 1;
-        overlayAdaptors = &newAdaptor;
-    } else {
-         newAdaptors = xalloc((numAdaptors + 1) *
-                              sizeof(XF86VideoAdaptorPtr*));
-         if (!newAdaptors) {
-            xf86XVFreeVideoAdaptorRec(newAdaptor);
-            return FALSE;
-         }
-
-         memcpy(newAdaptors, overlayAdaptors,
-                numAdaptors * sizeof(XF86VideoAdaptorPtr));
-         newAdaptors[numAdaptors++] = newAdaptor;
-         overlayAdaptors = newAdaptors;
-    }
-
-    if (!xf86XVScreenInit(pScreen, overlayAdaptors, numAdaptors)) {
-        debug_printf("Failed to initialize Xv extension\n");
-        xf86XVFreeVideoAdaptorRec(newAdaptor);
-        return FALSE;
-    }
-
-    if (newAdaptors) {
-        xfree(newAdaptors);
-    }
-
-    debug_printf("Initialized VMware Xv extension successfully\n");
-
-    return TRUE;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_close --
- *
- *    Unitializes video.
- *
- * Results:
- *    TRUE.
- *
- * Side effects:
- *    vmw->video_priv = NULL
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-vmw_video_close(struct vmw_customizer *vmw)
-{
-    ScrnInfoPtr pScrn = vmw->pScrn;
-    struct vmw_video_private *video;
-    int i;
-
-    debug_printf("%s: enter\n", __func__);
-
-    video = vmw->video_priv;
-    if (!video)
-       return TRUE;
-
-    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
-       /* make sure the port is stoped as well */
-       vmw_xv_stop_video(pScrn, &video->port[i], TRUE);
-       vmw_ioctl_unref_stream(vmw, video->port[i].streamId);
-    }
-
-    /* XXX: I'm sure this function is missing code for turning off Xv */
-
-    free(vmw->video_priv);
-    vmw->video_priv = NULL;
-
-    return TRUE;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_stop_all --
- *
- *    Stop all video streams from playing.
- *
- * Results:
- *    None.
- *
- * Side effects:
- *    All buffers are freed.
- *
- *-----------------------------------------------------------------------------
- */
-
-void vmw_video_stop_all(struct vmw_customizer *vmw)
-{
-    ScrnInfoPtr pScrn = vmw->pScrn;
-    struct vmw_video_private *video = vmw->video_priv;
-    int i;
-
-    debug_printf("%s: enter\n", __func__);
-
-    if (!video)
-       return;
-
-    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
-       vmw_xv_stop_video(pScrn, &video->port[i], TRUE);
-    }
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_init_adaptor --
- *
- *    Initializes a XF86VideoAdaptor structure with the capabilities and
- *    functions supported by this video driver.
- *
- * Results:
- *    On success initialized XF86VideoAdaptor struct or NULL on error
- *
- * Side effects:
- *    None.
- *
- *-----------------------------------------------------------------------------
- */
-
-static XF86VideoAdaptorPtr
-vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw)
-{
-    XF86VideoAdaptorPtr adaptor;
-    struct vmw_video_private *video;
-    int i;
-
-    debug_printf("%s: enter \n", __func__);
-
-    adaptor = xf86XVAllocateVideoAdaptorRec(pScrn);
-    if (!adaptor) {
-        debug_printf("Not enough memory\n");
-        return NULL;
-    }
-
-    video = xcalloc(1, sizeof(*video));
-    if (!video) {
-        debug_printf("Not enough memory.\n");
-        xf86XVFreeVideoAdaptorRec(adaptor);
-        return NULL;
-    }
-
-    vmw->video_priv = video;
-
-    adaptor->type = XvInputMask | XvImageMask | XvWindowMask;
-    adaptor->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
-    adaptor->name = "VMware Video Engine";
-    adaptor->nEncodings = VMWARE_VID_NUM_ENCODINGS;
-    adaptor->pEncodings = vmwareVideoEncodings;
-    adaptor->nFormats = VMWARE_VID_NUM_FORMATS;
-    adaptor->pFormats = vmwareVideoFormats;
-    adaptor->nPorts = VMWARE_VID_NUM_PORTS;
-    adaptor->pPortPrivates = video->port_ptr;
-
-    for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
-        vmw_ioctl_claim_stream(vmw, &video->port[i].streamId);
-        video->port[i].play = vmw_video_port_init;
-        video->port[i].flags = SVGA_VIDEO_FLAG_COLORKEY;
-        video->port[i].colorKey = VMWARE_VIDEO_COLORKEY;
-        video->port[i].isAutoPaintColorkey = TRUE;
-        adaptor->pPortPrivates[i].ptr = &video->port[i];
-    }
-
-    adaptor->nAttributes = VMWARE_VID_NUM_ATTRIBUTES;
-    adaptor->pAttributes = vmwareVideoAttributes;
-
-    adaptor->nImages = VMWARE_VID_NUM_IMAGES;
-    adaptor->pImages = vmwareVideoImages;
-
-    adaptor->PutVideo = NULL;
-    adaptor->PutStill = NULL;
-    adaptor->GetVideo = NULL;
-    adaptor->GetStill = NULL;
-    adaptor->StopVideo = vmw_xv_stop_video;
-    adaptor->SetPortAttribute = vmw_xv_set_port_attribute;
-    adaptor->GetPortAttribute = vmw_xv_get_port_attribute;
-    adaptor->QueryBestSize = vmw_xv_query_best_size;
-    adaptor->PutImage = vmw_xv_put_image;
-    adaptor->QueryImageAttributes = vmw_xv_query_image_attributes;
-
-    debug_printf("%s: done %p\n", __func__, adaptor);
-
-    return adaptor;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_port_init --
- *
- *    Initializes a video stream in response to the first PutImage() on a
- *    video stream. The process goes as follows:
- *    - Figure out characteristics according to format
- *    - Allocate offscreen memory
- *    - Pass on video to Play() functions
- *
- * Results:
- *    Success or XvBadAlloc on failure.
- *
- * Side effects:
- *    Video stream is initialized and its first frame sent to the host
- *    (done by VideoPlay() function called at the end)
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port,
-                    short src_x, short src_y, short drw_x,
-                    short drw_y, short src_w, short src_h,
-                    short drw_w, short drw_h, int format,
-                    unsigned char *buf, short width,
-                    short height, RegionPtr clipBoxes)
-{
-    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
-    unsigned short w, h;
-    int i, ret;
-
-    debug_printf("\t%s: id %d, format %d\n", __func__, port->streamId, format);
-
-    w = width;
-    h = height;
-    /* init all the format attributes, used for buffers */
-    port->size = vmw_xv_query_image_attributes(pScrn, format, &w, &h,
-                                               port->pitches, port->offsets);
-
-    if (port->size == -1)
-        return XvBadAlloc;
-
-    port->play = vmw_video_port_play;
-
-    for (i = 0; i < VMWARE_VID_NUM_BUFFERS; ++i) {
-       ret = vmw_video_buffer_alloc(vmw, port->size, &port->bufs[i]);
-       if (ret != Success)
-           break;
-    }
-
-    /* Free all allocated buffers on failure */
-    if (ret != Success) {
-       for (--i; i >= 0; --i) {
-           vmw_video_buffer_free(vmw, &port->bufs[i]);
-       }
-       return ret;
-    }
-
-    port->currBuf = 0;
-
-    REGION_COPY(pScrn->pScreen, &port->clipBoxes, clipBoxes);
-
-    if (port->isAutoPaintColorkey)
-        xf86XVFillKeyHelper(pScrn->pScreen, port->colorKey, clipBoxes);
-
-    return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w, src_h,
-                      drw_w, drw_h, format, buf, width, height, clipBoxes);
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_port_play --
- *
- *    Sends all the attributes associated with the video frame using the
- *    FIFO ESCAPE mechanism to the host.
- *
- * Results:
- *    Always returns Success.
- *
- * Side effects:
- *    None.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
-                    short src_x, short src_y, short drw_x,
-                    short drw_y, short src_w, short src_h,
-                    short drw_w, short drw_h, int format,
-                    unsigned char *buf, short width,
-                    short height, RegionPtr clipBoxes)
-{
-    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
-    struct drm_vmw_control_stream_arg arg;
-    unsigned short w, h;
-    int size;
-    int ret;
-
-    debug_printf("\t%s: enter\n", __func__);
-
-    w = width;
-    h = height;
-
-    /* we don't update the ports size */
-    size = vmw_xv_query_image_attributes(pScrn, format, &w, &h,
-                                         port->pitches, port->offsets);
-
-    if (size > port->size) {
-        debug_printf("\t%s: Increase in size of Xv video frame streamId:%d.\n",
-                     __func__, port->streamId);
-        vmw_xv_stop_video(pScrn, port, TRUE);
-        return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w,
-                          src_h, drw_w, drw_h, format, buf, width, height,
-                          clipBoxes);
-    }
-
-    memcpy(port->bufs[port->currBuf].data, buf, port->size);
-
-    memset(&arg, 0, sizeof(arg));
-
-    arg.stream_id = port->streamId;
-    arg.enabled = TRUE;
-    arg.flags = port->flags;
-    arg.color_key = port->colorKey;
-    arg.handle = port->bufs[port->currBuf].handle;
-    arg.format = format;
-    arg.size = port->size;
-    arg.width = w;
-    arg.height = h;
-    arg.src.x = src_x;
-    arg.src.y = src_y;
-    arg.src.w = src_w;
-    arg.src.h = src_h;
-    arg.dst.x = drw_x;
-    arg.dst.y = drw_y;
-    arg.dst.w = drw_w;
-    arg.dst.h = drw_h;
-    arg.pitch[0] = port->pitches[0];
-    arg.pitch[1] = port->pitches[1];
-    arg.pitch[2] = port->pitches[2];
-    arg.offset = 0;
-
-    /*
-     *  Update the clipList and paint the colorkey, if required.
-     */
-    if (!REGION_EQUAL(pScrn->pScreen, &port->clipBoxes, clipBoxes)) {
-        REGION_COPY(pScrn->pScreen, &port->clipBoxes, clipBoxes);
-        if (port->isAutoPaintColorkey) {
-            xf86XVFillKeyHelper(pScrn->pScreen, port->colorKey, clipBoxes);
-        }
-    }
-
-    ret = drmCommandWrite(vmw->fd, DRM_VMW_CONTROL_STREAM, &arg, sizeof(arg));
-    if (ret) {
-       vmw_video_port_cleanup(pScrn, port);
-       return XvBadAlloc;
-    }
-
-    if (++(port->currBuf) >= VMWARE_VID_NUM_BUFFERS)
-       port->currBuf = 0;
-
-    return Success;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_port_cleanup --
- *
- *    Frees up all resources (if any) taken by a video stream.
- *
- * Results:
- *    None.
- *
- * Side effects:
- *    Same as above.
- *
- *-----------------------------------------------------------------------------
- */
-
-static void
-vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port)
-{
-    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
-    uint32 id, colorKey, flags;
-    Bool isAutoPaintColorkey;
-    int i;
-
-    debug_printf("\t%s: enter\n", __func__);
-
-    for (i = 0; i < VMWARE_VID_NUM_BUFFERS; i++) {
-       vmw_video_buffer_free(vmw, &port->bufs[i]);
-    }
-
-    /*
-     * reset stream for next video
-     */
-    id = port->streamId;
-    colorKey = port->colorKey;
-    flags = port->flags;
-    isAutoPaintColorkey = port->isAutoPaintColorkey;
-
-    memset(port, 0, sizeof(*port));
-
-    port->streamId = id;
-    port->play = vmw_video_port_init;
-    port->colorKey = colorKey;
-    port->flags = flags;
-    port->isAutoPaintColorkey = isAutoPaintColorkey;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_buffer_alloc --
- *
- *    Allocates and map a kernel buffer to be used as data storage.
- *
- * Results:
- *    XvBadAlloc on failure, otherwise Success.
- *
- * Side effects:
- *    Calls into the kernel, sets members of out.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size,
-                       struct vmw_video_buffer *out)
-{
-    out->buf = vmw_ioctl_buffer_create(vmw, size, &out->handle);
-    if (!out->buf)
-       return XvBadAlloc;
-
-    out->data = vmw_ioctl_buffer_map(vmw, out->buf);
-    if (!out->data) {
-       vmw_ioctl_buffer_destroy(vmw, out->buf);
-
-       out->handle = 0;
-       out->buf = NULL;
-
-       return XvBadAlloc;
-    }
-
-    out->size = size;
-    out->extra_data = xcalloc(1, size);
-
-    debug_printf("\t\t%s: allocated buffer %p of size %i\n", __func__, out, size);
-
-    return Success;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_video_buffer_free --
- *
- *    Frees and unmaps an allocated kernel buffer.
- *
- * Results:
- *    Success.
- *
- * Side effects:
- *    Calls into the kernel, sets members of out to 0.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-vmw_video_buffer_free(struct vmw_customizer *vmw,
-                      struct vmw_video_buffer *out)
-{
-    if (out->size == 0)
-       return Success;
-
-    xfree(out->extra_data);
-    vmw_ioctl_buffer_unmap(vmw, out->buf);
-    vmw_ioctl_buffer_destroy(vmw, out->buf);
-
-    out->buf = NULL;
-    out->data = NULL;
-    out->handle = 0;
-    out->size = 0;
-
-    debug_printf("\t\t%s: freed buffer %p\n", __func__, out);
-
-    return Success;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_xv_put_image --
- *
- *    Main video playback function. It copies the passed data which is in
- *    the specified format (e.g. FOURCC_YV12) into the overlay.
- *
- *    If sync is TRUE the driver should not return from this
- *    function until it is through reading the data from buf.
- *
- * Results:
- *    Success or XvBadAlloc on failure
- *
- * Side effects:
- *    Video port will be played(initialized if 1st frame) on success
- *    or will fail on error.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
-                 short drw_x, short drw_y, short src_w, short src_h,
-                 short drw_w, short drw_h, int format,
-                 unsigned char *buf, short width, short height,
-                 Bool sync, RegionPtr clipBoxes, pointer data,
-                 DrawablePtr dst)
-{
-    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
-    struct vmw_video_port *port = data;
-
-    debug_printf("%s: enter (%u, %u) (%ux%u) (%u, %u) (%ux%u) (%ux%u)\n", __func__,
-                src_x, src_y, src_w, src_h,
-                drw_x, drw_y, drw_w, drw_h,
-                width, height);
-
-    if (!vmw->video_priv)
-        return XvBadAlloc;
-
-    return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w, src_h,
-                      drw_w, drw_h, format, buf, width, height, clipBoxes);
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_xv_stop_video --
- *
- *    Called when we should stop playing video for a particular stream. If
- *    Cleanup is FALSE, the "stop" operation is only temporary, and thus we
- *    don't do anything. If Cleanup is TRUE we kill the video port by
- *    sending a message to the host and freeing up the stream.
- *
- * Results:
- *    None.
- *
- * Side effects:
- *    See above.
- *
- *-----------------------------------------------------------------------------
- */
-
-static void
-vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
-{
-    struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
-    struct vmw_video_port *port = data;
-    struct drm_vmw_control_stream_arg arg;
-    int ret;
-
-    debug_printf("%s: cleanup is %s\n", __func__, cleanup ? "TRUE" : "FALSE");
-
-    if (!vmw->video_priv)
-        return;
-
-    if (!cleanup)
-        return;
-
-
-    memset(&arg, 0, sizeof(arg));
-    arg.stream_id = port->streamId;
-    arg.enabled = FALSE;
-
-    ret = drmCommandWrite(vmw->fd, DRM_VMW_CONTROL_STREAM, &arg, sizeof(arg));
-    assert(ret == 0);
-
-    vmw_video_port_cleanup(pScrn, port);
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_xv_query_image_attributes --
- *
- *    From the spec: This function is called to let the driver specify how data
- *    for a particular image of size width by height should be stored.
- *    Sometimes only the size and corrected width and height are needed. In
- *    that case pitches and offsets are NULL.
- *
- * Results:
- *    The size of the memory required for the image, or -1 on error.
- *
- * Side effects:
- *    None.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-vmw_xv_query_image_attributes(ScrnInfoPtr pScrn, int format,
-                              unsigned short *width, unsigned short *height,
-                              int *pitches, int *offsets)
-{
-    INT32 size, tmp;
-
-    if (*width > VMWARE_VID_MAX_WIDTH) {
-        *width = VMWARE_VID_MAX_WIDTH;
-    }
-    if (*height > VMWARE_VID_MAX_HEIGHT) {
-        *height = VMWARE_VID_MAX_HEIGHT;
-    }
-
-    *width = (*width + 1) & ~1;
-    if (offsets != NULL) {
-        offsets[0] = 0;
-    }
-
-    switch (format) {
-       case FOURCC_YV12:
-           *height = (*height + 1) & ~1;
-           size = (*width + 3) & ~3;
-           if (pitches) {
-               pitches[0] = size;
-           }
-           size *= *height;
-           if (offsets) {
-               offsets[1] = size;
-           }
-           tmp = ((*width >> 1) + 3) & ~3;
-           if (pitches) {
-                pitches[1] = pitches[2] = tmp;
-           }
-           tmp *= (*height >> 1);
-           size += tmp;
-           if (offsets) {
-               offsets[2] = size;
-           }
-           size += tmp;
-           break;
-       case FOURCC_UYVY:
-       case FOURCC_YUY2:
-           size = *width * 2;
-           if (pitches) {
-               pitches[0] = size;
-           }
-           size *= *height;
-           break;
-       default:
-           debug_printf("Query for invalid video format %d\n", format);
-           return -1;
-    }
-    return size;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_xv_set_port_attribute --
- *
- *    From the spec: A port may have particular attributes such as colorKey, hue,
- *    saturation, brightness or contrast. Xv clients set these
- *    attribute values by sending attribute strings (Atoms) to the server.
- *
- * Results:
- *    Success if the attribute exists and XvBadAlloc otherwise.
- *
- * Side effects:
- *    The respective attribute gets the new value.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-vmw_xv_set_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
-                          INT32 value, pointer data)
-{
-    struct vmw_video_port *port = data;
-    Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
-    Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
-
-    if (attribute == xvColorKey) {
-        debug_printf("%s: Set colorkey:0x%x\n", __func__, (unsigned)value);
-        port->colorKey = value;
-    } else if (attribute == xvAutoPaint) {
-        debug_printf("%s: Set autoPaint: %s\n", __func__, value? "TRUE": "FALSE");
-        port->isAutoPaintColorkey = value;
-    } else {
-        return XvBadAlloc;
-    }
-
-    return Success;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_xv_get_port_attribute --
- *
- *    From the spec: A port may have particular attributes such as hue,
- *    saturation, brightness or contrast. Xv clients get these
- *    attribute values by sending attribute strings (Atoms) to the server
- *
- * Results:
- *    Success if the attribute exists and XvBadAlloc otherwise.
- *
- * Side effects:
- *    "value" contains the requested attribute on success.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-vmw_xv_get_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
-                          INT32 *value, pointer data)
-{
-    struct vmw_video_port *port = data;
-    Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
-    Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
-
-    if (attribute == xvColorKey) {
-        *value = port->colorKey;
-    } else if (attribute == xvAutoPaint) {
-        *value = port->isAutoPaintColorkey;
-    } else {
-        return XvBadAlloc;
-    }
-
-    return Success;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * vmw_xv_query_best_size --
- *
- *    From the spec: QueryBestSize provides the client with a way to query what
- *    the destination dimensions would end up being if they were to request
- *    that an area vid_w by vid_h from the video stream be scaled to rectangle
- *    of drw_w by drw_h on the screen. Since it is not expected that all
- *    hardware will be able to get the target dimensions exactly, it is
- *    important that the driver provide this function.
- *
- *    This function seems to never be called, but to be on the safe side
- *    we apply the same logic that QueryImageAttributes has for width
- *    and height.
- *
- * Results:
- *    None.
- *
- * Side effects:
- *    None.
- *
- *-----------------------------------------------------------------------------
- */
-
-static void
-vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
-                       short vid_w, short vid_h, short drw_w,
-                       short drw_h, unsigned int *p_w,
-                       unsigned int *p_h, pointer data)
-{
-    *p_w = (drw_w + 1) & ~1;
-    *p_h = drw_h;
-
-    return;
-}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c
deleted file mode 100644 (file)
index 87aad25..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/**********************************************************
- * Copyright 2008-2009 VMware, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-/**
- * @file
- * Glue file for Xorg State Tracker.
- *
- * @author Alan Hourihane <alanh@tungstengraphics.com>
- * @author Jakob Bornecrantz <wallbraker@gmail.com>
- */
-
-#include "vmw_hook.h"
-
-
-/*
- * Defines and modinfo
- */
-
-#define VMWGFX_DRIVER_NAME "vmwgfx"
-
-#define VMW_STRING_INNER(s) #s
-#define VMW_STRING(str) VMW_STRING_INNER(str)
-
-#define VMWGFX_VERSION_MAJOR 11
-#define VMWGFX_VERSION_MINOR 0
-#define VMWGFX_VERSION_PATCH 0
-#define VMWGFX_VERSION_STRING_MAJOR VMW_STRING(VMWGFX_VERSION_MAJOR)
-#define VMWGFX_VERSION_STRING_MINOR VMW_STRING(VMWGFX_VERSION_MINOR)
-#define VMWGFX_VERSION_STRING_PATCH VMW_STRING(VMWGFX_VERSION_PATCH)
-
-#define VMWGFX_DRIVER_VERSION \
-   (VMWGFX_VERSION_MAJOR * 65536 + VMWGFX_VERSION_MINOR * 256 + VMWGFX_VERSION_PATCH)
-#define VMWGFX_DRIVER_VERSION_STRING \
-    VMWGFX_VERSION_STRING_MAJOR "." VMWGFX_VERSION_STRING_MINOR \
-    "." VMWGFX_VERSION_STRING_PATCH
-
-/*
- * Standard four digit version string expected by VMware Tools installer.
- * As the driver's version is only  {major, minor, patchlevel}, simply append an
- * extra zero for the fourth digit.
- */
-#ifdef __GNUC__
-_X_EXPORT const char vmwgfx_drv_modinfo[] __attribute__((section(".modinfo"),unused)) =
-    "version=" VMWGFX_DRIVER_VERSION_STRING ".0";
-#endif
-
-static void vmw_xorg_identify(int flags);
-_X_EXPORT Bool vmw_xorg_pci_probe(DriverPtr driver,
-                                 int entity_num,
-                                 struct pci_device *device,
-                                 intptr_t match_data);
-
-
-/*
- * Tables
- */
-
-static const struct pci_id_match vmw_xorg_device_match[] = {
-    {0x15ad, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
-    {0, 0, 0, 0, 0, 0, 0},
-};
-
-static SymTabRec vmw_xorg_chipsets[] = {
-    {PCI_MATCH_ANY, "VMware SVGA Device"},
-    {-1, NULL}
-};
-
-static PciChipsets vmw_xorg_pci_devices[] = {
-    {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
-    {-1, -1, NULL}
-};
-
-static XF86ModuleVersionInfo vmw_xorg_version = {
-    VMWGFX_DRIVER_NAME,
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    VMWGFX_VERSION_MAJOR, VMWGFX_VERSION_MINOR, VMWGFX_VERSION_PATCH,
-    ABI_CLASS_VIDEODRV,
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_VIDEODRV,
-    {0, 0, 0, 0}
-};
-
-/*
- * Xorg driver exported structures
- */
-
-_X_EXPORT DriverRec vmwgfx = {
-    1,
-    VMWGFX_DRIVER_NAME,
-    vmw_xorg_identify,
-    NULL,
-    xorg_tracker_available_options,
-    NULL,
-    0,
-    NULL,
-    vmw_xorg_device_match,
-    vmw_xorg_pci_probe
-};
-
-static MODULESETUPPROTO(vmw_xorg_setup);
-
-_X_EXPORT XF86ModuleData vmwgfxModuleData = {
-    &vmw_xorg_version,
-    vmw_xorg_setup,
-    NULL
-};
-
-
-/*
- * Xorg driver functions
- */
-
-static pointer
-vmw_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = 0;
-
-    /* This module should be loaded only once, but check to be sure.
-     */
-    if (!setupDone) {
-       setupDone = 1;
-       xf86AddDriver(&vmwgfx, module, HaveDriverFuncs);
-
-       /*
-        * The return value must be non-NULL on success even though there
-        * is no TearDownProc.
-        */
-       return (pointer) 1;
-    } else {
-       if (errmaj)
-           *errmaj = LDR_ONCEONLY;
-       return NULL;
-    }
-}
-
-static void
-vmw_xorg_identify(int flags)
-{
-    xf86PrintChipsets("vmwgfx", "Driver for VMware SVGA device",
-                     vmw_xorg_chipsets);
-}
-
-_X_EXPORT Bool
-vmw_xorg_pci_probe(DriverPtr driver,
-         int entity_num, struct pci_device *device, intptr_t match_data)
-{
-    ScrnInfoPtr scrn = NULL;
-    EntityInfoPtr entity;
-
-    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, vmw_xorg_pci_devices,
-                              NULL, NULL, NULL, NULL, NULL);
-    if (scrn != NULL) {
-       scrn->driverVersion = 1;
-       scrn->driverName = "vmwgfx";
-       scrn->name = "vmwgfx";
-       scrn->Probe = NULL;
-
-       entity = xf86GetEntityInfo(entity_num);
-
-       /* Use all the functions from the xorg tracker */
-       xorg_tracker_set_functions(scrn);
-
-       vmw_screen_set_functions(scrn);
-    }
-    return scrn != NULL;
-}
diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript
deleted file mode 100644 (file)
index 1267fc6..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#######################################################################
-# SConscript for xlib winsys
-
-
-Import('*')
-
-if env['platform'] == 'windows':
-
-    env = env.Clone()
-
-    env.Append(CPPPATH = [
-        '#/src/gallium/include',
-        '#/src/gallium/auxiliary',
-        '#/src/gallium/drivers',
-    ])
-
-    ws_gdi = env.ConvenienceLibrary(
-        target = 'ws_gdi',
-        source = [
-           'gdi_sw_winsys.c',
-        ]
-    )
-    Export('ws_gdi')
diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.c b/src/gallium/winsys/gdi/gdi_sw_winsys.c
deleted file mode 100644 (file)
index f5c0b7d..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-
-/**
- * @file
- * GDI software rasterizer support.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#include <windows.h>
-
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "state_tracker/sw_winsys.h"
-#include "gdi_sw_winsys.h"
-
-
-struct gdi_sw_displaytarget
-{
-   enum pipe_format format;
-   unsigned width;
-   unsigned height;
-   unsigned stride;
-
-   unsigned size;
-
-   void *data;
-
-   BITMAPINFO bmi;
-};
-
-
-/** Cast wrapper */
-static INLINE struct gdi_sw_displaytarget *
-gdi_sw_displaytarget( struct sw_displaytarget *buf )
-{
-   return (struct gdi_sw_displaytarget *)buf;
-}
-
-
-static boolean
-gdi_sw_is_displaytarget_format_supported( struct sw_winsys *ws,
-                                                enum pipe_format format )
-{
-   switch(format) {
-   case PIPE_FORMAT_B8G8R8X8_UNORM:
-   case PIPE_FORMAT_B8G8R8A8_UNORM:
-      return TRUE;
-
-   /* TODO: Support other formats possible with BMPs, as described in 
-    * http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx */
-      
-   default:
-      return FALSE;
-   }
-}
-
-
-static void *
-gdi_sw_displaytarget_map(struct sw_winsys *ws,
-                               struct sw_displaytarget *dt,
-                               unsigned flags )
-{
-   struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
-
-   return gdt->data;
-}
-
-
-static void
-gdi_sw_displaytarget_unmap(struct sw_winsys *ws,
-                                 struct sw_displaytarget *dt )
-{
-
-}
-
-
-static void
-gdi_sw_displaytarget_destroy(struct sw_winsys *winsys,
-                                   struct sw_displaytarget *dt)
-{
-   struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
-
-   align_free(gdt->data);
-   FREE(gdt);
-}
-
-
-static struct sw_displaytarget *
-gdi_sw_displaytarget_create(struct sw_winsys *winsys,
-                                  enum pipe_format format,
-                                  unsigned width, unsigned height,
-                                  unsigned alignment,
-                                  unsigned *stride)
-{
-   struct gdi_sw_displaytarget *gdt;
-   unsigned cpp;
-   unsigned bpp;
-   
-   gdt = CALLOC_STRUCT(gdi_sw_displaytarget);
-   if(!gdt)
-      goto no_gdt;
-
-   gdt->format = format;
-   gdt->width = width;
-   gdt->height = height;
-
-   bpp = util_format_get_blocksizebits(format);
-   cpp = util_format_get_blocksize(format);
-   
-   gdt->stride = align(width * cpp, alignment);
-   gdt->size = gdt->stride * height;
-   
-   gdt->data = align_malloc(gdt->size, alignment);
-   if(!gdt->data)
-      goto no_data;
-
-   gdt->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-   gdt->bmi.bmiHeader.biWidth = gdt->stride / cpp;
-   gdt->bmi.bmiHeader.biHeight= -(long)height;
-   gdt->bmi.bmiHeader.biPlanes = 1;
-   gdt->bmi.bmiHeader.biBitCount = bpp;
-   gdt->bmi.bmiHeader.biCompression = BI_RGB;
-   gdt->bmi.bmiHeader.biSizeImage = 0;
-   gdt->bmi.bmiHeader.biXPelsPerMeter = 0;
-   gdt->bmi.bmiHeader.biYPelsPerMeter = 0;
-   gdt->bmi.bmiHeader.biClrUsed = 0;
-   gdt->bmi.bmiHeader.biClrImportant = 0;
-
-   *stride = gdt->stride;
-   return (struct sw_displaytarget *)gdt;
-
-no_data:
-   FREE(gdt);
-no_gdt:
-   return NULL;
-}
-
-
-void
-gdi_sw_display( struct sw_winsys *winsys,
-                struct sw_displaytarget *dt,
-                HDC hDC )
-{
-    struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
-
-    StretchDIBits(hDC,
-                  0, 0, gdt->width, gdt->height,
-                  0, 0, gdt->width, gdt->height,
-                  gdt->data, &gdt->bmi, 0, SRCCOPY);
-}
-
-static void
-gdi_sw_displaytarget_display(struct sw_winsys *winsys, 
-                             struct sw_displaytarget *dt,
-                             void *context_private)
-{
-    /* nasty:
-     */
-    HDC hDC = (HDC)context_private;
-
-    gdi_sw_display(winsys, dt, hDC);
-}
-
-
-static void
-gdi_sw_destroy(struct sw_winsys *winsys)
-{
-   FREE(winsys);
-}
-
-struct sw_winsys *
-gdi_create_sw_winsys(void)
-{
-   static struct sw_winsys *winsys;
-
-   winsys = CALLOC_STRUCT(sw_winsys);
-   if(!winsys)
-      return NULL;
-
-   winsys->destroy = gdi_sw_destroy;
-   winsys->is_displaytarget_format_supported = gdi_sw_is_displaytarget_format_supported;
-   winsys->displaytarget_create = gdi_sw_displaytarget_create;
-   winsys->displaytarget_map = gdi_sw_displaytarget_map;
-   winsys->displaytarget_unmap = gdi_sw_displaytarget_unmap;
-   winsys->displaytarget_display = gdi_sw_displaytarget_display;
-   winsys->displaytarget_destroy = gdi_sw_displaytarget_destroy;
-
-   return winsys;
-}
-
diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.h b/src/gallium/winsys/gdi/gdi_sw_winsys.h
deleted file mode 100644 (file)
index 4bbcb47..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef GDI_SW_WINSYS_H
-#define GDI_SW_WINSYS_H
-
-#include <windows.h>
-
-#include "pipe/p_compiler.h"
-#include "state_tracker/sw_winsys.h"
-
-void gdi_sw_display( struct sw_winsys *winsys,
-                     struct sw_displaytarget *dt,
-                     HDC hDC );
-
-struct sw_winsys *
-gdi_create_sw_winsys(void);
-
-#endif
diff --git a/src/gallium/winsys/i915/drm/Makefile b/src/gallium/winsys/i915/drm/Makefile
new file mode 100644 (file)
index 0000000..a67b9e8
--- /dev/null
@@ -0,0 +1,16 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i915drm
+
+C_SOURCES = \
+       i915_drm_batchbuffer.c \
+       i915_drm_buffer.c \
+       i915_drm_fence.c \
+       i915_drm_api.c
+
+LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
+
+LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/i915/drm/SConscript b/src/gallium/winsys/i915/drm/SConscript
new file mode 100644 (file)
index 0000000..ba29ac7
--- /dev/null
@@ -0,0 +1,17 @@
+Import('*')
+
+env = env.Clone()
+
+i915drm_sources = [
+    'i915_drm_api.c',
+    'i915_drm_batchbuffer.c',
+    'i915_drm_buffer.c',
+    'i915_drm_fence.c',
+]
+
+i915drm = env.ConvenienceLibrary(
+    target ='i915drm',
+    source = i915drm_sources,
+)
+
+Export('i915drm')
diff --git a/src/gallium/winsys/i915/drm/i915_drm_api.c b/src/gallium/winsys/i915/drm/i915_drm_api.c
new file mode 100644 (file)
index 0000000..6bb0aec
--- /dev/null
@@ -0,0 +1,109 @@
+#include <stdio.h>
+
+#include "state_tracker/drm_api.h"
+
+#include "i915_drm_winsys.h"
+#include "util/u_memory.h"
+
+#include "i915/i915_context.h"
+#include "i915/i915_screen.h"
+
+#include "trace/tr_drm.h"
+
+/*
+ * Helper functions
+ */
+
+
+static void
+i915_drm_get_device_id(unsigned int *device_id)
+{
+   char path[512];
+   FILE *file;
+   void *shutup_gcc;
+
+   /*
+    * FIXME: Fix this up to use a drm ioctl or whatever.
+    */
+
+   snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
+   file = fopen(path, "r");
+   if (!file) {
+      return;
+   }
+
+   shutup_gcc = fgets(path, sizeof(path), file);
+   (void) shutup_gcc;
+   sscanf(path, "%x", device_id);
+   fclose(file);
+}
+
+static void
+i915_drm_winsys_destroy(struct i915_winsys *iws)
+{
+   struct i915_drm_winsys *idws = i915_drm_winsys(iws);
+
+   drm_intel_bufmgr_destroy(idws->pools.gem);
+
+   FREE(idws);
+}
+
+static struct pipe_screen *
+i915_drm_create_screen(struct drm_api *api, int drmFD,
+                       struct drm_create_screen_arg *arg)
+{
+   struct i915_drm_winsys *idws;
+   unsigned int deviceID;
+
+   if (arg != NULL) {
+      switch(arg->mode) {
+      case DRM_CREATE_NORMAL:
+         break;
+      default:
+         return NULL;
+      }
+   }
+
+   idws = CALLOC_STRUCT(i915_drm_winsys);
+   if (!idws)
+      return NULL;
+
+   i915_drm_get_device_id(&deviceID);
+
+   i915_drm_winsys_init_batchbuffer_functions(idws);
+   i915_drm_winsys_init_buffer_functions(idws);
+   i915_drm_winsys_init_fence_functions(idws);
+
+   idws->fd = drmFD;
+   idws->id = deviceID;
+   idws->max_batch_size = 16 * 4096;
+
+   idws->base.destroy = i915_drm_winsys_destroy;
+
+   idws->pools.gem = drm_intel_bufmgr_gem_init(idws->fd, idws->max_batch_size);
+   drm_intel_bufmgr_gem_enable_reuse(idws->pools.gem);
+
+   idws->dump_cmd = debug_get_bool_option("INTEL_DUMP_CMD", FALSE);
+
+   return i915_create_screen(&idws->base, deviceID);
+}
+
+static void
+destroy(struct drm_api *api)
+{
+
+}
+
+struct drm_api intel_drm_api =
+{
+   .name = "i915",
+   .driver_name = "i915",
+   .create_screen = i915_drm_create_screen,
+   .destroy = destroy,
+};
+
+struct drm_api *
+drm_api_create()
+{
+   return trace_drm_create(&intel_drm_api);
+}
diff --git a/src/gallium/winsys/i915/drm/i915_drm_batchbuffer.c b/src/gallium/winsys/i915/drm/i915_drm_batchbuffer.c
new file mode 100644 (file)
index 0000000..102f59d
--- /dev/null
@@ -0,0 +1,244 @@
+
+#include "i915_drm_winsys.h"
+#include "util/u_memory.h"
+
+#include "i915_drm.h"
+
+#define BATCH_RESERVED 16
+
+#define INTEL_DEFAULT_RELOCS 100
+#define INTEL_MAX_RELOCS 400
+
+#define INTEL_BATCH_NO_CLIPRECTS 0x1
+#define INTEL_BATCH_CLIPRECTS    0x2
+
+#undef INTEL_RUN_SYNC
+#undef INTEL_MAP_BATCHBUFFER
+#undef INTEL_MAP_GTT
+#define INTEL_ALWAYS_FLUSH
+
+struct i915_drm_batchbuffer
+{
+   struct i915_winsys_batchbuffer base;
+
+   size_t actual_size;
+
+   drm_intel_bo *bo;
+};
+
+static INLINE struct i915_drm_batchbuffer *
+i915_drm_batchbuffer(struct i915_winsys_batchbuffer *batch)
+{
+   return (struct i915_drm_batchbuffer *)batch;
+}
+
+static void
+i915_drm_batchbuffer_reset(struct i915_drm_batchbuffer *batch)
+{
+   struct i915_drm_winsys *idws = i915_drm_winsys(batch->base.iws);
+   int ret;
+
+   if (batch->bo)
+      drm_intel_bo_unreference(batch->bo);
+   batch->bo = drm_intel_bo_alloc(idws->pools.gem,
+                                  "gallium3d_batchbuffer",
+                                  batch->actual_size,
+                                  4096);
+
+#ifdef INTEL_MAP_BATCHBUFFER
+#ifdef INTEL_MAP_GTT
+   ret = drm_intel_gem_bo_map_gtt(batch->bo);
+#else
+   ret = drm_intel_bo_map(batch->bo, TRUE);
+#endif
+   assert(ret == 0);
+   batch->base.map = batch->bo->virtual;
+#else
+   (void)ret;
+#endif
+
+   memset(batch->base.map, 0, batch->actual_size);
+   batch->base.ptr = batch->base.map;
+   batch->base.size = batch->actual_size - BATCH_RESERVED;
+   batch->base.relocs = 0;
+}
+
+static struct i915_winsys_batchbuffer *
+i915_drm_batchbuffer_create(struct i915_winsys *iws)
+{
+   struct i915_drm_winsys *idws = i915_drm_winsys(iws);
+   struct i915_drm_batchbuffer *batch = CALLOC_STRUCT(i915_drm_batchbuffer);
+
+   batch->actual_size = idws->max_batch_size;
+
+#ifdef INTEL_MAP_BATCHBUFFER
+   batch->base.map = NULL;
+#else
+   batch->base.map = MALLOC(batch->actual_size);
+#endif
+   batch->base.ptr = NULL;
+   batch->base.size = 0;
+
+   batch->base.relocs = 0;
+   batch->base.max_relocs = 300;/*INTEL_DEFAULT_RELOCS;*/
+
+   batch->base.iws = iws;
+
+   i915_drm_batchbuffer_reset(batch);
+
+   return &batch->base;
+}
+
+static int
+i915_drm_batchbuffer_reloc(struct i915_winsys_batchbuffer *ibatch,
+                            struct i915_winsys_buffer *buffer,
+                            enum i915_winsys_buffer_usage usage,
+                            unsigned pre_add)
+{
+   struct i915_drm_batchbuffer *batch = i915_drm_batchbuffer(ibatch);
+   unsigned write_domain = 0;
+   unsigned read_domain = 0;
+   unsigned offset;
+   int ret = 0;
+
+   assert(batch->base.relocs < batch->base.max_relocs);
+
+   if (usage == I915_USAGE_SAMPLER) {
+      write_domain = 0;
+      read_domain = I915_GEM_DOMAIN_SAMPLER;
+
+   } else if (usage == I915_USAGE_RENDER) {
+      write_domain = I915_GEM_DOMAIN_RENDER;
+      read_domain = I915_GEM_DOMAIN_RENDER;
+
+   } else if (usage == I915_USAGE_2D_TARGET) {
+      write_domain = I915_GEM_DOMAIN_RENDER;
+      read_domain = I915_GEM_DOMAIN_RENDER;
+
+   } else if (usage == I915_USAGE_2D_SOURCE) {
+      write_domain = 0;
+      read_domain = I915_GEM_DOMAIN_RENDER;
+
+   } else if (usage == I915_USAGE_VERTEX) {
+      write_domain = 0;
+      read_domain = I915_GEM_DOMAIN_VERTEX;
+
+   } else {
+      assert(0);
+      return -1;
+   }
+
+   offset = (unsigned)(batch->base.ptr - batch->base.map);
+
+   ret = drm_intel_bo_emit_reloc(batch->bo, offset,
+                                 intel_bo(buffer), pre_add,
+                                 read_domain,
+                                 write_domain);
+
+   ((uint32_t*)batch->base.ptr)[0] = intel_bo(buffer)->offset + pre_add;
+   batch->base.ptr += 4;
+
+   if (!ret)
+      batch->base.relocs++;
+
+   return ret;
+}
+
+static void
+i915_drm_batchbuffer_flush(struct i915_winsys_batchbuffer *ibatch,
+                            struct pipe_fence_handle **fence)
+{
+   struct i915_drm_batchbuffer *batch = i915_drm_batchbuffer(ibatch);
+   unsigned used = 0;
+   int ret = 0;
+   int i;
+
+   assert(i915_winsys_batchbuffer_space(ibatch) >= 0);
+
+   used = batch->base.ptr - batch->base.map;
+   assert((used & 3) == 0);
+
+
+#ifdef INTEL_ALWAYS_FLUSH
+   /* MI_FLUSH | FLUSH_MAP_CACHE */
+   i915_winsys_batchbuffer_dword(ibatch, (0x4<<23)|(1<<0));
+   used += 4;
+#endif
+
+   if ((used & 4) == 0) {
+      /* MI_NOOP */
+      i915_winsys_batchbuffer_dword(ibatch, 0);
+   }
+   /* MI_BATCH_BUFFER_END */
+   i915_winsys_batchbuffer_dword(ibatch, (0xA<<23));
+
+   used = batch->base.ptr - batch->base.map;
+   assert((used & 4) == 0);
+
+#ifdef INTEL_MAP_BATCHBUFFER
+#ifdef INTEL_MAP_GTT
+   drm_intel_gem_bo_unmap_gtt(batch->bo);
+#else
+   drm_intel_bo_unmap(batch->bo);
+#endif
+#else
+   drm_intel_bo_subdata(batch->bo, 0, used, batch->base.map);
+#endif
+
+   /* Do the sending to HW */
+   ret = drm_intel_bo_exec(batch->bo, used, NULL, 0, 0);
+   assert(ret == 0);
+
+   if (i915_drm_winsys(ibatch->iws)->dump_cmd) {
+      unsigned *ptr;
+      drm_intel_bo_map(batch->bo, FALSE);
+      ptr = (unsigned*)batch->bo->virtual;
+
+      debug_printf("%s:\n", __func__);
+      for (i = 0; i < used / 4; i++, ptr++) {
+         debug_printf("\t%08x:    %08x\n", i*4, *ptr);
+      }
+
+      drm_intel_bo_unmap(batch->bo);
+   } else {
+#ifdef INTEL_RUN_SYNC
+      drm_intel_bo_map(batch->bo, FALSE);
+      drm_intel_bo_unmap(batch->bo);
+#endif
+   }
+
+   if (fence) {
+      ibatch->iws->fence_reference(ibatch->iws, fence, NULL);
+
+#ifdef INTEL_RUN_SYNC
+      /* we run synced to GPU so just pass null */
+      (*fence) = i915_drm_fence_create(NULL);
+#else
+      (*fence) = i915_drm_fence_create(batch->bo);
+#endif
+   }
+
+   i915_drm_batchbuffer_reset(batch);
+}
+
+static void
+i915_drm_batchbuffer_destroy(struct i915_winsys_batchbuffer *ibatch)
+{
+   struct i915_drm_batchbuffer *batch = i915_drm_batchbuffer(ibatch);
+
+   if (batch->bo)
+      drm_intel_bo_unreference(batch->bo);
+
+#ifndef INTEL_MAP_BATCHBUFFER
+   FREE(batch->base.map);
+#endif
+   FREE(batch);
+}
+
+void i915_drm_winsys_init_batchbuffer_functions(struct i915_drm_winsys *idws)
+{
+   idws->base.batchbuffer_create = i915_drm_batchbuffer_create;
+   idws->base.batchbuffer_reloc = i915_drm_batchbuffer_reloc;
+   idws->base.batchbuffer_flush = i915_drm_batchbuffer_flush;
+   idws->base.batchbuffer_destroy = i915_drm_batchbuffer_destroy;
+}
diff --git a/src/gallium/winsys/i915/drm/i915_drm_buffer.c b/src/gallium/winsys/i915/drm/i915_drm_buffer.c
new file mode 100644 (file)
index 0000000..3bd8502
--- /dev/null
@@ -0,0 +1,217 @@
+
+#include "state_tracker/drm_api.h"
+#include "i915_drm_winsys.h"
+#include "util/u_memory.h"
+
+#include "i915_drm.h"
+
+static struct i915_winsys_buffer *
+i915_drm_buffer_create(struct i915_winsys *iws,
+                        unsigned size, unsigned alignment,
+                        enum i915_winsys_buffer_type type)
+{
+   struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer);
+   struct i915_drm_winsys *idws = i915_drm_winsys(iws);
+   drm_intel_bufmgr *pool;
+   char *name;
+
+   if (!buf)
+      return NULL;
+
+   buf->magic = 0xDEAD1337;
+   buf->flinked = FALSE;
+   buf->flink = 0;
+   buf->map_gtt = FALSE;
+
+   if (type == I915_NEW_TEXTURE) {
+      name = "gallium3d_texture";
+      pool = idws->pools.gem;
+   } else if (type == I915_NEW_VERTEX) {
+      name = "gallium3d_vertex";
+      pool = idws->pools.gem;
+      buf->map_gtt = TRUE;
+   } else if (type == I915_NEW_SCANOUT) {
+      name = "gallium3d_scanout";
+      pool = idws->pools.gem;
+      buf->map_gtt = TRUE;
+   } else {
+      assert(0);
+      name = "gallium3d_unknown";
+      pool = idws->pools.gem;
+   }
+
+   buf->bo = drm_intel_bo_alloc(pool, name, size, alignment);
+
+   if (!buf->bo)
+      goto err;
+
+   return (struct i915_winsys_buffer *)buf;
+
+err:
+   assert(0);
+   FREE(buf);
+   return NULL;
+}
+
+static struct i915_winsys_buffer *
+i915_drm_buffer_from_handle(struct i915_winsys *iws,
+                             struct winsys_handle *whandle,
+                             unsigned *stride)
+{
+   struct i915_drm_winsys *idws = i915_drm_winsys(iws);
+   struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer);
+   uint32_t tile = 0, swizzle = 0;
+
+   if (!buf)
+      return NULL;
+
+   buf->magic = 0xDEAD1337;
+   buf->bo = drm_intel_bo_gem_create_from_name(idws->pools.gem, "gallium3d_from_handle", whandle->handle);
+   buf->flinked = TRUE;
+   buf->flink = whandle->handle;
+
+   if (!buf->bo)
+      goto err;
+
+   drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle);
+   if (tile != I915_TILE_NONE)
+      buf->map_gtt = TRUE;
+
+   *stride = whandle->stride;
+
+   return (struct i915_winsys_buffer *)buf;
+
+err:
+   FREE(buf);
+   return NULL;
+}
+
+static boolean
+i915_drm_buffer_get_handle(struct i915_winsys *iws,
+                            struct i915_winsys_buffer *buffer,
+                            struct winsys_handle *whandle,
+                            unsigned stride)
+{
+   struct i915_drm_buffer *buf = i915_drm_buffer(buffer);
+
+   if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
+      if (!buf->flinked) {
+         if (drm_intel_bo_flink(buf->bo, &buf->flink))
+            return FALSE;
+         buf->flinked = TRUE;
+      }
+
+      whandle->handle = buf->flink;
+   } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
+      whandle->handle = buf->bo->handle;
+   } else {
+      assert(!"unknown usage");
+      return FALSE;
+   }
+
+   whandle->stride = stride;
+   return TRUE;
+}
+
+static int
+i915_drm_buffer_set_fence_reg(struct i915_winsys *iws,
+                               struct i915_winsys_buffer *buffer,
+                               unsigned stride,
+                               enum i915_winsys_buffer_tile tile)
+{
+   struct i915_drm_buffer *buf = i915_drm_buffer(buffer);
+   assert(I915_TILING_NONE == I915_TILE_NONE);
+   assert(I915_TILING_X == I915_TILE_X);
+   assert(I915_TILING_Y == I915_TILE_Y);
+
+   if (tile != I915_TILE_NONE) {
+      assert(buf->map_count == 0);
+      buf->map_gtt = TRUE;
+   }
+
+   return drm_intel_bo_set_tiling(buf->bo, &tile, stride);
+}
+
+static void *
+i915_drm_buffer_map(struct i915_winsys *iws,
+                     struct i915_winsys_buffer *buffer,
+                     boolean write)
+{
+   struct i915_drm_buffer *buf = i915_drm_buffer(buffer);
+   drm_intel_bo *bo = intel_bo(buffer);
+   int ret = 0;
+
+   assert(bo);
+
+   if (buf->map_count)
+      goto out;
+
+   if (buf->map_gtt)
+      ret = drm_intel_gem_bo_map_gtt(bo);
+   else
+      ret = drm_intel_bo_map(bo, write);
+
+   buf->ptr = bo->virtual;
+
+   assert(ret == 0);
+out:
+   if (ret)
+      return NULL;
+
+   buf->map_count++;
+   return buf->ptr;
+}
+
+static void
+i915_drm_buffer_unmap(struct i915_winsys *iws,
+                       struct i915_winsys_buffer *buffer)
+{
+   struct i915_drm_buffer *buf = i915_drm_buffer(buffer);
+
+   if (--buf->map_count)
+      return;
+
+   if (buf->map_gtt)
+      drm_intel_gem_bo_unmap_gtt(intel_bo(buffer));
+   else
+      drm_intel_bo_unmap(intel_bo(buffer));
+}
+
+static int
+i915_drm_buffer_write(struct i915_winsys *iws,
+                       struct i915_winsys_buffer *buffer,
+                       size_t offset,
+                       size_t size,
+                       const void *data)
+{
+   struct i915_drm_buffer *buf = i915_drm_buffer(buffer);
+
+   return drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
+}
+
+static void
+i915_drm_buffer_destroy(struct i915_winsys *iws,
+                         struct i915_winsys_buffer *buffer)
+{
+   drm_intel_bo_unreference(intel_bo(buffer));
+
+#ifdef DEBUG
+   i915_drm_buffer(buffer)->magic = 0;
+   i915_drm_buffer(buffer)->bo = NULL;
+#endif
+
+   FREE(buffer);
+}
+
+void
+i915_drm_winsys_init_buffer_functions(struct i915_drm_winsys *idws)
+{
+   idws->base.buffer_create = i915_drm_buffer_create;
+   idws->base.buffer_from_handle = i915_drm_buffer_from_handle;
+   idws->base.buffer_get_handle = i915_drm_buffer_get_handle;
+   idws->base.buffer_set_fence_reg = i915_drm_buffer_set_fence_reg;
+   idws->base.buffer_map = i915_drm_buffer_map;
+   idws->base.buffer_unmap = i915_drm_buffer_unmap;
+   idws->base.buffer_write = i915_drm_buffer_write;
+   idws->base.buffer_destroy = i915_drm_buffer_destroy;
+}
diff --git a/src/gallium/winsys/i915/drm/i915_drm_fence.c b/src/gallium/winsys/i915/drm/i915_drm_fence.c
new file mode 100644 (file)
index 0000000..30ebf48
--- /dev/null
@@ -0,0 +1,83 @@
+
+#include "i915_drm_winsys.h"
+#include "util/u_memory.h"
+#include "util/u_atomic.h"
+#include "util/u_inlines.h"
+
+/**
+ * Because gem does not have fence's we have to create our own fences.
+ *
+ * They work by keeping the batchbuffer around and checking if that has
+ * been idled. If bo is NULL fence has expired.
+ */
+struct i915_drm_fence
+{
+   struct pipe_reference reference;
+   drm_intel_bo *bo;
+};
+
+
+struct pipe_fence_handle *
+i915_drm_fence_create(drm_intel_bo *bo)
+{
+   struct i915_drm_fence *fence = CALLOC_STRUCT(i915_drm_fence);
+
+   pipe_reference_init(&fence->reference, 1);
+   /* bo is null if fence already expired */
+   if (bo) {
+      drm_intel_bo_reference(bo);
+      fence->bo = bo;
+   }
+
+   return (struct pipe_fence_handle *)fence;
+}
+
+static void
+i915_drm_fence_reference(struct i915_winsys *iws,
+                          struct pipe_fence_handle **ptr,
+                          struct pipe_fence_handle *fence)
+{
+   struct i915_drm_fence *old = (struct i915_drm_fence *)*ptr;
+   struct i915_drm_fence *f = (struct i915_drm_fence *)fence;
+
+   if (pipe_reference(&((struct i915_drm_fence *)(*ptr))->reference, &f->reference)) {
+      if (old->bo)
+         drm_intel_bo_unreference(old->bo);
+      FREE(old);
+   }
+   *ptr = fence;
+}
+
+static int
+i915_drm_fence_signalled(struct i915_winsys *iws,
+                          struct pipe_fence_handle *fence)
+{
+   assert(0);
+
+   return 0;
+}
+
+static int
+i915_drm_fence_finish(struct i915_winsys *iws,
+                       struct pipe_fence_handle *fence)
+{
+   struct i915_drm_fence *f = (struct i915_drm_fence *)fence;
+
+   /* fence already expired */
+   if (!f->bo)
+      return 0;
+
+   drm_intel_bo_wait_rendering(f->bo);
+   drm_intel_bo_unreference(f->bo);
+   f->bo = NULL;
+
+   return 0;
+}
+
+void
+i915_drm_winsys_init_fence_functions(struct i915_drm_winsys *idws)
+{
+   idws->base.fence_reference = i915_drm_fence_reference;
+   idws->base.fence_signalled = i915_drm_fence_signalled;
+   idws->base.fence_finish = i915_drm_fence_finish;
+}
diff --git a/src/gallium/winsys/i915/drm/i915_drm_winsys.h b/src/gallium/winsys/i915/drm/i915_drm_winsys.h
new file mode 100644 (file)
index 0000000..217c4a7
--- /dev/null
@@ -0,0 +1,77 @@
+
+#ifndef INTEL_DRM_WINSYS_H
+#define INTEL_DRM_WINSYS_H
+
+#include "i915/i915_batchbuffer.h"
+
+#include "drm.h"
+#include "intel_bufmgr.h"
+
+
+/*
+ * Winsys
+ */
+
+
+struct i915_drm_winsys
+{
+   struct i915_winsys base;
+
+   boolean dump_cmd;
+
+   int fd; /**< Drm file discriptor */
+
+   unsigned id;
+
+   size_t max_batch_size;
+
+   struct {
+      drm_intel_bufmgr *gem;
+   } pools;
+};
+
+static INLINE struct i915_drm_winsys *
+i915_drm_winsys(struct i915_winsys *iws)
+{
+   return (struct i915_drm_winsys *)iws;
+}
+
+struct i915_drm_winsys * i915_drm_winsys_create(int fd, unsigned pci_id);
+struct pipe_fence_handle * i915_drm_fence_create(drm_intel_bo *bo);
+
+void i915_drm_winsys_init_batchbuffer_functions(struct i915_drm_winsys *idws);
+void i915_drm_winsys_init_buffer_functions(struct i915_drm_winsys *idws);
+void i915_drm_winsys_init_fence_functions(struct i915_drm_winsys *idws);
+
+
+/*
+ * Buffer
+ */
+
+
+struct i915_drm_buffer {
+   unsigned magic;
+
+   drm_intel_bo *bo;
+
+   void *ptr;
+   unsigned map_count;
+   boolean map_gtt;
+
+   boolean flinked;
+   unsigned flink;
+};
+
+static INLINE struct i915_drm_buffer *
+i915_drm_buffer(struct i915_winsys_buffer *buffer)
+{
+   return (struct i915_drm_buffer *)buffer;
+}
+
+static INLINE drm_intel_bo *
+intel_bo(struct i915_winsys_buffer *buffer)
+{
+   return i915_drm_buffer(buffer)->bo;
+}
+
+#endif
diff --git a/src/gallium/winsys/i965/drm/Makefile b/src/gallium/winsys/i965/drm/Makefile
new file mode 100644 (file)
index 0000000..bbb71e2
--- /dev/null
@@ -0,0 +1,14 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i965drm
+
+C_SOURCES = \
+       i965_drm_buffer.c \
+       i965_drm_api.c
+
+LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
+
+LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/i965/drm/SConscript b/src/gallium/winsys/i965/drm/SConscript
new file mode 100644 (file)
index 0000000..150ab19
--- /dev/null
@@ -0,0 +1,15 @@
+Import('*')
+
+env = env.Clone()
+
+i965drm_sources = [
+    'i965_drm_api.c',
+    'i965_drm_buffer.c',
+]
+
+i965drm = env.ConvenienceLibrary(
+    target ='i965drm',
+    source = i965drm_sources,
+)
+
+Export('i965drm')
diff --git a/src/gallium/winsys/i965/drm/i965_drm_api.c b/src/gallium/winsys/i965/drm/i965_drm_api.c
new file mode 100644 (file)
index 0000000..9072a18
--- /dev/null
@@ -0,0 +1,122 @@
+
+#include <stdio.h>
+#include "state_tracker/drm_api.h"
+
+#include "i965_drm_winsys.h"
+#include "util/u_memory.h"
+
+#include "i965/brw_context.h"        /* XXX: shouldn't be doing this */
+#include "i965/brw_screen.h"         /* XXX: shouldn't be doing this */
+
+#include "trace/tr_drm.h"
+
+#include "../../sw/drm/sw_drm_api.h"
+
+/*
+ * Helper functions
+ */
+
+
+static void
+i965_libdrm_get_device_id(unsigned int *device_id)
+{
+   char path[512];
+   FILE *file;
+   void *shutup_gcc;
+
+   /*
+    * FIXME: Fix this up to use a drm ioctl or whatever.
+    */
+
+   snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
+   file = fopen(path, "r");
+   if (!file) {
+      return;
+   }
+
+   shutup_gcc = fgets(path, sizeof(path), file);
+   sscanf(path, "%x", device_id);
+   fclose(file);
+}
+
+static void
+i965_libdrm_winsys_destroy(struct brw_winsys_screen *iws)
+{
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(iws);
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   drm_intel_bufmgr_destroy(idws->gem);
+
+   FREE(idws);
+}
+
+static struct pipe_screen *
+i965_libdrm_create_screen(struct drm_api *api, int drmFD,
+                          struct drm_create_screen_arg *arg)
+{
+   struct i965_libdrm_winsys *idws;
+   unsigned int deviceID;
+
+   debug_printf("%s\n", __FUNCTION__);
+
+   if (arg != NULL) {
+      switch(arg->mode) {
+      case DRM_CREATE_NORMAL:
+         break;
+      default:
+         return NULL;
+      }
+   }
+
+   idws = CALLOC_STRUCT(i965_libdrm_winsys);
+   if (!idws)
+      return NULL;
+
+   i965_libdrm_get_device_id(&deviceID);
+
+   i965_libdrm_winsys_init_buffer_functions(idws);
+
+   idws->fd = drmFD;
+   idws->id = deviceID;
+
+   idws->base.destroy = i965_libdrm_winsys_destroy;
+
+   idws->gem = drm_intel_bufmgr_gem_init(idws->fd, BRW_BATCH_SIZE);
+   drm_intel_bufmgr_gem_enable_reuse(idws->gem);
+
+   idws->send_cmd = !debug_get_bool_option("BRW_NO_HW", FALSE);
+
+   return brw_create_screen(&idws->base, deviceID);
+}
+
+
+static void
+destroy(struct drm_api *api)
+{
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+}
+
+struct drm_api i965_libdrm_api =
+{
+   .name = "i965",
+   .create_screen = i965_libdrm_create_screen,
+   .destroy = destroy,
+};
+
+struct drm_api *
+drm_api_create()
+{
+   struct drm_api *api = NULL;
+
+   if (api == NULL && debug_get_bool_option("BRW_SOFTPIPE", FALSE))
+      api = sw_drm_api_create(&i965_libdrm_api);
+
+   if (api == NULL)
+      api = &i965_libdrm_api;
+
+   return trace_drm_create(api);
+}
diff --git a/src/gallium/winsys/i965/drm/i965_drm_buffer.c b/src/gallium/winsys/i965/drm/i965_drm_buffer.c
new file mode 100644 (file)
index 0000000..33a1749
--- /dev/null
@@ -0,0 +1,503 @@
+
+#include "state_tracker/drm_api.h"
+#include "i965_drm_winsys.h"
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+
+#include "i915_drm.h"
+#include "intel_bufmgr.h"
+
+
+
+const char *names[BRW_BUFFER_TYPE_MAX] = {
+   "TEXTURE",
+   "SCANOUT",
+   "VERTEX",
+   "CURBE",
+   "QUERY",
+   "SHADER_CONSTANTS",
+   "WM_SCRATCH",
+   "BATCH",
+   "GENERAL_STATE",
+   "SURFACE_STATE",
+   "PIXEL",
+   "GENERIC",
+};
+
+const char *usages[BRW_USAGE_MAX] = {
+   "STATE",
+   "QUERY_RESULT",
+   "RENDER_TARGET",
+   "DEPTH_BUFFER",
+   "BLIT_SOURCE",
+   "BLIT_DEST",
+   "SAMPLER",
+   "VERTEX",
+   "SCRATCH"
+};
+
+
+const char *data_types[BRW_DATA_MAX] =
+{
+   "GS: CC_VP",
+   "GS: CC_UNIT",
+   "GS: WM_PROG",
+   "GS: SAMPLER_DEFAULT_COLOR",
+   "GS: SAMPLER",
+   "GS: WM_UNIT",
+   "GS: SF_PROG",
+   "GS: SF_VP",
+   "GS: SF_UNIT",
+   "GS: VS_UNIT",
+   "GS: VS_PROG",
+   "GS: GS_UNIT",
+   "GS: GS_PROG",
+   "GS: CLIP_VP",
+   "GS: CLIP_UNIT",
+   "GS: CLIP_PROG",
+   "SS: SURFACE",
+   "SS: SURF_BIND",
+   "CONSTANT DATA",
+   "BATCH DATA",
+   "(untyped)"
+};
+
+static enum pipe_error 
+i965_libdrm_bo_alloc(struct brw_winsys_screen *sws,
+                     enum brw_buffer_type type,
+                     unsigned size,
+                     unsigned alignment,
+                     struct brw_winsys_buffer **bo_out)
+{
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
+   struct i965_libdrm_buffer *buf;
+
+   if (BRW_DUMP)
+      debug_printf("%s type %s sz %d align %d\n",
+                  __FUNCTION__, names[type], size, alignment );
+
+   buf = CALLOC_STRUCT(i965_libdrm_buffer);
+   if (!buf)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   switch (type) {
+   case BRW_BUFFER_TYPE_TEXTURE:
+/* case BRW_BUFFER_TYPE_SCANOUT:*/
+   case BRW_BUFFER_TYPE_VERTEX:
+   case BRW_BUFFER_TYPE_CURBE:
+   case BRW_BUFFER_TYPE_QUERY:
+   case BRW_BUFFER_TYPE_SHADER_CONSTANTS:
+   case BRW_BUFFER_TYPE_SHADER_SCRATCH:
+   case BRW_BUFFER_TYPE_BATCH:
+   case BRW_BUFFER_TYPE_GENERAL_STATE:
+   case BRW_BUFFER_TYPE_SURFACE_STATE:
+   case BRW_BUFFER_TYPE_PIXEL:
+   case BRW_BUFFER_TYPE_GENERIC:
+      break;
+   case BRW_BUFFER_TYPE_SCANOUT:
+      buf->map_gtt = TRUE;
+      break;
+   default:
+      assert(0);
+      break;
+   }
+
+   buf->bo = drm_intel_bo_alloc(idws->gem, 
+                                names[type], 
+                                size, 
+                                alignment);
+
+   if (!buf->bo)
+      goto err;
+
+   pipe_reference_init(&buf->base.reference, 1);
+   buf->base.size = size;
+   buf->base.sws = sws;
+
+   *bo_out = &buf->base;
+   return PIPE_OK;
+
+err:
+   assert(0);
+   FREE(buf);
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+static enum pipe_error
+i965_libdrm_bo_from_handle(struct brw_winsys_screen *sws,
+                           struct winsys_handle *whandle,
+                           unsigned *stride,
+                           unsigned *tile,
+                           struct brw_winsys_buffer **bo_out)
+{
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
+   struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer);
+   uint32_t swizzle = 0;
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (!buf)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   pipe_reference_init(&buf->base.reference, 1);
+   buf->bo = drm_intel_bo_gem_create_from_name(idws->gem, "FROM_HANDLE", whandle->handle);
+   buf->base.size = buf->bo->size;
+   buf->base.sws = &idws->base;
+   buf->flinked = TRUE;
+   buf->flink = whandle->handle;
+
+
+   if (!buf->bo)
+      goto err;
+
+   drm_intel_bo_get_tiling(buf->bo, &buf->tiling, &swizzle);
+   if (buf->tiling != 0)
+      buf->map_gtt = TRUE;
+
+   *tile = buf->tiling;
+   *stride = whandle->stride;
+
+   *bo_out = &buf->base;
+   return PIPE_OK;
+
+err:
+   FREE(buf);
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+static enum pipe_error
+i965_libdrm_bo_get_handle(struct brw_winsys_buffer *buffer,
+                          struct winsys_handle *whandle,
+                          unsigned stride)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
+      if (!buf->flinked) {
+         if (drm_intel_bo_flink(buf->bo, &buf->flink))
+            return PIPE_ERROR_BAD_INPUT;
+         buf->flinked = TRUE;
+      }
+
+      whandle->handle = buf->flink;
+   } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
+      whandle->handle = buf->bo->handle;
+   } else {
+      assert(!"unknown usage");
+      return PIPE_ERROR_BAD_INPUT;
+   }
+
+   whandle->stride = stride;
+   return PIPE_OK;
+}
+
+static void 
+i965_libdrm_bo_destroy(struct brw_winsys_buffer *buffer)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   drm_intel_bo_unreference(buf->bo);
+   FREE(buffer);
+}
+
+static enum pipe_error
+i965_libdrm_bo_emit_reloc(struct brw_winsys_buffer *buffer,
+                          enum brw_buffer_usage usage,
+                          unsigned delta,
+                          unsigned offset,
+                          struct brw_winsys_buffer *buffer2)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   struct i965_libdrm_buffer *buf2 = i965_libdrm_buffer(buffer2);
+   int read, write;
+   int ret;
+
+   if (BRW_DUMP)
+      debug_printf("%s buf %p offset %x delta %x buf2 %p/%s/%s\n",
+                  __FUNCTION__, (void *)buffer, 
+                  offset, delta,
+                  (void *)buffer2, names[buf2->data_type], usages[usage]);
+
+   switch (usage) {
+   case BRW_USAGE_STATE:
+      read = I915_GEM_DOMAIN_INSTRUCTION;
+      write = 0;
+      break;
+   case BRW_USAGE_QUERY_RESULT:
+      read = I915_GEM_DOMAIN_INSTRUCTION;
+      write = I915_GEM_DOMAIN_INSTRUCTION;
+      break;
+   case BRW_USAGE_RENDER_TARGET:
+      read = I915_GEM_DOMAIN_RENDER;
+      write = 0;
+      break;
+   case BRW_USAGE_DEPTH_BUFFER:
+      read = I915_GEM_DOMAIN_RENDER;
+      write = I915_GEM_DOMAIN_RENDER;
+      break;
+   case BRW_USAGE_BLIT_SOURCE:
+      read = 0;
+      write = I915_GEM_DOMAIN_RENDER;
+      break;
+   case BRW_USAGE_BLIT_DEST:
+      read = I915_GEM_DOMAIN_RENDER;
+      write = I915_GEM_DOMAIN_RENDER;
+      break;
+   case BRW_USAGE_SAMPLER:
+      read = I915_GEM_DOMAIN_SAMPLER;
+      write = 0;
+      break;
+   case BRW_USAGE_VERTEX:
+      read = I915_GEM_DOMAIN_VERTEX;
+      write = 0;
+      break;
+   case BRW_USAGE_SCRATCH:
+      read = 0;
+      write = 0;
+      break;
+   default:
+      assert(0);
+      return -1;
+   }
+
+   /* Needed??
+   ((uint32_t *)buf->bo->virtual)[offset/4] = (delta +
+                                              buf2->bo->offset);
+    */
+
+   ret = dri_bo_emit_reloc( buf->bo, read, write, delta, offset, buf2->bo );
+   if (ret)
+      return -1;
+
+   return 0;
+}
+
+static enum pipe_error 
+i965_libdrm_bo_exec(struct brw_winsys_buffer *buffer,
+                    unsigned bytes_used)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
+   int ret;
+
+   if (BRW_DUMP)
+      debug_printf("execute buffer %p, bytes %d\n", (void *)buffer, bytes_used);
+
+   if (idws->send_cmd) {
+      ret = dri_bo_exec(buf->bo, bytes_used, NULL, 0, 0);
+      if (ret)
+         return PIPE_ERROR;
+   }
+
+   return PIPE_OK;
+}
+
+static enum pipe_error
+i965_libdrm_bo_subdata(struct brw_winsys_buffer *buffer,
+                       enum brw_buffer_data_type data_type,
+                       size_t offset,
+                       size_t size,
+                       const void *data,
+                       const struct brw_winsys_reloc *reloc,
+                       unsigned nr_reloc)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
+   int ret, i;
+
+   (void)data_type;
+
+   if (BRW_DUMP)
+      debug_printf("%s buf %p off %d sz %d %s relocs: %d\n", 
+                  __FUNCTION__, 
+                  (void *)buffer, offset, size, 
+                  data_types[data_type],
+                  nr_reloc);
+
+   if (BRW_DUMP)
+      brw_dump_data( idws->id,
+                    data_type,
+                    buf->bo->offset + offset, 
+                    data, size );
+
+   /* XXX: use bo_map_gtt/memcpy/unmap_gtt under some circumstances???
+    */
+   ret = drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
+   if (ret)
+      return PIPE_ERROR;
+  
+   for (i = 0; i < nr_reloc; i++) {
+      i965_libdrm_bo_emit_reloc(buffer, reloc[i].usage, reloc[i].delta,
+                                reloc[i].offset, reloc[i].bo);
+   }
+
+   return PIPE_OK;
+}
+
+static boolean 
+i965_libdrm_bo_is_busy(struct brw_winsys_buffer *buffer)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   boolean ret;
+
+   if (BRW_DUMP)
+      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
+
+   ret = drm_intel_bo_busy(buf->bo);
+
+   if (BRW_DUMP)
+      debug_printf("  --> %d\n", ret);
+
+   return ret;
+}
+
+static boolean 
+i965_libdrm_bo_references(struct brw_winsys_buffer *a,
+                          struct brw_winsys_buffer *b)
+{
+   struct i965_libdrm_buffer *bufa = i965_libdrm_buffer(a);
+   struct i965_libdrm_buffer *bufb = i965_libdrm_buffer(b);
+   boolean ret;
+
+   if (BRW_DUMP)
+      debug_printf("%s %p %p\n", __FUNCTION__, (void *)a, (void *)b);
+
+   ret = drm_intel_bo_references(bufa->bo, bufb->bo);
+
+   if (BRW_DUMP)
+      debug_printf("  --> %d\n", ret);
+
+   return ret;
+}
+
+/* XXX: couldn't this be handled by returning true/false on
+ * bo_emit_reloc?
+ */
+static enum pipe_error
+i965_libdrm_check_aperture_space(struct brw_winsys_screen *iws,
+                                 struct brw_winsys_buffer **buffers,
+                                 unsigned count)
+{
+   static drm_intel_bo *bos[128];
+   int i;
+   int ret;
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (count > Elements(bos)) {
+      assert(0);
+      return FALSE;
+   }
+
+   for (i = 0; i < count; i++)
+      bos[i] = i965_libdrm_buffer(buffers[i])->bo;
+
+   /* XXX: converting from ??? to pipe_error:
+    */
+   ret = dri_bufmgr_check_aperture_space(bos, count);
+
+   if (BRW_DUMP)
+      debug_printf("  --> %d (ok == %d)\n", ret, PIPE_OK);
+
+   return ret;
+}
+
+static void *
+i965_libdrm_bo_map(struct brw_winsys_buffer *buffer,
+                   enum brw_buffer_data_type data_type,
+                   unsigned offset,
+                   unsigned length,
+                   boolean write,
+                   boolean discard,
+                   boolean flush_explicit)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   int ret;
+
+
+   if (BRW_DUMP)
+      debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer, 
+                  write ? "read/write" : "read",
+                  write ? data_types[data_type] : "");
+
+   if (!buf->map_count) {
+      if (buf->map_gtt) {
+         ret = drm_intel_gem_bo_map_gtt(buf->bo);
+         if (ret)
+            return NULL;
+      }
+      else {
+         ret = drm_intel_bo_map(buf->bo, write);
+         if (ret)
+            return NULL;
+      }
+   }
+
+   buf->data_type = data_type;
+   buf->map_count++;
+   return buf->bo->virtual;
+}
+
+static void
+i965_libdrm_bo_flush_range(struct brw_winsys_buffer *buffer,
+                           unsigned offset,
+                           unsigned length)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+   struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
+
+   if (BRW_DUMP)
+      debug_printf("%s %s offset %d len %d\n", __FUNCTION__,
+                  data_types[buf->data_type],
+                  offset, length);
+
+   if (BRW_DUMP)
+      brw_dump_data( idws->id,
+                    buf->data_type,
+                    buf->bo->offset + offset, 
+                    buf->bo->virtual + offset, 
+                    length );
+}
+
+static void 
+i965_libdrm_bo_unmap(struct brw_winsys_buffer *buffer)
+{
+   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+
+   if (BRW_DUMP)
+      debug_printf("%s\n", __FUNCTION__);
+
+   if (--buf->map_count > 0)
+      return;
+
+   if (buf->map_gtt)
+      drm_intel_gem_bo_unmap_gtt(buf->bo);
+   else
+      drm_intel_bo_unmap(buf->bo);
+}
+
+void
+i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws)
+{
+   idws->base.bo_alloc             = i965_libdrm_bo_alloc;
+   idws->base.bo_from_handle       = i965_libdrm_bo_from_handle;
+   idws->base.bo_get_handle        = i965_libdrm_bo_get_handle;
+   idws->base.bo_destroy           = i965_libdrm_bo_destroy;
+   idws->base.bo_emit_reloc        = i965_libdrm_bo_emit_reloc;
+   idws->base.bo_exec              = i965_libdrm_bo_exec;
+   idws->base.bo_subdata           = i965_libdrm_bo_subdata;
+   idws->base.bo_is_busy           = i965_libdrm_bo_is_busy;
+   idws->base.bo_references        = i965_libdrm_bo_references;
+   idws->base.check_aperture_space = i965_libdrm_check_aperture_space;
+   idws->base.bo_map               = i965_libdrm_bo_map;
+   idws->base.bo_flush_range       = i965_libdrm_bo_flush_range;
+   idws->base.bo_unmap             = i965_libdrm_bo_unmap;
+}
diff --git a/src/gallium/winsys/i965/drm/i965_drm_winsys.h b/src/gallium/winsys/i965/drm/i965_drm_winsys.h
new file mode 100644 (file)
index 0000000..c6a7d4a
--- /dev/null
@@ -0,0 +1,64 @@
+
+#ifndef INTEL_DRM_WINSYS_H
+#define INTEL_DRM_WINSYS_H
+
+#include "i965/brw_winsys.h"
+
+#include "drm.h"
+#include "intel_bufmgr.h"
+
+
+
+/*
+ * Winsys
+ */
+
+
+struct i965_libdrm_winsys
+{
+   struct brw_winsys_screen base;
+   drm_intel_bufmgr *gem;
+
+   boolean send_cmd;
+
+   int fd; /**< Drm file discriptor */
+
+   unsigned id;
+};
+
+static INLINE struct i965_libdrm_winsys *
+i965_libdrm_winsys(struct brw_winsys_screen *iws)
+{
+   return (struct i965_libdrm_winsys *)iws;
+}
+
+struct i965_libdrm_winsys *i965_libdrm_winsys_create(int fd, unsigned pci_id);
+
+void i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws);
+
+
+/* Buffer.  
+ */
+struct i965_libdrm_buffer {
+   struct brw_winsys_buffer base;
+
+   drm_intel_bo *bo;
+
+   void *ptr;
+   unsigned map_count;
+   unsigned data_type;         /* valid while mapped */
+   unsigned tiling;
+
+   boolean map_gtt;
+   boolean flinked;
+   unsigned flink;
+};
+
+static INLINE struct i965_libdrm_buffer *
+i965_libdrm_buffer(struct brw_winsys_buffer *buffer)
+{
+   return (struct i965_libdrm_buffer *)buffer;
+}
+
+
+#endif
diff --git a/src/gallium/winsys/i965/xlib/Makefile b/src/gallium/winsys/i965/xlib/Makefile
new file mode 100644 (file)
index 0000000..3730db6
--- /dev/null
@@ -0,0 +1,97 @@
+# src/gallium/winsys/i965/xlib/Makefile
+
+# This makefile produces a "stand-alone" libGL.so which is based on
+# Xlib (no DRI HW acceleration)
+
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+
+GL_MAJOR = 1
+GL_MINOR = 5
+GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
+
+
+INCLUDE_DIRS = \
+       -I$(TOP)/include \
+       -I$(TOP)/src/mesa \
+       -I$(TOP)/src/mesa/main \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/drivers/i965 \
+       -I$(TOP)/src/gallium/drivers/i965/include \
+       -I$(TOP)/src/gallium/state_trackers/glx/xlib \
+       -I$(TOP)/src/gallium/auxiliary \
+       -I/usr/include/drm
+
+XLIB_WINSYS_SOURCES = \
+       xlib_i965.c \
+
+
+
+XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
+
+
+
+LIBS = \
+       $(TOP)/src/gallium/drivers/i965/libi965.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \
+       $(TOP)/src/mesa/libglapi.a \
+       $(TOP)/src/mesa/libmesagallium.a \
+       $(GALLIUM_AUXILIARIES) 
+
+#      $(TOP)/src/gallium/drivers/i965/lib/libi9xx.a \
+
+.SUFFIXES : .cpp
+
+.c.o:
+       $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@
+
+.cpp.o:
+       $(CXX) -c $(INCLUDE_DIRS) $(DEFINES) $(CXXFLAGS) $< -o $@
+
+
+
+default: $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME)
+
+$(TOP)/$(LIB_DIR)/gallium:
+       @ mkdir -p $(TOP)/$(LIB_DIR)/gallium
+
+# Make the libGL.so library
+$(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS) Makefile
+       $(TOP)/bin/mklib -o $(GL_LIB) \
+               -linker "$(CC)" \
+               -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
+               -install $(TOP)/$(LIB_DIR)/gallium \
+               $(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \
+               -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS)
+
+
+depend: $(XLIB_WINSYS_SOURCES)
+       @ echo "running $(MKDEP)"
+       @ rm -f depend  # workaround oops on gutsy?!?
+       @ touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_WINSYS_SOURCES) \
+               > /dev/null 2>/dev/null
+
+
+install: default
+       $(INSTALL) -d $(INSTALL_DIR)/include/GL
+       $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
+       @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
+               $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
+       fi
+
+
+# Emacs tags
+tags:
+       etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
+
+clean:
+       -rm -f *.o
+
+
+include depend
diff --git a/src/gallium/winsys/i965/xlib/xlib_i965.c b/src/gallium/winsys/i965/xlib/xlib_i965.c
new file mode 100644 (file)
index 0000000..063e9f6
--- /dev/null
@@ -0,0 +1,503 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * 
+ **************************************************************************/
+
+/*
+ * Authors:
+ *   Keith Whitwell
+ *   Brian Paul
+ */
+
+
+#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "pipe/p_error.h"
+#include "pipe/p_context.h"
+
+#include "xm_public.h"
+
+#include "i965/brw_winsys.h"
+#include "i965/brw_screen.h"
+#include "i965/brw_reg.h"
+#include "i965/brw_structs_dump.h"
+
+#define MAX_VRAM (128*1024*1024)
+
+
+
+extern int brw_disasm (FILE *file, 
+                       const struct brw_instruction *inst,
+                       unsigned count );
+
+extern int intel_decode(const uint32_t *data, 
+                        int count,
+                        uint32_t hw_offset,
+                        uint32_t devid);
+
+struct xlib_brw_buffer
+{
+   struct brw_winsys_buffer base;
+   char *virtual;
+   unsigned offset;
+   unsigned type;
+   int map_count;
+   boolean modified;
+};
+
+
+/**
+ * Subclass of brw_winsys_screen for Xlib winsys
+ */
+struct xlib_brw_winsys
+{
+   struct brw_winsys_screen base;
+   struct brw_chipset chipset;
+
+   unsigned size;
+   unsigned used;
+};
+
+static struct xlib_brw_winsys *
+xlib_brw_winsys( struct brw_winsys_screen *screen )
+{
+   return (struct xlib_brw_winsys *)screen;
+}
+
+
+static struct xlib_brw_buffer *
+xlib_brw_buffer( struct brw_winsys_buffer *buffer )
+{
+   return (struct xlib_brw_buffer *)buffer;
+}
+
+
+
+const char *names[BRW_BUFFER_TYPE_MAX] = {
+   "TEXTURE",
+   "SCANOUT",
+   "VERTEX",
+   "CURBE",
+   "QUERY",
+   "SHADER_CONSTANTS",
+   "WM_SCRATCH",
+   "BATCH",
+   "GENERAL_STATE",
+   "SURFACE_STATE",
+   "PIXEL",
+   "GENERIC",
+};
+
+const char *usages[BRW_USAGE_MAX] = {
+   "STATE",
+   "QUERY_RESULT",
+   "RENDER_TARGET",
+   "DEPTH_BUFFER",
+   "BLIT_SOURCE",
+   "BLIT_DEST",
+   "SAMPLER",
+   "VERTEX",
+   "SCRATCH"
+};
+
+
+const char *data_types[BRW_DATA_MAX] =
+{
+   "GS: CC_VP",
+   "GS: CC_UNIT",
+   "GS: WM_PROG",
+   "GS: SAMPLER_DEFAULT_COLOR",
+   "GS: SAMPLER",
+   "GS: WM_UNIT",
+   "GS: SF_PROG",
+   "GS: SF_VP",
+   "GS: SF_UNIT",
+   "GS: VS_UNIT",
+   "GS: VS_PROG",
+   "GS: GS_UNIT",
+   "GS: GS_PROG",
+   "GS: CLIP_VP",
+   "GS: CLIP_UNIT",
+   "GS: CLIP_PROG",
+   "SS: SURFACE",
+   "SS: SURF_BIND",
+   "CONSTANT DATA",
+   "BATCH DATA",
+   "(untyped)"
+};
+
+
+static enum pipe_error
+xlib_brw_bo_alloc( struct brw_winsys_screen *sws,
+                   enum brw_buffer_type type,
+                   unsigned size,
+                   unsigned alignment,
+                   struct brw_winsys_buffer **bo_out )
+{
+   struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
+   struct xlib_brw_buffer *buf;
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s type %s sz %d align %d\n",
+                   __FUNCTION__, names[type], size, alignment );
+
+   buf = CALLOC_STRUCT(xlib_brw_buffer);
+   if (!buf)
+      return PIPE_ERROR_OUT_OF_MEMORY;
+
+   pipe_reference_init(&buf->base.reference, 1);
+
+   buf->offset = align(xbw->used, alignment);
+   buf->type = type;
+   buf->virtual = MALLOC(size);
+   buf->base.size = size;
+   buf->base.sws = sws;
+
+   xbw->used = align(xbw->used, alignment) + size;
+   if (xbw->used > MAX_VRAM)
+      goto err;
+
+   /* XXX: possibly rentrant call to bo_destroy:
+    */
+   bo_reference(bo_out, &buf->base);
+   return PIPE_OK;
+
+err:
+   assert(0);
+   FREE(buf->virtual);
+   FREE(buf);
+   return PIPE_ERROR_OUT_OF_MEMORY;
+}
+
+static void 
+xlib_brw_bo_destroy( struct brw_winsys_buffer *buffer )
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+
+   FREE(buf);
+}
+
+static int 
+xlib_brw_bo_emit_reloc( struct brw_winsys_buffer *buffer,
+                        enum brw_buffer_usage usage,
+                        unsigned delta,
+                        unsigned offset,
+                        struct brw_winsys_buffer *buffer2)
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+   struct xlib_brw_buffer *buf2 = xlib_brw_buffer(buffer2);
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s buf %p offset %x val %x + %x buf2 %p/%s/%s\n",
+                   __FUNCTION__, (void *)buffer, offset,
+                   buf2->offset, delta,
+                   (void *)buffer2, names[buf2->type], usages[usage]);
+
+   *(uint32_t *)(buf->virtual + offset) = buf2->offset + delta;
+
+   return 0;
+}
+
+static int 
+xlib_brw_bo_exec( struct brw_winsys_buffer *buffer,
+                    unsigned bytes_used )
+{
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("execute buffer %p, bytes %d\n", (void *)buffer, bytes_used);
+
+   return 0;
+}
+
+
+
+
+static int
+xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
+                    enum brw_buffer_data_type data_type,
+                    size_t offset,
+                    size_t size,
+                    const void *data,
+                    const struct brw_winsys_reloc *reloc,
+                    unsigned nr_relocs)
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+   struct xlib_brw_winsys *xbw = xlib_brw_winsys(buffer->sws);
+   unsigned i;
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s buf %p off %d sz %d %s relocs: %d\n", 
+                   __FUNCTION__, 
+                   (void *)buffer, offset, size, 
+                   data_types[data_type],
+                   nr_relocs);
+
+   assert(buf->base.size >= offset + size);
+   memcpy(buf->virtual + offset, data, size);
+
+   /* Apply the relocations:
+    */
+   for (i = 0; i < nr_relocs; i++) {
+      if (BRW_DEBUG & DEBUG_WINSYS)
+         debug_printf("\treloc[%d] usage %s off %d value %x+%x\n", 
+                      i, usages[reloc[i].usage], reloc[i].offset,
+                      xlib_brw_buffer(reloc[i].bo)->offset, reloc[i].delta);
+
+      *(unsigned *)(buf->virtual + offset + reloc[i].offset) = 
+         xlib_brw_buffer(reloc[i].bo)->offset + reloc[i].delta;
+   }
+
+   if (BRW_DUMP)
+      brw_dump_data( xbw->chipset.pci_id,
+                    data_type,
+                    buf->offset + offset, 
+                    buf->virtual + offset, size );
+
+
+   return 0;
+}
+
+
+static boolean 
+xlib_brw_bo_is_busy(struct brw_winsys_buffer *buffer)
+{
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
+   return TRUE;
+}
+
+static boolean 
+xlib_brw_bo_references(struct brw_winsys_buffer *a,
+                         struct brw_winsys_buffer *b)
+{
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %p %p\n", __FUNCTION__, (void *)a, (void *)b);
+   return TRUE;
+}
+
+static enum pipe_error
+xlib_brw_check_aperture_space( struct brw_winsys_screen *iws,
+                                struct brw_winsys_buffer **buffers,
+                                unsigned count )
+{
+   unsigned tot_size = 0;
+   unsigned i;
+
+   for (i = 0; i < count; i++)
+      tot_size += buffers[i]->size;
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %d bufs, tot_size: %d kb\n", 
+                   __FUNCTION__, count, 
+                   (tot_size + 1023) / 1024);
+
+   return PIPE_OK;
+}
+
+static void *
+xlib_brw_bo_map(struct brw_winsys_buffer *buffer,
+                enum brw_buffer_data_type data_type,
+                unsigned offset,
+                unsigned length,
+                boolean write,
+                boolean discard,
+                boolean explicit)
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer, 
+                   write ? "read/write" : "read",
+                   write ? data_types[data_type] : "");
+
+   if (write)
+      buf->modified = 1;
+
+   buf->map_count++;
+   return buf->virtual;
+}
+
+
+static void
+xlib_brw_bo_flush_range( struct brw_winsys_buffer *buffer,
+                         unsigned offset,
+                         unsigned length )
+{
+}
+
+
+static void 
+xlib_brw_bo_unmap(struct brw_winsys_buffer *buffer)
+{
+   struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
+
+   --buf->map_count;
+   assert(buf->map_count >= 0);
+
+   if (buf->map_count == 0 &&
+       buf->modified) {
+
+      buf->modified = 0;
+      
+      /* Consider dumping new buffer contents here, using the
+       * flush-range info to minimize verbosity.
+       */
+   }
+}
+
+
+static void
+xlib_brw_bo_wait_idle( struct brw_winsys_buffer *buffer )
+{
+}
+
+
+static void
+xlib_brw_winsys_destroy( struct brw_winsys_screen *sws )
+{
+   struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
+
+   FREE(xbw);
+}
+
+static struct brw_winsys_screen *
+xlib_create_brw_winsys_screen( void )
+{
+   struct xlib_brw_winsys *ws;
+
+   ws = CALLOC_STRUCT(xlib_brw_winsys);
+   if (!ws)
+      return NULL;
+
+   ws->used = 0;
+
+   ws->base.destroy              = xlib_brw_winsys_destroy;
+   ws->base.bo_alloc             = xlib_brw_bo_alloc;
+   ws->base.bo_destroy           = xlib_brw_bo_destroy;
+   ws->base.bo_emit_reloc        = xlib_brw_bo_emit_reloc;
+   ws->base.bo_exec              = xlib_brw_bo_exec;
+   ws->base.bo_subdata           = xlib_brw_bo_subdata;
+   ws->base.bo_is_busy           = xlib_brw_bo_is_busy;
+   ws->base.bo_references        = xlib_brw_bo_references;
+   ws->base.check_aperture_space = xlib_brw_check_aperture_space;
+   ws->base.bo_map               = xlib_brw_bo_map;
+   ws->base.bo_flush_range       = xlib_brw_bo_flush_range;
+   ws->base.bo_unmap             = xlib_brw_bo_unmap;
+   ws->base.bo_wait_idle         = xlib_brw_bo_wait_idle;
+
+   return &ws->base;
+}
+
+
+/***********************************************************************
+ * Implementation of Xlib co-state-tracker's winsys interface
+ */
+
+static void
+xlib_i965_display_surface(struct xmesa_buffer *xm_buffer,
+                          struct pipe_surface *surf)
+{
+   struct brw_surface *surface = brw_surface(surf);
+   struct xlib_brw_buffer *bo = xlib_brw_buffer(surface->bo);
+
+   if (BRW_DEBUG & DEBUG_WINSYS)
+      debug_printf("%s offset %x+%x sz %dx%d\n", __FUNCTION__, 
+                   bo->offset,
+                   surface->draw_offset,
+                   surf->width,
+                   surf->height);
+}
+
+static void
+xlib_i965_flush_frontbuffer(struct pipe_screen *screen,
+                           struct pipe_surface *surf,
+                           void *context_private)
+{
+   xlib_i965_display_surface(NULL, surf);
+}
+
+
+static struct pipe_screen *
+xlib_create_i965_screen( void )
+{
+   struct brw_winsys_screen *winsys;
+   struct pipe_screen *screen;
+
+   winsys = xlib_create_brw_winsys_screen();
+   if (winsys == NULL)
+      return NULL;
+
+   screen = brw_create_screen(winsys, PCI_CHIP_GM45_GM);
+   if (screen == NULL)
+      goto fail;
+
+   xlib_brw_winsys(winsys)->chipset = brw_screen(screen)->chipset;
+
+   screen->flush_frontbuffer = xlib_i965_flush_frontbuffer;
+   return screen;
+
+fail:
+   if (winsys)
+      winsys->destroy( winsys );
+
+   return NULL;
+}
+
+
+
+
+
+struct xm_driver xlib_i965_driver = 
+{
+   .create_pipe_screen = xlib_create_i965_screen,
+   .display_surface = xlib_i965_display_surface
+};
+
+
+/* Register this driver at library load: 
+ */
+static void _init( void ) __attribute__((constructor));
+static void _init( void )
+{
+   xmesa_set_driver( &xlib_i965_driver );
+}
+
+
+
+/***********************************************************************
+ *
+ * Butt-ugly hack to convince the linker not to throw away public GL
+ * symbols (they are all referenced from getprocaddress, I guess).
+ */
+extern void (*linker_foo(const unsigned char *procName))();
+extern void (*glXGetProcAddress(const unsigned char *procName))();
+
+extern void (*linker_foo(const unsigned char *procName))()
+{
+   return glXGetProcAddress(procName);
+}
diff --git a/src/gallium/winsys/nouveau/drm/Makefile b/src/gallium/winsys/nouveau/drm/Makefile
new file mode 100644 (file)
index 0000000..7102985
--- /dev/null
@@ -0,0 +1,11 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = nouveaudrm
+
+C_SOURCES = nouveau_drm_api.c
+
+LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I)
+LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_dri.h b/src/gallium/winsys/nouveau/drm/nouveau_dri.h
new file mode 100644 (file)
index 0000000..1207c2d
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef _NOUVEAU_DRI_
+#define _NOUVEAU_DRI_
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "nouveau_drm.h"
+
+struct nouveau_dri {
+       uint32_t device_id;     /**< \brief PCI device ID */
+       uint32_t width;         /**< \brief width in pixels of display */
+       uint32_t height;        /**< \brief height in scanlines of display */
+       uint32_t depth;         /**< \brief depth of display (8, 15, 16, 24) */
+       uint32_t bpp;           /**< \brief bit depth of display (8, 16, 24, 32) */
+
+       uint32_t bus_type;      /**< \brief ths bus type */
+       uint32_t bus_mode;      /**< \brief bus mode (used for AGP, maybe also for PCI-E ?) */
+
+       uint32_t front_offset;  /**< \brief front buffer offset */
+       uint32_t front_pitch;   /**< \brief front buffer pitch */
+       uint32_t back_offset;   /**< \brief private back buffer offset */
+       uint32_t back_pitch;    /**< \brief private back buffer pitch */
+       uint32_t depth_offset;  /**< \brief private depth buffer offset */
+       uint32_t depth_pitch;   /**< \brief private depth buffer pitch */
+
+};
+
+#endif
+
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_api.c
new file mode 100644 (file)
index 0000000..716d4ba
--- /dev/null
@@ -0,0 +1,157 @@
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+
+#include "nouveau_drm_api.h"
+
+#include "nouveau_drmif.h"
+#include "nouveau_channel.h"
+#include "nouveau_bo.h"
+
+#include "nouveau/nouveau_winsys.h"
+#include "nouveau/nouveau_screen.h"
+
+static struct pipe_surface *
+dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen,
+                        unsigned handle, enum pipe_format format,
+                        unsigned width, unsigned height, unsigned pitch)
+{
+       struct pipe_surface *ps = NULL;
+       struct pipe_texture *pt = NULL;
+       struct pipe_texture tmpl;
+       struct winsys_handle whandle;
+
+       memset(&tmpl, 0, sizeof(tmpl));
+       tmpl.tex_usage = PIPE_TEXTURE_USAGE_SCANOUT;
+       tmpl.target = PIPE_TEXTURE_2D;
+       tmpl.last_level = 0;
+       tmpl.depth0 = 1;
+       tmpl.format = format;
+       tmpl.width0 = width;
+       tmpl.height0 = height;
+
+       memset(&whandle, 0, sizeof(whandle));
+       whandle.stride = pitch;
+       whandle.handle = handle;
+
+       pt = pscreen->texture_from_handle(pscreen, &tmpl, &whandle);
+       if (!pt)
+               return NULL;
+
+       ps = pscreen->get_tex_surface(pscreen, pt, 0, 0, 0,
+                                     PIPE_BUFFER_USAGE_GPU_READ |
+                                     PIPE_BUFFER_USAGE_GPU_WRITE);
+
+       /* we don't need the texture from this point on */
+       pipe_texture_reference(&pt, NULL);
+       return ps;
+}
+
+static struct pipe_surface *
+nouveau_dri1_front_surface(struct pipe_context *pipe)
+{
+       return nouveau_winsys_screen(pipe->screen)->front;
+}
+
+static struct dri1_api nouveau_dri1_api = {
+       nouveau_dri1_front_surface,
+};
+
+static void
+nouveau_drm_destroy_winsys(struct pipe_winsys *s)
+{
+       struct nouveau_winsys *nv_winsys = nouveau_winsys(s);
+       struct nouveau_screen *nv_screen= nouveau_screen(nv_winsys->pscreen);
+       nouveau_device_close(&nv_screen->device);
+       FREE(nv_winsys);
+}
+
+static struct pipe_screen *
+nouveau_drm_create_screen(struct drm_api *api, int fd,
+                         struct drm_create_screen_arg *arg)
+{
+       struct dri1_create_screen_arg *dri1 = (void *)arg;
+       struct nouveau_winsys *nvws;
+       struct pipe_winsys *ws;
+       struct nouveau_device *dev = NULL;
+       struct pipe_screen *(*init)(struct pipe_winsys *,
+                                   struct nouveau_device *);
+       int ret;
+
+       ret = nouveau_device_open_existing(&dev, 0, fd, 0);
+       if (ret)
+               return NULL;
+
+       switch (dev->chipset & 0xf0) {
+       case 0x30:
+       case 0x40:
+       case 0x60:
+               init = nvfx_screen_create;
+               break;
+       case 0x50:
+       case 0x80:
+       case 0x90:
+       case 0xa0:
+               init = nv50_screen_create;
+               break;
+       default:
+               debug_printf("%s: unknown chipset nv%02x\n", __func__,
+                            dev->chipset);
+               return NULL;
+       }
+
+       nvws = CALLOC_STRUCT(nouveau_winsys);
+       if (!nvws) {
+               nouveau_device_close(&dev);
+               return NULL;
+       }
+       ws = &nvws->base;
+       ws->destroy = nouveau_drm_destroy_winsys;
+
+       nvws->pscreen = init(ws, dev);
+       if (!nvws->pscreen) {
+               ws->destroy(ws);
+               return NULL;
+       }
+
+       if (arg && arg->mode == DRM_CREATE_DRI1) {
+               struct nouveau_dri *nvdri = dri1->ddx_info;
+               enum pipe_format format;
+
+               if (nvdri->bpp == 16)
+                       format = PIPE_FORMAT_B5G6R5_UNORM;
+               else
+                       format = PIPE_FORMAT_B8G8R8A8_UNORM;
+
+               nvws->front = dri_surface_from_handle(api, nvws->pscreen,
+                                                     nvdri->front_offset,
+                                                     format, nvdri->width,
+                                                     nvdri->height,
+                                                     nvdri->front_pitch *
+                                                     (nvdri->bpp / 8));
+               if (!nvws->front) {
+                       debug_printf("%s: error referencing front buffer\n",
+                                    __func__);
+                       ws->destroy(ws);
+                       return NULL;
+               }
+
+               dri1->api = &nouveau_dri1_api;
+       }
+
+       return nvws->pscreen;
+}
+
+struct drm_api drm_api_hooks = {
+       .name = "nouveau",
+       .driver_name = "nouveau",
+       .create_screen = nouveau_drm_create_screen,
+};
+
+struct drm_api *
+drm_api_create() {
+       return &drm_api_hooks;
+}
+
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/nouveau/drm/nouveau_drm_api.h
new file mode 100644 (file)
index 0000000..a91aad7
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef __NOUVEAU_DRM_API_H__
+#define __NOUVEAU_DRM_API_H__
+
+#include "state_tracker/drm_api.h"
+#include "state_tracker/dri1_api.h"
+
+#include "util/u_simple_screen.h"
+
+#include "nouveau_dri.h"
+
+struct nouveau_winsys {
+       struct pipe_winsys base;
+
+       struct pipe_screen *pscreen;
+
+       struct pipe_surface *front;
+};
+
+static INLINE struct nouveau_winsys *
+nouveau_winsys(struct pipe_winsys *ws)
+{
+       return (struct nouveau_winsys *)ws;
+}
+
+static INLINE struct nouveau_winsys *
+nouveau_winsys_screen(struct pipe_screen *pscreen)
+{
+       return nouveau_winsys(pscreen->winsys);
+}
+
+#endif
diff --git a/src/gallium/winsys/null/Makefile b/src/gallium/winsys/null/Makefile
deleted file mode 100644 (file)
index 3a3fb75..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = ws_null
-
-LIBRARY_INCLUDES = \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/auxiliary
-
-C_SOURCES = \
-       null_sw_winsys.c 
-
-include ../../Makefile.template
-
-
diff --git a/src/gallium/winsys/null/SConscript b/src/gallium/winsys/null/SConscript
deleted file mode 100644 (file)
index 21837dc..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#######################################################################
-# SConscript for xlib winsys
-
-
-Import('*')
-
-env = env.Clone()
-
-env.Append(CPPPATH = [
-    '#/src/gallium/include',
-    '#/src/gallium/auxiliary',
-    '#/src/gallium/drivers',
-])
-
-ws_null = env.ConvenienceLibrary(
-    target = 'ws_null',
-    source = [
-       'null_sw_winsys.c',
-    ]
-)
-Export('ws_null')
diff --git a/src/gallium/winsys/null/null_sw_winsys.c b/src/gallium/winsys/null/null_sw_winsys.c
deleted file mode 100644 (file)
index d961d34..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- **************************************************************************/
-
-/**
- * @file
- * Null software rasterizer winsys.
- * 
- * There is no present support. Framebuffer data needs to be obtained via
- * transfers.
- *
- * @author Jose Fonseca
- */
-
-
-#include "pipe/p_format.h"
-#include "util/u_memory.h"
-#include "state_tracker/sw_winsys.h"
-#include "null_sw_winsys.h"
-
-
-static boolean
-null_sw_is_displaytarget_format_supported(struct sw_winsys *ws,
-                                          enum pipe_format format )
-{
-   return FALSE;
-}
-
-
-static void *
-null_sw_displaytarget_map(struct sw_winsys *ws,
-                          struct sw_displaytarget *dt,
-                          unsigned flags )
-{
-   assert(0);
-   return NULL;
-}
-
-
-static void
-null_sw_displaytarget_unmap(struct sw_winsys *ws,
-                            struct sw_displaytarget *dt )
-{
-   assert(0);
-}
-
-
-static void
-null_sw_displaytarget_destroy(struct sw_winsys *winsys,
-                              struct sw_displaytarget *dt)
-{
-   assert(0);
-}
-
-
-static struct sw_displaytarget *
-null_sw_displaytarget_create(struct sw_winsys *winsys,
-                             enum pipe_format format,
-                             unsigned width, unsigned height,
-                             unsigned alignment,
-                             unsigned *stride)
-{
-   return NULL;
-}
-
-
-static void
-null_sw_displaytarget_display(struct sw_winsys *winsys,
-                              struct sw_displaytarget *dt,
-                              void *context_private)
-{
-   assert(0);
-}
-
-
-static void
-null_sw_destroy(struct sw_winsys *winsys)
-{
-   FREE(winsys);
-}
-
-
-struct sw_winsys *
-null_sw_create(void)
-{
-   static struct sw_winsys *winsys;
-
-   winsys = CALLOC_STRUCT(sw_winsys);
-   if (!winsys)
-      return NULL;
-
-   winsys->destroy = null_sw_destroy;
-   winsys->is_displaytarget_format_supported = null_sw_is_displaytarget_format_supported;
-   winsys->displaytarget_create = null_sw_displaytarget_create;
-   winsys->displaytarget_map = null_sw_displaytarget_map;
-   winsys->displaytarget_unmap = null_sw_displaytarget_unmap;
-   winsys->displaytarget_display = null_sw_displaytarget_display;
-   winsys->displaytarget_destroy = null_sw_displaytarget_destroy;
-
-   return winsys;
-}
diff --git a/src/gallium/winsys/null/null_sw_winsys.h b/src/gallium/winsys/null/null_sw_winsys.h
deleted file mode 100644 (file)
index 1986186..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- **************************************************************************/
-
-
-#ifndef NULL_SW_WINSYS_H_
-#define NULL_SW_WINSYS_H_
-
-
-struct sw_winsys;
-
-
-struct sw_winsys *
-null_sw_create(void);
-
-
-#endif /* NULL_SW_WINSYS_H_ */
diff --git a/src/gallium/winsys/radeon/drm/Makefile b/src/gallium/winsys/radeon/drm/Makefile
new file mode 100644 (file)
index 0000000..7f69e39
--- /dev/null
@@ -0,0 +1,17 @@
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = radeonwinsys
+
+C_SOURCES = \
+       radeon_drm_buffer.c \
+       radeon_drm.c \
+       radeon_r300.c
+
+LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/r300 \
+                  $(shell pkg-config libdrm --cflags-only-I)
+
+include ../../../Makefile.template
+
+symlinks:
diff --git a/src/gallium/winsys/radeon/drm/SConscript b/src/gallium/winsys/radeon/drm/SConscript
new file mode 100644 (file)
index 0000000..fab4292
--- /dev/null
@@ -0,0 +1,18 @@
+Import('*')
+
+env = env.Clone()
+
+radeon_sources = [
+    'radeon_drm_buffer.c',
+    'radeon_drm.c',
+    'radeon_r300.c',
+]
+
+env.Append(CPPPATH = '#/src/gallium/drivers/r300')
+
+radeonwinsys = env.ConvenienceLibrary(
+    target ='radeonwinsys',
+    source = radeon_sources,
+)
+
+Export('radeonwinsys')
diff --git a/src/gallium/winsys/radeon/drm/radeon_buffer.h b/src/gallium/winsys/radeon/drm/radeon_buffer.h
new file mode 100644 (file)
index 0000000..218a376
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright Â© 2008 Jérôme Glisse
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#ifndef RADEON_BUFFER_H
+#define RADEON_BUFFER_H
+
+#include <stdio.h>
+
+#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_bufmgr.h"
+
+#include "radeon_bo.h"
+#include "radeon_cs.h"
+
+#include "radeon_winsys.h"
+
+
+#define RADEON_MAX_BOS 24
+
+static INLINE struct pb_buffer *
+radeon_pb_buffer(struct r300_winsys_buffer *buffer)
+{
+    return (struct pb_buffer *)buffer;
+}
+
+static INLINE struct r300_winsys_buffer *
+radeon_libdrm_winsys_buffer(struct pb_buffer *buffer)
+{
+    return (struct r300_winsys_buffer *)buffer;
+}
+
+struct pb_manager *
+radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws);
+
+boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf,
+                                    uint32_t rd, uint32_t wd);
+
+
+void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
+                                  uint32_t rd, uint32_t wd,
+                                  uint32_t flags);
+
+struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
+                                                             uint32_t handle);
+
+void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf,
+                                  enum r300_buffer_tiling microtiled,
+                                  enum r300_buffer_tiling macrotiled,
+                                  uint32_t pitch);
+
+void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr);
+
+boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
+                                    struct winsys_handle *whandle);
+
+boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf);
+#endif
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm.c b/src/gallium/winsys/radeon/drm/radeon_drm.c
new file mode 100644 (file)
index 0000000..3dfcc5a
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * Copyright Â© 2009 Corbin Simpson
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Corbin Simpson <MostAwesomeDude@gmail.com>
+ *      Joakim Sindholt <opensource@zhasha.com>
+ */
+
+#include "radeon_drm.h"
+#include "radeon_r300.h"
+#include "radeon_buffer.h"
+
+#include "r300_winsys.h"
+#include "trace/tr_drm.h"
+
+#include "util/u_memory.h"
+
+#include "xf86drm.h"
+#include <sys/ioctl.h>
+
+static struct radeon_libdrm_winsys *
+radeon_winsys_create(int fd)
+{
+    struct radeon_libdrm_winsys *rws;
+
+    rws = CALLOC_STRUCT(radeon_libdrm_winsys);
+    if (rws == NULL) {
+        return NULL;
+    }
+
+    rws->fd = fd;
+    return rws;
+}
+
+/* Helper function to do the ioctls needed for setup and init. */
+static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys)
+{
+    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.
+     * This is also for some features.
+     *
+     * Then, the PCI ID. This is essential and should return usable numbers
+     * for all Radeons. If this fails, we probably got handed an FD for some
+     * non-Radeon card.
+     *
+     * The GB and Z pipe requests should always succeed, but they might not
+     * return sensical values for all chipsets, but that's alright because
+     * the pipe drivers already know that.
+     *
+     * The GEM info is actually bogus on the kernel side, as well as our side
+     * (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because
+     * we don't actually use the info for anything yet. */
+
+    version = drmGetVersion(fd);
+    if (version->version_major != 2) {
+        fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
+                "only compatible with 2.x.x\n", __FUNCTION__,
+                version->version_major, version->version_minor,
+                version->version_patchlevel);
+        drmFreeVersion(version);
+        exit(1);
+    }
+
+/* XXX Remove this ifdef when libdrm version 2.4.19 becomes mandatory. */
+#ifdef RADEON_BO_FLAGS_MICRO_TILE_SQUARE
+    // Supported since 2.1.0.
+    winsys->squaretiling = version->version_major > 2 ||
+                           version->version_minor >= 1;
+#endif
+
+    info.request = RADEON_INFO_DEVICE_ID;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get PCI ID, "
+                "error number %d\n", __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->pci_id = target;
+
+    info.request = RADEON_INFO_NUM_GB_PIPES;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get GB pipe count, "
+                "error number %d\n", __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->gb_pipes = target;
+
+    info.request = RADEON_INFO_NUM_Z_PIPES;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get Z pipe count, "
+                "error number %d\n", __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->z_pipes = target;
+
+    retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO,
+            &gem_info, sizeof(gem_info));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get MM info, error number %d\n",
+                __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->gart_size = gem_info.gart_size;
+    winsys->vram_size = gem_info.vram_size;
+
+    debug_printf("radeon: Successfully grabbed chipset info from kernel!\n"
+                 "radeon: DRM version: %d.%d.%d ID: 0x%04x GB: %d Z: %d\n"
+                 "radeon: GART size: %d MB VRAM size: %d MB\n",
+                 version->version_major, version->version_minor,
+                 version->version_patchlevel, winsys->pci_id,
+                 winsys->gb_pipes, winsys->z_pipes,
+                 winsys->gart_size / 1024 / 1024,
+                 winsys->vram_size / 1024 / 1024);
+
+    drmFreeVersion(version);
+}
+
+/* Create a pipe_screen. */
+struct pipe_screen* radeon_create_screen(struct drm_api* api,
+                                         int drmFB,
+                                         struct drm_create_screen_arg *arg)
+{
+    struct radeon_libdrm_winsys* rws; 
+    boolean ret;
+
+    rws = radeon_winsys_create(drmFB);
+    if (!rws)
+       return NULL;
+
+    do_ioctls(drmFB, rws);
+
+    /* The state tracker can organize a softpipe fallback if no hw
+     * driver is found.
+     */
+    if (is_r3xx(rws->pci_id)) {
+        ret = radeon_setup_winsys(drmFB, rws);
+       if (ret == FALSE)
+           goto fail;
+        return r300_create_screen(&rws->base);
+    }
+
+fail:
+    FREE(rws);
+    return NULL;
+}
+
+static void radeon_drm_api_destroy(struct drm_api *api)
+{
+    return;
+}
+
+struct drm_api drm_api_hooks = {
+    .name = "radeon",
+    .driver_name = "radeon",
+    .create_screen = radeon_create_screen,
+    .destroy = radeon_drm_api_destroy,
+};
+
+struct drm_api* drm_api_create()
+{
+#ifdef DEBUG
+    return trace_drm_create(&drm_api_hooks);
+#else
+    return &drm_api_hooks;
+#endif
+}
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm.h b/src/gallium/winsys/radeon/drm/radeon_drm.h
new file mode 100644 (file)
index 0000000..2dc077c
--- /dev/null
@@ -0,0 +1,66 @@
+/* 
+ * Copyright Â© 2009 Corbin Simpson
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Corbin Simpson <MostAwesomeDude@gmail.com>
+ */
+#ifndef RADEON_DRM_H
+#define RADEON_DRM_H
+
+#include "state_tracker/drm_api.h"
+
+
+struct pipe_screen* radeon_create_screen(struct drm_api* api,
+                                         int drmFB,
+                                        struct drm_create_screen_arg *arg);
+
+boolean radeon_buffer_from_texture(struct drm_api* api,
+                                   struct pipe_screen* screen,
+                                   struct pipe_texture* texture,
+                                   struct pipe_buffer** buffer,
+                                   unsigned* stride);
+
+boolean radeon_handle_from_buffer(struct drm_api* api,
+                                  struct pipe_screen* screen,
+                                  struct pipe_buffer* buffer,
+                                  unsigned* handle);
+
+boolean radeon_global_handle_from_buffer(struct drm_api* api,
+                                         struct pipe_screen* screen,
+                                         struct pipe_buffer* buffer,
+                                         unsigned* handle);
+
+void radeon_destroy_drm_api(struct drm_api* api);
+
+/* Guess at whether this chipset should use r300g.
+ *
+ * I believe that this check is valid, but I haven't been exhaustive. */
+static INLINE boolean is_r3xx(int pciid)
+{
+    return (pciid > 0x3150) && (pciid < 0x796f);
+}
+
+#endif
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
new file mode 100644 (file)
index 0000000..66f6132
--- /dev/null
@@ -0,0 +1,385 @@
+
+#include <sys/ioctl.h>
+#include "radeon_drm.h"
+#include "radeon_bo_gem.h"
+#include "radeon_cs_gem.h"
+#include "radeon_buffer.h"
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_simple_list.h"
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_bufmgr.h"
+
+#include "radeon_winsys.h"
+struct radeon_drm_bufmgr;
+
+struct radeon_drm_buffer {
+    struct pb_buffer base;
+    struct radeon_drm_bufmgr *mgr;
+
+    struct radeon_bo *bo;
+
+    boolean flinked;
+    uint32_t flink;
+
+    struct radeon_drm_buffer *next, *prev;
+};
+
+extern const struct pb_vtbl radeon_drm_buffer_vtbl;
+
+
+static INLINE struct radeon_drm_buffer *
+radeon_drm_buffer(struct pb_buffer *buf)
+{
+    assert(buf);
+    assert(buf->vtbl == &radeon_drm_buffer_vtbl);
+    return (struct radeon_drm_buffer *)buf;
+}
+
+struct radeon_drm_bufmgr {
+    struct pb_manager base;
+    struct radeon_libdrm_winsys *rws;
+    struct radeon_drm_buffer buffer_map_list;
+};
+
+static INLINE struct radeon_drm_bufmgr *
+radeon_drm_bufmgr(struct pb_manager *mgr)
+{
+    assert(mgr);
+    return (struct radeon_drm_bufmgr *)mgr;
+}
+
+static void
+radeon_drm_buffer_destroy(struct pb_buffer *_buf)
+{
+    struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
+
+    if (buf->bo->ptr != NULL) {
+       remove_from_list(buf);
+       radeon_bo_unmap(buf->bo);
+       buf->bo->ptr = NULL;
+    }
+    radeon_bo_unref(buf->bo);
+
+    FREE(buf);
+}
+
+static void *
+radeon_drm_buffer_map(struct pb_buffer *_buf,
+                     unsigned flags)
+{
+    struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
+    int write = 0;
+
+    if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+       if ((_buf->base.usage & PIPE_BUFFER_USAGE_VERTEX) ||
+           (_buf->base.usage & PIPE_BUFFER_USAGE_INDEX))
+           if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs))
+               return NULL;
+    }
+
+    if (buf->bo->ptr != NULL)
+       return buf->bo->ptr;
+
+    if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+        uint32_t domain;
+        if (radeon_bo_is_busy(buf->bo, &domain))
+            return NULL;
+    }
+
+    if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) {
+        buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data);
+    }
+
+    if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
+        write = 1;
+    }
+
+    if (radeon_bo_map(buf->bo, write)) {
+        return NULL;
+    }
+    insert_at_tail(&buf->mgr->buffer_map_list, buf);
+    return buf->bo->ptr;
+}
+
+static void
+radeon_drm_buffer_unmap(struct pb_buffer *_buf)
+{
+    (void)_buf;
+}
+
+static void
+radeon_drm_buffer_get_base_buffer(struct pb_buffer *buf,
+                                 struct pb_buffer **base_buf,
+                                 unsigned *offset)
+{
+    *base_buf = buf;
+    *offset = 0;
+}
+
+
+static enum pipe_error
+radeon_drm_buffer_validate(struct pb_buffer *_buf, 
+                          struct pb_validate *vl,
+                          unsigned flags)
+{
+   /* Always pinned */
+   return PIPE_OK;
+}
+
+static void
+radeon_drm_buffer_fence(struct pb_buffer *buf,
+                       struct pipe_fence_handle *fence)
+{
+}
+
+const struct pb_vtbl radeon_drm_buffer_vtbl = {
+    radeon_drm_buffer_destroy,
+    radeon_drm_buffer_map,
+    radeon_drm_buffer_unmap,
+    radeon_drm_buffer_validate,
+    radeon_drm_buffer_fence,
+    radeon_drm_buffer_get_base_buffer,
+};
+
+
+static uint32_t radeon_domain_from_usage(unsigned usage)
+{
+    uint32_t domain = 0;
+
+    if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
+        domain |= RADEON_GEM_DOMAIN_VRAM;
+    }
+    if (usage & PIPE_BUFFER_USAGE_PIXEL) {
+        domain |= RADEON_GEM_DOMAIN_VRAM;
+    }
+    if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+        domain |= RADEON_GEM_DOMAIN_GTT;
+    }
+    if (usage & PIPE_BUFFER_USAGE_INDEX) {
+        domain |= RADEON_GEM_DOMAIN_GTT;
+    }
+
+    return domain;
+}
+
+struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
+                                                             uint32_t handle)
+{
+    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
+    struct radeon_libdrm_winsys *rws = mgr->rws;
+    struct radeon_drm_buffer *buf;
+    struct radeon_bo *bo;
+
+    bo = radeon_bo_open(rws->bom, handle, 0,
+                       0, 0, 0);
+    if (bo == NULL)
+       return NULL;
+
+    buf = CALLOC_STRUCT(radeon_drm_buffer);
+    if (!buf) {
+       radeon_bo_unref(bo);
+       return NULL;
+    }
+
+    make_empty_list(buf);
+
+    pipe_reference_init(&buf->base.base.reference, 1);
+    buf->base.base.alignment = 0;
+    buf->base.base.usage = PIPE_BUFFER_USAGE_PIXEL;
+    buf->base.base.size = 0;
+    buf->base.vtbl = &radeon_drm_buffer_vtbl;
+    buf->mgr = mgr;
+
+    buf->bo = bo;
+
+    return &buf->base;
+}
+
+static struct pb_buffer *
+radeon_drm_bufmgr_create_buffer(struct pb_manager *_mgr,
+                               pb_size size,
+                               const struct pb_desc *desc)
+{
+    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
+    struct radeon_libdrm_winsys *rws = mgr->rws;
+    struct radeon_drm_buffer *buf;
+    uint32_t domain;
+
+    buf = CALLOC_STRUCT(radeon_drm_buffer);
+    if (!buf)
+       goto error1;
+
+    pipe_reference_init(&buf->base.base.reference, 1);
+    buf->base.base.alignment = desc->alignment;
+    buf->base.base.usage = desc->usage;
+    buf->base.base.size = size;
+    buf->base.vtbl = &radeon_drm_buffer_vtbl;
+    buf->mgr = mgr;
+
+    make_empty_list(buf);
+    domain = radeon_domain_from_usage(desc->usage);
+    buf->bo = radeon_bo_open(rws->bom, 0, size,
+                            desc->alignment, domain, 0);
+    if (buf->bo == NULL)
+       goto error2;
+
+    return &buf->base;
+
+ error2:
+    FREE(buf);
+ error1:
+    return NULL; 
+}
+
+static void
+radeon_drm_bufmgr_flush(struct pb_manager *mgr)
+{
+    /* NOP */
+}
+
+static void
+radeon_drm_bufmgr_destroy(struct pb_manager *_mgr)
+{
+    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
+    FREE(mgr);
+}
+
+struct pb_manager *
+radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws)
+{
+    struct radeon_drm_bufmgr *mgr;
+
+    mgr = CALLOC_STRUCT(radeon_drm_bufmgr);
+    if (!mgr)
+       return NULL;
+
+    mgr->base.destroy = radeon_drm_bufmgr_destroy;
+    mgr->base.create_buffer = radeon_drm_bufmgr_create_buffer;
+    mgr->base.flush = radeon_drm_bufmgr_flush;
+
+    mgr->rws = rws;
+    make_empty_list(&mgr->buffer_map_list);
+    return &mgr->base;
+}
+
+static struct radeon_drm_buffer *get_drm_buffer(struct pb_buffer *_buf)
+{
+    struct radeon_drm_buffer *buf;
+    if (_buf->vtbl == &radeon_drm_buffer_vtbl) {
+        buf = radeon_drm_buffer(_buf);
+    } else {
+       struct pb_buffer *base_buf;
+       pb_size offset;
+       pb_get_base_buffer(_buf, &base_buf, &offset);
+
+       buf = radeon_drm_buffer(base_buf);
+    }
+    return buf;
+}
+
+boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
+                                    struct winsys_handle *whandle)
+{
+    int retval, fd;
+    struct drm_gem_flink flink;
+    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
+    if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
+       if (!buf->flinked) {
+           fd = buf->mgr->rws->fd;
+           flink.handle = buf->bo->handle;
+
+           retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
+           if (retval) {
+               return FALSE;
+           }
+
+           buf->flinked = TRUE;
+           buf->flink = flink.name;
+       }
+       whandle->handle = buf->flink;
+    } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
+       whandle->handle = buf->bo->handle;
+    }
+    return TRUE;
+}
+                                          
+
+void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf,
+                                  enum r300_buffer_tiling microtiled,
+                                  enum r300_buffer_tiling macrotiled,
+                                  uint32_t pitch)
+{
+    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
+    uint32_t flags = 0, old_flags, old_pitch;
+    if (microtiled == R300_BUFFER_TILED)
+        flags |= RADEON_BO_FLAGS_MICRO_TILE;
+/* XXX Remove this ifdef when libdrm version 2.4.19 becomes mandatory. */
+#ifdef RADEON_BO_FLAGS_MICRO_TILE_SQUARE
+    else if (microtiled == R300_BUFFER_SQUARETILED)
+        flags |= RADEON_BO_FLAGS_MICRO_TILE_SQUARE;
+#endif
+    if (macrotiled == R300_BUFFER_TILED)
+        flags |= RADEON_BO_FLAGS_MACRO_TILE;
+
+    radeon_bo_get_tiling(buf->bo, &old_flags, &old_pitch);
+
+    if (flags != old_flags || pitch != old_pitch) {
+        /* Tiling determines how DRM treats the buffer data.
+         * We must flush CS when changing it if the buffer is referenced. */
+        if (radeon_bo_is_referenced_by_cs(buf->bo,  buf->mgr->rws->cs)) {
+           buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data);
+        }
+    }
+    radeon_bo_set_tiling(buf->bo, flags, pitch);
+
+}
+
+boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf,
+                                    uint32_t rd, uint32_t wd)
+{
+    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
+    radeon_cs_space_add_persistent_bo(buf->mgr->rws->cs, buf->bo,
+                                         rd, wd);
+    return TRUE;
+}
+
+void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
+                                  uint32_t rd, uint32_t wd,
+                                  uint32_t flags)
+{
+    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
+    int retval;
+
+    retval = radeon_cs_write_reloc(buf->mgr->rws->cs,
+                                  buf->bo, rd, wd, flags);
+    if (retval) {
+        debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
+                    buf, rd, wd, flags);
+    }
+}
+
+boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf)
+{
+    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
+    uint32_t domain;
+
+    return (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs) ||
+           radeon_bo_is_busy(buf->bo, &domain));
+}
+
+
+void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr)
+{
+    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
+    struct radeon_drm_buffer *rpb, *t_rpb;
+
+    foreach_s(rpb, t_rpb, &mgr->buffer_map_list) {
+       radeon_bo_unmap(rpb->bo);
+       rpb->bo->ptr = NULL;
+       remove_from_list(rpb);
+    }
+
+    make_empty_list(&mgr->buffer_map_list);
+}
diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c
new file mode 100644 (file)
index 0000000..38fcf88
--- /dev/null
@@ -0,0 +1,348 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include "radeon_r300.h"
+#include "radeon_buffer.h"
+
+#include "radeon_bo_gem.h"
+#include "radeon_cs_gem.h"
+#include "state_tracker/drm_api.h"
+
+static struct r300_winsys_buffer *
+radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws,
+                                unsigned alignment,
+                                unsigned usage,
+                                unsigned size)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    struct pb_desc desc;
+    struct pb_manager *provider;
+    struct pb_buffer *buffer;
+
+    memset(&desc, 0, sizeof(desc));
+    desc.alignment = alignment;
+    desc.usage = usage;
+
+    if (usage & PIPE_BUFFER_USAGE_CONSTANT)
+        provider = ws->mman;
+    else if ((usage & PIPE_BUFFER_USAGE_VERTEX) ||
+            (usage & PIPE_BUFFER_USAGE_INDEX))
+       provider = ws->cman;
+    else
+        provider = ws->kman;
+    buffer = provider->create_buffer(provider, size, &desc);
+    if (!buffer)
+       return NULL;
+
+    return radeon_libdrm_winsys_buffer(buffer);
+}
+
+static void radeon_r300_winsys_buffer_destroy(struct r300_winsys_buffer *buf)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buf);
+
+    pb_destroy(_buf);
+}
+static void radeon_r300_winsys_buffer_set_tiling(struct r300_winsys_screen *rws,
+                                                 struct r300_winsys_buffer *buf,
+                                                 uint32_t pitch,
+                                                 enum r300_buffer_tiling microtiled,
+                                                 enum r300_buffer_tiling macrotiled)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buf);
+    radeon_drm_bufmgr_set_tiling(_buf, microtiled, macrotiled, pitch);
+}
+
+static void *radeon_r300_winsys_buffer_map(struct r300_winsys_screen *ws,
+                                          struct r300_winsys_buffer *buf,
+                                          unsigned usage)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buf);
+    
+    return pb_map(_buf, usage);
+}
+
+static void radeon_r300_winsys_buffer_unmap(struct r300_winsys_screen *ws,
+                                           struct r300_winsys_buffer *buf)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buf);
+
+    pb_unmap(_buf);
+}
+
+static void radeon_r300_winsys_buffer_reference(struct r300_winsys_screen *rws,
+                                               struct r300_winsys_buffer **pdst,
+                                               struct r300_winsys_buffer *src)
+{
+    struct pb_buffer *_src = radeon_pb_buffer(src);
+    struct pb_buffer *_dst = radeon_pb_buffer(*pdst);
+
+    pb_reference(&_dst, _src);
+
+    *pdst = radeon_libdrm_winsys_buffer(_dst);
+}
+
+static boolean radeon_r300_winsys_is_buffer_referenced(struct r300_winsys_screen *rws,
+                                                      struct r300_winsys_buffer *buf)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buf);
+
+    return radeon_drm_bufmgr_is_buffer_referenced(_buf);
+}
+
+static struct r300_winsys_buffer *radeon_r300_winsys_buffer_from_handle(struct r300_winsys_screen *rws,
+                                                                       struct pipe_screen *screen,
+                                                                       struct winsys_handle *whandle,
+                                                                       unsigned *stride)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    struct pb_buffer *_buf;
+
+    _buf = radeon_drm_bufmgr_create_buffer_from_handle(ws->kman, whandle->handle);
+    *stride = whandle->stride;
+    return radeon_libdrm_winsys_buffer(_buf);
+}
+
+static boolean radeon_r300_winsys_buffer_get_handle(struct r300_winsys_screen *rws,
+                                                   struct r300_winsys_buffer *buffer,
+                                                   unsigned stride,
+                                                   struct winsys_handle *whandle)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buffer);
+    boolean ret;
+    ret = radeon_drm_bufmgr_get_handle(_buf, whandle);
+    if (ret)
+       whandle->stride = stride;
+    return ret;
+}
+
+static void radeon_set_flush_cb(struct r300_winsys_screen *rws,
+                                void (*flush_cb)(void *),
+                                void *data)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    ws->flush_cb = flush_cb;
+    ws->flush_data = data;
+    radeon_cs_space_set_flush(ws->cs, flush_cb, data);
+}
+
+static boolean radeon_add_buffer(struct r300_winsys_screen *rws,
+                                 struct r300_winsys_buffer *buf,
+                                 uint32_t rd,
+                                 uint32_t wd)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buf);
+
+    return radeon_drm_bufmgr_add_buffer(_buf, rd, wd);
+}
+
+static boolean radeon_validate(struct r300_winsys_screen *rws)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    if (radeon_cs_space_check(ws->cs) < 0) {
+        return FALSE;
+    }
+
+    /* Things are fine, we can proceed as normal. */
+    return TRUE;
+}
+
+static boolean radeon_check_cs(struct r300_winsys_screen *rws, int size)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    struct radeon_cs *cs = ws->cs;
+
+    return radeon_validate(rws) && cs->cdw + size <= cs->ndw;
+}
+
+static void radeon_begin_cs(struct r300_winsys_screen *rws,
+                            int size,
+                            const char* file,
+                            const char* function,
+                            int line)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    radeon_cs_begin(ws->cs, size, file, function, line);
+}
+
+static void radeon_write_cs_dword(struct r300_winsys_screen *rws,
+                                  uint32_t dword)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    radeon_cs_write_dword(ws->cs, dword);
+}
+
+static void radeon_write_cs_reloc(struct r300_winsys_screen *rws,
+                                  struct r300_winsys_buffer *buf,
+                                  uint32_t rd,
+                                  uint32_t wd,
+                                  uint32_t flags)
+{
+    struct pb_buffer *_buf = radeon_pb_buffer(buf);
+    radeon_drm_bufmgr_write_reloc(_buf, rd, wd, flags);
+}
+
+static void radeon_reset_bos(struct r300_winsys_screen *rws)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    radeon_cs_space_reset_bos(ws->cs);
+}
+
+static void radeon_end_cs(struct r300_winsys_screen *rws,
+                          const char* file,
+                          const char* function,
+                          int line)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    radeon_cs_end(ws->cs, file, function, line);
+}
+
+static void radeon_flush_cs(struct r300_winsys_screen *rws)
+{
+    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
+    int retval;
+
+    /* Don't flush a zero-sized CS. */
+    if (!ws->cs->cdw) {
+        return;
+    }
+
+    radeon_drm_bufmgr_flush_maps(ws->kman);
+    /* Emit the CS. */
+    retval = radeon_cs_emit(ws->cs);
+    if (retval) {
+        debug_printf("radeon: Bad CS, dumping...\n");
+        radeon_cs_print(ws->cs, stderr);
+    }
+
+    /* Reset CS.
+     * Someday, when we care about performance, we should really find a way
+     * to rotate between two or three CS objects so that the GPU can be
+     * spinning through one CS while another one is being filled. */
+    radeon_cs_erase(ws->cs);
+}
+
+static uint32_t radeon_get_value(struct r300_winsys_screen *rws,
+                            enum r300_value_id id)
+{
+    struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
+
+    switch(id) {
+    case R300_VID_PCI_ID:
+       return ws->pci_id;
+    case R300_VID_GB_PIPES:
+       return ws->gb_pipes;
+    case R300_VID_Z_PIPES:
+       return ws->z_pipes;
+    case R300_VID_SQUARE_TILING_SUPPORT:
+        return ws->squaretiling;
+    }
+    return 0;
+}
+
+static void
+radeon_winsys_destroy(struct r300_winsys_screen *rws)
+{
+    struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
+    radeon_cs_destroy(ws->cs);
+
+    ws->cman->destroy(ws->cman);
+    ws->kman->destroy(ws->kman);
+    ws->mman->destroy(ws->mman);
+
+    radeon_bo_manager_gem_dtor(ws->bom);
+    radeon_cs_manager_gem_dtor(ws->csm);
+}
+
+boolean
+radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws)
+{
+    
+    ws->csm = radeon_cs_manager_gem_ctor(fd);
+    if (!ws->csm)
+       goto fail;
+    ws->bom = radeon_bo_manager_gem_ctor(fd);
+    if (!ws->bom)
+       goto fail;
+    ws->kman = radeon_drm_bufmgr_create(ws);
+    if (!ws->kman)
+       goto fail;
+
+    ws->cman = pb_cache_manager_create(ws->kman, 100000);
+    if (!ws->cman)
+       goto fail;
+
+    ws->mman = pb_malloc_bufmgr_create();
+    if (!ws->mman)
+       goto fail;
+
+    /* Size limit on IBs is 64 kibibytes. */
+    ws->cs = radeon_cs_create(ws->csm, 1024 * 64 / 4);
+    if (!ws->cs)
+       goto fail;
+    radeon_cs_set_limit(ws->cs,
+            RADEON_GEM_DOMAIN_GTT, ws->gart_size);
+    radeon_cs_set_limit(ws->cs,
+            RADEON_GEM_DOMAIN_VRAM, ws->vram_size);
+
+    ws->base.add_buffer = radeon_add_buffer;
+    ws->base.validate = radeon_validate;
+    ws->base.destroy = radeon_winsys_destroy;
+    ws->base.check_cs = radeon_check_cs;
+    ws->base.begin_cs = radeon_begin_cs;
+    ws->base.write_cs_dword = radeon_write_cs_dword;
+    ws->base.write_cs_reloc = radeon_write_cs_reloc;
+    ws->base.end_cs = radeon_end_cs;
+    ws->base.flush_cs = radeon_flush_cs;
+    ws->base.reset_bos = radeon_reset_bos;
+    ws->base.set_flush_cb = radeon_set_flush_cb;
+    ws->base.get_value = radeon_get_value;
+
+    ws->base.buffer_create = radeon_r300_winsys_buffer_create;
+    ws->base.buffer_destroy = radeon_r300_winsys_buffer_destroy;
+    ws->base.buffer_set_tiling = radeon_r300_winsys_buffer_set_tiling;
+    ws->base.buffer_map = radeon_r300_winsys_buffer_map;
+    ws->base.buffer_unmap = radeon_r300_winsys_buffer_unmap;
+    ws->base.buffer_reference = radeon_r300_winsys_buffer_reference;
+    ws->base.buffer_from_handle = radeon_r300_winsys_buffer_from_handle;
+    ws->base.buffer_get_handle = radeon_r300_winsys_buffer_get_handle;
+    ws->base.is_buffer_referenced = radeon_r300_winsys_is_buffer_referenced;
+    return TRUE;
+
+fail:
+    if (ws->csm)
+       radeon_cs_manager_gem_dtor(ws->csm);
+
+    if (ws->bom)
+       radeon_bo_manager_gem_dtor(ws->bom);
+
+    if (ws->cman)
+       ws->cman->destroy(ws->cman);
+    if (ws->kman)
+       ws->kman->destroy(ws->kman);
+    if (ws->mman)
+       ws->mman->destroy(ws->mman);
+
+    if (ws->cs)
+       radeon_cs_destroy(ws->cs);
+    return FALSE;
+}
diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.h b/src/gallium/winsys/radeon/drm/radeon_r300.h
new file mode 100644 (file)
index 0000000..2703464
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef RADEON_R300_H
+#define RADEON_R300_H
+
+#include "radeon_winsys.h"
+
+boolean radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* winsys);
+
+#endif /* RADEON_R300_H */
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h
new file mode 100644 (file)
index 0000000..4260dba
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright Â© 2009 Corbin Simpson
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Corbin Simpson <MostAwesomeDude@gmail.com>
+ */
+#ifndef RADEON_WINSYS_H
+#define RADEON_WINSYS_H
+
+#include "r300_winsys.h"
+
+struct radeon_libdrm_winsys {
+    /* Parent class. */
+    struct r300_winsys_screen base;
+
+    struct pb_manager *kman;
+
+    struct pb_manager *cman;
+
+    struct pb_manager *mman;
+
+    /* PCI ID */
+    uint32_t pci_id;
+
+    /* GB pipe count */
+    uint32_t gb_pipes;
+
+    /* Z pipe count (rv530 only) */
+    uint32_t z_pipes;
+
+    /* GART size. */
+    uint32_t gart_size;
+
+    /* VRAM size. */
+    uint32_t vram_size;
+
+    /* Square tiling support. */
+    boolean squaretiling;
+
+    /* DRM FD */
+    int fd;
+
+    /* Radeon BO manager. */
+    struct radeon_bo_manager *bom;
+
+    /* Radeon CS manager. */
+    struct radeon_cs_manager *csm;
+
+    /* Current CS. */
+    struct radeon_cs *cs;
+
+    /* Flush CB */
+    void (*flush_cb)(void *);
+    void *flush_data;
+};
+
+static INLINE struct radeon_libdrm_winsys *
+radeon_winsys_screen(struct r300_winsys_screen *base)
+{
+  return (struct radeon_libdrm_winsys *)base;
+}
+
+#endif
diff --git a/src/gallium/winsys/svga/drm/Makefile b/src/gallium/winsys/svga/drm/Makefile
new file mode 100644 (file)
index 0000000..c2f59e0
--- /dev/null
@@ -0,0 +1,27 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = svgadrm
+
+C_SOURCES = \
+        vmw_buffer.c \
+        vmw_context.c  \
+        vmw_fence.c  \
+        vmw_screen.c  \
+        vmw_screen_dri.c  \
+        vmw_screen_ioctl.c  \
+        vmw_screen_pools.c  \
+        vmw_screen_svga.c  \
+        vmw_surface.c
+
+LIBRARY_INCLUDES = \
+       -I$(TOP)/src/gallium/drivers/svga \
+       -I$(TOP)/src/gallium/drivers/svga/include \
+       $(shell pkg-config libdrm --cflags-only-I)
+
+LIBRARY_DEFINES = \
+       -std=gnu99 -fvisibility=hidden \
+       -DHAVE_STDINT_H -D_FILE_OFFSET_BITS=64 \
+       $(shell pkg-config libdrm --cflags-only-other)
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/svga/drm/SConscript b/src/gallium/winsys/svga/drm/SConscript
new file mode 100644 (file)
index 0000000..edaf945
--- /dev/null
@@ -0,0 +1,39 @@
+Import('*')
+
+env = env.Clone()
+
+if env['gcc']:
+       env.Append(CCFLAGS = ['-fvisibility=hidden'])
+       env.Append(CPPDEFINES = [
+               'HAVE_STDINT_H', 
+               'HAVE_SYS_TYPES_H',
+                '-D_FILE_OFFSET_BITS=64',
+       ])
+       
+env.Prepend(CPPPATH = [
+       'include',
+        '#/src/gallium/drivers/svga',
+        '#/src/gallium/drivers/svga/include',
+])
+
+env.Append(CPPDEFINES = [
+])
+
+sources = [
+        'vmw_buffer.c',
+        'vmw_context.c',
+        'vmw_fence.c',
+        'vmw_screen.c',
+        'vmw_screen_dri.c',
+        'vmw_screen_ioctl.c',
+        'vmw_screen_pools.c',
+        'vmw_screen_svga.c',
+        'vmw_surface.c',
+]
+
+svgadrm = env.ConvenienceLibrary(
+       target = 'svgadrm',
+       source = sources,
+)
+
+Export('svgadrm')
diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.c b/src/gallium/winsys/svga/drm/vmw_buffer.c
new file mode 100644 (file)
index 0000000..eca174a
--- /dev/null
@@ -0,0 +1,274 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * SVGA buffer manager for Guest Memory Regions (GMRs).
+ * 
+ * GMRs are used for pixel and vertex data upload/download to/from the virtual
+ * SVGA hardware. There is a limited number of GMRs available, and 
+ * creating/destroying them is also a slow operation so we must suballocate 
+ * them.
+ * 
+ * This file implements a pipebuffer library's buffer manager, so that we can
+ * use pipepbuffer's suballocation, fencing, and debugging facilities with GMRs. 
+ * 
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include "svga_cmd.h"
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_bufmgr.h"
+
+#include "svga_winsys.h"
+
+#include "vmw_screen.h"
+#include "vmw_buffer.h"
+
+
+struct vmw_gmr_bufmgr;
+
+
+struct vmw_gmr_buffer
+{
+   struct pb_buffer base;
+   
+   struct vmw_gmr_bufmgr *mgr;
+   
+   struct vmw_region *region;
+   void *map;
+   
+#ifdef DEBUG
+   struct pipe_fence_handle *last_fence;
+#endif
+};
+
+
+extern const struct pb_vtbl vmw_gmr_buffer_vtbl;
+
+
+static INLINE struct vmw_gmr_buffer *
+vmw_gmr_buffer(struct pb_buffer *buf)
+{
+   assert(buf);
+   assert(buf->vtbl == &vmw_gmr_buffer_vtbl);
+   return (struct vmw_gmr_buffer *)buf;
+}
+
+
+struct vmw_gmr_bufmgr
+{
+   struct pb_manager base;
+   
+   struct vmw_winsys_screen *vws;
+};
+
+
+static INLINE struct vmw_gmr_bufmgr *
+vmw_gmr_bufmgr(struct pb_manager *mgr)
+{
+   assert(mgr);
+   return (struct vmw_gmr_bufmgr *)mgr;
+}
+
+
+static void
+vmw_gmr_buffer_destroy(struct pb_buffer *_buf)
+{
+   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
+
+#ifdef DEBUG
+   if(buf->last_fence) {
+      struct svga_winsys_screen *sws = &buf->mgr->vws->base;
+      assert(sws->fence_signalled(sws, buf->last_fence, 0) == 0);
+   }
+#endif
+
+   vmw_ioctl_region_unmap(buf->region);
+   
+   vmw_ioctl_region_destroy(buf->region);
+
+   FREE(buf);
+}
+
+
+static void *
+vmw_gmr_buffer_map(struct pb_buffer *_buf,
+               unsigned flags)
+{
+   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
+   return buf->map;
+}
+
+
+static void
+vmw_gmr_buffer_unmap(struct pb_buffer *_buf)
+{
+   /* Do nothing */
+   (void)_buf;
+}
+
+
+static void
+vmw_gmr_buffer_get_base_buffer(struct pb_buffer *buf,
+                           struct pb_buffer **base_buf,
+                           unsigned *offset)
+{
+   *base_buf = buf;
+   *offset = 0;
+}
+
+
+static enum pipe_error
+vmw_gmr_buffer_validate( struct pb_buffer *_buf, 
+                         struct pb_validate *vl,
+                         unsigned flags )
+{
+   /* Always pinned */
+   return PIPE_OK;
+}
+
+
+static void
+vmw_gmr_buffer_fence( struct pb_buffer *_buf, 
+                      struct pipe_fence_handle *fence )
+{
+   /* We don't need to do anything, as the pipebuffer library
+    * will take care of delaying the destruction of fenced buffers */  
+#ifdef DEBUG
+   struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
+   if(fence)
+      buf->last_fence = fence;
+#endif
+}
+
+
+const struct pb_vtbl vmw_gmr_buffer_vtbl = {
+   vmw_gmr_buffer_destroy,
+   vmw_gmr_buffer_map,
+   vmw_gmr_buffer_unmap,
+   vmw_gmr_buffer_validate,
+   vmw_gmr_buffer_fence,
+   vmw_gmr_buffer_get_base_buffer
+};
+
+
+static struct pb_buffer *
+vmw_gmr_bufmgr_create_buffer(struct pb_manager *_mgr,
+                         pb_size size,
+                         const struct pb_desc *desc) 
+{
+   struct vmw_gmr_bufmgr *mgr = vmw_gmr_bufmgr(_mgr);
+   struct vmw_winsys_screen *vws = mgr->vws;
+   struct vmw_gmr_buffer *buf;
+   
+   buf = CALLOC_STRUCT(vmw_gmr_buffer);
+   if(!buf)
+      goto error1;
+
+   pipe_reference_init(&buf->base.base.reference, 1);
+   buf->base.base.alignment = desc->alignment;
+   buf->base.base.usage = desc->usage;
+   buf->base.base.size = size;
+   buf->base.vtbl = &vmw_gmr_buffer_vtbl;
+   buf->mgr = mgr;
+
+   buf->region = vmw_ioctl_region_create(vws, size);
+   if(!buf->region)
+      goto error2;
+        
+   buf->map = vmw_ioctl_region_map(buf->region);
+   if(!buf->map)
+      goto error3;
+
+   return &buf->base;
+
+error3:
+   vmw_ioctl_region_destroy(buf->region);
+error2:
+   FREE(buf);
+error1:
+   return NULL;
+}
+
+
+static void
+vmw_gmr_bufmgr_flush(struct pb_manager *mgr) 
+{
+   /* No-op */
+}
+
+
+static void
+vmw_gmr_bufmgr_destroy(struct pb_manager *_mgr) 
+{
+   struct vmw_gmr_bufmgr *mgr = vmw_gmr_bufmgr(_mgr);
+   FREE(mgr);
+}
+
+
+struct pb_manager *
+vmw_gmr_bufmgr_create(struct vmw_winsys_screen *vws) 
+{
+   struct vmw_gmr_bufmgr *mgr;
+   
+   mgr = CALLOC_STRUCT(vmw_gmr_bufmgr);
+   if(!mgr)
+      return NULL;
+
+   mgr->base.destroy = vmw_gmr_bufmgr_destroy;
+   mgr->base.create_buffer = vmw_gmr_bufmgr_create_buffer;
+   mgr->base.flush = vmw_gmr_bufmgr_flush;
+   
+   mgr->vws = vws;
+   
+   return &mgr->base;
+}
+
+
+boolean
+vmw_gmr_bufmgr_region_ptr(struct pb_buffer *buf, 
+                          struct SVGAGuestPtr *ptr)
+{
+   struct pb_buffer *base_buf;
+   unsigned offset = 0;
+   struct vmw_gmr_buffer *gmr_buf;
+   
+   pb_get_base_buffer( buf, &base_buf, &offset );
+   
+   gmr_buf = vmw_gmr_buffer(base_buf);
+   if(!gmr_buf)
+      return FALSE;
+   
+   *ptr = vmw_ioctl_region_ptr(gmr_buf->region);
+   
+   ptr->offset += offset;
+   
+   return TRUE;
+}
diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.h b/src/gallium/winsys/svga/drm/vmw_buffer.h
new file mode 100644 (file)
index 0000000..41fb447
--- /dev/null
@@ -0,0 +1,65 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#ifndef VMW_BUFFER_H_
+#define VMW_BUFFER_H_
+
+#include <assert.h>
+#include "pipe/p_compiler.h"
+
+struct SVGAGuestPtr;
+struct pb_buffer;
+struct pb_manager;
+struct svga_winsys_buffer;
+struct svga_winsys_surface;
+struct vmw_winsys_screen;
+
+
+static INLINE struct pb_buffer *
+vmw_pb_buffer(struct svga_winsys_buffer *buffer)
+{
+   assert(buffer);
+   return (struct pb_buffer *)buffer;
+}
+
+
+static INLINE struct svga_winsys_buffer *
+vmw_svga_winsys_buffer(struct pb_buffer *buffer)
+{
+   assert(buffer);
+   return (struct svga_winsys_buffer *)buffer;
+}
+
+
+struct pb_manager *
+vmw_gmr_bufmgr_create(struct vmw_winsys_screen *vws);
+
+boolean
+vmw_gmr_bufmgr_region_ptr(struct pb_buffer *buf, 
+                          struct SVGAGuestPtr *ptr);
+
+
+#endif /* VMW_BUFFER_H_ */
diff --git a/src/gallium/winsys/svga/drm/vmw_context.c b/src/gallium/winsys/svga/drm/vmw_context.c
new file mode 100644 (file)
index 0000000..90ffc48
--- /dev/null
@@ -0,0 +1,382 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#include "svga_cmd.h"
+
+#include "util/u_debug.h"
+#include "util/u_memory.h"
+#include "util/u_debug_stack.h"
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_validate.h"
+
+#include "svga_winsys.h"
+#include "vmw_context.h"
+#include "vmw_screen.h"
+#include "vmw_buffer.h"
+#include "vmw_surface.h"
+#include "vmw_fence.h"
+
+#define VMW_COMMAND_SIZE (64*1024)
+#define VMW_SURFACE_RELOCS (1024)
+#define VMW_REGION_RELOCS (512)
+
+#define VMW_MUST_FLUSH_STACK 8
+
+struct vmw_region_relocation
+{
+   struct SVGAGuestPtr *where;
+   struct pb_buffer *buffer;
+   /* TODO: put offset info inside where */
+   uint32 offset;
+};
+
+struct vmw_svga_winsys_context
+{
+   struct svga_winsys_context base;
+
+   struct vmw_winsys_screen *vws;
+
+#ifdef DEBUG
+   boolean must_flush;
+   struct debug_stack_frame must_flush_stack[VMW_MUST_FLUSH_STACK];
+#endif
+
+   struct {
+      uint8_t buffer[VMW_COMMAND_SIZE];
+      uint32_t size;
+      uint32_t used;
+      uint32_t reserved;
+   } command;
+
+   struct {
+      struct vmw_svga_winsys_surface *handles[VMW_SURFACE_RELOCS];
+      uint32_t size;
+      uint32_t used;
+      uint32_t staged;
+      uint32_t reserved;
+   } surface;
+   
+   struct {
+      struct vmw_region_relocation relocs[VMW_REGION_RELOCS];
+      uint32_t size;
+      uint32_t used;
+      uint32_t staged;
+      uint32_t reserved;
+   } region;
+
+   struct pb_validate *validate;
+
+   uint32_t last_fence;
+
+   /**
+    * The amount of GMR that is referred by the commands currently batched
+    * in the context.
+    */
+   uint32_t seen_regions;
+
+   /**
+    * Whether this context should fail to reserve more commands, not because it
+    * ran out of command space, but because a substantial ammount of GMR was
+    * referred.
+    */
+   boolean preemptive_flush;
+};
+
+
+static INLINE struct vmw_svga_winsys_context *
+vmw_svga_winsys_context(struct svga_winsys_context *swc)
+{
+   assert(swc);
+   return (struct vmw_svga_winsys_context *)swc;
+}
+
+
+static enum pipe_error
+vmw_swc_flush(struct svga_winsys_context *swc,
+              struct pipe_fence_handle **pfence)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+   struct pipe_fence_handle *fence = NULL;
+   unsigned i;
+   enum pipe_error ret;
+
+   ret = pb_validate_validate(vswc->validate);
+   assert(ret == PIPE_OK);
+   if(ret == PIPE_OK) {
+   
+      /* Apply relocations */
+      for(i = 0; i < vswc->region.used; ++i) {
+         struct vmw_region_relocation *reloc = &vswc->region.relocs[i];
+         struct SVGAGuestPtr ptr;
+
+         if(!vmw_gmr_bufmgr_region_ptr(reloc->buffer, &ptr))
+            assert(0);
+
+         ptr.offset += reloc->offset;
+
+         *reloc->where = ptr;
+      }
+
+      if (vswc->command.used)
+         vmw_ioctl_command(vswc->vws,
+                           vswc->command.buffer,
+                           vswc->command.used,
+                           &vswc->last_fence);
+
+      fence = vmw_pipe_fence(vswc->last_fence);
+
+      pb_validate_fence(vswc->validate, fence);
+   }
+
+   vswc->command.used = 0;
+   vswc->command.reserved = 0;
+
+   for(i = 0; i < vswc->surface.used + vswc->surface.staged; ++i) {
+      struct vmw_svga_winsys_surface *vsurf =
+        vswc->surface.handles[i];
+      p_atomic_dec(&vsurf->validated);
+      vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
+   }
+
+   vswc->surface.used = 0;
+   vswc->surface.reserved = 0;
+
+   for(i = 0; i < vswc->region.used + vswc->region.staged; ++i) {
+      pb_reference(&vswc->region.relocs[i].buffer, NULL);
+   }
+
+   vswc->region.used = 0;
+   vswc->region.reserved = 0;
+
+#ifdef DEBUG
+   vswc->must_flush = FALSE;
+#endif
+   vswc->preemptive_flush = FALSE;
+   vswc->seen_regions = 0;
+
+   if(pfence)
+      *pfence = fence;
+
+   return ret;
+}
+
+
+static void *
+vmw_swc_reserve(struct svga_winsys_context *swc,
+                uint32_t nr_bytes, uint32_t nr_relocs )
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+
+#ifdef DEBUG
+   /* Check if somebody forgot to check the previous failure */
+   if(vswc->must_flush) {
+      debug_printf("Forgot to flush:\n");
+      debug_backtrace_dump(vswc->must_flush_stack, VMW_MUST_FLUSH_STACK);
+      assert(!vswc->must_flush);
+   }
+#endif
+
+   assert(nr_bytes <= vswc->command.size);
+   if(nr_bytes > vswc->command.size)
+      return NULL;
+
+   if(vswc->preemptive_flush ||
+      vswc->command.used + nr_bytes > vswc->command.size ||
+      vswc->surface.used + nr_relocs > vswc->surface.size ||
+      vswc->region.used + nr_relocs > vswc->region.size) {
+#ifdef DEBUG
+      vswc->must_flush = TRUE;
+      debug_backtrace_capture(vswc->must_flush_stack, 1,
+                              VMW_MUST_FLUSH_STACK);
+#endif
+      return NULL;
+   }
+
+   assert(vswc->command.used + nr_bytes <= vswc->command.size);
+   assert(vswc->surface.used + nr_relocs <= vswc->surface.size);
+   assert(vswc->region.used + nr_relocs <= vswc->region.size);
+   
+   vswc->command.reserved = nr_bytes;
+   vswc->surface.reserved = nr_relocs;
+   vswc->surface.staged = 0;
+   vswc->region.reserved = nr_relocs;
+   vswc->region.staged = 0;
+   
+   return vswc->command.buffer + vswc->command.used;
+}
+
+
+static void
+vmw_swc_surface_relocation(struct svga_winsys_context *swc,
+                           uint32 *where,
+                           struct svga_winsys_surface *surface,
+                           unsigned flags)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+   struct vmw_svga_winsys_surface *vsurf;
+
+   if(!surface) {
+      *where = SVGA3D_INVALID_ID;
+      return;
+   }
+
+   assert(vswc->surface.staged < vswc->surface.reserved);
+
+   vsurf = vmw_svga_winsys_surface(surface);
+
+   *where = vsurf->sid;
+
+   vmw_svga_winsys_surface_reference(&vswc->surface.handles[vswc->surface.used + vswc->surface.staged], vsurf);
+   p_atomic_inc(&vsurf->validated);
+   ++vswc->surface.staged;
+}
+
+
+static void
+vmw_swc_region_relocation(struct svga_winsys_context *swc,
+                          struct SVGAGuestPtr *where,
+                          struct svga_winsys_buffer *buffer,
+                          uint32 offset,
+                          unsigned flags)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+   struct vmw_region_relocation *reloc;
+   enum pipe_error ret;
+   
+   assert(vswc->region.staged < vswc->region.reserved);
+
+   reloc = &vswc->region.relocs[vswc->region.used + vswc->region.staged];
+   reloc->where = where;
+   pb_reference(&reloc->buffer, vmw_pb_buffer(buffer));
+   reloc->offset = offset;
+
+   ++vswc->region.staged;
+
+   ret = pb_validate_add_buffer(vswc->validate, reloc->buffer, flags);
+   /* TODO: Update pipebuffer to reserve buffers and not fail here */
+   assert(ret == PIPE_OK);
+
+   /*
+    * Flush preemptively the FIFO commands to keep the GMR working set within
+    * the GMR pool size.
+    *
+    * This is necessary for applications like SPECviewperf that generate huge
+    * amounts of immediate vertex data, so that we don't pile up too much of
+    * that vertex data neither in the guest nor in the host.
+    *
+    * Note that in the current implementation if a region is referred twice in
+    * a command stream, it will be accounted twice. We could detect repeated
+    * regions and count only once, but there is no incentive to do that, since
+    * regions are typically short-lived; always referred in a single command;
+    * and at the worst we just flush the commands a bit sooner, which for the
+    * SVGA virtual device it's not a performance issue since flushing commands
+    * to the FIFO won't cause flushing in the host.
+    */
+   vswc->seen_regions += reloc->buffer->base.size;
+   if(vswc->seen_regions >= VMW_GMR_POOL_SIZE/2)
+      vswc->preemptive_flush = TRUE;
+}
+
+
+static void
+vmw_swc_commit(struct svga_winsys_context *swc)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+
+   assert(vswc->command.reserved);
+   assert(vswc->command.used + vswc->command.reserved <= vswc->command.size);
+   vswc->command.used += vswc->command.reserved;
+   vswc->command.reserved = 0;
+
+   assert(vswc->surface.staged <= vswc->surface.reserved);
+   assert(vswc->surface.used + vswc->surface.staged <= vswc->surface.size);
+   vswc->surface.used += vswc->surface.staged;
+   vswc->surface.staged = 0;
+   vswc->surface.reserved = 0;
+
+   assert(vswc->region.staged <= vswc->region.reserved);
+   assert(vswc->region.used + vswc->region.staged <= vswc->region.size);
+   vswc->region.used += vswc->region.staged;
+   vswc->region.staged = 0;
+   vswc->region.reserved = 0;
+}
+
+
+static void
+vmw_swc_destroy(struct svga_winsys_context *swc)
+{
+   struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
+   unsigned i;
+
+   for(i = 0; i < vswc->region.used; ++i) {
+      pb_reference(&vswc->region.relocs[i].buffer, NULL);
+   }
+
+   for(i = 0; i < vswc->surface.used; ++i) {
+      p_atomic_dec(&vswc->surface.handles[i]->validated);
+      vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
+   }
+   pb_validate_destroy(vswc->validate);
+   vmw_ioctl_context_destroy(vswc->vws, swc->cid);
+   FREE(vswc);
+}
+
+
+struct svga_winsys_context *
+vmw_svga_winsys_context_create(struct svga_winsys_screen *sws)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   struct vmw_svga_winsys_context *vswc;
+
+   vswc = CALLOC_STRUCT(vmw_svga_winsys_context);
+   if(!vswc)
+      return NULL;
+
+   vswc->base.destroy = vmw_swc_destroy;
+   vswc->base.reserve = vmw_swc_reserve;
+   vswc->base.surface_relocation = vmw_swc_surface_relocation;
+   vswc->base.region_relocation = vmw_swc_region_relocation;
+   vswc->base.commit = vmw_swc_commit;
+   vswc->base.flush = vmw_swc_flush;
+
+   vswc->base.cid = vmw_ioctl_context_create(vws);
+
+   vswc->vws = vws;
+
+   vswc->command.size = VMW_COMMAND_SIZE;
+   vswc->surface.size = VMW_SURFACE_RELOCS;
+   vswc->region.size = VMW_REGION_RELOCS;
+
+   vswc->validate = pb_validate_create();
+   if(!vswc->validate) {
+      FREE(vswc);
+      return NULL;
+   }
+
+   return &vswc->base;
+}
+
+
diff --git a/src/gallium/winsys/svga/drm/vmw_context.h b/src/gallium/winsys/svga/drm/vmw_context.h
new file mode 100644 (file)
index 0000000..d4884d2
--- /dev/null
@@ -0,0 +1,56 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#ifndef VMW_CONTEXT_H_
+#define VMW_CONTEXT_H_
+
+#include "pipe/p_compiler.h"
+
+struct svga_winsys_screen;
+struct svga_winsys_context;
+struct pipe_context;
+struct pipe_screen;
+
+#define VMW_DEBUG 0
+
+#if VMW_DEBUG
+#define vmw_printf debug_printf
+#define VMW_FUNC  debug_printf("%s\n", __FUNCTION__)
+#else
+#define VMW_FUNC
+#define vmw_printf(...)
+#endif
+
+
+struct svga_winsys_context *
+vmw_svga_winsys_context_create(struct svga_winsys_screen *sws);
+
+
+#endif /* VMW_CONTEXT_H_ */
diff --git a/src/gallium/winsys/svga/drm/vmw_fence.c b/src/gallium/winsys/svga/drm/vmw_fence.c
new file mode 100644 (file)
index 0000000..873dd51
--- /dev/null
@@ -0,0 +1,108 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#include "util/u_memory.h"
+#include "pipebuffer/pb_buffer_fenced.h"
+
+#include "vmw_screen.h"
+#include "vmw_fence.h"
+
+
+
+struct vmw_fence_ops 
+{
+   struct pb_fence_ops base;
+
+   struct vmw_winsys_screen *vws;
+};
+
+
+static INLINE struct vmw_fence_ops *
+vmw_fence_ops(struct pb_fence_ops *ops)
+{
+   assert(ops);
+   return (struct vmw_fence_ops *)ops;
+}
+
+
+static void
+vmw_fence_ops_fence_reference(struct pb_fence_ops *ops,
+                              struct pipe_fence_handle **ptr,
+                              struct pipe_fence_handle *fence)
+{
+   *ptr = fence;
+}
+
+
+static int
+vmw_fence_ops_fence_signalled(struct pb_fence_ops *ops,
+                              struct pipe_fence_handle *fence,
+                              unsigned flag)
+{
+   struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
+   (void)flag;
+   return vmw_ioctl_fence_signalled(vws, vmw_fence(fence));
+}
+
+
+static int
+vmw_fence_ops_fence_finish(struct pb_fence_ops *ops,
+                           struct pipe_fence_handle *fence,
+                           unsigned flag)
+{
+   struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
+   (void)flag;
+   return vmw_ioctl_fence_finish(vws, vmw_fence(fence));
+}
+
+
+static void
+vmw_fence_ops_destroy(struct pb_fence_ops *ops)
+{
+   FREE(ops);
+}
+
+
+struct pb_fence_ops *
+vmw_fence_ops_create(struct vmw_winsys_screen *vws) 
+{
+   struct vmw_fence_ops *ops;
+
+   ops = CALLOC_STRUCT(vmw_fence_ops);
+   if(!ops)
+      return NULL;
+
+   ops->base.destroy = &vmw_fence_ops_destroy;
+   ops->base.fence_reference = &vmw_fence_ops_fence_reference;
+   ops->base.fence_signalled = &vmw_fence_ops_fence_signalled;
+   ops->base.fence_finish = &vmw_fence_ops_fence_finish;
+
+   ops->vws = vws;
+
+   return &ops->base;
+}
+
+
diff --git a/src/gallium/winsys/svga/drm/vmw_fence.h b/src/gallium/winsys/svga/drm/vmw_fence.h
new file mode 100644 (file)
index 0000000..5357b4f
--- /dev/null
@@ -0,0 +1,59 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#ifndef VMW_FENCE_H_
+#define VMW_FENCE_H_
+
+
+#include "pipe/p_compiler.h"
+
+
+struct pipe_fence_handle;
+struct pb_fence_ops;
+struct vmw_winsys_screen;
+
+
+/** Cast from a pipe_fence_handle pointer into a SVGA fence */
+static INLINE uint32_t
+vmw_fence( struct pipe_fence_handle *fence )
+{
+   return (uint32_t)(uintptr_t)fence;
+}
+
+
+/** Cast from a SVGA fence number to pipe_fence_handle pointer */
+static INLINE struct pipe_fence_handle *
+vmw_pipe_fence( uint32_t fence )
+{
+   return (struct pipe_fence_handle *)(uintptr_t)fence;
+}
+
+
+struct pb_fence_ops *
+vmw_fence_ops_create(struct vmw_winsys_screen *vws); 
+
+
+#endif /* VMW_FENCE_H_ */
diff --git a/src/gallium/winsys/svga/drm/vmw_screen.c b/src/gallium/winsys/svga/drm/vmw_screen.c
new file mode 100644 (file)
index 0000000..6cc9b38
--- /dev/null
@@ -0,0 +1,77 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#include "vmw_screen.h"
+
+#include "vmw_context.h"
+
+#include "util/u_memory.h"
+#include "pipe/p_compiler.h"
+
+
+/* Called from vmw_drm_create_screen(), creates and initializes the
+ * vmw_winsys_screen structure, which is the main entity in this
+ * module.
+ */
+struct vmw_winsys_screen *
+vmw_winsys_create( int fd, boolean use_old_scanout_flag )
+{
+   struct vmw_winsys_screen *vws = CALLOC_STRUCT(vmw_winsys_screen);
+   if (!vws)
+      goto out_no_vws;
+
+   vws->ioctl.drm_fd = fd;
+   vws->use_old_scanout_flag = use_old_scanout_flag;
+   debug_printf("%s: use_old_scanout_flag == %s\n", __FUNCTION__,
+               use_old_scanout_flag ? "true" : "false");
+
+   if (!vmw_ioctl_init(vws))
+      goto out_no_ioctl;
+
+   if(!vmw_pools_init(vws))
+      goto out_no_pools;
+
+   if (!vmw_winsys_screen_init_svga(vws))
+      goto out_no_svga;
+
+   return vws;
+out_no_svga:
+   vmw_pools_cleanup(vws);
+out_no_pools:
+   vmw_ioctl_cleanup(vws);
+out_no_ioctl:
+   FREE(vws);
+out_no_vws:
+   return NULL;
+}
+
+void
+vmw_winsys_destroy(struct vmw_winsys_screen *vws)
+{
+   vmw_pools_cleanup(vws);
+   vmw_ioctl_cleanup(vws);
+   FREE(vws);
+}
diff --git a/src/gallium/winsys/svga/drm/vmw_screen.h b/src/gallium/winsys/svga/drm/vmw_screen.h
new file mode 100644 (file)
index 0000000..d3f2c2c
--- /dev/null
@@ -0,0 +1,140 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Common definitions for the VMware SVGA winsys.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#ifndef VMW_SCREEN_H_
+#define VMW_SCREEN_H_
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+#include "svga_winsys.h"
+
+
+#define VMW_GMR_POOL_SIZE (16*1024*1024)
+
+
+struct pb_manager;
+struct vmw_region;
+
+
+struct vmw_winsys_screen
+{
+   struct svga_winsys_screen base;
+
+   boolean use_old_scanout_flag;
+
+   struct {
+      volatile uint32_t *fifo_map;
+      uint64_t last_fence;
+      int drm_fd;
+   } ioctl;
+
+   struct {
+      struct pb_manager *gmr;
+      struct pb_manager *gmr_mm;
+      struct pb_manager *gmr_fenced;
+   } pools;
+};
+
+
+static INLINE struct vmw_winsys_screen *
+vmw_winsys_screen(struct svga_winsys_screen *base)
+{
+   return (struct vmw_winsys_screen *)base;
+}
+
+/*  */
+uint32
+vmw_ioctl_context_create(struct vmw_winsys_screen *vws);
+
+void
+vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws,
+                          uint32 cid);
+
+uint32
+vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
+                              SVGA3dSurfaceFlags flags,
+                              SVGA3dSurfaceFormat format,
+                              SVGA3dSize size,
+                              uint32 numFaces,
+                              uint32 numMipLevels);
+
+void
+vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws,
+                          uint32 sid);
+
+void
+vmw_ioctl_command(struct vmw_winsys_screen *vws,
+                       void *commands,
+                       uint32_t size,
+                       uint32_t *fence);
+
+struct vmw_region *
+vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size);
+
+void
+vmw_ioctl_region_destroy(struct vmw_region *region);
+
+struct SVGAGuestPtr
+vmw_ioctl_region_ptr(struct vmw_region *region);
+
+void *
+vmw_ioctl_region_map(struct vmw_region *region);
+void
+vmw_ioctl_region_unmap(struct vmw_region *region);
+
+
+int
+vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
+                       uint32_t fence);
+
+int
+vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
+                          uint32_t fence);
+
+
+/* Initialize parts of vmw_winsys_screen at startup:
+ */
+boolean vmw_ioctl_init(struct vmw_winsys_screen *vws);
+boolean vmw_pools_init(struct vmw_winsys_screen *vws);
+boolean vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws);
+
+void vmw_ioctl_cleanup(struct vmw_winsys_screen *vws);
+void vmw_pools_cleanup(struct vmw_winsys_screen *vws);
+
+struct vmw_winsys_screen *vmw_winsys_create(int fd, boolean use_old_scanout_flag);
+void vmw_winsys_destroy(struct vmw_winsys_screen *sws);
+
+
+#endif /* VMW_SCREEN_H_ */
diff --git a/src/gallium/winsys/svga/drm/vmw_screen_dri.c b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
new file mode 100644 (file)
index 0000000..e8ebe9a
--- /dev/null
@@ -0,0 +1,373 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#include "pipe/p_compiler.h"
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_format.h"
+#include "vmw_screen.h"
+
+#include "trace/tr_drm.h"
+
+#include "vmw_screen.h"
+#include "vmw_surface.h"
+#include "vmw_fence.h"
+#include "vmw_context.h"
+
+#include <state_tracker/dri1_api.h>
+#include <state_tracker/drm_api.h>
+#include "vmwgfx_drm.h"
+#include <xf86drm.h>
+
+#include <stdio.h>
+
+static struct svga_winsys_surface *
+vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
+                           struct winsys_handle *whandle,
+                           SVGA3dSurfaceFormat *format);
+static boolean
+vmw_drm_surface_get_handle(struct svga_winsys_screen *sws,
+                          struct svga_winsys_surface *surface,
+                          unsigned stride,
+                          struct winsys_handle *whandle);
+
+static struct dri1_api dri1_api_hooks;
+static struct dri1_api_version ddx_required = { 0, 1, 0 };
+static struct dri1_api_version ddx_compat = { 0, 0, 0 };
+static struct dri1_api_version dri_required = { 4, 0, 0 };
+static struct dri1_api_version dri_compat = { 4, 0, 0 };
+static struct dri1_api_version drm_required = { 1, 0, 0 };
+static struct dri1_api_version drm_compat = { 1, 0, 0 };
+static struct dri1_api_version drm_scanout = { 0, 9, 0 };
+
+static boolean
+vmw_dri1_check_version(const struct dri1_api_version *cur,
+                      const struct dri1_api_version *required,
+                      const struct dri1_api_version *compat,
+                      const char component[])
+{
+   if (cur->major > required->major && cur->major <= compat->major)
+      return TRUE;
+   if (cur->major == required->major && cur->minor >= required->minor)
+      return TRUE;
+
+   fprintf(stderr, "%s version failure.\n", component);
+   fprintf(stderr, "%s version is %d.%d.%d and this driver can only work\n"
+          "with versions %d.%d.x through %d.x.x.\n",
+          component,
+          cur->major,
+          cur->minor,
+          cur->patch_level, required->major, required->minor, compat->major);
+   return FALSE;
+}
+
+/* This is actually the entrypoint to the entire driver, called by the
+ * libGL (or EGL, or ...) code via the drm_api_hooks table at the
+ * bottom of the file.
+ */
+static struct pipe_screen *
+vmw_drm_create_screen(struct drm_api *drm_api,
+                      int fd,
+                      struct drm_create_screen_arg *arg)
+{
+   struct vmw_winsys_screen *vws;
+   struct pipe_screen *screen;
+   struct dri1_create_screen_arg *dri1;
+   boolean use_old_scanout_flag = FALSE;
+
+   if (!arg || arg->mode == DRM_CREATE_NORMAL) {
+      struct dri1_api_version drm_ver;
+      drmVersionPtr ver;
+
+      ver = drmGetVersion(fd);
+      if (ver == NULL)
+        return NULL;
+
+      drm_ver.major = ver->version_major;
+      drm_ver.minor = ver->version_minor;
+      drm_ver.patch_level = 0; /* ??? */
+
+      drmFreeVersion(ver);
+      if (!vmw_dri1_check_version(&drm_ver, &drm_required,
+                                 &drm_compat, "vmwgfx drm driver"))
+        return NULL;
+
+      if (!vmw_dri1_check_version(&drm_ver, &drm_scanout,
+                                 &drm_compat, "use old scanout field (not a error)"))
+         use_old_scanout_flag = TRUE;
+   }
+
+   if (arg != NULL) {
+      switch (arg->mode) {
+      case DRM_CREATE_NORMAL:
+        break;
+      case DRM_CREATE_DRI1:
+        dri1 = (struct dri1_create_screen_arg *)arg;
+        if (!vmw_dri1_check_version(&dri1->ddx_version, &ddx_required,
+                                    &ddx_compat, "ddx - driver api"))
+           return NULL;
+        if (!vmw_dri1_check_version(&dri1->dri_version, &dri_required,
+                                    &dri_compat, "dri info"))
+           return NULL;
+        if (!vmw_dri1_check_version(&dri1->drm_version, &drm_required,
+                                    &drm_compat, "vmwgfx drm driver"))
+           return NULL;
+        if (!vmw_dri1_check_version(&dri1->drm_version, &drm_scanout,
+                                    &drm_compat, "use old scanout field (not a error)"))
+           use_old_scanout_flag = TRUE;
+        dri1->api = &dri1_api_hooks;
+#if 0
+        break;
+#else
+        assert(!"No dri 1 support for now\n");
+        return NULL;
+#endif
+      default:
+        return NULL;
+      }
+   }
+
+   vws = vmw_winsys_create( fd, use_old_scanout_flag );
+   if (!vws)
+      goto out_no_vws;
+
+   /* XXX do this properly */
+   vws->base.surface_from_handle = vmw_drm_surface_from_handle;
+   vws->base.surface_get_handle = vmw_drm_surface_get_handle;
+
+   screen = svga_screen_create( &vws->base );
+   if (!screen)
+      goto out_no_screen;
+
+   return screen;
+
+   /* Failure cases:
+    */
+out_no_screen:
+   vmw_winsys_destroy( vws );
+
+out_no_vws:
+   return NULL;
+}
+
+static INLINE boolean
+vmw_dri1_intersect_src_bbox(struct drm_clip_rect *dst,
+                           int dst_x,
+                           int dst_y,
+                           const struct drm_clip_rect *src,
+                           const struct drm_clip_rect *bbox)
+{
+   int xy1;
+   int xy2;
+
+   xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
+      (int)bbox->x1 + dst_x;
+   xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
+      (int)bbox->x2 + dst_x;
+   if (xy1 >= xy2 || xy1 < 0)
+      return FALSE;
+
+   dst->x1 = xy1;
+   dst->x2 = xy2;
+
+   xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
+      (int)bbox->y1 + dst_y;
+   xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
+      (int)bbox->y2 + dst_y;
+   if (xy1 >= xy2 || xy1 < 0)
+      return FALSE;
+
+   dst->y1 = xy1;
+   dst->y2 = xy2;
+   return TRUE;
+}
+
+/**
+ * No fancy get-surface-from-sarea stuff here.
+ * Just use the present blit.
+ */
+
+static void
+vmw_dri1_present_locked(struct pipe_context *locked_pipe,
+                       struct pipe_surface *surf,
+                       const struct drm_clip_rect *rect,
+                       unsigned int num_clip,
+                       int x_draw, int y_draw,
+                       const struct drm_clip_rect *bbox,
+                       struct pipe_fence_handle **p_fence)
+{
+#if 0
+   struct svga_winsys_surface *srf =
+      svga_screen_texture_get_winsys_surface(surf->texture);
+   struct vmw_svga_winsys_surface *vsrf = vmw_svga_winsys_surface(srf);
+   struct vmw_winsys_screen *vws =
+      vmw_winsys_screen(svga_winsys_screen(locked_pipe->screen));
+   struct drm_clip_rect clip;
+   int i;
+   struct
+   {
+      SVGA3dCmdHeader header;
+      SVGA3dCmdPresent body;
+      SVGA3dCopyRect rect;
+   } cmd;
+   boolean visible = FALSE;
+   uint32_t fence_seq = 0;
+
+   VMW_FUNC;
+   cmd.header.id = SVGA_3D_CMD_PRESENT;
+   cmd.header.size = sizeof cmd.body + sizeof cmd.rect;
+   cmd.body.sid = vsrf->sid;
+
+   for (i = 0; i < num_clip; ++i) {
+      if (!vmw_dri1_intersect_src_bbox(&clip, x_draw, y_draw, rect++, bbox))
+        continue;
+
+      cmd.rect.x = clip.x1;
+      cmd.rect.y = clip.y1;
+      cmd.rect.w = clip.x2 - clip.x1;
+      cmd.rect.h = clip.y2 - clip.y1;
+      cmd.rect.srcx = (int)clip.x1 - x_draw;
+      cmd.rect.srcy = (int)clip.y1 - y_draw;
+
+      vmw_printf("%s: Clip %d x %d y %d w %d h %d srcx %d srcy %d\n",
+                  __FUNCTION__,
+                  i,
+                  cmd.rect.x,
+                  cmd.rect.y,
+                  cmd.rect.w, cmd.rect.h, cmd.rect.srcx, cmd.rect.srcy);
+
+      vmw_ioctl_command(vws, &cmd, sizeof cmd.header + cmd.header.size,
+                        &fence_seq);
+      visible = TRUE;
+   }
+
+   *p_fence = (visible) ? vmw_pipe_fence(fence_seq) : NULL;
+   vmw_svga_winsys_surface_reference(&vsrf, NULL);
+#else
+   assert(!"No dri 1 support for now\n");
+#endif
+}
+
+static struct svga_winsys_surface *
+vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
+                           struct winsys_handle *whandle,
+                           SVGA3dSurfaceFormat *format)
+{
+    struct vmw_svga_winsys_surface *vsrf;
+    struct svga_winsys_surface *ssrf;
+    struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+    union drm_vmw_surface_reference_arg arg;
+    struct drm_vmw_surface_arg *req = &arg.req;
+    struct drm_vmw_surface_create_req *rep = &arg.rep;
+    int ret;
+    int i;
+
+    /**
+     * The vmware device specific handle is the hardware SID.
+     * FIXME: We probably want to move this to the ioctl implementations.
+     */
+
+    memset(&arg, 0, sizeof(arg));
+    req->sid = whandle->handle;
+
+    ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_REF_SURFACE,
+                             &arg, sizeof(arg));
+
+    if (ret) {
+       fprintf(stderr, "Failed referencing shared surface. SID %d.\n"
+               "Error %d (%s).\n",
+               whandle->handle, ret, strerror(-ret));
+       return NULL;
+    }
+
+    if (rep->mip_levels[0] != 1) {
+       fprintf(stderr, "Incorrect number of mipmap levels on shared surface."
+               " SID %d, levels %d\n",
+               whandle->handle, rep->mip_levels[0]);
+       goto out_mip;
+    }
+
+    for (i=1; i < DRM_VMW_MAX_SURFACE_FACES; ++i) {
+       if (rep->mip_levels[i] != 0) {
+           fprintf(stderr, "Incorrect number of faces levels on shared surface."
+                   " SID %d, face %d present.\n",
+                   whandle->handle, i);
+           goto out_mip;
+       }
+    }
+
+    vsrf = CALLOC_STRUCT(vmw_svga_winsys_surface);
+    if (!vsrf)
+       goto out_mip;
+
+    pipe_reference_init(&vsrf->refcnt, 1);
+    p_atomic_set(&vsrf->validated, 0);
+    vsrf->screen = vws;
+    vsrf->sid = whandle->handle;
+    ssrf = svga_winsys_surface(vsrf);
+    *format = rep->format;
+
+    return ssrf;
+
+out_mip:
+    vmw_ioctl_surface_destroy(vws, whandle->handle);
+    return NULL;
+}
+
+static boolean
+vmw_drm_surface_get_handle(struct svga_winsys_screen *sws,
+                          struct svga_winsys_surface *surface,
+                          unsigned stride,
+                          struct winsys_handle *whandle)
+{
+    struct vmw_svga_winsys_surface *vsrf;
+
+    if (!surface)
+       return FALSE;
+
+    vsrf = vmw_svga_winsys_surface(surface);
+    whandle->handle = vsrf->sid;
+    whandle->stride = stride;
+
+    return TRUE;
+}
+
+
+static struct dri1_api dri1_api_hooks = {
+   .front_srf_locked = NULL,
+   .present_locked = vmw_dri1_present_locked
+};
+
+static struct drm_api vmw_drm_api_hooks = {
+   .name = "vmwgfx",
+   .driver_name = "vmwgfx",
+   .create_screen = vmw_drm_create_screen,
+};
+
+struct drm_api* drm_api_create()
+{
+   return trace_drm_create(&vmw_drm_api_hooks);
+}
diff --git a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
new file mode 100644 (file)
index 0000000..5d81fa8
--- /dev/null
@@ -0,0 +1,529 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ *
+ * Wrappers for DRM ioctl functionlaity used by the rest of the vmw
+ * drm winsys.
+ *
+ * Based on svgaicd_escape.c
+ */
+
+
+#include "svga_cmd.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "svgadump/svga_dump.h"
+#include "vmw_screen.h"
+#include "vmw_context.h"
+#include "xf86drm.h"
+#include "vmwgfx_drm.h"
+
+#include <sys/mman.h>
+#include <errno.h>
+#include <unistd.h>
+
+struct vmw_region
+{
+   SVGAGuestPtr ptr;
+   uint32_t handle;
+   uint64_t map_handle;
+   void *data;
+   uint32_t map_count;
+   int drm_fd;
+   uint32_t size;
+};
+
+/* XXX: This isn't a real hardware flag, but just a hack for kernel to
+ * know about primary surfaces. In newer versions of the kernel
+ * interface the driver uses a special field.
+ */
+#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
+
+static void
+vmw_check_last_cmd(struct vmw_winsys_screen *vws)
+{
+   static uint32_t buffer[16384];
+   struct drm_vmw_fifo_debug_arg arg;
+   int ret;
+
+   return;
+   memset(&arg, 0, sizeof(arg));
+   arg.debug_buffer = (unsigned long)buffer;
+   arg.debug_buffer_size = 65536;
+
+   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_FIFO_DEBUG,
+                            &arg, sizeof(arg));
+
+   if (ret) {
+      debug_printf("%s Ioctl error: \"%s\".\n", __FUNCTION__, strerror(-ret));
+      return;
+   }
+
+   if (arg.did_not_fit) {
+      debug_printf("%s Command did not fit completely.\n", __FUNCTION__);
+   }
+
+   svga_dump_commands(buffer, arg.used_size);
+}
+
+static void
+vmw_ioctl_fifo_unmap(struct vmw_winsys_screen *vws, void *mapping)
+{
+   VMW_FUNC;
+   (void)munmap(mapping, getpagesize());
+}
+
+
+static void *
+vmw_ioctl_fifo_map(struct vmw_winsys_screen *vws,
+                   uint32_t fifo_offset )
+{
+   void *map;
+
+   VMW_FUNC;
+
+   map = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED,
+             vws->ioctl.drm_fd, fifo_offset);
+
+   if (map == MAP_FAILED) {
+      debug_printf("Map failed %s\n", strerror(errno));
+      return NULL;
+   }
+
+   vmw_printf("Fifo (min) is 0x%08x\n", ((uint32_t *) map)[SVGA_FIFO_MIN]);
+
+   return map;
+}
+
+uint32
+vmw_ioctl_context_create(struct vmw_winsys_screen *vws)
+{
+   struct drm_vmw_context_arg c_arg;
+   int ret;
+
+   VMW_FUNC;
+
+   ret = drmCommandRead(vws->ioctl.drm_fd, DRM_VMW_CREATE_CONTEXT,
+                       &c_arg, sizeof(c_arg));
+
+   if (ret)
+      return -1;
+
+   vmw_check_last_cmd(vws);
+   vmw_printf("Context id is %d\n", c_arg.cid);
+
+   return c_arg.cid;
+}
+
+void
+vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws, uint32 cid)
+{
+   struct drm_vmw_context_arg c_arg;
+
+   VMW_FUNC;
+
+   memset(&c_arg, 0, sizeof(c_arg));
+   c_arg.cid = cid;
+
+   (void)drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_UNREF_CONTEXT,
+                        &c_arg, sizeof(c_arg));
+
+   vmw_check_last_cmd(vws);
+}
+
+uint32
+vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
+                             SVGA3dSurfaceFlags flags,
+                             SVGA3dSurfaceFormat format,
+                             SVGA3dSize size,
+                             uint32_t numFaces, uint32_t numMipLevels)
+{
+   union drm_vmw_surface_create_arg s_arg;
+   struct drm_vmw_surface_create_req *req = &s_arg.req;
+   struct drm_vmw_surface_arg *rep = &s_arg.rep;
+   struct drm_vmw_size sizes[DRM_VMW_MAX_SURFACE_FACES*
+                            DRM_VMW_MAX_MIP_LEVELS];
+   struct drm_vmw_size *cur_size;
+   uint32_t iFace;
+   uint32_t iMipLevel;
+   int ret;
+
+   vmw_printf("%s flags %d format %d\n", __FUNCTION__, flags, format);
+
+   memset(&s_arg, 0, sizeof(s_arg));
+   if (vws->use_old_scanout_flag &&
+       (flags & SVGA3D_SURFACE_HINT_SCANOUT)) {
+      req->flags = (uint32_t) flags;
+      req->scanout = false;
+   } else if (flags & SVGA3D_SURFACE_HINT_SCANOUT) {
+      req->flags = (uint32_t) (flags & ~SVGA3D_SURFACE_HINT_SCANOUT);
+      req->scanout = true;
+   } else {
+      req->flags = (uint32_t) flags;
+      req->scanout = false;
+   }
+   req->format = (uint32_t) format;
+   req->shareable = 1;
+
+   assert(numFaces * numMipLevels < DRM_VMW_MAX_SURFACE_FACES*
+         DRM_VMW_MAX_MIP_LEVELS);
+   cur_size = sizes;
+   for (iFace = 0; iFace < numFaces; ++iFace) {
+      SVGA3dSize mipSize = size;
+
+      req->mip_levels[iFace] = numMipLevels;
+      for (iMipLevel = 0; iMipLevel < numMipLevels; ++iMipLevel) {
+        cur_size->width = mipSize.width;
+        cur_size->height = mipSize.height;
+        cur_size->depth = mipSize.depth;
+        mipSize.width = MAX2(mipSize.width >> 1, 1);
+        mipSize.height = MAX2(mipSize.height >> 1, 1);
+        mipSize.depth = MAX2(mipSize.depth >> 1, 1);
+        cur_size++;
+      }
+   }
+   for (iFace = numFaces; iFace < SVGA3D_MAX_SURFACE_FACES; ++iFace) {
+      req->mip_levels[iFace] = 0;
+   }
+
+   req->size_addr = (unsigned long)&sizes;
+
+   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_CREATE_SURFACE,
+                            &s_arg, sizeof(s_arg));
+
+   if (ret)
+      return -1;
+
+   vmw_printf("Surface id is %d\n", rep->sid);
+   vmw_check_last_cmd(vws);
+
+   return rep->sid;
+}
+
+void
+vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws, uint32 sid)
+{
+   struct drm_vmw_surface_arg s_arg;
+
+   VMW_FUNC;
+
+   memset(&s_arg, 0, sizeof(s_arg));
+   s_arg.sid = sid;
+
+   (void)drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_UNREF_SURFACE,
+                        &s_arg, sizeof(s_arg));
+   vmw_check_last_cmd(vws);
+
+}
+
+void
+vmw_ioctl_command(struct vmw_winsys_screen *vws, void *commands, uint32_t size,
+                      uint32_t * pfence)
+{
+   struct drm_vmw_execbuf_arg arg;
+   struct drm_vmw_fence_rep rep;
+   int ret;
+
+#ifdef DEBUG
+   {
+      static boolean firsttime = TRUE;
+      static boolean debug = FALSE;
+      static boolean skip = FALSE;
+      if (firsttime) {
+         debug = debug_get_bool_option("SVGA_DUMP_CMD", FALSE);
+         skip = debug_get_bool_option("SVGA_SKIP_CMD", FALSE);
+      }
+      if (debug) {
+         VMW_FUNC;
+         svga_dump_commands(commands, size);
+      }
+      firsttime = FALSE;
+      if (skip) {
+         size = 0;
+      }
+   }
+#endif
+
+   memset(&arg, 0, sizeof(arg));
+   memset(&rep, 0, sizeof(rep));
+
+   rep.error = -EFAULT;
+   arg.fence_rep = (unsigned long)&rep;
+   arg.commands = (unsigned long)commands;
+   arg.command_size = size;
+
+   do {
+       ret = drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_EXECBUF, &arg, sizeof(arg));
+   } while(ret == -ERESTART);
+   if (ret) {
+      debug_printf("%s error %s.\n", __FUNCTION__, strerror(-ret));
+   }
+   if (rep.error) {
+
+      /*
+       * Kernel has synced and put the last fence sequence in the FIFO
+       * register.
+       */
+
+      if (rep.error == -EFAULT)
+        rep.fence_seq = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
+
+      debug_printf("%s Fence error %s.\n", __FUNCTION__,
+                  strerror(-rep.error));
+   }
+
+   vws->ioctl.last_fence = rep.fence_seq;
+
+   if (pfence)
+      *pfence = rep.fence_seq;
+   vmw_check_last_cmd(vws);
+
+}
+
+
+struct vmw_region *
+vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size)
+{
+   struct vmw_region *region;
+   union drm_vmw_alloc_dmabuf_arg arg;
+   struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
+   struct drm_vmw_dmabuf_rep *rep = &arg.rep;
+   int ret;
+
+   vmw_printf("%s: size = %u\n", __FUNCTION__, size);
+
+   region = CALLOC_STRUCT(vmw_region);
+   if (!region)
+      goto out_err1;
+
+   memset(&arg, 0, sizeof(arg));
+   req->size = size;
+   do {
+      ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_ALLOC_DMABUF, &arg,
+                               sizeof(arg));
+   } while (ret == -ERESTART);
+
+   if (ret) {
+      debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
+      goto out_err1;
+   }
+
+   region->ptr.gmrId = rep->cur_gmr_id;
+   region->ptr.offset = rep->cur_gmr_offset;
+   region->data = NULL;
+   region->handle = rep->handle;
+   region->map_handle = rep->map_handle;
+   region->map_count = 0;
+   region->size = size;
+   region->drm_fd = vws->ioctl.drm_fd;
+
+   vmw_printf("   gmrId = %u, offset = %u\n",
+              region->ptr.gmrId, region->ptr.offset);
+
+   return region;
+
+ out_err1:
+   FREE(region);
+   return NULL;
+}
+
+void
+vmw_ioctl_region_destroy(struct vmw_region *region)
+{
+   struct drm_vmw_unref_dmabuf_arg arg;
+
+   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
+              region->ptr.gmrId, region->ptr.offset);
+
+   if (region->data) {
+      munmap(region->data, region->size);
+      region->data = NULL;
+   }
+
+   memset(&arg, 0, sizeof(arg));
+   arg.handle = region->handle;
+   drmCommandWrite(region->drm_fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
+
+   FREE(region);
+}
+
+SVGAGuestPtr
+vmw_ioctl_region_ptr(struct vmw_region *region)
+{
+   return region->ptr;
+}
+
+void *
+vmw_ioctl_region_map(struct vmw_region *region)
+{
+   void *map;
+
+   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
+              region->ptr.gmrId, region->ptr.offset);
+
+   if (region->data == NULL) {
+      map = mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+                region->drm_fd, region->map_handle);
+      if (map == MAP_FAILED) {
+        debug_printf("%s: Map failed.\n", __FUNCTION__);
+        return NULL;
+      }
+
+      region->data = map;
+   }
+
+   ++region->map_count;
+
+   return region->data;
+}
+
+void
+vmw_ioctl_region_unmap(struct vmw_region *region)
+{
+   vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
+              region->ptr.gmrId, region->ptr.offset);
+   --region->map_count;
+}
+
+
+int
+vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
+                          uint32_t fence)
+{
+   uint32_t expected;
+   uint32_t current;
+   
+   assert(fence);
+   if(!fence)
+      return 0;
+   
+   expected = fence;
+   current = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
+   
+   if ((int32)(current - expected) >= 0)
+      return 0; /* fence passed */
+   else
+      return -1;
+}
+
+
+static void
+vmw_ioctl_sync(struct vmw_winsys_screen *vws, 
+                   uint32_t fence)
+{
+   uint32_t cur_fence;
+   struct drm_vmw_fence_wait_arg arg;
+   int ret;
+
+   vmw_printf("%s: fence = %lu\n", __FUNCTION__,
+              (unsigned long)fence);
+
+   cur_fence = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
+   vmw_printf("%s: Fence id read is 0x%08x\n", __FUNCTION__,
+              (unsigned int)cur_fence);
+
+   if ((cur_fence - fence) < (1 << 24))
+      return;
+
+   memset(&arg, 0, sizeof(arg));
+   arg.sequence = fence;
+
+   do {
+       ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_FENCE_WAIT, &arg,
+                                sizeof(arg));
+   } while (ret == -ERESTART);
+}
+
+
+int
+vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
+                       uint32_t fence)
+{
+   assert(fence);
+   
+   if(fence) {
+      if(vmw_ioctl_fence_signalled(vws, fence) != 0) {
+         vmw_ioctl_sync(vws, fence);
+      }
+   }
+   
+   return 0;
+}
+
+
+boolean
+vmw_ioctl_init(struct vmw_winsys_screen *vws)
+{
+   struct drm_vmw_getparam_arg gp_arg;
+   int ret;
+
+   VMW_FUNC;
+
+   memset(&gp_arg, 0, sizeof(gp_arg));
+   gp_arg.param = DRM_VMW_PARAM_3D;
+   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
+                            &gp_arg, sizeof(gp_arg));
+   if (ret || gp_arg.value == 0) {
+      debug_printf("No 3D enabled (%i, %s)\n", ret, strerror(-ret));
+      goto out_err1;
+   }
+
+   memset(&gp_arg, 0, sizeof(gp_arg));
+   gp_arg.param = DRM_VMW_PARAM_FIFO_OFFSET;
+   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
+                            &gp_arg, sizeof(gp_arg));
+
+   if (ret) {
+      debug_printf("GET_PARAM on %d returned %d: %s\n",
+                  vws->ioctl.drm_fd, ret, strerror(-ret));
+      goto out_err1;
+   }
+
+   vmw_printf("Offset to map is 0x%08llx\n",
+              (unsigned long long)gp_arg.value);
+
+   vws->ioctl.fifo_map = vmw_ioctl_fifo_map(vws, gp_arg.value);
+   if (vws->ioctl.fifo_map == NULL)
+      goto out_err1;
+
+   vmw_printf("%s OK\n", __FUNCTION__);
+   return TRUE;
+
+ out_err1:
+   debug_printf("%s Failed\n", __FUNCTION__);
+   return FALSE;
+}
+
+
+
+void
+vmw_ioctl_cleanup(struct vmw_winsys_screen *vws)
+{
+   VMW_FUNC;
+
+   vmw_ioctl_fifo_unmap(vws, (void *)vws->ioctl.fifo_map);
+}
diff --git a/src/gallium/winsys/svga/drm/vmw_screen_pools.c b/src/gallium/winsys/svga/drm/vmw_screen_pools.c
new file mode 100644 (file)
index 0000000..b9823d7
--- /dev/null
@@ -0,0 +1,97 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#include "vmw_screen.h"
+
+#include "vmw_buffer.h"
+#include "vmw_fence.h"
+
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_bufmgr.h"
+
+void
+vmw_pools_cleanup(struct vmw_winsys_screen *vws)
+{
+   if(vws->pools.gmr_fenced)
+      vws->pools.gmr_fenced->destroy(vws->pools.gmr_fenced);
+
+   /* gmr_mm pool is already destroyed above */
+
+   if(vws->pools.gmr)
+      vws->pools.gmr->destroy(vws->pools.gmr);
+}
+
+
+boolean
+vmw_pools_init(struct vmw_winsys_screen *vws)
+{
+   vws->pools.gmr = vmw_gmr_bufmgr_create(vws);
+   if(!vws->pools.gmr)
+      goto error;
+
+   vws->pools.gmr_mm = mm_bufmgr_create(vws->pools.gmr,
+                                        VMW_GMR_POOL_SIZE,
+                                        12 /* 4096 alignment */);
+   if(!vws->pools.gmr_mm)
+      goto error;
+
+   /*
+    * GMR buffers are typically shortlived, but it's possible that at a given
+    * instance a buffer is mapped. So to avoid stalling we tell pipebuffer to
+    * forbid creation of buffers beyond half the GMR pool size,
+    *
+    * XXX: It is unclear weather we want to limit the total amount of temporary
+    * malloc memory used to backup unvalidated GMR buffers. On one hand it is
+    * preferrable to fail an allocation than exhausting the guest memory with
+    * temporary data, but on the other hand it is possible that a stupid
+    * application creates large vertex buffers and does not use them for a long
+    * time -- since the svga pipe driver only emits the DMA uploads when a
+    * buffer is used for drawing this would effectively disabling swapping GMR
+    * buffers to memory. So far, the preemptively flush already seems to keep
+    * total allocated memory within relatively small numbers, so we don't
+    * limit.
+    */
+   vws->pools.gmr_fenced = fenced_bufmgr_create(
+      vws->pools.gmr_mm,
+      vmw_fence_ops_create(vws),
+      VMW_GMR_POOL_SIZE/2,
+      ~0);
+
+#ifdef DEBUG
+   vws->pools.gmr_fenced = pb_debug_manager_create(vws->pools.gmr_fenced,
+                                                  4096,
+                                                  4096);
+#endif
+   if(!vws->pools.gmr_fenced)
+      goto error;
+
+   return TRUE;
+
+error:
+   vmw_pools_cleanup(vws);
+   return FALSE;
+}
+
diff --git a/src/gallium/winsys/svga/drm/vmw_screen_svga.c b/src/gallium/winsys/svga/drm/vmw_screen_svga.c
new file mode 100644 (file)
index 0000000..2b4e80f
--- /dev/null
@@ -0,0 +1,295 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * This file implements the SVGA interface into this winsys, defined
+ * in drivers/svga/svga_winsys.h.
+ *
+ * @author Keith Whitwell
+ * @author Jose Fonseca
+ */
+
+
+#include "svga_cmd.h"
+#include "svga3d_caps.h"
+
+#include "util/u_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "pipebuffer/pb_buffer.h"
+#include "pipebuffer/pb_bufmgr.h"
+#include "svga_winsys.h"
+#include "vmw_context.h"
+#include "vmw_screen.h"
+#include "vmw_surface.h"
+#include "vmw_buffer.h"
+#include "vmw_fence.h"
+
+
+static struct svga_winsys_buffer *
+vmw_svga_winsys_buffer_create(struct svga_winsys_screen *sws,
+                              unsigned alignment,
+                              unsigned usage,
+                              unsigned size)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   struct pb_desc desc;
+   struct pb_manager *provider;
+   struct pb_buffer *buffer;
+
+   memset(&desc, 0, sizeof desc);
+   desc.alignment = alignment;
+   desc.usage = usage;
+
+   provider = vws->pools.gmr_fenced;
+
+   assert(provider);
+   buffer = provider->create_buffer(provider, size, &desc);
+   if(!buffer)
+      return NULL;
+
+   return vmw_svga_winsys_buffer(buffer);
+}
+
+
+static void *
+vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,
+                           struct svga_winsys_buffer *buf,
+                           unsigned flags)
+{
+   (void)sws;
+   return pb_map(vmw_pb_buffer(buf), flags);
+}
+
+
+static void
+vmw_svga_winsys_buffer_unmap(struct svga_winsys_screen *sws,
+                             struct svga_winsys_buffer *buf)
+{
+   (void)sws;
+   pb_unmap(vmw_pb_buffer(buf));
+}
+
+
+static void
+vmw_svga_winsys_buffer_destroy(struct svga_winsys_screen *sws,
+                               struct svga_winsys_buffer *buf)
+{
+   struct pb_buffer *pbuf = vmw_pb_buffer(buf);
+   (void)sws;
+   pb_reference(&pbuf, NULL);
+}
+
+
+static void
+vmw_svga_winsys_fence_reference(struct svga_winsys_screen *sws,
+                                struct pipe_fence_handle **pdst,
+                                struct pipe_fence_handle *src)
+{
+   (void)sws;
+   *pdst = src;
+}
+
+
+static int
+vmw_svga_winsys_fence_signalled(struct svga_winsys_screen *sws,
+                                struct pipe_fence_handle *fence,
+                                unsigned flag)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   (void)flag;
+   return vmw_ioctl_fence_signalled(vws, vmw_fence(fence));
+}
+
+
+static int
+vmw_svga_winsys_fence_finish(struct svga_winsys_screen *sws,
+                             struct pipe_fence_handle *fence,
+                             unsigned flag)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   (void)flag;
+   return vmw_ioctl_fence_finish(vws, vmw_fence(fence));
+}
+
+
+
+static struct svga_winsys_surface *
+vmw_svga_winsys_surface_create(struct svga_winsys_screen *sws,
+                               SVGA3dSurfaceFlags flags,
+                               SVGA3dSurfaceFormat format,
+                               SVGA3dSize size,
+                               uint32 numFaces,
+                               uint32 numMipLevels)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   struct vmw_svga_winsys_surface *surface;
+
+   surface = CALLOC_STRUCT(vmw_svga_winsys_surface);
+   if(!surface)
+      goto no_surface;
+
+   pipe_reference_init(&surface->refcnt, 1);
+   p_atomic_set(&surface->validated, 0);
+   surface->screen = vws;
+   surface->sid = vmw_ioctl_surface_create(vws,
+                                           flags, format, size,
+                                           numFaces, numMipLevels);
+   if(surface->sid == SVGA3D_INVALID_ID)
+      goto no_sid;
+
+   return svga_winsys_surface(surface);
+
+no_sid:
+   FREE(surface);
+no_surface:
+   return NULL;
+}
+
+
+static boolean
+vmw_svga_winsys_surface_is_flushed(struct svga_winsys_screen *sws,
+                                   struct svga_winsys_surface *surface)
+{
+   struct vmw_svga_winsys_surface *vsurf = vmw_svga_winsys_surface(surface);
+   return (p_atomic_read(&vsurf->validated) == 0);
+}
+
+
+static void
+vmw_svga_winsys_surface_ref(struct svga_winsys_screen *sws,
+                           struct svga_winsys_surface **pDst,
+                           struct svga_winsys_surface *src)
+{
+   struct vmw_svga_winsys_surface *d_vsurf = vmw_svga_winsys_surface(*pDst);
+   struct vmw_svga_winsys_surface *s_vsurf = vmw_svga_winsys_surface(src);
+
+   vmw_svga_winsys_surface_reference(&d_vsurf, s_vsurf);
+   *pDst = svga_winsys_surface(d_vsurf);
+}
+
+
+static void
+vmw_svga_winsys_destroy(struct svga_winsys_screen *sws)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+
+   vmw_winsys_destroy(vws);
+}
+
+
+static boolean
+vmw_svga_winsys_get_cap(struct svga_winsys_screen *sws,
+                        SVGA3dDevCapIndex index,
+                        SVGA3dDevCapResult *result)
+{
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
+   const uint32 *capsBlock;
+   const SVGA3dCapsRecord *capsRecord = NULL;
+   uint32 offset;
+   const SVGA3dCapPair *capArray;
+   int numCaps, first, last;
+
+   if(!vws->ioctl.fifo_map)
+      return FALSE;
+
+   if(vws->ioctl.fifo_map[SVGA_FIFO_3D_HWVERSION] < SVGA3D_HWVERSION_WS6_B1)
+      return FALSE;
+
+   /*
+    * Search linearly through the caps block records for the specified type.
+    */
+   capsBlock = (const uint32 *)&vws->ioctl.fifo_map[SVGA_FIFO_3D_CAPS];
+   for (offset = 0; capsBlock[offset] != 0; offset += capsBlock[offset]) {
+      const SVGA3dCapsRecord *record;
+      assert(offset < SVGA_FIFO_3D_CAPS_SIZE);
+      record = (const SVGA3dCapsRecord *) (capsBlock + offset);
+      if ((record->header.type >= SVGA3DCAPS_RECORD_DEVCAPS_MIN) &&
+          (record->header.type <= SVGA3DCAPS_RECORD_DEVCAPS_MAX) &&
+          (!capsRecord || (record->header.type > capsRecord->header.type))) {
+         capsRecord = record;
+      }
+   }
+
+   if(!capsRecord)
+      return FALSE;
+
+   /*
+    * Calculate the number of caps from the size of the record.
+    */
+   capArray = (const SVGA3dCapPair *) capsRecord->data;
+   numCaps = (int) ((capsRecord->header.length * sizeof(uint32) -
+                     sizeof capsRecord->header) / (2 * sizeof(uint32)));
+
+   /*
+    * Binary-search for the cap with the specified index.
+    */
+   for (first = 0, last = numCaps - 1; first <= last; ) {
+      int mid = (first + last) / 2;
+
+      if ((SVGA3dDevCapIndex) capArray[mid][0] == index) {
+         /*
+          * Found it.
+          */
+         result->u = capArray[mid][1];
+         return TRUE;
+      }
+
+      /*
+       * Divide and conquer.
+       */
+      if ((SVGA3dDevCapIndex) capArray[mid][0] > index) {
+         last = mid - 1;
+      } else {
+         first = mid + 1;
+      }
+   }
+
+   return FALSE;
+}
+
+
+boolean
+vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws)
+{
+   vws->base.destroy = vmw_svga_winsys_destroy;
+   vws->base.get_cap = vmw_svga_winsys_get_cap;
+   vws->base.context_create = vmw_svga_winsys_context_create;
+   vws->base.surface_create = vmw_svga_winsys_surface_create;
+   vws->base.surface_is_flushed = vmw_svga_winsys_surface_is_flushed;
+   vws->base.surface_reference = vmw_svga_winsys_surface_ref;
+   vws->base.buffer_create = vmw_svga_winsys_buffer_create;
+   vws->base.buffer_map = vmw_svga_winsys_buffer_map;
+   vws->base.buffer_unmap = vmw_svga_winsys_buffer_unmap;
+   vws->base.buffer_destroy = vmw_svga_winsys_buffer_destroy;
+   vws->base.fence_reference = vmw_svga_winsys_fence_reference;
+   vws->base.fence_signalled = vmw_svga_winsys_fence_signalled;
+   vws->base.fence_finish = vmw_svga_winsys_fence_finish;
+
+   return TRUE;
+}
+
+
diff --git a/src/gallium/winsys/svga/drm/vmw_surface.c b/src/gallium/winsys/svga/drm/vmw_surface.c
new file mode 100644 (file)
index 0000000..5f1b9ad
--- /dev/null
@@ -0,0 +1,61 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#include "svga_cmd.h"
+#include "util/u_debug.h"
+#include "util/u_memory.h"
+
+#include "vmw_surface.h"
+#include "vmw_screen.h"
+
+void
+vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
+                                  struct vmw_svga_winsys_surface *src)
+{
+   struct pipe_reference *src_ref;
+   struct pipe_reference *dst_ref;
+   struct vmw_svga_winsys_surface *dst;
+
+   if(pdst == NULL || *pdst == src)
+      return;
+
+   dst = *pdst;
+
+   src_ref = src ? &src->refcnt : NULL;
+   dst_ref = dst ? &dst->refcnt : NULL;
+
+   if (pipe_reference(dst_ref, src_ref)) {
+      vmw_ioctl_surface_destroy(dst->screen, dst->sid);
+#ifdef DEBUG
+      /* to detect dangling pointers */
+      assert(p_atomic_read(&dst->validated) == 0);
+      dst->sid = SVGA3D_INVALID_ID;
+#endif
+      FREE(dst);
+   }
+
+   *pdst = src;
+}
diff --git a/src/gallium/winsys/svga/drm/vmw_surface.h b/src/gallium/winsys/svga/drm/vmw_surface.h
new file mode 100644 (file)
index 0000000..3d61595
--- /dev/null
@@ -0,0 +1,79 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Surfaces for VMware SVGA winsys.
+ * 
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#ifndef VMW_SURFACE_H_
+#define VMW_SURFACE_H_
+
+
+#include "pipe/p_compiler.h"
+#include "util/u_atomic.h"
+#include "util/u_inlines.h"
+
+#define VMW_MAX_PRESENTS 3
+
+
+
+struct vmw_svga_winsys_surface
+{
+   int32_t validated; /* atomic */
+   struct pipe_reference refcnt;
+
+   struct vmw_winsys_screen *screen;
+   uint32_t sid;
+
+   /* FIXME: make this thread safe */
+   unsigned next_present_no;
+   uint32_t present_fences[VMW_MAX_PRESENTS];
+};
+
+
+static INLINE struct svga_winsys_surface *
+svga_winsys_surface(struct vmw_svga_winsys_surface *surf)
+{
+   assert(!surf || surf->sid != SVGA3D_INVALID_ID);
+   return (struct svga_winsys_surface *)surf;
+}
+
+
+static INLINE struct vmw_svga_winsys_surface *
+vmw_svga_winsys_surface(struct svga_winsys_surface *surf)
+{
+   return (struct vmw_svga_winsys_surface *)surf;
+}
+
+
+void
+vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
+                                  struct vmw_svga_winsys_surface *src);
+
+#endif /* VMW_SURFACE_H_ */
diff --git a/src/gallium/winsys/svga/drm/vmwgfx_drm.h b/src/gallium/winsys/svga/drm/vmwgfx_drm.h
new file mode 100644 (file)
index 0000000..47914bd
--- /dev/null
@@ -0,0 +1,545 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef __VMWGFX_DRM_H__
+#define __VMWGFX_DRM_H__
+
+#define DRM_VMW_MAX_SURFACE_FACES 6
+#define DRM_VMW_MAX_MIP_LEVELS 24
+
+#define DRM_VMW_EXT_NAME_LEN 128
+
+#define DRM_VMW_GET_PARAM            0
+#define DRM_VMW_ALLOC_DMABUF         1
+#define DRM_VMW_UNREF_DMABUF         2
+#define DRM_VMW_CURSOR_BYPASS        3
+/* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
+#define DRM_VMW_CONTROL_STREAM       4
+#define DRM_VMW_CLAIM_STREAM         5
+#define DRM_VMW_UNREF_STREAM         6
+/* guarded by DRM_VMW_PARAM_3D == 1 */
+#define DRM_VMW_CREATE_CONTEXT       7
+#define DRM_VMW_UNREF_CONTEXT        8
+#define DRM_VMW_CREATE_SURFACE       9
+#define DRM_VMW_UNREF_SURFACE        10
+#define DRM_VMW_REF_SURFACE          11
+#define DRM_VMW_EXECBUF              12
+#define DRM_VMW_FIFO_DEBUG           13
+#define DRM_VMW_FENCE_WAIT           14
+
+
+/*************************************************************************/
+/**
+ * DRM_VMW_GET_PARAM - get device information.
+ *
+ * DRM_VMW_PARAM_FIFO_OFFSET:
+ * Offset to use to map the first page of the FIFO read-only.
+ * The fifo is mapped using the mmap() system call on the drm device.
+ *
+ * DRM_VMW_PARAM_OVERLAY_IOCTL:
+ * Does the driver support the overlay ioctl.
+ */
+
+#define DRM_VMW_PARAM_NUM_STREAMS      0
+#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
+#define DRM_VMW_PARAM_3D               2
+#define DRM_VMW_PARAM_FIFO_OFFSET      3
+#define DRM_VMW_PARAM_HW_CAPS          4
+#define DRM_VMW_PARAM_FIFO_CAPS        5
+
+/**
+ * struct drm_vmw_getparam_arg
+ *
+ * @value: Returned value. //Out
+ * @param: Parameter to query. //In.
+ *
+ * Argument to the DRM_VMW_GET_PARAM Ioctl.
+ */
+
+struct drm_vmw_getparam_arg {
+       uint64_t value;
+       uint32_t param;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CREATE_CONTEXT - Create a host context.
+ *
+ * Allocates a device unique context id, and queues a create context command
+ * for the host. Does not wait for host completion.
+ */
+
+/**
+ * struct drm_vmw_context_arg
+ *
+ * @cid: Device unique context ID.
+ *
+ * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
+ * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
+ */
+
+struct drm_vmw_context_arg {
+       int32_t cid;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_CONTEXT - Create a host context.
+ *
+ * Frees a global context id, and queues a destroy host command for the host.
+ * Does not wait for host completion. The context ID can be used directly
+ * in the command stream and shows up as the same context ID on the host.
+ */
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CREATE_SURFACE - Create a host suface.
+ *
+ * Allocates a device unique surface id, and queues a create surface command
+ * for the host. Does not wait for host completion. The surface ID can be
+ * used directly in the command stream and shows up as the same surface
+ * ID on the host.
+ */
+
+/**
+ * struct drm_wmv_surface_create_req
+ *
+ * @flags: Surface flags as understood by the host.
+ * @format: Surface format as understood by the host.
+ * @mip_levels: Number of mip levels for each face.
+ * An unused face should have 0 encoded.
+ * @size_addr: Address of a user-space array of sruct drm_vmw_size
+ * cast to an uint64_t for 32-64 bit compatibility.
+ * The size of the array should equal the total number of mipmap levels.
+ * @shareable: Boolean whether other clients (as identified by file descriptors)
+ * may reference this surface.
+ * @scanout: Boolean whether the surface is intended to be used as a
+ * scanout.
+ *
+ * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
+ * Output data from the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+struct drm_vmw_surface_create_req {
+       uint32_t flags;
+       uint32_t format;
+       uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
+       uint64_t size_addr;
+       int32_t shareable;
+       int32_t scanout;
+};
+
+/**
+ * struct drm_wmv_surface_arg
+ *
+ * @sid: Surface id of created surface or surface to destroy or reference.
+ *
+ * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
+ * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
+ * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+struct drm_vmw_surface_arg {
+       int32_t sid;
+       uint32_t pad64;
+};
+
+/**
+ * struct drm_vmw_size ioctl.
+ *
+ * @width - mip level width
+ * @height - mip level height
+ * @depth - mip level depth
+ *
+ * Description of a mip level.
+ * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
+ */
+
+struct drm_vmw_size {
+       uint32_t width;
+       uint32_t height;
+       uint32_t depth;
+       uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_surface_create_arg
+ *
+ * @rep: Output data as described above.
+ * @req: Input data as described above.
+ *
+ * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
+ */
+
+union drm_vmw_surface_create_arg {
+       struct drm_vmw_surface_arg rep;
+       struct drm_vmw_surface_create_req req;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_REF_SURFACE - Reference a host surface.
+ *
+ * Puts a reference on a host surface with a give sid, as previously
+ * returned by the DRM_VMW_CREATE_SURFACE ioctl.
+ * A reference will make sure the surface isn't destroyed while we hold
+ * it and will allow the calling client to use the surface ID in the command
+ * stream.
+ *
+ * On successful return, the Ioctl returns the surface information given
+ * in the DRM_VMW_CREATE_SURFACE ioctl.
+ */
+
+/**
+ * union drm_vmw_surface_reference_arg
+ *
+ * @rep: Output data as described above.
+ * @req: Input data as described above.
+ *
+ * Argument to the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+union drm_vmw_surface_reference_arg {
+       struct drm_vmw_surface_create_req rep;
+       struct drm_vmw_surface_arg req;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
+ *
+ * Clear a reference previously put on a host surface.
+ * When all references are gone, including the one implicitly placed
+ * on creation,
+ * a destroy surface command will be queued for the host.
+ * Does not wait for completion.
+ */
+
+/*************************************************************************/
+/**
+ * DRM_VMW_EXECBUF
+ *
+ * Submit a command buffer for execution on the host, and return a
+ * fence sequence that when signaled, indicates that the command buffer has
+ * executed.
+ */
+
+/**
+ * struct drm_vmw_execbuf_arg
+ *
+ * @commands: User-space address of a command buffer cast to an uint64_t.
+ * @command-size: Size in bytes of the command buffer.
+ * @throttle-us: Sleep until software is less than @throttle_us
+ * microseconds ahead of hardware. The driver may round this value
+ * to the nearest kernel tick.
+ * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
+ * uint64_t.
+ * @version: Allows expanding the execbuf ioctl parameters without breaking
+ * backwards compatibility, since user-space will always tell the kernel
+ * which version it uses.
+ * @flags: Execbuf flags. None currently.
+ *
+ * Argument to the DRM_VMW_EXECBUF Ioctl.
+ */
+
+#define DRM_VMW_EXECBUF_VERSION 0
+
+struct drm_vmw_execbuf_arg {
+       uint64_t commands;
+       uint32_t command_size;
+       uint32_t throttle_us;
+       uint64_t fence_rep;
+        uint32_t version;
+        uint32_t flags;
+};
+
+/**
+ * struct drm_vmw_fence_rep
+ *
+ * @fence_seq: Fence sequence associated with a command submission.
+ * @error: This member should've been set to -EFAULT on submission.
+ * The following actions should be take on completion:
+ * error == -EFAULT: Fence communication failed. The host is synchronized.
+ * Use the last fence id read from the FIFO fence register.
+ * error != 0 && error != -EFAULT:
+ * Fence submission failed. The host is synchronized. Use the fence_seq member.
+ * error == 0: All is OK, The host may not be synchronized.
+ * Use the fence_seq member.
+ *
+ * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
+ */
+
+struct drm_vmw_fence_rep {
+       uint64_t fence_seq;
+       int32_t error;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_ALLOC_DMABUF
+ *
+ * Allocate a DMA buffer that is visible also to the host.
+ * NOTE: The buffer is
+ * identified by a handle and an offset, which are private to the guest, but
+ * useable in the command stream. The guest kernel may translate these
+ * and patch up the command stream accordingly. In the future, the offset may
+ * be zero at all times, or it may disappear from the interface before it is
+ * fixed.
+ *
+ * The DMA buffer may stay user-space mapped in the guest at all times,
+ * and is thus suitable for sub-allocation.
+ *
+ * DMA buffers are mapped using the mmap() syscall on the drm device.
+ */
+
+/**
+ * struct drm_vmw_alloc_dmabuf_req
+ *
+ * @size: Required minimum size of the buffer.
+ *
+ * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+struct drm_vmw_alloc_dmabuf_req {
+       uint32_t size;
+       uint32_t pad64;
+};
+
+/**
+ * struct drm_vmw_dmabuf_rep
+ *
+ * @map_handle: Offset to use in the mmap() call used to map the buffer.
+ * @handle: Handle unique to this buffer. Used for unreferencing.
+ * @cur_gmr_id: GMR id to use in the command stream when this buffer is
+ * referenced. See not above.
+ * @cur_gmr_offset: Offset to use in the command stream when this buffer is
+ * referenced. See note above.
+ *
+ * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+struct drm_vmw_dmabuf_rep {
+       uint64_t map_handle;
+       uint32_t handle;
+       uint32_t cur_gmr_id;
+       uint32_t cur_gmr_offset;
+       uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_dmabuf_arg
+ *
+ * @req: Input data as described above.
+ * @rep: Output data as described above.
+ *
+ * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+union drm_vmw_alloc_dmabuf_arg {
+       struct drm_vmw_alloc_dmabuf_req req;
+       struct drm_vmw_dmabuf_rep rep;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
+ *
+ */
+
+/**
+ * struct drm_vmw_unref_dmabuf_arg
+ *
+ * @handle: Handle indicating what buffer to free. Obtained from the
+ * DRM_VMW_ALLOC_DMABUF Ioctl.
+ *
+ * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
+ */
+
+struct drm_vmw_unref_dmabuf_arg {
+       uint32_t handle;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
+ *
+ * This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
+ */
+
+/**
+ * struct drm_vmw_fifo_debug_arg
+ *
+ * @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
+ * @debug_buffer_size: Size in bytes of debug buffer //In
+ * @used_size: Number of bytes copied to the buffer // Out
+ * @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
+ *
+ * Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
+ */
+
+struct drm_vmw_fifo_debug_arg {
+       uint64_t debug_buffer;
+       uint32_t debug_buffer_size;
+       uint32_t used_size;
+       int32_t did_not_fit;
+       uint32_t pad64;
+};
+
+struct drm_vmw_fence_wait_arg {
+       uint64_t sequence;
+       uint64_t kernel_cookie;
+       int32_t cookie_valid;
+       int32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
+ *
+ * This IOCTL controls the overlay units of the svga device.
+ * The SVGA overlay units does not work like regular hardware units in
+ * that they do not automaticaly read back the contents of the given dma
+ * buffer. But instead only read back for each call to this ioctl, and
+ * at any point between this call being made and a following call that
+ * either changes the buffer or disables the stream.
+ */
+
+/**
+ * struct drm_vmw_rect
+ *
+ * Defines a rectangle. Used in the overlay ioctl to define
+ * source and destination rectangle.
+ */
+
+struct drm_vmw_rect {
+       int32_t x;
+       int32_t y;
+       uint32_t w;
+       uint32_t h;
+};
+
+/**
+ * struct drm_vmw_control_stream_arg
+ *
+ * @stream_id: Stearm to control
+ * @enabled: If false all following arguments are ignored.
+ * @handle: Handle to buffer for getting data from.
+ * @format: Format of the overlay as understood by the host.
+ * @width: Width of the overlay.
+ * @height: Height of the overlay.
+ * @size: Size of the overlay in bytes.
+ * @pitch: Array of pitches, the two last are only used for YUV12 formats.
+ * @offset: Offset from start of dma buffer to overlay.
+ * @src: Source rect, must be within the defined area above.
+ * @dst: Destination rect, x and y may be negative.
+ *
+ * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
+ */
+
+struct drm_vmw_control_stream_arg {
+       uint32_t stream_id;
+       uint32_t enabled;
+
+       uint32_t flags;
+       uint32_t color_key;
+
+       uint32_t handle;
+       uint32_t offset;
+       int32_t format;
+       uint32_t size;
+       uint32_t width;
+       uint32_t height;
+       uint32_t pitch[3];
+
+       uint32_t pad64;
+       struct drm_vmw_rect src;
+       struct drm_vmw_rect dst;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
+ *
+ */
+
+#define DRM_VMW_CURSOR_BYPASS_ALL    (1 << 0)
+#define DRM_VMW_CURSOR_BYPASS_FLAGS       (1)
+
+/**
+ * struct drm_vmw_cursor_bypass_arg
+ *
+ * @flags: Flags.
+ * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
+ * @xpos: X position of cursor.
+ * @ypos: Y position of cursor.
+ * @xhot: X hotspot.
+ * @yhot: Y hotspot.
+ *
+ * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
+ */
+
+struct drm_vmw_cursor_bypass_arg {
+       uint32_t flags;
+       uint32_t crtc_id;
+       int32_t xpos;
+       int32_t ypos;
+       int32_t xhot;
+       int32_t yhot;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CLAIM_STREAM - Claim a single stream.
+ */
+
+/**
+ * struct drm_vmw_context_arg
+ *
+ * @stream_id: Device unique context ID.
+ *
+ * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
+ * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
+ */
+
+struct drm_vmw_stream_arg {
+       uint32_t stream_id;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_STREAM - Unclaim a stream.
+ *
+ * Return a single stream that was claimed by this process. Also makes
+ * sure that the stream has been stopped.
+ */
+
+#endif
diff --git a/src/gallium/winsys/sw/Makefile b/src/gallium/winsys/sw/Makefile
new file mode 100644 (file)
index 0000000..e9182ea
--- /dev/null
@@ -0,0 +1,12 @@
+# src/gallium/winsys/sw/Makefile
+TOP = ../../../..
+include $(TOP)/configs/current
+
+SUBDIRS = null wrapper
+
+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/sw/dri/Makefile b/src/gallium/winsys/sw/dri/Makefile
new file mode 100644 (file)
index 0000000..a3fca6b
--- /dev/null
@@ -0,0 +1,13 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = swdri
+
+LIBRARY_INCLUDES =
+
+LIBRARY_DEFINES =
+
+C_SOURCES = \
+       dri_sw_winsys.c
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/sw/dri/SConscript b/src/gallium/winsys/sw/dri/SConscript
new file mode 100644 (file)
index 0000000..b255d72
--- /dev/null
@@ -0,0 +1,23 @@
+#######################################################################
+# SConscript for xlib winsys
+
+
+Import('*')
+
+if env['platform'] == 'linux':
+
+    env = env.Clone()
+
+    env.Append(CPPPATH = [
+        '#/src/gallium/include',
+        '#/src/gallium/auxiliary',
+        '#/src/gallium/drivers',
+    ])
+
+    ws_dri = env.ConvenienceLibrary(
+        target = 'ws_dri',
+        source = [
+           'dri_sw_winsys.c',
+        ]
+    )
+    Export('ws_dri')
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
new file mode 100644 (file)
index 0000000..870c6af
--- /dev/null
@@ -0,0 +1,225 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+#include "util/u_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "state_tracker/sw_winsys.h"
+#include "dri_sw_winsys.h"
+
+
+struct dri_sw_displaytarget
+{
+   enum pipe_format format;
+   unsigned width;
+   unsigned height;
+   unsigned stride;
+
+   void *data;
+   void *mapped;
+};
+
+struct dri_sw_winsys
+{
+   struct sw_winsys base;
+
+   struct drisw_loader_funcs *lf;
+};
+
+static INLINE struct dri_sw_displaytarget *
+dri_sw_displaytarget( struct sw_displaytarget *dt )
+{
+   return (struct dri_sw_displaytarget *)dt;
+}
+
+static INLINE struct dri_sw_winsys *
+dri_sw_winsys( struct sw_winsys *ws )
+{
+   return (struct dri_sw_winsys *)ws;
+}
+
+
+static boolean
+dri_sw_is_displaytarget_format_supported( struct sw_winsys *ws,
+                                          unsigned tex_usage,
+                                          enum pipe_format format )
+{
+   /* TODO: check visuals or other sensible thing here */
+   return TRUE;
+}
+
+static struct sw_displaytarget *
+dri_sw_displaytarget_create(struct sw_winsys *winsys,
+                            unsigned tex_usage,
+                            enum pipe_format format,
+                            unsigned width, unsigned height,
+                            unsigned alignment,
+                            unsigned *stride)
+{
+   struct dri_sw_displaytarget *dri_sw_dt;
+   unsigned nblocksy, size, format_stride;
+
+   dri_sw_dt = CALLOC_STRUCT(dri_sw_displaytarget);
+   if(!dri_sw_dt)
+      goto no_dt;
+
+   dri_sw_dt->format = format;
+   dri_sw_dt->width = width;
+   dri_sw_dt->height = height;
+
+   format_stride = util_format_get_stride(format, width);
+   dri_sw_dt->stride = align(format_stride, alignment);
+
+   nblocksy = util_format_get_nblocksy(format, height);
+   size = dri_sw_dt->stride * nblocksy;
+
+   dri_sw_dt->data = align_malloc(size, alignment);
+   if(!dri_sw_dt->data)
+      goto no_data;
+
+   *stride = dri_sw_dt->stride;
+   return (struct sw_displaytarget *)dri_sw_dt;
+
+no_data:
+   FREE(dri_sw_dt);
+no_dt:
+   return NULL;
+}
+
+static void
+dri_sw_displaytarget_destroy(struct sw_winsys *ws,
+                             struct sw_displaytarget *dt)
+{
+   struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
+
+   if (dri_sw_dt->data) {
+      FREE(dri_sw_dt->data);
+   }
+
+   FREE(dri_sw_dt);
+}
+
+static void *
+dri_sw_displaytarget_map(struct sw_winsys *ws,
+                         struct sw_displaytarget *dt,
+                         unsigned flags)
+{
+   struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
+   dri_sw_dt->mapped = dri_sw_dt->data;
+   return dri_sw_dt->mapped;
+}
+
+static void
+dri_sw_displaytarget_unmap(struct sw_winsys *ws,
+                           struct sw_displaytarget *dt)
+{
+   struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
+   dri_sw_dt->mapped = NULL;
+}
+
+static struct sw_displaytarget *
+dri_sw_displaytarget_from_handle(struct sw_winsys *winsys,
+                                 const struct pipe_texture *templ,
+                                 struct winsys_handle *whandle,
+                                 unsigned *stride)
+{
+   assert(0);
+   return NULL;
+}
+
+static boolean
+dri_sw_displaytarget_get_handle(struct sw_winsys *winsys,
+                                struct sw_displaytarget *dt,
+                                struct winsys_handle *whandle)
+{
+   assert(0);
+   return FALSE;
+}
+
+static void
+dri_sw_displaytarget_display(struct sw_winsys *ws,
+                             struct sw_displaytarget *dt,
+                             void *context_private)
+{
+   struct dri_sw_winsys *dri_sw_ws = dri_sw_winsys(ws);
+   struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
+   struct dri_drawable *dri_drawable = (struct dri_drawable *)context_private;
+   unsigned width, height;
+
+   /* Set the width to 'stride / cpp'.
+    *
+    * PutImage correctly clips to the width of the dst drawable.
+    */
+   width = dri_sw_dt->stride / util_format_get_blocksize(dri_sw_dt->format);
+
+   height = dri_sw_dt->height;
+
+   dri_sw_ws->lf->put_image(dri_drawable, dri_sw_dt->data, width, height);
+}
+
+
+static void
+dri_destroy_sw_winsys(struct sw_winsys *winsys)
+{
+   FREE(winsys);
+}
+
+struct sw_winsys *
+dri_create_sw_winsys(struct drisw_loader_funcs *lf)
+{
+   struct dri_sw_winsys *ws;
+
+   ws = CALLOC_STRUCT(dri_sw_winsys);
+   if (!ws)
+      return NULL;
+
+   ws->lf = lf;
+   ws->base.destroy = dri_destroy_sw_winsys;
+
+   ws->base.is_displaytarget_format_supported = dri_sw_is_displaytarget_format_supported;
+
+   /* screen texture functions */
+   ws->base.displaytarget_create = dri_sw_displaytarget_create;
+   ws->base.displaytarget_destroy = dri_sw_displaytarget_destroy;
+   ws->base.displaytarget_from_handle = dri_sw_displaytarget_from_handle;
+   ws->base.displaytarget_get_handle = dri_sw_displaytarget_get_handle;
+
+   /* texture functions */
+   ws->base.displaytarget_map = dri_sw_displaytarget_map;
+   ws->base.displaytarget_unmap = dri_sw_displaytarget_unmap;
+
+   ws->base.displaytarget_display = dri_sw_displaytarget_display;
+
+   return &ws->base;
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.h b/src/gallium/winsys/sw/dri/dri_sw_winsys.h
new file mode 100644 (file)
index 0000000..329ac06
--- /dev/null
@@ -0,0 +1,38 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef DRI_SW_WINSYS
+#define DRI_SW_WINSYS
+
+#include "state_tracker/drisw_api.h"
+
+struct sw_winsys;
+
+struct sw_winsys *dri_create_sw_winsys(struct drisw_loader_funcs *lf);
+
+#endif
diff --git a/src/gallium/winsys/sw/drm/Makefile b/src/gallium/winsys/sw/drm/Makefile
new file mode 100644 (file)
index 0000000..7966453
--- /dev/null
@@ -0,0 +1,12 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = swdrm
+
+C_SOURCES = sw_drm_api.c
+
+LIBRARY_INCLUDES =
+
+LIBRARY_DEFINES =
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/sw/drm/sw_drm_api.c b/src/gallium/winsys/sw/drm/sw_drm_api.c
new file mode 100644 (file)
index 0000000..eb81d26
--- /dev/null
@@ -0,0 +1,97 @@
+/**********************************************************
+ * Copyright 2010 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+
+#include "util/u_memory.h"
+#include "softpipe/sp_public.h"
+#include "state_tracker/drm_api.h"
+#include "../../sw/wrapper/wrapper_sw_winsys.h"
+#include "sw_drm_api.h"
+
+
+/*
+ * Defines
+ */
+
+
+struct sw_drm_api
+{
+   struct drm_api base;
+   struct drm_api *api;
+   struct sw_winsys *sw;
+};
+
+static INLINE struct sw_drm_api *
+sw_drm_api(struct drm_api *api)
+{
+   return (struct sw_drm_api *)api;
+}
+
+
+/*
+ * Exported functions
+ */
+
+
+static struct pipe_screen *
+sw_drm_create_screen(struct drm_api *_api, int drmFD,
+                     struct drm_create_screen_arg *arg)
+{
+   struct sw_drm_api *swapi = sw_drm_api(_api);
+   struct drm_api *api = swapi->api;
+   struct sw_winsys *sww;
+   struct pipe_screen *screen;
+
+   screen = api->create_screen(api, drmFD, arg);
+
+   sww = wrapper_sw_winsys_warp_pipe_screen(screen);
+
+   return softpipe_create_screen(sww);
+}
+
+static void
+sw_drm_destroy(struct drm_api *api)
+{
+   struct sw_drm_api *swapi = sw_drm_api(api);
+   if (swapi->api->destroy)
+      swapi->api->destroy(swapi->api);
+
+   FREE(swapi);
+}
+
+struct drm_api *
+sw_drm_api_create(struct drm_api *api)
+{
+   struct sw_drm_api *swapi = CALLOC_STRUCT(sw_drm_api);
+
+   swapi->base.name = "sw";
+   swapi->base.driver_name = api->driver_name;
+   swapi->base.create_screen = sw_drm_create_screen;
+   swapi->base.destroy = sw_drm_destroy;
+
+   swapi->api = api;
+
+   return &swapi->base;
+}
diff --git a/src/gallium/winsys/sw/drm/sw_drm_api.h b/src/gallium/winsys/sw/drm/sw_drm_api.h
new file mode 100644 (file)
index 0000000..ce90a04
--- /dev/null
@@ -0,0 +1,34 @@
+/**********************************************************
+ * Copyright 2010 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * 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 SW_DRM_API_H
+#define SW_DRM_API_H
+
+struct drm_api;
+
+struct drm_api * sw_drm_api_create(struct drm_api *api);
+
+#endif
diff --git a/src/gallium/winsys/sw/gdi/SConscript b/src/gallium/winsys/sw/gdi/SConscript
new file mode 100644 (file)
index 0000000..1267fc6
--- /dev/null
@@ -0,0 +1,23 @@
+#######################################################################
+# SConscript for xlib winsys
+
+
+Import('*')
+
+if env['platform'] == 'windows':
+
+    env = env.Clone()
+
+    env.Append(CPPPATH = [
+        '#/src/gallium/include',
+        '#/src/gallium/auxiliary',
+        '#/src/gallium/drivers',
+    ])
+
+    ws_gdi = env.ConvenienceLibrary(
+        target = 'ws_gdi',
+        source = [
+           'gdi_sw_winsys.c',
+        ]
+    )
+    Export('ws_gdi')
diff --git a/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c b/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c
new file mode 100644 (file)
index 0000000..4dba4b5
--- /dev/null
@@ -0,0 +1,247 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * GDI software rasterizer support.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include <windows.h>
+
+#include "pipe/p_format.h"
+#include "pipe/p_context.h"
+#include "util/u_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "state_tracker/sw_winsys.h"
+#include "gdi_sw_winsys.h"
+
+
+struct gdi_sw_displaytarget
+{
+   enum pipe_format format;
+   unsigned width;
+   unsigned height;
+   unsigned stride;
+
+   unsigned size;
+
+   void *data;
+
+   BITMAPINFO bmi;
+};
+
+
+/** Cast wrapper */
+static INLINE struct gdi_sw_displaytarget *
+gdi_sw_displaytarget( struct sw_displaytarget *buf )
+{
+   return (struct gdi_sw_displaytarget *)buf;
+}
+
+
+static boolean
+gdi_sw_is_displaytarget_format_supported( struct sw_winsys *ws,
+                                                unsigned tex_usage,
+                                                enum pipe_format format )
+{
+   switch(format) {
+   case PIPE_FORMAT_B8G8R8X8_UNORM:
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
+      return TRUE;
+
+   /* TODO: Support other formats possible with BMPs, as described in 
+    * http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx */
+      
+   default:
+      return FALSE;
+   }
+}
+
+
+static void *
+gdi_sw_displaytarget_map(struct sw_winsys *ws,
+                               struct sw_displaytarget *dt,
+                               unsigned flags )
+{
+   struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
+
+   return gdt->data;
+}
+
+
+static void
+gdi_sw_displaytarget_unmap(struct sw_winsys *ws,
+                                 struct sw_displaytarget *dt )
+{
+
+}
+
+
+static void
+gdi_sw_displaytarget_destroy(struct sw_winsys *winsys,
+                                   struct sw_displaytarget *dt)
+{
+   struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
+
+   align_free(gdt->data);
+   FREE(gdt);
+}
+
+
+static struct sw_displaytarget *
+gdi_sw_displaytarget_create(struct sw_winsys *winsys,
+                                  unsigned tex_usage,
+                                  enum pipe_format format,
+                                  unsigned width, unsigned height,
+                                  unsigned alignment,
+                                  unsigned *stride)
+{
+   struct gdi_sw_displaytarget *gdt;
+   unsigned cpp;
+   unsigned bpp;
+   
+   gdt = CALLOC_STRUCT(gdi_sw_displaytarget);
+   if(!gdt)
+      goto no_gdt;
+
+   gdt->format = format;
+   gdt->width = width;
+   gdt->height = height;
+
+   bpp = util_format_get_blocksizebits(format);
+   cpp = util_format_get_blocksize(format);
+   
+   gdt->stride = align(width * cpp, alignment);
+   gdt->size = gdt->stride * height;
+   
+   gdt->data = align_malloc(gdt->size, alignment);
+   if(!gdt->data)
+      goto no_data;
+
+   gdt->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+   gdt->bmi.bmiHeader.biWidth = gdt->stride / cpp;
+   gdt->bmi.bmiHeader.biHeight= -(long)height;
+   gdt->bmi.bmiHeader.biPlanes = 1;
+   gdt->bmi.bmiHeader.biBitCount = bpp;
+   gdt->bmi.bmiHeader.biCompression = BI_RGB;
+   gdt->bmi.bmiHeader.biSizeImage = 0;
+   gdt->bmi.bmiHeader.biXPelsPerMeter = 0;
+   gdt->bmi.bmiHeader.biYPelsPerMeter = 0;
+   gdt->bmi.bmiHeader.biClrUsed = 0;
+   gdt->bmi.bmiHeader.biClrImportant = 0;
+
+   *stride = gdt->stride;
+   return (struct sw_displaytarget *)gdt;
+
+no_data:
+   FREE(gdt);
+no_gdt:
+   return NULL;
+}
+
+
+static struct sw_displaytarget *
+gdi_sw_displaytarget_from_handle(struct sw_winsys *winsys,
+                                 const struct pipe_texture *templet,
+                                 struct winsys_handle *whandle,
+                                 unsigned *stride)
+{
+   assert(0);
+   return NULL;
+}
+
+
+static boolean
+gdi_sw_displaytarget_get_handle(struct sw_winsys *winsys,
+                                struct sw_displaytarget *dt,
+                                struct winsys_handle *whandle)
+{
+   assert(0);
+   return FALSE;
+}
+
+
+void
+gdi_sw_display( struct sw_winsys *winsys,
+                struct sw_displaytarget *dt,
+                HDC hDC )
+{
+    struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
+
+    StretchDIBits(hDC,
+                  0, 0, gdt->width, gdt->height,
+                  0, 0, gdt->width, gdt->height,
+                  gdt->data, &gdt->bmi, 0, SRCCOPY);
+}
+
+static void
+gdi_sw_displaytarget_display(struct sw_winsys *winsys, 
+                             struct sw_displaytarget *dt,
+                             void *context_private)
+{
+    /* nasty:
+     */
+    HDC hDC = (HDC)context_private;
+
+    gdi_sw_display(winsys, dt, hDC);
+}
+
+
+static void
+gdi_sw_destroy(struct sw_winsys *winsys)
+{
+   FREE(winsys);
+}
+
+struct sw_winsys *
+gdi_create_sw_winsys(void)
+{
+   static struct sw_winsys *winsys;
+
+   winsys = CALLOC_STRUCT(sw_winsys);
+   if(!winsys)
+      return NULL;
+
+   winsys->destroy = gdi_sw_destroy;
+   winsys->is_displaytarget_format_supported = gdi_sw_is_displaytarget_format_supported;
+   winsys->displaytarget_create = gdi_sw_displaytarget_create;
+   winsys->displaytarget_from_handle = gdi_sw_displaytarget_from_handle;
+   winsys->displaytarget_get_handle = gdi_sw_displaytarget_get_handle;
+   winsys->displaytarget_map = gdi_sw_displaytarget_map;
+   winsys->displaytarget_unmap = gdi_sw_displaytarget_unmap;
+   winsys->displaytarget_display = gdi_sw_displaytarget_display;
+   winsys->displaytarget_destroy = gdi_sw_displaytarget_destroy;
+
+   return winsys;
+}
+
diff --git a/src/gallium/winsys/sw/gdi/gdi_sw_winsys.h b/src/gallium/winsys/sw/gdi/gdi_sw_winsys.h
new file mode 100644 (file)
index 0000000..4bbcb47
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef GDI_SW_WINSYS_H
+#define GDI_SW_WINSYS_H
+
+#include <windows.h>
+
+#include "pipe/p_compiler.h"
+#include "state_tracker/sw_winsys.h"
+
+void gdi_sw_display( struct sw_winsys *winsys,
+                     struct sw_displaytarget *dt,
+                     HDC hDC );
+
+struct sw_winsys *
+gdi_create_sw_winsys(void);
+
+#endif
diff --git a/src/gallium/winsys/sw/null/Makefile b/src/gallium/winsys/sw/null/Makefile
new file mode 100644 (file)
index 0000000..b1882b5
--- /dev/null
@@ -0,0 +1,16 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = ws_null
+
+LIBRARY_INCLUDES = \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary
+
+C_SOURCES = \
+       null_sw_winsys.c 
+
+include ../../../Makefile.template
+
+
diff --git a/src/gallium/winsys/sw/null/SConscript b/src/gallium/winsys/sw/null/SConscript
new file mode 100644 (file)
index 0000000..21837dc
--- /dev/null
@@ -0,0 +1,21 @@
+#######################################################################
+# SConscript for xlib winsys
+
+
+Import('*')
+
+env = env.Clone()
+
+env.Append(CPPPATH = [
+    '#/src/gallium/include',
+    '#/src/gallium/auxiliary',
+    '#/src/gallium/drivers',
+])
+
+ws_null = env.ConvenienceLibrary(
+    target = 'ws_null',
+    source = [
+       'null_sw_winsys.c',
+    ]
+)
+Export('ws_null')
diff --git a/src/gallium/winsys/sw/null/null_sw_winsys.c b/src/gallium/winsys/sw/null/null_sw_winsys.c
new file mode 100644 (file)
index 0000000..5027e57
--- /dev/null
@@ -0,0 +1,148 @@
+/**************************************************************************
+ * 
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ **************************************************************************/
+
+/**
+ * @file
+ * Null software rasterizer winsys.
+ * 
+ * There is no present support. Framebuffer data needs to be obtained via
+ * transfers.
+ *
+ * @author Jose Fonseca
+ */
+
+
+#include "pipe/p_format.h"
+#include "util/u_memory.h"
+#include "state_tracker/sw_winsys.h"
+#include "null_sw_winsys.h"
+
+
+static boolean
+null_sw_is_displaytarget_format_supported(struct sw_winsys *ws,
+                                          unsigned tex_usage,
+                                          enum pipe_format format )
+{
+   return FALSE;
+}
+
+
+static void *
+null_sw_displaytarget_map(struct sw_winsys *ws,
+                          struct sw_displaytarget *dt,
+                          unsigned flags )
+{
+   assert(0);
+   return NULL;
+}
+
+
+static void
+null_sw_displaytarget_unmap(struct sw_winsys *ws,
+                            struct sw_displaytarget *dt )
+{
+   assert(0);
+}
+
+
+static void
+null_sw_displaytarget_destroy(struct sw_winsys *winsys,
+                              struct sw_displaytarget *dt)
+{
+   assert(0);
+}
+
+
+static struct sw_displaytarget *
+null_sw_displaytarget_create(struct sw_winsys *winsys,
+                             unsigned tex_usage,
+                             enum pipe_format format,
+                             unsigned width, unsigned height,
+                             unsigned alignment,
+                             unsigned *stride)
+{
+   return NULL;
+}
+
+
+static struct sw_displaytarget *
+null_sw_displaytarget_from_handle(struct sw_winsys *winsys,
+                                  const struct pipe_texture *templet,
+                                  struct winsys_handle *whandle,
+                                  unsigned *stride)
+{
+   return NULL;
+}
+
+
+static boolean
+null_sw_displaytarget_get_handle(struct sw_winsys *winsys,
+                                 struct sw_displaytarget *dt,
+                                 struct winsys_handle *whandle)
+{
+   assert(0);
+   return FALSE;
+}
+
+
+static void
+null_sw_displaytarget_display(struct sw_winsys *winsys,
+                              struct sw_displaytarget *dt,
+                              void *context_private)
+{
+   assert(0);
+}
+
+
+static void
+null_sw_destroy(struct sw_winsys *winsys)
+{
+   FREE(winsys);
+}
+
+
+struct sw_winsys *
+null_sw_create(void)
+{
+   static struct sw_winsys *winsys;
+
+   winsys = CALLOC_STRUCT(sw_winsys);
+   if (!winsys)
+      return NULL;
+
+   winsys->destroy = null_sw_destroy;
+   winsys->is_displaytarget_format_supported = null_sw_is_displaytarget_format_supported;
+   winsys->displaytarget_create = null_sw_displaytarget_create;
+   winsys->displaytarget_from_handle = null_sw_displaytarget_from_handle;
+   winsys->displaytarget_get_handle = null_sw_displaytarget_get_handle;
+   winsys->displaytarget_map = null_sw_displaytarget_map;
+   winsys->displaytarget_unmap = null_sw_displaytarget_unmap;
+   winsys->displaytarget_display = null_sw_displaytarget_display;
+   winsys->displaytarget_destroy = null_sw_displaytarget_destroy;
+
+   return winsys;
+}
diff --git a/src/gallium/winsys/sw/null/null_sw_winsys.h b/src/gallium/winsys/sw/null/null_sw_winsys.h
new file mode 100644 (file)
index 0000000..1986186
--- /dev/null
@@ -0,0 +1,40 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+
+#ifndef NULL_SW_WINSYS_H_
+#define NULL_SW_WINSYS_H_
+
+
+struct sw_winsys;
+
+
+struct sw_winsys *
+null_sw_create(void);
+
+
+#endif /* NULL_SW_WINSYS_H_ */
diff --git a/src/gallium/winsys/sw/wrapper/Makefile b/src/gallium/winsys/sw/wrapper/Makefile
new file mode 100644 (file)
index 0000000..4771fbc
--- /dev/null
@@ -0,0 +1,12 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = wsw
+
+C_SOURCES = wrapper_sw_winsys.c
+
+LIBRARY_INCLUDES =
+
+LIBRARY_DEFINES =
+
+include ../../../Makefile.template
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
new file mode 100644 (file)
index 0000000..459b1c1
--- /dev/null
@@ -0,0 +1,282 @@
+/**********************************************************
+ * Copyright 2010 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * 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 "wrapper_sw_winsys.h"
+
+#include "pipe/p_format.h"
+#include "pipe/p_state.h"
+
+#include "state_tracker/sw_winsys.h"
+
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+
+/*
+ * This code wraps a pipe_screen and exposes a sw_winsys interface for use
+ * with software resterizers. This code is used by the DRM based winsys to
+ * allow access to the drm driver.
+ *
+ * We must borrow the whole stack because only the pipe screen knows how
+ * to decode the content of a buffer. Or how to create a buffer that
+ * can still be used by drivers using real hardware (as the case is
+ * with software st/xorg but hw st/dri).
+ *
+ * We also need a pipe context for the transfers.
+ */
+
+struct wrapper_sw_winsys
+{
+   struct sw_winsys base;
+   struct pipe_screen *screen;
+   struct pipe_context *pipe;
+};
+
+struct wrapper_sw_displaytarget
+{
+   struct wrapper_sw_winsys *winsys;
+   struct pipe_texture *tex;
+   struct pipe_transfer *transfer;
+
+   unsigned width;
+   unsigned height;
+   unsigned map_count;
+   unsigned stride; /**< because we give stride at create */
+   void *ptr;
+};
+
+static INLINE struct wrapper_sw_winsys *
+wrapper_sw_winsys(struct sw_winsys *ws)
+{
+   return (struct wrapper_sw_winsys *)ws;
+}
+
+static INLINE struct wrapper_sw_displaytarget *
+wrapper_sw_displaytarget(struct sw_displaytarget *dt)
+{
+   return (struct wrapper_sw_displaytarget *)dt;
+}
+
+
+/*
+ * Functions
+ */
+
+
+static boolean
+wsw_dt_get_stride(struct wrapper_sw_displaytarget *wdt, unsigned *stride)
+{
+   struct pipe_context *pipe = wdt->winsys->pipe;
+   struct pipe_texture *tex = wdt->tex;
+   struct pipe_transfer *tr;
+
+   tr = pipe->get_tex_transfer(pipe, tex, 0, 0, 0,
+                               PIPE_TRANSFER_READ_WRITE,
+                               0, 0, wdt->width, wdt->height);
+   if (!tr)
+      return FALSE;
+
+   *stride = tr->stride;
+   wdt->stride = tr->stride;
+
+   pipe->tex_transfer_destroy(pipe, tr);
+
+   return TRUE;
+}
+
+static struct sw_displaytarget *
+wsw_dt_wrap_texture(struct wrapper_sw_winsys *wsw,
+                    struct pipe_texture *tex, unsigned *stride)
+{
+   struct wrapper_sw_displaytarget *wdt = CALLOC_STRUCT(wrapper_sw_displaytarget);
+   if (!wdt)
+      goto err_unref;
+
+   wdt->tex = tex;
+   wdt->winsys = wsw;
+
+   if (!wsw_dt_get_stride(wdt, stride))
+      goto err_free;
+
+   return (struct sw_displaytarget *)wdt;
+
+err_free:
+   FREE(wdt);
+err_unref:
+   pipe_texture_reference(&tex, NULL);
+   return NULL;
+}
+
+static struct sw_displaytarget *
+wsw_dt_create(struct sw_winsys *ws,
+              unsigned tex_usage,
+              enum pipe_format format,
+              unsigned width, unsigned height,
+              unsigned alignment,
+              unsigned *stride)
+{
+   struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
+   struct pipe_texture templ;
+   struct pipe_texture *tex;
+
+   /*
+    * XXX Why don't we just get the template.
+    */
+   memset(&templ, 0, sizeof(templ));
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.format = format;
+   templ.tex_usage = tex_usage;
+
+   /* XXX alignment: we can't do anything about this */
+
+   tex = wsw->screen->texture_create(wsw->screen, &templ);
+   if (!tex)
+      return NULL;
+
+   return wsw_dt_wrap_texture(wsw, tex, stride);
+}
+
+static struct sw_displaytarget *
+wsw_dt_from_handle(struct sw_winsys *ws,
+                   const struct pipe_texture *templ,
+                   struct winsys_handle *whandle,
+                   unsigned *stride)
+{
+   struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
+   struct pipe_texture *tex;
+
+   tex = wsw->screen->texture_from_handle(wsw->screen, templ, whandle);
+   if (!tex)
+      return NULL;
+
+   return wsw_dt_wrap_texture(wsw, tex, stride);
+}
+
+static void *
+wsw_dt_map(struct sw_winsys *ws,
+           struct sw_displaytarget *dt,
+           unsigned flags)
+{
+   struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
+   struct pipe_context *pipe = wdt->winsys->pipe;
+   struct pipe_texture *tex = wdt->tex;
+   struct pipe_transfer *tr;
+   void *ptr;
+
+   if (!wdt->map_count) {
+
+      assert(!wdt->transfer);
+
+      tr = pipe->get_tex_transfer(pipe, tex, 0, 0, 0,
+                                  PIPE_TRANSFER_READ_WRITE,
+                                  0, 0, wdt->width, wdt->height);
+      if (!tr)
+         return NULL;
+
+      ptr = pipe->transfer_map(pipe, tr);
+      if (!ptr)
+        goto err;
+
+      wdt->transfer = tr;
+      wdt->ptr = ptr;
+
+      /* XXX Handle this case */
+      assert(tr->stride == wdt->stride);
+   }
+
+   wdt->map_count++;
+
+   return wdt->ptr;
+
+err:
+   pipe->tex_transfer_destroy(pipe, tr);
+   return NULL;
+}
+
+static void
+wsw_dt_unmap(struct sw_winsys *ws,
+             struct sw_displaytarget *dt)
+{
+   struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
+   struct pipe_context *pipe = wdt->winsys->pipe;
+
+   assert(wdt->transfer);
+
+   wdt->map_count--;
+
+   if (wdt->map_count)
+      return;
+
+   pipe->transfer_unmap(pipe, wdt->transfer);
+   pipe->tex_transfer_destroy(pipe, wdt->transfer);
+   wdt->transfer = NULL;
+}
+
+static void
+wsw_dt_destroy(struct sw_winsys *ws,
+               struct sw_displaytarget *dt)
+{
+   struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
+
+   pipe_texture_reference(&wdt->tex, NULL);
+
+   FREE(wdt);
+}
+
+static void
+wsw_destroy(struct sw_winsys *ws)
+{
+   struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
+
+   wsw->pipe->destroy(wsw->pipe);
+   wsw->screen->destroy(wsw->screen);
+
+   FREE(wsw);
+}
+
+struct sw_winsys *
+wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen)
+{
+   struct wrapper_sw_winsys *wsw = CALLOC_STRUCT(wrapper_sw_winsys);
+
+   wsw->base.displaytarget_create = wsw_dt_create;
+   wsw->base.displaytarget_from_handle = wsw_dt_from_handle;
+   wsw->base.displaytarget_map = wsw_dt_map;
+   wsw->base.displaytarget_unmap = wsw_dt_unmap;
+   wsw->base.displaytarget_destroy = wsw_dt_destroy;
+   wsw->base.destroy = wsw_destroy;
+
+   wsw->screen = screen;
+   wsw->pipe = screen->context_create(screen, NULL);
+   if (!wsw->pipe)
+      goto err;
+
+   return &wsw->base;
+
+err:
+   FREE(wsw);
+   return NULL;
+}
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.h b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.h
new file mode 100644 (file)
index 0000000..b5c25a3
--- /dev/null
@@ -0,0 +1,35 @@
+/**********************************************************
+ * Copyright 2010 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * 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 WRAPPER_SW_WINSYS
+#define WRAPPER_SW_WINSYS
+
+struct sw_winsys;
+struct pipe_screen;
+
+struct sw_winsys *wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen);
+
+#endif
diff --git a/src/gallium/winsys/sw/xlib/Makefile b/src/gallium/winsys/sw/xlib/Makefile
new file mode 100644 (file)
index 0000000..c669389
--- /dev/null
@@ -0,0 +1,17 @@
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = ws_xlib
+
+LIBRARY_INCLUDES = \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary \
+       $(X11_CFLAGS)
+
+C_SOURCES = \
+       xlib_sw_winsys.c 
+
+include ../../../Makefile.template
+
+
diff --git a/src/gallium/winsys/sw/xlib/SConscript b/src/gallium/winsys/sw/xlib/SConscript
new file mode 100644 (file)
index 0000000..2af6153
--- /dev/null
@@ -0,0 +1,23 @@
+#######################################################################
+# SConscript for xlib winsys
+
+
+Import('*')
+
+if env['platform'] == 'linux':
+
+    env = env.Clone()
+
+    env.Append(CPPPATH = [
+        '#/src/gallium/include',
+        '#/src/gallium/auxiliary',
+        '#/src/gallium/drivers',
+    ])
+
+    ws_xlib = env.ConvenienceLibrary(
+        target = 'ws_xlib',
+        source = [
+           'xlib_sw_winsys.c',
+        ]
+    )
+    Export('ws_xlib')
diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
new file mode 100644 (file)
index 0000000..ad843b7
--- /dev/null
@@ -0,0 +1,466 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * 
+ **************************************************************************/
+
+/*
+ * Authors:
+ *   Keith Whitwell
+ *   Brian Paul
+ */
+
+#include "pipe/p_format.h"
+#include "pipe/p_context.h"
+#include "util/u_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "state_tracker/xlib_sw_winsys.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+
+/**
+ * Subclass of pipe_buffer for Xlib winsys.
+ * Low-level OS/window system memory buffer
+ */
+struct xm_displaytarget
+{
+   enum pipe_format format;
+   unsigned width;
+   unsigned height;
+   unsigned stride;
+
+   void *data;
+   void *mapped;
+
+   Display *display;
+   Visual *visual;
+   XImage *tempImage;
+   GC gc;
+
+   /* This is the last drawable that this display target was presented
+    * against.  May need to recreate gc, tempImage when this changes??
+    */
+   Drawable drawable;
+
+   XShmSegmentInfo shminfo;
+   int shm;
+};
+
+
+/**
+ * Subclass of sw_winsys for Xlib winsys
+ */
+struct xlib_sw_winsys
+{
+   struct sw_winsys base;
+
+
+
+   Display *display;
+};
+
+
+
+/** Cast wrapper */
+static INLINE struct xm_displaytarget *
+xm_displaytarget( struct sw_displaytarget *dt )
+{
+   return (struct xm_displaytarget *)dt;
+}
+
+
+/**
+ * X Shared Memory Image extension code
+ */
+
+static volatile int mesaXErrorFlag = 0;
+
+/**
+ * Catches potential Xlib errors.
+ */
+static int
+mesaHandleXError(Display *dpy, XErrorEvent *event)
+{
+   (void) dpy;
+   (void) event;
+   mesaXErrorFlag = 1;
+   return 0;
+}
+
+
+static char *alloc_shm(struct xm_displaytarget *buf, unsigned size)
+{
+   XShmSegmentInfo *const shminfo = & buf->shminfo;
+
+   shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
+   if (shminfo->shmid < 0) {
+      return NULL;
+   }
+
+   shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
+   if (shminfo->shmaddr == (char *) -1) {
+      shmctl(shminfo->shmid, IPC_RMID, 0);
+      return NULL;
+   }
+
+   shminfo->readOnly = False;
+   return shminfo->shmaddr;
+}
+
+
+/**
+ * Allocate a shared memory XImage back buffer for the given XMesaBuffer.
+ */
+static void
+alloc_shm_ximage(struct xm_displaytarget *xm_dt,
+                 struct xlib_drawable *xmb,
+                 unsigned width, unsigned height)
+{
+   /*
+    * We have to do a _lot_ of error checking here to be sure we can
+    * really use the XSHM extension.  It seems different servers trigger
+    * errors at different points if the extension won't work.  Therefore
+    * we have to be very careful...
+    */
+   int (*old_handler)(Display *, XErrorEvent *);
+
+   xm_dt->tempImage = XShmCreateImage(xm_dt->display,
+                                      xmb->visual,
+                                      xmb->depth,
+                                      ZPixmap,
+                                      NULL,
+                                      &xm_dt->shminfo,
+                                      width, height);
+   if (xm_dt->tempImage == NULL) {
+      xm_dt->shm = 0;
+      return;
+   }
+
+
+   mesaXErrorFlag = 0;
+   old_handler = XSetErrorHandler(mesaHandleXError);
+   /* This may trigger the X protocol error we're ready to catch: */
+   XShmAttach(xm_dt->display, &xm_dt->shminfo);
+   XSync(xm_dt->display, False);
+
+   if (mesaXErrorFlag) {
+      /* we are on a remote display, this error is normal, don't print it */
+      XFlush(xm_dt->display);
+      mesaXErrorFlag = 0;
+      XDestroyImage(xm_dt->tempImage);
+      xm_dt->tempImage = NULL;
+      xm_dt->shm = 0;
+      (void) XSetErrorHandler(old_handler);
+      return;
+   }
+
+   xm_dt->shm = 1;
+}
+
+
+static void
+alloc_ximage(struct xm_displaytarget *xm_dt,
+             struct xlib_drawable *xmb,
+             unsigned width, unsigned height)
+{
+   if (xm_dt->shm) {
+      alloc_shm_ximage(xm_dt, xmb, width, height);
+      return;
+   }
+
+   xm_dt->tempImage = XCreateImage(xm_dt->display,
+                                   xmb->visual,
+                                   xmb->depth,
+                                   ZPixmap, 0,
+                                   NULL, width, height,
+                                   8, 0);
+}
+
+static boolean
+xm_is_displaytarget_format_supported( struct sw_winsys *ws,
+                                      unsigned tex_usage,
+                                      enum pipe_format format )
+{
+   /* TODO: check visuals or other sensible thing here */
+   return TRUE;
+}
+
+
+static void *
+xm_displaytarget_map(struct sw_winsys *ws,
+                     struct sw_displaytarget *dt,
+                     unsigned flags)
+{
+   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+   xm_dt->mapped = xm_dt->data;
+   return xm_dt->mapped;
+}
+
+static void
+xm_displaytarget_unmap(struct sw_winsys *ws,
+                       struct sw_displaytarget *dt)
+{
+   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+   xm_dt->mapped = NULL;
+}
+
+static void
+xm_displaytarget_destroy(struct sw_winsys *ws,
+                         struct sw_displaytarget *dt)
+{
+   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+
+   if (xm_dt->data) {
+      if (xm_dt->shminfo.shmid >= 0) {
+         shmdt(xm_dt->shminfo.shmaddr);
+         shmctl(xm_dt->shminfo.shmid, IPC_RMID, 0);
+         
+         xm_dt->shminfo.shmid = -1;
+         xm_dt->shminfo.shmaddr = (char *) -1;
+      }
+      else {
+         FREE(xm_dt->data);
+      }
+   }
+
+   if (xm_dt->tempImage)
+      XDestroyImage(xm_dt->tempImage);
+
+   if (xm_dt->gc)
+      XFreeGC(xm_dt->display, xm_dt->gc);
+
+   FREE(xm_dt);
+}
+
+
+/**
+ * Display/copy the image in the surface into the X window specified
+ * by the XMesaBuffer.
+ */
+static void
+xlib_sw_display(struct xlib_drawable *xlib_drawable,
+                struct sw_displaytarget *dt)
+{
+   static boolean no_swap = 0;
+   static boolean firsttime = 1;
+   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+   Display *display = xm_dt->display;
+   XImage *ximage;
+
+   if (firsttime) {
+      no_swap = getenv("SP_NO_RAST") != NULL;
+      firsttime = 0;
+   }
+
+   if (no_swap)
+      return;
+
+   if (xm_dt->drawable != xlib_drawable->drawable) {
+      if (xm_dt->gc) {
+         XFreeGC( display, xm_dt->gc );
+         xm_dt->gc = NULL;
+      }
+
+      if (xm_dt->tempImage) {
+         XDestroyImage( xm_dt->tempImage );
+         xm_dt->tempImage = NULL;
+      }
+
+      xm_dt->drawable = xlib_drawable->drawable;
+   }
+
+   if (xm_dt->tempImage == NULL) {
+      assert(util_format_get_blockwidth(xm_dt->format) == 1);
+      assert(util_format_get_blockheight(xm_dt->format) == 1);
+      alloc_ximage(xm_dt, xlib_drawable,
+                   xm_dt->stride / util_format_get_blocksize(xm_dt->format),
+                   xm_dt->height);
+      if (!xm_dt->tempImage)
+         return;
+   }
+
+   if (xm_dt->gc == NULL) {
+      xm_dt->gc = XCreateGC( display, xlib_drawable->drawable, 0, NULL );
+      XSetFunction( display, xm_dt->gc, GXcopy );
+   }
+
+   if (xm_dt->shm)
+   {
+      ximage = xm_dt->tempImage;
+      ximage->data = xm_dt->data;
+
+      /* _debug_printf("XSHM\n"); */
+      XShmPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc,
+                   ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False);
+   }
+   else {
+      /* display image in Window */
+      ximage = xm_dt->tempImage;
+      ximage->data = xm_dt->data;
+
+      /* check that the XImage has been previously initialized */
+      assert(ximage->format);
+      assert(ximage->bitmap_unit);
+
+      /* update XImage's fields */
+      ximage->width = xm_dt->width;
+      ximage->height = xm_dt->height;
+      ximage->bytes_per_line = xm_dt->stride;
+
+      /* _debug_printf("XPUT\n"); */
+      XPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc,
+                ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height);
+   }
+
+   XFlush(xm_dt->display);
+}
+
+/**
+ * Display/copy the image in the surface into the X window specified
+ * by the XMesaBuffer.
+ */
+static void
+xm_displaytarget_display(struct sw_winsys *ws,
+                         struct sw_displaytarget *dt,
+                         void *context_private)
+{
+   struct xlib_drawable *xlib_drawable = (struct xlib_drawable *)context_private;
+   xlib_sw_display(xlib_drawable, dt);
+}
+
+
+static struct sw_displaytarget *
+xm_displaytarget_create(struct sw_winsys *winsys,
+                        unsigned tex_usage,
+                        enum pipe_format format,
+                        unsigned width, unsigned height,
+                        unsigned alignment,
+                        unsigned *stride)
+{
+   struct xm_displaytarget *xm_dt;
+   unsigned nblocksy, size;
+
+   xm_dt = CALLOC_STRUCT(xm_displaytarget);
+   if(!xm_dt)
+      goto no_xm_dt;
+
+   xm_dt->display = ((struct xlib_sw_winsys *)winsys)->display;
+   xm_dt->format = format;
+   xm_dt->width = width;
+   xm_dt->height = height;
+
+   nblocksy = util_format_get_nblocksy(format, height);
+   xm_dt->stride = align(util_format_get_stride(format, width), alignment);
+   size = xm_dt->stride * nblocksy;
+
+   if (!debug_get_bool_option("XLIB_NO_SHM", FALSE))
+   {
+      xm_dt->shminfo.shmid = -1;
+      xm_dt->shminfo.shmaddr = (char *) -1;
+      xm_dt->shm = TRUE;
+         
+      xm_dt->data = alloc_shm(xm_dt, size);
+      if(!xm_dt->data)
+         goto no_data;
+   }
+
+   if(!xm_dt->data) {
+      xm_dt->data = align_malloc(size, alignment);
+      if(!xm_dt->data)
+         goto no_data;
+   }
+
+   *stride = xm_dt->stride;
+   return (struct sw_displaytarget *)xm_dt;
+
+no_data:
+   FREE(xm_dt);
+no_xm_dt:
+   return NULL;
+}
+
+
+static struct sw_displaytarget *
+xm_displaytarget_from_handle(struct sw_winsys *winsys,
+                             const struct pipe_texture *templet,
+                             struct winsys_handle *whandle,
+                             unsigned *stride)
+{
+   assert(0);
+   return NULL;
+}
+
+
+static boolean
+xm_displaytarget_get_handle(struct sw_winsys *winsys,
+                            struct sw_displaytarget *dt,
+                            struct winsys_handle *whandle)
+{
+   assert(0);
+   return FALSE;
+}
+
+
+static void
+xm_destroy( struct sw_winsys *ws )
+{
+   FREE(ws);
+}
+
+
+struct sw_winsys *
+xlib_create_sw_winsys( Display *display )
+{
+   struct xlib_sw_winsys *ws;
+
+   ws = CALLOC_STRUCT(xlib_sw_winsys);
+   if (!ws)
+      return NULL;
+
+   ws->display = display;
+   ws->base.destroy = xm_destroy;
+
+   ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported;
+
+   ws->base.displaytarget_create = xm_displaytarget_create;
+   ws->base.displaytarget_from_handle = xm_displaytarget_from_handle;
+   ws->base.displaytarget_get_handle = xm_displaytarget_get_handle;
+   ws->base.displaytarget_map = xm_displaytarget_map;
+   ws->base.displaytarget_unmap = xm_displaytarget_unmap;
+   ws->base.displaytarget_destroy = xm_displaytarget_destroy;
+
+   ws->base.displaytarget_display = xm_displaytarget_display;
+
+   return &ws->base;
+}
+
diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile
deleted file mode 100644 (file)
index 18357a4..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = ws_xlib
-
-LIBRARY_INCLUDES = \
-       -I$(TOP)/src/gallium/include \
-       -I$(TOP)/src/gallium/drivers \
-       -I$(TOP)/src/gallium/auxiliary \
-       $(X_CFLAGS)
-
-C_SOURCES = \
-       xlib_sw_winsys.c 
-
-include ../../Makefile.template
-
-
diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript
deleted file mode 100644 (file)
index 2af6153..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#######################################################################
-# SConscript for xlib winsys
-
-
-Import('*')
-
-if env['platform'] == 'linux':
-
-    env = env.Clone()
-
-    env.Append(CPPPATH = [
-        '#/src/gallium/include',
-        '#/src/gallium/auxiliary',
-        '#/src/gallium/drivers',
-    ])
-
-    ws_xlib = env.ConvenienceLibrary(
-        target = 'ws_xlib',
-        source = [
-           'xlib_sw_winsys.c',
-        ]
-    )
-    Export('ws_xlib')
diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c
deleted file mode 100644 (file)
index cecfa4a..0000000
+++ /dev/null
@@ -1,439 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell
- *   Brian Paul
- */
-
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-
-#include "state_tracker/xlib_sw_winsys.h"
-
-#include <X11/Xlib.h>
-#include <X11/Xlibint.h>
-#include <X11/Xutil.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <X11/extensions/XShm.h>
-
-/**
- * Subclass of pipe_buffer for Xlib winsys.
- * Low-level OS/window system memory buffer
- */
-struct xm_displaytarget
-{
-   enum pipe_format format;
-   unsigned width;
-   unsigned height;
-   unsigned stride;
-
-   void *data;
-   void *mapped;
-
-   Display *display;
-   Visual *visual;
-   XImage *tempImage;
-   GC gc;
-
-   /* This is the last drawable that this display target was presented
-    * against.  May need to recreate gc, tempImage when this changes??
-    */
-   Drawable drawable;
-
-   XShmSegmentInfo shminfo;
-   int shm;
-};
-
-
-/**
- * Subclass of sw_winsys for Xlib winsys
- */
-struct xlib_sw_winsys
-{
-   struct sw_winsys base;
-
-
-
-   Display *display;
-};
-
-
-
-/** Cast wrapper */
-static INLINE struct xm_displaytarget *
-xm_displaytarget( struct sw_displaytarget *dt )
-{
-   return (struct xm_displaytarget *)dt;
-}
-
-
-/**
- * X Shared Memory Image extension code
- */
-
-static volatile int mesaXErrorFlag = 0;
-
-/**
- * Catches potential Xlib errors.
- */
-static int
-mesaHandleXError(Display *dpy, XErrorEvent *event)
-{
-   (void) dpy;
-   (void) event;
-   mesaXErrorFlag = 1;
-   return 0;
-}
-
-
-static char *alloc_shm(struct xm_displaytarget *buf, unsigned size)
-{
-   XShmSegmentInfo *const shminfo = & buf->shminfo;
-
-   shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
-   if (shminfo->shmid < 0) {
-      return NULL;
-   }
-
-   shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
-   if (shminfo->shmaddr == (char *) -1) {
-      shmctl(shminfo->shmid, IPC_RMID, 0);
-      return NULL;
-   }
-
-   shminfo->readOnly = False;
-   return shminfo->shmaddr;
-}
-
-
-/**
- * Allocate a shared memory XImage back buffer for the given XMesaBuffer.
- */
-static void
-alloc_shm_ximage(struct xm_displaytarget *xm_dt,
-                 struct xlib_drawable *xmb,
-                 unsigned width, unsigned height)
-{
-   /*
-    * We have to do a _lot_ of error checking here to be sure we can
-    * really use the XSHM extension.  It seems different servers trigger
-    * errors at different points if the extension won't work.  Therefore
-    * we have to be very careful...
-    */
-   int (*old_handler)(Display *, XErrorEvent *);
-
-   xm_dt->tempImage = XShmCreateImage(xm_dt->display,
-                                      xmb->visual,
-                                      xmb->depth,
-                                      ZPixmap,
-                                      NULL,
-                                      &xm_dt->shminfo,
-                                      width, height);
-   if (xm_dt->tempImage == NULL) {
-      xm_dt->shm = 0;
-      return;
-   }
-
-
-   mesaXErrorFlag = 0;
-   old_handler = XSetErrorHandler(mesaHandleXError);
-   /* This may trigger the X protocol error we're ready to catch: */
-   XShmAttach(xm_dt->display, &xm_dt->shminfo);
-   XSync(xm_dt->display, False);
-
-   if (mesaXErrorFlag) {
-      /* we are on a remote display, this error is normal, don't print it */
-      XFlush(xm_dt->display);
-      mesaXErrorFlag = 0;
-      XDestroyImage(xm_dt->tempImage);
-      xm_dt->tempImage = NULL;
-      xm_dt->shm = 0;
-      (void) XSetErrorHandler(old_handler);
-      return;
-   }
-
-   xm_dt->shm = 1;
-}
-
-
-static void
-alloc_ximage(struct xm_displaytarget *xm_dt,
-             struct xlib_drawable *xmb,
-             unsigned width, unsigned height)
-{
-   if (xm_dt->shm) {
-      alloc_shm_ximage(xm_dt, xmb, width, height);
-      return;
-   }
-
-   xm_dt->tempImage = XCreateImage(xm_dt->display,
-                                   xmb->visual,
-                                   xmb->depth,
-                                   ZPixmap, 0,
-                                   NULL, width, height,
-                                   8, 0);
-}
-
-static boolean
-xm_is_displaytarget_format_supported( struct sw_winsys *ws,
-                                      enum pipe_format format )
-{
-   /* TODO: check visuals or other sensible thing here */
-   return TRUE;
-}
-
-
-static void *
-xm_displaytarget_map(struct sw_winsys *ws,
-                     struct sw_displaytarget *dt,
-                     unsigned flags)
-{
-   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
-   xm_dt->mapped = xm_dt->data;
-   return xm_dt->mapped;
-}
-
-static void
-xm_displaytarget_unmap(struct sw_winsys *ws,
-                       struct sw_displaytarget *dt)
-{
-   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
-   xm_dt->mapped = NULL;
-}
-
-static void
-xm_displaytarget_destroy(struct sw_winsys *ws,
-                         struct sw_displaytarget *dt)
-{
-   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
-
-   if (xm_dt->data) {
-      if (xm_dt->shminfo.shmid >= 0) {
-         shmdt(xm_dt->shminfo.shmaddr);
-         shmctl(xm_dt->shminfo.shmid, IPC_RMID, 0);
-         
-         xm_dt->shminfo.shmid = -1;
-         xm_dt->shminfo.shmaddr = (char *) -1;
-      }
-      else {
-         FREE(xm_dt->data);
-      }
-   }
-
-   if (xm_dt->tempImage)
-      XDestroyImage(xm_dt->tempImage);
-
-   if (xm_dt->gc)
-      XFreeGC(xm_dt->display, xm_dt->gc);
-
-   FREE(xm_dt);
-}
-
-
-/**
- * Display/copy the image in the surface into the X window specified
- * by the XMesaBuffer.
- */
-static void
-xlib_sw_display(struct xlib_drawable *xlib_drawable,
-                struct sw_displaytarget *dt)
-{
-   static boolean no_swap = 0;
-   static boolean firsttime = 1;
-   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
-   Display *display = xm_dt->display;
-   XImage *ximage;
-
-   if (firsttime) {
-      no_swap = getenv("SP_NO_RAST") != NULL;
-      firsttime = 0;
-   }
-
-   if (no_swap)
-      return;
-
-   if (xm_dt->drawable != xlib_drawable->drawable) {
-      if (xm_dt->gc) {
-         XFreeGC( display, xm_dt->gc );
-         xm_dt->gc = NULL;
-      }
-
-      if (xm_dt->tempImage) {
-         XDestroyImage( xm_dt->tempImage );
-         xm_dt->tempImage = NULL;
-      }
-
-      xm_dt->drawable = xlib_drawable->drawable;
-   }
-
-   if (xm_dt->tempImage == NULL) {
-      assert(util_format_get_blockwidth(xm_dt->format) == 1);
-      assert(util_format_get_blockheight(xm_dt->format) == 1);
-      alloc_ximage(xm_dt, xlib_drawable,
-                   xm_dt->stride / util_format_get_blocksize(xm_dt->format),
-                   xm_dt->height);
-      if (!xm_dt->tempImage)
-         return;
-   }
-
-   if (xm_dt->gc == NULL) {
-      xm_dt->gc = XCreateGC( display, xlib_drawable->drawable, 0, NULL );
-      XSetFunction( display, xm_dt->gc, GXcopy );
-   }
-
-   if (xm_dt->shm)
-   {
-      ximage = xm_dt->tempImage;
-      ximage->data = xm_dt->data;
-
-      /* _debug_printf("XSHM\n"); */
-      XShmPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc,
-                   ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False);
-   }
-   else {
-      /* display image in Window */
-      ximage = xm_dt->tempImage;
-      ximage->data = xm_dt->data;
-
-      /* check that the XImage has been previously initialized */
-      assert(ximage->format);
-      assert(ximage->bitmap_unit);
-
-      /* update XImage's fields */
-      ximage->width = xm_dt->width;
-      ximage->height = xm_dt->height;
-      ximage->bytes_per_line = xm_dt->stride;
-
-      /* _debug_printf("XPUT\n"); */
-      XPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc,
-                ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height);
-   }
-}
-
-/**
- * Display/copy the image in the surface into the X window specified
- * by the XMesaBuffer.
- */
-static void
-xm_displaytarget_display(struct sw_winsys *ws,
-                         struct sw_displaytarget *dt,
-                         void *context_private)
-{
-   struct xlib_drawable *xlib_drawable = (struct xlib_drawable *)context_private;
-   xlib_sw_display(xlib_drawable, dt);
-}
-
-
-static struct sw_displaytarget *
-xm_displaytarget_create(struct sw_winsys *winsys,
-                        enum pipe_format format,
-                        unsigned width, unsigned height,
-                        unsigned alignment,
-                        unsigned *stride)
-{
-   struct xm_displaytarget *xm_dt;
-   unsigned nblocksy, size;
-
-   xm_dt = CALLOC_STRUCT(xm_displaytarget);
-   if(!xm_dt)
-      goto no_xm_dt;
-
-   xm_dt->display = ((struct xlib_sw_winsys *)winsys)->display;
-   xm_dt->format = format;
-   xm_dt->width = width;
-   xm_dt->height = height;
-
-   nblocksy = util_format_get_nblocksy(format, height);
-   xm_dt->stride = align(util_format_get_stride(format, width), alignment);
-   size = xm_dt->stride * nblocksy;
-
-   if (!debug_get_bool_option("XLIB_NO_SHM", FALSE))
-   {
-      xm_dt->shminfo.shmid = -1;
-      xm_dt->shminfo.shmaddr = (char *) -1;
-      xm_dt->shm = TRUE;
-         
-      xm_dt->data = alloc_shm(xm_dt, size);
-      if(!xm_dt->data)
-         goto no_data;
-   }
-
-   if(!xm_dt->data) {
-      xm_dt->data = align_malloc(size, alignment);
-      if(!xm_dt->data)
-         goto no_data;
-   }
-
-   *stride = xm_dt->stride;
-   return (struct sw_displaytarget *)xm_dt;
-
-no_data:
-   FREE(xm_dt);
-no_xm_dt:
-   return NULL;
-}
-
-
-static void
-xm_destroy( struct sw_winsys *ws )
-{
-   FREE(ws);
-}
-
-
-struct sw_winsys *
-xlib_create_sw_winsys( Display *display )
-{
-   struct xlib_sw_winsys *ws;
-
-   ws = CALLOC_STRUCT(xlib_sw_winsys);
-   if (!ws)
-      return NULL;
-
-   ws->display = display;
-   ws->base.destroy = xm_destroy;
-
-   ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported;
-
-   ws->base.displaytarget_create = xm_displaytarget_create;
-   ws->base.displaytarget_map = xm_displaytarget_map;
-   ws->base.displaytarget_unmap = xm_displaytarget_unmap;
-   ws->base.displaytarget_destroy = xm_displaytarget_destroy;
-
-   ws->base.displaytarget_display = xm_displaytarget_display;
-
-   return &ws->base;
-}
-
index 5de55cdbf29505fa97bb9713bf2150f2851b8ea7..9ca9b3eb06559c2ab3f16d5a3c4376a5e08d1d7d 100644 (file)
@@ -62,6 +62,8 @@ static Bool
 DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire);
 static Status
 DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire);
+static int
+DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code);
 
 static /* const */ XExtensionHooks dri2ExtensionHooks = {
   NULL,                   /* create_gc */
@@ -73,7 +75,7 @@ static /* const */ XExtensionHooks dri2ExtensionHooks = {
   DRI2CloseDisplay,       /* close_display */
   DRI2WireToEvent,        /* wire_to_event */
   DRI2EventToWire,        /* event_to_wire */
-  NULL,                   /* error */
+  DRI2Error,              /* error */
   NULL,                   /* error_string */
 };
 
@@ -160,6 +162,17 @@ DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire)
    return Success;
 }
 
+static int
+DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code)
+{
+    if (err->majorCode == codes->major_opcode &&
+       err->errorCode == BadDrawable &&
+       err->minorCode == X_DRI2CopyRegion)
+       return True;
+
+    return False;
+}
+
 Bool
 DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase)
 {
index 5b0f335db6af28190d51d89bd92988662fa145d8..14788b89bead096bb91c680bb12bf842df36822f 100644 (file)
@@ -202,6 +202,8 @@ dri2CreateDrawable(__GLXscreenConfigs * psc,
    return &pdraw->base;
 }
 
+#ifdef X_DRI2GetMSC
+
 static int
 dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw,
                   int64_t *ust, int64_t *msc, int64_t *sbc)
@@ -209,6 +211,11 @@ dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw,
    return DRI2GetMSC(psc->dpy, pdraw->xDrawable, ust, msc, sbc);
 }
 
+#endif
+
+
+#ifdef X_DRI2WaitMSC
+
 static int
 dri2WaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
               int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc)
@@ -225,6 +232,8 @@ dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
                      sbc);
 }
 
+#endif /* X_DRI2WaitMSC */
+
 static void
 dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height)
 {
@@ -448,6 +457,8 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable,
    return pdraw->buffers;
 }
 
+#ifdef X_DRI2SwapInterval
+
 static void
 dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
 {
@@ -465,6 +476,8 @@ dri2GetSwapInterval(__GLXDRIdrawable *pdraw)
   return priv->swap_interval;
 }
 
+#endif /* X_DRI2SwapInterval */
+
 static const __DRIdri2LoaderExtension dri2LoaderExtension = {
    {__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION},
    dri2GetBuffers,
index 1b94a56fd1326ce33493dca5a44431241f95d355..786faff81c1733651f27f3adc06f1d8f027d10ed 100644 (file)
@@ -53,13 +53,8 @@ struct __GLXDRIdrawablePrivateRec
 
    XVisualInfo *visinfo;
    XImage *ximage;
-   int bpp;
 };
 
-/**
- * swrast loader functions
- */
-
 static Bool
 XCreateDrawable(__GLXDRIdrawablePrivate * pdp,
                 Display * dpy, XID drawable, int visualid)
@@ -79,20 +74,21 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp,
    XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
    XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);
 
-   /* create XImage  */
+   /* visual */
    visTemp.screen = DefaultScreen(dpy);
    visTemp.visualid = visualid;
    visMask = (VisualScreenMask | VisualIDMask);
    pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);
 
-   pdp->ximage = XCreateImage(dpy, pdp->visinfo->visual, pdp->visinfo->depth, ZPixmap, 0,       /* format, offset */
-                              NULL,     /* data */
-                              0, 0,     /* size */
-                              32,       /* bitmap_pad */
-                              0);       /* bytes_per_line */
-
-   /* get the true number of bits per pixel */
-   pdp->bpp = pdp->ximage->bits_per_pixel;
+   /* create XImage */
+   pdp->ximage = XCreateImage(dpy,
+                              pdp->visinfo->visual,
+                              pdp->visinfo->depth,
+                              ZPixmap, 0,             /* format, offset */
+                              NULL,                   /* data */
+                              0, 0,                   /* width, height */
+                              32,                     /* bitmap_pad */
+                              0);                     /* bytes_per_line */
 
    return True;
 }
@@ -107,9 +103,14 @@ XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable)
    XFreeGC(dpy, pdp->swapgc);
 }
 
+/**
+ * swrast loader functions
+ */
+
 static void
 swrastGetDrawableInfo(__DRIdrawable * draw,
-                      int *x, int *y, int *w, int *h, void *loaderPrivate)
+                      int *x, int *y, int *w, int *h,
+                      void *loaderPrivate)
 {
    __GLXDRIdrawablePrivate *pdp = loaderPrivate;
    __GLXDRIdrawable *pdraw = &(pdp->base);
@@ -118,26 +119,42 @@ swrastGetDrawableInfo(__DRIdrawable * draw,
 
    Window root;
    Status stat;
-   unsigned int bw, depth;
+   unsigned uw, uh, bw, depth;
 
    drawable = pdraw->xDrawable;
 
    stat = XGetGeometry(dpy, drawable, &root,
-                       x, y, (unsigned int *) w, (unsigned int *) h,
-                       &bw, &depth);
+                       x, y, &uw, &uh, &bw, &depth);
+   *w = uw;
+   *h = uh;
 }
 
+/**
+ * Align renderbuffer pitch.
+ *
+ * This should be chosen by the driver and the loader (libGL, xserver/glx)
+ * should use the driver provided pitch.
+ *
+ * It seems that the xorg loader (that is the xserver loading swrast_dri for
+ * indirect rendering, not client-side libGL) requires that the pitch is
+ * exactly the image width padded to 32 bits. XXX
+ *
+ * The above restriction can probably be overcome by using ScratchPixmap and
+ * CopyArea in the xserver, similar to ShmPutImage, and setting the width of
+ * the scratch pixmap to 'pitch / cpp'.
+ */
 static inline int
-bytes_per_line(int w, int bpp, unsigned mul)
+bytes_per_line(unsigned pitch_bits, unsigned mul)
 {
    unsigned mask = mul - 1;
 
-   return ((w * bpp + mask) & ~mask) / 8;
+   return ((pitch_bits + mask) & ~mask) / 8;
 }
 
 static void
 swrastPutImage(__DRIdrawable * draw, int op,
-               int x, int y, int w, int h, char *data, void *loaderPrivate)
+               int x, int y, int w, int h,
+               char *data, void *loaderPrivate)
 {
    __GLXDRIdrawablePrivate *pdp = loaderPrivate;
    __GLXDRIdrawable *pdraw = &(pdp->base);
@@ -163,7 +180,7 @@ swrastPutImage(__DRIdrawable * draw, int op,
    ximage->data = data;
    ximage->width = w;
    ximage->height = h;
-   ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
+   ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
 
    XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
 
@@ -171,24 +188,25 @@ swrastPutImage(__DRIdrawable * draw, int op,
 }
 
 static void
-swrastGetImage(__DRIdrawable * draw,
-               int x, int y, int w, int h, char *data, void *loaderPrivate)
+swrastGetImage(__DRIdrawable * read,
+               int x, int y, int w, int h,
+               char *data, void *loaderPrivate)
 {
-   __GLXDRIdrawablePrivate *pdp = loaderPrivate;
-   __GLXDRIdrawable *pdraw = &(pdp->base);
-   Display *dpy = pdraw->psc->dpy;
-   Drawable drawable;
+   __GLXDRIdrawablePrivate *prp = loaderPrivate;
+   __GLXDRIdrawable *pread = &(prp->base);
+   Display *dpy = pread->psc->dpy;
+   Drawable readable;
    XImage *ximage;
 
-   drawable = pdraw->xDrawable;
+   readable = pread->xDrawable;
 
-   ximage = pdp->ximage;
+   ximage = prp->ximage;
    ximage->data = data;
    ximage->width = w;
    ximage->height = h;
-   ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
+   ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
 
-   XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
+   XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
 
    ximage->data = NULL;
 }
@@ -334,10 +352,17 @@ driCreateDrawable(__GLXscreenConfigs * psc,
    return pdraw;
 }
 
-static void
-driSwapBuffers(__GLXDRIdrawable * pdraw)
+static int64_t
+driSwapBuffers(__GLXDRIdrawable * pdraw,
+               int64_t target_msc, int64_t divisor, int64_t remainder)
 {
+   (void) target_msc;
+   (void) divisor;
+   (void) remainder;
+
    (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable);
+
+   return 0;
 }
 
 static void
@@ -350,6 +375,20 @@ driDestroyScreen(__GLXscreenConfigs * psc)
       dlclose(psc->driver);
 }
 
+static void *
+driOpenSwrast(void)
+{
+   void *driver = NULL;
+
+   if (driver == NULL)
+      driver = driOpenDriver("swrast");
+
+   if (driver == NULL)
+      driver = driOpenDriver("swrastg");
+
+   return driver;
+}
+
 static __GLXDRIscreen *
 driCreateScreen(__GLXscreenConfigs * psc, int screen,
                 __GLXdisplayPrivate * priv)
@@ -357,14 +396,13 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,
    __GLXDRIscreen *psp;
    const __DRIconfig **driver_configs;
    const __DRIextension **extensions;
-   const char *driverName = "swrast";
    int i;
 
    psp = Xcalloc(1, sizeof *psp);
    if (psp == NULL)
       return NULL;
 
-   psc->driver = driOpenDriver(driverName);
+   psc->driver = driOpenSwrast();
    if (psc->driver == NULL)
       goto handle_error;
 
index 49cbce72f8a279fc2368cbbda17761a75cadde47..ea267f3dd8ace2f2f024ee4eefff0ea4c7e99c5b 100644 (file)
@@ -2507,6 +2507,9 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
    if (divisor > 0 && remainder >= divisor)
       return -1;
 
+   if (target_msc == 0 && divisor == 0 && remainder == 0)
+      remainder = 1;
+
 #ifdef __DRI_SWAP_BUFFER_COUNTER
    if (psc->counters != NULL)
       return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc,
index 86da6f58bd8e7e53b5971f878e0e6929285c7599..c85085434e4ace1d697db29c82ccabf8144dede0 100644 (file)
@@ -182,6 +182,7 @@ if env['platform'] != 'winddk':
                'state_tracker/st_format.c',
                'state_tracker/st_framebuffer.c',
                'state_tracker/st_gen_mipmap.c',
+               'state_tracker/st_manager.c',
                'state_tracker/st_mesa_to_tgsi.c',
                'state_tracker/st_program.c',
                'state_tracker/st_texture.c',
index b97b760f1815da03e06705b28836100765e86d11..84a2a5fcb3a01f7fb9f12392eaa99e85e1718d7e 100644 (file)
@@ -429,13 +429,15 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state)
    if (state & META_SHADER) {
       if (ctx->Extensions.ARB_vertex_program) {
          save->VertexProgramEnabled = ctx->VertexProgram.Enabled;
-         save->VertexProgram = ctx->VertexProgram.Current;
+         _mesa_reference_vertprog(ctx, &save->VertexProgram,
+                                 ctx->VertexProgram.Current);
          _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE);
       }
 
       if (ctx->Extensions.ARB_fragment_program) {
          save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled;
-         save->FragmentProgram = ctx->FragmentProgram.Current;
+         _mesa_reference_fragprog(ctx, &save->FragmentProgram,
+                                 ctx->FragmentProgram.Current);
          _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE);
       }
 
@@ -663,6 +665,7 @@ _mesa_meta_end(GLcontext *ctx)
                           save->VertexProgramEnabled);
          _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, 
                                   save->VertexProgram);
+        _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL);
       }
 
       if (ctx->Extensions.ARB_fragment_program) {
@@ -670,6 +673,7 @@ _mesa_meta_end(GLcontext *ctx)
                           save->FragmentProgramEnabled);
          _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
                                   save->FragmentProgram);
+        _mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL);
       }
 
       if (ctx->Extensions.ARB_shader_objects) {
@@ -720,6 +724,7 @@ _mesa_meta_end(GLcontext *ctx)
       for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
          _mesa_reference_texobj(&ctx->Texture.Unit[0].CurrentTex[tgt],
                                 save->CurrentTexture[tgt]);
+         _mesa_reference_texobj(&save->CurrentTexture[tgt], NULL);
       }
 
       /* Re-enable textures, texgen */
@@ -2062,8 +2067,10 @@ _mesa_meta_Bitmap(GLcontext *ctx,
    }
 
    bitmap1 = _mesa_map_pbo_source(ctx, &unpackSave, bitmap1);
-   if (!bitmap1)
+   if (!bitmap1) {
+      _mesa_meta_end(ctx);
       return;
+   }
 
    bitmap8 = (GLubyte *) calloc(1, width * height);
    if (bitmap8) {
index a0c25d26cdf6011ba3a5cf1f5cb0e395b773d647..f19cc039b22578acc7b6ba9ddb31b1cdce32e448 100644 (file)
@@ -51,9 +51,12 @@ lib: symlinks subdirs depend
        @$(MAKE) $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
 
 $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \
-               $(TOP)/src/mesa/drivers/dri/Makefile.template
-       $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o
+       $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS)
+       $(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
+       @rm -f $@.test
+       mv -f $@.tmp $@
 
 
 $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
diff --git a/src/mesa/drivers/dri/common/dri_sw.c b/src/mesa/drivers/dri/common/dri_sw.c
deleted file mode 100644 (file)
index b7f9036..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file dri_sw.c
- *
- * DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits.
- */
-
-#include "dri_sw.h"
-#include "utils.h"
-
-
-/**
- * Screen functions
- */
-
-static void
-setupLoaderExtensions(__DRIscreen *psp,
-                     const __DRIextension **extensions)
-{
-    int i;
-
-    for (i = 0; extensions[i]; i++) {
-       if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0)
-           psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
-    }
-}
-
-static __DRIscreen *
-driCreateNewScreen(int scrn, const __DRIextension **extensions,
-                  const __DRIconfig ***driver_configs, void *data)
-{
-    static const __DRIextension *emptyExtensionList[] = { NULL };
-    __DRIscreen *psp;
-
-    (void) data;
-
-    psp = CALLOC_STRUCT(__DRIscreenRec);
-    if (!psp)
-       return NULL;
-
-    setupLoaderExtensions(psp, extensions);
-
-    psp->extensions = emptyExtensionList;
-    psp->myNum = scrn;
-
-    *driver_configs = driDriverAPI.InitScreen(psp);
-
-    if (*driver_configs == NULL) {
-       FREE(psp);
-       return NULL;
-    }
-
-    return psp;
-}
-
-static void driDestroyScreen(__DRIscreen *psp)
-{
-    if (psp) {
-       driDriverAPI.DestroyScreen(psp);
-
-       FREE(psp);
-    }
-}
-
-static const __DRIextension **driGetExtensions(__DRIscreen *psp)
-{
-    return psp->extensions;
-}
-
-
-/**
- * Context functions
- */
-
-static __DRIcontext *
-driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
-                   __DRIcontext *shared, void *data)
-{
-    __DRIcontext *pcp;
-    void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
-
-    pcp = CALLOC_STRUCT(__DRIcontextRec);
-    if (!pcp)
-       return NULL;
-
-    pcp->loaderPrivate = data;
-
-    pcp->driScreenPriv = psp;
-    pcp->driDrawablePriv = NULL;
-    pcp->driReadablePriv = NULL;
-
-    if (!driDriverAPI.CreateContext(&config->modes, pcp, shareCtx)) {
-       FREE(pcp);
-       return NULL;
-    }
-
-    return pcp;
-}
-
-static void
-driDestroyContext(__DRIcontext *pcp)
-{
-    if (pcp) {
-       driDriverAPI.DestroyContext(pcp);
-       FREE(pcp);
-    }
-}
-
-static int
-driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask)
-{
-    return GL_FALSE;
-}
-
-static void dri_get_drawable(__DRIdrawable *pdp);
-static void dri_put_drawable(__DRIdrawable *pdp);
-
-static int driBindContext(__DRIcontext *pcp,
-                         __DRIdrawable *pdp,
-                         __DRIdrawable *prp)
-{
-    /* Bind the drawable to the context */
-    if (pcp) {
-       pcp->driDrawablePriv = pdp;
-       pcp->driReadablePriv = prp;
-       if (pdp) {
-           dri_get_drawable(pdp);
-       }
-       if ( prp && pdp != prp ) {
-           dri_get_drawable(prp);
-       }
-    }
-
-    return driDriverAPI.MakeCurrent(pcp, pdp, prp);
-}
-
-static int driUnbindContext(__DRIcontext *pcp)
-{
-    __DRIdrawable *pdp;
-    __DRIdrawable *prp;
-
-    if (pcp == NULL)
-       return GL_FALSE;
-
-    pdp = pcp->driDrawablePriv;
-    prp = pcp->driReadablePriv;
-
-    /* already unbound */
-    if (!pdp && !prp)
-       return GL_TRUE;
-
-    driDriverAPI.UnbindContext(pcp);
-
-    dri_put_drawable(pdp);
-
-    if (prp != pdp) {
-       dri_put_drawable(prp);
-    }
-
-    pcp->driDrawablePriv = NULL;
-    pcp->driReadablePriv = NULL;
-
-    return GL_TRUE;
-}
-
-
-/**
- * Drawable functions
- */
-
-static void dri_get_drawable(__DRIdrawable *pdp)
-{
-    pdp->refcount++;
-}
-
-static void dri_put_drawable(__DRIdrawable *pdp)
-{
-    if (pdp) {
-       pdp->refcount--;
-       if (pdp->refcount)
-           return;
-
-       driDriverAPI.DestroyBuffer(pdp);
-
-       FREE(pdp);
-    }
-}
-
-static __DRIdrawable *
-driCreateNewDrawable(__DRIscreen *psp,
-                    const __DRIconfig *config, void *data)
-{
-    __DRIdrawable *pdp;
-
-    pdp = CALLOC_STRUCT(__DRIdrawableRec);
-    if (!pdp)
-       return NULL;
-
-    pdp->loaderPrivate = data;
-
-    pdp->driScreenPriv = psp;
-
-    dri_get_drawable(pdp);
-
-    if (!driDriverAPI.CreateBuffer(psp, pdp, &config->modes, GL_FALSE)) {
-       FREE(pdp);
-       return NULL;
-    }
-
-    return pdp;
-}
-
-static void
-driDestroyDrawable(__DRIdrawable *pdp)
-{
-    dri_put_drawable(pdp);
-}
-
-static void driSwapBuffers(__DRIdrawable *pdp)
-{
-    driDriverAPI.SwapBuffers(pdp);
-}
-
-const __DRIcoreExtension driCoreExtension = {
-    { __DRI_CORE, __DRI_CORE_VERSION },
-    NULL, /* driCreateNewScreen */
-    driDestroyScreen,
-    driGetExtensions,
-    driGetConfigAttrib,
-    driIndexConfigAttrib,
-    NULL, /* driCreateNewDrawable */
-    driDestroyDrawable,
-    driSwapBuffers,
-    driCreateNewContext,
-    driCopyContext,
-    driDestroyContext,
-    driBindContext,
-    driUnbindContext
-};
-
-const __DRIswrastExtension driSWRastExtension = {
-    { __DRI_SWRAST, __DRI_SWRAST_VERSION },
-    driCreateNewScreen,
-    driCreateNewDrawable
-};
diff --git a/src/mesa/drivers/dri/common/dri_sw.h b/src/mesa/drivers/dri/common/dri_sw.h
deleted file mode 100644 (file)
index e353e26..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef _DRI_SW_H
-#define _DRI_SW_H
-
-#include <GL/gl.h>
-#include <GL/internal/glcore.h>
-#include <GL/internal/dri_interface.h>
-
-
-/**
- * Extensions
- */
-extern const __DRIcoreExtension driCoreExtension;
-extern const __DRIswrastExtension driSWRastExtension;
-
-
-/**
- * Data types
- */
-struct __DRIscreenRec {
-    int myNum;
-
-    int fd;
-
-    void *private;
-
-    const __DRIextension **extensions;
-
-    const __DRIswrastLoaderExtension *swrast_loader;
-};
-
-struct __DRIcontextRec {
-
-    void *driverPrivate;
-
-    void *loaderPrivate;
-
-    __DRIdrawable *driDrawablePriv;
-
-    __DRIdrawable *driReadablePriv;
-
-    __DRIscreen *driScreenPriv;
-};
-
-struct __DRIdrawableRec {
-
-    void *driverPrivate;
-
-    void *loaderPrivate;
-
-    __DRIscreen *driScreenPriv;
-
-    int refcount;
-};
-
-
-/**
- * Driver callback functions
- */
-struct __DriverAPIRec {
-    const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
-
-    void (*DestroyScreen)(__DRIscreen *driScrnPriv);
-
-    GLboolean (*CreateContext)(const __GLcontextModes *glVis,
-                               __DRIcontext *driContextPriv,
-                               void *sharedContextPrivate);
-
-    void (*DestroyContext)(__DRIcontext *driContextPriv);
-
-    GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
-                              __DRIdrawable *driDrawPriv,
-                              const __GLcontextModes *glVis,
-                              GLboolean pixmapBuffer);
-
-    void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
-
-    void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
-
-    GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
-                             __DRIdrawable *driDrawPriv,
-                             __DRIdrawable *driReadPriv);
-
-    GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
-};
-
-extern const struct __DriverAPIRec driDriverAPI;
-
-#endif /* _DRI_SW_H */
diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c
new file mode 100644 (file)
index 0000000..793f0c3
--- /dev/null
@@ -0,0 +1,89 @@
+#include "main/glheader.h"
+#include "main/compiler.h"
+#include "glapi/glapi.h"
+
+/* This is just supposed to make sure we get a reference to
+   the driver entry symbol that the compiler doesn't optimize away */
+
+extern char __driDriverExtensions[];
+
+/* provide glapi symbols */
+
+#if defined(GLX_USE_TLS)
+
+PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch
+    __attribute__((tls_model("initial-exec")));
+
+PUBLIC __thread void * _glapi_tls_Context
+    __attribute__((tls_model("initial-exec")));
+
+PUBLIC const struct _glapi_table *_glapi_Dispatch;
+PUBLIC const void *_glapi_Context;
+
+#else
+
+PUBLIC struct _glapi_table *_glapi_Dispatch;
+PUBLIC void *_glapi_Context;
+
+#endif
+
+PUBLIC void
+_glapi_check_multithread(void)
+{}
+
+PUBLIC void
+_glapi_set_context(void *context)
+{}
+
+PUBLIC void *
+_glapi_get_context(void)
+{
+       return 0;
+}
+
+PUBLIC void
+_glapi_set_dispatch(struct _glapi_table *dispatch)
+{}
+
+PUBLIC struct _glapi_table *
+_glapi_get_dispatch(void)
+{
+       return 0;
+}
+
+PUBLIC int
+_glapi_add_dispatch( const char * const * function_names,
+                    const char * parameter_signature )
+{
+       return 0;
+}
+
+PUBLIC GLint
+_glapi_get_proc_offset(const char *funcName)
+{
+       return 0;
+}
+
+PUBLIC _glapi_proc
+_glapi_get_proc_address(const char *funcName)
+{
+       return 0;
+}
+
+PUBLIC GLuint
+_glapi_get_dispatch_table_size(void)
+{
+       return 0;
+}
+
+PUBLIC unsigned long
+_glthread_GetID(void)
+{
+   return 0;
+}
+
+int main(int argc, char** argv)
+{
+   void* p = __driDriverExtensions;
+   return (int)(unsigned long)p;
+}
index badbb5ff824dd24082a232d53660dbae409730c0..f1bbd38612868381b49ba75dfdbaa547cc111ed8 100644 (file)
@@ -129,11 +129,6 @@ static int driUnbindContext(__DRIcontext *pcp)
      */
     pcp->driDrawablePriv = pcp->driReadablePriv = NULL;
 
-#if 0
-    /* Unbind the drawable */
-    pdp->driContextPriv = &psp->dummyContextPriv;
-#endif
-
     return GL_TRUE;
 }
 
@@ -433,7 +428,6 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
     pdp->vblFlags = 0;
 
     pdp->driScreenPriv = psp;
-    pdp->driContextPriv = &psp->dummyContextPriv;
 
     if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes,
                                        renderType == GLX_PIXMAP_BIT)) {
@@ -567,17 +561,6 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
     
     pcp->dri2.draw_stamp = 0;
     pcp->dri2.read_stamp = 0;
-    /* When the first context is created for a screen, initialize a "dummy"
-     * context.
-     */
-
-    if (!psp->dri2.enabled && !psp->dummyContextPriv.driScreenPriv) {
-        psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context;
-        psp->dummyContextPriv.driScreenPriv = psp;
-        psp->dummyContextPriv.driDrawablePriv = NULL;
-        psp->dummyContextPriv.driverPrivate = NULL;
-       /* No other fields should be used! */
-    }
 
     pcp->hHWContext = hwContext;
 
@@ -734,13 +717,6 @@ driCreateNewScreen(int scrn,
     psp->myNum = scrn;
     psp->dri2.enabled = GL_FALSE;
 
-    /*
-    ** Do not init dummy context here; actual initialization will be
-    ** done when the first DRI context is created.  Init screen priv ptr
-    ** to NULL to let CreateContext routine that it needs to be inited.
-    */
-    psp->dummyContextPriv.driScreenPriv = NULL;
-
     psp->DriverAPI = driDriverAPI;
 
     *driver_modes = driDriverAPI.InitScreen(psp);
index f63583cebc01256039731e98f3ec077197d3818e..038a81604fc3c3e675ebb0a68785bf98db212b45 100644 (file)
@@ -398,11 +398,6 @@ struct __DRIcontextRec {
      */
     void *driverPrivate;
 
-    /**
-     * Pointer back to the \c __DRIcontext that contains this structure.
-     */
-    __DRIcontext *pctx;
-
     /**
      * Pointer to drawable currently bound to this context for drawing.
      */
@@ -510,18 +505,6 @@ struct __DRIscreenRec {
     int devPrivSize;
     /*@}*/
 
-    /**
-     * Dummy context to which drawables are bound when not bound to any
-     * other context. 
-     *
-     * A dummy hHWContext is created for this context, and is used by the GL
-     * core when a hardware lock is required but the drawable is not currently
-     * bound (e.g., potentially during a SwapBuffers request).  The dummy
-     * context is created when the first "real" context is created on this
-     * screen.
-     */
-    __DRIcontext dummyContextPriv;
-
     /**
      * Device-dependent private information (not stored in the SAREA).
      * 
@@ -529,11 +512,6 @@ struct __DRIscreenRec {
      */
     void *private;
 
-    /**
-     * Pointer back to the \c __DRIscreen that contains this structure.
-     */
-    __DRIscreen *psc;
-
     /* Extensions provided by the loader. */
     const __DRIgetDrawableInfoExtension *getDrawableInfo;
     const __DRIsystemTimeExtension *systemTime;
diff --git a/src/mesa/drivers/dri/common/drisw_util.c b/src/mesa/drivers/dri/common/drisw_util.c
new file mode 100644 (file)
index 0000000..8d08b93
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 drisw_util.c
+ *
+ * DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits.
+ */
+
+#include "drisw_util.h"
+#include "utils.h"
+
+
+/**
+ * Screen functions
+ */
+
+static void
+setupLoaderExtensions(__DRIscreen *psp,
+                     const __DRIextension **extensions)
+{
+    int i;
+
+    for (i = 0; extensions[i]; i++) {
+       if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0)
+           psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
+    }
+}
+
+static __DRIscreen *
+driCreateNewScreen(int scrn, const __DRIextension **extensions,
+                  const __DRIconfig ***driver_configs, void *data)
+{
+    static const __DRIextension *emptyExtensionList[] = { NULL };
+    __DRIscreen *psp;
+
+    (void) data;
+
+    psp = CALLOC_STRUCT(__DRIscreenRec);
+    if (!psp)
+       return NULL;
+
+    setupLoaderExtensions(psp, extensions);
+
+    psp->extensions = emptyExtensionList;
+    psp->fd = -1;
+    psp->myNum = scrn;
+
+    *driver_configs = driDriverAPI.InitScreen(psp);
+
+    if (*driver_configs == NULL) {
+       FREE(psp);
+       return NULL;
+    }
+
+    return psp;
+}
+
+static void driDestroyScreen(__DRIscreen *psp)
+{
+    if (psp) {
+       driDriverAPI.DestroyScreen(psp);
+
+       FREE(psp);
+    }
+}
+
+static const __DRIextension **driGetExtensions(__DRIscreen *psp)
+{
+    return psp->extensions;
+}
+
+
+/**
+ * Context functions
+ */
+
+static __DRIcontext *
+driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
+                   __DRIcontext *shared, void *data)
+{
+    __DRIcontext *pcp;
+    void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
+
+    pcp = CALLOC_STRUCT(__DRIcontextRec);
+    if (!pcp)
+       return NULL;
+
+    pcp->loaderPrivate = data;
+
+    pcp->driScreenPriv = psp;
+    pcp->driDrawablePriv = NULL;
+    pcp->driReadablePriv = NULL;
+
+    if (!driDriverAPI.CreateContext(&config->modes, pcp, shareCtx)) {
+       FREE(pcp);
+       return NULL;
+    }
+
+    return pcp;
+}
+
+static void
+driDestroyContext(__DRIcontext *pcp)
+{
+    if (pcp) {
+       driDriverAPI.DestroyContext(pcp);
+       FREE(pcp);
+    }
+}
+
+static int
+driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask)
+{
+    return GL_FALSE;
+}
+
+static void dri_get_drawable(__DRIdrawable *pdp);
+static void dri_put_drawable(__DRIdrawable *pdp);
+
+static int driBindContext(__DRIcontext *pcp,
+                         __DRIdrawable *pdp,
+                         __DRIdrawable *prp)
+{
+    /* Bind the drawable to the context */
+    if (pcp) {
+       pcp->driDrawablePriv = pdp;
+       pcp->driReadablePriv = prp;
+       if (pdp) {
+           pdp->driContextPriv = pcp;
+           dri_get_drawable(pdp);
+       }
+       if ( prp && pdp != prp ) {
+           dri_get_drawable(prp);
+       }
+    }
+
+    return driDriverAPI.MakeCurrent(pcp, pdp, prp);
+}
+
+static int driUnbindContext(__DRIcontext *pcp)
+{
+    __DRIdrawable *pdp;
+    __DRIdrawable *prp;
+
+    if (pcp == NULL)
+       return GL_FALSE;
+
+    pdp = pcp->driDrawablePriv;
+    prp = pcp->driReadablePriv;
+
+    /* already unbound */
+    if (!pdp && !prp)
+       return GL_TRUE;
+
+    driDriverAPI.UnbindContext(pcp);
+
+    dri_put_drawable(pdp);
+
+    if (prp != pdp) {
+       dri_put_drawable(prp);
+    }
+
+    pcp->driDrawablePriv = NULL;
+    pcp->driReadablePriv = NULL;
+
+    return GL_TRUE;
+}
+
+
+/**
+ * Drawable functions
+ */
+
+static void dri_get_drawable(__DRIdrawable *pdp)
+{
+    pdp->refcount++;
+}
+
+static void dri_put_drawable(__DRIdrawable *pdp)
+{
+    if (pdp) {
+       pdp->refcount--;
+       if (pdp->refcount)
+           return;
+
+       driDriverAPI.DestroyBuffer(pdp);
+
+       FREE(pdp);
+    }
+}
+
+static __DRIdrawable *
+driCreateNewDrawable(__DRIscreen *psp,
+                    const __DRIconfig *config, void *data)
+{
+    __DRIdrawable *pdp;
+
+    pdp = CALLOC_STRUCT(__DRIdrawableRec);
+    if (!pdp)
+       return NULL;
+
+    pdp->loaderPrivate = data;
+
+    pdp->driScreenPriv = psp;
+    pdp->driContextPriv = NULL;
+
+    dri_get_drawable(pdp);
+
+    if (!driDriverAPI.CreateBuffer(psp, pdp, &config->modes, GL_FALSE)) {
+       FREE(pdp);
+       return NULL;
+    }
+
+    pdp->lastStamp = 1; /* const */
+
+    return pdp;
+}
+
+static void
+driDestroyDrawable(__DRIdrawable *pdp)
+{
+    dri_put_drawable(pdp);
+}
+
+static void driSwapBuffers(__DRIdrawable *pdp)
+{
+    driDriverAPI.SwapBuffers(pdp);
+}
+
+const __DRIcoreExtension driCoreExtension = {
+    { __DRI_CORE, __DRI_CORE_VERSION },
+    NULL, /* driCreateNewScreen */
+    driDestroyScreen,
+    driGetExtensions,
+    driGetConfigAttrib,
+    driIndexConfigAttrib,
+    NULL, /* driCreateNewDrawable */
+    driDestroyDrawable,
+    driSwapBuffers,
+    driCreateNewContext,
+    driCopyContext,
+    driDestroyContext,
+    driBindContext,
+    driUnbindContext
+};
+
+const __DRIswrastExtension driSWRastExtension = {
+    { __DRI_SWRAST, __DRI_SWRAST_VERSION },
+    driCreateNewScreen,
+    driCreateNewDrawable
+};
diff --git a/src/mesa/drivers/dri/common/drisw_util.h b/src/mesa/drivers/dri/common/drisw_util.h
new file mode 100644 (file)
index 0000000..08d5a11
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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
+ * Binding of the DRI interface (dri_interface.h) for DRISW.
+ *
+ * The DRISW structs are 'base classes' of the corresponding DRI1 / DRI2 (DRM)
+ * structs. The bindings for SW and DRM can be unified by making the DRM structs
+ * 'sub-classes' of the SW structs, either proper or with field re-ordering.
+ *
+ * The code can also be unified but that requires cluttering the common code
+ * with ifdef's and guarding with (__DRIscreen::fd >= 0) for DRM.
+ */
+
+#ifndef _DRISW_UTIL_H
+#define _DRISW_UTIL_H
+
+#include <GL/gl.h>
+#include <GL/internal/glcore.h>
+#include <GL/internal/dri_interface.h>
+typedef struct _drmLock drmLock;
+
+
+/**
+ * Extensions
+ */
+extern const __DRIcoreExtension driCoreExtension;
+extern const __DRIswrastExtension driSWRastExtension;
+
+
+/**
+ * Driver callback functions
+ */
+struct __DriverAPIRec {
+    const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
+
+    void (*DestroyScreen)(__DRIscreen *driScrnPriv);
+
+    GLboolean (*CreateContext)(const __GLcontextModes *glVis,
+                               __DRIcontext *driContextPriv,
+                               void *sharedContextPrivate);
+
+    void (*DestroyContext)(__DRIcontext *driContextPriv);
+
+    GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
+                              __DRIdrawable *driDrawPriv,
+                              const __GLcontextModes *glVis,
+                              GLboolean pixmapBuffer);
+
+    void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
+
+    void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
+
+    GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
+                             __DRIdrawable *driDrawPriv,
+                             __DRIdrawable *driReadPriv);
+
+    GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
+};
+
+extern const struct __DriverAPIRec driDriverAPI;
+
+
+/**
+ * Data types
+ */
+struct __DRIscreenRec {
+    int myNum;
+
+    int fd;
+
+    void *private;
+
+    const __DRIextension **extensions;
+
+    const __DRIswrastLoaderExtension *swrast_loader;
+};
+
+struct __DRIcontextRec {
+
+    void *driverPrivate;
+
+    void *loaderPrivate;
+
+    __DRIdrawable *driDrawablePriv;
+
+    __DRIdrawable *driReadablePriv;
+
+    __DRIscreen *driScreenPriv;
+};
+
+struct __DRIdrawableRec {
+
+    void *driverPrivate;
+
+    void *loaderPrivate;
+
+    __DRIcontext *driContextPriv;
+
+    __DRIscreen *driScreenPriv;
+
+    int refcount;
+
+    /* gallium */
+    unsigned int lastStamp;
+
+    int w;
+    int h;
+};
+
+#endif /* _DRISW_UTIL_H */
index e8f7e378ec7f2ce3509149730d109c005283e43d..a28073919cb07f66247ace46f6e5e803d747d377 100644 (file)
@@ -146,15 +146,15 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
    dri_bo_reference(intelObj->mt->region->buffer);
    i830->state.tex_buffer[unit] = intelObj->mt->region->buffer;
+   pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;
+
    /* XXX: This calculation is probably broken for tiled images with
     * a non-page-aligned offset.
     */
-   i830->state.tex_offset[unit] = (dst_x + dst_y * intelObj->mt->pitch) *
-      intelObj->mt->cpp;
+   i830->state.tex_offset[unit] = dst_x * intelObj->mt->cpp + dst_y * pitch;
 
    format = translate_texture_format(firstImage->TexFormat,
                                     firstImage->InternalFormat);
-   pitch = intelObj->mt->pitch * intelObj->mt->cpp;
 
    state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
                                (LOAD_TEXTURE_MAP0 << unit) | 4);
index 7275617a6fb98bdcca011b88c643fe8625c632d6..91b228d52b9e62a677970b3e9dc3747bc9b2f6f7 100644 (file)
@@ -374,7 +374,7 @@ intelCalcViewport(GLcontext * ctx)
    else {
       /* window buffer, y=0=top */
       yScale = -1.0;
-      yBias = (intel->driDrawable) ? intel->driDrawable->h : 0.0F;
+      yBias = ctx->DrawBuffer->Height;
    }
 
    m[MAT_SX] = v[MAT_SX];
index fe3908f580aa004f56835e927c0845b470bfcb72..702655283ba40d7c29d81ade782c9ab838048ae7 100644 (file)
@@ -123,13 +123,12 @@ i915_miptree_layout_cube(struct intel_context *intel,
    assert(lvlWidth == lvlHeight); /* cubemap images are square */
 
    /* double pitch for cube layouts */
-   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, dim * 2);
+   mt->total_width = dim * 2;
    mt->total_height = dim * 4;
 
    for (level = mt->first_level; level <= mt->last_level; level++) {
       intel_miptree_set_level_info(mt, level, 6,
                                   0, 0,
-                                  /*OLD: mt->pitch, mt->total_height,*/
                                   lvlWidth, lvlHeight,
                                   1);
       lvlWidth /= 2;
@@ -167,7 +166,7 @@ i915_miptree_layout_3d(struct intel_context *intel,
    GLint level;
 
    /* Calculate the size of a single slice. */
-   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0);
+   mt->total_width = mt->width0;
 
    /* XXX: hardware expects/requires 9 levels at minimum. */
    for (level = mt->first_level; level <= MAX2(8, mt->last_level); level++) {
@@ -210,7 +209,7 @@ i915_miptree_layout_2d(struct intel_context *intel,
    GLuint img_height;
    GLint level;
 
-   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0);
+   mt->total_width = mt->width0;
    mt->total_height = 0;
 
    for (level = mt->first_level; level <= mt->last_level; level++) {
@@ -251,9 +250,8 @@ i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt,
       break;
    }
 
-   DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
-       mt->pitch,
-       mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp);
+   DBG("%s: %dx%dx%d\n", __FUNCTION__,
+       mt->total_width, mt->total_height, mt->cpp);
 
    return GL_TRUE;
 }
@@ -336,9 +334,9 @@ i945_miptree_layout_cube(struct intel_context *intel,
     * or the final row of 4x4, 2x2 and 1x1 faces below this.
     */
    if (dim > 32)
-      mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, dim * 2);
+      mt->total_width = dim * 2;
    else
-      mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, 14 * 8);
+      mt->total_width = 14 * 8;
 
    if (dim >= 4)
       mt->total_height = dim * 4 + 4;
@@ -423,11 +421,11 @@ i945_miptree_layout_3d(struct intel_context *intel,
    GLuint pack_y_pitch;
    GLuint level;
 
-   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0);
+   mt->total_width = mt->width0;
    mt->total_height = 0;
 
    pack_y_pitch = MAX2(mt->height0, 2);
-   pack_x_pitch = mt->pitch;
+   pack_x_pitch = mt->total_width;
    pack_x_nr = 1;
 
    for (level = mt->first_level; level <= mt->last_level; level++) {
@@ -454,7 +452,7 @@ i945_miptree_layout_3d(struct intel_context *intel,
       if (pack_x_pitch > 4) {
         pack_x_pitch >>= 1;
         pack_x_nr <<= 1;
-        assert(pack_x_pitch * pack_x_nr <= mt->pitch);
+        assert(pack_x_pitch * pack_x_nr <= mt->total_width);
       }
 
       if (pack_y_pitch > 2) {
@@ -491,9 +489,8 @@ i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt,
       break;
    }
 
-   DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
-       mt->pitch,
-       mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp);
+   DBG("%s: %dx%dx%d\n", __FUNCTION__,
+       mt->total_width, mt->total_height, mt->cpp);
 
    return GL_TRUE;
 }
index a1ab8f8b6d2ac92e7b9f41f2262e651f3aa11e09..ff9ab88c5abe9d90aa13823fcc7a9badc4fdcd36 100644 (file)
@@ -165,7 +165,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    format = translate_texture_format(firstImage->TexFormat,
                                     firstImage->InternalFormat,
                                     tObj->DepthMode);
-   pitch = intelObj->mt->pitch * intelObj->mt->cpp;
+   pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;
 
    state[I915_TEXREG_MS3] =
       (((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) |
index fb191fe346f16e3842324adb94b3585e7268d833..9449a158dc6695273e587ba9aca49475afec5c70 100644 (file)
@@ -251,7 +251,7 @@ void intel_flush_prim(struct intel_context *intel)
       BEGIN_BATCH(5);
       OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
                I1_LOAD_S(0) | I1_LOAD_S(1) | 1);
-      assert((offset & !S0_VB_OFFSET_MASK) == 0);
+      assert((offset & ~S0_VB_OFFSET_MASK) == 0);
       OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, offset);
       OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) |
                (intel->vertex_size << S1_VERTEX_PITCH_SHIFT));
@@ -270,7 +270,7 @@ void intel_flush_prim(struct intel_context *intel)
       OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
                I1_LOAD_S(0) | I1_LOAD_S(2) | 1);
       /* S0 */
-      assert((offset & !S0_VB_OFFSET_MASK_830) == 0);
+      assert((offset & ~S0_VB_OFFSET_MASK_830) == 0);
       OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0,
                offset | (intel->vertex_size << S0_VB_PITCH_SHIFT_830) |
                S0_VB_ENABLE_830);
@@ -488,9 +488,9 @@ intel_wpos_triangle(struct intel_context *intel,
    __memcpy(v1_wpos, v1, size);
    __memcpy(v2_wpos, v2, size);
 
-   v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
-   v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h;
-   v2_wpos[1] = -v2_wpos[1] + intel->driDrawable->h;
+   v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height;
+   v1_wpos[1] = -v1_wpos[1] + intel->ctx.DrawBuffer->Height;
+   v2_wpos[1] = -v2_wpos[1] + intel->ctx.DrawBuffer->Height;
 
 
    intel_draw_triangle(intel, v0, v1, v2);
@@ -509,8 +509,8 @@ intel_wpos_line(struct intel_context *intel,
    __memcpy(v0_wpos, v0, size);
    __memcpy(v1_wpos, v1, size);
 
-   v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
-   v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h;
+   v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height;
+   v1_wpos[1] = -v1_wpos[1] + intel->ctx.DrawBuffer->Height;
 
    intel_draw_line(intel, v0, v1);
 }
@@ -524,7 +524,7 @@ intel_wpos_point(struct intel_context *intel, intelVertexPtr v0)
    GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
 
    __memcpy(v0_wpos, v0, size);
-   v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
+   v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height;
 
    intel_draw_point(intel, v0);
 }
index 984e56d00c8c0c6eaecb034438fb903e12a408f5..6fe574b22e2a7c7bd6202d7f1c69d3142de233e2 100644 (file)
 #define CMD_URB                                        0x7805 /* GEN6+ */
 # define GEN6_URB_VS_SIZE_SHIFT                                16
 # define GEN6_URB_VS_ENTRIES_SHIFT                     0
-# define GEN6_URB_GS_SIZE_SHIFT                                8
-# define GEN6_URB_GS_ENTRIES_SHIFT                     0
+# define GEN6_URB_GS_ENTRIES_SHIFT                     8
+# define GEN6_URB_GS_SIZE_SHIFT                                0
 
 #define CMD_VIEWPORT_STATE_POINTERS                    0x780d /* GEN6+ */
 # define GEN6_CC_VIEWPORT_MODIFY                       (1 << 12)
index ad61770212c631fe8e70bbbdf6fe81a8b5a7c721..db3fc50a63b5e4ca43220d44690746550550047a 100644 (file)
@@ -57,6 +57,7 @@ struct {
     [BRW_OPCODE_DPH] = { .name = "dph", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_DP3] = { .name = "dp3", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_DP2] = { .name = "dp2", .nsrc = 2, .ndst = 1 },
+    [BRW_OPCODE_MATH] = { .name = "math", .nsrc = 2, .ndst = 1 },
 
     [BRW_OPCODE_AVG] = { .name = "avg", .nsrc = 2, .ndst = 1 },
     [BRW_OPCODE_ADD] = { .name = "add", .nsrc = 2, .ndst = 1 },
@@ -797,7 +798,11 @@ int brw_disasm (FILE *file, struct brw_instruction *inst)
     err |= control (file, "saturate", saturate, inst->header.saturate, NULL);
     err |= control (file, "debug control", debug_ctrl, inst->header.debug_control, NULL);
 
-    if (inst->header.opcode != BRW_OPCODE_SEND)
+    if (inst->header.opcode == BRW_OPCODE_MATH) {
+       string (file, " ");
+       err |= control (file, "function", math_function,
+                       inst->header.destreg__conditionalmod, NULL);
+    } else if (inst->header.opcode != BRW_OPCODE_SEND)
        err |= control (file, "conditional modifier", conditional_modifier,
                        inst->header.destreg__conditionalmod, NULL);
 
index d2395dec288ab53624922fb644f879651a110aec..c33c3def30413bcccfafb4f29c62deb1afd0c044 100644 (file)
@@ -1416,7 +1416,10 @@ void brw_urb_WRITE(struct brw_compile *p,
     * and the first message register index comes from src0.
     */
    if (intel->gen >= 6) {
+      brw_push_insn_state(p);
+      brw_set_mask_control( p, BRW_MASK_DISABLE );
       brw_MOV(p, brw_message_reg(msg_reg_nr), src0);
+      brw_pop_insn_state(p);
       src0 = brw_message_reg(msg_reg_nr);
    }
 
index 09edfd81fde7e4679eda22058d572110fe06d077..b1f56a8e6488c179b5a6684f0a66e51fb4ac1317 100644 (file)
@@ -58,12 +58,12 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
           GLuint qpitch = 0;
           GLuint y_pitch = 0;
 
-          mt->pitch = mt->width0;
+          mt->total_width = mt->width0;
           intel_get_texture_alignment_unit(mt->internal_format, &align_w, &align_h);
           y_pitch = ALIGN(height, align_h);
 
           if (mt->compressed) {
-              mt->pitch = ALIGN(mt->width0, align_w);
+              mt->total_width = ALIGN(mt->width0, align_w);
           }
 
           if (mt->first_level != mt->last_level) {
@@ -77,13 +77,11 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
                       + minify(minify(mt->width0));
               }
 
-              if (mip1_width > mt->pitch) {
-                  mt->pitch = mip1_width;
+              if (mip1_width > mt->total_width) {
+                  mt->total_width = mip1_width;
               }
           }
 
-          mt->pitch = intel_miptree_pitch_align(intel, mt, tiling, mt->pitch);
-
           if (mt->compressed) {
               qpitch = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4;
               mt->total_height = (y_pitch + ALIGN(minify(y_pitch), align_h) + 11 * align_h) / 4 * 6;
@@ -137,10 +135,10 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
       intel_get_texture_alignment_unit(mt->internal_format, &align_w, &align_h);
 
       if (mt->compressed) {
-          mt->pitch = ALIGN(width, align_w);
+          mt->total_width = ALIGN(width, align_w);
           pack_y_pitch = (height + 3) / 4;
       } else {
-        mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->width0);
+        mt->total_width = mt->width0;
         pack_y_pitch = ALIGN(mt->height0, align_h);
       }
 
@@ -184,7 +182,7 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
            if (pack_x_pitch > 4) {
               pack_x_pitch >>= 1;
               pack_x_nr <<= 1;
-              assert(pack_x_pitch * pack_x_nr <= mt->pitch);
+              assert(pack_x_pitch * pack_x_nr <= mt->total_width);
            }
 
            if (pack_y_pitch > 2) {
@@ -211,11 +209,8 @@ GLboolean brw_miptree_layout(struct intel_context *intel,
       i945_miptree_layout_2d(intel, mt, tiling);
       break;
    }
-   DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
-               mt->pitch,
-               mt->total_height,
-               mt->cpp,
-               mt->pitch * mt->total_height * mt->cpp );
+   DBG("%s: %dx%dx%d\n", __FUNCTION__,
+       mt->total_width, mt->total_height, mt->cpp);
 
    return GL_TRUE;
 }
index d16e916832e7c95a592816fd33932a4725219cb0..227261409c431e5278eb38c0baa98b9de1584977 100644 (file)
@@ -384,8 +384,9 @@ static void emit_sop( struct brw_vs_compile *c,
 {
    struct brw_compile *p = &c->func;
 
-   brw_CMP(p, brw_null_reg(), cond, arg1, arg0);
-   brw_SEL(p, dst, brw_null_reg(), brw_imm_f(1.0f));
+   brw_MOV(p, dst, brw_imm_f(0.0f));
+   brw_CMP(p, brw_null_reg(), cond, arg0, arg1);
+   brw_MOV(p, dst, brw_imm_f(1.0f));
    brw_set_predicate_control_flag_value(p, 0xff);
 }
 
@@ -1360,31 +1361,6 @@ static void emit_vertex_write( struct brw_vs_compile *c)
    }
 }
 
-
-/**
- * Called after code generation to resolve subroutine calls and the
- * END instruction.
- * \param end_inst  points to brw code for END instruction
- * \param last_inst  points to last instruction emitted before vertex write
- */
-static void 
-post_vs_emit( struct brw_vs_compile *c,
-              struct brw_instruction *end_inst,
-              struct brw_instruction *last_inst )
-{
-   GLint offset;
-
-   brw_resolve_cals(&c->func);
-
-   /* patch up the END code to jump past subroutines, etc */
-   offset = last_inst - end_inst;
-   if (offset > 1) {
-      brw_set_src1(end_inst, brw_imm_d(offset * 16));
-   } else {
-      end_inst->header.opcode = BRW_OPCODE_NOP;
-   }
-}
-
 static GLboolean
 accumulator_contains(struct brw_vs_compile *c, struct brw_reg val)
 {
@@ -1465,8 +1441,6 @@ void brw_vs_emit(struct brw_vs_compile *c )
    struct intel_context *intel = &brw->intel;
    const GLuint nr_insns = c->vp->program.Base.NumInstructions;
    GLuint insn, if_depth = 0, loop_depth = 0;
-   GLuint end_offset = 0;
-   struct brw_instruction *end_inst, *last_inst;
    struct brw_instruction *if_inst[MAX_IF_DEPTH], *loop_inst[MAX_LOOP_DEPTH] = { 0 };
    const struct brw_indirect stack_index = brw_indirect(0, 0);   
    GLuint index;
@@ -1750,12 +1724,8 @@ void brw_vs_emit(struct brw_vs_compile *c )
          brw_MOV(p, brw_ip_reg(), deref_1d(stack_index, 0));
         brw_set_access_mode(p, BRW_ALIGN_16);
         break;
-      case OPCODE_END: 
-         end_offset = p->nr_insn;
-         /* this instruction will get patched later to jump past subroutine
-          * code, etc.
-          */
-         brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+      case OPCODE_END:
+        emit_vertex_write(c);
          break;
       case OPCODE_PRINT:
          /* no-op */
@@ -1816,13 +1786,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
       release_tmps(c);
    }
 
-   end_inst = &p->store[end_offset];
-   last_inst = &p->store[p->nr_insn];
-
-   /* The END instruction will be patched to jump to this code */
-   emit_vertex_write(c);
-
-   post_vs_emit(c, end_inst, last_inst);
+   brw_resolve_cals(p);
 
    brw_optimize(p);
 
index 47b764d24d1b67d4c4abff40673e8ecb757ca219..5aade1c4e690e0fe22cfe5cbff45b2790b108573 100644 (file)
@@ -286,7 +286,7 @@ void brw_wm_pass0( struct brw_wm_compile *c );
 void brw_wm_pass1( struct brw_wm_compile *c );
 void brw_wm_pass2( struct brw_wm_compile *c );
 void brw_wm_emit( struct brw_wm_compile *c );
-
+GLboolean brw_wm_arg_can_be_immediate(enum prog_opcode, int arg);
 void brw_wm_print_value( struct brw_wm_compile *c,
                         struct brw_wm_value *value );
 
index 05e464d4b61726693af09a639dba25487234af26..f79de5dbffc8c62c58aeb93220efbdd2c588e2ce 100644 (file)
@@ -61,6 +61,44 @@ static INLINE struct brw_reg sechalf( struct brw_reg reg )
    return reg;
 }
 
+/* Return the SrcReg index of the channels that can be immediate float operands
+ * instead of usage of PROGRAM_CONSTANT values through push/pull.
+ */
+GLboolean
+brw_wm_arg_can_be_immediate(enum prog_opcode opcode, int arg)
+{
+   int opcode_array[] = {
+      [OPCODE_ADD] = 2,
+      [OPCODE_CMP] = 3,
+      [OPCODE_DP3] = 2,
+      [OPCODE_DP4] = 2,
+      [OPCODE_DPH] = 2,
+      [OPCODE_MAX] = 2,
+      [OPCODE_MIN] = 2,
+      [OPCODE_MOV] = 1,
+      [OPCODE_MUL] = 2,
+      [OPCODE_SEQ] = 2,
+      [OPCODE_SGE] = 2,
+      [OPCODE_SGT] = 2,
+      [OPCODE_SLE] = 2,
+      [OPCODE_SLT] = 2,
+      [OPCODE_SNE] = 2,
+      [OPCODE_XPD] = 2,
+   };
+
+   /* These opcodes get broken down in a way that allow two
+    * args to be immediates.
+    */
+   if (opcode == OPCODE_MAD || opcode == OPCODE_LRP) {
+      if (arg == 1 || arg == 2)
+        return GL_TRUE;
+   }
+
+   if (opcode > ARRAY_SIZE(opcode_array))
+      return GL_FALSE;
+
+   return arg == opcode_array[opcode] - 1;
+}
 
 /**
  * Computes the screen-space x,y position of the pixels.
@@ -545,8 +583,11 @@ void emit_sop(struct brw_compile *p,
    for (i = 0; i < 4; i++) {
       if (mask & (1<<i)) {     
         brw_push_insn_state(p);
-        brw_CMP(p, brw_null_reg(), cond, arg1[i], arg0[i]);
-        brw_SEL(p, dst[i], brw_null_reg(), brw_imm_f(1.0));
+        brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]);
+        brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+        brw_MOV(p, dst[i], brw_imm_f(0));
+        brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+        brw_MOV(p, dst[i], brw_imm_f(1.0));
         brw_pop_insn_state(p);
       }
    }
@@ -617,14 +658,10 @@ void emit_cmp(struct brw_compile *p,
 
    for (i = 0; i < 4; i++) {
       if (mask & (1<<i)) {     
-        brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
-        brw_MOV(p, dst[i], arg2[i]);
-        brw_set_saturate(p, 0);
-
         brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0[i], brw_imm_f(0));
 
         brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
-        brw_MOV(p, dst[i], arg1[i]);
+        brw_SEL(p, dst[i], arg1[i], arg2[i]);
         brw_set_saturate(p, 0);
         brw_set_predicate_control_flag_value(p, 0xff);
       }
index 0b66cc6c9f3ea34848563e35d5df1739044bc4ab..3b7e421b16ad7a5fedbee389d3076ce6936b1eb7 100644 (file)
@@ -23,6 +23,9 @@ GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp)
 {
     int i;
 
+    if (INTEL_DEBUG & DEBUG_GLSL_FORCE)
+       return GL_TRUE;
+
     for (i = 0; i < fp->Base.NumInstructions; i++) {
        const struct prog_instruction *inst = &fp->Base.Instructions[i];
        switch (inst->Opcode) {
@@ -567,12 +570,35 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c,
     const GLuint nr = 1;
     const GLuint component = GET_SWZ(src->Swizzle, channel);
 
-    /* Extended swizzle terms */
-    if (component == SWIZZLE_ZERO) {
-       return brw_imm_f(0.0F);
-    }
-    else if (component == SWIZZLE_ONE) {
-       return brw_imm_f(1.0F);
+    /* Only one immediate value can be used per native opcode, and it
+     * has be in the src1 slot, so not all Mesa instructions will get
+     * to take advantage of immediate constants.
+     */
+    if (brw_wm_arg_can_be_immediate(inst->Opcode, srcRegIndex)) {
+       const struct gl_program_parameter_list *params;
+
+       params = c->fp->program.Base.Parameters;
+
+       /* Extended swizzle terms */
+       if (component == SWIZZLE_ZERO) {
+         return brw_imm_f(0.0F);
+       } else if (component == SWIZZLE_ONE) {
+         if (src->Negate)
+            return brw_imm_f(-1.0F);
+         else
+            return brw_imm_f(1.0F);
+       }
+
+       if (src->File == PROGRAM_CONSTANT) {
+         float f = params->ParameterValues[src->Index][component];
+
+         if (src->Abs)
+            f = fabs(f);
+         if (src->Negate)
+            f = -f;
+
+         return brw_imm_f(f);
+       }
     }
 
     if (c->fp->use_const_buffer &&
index ce0bf0b97d24af30d44a98c1bfe52d64a11c1aeb..6b9e5668862336664fd335018aada20f90177576 100644 (file)
@@ -261,7 +261,7 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit )
 
    key.format = firstImage->TexFormat;
    key.internal_format = firstImage->InternalFormat;
-   key.pitch = intelObj->mt->pitch;
+   key.pitch = intelObj->mt->region->pitch;
    key.depth = firstImage->Depth;
    key.bo = intelObj->mt->region->buffer;
    key.offset = 0;
index 06f8145e32dae20b4e8bb7bdc96e1af5dbedefdb..acc4b7f1019130814826b166c3ee5ac50d15822b 100644 (file)
@@ -55,7 +55,7 @@ upload_clip_state(struct brw_context *brw)
    OUT_BATCH(GEN6_CLIP_STATISTICS_ENABLE);
    OUT_BATCH(GEN6_CLIP_ENABLE |
             GEN6_CLIP_API_OGL |
-            GEN6_CLIP_MODE_REJECT_ALL | /* XXX: debug: get VS working */
+            GEN6_CLIP_MODE_NORMAL |
             GEN6_CLIP_XY_TEST |
             depth_clamp |
             provoking);
index 161e7b85c289c1335458741d6527ae72bf18c349..cefc93ba48b13fed9482231f98cd5c8b3ed9b86c 100644 (file)
@@ -50,7 +50,8 @@ upload_gs_state(struct brw_context *brw)
       BEGIN_BATCH(7);
       OUT_BATCH(CMD_3D_GS_STATE << 16 | (7 - 2));
       OUT_RELOC(brw->gs.prog_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
-      OUT_BATCH((0 << GEN6_GS_SAMPLER_COUNT_SHIFT) |
+      OUT_BATCH(GEN6_GS_SPF_MODE |
+               (0 << GEN6_GS_SAMPLER_COUNT_SHIFT) |
                (0 << GEN6_GS_BINDING_TABLE_ENTRY_COUNT_SHIFT));
       OUT_BATCH(0); /* scratch space base offset */
       OUT_BATCH((1 << GEN6_GS_DISPATCH_START_GRF_SHIFT) |
index fe597dfb945f38458ce4efc82d09f7373fe1bf08..5916a139946f9ab8350b683ce0ba6c6898968fa2 100644 (file)
@@ -100,7 +100,8 @@ upload_vs_state(struct brw_context *brw)
             (brw->vs.prog_data->urb_read_length << GEN6_VS_URB_READ_LENGTH_SHIFT) |
             (0 << GEN6_VS_URB_ENTRY_READ_OFFSET_SHIFT));
    OUT_BATCH((0 << GEN6_VS_MAX_THREADS_SHIFT) |
-            GEN6_VS_STATISTICS_ENABLE);
+            GEN6_VS_STATISTICS_ENABLE |
+            GEN6_VS_ENABLE);
    ADVANCE_BATCH();
 
    intel_batchbuffer_emit_mi_flush(intel->batch);
index f2769aa3e8cc4ec7a6044a1091156b8d0a292115..167140d274a37b94f0578f558a6af4e8dba701da 100644 (file)
@@ -119,24 +119,8 @@ intelEmitCopyBlit(struct intel_context *intel,
            break;
    } while (pass < 2);
 
-   intel_prepare_render(intel);
-
-   if (pass >= 2) {
-      drm_intel_gem_bo_map_gtt(dst_buffer);
-      drm_intel_gem_bo_map_gtt(src_buffer);
-      _mesa_copy_rect((GLubyte *)dst_buffer->virtual + dst_offset,
-                     cpp,
-                     dst_pitch,
-                     dst_x, dst_y,
-                     w, h,
-                     (GLubyte *)src_buffer->virtual + src_offset,
-                     src_pitch,
-                     src_x, src_y);
-      drm_intel_gem_bo_unmap_gtt(src_buffer);
-      drm_intel_gem_bo_unmap_gtt(dst_buffer);
-
-      return GL_TRUE;
-   }
+   if (pass >= 2)
+      return GL_FALSE;
 
    intel_batchbuffer_require_space(intel->batch, 8 * 4);
    DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
@@ -482,6 +466,7 @@ intel_emit_linear_blit(struct intel_context *intel,
                       unsigned int size)
 {
    GLuint pitch, height;
+   GLboolean ok;
 
    /* Blits are in a different ringbuffer so we don't use them. */
    assert(intel->gen < 6);
@@ -489,25 +474,27 @@ intel_emit_linear_blit(struct intel_context *intel,
    /* The pitch is a signed value. */
    pitch = MIN2(size, (1 << 15) - 1);
    height = size / pitch;
-   intelEmitCopyBlit(intel, 1,
-                    pitch, src_bo, src_offset, I915_TILING_NONE,
-                    pitch, dst_bo, dst_offset, I915_TILING_NONE,
-                    0, 0, /* src x/y */
-                    0, 0, /* dst x/y */
-                    pitch, height, /* w, h */
-                    GL_COPY);
+   ok = intelEmitCopyBlit(intel, 1,
+                         pitch, src_bo, src_offset, I915_TILING_NONE,
+                         pitch, dst_bo, dst_offset, I915_TILING_NONE,
+                         0, 0, /* src x/y */
+                         0, 0, /* dst x/y */
+                         pitch, height, /* w, h */
+                         GL_COPY);
+   assert(ok);
 
    src_offset += pitch * height;
    dst_offset += pitch * height;
    size -= pitch * height;
    assert (size < (1 << 15));
    if (size != 0) {
-      intelEmitCopyBlit(intel, 1,
-                       size, src_bo, src_offset, I915_TILING_NONE,
-                       size, dst_bo, dst_offset, I915_TILING_NONE,
-                       0, 0, /* src x/y */
-                       0, 0, /* dst x/y */
-                       size, 1, /* w, h */
-                       GL_COPY);
+      ok = intelEmitCopyBlit(intel, 1,
+                            size, src_bo, src_offset, I915_TILING_NONE,
+                            size, dst_bo, dst_offset, I915_TILING_NONE,
+                            0, 0, /* src x/y */
+                            0, 0, /* dst x/y */
+                            size, 1, /* w, h */
+                            GL_COPY);
+      assert(ok);
    }
 }
index b10693050a9485c314af6e86195a17bb66db4911..0480770ba1d4b077dcfb177eb1556f711f606479 100644 (file)
@@ -226,7 +226,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
        * only changes with _NEW_STENCIL (which seems sensible).  So flag it
        * here since this is the _NEW_BUFFERS path.
        */
-      ctx->NewState |= (_NEW_DEPTH | _NEW_STENCIL);
+      intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL);
    }
 
    intel->vtbl.set_draw_region(intel, colorRegions, depthRegion, 
@@ -236,7 +236,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
 #ifdef I915
    intelCalcViewport(ctx);
 #else
-   ctx->NewState |= _NEW_VIEWPORT;
+   intel->NewGLState |= _NEW_VIEWPORT;
 #endif
    /* Set state we know depends on drawable parameters:
     */
@@ -256,7 +256,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
    if (ctx->Driver.FrontFace)
       ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
    else
-      ctx->NewState |= _NEW_POLYGON;
+      intel->NewGLState |= _NEW_POLYGON;
 }
 
 
index d6a1ba69524f0c7f1f1171deb16e0258d9b1b0b0..9077a611328e75c6fb003d37b1b9d410e4ed2290 100644 (file)
@@ -63,7 +63,7 @@ int INTEL_DEBUG = (0);
 #endif
 
 
-#define DRIVER_DATE                     "20091221 DEVELOPMENT"
+#define DRIVER_DATE                     "20100330 DEVELOPMENT"
 #define DRIVER_DATE_GEM                 "GEM " DRIVER_DATE
 
 
@@ -389,7 +389,7 @@ intel_prepare_render(struct intel_context *intel)
    __DRIcontext *driContext = intel->driContext;
    __DRIdrawable *drawable;
 
-   drawable = intel->driDrawable;
+   drawable = driContext->driDrawablePriv;
    if (drawable->dri2.stamp != driContext->dri2.draw_stamp) {
       if (drawable->lastStamp != drawable->dri2.stamp)
         intel_update_renderbuffers(driContext, drawable);
@@ -397,7 +397,7 @@ intel_prepare_render(struct intel_context *intel)
       driContext->dri2.draw_stamp = drawable->dri2.stamp;
    }
 
-   drawable = intel->driReadDrawable;
+   drawable = driContext->driReadablePriv;
    if (drawable->dri2.stamp != driContext->dri2.read_stamp) {
       if (drawable->lastStamp != drawable->dri2.stamp)
         intel_update_renderbuffers(driContext, drawable);
@@ -444,6 +444,7 @@ static const struct dri_debug_control debug_control[] = {
    { "sing",  DEBUG_SINGLE_THREAD },
    { "thre",  DEBUG_SINGLE_THREAD },
    { "wm",    DEBUG_WM },
+   { "glsl_force", DEBUG_GLSL_FORCE },
    { "urb",   DEBUG_URB },
    { "vs",    DEBUG_VS },
    { NULL,    0 }
@@ -471,6 +472,7 @@ void
 intel_flush(GLcontext *ctx, GLboolean needs_mi_flush)
 {
    struct intel_context *intel = intel_context(ctx);
+    __DRIcontext *driContext = intel->driContext;
 
    if (intel->Fallback)
       _swrast_flush(ctx);
@@ -487,9 +489,10 @@ intel_flush(GLcontext *ctx, GLboolean needs_mi_flush)
       if (screen->dri2.loader &&
           (screen->dri2.loader->base.version >= 2)
          && (screen->dri2.loader->flushFrontBuffer != NULL) &&
-          intel->driDrawable && intel->driDrawable->loaderPrivate) {
-        (*screen->dri2.loader->flushFrontBuffer)(intel->driDrawable,
-                                                 intel->driDrawable->loaderPrivate);
+          driContext->driDrawablePriv &&
+         driContext->driDrawablePriv->loaderPrivate) {
+        (*screen->dri2.loader->flushFrontBuffer)(driContext->driDrawablePriv,
+                                                 driContext->driDrawablePriv->loaderPrivate);
 
         /* Only clear the dirty bit if front-buffer rendering is no longer
          * enabled.  This is done so that the dirty bit can only be set in
@@ -606,7 +609,6 @@ intelInitContext(struct intel_context *intel,
 
    driContextPriv->driverPrivate = intel;
    intel->intelScreen = intelScreen;
-   intel->driScreen = sPriv;
    intel->driContext = driContextPriv;
    intel->driFd = sPriv->fd;
 
@@ -635,8 +637,7 @@ intelInitContext(struct intel_context *intel,
    }
 
    driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
-                       intel->driScreen->myNum,
-                      (intel->gen >= 4) ? "i965" : "i915");
+                       sPriv->myNum, (intel->gen >= 4) ? "i965" : "i915");
    if (intelScreen->deviceID == PCI_CHIP_I865_G)
       intel->maxBatchSize = 4096;
    else
@@ -844,14 +845,6 @@ intelDestroyContext(__DRIcontext * driContextPriv)
 GLboolean
 intelUnbindContext(__DRIcontext * driContextPriv)
 {
-   struct intel_context *intel =
-      (struct intel_context *) driContextPriv->driverPrivate;
-
-   /* Deassociate the context with the drawables.
-    */
-   intel->driDrawable = NULL;
-   intel->driReadDrawable = NULL;
-
    return GL_TRUE;
 }
 
@@ -880,12 +873,10 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
       struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
       struct gl_framebuffer *readFb = driReadPriv->driverPrivate;
 
-      _mesa_make_current(&intel->ctx, fb, readFb);
-      intel->driReadDrawable = driReadPriv;
-      intel->driDrawable = driDrawPriv;
       driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
       driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
       intel_prepare_render(intel);
+      _mesa_make_current(&intel->ctx, fb, readFb);
    }
    else {
       _mesa_make_current(NULL, NULL, NULL);
index 22736a93279b07e609d66e23bed30253745ac8ac..c4bb2bed8e0a72cbba4c58be4280f8e95875309c 100644 (file)
@@ -243,9 +243,6 @@ struct intel_context
    int driFd;
 
    __DRIcontext *driContext;
-   __DRIdrawable *driDrawable;
-   __DRIdrawable *driReadDrawable;
-   __DRIscreen *driScreen;
    struct intel_screen *intelScreen;
 
    /**
@@ -342,6 +339,7 @@ extern int INTEL_DEBUG;
 #define DEBUG_WM        0x800000
 #define DEBUG_URB       0x1000000
 #define DEBUG_VS        0x2000000
+#define DEBUG_GLSL_FORCE 0x4000000
 
 #define DBG(...) do {                                          \
        if (INTEL_DEBUG & FILE_DEBUG_FLAG)                      \
index a429f8d003dfa94c0adc3679b95da9b646efc0d7..8278d12bb9002543a998988ea5201cfcd4cb86e4 100644 (file)
@@ -104,7 +104,6 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    struct intel_context *intel = intel_context(ctx);
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
    int cpp;
-   GLuint pitch;
 
    ASSERT(rb->Name != 0);
 
@@ -176,15 +175,11 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 
    /* allocate new memory region/renderbuffer */
 
-   /* Choose a pitch to match hardware requirements:
-    */
-   pitch = ((cpp * width + 63) & ~63) / cpp;
-
    /* alloc hardware renderbuffer */
-   DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width, height, pitch);
+   DBG("Allocating %d x %d Intel RBO\n", width, height);
 
    irb->region = intel_region_alloc(intel, I915_TILING_NONE, cpp,
-                                   width, height, pitch, GL_TRUE);
+                                   width, height, GL_TRUE);
    if (!irb->region)
       return GL_FALSE;       /* out of memory? */
 
@@ -573,7 +568,7 @@ intel_render_texture(GLcontext * ctx,
                                  att->Zoffset,
                                  &dst_x, &dst_y);
 
-   intel_image->mt->region->draw_offset = (dst_y * intel_image->mt->pitch +
+   intel_image->mt->region->draw_offset = (dst_y * intel_image->mt->region->pitch +
                                           dst_x) * intel_image->mt->cpp;
    intel_image->mt->region->draw_x = dst_x;
    intel_image->mt->region->draw_y = dst_y;
index 4f14946ec729df39af59a76be4776ac0fb4288b1..ef1966ea7e14c0136e87a1ec3bb59df08b38d7e0 100644 (file)
@@ -83,7 +83,6 @@ intel_miptree_create_internal(struct intel_context *intel,
    mt->cpp = compress_byte ? compress_byte : cpp;
    mt->compressed = compress_byte ? 1 : 0;
    mt->refcount = 1; 
-   mt->pitch = 0;
 
 #ifdef I915
    if (intel->is_945)
@@ -136,7 +135,7 @@ intel_miptree_create(struct intel_context *intel,
    /*
     * pitch == 0 || height == 0  indicates the null texture
     */
-   if (!mt || !mt->pitch || !mt->total_height) {
+   if (!mt || !mt->total_height) {
       free(mt);
       return NULL;
    }
@@ -144,9 +143,8 @@ intel_miptree_create(struct intel_context *intel,
    mt->region = intel_region_alloc(intel,
                                   tiling,
                                   mt->cpp,
-                                  mt->pitch,
+                                  mt->total_width,
                                   mt->total_height,
-                                  mt->pitch,
                                   expect_accelerated_upload);
 
    if (!mt->region) {
@@ -177,81 +175,12 @@ intel_miptree_create_for_region(struct intel_context *intel,
                                      I915_TILING_NONE);
    if (!mt)
       return mt;
-#if 0
-   if (mt->pitch != region->pitch) {
-      fprintf(stderr,
-             "region pitch (%d) doesn't match mipmap tree pitch (%d)\n",
-             region->pitch, mt->pitch);
-      free(mt);
-      return NULL;
-   }
-#else
-   /* The mipmap tree pitch is aligned to 64 bytes to make sure render
-    * to texture works, but we don't need that for texturing from a
-    * pixmap.  Just override it here. */
-   mt->pitch = region->pitch;
-#endif
 
    intel_region_reference(&mt->region, region);
 
    return mt;
 }
 
-
-/**
- * intel_miptree_pitch_align:
- *
- * @intel: intel context pointer
- *
- * @mt: the miptree to compute pitch alignment for
- *
- * @pitch: the natural pitch value
- *
- * Given @pitch, compute a larger value which accounts for
- * any necessary alignment required by the device
- */
-int intel_miptree_pitch_align (struct intel_context *intel,
-                              struct intel_mipmap_tree *mt,
-                              uint32_t tiling,
-                              int pitch)
-{
-#ifdef I915
-   GLcontext *ctx = &intel->ctx;
-#endif
-
-   if (!mt->compressed) {
-      int pitch_align;
-
-      /* XXX: Align pitch to multiple of 64 bytes for now to allow
-       * render-to-texture to work in all cases. This should probably be
-       * replaced at some point by some scheme to only do this when really
-       * necessary.
-       */
-      pitch_align = 64;
-
-      if (tiling == I915_TILING_X)
-        pitch_align = 512;
-      else if (tiling == I915_TILING_Y)
-        pitch_align = 128;
-
-      pitch = ALIGN(pitch * mt->cpp, pitch_align);
-
-#ifdef I915
-      /* Do a little adjustment to linear allocations so that we avoid
-       * hitting the same channel of memory for 2 different pages when
-       * reading a 2x2 subspan or doing bilinear filtering.
-       */
-      if (tiling == I915_TILING_NONE && !(pitch & 511) &&
-        (pitch + pitch_align) < (1 << ctx->Const.MaxTextureLevels))
-        pitch += pitch_align;
-#endif
-
-      pitch /= mt->cpp;
-   }
-   return pitch;
-}
-
-
 void
 intel_miptree_reference(struct intel_mipmap_tree **dst,
                         struct intel_mipmap_tree *src)
@@ -351,13 +280,12 @@ intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
    mt->level[level].width = w;
    mt->level[level].height = h;
    mt->level[level].depth = d;
-   mt->level[level].level_offset = (x + y * mt->pitch) * mt->cpp;
    mt->level[level].level_x = x;
    mt->level[level].level_y = y;
    mt->level[level].nr_images = nr_images;
 
-   DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
-       level, w, h, d, x, y, mt->level[level].level_offset);
+   DBG("%s level %d size: %d,%d,%d offset %d,%d\n", __FUNCTION__,
+       level, w, h, d, x, y);
 
    assert(nr_images);
    assert(!mt->level[level].x_offset);
@@ -424,7 +352,7 @@ intel_miptree_image_map(struct intel_context * intel,
    DBG("%s \n", __FUNCTION__);
 
    if (row_stride)
-      *row_stride = mt->pitch * mt->cpp;
+      *row_stride = mt->region->pitch * mt->cpp;
 
    if (mt->target == GL_TEXTURE_3D) {
       int i;
@@ -433,7 +361,7 @@ intel_miptree_image_map(struct intel_context * intel,
 
         intel_miptree_get_image_offset(mt, level, face, i,
                                        &x, &y);
-        image_offsets[i] = x + y * mt->pitch;
+        image_offsets[i] = x + y * mt->region->pitch;
       }
 
       return intel_region_map(intel, mt->region);
@@ -444,7 +372,7 @@ intel_miptree_image_map(struct intel_context * intel,
       image_offsets[0] = 0;
 
       return intel_region_map(intel, mt->region) +
-        (x + y * mt->pitch) * mt->cpp;
+        (x + y * mt->region->pitch) * mt->cpp;
    }
 }
 
@@ -520,12 +448,15 @@ intel_miptree_image_copy(struct intel_context *intel,
        width = ALIGN(width, align_w);
    }
 
+   intel_prepare_render(intel);
+
    for (i = 0; i < depth; i++) {
       intel_miptree_get_image_offset(src, level, face, i, &src_x, &src_y);
       intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y);
       success = intel_region_copy(intel,
                                  dst->region, 0, dst_x, dst_y,
-                                 src->region, 0, src_x, src_y, width, height,
+                                 src->region, 0, src_x, src_y,
+                                 width, height, GL_FALSE,
                                  GL_COPY);
       if (!success) {
         GLubyte *src_ptr, *dst_ptr;
@@ -533,13 +464,13 @@ intel_miptree_image_copy(struct intel_context *intel,
         src_ptr = intel_region_map(intel, src->region);
         dst_ptr = intel_region_map(intel, dst->region);
 
-        _mesa_copy_rect(dst_ptr + dst->cpp * (dst_x + dst_y * dst->pitch),
+        _mesa_copy_rect(dst_ptr,
                         dst->cpp,
-                        dst->pitch,
-                        0, 0, width, height,
-                        src_ptr + src->cpp * (src_x + src_y * src->pitch),
-                        src->pitch,
-                        0, 0);
+                        dst->region->pitch,
+                        dst_x, dst_y, width, height,
+                        src_ptr,
+                        src->region->pitch,
+                        src_x, src_y);
         intel_region_unmap(intel, src->region);
         intel_region_unmap(intel, dst->region);
       }
index b19c548def344989cfbea6bf9fef77fdd77ff986..21db2f4d3b3c191a028cf6536491b5e72d9c2316 100644 (file)
  */
 struct intel_mipmap_level
 {
-   /**
-    * Byte offset to the base of this level.
-    *
-    * This is used for mipmap levels of 1D/2D/3D textures.  However, CUBE
-    * layouts spread images around the whole tree, so the level offset is
-    * always zero in that case.
-    */
-   GLuint level_offset;
    /** Offset to this miptree level, used in computing x_offset. */
    GLuint level_x;
    /** Offset to this miptree level, used in computing y_offset. */
@@ -81,8 +73,8 @@ struct intel_mipmap_level
    /** Number of images at this level: 1 for 1D/2D, 6 for CUBE, depth for 3D */
    GLuint nr_images;
 
-   /**
-    * Byte offset from level_offset to the image for each cube face or depth
+   /** @{
+    * offsets from level_[xy] to the image for each cube face or depth
     * level.
     *
     * Pretty much have to accept that hardware formats
@@ -91,6 +83,7 @@ struct intel_mipmap_level
     * so have to store them as a lookup table.
     */
    GLuint *x_offset, *y_offset;
+   /** @} */
 };
 
 struct intel_mipmap_tree
@@ -109,8 +102,7 @@ struct intel_mipmap_tree
 
    /* Derived from the above:
     */
-   GLuint pitch;
-   GLuint depth_pitch;          /* per-image on i945? */
+   GLuint total_width;
    GLuint total_height;
 
    /* Includes image offset tables:
index f4f3fd6d889e9008dc0ede03f8d57c3342246c4b..56faf076c7e9d26d83cd9bf15486699657f713a6 100644 (file)
@@ -108,14 +108,15 @@ do_blit_copypixels(GLcontext * ctx,
                    GLint dstx, GLint dsty, GLenum type)
 {
    struct intel_context *intel = intel_context(ctx);
-   struct intel_region *dst = intel_drawbuf_region(intel);
-   struct intel_region *src = copypix_src_region(intel, type);
+   struct intel_region *dst;
+   struct intel_region *src;
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    struct gl_framebuffer *read_fb = ctx->ReadBuffer;
    GLint orig_dstx;
    GLint orig_dsty;
    GLint orig_srcx;
    GLint orig_srcy;
+   GLboolean flip = GL_FALSE;
 
    if (type == GL_DEPTH || type == GL_STENCIL) {
       if (INTEL_DEBUG & DEBUG_FALLBACKS)
@@ -133,15 +134,16 @@ do_blit_copypixels(GLcontext * ctx,
        ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F)
       return GL_FALSE;
 
+   intel_prepare_render(intel);
+
+   dst = intel_drawbuf_region(intel);
+   src = copypix_src_region(intel, type);
+
    if (!src || !dst)
       return GL_FALSE;
 
    intelFlush(&intel->ctx);
 
-   intel_prepare_render(intel);
-
-   /* XXX: We fail to handle different inversion between read and draw framebuffer. */
-
    /* Clip to destination buffer. */
    orig_dstx = dstx;
    orig_dsty = dsty;
@@ -164,23 +166,23 @@ do_blit_copypixels(GLcontext * ctx,
    dstx += srcx - orig_srcx;
    dsty += srcy - orig_srcy;
 
-   /* Convert from GL to hardware coordinates: */
+   /* Flip dest Y if it's a window system framebuffer. */
    if (fb->Name == 0) {
-      /* copypixels to a system framebuffer */
+      /* copypixels to a window system framebuffer */
       dsty = fb->Height - dsty - height;
-   } else {
-      /* copypixels to a user framebuffer object */
-      dsty = dsty;
+      flip = !flip;
    }
 
-   /* Flip source Y if it's a system framebuffer. */
-   if (read_fb->Name == 0)
-      srcy = fb->Height - srcy - height;
+   /* Flip source Y if it's a window system framebuffer. */
+   if (read_fb->Name == 0) {
+      srcy = read_fb->Height - srcy - height;
+      flip = !flip;
+   }
 
    if (!intel_region_copy(intel,
                          dst, 0, dstx, dsty,
                          src, 0, srcx, srcy,
-                         width, height,
+                         width, height, flip,
                          ctx->Color.ColorLogicOpEnabled ?
                          ctx->Color.LogicOp : GL_COPY)) {
       DBG("%s: blit failure\n", __FUNCTION__);
index d19f1bae34ce36e67aeac359c79fdc606d04bc58..36d8180598e48ebb949b200abc674b9ced7a8722 100644 (file)
 
 /** @{
  * 915 definitions
+ *
+ * 915 documents say that bits 31:28 and 1 are "undefined, must be zero."
  */
-#define S0_VB_OFFSET_MASK              0xffffffc0
+#define S0_VB_OFFSET_MASK              0x0ffffffc
 #define S0_AUTO_CACHE_INV_DISABLE      (1<<0)
 /** @} */
 
index f042bcbc28ce38c5a47ebdd4f53b6747f03b40cb..1172de90b1385776fd188274ea650d225df91c5d 100644 (file)
@@ -164,7 +164,6 @@ intel_region_alloc_internal(struct intel_context *intel,
 
    /* Default to no tiling */
    region->tiling = I915_TILING_NONE;
-   region->bit_6_swizzle = I915_BIT_6_SWIZZLE_NONE;
 
    _DBG("%s <-- %p\n", __FUNCTION__, region);
    return region;
@@ -173,7 +172,7 @@ intel_region_alloc_internal(struct intel_context *intel,
 struct intel_region *
 intel_region_alloc(struct intel_context *intel,
                   uint32_t tiling,
-                   GLuint cpp, GLuint width, GLuint height, GLuint pitch,
+                   GLuint cpp, GLuint width, GLuint height,
                   GLboolean expect_accelerated_upload)
 {
    dri_bo *buffer;
@@ -187,19 +186,10 @@ intel_region_alloc(struct intel_context *intel,
    buffer = drm_intel_bo_alloc_tiled(intel->bufmgr, "region",
                                     width, height, cpp,
                                     &tiling, &aligned_pitch, flags);
-   /* We've already chosen a pitch as part of miptree layout.  It had
-    * better be the same.
-    */
-   assert(aligned_pitch == pitch * cpp);
 
    region = intel_region_alloc_internal(intel, cpp, width, height,
-                                       pitch, buffer);
-
-   if (tiling != I915_TILING_NONE) {
-      assert(((pitch * cpp) & 127) == 0);
-      drm_intel_bo_set_tiling(buffer, &tiling, pitch * cpp);
-      drm_intel_bo_get_tiling(buffer, &region->tiling, &region->bit_6_swizzle);
-   }
+                                       aligned_pitch / cpp, buffer);
+   region->tiling = tiling;
 
    return region;
 }
@@ -213,6 +203,7 @@ intel_region_alloc_for_handle(struct intel_context *intel,
    struct intel_region *region, *dummy;
    dri_bo *buffer;
    int ret;
+   uint32_t bit_6_swizzle;
 
    region = _mesa_HashLookup(intel->intelScreen->named_regions, handle);
    if (region != NULL) {
@@ -236,7 +227,7 @@ intel_region_alloc_for_handle(struct intel_context *intel,
       return region;
 
    ret = dri_bo_get_tiling(region->buffer, &region->tiling,
-                          &region->bit_6_swizzle);
+                          &bit_6_swizzle);
    if (ret != 0) {
       fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n",
              handle, name, strerror(-ret));
@@ -316,7 +307,7 @@ _mesa_copy_rect(GLubyte * dst,
    dst += dst_x * cpp;
    src += src_x * cpp;
    dst += dst_y * dst_pitch;
-   src += src_y * dst_pitch;
+   src += src_y * src_pitch;
    width *= cpp;
 
    if (width == dst_pitch && width == src_pitch)
@@ -380,8 +371,11 @@ intel_region_copy(struct intel_context *intel,
                   struct intel_region *src,
                   GLuint src_offset,
                   GLuint srcx, GLuint srcy, GLuint width, GLuint height,
+                 GLboolean flip,
                  GLenum logicop)
 {
+   uint32_t src_pitch = src->pitch;
+
    _DBG("%s\n", __FUNCTION__);
 
    if (intel == NULL)
@@ -397,9 +391,12 @@ intel_region_copy(struct intel_context *intel,
 
    assert(src->cpp == dst->cpp);
 
+   if (flip)
+      src_pitch = -src_pitch;
+
    return intelEmitCopyBlit(intel,
                            dst->cpp,
-                           src->pitch, src->buffer, src_offset, src->tiling,
+                           src_pitch, src->buffer, src_offset, src->tiling,
                            dst->pitch, dst->buffer, dst_offset, dst->tiling,
                            srcx, srcy, dstx, dsty, width, height,
                            logicop);
index 7ee6a988eae3d9c518648c12628bdd801deaf87c..2459c9a924d255935cd1b4a1964a17473f8b0361 100644 (file)
@@ -65,7 +65,6 @@ struct intel_region
    GLuint draw_x, draw_y; /**< Offset of drawing within the region */
 
    uint32_t tiling; /**< Which tiling mode the region is in */
-   uint32_t bit_6_swizzle; /**< GEM flag for address swizzling requirement */
    struct intel_buffer_object *pbo;     /* zero-copy uploads */
 
    uint32_t name; /**< Global name for the bo */
@@ -79,7 +78,7 @@ struct intel_region
 struct intel_region *intel_region_alloc(struct intel_context *intel,
                                         uint32_t tiling,
                                        GLuint cpp, GLuint width,
-                                        GLuint height, GLuint pitch,
+                                        GLuint height,
                                        GLboolean expect_accelerated_upload);
 
 struct intel_region *
@@ -122,6 +121,7 @@ intel_region_copy(struct intel_context *intel,
                  struct intel_region *src,
                  GLuint src_offset,
                  GLuint srcx, GLuint srcy, GLuint width, GLuint height,
+                 GLboolean flip,
                  GLenum logicop);
 
 /* Helpers for zerocopy uploads, particularly texture image uploads:
index 6e4bb64365158f9c20fb9031d75041148b63939b..5e3f40836d04625c56642d2b5c484e779e46a413 100644 (file)
@@ -312,18 +312,13 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
       }
 
       if (mesaVis->depthBits == 24) {
-        if (mesaVis->stencilBits == 8) {
-           /* combined depth/stencil buffer */
-           struct intel_renderbuffer *depthStencilRb
-              = intel_create_renderbuffer(MESA_FORMAT_S8_Z24);
-           /* note: bind RB to two attachment points */
-           _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base);
-           _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base);
-        } else {
-           struct intel_renderbuffer *depthRb
-              = intel_create_renderbuffer(MESA_FORMAT_X8_Z24);
-           _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
-        }
+        assert(mesaVis->stencilBits == 8);
+        /* combined depth/stencil buffer */
+        struct intel_renderbuffer *depthStencilRb
+           = intel_create_renderbuffer(MESA_FORMAT_S8_Z24);
+        /* note: bind RB to two attachment points */
+        _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base);
+        _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base);
       }
       else if (mesaVis->depthBits == 16) {
          /* just 16-bit depth buffer, no hw stencil */
index fb5c01bc4dc1a4aded76f9e28de5f63e4072f02f..c1e15d1b0f299db27ff5d107f5cb23d72e5bfb13 100644 (file)
@@ -48,11 +48,11 @@ intel_set_span_functions(struct intel_context *intel,
 
 #define LOCAL_VARS                                                     \
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);            \
-   const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1;                        \
-   const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\
+   const GLint yScale = rb->Name ? 1 : -1;                             \
+   const GLint yBias = rb->Name ? 0 : rb->Height - 1;                  \
    int minx = 0, miny = 0;                                             \
-   int maxx = ctx->DrawBuffer->Width;                                  \
-   int maxy = ctx->DrawBuffer->Height;                                 \
+   int maxx = rb->Width;                                               \
+   int maxy = rb->Height;                                              \
    int pitch = irb->region->pitch * irb->region->cpp;                  \
    void *buf = irb->region->buffer->virtual;                           \
    GLuint p;                                                           \
@@ -108,11 +108,11 @@ intel_set_span_functions(struct intel_context *intel,
 
 #define LOCAL_DEPTH_VARS                                               \
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);            \
-   const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1;                        \
-   const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\
+   const GLint yScale = rb->Name ? 1 : -1;                             \
+   const GLint yBias = rb->Name ? 0 : rb->Height - 1;                  \
    int minx = 0, miny = 0;                                             \
-   int maxx = ctx->DrawBuffer->Width;                                  \
-   int maxy = ctx->DrawBuffer->Height;                                 \
+   int maxx = rb->Width;                                               \
+   int maxy = rb->Height;                                              \
    int pitch = irb->region->pitch * irb->region->cpp;                  \
    void *buf = irb->region->buffer->virtual;                           \
    (void)buf; (void)pitch; /* unused for non-gttmap. */                        \
@@ -134,7 +134,7 @@ intel_set_span_functions(struct intel_context *intel,
    (*(uint32_t *)(irb->region->buffer->virtual + NO_TILE(_x, _y)) = d)
 #define READ_DEPTH(d, _x, _y) \
    d = *(uint32_t *)(irb->region->buffer->virtual + NO_TILE(_x, _y))
-#define TAG(x) intel_##x##_z24_x8
+#define TAG(x) intel_##x##_z24_s8
 #include "depthtmp.h"
 
 void
@@ -361,7 +361,7 @@ intel_set_span_functions(struct intel_context *intel,
       break;
    case MESA_FORMAT_X8_Z24:
    case MESA_FORMAT_S8_Z24:
-      intel_InitDepthPointers_z24_x8(rb);
+      intel_InitDepthPointers_z24_s8(rb);
       break;
    default:
       _mesa_problem(NULL,
index 13b8bcfa86c31b9b1edfb6d5097b0e11d4970baa..62e1e78f59be035ca2e3d9649a7e17f2aa4de8bc 100644 (file)
@@ -130,18 +130,8 @@ do_copy_texsubimage(struct intel_context *intel,
       }
 
       if (ctx->ReadBuffer->Name == 0) {
-        /* reading from a window, adjust x, y */
-        const __DRIdrawable *dPriv = intel->driReadDrawable;
-        y = dPriv->y + (dPriv->h - (y + height));
-        x += dPriv->x;
-
-        /* Invert the data coming from the source rectangle due to GL
-         * and hardware disagreeing on where y=0 is.
-         *
-         * It appears that our offsets and pitches get mangled
-         * appropriately by the hardware, and we don't need to adjust them
-         * on our own.
-         */
+        /* Flip vertical orientation for system framebuffers */
+        y = ctx->ReadBuffer->Height - (y + height);
         src_pitch = -src->pitch;
       } else {
         /* reading from a FBO, y is already oriented the way we like */
@@ -155,7 +145,7 @@ do_copy_texsubimage(struct intel_context *intel,
                             src->buffer,
                             0,
                             src->tiling,
-                            intelImage->mt->pitch,
+                            intelImage->mt->region->pitch,
                             dst_bo,
                             0,
                             intelImage->mt->region->tiling,
index bac36eeb56950bab9fa3d774496c51c98542f7ea..9db96acdc08d55bfb27e5db5c6f827618182c537 100644 (file)
@@ -236,7 +236,7 @@ try_pbo_upload(struct intel_context *intel,
                                  intelImage->face, 0,
                                  &dst_x, &dst_y);
 
-   dst_stride = intelImage->mt->pitch;
+   dst_stride = intelImage->mt->region->pitch;
 
    if (drm_intel_bo_references(intel->batch->buf, dst_buffer))
       intelFlush(&intel->ctx);
@@ -290,7 +290,7 @@ try_pbo_zcopy(struct intel_context *intel,
                                  intelImage->face, 0,
                                  &dst_x, &dst_y);
 
-   dst_stride = intelImage->mt->pitch;
+   dst_stride = intelImage->mt->region->pitch;
 
    if (src_stride != dst_stride || dst_x != 0 || dst_y != 0 ||
        src_offset != 0) {
index 7d69ea4484afe811b05a33ace971ffa3df34d180..d132e19e831b72b6270edf8dbe718f753a8f35cf 100644 (file)
@@ -74,14 +74,14 @@ void i945_miptree_layout_2d( struct intel_context *intel,
    GLuint width = mt->width0;
    GLuint height = mt->height0;
 
-   mt->pitch = mt->width0;
+   mt->total_width = mt->width0;
    intel_get_texture_alignment_unit(mt->internal_format, &align_w, &align_h);
 
    if (mt->compressed) {
-       mt->pitch = ALIGN(mt->width0, align_w);
+       mt->total_width = ALIGN(mt->width0, align_w);
    }
 
-   /* May need to adjust pitch to accomodate the placement of
+   /* May need to adjust width to accomodate the placement of
     * the 2nd mipmap.  This occurs when the alignment
     * constraints of mipmap placement push the right edge of the
     * 2nd mipmap out past the width of its parent.
@@ -97,15 +97,11 @@ void i945_miptree_layout_2d( struct intel_context *intel,
                + minify(minify(mt->width0));
        }
 
-       if (mip1_width > mt->pitch) {
-           mt->pitch = mip1_width;
+       if (mip1_width > mt->total_width) {
+           mt->total_width = mip1_width;
        }
    }
 
-   /* Pitch must be a whole number of dwords, even though we
-    * express it in texels.
-    */
-   mt->pitch = intel_miptree_pitch_align (intel, mt, tiling, mt->pitch);
    mt->total_height = 0;
 
    for ( level = mt->first_level ; level <= mt->last_level ; level++ ) {
index be57d48b8ddf5f3cc653ad172d76533c8d7afe77..42bec659d73e1d8dd36daadc09c7f075b42b5894 100644 (file)
@@ -54,6 +54,7 @@ static const struct dri_extension nouveau_extensions[] = {
        { "GL_ARB_texture_env_dot3",    NULL },
        { "GL_ARB_texture_mirrored_repeat", NULL },
        { "GL_EXT_fog_coord",           GL_EXT_fog_coord_functions },
+       { "GL_EXT_framebuffer_blit",    NULL },
        { "GL_EXT_framebuffer_object",  GL_EXT_framebuffer_object_functions },
        { "GL_EXT_secondary_color",     GL_EXT_secondary_color_functions },
        { "GL_EXT_stencil_wrap",        NULL },
@@ -337,6 +338,8 @@ nouveau_validate_framebuffer(GLcontext *ctx)
                update_framebuffer(dri_ctx, dri_read,
                                   &dri_ctx->dri2.read_stamp);
 
-       if (nouveau_next_dirty_state(ctx) >= 0)
+       if (nouveau_next_dirty_state(ctx) >= 0) {
+               nouveau_state_emit(ctx);
                FIRE_RING(context_chan(ctx));
+       }
 }
index 1d12f43741fceb1cc30f21832c685e1dda8735fe..4ec864c181c23165b10d44da033d278e6362218c 100644 (file)
@@ -135,4 +135,8 @@ nouveau_driver_functions_init(struct dd_function_table *functions)
        functions->Flush = nouveau_flush;
        functions->Finish = nouveau_finish;
        functions->Clear = nouveau_clear;
+       functions->DrawPixels = _mesa_meta_DrawPixels;
+       functions->CopyPixels = _mesa_meta_CopyPixels;
+       functions->Bitmap = _mesa_meta_Bitmap;
+       functions->BlitFramebuffer = _mesa_meta_BlitFramebuffer;
 }
index 2ec3dc92420c0e6480296e2157ba9a77e022a74e..8be7edb150bf8bbde835eed86ee0ecdcf3fd9a37 100644 (file)
@@ -236,7 +236,7 @@ nouveau_render_texture(GLcontext *ctx, struct gl_framebuffer *fb,
        /* Allocate a renderbuffer object for the texture if we
         * haven't already done so. */
        if (!rb) {
-               rb = nouveau_renderbuffer_new(ctx, 0);
+               rb = nouveau_renderbuffer_new(ctx, ~0);
                assert(rb);
 
                rb->AllocStorage = NULL;
@@ -259,11 +259,7 @@ static void
 nouveau_finish_render_texture(GLcontext *ctx,
                              struct gl_renderbuffer_attachment *att)
 {
-       struct nouveau_renderbuffer *nrb
-               = to_nouveau_renderbuffer(att->Renderbuffer);
-
        texture_dirty(att->Texture);
-       nouveau_surface_ref(NULL, &nrb->surface);
 }
 
 void
index 00007a9a351681d9256f2330b29e53b264841b9c..fbeed3baeabb127970bf82ac4fc68f6533df0b09 100644 (file)
@@ -260,4 +260,23 @@ nvgl_filter_mode(unsigned filter)
        }
 }
 
+static inline unsigned
+nvgl_texgen_mode(unsigned mode)
+{
+       switch (mode) {
+       case GL_EYE_LINEAR:
+               return 0x2400;
+       case GL_OBJECT_LINEAR:
+               return 0x2401;
+       case GL_SPHERE_MAP:
+               return 0x2402;
+       case GL_NORMAL_MAP:
+               return 0x8511;
+       case GL_REFLECTION_MAP:
+               return 0x8512;
+       default:
+               assert(0);
+       }
+}
+
 #endif
index bff0ccfd7624fc0afdb5a3da7c021ad430e9e1db..923b79b2cf6badec42b48473e7502c994b0179b4 100644 (file)
@@ -32,8 +32,8 @@
 struct nouveau_array_state;
 
 typedef void (*dispatch_t)(GLcontext *, unsigned int, int, unsigned int);
-typedef unsigned (*extract_u_t)(struct nouveau_array_state *a, int i, int j);
-typedef float (*extract_f_t)(struct nouveau_array_state *a, int i, int j);
+typedef unsigned (*extract_u_t)(struct nouveau_array_state *, int, int);
+typedef float (*extract_f_t)(struct nouveau_array_state *, int, int);
 
 struct nouveau_attr_info {
        int vbo_index;
index c0505781cfebd05722165ca3b409e972ec1aff66..7ccd7e6416528189d05fd63216b56d75132a7449 100644 (file)
@@ -254,7 +254,7 @@ get_scratch_vbo(GLcontext *ctx, unsigned size, struct nouveau_bo **bo,
  */
 static inline unsigned
 get_max_vertices(GLcontext *ctx, const struct _mesa_index_buffer *ib,
-                unsigned n)
+                int n)
 {
        struct nouveau_render_state *render = to_render_state(ctx);
 
index f1a56dd03af9a03aeaeeba6f0a1ad0e69f317ac4..1bfdecc6a219b9ed14a993f37a2eff45f590618a 100644 (file)
@@ -32,7 +32,6 @@
 #include "swrast/swrast.h"
 
 #define LOCAL_VARS                                                     \
-       struct gl_framebuffer *fb = ctx->DrawBuffer;                    \
        struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface; \
        GLuint p;                                                       \
        (void)p;
 #define HW_CLIPLOOP() {                                                        \
        int minx = 0;                                                   \
        int miny = 0;                                                   \
-       int maxx = fb->Width;                                           \
-       int maxy = fb->Height;
+       int maxx = rb->Width;                                           \
+       int maxy = rb->Height;
 
 #define HW_ENDCLIPLOOP() }
 
-#define Y_FLIP(y) (fb->Name ? (y) : rb->Height - 1 - (y))
+#define Y_FLIP(y) (rb->Name ? (y) : rb->Height - 1 - (y))
 
 /* RGB565 span functions */
 #define SPANTMP_PIXEL_FMT GL_RGB
@@ -144,17 +143,28 @@ texture_unit_map_unmap(GLcontext *ctx, struct gl_texture_unit *u, GLboolean map)
 }
 
 static void
-span_map_unmap(GLcontext *ctx, GLboolean map)
+framebuffer_map_unmap(struct gl_framebuffer *fb, GLboolean map)
 {
        int i;
 
-       for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++)
-               renderbuffer_map_unmap(ctx->DrawBuffer->_ColorDrawBuffers[i], map);
+       for (i = 0; i < fb->_NumColorDrawBuffers; i++)
+               renderbuffer_map_unmap(fb->_ColorDrawBuffers[i], map);
+
+       renderbuffer_map_unmap(fb->_ColorReadBuffer, map);
+
+       if (fb->_DepthBuffer)
+               renderbuffer_map_unmap(fb->_DepthBuffer->Wrapped, map);
+}
+
+static void
+span_map_unmap(GLcontext *ctx, GLboolean map)
+{
+       int i;
 
-       renderbuffer_map_unmap(ctx->DrawBuffer->_ColorReadBuffer, map);
+       framebuffer_map_unmap(ctx->DrawBuffer, map);
 
-       if (ctx->DrawBuffer->_DepthBuffer)
-               renderbuffer_map_unmap(ctx->DrawBuffer->_DepthBuffer->Wrapped, map);
+       if (ctx->ReadBuffer != ctx->DrawBuffer)
+               framebuffer_map_unmap(ctx->ReadBuffer, map);
 
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
                texture_unit_map_unmap(ctx, &ctx->Texture.Unit[i], map);
index bc610451b403d6bae828856d613880106daa623a..a57df2d9dcd9adf4117958428d1128478782b07b 100644 (file)
@@ -189,6 +189,7 @@ nouveau_enable(GLcontext *ctx, GLenum cap, GLboolean state)
        case GL_LIGHTING:
                context_dirty(ctx, FRAG);
                context_dirty(ctx, MODELVIEW);
+               context_dirty(ctx, LIGHT_MODEL);
                context_dirty(ctx, LIGHT_ENABLE);
 
                for (i = 0; i < MAX_LIGHTS; i++) {
@@ -231,9 +232,17 @@ nouveau_enable(GLcontext *ctx, GLenum cap, GLboolean state)
        case GL_TEXTURE_1D:
        case GL_TEXTURE_2D:
        case GL_TEXTURE_3D:
+       case GL_TEXTURE_RECTANGLE:
                context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit);
                context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
                break;
+       case GL_TEXTURE_GEN_S:
+       case GL_TEXTURE_GEN_T:
+       case GL_TEXTURE_GEN_R:
+       case GL_TEXTURE_GEN_Q:
+               context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
+               context_dirty(ctx, MODELVIEW);
+               break;
        }
 }
 
@@ -368,7 +377,15 @@ static void
 nouveau_tex_gen(GLcontext *ctx, GLenum coord, GLenum pname,
                const GLfloat *params)
 {
-       context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
+       switch (pname) {
+       case GL_TEXTURE_GEN_MODE:
+               context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
+               context_dirty(ctx, MODELVIEW);
+               break;
+       default:
+               context_dirty_i(ctx, TEX_GEN, ctx->Texture.CurrentUnit);
+               break;
+       }
 }
 
 static void
@@ -454,12 +471,19 @@ nouveau_state_emit(GLcontext *ctx)
 static void
 nouveau_update_state(GLcontext *ctx, GLbitfield new_state)
 {
+       int i;
+
        if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW))
                context_dirty(ctx, PROJECTION);
 
        if (new_state & _NEW_MODELVIEW)
                context_dirty(ctx, MODELVIEW);
 
+       if (new_state & _NEW_TEXTURE_MATRIX) {
+               for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
+                       context_dirty_i(ctx, TEX_MAT, i);
+       }
+
        if (new_state & _NEW_CURRENT_ATTRIB &&
            new_state & _NEW_LIGHT) {
                context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
index d01d962c9f200852ea5e57098feb733904a48d56..38ac9753c8cbc433d95eb8c59188d55de536e3a9 100644 (file)
@@ -89,6 +89,10 @@ enum {
        NOUVEAU_STATE_TEX_GEN1,
        NOUVEAU_STATE_TEX_GEN2,
        NOUVEAU_STATE_TEX_GEN3,
+       NOUVEAU_STATE_TEX_MAT0,
+       NOUVEAU_STATE_TEX_MAT1,
+       NOUVEAU_STATE_TEX_MAT2,
+       NOUVEAU_STATE_TEX_MAT3,
        NOUVEAU_STATE_TEX_OBJ0,
        NOUVEAU_STATE_TEX_OBJ1,
        NOUVEAU_STATE_TEX_OBJ2,
index bf365bfca34f693dbb29819651da1e613701f323..dbf9a5cc613f0469881458e39817c6f631c09854 100644 (file)
@@ -177,15 +177,15 @@ nouveau_choose_tex_format(GLcontext *ctx, GLint internalFormat,
 }
 
 static GLboolean
-teximage_fits(struct gl_texture_object *t, int level,
-             struct gl_texture_image *ti)
+teximage_fits(struct gl_texture_object *t, int level)
 {
        struct nouveau_surface *s = &to_nouveau_texture(t)->surfaces[level];
+       struct gl_texture_image *ti = t->Image[0][level];
 
-       return t->Target == GL_TEXTURE_RECTANGLE ||
-               (s->bo && s->width == ti->Width &&
-                s->height == ti->Height &&
-                s->format == ti->TexFormat);
+       return ti && (t->Target == GL_TEXTURE_RECTANGLE ||
+                     (s->bo && s->width == ti->Width &&
+                      s->height == ti->Height &&
+                      s->format == ti->TexFormat));
 }
 
 static GLboolean
@@ -195,7 +195,7 @@ validate_teximage(GLcontext *ctx, struct gl_texture_object *t,
 {
        struct gl_texture_image *ti = t->Image[0][level];
 
-       if (ti && teximage_fits(t, level, ti)) {
+       if (teximage_fits(t, level)) {
                struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
                struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
 
@@ -283,7 +283,8 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t)
        struct nouveau_texture *nt = to_nouveau_texture(t);
        int i, last = get_last_level(t);
 
-       if (!nt->surfaces[last].bo)
+       if (!teximage_fits(t, t->BaseLevel) ||
+           !teximage_fits(t, last))
                return GL_FALSE;
 
        if (nt->dirty) {
@@ -296,6 +297,8 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t)
                        validate_teximage(ctx, t, i, 0, 0, 0,
                                          s->width, s->height, 1);
                }
+
+               FIRE_RING(context_chan(ctx));
        }
 
        return GL_TRUE;
@@ -304,9 +307,12 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t)
 void
 nouveau_texture_reallocate(GLcontext *ctx, struct gl_texture_object *t)
 {
-       texture_dirty(t);
-       relayout_texture(ctx, t);
-       nouveau_texture_validate(ctx, t);
+       if (!teximage_fits(t, t->BaseLevel) ||
+           !teximage_fits(t, get_last_level(t))) {
+               texture_dirty(t);
+               relayout_texture(ctx, t);
+               nouveau_texture_validate(ctx, t);
+       }
 }
 
 static unsigned
@@ -364,7 +370,7 @@ nouveau_teximage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
        }
 
        if (level == t->BaseLevel) {
-               if (!teximage_fits(t, level, ti))
+               if (!teximage_fits(t, level))
                        relayout_texture(ctx, t);
                nouveau_texture_validate(ctx, t);
        }
@@ -415,6 +421,40 @@ nouveau_teximage_3d(GLcontext *ctx, GLenum target, GLint level,
                         packing, t, ti);
 }
 
+static void
+nouveau_texsubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
+                   GLint xoffset, GLint yoffset, GLint zoffset,
+                   GLint width, GLint height, GLint depth,
+                   GLenum format, GLenum type, const void *pixels,
+                   const struct gl_pixelstore_attrib *packing,
+                   struct gl_texture_object *t,
+                   struct gl_texture_image *ti)
+{
+       struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
+       int ret;
+
+       pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, depth,
+                                            format, type, pixels, packing,
+                                            "glTexSubImage");
+       if (pixels) {
+               nouveau_teximage_map(ctx, ti);
+
+               ret = _mesa_texstore(ctx, 3, ti->_BaseFormat, ti->TexFormat,
+                                    ti->Data, xoffset, yoffset, zoffset,
+                                    s->pitch, ti->ImageOffsets,
+                                    width, height, depth, format, type,
+                                    pixels, packing);
+               assert(ret);
+
+               nouveau_teximage_unmap(ctx, ti);
+               _mesa_unmap_teximage_pbo(ctx, packing);
+       }
+
+       if (!to_nouveau_texture(t)->dirty)
+               validate_teximage(ctx, t, level, xoffset, yoffset, zoffset,
+                                 width, height, depth);
+}
+
 static void
 nouveau_texsubimage_3d(GLcontext *ctx, GLenum target, GLint level,
                       GLint xoffset, GLint yoffset, GLint zoffset,
@@ -424,15 +464,9 @@ nouveau_texsubimage_3d(GLcontext *ctx, GLenum target, GLint level,
                       struct gl_texture_object *t,
                       struct gl_texture_image *ti)
 {
-       nouveau_teximage_map(ctx, ti);
-       _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
-                                 width, height, depth, format, type, pixels,
-                                 packing, t, ti);
-       nouveau_teximage_unmap(ctx, ti);
-
-       if (!to_nouveau_texture(t)->dirty)
-               validate_teximage(ctx, t, level, xoffset, yoffset, zoffset,
-                                 width, height, depth);
+       nouveau_texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset,
+                           width, height, depth, format, type, pixels,
+                           packing, t, ti);
 }
 
 static void
@@ -444,15 +478,9 @@ nouveau_texsubimage_2d(GLcontext *ctx, GLenum target, GLint level,
                       struct gl_texture_object *t,
                       struct gl_texture_image *ti)
 {
-       nouveau_teximage_map(ctx, ti);
-       _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset,
-                                 width, height, format, type, pixels,
-                                 packing, t, ti);
-       nouveau_teximage_unmap(ctx, ti);
-
-       if (!to_nouveau_texture(t)->dirty)
-               validate_teximage(ctx, t, level, xoffset, yoffset, 0,
-                                 width, height, 1);
+       nouveau_texsubimage(ctx, 2, target, level, xoffset, yoffset, 0,
+                           width, height, 1, format, type, pixels,
+                           packing, t, ti);
 }
 
 static void
@@ -463,15 +491,9 @@ nouveau_texsubimage_1d(GLcontext *ctx, GLenum target, GLint level,
                       struct gl_texture_object *t,
                       struct gl_texture_image *ti)
 {
-       nouveau_teximage_map(ctx, ti);
-       _mesa_store_texsubimage1d(ctx, target, level, xoffset,
-                                 width, format, type, pixels,
-                                 packing, t, ti);
-       nouveau_teximage_unmap(ctx, ti);
-
-       if (!to_nouveau_texture(t)->dirty)
-               validate_teximage(ctx, t, level, xoffset, 0, 0,
-                                 width, 1, 1);
+       nouveau_texsubimage(ctx, 1, target, level, xoffset, 0, 0,
+                           width, 1, 1, format, type, pixels,
+                           packing, t, ti);
 }
 
 static void
index b91facbdeb6b5ac5bb1074b4cc89099baa5fdb8b..251f537bba7151f7eb152dba9c2cf0d580239325 100644 (file)
@@ -41,7 +41,7 @@ struct nouveau_texture {
 #define to_nouveau_texture(x) ((struct nouveau_texture *)(x))
 
 #define texture_dirty(t) \
-       to_nouveau_texture(t)->dirty = GL_TRUE;
+       to_nouveau_texture(t)->dirty = GL_TRUE
 
 void
 nouveau_set_texbuffer(__DRIcontext *dri_ctx,
index d6007aba2b9e847b1cc50b63ffa2aeacd51c2085..584cb80ef62fa3e8479d8428f91b9f1d09103abd 100644 (file)
@@ -191,4 +191,22 @@ is_texture_source(int s)
        return s == GL_TEXTURE || (s >= GL_TEXTURE0 && s <= GL_TEXTURE31);
 }
 
+static inline struct gl_texgen *
+get_texgen_coord(struct gl_texture_unit *u, int i)
+{
+       return ((struct gl_texgen *[])
+               { &u->GenS, &u->GenT, &u->GenR, &u->GenQ }) [i];
+}
+
+static inline float *
+get_texgen_coeff(struct gl_texgen *c)
+{
+       if (c->Mode == GL_OBJECT_LINEAR)
+               return c->ObjectPlane;
+       else if (c->Mode == GL_EYE_LINEAR)
+               return c->EyePlane;
+       else
+               return NULL;
+}
+
 #endif
index a365b977f294c08afc77647fcf68377e5e73ef71..e5858f82684aeb566315d4f9aa9098c0d5ea7835 100644 (file)
@@ -85,6 +85,18 @@ vbo_deinit_array(struct nouveau_array_state *a)
        a->fields = 0;
 }
 
+static int
+get_array_stride(GLcontext *ctx, const struct gl_client_array *a)
+{
+       struct nouveau_render_state *render = to_render_state(ctx);
+
+       if (render->mode == VBO && !_mesa_is_bufferobj(a->BufferObj))
+               /* Pack client buffers. */
+               return align(_mesa_sizeof_type(a->Type) * a->Size, 4);
+       else
+               return a->StrideB;
+}
+
 static void
 vbo_init_arrays(GLcontext *ctx, const struct _mesa_index_buffer *ib,
                const struct gl_client_array **arrays)
@@ -101,18 +113,10 @@ vbo_init_arrays(GLcontext *ctx, const struct _mesa_index_buffer *ib,
 
                if (attr >= 0) {
                        const struct gl_client_array *array = arrays[attr];
-                       int stride;
-
-                       if (render->mode == VBO &&
-                           !_mesa_is_bufferobj(array->BufferObj))
-                               /* Pack client buffers. */
-                               stride = align(_mesa_sizeof_type(array->Type)
-                                              * array->Size, 4);
-                       else
-                               stride = array->StrideB;
 
                        vbo_init_array(&render->attrs[attr], attr,
-                                      stride, array->Size, array->Type,
+                                      get_array_stride(ctx, array),
+                                      array->Size, array->Type,
                                       array->BufferObj, array->Ptr,
                                       render->mode == IMM);
                }
@@ -224,9 +228,11 @@ vbo_choose_attrs(GLcontext *ctx, const struct gl_client_array **arrays)
        if (ctx->Fog.Enabled && ctx->Fog.FogCoordinateSource == GL_FOG_COORD)
                vbo_emit_attr(ctx, arrays, VERT_ATTRIB_FOG);
 
-       if (ctx->Light.Enabled) {
+       if (ctx->Light.Enabled ||
+           (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))
                vbo_emit_attr(ctx, arrays, VERT_ATTRIB_NORMAL);
 
+       if (ctx->Light.Enabled) {
                vbo_emit_attr(ctx, arrays, MAT(FRONT_AMBIENT));
                vbo_emit_attr(ctx, arrays, MAT(FRONT_DIFFUSE));
                vbo_emit_attr(ctx, arrays, MAT(FRONT_SPECULAR));
@@ -243,18 +249,21 @@ vbo_choose_attrs(GLcontext *ctx, const struct gl_client_array **arrays)
        vbo_emit_attr(ctx, arrays, VERT_ATTRIB_POS);
 }
 
-static unsigned
-get_max_client_stride(GLcontext *ctx)
+static int
+get_max_client_stride(GLcontext *ctx, const struct gl_client_array **arrays)
 {
        struct nouveau_render_state *render = to_render_state(ctx);
        int i, s = 0;
 
        for (i = 0; i < render->attr_count; i++) {
                int attr = render->map[i];
-               struct nouveau_array_state *a = &render->attrs[attr];
 
-               if (attr >= 0 && !a->bo)
-                       s = MAX2(a->stride, s);
+               if (attr >= 0) {
+                       const struct gl_client_array *a = arrays[attr];
+
+                       if (!_mesa_is_bufferobj(a->BufferObj))
+                               s = MAX2(s, get_array_stride(ctx, a));
+               }
        }
 
        return s;
@@ -275,14 +284,15 @@ vbo_maybe_split(GLcontext *ctx, const struct gl_client_array **arrays,
 {
        struct nouveau_context *nctx = to_nouveau_context(ctx);
        struct nouveau_render_state *render = to_render_state(ctx);
-       unsigned pushbuf_avail = PUSHBUF_DWORDS - 2 * nctx->bo.count,
+       unsigned pushbuf_avail = PUSHBUF_DWORDS - 2 * (nctx->bo.count +
+                                                      render->attr_count),
                vert_avail = get_max_vertices(ctx, NULL, pushbuf_avail),
                idx_avail = get_max_vertices(ctx, ib, pushbuf_avail);
        int stride;
 
        /* Try to keep client buffers smaller than the scratch BOs. */
        if (render->mode == VBO &&
-           (stride = get_max_client_stride(ctx)))
+           (stride = get_max_client_stride(ctx, arrays)))
                    vert_avail = MIN2(vert_avail,
                                      RENDER_SCRATCH_SIZE / stride);
 
@@ -321,6 +331,7 @@ vbo_bind_vertices(GLcontext *ctx, const struct gl_client_array **arrays,
                                * array->StrideB;
 
                        if (a->bo) {
+                               /* Array in a buffer obj. */
                                a->offset = (intptr_t)array->Ptr + delta;
                        } else {
                                int j, n = max_index - min_index + 1;
@@ -328,6 +339,8 @@ vbo_bind_vertices(GLcontext *ctx, const struct gl_client_array **arrays,
                                char *dp = get_scratch_vbo(ctx, n * a->stride,
                                                           &a->bo, &a->offset);
 
+                               /* Array in client memory, move it to
+                                * a scratch buffer obj. */
                                for (j = 0; j < n; j++)
                                        memcpy(dp + j * a->stride,
                                               sp + j * array->StrideB,
@@ -371,8 +384,6 @@ vbo_draw_vbo(GLcontext *ctx, const struct gl_client_array **arrays,
                dispatch(ctx, start, delta, count);
                BATCH_END();
        }
-
-       FIRE_RING(chan);
 }
 
 /* Immediate rendering path. */
@@ -416,8 +427,6 @@ vbo_draw_imm(GLcontext *ctx, const struct gl_client_array **arrays,
 
                BATCH_END();
        }
-
-       FIRE_RING(chan);
 }
 
 /* draw_prims entry point when we're doing hw-tnl. */
index 3624b3af9211b77ec0ec2114af91e5b7f83fc888..6834f7cd3dc60fb2e868651c7dab809990c37305 100644 (file)
@@ -276,6 +276,10 @@ const struct nouveau_driver nv04_driver = {
                nouveau_emit_nothing,
                nouveau_emit_nothing,
                nouveau_emit_nothing,
+               nouveau_emit_nothing,
+               nouveau_emit_nothing,
+               nouveau_emit_nothing,
+               nouveau_emit_nothing,
                nv04_emit_tex_obj,
                nv04_emit_tex_obj,
                nouveau_emit_nothing,
index 860d0aeb8f5f6d0631854f58a6fa8d4979d7219d..b6d10361de0bcbf954c2b5d2b796de6195251286 100644 (file)
@@ -212,7 +212,7 @@ nv10_hwctx_init(GLcontext *ctx)
        OUT_RING(chan, 0);
        BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1);
        OUT_RING(chan, 0);
-       BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_S(0), 8);
+       BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_MODE_S(0), 8);
        for (i = 0; i < 8; i++)
                OUT_RING(chan, 0);
 
@@ -412,6 +412,10 @@ const struct nouveau_driver nv10_driver = {
                nv10_emit_tex_gen,
                nouveau_emit_nothing,
                nouveau_emit_nothing,
+               nv10_emit_tex_mat,
+               nv10_emit_tex_mat,
+               nouveau_emit_nothing,
+               nouveau_emit_nothing,
                nv10_emit_tex_obj,
                nv10_emit_tex_obj,
                nouveau_emit_nothing,
index d662712533b8bd641b59398ce224119135f2e57f..cefd6c6fba8494ec4d2ce481baaf9f1e385fc12d 100644 (file)
@@ -133,6 +133,9 @@ nv10_emit_frag(GLcontext *ctx, int emit);
 void
 nv10_emit_tex_gen(GLcontext *ctx, int emit);
 
+void
+nv10_emit_tex_mat(GLcontext *ctx, int emit);
+
 void
 nv10_emit_tex_obj(GLcontext *ctx, int emit);
 
index 6bd383ebcd32e2dbf81a71c8455fa5528cb00da4..a2fcb6b695983db4376d6ac7bcf21dc176ef0c69 100644 (file)
@@ -71,6 +71,7 @@ setup_lma_buffer(GLcontext *ctx)
        nouveau_bo_markl(bctx, celsius, NV17TCL_LMA_DEPTH_BUFFER_OFFSET,
                         nfb->lma_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
 
+       WAIT_RING(chan, 9);
        BEGIN_RING(chan, celsius, NV17TCL_LMA_DEPTH_WINDOW_X, 4);
        OUT_RINGf(chan, - 1792);
        OUT_RINGf(chan, - 2304 + fb->Height);
@@ -171,15 +172,13 @@ nv10_emit_viewport(GLcontext *ctx, int emit)
        struct nouveau_grobj *celsius = context_eng3d(ctx);
        struct gl_framebuffer *fb = ctx->DrawBuffer;
        float a[4] = {};
-       int i;
 
        get_viewport_translate(ctx, a);
        a[0] -= 2048;
        a[1] -= 2048;
 
        BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_TRANSLATE_X, 4);
-       for (i = 0; i < 4; i++)
-               OUT_RINGf(chan, a[i]);
+       OUT_RINGp(chan, a, 4);
 
        BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 1);
        OUT_RING(chan, (fb->Width - 1) << 16 | 0x08000800);
index 02a5ca797ae0cce44f6c485871fe37269af7e88f..6dedb18c72ba5f56ac5d18c4db6dd6d2fc02025a 100644 (file)
 #include "nouveau_util.h"
 #include "nv10_driver.h"
 
+#define TX_GEN_MODE(i, j) (NV10TCL_TX_GEN_MODE_S(i) + 4 * (j))
+#define TX_GEN_COEFF(i, j) (NV10TCL_TX_GEN_COEFF_S_A(i) + 16 * (j))
+#define TX_MATRIX(i) (NV10TCL_TX0_MATRIX(0) + 64 * (i))
+
 void
 nv10_emit_tex_gen(GLcontext *ctx, int emit)
 {
+       const int i = emit - NOUVEAU_STATE_TEX_GEN0;
+       struct nouveau_context *nctx = to_nouveau_context(ctx);
+       struct nouveau_channel *chan = context_chan(ctx);
+       struct nouveau_grobj *celsius = context_eng3d(ctx);
+       struct gl_texture_unit *unit = &ctx->Texture.Unit[i];
+       int j;
+
+       for (j = 0; j < 4; j++) {
+               if (nctx->fallback == HWTNL && (unit->TexGenEnabled & 1 << j)) {
+                       struct gl_texgen *coord = get_texgen_coord(unit, j);
+                       float *k = get_texgen_coeff(coord);
+
+                       if (k) {
+                               BEGIN_RING(chan, celsius,
+                                          TX_GEN_COEFF(i, j), 4);
+                               OUT_RINGp(chan, k, 4);
+                       }
+
+                       BEGIN_RING(chan, celsius, TX_GEN_MODE(i, j), 1);
+                       OUT_RING(chan, nvgl_texgen_mode(coord->Mode));
+
+               } else {
+                       BEGIN_RING(chan, celsius, TX_GEN_MODE(i, j), 1);
+                       OUT_RING(chan, 0);
+               }
+       }
+
+       context_dirty_i(ctx, TEX_MAT, i);
+}
+
+void
+nv10_emit_tex_mat(GLcontext *ctx, int emit)
+{
+       const int i = emit - NOUVEAU_STATE_TEX_MAT0;
+       struct nouveau_context *nctx = to_nouveau_context(ctx);
+       struct nouveau_channel *chan = context_chan(ctx);
+       struct nouveau_grobj *celsius = context_eng3d(ctx);
+
+       if (nctx->fallback == HWTNL &&
+           ((ctx->Texture._TexMatEnabled & 1 << i) ||
+            ctx->Texture.Unit[i]._GenFlags)) {
+               BEGIN_RING(chan, celsius, NV10TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING(chan, 1);
+
+               BEGIN_RING(chan, celsius, TX_MATRIX(i), 16);
+               OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m);
+
+       } else {
+               BEGIN_RING(chan, celsius, NV10TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING(chan, 0);
+       }
 }
 
 static uint32_t
index 406e24c455d3d73bb658b072080cb046af26d774..0e592a16292e9aa8c675104e7e2a26415db031c1 100644 (file)
@@ -140,9 +140,7 @@ nv10_emit_fog(GLcontext *ctx, int emit)
        OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color));
 
        BEGIN_RING(chan, celsius, NV10TCL_FOG_EQUATION_CONSTANT, 3);
-       OUT_RINGf(chan, k[0]);
-       OUT_RINGf(chan, k[1]);
-       OUT_RINGf(chan, k[2]);
+       OUT_RINGp(chan, k, 3);
 
        context_dirty(ctx, FRAG);
 }
@@ -284,9 +282,7 @@ nv10_emit_light_source(GLcontext *ctx, int emit)
 
        if (l->_Flags & LIGHT_POSITIONAL) {
                BEGIN_RING(chan, celsius, NV10TCL_LIGHT_POSITION_X(i), 3);
-               OUT_RINGf(chan, l->_Position[0]);
-               OUT_RINGf(chan, l->_Position[1]);
-               OUT_RINGf(chan, l->_Position[2]);
+               OUT_RINGp(chan, l->_Position, 3);
 
                BEGIN_RING(chan, celsius,
                           NV10TCL_LIGHT_ATTENUATION_CONSTANT(i), 3);
@@ -296,14 +292,10 @@ nv10_emit_light_source(GLcontext *ctx, int emit)
 
        } else {
                BEGIN_RING(chan, celsius, NV10TCL_LIGHT_DIRECTION_X(i), 3);
-               OUT_RINGf(chan, l->_VP_inf_norm[0]);
-               OUT_RINGf(chan, l->_VP_inf_norm[1]);
-               OUT_RINGf(chan, l->_VP_inf_norm[2]);
+               OUT_RINGp(chan, l->_VP_inf_norm, 3);
 
                BEGIN_RING(chan, celsius, NV10TCL_LIGHT_HALF_VECTOR_X(i), 3);
-               OUT_RINGf(chan, l->_h_inf_norm[0]);
-               OUT_RINGf(chan, l->_h_inf_norm[1]);
-               OUT_RINGf(chan, l->_h_inf_norm[2]);
+               OUT_RINGp(chan, l->_h_inf_norm, 3);
        }
 
        if (l->_Flags & LIGHT_SPOT) {
@@ -312,13 +304,7 @@ nv10_emit_light_source(GLcontext *ctx, int emit)
                nv10_get_spot_coeff(l, k);
 
                BEGIN_RING(chan, celsius, NV10TCL_LIGHT_SPOT_CUTOFF_A(i), 7);
-               OUT_RINGf(chan, k[0]);
-               OUT_RINGf(chan, k[1]);
-               OUT_RINGf(chan, k[2]);
-               OUT_RINGf(chan, k[3]);
-               OUT_RINGf(chan, k[4]);
-               OUT_RINGf(chan, k[5]);
-               OUT_RINGf(chan, k[6]);
+               OUT_RINGp(chan, k, 7);
        }
 }
 
@@ -350,15 +336,11 @@ nv10_emit_material_ambient(GLcontext *ctx, int emit)
        }
 
        BEGIN_RING(chan, celsius, NV10TCL_LIGHT_MODEL_AMBIENT_R, 3);
-       OUT_RINGf(chan, c_scene[0]);
-       OUT_RINGf(chan, c_scene[1]);
-       OUT_RINGf(chan, c_scene[2]);
+       OUT_RINGp(chan, c_scene, 3);
 
        if (ctx->Light.ColorMaterialEnabled) {
                BEGIN_RING(chan, celsius, NV10TCL_MATERIAL_FACTOR_R, 3);
-               OUT_RINGf(chan, c_factor[0]);
-               OUT_RINGf(chan, c_factor[1]);
-               OUT_RINGf(chan, c_factor[2]);
+               OUT_RINGp(chan, c_factor, 3);
        }
 
        foreach(l, &ctx->Light.EnabledList) {
@@ -368,9 +350,7 @@ nv10_emit_material_ambient(GLcontext *ctx, int emit)
                                  l->_MatAmbient[0]);
 
                BEGIN_RING(chan, celsius, NV10TCL_LIGHT_AMBIENT_R(i), 3);
-               OUT_RINGf(chan, c_light[0]);
-               OUT_RINGf(chan, c_light[1]);
-               OUT_RINGf(chan, c_light[2]);
+               OUT_RINGp(chan, c_light, 3);
        }
 }
 
@@ -392,9 +372,7 @@ nv10_emit_material_diffuse(GLcontext *ctx, int emit)
                                  l->_MatDiffuse[0]);
 
                BEGIN_RING(chan, celsius, NV10TCL_LIGHT_DIFFUSE_R(i), 3);
-               OUT_RINGf(chan, c_light[0]);
-               OUT_RINGf(chan, c_light[1]);
-               OUT_RINGf(chan, c_light[2]);
+               OUT_RINGp(chan, c_light, 3);
        }
 }
 
@@ -412,9 +390,7 @@ nv10_emit_material_specular(GLcontext *ctx, int emit)
                                  l->_MatSpecular[0]);
 
                BEGIN_RING(chan, celsius, NV10TCL_LIGHT_SPECULAR_R(i), 3);
-               OUT_RINGf(chan, c_light[0]);
-               OUT_RINGf(chan, c_light[1]);
-               OUT_RINGf(chan, c_light[2]);
+               OUT_RINGp(chan, c_light, 3);
        }
 }
 
@@ -455,12 +431,7 @@ nv10_emit_material_shininess(GLcontext *ctx, int emit)
                k);
 
        BEGIN_RING(chan, celsius, NV10TCL_MATERIAL_SHININESS(0), 6);
-       OUT_RINGf(chan, k[0]);
-       OUT_RINGf(chan, k[1]);
-       OUT_RINGf(chan, k[2]);
-       OUT_RINGf(chan, k[3]);
-       OUT_RINGf(chan, k[4]);
-       OUT_RINGf(chan, k[5]);
+       OUT_RINGp(chan, k, 6);
 }
 
 void
@@ -474,12 +445,14 @@ nv10_emit_modelview(GLcontext *ctx, int emit)
        if (nctx->fallback != HWTNL)
                return;
 
-       if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled) {
+       if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled ||
+           (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) {
                BEGIN_RING(chan, celsius, NV10TCL_MODELVIEW0_MATRIX(0), 16);
                OUT_RINGm(chan, m->m);
        }
 
-       if (ctx->Light.Enabled) {
+       if (ctx->Light.Enabled ||
+           (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) {
                int i, j;
 
                BEGIN_RING(chan, celsius,
index db39ef70750cb3b81878631e29abd26bcf428963..789dcaa6b46383bfc51857a56564655e62664fb8 100644 (file)
@@ -297,9 +297,9 @@ nv20_hwctx_init(GLcontext *ctx)
        BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_ENABLE, 1);
        OUT_RING  (chan, 0);
 
-       BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_S(0),
-                  4 * NV20TCL_TX_GEN_S__SIZE);
-       for (i=0; i < 4 * NV20TCL_TX_GEN_S__SIZE; i++)
+       BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_MODE_S(0),
+                  4 * NV20TCL_TX_GEN_MODE_S__SIZE);
+       for (i=0; i < 4 * NV20TCL_TX_GEN_MODE_S__SIZE; i++)
                OUT_RING(chan, 0);
 
        BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3);
@@ -497,10 +497,14 @@ const struct nouveau_driver nv20_driver = {
                nv20_emit_tex_env,
                nv20_emit_tex_env,
                nv20_emit_tex_env,
-               nv10_emit_tex_gen,
-               nv10_emit_tex_gen,
-               nv10_emit_tex_gen,
-               nv10_emit_tex_gen,
+               nv20_emit_tex_gen,
+               nv20_emit_tex_gen,
+               nv20_emit_tex_gen,
+               nv20_emit_tex_gen,
+               nv20_emit_tex_mat,
+               nv20_emit_tex_mat,
+               nv20_emit_tex_mat,
+               nv20_emit_tex_mat,
                nv20_emit_tex_obj,
                nv20_emit_tex_obj,
                nv20_emit_tex_obj,
index 18574e9be6413073ecb72fec22706dae1174f7e5..8adecef2c4eee867a9c63818c5c6a2a3b4af2bed 100644 (file)
@@ -67,6 +67,12 @@ void
 nv20_emit_frag(GLcontext *ctx, int emit);
 
 /* nv20_state_tex.c */
+void
+nv20_emit_tex_gen(GLcontext *ctx, int emit);
+
+void
+nv20_emit_tex_mat(GLcontext *ctx, int emit);
+
 void
 nv20_emit_tex_obj(GLcontext *ctx, int emit);
 
index d638541df9eb81dc7090ed79d719ab1c336e5cf6..21da4f7af1643dd77f4dbaf5fe72f359b1538373 100644 (file)
@@ -106,13 +106,11 @@ nv20_emit_viewport(GLcontext *ctx, int emit)
        struct nouveau_grobj *kelvin = context_eng3d(ctx);
        struct gl_framebuffer *fb = ctx->DrawBuffer;
        float a[4] = {};
-       int i;
 
        get_viewport_translate(ctx, a);
 
        BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4);
-       for (i = 0; i < 4; i++)
-               OUT_RINGf(chan, a[i]);
+       OUT_RINGp(chan, a, 4);
 
        BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1);
        OUT_RING(chan, (fb->Width - 1) << 16);
index 92870105f96beac422c1a74578b04e90ad05cb43..e46118e4fce53a9742c7fd97a29d88f1db7c376a 100644 (file)
 #include "nouveau_util.h"
 #include "nv20_driver.h"
 
+#define TX_GEN_MODE(i, j) (NV20TCL_TX_GEN_MODE_S(i) + 4 * (j))
+#define TX_GEN_COEFF(i, j) (NV20TCL_TX_GEN_COEFF_S_A(i) + 16 * (j))
+#define TX_MATRIX(i) (NV20TCL_TX0_MATRIX(0) + 64 * (i))
+
+void
+nv20_emit_tex_gen(GLcontext *ctx, int emit)
+{
+       const int i = emit - NOUVEAU_STATE_TEX_GEN0;
+       struct nouveau_context *nctx = to_nouveau_context(ctx);
+       struct nouveau_channel *chan = context_chan(ctx);
+       struct nouveau_grobj *kelvin = context_eng3d(ctx);
+       struct gl_texture_unit *unit = &ctx->Texture.Unit[i];
+       int j;
+
+       for (j = 0; j < 4; j++) {
+               if (nctx->fallback == HWTNL && (unit->TexGenEnabled & 1 << j)) {
+                       struct gl_texgen *coord = get_texgen_coord(unit, j);
+                       float *k = get_texgen_coeff(coord);
+
+                       if (k) {
+                               BEGIN_RING(chan, kelvin, TX_GEN_COEFF(i, j), 4);
+                               OUT_RINGp(chan, k, 4);
+                       }
+
+                       BEGIN_RING(chan, kelvin, TX_GEN_MODE(i, j), 1);
+                       OUT_RING(chan, nvgl_texgen_mode(coord->Mode));
+
+               } else {
+                       BEGIN_RING(chan, kelvin, TX_GEN_MODE(i, j), 1);
+                       OUT_RING(chan, 0);
+               }
+       }
+}
+
+void
+nv20_emit_tex_mat(GLcontext *ctx, int emit)
+{
+       const int i = emit - NOUVEAU_STATE_TEX_MAT0;
+       struct nouveau_context *nctx = to_nouveau_context(ctx);
+       struct nouveau_channel *chan = context_chan(ctx);
+       struct nouveau_grobj *kelvin = context_eng3d(ctx);
+
+       if (nctx->fallback == HWTNL &&
+           (ctx->Texture._TexMatEnabled & 1 << i)) {
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING(chan, 1);
+
+               BEGIN_RING(chan, kelvin, TX_MATRIX(i), 16);
+               OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m);
+
+       } else {
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING(chan, 0);
+       }
+}
+
 static uint32_t
 get_tex_format_pot(struct gl_texture_image *ti)
 {
index 43f8c7231226fc8712919f4e0a9d680690f1cf56..62efe80fe4b763d6582f885d67a44e0d0f2c60e6 100644 (file)
@@ -139,9 +139,7 @@ nv20_emit_fog(GLcontext *ctx, int emit)
        OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color));
 
        BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3);
-       OUT_RINGf(chan, k[0]);
-       OUT_RINGf(chan, k[1]);
-       OUT_RINGf(chan, k[2]);
+       OUT_RINGp(chan, k, 3);
 }
 
 void
@@ -176,9 +174,7 @@ nv20_emit_light_source(GLcontext *ctx, int emit)
 
        if (l->_Flags & LIGHT_POSITIONAL) {
                BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_POSITION_X(i), 3);
-               OUT_RINGf(chan, l->_Position[0]);
-               OUT_RINGf(chan, l->_Position[1]);
-               OUT_RINGf(chan, l->_Position[2]);
+               OUT_RINGp(chan, l->_Position, 3);
 
                BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_ATTENUATION_CONSTANT(i), 3);
                OUT_RINGf(chan, l->ConstantAttenuation);
@@ -187,14 +183,10 @@ nv20_emit_light_source(GLcontext *ctx, int emit)
 
        } else {
                BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_DIRECTION_X(i), 3);
-               OUT_RINGf(chan, l->_VP_inf_norm[0]);
-               OUT_RINGf(chan, l->_VP_inf_norm[1]);
-               OUT_RINGf(chan, l->_VP_inf_norm[2]);
+               OUT_RINGp(chan, l->_VP_inf_norm, 3);
 
                BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_HALF_VECTOR_X(i), 3);
-               OUT_RINGf(chan, l->_h_inf_norm[0]);
-               OUT_RINGf(chan, l->_h_inf_norm[1]);
-               OUT_RINGf(chan, l->_h_inf_norm[2]);
+               OUT_RINGp(chan, l->_h_inf_norm, 3);
        }
 
        if (l->_Flags & LIGHT_SPOT) {
@@ -203,13 +195,7 @@ nv20_emit_light_source(GLcontext *ctx, int emit)
                nv10_get_spot_coeff(l, k);
 
                BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_SPOT_CUTOFF_A(i), 7);
-               OUT_RINGf(chan, k[0]);
-               OUT_RINGf(chan, k[1]);
-               OUT_RINGf(chan, k[2]);
-               OUT_RINGf(chan, k[3]);
-               OUT_RINGf(chan, k[4]);
-               OUT_RINGf(chan, k[5]);
-               OUT_RINGf(chan, k[6]);
+               OUT_RINGp(chan, k, 7);
        }
 }
 
@@ -246,15 +232,11 @@ nv20_emit_material_ambient(GLcontext *ctx, int emit)
        }
 
        BEGIN_RING(chan, kelvin, m_scene[side], 3);
-       OUT_RINGf(chan, c_scene[0]);
-       OUT_RINGf(chan, c_scene[1]);
-       OUT_RINGf(chan, c_scene[2]);
+       OUT_RINGp(chan, c_scene, 3);
 
        if (ctx->Light.ColorMaterialEnabled) {
                BEGIN_RING(chan, kelvin, m_factor[side], 3);
-               OUT_RINGf(chan, c_factor[0]);
-               OUT_RINGf(chan, c_factor[1]);
-               OUT_RINGf(chan, c_factor[2]);
+               OUT_RINGp(chan, c_factor, 3);
        }
 
        foreach(l, &ctx->Light.EnabledList) {
@@ -266,9 +248,7 @@ nv20_emit_material_ambient(GLcontext *ctx, int emit)
                                  l->_MatAmbient[side]);
 
                BEGIN_RING(chan, kelvin, m_light[side], 3);
-               OUT_RINGf(chan, c_light[0]);
-               OUT_RINGf(chan, c_light[1]);
-               OUT_RINGf(chan, c_light[2]);
+               OUT_RINGp(chan, c_light, 3);
        }
 }
 
@@ -295,9 +275,7 @@ nv20_emit_material_diffuse(GLcontext *ctx, int emit)
                                  l->_MatDiffuse[side]);
 
                BEGIN_RING(chan, kelvin, m_light[side], 3);
-               OUT_RINGf(chan, c_light[0]);
-               OUT_RINGf(chan, c_light[1]);
-               OUT_RINGf(chan, c_light[2]);
+               OUT_RINGp(chan, c_light, 3);
        }
 }
 
@@ -318,9 +296,7 @@ nv20_emit_material_specular(GLcontext *ctx, int emit)
                                  l->_MatSpecular[side]);
 
                BEGIN_RING(chan, kelvin, m_light[side], 3);
-               OUT_RINGf(chan, c_light[0]);
-               OUT_RINGf(chan, c_light[1]);
-               OUT_RINGf(chan, c_light[2]);
+               OUT_RINGp(chan, c_light, 3);
        }
 }
 
@@ -340,12 +316,7 @@ nv20_emit_material_shininess(GLcontext *ctx, int emit)
                k);
 
        BEGIN_RING(chan, kelvin, mthd[side], 6);
-       OUT_RINGf(chan, k[0]);
-       OUT_RINGf(chan, k[1]);
-       OUT_RINGf(chan, k[2]);
-       OUT_RINGf(chan, k[3]);
-       OUT_RINGf(chan, k[4]);
-       OUT_RINGf(chan, k[5]);
+       OUT_RINGp(chan, k, 6);
 }
 
 void
@@ -359,12 +330,14 @@ nv20_emit_modelview(GLcontext *ctx, int emit)
        if (nctx->fallback != HWTNL)
                return;
 
-       if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled) {
+       if (ctx->Light._NeedEyeCoords || ctx->Fog.Enabled ||
+           (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) {
                BEGIN_RING(chan, kelvin, NV20TCL_MODELVIEW0_MATRIX(0), 16);
                OUT_RINGm(chan, m->m);
        }
 
-       if (ctx->Light.Enabled) {
+       if (ctx->Light.Enabled ||
+           (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD)) {
                int i, j;
 
                BEGIN_RING(chan, kelvin,
index 2f2b8d94dca12b359f94e059e6a72ecaf8ac6c13..ad43a8ca9203e3fb4422c8833848ec241bb26ea7 100644 (file)
@@ -189,7 +189,8 @@ void r200FlushElts(GLcontext *ctx)
    if (R200_ELT_BUF_SZ > elt_used)
      radeonReturnDmaRegion(&rmesa->radeon, R200_ELT_BUF_SZ - elt_used);
 
-   if (radeon_is_debug_enabled(RADEON_SYNC, RADEON_CRITICAL)) {
+   if (radeon_is_debug_enabled(RADEON_SYNC, RADEON_CRITICAL)
+         && !rmesa->radeon.radeonScreen->kernel_mm) {
       radeon_print(RADEON_SYNC, RADEON_NORMAL, "%s: Syncing\n", __FUNCTION__);
       radeonFinish( rmesa->radeon.glCtx );
    }
index 9c2ac05ad6c55a4b489dd02eef939306e298aa05..29d7bed8b6a993d364fa8df949e931c356a08d93 100644 (file)
@@ -2496,11 +2496,10 @@ void r200InitStateFuncs( radeonContextPtr radeon, struct dd_function_table *func
    functions->DrawBuffer               = radeonDrawBuffer;
    functions->ReadBuffer               = radeonReadBuffer;
 
-   if (radeon->radeonScreen->kernel_mm) {
-          functions->CopyPixels                = _mesa_meta_CopyPixels;
-          functions->DrawPixels                = _mesa_meta_DrawPixels;
+   functions->CopyPixels                = _mesa_meta_CopyPixels;
+   functions->DrawPixels                = _mesa_meta_DrawPixels;
+   if (radeon->radeonScreen->kernel_mm)
           functions->ReadPixels                = radeonReadPixels;
-   }
 
    functions->AlphaFunc                        = r200AlphaFunc;
    functions->BlendColor               = r200BlendColor;
index f3f558b7def05c50a6e7133ab6945e426d621327..d43e14581e931faa03cc3eb30bd398731e5ef78b 100644 (file)
@@ -404,8 +404,9 @@ static GLuint r200EnsureEmitSize( GLcontext * ctx , GLubyte* vimap_rev )
          rendering code may decide convert to elts.
         In that case we have to make pessimistic prediction.
         and use larger of 2 paths. */
-      const GLuint elts = ELTS_BUFSZ(nr_aos);
-      const GLuint index = INDEX_BUFSZ;
+      const GLuint elt_count =(VB->Primitive[i].count/GET_MAX_HW_ELTS() + 1);
+      const GLuint elts = ELTS_BUFSZ(nr_aos) * elt_count;
+      const GLuint index = INDEX_BUFSZ * elt_count;
       const GLuint vbuf = VBUF_BUFSZ;
       if ( (!VB->Elts && VB->Primitive[i].count >= MAX_CONVERSION_SIZE)
          || vbuf > index + elts)
@@ -687,25 +688,34 @@ static char *getFallbackString(GLuint bit)
 
 void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 {
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   GLuint oldfallback = rmesa->radeon.TclFallback;
-
-   if (mode) {
-      rmesa->radeon.TclFallback |= bit;
-      if (oldfallback == 0) {
-        if (R200_DEBUG & RADEON_FALLBACKS)
-           fprintf(stderr, "R200 begin tcl fallback %s\n",
-                   getFallbackString( bit ));
-        transition_to_swtnl( ctx );
-      }
-   }
-   else {
-      rmesa->radeon.TclFallback &= ~bit;
-      if (oldfallback == bit) {
-        if (R200_DEBUG & RADEON_FALLBACKS)
-           fprintf(stderr, "R200 end tcl fallback %s\n",
-                   getFallbackString( bit ));
-        transition_to_hwtnl( ctx );
-      }
-   }
+       r200ContextPtr rmesa = R200_CONTEXT(ctx);
+       GLuint oldfallback = rmesa->radeon.TclFallback;
+
+       if (mode) {
+               if (oldfallback == 0) {
+                       /* We have to flush before transition */
+                       if ( rmesa->radeon.dma.flush )
+                               rmesa->radeon.dma.flush( rmesa->radeon.glCtx );
+
+                       if (R200_DEBUG & RADEON_FALLBACKS)
+                               fprintf(stderr, "R200 begin tcl fallback %s\n",
+                                               getFallbackString( bit ));
+                       rmesa->radeon.TclFallback |= bit;
+                       transition_to_swtnl( ctx );
+               } else
+                       rmesa->radeon.TclFallback |= bit;
+       } else {
+               if (oldfallback == bit) {
+                       /* We have to flush before transition */
+                       if ( rmesa->radeon.dma.flush )
+                               rmesa->radeon.dma.flush( rmesa->radeon.glCtx );
+
+                       if (R200_DEBUG & RADEON_FALLBACKS)
+                               fprintf(stderr, "R200 end tcl fallback %s\n",
+                                               getFallbackString( bit ));
+                       rmesa->radeon.TclFallback &= ~bit;
+                       transition_to_hwtnl( ctx );
+               } else
+                       rmesa->radeon.TclFallback &= ~bit;
+       }
 }
index 710cae727a1a321b7874462251505dc18ebf7b59..b6dfe28def99e6adfa2aac39df1dd5a9fff72d1e 100644 (file)
@@ -190,6 +190,17 @@ static unsigned int use_source(struct r500_fragment_program_code* code, struct r
        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.
@@ -205,6 +216,14 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair
 
        int 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);
 
@@ -252,8 +271,8 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair
        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);
+       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;
@@ -469,9 +488,8 @@ void r500BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compi
        if (compiler->Base.Error)
                return;
 
-       assert(code->inst_end >= 0);
-
-       if ((code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) {
+       if (code->inst_end == -1 ||
+           (code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) {
                /* This may happen when dead-code elimination is disabled or
                 * when most of the fragment program logic is leading to a KIL */
                if (code->inst_end >= 511) {
index c1c0181fac1653893d21ffe97cc754db18fc72d1..9d289fce3429e439dce7cf5c4c59b77f2dfcf338 100644 (file)
@@ -75,14 +75,14 @@ struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = {
        {
                .Opcode = RC_OPCODE_DDX,
                .Name = "DDX",
-               .NumSrcRegs = 1,
+               .NumSrcRegs = 2,
                .HasDstReg = 1,
                .IsComponentwise = 1
        },
        {
                .Opcode = RC_OPCODE_DDY,
                .Name = "DDY",
-               .NumSrcRegs = 1,
+               .NumSrcRegs = 2,
                .HasDstReg = 1,
                .IsComponentwise = 1
        },
index fff5b0c21735a5158f96e8fc4c80429b56721856..3a26e7daaf9563bf58bd886c9d088f02e6e1de8d 100644 (file)
@@ -159,11 +159,6 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c,
        int nargs = opcode->NumSrcRegs;
        int i;
 
-       /* Special case for DDX/DDY (MDH/MDV). */
-       if (inst->Opcode == RC_OPCODE_DDX || inst->Opcode == RC_OPCODE_DDY) {
-               nargs++;
-       }
-
        for(i = 0; i < opcode->NumSrcRegs; ++i) {
                int source;
                if (needrgb && !istranscendent) {
index b5c08aea49e2aa0578c65ce43145f697a649f496..f5b7d57eab7f368b84a79bb47b6ad87089e90ea2 100644 (file)
@@ -506,6 +506,46 @@ static void transform_r300_vertex_ABS(struct radeon_compiler* c,
        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 two temps and three extra slots,
+        * but should be equivalent:
+        *
+        * SLT tmp0, src0, 0.0
+        * SGE tmp1, src0, 0.0
+        * MUL tmp0, tmp0, src1
+        * MAD dst, src2, tmp1, tmp0
+        *
+        * Yes, I know, I'm a mad scientist. ~ C. */
+       int tempreg0 = rc_find_free_temporary(c);
+       int tempreg1 = rc_find_free_temporary(c);
+
+       /* SLT tmp0, src0, 0.0 */
+       emit2(c, inst->Prev, RC_OPCODE_SLT, 0,
+               dstreg(RC_FILE_TEMPORARY, tempreg0),
+               inst->U.I.SrcReg[0], builtin_zero);
+
+       /* SGE tmp1, src0, 0.0 */
+       emit2(c, inst->Prev, RC_OPCODE_SGE, 0,
+               dstreg(RC_FILE_TEMPORARY, tempreg1),
+               inst->U.I.SrcReg[0], builtin_zero);
+
+       /* MUL tmp0, tmp0, src1 */
+       emit2(c, inst->Prev, RC_OPCODE_MUL, 0,
+               dstreg(RC_FILE_TEMPORARY, tempreg0),
+               srcreg(RC_FILE_TEMPORARY, tempreg0), inst->U.I.SrcReg[1]);
+
+       /* MAD dst, src2, tmp1, tmp0 */
+       emit3(c, inst->Prev, RC_OPCODE_MAD, inst->U.I.SaturateMode,
+               inst->U.I.DstReg,
+               inst->U.I.SrcReg[2], srcreg(RC_FILE_TEMPORARY, tempreg1), srcreg(RC_FILE_TEMPORARY, tempreg0));
+
+       rc_remove_instruction(inst);
+}
+
 /**
  * For use with radeonLocalTransform, this transforms non-native ALU
  * instructions of the r300 up to r500 vertex engine.
@@ -517,6 +557,7 @@ int r300_transform_vertex_alu(
 {
        switch(inst->U.I.Opcode) {
        case RC_OPCODE_ABS: transform_r300_vertex_ABS(c, inst); return 1;
+       case RC_OPCODE_CMP: transform_r300_vertex_CMP(c, inst); return 1;
        case RC_OPCODE_DP3: transform_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;
index e2dbb1dbf400aab51613dbfdfb3df691f1ec61e6..c40802aec6e72e6476669628dffe1d78b776c362 100644 (file)
@@ -77,12 +77,29 @@ static int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom)
        cnt = vpu_count(atom->cmd);
 
        if (r300->radeon.radeonScreen->kernel_mm) {
-               extra = 5;
+               extra = 3;
        }
 
        return cnt ? (cnt * 4) + extra : 0;
 }
 
+static int check_vpp(GLcontext *ctx, struct radeon_state_atom *atom)
+{
+    r300ContextPtr r300 = R300_CONTEXT(ctx);
+    int cnt;
+    int extra = 1;
+
+    if (r300->radeon.radeonScreen->kernel_mm) {
+        cnt = r300->selected_vp->code.constants.Count * 4;
+        extra = 3;
+    } else {
+        cnt = vpu_count(atom->cmd);
+        extra = 1;
+    }
+
+    return cnt ? (cnt * 4) + extra : 0;
+}
+
 void r300_emit_vpu(struct r300_context *r300,
                    uint32_t *data,
                    unsigned len,
@@ -101,15 +118,26 @@ static void emit_vpu_state(GLcontext *ctx, struct radeon_state_atom * atom)
 {
     r300ContextPtr r300 = R300_CONTEXT(ctx);
     drm_r300_cmd_header_t cmd;
-    uint32_t addr, ndw;
+    uint32_t addr;
 
     cmd.u = atom->cmd[0];
     addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo;
-    ndw = atom->check(ctx, atom);
 
     r300_emit_vpu(r300, &atom->cmd[1], vpu_count(atom->cmd) * 4, addr);
 }
 
+static void emit_vpp_state(GLcontext *ctx, struct radeon_state_atom * atom)
+{
+    r300ContextPtr r300 = R300_CONTEXT(ctx);
+    drm_r300_cmd_header_t cmd;
+    uint32_t addr;
+
+    cmd.u = atom->cmd[0];
+    addr = (cmd.vpu.adrhi << 8) | cmd.vpu.adrlo;
+
+    r300_emit_vpu(r300, &atom->cmd[1], r300->selected_vp->code.constants.Count * 4, addr);
+}
+
 void r500_emit_fp(struct r300_context *r300,
                   uint32_t *data,
                   unsigned len,
@@ -785,11 +813,11 @@ void r300InitCmdBuf(r300ContextPtr r300)
                        r300->hw.vpi.emit = emit_vpu_state;
 
                if (is_r500) {
-                       ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
+                       ALLOC_STATE(vpp, vpp, R300_VPP_CMDSIZE, 0);
                        r300->hw.vpp.cmd[0] =
                                cmdvpu(r300->radeon.radeonScreen, R500_PVS_CONST_START, 0);
                        if (r300->radeon.radeonScreen->kernel_mm)
-                               r300->hw.vpp.emit = emit_vpu_state;
+                               r300->hw.vpp.emit = emit_vpp_state;
 
                        ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
                        r300->hw.vps.cmd[0] =
@@ -806,11 +834,11 @@ void r300InitCmdBuf(r300ContextPtr r300)
                                        r300->hw.vpucp[i].emit = emit_vpu_state;
                        }
                } else {
-                       ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
+                       ALLOC_STATE(vpp, vpp, R300_VPP_CMDSIZE, 0);
                        r300->hw.vpp.cmd[0] =
                                cmdvpu(r300->radeon.radeonScreen, R300_PVS_CONST_START, 0);
                        if (r300->radeon.radeonScreen->kernel_mm)
-                               r300->hw.vpp.emit = emit_vpu_state;
+                               r300->hw.vpp.emit = emit_vpp_state;
 
                        ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
                        r300->hw.vps.cmd[0] =
index 61ea5e4d9a35fb5c88fefe56ca20a9279996db0c..0646da46249ea9b5fe36714f0031ff838b03bdb9 100644 (file)
@@ -256,6 +256,19 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog
 
        fp->InputsRead = compiler.Base.Program.InputsRead;
 
+       /* Clear the fog/wpos_attr if code accessing these
+        * attributes has been removed during compilation
+        */
+       if (fp->fog_attr != FRAG_ATTRIB_MAX) {
+               if (!(fp->InputsRead & (1 << fp->fog_attr)))
+                       fp->fog_attr = FRAG_ATTRIB_MAX;
+       }
+
+       if (fp->wpos_attr != FRAG_ATTRIB_MAX) {
+               if (!(fp->InputsRead & (1 << fp->wpos_attr)))
+                       fp->wpos_attr = FRAG_ATTRIB_MAX;
+       }
+
        rc_destroy(&compiler.Base);
 }
 
index 749a2464e7cbf3ee66acc1e757e071542677e7b1..e660b1fb3bbb7b2fa704469824d52e2287fcdc83 100644 (file)
@@ -2396,11 +2396,10 @@ void r300InitStateFuncs(radeonContextPtr radeon, struct dd_function_table *funct
        functions->DrawBuffer = radeonDrawBuffer;
        functions->ReadBuffer = radeonReadBuffer;
 
-       if (radeon->radeonScreen->kernel_mm) {
-               functions->CopyPixels = _mesa_meta_CopyPixels;
-               functions->DrawPixels = _mesa_meta_DrawPixels;
+       functions->CopyPixels = _mesa_meta_CopyPixels;
+       functions->DrawPixels = _mesa_meta_DrawPixels;
+       if (radeon->radeonScreen->kernel_mm)
                functions->ReadPixels = radeonReadPixels;
-       }
 }
 
 void r300InitShaderFunctions(r300ContextPtr r300)
index 129004fee7850d97d0cea5572a9e6de699ee3699..a1fe3780294e5c6c04d113057531f80aceb397f6 100644 (file)
@@ -263,15 +263,25 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
        rc_move_output(&compiler.Base, VERT_RESULT_PSIZ, VERT_RESULT_PSIZ, WRITEMASK_X);
 
        if (vp->key.WPosAttr != FRAG_ATTRIB_MAX) {
-               rc_copy_output(&compiler.Base,
-                       VERT_RESULT_HPOS,
-                       vp->key.WPosAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0);
+               unsigned int vp_wpos_attr = vp->key.WPosAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0;
+
+               /* Set empty writemask for instructions writing to vp_wpos_attr
+                * before moving the wpos attr there.
+                * Such instructions will be removed by DCE.
+                */
+               rc_move_output(&compiler.Base, vp_wpos_attr, vp->key.WPosAttr, 0);
+               rc_copy_output(&compiler.Base, VERT_RESULT_HPOS, vp_wpos_attr);
        }
 
        if (vp->key.FogAttr != FRAG_ATTRIB_MAX) {
-               rc_move_output(&compiler.Base,
-                       VERT_RESULT_FOGC,
-                       vp->key.FogAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0, WRITEMASK_X);
+               unsigned int vp_fog_attr = vp->key.FogAttr - FRAG_ATTRIB_TEX0 + VERT_RESULT_TEX0;
+
+               /* Set empty writemask for instructions writing to vp_fog_attr
+                * before moving the fog attr there.
+                * Such instructions will be removed by DCE.
+                */
+               rc_move_output(&compiler.Base, vp_fog_attr, vp->key.FogAttr, 0);
+               rc_move_output(&compiler.Base, VERT_RESULT_FOGC, vp_fog_attr, WRITEMASK_X);
        }
 
        r3xx_compile_vertex_program(&compiler);
@@ -382,7 +392,11 @@ void r300SetupVertexProgram(r300ContextPtr rmesa)
        R300_STATECHANGE(rmesa, vap_cntl);
        R300_STATECHANGE(rmesa, vpp);
        param_count = r300VertexProgUpdateParams(ctx, prog, (float *)&rmesa->hw.vpp.cmd[R300_VPP_PARAM_0]);
-       bump_vpu_count(rmesa->hw.vpp.cmd, param_count);
+       if (!rmesa->radeon.radeonScreen->kernel_mm && param_count > 255 * 4) {
+               WARN_ONCE("Too many VP params, expect rendering errors\n");
+       }
+       /* Prevent the overflow (vpu.count is u8) */
+       bump_vpu_count(rmesa->hw.vpp.cmd, MIN2(255 * 4, param_count));
        param_count /= 4;
 
        r300EmitVertexProgram(rmesa, R300_PVS_CODE_START, &(prog->code));
@@ -395,6 +409,6 @@ void r300SetupVertexProgram(r300ContextPtr rmesa)
        rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = (0 << R300_PVS_FIRST_INST_SHIFT) | (inst_count << R300_PVS_XYZW_VALID_INST_SHIFT) |
                                (inst_count << R300_PVS_LAST_INST_SHIFT);
 
-       rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = (0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) | (param_count << R300_PVS_MAX_CONST_ADDR_SHIFT);
+       rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = (0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) | ((param_count - 1) << R300_PVS_MAX_CONST_ADDR_SHIFT);
        rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = (inst_count << R300_PVS_LAST_VTX_SRC_INST_SHIFT);
 }
index 2953ffd0288651f48fe06f7c1066757089f4321e..1da31e7b2b4e2dec09ab62ac58b1b23912a8d377 100644 (file)
@@ -615,7 +615,7 @@ static GLuint translate_logicop(GLenum logicop)
        case GL_XOR:
                return 0x66;
        case GL_EQUIV:
-               return 0xaa;
+               return 0x99;
        case GL_AND_REVERSE:
                return 0x44;
        case GL_AND_INVERTED:
@@ -1861,10 +1861,9 @@ void r700InitStateFuncs(radeonContextPtr radeon, struct dd_function_table *funct
        functions->DrawBuffer = radeonDrawBuffer;
        functions->ReadBuffer = radeonReadBuffer;
 
-       if (radeon->radeonScreen->kernel_mm) {
-               functions->CopyPixels = _mesa_meta_CopyPixels;
-               functions->DrawPixels = _mesa_meta_DrawPixels;
+       functions->CopyPixels = _mesa_meta_CopyPixels;
+       functions->DrawPixels = _mesa_meta_DrawPixels;
+       if (radeon->radeonScreen->kernel_mm)
                functions->ReadPixels = radeonReadPixels;
-       }
 }
 
index 22499bc38d1b8fb981f59626f0c7cc9b3b86daf8..6b7690cf8b397dc2275e36826369116143d21332 100644 (file)
@@ -184,9 +184,6 @@ void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
        radeon_print(RADEON_DMA, RADEON_NORMAL, "%s size %d minimum_size %d\n",
                        __FUNCTION__, size, rmesa->dma.minimum_size);
 
-       if (!is_empty_list(&rmesa->dma.reserved))
-               radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo);
-
        if (is_empty_list(&rmesa->dma.free)
              || last_elem(&rmesa->dma.free)->bo->size < size) {
                dma_bo = CALLOC_STRUCT(radeon_dma_bo);
@@ -336,9 +333,6 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
                legacy_track_pending(rmesa->radeonScreen->bom, 0);
        }
 
-       if (!is_empty_list(&rmesa->dma.reserved))
-               radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo);
-
        /* move waiting bos to free list.
           wait list provides gpu time to handle data before reuse */
        foreach_s(dma_bo, temp, &rmesa->dma.wait) {
@@ -368,6 +362,7 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa)
 
        /* move reserved to wait list */
        foreach_s(dma_bo, temp, &rmesa->dma.reserved) {
+               radeon_bo_unmap(dma_bo->bo);
                /* free objects that are too small to be used because of large request */
                if (dma_bo->bo->size < rmesa->dma.minimum_size) {
                   radeon_bo_unref(dma_bo->bo);
index 0afbc19c1273a71694f9979d39325fd26b670080..539b067742fda0b588a0b13fe98af4d343547f55 100644 (file)
@@ -2249,11 +2249,10 @@ void radeonInitStateFuncs( GLcontext *ctx , GLboolean dri2 )
 
    ctx->Driver.DrawBuffer              = radeonDrawBuffer;
    ctx->Driver.ReadBuffer              = radeonReadBuffer;
-   if (dri2) {
-          ctx->Driver.CopyPixels               = _mesa_meta_CopyPixels;
-          ctx->Driver.DrawPixels               = _mesa_meta_DrawPixels;
+   ctx->Driver.CopyPixels               = _mesa_meta_CopyPixels;
+   ctx->Driver.DrawPixels               = _mesa_meta_DrawPixels;
+   if (dri2)
           ctx->Driver.ReadPixels               = radeonReadPixels;
-   }
 
    ctx->Driver.AlphaFunc               = radeonAlphaFunc;
    ctx->Driver.BlendEquationSeparate   = radeonBlendEquationSeparate;
index cc59eefdb2dbf5bd4c84c66d1402d8b5c9b4eba8..d2cf6dbc55b1893cb6c39c0e7070d6d5ee4b271d 100644 (file)
@@ -5,6 +5,8 @@ include $(TOP)/configs/current
 
 LIBNAME = swrast_dri.so
 
+DRIVER_DEFINES = -D__NOT_HAVE_DRM_H
+
 DRIVER_SOURCES = \
        swrast.c \
        swrast_span.c
@@ -18,7 +20,7 @@ ASM_SOURCES =
 SWRAST_COMMON_SOURCES = \
        ../../common/driverfuncs.c \
        ../common/utils.c \
-       ../common/dri_sw.c
+       ../common/drisw_util.c
 
 include ../Makefile.template
 
index e9ca99a86f0d20ae60591ebf39935db1908f9a19..8b68281fab0c39255f4d8248bca98c02bfaf3ac2 100644 (file)
@@ -206,12 +206,20 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
     free(rb);
 }
 
+/* see bytes_per_line in libGL */
+static INLINE int
+bytes_per_line(unsigned pitch_bits, unsigned mul)
+{
+   unsigned mask = mul - 1;
+
+   return ((pitch_bits + mask) & ~mask) / 8;
+}
+
 static GLboolean
 swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
                           GLenum internalFormat, GLuint width, GLuint height)
 {
     struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
-    unsigned mask = PITCH_ALIGN_BITS - 1;
 
     TRACE;
 
@@ -219,8 +227,7 @@ swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
     rb->Width = width;
     rb->Height = height;
 
-    /* always pad to PITCH_ALIGN_BITS */
-    xrb->pitch = ((width * xrb->bpp + mask) & ~mask) / 8;
+    xrb->pitch = bytes_per_line(width * xrb->bpp, 32);
 
     return GL_TRUE;
 }
@@ -394,8 +401,10 @@ dri_swap_buffers(__DRIdrawable * dPriv)
 
     fb = &drawable->Base;
 
-    frontrb = swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
-    backrb = swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+    frontrb =
+       swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+    backrb =
+       swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
 
     /* check for signle-buffered */
     if (backrb == NULL)
index 77670d89a5ec5792c2d85ffc51c0bdc10a5f71b8..6679061a983163a8cc7c1f82439b02c1b40b825e 100644 (file)
@@ -30,7 +30,7 @@
 #include <GL/gl.h>
 #include <GL/internal/dri_interface.h>
 #include "main/mtypes.h"
-#include "dri_sw.h"
+#include "drisw_util.h"
 
 
 /**
@@ -124,14 +124,6 @@ swrast_renderbuffer(struct gl_renderbuffer *rb)
 #define PF_R3G3B2     3                /**<  8bpp TrueColor:  3-R, 3-G, 2-B bits */
 #define PF_X8R8G8B8   4                /**< 32bpp TrueColor:  8-R, 8-G, 8-B bits */
 
-/**
- * Renderbuffer pitch alignment (in bits).
- *
- * The xorg loader requires padding images to 32 bits. However, this should
- * become a screen/drawable parameter XXX
- */
-#define PITCH_ALIGN_BITS 32
-
 
 /* swrast_span.c */
 
index c5681e34a916beeaf80e1df8ca1214b12fd8436e..c7d0bfdac72b6fdb8f11aae3fcd316923e942082 100644 (file)
@@ -236,7 +236,7 @@ static const GLubyte kernel[16] = {
    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
 #define INIT_PIXEL_PTR(P, X, Y) \
    GLushort *P = (GLushort *)row;
-#define INC_PIXEL_PTR(P) P += 2
+#define INC_PIXEL_PTR(P) P++
 #define STORE_PIXEL(DST, X, Y, VALUE) \
    STORE_PIXEL_R5G6B5(DST, X, Y, VALUE)
 #define FETCH_PIXEL(DST, SRC) \
index 079726ae4abfc2488da04ad1b34d432281587f9f..1e9405eebfba725d47373a3416f9e7fbf0c19171 100644 (file)
@@ -37,7 +37,7 @@
 #define _SWRAST_SPANTEMP_ONCE
 
 static INLINE void
-PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p )
+PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLvoid *p )
 {
     __DRIcontext *ctx = swrast_context(glCtx)->cPriv;
     __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer)->dPriv;
@@ -168,7 +168,8 @@ NAME(put_row)( GLcontext *ctx, struct gl_renderbuffer *rb,
    if (mask) {
       for (i = 0; i < count; i++) {
          if (mask[i]) {
-            RB_TYPE pixel[4];
+            RB_TYPE row[4];
+            INIT_PIXEL_PTR(pixel, x, y);
             STORE_PIXEL(pixel, x + i, y, src[i]);
             PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel);
          }
@@ -200,7 +201,8 @@ NAME(put_row_rgb)( GLcontext *ctx, struct gl_renderbuffer *rb,
    if (mask) {
       for (i = 0; i < count; i++) {
          if (mask[i]) {
-            RB_TYPE pixel[4];
+            RB_TYPE row[4];
+            INIT_PIXEL_PTR(pixel, x, y);
 #ifdef STORE_PIXEL_RGB
             STORE_PIXEL_RGB(pixel, x + i, y, src[i]);
 #else
@@ -240,7 +242,8 @@ NAME(put_mono_row)( GLcontext *ctx, struct gl_renderbuffer *rb,
    if (mask) {
       for (i = 0; i < count; i++) {
          if (mask[i]) {
-            RB_TYPE pixel[4];
+            RB_TYPE row[4];
+            INIT_PIXEL_PTR(pixel, x, y);
             STORE_PIXEL(pixel, x + i, y, src);
             PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel);
          }
@@ -272,7 +275,8 @@ NAME(put_values)( GLcontext *ctx, struct gl_renderbuffer *rb,
    ASSERT(mask);
    for (i = 0; i < count; i++) {
       if (mask[i]) {
-         RB_TYPE pixel[4];
+         RB_TYPE row[4];
+         INIT_PIXEL_PTR(pixel, x, y);
          STORE_PIXEL(pixel, x[i], y[i], src[i]);
          PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel);
       }
@@ -294,7 +298,8 @@ NAME(put_mono_values)( GLcontext *ctx, struct gl_renderbuffer *rb,
    ASSERT(mask);
    for (i = 0; i < count; i++) {
       if (mask[i]) {
-         RB_TYPE pixel[4];
+         RB_TYPE row[4];
+         INIT_PIXEL_PTR(pixel, x, y);
          STORE_PIXEL(pixel, x[i], y[i], src);
          PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel);
       }
index 080fe475c16eb4f5a1ad632c6ef53c65ee146334..7dcf9a6541ae2bc4a37b9c696f629f5cbcf3d584 100644 (file)
@@ -9,12 +9,9 @@ PROGRAM = glslcompiler
 
 OBJECTS = \
        glslcompiler.o \
-       ../../glapi/glapi.o \
-       ../../glapi/glapi_nop.o \
-       ../../glapi/glthread.o \
-       ../../main/dispatch.o \
        ../common/driverfuncs.o \
-       ../../libmesa.a
+       ../../libmesa.a \
+       ../../libglapi.a
 
 INCLUDES = \
        -I$(TOP)/include \
index 66035a4a43c140f2795ec1b4e8540d1993b6aa62..d58f32b2930cfc7d5c0de56bdc49d01248535d9d 100644 (file)
@@ -68,6 +68,7 @@ static const char *Prog = "glslcompiler";
 
 struct options {
    GLboolean LineNumbers;
+   GLboolean Link;
    gl_prog_print_mode Mode;
    const char *VertFile;
    const char *FragFile;
@@ -207,23 +208,29 @@ ReadShader(GLuint shader, const char *filename)
 }
 
 
-#if 0
 static void
-CheckLink(GLuint prog)
+CheckLink(GLuint v_shader, GLuint f_shader)
 {
+   GLuint prog;
    GLint stat;
+
+   prog = _mesa_CreateProgram();
+
+   _mesa_AttachShader(prog, v_shader);
+   _mesa_AttachShader(prog, f_shader);
+
+   _mesa_LinkProgramARB(prog);
    _mesa_GetProgramiv(prog, GL_LINK_STATUS, &stat);
    if (!stat) {
       GLchar log[1000];
       GLsizei len;
       _mesa_GetProgramInfoLog(prog, 1000, &len, log);
-      fprintf(stderr, "%s: Linker error:\n%s\n", Prog, log);
+      fprintf(stderr, "Linker error:\n%s\n", log);
    }
    else {
-      fprintf(stderr, "%s: Link success!\n", Prog);
+      fprintf(stderr, "Link success!\n");
    }
 }
-#endif
 
 
 static void
@@ -262,6 +269,7 @@ Usage(void)
    printf("  --fs FILE          fragment shader input filename\n");
    printf("  --arb              emit ARB-style instructions\n");
    printf("  --nv               emit NV-style instructions\n");
+   printf("  --link             run linker\n");
    printf("  --debug            force #pragma debug(on)\n");
    printf("  --nodebug          force #pragma debug(off)\n");
    printf("  --opt              force #pragma optimize(on)\n");
@@ -309,6 +317,9 @@ ParseOptions(int argc, char *argv[])
       else if (strcmp(argv[i], "--nv") == 0) {
          Options.Mode = PROG_PRINT_NV;
       }
+      else if (strcmp(argv[i], "--link") == 0) {
+         Options.Link = GL_TRUE;
+      }
       else if (strcmp(argv[i], "--debug") == 0) {
          Options.Pragmas.IgnoreDebug = GL_TRUE;
          Options.Pragmas.Debug = GL_TRUE;
@@ -358,7 +369,7 @@ ParseOptions(int argc, char *argv[])
 int
 main(int argc, char *argv[])
 {
-   GLuint shader = 0;
+   GLuint v_shader = 0, f_shader = 0;
 
    ParseOptions(argc, argv);
 
@@ -368,24 +379,38 @@ main(int argc, char *argv[])
    }
 
    if (Options.VertFile) {
-      shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER);
+      v_shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER);
    }
-   else if (Options.FragFile) {
-      shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER);
+
+   if (Options.FragFile) {
+      f_shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER);
    }
 
-   if (shader) {
+   if (v_shader || f_shader) {
       if (Options.OutputFile) {
          fclose(stdout);
          /*stdout =*/ freopen(Options.OutputFile, "w", stdout);
       }
-      if (stdout) {
-         PrintShaderInstructions(shader, stdout);
+      if (stdout && v_shader) {
+         PrintShaderInstructions(v_shader, stdout);
+      }
+      if (stdout && f_shader) {
+         PrintShaderInstructions(f_shader, stdout);
       }
       if (Options.OutputFile) {
          fclose(stdout);
       }
    }
 
+   if (Options.Link) {
+      if (!v_shader || !f_shader) {
+         fprintf(stderr,
+                 "--link option requires both a vertex and fragment shader.\n");
+         exit(1);
+      }
+
+      CheckLink(v_shader, f_shader);
+   }
+
    return 0;
 }
index e11aff1a849beb82cb655c76596d93b07205b59a..955eba4e944d1255f29a60a69e0d27a5ea7fd9c8 100644 (file)
@@ -1113,7 +1113,7 @@ glXGetAGPOffsetMESA( const GLvoid *pointer )
 
 /*** GLX_MESA_allocate_memory */
 
-void *
+void PUBLIC *
 glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size,
                       float readfreq, float writefreq, float priority)
 {
@@ -1121,14 +1121,14 @@ glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size,
    return NULL;
 }
 
-void
+void PUBLIC
 glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
 {
    /* dummy */
 }
 
 
-GLuint
+GLuint PUBLIC
 glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer)
 {
    /* dummy */
@@ -1138,7 +1138,7 @@ glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer)
 
 /*** GLX_EXT_texture_from_pixmap */
 
-void
+void PUBLIC
 glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer,
                    const int *attrib_list)
 {
@@ -1148,7 +1148,7 @@ glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer,
       t->BindTexImageEXT(dpy, drawable, buffer, attrib_list);
 }
 
-void
+void PUBLIC
 glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer)
 {
    struct _glxapi_table *t;
@@ -1426,7 +1426,7 @@ _glxapi_get_proc_address(const char *funcName)
  * This function does not get dispatched through the dispatch table
  * since it's really a "meta" function.
  */
-__GLXextFuncPtr
+__GLXextFuncPtr PUBLIC
 glXGetProcAddressARB(const GLubyte *procName)
 {
    __GLXextFuncPtr f;
@@ -1442,7 +1442,8 @@ glXGetProcAddressARB(const GLubyte *procName)
 
 
 /* GLX 1.4 */
-void (*glXGetProcAddress(const GLubyte *procName))()
+void PUBLIC
+(*glXGetProcAddress(const GLubyte *procName))()
 {
    return glXGetProcAddressARB(procName);
 }
index fbe67445c932c560235d8d51ee0f5afa3ccdd3b7..8b484853afe7bb8be785e19a1cf30823d5dbf432 100644 (file)
@@ -19,9 +19,8 @@ es1: $(ES1_LIBS)
 es2: $(ES2_LIBS)
        @rm -f subdirs-stamp-tmp
 
-# force the inclusion of es's mfeatures.h
-ES1_CPPFLAGS := -include main/mfeatures_es1.h -D__GL_EXPORTS
-ES2_CPPFLAGS := -include main/mfeatures_es2.h -D__GL_EXPORTS
+ES1_CPPFLAGS := -DFEATURE_ES1=1 -D__GL_EXPORTS
+ES2_CPPFLAGS := -DFEATURE_ES2=1 -D__GL_EXPORTS
 
 ES1_OBJ_DIR := objs-es1
 ES2_OBJ_DIR := objs-es2
diff --git a/src/mesa/es/main/mfeatures_es1.h b/src/mesa/es/main/mfeatures_es1.h
deleted file mode 100644 (file)
index 1793550..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-/**
- * \file mfeatures.h
- *
- * The #defines in this file enable/disable Mesa features needed
- * for OpenGL ES 1.1.
- */
-
-
-#ifndef MFEATURES_ES1_H
-#define MFEATURES_ES1_H
-
-/* this file replaces main/mfeatures.h */
-#ifdef FEATURES_H
-#error "main/mfeatures.h was wrongly included"
-#endif
-#define FEATURES_H
-
-#define ASSERT_NO_FEATURE() ASSERT(0)
-
-/*
- * Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1.
- */
-#ifndef _HAVE_FULL_GL
-#define _HAVE_FULL_GL 1
-#endif
-
-#ifdef IN_DRI_DRIVER
-#define FEATURE_remap_table 1
-#else
-#define FEATURE_remap_table 0
-#endif
-
-#define FEATURE_accum 0
-#define FEATURE_arrayelt 0
-#define FEATURE_attrib 0
-#define FEATURE_beginend 0
-#define FEATURE_colortable 0
-#define FEATURE_convolve 0
-#define FEATURE_dispatch 1
-#define FEATURE_dlist 0
-#define FEATURE_draw_read_buffer 0
-#define FEATURE_drawpix 0
-#define FEATURE_eval 0
-#define FEATURE_feedback 0
-#define FEATURE_fixedpt 1
-#define FEATURE_histogram 0
-#define FEATURE_pixel 0
-#define FEATURE_point_size_array 1
-#define FEATURE_queryobj 0
-#define FEATURE_rastpos 0
-#define FEATURE_texgen 1
-#define FEATURE_texture_fxt1 0
-#define FEATURE_texture_s3tc 0
-#define FEATURE_userclip 1
-#define FEATURE_vertex_array_byte 1
-#define FEATURE_es2_glsl 0
-
-#define FEATURE_ARB_fragment_program  _HAVE_FULL_GL
-#define FEATURE_ARB_vertex_buffer_object  _HAVE_FULL_GL
-#define FEATURE_ARB_vertex_program  _HAVE_FULL_GL
-
-#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL
-#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL
-#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader)
-#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects
-#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects
-
-#define FEATURE_EXT_framebuffer_blit 0
-#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL
-#define FEATURE_EXT_pixel_buffer_object  _HAVE_FULL_GL
-#define FEATURE_EXT_texture_sRGB 0
-#define FEATURE_ATI_fragment_shader 0
-#define FEATURE_MESA_program_debug  _HAVE_FULL_GL
-#define FEATURE_NV_fence 0
-#define FEATURE_NV_fragment_program 0
-#define FEATURE_NV_vertex_program 0
-
-#define FEATURE_OES_framebuffer_object 1
-#define FEATURE_OES_draw_texture 1
-#define FEATURE_OES_mapbuffer 1
-
-#define FEATURE_OES_EGL_image 1
-
-#define FEATURE_extra_context_init 1
-
-/*@}*/
-
-
-
-
-#endif /* MFEATURES_ES1_H */
diff --git a/src/mesa/es/main/mfeatures_es2.h b/src/mesa/es/main/mfeatures_es2.h
deleted file mode 100644 (file)
index a463bed..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-/**
- * \file mfeatures.h
- *
- * The #defines in this file enable/disable Mesa features needed
- * for OpenGL ES 2.0.
- */
-
-
-#ifndef MFEATURES_ES2_H
-#define MFEATURES_ES2_H
-
-/* this file replaces main/mfeatures.h */
-#ifdef FEATURES_H
-#error "main/mfeatures.h was wrongly included"
-#endif
-#define FEATURES_H
-
-#define ASSERT_NO_FEATURE() ASSERT(0)
-
-/*
- * Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1.
- */
-#ifndef _HAVE_FULL_GL
-#define _HAVE_FULL_GL 1
-#endif
-
-#ifdef IN_DRI_DRIVER
-#define FEATURE_remap_table 1
-#else
-#define FEATURE_remap_table 0
-#endif
-
-#define FEATURE_accum 0
-#define FEATURE_arrayelt 0
-#define FEATURE_attrib 0
-#define FEATURE_beginend 0
-#define FEATURE_colortable 0
-#define FEATURE_convolve 0
-#define FEATURE_dispatch 1
-#define FEATURE_dlist 0
-#define FEATURE_draw_read_buffer 0
-#define FEATURE_drawpix 0
-#define FEATURE_eval 0
-#define FEATURE_feedback 0
-#define FEATURE_fixedpt 1
-#define FEATURE_histogram 0
-#define FEATURE_pixel 0
-#define FEATURE_point_size_array 1
-#define FEATURE_queryobj 0
-#define FEATURE_rastpos 0
-#define FEATURE_texgen 1
-#define FEATURE_texture_fxt1 0
-#define FEATURE_texture_s3tc 0
-#define FEATURE_userclip 1
-#define FEATURE_vertex_array_byte 1
-#define FEATURE_es2_glsl 1
-
-#define FEATURE_ARB_fragment_program  _HAVE_FULL_GL
-#define FEATURE_ARB_vertex_buffer_object  _HAVE_FULL_GL
-#define FEATURE_ARB_vertex_program  _HAVE_FULL_GL
-
-#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL
-#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL
-#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader)
-#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects
-#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects
-
-#define FEATURE_EXT_framebuffer_blit 0
-#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL
-#define FEATURE_EXT_pixel_buffer_object  _HAVE_FULL_GL
-#define FEATURE_EXT_texture_sRGB 0
-#define FEATURE_ATI_fragment_shader 0
-#define FEATURE_MESA_program_debug  _HAVE_FULL_GL
-#define FEATURE_NV_fence 0
-#define FEATURE_NV_fragment_program 0
-#define FEATURE_NV_vertex_program 0
-
-#define FEATURE_OES_framebuffer_object 1
-#define FEATURE_OES_draw_texture 0
-#define FEATURE_OES_mapbuffer 1
-
-#define FEATURE_OES_EGL_image 1
-
-#define FEATURE_extra_context_init 1
-
-/*@}*/
-
-
-
-
-#endif /* MFEATURES_ES2_H */
index e7b8bc780f8c923932562054d700a9e6099482d3..b829543cc01f45e76e478d9904a87355ef45a2ec 100644 (file)
       _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); \
    } while (0)
 
-#if FEATURE_accum
-/* This is a sanity check that to be sure we're using the correct mfeatures.h
- * header.  We don't want to accidentally use the one from mainline Mesa.
- */
-#error "The wrong mfeatures.h file is being included!"
-#endif
-
 
 /* silence compiler warnings */
 extern void GLAPIENTRY _vbo_Materialf(GLenum face, GLenum pname, GLfloat param);
index a48724ee615bec3cd5fb1ee9bc7d3358c2b7d81f..10dfa1ddb34ec7b15a3bfa95db52b6dc30773b79 100644 (file)
@@ -226,11 +226,11 @@ class PrintGenericStubs(gl_XML.gl_print_base):
                        stack = self.get_stack_size(f)
                        alt = "%s@%u" % (name, stack)
 
-                       if f.is_static_entry_point(f.name):
-                               for n in f.entry_points:
+                       for n in f.entry_points:
+                               if f.is_static_entry_point(n):
                                        if n != f.name:
                                                alt2 = "%s@%u" % (n, stack)
-                                               text = '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, f.name, alt)
+                                               text = '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, name, alt)
 
                                                if f.has_different_protocol(n):
                                                        print '#ifndef GLX_INDIRECT_RENDERING'
index c4f43f66a188854d81f234a6b5b086f52c660851..239780e7539ebebfbb6506c80bdbae9f4304bc6a 100644 (file)
@@ -56,7 +56,7 @@ extern const GLubyte gl_dispatch_functions_start[];
 #if defined(DISPATCH_FUNCTION_SIZE)
 
 _glapi_proc
-get_entrypoint_address(GLuint functionOffset)
+get_entrypoint_address(unsigned int functionOffset)
 {
    return (_glapi_proc) (gl_dispatch_functions_start
                          + (DISPATCH_FUNCTION_SIZE * functionOffset));
@@ -97,7 +97,7 @@ init_glapi_relocs( void )
  * We need assembly language in order to accomplish this.
  */
 _glapi_proc
-generate_entrypoint(GLuint functionOffset)
+generate_entrypoint(unsigned int functionOffset)
 {
    /* 32 is chosen as something of a magic offset.  For x86, the dispatch
     * at offset 32 is the first one where the offset in the
@@ -122,7 +122,7 @@ generate_entrypoint(GLuint functionOffset)
  * stub that was generated with the preceeding function.
  */
 void
-fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset)
+fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset)
 {
    GLubyte * const code = (GLubyte *) entrypoint;
 
index 6a1fac597f31d7b2db6c9c18774e7e1bf437481f..57f00be8dcc5b0df816c317085e4921884a13833 100644 (file)
@@ -40,6 +40,7 @@
 #endif
 
 #include "glapi/glthread.h"
+#include "glapi/glapi_priv.h"
 
 
 #if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun)
index b1a718a5f0a5dfa89273092e6920d6a1736fd1b7..df9c5872842ef1369fbf5522cf40dbd5309fbbf4 100644 (file)
@@ -93,7 +93,7 @@ NoOpUnused(void)
 
 #else
 
-static void
+static int
 NoOpGeneric(void)
 {
 #if !defined(_WIN32_WCE)
@@ -101,6 +101,7 @@ NoOpGeneric(void)
       fprintf(stderr, "GL User Error: calling GL function without a rendering context\n");
    }
 #endif
+   return 0;
 }
 
 #define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric
index 0e2de460f2e8c5532b1000c37ef1c44338bef82b..da6fee63fe7ed994ea09e9220d9e9bebcc8974c6 100644 (file)
@@ -27,6 +27,8 @@
 #define _GLAPI_PRIV_H
 
 #include "glthread.h"
+#include "glapi.h"
+
 
 
 /* getproc */
@@ -42,7 +44,7 @@ _glapi_check_table(const struct _glapi_table *table);
 /* execmem */
 
 extern void *
-_glapi_exec_malloc(GLuint size);
+_glapi_exec_malloc(unsigned int size);
 
 
 /* entrypoint */
@@ -52,15 +54,15 @@ init_glapi_relocs_once(void);
 
 
 extern _glapi_proc
-generate_entrypoint(GLuint functionOffset);
+generate_entrypoint(unsigned int functionOffset);
 
 
 extern void
-fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset);
+fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset);
 
 
 extern _glapi_proc
-get_entrypoint_address(GLuint functionOffset);
+get_entrypoint_address(unsigned int functionOffset);
 
 
 /**
index 71d1514fe4900766b80fa0a8a2efe8076b4ab0ee..11bf48622fd1b6d68e59d911100812b308a20dac 100644 (file)
@@ -32,6 +32,7 @@
 
 
 #include "glheader.h"
+#include "enums.h"
 #include "hash.h"
 #include "imports.h"
 #include "image.h"
@@ -46,7 +47,7 @@
 /*#define BOUNDS_CHECK*/
 
 
-#ifdef FEATURE_OES_mapbuffer
+#if FEATURE_OES_mapbuffer
 #define DEFAULT_ACCESS GL_MAP_WRITE_BIT
 #else
 #define DEFAULT_ACCESS (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)
@@ -1376,31 +1377,49 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
 
    bufObj = get_buffer(ctx, target);
    if (!bufObj) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "GetBufferParameterivARB(target)" );
+      _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)" );
       return;
    }
    if (!_mesa_is_bufferobj(bufObj)) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "GetBufferParameterivARB" );
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameterivARB" );
       return;
    }
 
    switch (pname) {
    case GL_BUFFER_SIZE_ARB:
       *params = (GLint) bufObj->Size;
-      break;
+      return;
    case GL_BUFFER_USAGE_ARB:
       *params = bufObj->Usage;
-      break;
+      return;
    case GL_BUFFER_ACCESS_ARB:
       *params = simplified_access_mode(bufObj->AccessFlags);
-      break;
+      return;
    case GL_BUFFER_MAPPED_ARB:
       *params = _mesa_bufferobj_mapped(bufObj);
-      break;
-   default:
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname)");
       return;
+   case GL_BUFFER_ACCESS_FLAGS:
+      if (ctx->VersionMajor < 3)
+         goto invalid_pname;
+      *params = bufObj->AccessFlags;
+      return;
+   case GL_BUFFER_MAP_OFFSET:
+      if (ctx->VersionMajor < 3)
+         goto invalid_pname;
+      *params = (GLint) bufObj->Offset;
+      return;
+   case GL_BUFFER_MAP_LENGTH:
+      if (ctx->VersionMajor < 3)
+         goto invalid_pname;
+      *params = (GLint) bufObj->Length;
+      return;
+   default:
+      ; /* fall-through */
    }
+
+invalid_pname:
+   _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname=%s)",
+               _mesa_lookup_enum_by_nr(pname));
 }
 
 
@@ -1418,31 +1437,49 @@ _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params)
 
    bufObj = get_buffer(ctx, target);
    if (!bufObj) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "GetBufferParameteri64v(target)" );
+      _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(target)" );
       return;
    }
    if (!_mesa_is_bufferobj(bufObj)) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "GetBufferParameteri64v" );
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameteri64v" );
       return;
    }
 
    switch (pname) {
    case GL_BUFFER_SIZE_ARB:
       *params = bufObj->Size;
-      break;
+      return;
    case GL_BUFFER_USAGE_ARB:
       *params = bufObj->Usage;
-      break;
+      return;
    case GL_BUFFER_ACCESS_ARB:
       *params = simplified_access_mode(bufObj->AccessFlags);
-      break;
+      return;
+   case GL_BUFFER_ACCESS_FLAGS:
+      if (ctx->VersionMajor < 3)
+         goto invalid_pname;
+      *params = bufObj->AccessFlags;
+      return;
    case GL_BUFFER_MAPPED_ARB:
       *params = _mesa_bufferobj_mapped(bufObj);
-      break;
-   default:
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname)");
       return;
+   case GL_BUFFER_MAP_OFFSET:
+      if (ctx->VersionMajor < 3)
+         goto invalid_pname;
+      *params = bufObj->Offset;
+      return;
+   case GL_BUFFER_MAP_LENGTH:
+      if (ctx->VersionMajor < 3)
+         goto invalid_pname;
+      *params = bufObj->Length;
+      return;
+   default:
+      ; /* fall-through */
    }
+
+invalid_pname:
+   _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname=%s)",
+               _mesa_lookup_enum_by_nr(pname));
 }
 
 
index 73126b95755f1c95945c120f7a0755ebe6c349a1..521b18e43edd75bceb6d1ae91f5b8597eeacab66 100644 (file)
@@ -873,7 +873,7 @@ _mesa_initialize_context(GLcontext *ctx,
       ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
    }
 
-#ifdef FEATURE_extra_context_init
+#if FEATURE_extra_context_init
    _mesa_initialize_context_extra(ctx);
 #endif
 
index 33b35e03c79d4bb7e3eeefca8c7f8c65fdf85bc6..9bcfc1008a8852f402733053645ceecfdd279c35 100644 (file)
@@ -85,7 +85,7 @@ void
 _mesa_print_state( const char *msg, GLuint state )
 {
    _mesa_debug(NULL,
-          "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+          "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
           msg,
           state,
           (state & _NEW_MODELVIEW)       ? "ctx->ModelView, " : "",
@@ -105,6 +105,7 @@ _mesa_print_state( const char *msg, GLuint state )
           (state & _NEW_POLYGON)         ? "ctx->Polygon, " : "",
           (state & _NEW_POLYGONSTIPPLE)  ? "ctx->PolygonStipple, " : "",
           (state & _NEW_SCISSOR)         ? "ctx->Scissor, " : "",
+          (state & _NEW_STENCIL)         ? "ctx->Stencil, " : "",
           (state & _NEW_TEXTURE)         ? "ctx->Texture, " : "",
           (state & _NEW_TRANSFORM)       ? "ctx->Transform, " : "",
           (state & _NEW_VIEWPORT)        ? "ctx->Viewport, " : "",
index 30245d6aafa6d8c361685ed33c515a6e747e439f..ca992d12613f0d17e7facaf206b489af548ea811 100644 (file)
@@ -480,7 +480,7 @@ _mesa_enable_2_1_extensions(GLcontext *ctx)
 #if FEATURE_EXT_texture_sRGB
    ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
 #endif
-#ifdef FEATURE_ARB_shading_language_120
+#if FEATURE_ARB_shading_language_120
    ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
 #endif
 }
index 7c442e390c2a3feaca8467f8e22f205b24299f1b..e3e006bb948d0d0d5e9026a11ee8007bbf64b1f1 100644 (file)
@@ -180,8 +180,12 @@ _mesa_get_attachment(GLcontext *ctx, struct gl_framebuffer *fb,
       return &fb->Attachment[BUFFER_COLOR0 + i];
    case GL_DEPTH_STENCIL_ATTACHMENT:
       /* fall-through */
+   case GL_DEPTH_BUFFER:
+      /* fall-through / new in GL 3.0 */
    case GL_DEPTH_ATTACHMENT_EXT:
       return &fb->Attachment[BUFFER_DEPTH];
+   case GL_STENCIL_BUFFER:
+      /* fall-through / new in GL 3.0 */
    case GL_STENCIL_ATTACHMENT_EXT:
       return &fb->Attachment[BUFFER_STENCIL];
    default:
@@ -625,7 +629,7 @@ _mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb)
       }
    }
 
-#ifndef FEATURE_OES_framebuffer_object
+#if !FEATURE_OES_framebuffer_object
    /* Check that all DrawBuffers are present */
    for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) {
       if (fb->ColorDrawBuffer[j] != GL_NONE) {
index edc44009120433cfe139fce0f2346dc297dac749..266fda40ec51668c78eebf02a75212a463be5e35 100644 (file)
@@ -77,9 +77,6 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
    if (!params)
       return;
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    if (ctx->Driver.GetBooleanv &&
        ctx->Driver.GetBooleanv(ctx, pname, params))
       return;
@@ -107,6 +104,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.AlphaBias);
          break;
       case GL_ALPHA_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.alphaBits);
          break;
       case GL_ALPHA_SCALE:
@@ -167,6 +166,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.BlueBias);
          break;
       case GL_BLUE_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.blueBits);
          break;
       case GL_BLUE_SCALE:
@@ -221,27 +222,21 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          params[0] = ENUM_TO_BOOLEAN(ctx->Polygon.CullFaceMode);
          break;
       case GL_CURRENT_COLOR:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]);
          params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]);
          params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]);
          params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]);
-         }
          break;
       case GL_CURRENT_INDEX:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]);
-         }
          break;
       case GL_CURRENT_NORMAL:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]);
          params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]);
          params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]);
-         }
          break;
       case GL_CURRENT_RASTER_COLOR:
          params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[0]);
@@ -334,10 +329,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          params[0] = ENUM_TO_BOOLEAN(ctx->DrawBuffer->ColorDrawBuffer[0]);
          break;
       case GL_EDGE_FLAG:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = (ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0);
-         }
          break;
       case GL_FEEDBACK_BUFFER_SIZE:
          params[0] = INT_TO_BOOLEAN(ctx->Feedback.BufferSize);
@@ -379,12 +372,16 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenBias);
          break;
       case GL_GREEN_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.greenBits);
          break;
       case GL_GREEN_SCALE:
          params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenScale);
          break;
       case GL_INDEX_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.indexBits);
          break;
       case GL_INDEX_CLEAR_VALUE:
@@ -815,6 +812,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.RedBias);
          break;
       case GL_RED_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.redBits);
          break;
       case GL_RED_SCALE:
@@ -917,6 +916,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          CHECK_EXT1(MESA_texture_array, "GetBooleanv");
          params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name);
          break;
+      case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT:
+         CHECK_EXT1(MESA_texture_array, "GetBooleanv");
+         params[0] = INT_TO_BOOLEAN(ctx->Const.MaxArrayTextureLayers);
+         break;
       case GL_TEXTURE_GEN_S:
          params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0);
          break;
@@ -1341,13 +1344,11 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          break;
       case GL_CURRENT_SECONDARY_COLOR_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetBooleanv");
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]);
          params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]);
          params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]);
          params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]);
-         }
          break;
       case GL_SECONDARY_COLOR_ARRAY_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetBooleanv");
@@ -1367,10 +1368,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          break;
       case GL_CURRENT_FOG_COORDINATE_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetBooleanv");
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]);
-         }
          break;
       case GL_FOG_COORDINATE_ARRAY_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetBooleanv");
@@ -1932,6 +1931,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
       case GL_MINOR_VERSION:
          params[0] = INT_TO_BOOLEAN(ctx->VersionMinor);
          break;
+      case GL_CONTEXT_FLAGS:
+         params[0] = INT_TO_BOOLEAN(ctx->Const.ContextFlags);
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname);
    }
@@ -1946,9 +1948,6 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
    if (!params)
       return;
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    if (ctx->Driver.GetFloatv &&
        ctx->Driver.GetFloatv(ctx, pname, params))
       return;
@@ -1976,6 +1975,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          params[0] = ctx->Pixel.AlphaBias;
          break;
       case GL_ALPHA_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLfloat)(ctx->DrawBuffer->Visual.alphaBits);
          break;
       case GL_ALPHA_SCALE:
@@ -2036,6 +2037,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          params[0] = ctx->Pixel.BlueBias;
          break;
       case GL_BLUE_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLfloat)(ctx->DrawBuffer->Visual.blueBits);
          break;
       case GL_BLUE_SCALE:
@@ -2090,27 +2093,21 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          params[0] = ENUM_TO_FLOAT(ctx->Polygon.CullFaceMode);
          break;
       case GL_CURRENT_COLOR:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0];
          params[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1];
          params[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2];
          params[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3];
-         }
          break;
       case GL_CURRENT_INDEX:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0];
-         }
          break;
       case GL_CURRENT_NORMAL:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0];
          params[1] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1];
          params[2] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2];
-         }
          break;
       case GL_CURRENT_RASTER_COLOR:
          params[0] = ctx->Current.RasterColor[0];
@@ -2203,10 +2200,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          params[0] = ENUM_TO_FLOAT(ctx->DrawBuffer->ColorDrawBuffer[0]);
          break;
       case GL_EDGE_FLAG:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = BOOLEAN_TO_FLOAT((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0));
-         }
          break;
       case GL_FEEDBACK_BUFFER_SIZE:
          params[0] = (GLfloat)(ctx->Feedback.BufferSize);
@@ -2248,12 +2243,16 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          params[0] = ctx->Pixel.GreenBias;
          break;
       case GL_GREEN_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLfloat)(ctx->DrawBuffer->Visual.greenBits);
          break;
       case GL_GREEN_SCALE:
          params[0] = ctx->Pixel.GreenScale;
          break;
       case GL_INDEX_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLfloat)(ctx->DrawBuffer->Visual.indexBits);
          break;
       case GL_INDEX_CLEAR_VALUE:
@@ -2684,6 +2683,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          params[0] = ctx->Pixel.RedBias;
          break;
       case GL_RED_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLfloat)(ctx->DrawBuffer->Visual.redBits);
          break;
       case GL_RED_SCALE:
@@ -2786,6 +2787,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          CHECK_EXT1(MESA_texture_array, "GetFloatv");
          params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name);
          break;
+      case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT:
+         CHECK_EXT1(MESA_texture_array, "GetFloatv");
+         params[0] = (GLfloat)(ctx->Const.MaxArrayTextureLayers);
+         break;
       case GL_TEXTURE_GEN_S:
          params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0));
          break;
@@ -3210,13 +3215,11 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          break;
       case GL_CURRENT_SECONDARY_COLOR_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetFloatv");
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0];
          params[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1];
          params[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2];
          params[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3];
-         }
          break;
       case GL_SECONDARY_COLOR_ARRAY_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetFloatv");
@@ -3236,10 +3239,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          break;
       case GL_CURRENT_FOG_COORDINATE_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetFloatv");
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
-         }
          break;
       case GL_FOG_COORDINATE_ARRAY_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetFloatv");
@@ -3801,6 +3802,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
       case GL_MINOR_VERSION:
          params[0] = (GLfloat)(ctx->VersionMinor);
          break;
+      case GL_CONTEXT_FLAGS:
+         params[0] = (GLfloat)(ctx->Const.ContextFlags);
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname);
    }
@@ -3815,9 +3819,6 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
    if (!params)
       return;
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    if (ctx->Driver.GetIntegerv &&
        ctx->Driver.GetIntegerv(ctx, pname, params))
       return;
@@ -3845,6 +3846,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          params[0] = IROUND(ctx->Pixel.AlphaBias);
          break;
       case GL_ALPHA_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = ctx->DrawBuffer->Visual.alphaBits;
          break;
       case GL_ALPHA_SCALE:
@@ -3905,6 +3908,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          params[0] = IROUND(ctx->Pixel.BlueBias);
          break;
       case GL_BLUE_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = ctx->DrawBuffer->Visual.blueBits;
          break;
       case GL_BLUE_SCALE:
@@ -3959,27 +3964,21 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          params[0] = ENUM_TO_INT(ctx->Polygon.CullFaceMode);
          break;
       case GL_CURRENT_COLOR:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]);
          params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]);
          params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]);
          params[3] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]);
-         }
          break;
       case GL_CURRENT_INDEX:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]);
-         }
          break;
       case GL_CURRENT_NORMAL:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]);
          params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]);
          params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]);
-         }
          break;
       case GL_CURRENT_RASTER_COLOR:
          params[0] = FLOAT_TO_INT(ctx->Current.RasterColor[0]);
@@ -4072,10 +4071,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          params[0] = ENUM_TO_INT(ctx->DrawBuffer->ColorDrawBuffer[0]);
          break;
       case GL_EDGE_FLAG:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = BOOLEAN_TO_INT((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0));
-         }
          break;
       case GL_FEEDBACK_BUFFER_SIZE:
          params[0] = ctx->Feedback.BufferSize;
@@ -4117,12 +4114,16 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          params[0] = IROUND(ctx->Pixel.GreenBias);
          break;
       case GL_GREEN_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = ctx->DrawBuffer->Visual.greenBits;
          break;
       case GL_GREEN_SCALE:
          params[0] = IROUND(ctx->Pixel.GreenScale);
          break;
       case GL_INDEX_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = ctx->DrawBuffer->Visual.indexBits;
          break;
       case GL_INDEX_CLEAR_VALUE:
@@ -4553,6 +4554,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          params[0] = IROUND(ctx->Pixel.RedBias);
          break;
       case GL_RED_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = ctx->DrawBuffer->Visual.redBits;
          break;
       case GL_RED_SCALE:
@@ -4655,6 +4658,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          CHECK_EXT1(MESA_texture_array, "GetIntegerv");
          params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name;
          break;
+      case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT:
+         CHECK_EXT1(MESA_texture_array, "GetIntegerv");
+         params[0] = ctx->Const.MaxArrayTextureLayers;
+         break;
       case GL_TEXTURE_GEN_S:
          params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0));
          break;
@@ -5079,13 +5086,11 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          break;
       case GL_CURRENT_SECONDARY_COLOR_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetIntegerv");
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]);
          params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]);
          params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]);
          params[3] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]);
-         }
          break;
       case GL_SECONDARY_COLOR_ARRAY_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetIntegerv");
@@ -5105,10 +5110,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          break;
       case GL_CURRENT_FOG_COORDINATE_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetIntegerv");
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]);
-         }
          break;
       case GL_FOG_COORDINATE_ARRAY_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetIntegerv");
@@ -5670,6 +5673,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
       case GL_MINOR_VERSION:
          params[0] = ctx->VersionMinor;
          break;
+      case GL_CONTEXT_FLAGS:
+         params[0] = ctx->Const.ContextFlags;
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname);
    }
@@ -5685,9 +5691,6 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
    if (!params)
       return;
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    if (ctx->Driver.GetInteger64v &&
        ctx->Driver.GetInteger64v(ctx, pname, params))
       return;
@@ -5715,6 +5718,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.AlphaBias);
          break;
       case GL_ALPHA_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLint64)(ctx->DrawBuffer->Visual.alphaBits);
          break;
       case GL_ALPHA_SCALE:
@@ -5775,6 +5780,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.BlueBias);
          break;
       case GL_BLUE_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLint64)(ctx->DrawBuffer->Visual.blueBits);
          break;
       case GL_BLUE_SCALE:
@@ -5829,27 +5836,21 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = ENUM_TO_INT64(ctx->Polygon.CullFaceMode);
          break;
       case GL_CURRENT_COLOR:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]);
          params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]);
          params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]);
          params[3] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]);
-         }
          break;
       case GL_CURRENT_INDEX:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]);
-         }
          break;
       case GL_CURRENT_NORMAL:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]);
          params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]);
          params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]);
-         }
          break;
       case GL_CURRENT_RASTER_COLOR:
          params[0] = FLOAT_TO_INT64(ctx->Current.RasterColor[0]);
@@ -5942,10 +5943,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = ENUM_TO_INT64(ctx->DrawBuffer->ColorDrawBuffer[0]);
          break;
       case GL_EDGE_FLAG:
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = BOOLEAN_TO_INT64((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0));
-         }
          break;
       case GL_FEEDBACK_BUFFER_SIZE:
          params[0] = (GLint64)(ctx->Feedback.BufferSize);
@@ -5987,12 +5986,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.GreenBias);
          break;
       case GL_GREEN_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLint64)(ctx->DrawBuffer->Visual.greenBits);
          break;
       case GL_GREEN_SCALE:
          params[0] = IROUND64(ctx->Pixel.GreenScale);
          break;
       case GL_INDEX_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLint64)(ctx->DrawBuffer->Visual.indexBits);
          break;
       case GL_INDEX_CLEAR_VALUE:
@@ -6423,6 +6426,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          params[0] = IROUND64(ctx->Pixel.RedBias);
          break;
       case GL_RED_BITS:
+         if (ctx->NewState & _NEW_BUFFERS)
+            _mesa_update_state(ctx);
          params[0] = (GLint64)(ctx->DrawBuffer->Visual.redBits);
          break;
       case GL_RED_SCALE:
@@ -6525,6 +6530,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          CHECK_EXT1(MESA_texture_array, "GetInteger64v");
          params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name);
          break;
+      case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT:
+         CHECK_EXT1(MESA_texture_array, "GetInteger64v");
+         params[0] = (GLint64)(ctx->Const.MaxArrayTextureLayers);
+         break;
       case GL_TEXTURE_GEN_S:
          params[0] = BOOLEAN_TO_INT64(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0));
          break;
@@ -6949,13 +6958,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_CURRENT_SECONDARY_COLOR_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetInteger64v");
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]);
          params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]);
          params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]);
          params[3] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]);
-         }
          break;
       case GL_SECONDARY_COLOR_ARRAY_EXT:
          CHECK_EXT1(EXT_secondary_color, "GetInteger64v");
@@ -6975,10 +6982,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_CURRENT_FOG_COORDINATE_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetInteger64v");
-         {
          FLUSH_CURRENT(ctx, 0);
          params[0] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]);
-         }
          break;
       case GL_FOG_COORDINATE_ARRAY_EXT:
          CHECK_EXT1(EXT_fog_coord, "GetInteger64v");
@@ -7540,6 +7545,9 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
       case GL_MINOR_VERSION:
          params[0] = (GLint64)(ctx->VersionMinor);
          break;
+      case GL_CONTEXT_FLAGS:
+         params[0] = (GLint64)(ctx->Const.ContextFlags);
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64v(pname=0x%x)", pname);
    }
@@ -7578,14 +7586,12 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
    if (!params)
       return;
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    switch (pname) {
       case GL_BLEND:
          CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv");
          if (index >= ctx->Const.MaxDrawBuffers) {
             _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
+            return;
          }
          params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1));
          break;
@@ -7593,6 +7599,7 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
          CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv");
          if (index >= ctx->Const.MaxDrawBuffers) {
             _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
+            return;
          }
          params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0);
          params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0);
@@ -7613,14 +7620,12 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
    if (!params)
       return;
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    switch (pname) {
       case GL_BLEND:
          CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv");
          if (index >= ctx->Const.MaxDrawBuffers) {
             _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
+            return;
          }
          params[0] = ((ctx->Color.BlendEnabled >> index) & 1);
          break;
@@ -7628,6 +7633,7 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
          CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv");
          if (index >= ctx->Const.MaxDrawBuffers) {
             _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
+            return;
          }
          params[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0;
          params[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0;
@@ -7649,14 +7655,12 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
    if (!params)
       return;
 
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
    switch (pname) {
       case GL_BLEND:
          CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv");
          if (index >= ctx->Const.MaxDrawBuffers) {
             _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
+            return;
          }
          params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1));
          break;
@@ -7664,6 +7668,7 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
          CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv");
          if (index >= ctx->Const.MaxDrawBuffers) {
             _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
+            return;
          }
          params[0] = (GLint64)(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0);
          params[1] = (GLint64)(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0);
index 9d5a51d58c53aa86c7166c57bab96c567ee30f3a..cecb86d76a164f47ac27cb57ae0b77a48141b140 100644 (file)
@@ -49,123 +49,132 @@ TypeStrings = {
 }
 
 
+NoState = None
+NoExt = None
+FlushCurrent = 1
+
+
 # Each entry is a tuple of:
 #  - the GL state name, such as GL_CURRENT_COLOR
 #  - the state datatype, one of GLint, GLfloat, GLboolean or GLenum
 #  - list of code fragments to get the state, such as ["ctx->Foo.Bar"]
 #  - optional extra code or empty string.  If present, "CONVERSION" will be
 #    replaced by ENUM_TO_FLOAT, INT_TO_FLOAT, etc.
-#  - optional extensions to check, or None
+#  - state flags: either NoExt, FlushCurrent or "_NEW_xxx"
+#    if NoExt, do nothing special
+#    if FlushCurrent, emit FLUSH_CURRENT() call
+#    if "_NEW_xxx", call _mesa_update_state() if that dirty state flag is set
+#  - optional extensions to check, or NoExt
 #
 StateVars = [
        ( "GL_ACCUM_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.accumRedBits"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_ACCUM_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.accumGreenBits"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_ACCUM_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.accumBlueBits"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_ACCUM_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.accumAlphaBits"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_ACCUM_CLEAR_VALUE", GLfloatN,
          [ "ctx->Accum.ClearColor[0]",
                "ctx->Accum.ClearColor[1]",
                "ctx->Accum.ClearColor[2]",
                "ctx->Accum.ClearColor[3]" ],
-         "", None ),
-       ( "GL_ALPHA_BIAS", GLfloat, ["ctx->Pixel.AlphaBias"], "", None ),
+         "", NoState, NoExt ),
+       ( "GL_ALPHA_BIAS", GLfloat, ["ctx->Pixel.AlphaBias"], "", NoState, NoExt ),
        ( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"],
-         "", None ),
-       ( "GL_ALPHA_SCALE", GLfloat, ["ctx->Pixel.AlphaScale"], "", None ),
-       ( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", None ),
-       ( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", None ),
-       ( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", None ),
-       ( "GL_ATTRIB_STACK_DEPTH", GLint, ["ctx->AttribStackDepth"], "", None ),
-       ( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", None ),
+         "", "_NEW_BUFFERS", NoExt ),
+       ( "GL_ALPHA_SCALE", GLfloat, ["ctx->Pixel.AlphaScale"], "", NoState, NoExt ),
+       ( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", NoState, NoExt ),
+       ( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", NoState, NoExt ),
+       ( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", NoState, NoExt ),
+       ( "GL_ATTRIB_STACK_DEPTH", GLint, ["ctx->AttribStackDepth"], "", NoState, NoExt ),
+       ( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", NoState, NoExt ),
        ( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"],
-         "", None ),
-       ( "GL_BLEND", GLboolean, ["(ctx->Color.BlendEnabled & 1)"], "", None ),
-       ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
-       ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
-       ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
-       ( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
-       ( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", None ),
-       ( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", None ),
-       ( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", None),
+         "", NoState, NoExt ),
+       ( "GL_BLEND", GLboolean, ["(ctx->Color.BlendEnabled & 1)"], "", NoState, NoExt ),
+       ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", NoState, NoExt ),
+       ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", NoState, NoExt ),
+       ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", NoState, NoExt ),
+       ( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", NoState, NoExt ),
+       ( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", NoState, NoExt ),
+       ( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", NoState, NoExt ),
+       ( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", NoState, NoExt),
        ( "GL_BLEND_EQUATION_ALPHA_EXT", GLenum, ["ctx->Color.BlendEquationA "],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_BLEND_COLOR_EXT", GLfloatN,
          [ "ctx->Color.BlendColor[0]",
                "ctx->Color.BlendColor[1]",
                "ctx->Color.BlendColor[2]",
-               "ctx->Color.BlendColor[3]"], "", None ),
-       ( "GL_BLUE_BIAS", GLfloat, ["ctx->Pixel.BlueBias"], "", None ),
-       ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", None ),
-       ( "GL_BLUE_SCALE", GLfloat, ["ctx->Pixel.BlueScale"], "", None ),
+               "ctx->Color.BlendColor[3]"], "", NoState, NoExt ),
+       ( "GL_BLUE_BIAS", GLfloat, ["ctx->Pixel.BlueBias"], "", NoState, NoExt ),
+       ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", "_NEW_BUFFERS", NoExt ),
+       ( "GL_BLUE_SCALE", GLfloat, ["ctx->Pixel.BlueScale"], "", NoState, NoExt ),
        ( "GL_CLIENT_ATTRIB_STACK_DEPTH", GLint,
-         ["ctx->ClientAttribStackDepth"], "", None ),
+         ["ctx->ClientAttribStackDepth"], "", NoState, NoExt ),
        ( "GL_CLIP_PLANE0", GLboolean,
-         [ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", None ),
+         [ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", NoState, NoExt ),
        ( "GL_CLIP_PLANE1", GLboolean,
-         [ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", None ),
+         [ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", NoState, NoExt ),
        ( "GL_CLIP_PLANE2", GLboolean,
-         [ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", None ),
+         [ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", NoState, NoExt ),
        ( "GL_CLIP_PLANE3", GLboolean,
-         [ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", None ),
+         [ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", NoState, NoExt ),
        ( "GL_CLIP_PLANE4", GLboolean,
-         [ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", None ),
+         [ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", NoState, NoExt ),
        ( "GL_CLIP_PLANE5", GLboolean,
-         [ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", None ),
+         [ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", NoState, NoExt ),
        ( "GL_COLOR_CLEAR_VALUE", GLfloatN,
          [ "ctx->Color.ClearColor[0]",
                "ctx->Color.ClearColor[1]",
                "ctx->Color.ClearColor[2]",
-               "ctx->Color.ClearColor[3]" ], "", None ),
+               "ctx->Color.ClearColor[3]" ], "", NoState, NoExt ),
        ( "GL_COLOR_MATERIAL", GLboolean,
-         ["ctx->Light.ColorMaterialEnabled"], "", None ),
+         ["ctx->Light.ColorMaterialEnabled"], "", NoState, NoExt ),
        ( "GL_COLOR_MATERIAL_FACE", GLenum,
-         ["ctx->Light.ColorMaterialFace"], "", None ),
+         ["ctx->Light.ColorMaterialFace"], "", NoState, NoExt ),
        ( "GL_COLOR_MATERIAL_PARAMETER", GLenum,
-         ["ctx->Light.ColorMaterialMode"], "", None ),
+         ["ctx->Light.ColorMaterialMode"], "", NoState, NoExt ),
        ( "GL_COLOR_WRITEMASK", GLint,
          [ "ctx->Color.ColorMask[0][RCOMP] ? 1 : 0",
                "ctx->Color.ColorMask[0][GCOMP] ? 1 : 0",
                "ctx->Color.ColorMask[0][BCOMP] ? 1 : 0",
-               "ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", None ),
-       ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ),
-       ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ),
+               "ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", NoState, NoExt ),
+       ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", NoState, NoExt ),
+       ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", NoState, NoExt ),
        ( "GL_CURRENT_COLOR", GLfloatN,
          [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]",
                "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]",
                "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]",
                "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]" ],
-         "FLUSH_CURRENT(ctx, 0);", None ),
+         "", FlushCurrent, NoExt ),
        ( "GL_CURRENT_INDEX", GLfloat,
          [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]" ],
-         "FLUSH_CURRENT(ctx, 0);", None ),
+         "", FlushCurrent, NoExt ),
        ( "GL_CURRENT_NORMAL", GLfloatN,
          [ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]",
                "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]",
                "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]"],
-         "FLUSH_CURRENT(ctx, 0);", None ),
+         "", FlushCurrent, NoExt ),
        ( "GL_CURRENT_RASTER_COLOR", GLfloatN,
          ["ctx->Current.RasterColor[0]",
           "ctx->Current.RasterColor[1]",
           "ctx->Current.RasterColor[2]",
-          "ctx->Current.RasterColor[3]"], "", None ),
+          "ctx->Current.RasterColor[3]"], "", NoState, NoExt ),
        ( "GL_CURRENT_RASTER_DISTANCE", GLfloat,
-         ["ctx->Current.RasterDistance"], "", None ),
+         ["ctx->Current.RasterDistance"], "", NoState, NoExt ),
        ( "GL_CURRENT_RASTER_INDEX", GLfloat,
-         ["1.0"], "", None ),
+         ["1.0"], "", NoState, NoExt ),
        ( "GL_CURRENT_RASTER_POSITION", GLfloat,
          ["ctx->Current.RasterPos[0]",
           "ctx->Current.RasterPos[1]",
           "ctx->Current.RasterPos[2]",
-          "ctx->Current.RasterPos[3]"], "", None ),
+          "ctx->Current.RasterPos[3]"], "", NoState, NoExt ),
        ( "GL_CURRENT_RASTER_SECONDARY_COLOR", GLfloatN,
          ["ctx->Current.RasterSecondaryColor[0]",
           "ctx->Current.RasterSecondaryColor[1]",
           "ctx->Current.RasterSecondaryColor[2]",
-          "ctx->Current.RasterSecondaryColor[3]"], "", None ),
+          "ctx->Current.RasterSecondaryColor[3]"], "", NoState, NoExt ),
        ( "GL_CURRENT_RASTER_TEXTURE_COORDS", GLfloat,
          ["ctx->Current.RasterTexCoords[unit][0]",
           "ctx->Current.RasterTexCoords[unit][1]",
@@ -177,9 +186,9 @@ StateVars = [
                         "glGet(raster tex coords, unit %u)", unit);
             return;
          }""",
-         None ),
+         NoState, NoExt ),
        ( "GL_CURRENT_RASTER_POSITION_VALID", GLboolean,
-         ["ctx->Current.RasterPosValid"], "", None ),
+         ["ctx->Current.RasterPosValid"], "", NoState, NoExt ),
        ( "GL_CURRENT_TEXTURE_COORDS", GLfloat,
          ["ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]",
           "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]",
@@ -192,85 +201,85 @@ StateVars = [
             return;
          }
          FLUSH_CURRENT(ctx, 0);""",
-         None ),
-       ( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", None ),
+         NoState, NoExt ),
+       ( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", NoState, NoExt ),
        ( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"],
-         "", None ),
-       ( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["((GLfloat) ctx->Depth.Clear)"], "", None ),
-       ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ),
+         "", NoState, NoExt ),
+       ( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["((GLfloat) ctx->Depth.Clear)"], "", NoState, NoExt ),
+       ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", NoState, NoExt ),
        ( "GL_DEPTH_RANGE", GLfloatN,
-         [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", None ),
-       ( "GL_DEPTH_SCALE", GLfloat, ["ctx->Pixel.DepthScale"], "", None ),
-       ( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", None ),
-       ( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", None ),
-       ( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", None ),
+         [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", NoState, NoExt ),
+       ( "GL_DEPTH_SCALE", GLfloat, ["ctx->Pixel.DepthScale"], "", NoState, NoExt ),
+       ( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", NoState, NoExt ),
+       ( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", NoState, NoExt ),
+       ( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", NoState, NoExt ),
        ( "GL_DOUBLEBUFFER", GLboolean,
-         ["ctx->DrawBuffer->Visual.doubleBufferMode"], "", None ),
-       ( "GL_DRAW_BUFFER", GLenum, ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", None ),
+         ["ctx->DrawBuffer->Visual.doubleBufferMode"], "", NoState, NoExt ),
+       ( "GL_DRAW_BUFFER", GLenum, ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", NoState, NoExt ),
        ( "GL_EDGE_FLAG", GLboolean, ["(ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)"],
-         "FLUSH_CURRENT(ctx, 0);", None ),
-       ( "GL_FEEDBACK_BUFFER_SIZE", GLint, ["ctx->Feedback.BufferSize"], "", None ),
-       ( "GL_FEEDBACK_BUFFER_TYPE", GLenum, ["ctx->Feedback.Type"], "", None ),
-       ( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", None ),
+         "", FlushCurrent, NoExt ),
+       ( "GL_FEEDBACK_BUFFER_SIZE", GLint, ["ctx->Feedback.BufferSize"], "", NoState, NoExt ),
+       ( "GL_FEEDBACK_BUFFER_TYPE", GLenum, ["ctx->Feedback.Type"], "", NoState, NoExt ),
+       ( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", NoState, NoExt ),
        ( "GL_FOG_COLOR", GLfloatN,
          [ "ctx->Fog.Color[0]",
                "ctx->Fog.Color[1]",
                "ctx->Fog.Color[2]",
-               "ctx->Fog.Color[3]" ], "", None ),
-       ( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", None ),
-       ( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", None ),
-       ( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", None ),
-       ( "GL_FOG_INDEX", GLfloat, ["ctx->Fog.Index"], "", None ),
-       ( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", None ),
-       ( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", None ),
-       ( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", None ),
-       ( "GL_GREEN_BIAS", GLfloat, ["ctx->Pixel.GreenBias"], "", None ),
+               "ctx->Fog.Color[3]" ], "", NoState, NoExt ),
+       ( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", NoState, NoExt ),
+       ( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", NoState, NoExt ),
+       ( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", NoState, NoExt ),
+       ( "GL_FOG_INDEX", GLfloat, ["ctx->Fog.Index"], "", NoState, NoExt ),
+       ( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", NoState, NoExt ),
+       ( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", NoState, NoExt ),
+       ( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", NoState, NoExt ),
+       ( "GL_GREEN_BIAS", GLfloat, ["ctx->Pixel.GreenBias"], "", NoState, NoExt ),
        ( "GL_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.greenBits"],
-         "", None ),
-       ( "GL_GREEN_SCALE", GLfloat, ["ctx->Pixel.GreenScale"], "", None ),
+         "", "_NEW_BUFFERS", NoExt ),
+       ( "GL_GREEN_SCALE", GLfloat, ["ctx->Pixel.GreenScale"], "", NoState, NoExt ),
        ( "GL_INDEX_BITS", GLint, ["ctx->DrawBuffer->Visual.indexBits"],
-         "", None ),
-       ( "GL_INDEX_CLEAR_VALUE", GLint, ["ctx->Color.ClearIndex"], "", None ),
+         "", "_NEW_BUFFERS", NoExt ),
+       ( "GL_INDEX_CLEAR_VALUE", GLint, ["ctx->Color.ClearIndex"], "", NoState, NoExt ),
        ( "GL_INDEX_MODE", GLboolean, ["GL_FALSE"],
-         "", None ),
-       ( "GL_INDEX_OFFSET", GLint, ["ctx->Pixel.IndexOffset"], "", None ),
-       ( "GL_INDEX_SHIFT", GLint, ["ctx->Pixel.IndexShift"], "", None ),
-       ( "GL_INDEX_WRITEMASK", GLint, ["ctx->Color.IndexMask"], "", None ),
-       ( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", None ),
-       ( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", None ),
-       ( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", None ),
-       ( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", None ),
-       ( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", None ),
-       ( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", None ),
-       ( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", None ),
-       ( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", None ),
-       ( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", None ),
+         "", NoState, NoExt ),
+       ( "GL_INDEX_OFFSET", GLint, ["ctx->Pixel.IndexOffset"], "", NoState, NoExt ),
+       ( "GL_INDEX_SHIFT", GLint, ["ctx->Pixel.IndexShift"], "", NoState, NoExt ),
+       ( "GL_INDEX_WRITEMASK", GLint, ["ctx->Color.IndexMask"], "", NoState, NoExt ),
+       ( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", NoState, NoExt ),
+       ( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", NoState, NoExt ),
+       ( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", NoState, NoExt ),
+       ( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", NoState, NoExt ),
+       ( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", NoState, NoExt ),
+       ( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", NoState, NoExt ),
+       ( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", NoState, NoExt ),
+       ( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", NoState, NoExt ),
+       ( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", NoState, NoExt ),
        ( "GL_LIGHT_MODEL_AMBIENT", GLfloatN,
          ["ctx->Light.Model.Ambient[0]",
           "ctx->Light.Model.Ambient[1]",
           "ctx->Light.Model.Ambient[2]",
-          "ctx->Light.Model.Ambient[3]"], "", None ),
+          "ctx->Light.Model.Ambient[3]"], "", NoState, NoExt ),
        ( "GL_LIGHT_MODEL_COLOR_CONTROL", GLenum,
-         ["ctx->Light.Model.ColorControl"], "", None ),
+         ["ctx->Light.Model.ColorControl"], "", NoState, NoExt ),
        ( "GL_LIGHT_MODEL_LOCAL_VIEWER", GLboolean,
-         ["ctx->Light.Model.LocalViewer"], "", None ),
-       ( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", None ),
-       ( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", None ),
-       ( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", None ),
-       ( "GL_LINE_STIPPLE", GLboolean, ["ctx->Line.StippleFlag"], "", None ),
-       ( "GL_LINE_STIPPLE_PATTERN", GLint, ["ctx->Line.StipplePattern"], "", None ),
-       ( "GL_LINE_STIPPLE_REPEAT", GLint, ["ctx->Line.StippleFactor"], "", None ),
-       ( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", None ),
+         ["ctx->Light.Model.LocalViewer"], "", NoState, NoExt ),
+       ( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", NoState, NoExt ),
+       ( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", NoState, NoExt ),
+       ( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", NoState, NoExt ),
+       ( "GL_LINE_STIPPLE", GLboolean, ["ctx->Line.StippleFlag"], "", NoState, NoExt ),
+       ( "GL_LINE_STIPPLE_PATTERN", GLint, ["ctx->Line.StipplePattern"], "", NoState, NoExt ),
+       ( "GL_LINE_STIPPLE_REPEAT", GLint, ["ctx->Line.StippleFactor"], "", NoState, NoExt ),
+       ( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", NoState, NoExt ),
        ( "GL_LINE_WIDTH_GRANULARITY", GLfloat,
-         ["ctx->Const.LineWidthGranularity"], "", None ),
+         ["ctx->Const.LineWidthGranularity"], "", NoState, NoExt ),
        ( "GL_LINE_WIDTH_RANGE", GLfloat,
          ["ctx->Const.MinLineWidthAA",
-          "ctx->Const.MaxLineWidthAA"], "", None ),
+          "ctx->Const.MaxLineWidthAA"], "", NoState, NoExt ),
        ( "GL_ALIASED_LINE_WIDTH_RANGE", GLfloat,
          ["ctx->Const.MinLineWidth",
-          "ctx->Const.MaxLineWidth"], "", None ),
-       ( "GL_LIST_BASE", GLint, ["ctx->List.ListBase"], "", None ),
-       ( "GL_LIST_INDEX", GLint, ["(ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)"], "", None ),
+          "ctx->Const.MaxLineWidth"], "", NoState, NoExt ),
+       ( "GL_LIST_BASE", GLint, ["ctx->List.ListBase"], "", NoState, NoExt ),
+       ( "GL_LIST_INDEX", GLint, ["(ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)"], "", NoState, NoExt ),
        ( "GL_LIST_MODE", GLenum, ["mode"],
          """GLenum mode;
          if (!ctx->CompileFlag)
@@ -278,193 +287,195 @@ StateVars = [
          else if (ctx->ExecuteFlag)
             mode = GL_COMPILE_AND_EXECUTE;
          else
-            mode = GL_COMPILE;""", None ),
-       ( "GL_INDEX_LOGIC_OP", GLboolean, ["ctx->Color.IndexLogicOpEnabled"], "", None ),
-       ( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", None ),
-       ( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", None ),
-       ( "GL_MAP1_COLOR_4", GLboolean, ["ctx->Eval.Map1Color4"], "", None ),
+            mode = GL_COMPILE;""", NoState, NoExt ),
+       ( "GL_INDEX_LOGIC_OP", GLboolean, ["ctx->Color.IndexLogicOpEnabled"], "", NoState, NoExt ),
+       ( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", NoState, NoExt ),
+       ( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", NoState, NoExt ),
+       ( "GL_MAP1_COLOR_4", GLboolean, ["ctx->Eval.Map1Color4"], "", NoState, NoExt ),
        ( "GL_MAP1_GRID_DOMAIN", GLfloat,
          ["ctx->Eval.MapGrid1u1",
-          "ctx->Eval.MapGrid1u2"], "", None ),
-       ( "GL_MAP1_GRID_SEGMENTS", GLint, ["ctx->Eval.MapGrid1un"], "", None ),
-       ( "GL_MAP1_INDEX", GLboolean, ["ctx->Eval.Map1Index"], "", None ),
-       ( "GL_MAP1_NORMAL", GLboolean, ["ctx->Eval.Map1Normal"], "", None ),
-       ( "GL_MAP1_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map1TextureCoord1"], "", None ),
-       ( "GL_MAP1_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map1TextureCoord2"], "", None ),
-       ( "GL_MAP1_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map1TextureCoord3"], "", None ),
-       ( "GL_MAP1_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map1TextureCoord4"], "", None ),
-       ( "GL_MAP1_VERTEX_3", GLboolean, ["ctx->Eval.Map1Vertex3"], "", None ),
-       ( "GL_MAP1_VERTEX_4", GLboolean, ["ctx->Eval.Map1Vertex4"], "", None ),
-       ( "GL_MAP2_COLOR_4", GLboolean, ["ctx->Eval.Map2Color4"], "", None ),
+          "ctx->Eval.MapGrid1u2"], "", NoState, NoExt ),
+       ( "GL_MAP1_GRID_SEGMENTS", GLint, ["ctx->Eval.MapGrid1un"], "", NoState, NoExt ),
+       ( "GL_MAP1_INDEX", GLboolean, ["ctx->Eval.Map1Index"], "", NoState, NoExt ),
+       ( "GL_MAP1_NORMAL", GLboolean, ["ctx->Eval.Map1Normal"], "", NoState, NoExt ),
+       ( "GL_MAP1_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map1TextureCoord1"], "", NoState, NoExt ),
+       ( "GL_MAP1_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map1TextureCoord2"], "", NoState, NoExt ),
+       ( "GL_MAP1_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map1TextureCoord3"], "", NoState, NoExt ),
+       ( "GL_MAP1_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map1TextureCoord4"], "", NoState, NoExt ),
+       ( "GL_MAP1_VERTEX_3", GLboolean, ["ctx->Eval.Map1Vertex3"], "", NoState, NoExt ),
+       ( "GL_MAP1_VERTEX_4", GLboolean, ["ctx->Eval.Map1Vertex4"], "", NoState, NoExt ),
+       ( "GL_MAP2_COLOR_4", GLboolean, ["ctx->Eval.Map2Color4"], "", NoState, NoExt ),
        ( "GL_MAP2_GRID_DOMAIN", GLfloat,
          ["ctx->Eval.MapGrid2u1",
           "ctx->Eval.MapGrid2u2",
           "ctx->Eval.MapGrid2v1",
-          "ctx->Eval.MapGrid2v2"], "", None ),
+          "ctx->Eval.MapGrid2v2"], "", NoState, NoExt ),
        ( "GL_MAP2_GRID_SEGMENTS", GLint,
          ["ctx->Eval.MapGrid2un",
-          "ctx->Eval.MapGrid2vn"], "", None ),
-       ( "GL_MAP2_INDEX", GLboolean, ["ctx->Eval.Map2Index"], "", None ),
-       ( "GL_MAP2_NORMAL", GLboolean, ["ctx->Eval.Map2Normal"], "", None ),
-       ( "GL_MAP2_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map2TextureCoord1"], "", None ),
-       ( "GL_MAP2_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map2TextureCoord2"], "", None ),
-       ( "GL_MAP2_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map2TextureCoord3"], "", None ),
-       ( "GL_MAP2_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map2TextureCoord4"], "", None ),
-       ( "GL_MAP2_VERTEX_3", GLboolean, ["ctx->Eval.Map2Vertex3"], "", None ),
-       ( "GL_MAP2_VERTEX_4", GLboolean, ["ctx->Eval.Map2Vertex4"], "", None ),
-       ( "GL_MAP_COLOR", GLboolean, ["ctx->Pixel.MapColorFlag"], "", None ),
-       ( "GL_MAP_STENCIL", GLboolean, ["ctx->Pixel.MapStencilFlag"], "", None ),
-       ( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", None ),
-
-       ( "GL_MAX_ATTRIB_STACK_DEPTH", GLint, ["MAX_ATTRIB_STACK_DEPTH"], "", None ),
-       ( "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", GLint, ["MAX_CLIENT_ATTRIB_STACK_DEPTH"], "", None ),
-       ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ),
-       ( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ),
-       ( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ),
-       ( "GL_MAX_EVAL_ORDER", GLint, ["MAX_EVAL_ORDER"], "", None ),
-       ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ),
-       ( "GL_MAX_LIST_NESTING", GLint, ["MAX_LIST_NESTING"], "", None ),
-       ( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", None ),
-       ( "GL_MAX_NAME_STACK_DEPTH", GLint, ["MAX_NAME_STACK_DEPTH"], "", None ),
-       ( "GL_MAX_PIXEL_MAP_TABLE", GLint, ["MAX_PIXEL_MAP_TABLE"], "", None ),
-       ( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", None ),
-       ( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", None ),
-       ( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", None ),
-       ( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", None ),
+          "ctx->Eval.MapGrid2vn"], "", NoState, NoExt ),
+       ( "GL_MAP2_INDEX", GLboolean, ["ctx->Eval.Map2Index"], "", NoState, NoExt ),
+       ( "GL_MAP2_NORMAL", GLboolean, ["ctx->Eval.Map2Normal"], "", NoState, NoExt ),
+       ( "GL_MAP2_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map2TextureCoord1"], "", NoState, NoExt ),
+       ( "GL_MAP2_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map2TextureCoord2"], "", NoState, NoExt ),
+       ( "GL_MAP2_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map2TextureCoord3"], "", NoState, NoExt ),
+       ( "GL_MAP2_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map2TextureCoord4"], "", NoState, NoExt ),
+       ( "GL_MAP2_VERTEX_3", GLboolean, ["ctx->Eval.Map2Vertex3"], "", NoState, NoExt ),
+       ( "GL_MAP2_VERTEX_4", GLboolean, ["ctx->Eval.Map2Vertex4"], "", NoState, NoExt ),
+       ( "GL_MAP_COLOR", GLboolean, ["ctx->Pixel.MapColorFlag"], "", NoState, NoExt ),
+       ( "GL_MAP_STENCIL", GLboolean, ["ctx->Pixel.MapStencilFlag"], "", NoState, NoExt ),
+       ( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", NoState, NoExt ),
+
+       ( "GL_MAX_ATTRIB_STACK_DEPTH", GLint, ["MAX_ATTRIB_STACK_DEPTH"], "", NoState, NoExt ),
+       ( "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", GLint, ["MAX_CLIENT_ATTRIB_STACK_DEPTH"], "", NoState, NoExt ),
+       ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", NoState, NoExt ),
+       ( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", NoState, NoExt ),
+       ( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", NoState, NoExt ),
+       ( "GL_MAX_EVAL_ORDER", GLint, ["MAX_EVAL_ORDER"], "", NoState, NoExt ),
+       ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", NoState, NoExt ),
+       ( "GL_MAX_LIST_NESTING", GLint, ["MAX_LIST_NESTING"], "", NoState, NoExt ),
+       ( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", NoState, NoExt ),
+       ( "GL_MAX_NAME_STACK_DEPTH", GLint, ["MAX_NAME_STACK_DEPTH"], "", NoState, NoExt ),
+       ( "GL_MAX_PIXEL_MAP_TABLE", GLint, ["MAX_PIXEL_MAP_TABLE"], "", NoState, NoExt ),
+       ( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", NoState, NoExt ),
+       ( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", NoState, NoExt ),
+       ( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", NoState, NoExt ),
+       ( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", NoState, NoExt ),
        ( "GL_MAX_VIEWPORT_DIMS", GLint,
          ["ctx->Const.MaxViewportWidth", "ctx->Const.MaxViewportHeight"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_MODELVIEW_MATRIX", GLfloat,
          [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
                "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
                "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
                "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
-         "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ),
-       ( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", None ),
-       ( "GL_NAME_STACK_DEPTH", GLint, ["ctx->Select.NameStackDepth"], "", None ),
-       ( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", None ),
-       ( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", None ),
-       ( "GL_PACK_LSB_FIRST", GLboolean, ["ctx->Pack.LsbFirst"], "", None ),
-       ( "GL_PACK_ROW_LENGTH", GLint, ["ctx->Pack.RowLength"], "", None ),
-       ( "GL_PACK_SKIP_PIXELS", GLint, ["ctx->Pack.SkipPixels"], "", None ),
-       ( "GL_PACK_SKIP_ROWS", GLint, ["ctx->Pack.SkipRows"], "", None ),
-       ( "GL_PACK_SWAP_BYTES", GLboolean, ["ctx->Pack.SwapBytes"], "", None ),
-       ( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", None ),
-       ( "GL_PACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Pack.ImageHeight"], "", None ),
-       ( "GL_PACK_INVERT_MESA", GLboolean, ["ctx->Pack.Invert"], "", None ),
+         "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", NoState, NoExt ),
+       ( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", NoState, NoExt ),
+       ( "GL_NAME_STACK_DEPTH", GLint, ["ctx->Select.NameStackDepth"], "", NoState, NoExt ),
+       ( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", NoState, NoExt ),
+       ( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", NoState, NoExt ),
+       ( "GL_PACK_LSB_FIRST", GLboolean, ["ctx->Pack.LsbFirst"], "", NoState, NoExt ),
+       ( "GL_PACK_ROW_LENGTH", GLint, ["ctx->Pack.RowLength"], "", NoState, NoExt ),
+       ( "GL_PACK_SKIP_PIXELS", GLint, ["ctx->Pack.SkipPixels"], "", NoState, NoExt ),
+       ( "GL_PACK_SKIP_ROWS", GLint, ["ctx->Pack.SkipRows"], "", NoState, NoExt ),
+       ( "GL_PACK_SWAP_BYTES", GLboolean, ["ctx->Pack.SwapBytes"], "", NoState, NoExt ),
+       ( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", NoState, NoExt ),
+       ( "GL_PACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Pack.ImageHeight"], "", NoState, NoExt ),
+       ( "GL_PACK_INVERT_MESA", GLboolean, ["ctx->Pack.Invert"], "", NoState, NoExt ),
        ( "GL_PERSPECTIVE_CORRECTION_HINT", GLenum,
-         ["ctx->Hint.PerspectiveCorrection"], "", None ),
-       ( "GL_PIXEL_MAP_A_TO_A_SIZE", GLint, ["ctx->PixelMaps.AtoA.Size"], "", None ),
-       ( "GL_PIXEL_MAP_B_TO_B_SIZE", GLint, ["ctx->PixelMaps.BtoB.Size"], "", None ),
-       ( "GL_PIXEL_MAP_G_TO_G_SIZE", GLint, ["ctx->PixelMaps.GtoG.Size"], "", None ),
-       ( "GL_PIXEL_MAP_I_TO_A_SIZE", GLint, ["ctx->PixelMaps.ItoA.Size"], "", None ),
-       ( "GL_PIXEL_MAP_I_TO_B_SIZE", GLint, ["ctx->PixelMaps.ItoB.Size"], "", None ),
-       ( "GL_PIXEL_MAP_I_TO_G_SIZE", GLint, ["ctx->PixelMaps.ItoG.Size"], "", None ),
-       ( "GL_PIXEL_MAP_I_TO_I_SIZE", GLint, ["ctx->PixelMaps.ItoI.Size"], "", None ),
-       ( "GL_PIXEL_MAP_I_TO_R_SIZE", GLint, ["ctx->PixelMaps.ItoR.Size"], "", None ),
-       ( "GL_PIXEL_MAP_R_TO_R_SIZE", GLint, ["ctx->PixelMaps.RtoR.Size"], "", None ),
-       ( "GL_PIXEL_MAP_S_TO_S_SIZE", GLint, ["ctx->PixelMaps.StoS.Size"], "", None ),
-       ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", None ),
+         ["ctx->Hint.PerspectiveCorrection"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_A_TO_A_SIZE", GLint, ["ctx->PixelMaps.AtoA.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_B_TO_B_SIZE", GLint, ["ctx->PixelMaps.BtoB.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_G_TO_G_SIZE", GLint, ["ctx->PixelMaps.GtoG.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_I_TO_A_SIZE", GLint, ["ctx->PixelMaps.ItoA.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_I_TO_B_SIZE", GLint, ["ctx->PixelMaps.ItoB.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_I_TO_G_SIZE", GLint, ["ctx->PixelMaps.ItoG.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_I_TO_I_SIZE", GLint, ["ctx->PixelMaps.ItoI.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_I_TO_R_SIZE", GLint, ["ctx->PixelMaps.ItoR.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_R_TO_R_SIZE", GLint, ["ctx->PixelMaps.RtoR.Size"], "", NoState, NoExt ),
+       ( "GL_PIXEL_MAP_S_TO_S_SIZE", GLint, ["ctx->PixelMaps.StoS.Size"], "", NoState, NoExt ),
+       ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", NoState, NoExt ),
        ( "GL_POINT_SIZE_GRANULARITY", GLfloat,
-         ["ctx->Const.PointSizeGranularity"], "", None ),
+         ["ctx->Const.PointSizeGranularity"], "", NoState, NoExt ),
        ( "GL_POINT_SIZE_RANGE", GLfloat,
          ["ctx->Const.MinPointSizeAA",
-          "ctx->Const.MaxPointSizeAA"], "", None ),
+          "ctx->Const.MaxPointSizeAA"], "", NoState, NoExt ),
        ( "GL_ALIASED_POINT_SIZE_RANGE", GLfloat,
          ["ctx->Const.MinPointSize",
-          "ctx->Const.MaxPointSize"], "", None ),
-       ( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", None ),
-       ( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", None ),
-       ( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", None ),
-       ( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", None ),
+          "ctx->Const.MaxPointSize"], "", NoState, NoExt ),
+       ( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", NoState, NoExt ),
+       ( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", NoState, NoExt ),
+       ( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", NoState, NoExt ),
+       ( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", NoState, NoExt ),
        ( "GL_POINT_FADE_THRESHOLD_SIZE_EXT", GLfloat,
-         ["ctx->Point.Threshold"], "", None ),
+         ["ctx->Point.Threshold"], "", NoState, NoExt ),
        ( "GL_DISTANCE_ATTENUATION_EXT", GLfloat,
          ["ctx->Point.Params[0]",
           "ctx->Point.Params[1]",
-          "ctx->Point.Params[2]"], "", None ),
+          "ctx->Point.Params[2]"], "", NoState, NoExt ),
        ( "GL_POLYGON_MODE", GLenum,
          ["ctx->Polygon.FrontMode",
-          "ctx->Polygon.BackMode"], "", None ),
-       ( "GL_POLYGON_OFFSET_BIAS_EXT", GLfloat, ["ctx->Polygon.OffsetUnits"], "", None ),
-       ( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", None ),
-       ( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", None ),
-       ( "GL_POLYGON_OFFSET_POINT", GLboolean, ["ctx->Polygon.OffsetPoint"], "", None ),
-       ( "GL_POLYGON_OFFSET_LINE", GLboolean, ["ctx->Polygon.OffsetLine"], "", None ),
-       ( "GL_POLYGON_OFFSET_FILL", GLboolean, ["ctx->Polygon.OffsetFill"], "", None ),
-       ( "GL_POLYGON_SMOOTH", GLboolean, ["ctx->Polygon.SmoothFlag"], "", None ),
-       ( "GL_POLYGON_SMOOTH_HINT", GLenum, ["ctx->Hint.PolygonSmooth"], "", None ),
-       ( "GL_POLYGON_STIPPLE", GLboolean, ["ctx->Polygon.StippleFlag"], "", None ),
+          "ctx->Polygon.BackMode"], "", NoState, NoExt ),
+       ( "GL_POLYGON_OFFSET_BIAS_EXT", GLfloat, ["ctx->Polygon.OffsetUnits"], "", NoState, NoExt ),
+       ( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", NoState, NoExt ),
+       ( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", NoState, NoExt ),
+       ( "GL_POLYGON_OFFSET_POINT", GLboolean, ["ctx->Polygon.OffsetPoint"], "", NoState, NoExt ),
+       ( "GL_POLYGON_OFFSET_LINE", GLboolean, ["ctx->Polygon.OffsetLine"], "", NoState, NoExt ),
+       ( "GL_POLYGON_OFFSET_FILL", GLboolean, ["ctx->Polygon.OffsetFill"], "", NoState, NoExt ),
+       ( "GL_POLYGON_SMOOTH", GLboolean, ["ctx->Polygon.SmoothFlag"], "", NoState, NoExt ),
+       ( "GL_POLYGON_SMOOTH_HINT", GLenum, ["ctx->Hint.PolygonSmooth"], "", NoState, NoExt ),
+       ( "GL_POLYGON_STIPPLE", GLboolean, ["ctx->Polygon.StippleFlag"], "", NoState, NoExt ),
        ( "GL_PROJECTION_MATRIX", GLfloat,
          [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
                "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
                "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
                "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
-         "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ),
+         "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", NoState, NoExt ),
        ( "GL_PROJECTION_STACK_DEPTH", GLint,
-         ["ctx->ProjectionMatrixStack.Depth + 1"], "", None ),
-       ( "GL_READ_BUFFER", GLenum, ["ctx->ReadBuffer->ColorReadBuffer"], "", None ),
-       ( "GL_RED_BIAS", GLfloat, ["ctx->Pixel.RedBias"], "", None ),
-       ( "GL_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.redBits"], "", None ),
-       ( "GL_RED_SCALE", GLfloat, ["ctx->Pixel.RedScale"], "", None ),
-       ( "GL_RENDER_MODE", GLenum, ["ctx->RenderMode"], "", None ),
+         ["ctx->ProjectionMatrixStack.Depth + 1"], "", NoState, NoExt ),
+       ( "GL_READ_BUFFER", GLenum, ["ctx->ReadBuffer->ColorReadBuffer"], "", NoState, NoExt ),
+       ( "GL_RED_BIAS", GLfloat, ["ctx->Pixel.RedBias"], "", NoState, NoExt ),
+       ( "GL_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.redBits"], "", "_NEW_BUFFERS", NoExt ),
+       ( "GL_RED_SCALE", GLfloat, ["ctx->Pixel.RedScale"], "", NoState, NoExt ),
+       ( "GL_RENDER_MODE", GLenum, ["ctx->RenderMode"], "", NoState, NoExt ),
        ( "GL_RESCALE_NORMAL", GLboolean,
-         ["ctx->Transform.RescaleNormals"], "", None ),
+         ["ctx->Transform.RescaleNormals"], "", NoState, NoExt ),
        ( "GL_RGBA_MODE", GLboolean, ["GL_TRUE"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_SCISSOR_BOX", GLint,
          ["ctx->Scissor.X",
           "ctx->Scissor.Y",
           "ctx->Scissor.Width",
-          "ctx->Scissor.Height"], "", None ),
-       ( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", None ),
-       ( "GL_SELECTION_BUFFER_SIZE", GLint, ["ctx->Select.BufferSize"], "", None ),
-       ( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", None ),
+          "ctx->Scissor.Height"], "", NoState, NoExt ),
+       ( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", NoState, NoExt ),
+       ( "GL_SELECTION_BUFFER_SIZE", GLint, ["ctx->Select.BufferSize"], "", NoState, NoExt ),
+       ( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", NoState, NoExt ),
        ( "GL_SHARED_TEXTURE_PALETTE_EXT", GLboolean,
-         ["ctx->Texture.SharedPalette"], "", None ),
-       ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", None ),
-       ( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", None ),
+         ["ctx->Texture.SharedPalette"], "", NoState, NoExt ),
+       ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", NoState, NoExt ),
+       ( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", NoState, NoExt ),
        ( "GL_STENCIL_FAIL", GLenum,
-         ["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", None ),
+         ["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ),
        ( "GL_STENCIL_FUNC", GLenum,
-         ["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", None ),
+         ["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ),
        ( "GL_STENCIL_PASS_DEPTH_FAIL", GLenum,
-         ["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", None ),
+         ["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ),
        ( "GL_STENCIL_PASS_DEPTH_PASS", GLenum,
-         ["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", None ),
+         ["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ),
        ( "GL_STENCIL_REF", GLint,
-         ["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", None ),
-       ( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", None ),
+         ["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ),
+       ( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", NoState, NoExt ),
        ( "GL_STENCIL_VALUE_MASK", GLint,
-         ["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", None ),
+         ["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ),
        ( "GL_STENCIL_WRITEMASK", GLint,
-         ["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", None ),
+         ["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ),
        ( "GL_STEREO", GLboolean, ["ctx->DrawBuffer->Visual.stereoMode"],
-         "", None ),
-       ( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", None ),
-       ( "GL_TEXTURE_1D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D)"], "", None ),
-       ( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", None ),
-       ( "GL_TEXTURE_3D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_3D)"], "", None ),
-       ( "GL_TEXTURE_1D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)"], "", ["MESA_texture_array"] ),
-       ( "GL_TEXTURE_2D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)"], "", ["MESA_texture_array"] ),
+         "", NoState, NoExt ),
+       ( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", NoState, NoExt ),
+       ( "GL_TEXTURE_1D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D)"], "", NoState, NoExt ),
+       ( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", NoState, NoExt ),
+       ( "GL_TEXTURE_3D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_3D)"], "", NoState, NoExt ),
+       ( "GL_TEXTURE_1D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)"], "", NoState, ["MESA_texture_array"] ),
+       ( "GL_TEXTURE_2D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)"], "", NoState, ["MESA_texture_array"] ),
        ( "GL_TEXTURE_BINDING_1D", GLint,
-         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name"], "", None ),
+         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name"], "", NoState, NoExt ),
        ( "GL_TEXTURE_BINDING_2D", GLint,
-         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name"], "", None ),
+         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name"], "", NoState, NoExt ),
        ( "GL_TEXTURE_BINDING_3D", GLint,
-         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name"], "", None ),
+         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name"], "", NoState, NoExt ),
        ( "GL_TEXTURE_BINDING_1D_ARRAY_EXT", GLint,
-         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name"], "", ["MESA_texture_array"] ),
+         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name"], "", NoState, ["MESA_texture_array"] ),
        ( "GL_TEXTURE_BINDING_2D_ARRAY_EXT", GLint,
-         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name"], "", ["MESA_texture_array"] ),
+         ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name"], "", NoState, ["MESA_texture_array"] ),
+       ( "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT", GLint,
+         ["ctx->Const.MaxArrayTextureLayers"], "", NoState, ["MESA_texture_array"] ),
        ( "GL_TEXTURE_GEN_S", GLboolean,
-         ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None ),
+         ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", NoState, NoExt ),
        ( "GL_TEXTURE_GEN_T", GLboolean,
-         ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", None ),
+         ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", NoState, NoExt ),
        ( "GL_TEXTURE_GEN_R", GLboolean,
-         ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", None ),
+         ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", NoState, NoExt ),
        ( "GL_TEXTURE_GEN_Q", GLboolean,
-         ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)"], "", None ),
+         ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)"], "", NoState, NoExt ),
        ( "GL_TEXTURE_MATRIX", GLfloat,
          ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
           "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
@@ -478,7 +489,7 @@ StateVars = [
             return;
          }
          matrix = ctx->TextureMatrixStack[unit].Top->m;""",
-         None ),
+         NoState, NoExt ),
        ( "GL_TEXTURE_STACK_DEPTH", GLint,
          ["ctx->TextureMatrixStack[unit].Depth + 1"],
          """const GLuint unit = ctx->Texture.CurrentUnit;
@@ -487,77 +498,77 @@ StateVars = [
                         "glGet(texture stack depth, unit %u)", unit);
             return;
          }""",
-         None ),
-       ( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", None ),
-       ( "GL_UNPACK_LSB_FIRST", GLboolean, ["ctx->Unpack.LsbFirst"], "", None ),
-       ( "GL_UNPACK_ROW_LENGTH", GLint, ["ctx->Unpack.RowLength"], "", None ),
-       ( "GL_UNPACK_SKIP_PIXELS", GLint, ["ctx->Unpack.SkipPixels"], "", None ),
-       ( "GL_UNPACK_SKIP_ROWS", GLint, ["ctx->Unpack.SkipRows"], "", None ),
-       ( "GL_UNPACK_SWAP_BYTES", GLboolean, ["ctx->Unpack.SwapBytes"], "", None ),
-       ( "GL_UNPACK_SKIP_IMAGES_EXT", GLint, ["ctx->Unpack.SkipImages"], "", None ),
-       ( "GL_UNPACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Unpack.ImageHeight"], "", None ),
-       ( "GL_UNPACK_CLIENT_STORAGE_APPLE", GLboolean, ["ctx->Unpack.ClientStorage"], "", None ),
+         NoState, NoExt ),
+       ( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", NoState, NoExt ),
+       ( "GL_UNPACK_LSB_FIRST", GLboolean, ["ctx->Unpack.LsbFirst"], "", NoState, NoExt ),
+       ( "GL_UNPACK_ROW_LENGTH", GLint, ["ctx->Unpack.RowLength"], "", NoState, NoExt ),
+       ( "GL_UNPACK_SKIP_PIXELS", GLint, ["ctx->Unpack.SkipPixels"], "", NoState, NoExt ),
+       ( "GL_UNPACK_SKIP_ROWS", GLint, ["ctx->Unpack.SkipRows"], "", NoState, NoExt ),
+       ( "GL_UNPACK_SWAP_BYTES", GLboolean, ["ctx->Unpack.SwapBytes"], "", NoState, NoExt ),
+       ( "GL_UNPACK_SKIP_IMAGES_EXT", GLint, ["ctx->Unpack.SkipImages"], "", NoState, NoExt ),
+       ( "GL_UNPACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Unpack.ImageHeight"], "", NoState, NoExt ),
+       ( "GL_UNPACK_CLIENT_STORAGE_APPLE", GLboolean, ["ctx->Unpack.ClientStorage"], "", NoState, NoExt ),
        ( "GL_VIEWPORT", GLint, [ "ctx->Viewport.X", "ctx->Viewport.Y",
-         "ctx->Viewport.Width", "ctx->Viewport.Height" ], "", None ),
-       ( "GL_ZOOM_X", GLfloat, ["ctx->Pixel.ZoomX"], "", None ),
-       ( "GL_ZOOM_Y", GLfloat, ["ctx->Pixel.ZoomY"], "", None ),
+         "ctx->Viewport.Width", "ctx->Viewport.Height" ], "", NoState, NoExt ),
+       ( "GL_ZOOM_X", GLfloat, ["ctx->Pixel.ZoomX"], "", NoState, NoExt ),
+       ( "GL_ZOOM_Y", GLfloat, ["ctx->Pixel.ZoomY"], "", NoState, NoExt ),
 
        # Vertex arrays
-       ( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Vertex.Enabled"], "", None ),
-       ( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Vertex.Size"], "", None ),
-       ( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Vertex.Type"], "", None ),
-       ( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Vertex.Stride"], "", None ),
-       ( "GL_VERTEX_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
-       ( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.ArrayObj->Normal.Enabled"], "", None ),
-       ( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Normal.Type"], "", None ),
-       ( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Normal.Stride"], "", None ),
-       ( "GL_NORMAL_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
-       ( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Color.Enabled"], "", None ),
-       ( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Color.Size"], "", None ),
-       ( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Color.Type"], "", None ),
-       ( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Color.Stride"], "", None ),
-       ( "GL_COLOR_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
-       ( "GL_INDEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Index.Enabled"], "", None ),
-       ( "GL_INDEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Index.Type"], "", None ),
-       ( "GL_INDEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Index.Stride"], "", None ),
-       ( "GL_INDEX_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
+       ( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Vertex.Enabled"], "", NoState, NoExt ),
+       ( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Vertex.Size"], "", NoState, NoExt ),
+       ( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Vertex.Type"], "", NoState, NoExt ),
+       ( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Vertex.Stride"], "", NoState, NoExt ),
+       ( "GL_VERTEX_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ),
+       ( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.ArrayObj->Normal.Enabled"], "", NoState, NoExt ),
+       ( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Normal.Type"], "", NoState, NoExt ),
+       ( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Normal.Stride"], "", NoState, NoExt ),
+       ( "GL_NORMAL_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ),
+       ( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Color.Enabled"], "", NoState, NoExt ),
+       ( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Color.Size"], "", NoState, NoExt ),
+       ( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Color.Type"], "", NoState, NoExt ),
+       ( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Color.Stride"], "", NoState, NoExt ),
+       ( "GL_COLOR_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ),
+       ( "GL_INDEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Index.Enabled"], "", NoState, NoExt ),
+       ( "GL_INDEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Index.Type"], "", NoState, NoExt ),
+       ( "GL_INDEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Index.Stride"], "", NoState, NoExt ),
+       ( "GL_INDEX_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ),
        ( "GL_TEXTURE_COORD_ARRAY", GLboolean,
-         ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled"], "", None ),
+         ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled"], "", NoState, NoExt ),
        ( "GL_TEXTURE_COORD_ARRAY_SIZE", GLint,
-         ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size"], "", None ),
+         ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size"], "", NoState, NoExt ),
        ( "GL_TEXTURE_COORD_ARRAY_TYPE", GLenum,
-         ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type"], "", None ),
+         ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type"], "", NoState, NoExt ),
        ( "GL_TEXTURE_COORD_ARRAY_STRIDE", GLint,
-         ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride"], "", None ),
-       ( "GL_TEXTURE_COORD_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
-       ( "GL_EDGE_FLAG_ARRAY", GLboolean, ["ctx->Array.ArrayObj->EdgeFlag.Enabled"], "", None ),
-       ( "GL_EDGE_FLAG_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->EdgeFlag.Stride"], "", None ),
-       ( "GL_EDGE_FLAG_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
+         ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride"], "", NoState, NoExt ),
+       ( "GL_TEXTURE_COORD_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ),
+       ( "GL_EDGE_FLAG_ARRAY", GLboolean, ["ctx->Array.ArrayObj->EdgeFlag.Enabled"], "", NoState, NoExt ),
+       ( "GL_EDGE_FLAG_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->EdgeFlag.Stride"], "", NoState, NoExt ),
+       ( "GL_EDGE_FLAG_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ),
 
        # GL_ARB_multitexture
        ( "GL_MAX_TEXTURE_UNITS_ARB", GLint,
-         ["ctx->Const.MaxTextureUnits"], "", ["ARB_multitexture"] ),
+         ["ctx->Const.MaxTextureUnits"], "", NoState, ["ARB_multitexture"] ),
        ( "GL_ACTIVE_TEXTURE_ARB", GLint,
-         [ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", ["ARB_multitexture"] ),
+         [ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", NoState, ["ARB_multitexture"] ),
        ( "GL_CLIENT_ACTIVE_TEXTURE_ARB", GLint,
-         ["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", ["ARB_multitexture"] ),
+         ["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", NoState, ["ARB_multitexture"] ),
 
        # GL_ARB_texture_cube_map
        ( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean,
-         ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", ["ARB_texture_cube_map"] ),
+         ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", NoState, ["ARB_texture_cube_map"] ),
        ( "GL_TEXTURE_BINDING_CUBE_MAP_ARB", GLint,
          ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name"],
-         "", ["ARB_texture_cube_map"] ),
+         "", NoState, ["ARB_texture_cube_map"] ),
        ( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", GLint,
          ["(1 << (ctx->Const.MaxCubeTextureLevels - 1))"],
-         "", ["ARB_texture_cube_map"]),
+         "", NoState, ["ARB_texture_cube_map"]),
 
        # GL_ARB_texture_compression */
        ( "GL_TEXTURE_COMPRESSION_HINT_ARB", GLint,
-         ["ctx->Hint.TextureCompression"], "", None ),
+         ["ctx->Hint.TextureCompression"], "", NoState, NoExt ),
        ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint,
          ["_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum,
          [],
          """GLint formats[100];
@@ -565,13 +576,13 @@ StateVars = [
          ASSERT(n <= 100);
          for (i = 0; i < n; i++)
             params[i] = CONVERSION(formats[i]);""",
-         None ),
+         NoState, NoExt ),
 
        # GL_EXT_compiled_vertex_array
        ( "GL_ARRAY_ELEMENT_LOCK_FIRST_EXT", GLint, ["ctx->Array.LockFirst"],
-         "", ["EXT_compiled_vertex_array"] ),
+         "", NoState, ["EXT_compiled_vertex_array"] ),
        ( "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT", GLint, ["ctx->Array.LockCount"],
-         "", ["EXT_compiled_vertex_array"] ),
+         "", NoState, ["EXT_compiled_vertex_array"] ),
 
        # GL_ARB_transpose_matrix
        ( "GL_TRANSPOSE_COLOR_MATRIX_ARB", GLfloat,
@@ -579,25 +590,29 @@ StateVars = [
           "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
           "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
           "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
-         "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", None ),
+         "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;",
+         NoState, NoExt ),
        ( "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB", GLfloat,
          ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
           "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
           "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
           "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
-         "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ),
+         "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;",
+         NoState, NoExt ),
        ( "GL_TRANSPOSE_PROJECTION_MATRIX_ARB", GLfloat,
          ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
           "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
           "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
           "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
-         "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ),
+         "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;",
+         NoState, NoExt ),
        ( "GL_TRANSPOSE_TEXTURE_MATRIX_ARB", GLfloat,
          ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
           "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
           "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
           "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
-         "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", None ),
+         "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;",
+         NoState, NoExt ),
 
        # GL_SGI_color_matrix (also in 1.2 imaging)
        ( "GL_COLOR_MATRIX_SGI", GLfloat,
@@ -605,343 +620,373 @@ StateVars = [
           "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
           "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
           "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
-         "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", None ),
+         "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;",
+         NoState, NoExt ),
        ( "GL_COLOR_MATRIX_STACK_DEPTH_SGI", GLint,
-         ["ctx->ColorMatrixStack.Depth + 1"], "", None ),
+         ["ctx->ColorMatrixStack.Depth + 1"], "", NoState, NoExt ),
        ( "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI", GLint,
-         ["MAX_COLOR_STACK_DEPTH"], "", None ),
+         ["MAX_COLOR_STACK_DEPTH"], "", NoState, NoExt ),
        ( "GL_POST_COLOR_MATRIX_RED_SCALE_SGI", GLfloat,
-         ["ctx->Pixel.PostColorMatrixScale[0]"], "", None ),
+         ["ctx->Pixel.PostColorMatrixScale[0]"], "", NoState, NoExt ),
        ( "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI", GLfloat,
-         ["ctx->Pixel.PostColorMatrixScale[1]"], "", None ),
+         ["ctx->Pixel.PostColorMatrixScale[1]"], "", NoState, NoExt ),
        ( "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI", GLfloat,
-         ["ctx->Pixel.PostColorMatrixScale[2]"], "", None ),
+         ["ctx->Pixel.PostColorMatrixScale[2]"], "", NoState, NoExt ),
        ( "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI", GLfloat,
-         ["ctx->Pixel.PostColorMatrixScale[3]"], "", None ),
+         ["ctx->Pixel.PostColorMatrixScale[3]"], "", NoState, NoExt ),
        ( "GL_POST_COLOR_MATRIX_RED_BIAS_SGI", GLfloat,
-         ["ctx->Pixel.PostColorMatrixBias[0]"], "", None ),
+         ["ctx->Pixel.PostColorMatrixBias[0]"], "", NoState, NoExt ),
        ( "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI", GLfloat,
-         ["ctx->Pixel.PostColorMatrixBias[1]"], "", None ),
+         ["ctx->Pixel.PostColorMatrixBias[1]"], "", NoState, NoExt ),
        ( "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI", GLfloat,
-         ["ctx->Pixel.PostColorMatrixBias[2]"], "", None ),
+         ["ctx->Pixel.PostColorMatrixBias[2]"], "", NoState, NoExt ),
        ( "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI", GLfloat,
-         ["ctx->Pixel.PostColorMatrixBias[3]"], "", None ),
+         ["ctx->Pixel.PostColorMatrixBias[3]"], "", NoState, NoExt ),
 
        # GL_EXT_convolution (also in 1.2 imaging)
        ( "GL_CONVOLUTION_1D_EXT", GLboolean,
-         ["ctx->Pixel.Convolution1DEnabled"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.Convolution1DEnabled"], "", NoState, ["EXT_convolution"] ),
        ( "GL_CONVOLUTION_2D_EXT", GLboolean,
-         ["ctx->Pixel.Convolution2DEnabled"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.Convolution2DEnabled"], "", NoState, ["EXT_convolution"] ),
        ( "GL_SEPARABLE_2D_EXT", GLboolean,
-         ["ctx->Pixel.Separable2DEnabled"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.Separable2DEnabled"], "", NoState, ["EXT_convolution"] ),
        ( "GL_POST_CONVOLUTION_RED_SCALE_EXT", GLfloat,
-         ["ctx->Pixel.PostConvolutionScale[0]"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.PostConvolutionScale[0]"], "", NoState, ["EXT_convolution"] ),
        ( "GL_POST_CONVOLUTION_GREEN_SCALE_EXT", GLfloat,
-         ["ctx->Pixel.PostConvolutionScale[1]"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.PostConvolutionScale[1]"], "", NoState, ["EXT_convolution"] ),
        ( "GL_POST_CONVOLUTION_BLUE_SCALE_EXT", GLfloat,
-         ["ctx->Pixel.PostConvolutionScale[2]"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.PostConvolutionScale[2]"], "", NoState, ["EXT_convolution"] ),
        ( "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT", GLfloat,
-         ["ctx->Pixel.PostConvolutionScale[3]"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.PostConvolutionScale[3]"], "", NoState, ["EXT_convolution"] ),
        ( "GL_POST_CONVOLUTION_RED_BIAS_EXT", GLfloat,
-         ["ctx->Pixel.PostConvolutionBias[0]"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.PostConvolutionBias[0]"], "", NoState, ["EXT_convolution"] ),
        ( "GL_POST_CONVOLUTION_GREEN_BIAS_EXT", GLfloat,
-         ["ctx->Pixel.PostConvolutionBias[1]"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.PostConvolutionBias[1]"], "", NoState, ["EXT_convolution"] ),
        ( "GL_POST_CONVOLUTION_BLUE_BIAS_EXT", GLfloat,
-         ["ctx->Pixel.PostConvolutionBias[2]"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.PostConvolutionBias[2]"], "", NoState, ["EXT_convolution"] ),
        ( "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT", GLfloat,
-         ["ctx->Pixel.PostConvolutionBias[3]"], "", ["EXT_convolution"] ),
+         ["ctx->Pixel.PostConvolutionBias[3]"], "", NoState, ["EXT_convolution"] ),
 
        # GL_EXT_histogram / GL_ARB_imaging
        ( "GL_HISTOGRAM", GLboolean,
-         [ "ctx->Pixel.HistogramEnabled" ], "", ["EXT_histogram"] ),
+         [ "ctx->Pixel.HistogramEnabled" ], "", NoState, ["EXT_histogram"] ),
        ( "GL_MINMAX", GLboolean,
-         [ "ctx->Pixel.MinMaxEnabled" ], "", ["EXT_histogram"] ),
+         [ "ctx->Pixel.MinMaxEnabled" ], "", NoState, ["EXT_histogram"] ),
 
        # GL_SGI_color_table / GL_ARB_imaging
        ( "GL_COLOR_TABLE_SGI", GLboolean,
-         ["ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]"], "", ["SGI_color_table"] ),
+         ["ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]"], "",
+         NoState, ["SGI_color_table"] ),
        ( "GL_POST_CONVOLUTION_COLOR_TABLE_SGI", GLboolean,
-         ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]"], "", ["SGI_color_table"] ),
+         ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]"], "",
+         NoState, ["SGI_color_table"] ),
        ( "GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI", GLboolean,
-         ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]"], "", ["SGI_color_table"] ),
+         ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]"], "",
+         NoState, ["SGI_color_table"] ),
 
        # GL_SGI_texture_color_table
        ( "GL_TEXTURE_COLOR_TABLE_SGI", GLboolean,
          ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled"],
-         "", ["SGI_texture_color_table"] ),
+         "", NoState, ["SGI_texture_color_table"] ),
 
        # GL_EXT_secondary_color
        ( "GL_COLOR_SUM_EXT", GLboolean,
-         ["ctx->Fog.ColorSumEnabled"], "",
+         ["ctx->Fog.ColorSumEnabled"], "", NoState,
          ["EXT_secondary_color", "ARB_vertex_program"] ),
        ( "GL_CURRENT_SECONDARY_COLOR_EXT", GLfloatN,
          ["ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]",
           "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]",
           "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]",
           "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]"],
-         "FLUSH_CURRENT(ctx, 0);", ["EXT_secondary_color"] ),
+         "", FlushCurrent, ["EXT_secondary_color"] ),
        ( "GL_SECONDARY_COLOR_ARRAY_EXT", GLboolean,
-         ["ctx->Array.ArrayObj->SecondaryColor.Enabled"], "", ["EXT_secondary_color"] ),
+         ["ctx->Array.ArrayObj->SecondaryColor.Enabled"],
+         "", NoState, ["EXT_secondary_color"] ),
        ( "GL_SECONDARY_COLOR_ARRAY_TYPE_EXT", GLenum,
-         ["ctx->Array.ArrayObj->SecondaryColor.Type"], "",  ["EXT_secondary_color"] ),
+         ["ctx->Array.ArrayObj->SecondaryColor.Type"],
+         "", NoState,  ["EXT_secondary_color"] ),
        ( "GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT", GLint,
-         ["ctx->Array.ArrayObj->SecondaryColor.Stride"], "", ["EXT_secondary_color"] ),
+         ["ctx->Array.ArrayObj->SecondaryColor.Stride"],
+         "", NoState, ["EXT_secondary_color"] ),
        ( "GL_SECONDARY_COLOR_ARRAY_SIZE_EXT", GLint,
-         ["ctx->Array.ArrayObj->SecondaryColor.Size"], "", ["EXT_secondary_color"] ),
+         ["ctx->Array.ArrayObj->SecondaryColor.Size"],
+         "", NoState, ["EXT_secondary_color"] ),
 
        # GL_EXT_fog_coord
        ( "GL_CURRENT_FOG_COORDINATE_EXT", GLfloat,
          ["ctx->Current.Attrib[VERT_ATTRIB_FOG][0]"],
-         "FLUSH_CURRENT(ctx, 0);", ["EXT_fog_coord"] ),
-       ( "GL_FOG_COORDINATE_ARRAY_EXT", GLboolean, ["ctx->Array.ArrayObj->FogCoord.Enabled"],
-         "",  ["EXT_fog_coord"] ),
-       ( "GL_FOG_COORDINATE_ARRAY_TYPE_EXT", GLenum, ["ctx->Array.ArrayObj->FogCoord.Type"],
-         "", ["EXT_fog_coord"] ),
-       ( "GL_FOG_COORDINATE_ARRAY_STRIDE_EXT", GLint, ["ctx->Array.ArrayObj->FogCoord.Stride"],
-         "", ["EXT_fog_coord"] ),
-       ( "GL_FOG_COORDINATE_SOURCE_EXT", GLenum, ["ctx->Fog.FogCoordinateSource"],
-         "", ["EXT_fog_coord"] ),
+         "", FlushCurrent, ["EXT_fog_coord"] ),
+       ( "GL_FOG_COORDINATE_ARRAY_EXT", GLboolean,
+         ["ctx->Array.ArrayObj->FogCoord.Enabled"],
+         "", NoState,  ["EXT_fog_coord"] ),
+       ( "GL_FOG_COORDINATE_ARRAY_TYPE_EXT", GLenum,
+         ["ctx->Array.ArrayObj->FogCoord.Type"],
+         "", NoState, ["EXT_fog_coord"] ),
+       ( "GL_FOG_COORDINATE_ARRAY_STRIDE_EXT", GLint,
+         ["ctx->Array.ArrayObj->FogCoord.Stride"],
+         "", NoState, ["EXT_fog_coord"] ),
+       ( "GL_FOG_COORDINATE_SOURCE_EXT", GLenum,
+         ["ctx->Fog.FogCoordinateSource"],
+         "", NoState, ["EXT_fog_coord"] ),
 
        # GL_EXT_texture_lod_bias
        ( "GL_MAX_TEXTURE_LOD_BIAS_EXT", GLfloat,
-         ["ctx->Const.MaxTextureLodBias"], "", ["EXT_texture_lod_bias"]),
+         ["ctx->Const.MaxTextureLodBias"], "", NoState, ["EXT_texture_lod_bias"]),
 
        # GL_EXT_texture_filter_anisotropic
        ( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", GLfloat,
-         ["ctx->Const.MaxTextureMaxAnisotropy"], "", ["EXT_texture_filter_anisotropic"]),
+         ["ctx->Const.MaxTextureMaxAnisotropy"],
+         "", NoState, ["EXT_texture_filter_anisotropic"]),
 
        # GL_ARB_multisample
        ( "GL_MULTISAMPLE_ARB", GLboolean,
-         ["ctx->Multisample.Enabled"], "", None ),
+         ["ctx->Multisample.Enabled"], "", NoState, NoExt ),
        ( "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB", GLboolean,
-         ["ctx->Multisample.SampleAlphaToCoverage"], "", None ),
+         ["ctx->Multisample.SampleAlphaToCoverage"], "", NoState, NoExt ),
        ( "GL_SAMPLE_ALPHA_TO_ONE_ARB", GLboolean,
-         ["ctx->Multisample.SampleAlphaToOne"], "", None ),
+         ["ctx->Multisample.SampleAlphaToOne"], "", NoState, NoExt ),
        ( "GL_SAMPLE_COVERAGE_ARB", GLboolean,
-         ["ctx->Multisample.SampleCoverage"], "", None ),
+         ["ctx->Multisample.SampleCoverage"], "", NoState, NoExt ),
        ( "GL_SAMPLE_COVERAGE_VALUE_ARB", GLfloat,
-         ["ctx->Multisample.SampleCoverageValue"], "", None ),
+         ["ctx->Multisample.SampleCoverageValue"], "", NoState, NoExt ),
        ( "GL_SAMPLE_COVERAGE_INVERT_ARB", GLboolean,
-         ["ctx->Multisample.SampleCoverageInvert"], "", None ),
+         ["ctx->Multisample.SampleCoverageInvert"], "", NoState, NoExt ),
        ( "GL_SAMPLE_BUFFERS_ARB", GLint,
-         ["ctx->DrawBuffer->Visual.sampleBuffers"], "", None ),
+         ["ctx->DrawBuffer->Visual.sampleBuffers"], "", NoState, NoExt ),
        ( "GL_SAMPLES_ARB", GLint,
-         ["ctx->DrawBuffer->Visual.samples"], "", None ),
+         ["ctx->DrawBuffer->Visual.samples"], "", NoState, NoExt ),
 
        # GL_IBM_rasterpos_clip
        ( "GL_RASTER_POSITION_UNCLIPPED_IBM", GLboolean,
-         ["ctx->Transform.RasterPositionUnclipped"], "", ["IBM_rasterpos_clip"] ),
+         ["ctx->Transform.RasterPositionUnclipped"],
+         "", NoState, ["IBM_rasterpos_clip"] ),
 
        # GL_NV_point_sprite
        ( "GL_POINT_SPRITE_NV", GLboolean, ["ctx->Point.PointSprite"], # == GL_POINT_SPRITE_ARB
-         "", ["NV_point_sprite", "ARB_point_sprite"] ),
+         "", NoState, ["NV_point_sprite", "ARB_point_sprite"] ),
        ( "GL_POINT_SPRITE_R_MODE_NV", GLenum, ["ctx->Point.SpriteRMode"],
-         "", ["NV_point_sprite"] ),
+         "", NoState, ["NV_point_sprite"] ),
        ( "GL_POINT_SPRITE_COORD_ORIGIN", GLenum, ["ctx->Point.SpriteOrigin"],
-         "", ["NV_point_sprite", "ARB_point_sprite"] ),
+         "", NoState, ["NV_point_sprite", "ARB_point_sprite"] ),
 
        # GL_SGIS_generate_mipmap
        ( "GL_GENERATE_MIPMAP_HINT_SGIS", GLenum, ["ctx->Hint.GenerateMipmap"],
-         "", ["SGIS_generate_mipmap"] ),
+         "", NoState, ["SGIS_generate_mipmap"] ),
 
        # GL_NV_vertex_program
        ( "GL_VERTEX_PROGRAM_BINDING_NV", GLint,
          ["(ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0)"],
-         "", ["NV_vertex_program"] ),
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY0_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[0].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[0].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY1_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[1].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[1].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY2_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[2].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[2].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY3_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[3].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[3].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY4_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[4].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[4].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY5_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[5].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[5].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY6_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[6].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[6].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY7_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[7].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[7].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY8_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[8].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[8].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY9_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[9].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[9].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY10_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[10].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[10].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY11_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[11].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[11].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY12_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[12].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[12].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY13_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[13].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[13].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY14_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[14].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[14].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_VERTEX_ATTRIB_ARRAY15_NV", GLboolean,
-         ["ctx->Array.ArrayObj->VertexAttrib[15].Enabled"], "", ["NV_vertex_program"] ),
+         ["ctx->Array.ArrayObj->VertexAttrib[15].Enabled"],
+         "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB0_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[0]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[0]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB1_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[1]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[1]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB2_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[2]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[2]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB3_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[3]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[3]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB4_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[4]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[4]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB5_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[5]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[5]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB6_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[6]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[6]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB7_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[7]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[7]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB8_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[8]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[8]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB9_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[9]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[9]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB10_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[10]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[10]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB11_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[11]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[11]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB12_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[12]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[12]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB13_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[13]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[13]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB14_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[14]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[14]"], "", NoState, ["NV_vertex_program"] ),
        ( "GL_MAP1_VERTEX_ATTRIB15_4_NV", GLboolean,
-         ["ctx->Eval.Map1Attrib[15]"], "", ["NV_vertex_program"] ),
+         ["ctx->Eval.Map1Attrib[15]"], "", NoState, ["NV_vertex_program"] ),
 
        # GL_NV_fragment_program
        ( "GL_FRAGMENT_PROGRAM_NV", GLboolean,
-         ["ctx->FragmentProgram.Enabled"], "", ["NV_fragment_program"] ),
+         ["ctx->FragmentProgram.Enabled"], "", NoState, ["NV_fragment_program"] ),
        ( "GL_FRAGMENT_PROGRAM_BINDING_NV", GLint,
          ["ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0"],
-         "", ["NV_fragment_program"] ),
+         "", NoState, ["NV_fragment_program"] ),
        ( "GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV", GLint,
-         ["MAX_NV_FRAGMENT_PROGRAM_PARAMS"], "", ["NV_fragment_program"] ),
+         ["MAX_NV_FRAGMENT_PROGRAM_PARAMS"], "", NoState, ["NV_fragment_program"] ),
 
        # GL_NV_texture_rectangle
        ( "GL_TEXTURE_RECTANGLE_NV", GLboolean,
-         ["_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)"], "", ["NV_texture_rectangle"] ),
+         ["_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)"], "", NoState, ["NV_texture_rectangle"] ),
        ( "GL_TEXTURE_BINDING_RECTANGLE_NV", GLint,
          ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name"],
-         "", ["NV_texture_rectangle"] ),
+         "", NoState, ["NV_texture_rectangle"] ),
        ( "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV", GLint,
-         ["ctx->Const.MaxTextureRectSize"], "", ["NV_texture_rectangle"] ),
+         ["ctx->Const.MaxTextureRectSize"], "", NoState, ["NV_texture_rectangle"] ),
 
        # GL_EXT_stencil_two_side
        ( "GL_STENCIL_TEST_TWO_SIDE_EXT", GLboolean,
-         ["ctx->Stencil.TestTwoSide"], "", ["EXT_stencil_two_side"] ),
+         ["ctx->Stencil.TestTwoSide"], "", NoState, ["EXT_stencil_two_side"] ),
        ( "GL_ACTIVE_STENCIL_FACE_EXT", GLenum,
          ["ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT"],
-         "", ["EXT_stencil_two_side"] ),
+         "", NoState, ["EXT_stencil_two_side"] ),
 
        # GL_NV_light_max_exponent
        ( "GL_MAX_SHININESS_NV", GLfloat,
-         ["ctx->Const.MaxShininess"], "", ["NV_light_max_exponent"] ),
+         ["ctx->Const.MaxShininess"], "", NoState, ["NV_light_max_exponent"] ),
        ( "GL_MAX_SPOT_EXPONENT_NV", GLfloat,
-         ["ctx->Const.MaxSpotExponent"], "", ["NV_light_max_exponent"] ),
+         ["ctx->Const.MaxSpotExponent"], "", NoState, ["NV_light_max_exponent"] ),
 
        # GL_ARB_vertex_buffer_object
        ( "GL_ARRAY_BUFFER_BINDING_ARB", GLint,
-         ["ctx->Array.ArrayBufferObj->Name"], "", None ),
+         ["ctx->Array.ArrayBufferObj->Name"], "", NoState, NoExt ),
        ( "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB", GLint,
-         ["ctx->Array.ArrayObj->Vertex.BufferObj->Name"], "", None ),
+         ["ctx->Array.ArrayObj->Vertex.BufferObj->Name"], "", NoState, NoExt ),
        ( "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB", GLint,
-         ["ctx->Array.ArrayObj->Normal.BufferObj->Name"], "", None ),
+         ["ctx->Array.ArrayObj->Normal.BufferObj->Name"], "", NoState, NoExt ),
        ( "GL_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint,
-         ["ctx->Array.ArrayObj->Color.BufferObj->Name"], "", None ),
+         ["ctx->Array.ArrayObj->Color.BufferObj->Name"], "", NoState, NoExt ),
        ( "GL_INDEX_ARRAY_BUFFER_BINDING_ARB", GLint,
-         ["ctx->Array.ArrayObj->Index.BufferObj->Name"], "", None ),
+         ["ctx->Array.ArrayObj->Index.BufferObj->Name"], "", NoState, NoExt ),
        ( "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB", GLint,
          ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB", GLint,
-         ["ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name"], "", None ),
+         ["ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name"], "", NoState, NoExt ),
        ( "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint,
          ["ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name"],
-         "", None ),
+         "", NoState, NoExt ),
        ( "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB", GLint,
          ["ctx->Array.ArrayObj->FogCoord.BufferObj->Name"],
-         "", None ),
+         "", NoState, NoExt ),
        # GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported
        ( "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB", GLint,
          ["ctx->Array.ElementArrayBufferObj->Name"],
-         "", None ),
+         "", NoState, NoExt ),
 
        # GL_EXT_pixel_buffer_object
        ( "GL_PIXEL_PACK_BUFFER_BINDING_EXT", GLint,
-         ["ctx->Pack.BufferObj->Name"], "", ["EXT_pixel_buffer_object"] ),
+         ["ctx->Pack.BufferObj->Name"], "", NoState, ["EXT_pixel_buffer_object"] ),
        ( "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT", GLint,
-         ["ctx->Unpack.BufferObj->Name"], "", ["EXT_pixel_buffer_object"] ),
+         ["ctx->Unpack.BufferObj->Name"], "", NoState, ["EXT_pixel_buffer_object"] ),
 
        # GL_ARB_vertex_program
        ( "GL_VERTEX_PROGRAM_ARB", GLboolean, # == GL_VERTEX_PROGRAM_NV
-         ["ctx->VertexProgram.Enabled"], "",
+         ["ctx->VertexProgram.Enabled"], "", NoState,
          ["ARB_vertex_program", "NV_vertex_program"] ),
        ( "GL_VERTEX_PROGRAM_POINT_SIZE_ARB", GLboolean, # == GL_VERTEX_PROGRAM_POINT_SIZE_NV
-         ["ctx->VertexProgram.PointSizeEnabled"], "",
+         ["ctx->VertexProgram.PointSizeEnabled"], "", NoState,
          ["ARB_vertex_program", "NV_vertex_program"] ),
        ( "GL_VERTEX_PROGRAM_TWO_SIDE_ARB", GLboolean, # == GL_VERTEX_PROGRAM_TWO_SIDE_NV
-         ["ctx->VertexProgram.TwoSideEnabled"], "",
+         ["ctx->VertexProgram.TwoSideEnabled"], "", NoState,
          ["ARB_vertex_program", "NV_vertex_program"] ),
        ( "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB", GLint, # == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV
-         ["ctx->Const.MaxProgramMatrixStackDepth"], "",
+         ["ctx->Const.MaxProgramMatrixStackDepth"], "", NoState,
          ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ),
        ( "GL_MAX_PROGRAM_MATRICES_ARB", GLint, # == GL_MAX_TRACK_MATRICES_NV
-         ["ctx->Const.MaxProgramMatrices"], "",
+         ["ctx->Const.MaxProgramMatrices"], "", NoState,
          ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ),
        ( "GL_CURRENT_MATRIX_STACK_DEPTH_ARB", GLboolean, # == GL_CURRENT_MATRIX_STACK_DEPTH_NV
-         ["ctx->CurrentStack->Depth + 1"], "",
+         ["ctx->CurrentStack->Depth + 1"], "", NoState,
          ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ),
        ( "GL_CURRENT_MATRIX_ARB", GLfloat, # == GL_CURRENT_MATRIX_NV
          ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
           "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
           "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
           "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
-         "const GLfloat *matrix = ctx->CurrentStack->Top->m;",
+         "const GLfloat *matrix = ctx->CurrentStack->Top->m;", NoState,
          ["ARB_vertex_program", "ARB_fragment_program", "NV_fragment_program"] ),
        ( "GL_TRANSPOSE_CURRENT_MATRIX_ARB", GLfloat,
          ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
           "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
           "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
           "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
-         "const GLfloat *matrix = ctx->CurrentStack->Top->m;",
+         "const GLfloat *matrix = ctx->CurrentStack->Top->m;", NoState,
          ["ARB_vertex_program", "ARB_fragment_program"] ),
        ( "GL_MAX_VERTEX_ATTRIBS_ARB", GLint,
-         ["ctx->Const.VertexProgram.MaxAttribs"], "", ["ARB_vertex_program"] ),
+         ["ctx->Const.VertexProgram.MaxAttribs"], "", NoState, ["ARB_vertex_program"] ),
        ( "GL_PROGRAM_ERROR_POSITION_ARB", GLint, # == GL_PROGRAM_ERROR_POSITION_NV
-         ["ctx->Program.ErrorPos"], "", ["NV_vertex_program",
+         ["ctx->Program.ErrorPos"], "", NoState, ["NV_vertex_program",
           "ARB_vertex_program", "NV_fragment_program", "ARB_fragment_program"] ),
 
        # GL_ARB_fragment_program
        ( "GL_FRAGMENT_PROGRAM_ARB", GLboolean,
-         ["ctx->FragmentProgram.Enabled"], "", ["ARB_fragment_program"] ),
+         ["ctx->FragmentProgram.Enabled"], "", NoState, ["ARB_fragment_program"] ),
        ( "GL_MAX_TEXTURE_COORDS_ARB", GLint, # == GL_MAX_TEXTURE_COORDS_NV
-         ["ctx->Const.MaxTextureCoordUnits"], "",
+         ["ctx->Const.MaxTextureCoordUnits"], "", NoState,
          ["ARB_fragment_program", "NV_fragment_program"] ),
        ( "GL_MAX_TEXTURE_IMAGE_UNITS_ARB", GLint, # == GL_MAX_TEXTURE_IMAGE_UNITS_NV
-         ["ctx->Const.MaxTextureImageUnits"], "",
+         ["ctx->Const.MaxTextureImageUnits"], "", NoState,
          ["ARB_fragment_program", "NV_fragment_program"] ),
 
        # GL_EXT_depth_bounds_test
        ( "GL_DEPTH_BOUNDS_TEST_EXT", GLboolean,
-         ["ctx->Depth.BoundsTest"], "", ["EXT_depth_bounds_test"] ),
+         ["ctx->Depth.BoundsTest"], "", NoState, ["EXT_depth_bounds_test"] ),
        ( "GL_DEPTH_BOUNDS_EXT", GLfloat,
          ["ctx->Depth.BoundsMin", "ctx->Depth.BoundsMax"],
-         "", ["EXT_depth_bounds_test"] ),
+         "", NoState, ["EXT_depth_bounds_test"] ),
 
        # GL_ARB_depth_clamp
        ( "GL_DEPTH_CLAMP", GLboolean, ["ctx->Transform.DepthClamp"], "",
-         ["ARB_depth_clamp"] ),
+         NoState, ["ARB_depth_clamp"] ),
 
        # GL_ARB_draw_buffers
        ( "GL_MAX_DRAW_BUFFERS_ARB", GLint,
-         ["ctx->Const.MaxDrawBuffers"], "", None ),
+         ["ctx->Const.MaxDrawBuffers"], "", NoState, NoExt ),
        ( "GL_DRAW_BUFFER0_ARB", GLenum,
-         ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", None ),
+         ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", NoState, NoExt ),
        ( "GL_DRAW_BUFFER1_ARB", GLenum,
          ["buffer"],
          """GLenum buffer;
@@ -949,7 +994,7 @@ StateVars = [
             _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
             return;
          }
-         buffer = ctx->DrawBuffer->ColorDrawBuffer[1];""", None ),
+         buffer = ctx->DrawBuffer->ColorDrawBuffer[1];""", NoState, NoExt ),
        ( "GL_DRAW_BUFFER2_ARB", GLenum,
          ["buffer"],
          """GLenum buffer;
@@ -957,7 +1002,7 @@ StateVars = [
             _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
             return;
          }
-         buffer = ctx->DrawBuffer->ColorDrawBuffer[2];""", None ),
+         buffer = ctx->DrawBuffer->ColorDrawBuffer[2];""", NoState, NoExt ),
        ( "GL_DRAW_BUFFER3_ARB", GLenum,
          ["buffer"],
          """GLenum buffer;
@@ -965,117 +1010,138 @@ StateVars = [
             _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
             return;
          }
-         buffer = ctx->DrawBuffer->ColorDrawBuffer[3];""", None ),
+         buffer = ctx->DrawBuffer->ColorDrawBuffer[3];""", NoState, NoExt ),
        # XXX Add more GL_DRAW_BUFFERn_ARB entries as needed in the future
 
        # GL_OES_read_format
        ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint,
-         ["_mesa_get_color_read_type(ctx)"], "", ["OES_read_format"] ),
+         ["_mesa_get_color_read_type(ctx)"], "", NoState, ["OES_read_format"] ),
        ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint,
-         ["_mesa_get_color_read_format(ctx)"], "", ["OES_read_format"] ),
+         ["_mesa_get_color_read_format(ctx)"], "", NoState, ["OES_read_format"] ),
 
        # GL_ATI_fragment_shader
-       ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"], "", ["ATI_fragment_shader"] ),
-       ( "GL_NUM_FRAGMENT_CONSTANTS_ATI", GLint, ["8"], "", ["ATI_fragment_shader"] ),
-       ( "GL_NUM_PASSES_ATI", GLint, ["2"], "", ["ATI_fragment_shader"] ),
-       ( "GL_NUM_INSTRUCTIONS_PER_PASS_ATI", GLint, ["8"], "", ["ATI_fragment_shader"] ),
-       ( "GL_NUM_INSTRUCTIONS_TOTAL_ATI", GLint, ["16"], "", ["ATI_fragment_shader"] ),
-       ( "GL_COLOR_ALPHA_PAIRING_ATI", GLboolean, ["GL_TRUE"], "", ["ATI_fragment_shader"] ),
-       ( "GL_NUM_LOOPBACK_COMPONENTS_ATI", GLint, ["3"], "", ["ATI_fragment_shader"] ),
-       ( "GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI", GLint, ["3"], "", ["ATI_fragment_shader"] ),
+       ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"],
+         "", NoState, ["ATI_fragment_shader"] ),
+       ( "GL_NUM_FRAGMENT_CONSTANTS_ATI", GLint, ["8"],
+         "", NoState, ["ATI_fragment_shader"] ),
+       ( "GL_NUM_PASSES_ATI", GLint, ["2"],
+         "", NoState, ["ATI_fragment_shader"] ),
+       ( "GL_NUM_INSTRUCTIONS_PER_PASS_ATI", GLint, ["8"],
+         "", NoState, ["ATI_fragment_shader"] ),
+       ( "GL_NUM_INSTRUCTIONS_TOTAL_ATI", GLint, ["16"],
+         "", NoState, ["ATI_fragment_shader"] ),
+       ( "GL_COLOR_ALPHA_PAIRING_ATI", GLboolean, ["GL_TRUE"],
+         "", NoState, ["ATI_fragment_shader"] ),
+       ( "GL_NUM_LOOPBACK_COMPONENTS_ATI", GLint, ["3"],
+         "", NoState, ["ATI_fragment_shader"] ),
+       ( "GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI", GLint, ["3"],
+         "", NoState, ["ATI_fragment_shader"] ),
 
        # OpenGL 2.0
-       ( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"], "", None ),
-       ( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"], "", None ),
-       ( "GL_STENCIL_BACK_WRITEMASK", GLint, ["ctx->Stencil.WriteMask[1]"], "", None ),
-       ( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"], "", None ),
-       ( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"], "", None ),
-       ( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"], "", None ),
-       ( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], "", None ),
+       ( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"],
+         "", NoState, NoExt ),
+       ( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"],
+         "", NoState, NoExt ),
+       ( "GL_STENCIL_BACK_WRITEMASK", GLint, ["ctx->Stencil.WriteMask[1]"],
+         "", NoState, NoExt ),
+       ( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"],
+         "", NoState, NoExt ),
+       ( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"],
+         "", NoState, NoExt ),
+       ( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"],
+         "", NoState, NoExt ),
+       ( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"],
+         "", NoState, NoExt ),
 
        # GL_EXT_framebuffer_object
        ( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "",
-         ["EXT_framebuffer_object"] ),
+         NoState, ["EXT_framebuffer_object"] ),
        ( "GL_RENDERBUFFER_BINDING_EXT", GLint,
          ["ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0"], "",
-         ["EXT_framebuffer_object"] ),
+         NoState, ["EXT_framebuffer_object"] ),
        ( "GL_MAX_COLOR_ATTACHMENTS_EXT", GLint,
          ["ctx->Const.MaxColorAttachments"], "",
-         ["EXT_framebuffer_object"] ),
+         NoState, ["EXT_framebuffer_object"] ),
        ( "GL_MAX_RENDERBUFFER_SIZE_EXT", GLint,
          ["ctx->Const.MaxRenderbufferSize"], "",
-         ["EXT_framebuffer_object"] ),
+         NoState, ["EXT_framebuffer_object"] ),
 
        # GL_EXT_framebuffer_blit
        # NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT
        ( "GL_READ_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->ReadBuffer->Name"], "",
-         ["EXT_framebuffer_blit"] ),
+         NoState, ["EXT_framebuffer_blit"] ),
 
        # GL_EXT_provoking_vertex
        ( "GL_PROVOKING_VERTEX_EXT", GLboolean,
-         ["ctx->Light.ProvokingVertex"], "", ["EXT_provoking_vertex"] ),
+         ["ctx->Light.ProvokingVertex"], "", NoState, ["EXT_provoking_vertex"] ),
        ( "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT", GLboolean,
          ["ctx->Const.QuadsFollowProvokingVertexConvention"], "",
-         ["EXT_provoking_vertex"] ),
+         NoState, ["EXT_provoking_vertex"] ),
 
        # GL_ARB_fragment_shader
        ( "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", GLint,
          ["ctx->Const.FragmentProgram.MaxUniformComponents"], "",
-         ["ARB_fragment_shader"] ),
+         NoState, ["ARB_fragment_shader"] ),
        ( "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB", GLenum,
-         ["ctx->Hint.FragmentShaderDerivative"], "", ["ARB_fragment_shader"] ),
+         ["ctx->Hint.FragmentShaderDerivative"],
+         "", NoState, ["ARB_fragment_shader"] ),
 
        # GL_ARB_vertex_shader
        ( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB", GLint,
          ["ctx->Const.VertexProgram.MaxUniformComponents"], "",
-         ["ARB_vertex_shader"] ),
+         NoState, ["ARB_vertex_shader"] ),
        ( "GL_MAX_VARYING_FLOATS_ARB", GLint,
-         ["ctx->Const.MaxVarying * 4"], "", ["ARB_vertex_shader"] ),
+         ["ctx->Const.MaxVarying * 4"], "", NoState, ["ARB_vertex_shader"] ),
        ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint,
-         ["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ),
+         ["ctx->Const.MaxVertexTextureImageUnits"],
+         "", NoState, ["ARB_vertex_shader"] ),
        ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint,
-         ["ctx->Const.MaxCombinedTextureImageUnits"], "", ["ARB_vertex_shader"] ),
+         ["ctx->Const.MaxCombinedTextureImageUnits"],
+         "", NoState, ["ARB_vertex_shader"] ),
 
        # GL_ARB_shader_objects
        # Actually, this token isn't part of GL_ARB_shader_objects, but is
        # close enough for now.
        ( "GL_CURRENT_PROGRAM", GLint,
          ["ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0"],
-         "", ["ARB_shader_objects"] ),
+         "", NoState, ["ARB_shader_objects"] ),
 
        # GL_ARB_framebuffer_object
        ( "GL_MAX_SAMPLES", GLint, ["ctx->Const.MaxSamples"], "",
-         ["ARB_framebuffer_object"] ),
+         NoState, ["ARB_framebuffer_object"] ),
 
        # GL_APPLE_vertex_array_object
        ( "GL_VERTEX_ARRAY_BINDING_APPLE", GLint, ["ctx->Array.ArrayObj->Name"], "",
-         ["APPLE_vertex_array_object"] ),
+         NoState, ["APPLE_vertex_array_object"] ),
 
        # GL_ARB_seamless_cube_map
        ( "GL_TEXTURE_CUBE_MAP_SEAMLESS", GLboolean, ["ctx->Texture.CubeMapSeamless"], "",
-         ["ARB_seamless_cube_map"] ),
+         NoState, ["ARB_seamless_cube_map"] ),
 
        # GL_ARB_sync
        ( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "",
-         ["ARB_sync"] ),
+         NoState, ["ARB_sync"] ),
 
        # GL3
-       ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", None ),
-       ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", None ),
-       ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", None )
+       ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", NoState, NoExt ),
+       ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", NoState, NoExt ),
+       ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", NoState, NoExt ),
+       ( "GL_CONTEXT_FLAGS", GLint, ["ctx->Const.ContextFlags"], "", NoState, NoExt )
 ]
 
 
 # These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v()
+# The tuples are the same as above, with one exception: the "optional"
+# code field is instead the max legal index value.
 IndexedStateVars = [
        ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"],
-         "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ),
+         "ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ),
        ( "GL_COLOR_WRITEMASK", GLint,
          [ "ctx->Color.ColorMask[index][RCOMP] ? 1 : 0",
                "ctx->Color.ColorMask[index][GCOMP] ? 1 : 0",
                "ctx->Color.ColorMask[index][BCOMP] ? 1 : 0",
                "ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ],
-         "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ),
+         "ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ),
        # XXX more to come...
 ]
 
@@ -1152,9 +1218,6 @@ def EmitGetFunction(stateVars, returnType, indexed):
        print "   if (!params)"
        print "      return;"
        print ""
-       print "   if (ctx->NewState)"
-       print "      _mesa_update_state(ctx);"
-       print ""
        if indexed == 0:
                print "   if (ctx->Driver.%s &&" % function
                print "       ctx->Driver.%s(ctx, pname, params))" % function
@@ -1164,12 +1227,14 @@ def EmitGetFunction(stateVars, returnType, indexed):
 
        for state in stateVars:
                if indexed:
-                       (name, varType, state, indexMax, extensions) = state
+                       (name, varType, state, indexMax, dirtyFlags, extensions) = state
                        optionalCode = 0
                else:
-                       (name, varType, state, optionalCode, extensions) = state
+                       (name, varType, state, optionalCode, dirtyFlags, extensions) = state
                        indexMax = 0
                print "      case " + name + ":"
+
+               # Do extension check
                if extensions:
                        if len(extensions) == 1:
                                print ('         CHECK_EXT1(%s, "%s");' %
@@ -1184,9 +1249,20 @@ def EmitGetFunction(stateVars, returnType, indexed):
                                assert len(extensions) == 4
                                print ('         CHECK_EXT4(%s, %s, %s, %s, "%s");' %
                                           (extensions[0], extensions[1], extensions[2], extensions[3], function))
+
+               # Do dirty state check
+               if dirtyFlags:
+                       if dirtyFlags == FlushCurrent:
+                               print ('         FLUSH_CURRENT(ctx, 0);')
+                       else:
+                               print ('         if (ctx->NewState & %s)' % dirtyFlags)
+                               print ('            _mesa_update_state(ctx);')
+
+               # Do index validation for glGet*Indexed() calls
                if indexMax:
                        print ('         if (index >= %s) {' % indexMax)
                        print ('            _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function)
+                       print ('            return;')
                        print ('         }')
 
                conversion = ConversionFunc(varType, returnType)
index 975775469d94e5f0e74afd790c08d3ab037fde50..b624e6ecac1537ed8851d83b8081eeab04f5bf2d 100644 (file)
@@ -120,15 +120,11 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table)
 
 
 /**
- * Lookup an entry in the hash table.
- * 
- * \param table the hash table.
- * \param key the key.
- * 
- * \return pointer to user's data or NULL if key not in table
+ * Lookup an entry in the hash table, without locking.
+ * \sa _mesa_HashLookup
  */
-void *
-_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key)
+static INLINE void *
+_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key)
 {
    GLuint pos;
    const struct HashEntry *entry;
@@ -137,20 +133,36 @@ _mesa_HashLookup(struct _mesa_HashTable *table, GLuint key)
    assert(key);
 
    pos = HASH_FUNC(key);
-   _glthread_LOCK_MUTEX(table->Mutex);
    entry = table->Table[pos];
    while (entry) {
       if (entry->Key == key) {
-         _glthread_UNLOCK_MUTEX(table->Mutex);
          return entry->Data;
       }
       entry = entry->Next;
    }
-   _glthread_UNLOCK_MUTEX(table->Mutex);
    return NULL;
 }
 
 
+/**
+ * Lookup an entry in the hash table.
+ * 
+ * \param table the hash table.
+ * \param key the key.
+ * 
+ * \return pointer to user's data or NULL if key not in table
+ */
+void *
+_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key)
+{
+   void *res;
+   assert(table);
+   _glthread_LOCK_MUTEX(table->Mutex);
+   res = _mesa_HashLookup_unlocked(table, key);
+   _glthread_UNLOCK_MUTEX(table->Mutex);
+   return res;
+}
+
 
 /**
  * Insert a key/pointer pair into the hash table.  
@@ -447,7 +459,7 @@ _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys)
       GLuint freeStart = 1;
       GLuint key;
       for (key = 1; key != maxKey; key++) {
-        if (_mesa_HashLookup(table, key)) {
+        if (_mesa_HashLookup_unlocked(table, key)) {
            /* darn, this key is already in use */
            freeCount = 0;
            freeStart = key+1;
index 72717d67873af490f8392d64672fc04aacde0e12..9b34be0dfaa529be7d6eed80b16f58a1df701ddb 100644 (file)
@@ -303,7 +303,7 @@ _mesa_clip_drawpixels(const GLcontext *ctx,
 
 extern GLboolean
 _mesa_clip_readpixels(const GLcontext *ctx,
-                      GLint *destX, GLint *destY,
+                      GLint *srcX, GLint *srcY,
                       GLsizei *width, GLsizei *height,
                       struct gl_pixelstore_attrib *pack);
 
index 56e8195810ea4f79ac4b5f27b0fc3dbd4a2008d7..1ae085336480246b7b298e44fbbd94cfd72e29b2 100644 (file)
@@ -795,18 +795,20 @@ _mesa_strdup( const char *s )
    }
 }
 
-/** Wrapper around strtod() */
-double
-_mesa_strtod( const char *s, char **end )
+/** Wrapper around strtof() */
+float
+_mesa_strtof( const char *s, char **end )
 {
 #ifdef _GNU_SOURCE
    static locale_t loc = NULL;
    if (!loc) {
       loc = newlocale(LC_CTYPE_MASK, "C", NULL);
    }
-   return strtod_l(s, end, loc);
+   return strtof_l(s, end, loc);
+#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
+   return strtof(s, end);
 #else
-   return strtod(s, end);
+   return (float)strtod(s, end);
 #endif
 }
 
index fb4a00eca7b5aa608349a82290b43010449ed33b..d28f4ad125d27f4588e4f02407b9b7a3f9f91deb 100644 (file)
@@ -575,8 +575,8 @@ _mesa_getenv( const char *var );
 extern char *
 _mesa_strdup( const char *s );
 
-extern double
-_mesa_strtod( const char *s, char **end );
+extern float
+_mesa_strtof( const char *s, char **end );
 
 extern unsigned int
 _mesa_str_checksum(const char *str);
index 5c863f6f32ae445430b2c8315a038ae5f26e7630..4b8c00b5b63795ad13fb039a442388ff3843d401 100644 (file)
@@ -322,7 +322,7 @@ _mesa_LoadIdentity( void )
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API)
-      _mesa_debug(ctx, "glLoadIdentity()");
+      _mesa_debug(ctx, "glLoadIdentity()\n");
 
    _math_matrix_set_identity( ctx->CurrentStack->Top );
    ctx->NewState |= ctx->CurrentStack->DirtyFlag;
index cb96c4d1d05e444bc135de94ec37094398a93654..54edf9e7f01df2c3dc542bf82c1899612c7a1cc0 100644 (file)
  * enabled or not.
  */
 
+#ifndef FEATURE_ES1
+#define FEATURE_ES1 0
+#endif
+#ifndef FEATURE_ES2
+#define FEATURE_ES2 0
+#endif
+
+#define FEATURE_ES (FEATURE_ES1 || FEATURE_ES2)
+
+#ifndef FEATURE_GL
+#define FEATURE_GL !FEATURE_ES
+#endif
+
 #ifdef IN_DRI_DRIVER
-#define FEATURE_remap_table 1
+#define FEATURE_remap_table               1
 #else
-#define FEATURE_remap_table 0
+#define FEATURE_remap_table               0
 #endif
 
-#define FEATURE_accum  _HAVE_FULL_GL
-#define FEATURE_arrayelt  _HAVE_FULL_GL
-#define FEATURE_attrib_stack  _HAVE_FULL_GL
+#define FEATURE_dispatch                  1
+#define FEATURE_texgen                    1
+#define FEATURE_userclip                  1
+
+#define FEATURE_accum                     FEATURE_GL
+#define FEATURE_arrayelt                  FEATURE_GL
+#define FEATURE_attrib_stack              FEATURE_GL
 /* this disables vtxfmt, api_loopback, and api_noop completely */
-#define FEATURE_beginend  _HAVE_FULL_GL
-#define FEATURE_colortable  _HAVE_FULL_GL
-#define FEATURE_convolve  _HAVE_FULL_GL
-#define FEATURE_dispatch  _HAVE_FULL_GL
-#define FEATURE_dlist  (_HAVE_FULL_GL && FEATURE_arrayelt && FEATURE_beginend)
-#define FEATURE_draw_read_buffer  _HAVE_FULL_GL
-#define FEATURE_drawpix  _HAVE_FULL_GL
-#define FEATURE_evaluators  _HAVE_FULL_GL
-#define FEATURE_feedback  _HAVE_FULL_GL
-#define FEATURE_fixedpt 0
-#define FEATURE_histogram  _HAVE_FULL_GL
-#define FEATURE_pixel_transfer  _HAVE_FULL_GL
-#define FEATURE_point_size_array 0
-#define FEATURE_queryobj  _HAVE_FULL_GL
-#define FEATURE_rastpos  _HAVE_FULL_GL
-#define FEATURE_texgen  _HAVE_FULL_GL
-#define FEATURE_texture_fxt1  _HAVE_FULL_GL
-#define FEATURE_texture_s3tc  _HAVE_FULL_GL
-#define FEATURE_userclip  _HAVE_FULL_GL
-#define FEATURE_vertex_array_byte 0
-#define FEATURE_es2_glsl 0
-
-#define FEATURE_ARB_fragment_program  _HAVE_FULL_GL
-#define FEATURE_ARB_framebuffer_object  _HAVE_FULL_GL
-#define FEATURE_ARB_map_buffer_range  _HAVE_FULL_GL
-#define FEATURE_ARB_pixel_buffer_object  _HAVE_FULL_GL
-#define FEATURE_ARB_vertex_buffer_object  _HAVE_FULL_GL
-#define FEATURE_ARB_vertex_program  _HAVE_FULL_GL
-#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL
-#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL
-#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader)
-#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects
-#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects
-#define FEATURE_ARB_sync _HAVE_FULL_GL
-
-#define FEATURE_EXT_framebuffer_blit _HAVE_FULL_GL
-#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL
-#define FEATURE_EXT_pixel_buffer_object  _HAVE_FULL_GL
-#define FEATURE_APPLE_object_purgeable _HAVE_FULL_GL
-#define FEATURE_EXT_texture_sRGB _HAVE_FULL_GL
-#define FEATURE_ATI_fragment_shader _HAVE_FULL_GL
-#define FEATURE_NV_fence  _HAVE_FULL_GL
-#define FEATURE_NV_fragment_program  _HAVE_FULL_GL
-#define FEATURE_NV_vertex_program  _HAVE_FULL_GL
-
-#define FEATURE_OES_EGL_image _HAVE_FULL_GL
+#define FEATURE_beginend                  FEATURE_GL
+#define FEATURE_colortable                FEATURE_GL
+#define FEATURE_convolve                  FEATURE_GL
+#define FEATURE_dlist                     (FEATURE_GL && FEATURE_arrayelt && FEATURE_beginend)
+#define FEATURE_draw_read_buffer          FEATURE_GL
+#define FEATURE_drawpix                   FEATURE_GL
+#define FEATURE_evaluators                FEATURE_GL
+#define FEATURE_feedback                  FEATURE_GL
+#define FEATURE_histogram                 FEATURE_GL
+#define FEATURE_pixel_transfer            FEATURE_GL
+#define FEATURE_queryobj                  FEATURE_GL
+#define FEATURE_rastpos                   FEATURE_GL
+#define FEATURE_texture_fxt1              FEATURE_GL
+#define FEATURE_texture_s3tc              FEATURE_GL
+
+#define FEATURE_extra_context_init        FEATURE_ES
+#define FEATURE_fixedpt                   FEATURE_ES
+#define FEATURE_point_size_array          FEATURE_ES
+#define FEATURE_vertex_array_byte         FEATURE_ES
+
+#define FEATURE_es2_glsl                  FEATURE_ES2
+
+#define FEATURE_ARB_fragment_program      1
+#define FEATURE_ARB_vertex_program        1
+#define FEATURE_ARB_vertex_shader         1
+#define FEATURE_ARB_fragment_shader       1
+#define FEATURE_ARB_shader_objects        (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader)
+#define FEATURE_ARB_shading_language_100  FEATURE_ARB_shader_objects
+#define FEATURE_ARB_shading_language_120  FEATURE_ARB_shader_objects
+
+#define FEATURE_ARB_framebuffer_object    (FEATURE_GL && FEATURE_EXT_framebuffer_object)
+#define FEATURE_ARB_map_buffer_range      FEATURE_GL
+#define FEATURE_ARB_pixel_buffer_object   (FEATURE_GL && FEATURE_EXT_pixel_buffer_object)
+#define FEATURE_ARB_sync                  FEATURE_GL
+#define FEATURE_ARB_vertex_buffer_object  1
+
+#define FEATURE_EXT_framebuffer_blit      FEATURE_GL
+#define FEATURE_EXT_framebuffer_object    1
+#define FEATURE_EXT_pixel_buffer_object   1
+#define FEATURE_EXT_texture_sRGB          FEATURE_GL
+
+#define FEATURE_APPLE_object_purgeable    FEATURE_GL
+#define FEATURE_ATI_fragment_shader       FEATURE_GL
+#define FEATURE_NV_fence                  FEATURE_GL
+#define FEATURE_NV_fragment_program       FEATURE_GL
+#define FEATURE_NV_vertex_program         FEATURE_GL
 
+#define FEATURE_OES_EGL_image             1
+#define FEATURE_OES_draw_texture          FEATURE_ES1
+#define FEATURE_OES_framebuffer_object    FEATURE_ES
+#define FEATURE_OES_mapbuffer             FEATURE_ES
 
 #endif /* FEATURES_H */
index 9d9b475dd17f6b11a8e8c7420136a383c7c2d692..82e004f34868c5a945fcd33abc4d4222de9f4e17 100644 (file)
@@ -2385,6 +2385,9 @@ struct gl_constants
 
    /**< GL_EXT_provoking_vertex */
    GLboolean QuadsFollowProvokingVertexConvention;
+
+   /**< OpenGL version 3.x */
+   GLbitfield ContextFlags;  /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
 };
 
 
index 0fde89b5079c71b4fd8a788e5aee72169899dc4c..ca03404f12f32566bef4b220423d0317bad8410a 100644 (file)
@@ -371,7 +371,7 @@ set_tex_parameteri(GLcontext *ctx,
       }
       return GL_FALSE;
 
-#ifdef FEATURE_OES_draw_texture
+#if FEATURE_OES_draw_texture
    case GL_TEXTURE_CROP_RECT_OES:
       texObj->CropRect[0] = params[0];
       texObj->CropRect[1] = params[1];
@@ -604,7 +604,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
       }
       break;
 
-#ifdef FEATURE_OES_draw_texture
+#if FEATURE_OES_draw_texture
    case GL_TEXTURE_CROP_RECT_OES:
       {
          /* convert float params to int */
@@ -940,6 +940,18 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
                         "glGetTexLevelParameter[if]v(pname)");
          }
          break;
+      case GL_TEXTURE_SHARED_SIZE:
+         if (ctx->VersionMajor >= 3) {
+            /* XXX return number of exponent bits for shared exponent texture
+             * formats, like GL_RGB9_E5.
+             */
+            *params = 0;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM,
+                        "glGetTexLevelParameter[if]v(pname)");
+         }
+         break;
 
       /* GL_ARB_texture_compression */
       case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
@@ -1148,7 +1160,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
         else 
            error = GL_TRUE;
          break;
-#ifdef FEATURE_OES_draw_texture
+#if FEATURE_OES_draw_texture
       case GL_TEXTURE_CROP_RECT_OES:
          params[0] = obj->CropRect[0];
          params[1] = obj->CropRect[1];
@@ -1318,7 +1330,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
             error = GL_TRUE;
          }
          break;
-#ifdef FEATURE_OES_draw_texture
+#if FEATURE_OES_draw_texture
       case GL_TEXTURE_CROP_RECT_OES:
          params[0] = obj->CropRect[0];
          params[1] = obj->CropRect[1];
index a08617ff8d44f2965858a20e4e1dc6b488be6599..4c5c644a6ed47a11774d05c80601a4417d4ed5fa 100644 (file)
@@ -2198,7 +2198,7 @@ case 142:
 YY_RULE_SETUP
 #line 326 "program_lexer.l"
 {
-   yylval->real = (float) _mesa_strtod(yytext, NULL);
+   yylval->real = _mesa_strtof(yytext, NULL);
    return REAL;
 }
        YY_BREAK
@@ -2210,7 +2210,7 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
 #line 330 "program_lexer.l"
 {
-   yylval->real = (float) _mesa_strtod(yytext, NULL);
+   yylval->real = _mesa_strtof(yytext, NULL);
    return REAL;
 }
        YY_BREAK
@@ -2218,7 +2218,7 @@ case 144:
 YY_RULE_SETUP
 #line 334 "program_lexer.l"
 {
-   yylval->real = (float) _mesa_strtod(yytext, NULL);
+   yylval->real = _mesa_strtof(yytext, NULL);
    return REAL;
 }
        YY_BREAK
@@ -2226,7 +2226,7 @@ case 145:
 YY_RULE_SETUP
 #line 338 "program_lexer.l"
 {
-   yylval->real = (float) _mesa_strtod(yytext, NULL);
+   yylval->real = _mesa_strtof(yytext, NULL);
    return REAL;
 }
        YY_BREAK
index d03cb4e493bb8c99fcedc4826b500da65d930557..0de3c5804d21b80ff324b0c5d180a3f9c4e4266e 100644 (file)
@@ -456,7 +456,7 @@ Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number)
 {
    char *end = NULL;
 
-   *number = (GLfloat) _mesa_strtod((const char *) parseState->pos, &end);
+   *number = (GLfloat) _mesa_strtof((const char *) parseState->pos, &end);
 
    if (end && end > (char *) parseState->pos) {
       /* got a number */
index b00765793dcb6ad576f14c8f465b2ec40c0afe30..fe18272cdbaf46f037bee471e8a4c8820a7cab5a 100644 (file)
@@ -324,19 +324,19 @@ ARRAYSHADOW2D             { return_token_or_IDENTIFIER(require_ARB_fp && require
    return INTEGER;
 }
 {num}?{frac}{exp}?        {
-   yylval->real = (float) _mesa_strtod(yytext, NULL);
+   yylval->real = _mesa_strtof(yytext, NULL);
    return REAL;
 }
 {num}"."/[^.]             {
-   yylval->real = (float) _mesa_strtod(yytext, NULL);
+   yylval->real = _mesa_strtof(yytext, NULL);
    return REAL;
 }
 {num}{exp}                {
-   yylval->real = (float) _mesa_strtod(yytext, NULL);
+   yylval->real = _mesa_strtof(yytext, NULL);
    return REAL;
 }
 {num}"."{exp}             {
-   yylval->real = (float) _mesa_strtod(yytext, NULL);
+   yylval->real = _mesa_strtof(yytext, NULL);
    return REAL;
 }
 
index a25ca55bc42592c06f1929bc147b0c569a7ee537..d75354deffe71909da2bc2482dfd535d5fff2043 100644 (file)
@@ -605,7 +605,7 @@ float sqrt(const float x)
    const float nx = -x;
    float r;
    __asm float_rsq r, x;
-   __asm float_rcp r, r;
+   r = r * x;
    __asm vec4_cmp __retVal, nx, r, 0.0;
 }
 
@@ -615,8 +615,7 @@ vec2 sqrt(const vec2 x)
    vec2 r;
    __asm float_rsq r.x, x.x;
    __asm float_rsq r.y, x.y;
-   __asm float_rcp r.x, r.x;
-   __asm float_rcp r.y, r.y;
+   r = r * x;
    __asm vec4_cmp __retVal, nx, r, zero;
 }
 
@@ -627,9 +626,7 @@ vec3 sqrt(const vec3 x)
    __asm float_rsq r.x, x.x;
    __asm float_rsq r.y, x.y;
    __asm float_rsq r.z, x.z;
-   __asm float_rcp r.x, r.x;
-   __asm float_rcp r.y, r.y;
-   __asm float_rcp r.z, r.z;
+   r = r * x;
    __asm vec4_cmp __retVal, nx, r, zero;
 }
 
@@ -641,10 +638,7 @@ vec4 sqrt(const vec4 x)
    __asm float_rsq r.y, x.y;
    __asm float_rsq r.z, x.z;
    __asm float_rsq r.w, x.w;
-   __asm float_rcp r.x, r.x;
-   __asm float_rcp r.y, r.y;
-   __asm float_rcp r.z, r.z;
-   __asm float_rcp r.w, r.w;
+   r = r * x;
    __asm vec4_cmp __retVal, nx, r, zero;
 }
 
@@ -1166,7 +1160,7 @@ float length(const vec2 v)
    float r;
    const float p = dot(v, v);      // p = v.x * v.x + v.y * v.y
    __asm float_rsq r, p;           // r = 1 / sqrt(p)
-   __asm float_rcp __retVal.x, r;  // retVal = 1 / r
+   __retVal = p * r;               // p * r = sqrt(p);
 }
 
 float length(const vec3 v)
@@ -1174,7 +1168,7 @@ float length(const vec3 v)
    float r;
    const float p = dot(v, v);      // p = v.x * v.x + v.y * v.y + v.z * v.z
    __asm float_rsq r, p;           // r = 1 / sqrt(p)
-   __asm float_rcp __retVal, r;    // retVal = 1 / r
+   __retVal = p * r;               // p * r = sqrt(p);
 }
 
 float length(const vec4 v)
@@ -1182,7 +1176,7 @@ float length(const vec4 v)
    float r;
    const float p = dot(v, v);      // p = v.x * v.x + v.y * v.y + ...
    __asm float_rsq r, p;           // r = 1 / sqrt(p)
-   __asm float_rcp __retVal, r;    // retVal = 1 / r
+   __retVal = p * r;               // p * r = sqrt(p);
 }
 
 
index b95c15fea6114e7c3bb80c193bf9a185aaf1a305..ad86676157076015637560fee71c14f2c1fadde1 100644 (file)
@@ -246,7 +246,7 @@ parse_general_number(slang_parse_ctx *ctx, float *number)
    if (flt[strlen(flt) - 1] == 'f' || flt[strlen(flt) - 1] == 'F') {
       flt[strlen(flt) - 1] = '\0';
    }
-   *number = (float)_mesa_strtod(flt, (char **)NULL);
+   *number = _mesa_strtof(flt, (char **)NULL);
    free(flt);
 
    return 1;
@@ -312,7 +312,7 @@ parse_float(slang_parse_ctx * C, float *number)
       slang_string_concat(whole, "E");
       slang_string_concat(whole, exponent);
 
-      *number = (float) (_mesa_strtod(whole, (char **) NULL));
+      *number = _mesa_strtof(whole, (char **) NULL);
 
       _slang_free(whole);
    }
index d59e24de1f2fbe5f806d0e2087fd39068981a322..d6ae696e39571887d36ddd7bffc32831d7392afc 100644 (file)
@@ -214,6 +214,7 @@ STATETRACKER_SOURCES = \
        state_tracker/st_format.c \
        state_tracker/st_framebuffer.c \
        state_tracker/st_gen_mipmap.c \
+       state_tracker/st_manager.c \
        state_tracker/st_mesa_to_tgsi.c \
        state_tracker/st_program.c \
        state_tracker/st_texture.c
index 7806df4a5310592a628c2fff2023b185209fd5a2..cf391f1f91f593d27e561991f0a02560401fb0ce 100644 (file)
@@ -34,8 +34,7 @@
 #include "st_atom.h"
 #include "st_cb_bitmap.h"
 #include "st_program.h"
-
-#include "pipe/p_context.h"
+#include "st_manager.h"
 
 
 /**
@@ -136,9 +135,7 @@ void st_validate_state( struct st_context *st )
 
    check_program_state( st );
 
-   if (st->pipe->screen->update_buffer)
-      st->pipe->screen->update_buffer(st->pipe->screen,
-                                     st->pipe->priv);
+   st_manager_validate_framebuffers(st);
 
    if (state->st == 0)
       return;
index fba7bfe2cea6d7a81b40fc0a78275341ad03bb94..79ad70909a9e5e03031d216d7a81bfe17483d8f9 100644 (file)
@@ -38,7 +38,6 @@
 #include "st_texture.h"
 #include "pipe/p_context.h"
 #include "cso_cache/cso_context.h"
-#include "util/u_rect.h"
 #include "util/u_math.h"
 #include "util/u_inlines.h"
 
@@ -164,17 +163,10 @@ update_framebuffer_state( struct st_context *st )
          (void) st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT, &surf_front);
          (void) st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT, &surf_back);
 
-         if (st->pipe->surface_copy) {
-            st->pipe->surface_copy(st->pipe,
-                                   surf_front, 0, 0,  /* dest */
-                                   surf_back, 0, 0,   /* src */
-                                   fb->Width, fb->Height);
-         } else {
-            util_surface_copy(st->pipe, FALSE,
-                              surf_front, 0, 0,
-                              surf_back, 0, 0,
-                              fb->Width, fb->Height);
-         }
+         st->pipe->surface_copy(st->pipe,
+                                surf_front, 0, 0,  /* dest */
+                                surf_back, 0, 0,   /* src */
+                                fb->Width, fb->Height);
       }
       /* we're assuming we'll really draw to the front buffer */
       st->frontbuffer_status = FRONT_STATUS_DIRTY;
index b446b2079cf172a5bf91fae8eaa53a558711b466..03e333614487e6e70bbc2b90989a956f59784f8c 100644 (file)
@@ -256,6 +256,8 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
       /* create the colormap/texture now if not already done */
       if (!st->pixel_xfer.pixelmap_texture) {
          st->pixel_xfer.pixelmap_texture = create_color_map_texture(ctx);
+         st->pixel_xfer.pixelmap_sampler_view = st_sampler_view_from_texture(ctx->st->pipe,
+                                                                             st->pixel_xfer.pixelmap_texture);
       }
 
       /* with a little effort, we can do four pixel map look-ups with
index 57b71c1e7b02d6d2cfa01d463886ee62d0e33668..241c001f94fa5b865876e83d8f45c0aee28cdb13 100644 (file)
@@ -56,7 +56,7 @@ update_textures(struct st_context *st)
 
    /* loop over sampler units (aka tex image units) */
    for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
-      struct pipe_texture *pt = NULL;
+      struct pipe_sampler_view *sampler_view = NULL;
 
       if (samplersUsed & (1 << su)) {
          struct gl_texture_object *texObj;
@@ -84,7 +84,7 @@ update_textures(struct st_context *st)
 
          st->state.num_textures = su + 1;
 
-         pt = st_get_stobj_texture(stObj);
+         sampler_view = st_get_stobj_sampler_view(stObj);
       }
 
       /*
@@ -96,17 +96,17 @@ update_textures(struct st_context *st)
       }
       */
 
-      pipe_texture_reference(&st->state.sampler_texture[su], pt);
+      pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view);
    }
 
-   cso_set_sampler_textures(st->cso_context,
-                            st->state.num_textures,
-                            st->state.sampler_texture);
+   cso_set_fragment_sampler_views(st->cso_context,
+                                  st->state.num_textures,
+                                  st->state.sampler_views);
    if (st->ctx->Const.MaxVertexTextureImageUnits > 0) {
-      cso_set_vertex_sampler_textures(st->cso_context,
-                                      MIN2(st->state.num_textures,
-                                           st->ctx->Const.MaxVertexTextureImageUnits),
-                                      st->state.sampler_texture);
+      cso_set_vertex_sampler_views(st->cso_context,
+                                   MIN2(st->state.num_textures,
+                                        st->ctx->Const.MaxVertexTextureImageUnits),
+                                   st->state.sampler_views);
    }
 }
 
index dfd8925edf4d66d2c6487d23d7aadeed4487b280..9a0446bb7103679a2ac3a06b7aa6e1359a730bb9 100644 (file)
@@ -397,7 +397,7 @@ setup_bitmap_vertex_data(struct st_context *st,
 static void
 draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
                  GLsizei width, GLsizei height,
-                 struct pipe_texture *pt,
+                 struct pipe_sampler_view *sv,
                  const GLfloat *color)
 {
    struct st_context *st = ctx->st;
@@ -435,7 +435,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
 
    cso_save_rasterizer(cso);
    cso_save_samplers(cso);
-   cso_save_sampler_textures(cso);
+   cso_save_fragment_sampler_views(cso);
    cso_save_viewport(cso);
    cso_save_fragment_shader(cso);
    cso_save_vertex_shader(cso);
@@ -465,11 +465,11 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
 
    /* user textures, plus the bitmap texture */
    {
-      struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
+      struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
       uint num = MAX2(stfp->bitmap_sampler + 1, st->state.num_textures);
-      memcpy(textures, st->state.sampler_texture, sizeof(textures));
-      textures[stfp->bitmap_sampler] = pt;
-      cso_set_sampler_textures(cso, num, textures);
+      memcpy(sampler_views, st->state.sampler_views, sizeof(sampler_views));
+      sampler_views[stfp->bitmap_sampler] = sv;
+      cso_set_fragment_sampler_views(cso, num, sampler_views);
    }
 
    /* viewport state: viewport matching window dims */
@@ -507,7 +507,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    /* restore state */
    cso_restore_rasterizer(cso);
    cso_restore_samplers(cso);
-   cso_restore_sampler_textures(cso);
+   cso_restore_fragment_sampler_views(cso);
    cso_restore_viewport(cso);
    cso_restore_fragment_shader(cso);
    cso_restore_vertex_shader(cso);
@@ -598,6 +598,7 @@ st_flush_bitmap_cache(struct st_context *st)
 
       if (st->ctx->DrawBuffer) {
          struct pipe_context *pipe = st->pipe;
+         struct pipe_sampler_view *sv;
 
          assert(cache->xmin <= cache->xmax);
  
@@ -620,13 +621,18 @@ st_flush_bitmap_cache(struct st_context *st)
             cache->trans = NULL;
          }
 
-         draw_bitmap_quad(st->ctx,
-                          cache->xpos,
-                          cache->ypos,
-                          cache->zpos,
-                          BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
-                          cache->texture,
-                          cache->color);
+         sv = st_sampler_view_from_texture(st->pipe, cache->texture);
+         if (sv) {
+            draw_bitmap_quad(st->ctx,
+                             cache->xpos,
+                             cache->ypos,
+                             cache->zpos,
+                             BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
+                             sv,
+                             cache->color);
+
+            pipe_sampler_view_reference(&sv, NULL);
+         }
       }
 
       /* release/free the texture */
@@ -749,10 +755,18 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
 
    pt = make_bitmap_texture(ctx, width, height, unpack, bitmap);
    if (pt) {
+      struct pipe_sampler_view *sv = st_sampler_view_from_texture(st->pipe, pt);
+
       assert(pt->target == PIPE_TEXTURE_2D);
-      draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2],
-                       width, height, pt,
-                       st->ctx->Current.RasterColor);
+
+      if (sv) {
+         draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2],
+                          width, height, sv,
+                          st->ctx->Current.RasterColor);
+
+         pipe_sampler_view_reference(&sv, NULL);
+      }
+
       /* release/free the texture */
       pipe_texture_reference(&pt, NULL);
    }
index 36e03018d9f6ca3a3d277300395e6e7f0856b982..06b0a18fd221786ec202dd3da9f0711ee013c314 100644 (file)
@@ -69,6 +69,7 @@ st_BlitFramebuffer(GLcontext *ctx,
    const GLbitfield depthStencil = (GL_DEPTH_BUFFER_BIT |
                                     GL_STENCIL_BUFFER_BIT);
    struct st_context *st = ctx->st;
+   struct pipe_context *pipe = st->pipe;
    const uint pFilter = ((filter == GL_NEAREST)
                          ? PIPE_TEX_MIPFILTER_NEAREST
                          : PIPE_TEX_MIPFILTER_LINEAR);
@@ -111,8 +112,8 @@ st_BlitFramebuffer(GLcontext *ctx,
          &readFB->Attachment[readFB->_ColorReadBufferIndex];
 
       if(srcAtt->Type == GL_TEXTURE) {
-         struct pipe_screen *screen = ctx->st->pipe->screen;
-         const struct st_texture_object *srcObj =
+         struct pipe_screen *screen = pipe->screen;
+         struct st_texture_object *srcObj =
             st_texture_object(srcAtt->Texture);
          struct st_renderbuffer *dstRb =
             st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
@@ -132,7 +133,8 @@ st_BlitFramebuffer(GLcontext *ctx,
             return;
 
          util_blit_pixels(st->blit,
-                          srcSurf, srcX0, srcY0, srcX1, srcY1,
+                          srcSurf, st_get_stobj_sampler_view(srcObj),
+                          srcX0, srcY0, srcX1, srcY1,
                           dstSurf, dstX0, dstY0, dstX1, dstY1,
                           0.0, pFilter);
 
@@ -144,10 +146,11 @@ st_BlitFramebuffer(GLcontext *ctx,
          struct st_renderbuffer *dstRb =
             st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
          struct pipe_surface *srcSurf = srcRb->surface;
+         struct pipe_sampler_view *srcView = st_renderbuffer_get_sampler_view(srcRb, pipe);
          struct pipe_surface *dstSurf = dstRb->surface;
 
          util_blit_pixels(st->blit,
-                          srcSurf, srcX0, srcY0, srcX1, srcY1,
+                          srcSurf, srcView, srcX0, srcY0, srcX1, srcY1,
                           dstSurf, dstX0, dstY0, dstX1, dstY1,
                           0.0, pFilter);
       }
@@ -179,11 +182,13 @@ st_BlitFramebuffer(GLcontext *ctx,
       if ((mask & depthStencil) == depthStencil &&
           srcDepthSurf == srcStencilSurf &&
           dstDepthSurf == dstStencilSurf) {
+         struct pipe_sampler_view *srcView = st_renderbuffer_get_sampler_view(srcDepthRb, pipe);
+
          /* Blitting depth and stencil values between combined
           * depth/stencil buffers.  This is the ideal case for such buffers.
           */
          util_blit_pixels(st->blit,
-                          srcDepthSurf, srcX0, srcY0, srcX1, srcY1,
+                          srcDepthSurf, srcView, srcX0, srcY0, srcX1, srcY1,
                           dstDepthSurf, dstX0, dstY0, dstX1, dstY1,
                           0.0, pFilter);
       }
index de86062fc404ed601d34d02c0b4eb887368db191..6007c767182128e282485062c25703ce8305d440 100644 (file)
 #include "st_inlines.h"
 
 #include "pipe/p_context.h"
-#include "util/u_inlines.h"
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "util/u_format.h"
+#include "util/u_inlines.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_draw_quad.h"
 
 #include "cso_cache/cso_context.h"
 
 
+/**
+ * Do per-context initialization for glClear.
+ */
 void
 st_init_clear(struct st_context *st)
 {
@@ -67,8 +70,7 @@ st_init_clear(struct st_context *st)
    st->clear.raster.gl_rasterization_rules = 1;
 
    /* fragment shader state: color pass-through program */
-   st->clear.fs =
-      util_make_fragment_passthrough_shader(pipe);
+   st->clear.fs = util_make_fragment_passthrough_shader(pipe);
 
    /* vertex shader state: color/position pass-through */
    {
@@ -82,6 +84,9 @@ st_init_clear(struct st_context *st)
 }
 
 
+/**
+ * Free per-context state for glClear.
+ */
 void
 st_destroy_clear(struct st_context *st)
 {
@@ -131,7 +136,8 @@ draw_quad(GLcontext *ctx,
    }
 
    if (!st->clear.vbuf) {
-      st->clear.vbuf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
+      st->clear.vbuf = pipe_buffer_create(pipe->screen, 32,
+                                          PIPE_BUFFER_USAGE_VERTEX,
                                           max_slots * sizeof(st->clear.vertices));
    }
 
@@ -160,7 +166,8 @@ draw_quad(GLcontext *ctx,
 
    /* put vertex data into vbuf */
    st_no_flush_pipe_buffer_write_nooverlap(st, st->clear.vbuf,
-                                           st->clear.vbuf_slot * sizeof(st->clear.vertices),
+                                           st->clear.vbuf_slot
+                                             * sizeof(st->clear.vertices),
                                            sizeof(st->clear.vertices),
                                            st->clear.vertices);
 
@@ -289,7 +296,8 @@ clear_with_quad(GLcontext *ctx,
    cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
 
    /* draw quad matching scissor rect (XXX verify coord round-off) */
-   draw_quad(ctx, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor);
+   draw_quad(ctx, x0, y0, x1, y1,
+             (GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor);
 
    /* Restore pipe state */
    cso_restore_blend(st->cso_context);
@@ -301,7 +309,6 @@ clear_with_quad(GLcontext *ctx,
    cso_restore_fragment_shader(st->cso_context);
    cso_restore_vertex_shader(st->cso_context);
    cso_restore_vertex_elements(st->cso_context);
-
 }
 
 
@@ -316,18 +323,22 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
         ctx->Scissor.Y != 0 ||
         ctx->Scissor.Width < rb->Width ||
         ctx->Scissor.Height < rb->Height))
-      return TRUE;
+      return GL_TRUE;
 
    if (!ctx->Color.ColorMask[0][0] ||
        !ctx->Color.ColorMask[0][1] ||
        !ctx->Color.ColorMask[0][2] ||
        !ctx->Color.ColorMask[0][3])
-      return TRUE;
+      return GL_TRUE;
 
-   return FALSE;
+   return GL_FALSE;
 }
 
 
+/**
+ * Determine if we need to clear the combiend depth/stencil buffer by
+ * drawing a quad.
+ */
 static INLINE GLboolean
 check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
@@ -344,12 +355,12 @@ check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
         ctx->Scissor.Y != 0 ||
         ctx->Scissor.Width < rb->Width ||
         ctx->Scissor.Height < rb->Height))
-      return TRUE;
+      return GL_TRUE;
 
    if (maskStencil)
-      return TRUE;
+      return GL_TRUE;
 
-   return FALSE;
+   return GL_FALSE;
 }
 
 
@@ -367,13 +378,12 @@ check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
         ctx->Scissor.Y != 0 ||
         ctx->Scissor.Width < rb->Width ||
         ctx->Scissor.Height < rb->Height))
-      return TRUE;
+      return GL_TRUE;
 
-   if (isDS && 
-       ctx->DrawBuffer->Visual.stencilBits > 0)
-      return TRUE;
+   if (isDS && ctx->DrawBuffer->Visual.stencilBits > 0)
+      return GL_TRUE;
 
-   return FALSE;
+   return GL_FALSE;
 }
 
 
@@ -394,30 +404,33 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
           rb->Format == MESA_FORMAT_S8_Z24);
 
    if (maskStencil) 
-      return TRUE;
+      return GL_TRUE;
 
    if (ctx->Scissor.Enabled &&
        (ctx->Scissor.X != 0 ||
         ctx->Scissor.Y != 0 ||
         ctx->Scissor.Width < rb->Width ||
         ctx->Scissor.Height < rb->Height))
-      return TRUE;
+      return GL_TRUE;
 
    /* This is correct, but it is necessary to look at the depth clear
     * value held in the surface when it comes time to issue the clear,
     * rather than taking depth and stencil clear values from the
     * current state.
     */
-   if (isDS && 
-       ctx->DrawBuffer->Visual.depthBits > 0)
-      return TRUE;
+   if (isDS && ctx->DrawBuffer->Visual.depthBits > 0)
+      return GL_TRUE;
 
-   return FALSE;
+   return GL_FALSE;
 }
 
 
 
-void st_flush_clear( struct st_context *st )
+/**
+ * Called when we need to flush.
+ */
+void
+st_flush_clear(struct st_context *st)
 {
    /* Release vertex buffer to avoid synchronous rendering if we were
     * to map it in the next frame.
@@ -430,10 +443,9 @@ void st_flush_clear( struct st_context *st )
 
 /**
  * Called via ctx->Driver.Clear()
- * XXX: doesn't pick up the differences between front/back/left/right
- * clears.  Need to sort that out...
  */
-static void st_clear(GLcontext *ctx, GLbitfield mask)
+static void
+st_Clear(GLcontext *ctx, GLbitfield mask)
 {
    static const GLbitfield BUFFER_BITS_DS
       = (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
@@ -442,8 +454,8 @@ static void st_clear(GLcontext *ctx, GLbitfield mask)
       = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
    struct gl_renderbuffer *stencilRb
       = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
-   GLbitfield quad_buffers = 0;
-   GLbitfield clear_buffers = 0;
+   GLbitfield quad_buffers = 0x0;
+   GLbitfield clear_buffers = 0x0;
    GLuint i;
 
    /* This makes sure the pipe has the latest scissor, etc values */
@@ -528,7 +540,8 @@ static void st_clear(GLcontext *ctx, GLbitfield mask)
 }
 
 
-void st_init_clear_functions(struct dd_function_table *functions)
+void
+st_init_clear_functions(struct dd_function_table *functions)
 {
-   functions->Clear = st_clear;
+   functions->Clear = st_Clear;
 }
index c44d0fc3e86e87a291713b04d613a2227c776ca0..c9d1e9c6c4b2b15796405e12a5342c2556b11ca1 100644 (file)
@@ -59,7 +59,6 @@
 #include "util/u_draw_quad.h"
 #include "util/u_format.h"
 #include "util/u_math.h"
-#include "util/u_rect.h"
 #include "shader/prog_instruction.h"
 #include "cso_cache/cso_context.h"
 
@@ -525,7 +524,7 @@ static void
 draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
                    GLsizei width, GLsizei height,
                    GLfloat zoomX, GLfloat zoomY,
-                   struct pipe_texture *pt,
+                   struct pipe_sampler_view *sv,
                    void *driver_vp,
                    void *driver_fp,
                    const GLfloat *color,
@@ -548,7 +547,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    cso_save_rasterizer(cso);
    cso_save_viewport(cso);
    cso_save_samplers(cso);
-   cso_save_sampler_textures(cso);
+   cso_save_fragment_sampler_views(cso);
    cso_save_fragment_shader(cso);
    cso_save_vertex_shader(cso);
    cso_save_vertex_elements(cso);
@@ -608,13 +607,13 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
 
    /* texture state: */
    if (st->pixel_xfer.pixelmap_enabled) {
-      struct pipe_texture *textures[2];
-      textures[0] = pt;
-      textures[1] = st->pixel_xfer.pixelmap_texture;
-      pipe->set_fragment_sampler_textures(pipe, 2, textures);
+      struct pipe_sampler_view *sampler_views[2];
+      sampler_views[0] = sv;
+      sampler_views[1] = st->pixel_xfer.pixelmap_sampler_view;
+      cso_set_fragment_sampler_views(cso, 2, sampler_views);
    }
    else {
-      pipe->set_fragment_sampler_textures(pipe, 1, &pt);
+      cso_set_fragment_sampler_views(cso, 1, &sv);
    }
 
    /* Compute Gallium window coords (y=0=top) with pixel zoom.
@@ -635,14 +634,14 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    z = z * 2.0 - 1.0;
 
    draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex,
-            (GLfloat) width / pt->width0,
-            (GLfloat) height / pt->height0);
+             (GLfloat) width / sv->texture->width0,
+             (GLfloat) height / sv->texture->height0);
 
    /* restore state */
    cso_restore_rasterizer(cso);
    cso_restore_viewport(cso);
    cso_restore_samplers(cso);
-   cso_restore_sampler_textures(cso);
+   cso_restore_fragment_sampler_views(cso);
    cso_restore_fragment_shader(cso);
    cso_restore_vertex_shader(cso);
    cso_restore_vertex_elements(cso);
@@ -835,12 +834,17 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
       struct pipe_texture *pt
          = make_texture(st, width, height, format, type, unpack, pixels);
       if (pt) {
-         draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2],
-                            width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
-                            pt, 
-                            driver_vp, 
-                            driver_fp,
-                            color, GL_FALSE);
+         struct pipe_sampler_view *sv = st_sampler_view_from_texture(st->pipe, pt);
+
+         if (sv) {
+            draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2],
+                               width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
+                               sv,
+                               driver_vp, 
+                               driver_fp,
+                               color, GL_FALSE);
+            pipe_sampler_view_reference(&sv, NULL);
+         }
          pipe_texture_reference(&pt, NULL);
       }
    }
@@ -959,42 +963,17 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
    struct st_renderbuffer *rbRead;
    void *driver_vp, *driver_fp;
    struct pipe_texture *pt;
+   struct pipe_sampler_view *sv;
    GLfloat *color;
    enum pipe_format srcFormat, texFormat;
    GLboolean invertTex = GL_FALSE;
+   GLint readX, readY, readW, readH;
+   struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
 
    pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
 
    st_validate_state(st);
 
-   if (srcx < 0) {
-      width -= -srcx;
-      dstx += -srcx;
-      srcx = 0;
-   }
-
-   if (srcy < 0) {
-      height -= -srcy;
-      dsty += -srcy;
-      srcy = 0;
-   }
-
-   if (dstx < 0) {
-      width -= -dstx;
-      srcx += -dstx;
-      dstx = 0;
-   }
-
-   if (dsty < 0) {
-      height -= -dsty;
-      srcy += -dsty;
-      dsty = 0;
-   }
-
-   if (width < 0 || height < 0)
-      return;
-
-
    if (type == GL_STENCIL) {
       /* can't use texturing to do stencil */
       copy_stencil_pixels(ctx, srcx, srcy, width, height, dstx, dsty);
@@ -1027,7 +1006,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
          texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT,
                                       PIPE_TEXTURE_2D, 
                                       PIPE_TEXTURE_USAGE_DEPTH_STENCIL);
-         assert(texFormat != PIPE_FORMAT_NONE); /* XXX no depth texture formats??? */
+         assert(texFormat != PIPE_FORMAT_NONE);
       }
       else {
          /* default color format */
@@ -1037,27 +1016,38 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       }
    }
 
+   /* Invert src region if needed */
    if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
       srcy = ctx->ReadBuffer->Height - srcy - height;
-
-      if (srcy < 0) {
-         height -= -srcy;
-         srcy = 0;
-      }
-
-      if (height < 0)
-         return;
-
       invertTex = !invertTex;
    }
 
+   /* Clip the read region against the src buffer bounds.
+    * We'll still allocate a temporary buffer/texture for the original
+    * src region size but we'll only read the region which is on-screen.
+    * This may mean that we draw garbage pixels into the dest region, but
+    * that's expected.
+    */
+   readX = srcx;
+   readY = srcy;
+   readW = width;
+   readH = height;
+   _mesa_clip_readpixels(ctx, &readX, &readY, &readW, &readH, &pack);
+   readW = MAX2(0, readW);
+   readH = MAX2(0, readH);
+
    /* alloc temporary texture */
    pt = alloc_texture(st, width, height, texFormat);
    if (!pt)
       return;
 
+   sv = st_sampler_view_from_texture(st->pipe, pt);
+   if (!sv) {
+      pipe_texture_reference(&pt, NULL);
+      return;
+   }
+
    /* Make temporary texture which is a copy of the src region.
-    * We'll draw a quad with this texture to draw the dest image.
     */
    if (srcFormat == texFormat) {
       /* copy source framebuffer surface into mipmap/texture */
@@ -1066,19 +1056,12 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
                                        PIPE_BUFFER_USAGE_GPU_READ);
       struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, 
                                       PIPE_BUFFER_USAGE_GPU_WRITE );
-      if (pipe->surface_copy) {
-         pipe->surface_copy(pipe,
-                            psTex, /* dest */
-                            0, 0, /* destx/y */
-                            psRead,
-                            srcx, srcy, width, height);
-      } else {
-         util_surface_copy(pipe, FALSE,
-                           psTex,
-                           0, 0,
-                           psRead,
-                           srcx, srcy, width, height);
-      }
+
+      pipe->surface_copy(pipe,
+                         psTex,                               /* dest surf */
+                         pack.SkipPixels, pack.SkipRows,      /* dest pos */
+                         psRead,                              /* src surf */
+                         readX, readY, readW, readH);         /* src region */
 
       if (0) {
          /* debug */
@@ -1093,8 +1076,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       /* CPU-based fallback/conversion */
       struct pipe_transfer *ptRead =
          st_cond_flush_get_tex_transfer(st, rbRead->texture, 0, 0, 0,
-                                       PIPE_TRANSFER_READ, srcx, srcy, width,
-                                       height);
+                                        PIPE_TRANSFER_READ,
+                                        readX, readY, readW, readH);
       struct pipe_transfer *ptTex;
       enum pipe_transfer_usage transfer_usage;
 
@@ -1109,20 +1092,21 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       ptTex = st_cond_flush_get_tex_transfer(st, pt, 0, 0, 0, transfer_usage,
                                              0, 0, width, height);
 
+      /* copy image from ptRead surface to ptTex surface */
       if (type == GL_COLOR) {
          /* alternate path using get/put_tile() */
          GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
-         pipe_get_tile_rgba(pipe, ptRead, 0, 0, width, height, buf);
-         pipe_put_tile_rgba(pipe, ptTex, 0, 0, width, height, buf);
-
+         pipe_get_tile_rgba(pipe, ptRead, readX, readY, readW, readH, buf);
+         pipe_put_tile_rgba(pipe, ptTex, pack.SkipPixels, pack.SkipRows,
+                            readW, readH, buf);
          free(buf);
       }
       else {
          /* GL_DEPTH */
          GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
-         pipe_get_tile_z(pipe, ptRead, 0, 0, width, height, buf);
-         pipe_put_tile_z(pipe, ptTex, 0, 0, width, height, buf);
+         pipe_get_tile_z(pipe, ptRead, readX, readY, readW, readH, buf);
+         pipe_put_tile_z(pipe, ptTex, pack.SkipPixels, pack.SkipRows,
+                         readW, readH, buf);
          free(buf);
       }
 
@@ -1130,15 +1114,18 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       pipe->tex_transfer_destroy(pipe, ptTex);
    }
 
-   /* draw textured quad */
+   /* OK, the texture 'pt' contains the src image/pixels.  Now draw a
+    * textured quad with that texture.
+    */
    draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
                       width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
-                      pt
+                      sv
                       driver_vp, 
                       driver_fp,
                       color, invertTex);
 
    pipe_texture_reference(&pt, NULL);
+   pipe_sampler_view_reference(&sv, NULL);
 }
 
 
index abf0c8d6cb1d0bc3549486087e1305c2899482ff..84c2474038d0a7194c81ccc3982831c1b8bf469d 100644 (file)
@@ -48,9 +48,9 @@
 #include "st_format.h"
 #include "st_public.h"
 #include "st_texture.h"
+#include "st_manager.h"
 
 #include "util/u_format.h"
-#include "util/u_rect.h"
 #include "util/u_inlines.h"
 
 
@@ -103,6 +103,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
        */
       pipe_surface_reference( &strb->surface, NULL );
       pipe_texture_reference( &strb->texture, NULL );
+      pipe_sampler_view_reference(&strb->sampler_view, NULL);
 
       /* Setup new texture template.
        */
@@ -162,6 +163,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
    ASSERT(strb);
    pipe_surface_reference(&strb->surface, NULL);
    pipe_texture_reference(&strb->texture, NULL);
+   pipe_sampler_view_reference(&strb->sampler_view, NULL);
    free(strb->data);
    free(strb);
 }
@@ -368,6 +370,8 @@ st_render_texture(GLcontext *ctx,
 
    pipe_surface_reference(&strb->surface, NULL);
 
+   pipe_sampler_view_reference(&strb->sampler_view, st_get_stobj_sampler_view(stObj));
+
    assert(strb->rtt_level <= strb->texture->last_level);
 
    /* new surface for rendering into the texture */
@@ -513,17 +517,10 @@ copy_back_to_front(struct st_context *st,
    (void) st_get_framebuffer_surface(stfb, backIndex, &surf_back);
 
    if (surf_front && surf_back) {
-      if (st->pipe->surface_copy) {
-         st->pipe->surface_copy(st->pipe,
-                                surf_front, 0, 0,  /* dest */
-                                surf_back, 0, 0,   /* src */
-                                fb->Width, fb->Height);
-      } else {
-         util_surface_copy(st->pipe, FALSE,
-                           surf_front, 0, 0,
-                           surf_back, 0, 0,
-                           fb->Width, fb->Height);
-      }
+      st->pipe->surface_copy(st->pipe,
+                             surf_front, 0, 0,  /* dest */
+                             surf_back, 0, 0,   /* src */
+                             fb->Width, fb->Height);
    }
 }
 
@@ -614,8 +611,18 @@ check_create_front_buffers(GLcontext *ctx, struct gl_framebuffer *fb)
 static void
 st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
 {
+   GLframebuffer *fb = ctx->DrawBuffer;
+   GLuint i;
+
    (void) count;
    (void) buffers;
+
+   /* add the renderbuffers on demand */
+   for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+      gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i];
+      st_manager_add_color_renderbuffer(ctx->st, fb, idx);
+   }
+
    check_create_front_buffers(ctx, ctx->DrawBuffer);
 }
 
@@ -626,8 +633,13 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
 static void
 st_ReadBuffer(GLcontext *ctx, GLenum buffer)
 {
+   GLframebuffer *fb = ctx->ReadBuffer;
+
    (void) buffer;
-   check_create_front_buffers(ctx, ctx->ReadBuffer);
+
+   /* add the renderbuffer on demand */
+   st_manager_add_color_renderbuffer(ctx->st, fb, fb->_ColorReadBufferIndex);
+   check_create_front_buffers(ctx, fb);
 }
 
 
@@ -647,3 +659,14 @@ void st_init_fbo_functions(struct dd_function_table *functions)
    functions->DrawBuffers = st_DrawBuffers;
    functions->ReadBuffer = st_ReadBuffer;
 }
+
+struct pipe_sampler_view *
+st_renderbuffer_get_sampler_view(struct st_renderbuffer *rb,
+                                 struct pipe_context *pipe)
+{
+   if (!rb->sampler_view) {
+      rb->sampler_view = st_sampler_view_from_texture(pipe, rb->texture);
+   }
+
+   return rb->sampler_view;
+}
index bea6eb89c3ecf0b7782df89757c37bc7efd7af6a..7a45a608fe120d3d541c6fcbd3fcbbb6f864284c 100644 (file)
@@ -39,6 +39,7 @@ struct st_renderbuffer
    struct gl_renderbuffer Base;
    struct pipe_texture *texture;
    struct pipe_surface *surface; /* temporary view into texture */
+   struct pipe_sampler_view *sampler_view;
    enum pipe_format format;  /** preferred format, or PIPE_FORMAT_NONE */
    GLboolean defined;        /**< defined contents? */
 
@@ -55,6 +56,7 @@ struct st_renderbuffer
    /** Render to texture state */
    struct pipe_texture *texture_save;
    struct pipe_surface *surface_save;
+   struct pipe_sampler_view *sampler_view_save;
 };
 
 
@@ -71,5 +73,9 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw);
 extern void
 st_init_fbo_functions(struct dd_function_table *functions);
 
+extern struct pipe_sampler_view *
+st_renderbuffer_get_sampler_view(struct st_renderbuffer *rb,
+                                 struct pipe_context *pipe);
+
 
 #endif /* ST_CB_FBO_H */
index 28a384ba49b6450a0117fe7b57113f8a8009ed26..30e7afcf2a317e3ff32043eaca82560cb4d7b38e 100644 (file)
@@ -40,6 +40,7 @@
 #include "st_cb_clear.h"
 #include "st_cb_fbo.h"
 #include "st_public.h"
+#include "st_manager.h"
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
@@ -74,12 +75,9 @@ display_front_buffer(struct st_context *st)
       = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
 
    if (strb) {
-      struct pipe_surface *front_surf = strb->surface;
-      
       /* Hook for copying "fake" frontbuffer if necessary:
        */
-      st->pipe->screen->flush_frontbuffer( st->pipe->screen, front_surf,
-                                           st->winsys_drawable_handle );
+      st_manager_flush_frontbuffer(st);
 
       /*
         st->frontbuffer_status = FRONT_STATUS_UNDEFINED;
index 080a5f9bfb832ee457bc64b2e706d4927abe548e..7afb275fe2fa11fc96108b1bebbda9f77d704788 100644 (file)
@@ -45,6 +45,7 @@
 
 #include "st_debug.h"
 #include "st_context.h"
+#include "st_atom.h"
 #include "st_cb_readpixels.h"
 #include "st_cb_fbo.h"
 #include "st_public.h"
@@ -350,6 +351,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
    /* XXX convolution not done yet */
    assert((transferOps & IMAGE_CONVOLUTION_BIT) == 0);
 
+   st_validate_state(ctx->st);
+
    /* Do all needed clipping here, so that we can forget about it later */
    if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) {
       /* The ReadPixels transfer is totally outside the window bounds */
index 626e6ad660d167250fc3911a5eab65ecac20736b..390ada5489cb5fbc1af419c5dc9383720d9d29d7 100644 (file)
@@ -63,6 +63,7 @@
 #include "util/u_blit.h"
 #include "util/u_format.h"
 #include "util/u_surface.h"
+#include "util/u_sampler.h"
 #include "util/u_math.h"
 
 
@@ -123,7 +124,17 @@ st_DeleteTextureObject(GLcontext *ctx,
    struct st_texture_object *stObj = st_texture_object(texObj);
    if (stObj->pt)
       pipe_texture_reference(&stObj->pt, NULL);
-
+   if (stObj->sampler_view) {
+      if (stObj->sampler_view->context != ctx->st->pipe) {
+         /* Take "ownership" of this texture sampler view by setting
+          * its context pointer to this context.  This avoids potential
+          * crashes when the texture object is shared among contexts
+          * and the original/owner context has already been destroyed.
+          */
+         stObj->sampler_view->context = ctx->st->pipe;
+      }
+      pipe_sampler_view_reference(&stObj->sampler_view, NULL);
+   }
    _mesa_delete_texture_object(ctx, texObj);
 }
 
@@ -312,6 +323,8 @@ guess_and_alloc_texture(struct st_context *st,
                                  depth,
                                  usage);
 
+   stObj->pipe = st->pipe;
+
    DBG("%s - success\n", __FUNCTION__);
 }
 
@@ -376,6 +389,8 @@ compress_with_blit(GLcontext * ctx,
    gl_format mesa_format;
    struct pipe_texture templ;
    struct pipe_texture *src_tex;
+   struct pipe_sampler_view view_templ;
+   struct pipe_sampler_view *src_view;
    struct pipe_surface *dst_surface;
    struct pipe_transfer *tex_xfer;
    void *map;
@@ -437,9 +452,16 @@ compress_with_blit(GLcontext * ctx,
    pipe->transfer_unmap(pipe, tex_xfer);
    pipe->tex_transfer_destroy(pipe, tex_xfer);
 
+   /* Create temporary sampler view */
+   u_sampler_view_default_template(&view_templ,
+                                   src_tex,
+                                   src_tex->format);
+   src_view = pipe->create_sampler_view(pipe, src_tex, &view_templ);
+
+
    /* copy / compress image */
    util_blit_pixels_tex(ctx->st->blit,
-                        src_tex,          /* pipe_texture (src) */
+                        src_view,         /* sampler view (src) */
                         0, 0,             /* src x0, y0 */
                         width, height,    /* src x1, y1 */
                         dst_surface,      /* pipe_surface (dst) */
@@ -451,6 +473,7 @@ compress_with_blit(GLcontext * ctx,
 
    pipe_surface_reference(&dst_surface, NULL);
    pipe_texture_reference(&src_tex, NULL);
+   pipe_sampler_view_reference(&src_view, NULL);
 
    return GL_TRUE;
 }
@@ -556,6 +579,7 @@ st_TexImage(GLcontext * ctx,
          DBG("release it\n");
          pipe_texture_reference(&stObj->pt, NULL);
          assert(!stObj->pt);
+         pipe_sampler_view_reference(&stObj->sampler_view, NULL);
          stObj->teximage_realloc = FALSE;
       }
    }
@@ -813,6 +837,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
    struct pipe_context *pipe = ctx->st->pipe;
    struct pipe_screen *screen = pipe->screen;
    struct st_texture_image *stImage = st_texture_image(texImage);
+   struct st_texture_object *stObj = st_texture_object(texObj);
+   struct pipe_sampler_view *src_view = st_get_stobj_sampler_view(stObj);
    const GLuint width = texImage->Width;
    const GLuint height = texImage->Height;
    struct pipe_surface *dst_surface;
@@ -829,7 +855,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
 
    /* blit/render/decompress */
    util_blit_pixels_tex(ctx->st->blit,
-                        stImage->pt,      /* pipe_texture (src) */
+                        src_view,      /* pipe_texture (src) */
                         0, 0,             /* src x0, y0 */
                         width, height,    /* src x1, y1 */
                         dst_surface,      /* pipe_surface (dst) */
@@ -882,6 +908,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
 
    _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
 
+   pipe->tex_transfer_destroy(pipe, tex_xfer);
+
    /* destroy the temp / dest surface */
    util_destroy_rgba_surface(dst_texture, dst_surface);
 }
@@ -906,7 +934,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
    GLubyte *dest;
 
    if (stImage->pt &&
-       util_format_is_compressed(stImage->pt->format) &&
+       util_format_is_s3tc(stImage->pt->format) &&
        !compressed_dst) {
       /* Need to decompress the texture.
        * We'll do this by rendering a textured quad.
@@ -1540,8 +1568,7 @@ st_copy_texsubimage(GLcontext *ctx,
 
    if (ctx->_ImageTransferState == 0x0) {
 
-      if (pipe->surface_copy &&
-          matching_base_formats &&
+      if (matching_base_formats &&
           src_format == dest_format &&
           !do_flip) 
       {
@@ -1593,6 +1620,7 @@ st_copy_texsubimage(GLcontext *ctx,
          }
          util_blit_pixels_writemask(ctx->st->blit,
                                     strb->surface,
+                                    st_renderbuffer_get_sampler_view(strb, pipe),
                                     srcX, srcY0,
                                     srcX + width, srcY1,
                                     dest_surface,
@@ -1789,6 +1817,7 @@ st_finalize_texture(GLcontext *ctx,
        firstImage->pt != stObj->pt &&
        firstImage->pt->last_level >= stObj->lastLevel) {
       pipe_texture_reference(&stObj->pt, firstImage->pt);
+      pipe_sampler_view_reference(&stObj->sampler_view, NULL);
    }
 
    /* bytes per pixel block (blocks are usually 1x1) */
@@ -1808,6 +1837,7 @@ st_finalize_texture(GLcontext *ctx,
           stObj->pt->depth0 != firstImage->base.Depth2)
       {
          pipe_texture_reference(&stObj->pt, NULL);
+         pipe_sampler_view_reference(&stObj->sampler_view, NULL);
          ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
       }
    }
index ca6d4dfb069fcc3013aa343803c2cb0801c7fddc..72f5a9c1e0b787bfd5e29c7d64ae63431aec6652 100644 (file)
@@ -30,9 +30,9 @@
 #include "vbo/vbo.h"
 #include "shader/shader_api.h"
 #include "glapi/glapi.h"
+#include "st_context.h"
 #include "st_public.h"
 #include "st_debug.h"
-#include "st_context.h"
 #include "st_cb_accum.h"
 #include "st_cb_bitmap.h"
 #include "st_cb_blit.h"
@@ -63,6 +63,7 @@
 #include "st_program.h"
 #include "pipe/p_context.h"
 #include "util/u_inlines.h"
+#include "util/u_rect.h"
 #include "draw/draw_context.h"
 #include "cso_cache/cso_context.h"
 
@@ -97,6 +98,19 @@ st_get_msaa(void)
 }
 
 
+/** Default method for pipe_context::surface_copy() */
+static void
+st_surface_copy(struct pipe_context *pipe,
+                struct pipe_surface *dst,
+                unsigned dst_x, unsigned dst_y,
+                struct pipe_surface *src,
+                unsigned src_x, unsigned src_y, 
+                unsigned w, unsigned h)
+{
+   util_surface_copy(pipe, FALSE, dst, dst_x, dst_y, src, src_x, src_y, w, h);
+}
+
+
 static struct st_context *
 st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
 {
@@ -166,6 +180,10 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
    st_init_limits(st);
    st_init_extensions(st);
 
+   /* plug in helper driver functions if needed */
+   if (!pipe->surface_copy)
+      pipe->surface_copy = st_surface_copy;
+
    return st;
 }
 
@@ -215,8 +233,8 @@ static void st_destroy_context_priv( struct st_context *st )
    st_destroy_drawtex(st);
 #endif
 
-   for (i = 0; i < Elements(st->state.sampler_texture); i++) {
-      pipe_texture_reference(&st->state.sampler_texture[i], NULL);
+   for (i = 0; i < Elements(st->state.sampler_views); i++) {
+      pipe_sampler_view_reference(&st->state.sampler_views[i], NULL);
    }
 
    for (i = 0; i < Elements(st->state.constants); i++) {
index e2d34fb3d1015adb39ae02e228ec0ef387257c92..786beaec08b94be1df612905609b33e38491f2a3 100644 (file)
@@ -31,6 +31,7 @@
 #include "main/mtypes.h"
 #include "shader/prog_cache.h"
 #include "pipe/p_state.h"
+#include "state_tracker/st_api.h"
 
 
 struct st_context;
@@ -73,6 +74,8 @@ struct st_tracked_state {
 
 struct st_context
 {
+   struct st_context_iface iface;
+
    GLcontext *ctx;
 
    struct pipe_context *pipe;
@@ -94,7 +97,7 @@ struct st_context
       struct pipe_clip_state clip;
       struct pipe_buffer *constants[2];
       struct pipe_framebuffer_state framebuffer;
-      struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
+      struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
       struct pipe_scissor_state scissor;
       struct pipe_viewport_state viewport;
 
@@ -141,6 +144,7 @@ struct st_context
       struct st_fragment_program *combined_prog;
       GLuint combined_prog_sn;
       struct pipe_texture *pixelmap_texture;
+      struct pipe_sampler_view *pixelmap_sampler_view;
       boolean pixelmap_enabled;  /**< use the pixelmap texture? */
    } pixel_xfer;
 
@@ -206,6 +210,11 @@ struct st_framebuffer
    GLframebuffer Base;
    void *Private;
    GLuint InitWidth, InitHeight;
+
+   struct st_framebuffer_iface *iface;
+   enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
+   unsigned num_statts;
+   int32_t revalidate;
 };
 
 
index 0a91183f89dd3a0d75b04caf9dbc9eefb4196e98..d3c43bbc68a7b180532b380c164021d71a764d12 100644 (file)
@@ -197,6 +197,7 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb,
    /* replace the renderbuffer's surface/texture pointers */
    pipe_surface_reference( &strb->surface, surf );
    pipe_texture_reference( &strb->texture, surf->texture );
+   pipe_sampler_view_reference(&strb->sampler_view, NULL);
 
    if (ctx) {
       /* If ctx isn't set, we've likely not made current yet.
index b2521433c87a57a417c5d7358d96c8763c602a80..030b0a0f0655ce7bbc7d053f15be823504d84acb 100644 (file)
@@ -79,22 +79,23 @@ st_destroy_generate_mipmap(struct st_context *st)
 static boolean
 st_render_mipmap(struct st_context *st,
                  GLenum target,
-                 struct pipe_texture *pt,
+                 struct st_texture_object *stObj,
                  uint baseLevel, uint lastLevel)
 {
    struct pipe_context *pipe = st->pipe;
    struct pipe_screen *screen = pipe->screen;
+   struct pipe_sampler_view *psv = st_get_stobj_sampler_view(stObj);
    const uint face = _mesa_tex_target_to_face(target);
 
    assert(target != GL_TEXTURE_3D); /* not done yet */
 
    /* check if we can render in the texture's format */
-   if (!screen->is_format_supported(screen, pt->format, pt->target,
+   if (!screen->is_format_supported(screen, psv->format, psv->texture->target,
                                     PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
       return FALSE;
    }
 
-   util_gen_mipmap(st->gen_mipmap, pt, face, baseLevel, lastLevel,
+   util_gen_mipmap(st->gen_mipmap, psv, face, baseLevel, lastLevel,
                    PIPE_TEX_FILTER_LINEAR);
 
    return TRUE;
@@ -211,6 +212,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
                    struct gl_texture_object *texObj)
 {
    struct st_context *st = ctx->st;
+   struct st_texture_object *stObj = st_texture_object(texObj);
    struct pipe_texture *pt = st_get_texobj_texture(texObj);
    const uint baseLevel = texObj->BaseLevel;
    uint lastLevel;
@@ -229,7 +231,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
       /* The current gallium texture doesn't have space for all the
        * mipmap levels we need to generate.  So allocate a new texture.
        */
-      struct st_texture_object *stObj = st_texture_object(texObj);
       struct pipe_texture *oldTex = stObj->pt;
       GLboolean needFlush;
 
@@ -255,6 +256,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
 
       /* release the old tex (will likely be freed too) */
       pipe_texture_reference(&oldTex, NULL);
+      pipe_sampler_view_reference(&stObj->sampler_view, NULL);
 
       pt = stObj->pt;
    }
@@ -264,7 +266,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
    /* Recall that the Mesa BaseLevel image is stored in the gallium
     * texture's level[0] position.  So pass baseLevel=0 here.
     */
-   if (!st_render_mipmap(st, target, pt, 0, lastLevel)) {
+   if (!st_render_mipmap(st, target, stObj, 0, lastLevel)) {
       fallback_generate_mipmap(ctx, target, texObj);
    }
 
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
new file mode 100644 (file)
index 0000000..cac62e4
--- /dev/null
@@ -0,0 +1,802 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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 "state_tracker/st_api.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_screen.h"
+#include "util/u_format.h"
+#include "util/u_pointer.h"
+#include "util/u_inlines.h"
+#include "util/u_atomic.h"
+
+#include "main/mtypes.h"
+#include "main/context.h"
+#include "main/texobj.h"
+#include "main/teximage.h"
+#include "main/texstate.h"
+#include "main/texfetch.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "st_texture.h"
+
+#include "st_context.h"
+#include "st_format.h"
+#include "st_cb_fbo.h"
+#include "st_manager.h"
+
+/* these functions are defined in st_context.c */
+struct st_context *
+st_create_context(struct pipe_context *pipe,
+                  const __GLcontextModes *visual,
+                  struct st_context *share);
+void st_destroy_context(struct st_context *st);
+void st_flush(struct st_context *st, uint pipeFlushFlags,
+              struct pipe_fence_handle **fence);
+
+/**
+ * Cast wrapper to convert a GLframebuffer to an st_framebuffer.
+ * Return NULL if the GLframebuffer is a user-created framebuffer.
+ * We'll only return non-null for window system framebuffers.
+ * Note that this function may fail.
+ */
+static INLINE struct st_framebuffer *
+st_ws_framebuffer(GLframebuffer *fb)
+{
+   /* FBO cannot be casted.  See st_new_framebuffer */
+   return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL);
+}
+
+/**
+ * Map an attachment to a buffer index.
+ */
+static INLINE gl_buffer_index
+attachment_to_buffer_index(enum st_attachment_type statt)
+{
+   gl_buffer_index index;
+
+   switch (statt) {
+   case ST_ATTACHMENT_FRONT_LEFT:
+      index = BUFFER_FRONT_LEFT;
+      break;
+   case ST_ATTACHMENT_BACK_LEFT:
+      index = BUFFER_BACK_LEFT;
+      break;
+   case ST_ATTACHMENT_FRONT_RIGHT:
+      index = BUFFER_FRONT_RIGHT;
+      break;
+   case ST_ATTACHMENT_BACK_RIGHT:
+      index = BUFFER_BACK_RIGHT;
+      break;
+   case ST_ATTACHMENT_DEPTH_STENCIL:
+      index = BUFFER_DEPTH;
+      break;
+   case ST_ATTACHMENT_ACCUM:
+      index = BUFFER_ACCUM;
+      break;
+   case ST_ATTACHMENT_SAMPLE:
+   default:
+      index = BUFFER_COUNT;
+      break;
+   }
+
+   return index;
+}
+
+/**
+ * Map a buffer index to an attachment.
+ */
+static INLINE enum st_attachment_type
+buffer_index_to_attachment(gl_buffer_index index)
+{
+   enum st_attachment_type statt;
+
+   switch (index) {
+   case BUFFER_FRONT_LEFT:
+      statt = ST_ATTACHMENT_FRONT_LEFT;
+      break;
+   case BUFFER_BACK_LEFT:
+      statt = ST_ATTACHMENT_BACK_LEFT;
+      break;
+   case BUFFER_FRONT_RIGHT:
+      statt = ST_ATTACHMENT_FRONT_RIGHT;
+      break;
+   case BUFFER_BACK_RIGHT:
+      statt = ST_ATTACHMENT_BACK_RIGHT;
+      break;
+   case BUFFER_DEPTH:
+      statt = ST_ATTACHMENT_DEPTH_STENCIL;
+      break;
+   case BUFFER_ACCUM:
+      statt = ST_ATTACHMENT_ACCUM;
+      break;
+   default:
+      statt = ST_ATTACHMENT_INVALID;
+      break;
+   }
+
+   return statt;
+}
+
+/**
+ * Validate a framebuffer to make sure up-to-date pipe_textures are used.
+ */
+static void
+st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
+{
+   struct pipe_screen *screen = st->pipe->screen;
+   struct pipe_texture *textures[ST_ATTACHMENT_COUNT];
+   uint width, height;
+   unsigned i;
+   boolean changed = FALSE;
+
+   if (!p_atomic_read(&stfb->revalidate))
+      return;
+
+   /* validate the fb */
+   if (!stfb->iface->validate(stfb->iface, stfb->statts, stfb->num_statts, textures))
+      return;
+
+   width = stfb->Base.Width;
+   height = stfb->Base.Height;
+
+   for (i = 0; i < stfb->num_statts; i++) {
+      struct st_renderbuffer *strb;
+      struct pipe_surface *ps;
+      gl_buffer_index idx;
+
+      if (!textures[i])
+         continue;
+
+      idx = attachment_to_buffer_index(stfb->statts[i]);
+      if (idx >= BUFFER_COUNT) {
+         pipe_texture_reference(&textures[i], NULL);
+         continue;
+      }
+
+      strb = st_renderbuffer(stfb->Base.Attachment[idx].Renderbuffer);
+      assert(strb);
+      if (strb->texture == textures[i]) {
+         pipe_texture_reference(&textures[i], NULL);
+         continue;
+      }
+
+      ps = screen->get_tex_surface(screen, textures[i], 0, 0, 0,
+            PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE);
+      if (ps) {
+         pipe_surface_reference(&strb->surface, ps);
+         pipe_texture_reference(&strb->texture, ps->texture);
+         /* ownership transfered */
+         pipe_surface_reference(&ps, NULL);
+
+         changed = TRUE;
+
+         strb->Base.Width = strb->surface->width;
+         strb->Base.Height = strb->surface->height;
+
+         width = strb->Base.Width;
+         height = strb->Base.Height;
+      }
+
+      pipe_texture_reference(&textures[i], NULL);
+   }
+
+   if (changed) {
+      st->dirty.st |= ST_NEW_FRAMEBUFFER;
+      _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);
+}
+
+/**
+ * Update the attachments to validate by looping the existing renderbuffers.
+ */
+static void
+st_framebuffer_update_attachments(struct st_framebuffer *stfb)
+{
+   gl_buffer_index idx;
+
+   stfb->num_statts = 0;
+   for (idx = 0; idx < BUFFER_COUNT; idx++) {
+      struct st_renderbuffer *strb;
+      enum st_attachment_type statt;
+
+      strb = st_renderbuffer(stfb->Base.Attachment[idx].Renderbuffer);
+      if (!strb || strb->software)
+         continue;
+
+      statt = buffer_index_to_attachment(idx);
+      if (statt != ST_ATTACHMENT_INVALID &&
+          st_visual_have_buffers(stfb->iface->visual, 1 << statt))
+         stfb->statts[stfb->num_statts++] = statt;
+   }
+
+   p_atomic_set(&stfb->revalidate, TRUE);
+}
+
+/**
+ * Add a renderbuffer to the framebuffer.
+ */
+static boolean
+st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
+                                gl_buffer_index idx)
+{
+   struct gl_renderbuffer *rb;
+   enum pipe_format format;
+   int samples;
+   boolean sw;
+
+   /* do not distinguish depth/stencil buffers */
+   if (idx == BUFFER_STENCIL)
+      idx = BUFFER_DEPTH;
+
+   switch (idx) {
+   case BUFFER_DEPTH:
+      format = stfb->iface->visual->depth_stencil_format;
+      sw = FALSE;
+      break;
+   case BUFFER_ACCUM:
+      format = stfb->iface->visual->accum_format;
+      sw = TRUE;
+      break;
+   default:
+      format = stfb->iface->visual->color_format;
+      sw = FALSE;
+      break;
+   }
+
+   if (format == PIPE_FORMAT_NONE)
+      return FALSE;
+
+   samples = stfb->iface->visual->samples;
+   if (!samples)
+      samples = st_get_msaa();
+
+   rb = st_new_renderbuffer_fb(format, samples, sw);
+   if (!rb)
+      return FALSE;
+
+   if (idx != BUFFER_DEPTH) {
+      _mesa_add_renderbuffer(&stfb->Base, idx, rb);
+   }
+   else {
+      if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0))
+         _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, rb);
+      if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1))
+         _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb);
+   }
+
+   return TRUE;
+}
+
+/**
+ * Intialize a __GLcontextModes from a visual.
+ */
+static void
+st_visual_to_context_mode(const struct st_visual *visual,
+                          __GLcontextModes *mode)
+{
+   memset(mode, 0, sizeof(*mode));
+
+   if (st_visual_have_buffers(visual, ST_ATTACHMENT_BACK_LEFT_MASK))
+      mode->doubleBufferMode = GL_TRUE;
+   if (st_visual_have_buffers(visual,
+            ST_ATTACHMENT_FRONT_RIGHT_MASK | ST_ATTACHMENT_BACK_RIGHT_MASK))
+      mode->stereoMode = GL_TRUE;
+
+   if (visual->color_format != PIPE_FORMAT_NONE) {
+      mode->rgbMode = GL_TRUE;
+
+      mode->redBits =
+         util_format_get_component_bits(visual->color_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 0);
+      mode->greenBits =
+         util_format_get_component_bits(visual->color_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 1);
+      mode->blueBits =
+         util_format_get_component_bits(visual->color_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 2);
+      mode->alphaBits =
+         util_format_get_component_bits(visual->color_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 3);
+
+      mode->rgbBits = mode->redBits +
+         mode->greenBits + mode->blueBits + mode->alphaBits;
+   }
+
+   if (visual->depth_stencil_format != PIPE_FORMAT_NONE) {
+      mode->depthBits =
+         util_format_get_component_bits(visual->depth_stencil_format,
+               UTIL_FORMAT_COLORSPACE_ZS, 0);
+      mode->stencilBits =
+         util_format_get_component_bits(visual->depth_stencil_format,
+               UTIL_FORMAT_COLORSPACE_ZS, 1);
+
+      mode->haveDepthBuffer = mode->depthBits > 0;
+      mode->haveStencilBuffer = mode->stencilBits > 0;
+   }
+
+   if (visual->accum_format != PIPE_FORMAT_NONE) {
+      mode->haveAccumBuffer = GL_TRUE;
+
+      mode->accumRedBits =
+         util_format_get_component_bits(visual->accum_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 0);
+      mode->accumGreenBits =
+         util_format_get_component_bits(visual->accum_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 1);
+      mode->accumBlueBits =
+         util_format_get_component_bits(visual->accum_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 2);
+      mode->accumAlphaBits =
+         util_format_get_component_bits(visual->accum_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 3);
+   }
+
+   if (visual->samples) {
+      mode->sampleBuffers = 1;
+      mode->samples = visual->samples;
+   }
+}
+
+/**
+ * Determine the default draw or read buffer from a visual.
+ */
+static void
+st_visual_to_default_buffer(const struct st_visual *visual,
+                            GLenum *buffer, GLint *index)
+{
+   enum st_attachment_type statt;
+   GLenum buf;
+   gl_buffer_index idx;
+
+   statt = visual->render_buffer;
+   /* do nothing if an invalid render buffer is specified */
+   if (statt == ST_ATTACHMENT_INVALID ||
+       !st_visual_have_buffers(visual, 1 << statt))
+      return;
+
+   switch (statt) {
+   case ST_ATTACHMENT_FRONT_LEFT:
+      buf = GL_FRONT_LEFT;
+      idx = BUFFER_FRONT_LEFT;
+      break;
+   case ST_ATTACHMENT_BACK_LEFT:
+      buf = GL_BACK_LEFT;
+      idx = BUFFER_BACK_LEFT;
+      break;
+   case ST_ATTACHMENT_FRONT_RIGHT:
+      buf = GL_FRONT_RIGHT;
+      idx = BUFFER_FRONT_RIGHT;
+      break;
+   case ST_ATTACHMENT_BACK_RIGHT:
+      buf = GL_BACK_RIGHT;
+      idx = BUFFER_BACK_RIGHT;
+      break;
+   default:
+      buf = GL_NONE;
+      idx = BUFFER_COUNT;
+      break;
+   }
+
+   if (buf != GL_NONE) {
+      if (buffer)
+         *buffer = buf;
+      if (index)
+         *index = idx;
+   }
+}
+
+/**
+ * Create a framebuffer from a manager interface.
+ */
+static struct st_framebuffer *
+st_framebuffer_create(struct st_framebuffer_iface *stfbi)
+{
+   struct st_framebuffer *stfb;
+   __GLcontextModes mode;
+   gl_buffer_index idx;
+
+   stfb = CALLOC_STRUCT(st_framebuffer);
+   if (!stfb)
+      return NULL;
+
+   st_visual_to_context_mode(stfbi->visual, &mode);
+   _mesa_initialize_window_framebuffer(&stfb->Base, &mode);
+
+   /* modify the draw/read buffers of the fb */
+   st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorDrawBuffer[0],
+         &stfb->Base._ColorDrawBufferIndexes[0]);
+   st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorReadBuffer,
+         &stfb->Base._ColorReadBufferIndex);
+
+   stfb->iface = stfbi;
+
+   /* add the color buffer */
+   idx = stfb->Base._ColorDrawBufferIndexes[0];
+   if (!st_framebuffer_add_renderbuffer(stfb, idx)) {
+      FREE(stfb);
+      return NULL;
+   }
+
+   st_framebuffer_add_renderbuffer(stfb, BUFFER_DEPTH);
+   st_framebuffer_add_renderbuffer(stfb, BUFFER_ACCUM);
+
+   st_framebuffer_update_attachments(stfb);
+
+   stfb->Base.Initialized = GL_TRUE;
+
+   return stfb;
+}
+
+/**
+ * Reference a framebuffer.
+ */
+static void
+st_framebuffer_reference(struct st_framebuffer **ptr,
+                         struct st_framebuffer *stfb)
+{
+   GLframebuffer *fb = &stfb->Base;
+   _mesa_reference_framebuffer((GLframebuffer **) ptr, fb);
+}
+
+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);
+   assert(stfb && stfb->iface == stfbi);
+
+   p_atomic_set(&stfb->revalidate, TRUE);
+}
+
+static void
+st_context_flush(struct st_context_iface *stctxi, unsigned flags,
+                 struct pipe_fence_handle **fence)
+{
+   struct st_context *st = (struct st_context *) stctxi;
+   st_flush(st, flags, fence);
+   if (flags & PIPE_FLUSH_RENDER_CACHE)
+      st_manager_flush_frontbuffer(st);
+}
+
+static boolean
+st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target,
+                    int level, enum pipe_format internal_format,
+                    struct pipe_texture *tex, boolean mipmap)
+{
+   struct st_context *st = (struct st_context *) stctxi;
+   GLcontext *ctx = st->ctx;
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+   struct gl_texture_object *texObj;
+   struct gl_texture_image *texImage;
+   struct st_texture_object *stObj;
+   struct st_texture_image *stImage;
+   GLenum internalFormat;
+
+   switch (target) {
+   case ST_TEXTURE_1D:
+      target = GL_TEXTURE_1D;
+      break;
+   case ST_TEXTURE_2D:
+      target = GL_TEXTURE_2D;
+      break;
+   case ST_TEXTURE_3D:
+      target = GL_TEXTURE_3D;
+      break;
+   case ST_TEXTURE_RECT:
+      target = GL_TEXTURE_RECTANGLE_ARB;
+      break;
+   default:
+      return FALSE;
+      break;
+   }
+
+   if (util_format_get_component_bits(internal_format,
+            UTIL_FORMAT_COLORSPACE_RGB, 3) > 0)
+      internalFormat = GL_RGBA;
+   else
+      internalFormat = GL_RGB;
+
+   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+   _mesa_lock_texture(ctx, texObj);
+
+   stObj = st_texture_object(texObj);
+   /* switch to surface based */
+   if (!stObj->surface_based) {
+      _mesa_clear_texture_object(ctx, texObj);
+      stObj->surface_based = GL_TRUE;
+   }
+
+   texImage = _mesa_get_tex_image(ctx, texObj, target, level);
+   stImage = st_texture_image(texImage);
+   if (tex) {
+      _mesa_init_teximage_fields(ctx, target, texImage,
+            tex->width0, tex->height0, 1, 0, internalFormat);
+      texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
+            GL_RGBA, GL_UNSIGNED_BYTE);
+      _mesa_set_fetch_functions(texImage, 2);
+   }
+   else {
+      _mesa_clear_texture_image(ctx, texImage);
+   }
+
+   stObj->pipe = st->pipe;
+   pipe_texture_reference(&stImage->pt, tex);
+
+   _mesa_dirty_texobj(ctx, texObj, GL_TRUE);
+   _mesa_unlock_texture(ctx, texObj);
+   
+   return TRUE;
+}
+
+static void
+st_context_destroy(struct st_context_iface *stctxi)
+{
+   struct st_context *st = (struct st_context *) stctxi;
+   st_destroy_context(st);
+}
+
+static struct st_context_iface *
+st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
+                      const struct st_visual *visual,
+                      struct st_context_iface *shared_stctxi)
+{
+   struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
+   struct st_context *st;
+   struct pipe_context *pipe;
+   __GLcontextModes mode;
+
+   pipe = smapi->screen->context_create(smapi->screen, NULL);
+   if (!pipe)
+      return NULL;
+
+   st_visual_to_context_mode(visual, &mode);
+   st = st_create_context(pipe, &mode, shared_ctx);
+   if (!st) {
+      pipe->destroy(pipe);
+      return NULL;
+   }
+
+   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 = NULL;
+
+   st->iface.st_context_private = (void *) smapi;
+
+   return &st->iface;
+}
+
+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;
+   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);
+      }
+      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);
+      }
+
+      if (stdraw && stread) {
+         st_framebuffer_validate(stdraw, st);
+         if (stread != stdraw)
+            st_framebuffer_validate(stread, st);
+
+         /* modify the draw/read buffers of the context */
+         st_visual_to_default_buffer(stdraw->iface->visual,
+               &st->ctx->Color.DrawBuffer[0], NULL);
+         st_visual_to_default_buffer(stread->iface->visual,
+               &st->ctx->Pixel.ReadBuffer, NULL);
+
+         ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base);
+      }
+      else {
+         ret = FALSE;
+      }
+
+      st_framebuffer_reference(&stdraw, NULL);
+      st_framebuffer_reference(&stread, NULL);
+   }
+   else {
+      ret = _mesa_make_current(NULL, NULL, NULL);
+   }
+
+   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 boolean
+st_api_is_visual_supported(struct st_api *stapi,
+                           const struct st_visual *visual)
+{
+   return TRUE;
+}
+
+static st_proc_t
+st_api_get_proc_address(struct st_api *stapi, const char *procname)
+{
+   return (st_proc_t) _glapi_get_proc_address(procname);
+}
+
+static void
+st_api_destroy(struct st_api *stapi)
+{
+   FREE(stapi);
+}
+
+/**
+ * Flush the front buffer if the current context renders to the front buffer.
+ */
+void
+st_manager_flush_frontbuffer(struct st_context *st)
+{
+   struct st_framebuffer *stfb = st_ws_framebuffer(st->ctx->DrawBuffer);
+   struct st_renderbuffer *strb = NULL;
+
+   if (stfb)
+      strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+   if (!strb)
+      return;
+
+   /* st_public.h */
+   if (!stfb->iface) {
+      struct pipe_surface *front_surf = strb->surface;
+      st->pipe->screen->flush_frontbuffer(st->pipe->screen,
+            front_surf, st->winsys_drawable_handle);
+      return;
+   }
+
+   stfb->iface->flush_front(stfb->iface, ST_ATTACHMENT_FRONT_LEFT);
+}
+
+/**
+ * Re-validate the framebuffers.
+ */
+void
+st_manager_validate_framebuffers(struct st_context *st)
+{
+   struct st_framebuffer *stdraw = st_ws_framebuffer(st->ctx->DrawBuffer);
+   struct st_framebuffer *stread = st_ws_framebuffer(st->ctx->ReadBuffer);
+
+   /* st_public.h */
+   if ((stdraw && !stdraw->iface) || (stread && !stread->iface)) {
+      struct pipe_screen *screen = st->pipe->screen;
+      if (screen->update_buffer)
+         screen->update_buffer(screen, st->pipe->priv);
+      return;
+   }
+
+   if (stdraw)
+      st_framebuffer_validate(stdraw, st);
+   if (stread && stread != stdraw)
+      st_framebuffer_validate(stread, st);
+}
+
+/**
+ * Add a color renderbuffer on demand.
+ */
+boolean
+st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb,
+                                  gl_buffer_index idx)
+{
+   struct st_framebuffer *stfb = st_ws_framebuffer(fb);
+
+   /* FBO or st_public.h */
+   if (!stfb || !stfb->iface)
+      return FALSE;
+
+   if (stfb->Base.Attachment[idx].Renderbuffer)
+      return TRUE;
+
+   switch (idx) {
+   case BUFFER_FRONT_LEFT:
+   case BUFFER_BACK_LEFT:
+   case BUFFER_FRONT_RIGHT:
+   case BUFFER_BACK_RIGHT:
+      break;
+   default:
+      return FALSE;
+      break;
+   }
+
+   if (!st_framebuffer_add_renderbuffer(stfb, idx))
+      return FALSE;
+
+   st_framebuffer_update_attachments(stfb);
+   st_invalidate_state(st->ctx, _NEW_BUFFERS);
+
+   return TRUE;
+}
+
+/**
+ * Create an st_api to manage the state tracker.
+ */
+struct st_api *
+st_manager_create_api(void)
+{
+   struct st_api *stapi;
+
+   stapi = CALLOC_STRUCT(st_api);
+   if (stapi) {
+      stapi->destroy = st_api_destroy;
+      stapi->get_proc_address = st_api_get_proc_address;
+      stapi->is_visual_supported = st_api_is_visual_supported;
+
+      stapi->create_context = st_api_create_context;
+      stapi->make_current = st_api_make_current;
+      stapi->get_current = st_api_get_current;
+   }
+
+   return stapi;
+}
diff --git a/src/mesa/state_tracker/st_manager.h b/src/mesa/state_tracker/st_manager.h
new file mode 100644 (file)
index 0000000..a3f5199
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF 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>
+ */
+
+#ifndef ST_MANAGER_H
+#define ST_MANAGER_H
+
+#include "state_tracker/st_api.h"
+#include "st_context.h"
+
+void
+st_manager_flush_frontbuffer(struct st_context *st);
+
+void
+st_manager_validate_framebuffers(struct st_context *st);
+
+boolean
+st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb,
+                                  gl_buffer_index idx);
+
+struct st_api *
+st_manager_create_api(void);
+
+#endif /* ST_MANAGER_H */
index 10a38befb41548484d2dc2db02244c4dcd0e5777..5809927852d4a87e6cd794bba6fa876ab0ab3229 100644 (file)
@@ -342,21 +342,12 @@ st_texture_image_copy(struct pipe_context *pipe,
       src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
                                             PIPE_BUFFER_USAGE_GPU_READ);
 
-      if (pipe->surface_copy) {
-         pipe->surface_copy(pipe,
-                           dst_surface,
-                           0, 0, /* destX, Y */
-                           src_surface,
-                           0, 0, /* srcX, Y */
-                           width, height);
-      } else {
-         util_surface_copy(pipe, FALSE,
-                          dst_surface,
-                          0, 0, /* destX, Y */
-                          src_surface,
-                          0, 0, /* srcX, Y */
-                          width, height);
-      }
+      pipe->surface_copy(pipe,
+                         dst_surface,
+                         0, 0, /* destX, Y */
+                         src_surface,
+                         0, 0, /* srcX, Y */
+                         width, height);
 
       pipe_surface_reference(&src_surface, NULL);
       pipe_surface_reference(&dst_surface, NULL);
@@ -528,14 +519,21 @@ st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex,
    /* save the renderbuffer's surface/texture info */
    pipe_texture_reference(&strb->texture_save, strb->texture);
    pipe_surface_reference(&strb->surface_save, strb->surface);
+   pipe_sampler_view_reference(&strb->sampler_view_save, strb->sampler_view);
 
    /* plug in new surface/texture info */
    pipe_texture_reference(&strb->texture, stImage->pt);
+
+   /* XXX: Shouldn't we release reference to old surface here?
+    */
+
    strb->surface = screen->get_tex_surface(screen, strb->texture,
                                            face, level, slice,
                                            (PIPE_BUFFER_USAGE_GPU_READ |
                                             PIPE_BUFFER_USAGE_GPU_WRITE));
 
+   pipe_sampler_view_reference(&strb->sampler_view, NULL);
+
    st->dirty.st |= ST_NEW_FRAMEBUFFER;
 
    return 1;
@@ -565,9 +563,11 @@ st_release_teximage(struct st_framebuffer *stfb, uint surfIndex,
    /* free tex surface, restore original */
    pipe_surface_reference(&strb->surface, strb->surface_save);
    pipe_texture_reference(&strb->texture, strb->texture_save);
+   pipe_sampler_view_reference(&strb->sampler_view, strb->sampler_view_save);
 
    pipe_surface_reference(&strb->surface_save, NULL);
    pipe_texture_reference(&strb->texture_save, NULL);
+   pipe_sampler_view_reference(&strb->sampler_view, NULL);
 
    st->dirty.st |= ST_NEW_FRAMEBUFFER;
 
index 60868ce06738917d7c32665b489f70c4b40cd4a1..c62f7f2cc0d172834e519f3bddee0a72c08e5c35 100644 (file)
@@ -29,6 +29,9 @@
 #define ST_TEXTURE_H
 
 
+#include "pipe/p_context.h"
+#include "util/u_sampler.h"
+
 #include "main/mtypes.h"
 
 struct pipe_context;
@@ -68,6 +71,13 @@ struct st_texture_object
     */
    struct pipe_texture *pt;
 
+   /* Default sampler view attached to this texture object. Created lazily
+    * on first binding.
+    */
+   struct pipe_sampler_view *sampler_view;
+
+   struct pipe_context *pipe;
+
    GLboolean teximage_realloc;
 
    /* True if there is/was a surface bound to this texture object.  It helps
@@ -105,6 +115,35 @@ st_get_stobj_texture(struct st_texture_object *stObj)
 }
 
 
+static INLINE struct pipe_sampler_view *
+st_sampler_view_from_texture(struct pipe_context *pipe,
+                             struct pipe_texture *texture)
+{
+   struct pipe_sampler_view templ;
+
+   u_sampler_view_default_template(&templ,
+                                   texture,
+                                   texture->format);
+
+   return pipe->create_sampler_view(pipe, texture, &templ);
+}
+
+
+static INLINE struct pipe_sampler_view *
+st_get_stobj_sampler_view(struct st_texture_object *stObj)
+{
+   if (!stObj || !stObj->pt) {
+      return NULL;
+   }
+
+   if (!stObj->sampler_view) {
+      stObj->sampler_view = st_sampler_view_from_texture(stObj->pipe, stObj->pt);
+   }
+
+   return stObj->sampler_view;
+}
+
+
 extern struct pipe_texture *
 st_texture_create(struct st_context *st,
                   enum pipe_texture_target target,
index fe3338ecef888e93eb7973471e9a0be9e890845a..1d90f322a3a81bee7bf2a47d675df51c3cfc660b 100644 (file)
@@ -268,88 +268,6 @@ compute_coveragef(const GLfloat v0[3], const GLfloat v1[3],
 
 
 
-/*
- * Compute how much (area) of the given pixel is inside the triangle.
- * Vertices MUST be specified in counter-clockwise order.
- * Return:  coverage in [0, 15].
- */
-static GLint
-compute_coveragei(const GLfloat v0[3], const GLfloat v1[3],
-                  const GLfloat v2[3], GLint winx, GLint winy)
-{
-   /* NOTE: 15 samples instead of 16. */
-   static const GLfloat samples[15][2] = {
-      /* start with the four corners */
-      { POS(0, 2), POS(0, 0) },
-      { POS(3, 3), POS(0, 2) },
-      { POS(0, 0), POS(3, 1) },
-      { POS(3, 1), POS(3, 3) },
-      /* continue with interior samples */
-      { POS(1, 1), POS(0, 1) },
-      { POS(2, 0), POS(0, 3) },
-      { POS(0, 3), POS(1, 3) },
-      { POS(1, 2), POS(1, 0) },
-      { POS(2, 3), POS(1, 2) },
-      { POS(3, 2), POS(1, 1) },
-      { POS(0, 1), POS(2, 2) },
-      { POS(1, 0), POS(2, 1) },
-      { POS(2, 1), POS(2, 3) },
-      { POS(3, 0), POS(2, 0) },
-      { POS(1, 3), POS(3, 0) }
-   };
-   const GLfloat x = (GLfloat) winx;
-   const GLfloat y = (GLfloat) winy;
-   const GLfloat dx0 = v1[0] - v0[0];
-   const GLfloat dy0 = v1[1] - v0[1];
-   const GLfloat dx1 = v2[0] - v1[0];
-   const GLfloat dy1 = v2[1] - v1[1];
-   const GLfloat dx2 = v0[0] - v2[0];
-   const GLfloat dy2 = v0[1] - v2[1];
-   GLint stop = 4, i;
-   GLint insideCount = 15;
-
-#ifdef DEBUG
-   {
-      const GLfloat area = dx0 * dy1 - dx1 * dy0;
-      ASSERT(area >= 0.0);
-   }
-#endif
-
-   for (i = 0; i < stop; i++) {
-      const GLfloat sx = x + samples[i][0];
-      const GLfloat sy = y + samples[i][1];
-      const GLfloat fx0 = sx - v0[0];
-      const GLfloat fy0 = sy - v0[1];
-      const GLfloat fx1 = sx - v1[0];
-      const GLfloat fy1 = sy - v1[1];
-      const GLfloat fx2 = sx - v2[0];
-      const GLfloat fy2 = sy - v2[1];
-      /* cross product determines if sample is inside or outside each edge */
-      GLfloat cross0 = (dx0 * fy0 - dy0 * fx0);
-      GLfloat cross1 = (dx1 * fy1 - dy1 * fx1);
-      GLfloat cross2 = (dx2 * fy2 - dy2 * fx2);
-      /* Check if the sample is exactly on an edge.  If so, let cross be a
-       * positive or negative value depending on the direction of the edge.
-       */
-      if (cross0 == 0.0F)
-         cross0 = dx0 + dy0;
-      if (cross1 == 0.0F)
-         cross1 = dx1 + dy1;
-      if (cross2 == 0.0F)
-         cross2 = dx2 + dy2;
-      if (cross0 < 0.0F || cross1 < 0.0F || cross2 < 0.0F) {
-         /* point is outside triangle */
-         insideCount--;
-         stop = 15;
-      }
-   }
-   if (stop == 4)
-      return 15;
-   else
-      return insideCount;
-}
-
-
 static void
 rgba_aa_tri(GLcontext *ctx,
            const SWvertex *v0,
index 7b0a63391fa26fb81fc26e2b67f9194b4c67c8dd..efe500ae2b151acc0d2d865b21adf45b3f3f533c 100644 (file)
@@ -25,7 +25,6 @@
 #include "main/glheader.h"
 #include "main/colormac.h"
 #include "main/condrender.h"
-#include "main/formats.h"
 #include "main/macros.h"
 #include "main/imports.h"
 #include "main/mtypes.h"
index 997c2f4bb79c5c443ed008be194f640c056a1414..3fc554c5a2050c85672a6ca95ae60147522853ba 100644 (file)
@@ -488,14 +488,15 @@ tex_array_slice(GLfloat coord, GLsizei size)
 
 /**
  * Compute nearest integer texcoords for given texobj and coordinate.
+ * NOTE: only used for depth texture sampling.
  */
 static INLINE void
 nearest_texcoord(const struct gl_texture_object *texObj,
+                 GLuint level,
                  const GLfloat texcoord[4],
                  GLint *i, GLint *j, GLint *k)
 {
-   const GLint baseLevel = texObj->BaseLevel;
-   const struct gl_texture_image *img = texObj->Image[0][baseLevel];
+   const struct gl_texture_image *img = texObj->Image[0][level];
    const GLint width = img->Width;
    const GLint height = img->Height;
    const GLint depth = img->Depth;
@@ -534,15 +535,16 @@ nearest_texcoord(const struct gl_texture_object *texObj,
 
 /**
  * Compute linear integer texcoords for given texobj and coordinate.
+ * NOTE: only used for depth texture sampling.
  */
 static INLINE void
 linear_texcoord(const struct gl_texture_object *texObj,
+                GLuint level,
                 const GLfloat texcoord[4],
                 GLint *i0, GLint *i1, GLint *j0, GLint *j1, GLint *slice,
                 GLfloat *wi, GLfloat *wj)
 {
-   const GLint baseLevel = texObj->BaseLevel;
-   const struct gl_texture_image *img = texObj->Image[0][baseLevel];
+   const struct gl_texture_image *img = texObj->Image[0][level];
    const GLint width = img->Width;
    const GLint height = img->Height;
    const GLint depth = img->Depth;
@@ -2963,7 +2965,26 @@ shadow_compare4(GLenum function, GLfloat coord,
 
 
 /**
- * Sample a shadow/depth texture.
+ * Choose the mipmap level to use when sampling from a depth texture.
+ */
+static int
+choose_depth_texture_level(const struct gl_texture_object *tObj, GLfloat lambda)
+{
+   GLint level;
+
+   lambda = CLAMP(lambda, tObj->MinLod, tObj->MaxLod);
+
+   level = (GLint) lambda;
+
+   level = CLAMP(level, tObj->BaseLevel, tObj->_MaxLevel);
+
+   return level;
+}
+
+
+/**
+ * Sample a shadow/depth texture.  This function is incomplete.  It doesn't
+ * check for minification vs. magnification, etc.
  */
 static void
 sample_depth_texture( GLcontext *ctx,
@@ -2971,8 +2992,8 @@ sample_depth_texture( GLcontext *ctx,
                       const GLfloat texcoords[][4], const GLfloat lambda[],
                       GLfloat texel[][4] )
 {
-   const GLint baseLevel = tObj->BaseLevel;
-   const struct gl_texture_image *img = tObj->Image[0][baseLevel];
+   const GLint level = choose_depth_texture_level(tObj, lambda[0]);
+   const struct gl_texture_image *img = tObj->Image[0][level];
    const GLint width = img->Width;
    const GLint height = img->Height;
    const GLint depth = img->Depth;
@@ -2982,8 +3003,6 @@ sample_depth_texture( GLcontext *ctx,
    GLenum function;
    GLfloat result;
 
-   (void) lambda;
-
    ASSERT(img->_BaseFormat == GL_DEPTH_COMPONENT ||
           img->_BaseFormat == GL_DEPTH_STENCIL_EXT);
 
@@ -3006,7 +3025,7 @@ sample_depth_texture( GLcontext *ctx,
          GLfloat depthSample;
          GLint col, row, slice;
 
-         nearest_texcoord(tObj, texcoords[i], &col, &row, &slice);
+         nearest_texcoord(tObj, level, texcoords[i], &col, &row, &slice);
 
          if (col >= 0 && row >= 0 && col < width && row < height && 
              slice >= 0 && slice < depth) {
@@ -3044,7 +3063,7 @@ sample_depth_texture( GLcontext *ctx,
          GLfloat wi, wj;
          GLuint useBorderTexel;
 
-         linear_texcoord(tObj, texcoords[i], &i0, &i1, &j0, &j1, &slice,
+         linear_texcoord(tObj, level, texcoords[i], &i0, &i1, &j0, &j1, &slice,
                          &wi, &wj);
 
          useBorderTexel = 0;
index bce401744dae7509ab8d00877aa82267a8de8721..2ec7d9b0fe39a7ff6b4a5f702e4cc56c4d2c5ebc 100644 (file)
@@ -196,7 +196,7 @@ flush( struct copy_context *copy )
               &copy->dstib,
               GL_TRUE,
               0,
-              copy->dstbuf_nr );
+              copy->dstbuf_nr - 1 );
 
    /* Reset all pointers: 
     */
index a7dd8d72186933cc34ab7e31e776f920af43168d..b1730d25a0d4e4aa46dccf4ca848318e8b2d2d13 100644 (file)
@@ -1022,74 +1022,16 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB_ALIAS(BlendColorEXT, _gloffset_BlendColor, BlendColorEXT@16, BlendColor, BlendColor@16)
        GL_STUB_ALIAS(BlendEquationEXT, _gloffset_BlendEquation, BlendEquationEXT@4, BlendEquation, BlendEquation@4)
        GL_STUB_ALIAS(DrawRangeElementsEXT, _gloffset_DrawRangeElements, DrawRangeElementsEXT@24, DrawRangeElements, DrawRangeElements@24)
-       GL_STUB_ALIAS(ColorTableSGI, _gloffset_ColorTable, ColorTableSGI@24, ColorTable, ColorTable@24)
        GL_STUB_ALIAS(ColorTableEXT, _gloffset_ColorTable, ColorTableEXT@24, ColorTable, ColorTable@24)
-       GL_STUB_ALIAS(ColorTableParameterfvSGI, _gloffset_ColorTableParameterfv, ColorTableParameterfvSGI@12, ColorTableParameterfv, ColorTableParameterfv@12)
-       GL_STUB_ALIAS(ColorTableParameterivSGI, _gloffset_ColorTableParameteriv, ColorTableParameterivSGI@12, ColorTableParameteriv, ColorTableParameteriv@12)
-       GL_STUB_ALIAS(CopyColorTableSGI, _gloffset_CopyColorTable, CopyColorTableSGI@20, CopyColorTable, CopyColorTable@20)
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetColorTableSGI, _gloffset_GetColorTable, GetColorTableSGI@16, GetColorTable, GetColorTable@16)
-#endif
 #ifndef GLX_INDIRECT_RENDERING
        GL_STUB_ALIAS(GetColorTableEXT, _gloffset_GetColorTable, GetColorTableEXT@16, GetColorTable, GetColorTable@16)
 #endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetColorTableParameterfvSGI, _gloffset_GetColorTableParameterfv, GetColorTableParameterfvSGI@12, GetColorTableParameterfv, GetColorTableParameterfv@12)
-#endif
 #ifndef GLX_INDIRECT_RENDERING
        GL_STUB_ALIAS(GetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfv, GetColorTableParameterfvEXT@12, GetColorTableParameterfv, GetColorTableParameterfv@12)
 #endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetColorTableParameterivSGI, _gloffset_GetColorTableParameteriv, GetColorTableParameterivSGI@12, GetColorTableParameteriv, GetColorTableParameteriv@12)
-#endif
 #ifndef GLX_INDIRECT_RENDERING
        GL_STUB_ALIAS(GetColorTableParameterivEXT, _gloffset_GetColorTableParameteriv, GetColorTableParameterivEXT@12, GetColorTableParameteriv, GetColorTableParameteriv@12)
 #endif
-       GL_STUB_ALIAS(ColorSubTableEXT, _gloffset_ColorSubTable, ColorSubTableEXT@24, ColorSubTable, ColorSubTable@24)
-       GL_STUB_ALIAS(CopyColorSubTableEXT, _gloffset_CopyColorSubTable, CopyColorSubTableEXT@20, CopyColorSubTable, CopyColorSubTable@20)
-       GL_STUB_ALIAS(ConvolutionFilter1DEXT, _gloffset_ConvolutionFilter1D, ConvolutionFilter1DEXT@24, ConvolutionFilter1D, ConvolutionFilter1D@24)
-       GL_STUB_ALIAS(ConvolutionFilter2DEXT, _gloffset_ConvolutionFilter2D, ConvolutionFilter2DEXT@28, ConvolutionFilter2D, ConvolutionFilter2D@28)
-       GL_STUB_ALIAS(ConvolutionParameterfEXT, _gloffset_ConvolutionParameterf, ConvolutionParameterfEXT@12, ConvolutionParameterf, ConvolutionParameterf@12)
-       GL_STUB_ALIAS(ConvolutionParameterfvEXT, _gloffset_ConvolutionParameterfv, ConvolutionParameterfvEXT@12, ConvolutionParameterfv, ConvolutionParameterfv@12)
-       GL_STUB_ALIAS(ConvolutionParameteriEXT, _gloffset_ConvolutionParameteri, ConvolutionParameteriEXT@12, ConvolutionParameteri, ConvolutionParameteri@12)
-       GL_STUB_ALIAS(ConvolutionParameterivEXT, _gloffset_ConvolutionParameteriv, ConvolutionParameterivEXT@12, ConvolutionParameteriv, ConvolutionParameteriv@12)
-       GL_STUB_ALIAS(CopyConvolutionFilter1DEXT, _gloffset_CopyConvolutionFilter1D, CopyConvolutionFilter1DEXT@20, CopyConvolutionFilter1D, CopyConvolutionFilter1D@20)
-       GL_STUB_ALIAS(CopyConvolutionFilter2DEXT, _gloffset_CopyConvolutionFilter2D, CopyConvolutionFilter2DEXT@24, CopyConvolutionFilter2D, CopyConvolutionFilter2D@24)
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetConvolutionFilterEXT, _gloffset_GetConvolutionFilter, GetConvolutionFilterEXT@16, GetConvolutionFilter, GetConvolutionFilter@16)
-#endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetConvolutionParameterfvEXT, _gloffset_GetConvolutionParameterfv, GetConvolutionParameterfvEXT@12, GetConvolutionParameterfv, GetConvolutionParameterfv@12)
-#endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetConvolutionParameterivEXT, _gloffset_GetConvolutionParameteriv, GetConvolutionParameterivEXT@12, GetConvolutionParameteriv, GetConvolutionParameteriv@12)
-#endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetSeparableFilterEXT, _gloffset_GetSeparableFilter, GetSeparableFilterEXT@24, GetSeparableFilter, GetSeparableFilter@24)
-#endif
-       GL_STUB_ALIAS(SeparableFilter2DEXT, _gloffset_SeparableFilter2D, SeparableFilter2DEXT@32, SeparableFilter2D, SeparableFilter2D@32)
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetHistogramEXT, _gloffset_GetHistogram, GetHistogramEXT@20, GetHistogram, GetHistogram@20)
-#endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetHistogramParameterfvEXT, _gloffset_GetHistogramParameterfv, GetHistogramParameterfvEXT@12, GetHistogramParameterfv, GetHistogramParameterfv@12)
-#endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetHistogramParameterivEXT, _gloffset_GetHistogramParameteriv, GetHistogramParameterivEXT@12, GetHistogramParameteriv, GetHistogramParameteriv@12)
-#endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetMinmaxEXT, _gloffset_GetMinmax, GetMinmaxEXT@20, GetMinmax, GetMinmax@20)
-#endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetMinmaxParameterfvEXT, _gloffset_GetMinmaxParameterfv, GetMinmaxParameterfvEXT@12, GetMinmaxParameterfv, GetMinmaxParameterfv@12)
-#endif
-#ifndef GLX_INDIRECT_RENDERING
-       GL_STUB_ALIAS(GetMinmaxParameterivEXT, _gloffset_GetMinmaxParameteriv, GetMinmaxParameterivEXT@12, GetMinmaxParameteriv, GetMinmaxParameteriv@12)
-#endif
-       GL_STUB_ALIAS(HistogramEXT, _gloffset_Histogram, HistogramEXT@16, Histogram, Histogram@16)
-       GL_STUB_ALIAS(MinmaxEXT, _gloffset_Minmax, MinmaxEXT@12, Minmax, Minmax@12)
-       GL_STUB_ALIAS(ResetHistogramEXT, _gloffset_ResetHistogram, ResetHistogramEXT@4, ResetHistogram, ResetHistogram@4)
-       GL_STUB_ALIAS(ResetMinmaxEXT, _gloffset_ResetMinmax, ResetMinmaxEXT@4, ResetMinmax, ResetMinmax@4)
        GL_STUB_ALIAS(TexImage3DEXT, _gloffset_TexImage3D, TexImage3DEXT@40, TexImage3D, TexImage3D@40)
        GL_STUB_ALIAS(TexSubImage3DEXT, _gloffset_TexSubImage3D, TexSubImage3DEXT@44, TexSubImage3D, TexSubImage3D@44)
        GL_STUB_ALIAS(CopyTexSubImage3DEXT, _gloffset_CopyTexSubImage3D, CopyTexSubImage3DEXT@36, CopyTexSubImage3D, CopyTexSubImage3D@36)
@@ -1127,7 +1069,6 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB_ALIAS(MultiTexCoord4iv, _gloffset_MultiTexCoord4ivARB, MultiTexCoord4iv@8, MultiTexCoord4ivARB, MultiTexCoord4ivARB@8)
        GL_STUB_ALIAS(MultiTexCoord4s, _gloffset_MultiTexCoord4sARB, MultiTexCoord4s@20, MultiTexCoord4sARB, MultiTexCoord4sARB@20)
        GL_STUB_ALIAS(MultiTexCoord4sv, _gloffset_MultiTexCoord4svARB, MultiTexCoord4sv@8, MultiTexCoord4svARB, MultiTexCoord4svARB@8)
-       GL_STUB_ALIAS(StencilOpSeparateATI, _gloffset_StencilOpSeparate, StencilOpSeparateATI@16, StencilOpSeparate, StencilOpSeparate@16)
        GL_STUB_ALIAS(LoadTransposeMatrixd, _gloffset_LoadTransposeMatrixdARB, LoadTransposeMatrixd@4, LoadTransposeMatrixdARB, LoadTransposeMatrixdARB@4)
        GL_STUB_ALIAS(LoadTransposeMatrixf, _gloffset_LoadTransposeMatrixfARB, LoadTransposeMatrixf@4, LoadTransposeMatrixfARB, LoadTransposeMatrixfARB@4)
        GL_STUB_ALIAS(MultTransposeMatrixd, _gloffset_MultTransposeMatrixdARB, MultTransposeMatrixd@4, MultTransposeMatrixdARB, MultTransposeMatrixdARB@4)
@@ -1242,10 +1183,8 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB_ALIAS(RenderbufferStorageMultisampleEXT, _gloffset_RenderbufferStorageMultisample, RenderbufferStorageMultisampleEXT@20, RenderbufferStorageMultisample, RenderbufferStorageMultisample@20)
        GL_STUB_ALIAS(PointParameterf, _gloffset_PointParameterfEXT, PointParameterf@8, PointParameterfEXT, PointParameterfEXT@8)
        GL_STUB_ALIAS(PointParameterfARB, _gloffset_PointParameterfEXT, PointParameterfARB@8, PointParameterfEXT, PointParameterfEXT@8)
-       GL_STUB_ALIAS(PointParameterfSGIS, _gloffset_PointParameterfEXT, PointParameterfSGIS@8, PointParameterfEXT, PointParameterfEXT@8)
        GL_STUB_ALIAS(PointParameterfv, _gloffset_PointParameterfvEXT, PointParameterfv@8, PointParameterfvEXT, PointParameterfvEXT@8)
        GL_STUB_ALIAS(PointParameterfvARB, _gloffset_PointParameterfvEXT, PointParameterfvARB@8, PointParameterfvEXT, PointParameterfvEXT@8)
-       GL_STUB_ALIAS(PointParameterfvSGIS, _gloffset_PointParameterfvEXT, PointParameterfvSGIS@8, PointParameterfvEXT, PointParameterfvEXT@8)
        GL_STUB_ALIAS(SecondaryColor3b, _gloffset_SecondaryColor3bEXT, SecondaryColor3b@12, SecondaryColor3bEXT, SecondaryColor3bEXT@12)
        GL_STUB_ALIAS(SecondaryColor3bv, _gloffset_SecondaryColor3bvEXT, SecondaryColor3bv@4, SecondaryColor3bvEXT, SecondaryColor3bvEXT@4)
        GL_STUB_ALIAS(SecondaryColor3d, _gloffset_SecondaryColor3dEXT, SecondaryColor3d@24, SecondaryColor3dEXT, SecondaryColor3dEXT@24)
@@ -1271,7 +1210,6 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB_ALIAS(FogCoordf, _gloffset_FogCoordfEXT, FogCoordf@4, FogCoordfEXT, FogCoordfEXT@4)
        GL_STUB_ALIAS(FogCoordfv, _gloffset_FogCoordfvEXT, FogCoordfv@4, FogCoordfvEXT, FogCoordfvEXT@4)
        GL_STUB_ALIAS(BlendFuncSeparate, _gloffset_BlendFuncSeparateEXT, BlendFuncSeparate@16, BlendFuncSeparateEXT, BlendFuncSeparateEXT@16)
-       GL_STUB_ALIAS(BlendFuncSeparateINGR, _gloffset_BlendFuncSeparateEXT, BlendFuncSeparateINGR@16, BlendFuncSeparateEXT, BlendFuncSeparateEXT@16)
        GL_STUB_ALIAS(WindowPos2d, _gloffset_WindowPos2dMESA, WindowPos2d@16, WindowPos2dMESA, WindowPos2dMESA@16)
        GL_STUB_ALIAS(WindowPos2dARB, _gloffset_WindowPos2dMESA, WindowPos2dARB@16, WindowPos2dMESA, WindowPos2dMESA@16)
        GL_STUB_ALIAS(WindowPos2dv, _gloffset_WindowPos2dvMESA, WindowPos2dv@4, WindowPos2dvMESA, WindowPos2dvMESA@4)
@@ -1312,6 +1250,9 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB_ALIAS(IsProgramARB, _gloffset_IsProgramNV, IsProgramARB@4, IsProgramNV, IsProgramNV@4)
        GL_STUB_ALIAS(PointParameteri, _gloffset_PointParameteriNV, PointParameteri@8, PointParameteriNV, PointParameteriNV@8)
        GL_STUB_ALIAS(PointParameteriv, _gloffset_PointParameterivNV, PointParameteriv@8, PointParameterivNV, PointParameterivNV@8)
+       GL_STUB_ALIAS(DeleteVertexArrays, _gloffset_DeleteVertexArraysAPPLE, DeleteVertexArrays@8, _dispatch_stub_755, _dispatch_stub_755@8)
+       GL_STUB_ALIAS(IsVertexArray, _gloffset_IsVertexArrayAPPLE, IsVertexArray@4, _dispatch_stub_757, _dispatch_stub_757@4)
+       GL_STUB_ALIAS(BlendEquationSeparate, _gloffset_BlendEquationSeparateEXT, BlendEquationSeparate@8, _dispatch_stub_765, _dispatch_stub_765@8)
        GL_STUB_ALIAS(BindFramebuffer, _gloffset_BindFramebufferEXT, BindFramebuffer@8, BindFramebufferEXT, BindFramebufferEXT@8)
        GL_STUB_ALIAS(BindRenderbuffer, _gloffset_BindRenderbufferEXT, BindRenderbuffer@8, BindRenderbufferEXT, BindRenderbufferEXT@8)
        GL_STUB_ALIAS(CheckFramebufferStatus, _gloffset_CheckFramebufferStatusEXT, CheckFramebufferStatus@4, CheckFramebufferStatusEXT, CheckFramebufferStatusEXT@4)
@@ -1329,6 +1270,7 @@ GLNAME(gl_dispatch_functions_start):
        GL_STUB_ALIAS(IsFramebuffer, _gloffset_IsFramebufferEXT, IsFramebuffer@4, IsFramebufferEXT, IsFramebufferEXT@4)
        GL_STUB_ALIAS(IsRenderbuffer, _gloffset_IsRenderbufferEXT, IsRenderbuffer@4, IsRenderbufferEXT, IsRenderbufferEXT@4)
        GL_STUB_ALIAS(RenderbufferStorage, _gloffset_RenderbufferStorageEXT, RenderbufferStorage@16, RenderbufferStorageEXT, RenderbufferStorageEXT@16)
+       GL_STUB_ALIAS(BlitFramebuffer, _gloffset_BlitFramebufferEXT, BlitFramebuffer@40, _dispatch_stub_783, _dispatch_stub_783@40)
        GL_STUB_ALIAS(FramebufferTextureLayer, _gloffset_FramebufferTextureLayerEXT, FramebufferTextureLayer@20, FramebufferTextureLayerEXT, FramebufferTextureLayerEXT@20)
        GL_STUB_ALIAS(ProvokingVertex, _gloffset_ProvokingVertexEXT, ProvokingVertex@4, ProvokingVertexEXT, ProvokingVertexEXT@4)
 
index 8995c03886b9992d1f64646349ddca38b853b40a..6e9aef2e1f876ce7e0a7084206d94cad1eed8bb4 100644 (file)
@@ -89,7 +89,7 @@
                        />\r
                        <Tool\r
                                Name="VCPostBuildEventTool"\r
-                               CommandLine="copy $(OutDir)\compile.exe ..\..\..\..\src\glsl\apps"\r
+                               CommandLine="copy &quot;$(OutDir)\compile.exe&quot; ..\..\..\..\src\glsl\apps"\r
                        />\r
                </Configuration>\r
                <Configuration\r
                        />\r
                        <Tool\r
                                Name="VCPostBuildEventTool"\r
-                               CommandLine="copy $(OutDir)\compile.exe ..\..\..\..\src\glsl\apps"\r
+                               CommandLine="copy &quot;$(OutDir)\compile.exe&quot; ..\..\..\..\src\glsl\apps"\r
                        />\r
                </Configuration>\r
        </Configurations>\r