summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/Makefile7
-rw-r--r--src/gallium/auxiliary/SConscript7
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c30
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c19
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aapoint.c34
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c18
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h4
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_util.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex.h2
-rw-r--r--src/gallium/auxiliary/os/os_memory.h (renamed from src/gallium/include/pipe/p_refcnt.h)99
-rw-r--r--src/gallium/auxiliary/os/os_memory_aligned.h (renamed from src/gallium/drivers/nv20/nv20_surface.c)69
-rw-r--r--src/gallium/auxiliary/os/os_memory_debug.h83
-rw-r--r--src/gallium/auxiliary/os/os_memory_stdc.h (renamed from src/gallium/drivers/nv04/nv04_surface.c)77
-rw-r--r--src/gallium/auxiliary/os/os_memory_win32k.h123
-rw-r--r--src/gallium/auxiliary/os/os_misc.c188
-rw-r--r--src/gallium/auxiliary/os/os_misc.h99
-rw-r--r--src/gallium/auxiliary/os/os_stream.h (renamed from src/gallium/auxiliary/util/u_stream.h)22
-rw-r--r--src/gallium/auxiliary/os/os_stream_stdc.c (renamed from src/gallium/auxiliary/util/u_stream_stdc.c)39
-rw-r--r--src/gallium/auxiliary/os/os_stream_wd.c (renamed from src/gallium/auxiliary/util/u_stream_wd.c)76
-rw-r--r--src/gallium/auxiliary/os/os_thread.h (renamed from src/gallium/include/pipe/p_thread.h)25
-rw-r--r--src/gallium/auxiliary/os/os_time.c128
-rw-r--r--src/gallium/auxiliary/os/os_time.h (renamed from src/gallium/drivers/nv10/nv10_surface.c)101
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h1
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c2
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_execmem.c4
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c39
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.c11
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.h4
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c19
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h5
-rw-r--r--src/gallium/auxiliary/util/u_atomic.h271
-rw-r--r--src/gallium/auxiliary/util/u_blit.c2
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c2
-rw-r--r--src/gallium/auxiliary/util/u_debug.c223
-rw-r--r--src/gallium/auxiliary/util/u_debug.h44
-rw-r--r--src/gallium/auxiliary/util/u_debug_memory.c33
-rw-r--r--src/gallium/auxiliary/util/u_dl.c10
-rw-r--r--src/gallium/auxiliary/util/u_draw_quad.c2
-rw-r--r--src/gallium/auxiliary/util/u_format.h1
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c2
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h (renamed from src/gallium/include/pipe/p_inlines.h)92
-rw-r--r--src/gallium/auxiliary/util/u_keymap.c1
-rw-r--r--src/gallium/auxiliary/util/u_memory.h158
-rw-r--r--src/gallium/auxiliary/util/u_prim.h5
-rw-r--r--src/gallium/auxiliary/util/u_ringbuffer.c2
-rw-r--r--src/gallium/auxiliary/util/u_simple_screen.c2
-rw-r--r--src/gallium/auxiliary/util/u_simple_screen.h139
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c1
-rw-r--r--src/gallium/auxiliary/util/u_surface.c1
-rw-r--r--src/gallium/auxiliary/util/u_texture.c1
-rw-r--r--src/gallium/auxiliary/util/u_tile.c2
-rw-r--r--src/gallium/auxiliary/util/u_time.c225
-rw-r--r--src/gallium/auxiliary/util/u_time.h96
-rw-r--r--src/gallium/auxiliary/util/u_timed_winsys.c2
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.c2
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c2
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c2
-rw-r--r--src/gallium/docs/source/conf.py4
-rw-r--r--src/gallium/docs/source/distro.rst31
-rw-r--r--src/gallium/docs/source/exts/tgsi.py17
-rw-r--r--src/gallium/docs/source/screen.rst4
-rw-r--r--src/gallium/docs/source/tgsi.rst512
-rw-r--r--src/gallium/drivers/cell/ppu/cell_clear.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_draw_arrays.c4
-rw-r--r--src/gallium/drivers/cell/ppu/cell_fence.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_screen.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_emit.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_shader.c4
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c4
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vertex_shader.c2
-rw-r--r--src/gallium/drivers/failover/fo_context.c2
-rw-r--r--src/gallium/drivers/failover/fo_state.c2
-rw-r--r--src/gallium/drivers/i915/i915_buffer.c1
-rw-r--r--src/gallium/drivers/i915/i915_context.c2
-rw-r--r--src/gallium/drivers/i915/i915_context.h2
-rw-r--r--src/gallium/drivers/i915/i915_debug.h2
-rw-r--r--src/gallium/drivers/i915/i915_debug_fp.c3
-rw-r--r--src/gallium/drivers/i915/i915_prim_vbuf.c2
-rw-r--r--src/gallium/drivers/i915/i915_screen.c2
-rw-r--r--src/gallium/drivers/i915/i915_state.c2
-rw-r--r--src/gallium/drivers/i915/i915_state_inlines.h1
-rw-r--r--src/gallium/drivers/i915/i915_texture.c2
-rw-r--r--src/gallium/drivers/i965/brw_context.c1
-rw-r--r--src/gallium/drivers/i965/brw_disasm.c1
-rw-r--r--src/gallium/drivers/i965/brw_draw.c1
-rw-r--r--src/gallium/drivers/i965/brw_draw_upload.c1
-rw-r--r--src/gallium/drivers/i965/brw_pipe_fb.c1
-rw-r--r--src/gallium/drivers/i965/brw_pipe_sampler.c1
-rw-r--r--src/gallium/drivers/i965/brw_pipe_shader.c1
-rw-r--r--src/gallium/drivers/i965/brw_screen.c2
-rw-r--r--src/gallium/drivers/i965/brw_screen_buffers.c2
-rw-r--r--src/gallium/drivers/i965/brw_winsys.h2
-rw-r--r--src/gallium/drivers/identity/id_objects.c2
-rw-r--r--src/gallium/drivers/llvmpipe/SConscript29
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_blend_logicop.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_logic.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_buffer.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_fence.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_fence.h4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c11
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast_priv.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_scene.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_scene.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_sampler.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_surface.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c2
-rw-r--r--src/gallium/drivers/nouveau/Makefile3
-rw-r--r--src/gallium/drivers/nouveau/nouveau_screen.c2
-rw-r--r--src/gallium/drivers/nouveau/nouveau_winsys.h20
-rw-r--r--src/gallium/drivers/nouveau/nv04_surface_2d.c (renamed from src/gallium/drivers/nv04/nv04_surface_2d.c)40
-rw-r--r--src/gallium/drivers/nouveau/nv04_surface_2d.h (renamed from src/gallium/drivers/nv04/nv04_surface_2d.h)0
-rw-r--r--src/gallium/drivers/nv04/Makefile21
-rw-r--r--src/gallium/drivers/nv04/nv04_clear.c12
-rw-r--r--src/gallium/drivers/nv04/nv04_context.c112
-rw-r--r--src/gallium/drivers/nv04/nv04_context.h148
-rw-r--r--src/gallium/drivers/nv04/nv04_fragprog.c21
-rw-r--r--src/gallium/drivers/nv04/nv04_fragtex.c73
-rw-r--r--src/gallium/drivers/nv04/nv04_miptree.c146
-rw-r--r--src/gallium/drivers/nv04/nv04_prim_vbuf.c339
-rw-r--r--src/gallium/drivers/nv04/nv04_screen.c222
-rw-r--r--src/gallium/drivers/nv04/nv04_screen.h30
-rw-r--r--src/gallium/drivers/nv04/nv04_state.c459
-rw-r--r--src/gallium/drivers/nv04/nv04_state.h72
-rw-r--r--src/gallium/drivers/nv04/nv04_state_emit.c246
-rw-r--r--src/gallium/drivers/nv04/nv04_transfer.c178
-rw-r--r--src/gallium/drivers/nv04/nv04_vbo.c78
-rw-r--r--src/gallium/drivers/nv10/Makefile20
-rw-r--r--src/gallium/drivers/nv10/nv10_clear.c14
-rw-r--r--src/gallium/drivers/nv10/nv10_context.c298
-rw-r--r--src/gallium/drivers/nv10/nv10_context.h151
-rw-r--r--src/gallium/drivers/nv10/nv10_fragprog.c21
-rw-r--r--src/gallium/drivers/nv10/nv10_fragtex.c130
-rw-r--r--src/gallium/drivers/nv10/nv10_miptree.c165
-rw-r--r--src/gallium/drivers/nv10/nv10_prim_vbuf.c267
-rw-r--r--src/gallium/drivers/nv10/nv10_screen.c208
-rw-r--r--src/gallium/drivers/nv10/nv10_screen.h28
-rw-r--r--src/gallium/drivers/nv10/nv10_state.c590
-rw-r--r--src/gallium/drivers/nv10/nv10_state.h140
-rw-r--r--src/gallium/drivers/nv10/nv10_state_emit.c333
-rw-r--r--src/gallium/drivers/nv10/nv10_transfer.c178
-rw-r--r--src/gallium/drivers/nv10/nv10_vbo.c78
-rw-r--r--src/gallium/drivers/nv20/Makefile21
-rw-r--r--src/gallium/drivers/nv20/nv20_clear.c14
-rw-r--r--src/gallium/drivers/nv20/nv20_context.c424
-rw-r--r--src/gallium/drivers/nv20/nv20_context.h150
-rw-r--r--src/gallium/drivers/nv20/nv20_fragprog.c21
-rw-r--r--src/gallium/drivers/nv20/nv20_fragtex.c130
-rw-r--r--src/gallium/drivers/nv20/nv20_miptree.c226
-rw-r--r--src/gallium/drivers/nv20/nv20_prim_vbuf.c440
-rw-r--r--src/gallium/drivers/nv20/nv20_screen.c204
-rw-r--r--src/gallium/drivers/nv20/nv20_screen.h28
-rw-r--r--src/gallium/drivers/nv20/nv20_state.c583
-rw-r--r--src/gallium/drivers/nv20/nv20_state.h140
-rw-r--r--src/gallium/drivers/nv20/nv20_state_emit.c426
-rw-r--r--src/gallium/drivers/nv20/nv20_transfer.c178
-rw-r--r--src/gallium/drivers/nv20/nv20_vbo.c79
-rw-r--r--src/gallium/drivers/nv20/nv20_vertprog.c841
-rw-r--r--src/gallium/drivers/nv30/nv30_context.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_context.h3
-rw-r--r--src/gallium/drivers/nv30/nv30_fragprog.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_miptree.c4
-rw-r--r--src/gallium/drivers/nv30/nv30_screen.c6
-rw-r--r--src/gallium/drivers/nv30/nv30_screen.h2
-rw-r--r--src/gallium/drivers/nv30/nv30_state.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_surface.c4
-rw-r--r--src/gallium/drivers/nv30/nv30_transfer.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_vbo.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_vertprog.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_context.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_context.h3
-rw-r--r--src/gallium/drivers/nv40/nv40_draw.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_fragprog.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_miptree.c4
-rw-r--r--src/gallium/drivers/nv40/nv40_screen.c6
-rw-r--r--src/gallium/drivers/nv40/nv40_screen.h2
-rw-r--r--src/gallium/drivers/nv40/nv40_state.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_surface.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_transfer.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_vbo.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_vertprog.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_context.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h2
-rw-r--r--src/gallium/drivers/nv50/nv50_miptree.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_program.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_query.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.c3
-rw-r--r--src/gallium/drivers/nv50/nv50_state.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_surface.c4
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_vbo.c2
-rw-r--r--src/gallium/drivers/r300/r300_context.h2
-rw-r--r--src/gallium/drivers/r300/r300_fs.c10
-rw-r--r--src/gallium/drivers/r300/r300_render.c4
-rw-r--r--src/gallium/drivers/r300/r300_screen.c7
-rw-r--r--src/gallium/drivers/r300/r300_texture.h13
-rw-r--r--src/gallium/drivers/r300/r300_tgsi_to_rc.c63
-rw-r--r--src/gallium/drivers/r300/r300_tgsi_to_rc.h7
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h2
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_state_surface.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_tile_cache.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_video_context.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_winsys.c3
-rw-r--r--src/gallium/drivers/svga/svga_context.c3
-rw-r--r--src/gallium/drivers/svga/svga_context.h4
-rw-r--r--src/gallium/drivers/svga/svga_draw.c2
-rw-r--r--src/gallium/drivers/svga/svga_draw_arrays.c2
-rw-r--r--src/gallium/drivers/svga/svga_draw_elements.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_blend.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_constants.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_depthstencil.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_draw.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_fs.c3
-rw-r--r--src/gallium/drivers/svga/svga_pipe_misc.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_rasterizer.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_sampler.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_vertex.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_vs.c2
-rw-r--r--src/gallium/drivers/svga/svga_screen.c2
-rw-r--r--src/gallium/drivers/svga/svga_screen.h2
-rw-r--r--src/gallium/drivers/svga/svga_screen_buffer.c4
-rw-r--r--src/gallium/drivers/svga/svga_screen_cache.h2
-rw-r--r--src/gallium/drivers/svga/svga_screen_texture.c4
-rw-r--r--src/gallium/drivers/svga/svga_screen_texture.h1
-rw-r--r--src/gallium/drivers/svga/svga_state_constants.c2
-rw-r--r--src/gallium/drivers/svga/svga_state_framebuffer.c2
-rw-r--r--src/gallium/drivers/svga/svga_state_fs.c128
-rw-r--r--src/gallium/drivers/svga/svga_state_need_swtnl.c2
-rw-r--r--src/gallium/drivers/svga/svga_state_rss.c2
-rw-r--r--src/gallium/drivers/svga/svga_state_tss.c2
-rw-r--r--src/gallium/drivers/svga/svga_state_vdecl.c2
-rw-r--r--src/gallium/drivers/svga/svga_state_vs.c2
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_backend.c2
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_draw.c2
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_state.c2
-rw-r--r--src/gallium/drivers/svga/svga_tgsi.h1
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_decl_sm30.c15
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_emit.h19
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_insn.c271
-rw-r--r--src/gallium/drivers/trace/tr_buffer.c1
-rw-r--r--src/gallium/drivers/trace/tr_dump.c14
-rw-r--r--src/gallium/drivers/trace/tr_dump_state.c2
-rw-r--r--src/gallium/drivers/trace/tr_rbug.c13
-rw-r--r--src/gallium/drivers/trace/tr_screen.c2
-rw-r--r--src/gallium/drivers/trace/tr_screen.h2
-rw-r--r--src/gallium/drivers/trace/tr_texture.c1
-rw-r--r--src/gallium/include/pipe/internal/p_winsys_screen.h190
-rw-r--r--src/gallium/include/pipe/p_atomic.h353
-rw-r--r--src/gallium/include/pipe/p_compiler.h13
-rw-r--r--src/gallium/include/pipe/p_config.h8
-rw-r--r--src/gallium/include/pipe/p_format.h4
-rw-r--r--src/gallium/include/pipe/p_state.h39
-rw-r--r--src/gallium/include/pipe/p_video_state.h4
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c1
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.c4
-rw-r--r--src/gallium/state_trackers/egl/Makefile4
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c34
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.h39
-rw-r--r--src/gallium/state_trackers/egl/kms/native_kms.c2
-rw-r--r--src/gallium/state_trackers/egl/x11/glxinit.c682
-rw-r--r--src/gallium/state_trackers/egl/x11/glxinit.h11
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c1
-rw-r--r--src/gallium/state_trackers/egl/x11/native_x11.c1
-rw-r--r--src/gallium/state_trackers/egl/x11/native_ximage.c3
-rw-r--r--src/gallium/state_trackers/egl/x11/sw_winsys.c4
-rw-r--r--src/gallium/state_trackers/egl/x11/x11_screen.c2
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.h2
-rw-r--r--src/gallium/state_trackers/python/gallium.i2
-rw-r--r--src/gallium/state_trackers/python/st_device.c2
-rw-r--r--src/gallium/state_trackers/python/st_llvmpipe_winsys.c2
-rw-r--r--src/gallium/state_trackers/python/st_sample.c2
-rw-r--r--src/gallium/state_trackers/vega/api_filters.c2
-rw-r--r--src/gallium/state_trackers/vega/api_images.c2
-rw-r--r--src/gallium/state_trackers/vega/api_masks.c2
-rw-r--r--src/gallium/state_trackers/vega/api_path.c2
-rw-r--r--src/gallium/state_trackers/vega/asm_fill.h551
-rw-r--r--src/gallium/state_trackers/vega/image.c2
-rw-r--r--src/gallium/state_trackers/vega/mask.c2
-rw-r--r--src/gallium/state_trackers/vega/paint.c2
-rw-r--r--src/gallium/state_trackers/vega/polygon.c2
-rw-r--r--src/gallium/state_trackers/vega/renderer.c2
-rw-r--r--src/gallium/state_trackers/vega/shader.c2
-rw-r--r--src/gallium/state_trackers/vega/shaders_cache.c151
-rw-r--r--src/gallium/state_trackers/vega/st_inlines.h2
-rw-r--r--src/gallium/state_trackers/vega/vg_context.c2
-rw-r--r--src/gallium/state_trackers/vega/vg_tracker.c2
-rw-r--r--src/gallium/state_trackers/wgl/stw_device.h2
-rw-r--r--src/gallium/state_trackers/wgl/stw_framebuffer.h2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_tracker.h2
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c1
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_api.c1
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_fence.c3
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/Makefile3
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c18
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h2
-rw-r--r--src/gallium/winsys/drm/nouveau/egl/Makefile3
-rw-r--r--src/gallium/winsys/drm/nouveau/xorg/Makefile3
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.h4
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_winsys.h2
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_buffer.c2
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_buffer.h2
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c3
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c2
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_surface.h6
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/Makefile5
-rw-r--r--src/gallium/winsys/g3dvl/xlib/xsp_winsys.c4
-rw-r--r--src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c2
-rw-r--r--src/gallium/winsys/gdi/gdi_softpipe_winsys.c4
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_context.c4
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c4
-rw-r--r--src/gallium/winsys/xlib/xlib_llvmpipe.c4
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c4
336 files changed, 3841 insertions, 11265 deletions
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index da1fb6b299..66cfe9d89d 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -48,6 +48,10 @@ C_SOURCES = \
draw/draw_vs_sse.c \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
+ os/os_misc.c \
+ os/os_stream_stdc.c \
+ os/os_stream_wd.c \
+ os/os_time.c \
pipebuffer/pb_buffer_malloc.c \
pipebuffer/pb_bufmgr_alt.c \
pipebuffer/pb_bufmgr_cache.c \
@@ -113,12 +117,9 @@ C_SOURCES = \
util/u_ringbuffer.c \
util/u_simple_shaders.c \
util/u_snprintf.c \
- util/u_stream_stdc.c \
- util/u_stream_wd.c \
util/u_surface.c \
util/u_texture.c \
util/u_tile.c \
- util/u_time.c \
util/u_timed_winsys.c \
util/u_upload_mgr.c \
util/u_simple_screen.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 3aa782f81e..255739b0a2 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -82,6 +82,10 @@ source = [
#'indices/u_unfilled_indices.c',
'indices/u_indices_gen.c',
'indices/u_unfilled_gen.c',
+ 'os/os_misc.c',
+ 'os/os_stream_stdc.c',
+ 'os/os_stream_wd.c',
+ 'os/os_time.c',
'pipebuffer/pb_buffer_fenced.c',
'pipebuffer/pb_buffer_malloc.c',
'pipebuffer/pb_bufmgr_alt.c',
@@ -149,12 +153,9 @@ source = [
'util/u_ringbuffer.c',
'util/u_simple_shaders.c',
'util/u_snprintf.c',
- 'util/u_stream_stdc.c',
- 'util/u_stream_wd.c',
'util/u_surface.c',
'util/u_texture.c',
'util/u_tile.c',
- 'util/u_time.c',
'util/u_timed_winsys.c',
'util/u_upload_mgr.c',
'util/u_simple_screen.c',
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index dec830ba93..c638239e80 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -36,6 +36,7 @@
*/
#include "pipe/p_state.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index d3084fd428..d5ddc4a6a9 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -352,7 +352,10 @@ draw_find_shader_output(const struct draw_context *draw,
/**
- * Return number of the shader outputs.
+ * Return total number of the shader outputs. This function is similar to
+ * draw_current_shader_outputs() but this function also counts any extra
+ * vertex/geometry output attributes that may be filled in by some draw
+ * stages (such as AA point, AA line).
*
* If geometry shader is present, its output will be returned,
* if not vertex shader is used.
@@ -362,8 +365,9 @@ draw_num_shader_outputs(const struct draw_context *draw)
{
uint count = draw->vs.vertex_shader->info.num_outputs;
- /* if geometry shader is present, its outputs go to te
- * driver, not the vertex shaders */
+ /* If a geometry shader is present, its outputs go to the
+ * driver, else the vertex shader's outputs.
+ */
if (draw->gs.geometry_shader)
count = draw->gs.geometry_shader->info.num_outputs;
@@ -374,7 +378,8 @@ draw_num_shader_outputs(const struct draw_context *draw)
/**
- * Provide TGSI sampler objects for vertex/geometry shaders that use texture fetches.
+ * Provide TGSI sampler objects for vertex/geometry shaders that use
+ * texture fetches.
* This might only be used by software drivers for the time being.
*/
void
@@ -454,14 +459,27 @@ void draw_do_flush( struct draw_context *draw, unsigned flags )
}
-int draw_current_shader_outputs(struct draw_context *draw)
+/**
+ * Return the number of output attributes produced by the geometry
+ * shader, if present. If no geometry shader, return the number of
+ * outputs from the vertex shader.
+ * \sa draw_num_shader_outputs
+ */
+uint
+draw_current_shader_outputs(const struct draw_context *draw)
{
if (draw->gs.geometry_shader)
return draw->gs.num_gs_outputs;
return draw->vs.num_vs_outputs;
}
-int draw_current_shader_position_output(struct draw_context *draw)
+
+/**
+ * Return the index of the shader output which will contain the
+ * vertex position.
+ */
+uint
+draw_current_shader_position_output(const struct draw_context *draw)
{
if (draw->gs.geometry_shader)
return draw->gs.position_output;
diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c
index 11d6485dcf..83dc1a35f4 100644
--- a/src/gallium/auxiliary/draw/draw_pipe.c
+++ b/src/gallium/auxiliary/draw/draw_pipe.c
@@ -32,6 +32,7 @@
#include "draw/draw_private.h"
#include "draw/draw_pipe.h"
+#include "util/u_debug.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 4585dcdb48..8f6ca15dfa 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -35,6 +35,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
@@ -48,6 +49,10 @@
#include "draw_pipe.h"
+/** Approx number of new tokens for instructions in aa_transform_inst() */
+#define NUM_NEW_TOKENS 50
+
+
/**
* Max texture level for the alpha texture used for antialiasing
*/
@@ -178,12 +183,7 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
static int
free_bit(uint bitfield)
{
- int i;
- for (i = 0; i < 32; i++) {
- if ((bitfield & (1 << i)) == 0)
- return i;
- }
- return -1;
+ return ffs(~bitfield) - 1;
}
@@ -342,11 +342,10 @@ generate_aaline_fs(struct aaline_stage *aaline)
const struct pipe_shader_state *orig_fs = &aaline->fs->state;
struct pipe_shader_state aaline_fs;
struct aa_transform_context transform;
-
-#define MAX 1000
+ const uint newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
aaline_fs = *orig_fs; /* copy to init */
- aaline_fs.tokens = MALLOC(sizeof(struct tgsi_token) * MAX);
+ aaline_fs.tokens = tgsi_alloc_tokens(newLen);
if (aaline_fs.tokens == NULL)
return FALSE;
@@ -362,7 +361,7 @@ generate_aaline_fs(struct aaline_stage *aaline)
tgsi_transform_shader(orig_fs->tokens,
(struct tgsi_token *) aaline_fs.tokens,
- MAX, &transform.base);
+ newLen, &transform.base);
#if 0 /* DEBUG */
tgsi_dump(orig_fs->tokens, 0);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index d86717e518..97f3480879 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -53,6 +53,10 @@
#include "draw_pipe.h"
+/** Approx number of new tokens for instructions in aa_transform_inst() */
+#define NUM_NEW_TOKENS 200
+
+
/*
* Enabling NORMALIZE might give _slightly_ better results.
* Basically, it controls whether we compute distance as d=sqrt(x*x+y*y) or
@@ -81,16 +85,19 @@ struct aapoint_stage
{
struct draw_stage stage;
- int psize_slot;
+ /** half of pipe_rasterizer_state::point_size */
float radius;
+ /** vertex attrib slot containing point size */
+ int psize_slot;
+
/** this is the vertex attrib slot for the new texcoords */
uint tex_slot;
+
+ /** vertex attrib slot containing position */
uint pos_slot;
- /*
- * Currently bound state
- */
+ /** Currently bound fragment shader */
struct aapoint_fragment_shader *fs;
/*
@@ -491,11 +498,10 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
const struct pipe_shader_state *orig_fs = &aapoint->fs->state;
struct pipe_shader_state aapoint_fs;
struct aa_transform_context transform;
-
-#define MAX 1000
+ const uint newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
aapoint_fs = *orig_fs; /* copy to init */
- aapoint_fs.tokens = MALLOC(sizeof(struct tgsi_token) * MAX);
+ aapoint_fs.tokens = tgsi_alloc_tokens(newLen);
if (aapoint_fs.tokens == NULL)
return FALSE;
@@ -511,7 +517,7 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
tgsi_transform_shader(orig_fs->tokens,
(struct tgsi_token *) aapoint_fs.tokens,
- MAX, &transform.base);
+ newLen, &transform.base);
#if 0 /* DEBUG */
printf("draw_aapoint, orig shader:\n");
@@ -575,8 +581,8 @@ aapoint_point(struct draw_stage *stage, struct prim_header *header)
const struct aapoint_stage *aapoint = aapoint_stage(stage);
struct prim_header tri;
struct vertex_header *v[4];
- uint texPos = aapoint->tex_slot;
- uint pos_slot = aapoint->pos_slot;
+ const uint tex_slot = aapoint->tex_slot;
+ const uint pos_slot = aapoint->pos_slot;
float radius, *pos, *tex;
uint i;
float k;
@@ -643,16 +649,16 @@ aapoint_point(struct draw_stage *stage, struct prim_header *header)
pos[1] += radius;
/* new texcoords */
- tex = v[0]->data[texPos];
+ tex = v[0]->data[tex_slot];
ASSIGN_4V(tex, -1, -1, k, 1);
- tex = v[1]->data[texPos];
+ tex = v[1]->data[tex_slot];
ASSIGN_4V(tex, 1, -1, k, 1);
- tex = v[2]->data[texPos];
+ tex = v[2]->data[tex_slot];
ASSIGN_4V(tex, 1, 1, k, 1);
- tex = v[3]->data[texPos];
+ tex = v[3]->data[tex_slot];
ASSIGN_4V(tex, -1, 1, k, 1);
/* emit 2 tris for the quad strip */
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index 0cc2b71864..d0d99aa331 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -37,6 +37,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
@@ -49,6 +50,9 @@
#include "draw_pipe.h"
+/** Approx number of new tokens for instructions in pstip_transform_inst() */
+#define NUM_NEW_TOKENS 50
+
/**
* Subclass of pipe_shader_state to carry extra fragment shader info.
@@ -171,12 +175,7 @@ pstip_transform_immed(struct tgsi_transform_context *ctx,
static int
free_bit(uint bitfield)
{
- int i;
- for (i = 0; i < 32; i++) {
- if ((bitfield & (1 << i)) == 0)
- return i;
- }
- return -1;
+ return ffs(~bitfield) - 1;
}
@@ -332,11 +331,10 @@ generate_pstip_fs(struct pstip_stage *pstip)
/*struct draw_context *draw = pstip->stage.draw;*/
struct pipe_shader_state pstip_fs;
struct pstip_transform_context transform;
-
-#define MAX 1000
+ const uint newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
pstip_fs = *orig_fs; /* copy to init */
- pstip_fs.tokens = MALLOC(sizeof(struct tgsi_token) * MAX);
+ pstip_fs.tokens = tgsi_alloc_tokens(newLen);
if (pstip_fs.tokens == NULL)
return FALSE;
@@ -351,7 +349,7 @@ generate_pstip_fs(struct pstip_stage *pstip)
tgsi_transform_shader(orig_fs->tokens,
(struct tgsi_token *) pstip_fs.tokens,
- MAX, &transform.base);
+ newLen, &transform.base);
#if 0 /* DEBUG */
tgsi_dump(orig_fs->tokens, 0);
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 6a7190e975..69466d8749 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -280,8 +280,8 @@ void draw_gs_destroy( struct draw_context *draw );
/*******************************************************************************
* Common shading code:
*/
-int draw_current_shader_outputs(struct draw_context *draw);
-int draw_current_shader_position_output(struct draw_context *draw);
+uint draw_current_shader_outputs(const struct draw_context *draw);
+uint draw_current_shader_position_output(const struct draw_context *draw);
/*******************************************************************************
* Vertex processing (was passthrough) code:
diff --git a/src/gallium/auxiliary/draw/draw_pt_util.c b/src/gallium/auxiliary/draw/draw_pt_util.c
index 17c3b8cec2..3236d38e6a 100644
--- a/src/gallium/auxiliary/draw/draw_pt_util.c
+++ b/src/gallium/auxiliary/draw/draw_pt_util.c
@@ -33,6 +33,7 @@
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"
+#include "util/u_debug.h"
void draw_pt_split_prim(unsigned prim, unsigned *first, unsigned *incr)
{
diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/draw/draw_vertex.h
index 554f4ac3c1..8c3c7befbc 100644
--- a/src/gallium/auxiliary/draw/draw_vertex.h
+++ b/src/gallium/auxiliary/draw/draw_vertex.h
@@ -39,7 +39,9 @@
#define DRAW_VERTEX_H
+#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
+#include "util/u_debug.h"
/**
diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/auxiliary/os/os_memory.h
index c1c7415e02..556662d35e 100644
--- a/src/gallium/include/pipe/p_refcnt.h
+++ b/src/gallium/auxiliary/os/os_memory.h
@@ -1,8 +1,8 @@
/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
+ *
+ * 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
@@ -10,86 +10,75 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
+ *
**************************************************************************/
-#ifndef P_REFCNT_H
-#define P_REFCNT_H
+
+/*
+ * OS memory management abstractions
+ */
+
+
+#ifndef _OS_MEMORY_H_
+#define _OS_MEMORY_H_
-#include "p_defines.h"
-#include "p_atomic.h"
+#include "pipe/p_config.h"
+#include "pipe/p_compiler.h"
+#if defined(PIPE_OS_EMBEDDED)
+
#ifdef __cplusplus
extern "C" {
#endif
+void *
+os_malloc(size_t size);
-struct pipe_reference
-{
- struct pipe_atomic count;
-};
+void *
+os_calloc(size_t count, size_t size);
+void
+os_free(void *ptr);
-static INLINE void
-pipe_reference_init(struct pipe_reference *reference, unsigned count)
-{
- p_atomic_set(&reference->count, count);
-}
+void *
+os_realloc(void *ptr, size_t old_size, size_t new_size);
+void *
+os_malloc_aligned(size_t size, size_t alignment);
-static INLINE boolean
-pipe_is_referenced(struct pipe_reference *reference)
-{
- return p_atomic_read(&reference->count) != 0;
+void
+os_free_aligned(void *ptr);
+
+#ifdef __cplusplus
}
+#endif
+#elif defined(PIPE_OS_WINDOWS) && defined(DEBUG) && !defined(DEBUG_MEMORY_IMPLEMENTATION)
-/**
- * Update reference counting.
- * The old thing pointed to, if any, will be unreferenced.
- * Both 'ptr' and 'reference' may be NULL.
- * \return TRUE if the object's refcount hits zero and should be destroyed.
- */
-static INLINE boolean
-pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
-{
- boolean destroy = FALSE;
-
- if(ptr != reference) {
- /* bump the reference.count first */
- if (reference) {
- assert(pipe_is_referenced(reference));
- p_atomic_inc(&reference->count);
- }
-
- if (ptr) {
- assert(pipe_is_referenced(ptr));
- if (p_atomic_dec_zero(&ptr->count)) {
- destroy = TRUE;
- }
- }
- }
-
- return destroy;
-}
+# include "os_memory_debug.h"
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+
+# include "os_memory_win32k.h"
+
+#else
+
+# include "os_memory_stdc.h"
-#ifdef __cplusplus
-}
#endif
-#endif /* P_REFCNT_H */
+#endif /* _OS_MEMORY_H_ */
diff --git a/src/gallium/drivers/nv20/nv20_surface.c b/src/gallium/auxiliary/os/os_memory_aligned.h
index 4224bdd6af..72c5cf65b6 100644
--- a/src/gallium/drivers/nv20/nv20_surface.c
+++ b/src/gallium/auxiliary/os/os_memory_aligned.h
@@ -1,7 +1,6 @@
-
/**************************************************************************
*
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -19,45 +18,55 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
-#include "nv20_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
-#include "util/u_tile.h"
-
-static void
-nv20_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest, unsigned destx, unsigned desty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
- struct nv04_surface_2d *eng2d = nv20->screen->eng2d;
- eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
-}
+/*
+ * Memory alignment wrappers.
+ */
+
+
+#ifndef _OS_MEMORY_H_
+#error "Must not be included directly. Include os_memory.h instead"
+#endif
+
-static void
-nv20_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
- unsigned destx, unsigned desty, unsigned width,
- unsigned height, unsigned value)
+#include "pipe/p_compiler.h"
+
+
+/**
+ * Return memory on given byte alignment
+ */
+static INLINE void *
+os_malloc_aligned(size_t size, size_t alignment)
{
- struct nv20_context *nv20 = nv20_context(pipe);
- struct nv04_surface_2d *eng2d = nv20->screen->eng2d;
+ char *ptr, *buf;
+
+ ptr = (char *) os_malloc(size + alignment + sizeof(void *));
+ if (!ptr)
+ return NULL;
- eng2d->fill(eng2d, dest, destx, desty, width, height, value);
+ buf = (char *)(((uintptr_t)ptr + sizeof(void *) + alignment - 1) & ~((uintptr_t)(alignment - 1)));
+ *(char **)(buf - sizeof(void *)) = ptr;
+
+ return buf;
}
-void
-nv20_init_surface_functions(struct nv20_context *nv20)
+
+/**
+ * Free memory returned by align_malloc().
+ */
+static INLINE void
+os_free_aligned(void *ptr)
{
- nv20->pipe.surface_copy = nv20_surface_copy;
- nv20->pipe.surface_fill = nv20_surface_fill;
+ if (ptr) {
+ void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
+ void *realAddr = *cubbyHole;
+ os_free(realAddr);
+ }
}
diff --git a/src/gallium/auxiliary/os/os_memory_debug.h b/src/gallium/auxiliary/os/os_memory_debug.h
new file mode 100644
index 0000000000..c664be9aad
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_memory_debug.h
@@ -0,0 +1,83 @@
+/**************************************************************************
+ *
+ * Copyright 2008-2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+
+
+/*
+ * Debugging wrappers for OS memory management abstractions.
+ */
+
+
+#ifndef _OS_MEMORY_H_
+#error "Must not be included directly. Include os_memory.h instead"
+#endif
+
+
+#include "pipe/p_compiler.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void *
+debug_malloc(const char *file, unsigned line, const char *function,
+ size_t size);
+
+void *
+debug_calloc(const char *file, unsigned line, const char *function,
+ size_t count, size_t size );
+
+void
+debug_free(const char *file, unsigned line, const char *function,
+ void *ptr);
+
+void *
+debug_realloc(const char *file, unsigned line, const char *function,
+ void *old_ptr, size_t old_size, size_t new_size );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifndef DEBUG_MEMORY_IMPLEMENTATION
+
+#define os_malloc( _size ) \
+ debug_malloc( __FILE__, __LINE__, __FUNCTION__, _size )
+#define os_calloc( _count, _size ) \
+ debug_calloc(__FILE__, __LINE__, __FUNCTION__, _count, _size )
+#define os_free( _ptr ) \
+ debug_free( __FILE__, __LINE__, __FUNCTION__, _ptr )
+#define os_realloc( _ptr, _old_size, _new_size ) \
+ debug_realloc( __FILE__, __LINE__, __FUNCTION__, _ptr, _old_size, _new_size )
+
+/* TODO: wrap os_malloc_aligned() and os_free_aligned() too */
+#include "os_memory_aligned.h"
+
+#endif /* !DEBUG_MEMORY_IMPLEMENTATION */
diff --git a/src/gallium/drivers/nv04/nv04_surface.c b/src/gallium/auxiliary/os/os_memory_stdc.h
index 0387ff4e78..806e536356 100644
--- a/src/gallium/drivers/nv04/nv04_surface.c
+++ b/src/gallium/auxiliary/os/os_memory_stdc.h
@@ -1,7 +1,6 @@
-
/**************************************************************************
*
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -19,45 +18,59 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
-#include "nv04_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
-#include "util/u_tile.h"
-
-static void
-nv04_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest, unsigned destx, unsigned desty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_surface_2d *eng2d = nv04->screen->eng2d;
- eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
-}
+/*
+ * OS memory management abstractions for the standard C library.
+ */
-static void
-nv04_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
- unsigned destx, unsigned desty, unsigned width,
- unsigned height, unsigned value)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_surface_2d *eng2d = nv04->screen->eng2d;
- eng2d->fill(eng2d, dest, destx, desty, width, height, value);
-}
+#ifndef _OS_MEMORY_H_
+#error "Must not be included directly. Include os_memory.h instead"
+#endif
+
+#include <stdlib.h>
+
+#include "pipe/p_compiler.h"
+
+
+#define os_malloc(_size) malloc(_size)
+#define os_calloc(_count, _size ) calloc(_count, _size )
+#define os_free(_ptr) free(_ptr)
+
+#define os_realloc( _old_ptr, _old_size, _new_size) \
+ realloc(_old_ptr, _new_size + 0*(_old_size))
-void
-nv04_init_surface_functions(struct nv04_context *nv04)
+
+#if defined(HAVE_POSIX_MEMALIGN)
+
+static INLINE void *
+os_malloc_aligned(size_t size, size_t alignment)
{
- nv04->pipe.surface_copy = nv04_surface_copy;
- nv04->pipe.surface_fill = nv04_surface_fill;
+ void *ptr;
+ alignment = (alignment + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
+ if(posix_memalign(&ptr, alignment, size) != 0)
+ return NULL;
+ return ptr;
}
+
+#define os_free_aligned(_ptr) free(_ptr)
+
+#elif defined(PIPE_OS_WINDOWS)
+
+#include <malloc.h>
+
+#define os_malloc_aligned(_size, _align) _aligned_malloc(_size, _align)
+#define os_free_aligned(_ptr) _aligned_free(_ptr)
+
+#else
+
+#include "os_memory_aligned.h"
+
+#endif
diff --git a/src/gallium/auxiliary/os/os_memory_win32k.h b/src/gallium/auxiliary/os/os_memory_win32k.h
new file mode 100644
index 0000000000..d56d690872
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_memory_win32k.h
@@ -0,0 +1,123 @@
+/**************************************************************************
+ *
+ * Copyright 2008-2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
+ *
+ **************************************************************************/
+
+
+/*
+ * OS memory management abstractions for Windows kernel.
+ */
+
+
+#ifndef _OS_MEMORY_H_
+#error "Must not be included directly. Include os_memory.h instead"
+#endif
+
+
+#include "pipe/p_compiler.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+
+void * __stdcall
+EngAllocMem(unsigned long Flags,
+ unsigned long MemSize,
+ unsigned long Tag);
+
+void __stdcall
+EngFreeMem(void *Mem);
+
+#define os_malloc(_size) EngAllocMem(0, _size, 'D3AG')
+#define os_calloc(_count, _size) EngAllocMem(1, (_count)*(_size), 'D3AG')
+#define _os_free(_ptr) EngFreeMem(_ptr)
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+
+void *
+ExAllocatePool(unsigned long PoolType,
+ size_t NumberOfBytes);
+
+void
+ExFreePool(void *P);
+
+#define os_malloc(_size) ExAllocatePool(0, _size)
+#define _os_free(_ptr) ExFreePool(_ptr)
+
+static INLINE void *
+os_calloc(unsigned count, unsigned size)
+{
+ void *ptr = os_malloc(count * size);
+ if (ptr) {
+ memset(ptr, 0, count * size);
+ }
+ return ptr;
+}
+
+#else
+
+#error "Unsupported subsystem"
+
+#endif
+
+
+static INLINE void
+os_free( void *ptr )
+{
+ if (ptr) {
+ _os_free(ptr);
+ }
+}
+
+
+static INLINE void *
+os_realloc(void *old_ptr, unsigned old_size, unsigned new_size)
+{
+ void *new_ptr = NULL;
+
+ if (new_size != 0) {
+ unsigned copy_size = old_size < new_size ? old_size : new_size;
+ new_ptr = os_malloc( new_size );
+ if (new_ptr && old_ptr && copy_size) {
+ memcpy(new_ptr, old_ptr, copy_size);
+ }
+ }
+
+ os_free(old_ptr);
+
+ return new_ptr;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#include "os_memory_aligned.h"
diff --git a/src/gallium/auxiliary/os/os_misc.c b/src/gallium/auxiliary/os/os_misc.c
new file mode 100644
index 0000000000..384988017b
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_misc.c
@@ -0,0 +1,188 @@
+/**************************************************************************
+ *
+ * Copyright 2008-2010 Vmware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "os_misc.h"
+
+#include <stdarg.h>
+
+
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
+
+#include <windows.h>
+#include <winddi.h>
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+#include <types.h>
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#endif
+#include <windows.h>
+#include <stdio.h>
+
+#else
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#endif
+
+
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
+static INLINE void
+_EngDebugPrint(const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ EngDebugPrint("", (PCHAR)format, ap);
+ va_end(ap);
+}
+#endif
+
+
+void
+os_log_message(const char *message)
+{
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+ _EngDebugPrint("%s", message);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ OutputDebugStringA(message);
+ if(GetConsoleWindow() && !IsDebuggerPresent()) {
+ fflush(stdout);
+ fputs(message, stderr);
+ fflush(stderr);
+ }
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+ wchar_t *wide_format;
+ long wide_str_len;
+ /* Format is ascii - needs to be converted to wchar_t for printing */
+ wide_str_len = MultiByteToWideChar(CP_ACP, 0, message, -1, NULL, 0);
+ wide_format = (wchar_t *) malloc((wide_str_len+1) * sizeof(wchar_t));
+ if (wide_format) {
+ MultiByteToWideChar(CP_ACP, 0, message, -1,
+ wide_format, wide_str_len);
+ NKDbgPrintfW(wide_format, wide_format);
+ free(wide_format);
+ }
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+ /* TODO */
+#else /* !PIPE_SUBSYSTEM_WINDOWS */
+ fflush(stdout);
+ fputs(message, stderr);
+#endif
+}
+
+
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
+static const char *
+find(const char *start, const char *end, char c)
+{
+ const char *p;
+ for(p = start; !end || p != end; ++p) {
+ if(*p == c)
+ return p;
+ if(*p < 32)
+ break;
+ }
+ return NULL;
+}
+
+static int
+compare(const char *start, const char *end, const char *s)
+{
+ const char *p, *q;
+ for(p = start, q = s; p != end && *q != '\0'; ++p, ++q) {
+ if(*p != *q)
+ return 0;
+ }
+ return p == end && *q == '\0';
+}
+
+static void
+copy(char *dst, const char *start, const char *end, size_t n)
+{
+ const char *p;
+ char *q;
+ for(p = start, q = dst, n = n - 1; p != end && n; ++p, ++q, --n)
+ *q = *p;
+ *q = '\0';
+}
+#endif
+
+
+const char *
+os_get_option(const char *name)
+{
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+ /* EngMapFile creates the file if it does not exists, so it must either be
+ * disabled on release versions (or put in a less conspicuous place). */
+#ifdef DEBUG
+ const char *result = NULL;
+ ULONG_PTR iFile = 0;
+ const void *pMap = NULL;
+ const char *sol, *eol, *sep;
+ static char output[1024];
+
+ pMap = EngMapFile(L"\\??\\c:\\gallium.cfg", 0, &iFile);
+ if(pMap) {
+ sol = (const char *)pMap;
+ while(1) {
+ /* TODO: handle LF line endings */
+ eol = find(sol, NULL, '\r');
+ if(!eol || eol == sol)
+ break;
+ sep = find(sol, eol, '=');
+ if(!sep)
+ break;
+ if(compare(sol, sep, name)) {
+ copy(output, sep + 1, eol, sizeof(output));
+ result = output;
+ break;
+ }
+ sol = eol + 2;
+ }
+ EngUnmapFile(iFile);
+ }
+ return result;
+#else
+ return NULL;
+#endif
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+ /* TODO: implement */
+ return NULL;
+#else
+ return getenv(name);
+#endif
+}
+
diff --git a/src/gallium/auxiliary/os/os_misc.h b/src/gallium/auxiliary/os/os_misc.h
new file mode 100644
index 0000000000..d59f9819fe
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_misc.h
@@ -0,0 +1,99 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+
+/*
+ * Miscellaneous OS services.
+ */
+
+
+#ifndef _OS_MISC_H_
+#define _OS_MISC_H_
+
+
+#include "pipe/p_compiler.h"
+
+
+#if defined(PIPE_OS_UNIX)
+# include <signal.h> /* for kill() */
+# include <unistd.h> /* getpid() */
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Trap into the debugger.
+ */
+#if (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)) && defined(PIPE_CC_GCC)
+# define os_break() __asm("int3")
+#elif defined(PIPE_CC_MSVC)
+# define os_break() __debugbreak()
+#elif defined(PIPE_OS_UNIX)
+# define os_break() kill(getpid(), SIGTRAP)
+#elif defined(PIPE_OS_EMBEDDED)
+void os_break(void);
+#else
+# define os_break() abort()
+#endif
+
+
+/*
+ * Abort the program.
+ */
+#if defined(DEBUG) || defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+# define os_abort() os_break()
+#elif defined(PIPE_OS_EMBEDDED)
+void os_abort(void);
+#else
+# define os_abort() abort()
+#endif
+
+
+/*
+ * Output a message. Message should preferably end in a newline.
+ */
+void
+os_log_message(const char *message);
+
+
+/*
+ * Get an option. Should return NULL if specified option is not set.
+ */
+const char *
+os_get_option(const char *name);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _OS_MISC_H_ */
diff --git a/src/gallium/auxiliary/util/u_stream.h b/src/gallium/auxiliary/os/os_stream.h
index a9d0f0121a..bf30e6542d 100644
--- a/src/gallium/auxiliary/util/u_stream.h
+++ b/src/gallium/auxiliary/os/os_stream.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -30,14 +30,14 @@
* Cross-platform sequential access stream abstraction.
*/
-#ifndef U_STREAM_H
-#define U_STREAM_H
+#ifndef _OS_STREAM_H_
+#define _OS_STREAM_H_
#include "pipe/p_compiler.h"
-struct util_stream;
+struct os_stream;
/**
@@ -45,17 +45,17 @@ struct util_stream;
* @param filename relative or absolute path (necessary for windows)
* @param optional maximum file size (0 for a growable size).
*/
-struct util_stream *
-util_stream_create(const char *filename, size_t max_size);
+struct os_stream *
+os_stream_create(const char *filename, size_t max_size);
boolean
-util_stream_write(struct util_stream *stream, const void *data, size_t size);
+os_stream_write(struct os_stream *stream, const void *data, size_t size);
void
-util_stream_flush(struct util_stream *stream);
+os_stream_flush(struct os_stream *stream);
void
-util_stream_close(struct util_stream *stream);
+os_stream_close(struct os_stream *stream);
-#endif /* U_STREAM_H */
+#endif /* _OS_STREAM_H_ */
diff --git a/src/gallium/auxiliary/util/u_stream_stdc.c b/src/gallium/auxiliary/os/os_stream_stdc.c
index 4d976d6dca..caa60c0b50 100644
--- a/src/gallium/auxiliary/util/u_stream_stdc.c
+++ b/src/gallium/auxiliary/os/os_stream_stdc.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -32,47 +32,46 @@
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
+#if defined(PIPE_OS_UNIX) || defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#include <stdlib.h>
#include <stdio.h>
-#include "util/u_memory.h"
+#include "os_stream.h"
-#include "u_stream.h"
-
-struct util_stream
+struct os_stream
{
FILE *file;
};
-struct util_stream *
-util_stream_create(const char *filename, size_t max_size)
+struct os_stream *
+os_stream_create(const char *filename, size_t max_size)
{
- struct util_stream *stream;
+ struct os_stream *stream;
(void)max_size;
- stream = CALLOC_STRUCT(util_stream);
+ stream = (struct os_stream *)calloc(1, sizeof(struct os_stream));
if(!stream)
- goto error1;
+ goto no_stream;
stream->file = fopen(filename, "w");
if(!stream->file)
- goto error2;
+ goto no_file;
return stream;
-error2:
- FREE(stream);
-error1:
+no_file:
+ free(stream);
+no_stream:
return NULL;
}
boolean
-util_stream_write(struct util_stream *stream, const void *data, size_t size)
+os_stream_write(struct os_stream *stream, const void *data, size_t size)
{
if(!stream)
return FALSE;
@@ -82,7 +81,7 @@ util_stream_write(struct util_stream *stream, const void *data, size_t size)
void
-util_stream_flush(struct util_stream *stream)
+os_stream_flush(struct os_stream *stream)
{
if(!stream)
return;
@@ -92,14 +91,14 @@ util_stream_flush(struct util_stream *stream)
void
-util_stream_close(struct util_stream *stream)
+os_stream_close(struct os_stream *stream)
{
if(!stream)
return;
fclose(stream->file);
- FREE(stream);
+ free(stream);
}
diff --git a/src/gallium/auxiliary/util/u_stream_wd.c b/src/gallium/auxiliary/os/os_stream_wd.c
index 864489e775..a64cbcab4c 100644
--- a/src/gallium/auxiliary/util/u_stream_wd.c
+++ b/src/gallium/auxiliary/os/os_stream_wd.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -37,16 +37,14 @@
#include <windows.h>
#include <winddi.h>
-#include "util/u_memory.h"
-#include "util/u_string.h"
-
-#include "u_stream.h"
+#include "os_memory.h"
+#include "os_stream.h"
#define MAP_FILE_SIZE (4*1024*1024)
-struct util_stream
+struct os_stream
{
char filename[MAX_PATH + 1];
WCHAR wFileName[MAX_PATH + 1];
@@ -60,23 +58,23 @@ struct util_stream
static INLINE boolean
-util_stream_map(struct util_stream *stream)
+os_stream_map(struct os_stream *stream)
{
ULONG BytesInUnicodeString;
static char filename[MAX_PATH + 1];
unsigned filename_len;
if(stream->growable)
- filename_len = util_snprintf(filename,
- sizeof(filename),
- "%s.%04x",
- stream->filename,
- stream->suffix++);
+ filename_len = snprintf(filename,
+ sizeof(filename),
+ "%s.%04x",
+ stream->filename,
+ stream->suffix++);
else
- filename_len = util_snprintf(filename,
- sizeof(filename),
- "%s",
- stream->filename);
+ filename_len = snprintf(filename,
+ sizeof(filename),
+ "%s",
+ stream->filename);
EngMultiByteToUnicodeN(
stream->wFileName,
@@ -97,7 +95,7 @@ util_stream_map(struct util_stream *stream)
static INLINE void
-util_stream_unmap(struct util_stream *stream)
+os_stream_unmap(struct os_stream *stream)
{
EngUnmapFile(stream->iFile);
if(stream->written < stream->map_size) {
@@ -112,7 +110,7 @@ util_stream_unmap(struct util_stream *stream)
static INLINE void
-util_stream_full_qualified_filename(char *dst, size_t size, const char *src)
+os_stream_full_qualified_filename(char *dst, size_t size, const char *src)
{
boolean need_drive, need_root;
@@ -125,24 +123,24 @@ util_stream_full_qualified_filename(char *dst, size_t size, const char *src)
need_root = src[0] == '\\' ? FALSE : TRUE;
}
- util_snprintf(dst, size,
- "\\??\\%s%s%s",
- need_drive ? "C:" : "",
- need_root ? "\\" : "",
- src);
+ snprintf(dst, size,
+ "\\??\\%s%s%s",
+ need_drive ? "C:" : "",
+ need_root ? "\\" : "",
+ src);
}
-struct util_stream *
-util_stream_create(const char *filename, size_t max_size)
+struct os_stream *
+os_stream_create(const char *filename, size_t max_size)
{
- struct util_stream *stream;
+ struct os_stream *stream;
- stream = CALLOC_STRUCT(util_stream);
+ stream = CALLOC_STRUCT(os_stream);
if(!stream)
goto error1;
- util_stream_full_qualified_filename(stream->filename,
+ os_stream_full_qualified_filename(stream->filename,
sizeof(stream->filename),
filename);
@@ -155,7 +153,7 @@ util_stream_create(const char *filename, size_t max_size)
stream->map_size = MAP_FILE_SIZE;
}
- if(!util_stream_map(stream))
+ if(!os_stream_map(stream))
goto error2;
return stream;
@@ -168,7 +166,7 @@ error1:
static INLINE void
-util_stream_copy(struct util_stream *stream, const char *data, size_t size)
+os_stream_copy(struct os_stream *stream, const char *data, size_t size)
{
assert(stream->written + size <= stream->map_size);
memcpy(stream->pMap + stream->written, data, size);
@@ -177,7 +175,7 @@ util_stream_copy(struct util_stream *stream, const char *data, size_t size)
boolean
-util_stream_write(struct util_stream *stream, const void *data, size_t size)
+os_stream_write(struct os_stream *stream, const void *data, size_t size)
{
if(!stream)
return FALSE;
@@ -187,35 +185,35 @@ util_stream_write(struct util_stream *stream, const void *data, size_t size)
while(stream->written + size > stream->map_size) {
size_t step = stream->map_size - stream->written;
- util_stream_copy(stream, data, step);
+ os_stream_copy(stream, data, step);
data = (const char *)data + step;
size -= step;
- util_stream_unmap(stream);
- if(!stream->growable || !util_stream_map(stream))
+ os_stream_unmap(stream);
+ if(!stream->growable || !os_stream_map(stream))
return FALSE;
}
- util_stream_copy(stream, data, size);
+ os_stream_copy(stream, data, size);
return TRUE;
}
void
-util_stream_flush(struct util_stream *stream)
+os_stream_flush(struct os_stream *stream)
{
(void)stream;
}
void
-util_stream_close(struct util_stream *stream)
+os_stream_close(struct os_stream *stream)
{
if(!stream)
return;
- util_stream_unmap(stream);
+ os_stream_unmap(stream);
FREE(stream);
}
diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/auxiliary/os/os_thread.h
index 8119c1f571..24a2309976 100644
--- a/src/gallium/include/pipe/p_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -32,8 +32,8 @@
*/
-#ifndef _P_THREAD2_H_
-#define _P_THREAD2_H_
+#ifndef OS_THREAD_H_
+#define OS_THREAD_H_
#include "pipe/p_compiler.h"
@@ -235,6 +235,25 @@ static INLINE void pipe_barrier_wait(pipe_barrier *barrier)
/** Dummy definitions */
typedef unsigned pipe_thread;
+
+#define PIPE_THREAD_ROUTINE( name, param ) \
+ void * name( void *param )
+
+static INLINE pipe_thread pipe_thread_create( void *(* routine)( void *), void *param )
+{
+ return 0;
+}
+
+static INLINE int pipe_thread_wait( pipe_thread thread )
+{
+ return -1;
+}
+
+static INLINE int pipe_thread_destroy( pipe_thread thread )
+{
+ return -1;
+}
+
typedef unsigned pipe_mutex;
typedef unsigned pipe_condvar;
typedef unsigned pipe_barrier;
@@ -413,4 +432,4 @@ pipe_tsd_set(pipe_tsd *tsd, void *value)
-#endif /* _P_THREAD2_H_ */
+#endif /* OS_THREAD_H_ */
diff --git a/src/gallium/auxiliary/os/os_time.c b/src/gallium/auxiliary/os/os_time.c
new file mode 100644
index 0000000000..6259142bec
--- /dev/null
+++ b/src/gallium/auxiliary/os/os_time.c
@@ -0,0 +1,128 @@
+/**************************************************************************
+ *
+ * Copyright 2008-2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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
+ * OS independent time-manipulation functions.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include "pipe/p_config.h"
+
+#if !defined(PIPE_OS_EMBEDDED)
+
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
+# include <sys/time.h> /* timeval */
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+# include <windows.h>
+# include <winddi.h>
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+# include <windows.h>
+extern VOID KeQuerySystemTime(PLARGE_INTEGER);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+# include <windows.h>
+#else
+# error Unsupported OS
+#endif
+
+#include "os_time.h"
+
+
+int64_t
+os_time_get(void)
+{
+#if defined(PIPE_OS_UNIX)
+
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return tv.tv_usec + tv.tv_sec*1000000LL;
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+
+ static LONGLONG frequency;
+ LONGLONG counter;
+ if(!frequency)
+ EngQueryPerformanceFrequency(&frequency);
+ EngQueryPerformanceCounter(&counter);
+ return counter*INT64_C(1000000)/frequency;
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+
+ static LARGE_INTEGER frequency;
+ LARGE_INTEGER counter;
+ if(!frequency.QuadPart)
+ QueryPerformanceFrequency(&frequency);
+ QueryPerformanceCounter(&counter);
+ return counter.QuadPart*INT64_C(1000000)/frequency.QuadPart;
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+
+ /* Updated every 10 miliseconds, measured in units of 100 nanoseconds.
+ * http://msdn.microsoft.com/en-us/library/ms801642.aspx */
+ LARGE_INTEGER counter;
+ KeQuerySystemTime(&counter);
+ return counter.QuadPart/10;
+
+#endif
+}
+
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+
+void
+os_time_sleep(int64_t usecs)
+{
+ static LONGLONG frequency;
+ LONGLONG start, curr, end;
+
+ EngQueryPerformanceCounter(&start);
+
+ if(!frequency)
+ EngQueryPerformanceFrequency(&frequency);
+
+ end = start + (usecs * frequency + 999999LL)/1000000LL;
+
+ do {
+ EngQueryPerformanceCounter(&curr);
+ } while(start <= curr && curr < end ||
+ end < start && (curr < end || start <= curr));
+}
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+
+void
+os_time_sleep(int64_t usecs)
+{
+ Sleep((usecs + 999) / 1000);
+}
+
+#endif
+
+
+#endif /* !PIPE_OS_EMBEDDED */
diff --git a/src/gallium/drivers/nv10/nv10_surface.c b/src/gallium/auxiliary/os/os_time.h
index 5b52246a9c..5b55c1b374 100644
--- a/src/gallium/drivers/nv10/nv10_surface.c
+++ b/src/gallium/auxiliary/os/os_time.h
@@ -1,9 +1,8 @@
-
/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ *
+ * Copyright 2008-2010 VMware, Inc.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -11,53 +10,83 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
+ *
**************************************************************************/
-#include "nv10_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
-#include "util/u_tile.h"
-
-static void
-nv10_surface_copy(struct pipe_context *pipe,
- struct pipe_surface *dest, unsigned destx, unsigned desty,
- struct pipe_surface *src, unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
- struct nv04_surface_2d *eng2d = nv10->screen->eng2d;
+/**
+ * @file
+ * OS independent time-manipulation functions.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
- eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
-}
+#ifndef _OS_TIME_H_
+#define _OS_TIME_H_
-static void
-nv10_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
- unsigned destx, unsigned desty, unsigned width,
- unsigned height, unsigned value)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
- struct nv04_surface_2d *eng2d = nv10->screen->eng2d;
- eng2d->fill(eng2d, dest, destx, desty, width, height, value);
-}
+#include "pipe/p_config.h"
+
+#if defined(PIPE_OS_UNIX)
+# include <unistd.h> /* usleep */
+#endif
+#include "pipe/p_compiler.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Get the current time in microseconds from an unknown base.
+ */
+int64_t
+os_time_get(void);
+
+
+/*
+ * Sleep.
+ */
+#if defined(PIPE_OS_UNIX)
+#define os_time_sleep(_usecs) usleep(_usecs)
+#else
void
-nv10_init_surface_functions(struct nv10_context *nv10)
+os_time_sleep(int64_t usecs);
+#endif
+
+
+/*
+ * Helper function for detecting time outs, taking in account overflow.
+ *
+ * Returns true the the current time has elapsed beyond the specified interval.
+ */
+static INLINE boolean
+os_time_timeout(int64_t start,
+ int64_t end,
+ int64_t curr)
{
- nv10->pipe.surface_copy = nv10_surface_copy;
- nv10->pipe.surface_fill = nv10_surface_fill;
+ if(start <= end)
+ return !(start <= curr && curr < end);
+ else
+ return !((start <= curr) || (curr < end));
+}
+
+
+#ifdef __cplusplus
}
+#endif
+
+#endif /* _OS_TIME_H_ */
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index eb7e84be84..34b1b77df4 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -46,6 +46,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index ba087ac0f3..95eb5f6563 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -44,7 +44,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_defines.h"
#include "util/u_debug.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index 7b34c8e357..c1498318df 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -36,7 +36,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index 8f74180a11..93f8960641 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -35,7 +35,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index 6400fc5b0a..63195715d6 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -35,7 +35,7 @@
#include "pipe/p_defines.h"
#include "util/u_debug.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_mm.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
index 7fd65ed226..fea234ae8c 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
@@ -37,7 +37,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index d21910d0bf..c445cb578b 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -38,7 +38,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
diff --git a/src/gallium/auxiliary/rtasm/rtasm_execmem.c b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
index ffed768f97..65d5ce795b 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_execmem.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
@@ -32,7 +32,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_memory.h"
#include "rtasm_execmem.h"
@@ -58,7 +58,7 @@
#include <unistd.h>
#include <sys/mman.h>
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_mm.h"
#define EXEC_HEAP_SIZE (10*1024*1024)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index fbb9aa0e63..f7a1bb74a9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -264,6 +264,12 @@ static void
micro_rcp(union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src)
{
+#if 0 /* for debugging */
+ assert(src->f[0] != 0.0f);
+ assert(src->f[1] != 0.0f);
+ assert(src->f[2] != 0.0f);
+ assert(src->f[3] != 0.0f);
+#endif
dst->f[0] = 1.0f / src->f[0];
dst->f[1] = 1.0f / src->f[1];
dst->f[2] = 1.0f / src->f[2];
@@ -284,6 +290,12 @@ static void
micro_rsq(union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src)
{
+#if 0 /* for debugging */
+ assert(src->f[0] != 0.0f);
+ assert(src->f[1] != 0.0f);
+ assert(src->f[2] != 0.0f);
+ assert(src->f[3] != 0.0f);
+#endif
dst->f[0] = 1.0f / sqrtf(fabsf(src->f[0]));
dst->f[1] = 1.0f / sqrtf(fabsf(src->f[1]));
dst->f[2] = 1.0f / sqrtf(fabsf(src->f[2]));
@@ -450,12 +462,20 @@ static const union tgsi_exec_channel ZeroVec =
{ { 0.0, 0.0, 0.0, 0.0 } };
-#define CHECK_INF_OR_NAN(chan) do {\
- assert(!util_is_inf_or_nan((chan)->f[0]));\
- assert(!util_is_inf_or_nan((chan)->f[1]));\
- assert(!util_is_inf_or_nan((chan)->f[2]));\
- assert(!util_is_inf_or_nan((chan)->f[3]));\
- } while (0)
+/**
+ * Assert that none of the float values in 'chan' are infinite or NaN.
+ * NaN and Inf may occur normally during program execution and should
+ * not lead to crashes, etc. But when debugging, it's helpful to catch
+ * them.
+ */
+static INLINE void
+check_inf_or_nan(const union tgsi_exec_channel *chan)
+{
+ assert(!util_is_inf_or_nan((chan)->f[0]));
+ assert(!util_is_inf_or_nan((chan)->f[1]));
+ assert(!util_is_inf_or_nan((chan)->f[2]));
+ assert(!util_is_inf_or_nan((chan)->f[3]));
+}
#ifdef DEBUG
@@ -1219,8 +1239,9 @@ store_dest(struct tgsi_exec_machine *mach,
int offset = 0; /* indirection offset */
int index;
- if (dst_datatype == TGSI_EXEC_DATA_FLOAT) {
- CHECK_INF_OR_NAN(chan);
+ /* for debugging */
+ if (0 && dst_datatype == TGSI_EXEC_DATA_FLOAT) {
+ check_inf_or_nan(chan);
}
/* There is an extra source register that indirectly subscripts
@@ -1478,7 +1499,7 @@ emit_primitive(struct tgsi_exec_machine *mach)
}
/*
- * Fetch a four texture samples using STR texture coordinates.
+ * Fetch four texture samples using STR texture coordinates.
*/
static void
fetch_texel( struct tgsi_sampler *sampler,
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c
index fd37fc3079..7e19e1fe36 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c
@@ -284,3 +284,14 @@ tgsi_dup_tokens(const struct tgsi_token *tokens)
memcpy(new_tokens, tokens, bytes);
return new_tokens;
}
+
+
+/**
+ * Allocate memory for num_tokens tokens.
+ */
+struct tgsi_token *
+tgsi_alloc_tokens(unsigned num_tokens)
+{
+ unsigned bytes = num_tokens * sizeof(struct tgsi_token);
+ return (struct tgsi_token *) MALLOC(bytes);
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.h b/src/gallium/auxiliary/tgsi/tgsi_parse.h
index 8150e3cd29..b45ccee2f6 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.h
@@ -130,6 +130,10 @@ tgsi_num_tokens(const struct tgsi_token *tokens);
struct tgsi_token *
tgsi_dup_tokens(const struct tgsi_token *tokens);
+struct tgsi_token *
+tgsi_alloc_tokens(unsigned num_tokens);
+
+
#if defined __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 96be353e26..f918151daa 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -29,7 +29,7 @@
#include "util/u_memory.h"
#include "util/u_prim.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "tgsi_text.h"
#include "tgsi_build.h"
#include "tgsi_info.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 0ae46785bb..27960bac22 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -33,6 +33,7 @@
#include "tgsi/tgsi_info.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_sanity.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_math.h"
@@ -103,6 +104,8 @@ struct ureg_program
struct {
unsigned index;
+ unsigned semantic_name;
+ unsigned semantic_index;
} gs_input[UREG_MAX_INPUT];
unsigned nr_gs_inputs;
@@ -325,10 +328,14 @@ ureg_DECL_vs_input( struct ureg_program *ureg,
struct ureg_src
ureg_DECL_gs_input(struct ureg_program *ureg,
- unsigned index)
+ unsigned index,
+ unsigned semantic_name,
+ unsigned semantic_index)
{
if (ureg->nr_gs_inputs < UREG_MAX_INPUT) {
ureg->gs_input[ureg->nr_gs_inputs].index = index;
+ ureg->gs_input[ureg->nr_gs_inputs].semantic_name = semantic_name;
+ ureg->gs_input[ureg->nr_gs_inputs].semantic_index = semantic_index;
ureg->nr_gs_inputs++;
} else {
set_bad(ureg);
@@ -1251,10 +1258,12 @@ static void emit_decls( struct ureg_program *ureg )
}
} else {
for (i = 0; i < ureg->nr_gs_inputs; i++) {
- emit_decl_range(ureg,
- TGSI_FILE_INPUT,
- ureg->gs_input[i].index,
- 1);
+ emit_decl(ureg,
+ TGSI_FILE_INPUT,
+ ureg->gs_input[i].index,
+ ureg->gs_input[i].semantic_name,
+ ureg->gs_input[i].semantic_index,
+ TGSI_INTERPOLATE_CONSTANT);
}
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index e25f35c6dc..6be66d0694 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -30,6 +30,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_debug.h"
#ifdef __cplusplus
extern "C" {
@@ -160,7 +161,9 @@ ureg_DECL_vs_input( struct ureg_program *,
struct ureg_src
ureg_DECL_gs_input(struct ureg_program *,
- unsigned index);
+ unsigned index,
+ unsigned semantic_name,
+ unsigned semantic_index);
struct ureg_src
ureg_DECL_system_value(struct ureg_program *,
diff --git a/src/gallium/auxiliary/util/u_atomic.h b/src/gallium/auxiliary/util/u_atomic.h
new file mode 100644
index 0000000000..540112f7f3
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_atomic.h
@@ -0,0 +1,271 @@
+/**
+ * Many similar implementations exist. See for example libwsbm
+ * or the linux kernel include/atomic.h
+ *
+ * No copyright claimed on this file.
+ *
+ */
+
+#ifndef U_ATOMIC_H
+#define U_ATOMIC_H
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
+
+/* Favor OS-provided implementations.
+ *
+ * Where no OS-provided implementation is available, fall back to
+ * locally coded assembly, compiler intrinsic or ultimately a
+ * mutex-based implementation.
+ */
+#if (defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \
+ defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT))
+#define PIPE_ATOMIC_OS_UNLOCKED
+#elif defined(PIPE_CC_MSVC)
+#define PIPE_ATOMIC_MSVC_INTRINSIC
+#elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86))
+#define PIPE_ATOMIC_ASM_MSVC_X86
+#elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86))
+#define PIPE_ATOMIC_ASM_GCC_X86
+#elif defined(PIPE_CC_GCC)
+#define PIPE_ATOMIC_GCC_INTRINSIC
+#else
+#error "Unsupported platform"
+#endif
+
+
+
+#if defined(PIPE_ATOMIC_ASM_GCC_X86)
+
+#define PIPE_ATOMIC "GCC x86 assembly"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define p_atomic_set(_v, _i) (*(_v) = (_i))
+#define p_atomic_read(_v) (*(_v))
+
+static INLINE boolean
+p_atomic_dec_zero(int32_t *v)
+{
+ unsigned char c;
+
+ __asm__ __volatile__("lock; decl %0; sete %1":"+m"(*v), "=qm"(c)
+ ::"memory");
+
+ return c != 0;
+}
+
+static INLINE void
+p_atomic_inc(int32_t *v)
+{
+ __asm__ __volatile__("lock; incl %0":"+m"(*v));
+}
+
+static INLINE void
+p_atomic_dec(int32_t *v)
+{
+ __asm__ __volatile__("lock; decl %0":"+m"(*v));
+}
+
+static INLINE int32_t
+p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
+{
+ return __sync_val_compare_and_swap(v, old, _new);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+
+/* Implementation using GCC-provided synchronization intrinsics
+ */
+#if defined(PIPE_ATOMIC_GCC_INTRINSIC)
+
+#define PIPE_ATOMIC "GCC Sync Intrinsics"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define p_atomic_set(_v, _i) (*(_v) = (_i))
+#define p_atomic_read(_v) (*(_v))
+
+static INLINE boolean
+p_atomic_dec_zero(int32_t *v)
+{
+ return (__sync_sub_and_fetch(v, 1) == 0);
+}
+
+static INLINE void
+p_atomic_inc(int32_t *v)
+{
+ (void) __sync_add_and_fetch(v, 1);
+}
+
+static INLINE void
+p_atomic_dec(int32_t *v)
+{
+ (void) __sync_sub_and_fetch(v, 1);
+}
+
+static INLINE int32_t
+p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
+{
+ return __sync_val_compare_and_swap(v, old, _new);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+
+/* Unlocked version for single threaded environments, such as some
+ * windows kernel modules.
+ */
+#if defined(PIPE_ATOMIC_OS_UNLOCKED)
+
+#define PIPE_ATOMIC "Unlocked"
+
+#define p_atomic_set(_v, _i) (*(_v) = (_i))
+#define p_atomic_read(_v) (*(_v))
+#define p_atomic_dec_zero(_v) ((boolean) --(*(_v)))
+#define p_atomic_inc(_v) ((void) (*(_v))++)
+#define p_atomic_dec(_v) ((void) (*(_v))--)
+#define p_atomic_cmpxchg(_v, old, _new) (*(_v) == old ? *(_v) = (_new) : *(_v))
+
+#endif
+
+
+/* Locally coded assembly for MSVC on x86:
+ */
+#if defined(PIPE_ATOMIC_ASM_MSVC_X86)
+
+#define PIPE_ATOMIC "MSVC x86 assembly"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define p_atomic_set(_v, _i) (*(_v) = (_i))
+#define p_atomic_read(_v) (*(_v))
+
+static INLINE boolean
+p_atomic_dec_zero(int32_t *v)
+{
+ unsigned char c;
+
+ __asm {
+ mov eax, [v]
+ lock dec dword ptr [eax]
+ sete byte ptr [c]
+ }
+
+ return c != 0;
+}
+
+static INLINE void
+p_atomic_inc(int32_t *v)
+{
+ __asm {
+ mov eax, [v]
+ lock inc dword ptr [eax]
+ }
+}
+
+static INLINE void
+p_atomic_dec(int32_t *v)
+{
+ __asm {
+ mov eax, [v]
+ lock dec dword ptr [eax]
+ }
+}
+
+static INLINE int32_t
+p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
+{
+ int32_t orig;
+
+ __asm {
+ mov ecx, [v]
+ mov eax, [old]
+ mov edx, [_new]
+ lock cmpxchg [ecx], edx
+ mov [orig], eax
+ }
+
+ return orig;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+#if defined(PIPE_ATOMIC_MSVC_INTRINSIC)
+
+#define PIPE_ATOMIC "MSVC Intrinsics"
+
+#include <intrin.h>
+
+#pragma intrinsic(_InterlockedIncrement)
+#pragma intrinsic(_InterlockedDecrement)
+#pragma intrinsic(_InterlockedCompareExchange)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define p_atomic_set(_v, _i) (*(_v) = (_i))
+#define p_atomic_read(_v) (*(_v))
+
+static INLINE boolean
+p_atomic_dec_zero(int32_t *v)
+{
+ return _InterlockedDecrement((long *)v) == 0;
+}
+
+static INLINE void
+p_atomic_inc(int32_t *v)
+{
+ _InterlockedIncrement((long *)v);
+}
+
+static INLINE void
+p_atomic_dec(int32_t *v)
+{
+ _InterlockedDecrement((long *)v);
+}
+
+static INLINE int32_t
+p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
+{
+ return _InterlockedCompareExchange((long *)v, _new, old);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+
+#ifndef PIPE_ATOMIC
+#error "No pipe_atomic implementation selected"
+#endif
+
+
+
+#endif /* U_ATOMIC_H */
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index eb63bec7b5..f0bc58a558 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -36,7 +36,7 @@
#include "pipe/p_context.h"
#include "util/u_debug.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_state.h"
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 935e11c5d8..f3b4491d17 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -34,7 +34,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_state.h"
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 7ee0864d29..4821b8a143 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -29,125 +29,30 @@
#include "pipe/p_config.h"
-#include <stdarg.h>
-
-
-#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
-
-#include <windows.h>
-#include <winddi.h>
-
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE)
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-#include <types.h>
-
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-#endif
-#include <windows.h>
-#include <stdio.h>
-
-#else
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#endif
-
-#include "pipe/p_compiler.h"
+#include "pipe/p_compiler.h"
+#include "os/os_stream.h"
#include "util/u_debug.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_string.h"
-#include "util/u_stream.h"
#include "util/u_math.h"
#include "util/u_tile.h"
#include "util/u_prim.h"
-#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
-static INLINE void
-_EngDebugPrint(const char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
- EngDebugPrint("", (PCHAR)format, ap);
- va_end(ap);
-}
-#endif
-
-
void _debug_vprintf(const char *format, va_list ap)
{
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
- /* EngDebugPrint does not handle float point arguments, so we need to use
- * our own vsnprintf implementation. It is also very slow, so buffer until
- * we find a newline. */
- static char buf[512] = {'\0'};
- size_t len = strlen(buf);
- int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
- if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
- _EngDebugPrint("%s", buf);
- buf[0] = '\0';
- }
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- /* OutputDebugStringA can be very slow, so buffer until we find a newline. */
+ /* We buffer until we find a newline. */
static char buf[4096] = {'\0'};
size_t len = strlen(buf);
int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
- OutputDebugStringA(buf);
+ os_log_message(buf);
buf[0] = '\0';
}
-
- if(GetConsoleWindow() && !IsDebuggerPresent()) {
- fflush(stdout);
- vfprintf(stderr, format, ap);
- fflush(stderr);
- }
-
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE)
- wchar_t *wide_format;
- long wide_str_len;
- char buf[512];
- int ret;
-#if (_WIN32_WCE < 600)
- ret = vsprintf(buf, format, ap);
- if(ret < 0){
- sprintf(buf, "Cant handle debug print!");
- ret = 25;
- }
-#else
- ret = vsprintf_s(buf, 512, format, ap);
- if(ret < 0){
- sprintf_s(buf, 512, "Cant handle debug print!");
- ret = 25;
- }
-#endif
- buf[ret] = '\0';
- /* Format is ascii - needs to be converted to wchar_t for printing */
- wide_str_len = MultiByteToWideChar(CP_ACP, 0, (const char *) buf, -1, NULL, 0);
- wide_format = (wchar_t *) malloc((wide_str_len+1) * sizeof(wchar_t));
- if (wide_format) {
- MultiByteToWideChar(CP_ACP, 0, (const char *) buf, -1,
- wide_format, wide_str_len);
- NKDbgPrintfW(wide_format, wide_format);
- free(wide_format);
- }
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
- /* TODO */
-#else /* !PIPE_SUBSYSTEM_WINDOWS */
- fflush(stdout);
- vfprintf(stderr, format, ap);
-#endif
}
@@ -169,108 +74,12 @@ void debug_print_blob( const char *name,
#endif
-#ifndef debug_break
-void debug_break(void)
-{
-#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- DebugBreak();
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
- EngDebugBreak();
-#else
- abort();
-#endif
-}
-#endif
-
-
-#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
-static const char *
-find(const char *start, const char *end, char c)
-{
- const char *p;
- for(p = start; !end || p != end; ++p) {
- if(*p == c)
- return p;
- if(*p < 32)
- break;
- }
- return NULL;
-}
-
-static int
-compare(const char *start, const char *end, const char *s)
-{
- const char *p, *q;
- for(p = start, q = s; p != end && *q != '\0'; ++p, ++q) {
- if(*p != *q)
- return 0;
- }
- return p == end && *q == '\0';
-}
-
-static void
-copy(char *dst, const char *start, const char *end, size_t n)
-{
- const char *p;
- char *q;
- for(p = start, q = dst, n = n - 1; p != end && n; ++p, ++q, --n)
- *q = *p;
- *q = '\0';
-}
-#endif
-
-
-static INLINE const char *
-_debug_get_option(const char *name)
-{
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
- /* EngMapFile creates the file if it does not exists, so it must either be
- * disabled on release versions (or put in a less conspicuous place). */
-#ifdef DEBUG
- const char *result = NULL;
- ULONG_PTR iFile = 0;
- const void *pMap = NULL;
- const char *sol, *eol, *sep;
- static char output[1024];
-
- pMap = EngMapFile(L"\\??\\c:\\gallium.cfg", 0, &iFile);
- if(pMap) {
- sol = (const char *)pMap;
- while(1) {
- /* TODO: handle LF line endings */
- eol = find(sol, NULL, '\r');
- if(!eol || eol == sol)
- break;
- sep = find(sol, eol, '=');
- if(!sep)
- break;
- if(compare(sol, sep, name)) {
- copy(output, sep + 1, eol, sizeof(output));
- result = output;
- break;
- }
- sol = eol + 2;
- }
- EngUnmapFile(iFile);
- }
- return result;
-#else
- return NULL;
-#endif
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
- /* TODO: implement */
- return NULL;
-#else
- return getenv(name);
-#endif
-}
-
const char *
debug_get_option(const char *name, const char *dfault)
{
const char *result;
- result = _debug_get_option(name);
+ result = os_get_option(name);
if(!result)
result = dfault;
@@ -282,7 +91,7 @@ debug_get_option(const char *name, const char *dfault)
boolean
debug_get_bool_option(const char *name, boolean dfault)
{
- const char *str = _debug_get_option(name);
+ const char *str = os_get_option(name);
boolean result;
if(str == NULL)
@@ -312,7 +121,7 @@ debug_get_num_option(const char *name, long dfault)
long result;
const char *str;
- str = _debug_get_option(name);
+ str = os_get_option(name);
if(!str)
result = dfault;
else {
@@ -348,7 +157,7 @@ debug_get_flags_option(const char *name,
unsigned long result;
const char *str;
- str = _debug_get_option(name);
+ str = os_get_option(name);
if(!str)
result = dfault;
else if (!util_strcmp(str, "help")) {
@@ -389,7 +198,7 @@ void _debug_assert_fail(const char *expr,
#else
if (debug_get_bool_option("GALLIUM_ABORT_ON_ASSERT", TRUE))
#endif
- debug_break();
+ os_abort();
else
_debug_printf("continuing...\n");
}
@@ -872,7 +681,7 @@ debug_dump_float_rgba_bmp(const char *filename,
float *rgba, unsigned stride)
{
#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
- struct util_stream *stream;
+ struct os_stream *stream;
struct bmp_file_header bmfh;
struct bmp_info_header bmih;
unsigned x, y;
@@ -898,12 +707,12 @@ debug_dump_float_rgba_bmp(const char *filename,
bmih.biClrUsed = 0;
bmih.biClrImportant = 0;
- stream = util_stream_create(filename, bmfh.bfSize);
+ stream = os_stream_create(filename, bmfh.bfSize);
if(!stream)
goto error1;
- util_stream_write(stream, &bmfh, 14);
- util_stream_write(stream, &bmih, 40);
+ os_stream_write(stream, &bmfh, 14);
+ os_stream_write(stream, &bmih, 40);
y = height;
while(y--) {
@@ -915,11 +724,11 @@ debug_dump_float_rgba_bmp(const char *filename,
pixel.rgbGreen = float_to_ubyte(ptr[x*4 + 1]);
pixel.rgbBlue = float_to_ubyte(ptr[x*4 + 2]);
pixel.rgbAlpha = 255;
- util_stream_write(stream, &pixel, 4);
+ os_stream_write(stream, &pixel, 4);
}
}
- util_stream_close(stream);
+ os_stream_close(stream);
error1:
;
#endif
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index 131c991539..efcf065d27 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -39,9 +39,7 @@
#define U_DEBUG_H_
-#include <stdarg.h>
-
-#include "pipe/p_compiler.h"
+#include "os/os_misc.h"
#ifdef __cplusplus
@@ -49,22 +47,6 @@ extern "C" {
#endif
-#if defined(DBG) || defined(DEBUG)
-#ifndef DEBUG
-#define DEBUG 1
-#endif
-#else
-#ifndef NDEBUG
-#define NDEBUG 1
-#endif
-#endif
-
-
-/* MSVC bebore VC7 does not have the __FUNCTION__ macro */
-#if defined(_MSC_VER) && _MSC_VER < 1300
-#define __FUNCTION__ "???"
-#endif
-
#if defined(__GNUC__)
#define _util_printf_format(fmt, list) __attribute__ ((format (printf, fmt, list)))
#else
@@ -155,13 +137,7 @@ void debug_print_format(const char *msg, unsigned fmt );
* Hard-coded breakpoint.
*/
#ifdef DEBUG
-#if (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)) && defined(PIPE_CC_GCC)
-#define debug_break() __asm("int3")
-#elif defined(PIPE_CC_MSVC)
-#define debug_break() __debugbreak()
-#else
-void debug_break(void);
-#endif
+#define debug_break() os_break()
#else /* !DEBUG */
#define debug_break() ((void)0)
#endif /* !DEBUG */
@@ -328,22 +304,6 @@ debug_get_flags_option(const char *name,
unsigned long dfault);
-void *
-debug_malloc(const char *file, unsigned line, const char *function,
- size_t size);
-
-void
-debug_free(const char *file, unsigned line, const char *function,
- void *ptr);
-
-void *
-debug_calloc(const char *file, unsigned line, const char *function,
- size_t count, size_t size );
-
-void *
-debug_realloc(const char *file, unsigned line, const char *function,
- void *old_ptr, size_t old_size, size_t new_size );
-
unsigned long
debug_memory_begin(void);
diff --git a/src/gallium/auxiliary/util/u_debug_memory.c b/src/gallium/auxiliary/util/u_debug_memory.c
index d6484f4ad5..f1baa62f89 100644
--- a/src/gallium/auxiliary/util/u_debug_memory.c
+++ b/src/gallium/auxiliary/util/u_debug_memory.c
@@ -34,15 +34,10 @@
#include "pipe/p_config.h"
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-#include <windows.h>
-#include <winddi.h>
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
-#include <wdm.h>
-#else
-#include <stdio.h>
-#include <stdlib.h>
-#endif
+#define DEBUG_MEMORY_IMPLEMENTATION
+
+#include "os/os_memory.h"
+#include "os/os_memory_debug.h"
#include "util/u_debug.h"
#include "util/u_debug_stack.h"
@@ -53,18 +48,6 @@
#define DEBUG_MEMORY_STACK 0 /* XXX: disabled until we have symbol lookup */
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
-#define real_malloc(_size) EngAllocMem(0, _size, 'D3AG')
-#define real_free(_ptr) EngFreeMem(_ptr)
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
-#define real_malloc(_size) ExAllocatePool(0, _size)
-#define real_free(_ptr) ExFreePool(_ptr)
-#else
-#define real_malloc(_size) malloc(_size)
-#define real_free(_ptr) free(_ptr)
-#endif
-
-
struct debug_memory_header
{
struct list_head head;
@@ -127,7 +110,7 @@ debug_malloc(const char *file, unsigned line, const char *function,
struct debug_memory_header *hdr;
struct debug_memory_footer *ftr;
- hdr = real_malloc(sizeof(*hdr) + size + sizeof(*ftr));
+ hdr = os_malloc(sizeof(*hdr) + size + sizeof(*ftr));
if(!hdr) {
debug_printf("%s:%u:%s: out of memory when trying to allocate %lu bytes\n",
file, line, function,
@@ -185,7 +168,7 @@ debug_free(const char *file, unsigned line, const char *function,
hdr->magic = 0;
ftr->magic = 0;
- real_free(hdr);
+ os_free(hdr);
}
void *
@@ -232,7 +215,7 @@ debug_realloc(const char *file, unsigned line, const char *function,
}
/* alloc new */
- new_hdr = real_malloc(sizeof(*new_hdr) + new_size + sizeof(*new_ftr));
+ new_hdr = os_malloc(sizeof(*new_hdr) + new_size + sizeof(*new_ftr));
if(!new_hdr) {
debug_printf("%s:%u:%s: out of memory when trying to allocate %lu bytes\n",
file, line, function,
@@ -258,7 +241,7 @@ debug_realloc(const char *file, unsigned line, const char *function,
/* free old */
old_hdr->magic = 0;
old_ftr->magic = 0;
- real_free(old_hdr);
+ os_free(old_hdr);
return new_ptr;
}
diff --git a/src/gallium/auxiliary/util/u_dl.c b/src/gallium/auxiliary/util/u_dl.c
index d8803f77fa..37ed789f95 100644
--- a/src/gallium/auxiliary/util/u_dl.c
+++ b/src/gallium/auxiliary/util/u_dl.c
@@ -26,8 +26,9 @@
*
**************************************************************************/
+
#include "pipe/p_config.h"
-#include "util/u_debug.h"
+#include "pipe/p_compiler.h"
#if defined(PIPE_OS_UNIX)
#include <dlfcn.h>
@@ -43,12 +44,7 @@ struct util_dl_library *
util_dl_open(const char *filename)
{
#if defined(PIPE_OS_UNIX)
- struct util_dl_library *lib;
- lib = (struct util_dl_library *)dlopen(filename, RTLD_LAZY | RTLD_GLOBAL);
- if (!lib) {
- debug_printf("gallium: dlopen() failed: %s\n", dlerror());
- }
- return lib;
+ return (struct util_dl_library *)dlopen(filename, RTLD_LAZY | RTLD_GLOBAL);
#elif defined(PIPE_OS_WINDOWS)
return (struct util_dl_library *)LoadLibraryA(filename);
#else
diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c
index e2e23c3cdd..14506e8451 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.c
+++ b/src/gallium/auxiliary/util/u_draw_quad.c
@@ -28,7 +28,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_draw_quad.h"
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index a558923b2e..4323bc881b 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -31,6 +31,7 @@
#include "pipe/p_format.h"
+#include "util/u_debug.h"
#ifdef __cplusplus
extern "C" {
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 8611231ed7..4e358d3938 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -37,7 +37,7 @@
#include "pipe/p_context.h"
#include "util/u_debug.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_state.h"
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index 72f5c1dc2a..e95d58ea86 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -25,12 +25,15 @@
*
**************************************************************************/
-#ifndef P_INLINES_H
-#define P_INLINES_H
+#ifndef U_INLINES_H
+#define U_INLINES_H
-#include "p_context.h"
-#include "p_defines.h"
-#include "p_screen.h"
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
+#include "pipe/p_screen.h"
+#include "util/u_debug.h"
+#include "util/u_atomic.h"
#ifdef __cplusplus
@@ -38,7 +41,84 @@ extern "C" {
#endif
+/*
+ * Reference counting helper functions.
+ */
+
+
+static INLINE void
+pipe_reference_init(struct pipe_reference *reference, unsigned count)
+{
+ p_atomic_set(&reference->count, count);
+}
+
+static INLINE boolean
+pipe_is_referenced(struct pipe_reference *reference)
+{
+ return p_atomic_read(&reference->count) != 0;
+}
+
/**
+ * Update reference counting.
+ * The old thing pointed to, if any, will be unreferenced.
+ * Both 'ptr' and 'reference' may be NULL.
+ * \return TRUE if the object's refcount hits zero and should be destroyed.
+ */
+static INLINE boolean
+pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
+{
+ boolean destroy = FALSE;
+
+ if(ptr != reference) {
+ /* bump the reference.count first */
+ if (reference) {
+ assert(pipe_is_referenced(reference));
+ p_atomic_inc(&reference->count);
+ }
+
+ if (ptr) {
+ assert(pipe_is_referenced(ptr));
+ if (p_atomic_dec_zero(&ptr->count)) {
+ destroy = TRUE;
+ }
+ }
+ }
+
+ return destroy;
+}
+
+static INLINE void
+pipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf)
+{
+ struct pipe_buffer *old_buf = *ptr;
+
+ if (pipe_reference(&(*ptr)->reference, &buf->reference))
+ old_buf->screen->buffer_destroy(old_buf);
+ *ptr = buf;
+}
+
+static INLINE void
+pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
+{
+ struct pipe_surface *old_surf = *ptr;
+
+ if (pipe_reference(&(*ptr)->reference, &surf->reference))
+ old_surf->texture->screen->tex_surface_destroy(old_surf);
+ *ptr = surf;
+}
+
+static INLINE void
+pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
+{
+ struct pipe_texture *old_tex = *ptr;
+
+ if (pipe_reference(&(*ptr)->reference, &tex->reference))
+ old_tex->screen->texture_destroy(old_tex);
+ *ptr = tex;
+}
+
+
+/*
* Convenience wrappers for screen buffer functions.
*/
@@ -221,4 +301,4 @@ pipe_transfer_buffer_flags( struct pipe_transfer *transf )
}
#endif
-#endif /* P_INLINES_H */
+#endif /* U_INLINES_H */
diff --git a/src/gallium/auxiliary/util/u_keymap.c b/src/gallium/auxiliary/util/u_keymap.c
index c4b9eb3d9b..e161ccd88e 100644
--- a/src/gallium/auxiliary/util/u_keymap.c
+++ b/src/gallium/auxiliary/util/u_keymap.c
@@ -36,7 +36,6 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
-#include "pipe/p_defines.h"
#include "cso_cache/cso_hash.h"
diff --git a/src/gallium/auxiliary/util/u_memory.h b/src/gallium/auxiliary/util/u_memory.h
index c3f8c91833..a2fc597356 100644
--- a/src/gallium/auxiliary/util/u_memory.h
+++ b/src/gallium/auxiliary/util/u_memory.h
@@ -26,7 +26,7 @@
**************************************************************************/
-/**
+/*
* Memory functions
*/
@@ -37,6 +37,7 @@
#include "util/u_pointer.h"
#include "util/u_debug.h"
+#include "os/os_memory.h"
#ifdef __cplusplus
@@ -44,114 +45,13 @@ extern "C" {
#endif
-/* Define ENOMEM for WINCE */
-#if (_WIN32_WCE < 600)
-#ifndef ENOMEM
-#define ENOMEM 12
-#endif
-#endif
-
-
-#if defined(PIPE_OS_WINDOWS) && defined(DEBUG)
-
-/* memory debugging */
-
-#include "util/u_debug.h"
-
-#define MALLOC( _size ) \
- debug_malloc( __FILE__, __LINE__, __FUNCTION__, _size )
-#define CALLOC( _count, _size ) \
- debug_calloc(__FILE__, __LINE__, __FUNCTION__, _count, _size )
-#define FREE( _ptr ) \
- debug_free( __FILE__, __LINE__, __FUNCTION__, _ptr )
-#define REALLOC( _ptr, _old_size, _size ) \
- debug_realloc( __FILE__, __LINE__, __FUNCTION__, _ptr, _old_size, _size )
-
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-
-void * __stdcall
-EngAllocMem(
- unsigned long Flags,
- unsigned long MemSize,
- unsigned long Tag );
-
-void __stdcall
-EngFreeMem(
- void *Mem );
-
-#define MALLOC( _size ) EngAllocMem( 0, _size, 'D3AG' )
-#define _FREE( _ptr ) EngFreeMem( _ptr )
-
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
-
-void *
-ExAllocatePool(
- unsigned long PoolType,
- size_t NumberOfBytes);
-
-void
-ExFreePool(void *P);
-
-#define MALLOC(_size) ExAllocatePool(0, _size)
-#define _FREE(_ptr) ExFreePool(_ptr)
-
-#else
-
-#define MALLOC( SIZE ) malloc( SIZE )
-#define CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
-#define FREE( PTR ) free( PTR )
-
-static INLINE void *
-_REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
-{
- (void) old_size;
- return realloc(old_ptr, new_size);
-}
-#define REALLOC( a, b, c ) _REALLOC( a, b, c )
-#endif
-
-
-#ifndef CALLOC
-static INLINE void *
-CALLOC( unsigned count, unsigned size )
-{
- void *ptr = MALLOC( count * size );
- if( ptr ) {
- memset( ptr, 0, count * size );
- }
- return ptr;
-}
-#endif /* !CALLOC */
+#define MALLOC(_size) os_malloc(_size)
-#ifndef FREE
-static INLINE void
-FREE( void *ptr )
-{
- if( ptr ) {
- _FREE( ptr );
- }
-}
-#endif /* !FREE */
+#define CALLOC(_count, _size) os_calloc(_count, _size)
-#ifndef REALLOC
-static INLINE void *
-REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
-{
- void *new_ptr = NULL;
-
- if (new_size != 0) {
- unsigned copy_size = old_size < new_size ? old_size : new_size;
- new_ptr = MALLOC( new_size );
- if (new_ptr && old_ptr && copy_size) {
- memcpy( new_ptr, old_ptr, copy_size );
- }
- }
-
- FREE( old_ptr );
- return new_ptr;
-}
-#endif /* !REALLOC */
+#define FREE(_ptr ) os_free(_ptr)
+#define REALLOC(_ptr, _old_size, _size) os_realloc(_ptr, _old_size, _size)
#define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))
@@ -160,50 +60,8 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
#define CALLOC_VARIANT_LENGTH_STRUCT(T,more_size) ((struct T *) CALLOC(1, sizeof(struct T) + more_size))
-/**
- * Return memory on given byte alignment
- */
-static INLINE void *
-align_malloc(size_t bytes, uint alignment)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
- void *mem;
- alignment = (alignment + (uint)sizeof(void*) - 1) & ~((uint)sizeof(void*) - 1);
- if(posix_memalign(& mem, alignment, bytes) != 0)
- return NULL;
- return mem;
-#else
- char *ptr, *buf;
-
- assert( alignment > 0 );
-
- ptr = (char *) MALLOC(bytes + alignment + sizeof(void *));
- if (!ptr)
- return NULL;
-
- buf = (char *) align_pointer( ptr + sizeof(void *), alignment );
- *(char **)(buf - sizeof(void *)) = ptr;
-
- return buf;
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-/**
- * Free memory returned by align_malloc().
- */
-static INLINE void
-align_free(void *ptr)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
- FREE(ptr);
-#else
- if (ptr) {
- void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
- void *realAddr = *cubbyHole;
- FREE(realAddr);
- }
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
+#define align_malloc(_size, _alignment) os_malloc_aligned(_size, _alignment)
+#define align_free(_ptr) os_free_aligned(_ptr)
/**
diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h
index 10a874f341..64390e1385 100644
--- a/src/gallium/auxiliary/util/u_prim.h
+++ b/src/gallium/auxiliary/util/u_prim.h
@@ -30,12 +30,13 @@
#define U_BLIT_H
+#include "pipe/p_defines.h"
+#include "util/u_debug.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-#include "pipe/p_defines.h"
-
static INLINE boolean u_validate_pipe_prim( unsigned pipe_prim, unsigned nr )
{
boolean ok = TRUE;
diff --git a/src/gallium/auxiliary/util/u_ringbuffer.c b/src/gallium/auxiliary/util/u_ringbuffer.c
index e73ba0b348..648b105b13 100644
--- a/src/gallium/auxiliary/util/u_ringbuffer.c
+++ b/src/gallium/auxiliary/util/u_ringbuffer.c
@@ -1,5 +1,5 @@
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "pipe/p_defines.h"
#include "util/u_ringbuffer.h"
#include "util/u_math.h"
diff --git a/src/gallium/auxiliary/util/u_simple_screen.c b/src/gallium/auxiliary/util/u_simple_screen.c
index 5238299015..53f3c16dbc 100644
--- a/src/gallium/auxiliary/util/u_simple_screen.c
+++ b/src/gallium/auxiliary/util/u_simple_screen.c
@@ -29,7 +29,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
static struct pipe_buffer *
diff --git a/src/gallium/auxiliary/util/u_simple_screen.h b/src/gallium/auxiliary/util/u_simple_screen.h
index 6612a8a7c0..bb3f5ba102 100644
--- a/src/gallium/auxiliary/util/u_simple_screen.h
+++ b/src/gallium/auxiliary/util/u_simple_screen.h
@@ -28,8 +28,145 @@
#ifndef U_SIMPLE_SCREEN_H
#define U_SIMPLE_SCREEN_H
+#include "pipe/p_format.h"
+
struct pipe_screen;
-struct pipe_winsys;
+struct pipe_fence_handle;
+struct pipe_surface;
+struct pipe_buffer;
+
+/**
+ * Gallium3D drivers are (meant to be!) independent of both GL and the
+ * window system. The window system provides a buffer manager and a
+ * set of additional hooks for things like command buffer submission,
+ * etc.
+ *
+ * There clearly has to be some agreement between the window system
+ * driver and the hardware driver about the format of command buffers,
+ * etc.
+ */
+struct pipe_winsys
+{
+ void (*destroy)( struct pipe_winsys *ws );
+
+ /** Returns name of this winsys interface */
+ const char *(*get_name)( struct pipe_winsys *ws );
+
+ /**
+ * Do any special operations to ensure buffer size is correct
+ */
+ void (*update_buffer)( struct pipe_winsys *ws,
+ void *context_private );
+ /**
+ * Do any special operations to ensure frontbuffer contents are
+ * displayed, eg copy fake frontbuffer.
+ */
+ void (*flush_frontbuffer)( struct pipe_winsys *ws,
+ struct pipe_surface *surf,
+ void *context_private );
+
+
+ /**
+ * Buffer management. Buffer attributes are mostly fixed over its lifetime.
+ *
+ * Remember that gallium gets to choose the interface it needs, and the
+ * window systems must then implement that interface (rather than the
+ * other way around...).
+ *
+ * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
+ * usage argument is only an optimization hint, not a guarantee, therefore
+ * proper behavior must be observed in all circumstances.
+ *
+ * alignment indicates the client's alignment requirements, eg for
+ * SSE instructions.
+ */
+ struct pipe_buffer *(*buffer_create)( struct pipe_winsys *ws,
+ unsigned alignment,
+ unsigned usage,
+ unsigned size );
+
+ /**
+ * Create a buffer that wraps user-space data.
+ *
+ * Effectively this schedules a delayed call to buffer_create
+ * followed by an upload of the data at *some point in the future*,
+ * or perhaps never. Basically the allocate/upload is delayed
+ * until the buffer is actually passed to hardware.
+ *
+ * The intention is to provide a quick way to turn regular data
+ * into a buffer, and secondly to avoid a copy operation if that
+ * data subsequently turns out to be only accessed by the CPU.
+ *
+ * Common example is OpenGL vertex buffers that are subsequently
+ * processed either by software TNL in the driver or by passing to
+ * hardware.
+ *
+ * XXX: What happens if the delayed call to buffer_create() fails?
+ *
+ * Note that ptr may be accessed at any time upto the time when the
+ * buffer is destroyed, so the data must not be freed before then.
+ */
+ struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *ws,
+ void *ptr,
+ unsigned bytes);
+
+ /**
+ * Allocate storage for a display target surface.
+ *
+ * Often surfaces which are meant to be blitted to the front screen (i.e.,
+ * display targets) must be allocated with special characteristics, memory
+ * pools, or obtained directly from the windowing system.
+ *
+ * This callback is invoked by the pipe_screenwhen creating a texture marked
+ * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
+ * buffer storage.
+ */
+ struct pipe_buffer *(*surface_buffer_create)(struct pipe_winsys *ws,
+ unsigned width, unsigned height,
+ enum pipe_format format,
+ unsigned usage,
+ unsigned tex_usage,
+ unsigned *stride);
+
+
+ /**
+ * Map the entire data store of a buffer object into the client's address.
+ * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
+ */
+ void *(*buffer_map)( struct pipe_winsys *ws,
+ struct pipe_buffer *buf,
+ unsigned usage );
+
+ void (*buffer_unmap)( struct pipe_winsys *ws,
+ struct pipe_buffer *buf );
+
+ void (*buffer_destroy)( struct pipe_buffer *buf );
+
+
+ /** Set ptr = fence, with reference counting */
+ void (*fence_reference)( struct pipe_winsys *ws,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence );
+
+ /**
+ * Checks whether the fence has been signalled.
+ * \param flags driver-specific meaning
+ * \return zero on success.
+ */
+ int (*fence_signalled)( struct pipe_winsys *ws,
+ struct pipe_fence_handle *fence,
+ unsigned flag );
+
+ /**
+ * Wait for the fence to finish.
+ * \param flags driver-specific meaning
+ * \return zero on success.
+ */
+ int (*fence_finish)( struct pipe_winsys *ws,
+ struct pipe_fence_handle *fence,
+ unsigned flag );
+
+};
/**
* The following function initializes a simple passthrough screen.
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index b751e29ab6..019dda767d 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -38,6 +38,7 @@
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_simple_shaders.h"
+#include "util/u_debug.h"
#include "tgsi/tgsi_ureg.h"
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index 70de140ec9..c9f1c9c210 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -35,6 +35,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_surface.h"
diff --git a/src/gallium/auxiliary/util/u_texture.c b/src/gallium/auxiliary/util/u_texture.c
index cd477ab640..d97e57a790 100644
--- a/src/gallium/auxiliary/util/u_texture.c
+++ b/src/gallium/auxiliary/util/u_texture.c
@@ -37,6 +37,7 @@
#include "pipe/p_defines.h"
+#include "util/u_debug.h"
#include "util/u_texture.h"
void util_map_texcoords2d_onto_cubemap(unsigned face,
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index c25e1e52e9..0051258e22 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -32,7 +32,7 @@
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c
deleted file mode 100644
index b958a98635..0000000000
--- a/src/gallium/auxiliary/util/u_time.c
+++ /dev/null
@@ -1,225 +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
- * OS independent time-manipulation functions.
- *
- * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-
-#include "pipe/p_config.h"
-
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
-#include <sys/time.h>
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-#include <windows.h>
-#include <winddi.h>
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
-#include <windows.h>
-extern VOID KeQuerySystemTime(PLARGE_INTEGER);
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
-#include <windows.h>
-#else
-#error Unsupported OS
-#endif
-
-#include "util/u_time.h"
-
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
-
-static int64_t frequency = 0;
-
-static INLINE void
-util_time_get_frequency(void)
-{
- if(!frequency) {
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
- LONGLONG temp;
- EngQueryPerformanceFrequency(&temp);
- frequency = temp;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
- LARGE_INTEGER temp;
- QueryPerformanceFrequency(&temp);
- frequency = temp.QuadPart;
-#endif
- }
-}
-#endif
-
-
-void
-util_time_get(struct util_time *t)
-{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- gettimeofday(&t->tv, NULL);
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
- LONGLONG temp;
- EngQueryPerformanceCounter(&temp);
- t->counter = temp;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
- /* Updated every 10 miliseconds, measured in units of 100 nanoseconds.
- * http://msdn.microsoft.com/en-us/library/ms801642.aspx */
- LARGE_INTEGER temp;
- KeQuerySystemTime(&temp);
- t->counter = temp.QuadPart;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
- LARGE_INTEGER temp;
- QueryPerformanceCounter(&temp);
- t->counter = temp.QuadPart;
-#endif
-}
-
-
-void
-util_time_add(const struct util_time *t1,
- int64_t usecs,
- struct util_time *t2)
-{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- t2->tv.tv_sec = t1->tv.tv_sec + usecs / 1000000;
- t2->tv.tv_usec = t1->tv.tv_usec + usecs % 1000000;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
- util_time_get_frequency();
- t2->counter = t1->counter + (usecs * frequency + INT64_C(999999))/INT64_C(1000000);
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
- /* 1 tick = 100 nano seconds. */
- t2->counter = t1->counter + usecs * 10;
-#else
- LARGE_INTEGER temp;
- LONGLONG freq;
- freq = temp.QuadPart;
- t2->counter = t1->counter + (usecs * freq)/1000000L;
-#endif
-}
-
-
-int64_t
-util_time_diff(const struct util_time *t1,
- const struct util_time *t2)
-{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- return (t2->tv.tv_usec - t1->tv.tv_usec) +
- (t2->tv.tv_sec - t1->tv.tv_sec)*1000000;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
- util_time_get_frequency();
- return (t2->counter - t1->counter)*INT64_C(1000000)/frequency;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
- return (t2->counter - t1->counter)/10;
-#endif
-}
-
-
-
-uint64_t
-util_time_micros( void )
-{
- struct util_time t1;
-
- util_time_get(&t1);
-
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- return t1.tv.tv_usec + t1.tv.tv_sec*1000000LL;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
- util_time_get_frequency();
- return t1.counter*INT64_C(1000000)/frequency;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
- return t1.counter/10;
-#endif
-}
-
-
-
-/**
- * Compare two time values.
- *
- * Not publicly available because it does not take in account wrap-arounds.
- * Use util_time_timeout instead.
- */
-static INLINE int
-util_time_compare(const struct util_time *t1,
- const struct util_time *t2)
-{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- if (t1->tv.tv_sec < t2->tv.tv_sec)
- return -1;
- else if(t1->tv.tv_sec > t2->tv.tv_sec)
- return 1;
- else if (t1->tv.tv_usec < t2->tv.tv_usec)
- return -1;
- else if(t1->tv.tv_usec > t2->tv.tv_usec)
- return 1;
- else
- return 0;
-#elif defined(PIPE_OS_WINDOWS)
- if (t1->counter < t2->counter)
- return -1;
- else if(t1->counter > t2->counter)
- return 1;
- else
- return 0;
-#endif
-}
-
-
-boolean
-util_time_timeout(const struct util_time *start,
- const struct util_time *end,
- const struct util_time *curr)
-{
- if(util_time_compare(start, end) <= 0)
- return !(util_time_compare(start, curr) <= 0 && util_time_compare(curr, end) < 0);
- else
- return !(util_time_compare(start, curr) <= 0 || util_time_compare(curr, end) < 0);
-}
-
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-void util_time_sleep(unsigned usecs)
-{
- LONGLONG start, curr, end;
-
- EngQueryPerformanceCounter(&start);
-
- if(!frequency)
- EngQueryPerformanceFrequency(&frequency);
-
- end = start + (usecs * frequency + 999999LL)/1000000LL;
-
- do {
- EngQueryPerformanceCounter(&curr);
- } while(start <= curr && curr < end ||
- end < start && (curr < end || start <= curr));
-}
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-void util_time_sleep(unsigned usecs)
-{
- Sleep((usecs + 999)/ 1000);
-}
-#endif
diff --git a/src/gallium/auxiliary/util/u_time.h b/src/gallium/auxiliary/util/u_time.h
index 29fd1cbc67..15899c2c88 100644
--- a/src/gallium/auxiliary/util/u_time.h
+++ b/src/gallium/auxiliary/util/u_time.h
@@ -38,15 +38,7 @@
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE)
-#include <time.h> /* timeval */
-#include <unistd.h> /* usleep */
-#endif
-
-#if defined(PIPE_OS_HAIKU)
-#include <sys/time.h> /* timeval */
-#include <unistd.h>
-#endif
+#include "os/os_time.h"
#include "pipe/p_compiler.h"
@@ -63,52 +55,92 @@ extern "C" {
*/
struct util_time
{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- struct timeval tv;
-#else
int64_t counter;
-#endif
};
-void
-util_time_get(struct util_time *t);
+PIPE_DEPRECATED
+static INLINE void
+util_time_get(struct util_time *t)
+{
+ t->counter = os_time_get();
+}
+
/**
* Return t2 = t1 + usecs
*/
-void
+PIPE_DEPRECATED
+static INLINE void
util_time_add(const struct util_time *t1,
int64_t usecs,
- struct util_time *t2);
+ struct util_time *t2)
+{
+ t2->counter = t1->counter + usecs;
+}
-/**
- * Return current time in microseconds
- */
-uint64_t
-util_time_micros( void );
/**
* Return difference between times, in microseconds
*/
-int64_t
+PIPE_DEPRECATED
+static INLINE int64_t
util_time_diff(const struct util_time *t1,
- const struct util_time *t2);
+ const struct util_time *t2)
+{
+ return t2->counter - t1->counter;
+}
+
+
+/**
+ * Compare two time values.
+ *
+ * Not publicly available because it does not take in account wrap-arounds.
+ * Use util_time_timeout instead.
+ */
+static INLINE int
+_util_time_compare(const struct util_time *t1,
+ const struct util_time *t2)
+{
+ if (t1->counter < t2->counter)
+ return -1;
+ else if(t1->counter > t2->counter)
+ return 1;
+ else
+ return 0;
+}
+
/**
* Returns non-zero when the timeout expires.
*/
-boolean
+PIPE_DEPRECATED
+static INLINE boolean
util_time_timeout(const struct util_time *start,
const struct util_time *end,
- const struct util_time *curr);
+ const struct util_time *curr)
+{
+ return os_time_timeout(start->counter, end->counter, curr->counter);
+}
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
-#define util_time_sleep usleep
-#else
-void
-util_time_sleep(unsigned usecs);
-#endif
+
+/**
+ * Return current time in microseconds
+ */
+PIPE_DEPRECATED
+static INLINE int64_t
+util_time_micros(void)
+{
+ return os_time_get();
+}
+
+
+PIPE_DEPRECATED
+static INLINE void
+util_time_sleep(int64_t usecs)
+{
+ os_time_sleep(usecs);
+}
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/util/u_timed_winsys.c b/src/gallium/auxiliary/util/u_timed_winsys.c
index 178acdca4d..59bdcd2c45 100644
--- a/src/gallium/auxiliary/util/u_timed_winsys.c
+++ b/src/gallium/auxiliary/util/u_timed_winsys.c
@@ -30,7 +30,7 @@
*/
#include "pipe/p_state.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "u_timed_winsys.h"
#include "util/u_memory.h"
#include "util/u_time.h"
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index 55a65375c8..012b2ae233 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -30,7 +30,7 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "util/u_math.h"
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index a524e2fdfb..6c5298daab 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -28,7 +28,7 @@
#include "vl_compositor.h"
#include <assert.h>
#include <pipe/p_context.h>
-#include <pipe/p_inlines.h>
+#include <util/u_inlines.h>
#include <tgsi/tgsi_parse.h>
#include <tgsi/tgsi_build.h>
#include <util/u_memory.h>
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
index e43187545c..c2552f40b4 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -28,7 +28,7 @@
#include "vl_mpeg12_mc_renderer.h"
#include <assert.h>
#include <pipe/p_context.h>
-#include <pipe/p_inlines.h>
+#include <util/u_inlines.h>
#include <util/u_format.h>
#include <util/u_math.h>
#include <util/u_memory.h>
diff --git a/src/gallium/docs/source/conf.py b/src/gallium/docs/source/conf.py
index 9b0c86babd..59c19ed98d 100644
--- a/src/gallium/docs/source/conf.py
+++ b/src/gallium/docs/source/conf.py
@@ -16,13 +16,13 @@ import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.append(os.path.abspath('.'))
+sys.path.append(os.path.abspath('exts'))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.pngmath']
+extensions = ['sphinx.ext.pngmath', 'tgsi']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst
index 0ef9fe2645..100afe3397 100644
--- a/src/gallium/docs/source/distro.rst
+++ b/src/gallium/docs/source/distro.rst
@@ -31,21 +31,6 @@ Wrapper driver.
LLVM Softpipe
^^^^^^^^^^^^^
-nVidia nv04
-^^^^^^^^^^^
-
-Deprecated.
-
-nVidia nv10
-^^^^^^^^^^^
-
-Deprecated.
-
-nVidia nv20
-^^^^^^^^^^^
-
-Deprecated.
-
nVidia nv30
^^^^^^^^^^^
@@ -103,6 +88,22 @@ Xorg XFree86 DDX
Auxiliary
---------
+OS
+^^
+
+The OS module contains the abstractions for basic operating system services:
+
+* memory allocation
+* simple message logging
+* obtaining run-time configuration option
+* threading primitives
+
+This is the bare minimum required to port Gallium to a new platform.
+
+The OS module already provides the implementations of these abstractions for
+the most common platforms. When targeting an embedded platform no
+implementation will be provided -- these must be provided separately.
+
CSO Cache
^^^^^^^^^
diff --git a/src/gallium/docs/source/exts/tgsi.py b/src/gallium/docs/source/exts/tgsi.py
new file mode 100644
index 0000000000..e92cd5c4d1
--- /dev/null
+++ b/src/gallium/docs/source/exts/tgsi.py
@@ -0,0 +1,17 @@
+# tgsi.py
+# Sphinx extension providing formatting for TGSI opcodes
+# (c) Corbin Simpson 2010
+
+import docutils.nodes
+import sphinx.addnodes
+
+def parse_opcode(env, sig, signode):
+ opcode, desc = sig.split("-", 1)
+ opcode = opcode.strip().upper()
+ desc = " (%s)" % desc.strip()
+ signode += sphinx.addnodes.desc_name(opcode, opcode)
+ signode += sphinx.addnodes.desc_annotation(desc, desc)
+ return opcode
+
+def setup(app):
+ app.add_description_unit("opcode", "opcode", "%s (TGSI opcode)", parse_opcode)
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index 3e57a282fd..55a4c6990d 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -227,7 +227,7 @@ buffer_map
Map a buffer into memory.
-**usage** is a bitmask of :ref:`PIPE_TEXTURE_USAGE` flags.
+**usage** is a bitmask of :ref:`PIPE_BUFFER_USAGE` flags.
Returns a pointer to the map, or NULL if the mapping failed.
@@ -248,7 +248,7 @@ Flush a range of mapped memory into a buffer.
The buffer must have been mapped with ``PIPE_BUFFER_USAGE_FLUSH_EXPLICIT``.
-**usage** is a bitmask of :ref:`PIPE_TEXTURE_USAGE` flags.
+**usage** is a bitmask of :ref:`PIPE_BUFFER_USAGE` flags.
buffer_unmap
^^^^^^^^^^^^
diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
index 3e702ceeda..5478d86667 100644
--- a/src/gallium/docs/source/tgsi.rst
+++ b/src/gallium/docs/source/tgsi.rst
@@ -6,6 +6,23 @@ for describing shaders. Since Gallium is inherently shaderful, shaders are
an important part of the API. TGSI is the only intermediate representation
used by all drivers.
+Basics
+------
+
+All TGSI instructions, known as *opcodes*, operate on arbitrary-precision
+floating-point four-component vectors. An opcode may have up to one
+destination register, known as *dst*, and between zero and three source
+registers, called *src0* through *src2*, or simply *src* if there is only
+one.
+
+Some instructions, like :opcode:`I2F`, permit re-interpretation of vector
+components as integers. Other instructions permit using registers as
+two-component vectors with double precision; see :ref:`Double Opcodes`.
+
+When an instruction has a scalar result, the result is usually copied into
+each of the components of *dst*. When this happens, the result is said to be
+*replicated* to *dst*. :opcode:`RCP` is one such instruction.
+
Instruction Set
---------------
@@ -13,7 +30,7 @@ From GL_NV_vertex_program
^^^^^^^^^^^^^^^^^^^^^^^^^
-ARL - Address Register Load
+.. opcode:: ARL - Address Register Load
.. math::
@@ -26,7 +43,7 @@ ARL - Address Register Load
dst.w = \lfloor src.w\rfloor
-MOV - Move
+.. opcode:: MOV - Move
.. math::
@@ -39,7 +56,7 @@ MOV - Move
dst.w = src.w
-LIT - Light Coefficients
+.. opcode:: LIT - Light Coefficients
.. math::
@@ -52,33 +69,25 @@ LIT - Light Coefficients
dst.w = 1
-RCP - Reciprocal
-
-.. math::
+.. opcode:: RCP - Reciprocal
- dst.x = \frac{1}{src.x}
+This instruction replicates its result.
- dst.y = \frac{1}{src.x}
+.. math::
- dst.z = \frac{1}{src.x}
+ dst = \frac{1}{src.x}
- dst.w = \frac{1}{src.x}
+.. opcode:: RSQ - Reciprocal Square Root
-RSQ - Reciprocal Square Root
+This instruction replicates its result.
.. math::
- dst.x = \frac{1}{\sqrt{|src.x|}}
-
- dst.y = \frac{1}{\sqrt{|src.x|}}
-
- dst.z = \frac{1}{\sqrt{|src.x|}}
+ dst = \frac{1}{\sqrt{|src.x|}}
- dst.w = \frac{1}{\sqrt{|src.x|}}
-
-EXP - Approximate Exponential Base 2
+.. opcode:: EXP - Approximate Exponential Base 2
.. math::
@@ -91,7 +100,7 @@ EXP - Approximate Exponential Base 2
dst.w = 1
-LOG - Approximate Logarithm Base 2
+.. opcode:: LOG - Approximate Logarithm Base 2
.. math::
@@ -104,7 +113,7 @@ LOG - Approximate Logarithm Base 2
dst.w = 1
-MUL - Multiply
+.. opcode:: MUL - Multiply
.. math::
@@ -117,7 +126,7 @@ MUL - Multiply
dst.w = src0.w \times src1.w
-ADD - Add
+.. opcode:: ADD - Add
.. math::
@@ -130,33 +139,25 @@ ADD - Add
dst.w = src0.w + src1.w
-DP3 - 3-component Dot Product
-
-.. math::
+.. opcode:: DP3 - 3-component Dot Product
- dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
+This instruction replicates its result.
- dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
+.. math::
- dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
+ dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
- dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
+.. opcode:: DP4 - 4-component Dot Product
-DP4 - 4-component Dot Product
+This instruction replicates its result.
.. math::
- dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
-
- dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
+ dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
- dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
- dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
-
-
-DST - Distance Vector
+.. opcode:: DST - Distance Vector
.. math::
@@ -169,7 +170,7 @@ DST - Distance Vector
dst.w = src1.w
-MIN - Minimum
+.. opcode:: MIN - Minimum
.. math::
@@ -182,7 +183,7 @@ MIN - Minimum
dst.w = min(src0.w, src1.w)
-MAX - Maximum
+.. opcode:: MAX - Maximum
.. math::
@@ -195,7 +196,7 @@ MAX - Maximum
dst.w = max(src0.w, src1.w)
-SLT - Set On Less Than
+.. opcode:: SLT - Set On Less Than
.. math::
@@ -208,7 +209,7 @@ SLT - Set On Less Than
dst.w = (src0.w < src1.w) ? 1 : 0
-SGE - Set On Greater Equal Than
+.. opcode:: SGE - Set On Greater Equal Than
.. math::
@@ -221,7 +222,7 @@ SGE - Set On Greater Equal Than
dst.w = (src0.w >= src1.w) ? 1 : 0
-MAD - Multiply And Add
+.. opcode:: MAD - Multiply And Add
.. math::
@@ -234,7 +235,7 @@ MAD - Multiply And Add
dst.w = src0.w \times src1.w + src2.w
-SUB - Subtract
+.. opcode:: SUB - Subtract
.. math::
@@ -247,7 +248,7 @@ SUB - Subtract
dst.w = src0.w - src1.w
-LRP - Linear Interpolate
+.. opcode:: LRP - Linear Interpolate
.. math::
@@ -260,7 +261,7 @@ LRP - Linear Interpolate
dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
-CND - Condition
+.. opcode:: CND - Condition
.. math::
@@ -273,7 +274,7 @@ CND - Condition
dst.w = (src2.w > 0.5) ? src0.w : src1.w
-DP2A - 2-component Dot Product And Add
+.. opcode:: DP2A - 2-component Dot Product And Add
.. math::
@@ -286,7 +287,7 @@ DP2A - 2-component Dot Product And Add
dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
-FRAC - Fraction
+.. opcode:: FRAC - Fraction
.. math::
@@ -299,7 +300,7 @@ FRAC - Fraction
dst.w = src.w - \lfloor src.w\rfloor
-CLAMP - Clamp
+.. opcode:: CLAMP - Clamp
.. math::
@@ -312,9 +313,9 @@ CLAMP - Clamp
dst.w = clamp(src0.w, src1.w, src2.w)
-FLR - Floor
+.. opcode:: FLR - Floor
-This is identical to ARL.
+This is identical to :opcode:`ARL`.
.. math::
@@ -327,7 +328,7 @@ This is identical to ARL.
dst.w = \lfloor src.w\rfloor
-ROUND - Round
+.. opcode:: ROUND - Round
.. math::
@@ -340,45 +341,33 @@ ROUND - Round
dst.w = round(src.w)
-EX2 - Exponential Base 2
+.. opcode:: EX2 - Exponential Base 2
-.. math::
+This instruction replicates its result.
- dst.x = 2^{src.x}
-
- dst.y = 2^{src.x}
+.. math::
- dst.z = 2^{src.x}
+ dst = 2^{src.x}
- dst.w = 2^{src.x}
+.. opcode:: LG2 - Logarithm Base 2
-LG2 - Logarithm Base 2
+This instruction replicates its result.
.. math::
- dst.x = \log_2{src.x}
-
- dst.y = \log_2{src.x}
-
- dst.z = \log_2{src.x}
+ dst = \log_2{src.x}
- dst.w = \log_2{src.x}
+.. opcode:: POW - Power
-POW - Power
+This instruction replicates its result.
.. math::
- dst.x = src0.x^{src1.x}
+ dst = src0.x^{src1.x}
- dst.y = src0.x^{src1.x}
-
- dst.z = src0.x^{src1.x}
-
- dst.w = src0.x^{src1.x}
-
-XPD - Cross Product
+.. opcode:: XPD - Cross Product
.. math::
@@ -391,7 +380,7 @@ XPD - Cross Product
dst.w = 1
-ABS - Absolute
+.. opcode:: ABS - Absolute
.. math::
@@ -404,48 +393,36 @@ ABS - Absolute
dst.w = |src.w|
-RCC - Reciprocal Clamped
+.. opcode:: RCC - Reciprocal Clamped
+
+This instruction replicates its result.
XXX cleanup on aisle three
.. math::
- dst.x = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
-
- dst.y = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
-
- dst.z = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
+ dst = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
- dst.w = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
+.. opcode:: DPH - Homogeneous Dot Product
-DPH - Homogeneous Dot Product
+This instruction replicates its result.
.. math::
- dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
+ dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
- dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
- dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
+.. opcode:: COS - Cosine
- dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
-
-
-COS - Cosine
+This instruction replicates its result.
.. math::
- dst.x = \cos{src.x}
-
- dst.y = \cos{src.x}
-
- dst.z = \cos{src.x}
+ dst = \cos{src.x}
- dst.w = \cos{src.x}
-
-DDX - Derivative Relative To X
+.. opcode:: DDX - Derivative Relative To X
.. math::
@@ -458,7 +435,7 @@ DDX - Derivative Relative To X
dst.w = partialx(src.w)
-DDY - Derivative Relative To Y
+.. opcode:: DDY - Derivative Relative To Y
.. math::
@@ -471,32 +448,32 @@ DDY - Derivative Relative To Y
dst.w = partialy(src.w)
-KILP - Predicated Discard
+.. opcode:: KILP - Predicated Discard
discard
-PK2H - Pack Two 16-bit Floats
+.. opcode:: PK2H - Pack Two 16-bit Floats
TBD
-PK2US - Pack Two Unsigned 16-bit Scalars
+.. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
TBD
-PK4B - Pack Four Signed 8-bit Scalars
+.. opcode:: PK4B - Pack Four Signed 8-bit Scalars
TBD
-PK4UB - Pack Four Unsigned 8-bit Scalars
+.. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
TBD
-RFL - Reflection Vector
+.. opcode:: RFL - Reflection Vector
.. math::
@@ -508,10 +485,12 @@ RFL - Reflection Vector
dst.w = 1
-Considered for removal.
+.. note::
+
+ Considered for removal.
-SEQ - Set On Equal
+.. opcode:: SEQ - Set On Equal
.. math::
@@ -524,21 +503,20 @@ SEQ - Set On Equal
dst.w = (src0.w == src1.w) ? 1 : 0
-SFL - Set On False
+.. opcode:: SFL - Set On False
-.. math::
+This instruction replicates its result.
- dst.x = 0
+.. math::
- dst.y = 0
+ dst = 0
- dst.z = 0
+.. note::
- dst.w = 0
+ Considered for removal.
-Considered for removal.
-SGT - Set On Greater Than
+.. opcode:: SGT - Set On Greater Than
.. math::
@@ -551,20 +529,16 @@ SGT - Set On Greater Than
dst.w = (src0.w > src1.w) ? 1 : 0
-SIN - Sine
+.. opcode:: SIN - Sine
-.. math::
+This instruction replicates its result.
- dst.x = \sin{src.x}
-
- dst.y = \sin{src.x}
-
- dst.z = \sin{src.x}
+.. math::
- dst.w = \sin{src.x}
+ dst = \sin{src.x}
-SLE - Set On Less Equal Than
+.. opcode:: SLE - Set On Less Equal Than
.. math::
@@ -577,7 +551,7 @@ SLE - Set On Less Equal Than
dst.w = (src0.w <= src1.w) ? 1 : 0
-SNE - Set On Not Equal
+.. opcode:: SNE - Set On Not Equal
.. math::
@@ -590,59 +564,63 @@ SNE - Set On Not Equal
dst.w = (src0.w != src1.w) ? 1 : 0
-STR - Set On True
+.. opcode:: STR - Set On True
-.. math::
+This instruction replicates its result.
- dst.x = 1
-
- dst.y = 1
-
- dst.z = 1
+.. math::
- dst.w = 1
+ dst = 1
-TEX - Texture Lookup
+.. opcode:: TEX - Texture Lookup
TBD
-TXD - Texture Lookup with Derivatives
+.. opcode:: TXD - Texture Lookup with Derivatives
TBD
-TXP - Projective Texture Lookup
+.. opcode:: TXP - Projective Texture Lookup
TBD
-UP2H - Unpack Two 16-Bit Floats
+.. opcode:: UP2H - Unpack Two 16-Bit Floats
TBD
- Considered for removal.
+.. note::
-UP2US - Unpack Two Unsigned 16-Bit Scalars
+ Considered for removal.
+
+.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
TBD
- Considered for removal.
+.. note::
+
+ Considered for removal.
-UP4B - Unpack Four Signed 8-Bit Values
+.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
TBD
- Considered for removal.
+.. note::
+
+ Considered for removal.
-UP4UB - Unpack Four Unsigned 8-Bit Scalars
+.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
TBD
- Considered for removal.
+.. note::
-X2D - 2D Coordinate Transformation
+ Considered for removal.
+
+.. opcode:: X2D - 2D Coordinate Transformation
.. math::
@@ -654,20 +632,24 @@ X2D - 2D Coordinate Transformation
dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
-Considered for removal.
+.. note::
+
+ Considered for removal.
From GL_NV_vertex_program2
^^^^^^^^^^^^^^^^^^^^^^^^^^
-ARA - Address Register Add
+.. opcode:: ARA - Address Register Add
TBD
- Considered for removal.
+.. note::
-ARR - Address Register Load With Round
+ Considered for removal.
+
+.. opcode:: ARR - Address Register Load With Round
.. math::
@@ -680,26 +662,28 @@ ARR - Address Register Load With Round
dst.w = round(src.w)
-BRA - Branch
+.. opcode:: BRA - Branch
pc = target
- Considered for removal.
+.. note::
+
+ Considered for removal.
-CAL - Subroutine Call
+.. opcode:: CAL - Subroutine Call
push(pc)
pc = target
-RET - Subroutine Call Return
+.. opcode:: RET - Subroutine Call Return
pc = pop()
Potential restrictions:
* Only occurs at end of function.
-SSG - Set Sign
+.. opcode:: SSG - Set Sign
.. math::
@@ -712,7 +696,7 @@ SSG - Set Sign
dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
-CMP - Compare
+.. opcode:: CMP - Compare
.. math::
@@ -725,7 +709,7 @@ CMP - Compare
dst.w = (src0.w < 0) ? src1.w : src2.w
-KIL - Conditional Discard
+.. opcode:: KIL - Conditional Discard
.. math::
@@ -734,7 +718,7 @@ KIL - Conditional Discard
endif
-SCS - Sine Cosine
+.. opcode:: SCS - Sine Cosine
.. math::
@@ -747,12 +731,12 @@ SCS - Sine Cosine
dst.y = 1
-TXB - Texture Lookup With Bias
+.. opcode:: TXB - Texture Lookup With Bias
TBD
-NRM - 3-component Vector Normalise
+.. opcode:: NRM - 3-component Vector Normalise
.. math::
@@ -765,7 +749,7 @@ NRM - 3-component Vector Normalise
dst.w = 1
-DIV - Divide
+.. opcode:: DIV - Divide
.. math::
@@ -778,35 +762,31 @@ DIV - Divide
dst.w = \frac{src0.w}{src1.w}
-DP2 - 2-component Dot Product
-
-.. math::
-
- dst.x = src0.x \times src1.x + src0.y \times src1.y
+.. opcode:: DP2 - 2-component Dot Product
- dst.y = src0.x \times src1.x + src0.y \times src1.y
+This instruction replicates its result.
- dst.z = src0.x \times src1.x + src0.y \times src1.y
+.. math::
- dst.w = src0.x \times src1.x + src0.y \times src1.y
+ dst = src0.x \times src1.x + src0.y \times src1.y
-TXL - Texture Lookup With LOD
+.. opcode:: TXL - Texture Lookup With LOD
TBD
-BRK - Break
+.. opcode:: BRK - Break
TBD
-IF - If
+.. opcode:: IF - If
TBD
-BGNFOR - Begin a For-Loop
+.. opcode:: BGNFOR - Begin a For-Loop
dst.x = floor(src.x)
dst.y = floor(src.y)
@@ -819,25 +799,31 @@ BGNFOR - Begin a For-Loop
Note: The destination must be a loop register.
The source must be a constant register.
- Considered for cleanup / removal.
+.. note::
+ Considered for cleanup.
-REP - Repeat
+.. note::
+
+ Considered for removal.
+
+
+.. opcode:: REP - Repeat
TBD
-ELSE - Else
+.. opcode:: ELSE - Else
TBD
-ENDIF - End If
+.. opcode:: ENDIF - End If
TBD
-ENDFOR - End a For-Loop
+.. opcode:: ENDFOR - End a For-Loop
dst.x = dst.x + dst.z
dst.y = dst.y - 1.0
@@ -848,30 +834,48 @@ ENDFOR - End a For-Loop
Note: The destination must be a loop register.
- Considered for cleanup / removal.
+.. note::
+
+ Considered for cleanup.
+
+.. note::
-ENDREP - End Repeat
+ Considered for removal.
+
+.. opcode:: ENDREP - End Repeat
TBD
-PUSHA - Push Address Register On Stack
+.. opcode:: PUSHA - Push Address Register On Stack
push(src.x)
push(src.y)
push(src.z)
push(src.w)
- Considered for cleanup / removal.
+.. note::
+
+ Considered for cleanup.
+
+.. note::
-POPA - Pop Address Register From Stack
+ Considered for removal.
+
+.. opcode:: POPA - Pop Address Register From Stack
dst.w = pop()
dst.z = pop()
dst.y = pop()
dst.x = pop()
- Considered for cleanup / removal.
+.. note::
+
+ Considered for cleanup.
+
+.. note::
+
+ Considered for removal.
From GL_NV_gpu_program4
@@ -879,7 +883,7 @@ From GL_NV_gpu_program4
Support for these opcodes indicated by a special pipe capability bit (TBD).
-CEIL - Ceiling
+.. opcode:: CEIL - Ceiling
.. math::
@@ -892,7 +896,7 @@ CEIL - Ceiling
dst.w = \lceil src.w\rceil
-I2F - Integer To Float
+.. opcode:: I2F - Integer To Float
.. math::
@@ -905,7 +909,7 @@ I2F - Integer To Float
dst.w = (float) src.w
-NOT - Bitwise Not
+.. opcode:: NOT - Bitwise Not
.. math::
@@ -918,7 +922,7 @@ NOT - Bitwise Not
dst.w = ~src.w
-TRUNC - Truncate
+.. opcode:: TRUNC - Truncate
.. math::
@@ -931,7 +935,7 @@ TRUNC - Truncate
dst.w = trunc(src.w)
-SHL - Shift Left
+.. opcode:: SHL - Shift Left
.. math::
@@ -944,7 +948,7 @@ SHL - Shift Left
dst.w = src0.w << src1.x
-SHR - Shift Right
+.. opcode:: SHR - Shift Right
.. math::
@@ -957,7 +961,7 @@ SHR - Shift Right
dst.w = src0.w >> src1.x
-AND - Bitwise And
+.. opcode:: AND - Bitwise And
.. math::
@@ -970,7 +974,7 @@ AND - Bitwise And
dst.w = src0.w & src1.w
-OR - Bitwise Or
+.. opcode:: OR - Bitwise Or
.. math::
@@ -983,7 +987,7 @@ OR - Bitwise Or
dst.w = src0.w | src1.w
-MOD - Modulus
+.. opcode:: MOD - Modulus
.. math::
@@ -996,7 +1000,7 @@ MOD - Modulus
dst.w = src0.w \bmod src1.w
-XOR - Bitwise Xor
+.. opcode:: XOR - Bitwise Xor
.. math::
@@ -1009,7 +1013,7 @@ XOR - Bitwise Xor
dst.w = src0.w \oplus src1.w
-SAD - Sum Of Absolute Differences
+.. opcode:: SAD - Sum Of Absolute Differences
.. math::
@@ -1022,17 +1026,17 @@ SAD - Sum Of Absolute Differences
dst.w = |src0.w - src1.w| + src2.w
-TXF - Texel Fetch
+.. opcode:: TXF - Texel Fetch
TBD
-TXQ - Texture Size Query
+.. opcode:: TXQ - Texture Size Query
TBD
-CONT - Continue
+.. opcode:: CONT - Continue
TBD
@@ -1041,12 +1045,12 @@ From GL_NV_geometry_program4
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-EMIT - Emit
+.. opcode:: EMIT - Emit
TBD
-ENDPRIM - End Primitive
+.. opcode:: ENDPRIM - End Primitive
TBD
@@ -1055,66 +1059,64 @@ From GLSL
^^^^^^^^^^
-BGNLOOP - Begin a Loop
+.. opcode:: BGNLOOP - Begin a Loop
TBD
-BGNSUB - Begin Subroutine
+.. opcode:: BGNSUB - Begin Subroutine
TBD
-ENDLOOP - End a Loop
+.. opcode:: ENDLOOP - End a Loop
TBD
-ENDSUB - End Subroutine
+.. opcode:: ENDSUB - End Subroutine
TBD
-NOP - No Operation
+.. opcode:: NOP - No Operation
Do nothing.
-NRM4 - 4-component Vector Normalise
-
-.. math::
+.. opcode:: NRM4 - 4-component Vector Normalise
- dst.x = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
+This instruction replicates its result.
- dst.y = \frac{src.y}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
-
- dst.z = \frac{src.z}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
+.. math::
- dst.w = \frac{src.w}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
+ dst = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
ps_2_x
^^^^^^^^^^^^
-CALLNZ - Subroutine Call If Not Zero
+.. opcode:: CALLNZ - Subroutine Call If Not Zero
TBD
-IFC - If
+.. opcode:: IFC - If
TBD
-BREAKC - Break Conditional
+.. opcode:: BREAKC - Break Conditional
TBD
+.. _doubleopcodes:
+
Double Opcodes
^^^^^^^^^^^^^^^
-DADD - Add Double
+.. opcode:: DADD - Add Double
.. math::
@@ -1123,7 +1125,7 @@ DADD - Add Double
dst.zw = src0.zw + src1.zw
-DDIV - Divide Double
+.. opcode:: DDIV - Divide Double
.. math::
@@ -1131,7 +1133,7 @@ DDIV - Divide Double
dst.zw = src0.zw / src1.zw
-DSEQ - Set Double on Equal
+.. opcode:: DSEQ - Set Double on Equal
.. math::
@@ -1139,7 +1141,7 @@ DSEQ - Set Double on Equal
dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
-DSLT - Set Double on Less than
+.. opcode:: DSLT - Set Double on Less than
.. math::
@@ -1147,7 +1149,7 @@ DSLT - Set Double on Less than
dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
-DFRAC - Double Fraction
+.. opcode:: DFRAC - Double Fraction
.. math::
@@ -1156,7 +1158,7 @@ DFRAC - Double Fraction
dst.zw = src.zw - \lfloor src.zw\rfloor
-DFRACEXP - Convert Double Number to Fractional and Integral Components
+.. opcode:: DFRACEXP - Convert Double Number to Fractional and Integral Components
.. math::
@@ -1164,7 +1166,7 @@ DFRACEXP - Convert Double Number to Fractional and Integral Components
dst0.zw = frexp(src.zw, dst1.zw)
-DLDEXP - Multiple Double Number by Integral Power of 2
+.. opcode:: DLDEXP - Multiple Double Number by Integral Power of 2
.. math::
@@ -1172,7 +1174,7 @@ DLDEXP - Multiple Double Number by Integral Power of 2
dst.zw = ldexp(src0.zw, src1.zw)
-DMIN - Minimum Double
+.. opcode:: DMIN - Minimum Double
.. math::
@@ -1180,7 +1182,7 @@ DMIN - Minimum Double
dst.zw = min(src0.zw, src1.zw)
-DMAX - Maximum Double
+.. opcode:: DMAX - Maximum Double
.. math::
@@ -1188,7 +1190,7 @@ DMAX - Maximum Double
dst.zw = max(src0.zw, src1.zw)
-DMUL - Multiply Double
+.. opcode:: DMUL - Multiply Double
.. math::
@@ -1197,7 +1199,7 @@ DMUL - Multiply Double
dst.zw = src0.zw \times src1.zw
-DMAD - Multiply And Add Doubles
+.. opcode:: DMAD - Multiply And Add Doubles
.. math::
@@ -1206,7 +1208,7 @@ DMAD - Multiply And Add Doubles
dst.zw = src0.zw \times src1.zw + src2.zw
-DRCP - Reciprocal Double
+.. opcode:: DRCP - Reciprocal Double
.. math::
@@ -1214,7 +1216,7 @@ DRCP - Reciprocal Double
dst.zw = \frac{1}{src.zw}
-DSQRT - Square root double
+.. opcode:: DSQRT - Square root double
.. math::
@@ -1269,20 +1271,8 @@ Keywords
discard Discard fragment.
- dst First destination register.
-
- dst0 First destination register.
-
pc Program counter.
- src First source register.
-
- src0 First source register.
-
- src1 Second source register.
-
- src2 Third source register.
-
target Label of target instruction.
@@ -1441,3 +1431,43 @@ GL_ARB_fragment_coord_conventions extension.
DirectX 9 uses INTEGER.
DirectX 10 uses HALF_INTEGER.
+
+
+
+Texture Sampling and Texture Formats
+------------------------------------
+
+This table shows how texture image components are returned as (x,y,z,w) tuples
+by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
+:opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
+well.
+
++--------------------+--------------+--------------------+--------------+
+| Texture Components | Gallium | OpenGL | Direct3D 9 |
++====================+==============+====================+==============+
+| R | XXX TBD | (r, 0, 0, 1) | (r, 1, 1, 1) |
++--------------------+--------------+--------------------+--------------+
+| RG | XXX TBD | (r, g, 0, 1) | (r, g, 1, 1) |
++--------------------+--------------+--------------------+--------------+
+| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
++--------------------+--------------+--------------------+--------------+
+| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
++--------------------+--------------+--------------------+--------------+
+| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
++--------------------+--------------+--------------------+--------------+
+| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
++--------------------+--------------+--------------------+--------------+
+| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
++--------------------+--------------+--------------------+--------------+
+| I | (i, i, i, i) | (i, i, i, i) | N/A |
++--------------------+--------------+--------------------+--------------+
+| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
+| | | [#envmap-bumpmap]_ | |
++--------------------+--------------+--------------------+--------------+
+| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
+| | | [#depth-tex-mode]_ | |
++--------------------+--------------+--------------------+--------------+
+
+.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
+.. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
+ or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.
diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c
index 3a3f968a49..246fe21054 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.c
+++ b/src/gallium/drivers/cell/ppu/cell_clear.c
@@ -33,7 +33,7 @@
#include <stdio.h>
#include <assert.h>
#include <stdint.h>
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_pack_color.h"
#include "cell/common.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index ebb7a7acc4..30aa04482e 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -36,7 +36,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_format.h"
#include "util/u_memory.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_screen.h"
#include "draw/draw_context.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
index c674d0be63..bffd0fac6f 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
@@ -33,8 +33,8 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_simple_screen.h"
+#include "util/u_inlines.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_fence.c b/src/gallium/drivers/cell/ppu/cell_fence.c
index 13125a9fa3..e10071529a 100644
--- a/src/gallium/drivers/cell/ppu/cell_fence.c
+++ b/src/gallium/drivers/cell/ppu/cell_fence.c
@@ -27,7 +27,7 @@
#include <unistd.h>
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "cell_context.h"
#include "cell_batch.h"
#include "cell_fence.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index c18a5d0635..3259c58687 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -31,7 +31,7 @@
*/
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "draw/draw_context.h"
#include "cell_context.h"
#include "cell_flush.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c
index 37b04396b3..c329c6682d 100644
--- a/src/gallium/drivers/cell/ppu/cell_screen.c
+++ b/src/gallium/drivers/cell/ppu/cell_screen.c
@@ -28,7 +28,7 @@
#include "util/u_memory.h"
#include "util/u_simple_screen.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_state_emit.c b/src/gallium/drivers/cell/ppu/cell_state_emit.c
index f1e1dcb9eb..282f05ba08 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_emit.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_emit.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "cell_context.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c
index 1b09cf7f7d..9b2f86fdfb 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c
@@ -27,8 +27,8 @@
#include "pipe/p_defines.h"
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_inlines.h"
+#include "util/u_simple_screen.h"
#include "draw/draw_context.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index 998944f77a..fad290dfa0 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -33,8 +33,8 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_inlines.h"
+#include "util/u_simple_screen.h"
#include "util/u_format.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
index 403cf6d50f..cf8cd41159 100644
--- a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
@@ -31,7 +31,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "util/u_math.h"
#include "cell_context.h"
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 46e4338d98..2ccc5d3e60 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -27,7 +27,7 @@
#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "util/u_memory.h"
#include "pipe/p_context.h"
diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c
index d6ec4d1313..c189d1d82c 100644
--- a/src/gallium/drivers/failover/fo_state.c
+++ b/src/gallium/drivers/failover/fo_state.c
@@ -28,6 +28,8 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
+#include "util/u_inlines.h"
+
#include "fo_context.h"
diff --git a/src/gallium/drivers/i915/i915_buffer.c b/src/gallium/drivers/i915/i915_buffer.c
index 669964770d..0f76a59e93 100644
--- a/src/gallium/drivers/i915/i915_buffer.c
+++ b/src/gallium/drivers/i915/i915_buffer.c
@@ -23,6 +23,7 @@
*
**************************************************************************/
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "i915_screen.h"
#include "i915_buffer.h"
diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c
index a0c80d0228..f8219c9f29 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -32,7 +32,7 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index 37cbd56036..6ec5566d5d 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -167,7 +167,7 @@ struct i915_depth_stencil_state {
};
struct i915_rasterizer_state {
- int light_twoside : 1;
+ unsigned light_twoside : 1;
unsigned st;
enum interp_mode color_interp;
diff --git a/src/gallium/drivers/i915/i915_debug.h b/src/gallium/drivers/i915/i915_debug.h
index dd9b86e17b..8f7484797d 100644
--- a/src/gallium/drivers/i915/i915_debug.h
+++ b/src/gallium/drivers/i915/i915_debug.h
@@ -72,7 +72,7 @@ void i915_print_ureg(const char *msg, unsigned ureg);
#if defined(DEBUG) && defined(FILE_DEBUG_FLAG)
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
static INLINE void
I915_DBG(
diff --git a/src/gallium/drivers/i915/i915_debug_fp.c b/src/gallium/drivers/i915/i915_debug_fp.c
index f9c40d8a11..066e7392d1 100644
--- a/src/gallium/drivers/i915/i915_debug_fp.c
+++ b/src/gallium/drivers/i915/i915_debug_fp.c
@@ -28,7 +28,8 @@
#include "i915_reg.h"
#include "i915_debug.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
+#include "util/u_debug.h"
static void
diff --git a/src/gallium/drivers/i915/i915_prim_vbuf.c b/src/gallium/drivers/i915/i915_prim_vbuf.c
index 6b832140a8..cad4109ee6 100644
--- a/src/gallium/drivers/i915/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915/i915_prim_vbuf.c
@@ -41,7 +41,7 @@
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
#include "util/u_debug.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_fifo.h"
diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
index 7b8d66b8aa..e6b560bc21 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_string.h"
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 23e4d6b993..beb26e996a 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -30,7 +30,7 @@
#include "draw/draw_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/i915/i915_state_inlines.h b/src/gallium/drivers/i915/i915_state_inlines.h
index 378de8f9c4..b589117fbf 100644
--- a/src/gallium/drivers/i915/i915_state_inlines.h
+++ b/src/gallium/drivers/i915/i915_state_inlines.h
@@ -30,6 +30,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_defines.h"
+#include "util/u_debug.h"
#include "i915_reg.h"
diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c
index 612e5c1cdd..e101c8683e 100644
--- a/src/gallium/drivers/i915/i915_texture.c
+++ b/src/gallium/drivers/i915/i915_texture.c
@@ -33,7 +33,7 @@
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/i965/brw_context.c b/src/gallium/drivers/i965/brw_context.c
index d60b7b99b6..7cbda05ac5 100644
--- a/src/gallium/drivers/i965/brw_context.c
+++ b/src/gallium/drivers/i965/brw_context.c
@@ -31,6 +31,7 @@
#include "pipe/p_context.h"
+#include "util/u_inlines.h"
#include "util/u_simple_list.h"
#include "brw_context.h"
diff --git a/src/gallium/drivers/i965/brw_disasm.c b/src/gallium/drivers/i965/brw_disasm.c
index 65db27248b..9c2ccfff65 100644
--- a/src/gallium/drivers/i965/brw_disasm.c
+++ b/src/gallium/drivers/i965/brw_disasm.c
@@ -366,6 +366,7 @@ static int format (FILE *f, char *format, ...)
va_start (args, format);
vsnprintf (buf, sizeof (buf) - 1, format, args);
+ va_end (args);
string (f, buf);
return 0;
}
diff --git a/src/gallium/drivers/i965/brw_draw.c b/src/gallium/drivers/i965/brw_draw.c
index 1b5cd23995..9bad61ef72 100644
--- a/src/gallium/drivers/i965/brw_draw.c
+++ b/src/gallium/drivers/i965/brw_draw.c
@@ -26,6 +26,7 @@
**************************************************************************/
+#include "util/u_inlines.h"
#include "util/u_prim.h"
#include "util/u_upload_mgr.h"
diff --git a/src/gallium/drivers/i965/brw_draw_upload.c b/src/gallium/drivers/i965/brw_draw_upload.c
index a27da5f1c1..d59261557b 100644
--- a/src/gallium/drivers/i965/brw_draw_upload.c
+++ b/src/gallium/drivers/i965/brw_draw_upload.c
@@ -26,6 +26,7 @@
**************************************************************************/
#include "pipe/p_context.h"
+#include "util/u_inlines.h"
#include "util/u_upload_mgr.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/i965/brw_pipe_fb.c b/src/gallium/drivers/i965/brw_pipe_fb.c
index c1f049272a..a90b7c73f6 100644
--- a/src/gallium/drivers/i965/brw_pipe_fb.c
+++ b/src/gallium/drivers/i965/brw_pipe_fb.c
@@ -1,6 +1,7 @@
#include "util/u_math.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
+#include "util/u_inlines.h"
#include "brw_context.h"
diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c
index ef6c1bb315..6aab561004 100644
--- a/src/gallium/drivers/i965/brw_pipe_sampler.c
+++ b/src/gallium/drivers/i965/brw_pipe_sampler.c
@@ -4,6 +4,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
+#include "util/u_inlines.h"
#include "brw_context.h"
#include "brw_defines.h"
diff --git a/src/gallium/drivers/i965/brw_pipe_shader.c b/src/gallium/drivers/i965/brw_pipe_shader.c
index e389587f3e..c2b1839110 100644
--- a/src/gallium/drivers/i965/brw_pipe_shader.c
+++ b/src/gallium/drivers/i965/brw_pipe_shader.c
@@ -29,6 +29,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c
index a8f9892d71..1d79d84dc6 100644
--- a/src/gallium/drivers/i965/brw_screen.c
+++ b/src/gallium/drivers/i965/brw_screen.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_string.h"
diff --git a/src/gallium/drivers/i965/brw_screen_buffers.c b/src/gallium/drivers/i965/brw_screen_buffers.c
index d8141a3f5b..0b38885f40 100644
--- a/src/gallium/drivers/i965/brw_screen_buffers.c
+++ b/src/gallium/drivers/i965/brw_screen_buffers.c
@@ -4,7 +4,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "brw_screen.h"
#include "brw_winsys.h"
diff --git a/src/gallium/drivers/i965/brw_winsys.h b/src/gallium/drivers/i965/brw_winsys.h
index a242e31218..8841de2611 100644
--- a/src/gallium/drivers/i965/brw_winsys.h
+++ b/src/gallium/drivers/i965/brw_winsys.h
@@ -28,7 +28,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_defines.h"
-#include "pipe/p_refcnt.h"
+#include "util/u_inlines.h"
struct brw_winsys;
struct pipe_fence_handle;
diff --git a/src/gallium/drivers/identity/id_objects.c b/src/gallium/drivers/identity/id_objects.c
index bc9bc7121d..2b1a60c1bf 100644
--- a/src/gallium/drivers/identity/id_objects.c
+++ b/src/gallium/drivers/identity/id_objects.c
@@ -25,9 +25,9 @@
*
**************************************************************************/
+#include "util/u_inlines.h"
#include "util/u_memory.h"
-#include "id_public.h"
#include "id_screen.h"
#include "id_objects.h"
diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript
index d7a396292c..840cb0950e 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -80,21 +80,22 @@ llvmpipe = env.ConvenienceLibrary(
])
-env = env.Clone()
+if env['platform'] != 'embedded':
+ env = env.Clone()
-env.Prepend(LIBS = [llvmpipe] + gallium)
+ env.Prepend(LIBS = [llvmpipe] + gallium)
-tests = [
- 'format',
- 'blend',
- 'conv',
-]
+ tests = [
+ 'format',
+ 'blend',
+ 'conv',
+ ]
-for test in tests:
- target = env.Program(
- target = 'lp_test_' + test,
- source = ['lp_test_' + test + '.c', 'lp_test_main.c'],
- )
- env.InstallProgram(target)
+ for test in tests:
+ target = env.Program(
+ target = 'lp_test_' + test,
+ source = ['lp_test_' + test + '.c', 'lp_test_main.c'],
+ )
+ env.InstallProgram(target)
-Export('llvmpipe')
+ Export('llvmpipe')
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
index ad1dbbc9b1..0215bb72ac 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
@@ -44,6 +44,7 @@
#include "pipe/p_state.h"
+#include "util/u_debug.h"
#include "lp_bld_type.h"
#include "lp_bld_const.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_logicop.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_logicop.c
index 88321f62a2..1eac0a5c89 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_logicop.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_logicop.c
@@ -35,6 +35,7 @@
#include "pipe/p_state.h"
+#include "util/u_debug.h"
#include "lp_bld_blend.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
index a73d1158e7..6d5a45db7a 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
@@ -69,6 +69,7 @@
#include "pipe/p_state.h"
+#include "util/u_debug.h"
#include "lp_bld_type.h"
#include "lp_bld_arit.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_logic.c b/src/gallium/drivers/llvmpipe/lp_bld_logic.c
index d094a040d6..d23de4f0ef 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_logic.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_logic.c
@@ -34,6 +34,7 @@
#include "util/u_cpu_detect.h"
+#include "util/u_debug.h"
#include "lp_bld_type.h"
#include "lp_bld_const.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_buffer.c b/src/gallium/drivers/llvmpipe/lp_buffer.c
index a5ef221a21..9eda972081 100644
--- a/src/gallium/drivers/llvmpipe/lp_buffer.c
+++ b/src/gallium/drivers/llvmpipe/lp_buffer.c
@@ -26,12 +26,12 @@
**************************************************************************/
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "lp_winsys.h"
#include "lp_screen.h"
-#include "lp_texture.h"
#include "lp_buffer.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c
index 51de6f93ca..a76bde3905 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.c
+++ b/src/gallium/drivers/llvmpipe/lp_context.c
@@ -33,6 +33,7 @@
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "lp_clear.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_fence.c b/src/gallium/drivers/llvmpipe/lp_fence.c
index 97c46087da..525c117f31 100644
--- a/src/gallium/drivers/llvmpipe/lp_fence.c
+++ b/src/gallium/drivers/llvmpipe/lp_fence.c
@@ -28,6 +28,7 @@
#include "pipe/p_screen.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "lp_fence.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_fence.h b/src/gallium/drivers/llvmpipe/lp_fence.h
index d45318f9e4..c90e6de423 100644
--- a/src/gallium/drivers/llvmpipe/lp_fence.h
+++ b/src/gallium/drivers/llvmpipe/lp_fence.h
@@ -30,8 +30,8 @@
#define LP_FENCE_H
-#include "pipe/p_refcnt.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
+#include "pipe/p_state.h"
struct pipe_screen;
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index e27b6528ea..54af850467 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -808,12 +808,12 @@ lp_rasterize_scene( struct lp_rasterizer *rast,
if (debug) {
unsigned x, y;
- printf("rasterize scene:\n");
- printf(" data size: %u\n", lp_scene_data_size(scene));
+ debug_printf("rasterize scene:\n");
+ debug_printf(" data size: %u\n", lp_scene_data_size(scene));
for (y = 0; y < scene->tiles_y; y++) {
for (x = 0; x < scene->tiles_x; x++) {
- printf(" bin %u, %u size: %u\n", x, y,
- lp_scene_bin_size(scene, x, y));
+ debug_printf(" bin %u, %u size: %u\n", x, y,
+ lp_scene_bin_size(scene, x, y));
}
}
}
@@ -864,8 +864,7 @@ lp_rasterize_scene( struct lp_rasterizer *rast,
* 2. do work
* 3. signal that we're done
*/
-static void *
-thread_func( void *init_data )
+static PIPE_THREAD_ROUTINE( thread_func, init_data )
{
struct lp_rasterizer_task *task = (struct lp_rasterizer_task *) init_data;
struct lp_rasterizer *rast = task->rast;
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 607968e345..71e3a301e6 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -28,7 +28,7 @@
#ifndef LP_RAST_PRIV_H
#define LP_RAST_PRIV_H
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "lp_rast.h"
#include "lp_tile_soa.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c
index 191122de7d..0421c506d8 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.c
+++ b/src/gallium/drivers/llvmpipe/lp_scene.c
@@ -27,6 +27,7 @@
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "util/u_simple_list.h"
#include "lp_scene.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h
index 86facf8eac..7db2165cf1 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.h
+++ b/src/gallium/drivers/llvmpipe/lp_scene.h
@@ -35,7 +35,7 @@
#ifndef LP_SCENE_H
#define LP_SCENE_H
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "lp_tile_soa.h"
#include "lp_rast.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index f8fc912fa1..2e3ef4ae5c 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -33,7 +33,7 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_pack_color.h"
#include "util/u_surface.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 0602e940d9..c5f6df23a1 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -62,6 +62,7 @@
#include <limits.h>
#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_format.h"
#include "util/u_debug_dump.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
index 976f81113f..43649febf2 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
@@ -29,6 +29,7 @@
* Brian Paul
*/
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c
index aa4241a80d..048ac5b968 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_surface.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c
@@ -29,6 +29,7 @@
*/
#include "pipe/p_state.h"
+#include "util/u_inlines.h"
#include "util/u_surface.h"
#include "lp_context.h"
#include "lp_state.h"
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index c9b6eb180f..605200396b 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -32,7 +32,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/nouveau/Makefile b/src/gallium/drivers/nouveau/Makefile
index 0cb66041d5..0e02680bc6 100644
--- a/src/gallium/drivers/nouveau/Makefile
+++ b/src/gallium/drivers/nouveau/Makefile
@@ -4,6 +4,7 @@ include $(TOP)/configs/current
LIBNAME = nouveau
C_SOURCES = nouveau_screen.c \
- nouveau_context.c
+ nouveau_context.c \
+ nv04_surface_2d.c
include ../../Makefile.template
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index 1ad539d285..156cb2d229 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -3,7 +3,9 @@
#include <pipe/p_state.h>
#include <util/u_memory.h>
+#include <util/u_inlines.h>
+#include <stdio.h>
#include <errno.h>
#include "nouveau/nouveau_bo.h"
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index 4c3e08a43f..4c5d2f8b1c 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -2,7 +2,7 @@
#define NOUVEAU_WINSYS_H
#include <stdint.h>
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_defines.h"
#include "nouveau/nouveau_bo.h"
@@ -27,24 +27,6 @@
#define NOUVEAU_BUFFER_USAGE_NO_RENDER (1 << 19)
extern struct pipe_screen *
-nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
-
-extern struct pipe_context *
-nv04_create(struct pipe_screen *, unsigned pctx_id);
-
-extern struct pipe_screen *
-nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
-
-extern struct pipe_context *
-nv10_create(struct pipe_screen *, unsigned pctx_id);
-
-extern struct pipe_screen *
-nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
-
-extern struct pipe_context *
-nv20_create(struct pipe_screen *, unsigned pctx_id);
-
-extern struct pipe_screen *
nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
extern struct pipe_context *
diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nouveau/nv04_surface_2d.c
index b24a9cee5a..42c2ca932d 100644
--- a/src/gallium/drivers/nv04/nv04_surface_2d.c
+++ b/src/gallium/drivers/nouveau/nv04_surface_2d.c
@@ -60,17 +60,17 @@ nv04_scaled_image_format(enum pipe_format format)
case PIPE_FORMAT_A8_UNORM:
case PIPE_FORMAT_L8_UNORM:
case PIPE_FORMAT_I8_UNORM:
- return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8;
+ return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8;
case PIPE_FORMAT_A1R5G5B5_UNORM:
- return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5;
+ return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5;
case PIPE_FORMAT_A8R8G8B8_UNORM:
- return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8;
+ return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8;
case PIPE_FORMAT_X8R8G8B8_UNORM:
- return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8;
+ return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8;
case PIPE_FORMAT_R5G6B5_UNORM:
case PIPE_FORMAT_R16_SNORM:
case PIPE_FORMAT_A8L8_UNORM:
- return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5;
+ return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5;
default:
return -1;
}
@@ -155,7 +155,7 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
log2i(dst->width) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT |
log2i(dst->height) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT);
- BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
+ BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
OUT_RELOCo(chan, src_bo,
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1);
@@ -173,22 +173,22 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
OUT_RELOCl(chan, dst_bo, dst->offset,
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
- OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
+ BEGIN_RING(chan, sifm, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
+ OUT_RING (chan, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
OUT_RING (chan, nv04_scaled_image_format(src->format));
- OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
- OUT_RING (chan, (x + dx) | ((y + dy) << NV04_SCALED_IMAGE_FROM_MEMORY_CLIP_POINT_Y_SHIFT));
- OUT_RING (chan, sub_h << NV04_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE_H_SHIFT | sub_w);
- OUT_RING (chan, (x + dx) | ((y + dy) << NV04_SCALED_IMAGE_FROM_MEMORY_OUT_POINT_Y_SHIFT));
- OUT_RING (chan, sub_h << NV04_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE_H_SHIFT | sub_w);
+ OUT_RING (chan, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
+ OUT_RING (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_POINT_Y_SHIFT));
+ OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE_H_SHIFT | sub_w);
+ OUT_RING (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_POINT_Y_SHIFT));
+ OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE_H_SHIFT | sub_w);
OUT_RING (chan, 1 << 20);
OUT_RING (chan, 1 << 20);
- BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
- OUT_RING (chan, sub_h << NV04_SCALED_IMAGE_FROM_MEMORY_SIZE_H_SHIFT | sub_w);
+ BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
+ OUT_RING (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_SIZE_H_SHIFT | sub_w);
OUT_RING (chan, src_pitch |
- NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
- NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
+ NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
+ NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * util_format_get_blocksize(src->texture->format),
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
OUT_RING (chan, 0);
@@ -421,12 +421,12 @@ nv04_surface_2d_init(struct nouveau_screen *screen)
return NULL;
}
- BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_DMA_NOTIFY, 1);
+ BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_DMA_NOTIFY, 1);
OUT_RING (chan, ctx->ntfy->handle);
BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_SURFACE, 1);
OUT_RING (chan, ctx->surf2d->handle);
- BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_OPERATION, 1);
- OUT_RING (chan, NV04_IMAGE_BLIT_OPERATION_SRCCOPY);
+ BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_OPERATION, 1);
+ OUT_RING (chan, NV01_IMAGE_BLIT_OPERATION_SRCCOPY);
ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT,
&ctx->rect);
diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.h b/src/gallium/drivers/nouveau/nv04_surface_2d.h
index ce696a11a3..ce696a11a3 100644
--- a/src/gallium/drivers/nv04/nv04_surface_2d.h
+++ b/src/gallium/drivers/nouveau/nv04_surface_2d.h
diff --git a/src/gallium/drivers/nv04/Makefile b/src/gallium/drivers/nv04/Makefile
deleted file mode 100644
index 7c14bacb1d..0000000000
--- a/src/gallium/drivers/nv04/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nv04
-
-C_SOURCES = \
- nv04_surface_2d.c \
- nv04_clear.c \
- nv04_context.c \
- nv04_fragprog.c \
- nv04_fragtex.c \
- nv04_miptree.c \
- nv04_prim_vbuf.c \
- nv04_screen.c \
- nv04_state.c \
- nv04_state_emit.c \
- nv04_surface.c \
- nv04_transfer.c \
- nv04_vbo.c
-
-include ../../Makefile.template
diff --git a/src/gallium/drivers/nv04/nv04_clear.c b/src/gallium/drivers/nv04/nv04_clear.c
deleted file mode 100644
index 01cacd36fe..0000000000
--- a/src/gallium/drivers/nv04/nv04_clear.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#include "nv04_context.h"
-
-void
-nv04_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
-{
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
-}
diff --git a/src/gallium/drivers/nv04/nv04_context.c b/src/gallium/drivers/nv04/nv04_context.c
deleted file mode 100644
index edd96859cf..0000000000
--- a/src/gallium/drivers/nv04/nv04_context.c
+++ /dev/null
@@ -1,112 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
-
-#include "nv04_context.h"
-#include "nv04_screen.h"
-
-static void
-nv04_flush(struct pipe_context *pipe, unsigned flags,
- struct pipe_fence_handle **fence)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
-
- draw_flush(nv04->draw);
-
- FIRE_RING(chan);
- if (fence)
- *fence = NULL;
-}
-
-static void
-nv04_destroy(struct pipe_context *pipe)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- if (nv04->draw)
- draw_destroy(nv04->draw);
-
- FREE(nv04);
-}
-
-static boolean
-nv04_init_hwctx(struct nv04_context *nv04)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- // requires a valid handle
-// BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_NOTIFY, 1);
-// OUT_RING(0);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_NOP, 1);
- OUT_RING(chan, 0);
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
- OUT_RING(chan, 0x40182800);
-// OUT_RING(1<<20/*no cull*/);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1);
-// OUT_RING(0x24|(1<<6)|(1<<8));
- OUT_RING(chan, 0x120001a4);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FORMAT, 1);
- OUT_RING(chan, 0x332213a1);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FILTER, 1);
- OUT_RING(chan, 0x11001010);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_COLORKEY, 1);
- OUT_RING(chan, 0x0);
-// BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 1);
-// OUT_RING(SCREEN_OFFSET);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_FOGCOLOR, 1);
- OUT_RING(chan, 0xff000000);
-
-
-
- FIRE_RING (chan);
- return TRUE;
-}
-
-struct pipe_context *
-nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
-{
- struct nv04_screen *screen = nv04_screen(pscreen);
- struct pipe_winsys *ws = pscreen->winsys;
- struct nv04_context *nv04;
- struct nouveau_winsys *nvws = screen->nvws;
-
- nv04 = CALLOC(1, sizeof(struct nv04_context));
- if (!nv04)
- return NULL;
- nv04->screen = screen;
- nv04->pctx_id = pctx_id;
-
- nv04->nvws = nvws;
-
- nv04->pipe.winsys = ws;
- nv04->pipe.screen = pscreen;
- nv04->pipe.destroy = nv04_destroy;
- nv04->pipe.draw_arrays = nv04_draw_arrays;
- nv04->pipe.draw_elements = nv04_draw_elements;
- nv04->pipe.clear = nv04_clear;
- nv04->pipe.flush = nv04_flush;
-
- nv04->pipe.is_texture_referenced = nouveau_is_texture_referenced;
- nv04->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
-
- nv04_init_surface_functions(nv04);
- nv04_init_state_functions(nv04);
-
- nv04->draw = draw_create();
- assert(nv04->draw);
- draw_wide_point_threshold(nv04->draw, 0.0);
- draw_wide_line_threshold(nv04->draw, 0.0);
- draw_enable_line_stipple(nv04->draw, FALSE);
- draw_enable_point_sprites(nv04->draw, FALSE);
- draw_set_rasterize_stage(nv04->draw, nv04_draw_vbuf_stage(nv04));
-
- nv04_init_hwctx(nv04);
-
- return &nv04->pipe;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_context.h b/src/gallium/drivers/nv04/nv04_context.h
deleted file mode 100644
index fe3b527423..0000000000
--- a/src/gallium/drivers/nv04/nv04_context.h
+++ /dev/null
@@ -1,148 +0,0 @@
-#ifndef __NV04_CONTEXT_H__
-#define __NV04_CONTEXT_H__
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "pipe/p_compiler.h"
-
-#include "util/u_memory.h"
-#include "util/u_math.h"
-
-#include "draw/draw_vertex.h"
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_gldefs.h"
-#include "nouveau/nouveau_context.h"
-
-#include "nv04_state.h"
-
-#define NOUVEAU_ERR(fmt, args...) \
- fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
-#define NOUVEAU_MSG(fmt, args...) \
- fprintf(stderr, "nouveau: "fmt, ##args);
-
-#include "nv04_screen.h"
-
-#define NV04_NEW_VERTPROG (1 << 1)
-#define NV04_NEW_FRAGPROG (1 << 2)
-#define NV04_NEW_BLEND (1 << 3)
-#define NV04_NEW_RAST (1 << 4)
-#define NV04_NEW_CONTROL (1 << 5)
-#define NV04_NEW_VIEWPORT (1 << 6)
-#define NV04_NEW_SAMPLER (1 << 7)
-#define NV04_NEW_FRAMEBUFFER (1 << 8)
-#define NV04_NEW_VTXARRAYS (1 << 9)
-
-struct nv04_context {
- struct pipe_context pipe;
-
- struct nouveau_winsys *nvws;
- struct nv04_screen *screen;
- unsigned pctx_id;
-
- struct draw_context *draw;
-
- int chipset;
- struct nouveau_notifier *sync;
-
- uint32_t dirty;
-
- struct nv04_blend_state *blend;
- struct nv04_sampler_state *sampler[PIPE_MAX_SAMPLERS];
- struct nv04_fragtex_state fragtex;
- struct nv04_rasterizer_state *rast;
- struct nv04_depth_stencil_alpha_state *dsa;
-
- struct nv04_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
- unsigned dirty_samplers;
- unsigned fp_samplers;
- unsigned vp_samplers;
-
- uint32_t rt_enable;
- struct pipe_framebuffer_state *framebuffer;
- struct pipe_surface *rt;
- struct pipe_surface *zeta;
-
- struct {
- struct pipe_buffer *buffer;
- uint32_t format;
- } tex[16];
-
- unsigned vb_enable;
- struct {
- struct pipe_buffer *buffer;
- unsigned delta;
- } vb[16];
-
- float *constbuf[PIPE_SHADER_TYPES][32][4];
- unsigned constbuf_nr[PIPE_SHADER_TYPES];
-
- struct vertex_info vertex_info;
- struct {
-
- struct nouveau_resource *exec_heap;
- struct nouveau_resource *data_heap;
-
- struct nv04_vertex_program *active;
-
- struct nv04_vertex_program *current;
- struct pipe_buffer *constant_buf;
- } vertprog;
-
- struct {
- struct nv04_fragment_program *active;
-
- struct nv04_fragment_program *current;
- struct pipe_buffer *constant_buf;
- } fragprog;
-
- struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
- struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
-
- struct pipe_viewport_state viewport;
-};
-
-static INLINE struct nv04_context *
-nv04_context(struct pipe_context *pipe)
-{
- return (struct nv04_context *)pipe;
-}
-
-extern void nv04_init_state_functions(struct nv04_context *nv04);
-extern void nv04_init_surface_functions(struct nv04_context *nv04);
-extern void nv04_screen_init_miptree_functions(struct pipe_screen *screen);
-
-/* nv04_clear.c */
-extern void nv04_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
-
-/* nv04_draw.c */
-extern struct draw_stage *nv04_draw_render_stage(struct nv04_context *nv04);
-
-/* nv04_fragprog.c */
-extern void nv04_fragprog_bind(struct nv04_context *,
- struct nv04_fragment_program *);
-extern void nv04_fragprog_destroy(struct nv04_context *,
- struct nv04_fragment_program *);
-
-/* nv04_fragtex.c */
-extern void nv04_fragtex_bind(struct nv04_context *);
-
-/* nv04_prim_vbuf.c */
-struct draw_stage *nv04_draw_vbuf_stage( struct nv04_context *nv04 );
-
-/* nv04_state.c and friends */
-extern void nv04_emit_hw_state(struct nv04_context *nv04);
-extern void nv04_state_tex_update(struct nv04_context *nv04);
-
-/* nv04_vbo.c */
-extern void nv04_draw_arrays(struct pipe_context *, unsigned mode,
- unsigned start, unsigned count);
-extern void nv04_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count);
-
-
-#endif
diff --git a/src/gallium/drivers/nv04/nv04_fragprog.c b/src/gallium/drivers/nv04/nv04_fragprog.c
deleted file mode 100644
index 8a2af41fe0..0000000000
--- a/src/gallium/drivers/nv04/nv04_fragprog.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#include "pipe/p_shader_tokens.h"
-#include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_util.h"
-
-#include "nv04_context.h"
-
-void
-nv04_fragprog_bind(struct nv04_context *nv04, struct nv04_fragment_program *fp)
-{
-}
-
-void
-nv04_fragprog_destroy(struct nv04_context *nv04,
- struct nv04_fragment_program *fp)
-{
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_fragtex.c b/src/gallium/drivers/nv04/nv04_fragtex.c
deleted file mode 100644
index c152b52119..0000000000
--- a/src/gallium/drivers/nv04/nv04_fragtex.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "nv04_context.h"
-#include "nouveau/nouveau_util.h"
-
-#define _(m,tf) \
-{ \
- PIPE_FORMAT_##m, \
- NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_##tf, \
-}
-
-struct nv04_texture_format {
- uint pipe;
- int format;
-};
-
-static struct nv04_texture_format
-nv04_texture_formats[] = {
- _(A8R8G8B8_UNORM, A8R8G8B8),
- _(X8R8G8B8_UNORM, X8R8G8B8),
- _(A1R5G5B5_UNORM, A1R5G5B5),
- _(A4R4G4B4_UNORM, A4R4G4B4),
- _(L8_UNORM, Y8 ),
- _(A8_UNORM, Y8 ),
-};
-
-static uint32_t
-nv04_fragtex_format(uint pipe_format)
-{
- struct nv04_texture_format *tf = nv04_texture_formats;
- int i;
-
- for (i=0; i< sizeof(nv04_texture_formats)/sizeof(nv04_texture_formats[0]); i++) {
- if (tf->pipe == pipe_format)
- return tf->format;
- tf++;
- }
-
- NOUVEAU_ERR("unknown texture format %s\n", pf_name(pipe_format));
- return 0;
-}
-
-
-static void
-nv04_fragtex_build(struct nv04_context *nv04, int unit)
-{
- struct nv04_miptree *nv04mt = nv04->tex_miptree[unit];
- struct pipe_texture *pt = &nv04mt->base;
-
- switch (pt->target) {
- case PIPE_TEXTURE_2D:
- break;
- default:
- NOUVEAU_ERR("Unknown target %d\n", pt->target);
- return;
- }
-
- nv04->fragtex.format = NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_ZOH_CORNER
- | NV04_TEXTURED_TRIANGLE_FORMAT_ORIGIN_FOH_CORNER
- | nv04_fragtex_format(pt->format)
- | ( (pt->last_level + 1) << NV04_TEXTURED_TRIANGLE_FORMAT_MIPMAP_LEVELS_SHIFT )
- | ( log2i(pt->width0) << NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_U_SHIFT )
- | ( log2i(pt->height0) << NV04_TEXTURED_TRIANGLE_FORMAT_BASE_SIZE_V_SHIFT )
- | NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE
- | NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_CLAMP_TO_EDGE
- ;
-}
-
-
-void
-nv04_fragtex_bind(struct nv04_context *nv04)
-{
- nv04_fragtex_build(nv04, 0);
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_miptree.c b/src/gallium/drivers/nv04/nv04_miptree.c
deleted file mode 100644
index e0a6948aeb..0000000000
--- a/src/gallium/drivers/nv04/nv04_miptree.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "util/u_math.h"
-
-#include "nv04_context.h"
-#include "nv04_screen.h"
-
-static void
-nv04_miptree_layout(struct nv04_miptree *nv04mt)
-{
- struct pipe_texture *pt = &nv04mt->base;
- uint offset = 0;
- int nr_faces, l;
-
- nr_faces = 1;
-
- for (l = 0; l <= pt->last_level; l++) {
- nv04mt->level[l].pitch = pt->width0;
- nv04mt->level[l].pitch = (nv04mt->level[l].pitch + 63) & ~63;
- }
-
- for (l = 0; l <= pt->last_level; l++) {
- nv04mt->level[l].image_offset =
- CALLOC(nr_faces, sizeof(unsigned));
- /* XXX guess was obviously missing */
- nv04mt->level[l].image_offset[0] = offset;
- offset += nv04mt->level[l].pitch * u_minify(pt->height0, l);
- }
-
- nv04mt->total_size = offset;
-}
-
-static struct pipe_texture *
-nv04_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
-{
- struct nv04_miptree *mt;
-
- mt = MALLOC(sizeof(struct nv04_miptree));
- if (!mt)
- return NULL;
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = pscreen;
-
- //mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
-
- nv04_miptree_layout(mt);
-
- mt->buffer = pscreen->buffer_create(pscreen, 256, PIPE_BUFFER_USAGE_PIXEL |
- NOUVEAU_BUFFER_USAGE_TEXTURE,
- mt->total_size);
- if (!mt->buffer) {
- printf("failed %d byte alloc\n",mt->total_size);
- FREE(mt);
- return NULL;
- }
- mt->bo = nouveau_bo(mt->buffer);
- return &mt->base;
-}
-
-static struct pipe_texture *
-nv04_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
- const unsigned *stride, struct pipe_buffer *pb)
-{
- struct nv04_miptree *mt;
-
- /* Only supports 2D, non-mipmapped textures for the moment */
- if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
- pt->depth0 != 1)
- return NULL;
-
- mt = CALLOC_STRUCT(nv04_miptree);
- if (!mt)
- return NULL;
-
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = pscreen;
- mt->level[0].pitch = stride[0];
- mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
-
- pipe_buffer_reference(&mt->buffer, pb);
- mt->bo = nouveau_bo(mt->buffer);
- return &mt->base;
-}
-
-static void
-nv04_miptree_destroy(struct pipe_texture *pt)
-{
- struct nv04_miptree *mt = (struct nv04_miptree *)pt;
- int l;
-
- pipe_buffer_reference(&mt->buffer, NULL);
- for (l = 0; l <= pt->last_level; l++) {
- if (mt->level[l].image_offset)
- FREE(mt->level[l].image_offset);
- }
-
- FREE(mt);
-}
-
-static struct pipe_surface *
-nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
-{
- struct nv04_miptree *nv04mt = (struct nv04_miptree *)pt;
- struct nv04_surface *ns;
-
- ns = CALLOC_STRUCT(nv04_surface);
- if (!ns)
- return NULL;
- pipe_texture_reference(&ns->base.texture, pt);
- ns->base.format = pt->format;
- ns->base.width = u_minify(pt->width0, level);
- ns->base.height = u_minify(pt->height0, level);
- ns->base.usage = flags;
- pipe_reference_init(&ns->base.reference, 1);
- ns->base.face = face;
- ns->base.level = level;
- ns->base.zslice = zslice;
- ns->pitch = nv04mt->level[level].pitch;
-
- ns->base.offset = nv04mt->level[level].image_offset[0];
-
- return &ns->base;
-}
-
-static void
-nv04_miptree_surface_del(struct pipe_surface *ps)
-{
- pipe_texture_reference(&ps->texture, NULL);
- FREE(ps);
-}
-
-void
-nv04_screen_init_miptree_functions(struct pipe_screen *pscreen)
-{
- pscreen->texture_create = nv04_miptree_create;
- pscreen->texture_blanket = nv04_miptree_blanket;
- pscreen->texture_destroy = nv04_miptree_destroy;
- pscreen->get_tex_surface = nv04_miptree_surface_new;
- pscreen->tex_surface_destroy = nv04_miptree_surface_del;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_prim_vbuf.c b/src/gallium/drivers/nv04/nv04_prim_vbuf.c
deleted file mode 100644
index 0b795ea243..0000000000
--- a/src/gallium/drivers/nv04/nv04_prim_vbuf.c
+++ /dev/null
@@ -1,339 +0,0 @@
-
-#include "util/u_debug.h"
-#include "pipe/p_inlines.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_compiler.h"
-
-#include "draw/draw_vbuf.h"
-
-#include "nv04_context.h"
-#include "nv04_state.h"
-
-#define VERTEX_SIZE 40
-#define VERTEX_BUFFER_SIZE (4096*VERTEX_SIZE) // 4096 vertices of 40 bytes each
-
-/**
- * Primitive renderer for nv04.
- */
-struct nv04_vbuf_render {
- struct vbuf_render base;
-
- struct nv04_context *nv04;
-
- /** Vertex buffer */
- unsigned char* buffer;
-
- /** Vertex size in bytes */
- unsigned vertex_size;
-
- /** Current primitive */
- unsigned prim;
-};
-
-
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct nv04_vbuf_render *
-nv04_vbuf_render( struct vbuf_render *render )
-{
- assert(render);
- return (struct nv04_vbuf_render *)render;
-}
-
-
-static const struct vertex_info *
-nv04_vbuf_render_get_vertex_info( struct vbuf_render *render )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
- struct nv04_context *nv04 = nv04_render->nv04;
- return &nv04->vertex_info;
-}
-
-
-static boolean
-nv04_vbuf_render_allocate_vertices( struct vbuf_render *render,
- ushort vertex_size,
- ushort nr_vertices )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
-
- nv04_render->buffer = (unsigned char*) MALLOC(VERTEX_BUFFER_SIZE);
- assert(!nv04_render->buffer);
-
- return nv04_render->buffer ? TRUE : FALSE;
-}
-
-static void *
-nv04_vbuf_render_map_vertices( struct vbuf_render *render )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
- return nv04_render->buffer;
-}
-
-static void
-nv04_vbuf_render_unmap_vertices( struct vbuf_render *render,
- ushort min_index,
- ushort max_index )
-{
-}
-
-static boolean
-nv04_vbuf_render_set_primitive( struct vbuf_render *render,
- unsigned prim )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
-
- if (prim <= PIPE_PRIM_LINE_STRIP)
- return FALSE;
-
- nv04_render->prim = prim;
- return TRUE;
-}
-
-static INLINE void nv04_2triangles(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xA), 49);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v3,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v4,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v5,8);
- OUT_RING(chan, 0xFEDCBA);
-}
-
-static INLINE void nv04_1triangle(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xD), 25);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
- OUT_RING(chan, 0xFED);
-}
-
-static INLINE void nv04_1quad(struct nv04_context* nv04, unsigned char* buffer, ushort v0, ushort v1, ushort v2, ushort v3)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0xC), 33);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v0,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v1,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v2,8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * v3,8);
- OUT_RING(chan, 0xFECEDC);
-}
-
-static void nv04_vbuf_render_triangles_elts(struct nv04_vbuf_render * render, const ushort * indices, uint nr_indices)
-{
- unsigned char* buffer = render->buffer;
- struct nv04_context* nv04 = render->nv04;
- int i;
-
- for( i=0; i< nr_indices-5; i+=6)
- nv04_2triangles(nv04,
- buffer,
- indices[i+0],
- indices[i+1],
- indices[i+2],
- indices[i+3],
- indices[i+4],
- indices[i+5]
- );
- if (i != nr_indices)
- {
- nv04_1triangle(nv04,
- buffer,
- indices[i+0],
- indices[i+1],
- indices[i+2]
- );
- i+=3;
- }
- if (i != nr_indices)
- NOUVEAU_ERR("Houston, we have lost some vertices\n");
-}
-
-static void nv04_vbuf_render_tri_strip_elts(struct nv04_vbuf_render* render, const ushort* indices, uint nr_indices)
-{
- const uint32_t striptbl[]={0x321210,0x543432,0x765654,0x987876,0xBA9A98,0xDCBCBA,0xFEDEDC};
- unsigned char* buffer = render->buffer;
- struct nv04_context *nv04 = render->nv04;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- int i,j;
-
- for(i = 0; i<nr_indices; i+=14)
- {
- int numvert = MIN2(16, nr_indices - i);
- int numtri = numvert - 2;
- if (numvert<3)
- break;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), numvert*8);
- for(j = 0; j<numvert; j++)
- OUT_RINGp(chan, buffer + VERTEX_SIZE * indices [i+j], 8 );
-
- BEGIN_RING_NI(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE(0), (numtri+1)/2 );
- for(j = 0; j<numtri/2; j++ )
- OUT_RING(chan, striptbl[j]);
- if (numtri%2)
- OUT_RING(chan, striptbl[numtri/2]&0xFFF);
- }
-}
-
-static void nv04_vbuf_render_tri_fan_elts(struct nv04_vbuf_render* render, const ushort* indices, uint nr_indices)
-{
- const uint32_t fantbl[]={0x320210,0x540430,0x760650,0x980870,0xBA0A90,0xDC0CB0,0xFE0ED0};
- unsigned char* buffer = render->buffer;
- struct nv04_context *nv04 = render->nv04;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- int i,j;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0), 8);
- OUT_RINGp(chan, buffer + VERTEX_SIZE * indices[0], 8);
-
- for(i = 1; i<nr_indices; i+=14)
- {
- int numvert=MIN2(15, nr_indices - i);
- int numtri=numvert-2;
- if (numvert < 3)
- break;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_TLVERTEX_SX(0x1), numvert*8);
-
- for(j=0;j<numvert;j++)
- OUT_RINGp(chan, buffer + VERTEX_SIZE * indices[ i+j ], 8 );
-
- BEGIN_RING_NI(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_DRAWPRIMITIVE(0), (numtri+1)/2);
- for(j = 0; j<numtri/2; j++)
- OUT_RING(chan, fantbl[j]);
- if (numtri%2)
- OUT_RING(chan, fantbl[numtri/2]&0xFFF);
- }
-}
-
-static void nv04_vbuf_render_quads_elts(struct nv04_vbuf_render* render, const ushort* indices, uint nr_indices)
-{
- unsigned char* buffer = render->buffer;
- struct nv04_context* nv04 = render->nv04;
- int i;
-
- for(i = 0; i < nr_indices; i += 4)
- nv04_1quad(nv04,
- buffer,
- indices[i+0],
- indices[i+1],
- indices[i+2],
- indices[i+3]
- );
-}
-
-
-static void
-nv04_vbuf_render_draw( struct vbuf_render *render,
- const ushort *indices,
- uint nr_indices)
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
-
- // emit the indices
- switch( nv04_render->prim )
- {
- case PIPE_PRIM_TRIANGLES:
- nv04_vbuf_render_triangles_elts(nv04_render, indices, nr_indices);
- break;
- case PIPE_PRIM_QUAD_STRIP:
- case PIPE_PRIM_TRIANGLE_STRIP:
- nv04_vbuf_render_tri_strip_elts(nv04_render, indices, nr_indices);
- break;
- case PIPE_PRIM_TRIANGLE_FAN:
- case PIPE_PRIM_POLYGON:
- nv04_vbuf_render_tri_fan_elts(nv04_render, indices, nr_indices);
- break;
- case PIPE_PRIM_QUADS:
- nv04_vbuf_render_quads_elts(nv04_render, indices, nr_indices);
- break;
- default:
- NOUVEAU_ERR("You have to implement primitive %d, young padawan\n", nv04_render->prim);
- break;
- }
-}
-
-
-static void
-nv04_vbuf_render_release_vertices( struct vbuf_render *render )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
-
- free(nv04_render->buffer);
- nv04_render->buffer = NULL;
-}
-
-
-static void
-nv04_vbuf_render_destroy( struct vbuf_render *render )
-{
- struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
- FREE(nv04_render);
-}
-
-
-/**
- * Create a new primitive render.
- */
-static struct vbuf_render *
-nv04_vbuf_render_create( struct nv04_context *nv04 )
-{
- struct nv04_vbuf_render *nv04_render = CALLOC_STRUCT(nv04_vbuf_render);
-
- nv04_render->nv04 = nv04;
-
- nv04_render->base.max_vertex_buffer_bytes = VERTEX_BUFFER_SIZE;
- nv04_render->base.max_indices = 65536;
- nv04_render->base.get_vertex_info = nv04_vbuf_render_get_vertex_info;
- nv04_render->base.allocate_vertices = nv04_vbuf_render_allocate_vertices;
- nv04_render->base.map_vertices = nv04_vbuf_render_map_vertices;
- nv04_render->base.unmap_vertices = nv04_vbuf_render_unmap_vertices;
- nv04_render->base.set_primitive = nv04_vbuf_render_set_primitive;
- nv04_render->base.draw = nv04_vbuf_render_draw;
- nv04_render->base.release_vertices = nv04_vbuf_render_release_vertices;
- nv04_render->base.destroy = nv04_vbuf_render_destroy;
-
- return &nv04_render->base;
-}
-
-
-/**
- * Create a new primitive vbuf/render stage.
- */
-struct draw_stage *nv04_draw_vbuf_stage( struct nv04_context *nv04 )
-{
- struct vbuf_render *render;
- struct draw_stage *stage;
-
- render = nv04_vbuf_render_create(nv04);
- if(!render)
- return NULL;
-
- stage = draw_vbuf_stage( nv04->draw, render );
- if(!stage) {
- render->destroy(render);
- return NULL;
- }
-
- return stage;
-}
diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c
deleted file mode 100644
index 97538964af..0000000000
--- a/src/gallium/drivers/nv04/nv04_screen.c
+++ /dev/null
@@ -1,222 +0,0 @@
-#include "pipe/p_screen.h"
-#include "pipe/p_inlines.h"
-
-#include "nv04_context.h"
-#include "nv04_screen.h"
-
-static int
-nv04_screen_get_param(struct pipe_screen *screen, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
- return 1;
- case PIPE_CAP_NPOT_TEXTURES:
- return 0;
- case PIPE_CAP_TWO_SIDED_STENCIL:
- return 0;
- case PIPE_CAP_GLSL:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
- case PIPE_CAP_POINT_SPRITE:
- return 0;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 0;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 0;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 10;
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 0;
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 0;
- case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
- return 0;
- case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
- return 0;
- case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
- return 1;
- case PIPE_CAP_TGSI_CONT_SUPPORTED:
- return 0;
- case PIPE_CAP_BLEND_EQUATION_SEPARATE:
- return 0;
- case NOUVEAU_CAP_HW_VTXBUF:
- case NOUVEAU_CAP_HW_IDXBUF:
- return 0;
- case PIPE_CAP_INDEP_BLEND_ENABLE:
- return 0;
- case PIPE_CAP_INDEP_BLEND_FUNC:
- return 0;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
- case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
- return 1;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
- case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
- return 0;
- default:
- NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
- return 0;
- }
-}
-
-static float
-nv04_screen_get_paramf(struct pipe_screen *screen, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_LINE_WIDTH:
- case PIPE_CAP_MAX_LINE_WIDTH_AA:
- return 0.0;
- case PIPE_CAP_MAX_POINT_WIDTH:
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 0.0;
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 0.0;
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 0.0;
- default:
- NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
- return 0.0;
- }
-}
-
-static boolean
-nv04_screen_is_format_supported(struct pipe_screen *screen,
- enum pipe_format format,
- enum pipe_texture_target target,
- unsigned tex_usage, unsigned geom_flags)
-{
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- return TRUE;
- default:
- break;
- }
- } else
- if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
- switch (format) {
- case PIPE_FORMAT_Z16_UNORM:
- return TRUE;
- default:
- break;
- }
- } else {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_L8_UNORM:
- case PIPE_FORMAT_A8_UNORM:
- return TRUE;
- default:
- break;
- }
- }
-
- return FALSE;
-}
-
-static void
-nv04_screen_destroy(struct pipe_screen *pscreen)
-{
- struct nv04_screen *screen = nv04_screen(pscreen);
-
- nouveau_notifier_free(&screen->sync);
- nouveau_grobj_free(&screen->fahrenheit);
- nv04_surface_2d_takedown(&screen->eng2d);
-
- nouveau_screen_fini(&screen->base);
-
- FREE(pscreen);
-}
-
-static struct pipe_buffer *
-nv04_surface_buffer(struct pipe_surface *surf)
-{
- struct nv04_miptree *mt = (struct nv04_miptree *)surf->texture;
-
- return mt->buffer;
-}
-
-struct pipe_screen *
-nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
-{
- struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen);
- struct nouveau_channel *chan;
- struct pipe_screen *pscreen;
- unsigned fahrenheit_class = 0, sub3d_class = 0;
- int ret;
-
- if (!screen)
- return NULL;
- pscreen = &screen->base.base;
-
- ret = nouveau_screen_init(&screen->base, dev);
- if (ret) {
- nv04_screen_destroy(pscreen);
- return NULL;
- }
- chan = screen->base.channel;
-
- pscreen->winsys = ws;
- pscreen->destroy = nv04_screen_destroy;
- pscreen->get_param = nv04_screen_get_param;
- pscreen->get_paramf = nv04_screen_get_paramf;
- pscreen->is_format_supported = nv04_screen_is_format_supported;
-
- nv04_screen_init_miptree_functions(pscreen);
- nv04_screen_init_transfer_functions(pscreen);
-
- if (dev->chipset >= 0x20) {
- fahrenheit_class = 0;
- sub3d_class = 0;
- } else if (dev->chipset >= 0x10) {
- fahrenheit_class = NV10_TEXTURED_TRIANGLE;
- sub3d_class = NV10_CONTEXT_SURFACES_3D;
- } else {
- fahrenheit_class=NV04_TEXTURED_TRIANGLE;
- sub3d_class = NV04_CONTEXT_SURFACES_3D;
- }
-
- if (!fahrenheit_class) {
- NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", dev->chipset);
- return NULL;
- }
-
- /* 3D object */
- ret = nouveau_grobj_alloc(chan, 0xbeef0001, fahrenheit_class,
- &screen->fahrenheit);
- if (ret) {
- NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
- return NULL;
- }
- BIND_RING(chan, screen->fahrenheit, 7);
-
- /* 3D surface object */
- ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class,
- &screen->context_surfaces_3d);
- if (ret) {
- NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret);
- return NULL;
- }
- BIND_RING(chan, screen->context_surfaces_3d, 6);
-
- /* 2D engine setup */
- screen->eng2d = nv04_surface_2d_init(&screen->base);
- screen->eng2d->buf = nv04_surface_buffer;
-
- /* Notifier for sync purposes */
- ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
- if (ret) {
- NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
- nv04_screen_destroy(pscreen);
- return NULL;
- }
-
- return pscreen;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_screen.h b/src/gallium/drivers/nv04/nv04_screen.h
deleted file mode 100644
index 11466b9442..0000000000
--- a/src/gallium/drivers/nv04/nv04_screen.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __NV04_SCREEN_H__
-#define __NV04_SCREEN_H__
-
-#include "nouveau/nouveau_screen.h"
-#include "nv04_surface_2d.h"
-
-struct nv04_screen {
- struct nouveau_screen base;
-
- struct nouveau_winsys *nvws;
- unsigned chipset;
-
- /* HW graphics objects */
- struct nv04_surface_2d *eng2d;
- struct nouveau_grobj *fahrenheit;
- struct nouveau_grobj *context_surfaces_3d;
- struct nouveau_notifier *sync;
-
-};
-
-static INLINE struct nv04_screen *
-nv04_screen(struct pipe_screen *screen)
-{
- return (struct nv04_screen *)screen;
-}
-
-void
-nv04_screen_init_transfer_functions(struct pipe_screen *pscreen);
-
-#endif
diff --git a/src/gallium/drivers/nv04/nv04_state.c b/src/gallium/drivers/nv04/nv04_state.c
deleted file mode 100644
index 1fdb764b53..0000000000
--- a/src/gallium/drivers/nv04/nv04_state.c
+++ /dev/null
@@ -1,459 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/p_inlines.h"
-
-#include "tgsi/tgsi_parse.h"
-
-#include "nv04_context.h"
-#include "nv04_state.h"
-
-static void *
-nv04_blend_state_create(struct pipe_context *pipe,
- const struct pipe_blend_state *cso)
-{
- struct nv04_blend_state *cb;
-
- cb = MALLOC(sizeof(struct nv04_blend_state));
-
- cb->b_enable = cso->rt[0].blend_enable ? 1 : 0;
- cb->b_src = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) |
- (nvgl_blend_func(cso->rt[0].rgb_src_factor)));
- cb->b_dst = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) |
- (nvgl_blend_func(cso->rt[0].rgb_dst_factor)));
-
-
- return (void *)cb;
-}
-
-static void
-nv04_blend_state_bind(struct pipe_context *pipe, void *blend)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->blend = (struct nv04_blend_state*)blend;
-
- nv04->dirty |= NV04_NEW_BLEND;
-}
-
-static void
-nv04_blend_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- free(hwcso);
-}
-
-
-static INLINE unsigned
-wrap_mode(unsigned wrap) {
- unsigned ret;
-
- switch (wrap) {
- case PIPE_TEX_WRAP_REPEAT:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_REPEAT;
- break;
- case PIPE_TEX_WRAP_MIRROR_REPEAT:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_MIRRORED_REPEAT;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_EDGE;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP_TO_BORDER;
- break;
- case PIPE_TEX_WRAP_CLAMP:
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP;
- break;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
- case PIPE_TEX_WRAP_MIRROR_CLAMP:
- default:
- NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
- ret = NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_CLAMP;
- }
- return ret >> NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT;
-}
-
-static void *
-nv04_sampler_state_create(struct pipe_context *pipe,
- const struct pipe_sampler_state *cso)
-{
-
- struct nv04_sampler_state *ss;
- uint32_t filter = 0;
-
- ss = MALLOC(sizeof(struct nv04_sampler_state));
-
- ss->format = ((wrap_mode(cso->wrap_s) << NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_SHIFT) |
- (wrap_mode(cso->wrap_t) << NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_SHIFT));
-
- if (cso->max_anisotropy > 1.0) {
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MINIFY_ENABLE | NV04_TEXTURED_TRIANGLE_FILTER_ANISOTROPIC_MAGNIFY_ENABLE;
- }
-
- switch (cso->mag_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_LINEAR;
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MAGNIFY_NEAREST;
- break;
- }
-
- switch (cso->min_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_LINEAR;
- break;
- }
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST;
- break;
- }
- break;
- }
-
- ss->filter = filter;
-
- return (void *)ss;
-}
-
-static void
-nv04_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- unsigned unit;
-
- for (unit = 0; unit < nr; unit++) {
- nv04->sampler[unit] = sampler[unit];
- nv04->dirty_samplers |= (1 << unit);
- }
-}
-
-static void
-nv04_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- free(hwcso);
-}
-
-static void
-nv04_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
- struct pipe_texture **miptree)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- unsigned unit;
-
- for (unit = 0; unit < nr; unit++) {
- nv04->tex_miptree[unit] = (struct nv04_miptree *)miptree[unit];
- nv04->dirty_samplers |= (1 << unit);
- }
-}
-
-static void *
-nv04_rasterizer_state_create(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *cso)
-{
- struct nv04_rasterizer_state *rs;
-
- /*XXX: ignored:
- * scissor
- * points/lines (no hw support, emulated with tris in gallium)
- */
- rs = MALLOC(sizeof(struct nv04_rasterizer_state));
-
- rs->blend = cso->flatshade ? NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_FLAT : NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_GOURAUD;
-
- return (void *)rs;
-}
-
-static void
-nv04_rasterizer_state_bind(struct pipe_context *pipe, void *rast)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->rast = (struct nv04_rasterizer_state*)rast;
-
- draw_set_rasterizer_state(nv04->draw, (nv04->rast ? nv04->rast->templ : NULL));
-
- nv04->dirty |= NV04_NEW_RAST | NV04_NEW_BLEND;
-}
-
-static void
-nv04_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- free(hwcso);
-}
-
-static INLINE uint32_t nv04_compare_func(uint32_t f)
-{
- switch ( f ) {
- case PIPE_FUNC_NEVER: return 1;
- case PIPE_FUNC_LESS: return 2;
- case PIPE_FUNC_EQUAL: return 3;
- case PIPE_FUNC_LEQUAL: return 4;
- case PIPE_FUNC_GREATER: return 5;
- case PIPE_FUNC_NOTEQUAL: return 6;
- case PIPE_FUNC_GEQUAL: return 7;
- case PIPE_FUNC_ALWAYS: return 8;
- }
- NOUVEAU_MSG("Unable to find the function\n");
- return 0;
-}
-
-static void *
-nv04_depth_stencil_alpha_state_create(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *cso)
-{
- struct nv04_depth_stencil_alpha_state *hw;
-
- hw = MALLOC(sizeof(struct nv04_depth_stencil_alpha_state));
-
- hw->control = float_to_ubyte(cso->alpha.ref_value);
- hw->control |= ( nv04_compare_func(cso->alpha.func) << NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_SHIFT );
- hw->control |= cso->alpha.enabled ? NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_ENABLE : 0;
- hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN;
- hw->control |= cso->depth.enabled ? NV04_TEXTURED_TRIANGLE_CONTROL_Z_ENABLE : 0;
- hw->control |= ( nv04_compare_func(cso->depth.func)<< NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_SHIFT );
- hw->control |= 1 << NV04_TEXTURED_TRIANGLE_CONTROL_CULL_MODE_SHIFT; // no culling, handled by the draw module
- hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_DITHER_ENABLE;
- hw->control |= NV04_TEXTURED_TRIANGLE_CONTROL_Z_PERSPECTIVE_ENABLE;
- hw->control |= cso->depth.writemask ? NV04_TEXTURED_TRIANGLE_CONTROL_Z_WRITE : 0;
- hw->control |= 1 << NV04_TEXTURED_TRIANGLE_CONTROL_Z_FORMAT_SHIFT; // integer zbuffer format
-
- return (void *)hw;
-}
-
-static void
-nv04_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->dsa = hwcso;
- nv04->dirty |= NV04_NEW_CONTROL;
-}
-
-static void
-nv04_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- free(hwcso);
-}
-
-static void *
-nv04_vp_state_create(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- return draw_create_vertex_shader(nv04->draw, templ);
-}
-
-static void
-nv04_vp_state_bind(struct pipe_context *pipe, void *shader)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- draw_bind_vertex_shader(nv04->draw, (struct draw_vertex_shader *) shader);
-
- nv04->dirty |= NV04_NEW_VERTPROG;
-}
-
-static void
-nv04_vp_state_delete(struct pipe_context *pipe, void *shader)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- draw_delete_vertex_shader(nv04->draw, (struct draw_vertex_shader *) shader);
-}
-
-static void *
-nv04_fp_state_create(struct pipe_context *pipe,
- const struct pipe_shader_state *cso)
-{
- struct nv04_fragment_program *fp;
-
- fp = CALLOC(1, sizeof(struct nv04_fragment_program));
- fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
-
- return (void *)fp;
-}
-
-static void
-nv04_fp_state_bind(struct pipe_context *pipe, void *hwcso)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_fragment_program *fp = hwcso;
-
- nv04->fragprog.current = fp;
- nv04->dirty |= NV04_NEW_FRAGPROG;
-}
-
-static void
-nv04_fp_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_fragment_program *fp = hwcso;
-
- nv04_fragprog_destroy(nv04, fp);
- free((void*)fp->pipe.tokens);
- free(fp);
-}
-
-static void
-nv04_set_blend_color(struct pipe_context *pipe,
- const struct pipe_blend_color *bcol)
-{
-}
-
-static void
-nv04_set_clip_state(struct pipe_context *pipe,
- const struct pipe_clip_state *clip)
-{
-}
-
-static void
-nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
- struct pipe_buffer *buf )
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct pipe_screen *pscreen = pipe->screen;
-
- assert(shader < PIPE_SHADER_TYPES);
- assert(index == 0);
-
- if (buf) {
- void *mapped;
- if (buf && buf->size &&
- (mapped = pipe_buffer_map(pscreen, buf, PIPE_BUFFER_USAGE_CPU_READ)))
- {
- memcpy(nv04->constbuf[shader], mapped, buf->size);
- nv04->constbuf_nr[shader] =
- buf->size / (4 * sizeof(float));
- pipe_buffer_unmap(pscreen, buf);
- }
- }
-}
-
-static void
-nv04_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->framebuffer = (struct pipe_framebuffer_state*)fb;
-
- nv04->dirty |= NV04_NEW_FRAMEBUFFER;
-}
-static void
-nv04_set_polygon_stipple(struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple)
-{
- NOUVEAU_ERR("line stipple hahaha\n");
-}
-
-static void
-nv04_set_scissor_state(struct pipe_context *pipe,
- const struct pipe_scissor_state *s)
-{
-/* struct nv04_context *nv04 = nv04_context(pipe);
-
- // XXX
- BEGIN_RING(fahrenheit, NV04_TEXTURED_TRIANGLE_SCISSOR_HORIZ, 2);
- OUT_RING (((s->maxx - s->minx) << 16) | s->minx);
- OUT_RING (((s->maxy - s->miny) << 16) | s->miny);*/
-}
-
-static void
-nv04_set_viewport_state(struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- nv04->viewport = *viewport;
-
- draw_set_viewport_state(nv04->draw, &nv04->viewport);
-}
-
-static void
-nv04_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
- const struct pipe_vertex_buffer *buffers)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- memcpy(nv04->vtxbuf, buffers, count * sizeof(buffers[0]));
- nv04->dirty |= NV04_NEW_VTXARRAYS;
-
- draw_set_vertex_buffers(nv04->draw, count, buffers);
-}
-
-static void
-nv04_set_vertex_elements(struct pipe_context *pipe, unsigned count,
- const struct pipe_vertex_element *elements)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
-
- memcpy(nv04->vtxelt, elements, sizeof(*elements) * count);
- nv04->dirty |= NV04_NEW_VTXARRAYS;
-
- draw_set_vertex_elements(nv04->draw, count, elements);
-}
-
-void
-nv04_init_state_functions(struct nv04_context *nv04)
-{
- nv04->pipe.create_blend_state = nv04_blend_state_create;
- nv04->pipe.bind_blend_state = nv04_blend_state_bind;
- nv04->pipe.delete_blend_state = nv04_blend_state_delete;
-
- nv04->pipe.create_sampler_state = nv04_sampler_state_create;
- nv04->pipe.bind_fragment_sampler_states = nv04_sampler_state_bind;
- nv04->pipe.delete_sampler_state = nv04_sampler_state_delete;
- nv04->pipe.set_fragment_sampler_textures = nv04_set_sampler_texture;
-
- nv04->pipe.create_rasterizer_state = nv04_rasterizer_state_create;
- nv04->pipe.bind_rasterizer_state = nv04_rasterizer_state_bind;
- nv04->pipe.delete_rasterizer_state = nv04_rasterizer_state_delete;
-
- nv04->pipe.create_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_create;
- nv04->pipe.bind_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_bind;
- nv04->pipe.delete_depth_stencil_alpha_state = nv04_depth_stencil_alpha_state_delete;
-
- nv04->pipe.create_vs_state = nv04_vp_state_create;
- nv04->pipe.bind_vs_state = nv04_vp_state_bind;
- nv04->pipe.delete_vs_state = nv04_vp_state_delete;
-
- nv04->pipe.create_fs_state = nv04_fp_state_create;
- nv04->pipe.bind_fs_state = nv04_fp_state_bind;
- nv04->pipe.delete_fs_state = nv04_fp_state_delete;
-
- nv04->pipe.set_blend_color = nv04_set_blend_color;
- nv04->pipe.set_clip_state = nv04_set_clip_state;
- nv04->pipe.set_constant_buffer = nv04_set_constant_buffer;
- nv04->pipe.set_framebuffer_state = nv04_set_framebuffer_state;
- nv04->pipe.set_polygon_stipple = nv04_set_polygon_stipple;
- nv04->pipe.set_scissor_state = nv04_set_scissor_state;
- nv04->pipe.set_viewport_state = nv04_set_viewport_state;
-
- nv04->pipe.set_vertex_buffers = nv04_set_vertex_buffers;
- nv04->pipe.set_vertex_elements = nv04_set_vertex_elements;
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_state.h b/src/gallium/drivers/nv04/nv04_state.h
deleted file mode 100644
index 81d1d2ebaa..0000000000
--- a/src/gallium/drivers/nv04/nv04_state.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef __NV04_STATE_H__
-#define __NV04_STATE_H__
-
-#include "pipe/p_state.h"
-#include "tgsi/tgsi_scan.h"
-
-struct nv04_blend_state {
- uint32_t b_enable;
- uint32_t b_src;
- uint32_t b_dst;
-};
-
-struct nv04_fragtex_state {
- uint32_t format;
-};
-
-struct nv04_sampler_state {
- uint32_t filter;
- uint32_t format;
-};
-
-struct nv04_depth_stencil_alpha_state {
- uint32_t control;
-};
-
-struct nv04_rasterizer_state {
- uint32_t blend;
-
- const struct pipe_rasterizer_state *templ;
-};
-
-struct nv04_miptree {
- struct pipe_texture base;
- struct nouveau_bo *bo;
-
- struct pipe_buffer *buffer;
- uint total_size;
-
- struct {
- uint pitch;
- uint *image_offset;
- } level[PIPE_MAX_TEXTURE_LEVELS];
-};
-
-struct nv04_fragment_program_data {
- unsigned offset;
- unsigned index;
-};
-
-struct nv04_fragment_program {
- struct pipe_shader_state pipe;
- struct tgsi_shader_info info;
-
- boolean translated;
- boolean on_hw;
- unsigned samplers;
-
- uint32_t *insn;
- int insn_len;
-
- struct nv04_fragment_program_data *consts;
- unsigned nr_consts;
-
- struct pipe_buffer *buffer;
-
- uint32_t fp_control;
- uint32_t fp_reg_control;
-};
-
-
-
-#endif
diff --git a/src/gallium/drivers/nv04/nv04_state_emit.c b/src/gallium/drivers/nv04/nv04_state_emit.c
deleted file mode 100644
index b8d6dc560f..0000000000
--- a/src/gallium/drivers/nv04/nv04_state_emit.c
+++ /dev/null
@@ -1,246 +0,0 @@
-#include "nv04_context.h"
-#include "nv04_state.h"
-
-static void nv04_vertex_layout(struct pipe_context* pipe)
-{
- struct nv04_context *nv04 = nv04_context(pipe);
- struct nv04_fragment_program *fp = nv04->fragprog.current;
- uint32_t src = 0;
- int i;
- struct vertex_info vinfo;
-
- memset(&vinfo, 0, sizeof(vinfo));
-
- for (i = 0; i < fp->info.num_inputs; i++) {
- int isn = fp->info.input_semantic_name[i];
- int isi = fp->info.input_semantic_index[i];
- switch (isn) {
- case TGSI_SEMANTIC_POSITION:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
- break;
- case TGSI_SEMANTIC_COLOR:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
- break;
- default:
- case TGSI_SEMANTIC_GENERIC:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
- break;
- case TGSI_SEMANTIC_FOG:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
- break;
- }
- }
-
- printf("%d vertex input\n",fp->info.num_inputs);
- draw_compute_vertex_size(&vinfo);
-}
-
-static uint32_t nv04_blend_func(uint32_t f)
-{
- switch ( f ) {
- case PIPE_BLENDFACTOR_ZERO: return 0x1;
- case PIPE_BLENDFACTOR_ONE: return 0x2;
- case PIPE_BLENDFACTOR_SRC_COLOR: return 0x3;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR: return 0x4;
- case PIPE_BLENDFACTOR_SRC_ALPHA: return 0x5;
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA: return 0x6;
- case PIPE_BLENDFACTOR_DST_ALPHA: return 0x7;
- case PIPE_BLENDFACTOR_INV_DST_ALPHA: return 0x8;
- case PIPE_BLENDFACTOR_DST_COLOR: return 0x9;
- case PIPE_BLENDFACTOR_INV_DST_COLOR: return 0xA;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: return 0xB;
- }
- NOUVEAU_MSG("Unable to find the blend function 0x%x\n",f);
- return 0;
-}
-
-static void nv04_emit_control(struct nv04_context* nv04)
-{
- uint32_t control = nv04->dsa->control;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
- OUT_RING(chan, control);
-}
-
-static void nv04_emit_blend(struct nv04_context* nv04)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- uint32_t blend;
-
- blend=0x4; // texture MODULATE_ALPHA
- blend|=0x20; // alpha is MSB
- blend|=(2<<6); // flat shading
- blend|=(1<<8); // persp correct
- blend|=(0<<16); // no fog
- blend|=(nv04->blend->b_enable<<20);
- blend|=(nv04_blend_func(nv04->blend->b_src)<<24);
- blend|=(nv04_blend_func(nv04->blend->b_dst)<<28);
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_BLEND, 1);
- OUT_RING(chan, blend);
-}
-
-static void nv04_emit_sampler(struct nv04_context *nv04, int unit)
-{
- struct nv04_miptree *nv04mt = nv04->tex_miptree[unit];
- struct pipe_texture *pt = &nv04mt->base;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- struct nouveau_bo *bo = nouveau_bo(nv04mt->buffer);
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 3);
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- OUT_RELOCd(chan, bo, (nv04->fragtex.format | nv04->sampler[unit]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
- OUT_RING(chan, nv04->sampler[unit]->filter);
-}
-
-static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
-{
- struct pipe_framebuffer_state* fb = nv04->framebuffer;
- struct nv04_surface *rt, *zeta;
- uint32_t rt_format, w, h;
- int colour_format = 0, zeta_format = 0;
- struct nv04_miptree *nv04mt = 0;
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *context_surfaces_3d = screen->context_surfaces_3d;
- struct nouveau_bo *bo;
-
- w = fb->cbufs[0]->width;
- h = fb->cbufs[0]->height;
- colour_format = fb->cbufs[0]->format;
- rt = (struct nv04_surface *)fb->cbufs[0];
-
- if (fb->zsbuf) {
- if (colour_format) {
- assert(w == fb->zsbuf->width);
- assert(h == fb->zsbuf->height);
- } else {
- w = fb->zsbuf->width;
- h = fb->zsbuf->height;
- }
-
- zeta_format = fb->zsbuf->format;
- zeta = (struct nv04_surface *)fb->zsbuf;
- }
-
- switch (colour_format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case 0:
- rt_format = 0x108;
- break;
- case PIPE_FORMAT_R5G6B5_UNORM:
- rt_format = 0x103;
- break;
- default:
- assert(0);
- }
-
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1);
- OUT_RING(chan, rt_format);
-
- nv04mt = (struct nv04_miptree *)rt->base.texture;
- bo = nouveau_bo(nv04mt->buffer);
- /* FIXME pitches have to be aligned ! */
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
- OUT_RING(chan, rt->pitch|(zeta->pitch<<16));
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- if (fb->zsbuf) {
- nv04mt = (struct nv04_miptree *)zeta->base.texture;
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- }
-}
-
-void
-nv04_emit_hw_state(struct nv04_context *nv04)
-{
- struct nv04_screen *screen = nv04->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *fahrenheit = screen->fahrenheit;
- struct nouveau_grobj *context_surfaces_3d = screen->context_surfaces_3d;
- int i;
-
- if (nv04->dirty & NV04_NEW_VERTPROG) {
- //nv04_vertprog_bind(nv04, nv04->vertprog.current);
- nv04->dirty &= ~NV04_NEW_VERTPROG;
- }
-
- if (nv04->dirty & NV04_NEW_FRAGPROG) {
- nv04_fragprog_bind(nv04, nv04->fragprog.current);
- nv04->dirty &= ~NV04_NEW_FRAGPROG;
- nv04->dirty_samplers |= (1<<10);
- nv04->dirty_samplers = 0;
- }
-
- if (nv04->dirty & NV04_NEW_CONTROL) {
- nv04->dirty &= ~NV04_NEW_CONTROL;
-
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
- OUT_RING(chan, nv04->dsa->control);
- }
-
- if (nv04->dirty & NV04_NEW_BLEND) {
- nv04->dirty &= ~NV04_NEW_BLEND;
-
- nv04_emit_blend(nv04);
- }
-
- if (nv04->dirty & NV04_NEW_VTXARRAYS) {
- nv04->dirty &= ~NV04_NEW_VTXARRAYS;
- nv04_vertex_layout(nv04);
- }
-
- if (nv04->dirty & NV04_NEW_SAMPLER) {
- nv04->dirty &= ~NV04_NEW_SAMPLER;
-
- nv04_emit_sampler(nv04, 0);
- }
-
- if (nv04->dirty & NV04_NEW_VIEWPORT) {
- nv04->dirty &= ~NV04_NEW_VIEWPORT;
-// nv04_state_emit_viewport(nv04);
- }
-
- if (nv04->dirty & NV04_NEW_FRAMEBUFFER) {
- nv04->dirty &= ~NV04_NEW_FRAMEBUFFER;
- nv04_state_emit_framebuffer(nv04);
- }
-
- /* Emit relocs for every referenced buffer.
- * This is to ensure the bufmgr has an accurate idea of how
- * the buffer is used. This isn't very efficient, but we don't
- * seem to take a significant performance hit. Will be improved
- * at some point. Vertex arrays are emitted by nv04_vbo.c
- */
-
- /* Render target */
- unsigned rt_pitch = ((struct nv04_surface *)nv04->rt)->pitch;
- unsigned zeta_pitch = ((struct nv04_surface *)nv04->zeta)->pitch;
-
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
- OUT_RING(chan, rt_pitch|(zeta_pitch<<16));
- OUT_RELOCl(chan, nouveau_bo(nv04->rt), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- if (nv04->zeta) {
- BEGIN_RING(chan, context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
- OUT_RELOCl(chan, nouveau_bo(nv04->zeta), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- }
-
- /* Texture images */
- for (i = 0; i < 1; i++) {
- if (!(nv04->fp_samplers & (1 << i)))
- continue;
- struct nv04_miptree *nv04mt = nv04->tex_miptree[i];
- struct nouveau_bo *bo = nouveau_bo(nv04mt->buffer);
- BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_OFFSET, 2);
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- OUT_RELOCd(chan, bo, (nv04->fragtex.format | nv04->sampler[i]->format), NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
- }
-}
-
diff --git a/src/gallium/drivers/nv04/nv04_transfer.c b/src/gallium/drivers/nv04/nv04_transfer.c
deleted file mode 100644
index 2dd2e146a8..0000000000
--- a/src/gallium/drivers/nv04/nv04_transfer.c
+++ /dev/null
@@ -1,178 +0,0 @@
-#include <pipe/p_state.h>
-#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
-#include <util/u_format.h>
-#include <util/u_memory.h>
-#include <util/u_math.h>
-#include <nouveau/nouveau_winsys.h>
-#include "nv04_context.h"
-#include "nv04_screen.h"
-#include "nv04_state.h"
-
-struct nv04_transfer {
- struct pipe_transfer base;
- struct pipe_surface *surface;
- boolean direct;
-};
-
-static void
-nv04_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
- struct pipe_texture *template)
-{
- memset(template, 0, sizeof(struct pipe_texture));
- template->target = pt->target;
- template->format = pt->format;
- template->width0 = width;
- template->height0 = height;
- template->depth0 = 1;
- template->last_level = 0;
- template->nr_samples = pt->nr_samples;
-
- template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
- NOUVEAU_TEXTURE_USAGE_LINEAR;
-}
-
-static struct pipe_transfer *
-nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
-{
- struct nv04_miptree *mt = (struct nv04_miptree *)pt;
- struct nv04_transfer *tx;
- struct pipe_texture tx_tex_template, *tx_tex;
-
- tx = CALLOC_STRUCT(nv04_transfer);
- if (!tx)
- return NULL;
-
- pipe_texture_reference(&tx->base.texture, pt);
- tx->base.x = x;
- tx->base.y = y;
- tx->base.width = w;
- tx->base.height = h;
- tx->base.stride = mt->level[level].pitch;
- tx->base.usage = usage;
- tx->base.face = face;
- tx->base.level = level;
- 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*/)) &&
- pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
- {
- tx->direct = true;
- tx->surface = pscreen->get_tex_surface(pscreen, pt,
- 0, 0, 0,
- pipe_transfer_buffer_flags(&tx->base));
- return &tx->base;
- }
-
- tx->direct = false;
-
- nv04_compatible_transfer_tex(pt, w, h, &tx_tex_template);
-
- tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
- if (!tx_tex)
- {
- FREE(tx);
- return NULL;
- }
-
- tx->base.stride = ((struct nv04_miptree*)tx_tex)->level[0].pitch;
-
- tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
- face, level, zslice,
- pipe_transfer_buffer_flags(&tx->base));
-
- pipe_texture_reference(&tx_tex, NULL);
-
- if (!tx->surface)
- {
- pipe_surface_reference(&tx->surface, NULL);
- FREE(tx);
- return NULL;
- }
-
- if (usage & PIPE_TRANSFER_READ) {
- struct nv04_screen *nvscreen = nv04_screen(pscreen);
- struct pipe_surface *src;
-
- src = pscreen->get_tex_surface(pscreen, pt,
- face, level, zslice,
- PIPE_BUFFER_USAGE_GPU_READ);
-
- /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
- /* TODO: Check if SIFM can un-swizzle */
- nvscreen->eng2d->copy(nvscreen->eng2d,
- tx->surface, 0, 0,
- src, x, y,
- w, h);
-
- pipe_surface_reference(&src, NULL);
- }
-
- return &tx->base;
-}
-
-static void
-nv04_transfer_del(struct pipe_transfer *ptx)
-{
- struct nv04_transfer *tx = (struct nv04_transfer *)ptx;
-
- if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
- struct pipe_screen *pscreen = ptx->texture->screen;
- struct nv04_screen *nvscreen = nv04_screen(pscreen);
- struct pipe_surface *dst;
-
- dst = pscreen->get_tex_surface(pscreen, ptx->texture,
- ptx->face, ptx->level, ptx->zslice,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
- /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
- nvscreen->eng2d->copy(nvscreen->eng2d,
- dst, tx->base.x, tx->base.y,
- tx->surface, 0, 0,
- tx->base.width, tx->base.height);
-
- pipe_surface_reference(&dst, NULL);
- }
-
- pipe_surface_reference(&tx->surface, NULL);
- pipe_texture_reference(&ptx->texture, NULL);
- FREE(ptx);
-}
-
-static void *
-nv04_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
-{
- struct nv04_transfer *tx = (struct nv04_transfer *)ptx;
- struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
- struct nv04_miptree *mt = (struct nv04_miptree *)tx->surface->texture;
- void *map = pipe_buffer_map(pscreen, mt->buffer,
- pipe_transfer_buffer_flags(ptx));
-
- if(!tx->direct)
- return map + ns->base.offset;
- else
- return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
-}
-
-static void
-nv04_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
-{
- struct nv04_transfer *tx = (struct nv04_transfer *)ptx;
- struct nv04_miptree *mt = (struct nv04_miptree *)tx->surface->texture;
-
- pipe_buffer_unmap(pscreen, mt->buffer);
-}
-
-void
-nv04_screen_init_transfer_functions(struct pipe_screen *pscreen)
-{
- pscreen->get_tex_transfer = nv04_transfer_new;
- pscreen->tex_transfer_destroy = nv04_transfer_del;
- pscreen->transfer_map = nv04_transfer_map;
- pscreen->transfer_unmap = nv04_transfer_unmap;
-}
diff --git a/src/gallium/drivers/nv04/nv04_vbo.c b/src/gallium/drivers/nv04/nv04_vbo.c
deleted file mode 100644
index 2db61d8941..0000000000
--- a/src/gallium/drivers/nv04/nv04_vbo.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
-
-#include "nv04_context.h"
-#include "nv04_state.h"
-
-#include "nouveau/nouveau_channel.h"
-#include "nouveau/nouveau_pushbuf.h"
-
-void nv04_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count)
-{
- struct pipe_screen *pscreen = pipe->screen;
- struct nv04_context *nv04 = nv04_context( pipe );
- struct draw_context *draw = nv04->draw;
- unsigned i;
-
- nv04_emit_hw_state(nv04);
-
- /*
- * Map vertex buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (nv04->vtxbuf[i].buffer) {
- void *buf
- = pipe_buffer_map(pscreen,
- nv04->vtxbuf[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
- }
- /* Map index buffer, if present */
- if (indexBuffer) {
- void *mapped_indexes
- = pipe_buffer_map(pscreen, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
- }
- else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
- draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
- nv04->constbuf[PIPE_SHADER_VERTEX],
- nv04->constbuf_nr[PIPE_SHADER_VERTEX]);
-
- /* draw! */
- draw_arrays(nv04->draw, prim, start, count);
-
- /*
- * unmap vertex/index buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (nv04->vtxbuf[i].buffer) {
- pipe_buffer_unmap(pscreen, nv04->vtxbuf[i].buffer);
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- }
- }
- if (indexBuffer) {
- pipe_buffer_unmap(pscreen, indexBuffer);
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-}
-
-void nv04_draw_arrays( struct pipe_context *pipe,
- unsigned prim, unsigned start, unsigned count)
-{
- printf("coucou in draw arrays\n");
- nv04_draw_elements(pipe, NULL, 0, prim, start, count);
-}
-
-
-
diff --git a/src/gallium/drivers/nv10/Makefile b/src/gallium/drivers/nv10/Makefile
deleted file mode 100644
index 62677f5194..0000000000
--- a/src/gallium/drivers/nv10/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nv10
-
-C_SOURCES = \
- nv10_clear.c \
- nv10_context.c \
- nv10_fragprog.c \
- nv10_fragtex.c \
- nv10_miptree.c \
- nv10_prim_vbuf.c \
- nv10_screen.c \
- nv10_state.c \
- nv10_state_emit.c \
- nv10_surface.c \
- nv10_transfer.c \
- nv10_vbo.c
-
-include ../../Makefile.template
diff --git a/src/gallium/drivers/nv10/nv10_clear.c b/src/gallium/drivers/nv10/nv10_clear.c
deleted file mode 100644
index a39a2b5f52..0000000000
--- a/src/gallium/drivers/nv10/nv10_clear.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "util/u_clear.h"
-
-#include "nv10_context.h"
-
-void
-nv10_clear(struct pipe_context *pipe, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
-{
- util_clear(pipe, nv10_context(pipe)->framebuffer, buffers, rgba, depth,
- stencil);
-}
diff --git a/src/gallium/drivers/nv10/nv10_context.c b/src/gallium/drivers/nv10/nv10_context.c
deleted file mode 100644
index 1ecb73d06e..0000000000
--- a/src/gallium/drivers/nv10/nv10_context.c
+++ /dev/null
@@ -1,298 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
-
-#include "nv10_context.h"
-#include "nv10_screen.h"
-
-static void
-nv10_flush(struct pipe_context *pipe, unsigned flags,
- struct pipe_fence_handle **fence)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
-
- draw_flush(nv10->draw);
-
- FIRE_RING(chan);
- if (fence)
- *fence = NULL;
-}
-
-static void
-nv10_destroy(struct pipe_context *pipe)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- if (nv10->draw)
- draw_destroy(nv10->draw);
-
- FREE(nv10);
-}
-
-static void nv10_init_hwctx(struct nv10_context *nv10)
-{
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
- int i;
- float projectionmatrix[16];
-
- BEGIN_RING(chan, celsius, NV10TCL_DMA_NOTIFY, 1);
- OUT_RING (chan, screen->sync->handle);
- BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY0, 2);
- OUT_RING (chan, chan->vram->handle);
- OUT_RING (chan, chan->gart->handle);
- BEGIN_RING(chan, celsius, NV10TCL_DMA_IN_MEMORY2, 2);
- OUT_RING (chan, chan->vram->handle);
- OUT_RING (chan, chan->vram->handle);
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_RT_HORIZ, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 1);
- OUT_RING (chan, (0x7ff<<16)|0x800);
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(0), 1);
- OUT_RING (chan, (0x7ff<<16)|0x800);
-
- for (i=1;i<8;i++) {
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(i), 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_VERT(i), 1);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, celsius, 0x290, 1);
- OUT_RING (chan, (0x10<<16)|1);
- BEGIN_RING(chan, celsius, 0x3f4, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING (chan, 0);
-
- if (nv10->screen->celsius->grclass != NV10TCL) {
- /* For nv11, nv17 */
- BEGIN_RING(chan, celsius, 0x120, 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 1);
- OUT_RING (chan, 2);
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING (chan, 0);
-
- /* Set state */
- BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_FUNC, 2);
- OUT_RING (chan, 0x207);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(0), 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_RC_IN_ALPHA(0), 12);
- OUT_RING (chan, 0x30141010);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0x20040000);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0x00000c00);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0x00000c00);
- OUT_RING (chan, 0x18000000);
- OUT_RING (chan, 0x300e0300);
- OUT_RING (chan, 0x0c091c80);
-
- BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_DITHER_ENABLE, 2);
- OUT_RING (chan, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_WEIGHT_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_SRC, 4);
- OUT_RING (chan, 1);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0x8006);
- BEGIN_RING(chan, celsius, NV10TCL_STENCIL_MASK, 8);
- OUT_RING (chan, 0xff);
- OUT_RING (chan, 0x207);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0xff);
- OUT_RING (chan, 0x1e00);
- OUT_RING (chan, 0x1e00);
- OUT_RING (chan, 0x1e00);
- OUT_RING (chan, 0x1d01);
- BEGIN_RING(chan, celsius, NV10TCL_NORMALIZE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_FOG_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_LIGHT_MODEL, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_COLOR_CONTROL, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_ENABLED_LIGHTS, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_FUNC, 1);
- OUT_RING (chan, 0x201);
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_TEST_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_OFFSET_FACTOR, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_POINT_SIZE, 1);
- OUT_RING (chan, 8);
- BEGIN_RING(chan, celsius, NV10TCL_POINT_PARAMETERS_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_LINE_WIDTH, 1);
- OUT_RING (chan, 8);
- BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_MODE_FRONT, 2);
- OUT_RING (chan, 0x1b02);
- OUT_RING (chan, 0x1b02);
- BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE, 2);
- OUT_RING (chan, 0x405);
- OUT_RING (chan, 0x901);
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_SMOOTH_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_TX_GEN_S(0), 8);
- for (i=0;i<8;i++) {
- OUT_RING (chan, 0);
- }
- BEGIN_RING(chan, celsius, NV10TCL_FOG_EQUATION_CONSTANT, 3);
- OUT_RING (chan, 0x3fc00000); /* -1.50 */
- OUT_RING (chan, 0xbdb8aa0a); /* -0.09 */
- OUT_RING (chan, 0); /* 0.00 */
-
- BEGIN_RING(chan, celsius, NV10TCL_NOP, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, celsius, NV10TCL_FOG_MODE, 2);
- OUT_RING (chan, 0x802);
- OUT_RING (chan, 2);
- /* for some reason VIEW_MATRIX_ENABLE need to be 6 instead of 4 when
- * using texturing, except when using the texture matrix
- */
- BEGIN_RING(chan, celsius, NV10TCL_VIEW_MATRIX_ENABLE, 1);
- OUT_RING (chan, 6);
- BEGIN_RING(chan, celsius, NV10TCL_COLOR_MASK, 1);
- OUT_RING (chan, 0x01010101);
-
- /* Set vertex component */
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL_4F_R, 4);
- OUT_RINGf (chan, 1.0);
- OUT_RINGf (chan, 1.0);
- OUT_RINGf (chan, 1.0);
- OUT_RINGf (chan, 1.0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_COL2_3F_R, 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_NOR_3F_X, 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RINGf (chan, 1.0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX0_4F_S, 4);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 1.0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_TX1_4F_S, 4);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 1.0);
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_FOG_1F, 1);
- OUT_RINGf (chan, 0.0);
- BEGIN_RING(chan, celsius, NV10TCL_EDGEFLAG_ENABLE, 1);
- OUT_RING (chan, 1);
-
- memset(projectionmatrix, 0, sizeof(projectionmatrix));
- BEGIN_RING(chan, celsius, NV10TCL_PROJECTION_MATRIX(0), 16);
- projectionmatrix[0*4+0] = 1.0;
- projectionmatrix[1*4+1] = 1.0;
- projectionmatrix[2*4+2] = 1.0;
- projectionmatrix[3*4+3] = 1.0;
- for (i=0;i<16;i++) {
- OUT_RINGf (chan, projectionmatrix[i]);
- }
-
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_RANGE_NEAR, 2);
- OUT_RING (chan, 0.0);
- OUT_RINGf (chan, 16777216.0);
-
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_TRANSLATE_X, 4);
- OUT_RINGf (chan, -2048.0);
- OUT_RINGf (chan, -2048.0);
- OUT_RINGf (chan, 16777215.0 * 0.5);
- OUT_RING (chan, 0);
-
- FIRE_RING (chan);
-}
-
-struct pipe_context *
-nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
-{
- struct nv10_screen *screen = nv10_screen(pscreen);
- struct pipe_winsys *ws = pscreen->winsys;
- struct nv10_context *nv10;
- struct nouveau_winsys *nvws = screen->nvws;
-
- nv10 = CALLOC(1, sizeof(struct nv10_context));
- if (!nv10)
- return NULL;
- nv10->screen = screen;
- nv10->pctx_id = pctx_id;
-
- nv10->nvws = nvws;
-
- nv10->pipe.winsys = ws;
- nv10->pipe.screen = pscreen;
- nv10->pipe.destroy = nv10_destroy;
- nv10->pipe.draw_arrays = nv10_draw_arrays;
- nv10->pipe.draw_elements = nv10_draw_elements;
- nv10->pipe.clear = nv10_clear;
- nv10->pipe.flush = nv10_flush;
-
- nv10->pipe.is_texture_referenced = nouveau_is_texture_referenced;
- nv10->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
-
- nv10_init_surface_functions(nv10);
- nv10_init_state_functions(nv10);
-
- nv10->draw = draw_create();
- assert(nv10->draw);
- draw_set_rasterize_stage(nv10->draw, nv10_draw_vbuf_stage(nv10));
-
- nv10_init_hwctx(nv10);
-
- return &nv10->pipe;
-}
-
diff --git a/src/gallium/drivers/nv10/nv10_context.h b/src/gallium/drivers/nv10/nv10_context.h
deleted file mode 100644
index ab4b825487..0000000000
--- a/src/gallium/drivers/nv10/nv10_context.h
+++ /dev/null
@@ -1,151 +0,0 @@
-#ifndef __NV10_CONTEXT_H__
-#define __NV10_CONTEXT_H__
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "pipe/p_compiler.h"
-
-#include "util/u_memory.h"
-#include "util/u_math.h"
-
-#include "draw/draw_vertex.h"
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_gldefs.h"
-#include "nouveau/nouveau_context.h"
-
-#include "nv10_state.h"
-
-#define NOUVEAU_ERR(fmt, args...) \
- fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
-#define NOUVEAU_MSG(fmt, args...) \
- fprintf(stderr, "nouveau: "fmt, ##args);
-
-#define NV10_NEW_VERTPROG (1 << 0)
-#define NV10_NEW_FRAGPROG (1 << 1)
-#define NV10_NEW_VTXARRAYS (1 << 2)
-#define NV10_NEW_BLEND (1 << 3)
-#define NV10_NEW_BLENDCOL (1 << 4)
-#define NV10_NEW_RAST (1 << 5)
-#define NV10_NEW_DSA (1 << 6)
-#define NV10_NEW_VIEWPORT (1 << 7)
-#define NV10_NEW_SCISSOR (1 << 8)
-#define NV10_NEW_FRAMEBUFFER (1 << 9)
-
-#include "nv10_screen.h"
-
-struct nv10_context {
- struct pipe_context pipe;
-
- struct nouveau_winsys *nvws;
- struct nv10_screen *screen;
- unsigned pctx_id;
-
- struct draw_context *draw;
-
- uint32_t dirty;
-
- struct nv10_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
- struct nv10_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
- unsigned dirty_samplers;
- unsigned fp_samplers;
- unsigned vp_samplers;
-
- uint32_t rt_enable;
- struct pipe_buffer *rt[4];
- struct pipe_buffer *zeta;
- uint32_t lma_offset;
-
- struct nv10_blend_state *blend;
- struct pipe_blend_color *blend_color;
- struct nv10_rasterizer_state *rast;
- struct nv10_depth_stencil_alpha_state *dsa;
- struct pipe_viewport_state *viewport;
- struct pipe_scissor_state *scissor;
- struct pipe_framebuffer_state *framebuffer;
-
- //struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
- float *constbuf[PIPE_SHADER_TYPES][32][4];
- unsigned constbuf_nr[PIPE_SHADER_TYPES];
-
- struct vertex_info vertex_info;
-
- struct {
- struct pipe_buffer *buffer;
- uint32_t format;
- } tex[2];
-
- unsigned vb_enable;
- struct {
- struct pipe_buffer *buffer;
- unsigned delta;
- } vb[16];
-
-/* struct {
-
- struct nouveau_resource *exec_heap;
- struct nouveau_resource *data_heap;
-
- struct nv10_vertex_program *active;
-
- struct nv10_vertex_program *current;
- } vertprog;
-*/
- struct {
- struct nv10_fragment_program *active;
-
- struct nv10_fragment_program *current;
- struct pipe_buffer *constant_buf;
- } fragprog;
-
- struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
- struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
-};
-
-static INLINE struct nv10_context *
-nv10_context(struct pipe_context *pipe)
-{
- return (struct nv10_context *)pipe;
-}
-
-extern void nv10_init_state_functions(struct nv10_context *nv10);
-extern void nv10_init_surface_functions(struct nv10_context *nv10);
-
-extern void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen);
-
-/* nv10_clear.c */
-extern void nv10_clear(struct pipe_context *pipe, unsigned buffers,
- const float *rgba, double depth, unsigned stencil);
-
-
-/* nv10_draw.c */
-extern struct draw_stage *nv10_draw_render_stage(struct nv10_context *nv10);
-
-/* nv10_fragprog.c */
-extern void nv10_fragprog_bind(struct nv10_context *,
- struct nv10_fragment_program *);
-extern void nv10_fragprog_destroy(struct nv10_context *,
- struct nv10_fragment_program *);
-
-/* nv10_fragtex.c */
-extern void nv10_fragtex_bind(struct nv10_context *);
-
-/* nv10_prim_vbuf.c */
-struct draw_stage *nv10_draw_vbuf_stage( struct nv10_context *nv10 );
-extern void nv10_vtxbuf_bind(struct nv10_context* nv10);
-
-/* nv10_state.c and friends */
-extern void nv10_emit_hw_state(struct nv10_context *nv10);
-extern void nv10_state_tex_update(struct nv10_context *nv10);
-
-/* nv10_vbo.c */
-extern void nv10_draw_arrays(struct pipe_context *, unsigned mode,
- unsigned start, unsigned count);
-extern void nv10_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count);
-
-
-#endif
diff --git a/src/gallium/drivers/nv10/nv10_fragprog.c b/src/gallium/drivers/nv10/nv10_fragprog.c
deleted file mode 100644
index 698db5a16a..0000000000
--- a/src/gallium/drivers/nv10/nv10_fragprog.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#include "pipe/p_shader_tokens.h"
-#include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_util.h"
-
-#include "nv10_context.h"
-
-void
-nv10_fragprog_bind(struct nv10_context *nv10, struct nv10_fragment_program *fp)
-{
-}
-
-void
-nv10_fragprog_destroy(struct nv10_context *nv10,
- struct nv10_fragment_program *fp)
-{
-}
-
diff --git a/src/gallium/drivers/nv10/nv10_fragtex.c b/src/gallium/drivers/nv10/nv10_fragtex.c
deleted file mode 100644
index c1f7ccb9ab..0000000000
--- a/src/gallium/drivers/nv10/nv10_fragtex.c
+++ /dev/null
@@ -1,130 +0,0 @@
-#include "nv10_context.h"
-#include "nouveau/nouveau_util.h"
-
-#define _(m,tf) \
-{ \
- TRUE, \
- PIPE_FORMAT_##m, \
- NV10TCL_TX_FORMAT_FORMAT_##tf, \
-}
-
-struct nv10_texture_format {
- boolean defined;
- uint pipe;
- int format;
-};
-
-static struct nv10_texture_format
-nv10_texture_formats[] = {
- _(A8R8G8B8_UNORM, A8R8G8B8),
- _(A1R5G5B5_UNORM, A1R5G5B5),
- _(A4R4G4B4_UNORM, A4R4G4B4),
- _(L8_UNORM , L8 ),
- _(A8_UNORM , A8 ),
- _(A8L8_UNORM , A8L8 ),
-// _(RGB_DXT1 , DXT1, ),
-// _(RGBA_DXT1 , DXT1, ),
-// _(RGBA_DXT3 , DXT3, ),
-// _(RGBA_DXT5 , DXT5, ),
- {},
-};
-
-static struct nv10_texture_format *
-nv10_fragtex_format(uint pipe_format)
-{
- struct nv10_texture_format *tf = nv10_texture_formats;
-
- while (tf->defined) {
- if (tf->pipe == pipe_format)
- return tf;
- tf++;
- }
-
- return NULL;
-}
-
-
-static void
-nv10_fragtex_build(struct nv10_context *nv10, int unit)
-{
-#if 0
- struct nv10_sampler_state *ps = nv10->tex_sampler[unit];
- struct nv10_miptree *nv10mt = nv10->tex_miptree[unit];
- struct pipe_texture *pt = &nv10mt->base;
- struct nv10_texture_format *tf;
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
- uint32_t txf, txs, txp;
-
- tf = nv10_fragtex_format(pt->format);
- if (!tf || !tf->defined) {
- NOUVEAU_ERR("Unsupported texture format: 0x%x\n", pt->format);
- return;
- }
-
- txf = tf->format << 8;
- txf |= (pt->last_level + 1) << 16;
- txf |= log2i(pt->width0) << 20;
- txf |= log2i(pt->height0) << 24;
- txf |= log2i(pt->depth0) << 28;
- txf |= 8;
-
- switch (pt->target) {
- case PIPE_TEXTURE_CUBE:
- txf |= NV10TCL_TX_FORMAT_CUBE_MAP;
- /* fall-through */
- case PIPE_TEXTURE_2D:
- txf |= (2<<4);
- break;
- case PIPE_TEXTURE_1D:
- txf |= (1<<4);
- break;
- default:
- NOUVEAU_ERR("Unknown target %d\n", pt->target);
- return;
- }
-
- BEGIN_RING(chan, celsius, NV10TCL_TX_OFFSET(unit), 8);
- OUT_RELOCl(chan, nouveau_bo(nv10mt->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- OUT_RELOCd(chan, nouveau_bo(nv10mt->buffer),txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
- OUT_RING (chan, ps->wrap);
- OUT_RING (chan, 0x40000000); /* enable */
- OUT_RING (chan, txs);
- OUT_RING (chan, ps->filt | 0x2000 /* magic */);
- OUT_RING (chan, (pt->width0 << 16) | pt->height0);
- OUT_RING (chan, ps->bcol);
-#endif
-}
-
-void
-nv10_fragtex_bind(struct nv10_context *nv10)
-{
-#if 0
- struct nv10_fragment_program *fp = nv10->fragprog.active;
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
- unsigned samplers, unit;
-
- samplers = nv10->fp_samplers & ~fp->samplers;
- while (samplers) {
- unit = ffs(samplers) - 1;
- samplers &= ~(1 << unit);
-
- BEGIN_RING(chan, celsius, NV10TCL_TX_ENABLE(unit), 1);
- OUT_RING (chan, 0);
- }
-
- samplers = nv10->dirty_samplers & fp->samplers;
- while (samplers) {
- unit = ffs(samplers) - 1;
- samplers &= ~(1 << unit);
-
- nv10_fragtex_build(nv10, unit);
- }
-
- nv10->fp_samplers = fp->samplers;
-#endif
-}
-
diff --git a/src/gallium/drivers/nv10/nv10_miptree.c b/src/gallium/drivers/nv10/nv10_miptree.c
deleted file mode 100644
index 908482ad85..0000000000
--- a/src/gallium/drivers/nv10/nv10_miptree.c
+++ /dev/null
@@ -1,165 +0,0 @@
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-
-#include "nv10_context.h"
-#include "nv10_screen.h"
-
-static void
-nv10_miptree_layout(struct nv10_miptree *nv10mt)
-{
- struct pipe_texture *pt = &nv10mt->base;
- boolean swizzled = FALSE;
- uint width = pt->width0;
- uint offset = 0;
- int nr_faces, l, f;
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- nr_faces = 6;
- } else {
- nr_faces = 1;
- }
-
- for (l = 0; l <= pt->last_level; l++) {
- if (swizzled)
- nv10mt->level[l].pitch = util_format_get_stride(pt->format, width);
- else
- nv10mt->level[l].pitch = util_format_get_stride(pt->format, pt->width0);
- nv10mt->level[l].pitch = (nv10mt->level[l].pitch + 63) & ~63;
-
- nv10mt->level[l].image_offset =
- CALLOC(nr_faces, sizeof(unsigned));
-
- width = u_minify(width, 1);
-
- }
-
- for (f = 0; f < nr_faces; f++) {
- for (l = 0; l <= pt->last_level; l++) {
- nv10mt->level[l].image_offset[f] = offset;
- offset += nv10mt->level[l].pitch * u_minify(pt->height0, l);
- }
- }
-
- nv10mt->total_size = offset;
-}
-
-static struct pipe_texture *
-nv10_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
- const unsigned *stride, struct pipe_buffer *pb)
-{
- struct nv10_miptree *mt;
-
- /* Only supports 2D, non-mipmapped textures for the moment */
- if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
- pt->depth0 != 1)
- return NULL;
-
- mt = CALLOC_STRUCT(nv10_miptree);
- if (!mt)
- return NULL;
-
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = pscreen;
- mt->level[0].pitch = stride[0];
- mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
-
- pipe_buffer_reference(&mt->buffer, pb);
- mt->bo = nouveau_bo(mt->buffer);
- return &mt->base;
-}
-
-static struct pipe_texture *
-nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
-{
- struct nv10_miptree *mt;
-
- mt = MALLOC(sizeof(struct nv10_miptree));
- if (!mt)
- return NULL;
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = screen;
-
- nv10_miptree_layout(mt);
-
- mt->buffer = screen->buffer_create(screen, 256, PIPE_BUFFER_USAGE_PIXEL,
- mt->total_size);
- if (!mt->buffer) {
- FREE(mt);
- return NULL;
- }
- mt->bo = nouveau_bo(mt->buffer);
-
- return &mt->base;
-}
-
-static void
-nv10_miptree_destroy(struct pipe_texture *pt)
-{
- struct nv10_miptree *nv10mt = (struct nv10_miptree *)pt;
- int l;
-
- pipe_buffer_reference(&nv10mt->buffer, NULL);
- for (l = 0; l <= pt->last_level; l++) {
- if (nv10mt->level[l].image_offset)
- FREE(nv10mt->level[l].image_offset);
- }
- FREE(nv10mt);
-}
-
-static void
-nv10_miptree_update(struct pipe_context *pipe, struct pipe_texture *mt,
- uint face, uint levels)
-{
-}
-
-
-static struct pipe_surface *
-nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
-{
- struct nv10_miptree *nv10mt = (struct nv10_miptree *)pt;
- struct nv04_surface *ns;
-
- ns = CALLOC_STRUCT(nv04_surface);
- if (!ns)
- return NULL;
- pipe_texture_reference(&ns->base.texture, pt);
- ns->base.format = pt->format;
- ns->base.width = u_minify(pt->width0, level);
- ns->base.height = u_minify(pt->height0, level);
- ns->base.usage = flags;
- pipe_reference_init(&ns->base.reference, 1);
- ns->base.face = face;
- ns->base.level = level;
- ns->base.zslice = zslice;
- ns->pitch = nv10mt->level[level].pitch;
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- ns->base.offset = nv10mt->level[level].image_offset[face];
- } else {
- ns->base.offset = nv10mt->level[level].image_offset[0];
- }
-
- return &ns->base;
-}
-
-static void
-nv10_miptree_surface_destroy(struct pipe_surface *surface)
-{
-}
-
-void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen)
-{
- pscreen->texture_create = nv10_miptree_create;
- pscreen->texture_blanket = nv10_miptree_blanket;
- pscreen->texture_destroy = nv10_miptree_destroy;
- pscreen->get_tex_surface = nv10_miptree_surface_get;
- pscreen->tex_surface_destroy = nv10_miptree_surface_destroy;
-}
-
diff --git a/src/gallium/drivers/nv10/nv10_prim_vbuf.c b/src/gallium/drivers/nv10/nv10_prim_vbuf.c
deleted file mode 100644
index c5dbe43dbc..0000000000
--- a/src/gallium/drivers/nv10/nv10_prim_vbuf.c
+++ /dev/null
@@ -1,267 +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.
- *
- **************************************************************************/
-
-/**
- * \file
- * Build post-transformation, post-clipping vertex buffers and element
- * lists by hooking into the end of the primitive pipeline and
- * manipulating the vertex_id field in the vertex headers.
- *
- * XXX: work in progress
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- * \author Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "util/u_debug.h"
-#include "pipe/p_inlines.h"
-
-#include "nv10_context.h"
-#include "nv10_state.h"
-
-#include "draw/draw_vbuf.h"
-
-/**
- * Primitive renderer for nv10.
- */
-struct nv10_vbuf_render {
- struct vbuf_render base;
-
- struct nv10_context *nv10;
-
- /** Vertex buffer */
- struct pipe_buffer* buffer;
-
- /** Vertex size in bytes */
- unsigned vertex_size;
-
- /** Hardware primitive */
- unsigned hwprim;
-};
-
-
-void nv10_vtxbuf_bind( struct nv10_context* nv10 )
-{
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
- int i;
- for(i = 0; i < 8; i++) {
- BEGIN_RING(chan, celsius, NV10TCL_VTXBUF_ADDRESS(i), 1);
- OUT_RING(chan, 0/*nv10->vtxbuf*/);
- BEGIN_RING(chan, celsius, NV10TCL_VTXFMT(i), 1);
- OUT_RING(chan, 0/*XXX*/);
- }
-}
-
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct nv10_vbuf_render *
-nv10_vbuf_render( struct vbuf_render *render )
-{
- assert(render);
- return (struct nv10_vbuf_render *)render;
-}
-
-
-static const struct vertex_info *
-nv10_vbuf_render_get_vertex_info( struct vbuf_render *render )
-{
- struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
- struct nv10_context *nv10 = nv10_render->nv10;
-
- nv10_emit_hw_state(nv10);
-
- return &nv10->vertex_info;
-}
-
-static boolean
-nv10_vbuf_render_allocate_vertices( struct vbuf_render *render,
- ushort vertex_size,
- ushort nr_vertices )
-{
- struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
- struct nv10_context *nv10 = nv10_render->nv10;
- struct pipe_screen *screen = nv10->pipe.screen;
- size_t size = (size_t)vertex_size * (size_t)nr_vertices;
-
- assert(!nv10_render->buffer);
- nv10_render->buffer = screen->buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX, size);
-
- nv10->dirty |= NV10_NEW_VTXARRAYS;
-
- if (nv10_render->buffer)
- return FALSE;
- return TRUE;
-}
-
-static void *
-nv10_vbuf_render_map_vertices( struct vbuf_render *render )
-{
- struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
- struct nv10_context *nv10 = nv10_render->nv10;
- struct pipe_screen *pscreen = nv10->pipe.screen;
-
- return pipe_buffer_map(pscreen, nv10_render->buffer,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-}
-
-static void
-nv10_vbuf_render_unmap_vertices( struct vbuf_render *render,
- ushort min_index,
- ushort max_index )
-{
- struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
- struct nv10_context *nv10 = nv10_render->nv10;
- struct pipe_screen *pscreen = nv10->pipe.screen;
-
- assert(!nv10_render->buffer);
- pipe_buffer_unmap(pscreen, nv10_render->buffer);
-}
-
-static boolean
-nv10_vbuf_render_set_primitive( struct vbuf_render *render,
- unsigned prim )
-{
- struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
- unsigned hwp = nvgl_primitive(prim);
- if (hwp == 0)
- return FALSE;
-
- nv10_render->hwprim = hwp;
- return TRUE;
-}
-
-
-static void
-nv10_vbuf_render_draw( struct vbuf_render *render,
- const ushort *indices,
- uint nr_indices)
-{
- struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
- struct nv10_context *nv10 = nv10_render->nv10;
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
- int push, i;
-
- nv10_emit_hw_state(nv10);
-
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1);
- OUT_RELOCl(chan, nouveau_bo(nv10_render->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
-
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
- OUT_RING(chan, nv10_render->hwprim);
-
- if (nr_indices & 1) {
- BEGIN_RING(chan, celsius, NV10TCL_VB_ELEMENT_U32, 1);
- OUT_RING (chan, indices[0]);
- indices++; nr_indices--;
- }
-
- while (nr_indices) {
- // XXX too big/small ? check the size
- push = MIN2(nr_indices, 1200 * 2);
-
- BEGIN_RING_NI(chan, celsius, NV10TCL_VB_ELEMENT_U16, push >> 1);
- for (i = 0; i < push; i+=2)
- OUT_RING(chan, (indices[i+1] << 16) | indices[i]);
-
- nr_indices -= push;
- indices += push;
- }
-
- BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
- OUT_RING (chan, 0);
-}
-
-
-static void
-nv10_vbuf_render_release_vertices( struct vbuf_render *render )
-{
- struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
-
- assert(nv10_render->buffer);
- pipe_buffer_reference(&nv10_render->buffer, NULL);
-}
-
-
-static void
-nv10_vbuf_render_destroy( struct vbuf_render *render )
-{
- struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
- FREE(nv10_render);
-}
-
-
-/**
- * Create a new primitive render.
- */
-static struct vbuf_render *
-nv10_vbuf_render_create( struct nv10_context *nv10 )
-{
- struct nv10_vbuf_render *nv10_render = CALLOC_STRUCT(nv10_vbuf_render);
-
- nv10_render->nv10 = nv10;
-
- nv10_render->base.max_vertex_buffer_bytes = 16*1024;
- nv10_render->base.max_indices = 1024;
- nv10_render->base.get_vertex_info = nv10_vbuf_render_get_vertex_info;
- nv10_render->base.allocate_vertices = nv10_vbuf_render_allocate_vertices;
- nv10_render->base.map_vertices = nv10_vbuf_render_map_vertices;
- nv10_render->base.unmap_vertices = nv10_vbuf_render_unmap_vertices;
- nv10_render->base.set_primitive = nv10_vbuf_render_set_primitive;
- nv10_render->base.draw = nv10_vbuf_render_draw;
- nv10_render->base.release_vertices = nv10_vbuf_render_release_vertices;
- nv10_render->base.destroy = nv10_vbuf_render_destroy;
-
- return &nv10_render->base;
-}
-
-
-/**
- * Create a new primitive vbuf/render stage.
- */
-struct draw_stage *nv10_draw_vbuf_stage( struct nv10_context *nv10 )
-{
- struct vbuf_render *render;
- struct draw_stage *stage;
-
- render = nv10_vbuf_render_create(nv10);
- if(!render)
- return NULL;
-
- stage = draw_vbuf_stage( nv10->draw, render );
- if(!stage) {
- render->destroy(render);
- return NULL;
- }
-
- return stage;
-}
diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c
deleted file mode 100644
index 4e6bc12994..0000000000
--- a/src/gallium/drivers/nv10/nv10_screen.c
+++ /dev/null
@@ -1,208 +0,0 @@
-#include "pipe/p_screen.h"
-
-#include "nv10_context.h"
-#include "nv10_screen.h"
-
-static int
-nv10_screen_get_param(struct pipe_screen *screen, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
- return 2;
- case PIPE_CAP_NPOT_TEXTURES:
- return 0;
- case PIPE_CAP_TWO_SIDED_STENCIL:
- return 0;
- case PIPE_CAP_GLSL:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 1;
- case PIPE_CAP_POINT_SPRITE:
- return 0;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 0;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 0;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 12;
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 0;
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 12;
- case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
- return 0;
- case PIPE_CAP_TGSI_CONT_SUPPORTED:
- return 0;
- case PIPE_CAP_BLEND_EQUATION_SEPARATE:
- return 0;
- case NOUVEAU_CAP_HW_VTXBUF:
- case NOUVEAU_CAP_HW_IDXBUF:
- return 0;
- case PIPE_CAP_INDEP_BLEND_ENABLE:
- return 0;
- case PIPE_CAP_INDEP_BLEND_FUNC:
- return 0;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
- case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
- return 1;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
- case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
- return 0;
- default:
- NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
- return 0;
- }
-}
-
-static float
-nv10_screen_get_paramf(struct pipe_screen *screen, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_LINE_WIDTH:
- case PIPE_CAP_MAX_LINE_WIDTH_AA:
- return 10.0;
- case PIPE_CAP_MAX_POINT_WIDTH:
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 64.0;
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 2.0;
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 4.0;
- default:
- NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
- return 0.0;
- }
-}
-
-static boolean
-nv10_screen_is_format_supported(struct pipe_screen *screen,
- enum pipe_format format,
- enum pipe_texture_target target,
- unsigned tex_usage, unsigned geom_flags)
-{
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- return TRUE;
- default:
- break;
- }
- } else
- if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
- switch (format) {
- case PIPE_FORMAT_Z24S8_UNORM:
- case PIPE_FORMAT_Z24X8_UNORM:
- case PIPE_FORMAT_Z16_UNORM:
- return TRUE;
- default:
- break;
- }
- } else {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- case PIPE_FORMAT_A4R4G4B4_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_L8_UNORM:
- case PIPE_FORMAT_A8_UNORM:
- case PIPE_FORMAT_I8_UNORM:
- return TRUE;
- default:
- break;
- }
- }
-
- return FALSE;
-}
-
-static void
-nv10_screen_destroy(struct pipe_screen *pscreen)
-{
- struct nv10_screen *screen = nv10_screen(pscreen);
-
- nouveau_notifier_free(&screen->sync);
- nouveau_grobj_free(&screen->celsius);
- nv04_surface_2d_takedown(&screen->eng2d);
-
- nouveau_screen_fini(&screen->base);
-
- FREE(pscreen);
-}
-
-static struct pipe_buffer *
-nv10_surface_buffer(struct pipe_surface *surf)
-{
- struct nv10_miptree *mt = (struct nv10_miptree *)surf->texture;
-
- return mt->buffer;
-}
-
-struct pipe_screen *
-nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
-{
- struct nv10_screen *screen = CALLOC_STRUCT(nv10_screen);
- struct nouveau_channel *chan;
- struct pipe_screen *pscreen;
- unsigned celsius_class;
- int ret;
-
- if (!screen)
- return NULL;
- pscreen = &screen->base.base;
-
- ret = nouveau_screen_init(&screen->base, dev);
- if (ret) {
- nv10_screen_destroy(pscreen);
- return NULL;
- }
- chan = screen->base.channel;
-
- pscreen->winsys = ws;
- pscreen->destroy = nv10_screen_destroy;
- pscreen->get_param = nv10_screen_get_param;
- pscreen->get_paramf = nv10_screen_get_paramf;
- pscreen->is_format_supported = nv10_screen_is_format_supported;
-
- nv10_screen_init_miptree_functions(pscreen);
- nv10_screen_init_transfer_functions(pscreen);
-
- /* 3D object */
- if (dev->chipset >= 0x20)
- celsius_class = NV11TCL;
- else if (dev->chipset >= 0x17)
- celsius_class = NV17TCL;
- else if (dev->chipset >= 0x11)
- celsius_class = NV11TCL;
- else
- celsius_class = NV10TCL;
-
- if (!celsius_class) {
- NOUVEAU_ERR("Unknown nv1x chipset: nv%02x\n", dev->chipset);
- return NULL;
- }
-
- ret = nouveau_grobj_alloc(chan, 0xbeef0001, celsius_class,
- &screen->celsius);
- if (ret) {
- NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
- return FALSE;
- }
-
- /* 2D engine setup */
- screen->eng2d = nv04_surface_2d_init(&screen->base);
- screen->eng2d->buf = nv10_surface_buffer;
-
- /* Notifier for sync purposes */
- ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
- if (ret) {
- NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
- nv10_screen_destroy(pscreen);
- return NULL;
- }
-
- return pscreen;
-}
-
diff --git a/src/gallium/drivers/nv10/nv10_screen.h b/src/gallium/drivers/nv10/nv10_screen.h
deleted file mode 100644
index 86b6d8def5..0000000000
--- a/src/gallium/drivers/nv10/nv10_screen.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __NV10_SCREEN_H__
-#define __NV10_SCREEN_H__
-
-#include "nouveau/nouveau_screen.h"
-#include "nv04/nv04_surface_2d.h"
-
-struct nv10_screen {
- struct nouveau_screen base;
-
- struct nouveau_winsys *nvws;
-
- /* HW graphics objects */
- struct nv04_surface_2d *eng2d;
- struct nouveau_grobj *celsius;
- struct nouveau_notifier *sync;
-};
-
-static INLINE struct nv10_screen *
-nv10_screen(struct pipe_screen *screen)
-{
- return (struct nv10_screen *)screen;
-}
-
-
-void
-nv10_screen_init_transfer_functions(struct pipe_screen *pscreen);
-
-#endif
diff --git a/src/gallium/drivers/nv10/nv10_state.c b/src/gallium/drivers/nv10/nv10_state.c
deleted file mode 100644
index 9aafc60411..0000000000
--- a/src/gallium/drivers/nv10/nv10_state.c
+++ /dev/null
@@ -1,590 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/p_inlines.h"
-
-#include "tgsi/tgsi_parse.h"
-
-#include "nv10_context.h"
-#include "nv10_state.h"
-
-static void *
-nv10_blend_state_create(struct pipe_context *pipe,
- const struct pipe_blend_state *cso)
-{
- struct nv10_blend_state *cb;
-
- cb = MALLOC(sizeof(struct nv10_blend_state));
-
- cb->b_enable = cso->rt[0].blend_enable ? 1 : 0;
- cb->b_srcfunc = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) |
- (nvgl_blend_func(cso->rt[0].rgb_src_factor)));
- cb->b_dstfunc = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) |
- (nvgl_blend_func(cso->rt[0].rgb_dst_factor)));
-
- cb->c_mask = (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01<<24) : 0) |
- ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01<<16) : 0) |
- ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) |
- ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01<< 0) : 0));
-
- cb->d_enable = cso->dither ? 1 : 0;
-
- return (void *)cb;
-}
-
-static void
-nv10_blend_state_bind(struct pipe_context *pipe, void *blend)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- nv10->blend = (struct nv10_blend_state*)blend;
-
- nv10->dirty |= NV10_NEW_BLEND;
-}
-
-static void
-nv10_blend_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- FREE(hwcso);
-}
-
-
-static INLINE unsigned
-wrap_mode(unsigned wrap) {
- unsigned ret;
-
- switch (wrap) {
- case PIPE_TEX_WRAP_REPEAT:
- ret = NV10TCL_TX_FORMAT_WRAP_S_REPEAT;
- break;
- case PIPE_TEX_WRAP_MIRROR_REPEAT:
- ret = NV10TCL_TX_FORMAT_WRAP_S_MIRRORED_REPEAT;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- ret = NV10TCL_TX_FORMAT_WRAP_S_CLAMP_TO_EDGE;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- ret = NV10TCL_TX_FORMAT_WRAP_S_CLAMP_TO_BORDER;
- break;
- case PIPE_TEX_WRAP_CLAMP:
- ret = NV10TCL_TX_FORMAT_WRAP_S_CLAMP;
- break;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
- case PIPE_TEX_WRAP_MIRROR_CLAMP:
- default:
- NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
- ret = NV10TCL_TX_FORMAT_WRAP_S_REPEAT;
- break;
- }
-
- return ret >> NV10TCL_TX_FORMAT_WRAP_S_SHIFT;
-}
-
-static void *
-nv10_sampler_state_create(struct pipe_context *pipe,
- const struct pipe_sampler_state *cso)
-{
- struct nv10_sampler_state *ps;
- uint32_t filter = 0;
-
- ps = MALLOC(sizeof(struct nv10_sampler_state));
-
- ps->wrap = ((wrap_mode(cso->wrap_s) << NV10TCL_TX_FORMAT_WRAP_S_SHIFT) |
- (wrap_mode(cso->wrap_t) << NV10TCL_TX_FORMAT_WRAP_T_SHIFT));
-
- ps->en = 0;
- if (cso->max_anisotropy > 1.0) {
- /* no idea, binary driver sets it, works without it.. meh.. */
- ps->wrap |= (1 << 5);
-
-/* if (cso->max_anisotropy >= 16.0) {
- ps->en |= NV10TCL_TX_ENABLE_ANISO_16X;
- } else
- if (cso->max_anisotropy >= 12.0) {
- ps->en |= NV10TCL_TX_ENABLE_ANISO_12X;
- } else
- if (cso->max_anisotropy >= 10.0) {
- ps->en |= NV10TCL_TX_ENABLE_ANISO_10X;
- } else
- if (cso->max_anisotropy >= 8.0) {
- ps->en |= NV10TCL_TX_ENABLE_ANISO_8X;
- } else
- if (cso->max_anisotropy >= 6.0) {
- ps->en |= NV10TCL_TX_ENABLE_ANISO_6X;
- } else
- if (cso->max_anisotropy >= 4.0) {
- ps->en |= NV10TCL_TX_ENABLE_ANISO_4X;
- } else {
- ps->en |= NV10TCL_TX_ENABLE_ANISO_2X;
- }*/
- }
-
- switch (cso->mag_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- filter |= NV10TCL_TX_FILTER_MAGNIFY_LINEAR;
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- filter |= NV10TCL_TX_FILTER_MAGNIFY_NEAREST;
- break;
- }
-
- switch (cso->min_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- filter |= NV10TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- filter |= NV10TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- filter |= NV10TCL_TX_FILTER_MINIFY_LINEAR;
- break;
- }
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- filter |= NV10TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- filter |= NV10TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- filter |= NV10TCL_TX_FILTER_MINIFY_NEAREST;
- break;
- }
- break;
- }
-
- ps->filt = filter;
-
-/* if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
- switch (cso->compare_func) {
- case PIPE_FUNC_NEVER:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_NEVER;
- break;
- case PIPE_FUNC_GREATER:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_GREATER;
- break;
- case PIPE_FUNC_EQUAL:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_EQUAL;
- break;
- case PIPE_FUNC_GEQUAL:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_GEQUAL;
- break;
- case PIPE_FUNC_LESS:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_LESS;
- break;
- case PIPE_FUNC_NOTEQUAL:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_NOTEQUAL;
- break;
- case PIPE_FUNC_LEQUAL:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_LEQUAL;
- break;
- case PIPE_FUNC_ALWAYS:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_ALWAYS;
- break;
- default:
- break;
- }
- }*/
-
- ps->bcol = ((float_to_ubyte(cso->border_color[3]) << 24) |
- (float_to_ubyte(cso->border_color[0]) << 16) |
- (float_to_ubyte(cso->border_color[1]) << 8) |
- (float_to_ubyte(cso->border_color[2]) << 0));
-
- return (void *)ps;
-}
-
-static void
-nv10_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
- unsigned unit;
-
- for (unit = 0; unit < nr; unit++) {
- nv10->tex_sampler[unit] = sampler[unit];
- nv10->dirty_samplers |= (1 << unit);
- }
-}
-
-static void
-nv10_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- FREE(hwcso);
-}
-
-static void
-nv10_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
- struct pipe_texture **miptree)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
- unsigned unit;
-
- for (unit = 0; unit < nr; unit++) {
- nv10->tex_miptree[unit] = (struct nv10_miptree *)miptree[unit];
- nv10->dirty_samplers |= (1 << unit);
- }
-}
-
-static void *
-nv10_rasterizer_state_create(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *cso)
-{
- struct nv10_rasterizer_state *rs;
- int i;
-
- /*XXX: ignored:
- * light_twoside
- * offset_cw/ccw -nohw
- * scissor
- * point_smooth -nohw
- * multisample
- * offset_units / offset_scale
- */
- rs = MALLOC(sizeof(struct nv10_rasterizer_state));
-
- rs->templ = cso;
-
- rs->shade_model = cso->flatshade ? 0x1d00 : 0x1d01;
-
- rs->line_width = (unsigned char)(cso->line_width * 8.0) & 0xff;
- rs->line_smooth_en = cso->line_smooth ? 1 : 0;
-
- rs->point_size = *(uint32_t*)&cso->point_size;
-
- rs->poly_smooth_en = cso->poly_smooth ? 1 : 0;
-
- if (cso->front_winding == PIPE_WINDING_CCW) {
- rs->front_face = NV10TCL_FRONT_FACE_CCW;
- rs->poly_mode_front = nvgl_polygon_mode(cso->fill_ccw);
- rs->poly_mode_back = nvgl_polygon_mode(cso->fill_cw);
- } else {
- rs->front_face = NV10TCL_FRONT_FACE_CW;
- rs->poly_mode_front = nvgl_polygon_mode(cso->fill_cw);
- rs->poly_mode_back = nvgl_polygon_mode(cso->fill_ccw);
- }
-
- switch (cso->cull_mode) {
- case PIPE_WINDING_CCW:
- rs->cull_face_en = 1;
- if (cso->front_winding == PIPE_WINDING_CCW)
- rs->cull_face = NV10TCL_CULL_FACE_FRONT;
- else
- rs->cull_face = NV10TCL_CULL_FACE_BACK;
- break;
- case PIPE_WINDING_CW:
- rs->cull_face_en = 1;
- if (cso->front_winding == PIPE_WINDING_CW)
- rs->cull_face = NV10TCL_CULL_FACE_FRONT;
- else
- rs->cull_face = NV10TCL_CULL_FACE_BACK;
- break;
- case PIPE_WINDING_BOTH:
- rs->cull_face_en = 1;
- rs->cull_face = NV10TCL_CULL_FACE_FRONT_AND_BACK;
- break;
- case PIPE_WINDING_NONE:
- default:
- rs->cull_face_en = 0;
- rs->cull_face = 0;
- break;
- }
-
- if (cso->point_sprite) {
- rs->point_sprite = (1 << 0);
- for (i = 0; i < 8; i++) {
- if (cso->sprite_coord_mode[i] != PIPE_SPRITE_COORD_NONE)
- rs->point_sprite |= (1 << (8 + i));
- }
- } else {
- rs->point_sprite = 0;
- }
-
- return (void *)rs;
-}
-
-static void
-nv10_rasterizer_state_bind(struct pipe_context *pipe, void *rast)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- nv10->rast = (struct nv10_rasterizer_state*)rast;
-
- draw_set_rasterizer_state(nv10->draw, (nv10->rast ? nv10->rast->templ : NULL));
-
- nv10->dirty |= NV10_NEW_RAST;
-}
-
-static void
-nv10_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- FREE(hwcso);
-}
-
-static void *
-nv10_depth_stencil_alpha_state_create(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *cso)
-{
- struct nv10_depth_stencil_alpha_state *hw;
-
- hw = MALLOC(sizeof(struct nv10_depth_stencil_alpha_state));
-
- hw->depth.func = nvgl_comparison_op(cso->depth.func);
- hw->depth.write_enable = cso->depth.writemask ? 1 : 0;
- hw->depth.test_enable = cso->depth.enabled ? 1 : 0;
-
- hw->stencil.enable = cso->stencil[0].enabled ? 1 : 0;
- hw->stencil.wmask = cso->stencil[0].writemask;
- hw->stencil.func = nvgl_comparison_op(cso->stencil[0].func);
- hw->stencil.ref = cso->stencil[0].ref_value;
- hw->stencil.vmask = cso->stencil[0].valuemask;
- hw->stencil.fail = nvgl_stencil_op(cso->stencil[0].fail_op);
- hw->stencil.zfail = nvgl_stencil_op(cso->stencil[0].zfail_op);
- hw->stencil.zpass = nvgl_stencil_op(cso->stencil[0].zpass_op);
-
- hw->alpha.enabled = cso->alpha.enabled ? 1 : 0;
- hw->alpha.func = nvgl_comparison_op(cso->alpha.func);
- hw->alpha.ref = float_to_ubyte(cso->alpha.ref_value);
-
- return (void *)hw;
-}
-
-static void
-nv10_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *dsa)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- nv10->dsa = (struct nv10_depth_stencil_alpha_state*)dsa;
-
- nv10->dirty |= NV10_NEW_DSA;
-}
-
-static void
-nv10_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- FREE(hwcso);
-}
-
-static void *
-nv10_vp_state_create(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- return draw_create_vertex_shader(nv10->draw, templ);
-}
-
-static void
-nv10_vp_state_bind(struct pipe_context *pipe, void *shader)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- draw_bind_vertex_shader(nv10->draw, (struct draw_vertex_shader *) shader);
-
- nv10->dirty |= NV10_NEW_VERTPROG;
-}
-
-static void
-nv10_vp_state_delete(struct pipe_context *pipe, void *shader)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- draw_delete_vertex_shader(nv10->draw, (struct draw_vertex_shader *) shader);
-}
-
-static void *
-nv10_fp_state_create(struct pipe_context *pipe,
- const struct pipe_shader_state *cso)
-{
- struct nv10_fragment_program *fp;
-
- fp = CALLOC(1, sizeof(struct nv10_fragment_program));
- fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
-
- tgsi_scan_shader(cso->tokens, &fp->info);
-
- return (void *)fp;
-}
-
-static void
-nv10_fp_state_bind(struct pipe_context *pipe, void *hwcso)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
- struct nv10_fragment_program *fp = hwcso;
-
- nv10->fragprog.current = fp;
- nv10->dirty |= NV10_NEW_FRAGPROG;
-}
-
-static void
-nv10_fp_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
- struct nv10_fragment_program *fp = hwcso;
-
- nv10_fragprog_destroy(nv10, fp);
- FREE((void*)fp->pipe.tokens);
- FREE(fp);
-}
-
-static void
-nv10_set_blend_color(struct pipe_context *pipe,
- const struct pipe_blend_color *bcol)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- nv10->blend_color = (struct pipe_blend_color*)bcol;
-
- nv10->dirty |= NV10_NEW_BLENDCOL;
-}
-
-static void
-nv10_set_clip_state(struct pipe_context *pipe,
- const struct pipe_clip_state *clip)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- draw_set_clip_state(nv10->draw, clip);
-}
-
-static void
-nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
- struct pipe_buffer *buf )
-{
- struct nv10_context *nv10 = nv10_context(pipe);
- struct pipe_screen *pscreen = pipe->screen;
-
- assert(shader < PIPE_SHADER_TYPES);
- assert(index == 0);
-
- if (buf) {
- void *mapped;
- if (buf->size &&
- (mapped = pipe_buffer_map(pscreen, buf, PIPE_BUFFER_USAGE_CPU_READ)))
- {
- memcpy(nv10->constbuf[shader], mapped, buf->size);
- nv10->constbuf_nr[shader] =
- buf->size / (4 * sizeof(float));
- pipe_buffer_unmap(pscreen, buf);
- }
- }
-}
-
-static void
-nv10_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- nv10->framebuffer = (struct pipe_framebuffer_state*)fb;
-
- nv10->dirty |= NV10_NEW_FRAMEBUFFER;
-}
-
-static void
-nv10_set_polygon_stipple(struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple)
-{
- NOUVEAU_ERR("line stipple hahaha\n");
-}
-
-static void
-nv10_set_scissor_state(struct pipe_context *pipe,
- const struct pipe_scissor_state *s)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- nv10->scissor = (struct pipe_scissor_state*)s;
-
- nv10->dirty |= NV10_NEW_SCISSOR;
-}
-
-static void
-nv10_set_viewport_state(struct pipe_context *pipe,
- const struct pipe_viewport_state *vpt)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- nv10->viewport = (struct pipe_viewport_state*)vpt;
-
- draw_set_viewport_state(nv10->draw, nv10->viewport);
-
- nv10->dirty |= NV10_NEW_VIEWPORT;
-}
-
-static void
-nv10_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
- const struct pipe_vertex_buffer *vb)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- memcpy(nv10->vtxbuf, vb, sizeof(*vb) * count);
- nv10->dirty |= NV10_NEW_VTXARRAYS;
-
- draw_set_vertex_buffers(nv10->draw, count, vb);
-}
-
-static void
-nv10_set_vertex_elements(struct pipe_context *pipe, unsigned count,
- const struct pipe_vertex_element *ve)
-{
- struct nv10_context *nv10 = nv10_context(pipe);
-
- memcpy(nv10->vtxelt, ve, sizeof(*ve) * count);
- nv10->dirty |= NV10_NEW_VTXARRAYS;
-
- draw_set_vertex_elements(nv10->draw, count, ve);
-}
-
-void
-nv10_init_state_functions(struct nv10_context *nv10)
-{
- nv10->pipe.create_blend_state = nv10_blend_state_create;
- nv10->pipe.bind_blend_state = nv10_blend_state_bind;
- nv10->pipe.delete_blend_state = nv10_blend_state_delete;
-
- nv10->pipe.create_sampler_state = nv10_sampler_state_create;
- nv10->pipe.bind_fragment_sampler_states = nv10_sampler_state_bind;
- nv10->pipe.delete_sampler_state = nv10_sampler_state_delete;
- nv10->pipe.set_fragment_sampler_textures = nv10_set_sampler_texture;
-
- nv10->pipe.create_rasterizer_state = nv10_rasterizer_state_create;
- nv10->pipe.bind_rasterizer_state = nv10_rasterizer_state_bind;
- nv10->pipe.delete_rasterizer_state = nv10_rasterizer_state_delete;
-
- nv10->pipe.create_depth_stencil_alpha_state =
- nv10_depth_stencil_alpha_state_create;
- nv10->pipe.bind_depth_stencil_alpha_state =
- nv10_depth_stencil_alpha_state_bind;
- nv10->pipe.delete_depth_stencil_alpha_state =
- nv10_depth_stencil_alpha_state_delete;
-
- nv10->pipe.create_vs_state = nv10_vp_state_create;
- nv10->pipe.bind_vs_state = nv10_vp_state_bind;
- nv10->pipe.delete_vs_state = nv10_vp_state_delete;
-
- nv10->pipe.create_fs_state = nv10_fp_state_create;
- nv10->pipe.bind_fs_state = nv10_fp_state_bind;
- nv10->pipe.delete_fs_state = nv10_fp_state_delete;
-
- nv10->pipe.set_blend_color = nv10_set_blend_color;
- nv10->pipe.set_clip_state = nv10_set_clip_state;
- nv10->pipe.set_constant_buffer = nv10_set_constant_buffer;
- nv10->pipe.set_framebuffer_state = nv10_set_framebuffer_state;
- nv10->pipe.set_polygon_stipple = nv10_set_polygon_stipple;
- nv10->pipe.set_scissor_state = nv10_set_scissor_state;
- nv10->pipe.set_viewport_state = nv10_set_viewport_state;
-
- nv10->pipe.set_vertex_buffers = nv10_set_vertex_buffers;
- nv10->pipe.set_vertex_elements = nv10_set_vertex_elements;
-}
-
diff --git a/src/gallium/drivers/nv10/nv10_state.h b/src/gallium/drivers/nv10/nv10_state.h
deleted file mode 100644
index 2524ac02e2..0000000000
--- a/src/gallium/drivers/nv10/nv10_state.h
+++ /dev/null
@@ -1,140 +0,0 @@
-#ifndef __NV10_STATE_H__
-#define __NV10_STATE_H__
-
-#include "pipe/p_state.h"
-#include "tgsi/tgsi_scan.h"
-
-struct nv10_blend_state {
- uint32_t b_enable;
- uint32_t b_srcfunc;
- uint32_t b_dstfunc;
-
- uint32_t c_mask;
-
- uint32_t d_enable;
-};
-
-struct nv10_sampler_state {
- uint32_t wrap;
- uint32_t en;
- uint32_t filt;
- uint32_t bcol;
-};
-
-struct nv10_rasterizer_state {
- uint32_t shade_model;
-
- uint32_t line_width;
- uint32_t line_smooth_en;
-
- uint32_t point_size;
-
- uint32_t poly_smooth_en;
-
- uint32_t poly_mode_front;
- uint32_t poly_mode_back;
-
- uint32_t front_face;
- uint32_t cull_face;
- uint32_t cull_face_en;
-
- uint32_t point_sprite;
-
- const struct pipe_rasterizer_state *templ;
-};
-
-struct nv10_vertex_program_exec {
- uint32_t data[4];
- boolean has_branch_offset;
- int const_index;
-};
-
-struct nv10_vertex_program_data {
- int index; /* immediates == -1 */
- float value[4];
-};
-
-struct nv10_vertex_program {
- const struct pipe_shader_state *pipe;
-
- boolean translated;
- struct nv10_vertex_program_exec *insns;
- unsigned nr_insns;
- struct nv10_vertex_program_data *consts;
- unsigned nr_consts;
-
- struct nouveau_resource *exec;
- unsigned exec_start;
- struct nouveau_resource *data;
- unsigned data_start;
- unsigned data_start_min;
-
- uint32_t ir;
- uint32_t or;
-};
-
-struct nv10_fragment_program_data {
- unsigned offset;
- unsigned index;
-};
-
-struct nv10_fragment_program {
- struct pipe_shader_state pipe;
- struct tgsi_shader_info info;
-
- boolean translated;
- boolean on_hw;
- unsigned samplers;
-
- uint32_t *insn;
- int insn_len;
-
- struct nv10_fragment_program_data *consts;
- unsigned nr_consts;
-
- struct pipe_buffer *buffer;
-
- uint32_t fp_control;
- uint32_t fp_reg_control;
-};
-
-
-struct nv10_depth_stencil_alpha_state {
- struct {
- uint32_t func;
- uint32_t write_enable;
- uint32_t test_enable;
- } depth;
-
- struct {
- uint32_t enable;
- uint32_t wmask;
- uint32_t func;
- uint32_t ref;
- uint32_t vmask;
- uint32_t fail;
- uint32_t zfail;
- uint32_t zpass;
- } stencil;
-
- struct {
- uint32_t enabled;
- uint32_t func;
- uint32_t ref;
- } alpha;
-};
-
-struct nv10_miptree {
- struct pipe_texture base;
- struct nouveau_bo *bo;
-
- struct pipe_buffer *buffer;
- uint total_size;
-
- struct {
- uint pitch;
- uint *image_offset;
- } level[PIPE_MAX_TEXTURE_LEVELS];
-};
-
-#endif
diff --git a/src/gallium/drivers/nv10/nv10_state_emit.c b/src/gallium/drivers/nv10/nv10_state_emit.c
deleted file mode 100644
index 30a596ca60..0000000000
--- a/src/gallium/drivers/nv10/nv10_state_emit.c
+++ /dev/null
@@ -1,333 +0,0 @@
-#include "nv10_context.h"
-#include "nv10_state.h"
-
-static void nv10_state_emit_blend(struct nv10_context* nv10)
-{
- struct nv10_blend_state *b = nv10->blend;
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
-
- BEGIN_RING(chan, celsius, NV10TCL_DITHER_ENABLE, 1);
- OUT_RING (chan, b->d_enable);
-
- BEGIN_RING(chan, celsius, NV10TCL_BLEND_FUNC_ENABLE, 3);
- OUT_RING (chan, b->b_enable);
- OUT_RING (chan, b->b_srcfunc);
- OUT_RING (chan, b->b_dstfunc);
-
- BEGIN_RING(chan, celsius, NV10TCL_COLOR_MASK, 1);
- OUT_RING (chan, b->c_mask);
-}
-
-static void nv10_state_emit_blend_color(struct nv10_context* nv10)
-{
- struct pipe_blend_color *c = nv10->blend_color;
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
-
- BEGIN_RING(chan, celsius, NV10TCL_BLEND_COLOR, 1);
- OUT_RING (chan,
- (float_to_ubyte(c->color[3]) << 24)|
- (float_to_ubyte(c->color[0]) << 16)|
- (float_to_ubyte(c->color[1]) << 8) |
- (float_to_ubyte(c->color[2]) << 0));
-}
-
-static void nv10_state_emit_rast(struct nv10_context* nv10)
-{
- struct nv10_rasterizer_state *r = nv10->rast;
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
-
- BEGIN_RING(chan, celsius, NV10TCL_SHADE_MODEL, 2);
- OUT_RING (chan, r->shade_model);
- OUT_RING (chan, r->line_width);
-
-
- BEGIN_RING(chan, celsius, NV10TCL_POINT_SIZE, 1);
- OUT_RING (chan, r->point_size);
-
- BEGIN_RING(chan, celsius, NV10TCL_POLYGON_MODE_FRONT, 2);
- OUT_RING (chan, r->poly_mode_front);
- OUT_RING (chan, r->poly_mode_back);
-
-
- BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE, 2);
- OUT_RING (chan, r->cull_face);
- OUT_RING (chan, r->front_face);
-
- BEGIN_RING(chan, celsius, NV10TCL_LINE_SMOOTH_ENABLE, 2);
- OUT_RING (chan, r->line_smooth_en);
- OUT_RING (chan, r->poly_smooth_en);
-
- BEGIN_RING(chan, celsius, NV10TCL_CULL_FACE_ENABLE, 1);
- OUT_RING (chan, r->cull_face_en);
-}
-
-static void nv10_state_emit_dsa(struct nv10_context* nv10)
-{
- struct nv10_depth_stencil_alpha_state *d = nv10->dsa;
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
-
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_FUNC, 1);
- OUT_RING (chan, d->depth.func);
-
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_WRITE_ENABLE, 1);
- OUT_RING (chan, d->depth.write_enable);
-
- BEGIN_RING(chan, celsius, NV10TCL_DEPTH_TEST_ENABLE, 1);
- OUT_RING (chan, d->depth.test_enable);
-
-#if 0
- BEGIN_RING(chan, celsius, NV10TCL_STENCIL_ENABLE, 1);
- OUT_RING (chan, d->stencil.enable);
- BEGIN_RING(chan, celsius, NV10TCL_STENCIL_MASK, 7);
- OUT_RINGp (chan, (uint32_t *)&(d->stencil.wmask), 7);
-#endif
-
- BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_ENABLE, 1);
- OUT_RING (chan, d->alpha.enabled);
-
- BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_FUNC, 1);
- OUT_RING (chan, d->alpha.func);
-
- BEGIN_RING(chan, celsius, NV10TCL_ALPHA_FUNC_REF, 1);
- OUT_RING (chan, d->alpha.ref);
-}
-
-static void nv10_state_emit_viewport(struct nv10_context* nv10)
-{
-}
-
-static void nv10_state_emit_scissor(struct nv10_context* nv10)
-{
- // XXX this is so not working
-/* struct pipe_scissor_state *s = nv10->scissor;
- BEGIN_RING(celsius, NV10TCL_SCISSOR_HORIZ, 2);
- OUT_RING (((s->maxx - s->minx) << 16) | s->minx);
- OUT_RING (((s->maxy - s->miny) << 16) | s->miny);*/
-}
-
-static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
-{
- struct pipe_framebuffer_state* fb = nv10->framebuffer;
- struct nv04_surface *rt, *zeta = NULL;
- uint32_t rt_format, w, h;
- int colour_format = 0, zeta_format = 0;
- struct nv10_miptree *nv10mt = 0;
-
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
-
- w = fb->cbufs[0]->width;
- h = fb->cbufs[0]->height;
- colour_format = fb->cbufs[0]->format;
- rt = (struct nv04_surface *)fb->cbufs[0];
-
- if (fb->zsbuf) {
- if (colour_format) {
- assert(w == fb->zsbuf->width);
- assert(h == fb->zsbuf->height);
- } else {
- w = fb->zsbuf->width;
- h = fb->zsbuf->height;
- }
-
- zeta_format = fb->zsbuf->format;
- zeta = (struct nv04_surface *)fb->zsbuf;
- }
-
- rt_format = NV10TCL_RT_FORMAT_TYPE_LINEAR;
-
- switch (colour_format) {
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- rt_format |= NV10TCL_RT_FORMAT_COLOR_X8R8G8B8;
- break;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case 0:
- rt_format |= NV10TCL_RT_FORMAT_COLOR_A8R8G8B8;
- break;
- case PIPE_FORMAT_R5G6B5_UNORM:
- rt_format |= NV10TCL_RT_FORMAT_COLOR_R5G6B5;
- break;
- default:
- assert(0);
- }
-
- if (zeta) {
- BEGIN_RING(chan, celsius, NV10TCL_RT_PITCH, 1);
- OUT_RING (chan, rt->pitch | (zeta->pitch << 16));
- } else {
- BEGIN_RING(chan, celsius, NV10TCL_RT_PITCH, 1);
- OUT_RING (chan, rt->pitch | (rt->pitch << 16));
- }
-
- nv10mt = (struct nv10_miptree *)rt->base.texture;
- nv10->rt[0] = nv10mt->buffer;
-
- if (zeta_format)
- {
- nv10mt = (struct nv10_miptree *)zeta->base.texture;
- nv10->zeta = nv10mt->buffer;
- }
-
- BEGIN_RING(chan, celsius, NV10TCL_RT_HORIZ, 3);
- OUT_RING (chan, (w << 16) | 0);
- OUT_RING (chan, (h << 16) | 0);
- OUT_RING (chan, rt_format);
- BEGIN_RING(chan, celsius, NV10TCL_VIEWPORT_CLIP_HORIZ(0), 2);
- OUT_RING (chan, ((w - 1) << 16) | 0 | 0x08000800);
- OUT_RING (chan, ((h - 1) << 16) | 0 | 0x08000800);
-}
-
-static void nv10_vertex_layout(struct nv10_context *nv10)
-{
- struct nv10_fragment_program *fp = nv10->fragprog.current;
- uint32_t src = 0;
- int i;
- struct vertex_info vinfo;
-
- memset(&vinfo, 0, sizeof(vinfo));
-
- for (i = 0; i < fp->info.num_inputs; i++) {
- switch (fp->info.input_semantic_name[i]) {
- case TGSI_SEMANTIC_POSITION:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
- break;
- case TGSI_SEMANTIC_COLOR:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, src++);
- break;
- default:
- case TGSI_SEMANTIC_GENERIC:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
- break;
- case TGSI_SEMANTIC_FOG:
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
- break;
- }
- }
- draw_compute_vertex_size(&vinfo);
-}
-
-void
-nv10_emit_hw_state(struct nv10_context *nv10)
-{
- struct nv10_screen *screen = nv10->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *celsius = screen->celsius;
- struct nouveau_bo *rt_bo;
- int i;
-
- if (nv10->dirty & NV10_NEW_VERTPROG) {
- //nv10_vertprog_bind(nv10, nv10->vertprog.current);
- nv10->dirty &= ~NV10_NEW_VERTPROG;
- }
-
- if (nv10->dirty & NV10_NEW_FRAGPROG) {
- nv10_fragprog_bind(nv10, nv10->fragprog.current);
- /*XXX: clear NV10_NEW_FRAGPROG if no new program uploaded */
- nv10->dirty_samplers |= (1<<10);
- nv10->dirty_samplers = 0;
- }
-
- if (nv10->dirty_samplers || (nv10->dirty & NV10_NEW_FRAGPROG)) {
- nv10_fragtex_bind(nv10);
- nv10->dirty &= ~NV10_NEW_FRAGPROG;
- }
-
- if (nv10->dirty & NV10_NEW_VTXARRAYS) {
- nv10->dirty &= ~NV10_NEW_VTXARRAYS;
- nv10_vertex_layout(nv10);
- nv10_vtxbuf_bind(nv10);
- }
-
- if (nv10->dirty & NV10_NEW_BLEND) {
- nv10->dirty &= ~NV10_NEW_BLEND;
- nv10_state_emit_blend(nv10);
- }
-
- if (nv10->dirty & NV10_NEW_BLENDCOL) {
- nv10->dirty &= ~NV10_NEW_BLENDCOL;
- nv10_state_emit_blend_color(nv10);
- }
-
- if (nv10->dirty & NV10_NEW_RAST) {
- nv10->dirty &= ~NV10_NEW_RAST;
- nv10_state_emit_rast(nv10);
- }
-
- if (nv10->dirty & NV10_NEW_DSA) {
- nv10->dirty &= ~NV10_NEW_DSA;
- nv10_state_emit_dsa(nv10);
- }
-
- if (nv10->dirty & NV10_NEW_VIEWPORT) {
- nv10->dirty &= ~NV10_NEW_VIEWPORT;
- nv10_state_emit_viewport(nv10);
- }
-
- if (nv10->dirty & NV10_NEW_SCISSOR) {
- nv10->dirty &= ~NV10_NEW_SCISSOR;
- nv10_state_emit_scissor(nv10);
- }
-
- if (nv10->dirty & NV10_NEW_FRAMEBUFFER) {
- nv10->dirty &= ~NV10_NEW_FRAMEBUFFER;
- nv10_state_emit_framebuffer(nv10);
- }
-
- /* Emit relocs for every referenced buffer.
- * This is to ensure the bufmgr has an accurate idea of how
- * the buffer is used. This isn't very efficient, but we don't
- * seem to take a significant performance hit. Will be improved
- * at some point. Vertex arrays are emitted by nv10_vbo.c
- */
-
- /* Render target */
- rt_bo = nouveau_bo(nv10->rt[0]);
-// XXX figre out who's who for NV10TCL_DMA_* and fill accordingly
-// BEGIN_RING(chan, celsius, NV10TCL_DMA_COLOR0, 1);
-// OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, celsius, NV10TCL_COLOR_OFFSET, 1);
- OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- if (nv10->zeta) {
- struct nouveau_bo *zeta_bo = nouveau_bo(nv10->zeta);
-// XXX
-// BEGIN_RING(chan, celsius, NV10TCL_DMA_ZETA, 1);
-// OUT_RELOCo(chan, zeta_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, celsius, NV10TCL_ZETA_OFFSET, 1);
- OUT_RELOCl(chan, zeta_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- /* XXX for when we allocate LMA on nv17 */
-/* BEGIN_RING(chan, celsius, NV10TCL_LMA_DEPTH_BUFFER_OFFSET, 1);
- OUT_RELOCl(chan, nouveau_bo(nv10->zeta + lma_offset));*/
- }
-
- /* Vertex buffer */
- BEGIN_RING(chan, celsius, NV10TCL_DMA_VTXBUF0, 1);
- OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, celsius, NV10TCL_COLOR_OFFSET, 1);
- OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- /* Texture images */
- for (i = 0; i < 2; i++) {
- if (!(nv10->fp_samplers & (1 << i)))
- continue;
- struct nouveau_bo *bo = nouveau_bo(nv10->tex[i].buffer);
- BEGIN_RING(chan, celsius, NV10TCL_TX_OFFSET(i), 1);
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM |
- NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- BEGIN_RING(chan, celsius, NV10TCL_TX_FORMAT(i), 1);
- OUT_RELOCd(chan, bo, nv10->tex[i].format,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
- NOUVEAU_BO_OR, NV10TCL_TX_FORMAT_DMA0,
- NV10TCL_TX_FORMAT_DMA1);
- }
-}
-
diff --git a/src/gallium/drivers/nv10/nv10_transfer.c b/src/gallium/drivers/nv10/nv10_transfer.c
deleted file mode 100644
index eb04af9782..0000000000
--- a/src/gallium/drivers/nv10/nv10_transfer.c
+++ /dev/null
@@ -1,178 +0,0 @@
-#include <pipe/p_state.h>
-#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
-#include <util/u_format.h>
-#include <util/u_memory.h>
-#include <util/u_math.h>
-#include <nouveau/nouveau_winsys.h>
-#include "nv10_context.h"
-#include "nv10_screen.h"
-#include "nv10_state.h"
-
-struct nv10_transfer {
- struct pipe_transfer base;
- struct pipe_surface *surface;
- boolean direct;
-};
-
-static void
-nv10_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
- struct pipe_texture *template)
-{
- memset(template, 0, sizeof(struct pipe_texture));
- template->target = pt->target;
- template->format = pt->format;
- template->width0 = width;
- template->height0 = height;
- template->depth0 = 1;
- template->last_level = 0;
- template->nr_samples = pt->nr_samples;
-
- template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
- NOUVEAU_TEXTURE_USAGE_LINEAR;
-}
-
-static struct pipe_transfer *
-nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
-{
- struct nv10_miptree *mt = (struct nv10_miptree *)pt;
- struct nv10_transfer *tx;
- struct pipe_texture tx_tex_template, *tx_tex;
-
- tx = CALLOC_STRUCT(nv10_transfer);
- if (!tx)
- return NULL;
-
- pipe_texture_reference(&tx->base.texture, pt);
- tx->base.x = x;
- tx->base.y = y;
- tx->base.width = w;
- tx->base.height = h;
- tx->base.stride = mt->level[level].pitch;
- tx->base.usage = usage;
- tx->base.face = face;
- tx->base.level = level;
- 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*/)) &&
- pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
- {
- tx->direct = true;
- tx->surface = pscreen->get_tex_surface(pscreen, pt,
- 0, 0, 0,
- pipe_transfer_buffer_flags(&tx->base));
- return &tx->base;
- }
-
- tx->direct = false;
-
- nv10_compatible_transfer_tex(pt, w, h, &tx_tex_template);
-
- tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
- if (!tx_tex)
- {
- FREE(tx);
- return NULL;
- }
-
- tx->base.stride = ((struct nv10_miptree*)tx_tex)->level[0].pitch;
-
- tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
- face, level, zslice,
- pipe_transfer_buffer_flags(&tx->base));
-
- pipe_texture_reference(&tx_tex, NULL);
-
- if (!tx->surface)
- {
- pipe_surface_reference(&tx->surface, NULL);
- FREE(tx);
- return NULL;
- }
-
- if (usage & PIPE_TRANSFER_READ) {
- struct nv10_screen *nvscreen = nv10_screen(pscreen);
- struct pipe_surface *src;
-
- src = pscreen->get_tex_surface(pscreen, pt,
- face, level, zslice,
- PIPE_BUFFER_USAGE_GPU_READ);
-
- /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
- /* TODO: Check if SIFM can un-swizzle */
- nvscreen->eng2d->copy(nvscreen->eng2d,
- tx->surface, 0, 0,
- src, x, y,
- w, h);
-
- pipe_surface_reference(&src, NULL);
- }
-
- return &tx->base;
-}
-
-static void
-nv10_transfer_del(struct pipe_transfer *ptx)
-{
- struct nv10_transfer *tx = (struct nv10_transfer *)ptx;
-
- if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
- struct pipe_screen *pscreen = ptx->texture->screen;
- struct nv10_screen *nvscreen = nv10_screen(pscreen);
- struct pipe_surface *dst;
-
- dst = pscreen->get_tex_surface(pscreen, ptx->texture,
- ptx->face, ptx->level, ptx->zslice,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
- /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
- nvscreen->eng2d->copy(nvscreen->eng2d,
- dst, tx->base.x, tx->base.y,
- tx->surface, 0, 0,
- tx->base.width, tx->base.height);
-
- pipe_surface_reference(&dst, NULL);
- }
-
- pipe_surface_reference(&tx->surface, NULL);
- pipe_texture_reference(&ptx->texture, NULL);
- FREE(ptx);
-}
-
-static void *
-nv10_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
-{
- struct nv10_transfer *tx = (struct nv10_transfer *)ptx;
- struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
- struct nv10_miptree *mt = (struct nv10_miptree *)tx->surface->texture;
- void *map = pipe_buffer_map(pscreen, mt->buffer,
- pipe_transfer_buffer_flags(ptx));
-
- if(!tx->direct)
- return map + ns->base.offset;
- else
- return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
-}
-
-static void
-nv10_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
-{
- struct nv10_transfer *tx = (struct nv10_transfer *)ptx;
- struct nv10_miptree *mt = (struct nv10_miptree *)tx->surface->texture;
-
- pipe_buffer_unmap(pscreen, mt->buffer);
-}
-
-void
-nv10_screen_init_transfer_functions(struct pipe_screen *pscreen)
-{
- pscreen->get_tex_transfer = nv10_transfer_new;
- pscreen->tex_transfer_destroy = nv10_transfer_del;
- pscreen->transfer_map = nv10_transfer_map;
- pscreen->transfer_unmap = nv10_transfer_unmap;
-}
diff --git a/src/gallium/drivers/nv10/nv10_vbo.c b/src/gallium/drivers/nv10/nv10_vbo.c
deleted file mode 100644
index da5c93f081..0000000000
--- a/src/gallium/drivers/nv10/nv10_vbo.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
-
-#include "nv10_context.h"
-#include "nv10_state.h"
-
-#include "nouveau/nouveau_channel.h"
-#include "nouveau/nouveau_pushbuf.h"
-
-void nv10_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count)
-{
- struct nv10_context *nv10 = nv10_context( pipe );
- struct draw_context *draw = nv10->draw;
- struct pipe_screen *pscreen = pipe->screen;
- unsigned i;
-
- nv10_emit_hw_state(nv10);
-
- /*
- * Map vertex buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (nv10->vtxbuf[i].buffer) {
- void *buf =
- pipe_buffer_map(pscreen, nv10->vtxbuf[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
- }
- /* Map index buffer, if present */
- if (indexBuffer) {
- void *mapped_indexes
- = pipe_buffer_map(pscreen, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
- }
- else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
- draw_set_mapped_constant_buffer(draw,
- PIPE_SHADER_VERTEX,
- 0,
- nv10->constbuf[PIPE_SHADER_VERTEX],
- nv10->constbuf_nr[PIPE_SHADER_VERTEX]);
-
- /* draw! */
- draw_arrays(nv10->draw, prim, start, count);
-
- /*
- * unmap vertex/index buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (nv10->vtxbuf[i].buffer) {
- pipe_buffer_unmap(pscreen, nv10->vtxbuf[i].buffer);
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- }
- }
- if (indexBuffer) {
- pipe_buffer_unmap(pscreen, indexBuffer);
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-}
-
-void nv10_draw_arrays( struct pipe_context *pipe,
- unsigned prim, unsigned start, unsigned count)
-{
- nv10_draw_elements(pipe, NULL, 0, prim, start, count);
-}
-
-
-
diff --git a/src/gallium/drivers/nv20/Makefile b/src/gallium/drivers/nv20/Makefile
deleted file mode 100644
index 1305f26c59..0000000000
--- a/src/gallium/drivers/nv20/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nv20
-
-C_SOURCES = \
- nv20_clear.c \
- nv20_context.c \
- nv20_fragprog.c \
- nv20_fragtex.c \
- nv20_miptree.c \
- nv20_prim_vbuf.c \
- nv20_screen.c \
- nv20_state.c \
- nv20_state_emit.c \
- nv20_surface.c \
- nv20_transfer.c \
- nv20_vbo.c
-# nv20_vertprog.c
-
-include ../../Makefile.template
diff --git a/src/gallium/drivers/nv20/nv20_clear.c b/src/gallium/drivers/nv20/nv20_clear.c
deleted file mode 100644
index 2b4490fa5e..0000000000
--- a/src/gallium/drivers/nv20/nv20_clear.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "util/u_clear.h"
-
-#include "nv20_context.h"
-
-void
-nv20_clear(struct pipe_context *pipe, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
-{
- util_clear(pipe, nv20_context(pipe)->framebuffer, buffers, rgba, depth,
- stencil);
-}
diff --git a/src/gallium/drivers/nv20/nv20_context.c b/src/gallium/drivers/nv20/nv20_context.c
deleted file mode 100644
index 5b80af2d22..0000000000
--- a/src/gallium/drivers/nv20/nv20_context.c
+++ /dev/null
@@ -1,424 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
-
-#include "nv20_context.h"
-#include "nv20_screen.h"
-
-static void
-nv20_flush(struct pipe_context *pipe, unsigned flags,
- struct pipe_fence_handle **fence)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
-
- draw_flush(nv20->draw);
-
- FIRE_RING(chan);
- if (fence)
- *fence = NULL;
-}
-
-static void
-nv20_destroy(struct pipe_context *pipe)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- if (nv20->draw)
- draw_destroy(nv20->draw);
-
- FREE(nv20);
-}
-
-static void nv20_init_hwctx(struct nv20_context *nv20)
-{
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
- int i;
- float projectionmatrix[16];
- const boolean is_nv25tcl = (kelvin->grclass == NV25TCL);
-
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_NOTIFY, 1);
- OUT_RING (chan, screen->sync->handle);
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_TEXTURE0, 2);
- OUT_RING (chan, chan->vram->handle);
- OUT_RING (chan, chan->gart->handle); /* TEXTURE1 */
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_COLOR, 2);
- OUT_RING (chan, chan->vram->handle);
- OUT_RING (chan, chan->vram->handle); /* ZETA */
-
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_QUERY, 1);
- OUT_RING (chan, 0); /* renouveau: beef0351, unique */
-
- BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 1);
- OUT_RING (chan, (0xfff << 16) | 0x0);
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(0), 1);
- OUT_RING (chan, (0xfff << 16) | 0x0);
-
- for (i = 1; i < NV20TCL_VIEWPORT_CLIP_HORIZ__SIZE; i++) {
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(i), 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_VERT(i), 1);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_MODE, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, 0x17e0, 3);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 1.0);
-
- if (is_nv25tcl) {
- BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1);
- OUT_RING (chan, NV20TCL_TX_RCOMP_LEQUAL | 0xdb0);
- } else {
- BEGIN_RING(chan, kelvin, 0x1e68, 1);
- OUT_RING (chan, 0x4b800000); /* 16777216.000000 */
- BEGIN_RING(chan, kelvin, NV20TCL_TX_RCOMP, 1);
- OUT_RING (chan, NV20TCL_TX_RCOMP_LEQUAL);
- }
-
- BEGIN_RING(chan, kelvin, 0x290, 1);
- OUT_RING (chan, (0x10 << 16) | 1);
- BEGIN_RING(chan, kelvin, 0x9fc, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, 0x1d80, 1);
- OUT_RING (chan, 1);
- BEGIN_RING(chan, kelvin, 0x9f8, 1);
- OUT_RING (chan, 4);
- BEGIN_RING(chan, kelvin, 0x17ec, 3);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 1.0);
- OUT_RINGf (chan, 0.0);
-
- if (is_nv25tcl) {
- BEGIN_RING(chan, kelvin, 0x1d88, 1);
- OUT_RING (chan, 3);
-
- BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY9, 1);
- OUT_RING (chan, chan->vram->handle);
- BEGIN_RING(chan, kelvin, NV25TCL_DMA_IN_MEMORY8, 1);
- OUT_RING (chan, chan->vram->handle);
- }
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_FENCE, 1);
- OUT_RING (chan, 0); /* renouveau: beef1e10 */
-
- BEGIN_RING(chan, kelvin, 0x1e98, 1);
- OUT_RING (chan, 0);
-#if 0
- if (is_nv25tcl) {
- BEGIN_RING(chan, NvSub3D, NV25TCL_DMA_IN_MEMORY4, 2);
- OUT_RING (chan, NvDmaTT); /* renouveau: beef0202 */
- OUT_RING (chan, NvDmaFB); /* renouveau: beef0201 */
-
- BEGIN_RING(chan, NvSub3D, NV20TCL_DMA_TEXTURE1, 1);
- OUT_RING (chan, NvDmaTT); /* renouveau: beef0202 */
- }
-#endif
- BEGIN_RING(chan, kelvin, NV20TCL_NOTIFY, 1);
- OUT_RING (chan, 0);
-
- BEGIN_RING(chan, kelvin, 0x120, 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 1);
- OUT_RING (chan, 2);
-
-/* error: ILLEGAL_MTHD, PROTECTION_FAULT
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 512.0);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0);
-*/
-
- if (is_nv25tcl) {
- BEGIN_RING(chan, kelvin, 0x022c, 2);
- OUT_RING (chan, 0x280);
- OUT_RING (chan, 0x07d28000);
- }
-
-/* * illegal method, protection fault
- BEGIN_RING(chan, NvSub3D, 0x1c2c, 1);
- OUT_RING (chan, 0); */
-
- if (is_nv25tcl) {
- BEGIN_RING(chan, kelvin, 0x1da4, 1);
- OUT_RING (chan, 0);
- }
-
-/* * crashes with illegal method, protection fault
- BEGIN_RING(chan, NvSub3D, 0x1c18, 1);
- OUT_RING (chan, 0x200); */
-
- BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 2);
- OUT_RING (chan, (0 << 16) | 0);
- OUT_RING (chan, (0 << 16) | 0);
-
- /* *** Set state *** */
-
- BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_FUNC, 2);
- OUT_RING (chan, NV20TCL_ALPHA_FUNC_FUNC_ALWAYS);
- OUT_RING (chan, 0); /* NV20TCL_ALPHA_FUNC_REF */
-
- for (i = 0; i < NV20TCL_TX_ENABLE__SIZE; ++i) {
- BEGIN_RING(chan, kelvin, NV20TCL_TX_ENABLE(i), 1);
- OUT_RING (chan, 0);
- }
- BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_OP, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_TX_SHADER_CULL_MODE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_ALPHA(0), 4);
- OUT_RING (chan, 0x30d410d0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_RGB(0), 4);
- OUT_RING (chan, 0x00000c00);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_ENABLE, 1);
- OUT_RING (chan, 0x00011101);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_FINAL0, 2);
- OUT_RING (chan, 0x130e0300);
- OUT_RING (chan, 0x0c091c80);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_OUT_ALPHA(0), 4);
- OUT_RING (chan, 0x00000c00);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_IN_RGB(0), 4);
- OUT_RING (chan, 0x20c400c0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_COLOR0, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_RC_CONSTANT_COLOR0(0), 4);
- OUT_RING (chan, 0x035125a0);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0x40002000);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_MULTISAMPLE_CONTROL, 1);
- OUT_RING (chan, 0xffff0000);
-
- BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_DITHER_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_SRC, 4);
- OUT_RING (chan, NV20TCL_BLEND_FUNC_SRC_ONE);
- OUT_RING (chan, NV20TCL_BLEND_FUNC_DST_ZERO);
- OUT_RING (chan, 0); /* NV20TCL_BLEND_COLOR */
- OUT_RING (chan, NV20TCL_BLEND_EQUATION_FUNC_ADD);
- BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_MASK, 7);
- OUT_RING (chan, 0xff);
- OUT_RING (chan, NV20TCL_STENCIL_FUNC_FUNC_ALWAYS);
- OUT_RING (chan, 0); /* NV20TCL_STENCIL_FUNC_REF */
- OUT_RING (chan, 0xff); /* NV20TCL_STENCIL_FUNC_MASK */
- OUT_RING (chan, NV20TCL_STENCIL_OP_FAIL_KEEP);
- OUT_RING (chan, NV20TCL_STENCIL_OP_ZFAIL_KEEP);
- OUT_RING (chan, NV20TCL_STENCIL_OP_ZPASS_KEEP);
-
- BEGIN_RING(chan, kelvin, NV20TCL_COLOR_LOGIC_OP_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, NV20TCL_COLOR_LOGIC_OP_OP_COPY);
- BEGIN_RING(chan, kelvin, 0x17cc, 1);
- OUT_RING (chan, 0);
- if (is_nv25tcl) {
- BEGIN_RING(chan, kelvin, 0x1d84, 1);
- OUT_RING (chan, 1);
- }
- BEGIN_RING(chan, kelvin, NV20TCL_LIGHTING_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_CONTROL, 1);
- OUT_RING (chan, 0x00020000);
- BEGIN_RING(chan, kelvin, NV20TCL_SEPARATE_SPECULAR_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_LIGHT_MODEL_TWO_SIDE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_ENABLED_LIGHTS, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_NORMALIZE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_PATTERN(0),
- NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE);
- for (i = 0; i < NV20TCL_POLYGON_STIPPLE_PATTERN__SIZE; ++i) {
- OUT_RING(chan, 0xffffffff);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0); /* NV20TCL.POLYGON_OFFSET_LINE_ENABLE */
- OUT_RING (chan, 0); /* NV20TCL.POLYGON_OFFSET_FILL_ENABLE */
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_FUNC, 1);
- OUT_RING (chan, NV20TCL_DEPTH_FUNC_LESS);
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_OFFSET_FACTOR, 2);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 0.0); /* NV20TCL.POLYGON_OFFSET_UNITS */
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_UNK17D8, 1);
- OUT_RING (chan, 1);
- if (!is_nv25tcl) {
- BEGIN_RING(chan, kelvin, 0x1d84, 1);
- OUT_RING (chan, 3);
- }
- BEGIN_RING(chan, kelvin, NV20TCL_POINT_SIZE, 1);
- if (!is_nv25tcl) {
- OUT_RING (chan, 8);
- } else {
- OUT_RINGf (chan, 1.0);
- }
- if (!is_nv25tcl) {
- BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0); /* NV20TCL.POINT_SMOOTH_ENABLE */
- } else {
- BEGIN_RING(chan, kelvin, NV20TCL_POINT_PARAMETERS_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, 0x0a1c, 1);
- OUT_RING (chan, 0x800);
- }
- BEGIN_RING(chan, kelvin, NV20TCL_LINE_WIDTH, 1);
- OUT_RING (chan, 8);
- BEGIN_RING(chan, kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_MODE_FRONT, 2);
- OUT_RING (chan, NV20TCL_POLYGON_MODE_FRONT_FILL);
- OUT_RING (chan, NV20TCL_POLYGON_MODE_BACK_FILL);
- BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE, 2);
- OUT_RING (chan, NV20TCL_CULL_FACE_BACK);
- OUT_RING (chan, NV20TCL_FRONT_FACE_CCW);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_SMOOTH_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_SHADE_MODEL, 1);
- OUT_RING (chan, NV20TCL_SHADE_MODEL_SMOOTH);
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_STIPPLE_ENABLE, 1);
- OUT_RING (chan, 0);
- BEGIN_RING(chan, kelvin, NV20TCL_TX_GEN_S(0), 4 * NV20TCL_TX_GEN_S__SIZE);
- for (i=0; i < 4 * NV20TCL_TX_GEN_S__SIZE; ++i) {
- OUT_RING(chan, 0);
- }
- BEGIN_RING(chan, kelvin, NV20TCL_FOG_EQUATION_CONSTANT, 3);
- OUT_RINGf (chan, 1.5);
- OUT_RINGf (chan, -0.090168); /* NV20TCL.FOG_EQUATION_LINEAR */
- OUT_RINGf (chan, 0.0); /* NV20TCL.FOG_EQUATION_QUADRATIC */
- BEGIN_RING(chan, kelvin, NV20TCL_FOG_MODE, 2);
- OUT_RING (chan, NV20TCL_FOG_MODE_EXP_SIGNED);
- OUT_RING (chan, NV20TCL_FOG_COORD_FOG);
- BEGIN_RING(chan, kelvin, NV20TCL_FOG_ENABLE, 2);
- OUT_RING (chan, 0);
- OUT_RING (chan, 0); /* NV20TCL.FOG_COLOR */
- BEGIN_RING(chan, kelvin, NV20TCL_ENGINE, 1);
- OUT_RING (chan, NV20TCL_ENGINE_FIXED);
-
- for (i = 0; i < NV20TCL_TX_MATRIX_ENABLE__SIZE; ++i) {
- BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
- OUT_RING (chan, 0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_VTX_ATTR_4F_X(1), 4 * 15);
- OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 0.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0);
- OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0); OUT_RINGf(chan, 1.0);
- for (i = 4; i < 16; ++i) {
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 0.0);
- OUT_RINGf(chan, 1.0);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_EDGEFLAG_ENABLE, 1);
- OUT_RING (chan, 1);
- BEGIN_RING(chan, kelvin, NV20TCL_COLOR_MASK, 1);
- OUT_RING (chan, 0x00010101);
- BEGIN_RING(chan, kelvin, NV20TCL_CLEAR_VALUE, 1);
- OUT_RING (chan, 0);
-
- memset(projectionmatrix, 0, sizeof(projectionmatrix));
- projectionmatrix[0*4+0] = 1.0;
- projectionmatrix[1*4+1] = 1.0;
- projectionmatrix[2*4+2] = 16777215.0;
- projectionmatrix[3*4+3] = 1.0;
- BEGIN_RING(chan, kelvin, NV20TCL_PROJECTION_MATRIX(0), 16);
- for (i = 0; i < 16; i++) {
- OUT_RINGf (chan, projectionmatrix[i]);
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_RANGE_NEAR, 2);
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 16777216.0); /* [0, 1] scaled approx to [0, 2^24] */
-
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_TRANSLATE_X, 4);
- OUT_RINGf (chan, 0.0); /* x-offset, w/2 + 1.031250 */
- OUT_RINGf (chan, 0.0); /* y-offset, h/2 + 0.030762 */
- OUT_RINGf (chan, 0.0);
- OUT_RINGf (chan, 16777215.0);
-
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_SCALE_X, 4);
- OUT_RINGf (chan, 0.0); /* no effect?, w/2 */
- OUT_RINGf (chan, 0.0); /* no effect?, h/2 */
- OUT_RINGf (chan, 16777215.0 * 0.5);
- OUT_RINGf (chan, 65535.0);
-
- FIRE_RING (chan);
-}
-
-struct pipe_context *
-nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
-{
- struct nv20_screen *screen = nv20_screen(pscreen);
- struct pipe_winsys *ws = pscreen->winsys;
- struct nv20_context *nv20;
- struct nouveau_winsys *nvws = screen->nvws;
-
- nv20 = CALLOC(1, sizeof(struct nv20_context));
- if (!nv20)
- return NULL;
- nv20->screen = screen;
- nv20->pctx_id = pctx_id;
-
- nv20->nvws = nvws;
-
- nv20->pipe.winsys = ws;
- nv20->pipe.screen = pscreen;
- nv20->pipe.destroy = nv20_destroy;
- nv20->pipe.draw_arrays = nv20_draw_arrays;
- nv20->pipe.draw_elements = nv20_draw_elements;
- nv20->pipe.clear = nv20_clear;
- nv20->pipe.flush = nv20_flush;
-
- nv20->pipe.is_texture_referenced = nouveau_is_texture_referenced;
- nv20->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
-
- nv20_init_surface_functions(nv20);
- nv20_init_state_functions(nv20);
-
- nv20->draw = draw_create();
- assert(nv20->draw);
- draw_set_rasterize_stage(nv20->draw, nv20_draw_vbuf_stage(nv20));
-
- nv20_init_hwctx(nv20);
-
- return &nv20->pipe;
-}
-
diff --git a/src/gallium/drivers/nv20/nv20_context.h b/src/gallium/drivers/nv20/nv20_context.h
deleted file mode 100644
index c7dfadaa31..0000000000
--- a/src/gallium/drivers/nv20/nv20_context.h
+++ /dev/null
@@ -1,150 +0,0 @@
-#ifndef __NV20_CONTEXT_H__
-#define __NV20_CONTEXT_H__
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "pipe/p_compiler.h"
-
-#include "util/u_memory.h"
-#include "util/u_math.h"
-
-#include "draw/draw_vertex.h"
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_gldefs.h"
-#include "nouveau/nouveau_context.h"
-
-#include "nv20_state.h"
-
-#define NOUVEAU_ERR(fmt, args...) \
- fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
-#define NOUVEAU_MSG(fmt, args...) \
- fprintf(stderr, "nouveau: "fmt, ##args);
-
-#define NV20_NEW_VERTPROG (1 << 0)
-#define NV20_NEW_FRAGPROG (1 << 1)
-#define NV20_NEW_VTXARRAYS (1 << 2)
-#define NV20_NEW_BLEND (1 << 3)
-#define NV20_NEW_BLENDCOL (1 << 4)
-#define NV20_NEW_RAST (1 << 5)
-#define NV20_NEW_DSA (1 << 6)
-#define NV20_NEW_VIEWPORT (1 << 7)
-#define NV20_NEW_SCISSOR (1 << 8)
-#define NV20_NEW_FRAMEBUFFER (1 << 9)
-
-#include "nv20_screen.h"
-
-struct nv20_context {
- struct pipe_context pipe;
-
- struct nouveau_winsys *nvws;
- struct nv20_screen *screen;
- unsigned pctx_id;
-
- struct draw_context *draw;
-
- uint32_t dirty;
-
- struct nv20_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
- struct nv20_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
- unsigned dirty_samplers;
- unsigned fp_samplers;
- unsigned vp_samplers;
-
- uint32_t rt_enable;
- struct pipe_buffer *rt[4];
- struct pipe_buffer *zeta;
- uint32_t lma_offset;
-
- struct nv20_blend_state *blend;
- struct pipe_blend_color *blend_color;
- struct nv20_rasterizer_state *rast;
- struct nv20_depth_stencil_alpha_state *dsa;
- struct pipe_viewport_state *viewport;
- struct pipe_scissor_state *scissor;
- struct pipe_framebuffer_state *framebuffer;
-
- //struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
- float *constbuf[PIPE_SHADER_TYPES][32][4];
- unsigned constbuf_nr[PIPE_SHADER_TYPES];
-
- struct vertex_info vertex_info;
-
- struct {
- struct pipe_buffer *buffer;
- uint32_t format;
- } tex[2];
-
- unsigned vb_enable;
- struct {
- struct pipe_buffer *buffer;
- unsigned delta;
- } vb[16];
-
-/* struct {
-
- struct nouveau_resource *exec_heap;
- struct nouveau_resource *data_heap;
-
- struct nv20_vertex_program *active;
-
- struct nv20_vertex_program *current;
- } vertprog;
-*/
- struct {
- struct nv20_fragment_program *active;
-
- struct nv20_fragment_program *current;
- struct pipe_buffer *constant_buf;
- } fragprog;
-
- struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
- struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
-};
-
-static INLINE struct nv20_context *
-nv20_context(struct pipe_context *pipe)
-{
- return (struct nv20_context *)pipe;
-}
-
-extern void nv20_init_state_functions(struct nv20_context *nv20);
-extern void nv20_init_surface_functions(struct nv20_context *nv20);
-
-extern void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen);
-
-/* nv20_clear.c */
-extern void nv20_clear(struct pipe_context *pipe, unsigned buffers,
- const float *rgba, double depth, unsigned stencil);
-
-/* nv20_draw.c */
-extern struct draw_stage *nv20_draw_render_stage(struct nv20_context *nv20);
-
-/* nv20_fragprog.c */
-extern void nv20_fragprog_bind(struct nv20_context *,
- struct nv20_fragment_program *);
-extern void nv20_fragprog_destroy(struct nv20_context *,
- struct nv20_fragment_program *);
-
-/* nv20_fragtex.c */
-extern void nv20_fragtex_bind(struct nv20_context *);
-
-/* nv20_prim_vbuf.c */
-struct draw_stage *nv20_draw_vbuf_stage( struct nv20_context *nv20 );
-extern void nv20_vtxbuf_bind(struct nv20_context* nv20);
-
-/* nv20_state.c and friends */
-extern void nv20_emit_hw_state(struct nv20_context *nv20);
-extern void nv20_state_tex_update(struct nv20_context *nv20);
-
-/* nv20_vbo.c */
-extern void nv20_draw_arrays(struct pipe_context *, unsigned mode,
- unsigned start, unsigned count);
-extern void nv20_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count);
-
-
-#endif
diff --git a/src/gallium/drivers/nv20/nv20_fragprog.c b/src/gallium/drivers/nv20/nv20_fragprog.c
deleted file mode 100644
index 4f496369dd..0000000000
--- a/src/gallium/drivers/nv20/nv20_fragprog.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#include "pipe/p_shader_tokens.h"
-#include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_util.h"
-
-#include "nv20_context.h"
-
-void
-nv20_fragprog_bind(struct nv20_context *nv20, struct nv20_fragment_program *fp)
-{
-}
-
-void
-nv20_fragprog_destroy(struct nv20_context *nv20,
- struct nv20_fragment_program *fp)
-{
-}
-
diff --git a/src/gallium/drivers/nv20/nv20_fragtex.c b/src/gallium/drivers/nv20/nv20_fragtex.c
deleted file mode 100644
index dedbec73f3..0000000000
--- a/src/gallium/drivers/nv20/nv20_fragtex.c
+++ /dev/null
@@ -1,130 +0,0 @@
-#include "nv20_context.h"
-#include "nouveau/nouveau_util.h"
-
-#define _(m,tf) \
-{ \
- TRUE, \
- PIPE_FORMAT_##m, \
- NV20TCL_TX_FORMAT_FORMAT_##tf, \
-}
-
-struct nv20_texture_format {
- boolean defined;
- uint pipe;
- int format;
-};
-
-static struct nv20_texture_format
-nv20_texture_formats[] = {
- _(A8R8G8B8_UNORM, A8R8G8B8),
- _(A1R5G5B5_UNORM, A1R5G5B5),
- _(A4R4G4B4_UNORM, A4R4G4B4),
- _(L8_UNORM , L8 ),
- _(A8_UNORM , A8 ),
- _(A8L8_UNORM , A8L8 ),
-/* _(RGB_DXT1 , DXT1, ), */
-/* _(RGBA_DXT1 , DXT1, ), */
-/* _(RGBA_DXT3 , DXT3, ), */
-/* _(RGBA_DXT5 , DXT5, ), */
- {},
-};
-
-static struct nv20_texture_format *
-nv20_fragtex_format(uint pipe_format)
-{
- struct nv20_texture_format *tf = nv20_texture_formats;
-
- while (tf->defined) {
- if (tf->pipe == pipe_format)
- return tf;
- tf++;
- }
-
- return NULL;
-}
-
-
-static void
-nv20_fragtex_build(struct nv20_context *nv20, int unit)
-{
-#if 0
- struct nv20_sampler_state *ps = nv20->tex_sampler[unit];
- struct nv20_miptree *nv20mt = nv20->tex_miptree[unit];
- struct pipe_texture *pt = &nv20mt->base;
- struct nv20_texture_format *tf;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
- uint32_t txf, txs, txp;
-
- tf = nv20_fragtex_format(pt->format);
- if (!tf || !tf->defined) {
- NOUVEAU_ERR("Unsupported texture format: 0x%x\n", pt->format);
- return;
- }
-
- txf = tf->format << 8;
- txf |= (pt->last_level + 1) << 16;
- txf |= log2i(pt->width0) << 20;
- txf |= log2i(pt->height0) << 24;
- txf |= log2i(pt->depth0) << 28;
- txf |= 8;
-
- switch (pt->target) {
- case PIPE_TEXTURE_CUBE:
- txf |= NV10TCL_TX_FORMAT_CUBE_MAP;
- /* fall-through */
- case PIPE_TEXTURE_2D:
- txf |= (2<<4);
- break;
- case PIPE_TEXTURE_1D:
- txf |= (1<<4);
- break;
- default:
- NOUVEAU_ERR("Unknown target %d\n", pt->target);
- return;
- }
-
- BEGIN_RING(chan, kelvin, NV10TCL_TX_OFFSET(unit), 8);
- OUT_RELOCl(chan, nouveau_bo(nv20mt->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- OUT_RELOCd(chan, nouveau_bo(nv20mt->buffer),txf,NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_OR | NOUVEAU_BO_RD, 1/*VRAM*/,2/*TT*/);
- OUT_RING (chan, ps->wrap);
- OUT_RING (chan, 0x40000000); /* enable */
- OUT_RING (chan, txs);
- OUT_RING (chan, ps->filt | 0x2000 /* magic */);
- OUT_RING (chan, (pt->width0 << 16) | pt->height0);
- OUT_RING (chan, ps->bcol);
-#endif
-}
-
-void
-nv20_fragtex_bind(struct nv20_context *nv20)
-{
-#if 0
- struct nv20_fragment_program *fp = nv20->fragprog.active;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
- unsigned samplers, unit;
-
- samplers = nv20->fp_samplers & ~fp->samplers;
- while (samplers) {
- unit = ffs(samplers) - 1;
- samplers &= ~(1 << unit);
-
- BEGIN_RING(chan, kelvin, NV10TCL_TX_ENABLE(unit), 1);
- OUT_RING (chan, 0);
- }
-
- samplers = nv20->dirty_samplers & fp->samplers;
- while (samplers) {
- unit = ffs(samplers) - 1;
- samplers &= ~(1 << unit);
-
- nv20_fragtex_build(nv20, unit);
- }
-
- nv20->fp_samplers = fp->samplers;
-#endif
-}
-
diff --git a/src/gallium/drivers/nv20/nv20_miptree.c b/src/gallium/drivers/nv20/nv20_miptree.c
deleted file mode 100644
index 8f7538e7f5..0000000000
--- a/src/gallium/drivers/nv20/nv20_miptree.c
+++ /dev/null
@@ -1,226 +0,0 @@
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-
-#include "nv20_context.h"
-#include "nv20_screen.h"
-#include "../nv04/nv04_surface_2d.h"
-
-static void
-nv20_miptree_layout(struct nv20_miptree *nv20mt)
-{
- struct pipe_texture *pt = &nv20mt->base;
- uint width = pt->width0;
- uint offset = 0;
- int nr_faces, l, f;
- uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
- PIPE_TEXTURE_USAGE_RENDER_TARGET |
- PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_PRIMARY);
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- nr_faces = 6;
- } else {
- nr_faces = 1;
- }
-
- for (l = 0; l <= pt->last_level; l++) {
- if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
- nv20mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
- else
- nv20mt->level[l].pitch = util_format_get_stride(pt->format, width);
-
- nv20mt->level[l].image_offset =
- CALLOC(nr_faces, sizeof(unsigned));
-
- width = u_minify(width, 1);
- }
-
- for (f = 0; f < nr_faces; f++) {
- for (l = 0; l < pt->last_level; l++) {
- nv20mt->level[l].image_offset[f] = offset;
-
- if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
- u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1)
- offset += align(nv20mt->level[l].pitch * u_minify(pt->height0, l), 64);
- else
- offset += nv20mt->level[l].pitch * u_minify(pt->height0, l);
- }
-
- nv20mt->level[l].image_offset[f] = offset;
- offset += nv20mt->level[l].pitch * u_minify(pt->height0, l);
- }
-
- nv20mt->total_size = offset;
-}
-
-static struct pipe_texture *
-nv20_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
- const unsigned *stride, struct pipe_buffer *pb)
-{
- struct nv20_miptree *mt;
-
- /* Only supports 2D, non-mipmapped textures for the moment */
- if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
- pt->depth0 != 1)
- return NULL;
-
- mt = CALLOC_STRUCT(nv20_miptree);
- if (!mt)
- return NULL;
-
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = pscreen;
- mt->level[0].pitch = stride[0];
- mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
-
- pipe_buffer_reference(&mt->buffer, pb);
- mt->bo = nouveau_bo(mt->buffer);
- return &mt->base;
-}
-
-static struct pipe_texture *
-nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
-{
- struct nv20_miptree *mt;
- unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
- NOUVEAU_BUFFER_USAGE_TEXTURE;
-
- mt = MALLOC(sizeof(struct nv20_miptree));
- if (!mt)
- return NULL;
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = screen;
-
- /* Swizzled textures must be POT */
- if (pt->width0 & (pt->width0 - 1) ||
- pt->height0 & (pt->height0 - 1))
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
- else
- if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY |
- PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
- else
- if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
- else {
- switch (pt->format) {
- /* TODO: Figure out which formats can be swizzled */
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- case PIPE_FORMAT_R16_SNORM:
- {
- if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE))
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
- break;
- }
- default:
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
- }
- }
-
- if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
- buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
-
- /* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
- * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
- * This also happens for small mipmaps of large textures. */
- if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64)
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
-
- nv20_miptree_layout(mt);
-
- mt->buffer = screen->buffer_create(screen, 256, buf_usage, mt->total_size);
- if (!mt->buffer) {
- FREE(mt);
- return NULL;
- }
- mt->bo = nouveau_bo(mt->buffer);
-
- return &mt->base;
-}
-
-static void
-nv20_miptree_destroy(struct pipe_texture *pt)
-{
- struct nv20_miptree *nv20mt = (struct nv20_miptree *)pt;
- int l;
-
- pipe_buffer_reference(&nv20mt->buffer, NULL);
- for (l = 0; l <= pt->last_level; l++) {
- if (nv20mt->level[l].image_offset)
- FREE(nv20mt->level[l].image_offset);
- }
-}
-
-static struct pipe_surface *
-nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
-{
- struct nv20_miptree *nv20mt = (struct nv20_miptree *)pt;
- struct nv04_surface *ns;
-
- ns = CALLOC_STRUCT(nv04_surface);
- if (!ns)
- return NULL;
- pipe_texture_reference(&ns->base.texture, pt);
- ns->base.format = pt->format;
- ns->base.width = u_minify(pt->width0, level);
- ns->base.height = u_minify(pt->height0, level);
- ns->base.usage = flags;
- pipe_reference_init(&ns->base.reference, 1);
- ns->base.face = face;
- ns->base.level = level;
- ns->base.zslice = zslice;
- ns->pitch = nv20mt->level[level].pitch;
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- ns->base.offset = nv20mt->level[level].image_offset[face];
- } else
- if (pt->target == PIPE_TEXTURE_3D) {
- ns->base.offset = nv20mt->level[level].image_offset[zslice];
- } else {
- ns->base.offset = nv20mt->level[level].image_offset[0];
- }
-
- /* create a linear temporary that we can render into if necessary.
- * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
- * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
- if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
- return &nv04_surface_wrap_for_render(screen, ((struct nv20_screen*)screen)->eng2d, ns)->base;
-
- return &ns->base;
-}
-
-static void
-nv20_miptree_surface_destroy(struct pipe_surface *ps)
-{
- struct nv04_surface* ns = (struct nv04_surface*)ps;
- if(ns->backing)
- {
- struct nv20_screen* screen = (struct nv20_screen*)ps->texture->screen;
- if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
- screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
- nv20_miptree_surface_destroy(&ns->backing->base);
- }
-
- pipe_texture_reference(&ps->texture, NULL);
- FREE(ps);
-}
-
-void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen)
-{
- pscreen->texture_create = nv20_miptree_create;
- pscreen->texture_blanket = nv20_miptree_blanket;
- pscreen->texture_destroy = nv20_miptree_destroy;
- pscreen->get_tex_surface = nv20_miptree_surface_get;
- pscreen->tex_surface_destroy = nv20_miptree_surface_destroy;
-}
-
diff --git a/src/gallium/drivers/nv20/nv20_prim_vbuf.c b/src/gallium/drivers/nv20/nv20_prim_vbuf.c
deleted file mode 100644
index 2e145672da..0000000000
--- a/src/gallium/drivers/nv20/nv20_prim_vbuf.c
+++ /dev/null
@@ -1,440 +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.
- *
- **************************************************************************/
-
-/**
- * \file
- * Build post-transformation, post-clipping vertex buffers and element
- * lists by hooking into the end of the primitive pipeline and
- * manipulating the vertex_id field in the vertex headers.
- *
- * XXX: work in progress
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- * \author Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "util/u_debug.h"
-#include "pipe/p_inlines.h"
-#include "pipe/internal/p_winsys_screen.h"
-
-#include "nv20_context.h"
-#include "nv20_state.h"
-
-#include "draw/draw_vbuf.h"
-
-/**
- * Primitive renderer for nv20.
- */
-struct nv20_vbuf_render {
- struct vbuf_render base;
-
- struct nv20_context *nv20;
-
- /** Vertex buffer in VRAM */
- struct pipe_buffer *pbuffer;
-
- /** Vertex buffer in normal memory */
- void *mbuffer;
-
- /** Vertex size in bytes */
- /*unsigned vertex_size;*/
-
- /** Hardware primitive */
- unsigned hwprim;
-};
-
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct nv20_vbuf_render *
-nv20_vbuf_render(struct vbuf_render *render)
-{
- assert(render);
- return (struct nv20_vbuf_render *)render;
-}
-
-void nv20_vtxbuf_bind( struct nv20_context* nv20 )
-{
-#if 0
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
- int i;
- for(i = 0; i < NV20TCL_VTXBUF_ADDRESS__SIZE; i++) {
- BEGIN_RING(chan, kelvin, NV20TCL_VTXBUF_ADDRESS(i), 1);
- OUT_RING(chan, 0/*nv20->vtxbuf*/);
- BEGIN_RING(chan, kelvin, NV20TCL_VTXFMT(i) ,1);
- OUT_RING(chan, 0/*XXX*/);
- }
-#endif
-}
-
-static const struct vertex_info *
-nv20_vbuf_render_get_vertex_info( struct vbuf_render *render )
-{
- struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
- struct nv20_context *nv20 = nv20_render->nv20;
-
- nv20_emit_hw_state(nv20);
-
- return &nv20->vertex_info;
-}
-
-static void *
-nv20__allocate_mbuffer(struct nv20_vbuf_render *nv20_render, size_t size)
-{
- nv20_render->mbuffer = MALLOC(size);
- return nv20_render->mbuffer;
-}
-
-static void
-nv20__allocate_pbuffer(struct nv20_vbuf_render *nv20_render, size_t size)
-{
- struct pipe_screen *screen = nv20_render->nv20->pipe.screen;
- nv20_render->pbuffer = screen->buffer_create(screen, 64,
- PIPE_BUFFER_USAGE_VERTEX, size);
-}
-
-static boolean
-nv20_vbuf_render_allocate_vertices( struct vbuf_render *render,
- ushort vertex_size,
- ushort nr_vertices )
-{
- struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
- size_t size = (size_t)vertex_size * (size_t)nr_vertices;
- void *buf;
-
- assert(!nv20_render->pbuffer);
- assert(!nv20_render->mbuffer);
-
- /*
- * For small amount of vertices, don't bother with pipe vertex
- * buffer, the data will be passed directly via the fifo.
- */
- /* XXX: Pipe vertex buffers don't work. */
- if (0 && size > 16 * 1024) {
- nv20__allocate_pbuffer(nv20_render, size);
- /* umm yeah so this is ugly */
- buf = nv20_render->pbuffer;
- } else {
- buf = nv20__allocate_mbuffer(nv20_render, size);
- }
-
- if (buf)
- nv20_render->nv20->dirty |= NV20_NEW_VTXARRAYS;
-
- return buf ? TRUE : FALSE;
-}
-
-static void *
-nv20_vbuf_render_map_vertices( struct vbuf_render *render )
-{
- struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
- struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen;
-
- if (nv20_render->pbuffer) {
- return pipe_buffer_map(pscreen, nv20_render->pbuffer,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- } else if (nv20_render->mbuffer) {
- return nv20_render->mbuffer;
- } else
- assert(0);
-
- /* warnings be gone */
- return NULL;
-}
-
-static void
-nv20_vbuf_render_unmap_vertices( struct vbuf_render *render,
- ushort min_index,
- ushort max_index )
-{
- struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
- struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen;
-
- if (nv20_render->pbuffer)
- pipe_buffer_unmap(pscreen, nv20_render->pbuffer);
-}
-
-static boolean
-nv20_vbuf_render_set_primitive( struct vbuf_render *render,
- unsigned prim )
-{
- struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
- unsigned hwp = nvgl_primitive(prim);
- if (hwp == 0)
- return FALSE;
-
- nv20_render->hwprim = hwp;
- return TRUE;
-}
-
-static uint32_t
-nv20__vtxhwformat(unsigned stride, unsigned fields, unsigned type)
-{
- return (stride << NV20TCL_VTXFMT_STRIDE_SHIFT) |
- (fields << NV20TCL_VTXFMT_SIZE_SHIFT) |
- (type << NV20TCL_VTXFMT_TYPE_SHIFT);
-}
-
-static unsigned
-nv20__emit_format(struct nv20_context *nv20, enum attrib_emit type, int hwattr)
-{
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
- uint32_t hwfmt = 0;
- unsigned fields;
-
- switch (type) {
- case EMIT_OMIT:
- hwfmt = nv20__vtxhwformat(0, 0, 2);
- fields = 0;
- break;
- case EMIT_1F:
- hwfmt = nv20__vtxhwformat(4, 1, 2);
- fields = 1;
- break;
- case EMIT_2F:
- hwfmt = nv20__vtxhwformat(8, 2, 2);
- fields = 2;
- break;
- case EMIT_3F:
- hwfmt = nv20__vtxhwformat(12, 3, 2);
- fields = 3;
- break;
- case EMIT_4F:
- hwfmt = nv20__vtxhwformat(16, 4, 2);
- fields = 4;
- break;
- default:
- NOUVEAU_ERR("unhandled attrib_emit %d\n", type);
- return 0;
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_VTXFMT(hwattr), 1);
- OUT_RING(chan, hwfmt);
- return fields;
-}
-
-static unsigned
-nv20__emit_vertex_array_format(struct nv20_context *nv20)
-{
- struct vertex_info *vinfo = &nv20->vertex_info;
- int hwattr = NV20TCL_VTXFMT__SIZE;
- int attr = 0;
- unsigned nr_fields = 0;
-
- while (hwattr-- > 0) {
- if (vinfo->hwfmt[0] & (1 << hwattr)) {
- nr_fields += nv20__emit_format(nv20,
- vinfo->attrib[attr].emit, hwattr);
- attr++;
- } else
- nv20__emit_format(nv20, EMIT_OMIT, hwattr);
- }
-
- return nr_fields;
-}
-
-static void
-nv20__draw_mbuffer(struct nv20_vbuf_render *nv20_render,
- const ushort *indices,
- uint nr_indices)
-{
- struct nv20_context *nv20 = nv20_render->nv20;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
- struct vertex_info *vinfo = &nv20->vertex_info;
- unsigned nr_fields;
- int max_push;
- ubyte *data = nv20_render->mbuffer;
- int vsz = 4 * vinfo->size;
-
- nr_fields = nv20__emit_vertex_array_format(nv20);
-
- BEGIN_RING(chan, kelvin, NV20TCL_VERTEX_BEGIN_END, 1);
- OUT_RING(chan, nv20_render->hwprim);
-
- max_push = 1200 / nr_fields;
- while (nr_indices) {
- int i;
- int push = MIN2(nr_indices, max_push);
-
- BEGIN_RING_NI(chan, kelvin, NV20TCL_VERTEX_DATA, push * nr_fields);
- for (i = 0; i < push; i++) {
- /* XXX: fixme to handle other than floats? */
- int f = nr_fields;
- float *attrv = (float*)&data[indices[i] * vsz];
- while (f-- > 0)
- OUT_RINGf(chan, *attrv++);
- }
-
- nr_indices -= push;
- indices += push;
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_VERTEX_BEGIN_END, 1);
- OUT_RING(chan, NV20TCL_VERTEX_BEGIN_END_STOP);
-}
-
-static void
-nv20__draw_pbuffer(struct nv20_vbuf_render *nv20_render,
- const ushort *indices,
- uint nr_indices)
-{
- struct nv20_context *nv20 = nv20_render->nv20;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
- int push, i;
-
- NOUVEAU_ERR("nv20__draw_pbuffer: this path is broken.\n");
-
- BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_ARRAY_OFFSET_POS, 1);
- OUT_RELOCl(chan, nouveau_bo(nv20_render->pbuffer), 0,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
-
- BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
- OUT_RING(chan, nv20_render->hwprim);
-
- if (nr_indices & 1) {
- BEGIN_RING(chan, kelvin, NV10TCL_VB_ELEMENT_U32, 1);
- OUT_RING (chan, indices[0]);
- indices++; nr_indices--;
- }
-
- while (nr_indices) {
- // XXX too big/small ? check the size
- push = MIN2(nr_indices, 1200 * 2);
-
- BEGIN_RING_NI(chan, kelvin, NV10TCL_VB_ELEMENT_U16, push >> 1);
- for (i = 0; i < push; i+=2)
- OUT_RING(chan, (indices[i+1] << 16) | indices[i]);
-
- nr_indices -= push;
- indices += push;
- }
-
- BEGIN_RING(chan, kelvin, NV10TCL_VERTEX_BUFFER_BEGIN_END, 1);
- OUT_RING (chan, 0);
-}
-
-static void
-nv20_vbuf_render_draw( struct vbuf_render *render,
- const ushort *indices,
- uint nr_indices)
-{
- struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
-
- nv20_emit_hw_state(nv20_render->nv20);
-
- if (nv20_render->pbuffer)
- nv20__draw_pbuffer(nv20_render, indices, nr_indices);
- else if (nv20_render->mbuffer)
- nv20__draw_mbuffer(nv20_render, indices, nr_indices);
- else
- assert(0);
-}
-
-
-static void
-nv20_vbuf_render_release_vertices( struct vbuf_render *render )
-{
- struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
- struct nv20_context *nv20 = nv20_render->nv20;
-
- if (nv20_render->pbuffer) {
- pipe_buffer_reference(&nv20_render->pbuffer, NULL);
- } else if (nv20_render->mbuffer) {
- FREE(nv20_render->mbuffer);
- nv20_render->mbuffer = NULL;
- } else
- assert(0);
-}
-
-
-static void
-nv20_vbuf_render_destroy( struct vbuf_render *render )
-{
- struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
-
- assert(!nv20_render->pbuffer);
- assert(!nv20_render->mbuffer);
-
- FREE(nv20_render);
-}
-
-
-/**
- * Create a new primitive render.
- */
-static struct vbuf_render *
-nv20_vbuf_render_create( struct nv20_context *nv20 )
-{
- struct nv20_vbuf_render *nv20_render = CALLOC_STRUCT(nv20_vbuf_render);
-
- nv20_render->nv20 = nv20;
-
- nv20_render->base.max_vertex_buffer_bytes = 16*1024;
- nv20_render->base.max_indices = 1024;
- nv20_render->base.get_vertex_info = nv20_vbuf_render_get_vertex_info;
- nv20_render->base.allocate_vertices =
- nv20_vbuf_render_allocate_vertices;
- nv20_render->base.map_vertices = nv20_vbuf_render_map_vertices;
- nv20_render->base.unmap_vertices = nv20_vbuf_render_unmap_vertices;
- nv20_render->base.set_primitive = nv20_vbuf_render_set_primitive;
- nv20_render->base.draw = nv20_vbuf_render_draw;
- nv20_render->base.release_vertices = nv20_vbuf_render_release_vertices;
- nv20_render->base.destroy = nv20_vbuf_render_destroy;
-
- return &nv20_render->base;
-}
-
-
-/**
- * Create a new primitive vbuf/render stage.
- */
-struct draw_stage *nv20_draw_vbuf_stage( struct nv20_context *nv20 )
-{
- struct vbuf_render *render;
- struct draw_stage *stage;
-
- render = nv20_vbuf_render_create(nv20);
- if(!render)
- return NULL;
-
- stage = draw_vbuf_stage( nv20->draw, render );
- if(!stage) {
- render->destroy(render);
- return NULL;
- }
-
- return stage;
-}
diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c
deleted file mode 100644
index df9401bcce..0000000000
--- a/src/gallium/drivers/nv20/nv20_screen.c
+++ /dev/null
@@ -1,204 +0,0 @@
-#include "pipe/p_screen.h"
-
-#include "nv20_context.h"
-#include "nv20_screen.h"
-
-static int
-nv20_screen_get_param(struct pipe_screen *screen, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
- return 2;
- case PIPE_CAP_NPOT_TEXTURES:
- return 0;
- case PIPE_CAP_TWO_SIDED_STENCIL:
- return 0;
- case PIPE_CAP_GLSL:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 1;
- case PIPE_CAP_POINT_SPRITE:
- return 0;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 0;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 0;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 12;
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 0;
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 12;
- case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
- return 0;
- case PIPE_CAP_TGSI_CONT_SUPPORTED:
- return 0;
- case PIPE_CAP_BLEND_EQUATION_SEPARATE:
- return 0;
- case NOUVEAU_CAP_HW_VTXBUF:
- case NOUVEAU_CAP_HW_IDXBUF:
- return 0;
- case PIPE_CAP_INDEP_BLEND_ENABLE:
- return 0;
- case PIPE_CAP_INDEP_BLEND_FUNC:
- return 0;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
- case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
- return 1;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
- case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
- return 0;
- default:
- NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
- return 0;
- }
-}
-
-static float
-nv20_screen_get_paramf(struct pipe_screen *screen, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_LINE_WIDTH:
- case PIPE_CAP_MAX_LINE_WIDTH_AA:
- return 10.0;
- case PIPE_CAP_MAX_POINT_WIDTH:
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 64.0;
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 2.0;
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 4.0;
- default:
- NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
- return 0.0;
- }
-}
-
-static boolean
-nv20_screen_is_format_supported(struct pipe_screen *screen,
- enum pipe_format format,
- enum pipe_texture_target target,
- unsigned tex_usage, unsigned geom_flags)
-{
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- return TRUE;
- default:
- break;
- }
- } else
- if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
- switch (format) {
- case PIPE_FORMAT_Z24S8_UNORM:
- case PIPE_FORMAT_Z24X8_UNORM:
- case PIPE_FORMAT_Z16_UNORM:
- return TRUE;
- default:
- break;
- }
- } else {
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- case PIPE_FORMAT_A4R4G4B4_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_L8_UNORM:
- case PIPE_FORMAT_A8_UNORM:
- case PIPE_FORMAT_I8_UNORM:
- return TRUE;
- default:
- break;
- }
- }
-
- return FALSE;
-}
-
-static void
-nv20_screen_destroy(struct pipe_screen *pscreen)
-{
- struct nv20_screen *screen = nv20_screen(pscreen);
-
- nouveau_notifier_free(&screen->sync);
- nouveau_grobj_free(&screen->kelvin);
- nv04_surface_2d_takedown(&screen->eng2d);
-
- nouveau_screen_fini(&screen->base);
-
- FREE(pscreen);
-}
-
-static struct pipe_buffer *
-nv20_surface_buffer(struct pipe_surface *surf)
-{
- struct nv20_miptree *mt = (struct nv20_miptree *)surf->texture;
-
- return mt->buffer;
-}
-
-struct pipe_screen *
-nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
-{
- struct nv20_screen *screen = CALLOC_STRUCT(nv20_screen);
- struct nouveau_channel *chan;
- struct pipe_screen *pscreen;
- unsigned kelvin_class = 0;
- int ret;
-
- if (!screen)
- return NULL;
- pscreen = &screen->base.base;
-
- ret = nouveau_screen_init(&screen->base, dev);
- if (ret) {
- nv20_screen_destroy(pscreen);
- return NULL;
- }
- chan = screen->base.channel;
-
- pscreen->winsys = ws;
- pscreen->destroy = nv20_screen_destroy;
- pscreen->get_param = nv20_screen_get_param;
- pscreen->get_paramf = nv20_screen_get_paramf;
- pscreen->is_format_supported = nv20_screen_is_format_supported;
-
- nv20_screen_init_miptree_functions(pscreen);
- nv20_screen_init_transfer_functions(pscreen);
-
- /* 3D object */
- if (dev->chipset >= 0x25)
- kelvin_class = NV25TCL;
- else if (dev->chipset >= 0x20)
- kelvin_class = NV20TCL;
-
- if (!kelvin_class || dev->chipset >= 0x30) {
- NOUVEAU_ERR("Unknown nv2x chipset: nv%02x\n", dev->chipset);
- return NULL;
- }
-
- ret = nouveau_grobj_alloc(chan, 0xbeef0097, kelvin_class,
- &screen->kelvin);
- if (ret) {
- NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
- return FALSE;
- }
-
- /* 2D engine setup */
- screen->eng2d = nv04_surface_2d_init(&screen->base);
- screen->eng2d->buf = nv20_surface_buffer;
-
- /* Notifier for sync purposes */
- ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
- if (ret) {
- NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
- nv20_screen_destroy(pscreen);
- return NULL;
- }
-
- return pscreen;
-}
-
diff --git a/src/gallium/drivers/nv20/nv20_screen.h b/src/gallium/drivers/nv20/nv20_screen.h
deleted file mode 100644
index fc7bb05033..0000000000
--- a/src/gallium/drivers/nv20/nv20_screen.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __NV20_SCREEN_H__
-#define __NV20_SCREEN_H__
-
-#include "nouveau/nouveau_screen.h"
-#include "nv04/nv04_surface_2d.h"
-
-struct nv20_screen {
- struct nouveau_screen base;
-
- struct nouveau_winsys *nvws;
-
- /* HW graphics objects */
- struct nv04_surface_2d *eng2d;
- struct nouveau_grobj *kelvin;
- struct nouveau_notifier *sync;
-};
-
-static INLINE struct nv20_screen *
-nv20_screen(struct pipe_screen *screen)
-{
- return (struct nv20_screen *)screen;
-}
-
-
-void
-nv20_screen_init_transfer_functions(struct pipe_screen *pscreen);
-
-#endif
diff --git a/src/gallium/drivers/nv20/nv20_state.c b/src/gallium/drivers/nv20/nv20_state.c
deleted file mode 100644
index 83335c790a..0000000000
--- a/src/gallium/drivers/nv20/nv20_state.c
+++ /dev/null
@@ -1,583 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/p_inlines.h"
-
-#include "tgsi/tgsi_parse.h"
-
-#include "nv20_context.h"
-#include "nv20_state.h"
-
-static void *
-nv20_blend_state_create(struct pipe_context *pipe,
- const struct pipe_blend_state *cso)
-{
- struct nv20_blend_state *cb;
-
- cb = MALLOC(sizeof(struct nv20_blend_state));
-
- cb->b_enable = cso->rt[0].blend_enable ? 1 : 0;
- cb->b_srcfunc = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) |
- (nvgl_blend_func(cso->rt[0].rgb_src_factor)));
- cb->b_dstfunc = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) |
- (nvgl_blend_func(cso->rt[0].rgb_dst_factor)));
-
- cb->c_mask = (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01<<24) : 0) |
- ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01<<16) : 0) |
- ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) |
- ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01<< 0) : 0));
-
- cb->d_enable = cso->dither ? 1 : 0;
-
- return (void *)cb;
-}
-
-static void
-nv20_blend_state_bind(struct pipe_context *pipe, void *blend)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- nv20->blend = (struct nv20_blend_state*)blend;
-
- nv20->dirty |= NV20_NEW_BLEND;
-}
-
-static void
-nv20_blend_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- FREE(hwcso);
-}
-
-
-static INLINE unsigned
-wrap_mode(unsigned wrap) {
- unsigned ret;
-
- switch (wrap) {
- case PIPE_TEX_WRAP_REPEAT:
- ret = NV20TCL_TX_WRAP_S_REPEAT;
- break;
- case PIPE_TEX_WRAP_MIRROR_REPEAT:
- ret = NV20TCL_TX_WRAP_S_MIRRORED_REPEAT;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- ret = NV20TCL_TX_WRAP_S_CLAMP_TO_EDGE;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- ret = NV20TCL_TX_WRAP_S_CLAMP_TO_BORDER;
- break;
- case PIPE_TEX_WRAP_CLAMP:
- ret = NV20TCL_TX_WRAP_S_CLAMP;
- break;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
- case PIPE_TEX_WRAP_MIRROR_CLAMP:
- default:
- NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
- ret = NV20TCL_TX_WRAP_S_REPEAT;
- break;
- }
-
- return (ret >> NV20TCL_TX_WRAP_S_SHIFT);
-}
-
-static void *
-nv20_sampler_state_create(struct pipe_context *pipe,
- const struct pipe_sampler_state *cso)
-{
- struct nv20_sampler_state *ps;
- uint32_t filter = 0;
-
- ps = MALLOC(sizeof(struct nv20_sampler_state));
-
- ps->wrap = ((wrap_mode(cso->wrap_s) << NV20TCL_TX_WRAP_S_SHIFT) |
- (wrap_mode(cso->wrap_t) << NV20TCL_TX_WRAP_T_SHIFT));
-
- ps->en = 0;
- if (cso->max_anisotropy > 1.0) {
- /* no idea, binary driver sets it, works without it.. meh.. */
- ps->wrap |= (1 << 5);
-
-/* if (cso->max_anisotropy >= 8.0) {
- ps->en |= NV20TCL_TX_ENABLE_ANISO_8X;
- } else
- if (cso->max_anisotropy >= 4.0) {
- ps->en |= NV20TCL_TX_ENABLE_ANISO_4X;
- } else {
- ps->en |= NV20TCL_TX_ENABLE_ANISO_2X;
- }*/
- }
-
- switch (cso->mag_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- filter |= NV20TCL_TX_FILTER_MAGNIFY_LINEAR;
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- filter |= NV20TCL_TX_FILTER_MAGNIFY_NEAREST;
- break;
- }
-
- switch (cso->min_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- filter |=
- NV20TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- filter |= NV20TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- filter |= NV20TCL_TX_FILTER_MINIFY_LINEAR;
- break;
- }
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- filter |=
- NV20TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- filter |=
- NV20TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- filter |= NV20TCL_TX_FILTER_MINIFY_NEAREST;
- break;
- }
- break;
- }
-
- ps->filt = filter;
-
-/* if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
- switch (cso->compare_func) {
- case PIPE_FUNC_NEVER:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_NEVER;
- break;
- case PIPE_FUNC_GREATER:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_GREATER;
- break;
- case PIPE_FUNC_EQUAL:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_EQUAL;
- break;
- case PIPE_FUNC_GEQUAL:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_GEQUAL;
- break;
- case PIPE_FUNC_LESS:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_LESS;
- break;
- case PIPE_FUNC_NOTEQUAL:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_NOTEQUAL;
- break;
- case PIPE_FUNC_LEQUAL:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_LEQUAL;
- break;
- case PIPE_FUNC_ALWAYS:
- ps->wrap |= NV10TCL_TX_WRAP_RCOMP_ALWAYS;
- break;
- default:
- break;
- }
- }*/
-
- ps->bcol = ((float_to_ubyte(cso->border_color[3]) << 24) |
- (float_to_ubyte(cso->border_color[0]) << 16) |
- (float_to_ubyte(cso->border_color[1]) << 8) |
- (float_to_ubyte(cso->border_color[2]) << 0));
-
- return (void *)ps;
-}
-
-static void
-nv20_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
- unsigned unit;
-
- for (unit = 0; unit < nr; unit++) {
- nv20->tex_sampler[unit] = sampler[unit];
- nv20->dirty_samplers |= (1 << unit);
- }
-}
-
-static void
-nv20_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- FREE(hwcso);
-}
-
-static void
-nv20_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
- struct pipe_texture **miptree)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
- unsigned unit;
-
- for (unit = 0; unit < nr; unit++) {
- nv20->tex_miptree[unit] = (struct nv20_miptree *)miptree[unit];
- nv20->dirty_samplers |= (1 << unit);
- }
-}
-
-static void *
-nv20_rasterizer_state_create(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *cso)
-{
- struct nv20_rasterizer_state *rs;
- int i;
-
- /*XXX: ignored:
- * light_twoside
- * offset_cw/ccw -nohw
- * scissor
- * point_smooth -nohw
- * multisample
- * offset_units / offset_scale
- */
- rs = MALLOC(sizeof(struct nv20_rasterizer_state));
-
- rs->templ = cso;
-
- rs->shade_model = cso->flatshade ? NV20TCL_SHADE_MODEL_FLAT :
- NV20TCL_SHADE_MODEL_SMOOTH;
-
- rs->line_width = (unsigned char)(cso->line_width * 8.0) & 0xff;
- rs->line_smooth_en = cso->line_smooth ? 1 : 0;
-
- /* XXX: nv20 and nv25 different! */
- rs->point_size = *(uint32_t*)&cso->point_size;
-
- rs->poly_smooth_en = cso->poly_smooth ? 1 : 0;
-
- if (cso->front_winding == PIPE_WINDING_CCW) {
- rs->front_face = NV20TCL_FRONT_FACE_CCW;
- rs->poly_mode_front = nvgl_polygon_mode(cso->fill_ccw);
- rs->poly_mode_back = nvgl_polygon_mode(cso->fill_cw);
- } else {
- rs->front_face = NV20TCL_FRONT_FACE_CW;
- rs->poly_mode_front = nvgl_polygon_mode(cso->fill_cw);
- rs->poly_mode_back = nvgl_polygon_mode(cso->fill_ccw);
- }
-
- switch (cso->cull_mode) {
- case PIPE_WINDING_CCW:
- rs->cull_face_en = 1;
- if (cso->front_winding == PIPE_WINDING_CCW)
- rs->cull_face = NV20TCL_CULL_FACE_FRONT;
- else
- rs->cull_face = NV20TCL_CULL_FACE_BACK;
- break;
- case PIPE_WINDING_CW:
- rs->cull_face_en = 1;
- if (cso->front_winding == PIPE_WINDING_CW)
- rs->cull_face = NV20TCL_CULL_FACE_FRONT;
- else
- rs->cull_face = NV20TCL_CULL_FACE_BACK;
- break;
- case PIPE_WINDING_BOTH:
- rs->cull_face_en = 1;
- rs->cull_face = NV20TCL_CULL_FACE_FRONT_AND_BACK;
- break;
- case PIPE_WINDING_NONE:
- default:
- rs->cull_face_en = 0;
- rs->cull_face = 0;
- break;
- }
-
- if (cso->point_sprite) {
- rs->point_sprite = (1 << 0);
- for (i = 0; i < 8; i++) {
- if (cso->sprite_coord_mode[i] != PIPE_SPRITE_COORD_NONE)
- rs->point_sprite |= (1 << (8 + i));
- }
- } else {
- rs->point_sprite = 0;
- }
-
- return (void *)rs;
-}
-
-static void
-nv20_rasterizer_state_bind(struct pipe_context *pipe, void *rast)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- nv20->rast = (struct nv20_rasterizer_state*)rast;
-
- draw_set_rasterizer_state(nv20->draw, (nv20->rast ? nv20->rast->templ : NULL));
-
- nv20->dirty |= NV20_NEW_RAST;
-}
-
-static void
-nv20_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- FREE(hwcso);
-}
-
-static void *
-nv20_depth_stencil_alpha_state_create(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *cso)
-{
- struct nv20_depth_stencil_alpha_state *hw;
-
- hw = MALLOC(sizeof(struct nv20_depth_stencil_alpha_state));
-
- hw->depth.func = nvgl_comparison_op(cso->depth.func);
- hw->depth.write_enable = cso->depth.writemask ? 1 : 0;
- hw->depth.test_enable = cso->depth.enabled ? 1 : 0;
-
- hw->stencil.enable = cso->stencil[0].enabled ? 1 : 0;
- hw->stencil.wmask = cso->stencil[0].writemask;
- hw->stencil.func = nvgl_comparison_op(cso->stencil[0].func);
- hw->stencil.ref = cso->stencil[0].ref_value;
- hw->stencil.vmask = cso->stencil[0].valuemask;
- hw->stencil.fail = nvgl_stencil_op(cso->stencil[0].fail_op);
- hw->stencil.zfail = nvgl_stencil_op(cso->stencil[0].zfail_op);
- hw->stencil.zpass = nvgl_stencil_op(cso->stencil[0].zpass_op);
-
- hw->alpha.enabled = cso->alpha.enabled ? 1 : 0;
- hw->alpha.func = nvgl_comparison_op(cso->alpha.func);
- hw->alpha.ref = float_to_ubyte(cso->alpha.ref_value);
-
- return (void *)hw;
-}
-
-static void
-nv20_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *dsa)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- nv20->dsa = (struct nv20_depth_stencil_alpha_state*)dsa;
-
- nv20->dirty |= NV20_NEW_DSA;
-}
-
-static void
-nv20_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- FREE(hwcso);
-}
-
-static void *
-nv20_vp_state_create(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- return draw_create_vertex_shader(nv20->draw, templ);
-}
-
-static void
-nv20_vp_state_bind(struct pipe_context *pipe, void *shader)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- draw_bind_vertex_shader(nv20->draw, (struct draw_vertex_shader *) shader);
-
- nv20->dirty |= NV20_NEW_VERTPROG;
-}
-
-static void
-nv20_vp_state_delete(struct pipe_context *pipe, void *shader)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- draw_delete_vertex_shader(nv20->draw, (struct draw_vertex_shader *) shader);
-}
-
-static void *
-nv20_fp_state_create(struct pipe_context *pipe,
- const struct pipe_shader_state *cso)
-{
- struct nv20_fragment_program *fp;
-
- fp = CALLOC(1, sizeof(struct nv20_fragment_program));
- fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
-
- tgsi_scan_shader(cso->tokens, &fp->info);
-
- return (void *)fp;
-}
-
-static void
-nv20_fp_state_bind(struct pipe_context *pipe, void *hwcso)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
- struct nv20_fragment_program *fp = hwcso;
-
- nv20->fragprog.current = fp;
- nv20->dirty |= NV20_NEW_FRAGPROG;
-}
-
-static void
-nv20_fp_state_delete(struct pipe_context *pipe, void *hwcso)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
- struct nv20_fragment_program *fp = hwcso;
-
- nv20_fragprog_destroy(nv20, fp);
- FREE((void*)fp->pipe.tokens);
- FREE(fp);
-}
-
-static void
-nv20_set_blend_color(struct pipe_context *pipe,
- const struct pipe_blend_color *bcol)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- nv20->blend_color = (struct pipe_blend_color*)bcol;
-
- nv20->dirty |= NV20_NEW_BLENDCOL;
-}
-
-static void
-nv20_set_clip_state(struct pipe_context *pipe,
- const struct pipe_clip_state *clip)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- draw_set_clip_state(nv20->draw, clip);
-}
-
-static void
-nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
- struct pipe_buffer *buf )
-{
- struct nv20_context *nv20 = nv20_context(pipe);
- struct pipe_screen *pscreen = pipe->screen;
-
- assert(shader < PIPE_SHADER_TYPES);
- assert(index == 0);
-
- if (buf) {
- void *mapped;
- if (buf->size &&
- (mapped = pipe_buffer_map(pscreen, buf, PIPE_BUFFER_USAGE_CPU_READ)))
- {
- memcpy(nv20->constbuf[shader], mapped, buf->size);
- nv20->constbuf_nr[shader] =
- buf->size / (4 * sizeof(float));
- pipe_buffer_unmap(pscreen, buf);
- }
- }
-}
-
-static void
-nv20_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- nv20->framebuffer = (struct pipe_framebuffer_state*)fb;
-
- nv20->dirty |= NV20_NEW_FRAMEBUFFER;
-}
-
-static void
-nv20_set_polygon_stipple(struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple)
-{
- NOUVEAU_ERR("line stipple hahaha\n");
-}
-
-static void
-nv20_set_scissor_state(struct pipe_context *pipe,
- const struct pipe_scissor_state *s)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- nv20->scissor = (struct pipe_scissor_state*)s;
-
- nv20->dirty |= NV20_NEW_SCISSOR;
-}
-
-static void
-nv20_set_viewport_state(struct pipe_context *pipe,
- const struct pipe_viewport_state *vpt)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- nv20->viewport = (struct pipe_viewport_state*)vpt;
-
- draw_set_viewport_state(nv20->draw, nv20->viewport);
-
- nv20->dirty |= NV20_NEW_VIEWPORT;
-}
-
-static void
-nv20_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
- const struct pipe_vertex_buffer *vb)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- memcpy(nv20->vtxbuf, vb, sizeof(*vb) * count);
- nv20->dirty |= NV20_NEW_VTXARRAYS;
-
- draw_set_vertex_buffers(nv20->draw, count, vb);
-}
-
-static void
-nv20_set_vertex_elements(struct pipe_context *pipe, unsigned count,
- const struct pipe_vertex_element *ve)
-{
- struct nv20_context *nv20 = nv20_context(pipe);
-
- memcpy(nv20->vtxelt, ve, sizeof(*ve) * count);
- nv20->dirty |= NV20_NEW_VTXARRAYS;
-
- draw_set_vertex_elements(nv20->draw, count, ve);
-}
-
-void
-nv20_init_state_functions(struct nv20_context *nv20)
-{
- nv20->pipe.create_blend_state = nv20_blend_state_create;
- nv20->pipe.bind_blend_state = nv20_blend_state_bind;
- nv20->pipe.delete_blend_state = nv20_blend_state_delete;
-
- nv20->pipe.create_sampler_state = nv20_sampler_state_create;
- nv20->pipe.bind_fragment_sampler_states = nv20_sampler_state_bind;
- nv20->pipe.delete_sampler_state = nv20_sampler_state_delete;
- nv20->pipe.set_fragment_sampler_textures = nv20_set_sampler_texture;
-
- nv20->pipe.create_rasterizer_state = nv20_rasterizer_state_create;
- nv20->pipe.bind_rasterizer_state = nv20_rasterizer_state_bind;
- nv20->pipe.delete_rasterizer_state = nv20_rasterizer_state_delete;
-
- nv20->pipe.create_depth_stencil_alpha_state =
- nv20_depth_stencil_alpha_state_create;
- nv20->pipe.bind_depth_stencil_alpha_state =
- nv20_depth_stencil_alpha_state_bind;
- nv20->pipe.delete_depth_stencil_alpha_state =
- nv20_depth_stencil_alpha_state_delete;
-
- nv20->pipe.create_vs_state = nv20_vp_state_create;
- nv20->pipe.bind_vs_state = nv20_vp_state_bind;
- nv20->pipe.delete_vs_state = nv20_vp_state_delete;
-
- nv20->pipe.create_fs_state = nv20_fp_state_create;
- nv20->pipe.bind_fs_state = nv20_fp_state_bind;
- nv20->pipe.delete_fs_state = nv20_fp_state_delete;
-
- nv20->pipe.set_blend_color = nv20_set_blend_color;
- nv20->pipe.set_clip_state = nv20_set_clip_state;
- nv20->pipe.set_constant_buffer = nv20_set_constant_buffer;
- nv20->pipe.set_framebuffer_state = nv20_set_framebuffer_state;
- nv20->pipe.set_polygon_stipple = nv20_set_polygon_stipple;
- nv20->pipe.set_scissor_state = nv20_set_scissor_state;
- nv20->pipe.set_viewport_state = nv20_set_viewport_state;
-
- nv20->pipe.set_vertex_buffers = nv20_set_vertex_buffers;
- nv20->pipe.set_vertex_elements = nv20_set_vertex_elements;
-}
-
diff --git a/src/gallium/drivers/nv20/nv20_state.h b/src/gallium/drivers/nv20/nv20_state.h
deleted file mode 100644
index dde4106568..0000000000
--- a/src/gallium/drivers/nv20/nv20_state.h
+++ /dev/null
@@ -1,140 +0,0 @@
-#ifndef __NV20_STATE_H__
-#define __NV20_STATE_H__
-
-#include "pipe/p_state.h"
-#include "tgsi/tgsi_scan.h"
-
-struct nv20_blend_state {
- uint32_t b_enable;
- uint32_t b_srcfunc;
- uint32_t b_dstfunc;
-
- uint32_t c_mask;
-
- uint32_t d_enable;
-};
-
-struct nv20_sampler_state {
- uint32_t wrap;
- uint32_t en;
- uint32_t filt;
- uint32_t bcol;
-};
-
-struct nv20_rasterizer_state {
- uint32_t shade_model;
-
- uint32_t line_width;
- uint32_t line_smooth_en;
-
- uint32_t point_size;
-
- uint32_t poly_smooth_en;
-
- uint32_t poly_mode_front;
- uint32_t poly_mode_back;
-
- uint32_t front_face;
- uint32_t cull_face;
- uint32_t cull_face_en;
-
- uint32_t point_sprite;
-
- const struct pipe_rasterizer_state *templ;
-};
-
-struct nv20_vertex_program_exec {
- uint32_t data[4];
- boolean has_branch_offset;
- int const_index;
-};
-
-struct nv20_vertex_program_data {
- int index; /* immediates == -1 */
- float value[4];
-};
-
-struct nv20_vertex_program {
- const struct pipe_shader_state *pipe;
-
- boolean translated;
- struct nv20_vertex_program_exec *insns;
- unsigned nr_insns;
- struct nv20_vertex_program_data *consts;
- unsigned nr_consts;
-
- struct nouveau_resource *exec;
- unsigned exec_start;
- struct nouveau_resource *data;
- unsigned data_start;
- unsigned data_start_min;
-
- uint32_t ir;
- uint32_t or;
-};
-
-struct nv20_fragment_program_data {
- unsigned offset;
- unsigned index;
-};
-
-struct nv20_fragment_program {
- struct pipe_shader_state pipe;
- struct tgsi_shader_info info;
-
- boolean translated;
- boolean on_hw;
- unsigned samplers;
-
- uint32_t *insn;
- int insn_len;
-
- struct nv20_fragment_program_data *consts;
- unsigned nr_consts;
-
- struct pipe_buffer *buffer;
-
- uint32_t fp_control;
- uint32_t fp_reg_control;
-};
-
-
-struct nv20_depth_stencil_alpha_state {
- struct {
- uint32_t func;
- uint32_t write_enable;
- uint32_t test_enable;
- } depth;
-
- struct {
- uint32_t enable;
- uint32_t wmask;
- uint32_t func;
- uint32_t ref;
- uint32_t vmask;
- uint32_t fail;
- uint32_t zfail;
- uint32_t zpass;
- } stencil;
-
- struct {
- uint32_t enabled;
- uint32_t func;
- uint32_t ref;
- } alpha;
-};
-
-struct nv20_miptree {
- struct pipe_texture base;
- struct nouveau_bo *bo;
-
- struct pipe_buffer *buffer;
- uint total_size;
-
- struct {
- uint pitch;
- uint *image_offset;
- } level[PIPE_MAX_TEXTURE_LEVELS];
-};
-
-#endif
diff --git a/src/gallium/drivers/nv20/nv20_state_emit.c b/src/gallium/drivers/nv20/nv20_state_emit.c
deleted file mode 100644
index 6bbd1fdae9..0000000000
--- a/src/gallium/drivers/nv20/nv20_state_emit.c
+++ /dev/null
@@ -1,426 +0,0 @@
-#include "nv20_context.h"
-#include "nv20_state.h"
-#include "draw/draw_context.h"
-
-static void nv20_state_emit_blend(struct nv20_context* nv20)
-{
- struct nv20_blend_state *b = nv20->blend;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
-
- BEGIN_RING(chan, kelvin, NV20TCL_DITHER_ENABLE, 1);
- OUT_RING (chan, b->d_enable);
-
- BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_ENABLE, 1);
- OUT_RING (chan, b->b_enable);
-
- BEGIN_RING(chan, kelvin, NV20TCL_BLEND_FUNC_SRC, 2);
- OUT_RING (chan, b->b_srcfunc);
- OUT_RING (chan, b->b_dstfunc);
-
- BEGIN_RING(chan, kelvin, NV20TCL_COLOR_MASK, 1);
- OUT_RING (chan, b->c_mask);
-}
-
-static void nv20_state_emit_blend_color(struct nv20_context* nv20)
-{
- struct pipe_blend_color *c = nv20->blend_color;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
-
- BEGIN_RING(chan, kelvin, NV20TCL_BLEND_COLOR, 1);
- OUT_RING (chan,
- (float_to_ubyte(c->color[3]) << 24)|
- (float_to_ubyte(c->color[0]) << 16)|
- (float_to_ubyte(c->color[1]) << 8) |
- (float_to_ubyte(c->color[2]) << 0));
-}
-
-static void nv20_state_emit_rast(struct nv20_context* nv20)
-{
- struct nv20_rasterizer_state *r = nv20->rast;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
-
- BEGIN_RING(chan, kelvin, NV20TCL_SHADE_MODEL, 2);
- OUT_RING (chan, r->shade_model);
- OUT_RING (chan, r->line_width);
-
-
- BEGIN_RING(chan, kelvin, NV20TCL_POINT_SIZE, 1);
- OUT_RING (chan, r->point_size);
-
- BEGIN_RING(chan, kelvin, NV20TCL_POLYGON_MODE_FRONT, 2);
- OUT_RING (chan, r->poly_mode_front);
- OUT_RING (chan, r->poly_mode_back);
-
-
- BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE, 2);
- OUT_RING (chan, r->cull_face);
- OUT_RING (chan, r->front_face);
-
- BEGIN_RING(chan, kelvin, NV20TCL_LINE_SMOOTH_ENABLE, 2);
- OUT_RING (chan, r->line_smooth_en);
- OUT_RING (chan, r->poly_smooth_en);
-
- BEGIN_RING(chan, kelvin, NV20TCL_CULL_FACE_ENABLE, 1);
- OUT_RING (chan, r->cull_face_en);
-}
-
-static void nv20_state_emit_dsa(struct nv20_context* nv20)
-{
- struct nv20_depth_stencil_alpha_state *d = nv20->dsa;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
-
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_FUNC, 1);
- OUT_RING (chan, d->depth.func);
-
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_WRITE_ENABLE, 1);
- OUT_RING (chan, d->depth.write_enable);
-
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_TEST_ENABLE, 1);
- OUT_RING (chan, d->depth.test_enable);
-
- BEGIN_RING(chan, kelvin, NV20TCL_DEPTH_UNK17D8, 1);
- OUT_RING (chan, 1);
-
-#if 0
- BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_ENABLE, 1);
- OUT_RING (chan, d->stencil.enable);
- BEGIN_RING(chan, kelvin, NV20TCL_STENCIL_MASK, 7);
- OUT_RINGp (chan, (uint32_t *)&(d->stencil.wmask), 7);
-#endif
-
- BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_ENABLE, 1);
- OUT_RING (chan, d->alpha.enabled);
-
- BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_FUNC, 1);
- OUT_RING (chan, d->alpha.func);
-
- BEGIN_RING(chan, kelvin, NV20TCL_ALPHA_FUNC_REF, 1);
- OUT_RING (chan, d->alpha.ref);
-}
-
-static void nv20_state_emit_viewport(struct nv20_context* nv20)
-{
-}
-
-static void nv20_state_emit_scissor(struct nv20_context* nv20)
-{
- /* NV20TCL_SCISSOR_* is probably a software method */
-/* struct pipe_scissor_state *s = nv20->scissor;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
-
- BEGIN_RING(chan, kelvin, NV20TCL_SCISSOR_HORIZ, 2);
- OUT_RING (chan, ((s->maxx - s->minx) << 16) | s->minx);
- OUT_RING (chan, ((s->maxy - s->miny) << 16) | s->miny);*/
-}
-
-static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
-{
- struct pipe_framebuffer_state* fb = nv20->framebuffer;
- struct nv04_surface *rt, *zeta = NULL;
- uint32_t rt_format, w, h;
- int colour_format = 0, zeta_format = 0;
- struct nv20_miptree *nv20mt = 0;
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
-
- w = fb->cbufs[0]->width;
- h = fb->cbufs[0]->height;
- colour_format = fb->cbufs[0]->format;
- rt = (struct nv04_surface *)fb->cbufs[0];
-
- if (fb->zsbuf) {
- if (colour_format) {
- assert(w == fb->zsbuf->width);
- assert(h == fb->zsbuf->height);
- } else {
- w = fb->zsbuf->width;
- h = fb->zsbuf->height;
- }
-
- zeta_format = fb->zsbuf->format;
- zeta = (struct nv04_surface *)fb->zsbuf;
- }
-
- rt_format = NV20TCL_RT_FORMAT_TYPE_LINEAR | 0x20;
-
- switch (colour_format) {
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- rt_format |= NV20TCL_RT_FORMAT_COLOR_X8R8G8B8;
- break;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case 0:
- rt_format |= NV20TCL_RT_FORMAT_COLOR_A8R8G8B8;
- break;
- case PIPE_FORMAT_R5G6B5_UNORM:
- rt_format |= NV20TCL_RT_FORMAT_COLOR_R5G6B5;
- break;
- default:
- assert(0);
- }
-
- if (zeta) {
- BEGIN_RING(chan, kelvin, NV20TCL_RT_PITCH, 1);
- OUT_RING (chan, rt->pitch | (zeta->pitch << 16));
- } else {
- BEGIN_RING(chan, kelvin, NV20TCL_RT_PITCH, 1);
- OUT_RING (chan, rt->pitch | (rt->pitch << 16));
- }
-
- nv20mt = (struct nv20_miptree *)rt->base.texture;
- nv20->rt[0] = nv20mt->buffer;
-
- if (zeta_format)
- {
- nv20mt = (struct nv20_miptree *)zeta->base.texture;
- nv20->zeta = nv20mt->buffer;
- }
-
- BEGIN_RING(chan, kelvin, NV20TCL_RT_HORIZ, 3);
- OUT_RING (chan, (w << 16) | 0);
- OUT_RING (chan, (h << 16) | 0); /*NV20TCL_RT_VERT */
- OUT_RING (chan, rt_format); /* NV20TCL_RT_FORMAT */
- BEGIN_RING(chan, kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 2);
- OUT_RING (chan, ((w - 1) << 16) | 0);
- OUT_RING (chan, ((h - 1) << 16) | 0);
-}
-
-static void nv20_vertex_layout(struct nv20_context *nv20)
-{
- struct nv20_fragment_program *fp = nv20->fragprog.current;
- struct draw_context *dc = nv20->draw;
- int src;
- int i;
- struct vertex_info *vinfo = &nv20->vertex_info;
- const enum interp_mode colorInterp = INTERP_LINEAR;
- boolean colors[2] = { FALSE };
- boolean generics[12] = { FALSE };
- boolean fog = FALSE;
-
- memset(vinfo, 0, sizeof(*vinfo));
-
- /*
- * Assumed NV20 hardware vertex attribute order:
- * 0 position, 1 ?, 2 ?, 3 col0,
- * 4 col1?, 5 ?, 6 ?, 7 ?,
- * 8 ?, 9 tex0, 10 tex1, 11 tex2,
- * 12 tex3, 13 ?, 14 ?, 15 ?
- * unaccounted: wgh, nor, fog
- * There are total 16 attrs.
- * vinfo->hwfmt[0] has a used-bit corresponding to each of these.
- * relation to TGSI_SEMANTIC_*:
- * - POSITION: position (always used)
- * - COLOR: col1, col0
- * - GENERIC: tex3, tex2, tex1, tex0, normal, weight
- * - FOG: fog
- */
-
- for (i = 0; i < fp->info.num_inputs; i++) {
- int isn = fp->info.input_semantic_name[i];
- int isi = fp->info.input_semantic_index[i];
- switch (isn) {
- case TGSI_SEMANTIC_POSITION:
- break;
- case TGSI_SEMANTIC_COLOR:
- assert(isi < 2);
- colors[isi] = TRUE;
- break;
- case TGSI_SEMANTIC_GENERIC:
- assert(isi < 12);
- generics[isi] = TRUE;
- break;
- case TGSI_SEMANTIC_FOG:
- fog = TRUE;
- break;
- default:
- assert(0 && "unknown input_semantic_name");
- }
- }
-
- /* always do position */ {
- src = draw_find_shader_output(dc, TGSI_SEMANTIC_POSITION, 0);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_LINEAR, src);
- vinfo->hwfmt[0] |= (1 << 0);
- }
-
- /* two unnamed generics */
- for (i = 4; i < 6; i++) {
- if (!generics[i])
- continue;
- src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
- vinfo->hwfmt[0] |= (1 << (i - 3));
- }
-
- if (colors[0]) {
- src = draw_find_shader_output(dc, TGSI_SEMANTIC_COLOR, 0);
- draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
- vinfo->hwfmt[0] |= (1 << 3);
- }
-
- if (colors[1]) {
- src = draw_find_shader_output(dc, TGSI_SEMANTIC_COLOR, 1);
- draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
- vinfo->hwfmt[0] |= (1 << 4);
- }
-
- /* four unnamed generics */
- for (i = 6; i < 10; i++) {
- if (!generics[i])
- continue;
- src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
- vinfo->hwfmt[0] |= (1 << (i - 1));
- }
-
- /* tex0, tex1, tex2, tex3 */
- for (i = 0; i < 4; i++) {
- if (!generics[i])
- continue;
- src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
- vinfo->hwfmt[0] |= (1 << (i + 9));
- }
-
- /* two unnamed generics */
- for (i = 10; i < 12; i++) {
- if (!generics[i])
- continue;
- src = draw_find_shader_output(dc, TGSI_SEMANTIC_GENERIC, i);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
- vinfo->hwfmt[0] |= (1 << (i + 3));
- }
-
- if (fog) {
- src = draw_find_shader_output(dc, TGSI_SEMANTIC_FOG, 0);
- draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src);
- vinfo->hwfmt[0] |= (1 << 15);
- }
-
- draw_compute_vertex_size(vinfo);
-}
-
-void
-nv20_emit_hw_state(struct nv20_context *nv20)
-{
- struct nv20_screen *screen = nv20->screen;
- struct nouveau_channel *chan = screen->base.channel;
- struct nouveau_grobj *kelvin = screen->kelvin;
- struct nouveau_bo *rt_bo;
- int i;
-
- if (nv20->dirty & NV20_NEW_VERTPROG) {
- //nv20_vertprog_bind(nv20, nv20->vertprog.current);
- nv20->dirty &= ~NV20_NEW_VERTPROG;
- }
-
- if (nv20->dirty & NV20_NEW_FRAGPROG) {
- nv20_fragprog_bind(nv20, nv20->fragprog.current);
- /*XXX: clear NV20_NEW_FRAGPROG if no new program uploaded */
- nv20->dirty_samplers |= (1<<10);
- nv20->dirty_samplers = 0;
- }
-
- if (nv20->dirty_samplers || (nv20->dirty & NV20_NEW_FRAGPROG)) {
- nv20_fragtex_bind(nv20);
- nv20->dirty &= ~NV20_NEW_FRAGPROG;
- }
-
- if (nv20->dirty & NV20_NEW_VTXARRAYS) {
- nv20->dirty &= ~NV20_NEW_VTXARRAYS;
- nv20_vertex_layout(nv20);
- nv20_vtxbuf_bind(nv20);
- }
-
- if (nv20->dirty & NV20_NEW_BLEND) {
- nv20->dirty &= ~NV20_NEW_BLEND;
- nv20_state_emit_blend(nv20);
- }
-
- if (nv20->dirty & NV20_NEW_BLENDCOL) {
- nv20->dirty &= ~NV20_NEW_BLENDCOL;
- nv20_state_emit_blend_color(nv20);
- }
-
- if (nv20->dirty & NV20_NEW_RAST) {
- nv20->dirty &= ~NV20_NEW_RAST;
- nv20_state_emit_rast(nv20);
- }
-
- if (nv20->dirty & NV20_NEW_DSA) {
- nv20->dirty &= ~NV20_NEW_DSA;
- nv20_state_emit_dsa(nv20);
- }
-
- if (nv20->dirty & NV20_NEW_VIEWPORT) {
- nv20->dirty &= ~NV20_NEW_VIEWPORT;
- nv20_state_emit_viewport(nv20);
- }
-
- if (nv20->dirty & NV20_NEW_SCISSOR) {
- nv20->dirty &= ~NV20_NEW_SCISSOR;
- nv20_state_emit_scissor(nv20);
- }
-
- if (nv20->dirty & NV20_NEW_FRAMEBUFFER) {
- nv20->dirty &= ~NV20_NEW_FRAMEBUFFER;
- nv20_state_emit_framebuffer(nv20);
- }
-
- /* Emit relocs for every referenced buffer.
- * This is to ensure the bufmgr has an accurate idea of how
- * the buffer is used. This isn't very efficient, but we don't
- * seem to take a significant performance hit. Will be improved
- * at some point. Vertex arrays are emitted by nv20_vbo.c
- */
-
- /* Render target */
- rt_bo = nouveau_bo(nv20->rt[0]);
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_COLOR, 1);
- OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, kelvin, NV20TCL_COLOR_OFFSET, 1);
- OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- if (nv20->zeta) {
- struct nouveau_bo *zeta_bo = nouveau_bo(nv20->zeta);
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_ZETA, 1);
- OUT_RELOCo(chan, zeta_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, kelvin, NV20TCL_ZETA_OFFSET, 1);
- OUT_RELOCl(chan, zeta_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- /* XXX for when we allocate LMA on nv17 */
-/* BEGIN_RING(chan, kelvin, NV10TCL_LMA_DEPTH_BUFFER_OFFSET, 1);
- OUT_RELOCl(chan, nouveau_bo(nv20->zeta + lma_offset));*/
- }
-
- /* Vertex buffer */
- BEGIN_RING(chan, kelvin, NV20TCL_DMA_VTXBUF0, 1);
- OUT_RELOCo(chan, rt_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- BEGIN_RING(chan, kelvin, NV20TCL_COLOR_OFFSET, 1);
- OUT_RELOCl(chan, rt_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-
- /* Texture images */
- for (i = 0; i < 2; i++) {
- if (!(nv20->fp_samplers & (1 << i)))
- continue;
- struct nouveau_bo *bo = nouveau_bo(nv20->tex[i].buffer);
- BEGIN_RING(chan, kelvin, NV20TCL_TX_OFFSET(i), 1);
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM |
- NOUVEAU_BO_GART | NOUVEAU_BO_RD);
- BEGIN_RING(chan, kelvin, NV20TCL_TX_FORMAT(i), 1);
- OUT_RELOCd(chan, bo, nv20->tex[i].format,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
- NOUVEAU_BO_OR, NV20TCL_TX_FORMAT_DMA0,
- NV20TCL_TX_FORMAT_DMA1);
- }
-}
-
diff --git a/src/gallium/drivers/nv20/nv20_transfer.c b/src/gallium/drivers/nv20/nv20_transfer.c
deleted file mode 100644
index 699773e8e6..0000000000
--- a/src/gallium/drivers/nv20/nv20_transfer.c
+++ /dev/null
@@ -1,178 +0,0 @@
-#include <pipe/p_state.h>
-#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
-#include <util/u_format.h>
-#include <util/u_memory.h>
-#include <util/u_math.h>
-#include <nouveau/nouveau_winsys.h>
-#include "nv20_context.h"
-#include "nv20_screen.h"
-#include "nv20_state.h"
-
-struct nv20_transfer {
- struct pipe_transfer base;
- struct pipe_surface *surface;
- boolean direct;
-};
-
-static void
-nv20_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
- struct pipe_texture *template)
-{
- memset(template, 0, sizeof(struct pipe_texture));
- template->target = pt->target;
- template->format = pt->format;
- template->width0 = width;
- template->height0 = height;
- template->depth0 = 1;
- template->last_level = 0;
- template->nr_samples = pt->nr_samples;
-
- template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
- NOUVEAU_TEXTURE_USAGE_LINEAR;
-}
-
-static struct pipe_transfer *
-nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
-{
- struct nv20_miptree *mt = (struct nv20_miptree *)pt;
- struct nv20_transfer *tx;
- struct pipe_texture tx_tex_template, *tx_tex;
-
- tx = CALLOC_STRUCT(nv20_transfer);
- if (!tx)
- return NULL;
-
- pipe_texture_reference(&tx->base.texture, pt);
- tx->base.x = x;
- tx->base.y = y;
- tx->base.width = w;
- tx->base.height = h;
- tx->base.stride = mt->level[level].pitch;
- tx->base.usage = usage;
- tx->base.face = face;
- tx->base.level = level;
- 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*/)) &&
- pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
- {
- tx->direct = true;
- tx->surface = pscreen->get_tex_surface(pscreen, pt,
- 0, 0, 0,
- pipe_transfer_buffer_flags(&tx->base));
- return &tx->base;
- }
-
- tx->direct = false;
-
- nv20_compatible_transfer_tex(pt, w, h, &tx_tex_template);
-
- tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
- if (!tx_tex)
- {
- FREE(tx);
- return NULL;
- }
-
- tx->base.stride = ((struct nv20_miptree*)tx_tex)->level[0].pitch;
-
- tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
- face, level, zslice,
- pipe_transfer_buffer_flags(&tx->base));
-
- pipe_texture_reference(&tx_tex, NULL);
-
- if (!tx->surface)
- {
- pipe_surface_reference(&tx->surface, NULL);
- FREE(tx);
- return NULL;
- }
-
- if (usage & PIPE_TRANSFER_READ) {
- struct nv20_screen *nvscreen = nv20_screen(pscreen);
- struct pipe_surface *src;
-
- src = pscreen->get_tex_surface(pscreen, pt,
- face, level, zslice,
- PIPE_BUFFER_USAGE_GPU_READ);
-
- /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
- /* TODO: Check if SIFM can un-swizzle */
- nvscreen->eng2d->copy(nvscreen->eng2d,
- tx->surface, 0, 0,
- src, x, y,
- w, h);
-
- pipe_surface_reference(&src, NULL);
- }
-
- return &tx->base;
-}
-
-static void
-nv20_transfer_del(struct pipe_transfer *ptx)
-{
- struct nv20_transfer *tx = (struct nv20_transfer *)ptx;
-
- if (!tx->direct && (ptx->usage = PIPE_TRANSFER_WRITE)) {
- struct pipe_screen *pscreen = ptx->texture->screen;
- struct nv20_screen *nvscreen = nv20_screen(pscreen);
- struct pipe_surface *dst;
-
- dst = pscreen->get_tex_surface(pscreen, ptx->texture,
- ptx->face, ptx->level, ptx->zslice,
- PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
-
- /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
- nvscreen->eng2d->copy(nvscreen->eng2d,
- dst, tx->base.x, tx->base.y,
- tx->surface, 0, 0,
- tx->base.width, tx->base.height);
-
- pipe_surface_reference(&dst, NULL);
- }
-
- pipe_surface_reference(&tx->surface, NULL);
- pipe_texture_reference(&ptx->texture, NULL);
- FREE(ptx);
-}
-
-static void *
-nv20_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
-{
- struct nv20_transfer *tx = (struct nv20_transfer *)ptx;
- struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
- struct nv20_miptree *mt = (struct nv20_miptree *)tx->surface->texture;
- void *map = pipe_buffer_map(pscreen, mt->buffer,
- pipe_transfer_buffer_flags(ptx));
-
- if(!tx->direct)
- return map + ns->base.offset;
- else
- return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
-}
-
-static void
-nv20_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
-{
- struct nv20_transfer *tx = (struct nv20_transfer *)ptx;
- struct nv20_miptree *mt = (struct nv20_miptree *)tx->surface->texture;
-
- pipe_buffer_unmap(pscreen, mt->buffer);
-}
-
-void
-nv20_screen_init_transfer_functions(struct pipe_screen *pscreen)
-{
- pscreen->get_tex_transfer = nv20_transfer_new;
- pscreen->tex_transfer_destroy = nv20_transfer_del;
- pscreen->transfer_map = nv20_transfer_map;
- pscreen->transfer_unmap = nv20_transfer_unmap;
-}
diff --git a/src/gallium/drivers/nv20/nv20_vbo.c b/src/gallium/drivers/nv20/nv20_vbo.c
deleted file mode 100644
index 6dc9538901..0000000000
--- a/src/gallium/drivers/nv20/nv20_vbo.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "draw/draw_context.h"
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
-
-#include "nv20_context.h"
-#include "nv20_state.h"
-
-#include "nouveau/nouveau_channel.h"
-#include "nouveau/nouveau_pushbuf.h"
-
-void nv20_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count)
-{
- struct pipe_screen *pscreen = pipe->screen;
- struct nv20_context *nv20 = nv20_context( pipe );
- struct draw_context *draw = nv20->draw;
- unsigned i;
-
- nv20_emit_hw_state(nv20);
-
- /*
- * Map vertex buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (nv20->vtxbuf[i].buffer) {
- void *buf
- = pipe_buffer_map(pscreen,
- nv20->vtxbuf[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
- }
- /* Map index buffer, if present */
- if (indexBuffer) {
- void *mapped_indexes
- = pipe_buffer_map(pscreen, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
- }
- else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
- draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
- nv20->constbuf[PIPE_SHADER_VERTEX],
- nv20->constbuf_nr[PIPE_SHADER_VERTEX]);
-
- /* draw! */
- draw_arrays(nv20->draw, prim, start, count);
-
- /*
- * unmap vertex/index buffers
- */
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (nv20->vtxbuf[i].buffer) {
- pipe_buffer_unmap(pscreen, nv20->vtxbuf[i].buffer);
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- }
- }
- if (indexBuffer) {
- pipe_buffer_unmap(pscreen, indexBuffer);
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
- draw_flush(nv20->draw);
-}
-
-void nv20_draw_arrays( struct pipe_context *pipe,
- unsigned prim, unsigned start, unsigned count)
-{
- nv20_draw_elements(pipe, NULL, 0, prim, start, count);
-}
-
-
-
diff --git a/src/gallium/drivers/nv20/nv20_vertprog.c b/src/gallium/drivers/nv20/nv20_vertprog.c
deleted file mode 100644
index 7886c2af7e..0000000000
--- a/src/gallium/drivers/nv20/nv20_vertprog.c
+++ /dev/null
@@ -1,841 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
-
-#include "pipe/p_shader_tokens.h"
-#include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_dump.h"
-
-#include "nv20_context.h"
-#include "nv20_state.h"
-
-/* TODO (at least...):
- * 1. Indexed consts + ARL
- * 2. Arb. swz/negation
- * 3. NV_vp11, NV_vp2, NV_vp3 features
- * - extra arith opcodes
- * - branching
- * - texture sampling
- * - indexed attribs
- * - indexed results
- * 4. bugs
- */
-
-#define SWZ_X 0
-#define SWZ_Y 1
-#define SWZ_Z 2
-#define SWZ_W 3
-#define MASK_X 8
-#define MASK_Y 4
-#define MASK_Z 2
-#define MASK_W 1
-#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
-#define DEF_SCALE 0
-#define DEF_CTEST 0
-#include "nv20_shader.h"
-
-#define swz(s,x,y,z,w) nv20_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
-#define neg(s) nv20_sr_neg((s))
-#define abs(s) nv20_sr_abs((s))
-
-struct nv20_vpc {
- struct nv20_vertex_program *vp;
-
- struct nv20_vertex_program_exec *vpi;
-
- unsigned output_map[PIPE_MAX_SHADER_OUTPUTS];
-
- int high_temp;
- int temp_temp_count;
-
- struct nv20_sreg *imm;
- unsigned nr_imm;
-};
-
-static struct nv20_sreg
-temp(struct nv20_vpc *vpc)
-{
- int idx;
-
- idx = vpc->temp_temp_count++;
- idx += vpc->high_temp + 1;
- return nv20_sr(NV30SR_TEMP, idx);
-}
-
-static struct nv20_sreg
-constant(struct nv20_vpc *vpc, int pipe, float x, float y, float z, float w)
-{
- struct nv20_vertex_program *vp = vpc->vp;
- struct nv20_vertex_program_data *vpd;
- int idx;
-
- if (pipe >= 0) {
- for (idx = 0; idx < vp->nr_consts; idx++) {
- if (vp->consts[idx].index == pipe)
- return nv20_sr(NV30SR_CONST, idx);
- }
- }
-
- idx = vp->nr_consts++;
- vp->consts = realloc(vp->consts, sizeof(*vpd) * vp->nr_consts);
- vpd = &vp->consts[idx];
-
- vpd->index = pipe;
- vpd->value[0] = x;
- vpd->value[1] = y;
- vpd->value[2] = z;
- vpd->value[3] = w;
- return nv20_sr(NV30SR_CONST, idx);
-}
-
-#define arith(cc,s,o,d,m,s0,s1,s2) \
- nv20_vp_arith((cc), (s), NV30_VP_INST_##o, (d), (m), (s0), (s1), (s2))
-
-static void
-emit_src(struct nv20_vpc *vpc, uint32_t *hw, int pos, struct nv20_sreg src)
-{
- struct nv20_vertex_program *vp = vpc->vp;
- uint32_t sr = 0;
-
- switch (src.type) {
- case NV30SR_TEMP:
- sr |= (NV30_VP_SRC_REG_TYPE_TEMP << NV30_VP_SRC_REG_TYPE_SHIFT);
- sr |= (src.index << NV30_VP_SRC_TEMP_SRC_SHIFT);
- break;
- case NV30SR_INPUT:
- sr |= (NV30_VP_SRC_REG_TYPE_INPUT <<
- NV30_VP_SRC_REG_TYPE_SHIFT);
- vp->ir |= (1 << src.index);
- hw[1] |= (src.index << NV30_VP_INST_INPUT_SRC_SHIFT);
- break;
- case NV30SR_CONST:
- sr |= (NV30_VP_SRC_REG_TYPE_CONST <<
- NV30_VP_SRC_REG_TYPE_SHIFT);
- assert(vpc->vpi->const_index == -1 ||
- vpc->vpi->const_index == src.index);
- vpc->vpi->const_index = src.index;
- break;
- case NV30SR_NONE:
- sr |= (NV30_VP_SRC_REG_TYPE_INPUT <<
- NV30_VP_SRC_REG_TYPE_SHIFT);
- break;
- default:
- assert(0);
- }
-
- if (src.negate)
- sr |= NV30_VP_SRC_NEGATE;
-
- if (src.abs)
- hw[0] |= (1 << (21 + pos));
-
- sr |= ((src.swz[0] << NV30_VP_SRC_SWZ_X_SHIFT) |
- (src.swz[1] << NV30_VP_SRC_SWZ_Y_SHIFT) |
- (src.swz[2] << NV30_VP_SRC_SWZ_Z_SHIFT) |
- (src.swz[3] << NV30_VP_SRC_SWZ_W_SHIFT));
-
-/*
- * |VVV|
- * d�.�b
- * \u/
- *
- */
-
- switch (pos) {
- case 0:
- hw[1] |= ((sr & NV30_VP_SRC0_HIGH_MASK) >>
- NV30_VP_SRC0_HIGH_SHIFT) << NV30_VP_INST_SRC0H_SHIFT;
- hw[2] |= (sr & NV30_VP_SRC0_LOW_MASK) <<
- NV30_VP_INST_SRC0L_SHIFT;
- break;
- case 1:
- hw[2] |= sr << NV30_VP_INST_SRC1_SHIFT;
- break;
- case 2:
- hw[2] |= ((sr & NV30_VP_SRC2_HIGH_MASK) >>
- NV30_VP_SRC2_HIGH_SHIFT) << NV30_VP_INST_SRC2H_SHIFT;
- hw[3] |= (sr & NV30_VP_SRC2_LOW_MASK) <<
- NV30_VP_INST_SRC2L_SHIFT;
- break;
- default:
- assert(0);
- }
-}
-
-static void
-emit_dst(struct nv20_vpc *vpc, uint32_t *hw, int slot, struct nv20_sreg dst)
-{
- struct nv20_vertex_program *vp = vpc->vp;
-
- switch (dst.type) {
- case NV30SR_TEMP:
- hw[0] |= (dst.index << NV30_VP_INST_DEST_TEMP_ID_SHIFT);
- break;
- case NV30SR_OUTPUT:
- switch (dst.index) {
- case NV30_VP_INST_DEST_COL0 : vp->or |= (1 << 0); break;
- case NV30_VP_INST_DEST_COL1 : vp->or |= (1 << 1); break;
- case NV30_VP_INST_DEST_BFC0 : vp->or |= (1 << 2); break;
- case NV30_VP_INST_DEST_BFC1 : vp->or |= (1 << 3); break;
- case NV30_VP_INST_DEST_FOGC : vp->or |= (1 << 4); break;
- case NV30_VP_INST_DEST_PSZ : vp->or |= (1 << 5); break;
- case NV30_VP_INST_DEST_TC(0): vp->or |= (1 << 14); break;
- case NV30_VP_INST_DEST_TC(1): vp->or |= (1 << 15); break;
- case NV30_VP_INST_DEST_TC(2): vp->or |= (1 << 16); break;
- case NV30_VP_INST_DEST_TC(3): vp->or |= (1 << 17); break;
- case NV30_VP_INST_DEST_TC(4): vp->or |= (1 << 18); break;
- case NV30_VP_INST_DEST_TC(5): vp->or |= (1 << 19); break;
- case NV30_VP_INST_DEST_TC(6): vp->or |= (1 << 20); break;
- case NV30_VP_INST_DEST_TC(7): vp->or |= (1 << 21); break;
- default:
- break;
- }
-
- hw[3] |= (dst.index << NV30_VP_INST_DEST_SHIFT);
- hw[0] |= NV30_VP_INST_VEC_DEST_TEMP_MASK | (1<<20);
-
- /*XXX: no way this is entirely correct, someone needs to
- * figure out what exactly it is.
- */
- hw[3] |= 0x800;
- break;
- default:
- assert(0);
- }
-}
-
-static void
-nv20_vp_arith(struct nv20_vpc *vpc, int slot, int op,
- struct nv20_sreg dst, int mask,
- struct nv20_sreg s0, struct nv20_sreg s1,
- struct nv20_sreg s2)
-{
- struct nv20_vertex_program *vp = vpc->vp;
- uint32_t *hw;
-
- vp->insns = realloc(vp->insns, ++vp->nr_insns * sizeof(*vpc->vpi));
- vpc->vpi = &vp->insns[vp->nr_insns - 1];
- memset(vpc->vpi, 0, sizeof(*vpc->vpi));
- vpc->vpi->const_index = -1;
-
- hw = vpc->vpi->data;
-
- hw[0] |= (NV30_VP_INST_COND_TR << NV30_VP_INST_COND_SHIFT);
- hw[0] |= ((0 << NV30_VP_INST_COND_SWZ_X_SHIFT) |
- (1 << NV30_VP_INST_COND_SWZ_Y_SHIFT) |
- (2 << NV30_VP_INST_COND_SWZ_Z_SHIFT) |
- (3 << NV30_VP_INST_COND_SWZ_W_SHIFT));
-
- hw[1] |= (op << NV30_VP_INST_VEC_OPCODE_SHIFT);
-// hw[3] |= NV30_VP_INST_SCA_DEST_TEMP_MASK;
-// hw[3] |= (mask << NV30_VP_INST_VEC_WRITEMASK_SHIFT);
-
- if (dst.type == NV30SR_OUTPUT) {
- if (slot)
- hw[3] |= (mask << NV30_VP_INST_SDEST_WRITEMASK_SHIFT);
- else
- hw[3] |= (mask << NV30_VP_INST_VDEST_WRITEMASK_SHIFT);
- } else {
- if (slot)
- hw[3] |= (mask << NV30_VP_INST_STEMP_WRITEMASK_SHIFT);
- else
- hw[3] |= (mask << NV30_VP_INST_VTEMP_WRITEMASK_SHIFT);
- }
-
- emit_dst(vpc, hw, slot, dst);
- emit_src(vpc, hw, 0, s0);
- emit_src(vpc, hw, 1, s1);
- emit_src(vpc, hw, 2, s2);
-}
-
-static INLINE struct nv20_sreg
-tgsi_src(struct nv20_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
- struct nv20_sreg src;
-
- switch (fsrc->Register.File) {
- case TGSI_FILE_INPUT:
- src = nv20_sr(NV30SR_INPUT, fsrc->Register.Index);
- break;
- case TGSI_FILE_CONSTANT:
- src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
- break;
- case TGSI_FILE_IMMEDIATE:
- src = vpc->imm[fsrc->Register.Index];
- break;
- case TGSI_FILE_TEMPORARY:
- if (vpc->high_temp < fsrc->Register.Index)
- vpc->high_temp = fsrc->Register.Index;
- src = nv20_sr(NV30SR_TEMP, fsrc->Register.Index);
- break;
- default:
- NOUVEAU_ERR("bad src file\n");
- break;
- }
-
- src.abs = fsrc->Register.Absolute;
- src.negate = fsrc->Register.Negate;
- src.swz[0] = fsrc->Register.SwizzleX;
- src.swz[1] = fsrc->Register.SwizzleY;
- src.swz[2] = fsrc->Register.SwizzleZ;
- src.swz[3] = fsrc->Register.SwizzleW;
- return src;
-}
-
-static INLINE struct nv20_sreg
-tgsi_dst(struct nv20_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
- struct nv20_sreg dst;
-
- switch (fdst->Register.File) {
- case TGSI_FILE_OUTPUT:
- dst = nv20_sr(NV30SR_OUTPUT,
- vpc->output_map[fdst->Register.Index]);
-
- break;
- case TGSI_FILE_TEMPORARY:
- dst = nv20_sr(NV30SR_TEMP, fdst->Register.Index);
- if (vpc->high_temp < dst.index)
- vpc->high_temp = dst.index;
- break;
- default:
- NOUVEAU_ERR("bad dst file\n");
- break;
- }
-
- return dst;
-}
-
-static INLINE int
-tgsi_mask(uint tgsi)
-{
- int mask = 0;
-
- if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
- if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
- if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
- if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
- return mask;
-}
-
-static boolean
-nv20_vertprog_parse_instruction(struct nv20_vpc *vpc,
- const struct tgsi_full_instruction *finst)
-{
- struct nv20_sreg src[3], dst, tmp;
- struct nv20_sreg none = nv20_sr(NV30SR_NONE, 0);
- int mask;
- int ai = -1, ci = -1;
- int i;
-
- if (finst->Instruction.Opcode == TGSI_OPCODE_END)
- return TRUE;
-
- vpc->temp_temp_count = 0;
- for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
- const struct tgsi_full_src_register *fsrc;
-
- fsrc = &finst->Src[i];
- if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
- src[i] = tgsi_src(vpc, fsrc);
- }
- }
-
- for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
- const struct tgsi_full_src_register *fsrc;
-
- fsrc = &finst->Src[i];
- switch (fsrc->Register.File) {
- case TGSI_FILE_INPUT:
- if (ai == -1 || ai == fsrc->Register.Index) {
- ai = fsrc->Register.Index;
- src[i] = tgsi_src(vpc, fsrc);
- } else {
- src[i] = temp(vpc);
- arith(vpc, 0, OP_MOV, src[i], MASK_ALL,
- tgsi_src(vpc, fsrc), none, none);
- }
- break;
- /*XXX: index comparison is broken now that consts come from
- * two different register files.
- */
- case TGSI_FILE_CONSTANT:
- case TGSI_FILE_IMMEDIATE:
- if (ci == -1 || ci == fsrc->Register.Index) {
- ci = fsrc->Register.Index;
- src[i] = tgsi_src(vpc, fsrc);
- } else {
- src[i] = temp(vpc);
- arith(vpc, 0, OP_MOV, src[i], MASK_ALL,
- tgsi_src(vpc, fsrc), none, none);
- }
- break;
- case TGSI_FILE_TEMPORARY:
- /* handled above */
- break;
- default:
- NOUVEAU_ERR("bad src file\n");
- return FALSE;
- }
- }
-
- dst = tgsi_dst(vpc, &finst->Dst[0]);
- mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
-
- switch (finst->Instruction.Opcode) {
- case TGSI_OPCODE_ABS:
- arith(vpc, 0, OP_MOV, dst, mask, abs(src[0]), none, none);
- break;
- case TGSI_OPCODE_ADD:
- arith(vpc, 0, OP_ADD, dst, mask, src[0], none, src[1]);
- break;
- case TGSI_OPCODE_ARL:
- arith(vpc, 0, OP_ARL, dst, mask, src[0], none, none);
- break;
- case TGSI_OPCODE_DP3:
- arith(vpc, 0, OP_DP3, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_DP4:
- arith(vpc, 0, OP_DP4, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_DPH:
- arith(vpc, 0, OP_DPH, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_DST:
- arith(vpc, 0, OP_DST, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_EX2:
- arith(vpc, 1, OP_EX2, dst, mask, none, none, src[0]);
- break;
- case TGSI_OPCODE_EXP:
- arith(vpc, 1, OP_EXP, dst, mask, none, none, src[0]);
- break;
- case TGSI_OPCODE_FLR:
- arith(vpc, 0, OP_FLR, dst, mask, src[0], none, none);
- break;
- case TGSI_OPCODE_FRC:
- arith(vpc, 0, OP_FRC, dst, mask, src[0], none, none);
- break;
- case TGSI_OPCODE_LG2:
- arith(vpc, 1, OP_LG2, dst, mask, none, none, src[0]);
- break;
- case TGSI_OPCODE_LIT:
- arith(vpc, 1, OP_LIT, dst, mask, none, none, src[0]);
- break;
- case TGSI_OPCODE_LOG:
- arith(vpc, 1, OP_LOG, dst, mask, none, none, src[0]);
- break;
- case TGSI_OPCODE_MAD:
- arith(vpc, 0, OP_MAD, dst, mask, src[0], src[1], src[2]);
- break;
- case TGSI_OPCODE_MAX:
- arith(vpc, 0, OP_MAX, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_MIN:
- arith(vpc, 0, OP_MIN, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_MOV:
- arith(vpc, 0, OP_MOV, dst, mask, src[0], none, none);
- break;
- case TGSI_OPCODE_MUL:
- arith(vpc, 0, OP_MUL, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_POW:
- tmp = temp(vpc);
- arith(vpc, 1, OP_LG2, tmp, MASK_X, none, none,
- swz(src[0], X, X, X, X));
- arith(vpc, 0, OP_MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
- swz(src[1], X, X, X, X), none);
- arith(vpc, 1, OP_EX2, dst, mask, none, none,
- swz(tmp, X, X, X, X));
- break;
- case TGSI_OPCODE_RCP:
- arith(vpc, 1, OP_RCP, dst, mask, none, none, src[0]);
- break;
- case TGSI_OPCODE_RET:
- break;
- case TGSI_OPCODE_RSQ:
- arith(vpc, 1, OP_RSQ, dst, mask, none, none, src[0]);
- break;
- case TGSI_OPCODE_SGE:
- arith(vpc, 0, OP_SGE, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_SGT:
- arith(vpc, 0, OP_SGT, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_SLT:
- arith(vpc, 0, OP_SLT, dst, mask, src[0], src[1], none);
- break;
- case TGSI_OPCODE_SUB:
- arith(vpc, 0, OP_ADD, dst, mask, src[0], none, neg(src[1]));
- break;
- case TGSI_OPCODE_XPD:
- tmp = temp(vpc);
- arith(vpc, 0, OP_MUL, tmp, mask,
- swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
- arith(vpc, 0, OP_MAD, dst, (mask & ~MASK_W),
- swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
- neg(tmp));
- break;
- default:
- NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static boolean
-nv20_vertprog_parse_decl_output(struct nv20_vpc *vpc,
- const struct tgsi_full_declaration *fdec)
-{
- int hw;
-
- switch (fdec->Semantic.Name) {
- case TGSI_SEMANTIC_POSITION:
- hw = NV30_VP_INST_DEST_POS;
- break;
- case TGSI_SEMANTIC_COLOR:
- if (fdec->Semantic.Index == 0) {
- hw = NV30_VP_INST_DEST_COL0;
- } else
- if (fdec->Semantic.Index == 1) {
- hw = NV30_VP_INST_DEST_COL1;
- } else {
- NOUVEAU_ERR("bad colour semantic index\n");
- return FALSE;
- }
- break;
- case TGSI_SEMANTIC_BCOLOR:
- if (fdec->Semantic.Index == 0) {
- hw = NV30_VP_INST_DEST_BFC0;
- } else
- if (fdec->Semantic.Index == 1) {
- hw = NV30_VP_INST_DEST_BFC1;
- } else {
- NOUVEAU_ERR("bad bcolour semantic index\n");
- return FALSE;
- }
- break;
- case TGSI_SEMANTIC_FOG:
- hw = NV30_VP_INST_DEST_FOGC;
- break;
- case TGSI_SEMANTIC_PSIZE:
- hw = NV30_VP_INST_DEST_PSZ;
- break;
- case TGSI_SEMANTIC_GENERIC:
- if (fdec->Semantic.Index <= 7) {
- hw = NV30_VP_INST_DEST_TC(fdec->Semantic.Index);
- } else {
- NOUVEAU_ERR("bad generic semantic index\n");
- return FALSE;
- }
- break;
- case TGSI_SEMANTIC_EDGEFLAG:
- NOUVEAU_ERR("cannot handle edgeflag output\n");
- return FALSE;
- default:
- NOUVEAU_ERR("bad output semantic\n");
- return FALSE;
- }
-
- vpc->output_map[fdec->Range.First] = hw;
- return TRUE;
-}
-
-static boolean
-nv20_vertprog_prepare(struct nv20_vpc *vpc)
-{
- struct tgsi_parse_context p;
- int nr_imm = 0;
-
- tgsi_parse_init(&p, vpc->vp->pipe.tokens);
- while (!tgsi_parse_end_of_tokens(&p)) {
- const union tgsi_full_token *tok = &p.FullToken;
-
- tgsi_parse_token(&p);
- switch(tok->Token.Type) {
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- nr_imm++;
- break;
- default:
- break;
- }
- }
- tgsi_parse_free(&p);
-
- if (nr_imm) {
- vpc->imm = CALLOC(nr_imm, sizeof(struct nv20_sreg));
- assert(vpc->imm);
- }
-
- return TRUE;
-}
-
-static void
-nv20_vertprog_translate(struct nv20_context *nv20,
- struct nv20_vertex_program *vp)
-{
- struct tgsi_parse_context parse;
- struct nv20_vpc *vpc = NULL;
-
- tgsi_dump(vp->pipe.tokens,0);
-
- vpc = CALLOC(1, sizeof(struct nv20_vpc));
- if (!vpc)
- return;
- vpc->vp = vp;
- vpc->high_temp = -1;
-
- if (!nv20_vertprog_prepare(vpc)) {
- FREE(vpc);
- return;
- }
-
- tgsi_parse_init(&parse, vp->pipe.tokens);
-
- while (!tgsi_parse_end_of_tokens(&parse)) {
- tgsi_parse_token(&parse);
-
- switch (parse.FullToken.Token.Type) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- {
- const struct tgsi_full_declaration *fdec;
- fdec = &parse.FullToken.FullDeclaration;
- switch (fdec->Declaration.File) {
- case TGSI_FILE_OUTPUT:
- if (!nv20_vertprog_parse_decl_output(vpc, fdec))
- goto out_err;
- break;
- default:
- break;
- }
- }
- break;
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- {
- const struct tgsi_full_immediate *imm;
-
- imm = &parse.FullToken.FullImmediate;
- assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
- assert(imm->Immediate.NrTokens == 4 + 1);
- vpc->imm[vpc->nr_imm++] =
- constant(vpc, -1,
- imm->u[0].Float,
- imm->u[1].Float,
- imm->u[2].Float,
- imm->u[3].Float);
- }
- break;
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- {
- const struct tgsi_full_instruction *finst;
- finst = &parse.FullToken.FullInstruction;
- if (!nv20_vertprog_parse_instruction(vpc, finst))
- goto out_err;
- }
- break;
- default:
- break;
- }
- }
-
- vp->insns[vp->nr_insns - 1].data[3] |= NV30_VP_INST_LAST;
- vp->translated = TRUE;
-out_err:
- tgsi_parse_free(&parse);
- FREE(vpc);
-}
-
-static boolean
-nv20_vertprog_validate(struct nv20_context *nv20)
-{
- struct pipe_screen *pscreen = nv20->pipe.screen;
- struct nouveau_winsys *nvws = nv20->nvws;
- struct nouveau_grobj *rankine = nv20->screen->rankine;
- struct nv20_vertex_program *vp;
- struct pipe_buffer *constbuf;
- boolean upload_code = FALSE, upload_data = FALSE;
- int i;
-
- vp = nv20->vertprog;
- constbuf = nv20->constbuf[PIPE_SHADER_VERTEX];
-
- /* Translate TGSI shader into hw bytecode */
- if (!vp->translated) {
- nv20_vertprog_translate(nv20, vp);
- if (!vp->translated)
- return FALSE;
- }
-
- /* Allocate hw vtxprog exec slots */
- if (!vp->exec) {
- struct nouveau_resource *heap = nv20->screen->vp_exec_heap;
- struct nouveau_stateobj *so;
- uint vplen = vp->nr_insns;
-
- if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) {
- while (heap->next && heap->size < vplen) {
- struct nv20_vertex_program *evict;
-
- evict = heap->next->priv;
- nvws->res_free(&evict->exec);
- }
-
- if (nvws->res_alloc(heap, vplen, vp, &vp->exec))
- assert(0);
- }
-
- so = so_new(2, 0);
- so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1);
- so_data (so, vp->exec->start);
- so_ref(so, &vp->so);
-
- upload_code = TRUE;
- }
-
- /* Allocate hw vtxprog const slots */
- if (vp->nr_consts && !vp->data) {
- struct nouveau_resource *heap = nv20->screen->vp_data_heap;
-
- if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) {
- while (heap->next && heap->size < vp->nr_consts) {
- struct nv20_vertex_program *evict;
-
- evict = heap->next->priv;
- nvws->res_free(&evict->data);
- }
-
- if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data))
- assert(0);
- }
-
- /*XXX: handle this some day */
- assert(vp->data->start >= vp->data_start_min);
-
- upload_data = TRUE;
- if (vp->data_start != vp->data->start)
- upload_code = TRUE;
- }
-
- /* If exec or data segments moved we need to patch the program to
- * fixup offsets and register IDs.
- */
- if (vp->exec_start != vp->exec->start) {
- for (i = 0; i < vp->nr_insns; i++) {
- struct nv20_vertex_program_exec *vpi = &vp->insns[i];
-
- if (vpi->has_branch_offset) {
- assert(0);
- }
- }
-
- vp->exec_start = vp->exec->start;
- }
-
- if (vp->nr_consts && vp->data_start != vp->data->start) {
- for (i = 0; i < vp->nr_insns; i++) {
- struct nv20_vertex_program_exec *vpi = &vp->insns[i];
-
- if (vpi->const_index >= 0) {
- vpi->data[1] &= ~NV30_VP_INST_CONST_SRC_MASK;
- vpi->data[1] |=
- (vpi->const_index + vp->data->start) <<
- NV30_VP_INST_CONST_SRC_SHIFT;
-
- }
- }
-
- vp->data_start = vp->data->start;
- }
-
- /* Update + Upload constant values */
- if (vp->nr_consts) {
- float *map = NULL;
-
- if (constbuf) {
- map = pipe_buffer_map(pscreen, constbuf,
- PIPE_BUFFER_USAGE_CPU_READ);
- }
-
- for (i = 0; i < vp->nr_consts; i++) {
- struct nv20_vertex_program_data *vpd = &vp->consts[i];
-
- if (vpd->index >= 0) {
- if (!upload_data &&
- !memcmp(vpd->value, &map[vpd->index * 4],
- 4 * sizeof(float)))
- continue;
- memcpy(vpd->value, &map[vpd->index * 4],
- 4 * sizeof(float));
- }
-
- BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_CONST_ID, 5);
- OUT_RING (i + vp->data->start);
- OUT_RINGp ((uint32_t *)vpd->value, 4);
- }
-
- if (constbuf)
- pipe_buffer_unmap(pscreen, constbuf);
- }
-
- /* Upload vtxprog */
- if (upload_code) {
-#if 0
- for (i = 0; i < vp->nr_insns; i++) {
- NOUVEAU_MSG("VP inst %d: 0x%08x 0x%08x 0x%08x 0x%08x\n",
- i, vp->insns[i].data[0], vp->insns[i].data[1],
- vp->insns[i].data[2], vp->insns[i].data[3]);
- }
-#endif
- BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_FROM_ID, 1);
- OUT_RING (vp->exec->start);
- for (i = 0; i < vp->nr_insns; i++) {
- BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_INST(0), 4);
- OUT_RINGp (vp->insns[i].data, 4);
- }
- }
-
- if (vp->so != nv20->state.hw[NV30_STATE_VERTPROG]) {
- so_ref(vp->so, &nv20->state.hw[NV30_STATE_VERTPROG]);
- return TRUE;
- }
-
- return FALSE;
-}
-
-void
-nv20_vertprog_destroy(struct nv20_context *nv20, struct nv20_vertex_program *vp)
-{
- struct nouveau_winsys *nvws = nv20->screen->nvws;
-
- vp->translated = FALSE;
-
- if (vp->nr_insns) {
- FREE(vp->insns);
- vp->insns = NULL;
- vp->nr_insns = 0;
- }
-
- if (vp->nr_consts) {
- FREE(vp->consts);
- vp->consts = NULL;
- vp->nr_consts = 0;
- }
-
- nvws->res_free(&vp->exec);
- vp->exec_start = 0;
- nvws->res_free(&vp->data);
- vp->data_start = 0;
- vp->data_start_min = 0;
-
- vp->ir = vp->or = 0;
- so_ref(NULL, &vp->so);
-}
-
-struct nv20_state_entry nv20_state_vertprog = {
- .validate = nv20_vertprog_validate,
- .dirty = {
- .pipe = NV30_NEW_VERTPROG /*| NV30_NEW_UCP*/,
- .hw = NV30_STATE_VERTPROG,
- }
-};
diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
index 54572e9ab3..8a40cea2e5 100644
--- a/src/gallium/drivers/nv30/nv30_context.c
+++ b/src/gallium/drivers/nv30/nv30_context.c
@@ -1,6 +1,6 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "nv30_context.h"
#include "nv30_screen.h"
diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
index e59449287b..7d05338327 100644
--- a/src/gallium/drivers/nv30/nv30_context.h
+++ b/src/gallium/drivers/nv30/nv30_context.h
@@ -1,6 +1,8 @@
#ifndef __NV30_CONTEXT_H__
#define __NV30_CONTEXT_H__
+#include <stdio.h>
+
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
@@ -8,6 +10,7 @@
#include "util/u_memory.h"
#include "util/u_math.h"
+#include "util/u_inlines.h"
#include "draw/draw_vertex.h"
diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
index 2d565cb631..2c432c6dfa 100644
--- a/src/gallium/drivers/nv30/nv30_fragprog.c
+++ b/src/gallium/drivers/nv30/nv30_fragprog.c
@@ -1,7 +1,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_dump.h"
diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c
index 8fbba38e78..c29c36e20a 100644
--- a/src/gallium/drivers/nv30/nv30_miptree.c
+++ b/src/gallium/drivers/nv30/nv30_miptree.c
@@ -1,11 +1,11 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "nv30_context.h"
-#include "../nv04/nv04_surface_2d.h"
+#include "../nouveau/nv04_surface_2d.h"
static void
nv30_miptree_layout(struct nv30_miptree *nv30mt)
diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
index ee83ec5676..62ee2e7697 100644
--- a/src/gallium/drivers/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nv30/nv30_screen.c
@@ -173,9 +173,9 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
so_ref(NULL, &screen->state[i]);
}
- nouveau_resource_free(&screen->vp_exec_heap);
- nouveau_resource_free(&screen->vp_data_heap);
- nouveau_resource_free(&screen->query_heap);
+ nouveau_resource_destroy(&screen->vp_exec_heap);
+ nouveau_resource_destroy(&screen->vp_data_heap);
+ nouveau_resource_destroy(&screen->query_heap);
nouveau_notifier_free(&screen->query);
nouveau_notifier_free(&screen->sync);
nouveau_grobj_free(&screen->rankine);
diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h
index 5fbd998b53..744a72de91 100644
--- a/src/gallium/drivers/nv30/nv30_screen.h
+++ b/src/gallium/drivers/nv30/nv30_screen.h
@@ -3,7 +3,7 @@
#include "nouveau/nouveau_screen.h"
-#include "nv04/nv04_surface_2d.h"
+#include "nouveau/nv04_surface_2d.h"
struct nv30_screen {
struct nouveau_screen base;
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index 1f4c964270..25532e3a54 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -1,6 +1,6 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/nv30/nv30_surface.c b/src/gallium/drivers/nv30/nv30_surface.c
index 5e237e13eb..b48c5ab51a 100644
--- a/src/gallium/drivers/nv30/nv30_surface.c
+++ b/src/gallium/drivers/nv30/nv30_surface.c
@@ -28,8 +28,8 @@
#include "nv30_context.h"
#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_simple_screen.h"
+#include "util/u_inlines.h"
#include "util/u_tile.h"
static void
diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c
index 65598991c6..554bcbbdd0 100644
--- a/src/gallium/drivers/nv30/nv30_transfer.c
+++ b/src/gallium/drivers/nv30/nv30_transfer.c
@@ -1,6 +1,6 @@
#include <pipe/p_state.h>
#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
+#include <util/u_inlines.h>
#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c
index 1c5db03ea2..d50055fdd3 100644
--- a/src/gallium/drivers/nv30/nv30_vbo.c
+++ b/src/gallium/drivers/nv30/nv30_vbo.c
@@ -1,6 +1,6 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "nv30_context.h"
#include "nv30_state.h"
diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c
index e77a5be3f2..809be3712d 100644
--- a/src/gallium/drivers/nv30/nv30_vertprog.c
+++ b/src/gallium/drivers/nv30/nv30_vertprog.c
@@ -1,7 +1,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
index f79ae4db84..ffe25ffebd 100644
--- a/src/gallium/drivers/nv40/nv40_context.c
+++ b/src/gallium/drivers/nv40/nv40_context.c
@@ -1,6 +1,6 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "nv40_context.h"
#include "nv40_screen.h"
diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
index e219bb537a..3998cf2dd3 100644
--- a/src/gallium/drivers/nv40/nv40_context.h
+++ b/src/gallium/drivers/nv40/nv40_context.h
@@ -1,6 +1,8 @@
#ifndef __NV40_CONTEXT_H__
#define __NV40_CONTEXT_H__
+#include <stdio.h>
+
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
@@ -8,6 +10,7 @@
#include "util/u_memory.h"
#include "util/u_math.h"
+#include "util/u_inlines.h"
#include "draw/draw_vertex.h"
diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
index a2fd5f6c02..60ab49fad1 100644
--- a/src/gallium/drivers/nv40/nv40_draw.c
+++ b/src/gallium/drivers/nv40/nv40_draw.c
@@ -1,5 +1,5 @@
#include "pipe/p_shader_tokens.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_pack_color.h"
diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
index 1237066c39..dc24f9b08a 100644
--- a/src/gallium/drivers/nv40/nv40_fragprog.c
+++ b/src/gallium/drivers/nv40/nv40_fragprog.c
@@ -1,7 +1,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c
index 89bd155ff4..ad1a9a5195 100644
--- a/src/gallium/drivers/nv40/nv40_miptree.c
+++ b/src/gallium/drivers/nv40/nv40_miptree.c
@@ -1,11 +1,11 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "nv40_context.h"
-#include "../nv04/nv04_surface_2d.h"
+#include "../nouveau/nv04_surface_2d.h"
diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
index b1a7343b40..56fb80975c 100644
--- a/src/gallium/drivers/nv40/nv40_screen.c
+++ b/src/gallium/drivers/nv40/nv40_screen.c
@@ -157,9 +157,9 @@ nv40_screen_destroy(struct pipe_screen *pscreen)
so_ref(NULL, &screen->state[i]);
}
- nouveau_resource_free(&screen->vp_exec_heap);
- nouveau_resource_free(&screen->vp_data_heap);
- nouveau_resource_free(&screen->query_heap);
+ nouveau_resource_destroy(&screen->vp_exec_heap);
+ nouveau_resource_destroy(&screen->vp_data_heap);
+ nouveau_resource_destroy(&screen->query_heap);
nouveau_notifier_free(&screen->query);
nouveau_notifier_free(&screen->sync);
nouveau_grobj_free(&screen->curie);
diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h
index 57b4c8fc46..98fde8755b 100644
--- a/src/gallium/drivers/nv40/nv40_screen.h
+++ b/src/gallium/drivers/nv40/nv40_screen.h
@@ -2,7 +2,7 @@
#define __NV40_SCREEN_H__
#include "nouveau/nouveau_screen.h"
-#include "nv04/nv04_surface_2d.h"
+#include "nouveau/nv04_surface_2d.h"
struct nv40_screen {
struct nouveau_screen base;
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index 7a63fba18c..b09c450dc2 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -1,6 +1,6 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "draw/draw_context.h"
diff --git a/src/gallium/drivers/nv40/nv40_surface.c b/src/gallium/drivers/nv40/nv40_surface.c
index a596547974..02ecfd7bbb 100644
--- a/src/gallium/drivers/nv40/nv40_surface.c
+++ b/src/gallium/drivers/nv40/nv40_surface.c
@@ -27,7 +27,7 @@
**************************************************************************/
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_tile.h"
diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c
index 791ee6823d..ee266c6cfb 100644
--- a/src/gallium/drivers/nv40/nv40_transfer.c
+++ b/src/gallium/drivers/nv40/nv40_transfer.c
@@ -1,6 +1,6 @@
#include <pipe/p_state.h>
#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
+#include <util/u_inlines.h>
#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
index a777898f68..d1c76c03cd 100644
--- a/src/gallium/drivers/nv40/nv40_vbo.c
+++ b/src/gallium/drivers/nv40/nv40_vbo.c
@@ -1,6 +1,6 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "nv40_context.h"
#include "nv40_state.h"
diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c
index 8d80fcad38..b289eef0fc 100644
--- a/src/gallium/drivers/nv40/nv40_vertprog.c
+++ b/src/gallium/drivers/nv40/nv40_vertprog.c
@@ -1,7 +1,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c
index 5c705ccc8f..ac1abc1d5c 100644
--- a/src/gallium/drivers/nv50/nv50_context.c
+++ b/src/gallium/drivers/nv50/nv50_context.c
@@ -22,7 +22,7 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "nv50_context.h"
#include "nv50_screen.h"
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index bebcd95054..44d8f61342 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -1,6 +1,7 @@
#ifndef __NV50_CONTEXT_H__
#define __NV50_CONTEXT_H__
+#include <stdio.h>
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
@@ -8,6 +9,7 @@
#include "util/u_memory.h"
#include "util/u_math.h"
+#include "util/u_inlines.h"
#include "draw/draw_vertex.h"
diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c
index dc8364ced7..7297c74a83 100644
--- a/src/gallium/drivers/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nv50/nv50_miptree.c
@@ -22,7 +22,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "nv50_context.h"
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index e74a526c62..3653e606ef 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -23,7 +23,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c
index 9eba4c9611..57b16a355d 100644
--- a/src/gallium/drivers/nv50/nv50_query.c
+++ b/src/gallium/drivers/nv50/nv50_query.c
@@ -21,7 +21,7 @@
*/
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "nv50_context.h"
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index c4465a228c..48c7b19584 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -195,6 +195,9 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
nouveau_grobj_free(&screen->tesla);
nouveau_grobj_free(&screen->eng2d);
nouveau_grobj_free(&screen->m2mf);
+ nouveau_resource_destroy(&screen->immd_heap[0]);
+ nouveau_resource_destroy(&screen->parm_heap[0]);
+ nouveau_resource_destroy(&screen->parm_heap[1]);
nouveau_screen_fini(&screen->base);
FREE(screen);
}
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index da8dc933b0..7eb326adf5 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -22,7 +22,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c
index 6378132979..ac0c1d0270 100644
--- a/src/gallium/drivers/nv50/nv50_surface.c
+++ b/src/gallium/drivers/nv50/nv50_surface.c
@@ -25,8 +25,8 @@
#include "nouveau/nouveau_pushbuf.h"
#include "nv50_context.h"
#include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_simple_screen.h"
+#include "util/u_inlines.h"
#include "util/u_tile.h"
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index a2f1db2914..d08b4d7354 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -1,6 +1,6 @@
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c
index bfb1b34d27..ca2f8061f3 100644
--- a/src/gallium/drivers/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nv50/nv50_vbo.c
@@ -22,7 +22,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 3f461640a0..ea9b4abfde 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -28,7 +28,7 @@
#include "util/u_blitter.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "r300_screen.h"
diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c
index 60ea9c171d..39bcdc8fe6 100644
--- a/src/gallium/drivers/r300/r300_fs.c
+++ b/src/gallium/drivers/r300/r300_fs.c
@@ -77,17 +77,21 @@ void r300_shader_read_fs_inputs(struct tgsi_shader_info* info,
static void find_output_registers(struct r300_fragment_program_compiler * compiler,
struct r300_fragment_shader * fs)
{
- unsigned i;
+ unsigned i, colorbuf_count = 0;
/* Mark the outputs as not present initially */
- compiler->OutputColor = fs->info.num_outputs;
+ compiler->OutputColor[0] = fs->info.num_outputs;
+ compiler->OutputColor[1] = fs->info.num_outputs;
+ compiler->OutputColor[2] = fs->info.num_outputs;
+ compiler->OutputColor[3] = fs->info.num_outputs;
compiler->OutputDepth = fs->info.num_outputs;
/* Now see where they really are. */
for(i = 0; i < fs->info.num_outputs; ++i) {
switch(fs->info.output_semantic_name[i]) {
case TGSI_SEMANTIC_COLOR:
- compiler->OutputColor = i;
+ compiler->OutputColor[colorbuf_count] = i;
+ colorbuf_count++;
break;
case TGSI_SEMANTIC_POSITION:
compiler->OutputDepth = i;
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 95b7cb5fa4..cd4971ae13 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -26,7 +26,7 @@
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_memory.h"
@@ -142,7 +142,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300,
/* Stride to the same attrib in the next vertex in the vertex buffer,
* in dwords. */
- unsigned stride[PIPE_MAX_ATTRIBS];
+ unsigned stride[PIPE_MAX_ATTRIBS] = {0};
/* Mapped vertex buffers. */
uint32_t* map[PIPE_MAX_ATTRIBS] = {0};
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index fa8ed581da..18eecf7c13 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_simple_screen.h"
@@ -375,8 +375,11 @@ struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys)
struct r300_screen* r300screen = CALLOC_STRUCT(r300_screen);
struct r300_capabilities* caps = CALLOC_STRUCT(r300_capabilities);
- if (!r300screen || !caps)
+ if (!r300screen || !caps) {
+ FREE(r300screen);
+ FREE(caps);
return NULL;
+ }
caps->pci_id = radeon_winsys->pci_id;
caps->num_frag_pipes = radeon_winsys->gb_pipes;
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 453fb1accc..b37be26133 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -37,24 +37,31 @@ unsigned r300_texture_get_stride(struct r300_screen* screen,
unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
unsigned zslice, unsigned face);
-/* Note the signature of R300_EASY_TX_FORMAT(A, R, G, B, FORMAT)... */
+/* Translate a pipe_format into a useful texture format for sampling.
+ *
+ * R300_EASY_TX_FORMAT swizzles the texture.
+ * Note the signature of R300_EASY_TX_FORMAT:
+ * R300_EASY_TX_FORMAT(B, G, R, A, FORMAT);
+ *
+ * The FORMAT specifies how the texture sampler will treat the texture, and
+ * makes available X, Y, Z, W, ZERO, and ONE for swizzling. */
static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
{
switch (format) {
/* X8 */
case PIPE_FORMAT_A8_UNORM:
+ return R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X8);
case PIPE_FORMAT_I8_UNORM:
return R300_EASY_TX_FORMAT(X, X, X, X, X8);
case PIPE_FORMAT_L8_UNORM:
return R300_EASY_TX_FORMAT(X, X, X, ONE, X8);
/* X16 */
case PIPE_FORMAT_R16_UNORM:
+ case PIPE_FORMAT_Z16_UNORM:
return R300_EASY_TX_FORMAT(X, X, X, X, X16);
case PIPE_FORMAT_R16_SNORM:
return R300_EASY_TX_FORMAT(X, X, X, X, X16) |
R300_TX_FORMAT_SIGNED;
- case PIPE_FORMAT_Z16_UNORM:
- return R300_EASY_TX_FORMAT(X, X, X, X, X16);
/* Y8X8 */
case PIPE_FORMAT_A8L8_UNORM:
return R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8);
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
index a792c2cf98..941ec17016 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
@@ -201,6 +201,8 @@ static void transform_srcreg(
struct rc_src_register * dst,
struct tgsi_full_src_register * src)
{
+ unsigned i, j;
+
dst->File = translate_register_file(src->Register.File);
dst->Index = translate_register_index(ttr, src->Register.File, src->Register.Index);
dst->RelAddr = src->Register.Indirect;
@@ -210,6 +212,21 @@ static void transform_srcreg(
dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 3) << 9;
dst->Abs = src->Register.Absolute;
dst->Negate = src->Register.Negate ? RC_MASK_XYZW : 0;
+
+ if (src->Register.File == TGSI_FILE_IMMEDIATE) {
+ for (i = 0; i < ttr->imms_to_swizzle_count; i++) {
+ if (ttr->imms_to_swizzle[i].index == src->Register.Index) {
+ dst->File = RC_FILE_TEMPORARY;
+ dst->Index = 0;
+ dst->Swizzle = 0;
+ for (j = 0; j < 4; j++) {
+ dst->Swizzle |= GET_SWZ(ttr->imms_to_swizzle[i].swizzle,
+ tgsi_util_get_full_src_register_swizzle(src, j)) << (j * 3);
+ }
+ break;
+ }
+ }
+ }
}
static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src,
@@ -277,21 +294,45 @@ static void transform_instruction(struct tgsi_to_rc * ttr, struct tgsi_full_inst
&ttr->compiler->Program.ShadowSamplers);
}
-static void handle_immediate(struct tgsi_to_rc * ttr, struct tgsi_full_immediate * imm)
+static void handle_immediate(struct tgsi_to_rc * ttr,
+ struct tgsi_full_immediate * imm,
+ unsigned index)
{
struct rc_constant constant;
- int i;
+ unsigned swizzle = 0;
+ boolean can_swizzle = TRUE;
+ unsigned i;
- constant.Type = RC_CONSTANT_IMMEDIATE;
- constant.Size = 4;
- for(i = 0; i < 4; ++i)
- constant.u.Immediate[i] = imm->u[i].Float;
- rc_constants_add(&ttr->compiler->Program.Constants, &constant);
+ for (i = 0; i < 4; i++) {
+ if (imm->u[i].Float == 0.0f) {
+ swizzle |= RC_SWIZZLE_ZERO << (i * 3);
+ } else if (imm->u[i].Float == 0.5f) {
+ swizzle |= RC_SWIZZLE_HALF << (i * 3);
+ } else if (imm->u[i].Float == 1.0f) {
+ swizzle |= RC_SWIZZLE_ONE << (i * 3);
+ } else {
+ can_swizzle = FALSE;
+ break;
+ }
+ }
+
+ if (can_swizzle) {
+ ttr->imms_to_swizzle[ttr->imms_to_swizzle_count].index = index;
+ ttr->imms_to_swizzle[ttr->imms_to_swizzle_count].swizzle = swizzle;
+ ttr->imms_to_swizzle_count++;
+ } else {
+ constant.Type = RC_CONSTANT_IMMEDIATE;
+ constant.Size = 4;
+ for(i = 0; i < 4; ++i)
+ constant.u.Immediate[i] = imm->u[i].Float;
+ rc_constants_add(&ttr->compiler->Program.Constants, &constant);
+ }
}
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
{
struct tgsi_parse_context parser;
+ unsigned imm_index = 0;
int i;
/* Allocate constants placeholders.
@@ -308,6 +349,9 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
ttr->immediate_offset = ttr->compiler->Program.Constants.Count;
+ ttr->imms_to_swizzle = malloc(ttr->info->immediate_count * sizeof(struct swizzled_imms));
+ ttr->imms_to_swizzle_count = 0;
+
tgsi_parse_init(&parser, tokens);
while (!tgsi_parse_end_of_tokens(&parser)) {
@@ -317,7 +361,8 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
case TGSI_TOKEN_TYPE_DECLARATION:
break;
case TGSI_TOKEN_TYPE_IMMEDIATE:
- handle_immediate(ttr, &parser.FullToken.FullImmediate);
+ handle_immediate(ttr, &parser.FullToken.FullImmediate, imm_index);
+ imm_index++;
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
transform_instruction(ttr, &parser.FullToken.FullInstruction);
@@ -327,6 +372,8 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
tgsi_parse_free(&parser);
+ free(ttr->imms_to_swizzle);
+
rc_calculate_inputs_outputs(ttr->compiler);
}
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.h b/src/gallium/drivers/r300/r300_tgsi_to_rc.h
index 93e90ec6d2..39b473c7bf 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.h
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.h
@@ -29,11 +29,18 @@ struct tgsi_full_declaration;
struct tgsi_shader_info;
struct tgsi_token;
+struct swizzled_imms {
+ unsigned index;
+ unsigned swizzle;
+};
+
struct tgsi_to_rc {
struct radeon_compiler * compiler;
const struct tgsi_shader_info * info;
int immediate_offset;
+ struct swizzled_imms * imms_to_swizzle;
+ unsigned imms_to_swizzle_count;
};
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens);
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index bdb8b54bab..d4842e94ae 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -33,7 +33,7 @@ extern "C" {
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "radeon_winsys.h"
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 53133d2888..b1cfe59bc1 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -35,6 +35,7 @@
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_flush.h"
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 2b82427d54..b2acc36bf7 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -33,8 +33,8 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_simple_screen.h"
+#include "util/u_inlines.h"
#include "util/u_prim.h"
#include "sp_context.h"
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index 714a1cf534..ee6969e60f 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -28,7 +28,7 @@
#include "util/u_memory.h"
#include "util/u_simple_screen.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index f6856a5f69..d2eda7324c 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -30,7 +30,6 @@
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
-#include "draw/draw_private.h"
#include "sp_context.h"
#include "sp_screen.h"
#include "sp_state.h"
@@ -67,7 +66,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
/* compute vertex layout now */
const struct sp_fragment_shader *spfs = softpipe->fs;
struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf;
- const uint num = draw_current_shader_outputs(softpipe->draw);
+ const uint num = draw_num_shader_outputs(softpipe->draw);
uint i;
/* Tell draw_vbuf to simply emit the whole post-xform vertex
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index de3edde976..c88e213751 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -31,6 +31,7 @@
#include "pipe/p_defines.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "draw/draw_context.h"
#include "draw/draw_vs.h"
#include "tgsi/tgsi_dump.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c
index 3946678219..2db6faeca4 100644
--- a/src/gallium/drivers/softpipe/sp_state_surface.c
+++ b/src/gallium/drivers/softpipe/sp_state_surface.c
@@ -35,6 +35,7 @@
#include "draw/draw_context.h"
#include "util/u_format.h"
+#include "util/u_inlines.h"
/**
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
index 50242d5bd6..a0b95c8884 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
@@ -32,7 +32,7 @@
* Brian Paul
*/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_tile.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index a5fff91507..371c4e2025 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -31,7 +31,7 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index 112a6fe0cf..1b50bd7ffe 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -32,7 +32,7 @@
* Brian Paul
*/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_tile.h"
diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c
index d0723ebe9e..7a8b132ddc 100644
--- a/src/gallium/drivers/softpipe/sp_video_context.c
+++ b/src/gallium/drivers/softpipe/sp_video_context.c
@@ -26,7 +26,7 @@
**************************************************************************/
#include "sp_video_context.h"
-#include <pipe/p_inlines.h>
+#include <util/u_inlines.h>
#include <util/u_memory.h>
#include "softpipe/sp_winsys.h"
#include "softpipe/sp_texture.h"
diff --git a/src/gallium/drivers/softpipe/sp_winsys.c b/src/gallium/drivers/softpipe/sp_winsys.c
index 38bcd64c6a..f6598927d3 100644
--- a/src/gallium/drivers/softpipe/sp_winsys.c
+++ b/src/gallium/drivers/softpipe/sp_winsys.c
@@ -36,12 +36,13 @@
*/
-#include "pipe/internal/p_winsys_screen.h"/* port to just p_screen */
+#include "util/u_simple_screen.h"/* port to just p_screen */
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "softpipe/sp_winsys.h"
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
index af99c9de37..c4181c3f5b 100644
--- a/src/gallium/drivers/svga/svga_context.c
+++ b/src/gallium/drivers/svga/svga_context.c
@@ -26,7 +26,7 @@
#include "svga_cmd.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "util/u_bitmask.h"
@@ -215,7 +215,6 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen )
svga->state.hw_draw.num_views = 0;
svga->dirty = ~0;
- svga->state.white_fs_id = SVGA3D_INVALID_ID;
LIST_INITHEAD(&svga->dirty_buffers);
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index 66259fd010..ba86256eb2 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -327,10 +327,6 @@ struct svga_context
unsigned texture_timestamp;
- /* Internally generated shaders:
- */
- unsigned white_fs_id;
-
/*
*/
struct svga_sw_state sw;
diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c
index ca73cf9d5a..f4d2d8992c 100644
--- a/src/gallium/drivers/svga/svga_draw.c
+++ b/src/gallium/drivers/svga/svga_draw.c
@@ -24,7 +24,7 @@
**********************************************************/
#include "pipe/p_compiler.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c
index 6b6ebc9b58..6192aa96b1 100644
--- a/src/gallium/drivers/svga/svga_draw_arrays.c
+++ b/src/gallium/drivers/svga/svga_draw_arrays.c
@@ -25,7 +25,7 @@
#include "svga_cmd.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "indices/u_indices.h"
#include "svga_hw_reg.h"
diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c
index 022b444eb9..e8097d82f1 100644
--- a/src/gallium/drivers/svga/svga_draw_elements.c
+++ b/src/gallium/drivers/svga/svga_draw_elements.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_upload_mgr.h"
#include "indices/u_indices.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_blend.c b/src/gallium/drivers/svga/svga_pipe_blend.c
index 9df5485f46..9dd6fb068c 100644
--- a/src/gallium/drivers/svga/svga_pipe_blend.c
+++ b/src/gallium/drivers/svga/svga_pipe_blend.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_constants.c b/src/gallium/drivers/svga/svga_pipe_constants.c
index 9022f7c439..73a0cd6b3a 100644
--- a/src/gallium/drivers/svga/svga_pipe_constants.c
+++ b/src/gallium/drivers/svga/svga_pipe_constants.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_depthstencil.c b/src/gallium/drivers/svga/svga_pipe_depthstencil.c
index 34e60cb341..12bbd233a5 100644
--- a/src/gallium/drivers/svga/svga_pipe_depthstencil.c
+++ b/src/gallium/drivers/svga/svga_pipe_depthstencil.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c
index 4e0c499dc3..f1d23c0e74 100644
--- a/src/gallium/drivers/svga/svga_pipe_draw.c
+++ b/src/gallium/drivers/svga/svga_pipe_draw.c
@@ -25,7 +25,7 @@
#include "svga_cmd.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_prim.h"
#include "util/u_time.h"
#include "indices/u_indices.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_fs.c b/src/gallium/drivers/svga/svga_pipe_fs.c
index 32f07fb261..b71bc66552 100644
--- a/src/gallium/drivers/svga/svga_pipe_fs.c
+++ b/src/gallium/drivers/svga/svga_pipe_fs.c
@@ -23,12 +23,11 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_bitmask.h"
#include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_text.h"
#include "svga_screen.h"
#include "svga_context.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c
index 8cf1f2e083..49b43bebc2 100644
--- a/src/gallium/drivers/svga/svga_pipe_misc.c
+++ b/src/gallium/drivers/svga/svga_pipe_misc.c
@@ -25,6 +25,8 @@
#include "svga_cmd.h"
+#include "util/u_inlines.h"
+
#include "svga_context.h"
#include "svga_screen_texture.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c
index 9ea11aad9a..2f0b54092b 100644
--- a/src/gallium/drivers/svga/svga_pipe_rasterizer.c
+++ b/src/gallium/drivers/svga/svga_pipe_rasterizer.c
@@ -24,7 +24,7 @@
**********************************************************/
#include "draw/draw_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c
index 161c66dd4f..b70081343d 100644
--- a/src/gallium/drivers/svga/svga_pipe_sampler.c
+++ b/src/gallium/drivers/svga/svga_pipe_sampler.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c
index 724166a335..ffc0f99565 100644
--- a/src/gallium/drivers/svga/svga_pipe_vertex.c
+++ b/src/gallium/drivers/svga/svga_pipe_vertex.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_vs.c b/src/gallium/drivers/svga/svga_pipe_vs.c
index c4ac5304ac..de8c919e12 100644
--- a/src/gallium/drivers/svga/svga_pipe_vs.c
+++ b/src/gallium/drivers/svga/svga_pipe_vs.c
@@ -24,7 +24,7 @@
**********************************************************/
#include "draw/draw_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_bitmask.h"
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
index c9db9ac874..6933d51562 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -24,7 +24,7 @@
**********************************************************/
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_string.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/svga/svga_screen.h b/src/gallium/drivers/svga/svga_screen.h
index a009b60720..9dc229b0a8 100644
--- a/src/gallium/drivers/svga/svga_screen.h
+++ b/src/gallium/drivers/svga/svga_screen.h
@@ -28,7 +28,7 @@
#include "pipe/p_screen.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_double_list.h"
diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c
index 430a6970fd..c9e9bef540 100644
--- a/src/gallium/drivers/svga/svga_screen_buffer.c
+++ b/src/gallium/drivers/svga/svga_screen_buffer.c
@@ -27,8 +27,8 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_thread.h"
+#include "util/u_inlines.h"
+#include "os/os_thread.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/svga/svga_screen_cache.h b/src/gallium/drivers/svga/svga_screen_cache.h
index f5aa740d40..62156e3f52 100644
--- a/src/gallium/drivers/svga/svga_screen_cache.h
+++ b/src/gallium/drivers/svga/svga_screen_cache.h
@@ -31,7 +31,7 @@
#include "svga_reg.h"
#include "svga3d_reg.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_double_list.h"
diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c
index 0d69007fd8..ad7bb65278 100644
--- a/src/gallium/drivers/svga/svga_screen_texture.c
+++ b/src/gallium/drivers/svga/svga_screen_texture.c
@@ -27,8 +27,8 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_thread.h"
+#include "util/u_inlines.h"
+#include "os/os_thread.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/svga/svga_screen_texture.h b/src/gallium/drivers/svga/svga_screen_texture.h
index 89ae24219f..43853d48f8 100644
--- a/src/gallium/drivers/svga/svga_screen_texture.h
+++ b/src/gallium/drivers/svga/svga_screen_texture.h
@@ -29,6 +29,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
+#include "util/u_inlines.h"
#include "svga_screen_cache.h"
struct pipe_context;
diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c
index 6b0e511cec..bb92f818ea 100644
--- a/src/gallium/drivers/svga/svga_state_constants.c
+++ b/src/gallium/drivers/svga/svga_state_constants.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "svga_context.h"
diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c
index eda1aefd67..b4cafb8f21 100644
--- a/src/gallium/drivers/svga/svga_state_framebuffer.c
+++ b/src/gallium/drivers/svga/svga_state_framebuffer.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c
index ec2886348b..2973444d0a 100644
--- a/src/gallium/drivers/svga/svga_state_fs.c
+++ b/src/gallium/drivers/svga/svga_state_fs.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "util/u_bitmask.h"
@@ -108,70 +108,6 @@ fail:
return ret;
}
-/* The blend workaround for simulating logicop xor behaviour requires
- * that the incoming fragment color be white. This change achieves
- * that by hooking up a hard-wired fragment shader that just emits
- * color 1,1,1,1
- *
- * This is a slightly incomplete solution as it assumes that the
- * actual bound shader has no other effects beyond generating a
- * fragment color. In particular shaders containing TEXKIL and/or
- * depth-write will not have the correct behaviour, nor will those
- * expecting to use alphatest.
- *
- * These are avoidable issues, but they are not much worse than the
- * unavoidable ones associated with this technique, so it's not clear
- * how much effort should be expended trying to resolve them - the
- * ultimate result will still not be correct in most cases.
- *
- * Shader below was generated with:
- * SVGA_DEBUG=tgsi ./mesa/progs/fp/fp-tri white.txt
- */
-static int emit_white_fs( struct svga_context *svga )
-{
- int ret = PIPE_ERROR;
-
- /* ps_3_0
- * def c0, 1.000000, 0.000000, 0.000000, 1.000000
- * mov oC0, c0.x
- * end
- */
- static const unsigned white_tokens[] = {
- 0xffff0300,
- 0x05000051,
- 0xa00f0000,
- 0x3f800000,
- 0x00000000,
- 0x00000000,
- 0x3f800000,
- 0x02000001,
- 0x800f0800,
- 0xa0000000,
- 0x0000ffff,
- };
-
- assert(SVGA3D_INVALID_ID == UTIL_BITMASK_INVALID_INDEX);
- svga->state.white_fs_id = util_bitmask_add(svga->fs_bm);
- if(svga->state.white_fs_id == SVGA3D_INVALID_ID)
- goto no_fs_id;
-
- ret = SVGA3D_DefineShader(svga->swc,
- svga->state.white_fs_id,
- SVGA3D_SHADERTYPE_PS,
- white_tokens,
- sizeof(white_tokens));
- if (ret)
- goto no_definition;
-
- return 0;
-
-no_definition:
- util_bitmask_clear(svga->fs_bm, svga->state.white_fs_id);
- svga->state.white_fs_id = SVGA3D_INVALID_ID;
-no_fs_id:
- return ret;
-}
-
/* SVGA_NEW_TEXTURE_BINDING
* SVGA_NEW_RAST
@@ -199,6 +135,23 @@ static int make_fs_key( const struct svga_context *svga,
PIPE_WINDING_CW);
}
+ /* The blend workaround for simulating logicop xor behaviour
+ * requires that the incoming fragment color be white. This change
+ * achieves that by creating a varient of the current fragment
+ * shader that overrides all output colors with 1,1,1,1
+ *
+ * This will work for most shaders, including those containing
+ * TEXKIL and/or depth-write. However, it will break on the
+ * combination of xor-logicop plus alphatest.
+ *
+ * Ultimately, we could implement alphatest in the shader using
+ * texkil prior to overriding the outgoing fragment color.
+ *
+ * SVGA_NEW_BLEND
+ */
+ if (svga->curr.blend->need_white_fragments) {
+ key->white_fragments = 1;
+ }
/* XXX: want to limit this to the textures that the shader actually
* refers to.
@@ -238,40 +191,29 @@ static int emit_hw_fs( struct svga_context *svga,
unsigned id = SVGA3D_INVALID_ID;
int ret = 0;
+ struct svga_fragment_shader *fs = svga->curr.fs;
+ struct svga_fs_compile_key key;
+
/* SVGA_NEW_BLEND
+ * SVGA_NEW_TEXTURE_BINDING
+ * SVGA_NEW_RAST
+ * SVGA_NEW_NEED_SWTNL
+ * SVGA_NEW_SAMPLER
*/
- if (svga->curr.blend->need_white_fragments) {
- if (svga->state.white_fs_id == SVGA3D_INVALID_ID) {
- ret = emit_white_fs( svga );
- if (ret)
- return ret;
- }
- id = svga->state.white_fs_id;
- }
- else {
- struct svga_fragment_shader *fs = svga->curr.fs;
- struct svga_fs_compile_key key;
-
- /* SVGA_NEW_TEXTURE_BINDING
- * SVGA_NEW_RAST
- * SVGA_NEW_NEED_SWTNL
- * SVGA_NEW_SAMPLER
- */
- ret = make_fs_key( svga, &key );
+ ret = make_fs_key( svga, &key );
+ if (ret)
+ return ret;
+
+ result = search_fs_key( fs, &key );
+ if (!result) {
+ ret = compile_fs( svga, fs, &key, &result );
if (ret)
return ret;
-
- result = search_fs_key( fs, &key );
- if (!result) {
- ret = compile_fs( svga, fs, &key, &result );
- if (ret)
- return ret;
- }
-
- assert (result);
- id = result->id;
}
+ assert (result);
+ id = result->id;
+
assert(id != SVGA3D_INVALID_ID);
if (result != svga->state.hw_draw.fs) {
diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c
index 3c35a8579f..dd13a89d24 100644
--- a/src/gallium/drivers/svga/svga_state_need_swtnl.c
+++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_state.h"
diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c
index 2f9adaeb56..ff656a7e05 100644
--- a/src/gallium/drivers/svga/svga_state_rss.c
+++ b/src/gallium/drivers/svga/svga_state_rss.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c
index b3c9687b1a..17b4785978 100644
--- a/src/gallium/drivers/svga/svga_state_tss.c
+++ b/src/gallium/drivers/svga/svga_state_tss.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/svga/svga_state_vdecl.c b/src/gallium/drivers/svga/svga_state_vdecl.c
index c534308f50..d1066ce13b 100644
--- a/src/gallium/drivers/svga/svga_state_vdecl.c
+++ b/src/gallium/drivers/svga/svga_state_vdecl.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_math.h"
#include "util/u_upload_mgr.h"
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
index e7e6c08432..d7999fe53d 100644
--- a/src/gallium/drivers/svga/svga_state_vs.c
+++ b/src/gallium/drivers/svga/svga_state_vs.c
@@ -23,7 +23,7 @@
*
**********************************************************/
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_defines.h"
#include "util/u_format.h"
#include "util/u_math.h"
diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c
index aafb3e26b0..e9d7942fb5 100644
--- a/src/gallium/drivers/svga/svga_swtnl_backend.c
+++ b/src/gallium/drivers/svga/svga_swtnl_backend.c
@@ -28,7 +28,7 @@
#include "draw/draw_vertex.h"
#include "util/u_debug.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
index 5e6e30c7df..da15be155c 100644
--- a/src/gallium/drivers/svga/svga_swtnl_draw.c
+++ b/src/gallium/drivers/svga/svga_swtnl_draw.c
@@ -25,7 +25,7 @@
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_state.h"
#include "svga_context.h"
diff --git a/src/gallium/drivers/svga/svga_swtnl_state.c b/src/gallium/drivers/svga/svga_swtnl_state.c
index fe03e207ff..35f36a828f 100644
--- a/src/gallium/drivers/svga/svga_swtnl_state.c
+++ b/src/gallium/drivers/svga/svga_swtnl_state.c
@@ -25,7 +25,7 @@
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_state.h"
#include "svga_context.h"
diff --git a/src/gallium/drivers/svga/svga_tgsi.h b/src/gallium/drivers/svga/svga_tgsi.h
index 737a2213af..063c9cf422 100644
--- a/src/gallium/drivers/svga/svga_tgsi.h
+++ b/src/gallium/drivers/svga/svga_tgsi.h
@@ -49,6 +49,7 @@ struct svga_fs_compile_key
{
unsigned light_twoside:1;
unsigned front_cw:1;
+ unsigned white_fragments:1;
unsigned num_textures:8;
unsigned num_unnormalized_coords:8;
struct {
diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
index 43fc0d3235..73102a72a8 100644
--- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
+++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
@@ -194,8 +194,19 @@ static boolean ps30_output( struct svga_shader_emitter *emit,
switch (semantic.Name) {
case TGSI_SEMANTIC_COLOR:
- emit->output_map[idx] = dst_register( SVGA3DREG_COLOROUT,
- semantic.Index );
+ if (emit->unit == PIPE_SHADER_FRAGMENT &&
+ emit->key.fkey.white_fragments) {
+
+ emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
+ emit->nr_hw_temp++ );
+ emit->temp_col[idx] = emit->output_map[idx];
+ emit->true_col[idx] = dst_register( SVGA3DREG_COLOROUT,
+ semantic.Index );
+ }
+ else {
+ emit->output_map[idx] = dst_register( SVGA3DREG_COLOROUT,
+ semantic.Index );
+ }
break;
case TGSI_SEMANTIC_POSITION:
emit->output_map[idx] = dst_register( SVGA3DREG_TEMP,
diff --git a/src/gallium/drivers/svga/svga_tgsi_emit.h b/src/gallium/drivers/svga/svga_tgsi_emit.h
index 2557824293..e8f75485d5 100644
--- a/src/gallium/drivers/svga/svga_tgsi_emit.h
+++ b/src/gallium/drivers/svga/svga_tgsi_emit.h
@@ -79,6 +79,8 @@ struct svga_shader_emitter
int ps30_input_count;
+ int dynamic_branching_level;
+
boolean in_main_func;
boolean created_zero_immediate;
@@ -199,6 +201,23 @@ static INLINE boolean emit_op3( struct svga_shader_emitter *emit,
}
+static INLINE boolean emit_op4( struct svga_shader_emitter *emit,
+ SVGA3dShaderInstToken inst,
+ SVGA3dShaderDestToken dest,
+ struct src_register src0,
+ struct src_register src1,
+ struct src_register src2,
+ struct src_register src3)
+{
+ return (emit_instruction( emit, inst ) &&
+ emit_dst( emit, dest ) &&
+ emit_src( emit, src0 ) &&
+ emit_src( emit, src1 ) &&
+ emit_src( emit, src2 ) &&
+ emit_src( emit, src3 ));
+}
+
+
#define TRANSLATE_SWIZZLE(x,y,z,w) ((x) | ((y) << 2) | ((z) << 4) | ((w) << 6))
#define SWIZZLE_XYZW \
TRANSLATE_SWIZZLE(TGSI_SWIZZLE_X,TGSI_SWIZZLE_Y,TGSI_SWIZZLE_Z,TGSI_SWIZZLE_W)
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
index dc5eb8fc60..be821e9821 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -46,8 +46,6 @@ translate_opcode(
case TGSI_OPCODE_ABS: return SVGA3DOP_ABS;
case TGSI_OPCODE_ADD: return SVGA3DOP_ADD;
case TGSI_OPCODE_BREAKC: return SVGA3DOP_BREAKC;
- case TGSI_OPCODE_DDX: return SVGA3DOP_DSX;
- case TGSI_OPCODE_DDY: return SVGA3DOP_DSY;
case TGSI_OPCODE_DP2A: return SVGA3DOP_DP2ADD;
case TGSI_OPCODE_DP3: return SVGA3DOP_DP3;
case TGSI_OPCODE_DP4: return SVGA3DOP_DP4;
@@ -415,6 +413,88 @@ static boolean submit_op3( struct svga_shader_emitter *emit,
}
+
+
+/* SVGA shaders may not refer to >1 constant register in a single
+ * instruction. This function checks for that usage and inserts a
+ * move to temporary if detected.
+ */
+static boolean submit_op4( struct svga_shader_emitter *emit,
+ SVGA3dShaderInstToken inst,
+ SVGA3dShaderDestToken dest,
+ struct src_register src0,
+ struct src_register src1,
+ struct src_register src2,
+ struct src_register src3)
+{
+ SVGA3dShaderDestToken temp0;
+ SVGA3dShaderDestToken temp3;
+ boolean need_temp0 = FALSE;
+ boolean need_temp3 = FALSE;
+ SVGA3dShaderRegType type0, type1, type2, type3;
+
+ temp0.value = 0;
+ temp3.value = 0;
+ type0 = SVGA3dShaderGetRegType( src0.base.value );
+ type1 = SVGA3dShaderGetRegType( src1.base.value );
+ type2 = SVGA3dShaderGetRegType( src2.base.value );
+ type3 = SVGA3dShaderGetRegType( src2.base.value );
+
+ /* Make life a little easier - this is only used by the TXD
+ * instruction which is guaranteed not to have a constant/input reg
+ * in one slot at least:
+ */
+ assert(type1 == SVGA3DREG_SAMPLER);
+
+ if (type0 == SVGA3DREG_CONST &&
+ ((type3 == SVGA3DREG_CONST && src0.base.num != src3.base.num) ||
+ (type2 == SVGA3DREG_CONST && src0.base.num != src2.base.num)))
+ need_temp0 = TRUE;
+
+ if (type3 == SVGA3DREG_CONST &&
+ (type2 == SVGA3DREG_CONST && src3.base.num != src2.base.num))
+ need_temp3 = TRUE;
+
+ if (type0 == SVGA3DREG_INPUT &&
+ ((type3 == SVGA3DREG_INPUT && src0.base.num != src3.base.num) ||
+ (type2 == SVGA3DREG_INPUT && src0.base.num != src2.base.num)))
+ need_temp0 = TRUE;
+
+ if (type3 == SVGA3DREG_INPUT &&
+ (type2 == SVGA3DREG_INPUT && src3.base.num != src2.base.num))
+ need_temp3 = TRUE;
+
+ if (need_temp0)
+ {
+ temp0 = get_temp( emit );
+
+ if (!emit_op1( emit, inst_token( SVGA3DOP_MOV ), temp0, src0 ))
+ return FALSE;
+
+ src0 = src( temp0 );
+ }
+
+ if (need_temp3)
+ {
+ temp3 = get_temp( emit );
+
+ if (!emit_op1( emit, inst_token( SVGA3DOP_MOV ), temp3, src3 ))
+ return FALSE;
+
+ src3 = src( temp3 );
+ }
+
+ if (!emit_op4( emit, inst, dest, src0, src1, src2, src3 ))
+ return FALSE;
+
+ if (need_temp3)
+ release_temp( emit, temp3 );
+ if (need_temp0)
+ release_temp( emit, temp0 );
+ return TRUE;
+}
+
+
static boolean emit_def_const( struct svga_shader_emitter *emit,
SVGA3dShaderConstType type,
unsigned idx,
@@ -660,6 +740,8 @@ static boolean emit_if(struct svga_shader_emitter *emit,
if_token.control = SVGA3DOPCOMPC_NE;
zero = scalar(zero, TGSI_SWIZZLE_X);
+ emit->dynamic_branching_level++;
+
return (emit_instruction( emit, if_token ) &&
emit_src( emit, src ) &&
emit_src( emit, zero ) );
@@ -668,6 +750,8 @@ static boolean emit_if(struct svga_shader_emitter *emit,
static boolean emit_endif(struct svga_shader_emitter *emit,
const struct tgsi_full_instruction *insn)
{
+ emit->dynamic_branching_level--;
+
return (emit_instruction( emit,
inst_token( SVGA3DOP_ENDIF )));
}
@@ -1011,10 +1095,10 @@ static boolean emit_kilp(struct svga_shader_emitter *emit,
{
SVGA3dShaderInstToken inst;
SVGA3dShaderDestToken temp;
- struct src_register one = get_zero_immediate( emit );
+ struct src_register one = scalar( get_zero_immediate( emit ),
+ TGSI_SWIZZLE_W );
inst = inst_token( SVGA3DOP_TEXKILL );
- one = scalar( one, TGSI_SWIZZLE_W );
/* texkill doesn't allow negation on the operand so lets move
* negation of {1} to a temp register */
@@ -1169,41 +1253,79 @@ static boolean emit_tex2(struct svga_shader_emitter *emit,
SVGA3dShaderDestToken dst )
{
SVGA3dShaderInstToken inst;
- struct src_register src0;
- struct src_register src1;
-
+ struct src_register texcoord;
+ struct src_register sampler;
+ SVGA3dShaderDestToken tmp;
+
inst.value = 0;
- inst.op = SVGA3DOP_TEX;
switch (insn->Instruction.Opcode) {
case TGSI_OPCODE_TEX:
+ inst.op = SVGA3DOP_TEX;
break;
case TGSI_OPCODE_TXP:
+ inst.op = SVGA3DOP_TEX;
inst.control = SVGA3DOPCONT_PROJECT;
break;
case TGSI_OPCODE_TXB:
+ inst.op = SVGA3DOP_TEX;
inst.control = SVGA3DOPCONT_BIAS;
break;
+ case TGSI_OPCODE_TXL:
+ inst.op = SVGA3DOP_TEXLDL;
+ break;
default:
assert(0);
return FALSE;
}
- src0 = translate_src_register( emit, &insn->Src[0] );
- src1 = translate_src_register( emit, &insn->Src[1] );
+ texcoord = translate_src_register( emit, &insn->Src[0] );
+ sampler = translate_src_register( emit, &insn->Src[1] );
- if (emit->key.fkey.tex[src1.base.num].unnormalized) {
- struct src_register wh = get_tex_dimensions( emit, src1.base.num );
- SVGA3dShaderDestToken tmp = get_temp( emit );
+ if (emit->key.fkey.tex[sampler.base.num].unnormalized ||
+ emit->dynamic_branching_level > 0)
+ tmp = get_temp( emit );
+
+ /* Can't do mipmapping inside dynamic branch constructs. Force LOD
+ * zero in that case.
+ */
+ if (emit->dynamic_branching_level > 0 &&
+ inst.op == SVGA3DOP_TEX &&
+ SVGA3dShaderGetRegType(texcoord.base.value) == SVGA3DREG_TEMP) {
+ struct src_register zero = get_zero_immediate( emit );
+
+ /* MOV tmp, texcoord */
+ if (!submit_op1( emit,
+ inst_token( SVGA3DOP_MOV ),
+ tmp,
+ texcoord ))
+ return FALSE;
+
+ /* MOV tmp.w, zero */
+ if (!submit_op1( emit,
+ inst_token( SVGA3DOP_MOV ),
+ writemask( tmp, TGSI_WRITEMASK_W ),
+ scalar( zero, TGSI_SWIZZLE_X )))
+ return FALSE;
+
+ texcoord = src( tmp );
+ inst.op = SVGA3DOP_TEXLDL;
+ }
+
+ /* Explicit normalization of texcoords:
+ */
+ if (emit->key.fkey.tex[sampler.base.num].unnormalized) {
+ struct src_register wh = get_tex_dimensions( emit, sampler.base.num );
/* MUL tmp, SRC0, WH */
if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ),
- tmp, src0, wh ))
+ tmp, texcoord, wh ))
return FALSE;
- src0 = src( tmp );
+
+ texcoord = src( tmp );
}
- return submit_op2( emit, inst, dst, src0, src1 );
+ return submit_op2( emit, inst, dst, texcoord, sampler );
}
@@ -1211,31 +1333,33 @@ static boolean emit_tex2(struct svga_shader_emitter *emit,
/* Translate texture instructions to SVGA3D representation.
*/
-static boolean emit_tex3(struct svga_shader_emitter *emit,
+static boolean emit_tex4(struct svga_shader_emitter *emit,
const struct tgsi_full_instruction *insn,
SVGA3dShaderDestToken dst )
{
SVGA3dShaderInstToken inst;
- struct src_register src0;
- struct src_register src1;
- struct src_register src2;
+ struct src_register texcoord;
+ struct src_register ddx;
+ struct src_register ddy;
+ struct src_register sampler;
+
+ texcoord = translate_src_register( emit, &insn->Src[0] );
+ ddx = translate_src_register( emit, &insn->Src[1] );
+ ddy = translate_src_register( emit, &insn->Src[2] );
+ sampler = translate_src_register( emit, &insn->Src[3] );
inst.value = 0;
switch (insn->Instruction.Opcode) {
case TGSI_OPCODE_TXD:
- inst.op = SVGA3DOP_TEXLDD;
- break;
- case TGSI_OPCODE_TXL:
- inst.op = SVGA3DOP_TEXLDL;
+ inst.op = SVGA3DOP_TEXLDD; /* 4 args! */
break;
+ default:
+ assert(0);
+ return FALSE;
}
- src0 = translate_src_register( emit, &insn->Src[0] );
- src1 = translate_src_register( emit, &insn->Src[1] );
- src2 = translate_src_register( emit, &insn->Src[2] );
-
- return submit_op3( emit, inst, dst, src0, src1, src2 );
+ return submit_op4( emit, inst, dst, texcoord, sampler, ddx, ddy );
}
@@ -1271,12 +1395,12 @@ static boolean emit_tex(struct svga_shader_emitter *emit,
case TGSI_OPCODE_TEX:
case TGSI_OPCODE_TXB:
case TGSI_OPCODE_TXP:
+ case TGSI_OPCODE_TXL:
if (!emit_tex2( emit, insn, tex_result ))
return FALSE;
break;
- case TGSI_OPCODE_TXL:
case TGSI_OPCODE_TXD:
- if (!emit_tex3( emit, insn, tex_result ))
+ if (!emit_tex4( emit, insn, tex_result ))
return FALSE;
break;
default:
@@ -1330,6 +1454,8 @@ static boolean emit_bgnloop2( struct svga_shader_emitter *emit,
struct src_register loop_reg = src_register( SVGA3DREG_LOOP, 0 );
struct src_register const_int = get_loop_const( emit );
+ emit->dynamic_branching_level++;
+
return (emit_instruction( emit, inst ) &&
emit_src( emit, loop_reg ) &&
emit_src( emit, const_int ) );
@@ -1339,6 +1465,9 @@ static boolean emit_endloop2( struct svga_shader_emitter *emit,
const struct tgsi_full_instruction *insn )
{
SVGA3dShaderInstToken inst = inst_token( SVGA3DOP_ENDLOOP );
+
+ emit->dynamic_branching_level--;
+
return emit_instruction( emit, inst );
}
@@ -1398,6 +1527,46 @@ static boolean emit_simple_instruction(struct svga_shader_emitter *emit,
}
}
+
+static boolean emit_deriv(struct svga_shader_emitter *emit,
+ const struct tgsi_full_instruction *insn )
+{
+ if (emit->dynamic_branching_level > 0 &&
+ insn->Src[0].Register.File == TGSI_FILE_TEMPORARY)
+ {
+ struct src_register zero = get_zero_immediate( emit );
+ SVGA3dShaderDestToken dst =
+ translate_dst_register( emit, insn, 0 );
+
+ /* Deriv opcodes not valid inside dynamic branching, workaround
+ * by zeroing out the destination.
+ */
+ if (!submit_op1(emit,
+ inst_token( SVGA3DOP_MOV ),
+ dst,
+ scalar(zero, TGSI_SWIZZLE_X)))
+ return FALSE;
+
+ return TRUE;
+ }
+ else {
+ unsigned opcode;
+
+ switch (insn->Instruction.Opcode) {
+ case TGSI_OPCODE_DDX:
+ opcode = SVGA3DOP_DSX;
+ break;
+ case TGSI_OPCODE_DDY:
+ opcode = SVGA3DOP_DSY;
+ break;
+ default:
+ return FALSE;
+ }
+
+ return emit_simple_instruction( emit, opcode, insn );
+ }
+}
+
static boolean emit_arl(struct svga_shader_emitter *emit,
const struct tgsi_full_instruction *insn)
{
@@ -2002,6 +2171,10 @@ static boolean svga_emit_instruction( struct svga_shader_emitter *emit,
case TGSI_OPCODE_TXD:
return emit_tex( emit, insn );
+ case TGSI_OPCODE_DDX:
+ case TGSI_OPCODE_DDY:
+ return emit_deriv( emit, insn );
+
case TGSI_OPCODE_BGNSUB:
return emit_bgnsub( emit, position, insn );
@@ -2254,11 +2427,28 @@ static boolean emit_ps_postamble( struct svga_shader_emitter *emit )
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
if (SVGA3dShaderGetRegType(emit->true_col[i].value) != 0) {
- if (!submit_op1( emit,
- inst_token(SVGA3DOP_MOV),
- emit->true_col[i],
- src(emit->temp_col[i]) ))
- return FALSE;
+ /* Potentially override output colors with white for XOR
+ * logicop workaround.
+ */
+ if (emit->unit == PIPE_SHADER_FRAGMENT &&
+ emit->key.fkey.white_fragments) {
+
+ struct src_register one = scalar( get_zero_immediate( emit ),
+ TGSI_SWIZZLE_W );
+
+ if (!submit_op1( emit,
+ inst_token(SVGA3DOP_MOV),
+ emit->true_col[i],
+ one ))
+ return FALSE;
+ }
+ else {
+ if (!submit_op1( emit,
+ inst_token(SVGA3DOP_MOV),
+ emit->true_col[i],
+ src(emit->temp_col[i]) ))
+ return FALSE;
+ }
}
}
@@ -2467,6 +2657,9 @@ needs_to_create_zero( struct svga_shader_emitter *emit )
if (emit->key.fkey.light_twoside)
return TRUE;
+ if (emit->key.fkey.white_fragments)
+ return TRUE;
+
if (emit->emit_frontface)
return TRUE;
@@ -2476,6 +2669,10 @@ needs_to_create_zero( struct svga_shader_emitter *emit )
}
if (emit->info.opcode_count[TGSI_OPCODE_IF] >= 1 ||
+ emit->info.opcode_count[TGSI_OPCODE_BGNLOOP] >= 1 ||
+ emit->info.opcode_count[TGSI_OPCODE_BGNFOR] >= 1 ||
+ emit->info.opcode_count[TGSI_OPCODE_DDX] >= 1 ||
+ emit->info.opcode_count[TGSI_OPCODE_DDY] >= 1 ||
emit->info.opcode_count[TGSI_OPCODE_SGE] >= 1 ||
emit->info.opcode_count[TGSI_OPCODE_SGT] >= 1 ||
emit->info.opcode_count[TGSI_OPCODE_SLE] >= 1 ||
@@ -2702,6 +2899,8 @@ boolean svga_shader_emit_instructions( struct svga_shader_emitter *emit,
goto done;
}
+ assert(emit->dynamic_branching_level == 0);
+
/* Need to terminate the whole shader:
*/
ret = emit_instruction( emit, inst_token( SVGA3DOP_END ) );
diff --git a/src/gallium/drivers/trace/tr_buffer.c b/src/gallium/drivers/trace/tr_buffer.c
index 4f0eff6a5a..fa2ac068eb 100644
--- a/src/gallium/drivers/trace/tr_buffer.c
+++ b/src/gallium/drivers/trace/tr_buffer.c
@@ -26,6 +26,7 @@
**************************************************************************/
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 0f45e211a3..8de451c22c 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -45,11 +45,11 @@
#endif
#include "pipe/p_compiler.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
+#include "os/os_stream.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_string.h"
-#include "util/u_stream.h"
#include "tr_dump.h"
#include "tr_screen.h"
@@ -57,7 +57,7 @@
#include "tr_buffer.h"
-static struct util_stream *stream = NULL;
+static struct os_stream *stream = NULL;
static unsigned refcount = 0;
static pipe_mutex call_mutex;
static long unsigned call_no = 0;
@@ -69,7 +69,7 @@ static INLINE void
trace_dump_write(const char *buf, size_t size)
{
if(stream)
- util_stream_write(stream, buf, size);
+ os_stream_write(stream, buf, size);
}
@@ -220,7 +220,7 @@ trace_dump_trace_close(void)
{
if(stream) {
trace_dump_writes("</trace>\n");
- util_stream_close(stream);
+ os_stream_close(stream);
stream = NULL;
refcount = 0;
call_no = 0;
@@ -250,7 +250,7 @@ boolean trace_dump_trace_begin()
if(!stream) {
- stream = util_stream_create(filename, 0);
+ stream = os_stream_create(filename, 0);
if(!stream)
return FALSE;
@@ -367,7 +367,7 @@ void trace_dump_call_end_locked(void)
trace_dump_indent(1);
trace_dump_tag_end("call");
trace_dump_newline();
- util_stream_flush(stream);
+ os_stream_flush(stream);
}
void trace_dump_call_begin(const char *klass, const char *method)
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index dbca5de0a5..c7364e2bd1 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -49,7 +49,7 @@ static void trace_dump_reference(const struct pipe_reference *reference)
return;
trace_dump_struct_begin("pipe_reference");
- trace_dump_member(int, &reference->count, count);
+ trace_dump_member(int, reference, count);
trace_dump_struct_end();
}
diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c
index 0546aad9b5..691b83c63f 100644
--- a/src/gallium/drivers/trace/tr_rbug.c
+++ b/src/gallium/drivers/trace/tr_rbug.c
@@ -26,11 +26,13 @@
**************************************************************************/
+#include "os/os_thread.h"
#include "util/u_format.h"
#include "util/u_string.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
#include "util/u_network.h"
+#include "util/u_time.h"
#include "tgsi/tgsi_parse.h"
@@ -43,15 +45,6 @@
#include <errno.h>
-#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-# define sleep Sleep
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_APPLE)
-void usleep(int);
-# define sleep usleep
-#else
-# warning "No socket implementation"
-#endif
-
#define U642VOID(x) ((void *)(unsigned long)(x))
#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
@@ -805,7 +798,7 @@ PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug)
debug_printf("trace_rbug - remote debugging listening on port %u\n", --port);
while(tr_rbug->running) {
- sleep(1);
+ util_time_sleep(1);
c = u_socket_accept(s);
if (c < 0)
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 117503aaff..6cdb4c04a8 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -35,7 +35,7 @@
#include "tr_texture.h"
#include "tr_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_format.h"
diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h
index dba8cd7c65..fe5a0fa190 100644
--- a/src/gallium/drivers/trace/tr_screen.h
+++ b/src/gallium/drivers/trace/tr_screen.h
@@ -30,7 +30,7 @@
#include "pipe/p_screen.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#ifdef __cplusplus
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
index 1f25fe38d4..5321d68ec0 100644
--- a/src/gallium/drivers/trace/tr_texture.c
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -25,6 +25,7 @@
*
**************************************************************************/
+#include "util/u_inlines.h"
#include "util/u_hash_table.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
diff --git a/src/gallium/include/pipe/internal/p_winsys_screen.h b/src/gallium/include/pipe/internal/p_winsys_screen.h
deleted file mode 100644
index a1542dada7..0000000000
--- a/src/gallium/include/pipe/internal/p_winsys_screen.h
+++ /dev/null
@@ -1,190 +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.
- *
- **************************************************************************/
-
-/**
- * \file
- * This is the interface that Gallium3D requires any window system
- * hosting it to implement. This is the only include file in Gallium3D
- * which is public.
- */
-
-#ifndef P_WINSYS_H
-#define P_WINSYS_H
-
-
-#include "pipe/p_format.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** Opaque type */
-struct pipe_fence_handle;
-
-struct pipe_surface;
-
-
-/**
- * Gallium3D drivers are (meant to be!) independent of both GL and the
- * window system. The window system provides a buffer manager and a
- * set of additional hooks for things like command buffer submission,
- * etc.
- *
- * There clearly has to be some agreement between the window system
- * driver and the hardware driver about the format of command buffers,
- * etc.
- */
-struct pipe_winsys
-{
- void (*destroy)( struct pipe_winsys *ws );
-
- /** Returns name of this winsys interface */
- const char *(*get_name)( struct pipe_winsys *ws );
-
- /**
- * Do any special operations to ensure buffer size is correct
- */
- void (*update_buffer)( struct pipe_winsys *ws,
- void *context_private );
- /**
- * Do any special operations to ensure frontbuffer contents are
- * displayed, eg copy fake frontbuffer.
- */
- void (*flush_frontbuffer)( struct pipe_winsys *ws,
- struct pipe_surface *surf,
- void *context_private );
-
-
- /**
- * Buffer management. Buffer attributes are mostly fixed over its lifetime.
- *
- * Remember that gallium gets to choose the interface it needs, and the
- * window systems must then implement that interface (rather than the
- * other way around...).
- *
- * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
- * usage argument is only an optimization hint, not a guarantee, therefore
- * proper behavior must be observed in all circumstances.
- *
- * alignment indicates the client's alignment requirements, eg for
- * SSE instructions.
- */
- struct pipe_buffer *(*buffer_create)( struct pipe_winsys *ws,
- unsigned alignment,
- unsigned usage,
- unsigned size );
-
- /**
- * Create a buffer that wraps user-space data.
- *
- * Effectively this schedules a delayed call to buffer_create
- * followed by an upload of the data at *some point in the future*,
- * or perhaps never. Basically the allocate/upload is delayed
- * until the buffer is actually passed to hardware.
- *
- * The intention is to provide a quick way to turn regular data
- * into a buffer, and secondly to avoid a copy operation if that
- * data subsequently turns out to be only accessed by the CPU.
- *
- * Common example is OpenGL vertex buffers that are subsequently
- * processed either by software TNL in the driver or by passing to
- * hardware.
- *
- * XXX: What happens if the delayed call to buffer_create() fails?
- *
- * Note that ptr may be accessed at any time upto the time when the
- * buffer is destroyed, so the data must not be freed before then.
- */
- struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *ws,
- void *ptr,
- unsigned bytes);
-
- /**
- * Allocate storage for a display target surface.
- *
- * Often surfaces which are meant to be blitted to the front screen (i.e.,
- * display targets) must be allocated with special characteristics, memory
- * pools, or obtained directly from the windowing system.
- *
- * This callback is invoked by the pipe_screenwhen creating a texture marked
- * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
- * buffer storage.
- */
- struct pipe_buffer *(*surface_buffer_create)(struct pipe_winsys *ws,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride);
-
-
- /**
- * Map the entire data store of a buffer object into the client's address.
- * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
- */
- void *(*buffer_map)( struct pipe_winsys *ws,
- struct pipe_buffer *buf,
- unsigned usage );
-
- void (*buffer_unmap)( struct pipe_winsys *ws,
- struct pipe_buffer *buf );
-
- void (*buffer_destroy)( struct pipe_buffer *buf );
-
-
- /** Set ptr = fence, with reference counting */
- void (*fence_reference)( struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence );
-
- /**
- * Checks whether the fence has been signalled.
- * \param flags driver-specific meaning
- * \return zero on success.
- */
- int (*fence_signalled)( struct pipe_winsys *ws,
- struct pipe_fence_handle *fence,
- unsigned flag );
-
- /**
- * Wait for the fence to finish.
- * \param flags driver-specific meaning
- * \return zero on success.
- */
- int (*fence_finish)( struct pipe_winsys *ws,
- struct pipe_fence_handle *fence,
- unsigned flag );
-
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* P_WINSYS_H */
diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h
deleted file mode 100644
index 0c3fbae428..0000000000
--- a/src/gallium/include/pipe/p_atomic.h
+++ /dev/null
@@ -1,353 +0,0 @@
-/**
- * Many similar implementations exist. See for example libwsbm
- * or the linux kernel include/atomic.h
- *
- * No copyright claimed on this file.
- *
- */
-
-#ifndef P_ATOMIC_H
-#define P_ATOMIC_H
-
-#include "p_compiler.h"
-#include "p_defines.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Favor OS-provided implementations.
- *
- * Where no OS-provided implementation is available, fall back to
- * locally coded assembly, compiler intrinsic or ultimately a
- * mutex-based implementation.
- */
-#if (defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \
- defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT))
-#define PIPE_ATOMIC_OS_UNLOCKED
-#elif (defined(PIPE_CC_MSVC) && defined(PIPE_SUBSYSTEM_WINDOWS_USER))
-#define PIPE_ATOMIC_OS_MS_INTERLOCK
-#elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86))
-#define PIPE_ATOMIC_ASM_MSVC_X86
-#elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86))
-#define PIPE_ATOMIC_ASM_GCC_X86
-#elif defined(PIPE_CC_GCC)
-#define PIPE_ATOMIC_GCC_INTRINSIC
-#else
-#define PIPE_ATOMIC_MUTEX
-#endif
-
-
-
-#if defined(PIPE_ATOMIC_ASM_GCC_X86)
-
-#define PIPE_ATOMIC "GCC x86 assembly"
-
-struct pipe_atomic {
- int32_t count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- unsigned char c;
-
- __asm__ __volatile__("lock; decl %0; sete %1":"+m"(v->count), "=qm"(c)
- ::"memory");
-
- return c != 0;
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- __asm__ __volatile__("lock; incl %0":"+m"(v->count));
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- __asm__ __volatile__("lock; decl %0":"+m"(v->count));
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- return __sync_val_compare_and_swap(&v->count, old, _new);
-}
-#endif
-
-
-
-/* Implementation using GCC-provided synchronization intrinsics
- */
-#if defined(PIPE_ATOMIC_GCC_INTRINSIC)
-
-#define PIPE_ATOMIC "GCC Sync Intrinsics"
-
-struct pipe_atomic {
- int32_t count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- return (__sync_sub_and_fetch(&v->count, 1) == 0);
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- (void) __sync_add_and_fetch(&v->count, 1);
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- (void) __sync_sub_and_fetch(&v->count, 1);
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- return __sync_val_compare_and_swap(&v->count, old, _new);
-}
-#endif
-
-
-
-/* Unlocked version for single threaded environments, such as some
- * windows kernel modules.
- */
-#if defined(PIPE_ATOMIC_OS_UNLOCKED)
-
-#define PIPE_ATOMIC "Unlocked"
-
-struct pipe_atomic
-{
- int32_t count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-#define p_atomic_dec_zero(_v) ((boolean) --(_v)->count)
-#define p_atomic_inc(_v) ((void) (_v)->count++)
-#define p_atomic_dec(_v) ((void) (_v)->count--)
-#define p_atomic_cmpxchg(_v, old, _new) ((_v)->count == old ? (_v)->count = (_new) : (_v)->count)
-
-#endif
-
-
-/* Locally coded assembly for MSVC on x86:
- */
-#if defined(PIPE_ATOMIC_ASM_MSVC_X86)
-
-#define PIPE_ATOMIC "MSVC x86 assembly"
-
-struct pipe_atomic
-{
- int32_t count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- int32_t *pcount = &v->count;
- unsigned char c;
-
- __asm {
- mov eax, [pcount]
- lock dec dword ptr [eax]
- sete byte ptr [c]
- }
-
- return c != 0;
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- int32_t *pcount = &v->count;
-
- __asm {
- mov eax, [pcount]
- lock inc dword ptr [eax]
- }
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- int32_t *pcount = &v->count;
-
- __asm {
- mov eax, [pcount]
- lock dec dword ptr [eax]
- }
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- int32_t *pcount = &v->count;
- int32_t orig;
-
- __asm {
- mov ecx, [pcount]
- mov eax, [old]
- mov edx, [_new]
- lock cmpxchg [ecx], edx
- mov [orig], eax
- }
-
- return orig;
-}
-#endif
-
-
-#if defined(PIPE_ATOMIC_OS_MS_INTERLOCK)
-
-#define PIPE_ATOMIC "MS userspace interlocks"
-
-#include <windows.h>
-
-struct pipe_atomic
-{
- volatile long count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- return InterlockedDecrement(&v->count) == 0;
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- InterlockedIncrement(&v->count);
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- InterlockedDecrement(&v->count);
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- return InterlockedCompareExchange(&v->count, _new, old);
-}
-
-#endif
-
-
-
-#if defined(PIPE_ATOMIC_MUTEX)
-
-#define PIPE_ATOMIC "mutex-based fallback"
-
-#include "pipe/p_thread.h"
-
-/**
- * This implementation should really not be used.
- * Add an assembly port instead. It may abort and
- * doesn't destroy used mutexes.
- */
-
-struct pipe_atomic {
- pipe_mutex mutex;
- int32_t count;
-};
-
-static INLINE void
-p_atomic_set(struct pipe_atomic *v, int32_t i)
-{
- pipe_mutex_init(v->mutex);
- pipe_mutex_lock(v->mutex);
- v->count = i;
- pipe_mutex_unlock(v->mutex);
-}
-
-static INLINE int32_t
-p_atomic_read(struct pipe_atomic *v)
-{
- int32_t ret;
-
- pipe_mutex_lock(v->mutex);
- ret = v->count;
- pipe_mutex_unlock(v->mutex);
- return ret;
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- pipe_mutex_lock(v->mutex);
- ++v->count;
- pipe_mutex_unlock(v->mutex);
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- pipe_mutex_lock(v->mutex);
- --v->count;
- pipe_mutex_unlock(v->mutex);
-}
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- boolean ret;
-
- pipe_mutex_lock(v->mutex);
- ret = (--v->count == 0);
- pipe_mutex_unlock(v->mutex);
- return ret;
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- int32_t ret;
-
- pipe_mutex_lock(v->mutex);
- ret = v->count;
- if (ret == old)
- v->count = _new;
- pipe_mutex_unlock(v->mutex);
-
- return ret;
-}
-
-#endif
-
-
-#ifndef PIPE_ATOMIC
-#error "No pipe_atomic implementation selected"
-#endif
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* P_ATOMIC_H */
diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h
index 6a9018aa3a..c7d3507494 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -38,6 +38,8 @@
#include "xf86_ansic.h"
#include "xf86_libc.h"
#endif
+#include <stddef.h>
+#include <stdarg.h>
#if defined(_WIN32) && !defined(__WIN32__)
@@ -125,6 +127,9 @@ typedef unsigned char boolean;
# define __FUNCTION__ "<unknown>"
# endif
# endif
+# if defined(_MSC_VER) && _MSC_VER < 1300
+# define __FUNCTION__ "<unknown>"
+# endif
#endif
@@ -140,6 +145,14 @@ typedef unsigned char boolean;
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+#define PIPE_DEPRECATED __attribute__((__deprecated__))
+#else
+#define PIPE_DEPRECATED
+#endif
+
+
+
/* Macros for data alignment. */
#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h
index 064605a4a0..c5928dde47 100644
--- a/src/gallium/include/pipe/p_config.h
+++ b/src/gallium/include/pipe/p_config.h
@@ -115,8 +115,10 @@
#endif
+#if !defined(PIPE_OS_EMBEDDED)
+
/*
- * Operating system family.
+ * Auto-detect the operating system family.
*
* See subsystem below for a more fine-grained distinction.
*/
@@ -164,7 +166,7 @@
#endif
/*
- * Subsystem.
+ * Try to auto-detect the subsystem.
*
* NOTE: There is no way to auto-detect most of these.
*/
@@ -191,5 +193,7 @@
#endif
#endif /* PIPE_OS_WINDOWS */
+#endif /* !PIPE_OS_EMBEDDED */
+
#endif /* P_CONFIG_H_ */
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index 6bfff1cc59..2894e13e7d 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -31,10 +31,6 @@
#include "p_compiler.h"
-/* FIXME: remove these header dependencies */
-#include "util/u_debug.h"
-#include "util/u_string.h"
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 03cd74efed..9ae096ee3c 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -43,7 +43,6 @@
#include "p_compiler.h"
#include "p_defines.h"
#include "p_format.h"
-#include "p_refcnt.h"
#include "p_screen.h"
@@ -66,6 +65,12 @@ extern "C" {
#define PIPE_MAX_TEXTURE_LEVELS 16
+struct pipe_reference
+{
+ int32_t count; /* atomic */
+};
+
+
/**
* The driver will certainly subclass this to include actual memory
* management information.
@@ -383,38 +388,6 @@ struct pipe_vertex_element
};
-/* Reference counting helper functions */
-static INLINE void
-pipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf)
-{
- struct pipe_buffer *old_buf = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &buf->reference))
- old_buf->screen->buffer_destroy(old_buf);
- *ptr = buf;
-}
-
-static INLINE void
-pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
-{
- struct pipe_surface *old_surf = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &surf->reference))
- old_surf->texture->screen->tex_surface_destroy(old_surf);
- *ptr = surf;
-}
-
-static INLINE void
-pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
-{
- struct pipe_texture *old_tex = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &tex->reference))
- old_tex->screen->texture_destroy(old_tex);
- *ptr = tex;
-}
-
-
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h
index b85f01c2b0..77e22d0a56 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -30,12 +30,12 @@
/* u_reduce_video_profile() needs these */
#include <pipe/p_compiler.h>
-#include <util/u_debug.h>
#include <pipe/p_defines.h>
#include <pipe/p_format.h>
-#include <pipe/p_refcnt.h>
+#include <pipe/p_state.h>
#include <pipe/p_screen.h>
+#include <util/u_inlines.h>
#ifdef __cplusplus
extern "C" {
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index 1f456cb829..f7ed6605bf 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -46,6 +46,7 @@
#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,
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index a412b81256..2052867309 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -42,6 +42,8 @@
#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)
@@ -194,7 +196,7 @@ dri_fill_in_modes(struct dri_screen *screen,
return NULL;
}
- return (const const __DRIconfig **)configs;
+ return (const __DRIconfig **)configs;
}
/**
diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile
index b696f2fae9..2863320a48 100644
--- a/src/gallium/state_trackers/egl/Makefile
+++ b/src/gallium/state_trackers/egl/Makefile
@@ -15,13 +15,11 @@ common_OBJECTS = $(common_SOURCES:.c=.o)
x11_INCLUDES = \
-I$(TOP)/src/gallium/drivers \
-I$(TOP)/src/glx/x11 \
- -I$(TOP)/src/egl/drivers/xdri \
-I$(TOP)/src/mesa \
$(shell pkg-config --cflags-only-I libdrm)
x11_SOURCES = $(wildcard x11/*.c) \
- $(TOP)/src/glx/x11/dri2.c \
- $(TOP)/src/egl/drivers/xdri/glxinit.c
+ $(TOP)/src/glx/x11/dri2.c
x11_OBJECTS = $(x11_SOURCES:.c=.o)
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 6c8f3b9f79..70216177bd 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -23,10 +23,12 @@
*/
#include <assert.h>
+#include <stdio.h>
#include <string.h>
#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
+#include "util/u_inlines.h"
#include "egldriver.h"
#include "eglcurrent.h"
#include "eglconfigutil.h"
@@ -468,7 +470,7 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id)
if (!gconf)
continue;
- _eglInitConfig(&gconf->base, id);
+ _eglInitConfig(&gconf->base, dpy, id);
api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask);
if (!api_mask) {
@@ -631,7 +633,7 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
return NULL;
}
- if (!_eglInitContext(drv, &gctx->base, conf, attribs)) {
+ if (!_eglInitContext(&gctx->base, dpy, conf, attribs)) {
free(gctx);
return NULL;
}
@@ -713,7 +715,7 @@ egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
- if (!_eglInitSurface(drv, &gsurf->base, EGL_WINDOW_BIT, conf, attribs)) {
+ if (!_eglInitSurface(&gsurf->base, dpy, EGL_WINDOW_BIT, conf, attribs)) {
free(gsurf);
return NULL;
}
@@ -753,7 +755,7 @@ egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
- if (!_eglInitSurface(drv, &gsurf->base, EGL_PIXMAP_BIT, conf, attribs)) {
+ if (!_eglInitSurface(&gsurf->base, dpy, EGL_PIXMAP_BIT, conf, attribs)) {
free(gsurf);
return NULL;
}
@@ -790,7 +792,7 @@ egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
- if (!_eglInitSurface(drv, &gsurf->base, EGL_PBUFFER_BIT, conf, attribs)) {
+ if (!_eglInitSurface(&gsurf->base, dpy, EGL_PBUFFER_BIT, conf, attribs)) {
free(gsurf);
return NULL;
}
@@ -1087,8 +1089,8 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLSurface *surf, EGLint buffer)
{
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
- _EGLContext *ctx = _eglGetAPIContext(EGL_OPENGL_ES_API);
- struct egl_g3d_context *gctx = egl_g3d_context(ctx);
+ _EGLContext *es1 = _eglGetAPIContext(EGL_OPENGL_ES_API);
+ struct egl_g3d_context *gctx;
enum pipe_format target_format;
int target;
@@ -1118,6 +1120,11 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,
return _eglError(EGL_BAD_MATCH, "eglBindTexImage");
}
+ if (!es1)
+ return EGL_TRUE;
+ if (!gsurf->render_surface)
+ return EGL_FALSE;
+
/* flush properly if the surface is bound */
if (gsurf->base.CurrentContext) {
gctx = egl_g3d_context(gsurf->base.CurrentContext);
@@ -1125,14 +1132,11 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy,
PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
}
- if (gctx) {
- if (!gsurf->render_surface)
- return EGL_FALSE;
+ gctx = egl_g3d_context(es1);
+ gctx->stapi->st_bind_texture_surface(gsurf->render_surface,
+ target, gsurf->base.MipmapLevel, target_format);
- gctx->stapi->st_bind_texture_surface(gsurf->render_surface,
- target, gsurf->base.MipmapLevel, target_format);
- gsurf->base.BoundToTexture = EGL_TRUE;
- }
+ gsurf->base.BoundToTexture = EGL_TRUE;
return EGL_TRUE;
}
@@ -1180,7 +1184,7 @@ egl_g3d_create_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
- if (!_eglInitSurface(drv, &gsurf->base,
+ if (!_eglInitSurface(&gsurf->base, dpy,
EGL_SCREEN_BIT_MESA, conf, attribs)) {
free(gsurf);
return NULL;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h
index 3dae8c4052..5d2d9c481a 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.h
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.h
@@ -87,41 +87,8 @@ struct egl_g3d_screen {
const struct native_mode **native_modes;
};
-static INLINE struct egl_g3d_driver *
-egl_g3d_driver(_EGLDriver *drv)
-{
- return (struct egl_g3d_driver *) drv;
-}
-
-static INLINE struct egl_g3d_display *
-egl_g3d_display(_EGLDisplay *dpy)
-{
- /* note that it is not direct casting */
- return (struct egl_g3d_display *) dpy->DriverData;
-}
-
-static INLINE struct egl_g3d_context *
-egl_g3d_context(_EGLContext *ctx)
-{
- return (struct egl_g3d_context *) ctx;
-}
-
-static INLINE struct egl_g3d_surface *
-egl_g3d_surface(_EGLSurface *surf)
-{
- return (struct egl_g3d_surface *) surf;
-}
-
-static INLINE struct egl_g3d_config *
-egl_g3d_config(_EGLConfig *conf)
-{
- return (struct egl_g3d_config *) conf;
-}
-
-static INLINE struct egl_g3d_screen *
-egl_g3d_screen(_EGLScreen *scr)
-{
- return (struct egl_g3d_screen *) scr;
-}
+/* standard typecasts */
+_EGL_DRIVER_STANDARD_TYPECASTS(egl_g3d)
+_EGL_DRIVER_TYPECAST(egl_g3d_screen, _EGLScreen, obj)
#endif /* _EGL_G3D_H_ */
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c
index d5baf2c2f0..445c28c383 100644
--- a/src/gallium/state_trackers/egl/kms/native_kms.c
+++ b/src/gallium/state_trackers/egl/kms/native_kms.c
@@ -22,12 +22,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <stdio.h>
#include <string.h>
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "egllog.h"
#include "native_kms.h"
diff --git a/src/gallium/state_trackers/egl/x11/glxinit.c b/src/gallium/state_trackers/egl/x11/glxinit.c
new file mode 100644
index 0000000000..ba6132788a
--- /dev/null
+++ b/src/gallium/state_trackers/egl/x11/glxinit.c
@@ -0,0 +1,682 @@
+/**
+ * GLX initialization. Code based on glxext.c, glx_query.c, and
+ * glcontextmodes.c under src/glx/x11/. The major difference is that DRI
+ * related code is stripped out.
+ *
+ * If the maintenance of this file takes too much time, we should consider
+ * refactoring glxext.c.
+ */
+
+#include <assert.h>
+#include <X11/Xlib.h>
+#include <X11/Xproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <sys/time.h>
+
+#include "glxinit.h"
+
+typedef struct GLXGenericGetString
+{
+ CARD8 reqType;
+ CARD8 glxCode;
+ CARD16 length B16;
+ CARD32 for_whom B32;
+ CARD32 name B32;
+} xGLXGenericGetStringReq;
+
+#define sz_xGLXGenericGetStringReq 12
+#define X_GLXGenericGetString 0
+
+/* Extension required boiler plate */
+
+static char *__glXExtensionName = GLX_EXTENSION_NAME;
+static XExtensionInfo *__glXExtensionInfo = NULL;
+
+static int
+__glXCloseDisplay(Display * dpy, XExtCodes * codes)
+{
+ return XextRemoveDisplay(__glXExtensionInfo, dpy);
+}
+
+static /* const */ XExtensionHooks __glXExtensionHooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ __glXCloseDisplay, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
+ __glXExtensionName, &__glXExtensionHooks,
+ __GLX_NUMBER_EVENTS, NULL)
+
+static GLint
+_gl_convert_from_x_visual_type(int visualType)
+{
+#define NUM_VISUAL_TYPES 6
+ static const int glx_visual_types[NUM_VISUAL_TYPES] = {
+ GLX_STATIC_GRAY, GLX_GRAY_SCALE,
+ GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
+ GLX_TRUE_COLOR, GLX_DIRECT_COLOR
+ };
+
+ return ((unsigned) visualType < NUM_VISUAL_TYPES)
+ ? glx_visual_types[visualType] : GLX_NONE;
+}
+
+static __GLcontextModes *
+_gl_context_modes_create(unsigned count, size_t minimum_size)
+{
+ const size_t size = (minimum_size > sizeof(__GLcontextModes))
+ ? minimum_size : sizeof(__GLcontextModes);
+ __GLcontextModes *base = NULL;
+ __GLcontextModes **next;
+ unsigned i;
+
+ next = &base;
+ for (i = 0; i < count; i++) {
+ *next = (__GLcontextModes *) Xmalloc(size);
+ if (*next == NULL) {
+ _gl_context_modes_destroy(base);
+ base = NULL;
+ break;
+ }
+
+ memset(*next, 0, size);
+ (*next)->visualID = GLX_DONT_CARE;
+ (*next)->visualType = GLX_DONT_CARE;
+ (*next)->visualRating = GLX_NONE;
+ (*next)->transparentPixel = GLX_NONE;
+ (*next)->transparentRed = GLX_DONT_CARE;
+ (*next)->transparentGreen = GLX_DONT_CARE;
+ (*next)->transparentBlue = GLX_DONT_CARE;
+ (*next)->transparentAlpha = GLX_DONT_CARE;
+ (*next)->transparentIndex = GLX_DONT_CARE;
+ (*next)->xRenderable = GLX_DONT_CARE;
+ (*next)->fbconfigID = GLX_DONT_CARE;
+ (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML;
+ (*next)->bindToTextureRgb = GLX_DONT_CARE;
+ (*next)->bindToTextureRgba = GLX_DONT_CARE;
+ (*next)->bindToMipmapTexture = GLX_DONT_CARE;
+ (*next)->bindToTextureTargets = GLX_DONT_CARE;
+ (*next)->yInverted = GLX_DONT_CARE;
+
+ next = &((*next)->next);
+ }
+
+ return base;
+}
+
+_X_HIDDEN void
+_gl_context_modes_destroy(__GLcontextModes * modes)
+{
+ while (modes != NULL) {
+ __GLcontextModes *const next = modes->next;
+
+ Xfree(modes);
+ modes = next;
+ }
+}
+
+_X_HIDDEN char *
+__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name)
+{
+ xGLXGenericGetStringReq *req;
+ xGLXSingleReply reply;
+ int length;
+ int numbytes;
+ char *buf;
+ CARD32 for_whom = screen;
+ CARD32 glxCode = X_GLXQueryServerString;
+
+
+ LockDisplay(dpy);
+
+
+ /* All of the GLX protocol requests for getting a string from the server
+ * look the same. The exact meaning of the for_whom field is usually
+ * either the screen number (for glXQueryServerString) or the context tag
+ * (for GLXSingle).
+ */
+
+ GetReq(GLXGenericGetString, req);
+ req->reqType = opcode;
+ req->glxCode = glxCode;
+ req->for_whom = for_whom;
+ req->name = name;
+
+ _XReply(dpy, (xReply *) & reply, 0, False);
+
+ length = reply.length * 4;
+ numbytes = reply.size;
+
+ buf = (char *) Xmalloc(numbytes);
+ if (buf != NULL) {
+ _XRead(dpy, buf, numbytes);
+ length -= numbytes;
+ }
+
+ _XEatData(dpy, length);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return buf;
+}
+
+/************************************************************************/
+/*
+** Free the per screen configs data as well as the array of
+** __glXScreenConfigs.
+*/
+static void
+FreeScreenConfigs(__GLXdisplayPrivate * priv)
+{
+ __GLXscreenConfigs *psc;
+ GLint i, screens;
+
+ /* Free screen configuration information */
+ psc = priv->screenConfigs;
+ screens = ScreenCount(priv->dpy);
+ for (i = 0; i < screens; i++, psc++) {
+ if (psc->configs) {
+ _gl_context_modes_destroy(psc->configs);
+ psc->configs = NULL; /* NOTE: just for paranoia */
+ }
+ if (psc->visuals) {
+ _gl_context_modes_destroy(psc->visuals);
+ psc->visuals = NULL; /* NOTE: just for paranoia */
+ }
+ Xfree((char *) psc->serverGLXexts);
+ }
+ XFree((char *) priv->screenConfigs);
+ priv->screenConfigs = NULL;
+}
+
+/*
+** Release the private memory referred to in a display private
+** structure. The caller will free the extension structure.
+*/
+static int
+__glXFreeDisplayPrivate(XExtData * extension)
+{
+ __GLXdisplayPrivate *priv;
+
+ priv = (__GLXdisplayPrivate *) extension->private_data;
+ FreeScreenConfigs(priv);
+ if (priv->serverGLXvendor) {
+ Xfree((char *) priv->serverGLXvendor);
+ priv->serverGLXvendor = 0x0; /* to protect against double free's */
+ }
+ if (priv->serverGLXversion) {
+ Xfree((char *) priv->serverGLXversion);
+ priv->serverGLXversion = 0x0; /* to protect against double free's */
+ }
+
+ Xfree((char *) priv);
+ return 0;
+}
+
+/************************************************************************/
+
+/*
+** Query the version of the GLX extension. This procedure works even if
+** the client extension is not completely set up.
+*/
+static Bool
+QueryVersion(Display * dpy, int opcode, int *major, int *minor)
+{
+ xGLXQueryVersionReq *req;
+ xGLXQueryVersionReply reply;
+
+ /* Send the glXQueryVersion request */
+ LockDisplay(dpy);
+ GetReq(GLXQueryVersion, req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXQueryVersion;
+ req->majorVersion = GLX_MAJOR_VERSION;
+ req->minorVersion = GLX_MINOR_VERSION;
+ _XReply(dpy, (xReply *) & reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (reply.majorVersion != GLX_MAJOR_VERSION) {
+ /*
+ ** The server does not support the same major release as this
+ ** client.
+ */
+ return GL_FALSE;
+ }
+ *major = reply.majorVersion;
+ *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
+ return GL_TRUE;
+}
+
+_X_HIDDEN void
+__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count,
+ const INT32 * bp, Bool tagged_only,
+ Bool fbconfig_style_tags)
+{
+ int i;
+
+ if (!tagged_only) {
+ /* Copy in the first set of properties */
+ config->visualID = *bp++;
+
+ config->visualType = _gl_convert_from_x_visual_type(*bp++);
+
+ config->rgbMode = *bp++;
+
+ config->redBits = *bp++;
+ config->greenBits = *bp++;
+ config->blueBits = *bp++;
+ config->alphaBits = *bp++;
+ config->accumRedBits = *bp++;
+ config->accumGreenBits = *bp++;
+ config->accumBlueBits = *bp++;
+ config->accumAlphaBits = *bp++;
+
+ config->doubleBufferMode = *bp++;
+ config->stereoMode = *bp++;
+
+ config->rgbBits = *bp++;
+ config->depthBits = *bp++;
+ config->stencilBits = *bp++;
+ config->numAuxBuffers = *bp++;
+ config->level = *bp++;
+
+ count -= __GLX_MIN_CONFIG_PROPS;
+ }
+
+ /*
+ ** Additional properties may be in a list at the end
+ ** of the reply. They are in pairs of property type
+ ** and property value.
+ */
+
+#define FETCH_OR_SET(tag) \
+ config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1
+
+ for (i = 0; i < count; i += 2) {
+ switch (*bp++) {
+ case GLX_RGBA:
+ FETCH_OR_SET(rgbMode);
+ break;
+ case GLX_BUFFER_SIZE:
+ config->rgbBits = *bp++;
+ break;
+ case GLX_LEVEL:
+ config->level = *bp++;
+ break;
+ case GLX_DOUBLEBUFFER:
+ FETCH_OR_SET(doubleBufferMode);
+ break;
+ case GLX_STEREO:
+ FETCH_OR_SET(stereoMode);
+ break;
+ case GLX_AUX_BUFFERS:
+ config->numAuxBuffers = *bp++;
+ break;
+ case GLX_RED_SIZE:
+ config->redBits = *bp++;
+ break;
+ case GLX_GREEN_SIZE:
+ config->greenBits = *bp++;
+ break;
+ case GLX_BLUE_SIZE:
+ config->blueBits = *bp++;
+ break;
+ case GLX_ALPHA_SIZE:
+ config->alphaBits = *bp++;
+ break;
+ case GLX_DEPTH_SIZE:
+ config->depthBits = *bp++;
+ break;
+ case GLX_STENCIL_SIZE:
+ config->stencilBits = *bp++;
+ break;
+ case GLX_ACCUM_RED_SIZE:
+ config->accumRedBits = *bp++;
+ break;
+ case GLX_ACCUM_GREEN_SIZE:
+ config->accumGreenBits = *bp++;
+ break;
+ case GLX_ACCUM_BLUE_SIZE:
+ config->accumBlueBits = *bp++;
+ break;
+ case GLX_ACCUM_ALPHA_SIZE:
+ config->accumAlphaBits = *bp++;
+ break;
+ case GLX_VISUAL_CAVEAT_EXT:
+ config->visualRating = *bp++;
+ break;
+ case GLX_X_VISUAL_TYPE:
+ config->visualType = *bp++;
+ break;
+ case GLX_TRANSPARENT_TYPE:
+ config->transparentPixel = *bp++;
+ break;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ config->transparentIndex = *bp++;
+ break;
+ case GLX_TRANSPARENT_RED_VALUE:
+ config->transparentRed = *bp++;
+ break;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ config->transparentGreen = *bp++;
+ break;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ config->transparentBlue = *bp++;
+ break;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ config->transparentAlpha = *bp++;
+ break;
+ case GLX_VISUAL_ID:
+ config->visualID = *bp++;
+ break;
+ case GLX_DRAWABLE_TYPE:
+ config->drawableType = *bp++;
+ break;
+ case GLX_RENDER_TYPE:
+ config->renderType = *bp++;
+ break;
+ case GLX_X_RENDERABLE:
+ config->xRenderable = *bp++;
+ break;
+ case GLX_FBCONFIG_ID:
+ config->fbconfigID = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_WIDTH:
+ config->maxPbufferWidth = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ config->maxPbufferHeight = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_PIXELS:
+ config->maxPbufferPixels = *bp++;
+ break;
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ config->optimalPbufferWidth = *bp++;
+ break;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ config->optimalPbufferHeight = *bp++;
+ break;
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ config->visualSelectGroup = *bp++;
+ break;
+ case GLX_SWAP_METHOD_OML:
+ config->swapMethod = *bp++;
+ break;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ config->sampleBuffers = *bp++;
+ break;
+ case GLX_SAMPLES_SGIS:
+ config->samples = *bp++;
+ break;
+ case GLX_BIND_TO_TEXTURE_RGB_EXT:
+ config->bindToTextureRgb = *bp++;
+ break;
+ case GLX_BIND_TO_TEXTURE_RGBA_EXT:
+ config->bindToTextureRgba = *bp++;
+ break;
+ case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
+ config->bindToMipmapTexture = *bp++;
+ break;
+ case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
+ config->bindToTextureTargets = *bp++;
+ break;
+ case GLX_Y_INVERTED_EXT:
+ config->yInverted = *bp++;
+ break;
+ case None:
+ i = count;
+ break;
+ default:
+ break;
+ }
+ }
+
+ config->renderType =
+ (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+
+ config->haveAccumBuffer = ((config->accumRedBits +
+ config->accumGreenBits +
+ config->accumBlueBits +
+ config->accumAlphaBits) > 0);
+ config->haveDepthBuffer = (config->depthBits > 0);
+ config->haveStencilBuffer = (config->stencilBits > 0);
+}
+
+static __GLcontextModes *
+createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
+ int screen, GLboolean tagged_only)
+{
+ INT32 buf[__GLX_TOTAL_CONFIG], *props;
+ unsigned prop_size;
+ __GLcontextModes *modes, *m;
+ int i;
+
+ if (nprops == 0)
+ return NULL;
+
+ /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */
+
+ /* Check number of properties */
+ if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
+ return NULL;
+
+ /* Allocate memory for our config structure */
+ modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
+ if (!modes)
+ return NULL;
+
+ prop_size = nprops * __GLX_SIZE_INT32;
+ if (prop_size <= sizeof(buf))
+ props = buf;
+ else
+ props = Xmalloc(prop_size);
+
+ /* Read each config structure and convert it into our format */
+ m = modes;
+ for (i = 0; i < nvisuals; i++) {
+ _XRead(dpy, (char *) props, prop_size);
+ /* Older X servers don't send this so we default it here. */
+ m->drawableType = GLX_WINDOW_BIT;
+ __glXInitializeVisualConfigFromTags(m, nprops, props,
+ tagged_only, GL_TRUE);
+ m->screen = screen;
+ m = m->next;
+ }
+
+ if (props != buf)
+ Xfree(props);
+
+ return modes;
+}
+
+static GLboolean
+getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
+{
+ xGLXGetVisualConfigsReq *req;
+ __GLXscreenConfigs *psc;
+ xGLXGetVisualConfigsReply reply;
+
+ LockDisplay(dpy);
+
+ psc = priv->screenConfigs + screen;
+ psc->visuals = NULL;
+ GetReq(GLXGetVisualConfigs, req);
+ req->reqType = priv->majorOpcode;
+ req->glxCode = X_GLXGetVisualConfigs;
+ req->screen = screen;
+
+ if (!_XReply(dpy, (xReply *) & reply, 0, False))
+ goto out;
+
+ psc->visuals = createConfigsFromProperties(dpy,
+ reply.numVisuals,
+ reply.numProps,
+ screen, GL_FALSE);
+
+ out:
+ UnlockDisplay(dpy);
+ return psc->visuals != NULL;
+}
+
+static GLboolean
+getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
+{
+ xGLXGetFBConfigsReq *fb_req;
+ xGLXGetFBConfigsSGIXReq *sgi_req;
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXGetFBConfigsReply reply;
+ __GLXscreenConfigs *psc;
+
+ psc = priv->screenConfigs + screen;
+ psc->serverGLXexts =
+ __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS);
+
+ LockDisplay(dpy);
+
+ psc->configs = NULL;
+ if (atof(priv->serverGLXversion) >= 1.3) {
+ GetReq(GLXGetFBConfigs, fb_req);
+ fb_req->reqType = priv->majorOpcode;
+ fb_req->glxCode = X_GLXGetFBConfigs;
+ fb_req->screen = screen;
+ }
+ else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXGetFBConfigsSGIXReq +
+ sz_xGLXVendorPrivateWithReplyReq, vpreq);
+ sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
+ sgi_req->reqType = priv->majorOpcode;
+ sgi_req->glxCode = X_GLXVendorPrivateWithReply;
+ sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
+ sgi_req->screen = screen;
+ }
+ else
+ goto out;
+
+ if (!_XReply(dpy, (xReply *) & reply, 0, False))
+ goto out;
+
+ psc->configs = createConfigsFromProperties(dpy,
+ reply.numFBConfigs,
+ reply.numAttribs * 2,
+ screen, GL_TRUE);
+
+ out:
+ UnlockDisplay(dpy);
+ return psc->configs != NULL;
+}
+
+static GLboolean
+AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
+{
+ __GLXscreenConfigs *psc;
+ GLint i, screens;
+
+ /*
+ ** First allocate memory for the array of per screen configs.
+ */
+ screens = ScreenCount(dpy);
+ psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs));
+ if (!psc) {
+ return GL_FALSE;
+ }
+ memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
+ priv->screenConfigs = psc;
+
+ priv->serverGLXversion =
+ __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
+ if (priv->serverGLXversion == NULL) {
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ for (i = 0; i < screens; i++, psc++) {
+ getFBConfigs(dpy, priv, i);
+ getVisualConfigs(dpy, priv, i);
+ psc->scr = i;
+ psc->dpy = dpy;
+ }
+
+ SyncHandle();
+
+ return GL_TRUE;
+}
+
+_X_HIDDEN __GLXdisplayPrivate *
+__glXInitialize(Display * dpy)
+{
+ XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ XExtData **privList, *private, *found;
+ __GLXdisplayPrivate *dpyPriv;
+ XEDataObject dataObj;
+ int major, minor;
+
+ if (!XextHasExtension(info))
+ return NULL;
+
+ /* See if a display private already exists. If so, return it */
+ dataObj.display = dpy;
+ privList = XEHeadOfExtensionList(dataObj);
+ found = XFindOnExtensionList(privList, info->codes->extension);
+ if (found)
+ return (__GLXdisplayPrivate *) found->private_data;
+
+ /* See if the versions are compatible */
+ if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor))
+ return NULL;
+
+ /*
+ ** Allocate memory for all the pieces needed for this buffer.
+ */
+ private = (XExtData *) Xmalloc(sizeof(XExtData));
+ if (!private)
+ return NULL;
+ dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate));
+ if (!dpyPriv) {
+ Xfree(private);
+ return NULL;
+ }
+
+ /*
+ ** Init the display private and then read in the screen config
+ ** structures from the server.
+ */
+ dpyPriv->majorOpcode = info->codes->major_opcode;
+ dpyPriv->majorVersion = major;
+ dpyPriv->minorVersion = minor;
+ dpyPriv->dpy = dpy;
+
+ dpyPriv->serverGLXvendor = NULL;
+ dpyPriv->serverGLXversion = NULL;
+
+ if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
+ Xfree(dpyPriv);
+ Xfree(private);
+ return NULL;
+ }
+
+ /*
+ ** Fill in the private structure. This is the actual structure that
+ ** hangs off of the Display structure. Our private structure is
+ ** referred to by this structure. Got that?
+ */
+ private->number = info->codes->extension;
+ private->next = 0;
+ private->free_private = __glXFreeDisplayPrivate;
+ private->private_data = (char *) dpyPriv;
+ XAddToExtensionList(privList, private);
+
+ return dpyPriv;
+}
diff --git a/src/gallium/state_trackers/egl/x11/glxinit.h b/src/gallium/state_trackers/egl/x11/glxinit.h
new file mode 100644
index 0000000000..1cc7c460fe
--- /dev/null
+++ b/src/gallium/state_trackers/egl/x11/glxinit.h
@@ -0,0 +1,11 @@
+#ifndef GLXINIT_INCLUDED
+#define GLXINIT_INCLUDED
+
+#include <X11/Xlib.h>
+#include "glxclient.h"
+
+/* this is used by DRI loaders */
+extern void
+_gl_context_modes_destroy(__GLcontextModes * modes);
+
+#endif /* GLXINIT_INCLUDED */
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 07f82d878c..b2eba7219f 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -25,6 +25,7 @@
#include "util/u_memory.h"
#include "util/u_math.h"
#include "util/u_format.h"
+#include "util/u_inlines.h"
#include "pipe/p_compiler.h"
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c
index dd3c9f8b6a..8eb542bd82 100644
--- a/src/gallium/state_trackers/egl/x11/native_x11.c
+++ b/src/gallium/state_trackers/egl/x11/native_x11.c
@@ -22,6 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <stdio.h>
#include <string.h>
#include "util/u_debug.h"
#include "util/u_memory.h"
diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c
index dfa8df2223..7946415ce7 100644
--- a/src/gallium/state_trackers/egl/x11/native_ximage.c
+++ b/src/gallium/state_trackers/egl/x11/native_ximage.c
@@ -33,7 +33,8 @@
#include "util/u_math.h"
#include "util/u_format.h"
#include "pipe/p_compiler.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
+#include "util/u_inlines.h"
#include "softpipe/sp_winsys.h"
#include "egllog.h"
diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.c b/src/gallium/state_trackers/egl/x11/sw_winsys.c
index 6ee3ede38c..33328aadf2 100644
--- a/src/gallium/state_trackers/egl/x11/sw_winsys.c
+++ b/src/gallium/state_trackers/egl/x11/sw_winsys.c
@@ -35,9 +35,9 @@
*/
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c
index 76ce45ee57..d72bfc99d3 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.c
@@ -43,7 +43,7 @@ struct x11_screen {
int number;
/*
- * This is used to fetch GLX visuals/fbconfigs. It uses code from egl_xdri.
+ * This is used to fetch GLX visuals/fbconfigs. It steals code from GLX.
* It might be better to rewrite the part in Xlib or XCB.
*/
__GLXdisplayPrivate *glx_dpy;
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h
index d24971ca1c..63a329cbe0 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
@@ -60,7 +60,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 "pipe/p_thread.h"
+#include "os/os_thread.h"
# include <X11/Xlib.h>
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index 6879722845..99e177b0be 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -40,9 +40,9 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "cso_cache/cso_context.h"
+#include "util/u_inlines.h"
#include "util/u_draw_quad.h"
#include "util/u_tile.h"
#include "util/u_math.h"
diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c
index e41125f6f9..467e20207a 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -29,7 +29,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "cso_cache/cso_context.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/state_trackers/python/st_llvmpipe_winsys.c b/src/gallium/state_trackers/python/st_llvmpipe_winsys.c
index 0096b18c99..c5ee1679f0 100644
--- a/src/gallium/state_trackers/python/st_llvmpipe_winsys.c
+++ b/src/gallium/state_trackers/python/st_llvmpipe_winsys.c
@@ -36,7 +36,7 @@
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "llvmpipe/lp_winsys.h"
diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c
index 9637741421..32a6551a87 100644
--- a/src/gallium/state_trackers/python/st_sample.c
+++ b/src/gallium/state_trackers/python/st_sample.c
@@ -29,7 +29,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_tile.h"
#include "util/u_math.h"
diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c
index cf4a11bb14..20c72c1ff5 100644
--- a/src/gallium/state_trackers/vega/api_filters.c
+++ b/src/gallium/state_trackers/vega/api_filters.c
@@ -34,7 +34,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#include "pipe/p_shader_tokens.h"
diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c
index c437553bc2..015241498e 100644
--- a/src/gallium/state_trackers/vega/api_images.c
+++ b/src/gallium/state_trackers/vega/api_images.c
@@ -35,7 +35,7 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_blit.h"
#include "util/u_tile.h"
#include "util/u_memory.h"
diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c
index e6070c7353..9c123a4cf9 100644
--- a/src/gallium/state_trackers/vega/api_masks.c
+++ b/src/gallium/state_trackers/vega/api_masks.c
@@ -31,7 +31,7 @@
#include "vg_context.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_pack_color.h"
#include "util/u_draw_quad.h"
diff --git a/src/gallium/state_trackers/vega/api_path.c b/src/gallium/state_trackers/vega/api_path.c
index 15ac1900f4..58ebb3b60e 100644
--- a/src/gallium/state_trackers/vega/api_path.c
+++ b/src/gallium/state_trackers/vega/api_path.c
@@ -32,7 +32,7 @@
#include "paint.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_draw_quad.h"
VGPath vgCreatePath(VGint pathFormat,
diff --git a/src/gallium/state_trackers/vega/asm_fill.h b/src/gallium/state_trackers/vega/asm_fill.h
index 2f394ad6c5..27773467fa 100644
--- a/src/gallium/state_trackers/vega/asm_fill.h
+++ b/src/gallium/state_trackers/vega/asm_fill.h
@@ -27,166 +27,375 @@
#ifndef ASM_FILL_H
#define ASM_FILL_H
-static const char solid_fill_asm[] =
- "MOV %s, CONST[0]\n";
-
-
-static const char linear_grad_asm[] =
- "MOV TEMP[0].xy, IN[0]\n"
- "MOV TEMP[0].z, CONST[1].yyyy\n"
- "DP3 TEMP[1], CONST[2], TEMP[0]\n"
- "DP3 TEMP[2], CONST[3], TEMP[0]\n"
- "DP3 TEMP[3], CONST[4], TEMP[0]\n"
- "RCP TEMP[3], TEMP[3]\n"
- "MUL TEMP[1], TEMP[1], TEMP[3]\n"
- "MUL TEMP[2], TEMP[2], TEMP[3]\n"
- "MOV TEMP[4].x, TEMP[1]\n"
- "MOV TEMP[4].y, TEMP[2]\n"
- "MUL TEMP[0], CONST[0].yyyy, TEMP[4].yyyy\n"
- "MAD TEMP[1], CONST[0].xxxx, TEMP[4].xxxx, TEMP[0]\n"
- "MUL TEMP[2], TEMP[1], CONST[0].zzzz\n"
- "TEX %s, TEMP[2], SAMP[0], 1D\n";
-
-static const char radial_grad_asm[] =
- "MOV TEMP[0].xy, IN[0]\n"
- "MOV TEMP[0].z, CONST[1].yyyy\n"
- "DP3 TEMP[1], CONST[2], TEMP[0]\n"
- "DP3 TEMP[2], CONST[3], TEMP[0]\n"
- "DP3 TEMP[3], CONST[4], TEMP[0]\n"
- "RCP TEMP[3], TEMP[3]\n"
- "MUL TEMP[1], TEMP[1], TEMP[3]\n"
- "MUL TEMP[2], TEMP[2], TEMP[3]\n"
- "MOV TEMP[5].x, TEMP[1]\n"
- "MOV TEMP[5].y, TEMP[2]\n"
- "MUL TEMP[0], CONST[0].yyyy, TEMP[5].yyyy\n"
- "MAD TEMP[1], CONST[0].xxxx, TEMP[5].xxxx, TEMP[0]\n"
- "ADD TEMP[1], TEMP[1], TEMP[1]\n"
- "MUL TEMP[3], TEMP[5].yyyy, TEMP[5].yyyy\n"
- "MAD TEMP[4], TEMP[5].xxxx, TEMP[5].xxxx, TEMP[3]\n"
- "MOV TEMP[4], -TEMP[4]\n"
- "MUL TEMP[2], CONST[0].zzzz, TEMP[4]\n"
- "MUL TEMP[0], CONST[1].wwww, TEMP[2]\n"
- "MUL TEMP[3], TEMP[1], TEMP[1]\n"
- "SUB TEMP[2], TEMP[3], TEMP[0]\n"
- "RSQ TEMP[2], |TEMP[2]|\n"
- "RCP TEMP[2], TEMP[2]\n"
- "SUB TEMP[1], TEMP[2], TEMP[1]\n"
- "ADD TEMP[0], CONST[0].zzzz, CONST[0].zzzz\n"
- "RCP TEMP[0], TEMP[0]\n"
- "MUL TEMP[2], TEMP[1], TEMP[0]\n"
- "TEX %s, TEMP[2], SAMP[0], 1D\n";
-
-static const char pattern_asm[] =
- "MOV TEMP[0].xy, IN[0]\n"
- "MOV TEMP[0].z, CONST[1].yyyy\n"
- "DP3 TEMP[1], CONST[2], TEMP[0]\n"
- "DP3 TEMP[2], CONST[3], TEMP[0]\n"
- "DP3 TEMP[3], CONST[4], TEMP[0]\n"
- "RCP TEMP[3], TEMP[3]\n"
- "MUL TEMP[1], TEMP[1], TEMP[3]\n"
- "MUL TEMP[2], TEMP[2], TEMP[3]\n"
- "MOV TEMP[4].x, TEMP[1]\n"
- "MOV TEMP[4].y, TEMP[2]\n"
- "RCP TEMP[0], CONST[1].zwzw\n"
- "MOV TEMP[1], TEMP[4]\n"
- "MUL TEMP[1].x, TEMP[1], TEMP[0]\n"
- "MUL TEMP[1].y, TEMP[1], TEMP[0]\n"
- "TEX %s, TEMP[1], SAMP[0], 2D\n";
-
-
-static const char mask_asm[] =
- "TEX TEMP[1], IN[0], SAMP[1], 2D\n"
- "MUL TEMP[0].w, TEMP[0].wwww, TEMP[1].wwww\n"
- "MOV %s, TEMP[0]\n";
-
-
-static const char image_normal_asm[] =
- "TEX %s, IN[1], SAMP[3], 2D\n";
-
-static const char image_multiply_asm[] =
- "TEX TEMP[1], IN[1], SAMP[3], 2D\n"
- "MUL %s, TEMP[0], TEMP[1]\n";
-
-static const char image_stencil_asm[] =
- "TEX TEMP[1], IN[1], SAMP[3], 2D\n"
- "MUL %s, TEMP[0], TEMP[1]\n";
-
-
-#define EXTENDED_BLEND_OVER \
- "SUB TEMP[3], CONST[1].yyyy, TEMP[1].wwww\n" \
- "SUB TEMP[4], CONST[1].yyyy, TEMP[0].wwww\n" \
- "MUL TEMP[3], TEMP[0], TEMP[3]\n" \
- "MUL TEMP[4], TEMP[1], TEMP[4]\n" \
- "ADD TEMP[3], TEMP[3], TEMP[4]\n"
-
-static const char blend_multiply_asm[] =
- "TEX TEMP[1], IN[0], SAMP[2], 2D\n"
- EXTENDED_BLEND_OVER
- "MUL TEMP[4], TEMP[0], TEMP[1]\n"
- "ADD TEMP[1], TEMP[4], TEMP[3]\n"/*result.rgb*/
- "MUL TEMP[2], TEMP[0].wwww, TEMP[1].wwww\n"
- "ADD TEMP[3], TEMP[0].wwww, TEMP[1].wwww\n"
- "SUB TEMP[1].w, TEMP[3], TEMP[2]\n"
- "MOV %s, TEMP[1]\n";
-#if 1
-static const char blend_screen_asm[] =
- "TEX TEMP[1], IN[0], SAMP[2], 2D\n"
- "ADD TEMP[3], TEMP[0], TEMP[1]\n"
- "MUL TEMP[2], TEMP[0], TEMP[1]\n"
- "SUB %s, TEMP[3], TEMP[2]\n";
-#else
-static const char blend_screen_asm[] =
- "TEX TEMP[1], IN[0], SAMP[2], 2D\n"
- "MOV %s, TEMP[1]\n";
-#endif
-
-static const char blend_darken_asm[] =
- "TEX TEMP[1], IN[0], SAMP[2], 2D\n"
- EXTENDED_BLEND_OVER
- "MUL TEMP[4], TEMP[0], TEMP[1].wwww\n"
- "MUL TEMP[5], TEMP[1], TEMP[0].wwww\n"
- "MIN TEMP[4], TEMP[4], TEMP[5]\n"
- "ADD TEMP[1], TEMP[3], TEMP[4]\n"
- "MUL TEMP[2], TEMP[0].wwww, TEMP[1].wwww\n"
- "ADD TEMP[3], TEMP[0].wwww, TEMP[1].wwww\n"
- "SUB TEMP[1].w, TEMP[3], TEMP[2]\n"
- "MOV %s, TEMP[1]\n";
-
-static const char blend_lighten_asm[] =
- "TEX TEMP[1], IN[0], SAMP[2], 2D\n"
- EXTENDED_BLEND_OVER
- "MUL TEMP[4], TEMP[0], TEMP[1].wwww\n"
- "MUL TEMP[5], TEMP[1], TEMP[0].wwww\n"
- "MAX TEMP[4], TEMP[4], TEMP[5]\n"
- "ADD TEMP[1], TEMP[3], TEMP[4]\n"
- "MUL TEMP[2], TEMP[0].wwww, TEMP[1].wwww\n"
- "ADD TEMP[3], TEMP[0].wwww, TEMP[1].wwww\n"
- "SUB TEMP[1].w, TEMP[3], TEMP[2]\n"
- "MOV %s, TEMP[1]\n";
-
-
-static const char premultiply_asm[] =
- "MUL TEMP[0].xyz, TEMP[0], TEMP[0].wwww\n";
-
-static const char unpremultiply_asm[] =
- "TEX TEMP[0], IN[0], SAMP[1], 2D\n";
-
-
-static const char color_bw_asm[] =
- "ADD TEMP[1], CONST[1].yyyy, CONST[1].yyyy\n"
- "RCP TEMP[2], TEMP[1]\n"
- "ADD TEMP[1], CONST[1].yyyy, TEMP[2]\n"
- "ADD TEMP[2].x, TEMP[0].xxxx, TEMP[0].yyyy\n"
- "ADD TEMP[2].x, TEMP[0].zzzz, TEMP[0].xxxx\n"
- "SGE TEMP[0].xyz, TEMP[2].xxxx, TEMP[1]\n"
- "SGE TEMP[0].w, TEMP[0].wwww, TEMP[2].yyyy\n"
- "MOV %s, TEMP[0]\n";
+#include "tgsi/tgsi_ureg.h"
+
+typedef void (* ureg_func)( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant);
+
+static INLINE void
+solid_fill( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_MOV(ureg, *out, constant[0]);
+}
+
+static INLINE void
+linear_grad( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+
+ ureg_MOV(ureg,
+ ureg_writemask(temp[0], TGSI_WRITEMASK_XY),
+ in[0]);
+ ureg_MOV(ureg,
+ ureg_writemask(temp[0], TGSI_WRITEMASK_Z),
+ ureg_scalar(constant[1], TGSI_SWIZZLE_Y));
+ ureg_DP3(ureg, temp[1], constant[2], ureg_src(temp[0]));
+ ureg_DP3(ureg, temp[2], constant[3], ureg_src(temp[0]));
+ ureg_DP3(ureg, temp[3], constant[4], ureg_src(temp[0]));
+ ureg_RCP(ureg, temp[3], ureg_src(temp[3]));
+ ureg_MUL(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[3]));
+ ureg_MUL(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[3]));
+ ureg_MOV(ureg, ureg_writemask(temp[4], TGSI_WRITEMASK_X), ureg_src(temp[1]));
+ ureg_MOV(ureg, ureg_writemask(temp[4], TGSI_WRITEMASK_Y), ureg_src(temp[2]));
+ ureg_MUL(ureg, temp[0],
+ ureg_scalar(constant[0], TGSI_SWIZZLE_Y),
+ ureg_scalar(ureg_src(temp[4]), TGSI_SWIZZLE_Y));
+ ureg_MAD(ureg, temp[1],
+ ureg_scalar(constant[0], TGSI_SWIZZLE_X),
+ ureg_scalar(ureg_src(temp[4]), TGSI_SWIZZLE_X),
+ ureg_src(temp[0]));
+ ureg_MUL(ureg, temp[2], ureg_src(temp[1]),
+ ureg_scalar(constant[0], TGSI_SWIZZLE_Z));
+ ureg_TEX(ureg, *out, TGSI_TEXTURE_1D, ureg_src(temp[2]), sampler[0]);
+}
+
+static INLINE void
+radial_grad( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+
+ ureg_MOV(ureg, ureg_writemask(temp[0], TGSI_WRITEMASK_XY), in[0]);
+ ureg_MOV(ureg,
+ ureg_writemask(temp[0], TGSI_WRITEMASK_Z),
+ ureg_scalar(constant[1], TGSI_SWIZZLE_Y));
+ ureg_DP3(ureg, temp[1], constant[2], ureg_src(temp[0]));
+ ureg_DP3(ureg, temp[2], constant[3], ureg_src(temp[0]));
+ ureg_DP3(ureg, temp[3], constant[4], ureg_src(temp[0]));
+ ureg_RCP(ureg, temp[3], ureg_src(temp[3]));
+ ureg_MUL(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[3]));
+ ureg_MUL(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[3]));
+ ureg_MOV(ureg, ureg_writemask(temp[5], TGSI_WRITEMASK_X), ureg_src(temp[1]));
+ ureg_MOV(ureg, ureg_writemask(temp[5], TGSI_WRITEMASK_Y), ureg_src(temp[2]));
+ ureg_MUL(ureg, temp[0], ureg_scalar(constant[0], TGSI_SWIZZLE_Y),
+ ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_Y));
+ ureg_MAD(ureg, temp[1],
+ ureg_scalar(constant[0], TGSI_SWIZZLE_X),
+ ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_X), ureg_src(temp[0]));
+ ureg_ADD(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[1]));
+ ureg_MUL(ureg, temp[3],
+ ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_Y),
+ ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_Y));
+ ureg_MAD(ureg, temp[4],
+ ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_X),
+ ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_X),
+ ureg_src(temp[3]));
+ ureg_MOV(ureg, temp[4], ureg_negate(ureg_src(temp[4])));
+ ureg_MUL(ureg, temp[2],
+ ureg_scalar(constant[0], TGSI_SWIZZLE_Z),
+ ureg_src(temp[4]));
+ ureg_MUL(ureg, temp[0],
+ ureg_scalar(constant[1], TGSI_SWIZZLE_W),
+ ureg_src(temp[2]));
+ ureg_MUL(ureg, temp[3], ureg_src(temp[1]), ureg_src(temp[1]));
+
+ ureg_SUB(ureg, temp[2], ureg_src(temp[3]), ureg_src(temp[0]));
+ ureg_RSQ(ureg, temp[2], ureg_abs(ureg_src(temp[2])));
+ ureg_RCP(ureg, temp[2], ureg_src(temp[2]));
+ ureg_SUB(ureg, temp[1], ureg_src(temp[2]), ureg_src(temp[1]));
+ ureg_ADD(ureg, temp[0],
+ ureg_scalar(constant[0], TGSI_SWIZZLE_Z),
+ ureg_scalar(constant[0], TGSI_SWIZZLE_Z));
+ ureg_RCP(ureg, temp[0], ureg_src(temp[0]));
+ ureg_MUL(ureg, temp[2], ureg_src(temp[1]), ureg_src(temp[0]));
+ ureg_TEX(ureg, *out, TGSI_TEXTURE_1D, ureg_src(temp[2]), sampler[0]);
+
+}
+
+
+static INLINE void
+pattern( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_MOV(ureg,
+ ureg_writemask(temp[0], TGSI_WRITEMASK_XY),
+ in[0]);
+ ureg_MOV(ureg,
+ ureg_writemask(temp[0], TGSI_WRITEMASK_Z),
+ ureg_scalar(constant[1], TGSI_SWIZZLE_Y));
+ ureg_DP3(ureg, temp[1], constant[2], ureg_src(temp[0]));
+ ureg_DP3(ureg, temp[2], constant[3], ureg_src(temp[0]));
+ ureg_DP3(ureg, temp[3], constant[4], ureg_src(temp[0]));
+ ureg_RCP(ureg, temp[3], ureg_src(temp[3]));
+ ureg_MUL(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[3]));
+ ureg_MUL(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[3]));
+ ureg_MOV(ureg, ureg_writemask(temp[4], TGSI_WRITEMASK_X), ureg_src(temp[1]));
+ ureg_MOV(ureg, ureg_writemask(temp[4], TGSI_WRITEMASK_Y), ureg_src(temp[2]));
+ ureg_RCP(ureg, temp[0],
+ ureg_swizzle(constant[1],
+ TGSI_SWIZZLE_Z,
+ TGSI_SWIZZLE_W,
+ TGSI_SWIZZLE_Z,
+ TGSI_SWIZZLE_W));
+ ureg_MOV(ureg, temp[1], ureg_src(temp[4]));
+ ureg_MUL(ureg,
+ ureg_writemask(temp[1], TGSI_WRITEMASK_X),
+ ureg_src(temp[1]),
+ ureg_src(temp[0]));
+ ureg_MUL(ureg,
+ ureg_writemask(temp[1], TGSI_WRITEMASK_Y),
+ ureg_src(temp[1]),
+ ureg_src(temp[0]));
+ ureg_TEX(ureg, *out, TGSI_TEXTURE_2D, ureg_src(temp[1]), sampler[0]);
+}
+
+static INLINE void
+mask( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[0], sampler[1]);
+ ureg_MUL(ureg, ureg_writemask(temp[0], TGSI_WRITEMASK_W),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_MOV(ureg, *out, ureg_src(temp[0]));
+}
+
+static INLINE void
+image_normal( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, *out, TGSI_TEXTURE_2D, in[1], sampler[3]);
+}
+
+
+static INLINE void
+image_multiply( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[1], sampler[3]);
+ ureg_MUL(ureg, *out, ureg_src(temp[0]), ureg_src(temp[1]));
+}
+
+
+static INLINE void
+image_stencil( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[1], sampler[3]);
+ ureg_MUL(ureg, *out, ureg_src(temp[0]), ureg_src(temp[1]));
+}
+
+#define EXTENDED_BLENDER_OVER_FUNC \
+ ureg_SUB(ureg, temp[3], \
+ ureg_scalar(constant[1], TGSI_SWIZZLE_Y), \
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W)); \
+ ureg_SUB(ureg, temp[3], \
+ ureg_scalar(constant[1], TGSI_SWIZZLE_Y), \
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W)); \
+ ureg_MUL(ureg, temp[3], ureg_src(temp[0]), ureg_src(temp[3])); \
+ ureg_MUL(ureg, temp[4], ureg_src(temp[1]), ureg_src(temp[4])); \
+ ureg_ADD(ureg, temp[3], ureg_src(temp[3]), ureg_src(temp[4]));
+
+
+static INLINE void
+blend_multiply( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[0], sampler[2]);
+ EXTENDED_BLENDER_OVER_FUNC
+ ureg_MUL(ureg, temp[4], ureg_src(temp[0]), ureg_src(temp[1]));
+ ureg_ADD(ureg, temp[1], ureg_src(temp[4]), ureg_src(temp[3]));
+
+ ureg_MUL(ureg, temp[2], ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_ADD(ureg, temp[3], ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_SUB(ureg, ureg_writemask(temp[1], TGSI_WRITEMASK_W),
+ ureg_src(temp[3]), ureg_src(temp[2]));
+
+ ureg_MOV(ureg, *out, ureg_src(temp[1]));
+}
+
+static INLINE void
+blend_screen( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[0], sampler[2]);
+ ureg_ADD(ureg, temp[3], ureg_src(temp[0]), ureg_src(temp[1]));
+ ureg_MUL(ureg, temp[2], ureg_src(temp[0]), ureg_src(temp[1]));
+ ureg_SUB(ureg, *out, ureg_src(temp[3]), ureg_src(temp[2]));
+}
+
+static INLINE void
+blend_darken( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[0], sampler[2]);
+ EXTENDED_BLENDER_OVER_FUNC
+ ureg_MUL(ureg, temp[4], ureg_src(temp[0]),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_MUL(ureg, temp[5], ureg_src(temp[1]),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W));
+ ureg_MIN(ureg, temp[4], ureg_src(temp[4]), ureg_src(temp[5]));
+ ureg_ADD(ureg, temp[1], ureg_src(temp[3]), ureg_src(temp[4]));
+
+ ureg_MUL(ureg, temp[2], ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_ADD(ureg, temp[3], ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_SUB(ureg, ureg_writemask(temp[1], TGSI_WRITEMASK_W),
+ ureg_src(temp[3]), ureg_src(temp[2]));
+
+ ureg_MOV(ureg, *out, ureg_src(temp[1]));
+}
+
+static INLINE void
+blend_lighten( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[0], sampler[2]);
+ EXTENDED_BLENDER_OVER_FUNC
+ ureg_MUL(ureg, temp[4], ureg_src(temp[0]),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_MUL(ureg, temp[5], ureg_src(temp[1]),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W));
+ ureg_MAX(ureg, temp[4], ureg_src(temp[4]), ureg_src(temp[5]));
+ ureg_ADD(ureg, temp[1], ureg_src(temp[3]), ureg_src(temp[4]));
+
+ ureg_MUL(ureg, temp[2], ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_ADD(ureg, temp[3], ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_SUB(ureg, ureg_writemask(temp[1], TGSI_WRITEMASK_W),
+ ureg_src(temp[3]), ureg_src(temp[2]));
+
+ ureg_MOV(ureg, *out, ureg_src(temp[1]));
+}
+
+static INLINE void
+premultiply( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_MUL(ureg,
+ ureg_writemask(temp[0], TGSI_WRITEMASK_XYZ),
+ ureg_src(temp[0]),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W));
+}
+
+static INLINE void
+unpremultiply( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_TEX(ureg, temp[0], TGSI_TEXTURE_2D, in[0], sampler[1]);
+}
+
+
+static INLINE void
+color_bw( struct ureg_program *ureg,
+ struct ureg_dst *out,
+ struct ureg_src *in,
+ struct ureg_src *sampler,
+ struct ureg_dst *temp,
+ struct ureg_src *constant)
+{
+ ureg_ADD(ureg, temp[1],
+ ureg_scalar(constant[1], TGSI_SWIZZLE_Y),
+ ureg_scalar(constant[1], TGSI_SWIZZLE_Y));
+ ureg_RCP(ureg, temp[2], ureg_src(temp[1]));
+ ureg_ADD(ureg, temp[1],
+ ureg_scalar(constant[1], TGSI_SWIZZLE_Y),
+ ureg_src(temp[2]));
+ ureg_ADD(ureg, ureg_writemask(temp[2], TGSI_WRITEMASK_X),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_X),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_Y));
+ ureg_ADD(ureg, ureg_writemask(temp[2], TGSI_WRITEMASK_X),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_Z),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_X));
+ ureg_SGE(ureg,
+ ureg_writemask(temp[0], TGSI_WRITEMASK_XYZ),
+ ureg_scalar(ureg_src(temp[2]), TGSI_SWIZZLE_X),
+ ureg_src(temp[1]));
+ ureg_SGE(ureg,
+ ureg_writemask(temp[0], TGSI_WRITEMASK_W),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[2]), TGSI_SWIZZLE_Y));
+ ureg_MOV(ureg, *out, ureg_src(temp[0]));
+}
struct shader_asm_info {
VGint id;
- VGint num_tokens;
- const char * txt;
+ ureg_func func;
VGboolean needs_position;
@@ -203,44 +412,44 @@ struct shader_asm_info {
static const struct shader_asm_info shaders_asm[] = {
/* fills */
- {VEGA_SOLID_FILL_SHADER, 40, solid_fill_asm,
+ {VEGA_SOLID_FILL_SHADER, solid_fill,
VG_FALSE, 0, 1, 0, 0, 0, 0},
- {VEGA_LINEAR_GRADIENT_SHADER, 200, linear_grad_asm,
+ {VEGA_LINEAR_GRADIENT_SHADER, linear_grad,
VG_TRUE, 0, 5, 0, 1, 0, 5},
- {VEGA_RADIAL_GRADIENT_SHADER, 200, radial_grad_asm,
+ {VEGA_RADIAL_GRADIENT_SHADER, radial_grad,
VG_TRUE, 0, 5, 0, 1, 0, 6},
- {VEGA_PATTERN_SHADER, 100, pattern_asm,
+ {VEGA_PATTERN_SHADER, pattern,
VG_TRUE, 1, 4, 0, 1, 0, 5},
/* image draw modes */
- {VEGA_IMAGE_NORMAL_SHADER, 200, image_normal_asm,
+ {VEGA_IMAGE_NORMAL_SHADER, image_normal,
VG_TRUE, 0, 0, 3, 1, 0, 0},
- {VEGA_IMAGE_MULTIPLY_SHADER, 200, image_multiply_asm,
+ {VEGA_IMAGE_MULTIPLY_SHADER, image_multiply,
VG_TRUE, 0, 0, 3, 1, 0, 2},
- {VEGA_IMAGE_STENCIL_SHADER, 200, image_stencil_asm,
+ {VEGA_IMAGE_STENCIL_SHADER, image_stencil,
VG_TRUE, 0, 0, 3, 1, 0, 2},
- {VEGA_MASK_SHADER, 100, mask_asm,
+ {VEGA_MASK_SHADER, mask,
VG_TRUE, 0, 0, 1, 1, 0, 2},
/* extra blend modes */
- {VEGA_BLEND_MULTIPLY_SHADER, 200, blend_multiply_asm,
+ {VEGA_BLEND_MULTIPLY_SHADER, blend_multiply,
VG_TRUE, 1, 1, 2, 1, 0, 5},
- {VEGA_BLEND_SCREEN_SHADER, 200, blend_screen_asm,
+ {VEGA_BLEND_SCREEN_SHADER, blend_screen,
VG_TRUE, 0, 0, 2, 1, 0, 4},
- {VEGA_BLEND_DARKEN_SHADER, 200, blend_darken_asm,
+ {VEGA_BLEND_DARKEN_SHADER, blend_darken,
VG_TRUE, 1, 1, 2, 1, 0, 6},
- {VEGA_BLEND_LIGHTEN_SHADER, 200, blend_lighten_asm,
+ {VEGA_BLEND_LIGHTEN_SHADER, blend_lighten,
VG_TRUE, 1, 1, 2, 1, 0, 6},
/* premultiply */
- {VEGA_PREMULTIPLY_SHADER, 100, premultiply_asm,
+ {VEGA_PREMULTIPLY_SHADER, premultiply,
VG_FALSE, 0, 0, 0, 0, 0, 1},
- {VEGA_UNPREMULTIPLY_SHADER, 100, unpremultiply_asm,
+ {VEGA_UNPREMULTIPLY_SHADER, unpremultiply,
VG_FALSE, 0, 0, 0, 0, 0, 1},
/* color transform to black and white */
- {VEGA_BW_SHADER, 150, color_bw_asm,
+ {VEGA_BW_SHADER, color_bw,
VG_FALSE, 1, 1, 0, 0, 0, 3},
};
#endif
diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c
index 1112ad9839..2e10965be4 100644
--- a/src/gallium/state_trackers/vega/image.c
+++ b/src/gallium/state_trackers/vega/image.c
@@ -37,7 +37,7 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_blit.h"
#include "util/u_format.h"
#include "util/u_tile.h"
diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c
index ba8ecef1d2..467b95b751 100644
--- a/src/gallium/state_trackers/vega/mask.c
+++ b/src/gallium/state_trackers/vega/mask.c
@@ -35,7 +35,7 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_memory.h"
diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c
index d8f6299b2d..3405d635f0 100644
--- a/src/gallium/state_trackers/vega/paint.c
+++ b/src/gallium/state_trackers/vega/paint.c
@@ -32,7 +32,7 @@
#include "st_inlines.h"
#include "pipe/p_compiler.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_memory.h"
diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c
index f5352ee84e..f56ea0c8b4 100644
--- a/src/gallium/state_trackers/vega/polygon.c
+++ b/src/gallium/state_trackers/vega/polygon.c
@@ -37,7 +37,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#include "util/u_draw_quad.h"
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index 47e18dc1e2..05620efa9c 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -30,7 +30,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#include "pipe/p_shader_tokens.h"
diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c
index 8e59d53dc7..0e71a507bf 100644
--- a/src/gallium/state_trackers/vega/shader.c
+++ b/src/gallium/state_trackers/vega/shader.c
@@ -35,7 +35,7 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#define MAX_CONSTANTS 20
diff --git a/src/gallium/state_trackers/vega/shaders_cache.c b/src/gallium/state_trackers/vega/shaders_cache.c
index f620075d0b..f43fe6ee4c 100644
--- a/src/gallium/state_trackers/vega/shaders_cache.c
+++ b/src/gallium/state_trackers/vega/shaders_cache.c
@@ -30,7 +30,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#include "pipe/p_shader_tokens.h"
@@ -123,17 +123,23 @@ static INLINE VGint range_max(VGint max, VGint current)
return MAX2(max, current);
}
-static void
-create_preamble(char *txt,
- const struct shader_asm_info *shaders[SHADER_STAGES],
- int num_shaders)
+static void *
+combine_shaders(const struct shader_asm_info *shaders[SHADER_STAGES], int num_shaders,
+ struct pipe_context *pipe,
+ struct pipe_shader_state *shader)
{
VGboolean declare_input = VG_FALSE;
VGint start_const = -1, end_const = 0;
VGint start_temp = -1, end_temp = 0;
VGint start_sampler = -1, end_sampler = 0;
- VGint i;
+ VGint i, current_shader = 0;
VGint num_consts, num_temps, num_samplers;
+ struct ureg_program *ureg;
+ struct ureg_src in[2];
+ struct ureg_src *sampler = NULL;
+ struct ureg_src *constant = NULL;
+ struct ureg_dst out, *temp = NULL;
+ void *p = NULL;
for (i = 0; i < num_shaders; ++i) {
if (shaders[i]->num_consts)
@@ -158,99 +164,94 @@ create_preamble(char *txt,
if (start_temp < 0)
start_temp = 0;
if (start_sampler < 0)
- start_sampler = 0;
+ start_sampler = 0;
num_consts = end_const - start_const;
num_temps = end_temp - start_temp;
num_samplers = end_sampler - start_sampler;
- /* end exclusive */
- --end_const;
- --end_temp;
- --end_sampler;
- sprintf(txt, "FRAG\n");
+ ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ if (!ureg)
+ return NULL;
if (declare_input) {
- sprintf(txt + strlen(txt), "DCL IN[0], POSITION, LINEAR\n");
- sprintf(txt + strlen(txt), "DCL IN[1], GENERIC[0], PERSPECTIVE\n");
+ in[0] = ureg_DECL_fs_input(ureg,
+ TGSI_SEMANTIC_POSITION,
+ 0,
+ TGSI_INTERPOLATE_LINEAR);
+ in[1] = ureg_DECL_fs_input(ureg,
+ TGSI_SEMANTIC_GENERIC,
+ 0,
+ TGSI_INTERPOLATE_PERSPECTIVE);
}
/* we always have a color output */
- sprintf(txt + strlen(txt), "DCL OUT[0], COLOR, CONSTANT\n");
-
- if (num_consts > 1)
- sprintf(txt + strlen(txt), "DCL CONST[%d..%d], CONSTANT\n", start_const, end_const);
- else if (num_consts == 1)
- sprintf(txt + strlen(txt), "DCL CONST[%d], CONSTANT\n", start_const);
-
- if (num_temps > 1)
- sprintf(txt + strlen(txt), "DCL TEMP[%d..%d], CONSTANT\n", start_temp, end_temp);
- else if (num_temps > 1)
- sprintf(txt + strlen(txt), "DCL TEMP[%d], CONSTANT\n", start_temp);
-
- if (num_samplers > 1)
- sprintf(txt + strlen(txt), "DCL SAMP[%d..%d], CONSTANT\n", start_sampler, end_sampler);
- else if (num_samplers == 1)
- sprintf(txt + strlen(txt), "DCL SAMP[%d], CONSTANT\n", start_sampler);
-}
+ out = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0);
-static void *
-combine_shaders(const struct shader_asm_info *shaders[SHADER_STAGES], int num_shaders,
- struct pipe_context *pipe,
- struct pipe_shader_state *shader)
-{
- char *combined_txt;
- int combined_len = MAX_PREAMBLE;
- int combined_tokens = 0;
- int i = 0;
- int current_shader = 0;
- int current_len;
+ if (num_consts >= 1) {
+ constant = (struct ureg_src *) malloc(sizeof(struct ureg_src) * end_const);
+ for (i = start_const; i < end_const; i++) {
+ constant[i] = ureg_DECL_constant(ureg, i);
+ }
- for (i = 0; i < num_shaders; ++i) {
- combined_len += strlen(shaders[i]->txt);
- combined_tokens += shaders[i]->num_tokens;
}
- /* add for the %s->TEMP[0] substitutions */
- combined_len += num_shaders * 7 /*TEMP[0]*/ + 4 /*"END\n"*/;
- combined_txt = (char*)malloc(combined_len);
- combined_txt[0] = '\0';
+ if (num_temps >= 1) {
+ temp = (struct ureg_dst *) malloc(sizeof(struct ureg_dst) * end_temp);
+ for (i = start_temp; i < end_temp; i++) {
+ temp[i] = ureg_DECL_temporary(ureg);
+ }
+ }
- create_preamble(combined_txt, shaders, num_shaders);
+ if (num_samplers >= 1) {
+ sampler = (struct ureg_src *) malloc(sizeof(struct ureg_src) * end_sampler);
+ for (i = start_sampler; i < end_sampler; i++) {
+ sampler[i] = ureg_DECL_sampler(ureg, i);
+ }
+ }
while (current_shader < num_shaders) {
- const char temp[] = "TEMP[0]";
- const char out[] = "OUT[0]";
- const char *subst = temp;
-
- current_len = strlen(combined_txt);
-
- /* if the last shader then output */
- if (current_shader + 1 == num_shaders)
- subst = out;
-
- snprintf(combined_txt + current_len,
- combined_len - current_len,
- shaders[current_shader]->txt,
- subst);
- ++current_shader;
+ if ((current_shader + 1) == num_shaders) {
+ shaders[current_shader]->func(ureg,
+ &out,
+ in,
+ sampler,
+ temp,
+ constant);
+ } else {
+ shaders[current_shader]->func(ureg,
+ &temp[0],
+ in,
+ sampler,
+ temp,
+ constant);
+ }
+ current_shader++;
}
+ ureg_END(ureg);
- current_len = strlen(combined_txt);
- snprintf(combined_txt + current_len,
- combined_len - current_len,
- "END\n");
+ shader->tokens = ureg_finalize(ureg);
+ if(!shader->tokens)
+ return NULL;
- debug_printf("Combined shader is : \n%s\n",
- combined_txt);
+ p = pipe->create_fs_state(pipe, shader);
+ ureg_destroy(ureg);
- shader->tokens = tokens_from_assembly(
- combined_txt, combined_tokens);
+ if (num_temps >= 1) {
+ for (i = start_temp; i < end_temp; i++) {
+ ureg_release_temporary(ureg, temp[i]);
+ }
+ }
- free(combined_txt);
+ if (temp)
+ free(temp);
+ if (constant)
+ free(constant);
+ if (sampler)
+ free(sampler);
- return pipe->create_fs_state(pipe, shader);
+ return p;
}
static void *
diff --git a/src/gallium/state_trackers/vega/st_inlines.h b/src/gallium/state_trackers/vega/st_inlines.h
index 610755e063..419151c3ae 100644
--- a/src/gallium/state_trackers/vega/st_inlines.h
+++ b/src/gallium/state_trackers/vega/st_inlines.h
@@ -38,7 +38,7 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_state.h"
static INLINE struct pipe_transfer *
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c
index 64207d97ba..426bf9bc62 100644
--- a/src/gallium/state_trackers/vega/vg_context.c
+++ b/src/gallium/state_trackers/vega/vg_context.c
@@ -34,7 +34,7 @@
#include "st_inlines.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "cso_cache/cso_context.h"
diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c
index 617c174eb6..a94dfb160c 100644
--- a/src/gallium/state_trackers/vega/vg_tracker.c
+++ b/src/gallium/state_trackers/vega/vg_tracker.c
@@ -29,7 +29,7 @@
#include "mask.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#include "util/u_format.h"
#include "util/u_memory.h"
diff --git a/src/gallium/state_trackers/wgl/stw_device.h b/src/gallium/state_trackers/wgl/stw_device.h
index 0bf3b0da82..a83841f6b7 100644
--- a/src/gallium/state_trackers/wgl/stw_device.h
+++ b/src/gallium/state_trackers/wgl/stw_device.h
@@ -30,7 +30,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
#include "util/u_handle_table.h"
#include "stw_icd.h"
#include "stw_pixelformat.h"
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.h b/src/gallium/state_trackers/wgl/stw_framebuffer.h
index b80d168a7c..08cc4973bc 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.h
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.h
@@ -32,7 +32,7 @@
#include "main/mtypes.h"
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
struct pipe_surface;
struct stw_pixelformat_info;
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index 2395d54975..221ce772af 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -49,7 +49,7 @@
#include <X11/extensions/dpms.h>
#endif
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_rect.h"
#ifdef HAVE_LIBKMS
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index 59588f0ff7..7457fe1c6d 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -38,7 +38,7 @@
#include "dri2.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index a3c3993ab8..83b0d31e38 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -9,7 +9,7 @@
#include "util/u_memory.h"
#include "util/u_rect.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include <math.h>
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index a88b1d520d..58bb60a721 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -47,6 +47,8 @@
#endif
#include "pipe/p_screen.h"
+#include "util/u_inlines.h"
+#include "util/u_debug.h"
#include "state_tracker/drm_api.h"
#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
index a4a72b372d..07be1df87f 100644
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
+++ b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
@@ -1,6 +1,7 @@
#include "i965_drm_winsys.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "i915_drm.h"
#include "intel_bufmgr.h"
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
index 8c8176e44a..118afc3395 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include "state_tracker/drm_api.h"
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c b/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
index e8b58742ab..102faedfea 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
@@ -1,7 +1,8 @@
#include "intel_drm_winsys.h"
#include "util/u_memory.h"
-#include "pipe/p_refcnt.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.
diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile
index 0937f68c34..7e95f79d03 100644
--- a/src/gallium/winsys/drm/nouveau/dri/Makefile
+++ b/src/gallium/winsys/drm/nouveau/dri/Makefile
@@ -6,9 +6,6 @@ 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/nv04/libnv04.a \
- $(TOP)/src/gallium/drivers/nv10/libnv10.a \
- $(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
index 75cd1e2902..3f41e5d0ce 100644
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
@@ -81,15 +81,6 @@ nouveau_drm_create_screen(struct drm_api *api, int fd,
return NULL;
switch (dev->chipset & 0xf0) {
- case 0x00:
- init = nv04_screen_create;
- break;
- case 0x10:
- init = nv10_screen_create;
- break;
- case 0x20:
- init = nv20_screen_create;
- break;
case 0x30:
init = nv30_screen_create;
break;
@@ -160,15 +151,6 @@ nouveau_drm_create_context(struct drm_api *api, struct pipe_screen *pscreen)
int i;
switch (chipset & 0xf0) {
- case 0x00:
- init = nv04_create;
- break;
- case 0x10:
- init = nv10_create;
- break;
- case 0x20:
- init = nv20_create;
- break;
case 0x30:
init = nv30_create;
break;
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
index e61e0e0957..a32f2907b3 100644
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
@@ -4,7 +4,7 @@
#include "state_tracker/drm_api.h"
#include "state_tracker/dri1_api.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "nouveau_dri.h"
diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile
index 8e812acc86..2c35260332 100644
--- a/src/gallium/winsys/drm/nouveau/egl/Makefile
+++ b/src/gallium/winsys/drm/nouveau/egl/Makefile
@@ -7,9 +7,6 @@ EGL_DRIVER_LIBS = -ldrm_nouveau
EGL_DRIVER_PIPES = \
$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
- $(TOP)/src/gallium/drivers/nv04/libnv04.a \
- $(TOP)/src/gallium/drivers/nv10/libnv10.a \
- $(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
diff --git a/src/gallium/winsys/drm/nouveau/xorg/Makefile b/src/gallium/winsys/drm/nouveau/xorg/Makefile
index f0d3b337e8..179b50230b 100644
--- a/src/gallium/winsys/drm/nouveau/xorg/Makefile
+++ b/src/gallium/winsys/drm/nouveau/xorg/Makefile
@@ -18,9 +18,6 @@ INCLUDES = \
LIBS = \
$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
- $(TOP)/src/gallium/drivers/nv04/libnv04.a \
- $(TOP)/src/gallium/drivers/nv10/libnv10.a \
- $(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
index de71cb2f42..f1c8fc2a3b 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
@@ -32,9 +32,9 @@
#include <stdio.h>
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "pipebuffer/pb_buffer.h"
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
index 864082b99b..4901080ca7 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
@@ -30,7 +30,7 @@
#ifndef RADEON_WINSYS_H
#define RADEON_WINSYS_H
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
struct radeon_winsys_priv;
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c b/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
index b812fb59d3..eca174a6c5 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
@@ -41,7 +41,7 @@
#include "svga_cmd.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "pipebuffer/pb_buffer.h"
#include "pipebuffer/pb_bufmgr.h"
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h b/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
index 634bdcabd2..41fb4476da 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
+++ b/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
@@ -27,7 +27,7 @@
#ifndef VMW_BUFFER_H_
#define VMW_BUFFER_H_
-
+#include <assert.h>
#include "pipe/p_compiler.h"
struct SVGAGuestPtr;
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
index d9abde3079..2939c10918 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
@@ -25,8 +25,9 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_inlines.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"
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
index d7d008859b..2b4e80f003 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
+++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
@@ -36,7 +36,7 @@
#include "svga_cmd.h"
#include "svga3d_caps.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipebuffer/pb_buffer.h"
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.h b/src/gallium/winsys/drm/vmware/core/vmw_surface.h
index 340cc1532e..3d61595c28 100644
--- a/src/gallium/winsys/drm/vmware/core/vmw_surface.h
+++ b/src/gallium/winsys/drm/vmware/core/vmw_surface.h
@@ -36,8 +36,8 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_atomic.h"
-#include "pipe/p_refcnt.h"
+#include "util/u_atomic.h"
+#include "util/u_inlines.h"
#define VMW_MAX_PRESENTS 3
@@ -45,7 +45,7 @@
struct vmw_svga_winsys_surface
{
- struct pipe_atomic validated;
+ int32_t validated; /* atomic */
struct pipe_reference refcnt;
struct vmw_winsys_screen *screen;
diff --git a/src/gallium/winsys/g3dvl/nouveau/Makefile b/src/gallium/winsys/g3dvl/nouveau/Makefile
index 3965bd949f..f07a7926d6 100644
--- a/src/gallium/winsys/g3dvl/nouveau/Makefile
+++ b/src/gallium/winsys/g3dvl/nouveau/Makefile
@@ -20,14 +20,11 @@ LDFLAGS += -L${DRMDIR}/lib \
-L${DRIDIR}/lib \
-L${GALLIUMDIR}/winsys/drm/nouveau/common \
-L${GALLIUMDIR}/auxiliary \
- -L${GALLIUMDIR}/drivers/nv04 \
- -L${GALLIUMDIR}/drivers/nv10 \
- -L${GALLIUMDIR}/drivers/nv20 \
-L${GALLIUMDIR}/drivers/nv30 \
-L${GALLIUMDIR}/drivers/nv40 \
-L${GALLIUMDIR}/drivers/nv50
-LIBS += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv04 -lnv10 -lnv20 -lnv30 -lnv40 -lnv50 -lgallium -lm
+LIBS += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv30 -lnv40 -lnv50 -lgallium -lm
#############################################
diff --git a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
index f15bcd37b5..048af62ed3 100644
--- a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
+++ b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
@@ -27,9 +27,9 @@
#include <vl_winsys.h>
#include <X11/Xutil.h>
-#include <pipe/internal/p_winsys_screen.h>
+#include <util/u_simple_screen.h>
#include <pipe/p_state.h>
-#include <pipe/p_inlines.h>
+#include <util/u_inlines.h>
#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
index 7d076be3a3..33c83210eb 100644
--- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
@@ -38,7 +38,7 @@
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
index 2ad794c3f0..36bf867f19 100644
--- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
@@ -38,10 +38,10 @@
#include <windows.h>
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/winsys/xlib/xlib_brw_context.c b/src/gallium/winsys/xlib/xlib_brw_context.c
index fc9addd09e..22bf41a46f 100644
--- a/src/gallium/winsys/xlib/xlib_brw_context.c
+++ b/src/gallium/winsys/xlib/xlib_brw_context.c
@@ -36,8 +36,8 @@
/* #include "glxheader.h" */
/* #include "xmesaP.h" */
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
+#include "util/u_simple_screen.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "i965simple/brw_winsys.h"
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
index 47ae0519a4..9520bac69d 100644
--- a/src/gallium/winsys/xlib/xlib_cell.c
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -41,10 +41,10 @@
#undef ASSERT
#undef Elements
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c
index 2a434b5fd2..503addb55c 100644
--- a/src/gallium/winsys/xlib/xlib_llvmpipe.c
+++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c
@@ -40,10 +40,10 @@
#undef ASSERT
#undef Elements
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index bf78aca686..8ce1ea7936 100644
--- a/src/gallium/winsys/xlib/xlib_softpipe.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -38,10 +38,10 @@
#undef ASSERT
#undef Elements
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"