summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/Makefile20
-rw-r--r--src/gallium/Makefile.template74
-rw-r--r--src/gallium/auxiliary/Makefile14
-rw-r--r--src/gallium/auxiliary/cso_cache/Makefile3
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_cache.c2
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c1
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_hash.c2
-rw-r--r--src/gallium/auxiliary/draw/Makefile4
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c17
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aapoint.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c20
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_vbuf.c95
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.h4
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_emit.c67
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_emit.c69
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c107
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c23
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_post_vs.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_vbuf.h16
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos.c55
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos.h2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos_io.c4
-rw-r--r--src/gallium/auxiliary/gallivm/storagesoa.cpp2
-rw-r--r--src/gallium/auxiliary/indices/Makefile8
-rw-r--r--src/gallium/auxiliary/indices/SConscript9
-rw-r--r--src/gallium/auxiliary/indices/u_indices.h23
-rw-r--r--src/gallium/auxiliary/indices/u_indices_gen.c2
-rw-r--r--src/gallium/auxiliary/indices/u_indices_gen.py2
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_gen.c1152
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_gen.py247
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_indices.c186
-rw-r--r--src/gallium/auxiliary/pipebuffer/Makefile3
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h28
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c143
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h9
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h5
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c13
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c26
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c6
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c18
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c10
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_validate.c2
-rw-r--r--src/gallium/auxiliary/rtasm/Makefile3
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_cpu.c2
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_execmem.c12
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_ppc.c2
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_x86sse.c2
-rw-r--r--src/gallium/auxiliary/sct/Makefile3
-rw-r--r--src/gallium/auxiliary/sct/sct.c3
-rw-r--r--src/gallium/auxiliary/tgsi/Makefile3
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt1036
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c10
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump_c.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c326
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_iterate.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.c17
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ppc.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sanity.c32
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_scan.c9
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sse2.c3
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_transform.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_util.c2
-rw-r--r--src/gallium/auxiliary/translate/Makefile3
-rw-r--r--src/gallium/auxiliary/util/Makefile5
-rw-r--r--src/gallium/auxiliary/util/SConscript8
-rw-r--r--src/gallium/auxiliary/util/u_bitmask.c320
-rw-r--r--src/gallium/auxiliary/util/u_bitmask.h114
-rw-r--r--src/gallium/auxiliary/util/u_blit.c75
-rw-r--r--src/gallium/auxiliary/util/u_cache.c2
-rw-r--r--src/gallium/auxiliary/util/u_debug.c (renamed from src/gallium/auxiliary/util/p_debug.c)68
-rw-r--r--src/gallium/auxiliary/util/u_debug.h (renamed from src/gallium/include/pipe/p_debug.h)10
-rw-r--r--src/gallium/auxiliary/util/u_debug_memory.c (renamed from src/gallium/auxiliary/util/p_debug_mem.c)15
-rw-r--r--src/gallium/auxiliary/util/u_debug_profile.c (renamed from src/gallium/auxiliary/util/p_debug_prof.c)2
-rw-r--r--src/gallium/auxiliary/util/u_debug_stack.c97
-rw-r--r--src/gallium/auxiliary/util/u_debug_stack.h (renamed from src/gallium/state_trackers/wgl/stw.c)64
-rw-r--r--src/gallium/auxiliary/util/u_draw_quad.c4
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c290
-rw-r--r--src/gallium/auxiliary/util/u_handle_table.c2
-rw-r--r--src/gallium/auxiliary/util/u_hash_table.c2
-rw-r--r--src/gallium/auxiliary/util/u_keymap.c2
-rw-r--r--src/gallium/auxiliary/util/u_linear.c2
-rw-r--r--src/gallium/auxiliary/util/u_math.h2
-rw-r--r--src/gallium/auxiliary/util/u_memory.h14
-rw-r--r--src/gallium/auxiliary/util/u_mm.c2
-rw-r--r--src/gallium/auxiliary/util/u_rect.c112
-rw-r--r--src/gallium/auxiliary/util/u_simple_screen.c28
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c74
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.h9
-rw-r--r--src/gallium/auxiliary/util/u_stream_stdc.c2
-rw-r--r--src/gallium/auxiliary/util/u_tile.c153
-rw-r--r--src/gallium/auxiliary/util/u_tile.h30
-rw-r--r--src/gallium/auxiliary/util/u_time.c12
-rw-r--r--src/gallium/auxiliary/util/u_time.h6
-rw-r--r--src/gallium/auxiliary/util/u_timed_winsys.c7
-rw-r--r--src/gallium/drivers/Makefile16
-rw-r--r--src/gallium/drivers/cell/ppu/cell_clear.c6
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.h3
-rw-r--r--src/gallium/drivers/cell/ppu/cell_fence.c18
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c95
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_emit.c18
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_shader.c4
-rw-r--r--src/gallium/drivers/cell/ppu/cell_surface.c14
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c377
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.h28
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vbuf.c33
-rw-r--r--src/gallium/drivers/cell/spu/Makefile5
-rw-r--r--src/gallium/drivers/cell/spu/spu_tri.c179
-rw-r--r--src/gallium/drivers/cell/spu/spu_util.c2
-rw-r--r--src/gallium/drivers/failover/Makefile3
-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/i915simple/Makefile3
-rw-r--r--src/gallium/drivers/i915simple/i915_debug.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc_translate.c11
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_vbuf.c59
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c83
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.h21
-rw-r--r--src/gallium/drivers/i915simple/i915_state_emit.c8
-rw-r--r--src/gallium/drivers/i915simple/i915_state_sampler.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_surface.c80
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c92
-rw-r--r--src/gallium/drivers/i915simple/i915_winsys.h42
-rw-r--r--src/gallium/drivers/i965simple/Makefile2
-rw-r--r--src/gallium/drivers/i965simple/brw_eu_debug.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_surface.c13
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.c38
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_surface_state.c2
-rw-r--r--src/gallium/drivers/nouveau/nouveau_stateobj.h14
-rw-r--r--src/gallium/drivers/nouveau/nouveau_winsys.h7
-rw-r--r--src/gallium/drivers/nv04/Makefile12
-rw-r--r--src/gallium/drivers/nv04/nv04_miptree.c78
-rw-r--r--src/gallium/drivers/nv04/nv04_prim_vbuf.c24
-rw-r--r--src/gallium/drivers/nv04/nv04_screen.c26
-rw-r--r--src/gallium/drivers/nv04/nv04_screen.h3
-rw-r--r--src/gallium/drivers/nv04/nv04_state.h3
-rw-r--r--src/gallium/drivers/nv04/nv04_state_emit.c17
-rw-r--r--src/gallium/drivers/nv04/nv04_surface.c11
-rw-r--r--src/gallium/drivers/nv04/nv04_surface_2d.c61
-rw-r--r--src/gallium/drivers/nv04/nv04_surface_2d.h5
-rw-r--r--src/gallium/drivers/nv04/nv04_transfer.c196
-rw-r--r--src/gallium/drivers/nv10/Makefile12
-rw-r--r--src/gallium/drivers/nv10/nv10_miptree.c74
-rw-r--r--src/gallium/drivers/nv10/nv10_prim_vbuf.c44
-rw-r--r--src/gallium/drivers/nv10/nv10_screen.c28
-rw-r--r--src/gallium/drivers/nv10/nv10_screen.h4
-rw-r--r--src/gallium/drivers/nv10/nv10_state_emit.c14
-rw-r--r--src/gallium/drivers/nv10/nv10_surface.c11
-rw-r--r--src/gallium/drivers/nv10/nv10_transfer.c196
-rw-r--r--src/gallium/drivers/nv20/Makefile12
-rw-r--r--src/gallium/drivers/nv20/nv20_miptree.c113
-rw-r--r--src/gallium/drivers/nv20/nv20_prim_vbuf.c66
-rw-r--r--src/gallium/drivers/nv20/nv20_screen.c28
-rw-r--r--src/gallium/drivers/nv20/nv20_screen.h4
-rw-r--r--src/gallium/drivers/nv20/nv20_state_emit.c14
-rw-r--r--src/gallium/drivers/nv20/nv20_surface.c11
-rw-r--r--src/gallium/drivers/nv20/nv20_transfer.c196
-rw-r--r--src/gallium/drivers/nv30/Makefile12
-rw-r--r--src/gallium/drivers/nv30/nv30_fragprog.c4
-rw-r--r--src/gallium/drivers/nv30/nv30_fragtex.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_miptree.c89
-rw-r--r--src/gallium/drivers/nv30/nv30_screen.c80
-rw-r--r--src/gallium/drivers/nv30/nv30_screen.h3
-rw-r--r--src/gallium/drivers/nv30/nv30_state.c3
-rw-r--r--src/gallium/drivers/nv30/nv30_state.h3
-rw-r--r--src/gallium/drivers/nv30/nv30_state_blend.c1
-rw-r--r--src/gallium/drivers/nv30/nv30_state_fb.c29
-rw-r--r--src/gallium/drivers/nv30/nv30_state_scissor.c1
-rw-r--r--src/gallium/drivers/nv30/nv30_state_stipple.c1
-rw-r--r--src/gallium/drivers/nv30/nv30_state_viewport.c4
-rw-r--r--src/gallium/drivers/nv30/nv30_surface.c11
-rw-r--r--src/gallium/drivers/nv30/nv30_transfer.c196
-rw-r--r--src/gallium/drivers/nv30/nv30_vbo.c3
-rw-r--r--src/gallium/drivers/nv30/nv30_vertprog.c1
-rw-r--r--src/gallium/drivers/nv40/Makefile12
-rw-r--r--src/gallium/drivers/nv40/nv40_fragprog.c4
-rw-r--r--src/gallium/drivers/nv40/nv40_fragtex.c1
-rw-r--r--src/gallium/drivers/nv40/nv40_miptree.c78
-rw-r--r--src/gallium/drivers/nv40/nv40_screen.c83
-rw-r--r--src/gallium/drivers/nv40/nv40_screen.h3
-rw-r--r--src/gallium/drivers/nv40/nv40_state.c3
-rw-r--r--src/gallium/drivers/nv40/nv40_state.h3
-rw-r--r--src/gallium/drivers/nv40/nv40_state_blend.c1
-rw-r--r--src/gallium/drivers/nv40/nv40_state_fb.c41
-rw-r--r--src/gallium/drivers/nv40/nv40_state_scissor.c1
-rw-r--r--src/gallium/drivers/nv40/nv40_state_viewport.c4
-rw-r--r--src/gallium/drivers/nv40/nv40_surface.c11
-rw-r--r--src/gallium/drivers/nv40/nv40_transfer.c196
-rw-r--r--src/gallium/drivers/nv40/nv40_vbo.c3
-rw-r--r--src/gallium/drivers/nv40/nv40_vertprog.c1
-rw-r--r--src/gallium/drivers/nv50/Makefile12
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h8
-rw-r--r--src/gallium/drivers/nv50/nv50_miptree.c160
-rw-r--r--src/gallium/drivers/nv50/nv50_program.c8
-rw-r--r--src/gallium/drivers/nv50/nv50_query.c11
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.c87
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.h3
-rw-r--r--src/gallium/drivers/nv50/nv50_state.c3
-rw-r--r--src/gallium/drivers/nv50/nv50_state_validate.c8
-rw-r--r--src/gallium/drivers/nv50/nv50_surface.c38
-rw-r--r--src/gallium/drivers/nv50/nv50_tex.c10
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c211
-rw-r--r--src/gallium/drivers/nv50/nv50_vbo.c4
-rw-r--r--src/gallium/drivers/r300/Makefile6
-rw-r--r--src/gallium/drivers/r300/r300_chipset.c15
-rw-r--r--src/gallium/drivers/r300/r300_chipset.h1
-rw-r--r--src/gallium/drivers/r300/r300_context.c88
-rw-r--r--src/gallium/drivers/r300/r300_context.h137
-rw-r--r--src/gallium/drivers/r300/r300_cs.h30
-rw-r--r--src/gallium/drivers/r300/r300_cs_inlines.h19
-rw-r--r--src/gallium/drivers/r300/r300_debug.c218
-rw-r--r--src/gallium/drivers/r300/r300_debug.h31
-rw-r--r--src/gallium/drivers/r300/r300_emit.c346
-rw-r--r--src/gallium/drivers/r300/r300_emit.h27
-rw-r--r--src/gallium/drivers/r300/r300_flush.c1
-rw-r--r--src/gallium/drivers/r300/r300_query.c111
-rw-r--r--src/gallium/drivers/r300/r300_query.h44
-rw-r--r--src/gallium/drivers/r300/r300_reg.h248
-rw-r--r--src/gallium/drivers/r300/r300_screen.c138
-rw-r--r--src/gallium/drivers/r300/r300_screen.h18
-rw-r--r--src/gallium/drivers/r300/r300_state.c414
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.c299
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.h34
-rw-r--r--src/gallium/drivers/r300/r300_state_inlines.h384
-rw-r--r--src/gallium/drivers/r300/r300_state_invariant.c203
-rw-r--r--src/gallium/drivers/r300/r300_state_invariant.h33
-rw-r--r--src/gallium/drivers/r300/r300_state_shader.c553
-rw-r--r--src/gallium/drivers/r300/r300_state_shader.h133
-rw-r--r--src/gallium/drivers/r300/r300_surface.c433
-rw-r--r--src/gallium/drivers/r300/r300_surface.h36
-rw-r--r--src/gallium/drivers/r300/r300_swtcl_emit.c324
-rw-r--r--src/gallium/drivers/r300/r300_texture.c115
-rw-r--r--src/gallium/drivers/r300/r300_texture.h9
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h15
-rw-r--r--src/gallium/drivers/softpipe/Makefile5
-rw-r--r--src/gallium/drivers/softpipe/SConscript2
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c16
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h31
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_flush.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_exec.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_llvm.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_sse.c5
-rw-r--r--src/gallium/drivers/softpipe/sp_headers.h95
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_vbuf.c78
-rw-r--r--src/gallium/drivers/softpipe/sp_quad.h81
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_alpha_test.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_blend.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_bufloop.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_colormask.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_coverage.c9
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_depth_test.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_earlyz.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_occlusion.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_output.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_pipe.c (renamed from src/gallium/drivers/softpipe/sp_quad.c)0
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_pipe.h74
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_stencil.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_stipple.c27
-rw-r--r--src/gallium/drivers/softpipe/sp_query.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_setup.c38
-rw-r--r--src/gallium/drivers/softpipe/sp_state.h6
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c31
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_state_surface.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_surface.c13
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c174
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.h15
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c183
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.h4
-rw-r--r--src/gallium/drivers/trace/Makefile8
-rw-r--r--src/gallium/drivers/trace/SConscript4
-rw-r--r--src/gallium/drivers/trace/tr_buffer.c70
-rw-r--r--src/gallium/drivers/trace/tr_buffer.h (renamed from src/gallium/winsys/drm/intel/dri/intel_reg.h)51
-rw-r--r--src/gallium/drivers/trace/tr_context.c210
-rw-r--r--src/gallium/drivers/trace/tr_context.h6
-rw-r--r--src/gallium/drivers/trace/tr_dump.c117
-rw-r--r--src/gallium/drivers/trace/tr_dump.h13
-rw-r--r--src/gallium/drivers/trace/tr_screen.c777
-rw-r--r--src/gallium/drivers/trace/tr_screen.h17
-rw-r--r--src/gallium/drivers/trace/tr_state.c76
-rw-r--r--src/gallium/drivers/trace/tr_state.h2
-rw-r--r--src/gallium/drivers/trace/tr_texture.c80
-rw-r--r--src/gallium/drivers/trace/tr_texture.h42
-rw-r--r--src/gallium/drivers/trace/tr_winsys.c450
-rw-r--r--src/gallium/include/pipe/internal/p_winsys_screen.h8
-rw-r--r--src/gallium/include/pipe/p_atomic.h382
-rw-r--r--src/gallium/include/pipe/p_config.h8
-rw-r--r--src/gallium/include/pipe/p_context.h1
-rw-r--r--src/gallium/include/pipe/p_defines.h12
-rw-r--r--src/gallium/include/pipe/p_format.h3
-rw-r--r--src/gallium/include/pipe/p_inlines.h175
-rw-r--r--src/gallium/include/pipe/p_refcnt.h (renamed from src/gallium/drivers/trace/tr_winsys.h)84
-rw-r--r--src/gallium/include/pipe/p_screen.h60
-rw-r--r--src/gallium/include/pipe/p_shader_tokens.h6
-rw-r--r--src/gallium/include/pipe/p_state.h85
-rw-r--r--src/gallium/include/pipe/p_thread.h32
-rw-r--r--src/gallium/include/state_tracker/drm_api.h24
-rw-r--r--src/gallium/state_trackers/dri2/Makefile28
-rw-r--r--src/gallium/state_trackers/dri2/dri_context.c (renamed from src/gallium/state_trackers/glx/dri/dri_context.c)64
-rw-r--r--src/gallium/state_trackers/dri2/dri_context.h (renamed from src/gallium/state_trackers/glx/dri/dri_context.h)41
-rw-r--r--src/gallium/state_trackers/dri2/dri_drawable.c325
-rw-r--r--src/gallium/state_trackers/dri2/dri_drawable.h (renamed from src/gallium/state_trackers/glx/dri/dri_drawable.h)36
-rw-r--r--src/gallium/state_trackers/dri2/dri_extensions.c (renamed from src/gallium/state_trackers/glx/dri/dri_extensions.c)27
-rw-r--r--src/gallium/state_trackers/dri2/dri_screen.c (renamed from src/gallium/state_trackers/glx/dri/dri_screen.c)231
-rw-r--r--src/gallium/state_trackers/dri2/dri_screen.h (renamed from src/gallium/state_trackers/glx/dri/dri_screen.h)53
-rw-r--r--src/gallium/state_trackers/egl/Makefile6
-rw-r--r--src/gallium/state_trackers/egl/egl_context.c2
-rw-r--r--src/gallium/state_trackers/egl/egl_surface.c14
-rw-r--r--src/gallium/state_trackers/egl/egl_tracker.c4
-rw-r--r--src/gallium/state_trackers/egl/egl_tracker.h2
-rw-r--r--src/gallium/state_trackers/g3dvl/Makefile2
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_basic_csc.c10
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_context.c4
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c24
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_drawable.c363
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_lock.c90
-rw-r--r--src/gallium/state_trackers/glx/xlib/Makefile18
-rw-r--r--src/gallium/state_trackers/glx/xlib/SConscript5
-rw-r--r--src/gallium/state_trackers/glx/xlib/glxapi.c10
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c35
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.h1
-rw-r--r--src/gallium/state_trackers/python/gallium.i16
-rw-r--r--src/gallium/state_trackers/python/p_context.i10
-rw-r--r--src/gallium/state_trackers/python/p_state.i1
-rw-r--r--src/gallium/state_trackers/python/p_texture.i50
-rwxr-xr-xsrc/gallium/state_trackers/python/retrace/interpreter.py84
-rw-r--r--src/gallium/state_trackers/python/samples/tri.py14
-rw-r--r--src/gallium/state_trackers/python/st_device.c56
-rw-r--r--src/gallium/state_trackers/python/st_device.h6
-rw-r--r--src/gallium/state_trackers/python/st_sample.c49
-rw-r--r--src/gallium/state_trackers/python/st_softpipe_winsys.c4
-rw-r--r--src/gallium/state_trackers/wgl/SConscript5
-rw-r--r--src/gallium/state_trackers/wgl/icd/stw_icd.c253
-rw-r--r--src/gallium/state_trackers/wgl/opengl32.mingw.def387
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c213
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.h11
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_device.c69
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_device.h25
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.c49
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.c14
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_public.h27
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_quirks.c3
-rw-r--r--src/gallium/state_trackers/wgl/wgl/stw_wgl.c32
-rw-r--r--src/gallium/state_trackers/wgl/wgl/stw_wgl.h2
-rw-r--r--src/gallium/state_trackers/xorg/Makefile29
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c314
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c212
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c695
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c528
-rw-r--r--src/gallium/state_trackers/xorg/xorg_output.c296
-rw-r--r--src/gallium/state_trackers/xorg/xorg_tracker.h130
-rw-r--r--src/gallium/state_trackers/xorg/xorg_winsys.h (renamed from src/gallium/state_trackers/wgl/stw.h)44
-rw-r--r--src/gallium/winsys/Makefile18
-rw-r--r--src/gallium/winsys/drm/Makefile32
-rw-r--r--src/gallium/winsys/drm/Makefile.template19
-rw-r--r--src/gallium/winsys/drm/intel/Makefile21
-rw-r--r--src/gallium/winsys/drm/intel/common/Makefile23
-rw-r--r--src/gallium/winsys/drm/intel/common/Makefile.template64
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c429
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h69
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_context.c107
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_context.h40
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_device.c296
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_device.h72
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c949
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h138
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h102
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c268
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c377
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h115
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c161
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c968
-rw-r--r--src/gallium/winsys/drm/intel/dri/Makefile33
-rw-r--r--src/gallium/winsys/drm/intel/dri/SConscript41
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h24
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_context.c337
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_context.h164
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_lock.c102
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_screen.c703
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_screen.h122
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c260
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h47
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c82
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h39
-rw-r--r--src/gallium/winsys/drm/intel/dri/server/i830_common.h255
-rw-r--r--src/gallium/winsys/drm/intel/dri/server/i830_dri.h62
-rw-r--r--src/gallium/winsys/drm/intel/dri2/Makefile22
-rw-r--r--src/gallium/winsys/drm/intel/egl/Makefile13
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_api.c10
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_api.h14
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_context.c83
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_device.c48
-rw-r--r--src/gallium/winsys/drm/intel/gem/Makefile12
-rw-r--r--src/gallium/winsys/drm/intel/gem/Makefile.template64
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_api.c15
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_api.h14
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c7
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_context.c44
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_context.h17
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_device.c111
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_device.h32
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_fence.h18
-rw-r--r--src/gallium/winsys/drm/intel/xorg/Makefile43
-rw-r--r--src/gallium/winsys/drm/intel/xorg/intel_xorg.c156
-rw-r--r--src/gallium/winsys/drm/nouveau/Makefile21
-rw-r--r--src/gallium/winsys/drm/nouveau/common/Makefile22
-rw-r--r--src/gallium/winsys/drm/nouveau/common/Makefile.template59
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_context.c206
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_context.h59
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_local.h19
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_screen.c31
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_screen.h27
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c242
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.h44
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_winsys_softpipe.c101
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/Makefile10
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_context.c (renamed from src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.c)62
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_context.h (renamed from src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.h)14
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h (renamed from src/gallium/winsys/drm/nouveau/common/nouveau_dri.h)0
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c (renamed from src/gallium/winsys/drm/nouveau/common/nouveau_lock.c)5
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c (renamed from src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.c)94
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h (renamed from src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.h)9
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c32
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h11
-rw-r--r--src/gallium/winsys/drm/nouveau/dri2/Makefile26
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/Makefile13
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c194
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h5
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c (renamed from src/gallium/winsys/drm/nouveau/common/nouveau_winsys.c)73
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c204
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h52
-rw-r--r--src/gallium/winsys/drm/radeon/Makefile36
-rw-r--r--src/gallium/winsys/drm/radeon/core/Makefile18
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.c (renamed from src/gallium/winsys/drm/radeon/radeon_buffer.c)106
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.h (renamed from src/gallium/winsys/drm/radeon/radeon_buffer.h)25
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.c122
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.h (renamed from src/gallium/winsys/drm/radeon/radeon_context.h)63
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.c (renamed from src/gallium/winsys/drm/radeon/radeon_r300.c)7
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.h (renamed from src/gallium/winsys/drm/radeon/radeon_r300.h)3
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c (renamed from src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c)26
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h (renamed from src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h)11
-rw-r--r--src/gallium/winsys/drm/radeon/dri2/Makefile25
-rw-r--r--src/gallium/winsys/drm/radeon/egl/Makefile25
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_context.c306
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_screen.c288
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_screen.h41
-rw-r--r--src/gallium/winsys/drm/radeon/xorg/Makefile42
-rw-r--r--src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c157
-rw-r--r--src/gallium/winsys/egl_xlib/egl_xlib.c7
-rw-r--r--src/gallium/winsys/egl_xlib/sw_winsys.c6
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c2
-rw-r--r--src/gallium/winsys/g3dvl/xsp_winsys.c25
-rw-r--r--src/gallium/winsys/gdi/SConscript12
-rw-r--r--src/gallium/winsys/gdi/gdi_softpipe_winsys.c14
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_aub.c14
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_screen.c8
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c22
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c58
469 files changed, 18322 insertions, 14807 deletions
diff --git a/src/gallium/Makefile b/src/gallium/Makefile
index 875314f6c3..79ca767f7e 100644
--- a/src/gallium/Makefile
+++ b/src/gallium/Makefile
@@ -1,26 +1,12 @@
+# src/gallium/Makefile
TOP = ../..
include $(TOP)/configs/current
-
SUBDIRS = $(GALLIUM_DIRS)
-# Note winsys/ needs to be built after src/mesa
-
-
-default: subdirs
-
-subdirs:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
- rm -f `find . -name depend`
-
-
-# Dummy install target
-install:
diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template
index 655e949ca2..98487d43bd 100644
--- a/src/gallium/Makefile.template
+++ b/src/gallium/Makefile.template
@@ -1,64 +1,66 @@
-# -*-makefile-*-
+# src/gallium/Makefile.template
-
-# We still have a dependency on the "dri" buffer manager. Most likely
-# the interface can be reused in non-dri environments, and also as a
-# frontend to simpler memory managers.
+# Template makefile for gallium libraries.
+#
+# Usage:
+# The minimum that the including makefile needs to define
+# is TOP, LIBNAME and one of of the *_SOURCES.
#
-COMMON_SOURCES =
+# Optional defines:
+# LIBRARY_INCLUDES are appended to the list of includes directories.
+# LIBRARY_DEFINES is not used for makedepend, but for compilation.
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
+### Basic defines ###
+OBJECTS = $(C_SOURCES:.c=.o) \
+ $(CPP_SOURCES:.cpp=.o) \
+ $(ASM_SOURCES:.S=.o)
-### Include directories
INCLUDES = \
-I. \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/auxiliary \
-I$(TOP)/src/gallium/drivers \
- -I$(TOP)/include \
- $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
+ -I$(GALLIUM)/src/gallium/include \
+ -I$(GALLIUM)/src/gallium/auxiliary \
+ -I$(GALLIUM)/src/gallium/drivers \
+ $(LIBRARY_INCLUDES)
##### TARGETS #####
-default: depend symlinks lib$(LIBNAME).a
-
+default: depend lib$(LIBNAME).a
lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template
- $(TOP)/bin/mklib -o $(LIBNAME) -static $(OBJECTS) $(DRIVER_LIBS)
-
+ $(MKLIB) -o $(LIBNAME) -static $(OBJECTS)
depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
rm -f depend
touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
+ $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) 2> /dev/null
# Emacs tags
tags:
etags `find . -name \*.[ch]` `find ../include`
-
# Remove .o and backup files
-clean::
- -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
+clean:
+ rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak
+
+# Dummy target
+install:
+ @echo -n ""
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+.cpp.o:
+ $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
-include depend
+sinclude depend
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index eaa0f2fe4e..5446eb68a9 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -1,20 +1,12 @@
+# src/gallium/auxiliary/Makefile
TOP = ../../..
include $(TOP)/configs/current
-
SUBDIRS = $(GALLIUM_AUXILIARY_DIRS)
-
-default: subdirs
-
-
-subdirs:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
diff --git a/src/gallium/auxiliary/cso_cache/Makefile b/src/gallium/auxiliary/cso_cache/Makefile
index 6bd6602088..8726afcd94 100644
--- a/src/gallium/auxiliary/cso_cache/Makefile
+++ b/src/gallium/auxiliary/cso_cache/Makefile
@@ -9,6 +9,3 @@ C_SOURCES = \
cso_hash.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c b/src/gallium/auxiliary/cso_cache/cso_cache.c
index 6b1754ea00..0bc77a5728 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.c
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.c
@@ -28,7 +28,7 @@
/* Authors: Zack Rusin <zack@tungstengraphics.com>
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index a9157aad71..f388bf5d95 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -37,7 +37,6 @@
#include "pipe/p_state.h"
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
#include "tgsi/tgsi_parse.h"
#include "cso_cache/cso_context.h"
diff --git a/src/gallium/auxiliary/cso_cache/cso_hash.c b/src/gallium/auxiliary/cso_cache/cso_hash.c
index 4e7664f9bf..288cef7b6f 100644
--- a/src/gallium/auxiliary/cso_cache/cso_hash.c
+++ b/src/gallium/auxiliary/cso_cache/cso_hash.c
@@ -30,7 +30,7 @@
* Zack Rusin <zack@tungstengraphics.com>
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "cso_hash.h"
diff --git a/src/gallium/auxiliary/draw/Makefile b/src/gallium/auxiliary/draw/Makefile
index bdbf5a08ed..5041dcc072 100644
--- a/src/gallium/auxiliary/draw/Makefile
+++ b/src/gallium/auxiliary/draw/Makefile
@@ -43,8 +43,4 @@ C_SOURCES = \
draw_vs_ppc.c \
draw_vs_sse.c
-
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 7bd4a2e221..a4f1fcddc1 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -127,7 +127,7 @@ void draw_set_rasterizer_state( struct draw_context *draw,
draw->rasterizer = raster;
draw->bypass_clipping =
- ((draw->rasterizer && draw->rasterizer->bypass_clipping) ||
+ ((draw->rasterizer && draw->rasterizer->bypass_vs_clip_and_viewport) ||
draw->driver.bypass_clipping);
}
@@ -138,8 +138,9 @@ void draw_set_driver_clipping( struct draw_context *draw,
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
draw->driver.bypass_clipping = bypass_clipping;
- draw->bypass_clipping = (draw->rasterizer->bypass_clipping ||
- draw->driver.bypass_clipping);
+ draw->bypass_clipping =
+ ((draw->rasterizer && draw->rasterizer->bypass_vs_clip_and_viewport) ||
+ draw->driver.bypass_clipping);
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 20841bb5d6..ca69f0b95e 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -32,7 +32,6 @@
*/
-#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
@@ -410,7 +409,7 @@ aaline_create_texture(struct aaline_stage *aaline)
* texels which are zero. Special case the 1x1 and 2x2 levels.
*/
for (level = 0; level <= MAX_TEXTURE_LEVEL; level++) {
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
const uint size = aaline->texture->width[level];
ubyte *data;
uint i, j;
@@ -419,9 +418,9 @@ aaline_create_texture(struct aaline_stage *aaline)
/* This texture is new, no need to flush.
*/
- surface = screen->get_tex_surface(screen, aaline->texture, 0, level, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- data = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_WRITE);
+ transfer = screen->get_tex_transfer(screen, aaline->texture, 0, level, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, size, size);
+ data = screen->transfer_map(screen, transfer);
if (data == NULL)
return FALSE;
@@ -440,13 +439,13 @@ aaline_create_texture(struct aaline_stage *aaline)
else {
d = 255;
}
- data[i * surface->stride + j] = d;
+ data[i * transfer->stride + j] = d;
}
}
/* unmap */
- screen->surface_unmap(screen, surface);
- screen->tex_surface_release(screen, &surface);
+ screen->transfer_unmap(screen, transfer);
+ screen->tex_transfer_destroy(transfer);
}
return TRUE;
}
@@ -728,7 +727,7 @@ aaline_destroy(struct draw_stage *stage)
aaline->pipe->delete_sampler_state(aaline->pipe, aaline->sampler_cso);
if (aaline->texture)
- pipe_texture_release(&aaline->texture);
+ pipe_texture_reference(&aaline->texture, NULL);
draw_free_temp_verts( stage );
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index 2c1cacbdb4..5008086cf2 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -38,7 +38,6 @@
*/
-#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index a0f9716dac..04e59152c5 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -34,7 +34,6 @@
*/
-#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
@@ -372,7 +371,7 @@ pstip_update_texture(struct pstip_stage *pstip)
static const uint bit31 = 1 << 31;
struct pipe_context *pipe = pstip->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
const uint *stipple = pstip->state.stipple->stipple;
uint i, j;
ubyte *data;
@@ -381,10 +380,9 @@ pstip_update_texture(struct pstip_stage *pstip)
*/
pipe->flush( pipe, PIPE_FLUSH_TEXTURE_CACHE, NULL );
- surface = screen->get_tex_surface(screen, pstip->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- data = screen->surface_map(screen, surface,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ transfer = screen->get_tex_transfer(screen, pstip->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
+ data = screen->transfer_map(screen, transfer);
/*
* Load alpha texture.
@@ -396,18 +394,18 @@ pstip_update_texture(struct pstip_stage *pstip)
for (j = 0; j < 32; j++) {
if (stipple[i] & (bit31 >> j)) {
/* fragment "on" */
- data[i * surface->stride + j] = 0;
+ data[i * transfer->stride + j] = 0;
}
else {
/* fragment "off" */
- data[i * surface->stride + j] = 255;
+ data[i * transfer->stride + j] = 255;
}
}
}
/* unmap */
- screen->surface_unmap(screen, surface);
- screen->tex_surface_release(screen, &surface);
+ screen->transfer_unmap(screen, transfer);
+ screen->tex_transfer_destroy(transfer);
}
@@ -573,7 +571,7 @@ pstip_destroy(struct draw_stage *stage)
pstip->pipe->delete_sampler_state(pstip->pipe, pstip->sampler_cso);
- pipe_texture_release(&pstip->texture);
+ pipe_texture_reference(&pstip->texture, NULL);
draw_free_temp_verts( stage );
FREE( stage );
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index 9153bc2f86..12325d30d6 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -29,12 +29,12 @@
* \file
* Vertex buffer drawing stage.
*
- * \author José Fonseca <jrfonsec@tungstengraphics.com>
+ * \author Jose Fonseca <jrfonsec@tungstengraphics.com>
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -93,7 +93,6 @@ vbuf_stage( struct draw_stage *stage )
}
-static void vbuf_flush_indices( struct vbuf_stage *vbuf );
static void vbuf_flush_vertices( struct vbuf_stage *vbuf );
static void vbuf_alloc_vertices( struct vbuf_stage *vbuf );
@@ -109,13 +108,12 @@ overflow( void *map, void *ptr, unsigned bytes, unsigned bufsz )
static INLINE void
check_space( struct vbuf_stage *vbuf, unsigned nr )
{
- if (vbuf->nr_vertices + nr > vbuf->max_vertices ) {
- vbuf_flush_vertices(vbuf);
- vbuf_alloc_vertices(vbuf);
+ if (vbuf->nr_vertices + nr > vbuf->max_vertices ||
+ vbuf->nr_indices + nr > vbuf->max_indices)
+ {
+ vbuf_flush_vertices( vbuf );
+ vbuf_alloc_vertices( vbuf );
}
-
- if (vbuf->nr_indices + nr > vbuf->max_indices )
- vbuf_flush_indices(vbuf);
}
@@ -202,7 +200,7 @@ vbuf_point( struct draw_stage *stage,
* will be flushed if needed and a new one allocated.
*/
static void
-vbuf_set_prim( struct vbuf_stage *vbuf, uint prim )
+vbuf_start_prim( struct vbuf_stage *vbuf, uint prim )
{
struct translate_key hw_key;
unsigned dst_offset;
@@ -217,11 +215,7 @@ vbuf_set_prim( struct vbuf_stage *vbuf, uint prim )
* state change.
*/
vbuf->vinfo = vbuf->render->get_vertex_info(vbuf->render);
-
- if (vbuf->vertex_size != vbuf->vinfo->size * sizeof(float)) {
- vbuf_flush_vertices(vbuf);
- vbuf->vertex_size = vbuf->vinfo->size * sizeof(float);
- }
+ vbuf->vertex_size = vbuf->vinfo->size * sizeof(float);
/* Translate from pipeline vertices to hw vertices.
*/
@@ -294,8 +288,8 @@ vbuf_set_prim( struct vbuf_stage *vbuf, uint prim )
/* Allocate new buffer?
*/
- if (!vbuf->vertices)
- vbuf_alloc_vertices(vbuf);
+ assert(vbuf->vertices == NULL);
+ vbuf_alloc_vertices(vbuf);
}
@@ -305,9 +299,9 @@ vbuf_first_tri( struct draw_stage *stage,
{
struct vbuf_stage *vbuf = vbuf_stage( stage );
- vbuf_flush_indices( vbuf );
+ vbuf_flush_vertices( vbuf );
+ vbuf_start_prim(vbuf, PIPE_PRIM_TRIANGLES);
stage->tri = vbuf_tri;
- vbuf_set_prim(vbuf, PIPE_PRIM_TRIANGLES);
stage->tri( stage, prim );
}
@@ -318,9 +312,9 @@ vbuf_first_line( struct draw_stage *stage,
{
struct vbuf_stage *vbuf = vbuf_stage( stage );
- vbuf_flush_indices( vbuf );
+ vbuf_flush_vertices( vbuf );
+ vbuf_start_prim(vbuf, PIPE_PRIM_LINES);
stage->line = vbuf_line;
- vbuf_set_prim(vbuf, PIPE_PRIM_LINES);
stage->line( stage, prim );
}
@@ -331,53 +325,42 @@ vbuf_first_point( struct draw_stage *stage,
{
struct vbuf_stage *vbuf = vbuf_stage( stage );
- vbuf_flush_indices( vbuf );
+ vbuf_flush_vertices(vbuf);
+ vbuf_start_prim(vbuf, PIPE_PRIM_POINTS);
stage->point = vbuf_point;
- vbuf_set_prim(vbuf, PIPE_PRIM_POINTS);
stage->point( stage, prim );
}
-static void
-vbuf_flush_indices( struct vbuf_stage *vbuf )
-{
- if(!vbuf->nr_indices)
- return;
-
- assert((uint) (vbuf->vertex_ptr - vbuf->vertices) ==
- vbuf->nr_vertices * vbuf->vertex_size / sizeof(unsigned));
-
- vbuf->render->draw(vbuf->render, vbuf->indices, vbuf->nr_indices);
-
- vbuf->nr_indices = 0;
-}
-
/**
* Flush existing vertex buffer and allocate a new one.
- *
- * XXX: We separate flush-on-index-full and flush-on-vb-full, but may
- * raise issues uploading vertices if the hardware wants to flush when
- * we flush.
*/
static void
vbuf_flush_vertices( struct vbuf_stage *vbuf )
{
- if(vbuf->vertices) {
- vbuf_flush_indices(vbuf);
-
+ if(vbuf->vertices) {
+
+ vbuf->render->unmap_vertices( vbuf->render, 0, vbuf->nr_vertices - 1 );
+
+ if (vbuf->nr_indices)
+ {
+ vbuf->render->draw(vbuf->render,
+ vbuf->indices,
+ vbuf->nr_indices );
+
+ vbuf->nr_indices = 0;
+ }
+
/* Reset temporary vertices ids */
if(vbuf->nr_vertices)
draw_reset_vertex_ids( vbuf->stage.draw );
/* Free the vertex buffer */
- vbuf->render->release_vertices(vbuf->render,
- vbuf->vertices,
- vbuf->vertex_size,
- vbuf->nr_vertices);
+ vbuf->render->release_vertices( vbuf->render );
+
vbuf->max_vertices = vbuf->nr_vertices = 0;
vbuf->vertex_ptr = vbuf->vertices = NULL;
-
}
}
@@ -402,9 +385,12 @@ vbuf_alloc_vertices( struct vbuf_stage *vbuf )
* and it will flush itself if necessary to do so. If this does
* fail, we are basically without usable hardware.
*/
- vbuf->vertices = (uint *) vbuf->render->allocate_vertices(vbuf->render,
- (ushort) vbuf->vertex_size,
- (ushort) vbuf->max_vertices);
+ vbuf->render->allocate_vertices(vbuf->render,
+ (ushort) vbuf->vertex_size,
+ (ushort) vbuf->max_vertices);
+
+ vbuf->vertices = (uint *) vbuf->render->map_vertices( vbuf->render );
+
vbuf->vertex_ptr = vbuf->vertices;
}
@@ -415,14 +401,11 @@ vbuf_flush( struct draw_stage *stage, unsigned flags )
{
struct vbuf_stage *vbuf = vbuf_stage( stage );
- vbuf_flush_indices( vbuf );
+ vbuf_flush_vertices( vbuf );
stage->point = vbuf_first_point;
stage->line = vbuf_first_line;
stage->tri = vbuf_first_tri;
-
- if (flags & DRAW_FLUSH_BACKEND)
- vbuf_flush_vertices( vbuf );
}
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index 4e5ffa0930..9ea0cbe599 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -87,7 +87,7 @@ draw_pt_arrays(struct draw_context *draw,
opt |= PT_CLIPTEST;
}
- if (!draw->rasterizer->bypass_vs) {
+ if (!draw->rasterizer->bypass_vs_clip_and_viewport) {
opt |= PT_SHADE;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h
index c02f229110..6f3e1e0289 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -173,9 +173,7 @@ void draw_pt_emit( struct pt_emit *emit,
void draw_pt_emit_linear( struct pt_emit *emit,
const float (*vertex_data)[4],
- unsigned vertex_count,
unsigned stride,
- unsigned start,
unsigned count );
void draw_pt_emit_destroy( struct pt_emit *emit );
@@ -217,7 +215,7 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
boolean bypass_clipping,
- boolean identity_viewport,
+ boolean bypass_viewport,
boolean opengl );
struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );
diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c
index 232dfdaed2..064e16c295 100644
--- a/src/gallium/auxiliary/draw/draw_pt_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_emit.c
@@ -165,6 +165,9 @@ void draw_pt_emit( struct pt_emit *emit,
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
+ if (vertex_count == 0)
+ return;
+
if (vertex_count >= UNDEFINED_VERTEX_ID) {
assert(0);
return;
@@ -178,9 +181,11 @@ void draw_pt_emit( struct pt_emit *emit,
return;
}
- hw_verts = render->allocate_vertices(render,
- (ushort)translate->key.output_stride,
- (ushort)vertex_count);
+ render->allocate_vertices(render,
+ (ushort)translate->key.output_stride,
+ (ushort)vertex_count);
+
+ hw_verts = render->map_vertices( render );
if (!hw_verts) {
assert(0);
return;
@@ -201,22 +206,21 @@ void draw_pt_emit( struct pt_emit *emit,
vertex_count,
hw_verts );
+ render->unmap_vertices( render,
+ 0,
+ vertex_count - 1 );
+
render->draw(render,
elts,
count);
- render->release_vertices(render,
- hw_verts,
- translate->key.output_stride,
- vertex_count);
+ render->release_vertices(render);
}
void draw_pt_emit_linear(struct pt_emit *emit,
const float (*vertex_data)[4],
- unsigned vertex_count,
unsigned stride,
- unsigned start,
unsigned count)
{
struct draw_context *draw = emit->draw;
@@ -231,26 +235,23 @@ void draw_pt_emit_linear(struct pt_emit *emit,
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
- if (count >= UNDEFINED_VERTEX_ID) {
- assert(0);
- return;
- }
+ if (count >= UNDEFINED_VERTEX_ID)
+ goto fail;
/* XXX: and work out some way to coordinate the render primitive
* between vbuf.c and here...
*/
- if (!draw->render->set_primitive(draw->render, emit->prim)) {
- assert(0);
- return;
- }
+ if (!draw->render->set_primitive(draw->render, emit->prim))
+ goto fail;
- hw_verts = render->allocate_vertices(render,
- (ushort)translate->key.output_stride,
- (ushort)count);
- if (!hw_verts) {
- assert(0);
- return;
- }
+ if (!render->allocate_vertices(render,
+ (ushort)translate->key.output_stride,
+ (ushort)count))
+ goto fail;
+
+ hw_verts = render->map_vertices( render );
+ if (!hw_verts)
+ goto fail;
translate->set_buffer(translate, 0,
vertex_data, stride);
@@ -261,12 +262,12 @@ void draw_pt_emit_linear(struct pt_emit *emit,
translate->run(translate,
0,
- vertex_count,
+ count,
hw_verts);
if (0) {
unsigned i;
- for (i = 0; i < vertex_count; i++) {
+ for (i = 0; i < count; i++) {
debug_printf("\n\n%s vertex %d:\n", __FUNCTION__, i);
draw_dump_emitted_vertex( emit->vinfo,
(const uint8_t *)hw_verts +
@@ -274,13 +275,17 @@ void draw_pt_emit_linear(struct pt_emit *emit,
}
}
+ render->unmap_vertices( render, 0, count - 1 );
+
+ render->draw_arrays(render, 0, count);
+
+ render->release_vertices(render);
- render->draw_arrays(render, start, count);
+ return;
- render->release_vertices(render,
- hw_verts,
- translate->key.output_stride,
- vertex_count);
+fail:
+ assert(0);
+ return;
}
struct pt_emit *draw_pt_emit_create( struct draw_context *draw )
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index dcb7744b17..6b7d02a19b 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -234,9 +234,11 @@ static void fetch_emit_run( struct draw_pt_middle_end *middle,
return;
}
- hw_verts = draw->render->allocate_vertices( draw->render,
- (ushort)feme->translate->key.output_stride,
- (ushort)fetch_count );
+ draw->render->allocate_vertices( draw->render,
+ (ushort)feme->translate->key.output_stride,
+ (ushort)fetch_count );
+
+ hw_verts = draw->render->map_vertices( draw->render );
if (!hw_verts) {
assert(0);
return;
@@ -259,6 +261,10 @@ static void fetch_emit_run( struct draw_pt_middle_end *middle,
}
}
+ draw->render->unmap_vertices( draw->render,
+ 0,
+ (ushort)(fetch_count - 1) );
+
/* XXX: Draw arrays path to avoid re-emitting index list again and
* again.
*/
@@ -268,10 +274,7 @@ static void fetch_emit_run( struct draw_pt_middle_end *middle,
/* Done -- that was easy, wasn't it:
*/
- draw->render->release_vertices( draw->render,
- hw_verts,
- feme->translate->key.output_stride,
- fetch_count );
+ draw->render->release_vertices( draw->render );
}
@@ -288,18 +291,17 @@ static void fetch_emit_run_linear( struct draw_pt_middle_end *middle,
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
- if (count >= UNDEFINED_VERTEX_ID) {
- assert(0);
- return;
- }
+ if (count >= UNDEFINED_VERTEX_ID)
+ goto fail;
- hw_verts = draw->render->allocate_vertices( draw->render,
- (ushort)feme->translate->key.output_stride,
- (ushort)count );
- if (!hw_verts) {
- assert(0);
- return;
- }
+ if (!draw->render->allocate_vertices( draw->render,
+ (ushort)feme->translate->key.output_stride,
+ (ushort)count ))
+ goto fail;
+
+ hw_verts = draw->render->map_vertices( draw->render );
+ if (!hw_verts)
+ goto fail;
/* Single routine to fetch vertices and emit HW verts.
*/
@@ -317,20 +319,21 @@ static void fetch_emit_run_linear( struct draw_pt_middle_end *middle,
}
}
+ draw->render->unmap_vertices( draw->render, 0, count - 1 );
+
/* XXX: Draw arrays path to avoid re-emitting index list again and
* again.
*/
- draw->render->draw_arrays( draw->render,
- 0, /*start*/
- count );
+ draw->render->draw_arrays( draw->render, 0, count );
/* Done -- that was easy, wasn't it:
*/
- draw->render->release_vertices( draw->render,
- hw_verts,
- feme->translate->key.output_stride,
- count );
+ draw->render->release_vertices( draw->render );
+ return;
+fail:
+ assert(0);
+ return;
}
@@ -351,9 +354,12 @@ static boolean fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
if (count >= UNDEFINED_VERTEX_ID)
return FALSE;
- hw_verts = draw->render->allocate_vertices( draw->render,
- (ushort)feme->translate->key.output_stride,
- (ushort)count );
+ if (!draw->render->allocate_vertices( draw->render,
+ (ushort)feme->translate->key.output_stride,
+ (ushort)count ))
+ return FALSE;
+
+ hw_verts = draw->render->map_vertices( draw->render );
if (!hw_verts)
return FALSE;
@@ -364,6 +370,8 @@ static boolean fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
count,
hw_verts );
+ draw->render->unmap_vertices( draw->render, 0, (ushort)(count - 1) );
+
/* XXX: Draw arrays path to avoid re-emitting index list again and
* again.
*/
@@ -373,10 +381,7 @@ static boolean fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
/* Done -- that was easy, wasn't it:
*/
- draw->render->release_vertices( draw->render,
- hw_verts,
- feme->translate->key.output_stride,
- count );
+ draw->render->release_vertices( draw->render );
return TRUE;
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
index 84ffe3296a..44147aed9b 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
@@ -101,7 +101,8 @@ static void fse_prepare( struct draw_pt_middle_end *middle,
fse->key.nr_elements = MAX2(fse->key.nr_outputs, /* outputs - translate to hw format */
fse->key.nr_inputs); /* inputs - fetch from api format */
- fse->key.viewport = !draw->identity_viewport;
+ fse->key.viewport = (!draw->rasterizer->bypass_vs_clip_and_viewport &&
+ !draw->identity_viewport);
fse->key.clip = !draw->bypass_clipping;
fse->key.const_vbuffers = 0;
@@ -234,19 +235,17 @@ static void fse_run_linear( struct draw_pt_middle_end *middle,
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
- if (count >= UNDEFINED_VERTEX_ID) {
- assert(0);
- return;
- }
+ if (count >= UNDEFINED_VERTEX_ID)
+ goto fail;
- hw_verts = draw->render->allocate_vertices( draw->render,
- (ushort)fse->key.output_stride,
- (ushort)count );
+ if (!draw->render->allocate_vertices( draw->render,
+ (ushort)fse->key.output_stride,
+ (ushort)count ))
+ goto fail;
- if (!hw_verts) {
- assert(0);
- return;
- }
+ hw_verts = draw->render->map_vertices( draw->render );
+ if (!hw_verts)
+ goto fail;
/* Single routine to fetch vertices, run shader and emit HW verts.
* Clipping is done elsewhere -- either by the API or on hardware,
@@ -256,13 +255,7 @@ static void fse_run_linear( struct draw_pt_middle_end *middle,
start, count,
hw_verts );
- /* Draw arrays path to avoid re-emitting index list again and
- * again.
- */
- draw->render->draw_arrays( draw->render,
- 0,
- count );
-
+
if (0) {
unsigned i;
for (i = 0; i < count; i++) {
@@ -274,12 +267,24 @@ static void fse_run_linear( struct draw_pt_middle_end *middle,
(const uint8_t *)hw_verts + fse->key.output_stride * i );
}
}
+
+ draw->render->unmap_vertices( draw->render, 0, (ushort)(count - 1) );
+ /* Draw arrays path to avoid re-emitting index list again and
+ * again.
+ */
+ draw->render->draw_arrays( draw->render,
+ 0,
+ count );
+
+
+ draw->render->release_vertices( draw->render );
+
+ return;
- draw->render->release_vertices( draw->render,
- hw_verts,
- fse->key.output_stride,
- count );
+fail:
+ assert(0);
+ return;
}
@@ -298,18 +303,17 @@ fse_run(struct draw_pt_middle_end *middle,
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
- if (fetch_count >= UNDEFINED_VERTEX_ID) {
- assert(0);
- return;
- }
+ if (fetch_count >= UNDEFINED_VERTEX_ID)
+ goto fail;
- hw_verts = draw->render->allocate_vertices( draw->render,
- (ushort)fse->key.output_stride,
- (ushort)fetch_count );
- if (!hw_verts) {
- assert(0);
- return;
- }
+ if (!draw->render->allocate_vertices( draw->render,
+ (ushort)fse->key.output_stride,
+ (ushort)fetch_count ))
+ goto fail;
+
+ hw_verts = draw->render->map_vertices( draw->render );
+ if (!hw_verts)
+ goto fail;
/* Single routine to fetch vertices, run shader and emit HW verts.
@@ -319,9 +323,6 @@ fse_run(struct draw_pt_middle_end *middle,
fetch_count,
hw_verts );
- draw->render->draw( draw->render,
- draw_elts,
- draw_count );
if (0) {
unsigned i;
@@ -333,12 +334,19 @@ fse_run(struct draw_pt_middle_end *middle,
}
}
+ draw->render->unmap_vertices( draw->render, 0, (ushort)(fetch_count - 1) );
+
+ draw->render->draw( draw->render,
+ draw_elts,
+ draw_count );
+
- draw->render->release_vertices( draw->render,
- hw_verts,
- fse->key.output_stride,
- fetch_count );
+ draw->render->release_vertices( draw->render );
+ return;
+fail:
+ assert(0);
+ return;
}
@@ -360,13 +368,14 @@ static boolean fse_run_linear_elts( struct draw_pt_middle_end *middle,
if (count >= UNDEFINED_VERTEX_ID)
return FALSE;
- hw_verts = draw->render->allocate_vertices( draw->render,
- (ushort)fse->key.output_stride,
- (ushort)count );
+ if (!draw->render->allocate_vertices( draw->render,
+ (ushort)fse->key.output_stride,
+ (ushort)count ))
+ return FALSE;
- if (!hw_verts) {
+ hw_verts = draw->render->map_vertices( draw->render );
+ if (!hw_verts)
return FALSE;
- }
/* Single routine to fetch vertices, run shader and emit HW verts.
* Clipping is done elsewhere -- either by the API or on hardware,
@@ -382,11 +391,9 @@ static boolean fse_run_linear_elts( struct draw_pt_middle_end *middle,
draw_count );
+ draw->render->unmap_vertices( draw->render, 0, (ushort)(count - 1) );
- draw->render->release_vertices( draw->render,
- hw_verts,
- fse->key.output_stride,
- count );
+ draw->render->release_vertices( draw->render );
return TRUE;
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
index ec3b41c320..11ac90fc56 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -84,7 +84,8 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
*/
draw_pt_post_vs_prepare( fpme->post_vs,
(boolean)draw->bypass_clipping,
- (boolean)draw->identity_viewport,
+ (boolean)(draw->identity_viewport ||
+ draw->rasterizer->bypass_vs_clip_and_viewport),
(boolean)draw->rasterizer->gl_rasterization_rules );
@@ -140,9 +141,9 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
(char *)pipeline_verts );
/* Run the shader, note that this overwrites the data[] parts of
- * the pipeline verts. If there is no shader, ie a bypass shader,
- * then the inputs == outputs, and are already in the correct
- * place.
+ * the pipeline verts. If there is no shader, eg if
+ * bypass_vs_clip_and_viewport, then the inputs == outputs, and are
+ * already in the correct place.
*/
if (opt & PT_SHADE)
{
@@ -216,9 +217,9 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
(char *)pipeline_verts );
/* Run the shader, note that this overwrites the data[] parts of
- * the pipeline verts. If there is no shader, ie a bypass shader,
- * then the inputs == outputs, and are already in the correct
- * place.
+ * the pipeline verts. If there is no shader, ie if
+ * bypass_vs_clip_and_viewport, then the inputs == outputs, and are
+ * already in the correct place.
*/
if (opt & PT_SHADE)
{
@@ -251,9 +252,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
else {
draw_pt_emit_linear( fpme->emit,
(const float (*)[4])pipeline_verts->data,
- count,
fpme->vertex_size,
- 0, /*start*/
count );
}
@@ -288,9 +287,9 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
(char *)pipeline_verts );
/* Run the shader, note that this overwrites the data[] parts of
- * the pipeline verts. If there is no shader, ie a bypass shader,
- * then the inputs == outputs, and are already in the correct
- * place.
+ * the pipeline verts. If there is no shader, ie if
+ * bypass_vs_clip_and_viewport, then the inputs == outputs, and are
+ * already in the correct place.
*/
if (opt & PT_SHADE)
{
diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
index 96dc706b99..00d7197b13 100644
--- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c
+++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
@@ -200,11 +200,11 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
boolean bypass_clipping,
- boolean identity_viewport,
+ boolean bypass_viewport,
boolean opengl )
{
if (bypass_clipping) {
- if (identity_viewport)
+ if (bypass_viewport)
pvs->run = post_vs_none;
else
pvs->run = post_vs_viewport;
diff --git a/src/gallium/auxiliary/draw/draw_vbuf.h b/src/gallium/auxiliary/draw/draw_vbuf.h
index a1c4c14445..cccd3bf435 100644
--- a/src/gallium/auxiliary/draw/draw_vbuf.h
+++ b/src/gallium/auxiliary/draw/draw_vbuf.h
@@ -80,9 +80,14 @@ struct vbuf_render {
* Hardware renderers will use ttm memory, others will just malloc
* something.
*/
- void *(*allocate_vertices)( struct vbuf_render *,
- ushort vertex_size,
- ushort nr_vertices );
+ boolean (*allocate_vertices)( struct vbuf_render *,
+ ushort vertex_size,
+ ushort nr_vertices );
+
+ void *(*map_vertices)( struct vbuf_render * );
+ void (*unmap_vertices)( struct vbuf_render *,
+ ushort min_index,
+ ushort max_index );
/**
* Notify the renderer of the current primitive when it changes.
@@ -109,10 +114,7 @@ struct vbuf_render {
/**
* Called when vbuf is done with this set of vertices:
*/
- void (*release_vertices)( struct vbuf_render *,
- void *vertices,
- unsigned vertex_size,
- unsigned vertices_used );
+ void (*release_vertices)( struct vbuf_render * );
void (*destroy)( struct vbuf_render * );
};
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c
index 0c693a4a65..9e37a26c1e 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.c
@@ -32,7 +32,7 @@
#include "util/u_memory.h"
#include "util/u_math.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi/tgsi_exec.h"
@@ -143,7 +143,7 @@ static struct x86_reg get_reg_ptr(struct aos_compilation *cp,
return x86_make_disp(aos_get_x86(cp, 1, X86_CONSTANTS), idx * 4 * sizeof(float));
default:
- ERROR(cp, "unknown reg file");
+ AOS_ERROR(cp, "unknown reg file");
return x86_make_reg(0,0);
}
}
@@ -177,7 +177,7 @@ static void spill( struct aos_compilation *cp, unsigned idx )
(cp->xmm[idx].file != TGSI_FILE_INPUT && /* inputs are fetched into xmm & set dirty */
cp->xmm[idx].file != TGSI_FILE_OUTPUT &&
cp->xmm[idx].file != TGSI_FILE_TEMPORARY)) {
- ERROR(cp, "invalid spill");
+ AOS_ERROR(cp, "invalid spill");
return;
}
else {
@@ -284,6 +284,15 @@ void aos_release_xmm_reg( struct aos_compilation *cp,
}
+static void aos_soft_release_xmm( struct aos_compilation *cp,
+ struct x86_reg reg )
+{
+ if (reg.file == file_XMM) {
+ assert(cp->xmm[reg.idx].last_used == cp->insn_counter);
+ cp->xmm[reg.idx].last_used = cp->insn_counter - 1;
+ }
+}
+
/* Mark an xmm reg as holding the current copy of a shader reg.
@@ -534,7 +543,7 @@ static struct x86_reg fetch_src( struct aos_compilation *cp,
switch (swizzle) {
case TGSI_EXTSWIZZLE_ZERO:
case TGSI_EXTSWIZZLE_ONE:
- ERROR(cp, "not supporting full swizzles yet in tgsi_aos_sse2");
+ AOS_ERROR(cp, "not supporting full swizzles yet in tgsi_aos_sse2");
break;
default:
@@ -555,7 +564,7 @@ static struct x86_reg fetch_src( struct aos_compilation *cp,
break;
default:
- ERROR(cp, "unsupported sign-mode");
+ AOS_ERROR(cp, "unsupported sign-mode");
break;
}
}
@@ -584,15 +593,17 @@ static struct x86_reg fetch_src( struct aos_compilation *cp,
sse_mulps(cp->func, dst, tmp);
aos_release_xmm_reg(cp, tmp.idx);
+ aos_soft_release_xmm(cp, imm_swz);
}
else if (negs) {
struct x86_reg imm_negs = aos_get_internal_xmm(cp, IMM_NEGS);
sse_mulps(cp->func, dst, imm_negs);
+ aos_soft_release_xmm(cp, imm_negs);
}
if (abs && abs != 0xf) {
- ERROR(cp, "unsupported partial abs");
+ AOS_ERROR(cp, "unsupported partial abs");
}
else if (abs) {
struct x86_reg neg = aos_get_internal(cp, IMM_NEGS);
@@ -603,8 +614,10 @@ static struct x86_reg fetch_src( struct aos_compilation *cp,
sse_maxps(cp->func, dst, tmp);
aos_release_xmm_reg(cp, tmp.idx);
+ aos_soft_release_xmm(cp, neg);
}
+ aos_soft_release_xmm(cp, arg0);
return dst;
}
@@ -657,7 +670,7 @@ static void x87_fld_src( struct aos_compilation *cp,
break;
default:
- ERROR(cp, "unsupported sign-mode");
+ AOS_ERROR(cp, "unsupported sign-mode");
break;
}
}
@@ -1559,7 +1572,6 @@ static boolean emit_RCP( struct aos_compilation *cp, const struct tgsi_full_inst
*/
static boolean emit_RSQ( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
-
if (0) {
struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
struct x86_reg r = aos_get_xmm_reg(cp);
@@ -1568,21 +1580,30 @@ static boolean emit_RSQ( struct aos_compilation *cp, const struct tgsi_full_inst
return TRUE;
}
else {
- struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
- struct x86_reg r = aos_get_xmm_reg(cp);
+ struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
+ struct x86_reg r = aos_get_xmm_reg(cp);
struct x86_reg neg_half = get_reg_ptr( cp, AOS_FILE_INTERNAL, IMM_RSQ );
struct x86_reg one_point_five = x86_make_disp( neg_half, 4 );
struct x86_reg src = get_xmm_writable( cp, arg0 );
-
- sse_rsqrtss( cp->func, r, src ); /* rsqrtss(a) */
- sse_mulss( cp->func, src, neg_half ); /* -.5 * a */
- sse_mulss( cp->func, src, r ); /* -.5 * a * r */
- sse_mulss( cp->func, src, r ); /* -.5 * a * r * r */
- sse_addss( cp->func, src, one_point_five ); /* 1.5 - .5 * a * r * r */
- sse_mulss( cp->func, r, src ); /* r * (1.5 - .5 * a * r * r) */
+ struct x86_reg neg = aos_get_internal(cp, IMM_NEGS);
+ struct x86_reg tmp = aos_get_xmm_reg(cp);
+
+ sse_movaps(cp->func, tmp, src);
+ sse_mulps(cp->func, tmp, neg);
+ sse_maxps(cp->func, tmp, src);
+
+ sse_rsqrtss( cp->func, r, tmp ); /* rsqrtss(a) */
+ sse_mulss( cp->func, tmp, neg_half ); /* -.5 * a */
+ sse_mulss( cp->func, tmp, r ); /* -.5 * a * r */
+ sse_mulss( cp->func, tmp, r ); /* -.5 * a * r * r */
+ sse_addss( cp->func, tmp, one_point_five ); /* 1.5 - .5 * a * r * r */
+ sse_mulss( cp->func, r, tmp ); /* r * (1.5 - .5 * a * r * r) */
store_scalar_dest(cp, &op->FullDstRegisters[0], r);
+
+ aos_release_xmm_reg(cp, tmp.idx);
+
return TRUE;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.h b/src/gallium/auxiliary/draw/draw_vs_aos.h
index 264387517b..2cf72ddf7b 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.h
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.h
@@ -204,7 +204,7 @@ struct x86_reg aos_get_internal_xmm( struct aos_compilation *cp,
unsigned imm );
-#define ERROR(cp, msg) \
+#define AOS_ERROR(cp, msg) \
do { \
if (0) debug_printf("%s: x86 translation failed: %s\n", __FUNCTION__, msg); \
cp->error = 1; \
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_io.c b/src/gallium/auxiliary/draw/draw_vs_aos_io.c
index 39f75b50b7..a6eb37d128 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos_io.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos_io.c
@@ -199,7 +199,7 @@ static boolean load_input( struct aos_compilation *cp,
emit_load_R8G8B8A8_UNORM(cp, dataXMM, src);
break;
default:
- ERROR(cp, "unhandled input format");
+ AOS_ERROR(cp, "unhandled input format");
return FALSE;
}
@@ -410,7 +410,7 @@ static boolean emit_output( struct aos_compilation *cp,
}
break;
default:
- ERROR(cp, "unhandled output format");
+ AOS_ERROR(cp, "unhandled output format");
return FALSE;
}
diff --git a/src/gallium/auxiliary/gallivm/storagesoa.cpp b/src/gallium/auxiliary/gallivm/storagesoa.cpp
index e1e5cabcf5..4984ce985c 100644
--- a/src/gallium/auxiliary/gallivm/storagesoa.cpp
+++ b/src/gallium/auxiliary/gallivm/storagesoa.cpp
@@ -30,7 +30,7 @@
#include "gallivm_p.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include <llvm/BasicBlock.h>
#include <llvm/Module.h>
diff --git a/src/gallium/auxiliary/indices/Makefile b/src/gallium/auxiliary/indices/Makefile
index 8fa61d265e..f2ebc3f410 100644
--- a/src/gallium/auxiliary/indices/Makefile
+++ b/src/gallium/auxiliary/indices/Makefile
@@ -4,13 +4,13 @@ include $(TOP)/configs/current
LIBNAME = indices
C_SOURCES = \
- u_indices_gen.c
+ u_indices_gen.c \
+ u_unfilled_gen.c
include ../../Makefile.template
u_indices_gen.c: u_indices_gen.py
python $< > $@
-
-symlinks:
-
+u_unfilled_gen.c: u_unfilled_gen.py
+ python $< > $@
diff --git a/src/gallium/auxiliary/indices/SConscript b/src/gallium/auxiliary/indices/SConscript
index 65a43a9f64..e5f7ee9484 100644
--- a/src/gallium/auxiliary/indices/SConscript
+++ b/src/gallium/auxiliary/indices/SConscript
@@ -7,11 +7,20 @@ env.CodeGenerate(
command = 'python $SCRIPT > $TARGET'
)
+env.CodeGenerate(
+ target = 'u_unfilled_gen.c',
+ script = 'u_unfilled_gen.py',
+ source = [],
+ command = 'python $SCRIPT > $TARGET'
+)
+
indices = env.ConvenienceLibrary(
target = 'indices',
source = [
# 'u_indices.c',
+# 'u_unfilled_indices.c',
'u_indices_gen.c',
+ 'u_unfilled_gen.c',
])
auxiliaries.insert(0, indices)
diff --git a/src/gallium/auxiliary/indices/u_indices.h b/src/gallium/auxiliary/indices/u_indices.h
index abf5a3037d..be522c6725 100644
--- a/src/gallium/auxiliary/indices/u_indices.h
+++ b/src/gallium/auxiliary/indices/u_indices.h
@@ -80,4 +80,27 @@ int u_index_generator( unsigned hw_mask,
u_generate_func *out_generate );
+void u_unfilled_init( void );
+
+int u_unfilled_translator( unsigned prim,
+ unsigned in_index_size,
+ unsigned nr,
+ unsigned unfilled_mode,
+ unsigned *out_prim,
+ unsigned *out_index_size,
+ unsigned *out_nr,
+ u_translate_func *out_translate );
+
+int u_unfilled_generator( unsigned prim,
+ unsigned start,
+ unsigned nr,
+ unsigned unfilled_mode,
+ unsigned *out_prim,
+ unsigned *out_index_size,
+ unsigned *out_nr,
+ u_generate_func *out_generate );
+
+
+
+
#endif
diff --git a/src/gallium/auxiliary/indices/u_indices_gen.c b/src/gallium/auxiliary/indices/u_indices_gen.c
index 4c05b3eedb..3c981e5d7f 100644
--- a/src/gallium/auxiliary/indices/u_indices_gen.c
+++ b/src/gallium/auxiliary/indices/u_indices_gen.c
@@ -34,7 +34,7 @@
#include "indices/u_indices.h"
#include "indices/u_indices_priv.h"
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
diff --git a/src/gallium/auxiliary/indices/u_indices_gen.py b/src/gallium/auxiliary/indices/u_indices_gen.py
index 0dc58d0cd0..af63d09930 100644
--- a/src/gallium/auxiliary/indices/u_indices_gen.py
+++ b/src/gallium/auxiliary/indices/u_indices_gen.py
@@ -72,7 +72,7 @@ def prolog():
#include "indices/u_indices.h"
#include "indices/u_indices_priv.h"
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.c b/src/gallium/auxiliary/indices/u_unfilled_gen.c
new file mode 100644
index 0000000000..fd082ebbb3
--- /dev/null
+++ b/src/gallium/auxiliary/indices/u_unfilled_gen.c
@@ -0,0 +1,1152 @@
+/* File automatically generated by u_unfilled_gen.py */
+
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+/**
+ * @file
+ * Functions to translate and generate index lists
+ */
+
+#include "indices/u_indices.h"
+#include "indices/u_indices_priv.h"
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+#include "pipe/p_defines.h"
+#include "util/u_memory.h"
+
+
+static unsigned out_size_idx( unsigned index_size )
+{
+ switch (index_size) {
+ case 4: return OUT_UINT;
+ case 2: return OUT_USHORT;
+ default: assert(0); return OUT_USHORT;
+ }
+}
+
+static unsigned in_size_idx( unsigned index_size )
+{
+ switch (index_size) {
+ case 4: return IN_UINT;
+ case 2: return IN_USHORT;
+ case 1: return IN_UBYTE;
+ default: assert(0); return IN_UBYTE;
+ }
+}
+
+
+static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT];
+static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT];
+
+
+static void generate_tris_ushort(
+ unsigned nr,
+ void *_out )
+{
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i+=3) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1);
+ (out+j)[0] = (ushort)(i);
+ (out+j)[1] = (ushort)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)(i+1);
+ (out+j+2)[1] = (ushort)(i+2);
+ debug_printf(" line %d %d\n", (int)i+2, (int)i);
+ (out+j+4)[0] = (ushort)(i+2);
+ (out+j+4)[1] = (ushort)(i);
+ }
+}
+static void generate_tristrip_ushort(
+ unsigned nr,
+ void *_out )
+{
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
+ (out+j)[0] = (ushort)(i);
+ (out+j)[1] = (ushort)(i+1/*+(i&1)*/);
+ debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
+ (out+j+2)[0] = (ushort)(i+1/*+(i&1)*/);
+ (out+j+2)[1] = (ushort)(i+2/*-(i&1)*/);
+ debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
+ (out+j+4)[0] = (ushort)(i+2/*-(i&1)*/);
+ (out+j+4)[1] = (ushort)(i);
+ }
+}
+static void generate_trifan_ushort(
+ unsigned nr,
+ void *_out )
+{
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (ushort)(0);
+ (out+j)[1] = (ushort)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)(i+1);
+ (out+j+2)[1] = (ushort)(i+2);
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (ushort)(i+2);
+ (out+j+4)[1] = (ushort)(0);
+ }
+}
+static void generate_quads_ushort(
+ unsigned nr,
+ void *_out )
+{
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=4) {
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j)[0] = (ushort)(i+0);
+ (out+j)[1] = (ushort)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)(i+1);
+ (out+j+2)[1] = (ushort)(i+2);
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
+ (out+j+4)[0] = (ushort)(i+2);
+ (out+j+4)[1] = (ushort)(i+3);
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
+ (out+j+6)[0] = (ushort)(i+3);
+ (out+j+6)[1] = (ushort)(i+0);
+ }
+}
+static void generate_quadstrip_ushort(
+ unsigned nr,
+ void *_out )
+{
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=2) {
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
+ (out+j)[0] = (ushort)(i+2);
+ (out+j)[1] = (ushort)(i+0);
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j+2)[0] = (ushort)(i+0);
+ (out+j+2)[1] = (ushort)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
+ (out+j+4)[0] = (ushort)(i+1);
+ (out+j+4)[1] = (ushort)(i+3);
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
+ (out+j+6)[0] = (ushort)(i+3);
+ (out+j+6)[1] = (ushort)(i+2);
+ }
+}
+static void generate_polygon_ushort(
+ unsigned nr,
+ void *_out )
+{
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (ushort)(0);
+ (out+j)[1] = (ushort)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)(i+1);
+ (out+j+2)[1] = (ushort)(i+2);
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (ushort)(i+2);
+ (out+j+4)[1] = (ushort)(0);
+ }
+}
+static void generate_tris_uint(
+ unsigned nr,
+ void *_out )
+{
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i+=3) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1);
+ (out+j)[0] = (uint)(i);
+ (out+j)[1] = (uint)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)(i+1);
+ (out+j+2)[1] = (uint)(i+2);
+ debug_printf(" line %d %d\n", (int)i+2, (int)i);
+ (out+j+4)[0] = (uint)(i+2);
+ (out+j+4)[1] = (uint)(i);
+ }
+}
+static void generate_tristrip_uint(
+ unsigned nr,
+ void *_out )
+{
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
+ (out+j)[0] = (uint)(i);
+ (out+j)[1] = (uint)(i+1/*+(i&1)*/);
+ debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
+ (out+j+2)[0] = (uint)(i+1/*+(i&1)*/);
+ (out+j+2)[1] = (uint)(i+2/*-(i&1)*/);
+ debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
+ (out+j+4)[0] = (uint)(i+2/*-(i&1)*/);
+ (out+j+4)[1] = (uint)(i);
+ }
+}
+static void generate_trifan_uint(
+ unsigned nr,
+ void *_out )
+{
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (uint)(0);
+ (out+j)[1] = (uint)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)(i+1);
+ (out+j+2)[1] = (uint)(i+2);
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (uint)(i+2);
+ (out+j+4)[1] = (uint)(0);
+ }
+}
+static void generate_quads_uint(
+ unsigned nr,
+ void *_out )
+{
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=4) {
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j)[0] = (uint)(i+0);
+ (out+j)[1] = (uint)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)(i+1);
+ (out+j+2)[1] = (uint)(i+2);
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
+ (out+j+4)[0] = (uint)(i+2);
+ (out+j+4)[1] = (uint)(i+3);
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
+ (out+j+6)[0] = (uint)(i+3);
+ (out+j+6)[1] = (uint)(i+0);
+ }
+}
+static void generate_quadstrip_uint(
+ unsigned nr,
+ void *_out )
+{
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=2) {
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
+ (out+j)[0] = (uint)(i+2);
+ (out+j)[1] = (uint)(i+0);
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j+2)[0] = (uint)(i+0);
+ (out+j+2)[1] = (uint)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
+ (out+j+4)[0] = (uint)(i+1);
+ (out+j+4)[1] = (uint)(i+3);
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
+ (out+j+6)[0] = (uint)(i+3);
+ (out+j+6)[1] = (uint)(i+2);
+ }
+}
+static void generate_polygon_uint(
+ unsigned nr,
+ void *_out )
+{
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (uint)(0);
+ (out+j)[1] = (uint)(i+1);
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)(i+1);
+ (out+j+2)[1] = (uint)(i+2);
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (uint)(i+2);
+ (out+j+4)[1] = (uint)(0);
+ }
+}
+static void translate_tris_ubyte2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i+=3) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1);
+ (out+j)[0] = (ushort)in[i];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[i];
+ }
+}
+static void translate_tristrip_ubyte2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
+ (out+j)[0] = (ushort)in[i];
+ (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
+ (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
+ (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
+ (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
+ (out+j+4)[1] = (ushort)in[i];
+ }
+}
+static void translate_trifan_ubyte2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (ushort)in[0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[0];
+ }
+}
+static void translate_quads_ubyte2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=4) {
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j)[0] = (ushort)in[i+0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
+ (out+j+6)[0] = (ushort)in[i+3];
+ (out+j+6)[1] = (ushort)in[i+0];
+ }
+}
+static void translate_quadstrip_ubyte2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=2) {
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
+ (out+j)[0] = (ushort)in[i+2];
+ (out+j)[1] = (ushort)in[i+0];
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j+2)[0] = (ushort)in[i+0];
+ (out+j+2)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
+ (out+j+4)[0] = (ushort)in[i+1];
+ (out+j+4)[1] = (ushort)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
+ (out+j+6)[0] = (ushort)in[i+3];
+ (out+j+6)[1] = (ushort)in[i+2];
+ }
+}
+static void translate_polygon_ubyte2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (ushort)in[0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[0];
+ }
+}
+static void translate_tris_ubyte2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i+=3) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1);
+ (out+j)[0] = (uint)in[i];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[i];
+ }
+}
+static void translate_tristrip_ubyte2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
+ (out+j)[0] = (uint)in[i];
+ (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
+ (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
+ (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
+ (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
+ (out+j+4)[1] = (uint)in[i];
+ }
+}
+static void translate_trifan_ubyte2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (uint)in[0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[0];
+ }
+}
+static void translate_quads_ubyte2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=4) {
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j)[0] = (uint)in[i+0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
+ (out+j+6)[0] = (uint)in[i+3];
+ (out+j+6)[1] = (uint)in[i+0];
+ }
+}
+static void translate_quadstrip_ubyte2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=2) {
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
+ (out+j)[0] = (uint)in[i+2];
+ (out+j)[1] = (uint)in[i+0];
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j+2)[0] = (uint)in[i+0];
+ (out+j+2)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
+ (out+j+4)[0] = (uint)in[i+1];
+ (out+j+4)[1] = (uint)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
+ (out+j+6)[0] = (uint)in[i+3];
+ (out+j+6)[1] = (uint)in[i+2];
+ }
+}
+static void translate_polygon_ubyte2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ubyte*in = (const ubyte*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (uint)in[0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[0];
+ }
+}
+static void translate_tris_ushort2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i+=3) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1);
+ (out+j)[0] = (ushort)in[i];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[i];
+ }
+}
+static void translate_tristrip_ushort2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
+ (out+j)[0] = (ushort)in[i];
+ (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
+ (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
+ (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
+ (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
+ (out+j+4)[1] = (ushort)in[i];
+ }
+}
+static void translate_trifan_ushort2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (ushort)in[0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[0];
+ }
+}
+static void translate_quads_ushort2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=4) {
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j)[0] = (ushort)in[i+0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
+ (out+j+6)[0] = (ushort)in[i+3];
+ (out+j+6)[1] = (ushort)in[i+0];
+ }
+}
+static void translate_quadstrip_ushort2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=2) {
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
+ (out+j)[0] = (ushort)in[i+2];
+ (out+j)[1] = (ushort)in[i+0];
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j+2)[0] = (ushort)in[i+0];
+ (out+j+2)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
+ (out+j+4)[0] = (ushort)in[i+1];
+ (out+j+4)[1] = (ushort)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
+ (out+j+6)[0] = (ushort)in[i+3];
+ (out+j+6)[1] = (ushort)in[i+2];
+ }
+}
+static void translate_polygon_ushort2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (ushort)in[0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[0];
+ }
+}
+static void translate_tris_ushort2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i+=3) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1);
+ (out+j)[0] = (uint)in[i];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[i];
+ }
+}
+static void translate_tristrip_ushort2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
+ (out+j)[0] = (uint)in[i];
+ (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
+ (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
+ (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
+ (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
+ (out+j+4)[1] = (uint)in[i];
+ }
+}
+static void translate_trifan_ushort2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (uint)in[0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[0];
+ }
+}
+static void translate_quads_ushort2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=4) {
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j)[0] = (uint)in[i+0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
+ (out+j+6)[0] = (uint)in[i+3];
+ (out+j+6)[1] = (uint)in[i+0];
+ }
+}
+static void translate_quadstrip_ushort2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=2) {
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
+ (out+j)[0] = (uint)in[i+2];
+ (out+j)[1] = (uint)in[i+0];
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j+2)[0] = (uint)in[i+0];
+ (out+j+2)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
+ (out+j+4)[0] = (uint)in[i+1];
+ (out+j+4)[1] = (uint)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
+ (out+j+6)[0] = (uint)in[i+3];
+ (out+j+6)[1] = (uint)in[i+2];
+ }
+}
+static void translate_polygon_ushort2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const ushort*in = (const ushort*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (uint)in[0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[0];
+ }
+}
+static void translate_tris_uint2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i+=3) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1);
+ (out+j)[0] = (ushort)in[i];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[i];
+ }
+}
+static void translate_tristrip_uint2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
+ (out+j)[0] = (ushort)in[i];
+ (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
+ (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
+ (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
+ (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
+ (out+j+4)[1] = (ushort)in[i];
+ }
+}
+static void translate_trifan_uint2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (ushort)in[0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[0];
+ }
+}
+static void translate_quads_uint2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=4) {
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j)[0] = (ushort)in[i+0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
+ (out+j+6)[0] = (ushort)in[i+3];
+ (out+j+6)[1] = (ushort)in[i+0];
+ }
+}
+static void translate_quadstrip_uint2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=2) {
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
+ (out+j)[0] = (ushort)in[i+2];
+ (out+j)[1] = (ushort)in[i+0];
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j+2)[0] = (ushort)in[i+0];
+ (out+j+2)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
+ (out+j+4)[0] = (ushort)in[i+1];
+ (out+j+4)[1] = (ushort)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
+ (out+j+6)[0] = (ushort)in[i+3];
+ (out+j+6)[1] = (ushort)in[i+2];
+ }
+}
+static void translate_polygon_uint2ushort(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ ushort *out = (ushort*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (ushort)in[0];
+ (out+j)[1] = (ushort)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (ushort)in[i+1];
+ (out+j+2)[1] = (ushort)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (ushort)in[i+2];
+ (out+j+4)[1] = (ushort)in[0];
+ }
+}
+static void translate_tris_uint2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i+=3) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1);
+ (out+j)[0] = (uint)in[i];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[i];
+ }
+}
+static void translate_tristrip_uint2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
+ (out+j)[0] = (uint)in[i];
+ (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
+ (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
+ (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
+ debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
+ (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
+ (out+j+4)[1] = (uint)in[i];
+ }
+}
+static void translate_trifan_uint2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (uint)in[0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[0];
+ }
+}
+static void translate_quads_uint2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=4) {
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j)[0] = (uint)in[i+0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
+ (out+j+6)[0] = (uint)in[i+3];
+ (out+j+6)[1] = (uint)in[i+0];
+ }
+}
+static void translate_quadstrip_uint2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=8, i+=2) {
+ debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
+ (out+j)[0] = (uint)in[i+2];
+ (out+j)[1] = (uint)in[i+0];
+ debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
+ (out+j+2)[0] = (uint)in[i+0];
+ (out+j+2)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
+ (out+j+4)[0] = (uint)in[i+1];
+ (out+j+4)[1] = (uint)in[i+3];
+ debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
+ (out+j+6)[0] = (uint)in[i+3];
+ (out+j+6)[1] = (uint)in[i+2];
+ }
+}
+static void translate_polygon_uint2uint(
+ const void * _in,
+ unsigned nr,
+ void *_out )
+{
+ const uint*in = (const uint*)_in;
+ uint *out = (uint*)_out;
+ unsigned i, j;
+ (void)j;
+ for (j = i = 0; j < nr; j+=6, i++) {
+ debug_printf(" line %d %d\n", (int)0, (int)i+1);
+ (out+j)[0] = (uint)in[0];
+ (out+j)[1] = (uint)in[i+1];
+ debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
+ (out+j+2)[0] = (uint)in[i+1];
+ (out+j+2)[1] = (uint)in[i+2];
+ debug_printf(" line %d %d\n", (int)i+2, (int)0);
+ (out+j+4)[0] = (uint)in[i+2];
+ (out+j+4)[1] = (uint)in[0];
+ }
+}
+void u_unfilled_init( void )
+{
+ static int firsttime = 1;
+ if (!firsttime) return;
+ firsttime = 0;
+generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLES] = generate_tris_ushort;
+generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort;
+generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort;
+generate_line[OUT_USHORT][PIPE_PRIM_QUADS] = generate_quads_ushort;
+generate_line[OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort;
+generate_line[OUT_USHORT][PIPE_PRIM_POLYGON] = generate_polygon_ushort;
+generate_line[OUT_UINT][PIPE_PRIM_TRIANGLES] = generate_tris_uint;
+generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint;
+generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint;
+generate_line[OUT_UINT][PIPE_PRIM_QUADS] = generate_quads_uint;
+generate_line[OUT_UINT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint;
+generate_line[OUT_UINT][PIPE_PRIM_POLYGON] = generate_polygon_uint;
+translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort;
+translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort;
+translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort;
+translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort;
+translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort;
+translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort;
+translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint;
+translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint;
+translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint;
+translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint;
+translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint;
+translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint;
+translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort;
+translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort;
+translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort;
+translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort;
+translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort;
+translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort;
+translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint;
+translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint;
+translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint;
+translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ushort2uint;
+translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint;
+translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint;
+translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort;
+translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort;
+translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort;
+translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_uint2ushort;
+translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort;
+translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort;
+translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint;
+translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint;
+translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint;
+translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_uint2uint;
+translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint;
+translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint;
+}
+#include "indices/u_unfilled_indices.c"
diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.py b/src/gallium/auxiliary/indices/u_unfilled_gen.py
new file mode 100644
index 0000000000..d0344fe313
--- /dev/null
+++ b/src/gallium/auxiliary/indices/u_unfilled_gen.py
@@ -0,0 +1,247 @@
+#!/usr/bin/env python
+copyright = '''
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+'''
+
+GENERATE, UBYTE, USHORT, UINT = 'generate', 'ubyte', 'ushort', 'uint'
+FIRST, LAST = 'first', 'last'
+
+INTYPES = (GENERATE, UBYTE, USHORT, UINT)
+OUTTYPES = (USHORT, UINT)
+PRIMS=('tris',
+ 'trifan',
+ 'tristrip',
+ 'quads',
+ 'quadstrip',
+ 'polygon')
+
+LONGPRIMS=('PIPE_PRIM_TRIANGLES',
+ 'PIPE_PRIM_TRIANGLE_FAN',
+ 'PIPE_PRIM_TRIANGLE_STRIP',
+ 'PIPE_PRIM_QUADS',
+ 'PIPE_PRIM_QUAD_STRIP',
+ 'PIPE_PRIM_POLYGON')
+
+longprim = dict(zip(PRIMS, LONGPRIMS))
+intype_idx = dict(ubyte='IN_UBYTE', ushort='IN_USHORT', uint='IN_UINT')
+outtype_idx = dict(ushort='OUT_USHORT', uint='OUT_UINT')
+
+
+def prolog():
+ print '''/* File automatically generated by u_unfilled_gen.py */'''
+ print copyright
+ print r'''
+
+/**
+ * @file
+ * Functions to translate and generate index lists
+ */
+
+#include "indices/u_indices.h"
+#include "indices/u_indices_priv.h"
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+#include "pipe/p_defines.h"
+#include "util/u_memory.h"
+
+
+static unsigned out_size_idx( unsigned index_size )
+{
+ switch (index_size) {
+ case 4: return OUT_UINT;
+ case 2: return OUT_USHORT;
+ default: assert(0); return OUT_USHORT;
+ }
+}
+
+static unsigned in_size_idx( unsigned index_size )
+{
+ switch (index_size) {
+ case 4: return IN_UINT;
+ case 2: return IN_USHORT;
+ case 1: return IN_UBYTE;
+ default: assert(0); return IN_UBYTE;
+ }
+}
+
+
+static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT];
+static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT];
+
+'''
+
+def vert( intype, outtype, v0 ):
+ if intype == GENERATE:
+ return '(' + outtype + ')(' + v0 + ')'
+ else:
+ return '(' + outtype + ')in[' + v0 + ']'
+
+def line( intype, outtype, ptr, v0, v1 ):
+ print ' debug_printf(" line %d %d\\n", (int)' + v0 + ', (int)' + v1 + ');'
+ print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
+ print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
+
+# XXX: have the opportunity here to avoid over-drawing shared lines in
+# tristrips, fans, etc, by integrating this into the calling functions
+# and only emitting each line at most once.
+#
+def do_tri( intype, outtype, ptr, v0, v1, v2 ):
+ line( intype, outtype, ptr, v0, v1 )
+ line( intype, outtype, ptr + '+2', v1, v2 )
+ line( intype, outtype, ptr + '+4', v2, v0 )
+
+def do_quad( intype, outtype, ptr, v0, v1, v2, v3 ):
+ line( intype, outtype, ptr, v0, v1 )
+ line( intype, outtype, ptr + '+2', v1, v2 )
+ line( intype, outtype, ptr + '+4', v2, v3 )
+ line( intype, outtype, ptr + '+6', v3, v0 )
+
+def name(intype, outtype, prim):
+ if intype == GENERATE:
+ return 'generate_' + prim + '_' + outtype
+ else:
+ return 'translate_' + prim + '_' + intype + '2' + outtype
+
+def preamble(intype, outtype, prim):
+ print 'static void ' + name( intype, outtype, prim ) + '('
+ if intype != GENERATE:
+ print ' const void * _in,'
+ print ' unsigned nr,'
+ print ' void *_out )'
+ print '{'
+ if intype != GENERATE:
+ print ' const ' + intype + '*in = (const ' + intype + '*)_in;'
+ print ' ' + outtype + ' *out = (' + outtype + '*)_out;'
+ print ' unsigned i, j;'
+ print ' (void)j;'
+
+def postamble():
+ print '}'
+
+
+def tris(intype, outtype):
+ preamble(intype, outtype, prim='tris')
+ print ' for (j = i = 0; j < nr; j+=6, i+=3) { '
+ do_tri( intype, outtype, 'out+j', 'i', 'i+1', 'i+2' );
+ print ' }'
+ postamble()
+
+
+def tristrip(intype, outtype):
+ preamble(intype, outtype, prim='tristrip')
+ print ' for (j = i = 0; j < nr; j+=6, i++) { '
+ do_tri( intype, outtype, 'out+j', 'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' );
+ print ' }'
+ postamble()
+
+
+def trifan(intype, outtype):
+ preamble(intype, outtype, prim='trifan')
+ print ' for (j = i = 0; j < nr; j+=6, i++) { '
+ do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' );
+ print ' }'
+ postamble()
+
+
+
+def polygon(intype, outtype):
+ preamble(intype, outtype, prim='polygon')
+ print ' for (j = i = 0; j < nr; j+=6, i++) { '
+ do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' );
+ print ' }'
+ postamble()
+
+
+def quads(intype, outtype):
+ preamble(intype, outtype, prim='quads')
+ print ' for (j = i = 0; j < nr; j+=8, i+=4) { '
+ do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' );
+ print ' }'
+ postamble()
+
+
+def quadstrip(intype, outtype):
+ preamble(intype, outtype, prim='quadstrip')
+ print ' for (j = i = 0; j < nr; j+=8, i+=2) { '
+ do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' );
+ print ' }'
+ postamble()
+
+
+def emit_funcs():
+ for intype in INTYPES:
+ for outtype in OUTTYPES:
+ tris(intype, outtype)
+ tristrip(intype, outtype)
+ trifan(intype, outtype)
+ quads(intype, outtype)
+ quadstrip(intype, outtype)
+ polygon(intype, outtype)
+
+def init(intype, outtype, prim):
+ if intype == GENERATE:
+ print ('generate_line[' +
+ outtype_idx[outtype] +
+ '][' + longprim[prim] +
+ '] = ' + name( intype, outtype, prim ) + ';')
+ else:
+ print ('translate_line[' +
+ intype_idx[intype] +
+ '][' + outtype_idx[outtype] +
+ '][' + longprim[prim] +
+ '] = ' + name( intype, outtype, prim ) + ';')
+
+
+def emit_all_inits():
+ for intype in INTYPES:
+ for outtype in OUTTYPES:
+ for prim in PRIMS:
+ init(intype, outtype, prim)
+
+def emit_init():
+ print 'void u_unfilled_init( void )'
+ print '{'
+ print ' static int firsttime = 1;'
+ print ' if (!firsttime) return;'
+ print ' firsttime = 0;'
+ emit_all_inits()
+ print '}'
+
+
+
+
+def epilog():
+ print '#include "indices/u_unfilled_indices.c"'
+
+
+def main():
+ prolog()
+ emit_funcs()
+ emit_init()
+ epilog()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/src/gallium/auxiliary/indices/u_unfilled_indices.c b/src/gallium/auxiliary/indices/u_unfilled_indices.c
new file mode 100644
index 0000000000..26c5d4d4c7
--- /dev/null
+++ b/src/gallium/auxiliary/indices/u_unfilled_indices.c
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "u_indices.h"
+#include "u_indices_priv.h"
+
+
+static void translate_ubyte_ushort( const void *in,
+ unsigned nr,
+ void *out )
+{
+ const ubyte *in_ub = (const ubyte *)in;
+ ushort *out_us = (ushort *)out;
+ unsigned i;
+ for (i = 0; i < nr; i++)
+ out_us[i] = (ushort) in_ub[i];
+}
+
+static void translate_memcpy_ushort( const void *in,
+ unsigned nr,
+ void *out )
+{
+ memcpy(out, in, nr*sizeof(short));
+}
+
+static void translate_memcpy_uint( const void *in,
+ unsigned nr,
+ void *out )
+{
+ memcpy(out, in, nr*sizeof(int));
+}
+
+
+static void generate_linear_ushort( unsigned nr,
+ void *out )
+{
+ ushort *out_us = (ushort *)out;
+ unsigned i;
+ for (i = 0; i < nr; i++)
+ out_us[i] = (ushort) i;
+}
+
+static void generate_linear_uint( unsigned nr,
+ void *out )
+{
+ unsigned *out_ui = (unsigned *)out;
+ unsigned i;
+ for (i = 0; i < nr; i++)
+ out_ui[i] = i;
+}
+
+
+static unsigned nr_lines( unsigned prim,
+ unsigned nr )
+{
+ switch (prim) {
+ case PIPE_PRIM_TRIANGLES:
+ return (nr / 3) * 6;
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ return (nr - 2) * 6;
+ case PIPE_PRIM_TRIANGLE_FAN:
+ return (nr - 2) * 6;
+ case PIPE_PRIM_QUADS:
+ return (nr / 4) * 8;
+ case PIPE_PRIM_QUAD_STRIP:
+ return (nr - 2) / 2 * 8;
+ case PIPE_PRIM_POLYGON:
+ return (nr - 2) * 6;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+
+
+int u_unfilled_translator( unsigned prim,
+ unsigned in_index_size,
+ unsigned nr,
+ unsigned unfilled_mode,
+ unsigned *out_prim,
+ unsigned *out_index_size,
+ unsigned *out_nr,
+ u_translate_func *out_translate )
+{
+ unsigned in_idx;
+ unsigned out_idx;
+
+ u_unfilled_init();
+
+ in_idx = in_size_idx(in_index_size);
+ *out_index_size = (in_index_size == 4) ? 4 : 2;
+ out_idx = out_size_idx(*out_index_size);
+
+ if (unfilled_mode == PIPE_POLYGON_MODE_POINT)
+ {
+ *out_prim = PIPE_PRIM_POINTS;
+ *out_nr = nr;
+
+ switch (in_index_size)
+ {
+ case 1:
+ *out_translate = translate_ubyte_ushort;
+ return U_TRANSLATE_NORMAL;
+ case 2:
+ *out_translate = translate_memcpy_uint;
+ return U_TRANSLATE_MEMCPY;
+ case 4:
+ *out_translate = translate_memcpy_ushort;
+ return U_TRANSLATE_MEMCPY;
+ default:
+ *out_translate = translate_memcpy_uint;
+ *out_nr = 0;
+ assert(0);
+ return U_TRANSLATE_ERROR;
+ }
+ }
+ else {
+ assert(unfilled_mode == PIPE_POLYGON_MODE_LINE);
+ *out_prim = PIPE_PRIM_LINES;
+ *out_translate = translate_line[in_idx][out_idx][prim];
+ *out_nr = nr_lines( prim, nr );
+ return U_TRANSLATE_NORMAL;
+ }
+}
+
+
+
+int u_unfilled_generator( unsigned prim,
+ unsigned start,
+ unsigned nr,
+ unsigned unfilled_mode,
+ unsigned *out_prim,
+ unsigned *out_index_size,
+ unsigned *out_nr,
+ u_generate_func *out_generate )
+{
+ unsigned out_idx;
+
+ u_unfilled_init();
+
+ *out_index_size = ((start + nr) > 0xfffe) ? 4 : 2;
+ out_idx = out_size_idx(*out_index_size);
+
+ if (unfilled_mode == PIPE_POLYGON_MODE_POINT) {
+
+ if (*out_index_size == 4)
+ *out_generate = generate_linear_uint;
+ else
+ *out_generate = generate_linear_ushort;
+
+ *out_prim = PIPE_PRIM_POINTS;
+ *out_nr = nr;
+ return U_GENERATE_LINEAR;
+ }
+ else {
+ assert(unfilled_mode == PIPE_POLYGON_MODE_LINE);
+ *out_prim = PIPE_PRIM_LINES;
+ *out_generate = generate_line[out_idx][prim];
+ *out_nr = nr_lines( prim, nr );
+
+ return U_GENERATE_REUSABLE;
+ }
+}
+
diff --git a/src/gallium/auxiliary/pipebuffer/Makefile b/src/gallium/auxiliary/pipebuffer/Makefile
index 3b501c51df..1c00ba8d98 100644
--- a/src/gallium/auxiliary/pipebuffer/Makefile
+++ b/src/gallium/auxiliary/pipebuffer/Makefile
@@ -17,6 +17,3 @@ C_SOURCES = \
pb_validate.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index d8f1f02d68..2a1315922a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -45,10 +45,9 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_error.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
#ifdef __cplusplus
@@ -159,7 +158,7 @@ pb_map(struct pb_buffer *buf,
assert(buf);
if(!buf)
return NULL;
- assert(buf->base.refcount > 0);
+ assert(p_atomic_read(&buf->base.reference.count) > 0);
return buf->vtbl->map(buf, flags);
}
@@ -170,7 +169,7 @@ pb_unmap(struct pb_buffer *buf)
assert(buf);
if(!buf)
return;
- assert(buf->base.refcount > 0);
+ assert(p_atomic_read(&buf->base.reference.count) > 0);
buf->vtbl->unmap(buf);
}
@@ -186,7 +185,7 @@ pb_get_base_buffer( struct pb_buffer *buf,
offset = 0;
return;
}
- assert(buf->base.refcount > 0);
+ assert(p_atomic_read(&buf->base.reference.count) > 0);
assert(buf->vtbl->get_base_buffer);
buf->vtbl->get_base_buffer(buf, base_buf, offset);
assert(*base_buf);
@@ -222,29 +221,18 @@ pb_destroy(struct pb_buffer *buf)
assert(buf);
if(!buf)
return;
- assert(buf->base.refcount == 0);
+ assert(p_atomic_read(&buf->base.reference.count) == 0);
buf->vtbl->destroy(buf);
}
-
-/* XXX: thread safety issues!
- */
static INLINE void
pb_reference(struct pb_buffer **dst,
struct pb_buffer *src)
{
- if (src) {
- assert(src->base.refcount);
- src->base.refcount++;
- }
-
- if (*dst) {
- assert((*dst)->base.refcount);
- if(--(*dst)->base.refcount == 0)
- pb_destroy( *dst );
- }
+ struct pb_buffer *old = *dst;
- *dst = src;
+ if (pipe_reference((struct pipe_reference**)dst, &src->base.reference))
+ pb_destroy( old );
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index f9e6226436..1bdf7a0b2d 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -36,14 +36,14 @@
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
#include <unistd.h>
#include <sched.h>
#endif
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
@@ -66,8 +66,12 @@ struct fenced_buffer_list
struct pb_fence_ops *ops;
size_t numDelayed;
-
struct list_head delayed;
+
+#ifdef DEBUG
+ size_t numUnfenced;
+ struct list_head unfenced;
+#endif
};
@@ -111,12 +115,15 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf)
{
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- assert(fenced_buf->base.base.refcount);
+ assert(p_atomic_read(&fenced_buf->base.base.reference.count));
assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
assert(fenced_buf->fence);
- assert(!fenced_buf->head.prev);
- assert(!fenced_buf->head.next);
+#ifdef DEBUG
+ LIST_DEL(&fenced_buf->head);
+ assert(fenced_list->numUnfenced);
+ --fenced_list->numUnfenced;
+#endif
LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
++fenced_list->numDelayed;
}
@@ -128,8 +135,19 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf)
static INLINE void
_fenced_buffer_destroy(struct fenced_buffer *fenced_buf)
{
- assert(!fenced_buf->base.base.refcount);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+
+ assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0);
assert(!fenced_buf->fence);
+#ifdef DEBUG
+ assert(fenced_buf->head.prev);
+ assert(fenced_buf->head.next);
+ LIST_DEL(&fenced_buf->head);
+ assert(fenced_list->numUnfenced);
+ --fenced_list->numUnfenced;
+#else
+ (void)fenced_list;
+#endif
pb_reference(&fenced_buf->buffer, NULL);
FREE(fenced_buf);
}
@@ -149,16 +167,21 @@ _fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
assert(fenced_buf->head.prev);
assert(fenced_buf->head.next);
- LIST_DEL(&fenced_buf->head);
-#ifdef DEBUG
- fenced_buf->head.prev = NULL;
- fenced_buf->head.next = NULL;
-#endif
+ LIST_DEL(&fenced_buf->head);
assert(fenced_list->numDelayed);
--fenced_list->numDelayed;
- if(!fenced_buf->base.base.refcount)
+#ifdef DEBUG
+ LIST_ADDTAIL(&fenced_buf->head, &fenced_list->unfenced);
+ ++fenced_list->numUnfenced;
+#endif
+
+ /**
+ * FIXME!!!
+ */
+
+ if(!p_atomic_read(&fenced_buf->base.base.reference.count))
_fenced_buffer_destroy(fenced_buf);
}
@@ -234,7 +257,7 @@ fenced_buffer_destroy(struct pb_buffer *buf)
struct fenced_buffer_list *fenced_list = fenced_buf->list;
pipe_mutex_lock(fenced_list->mutex);
- assert(fenced_buf->base.base.refcount == 0);
+ assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0);
if (fenced_buf->fence) {
struct pb_fence_ops *ops = fenced_list->ops;
if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
@@ -265,16 +288,26 @@ fenced_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+ struct pb_fence_ops *ops = fenced_list->ops;
void *map;
- assert(flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE);
- assert(!(flags & ~PIPE_BUFFER_USAGE_CPU_READ_WRITE));
- flags &= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
- /* Check for GPU read/write access */
- if(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) {
- /* Wait for the GPU to finish writing */
- _fenced_buffer_finish(fenced_buf);
+ /* Serialize writes */
+ if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) ||
+ ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) {
+ if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+ /* Don't wait for the GPU to finish writing */
+ if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0)
+ _fenced_buffer_remove(fenced_list, fenced_buf);
+ else
+ return NULL;
+ }
+ else {
+ /* Wait for the GPU to finish writing */
+ _fenced_buffer_finish(fenced_buf);
+ }
}
#if 0
@@ -288,7 +321,7 @@ fenced_buffer_map(struct pb_buffer *buf,
map = pb_map(fenced_buf->buffer, flags);
if(map) {
++fenced_buf->mapcount;
- fenced_buf->flags |= flags;
+ fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE;
}
return map;
@@ -432,7 +465,7 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
return NULL;
}
- buf->base.base.refcount = 1;
+ pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = buffer->base.alignment;
buf->base.base.usage = buffer->base.usage;
buf->base.base.size = buffer->base.size;
@@ -441,6 +474,13 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
buf->buffer = buffer;
buf->list = fenced_list;
+#ifdef DEBUG
+ pipe_mutex_lock(fenced_list->mutex);
+ LIST_ADDTAIL(&buf->head, &fenced_list->unfenced);
+ ++fenced_list->numUnfenced;
+ pipe_mutex_unlock(fenced_list->mutex);
+#endif
+
return &buf->base;
}
@@ -457,9 +497,13 @@ fenced_buffer_list_create(struct pb_fence_ops *ops)
fenced_list->ops = ops;
LIST_INITHEAD(&fenced_list->delayed);
-
fenced_list->numDelayed = 0;
+#ifdef DEBUG
+ LIST_INITHEAD(&fenced_list->unfenced);
+ fenced_list->numUnfenced = 0;
+#endif
+
pipe_mutex_init(fenced_list->mutex);
return fenced_list;
@@ -476,6 +520,51 @@ fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
}
+#ifdef DEBUG
+void
+fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
+{
+ struct pb_fence_ops *ops = fenced_list->ops;
+ struct list_head *curr, *next;
+ struct fenced_buffer *fenced_buf;
+
+ pipe_mutex_lock(fenced_list->mutex);
+
+ debug_printf("%10s %7s %10s %s\n",
+ "buffer", "reference.count", "fence", "signalled");
+
+ curr = fenced_list->unfenced.next;
+ next = curr->next;
+ while(curr != &fenced_list->unfenced) {
+ fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
+ assert(!fenced_buf->fence);
+ debug_printf("%10p %7u\n",
+ fenced_buf,
+ fenced_buf->base.base.reference.count);
+ curr = next;
+ next = curr->next;
+ }
+
+ curr = fenced_list->delayed.next;
+ next = curr->next;
+ while(curr != &fenced_list->delayed) {
+ int signaled;
+ fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
+ signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
+ debug_printf("%10p %7u %10p %s\n",
+ fenced_buf,
+ fenced_buf->base.base.reference.count,
+ fenced_buf->fence,
+ signaled == 0 ? "y" : "n");
+ curr = next;
+ next = curr->next;
+ }
+
+ pipe_mutex_unlock(fenced_list->mutex);
+}
+#endif
+
+
void
fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
{
@@ -484,13 +573,17 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
/* Wait on outstanding fences */
while (fenced_list->numDelayed) {
pipe_mutex_unlock(fenced_list->mutex);
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
sched_yield();
#endif
_fenced_buffer_list_check_free(fenced_list, 1);
pipe_mutex_lock(fenced_list->mutex);
}
+#ifdef DEBUG
+ //assert(!fenced_list->numUnfenced);
+#endif
+
pipe_mutex_unlock(fenced_list->mutex);
fenced_list->ops->destroy(fenced_list->ops);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
index d1c9d4c17d..034ca1e024 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
@@ -51,7 +51,7 @@
#define PB_BUFFER_FENCED_H_
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#ifdef __cplusplus
@@ -114,6 +114,13 @@ void
fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
int wait);
+
+#ifdef DEBUG
+void
+fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list);
+#endif
+
+
void
fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
index 53f497cfb0..689fd74771 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
@@ -34,7 +34,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"
@@ -132,7 +132,7 @@ pb_malloc_buffer_create(size_t size,
if(!buf)
return NULL;
- buf->base.base.refcount = 1;
+ pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = desc->alignment;
buf->base.base.usage = desc->usage;
buf->base.base.size = size;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index fec8db91c7..74077f8277 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -200,10 +200,11 @@ pb_ondemand_manager_create(struct pb_manager *provider);
/**
* Debug buffer manager to detect buffer under- and overflows.
*
- * Band size should be a multiple of the largest alignment
+ * Under/overflow sizes should be a multiple of the largest alignment
*/
struct pb_manager *
-pb_debug_manager_create(struct pb_manager *provider, size_t band_size);
+pb_debug_manager_create(struct pb_manager *provider,
+ size_t underflow_size, size_t overflow_size);
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
index c956924cc7..db67d46c56 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
@@ -34,7 +34,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index a168853713..010a2ecc1f 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -35,7 +35,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
@@ -112,7 +112,7 @@ _pb_cache_buffer_destroy(struct pb_cache_buffer *buf)
LIST_DEL(&buf->head);
assert(mgr->numDelayed);
--mgr->numDelayed;
- assert(!buf->base.base.refcount);
+ assert(p_atomic_read(&buf->base.base.reference.count) == 0);
pb_reference(&buf->buffer, NULL);
FREE(buf);
}
@@ -153,7 +153,7 @@ pb_cache_buffer_destroy(struct pb_buffer *_buf)
struct pb_cache_manager *mgr = buf->mgr;
pipe_mutex_lock(mgr->mutex);
- assert(buf->base.base.refcount == 0);
+ assert(p_atomic_read(&buf->base.base.reference.count) == 0);
_pb_cache_buffer_list_check_free(mgr);
@@ -293,7 +293,8 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
if(buf) {
LIST_DEL(&buf->head);
pipe_mutex_unlock(mgr->mutex);
- ++buf->base.base.refcount;
+ /* Increase refcount */
+ pb_reference((struct pb_buffer**)&buf, &buf->base);
return &buf->base;
}
@@ -309,12 +310,12 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
return NULL;
}
- assert(buf->buffer->base.refcount >= 1);
+ assert(p_atomic_read(&buf->buffer->base.reference.count) >= 1);
assert(pb_check_alignment(desc->alignment, buf->buffer->base.alignment));
assert(pb_check_usage(desc->usage, buf->buffer->base.usage));
assert(buf->buffer->base.size >= size);
- buf->base.base.refcount = 1;
+ pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = buf->buffer->base.alignment;
buf->base.base.usage = buf->buffer->base.usage;
buf->base.base.size = buf->buffer->base.size;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index 26d9c24aec..478682dbee 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -34,7 +34,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -78,7 +78,8 @@ struct pb_debug_manager
struct pb_manager *provider;
- size_t band_size;
+ size_t underflow_size;
+ size_t overflow_size;
};
@@ -205,9 +206,9 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
static void
pb_debug_buffer_destroy(struct pb_buffer *_buf)
{
- struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
+ struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
- assert(!buf->base.base.refcount);
+ assert(p_atomic_read(&buf->base.base.reference.count) == 0);
pb_debug_buffer_check(buf);
@@ -301,7 +302,7 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
if(!buf)
return NULL;
- real_size = size + 2*mgr->band_size;
+ real_size = mgr->underflow_size + size + mgr->overflow_size;
real_desc = *desc;
real_desc.usage |= PIPE_BUFFER_USAGE_CPU_WRITE;
real_desc.usage |= PIPE_BUFFER_USAGE_CPU_READ;
@@ -314,12 +315,12 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
return NULL;
}
- assert(buf->buffer->base.refcount >= 1);
+ assert(p_atomic_read(&buf->buffer->base.reference.count) >= 1);
assert(pb_check_alignment(real_desc.alignment, buf->buffer->base.alignment));
assert(pb_check_usage(real_desc.usage, buf->buffer->base.usage));
assert(buf->buffer->base.size >= real_size);
- buf->base.base.refcount = 1;
+ pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = desc->alignment;
buf->base.base.usage = desc->usage;
buf->base.base.size = size;
@@ -327,7 +328,7 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
buf->base.vtbl = &pb_debug_buffer_vtbl;
buf->mgr = mgr;
- buf->underflow_size = mgr->band_size;
+ buf->underflow_size = mgr->underflow_size;
buf->overflow_size = buf->buffer->base.size - buf->underflow_size - size;
pb_debug_buffer_fill(buf);
@@ -356,7 +357,8 @@ pb_debug_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
-pb_debug_manager_create(struct pb_manager *provider, size_t band_size)
+pb_debug_manager_create(struct pb_manager *provider,
+ size_t underflow_size, size_t overflow_size)
{
struct pb_debug_manager *mgr;
@@ -371,7 +373,8 @@ pb_debug_manager_create(struct pb_manager *provider, size_t band_size)
mgr->base.create_buffer = pb_debug_manager_create_buffer;
mgr->base.flush = pb_debug_manager_flush;
mgr->provider = provider;
- mgr->band_size = band_size;
+ mgr->underflow_size = underflow_size;
+ mgr->overflow_size = overflow_size;
return &mgr->base;
}
@@ -381,7 +384,8 @@ pb_debug_manager_create(struct pb_manager *provider, size_t band_size)
struct pb_manager *
-pb_debug_manager_create(struct pb_manager *provider, size_t band_size)
+pb_debug_manager_create(struct pb_manager *provider,
+ size_t underflow_size, size_t overflow_size)
{
return provider;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
index 47e9fee533..144db5669b 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
@@ -34,7 +34,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
@@ -79,6 +79,10 @@ fenced_bufmgr_create_buffer(struct pb_manager *mgr,
buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size, desc);
if(!buf) {
+#if 0
+ fenced_buffer_list_dump(fenced_mgr->fenced_list);
+#endif
+
/* give up */
return NULL;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index 2f5a5d8ea0..fb18dcc5dc 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -34,7 +34,7 @@
#include "pipe/p_defines.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
@@ -97,11 +97,11 @@ mm_buffer_destroy(struct pb_buffer *buf)
struct mm_buffer *mm_buf = mm_buffer(buf);
struct mm_pb_manager *mm = mm_buf->mgr;
- assert(buf->base.refcount == 0);
+ assert(p_atomic_read(&mm_buf->base.base.reference.count) == 0);
pipe_mutex_lock(mm->mutex);
u_mmFreeMem(mm_buf->block);
- FREE(buf);
+ FREE(mm_buf);
pipe_mutex_unlock(mm->mutex);
}
@@ -189,7 +189,7 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
return NULL;
}
- mm_buf->base.base.refcount = 1;
+ pipe_reference_init(&mm_buf->base.base.reference, 1);
mm_buf->base.base.alignment = desc->alignment;
mm_buf->base.base.usage = desc->usage;
mm_buf->base.base.size = size;
@@ -204,13 +204,9 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
#if 0
mmDumpMemInfo(mm->heap);
#endif
-
- mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0);
- if(!mm_buf->block) {
- FREE(mm_buf);
- pipe_mutex_unlock(mm->mutex);
- return NULL;
- }
+ FREE(mm_buf);
+ pipe_mutex_unlock(mm->mutex);
+ return NULL;
}
/* Some sanity checks */
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
index ba02a84e62..4f7e6b1c4d 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
@@ -34,7 +34,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"
@@ -242,7 +242,7 @@ pb_ondemand_manager_create_buffer(struct pb_manager *_mgr,
if(!buf)
return NULL;
- buf->base.base.refcount = 1;
+ pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = desc->alignment;
buf->base.base.usage = desc->usage;
buf->base.base.size = size;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
index a6ff37653e..75b95e132e 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
@@ -36,7 +36,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
@@ -108,7 +108,7 @@ pool_buffer_destroy(struct pb_buffer *buf)
struct pool_buffer *pool_buf = pool_buffer(buf);
struct pool_pb_manager *pool = pool_buf->mgr;
- assert(pool_buf->base.base.refcount == 0);
+ assert(p_atomic_read(&pool_buf->base.base.reference.count) == 0);
pipe_mutex_lock(pool->mutex);
LIST_ADD(&pool_buf->head, &pool->free);
@@ -216,8 +216,8 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr,
pipe_mutex_unlock(pool->mutex);
pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
- assert(pool_buf->base.base.refcount == 0);
- pool_buf->base.base.refcount = 1;
+ assert(p_atomic_read(&pool_buf->base.base.reference.count) == 0);
+ pipe_reference_init(&pool_buf->base.base.reference, 1);
pool_buf->base.base.alignment = desc->alignment;
pool_buf->base.base.usage = desc->usage;
@@ -295,7 +295,7 @@ pool_bufmgr_create(struct pb_manager *provider,
pool_buf = pool->bufs;
for (i = 0; i < numBufs; ++i) {
- pool_buf->base.base.refcount = 0;
+ pipe_reference_init(&pool_buf->base.base.reference, 0);
pool_buf->base.base.alignment = 0;
pool_buf->base.base.usage = 0;
pool_buf->base.base.size = bufSize;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index 9b9fedccb4..a431fd5211 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 "pipe/p_error.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
@@ -202,7 +202,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf)
pipe_mutex_lock(mgr->mutex);
- assert(buf->base.base.refcount == 0);
+ assert(p_atomic_read(&buf->base.base.reference.count) == 0);
buf->mapCount = 0;
@@ -340,7 +340,7 @@ pb_slab_create(struct pb_slab_manager *mgr)
buf = slab->buffers;
for (i=0; i < numBuffers; ++i) {
- buf->base.base.refcount = 0;
+ pipe_reference_init(&buf->base.base.reference, 0);
buf->base.base.size = mgr->bufSize;
buf->base.base.alignment = 0;
buf->base.base.usage = 0;
@@ -419,7 +419,7 @@ pb_slab_manager_create_buffer(struct pb_manager *_mgr,
pipe_mutex_unlock(mgr->mutex);
buf = LIST_ENTRY(struct pb_slab_buffer, list, head);
- ++buf->base.base.refcount;
+ pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = desc->alignment;
buf->base.base.usage = desc->usage;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c
index 94532bb4ce..150fd50618 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_validate.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c
@@ -36,7 +36,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
#include "util/u_memory.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pb_buffer.h"
#include "pb_buffer_fenced.h"
diff --git a/src/gallium/auxiliary/rtasm/Makefile b/src/gallium/auxiliary/rtasm/Makefile
index 252dc5274a..ab8ea464c6 100644
--- a/src/gallium/auxiliary/rtasm/Makefile
+++ b/src/gallium/auxiliary/rtasm/Makefile
@@ -11,6 +11,3 @@ C_SOURCES = \
rtasm_ppc_spe.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/rtasm/rtasm_cpu.c b/src/gallium/auxiliary/rtasm/rtasm_cpu.c
index 5499018b21..03bdd47238 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_cpu.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_cpu.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "rtasm_cpu.h"
diff --git a/src/gallium/auxiliary/rtasm/rtasm_execmem.c b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
index be7433baf8..1f0923b683 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_execmem.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
@@ -31,14 +31,18 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
#include "rtasm_execmem.h"
+#if defined(PIPE_OS_BSD)
+#define MAP_ANONYMOUS MAP_ANON
+#endif
-#if defined(PIPE_OS_LINUX)
+
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
/*
@@ -114,7 +118,7 @@ rtasm_exec_free(void *addr)
}
-#else /* PIPE_OS_LINUX */
+#else /* PIPE_OS_LINUX || PIPE_OS_BSD */
/*
* Just use regular memory.
@@ -134,4 +138,4 @@ rtasm_exec_free(void *addr)
}
-#endif /* PIPE_OS_LINUX */
+#endif /* PIPE_OS_LINUX || PIPE_OS_BSD */
diff --git a/src/gallium/auxiliary/rtasm/rtasm_ppc.c b/src/gallium/auxiliary/rtasm/rtasm_ppc.c
index 1bb9026205..e3586482db 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_ppc.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_ppc.c
@@ -38,7 +38,7 @@
#include <stdio.h>
#include "util/u_memory.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "rtasm_execmem.h"
#include "rtasm_ppc.h"
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
index 99ee74cf14..57fcf6de2a 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
@@ -26,7 +26,7 @@
#if defined(PIPE_ARCH_X86)
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_pointer.h"
#include "rtasm_execmem.h"
diff --git a/src/gallium/auxiliary/sct/Makefile b/src/gallium/auxiliary/sct/Makefile
index 516d1756cf..a7d111b689 100644
--- a/src/gallium/auxiliary/sct/Makefile
+++ b/src/gallium/auxiliary/sct/Makefile
@@ -7,6 +7,3 @@ C_SOURCES = \
sct.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/sct/sct.c b/src/gallium/auxiliary/sct/sct.c
index 49bb7ea92e..722d2b7e66 100644
--- a/src/gallium/auxiliary/sct/sct.c
+++ b/src/gallium/auxiliary/sct/sct.c
@@ -28,7 +28,6 @@
#include "util/u_memory.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
#include "sct.h"
@@ -372,7 +371,7 @@ sct_flush_textures(struct surface_context_tracker *sct,
for (tl = ci->textures_used; tl; tl = next) {
next = tl->next;
- pipe_texture_release(&tl->texture);
+ pipe_texture_reference(&tl->texture, NULL);
FREE(tl);
}
ci->textures_used = NULL;
diff --git a/src/gallium/auxiliary/tgsi/Makefile b/src/gallium/auxiliary/tgsi/Makefile
index d7df9490cf..b4900e8dba 100644
--- a/src/gallium/auxiliary/tgsi/Makefile
+++ b/src/gallium/auxiliary/tgsi/Makefile
@@ -19,6 +19,3 @@ C_SOURCES = \
tgsi_util.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt
new file mode 100644
index 0000000000..b83abd4093
--- /dev/null
+++ b/src/gallium/auxiliary/tgsi/tgsi-instruction-set.txt
@@ -0,0 +1,1036 @@
+TGSI Instruction Specification
+==============================
+==============================
+
+
+1 Instruction Set Operations
+=============================
+
+
+1.1 GL_NV_vertex_program
+-------------------------
+
+
+1.1.1 ARL - Address Register Load
+
+ dst.x = floor(src.x)
+ dst.y = floor(src.y)
+ dst.z = floor(src.z)
+ dst.w = floor(src.w)
+
+
+1.1.2 MOV - Move
+
+ dst.x = src.x
+ dst.y = src.y
+ dst.z = src.z
+ dst.w = src.w
+
+
+1.1.3 LIT - Light Coefficients
+
+ dst.x = 1.0
+ dst.y = max(src.x, 0.0)
+ dst.z = (src.x > 0.0) ? pow(max(src.y, 0.0), clamp(src.w, -128.0, 128.0)) : 0.0
+ dst.w = 1.0
+
+
+1.1.4 RCP - Reciprocal
+
+ dst.x = 1.0 / src.x
+ dst.y = 1.0 / src.x
+ dst.z = 1.0 / src.x
+ dst.w = 1.0 / src.x
+
+
+1.1.5 RSQ - Reciprocal Square Root
+
+ dst.x = 1.0 / sqrt(abs(src.x))
+ dst.y = 1.0 / sqrt(abs(src.x))
+ dst.z = 1.0 / sqrt(abs(src.x))
+ dst.w = 1.0 / sqrt(abs(src.x))
+
+
+1.1.6 EXP - Approximate Exponential Base 2
+
+ dst.x = pow(2.0, floor(src.x))
+ dst.y = src.x - floor(src.x)
+ dst.z = pow(2.0, src.x)
+ dst.w = 1.0
+
+
+1.1.7 LOG - Approximate Logarithm Base 2
+
+ dst.x = floor(lg2(abs(src.x)))
+ dst.y = abs(src.x) / pow(2.0, floor(lg2(abs(src.x))))
+ dst.z = lg2(abs(src.x))
+ dst.w = 1.0
+
+
+1.1.8 MUL - Multiply
+
+ dst.x = src0.x * src1.x
+ dst.y = src0.y * src1.y
+ dst.z = src0.z * src1.z
+ dst.w = src0.w * src1.w
+
+
+1.1.9 ADD - Add
+
+ dst.x = src0.x + src1.x
+ dst.y = src0.y + src1.y
+ dst.z = src0.z + src1.z
+ dst.w = src0.w + src1.w
+
+
+1.1.10 DP3 - 3-component Dot Product
+
+ dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
+ dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
+ dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
+ dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
+
+
+1.1.11 DP4 - 4-component Dot Product
+
+ dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
+ dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
+ dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
+ dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
+
+
+1.1.12 DST - Distance Vector
+
+ dst.x = 1.0
+ dst.y = src0.y * src1.y
+ dst.z = src0.z
+ dst.w = src1.w
+
+
+1.1.13 MIN - Minimum
+
+ dst.x = min(src0.x, src1.x)
+ dst.y = min(src0.y, src1.y)
+ dst.z = min(src0.z, src1.z)
+ dst.w = min(src0.w, src1.w)
+
+
+1.1.14 MAX - Maximum
+
+ dst.x = max(src0.x, src1.x)
+ dst.y = max(src0.y, src1.y)
+ dst.z = max(src0.z, src1.z)
+ dst.w = max(src0.w, src1.w)
+
+
+1.1.15 SLT - Set On Less Than
+
+ dst.x = (src0.x < src1.x) ? 1.0 : 0.0
+ dst.y = (src0.y < src1.y) ? 1.0 : 0.0
+ dst.z = (src0.z < src1.z) ? 1.0 : 0.0
+ dst.w = (src0.w < src1.w) ? 1.0 : 0.0
+
+
+1.1.16 SGE - Set On Greater Equal Than
+
+ dst.x = (src0.x >= src1.x) ? 1.0 : 0.0
+ dst.y = (src0.y >= src1.y) ? 1.0 : 0.0
+ dst.z = (src0.z >= src1.z) ? 1.0 : 0.0
+ dst.w = (src0.w >= src1.w) ? 1.0 : 0.0
+
+
+1.1.17 MAD - Multiply And Add
+
+ dst.x = src0.x * src1.x + src2.x
+ dst.y = src0.y * src1.y + src2.y
+ dst.z = src0.z * src1.z + src2.z
+ dst.w = src0.w * src1.w + src2.w
+
+
+1.2 GL_ATI_fragment_shader
+---------------------------
+
+
+1.2.1 SUB - Subtract
+
+ dst.x = src0.x - src1.x
+ dst.y = src0.y - src1.y
+ dst.z = src0.z - src1.z
+ dst.w = src0.w - src1.w
+
+
+1.2.2 DOT3 - 3-component Dot Product
+
+ Alias for DP3.
+
+
+1.2.3 DOT4 - 4-component Dot Product
+
+ Alias for DP4.
+
+
+1.2.4 LERP - Linear Interpolate
+
+ dst.x = src0.x * (src1.x - src2.x) + src2.x
+ dst.y = src0.y * (src1.y - src2.y) + src2.y
+ dst.z = src0.z * (src1.z - src2.z) + src2.z
+ dst.w = src0.w * (src1.w - src2.w) + src2.w
+
+
+1.2.5 CND - Condition
+
+ dst.x = (src2.x > 0.5) ? src0.x : src1.x
+ dst.y = (src2.y > 0.5) ? src0.y : src1.y
+ dst.z = (src2.z > 0.5) ? src0.z : src1.z
+ dst.w = (src2.w > 0.5) ? src0.w : src1.w
+
+
+1.2.6 CND0 - Condition Zero
+
+ dst.x = (src2.x >= 0.0) ? src0.x : src1.x
+ dst.y = (src2.y >= 0.0) ? src0.y : src1.y
+ dst.z = (src2.z >= 0.0) ? src0.z : src1.z
+ dst.w = (src2.w >= 0.0) ? src0.w : src1.w
+
+
+1.2.7 DOT2ADD - 2-component Dot Product And Add
+
+ dst.x = src0.x * src1.x + src0.y * src1.y + src2.x
+ dst.y = src0.x * src1.x + src0.y * src1.y + src2.x
+ dst.z = src0.x * src1.x + src0.y * src1.y + src2.x
+ dst.w = src0.x * src1.x + src0.y * src1.y + src2.x
+
+
+1.3 GL_EXT_vertex_shader
+-------------------------
+
+
+1.3.1 INDEX - Array Lookup
+
+ Considered for removal from language.
+
+
+1.3.2 NEGATE - Negate
+
+ Considered for removal from language.
+
+
+1.3.3 MADD - Multiply And Add
+
+ Alias for MAD.
+
+
+1.3.4 FRAC - Fraction
+
+ dst.x = src.x - floor(src.x)
+ dst.y = src.y - floor(src.y)
+ dst.z = src.z - floor(src.z)
+ dst.w = src.w - floor(src.w)
+
+
+1.3.5 SETGE - Set On Greater Equal
+
+ Alias for SGE.
+
+
+1.3.6 SETLT - Set On Less Than
+
+ Alias for SLT.
+
+
+1.3.7 CLAMP - Clamp
+
+ dst.x = clamp(src0.x, src1.x, src2.x)
+ dst.y = clamp(src0.y, src1.y, src2.y)
+ dst.z = clamp(src0.z, src1.z, src2.z)
+ dst.w = clamp(src0.w, src1.w, src2.w)
+
+
+1.3.8 FLOOR - Floor
+
+ dst.x = floor(src.x)
+ dst.y = floor(src.y)
+ dst.z = floor(src.z)
+ dst.w = floor(src.w)
+
+
+1.3.9 ROUND - Round
+
+ dst.x = round(src.x)
+ dst.y = round(src.y)
+ dst.z = round(src.z)
+ dst.w = round(src.w)
+
+
+1.3.10 EXPBASE2 - Exponent Base 2
+
+ dst.x = pow(2.0, src.x)
+ dst.y = pow(2.0, src.x)
+ dst.z = pow(2.0, src.x)
+ dst.w = pow(2.0, src.x)
+
+
+1.3.11 LOGBASE2 - Logarithm Base 2
+
+ dst.x = lg2(src.x)
+ dst.y = lg2(src.x)
+ dst.z = lg2(src.x)
+ dst.w = lg2(src.x)
+
+
+1.3.12 POWER - Power
+
+ dst.x = pow(src0.x, src1.x)
+ dst.y = pow(src0.x, src1.x)
+ dst.z = pow(src0.x, src1.x)
+ dst.w = pow(src0.x, src1.x)
+
+
+1.3.13 RECIP - Reciprocal
+
+ Alias for RCP.
+
+
+1.3.14 RECIPSQRT - Reciprocal Square Root
+
+ Alias for RSQ.
+
+
+1.3.15 CROSSPRODUCT - Cross Product
+
+ dst.x = src0.y * src1.z - src1.y * src0.z
+ dst.y = src0.z * src1.x - src1.z * src0.x
+ dst.z = src0.x * src1.y - src1.x * src0.y
+ dst.w = 1.0
+
+
+1.3.16 MULTIPLYMATRIX - Multiply Matrix
+
+ Considered for removal from language.
+
+
+1.4 GL_NV_vertex_program1_1
+----------------------------
+
+
+1.4.1 ABS - Absolute
+
+ dst.x = abs(src.x)
+ dst.y = abs(src.y)
+ dst.z = abs(src.z)
+ dst.w = abs(src.w)
+
+
+1.4.2 RCC - Reciprocal Clamped
+
+ dst.x = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
+ dst.y = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
+ dst.z = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
+ dst.w = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
+
+
+1.4.3 DPH - Homogeneous Dot Product
+
+ dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
+ dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
+ dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
+ dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
+
+
+1.5 GL_NV_fragment_program
+---------------------------
+
+
+1.5.1 COS - Cosine
+
+ dst.x = cos(src.x)
+ dst.y = cos(src.x)
+ dst.z = cos(src.x)
+ dst.w = cos(src.w)
+
+
+1.5.2 DDX - Derivative Relative To X
+
+ dst.x = partialx(src.x)
+ dst.y = partialx(src.y)
+ dst.z = partialx(src.z)
+ dst.w = partialx(src.w)
+
+
+1.5.3 DDY - Derivative Relative To Y
+
+ dst.x = partialy(src.x)
+ dst.y = partialy(src.y)
+ dst.z = partialy(src.z)
+ dst.w = partialy(src.w)
+
+
+1.5.4 EX2 - Exponential Base 2
+
+ Alias for EXPBASE2.
+
+
+1.5.5 FLR - Floor
+
+ Alias for FLOOR.
+
+
+1.5.6 FRC - Fraction
+
+ Alias for FRAC.
+
+
+1.5.7 KILP - Predicated Discard
+
+ TBD
+
+
+1.5.8 LG2 - Logarithm Base 2
+
+ Alias for LOGBASE2.
+
+
+1.5.9 LRP - Linear Interpolate
+
+ Alias for LERP.
+
+
+1.5.10 PK2H - Pack Two 16-bit Floats
+
+ TBD
+
+
+1.5.11 PK2US - Pack Two Unsigned 16-bit Scalars
+
+ TBD
+
+
+1.5.12 PK4B - Pack Four Signed 8-bit Scalars
+
+ TBD
+
+
+1.5.13 PK4UB - Pack Four Unsigned 8-bit Scalars
+
+ TBD
+
+
+1.5.14 POW - Power
+
+ Alias for POWER.
+
+
+1.5.15 RFL - Reflection Vector
+
+ dst.x = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.x - src1.x
+ dst.y = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.y - src1.y
+ dst.z = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.z - src1.z
+ dst.w = 1.0
+
+
+1.5.16 SEQ - Set On Equal
+
+ dst.x = (src0.x == src1.x) ? 1.0 : 0.0
+ dst.y = (src0.y == src1.y) ? 1.0 : 0.0
+ dst.z = (src0.z == src1.z) ? 1.0 : 0.0
+ dst.w = (src0.w == src1.w) ? 1.0 : 0.0
+
+
+1.5.17 SFL - Set On False
+
+ dst.x = 0.0
+ dst.y = 0.0
+ dst.z = 0.0
+ dst.w = 0.0
+
+
+1.5.18 SGT - Set On Greater Than
+
+ dst.x = (src0.x > src1.x) ? 1.0 : 0.0
+ dst.y = (src0.y > src1.y) ? 1.0 : 0.0
+ dst.z = (src0.z > src1.z) ? 1.0 : 0.0
+ dst.w = (src0.w > src1.w) ? 1.0 : 0.0
+
+
+1.5.19 SIN - Sine
+
+ dst.x = sin(src.x)
+ dst.y = sin(src.x)
+ dst.z = sin(src.x)
+ dst.w = sin(src.w)
+
+
+1.5.20 SLE - Set On Less Equal Than
+
+ dst.x = (src0.x <= src1.x) ? 1.0 : 0.0
+ dst.y = (src0.y <= src1.y) ? 1.0 : 0.0
+ dst.z = (src0.z <= src1.z) ? 1.0 : 0.0
+ dst.w = (src0.w <= src1.w) ? 1.0 : 0.0
+
+
+1.5.21 SNE - Set On Not Equal
+
+ dst.x = (src0.x != src1.x) ? 1.0 : 0.0
+ dst.y = (src0.y != src1.y) ? 1.0 : 0.0
+ dst.z = (src0.z != src1.z) ? 1.0 : 0.0
+ dst.w = (src0.w != src1.w) ? 1.0 : 0.0
+
+
+1.5.22 STR - Set On True
+
+ dst.x = 1.0
+ dst.y = 1.0
+ dst.z = 1.0
+ dst.w = 1.0
+
+
+1.5.23 TEX - Texture Lookup
+
+ TBD
+
+
+1.5.24 TXD - Texture Lookup with Derivatives
+
+ TBD
+
+
+1.5.25 TXP - Projective Texture Lookup
+
+ TBD
+
+
+1.5.26 UP2H - Unpack Two 16-Bit Floats
+
+ TBD
+
+
+1.5.27 UP2US - Unpack Two Unsigned 16-Bit Scalars
+
+ TBD
+
+
+1.5.28 UP4B - Unpack Four Signed 8-Bit Values
+
+ TBD
+
+
+1.5.29 UP4UB - Unpack Four Unsigned 8-Bit Scalars
+
+ TBD
+
+
+1.5.30 X2D - 2D Coordinate Transformation
+
+ dst.x = src0.x + src1.x * src2.x + src1.y * src2.y
+ dst.y = src0.y + src1.x * src2.z + src1.y * src2.w
+ dst.z = src0.x + src1.x * src2.x + src1.y * src2.y
+ dst.w = src0.y + src1.x * src2.z + src1.y * src2.w
+
+
+1.6 GL_NV_vertex_program2
+--------------------------
+
+
+1.6.1 ARA - Address Register Add
+
+ TBD
+
+
+1.6.2 ARR - Address Register Load With Round
+
+ dst.x = round(src.x)
+ dst.y = round(src.y)
+ dst.z = round(src.z)
+ dst.w = round(src.w)
+
+
+1.6.3 BRA - Branch
+
+ TBD
+
+
+1.6.4 CAL - Subroutine Call
+
+ push(pc)
+ pc = target
+
+
+1.6.5 RET - Subroutine Call Return
+
+ pc = pop()
+
+
+1.6.6 SSG - Set Sign
+
+ dst.x = (src.x > 0.0) ? 1.0 : (src.x < 0.0) ? -1.0 : 0.0
+ dst.y = (src.y > 0.0) ? 1.0 : (src.y < 0.0) ? -1.0 : 0.0
+ dst.z = (src.z > 0.0) ? 1.0 : (src.z < 0.0) ? -1.0 : 0.0
+ dst.w = (src.w > 0.0) ? 1.0 : (src.w < 0.0) ? -1.0 : 0.0
+
+
+1.7 GL_ARB_vertex_program
+--------------------------
+
+
+1.7.1 SWZ - Extended Swizzle
+
+ dst.x = src.x
+ dst.y = src.y
+ dst.z = src.z
+ dst.w = src.w
+
+
+1.7.2 XPD - Cross Product
+
+ Alias for CROSSPRODUCT.
+
+
+1.8 GL_ARB_fragment_program
+----------------------------
+
+
+1.8.1 CMP - Compare
+
+ dst.x = (src0.x < 0.0) ? src1.x : src2.x
+ dst.y = (src0.y < 0.0) ? src1.y : src2.y
+ dst.z = (src0.z < 0.0) ? src1.z : src2.z
+ dst.w = (src0.w < 0.0) ? src1.w : src2.w
+
+
+1.8.2 KIL - Conditional Discard
+
+ TBD
+
+
+1.8.3 SCS - Sine Cosine
+
+ dst.x = cos(src.x)
+ dst.y = sin(src.x)
+ dst.z = 0.0
+ dst.y = 1.0
+
+
+1.8.4 TXB - Texture Lookup With Bias
+
+ TBD
+
+
+1.9 GL_NV_fragment_program2
+----------------------------
+
+
+1.9.1 NRM - 3-component Vector Normalise
+
+ dst.x = src.x / (src.x * src.x + src.y * src.y + src.z * src.z)
+ dst.y = src.y / (src.x * src.x + src.y * src.y + src.z * src.z)
+ dst.z = src.z / (src.x * src.x + src.y * src.y + src.z * src.z)
+ dst.w = 1.0
+
+
+1.9.2 DIV - Divide
+
+ dst.x = src0.x / src1.x
+ dst.y = src0.y / src1.y
+ dst.z = src0.z / src1.z
+ dst.w = src0.w / src1.w
+
+
+1.9.3 DP2 - 2-component Dot Product
+
+ dst.x = src0.x * src1.x + src0.y * src1.y
+ dst.y = src0.x * src1.x + src0.y * src1.y
+ dst.z = src0.x * src1.x + src0.y * src1.y
+ dst.w = src0.x * src1.x + src0.y * src1.y
+
+
+1.9.4 DP2A - 2-component Dot Product And Add
+
+ Alias for DOT2ADD.
+
+
+1.9.5 TXL - Texture Lookup With LOD
+
+ TBD
+
+
+1.9.6 BRK - Break
+
+ TBD
+
+
+1.9.7 IF - If
+
+ TBD
+
+
+1.9.8 LOOP - Loop
+
+ TBD
+
+
+1.9.9 REP - Repeat
+
+ TBD
+
+
+1.9.10 ELSE - Else
+
+ TBD
+
+
+1.9.11 ENDIF - End If
+
+ TBD
+
+
+1.9.12 ENDLOOP - End Loop
+
+ TBD
+
+
+1.9.13 ENDREP - End Repeat
+
+ TBD
+
+
+1.10 GL_NV_vertex_program3
+---------------------------
+
+
+1.10.1 PUSHA - Push Address Register On Stack
+
+ push(src.x)
+ push(src.y)
+ push(src.z)
+ push(src.w)
+
+
+1.10.2 POPA - Pop Address Register From Stack
+
+ dst.w = pop()
+ dst.z = pop()
+ dst.y = pop()
+ dst.x = pop()
+
+
+1.11 GL_NV_gpu_program4
+------------------------
+
+
+1.11.1 CEIL - Ceiling
+
+ dst.x = ceil(src.x)
+ dst.y = ceil(src.y)
+ dst.z = ceil(src.z)
+ dst.w = ceil(src.w)
+
+
+1.11.2 I2F - Integer To Float
+
+ dst.x = (float) src.x
+ dst.y = (float) src.y
+ dst.z = (float) src.z
+ dst.w = (float) src.w
+
+
+1.11.3 NOT - Bitwise Not
+
+ dst.x = ~src.x
+ dst.y = ~src.y
+ dst.z = ~src.z
+ dst.w = ~src.w
+
+
+1.11.4 TRUNC - Truncate
+
+ dst.x = trunc(src.x)
+ dst.y = trunc(src.y)
+ dst.z = trunc(src.z)
+ dst.w = trunc(src.w)
+
+
+1.11.5 SHL - Shift Left
+
+ dst.x = src0.x << src1.x
+ dst.y = src0.y << src1.x
+ dst.z = src0.z << src1.x
+ dst.w = src0.w << src1.x
+
+
+1.11.6 SHR - Shift Right
+
+ dst.x = src0.x >> src1.x
+ dst.y = src0.y >> src1.x
+ dst.z = src0.z >> src1.x
+ dst.w = src0.w >> src1.x
+
+
+1.11.7 AND - Bitwise And
+
+ dst.x = src0.x & src1.x
+ dst.y = src0.y & src1.y
+ dst.z = src0.z & src1.z
+ dst.w = src0.w & src1.w
+
+
+1.11.8 OR - Bitwise Or
+
+ dst.x = src0.x | src1.x
+ dst.y = src0.y | src1.y
+ dst.z = src0.z | src1.z
+ dst.w = src0.w | src1.w
+
+
+1.11.9 MOD - Modulus
+
+ dst.x = src0.x % src1.x
+ dst.y = src0.y % src1.y
+ dst.z = src0.z % src1.z
+ dst.w = src0.w % src1.w
+
+
+1.11.10 XOR - Bitwise Xor
+
+ dst.x = src0.x ^ src1.x
+ dst.y = src0.y ^ src1.y
+ dst.z = src0.z ^ src1.z
+ dst.w = src0.w ^ src1.w
+
+
+1.11.11 SAD - Sum Of Absolute Differences
+
+ dst.x = abs(src0.x - src1.x) + src2.x
+ dst.y = abs(src0.y - src1.y) + src2.y
+ dst.z = abs(src0.z - src1.z) + src2.z
+ dst.w = abs(src0.w - src1.w) + src2.w
+
+
+1.11.12 TXF - Texel Fetch
+
+ TBD
+
+
+1.11.13 TXQ - Texture Size Query
+
+ TBD
+
+
+1.11.14 CONT - Continue
+
+ TBD
+
+
+1.12 GL_NV_geometry_program4
+-----------------------------
+
+
+1.12.1 EMIT - Emit
+
+ TBD
+
+
+1.12.2 ENDPRIM - End Primitive
+
+ TBD
+
+
+1.13 GLSL
+----------
+
+
+1.13.1 BGNLOOP2 - Begin Loop
+
+ TBD
+
+
+1.13.2 BGNSUB - Begin Subroutine
+
+ TBD
+
+
+1.13.3 ENDLOOP2 - End Loop
+
+ TBD
+
+
+1.13.4 ENDSUB - End Subroutine
+
+ TBD
+
+
+1.13.5 INT - Truncate
+
+ Alias for TRUNC.
+
+
+1.13.6 NOISE1 - 1D Noise
+
+ TBD
+
+
+1.13.7 NOISE2 - 2D Noise
+
+ TBD
+
+
+1.13.8 NOISE3 - 3D Noise
+
+ TBD
+
+
+1.13.9 NOISE4 - 4D Noise
+
+ TBD
+
+
+1.13.10 NOP - No Operation
+
+ Do nothing.
+
+
+1.14 ps_1_1
+------------
+
+
+1.14.1 TEXKILL - Conditional Discard
+
+ Alias for KIL.
+
+
+1.15 ps_1_4
+------------
+
+
+1.15.1 TEXLD - Texture Lookup
+
+ Alias for TEX.
+
+
+1.16 ps_2_0
+------------
+
+
+1.16.1 M4X4 - Multiply Matrix
+
+ Alias for MULTIPLYMATRIX.
+
+
+1.16.2 M4X3 - Multiply Matrix
+
+ Considered for removal from language.
+
+
+1.16.3 M3X4 - Multiply Matrix
+
+ Considered for removal from language.
+
+
+1.16.4 M3X3 - Multiply Matrix
+
+ Considered for removal from language.
+
+
+1.16.5 M3X2 - Multiply Matrix
+
+ Considered for removal from language.
+
+
+1.16.6 CRS - Cross Product
+
+ Alias for XPD.
+
+
+1.16.7 NRM4 - 4-component Vector Normalise
+
+ dst.x = src.x / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
+ dst.y = src.y / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
+ dst.z = src.z / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
+ dst.w = src.w / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
+
+
+1.16.8 SINCOS - Sine Cosine
+
+ Alias for SCS.
+
+
+1.16.9 TEXLDB - Texture Lookup With Bias
+
+ Alias for TXB.
+
+
+1.16.10 DP2ADD - 2-component Dot Product And Add
+
+ Alias for DP2A.
+
+
+1.17 ps_2_x
+------------
+
+
+1.17.1 CALL - Subroutine Call
+
+ Alias for CAL.
+
+
+1.17.2 CALLNZ - Subroutine Call If Not Zero
+
+ TBD
+
+
+1.17.3 IFC - If
+
+ TBD
+
+
+1.17.4 BREAK - Break
+
+ Alias for BRK.
+
+
+1.17.5 BREAKC - Break Conditional
+
+ TBD
+
+
+1.17.6 DSX - Derivative Relative To X
+
+ Alias for DDX.
+
+
+1.17.7 DSY - Derivative Relative To Y
+
+ Alias for DDY.
+
+
+1.17.8 TEXLDD - Texture Lookup with Derivatives
+
+ Alias for TXD.
+
+
+1.18 vs_1_1
+------------
+
+
+1.18.1 EXPP - Approximate Exponential Base 2
+
+ Alias for EXP.
+
+
+1.18.2 LOGP - Logarithm Base 2
+
+ Alias for LG2.
+
+
+1.19 vs_2_0
+------------
+
+
+1.19.1 SGN - Set Sign
+
+ Alias for SSG.
+
+
+1.19.2 MOVA - Move Address Register
+
+ Alias for ARR.
+
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 17886540cf..a1891a140a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_build.h"
#include "tgsi_parse.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index ab2b1f2c58..a784b7cc3c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_string.h"
#include "tgsi_dump.h"
#include "tgsi_info.h"
@@ -245,8 +245,12 @@ iter_declaration(
}
}
- TXT( ", " );
- ENM( decl->Declaration.Interpolate, interpolate_names );
+ if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
+ decl->Declaration.File == TGSI_FILE_INPUT)
+ {
+ TXT( ", " );
+ ENM( decl->Declaration.Interpolate, interpolate_names );
+ }
if (decl->Declaration.Centroid) {
TXT( ", CENTROID" );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
index 2ecf1e2f14..3dc61c48ca 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_string.h"
#include "tgsi_dump_c.h"
#include "tgsi_build.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index ab641efb60..ba807e498f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -486,6 +486,32 @@ micro_f2ut(
#endif
static void
+micro_float_clamp(union tgsi_exec_channel *dst,
+ const union tgsi_exec_channel *src)
+{
+ uint i;
+
+ for (i = 0; i < 4; i++) {
+ if (src->f[i] > 0.0f) {
+ if (src->f[i] > 1.884467e+019f)
+ dst->f[i] = 1.884467e+019f;
+ else if (src->f[i] < 5.42101e-020f)
+ dst->f[i] = 5.42101e-020f;
+ else
+ dst->f[i] = src->f[i];
+ }
+ else {
+ if (src->f[i] < -1.884467e+019f)
+ dst->f[i] = -1.884467e+019f;
+ else if (src->f[i] > -5.42101e-020f)
+ dst->f[i] = -5.42101e-020f;
+ else
+ dst->f[i] = src->f[i];
+ }
+ }
+}
+
+static void
micro_flr(
union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src )
@@ -508,20 +534,6 @@ micro_frc(
}
static void
-micro_ge(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->f[0] = src0->f[0] >= src1->f[0] ? src2->f[0] : src3->f[0];
- dst->f[1] = src0->f[1] >= src1->f[1] ? src2->f[1] : src3->f[1];
- dst->f[2] = src0->f[2] >= src1->f[2] ? src2->f[2] : src3->f[2];
- dst->f[3] = src0->f[3] >= src1->f[3] ? src2->f[3] : src3->f[3];
-}
-
-static void
micro_i2f(
union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src )
@@ -1614,6 +1626,7 @@ exec_tex(struct tgsi_exec_machine *mach,
switch (inst->InstructionExtTexture.Texture) {
case TGSI_TEXTURE_1D:
+ case TGSI_TEXTURE_SHADOW1D:
FETCH(&r[0], 0, CHAN_X);
@@ -1636,6 +1649,8 @@ exec_tex(struct tgsi_exec_machine *mach,
case TGSI_TEXTURE_2D:
case TGSI_TEXTURE_RECT:
+ case TGSI_TEXTURE_SHADOW2D:
+ case TGSI_TEXTURE_SHADOWRECT:
FETCH(&r[0], 0, CHAN_X);
FETCH(&r[1], 0, CHAN_Y);
@@ -1826,12 +1841,14 @@ exec_instruction(
int *pc )
{
uint chan_index;
- union tgsi_exec_channel r[8];
+ union tgsi_exec_channel r[10];
(*pc)++;
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_ARL:
+ /* TGSI_OPCODE_FLOOR */
+ /* TGSI_OPCODE_FLR */
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH( &r[0], 0, chan_index );
micro_flr( &r[0], &r[0] );
@@ -1849,31 +1866,31 @@ exec_instruction(
case TGSI_OPCODE_LIT:
if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
+ STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y ) || IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[0], 0, CHAN_X );
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- micro_max( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, CHAN_Y );
- }
+ FETCH( &r[0], 0, CHAN_X );
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+ micro_max( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
+ STORE( &r[0], 0, CHAN_Y );
+ }
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[1], 0, CHAN_Y );
- micro_max( &r[1], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+ FETCH( &r[1], 0, CHAN_Y );
+ micro_max( &r[1], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- FETCH( &r[2], 0, CHAN_W );
- micro_min( &r[2], &r[2], &mach->Temps[TEMP_128_I].xyzw[TEMP_128_C] );
- micro_max( &r[2], &r[2], &mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C] );
- micro_pow( &r[1], &r[1], &r[2] );
- micro_lt( &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, CHAN_Z );
- }
+ FETCH( &r[2], 0, CHAN_W );
+ micro_min( &r[2], &r[2], &mach->Temps[TEMP_128_I].xyzw[TEMP_128_C] );
+ micro_max( &r[2], &r[2], &mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C] );
+ micro_pow( &r[1], &r[1], &r[2] );
+ micro_lt( &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
+ STORE( &r[0], 0, CHAN_Z );
+ }
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
+ STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
}
break;
@@ -1882,17 +1899,18 @@ exec_instruction(
FETCH( &r[0], 0, CHAN_X );
micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] );
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ STORE( &r[0], 0, chan_index );
}
break;
case TGSI_OPCODE_RSQ:
/* TGSI_OPCODE_RECIPSQRT */
FETCH( &r[0], 0, CHAN_X );
+ micro_abs( &r[0], &r[0] );
micro_sqrt( &r[0], &r[0] );
micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] );
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ STORE( &r[0], 0, chan_index );
}
break;
@@ -2005,30 +2023,30 @@ exec_instruction(
micro_add( &r[0], &r[0], &r[1] );
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ STORE( &r[0], 0, chan_index );
}
break;
case TGSI_OPCODE_DST:
if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
+ STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- FETCH( &r[0], 0, CHAN_Y );
- FETCH( &r[1], 1, CHAN_Y);
- micro_mul( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, CHAN_Y );
+ FETCH( &r[0], 0, CHAN_Y );
+ FETCH( &r[1], 1, CHAN_Y);
+ micro_mul( &r[0], &r[0], &r[1] );
+ STORE( &r[0], 0, CHAN_Y );
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[0], 0, CHAN_Z );
- STORE( &r[0], 0, CHAN_Z );
+ FETCH( &r[0], 0, CHAN_Z );
+ STORE( &r[0], 0, CHAN_Z );
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- FETCH( &r[0], 1, CHAN_W );
- STORE( &r[0], 0, CHAN_W );
+ FETCH( &r[0], 1, CHAN_W );
+ STORE( &r[0], 0, CHAN_W );
}
break;
@@ -2071,7 +2089,7 @@ exec_instruction(
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH( &r[0], 0, chan_index );
FETCH( &r[1], 1, chan_index );
- micro_ge( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
+ micro_le( &r[0], &r[1], &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
STORE( &r[0], 0, chan_index );
}
break;
@@ -2115,15 +2133,27 @@ exec_instruction(
break;
case TGSI_OPCODE_CND:
- assert (0);
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ FETCH(&r[0], 0, chan_index);
+ FETCH(&r[1], 1, chan_index);
+ FETCH(&r[2], 2, chan_index);
+ micro_lt(&r[0], &mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C], &r[2], &r[0], &r[1]);
+ STORE(&r[0], 0, chan_index);
+ }
break;
case TGSI_OPCODE_CND0:
- assert (0);
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ FETCH(&r[0], 0, chan_index);
+ FETCH(&r[1], 1, chan_index);
+ FETCH(&r[2], 2, chan_index);
+ micro_le(&r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[2], &r[0], &r[1]);
+ STORE(&r[0], 0, chan_index);
+ }
break;
case TGSI_OPCODE_DOT2ADD:
- /* TGSI_OPCODE_DP2A */
+ /* TGSI_OPCODE_DP2A */
FETCH( &r[0], 0, CHAN_X );
FETCH( &r[1], 1, CHAN_X );
micro_mul( &r[0], &r[0], &r[1] );
@@ -2142,10 +2172,12 @@ exec_instruction(
break;
case TGSI_OPCODE_INDEX:
+ /* XXX: considered for removal */
assert (0);
break;
case TGSI_OPCODE_NEGATE:
+ /* XXX: considered for removal */
assert (0);
break;
@@ -2159,15 +2191,13 @@ exec_instruction(
break;
case TGSI_OPCODE_CLAMP:
- assert (0);
- break;
-
- case TGSI_OPCODE_FLOOR:
- /* TGSI_OPCODE_FLR */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_flr( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ FETCH(&r[0], 0, chan_index);
+ FETCH(&r[1], 1, chan_index);
+ micro_max(&r[0], &r[0], &r[1]);
+ FETCH(&r[1], 2, chan_index);
+ micro_min(&r[0], &r[0], &r[1]);
+ STORE(&r[0], 0, chan_index);
}
break;
@@ -2181,7 +2211,7 @@ exec_instruction(
break;
case TGSI_OPCODE_EXPBASE2:
- /* TGSI_OPCODE_EX2 */
+ /* TGSI_OPCODE_EX2 */
FETCH(&r[0], 0, CHAN_X);
#if FAST_MATH
@@ -2191,7 +2221,7 @@ exec_instruction(
#endif
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ STORE( &r[0], 0, chan_index );
}
break;
@@ -2205,19 +2235,19 @@ exec_instruction(
break;
case TGSI_OPCODE_POWER:
- /* TGSI_OPCODE_POW */
+ /* TGSI_OPCODE_POW */
FETCH(&r[0], 0, CHAN_X);
FETCH(&r[1], 1, CHAN_X);
micro_pow( &r[0], &r[0], &r[1] );
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ STORE( &r[0], 0, chan_index );
}
break;
case TGSI_OPCODE_CROSSPRODUCT:
- /* TGSI_OPCODE_XPD */
+ /* TGSI_OPCODE_XPD */
FETCH(&r[0], 0, CHAN_Y);
FETCH(&r[1], 1, CHAN_Z);
@@ -2260,6 +2290,7 @@ exec_instruction(
break;
case TGSI_OPCODE_MULTIPLYMATRIX:
+ /* XXX: considered for removal */
assert (0);
break;
@@ -2274,7 +2305,12 @@ exec_instruction(
break;
case TGSI_OPCODE_RCC:
- assert (0);
+ FETCH(&r[0], 0, CHAN_X);
+ micro_div(&r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0]);
+ micro_float_clamp(&r[0], &r[0]);
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&r[0], 0, chan_index);
+ }
break;
case TGSI_OPCODE_DPH:
@@ -2300,7 +2336,7 @@ exec_instruction(
micro_add( &r[0], &r[0], &r[1] );
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ STORE( &r[0], 0, chan_index );
}
break;
@@ -2310,7 +2346,7 @@ exec_instruction(
micro_cos( &r[0], &r[0] );
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ STORE( &r[0], 0, chan_index );
}
break;
@@ -2355,7 +2391,52 @@ exec_instruction(
break;
case TGSI_OPCODE_RFL:
- assert (0);
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X) ||
+ IS_CHANNEL_ENABLED(*inst, CHAN_Y) ||
+ IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ /* r0 = dp3(src0, src0) */
+ FETCH(&r[2], 0, CHAN_X);
+ micro_mul(&r[0], &r[2], &r[2]);
+ FETCH(&r[4], 0, CHAN_Y);
+ micro_mul(&r[8], &r[4], &r[4]);
+ micro_add(&r[0], &r[0], &r[8]);
+ FETCH(&r[6], 0, CHAN_Z);
+ micro_mul(&r[8], &r[6], &r[6]);
+ micro_add(&r[0], &r[0], &r[8]);
+
+ /* r1 = dp3(src0, src1) */
+ FETCH(&r[3], 1, CHAN_X);
+ micro_mul(&r[1], &r[2], &r[3]);
+ FETCH(&r[5], 1, CHAN_Y);
+ micro_mul(&r[8], &r[4], &r[5]);
+ micro_add(&r[1], &r[1], &r[8]);
+ FETCH(&r[7], 1, CHAN_Z);
+ micro_mul(&r[8], &r[6], &r[7]);
+ micro_add(&r[1], &r[1], &r[8]);
+
+ /* r1 = 2 * r1 / r0 */
+ micro_add(&r[1], &r[1], &r[1]);
+ micro_div(&r[1], &r[1], &r[0]);
+
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ micro_mul(&r[2], &r[2], &r[1]);
+ micro_sub(&r[2], &r[2], &r[3]);
+ STORE(&r[2], 0, CHAN_X);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ micro_mul(&r[4], &r[4], &r[1]);
+ micro_sub(&r[4], &r[4], &r[5]);
+ STORE(&r[4], 0, CHAN_Y);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ micro_mul(&r[6], &r[6], &r[1]);
+ micro_sub(&r[6], &r[6], &r[7]);
+ STORE(&r[6], 0, CHAN_Z);
+ }
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
+ STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W);
+ }
break;
case TGSI_OPCODE_SEQ:
@@ -2370,7 +2451,9 @@ exec_instruction(
break;
case TGSI_OPCODE_SFL:
- assert (0);
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], 0, chan_index);
+ }
break;
case TGSI_OPCODE_SGT:
@@ -2409,7 +2492,9 @@ exec_instruction(
break;
case TGSI_OPCODE_STR:
- assert (0);
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, chan_index);
+ }
break;
case TGSI_OPCODE_TEX:
@@ -2466,7 +2551,40 @@ exec_instruction(
break;
case TGSI_OPCODE_X2D:
- assert (0);
+ FETCH(&r[0], 1, CHAN_X);
+ FETCH(&r[1], 1, CHAN_Y);
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X) ||
+ IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ FETCH(&r[2], 2, CHAN_X);
+ micro_mul(&r[2], &r[2], &r[0]);
+ FETCH(&r[3], 2, CHAN_Y);
+ micro_mul(&r[3], &r[3], &r[1]);
+ micro_add(&r[2], &r[2], &r[3]);
+ FETCH(&r[3], 0, CHAN_X);
+ micro_add(&r[2], &r[2], &r[3]);
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ STORE(&r[2], 0, CHAN_X);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ STORE(&r[2], 0, CHAN_Z);
+ }
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y) ||
+ IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
+ FETCH(&r[2], 2, CHAN_Z);
+ micro_mul(&r[2], &r[2], &r[0]);
+ FETCH(&r[3], 2, CHAN_W);
+ micro_mul(&r[3], &r[3], &r[1]);
+ micro_add(&r[2], &r[2], &r[3]);
+ FETCH(&r[3], 0, CHAN_Y);
+ micro_add(&r[2], &r[2], &r[3]);
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ STORE(&r[2], 0, CHAN_Y);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
+ STORE(&r[2], 0, CHAN_W);
+ }
+ }
break;
case TGSI_OPCODE_ARA:
@@ -2551,14 +2669,14 @@ exec_instruction(
case TGSI_OPCODE_SCS:
if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) || IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
FETCH( &r[0], 0, CHAN_X );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) ) {
- micro_cos( &r[1], &r[0] );
- STORE( &r[1], 0, CHAN_X );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
- micro_sin( &r[1], &r[0] );
- STORE( &r[1], 0, CHAN_Y );
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ micro_cos(&r[1], &r[0]);
+ STORE(&r[1], 0, CHAN_X);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ micro_sin(&r[1], &r[0]);
+ STORE(&r[1], 0, CHAN_Y);
+ }
}
if( IS_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
STORE( &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], 0, CHAN_Z );
@@ -2570,32 +2688,36 @@ exec_instruction(
case TGSI_OPCODE_NRM:
/* 3-component vector normalize */
- {
- union tgsi_exec_channel tmp, dot;
-
- /* tmp = dp3(src0, src0): */
- FETCH( &r[0], 0, CHAN_X );
- micro_mul( &tmp, &r[0], &r[0] );
-
- FETCH( &r[1], 0, CHAN_Y );
- micro_mul( &dot, &r[1], &r[1] );
- micro_add( &tmp, &tmp, &dot );
-
- FETCH( &r[2], 0, CHAN_Z );
- micro_mul( &dot, &r[2], &r[2] );
- micro_add( &tmp, &tmp, &dot );
-
- /* tmp = 1 / sqrt(tmp) */
- micro_sqrt( &tmp, &tmp );
- micro_div( &tmp, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &tmp );
-
- /* note: w channel is undefined */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- /* chan = chan * tmp */
- micro_mul( &r[chan_index], &tmp, &r[chan_index] );
- STORE( &r[chan_index], 0, chan_index );
+ if(IS_CHANNEL_ENABLED(*inst, CHAN_X) ||
+ IS_CHANNEL_ENABLED(*inst, CHAN_Y) ||
+ IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ /* r3 = sqrt(dp3(src0, src0)) */
+ FETCH(&r[0], 0, CHAN_X);
+ micro_mul(&r[3], &r[0], &r[0]);
+ FETCH(&r[1], 0, CHAN_Y);
+ micro_mul(&r[4], &r[1], &r[1]);
+ micro_add(&r[3], &r[3], &r[4]);
+ FETCH(&r[2], 0, CHAN_Z);
+ micro_mul(&r[4], &r[2], &r[2]);
+ micro_add(&r[3], &r[3], &r[4]);
+ micro_sqrt(&r[3], &r[3]);
+
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ micro_div(&r[0], &r[0], &r[3]);
+ STORE(&r[0], 0, CHAN_X);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ micro_div(&r[1], &r[1], &r[3]);
+ STORE(&r[1], 0, CHAN_Y);
+ }
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ micro_div(&r[2], &r[2], &r[3]);
+ STORE(&r[2], 0, CHAN_Z);
}
}
+ if (IS_CHANNEL_ENABLED(*inst, CHAN_W)) {
+ STORE(&mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W);
+ }
break;
case TGSI_OPCODE_NRM4:
@@ -2956,5 +3078,3 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
return ~mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0];
}
-
-
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 68c7a6b7f5..2b8a6f0fb1 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "tgsi_info.h"
static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_iterate.c b/src/gallium/auxiliary/tgsi/tgsi_iterate.c
index 5371a88b96..d88c2558d8 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_iterate.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_iterate.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "tgsi_iterate.h"
boolean
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c
index d374b16f9a..0081f74ffc 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_parse.h"
#include "tgsi_build.h"
@@ -154,10 +154,17 @@ tgsi_parse_token(
switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32:
- imm->u.Pointer = MALLOC(
- sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.NrTokens - 1) );
- for( i = 0; i < imm->Immediate.NrTokens - 1; i++ ) {
- next_token( ctx, (struct tgsi_immediate_float32 *) &imm->u.ImmediateFloat32[i] );
+ {
+ uint imm_count = imm->Immediate.NrTokens - 1;
+ struct tgsi_immediate_float32 *data;
+
+ data = (struct tgsi_immediate_float32 *) MALLOC(sizeof(struct tgsi_immediate_float32) * imm_count);
+ if (data) {
+ for (i = 0; i < imm_count; i++) {
+ next_token(ctx, &data[i]);
+ }
+ imm->u.ImmediateFloat32 = data;
+ }
}
break;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
index f365030e52..0c64ae5713 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ppc.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
@@ -33,7 +33,7 @@
#if defined(PIPE_ARCH_PPC)
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c
index bc7b941b78..6f1f5c2b4b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c
@@ -25,23 +25,24 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "tgsi_sanity.h"
#include "tgsi_info.h"
#include "tgsi_iterate.h"
-#define MAX_REGISTERS 256
-
typedef uint reg_flag;
#define BITS_IN_REG_FLAG (sizeof( reg_flag ) * 8)
+#define MAX_REGISTERS 256
+#define MAX_REG_FLAGS ((MAX_REGISTERS + BITS_IN_REG_FLAG - 1) / BITS_IN_REG_FLAG)
+
struct sanity_check_ctx
{
struct tgsi_iterate_context iter;
- reg_flag regs_decl[TGSI_FILE_COUNT][MAX_REGISTERS / BITS_IN_REG_FLAG];
- reg_flag regs_used[TGSI_FILE_COUNT][MAX_REGISTERS / BITS_IN_REG_FLAG];
+ reg_flag regs_decl[TGSI_FILE_COUNT][MAX_REG_FLAGS];
+ reg_flag regs_used[TGSI_FILE_COUNT][MAX_REG_FLAGS];
boolean regs_ind_used[TGSI_FILE_COUNT];
uint num_imms;
uint num_instructions;
@@ -89,7 +90,7 @@ check_file_name(
uint file )
{
if (file <= TGSI_FILE_NULL || file >= TGSI_FILE_COUNT) {
- report_error( ctx, "Invalid register file name" );
+ report_error( ctx, "(%u): Invalid register file name", file );
return FALSE;
}
return TRUE;
@@ -113,7 +114,7 @@ is_any_register_declared(
{
uint i;
- for (i = 0; i < MAX_REGISTERS / BITS_IN_REG_FLAG; i++)
+ for (i = 0; i < MAX_REG_FLAGS; i++)
if (ctx->regs_decl[file][i])
return TRUE;
return FALSE;
@@ -162,9 +163,8 @@ check_register_usage(
ctx->regs_ind_used[file] = TRUE;
}
else {
- if (index < 0 || index > MAX_REGISTERS) {
- report_error( ctx, "%s[%i]: Invalid index %s",
- file_names[file], index, name );
+ if (index < 0 || index >= MAX_REGISTERS) {
+ report_error( ctx, "%s[%d]: Invalid %s index", file_names[file], index, name );
return FALSE;
}
@@ -193,15 +193,15 @@ iter_instruction(
info = tgsi_get_opcode_info( inst->Instruction.Opcode );
if (info == NULL) {
- report_error( ctx, "Invalid instruction opcode" );
+ report_error( ctx, "(%u): Invalid instruction opcode", inst->Instruction.Opcode );
return TRUE;
}
if (info->num_dst != inst->Instruction.NumDstRegs) {
- report_error( ctx, "Invalid number of destination operands" );
+ report_error( ctx, "Invalid number of destination operands, should be %u", info->num_dst );
}
if (info->num_src != inst->Instruction.NumSrcRegs) {
- report_error( ctx, "Invalid number of source operands" );
+ report_error( ctx, "Invalid number of source operands, should be %u", info->num_src );
}
/* Check destination and source registers' validity.
@@ -266,7 +266,7 @@ iter_declaration(
return TRUE;
for (i = decl->DeclarationRange.First; i <= decl->DeclarationRange.Last; i++) {
if (is_register_declared( ctx, file, i ))
- report_error( ctx, "The same register declared twice" );
+ report_error( ctx, "%s[%u]: The same register declared more than once", file_names[file], i );
ctx->regs_decl[file][i / BITS_IN_REG_FLAG] |= (1 << (i % BITS_IN_REG_FLAG));
}
@@ -295,7 +295,7 @@ iter_immediate(
/* Check data type validity.
*/
if (imm->Immediate.DataType != TGSI_IMM_FLOAT32) {
- report_error( ctx, "Invalid immediate data type" );
+ report_error( ctx, "(%u): Invalid immediate data type", imm->Immediate.DataType );
return TRUE;
}
@@ -322,7 +322,7 @@ epilog(
for (i = 0; i < MAX_REGISTERS; i++) {
if (is_register_declared( ctx, file, i ) && !is_register_used( ctx, file, i ) && !ctx->regs_ind_used[file]) {
- report_warning( ctx, "Register never used" );
+ report_warning( ctx, "%s[%u]: Register never used", file_names[file], i );
}
}
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index d02205a63e..c535788819 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -151,7 +151,14 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
break;
case TGSI_TOKEN_TYPE_IMMEDIATE:
- info->immediate_count++;
+ {
+ uint reg = info->immediate_count++;
+ uint file = TGSI_FILE_IMMEDIATE;
+
+ info->file_mask[file] |= (1 << reg);
+ info->file_count[file]++;
+ info->file_max[file] = MAX2(info->file_max[file], (int)reg);
+ }
break;
default:
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 481ba89c5e..d70bcd03c5 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -29,7 +29,7 @@
#if defined(PIPE_ARCH_X86)
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
#if defined(PIPE_ARCH_SSE)
@@ -1575,6 +1575,7 @@ emit_instruction(
case TGSI_OPCODE_RSQ:
/* TGSI_OPCODE_RECIPSQRT */
FETCH( func, *inst, 0, 0, CHAN_X );
+ emit_abs( func, 0 );
emit_rsqrt( func, 1, 0 );
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
STORE( func, *inst, 1, 0, chan_index );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 1e822fbbea..58fe07c11d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "tgsi_text.h"
#include "tgsi_build.h"
#include "tgsi_info.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c
index ea87da31e5..062c1be938 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_transform.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_transform.c
@@ -31,7 +31,7 @@
* Authors: Brian Paul
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "tgsi_transform.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c
index 50101a9bb0..71f8a6ca40 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_util.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_util.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_parse.h"
#include "tgsi_build.h"
diff --git a/src/gallium/auxiliary/translate/Makefile b/src/gallium/auxiliary/translate/Makefile
index ad2a5b705e..3c82f8ae03 100644
--- a/src/gallium/auxiliary/translate/Makefile
+++ b/src/gallium/auxiliary/translate/Makefile
@@ -10,6 +10,3 @@ C_SOURCES = \
translate_cache.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile
index 44c2377721..160df8dfa7 100644
--- a/src/gallium/auxiliary/util/Makefile
+++ b/src/gallium/auxiliary/util/Makefile
@@ -4,7 +4,7 @@ include $(TOP)/configs/current
LIBNAME = util
C_SOURCES = \
- p_debug.c \
+ u_debug.c \
u_blit.c \
u_cache.c \
u_draw_quad.c \
@@ -27,6 +27,3 @@ C_SOURCES = \
u_simple_screen.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript
index 35f683fb8e..9d5dd006f0 100644
--- a/src/gallium/auxiliary/util/SConscript
+++ b/src/gallium/auxiliary/util/SConscript
@@ -3,11 +3,13 @@ Import('*')
util = env.ConvenienceLibrary(
target = 'util',
source = [
- 'p_debug.c',
- 'p_debug_mem.c',
- 'p_debug_prof.c',
+ 'u_bitmask.c',
'u_blit.c',
'u_cache.c',
+ 'u_debug.c',
+ 'u_debug_memory.c',
+ 'u_debug_profile.c',
+ 'u_debug_stack.c',
'u_draw_quad.c',
'u_gen_mipmap.c',
'u_handle_table.c',
diff --git a/src/gallium/auxiliary/util/u_bitmask.c b/src/gallium/auxiliary/util/u_bitmask.c
new file mode 100644
index 0000000000..77587c07ec
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_bitmask.c
@@ -0,0 +1,320 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Generic bitmask implementation.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
+
+#include "util/u_memory.h"
+#include "util/u_bitmask.h"
+
+
+typedef uint32_t util_bitmask_word;
+
+
+#define UTIL_BITMASK_INITIAL_WORDS 16
+#define UTIL_BITMASK_BITS_PER_BYTE 8
+#define UTIL_BITMASK_BITS_PER_WORD (sizeof(util_bitmask_word) * UTIL_BITMASK_BITS_PER_BYTE)
+
+
+struct util_bitmask
+{
+ util_bitmask_word *words;
+
+ /** Number of bits we can currently hold */
+ unsigned size;
+
+ /** Number of consecutive bits set at the start of the bitmask */
+ unsigned filled;
+};
+
+
+struct util_bitmask *
+util_bitmask_create(void)
+{
+ struct util_bitmask *bm;
+
+ bm = MALLOC_STRUCT(util_bitmask);
+ if(!bm)
+ return NULL;
+
+ bm->words = (util_bitmask_word *)CALLOC(UTIL_BITMASK_INITIAL_WORDS, sizeof(util_bitmask_word));
+ if(!bm->words) {
+ FREE(bm);
+ return NULL;
+ }
+
+ bm->size = UTIL_BITMASK_INITIAL_WORDS * UTIL_BITMASK_BITS_PER_WORD;
+ bm->filled = 0;
+
+ return bm;
+}
+
+
+/**
+ * Resize the bitmask if necessary
+ */
+static INLINE boolean
+util_bitmask_resize(struct util_bitmask *bm,
+ unsigned minimum_index)
+{
+ unsigned minimum_size = minimum_index + 1;
+ unsigned new_size;
+ util_bitmask_word *new_words;
+
+ /* Check integer overflow */
+ if(!minimum_size)
+ return FALSE;
+
+ if(bm->size > minimum_size)
+ return TRUE;
+
+ assert(bm->size % UTIL_BITMASK_BITS_PER_WORD == 0);
+ new_size = bm->size;
+ while(!(new_size > minimum_size)) {
+ new_size *= 2;
+ /* Check integer overflow */
+ if(new_size < bm->size)
+ return FALSE;
+ }
+ assert(new_size);
+ assert(new_size % UTIL_BITMASK_BITS_PER_WORD == 0);
+
+ new_words = (util_bitmask_word *)REALLOC((void *)bm->words,
+ bm->size / UTIL_BITMASK_BITS_PER_BYTE,
+ new_size / UTIL_BITMASK_BITS_PER_BYTE);
+ if(!new_words)
+ return FALSE;
+
+ memset(new_words + bm->size/UTIL_BITMASK_BITS_PER_WORD,
+ 0,
+ (new_size - bm->size)/UTIL_BITMASK_BITS_PER_BYTE);
+
+ bm->size = new_size;
+ bm->words = new_words;
+
+ return TRUE;
+}
+
+
+/**
+ * Lazily update the filled.
+ */
+static INLINE void
+util_bitmask_filled_set(struct util_bitmask *bm,
+ unsigned index)
+{
+ assert(bm->filled <= bm->size);
+ assert(index <= bm->size);
+
+ if(index == bm->filled) {
+ ++bm->filled;
+ assert(bm->filled <= bm->size);
+ }
+}
+
+static INLINE void
+util_bitmask_filled_unset(struct util_bitmask *bm,
+ unsigned index)
+{
+ assert(bm->filled <= bm->size);
+ assert(index <= bm->size);
+
+ if(index < bm->filled)
+ bm->filled = index;
+}
+
+
+unsigned
+util_bitmask_add(struct util_bitmask *bm)
+{
+ unsigned word;
+ unsigned bit;
+ util_bitmask_word mask;
+
+ assert(bm);
+
+ /* linear search for an empty index */
+ word = bm->filled / UTIL_BITMASK_BITS_PER_WORD;
+ bit = bm->filled % UTIL_BITMASK_BITS_PER_WORD;
+ mask = 1 << bit;
+ while(word < bm->size / UTIL_BITMASK_BITS_PER_WORD) {
+ while(bit < UTIL_BITMASK_BITS_PER_WORD) {
+ if(!(bm->words[word] & mask))
+ goto found;
+ ++bm->filled;
+ ++bit;
+ mask <<= 1;
+ }
+ ++word;
+ bit = 0;
+ mask = 1;
+ }
+found:
+
+ /* grow the bitmask if necessary */
+ if(!util_bitmask_resize(bm, bm->filled))
+ return UTIL_BITMASK_INVALID_INDEX;
+
+ assert(!(bm->words[word] & mask));
+ bm->words[word] |= mask;
+
+ return bm->filled++;
+}
+
+
+unsigned
+util_bitmask_set(struct util_bitmask *bm,
+ unsigned index)
+{
+ unsigned word = index / UTIL_BITMASK_BITS_PER_WORD;
+ unsigned bit = index % UTIL_BITMASK_BITS_PER_WORD;
+ util_bitmask_word mask = 1 << bit;
+
+ assert(bm);
+
+ /* grow the bitmask if necessary */
+ if(!util_bitmask_resize(bm, index))
+ return UTIL_BITMASK_INVALID_INDEX;
+
+ bm->words[word] |= mask;
+
+ util_bitmask_filled_set(bm, index);
+
+ return index;
+}
+
+
+void
+util_bitmask_clear(struct util_bitmask *bm,
+ unsigned index)
+{
+ unsigned word = index / UTIL_BITMASK_BITS_PER_WORD;
+ unsigned bit = index % UTIL_BITMASK_BITS_PER_WORD;
+ util_bitmask_word mask = 1 << bit;
+
+ assert(bm);
+
+ if(index >= bm->size)
+ return;
+
+ bm->words[word] &= ~mask;
+
+ util_bitmask_filled_unset(bm, index);
+}
+
+
+boolean
+util_bitmask_get(struct util_bitmask *bm,
+ unsigned index)
+{
+ unsigned word = index / UTIL_BITMASK_BITS_PER_WORD;
+ unsigned bit = index % UTIL_BITMASK_BITS_PER_WORD;
+ util_bitmask_word mask = 1 << bit;
+
+ assert(bm);
+
+ if(index < bm->filled) {
+ assert(bm->words[word] & mask);
+ return TRUE;
+ }
+
+ if(index > bm->size)
+ return FALSE;
+
+ if(bm->words[word] & mask) {
+ util_bitmask_filled_set(bm, index);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+
+unsigned
+util_bitmask_get_next_index(struct util_bitmask *bm,
+ unsigned index)
+{
+ unsigned word = index / UTIL_BITMASK_BITS_PER_WORD;
+ unsigned bit = index % UTIL_BITMASK_BITS_PER_WORD;
+ util_bitmask_word mask = 1 << bit;
+
+ if(index < bm->filled) {
+ assert(bm->words[word] & mask);
+ return index;
+ }
+
+ if(index >= bm->size) {
+ return UTIL_BITMASK_INVALID_INDEX;
+ }
+
+ /* Do a linear search */
+ while(word < bm->size / UTIL_BITMASK_BITS_PER_WORD) {
+ while(bit < UTIL_BITMASK_BITS_PER_WORD) {
+ if(bm->words[word] & mask) {
+ if(index == bm->filled) {
+ ++bm->filled;
+ assert(bm->filled <= bm->size);
+ }
+ return index;
+ }
+ ++index;
+ ++bit;
+ mask <<= 1;
+ }
+ ++word;
+ bit = 0;
+ mask = 1;
+ }
+
+ return UTIL_BITMASK_INVALID_INDEX;
+}
+
+
+unsigned
+util_bitmask_get_first_index(struct util_bitmask *bm)
+{
+ return util_bitmask_get_next_index(bm, 0);
+}
+
+
+void
+util_bitmask_destroy(struct util_bitmask *bm)
+{
+ assert(bm);
+
+ FREE(bm->words);
+ FREE(bm);
+}
+
diff --git a/src/gallium/auxiliary/util/u_bitmask.h b/src/gallium/auxiliary/util/u_bitmask.h
new file mode 100644
index 0000000000..87f1110296
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_bitmask.h
@@ -0,0 +1,114 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Generic bitmask.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+#ifndef U_HANDLE_BITMASK_H_
+#define U_HANDLE_BITMASK_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define UTIL_BITMASK_INVALID_INDEX (~0U)
+
+
+/**
+ * Abstract data type to represent arbitrary set of bits.
+ */
+struct util_bitmask;
+
+
+struct util_bitmask *
+util_bitmask_create(void);
+
+
+/**
+ * Search a cleared bit and set it.
+ *
+ * It searches for the first cleared bit.
+ *
+ * Returns the bit index on success, or UTIL_BITMASK_INVALID_INDEX on out of
+ * memory growing the bitmask.
+ */
+unsigned
+util_bitmask_add(struct util_bitmask *bm);
+
+/**
+ * Set a bit.
+ *
+ * Returns the input index on success, or UTIL_BITMASK_INVALID_INDEX on out of
+ * memory growing the bitmask.
+ */
+unsigned
+util_bitmask_set(struct util_bitmask *bm,
+ unsigned index);
+
+void
+util_bitmask_clear(struct util_bitmask *bm,
+ unsigned index);
+
+boolean
+util_bitmask_get(struct util_bitmask *bm,
+ unsigned index);
+
+
+void
+util_bitmask_destroy(struct util_bitmask *bm);
+
+
+/**
+ * Search for the first set bit.
+ *
+ * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found.
+ */
+unsigned
+util_bitmask_get_first_index(struct util_bitmask *bm);
+
+
+/**
+ * Search for the first set bit, starting from the giving index.
+ *
+ * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found.
+ */
+unsigned
+util_bitmask_get_next_index(struct util_bitmask *bm,
+ unsigned index);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_HANDLE_BITMASK_H_ */
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 841e9c01e7..deb68c43a6 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -34,10 +34,11 @@
#include "pipe/p_context.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_state.h"
#include "util/u_blit.h"
#include "util/u_draw_quad.h"
@@ -59,8 +60,6 @@ struct blit_state
struct pipe_sampler_state sampler;
struct pipe_viewport_state viewport;
- struct pipe_shader_state vert_shader;
- struct pipe_shader_state frag_shader;
void *vs;
void *fs;
@@ -103,8 +102,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
ctx->rasterizer.front_winding = PIPE_WINDING_CW;
ctx->rasterizer.cull_mode = PIPE_WINDING_NONE;
- ctx->rasterizer.bypass_clipping = 1;
- /*ctx->rasterizer.bypass_vs = 1;*/
+ ctx->rasterizer.bypass_vs_clip_and_viewport = 1;
ctx->rasterizer.gl_rasterization_rules = 1;
/* samplers */
@@ -117,28 +115,20 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
ctx->sampler.mag_img_filter = 0; /* set later */
ctx->sampler.normalized_coords = 1;
- /* viewport (identity, we setup vertices in wincoords) */
- ctx->viewport.scale[0] = 1.0;
- ctx->viewport.scale[1] = 1.0;
- ctx->viewport.scale[2] = 1.0;
- ctx->viewport.scale[3] = 1.0;
- ctx->viewport.translate[0] = 0.0;
- ctx->viewport.translate[1] = 0.0;
- ctx->viewport.translate[2] = 0.0;
- ctx->viewport.translate[3] = 0.0;
-
- /* vertex shader */
+
+ /* vertex shader - still required to provide the linkage between
+ * fragment shader input semantics and vertex_element/buffers.
+ */
{
const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC };
const uint semantic_indexes[] = { 0, 0 };
ctx->vs = util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
- semantic_indexes,
- &ctx->vert_shader);
+ semantic_indexes);
}
/* fragment shader */
- ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader);
+ ctx->fs = util_make_fragment_tex_shader(pipe);
ctx->vbuf = NULL;
/* init vertex data that doesn't change */
@@ -163,10 +153,7 @@ util_destroy_blit(struct blit_state *ctx)
pipe->delete_vs_state(pipe, ctx->vs);
pipe->delete_fs_state(pipe, ctx->fs);
- FREE((void*) ctx->vert_shader.tokens);
- FREE((void*) ctx->frag_shader.tokens);
-
- pipe_buffer_reference(pipe->screen, &ctx->vbuf, NULL);
+ pipe_buffer_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -199,7 +186,6 @@ static unsigned
setup_vertex_data(struct blit_state *ctx,
float x0, float y0, float x1, float y1, float z)
{
- void *buf;
unsigned offset;
ctx->vertices[0][0][0] = x0;
@@ -228,12 +214,8 @@ setup_vertex_data(struct blit_state *ctx,
offset = get_next_slot( ctx );
- buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- memcpy((char *)buf + offset, ctx->vertices, sizeof(ctx->vertices));
-
- pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
+ pipe_buffer_write(ctx->pipe->screen, ctx->vbuf,
+ offset, sizeof(ctx->vertices), ctx->vertices);
return offset;
}
@@ -249,7 +231,6 @@ setup_vertex_data_tex(struct blit_state *ctx,
float s0, float t0, float s1, float t1,
float z)
{
- void *buf;
unsigned offset;
ctx->vertices[0][0][0] = x0;
@@ -278,12 +259,8 @@ setup_vertex_data_tex(struct blit_state *ctx,
offset = get_next_slot( ctx );
- buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- memcpy((char *)buf + offset, ctx->vertices, sizeof(ctx->vertices));
-
- pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
+ pipe_buffer_write(ctx->pipe->screen, ctx->vbuf,
+ offset, sizeof(ctx->vertices), ctx->vertices);
return offset;
}
@@ -337,7 +314,7 @@ util_blit_pixels(struct blit_state *ctx,
if(dst->format == src->format && (dstX1 - dstX0) == srcW && (dstY1 - dstY0) == srcH) {
/* FIXME: this will most surely fail for overlapping rectangles */
- pipe->surface_copy(pipe, FALSE,
+ pipe->surface_copy(pipe,
dst, dstX0, dstY0, /* dest */
src, srcX0, srcY0, /* src */
srcW, srcH); /* size */
@@ -371,14 +348,14 @@ util_blit_pixels(struct blit_state *ctx,
PIPE_BUFFER_USAGE_GPU_WRITE);
/* load temp texture */
- pipe->surface_copy(pipe, FALSE,
+ pipe->surface_copy(pipe,
texSurf, 0, 0, /* dest */
src, srcLeft, srcTop, /* src */
srcW, srcH); /* size */
/* free the surface, update the texture if necessary.
*/
- screen->tex_surface_release(screen, &texSurf);
+ pipe_surface_reference(&texSurf, NULL);
/* save state (restored below) */
cso_save_blend(ctx->cso);
@@ -389,13 +366,11 @@ util_blit_pixels(struct blit_state *ctx,
cso_save_framebuffer(ctx->cso);
cso_save_fragment_shader(ctx->cso);
cso_save_vertex_shader(ctx->cso);
- cso_save_viewport(ctx->cso);
/* set misc state we care about */
cso_set_blend(ctx->cso, &ctx->blend);
cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil);
cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
- cso_set_viewport(ctx->cso, &ctx->viewport);
/* sampler */
ctx->sampler.min_img_filter = filter;
@@ -437,9 +412,8 @@ util_blit_pixels(struct blit_state *ctx,
cso_restore_framebuffer(ctx->cso);
cso_restore_fragment_shader(ctx->cso);
cso_restore_vertex_shader(ctx->cso);
- cso_restore_viewport(ctx->cso);
- screen->texture_release(screen, &tex);
+ pipe_texture_reference(&tex, NULL);
}
@@ -448,7 +422,7 @@ util_blit_pixels(struct blit_state *ctx,
*/
void util_blit_flush( struct blit_state *ctx )
{
- pipe_buffer_reference(ctx->pipe->screen, &ctx->vbuf, NULL);
+ pipe_buffer_reference(&ctx->vbuf, NULL);
ctx->vbuf_slot = 0;
}
@@ -471,8 +445,6 @@ util_blit_pixels_tex(struct blit_state *ctx,
int dstX1, int dstY1,
float z, uint filter)
{
- struct pipe_context *pipe = ctx->pipe;
- struct pipe_screen *screen = pipe->screen;
struct pipe_framebuffer_state fb;
float s0, t0, s1, t1;
unsigned offset;
@@ -488,8 +460,10 @@ util_blit_pixels_tex(struct blit_state *ctx,
t0 = srcY0 / (float)tex->height[0];
t1 = srcY1 / (float)tex->height[0];
- assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
+ assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ 0));
/* save state (restored below) */
cso_save_blend(ctx->cso);
@@ -500,13 +474,11 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_save_framebuffer(ctx->cso);
cso_save_fragment_shader(ctx->cso);
cso_save_vertex_shader(ctx->cso);
- cso_save_viewport(ctx->cso);
/* set misc state we care about */
cso_set_blend(ctx->cso, &ctx->blend);
cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil);
cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
- cso_set_viewport(ctx->cso, &ctx->viewport);
/* sampler */
ctx->sampler.min_img_filter = filter;
@@ -551,5 +523,4 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_restore_framebuffer(ctx->cso);
cso_restore_fragment_shader(ctx->cso);
cso_restore_vertex_shader(ctx->cso);
- cso_restore_viewport(ctx->cso);
}
diff --git a/src/gallium/auxiliary/util/u_cache.c b/src/gallium/auxiliary/util/u_cache.c
index 0a1a64259f..41cd38171f 100644
--- a/src/gallium/auxiliary/util/u_cache.c
+++ b/src/gallium/auxiliary/util/u_cache.c
@@ -36,7 +36,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/auxiliary/util/p_debug.c b/src/gallium/auxiliary/util/u_debug.c
index f373f941dd..f96e27e09f 100644
--- a/src/gallium/auxiliary/util/p_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -50,6 +50,7 @@
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <windows.h>
+#include <stdio.h>
#else
@@ -59,7 +60,7 @@
#endif
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
@@ -106,6 +107,12 @@ void _debug_vprintf(const char *format, va_list ap)
OutputDebugStringA(buf);
buf[0] = '\0';
}
+
+ if(GetConsoleWindow() && !IsDebuggerPresent()) {
+ vfprintf(stderr, format, ap);
+ fflush(stderr);
+ }
+
#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE)
wchar_t *wide_format;
long wide_str_len;
@@ -643,34 +650,37 @@ void debug_dump_image(const char *prefix,
void debug_dump_surface(const char *prefix,
struct pipe_surface *surface)
{
- unsigned surface_usage;
+ struct pipe_texture *texture;
+ struct pipe_screen *screen;
+ struct pipe_transfer *transfer;
void *data;
if (!surface)
- goto error1;
+ return;
+
+ texture = surface->texture;
+ screen = texture->screen;
- /* XXX: force mappable surface */
- surface_usage = surface->usage;
- surface->usage |= PIPE_BUFFER_USAGE_CPU_READ;
+ transfer = screen->get_tex_transfer(screen, texture, surface->face,
+ surface->level, surface->zslice,
+ PIPE_TRANSFER_READ, 0, 0, surface->width,
+ surface->height);
- data = pipe_surface_map(surface,
- PIPE_BUFFER_USAGE_CPU_READ);
+ data = screen->transfer_map(screen, transfer);
if(!data)
- goto error2;
+ goto error;
debug_dump_image(prefix,
- surface->format,
- surface->block.size,
- surface->nblocksx,
- surface->nblocksy,
- surface->stride,
+ transfer->format,
+ transfer->block.size,
+ transfer->nblocksx,
+ transfer->nblocksy,
+ transfer->stride,
data);
- pipe_surface_unmap(surface);
-error2:
- surface->usage = surface_usage;
-error1:
- ;
+ screen->transfer_unmap(screen, transfer);
+error:
+ screen->tex_transfer_destroy(transfer);
}
@@ -710,8 +720,10 @@ debug_dump_surface_bmp(const char *filename,
struct pipe_surface *surface)
{
#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
+ struct pipe_texture *texture;
+ struct pipe_screen *screen;
struct util_stream *stream;
- unsigned surface_usage;
+ struct pipe_transfer *transfer;
struct bmp_file_header bmfh;
struct bmp_info_header bmih;
float *rgba;
@@ -748,14 +760,18 @@ debug_dump_surface_bmp(const char *filename,
util_stream_write(stream, &bmfh, 14);
util_stream_write(stream, &bmih, 40);
+
+ texture = surface->texture;
+ screen = texture->screen;
- /* XXX: force mappable surface */
- surface_usage = surface->usage;
- surface->usage |= PIPE_BUFFER_USAGE_CPU_READ;
+ transfer = screen->get_tex_transfer(screen, texture, surface->face,
+ surface->level, surface->zslice,
+ PIPE_TRANSFER_READ, 0, 0, surface->width,
+ surface->height);
y = surface->height;
while(y--) {
- pipe_get_tile_rgba(surface,
+ pipe_get_tile_rgba(transfer,
0, y, surface->width, 1,
rgba);
for(x = 0; x < surface->width; ++x)
@@ -768,9 +784,9 @@ debug_dump_surface_bmp(const char *filename,
util_stream_write(stream, &pixel, 4);
}
}
-
- surface->usage = surface_usage;
+ screen->tex_transfer_destroy(transfer);
+
util_stream_close(stream);
error2:
FREE(rgba);
diff --git a/src/gallium/include/pipe/p_debug.h b/src/gallium/auxiliary/util/u_debug.h
index e9c95982dd..7c829707b2 100644
--- a/src/gallium/include/pipe/p_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -35,13 +35,13 @@
* @author Jose Fonseca <jrfonseca@tungstengraphics.com>
*/
-#ifndef P_DEBUG_H_
-#define P_DEBUG_H_
+#ifndef U_DEBUG_H_
+#define U_DEBUG_H_
#include <stdarg.h>
-#include "p_compiler.h"
+#include "pipe/p_compiler.h"
#ifdef __cplusplus
@@ -162,7 +162,7 @@ void _debug_assert_fail(const char *expr,
#ifdef DEBUG
#define debug_assert(expr) ((expr) ? (void)0 : _debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
#else
-#define debug_assert(expr) ((void)0)
+#define debug_assert(expr) ((void)(expr))
#endif
@@ -358,4 +358,4 @@ void debug_dump_surface_bmp(const char *filename,
}
#endif
-#endif /* P_DEBUG_H_ */
+#endif /* U_DEBUG_H_ */
diff --git a/src/gallium/auxiliary/util/p_debug_mem.c b/src/gallium/auxiliary/util/u_debug_memory.c
index 250fd60f63..7623cb9398 100644
--- a/src/gallium/auxiliary/util/p_debug_mem.c
+++ b/src/gallium/auxiliary/util/u_debug_memory.c
@@ -44,11 +44,13 @@
#include <stdlib.h>
#endif
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
+#include "util/u_debug_stack.h"
#include "util/u_double_list.h"
#define DEBUG_MEMORY_MAGIC 0x6e34090aU
+#define DEBUG_MEMORY_STACK 0 /* XXX: disabled until we have symbol lookup */
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
@@ -71,7 +73,11 @@ struct debug_memory_header
const char *file;
unsigned line;
const char *function;
+#if DEBUG_MEMORY_STACK
+ struct debug_stack_frame backtrace[DEBUG_MEMORY_STACK];
+#endif
size_t size;
+
unsigned magic;
};
@@ -136,6 +142,10 @@ debug_malloc(const char *file, unsigned line, const char *function,
hdr->size = size;
hdr->magic = DEBUG_MEMORY_MAGIC;
+#if DEBUG_MEMORY_STACK
+ debug_backtrace_capture(hdr->backtrace, 0, DEBUG_MEMORY_STACK);
+#endif
+
ftr = footer_from_header(hdr);
ftr->magic = DEBUG_MEMORY_MAGIC;
@@ -290,6 +300,9 @@ debug_memory_end(unsigned long start_no)
debug_printf("%s:%u:%s: %u bytes at %p not freed\n",
hdr->file, hdr->line, hdr->function,
hdr->size, ptr);
+#if DEBUG_MEMORY_STACK
+ debug_backtrace_dump(hdr->backtrace, DEBUG_MEMORY_STACK);
+#endif
total_size += hdr->size;
}
diff --git a/src/gallium/auxiliary/util/p_debug_prof.c b/src/gallium/auxiliary/util/u_debug_profile.c
index 5f9772ef91..6d8b244c3a 100644
--- a/src/gallium/auxiliary/util/p_debug_prof.c
+++ b/src/gallium/auxiliary/util/u_debug_profile.c
@@ -42,7 +42,7 @@
#include <windows.h>
#include <winddi.h>
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_string.h"
diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c
new file mode 100644
index 0000000000..76068a6509
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_debug_stack.c
@@ -0,0 +1,97 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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
+ * Stack backtracing.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+#include "u_debug.h"
+#include "u_debug_stack.h"
+
+
+void
+debug_backtrace_capture(struct debug_stack_frame *backtrace,
+ unsigned start_frame,
+ unsigned nr_frames)
+{
+ const void **frame_pointer = NULL;
+ unsigned i = 0;
+
+ if(!nr_frames)
+ return;
+
+#if defined(PIPE_CC_GCC)
+ frame_pointer = ((const void **)__builtin_frame_address(1));
+#elif defined(PIPE_CC_MSVC)
+ __asm {
+ mov frame_pointer, ebp
+ }
+ frame_pointer = (const void **)frame_pointer[0];
+#else
+ frame_pointer = NULL;
+#endif
+
+
+#ifdef PIPE_ARCH_X86
+ while(nr_frames) {
+ if(!frame_pointer)
+ break;
+
+ if(start_frame)
+ --start_frame;
+ else {
+ backtrace[i++].function = frame_pointer[1];
+ --nr_frames;
+ }
+
+ frame_pointer = (const void **)frame_pointer[0];
+ }
+#endif
+
+ while(nr_frames) {
+ backtrace[i++].function = NULL;
+ --nr_frames;
+ }
+}
+
+
+void
+debug_backtrace_dump(const struct debug_stack_frame *backtrace,
+ unsigned nr_frames)
+{
+ unsigned i;
+
+ for(i = 0; i < nr_frames; ++i) {
+ if(!backtrace[i].function)
+ break;
+ debug_printf("\t%p\n", backtrace[i].function);
+ }
+}
+
diff --git a/src/gallium/state_trackers/wgl/stw.c b/src/gallium/auxiliary/util/u_debug_stack.h
index 8bccdad221..f50f04e0f7 100644
--- a/src/gallium/state_trackers/wgl/stw.c
+++ b/src/gallium/auxiliary/util/u_debug_stack.h
@@ -1,8 +1,8 @@
/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
+ *
+ * Copyright 2009 VMware, Inc.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -10,48 +10,56 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "stw.h"
-#include "shared/stw_winsys.h"
+#ifndef U_DEBUG_STACK_H_
+#define U_DEBUG_STACK_H_
-boolean
-st_init(const struct stw_winsys *stw_winsys)
-{
- if (!stw_shared_init( stw_winsys ))
- goto fail;
- if (!stw_icd_init())
- goto fail;
+/**
+ * @file
+ * Stack backtracing.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
- if (!stw_wgl_init())
- goto fail;
- return TRUE;
+#ifdef __cplusplus
+extern "C" {
+#endif
-fail:
- st_cleanup();
- return FALSE;
-}
+struct debug_stack_frame
+{
+ const void *function;
+};
+
void
-st_cleanup(void)
-{
- stw_icd_cleanup();
- stw_shared_cleanup();
- stw_wgl_cleanup();
+debug_backtrace_capture(struct debug_stack_frame *backtrace,
+ unsigned start_frame,
+ unsigned nr_frames);
+
+void
+debug_backtrace_dump(const struct debug_stack_frame *backtrace,
+ unsigned nr_frames);
+
+
+#ifdef __cplusplus
}
+#endif
+
+#endif /* U_DEBUG_STACK_H_ */
diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c
index f282f3d289..4110485fb1 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.c
+++ b/src/gallium/auxiliary/util/u_draw_quad.c
@@ -51,9 +51,11 @@ util_draw_vertex_buffer(struct pipe_context *pipe,
assert(num_attribs <= PIPE_MAX_ATTRIBS);
/* tell pipe about the vertex buffer */
+ memset(&vbuffer, 0, sizeof(vbuffer));
vbuffer.buffer = vbuf;
vbuffer.stride = num_attribs * 4 * sizeof(float); /* vertex size */
vbuffer.buffer_offset = offset;
+ vbuffer.max_index = num_verts - 1;
pipe->set_vertex_buffers(pipe, 1, &vbuffer);
/* tell pipe about the vertex attributes */
@@ -127,6 +129,6 @@ util_draw_texquad(struct pipe_context *pipe,
util_draw_vertex_buffer(pipe, vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, 2);
}
- pipe_buffer_reference(pipe->screen, &vbuf, NULL);
+ pipe_buffer_reference(&vbuf, NULL);
}
}
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 2b4cdab6cf..b32ad1cbe9 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -35,10 +35,11 @@
#include "pipe/p_context.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_state.h"
#include "util/u_memory.h"
#include "util/u_draw_quad.h"
@@ -61,10 +62,7 @@ struct gen_mipmap_state
struct pipe_depth_stencil_alpha_state depthstencil;
struct pipe_rasterizer_state rasterizer;
struct pipe_sampler_state sampler;
- struct pipe_viewport_state viewport;
- struct pipe_shader_state vert_shader;
- struct pipe_shader_state frag_shader;
void *vs;
void *fs;
@@ -78,15 +76,15 @@ struct gen_mipmap_state
enum dtype
{
- UBYTE,
- UBYTE_3_3_2,
- USHORT,
- USHORT_4_4_4_4,
- USHORT_5_6_5,
- USHORT_1_5_5_5_REV,
- UINT,
- FLOAT,
- HALF_FLOAT
+ DTYPE_UBYTE,
+ DTYPE_UBYTE_3_3_2,
+ DTYPE_USHORT,
+ DTYPE_USHORT_4_4_4_4,
+ DTYPE_USHORT_5_6_5,
+ DTYPE_USHORT_1_5_5_5_REV,
+ DTYPE_UINT,
+ DTYPE_FLOAT,
+ DTYPE_HALF_FLOAT
};
@@ -194,7 +192,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
assert(srcWidth == dstWidth || srcWidth == 2 * dstWidth);
*/
- if (datatype == UBYTE && comps == 4) {
+ if (datatype == DTYPE_UBYTE && comps == 4) {
uint i, j, k;
const ubyte(*rowA)[4] = (const ubyte(*)[4]) srcRowA;
const ubyte(*rowB)[4] = (const ubyte(*)[4]) srcRowB;
@@ -207,7 +205,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4;
}
}
- else if (datatype == UBYTE && comps == 3) {
+ else if (datatype == DTYPE_UBYTE && comps == 3) {
uint i, j, k;
const ubyte(*rowA)[3] = (const ubyte(*)[3]) srcRowA;
const ubyte(*rowB)[3] = (const ubyte(*)[3]) srcRowB;
@@ -219,7 +217,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4;
}
}
- else if (datatype == UBYTE && comps == 2) {
+ else if (datatype == DTYPE_UBYTE && comps == 2) {
uint i, j, k;
const ubyte(*rowA)[2] = (const ubyte(*)[2]) srcRowA;
const ubyte(*rowB)[2] = (const ubyte(*)[2]) srcRowB;
@@ -230,7 +228,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) >> 2;
}
}
- else if (datatype == UBYTE && comps == 1) {
+ else if (datatype == DTYPE_UBYTE && comps == 1) {
uint i, j, k;
const ubyte *rowA = (const ubyte *) srcRowA;
const ubyte *rowB = (const ubyte *) srcRowB;
@@ -241,7 +239,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
- else if (datatype == USHORT && comps == 4) {
+ else if (datatype == DTYPE_USHORT && comps == 4) {
uint i, j, k;
const ushort(*rowA)[4] = (const ushort(*)[4]) srcRowA;
const ushort(*rowB)[4] = (const ushort(*)[4]) srcRowB;
@@ -254,7 +252,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4;
}
}
- else if (datatype == USHORT && comps == 3) {
+ else if (datatype == DTYPE_USHORT && comps == 3) {
uint i, j, k;
const ushort(*rowA)[3] = (const ushort(*)[3]) srcRowA;
const ushort(*rowB)[3] = (const ushort(*)[3]) srcRowB;
@@ -266,7 +264,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4;
}
}
- else if (datatype == USHORT && comps == 2) {
+ else if (datatype == DTYPE_USHORT && comps == 2) {
uint i, j, k;
const ushort(*rowA)[2] = (const ushort(*)[2]) srcRowA;
const ushort(*rowB)[2] = (const ushort(*)[2]) srcRowB;
@@ -277,7 +275,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4;
}
}
- else if (datatype == USHORT && comps == 1) {
+ else if (datatype == DTYPE_USHORT && comps == 1) {
uint i, j, k;
const ushort *rowA = (const ushort *) srcRowA;
const ushort *rowB = (const ushort *) srcRowB;
@@ -288,7 +286,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
- else if (datatype == FLOAT && comps == 4) {
+ else if (datatype == DTYPE_FLOAT && comps == 4) {
uint i, j, k;
const float(*rowA)[4] = (const float(*)[4]) srcRowA;
const float(*rowB)[4] = (const float(*)[4]) srcRowB;
@@ -305,7 +303,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
rowB[j][3] + rowB[k][3]) * 0.25F;
}
}
- else if (datatype == FLOAT && comps == 3) {
+ else if (datatype == DTYPE_FLOAT && comps == 3) {
uint i, j, k;
const float(*rowA)[3] = (const float(*)[3]) srcRowA;
const float(*rowB)[3] = (const float(*)[3]) srcRowB;
@@ -320,7 +318,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
rowB[j][2] + rowB[k][2]) * 0.25F;
}
}
- else if (datatype == FLOAT && comps == 2) {
+ else if (datatype == DTYPE_FLOAT && comps == 2) {
uint i, j, k;
const float(*rowA)[2] = (const float(*)[2]) srcRowA;
const float(*rowB)[2] = (const float(*)[2]) srcRowB;
@@ -333,7 +331,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
rowB[j][1] + rowB[k][1]) * 0.25F;
}
}
- else if (datatype == FLOAT && comps == 1) {
+ else if (datatype == DTYPE_FLOAT && comps == 1) {
uint i, j, k;
const float *rowA = (const float *) srcRowA;
const float *rowB = (const float *) srcRowB;
@@ -345,7 +343,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
#if 0
- else if (datatype == HALF_FLOAT && comps == 4) {
+ else if (datatype == HALF_DTYPE_FLOAT && comps == 4) {
uint i, j, k, comp;
const half_float(*rowA)[4] = (const half_float(*)[4]) srcRowA;
const half_float(*rowB)[4] = (const half_float(*)[4]) srcRowB;
@@ -362,7 +360,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
}
- else if (datatype == HALF_FLOAT && comps == 3) {
+ else if (datatype == DTYPE_HALF_FLOAT && comps == 3) {
uint i, j, k, comp;
const half_float(*rowA)[3] = (const half_float(*)[3]) srcRowA;
const half_float(*rowB)[3] = (const half_float(*)[3]) srcRowB;
@@ -379,7 +377,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
}
- else if (datatype == HALF_FLOAT && comps == 2) {
+ else if (datatype == DTYPE_HALF_FLOAT && comps == 2) {
uint i, j, k, comp;
const half_float(*rowA)[2] = (const half_float(*)[2]) srcRowA;
const half_float(*rowB)[2] = (const half_float(*)[2]) srcRowB;
@@ -396,7 +394,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
}
- else if (datatype == HALF_FLOAT && comps == 1) {
+ else if (datatype == DTYPE_HALF_FLOAT && comps == 1) {
uint i, j, k;
const half_float *rowA = (const half_float *) srcRowA;
const half_float *rowB = (const half_float *) srcRowB;
@@ -413,7 +411,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
#endif
- else if (datatype == UINT && comps == 1) {
+ else if (datatype == DTYPE_UINT && comps == 1) {
uint i, j, k;
const uint *rowA = (const uint *) srcRowA;
const uint *rowB = (const uint *) srcRowB;
@@ -424,7 +422,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
- else if (datatype == USHORT_5_6_5 && comps == 3) {
+ else if (datatype == DTYPE_USHORT_5_6_5 && comps == 3) {
uint i, j, k;
const ushort *rowA = (const ushort *) srcRowA;
const ushort *rowB = (const ushort *) srcRowB;
@@ -449,7 +447,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (blue << 11) | (green << 5) | red;
}
}
- else if (datatype == USHORT_4_4_4_4 && comps == 4) {
+ else if (datatype == DTYPE_USHORT_4_4_4_4 && comps == 4) {
uint i, j, k;
const ushort *rowA = (const ushort *) srcRowA;
const ushort *rowB = (const ushort *) srcRowB;
@@ -479,7 +477,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (alpha << 12) | (blue << 8) | (green << 4) | red;
}
}
- else if (datatype == USHORT_1_5_5_5_REV && comps == 4) {
+ else if (datatype == DTYPE_USHORT_1_5_5_5_REV && comps == 4) {
uint i, j, k;
const ushort *rowA = (const ushort *) srcRowA;
const ushort *rowB = (const ushort *) srcRowB;
@@ -509,7 +507,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (alpha << 15) | (blue << 10) | (green << 5) | red;
}
}
- else if (datatype == UBYTE_3_3_2 && comps == 3) {
+ else if (datatype == DTYPE_UBYTE_3_3_2 && comps == 3) {
uint i, j, k;
const ubyte *rowA = (const ubyte *) srcRowA;
const ubyte *rowB = (const ubyte *) srcRowB;
@@ -570,7 +568,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
assert(comps >= 1);
assert(comps <= 4);
- if ((datatype == UBYTE) && (comps == 4)) {
+ if ((datatype == DTYPE_UBYTE) && (comps == 4)) {
DECLARE_ROW_POINTERS(ubyte, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -581,7 +579,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(3);
}
}
- else if ((datatype == UBYTE) && (comps == 3)) {
+ else if ((datatype == DTYPE_UBYTE) && (comps == 3)) {
DECLARE_ROW_POINTERS(ubyte, 3);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -591,7 +589,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(2);
}
}
- else if ((datatype == UBYTE) && (comps == 2)) {
+ else if ((datatype == DTYPE_UBYTE) && (comps == 2)) {
DECLARE_ROW_POINTERS(ubyte, 2);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -600,7 +598,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(1);
}
}
- else if ((datatype == UBYTE) && (comps == 1)) {
+ else if ((datatype == DTYPE_UBYTE) && (comps == 1)) {
DECLARE_ROW_POINTERS(ubyte, 1);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -608,7 +606,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(0);
}
}
- else if ((datatype == USHORT) && (comps == 4)) {
+ else if ((datatype == DTYPE_USHORT) && (comps == 4)) {
DECLARE_ROW_POINTERS(ushort, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -619,7 +617,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(3);
}
}
- else if ((datatype == USHORT) && (comps == 3)) {
+ else if ((datatype == DTYPE_USHORT) && (comps == 3)) {
DECLARE_ROW_POINTERS(ushort, 3);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -629,7 +627,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(2);
}
}
- else if ((datatype == USHORT) && (comps == 2)) {
+ else if ((datatype == DTYPE_USHORT) && (comps == 2)) {
DECLARE_ROW_POINTERS(ushort, 2);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -638,7 +636,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(1);
}
}
- else if ((datatype == USHORT) && (comps == 1)) {
+ else if ((datatype == DTYPE_USHORT) && (comps == 1)) {
DECLARE_ROW_POINTERS(ushort, 1);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -646,7 +644,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(0);
}
}
- else if ((datatype == FLOAT) && (comps == 4)) {
+ else if ((datatype == DTYPE_FLOAT) && (comps == 4)) {
DECLARE_ROW_POINTERS(float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -657,7 +655,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_F_3D(3);
}
}
- else if ((datatype == FLOAT) && (comps == 3)) {
+ else if ((datatype == DTYPE_FLOAT) && (comps == 3)) {
DECLARE_ROW_POINTERS(float, 3);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -667,7 +665,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_F_3D(2);
}
}
- else if ((datatype == FLOAT) && (comps == 2)) {
+ else if ((datatype == DTYPE_FLOAT) && (comps == 2)) {
DECLARE_ROW_POINTERS(float, 2);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -676,7 +674,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_F_3D(1);
}
}
- else if ((datatype == FLOAT) && (comps == 1)) {
+ else if ((datatype == DTYPE_FLOAT) && (comps == 1)) {
DECLARE_ROW_POINTERS(float, 1);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -684,7 +682,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_F_3D(0);
}
}
- else if ((datatype == HALF_FLOAT) && (comps == 4)) {
+ else if ((datatype == DTYPE_HALF_FLOAT) && (comps == 4)) {
DECLARE_ROW_POINTERS(half_float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -695,7 +693,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_HF_3D(3);
}
}
- else if ((datatype == HALF_FLOAT) && (comps == 3)) {
+ else if ((datatype == DTYPE_HALF_FLOAT) && (comps == 3)) {
DECLARE_ROW_POINTERS(half_float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -705,7 +703,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_HF_3D(2);
}
}
- else if ((datatype == HALF_FLOAT) && (comps == 2)) {
+ else if ((datatype == DTYPE_HALF_FLOAT) && (comps == 2)) {
DECLARE_ROW_POINTERS(half_float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -714,7 +712,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_HF_3D(1);
}
}
- else if ((datatype == HALF_FLOAT) && (comps == 1)) {
+ else if ((datatype == DTYPE_HALF_FLOAT) && (comps == 1)) {
DECLARE_ROW_POINTERS(half_float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -722,7 +720,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_HF_3D(0);
}
}
- else if ((datatype == UINT) && (comps == 1)) {
+ else if ((datatype == DTYPE_UINT) && (comps == 1)) {
const uint *rowA = (const uint *) srcRowA;
const uint *rowB = (const uint *) srcRowB;
const uint *rowC = (const uint *) srcRowC;
@@ -738,7 +736,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (float)((double) tmp * 0.125);
}
}
- else if ((datatype == USHORT_5_6_5) && (comps == 3)) {
+ else if ((datatype == DTYPE_USHORT_5_6_5) && (comps == 3)) {
DECLARE_ROW_POINTERS0(ushort);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -776,7 +774,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (b << 11) | (g << 5) | r;
}
}
- else if ((datatype == USHORT_4_4_4_4) && (comps == 4)) {
+ else if ((datatype == DTYPE_USHORT_4_4_4_4) && (comps == 4)) {
DECLARE_ROW_POINTERS0(ushort);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -825,7 +823,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (a << 12) | (b << 8) | (g << 4) | r;
}
}
- else if ((datatype == USHORT_1_5_5_5_REV) && (comps == 4)) {
+ else if ((datatype == DTYPE_USHORT_1_5_5_5_REV) && (comps == 4)) {
DECLARE_ROW_POINTERS0(ushort);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -874,7 +872,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (a << 15) | (b << 10) | (g << 5) | r;
}
}
- else if ((datatype == UBYTE_3_3_2) && (comps == 3)) {
+ else if ((datatype == DTYPE_UBYTE_3_3_2) && (comps == 3)) {
DECLARE_ROW_POINTERS0(ushort);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -928,34 +926,34 @@ format_to_type_comps(enum pipe_format pformat,
case PIPE_FORMAT_X8R8G8B8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_B8G8R8X8_UNORM:
- *datatype = UBYTE;
+ *datatype = DTYPE_UBYTE;
*comps = 4;
return;
case PIPE_FORMAT_A1R5G5B5_UNORM:
- *datatype = USHORT_1_5_5_5_REV;
+ *datatype = DTYPE_USHORT_1_5_5_5_REV;
*comps = 4;
return;
case PIPE_FORMAT_A4R4G4B4_UNORM:
- *datatype = USHORT_4_4_4_4;
+ *datatype = DTYPE_USHORT_4_4_4_4;
*comps = 4;
return;
case PIPE_FORMAT_R5G6B5_UNORM:
- *datatype = USHORT_5_6_5;
+ *datatype = DTYPE_USHORT_5_6_5;
*comps = 3;
return;
case PIPE_FORMAT_L8_UNORM:
case PIPE_FORMAT_A8_UNORM:
case PIPE_FORMAT_I8_UNORM:
- *datatype = UBYTE;
+ *datatype = DTYPE_UBYTE;
*comps = 1;
return;
case PIPE_FORMAT_A8L8_UNORM:
- *datatype = UBYTE;
+ *datatype = DTYPE_UBYTE;
*comps = 2;
return;
default:
assert(0);
- *datatype = UBYTE;
+ *datatype = DTYPE_UBYTE;
*comps = 0;
break;
}
@@ -1116,31 +1114,30 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
void *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
-
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
reduce_1d(pt->format,
- srcSurf->width, srcMap,
- dstSurf->width, dstMap);
+ srcTrans->width, srcMap,
+ dstTrans->width, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_destroy(srcTrans);
+ screen->tex_transfer_destroy(dstTrans);
}
}
@@ -1160,32 +1157,32 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
reduce_2d(pt->format,
- srcSurf->width, srcSurf->height,
- srcSurf->stride, srcMap,
- dstSurf->width, dstSurf->height,
- dstSurf->stride, dstMap);
+ srcTrans->width, srcTrans->height,
+ srcTrans->stride, srcMap,
+ dstTrans->width, dstTrans->height,
+ dstTrans->stride, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_destroy(srcTrans);
+ screen->tex_transfer_destroy(dstTrans);
}
}
@@ -1195,6 +1192,7 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_texture *pt,
uint face, uint baseLevel, uint lastLevel)
{
+#if 0
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
uint dstLevel, zslice = 0;
@@ -1204,37 +1202,36 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
-#if 0
reduce_3d(pt->format,
- srcSurf->width, srcSurf->height,
- srcSurf->stride, srcMap,
- dstSurf->width, dstSurf->height,
- dstSurf->stride, dstMap);
-#else
- (void) reduce_3d;
-#endif
+ srcTrans->width, srcTrans->height,
+ srcTrans->stride, srcMap,
+ dstTrans->width, dstTrans->height,
+ dstTrans->stride, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_destroy(srcTrans);
+ screen->tex_transfer_destroy(dstTrans);
}
+#else
+ (void) reduce_3d;
+#endif
}
@@ -1294,8 +1291,7 @@ util_create_gen_mipmap(struct pipe_context *pipe,
memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
ctx->rasterizer.front_winding = PIPE_WINDING_CW;
ctx->rasterizer.cull_mode = PIPE_WINDING_NONE;
- ctx->rasterizer.bypass_clipping = 1;
- /*ctx->rasterizer.bypass_vs = 1;*/
+ ctx->rasterizer.bypass_vs_clip_and_viewport = 1;
ctx->rasterizer.gl_rasterization_rules = 1;
/* sampler state */
@@ -1306,28 +1302,19 @@ util_create_gen_mipmap(struct pipe_context *pipe,
ctx->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
ctx->sampler.normalized_coords = 1;
- /* viewport state (identity, verts are in wincoords) */
- ctx->viewport.scale[0] = 1.0;
- ctx->viewport.scale[1] = 1.0;
- ctx->viewport.scale[2] = 1.0;
- ctx->viewport.scale[3] = 1.0;
- ctx->viewport.translate[0] = 0.0;
- ctx->viewport.translate[1] = 0.0;
- ctx->viewport.translate[2] = 0.0;
- ctx->viewport.translate[3] = 0.0;
-
- /* vertex shader */
+ /* vertex shader - still needed to specify mapping from fragment
+ * shader input semantics to vertex elements
+ */
{
const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC };
const uint semantic_indexes[] = { 0, 0 };
ctx->vs = util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
- semantic_indexes,
- &ctx->vert_shader);
+ semantic_indexes);
}
/* fragment shader */
- ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader);
+ ctx->fs = util_make_fragment_tex_shader(pipe);
/* vertex data that doesn't change */
for (i = 0; i < 4; i++) {
@@ -1369,7 +1356,6 @@ get_next_slot(struct gen_mipmap_state *ctx)
static unsigned
set_vertex_data(struct gen_mipmap_state *ctx, float width, float height)
{
- void *buf;
unsigned offset;
ctx->vertices[0][0][0] = 0.0f; /*x*/
@@ -1394,12 +1380,8 @@ set_vertex_data(struct gen_mipmap_state *ctx, float width, float height)
offset = get_next_slot( ctx );
- buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- memcpy((char *)buf + offset, ctx->vertices, sizeof(ctx->vertices));
-
- pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
+ pipe_buffer_write(ctx->pipe->screen, ctx->vbuf,
+ offset, sizeof(ctx->vertices), ctx->vertices);
return offset;
}
@@ -1417,10 +1399,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
pipe->delete_vs_state(pipe, ctx->vs);
pipe->delete_fs_state(pipe, ctx->fs);
- FREE((void*) ctx->vert_shader.tokens);
- FREE((void*) ctx->frag_shader.tokens);
-
- pipe_buffer_reference(pipe->screen, &ctx->vbuf, NULL);
+ pipe_buffer_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -1432,7 +1411,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
*/
void util_gen_mipmap_flush( struct gen_mipmap_state *ctx )
{
- pipe_buffer_reference(ctx->pipe->screen, &ctx->vbuf, NULL);
+ pipe_buffer_reference(&ctx->vbuf, NULL);
ctx->vbuf_slot = 0;
}
@@ -1476,13 +1455,11 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
cso_save_framebuffer(ctx->cso);
cso_save_fragment_shader(ctx->cso);
cso_save_vertex_shader(ctx->cso);
- cso_save_viewport(ctx->cso);
/* bind our state */
cso_set_blend(ctx->cso, &ctx->blend);
cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil);
cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
- cso_set_viewport(ctx->cso, &ctx->viewport);
cso_set_fragment_shader_handle(ctx->cso, ctx->fs);
cso_set_vertex_shader_handle(ctx->cso, ctx->vs);
@@ -1528,7 +1505,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
cso_set_sampler_textures(ctx->cso, 1, &pt);
- /* quad coords in window coords (bypassing clipping, viewport mapping) */
+ /* quad coords in window coords (bypassing vs, clip and viewport) */
offset = set_vertex_data(ctx,
(float) pt->width[dstLevel],
(float) pt->height[dstLevel]);
@@ -1555,5 +1532,4 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
cso_restore_framebuffer(ctx->cso);
cso_restore_fragment_shader(ctx->cso);
cso_restore_vertex_shader(ctx->cso);
- cso_restore_viewport(ctx->cso);
}
diff --git a/src/gallium/auxiliary/util/u_handle_table.c b/src/gallium/auxiliary/util/u_handle_table.c
index 2d15932ce3..6da7353e25 100644
--- a/src/gallium/auxiliary/util/u_handle_table.c
+++ b/src/gallium/auxiliary/util/u_handle_table.c
@@ -34,7 +34,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_handle_table.h"
diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c
index 0bc8de9632..2f83e318e4 100644
--- a/src/gallium/auxiliary/util/u_hash_table.c
+++ b/src/gallium/auxiliary/util/u_hash_table.c
@@ -39,7 +39,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "cso_cache/cso_hash.h"
diff --git a/src/gallium/auxiliary/util/u_keymap.c b/src/gallium/auxiliary/util/u_keymap.c
index 01b17ddb1b..3f70809efd 100644
--- a/src/gallium/auxiliary/util/u_keymap.c
+++ b/src/gallium/auxiliary/util/u_keymap.c
@@ -35,7 +35,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_error.h"
#include "cso_cache/cso_hash.h"
diff --git a/src/gallium/auxiliary/util/u_linear.c b/src/gallium/auxiliary/util/u_linear.c
index e999cefe74..6be365e53b 100644
--- a/src/gallium/auxiliary/util/u_linear.c
+++ b/src/gallium/auxiliary/util/u_linear.c
@@ -1,5 +1,5 @@
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "u_linear.h"
void
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index ab6f39ac31..1ecde7a912 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -40,7 +40,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/util/u_memory.h b/src/gallium/auxiliary/util/u_memory.h
index 1a6b596421..0b18d043ad 100644
--- a/src/gallium/auxiliary/util/u_memory.h
+++ b/src/gallium/auxiliary/util/u_memory.h
@@ -36,7 +36,7 @@
#include "util/u_pointer.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#ifdef __cplusplus
@@ -52,11 +52,11 @@ extern "C" {
#endif
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG)
+#if defined(PIPE_OS_WINDOWS) && defined(DEBUG)
/* memory debugging */
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#define MALLOC( _size ) \
debug_malloc( __FILE__, __LINE__, __FUNCTION__, _size )
@@ -191,9 +191,11 @@ align_free(void *ptr)
#if defined(HAVE_POSIX_MEMALIGN)
FREE(ptr);
#else
- void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
- void *realAddr = *cubbyHole;
- FREE(realAddr);
+ if (ptr) {
+ void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
+ void *realAddr = *cubbyHole;
+ FREE(realAddr);
+ }
#endif /* defined(HAVE_POSIX_MEMALIGN) */
}
diff --git a/src/gallium/auxiliary/util/u_mm.c b/src/gallium/auxiliary/util/u_mm.c
index 45ce257b5e..151a480d34 100644
--- a/src/gallium/auxiliary/util/u_mm.c
+++ b/src/gallium/auxiliary/util/u_mm.c
@@ -24,7 +24,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_mm.h"
diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c
index fe81a685be..74259d453b 100644
--- a/src/gallium/auxiliary/util/u_rect.c
+++ b/src/gallium/auxiliary/util/u_rect.c
@@ -169,46 +169,35 @@ util_surface_copy(struct pipe_context *pipe,
unsigned w, unsigned h)
{
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *new_src = NULL, *new_dst = NULL;
+ struct pipe_transfer *src_trans, *dst_trans;
void *dst_map;
const void *src_map;
- assert(dst->block.size == src->block.size);
- assert(dst->block.width == src->block.width);
- assert(dst->block.height == src->block.height);
-
- if ((src->usage & PIPE_BUFFER_USAGE_CPU_READ) == 0) {
- /* Need to create new src surface which is CPU readable */
- assert(src->texture);
- if (!src->texture)
- return;
- new_src = screen->get_tex_surface(screen,
+ assert(src->texture && dst->texture);
+ if (!src->texture || !dst->texture)
+ return;
+ src_trans = screen->get_tex_transfer(screen,
src->texture,
src->face,
src->level,
src->zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- src = new_src;
- }
+ PIPE_TRANSFER_READ,
+ src_x, src_y, w, h);
- if ((dst->usage & PIPE_BUFFER_USAGE_CPU_WRITE) == 0) {
- /* Need to create new dst surface which is CPU writable */
- assert(dst->texture);
- if (!dst->texture)
- return;
- new_dst = screen->get_tex_surface(screen,
+ dst_trans = screen->get_tex_transfer(screen,
dst->texture,
dst->face,
dst->level,
dst->zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- dst = new_dst;
- }
+ PIPE_TRANSFER_WRITE,
+ dst_x, dst_y, w, h);
- src_map = pipe->screen->surface_map(screen,
- src, PIPE_BUFFER_USAGE_CPU_READ);
- dst_map = pipe->screen->surface_map(screen,
- dst, PIPE_BUFFER_USAGE_CPU_WRITE);
+ assert(dst_trans->block.size == src_trans->block.size);
+ assert(dst_trans->block.width == src_trans->block.width);
+ assert(dst_trans->block.height == src_trans->block.height);
+
+ src_map = pipe->screen->transfer_map(screen, src_trans);
+ dst_map = pipe->screen->transfer_map(screen, dst_trans);
assert(src_map);
assert(dst_map);
@@ -216,36 +205,25 @@ util_surface_copy(struct pipe_context *pipe,
if (src_map && dst_map) {
/* If do_flip, invert src_y position and pass negative src stride */
pipe_copy_rect(dst_map,
- &dst->block,
- dst->stride,
- dst_x, dst_y,
+ &dst_trans->block,
+ dst_trans->stride,
+ 0, 0,
w, h,
src_map,
- do_flip ? -(int) src->stride : src->stride,
- src_x,
- do_flip ? src_y + h - 1 : src_y);
+ do_flip ? -(int) src_trans->stride : src_trans->stride,
+ 0,
+ do_flip ? h - 1 : 0);
}
- pipe->screen->surface_unmap(pipe->screen, src);
- pipe->screen->surface_unmap(pipe->screen, dst);
+ pipe->screen->transfer_unmap(pipe->screen, src_trans);
+ pipe->screen->transfer_unmap(pipe->screen, dst_trans);
- if (new_src)
- screen->tex_surface_release(screen, &new_src);
- if (new_dst)
- screen->tex_surface_release(screen, &new_dst);
+ screen->tex_transfer_destroy(src_trans);
+ screen->tex_transfer_destroy(dst_trans);
}
-static void *
-get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y)
-{
- return (char *)dst_map
- + y / dst->block.height * dst->stride
- + x / dst->block.width * dst->block.size;
-}
-
-
#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8))
@@ -260,42 +238,38 @@ util_surface_fill(struct pipe_context *pipe,
unsigned width, unsigned height, unsigned value)
{
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *new_dst = NULL;
+ struct pipe_transfer *dst_trans;
void *dst_map;
- if ((dst->usage & PIPE_BUFFER_USAGE_CPU_WRITE) == 0) {
- /* Need to create new dst surface which is CPU writable */
- assert(dst->texture);
- if (!dst->texture)
- return;
- new_dst = screen->get_tex_surface(screen,
+ assert(dst->texture);
+ if (!dst->texture)
+ return;
+ dst_trans = screen->get_tex_transfer(screen,
dst->texture,
dst->face,
dst->level,
dst->zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- dst = new_dst;
- }
+ PIPE_TRANSFER_WRITE,
+ dstx, dsty, width, height);
- dst_map = pipe->screen->surface_map(screen,
- dst, PIPE_BUFFER_USAGE_CPU_WRITE);
+ dst_map = pipe->screen->transfer_map(screen, dst_trans);
assert(dst_map);
if (dst_map) {
- assert(dst->stride > 0);
+ assert(dst_trans->stride > 0);
- switch (dst->block.size) {
+ switch (dst_trans->block.size) {
case 1:
case 2:
case 4:
- pipe_fill_rect(dst_map, &dst->block, dst->stride,
- dstx, dsty, width, height, value);
+ pipe_fill_rect(dst_map, &dst_trans->block, dst_trans->stride,
+ 0, 0, width, height, value);
break;
case 8:
{
/* expand the 4-byte clear value to an 8-byte value */
- ushort *row = (ushort *) get_pointer(dst, dst_map, dstx, dsty);
+ ushort *row = (ushort *) dst_map;
ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
@@ -312,7 +286,7 @@ util_surface_fill(struct pipe_context *pipe,
row[j*4+2] = val2;
row[j*4+3] = val3;
}
- row += dst->stride/2;
+ row += dst_trans->stride/2;
}
}
break;
@@ -322,8 +296,6 @@ util_surface_fill(struct pipe_context *pipe,
}
}
- pipe->screen->surface_unmap(pipe->screen, dst);
-
- if (new_dst)
- screen->tex_surface_release(screen, &new_dst);
+ pipe->screen->transfer_unmap(pipe->screen, dst_trans);
+ screen->tex_transfer_destroy(dst_trans);
}
diff --git a/src/gallium/auxiliary/util/u_simple_screen.c b/src/gallium/auxiliary/util/u_simple_screen.c
index 089bbbc48a..8114b53cd0 100644
--- a/src/gallium/auxiliary/util/u_simple_screen.c
+++ b/src/gallium/auxiliary/util/u_simple_screen.c
@@ -28,6 +28,7 @@
#include "u_simple_screen.h"
#include "pipe/p_screen.h"
+#include "pipe/p_state.h"
#include "pipe/internal/p_winsys_screen.h"
@@ -37,8 +38,12 @@ pass_buffer_create(struct pipe_screen *screen,
unsigned usage,
unsigned size)
{
- return screen->winsys->buffer_create(screen->winsys,
- alignment, usage, size);
+ struct pipe_buffer *buffer =
+ screen->winsys->buffer_create(screen->winsys, alignment, usage, size);
+
+ buffer->screen = screen;
+
+ return buffer;
}
static struct pipe_buffer *
@@ -46,8 +51,13 @@ pass_user_buffer_create(struct pipe_screen *screen,
void *ptr,
unsigned bytes)
{
- return screen->winsys->user_buffer_create(screen->winsys,
+ struct pipe_buffer *buffer =
+ screen->winsys->user_buffer_create(screen->winsys,
ptr, bytes);
+
+ buffer->screen = screen;
+
+ return buffer;
}
static struct pipe_buffer *
@@ -57,9 +67,14 @@ pass_surface_buffer_create(struct pipe_screen *screen,
unsigned usage,
unsigned *stride)
{
- return screen->winsys->surface_buffer_create(screen->winsys,
+ struct pipe_buffer *buffer =
+ screen->winsys->surface_buffer_create(screen->winsys,
width, height,
format, usage, stride);
+
+ buffer->screen = screen;
+
+ return buffer;
}
static void *
@@ -79,10 +94,9 @@ pass_buffer_unmap(struct pipe_screen *screen,
}
static void
-pass_buffer_destroy(struct pipe_screen *screen,
- struct pipe_buffer *buf)
+pass_buffer_destroy(struct pipe_buffer *buf)
{
- screen->winsys->buffer_destroy(screen->winsys, buf);
+ buf->screen->winsys->buffer_destroy(buf);
}
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index 706155e99a..e519c354d2 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -34,9 +34,8 @@
#include "pipe/p_context.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
#include "pipe/p_screen.h"
#include "pipe/p_shader_tokens.h"
@@ -56,12 +55,11 @@ void *
util_make_vertex_passthrough_shader(struct pipe_context *pipe,
uint num_attribs,
const uint *semantic_names,
- const uint *semantic_indexes,
- struct pipe_shader_state *shader)
+ const uint *semantic_indexes)
{
- uint maxTokens = 100;
- struct tgsi_token *tokens;
+ struct pipe_shader_state shader;
+ struct tgsi_token tokens[100];
struct tgsi_header *header;
struct tgsi_processor *processor;
struct tgsi_full_declaration decl;
@@ -69,8 +67,6 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
const uint procType = TGSI_PROCESSOR_VERTEX;
uint ti, i;
- tokens = (struct tgsi_token *) MALLOC(maxTokens * sizeof(tokens[0]));
-
/* shader header
*/
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -97,7 +93,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
- maxTokens - ti);
+ Elements(tokens) - ti);
}
/* declare outputs */
@@ -112,7 +108,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
- maxTokens - ti);
+ Elements(tokens) - ti);
}
/* emit MOV instructions */
@@ -129,7 +125,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
ti += tgsi_build_full_instruction(&inst,
&tokens[ti],
header,
- maxTokens - ti );
+ Elements(tokens) - ti );
}
/* END instruction */
@@ -140,16 +136,15 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
ti += tgsi_build_full_instruction(&inst,
&tokens[ti],
header,
- maxTokens - ti );
+ Elements(tokens) - ti );
#if 0 /*debug*/
tgsi_dump(tokens, 0);
#endif
- shader->tokens = tokens;
- /*shader->num_tokens = ti;*/
+ shader.tokens = tokens;
- return pipe->create_vs_state(pipe, shader);
+ return pipe->create_vs_state(pipe, &shader);
}
@@ -161,11 +156,10 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
* END;
*/
void *
-util_make_fragment_tex_shader(struct pipe_context *pipe,
- struct pipe_shader_state *shader)
+util_make_fragment_tex_shader(struct pipe_context *pipe)
{
- uint maxTokens = 100;
- struct tgsi_token *tokens;
+ struct pipe_shader_state shader;
+ struct tgsi_token tokens[100];
struct tgsi_header *header;
struct tgsi_processor *processor;
struct tgsi_full_declaration decl;
@@ -173,8 +167,6 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
const uint procType = TGSI_PROCESSOR_FRAGMENT;
uint ti;
- tokens = (struct tgsi_token *) MALLOC(maxTokens * sizeof(tokens[0]));
-
/* shader header
*/
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -200,7 +192,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
- maxTokens - ti);
+ Elements(tokens) - ti);
/* declare color[0] output */
decl = tgsi_default_full_declaration();
@@ -213,7 +205,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
- maxTokens - ti);
+ Elements(tokens) - ti);
/* declare sampler */
decl = tgsi_default_full_declaration();
@@ -223,7 +215,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
- maxTokens - ti);
+ Elements(tokens) - ti);
/* TEX instruction */
inst = tgsi_default_full_instruction();
@@ -240,7 +232,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
ti += tgsi_build_full_instruction(&inst,
&tokens[ti],
header,
- maxTokens - ti );
+ Elements(tokens) - ti );
/* END instruction */
inst = tgsi_default_full_instruction();
@@ -250,16 +242,15 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
ti += tgsi_build_full_instruction(&inst,
&tokens[ti],
header,
- maxTokens - ti );
+ Elements(tokens) - ti );
#if 0 /*debug*/
tgsi_dump(tokens, 0);
#endif
- shader->tokens = tokens;
- /*shader->num_tokens = ti;*/
+ shader.tokens = tokens;
- return pipe->create_fs_state(pipe, shader);
+ return pipe->create_fs_state(pipe, &shader);
}
@@ -270,11 +261,10 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
* Make simple fragment color pass-through shader.
*/
void *
-util_make_fragment_passthrough_shader(struct pipe_context *pipe,
- struct pipe_shader_state *shader)
+util_make_fragment_passthrough_shader(struct pipe_context *pipe)
{
- uint maxTokens = 40;
- struct tgsi_token *tokens;
+ struct pipe_shader_state shader;
+ struct tgsi_token tokens[40];
struct tgsi_header *header;
struct tgsi_processor *processor;
struct tgsi_full_declaration decl;
@@ -282,8 +272,6 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
const uint procType = TGSI_PROCESSOR_FRAGMENT;
uint ti;
- tokens = (struct tgsi_token *) MALLOC(maxTokens * sizeof(tokens[0]));
-
/* shader header
*/
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -307,7 +295,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
- maxTokens - ti);
+ Elements(tokens) - ti);
/* declare output */
decl = tgsi_default_full_declaration();
@@ -320,7 +308,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
- maxTokens - ti);
+ Elements(tokens) - ti);
/* MOVE out[0], in[0]; */
@@ -335,7 +323,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
ti += tgsi_build_full_instruction(&inst,
&tokens[ti],
header,
- maxTokens - ti );
+ Elements(tokens) - ti );
/* END instruction */
inst = tgsi_default_full_instruction();
@@ -345,17 +333,17 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
ti += tgsi_build_full_instruction(&inst,
&tokens[ti],
header,
- maxTokens - ti );
+ Elements(tokens) - ti );
- assert(ti < maxTokens);
+ assert(ti < Elements(tokens));
#if 0 /*debug*/
tgsi_dump(tokens, 0);
#endif
- shader->tokens = tokens;
- /*shader->num_tokens = ti;*/
+ shader.tokens = tokens;
- return pipe->create_fs_state(pipe, shader);
+ return pipe->create_fs_state(pipe, &shader);
}
+
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h b/src/gallium/auxiliary/util/u_simple_shaders.h
index 8ca4977d71..6f8d96af9b 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.h
+++ b/src/gallium/auxiliary/util/u_simple_shaders.h
@@ -46,18 +46,15 @@ extern void *
util_make_vertex_passthrough_shader(struct pipe_context *pipe,
uint num_attribs,
const uint *semantic_names,
- const uint *semantic_indexes,
- struct pipe_shader_state *shader);
+ const uint *semantic_indexes);
extern void *
-util_make_fragment_tex_shader(struct pipe_context *pipe,
- struct pipe_shader_state *shader);
+util_make_fragment_tex_shader(struct pipe_context *pipe);
extern void *
-util_make_fragment_passthrough_shader(struct pipe_context *pipe,
- struct pipe_shader_state *shader);
+util_make_fragment_passthrough_shader(struct pipe_context *pipe);
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/util/u_stream_stdc.c b/src/gallium/auxiliary/util/u_stream_stdc.c
index ca80bef0f3..0ead45a749 100644
--- a/src/gallium/auxiliary/util/u_stream_stdc.c
+++ b/src/gallium/auxiliary/util/u_stream_stdc.c
@@ -32,7 +32,7 @@
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX) || defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_SUBSYSTEM_WINDOWS_USER)
#include <stdio.h>
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index 32f6b072a0..d31ca9c029 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -28,7 +28,6 @@
/**
* RGBA/float tile get/put functions.
* Usable both by drivers and state trackers.
- * Surfaces should already be in a mapped state.
*/
@@ -42,58 +41,58 @@
/**
- * Move raw block of pixels from surface to user memory.
- * This should be usable by any hw driver that has mappable surfaces.
+ * Move raw block of pixels from transfer object to user memory.
*/
void
-pipe_get_tile_raw(struct pipe_surface *ps,
+pipe_get_tile_raw(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
void *dst, int dst_stride)
{
+ struct pipe_screen *screen = pt->texture->screen;
const void *src;
if (dst_stride == 0)
- dst_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size;
+ dst_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- src = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ);
+ src = screen->transfer_map(screen, pt);
assert(src);
if(!src)
return;
- pipe_copy_rect(dst, &ps->block, dst_stride, 0, 0, w, h, src, ps->stride, x, y);
+ pipe_copy_rect(dst, &pt->block, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
- pipe_surface_unmap(ps);
+ screen->transfer_unmap(screen, pt);
}
/**
- * Move raw block of pixels from user memory to surface.
- * This should be usable by any hw driver that has mappable surfaces.
+ * Move raw block of pixels from user memory to transfer object.
*/
void
-pipe_put_tile_raw(struct pipe_surface *ps,
+pipe_put_tile_raw(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const void *src, int src_stride)
{
+ struct pipe_screen *screen = pt->texture->screen;
void *dst;
if (src_stride == 0)
- src_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size;
+ src_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- dst = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE);
+ dst = screen->transfer_map(screen, pt);
assert(dst);
if(!dst)
return;
- pipe_copy_rect(dst, &ps->block, ps->stride, x, y, w, h, src, src_stride, 0, 0);
+ pipe_copy_rect(dst, &pt->block, pt->stride, x, y, w, h, src, src_stride, 0, 0);
- pipe_surface_unmap(ps);
+ screen->transfer_unmap(screen, pt);
}
@@ -883,6 +882,27 @@ ycbcr_get_tile_rgba(const ushort *src,
}
+static void
+fake_get_tile_rgba(const ushort *src,
+ unsigned w, unsigned h,
+ float *p,
+ unsigned dst_stride)
+{
+ unsigned i, j;
+
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++, pRow += 4) {
+ pRow[0] =
+ pRow[1] =
+ pRow[2] =
+ pRow[3] = (i ^ j) & 1 ? 1.0f : 0.0f;
+ }
+ p += dst_stride;
+ }
+}
+
+
void
pipe_tile_raw_to_rgba(enum pipe_format format,
void *src,
@@ -949,55 +969,56 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
ycbcr_get_tile_rgba((ushort *) src, w, h, dst, dst_stride, TRUE);
break;
default:
- assert(0);
+ debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(format));
+ fake_get_tile_rgba(src, w, h, dst, dst_stride);
}
}
void
-pipe_get_tile_rgba(struct pipe_surface *ps,
+pipe_get_tile_rgba(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
float *p)
{
unsigned dst_stride = w * 4;
void *packed;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(&ps->block, w, h) * ps->block.size);
+ packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
if (!packed)
return;
- if(ps->format == PIPE_FORMAT_YCBCR || ps->format == PIPE_FORMAT_YCBCR_REV)
+ if(pt->format == PIPE_FORMAT_YCBCR || pt->format == PIPE_FORMAT_YCBCR_REV)
assert((x & 1) == 0);
- pipe_get_tile_raw(ps, x, y, w, h, packed, 0);
+ pipe_get_tile_raw(pt, x, y, w, h, packed, 0);
- pipe_tile_raw_to_rgba(ps->format, packed, w, h, p, dst_stride);
+ pipe_tile_raw_to_rgba(pt->format, packed, w, h, p, dst_stride);
FREE(packed);
}
void
-pipe_put_tile_rgba(struct pipe_surface *ps,
+pipe_put_tile_rgba(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const float *p)
{
unsigned src_stride = w * 4;
void *packed;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(&ps->block, w, h) * ps->block.size);
+ packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
if (!packed)
return;
- switch (ps->format) {
+ switch (pt->format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
@@ -1051,10 +1072,10 @@ pipe_put_tile_rgba(struct pipe_surface *ps,
/*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
break;
default:
- assert(0);
+ debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(pt->format));
}
- pipe_put_tile_raw(ps, x, y, w, h, packed, 0);
+ pipe_put_tile_raw(pt, x, y, w, h, packed, 0);
FREE(packed);
}
@@ -1064,62 +1085,63 @@ pipe_put_tile_rgba(struct pipe_surface *ps,
* Get a block of Z values, converted to 32-bit range.
*/
void
-pipe_get_tile_z(struct pipe_surface *ps,
+pipe_get_tile_z(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
uint *z)
{
+ struct pipe_screen *screen = pt->texture->screen;
const uint dstStride = w;
ubyte *map;
uint *pDest = z;
uint i, j;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- map = (ubyte *)pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ);
+ map = (ubyte *)screen->transfer_map(screen, pt);
if (!map) {
assert(0);
return;
}
- switch (ps->format) {
+ switch (pt->format) {
case PIPE_FORMAT_Z32_UNORM:
{
- const uint *pSrc
- = (const uint *)(map + y * ps->stride + x*4);
+ const uint *ptrc
+ = (const uint *)(map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
- memcpy(pDest, pSrc, 4 * w);
+ memcpy(pDest, ptrc, 4 * w);
pDest += dstStride;
- pSrc += ps->stride/4;
+ ptrc += pt->stride/4;
}
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
{
- const uint *pSrc
- = (const uint *)(map + y * ps->stride + x*4);
+ const uint *ptrc
+ = (const uint *)(map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 24-bit Z to 32-bit Z */
- pDest[j] = (pSrc[j] << 8) | (pSrc[j] & 0xff);
+ pDest[j] = (ptrc[j] << 8) | (ptrc[j] & 0xff);
}
pDest += dstStride;
- pSrc += ps->stride/4;
+ ptrc += pt->stride/4;
}
}
break;
case PIPE_FORMAT_Z16_UNORM:
{
- const ushort *pSrc
- = (const ushort *)(map + y * ps->stride + x*2);
+ const ushort *ptrc
+ = (const ushort *)(map + y * pt->stride + x*2);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 16-bit Z to 32-bit Z */
- pDest[j] = (pSrc[j] << 16) | pSrc[j];
+ pDest[j] = (ptrc[j] << 16) | ptrc[j];
}
pDest += dstStride;
- pSrc += ps->stride/2;
+ ptrc += pt->stride/2;
}
}
break;
@@ -1127,64 +1149,65 @@ pipe_get_tile_z(struct pipe_surface *ps,
assert(0);
}
- pipe_surface_unmap(ps);
+ screen->transfer_unmap(screen, pt);
}
void
-pipe_put_tile_z(struct pipe_surface *ps,
+pipe_put_tile_z(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const uint *zSrc)
{
+ struct pipe_screen *screen = pt->texture->screen;
const uint srcStride = w;
- const uint *pSrc = zSrc;
+ const uint *ptrc = zSrc;
ubyte *map;
uint i, j;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- map = (ubyte *)pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = (ubyte *)screen->transfer_map(screen, pt);
if (!map) {
assert(0);
return;
}
- switch (ps->format) {
+ switch (pt->format) {
case PIPE_FORMAT_Z32_UNORM:
{
- uint *pDest = (uint *) (map + y * ps->stride + x*4);
+ uint *pDest = (uint *) (map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
- memcpy(pDest, pSrc, 4 * w);
- pDest += ps->stride/4;
- pSrc += srcStride;
+ memcpy(pDest, ptrc, 4 * w);
+ pDest += pt->stride/4;
+ ptrc += srcStride;
}
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
{
- uint *pDest = (uint *) (map + y * ps->stride + x*4);
+ uint *pDest = (uint *) (map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 32-bit Z to 24-bit Z (0 stencil) */
- pDest[j] = pSrc[j] >> 8;
+ pDest[j] = ptrc[j] >> 8;
}
- pDest += ps->stride/4;
- pSrc += srcStride;
+ pDest += pt->stride/4;
+ ptrc += srcStride;
}
}
break;
case PIPE_FORMAT_Z16_UNORM:
{
- ushort *pDest = (ushort *) (map + y * ps->stride + x*2);
+ ushort *pDest = (ushort *) (map + y * pt->stride + x*2);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 32-bit Z to 16-bit Z */
- pDest[j] = pSrc[j] >> 16;
+ pDest[j] = ptrc[j] >> 16;
}
- pDest += ps->stride/2;
- pSrc += srcStride;
+ pDest += pt->stride/2;
+ ptrc += srcStride;
}
}
break;
@@ -1192,7 +1215,7 @@ pipe_put_tile_z(struct pipe_surface *ps,
assert(0);
}
- pipe_surface_unmap(ps);
+ screen->transfer_unmap(screen, pt);
}
diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h
index a8ac805308..1453af38b8 100644
--- a/src/gallium/auxiliary/util/u_tile.h
+++ b/src/gallium/auxiliary/util/u_tile.h
@@ -30,24 +30,24 @@
#include "pipe/p_compiler.h"
-struct pipe_surface;
+struct pipe_transfer;
/**
- * Clip tile against surface dims.
+ * Clip tile against transfer dims.
* \return TRUE if tile is totally clipped, FALSE otherwise
*/
static INLINE boolean
-pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_surface *ps)
+pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_transfer *pt)
{
- if (x >= ps->width)
+ if (x >= pt->width)
return TRUE;
- if (y >= ps->height)
+ if (y >= pt->height)
return TRUE;
- if (x + *w > ps->width)
- *w = ps->width - x;
- if (y + *h > ps->height)
- *h = ps->height - y;
+ if (x + *w > pt->width)
+ *w = pt->width - x;
+ if (y + *h > pt->height)
+ *h = pt->height - y;
return FALSE;
}
@@ -56,34 +56,34 @@ extern "C" {
#endif
void
-pipe_get_tile_raw(struct pipe_surface *ps,
+pipe_get_tile_raw(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
void *p, int dst_stride);
void
-pipe_put_tile_raw(struct pipe_surface *ps,
+pipe_put_tile_raw(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const void *p, int src_stride);
void
-pipe_get_tile_rgba(struct pipe_surface *ps,
+pipe_get_tile_rgba(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
float *p);
void
-pipe_put_tile_rgba(struct pipe_surface *ps,
+pipe_put_tile_rgba(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const float *p);
void
-pipe_get_tile_z(struct pipe_surface *ps,
+pipe_get_tile_z(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
uint *z);
void
-pipe_put_tile_z(struct pipe_surface *ps,
+pipe_put_tile_z(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const uint *z);
diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c
index dde2c74fa8..357d9360c9 100644
--- a/src/gallium/auxiliary/util/u_time.c
+++ b/src/gallium/auxiliary/util/u_time.c
@@ -35,7 +35,7 @@
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
#include <sys/time.h>
#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <windows.h>
@@ -77,7 +77,7 @@ util_time_get_frequency(void)
void
util_time_get(struct util_time *t)
{
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
gettimeofday(&t->tv, NULL);
#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
LONGLONG temp;
@@ -102,7 +102,7 @@ util_time_add(const struct util_time *t1,
int64_t usecs,
struct util_time *t2)
{
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
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)
@@ -124,7 +124,7 @@ int64_t
util_time_diff(const struct util_time *t1,
const struct util_time *t2)
{
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
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)
@@ -144,7 +144,7 @@ util_time_micros( void )
util_time_get(&t1);
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
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();
@@ -166,7 +166,7 @@ static INLINE int
util_time_compare(const struct util_time *t1,
const struct util_time *t2)
{
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
if (t1->tv.tv_sec < t2->tv.tv_sec)
return -1;
else if(t1->tv.tv_sec > t2->tv.tv_sec)
diff --git a/src/gallium/auxiliary/util/u_time.h b/src/gallium/auxiliary/util/u_time.h
index 35d97d16c7..4346ce1fa4 100644
--- a/src/gallium/auxiliary/util/u_time.h
+++ b/src/gallium/auxiliary/util/u_time.h
@@ -38,7 +38,7 @@
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
#include <time.h> /* timeval */
#include <unistd.h> /* usleep */
#endif
@@ -58,7 +58,7 @@ extern "C" {
*/
struct util_time
{
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
struct timeval tv;
#else
int64_t counter;
@@ -89,7 +89,7 @@ util_time_timeout(const struct util_time *start,
const struct util_time *end,
const struct util_time *curr);
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
#define util_time_sleep usleep
#else
void
diff --git a/src/gallium/auxiliary/util/u_timed_winsys.c b/src/gallium/auxiliary/util/u_timed_winsys.c
index f237e12d73..77b2a3a1c8 100644
--- a/src/gallium/auxiliary/util/u_timed_winsys.c
+++ b/src/gallium/auxiliary/util/u_timed_winsys.c
@@ -29,6 +29,7 @@
* Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
+#include "pipe/p_state.h"
#include "pipe/internal/p_winsys_screen.h"
#include "u_timed_winsys.h"
#include "util/u_memory.h"
@@ -178,13 +179,13 @@ timed_buffer_unmap(struct pipe_winsys *winsys,
static void
-timed_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+timed_buffer_destroy(struct pipe_buffer *buf)
{
+ struct pipe_winsys *winsys = buf->screen->winsys;
struct pipe_winsys *backend = timed_winsys(winsys)->backend;
uint64_t start = time_start();
- backend->buffer_destroy( backend, buf );
+ backend->buffer_destroy( buf );
time_finish(winsys, start, 4, __FUNCTION__);
}
diff --git a/src/gallium/drivers/Makefile b/src/gallium/drivers/Makefile
index 6161cb6ff8..9fe9b2c11d 100644
--- a/src/gallium/drivers/Makefile
+++ b/src/gallium/drivers/Makefile
@@ -1,20 +1,12 @@
+# src/gallium/drivers/Makefile
TOP = ../../..
include $(TOP)/configs/current
+SUBDIRS = $(GALLIUM_DRIVERS_DIRS)
-SUBDIRS = $(GALLIUM_DRIVER_DIRS)
-
-
-default: subdirs
-
-
-subdirs:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c
index c2e276988c..edc06747ac 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.c
+++ b/src/gallium/drivers/cell/ppu/cell_clear.c
@@ -70,18 +70,12 @@ void
cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
unsigned clearValue)
{
- struct pipe_screen *screen = pipe->screen;
struct cell_context *cell = cell_context(pipe);
uint surfIndex;
if (cell->dirty)
cell_update_derived(cell);
-
- if (!cell->cbuf_map[0])
- cell->cbuf_map[0] = screen->surface_map(screen, ps,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
if (ps == cell->framebuffer.zsbuf) {
/* clear z/stencil buffer */
surfIndex = 1;
diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h
index eb1397bb3f..5c3188e7f9 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.h
+++ b/src/gallium/drivers/cell/ppu/cell_context.h
@@ -130,9 +130,6 @@ struct cell_context
ubyte *cbuf_map[PIPE_MAX_COLOR_BUFS];
ubyte *zsbuf_map;
- struct pipe_surface *tex_surf;
- uint *tex_map;
-
uint dirty;
uint dirty_textures; /* bitmask of texture units */
uint dirty_samplers; /* bitmask of sampler units */
diff --git a/src/gallium/drivers/cell/ppu/cell_fence.c b/src/gallium/drivers/cell/ppu/cell_fence.c
index 867b5dcaa0..13125a9fa3 100644
--- a/src/gallium/drivers/cell/ppu/cell_fence.c
+++ b/src/gallium/drivers/cell/ppu/cell_fence.c
@@ -96,7 +96,7 @@ cell_add_buffer_to_list(struct cell_context *cell,
struct cell_buffer_node *node = CALLOC_STRUCT(cell_buffer_node);
/* create new list node which references the buffer, insert at head */
if (node) {
- pipe_buffer_reference(ps, &node->buffer, buffer);
+ pipe_buffer_reference(&node->buffer, buffer);
node->next = list->head;
list->head = node;
}
@@ -127,10 +127,10 @@ cell_free_fenced_buffers(struct cell_context *cell,
pipe_buffer_unmap(ps, node->buffer);
#if 0
printf("Unref buffer %p\n", node->buffer);
- if (node->buffer->refcount == 1)
+ if (node->buffer->reference.count == 1)
printf(" Delete!\n");
#endif
- pipe_buffer_reference(ps, &node->buffer, NULL);
+ pipe_buffer_reference(&node->buffer, NULL);
FREE(node);
node = next;
}
@@ -153,16 +153,12 @@ cell_add_fenced_textures(struct cell_context *cell)
for (i = 0; i < cell->num_textures; i++) {
struct cell_texture *ct = cell->texture[i];
if (ct) {
- uint level;
- for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
- if (ct->tiled_buffer[level]) {
#if 0
- printf("Adding texture %p buffer %p to list\n",
- ct, ct->tiled_buffer[level]);
+ printf("Adding texture %p buffer %p to list\n",
+ ct, ct->tiled_buffer[level]);
#endif
- cell_add_buffer_to_list(cell, list, ct->tiled_buffer[level]);
- }
- }
+ if (ct->buffer)
+ cell_add_buffer_to_list(cell, list, ct->buffer);
}
}
}
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index ca358ed031..ccd0fef6e8 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -253,10 +253,13 @@ cell_set_sampler_textures(struct pipe_context *pipe,
assert(num <= CELL_MAX_SAMPLERS);
for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
- struct pipe_texture *new_tex = i < num ? texture[i] : NULL;
- if ((struct pipe_texture *) cell->texture[i] != new_tex) {
+ struct cell_texture *new_tex = cell_texture(i < num ? texture[i] : NULL);
+ struct cell_texture *old_tex = cell->texture[i];
+ if (old_tex != new_tex) {
+
pipe_texture_reference((struct pipe_texture **) &cell->texture[i],
- new_tex);
+ (struct pipe_texture *) new_tex);
+
changed |= (1 << i);
}
}
@@ -270,6 +273,70 @@ cell_set_sampler_textures(struct pipe_context *pipe,
}
+/**
+ * Map color and z/stencil framebuffer surfaces.
+ */
+static void
+cell_map_surfaces(struct cell_context *cell)
+{
+ struct pipe_screen *screen = cell->pipe.screen;
+ uint i;
+
+ for (i = 0; i < 1; i++) {
+ struct pipe_surface *ps = cell->framebuffer.cbufs[i];
+ if (ps) {
+ struct cell_texture *ct = cell_texture(ps->texture);
+ cell->cbuf_map[i] = screen->buffer_map(screen,
+ ct->buffer,
+ (PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE));
+ }
+ }
+
+ {
+ struct pipe_surface *ps = cell->framebuffer.zsbuf;
+ if (ps) {
+ struct cell_texture *ct = cell_texture(ps->texture);
+ cell->zsbuf_map = screen->buffer_map(screen,
+ ct->buffer,
+ (PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE));
+ }
+ }
+}
+
+
+/**
+ * Unmap color and z/stencil framebuffer surfaces.
+ */
+static void
+cell_unmap_surfaces(struct cell_context *cell)
+{
+ struct pipe_screen *screen = cell->pipe.screen;
+ uint i;
+
+ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+ struct pipe_surface *ps = cell->framebuffer.cbufs[i];
+ if (ps && cell->cbuf_map[i]) {
+ struct cell_texture *ct = cell_texture(ps->texture);
+ assert(ps->texture);
+ assert(ct->buffer);
+
+ screen->buffer_unmap(screen, ct->buffer);
+ cell->cbuf_map[i] = NULL;
+ }
+ }
+
+ {
+ struct pipe_surface *ps = cell->framebuffer.zsbuf;
+ if (ps && cell->zsbuf_map) {
+ struct cell_texture *ct = cell_texture(ps->texture);
+ screen->buffer_unmap(screen, ct->buffer);
+ cell->zsbuf_map = NULL;
+ }
+ }
+}
+
static void
cell_set_framebuffer_state(struct pipe_context *pipe,
@@ -278,24 +345,10 @@ cell_set_framebuffer_state(struct pipe_context *pipe,
struct cell_context *cell = cell_context(pipe);
if (1 /*memcmp(&cell->framebuffer, fb, sizeof(*fb))*/) {
- struct pipe_surface *csurf = fb->cbufs[0];
- struct pipe_surface *zsurf = fb->zsbuf;
uint i;
- uint flags = (PIPE_BUFFER_USAGE_GPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_READ);
/* unmap old surfaces */
- for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
- if (cell->framebuffer.cbufs[i] && cell->cbuf_map[i]) {
- pipe_surface_unmap(cell->framebuffer.cbufs[i]);
- cell->cbuf_map[i] = NULL;
- }
- }
-
- if (cell->framebuffer.zsbuf && cell->zsbuf_map) {
- pipe_surface_unmap(cell->framebuffer.zsbuf);
- cell->zsbuf_map = NULL;
- }
+ cell_unmap_surfaces(cell);
/* Finish any pending rendering to the current surface before
* installing a new surface!
@@ -314,11 +367,7 @@ cell_set_framebuffer_state(struct pipe_context *pipe,
pipe_surface_reference(&cell->framebuffer.zsbuf, fb->zsbuf);
/* map new surfaces */
- if (csurf)
- cell->cbuf_map[0] = pipe_surface_map(csurf, flags);
-
- if (zsurf)
- cell->zsbuf_map = pipe_surface_map(zsurf, flags);
+ cell_map_surfaces(cell);
cell->dirty |= CELL_NEW_FRAMEBUFFER;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_emit.c b/src/gallium/drivers/cell/ppu/cell_state_emit.c
index ff529fe22c..9479c0898f 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_emit.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_emit.c
@@ -287,19 +287,23 @@ cell_emit_state(struct cell_context *cell)
for (i = 0;i < CELL_MAX_SAMPLERS; i++) {
if (cell->dirty_textures & (1 << i)) {
STATIC_ASSERT(sizeof(struct cell_command_texture) % 16 == 0);
- struct cell_command_texture *texture
- = (struct cell_command_texture *)cell_batch_alloc16(cell, sizeof(*texture));
+ struct cell_command_texture *texture =
+ (struct cell_command_texture *)
+ cell_batch_alloc16(cell, sizeof(*texture));
+
texture->opcode[0] = CELL_CMD_STATE_TEXTURE;
texture->unit = i;
if (cell->texture[i]) {
+ struct cell_texture *ct = cell->texture[i];
uint level;
for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
- texture->start[level] = cell->texture[i]->tiled_mapped[level];
- texture->width[level] = cell->texture[i]->base.width[level];
- texture->height[level] = cell->texture[i]->base.height[level];
- texture->depth[level] = cell->texture[i]->base.depth[level];
+ texture->start[level] = (ct->mapped +
+ ct->level_offset[level]);
+ texture->width[level] = ct->base.width[level];
+ texture->height[level] = ct->base.height[level];
+ texture->depth[level] = ct->base.depth[level];
}
- texture->target = cell->texture[i]->base.target;
+ texture->target = ct->base.target;
}
else {
uint level;
diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c
index bf517ea563..6568c784fe 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c
@@ -193,9 +193,7 @@ cell_set_constant_buffer(struct pipe_context *pipe,
draw_flush(cell->draw);
/* note: reference counting */
- pipe_buffer_reference(pipe->screen,
- &cell->constants[shader].buffer,
- buf->buffer);
+ pipe_buffer_reference(&cell->constants[shader].buffer, buf->buffer);
if (shader == PIPE_SHADER_VERTEX)
cell->dirty |= CELL_NEW_VS_CONSTANTS;
diff --git a/src/gallium/drivers/cell/ppu/cell_surface.c b/src/gallium/drivers/cell/ppu/cell_surface.c
index c9203fee08..ffb8595d82 100644
--- a/src/gallium/drivers/cell/ppu/cell_surface.c
+++ b/src/gallium/drivers/cell/ppu/cell_surface.c
@@ -30,9 +30,21 @@
#include "cell_surface.h"
+static void
+cell_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)
+{
+ util_surface_copy(pipe, FALSE,
+ dest, destx, desty,
+ src, srcx, srcy,
+ width, height);
+}
+
void
cell_init_surface_functions(struct cell_context *cell)
{
- cell->pipe.surface_copy = util_surface_copy;
+ cell->pipe.surface_copy = cell_surface_copy;
cell->pipe.surface_fill = util_surface_fill;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index 9ba995ab7d..e26594448f 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -62,7 +62,7 @@ cell_texture_layout(struct cell_texture *ct)
ct->buffer_size = 0;
- for ( level = 0 ; level <= pt->last_level ; level++ ) {
+ for (level = 0; level <= pt->last_level; level++) {
unsigned size;
unsigned w_tile, h_tile;
@@ -90,7 +90,7 @@ cell_texture_layout(struct cell_texture *ct)
ct->buffer_size += size;
- width = minify(width);
+ width = minify(width);
height = minify(height);
depth = minify(depth);
}
@@ -101,18 +101,17 @@ static struct pipe_texture *
cell_texture_create(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
- struct pipe_winsys *ws = screen->winsys;
struct cell_texture *ct = CALLOC_STRUCT(cell_texture);
if (!ct)
return NULL;
ct->base = *templat;
- ct->base.refcount = 1;
+ pipe_reference_init(&ct->base.reference, 1);
ct->base.screen = screen;
cell_texture_layout(ct);
- ct->buffer = ws->buffer_create(ws, 32, PIPE_BUFFER_USAGE_PIXEL,
+ ct->buffer = screen->buffer_create(screen, 32, PIPE_BUFFER_USAGE_PIXEL,
ct->buffer_size);
if (!ct->buffer) {
@@ -125,42 +124,18 @@ cell_texture_create(struct pipe_screen *screen,
static void
-cell_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+cell_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
-
- /*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
- */
- if (--(*pt)->refcount <= 0) {
- /* Delete this texture now.
- * But note that the underlying pipe_buffer may linger...
- */
- struct cell_texture *ct = cell_texture(*pt);
- uint i;
+ struct cell_texture *ct = cell_texture(pt);
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) ct);
- */
+ if (ct->mapped) {
+ pipe_buffer_unmap(ct->buffer->screen, ct->buffer);
+ ct->mapped = NULL;
+ }
- pipe_buffer_reference(screen, &ct->buffer, NULL);
+ pipe_buffer_reference(&ct->buffer, NULL);
- for (i = 0; i < CELL_MAX_TEXTURE_LEVELS; i++) {
- /* Unreference the tiled image buffer.
- * It may not actually be deleted until a fence is hit.
- */
- if (ct->tiled_buffer[i]) {
- ct->tiled_mapped[i] = NULL;
- pipe_buffer_reference(screen, &ct->tiled_buffer[i], NULL);
- }
- }
-
- FREE(ct);
- }
- *pt = NULL;
+ FREE(ct);
}
@@ -294,103 +269,6 @@ untwiddle_image_uint(uint w, uint h, uint tile_size, uint *dst,
}
-/**
- * Convert linear texture image data to tiled format for SPU usage.
- */
-static void
-cell_twiddle_texture(struct pipe_screen *screen,
- struct pipe_surface *surface)
-{
- struct cell_texture *ct = cell_texture(surface->texture);
- const uint level = surface->level;
- const uint texWidth = ct->base.width[level];
- const uint texHeight = ct->base.height[level];
- const uint bufWidth = align(texWidth, TILE_SIZE);
- const uint bufHeight = align(texHeight, TILE_SIZE);
- const void *map = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_READ);
- const uint *src = (const uint *) map;
-
- switch (ct->base.format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- {
- int numFaces = ct->base.target == PIPE_TEXTURE_CUBE ? 6 : 1;
- int offset = bufWidth * bufHeight * 4 * surface->face;
- uint *dst;
-
- if (!ct->tiled_buffer[level]) {
- /* allocate buffer for tiled data now */
- struct pipe_winsys *ws = screen->winsys;
- uint bytes = bufWidth * bufHeight * 4 * numFaces;
- ct->tiled_buffer[level] =
- ws->buffer_create(ws, 16, PIPE_BUFFER_USAGE_PIXEL, bytes);
- /* and map it */
- ct->tiled_mapped[level] =
- ws->buffer_map(ws, ct->tiled_buffer[level],
- PIPE_BUFFER_USAGE_GPU_READ);
- }
- dst = (uint *) ((ubyte *) ct->tiled_mapped[level] + offset);
-
- twiddle_image_uint(texWidth, texHeight, TILE_SIZE, dst,
- surface->stride, src);
- }
- break;
- default:
- printf("Cell: twiddle unsupported texture format %s\n",
- pf_name(ct->base.format));
- }
-
- screen->surface_unmap(screen, surface);
-}
-
-
-/**
- * Convert SPU tiled texture image data to linear format for app usage.
- */
-static void
-cell_untwiddle_texture(struct pipe_screen *screen,
- struct pipe_surface *surface)
-{
- struct cell_texture *ct = cell_texture(surface->texture);
- const uint level = surface->level;
- const uint texWidth = ct->base.width[level];
- const uint texHeight = ct->base.height[level];
- const void *map = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_READ);
- const uint *src = (const uint *) ((const ubyte *) map + surface->offset);
-
- switch (ct->base.format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- {
- int numFaces = ct->base.target == PIPE_TEXTURE_CUBE ? 6 : 1;
- int offset = surface->stride * texHeight * 4 * surface->face;
- uint *dst;
-
- if (!ct->untiled_data[level]) {
- ct->untiled_data[level] =
- align_malloc(surface->stride * texHeight * 4 * numFaces, 16);
- }
-
- dst = (uint *) ((ubyte *) ct->untiled_data[level] + offset);
-
- untwiddle_image_uint(texWidth, texHeight, TILE_SIZE, dst,
- surface->stride, src);
- }
- break;
- default:
- {
- ct->untiled_data[level] = NULL;
- printf("Cell: untwiddle unsupported texture format %s\n",
- pf_name(ct->base.format));
- }
- }
-
- screen->surface_unmap(screen, surface);
-}
-
-
static struct pipe_surface *
cell_get_tex_surface(struct pipe_screen *screen,
struct pipe_texture *pt,
@@ -402,130 +280,223 @@ cell_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
- ps->block = pt->block;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = ct->stride[level];
ps->offset = ct->level_offset[level];
- ps->usage = usage;
-
/* XXX may need to override usage flags (see sp_texture.c) */
-
- pipe_texture_reference(&ps->texture, pt);
+ ps->usage = usage;
ps->face = face;
ps->level = level;
ps->zslice = zslice;
- if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
- ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
- ps->nblocksy *
- ps->stride;
+ if (pt->target == PIPE_TEXTURE_CUBE) {
+ ps->offset += face * pt->nblocksy[level] * ct->stride[level];
+ }
+ else if (pt->target == PIPE_TEXTURE_3D) {
+ ps->offset += zslice * pt->nblocksy[level] * ct->stride[level];
}
else {
assert(face == 0);
assert(zslice == 0);
}
-
- if (ps->usage & PIPE_BUFFER_USAGE_CPU_READ) {
- /* convert from tiled to linear layout */
- cell_untwiddle_texture(screen, ps);
- }
}
return ps;
}
static void
-cell_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **s)
+cell_tex_surface_destroy(struct pipe_surface *surf)
{
- struct cell_texture *ct = cell_texture((*s)->texture);
- const uint level = (*s)->level;
- struct pipe_surface *surf = *s;
-
- if ((surf->usage & PIPE_BUFFER_USAGE_CPU_READ) && (ct->untiled_data[level]))
- {
- align_free(ct->untiled_data[level]);
- ct->untiled_data[level] = NULL;
- }
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
+}
- if ((ct->base.tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) &&
- (surf->usage & PIPE_BUFFER_USAGE_CPU_WRITE)) {
- /* convert from linear to tiled layout */
- cell_twiddle_texture(screen, surf);
+
+/**
+ * Create new pipe_transfer object.
+ * This is used by the user to put tex data into a texture (and get it
+ * back out for glGetTexImage).
+ */
+static struct pipe_transfer *
+cell_get_tex_transfer(struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level, unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y, unsigned w, unsigned h)
+{
+ struct cell_texture *ct = cell_texture(texture);
+ struct cell_transfer *ctrans;
+
+ assert(texture);
+ assert(level <= texture->last_level);
+
+ ctrans = CALLOC_STRUCT(cell_transfer);
+ if (ctrans) {
+ struct pipe_transfer *pt = &ctrans->base;
+ pipe_texture_reference(&pt->texture, texture);
+ pt->format = texture->format;
+ pt->block = texture->block;
+ pt->x = x;
+ pt->y = y;
+ pt->width = w;
+ pt->height = h;
+ pt->nblocksx = texture->nblocksx[level];
+ pt->nblocksy = texture->nblocksy[level];
+ pt->stride = ct->stride[level];
+ pt->usage = usage;
+ pt->face = face;
+ pt->level = level;
+ pt->zslice = zslice;
+
+ ctrans->offset = ct->level_offset[level];
+
+ if (texture->target == PIPE_TEXTURE_CUBE) {
+ ctrans->offset += face * pt->nblocksy * pt->stride;
+ }
+ else if (texture->target == PIPE_TEXTURE_3D) {
+ ctrans->offset += zslice * pt->nblocksy * pt->stride;
+ }
+ else {
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+ return pt;
}
+ return NULL;
+}
- /* XXX if done rendering to teximage, re-tile */
- if (--surf->refcount == 0) {
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
- }
- *s = NULL;
+static void
+cell_tex_transfer_destroy(struct pipe_transfer *t)
+{
+ struct cell_transfer *transfer = cell_transfer(t);
+ /* Effectively do the texture_update work here - if texture images
+ * needed post-processing to put them into hardware layout, this is
+ * where it would happen. For cell, nothing to do.
+ */
+ assert (transfer->base.texture);
+ pipe_texture_reference(&transfer->base.texture, NULL);
+ FREE(transfer);
}
+/**
+ * Return pointer to texture image data in linear layout.
+ */
static void *
-cell_surface_map(struct pipe_screen *screen,
- struct pipe_surface *surface,
- unsigned flags)
+cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer)
{
- ubyte *map;
- struct cell_texture *ct = cell_texture(surface->texture);
- const uint level = surface->level;
+ struct cell_transfer *ctrans = cell_transfer(transfer);
+ struct pipe_texture *pt = transfer->texture;
+ struct cell_texture *ct = cell_texture(pt);
+ const uint level = ctrans->base.level;
+ const uint texWidth = pt->width[level];
+ const uint texHeight = pt->height[level];
+ const uint stride = ct->stride[level];
+ unsigned flags = 0x0;
+ unsigned size;
- assert(ct);
+ assert(transfer->texture);
-#if 0
- if (flags & ~surface->usage) {
- assert(0);
- return NULL;
+ if (transfer->usage != PIPE_TRANSFER_READ) {
+ flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
}
-#endif
- map = pipe_buffer_map( screen, ct->buffer, flags );
- if (map == NULL) {
- return NULL;
+ if (transfer->usage != PIPE_TRANSFER_WRITE) {
+ flags |= PIPE_BUFFER_USAGE_CPU_READ;
+ }
+
+ if (!ct->mapped) {
+ /* map now */
+ ct->mapped = pipe_buffer_map(screen, ct->buffer, flags);
}
- else {
- if ((surface->usage & PIPE_BUFFER_USAGE_CPU_READ) &&
- (ct->untiled_data[level])) {
- return (void *) ((ubyte *) ct->untiled_data[level] + surface->offset);
+
+ /*
+ * Create a buffer of ordinary memory for the linear texture.
+ * This is the memory that the user will read/write.
+ */
+ size = pt->nblocksx[level] * pt->nblocksy[level] * pt->block.size;
+
+ ctrans->map = align_malloc(size, 16);
+ if (!ctrans->map)
+ return NULL; /* out of memory */
+
+ if (transfer->usage & PIPE_TRANSFER_READ) {
+ /* need to untwiddle the texture to make a linear version */
+ const uint bpp = pf_get_size(ct->base.format);
+ if (bpp == 4) {
+ const uint *src = (uint *) (ct->mapped + ctrans->offset);
+ uint *dst = ctrans->map;
+ untwiddle_image_uint(texWidth, texHeight, TILE_SIZE,
+ dst, stride, src);
}
else {
- return (void *) (map + surface->offset);
+ // xxx fix
}
}
+
+ return ctrans->map;
}
+/**
+ * Called when user is done reading/writing texture data.
+ * If new data was written, this is where we convert the linear data
+ * to tiled data.
+ */
static void
-cell_surface_unmap(struct pipe_screen *screen,
- struct pipe_surface *surface)
+cell_transfer_unmap(struct pipe_screen *screen,
+ struct pipe_transfer *transfer)
{
- struct cell_texture *ct = cell_texture(surface->texture);
+ struct cell_transfer *ctrans = cell_transfer(transfer);
+ struct pipe_texture *pt = transfer->texture;
+ struct cell_texture *ct = cell_texture(pt);
+ const uint level = ctrans->base.level;
+ const uint texWidth = pt->width[level];
+ const uint texHeight = pt->height[level];
+ const uint stride = ct->stride[level];
+
+ if (!ct->mapped) {
+ /* map now */
+ ct->mapped = pipe_buffer_map(screen, ct->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ }
- assert(ct);
+ if (transfer->usage & PIPE_TRANSFER_WRITE) {
+ /* The user wrote new texture data into the mapped buffer.
+ * We need to convert the new linear data into the twiddled/tiled format.
+ */
+ const uint bpp = pf_get_size(ct->base.format);
+ if (bpp == 4) {
+ const uint *src = ctrans->map;
+ uint *dst = (uint *) (ct->mapped + ctrans->offset);
+ twiddle_image_uint(texWidth, texHeight, TILE_SIZE, dst, stride, src);
+ }
+ else {
+ // xxx fix
+ }
+ }
- pipe_buffer_unmap( screen, ct->buffer );
+ align_free(ctrans->map);
+ ctrans->map = NULL;
}
-
void
cell_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = cell_texture_create;
- screen->texture_release = cell_texture_release;
+ screen->texture_destroy = cell_texture_destroy;
screen->get_tex_surface = cell_get_tex_surface;
- screen->tex_surface_release = cell_tex_surface_release;
+ screen->tex_surface_destroy = cell_tex_surface_destroy;
+
+ screen->get_tex_transfer = cell_get_tex_transfer;
+ screen->tex_transfer_destroy = cell_tex_transfer_destroy;
- screen->surface_map = cell_surface_map;
- screen->surface_unmap = cell_surface_unmap;
+ screen->transfer_map = cell_transfer_map;
+ screen->transfer_unmap = cell_transfer_unmap;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h
index 7018b0c9bf..3ffc0bfdb5 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.h
+++ b/src/gallium/drivers/cell/ppu/cell_texture.h
@@ -43,16 +43,23 @@ struct cell_texture
unsigned long level_offset[CELL_MAX_TEXTURE_LEVELS];
unsigned long stride[CELL_MAX_TEXTURE_LEVELS];
- /* The data is held here:
- */
+ /** The tiled texture data is held in this buffer */
struct pipe_buffer *buffer;
unsigned long buffer_size;
- /** Texture data in tiled layout is held here */
- struct pipe_buffer *tiled_buffer[CELL_MAX_TEXTURE_LEVELS];
- /** Mapped, tiled texture data */
- void *tiled_mapped[CELL_MAX_TEXTURE_LEVELS];
- void *untiled_data[CELL_MAX_TEXTURE_LEVELS];
+ /** The buffer above, mapped. This is the memory from which the
+ * SPUs will fetch texels. This texture data is in the tiled layout.
+ */
+ ubyte *mapped;
+};
+
+
+struct cell_transfer
+{
+ struct pipe_transfer base;
+
+ unsigned long offset;
+ void *map;
};
@@ -64,6 +71,13 @@ cell_texture(struct pipe_texture *pt)
}
+/** cast wrapper */
+static INLINE struct cell_transfer *
+cell_transfer(struct pipe_transfer *pt)
+{
+ return (struct cell_transfer *) pt;
+}
+
extern void
cell_init_screen_texture_funcs(struct pipe_screen *screen);
diff --git a/src/gallium/drivers/cell/ppu/cell_vbuf.c b/src/gallium/drivers/cell/ppu/cell_vbuf.c
index ab54e79689..cfaffb52a8 100644
--- a/src/gallium/drivers/cell/ppu/cell_vbuf.c
+++ b/src/gallium/drivers/cell/ppu/cell_vbuf.c
@@ -62,6 +62,7 @@ struct cell_vbuf_render
uint vertex_size; /**< in bytes */
void *vertex_buffer; /**< just for debug, really */
uint vertex_buf; /**< in [0, CELL_NUM_BUFFERS-1] */
+ uint vertex_buffer_size; /**< size in bytes */
};
@@ -82,24 +83,26 @@ cell_vbuf_get_vertex_info(struct vbuf_render *vbr)
}
-static void *
+static boolean
cell_vbuf_allocate_vertices(struct vbuf_render *vbr,
ushort vertex_size, ushort nr_vertices)
{
struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
+ unsigned size = vertex_size * nr_vertices;
/*printf("Alloc verts %u * %u\n", vertex_size, nr_vertices);*/
assert(cvbr->vertex_buf == ~0);
cvbr->vertex_buf = cell_get_empty_buffer(cvbr->cell);
cvbr->vertex_buffer = cvbr->cell->buffer[cvbr->vertex_buf];
+ cvbr->vertex_buffer_size = size;
cvbr->vertex_size = vertex_size;
- return cvbr->vertex_buffer;
+
+ return cvbr->vertex_buffer != NULL;
}
static void
-cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
- unsigned vertex_size, unsigned vertices_used)
+cell_vbuf_release_vertices(struct vbuf_render *vbr)
{
struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
struct cell_context *cell = cvbr->cell;
@@ -127,11 +130,29 @@ cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
cvbr->vertex_buf = ~0;
cell_flush_int(cell, 0x0);
- assert(vertices == cvbr->vertex_buffer);
cvbr->vertex_buffer = NULL;
}
+static void *
+cell_vbuf_map_vertices(struct vbuf_render *vbr)
+{
+ struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
+ return cvbr->vertex_buffer;
+}
+
+
+static void
+cell_vbuf_unmap_vertices(struct vbuf_render *vbr,
+ ushort min_index,
+ ushort max_index )
+{
+ struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
+ assert( cvbr->vertex_buffer_size >= (max_index+1) * cvbr->vertex_size );
+ /* do nothing */
+}
+
+
static boolean
cell_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
@@ -295,6 +316,8 @@ cell_init_vbuf(struct cell_context *cell)
cell->vbuf_render->base.get_vertex_info = cell_vbuf_get_vertex_info;
cell->vbuf_render->base.allocate_vertices = cell_vbuf_allocate_vertices;
+ cell->vbuf_render->base.map_vertices = cell_vbuf_map_vertices;
+ cell->vbuf_render->base.unmap_vertices = cell_vbuf_unmap_vertices;
cell->vbuf_render->base.set_primitive = cell_vbuf_set_primitive;
cell->vbuf_render->base.draw = cell_vbuf_draw;
cell->vbuf_render->base.release_vertices = cell_vbuf_release_vertices;
diff --git a/src/gallium/drivers/cell/spu/Makefile b/src/gallium/drivers/cell/spu/Makefile
index 116453b79c..3cc52301da 100644
--- a/src/gallium/drivers/cell/spu/Makefile
+++ b/src/gallium/drivers/cell/spu/Makefile
@@ -33,9 +33,10 @@ OLD_SOURCES = \
spu_vertex_shader.c
-SPU_OBJECTS = $(SOURCES:.c=.o) \
+SPU_OBJECTS = $(SOURCES:.c=.o)
+
+SPU_ASM_OUT = $(SOURCES:.c=.s)
-SPU_ASM_OUT = $(SOURCES:.c=.s) \
INCLUDE_DIRS = \
-I$(TOP)/src/mesa \
diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c
index 0d9fcb9997..d727268475 100644
--- a/src/gallium/drivers/cell/spu/spu_tri.c
+++ b/src/gallium/drivers/cell/spu/spu_tri.c
@@ -29,7 +29,6 @@
* Triangle rendering within a tile.
*/
-#include <transpose_matrix4x4.h>
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
#include "util/u_math.h"
@@ -71,6 +70,12 @@ struct vertex_header {
#define MASK_ALL 0xf
+#define CHAN0 0
+#define CHAN1 1
+#define CHAN2 2
+#define CHAN3 3
+
+
#define DEBUG_VERTS 0
/**
@@ -144,99 +149,97 @@ struct setup_stage {
static struct setup_stage setup;
-/**
- * Evaluate attribute coefficients (plane equations) to compute
- * attribute values for the four fragments in a quad.
- * Eg: four colors will be computed (in AoS format).
- */
-static INLINE void
-eval_coeff(uint slot, float x, float y, vector float w, vector float result[4])
+static INLINE vector float
+splatx(vector float v)
{
- switch (spu.vertex_info.attrib[slot].interp_mode) {
- case INTERP_CONSTANT:
- result[QUAD_TOP_LEFT] =
- result[QUAD_TOP_RIGHT] =
- result[QUAD_BOTTOM_LEFT] =
- result[QUAD_BOTTOM_RIGHT] = setup.coef[slot].a0;
- break;
- case INTERP_LINEAR:
- {
- vector float dadx = setup.coef[slot].dadx;
- vector float dady = setup.coef[slot].dady;
- vector float topLeft =
- spu_add(setup.coef[slot].a0,
- spu_add(spu_mul(spu_splats(x), dadx),
- spu_mul(spu_splats(y), dady)));
-
- result[QUAD_TOP_LEFT] = topLeft;
- result[QUAD_TOP_RIGHT] = spu_add(topLeft, dadx);
- result[QUAD_BOTTOM_LEFT] = spu_add(topLeft, dady);
- result[QUAD_BOTTOM_RIGHT] = spu_add(spu_add(topLeft, dadx), dady);
- }
- break;
- case INTERP_PERSPECTIVE:
- {
- vector float dadx = setup.coef[slot].dadx;
- vector float dady = setup.coef[slot].dady;
- vector float topLeft =
- spu_add(setup.coef[slot].a0,
- spu_add(spu_mul(spu_splats(x), dadx),
- spu_mul(spu_splats(y), dady)));
-
- vector float wInv = spu_re(w); /* 1.0 / w */
-
- result[QUAD_TOP_LEFT] = spu_mul(topLeft, wInv);
- result[QUAD_TOP_RIGHT] = spu_mul(spu_add(topLeft, dadx), wInv);
- result[QUAD_BOTTOM_LEFT] = spu_mul(spu_add(topLeft, dady), wInv);
- result[QUAD_BOTTOM_RIGHT] = spu_mul(spu_add(spu_add(topLeft, dadx), dady), wInv);
- }
- break;
- case INTERP_POS:
- case INTERP_NONE:
- break;
- default:
- ASSERT(0);
- }
+ return spu_splats(spu_extract(v, CHAN0));
}
-
-/**
- * As above, but return 4 vectors in SOA format.
- * XXX this will all be re-written someday.
- */
-static INLINE void
-eval_coeff_soa(uint slot, float x, float y, vector float w, vector float result[4])
+static INLINE vector float
+splaty(vector float v)
{
- eval_coeff(slot, x, y, w, result);
- _transpose_matrix4x4(result, result);
+ return spu_splats(spu_extract(v, CHAN1));
}
+static INLINE vector float
+splatz(vector float v)
+{
+ return spu_splats(spu_extract(v, CHAN2));
+}
-/** Evalute coefficients to get Z for four pixels in a quad */
static INLINE vector float
-eval_z(float x, float y)
+splatw(vector float v)
{
- const uint slot = 0;
- const float dzdx = spu_extract(setup.coef[slot].dadx, 2);
- const float dzdy = spu_extract(setup.coef[slot].dady, 2);
- const float topLeft = spu_extract(setup.coef[slot].a0, 2) + x * dzdx + y * dzdy;
- const vector float topLeftv = spu_splats(topLeft);
- const vector float derivs = (vector float) { 0.0, dzdx, dzdy, dzdx + dzdy };
- return spu_add(topLeftv, derivs);
+ return spu_splats(spu_extract(v, CHAN3));
}
-/** Evalute coefficients to get W for four pixels in a quad */
-static INLINE vector float
-eval_w(float x, float y)
+/**
+ * Setup fragment shader inputs by evaluating triangle's vertex
+ * attribute coefficient info.
+ * \param x quad x pos
+ * \param y quad y pos
+ * \param fragZ returns quad Z values
+ * \param fragInputs returns fragment program inputs
+ * Note: this code could be incorporated into the fragment program
+ * itself to avoid the loop and switch.
+ */
+static void
+eval_inputs(float x, float y, vector float *fragZ, vector float fragInputs[])
{
- const uint slot = 0;
- const float dwdx = spu_extract(setup.coef[slot].dadx, 3);
- const float dwdy = spu_extract(setup.coef[slot].dady, 3);
- const float topLeft = spu_extract(setup.coef[slot].a0, 3) + x * dwdx + y * dwdy;
- const vector float topLeftv = spu_splats(topLeft);
- const vector float derivs = (vector float) { 0.0, dwdx, dwdy, dwdx + dwdy };
- return spu_add(topLeftv, derivs);
+ static const vector float deltaX = (const vector float) {0, 1, 0, 1};
+ static const vector float deltaY = (const vector float) {0, 0, 1, 1};
+
+ const uint posSlot = 0;
+ const vector float pos = setup.coef[posSlot].a0;
+ const vector float dposdx = setup.coef[posSlot].dadx;
+ const vector float dposdy = setup.coef[posSlot].dady;
+ const vector float fragX = spu_splats(x) + deltaX;
+ const vector float fragY = spu_splats(y) + deltaY;
+ vector float fragW, wInv;
+ uint i;
+
+ *fragZ = splatz(pos) + fragX * splatz(dposdx) + fragY * splatz(dposdy);
+ fragW = splatw(pos) + fragX * splatw(dposdx) + fragY * splatw(dposdy);
+ wInv = spu_re(fragW); /* 1 / w */
+
+ /* loop over fragment program inputs */
+ for (i = 0; i < spu.vertex_info.num_attribs; i++) {
+ uint attr = i + 1;
+ enum interp_mode interp = spu.vertex_info.attrib[attr].interp_mode;
+
+ /* constant term */
+ vector float a0 = setup.coef[attr].a0;
+ vector float r0 = splatx(a0);
+ vector float r1 = splaty(a0);
+ vector float r2 = splatz(a0);
+ vector float r3 = splatw(a0);
+
+ if (interp == INTERP_LINEAR || interp == INTERP_PERSPECTIVE) {
+ /* linear term */
+ vector float dadx = setup.coef[attr].dadx;
+ vector float dady = setup.coef[attr].dady;
+ /* Use SPU intrinsics here to get slightly better code.
+ * originally: r0 += fragX * splatx(dadx) + fragY * splatx(dady);
+ */
+ r0 = spu_madd(fragX, splatx(dadx), spu_madd(fragY, splatx(dady), r0));
+ r1 = spu_madd(fragX, splaty(dadx), spu_madd(fragY, splaty(dady), r1));
+ r2 = spu_madd(fragX, splatz(dadx), spu_madd(fragY, splatz(dady), r2));
+ r3 = spu_madd(fragX, splatw(dadx), spu_madd(fragY, splatw(dady), r3));
+ if (interp == INTERP_PERSPECTIVE) {
+ /* perspective term */
+ r0 *= wInv;
+ r1 *= wInv;
+ r2 *= wInv;
+ r3 *= wInv;
+ }
+ }
+ fragInputs[CHAN0] = r0;
+ fragInputs[CHAN1] = r1;
+ fragInputs[CHAN2] = r2;
+ fragInputs[CHAN3] = r3;
+ fragInputs += 4;
+ }
}
@@ -262,19 +265,11 @@ emit_quad( int x, int y, mask_t mask)
* Run fragment shader, execute per-fragment ops, update fb/tile.
*/
vector float inputs[4*4], outputs[2*4];
- vector float fragZ = eval_z((float) x, (float) y);
- vector float fragW = eval_w((float) x, (float) y);
vector unsigned int kill_mask;
+ vector float fragZ;
+
+ eval_inputs((float) x, (float) y, &fragZ, inputs);
- /* setup inputs */
-#if 0
- eval_coeff_soa(1, (float) x, (float) y, fragW, inputs);
-#else
- uint i;
- for (i = 0; i < spu.vertex_info.num_attribs; i++) {
- eval_coeff_soa(i+1, (float) x, (float) y, fragW, inputs + i * 4);
- }
-#endif
ASSERT(spu.fragment_program);
ASSERT(spu.fragment_ops);
diff --git a/src/gallium/drivers/cell/spu/spu_util.c b/src/gallium/drivers/cell/spu/spu_util.c
index b8a0d4a265..af25dd3718 100644
--- a/src/gallium/drivers/cell/spu/spu_util.c
+++ b/src/gallium/drivers/cell/spu/spu_util.c
@@ -1,7 +1,7 @@
#include "cell/common.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "tgsi/tgsi_parse.h"
//#include "tgsi_build.h"
#include "tgsi/tgsi_util.h"
diff --git a/src/gallium/drivers/failover/Makefile b/src/gallium/drivers/failover/Makefile
index f08b8df07a..dfb7f5dcf6 100644
--- a/src/gallium/drivers/failover/Makefile
+++ b/src/gallium/drivers/failover/Makefile
@@ -9,6 +9,3 @@ C_SOURCES = \
fo_context.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 0742b27b8f..fcad717cf8 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -145,7 +145,7 @@ struct pipe_context *failover_create( struct pipe_context *hw,
#if 0
failover->pipe.texture_create = hw->texture_create;
- failover->pipe.texture_release = hw->texture_release;
+ failover->pipe.texture_destroy = hw->texture_destroy;
failover->pipe.get_tex_surface = hw->get_tex_surface;
failover->pipe.texture_update = hw->texture_update;
#endif
diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c
index 6a79706632..c8eb926299 100644
--- a/src/gallium/drivers/failover/fo_state.c
+++ b/src/gallium/drivers/failover/fo_state.c
@@ -28,8 +28,6 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_inlines.h"
-
#include "fo_context.h"
diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile
index 41a61a0020..12821c5a76 100644
--- a/src/gallium/drivers/i915simple/Makefile
+++ b/src/gallium/drivers/i915simple/Makefile
@@ -26,6 +26,3 @@ C_SOURCES = \
i915_surface.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/i915simple/i915_debug.c b/src/gallium/drivers/i915simple/i915_debug.c
index a300b61c3b..e08582efab 100644
--- a/src/gallium/drivers/i915simple/i915_debug.c
+++ b/src/gallium/drivers/i915simple/i915_debug.c
@@ -31,7 +31,7 @@
#include "i915_debug.h"
#include "i915_batch.h"
#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
static void
diff --git a/src/gallium/drivers/i915simple/i915_fpc_translate.c b/src/gallium/drivers/i915simple/i915_fpc_translate.c
index d92bdc1bc6..961c1bf213 100644
--- a/src/gallium/drivers/i915simple/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915simple/i915_fpc_translate.c
@@ -321,16 +321,27 @@ static uint
translate_tex_src_target(struct i915_fp_compile *p, uint tex)
{
switch (tex) {
+ case TGSI_TEXTURE_SHADOW1D:
+ /* fall-through */
case TGSI_TEXTURE_1D:
return D0_SAMPLE_TYPE_2D;
+
+ case TGSI_TEXTURE_SHADOW2D:
+ /* fall-through */
case TGSI_TEXTURE_2D:
return D0_SAMPLE_TYPE_2D;
+
+ case TGSI_TEXTURE_SHADOWRECT:
+ /* fall-through */
case TGSI_TEXTURE_RECT:
return D0_SAMPLE_TYPE_2D;
+
case TGSI_TEXTURE_3D:
return D0_SAMPLE_TYPE_VOLUME;
+
case TGSI_TEXTURE_CUBE:
return D0_SAMPLE_TYPE_CUBE;
+
default:
i915_program_error(p, "TexSrc type");
return 0;
diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
index f49f6d6ed1..9bdd91f288 100644
--- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
@@ -40,7 +40,7 @@
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_inlines.h"
#include "pipe/internal/p_winsys_screen.h"
#include "util/u_math.h"
@@ -62,7 +62,7 @@ struct i915_vbuf_render {
struct i915_context *i915;
/** Vertex size in bytes */
- unsigned vertex_size;
+ size_t vertex_size;
/** Software primitive */
unsigned prim;
@@ -79,6 +79,7 @@ struct i915_vbuf_render {
size_t vbo_offset;
void *vbo_ptr;
size_t vbo_alloc_size;
+ size_t vbo_max_used;
};
@@ -108,7 +109,7 @@ i915_vbuf_render_get_vertex_info( struct vbuf_render *render )
}
-static void *
+static boolean
i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
ushort vertex_size,
ushort nr_vertices )
@@ -124,7 +125,8 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
if (i915_render->vbo_size > size + i915_render->vbo_offset && !i915->vbo_flushed) {
} else {
i915->vbo_flushed = 0;
- pipe_buffer_reference(screen, &i915_render->vbo, NULL);
+ if (i915_render->vbo)
+ pipe_buffer_reference(&i915_render->vbo, NULL);
}
if (!i915_render->vbo) {
@@ -134,19 +136,49 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
64,
I915_BUFFER_USAGE_LIT_VERTEX,
i915_render->vbo_size);
- i915_render->vbo_ptr = pipe_buffer_map(screen,
- i915_render->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- pipe_buffer_unmap(screen, i915_render->vbo);
+
}
+ i915_render->vertex_size = vertex_size;
i915->vbo = i915_render->vbo;
i915->vbo_offset = i915_render->vbo_offset;
i915->dirty |= I915_NEW_VBO;
+ if (!i915_render->vbo)
+ return FALSE;
+ return TRUE;
+}
+
+
+static void *
+i915_vbuf_render_map_vertices( struct vbuf_render *render )
+{
+ struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
+ struct i915_context *i915 = i915_render->i915;
+ struct pipe_screen *screen = i915->pipe.screen;
+
+ if (i915->vbo_flushed)
+ debug_printf("%s bad vbo flush occured stalling on hw\n");
+
+ i915_render->vbo_ptr = pipe_buffer_map(screen,
+ i915_render->vbo,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+
return (unsigned char *)i915_render->vbo_ptr + i915->vbo_offset;
}
+static void
+i915_vbuf_render_unmap_vertices( struct vbuf_render *render,
+ ushort min_index,
+ ushort max_index )
+{
+ struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
+ struct i915_context *i915 = i915_render->i915;
+ struct pipe_screen *screen = i915->pipe.screen;
+
+ i915_render->vbo_max_used = MAX2(i915_render->vbo_max_used, i915_render->vertex_size * (max_index + 1));
+ pipe_buffer_unmap(screen, i915_render->vbo);
+}
static boolean
i915_vbuf_render_set_primitive( struct vbuf_render *render,
@@ -454,18 +486,15 @@ out:
static void
-i915_vbuf_render_release_vertices( struct vbuf_render *render,
- void *vertices,
- unsigned vertex_size,
- unsigned vertices_used )
+i915_vbuf_render_release_vertices( struct vbuf_render *render )
{
struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
struct i915_context *i915 = i915_render->i915;
- size_t size = (size_t)vertex_size * (size_t)vertices_used;
assert(i915->vbo);
- i915_render->vbo_offset += size;
+ i915_render->vbo_offset += i915_render->vbo_max_used;
+ i915_render->vbo_max_used = 0;
i915->vbo = NULL;
i915->dirty |= I915_NEW_VBO;
}
@@ -499,6 +528,8 @@ i915_vbuf_render_create( struct i915_context *i915 )
i915_render->base.get_vertex_info = i915_vbuf_render_get_vertex_info;
i915_render->base.allocate_vertices = i915_vbuf_render_allocate_vertices;
+ i915_render->base.map_vertices = i915_vbuf_render_map_vertices;
+ i915_render->base.unmap_vertices = i915_vbuf_render_unmap_vertices;
i915_render->base.set_primitive = i915_vbuf_render_set_primitive;
i915_render->base.draw = i915_vbuf_render_draw;
i915_render->base.draw_arrays = i915_vbuf_render_draw_arrays;
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
index 39e48105b3..f4aa8e60d8 100644
--- a/src/gallium/drivers/i915simple/i915_screen.c
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -36,6 +36,7 @@
#include "i915_context.h"
#include "i915_screen.h"
#include "i915_texture.h"
+#include "i915_winsys.h"
static const char *
@@ -204,17 +205,71 @@ i915_destroy_screen( struct pipe_screen *screen )
}
+static struct pipe_transfer*
+i915_get_tex_transfer(struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level, unsigned zslice,
+ enum pipe_transfer_usage usage, unsigned x, unsigned y,
+ unsigned w, unsigned h)
+{
+ struct i915_texture *tex = (struct i915_texture *)texture;
+ struct i915_transfer *trans;
+ unsigned offset; /* in bytes */
+
+ if (texture->target == PIPE_TEXTURE_CUBE) {
+ offset = tex->image_offset[level][face];
+ }
+ else if (texture->target == PIPE_TEXTURE_3D) {
+ offset = tex->image_offset[level][zslice];
+ }
+ else {
+ offset = tex->image_offset[level][0];
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+
+ trans = CALLOC_STRUCT(i915_transfer);
+ if (trans) {
+ pipe_texture_reference(&trans->base.texture, texture);
+ trans->base.format = trans->base.format;
+ trans->base.width = w;
+ trans->base.height = h;
+ trans->base.block = texture->block;
+ trans->base.nblocksx = texture->nblocksx[level];
+ trans->base.nblocksy = texture->nblocksy[level];
+ trans->base.stride = tex->stride;
+ trans->offset = offset;
+ trans->base.usage = usage;
+ }
+ return &trans->base;
+}
+
+static void
+i915_tex_transfer_destroy(struct pipe_transfer *trans)
+{
+ pipe_texture_reference(&trans->texture, NULL);
+ FREE(trans);
+}
+
static void *
-i915_surface_map( struct pipe_screen *screen,
- struct pipe_surface *surface,
- unsigned flags )
+i915_transfer_map( struct pipe_screen *screen,
+ struct pipe_transfer *transfer )
{
- struct i915_texture *tex = (struct i915_texture *)surface->texture;
- char *map = pipe_buffer_map( screen, tex->buffer, flags );
+ struct i915_texture *tex = (struct i915_texture *)transfer->texture;
+ char *map;
+ unsigned flags = 0;
+
+ if (transfer->usage != PIPE_TRANSFER_WRITE)
+ flags |= PIPE_BUFFER_USAGE_CPU_READ;
+
+ if (transfer->usage != PIPE_TRANSFER_READ)
+ flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+
+ map = pipe_buffer_map( screen, tex->buffer, flags );
if (map == NULL)
return NULL;
- if (surface->texture &&
+ if (transfer->texture &&
(flags & PIPE_BUFFER_USAGE_CPU_WRITE))
{
/* Do something to notify contexts of a texture change.
@@ -222,14 +277,16 @@ i915_surface_map( struct pipe_screen *screen,
/* i915_screen(screen)->timestamp++; */
}
- return map + surface->offset;
+ return map + i915_transfer(transfer)->offset +
+ transfer->y / transfer->block.height * transfer->stride +
+ transfer->x / transfer->block.width * transfer->block.size;
}
static void
-i915_surface_unmap(struct pipe_screen *screen,
- struct pipe_surface *surface)
+i915_transfer_unmap(struct pipe_screen *screen,
+ struct pipe_transfer *transfer)
{
- struct i915_texture *tex = (struct i915_texture *)surface->texture;
+ struct i915_texture *tex = (struct i915_texture *)transfer->texture;
pipe_buffer_unmap( screen, tex->buffer );
}
@@ -278,8 +335,10 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
i915screen->screen.get_param = i915_get_param;
i915screen->screen.get_paramf = i915_get_paramf;
i915screen->screen.is_format_supported = i915_is_format_supported;
- i915screen->screen.surface_map = i915_surface_map;
- i915screen->screen.surface_unmap = i915_surface_unmap;
+ i915screen->screen.get_tex_transfer = i915_get_tex_transfer;
+ i915screen->screen.tex_transfer_destroy = i915_tex_transfer_destroy;
+ i915screen->screen.transfer_map = i915_transfer_map;
+ i915screen->screen.transfer_unmap = i915_transfer_unmap;
i915_init_screen_texture_functions(&i915screen->screen);
u_simple_screen_init(&i915screen->screen);
diff --git a/src/gallium/drivers/i915simple/i915_screen.h b/src/gallium/drivers/i915simple/i915_screen.h
index 73b0ff05ce..5284c32595 100644
--- a/src/gallium/drivers/i915simple/i915_screen.h
+++ b/src/gallium/drivers/i915simple/i915_screen.h
@@ -50,16 +50,29 @@ struct i915_screen
};
-/** cast wrapper */
+/**
+ * Subclass of pipe_transfer
+ */
+struct i915_transfer
+{
+ struct pipe_transfer base;
+
+ unsigned offset;
+};
+
+
+/** cast wrappers */
static INLINE struct i915_screen *
i915_screen(struct pipe_screen *pscreen)
{
return (struct i915_screen *) pscreen;
}
-
-extern struct pipe_screen *
-i915_create_screen(struct pipe_winsys *winsys, uint pci_id);
+static INLINE struct i915_transfer *
+i915_transfer( struct pipe_transfer *transfer )
+{
+ return (struct i915_transfer *)transfer;
+}
#ifdef __cplusplus
diff --git a/src/gallium/drivers/i915simple/i915_state_emit.c b/src/gallium/drivers/i915simple/i915_state_emit.c
index 6558cf1c3e..1e1fb968b4 100644
--- a/src/gallium/drivers/i915simple/i915_state_emit.c
+++ b/src/gallium/drivers/i915simple/i915_state_emit.c
@@ -211,11 +211,9 @@ i915_emit_hardware_state(struct i915_context *i915 )
struct pipe_surface *depth_surface = i915->framebuffer.zsbuf;
if (cbuf_surface) {
- unsigned cpitch = cbuf_surface->stride;
unsigned ctile = BUF_3D_USE_FENCE;
struct i915_texture *tex = (struct i915_texture *)
cbuf_surface->texture;
- struct pipe_buffer *buffer = tex->buffer;
assert(tex);
if (tex && tex->tiled) {
@@ -225,7 +223,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
OUT_BATCH(BUF_3D_ID_COLOR_BACK |
- BUF_3D_PITCH(cpitch) | /* pitch in bytes */
+ BUF_3D_PITCH(tex->stride) | /* pitch in bytes */
ctile);
OUT_RELOC(tex->buffer,
@@ -236,11 +234,9 @@ i915_emit_hardware_state(struct i915_context *i915 )
/* What happens if no zbuf??
*/
if (depth_surface) {
- unsigned zpitch = depth_surface->stride;
unsigned ztile = BUF_3D_USE_FENCE;
struct i915_texture *tex = (struct i915_texture *)
depth_surface->texture;
- struct pipe_buffer *buffer = tex->buffer;
assert(tex);
if (tex && tex->tiled) {
@@ -250,7 +246,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
OUT_BATCH(BUF_3D_ID_DEPTH |
- BUF_3D_PITCH(zpitch) | /* pitch in bytes */
+ BUF_3D_PITCH(tex->stride) | /* pitch in bytes */
ztile);
OUT_RELOC(tex->buffer,
diff --git a/src/gallium/drivers/i915simple/i915_state_sampler.c b/src/gallium/drivers/i915simple/i915_state_sampler.c
index c09c10601b..3667ed1afa 100644
--- a/src/gallium/drivers/i915simple/i915_state_sampler.c
+++ b/src/gallium/drivers/i915simple/i915_state_sampler.c
@@ -116,7 +116,7 @@ static void update_sampler(struct i915_context *i915,
ws == PIPE_TEX_WRAP_CLAMP_TO_BORDER ||
wt == PIPE_TEX_WRAP_CLAMP_TO_BORDER ||
wr == PIPE_TEX_WRAP_CLAMP_TO_BORDER)) {
- if (i915->strict_conformance) {
+ if (i915->conformance_mode > 0) {
assert(0);
/* sampler->fallback = true; */
/* TODO */
diff --git a/src/gallium/drivers/i915simple/i915_surface.c b/src/gallium/drivers/i915simple/i915_surface.c
index 94e2deaf61..09b2c499b8 100644
--- a/src/gallium/drivers/i915simple/i915_surface.c
+++ b/src/gallium/drivers/i915simple/i915_surface.c
@@ -41,50 +41,27 @@
*/
static void
i915_surface_copy(struct pipe_context *pipe,
- boolean do_flip,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
struct pipe_surface *src,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- assert( dst != src );
- assert( dst->block.size == src->block.size );
- assert( dst->block.width == src->block.height );
- assert( dst->block.height == src->block.height );
+ struct i915_texture *dst_tex = (struct i915_texture *)dst->texture;
+ struct i915_texture *src_tex = (struct i915_texture *)src->texture;
- if (0) {
- void *dst_map = pipe->screen->surface_map( pipe->screen,
- dst,
- PIPE_BUFFER_USAGE_CPU_WRITE );
-
- const void *src_map = pipe->screen->surface_map( pipe->screen,
- src,
- PIPE_BUFFER_USAGE_CPU_READ );
-
- pipe_copy_rect(dst_map,
- &dst->block,
- dst->stride,
- dstx, dsty,
- width, height,
- src_map,
- do_flip ? -(int) src->stride : src->stride,
- srcx, do_flip ? height - 1 - srcy : srcy);
+ assert( dst != src );
+ assert( dst_tex->base.block.size == src_tex->base.block.size );
+ assert( dst_tex->base.block.width == src_tex->base.block.height );
+ assert( dst_tex->base.block.height == src_tex->base.block.height );
+ assert( dst_tex->base.block.width == 1 );
+ assert( dst_tex->base.block.height == 1 );
- pipe->screen->surface_unmap(pipe->screen, src);
- pipe->screen->surface_unmap(pipe->screen, dst);
- }
- else {
- struct i915_texture *dst_tex = (struct i915_texture *)dst->texture;
- struct i915_texture *src_tex = (struct i915_texture *)src->texture;
- assert(dst->block.width == 1);
- assert(dst->block.height == 1);
- i915_copy_blit( i915_context(pipe),
- do_flip,
- dst->block.size,
- (unsigned short) src->stride, src_tex->buffer, src->offset,
- (unsigned short) dst->stride, dst_tex->buffer, dst->offset,
- (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
- }
+ i915_copy_blit( i915_context(pipe),
+ FALSE,
+ dst_tex->base.block.size,
+ (unsigned short) src_tex->stride, src_tex->buffer, src->offset,
+ (unsigned short) dst_tex->stride, dst_tex->buffer, dst->offset,
+ (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
}
@@ -94,27 +71,18 @@ i915_surface_fill(struct pipe_context *pipe,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height, unsigned value)
{
- if (0) {
- void *dst_map = pipe->screen->surface_map( pipe->screen,
- dst,
- PIPE_BUFFER_USAGE_CPU_WRITE );
+ struct i915_texture *tex = (struct i915_texture *)dst->texture;
- pipe_fill_rect(dst_map, &dst->block, dst->stride, dstx, dsty, width, height, value);
+ assert(tex->base.block.width == 1);
+ assert(tex->base.block.height == 1);
- pipe->screen->surface_unmap(pipe->screen, dst);
- }
- else {
- struct i915_texture *tex = (struct i915_texture *)dst->texture;
- assert(dst->block.width == 1);
- assert(dst->block.height == 1);
- i915_fill_blit( i915_context(pipe),
- dst->block.size,
- (unsigned short) dst->stride,
- tex->buffer, dst->offset,
- (short) dstx, (short) dsty,
- (short) width, (short) height,
- value );
- }
+ i915_fill_blit( i915_context(pipe),
+ tex->base.block.size,
+ (unsigned short) tex->stride,
+ tex->buffer, dst->offset,
+ (short) dstx, (short) dsty,
+ (short) width, (short) height,
+ value );
}
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index b2ca3a2286..39aca9f817 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -42,6 +42,7 @@
#include "i915_texture.h"
#include "i915_debug.h"
#include "i915_screen.h"
+#include "i915_winsys.h"
/*
* Helper function and arrays
@@ -581,7 +582,6 @@ i915_texture_create(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
struct i915_screen *i915screen = i915_screen(screen);
- struct pipe_winsys *ws = screen->winsys;
struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
size_t tex_size;
@@ -589,7 +589,7 @@ i915_texture_create(struct pipe_screen *screen,
return NULL;
tex->base = *templat;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.screen = screen;
tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width[0]);
@@ -605,7 +605,7 @@ i915_texture_create(struct pipe_screen *screen,
tex_size = tex->stride * tex->total_nblocksy;
- tex->buffer = ws->buffer_create(ws, 64,
+ tex->buffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex_size);
@@ -628,33 +628,22 @@ fail:
static void
-i915_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+i915_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
+ struct i915_texture *tex = (struct i915_texture *)pt;
+ uint i;
/*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
+ DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- if (--(*pt)->refcount <= 0) {
- struct i915_texture *tex = (struct i915_texture *)*pt;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
- if (tex->image_offset[i])
- FREE(tex->image_offset[i]);
+ for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
+ if (tex->image_offset[i])
+ FREE(tex->image_offset[i]);
- FREE(tex);
- }
- *pt = NULL;
+ FREE(tex);
}
static struct pipe_surface *
@@ -681,15 +670,11 @@ i915_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->block = pt->block;
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = tex->stride;
ps->offset = offset;
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;
@@ -718,7 +703,7 @@ i915_texture_blanket(struct pipe_screen * screen,
return NULL;
tex->base = *base;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.screen = screen;
tex->stride = stride[0];
@@ -726,7 +711,7 @@ i915_texture_blanket(struct pipe_screen * screen,
i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
- pipe_buffer_reference(screen, &tex->buffer, buffer);
+ pipe_buffer_reference(&tex->buffer, buffer);
return &tex->base;
}
@@ -738,34 +723,43 @@ i915_init_texture_functions(struct i915_context *i915)
}
static void
-i915_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **surface)
+i915_tex_surface_destroy(struct pipe_surface *surf)
{
- struct pipe_surface *surf = *surface;
-
- if (--surf->refcount == 0) {
-
- /* This really should not be possible, but it's actually
- * happening quite a bit... Will fix.
- */
- if (surf->status == PIPE_SURFACE_STATUS_CLEAR) {
- debug_printf("XXX destroying a surface with pending clears...\n");
- assert(0);
- }
-
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
+ /* This really should not be possible, but it's actually
+ * happening quite a bit... Will fix.
+ */
+ if (surf->status == PIPE_SURFACE_STATUS_CLEAR) {
+ debug_printf("XXX destroying a surface with pending clears...\n");
+ assert(0);
}
- *surface = NULL;
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
}
void
i915_init_screen_texture_functions(struct pipe_screen *screen)
{
screen->texture_create = i915_texture_create;
- screen->texture_release = i915_texture_release;
+ screen->texture_destroy = i915_texture_destroy;
screen->get_tex_surface = i915_get_tex_surface;
screen->texture_blanket = i915_texture_blanket;
- screen->tex_surface_release = i915_tex_surface_release;
+ screen->tex_surface_destroy = i915_tex_surface_destroy;
+}
+
+boolean i915_get_texture_buffer( struct pipe_texture *texture,
+ struct pipe_buffer **buf,
+ unsigned *stride )
+{
+ struct i915_texture *tex = (struct i915_texture *)texture;
+
+ if (!tex)
+ return FALSE;
+
+ pipe_buffer_reference(buf, tex->buffer);
+
+ if (stride)
+ *stride = tex->stride;
+
+ return TRUE;
}
diff --git a/src/gallium/drivers/i915simple/i915_winsys.h b/src/gallium/drivers/i915simple/i915_winsys.h
index 81904c2a74..ff5b34f193 100644
--- a/src/gallium/drivers/i915simple/i915_winsys.h
+++ b/src/gallium/drivers/i915simple/i915_winsys.h
@@ -30,7 +30,8 @@
* This is the interface that i915simple requires any window system
* hosting it to implement. This is the only include file in i915simple
* which is public.
- *
+ *
+ * This isn't currently true as the winsys needs i915_batchbuffer.h
*/
#ifndef I915_WINSYS_H
@@ -45,10 +46,9 @@ extern "C" {
#endif
-/* Pipe 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.
+/* Pipe drivers are 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,
@@ -56,6 +56,7 @@ extern "C" {
*/
struct i915_batchbuffer;
+struct pipe_texture;
struct pipe_buffer;
struct pipe_fence_handle;
struct pipe_winsys;
@@ -64,7 +65,7 @@ struct pipe_screen;
/**
* Additional winsys interface for i915simple.
- *
+ *
* It is an over-simple batchbuffer mechanism. Will want to improve the
* performance of this, perhaps based on the cmdstream stuff. It
* would be pretty impossible to implement swz on top of this
@@ -110,12 +111,33 @@ struct i915_winsys {
#define I915_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
-struct pipe_context *i915_create_context( struct pipe_screen *,
- struct pipe_winsys *,
- struct i915_winsys * );
+/**
+ * Create i915 pipe_screen.
+ */
+struct pipe_screen *i915_create_screen( struct pipe_winsys *winsys,
+ uint pci_id );
+
+/**
+ * Create a i915 pipe_context.
+ */
+struct pipe_context *i915_create_context( struct pipe_screen *screen,
+ struct pipe_winsys *winsys,
+ struct i915_winsys *i915 );
+
+/**
+ * Used for the winsys to get the buffer used for a texture
+ * and also the stride used for the texture.
+ *
+ * Buffer is referenced for you so you need to unref after use.
+ *
+ * This is needed for example kms.
+ */
+boolean i915_get_texture_buffer( struct pipe_texture *texture,
+ struct pipe_buffer **buf,
+ unsigned *stride );
#ifdef __cplusplus
}
#endif
-#endif
+#endif
diff --git a/src/gallium/drivers/i965simple/Makefile b/src/gallium/drivers/i965simple/Makefile
index e97146e57c..19182afa75 100644
--- a/src/gallium/drivers/i965simple/Makefile
+++ b/src/gallium/drivers/i965simple/Makefile
@@ -50,5 +50,3 @@ C_SOURCES = \
brw_wm_surface_state.c
include ../../Makefile.template
-
-symlinks:
diff --git a/src/gallium/drivers/i965simple/brw_eu_debug.c b/src/gallium/drivers/i965simple/brw_eu_debug.c
index 4a94ddefa6..4adfb0c02f 100644
--- a/src/gallium/drivers/i965simple/brw_eu_debug.c
+++ b/src/gallium/drivers/i965simple/brw_eu_debug.c
@@ -30,7 +30,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "brw_eu.h"
diff --git a/src/gallium/drivers/i965simple/brw_surface.c b/src/gallium/drivers/i965simple/brw_surface.c
index 0a95dce194..511779dbfa 100644
--- a/src/gallium/drivers/i965simple/brw_surface.c
+++ b/src/gallium/drivers/i965simple/brw_surface.c
@@ -41,7 +41,6 @@
*/
static void
brw_surface_copy(struct pipe_context *pipe,
- boolean do_flip,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
struct pipe_surface *src,
@@ -64,11 +63,11 @@ brw_surface_copy(struct pipe_context *pipe,
pipe_copy_rect(dst_map,
&dst->block,
dst->stride,
- dstx, dsty,
- width, height,
- src_map,
- do_flip ? -(int) src->stride : src->stride,
- srcx, do_flip ? height - 1 - srcy : srcy);
+ dstx, dsty,
+ width, height,
+ src_map,
+ src->stride,
+ srcx, srcy);
pipe->screen->surface_unmap(pipe->screen, src);
pipe->screen->surface_unmap(pipe->screen, dst);
@@ -79,7 +78,7 @@ brw_surface_copy(struct pipe_context *pipe,
assert(dst->block.width == 1);
assert(dst->block.height == 1);
brw_copy_blit(brw_context(pipe),
- do_flip,
+ FALSE,
dst->block.size,
(short) src->stride/src->block.size, src_tex->buffer, src->offset, FALSE,
(short) dst->stride/dst->block.size, dst_tex->buffer, dst->offset, FALSE,
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.c b/src/gallium/drivers/i965simple/brw_tex_layout.c
index 448229ed4e..c921c0d38b 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.c
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.c
@@ -284,18 +284,17 @@ static struct pipe_texture *
brw_texture_create_screen(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
- struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = CALLOC_STRUCT(brw_texture);
if (tex) {
tex->base = *templat;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width[0]);
tex->base.nblocksy[0] = pf_get_nblocksy(&tex->base.block, tex->base.height[0]);
if (brw_miptree_layout(tex))
- tex->buffer = ws->buffer_create(ws, 64,
+ tex->buffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex->stride *
tex->total_nblocksy);
@@ -311,33 +310,22 @@ brw_texture_create_screen(struct pipe_screen *screen,
static void
-brw_texture_release_screen(struct pipe_screen *screen,
- struct pipe_texture **pt)
+brw_texture_destroy_screen(struct pipe_texture *pt)
{
- if (!*pt)
- return;
+ struct brw_texture *tex = (struct brw_texture *)pt;
+ uint i;
/*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
+ DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- if (--(*pt)->refcount <= 0) {
- struct brw_texture *tex = (struct brw_texture *)*pt;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
- if (tex->image_offset[i])
- free(tex->image_offset[i]);
+ for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
+ if (tex->image_offset[i])
+ free(tex->image_offset[i]);
- free(tex);
- }
- *pt = NULL;
+ free(tex);
}
@@ -365,7 +353,7 @@ brw_get_tex_surface_screen(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
@@ -392,7 +380,7 @@ void
brw_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = brw_texture_create_screen;
- screen->texture_release = brw_texture_release_screen;
+ screen->texture_destroy = brw_texture_destroy_screen;
screen->get_tex_surface = brw_get_tex_surface_screen;
}
diff --git a/src/gallium/drivers/i965simple/brw_wm_surface_state.c b/src/gallium/drivers/i965simple/brw_wm_surface_state.c
index 1bab5bfdb3..b5b9e0e702 100644
--- a/src/gallium/drivers/i965simple/brw_wm_surface_state.c
+++ b/src/gallium/drivers/i965simple/brw_wm_surface_state.c
@@ -242,7 +242,7 @@ static void upload_wm_surfaces(struct brw_context *brw )
const struct brw_texture *texUnit = brw->attribs.Texture[i];
if (texUnit &&
- texUnit->base.refcount/*(texUnit->refcount > 0) == really used */) {
+ texUnit->base.reference.count/*(texUnit->reference.count > 0) == really used */) {
brw_update_texture_surface(brw, i);
diff --git a/src/gallium/drivers/nouveau/nouveau_stateobj.h b/src/gallium/drivers/nouveau/nouveau_stateobj.h
index 4ae4ff4940..97859110b5 100644
--- a/src/gallium/drivers/nouveau/nouveau_stateobj.h
+++ b/src/gallium/drivers/nouveau/nouveau_stateobj.h
@@ -1,7 +1,7 @@
#ifndef __NOUVEAU_STATEOBJ_H__
#define __NOUVEAU_STATEOBJ_H__
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
struct nouveau_stateobj_reloc {
struct pipe_buffer *bo;
@@ -16,7 +16,7 @@ struct nouveau_stateobj_reloc {
};
struct nouveau_stateobj {
- int refcount;
+ struct pipe_reference reference;
unsigned *push;
struct nouveau_stateobj_reloc *reloc;
@@ -32,7 +32,7 @@ so_new(unsigned push, unsigned reloc)
struct nouveau_stateobj *so;
so = MALLOC(sizeof(struct nouveau_stateobj));
- so->refcount = 0;
+ pipe_reference_init(&so->reference, 1);
so->push = MALLOC(sizeof(unsigned) * push);
so->reloc = MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);
@@ -47,17 +47,11 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso)
{
struct nouveau_stateobj *so = *pso;
- if (ref) {
- ref->refcount++;
- }
-
- if (so && --so->refcount <= 0) {
+ if (pipe_reference((struct pipe_reference**)pso, &ref->reference)) {
free(so->push);
free(so->reloc);
free(so);
}
-
- *pso = ref;
}
static INLINE void
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index b86c4b9338..ff7dd1c51c 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -19,11 +19,12 @@
#define NOUVEAU_TEXTURE_USAGE_LINEAR (1 << 16)
-#define NOUVEAU_BUFFER_USAGE_TEXTURE (1 << 16)
-#define NOUVEAU_BUFFER_USAGE_ZETA (1 << 17)
+#define NOUVEAU_BUFFER_USAGE_TEXTURE (1 << 16)
+#define NOUVEAU_BUFFER_USAGE_ZETA (1 << 17)
+#define NOUVEAU_BUFFER_USAGE_TRANSFER (1 << 18)
struct nouveau_winsys {
- struct nouveau_context *nv;
+ struct pipe_winsys *ws;
struct nouveau_channel *channel;
diff --git a/src/gallium/drivers/nv04/Makefile b/src/gallium/drivers/nv04/Makefile
index 4ed62dae95..7c14bacb1d 100644
--- a/src/gallium/drivers/nv04/Makefile
+++ b/src/gallium/drivers/nv04/Makefile
@@ -3,7 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nv04
-DRIVER_SOURCES = \
+C_SOURCES = \
nv04_surface_2d.c \
nv04_clear.c \
nv04_context.c \
@@ -15,15 +15,7 @@ DRIVER_SOURCES = \
nv04_state.c \
nv04_state_emit.c \
nv04_surface.c \
+ nv04_transfer.c \
nv04_vbo.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/nv04/nv04_miptree.c b/src/gallium/drivers/nv04/nv04_miptree.c
index 993c5ef5dd..85dc017fbc 100644
--- a/src/gallium/drivers/nv04/nv04_miptree.c
+++ b/src/gallium/drivers/nv04/nv04_miptree.c
@@ -41,23 +41,20 @@ nv04_miptree_layout(struct nv04_miptree *nv04mt)
static struct pipe_texture *
nv04_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv04_miptree *mt;
mt = MALLOC(sizeof(struct nv04_miptree));
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
- mt->shadow_tex = NULL;
- mt->shadow_surface = NULL;
//mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
nv04_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL |
+ mt->buffer = pscreen->buffer_create(pscreen, 256, PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE,
mt->total_size);
if (!mt->buffer) {
@@ -85,38 +82,27 @@ nv04_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ 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(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv04_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv04_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv04_miptree *mt = (struct nv04_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ 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);
}
- if (mt->shadow_tex) {
- assert(mt->shadow_surface);
- pscreen->tex_surface_release(pscreen, &mt->shadow_surface);
- nv04_miptree_release(pscreen, &mt->shadow_tex);
- }
-
FREE(mt);
}
@@ -126,41 +112,31 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
unsigned flags)
{
struct nv04_miptree *nv04mt = (struct nv04_miptree *)pt;
- struct pipe_surface *ps;
+ struct nv04_surface *ns;
- ps = CALLOC_STRUCT(pipe_surface);
- if (!ps)
+ ns = CALLOC_STRUCT(nv04_surface);
+ if (!ns)
return NULL;
- pipe_texture_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->block = pt->block;
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = nv04mt->level[level].pitch;
- ps->usage = flags;
- ps->status = PIPE_SURFACE_STATUS_DEFINED;
- ps->refcount = 1;
- ps->face = face;
- ps->level = level;
- ps->zslice = zslice;
-
- ps->offset = nv04mt->level[level].image_offset;
-
- return ps;
+ pipe_texture_reference(&ns->base.texture, pt);
+ ns->base.format = pt->format;
+ ns->base.width = pt->width[level];
+ ns->base.height = pt->height[level];
+ ns->base.usage = flags;
+ ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
+ 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;
+
+ return &ns->base;
}
static void
-nv04_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv04_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
@@ -170,8 +146,8 @@ nv04_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv04_miptree_create;
pscreen->texture_blanket = nv04_miptree_blanket;
- pscreen->texture_release = nv04_miptree_release;
+ pscreen->texture_destroy = nv04_miptree_destroy;
pscreen->get_tex_surface = nv04_miptree_surface_new;
- pscreen->tex_surface_release = nv04_miptree_surface_del;
+ 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
index 18a8872ae3..f6458232ae 100644
--- a/src/gallium/drivers/nv04/nv04_prim_vbuf.c
+++ b/src/gallium/drivers/nv04/nv04_prim_vbuf.c
@@ -1,5 +1,5 @@
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_inlines.h"
#include "pipe/internal/p_winsys_screen.h"
#include "pipe/p_compiler.h"
@@ -51,7 +51,7 @@ nv04_vbuf_render_get_vertex_info( struct vbuf_render *render )
}
-static void *
+static boolean
nv04_vbuf_render_allocate_vertices( struct vbuf_render *render,
ushort vertex_size,
ushort nr_vertices )
@@ -61,9 +61,22 @@ nv04_vbuf_render_allocate_vertices( struct 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,
@@ -244,10 +257,7 @@ nv04_vbuf_render_draw( struct vbuf_render *render,
static void
-nv04_vbuf_render_release_vertices( struct vbuf_render *render,
- void *vertices,
- unsigned vertex_size,
- unsigned vertices_used )
+nv04_vbuf_render_release_vertices( struct vbuf_render *render )
{
struct nv04_vbuf_render *nv04_render = nv04_vbuf_render(render);
@@ -278,6 +288,8 @@ nv04_vbuf_render_create( struct nv04_context *nv04 )
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;
diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c
index 9ef38bc244..f9f6d97426 100644
--- a/src/gallium/drivers/nv04/nv04_screen.c
+++ b/src/gallium/drivers/nv04/nv04_screen.c
@@ -119,28 +119,6 @@ nv04_screen_is_format_supported(struct pipe_screen *screen,
return FALSE;
}
-static void *
-nv04_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
- unsigned flags )
-{
- void *map;
- struct nv04_miptree *nv04mt = (struct nv04_miptree *)surface->texture;
-
- map = pipe_buffer_map(screen, nv04mt->buffer, flags);
- if (!map)
- return NULL;
-
- return map + surface->offset;
-}
-
-static void
-nv04_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
-{
- struct nv04_miptree *nv04mt = (struct nv04_miptree *)surface->texture;
-
- pipe_buffer_unmap(screen, nv04mt->buffer);
-}
-
static void
nv04_screen_destroy(struct pipe_screen *pscreen)
{
@@ -226,10 +204,8 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
screen->pipe.is_format_supported = nv04_screen_is_format_supported;
- screen->pipe.surface_map = nv04_surface_map;
- screen->pipe.surface_unmap = nv04_surface_unmap;
-
nv04_screen_init_miptree_functions(&screen->pipe);
+ nv04_screen_init_transfer_functions(&screen->pipe);
u_simple_screen_init(&screen->pipe);
return &screen->pipe;
diff --git a/src/gallium/drivers/nv04/nv04_screen.h b/src/gallium/drivers/nv04/nv04_screen.h
index 540aec907b..ee6fb6db44 100644
--- a/src/gallium/drivers/nv04/nv04_screen.h
+++ b/src/gallium/drivers/nv04/nv04_screen.h
@@ -24,4 +24,7 @@ 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.h b/src/gallium/drivers/nv04/nv04_state.h
index 15d4685ec1..0d51439e3f 100644
--- a/src/gallium/drivers/nv04/nv04_state.h
+++ b/src/gallium/drivers/nv04/nv04_state.h
@@ -35,9 +35,6 @@ struct nv04_miptree {
struct pipe_buffer *buffer;
uint total_size;
- struct pipe_texture *shadow_tex;
- struct pipe_surface *shadow_surface;
-
struct {
uint pitch;
uint image_offset;
diff --git a/src/gallium/drivers/nv04/nv04_state_emit.c b/src/gallium/drivers/nv04/nv04_state_emit.c
index bd8ef1adbf..eb2c1c57c6 100644
--- a/src/gallium/drivers/nv04/nv04_state_emit.c
+++ b/src/gallium/drivers/nv04/nv04_state_emit.c
@@ -93,7 +93,7 @@ static void nv04_emit_sampler(struct nv04_context *nv04, int unit)
static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
{
struct pipe_framebuffer_state* fb = nv04->framebuffer;
- struct pipe_surface *rt, *zeta;
+ struct nv04_surface *rt, *zeta;
uint32_t rt_format, w, h;
int colour_format = 0, zeta_format = 0;
struct nv04_miptree *nv04mt = 0;
@@ -101,7 +101,7 @@ static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
w = fb->cbufs[0]->width;
h = fb->cbufs[0]->height;
colour_format = fb->cbufs[0]->format;
- rt = fb->cbufs[0];
+ rt = (struct nv04_surface *)fb->cbufs[0];
if (fb->zsbuf) {
if (colour_format) {
@@ -113,7 +113,7 @@ static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
}
zeta_format = fb->zsbuf->format;
- zeta = fb->zsbuf;
+ zeta = (struct nv04_surface *)fb->zsbuf;
}
switch (colour_format) {
@@ -131,13 +131,13 @@ static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1);
OUT_RING(rt_format);
- nv04mt = (struct nv04_miptree *)rt->texture;
+ nv04mt = (struct nv04_miptree *)rt->base.texture;
/* FIXME pitches have to be aligned ! */
BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
- OUT_RING(rt->stride|(zeta->stride<<16));
+ OUT_RING(rt->pitch|(zeta->pitch<<16));
OUT_RELOCl(nv04mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
if (fb->zsbuf) {
- nv04mt = (struct nv04_miptree *)zeta->texture;
+ nv04mt = (struct nv04_miptree *)zeta->base.texture;
BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
OUT_RELOCl(nv04mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
}
@@ -202,8 +202,11 @@ nv04_emit_hw_state(struct nv04_context *nv04)
*/
/* Render target */
+ unsigned rt_pitch = ((struct nv04_surface *)nv04->rt)->pitch;
+ unsigned zeta_pitch = ((struct nv04_surface *)nv04->zeta)->pitch;
+
BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
- OUT_RING(nv04->rt->stride|(nv04->zeta->stride<<16));
+ OUT_RING(rt_pitch|(zeta_pitch<<16));
OUT_RELOCl(nv04->rt, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
if (nv04->zeta) {
BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
diff --git a/src/gallium/drivers/nv04/nv04_surface.c b/src/gallium/drivers/nv04/nv04_surface.c
index 14abf16679..0387ff4e78 100644
--- a/src/gallium/drivers/nv04/nv04_surface.c
+++ b/src/gallium/drivers/nv04/nv04_surface.c
@@ -33,7 +33,7 @@
#include "util/u_tile.h"
static void
-nv04_surface_copy(struct pipe_context *pipe, boolean do_flip,
+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)
@@ -41,15 +41,6 @@ nv04_surface_copy(struct pipe_context *pipe, boolean do_flip,
struct nv04_context *nv04 = nv04_context(pipe);
struct nv04_surface_2d *eng2d = nv04->screen->eng2d;
- if (do_flip) {
- desty += height;
- while (height--) {
- eng2d->copy(eng2d, dest, destx, desty--, src,
- srcx, srcy++, width, 1);
- }
- return;
- }
-
eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
}
diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c
index 230cfd17dd..f3a8d7efee 100644
--- a/src/gallium/drivers/nv04/nv04_surface_2d.c
+++ b/src/gallium/drivers/nv04/nv04_surface_2d.c
@@ -101,6 +101,7 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
struct nouveau_grobj *sifm = ctx->sifm;
struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
+ const unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
const unsigned max_w = 1024;
const unsigned max_h = 1024;
const unsigned sub_w = w > max_w ? max_w : w;
@@ -110,6 +111,8 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
/* POT or GTFO */
assert(!(w & (w - 1)) && !(h & (h - 1)));
+ /* That's the way she likes it */
+ assert(src_pitch == ((struct nv04_surface *)dst)->pitch);
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1);
OUT_RELOCo(chan, dst_bo,
@@ -130,7 +133,7 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
for (cx = 0; cx < w; cx += sub_w) {
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
OUT_RELOCl(chan, dst_bo, dst->offset + nv04_swizzle_bits(cx, cy) *
- dst->block.size, NOUVEAU_BO_GART |
+ dst->texture->block.size, NOUVEAU_BO_GART |
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
@@ -146,11 +149,11 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
OUT_RING (chan, sub_h << 16 | sub_w);
- OUT_RING (chan, src->stride |
+ OUT_RING (chan, src_pitch |
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
- OUT_RELOCl(chan, src_bo, src->offset + cy * src->stride +
- cx * src->block.size, NOUVEAU_BO_GART |
+ OUT_RELOCl(chan, src_bo, src->offset + cy * src_pitch +
+ cx * src->texture->block.size, NOUVEAU_BO_GART |
NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
OUT_RING (chan, 0);
}
@@ -168,10 +171,12 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
struct nouveau_grobj *m2mf = ctx->m2mf;
struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
- unsigned dst_offset, src_offset;
-
- dst_offset = dst->offset + (dy * dst->stride) + (dx * dst->block.size);
- src_offset = src->offset + (sy * src->stride) + (sx * src->block.size);
+ unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
+ unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
+ unsigned dst_offset = dst->offset + dy * dst_pitch +
+ dx * dst->texture->block.size;
+ unsigned src_offset = src->offset + sy * src_pitch +
+ sx * src->texture->block.size;
WAIT_RING (chan, 3 + ((h / 2047) + 1) * 9);
BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
@@ -188,16 +193,16 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
OUT_RELOCl(chan, dst_bo, dst_offset,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
- OUT_RING (chan, src->stride);
- OUT_RING (chan, dst->stride);
- OUT_RING (chan, w * src->block.size);
+ OUT_RING (chan, src_pitch);
+ OUT_RING (chan, dst_pitch);
+ OUT_RING (chan, w * src->texture->block.size);
OUT_RING (chan, count);
OUT_RING (chan, 0x0101);
OUT_RING (chan, 0);
h -= count;
- src_offset += src->stride * count;
- dst_offset += dst->stride * count;
+ src_offset += src_pitch * count;
+ dst_offset += dst_pitch * count;
}
return 0;
@@ -213,6 +218,8 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
struct nouveau_grobj *blit = ctx->blit;
struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
+ unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
+ unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
int format;
format = nv04_surface_format(dst->format);
@@ -225,7 +232,7 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
OUT_RING (chan, format);
- OUT_RING (chan, (dst->stride << 16) | src->stride);
+ OUT_RING (chan, (dst_pitch << 16) | src_pitch);
OUT_RELOCl(chan, src_bo, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
@@ -242,6 +249,8 @@ nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
int dx, int dy, struct pipe_surface *src, int sx, int sy,
int w, int h)
{
+ unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
+ unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
@@ -257,7 +266,8 @@ nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
* to NV_MEMORY_TO_MEMORY_FORMAT in this case.
*/
if ((src->offset & 63) || (dst->offset & 63) ||
- (src->stride & 63) || (dst->stride & 63)) {
+ (src_pitch & 63) || (dst_pitch & 63) ||
+ debug_get_bool_option("NOUVEAU_NO_COPYBLIT", FALSE)) {
nv04_surface_copy_m2mf(ctx, dst, dx, dy, src, sx, sy, w, h);
return;
}
@@ -273,6 +283,7 @@ nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
struct nouveau_grobj *surf2d = ctx->surf2d;
struct nouveau_grobj *rect = ctx->rect;
struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
+ unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
int cs2d_format, gdirect_format;
cs2d_format = nv04_surface_format(dst->format);
@@ -287,7 +298,7 @@ nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
OUT_RING (chan, cs2d_format);
- OUT_RING (chan, (dst->stride << 16) | dst->stride);
+ OUT_RING (chan, (dst_pitch << 16) | dst_pitch);
OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
@@ -426,13 +437,21 @@ nv04_surface_2d_init(struct nouveau_winsys *nvws)
return NULL;
}
- if (chan->device->chipset < 0x10) {
- class = NV04_SCALED_IMAGE_FROM_MEMORY;
- } else
- if (chan->device->chipset < 0x40) {
+ switch (chan->device->chipset & 0xf0) {
+ case 0x10:
+ case 0x20:
class = NV10_SCALED_IMAGE_FROM_MEMORY;
- } else {
+ break;
+ case 0x30:
+ class = NV30_SCALED_IMAGE_FROM_MEMORY;
+ break;
+ case 0x40:
+ case 0x60:
class = NV40_SCALED_IMAGE_FROM_MEMORY;
+ break;
+ default:
+ class = NV04_SCALED_IMAGE_FROM_MEMORY;
+ break;
}
ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->sifm);
diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.h b/src/gallium/drivers/nv04/nv04_surface_2d.h
index 21b8f86960..82ce7189c8 100644
--- a/src/gallium/drivers/nv04/nv04_surface_2d.h
+++ b/src/gallium/drivers/nv04/nv04_surface_2d.h
@@ -1,6 +1,11 @@
#ifndef __NV04_SURFACE_2D_H__
#define __NV04_SURFACE_2D_H__
+struct nv04_surface {
+ struct pipe_surface base;
+ unsigned pitch;
+};
+
struct nv04_surface_2d {
struct nouveau_winsys *nvws;
struct nouveau_notifier *ntfy;
diff --git a/src/gallium/drivers/nv04/nv04_transfer.c b/src/gallium/drivers/nv04/nv04_transfer.c
new file mode 100644
index 0000000000..e925a44e29
--- /dev/null
+++ b/src/gallium/drivers/nv04/nv04_transfer.c
@@ -0,0 +1,196 @@
+#include <pipe/p_state.h>
+#include <pipe/p_defines.h>
+#include <pipe/p_inlines.h>
+#include <util/u_memory.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;
+ bool direct;
+};
+
+static unsigned nv04_usage_tx_to_buf(unsigned tx_usage)
+{
+ switch (tx_usage) {
+ case PIPE_TRANSFER_READ:
+ return PIPE_BUFFER_USAGE_CPU_READ;
+ case PIPE_TRANSFER_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_WRITE;
+ case PIPE_TRANSFER_READ_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static void
+nv04_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+ struct pipe_texture *template)
+{
+ memset(template, 0, sizeof(struct pipe_texture));
+ template->target = pt->target;
+ template->format = pt->format;
+ template->width[0] = pt->width[level];
+ template->height[0] = pt->height[level];
+ template->depth[0] = 1;
+ template->block = pt->block;
+ template->nblocksx[0] = pt->nblocksx[level];
+ template->nblocksy[0] = pt->nblocksx[level];
+ template->last_level = 0;
+ template->compressed = pt->compressed;
+ 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.format = pt->format;
+ tx->base.x = x;
+ tx->base.y = y;
+ tx->base.width = w;
+ tx->base.height = h;
+ tx->base.block = pt->block;
+ tx->base.nblocksx = pt->nblocksx[level];
+ tx->base.nblocksy = pt->nblocksy[level];
+ tx->base.stride = mt->level[level].pitch;
+ tx->base.usage = usage;
+ tx->base.face = face;
+ 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,
+ nv04_usage_tx_to_buf(usage));
+ return &tx->base;
+ }
+
+ tx->direct = false;
+
+ nv04_compatible_transfer_tex(pt, level, &tx_tex_template);
+
+ tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
+ if (!tx_tex)
+ {
+ FREE(tx);
+ return NULL;
+ }
+
+ tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
+ face, level, zslice,
+ nv04_usage_tx_to_buf(usage));
+
+ pipe_texture_reference(&tx_tex, NULL);
+
+ if (!tx->surface)
+ {
+ pipe_surface_reference(&tx->surface, NULL);
+ FREE(tx);
+ return NULL;
+ }
+
+ if (usage != PIPE_TRANSFER_WRITE) {
+ 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, 0, 0,
+ src->width, src->height);
+
+ 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_READ) {
+ 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, 0, 0,
+ tx->surface, 0, 0,
+ dst->width, dst->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,
+ nv04_usage_tx_to_buf(ptx->usage));
+
+ return map + ns->base.offset +
+ ptx->y * ns->pitch + ptx->x * ptx->block.size;
+}
+
+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/nv10/Makefile b/src/gallium/drivers/nv10/Makefile
index 4ba7ce586d..62677f5194 100644
--- a/src/gallium/drivers/nv10/Makefile
+++ b/src/gallium/drivers/nv10/Makefile
@@ -3,7 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nv10
-DRIVER_SOURCES = \
+C_SOURCES = \
nv10_clear.c \
nv10_context.c \
nv10_fragprog.c \
@@ -14,15 +14,7 @@ DRIVER_SOURCES = \
nv10_state.c \
nv10_state_emit.c \
nv10_surface.c \
+ nv10_transfer.c \
nv10_vbo.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/nv10/nv10_miptree.c b/src/gallium/drivers/nv10/nv10_miptree.c
index 9616135461..bb3a1c0f19 100644
--- a/src/gallium/drivers/nv10/nv10_miptree.c
+++ b/src/gallium/drivers/nv10/nv10_miptree.c
@@ -66,31 +66,30 @@ nv10_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ 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(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static struct pipe_texture *
nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = screen->winsys;
struct nv10_miptree *mt;
mt = MALLOC(sizeof(struct nv10_miptree));
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = screen;
nv10_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL,
+ mt->buffer = screen->buffer_create(screen, 256, PIPE_BUFFER_USAGE_PIXEL,
mt->total_size);
if (!mt->buffer) {
FREE(mt);
@@ -101,22 +100,17 @@ nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
}
static void
-nv10_miptree_release(struct pipe_screen *screen, struct pipe_texture **pt)
+nv10_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *mt = *pt;
-
- *pt = NULL;
- if (--mt->refcount <= 0) {
- struct nv10_miptree *nv10mt = (struct nv10_miptree *)mt;
- int l;
-
- pipe_buffer_reference(screen, &nv10mt->buffer, NULL);
- for (l = 0; l <= mt->last_level; l++) {
- if (nv10mt->level[l].image_offset)
- FREE(nv10mt->level[l].image_offset);
- }
- FREE(nv10mt);
- }
+ 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
@@ -131,35 +125,35 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice,
unsigned flags)
{
- struct pipe_winsys *ws = screen->winsys;
struct nv10_miptree *nv10mt = (struct nv10_miptree *)pt;
- struct pipe_surface *ps;
+ struct nv04_surface *ns;
- ps = CALLOC_STRUCT(pipe_surface);
- if (!ps)
+ ns = CALLOC_STRUCT(nv04_surface);
+ if (!ns)
return NULL;
- pipe_texture_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->block = pt->block;
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = nv10mt->level[level].pitch;
- ps->refcount = 1;
+ pipe_texture_reference(&ns->base.texture, pt);
+ ns->base.format = pt->format;
+ ns->base.width = pt->width[level];
+ ns->base.height = pt->height[level];
+ ns->base.usage = flags;
+ ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
+ 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) {
- ps->offset = nv10mt->level[level].image_offset[face];
+ ns->base.offset = nv10mt->level[level].image_offset[face];
} else {
- ps->offset = nv10mt->level[level].image_offset[0];
+ ns->base.offset = nv10mt->level[level].image_offset[0];
}
- return ps;
+ return &ns->base;
}
static void
-nv10_miptree_surface_release(struct pipe_screen *screen,
- struct pipe_surface **surface)
+nv10_miptree_surface_destroy(struct pipe_surface *surface)
{
}
@@ -167,8 +161,8 @@ void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv10_miptree_create;
pscreen->texture_blanket = nv10_miptree_blanket;
- pscreen->texture_release = nv10_miptree_release;
+ pscreen->texture_destroy = nv10_miptree_destroy;
pscreen->get_tex_surface = nv10_miptree_surface_get;
- pscreen->tex_surface_release = nv10_miptree_surface_release;
+ 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
index 7435d87315..089c236302 100644
--- a/src/gallium/drivers/nv10/nv10_prim_vbuf.c
+++ b/src/gallium/drivers/nv10/nv10_prim_vbuf.c
@@ -38,7 +38,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_inlines.h"
#include "pipe/internal/p_winsys_screen.h"
@@ -99,27 +99,50 @@ nv10_vbuf_render_get_vertex_info( struct vbuf_render *render )
return &nv10->vertex_info;
}
-
-static void *
+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_winsys *winsys = nv10->pipe.winsys;
+ 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 = winsys->buffer_create(winsys, 64, PIPE_BUFFER_USAGE_VERTEX, size);
+ 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_winsys *winsys = nv10->pipe.winsys;
+
return winsys->buffer_map(winsys,
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_winsys *winsys = nv10->pipe.winsys;
+
+ assert(!nv10_render->buffer);
+ winsys->buffer_unmap(winsys, nv10_render->buffer);
+}
static boolean
nv10_vbuf_render_set_primitive( struct vbuf_render *render,
@@ -176,19 +199,14 @@ nv10_vbuf_render_draw( struct vbuf_render *render,
static void
-nv10_vbuf_render_release_vertices( struct vbuf_render *render,
- void *vertices,
- unsigned vertex_size,
- unsigned vertices_used )
+nv10_vbuf_render_release_vertices( struct vbuf_render *render )
{
struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
struct nv10_context *nv10 = nv10_render->nv10;
- struct pipe_winsys *winsys = nv10->pipe.winsys;
struct pipe_screen *pscreen = &nv10->screen->pipe;
assert(nv10_render->buffer);
- winsys->buffer_unmap(winsys, nv10_render->buffer);
- pipe_buffer_reference(pscreen, &nv10_render->buffer, NULL);
+ pipe_buffer_reference(&nv10_render->buffer, NULL);
}
@@ -214,6 +232,8 @@ nv10_vbuf_render_create( struct nv10_context *nv10 )
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;
diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c
index f417b06c94..6532a93c7b 100644
--- a/src/gallium/drivers/nv10/nv10_screen.c
+++ b/src/gallium/drivers/nv10/nv10_screen.c
@@ -116,30 +116,6 @@ nv10_screen_is_format_supported(struct pipe_screen *screen,
return FALSE;
}
-static void *
-nv10_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
- unsigned flags )
-{
- struct pipe_winsys *ws = screen->winsys;
- void *map;
- struct nv10_miptree *nv10mt = (struct nv10_miptree *)surface->texture;
-
- map = ws->buffer_map(ws, nv10mt->buffer, flags);
- if (!map)
- return NULL;
-
- return map + surface->offset;
-}
-
-static void
-nv10_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
-{
- struct pipe_winsys *ws = screen->winsys;
- struct nv10_miptree *nv10mt = (struct nv10_miptree *)surface->texture;
-
- ws->buffer_unmap(ws, nv10mt->buffer);
-}
-
static void
nv10_screen_destroy(struct pipe_screen *pscreen)
{
@@ -215,10 +191,8 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
screen->pipe.is_format_supported = nv10_screen_is_format_supported;
- screen->pipe.surface_map = nv10_surface_map;
- screen->pipe.surface_unmap = nv10_surface_unmap;
-
nv10_screen_init_miptree_functions(&screen->pipe);
+ nv10_screen_init_transfer_functions(&screen->pipe);
u_simple_screen_init(&screen->pipe);
return &screen->pipe;
diff --git a/src/gallium/drivers/nv10/nv10_screen.h b/src/gallium/drivers/nv10/nv10_screen.h
index 60102a369a..ad829ee3fd 100644
--- a/src/gallium/drivers/nv10/nv10_screen.h
+++ b/src/gallium/drivers/nv10/nv10_screen.h
@@ -21,4 +21,8 @@ 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_emit.c b/src/gallium/drivers/nv10/nv10_state_emit.c
index 5dec618b93..d8691ef9c6 100644
--- a/src/gallium/drivers/nv10/nv10_state_emit.c
+++ b/src/gallium/drivers/nv10/nv10_state_emit.c
@@ -103,7 +103,7 @@ static void nv10_state_emit_scissor(struct nv10_context* nv10)
static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
{
struct pipe_framebuffer_state* fb = nv10->framebuffer;
- struct pipe_surface *rt, *zeta = NULL;
+ struct nv04_surface *rt, *zeta = NULL;
uint32_t rt_format, w, h;
int colour_format = 0, zeta_format = 0;
struct nv10_miptree *nv10mt = 0;
@@ -111,7 +111,7 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
w = fb->cbufs[0]->width;
h = fb->cbufs[0]->height;
colour_format = fb->cbufs[0]->format;
- rt = fb->cbufs[0];
+ rt = (struct nv04_surface *)fb->cbufs[0];
if (fb->zsbuf) {
if (colour_format) {
@@ -123,7 +123,7 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
}
zeta_format = fb->zsbuf->format;
- zeta = fb->zsbuf;
+ zeta = (struct nv04_surface *)fb->zsbuf;
}
rt_format = NV10TCL_RT_FORMAT_TYPE_LINEAR;
@@ -142,18 +142,18 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
if (zeta) {
BEGIN_RING(celsius, NV10TCL_RT_PITCH, 1);
- OUT_RING (rt->stride | (zeta->stride << 16));
+ OUT_RING (rt->pitch | (zeta->pitch << 16));
} else {
BEGIN_RING(celsius, NV10TCL_RT_PITCH, 1);
- OUT_RING (rt->stride | (rt->stride << 16));
+ OUT_RING (rt->pitch | (rt->pitch << 16));
}
- nv10mt = (struct nv10_miptree *)rt->texture;
+ nv10mt = (struct nv10_miptree *)rt->base.texture;
nv10->rt[0] = nv10mt->buffer;
if (zeta_format)
{
- nv10mt = (struct nv10_miptree *)zeta->texture;
+ nv10mt = (struct nv10_miptree *)zeta->base.texture;
nv10->zeta = nv10mt->buffer;
}
diff --git a/src/gallium/drivers/nv10/nv10_surface.c b/src/gallium/drivers/nv10/nv10_surface.c
index 2538151063..5b52246a9c 100644
--- a/src/gallium/drivers/nv10/nv10_surface.c
+++ b/src/gallium/drivers/nv10/nv10_surface.c
@@ -33,7 +33,7 @@
#include "util/u_tile.h"
static void
-nv10_surface_copy(struct pipe_context *pipe, boolean do_flip,
+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)
@@ -41,15 +41,6 @@ nv10_surface_copy(struct pipe_context *pipe, boolean do_flip,
struct nv10_context *nv10 = nv10_context(pipe);
struct nv04_surface_2d *eng2d = nv10->screen->eng2d;
- if (do_flip) {
- desty += height;
- while (height--) {
- eng2d->copy(eng2d, dest, destx, desty--, src,
- srcx, srcy++, width, 1);
- }
- return;
- }
-
eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
}
diff --git a/src/gallium/drivers/nv10/nv10_transfer.c b/src/gallium/drivers/nv10/nv10_transfer.c
new file mode 100644
index 0000000000..5a99225409
--- /dev/null
+++ b/src/gallium/drivers/nv10/nv10_transfer.c
@@ -0,0 +1,196 @@
+#include <pipe/p_state.h>
+#include <pipe/p_defines.h>
+#include <pipe/p_inlines.h>
+#include <util/u_memory.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;
+ bool direct;
+};
+
+static unsigned nv10_usage_tx_to_buf(unsigned tx_usage)
+{
+ switch (tx_usage) {
+ case PIPE_TRANSFER_READ:
+ return PIPE_BUFFER_USAGE_CPU_READ;
+ case PIPE_TRANSFER_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_WRITE;
+ case PIPE_TRANSFER_READ_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static void
+nv10_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+ struct pipe_texture *template)
+{
+ memset(template, 0, sizeof(struct pipe_texture));
+ template->target = pt->target;
+ template->format = pt->format;
+ template->width[0] = pt->width[level];
+ template->height[0] = pt->height[level];
+ template->depth[0] = 1;
+ template->block = pt->block;
+ template->nblocksx[0] = pt->nblocksx[level];
+ template->nblocksy[0] = pt->nblocksx[level];
+ template->last_level = 0;
+ template->compressed = pt->compressed;
+ 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.format = pt->format;
+ tx->base.x = x;
+ tx->base.y = y;
+ tx->base.width = w;
+ tx->base.height = h;
+ tx->base.block = pt->block;
+ tx->base.nblocksx = pt->nblocksx[level];
+ tx->base.nblocksy = pt->nblocksy[level];
+ tx->base.stride = mt->level[level].pitch;
+ tx->base.usage = usage;
+ tx->base.face = face;
+ 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,
+ nv10_usage_tx_to_buf(usage));
+ return &tx->base;
+ }
+
+ tx->direct = false;
+
+ nv10_compatible_transfer_tex(pt, level, &tx_tex_template);
+
+ tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
+ if (!tx_tex)
+ {
+ FREE(tx);
+ return NULL;
+ }
+
+ tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
+ face, level, zslice,
+ nv10_usage_tx_to_buf(usage));
+
+ pipe_texture_reference(&tx_tex, NULL);
+
+ if (!tx->surface)
+ {
+ pipe_surface_reference(&tx->surface, NULL);
+ FREE(tx);
+ return NULL;
+ }
+
+ if (usage != PIPE_TRANSFER_WRITE) {
+ 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, 0, 0,
+ src->width, src->height);
+
+ 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_READ) {
+ 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, 0, 0,
+ tx->surface, 0, 0,
+ dst->width, dst->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,
+ nv10_usage_tx_to_buf(ptx->usage));
+
+ return map + ns->base.offset +
+ ptx->y * ns->pitch + ptx->x * ptx->block.size;
+}
+
+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/nv20/Makefile b/src/gallium/drivers/nv20/Makefile
index d777fd3d8b..1305f26c59 100644
--- a/src/gallium/drivers/nv20/Makefile
+++ b/src/gallium/drivers/nv20/Makefile
@@ -3,7 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nv20
-DRIVER_SOURCES = \
+C_SOURCES = \
nv20_clear.c \
nv20_context.c \
nv20_fragprog.c \
@@ -14,16 +14,8 @@ DRIVER_SOURCES = \
nv20_state.c \
nv20_state_emit.c \
nv20_surface.c \
+ nv20_transfer.c \
nv20_vbo.c
# nv20_vertprog.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/nv20/nv20_miptree.c b/src/gallium/drivers/nv20/nv20_miptree.c
index ef7e9c5428..b2f29aff8d 100644
--- a/src/gallium/drivers/nv20/nv20_miptree.c
+++ b/src/gallium/drivers/nv20/nv20_miptree.c
@@ -9,10 +9,14 @@ static void
nv20_miptree_layout(struct nv20_miptree *nv20mt)
{
struct pipe_texture *pt = &nv20mt->base;
- boolean swizzled = FALSE;
uint width = pt->width[0], height = pt->height[0];
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;
@@ -26,25 +30,31 @@ nv20_miptree_layout(struct nv20_miptree *nv20mt)
pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
- if (swizzled)
- nv20mt->level[l].pitch = pt->nblocksx[l] * pt->block.size;
+ if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
+ nv20mt->level[l].pitch = align(pt->width[0] * pt->block.size, 64);
else
- nv20mt->level[l].pitch = pt->nblocksx[0] * pt->block.size;
- nv20mt->level[l].pitch = (nv20mt->level[l].pitch + 63) & ~63;
+ nv20mt->level[l].pitch = pt->width[l] * pt->block.size;
nv20mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
width = MAX2(1, width >> 1);
height = MAX2(1, height >> 1);
-
}
for (f = 0; f < nr_faces; f++) {
- for (l = 0; l <= pt->last_level; l++) {
+ for (l = 0; l < pt->last_level; l++) {
nv20mt->level[l].image_offset[f] = offset;
- offset += nv20mt->level[l].pitch * pt->height[l];
+
+ if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
+ pt->width[l + 1] > 1 && pt->height[l + 1] > 1)
+ offset += align(nv20mt->level[l].pitch * pt->height[l], 64);
+ else
+ offset += nv20mt->level[l].pitch * pt->height[l];
}
+
+ nv20mt->level[l].image_offset[f] = offset;
+ offset += nv20mt->level[l].pitch * pt->height[l];
}
nv20mt->total_size = offset;
@@ -66,19 +76,18 @@ nv20_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ 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(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static struct pipe_texture *
nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = screen->winsys;
struct nv20_miptree *mt;
unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
@@ -87,7 +96,7 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = screen;
/* Swizzled textures must be POT */
@@ -96,7 +105,8 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
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_DISPLAY_TARGET |
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
else
if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
@@ -107,7 +117,11 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
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;
}
@@ -118,7 +132,7 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
nv20_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, buf_usage, mt->total_size);
+ mt->buffer = screen->buffer_create(screen, 256, buf_usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
@@ -128,22 +142,16 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
}
static void
-nv20_miptree_release(struct pipe_screen *screen, struct pipe_texture **pt)
+nv20_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *mt = *pt;
-
- *pt = NULL;
- if (--mt->refcount <= 0) {
- struct nv20_miptree *nv20mt = (struct nv20_miptree *)mt;
- int l;
+ struct nv20_miptree *nv20mt = (struct nv20_miptree *)pt;
+ int l;
- pipe_buffer_reference(screen, &nv20mt->buffer, NULL);
- for (l = 0; l <= mt->last_level; l++) {
- if (nv20mt->level[l].image_offset)
- FREE(nv20mt->level[l].image_offset);
- }
- FREE(nv20mt);
- }
+ 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 *
@@ -152,45 +160,38 @@ nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
unsigned flags)
{
struct nv20_miptree *nv20mt = (struct nv20_miptree *)pt;
- struct pipe_surface *ps;
+ struct nv04_surface *ns;
- ps = CALLOC_STRUCT(pipe_surface);
- if (!ps)
+ ns = CALLOC_STRUCT(nv04_surface);
+ if (!ns)
return NULL;
- pipe_texture_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->block = pt->block;
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = nv20mt->level[level].pitch;
- ps->usage = flags;
- ps->status = PIPE_SURFACE_STATUS_DEFINED;
- ps->refcount = 1;
+ pipe_texture_reference(&ns->base.texture, pt);
+ ns->base.format = pt->format;
+ ns->base.width = pt->width[level];
+ ns->base.height = pt->height[level];
+ ns->base.usage = flags;
+ ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
+ 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) {
- ps->offset = nv20mt->level[level].image_offset[face];
+ ns->base.offset = nv20mt->level[level].image_offset[face];
} else
if (pt->target == PIPE_TEXTURE_3D) {
- ps->offset = nv20mt->level[level].image_offset[zslice];
+ ns->base.offset = nv20mt->level[level].image_offset[zslice];
} else {
- ps->offset = nv20mt->level[level].image_offset[0];
+ ns->base.offset = nv20mt->level[level].image_offset[0];
}
- return ps;
+ return &ns->base;
}
static void
-nv20_miptree_surface_release(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv20_miptree_surface_destroy(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
@@ -199,8 +200,8 @@ void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv20_miptree_create;
pscreen->texture_blanket = nv20_miptree_blanket;
- pscreen->texture_release = nv20_miptree_release;
+ pscreen->texture_destroy = nv20_miptree_destroy;
pscreen->get_tex_surface = nv20_miptree_surface_get;
- pscreen->tex_surface_release = nv20_miptree_surface_release;
+ 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
index 4dd7052814..8aa342cd2d 100644
--- a/src/gallium/drivers/nv20/nv20_prim_vbuf.c
+++ b/src/gallium/drivers/nv20/nv20_prim_vbuf.c
@@ -38,7 +38,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_inlines.h"
#include "pipe/internal/p_winsys_screen.h"
@@ -109,18 +109,15 @@ nv20__allocate_mbuffer(struct nv20_vbuf_render *nv20_render, size_t size)
return nv20_render->mbuffer;
}
-static void *
+static void
nv20__allocate_pbuffer(struct nv20_vbuf_render *nv20_render, size_t size)
{
- struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys;
- nv20_render->pbuffer = winsys->buffer_create(winsys, 64,
+ struct pipe_screen *screen = nv20_render->nv20->pipe.screen;
+ nv20_render->pbuffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_VERTEX, size);
- return winsys->buffer_map(winsys,
- nv20_render->pbuffer,
- PIPE_BUFFER_USAGE_CPU_WRITE);
}
-static void *
+static boolean
nv20_vbuf_render_allocate_vertices( struct vbuf_render *render,
ushort vertex_size,
ushort nr_vertices )
@@ -137,15 +134,49 @@ nv20_vbuf_render_allocate_vertices( struct vbuf_render *render,
* buffer, the data will be passed directly via the fifo.
*/
/* XXX: Pipe vertex buffers don't work. */
- if (0 && size > 16 * 1024)
- buf = nv20__allocate_pbuffer(nv20_render, size);
- else
+ 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;
+ 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_winsys *winsys = nv20_render->nv20->pipe.winsys;
+
+ if (nv20_render->pbuffer) {
+ return winsys->buffer_map(winsys,
+ 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_winsys *winsys = nv20_render->nv20->pipe.winsys;
+
+ if (nv20_render->pbuffer)
+ winsys->buffer_unmap(winsys, nv20_render->pbuffer);
}
static boolean
@@ -323,19 +354,14 @@ nv20_vbuf_render_draw( struct vbuf_render *render,
static void
-nv20_vbuf_render_release_vertices( struct vbuf_render *render,
- void *vertices,
- unsigned vertex_size,
- unsigned vertices_used )
+nv20_vbuf_render_release_vertices( struct vbuf_render *render )
{
struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render);
struct nv20_context *nv20 = nv20_render->nv20;
- struct pipe_winsys *winsys = nv20->pipe.winsys;
struct pipe_screen *pscreen = &nv20->screen->pipe;
if (nv20_render->pbuffer) {
- winsys->buffer_unmap(winsys, nv20_render->pbuffer);
- pipe_buffer_reference(pscreen, &nv20_render->pbuffer, NULL);
+ pipe_buffer_reference(&nv20_render->pbuffer, NULL);
} else if (nv20_render->mbuffer) {
FREE(nv20_render->mbuffer);
nv20_render->mbuffer = NULL;
@@ -371,6 +397,8 @@ nv20_vbuf_render_create( struct nv20_context *nv20 )
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;
diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c
index 5f2b7b4f71..7760ae27c0 100644
--- a/src/gallium/drivers/nv20/nv20_screen.c
+++ b/src/gallium/drivers/nv20/nv20_screen.c
@@ -116,30 +116,6 @@ nv20_screen_is_format_supported(struct pipe_screen *screen,
return FALSE;
}
-static void *
-nv20_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
- unsigned flags )
-{
- struct pipe_winsys *ws = screen->winsys;
- void *map;
- struct nv20_miptree *nv20mt = (struct nv20_miptree *)surface->texture;
-
- map = ws->buffer_map(ws, nv20mt->buffer, flags);
- if (!map)
- return NULL;
-
- return map + surface->offset;
-}
-
-static void
-nv20_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
-{
- struct pipe_winsys *ws = screen->winsys;
- struct nv20_miptree *nv20mt = (struct nv20_miptree *)surface->texture;
-
- ws->buffer_unmap(ws, nv20mt->buffer);
-}
-
static void
nv20_screen_destroy(struct pipe_screen *pscreen)
{
@@ -211,10 +187,8 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
screen->pipe.is_format_supported = nv20_screen_is_format_supported;
- screen->pipe.surface_map = nv20_surface_map;
- screen->pipe.surface_unmap = nv20_surface_unmap;
-
nv20_screen_init_miptree_functions(&screen->pipe);
+ nv20_screen_init_transfer_functions(&screen->pipe);
u_simple_screen_init(&screen->pipe);
return &screen->pipe;
diff --git a/src/gallium/drivers/nv20/nv20_screen.h b/src/gallium/drivers/nv20/nv20_screen.h
index bf2f2c0d9f..d9fce2bced 100644
--- a/src/gallium/drivers/nv20/nv20_screen.h
+++ b/src/gallium/drivers/nv20/nv20_screen.h
@@ -21,4 +21,8 @@ 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_emit.c b/src/gallium/drivers/nv20/nv20_state_emit.c
index 0f4df9ca31..4042f46d05 100644
--- a/src/gallium/drivers/nv20/nv20_state_emit.c
+++ b/src/gallium/drivers/nv20/nv20_state_emit.c
@@ -109,7 +109,7 @@ static void nv20_state_emit_scissor(struct nv20_context* nv20)
static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
{
struct pipe_framebuffer_state* fb = nv20->framebuffer;
- struct pipe_surface *rt, *zeta = NULL;
+ struct nv04_surface *rt, *zeta = NULL;
uint32_t rt_format, w, h;
int colour_format = 0, zeta_format = 0;
struct nv20_miptree *nv20mt = 0;
@@ -117,7 +117,7 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
w = fb->cbufs[0]->width;
h = fb->cbufs[0]->height;
colour_format = fb->cbufs[0]->format;
- rt = fb->cbufs[0];
+ rt = (struct nv04_surface *)fb->cbufs[0];
if (fb->zsbuf) {
if (colour_format) {
@@ -129,7 +129,7 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
}
zeta_format = fb->zsbuf->format;
- zeta = fb->zsbuf;
+ zeta = (struct nv04_surface *)fb->zsbuf;
}
rt_format = NV20TCL_RT_FORMAT_TYPE_LINEAR | 0x20;
@@ -148,18 +148,18 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
if (zeta) {
BEGIN_RING(kelvin, NV20TCL_RT_PITCH, 1);
- OUT_RING (rt->stride | (zeta->stride << 16));
+ OUT_RING (rt->pitch | (zeta->pitch << 16));
} else {
BEGIN_RING(kelvin, NV20TCL_RT_PITCH, 1);
- OUT_RING (rt->stride | (rt->stride << 16));
+ OUT_RING (rt->pitch | (rt->pitch << 16));
}
- nv20mt = (struct nv20_miptree *)rt->texture;
+ nv20mt = (struct nv20_miptree *)rt->base.texture;
nv20->rt[0] = nv20mt->buffer;
if (zeta_format)
{
- nv20mt = (struct nv20_miptree *)zeta->texture;
+ nv20mt = (struct nv20_miptree *)zeta->base.texture;
nv20->zeta = nv20mt->buffer;
}
diff --git a/src/gallium/drivers/nv20/nv20_surface.c b/src/gallium/drivers/nv20/nv20_surface.c
index 6cd607583c..4224bdd6af 100644
--- a/src/gallium/drivers/nv20/nv20_surface.c
+++ b/src/gallium/drivers/nv20/nv20_surface.c
@@ -33,7 +33,7 @@
#include "util/u_tile.h"
static void
-nv20_surface_copy(struct pipe_context *pipe, boolean do_flip,
+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)
@@ -41,15 +41,6 @@ nv20_surface_copy(struct pipe_context *pipe, boolean do_flip,
struct nv20_context *nv20 = nv20_context(pipe);
struct nv04_surface_2d *eng2d = nv20->screen->eng2d;
- if (do_flip) {
- desty += height;
- while (height--) {
- eng2d->copy(eng2d, dest, destx, desty--, src,
- srcx, srcy++, width, 1);
- }
- return;
- }
-
eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
}
diff --git a/src/gallium/drivers/nv20/nv20_transfer.c b/src/gallium/drivers/nv20/nv20_transfer.c
new file mode 100644
index 0000000000..e5255296aa
--- /dev/null
+++ b/src/gallium/drivers/nv20/nv20_transfer.c
@@ -0,0 +1,196 @@
+#include <pipe/p_state.h>
+#include <pipe/p_defines.h>
+#include <pipe/p_inlines.h>
+#include <util/u_memory.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;
+ bool direct;
+};
+
+static unsigned nv20_usage_tx_to_buf(unsigned tx_usage)
+{
+ switch (tx_usage) {
+ case PIPE_TRANSFER_READ:
+ return PIPE_BUFFER_USAGE_CPU_READ;
+ case PIPE_TRANSFER_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_WRITE;
+ case PIPE_TRANSFER_READ_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static void
+nv20_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+ struct pipe_texture *template)
+{
+ memset(template, 0, sizeof(struct pipe_texture));
+ template->target = pt->target;
+ template->format = pt->format;
+ template->width[0] = pt->width[level];
+ template->height[0] = pt->height[level];
+ template->depth[0] = 1;
+ template->block = pt->block;
+ template->nblocksx[0] = pt->nblocksx[level];
+ template->nblocksy[0] = pt->nblocksx[level];
+ template->last_level = 0;
+ template->compressed = pt->compressed;
+ 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.format = pt->format;
+ tx->base.x = x;
+ tx->base.y = y;
+ tx->base.width = w;
+ tx->base.height = h;
+ tx->base.block = pt->block;
+ tx->base.nblocksx = pt->nblocksx[level];
+ tx->base.nblocksy = pt->nblocksy[level];
+ tx->base.stride = mt->level[level].pitch;
+ tx->base.usage = usage;
+ tx->base.face = face;
+ 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,
+ nv20_usage_tx_to_buf(usage));
+ return &tx->base;
+ }
+
+ tx->direct = false;
+
+ nv20_compatible_transfer_tex(pt, level, &tx_tex_template);
+
+ tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
+ if (!tx_tex)
+ {
+ FREE(tx);
+ return NULL;
+ }
+
+ tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
+ face, level, zslice,
+ nv20_usage_tx_to_buf(usage));
+
+ pipe_texture_reference(&tx_tex, NULL);
+
+ if (!tx->surface)
+ {
+ pipe_surface_reference(&tx->surface, NULL);
+ FREE(tx);
+ return NULL;
+ }
+
+ if (usage != PIPE_TRANSFER_WRITE) {
+ 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, 0, 0,
+ src->width, src->height);
+
+ 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_READ) {
+ 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);
+
+ /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
+ nvscreen->eng2d->copy(nvscreen->eng2d,
+ dst, 0, 0,
+ tx->surface, 0, 0,
+ dst->width, dst->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,
+ nv20_usage_tx_to_buf(ptx->usage));
+
+ return map + ns->base.offset +
+ ptx->y * ns->pitch + ptx->x * ptx->block.size;
+}
+
+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/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
index 69f2790dfe..364c80d8f3 100644
--- a/src/gallium/drivers/nv30/Makefile
+++ b/src/gallium/drivers/nv30/Makefile
@@ -3,7 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nv30
-DRIVER_SOURCES = \
+C_SOURCES = \
nv30_clear.c \
nv30_context.c \
nv30_draw.c \
@@ -22,16 +22,8 @@ DRIVER_SOURCES = \
nv30_state_viewport.c \
nv30_state_zsa.c \
nv30_surface.c \
+ nv30_transfer.c \
nv30_vbo.c \
nv30_vertprog.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
index 320ba3f4bf..bdfe1425d2 100644
--- a/src/gallium/drivers/nv30/nv30_fragprog.c
+++ b/src/gallium/drivers/nv30/nv30_fragprog.c
@@ -834,6 +834,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
struct nv30_fragment_program *fp = nv30->fragprog;
struct pipe_buffer *constbuf =
nv30->constbuf[PIPE_SHADER_FRAGMENT];
+ struct pipe_screen *screen = nv30->pipe.screen;
struct pipe_winsys *ws = nv30->pipe.winsys;
struct nouveau_stateobj *so;
boolean new_consts = FALSE;
@@ -849,7 +850,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
return FALSE;
}
- fp->buffer = ws->buffer_create(ws, 0x100, 0, fp->insn_len * 4);
+ fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4);
nv30_fragprog_upload(nv30, fp);
so = so_new(8, 1);
@@ -864,6 +865,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
so_method(so, nv30->screen->rankine, NV34TCL_TX_UNITS_ENABLE, 1);
so_data (so, fp->samplers);
so_ref(so, &fp->so);
+ so_ref(NULL, &so);
update_constants:
if (fp->nr_consts) {
diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
index b1d2663af3..8b6ab992d1 100644
--- a/src/gallium/drivers/nv30/nv30_fragtex.c
+++ b/src/gallium/drivers/nv30/nv30_fragtex.c
@@ -137,6 +137,7 @@ nv30_fragtex_validate(struct nv30_context *nv30)
so_method(so, nv30->screen->rankine, NV34TCL_TX_ENABLE(unit), 1);
so_data (so, 0);
so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
+ so_ref(NULL, &so);
state->dirty |= (1ULL << (NV30_STATE_FRAGTEX0 + unit));
}
@@ -147,6 +148,7 @@ nv30_fragtex_validate(struct nv30_context *nv30)
so = nv30_fragtex_build(nv30, unit);
so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
+ so_ref(NULL, &so);
state->dirty |= (1ULL << (NV30_STATE_FRAGTEX0 + unit));
}
diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c
index 510c94d4e6..d6dc621c9e 100644
--- a/src/gallium/drivers/nv30/nv30_miptree.c
+++ b/src/gallium/drivers/nv30/nv30_miptree.c
@@ -67,17 +67,16 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
static struct pipe_texture *
nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv30_miptree *mt;
+ unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
+ NOUVEAU_BUFFER_USAGE_TEXTURE;
mt = MALLOC(sizeof(struct nv30_miptree));
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
- mt->shadow_tex = NULL;
- mt->shadow_surface = NULL;
/* Swizzled textures must be POT */
if (pt->width[0] & (pt->width[0] - 1) ||
@@ -85,8 +84,8 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
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))
+ 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)
@@ -107,11 +106,12 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
}
}
+ if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
+ buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+
nv30_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256,
- PIPE_BUFFER_USAGE_PIXEL |
- NOUVEAU_BUFFER_USAGE_TEXTURE,
+ mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage,
mt->total_size);
if (!mt->buffer) {
FREE(mt);
@@ -137,38 +137,27 @@ nv30_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ 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(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv30_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv30_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv30_miptree *mt = (struct nv30_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ 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);
}
- if (mt->shadow_tex) {
- if (mt->shadow_surface)
- pscreen->tex_surface_release(pscreen, &mt->shadow_surface);
- nv30_miptree_release(pscreen, &mt->shadow_tex);
- }
-
FREE(mt);
}
@@ -178,48 +167,38 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
unsigned flags)
{
struct nv30_miptree *nv30mt = (struct nv30_miptree *)pt;
- struct pipe_surface *ps;
+ struct nv04_surface *ns;
- ps = CALLOC_STRUCT(pipe_surface);
- if (!ps)
+ ns = CALLOC_STRUCT(nv04_surface);
+ if (!ns)
return NULL;
- pipe_texture_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->block = pt->block;
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = nv30mt->level[level].pitch;
- ps->usage = flags;
- ps->status = PIPE_SURFACE_STATUS_DEFINED;
- ps->refcount = 1;
- ps->face = face;
- ps->level = level;
- ps->zslice = zslice;
+ pipe_texture_reference(&ns->base.texture, pt);
+ ns->base.format = pt->format;
+ ns->base.width = pt->width[level];
+ ns->base.height = pt->height[level];
+ ns->base.usage = flags;
+ ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
+ pipe_reference_init(&ns->base.reference, 1);
+ ns->base.face = face;
+ ns->base.level = level;
+ ns->base.zslice = zslice;
+ ns->pitch = nv30mt->level[level].pitch;
if (pt->target == PIPE_TEXTURE_CUBE) {
- ps->offset = nv30mt->level[level].image_offset[face];
+ ns->base.offset = nv30mt->level[level].image_offset[face];
} else
if (pt->target == PIPE_TEXTURE_3D) {
- ps->offset = nv30mt->level[level].image_offset[zslice];
+ ns->base.offset = nv30mt->level[level].image_offset[zslice];
} else {
- ps->offset = nv30mt->level[level].image_offset[0];
+ ns->base.offset = nv30mt->level[level].image_offset[0];
}
- return ps;
+ return &ns->base;
}
static void
-nv30_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv30_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
@@ -229,7 +208,7 @@ nv30_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv30_miptree_create;
pscreen->texture_blanket = nv30_miptree_blanket;
- pscreen->texture_release = nv30_miptree_release;
+ pscreen->texture_destroy = nv30_miptree_destroy;
pscreen->get_tex_surface = nv30_miptree_surface_new;
- pscreen->tex_surface_release = nv30_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv30_miptree_surface_del;
}
diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
index c97a73f0b1..d395c5e1b7 100644
--- a/src/gallium/drivers/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nv30/nv30_screen.c
@@ -135,82 +135,6 @@ nv30_surface_buffer(struct pipe_surface *surf)
return mt->buffer;
}
-static void *
-nv30_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
- unsigned flags )
-{
- struct pipe_winsys *ws = screen->winsys;
- struct pipe_surface *surface_to_map;
- void *map;
-
- if (!(surface->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
- struct nv30_miptree *mt = (struct nv30_miptree *)surface->texture;
-
- if (!mt->shadow_tex) {
- unsigned old_tex_usage = surface->texture->tex_usage;
- surface->texture->tex_usage = NOUVEAU_TEXTURE_USAGE_LINEAR |
- PIPE_TEXTURE_USAGE_DYNAMIC;
- mt->shadow_tex = screen->texture_create(screen, surface->texture);
- surface->texture->tex_usage = old_tex_usage;
-
- assert(mt->shadow_tex->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR);
- }
-
- mt->shadow_surface = screen->get_tex_surface
- (
- screen, mt->shadow_tex,
- surface->face, surface->level, surface->zslice,
- surface->usage
- );
-
- surface_to_map = mt->shadow_surface;
- }
- else
- surface_to_map = surface;
-
- assert(surface_to_map);
-
- map = ws->buffer_map(ws, nv30_surface_buffer(surface_to_map), flags);
- if (!map)
- return NULL;
-
- return map + surface_to_map->offset;
-}
-
-static void
-nv30_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
-{
- struct pipe_winsys *ws = screen->winsys;
- struct pipe_surface *surface_to_unmap;
-
- /* TODO: Copy from shadow just before push buffer is flushed instead.
- There are probably some programs that map/unmap excessively
- before rendering. */
- if (!(surface->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
- struct nv30_miptree *mt = (struct nv30_miptree *)surface->texture;
-
- assert(mt->shadow_tex);
-
- surface_to_unmap = mt->shadow_surface;
- }
- else
- surface_to_unmap = surface;
-
- assert(surface_to_unmap);
-
- ws->buffer_unmap(ws, nv30_surface_buffer(surface_to_unmap));
-
- if (surface_to_unmap != surface) {
- struct nv30_screen *nvscreen = nv30_screen(screen);
-
- nvscreen->eng2d->copy(nvscreen->eng2d, surface, 0, 0,
- surface_to_unmap, 0, 0,
- surface->width, surface->height);
-
- screen->tex_surface_release(screen, &surface_to_unmap);
- }
-}
-
static void
nv30_screen_destroy(struct pipe_screen *pscreen)
{
@@ -391,10 +315,8 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
screen->pipe.is_format_supported = nv30_screen_surface_format_supported;
- screen->pipe.surface_map = nv30_surface_map;
- screen->pipe.surface_unmap = nv30_surface_unmap;
-
nv30_screen_init_miptree_functions(&screen->pipe);
+ nv30_screen_init_transfer_functions(&screen->pipe);
u_simple_screen_init(&screen->pipe);
return &screen->pipe;
diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h
index b11e470f94..8e36883975 100644
--- a/src/gallium/drivers/nv30/nv30_screen.h
+++ b/src/gallium/drivers/nv30/nv30_screen.h
@@ -34,4 +34,7 @@ nv30_screen(struct pipe_screen *screen)
return (struct nv30_screen *)screen;
}
+void
+nv30_screen_init_transfer_functions(struct pipe_screen *pscreen);
+
#endif
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index 26147565a5..b91e972c12 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -51,6 +51,7 @@ nv30_blend_state_create(struct pipe_context *pipe,
so_data (so, cso->dither ? 1 : 0);
so_ref(so, &bso->so);
+ so_ref(NULL, &so);
bso->pipe = *cso;
return (void *)bso;
}
@@ -404,6 +405,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
}
so_ref(so, &rsso->so);
+ so_ref(NULL, &so);
rsso->pipe = *cso;
return (void *)rsso;
}
@@ -477,6 +479,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe,
}
so_ref(so, &zsaso->so);
+ so_ref(NULL, &so);
zsaso->pipe = *cso;
return (void *)zsaso;
}
diff --git a/src/gallium/drivers/nv30/nv30_state.h b/src/gallium/drivers/nv30/nv30_state.h
index 2023278e37..e6f23bf166 100644
--- a/src/gallium/drivers/nv30/nv30_state.h
+++ b/src/gallium/drivers/nv30/nv30_state.h
@@ -76,9 +76,6 @@ struct nv30_miptree {
struct pipe_buffer *buffer;
uint total_size;
- struct pipe_texture *shadow_tex;
- struct pipe_surface *shadow_surface;
-
struct {
uint pitch;
uint *image_offset;
diff --git a/src/gallium/drivers/nv30/nv30_state_blend.c b/src/gallium/drivers/nv30/nv30_state_blend.c
index 44d43e132a..64cf9ae93a 100644
--- a/src/gallium/drivers/nv30/nv30_state_blend.c
+++ b/src/gallium/drivers/nv30/nv30_state_blend.c
@@ -28,6 +28,7 @@ nv30_state_blend_colour_validate(struct nv30_context *nv30)
(float_to_ubyte(bcol->color[2]) << 0)));
so_ref(so, &nv30->state.hw[NV30_STATE_BCOL]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c
index 77368cb205..fdc1cade90 100644
--- a/src/gallium/drivers/nv30/nv30_state_fb.c
+++ b/src/gallium/drivers/nv30/nv30_state_fb.c
@@ -5,7 +5,7 @@ static boolean
nv30_state_framebuffer_validate(struct nv30_context *nv30)
{
struct pipe_framebuffer_state *fb = &nv30->framebuffer;
- struct pipe_surface *rt[2], *zeta = NULL;
+ struct nv04_surface *rt[2], *zeta = NULL;
uint32_t rt_enable, rt_format;
int i, colour_format = 0, zeta_format = 0;
struct nouveau_stateobj *so = so_new(64, 10);
@@ -21,7 +21,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
} else {
colour_format = fb->cbufs[i]->format;
rt_enable |= (NV34TCL_RT_ENABLE_COLOR0 << i);
- rt[i] = fb->cbufs[i];
+ rt[i] = (struct nv04_surface *)fb->cbufs[i];
}
}
@@ -30,13 +30,13 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
if (fb->zsbuf) {
zeta_format = fb->zsbuf->format;
- zeta = fb->zsbuf;
+ zeta = (struct nv04_surface *)fb->zsbuf;
}
- if (!(rt[0]->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+ if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
for (i = 1; i < fb->nr_cbufs; i++)
- assert(!(rt[i]->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
+ assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
/* FIXME: NV34TCL_RT_FORMAT_LOG2_[WIDTH/HEIGHT] */
rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
@@ -71,44 +71,44 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
}
if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) {
- uint32_t pitch = rt[0]->stride;
+ uint32_t pitch = rt[0]->pitch;
if (zeta) {
- pitch |= (zeta->stride << 16);
+ pitch |= (zeta->pitch << 16);
} else {
pitch |= (pitch << 16);
}
- nv30mt = (struct nv30_miptree *)rt[0]->texture;
+ nv30mt = (struct nv30_miptree *)rt[0]->base.texture;
so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR0, 1);
so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
nv30->nvws->channel->vram->handle,
nv30->nvws->channel->gart->handle);
so_method(so, nv30->screen->rankine, NV34TCL_COLOR0_PITCH, 2);
so_data (so, pitch);
- so_reloc (so, nv30mt->buffer, rt[0]->offset, rt_flags |
+ so_reloc (so, nv30mt->buffer, rt[0]->base.offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
}
if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
- nv30mt = (struct nv30_miptree *)rt[1]->texture;
+ nv30mt = (struct nv30_miptree *)rt[1]->base.texture;
so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR1, 1);
so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
nv30->nvws->channel->vram->handle,
nv30->nvws->channel->gart->handle);
so_method(so, nv30->screen->rankine, NV34TCL_COLOR1_OFFSET, 2);
- so_reloc (so, nv30mt->buffer, rt[1]->offset, rt_flags |
+ so_reloc (so, nv30mt->buffer, rt[1]->base.offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
- so_data (so, rt[1]->stride);
+ so_data (so, rt[1]->pitch);
}
if (zeta_format) {
- nv30mt = (struct nv30_miptree *)zeta->texture;
+ nv30mt = (struct nv30_miptree *)zeta->base.texture;
so_method(so, nv30->screen->rankine, NV34TCL_DMA_ZETA, 1);
so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
nv30->nvws->channel->vram->handle,
nv30->nvws->channel->gart->handle);
so_method(so, nv30->screen->rankine, NV34TCL_ZETA_OFFSET, 1);
- so_reloc (so, nv30mt->buffer, zeta->offset, rt_flags |
+ so_reloc (so, nv30mt->buffer, zeta->base.offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
/* TODO: allocate LMA depth buffer */
}
@@ -132,6 +132,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
so_data (so, 0);
so_ref(so, &nv30->state.hw[NV30_STATE_FB]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv30/nv30_state_scissor.c b/src/gallium/drivers/nv30/nv30_state_scissor.c
index 1db9bc1795..3ac7a8471e 100644
--- a/src/gallium/drivers/nv30/nv30_state_scissor.c
+++ b/src/gallium/drivers/nv30/nv30_state_scissor.c
@@ -23,6 +23,7 @@ nv30_state_scissor_validate(struct nv30_context *nv30)
}
so_ref(so, &nv30->state.hw[NV30_STATE_SCISSOR]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv30/nv30_state_stipple.c b/src/gallium/drivers/nv30/nv30_state_stipple.c
index 41b42813b4..d0c791ac08 100644
--- a/src/gallium/drivers/nv30/nv30_state_stipple.c
+++ b/src/gallium/drivers/nv30/nv30_state_stipple.c
@@ -27,6 +27,7 @@ nv30_state_stipple_validate(struct nv30_context *nv30)
}
so_ref(so, &nv30->state.hw[NV30_STATE_STIPPLE]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv30/nv30_state_viewport.c b/src/gallium/drivers/nv30/nv30_state_viewport.c
index 951d40ebfd..c3eb413dac 100644
--- a/src/gallium/drivers/nv30/nv30_state_viewport.c
+++ b/src/gallium/drivers/nv30/nv30_state_viewport.c
@@ -7,7 +7,8 @@ nv30_state_viewport_validate(struct nv30_context *nv30)
struct nouveau_stateobj *so;
unsigned bypass;
- if (/*nv30->render_mode == HW &&*/ !nv30->rasterizer->pipe.bypass_clipping)
+ if (/*nv30->render_mode == HW &&*/
+ !nv30->rasterizer->pipe.bypass_vs_clip_and_viewport)
bypass = 0;
else
bypass = 1;
@@ -58,6 +59,7 @@ nv30_state_viewport_validate(struct nv30_context *nv30)
so_data (so, 1);
so_ref(so, &nv30->state.hw[NV30_STATE_VIEWPORT]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv30/nv30_surface.c b/src/gallium/drivers/nv30/nv30_surface.c
index 0f8dc12045..5e237e13eb 100644
--- a/src/gallium/drivers/nv30/nv30_surface.c
+++ b/src/gallium/drivers/nv30/nv30_surface.c
@@ -33,7 +33,7 @@
#include "util/u_tile.h"
static void
-nv30_surface_copy(struct pipe_context *pipe, boolean do_flip,
+nv30_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)
@@ -41,15 +41,6 @@ nv30_surface_copy(struct pipe_context *pipe, boolean do_flip,
struct nv30_context *nv30 = nv30_context(pipe);
struct nv04_surface_2d *eng2d = nv30->screen->eng2d;
- if (do_flip) {
- desty += height;
- while (height--) {
- eng2d->copy(eng2d, dest, destx, desty--, src,
- srcx, srcy++, width, 1);
- }
- return;
- }
-
eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
}
diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c
new file mode 100644
index 0000000000..8b915b35bd
--- /dev/null
+++ b/src/gallium/drivers/nv30/nv30_transfer.c
@@ -0,0 +1,196 @@
+#include <pipe/p_state.h>
+#include <pipe/p_defines.h>
+#include <pipe/p_inlines.h>
+#include <util/u_memory.h>
+#include <nouveau/nouveau_winsys.h>
+#include "nv30_context.h"
+#include "nv30_screen.h"
+#include "nv30_state.h"
+
+struct nv30_transfer {
+ struct pipe_transfer base;
+ struct pipe_surface *surface;
+ bool direct;
+};
+
+static unsigned nv30_usage_tx_to_buf(unsigned tx_usage)
+{
+ switch (tx_usage) {
+ case PIPE_TRANSFER_READ:
+ return PIPE_BUFFER_USAGE_CPU_READ;
+ case PIPE_TRANSFER_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_WRITE;
+ case PIPE_TRANSFER_READ_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static void
+nv30_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+ struct pipe_texture *template)
+{
+ memset(template, 0, sizeof(struct pipe_texture));
+ template->target = pt->target;
+ template->format = pt->format;
+ template->width[0] = pt->width[level];
+ template->height[0] = pt->height[level];
+ template->depth[0] = 1;
+ template->block = pt->block;
+ template->nblocksx[0] = pt->nblocksx[level];
+ template->nblocksy[0] = pt->nblocksx[level];
+ template->last_level = 0;
+ template->compressed = pt->compressed;
+ template->nr_samples = pt->nr_samples;
+
+ template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
+ NOUVEAU_TEXTURE_USAGE_LINEAR;
+}
+
+static struct pipe_transfer *
+nv30_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 nv30_miptree *mt = (struct nv30_miptree *)pt;
+ struct nv30_transfer *tx;
+ struct pipe_texture tx_tex_template, *tx_tex;
+
+ tx = CALLOC_STRUCT(nv30_transfer);
+ if (!tx)
+ return NULL;
+
+ pipe_texture_reference(&tx->base.texture, pt);
+ tx->base.format = pt->format;
+ tx->base.x = x;
+ tx->base.y = y;
+ tx->base.width = w;
+ tx->base.height = h;
+ tx->base.block = pt->block;
+ tx->base.nblocksx = pt->nblocksx[level];
+ tx->base.nblocksy = pt->nblocksy[level];
+ tx->base.stride = mt->level[level].pitch;
+ tx->base.usage = usage;
+ tx->base.face = face;
+ 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,
+ face, level, zslice,
+ nv30_usage_tx_to_buf(usage));
+ return &tx->base;
+ }
+
+ tx->direct = false;
+
+ nv30_compatible_transfer_tex(pt, level, &tx_tex_template);
+
+ tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
+ if (!tx_tex)
+ {
+ FREE(tx);
+ return NULL;
+ }
+
+ tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
+ 0, 0, 0,
+ nv30_usage_tx_to_buf(usage));
+
+ pipe_texture_reference(&tx_tex, NULL);
+
+ if (!tx->surface)
+ {
+ pipe_surface_reference(&tx->surface, NULL);
+ FREE(tx);
+ return NULL;
+ }
+
+ if (usage != PIPE_TRANSFER_WRITE) {
+ struct nv30_screen *nvscreen = nv30_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, 0, 0,
+ src->width, src->height);
+
+ pipe_surface_reference(&src, NULL);
+ }
+
+ return &tx->base;
+}
+
+static void
+nv30_transfer_del(struct pipe_transfer *ptx)
+{
+ struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
+
+ if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
+ struct nv30_screen *nvscreen = nv30_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, 0, 0,
+ tx->surface, 0, 0,
+ dst->width, dst->height);
+
+ pipe_surface_reference(&dst, NULL);
+ }
+
+ pipe_surface_reference(&tx->surface, NULL);
+ pipe_texture_reference(&ptx->texture, NULL);
+ FREE(ptx);
+}
+
+static void *
+nv30_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+{
+ struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
+ struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
+ struct nv30_miptree *mt = (struct nv30_miptree *)tx->surface->texture;
+ void *map = pipe_buffer_map(pscreen, mt->buffer,
+ nv30_usage_tx_to_buf(ptx->usage));
+
+ return map + ns->base.offset +
+ ptx->y * ns->pitch + ptx->x * ptx->block.size;
+}
+
+static void
+nv30_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+{
+ struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
+ struct nv30_miptree *mt = (struct nv30_miptree *)tx->surface->texture;
+
+ pipe_buffer_unmap(pscreen, mt->buffer);
+}
+
+void
+nv30_screen_init_transfer_functions(struct pipe_screen *pscreen)
+{
+ pscreen->get_tex_transfer = nv30_transfer_new;
+ pscreen->tex_transfer_destroy = nv30_transfer_del;
+ pscreen->transfer_map = nv30_transfer_map;
+ pscreen->transfer_unmap = nv30_transfer_unmap;
+}
diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c
index 2d6d48ac16..990a876382 100644
--- a/src/gallium/drivers/nv30/nv30_vbo.c
+++ b/src/gallium/drivers/nv30/nv30_vbo.c
@@ -539,10 +539,13 @@ nv30_vbo_validate(struct nv30_context *nv30)
so_data (vtxbuf, 0);
so_ref(vtxbuf, &nv30->state.hw[NV30_STATE_VTXBUF]);
+ so_ref(NULL, &vtxbuf);
nv30->state.dirty |= (1ULL << NV30_STATE_VTXBUF);
so_ref(vtxfmt, &nv30->state.hw[NV30_STATE_VTXFMT]);
+ so_ref(NULL, &vtxfmt);
nv30->state.dirty |= (1ULL << NV30_STATE_VTXFMT);
so_ref(sattr, &nv30->state.hw[NV30_STATE_VTXATTR]);
+ so_ref(NULL, &sattr);
nv30->state.dirty |= (1ULL << NV30_STATE_VTXATTR);
return FALSE;
}
diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c
index d262725057..eaf543b8f7 100644
--- a/src/gallium/drivers/nv30/nv30_vertprog.c
+++ b/src/gallium/drivers/nv30/nv30_vertprog.c
@@ -685,6 +685,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1);
so_data (so, vp->exec->start);
so_ref(so, &vp->so);
+ so_ref(NULL, &so);
upload_code = TRUE;
}
diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
index 9c8eadf7e4..0ecae2b491 100644
--- a/src/gallium/drivers/nv40/Makefile
+++ b/src/gallium/drivers/nv40/Makefile
@@ -3,7 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nv40
-DRIVER_SOURCES = \
+C_SOURCES = \
nv40_clear.c \
nv40_context.c \
nv40_draw.c \
@@ -22,16 +22,8 @@ DRIVER_SOURCES = \
nv40_state_viewport.c \
nv40_state_zsa.c \
nv40_surface.c \
+ nv40_transfer.c \
nv40_vbo.c \
nv40_vertprog.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
index 91dcbebda0..16e40889ec 100644
--- a/src/gallium/drivers/nv40/nv40_fragprog.c
+++ b/src/gallium/drivers/nv40/nv40_fragprog.c
@@ -917,6 +917,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
struct nv40_fragment_program *fp = nv40->fragprog;
struct pipe_buffer *constbuf =
nv40->constbuf[PIPE_SHADER_FRAGMENT];
+ struct pipe_screen *screen = nv40->pipe.screen;
struct pipe_winsys *ws = nv40->pipe.winsys;
struct nouveau_stateobj *so;
boolean new_consts = FALSE;
@@ -932,7 +933,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
return FALSE;
}
- fp->buffer = ws->buffer_create(ws, 0x100, 0, fp->insn_len * 4);
+ fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4);
nv40_fragprog_upload(nv40, fp);
so = so_new(4, 1);
@@ -943,6 +944,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
so_method(so, nv40->screen->curie, NV40TCL_FP_CONTROL, 1);
so_data (so, fp->fp_control);
so_ref(so, &fp->so);
+ so_ref(NULL, &so);
update_constants:
if (fp->nr_consts) {
diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
index 0227d22620..eb3002dc05 100644
--- a/src/gallium/drivers/nv40/nv40_fragtex.c
+++ b/src/gallium/drivers/nv40/nv40_fragtex.c
@@ -151,6 +151,7 @@ nv40_fragtex_validate(struct nv40_context *nv40)
so = nv40_fragtex_build(nv40, unit);
so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
+ so_ref(NULL, &so);
state->dirty |= (1ULL << (NV40_STATE_FRAGTEX0 + unit));
}
diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c
index e38b1e7f5c..abadca8c93 100644
--- a/src/gallium/drivers/nv40/nv40_miptree.c
+++ b/src/gallium/drivers/nv40/nv40_miptree.c
@@ -67,7 +67,6 @@ nv40_miptree_layout(struct nv40_miptree *mt)
static struct pipe_texture *
nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv40_miptree *mt;
unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
@@ -76,10 +75,8 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
- mt->shadow_tex = NULL;
- mt->shadow_surface = NULL;
/* Swizzled textures must be POT */
if (pt->width[0] & (pt->width[0] - 1) ||
@@ -114,7 +111,7 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
nv40_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, buf_usage, mt->total_size);
+ mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
@@ -139,38 +136,27 @@ nv40_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ 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(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv40_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv40_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv40_miptree *mt = (struct nv40_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ 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);
}
- if (mt->shadow_tex) {
- if (mt->shadow_surface)
- pscreen->tex_surface_release(pscreen, &mt->shadow_surface);
- nv40_miptree_release(pscreen, &mt->shadow_tex);
- }
-
FREE(mt);
}
@@ -180,48 +166,38 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
unsigned flags)
{
struct nv40_miptree *mt = (struct nv40_miptree *)pt;
- struct pipe_surface *ps;
+ struct nv04_surface *ns;
- ps = CALLOC_STRUCT(pipe_surface);
- if (!ps)
+ ns = CALLOC_STRUCT(nv04_surface);
+ if (!ns)
return NULL;
- pipe_texture_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->block = pt->block;
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = mt->level[level].pitch;
- ps->usage = flags;
- ps->status = PIPE_SURFACE_STATUS_DEFINED;
- ps->refcount = 1;
- ps->face = face;
- ps->level = level;
- ps->zslice = zslice;
+ pipe_texture_reference(&ns->base.texture, pt);
+ ns->base.format = pt->format;
+ ns->base.width = pt->width[level];
+ ns->base.height = pt->height[level];
+ ns->base.usage = flags;
+ ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
+ pipe_reference_init(&ns->base.reference, 1);
+ ns->base.face = face;
+ ns->base.level = level;
+ ns->base.zslice = zslice;
+ ns->pitch = mt->level[level].pitch;
if (pt->target == PIPE_TEXTURE_CUBE) {
- ps->offset = mt->level[level].image_offset[face];
+ ns->base.offset = mt->level[level].image_offset[face];
} else
if (pt->target == PIPE_TEXTURE_3D) {
- ps->offset = mt->level[level].image_offset[zslice];
+ ns->base.offset = mt->level[level].image_offset[zslice];
} else {
- ps->offset = mt->level[level].image_offset[0];
+ ns->base.offset = mt->level[level].image_offset[0];
}
- return ps;
+ return &ns->base;
}
static void
-nv40_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv40_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
@@ -231,8 +207,8 @@ nv40_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv40_miptree_create;
pscreen->texture_blanket = nv40_miptree_blanket;
- pscreen->texture_release = nv40_miptree_release;
+ pscreen->texture_destroy = nv40_miptree_destroy;
pscreen->get_tex_surface = nv40_miptree_surface_new;
- pscreen->tex_surface_release = nv40_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv40_miptree_surface_del;
}
diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
index 2372bc8441..0d4baefaea 100644
--- a/src/gallium/drivers/nv40/nv40_screen.c
+++ b/src/gallium/drivers/nv40/nv40_screen.c
@@ -144,81 +144,6 @@ nv40_surface_buffer(struct pipe_surface *surf)
return mt->buffer;
}
-static void *
-nv40_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
- unsigned flags )
-{
- struct pipe_winsys *ws = screen->winsys;
- struct pipe_surface *surface_to_map;
- void *map;
-
- if (!(surface->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
- struct nv40_miptree *mt = (struct nv40_miptree *)surface->texture;
-
- if (!mt->shadow_tex) {
- unsigned old_tex_usage = surface->texture->tex_usage;
- surface->texture->tex_usage = NOUVEAU_TEXTURE_USAGE_LINEAR |
- PIPE_TEXTURE_USAGE_DYNAMIC;
- mt->shadow_tex = screen->texture_create(screen, surface->texture);
- surface->texture->tex_usage = old_tex_usage;
-
- assert(mt->shadow_tex->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR);
- }
-
- mt->shadow_surface = screen->get_tex_surface
- (
- screen, mt->shadow_tex,
- surface->face, surface->level, surface->zslice,
- surface->usage
- );
-
- surface_to_map = mt->shadow_surface;
- }
- else
- surface_to_map = surface;
-
- assert(surface_to_map);
- map = ws->buffer_map(ws, nv40_surface_buffer(surface_to_map), flags);
- if (!map)
- return NULL;
-
- return map + surface_to_map->offset;
-}
-
-static void
-nv40_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
-{
- struct pipe_winsys *ws = screen->winsys;
- struct pipe_surface *surface_to_unmap;
-
- /* TODO: Copy from shadow just before push buffer is flushed instead.
- There are probably some programs that map/unmap excessively
- before rendering. */
- if (!(surface->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
- struct nv40_miptree *mt = (struct nv40_miptree *)surface->texture;
-
- assert(mt->shadow_tex);
-
- surface_to_unmap = mt->shadow_surface;
- }
- else
- surface_to_unmap = surface;
-
- assert(surface_to_unmap);
-
- ws->buffer_unmap(ws, nv40_surface_buffer(surface_to_unmap));
-
- if (surface_to_unmap != surface) {
- struct nv40_screen *nvscreen = nv40_screen(screen);
-
- nvscreen->eng2d->copy(nvscreen->eng2d, surface, 0, 0,
- surface_to_unmap, 0, 0,
- surface->width, surface->height);
-
- screen->tex_surface_release(screen, &surface_to_unmap);
- }
-}
-
static void
nv40_screen_destroy(struct pipe_screen *pscreen)
{
@@ -240,7 +165,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
{
struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen);
struct nouveau_stateobj *so;
- unsigned curie_class;
+ unsigned curie_class = 0;
unsigned chipset = nvws->channel->device->chipset;
int ret;
@@ -265,8 +190,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
if (NV6X_GRCLASS4497_CHIPSETS & (1 << (chipset & 0x0f)))
curie_class = NV44TCL;
break;
- default:
- break;
}
if (!curie_class) {
@@ -372,10 +295,8 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
screen->pipe.is_format_supported = nv40_screen_surface_format_supported;
- screen->pipe.surface_map = nv40_surface_map;
- screen->pipe.surface_unmap = nv40_surface_unmap;
-
nv40_screen_init_miptree_functions(&screen->pipe);
+ nv40_screen_init_transfer_functions(&screen->pipe);
u_simple_screen_init(&screen->pipe);
return &screen->pipe;
diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h
index 4500aa0e5c..7b503bd207 100644
--- a/src/gallium/drivers/nv40/nv40_screen.h
+++ b/src/gallium/drivers/nv40/nv40_screen.h
@@ -34,4 +34,7 @@ nv40_screen(struct pipe_screen *screen)
return (struct nv40_screen *)screen;
}
+void
+nv40_screen_init_transfer_functions(struct pipe_screen *pscreen);
+
#endif
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index 2eff25aa83..c3ee4d2345 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -52,6 +52,7 @@ nv40_blend_state_create(struct pipe_context *pipe,
so_data (so, cso->dither ? 1 : 0);
so_ref(so, &bso->so);
+ so_ref(NULL, &so);
bso->pipe = *cso;
return (void *)bso;
}
@@ -414,6 +415,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
}
so_ref(so, &rsso->so);
+ so_ref(NULL, &so);
rsso->pipe = *cso;
return (void *)rsso;
}
@@ -487,6 +489,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
}
so_ref(so, &zsaso->so);
+ so_ref(NULL, &so);
zsaso->pipe = *cso;
return (void *)zsaso;
}
diff --git a/src/gallium/drivers/nv40/nv40_state.h b/src/gallium/drivers/nv40/nv40_state.h
index 9c55903ae3..8a9d8c8fdf 100644
--- a/src/gallium/drivers/nv40/nv40_state.h
+++ b/src/gallium/drivers/nv40/nv40_state.h
@@ -79,9 +79,6 @@ struct nv40_miptree {
struct pipe_buffer *buffer;
uint total_size;
- struct pipe_texture *shadow_tex;
- struct pipe_surface *shadow_surface;
-
struct {
uint pitch;
uint *image_offset;
diff --git a/src/gallium/drivers/nv40/nv40_state_blend.c b/src/gallium/drivers/nv40/nv40_state_blend.c
index 95e6d7394f..8cd05ce66e 100644
--- a/src/gallium/drivers/nv40/nv40_state_blend.c
+++ b/src/gallium/drivers/nv40/nv40_state_blend.c
@@ -28,6 +28,7 @@ nv40_state_blend_colour_validate(struct nv40_context *nv40)
(float_to_ubyte(bcol->color[2]) << 0)));
so_ref(so, &nv40->state.hw[NV40_STATE_BCOL]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c
index 454abad31f..be618a306b 100644
--- a/src/gallium/drivers/nv40/nv40_state_fb.c
+++ b/src/gallium/drivers/nv40/nv40_state_fb.c
@@ -12,7 +12,7 @@ static boolean
nv40_state_framebuffer_validate(struct nv40_context *nv40)
{
struct pipe_framebuffer_state *fb = &nv40->framebuffer;
- struct pipe_surface *rt[4], *zeta;
+ struct nv04_surface *rt[4], *zeta;
uint32_t rt_enable, rt_format;
int i, colour_format = 0, zeta_format = 0;
struct nouveau_stateobj *so = so_new(64, 10);
@@ -27,7 +27,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
} else {
colour_format = fb->cbufs[i]->format;
rt_enable |= (NV40TCL_RT_ENABLE_COLOR0 << i);
- rt[i] = fb->cbufs[i];
+ rt[i] = (struct nv04_surface *)fb->cbufs[i];
}
}
@@ -37,13 +37,13 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
if (fb->zsbuf) {
zeta_format = fb->zsbuf->format;
- zeta = fb->zsbuf;
+ zeta = (struct nv04_surface *)fb->zsbuf;
}
- if (!(rt[0]->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+ if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
for (i = 1; i < fb->nr_cbufs; i++)
- assert(!(rt[i]->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
+ assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
rt_format = NV40TCL_RT_FORMAT_TYPE_SWIZZLED |
log2i(fb->width) << NV40TCL_RT_FORMAT_LOG2_WIDTH_SHIFT |
@@ -78,60 +78,60 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) {
so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR0, 1);
- so_reloc (so, nv40_surface_buffer(rt[0]), 0, rt_flags | NOUVEAU_BO_OR,
+ so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0, rt_flags | NOUVEAU_BO_OR,
nv40->nvws->channel->vram->handle,
nv40->nvws->channel->gart->handle);
so_method(so, nv40->screen->curie, NV40TCL_COLOR0_PITCH, 2);
- so_data (so, rt[0]->stride);
- so_reloc (so, nv40_surface_buffer(rt[0]), rt[0]->offset, rt_flags |
+ so_data (so, rt[0]->pitch);
+ so_reloc (so, nv40_surface_buffer(&rt[0]->base), rt[0]->base.offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
}
if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) {
so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR1, 1);
- so_reloc (so, nv40_surface_buffer(rt[1]), 0, rt_flags | NOUVEAU_BO_OR,
+ so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0, rt_flags | NOUVEAU_BO_OR,
nv40->nvws->channel->vram->handle,
nv40->nvws->channel->gart->handle);
so_method(so, nv40->screen->curie, NV40TCL_COLOR1_OFFSET, 2);
- so_reloc (so, nv40_surface_buffer(rt[1]), rt[1]->offset, rt_flags |
+ so_reloc (so, nv40_surface_buffer(&rt[1]->base), rt[1]->base.offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
- so_data (so, rt[1]->stride);
+ so_data (so, rt[1]->pitch);
}
if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR2, 1);
- so_reloc (so, nv40_surface_buffer(rt[2]), 0, rt_flags | NOUVEAU_BO_OR,
+ so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0, rt_flags | NOUVEAU_BO_OR,
nv40->nvws->channel->vram->handle,
nv40->nvws->channel->gart->handle);
so_method(so, nv40->screen->curie, NV40TCL_COLOR2_OFFSET, 1);
- so_reloc (so, nv40_surface_buffer(rt[2]), rt[2]->offset, rt_flags |
+ so_reloc (so, nv40_surface_buffer(&rt[2]->base), rt[2]->base.offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
so_method(so, nv40->screen->curie, NV40TCL_COLOR2_PITCH, 1);
- so_data (so, rt[2]->stride);
+ so_data (so, rt[2]->pitch);
}
if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR3, 1);
- so_reloc (so, nv40_surface_buffer(rt[3]), 0, rt_flags | NOUVEAU_BO_OR,
+ so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0, rt_flags | NOUVEAU_BO_OR,
nv40->nvws->channel->vram->handle,
nv40->nvws->channel->gart->handle);
so_method(so, nv40->screen->curie, NV40TCL_COLOR3_OFFSET, 1);
- so_reloc (so, nv40_surface_buffer(rt[3]), rt[3]->offset, rt_flags |
+ so_reloc (so, nv40_surface_buffer(&rt[3]->base), rt[3]->base.offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
so_method(so, nv40->screen->curie, NV40TCL_COLOR3_PITCH, 1);
- so_data (so, rt[3]->stride);
+ so_data (so, rt[3]->pitch);
}
if (zeta_format) {
so_method(so, nv40->screen->curie, NV40TCL_DMA_ZETA, 1);
- so_reloc (so, nv40_surface_buffer(zeta), 0, rt_flags | NOUVEAU_BO_OR,
+ so_reloc (so, nv40_surface_buffer(&zeta->base), 0, rt_flags | NOUVEAU_BO_OR,
nv40->nvws->channel->vram->handle,
nv40->nvws->channel->gart->handle);
so_method(so, nv40->screen->curie, NV40TCL_ZETA_OFFSET, 1);
- so_reloc (so, nv40_surface_buffer(zeta), zeta->offset, rt_flags |
+ so_reloc (so, nv40_surface_buffer(&zeta->base), zeta->base.offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
so_method(so, nv40->screen->curie, NV40TCL_ZETA_PITCH, 1);
- so_data (so, zeta->stride);
+ so_data (so, zeta->pitch);
}
so_method(so, nv40->screen->curie, NV40TCL_RT_ENABLE, 1);
@@ -150,6 +150,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
so_data (so, (1 << 12) | h);
so_ref(so, &nv40->state.hw[NV40_STATE_FB]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv40/nv40_state_scissor.c b/src/gallium/drivers/nv40/nv40_state_scissor.c
index 285239ef41..cf58d33906 100644
--- a/src/gallium/drivers/nv40/nv40_state_scissor.c
+++ b/src/gallium/drivers/nv40/nv40_state_scissor.c
@@ -23,6 +23,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40)
}
so_ref(so, &nv40->state.hw[NV40_STATE_SCISSOR]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv40/nv40_state_viewport.c b/src/gallium/drivers/nv40/nv40_state_viewport.c
index 869a55b405..665d2d5fca 100644
--- a/src/gallium/drivers/nv40/nv40_state_viewport.c
+++ b/src/gallium/drivers/nv40/nv40_state_viewport.c
@@ -7,7 +7,8 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
struct nouveau_stateobj *so;
unsigned bypass;
- if (nv40->render_mode == HW && !nv40->rasterizer->pipe.bypass_clipping)
+ if (nv40->render_mode == HW &&
+ !nv40->rasterizer->pipe.bypass_vs_clip_and_viewport)
bypass = 0;
else
bypass = 1;
@@ -55,6 +56,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
}
so_ref(so, &nv40->state.hw[NV40_STATE_VIEWPORT]);
+ so_ref(NULL, &so);
return TRUE;
}
diff --git a/src/gallium/drivers/nv40/nv40_surface.c b/src/gallium/drivers/nv40/nv40_surface.c
index c4a5fb20d9..1a849da32d 100644
--- a/src/gallium/drivers/nv40/nv40_surface.c
+++ b/src/gallium/drivers/nv40/nv40_surface.c
@@ -33,7 +33,7 @@
#include "util/u_tile.h"
static void
-nv40_surface_copy(struct pipe_context *pipe, boolean do_flip,
+nv40_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)
@@ -41,15 +41,6 @@ nv40_surface_copy(struct pipe_context *pipe, boolean do_flip,
struct nv40_context *nv40 = nv40_context(pipe);
struct nv04_surface_2d *eng2d = nv40->screen->eng2d;
- if (do_flip) {
- desty += height;
- while (height--) {
- eng2d->copy(eng2d, dest, destx, desty--, src,
- srcx, srcy++, width, 1);
- }
- return;
- }
-
eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
}
diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c
new file mode 100644
index 0000000000..728e8b5674
--- /dev/null
+++ b/src/gallium/drivers/nv40/nv40_transfer.c
@@ -0,0 +1,196 @@
+#include <pipe/p_state.h>
+#include <pipe/p_defines.h>
+#include <pipe/p_inlines.h>
+#include <util/u_memory.h>
+#include <nouveau/nouveau_winsys.h>
+#include "nv40_context.h"
+#include "nv40_screen.h"
+#include "nv40_state.h"
+
+struct nv40_transfer {
+ struct pipe_transfer base;
+ struct pipe_surface *surface;
+ bool direct;
+};
+
+static unsigned nv40_usage_tx_to_buf(unsigned tx_usage)
+{
+ switch (tx_usage) {
+ case PIPE_TRANSFER_READ:
+ return PIPE_BUFFER_USAGE_CPU_READ;
+ case PIPE_TRANSFER_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_WRITE;
+ case PIPE_TRANSFER_READ_WRITE:
+ return PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static void
+nv40_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
+ struct pipe_texture *template)
+{
+ memset(template, 0, sizeof(struct pipe_texture));
+ template->target = pt->target;
+ template->format = pt->format;
+ template->width[0] = pt->width[level];
+ template->height[0] = pt->height[level];
+ template->depth[0] = 1;
+ template->block = pt->block;
+ template->nblocksx[0] = pt->nblocksx[level];
+ template->nblocksy[0] = pt->nblocksx[level];
+ template->last_level = 0;
+ template->compressed = pt->compressed;
+ template->nr_samples = pt->nr_samples;
+
+ template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
+ NOUVEAU_TEXTURE_USAGE_LINEAR;
+}
+
+static struct pipe_transfer *
+nv40_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 nv40_miptree *mt = (struct nv40_miptree *)pt;
+ struct nv40_transfer *tx;
+ struct pipe_texture tx_tex_template, *tx_tex;
+
+ tx = CALLOC_STRUCT(nv40_transfer);
+ if (!tx)
+ return NULL;
+
+ pipe_texture_reference(&tx->base.texture, pt);
+ tx->base.format = pt->format;
+ tx->base.x = x;
+ tx->base.y = y;
+ tx->base.width = w;
+ tx->base.height = h;
+ tx->base.block = pt->block;
+ tx->base.nblocksx = pt->nblocksx[level];
+ tx->base.nblocksy = pt->nblocksy[level];
+ tx->base.stride = mt->level[level].pitch;
+ tx->base.usage = usage;
+ tx->base.face = face;
+ 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,
+ face, level, zslice,
+ nv40_usage_tx_to_buf(usage));
+ return &tx->base;
+ }
+
+ tx->direct = false;
+
+ nv40_compatible_transfer_tex(pt, level, &tx_tex_template);
+
+ tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
+ if (!tx_tex)
+ {
+ FREE(tx);
+ return NULL;
+ }
+
+ tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
+ 0, 0, 0,
+ nv40_usage_tx_to_buf(usage));
+
+ pipe_texture_reference(&tx_tex, NULL);
+
+ if (!tx->surface)
+ {
+ pipe_surface_reference(&tx->surface, NULL);
+ FREE(tx);
+ return NULL;
+ }
+
+ if (usage != PIPE_TRANSFER_WRITE) {
+ struct nv40_screen *nvscreen = nv40_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, 0, 0,
+ src->width, src->height);
+
+ pipe_surface_reference(&src, NULL);
+ }
+
+ return &tx->base;
+}
+
+static void
+nv40_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+{
+ struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
+
+ if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
+ struct nv40_screen *nvscreen = nv40_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, 0, 0,
+ tx->surface, 0, 0,
+ dst->width, dst->height);
+
+ pipe_surface_reference(&dst, NULL);
+ }
+
+ pipe_surface_reference(&tx->surface, NULL);
+ pipe_texture_reference(&ptx->texture, NULL);
+ FREE(ptx);
+}
+
+static void *
+nv40_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+{
+ struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
+ struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
+ struct nv40_miptree *mt = (struct nv40_miptree *)tx->surface->texture;
+ void *map = pipe_buffer_map(pscreen, mt->buffer,
+ nv40_usage_tx_to_buf(ptx->usage));
+
+ return map + ns->base.offset +
+ ptx->y * ns->pitch + ptx->x * ptx->block.size;
+}
+
+static void
+nv40_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+{
+ struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
+ struct nv40_miptree *mt = (struct nv40_miptree *)tx->surface->texture;
+
+ pipe_buffer_unmap(pscreen, mt->buffer);
+}
+
+void
+nv40_screen_init_transfer_functions(struct pipe_screen *pscreen)
+{
+ pscreen->get_tex_transfer = nv40_transfer_new;
+ pscreen->tex_transfer_destroy = nv40_transfer_del;
+ pscreen->transfer_map = nv40_transfer_map;
+ pscreen->transfer_unmap = nv40_transfer_unmap;
+}
diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
index 8f1834628f..f3518b2e4f 100644
--- a/src/gallium/drivers/nv40/nv40_vbo.c
+++ b/src/gallium/drivers/nv40/nv40_vbo.c
@@ -537,10 +537,13 @@ nv40_vbo_validate(struct nv40_context *nv40)
so_data (vtxbuf, 0);
so_ref(vtxbuf, &nv40->state.hw[NV40_STATE_VTXBUF]);
+ so_ref(NULL, &vtxbuf);
nv40->state.dirty |= (1ULL << NV40_STATE_VTXBUF);
so_ref(vtxfmt, &nv40->state.hw[NV40_STATE_VTXFMT]);
+ so_ref(NULL, &vtxfmt);
nv40->state.dirty |= (1ULL << NV40_STATE_VTXFMT);
so_ref(sattr, &nv40->state.hw[NV40_STATE_VTXATTR]);
+ so_ref(NULL, &sattr);
nv40->state.dirty |= (1ULL << NV40_STATE_VTXATTR);
return FALSE;
}
diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c
index 0862386638..7df9a4d326 100644
--- a/src/gallium/drivers/nv40/nv40_vertprog.c
+++ b/src/gallium/drivers/nv40/nv40_vertprog.c
@@ -916,6 +916,7 @@ check_gpu_resources:
so_method(so, curie, NV40TCL_CLIP_PLANE_ENABLE, 1);
so_data (so, vp->clip_ctrl);
so_ref(so, &vp->so);
+ so_ref(NULL, &so);
upload_code = TRUE;
}
diff --git a/src/gallium/drivers/nv50/Makefile b/src/gallium/drivers/nv50/Makefile
index be30400c03..612aea28a3 100644
--- a/src/gallium/drivers/nv50/Makefile
+++ b/src/gallium/drivers/nv50/Makefile
@@ -3,7 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nv50
-DRIVER_SOURCES = \
+C_SOURCES = \
nv50_clear.c \
nv50_context.c \
nv50_draw.c \
@@ -15,15 +15,7 @@ DRIVER_SOURCES = \
nv50_state_validate.c \
nv50_surface.c \
nv50_tex.c \
+ nv50_transfer.c \
nv50_vbo.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index 1e9d45cb34..313e435e7a 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -64,10 +64,8 @@ struct nv50_rasterizer_stateobj {
};
struct nv50_miptree_level {
- struct pipe_buffer **image;
int *image_offset;
- unsigned image_dirty_cpu[512/32];
- unsigned image_dirty_gpu[512/32];
+ unsigned pitch;
};
struct nv50_miptree {
@@ -200,8 +198,4 @@ extern boolean nv50_state_validate(struct nv50_context *nv50);
/* nv50_tex.c */
extern void nv50_tex_validate(struct nv50_context *);
-/* nv50_miptree.c */
-extern void nv50_miptree_sync(struct pipe_screen *, struct nv50_miptree *,
- unsigned level, unsigned image);
-
#endif
diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c
index 91091d53f5..dc4688ccdc 100644
--- a/src/gallium/drivers/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nv50/nv50_miptree.c
@@ -29,7 +29,6 @@
static struct pipe_texture *
nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
struct pipe_texture *pt = &mt->base;
unsigned usage, width = tmp->width[0], height = tmp->height[0];
@@ -37,7 +36,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
int i, l;
mt->base = *tmp;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
usage = PIPE_BUFFER_USAGE_PIXEL;
@@ -72,7 +71,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
lvl->image_offset = CALLOC(mt->image_nr, sizeof(int));
- lvl->image = CALLOC(mt->image_nr, sizeof(struct pipe_buffer *));
+ lvl->pitch = align(pt->width[l] * pt->block.size, 64);
width = MAX2(1, width >> 1);
height = MAX2(1, height >> 1);
@@ -88,14 +87,13 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
size = align(size, 64);
size *= align(pt->height[l], 8) * pt->block.size;
- lvl->image[i] = ws->buffer_create(ws, 256, 0, size);
lvl->image_offset[i] = mt->total_size;
mt->total_size += size;
}
}
- mt->buffer = ws->buffer_create(ws, 256, usage, mt->total_size);
+ mt->buffer = pscreen->buffer_create(pscreen, 256, usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
@@ -120,119 +118,23 @@ nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->image_nr = 1;
+ mt->level[0].pitch = *stride;
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
-static INLINE void
-mark_dirty(uint32_t *flags, unsigned image)
-{
- flags[image / 32] |= (1 << (image % 32));
-}
-
-static INLINE void
-mark_clean(uint32_t *flags, unsigned image)
-{
- flags[image / 32] &= ~(1 << (image % 32));
-}
-
-static INLINE int
-is_dirty(uint32_t *flags, unsigned image)
-{
- return !!(flags[image / 32] & (1 << (image % 32)));
-}
-
static void
-nv50_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
-{
- struct pipe_texture *pt = *ppt;
-
- *ppt = NULL;
-
- if (--pt->refcount <= 0) {
- struct nv50_miptree *mt = nv50_miptree(pt);
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
- FREE(mt);
- }
-}
-
-void
-nv50_miptree_sync(struct pipe_screen *pscreen, struct nv50_miptree *mt,
- unsigned level, unsigned image)
+nv50_miptree_destroy(struct pipe_texture *pt)
{
- struct nv50_screen *nvscreen = nv50_screen(pscreen);
- struct nv50_miptree_level *lvl = &mt->level[level];
- struct pipe_surface *dst, *src;
- unsigned face = 0, zslice = 0;
-
- if (!is_dirty(lvl->image_dirty_cpu, image))
- return;
-
- if (mt->base.target == PIPE_TEXTURE_CUBE)
- face = image;
- else
- if (mt->base.target == PIPE_TEXTURE_3D)
- zslice = image;
-
- /* Mark as clean already - so we don't continually call this function
- * trying to get a GPU_WRITE pipe_surface!
- */
- mark_clean(lvl->image_dirty_cpu, image);
-
- /* Pretend we're doing CPU access so we get the backing pipe_surface
- * and not a view into the larger miptree.
- */
- src = pscreen->get_tex_surface(pscreen, &mt->base, face, level, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
-
- /* Pretend we're only reading with the GPU so surface doesn't get marked
- * as dirtied by the GPU.
- */
- dst = pscreen->get_tex_surface(pscreen, &mt->base, face, level, zslice,
- PIPE_BUFFER_USAGE_GPU_READ);
-
- nv50_surface_do_copy(nvscreen, dst, 0, 0, src, 0, 0, dst->width, dst->height);
-
- pscreen->tex_surface_release(pscreen, &dst);
- pscreen->tex_surface_release(pscreen, &src);
-}
-
-/* The reverse of the above */
-static void
-nv50_miptree_sync_cpu(struct pipe_screen *pscreen, struct nv50_miptree *mt,
- unsigned level, unsigned image)
-{
- struct nv50_screen *nvscreen = nv50_screen(pscreen);
- struct nv50_miptree_level *lvl = &mt->level[level];
- struct pipe_surface *dst, *src;
- unsigned face = 0, zslice = 0;
-
- if (!is_dirty(lvl->image_dirty_gpu, image))
- return;
-
- if (mt->base.target == PIPE_TEXTURE_CUBE)
- face = image;
- else
- if (mt->base.target == PIPE_TEXTURE_3D)
- zslice = image;
-
- mark_clean(lvl->image_dirty_gpu, image);
-
- src = pscreen->get_tex_surface(pscreen, &mt->base, face, level, zslice,
- PIPE_BUFFER_USAGE_GPU_READ);
- dst = pscreen->get_tex_surface(pscreen, &mt->base, face, level, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
-
- nv50_surface_do_copy(nvscreen, dst, 0, 0, src, 0, 0, dst->width, dst->height);
+ struct nv50_miptree *mt = nv50_miptree(pt);
- pscreen->tex_surface_release(pscreen, &dst);
- pscreen->tex_surface_release(pscreen, &src);
+ pipe_buffer_reference(&mt->buffer, NULL);
+ FREE(mt);
}
static struct pipe_surface *
@@ -260,52 +162,24 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ps->format = pt->format;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->block = pt->block;
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = ps->width * ps->block.size;
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
ps->face = face;
ps->level = level;
ps->zslice = zslice;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) {
- assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
- nv50_miptree_sync_cpu(pscreen, mt, level, img);
-
- ps->offset = 0;
- pipe_texture_reference(&ps->texture, pt);
-
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
- mark_dirty(lvl->image_dirty_cpu, img);
- } else {
- nv50_miptree_sync(pscreen, mt, level, img);
-
- ps->offset = lvl->image_offset[img];
- pipe_texture_reference(&ps->texture, pt);
-
- if (flags & PIPE_BUFFER_USAGE_GPU_WRITE)
- mark_dirty(lvl->image_dirty_gpu, img);
- }
+ ps->offset = lvl->image_offset[img];
return ps;
}
static void
-nv50_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv50_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
struct nv50_surface *s = nv50_surface(ps);
- *psurface = NULL;
-
- if (--ps->refcount <= 0) {
- pipe_texture_reference(&ps->texture, NULL);
- FREE(s);
- }
+ pipe_texture_reference(&ps->texture, NULL);
+ FREE(s);
}
void
@@ -313,8 +187,8 @@ nv50_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv50_miptree_create;
pscreen->texture_blanket = nv50_miptree_blanket;
- pscreen->texture_release = nv50_miptree_release;
+ pscreen->texture_destroy = nv50_miptree_destroy;
pscreen->get_tex_surface = nv50_miptree_surface_new;
- pscreen->tex_surface_release = nv50_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv50_miptree_surface_del;
}
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index 14c5d47e79..2d15868ae8 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -1603,7 +1603,7 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
{
struct nouveau_channel *chan = nv50->screen->nvws->channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
- struct pipe_winsys *ws = nv50->pipe.winsys;
+ struct pipe_screen *screen = nv50->pipe.screen;
struct nv50_program_exec *e;
struct nouveau_stateobj *so;
const unsigned flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR;
@@ -1611,7 +1611,7 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
boolean upload = FALSE;
if (!p->buffer) {
- p->buffer = ws->buffer_create(ws, 0x100, 0, p->exec_size * 4);
+ p->buffer = screen->buffer_create(screen, 0x100, 0, p->exec_size * 4);
upload = TRUE;
}
@@ -1719,6 +1719,7 @@ nv50_vertprog_validate(struct nv50_context *nv50)
so_method(so, tesla, 0x140c, 1);
so_data (so, 0); /* program start offset */
so_ref(so, &nv50->state.vertprog);
+ so_ref(NULL, &so);
}
void
@@ -1758,6 +1759,7 @@ nv50_fragprog_validate(struct nv50_context *nv50)
so_method(so, tesla, 0x1414, 1);
so_data (so, 0); /* program start offset */
so_ref(so, &nv50->state.fragprog);
+ so_ref(NULL, &so);
}
void
@@ -1775,7 +1777,7 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
p->exec_size = 0;
if (p->buffer)
- pipe_buffer_reference(pscreen, &p->buffer, NULL);
+ pipe_buffer_reference(&p->buffer, NULL);
nv50->screen->nvws->res_free(&p->data);
diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c
index 20745ceab8..a2c56f99a8 100644
--- a/src/gallium/drivers/nv50/nv50_query.c
+++ b/src/gallium/drivers/nv50/nv50_query.c
@@ -41,13 +41,13 @@ nv50_query(struct pipe_query *pipe)
static struct pipe_query *
nv50_query_create(struct pipe_context *pipe, unsigned type)
{
- struct pipe_winsys *ws = pipe->winsys;
+ struct pipe_screen *screen = pipe->winsys;
struct nv50_query *q = CALLOC_STRUCT(nv50_query);
assert (q->type == PIPE_QUERY_OCCLUSION_COUNTER);
q->type = type;
- q->buffer = ws->buffer_create(ws, 256, 0, 16);
+ q->buffer = screen->buffer_create(screen, 256, 0, 16);
if (!q->buffer) {
FREE(q);
return NULL;
@@ -62,7 +62,7 @@ nv50_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
struct nv50_query *q = nv50_query(pq);
if (q) {
- pipe_buffer_reference(pipe->screen, &q->buffer, NULL);
+ pipe_buffer_reference(&q->buffer, NULL);
FREE(q);
}
}
@@ -90,11 +90,12 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq)
struct nouveau_channel *chan = nv50->screen->nvws->channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct nv50_query *q = nv50_query(pq);
+ struct nouveau_bo *bo = nv50->screen->nvws->get_bo(q->buffer);
WAIT_RING (chan, 5);
BEGIN_RING(chan, tesla, 0x1b00, 4);
- OUT_RELOCh(chan, q->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
- OUT_RELOCl(chan, q->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+ OUT_RELOCh(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+ OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
OUT_RING (chan, 0x00000000);
OUT_RING (chan, 0x0100f002);
FIRE_RING (chan);
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 58d7a621a8..2980564594 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -29,10 +29,6 @@
#include "nouveau/nouveau_stateobj.h"
-#define NV5X_GRCLASS5097_CHIPSETS 0x00000001
-#define NV8X_GRCLASS8297_CHIPSETS 0x00000050
-#define NV9X_GRCLASS8297_CHIPSETS 0x00000014
-
static boolean
nv50_screen_is_format_supported(struct pipe_screen *pscreen,
enum pipe_format format,
@@ -124,9 +120,9 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param)
return 1;
case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
return 0;
- case NOUVEAU_CAP_HW_VTXBUF:
+ case NOUVEAU_CAP_HW_VTXBUF:
return 1;
- case NOUVEAU_CAP_HW_IDXBUF:
+ case NOUVEAU_CAP_HW_IDXBUF:
return 0;
default:
NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
@@ -173,36 +169,38 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
return NULL;
screen->nvws = nvws;
- /* 2D object */
- ret = nvws->grobj_alloc(nvws, NV50_2D, &screen->eng2d);
+ /* DMA engine object */
+ ret = nvws->grobj_alloc(nvws, 0x5039, &screen->m2mf);
if (ret) {
- NOUVEAU_ERR("Error creating 2D object: %d\n", ret);
+ NOUVEAU_ERR("Error creating M2MF object: %d\n", ret);
nv50_screen_destroy(&screen->pipe);
return NULL;
}
- /* 3D object */
- if ((chipset & 0xf0) != 0x50 && (chipset & 0xf0) != 0x80) {
- NOUVEAU_ERR("Not a G8x chipset\n");
+ /* 2D object */
+ ret = nvws->grobj_alloc(nvws, NV50_2D, &screen->eng2d);
+ if (ret) {
+ NOUVEAU_ERR("Error creating 2D object: %d\n", ret);
nv50_screen_destroy(&screen->pipe);
return NULL;
}
+ /* 3D object */
switch (chipset & 0xf0) {
case 0x50:
- if (NV5X_GRCLASS5097_CHIPSETS & (1 << (chipset & 0x0f)))
- tesla_class = 0x5097;
+ tesla_class = 0x5097;
break;
case 0x80:
- if (NV8X_GRCLASS8297_CHIPSETS & (1 << (chipset & 0x0f)))
- tesla_class = 0x8297;
- break;
case 0x90:
- if (NV9X_GRCLASS8297_CHIPSETS & (1 << (chipset & 0x0f)))
- tesla_class = 0x8297;
+ tesla_class = 0x8297;
break;
- default:
+ case 0xa0:
+ tesla_class = 0x8397;
break;
+ default:
+ NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset);
+ nv50_screen_destroy(&screen->pipe);
+ return NULL;
}
if (tesla_class == 0) {
@@ -226,6 +224,31 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
return NULL;
}
+ /* Setup the pipe */
+ screen->pipe.winsys = ws;
+
+ screen->pipe.destroy = nv50_screen_destroy;
+
+ screen->pipe.get_name = nv50_screen_get_name;
+ screen->pipe.get_vendor = nv50_screen_get_vendor;
+ screen->pipe.get_param = nv50_screen_get_param;
+ screen->pipe.get_paramf = nv50_screen_get_paramf;
+
+ screen->pipe.is_format_supported = nv50_screen_is_format_supported;
+
+ nv50_screen_init_miptree_functions(&screen->pipe);
+ nv50_transfer_init_screen_functions(&screen->pipe);
+ u_simple_screen_init(&screen->pipe);
+
+ /* Static M2MF init */
+ so = so_new(32, 0);
+ so_method(so, screen->m2mf, 0x0180, 3);
+ so_data (so, screen->sync->handle);
+ so_data (so, screen->nvws->channel->vram->handle);
+ so_data (so, screen->nvws->channel->vram->handle);
+ so_emit(nvws, so);
+ so_ref (NULL, &so);
+
/* Static 2D init */
so = so_new(64, 0);
so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4);
@@ -268,7 +291,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
so_data (so, 8);
/* Shared constant buffer */
- screen->constbuf = ws->buffer_create(ws, 0, 0, 128 * 4 * 4);
+ screen->constbuf = screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4);
if (nvws->res_init(&screen->vp_data_heap, 0, 128)) {
NOUVEAU_ERR("Error initialising constant buffer\n");
nv50_screen_destroy(&screen->pipe);
@@ -287,7 +310,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
* blocks. At some point we *may* want to go the NVIDIA way of doing
* things?
*/
- screen->tic = ws->buffer_create(ws, 0, 0, 32 * 8 * 4);
+ screen->tic = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4);
so_method(so, screen->tesla, 0x1280, 3);
so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
@@ -301,7 +324,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
so_data (so, 0x00000800);
- screen->tsc = ws->buffer_create(ws, 0, 0, 32 * 8 * 4);
+ screen->tsc = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4);
so_method(so, screen->tesla, 0x1280, 3);
so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
@@ -333,24 +356,10 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
so_data (so, 1);
so_emit(nvws, so);
- so_ref(so, &screen->static_init);
+ so_ref (so, &screen->static_init);
+ so_ref (NULL, &so);
nvws->push_flush(nvws, 0, NULL);
- screen->pipe.winsys = ws;
-
- screen->pipe.destroy = nv50_screen_destroy;
-
- screen->pipe.get_name = nv50_screen_get_name;
- screen->pipe.get_vendor = nv50_screen_get_vendor;
- screen->pipe.get_param = nv50_screen_get_param;
- screen->pipe.get_paramf = nv50_screen_get_paramf;
-
- screen->pipe.is_format_supported = nv50_screen_is_format_supported;
-
- nv50_screen_init_miptree_functions(&screen->pipe);
- nv50_surface_init_screen_functions(&screen->pipe);
- u_simple_screen_init(&screen->pipe);
-
return &screen->pipe;
}
diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h
index c888ca071c..db567aaac8 100644
--- a/src/gallium/drivers/nv50/nv50_screen.h
+++ b/src/gallium/drivers/nv50/nv50_screen.h
@@ -12,6 +12,7 @@ struct nv50_screen {
struct nouveau_grobj *tesla;
struct nouveau_grobj *eng2d;
+ struct nouveau_grobj *m2mf;
struct nouveau_notifier *sync;
struct pipe_buffer *constbuf;
@@ -29,6 +30,6 @@ nv50_screen(struct pipe_screen *screen)
return (struct nv50_screen *)screen;
}
-void nv50_surface_init_screen_functions(struct pipe_screen *);
+void nv50_transfer_init_screen_functions(struct pipe_screen *);
#endif
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index 787ff958ec..ba852194cd 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -85,6 +85,7 @@ nv50_blend_state_create(struct pipe_context *pipe,
bso->pipe = *cso;
so_ref(so, &bso->so);
+ so_ref(NULL, &so);
return (void *)bso;
}
@@ -352,6 +353,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
rso->pipe = *cso;
so_ref(so, &rso->so);
+ so_ref(NULL, &so);
return (void *)rso;
}
@@ -438,6 +440,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
zsa->pipe = *cso;
so_ref(so, &zsa->so);
+ so_ref(NULL, &so);
return (void *)zsa;
}
diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c
index 948112ffa9..85098a78a2 100644
--- a/src/gallium/drivers/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nv50/nv50_state_validate.c
@@ -124,6 +124,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
so_data (so, h);
so_ref(so, &nv50->state.fb);
+ so_ref(NULL, &so);
}
static void
@@ -214,6 +215,7 @@ nv50_state_validate(struct nv50_context *nv50)
so_data (so, fui(nv50->blend_colour.color[2]));
so_data (so, fui(nv50->blend_colour.color[3]));
so_ref(so, &nv50->state.blend_colour);
+ so_ref(NULL, &so);
}
if (nv50->dirty & NV50_NEW_STIPPLE) {
@@ -222,6 +224,7 @@ nv50_state_validate(struct nv50_context *nv50)
for (i = 0; i < 32; i++)
so_data(so, nv50->stipple.stipple[i]);
so_ref(so, &nv50->state.stipple);
+ so_ref(NULL, &so);
}
if (nv50->dirty & (NV50_NEW_SCISSOR | NV50_NEW_RASTERIZER)) {
@@ -243,6 +246,7 @@ nv50_state_validate(struct nv50_context *nv50)
so_data(so, (8192 << 16));
}
so_ref(so, &nv50->state.scissor);
+ so_ref(NULL, &so);
nv50->state.dirty |= NV50_NEW_SCISSOR;
}
scissor_uptodate:
@@ -250,7 +254,7 @@ scissor_uptodate:
if (nv50->dirty & NV50_NEW_VIEWPORT) {
unsigned bypass;
- if (!nv50->rasterizer->pipe.bypass_clipping)
+ if (!nv50->rasterizer->pipe.bypass_vs_clip_and_viewport)
bypass = 0;
else
bypass = 1;
@@ -283,6 +287,7 @@ scissor_uptodate:
}
so_ref(so, &nv50->state.viewport);
+ so_ref(NULL, &so);
}
viewport_uptodate:
@@ -296,6 +301,7 @@ viewport_uptodate:
for (i = 0; i < nv50->sampler_nr; i++)
so_datap (so, nv50->sampler[i], 8);
so_ref(so, &nv50->state.tsc_upload);
+ so_ref(NULL, &so);
}
if (nv50->dirty & NV50_NEW_TEXTURE)
diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c
index f2dd2eb30b..0cc5168144 100644
--- a/src/gallium/drivers/nv50/nv50_surface.c
+++ b/src/gallium/drivers/nv50/nv50_surface.c
@@ -51,6 +51,7 @@ nv50_format(enum pipe_format format)
static int
nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
{
+ struct nv50_miptree *mt = nv50_miptree(ps->texture);
struct nouveau_channel *chan = screen->nvws->channel;
struct nouveau_grobj *eng2d = screen->eng2d;
struct nouveau_bo *bo;
@@ -70,7 +71,7 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst)
OUT_RING (chan, format);
OUT_RING (chan, 1);
BEGIN_RING(chan, eng2d, mthd + 0x14, 5);
- OUT_RING (chan, ps->stride);
+ OUT_RING (chan, mt->level[0].pitch);
OUT_RING (chan, ps->width);
OUT_RING (chan, ps->height);
OUT_RELOCh(chan, bo, ps->offset, flags);
@@ -143,7 +144,7 @@ nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst,
}
static void
-nv50_surface_copy(struct pipe_context *pipe, boolean flip,
+nv50_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)
@@ -153,16 +154,8 @@ nv50_surface_copy(struct pipe_context *pipe, boolean flip,
assert(src->format == dest->format);
- if (flip) {
- desty += height;
- while (height--) {
- nv50_surface_do_copy(screen, dest, destx, desty--, src,
- srcx, srcy++, width, 1);
- }
- } else {
- nv50_surface_do_copy(screen, dest, destx, desty, src, srcx,
+ nv50_surface_do_copy(screen, dest, destx, desty, src, srcx,
srcy, width, height);
- }
}
static void
@@ -197,23 +190,6 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
OUT_RING (chan, height);
}
-static void *
-nv50_surface_map(struct pipe_screen *screen, struct pipe_surface *ps,
- unsigned flags )
-{
- struct pipe_winsys *ws = screen->winsys;
-
- return ws->buffer_map(ws, nv50_surface_buffer(ps), flags);
-}
-
-static void
-nv50_surface_unmap(struct pipe_screen *pscreen, struct pipe_surface *ps)
-{
- struct pipe_winsys *ws = pscreen->winsys;
-
- ws->buffer_unmap(ws, nv50_surface_buffer(ps));
-}
-
void
nv50_init_surface_functions(struct nv50_context *nv50)
{
@@ -221,10 +197,4 @@ nv50_init_surface_functions(struct nv50_context *nv50)
nv50->pipe.surface_fill = nv50_surface_fill;
}
-void
-nv50_surface_init_screen_functions(struct pipe_screen *pscreen)
-{
- pscreen->surface_map = nv50_surface_map;
- pscreen->surface_unmap = nv50_surface_unmap;
-}
diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c
index 675f9b20cb..223c8a3a45 100644
--- a/src/gallium/drivers/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nv50/nv50_tex.c
@@ -135,7 +135,7 @@ nv50_tex_validate(struct nv50_context *nv50)
{
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct nouveau_stateobj *so;
- int unit, level, image;
+ int unit;
so = so_new(nv50->miptree_nr * 8 + 3, nv50->miptree_nr * 2);
so_method(so, tesla, 0x0f00, 1);
@@ -144,13 +144,6 @@ nv50_tex_validate(struct nv50_context *nv50)
for (unit = 0; unit < nv50->miptree_nr; unit++) {
struct nv50_miptree *mt = nv50->miptree[unit];
- for (level = 0; level <= mt->base.last_level; level++) {
- for (image = 0; image < mt->image_nr; image++) {
- nv50_miptree_sync(&nv50->screen->pipe, mt,
- level, image);
- }
- }
-
if (nv50_tex_construct(so, mt)) {
NOUVEAU_ERR("failed tex validate\n");
so_ref(NULL, &so);
@@ -159,5 +152,6 @@ nv50_tex_validate(struct nv50_context *nv50)
}
so_ref(so, &nv50->state.tic_upload);
+ so_ref(NULL, &so);
}
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
new file mode 100644
index 0000000000..747195b4f6
--- /dev/null
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -0,0 +1,211 @@
+
+#include "pipe/p_context.h"
+#include "pipe/p_inlines.h"
+
+#include "nv50_context.h"
+
+struct nv50_transfer {
+ struct pipe_transfer base;
+ struct pipe_buffer *buffer;
+ struct nv50_miptree_level *level;
+ int level_pitch;
+ int level_width;
+ int level_height;
+ int level_x;
+ int level_y;
+};
+
+static void
+nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src,
+ int src_pitch, int sx, int sy, int sw, int sh,
+ struct pipe_buffer *dst, int dst_pitch, int dx, int dy,
+ int dw, int dh, int cpp, int width, int height,
+ unsigned src_reloc, unsigned dst_reloc)
+{
+ struct nv50_screen *screen = nv50_screen(pscreen);
+ struct nouveau_winsys *nvws = screen->nvws;
+ struct nouveau_channel *chan = nvws->channel;
+ struct nouveau_grobj *m2mf = screen->m2mf;
+ struct nouveau_bo *src_bo = nvws->get_bo(src);
+ struct nouveau_bo *dst_bo = nvws->get_bo(dst);
+ unsigned src_offset = 0, dst_offset = 0;
+
+ src_reloc |= NOUVEAU_BO_RD;
+ dst_reloc |= NOUVEAU_BO_WR;
+
+ WAIT_RING (chan, 14);
+
+ if (!src_bo->tiled) {
+ BEGIN_RING(chan, m2mf, 0x0200, 1);
+ OUT_RING (chan, 1);
+ BEGIN_RING(chan, m2mf, 0x0314, 1);
+ OUT_RING (chan, src_pitch);
+ src_offset = (sy * src_pitch) + (sx * cpp);
+ } else {
+ BEGIN_RING(chan, m2mf, 0x0200, 6);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, sw * cpp);
+ OUT_RING (chan, sh);
+ OUT_RING (chan, 1);
+ OUT_RING (chan, 0);
+ }
+
+ if (!dst_bo->tiled) {
+ BEGIN_RING(chan, m2mf, 0x021c, 1);
+ OUT_RING (chan, 1);
+ BEGIN_RING(chan, m2mf, 0x0318, 1);
+ OUT_RING (chan, dst_pitch);
+ dst_offset = (dy * dst_pitch) + (dx * cpp);
+ } else {
+ BEGIN_RING(chan, m2mf, 0x021c, 6);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, 0);
+ OUT_RING (chan, dw * cpp);
+ OUT_RING (chan, dh);
+ OUT_RING (chan, 1);
+ OUT_RING (chan, 0);
+ }
+
+ while (height) {
+ int line_count = height > 2047 ? 2047 : height;
+
+ WAIT_RING (chan, 15);
+ BEGIN_RING(chan, m2mf, 0x0238, 2);
+ OUT_RELOCh(chan, src_bo, src_offset, src_reloc);
+ OUT_RELOCh(chan, dst_bo, dst_offset, dst_reloc);
+ BEGIN_RING(chan, m2mf, 0x030c, 2);
+ OUT_RELOCl(chan, src_bo, src_offset, src_reloc);
+ OUT_RELOCl(chan, dst_bo, dst_offset, dst_reloc);
+ if (src_bo->tiled) {
+ BEGIN_RING(chan, m2mf, 0x0218, 1);
+ OUT_RING (chan, (dy << 16) | sx);
+ } else {
+ src_offset += (line_count * src_pitch);
+ }
+ if (dst_bo->tiled) {
+ BEGIN_RING(chan, m2mf, 0x0234, 1);
+ OUT_RING (chan, (sy << 16) | dx);
+ } else {
+ dst_offset += (line_count * dst_pitch);
+ }
+ BEGIN_RING(chan, m2mf, 0x031c, 4);
+ OUT_RING (chan, width * cpp);
+ OUT_RING (chan, line_count);
+ OUT_RING (chan, 0x00000101);
+ OUT_RING (chan, 0);
+ FIRE_RING (chan);
+
+ height -= line_count;
+ sy += line_count;
+ dy += line_count;
+ }
+}
+
+static struct pipe_transfer *
+nv50_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 nv50_miptree *mt = nv50_miptree(pt);
+ struct nv50_miptree_level *lvl = &mt->level[level];
+ struct nv50_transfer *tx;
+ unsigned image = 0;
+
+ if (pt->target == PIPE_TEXTURE_CUBE)
+ image = face;
+ else
+ if (pt->target == PIPE_TEXTURE_3D)
+ image = zslice;
+
+ tx = CALLOC_STRUCT(nv50_transfer);
+ if (!tx)
+ return NULL;
+
+ pipe_texture_reference(&tx->base.texture, pt);
+ tx->base.format = pt->format;
+ tx->base.width = w;
+ tx->base.height = h;
+ tx->base.block = pt->block;
+ tx->base.nblocksx = pt->nblocksx[level];
+ tx->base.nblocksy = pt->nblocksy[level];
+ tx->base.stride = (w * pt->block.size);
+ tx->base.usage = usage;
+
+ tx->level = lvl;
+ tx->level_pitch = lvl->pitch;
+ tx->level_width = mt->base.width[level];
+ tx->level_height = mt->base.height[level];
+ tx->level_x = x;
+ tx->level_y = y;
+ tx->buffer =
+ pipe_buffer_create(pscreen, 0, NOUVEAU_BUFFER_USAGE_TRANSFER,
+ w * tx->base.block.size * h);
+
+ if (usage != PIPE_TRANSFER_WRITE) {
+ nv50_transfer_rect_m2mf(pscreen, mt->buffer, tx->level_pitch,
+ x, y, tx->level_width, tx->level_height,
+ tx->buffer, tx->base.stride, 0, 0,
+ tx->base.width, tx->base.height,
+ tx->base.block.size, w, h,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_GART,
+ NOUVEAU_BO_GART);
+ }
+
+ return &tx->base;
+}
+
+static void
+nv50_transfer_del(struct pipe_transfer *ptx)
+{
+ struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
+ struct nv50_miptree *mt = nv50_miptree(ptx->texture);
+
+ if (ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
+ nv50_transfer_rect_m2mf(pscreen, tx->buffer, tx->base.stride,
+ 0, 0, tx->base.width, tx->base.height,
+ mt->buffer, tx->level_pitch,
+ tx->level_x, tx->level_y,
+ tx->level_width, tx->level_height,
+ tx->base.block.size, tx->base.width,
+ tx->base.height, NOUVEAU_BO_GART,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_GART);
+ }
+
+ pipe_buffer_reference(&tx->buffer, NULL);
+ pipe_texture_reference(&ptx->texture, NULL);
+ FREE(ptx);
+}
+
+static void *
+nv50_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+{
+ struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
+ unsigned flags = 0;
+
+ if (ptx->usage & PIPE_TRANSFER_WRITE)
+ flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+ if (ptx->usage & PIPE_TRANSFER_READ)
+ flags |= PIPE_BUFFER_USAGE_CPU_READ;
+
+ return pipe_buffer_map(pscreen, tx->buffer, flags);
+}
+
+static void
+nv50_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+{
+ struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
+
+ pipe_buffer_unmap(pscreen, tx->buffer);
+}
+
+void
+nv50_transfer_init_screen_functions(struct pipe_screen *pscreen)
+{
+ pscreen->get_tex_transfer = nv50_transfer_new;
+ pscreen->tex_transfer_destroy = nv50_transfer_del;
+ pscreen->transfer_map = nv50_transfer_map;
+ pscreen->transfer_unmap = nv50_transfer_unmap;
+}
diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c
index 0c970adb03..0749c90691 100644
--- a/src/gallium/drivers/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nv50/nv50_vbo.c
@@ -202,7 +202,7 @@ nv50_vbo_validate(struct nv50_context *nv50)
{
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct nouveau_stateobj *vtxbuf, *vtxfmt;
- int i, vpi = 0;
+ int i;
vtxbuf = so_new(nv50->vtxelt_nr * 4, nv50->vtxelt_nr * 2);
vtxfmt = so_new(nv50->vtxelt_nr + 1, 0);
@@ -250,5 +250,7 @@ nv50_vbo_validate(struct nv50_context *nv50)
so_ref (vtxfmt, &nv50->state.vtxfmt);
so_ref (vtxbuf, &nv50->state.vtxbuf);
+ so_ref (NULL, &vtxbuf);
+ so_ref (NULL, &vtxfmt);
}
diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile
index e83d943cd8..0e4e115532 100644
--- a/src/gallium/drivers/r300/Makefile
+++ b/src/gallium/drivers/r300/Makefile
@@ -7,15 +7,17 @@ C_SOURCES = \
r300_chipset.c \
r300_clear.c \
r300_context.c \
+ r300_debug.c \
r300_emit.c \
r300_flush.c \
+ r300_query.c \
r300_screen.c \
r300_state.c \
+ r300_state_derived.c \
+ r300_state_invariant.c \
r300_state_shader.c \
r300_surface.c \
r300_swtcl_emit.c \
r300_texture.c
include ../../Makefile.template
-
-symlinks:
diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c
index 7def62422a..e01a0546b2 100644
--- a/src/gallium/drivers/r300/r300_chipset.c
+++ b/src/gallium/drivers/r300/r300_chipset.c
@@ -21,7 +21,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "r300_chipset.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
/* r300_chipset: A file all to itself for deducing the various properties of
* Radeons. */
@@ -30,7 +30,7 @@
void r300_parse_chipset(struct r300_capabilities* caps)
{
/* Reasonable defaults */
- caps->has_tcl = TRUE;
+ caps->has_tcl = getenv("RADEON_NO_TCL") ? TRUE : FALSE;
caps->is_r500 = FALSE;
caps->num_vert_fpus = 4;
@@ -204,6 +204,13 @@ void r300_parse_chipset(struct r300_capabilities* caps)
caps->has_tcl = FALSE;
break;
+ case 0x793F:
+ case 0x7941:
+ case 0x7942:
+ caps->family = CHIP_FAMILY_RS600;
+ caps->has_tcl = FALSE;
+ break;
+
case 0x796C:
case 0x796D:
case 0x796E:
@@ -343,6 +350,6 @@ void r300_parse_chipset(struct r300_capabilities* caps)
break;
}
- /* Force off TCL for now */
- caps->has_tcl = FALSE;
+ /* XXX SW TCL is broken so no forcing it off right now
+ caps->has_tcl = FALSE; */
}
diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h
index a9cd372ec5..21eebeae60 100644
--- a/src/gallium/drivers/r300/r300_chipset.h
+++ b/src/gallium/drivers/r300/r300_chipset.h
@@ -64,6 +64,7 @@ enum {
CHIP_FAMILY_RC410,
CHIP_FAMILY_RS480,
CHIP_FAMILY_RS482,
+ CHIP_FAMILY_RS600,
CHIP_FAMILY_RS690,
CHIP_FAMILY_RS740,
CHIP_FAMILY_RV515,
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 7b605ae87a..b8584702aa 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -22,18 +22,87 @@
#include "r300_context.h"
+static boolean r300_draw_range_elements(struct pipe_context* pipe,
+ struct pipe_buffer* indexBuffer,
+ unsigned indexSize,
+ unsigned minIndex,
+ unsigned maxIndex,
+ unsigned mode,
+ unsigned start,
+ unsigned count)
+{
+ struct r300_context* r300 = r300_context(pipe);
+ int i;
+
+ if (r300->dirty_state) {
+ r300_emit_dirty_state(r300);
+ }
+
+ for (i = 0; i < r300->vertex_buffer_count; i++) {
+ void* buf = pipe_buffer_map(pipe->screen,
+ r300->vertex_buffers[i].buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_vertex_buffer(r300->draw, i, buf);
+ }
+
+ if (indexBuffer) {
+ void* indices = pipe_buffer_map(pipe->screen, indexBuffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_element_buffer_range(r300->draw, indexSize,
+ minIndex, maxIndex, indices);
+ } else {
+ draw_set_mapped_element_buffer(r300->draw, 0, NULL);
+ }
+
+ draw_set_mapped_constant_buffer(r300->draw,
+ r300->shader_constants[PIPE_SHADER_VERTEX].constants,
+ r300->shader_constants[PIPE_SHADER_VERTEX].user_count *
+ (sizeof(float) * 4));
+
+ draw_arrays(r300->draw, mode, start, count);
+
+ for (i = 0; i < r300->vertex_buffer_count; i++) {
+ pipe_buffer_unmap(pipe->screen, r300->vertex_buffers[i].buffer);
+ draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
+ }
+
+ if (indexBuffer) {
+ pipe_buffer_unmap(pipe->screen, indexBuffer);
+ draw_set_mapped_element_buffer_range(r300->draw, 0, start,
+ start + count - 1, NULL);
+ }
+
+ return TRUE;
+}
+
+static boolean r300_draw_elements(struct pipe_context* pipe,
+ struct pipe_buffer* indexBuffer,
+ unsigned indexSize, unsigned mode,
+ unsigned start, unsigned count)
+{
+ return r300_draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0,
+ mode, start, count);
+}
+
+static boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
+ unsigned start, unsigned count)
+{
+ return r300_draw_elements(pipe, NULL, 0, mode, start, count);
+}
+
static void r300_destroy_context(struct pipe_context* context) {
struct r300_context* r300 = r300_context(context);
draw_destroy(r300->draw);
FREE(r300->blend_color_state);
+ FREE(r300->rs_block);
FREE(r300->scissor_state);
+ FREE(r300->viewport_state);
FREE(r300);
}
struct pipe_context* r300_create_context(struct pipe_screen* screen,
- struct pipe_winsys* winsys,
struct r300_winsys* r300_winsys)
{
struct r300_context* r300 = CALLOC_STRUCT(r300_context);
@@ -41,26 +110,37 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
if (!r300)
return NULL;
+ /* XXX this could be refactored now? */
r300->winsys = r300_winsys;
- r300->context.winsys = winsys;
- r300->context.screen = r300_create_screen(winsys, r300_winsys);
+
+ r300->context.winsys = (struct pipe_winsys*)r300_winsys;
+ r300->context.screen = r300_screen(screen);
r300->context.destroy = r300_destroy_context;
r300->context.clear = r300_clear;
+ r300->context.draw_arrays = r300_draw_arrays;
+ r300->context.draw_elements = r300_draw_elements;
+ r300->context.draw_range_elements = r300_draw_range_elements;
+
r300->draw = draw_create();
- /*XXX draw_set_rasterize_stage(r300->draw, r300_draw_swtcl_stage(r300));*/
+ draw_set_rasterize_stage(r300->draw, r300_draw_swtcl_stage(r300));
r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state);
+ r300->rs_block = CALLOC_STRUCT(r300_rs_block);
r300->scissor_state = CALLOC_STRUCT(r300_scissor_state);
+ r300->viewport_state = CALLOC_STRUCT(r300_viewport_state);
r300_init_flush_functions(r300);
+ r300_init_query_functions(r300);
+
r300_init_surface_functions(r300);
r300_init_state_functions(r300);
+ r300_emit_invariant_state(r300);
r300->dirty_state = R300_NEW_KITCHEN_SINK;
r300->dirty_hw++;
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 376c57639d..0e5e471d11 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -24,11 +24,13 @@
#define R300_CONTEXT_H
#include "draw/draw_context.h"
+#include "draw/draw_vertex.h"
#include "pipe/p_context.h"
#include "tgsi/tgsi_scan.h"
#include "util/u_memory.h"
#include "r300_clear.h"
+#include "r300_query.h"
#include "r300_screen.h"
#include "r300_winsys.h"
@@ -58,8 +60,12 @@ struct r300_dsa_state {
};
struct r300_rs_state {
+ /* XXX icky as fucking hell */
+ struct pipe_rasterizer_state rs;
+
uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */
uint32_t point_size; /* R300_GA_POINT_SIZE: 0x421c */
+ uint32_t point_minmax; /* R300_GA_POINT_MINMAX: 0x4230 */
uint32_t line_control; /* R300_GA_LINE_CNTL: 0x4234 */
uint32_t depth_scale_front; /* R300_SU_POLY_OFFSET_FRONT_SCALE: 0x42a4 */
uint32_t depth_offset_front;/* R300_SU_POLY_OFFSET_FRONT_OFFSET: 0x42a8 */
@@ -69,6 +75,14 @@ struct r300_rs_state {
uint32_t cull_mode; /* R300_SU_CULL_MODE: 0x42b8 */
uint32_t line_stipple_config; /* R300_GA_LINE_STIPPLE_CONFIG: 0x4328 */
uint32_t line_stipple_value; /* R300_GA_LINE_STIPPLE_VALUE: 0x4260 */
+ uint32_t color_control; /* R300_GA_COLOR_CONTROL: 0x4278 */
+};
+
+struct r300_rs_block {
+ uint32_t ip[8]; /* R300_RS_IP_[0-7], R500_RS_IP_[0-7] */
+ uint32_t count; /* R300_RS_COUNT */
+ uint32_t inst_count; /* R300_RS_INST_COUNT */
+ uint32_t inst[8]; /* R300_RS_INST_[0-7] */
};
struct r300_sampler_state {
@@ -83,23 +97,52 @@ struct r300_scissor_state {
};
struct r300_texture_state {
+ uint32_t format0; /* R300_TX_FORMAT0: 0x4480 */
+ uint32_t format1; /* R300_TX_FORMAT1: 0x44c0 */
+ uint32_t format2; /* R300_TX_FORMAT2: 0x4500 */
+};
+
+struct r300_viewport_state {
+ float xscale; /* R300_VAP_VPORT_XSCALE: 0x2098 */
+ float xoffset; /* R300_VAP_VPORT_XOFFSET: 0x209c */
+ float yscale; /* R300_VAP_VPORT_YSCALE: 0x20a0 */
+ float yoffset; /* R300_VAP_VPORT_YOFFSET: 0x20a4 */
+ float zscale; /* R300_VAP_VPORT_ZSCALE: 0x20a8 */
+ float zoffset; /* R300_VAP_VPORT_ZOFFSET: 0x20ac */
+ uint32_t vte_control; /* R300_VAP_VTE_CNTL: 0x20b0 */
};
-#define R300_NEW_BLEND 0x000001
-#define R300_NEW_BLEND_COLOR 0x000002
-#define R300_NEW_DSA 0x000004
-#define R300_NEW_FRAMEBUFFERS 0x000008
-#define R300_NEW_FRAGMENT_SHADER 0x000010
-#define R300_NEW_RASTERIZER 0x000020
-#define R300_NEW_SAMPLER 0x000040
-#define R300_NEW_SCISSOR 0x004000
-#define R300_NEW_TEXTURE 0x008000
-#define R300_NEW_VERTEX_SHADER 0x800000
-#define R300_NEW_KITCHEN_SINK 0xffffff
+#define R300_NEW_BLEND 0x0000001
+#define R300_NEW_BLEND_COLOR 0x0000002
+#define R300_NEW_CONSTANTS 0x0000004
+#define R300_NEW_DSA 0x0000008
+#define R300_NEW_FRAMEBUFFERS 0x0000010
+#define R300_NEW_FRAGMENT_SHADER 0x0000020
+#define R300_NEW_RASTERIZER 0x0000040
+#define R300_NEW_RS_BLOCK 0x0000080
+#define R300_NEW_SAMPLER 0x0000100
+#define R300_ANY_NEW_SAMPLERS 0x000ff00
+#define R300_NEW_SCISSOR 0x0010000
+#define R300_NEW_TEXTURE 0x0020000
+#define R300_ANY_NEW_TEXTURES 0x1fe0000
+#define R300_NEW_VERTEX_FORMAT 0x2000000
+#define R300_NEW_VERTEX_SHADER 0x4000000
+#define R300_NEW_VIEWPORT 0x8000000
+#define R300_NEW_KITCHEN_SINK 0xfffffff
/* The next several objects are not pure Radeon state; they inherit from
* various Gallium classes. */
+struct r300_constant_buffer {
+ /* Buffer of constants */
+ /* XXX first number should be raised */
+ float constants[8][4];
+ /* Number of user-defined constants */
+ int user_count;
+ /* Total number of constants */
+ int count;
+};
+
struct r3xx_fragment_shader {
/* Parent class */
struct pipe_shader_state state;
@@ -107,16 +150,55 @@ struct r3xx_fragment_shader {
/* Has this shader been translated yet? */
boolean translated;
+
+ /* Pixel stack size */
+ int stack_size;
};
struct r300_fragment_shader {
/* Parent class */
struct r3xx_fragment_shader shader;
+
+ /* Number of ALU instructions */
+ int alu_instruction_count;
+
+ /* Number of texture instructions */
+ int tex_instruction_count;
+
+ /* Number of texture indirections */
+ int indirections;
+
+ /* Indirection node offsets */
+ int offset0;
+ int offset1;
+ int offset2;
+ int offset3;
+
+ /* Machine instructions */
+ struct {
+ uint32_t alu_rgb_inst;
+ uint32_t alu_rgb_addr;
+ uint32_t alu_alpha_inst;
+ uint32_t alu_alpha_addr;
+ } instructions[64]; /* XXX magic num */
};
struct r500_fragment_shader {
/* Parent class */
struct r3xx_fragment_shader shader;
+
+ /* Number of used instructions */
+ int instruction_count;
+
+ /* Machine instructions */
+ struct {
+ uint32_t inst0;
+ uint32_t inst1;
+ uint32_t inst2;
+ uint32_t inst3;
+ uint32_t inst4;
+ uint32_t inst5;
+ } instructions[256]; /*< XXX magic number */
};
struct r300_texture {
@@ -126,11 +208,30 @@ struct r300_texture {
/* Offsets into the buffer. */
unsigned offset[PIPE_MAX_TEXTURE_LEVELS];
+ /* Stride (pitch?) of this texture in bytes */
+ unsigned stride;
+
/* Total size of this texture, in bytes. */
unsigned size;
/* Pipe buffer backing this texture. */
struct pipe_buffer* buffer;
+
+ /* Registers carrying texture format data. */
+ struct r300_texture_state state;
+};
+
+struct r300_vertex_format {
+ /* Parent class */
+ struct vertex_info vinfo;
+ /* R300_VAP_PROG_STREAK_CNTL_[0-7] */
+ uint32_t vap_prog_stream_cntl[8];
+ /* R300_VAP_PROG_STREAK_CNTL_EXT_[0-7] */
+ uint32_t vap_prog_stream_cntl_ext[8];
+ /* This is a map of VAP/SW TCL outputs into the GA/RS.
+ * tab[i] is the location of input i in GA/RS input memory.
+ * Named tab for historical reasons. */
+ int tab[16];
};
struct r300_context {
@@ -147,6 +248,8 @@ struct r300_context {
struct r300_blend_state* blend_state;
/* Blend color state. */
struct r300_blend_color_state* blend_color_state;
+ /* Shader constants. */
+ struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES];
/* Depth, stencil, and alpha state. */
struct r300_dsa_state* dsa_state;
/* Fragment shader. */
@@ -155,6 +258,8 @@ struct r300_context {
struct pipe_framebuffer_state framebuffer_state;
/* Rasterizer state. */
struct r300_rs_state* rs_state;
+ /* RS block state. */
+ struct r300_rs_block* rs_block;
/* Sampler states. */
struct r300_sampler_state* sampler_states[8];
int sampler_count;
@@ -162,8 +267,14 @@ struct r300_context {
struct r300_scissor_state* scissor_state;
/* Texture states. */
struct r300_texture* textures[8];
- struct r300_texture_state* texture_states[8];
int texture_count;
+ /* Vertex buffers. */
+ struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
+ int vertex_buffer_count;
+ /* Vertex information. */
+ struct r300_vertex_format vertex_info;
+ /* Viewport state. */
+ struct r300_viewport_state* viewport_state;
/* Bitmask of dirty state objects. */
uint32_t dirty_state;
/* Flag indicating whether or not the HW is dirty. */
@@ -176,6 +287,7 @@ static struct r300_context* r300_context(struct pipe_context* context) {
}
/* Context initialization. */
+struct draw_stage* r300_draw_swtcl_stage(struct r300_context* r300);
void r300_init_state_functions(struct r300_context* r300);
void r300_init_surface_functions(struct r300_context* r300);
@@ -183,7 +295,6 @@ void r300_init_surface_functions(struct r300_context* r300);
* We'll just step out in that case... */
#ifndef R300_WINSYS_H
struct pipe_context* r300_create_context(struct pipe_screen* screen,
- struct pipe_winsys* winsys,
struct r300_winsys* r300_winsys);
#endif
diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h
index 385b61a096..d8038ff1e1 100644
--- a/src/gallium/drivers/r300/r300_cs.h
+++ b/src/gallium/drivers/r300/r300_cs.h
@@ -23,27 +23,19 @@
#ifndef R300_CS_H
#define R300_CS_H
+#include "util/u_math.h"
+
#include "r300_reg.h"
#include "r300_winsys.h"
-/* Pack a 32-bit float into a dword. */
-static uint32_t pack_float_32(float f)
-{
- union {
- float f;
- uint32_t u;
- } u;
-
- u.f = f;
- return u.u;
-}
-
/* Yes, I know macros are ugly. However, they are much prettier than the code
* that they neatly hide away, and don't have the cost of function setup,so
* we're going to use them. */
#define MAX_CS_SIZE 64 * 1024 / 4
+#define VERY_VERBOSE_REGISTERS 0
+
/* XXX stolen from radeon_drm.h */
#define RADEON_GEM_DOMAIN_CPU 0x1
#define RADEON_GEM_DOMAIN_GTT 0x2
@@ -80,13 +72,14 @@ static uint32_t pack_float_32(float f)
} while (0)
#define OUT_CS_32F(value) do { \
- cs_winsys->write_cs_dword(cs, pack_float_32(value)); \
+ cs_winsys->write_cs_dword(cs, fui(value)); \
cs_count--; \
} while (0)
#define OUT_CS_REG(register, value) do { \
- debug_printf("r300: writing 0x%08X to register 0x%04X\n", \
- value, register); \
+ if (VERY_VERBOSE_REGISTERS) \
+ debug_printf("r300: writing 0x%08X to register 0x%04X\n", \
+ value, register); \
assert(register); \
OUT_CS(CP_PACKET0(register, 0)); \
OUT_CS(value); \
@@ -95,8 +88,9 @@ static uint32_t pack_float_32(float f)
/* Note: This expects count to be the number of registers,
* not the actual packet0 count! */
#define OUT_CS_REG_SEQ(register, count) do { \
- debug_printf("r300: writing register sequence of %d to 0x%04X\n", \
- count, register); \
+ if (VERY_VERBOSE_REGISTERS) \
+ debug_printf("r300: writing register sequence of %d to 0x%04X\n", \
+ count, register); \
assert(register); \
OUT_CS(CP_PACKET0(register, ((count) - 1))); \
} while (0)
@@ -119,7 +113,7 @@ static uint32_t pack_float_32(float f)
} while (0)
#define FLUSH_CS do { \
- debug_printf("r300: FLUSH_CS in %s (%s:%d)\n", __FUNCTION__, __FILE__, \
+ debug_printf("r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, __FILE__, \
__LINE__); \
cs_winsys->flush_cs(cs); \
} while (0)
diff --git a/src/gallium/drivers/r300/r300_cs_inlines.h b/src/gallium/drivers/r300/r300_cs_inlines.h
index 71e6623699..03bb608eb9 100644
--- a/src/gallium/drivers/r300/r300_cs_inlines.h
+++ b/src/gallium/drivers/r300/r300_cs_inlines.h
@@ -26,12 +26,25 @@
#ifdef R300_CS_H
+#define RADEON_ONE_REG_WR (1 << 15)
+
+#define OUT_CS_ONE_REG(register, count) do { \
+ if (VERY_VERBOSE_REGISTERS) \
+ debug_printf("r300: writing data sequence of %d to 0x%04X\n", \
+ count, register); \
+ assert(register); \
+ OUT_CS(CP_PACKET0(register, ((count) - 1)) | RADEON_ONE_REG_WR); \
+} while (0)
+
#define R300_PACIFY do { \
+ OUT_CS_REG(RADEON_WAIT_UNTIL, (1 << 14) | (1 << 15) | (1 << 16) | (1 << 17) | \
+ (1 << 18)); \
+} while (0)
+
+#define R300_SCREENDOOR do { \
OUT_CS_REG(R300_SC_SCREENDOOR, 0x0); \
- OUT_CS_REG(RADEON_WAIT_UNTIL, (1 << 15) | (1 << 17) | \
- (1 << 18) | (1 << 31)); \
+ R300_PACIFY; \
OUT_CS_REG(R300_SC_SCREENDOOR, 0xffffff); \
} while (0)
-
#endif /* R300_CS_H */
diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c
new file mode 100644
index 0000000000..f657588c72
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_debug.c
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include "r300_debug.h"
+
+static char* r500_fs_swiz[] = {
+ " R",
+ " G",
+ " B",
+ " A",
+ " 0",
+ ".5",
+ " 1",
+ " U",
+};
+
+static char* r500_fs_op_rgb[] = {
+ "MAD",
+ "DP3",
+ "DP4",
+ "D2A",
+ "MIN",
+ "MAX",
+ "---",
+ "CND",
+ "CMP",
+ "FRC",
+ "SOP",
+ "MDH",
+ "MDV",
+};
+
+static char* r500_fs_op_alpha[] = {
+ "MAD",
+ " DP",
+ "MIN",
+ "MAX",
+ "---",
+ "CND",
+ "CMP",
+ "FRC",
+ "EX2",
+ "LN2",
+ "RCP",
+ "RSQ",
+ "SIN",
+ "COS",
+ "MDH",
+ "MDV",
+};
+
+static char* r500_fs_mask[] = {
+ "NONE",
+ "R ",
+ " G ",
+ "RG ",
+ " B ",
+ "R B ",
+ " GB ",
+ "RGB ",
+ " A",
+ "R A",
+ " G A",
+ "RG A",
+ " BA",
+ "R BA",
+ " GBA",
+ "RGBA",
+};
+
+static char* r500_fs_tex[] = {
+ " NOP",
+ " LD",
+ "TEXKILL",
+ " PROJ",
+ "LODBIAS",
+ " LOD",
+ " DXDY",
+};
+
+void r500_fs_dump(struct r500_fragment_shader* fs)
+{
+ int i;
+ uint32_t inst;
+
+ for (i = 0; i < fs->instruction_count; i++) {
+ inst = fs->instructions[i].inst0;
+ debug_printf("%d: 0: CMN_INST 0x%08x:", i, inst);
+ switch (inst & 0x3) {
+ case R500_INST_TYPE_ALU:
+ debug_printf("ALU ");
+ break;
+ case R500_INST_TYPE_OUT:
+ debug_printf("OUT ");
+ break;
+ case R500_INST_TYPE_FC:
+ debug_printf("FC ");
+ break;
+ case R500_INST_TYPE_TEX:
+ debug_printf("TEX ");
+ break;
+ }
+ debug_printf("%s %s %s %s ",
+ inst & R500_INST_TEX_SEM_WAIT ? "TEX_WAIT" : "",
+ inst & R500_INST_LAST ? "LAST" : "",
+ inst & R500_INST_NOP ? "NOP" : "",
+ inst & R500_INST_ALU_WAIT ? "ALU_WAIT" : "");
+ debug_printf("wmask: %s omask: %s\n",
+ r500_fs_mask[(inst >> 11) & 0xf],
+ r500_fs_mask[(inst >> 15) & 0xf]);
+ switch (inst & 0x3) {
+ case R500_INST_TYPE_ALU:
+ case R500_INST_TYPE_OUT:
+ inst = fs->instructions[i].inst1;
+ debug_printf(" 1: RGB_ADDR 0x%08x:", inst);
+ debug_printf("Addr0: %d%c, Addr1: %d%c, "
+ "Addr2: %d%c, srcp:%d\n",
+ inst & 0xff, (inst & (1 << 8)) ? 'c' : 't',
+ (inst >> 10) & 0xff, (inst & (1 << 18)) ? 'c' : 't',
+ (inst >> 20) & 0xff, (inst & (1 << 28)) ? 'c' : 't',
+ (inst >> 30));
+
+ inst = fs->instructions[i].inst2;
+ debug_printf(" 2: ALPHA_ADDR 0x%08x:", inst);
+ debug_printf("Addr0: %d%c, Addr1: %d%c, "
+ "Addr2: %d%c, srcp:%d\n",
+ inst & 0xff, (inst & (1 << 8)) ? 'c' : 't',
+ (inst >> 10) & 0xff, (inst & (1 << 18)) ? 'c' : 't',
+ (inst >> 20) & 0xff, (inst & (1 << 28)) ? 'c' : 't',
+ (inst >> 30));
+
+ inst = fs->instructions[i].inst3;
+ debug_printf(" 3: RGB_INST 0x%08x:", inst);
+ debug_printf("rgb_A_src:%d %s/%s/%s %d "
+ "rgb_B_src:%d %s/%s/%s %d\n",
+ inst & 0x3, r500_fs_swiz[(inst >> 2) & 0x7],
+ r500_fs_swiz[(inst >> 5) & 0x7],
+ r500_fs_swiz[(inst >> 8) & 0x7],
+ (inst >> 11) & 0x3, (inst >> 13) & 0x3,
+ r500_fs_swiz[(inst >> 15) & 0x7],
+ r500_fs_swiz[(inst >> 18) & 0x7],
+ r500_fs_swiz[(inst >> 21) & 0x7],
+ (inst >> 24) & 0x3);
+
+ inst = fs->instructions[i].inst4;
+ debug_printf(" 4: ALPHA_INST 0x%08x:", inst);
+ debug_printf("%s dest:%d%s alp_A_src:%d %s %d "
+ "alp_B_src:%d %s %d w:%d\n",
+ r500_fs_op_alpha[inst & 0xf], (inst >> 4) & 0x7f,
+ inst & (1<<11) ? "(rel)":"", (inst >> 12) & 0x3,
+ r500_fs_swiz[(inst >> 14) & 0x7], (inst >> 17) & 0x3,
+ (inst >> 19) & 0x3, r500_fs_swiz[(inst >> 21) & 0x7],
+ (inst >> 24) & 0x3, (inst >> 31) & 0x1);
+
+ inst = fs->instructions[i].inst5;
+ debug_printf(" 5: RGBA_INST 0x%08x:", inst);
+ debug_printf("%s dest:%d%s rgb_C_src:%d %s/%s/%s %d "
+ "alp_C_src:%d %s %d\n",
+ r500_fs_op_rgb[inst & 0xf], (inst >> 4) & 0x7f,
+ inst & (1 << 11) ? "(rel)":"", (inst >> 12) & 0x3,
+ r500_fs_swiz[(inst >> 14) & 0x7],
+ r500_fs_swiz[(inst >> 17) & 0x7],
+ r500_fs_swiz[(inst >> 20) & 0x7],
+ (inst >> 23) & 0x3, (inst >> 25) & 0x3,
+ r500_fs_swiz[(inst >> 27) & 0x7], (inst >> 30) & 0x3);
+ break;
+ case R500_INST_TYPE_FC:
+ /* XXX don't even bother yet */
+ break;
+ case R500_INST_TYPE_TEX:
+ inst = fs->instructions[i].inst1;
+ debug_printf(" 1: TEX_INST 0x%08x: id: %d "
+ "op:%s, %s, %s %s\n",
+ inst, (inst >> 16) & 0xf,
+ r500_fs_tex[(inst >> 22) & 0x7],
+ (inst & (1 << 25)) ? "ACQ" : "",
+ (inst & (1 << 26)) ? "IGNUNC" : "",
+ (inst & (1 << 27)) ? "UNSCALED" : "SCALED");
+
+ inst = fs->instructions[i].inst2;
+ debug_printf(" 2: TEX_ADDR 0x%08x: "
+ "src: %d%s %s/%s/%s/%s dst: %d%s %s/%s/%s/%s\n",
+ inst, inst & 0x7f, inst & (1 << 7) ? "(rel)" : "",
+ r500_fs_swiz[(inst >> 8) & 0x3],
+ r500_fs_swiz[(inst >> 10) & 0x3],
+ r500_fs_swiz[(inst >> 12) & 0x3],
+ r500_fs_swiz[(inst >> 14) & 0x3],
+ (inst >> 16) & 0x7f, inst & (1 << 23) ? "(rel)" : "",
+ r500_fs_swiz[(inst >> 24) & 0x3],
+ r500_fs_swiz[(inst >> 26) & 0x3],
+ r500_fs_swiz[(inst >> 28) & 0x3],
+ r500_fs_swiz[(inst >> 30) & 0x3]);
+
+ inst = fs->instructions[i].inst3;
+ debug_printf(" 3: TEX_DXDY 0x%08x\n", inst);
+ break;
+ }
+ }
+}
diff --git a/src/gallium/drivers/r300/r300_debug.h b/src/gallium/drivers/r300/r300_debug.h
new file mode 100644
index 0000000000..de5d701ed9
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_debug.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_DEBUG_H
+#define R300_DEBUG_H
+
+#include "r300_reg.h"
+#include "r300_state_shader.h"
+
+void r500_fs_dump(struct r500_fragment_shader* fs);
+
+#endif /* R300_DEBUG_H */
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 585a9e729d..a2e771bd1b 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -40,9 +40,9 @@ void r300_emit_blend_state(struct r300_context* r300,
void r300_emit_blend_color_state(struct r300_context* r300,
struct r300_blend_color_state* bc)
{
- struct r300_screen* r300screen =
- (struct r300_screen*)r300->context.screen;
+ struct r300_screen* r300screen = r300_screen(r300->context.screen);
CS_LOCALS(r300);
+
if (r300screen->caps->is_r500) {
BEGIN_CS(3);
OUT_CS_REG_SEQ(R500_RB3D_CONSTANT_COLOR_AR, 2);
@@ -59,9 +59,9 @@ void r300_emit_blend_color_state(struct r300_context* r300,
void r300_emit_dsa_state(struct r300_context* r300,
struct r300_dsa_state* dsa)
{
- struct r300_screen* r300screen =
- (struct r300_screen*)r300->context.screen;
+ struct r300_screen* r300screen = r300_screen(r300->context.screen);
CS_LOCALS(r300);
+
BEGIN_CS(r300screen->caps->is_r500 ? 8 : 8);
OUT_CS_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function);
/* XXX figure out the r300 counterpart for this */
@@ -79,7 +79,95 @@ void r300_emit_dsa_state(struct r300_context* r300,
END_CS;
}
-/* XXX add pitch, stride, z/stencil buf */
+void r300_emit_fragment_shader(struct r300_context* r300,
+ struct r300_fragment_shader* fs)
+{
+ CS_LOCALS(r300);
+ int i;
+
+ BEGIN_CS(22);
+
+ OUT_CS_REG(R300_US_CONFIG, MAX2(fs->indirections - 1, 0));
+ OUT_CS_REG(R300_US_PIXSIZE, fs->shader.stack_size);
+ /* XXX figure out exactly how big the sizes are on this reg */
+ OUT_CS_REG(R300_US_CODE_OFFSET, 0x0);
+ /* XXX figure these ones out a bit better kthnx */
+ OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_3, R300_RGBA_OUT);
+
+ for (i = 0; i < fs->alu_instruction_count; i++) {
+ OUT_CS_REG(R300_US_ALU_RGB_INST_0 + (4 * i),
+ fs->instructions[i].alu_rgb_inst);
+ OUT_CS_REG(R300_US_ALU_RGB_ADDR_0 + (4 * i),
+ fs->instructions[i].alu_rgb_addr);
+ OUT_CS_REG(R300_US_ALU_ALPHA_INST_0 + (4 * i),
+ fs->instructions[i].alu_alpha_inst);
+ OUT_CS_REG(R300_US_ALU_ALPHA_ADDR_0 + (4 * i),
+ fs->instructions[i].alu_alpha_addr);
+ }
+
+ END_CS;
+}
+
+void r500_emit_fragment_shader(struct r300_context* r300,
+ struct r500_fragment_shader* fs)
+{
+ CS_LOCALS(r300);
+ struct r300_constant_buffer* constants =
+ &r300->shader_constants[PIPE_SHADER_FRAGMENT];
+ int i;
+
+ BEGIN_CS(9 + (fs->instruction_count * 6) + (constants->count ? 3 : 0) +
+ (constants->count * 4));
+ OUT_CS_REG(R500_US_CONFIG, R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO);
+ OUT_CS_REG(R500_US_PIXSIZE, fs->shader.stack_size);
+ OUT_CS_REG(R500_US_CODE_ADDR, R500_US_CODE_START_ADDR(0) |
+ R500_US_CODE_END_ADDR(fs->instruction_count));
+
+ OUT_CS_REG(R500_GA_US_VECTOR_INDEX, R500_GA_US_VECTOR_INDEX_TYPE_INSTR);
+ OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, fs->instruction_count * 6);
+ for (i = 0; i < fs->instruction_count; i++) {
+ OUT_CS(fs->instructions[i].inst0);
+ OUT_CS(fs->instructions[i].inst1);
+ OUT_CS(fs->instructions[i].inst2);
+ OUT_CS(fs->instructions[i].inst3);
+ OUT_CS(fs->instructions[i].inst4);
+ OUT_CS(fs->instructions[i].inst5);
+ }
+
+ if (constants->count) {
+ OUT_CS_REG(R500_GA_US_VECTOR_INDEX,
+ R500_GA_US_VECTOR_INDEX_TYPE_CONST);
+ OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, constants->count * 4);
+ for (i = 0; i < constants->count; i++) {
+ OUT_CS_32F(constants->constants[i][0]);
+ OUT_CS_32F(constants->constants[i][1]);
+ OUT_CS_32F(constants->constants[i][2]);
+ OUT_CS_32F(constants->constants[i][3]);
+ }
+ }
+
+ END_CS;
+}
+
+/* Translate pipe_format into US_OUT_FMT. Note that formats are stored from
+ * C3 to C0. */
+uint32_t translate_out_fmt(enum pipe_format format)
+{
+ switch (format) {
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ return R300_US_OUT_FMT_C4_8 |
+ R300_C0_SEL_B | R300_C1_SEL_G |
+ R300_C2_SEL_R | R300_C3_SEL_A;
+ default:
+ return R300_US_OUT_FMT_UNUSED;
+ }
+ return 0;
+}
+
+/* XXX add pitch, stride, clean up */
void r300_emit_fb_state(struct r300_context* r300,
struct pipe_framebuffer_state* fb)
{
@@ -87,23 +175,47 @@ void r300_emit_fb_state(struct r300_context* r300,
struct r300_texture* tex;
int i;
- BEGIN_CS((3 * fb->nr_cbufs) + 6);
+ BEGIN_CS((6 * fb->nr_cbufs) + (fb->zsbuf ? 6 : 0) + 4);
for (i = 0; i < fb->nr_cbufs; i++) {
tex = (struct r300_texture*)fb->cbufs[i]->texture;
OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+
+ OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i),
+ translate_out_fmt(fb->cbufs[i]->format));
+ }
+
+ if (fb->zsbuf) {
+ tex = (struct r300_texture*)fb->zsbuf->texture;
+ OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
+ OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+ if (fb->zsbuf->format == PIPE_FORMAT_Z24S8_UNORM) {
+ OUT_CS_REG(R300_ZB_FORMAT,
+ R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL);
+ } else {
+ OUT_CS_REG(R300_ZB_FORMAT, 0x0);
+ }
}
- R300_PACIFY;
+
+ OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
+ R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
+ R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
+ OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
+ R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
+ R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
END_CS;
}
void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs)
{
- struct r300_screen* r300screen =
- (struct r300_screen*)r300->context.screen;
CS_LOCALS(r300);
- BEGIN_CS(14);
+
+ BEGIN_CS(20);
OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status);
+ OUT_CS_REG(R300_GA_POINT_SIZE, rs->point_size);
+ OUT_CS_REG_SEQ(R300_GA_POINT_MINMAX, 2);
+ OUT_CS(rs->point_minmax);
+ OUT_CS(rs->line_control);
OUT_CS_REG_SEQ(R300_SU_POLY_OFFSET_FRONT_SCALE, 6);
OUT_CS(rs->depth_scale_front);
OUT_CS(rs->depth_offset_front);
@@ -113,43 +225,241 @@ void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs)
OUT_CS(rs->cull_mode);
OUT_CS_REG(R300_GA_LINE_STIPPLE_CONFIG, rs->line_stipple_config);
OUT_CS_REG(R300_GA_LINE_STIPPLE_VALUE, rs->line_stipple_value);
+ OUT_CS_REG(R300_GA_COLOR_CONTROL, rs->color_control);
+ END_CS;
+}
+
+void r300_emit_rs_block_state(struct r300_context* r300,
+ struct r300_rs_block* rs)
+{
+ struct r300_screen* r300screen = r300_screen(r300->context.screen);
+ CS_LOCALS(r300);
+ int i;
+
+ BEGIN_CS(21);
+ if (r300screen->caps->is_r500) {
+ OUT_CS_REG_SEQ(R500_RS_IP_0, 8);
+ } else {
+ OUT_CS_REG_SEQ(R300_RS_IP_0, 8);
+ }
+ for (i = 0; i < 8; i++) {
+ OUT_CS(rs->ip[i]);
+ debug_printf("ip %d: 0x%08x\n", i, rs->ip[i]);
+ }
+
+ OUT_CS_REG_SEQ(R300_RS_COUNT, 2);
+ OUT_CS(rs->count);
+ OUT_CS(rs->inst_count);
+
+ if (r300screen->caps->is_r500) {
+ OUT_CS_REG_SEQ(R500_RS_INST_0, 8);
+ } else {
+ OUT_CS_REG_SEQ(R300_RS_INST_0, 8);
+ }
+ for (i = 0; i < 8; i++) {
+ OUT_CS(rs->inst[i]);
+ debug_printf("inst %d: 0x%08x\n", i, rs->inst[i]);
+ }
+
+ debug_printf("count: 0x%08x inst_count: 0x%08x\n", rs->count,
+ rs->inst_count);
+
END_CS;
}
-static void r300_emit_dirty_state(struct r300_context* r300)
+void r300_emit_sampler(struct r300_context* r300,
+ struct r300_sampler_state* sampler, unsigned offset)
{
- struct r300_screen* r300screen =
- (struct r300_screen*)r300->context.screen;
CS_LOCALS(r300);
+ BEGIN_CS(6);
+ OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0);
+ OUT_CS_REG(R300_TX_FILTER1_0 + (offset * 4), sampler->filter1);
+ OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (offset * 4), sampler->border_color);
+ END_CS;
+}
+
+void r300_emit_scissor_state(struct r300_context* r300,
+ struct r300_scissor_state* scissor)
+{
+ CS_LOCALS(r300);
+
+ BEGIN_CS(3);
+ OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2);
+ OUT_CS(scissor->scissor_top_left);
+ OUT_CS(scissor->scissor_bottom_right);
+ END_CS;
+}
+
+void r300_emit_texture(struct r300_context* r300,
+ struct r300_texture* tex, unsigned offset)
+{
+ CS_LOCALS(r300);
+
+ BEGIN_CS(10);
+ OUT_CS_REG(R300_TX_FORMAT0_0 + (offset * 4), tex->state.format0);
+ OUT_CS_REG(R300_TX_FORMAT1_0 + (offset * 4), tex->state.format1);
+ OUT_CS_REG(R300_TX_FORMAT2_0 + (offset * 4), tex->state.format2);
+ OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (offset * 4), 1);
+ OUT_CS_RELOC(tex->buffer, 0,
+ RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0);
+ END_CS;
+}
+
+void r300_emit_vertex_format_state(struct r300_context* r300)
+{
+ CS_LOCALS(r300);
+ int i;
+
+ BEGIN_CS(26);
+ OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info.vinfo.size);
+
+ OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2);
+ OUT_CS(r300->vertex_info.vinfo.hwfmt[0]);
+ OUT_CS(r300->vertex_info.vinfo.hwfmt[1]);
+ OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2);
+ OUT_CS(r300->vertex_info.vinfo.hwfmt[2]);
+ OUT_CS(r300->vertex_info.vinfo.hwfmt[3]);
+ for (i = 0; i < 4; i++) {
+ debug_printf("hwfmt%d: 0x%08x\n", i,
+ r300->vertex_info.vinfo.hwfmt[i]);
+ }
+
+ OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, 8);
+ for (i = 0; i < 8; i++) {
+ OUT_CS(r300->vertex_info.vap_prog_stream_cntl[i]);
+ debug_printf("prog_stream_cntl%d: 0x%08x\n", i,
+ r300->vertex_info.vap_prog_stream_cntl[i]);
+ }
+ OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0, 8);
+ for (i = 0; i < 8; i++) {
+ OUT_CS(r300->vertex_info.vap_prog_stream_cntl_ext[i]);
+ debug_printf("prog_stream_cntl_ext%d: 0x%08x\n", i,
+ r300->vertex_info.vap_prog_stream_cntl_ext[i]);
+ }
+ END_CS;
+}
+
+void r300_emit_viewport_state(struct r300_context* r300,
+ struct r300_viewport_state* viewport)
+{
+ return;
+ CS_LOCALS(r300);
+
+ BEGIN_CS(7);
+ OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 7);
+ OUT_CS_32F(viewport->xscale);
+ OUT_CS_32F(viewport->xoffset);
+ OUT_CS_32F(viewport->yscale);
+ OUT_CS_32F(viewport->yoffset);
+ OUT_CS_32F(viewport->zscale);
+ OUT_CS_32F(viewport->zoffset);
+ OUT_CS(viewport->vte_control);
+ END_CS;
+}
+
+static void r300_flush_textures(struct r300_context* r300)
+{
+ CS_LOCALS(r300);
+
+ BEGIN_CS(4);
+ OUT_CS_REG(R300_TX_INVALTAGS, 0);
+ OUT_CS_REG(R300_TX_ENABLE, (1 << r300->texture_count) - 1);
+ END_CS;
+}
+
+/* Emit all dirty state. */
+void r300_emit_dirty_state(struct r300_context* r300)
+{
+ struct r300_screen* r300screen = r300_screen(r300->context.screen);
+ int i;
+ int dirty_tex = 0;
+
if (!(r300->dirty_state) && !(r300->dirty_hw)) {
return;
}
+ r300_update_derived_state(r300);
+
/* XXX check size */
if (r300->dirty_state & R300_NEW_BLEND) {
r300_emit_blend_state(r300, r300->blend_state);
+ r300->dirty_state &= ~R300_NEW_BLEND;
}
if (r300->dirty_state & R300_NEW_BLEND_COLOR) {
r300_emit_blend_color_state(r300, r300->blend_color_state);
+ r300->dirty_state &= ~R300_NEW_BLEND_COLOR;
}
if (r300->dirty_state & R300_NEW_DSA) {
r300_emit_dsa_state(r300, r300->dsa_state);
+ r300->dirty_state &= ~R300_NEW_DSA;
+ }
+
+ if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) {
+ if (r300screen->caps->is_r500) {
+ r500_emit_fragment_shader(r300,
+ (struct r500_fragment_shader*)r300->fs);
+ } else {
+ r300_emit_fragment_shader(r300,
+ (struct r300_fragment_shader*)r300->fs);
+ }
+ r300->dirty_state &= ~R300_NEW_FRAGMENT_SHADER;
+ }
+
+ if (r300->dirty_state & R300_NEW_FRAMEBUFFERS) {
+ r300_emit_fb_state(r300, &r300->framebuffer_state);
+ r300->dirty_state &= ~R300_NEW_FRAMEBUFFERS;
}
if (r300->dirty_state & R300_NEW_RASTERIZER) {
r300_emit_rs_state(r300, r300->rs_state);
+ r300->dirty_state &= ~R300_NEW_RASTERIZER;
+ }
+
+ if (r300->dirty_state & R300_NEW_RS_BLOCK) {
+ r300_emit_rs_block_state(r300, r300->rs_block);
+ r300->dirty_state &= ~R300_NEW_RS_BLOCK;
+ }
+
+ if (r300->dirty_state & R300_ANY_NEW_SAMPLERS) {
+ for (i = 0; i < r300->sampler_count; i++) {
+ if (r300->dirty_state & (R300_NEW_SAMPLER << i)) {
+ r300_emit_sampler(r300, r300->sampler_states[i], i);
+ r300->dirty_state &= ~(R300_NEW_SAMPLER << i);
+ dirty_tex++;
+ }
+ }
}
if (r300->dirty_state & R300_NEW_SCISSOR) {
- struct r300_scissor_state* scissor = r300->scissor_state;
- /* XXX next two are contiguous regs */
- OUT_CS_REG(R300_SC_SCISSORS_TL, scissor->scissor_top_left);
- OUT_CS_REG(R300_SC_SCISSORS_BR, scissor->scissor_bottom_right);
+ r300_emit_scissor_state(r300, r300->scissor_state);
+ r300->dirty_state &= ~R300_NEW_SCISSOR;
}
- r300->dirty_state = 0;
+ if (r300->dirty_state & R300_ANY_NEW_TEXTURES) {
+ for (i = 0; i < r300->texture_count; i++) {
+ if (r300->dirty_state & (R300_NEW_TEXTURE << i)) {
+ r300_emit_texture(r300, r300->textures[i], i);
+ r300->dirty_state &= ~(R300_NEW_TEXTURE << i);
+ dirty_tex++;
+ }
+ }
+ }
+
+ if (r300->dirty_state & R300_NEW_VIEWPORT) {
+ r300_emit_viewport_state(r300, r300->viewport_state);
+ r300->dirty_state &= ~R300_NEW_VIEWPORT;
+ }
+
+ if (dirty_tex) {
+ r300_flush_textures(r300);
+ }
+
+ if (r300->dirty_state & R300_NEW_VERTEX_FORMAT) {
+ r300_emit_vertex_format_state(r300);
+ r300->dirty_state &= ~R300_NEW_VERTEX_FORMAT;
+ }
}
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index b6e69386f9..4aba1ee08c 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -20,6 +20,11 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
+#ifndef R300_EMIT_H
+#define R300_EMIT_H
+
+#include "util/u_math.h"
+
#include "r300_context.h"
#include "r300_cs.h"
#include "r300_screen.h"
@@ -33,4 +38,26 @@ void r300_emit_blend_color_state(struct r300_context* r300,
void r300_emit_dsa_state(struct r300_context* r300,
struct r300_dsa_state* dsa);
+void r300_emit_fragment_shader(struct r300_context* r300,
+ struct r300_fragment_shader* fs);
+
+void r500_emit_fragment_shader(struct r300_context* r300,
+ struct r500_fragment_shader* fs);
+
+void r300_emit_fb_state(struct r300_context* r300,
+ struct pipe_framebuffer_state* fb);
+
void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs);
+
+void r300_emit_rs_block_state(struct r300_context* r300,
+ struct r300_rs_block* rs);
+
+void r300_emit_scissor_state(struct r300_context* r300,
+ struct r300_scissor_state* scissor);
+
+void r300_emit_vertex_format_state(struct r300_context* r300);
+
+/* Emit all dirty state. */
+void r300_emit_dirty_state(struct r300_context* r300);
+
+#endif /* R300_EMIT_H */
diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c
index 3766f0a0a7..20ca6905ad 100644
--- a/src/gallium/drivers/r300/r300_flush.c
+++ b/src/gallium/drivers/r300/r300_flush.c
@@ -31,6 +31,7 @@ static void r300_flush(struct pipe_context* pipe,
if (r300->dirty_hw) {
FLUSH_CS;
+ r300_emit_invariant_state(r300);
r300->dirty_state = R300_NEW_KITCHEN_SINK;
r300->dirty_hw = 0;
}
diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
new file mode 100644
index 0000000000..5f5f4c4dbd
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_query.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include "r300_query.h"
+
+static struct pipe_query* r300_create_query(struct pipe_context* pipe,
+ unsigned query_type)
+{
+ struct r300_query* q = CALLOC_STRUCT(r300_query);
+
+ q->type = query_type;
+ assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
+
+ /* XXX this is to force winsys to give us a GTT buffer */
+ q->buf = pipe->screen->buffer_create(pipe->screen, 64,
+ PIPE_BUFFER_USAGE_VERTEX, 64);
+
+ return (struct pipe_query*)q;
+}
+
+static void r300_destroy_query(struct pipe_context* pipe,
+ struct pipe_query* query)
+{
+ FREE(query);
+}
+
+static void r300_begin_query(struct pipe_context* pipe,
+ struct pipe_query* query)
+{
+ struct r300_context* r300 = r300_context(pipe);
+ struct r300_query* q = (struct r300_query*)query;
+ CS_LOCALS(r300);
+
+ uint32_t* map = pipe_buffer_map(pipe->screen, q->buf,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ *map = ~0;
+ pipe_buffer_unmap(pipe->screen, q->buf);
+
+ BEGIN_CS(2);
+ OUT_CS_REG(R300_ZB_ZPASS_DATA, 0);
+ END_CS;
+}
+
+static void r300_end_query(struct pipe_context* pipe,
+ struct pipe_query* query)
+{
+ struct r300_context* r300 = r300_context(pipe);
+ struct r300_query* q = (struct r300_query*)query;
+ CS_LOCALS(r300);
+
+ BEGIN_CS(4);
+ OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
+ OUT_CS_RELOC(q->buf, 0, 0, RADEON_GEM_DOMAIN_GTT, 0);
+ END_CS;
+}
+
+static boolean r300_get_query_result(struct pipe_context* pipe,
+ struct pipe_query* query,
+ boolean wait,
+ uint64_t* result)
+{
+ struct r300_query* q = (struct r300_query*)query;
+ uint32_t temp;
+
+ if (wait) {
+ /* Well, we're expected to just sit here and spin, so let's go ahead
+ * and flush so we can be sure that the card's spinning... */
+ /* XXX double-check these params */
+ pipe->flush(pipe, 0, NULL);
+ }
+
+ uint32_t* map = pipe_buffer_map(pipe->screen, q->buf,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ temp = *map;
+ pipe_buffer_unmap(pipe->screen, q->buf);
+
+ if (temp < 0) {
+ /* Our results haven't been written yet... */
+ return FALSE;
+ }
+
+ *result = temp;
+ return TRUE;
+}
+
+void r300_init_query_functions(struct r300_context* r300) {
+ r300->context.create_query = r300_create_query;
+ r300->context.destroy_query = r300_destroy_query;
+ r300->context.begin_query = r300_begin_query;
+ r300->context.end_query = r300_end_query;
+ r300->context.get_query_result = r300_get_query_result;
+}
diff --git a/src/gallium/drivers/r300/r300_query.h b/src/gallium/drivers/r300/r300_query.h
new file mode 100644
index 0000000000..4f447ea45b
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_query.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_QUERY_H
+#define R300_QUERY_H
+
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_reg.h"
+
+struct r300_query {
+ /* The kind of query. Currently only OQ is supported. */
+ unsigned type;
+ /* Buffer object where we want our results to reside. */
+ struct pipe_buffer* buf;
+};
+
+static INLINE struct r300_query* r300_query(struct pipe_query* q)
+{
+ return (struct r300_query*)q;
+}
+
+void r300_init_query_functions(struct r300_context* r300);
+
+#endif /* R300_QUERY_H */
diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h
index dbd0cc28e2..6f3ad970ab 100644
--- a/src/gallium/drivers/r300/r300_reg.h
+++ b/src/gallium/drivers/r300/r300_reg.h
@@ -64,7 +64,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R300_SE_VPORT_ZSCALE 0x1DA8
#define R300_SE_VPORT_ZOFFSET 0x1DAC
-
+#define R300_VAP_PORT_IDX0 0x2040
/*
* Vertex Array Processing (VAP) Control
*/
@@ -139,17 +139,25 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_VAP_OUTPUT_VTX_FMT_1__3_COMPONENTS 3
# define R300_VAP_OUTPUT_VTX_FMT_1__4_COMPONENTS 4
-#define R300_SE_VTE_CNTL 0x20b0
-# define R300_VPORT_X_SCALE_ENA (1 << 0)
-# define R300_VPORT_X_OFFSET_ENA (1 << 1)
-# define R300_VPORT_Y_SCALE_ENA (1 << 2)
-# define R300_VPORT_Y_OFFSET_ENA (1 << 3)
-# define R300_VPORT_Z_SCALE_ENA (1 << 4)
-# define R300_VPORT_Z_OFFSET_ENA (1 << 5)
-# define R300_VTX_XY_FMT (1 << 8)
-# define R300_VTX_Z_FMT (1 << 9)
-# define R300_VTX_W0_FMT (1 << 10)
-# define R300_SERIAL_PROC_ENA (1 << 11)
+#define R300_VAP_VPORT_XSCALE 0x2098
+#define R300_VAP_VPORT_XOFFSET 0x209c
+#define R300_VAP_VPORT_YSCALE 0x20a0
+#define R300_VAP_VPORT_YOFFSET 0x20a4
+#define R300_VAP_VPORT_ZSCALE 0x20a8
+#define R300_VAP_VPORT_ZOFFSET 0x20ac
+
+#define R300_VAP_VTE_CNTL 0x20b0
+#define R300_SE_VTE_CNTL R300_VAP_VTE_CNTL
+# define R300_VPORT_X_SCALE_ENA (1 << 0)
+# define R300_VPORT_X_OFFSET_ENA (1 << 1)
+# define R300_VPORT_Y_SCALE_ENA (1 << 2)
+# define R300_VPORT_Y_OFFSET_ENA (1 << 3)
+# define R300_VPORT_Z_SCALE_ENA (1 << 4)
+# define R300_VPORT_Z_OFFSET_ENA (1 << 5)
+# define R300_VTX_XY_FMT (1 << 8)
+# define R300_VTX_Z_FMT (1 << 9)
+# define R300_VTX_W0_FMT (1 << 10)
+# define R300_SERIAL_PROC_ENA (1 << 11)
#define R300_VAP_VTX_SIZE 0x20b4
@@ -326,6 +334,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_WRITE_ENA_Z 4
# define R300_WRITE_ENA_W 8
# define R300_SWIZZLE1_SHIFT 16
+
+# define R300_VAP_SWIZZLE_XYZW \
+ ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \
+ (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \
+ (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) | \
+ (R300_SWIZZLE_SELECT_W << R300_SWIZZLE_SELECT_W_SHIFT) | \
+ (0xf << R300_WRITE_ENA_SHIFT))
+
#define R300_VAP_PROG_STREAM_CNTL_EXT_1 0x21e4
#define R300_VAP_PROG_STREAM_CNTL_EXT_2 0x21e8
#define R300_VAP_PROG_STREAM_CNTL_EXT_3 0x21ec
@@ -732,8 +748,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R500_RS_IP_TEX_PTR_Q_SHIFT 18
#define R500_RS_IP_COL_PTR_SHIFT 24
#define R500_RS_IP_COL_FMT_SHIFT 27
-# define R500_RS_COL_PTR(x) (x << 24)
-# define R500_RS_COL_FMT(x) (x << 27)
+# define R500_RS_SEL_S(x) ((x) << 0)
+# define R500_RS_SEL_T(x) ((x) << 6)
+# define R500_RS_SEL_R(x) ((x) << 12)
+# define R500_RS_SEL_Q(x) ((x) << 18)
+# define R500_RS_COL_PTR(x) ((x) << 24)
+# define R500_RS_COL_FMT(x) ((x) << 27)
/* gap */
#define R500_RS_IP_OFFSET_DIS (0 << 31)
#define R500_RS_IP_OFFSET_EN (1 << 31)
@@ -1019,20 +1039,27 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_THIRD (2 << 16)
# define R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST (3 << 16)
-/** TODO: might be candidate for removal */
-# define R300_RE_SHADE_MODEL_SMOOTH ( \
- R300_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA0_SHADING_GOURAUD | \
- R300_GA_COLOR_CONTROL_RGB1_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
- R300_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD | \
- R300_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
- R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
-/** TODO: might be candidate for removal, the GOURAUD stuff also looks buggy to me */
-# define R300_RE_SHADE_MODEL_FLAT ( \
- R300_GA_COLOR_CONTROL_RGB0_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA0_SHADING_FLAT | \
- R300_GA_COLOR_CONTROL_RGB1_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
- R300_GA_COLOR_CONTROL_RGB2_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT | \
- R300_GA_COLOR_CONTROL_RGB3_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
- R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
+# define R300_SHADE_MODEL_FLAT ( \
+ R300_GA_COLOR_CONTROL_RGB0_SHADING_FLAT | \
+ R300_GA_COLOR_CONTROL_ALPHA0_SHADING_FLAT | \
+ R300_GA_COLOR_CONTROL_RGB1_SHADING_FLAT | \
+ R300_GA_COLOR_CONTROL_ALPHA1_SHADING_FLAT | \
+ R300_GA_COLOR_CONTROL_RGB2_SHADING_FLAT | \
+ R300_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT | \
+ R300_GA_COLOR_CONTROL_RGB3_SHADING_FLAT | \
+ R300_GA_COLOR_CONTROL_ALPHA3_SHADING_FLAT | \
+ R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
+
+# define R300_SHADE_MODEL_SMOOTH ( \
+ R300_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD | \
+ R300_GA_COLOR_CONTROL_ALPHA0_SHADING_GOURAUD | \
+ R300_GA_COLOR_CONTROL_RGB1_SHADING_GOURAUD | \
+ R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
+ R300_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD | \
+ R300_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD | \
+ R300_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD | \
+ R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
+ R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
/* Specifies red & green components of fill color -- S312 format -- Backwards comp. */
#define R300_GA_SOLID_RG 0x427c
@@ -1146,6 +1173,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_W_ADDR_MASK 0x0003f000
# define R300_HIRES_DIS (0 << 18)
# define R300_HIRES_EN (1 << 18)
+# define R300_IT_COUNT(x) ((x) << 0)
+# define R300_IC_COUNT(x) ((x) << 7)
+# define R300_W_COUNT(x) ((x) << 12)
#define R300_RS_INST_COUNT 0x4304
# define R300_RS_INST_COUNT_SHIFT 0
@@ -1175,8 +1205,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_RS_INTERP_SRC_SHIFT 2 /* TODO: check for removal */
# define R300_RS_INTERP_SRC_MASK (7 << 2) /* TODO: check for removal */
# define R300_RS_TEX_PTR(x) (x << 0)
-# define R300_RS_COL_PTR(x) (x << 6)
-# define R300_RS_COL_FMT(x) (x << 9)
+# define R300_RS_COL_PTR(x) ((x) << 6)
+# define R300_RS_COL_FMT(x) ((x) << 9)
# define R300_RS_COL_FMT_RGBA 0
# define R300_RS_COL_FMT_RGB0 1
# define R300_RS_COL_FMT_RGB1 2
@@ -1186,10 +1216,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_RS_COL_FMT_111A 8
# define R300_RS_COL_FMT_1110 9
# define R300_RS_COL_FMT_1111 10
-# define R300_RS_SEL_S(x) (x << 13)
-# define R300_RS_SEL_T(x) (x << 16)
-# define R300_RS_SEL_R(x) (x << 19)
-# define R300_RS_SEL_Q(x) (x << 22)
+# define R300_RS_SEL_S(x) ((x) << 13)
+# define R300_RS_SEL_T(x) ((x) << 16)
+# define R300_RS_SEL_R(x) ((x) << 19)
+# define R300_RS_SEL_Q(x) ((x) << 22)
# define R300_RS_SEL_C0 0
# define R300_RS_SEL_C1 1
# define R300_RS_SEL_C2 2
@@ -1216,14 +1246,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R500_RS_INST_14 0x4358
#define R500_RS_INST_15 0x435c
#define R500_RS_INST_TEX_ID_SHIFT 0
+# define R500_RS_INST_TEX_ID(x) ((x) << 0)
#define R500_RS_INST_TEX_CN_WRITE (1 << 4)
#define R500_RS_INST_TEX_ADDR_SHIFT 5
+# define R500_RS_INST_TEX_ADDR(x) ((x) << 0)
#define R500_RS_INST_COL_ID_SHIFT 12
+# define R500_RS_INST_COL_ID(x) ((x) << 12)
#define R500_RS_INST_COL_CN_NO_WRITE (0 << 16)
#define R500_RS_INST_COL_CN_WRITE (1 << 16)
#define R500_RS_INST_COL_CN_WRITE_FBUFFER (2 << 16)
#define R500_RS_INST_COL_CN_WRITE_BACKFACE (3 << 16)
#define R500_RS_INST_COL_ADDR_SHIFT 18
+# define R500_RS_INST_COL_ADDR(x) ((x) << 18)
#define R500_RS_INST_TEX_ADJ (1 << 25)
#define R500_RS_INST_W_CN (1 << 26)
@@ -1240,9 +1274,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R300_RS_INST_7 0x434C
# define R300_RS_INST_TEX_ID(x) ((x) << 0)
# define R300_RS_INST_TEX_CN_WRITE (1 << 3)
+# define R300_RS_INST_TEX_ADDR(x) ((x) << 6)
# define R300_RS_INST_TEX_ADDR_SHIFT 6
# define R300_RS_INST_COL_ID(x) ((x) << 11)
# define R300_RS_INST_COL_CN_WRITE (1 << 14)
+# define R300_RS_INST_COL_ADDR(x) ((x) << 17)
# define R300_RS_INST_COL_ADDR_SHIFT 17
# define R300_RS_INST_TEX_ADJ (1 << 22)
# define R300_RS_COL_BIAS_UNUSED_SHIFT 23
@@ -1411,18 +1447,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R500_MACRO_SWITCH (1<<22)
# define R500_BORDER_FIX (1<<31)
-#define R300_TX_SIZE_0 0x4480
+#define R300_TX_FORMAT0_0 0x4480
# define R300_TX_WIDTHMASK_SHIFT 0
# define R300_TX_WIDTHMASK_MASK (2047 << 0)
# define R300_TX_HEIGHTMASK_SHIFT 11
# define R300_TX_HEIGHTMASK_MASK (2047 << 11)
-# define R300_TX_DEPTHMASK_SHIFT 22
-# define R300_TX_DEPTHMASK_MASK (0xf << 22)
+# define R300_TX_DEPTHMASK_SHIFT 22
+# define R300_TX_DEPTHMASK_MASK (0xf << 22)
# define R300_TX_MAX_MIP_LEVEL_SHIFT 26
# define R300_TX_MAX_MIP_LEVEL_MASK (0xf << 26)
-# define R300_TX_SIZE_PROJECTED (1<<30)
-# define R300_TX_SIZE_TXPITCH_EN (1<<31)
-#define R300_TX_FORMAT_0 0x44C0
+# define R300_TX_SIZE_PROJECTED (1 << 30)
+# define R300_TX_PITCH_EN (1 << 31)
+# define R300_TX_WIDTH(x) ((x) << 0)
+# define R300_TX_HEIGHT(x) ((x) << 11)
+
+#define R300_TX_FORMAT1_0 0x44C0
/* The interpretation of the format word by Wladimir van der Laan */
/* The X, Y, Z and W refer to the layout of the components.
They are given meanings as R, G, B and Alpha by the swizzle
@@ -1708,7 +1747,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_C3_SEL_R (1 << 14)
# define R300_C3_SEL_G (2 << 14)
# define R300_C3_SEL_B (3 << 14)
-# define R300_OUT_SIGN(x) (x << 16)
+# define R300_OUT_SIGN(x) ((x) << 16)
+# define R500_ROUND_ADJ (1 << 20)
/* ALU
* The ALU instructions register blocks are enumerated according to the order
@@ -1795,6 +1835,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_ALU_DSTC_OUTPUT_X (1 << 26)
# define R300_ALU_DSTC_OUTPUT_Y (1 << 27)
# define R300_ALU_DSTC_OUTPUT_Z (1 << 28)
+# define R300_ALU_DSTC_OUTPUT_XYZ (7 << 26)
+# define R300_RGB_ADDR0(x) ((x) << 0)
+# define R300_RGB_ADDR1(x) ((x) << 6)
+# define R300_RGB_ADDR2(x) ((x) << 12)
#define R300_US_ALU_ALPHA_ADDR_0 0x47C0
# define R300_ALU_SRC0A_SHIFT 0
@@ -1812,6 +1856,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_ALU_DSTA_REG (1 << 23)
# define R300_ALU_DSTA_OUTPUT (1 << 24)
# define R300_ALU_DSTA_DEPTH (1 << 27)
+# define R300_ALPHA_ADDR0(x) ((x) << 0)
+# define R300_ALPHA_ADDR1(x) ((x) << 6)
+# define R300_ALPHA_ADDR2(x) ((x) << 12)
#define R300_US_ALU_RGB_INST_0 0x48C0
# define R300_ALU_ARGC_SRC0C_XYZ 0
@@ -1846,6 +1893,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_ALU_ARGC_SRC0CA_WZY 29
# define R300_ALU_ARGC_SRC1CA_WZY 30
# define R300_ALU_ARGC_SRC2CA_WZY 31
+# define R300_RGB_SWIZA(x) ((x) << 0)
+# define R300_RGB_SWIZB(x) ((x) << 7)
+# define R300_RGB_SWIZC(x) ((x) << 14)
# define R300_ALU_ARG0C_SHIFT 0
# define R300_ALU_ARG0C_MASK (31 << 0)
@@ -1909,10 +1959,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_ALU_ARGA_SRCP_Y 13
# define R300_ALU_ARGA_SRCP_Z 14
# define R300_ALU_ARGA_SRCP_W 15
-
# define R300_ALU_ARGA_ZERO 16
# define R300_ALU_ARGA_ONE 17
# define R300_ALU_ARGA_HALF 18
+# define R300_ALPHA_SWIZA(x) ((x) << 0)
+# define R300_ALPHA_SWIZB(x) ((x) << 7)
+# define R300_ALPHA_SWIZC(x) ((x) << 14)
+
# define R300_ALU_ARG0A_SHIFT 0
# define R300_ALU_ARG0A_MASK (31 << 0)
# define R300_ALU_ARG0A_NOP (0 << 5)
@@ -2731,7 +2784,7 @@ enum {
# define R500_ALPHA_OP_COS 13
# define R500_ALPHA_OP_MDH 14
# define R500_ALPHA_OP_MDV 15
-# define R500_ALPHA_ADDRD(x) (x << 4)
+# define R500_ALPHA_ADDRD(x) ((x) << 4)
# define R500_ALPHA_ADDRD_REL (1 << 11)
# define R500_ALPHA_SEL_A_SHIFT 12
# define R500_ALPHA_SEL_A_SRC0 (0 << 12)
@@ -2775,16 +2828,16 @@ enum {
# define R500_ALPHA_OMOD_DIV_4 (5 << 26)
# define R500_ALPHA_OMOD_DIV_8 (6 << 26)
# define R500_ALPHA_OMOD_DISABLE (7 << 26)
-# define R500_ALPHA_TARGET(x) (x << 29)
+# define R500_ALPHA_TARGET(x) ((x) << 29)
# define R500_ALPHA_W_OMASK (1 << 31)
#define R500_US_ALU_ALPHA_ADDR_0 0x9800
-# define R500_ALPHA_ADDR0(x) (x << 0)
+# define R500_ALPHA_ADDR0(x) ((x) << 0)
# define R500_ALPHA_ADDR0_CONST (1 << 8)
# define R500_ALPHA_ADDR0_REL (1 << 9)
-# define R500_ALPHA_ADDR1(x) (x << 10)
+# define R500_ALPHA_ADDR1(x) ((x) << 10)
# define R500_ALPHA_ADDR1_CONST (1 << 18)
# define R500_ALPHA_ADDR1_REL (1 << 19)
-# define R500_ALPHA_ADDR2(x) (x << 20)
+# define R500_ALPHA_ADDR2(x) ((x) << 20)
# define R500_ALPHA_ADDR2_CONST (1 << 28)
# define R500_ALPHA_ADDR2_REL (1 << 29)
# define R500_ALPHA_SRCP_OP_1_MINUS_2A0 (0 << 30)
@@ -2805,7 +2858,7 @@ enum {
# define R500_ALU_RGBA_OP_SOP (10 << 0)
# define R500_ALU_RGBA_OP_MDH (11 << 0)
# define R500_ALU_RGBA_OP_MDV (12 << 0)
-# define R500_ALU_RGBA_ADDRD(x) (x << 4)
+# define R500_ALU_RGBA_ADDRD(x) ((x) << 4)
# define R500_ALU_RGBA_ADDRD_REL (1 << 11)
# define R500_ALU_RGBA_SEL_C_SHIFT 12
# define R500_ALU_RGBA_SEL_C_SRC0 (0 << 12)
@@ -2932,16 +2985,16 @@ enum {
# define R500_ALU_RGB_OMOD_DIV_4 (5 << 26)
# define R500_ALU_RGB_OMOD_DIV_8 (6 << 26)
# define R500_ALU_RGB_OMOD_DISABLE (7 << 26)
-# define R500_ALU_RGB_TARGET(x) (x << 29)
+# define R500_ALU_RGB_TARGET(x) ((x) << 29)
# define R500_ALU_RGB_WMASK (1 << 31)
#define R500_US_ALU_RGB_ADDR_0 0x9000
-# define R500_RGB_ADDR0(x) (x << 0)
+# define R500_RGB_ADDR0(x) ((x) << 0)
# define R500_RGB_ADDR0_CONST (1 << 8)
# define R500_RGB_ADDR0_REL (1 << 9)
-# define R500_RGB_ADDR1(x) (x << 10)
+# define R500_RGB_ADDR1(x) ((x) << 10)
# define R500_RGB_ADDR1_CONST (1 << 18)
# define R500_RGB_ADDR1_REL (1 << 19)
-# define R500_RGB_ADDR2(x) (x << 20)
+# define R500_RGB_ADDR2(x) ((x) << 20)
# define R500_RGB_ADDR2_CONST (1 << 28)
# define R500_RGB_ADDR2_REL (1 << 29)
# define R500_RGB_SRCP_OP_1_MINUS_2RGB0 (0 << 30)
@@ -2973,6 +3026,7 @@ enum {
# define R500_INST_RGB_OMASK_R (1 << 15)
# define R500_INST_RGB_OMASK_G (1 << 16)
# define R500_INST_RGB_OMASK_B (1 << 17)
+# define R500_INST_RGB_OMASK_RGB (7 << 15)
# define R500_INST_ALPHA_OMASK (1 << 18)
# define R500_INST_RGB_CLAMP (1 << 19)
# define R500_INST_ALPHA_CLAMP (1 << 20)
@@ -2996,19 +3050,19 @@ enum {
/* note that these are 8 bit lengths, despite the offsets, at least for R500 */
#define R500_US_CODE_ADDR 0x4630
-# define R500_US_CODE_START_ADDR(x) (x << 0)
-# define R500_US_CODE_END_ADDR(x) (x << 16)
+# define R500_US_CODE_START_ADDR(x) ((x) << 0)
+# define R500_US_CODE_END_ADDR(x) ((x) << 16)
#define R500_US_CODE_OFFSET 0x4638
-# define R500_US_CODE_OFFSET_ADDR(x) (x << 0)
+# define R500_US_CODE_OFFSET_ADDR(x) ((x) << 0)
#define R500_US_CODE_RANGE 0x4634
-# define R500_US_CODE_RANGE_ADDR(x) (x << 0)
-# define R500_US_CODE_RANGE_SIZE(x) (x << 16)
+# define R500_US_CODE_RANGE_ADDR(x) ((x) << 0)
+# define R500_US_CODE_RANGE_SIZE(x) ((x) << 16)
#define R500_US_CONFIG 0x4600
# define R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO (1 << 1)
#define R500_US_FC_ADDR_0 0xa000
-# define R500_FC_BOOL_ADDR(x) (x << 0)
-# define R500_FC_INT_ADDR(x) (x << 8)
-# define R500_FC_JUMP_ADDR(x) (x << 16)
+# define R500_FC_BOOL_ADDR(x) ((x) << 0)
+# define R500_FC_INT_ADDR(x) ((x) << 8)
+# define R500_FC_JUMP_ADDR(x) ((x) << 16)
# define R500_FC_JUMP_GLOBAL (1 << 31)
#define R500_US_FC_BOOL_CONST 0x4620
# define R500_FC_KBOOL(x) (x)
@@ -3029,8 +3083,8 @@ enum {
# define R500_FC_A_OP_NONE (0 << 6)
# define R500_FC_A_OP_POP (1 << 6)
# define R500_FC_A_OP_PUSH (2 << 6)
-# define R500_FC_JUMP_FUNC(x) (x << 8)
-# define R500_FC_B_POP_CNT(x) (x << 16)
+# define R500_FC_JUMP_FUNC(x) ((x) << 8)
+# define R500_FC_B_POP_CNT(x) ((x) << 16)
# define R500_FC_B_OP0_NONE (0 << 24)
# define R500_FC_B_OP0_DECR (1 << 24)
# define R500_FC_B_OP0_INCR (2 << 24)
@@ -3039,60 +3093,18 @@ enum {
# define R500_FC_B_OP1_INCR (2 << 26)
# define R500_FC_IGNORE_UNCOVERED (1 << 28)
#define R500_US_FC_INT_CONST_0 0x4c00
-# define R500_FC_INT_CONST_KR(x) (x << 0)
-# define R500_FC_INT_CONST_KG(x) (x << 8)
-# define R500_FC_INT_CONST_KB(x) (x << 16)
+# define R500_FC_INT_CONST_KR(x) ((x) << 0)
+# define R500_FC_INT_CONST_KG(x) ((x) << 8)
+# define R500_FC_INT_CONST_KB(x) ((x) << 16)
/* _0 through _15 */
#define R500_US_FORMAT0_0 0x4640
-# define R500_FORMAT_TXWIDTH(x) (x << 0)
-# define R500_FORMAT_TXHEIGHT(x) (x << 11)
-# define R500_FORMAT_TXDEPTH(x) (x << 22)
-/* _0 through _3 */
-#define R500_US_OUT_FMT_0 0x46A4
-# define R500_OUT_FMT_C4_8 (0 << 0)
-# define R500_OUT_FMT_C4_10 (1 << 0)
-# define R500_OUT_FMT_C4_10_GAMMA (2 << 0)
-# define R500_OUT_FMT_C_16 (3 << 0)
-# define R500_OUT_FMT_C2_16 (4 << 0)
-# define R500_OUT_FMT_C4_16 (5 << 0)
-# define R500_OUT_FMT_C_16_MPEG (6 << 0)
-# define R500_OUT_FMT_C2_16_MPEG (7 << 0)
-# define R500_OUT_FMT_C2_4 (8 << 0)
-# define R500_OUT_FMT_C_3_3_2 (9 << 0)
-# define R500_OUT_FMT_C_6_5_6 (10 << 0)
-# define R500_OUT_FMT_C_11_11_10 (11 << 0)
-# define R500_OUT_FMT_C_10_11_11 (12 << 0)
-# define R500_OUT_FMT_C_2_10_10_10 (13 << 0)
-/* #define R500_OUT_FMT_RESERVED (14 << 0) */
-# define R500_OUT_FMT_UNUSED (15 << 0)
-# define R500_OUT_FMT_C_16_FP (16 << 0)
-# define R500_OUT_FMT_C2_16_FP (17 << 0)
-# define R500_OUT_FMT_C4_16_FP (18 << 0)
-# define R500_OUT_FMT_C_32_FP (19 << 0)
-# define R500_OUT_FMT_C2_32_FP (20 << 0)
-# define R500_OUT_FMT_C4_32_FP (21 << 0)
-# define R500_C0_SEL_A (0 << 8)
-# define R500_C0_SEL_R (1 << 8)
-# define R500_C0_SEL_G (2 << 8)
-# define R500_C0_SEL_B (3 << 8)
-# define R500_C1_SEL_A (0 << 10)
-# define R500_C1_SEL_R (1 << 10)
-# define R500_C1_SEL_G (2 << 10)
-# define R500_C1_SEL_B (3 << 10)
-# define R500_C2_SEL_A (0 << 12)
-# define R500_C2_SEL_R (1 << 12)
-# define R500_C2_SEL_G (2 << 12)
-# define R500_C2_SEL_B (3 << 12)
-# define R500_C3_SEL_A (0 << 14)
-# define R500_C3_SEL_R (1 << 14)
-# define R500_C3_SEL_G (2 << 14)
-# define R500_C3_SEL_B (3 << 14)
-# define R500_OUT_SIGN(x) (x << 16)
-# define R500_ROUND_ADJ (1 << 20)
+# define R500_FORMAT_TXWIDTH(x) ((x) << 0)
+# define R500_FORMAT_TXHEIGHT(x) ((x) << 11)
+# define R500_FORMAT_TXDEPTH(x) ((x) << 22)
#define R500_US_PIXSIZE 0x4604
# define R500_PIX_SIZE(x) (x)
#define R500_US_TEX_ADDR_0 0x9800
-# define R500_TEX_SRC_ADDR(x) (x << 0)
+# define R500_TEX_SRC_ADDR(x) ((x) << 0)
# define R500_TEX_SRC_ADDR_REL (1 << 7)
# define R500_TEX_SRC_S_SWIZ_R (0 << 8)
# define R500_TEX_SRC_S_SWIZ_G (1 << 8)
@@ -3110,7 +3122,7 @@ enum {
# define R500_TEX_SRC_Q_SWIZ_G (1 << 14)
# define R500_TEX_SRC_Q_SWIZ_B (2 << 14)
# define R500_TEX_SRC_Q_SWIZ_A (3 << 14)
-# define R500_TEX_DST_ADDR(x) (x << 16)
+# define R500_TEX_DST_ADDR(x) ((x) << 16)
# define R500_TEX_DST_ADDR_REL (1 << 23)
# define R500_TEX_DST_R_SWIZ_R (0 << 24)
# define R500_TEX_DST_R_SWIZ_G (1 << 24)
@@ -3129,7 +3141,7 @@ enum {
# define R500_TEX_DST_A_SWIZ_B (2 << 30)
# define R500_TEX_DST_A_SWIZ_A (3 << 30)
#define R500_US_TEX_ADDR_DXDY_0 0xa000
-# define R500_DX_ADDR(x) (x << 0)
+# define R500_DX_ADDR(x) ((x) << 0)
# define R500_DX_ADDR_REL (1 << 7)
# define R500_DX_S_SWIZ_R (0 << 8)
# define R500_DX_S_SWIZ_G (1 << 8)
@@ -3147,7 +3159,7 @@ enum {
# define R500_DX_Q_SWIZ_G (1 << 14)
# define R500_DX_Q_SWIZ_B (2 << 14)
# define R500_DX_Q_SWIZ_A (3 << 14)
-# define R500_DY_ADDR(x) (x << 16)
+# define R500_DY_ADDR(x) ((x) << 16)
# define R500_DY_ADDR_REL (1 << 17)
# define R500_DY_S_SWIZ_R (0 << 24)
# define R500_DY_S_SWIZ_G (1 << 24)
@@ -3166,7 +3178,7 @@ enum {
# define R500_DY_Q_SWIZ_B (2 << 30)
# define R500_DY_Q_SWIZ_A (3 << 30)
#define R500_US_TEX_INST_0 0x9000
-# define R500_TEX_ID(x) (x << 16)
+# define R500_TEX_ID(x) ((x) << 16)
# define R500_TEX_INST_NOP (0 << 22)
# define R500_TEX_INST_LD (1 << 22)
# define R500_TEX_INST_TEXKILL (2 << 22)
@@ -3227,9 +3239,9 @@ enum {
#define R300_PACKET3_3D_LOAD_VBPNTR 0x00002F00
#define R300_PACKET3_INDX_BUFFER 0x00003300
-# define R300_EB_UNK1_SHIFT 24
-# define R300_EB_UNK1 (0x80<<24)
-# define R300_EB_UNK2 0x0810
+# define R300_INDX_BUFFER_DST_SHIFT 0
+# define R300_INDX_BUFFER_SKIP_SHIFT 16
+# define R300_INDX_BUFFER_ONE_REG_WR (1<<31)
/* Same as R300_PACKET3_3D_DRAW_VBUF but without VAP_VTX_FMT */
#define R300_PACKET3_3D_DRAW_VBUF_2 0x00003400
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 8ed66a1660..d2c5998c26 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -50,6 +50,7 @@ static const char* chip_families[] = {
"RC410",
"RS480",
"RS482",
+ "RS600",
"RS690",
"RS740",
"RV515",
@@ -100,11 +101,9 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
/* IN THEORY */
return 0;
case PIPE_CAP_MAX_RENDER_TARGETS:
- /* XXX 4 eventually */
- return 1;
+ return 4;
case PIPE_CAP_OCCLUSION_QUERY:
- /* IN THEORY */
- return 0;
+ return 1;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
/* IN THEORY */
return 0;
@@ -121,7 +120,7 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
* shows why this is silly. Assuming RGBA, 4cpp, we can see that
* 4096*4096*4096 = 64.0 GiB exactly, so it's not exactly
* practical. However, if at some point a game really wants this,
- * then we can remove this limit. */
+ * then we can remove or raise this limit. */
if (r300screen->caps->is_r500) {
/* 9 == 256x256x256 */
return 9;
@@ -142,7 +141,7 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
return 1;
case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
- /* XXX guessing */
+ /* XXX guessing (what a terrible guess) */
return 2;
default:
debug_printf("r300: Implementation error: Bad param %d\n",
@@ -175,15 +174,44 @@ static float r300_get_paramf(struct pipe_screen* pscreen, int param)
}
}
-/* XXX moar formats */
-static boolean check_tex_2d_format(enum pipe_format format)
+static boolean check_tex_2d_format(enum pipe_format format, boolean is_r500)
{
switch (format) {
+ /* Colorbuffer */
+ case PIPE_FORMAT_A4R4G4B4_UNORM:
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ case PIPE_FORMAT_A1R5G5B5_UNORM:
case PIPE_FORMAT_A8R8G8B8_UNORM:
+ /* Colorbuffer or texture */
case PIPE_FORMAT_I8_UNORM:
+ /* Z buffer */
+ case PIPE_FORMAT_Z16_UNORM:
+ /* Z buffer with stencil */
+ case PIPE_FORMAT_Z24S8_UNORM:
return TRUE;
+
+ /* XXX These don't even exist
+ case PIPE_FORMAT_A32R32G32B32:
+ case PIPE_FORMAT_A16R16G16B16: */
+ /* XXX Insert YUV422 packed VYUY and YVYU here */
+ /* XXX What the deuce is UV88? (r3xx accel page 14)
+ debug_printf("r300: Warning: Got unimplemented format: %s in %s\n",
+ pf_name(format), __FUNCTION__);
+ return FALSE; */
+
+ /* XXX Supported yet unimplemented r5xx formats: */
+ /* XXX Again, what is UV1010 this time? (r5xx accel page 148) */
+ /* XXX Even more that don't exist
+ case PIPE_FORMAT_A10R10G10B10_UNORM:
+ case PIPE_FORMAT_A2R10G10B10_UNORM:
+ case PIPE_FORMAT_I10_UNORM:
+ debug_printf(
+ "r300: Warning: Got unimplemented r500 format: %s in %s\n",
+ pf_name(format), __FUNCTION__);
+ return FALSE; */
+
default:
- debug_printf("r300: Warning: Got unknown format: %s, in %s\n",
+ debug_printf("r300: Warning: Got unsupported format: %s in %s\n",
pf_name(format), __FUNCTION__);
break;
}
@@ -200,7 +228,8 @@ static boolean r300_is_format_supported(struct pipe_screen* pscreen,
{
switch (target) {
case PIPE_TEXTURE_2D:
- return check_tex_2d_format(format);
+ return check_tex_2d_format(format,
+ r300_screen(pscreen)->caps->is_r500);
default:
debug_printf("r300: Warning: Got unknown format target: %d\n",
format);
@@ -210,24 +239,84 @@ static boolean r300_is_format_supported(struct pipe_screen* pscreen,
return FALSE;
}
-static void* r300_surface_map(struct pipe_screen* screen,
- struct pipe_surface* surface,
- unsigned flags)
+static struct pipe_transfer*
+r300_get_tex_transfer(struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level, unsigned zslice,
+ enum pipe_transfer_usage usage, unsigned x, unsigned y,
+ unsigned w, unsigned h)
+{
+ struct r300_texture *tex = (struct r300_texture *)texture;
+ struct r300_transfer *trans;
+ unsigned offset; /* in bytes */
+
+ /* XXX Add support for these things */
+ if (texture->target == PIPE_TEXTURE_CUBE) {
+ debug_printf("PIPE_TEXTURE_CUBE is not yet supported.\n");
+ /* offset = tex->image_offset[level][face]; */
+ }
+ else if (texture->target == PIPE_TEXTURE_3D) {
+ debug_printf("PIPE_TEXTURE_3D is not yet supported.\n");
+ /* offset = tex->image_offset[level][zslice]; */
+ }
+ else {
+ offset = tex->offset[level];
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+
+ trans = CALLOC_STRUCT(r300_transfer);
+ if (trans) {
+ pipe_texture_reference(&trans->transfer.texture, texture);
+ trans->transfer.format = trans->transfer.format;
+ trans->transfer.width = w;
+ trans->transfer.height = h;
+ trans->transfer.block = texture->block;
+ trans->transfer.nblocksx = texture->nblocksx[level];
+ trans->transfer.nblocksy = texture->nblocksy[level];
+ trans->transfer.stride = tex->stride;
+ trans->transfer.usage = usage;
+ trans->offset = offset;
+ }
+ return &trans->transfer;
+}
+
+static void
+r300_tex_transfer_destroy(struct pipe_transfer *trans)
{
- struct r300_texture* tex = (struct r300_texture*)surface->texture;
- char* map = pipe_buffer_map(screen, tex->buffer, flags);
+ pipe_texture_reference(&trans->texture, NULL);
+ FREE(trans);
+}
+
+static void* r300_transfer_map(struct pipe_screen* screen,
+ struct pipe_transfer* transfer)
+{
+ struct r300_texture* tex = (struct r300_texture*)transfer->texture;
+ char* map;
+ unsigned flags = 0;
+
+ if (transfer->usage != PIPE_TRANSFER_WRITE) {
+ flags |= PIPE_BUFFER_USAGE_CPU_READ;
+ }
+ if (transfer->usage != PIPE_TRANSFER_READ) {
+ flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+ }
+
+ map = pipe_buffer_map(screen, tex->buffer, flags);
if (!map) {
return NULL;
}
- return map + surface->offset;
+ return map + r300_transfer(transfer)->offset +
+ transfer->y / transfer->block.height * transfer->stride +
+ transfer->x / transfer->block.width * transfer->block.size;
}
-static void r300_surface_unmap(struct pipe_screen* screen,
- struct pipe_surface* surface)
+static void r300_transfer_unmap(struct pipe_screen* screen,
+ struct pipe_transfer* transfer)
{
- struct r300_texture* tex = (struct r300_texture*)surface->texture;
+ struct r300_texture* tex = (struct r300_texture*)transfer->texture;
pipe_buffer_unmap(screen, tex->buffer);
}
@@ -239,8 +328,7 @@ static void r300_destroy_screen(struct pipe_screen* pscreen)
FREE(r300screen);
}
-struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys,
- struct r300_winsys* r300_winsys)
+struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys)
{
struct r300_screen* r300screen = CALLOC_STRUCT(r300_screen);
struct r300_capabilities* caps = CALLOC_STRUCT(r300_capabilities);
@@ -254,15 +342,17 @@ struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys,
r300_parse_chipset(caps);
r300screen->caps = caps;
- r300screen->screen.winsys = winsys;
+ r300screen->screen.winsys = (struct pipe_winsys*)r300_winsys;
r300screen->screen.destroy = r300_destroy_screen;
r300screen->screen.get_name = r300_get_name;
r300screen->screen.get_vendor = r300_get_vendor;
r300screen->screen.get_param = r300_get_param;
r300screen->screen.get_paramf = r300_get_paramf;
r300screen->screen.is_format_supported = r300_is_format_supported;
- r300screen->screen.surface_map = r300_surface_map;
- r300screen->screen.surface_unmap = r300_surface_unmap;
+ r300screen->screen.get_tex_transfer = r300_get_tex_transfer;
+ r300screen->screen.tex_transfer_destroy = r300_tex_transfer_destroy;
+ r300screen->screen.transfer_map = r300_transfer_map;
+ r300screen->screen.transfer_unmap = r300_transfer_unmap;
r300_init_screen_texture_functions(&r300screen->screen);
u_simple_screen_init(&r300screen->screen);
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
index 2e25f61dbf..3f52dbc3be 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -40,13 +40,27 @@ struct r300_screen {
struct r300_capabilities* caps;
};
+struct r300_transfer {
+ /* Parent class */
+ struct pipe_transfer transfer;
+
+ /* Offset from start of buffer. */
+ unsigned offset;
+};
+
/* Convenience cast wrapper. */
static struct r300_screen* r300_screen(struct pipe_screen* screen) {
return (struct r300_screen*)screen;
}
+/* Convenience cast wrapper. */
+static INLINE struct r300_transfer*
+r300_transfer(struct pipe_transfer* transfer)
+{
+ return (struct r300_transfer*)transfer;
+}
+
/* Creates a new r300 screen. */
-struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys,
- struct r300_winsys* r300_winsys);
+struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys);
#endif /* R300_SCREEN_H */
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 9392d72342..58bce22fc8 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -22,92 +22,17 @@
#include "util/u_math.h"
#include "util/u_pack_color.h"
-#include "pipe/p_debug.h"
+
+#include "util/u_debug.h"
+#include "pipe/internal/p_winsys_screen.h"
#include "r300_context.h"
#include "r300_reg.h"
+#include "r300_state_inlines.h"
+#include "r300_state_shader.h"
/* r300_state: Functions used to intialize state context by translating
- * Gallium state objects into semi-native r300 state objects.
- *
- * XXX break this file up into pieces if it gets too big! */
-
-/* Pack a float into a dword. */
-static uint32_t pack_float_32(float f)
-{
- union {
- float f;
- uint32_t u;
- } u;
-
- u.f = f;
- return u.u;
-}
-
-static uint32_t translate_blend_function(int blend_func) {
- switch (blend_func) {
- case PIPE_BLEND_ADD:
- return R300_COMB_FCN_ADD_CLAMP;
- case PIPE_BLEND_SUBTRACT:
- return R300_COMB_FCN_SUB_CLAMP;
- case PIPE_BLEND_REVERSE_SUBTRACT:
- return R300_COMB_FCN_RSUB_CLAMP;
- case PIPE_BLEND_MIN:
- return R300_COMB_FCN_MIN;
- case PIPE_BLEND_MAX:
- return R300_COMB_FCN_MAX;
- default:
- debug_printf("r300: Unknown blend function %d\n", blend_func);
- break;
- }
- return 0;
-}
-
-/* XXX we can also offer the D3D versions of some of these... */
-static uint32_t translate_blend_factor(int blend_fact) {
- switch (blend_fact) {
- case PIPE_BLENDFACTOR_ONE:
- return R300_BLEND_GL_ONE;
- case PIPE_BLENDFACTOR_SRC_COLOR:
- return R300_BLEND_GL_SRC_COLOR;
- case PIPE_BLENDFACTOR_SRC_ALPHA:
- return R300_BLEND_GL_SRC_ALPHA;
- case PIPE_BLENDFACTOR_DST_ALPHA:
- return R300_BLEND_GL_DST_ALPHA;
- case PIPE_BLENDFACTOR_DST_COLOR:
- return R300_BLEND_GL_DST_COLOR;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
- return R300_BLEND_GL_SRC_ALPHA_SATURATE;
- case PIPE_BLENDFACTOR_CONST_COLOR:
- return R300_BLEND_GL_CONST_COLOR;
- case PIPE_BLENDFACTOR_CONST_ALPHA:
- return R300_BLEND_GL_CONST_ALPHA;
- /* XXX WTF are these?
- case PIPE_BLENDFACTOR_SRC1_COLOR:
- case PIPE_BLENDFACTOR_SRC1_ALPHA: */
- case PIPE_BLENDFACTOR_ZERO:
- return R300_BLEND_GL_ZERO;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR:
- return R300_BLEND_GL_ONE_MINUS_SRC_COLOR;
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
- return R300_BLEND_GL_ONE_MINUS_SRC_ALPHA;
- case PIPE_BLENDFACTOR_INV_DST_ALPHA:
- return R300_BLEND_GL_ONE_MINUS_DST_ALPHA;
- case PIPE_BLENDFACTOR_INV_DST_COLOR:
- return R300_BLEND_GL_ONE_MINUS_DST_COLOR;
- case PIPE_BLENDFACTOR_INV_CONST_COLOR:
- return R300_BLEND_GL_ONE_MINUS_CONST_COLOR;
- case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- return R300_BLEND_GL_ONE_MINUS_CONST_ALPHA;
- /* XXX see above
- case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
- case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: */
- default:
- debug_printf("r300: Unknown blend factor %d\n", blend_fact);
- break;
- }
- return 0;
-}
+ * Gallium state objects into semi-native r300 state objects. */
/* Create a new blend state based on the CSO blend state.
*
@@ -123,16 +48,16 @@ static void* r300_create_blend_state(struct pipe_context* pipe,
blend->blend_control = R300_ALPHA_BLEND_ENABLE |
R300_SEPARATE_ALPHA_ENABLE |
R300_READ_ENABLE |
- translate_blend_function(state->rgb_func) |
- (translate_blend_factor(state->rgb_src_factor) <<
+ r300_translate_blend_function(state->rgb_func) |
+ (r300_translate_blend_factor(state->rgb_src_factor) <<
R300_SRC_BLEND_SHIFT) |
- (translate_blend_factor(state->rgb_dst_factor) <<
+ (r300_translate_blend_factor(state->rgb_dst_factor) <<
R300_DST_BLEND_SHIFT);
blend->alpha_blend_control =
- translate_blend_function(state->alpha_func) |
- (translate_blend_factor(state->alpha_src_factor) <<
+ r300_translate_blend_function(state->alpha_func) |
+ (r300_translate_blend_factor(state->alpha_src_factor) <<
R300_SRC_BLEND_SHIFT) |
- (translate_blend_factor(state->alpha_dst_factor) <<
+ (r300_translate_blend_factor(state->alpha_dst_factor) <<
R300_DST_BLEND_SHIFT);
}
@@ -175,21 +100,17 @@ static void r300_set_blend_color(struct pipe_context* pipe,
const struct pipe_blend_color* color)
{
struct r300_context* r300 = r300_context(pipe);
- uint32_t r, g, b, a;
ubyte ur, ug, ub, ua;
- r = util_iround(color->color[0] * 1023.0f);
- g = util_iround(color->color[1] * 1023.0f);
- b = util_iround(color->color[2] * 1023.0f);
- a = util_iround(color->color[3] * 1023.0f);
-
ur = float_to_ubyte(color->color[0]);
ug = float_to_ubyte(color->color[1]);
ub = float_to_ubyte(color->color[2]);
ua = float_to_ubyte(color->color[3]);
- r300->blend_color_state->blend_color = (a << 24) | (r << 16) | (g << 8) | b;
+ util_pack_color(color->color, PIPE_FORMAT_A8R8G8B8_UNORM,
+ &r300->blend_color_state->blend_color);
+ /* XXX this is wrong */
r300->blend_color_state->blend_color_red_alpha = ur | (ua << 16);
r300->blend_color_state->blend_color_green_blue = ub | (ug << 16);
@@ -210,83 +131,24 @@ static void
uint shader, uint index,
const struct pipe_constant_buffer* buffer)
{
- /* XXX */
-}
-
-static uint32_t translate_depth_stencil_function(int zs_func) {
- switch (zs_func) {
- case PIPE_FUNC_NEVER:
- return R300_ZS_NEVER;
- case PIPE_FUNC_LESS:
- return R300_ZS_LESS;
- case PIPE_FUNC_EQUAL:
- return R300_ZS_EQUAL;
- case PIPE_FUNC_LEQUAL:
- return R300_ZS_LEQUAL;
- case PIPE_FUNC_GREATER:
- return R300_ZS_GREATER;
- case PIPE_FUNC_NOTEQUAL:
- return R300_ZS_NOTEQUAL;
- case PIPE_FUNC_GEQUAL:
- return R300_ZS_GEQUAL;
- case PIPE_FUNC_ALWAYS:
- return R300_ZS_ALWAYS;
- default:
- debug_printf("r300: Unknown depth/stencil function %d\n",
- zs_func);
- break;
- }
- return 0;
-}
+ struct r300_context* r300 = r300_context(pipe);
-static uint32_t translate_stencil_op(int s_op) {
- switch (s_op) {
- case PIPE_STENCIL_OP_KEEP:
- return R300_ZS_KEEP;
- case PIPE_STENCIL_OP_ZERO:
- return R300_ZS_ZERO;
- case PIPE_STENCIL_OP_REPLACE:
- return R300_ZS_REPLACE;
- case PIPE_STENCIL_OP_INCR:
- return R300_ZS_INCR;
- case PIPE_STENCIL_OP_DECR:
- return R300_ZS_DECR;
- case PIPE_STENCIL_OP_INCR_WRAP:
- return R300_ZS_INCR_WRAP;
- case PIPE_STENCIL_OP_DECR_WRAP:
- return R300_ZS_DECR_WRAP;
- case PIPE_STENCIL_OP_INVERT:
- return R300_ZS_INVERT;
- default:
- debug_printf("r300: Unknown stencil op %d", s_op);
- break;
+ /* This entire chunk of code seems ever-so-slightly baked.
+ * It's as if I've got pipe_buffer* matryoshkas... */
+ if (buffer && buffer->buffer && buffer->buffer->size) {
+ void* map = pipe->winsys->buffer_map(pipe->winsys, buffer->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ memcpy(r300->shader_constants[shader].constants,
+ map, buffer->buffer->size);
+ pipe->winsys->buffer_unmap(pipe->winsys, buffer->buffer);
+
+ r300->shader_constants[shader].user_count =
+ buffer->buffer->size / (sizeof(float) * 4);
+ } else {
+ r300->shader_constants[shader].user_count = 0;
}
- return 0;
-}
-static uint32_t translate_alpha_function(int alpha_func) {
- switch (alpha_func) {
- case PIPE_FUNC_NEVER:
- return R300_FG_ALPHA_FUNC_NEVER;
- case PIPE_FUNC_LESS:
- return R300_FG_ALPHA_FUNC_LESS;
- case PIPE_FUNC_EQUAL:
- return R300_FG_ALPHA_FUNC_EQUAL;
- case PIPE_FUNC_LEQUAL:
- return R300_FG_ALPHA_FUNC_LE;
- case PIPE_FUNC_GREATER:
- return R300_FG_ALPHA_FUNC_GREATER;
- case PIPE_FUNC_NOTEQUAL:
- return R300_FG_ALPHA_FUNC_NOTEQUAL;
- case PIPE_FUNC_GEQUAL:
- return R300_FG_ALPHA_FUNC_GE;
- case PIPE_FUNC_ALWAYS:
- return R300_FG_ALPHA_FUNC_ALWAYS;
- default:
- debug_printf("r300: Unknown alpha function %d", alpha_func);
- break;
- }
- return 0;
+ r300->dirty_state |= R300_NEW_CONSTANTS;
}
/* Create a new depth, stencil, and alpha state based on the CSO dsa state.
@@ -309,7 +171,7 @@ static void*
}
dsa->z_stencil_control |=
- (translate_depth_stencil_function(state->depth.func) <<
+ (r300_translate_depth_stencil_function(state->depth.func) <<
R300_Z_FUNC_SHIFT);
}
@@ -317,14 +179,14 @@ static void*
if (state->stencil[0].enabled) {
dsa->z_buffer_control |= R300_STENCIL_ENABLE;
dsa->z_stencil_control |=
- (translate_depth_stencil_function(state->stencil[0].func) <<
- R300_S_FRONT_FUNC_SHIFT) |
- (translate_stencil_op(state->stencil[0].fail_op) <<
- R300_S_FRONT_SFAIL_OP_SHIFT) |
- (translate_stencil_op(state->stencil[0].zpass_op) <<
- R300_S_FRONT_ZPASS_OP_SHIFT) |
- (translate_stencil_op(state->stencil[0].zfail_op) <<
- R300_S_FRONT_ZFAIL_OP_SHIFT);
+ (r300_translate_depth_stencil_function(state->stencil[0].func) <<
+ R300_S_FRONT_FUNC_SHIFT) |
+ (r300_translate_stencil_op(state->stencil[0].fail_op) <<
+ R300_S_FRONT_SFAIL_OP_SHIFT) |
+ (r300_translate_stencil_op(state->stencil[0].zpass_op) <<
+ R300_S_FRONT_ZPASS_OP_SHIFT) |
+ (r300_translate_stencil_op(state->stencil[0].zfail_op) <<
+ R300_S_FRONT_ZFAIL_OP_SHIFT);
dsa->stencil_ref_mask = (state->stencil[0].ref_value) |
(state->stencil[0].valuemask << R300_STENCILMASK_SHIFT) |
@@ -333,14 +195,14 @@ static void*
if (state->stencil[1].enabled) {
dsa->z_buffer_control |= R300_STENCIL_FRONT_BACK;
dsa->z_stencil_control |=
- (translate_depth_stencil_function(state->stencil[1].func) <<
- R300_S_BACK_FUNC_SHIFT) |
- (translate_stencil_op(state->stencil[1].fail_op) <<
- R300_S_BACK_SFAIL_OP_SHIFT) |
- (translate_stencil_op(state->stencil[1].zpass_op) <<
- R300_S_BACK_ZPASS_OP_SHIFT) |
- (translate_stencil_op(state->stencil[1].zfail_op) <<
- R300_S_BACK_ZFAIL_OP_SHIFT);
+ (r300_translate_depth_stencil_function(state->stencil[1].func) <<
+ R300_S_BACK_FUNC_SHIFT) |
+ (r300_translate_stencil_op(state->stencil[1].fail_op) <<
+ R300_S_BACK_SFAIL_OP_SHIFT) |
+ (r300_translate_stencil_op(state->stencil[1].zpass_op) <<
+ R300_S_BACK_ZPASS_OP_SHIFT) |
+ (r300_translate_stencil_op(state->stencil[1].zfail_op) <<
+ R300_S_BACK_ZFAIL_OP_SHIFT);
dsa->stencil_ref_bf = (state->stencil[1].ref_value) |
(state->stencil[1].valuemask << R300_STENCILMASK_SHIFT) |
@@ -350,7 +212,8 @@ static void*
/* Alpha test setup. */
if (state->alpha.enabled) {
- dsa->alpha_function = translate_alpha_function(state->alpha.func) |
+ dsa->alpha_function =
+ r300_translate_alpha_function(state->alpha.func) |
R300_FG_ALPHA_FUNC_ENABLE;
dsa->alpha_reference = CLAMP(state->alpha.ref_value * 1023.0f,
0, 1023);
@@ -415,6 +278,8 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
/* Copy state directly into shader. */
fs->state = *shader;
+ tgsi_scan_shader(shader->tokens, &fs->info);
+
return (void*)fs;
}
@@ -424,14 +289,18 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)
struct r300_context* r300 = r300_context(pipe);
struct r3xx_fragment_shader* fs = (struct r3xx_fragment_shader*)shader;
- if (!fs->translated) {
+ if (fs == NULL) {
+ r300->fs = NULL;
+ return;
+ } else if (!fs->translated) {
if (r300_screen(r300->context.screen)->caps->is_r500) {
- r500_translate_shader(r300, fs);
+ r500_translate_fragment_shader(r300, (struct r500_fragment_shader*)fs);
} else {
- r300_translate_shader(r300, fs);
+ r300_translate_fragment_shader(r300, (struct r300_fragment_shader*)fs);
}
}
+ fs->translated = TRUE;
r300->fs = fs;
r300->dirty_state |= R300_NEW_FRAGMENT_SHADER;
@@ -449,10 +318,6 @@ static void r300_set_polygon_stipple(struct pipe_context* pipe,
/* XXX */
}
-static INLINE int pack_float_16_6x(float f) {
- return ((int)(f * 6.0) & 0xffff);
-}
-
/* Create a new rasterizer state based on the CSO rasterizer state.
*
* This is a very large chunk of state, and covers most of the graphics
@@ -472,6 +337,12 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
rs->point_size = pack_float_16_6x(state->point_size) |
(pack_float_16_6x(state->point_size) << R300_POINTSIZE_X_SHIFT);
+ rs->point_minmax =
+ ((int)(state->point_size_min * 6.0) <<
+ R300_GA_POINT_MINMAX_MIN_SHIFT) |
+ ((int)(state->point_size_max * 6.0) <<
+ R300_GA_POINT_MINMAX_MAX_SHIFT);
+
rs->line_control = pack_float_16_6x(state->line_width) |
R300_GA_LINE_CNTL_END_TYPE_COMP;
@@ -504,20 +375,28 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
if (rs->polygon_offset_enable) {
rs->depth_offset_front = rs->depth_offset_back =
- pack_float_32(state->offset_units);
+ fui(state->offset_units);
rs->depth_scale_front = rs->depth_scale_back =
- pack_float_32(state->offset_scale);
+ fui(state->offset_scale);
}
if (state->line_stipple_enable) {
rs->line_stipple_config =
R300_GA_LINE_STIPPLE_CONFIG_LINE_RESET_LINE |
- (pack_float_32((float)state->line_stipple_factor) &
+ (fui((float)state->line_stipple_factor) &
R300_GA_LINE_STIPPLE_CONFIG_STIPPLE_SCALE_MASK);
/* XXX this might need to be scaled up */
rs->line_stipple_value = state->line_stipple_pattern;
}
+ if (state->flatshade) {
+ rs->color_control = R300_SHADE_MODEL_FLAT;
+ } else {
+ rs->color_control = R300_SHADE_MODEL_SMOOTH;
+ }
+
+ rs->rs = *state;
+
return (void*)rs;
}
@@ -525,8 +404,11 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
{
struct r300_context* r300 = r300_context(pipe);
+ struct r300_rs_state* rs = (struct r300_rs_state*)state;
+
+ draw_set_rasterizer_state(r300->draw, &rs->rs);
- r300->rs_state = (struct r300_rs_state*)state;
+ r300->rs_state = rs;
r300->dirty_state |= R300_NEW_RASTERIZER;
}
@@ -536,83 +418,6 @@ static void r300_delete_rs_state(struct pipe_context* pipe, void* state)
FREE(state);
}
-static uint32_t translate_wrap(int wrap) {
- switch (wrap) {
- case PIPE_TEX_WRAP_REPEAT:
- return R300_TX_REPEAT;
- case PIPE_TEX_WRAP_CLAMP:
- return R300_TX_CLAMP;
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- return R300_TX_CLAMP_TO_EDGE;
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- return R300_TX_CLAMP_TO_BORDER;
- case PIPE_TEX_WRAP_MIRROR_REPEAT:
- return R300_TX_REPEAT | R300_TX_MIRRORED;
- case PIPE_TEX_WRAP_MIRROR_CLAMP:
- return R300_TX_CLAMP | R300_TX_MIRRORED;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
- return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
- default:
- debug_printf("r300: Unknown texture wrap %d", wrap);
- return 0;
- }
-}
-
-static uint32_t translate_tex_filters(int min, int mag, int mip) {
- uint32_t retval = 0;
- switch (min) {
- case PIPE_TEX_FILTER_NEAREST:
- retval |= R300_TX_MIN_FILTER_NEAREST;
- case PIPE_TEX_FILTER_LINEAR:
- retval |= R300_TX_MIN_FILTER_LINEAR;
- case PIPE_TEX_FILTER_ANISO:
- retval |= R300_TX_MIN_FILTER_ANISO;
- default:
- debug_printf("r300: Unknown texture filter %d", min);
- break;
- }
- switch (mag) {
- case PIPE_TEX_FILTER_NEAREST:
- retval |= R300_TX_MAG_FILTER_NEAREST;
- case PIPE_TEX_FILTER_LINEAR:
- retval |= R300_TX_MAG_FILTER_LINEAR;
- case PIPE_TEX_FILTER_ANISO:
- retval |= R300_TX_MAG_FILTER_ANISO;
- default:
- debug_printf("r300: Unknown texture filter %d", mag);
- break;
- }
- switch (mip) {
- case PIPE_TEX_MIPFILTER_NONE:
- retval |= R300_TX_MIN_FILTER_MIP_NONE;
- case PIPE_TEX_MIPFILTER_NEAREST:
- retval |= R300_TX_MIN_FILTER_MIP_NEAREST;
- case PIPE_TEX_MIPFILTER_LINEAR:
- retval |= R300_TX_MIN_FILTER_MIP_LINEAR;
- default:
- debug_printf("r300: Unknown texture filter %d", mip);
- break;
- }
-
- return retval;
-}
-
-static uint32_t anisotropy(float max_aniso) {
- if (max_aniso >= 16.0f) {
- return R300_TX_MAX_ANISO_16_TO_1;
- } else if (max_aniso >= 8.0f) {
- return R300_TX_MAX_ANISO_8_TO_1;
- } else if (max_aniso >= 4.0f) {
- return R300_TX_MAX_ANISO_4_TO_1;
- } else if (max_aniso >= 2.0f) {
- return R300_TX_MAX_ANISO_2_TO_1;
- } else {
- return R300_TX_MAX_ANISO_1_TO_1;
- }
-}
-
static void*
r300_create_sampler_state(struct pipe_context* pipe,
const struct pipe_sampler_state* state)
@@ -622,19 +427,19 @@ static void*
int lod_bias;
sampler->filter0 |=
- (translate_wrap(state->wrap_s) << R300_TX_WRAP_S_SHIFT) |
- (translate_wrap(state->wrap_t) << R300_TX_WRAP_T_SHIFT) |
- (translate_wrap(state->wrap_r) << R300_TX_WRAP_R_SHIFT);
+ (r300_translate_wrap(state->wrap_s) << R300_TX_WRAP_S_SHIFT) |
+ (r300_translate_wrap(state->wrap_t) << R300_TX_WRAP_T_SHIFT) |
+ (r300_translate_wrap(state->wrap_r) << R300_TX_WRAP_R_SHIFT);
- sampler->filter0 |= translate_tex_filters(state->min_img_filter,
- state->mag_img_filter,
- state->min_mip_filter);
+ sampler->filter0 |= r300_translate_tex_filters(state->min_img_filter,
+ state->mag_img_filter,
+ state->min_mip_filter);
lod_bias = CLAMP((int)(state->lod_bias * 32), -(1 << 9), (1 << 9) - 1);
sampler->filter1 |= lod_bias << R300_LOD_BIAS_SHIFT;
- sampler->filter1 |= anisotropy(state->max_anisotropy);
+ sampler->filter1 |= r300_anisotropy(state->max_anisotropy);
util_pack_color(state->border_color, PIPE_FORMAT_A8R8G8B8_UNORM,
&sampler->border_color);
@@ -710,20 +515,12 @@ static void r300_set_scissor_state(struct pipe_context* pipe,
struct r300_context* r300 = r300_context(pipe);
draw_flush(r300->draw);
- uint32_t left, top, right, bottom;
-
- /* So, a bit of info. The scissors are offset by R300_SCISSORS_OFFSET in
- * both directions for all values, and can only be 13 bits wide. Why?
- * We may never know. */
- left = (state->minx + R300_SCISSORS_OFFSET) & 0x1fff;
- top = (state->miny + R300_SCISSORS_OFFSET) & 0x1fff;
- right = (state->maxx + R300_SCISSORS_OFFSET) & 0x1fff;
- bottom = (state->maxy + R300_SCISSORS_OFFSET) & 0x1fff;
-
- r300->scissor_state->scissor_top_left = (left << R300_SCISSORS_X_SHIFT) |
- (top << R300_SCISSORS_Y_SHIFT);
+ r300->scissor_state->scissor_top_left =
+ (state->minx << R300_SCISSORS_X_SHIFT) |
+ (state->miny << R300_SCISSORS_Y_SHIFT);
r300->scissor_state->scissor_bottom_right =
- (right << R300_SCISSORS_X_SHIFT) | (bottom << R300_SCISSORS_Y_SHIFT);
+ (state->maxx << R300_SCISSORS_X_SHIFT) |
+ (state->maxy << R300_SCISSORS_Y_SHIFT);
r300->dirty_state |= R300_NEW_SCISSOR;
}
@@ -732,8 +529,26 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
const struct pipe_viewport_state* state)
{
struct r300_context* r300 = r300_context(pipe);
- /* XXX handing this off to Draw for now */
- draw_set_viewport_state(r300->draw, state);
+
+ r300->viewport_state->xscale = state->scale[0];
+ r300->viewport_state->yscale = state->scale[1];
+ r300->viewport_state->zscale = state->scale[2];
+
+ r300->viewport_state->xoffset = state->translate[0];
+ r300->viewport_state->yoffset = state->translate[1];
+ r300->viewport_state->zoffset = state->translate[2];
+
+ r300->viewport_state->vte_control = 0;
+ if (r300_screen(r300->context.screen)->caps->has_tcl) {
+ /* Do the transform in HW. */
+ r300->viewport_state->vte_control |=
+ R300_VPORT_X_SCALE_ENA | R300_VPORT_X_OFFSET_ENA |
+ R300_VPORT_Y_SCALE_ENA | R300_VPORT_Y_OFFSET_ENA |
+ R300_VPORT_Z_SCALE_ENA | R300_VPORT_Z_OFFSET_ENA;
+ } else {
+ /* Have Draw do the actual transform. */
+ draw_set_viewport_state(r300->draw, state);
+ }
}
static void r300_set_vertex_buffers(struct pipe_context* pipe,
@@ -741,7 +556,12 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
const struct pipe_vertex_buffer* buffers)
{
struct r300_context* r300 = r300_context(pipe);
- /* XXX Draw */
+
+ memcpy(r300->vertex_buffers, buffers,
+ sizeof(struct pipe_vertex_buffer) * count);
+
+ r300->vertex_buffer_count = count;
+
draw_flush(r300->draw);
draw_set_vertex_buffers(r300->draw, count, buffers);
}
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
new file mode 100644
index 0000000000..d761a0302f
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -0,0 +1,299 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include "r300_state_derived.h"
+
+/* r300_state_derived: Various bits of state which are dependent upon
+ * currently bound CSO data. */
+
+/* Update the vertex_info struct in our r300_context.
+ *
+ * The vertex_info struct describes the post-TCL format of vertices. It is
+ * required for Draw when doing SW TCL, and also for describing the
+ * dreaded RS block on R300 chipsets. */
+/* XXX this function should be able to handle vert shaders as well as draw */
+static void r300_update_vertex_layout(struct r300_context* r300)
+{
+ struct r300_vertex_format vformat;
+ struct vertex_info vinfo;
+ boolean pos = FALSE, psize = FALSE, fog = FALSE;
+ int i, texs = 0, cols = 0;
+ int tab[16];
+
+ struct tgsi_shader_info* info = &r300->fs->info;
+
+ memset(&vinfo, 0, sizeof(vinfo));
+ for (i = 0; i < 16; i++) {
+ tab[i] = -1;
+ }
+
+ assert(info->num_inputs <= 16);
+
+ for (i = 0; i < info->num_inputs; i++) {
+ switch (info->input_semantic_name[i]) {
+ case TGSI_SEMANTIC_POSITION:
+ pos = TRUE;
+ tab[i] = 0;
+ break;
+ case TGSI_SEMANTIC_COLOR:
+ tab[i] = 2 + cols++;
+ break;
+ case TGSI_SEMANTIC_PSIZE:
+ psize = TRUE;
+ tab[i] = 1;
+ break;
+ case TGSI_SEMANTIC_FOG:
+ fog = TRUE;
+ /* Fall through... */
+ case TGSI_SEMANTIC_GENERIC:
+ tab[i] = 6 + texs++;
+ break;
+ default:
+ debug_printf("r300: Unknown vertex input %d\n",
+ info->input_semantic_name[i]);
+ break;
+ }
+ }
+
+ /* Do the actual vertex_info setup.
+ *
+ * vertex_info has four uints of hardware-specific data in it.
+ * vinfo.hwfmt[0] is R300_VAP_VTX_STATE_CNTL
+ * vinfo.hwfmt[1] is R300_VAP_VSM_VTX_ASSM
+ * vinfo.hwfmt[2] is R300_VAP_OUTPUT_VTX_FMT_0
+ * vinfo.hwfmt[3] is R300_VAP_OUTPUT_VTX_FMT_1 */
+
+ vinfo.hwfmt[0] = 0x5555; /* XXX this is classic Mesa bonghits */
+
+ if (!pos) {
+ debug_printf("r300: Forcing vertex position attribute emit...\n");
+ /* Make room for the position attribute
+ * at the beginning of the tab. */
+ for (i = 15; i > 0; i--) {
+ tab[i] = tab[i-1];
+ }
+ tab[0] = 0;
+
+ draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_POS,
+ draw_find_vs_output(r300->draw, TGSI_SEMANTIC_POSITION, 0));
+ } else {
+ draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE,
+ draw_find_vs_output(r300->draw, TGSI_SEMANTIC_POSITION, 0));
+ }
+ vinfo.hwfmt[1] |= R300_INPUT_CNTL_POS;
+ vinfo.hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
+
+ if (psize) {
+ draw_emit_vertex_attr(&vinfo, EMIT_1F_PSIZE, INTERP_POS,
+ draw_find_vs_output(r300->draw, TGSI_SEMANTIC_PSIZE, 0));
+ vinfo.hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
+ }
+
+ for (i = 0; i < cols; i++) {
+ draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR,
+ draw_find_vs_output(r300->draw, TGSI_SEMANTIC_COLOR, i));
+ vinfo.hwfmt[1] |= R300_INPUT_CNTL_COLOR;
+ vinfo.hwfmt[2] |= (R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i);
+ }
+
+ for (i = 0; i < texs; i++) {
+ draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE,
+ draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i));
+ vinfo.hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
+ vinfo.hwfmt[3] |= (4 << (3 * i));
+ }
+
+ if (fog) {
+ i++;
+ draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE,
+ draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0));
+ vinfo.hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
+ vinfo.hwfmt[3] |= (4 << (3 * i));
+ }
+
+ draw_compute_vertex_size(&vinfo);
+
+ if (memcmp(&r300->vertex_info, &vinfo, sizeof(struct vertex_info))) {
+ uint32_t temp;
+ debug_printf("attrib count: %d, fp input count: %d\n",
+ vinfo.num_attribs, info->num_inputs);
+ for (i = 0; i < vinfo.num_attribs; i++) {
+ debug_printf("attrib: offset %d, interp %d, size %d,"
+ " tab %d\n", vinfo.attrib[i].src_index,
+ vinfo.attrib[i].interp_mode, vinfo.attrib[i].emit,
+ tab[i]);
+ }
+
+ for (i = 0; i < vinfo.num_attribs; i++) {
+ /* Make sure we have a proper destination for our attribute */
+ assert(tab[i] != -1);
+
+ temp = translate_vertex_data_type(vinfo.attrib[i].emit) |
+ (tab[i] << R300_DST_VEC_LOC_SHIFT);
+ if (i & 1) {
+ r300->vertex_info.vap_prog_stream_cntl[i >> 1] &= 0x0000ffff;
+ r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= temp << 16;
+ } else {
+ r300->vertex_info.vap_prog_stream_cntl[i >> 1] &= 0xffff0000;
+ r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= temp;
+ }
+
+ r300->vertex_info.vap_prog_stream_cntl_ext[i >> 1] |=
+ (R300_VAP_SWIZZLE_XYZW << (i & 1 ? 16 : 0));
+ }
+ /* Set the last vector. */
+ i--;
+ r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= (R300_LAST_VEC <<
+ (i & 1 ? 16 : 0));
+
+ memcpy(r300->vertex_info.tab, tab, sizeof(tab));
+ memcpy(&r300->vertex_info, &vinfo, sizeof(struct vertex_info));
+ r300->dirty_state |= R300_NEW_VERTEX_FORMAT;
+ }
+}
+
+/* Set up the RS block. This is the part of the chipset that actually does
+ * the rasterization of vertices into fragments. This is also the part of the
+ * chipset that locks up if any part of it is even slightly wrong. */
+static void r300_update_rs_block(struct r300_context* r300)
+{
+ struct r300_rs_block* rs = r300->rs_block;
+ struct vertex_info* vinfo = &r300->vertex_info.vinfo;
+ int* tab = r300->vertex_info.tab;
+ int col_count = 0, fp_offset = 0, i, memory_pos, tex_count = 0;
+
+ memset(rs, 0, sizeof(struct r300_rs_block));
+
+ if (r300_screen(r300->context.screen)->caps->is_r500) {
+ for (i = 0; i < vinfo->num_attribs; i++) {
+ assert(tab[vinfo->attrib[i].src_index] != -1);
+ memory_pos = tab[vinfo->attrib[i].src_index] * 4;
+ switch (vinfo->attrib[i].interp_mode) {
+ case INTERP_LINEAR:
+ rs->ip[col_count] |=
+ R500_RS_COL_PTR(memory_pos) |
+ R500_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
+ col_count++;
+ break;
+ case INTERP_PERSPECTIVE:
+ rs->ip[tex_count] |=
+ R500_RS_SEL_S(memory_pos) |
+ R500_RS_SEL_T(memory_pos + 1) |
+ R500_RS_SEL_R(memory_pos + 2) |
+ R500_RS_SEL_Q(memory_pos + 3);
+ tex_count++;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (col_count == 0) {
+ rs->ip[0] |= R500_RS_COL_FMT(R300_RS_COL_FMT_0001);
+ }
+
+ /* Set up at least one texture pointer or RS will not be happy. */
+ if (tex_count == 0) {
+ rs->ip[0] |=
+ R500_RS_SEL_S(R500_RS_IP_PTR_K0) |
+ R500_RS_SEL_T(R500_RS_IP_PTR_K0) |
+ R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
+ R500_RS_SEL_Q(R500_RS_IP_PTR_K1);
+ }
+
+ for (i = 0; i < tex_count; i++) {
+ rs->inst[i] |= R500_RS_INST_TEX_ID(i) | R500_RS_INST_TEX_CN_WRITE |
+ R500_RS_INST_TEX_ADDR(fp_offset);
+ fp_offset++;
+ }
+
+ for (i = 0; i < col_count; i++) {
+ rs->inst[i] |= R500_RS_INST_COL_ID(i) | R500_RS_INST_COL_CN_WRITE |
+ R500_RS_INST_COL_ADDR(fp_offset);
+ fp_offset++;
+ }
+ } else {
+ for (i = 0; i < vinfo->num_attribs; i++) {
+ memory_pos = tab[vinfo->attrib[i].src_index] * 4;
+ assert(tab[vinfo->attrib[i].src_index] != -1);
+ switch (vinfo->attrib[i].interp_mode) {
+ case INTERP_LINEAR:
+ rs->ip[col_count] |=
+ R300_RS_COL_PTR(memory_pos) |
+ R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
+ col_count++;
+ break;
+ case INTERP_PERSPECTIVE:
+ rs->ip[tex_count] |=
+ R300_RS_TEX_PTR(memory_pos) |
+ R300_RS_SEL_S(R300_RS_SEL_C0) |
+ R300_RS_SEL_T(R300_RS_SEL_C1) |
+ R300_RS_SEL_R(R300_RS_SEL_C2) |
+ R300_RS_SEL_Q(R300_RS_SEL_C3);
+ tex_count++;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (col_count == 0) {
+ rs->ip[0] |= R300_RS_COL_FMT(R300_RS_COL_FMT_0001);
+ }
+
+ if (tex_count == 0) {
+ rs->ip[0] |=
+ R300_RS_SEL_S(R300_RS_SEL_K0) |
+ R300_RS_SEL_T(R300_RS_SEL_K0) |
+ R300_RS_SEL_R(R300_RS_SEL_K0) |
+ R300_RS_SEL_Q(R300_RS_SEL_K1);
+ }
+
+ for (i = 0; i < tex_count; i++) {
+ rs->inst[i] |= R300_RS_INST_TEX_ID(i) | R300_RS_INST_TEX_CN_WRITE |
+ R300_RS_INST_TEX_ADDR(fp_offset);
+ fp_offset++;
+ }
+
+ for (i = 0; i < col_count; i++) {
+ rs->inst[i] |= R300_RS_INST_COL_ID(i) | R300_RS_INST_COL_CN_WRITE |
+ R300_RS_INST_COL_ADDR(fp_offset);
+ fp_offset++;
+ }
+ }
+
+ rs->count = (tex_count * 4) | (col_count << R300_IC_COUNT_SHIFT) |
+ R300_HIRES_EN;
+
+ rs->inst_count = MAX2(MAX2(col_count - 1, tex_count - 1), 0);
+}
+
+void r300_update_derived_state(struct r300_context* r300)
+{
+ if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) {
+ r300_update_vertex_layout(r300);
+ }
+
+ if (r300->dirty_state & R300_NEW_VERTEX_FORMAT) {
+ r300_update_rs_block(r300);
+ }
+}
diff --git a/src/gallium/drivers/r300/r300_state_derived.h b/src/gallium/drivers/r300/r300_state_derived.h
new file mode 100644
index 0000000000..63ae8eb8d0
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_state_derived.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_STATE_DERIVED_H
+#define R300_STATE_DERIVED_H
+
+#include "draw/draw_vertex.h"
+
+#include "r300_context.h"
+#include "r300_reg.h"
+#include "r300_state_inlines.h"
+
+void r300_update_derived_state(struct r300_context* r300);
+
+#endif /* R300_STATE_DERIVED_H */
diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h
new file mode 100644
index 0000000000..fd92c71756
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_state_inlines.h
@@ -0,0 +1,384 @@
+/*
+ * Copyright 2009 Joakim Sindholt <opensource@zhasha.com>
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_STATE_INLINES_H
+#define R300_STATE_INLINES_H
+
+#include "pipe/p_format.h"
+
+#include "r300_reg.h"
+
+/* Some maths. These should probably find their way to u_math, if needed. */
+
+static INLINE int pack_float_16_6x(float f) {
+ return ((int)(f * 6.0) & 0xffff);
+}
+
+/* Blend state. */
+
+static INLINE uint32_t r300_translate_blend_function(int blend_func)
+{
+ switch (blend_func) {
+ case PIPE_BLEND_ADD:
+ return R300_COMB_FCN_ADD_CLAMP;
+ case PIPE_BLEND_SUBTRACT:
+ return R300_COMB_FCN_SUB_CLAMP;
+ case PIPE_BLEND_REVERSE_SUBTRACT:
+ return R300_COMB_FCN_RSUB_CLAMP;
+ case PIPE_BLEND_MIN:
+ return R300_COMB_FCN_MIN;
+ case PIPE_BLEND_MAX:
+ return R300_COMB_FCN_MAX;
+ default:
+ debug_printf("r300: Unknown blend function %d\n", blend_func);
+ break;
+ }
+ return 0;
+}
+
+/* XXX we can also offer the D3D versions of some of these... */
+static INLINE uint32_t r300_translate_blend_factor(int blend_fact)
+{
+ switch (blend_fact) {
+ case PIPE_BLENDFACTOR_ONE:
+ return R300_BLEND_GL_ONE;
+ case PIPE_BLENDFACTOR_SRC_COLOR:
+ return R300_BLEND_GL_SRC_COLOR;
+ case PIPE_BLENDFACTOR_SRC_ALPHA:
+ return R300_BLEND_GL_SRC_ALPHA;
+ case PIPE_BLENDFACTOR_DST_ALPHA:
+ return R300_BLEND_GL_DST_ALPHA;
+ case PIPE_BLENDFACTOR_DST_COLOR:
+ return R300_BLEND_GL_DST_COLOR;
+ case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
+ return R300_BLEND_GL_SRC_ALPHA_SATURATE;
+ case PIPE_BLENDFACTOR_CONST_COLOR:
+ return R300_BLEND_GL_CONST_COLOR;
+ case PIPE_BLENDFACTOR_CONST_ALPHA:
+ return R300_BLEND_GL_CONST_ALPHA;
+ /* XXX WTF are these?
+ case PIPE_BLENDFACTOR_SRC1_COLOR:
+ case PIPE_BLENDFACTOR_SRC1_ALPHA: */
+ case PIPE_BLENDFACTOR_ZERO:
+ return R300_BLEND_GL_ZERO;
+ case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+ return R300_BLEND_GL_ONE_MINUS_SRC_COLOR;
+ case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
+ return R300_BLEND_GL_ONE_MINUS_SRC_ALPHA;
+ case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+ return R300_BLEND_GL_ONE_MINUS_DST_ALPHA;
+ case PIPE_BLENDFACTOR_INV_DST_COLOR:
+ return R300_BLEND_GL_ONE_MINUS_DST_COLOR;
+ case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+ return R300_BLEND_GL_ONE_MINUS_CONST_COLOR;
+ case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+ return R300_BLEND_GL_ONE_MINUS_CONST_ALPHA;
+ /* XXX see above
+ case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+ case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: */
+ default:
+ debug_printf("r300: Unknown blend factor %d\n", blend_fact);
+ break;
+ }
+ return 0;
+}
+
+/* DSA state. */
+
+static INLINE uint32_t r300_translate_depth_stencil_function(int zs_func)
+{
+ switch (zs_func) {
+ case PIPE_FUNC_NEVER:
+ return R300_ZS_NEVER;
+ case PIPE_FUNC_LESS:
+ return R300_ZS_LESS;
+ case PIPE_FUNC_EQUAL:
+ return R300_ZS_EQUAL;
+ case PIPE_FUNC_LEQUAL:
+ return R300_ZS_LEQUAL;
+ case PIPE_FUNC_GREATER:
+ return R300_ZS_GREATER;
+ case PIPE_FUNC_NOTEQUAL:
+ return R300_ZS_NOTEQUAL;
+ case PIPE_FUNC_GEQUAL:
+ return R300_ZS_GEQUAL;
+ case PIPE_FUNC_ALWAYS:
+ return R300_ZS_ALWAYS;
+ default:
+ debug_printf("r300: Unknown depth/stencil function %d\n",
+ zs_func);
+ break;
+ }
+ return 0;
+}
+
+static INLINE uint32_t r300_translate_stencil_op(int s_op)
+{
+ switch (s_op) {
+ case PIPE_STENCIL_OP_KEEP:
+ return R300_ZS_KEEP;
+ case PIPE_STENCIL_OP_ZERO:
+ return R300_ZS_ZERO;
+ case PIPE_STENCIL_OP_REPLACE:
+ return R300_ZS_REPLACE;
+ case PIPE_STENCIL_OP_INCR:
+ return R300_ZS_INCR;
+ case PIPE_STENCIL_OP_DECR:
+ return R300_ZS_DECR;
+ case PIPE_STENCIL_OP_INCR_WRAP:
+ return R300_ZS_INCR_WRAP;
+ case PIPE_STENCIL_OP_DECR_WRAP:
+ return R300_ZS_DECR_WRAP;
+ case PIPE_STENCIL_OP_INVERT:
+ return R300_ZS_INVERT;
+ default:
+ debug_printf("r300: Unknown stencil op %d", s_op);
+ break;
+ }
+ return 0;
+}
+
+static INLINE uint32_t r300_translate_alpha_function(int alpha_func)
+{
+ switch (alpha_func) {
+ case PIPE_FUNC_NEVER:
+ return R300_FG_ALPHA_FUNC_NEVER;
+ case PIPE_FUNC_LESS:
+ return R300_FG_ALPHA_FUNC_LESS;
+ case PIPE_FUNC_EQUAL:
+ return R300_FG_ALPHA_FUNC_EQUAL;
+ case PIPE_FUNC_LEQUAL:
+ return R300_FG_ALPHA_FUNC_LE;
+ case PIPE_FUNC_GREATER:
+ return R300_FG_ALPHA_FUNC_GREATER;
+ case PIPE_FUNC_NOTEQUAL:
+ return R300_FG_ALPHA_FUNC_NOTEQUAL;
+ case PIPE_FUNC_GEQUAL:
+ return R300_FG_ALPHA_FUNC_GE;
+ case PIPE_FUNC_ALWAYS:
+ return R300_FG_ALPHA_FUNC_ALWAYS;
+ default:
+ debug_printf("r300: Unknown alpha function %d", alpha_func);
+ break;
+ }
+ return 0;
+}
+
+/* Texture sampler state. */
+
+static INLINE uint32_t r300_translate_wrap(int wrap)
+{
+ switch (wrap) {
+ case PIPE_TEX_WRAP_REPEAT:
+ return R300_TX_REPEAT;
+ case PIPE_TEX_WRAP_CLAMP:
+ return R300_TX_CLAMP;
+ case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
+ return R300_TX_CLAMP_TO_EDGE;
+ case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
+ return R300_TX_CLAMP_TO_BORDER;
+ case PIPE_TEX_WRAP_MIRROR_REPEAT:
+ return R300_TX_REPEAT | R300_TX_MIRRORED;
+ case PIPE_TEX_WRAP_MIRROR_CLAMP:
+ return R300_TX_CLAMP | R300_TX_MIRRORED;
+ case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
+ return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
+ case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
+ return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
+ default:
+ debug_printf("r300: Unknown texture wrap %d", wrap);
+ return 0;
+ }
+}
+
+static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip)
+{
+ uint32_t retval = 0;
+ switch (min) {
+ case PIPE_TEX_FILTER_NEAREST:
+ retval |= R300_TX_MIN_FILTER_NEAREST;
+ break;
+ case PIPE_TEX_FILTER_LINEAR:
+ retval |= R300_TX_MIN_FILTER_LINEAR;
+ break;
+ case PIPE_TEX_FILTER_ANISO:
+ retval |= R300_TX_MIN_FILTER_ANISO;
+ break;
+ default:
+ debug_printf("r300: Unknown texture filter %d\n", min);
+ break;
+ }
+ switch (mag) {
+ case PIPE_TEX_FILTER_NEAREST:
+ retval |= R300_TX_MAG_FILTER_NEAREST;
+ break;
+ case PIPE_TEX_FILTER_LINEAR:
+ retval |= R300_TX_MAG_FILTER_LINEAR;
+ break;
+ case PIPE_TEX_FILTER_ANISO:
+ retval |= R300_TX_MAG_FILTER_ANISO;
+ break;
+ default:
+ debug_printf("r300: Unknown texture filter %d\n", mag);
+ break;
+ }
+ switch (mip) {
+ case PIPE_TEX_MIPFILTER_NONE:
+ retval |= R300_TX_MIN_FILTER_MIP_NONE;
+ break;
+ case PIPE_TEX_MIPFILTER_NEAREST:
+ retval |= R300_TX_MIN_FILTER_MIP_NEAREST;
+ break;
+ case PIPE_TEX_MIPFILTER_LINEAR:
+ retval |= R300_TX_MIN_FILTER_MIP_LINEAR;
+ break;
+ default:
+ debug_printf("r300: Unknown texture filter %d\n", mip);
+ break;
+ }
+
+ return retval;
+}
+
+static INLINE uint32_t r300_anisotropy(float max_aniso)
+{
+ if (max_aniso >= 16.0f) {
+ return R300_TX_MAX_ANISO_16_TO_1;
+ } else if (max_aniso >= 8.0f) {
+ return R300_TX_MAX_ANISO_8_TO_1;
+ } else if (max_aniso >= 4.0f) {
+ return R300_TX_MAX_ANISO_4_TO_1;
+ } else if (max_aniso >= 2.0f) {
+ return R300_TX_MAX_ANISO_2_TO_1;
+ } else {
+ return R300_TX_MAX_ANISO_1_TO_1;
+ }
+}
+
+/* Buffer formats. */
+
+static INLINE uint32_t r300_translate_colorformat(enum pipe_format format)
+{
+ switch (format) {
+ /* 8-bit buffers */
+ case PIPE_FORMAT_I8_UNORM:
+ return R300_COLOR_FORMAT_I8;
+ /* 16-bit buffers */
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ return R300_COLOR_FORMAT_RGB565;
+ case PIPE_FORMAT_A1R5G5B5_UNORM:
+ return R300_COLOR_FORMAT_ARGB1555;
+ case PIPE_FORMAT_A4R4G4B4_UNORM:
+ return R300_COLOR_FORMAT_ARGB4444;
+ /* 32-bit buffers */
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ return R300_COLOR_FORMAT_ARGB8888;
+ /* XXX Not in pipe_format
+ case PIPE_FORMAT_A32R32G32B32:
+ return R300_COLOR_FORMAT_ARGB32323232;
+ case PIPE_FORMAT_A16R16G16B16:
+ return R300_COLOR_FORMAT_ARGB16161616; */
+ /* XXX Not in pipe_format
+ case PIPE_FORMAT_A10R10G10B10_UNORM:
+ return R500_COLOR_FORMAT_ARGB10101010;
+ case PIPE_FORMAT_A2R10G10B10_UNORM:
+ return R500_COLOR_FORMAT_ARGB2101010;
+ case PIPE_FORMAT_I10_UNORM:
+ return R500_COLOR_FORMAT_I10; */
+ default:
+ debug_printf("r300: Implementation error: " \
+ "Got unsupported color format %s in %s\n",
+ pf_name(format), __FUNCTION__);
+ break;
+ }
+ return 0;
+}
+
+static INLINE uint32_t r300_translate_zsformat(enum pipe_format format)
+{
+ switch (format) {
+ /* 16-bit depth, no stencil */
+ case PIPE_FORMAT_Z16_UNORM:
+ return R300_DEPTHFORMAT_16BIT_INT_Z;
+ /* 24-bit depth, 8-bit stencil */
+ case PIPE_FORMAT_Z24S8_UNORM:
+ return R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
+ default:
+ debug_printf("r300: Implementation error: " \
+ "Got unsupported ZS format %s in %s\n",
+ pf_name(format), __FUNCTION__);
+ break;
+ }
+ return 0;
+}
+
+/* Non-CSO state. (For now.) */
+
+static INLINE uint32_t r300_translate_gb_pipes(int pipe_count)
+{
+ switch (pipe_count) {
+ case 1:
+ return R300_GB_TILE_PIPE_COUNT_RV300;
+ break;
+ case 2:
+ return R300_GB_TILE_PIPE_COUNT_R300;
+ break;
+ case 3:
+ return R300_GB_TILE_PIPE_COUNT_R420_3P;
+ break;
+ case 4:
+ return R300_GB_TILE_PIPE_COUNT_R420;
+ break;
+ }
+ return 0;
+}
+
+static INLINE uint32_t translate_vertex_data_type(int type) {
+ switch (type) {
+ case EMIT_1F:
+ case EMIT_1F_PSIZE:
+ return R300_DATA_TYPE_FLOAT_1;
+ break;
+ case EMIT_2F:
+ return R300_DATA_TYPE_FLOAT_2;
+ break;
+ case EMIT_3F:
+ return R300_DATA_TYPE_FLOAT_3;
+ break;
+ case EMIT_4F:
+ return R300_DATA_TYPE_FLOAT_4;
+ break;
+ case EMIT_4UB:
+ return R300_DATA_TYPE_BYTE;
+ break;
+ default:
+ debug_printf("r300: Implementation error: "
+ "Bad vertex data type!\n");
+ assert(0);
+ break;
+ }
+
+ return 0;
+}
+
+#endif /* R300_STATE_INLINES_H */
diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c
new file mode 100644
index 0000000000..3d51a8e65d
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_state_invariant.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2009 Joakim Sindholt <opensource@zhasha.com>
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include "r300_state_invariant.h"
+
+/* Calculate and emit invariant state. This is data that the 3D engine
+ * will probably want at the beginning of every CS, but it's not currently
+ * handled by any CSO setup, and in addition it doesn't really change much.
+ *
+ * Note that eventually this should be empty, but it's useful for development
+ * and general unduplication of code. */
+void r300_emit_invariant_state(struct r300_context* r300)
+{
+ struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
+ CS_LOCALS(r300);
+
+ BEGIN_CS(24 + (caps->has_tcl ? 2: 0));
+
+ /* Various GB enables */
+ OUT_CS_REG(R300_GB_ENABLE, R300_GB_POINT_STUFF_ENABLE |
+ R300_GB_LINE_STUFF_ENABLE | R300_GB_TRIANGLE_STUFF_ENABLE);
+ /* Subpixel multisampling for AA */
+ OUT_CS_REG(R300_GB_MSPOS0, 0x66666666);
+ OUT_CS_REG(R300_GB_MSPOS1, 0x66666666);
+ /* GB tile config and pipe setup */
+ OUT_CS_REG(R300_GB_TILE_CONFIG, R300_GB_TILE_DISABLE |
+ r300_translate_gb_pipes(caps->num_frag_pipes));
+ /* Source of fog depth */
+ OUT_CS_REG(R300_GB_SELECT, R300_GB_FOG_SELECT_1_1_W);
+ /* AA enable */
+ OUT_CS_REG(R300_GB_AA_CONFIG, 0x0);
+ /* GA errata fixes. */
+ if (caps->is_r500) {
+ OUT_CS_REG(R300_GA_ENHANCE,
+ R300_GA_ENHANCE_DEADLOCK_CNTL_PREVENT_TCL |
+ R300_GA_ENHANCE_FASTSYNC_CNTL_ENABLE |
+ R500_GA_ENHANCE_REG_READWRITE_ENABLE |
+ R500_GA_ENHANCE_REG_NOSTALL_ENABLE);
+ } else {
+ OUT_CS_REG(R300_GA_ENHANCE,
+ R300_GA_ENHANCE_DEADLOCK_CNTL_PREVENT_TCL |
+ R300_GA_ENHANCE_FASTSYNC_CNTL_ENABLE);
+ }
+
+ /* Fog block. */
+ OUT_CS_REG(R300_FG_FOG_BLEND, 0x00000000);
+ OUT_CS_REG(R300_FG_FOG_COLOR_R, 0x00000000);
+ OUT_CS_REG(R300_FG_FOG_COLOR_G, 0x00000000);
+ OUT_CS_REG(R300_FG_FOG_COLOR_B, 0x00000000);
+ OUT_CS_REG(R300_FG_DEPTH_SRC, 0x00000000);
+
+ /* TCL-only stuff */
+ if (caps->has_tcl) {
+ /* Amount of time to wait for vertex fetches in PVS */
+ OUT_CS_REG(VAP_PVS_VTX_TIMEOUT_REG, 0xffff);
+ }
+
+ END_CS;
+
+ /* XXX unsorted stuff from surface_fill */
+ BEGIN_CS(99 + (caps->has_tcl ? 26 : 0));
+ /* Flush PVS. */
+ OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
+
+ OUT_CS_REG(R300_SE_VTE_CNTL, R300_VPORT_X_SCALE_ENA |
+ R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
+ R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
+ R300_VPORT_Z_OFFSET_ENA | R300_VTX_W0_FMT);
+ /* Max and min vertex index clamp. */
+ OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, 0xFFFFFF);
+ OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, 0x0);
+ /* XXX endian */
+ if (caps->has_tcl) {
+ OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VC_NO_SWAP);
+ OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE |
+ R300_PS_UCP_MODE_CLIP_AS_TRIFAN);
+ OUT_CS_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ, 4);
+ OUT_CS_32F(1.0);
+ OUT_CS_32F(1.0);
+ OUT_CS_32F(1.0);
+ OUT_CS_32F(1.0);
+ } else {
+ OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VC_NO_SWAP |
+ R300_VAP_TCL_BYPASS);
+ }
+ /* XXX magic number not in r300_reg */
+ OUT_CS_REG(R300_VAP_PSC_SGN_NORM_CNTL, 0xAAAAAAAA);
+ /* XXX point tex stuffing */
+ OUT_CS_REG_SEQ(R300_GA_POINT_S0, 1);
+ OUT_CS_32F(0.0);
+ OUT_CS_REG_SEQ(R300_GA_POINT_S1, 1);
+ OUT_CS_32F(1.0);
+ OUT_CS_REG(R300_GA_TRIANGLE_STIPPLE, 0x5 |
+ (0x5 << R300_GA_TRIANGLE_STIPPLE_Y_SHIFT_SHIFT));
+ /* XXX this big chunk should be refactored into rs_state */
+ OUT_CS_REG(R300_GA_LINE_S0, 0x00000000);
+ OUT_CS_REG(R300_GA_LINE_S1, 0x3F800000);
+ OUT_CS_REG(R300_GA_SOLID_RG, 0x00000000);
+ OUT_CS_REG(R300_GA_SOLID_BA, 0x00000000);
+ OUT_CS_REG(R300_GA_POLY_MODE, 0x00000000);
+ OUT_CS_REG(R300_GA_ROUND_MODE, 0x00000001);
+ OUT_CS_REG(R300_GA_OFFSET, 0x00000000);
+ OUT_CS_REG(R300_GA_FOG_SCALE, 0x3DBF1412);
+ OUT_CS_REG(R300_GA_FOG_OFFSET, 0x00000000);
+ OUT_CS_REG(R300_SU_TEX_WRAP, 0x00000000);
+ OUT_CS_REG(R300_SU_DEPTH_SCALE, 0x4B7FFFFF);
+ OUT_CS_REG(R300_SU_DEPTH_OFFSET, 0x00000000);
+ OUT_CS_REG(R300_SC_HYPERZ, 0x0000001C);
+ OUT_CS_REG(R300_SC_EDGERULE, 0x2DA49525);
+ OUT_CS_REG(R300_RB3D_CCTL, 0x00000000);
+ OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0x0000000F);
+ OUT_CS_REG(R300_RB3D_AARESOLVE_CTL, 0x00000000);
+ OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD, 0x00000000);
+ OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_GTE_THRESHOLD, 0xFFFFFFFF);
+ OUT_CS_REG(R300_ZB_FORMAT, 0x00000002);
+ OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT, 0x00000003);
+ OUT_CS_REG(R300_ZB_BW_CNTL, 0x00000000);
+ OUT_CS_REG(R300_ZB_DEPTHCLEARVALUE, 0x00000000);
+ OUT_CS_REG(R300_ZB_HIZ_OFFSET, 0x00000000);
+ OUT_CS_REG(R300_ZB_HIZ_PITCH, 0x00000000);
+ if (caps->has_tcl) {
+ OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
+ (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) |
+ ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) |
+ R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT));
+ } else {
+ OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
+ (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) |
+ ((R300_LAST_VEC | (2 << R300_DST_VEC_LOC_SHIFT) |
+ R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT));
+ }
+ OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0,
+ (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) |
+ (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT));
+ OUT_CS_REG(R300_VAP_VTX_STATE_CNTL, 0x1);
+ OUT_CS_REG(R300_VAP_VSM_VTX_ASSM, 0x405);
+ OUT_CS_REG(R300_SE_VTE_CNTL, 0x0000043F);
+ /* Vertex size. */
+ OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);
+ OUT_CS_REG(R300_VAP_PSC_SGN_NORM_CNTL, 0xAAAAAAAA);
+ OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0, 0x00000003);
+ OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x00000000);
+ OUT_CS_REG(R300_TX_ENABLE, 0x0);
+
+ /* XXX */
+ OUT_CS_REG(R300_SC_CLIP_RULE, 0xaaaa);
+
+ OUT_CS_REG_SEQ(R300_US_OUT_FMT_0, 4);
+ OUT_CS(R300_C0_SEL_B | R300_C1_SEL_G | R300_C2_SEL_R | R300_C3_SEL_A);
+ OUT_CS(R300_US_OUT_FMT_UNUSED);
+ OUT_CS(R300_US_OUT_FMT_UNUSED);
+ OUT_CS(R300_US_OUT_FMT_UNUSED);
+ OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W0);
+ /* XXX these magic numbers should be explained when
+ * this becomes a cached state object */
+ if (caps->has_tcl) {
+ OUT_CS_REG(R300_VAP_CNTL, 0xA |
+ (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) |
+ (0xB << R300_VF_MAX_VTX_NUM_SHIFT) |
+ (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT));
+ OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, 0x00100000);
+ OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x00000000);
+ OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, 0x00000001);
+ /* XXX translate these back into normal instructions */
+ OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x1);
+ OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0x0);
+ OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 8);
+ OUT_CS(0x00F00203);
+ OUT_CS(0x00D10001);
+ OUT_CS(0x01248001);
+ OUT_CS(0x00000000);
+ OUT_CS(0x00F02203);
+ OUT_CS(0x00D10021);
+ OUT_CS(0x01248021);
+ OUT_CS(0x00000000);
+ } else {
+ OUT_CS_REG(R300_VAP_CNTL, 0xA |
+ (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) |
+ (0x5 << R300_VF_MAX_VTX_NUM_SHIFT) |
+ (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT));
+ }
+ END_CS;
+}
diff --git a/src/gallium/drivers/r300/r300_state_invariant.h b/src/gallium/drivers/r300/r300_state_invariant.h
new file mode 100644
index 0000000000..8204bf9588
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_state_invariant.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_STATE_INVARIANT_H
+#define R300_STATE_INVARIANT_H
+
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_reg.h"
+#include "r300_state_inlines.h"
+
+void r300_emit_invariant_state(struct r300_context* r300);
+
+#endif /* R300_STATE_INVARIANT_H */
diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c
index e87172128f..20b83bd15b 100644
--- a/src/gallium/drivers/r300/r300_state_shader.c
+++ b/src/gallium/drivers/r300/r300_state_shader.c
@@ -22,12 +22,557 @@
#include "r300_state_shader.h"
-void r300_translate_shader(struct r300_context* r300,
- struct r300_fragment_shader* fs)
+static void r300_copy_passthrough_shader(struct r300_fragment_shader* fs)
{
+ struct r300_fragment_shader* pt = &r300_passthrough_fragment_shader;
+ fs->shader.stack_size = pt->shader.stack_size;
+ fs->alu_instruction_count = pt->alu_instruction_count;
+ fs->tex_instruction_count = pt->tex_instruction_count;
+ fs->indirections = pt->indirections;
+ fs->instructions[0] = pt->instructions[0];
}
-void r500_translate_shader(struct r300_context* r300,
- struct r500_fragment_shader* fs)
+static void r500_copy_passthrough_shader(struct r500_fragment_shader* fs)
{
+ struct r500_fragment_shader* pt = &r500_passthrough_fragment_shader;
+ fs->shader.stack_size = pt->shader.stack_size;
+ fs->instruction_count = pt->instruction_count;
+ fs->instructions[0] = pt->instructions[0];
+}
+
+static void r300_fs_declare(struct r300_fs_asm* assembler,
+ struct tgsi_full_declaration* decl)
+{
+ switch (decl->Declaration.File) {
+ case TGSI_FILE_INPUT:
+ switch (decl->Semantic.SemanticName) {
+ case TGSI_SEMANTIC_COLOR:
+ assembler->color_count++;
+ break;
+ case TGSI_SEMANTIC_GENERIC:
+ assembler->tex_count++;
+ break;
+ default:
+ debug_printf("r300: fs: Bad semantic declaration %d\n",
+ decl->Semantic.SemanticName);
+ break;
+ }
+ break;
+ case TGSI_FILE_OUTPUT:
+ case TGSI_FILE_CONSTANT:
+ break;
+ case TGSI_FILE_TEMPORARY:
+ assembler->temp_count++;
+ break;
+ default:
+ debug_printf("r300: fs: Bad file %d\n", decl->Declaration.File);
+ break;
+ }
+
+ assembler->temp_offset = assembler->color_count + assembler->tex_count;
+}
+
+static INLINE unsigned r300_fs_src(struct r300_fs_asm* assembler,
+ struct tgsi_src_register* src)
+{
+ switch (src->File) {
+ case TGSI_FILE_NULL:
+ return 0;
+ case TGSI_FILE_INPUT:
+ /* XXX may be wrong */
+ return src->Index;
+ break;
+ case TGSI_FILE_TEMPORARY:
+ return src->Index + assembler->temp_offset;
+ break;
+ case TGSI_FILE_IMMEDIATE:
+ return (src->Index + assembler->imm_offset) | (1 << 8);
+ break;
+ case TGSI_FILE_CONSTANT:
+ /* XXX magic */
+ return src->Index | (1 << 8);
+ break;
+ default:
+ debug_printf("r300: fs: Unimplemented src %d\n", src->File);
+ break;
+ }
+ return 0;
+}
+
+static INLINE unsigned r300_fs_dst(struct r300_fs_asm* assembler,
+ struct tgsi_dst_register* dst)
+{
+ switch (dst->File) {
+ case TGSI_FILE_NULL:
+ /* This happens during KIL instructions. */
+ return 0;
+ break;
+ case TGSI_FILE_OUTPUT:
+ return 0;
+ break;
+ case TGSI_FILE_TEMPORARY:
+ return dst->Index + assembler->temp_offset;
+ break;
+ default:
+ debug_printf("r300: fs: Unimplemented dst %d\n", dst->File);
+ break;
+ }
+ return 0;
+}
+
+static INLINE unsigned r500_fix_swiz(unsigned s)
+{
+ /* For historical reasons, the swizzle values x, y, z, w, and 0 are
+ * equivalent to the actual machine code, but 1 is not. Thus, we just
+ * adjust it a bit... */
+ if (s == TGSI_EXTSWIZZLE_ONE) {
+ return R500_SWIZZLE_ONE;
+ } else {
+ return s;
+ }
+}
+
+static uint32_t r500_rgba_swiz(struct tgsi_full_src_register* reg)
+{
+ if (reg->SrcRegister.Extended) {
+ return r500_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleX) |
+ (r500_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleY) << 3) |
+ (r500_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleZ) << 6) |
+ (r500_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleW) << 9);
+ } else {
+ return reg->SrcRegister.SwizzleX |
+ (reg->SrcRegister.SwizzleY << 3) |
+ (reg->SrcRegister.SwizzleZ << 6) |
+ (reg->SrcRegister.SwizzleW << 9);
+ }
+}
+
+static uint32_t r500_strq_swiz(struct tgsi_full_src_register* reg)
+{
+ return reg->SrcRegister.SwizzleX |
+ (reg->SrcRegister.SwizzleY << 2) |
+ (reg->SrcRegister.SwizzleZ << 4) |
+ (reg->SrcRegister.SwizzleW << 6);
+}
+
+static INLINE uint32_t r500_rgb_swiz(struct tgsi_full_src_register* reg)
+{
+ /* Only the first 9 bits... */
+ return (r500_rgba_swiz(reg) & 0x1ff) |
+ (reg->SrcRegister.Negate ? (1 << 9) : 0) |
+ (reg->SrcRegisterExtMod.Absolute ? (1 << 10) : 0);
+}
+
+static INLINE uint32_t r500_alpha_swiz(struct tgsi_full_src_register* reg)
+{
+ /* Only the last 3 bits... */
+ return (r500_rgba_swiz(reg) >> 9) |
+ (reg->SrcRegister.Negate ? (1 << 9) : 0) |
+ (reg->SrcRegisterExtMod.Absolute ? (1 << 10) : 0);
+}
+
+static INLINE uint32_t r500_rgba_op(unsigned op)
+{
+ switch (op) {
+ case TGSI_OPCODE_EX2:
+ case TGSI_OPCODE_LG2:
+ case TGSI_OPCODE_RCP:
+ case TGSI_OPCODE_RSQ:
+ return R500_ALU_RGBA_OP_SOP;
+ case TGSI_OPCODE_FRC:
+ return R500_ALU_RGBA_OP_FRC;
+ case TGSI_OPCODE_DP3:
+ return R500_ALU_RGBA_OP_DP3;
+ case TGSI_OPCODE_DP4:
+ case TGSI_OPCODE_DPH:
+ return R500_ALU_RGBA_OP_DP4;
+ case TGSI_OPCODE_ABS:
+ case TGSI_OPCODE_CMP:
+ case TGSI_OPCODE_MOV:
+ case TGSI_OPCODE_SWZ:
+ return R500_ALU_RGBA_OP_CMP;
+ case TGSI_OPCODE_ADD:
+ case TGSI_OPCODE_MAD:
+ case TGSI_OPCODE_MUL:
+ case TGSI_OPCODE_SUB:
+ return R500_ALU_RGBA_OP_MAD;
+ default:
+ return 0;
+ }
+}
+
+static INLINE uint32_t r500_alpha_op(unsigned op)
+{
+ switch (op) {
+ case TGSI_OPCODE_EX2:
+ return R500_ALPHA_OP_EX2;
+ case TGSI_OPCODE_LG2:
+ return R500_ALPHA_OP_LN2;
+ case TGSI_OPCODE_RCP:
+ return R500_ALPHA_OP_RCP;
+ case TGSI_OPCODE_RSQ:
+ return R500_ALPHA_OP_RSQ;
+ case TGSI_OPCODE_FRC:
+ return R500_ALPHA_OP_FRC;
+ case TGSI_OPCODE_DP3:
+ case TGSI_OPCODE_DP4:
+ case TGSI_OPCODE_DPH:
+ return R500_ALPHA_OP_DP;
+ case TGSI_OPCODE_ABS:
+ case TGSI_OPCODE_CMP:
+ case TGSI_OPCODE_MOV:
+ case TGSI_OPCODE_SWZ:
+ return R500_ALPHA_OP_CMP;
+ case TGSI_OPCODE_ADD:
+ case TGSI_OPCODE_MAD:
+ case TGSI_OPCODE_MUL:
+ case TGSI_OPCODE_SUB:
+ return R500_ALPHA_OP_MAD;
+ default:
+ return 0;
+ }
+}
+
+static INLINE uint32_t r500_tex_op(unsigned op)
+{
+ switch (op) {
+ case TGSI_OPCODE_KIL:
+ return R500_TEX_INST_TEXKILL;
+ case TGSI_OPCODE_TEX:
+ return R500_TEX_INST_LD;
+ case TGSI_OPCODE_TXB:
+ return R500_TEX_INST_LODBIAS;
+ case TGSI_OPCODE_TXP:
+ return R500_TEX_INST_PROJ;
+ default:
+ return 0;
+ }
+}
+
+/* Setup an ALU operation. */
+static INLINE void r500_emit_alu(struct r500_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_dst_register* dst)
+{
+ int i = fs->instruction_count;
+
+ if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
+ fs->instructions[i].inst0 = R500_INST_TYPE_OUT |
+ R500_ALU_OMASK(dst->DstRegister.WriteMask);
+ } else {
+ fs->instructions[i].inst0 = R500_INST_TYPE_ALU |
+ R500_ALU_WMASK(dst->DstRegister.WriteMask);
+ }
+
+ fs->instructions[i].inst0 |= R500_INST_TEX_SEM_WAIT;
+
+ fs->instructions[i].inst4 =
+ R500_ALPHA_ADDRD(r300_fs_dst(assembler, &dst->DstRegister));
+ fs->instructions[i].inst5 =
+ R500_ALU_RGBA_ADDRD(r300_fs_dst(assembler, &dst->DstRegister));
+}
+
+static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_src_register* src,
+ struct tgsi_full_dst_register* dst,
+ unsigned op,
+ unsigned count)
+{
+ int i = fs->instruction_count;
+
+ r500_emit_alu(fs, assembler, dst);
+
+ switch (count) {
+ case 3:
+ fs->instructions[i].inst1 =
+ R500_RGB_ADDR2(r300_fs_src(assembler, &src[2].SrcRegister));
+ fs->instructions[i].inst2 =
+ R500_ALPHA_ADDR2(r300_fs_src(assembler, &src[2].SrcRegister));
+ fs->instructions[i].inst5 |=
+ R500_ALU_RGBA_SEL_C_SRC2 |
+ R500_SWIZ_RGBA_C(r500_rgb_swiz(&src[2])) |
+ R500_ALU_RGBA_ALPHA_SEL_C_SRC2 |
+ R500_SWIZ_ALPHA_C(r500_alpha_swiz(&src[2]));
+ case 2:
+ fs->instructions[i].inst1 |=
+ R500_RGB_ADDR1(r300_fs_src(assembler, &src[1].SrcRegister));
+ fs->instructions[i].inst2 |=
+ R500_ALPHA_ADDR1(r300_fs_src(assembler, &src[1].SrcRegister));
+ fs->instructions[i].inst3 =
+ R500_ALU_RGB_SEL_B_SRC1 |
+ R500_SWIZ_RGB_B(r500_rgb_swiz(&src[1]));
+ fs->instructions[i].inst4 |=
+ R500_SWIZ_ALPHA_B(r500_alpha_swiz(&src[1])) |
+ R500_ALPHA_SEL_B_SRC1;
+ case 1:
+ case 0:
+ default:
+ fs->instructions[i].inst1 |=
+ R500_RGB_ADDR0(r300_fs_src(assembler, &src[0].SrcRegister));
+ fs->instructions[i].inst2 |=
+ R500_ALPHA_ADDR0(r300_fs_src(assembler, &src[0].SrcRegister));
+ fs->instructions[i].inst3 |=
+ R500_ALU_RGB_SEL_A_SRC0 |
+ R500_SWIZ_RGB_A(r500_rgb_swiz(&src[0]));
+ fs->instructions[i].inst4 |=
+ R500_SWIZ_ALPHA_A(r500_alpha_swiz(&src[0])) |
+ R500_ALPHA_SEL_A_SRC0;
+ break;
+ }
+
+ fs->instructions[i].inst4 |= r500_alpha_op(op);
+ fs->instructions[i].inst5 |= r500_rgba_op(op);
+
+ fs->instruction_count++;
+}
+
+static INLINE void r500_emit_tex(struct r500_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_src_register* src,
+ struct tgsi_full_dst_register* dst,
+ uint32_t op)
+{
+ int i = fs->instruction_count;
+
+ fs->instructions[i].inst0 = R500_INST_TYPE_TEX |
+ R500_TEX_WMASK(dst->DstRegister.WriteMask) |
+ R500_INST_TEX_SEM_WAIT;
+ fs->instructions[i].inst1 = R500_TEX_ID(0) |
+ R500_TEX_SEM_ACQUIRE | //R500_TEX_IGNORE_UNCOVERED |
+ r500_tex_op(op);
+ fs->instructions[i].inst2 =
+ R500_TEX_SRC_ADDR(r300_fs_src(assembler, &src->SrcRegister)) |
+ R500_SWIZ_TEX_STRQ(r500_strq_swiz(src)) |
+ R500_TEX_DST_ADDR(r300_fs_dst(assembler, &dst->DstRegister)) |
+ R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G |
+ R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A;
+
+ if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
+ fs->instructions[i].inst2 |=
+ R500_TEX_DST_ADDR(assembler->temp_count +
+ assembler->temp_offset);
+
+ fs->instruction_count++;
+
+ /* Setup and emit a MOV. */
+ src[0].SrcRegister.Index = assembler->temp_count;
+ src[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
+
+ src[1] = src[0];
+ src[2] = r500_constant_zero;
+ r500_emit_maths(fs, assembler, src, dst, TGSI_OPCODE_MOV, 3);
+ } else {
+ fs->instruction_count++;
+ }
+}
+
+static void r500_fs_instruction(struct r500_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_instruction* inst)
+{
+ int i;
+ /* Switch between opcodes. When possible, prefer using the official
+ * AMD/ATI names for opcodes, please, as it facilitates using the
+ * documentation. */
+ switch (inst->Instruction.Opcode) {
+ /* The simple scalar ops. */
+ case TGSI_OPCODE_EX2:
+ case TGSI_OPCODE_LG2:
+ case TGSI_OPCODE_RCP:
+ case TGSI_OPCODE_RSQ:
+ /* Copy red swizzle to alpha for src0 */
+ inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleW =
+ inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleX;
+ inst->FullSrcRegisters[0].SrcRegister.SwizzleW =
+ inst->FullSrcRegisters[0].SrcRegister.SwizzleX;
+ /* Fall through */
+ case TGSI_OPCODE_FRC:
+ r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode, 1);
+ break;
+
+ /* The dot products. */
+ case TGSI_OPCODE_DPH:
+ /* Set alpha swizzle to one for src0 */
+ if (!inst->FullSrcRegisters[0].SrcRegister.Extended) {
+ inst->FullSrcRegisters[0].SrcRegister.Extended = TRUE;
+ inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleX =
+ inst->FullSrcRegisters[0].SrcRegister.SwizzleX;
+ inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleY =
+ inst->FullSrcRegisters[0].SrcRegister.SwizzleY;
+ inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleZ =
+ inst->FullSrcRegisters[0].SrcRegister.SwizzleZ;
+ }
+ inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleW =
+ TGSI_EXTSWIZZLE_ONE;
+ /* Fall through */
+ case TGSI_OPCODE_DP3:
+ case TGSI_OPCODE_DP4:
+ r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode, 2);
+ break;
+
+ /* Simple three-source operations. */
+ case TGSI_OPCODE_CMP:
+ /* Swap src0 and src2 */
+ inst->FullSrcRegisters[3] = inst->FullSrcRegisters[2];
+ inst->FullSrcRegisters[2] = inst->FullSrcRegisters[0];
+ inst->FullSrcRegisters[0] = inst->FullSrcRegisters[3];
+ r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
+ break;
+
+ /* The MAD variants. */
+ case TGSI_OPCODE_SUB:
+ /* Just like ADD, but flip the negation on src1 first */
+ inst->FullSrcRegisters[1].SrcRegister.Negate =
+ !inst->FullSrcRegisters[1].SrcRegister.Negate;
+ /* Fall through */
+ case TGSI_OPCODE_ADD:
+ /* Force src0 to one, move all registers over */
+ inst->FullSrcRegisters[2] = inst->FullSrcRegisters[1];
+ inst->FullSrcRegisters[1] = inst->FullSrcRegisters[0];
+ inst->FullSrcRegisters[0] = r500_constant_one;
+ r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
+ break;
+ case TGSI_OPCODE_MUL:
+ /* Force our src2 to zero */
+ inst->FullSrcRegisters[2] = r500_constant_zero;
+ r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
+ break;
+ case TGSI_OPCODE_MAD:
+ r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
+ break;
+
+ /* The MOV variants. */
+ case TGSI_OPCODE_ABS:
+ /* Set absolute value modifiers. */
+ inst->FullSrcRegisters[0].SrcRegisterExtMod.Absolute = TRUE;
+ /* Fall through */
+ case TGSI_OPCODE_MOV:
+ case TGSI_OPCODE_SWZ:
+ /* src0 -> src1 and src2 forced to zero */
+ inst->FullSrcRegisters[1] = inst->FullSrcRegisters[0];
+ inst->FullSrcRegisters[2] = r500_constant_zero;
+ r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
+ break;
+
+ /* The texture instruction set. */
+ case TGSI_OPCODE_KIL:
+ case TGSI_OPCODE_TEX:
+ case TGSI_OPCODE_TXB:
+ case TGSI_OPCODE_TXP:
+ r500_emit_tex(fs, assembler, &inst->FullSrcRegisters[0],
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode);
+ break;
+
+ /* This is the end. My only friend, the end. */
+ case TGSI_OPCODE_END:
+ break;
+ default:
+ debug_printf("r300: fs: Bad opcode %d\n",
+ inst->Instruction.Opcode);
+ break;
+ }
+
+ /* Clamp, if saturation flags are set. */
+ if (inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE) {
+ fs->instructions[fs->instruction_count - 1].inst0 |=
+ R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP;
+ }
+}
+
+static void r500_fs_finalize(struct r500_fragment_shader* fs,
+ struct r300_fs_asm* assembler)
+{
+ fs->shader.stack_size = assembler->temp_count + assembler->temp_offset;
+
+ /* XXX should this just go with OPCODE_END? */
+ fs->instructions[fs->instruction_count - 1].inst0 |=
+ R500_INST_LAST;
+}
+
+void r300_translate_fragment_shader(struct r300_context* r300,
+ struct r300_fragment_shader* fs)
+{
+ struct tgsi_parse_context parser;
+
+ tgsi_parse_init(&parser, fs->shader.state.tokens);
+
+ while (!tgsi_parse_end_of_tokens(&parser)) {
+ tgsi_parse_token(&parser);
+ }
+
+ r300_copy_passthrough_shader(fs);
+}
+
+void r500_translate_fragment_shader(struct r300_context* r300,
+ struct r500_fragment_shader* fs)
+{
+ struct tgsi_parse_context parser;
+ int i;
+ struct r300_constant_buffer* consts =
+ &r300->shader_constants[PIPE_SHADER_FRAGMENT];
+
+ struct r300_fs_asm* assembler = CALLOC_STRUCT(r300_fs_asm);
+ if (assembler == NULL) {
+ return;
+ }
+ /* Setup starting offset for immediates. */
+ assembler->imm_offset = consts->user_count;
+
+ tgsi_parse_init(&parser, fs->shader.state.tokens);
+
+ while (!tgsi_parse_end_of_tokens(&parser)) {
+ tgsi_parse_token(&parser);
+
+ /* This is seriously the lamest way to create fragment programs ever.
+ * I blame TGSI. */
+ switch (parser.FullToken.Token.Type) {
+ case TGSI_TOKEN_TYPE_DECLARATION:
+ /* Allocated registers sitting at the beginning
+ * of the program. */
+ r300_fs_declare(assembler, &parser.FullToken.FullDeclaration);
+ break;
+ case TGSI_TOKEN_TYPE_IMMEDIATE:
+ debug_printf("r300: Emitting immediate to constant buffer, "
+ "position %d\n",
+ assembler->imm_offset + assembler->imm_count);
+ /* I am not amused by the length of these. */
+ for (i = 0; i < 4; i++) {
+ consts->constants[assembler->imm_offset +
+ assembler->imm_count][i] =
+ parser.FullToken.FullImmediate.u.ImmediateFloat32[i]
+ .Float;
+ }
+ assembler->imm_count++;
+ break;
+ case TGSI_TOKEN_TYPE_INSTRUCTION:
+ r500_fs_instruction(fs, assembler,
+ &parser.FullToken.FullInstruction);
+ break;
+ }
+
+ }
+
+ debug_printf("r300: %d texs and %d colors, first free reg is %d\n",
+ assembler->tex_count, assembler->color_count,
+ assembler->tex_count + assembler->color_count);
+
+ consts->count = consts->user_count + assembler->imm_count;
+ debug_printf("r300: %d total constants, "
+ "%d from user and %d from immediates\n", consts->count,
+ consts->user_count, assembler->imm_count);
+ r500_fs_finalize(fs, assembler);
+
+ tgsi_dump(fs->shader.state.tokens);
+ r500_fs_dump(fs);
+
+ tgsi_parse_free(&parser);
+ FREE(assembler);
}
diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h
index a20bd4276c..06c0bb7378 100644
--- a/src/gallium/drivers/r300/r300_state_shader.h
+++ b/src/gallium/drivers/r300/r300_state_shader.h
@@ -23,13 +23,142 @@
#ifndef R300_STATE_SHADER_H
#define R300_STATE_SHADER_H
+#include "tgsi/tgsi_parse.h"
+
#include "r300_context.h"
+#include "r300_debug.h"
+#include "r300_reg.h"
#include "r300_screen.h"
-void r300_translate_shader(struct r300_context* r300,
+/* XXX this all should find its way back to r300_reg */
+/* Swizzle tools */
+#define R500_SWIZZLE_ZERO 4
+#define R500_SWIZZLE_HALF 5
+#define R500_SWIZZLE_ONE 6
+#define R500_SWIZ_RGB_ZERO ((4 << 0) | (4 << 3) | (4 << 6))
+#define R500_SWIZ_RGB_ONE ((6 << 0) | (6 << 3) | (6 << 6))
+#define R500_SWIZ_RGB_RGB ((0 << 0) | (1 << 3) | (2 << 6))
+#define R500_SWIZ_MOD_NEG 1
+#define R500_SWIZ_MOD_ABS 2
+#define R500_SWIZ_MOD_NEG_ABS 3
+/* Swizzles for inst2 */
+#define R500_SWIZ_TEX_STRQ(x) ((x) << 8)
+#define R500_SWIZ_TEX_RGBA(x) ((x) << 24)
+/* Swizzles for inst3 */
+#define R500_SWIZ_RGB_A(x) ((x) << 2)
+#define R500_SWIZ_RGB_B(x) ((x) << 15)
+/* Swizzles for inst4 */
+#define R500_SWIZ_ALPHA_A(x) ((x) << 14)
+#define R500_SWIZ_ALPHA_B(x) ((x) << 21)
+/* Swizzle for inst5 */
+#define R500_SWIZ_RGBA_C(x) ((x) << 14)
+#define R500_SWIZ_ALPHA_C(x) ((x) << 27)
+/* Writemasks */
+#define R500_TEX_WMASK(x) ((x) << 11)
+#define R500_ALU_WMASK(x) ((x) << 11)
+#define R500_ALU_OMASK(x) ((x) << 15)
+
+/* TGSI constants. TGSI is like XML: If it can't solve your problems, you're
+ * not using enough of it. */
+static const struct tgsi_full_src_register r500_constant_zero = {
+ .SrcRegister.Extended = TRUE,
+ .SrcRegister.File = TGSI_FILE_NULL,
+ .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ZERO,
+ .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ZERO,
+ .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ZERO,
+ .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ZERO,
+};
+
+static const struct tgsi_full_src_register r500_constant_one = {
+ .SrcRegister.Extended = TRUE,
+ .SrcRegister.File = TGSI_FILE_NULL,
+ .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ONE,
+ .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ONE,
+ .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ONE,
+ .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ONE,
+};
+
+/* Temporary struct used to hold assembly state while putting together
+ * fragment programs. */
+struct r300_fs_asm {
+ /* Pipe context. */
+ struct r300_context* r300;
+ /* Number of colors. */
+ unsigned color_count;
+ /* Number of texcoords. */
+ unsigned tex_count;
+ /* Offset for temporary registers. Inputs and temporaries have no
+ * distinguishing markings, so inputs start at 0 and the first usable
+ * temporary register is after all inputs. */
+ unsigned temp_offset;
+ /* Number of requested temporary registers. */
+ unsigned temp_count;
+ /* Offset for immediate constants. Neither R300 nor R500 can do four
+ * inline constants per source, so instead we copy immediates into the
+ * constant buffer. */
+ unsigned imm_offset;
+ /* Number of immediate constants. */
+ unsigned imm_count;
+};
+
+void r300_translate_fragment_shader(struct r300_context* r300,
struct r300_fragment_shader* fs);
-void r500_translate_shader(struct r300_context* r300,
+void r500_translate_fragment_shader(struct r300_context* r300,
struct r500_fragment_shader* fs);
+static const struct r300_fragment_shader r300_passthrough_fragment_shader = {
+ /* XXX This is the emission code. TODO: decode
+ OUT_CS_REG(R300_US_CONFIG, 0);
+ OUT_CS_REG(R300_US_CODE_OFFSET, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_3, 0x400000);
+*/
+ .alu_instruction_count = 1,
+ .tex_instruction_count = 0,
+ .indirections = 1,
+ .shader.stack_size = 2,
+
+ .instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
+ R300_RGB_SWIZB(R300_ALU_ARGC_ONE) |
+ R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
+ R300_ALU_OUTC_MAD,
+ .instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
+ R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
+ .instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
+ R300_ALPHA_SWIZB(R300_ALU_ARGA_ONE) |
+ R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
+ R300_ALU_OUTA_MAD,
+ .instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) |
+ R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
+};
+
+static const struct r500_fragment_shader r500_passthrough_fragment_shader = {
+ .shader.stack_size = 0,
+ .instruction_count = 1,
+ .instructions[0].inst0 = R500_INST_TYPE_OUT |
+ R500_INST_TEX_SEM_WAIT | R500_INST_LAST |
+ R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK |
+ R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP,
+ .instructions[0].inst1 =
+ R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST |
+ R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST,
+ .instructions[0].inst2 =
+ R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST |
+ R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST,
+ .instructions[0].inst3 =
+ R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R |
+ R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B |
+ R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R |
+ R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B,
+ .instructions[0].inst4 =
+ R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A,
+ .instructions[0].inst5 =
+ R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 |
+ R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 |
+ R500_ALU_RGBA_A_SWIZ_0,
+};
+
#endif /* R300_STATE_SHADER_H */
diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c
index 1e1f96a7f9..2cc0677e52 100644
--- a/src/gallium/drivers/r300/r300_surface.c
+++ b/src/gallium/drivers/r300/r300_surface.c
@@ -1,5 +1,6 @@
/*
* Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Joakim Sindholt <opensource@zhasha.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -32,321 +33,161 @@ static void r300_surface_fill(struct pipe_context* pipe,
{
struct r300_context* r300 = r300_context(pipe);
CS_LOCALS(r300);
- struct r300_capabilities* caps = ((struct r300_screen*)pipe->screen)->caps;
+ struct r300_capabilities* caps = r300_screen(pipe->screen)->caps;
struct r300_texture* tex = (struct r300_texture*)dest->texture;
int i;
- float r, g, b, a;
+ float r, g, b, a, depth;
+ unsigned pixpitch = tex->stride / tex->tex.block.size;
+
r = (float)((color >> 16) & 0xff) / 255.0f;
g = (float)((color >> 8) & 0xff) / 255.0f;
b = (float)((color >> 0) & 0xff) / 255.0f;
debug_printf("r300: Filling surface %p at (%d,%d),"
- " dimensions %dx%d (stride %d), color 0x%x\n",
- dest, x, y, w, h, dest->stride, color);
+ " dimensions %dx%d (pixel pitch %d), color 0x%x\n",
+ dest, x, y, w, h, pixpitch, color);
/* Fallback? */
- if (0) {
+ if (tex->tex.format != PIPE_FORMAT_A8R8G8B8_UNORM) {
debug_printf("r300: Falling back on surface clear...");
- void* map = pipe->screen->surface_map(pipe->screen, dest,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- pipe_fill_rect(map, &dest->block, &dest->stride, x, y, w, h, color);
- pipe->screen->surface_unmap(pipe->screen, dest);
+ util_surface_fill(pipe, dest, x, y, w, h, color);
return;
}
-BEGIN_CS((caps->is_r500) ? 309 : 280);
-R300_PACIFY;
-OUT_CS_REG(R300_TX_INVALTAGS, 0x0);
-R300_PACIFY;
-/* Flush PVS. */
-OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
-
-OUT_CS_REG(R300_SE_VTE_CNTL, R300_VPORT_X_SCALE_ENA |
- R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
- R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
- R300_VPORT_Z_OFFSET_ENA | R300_VTX_W0_FMT);
-/* Vertex size. */
-OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);
-/* Max and min vertex index clamp. */
-OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, 0xFFFFFF);
-OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, 0x0);
-/* XXX endian */
-OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VC_NO_SWAP);
-OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, 0x0);
-/* XXX magic number not in r300_reg */
-OUT_CS_REG(R300_VAP_PSC_SGN_NORM_CNTL, 0xAAAAAAAA);
-OUT_CS_REG(R300_VAP_CLIP_CNTL, 0x0);
-OUT_CS_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ, 4);
-OUT_CS_32F(1.0);
-OUT_CS_32F(1.0);
-OUT_CS_32F(1.0);
-OUT_CS_32F(1.0);
-/* XXX is this too long? */
-OUT_CS_REG(VAP_PVS_VTX_TIMEOUT_REG, 0xFFFF);
-OUT_CS_REG(R300_GB_ENABLE, R300_GB_POINT_STUFF_ENABLE |
- R300_GB_LINE_STUFF_ENABLE | R300_GB_TRIANGLE_STUFF_ENABLE);
-/* XXX more magic numbers */
-OUT_CS_REG(R300_GB_MSPOS0, 0x66666666);
-OUT_CS_REG(R300_GB_MSPOS1, 0x66666666);
-/* XXX why doesn't classic Mesa write the number of pipes, too? */
-OUT_CS_REG(R300_GB_TILE_CONFIG, R300_GB_TILE_ENABLE | R300_GB_TILE_SIZE_16);
-OUT_CS_REG(R300_GB_SELECT, R300_GB_FOG_SELECT_1_1_W);
-OUT_CS_REG(R300_GB_AA_CONFIG, 0x0);
-/* XXX point tex stuffing */
-OUT_CS_REG_SEQ(R300_GA_POINT_S0, 1);
-OUT_CS_32F(0.0);
-OUT_CS_REG_SEQ(R300_GA_POINT_S1, 1);
-OUT_CS_32F(1.0);
-OUT_CS_REG(R300_GA_TRIANGLE_STIPPLE, 0x5 |
- (0x5 << R300_GA_TRIANGLE_STIPPLE_Y_SHIFT_SHIFT));
-/* XXX should this be related to the actual point size? */
-OUT_CS_REG(R300_GA_POINT_MINMAX, 0x6 |
- (0x1800 << R300_GA_POINT_MINMAX_MAX_SHIFT));
-/* XXX this big chunk should be refactored into rs_state */
-OUT_CS_REG(R300_GA_LINE_CNTL, 0x00030006);
-OUT_CS_REG(R300_GA_LINE_STIPPLE_CONFIG, 0x3BAAAAAB);
-OUT_CS_REG(R300_GA_LINE_STIPPLE_VALUE, 0x00000000);
-OUT_CS_REG(R300_GA_LINE_S0, 0x00000000);
-OUT_CS_REG(R300_GA_LINE_S1, 0x3F800000);
-OUT_CS_REG(R300_GA_ENHANCE, 0x00000002);
-OUT_CS_REG(R300_GA_COLOR_CONTROL, 0x0003AAAA);
-OUT_CS_REG(R300_GA_SOLID_RG, 0x00000000);
-OUT_CS_REG(R300_GA_SOLID_BA, 0x00000000);
-OUT_CS_REG(R300_GA_POLY_MODE, 0x00000000);
-OUT_CS_REG(R300_GA_ROUND_MODE, 0x00000001);
-OUT_CS_REG(R300_GA_OFFSET, 0x00000000);
-OUT_CS_REG(R300_GA_FOG_SCALE, 0x3DBF1412);
-OUT_CS_REG(R300_GA_FOG_OFFSET, 0x00000000);
-OUT_CS_REG(R300_SU_TEX_WRAP, 0x00000000);
-OUT_CS_REG(R300_SU_POLY_OFFSET_FRONT_SCALE, 0x00000000);
-OUT_CS_REG(R300_SU_POLY_OFFSET_FRONT_OFFSET, 0x00000000);
-OUT_CS_REG(R300_SU_POLY_OFFSET_BACK_SCALE, 0x00000000);
-OUT_CS_REG(R300_SU_POLY_OFFSET_BACK_OFFSET, 0x00000000);
-OUT_CS_REG(R300_SU_POLY_OFFSET_ENABLE, 0x00000000);
-OUT_CS_REG(R300_SU_CULL_MODE, 0x00000000);
-OUT_CS_REG(R300_SU_DEPTH_SCALE, 0x4B7FFFFF);
-OUT_CS_REG(R300_SU_DEPTH_OFFSET, 0x00000000);
-OUT_CS_REG(R300_SC_HYPERZ, 0x0000001C);
-OUT_CS_REG(R300_SC_EDGERULE, 0x2DA49525);
-OUT_CS_REG(R300_SC_SCREENDOOR, 0x00FFFFFF);
-OUT_CS_REG(R300_FG_FOG_BLEND, 0x00000002);
-OUT_CS_REG(R300_FG_FOG_COLOR_R, 0x00000000);
-OUT_CS_REG(R300_FG_FOG_COLOR_G, 0x00000000);
-OUT_CS_REG(R300_FG_FOG_COLOR_B, 0x00000000);
-OUT_CS_REG(R300_FG_DEPTH_SRC, 0x00000000);
-OUT_CS_REG(R300_FG_DEPTH_SRC, 0x00000000);
-OUT_CS_REG(R300_RB3D_CCTL, 0x00000000);
-OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0x0000000F);
-
-/* XXX: Oh the wonderful unknown */
-OUT_CS_REG_SEQ(0x4E54, 8);
-for (i = 0; i < 8; i++)
- OUT_CS(0x00000000);
-OUT_CS_REG(R300_RB3D_AARESOLVE_CTL, 0x00000000);
-OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD, 0x00000000);
-OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_GTE_THRESHOLD, 0xFFFFFFFF);
-OUT_CS_REG(R300_ZB_FORMAT, 0x00000002);
-OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT, 0x00000003);
-OUT_CS_REG(R300_ZB_BW_CNTL, 0x00000000);
-OUT_CS_REG(R300_ZB_DEPTHCLEARVALUE, 0x00000000);
-OUT_CS_REG(0x4F30, 0x00000000);
-OUT_CS_REG(0x4F34, 0x00000000);
-OUT_CS_REG(R300_ZB_HIZ_OFFSET, 0x00000000);
-OUT_CS_REG(R300_ZB_HIZ_PITCH, 0x00000000);
-R300_PACIFY;
-if (caps->has_tcl) {
- OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
- (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) |
- ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) |
- R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT));
-} else {
- OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0,
- (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) |
- ((R300_LAST_VEC | (2 << R300_DST_VEC_LOC_SHIFT) |
- R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT));
-}
-OUT_CS_REG(R300_FG_FOG_BLEND, 0x00000000);
-OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0, 0xF688F688);
-OUT_CS_REG(R300_VAP_VTX_STATE_CNTL, 0x1);
-OUT_CS_REG(R300_VAP_VSM_VTX_ASSM, 0x405);
-OUT_CS_REG(R300_SE_VTE_CNTL, 0x0000043F);
-OUT_CS_REG(R300_VAP_VTX_SIZE, 0x00000008);
-OUT_CS_REG(R300_VAP_PSC_SGN_NORM_CNTL, 0xAAAAAAAA);
-OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0, 0x00000003);
-OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x00000000);
-OUT_CS_REG(R300_TX_ENABLE, 0x0);
-/* XXX viewport setup */
-OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6);
-OUT_CS_32F(1.0);
-OUT_CS_32F((float)x);
-OUT_CS_32F(1.0);
-OUT_CS_32F((float)y);
-OUT_CS_32F(1.0);
-OUT_CS_32F(0.0);
-
-if (caps->has_tcl) {
- OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE |
- R300_PS_UCP_MODE_CLIP_AS_TRIFAN);
-}
-
-OUT_CS_REG(R300_GA_POINT_SIZE, ((h * 6) & R300_POINTSIZE_Y_MASK) |
- ((w * 6) << R300_POINTSIZE_X_SHIFT));
-
-/* XXX RS block and fp setup */
-if (caps->is_r500) {
- OUT_CS_REG_SEQ(R500_RS_IP_0, 8);
- for (i = 0; i < 8; i++) {
- /* I like the operator macros more than the shift macros... */
- OUT_CS((R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_S_SHIFT) |
- (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_T_SHIFT) |
- (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT) |
- (R500_RS_IP_PTR_K1 << R500_RS_IP_TEX_PTR_Q_SHIFT));
+ r300_emit_blend_state(r300, &blend_clear_state);
+ r300_emit_blend_color_state(r300, &blend_color_clear_state);
+ r300_emit_dsa_state(r300, &dsa_clear_state);
+ r300_emit_rs_state(r300, &rs_clear_state);
+
+ /* Fragment shader setup */
+ if (caps->is_r500) {
+ r500_emit_fragment_shader(r300, &r500_passthrough_fragment_shader);
+ r300_emit_rs_block_state(r300, &r500_rs_block_clear_state);
+ } else {
+ r300_emit_fragment_shader(r300, &r300_passthrough_fragment_shader);
+ r300_emit_rs_block_state(r300, &r300_rs_block_clear_state);
}
- /* XXX */
- OUT_CS_REG_SEQ(R300_RS_COUNT, 2);
- OUT_CS((1 << R300_IC_COUNT_SHIFT) | R300_HIRES_EN);
- OUT_CS(0x0);
- OUT_CS_REG(R500_RS_INST_0, R500_RS_INST_COL_CN_WRITE);
- OUT_CS_REG(R500_US_CONFIG, R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO);
- OUT_CS_REG(R500_US_PIXSIZE, 0x00000000);
- OUT_CS_REG(R500_US_CODE_ADDR, R500_US_CODE_START_ADDR(0) |
- R500_US_CODE_END_ADDR(1));
- OUT_CS_REG(R500_US_CODE_RANGE, R500_US_CODE_RANGE_ADDR(0) |
- R500_US_CODE_RANGE_SIZE(1));
- OUT_CS_REG(R500_US_CODE_OFFSET, R500_US_CODE_OFFSET_ADDR(0));
- R300_PACIFY;
- OUT_CS_REG(R500_GA_US_VECTOR_INDEX,
- 0 | R500_GA_US_VECTOR_INDEX_TYPE_INSTR);
- OUT_CS_REG(R500_GA_US_VECTOR_DATA,
- R500_INST_TYPE_OUT | R500_INST_TEX_SEM_WAIT | R500_INST_LAST |
- R500_INST_RGB_OMASK_R | R500_INST_RGB_OMASK_G | R500_INST_RGB_OMASK_B |
- R500_INST_ALPHA_OMASK | R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP);
- OUT_CS_REG(R500_GA_US_VECTOR_DATA,
- R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST |
- R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST);
- OUT_CS_REG(R500_GA_US_VECTOR_DATA,
- R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST |
- R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST);
- OUT_CS_REG(R500_GA_US_VECTOR_DATA,
- R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R |
- R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B |
- R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R |
- R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B);
- OUT_CS_REG(R500_GA_US_VECTOR_DATA,
- R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A);
- OUT_CS_REG(R500_GA_US_VECTOR_DATA,
- R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 |
- R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 |
- R500_ALU_RGBA_A_SWIZ_0);
-} else {
- OUT_CS_REG_SEQ(R300_RS_IP_0, 8);
- for (i = 0; i < 8; i++) {
- OUT_CS(R300_RS_SEL_T(R300_RS_SEL_K0) |
- R300_RS_SEL_R(R300_RS_SEL_K0) | R300_RS_SEL_Q(R300_RS_SEL_K1));
- }
- /* XXX */
- OUT_CS_REG_SEQ(R300_RS_COUNT, 2);
- OUT_CS((1 << R300_IC_COUNT_SHIFT) | R300_HIRES_EN);
- OUT_CS(1);
- OUT_CS_REG(R300_RS_INST_0, R300_RS_INST_COL_CN_WRITE);
-
- /* XXX magic numbers */
- OUT_CS_REG(R300_US_CONFIG, 0);
- OUT_CS_REG(R300_US_PIXSIZE, 2);
- OUT_CS_REG(R300_US_CODE_OFFSET, 0x0);
- OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0);
- OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0);
- OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0);
- OUT_CS_REG(R300_US_CODE_ADDR_3, 0x400000);
- OUT_CS_REG(R300_US_ALU_RGB_INST_0, 0x50A80);
- OUT_CS_REG(R300_US_ALU_RGB_ADDR_0, 0x1C000000);
- OUT_CS_REG(R300_US_ALU_ALPHA_INST_0, 0x40889);
- OUT_CS_REG(R300_US_ALU_ALPHA_ADDR_0, 0x1000000);
- OUT_CS_REG_SEQ(R300_US_OUT_FMT_0, 4);
- OUT_CS(R300_C0_SEL_B | R300_C1_SEL_G | R300_C2_SEL_R | R300_C3_SEL_A);
- OUT_CS(R300_US_OUT_FMT_UNUSED);
- OUT_CS(R300_US_OUT_FMT_UNUSED);
- OUT_CS(R300_US_OUT_FMT_UNUSED);
- OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W0);
-}
-/* XXX these magic numbers should be explained when
- * this becomes a cached state object */
-if (caps->has_tcl) {
- OUT_CS_REG(R300_VAP_CNTL, 0xA |
- (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) |
- (0xB << R300_VF_MAX_VTX_NUM_SHIFT) |
- (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT));
- OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, 0x00100000);
- OUT_CS_REG(R300_VAP_PVS_CONST_CNTL, 0x00000000);
- OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_1, 0x00000001);
- R300_PACIFY;
- /* XXX translate these back into normal instructions */
- OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x1);
- OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0x0);
- OUT_CS_REG(R300_VAP_PVS_UPLOAD_DATA, 0xF00203);
- OUT_CS_REG(R300_VAP_PVS_UPLOAD_DATA, 0xD10001);
- OUT_CS_REG(R300_VAP_PVS_UPLOAD_DATA, 0x1248001);
- OUT_CS_REG(R300_VAP_PVS_UPLOAD_DATA, 0x0);
- OUT_CS_REG(R300_VAP_PVS_UPLOAD_DATA, 0xF02203);
- OUT_CS_REG(R300_VAP_PVS_UPLOAD_DATA, 0xD10021);
- OUT_CS_REG(R300_VAP_PVS_UPLOAD_DATA, 0x1248021);
- OUT_CS_REG(R300_VAP_PVS_UPLOAD_DATA, 0x0);
-} else {
- OUT_CS_REG(R300_VAP_CNTL, 0xA |
- (0x5 << R300_PVS_NUM_CNTLRS_SHIFT) |
- (0x5 << R300_VF_MAX_VTX_NUM_SHIFT) |
- (caps->num_vert_fpus << R300_PVS_NUM_FPUS_SHIFT));
+ BEGIN_CS(36);
+
+ /* Viewport setup */
+ OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6);
+ OUT_CS_32F(1.0);
+ OUT_CS_32F((float)x);
+ OUT_CS_32F(1.0);
+ OUT_CS_32F((float)y);
+ OUT_CS_32F(1.0);
+ OUT_CS_32F(0.0);
+
+ /* Pixel scissors */
+ OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2);
+ OUT_CS((x << R300_SCISSORS_X_SHIFT) | (y << R300_SCISSORS_Y_SHIFT));
+ OUT_CS((w << R300_SCISSORS_X_SHIFT) | (h << R300_SCISSORS_Y_SHIFT));
+
+ /* The size of the point we're about to draw, in sixths of pixels */
+ OUT_CS_REG(R300_GA_POINT_SIZE,
+ ((h * 6) & R300_POINTSIZE_Y_MASK) |
+ ((w * 6) << R300_POINTSIZE_X_SHIFT));
+
+ /* Flush colorbuffer and blend caches. */
+ OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
+ R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D |
+ R300_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_SIGNAL);
+ OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
+ R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
+ R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
+
+ OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0, 1);
+ OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+ OUT_CS_REG(R300_RB3D_COLORPITCH0, pixpitch |
+ r300_translate_colorformat(tex->tex.format));
+ OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0x0000000F);
+ /* XXX Packet3 */
+ OUT_CS(CP_PACKET3(R200_3D_DRAW_IMMD_2, 8));
+ OUT_CS(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING |
+ (1 << R300_PRIM_NUM_VERTICES_SHIFT));
+ OUT_CS_32F(w / 2.0);
+ OUT_CS_32F(h / 2.0);
+ /* XXX this should be the depth value to clear to */
+ OUT_CS_32F(1.0);
+ OUT_CS_32F(1.0);
+ OUT_CS_32F(r);
+ OUT_CS_32F(g);
+ OUT_CS_32F(b);
+ OUT_CS_32F(1.0);
+
+ /* XXX figure out why this is 0xA and not 0x2 */
+ OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
+ /* XXX OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
+ R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
+ R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE); */
+
+ END_CS;
+
+ r300->dirty_hw++;
}
-R300_PACIFY;
-END_CS;
-r300_emit_blend_state(r300, &blend_clear_state);
-r300_emit_blend_color_state(r300, &blend_color_clear_state);
-r300_emit_dsa_state(r300, &dsa_clear_state);
-
-BEGIN_CS(36);
-R300_PACIFY;
-/* Flush colorbuffer and blend caches. */
-OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
- R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D |
- R300_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_SIGNAL);
-OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
- R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
- R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
-
-OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0, 1);
-OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
-/* XXX this should not be so rigid and it still doesn't work right */
-OUT_CS_REG(R300_RB3D_COLORPITCH0, (dest->stride >> 2) | R300_COLOR_FORMAT_ARGB8888);
-OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0x0000000F);
-/* XXX Packet3 */
-OUT_CS(CP_PACKET3(R200_3D_DRAW_IMMD_2, 8));
-OUT_CS(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING |
-(1 << R300_PRIM_NUM_VERTICES_SHIFT));
-OUT_CS_32F(w / 2.0);
-OUT_CS_32F(h / 2.0);
-/* XXX this should be the depth value to clear to */
-OUT_CS_32F(1.0);
-OUT_CS_32F(1.0);
-OUT_CS_32F(r);
-OUT_CS_32F(g);
-OUT_CS_32F(b);
-OUT_CS_32F(1.0);
-
-/* XXX figure out why this is 0xA and not 0x2 */
-OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
-/* XXX OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
- R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
- R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE); */
-R300_PACIFY;
-
-END_CS;
-FLUSH_CS;
-
- r300->dirty_state = R300_NEW_KITCHEN_SINK;
+static void r300_surface_copy(struct pipe_context* pipe,
+ struct pipe_surface* dest,
+ unsigned destx, unsigned desty,
+ struct pipe_surface* src,
+ unsigned srcx, unsigned srcy,
+ unsigned w, unsigned h)
+{
+ struct r300_context* r300 = r300_context(pipe);
+ CS_LOCALS(r300);
+ struct r300_texture* srctex = (struct r300_texture*)src->texture;
+ struct r300_texture* desttex = (struct r300_texture*)dest->texture;
+
+ unsigned pixpitch = srctex->stride / srctex->tex.block.size;
+ debug_printf("r300: Copying surface %p at (%d,%d) to %p at (%d, %d),"
+ " dimensions %dx%d (pixel pitch %d)\n",
+ src, srcx, srcy, dest, destx, desty, w, h, pixpitch);
+
+ if (TRUE) {
+ debug_printf("r300: Falling back on surface_copy\n");
+ return util_surface_copy(pipe, FALSE, dest, destx, desty, src,
+ srcx, srcy, w, h);
+ }
+#if 0
+ BEGIN_CS();
+ OUT_CS_REG(RADEON_DEFAULT_SC_BOTTOM_RIGHT,(RADEON_DEFAULT_SC_RIGHT_MAX |
+ RADEON_DEFAULT_SC_BOTTOM_MAX));
+ OUT_ACCEL_REG(RADEON_DP_GUI_MASTER_CNTL, (RADEON_GMC_DST_PITCH_OFFSET_CNTL |
+ RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
+ RADEON_GMC_BRUSH_NONE |
+ (datatype << 8) |
+ RADEON_GMC_SRC_DATATYPE_COLOR |
+ RADEON_ROP[rop].rop |
+ RADEON_DP_SRC_SOURCE_MEMORY |
+ RADEON_GMC_CLR_CMP_CNTL_DIS));
+ OUT_CS_REG(RADEON_DP_BRUSH_FRGD_CLR, 0xffffffff);
+ OUT_CS_REG(RADEON_DP_BRUSH_BKGD_CLR, 0x0);
+ OUT_CS_REG(RADEON_DP_SRC_FRGD_CLR, 0xffffffff);
+ OUT_CS_REG(RADEON_DP_SRC_BKGD_CLR, 0x0);
+ OUT_ACCEL_REG(RADEON_DP_WRITE_MASK, planemask);
+ OUT_ACCEL_REG(RADEON_DP_CNTL, ((info->accel_state->xdir >= 0 ? RADEON_DST_X_LEFT_TO_RIGHT : 0) |
+ (info->accel_state->ydir >= 0 ? RADEON_DST_Y_TOP_TO_BOTTOM : 0));
+);
+
+ OUT_CS_REG_SEQ(RADEON_DST_PITCH_OFFSET, 1);
+ OUT_CS_RELOC(desttex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+
+ OUT_CS_REG_SEQ(RADEON_SRC_PITCH_OFFSET, 1);
+ OUT_CS_RELOC(srctex->buffer, 0,
+ RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0);
+
+ OUT_CS_REG(RADEON_SRC_Y_X, (srcy << 16) | srcx);
+ OUT_CS_REG(RADEON_DST_Y_X, (desty << 16) | destx);
+ OUT_CS_REG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | w);
+ OUT_CS_REG(RADEON_DSTCACHE_CTLSTAT, RADEON_RB2D_DC_FLUSH_ALL);
+ OUT_CS_REG(RADEON_WAIT_UNTIL,
+ RADEON_WAIT_2D_IDLECLEAN | RADEON_WAIT_DMA_GUI_IDLE);
+ END_CS;
+#endif
}
void r300_init_surface_functions(struct r300_context* r300)
{
r300->context.surface_fill = r300_surface_fill;
+ r300->context.surface_copy = r300_surface_copy;
}
diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h
index e1d53116a1..b75b3ab84c 100644
--- a/src/gallium/drivers/r300/r300_surface.h
+++ b/src/gallium/drivers/r300/r300_surface.h
@@ -31,6 +31,8 @@
#include "r300_context.h"
#include "r300_cs.h"
#include "r300_emit.h"
+#include "r300_state_shader.h"
+#include "r300_state_inlines.h"
const struct r300_blend_state blend_clear_state = {
.blend_control = 0x0,
@@ -55,4 +57,38 @@ const struct r300_dsa_state dsa_clear_state = {
.stencil_ref_bf = 0x0,
};
+const struct r300_rs_state rs_clear_state = {
+ .point_minmax = 0x36000006,
+ .line_control = 0x00030006,
+ .depth_scale_front = 0x0,
+ .depth_offset_front = 0x0,
+ .depth_scale_back = 0x0,
+ .depth_offset_back = 0x0,
+ .polygon_offset_enable = 0x0,
+ .cull_mode = 0x0,
+ .line_stipple_config = 0x3BAAAAAB,
+ .line_stipple_value = 0x0,
+ .color_control = R300_SHADE_MODEL_FLAT,
+};
+
+const struct r300_rs_block r300_rs_block_clear_state = {
+ .ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) |
+ R500_RS_SEL_T(R300_RS_SEL_K0) |
+ R500_RS_SEL_R(R300_RS_SEL_K0) |
+ R500_RS_SEL_Q(R300_RS_SEL_K1),
+ .inst[0] = R300_RS_INST_COL_CN_WRITE,
+ .count = R300_IT_COUNT(0) | R300_IC_COUNT(1) | R300_HIRES_EN,
+ .inst_count = 0,
+};
+
+const struct r300_rs_block r500_rs_block_clear_state = {
+ .ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) |
+ R500_RS_SEL_T(R500_RS_IP_PTR_K0) |
+ R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
+ R500_RS_SEL_Q(R500_RS_IP_PTR_K1),
+ .inst[0] = R500_RS_INST_COL_CN_WRITE,
+ .count = R300_IT_COUNT(0) | R300_IC_COUNT(1) | R300_HIRES_EN,
+ .inst_count = 0,
+};
+
#endif /* R300_SURFACE_H */
diff --git a/src/gallium/drivers/r300/r300_swtcl_emit.c b/src/gallium/drivers/r300/r300_swtcl_emit.c
index f6e98d23e9..3db09514c6 100644
--- a/src/gallium/drivers/r300/r300_swtcl_emit.c
+++ b/src/gallium/drivers/r300/r300_swtcl_emit.c
@@ -21,109 +21,315 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "draw/draw_pipe.h"
+#include "draw/draw_vbuf.h"
#include "util/u_memory.h"
#include "r300_cs.h"
#include "r300_context.h"
#include "r300_reg.h"
+#include "r300_state_derived.h"
-/* r300_swtcl_emit: Primitive vertex emission using an immediate
- * vertex buffer and no HW TCL. */
+/* r300_swtcl_emit: Vertex and index buffer primitive emission. No HW TCL. */
-struct swtcl_stage {
+struct r300_swtcl_render {
/* Parent class */
- struct draw_stage draw;
-
+ struct vbuf_render base;
+
+ /* Pipe context */
struct r300_context* r300;
+
+ /* Vertex information */
+ size_t vertex_size;
+ unsigned prim;
+ unsigned hwprim;
+
+ /* VBO */
+ struct pipe_buffer* vbo;
+ size_t vbo_size;
+ size_t vbo_offset;
+ void* vbo_map;
+ size_t vbo_alloc_size;
+ size_t vbo_max_used;
};
-static INLINE struct swtcl_stage* swtcl_stage(struct draw_stage* draw) {
- return (struct swtcl_stage*)draw;
+static INLINE struct r300_swtcl_render*
+r300_swtcl_render(struct vbuf_render* render)
+{
+ return (struct r300_swtcl_render*)render;
}
-static void r300_emit_vertex(struct r300_context* r300,
- const struct vertex_header* vertex)
+static const struct vertex_info*
+r300_swtcl_render_get_vertex_info(struct vbuf_render* render)
{
- /* XXX */
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+ struct r300_context* r300 = r300render->r300;
+
+ r300_update_derived_state(r300);
+
+ return &r300->vertex_info;
}
-static INLINE void r300_emit_prim(struct draw_stage* draw,
- struct prim_header* prim,
- unsigned hwprim,
- unsigned count)
+static boolean r300_swtcl_render_allocate_vertices(struct vbuf_render* render,
+ ushort vertex_size,
+ ushort count)
{
- struct r300_context* r300 = swtcl_stage(draw)->r300;
- CS_LOCALS(r300);
- int i;
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+ struct r300_context* r300 = r300render->r300;
+ struct pipe_screen* screen = r300->context.screen;
+ size_t size = (size_t)vertex_size * (size_t)count;
- r300_emit_dirty_state(r300);
+ if (r300render->vbo) {
+ pipe_buffer_reference(&r300render->vbo, NULL);
+ }
+
+ r300render->vbo_size = MAX2(size, r300render->vbo_alloc_size);
+ r300render->vbo_offset = 0;
+ r300render->vbo = pipe_buffer_create(screen,
+ 64,
+ PIPE_BUFFER_USAGE_VERTEX,
+ r300render->vbo_size);
- /* XXX should be count * vtx size */
- BEGIN_CS(2 + count + 6);
- OUT_CS(CP_PACKET3(R200_3D_DRAW_IMMD_2, count));
- OUT_CS(hwprim | R300_PRIM_WALK_RING |
- (count << R300_PRIM_NUM_VERTICES_SHIFT));
+ r300render->vertex_size = vertex_size;
- for (i = 0; i < count; i++) {
- r300_emit_vertex(r300, prim->v[i]);
+ if (r300render->vbo) {
+ return TRUE;
+ } else {
+ return FALSE;
}
- R300_PACIFY;
- END_CS;
}
-/* Just as an aside...
- *
- * Radeons can do many more primitives:
- * - Line strip
- * - Triangle fan
- * - Triangle strip
- * - Line loop
- * - Quads
- * - Quad strip
- * - Polygons
- *
- * The following were just the only ones in Draw. */
+static void* r300_swtcl_render_map_vertices(struct vbuf_render* render)
+{
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+ struct pipe_screen* screen = r300render->r300->context.screen;
-static void r300_emit_point(struct draw_stage* draw, struct prim_header* prim)
+ r300render->vbo_map = pipe_buffer_map(screen, r300render->vbo,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+
+ return (unsigned char*)r300render->vbo_map + r300render->vbo_offset;
+}
+
+static void r300_swtcl_render_unmap_vertices(struct vbuf_render* render,
+ ushort min,
+ ushort max)
{
- r300_emit_prim(draw, prim, R300_PRIM_TYPE_POINT, 1);
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+ struct pipe_screen* screen = r300render->r300->context.screen;
+
+ r300render->vbo_max_used = MAX2(r300render->vbo_max_used,
+ r300render->vertex_size * (max + 1));
+
+ pipe_buffer_unmap(screen, r300render->vbo);
}
-static void r300_emit_line(struct draw_stage* draw, struct prim_header* prim)
+static void r300_swtcl_render_release_vertices(struct vbuf_render* render)
{
- r300_emit_prim(draw, prim, R300_PRIM_TYPE_LINE, 2);
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+
+ pipe_buffer_reference(&r300render->vbo, NULL);
}
-static void r300_emit_tri(struct draw_stage* draw, struct prim_header* prim)
+static boolean r300_swtcl_render_set_primitive(struct vbuf_render* render,
+ unsigned prim)
{
- r300_emit_prim(draw, prim, R300_PRIM_TYPE_TRI_LIST, 3);
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+ r300render->prim = prim;
+
+ switch (prim) {
+ case PIPE_PRIM_POINTS:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POINTS;
+ break;
+ case PIPE_PRIM_LINES:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINES;
+ break;
+ case PIPE_PRIM_LINE_LOOP:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
+ break;
+ case PIPE_PRIM_LINE_STRIP:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
+ break;
+ case PIPE_PRIM_TRIANGLES:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLES;
+ break;
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
+ break;
+ case PIPE_PRIM_TRIANGLE_FAN:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
+ break;
+ case PIPE_PRIM_QUADS:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUADS;
+ break;
+ case PIPE_PRIM_QUAD_STRIP:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
+ break;
+ case PIPE_PRIM_POLYGON:
+ r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POLYGON;
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+
+ return TRUE;
}
-static void r300_swtcl_flush(struct draw_stage* draw, unsigned flags)
+static void prepare_render(struct r300_swtcl_render* render, unsigned count)
{
+ struct r300_context* r300 = render->r300;
+ int i;
+
+ CS_LOCALS(r300);
+
+ /* Make sure that all possible state is emitted. */
+ r300_emit_dirty_state(r300);
+
+ debug_printf("r300: Preparing vertex buffer %p for render, "
+ "vertex size %d, vertex count %d\n", render->vbo,
+ r300->vertex_info.vinfo.size, count);
+ /* Set the pointer to our vertex buffer. The emitted values are this:
+ * PACKET3 [3D_LOAD_VBPNTR]
+ * COUNT [1]
+ * FORMAT [size | stride << 8]
+ * OFFSET [0]
+ * VBPNTR [relocated BO]
+ */
+ BEGIN_CS(7);
+ OUT_CS(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 3));
+ OUT_CS(1);
+ OUT_CS(r300->vertex_info.vinfo.size |
+ (r300->vertex_info.vinfo.size << 8));
+ OUT_CS(render->vbo_offset);
+ OUT_CS_RELOC(render->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
+ END_CS;
}
-static void r300_reset_stipple(struct draw_stage* draw)
+static void r300_swtcl_render_draw_arrays(struct vbuf_render* render,
+ unsigned start,
+ unsigned count)
{
- /* XXX */
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+ struct r300_context* r300 = r300render->r300;
+ struct pipe_screen* screen = r300->context.screen;
+
+ CS_LOCALS(r300);
+
+ r300render->vbo_offset = start;
+
+ prepare_render(r300render, count);
+
+ debug_printf("r300: Doing vbuf render, count %d\n", count);
+
+ BEGIN_CS(2);
+ OUT_CS(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0));
+ OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) |
+ r300render->hwprim);
+ END_CS;
+}
+
+static void r300_swtcl_render_draw(struct vbuf_render* render,
+ const ushort* indices,
+ uint count)
+{
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+ struct r300_context* r300 = r300render->r300;
+ struct pipe_screen* screen = r300->context.screen;
+ struct pipe_buffer* index_buffer;
+ void* index_map;
+
+ CS_LOCALS(r300);
+
+ count /= 4;
+
+ prepare_render(r300render, count);
+
+ /* Send our indices into an index buffer. */
+ index_buffer = pipe_buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX,
+ count * 4);
+ if (!index_buffer) {
+ return;
+ }
+
+ index_map = pipe_buffer_map(screen, index_buffer,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ memcpy(index_map, indices, count * 4);
+ pipe_buffer_unmap(screen, index_buffer);
+
+ debug_printf("r300: Doing indexbuf render, count %d\n", count);
+#if 0
+ BEGIN_CS(5);
+ OUT_CS(CP_PACKET3(R300_PACKET3_3D_DRAW_INDX_2, 0));
+ OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
+ r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
+
+ OUT_CS(CP_PACKET3(R300_PACKET3_INDX_BUFFER, 2));
+ OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2));
+ OUT_CS_RELOC(index_buffer, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
+ END_CS;
+#endif
+}
+
+static void r300_swtcl_render_destroy(struct vbuf_render* render)
+{
+ FREE(render);
}
-static void r300_swtcl_destroy(struct draw_stage* draw)
+static struct vbuf_render* r300_swtcl_render_create(struct r300_context* r300)
{
- FREE(draw);
+ struct r300_swtcl_render* r300render = CALLOC_STRUCT(r300_swtcl_render);
+ struct pipe_screen* screen = r300->context.screen;
+
+ r300render->r300 = r300;
+
+ /* XXX find real numbers plz */
+ r300render->base.max_vertex_buffer_bytes = 128 * 1024;
+ r300render->base.max_indices = 16 * 1024;
+
+ r300render->base.get_vertex_info = r300_swtcl_render_get_vertex_info;
+ r300render->base.allocate_vertices = r300_swtcl_render_allocate_vertices;
+ r300render->base.map_vertices = r300_swtcl_render_map_vertices;
+ r300render->base.unmap_vertices = r300_swtcl_render_unmap_vertices;
+ r300render->base.set_primitive = r300_swtcl_render_set_primitive;
+ r300render->base.draw = r300_swtcl_render_draw;
+ r300render->base.draw_arrays = r300_swtcl_render_draw_arrays;
+ r300render->base.release_vertices = r300_swtcl_render_release_vertices;
+ r300render->base.destroy = r300_swtcl_render_destroy;
+
+ /* XXX bonghits ahead
+ r300render->vbo_alloc_size = 128 * 4096;
+ r300render->vbo_size = r300render->vbo_alloc_size;
+ r300render->vbo_offset = 0;
+ r300render->vbo = pipe_buffer_create(screen,
+ 64,
+ PIPE_BUFFER_USAGE_VERTEX,
+ r300render->vbo_size);
+ r300render->vbo_map = pipe_buffer_map(screen,
+ r300render->vbo,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ pipe_buffer_unmap(screen, r300render->vbo); */
+
+ return &r300render->base;
}
struct draw_stage* r300_draw_swtcl_stage(struct r300_context* r300)
{
- struct swtcl_stage* swtcl = CALLOC_STRUCT(swtcl_stage);
+ struct vbuf_render* render;
+ struct draw_stage* stage;
+
+ render = r300_swtcl_render_create(r300);
+
+ if (!render) {
+ return NULL;
+ }
+
+ stage = draw_vbuf_stage(r300->draw, render);
+
+ if (!stage) {
+ render->destroy(render);
+ return NULL;
+ }
- swtcl->r300 = r300;
- swtcl->draw.point = r300_emit_point;
- swtcl->draw.line = r300_emit_line;
- swtcl->draw.tri = r300_emit_tri;
- swtcl->draw.flush = r300_swtcl_flush;
- swtcl->draw.reset_stipple_counter = r300_reset_stipple;
- swtcl->draw.destroy = r300_swtcl_destroy;
+ draw_set_render(r300->draw, render);
- return &swtcl->draw;
+ return stage;
}
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index ff812c09f8..6cdea3d285 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -27,12 +27,37 @@ static int minify(int i)
return MAX2(1, i >> 1);
}
+static void r300_setup_texture_state(struct r300_texture* tex,
+ unsigned width,
+ unsigned height,
+ unsigned pitch)
+{
+ struct r300_texture_state* state = &tex->state;
+
+ state->format0 = R300_TX_WIDTH((width - 1) & 0x7ff) |
+ R300_TX_HEIGHT((height - 1) & 0x7ff) | R300_TX_PITCH_EN;
+
+ /* XXX */
+ state->format1 = R300_TX_FORMAT_A8R8G8B8;
+
+ state->format2 = pitch - 1;
+
+ /* XXX
+ if (width > 2048) {
+ state->pitch |= R300_TXWIDTH_11;
+ }
+ if (height > 2048) {
+ state->pitch |= R300_TXHEIGHT_11;
+ } */
+}
+
static void r300_setup_miptree(struct r300_texture* tex)
{
struct pipe_texture* base = &tex->tex;
int stride, size, offset;
+ int i;
- for (int i = 0; i <= base->last_level; i++) {
+ for (i = 0; i <= base->last_level; i++) {
if (i > 0) {
base->width[i] = minify(base->width[i-1]);
base->height[i] = minify(base->height[i-1]);
@@ -43,13 +68,16 @@ static void r300_setup_miptree(struct r300_texture* tex)
base->nblocksy[i] = pf_get_nblocksy(&base->block, base->width[i]);
/* Radeons enjoy things in multiples of 32. */
- /* XXX NPOT -> 64, not 32 */
+ /* XXX this can be 32 when POT */
stride = (base->nblocksx[i] * base->block.size + 63) & ~63;
size = stride * base->nblocksy[i] * base->depth[i];
- /* XXX 64 for NPOT */
tex->offset[i] = (tex->size + 63) & ~63;
tex->size = tex->offset[i] + size;
+
+ if (i == 0) {
+ tex->stride = stride;
+ }
}
}
@@ -67,12 +95,16 @@ static struct pipe_texture*
}
tex->tex = *template;
- tex->tex.refcount = 1;
+ pipe_reference_init(&tex->tex.reference, 1);
tex->tex.screen = screen;
r300_setup_miptree(tex);
- tex->buffer = screen->buffer_create(screen, 63,
+ /* XXX */
+ r300_setup_texture_state(tex, tex->tex.width[0], tex->tex.height[0],
+ tex->tex.width[0]);
+
+ tex->buffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex->size);
@@ -84,24 +116,13 @@ static struct pipe_texture*
return (struct pipe_texture*)tex;
}
-static void r300_texture_release(struct pipe_screen* screen,
- struct pipe_texture** texture)
+static void r300_texture_destroy(struct pipe_texture* texture)
{
- if (!*texture) {
- return;
- }
-
- (*texture)->refcount--;
-
- if ((*texture)->refcount <= 0) {
- struct r300_texture* tex = (struct r300_texture*)*texture;
+ struct r300_texture* tex = (struct r300_texture*)texture;
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- FREE(tex);
- }
-
- *texture = NULL;
+ FREE(tex);
}
static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
@@ -119,17 +140,11 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
offset = tex->offset[level];
if (surface) {
- surface->refcount = 1;
+ pipe_reference_init(&surface->reference, 1);
pipe_texture_reference(&surface->texture, texture);
surface->format = texture->format;
surface->width = texture->width[level];
surface->height = texture->height[level];
- surface->block = texture->block;
- surface->nblocksx = texture->nblocksx[level];
- surface->nblocksy = texture->nblocksy[level];
- /* XXX save the actual stride instead plz kthnxbai */
- surface->stride =
- (texture->nblocksx[level] * texture->block.size + 63) & ~63;
surface->offset = offset;
surface->usage = flags;
surface->status = PIPE_SURFACE_STATUS_DEFINED;
@@ -138,19 +153,10 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
return surface;
}
-static void r300_tex_surface_release(struct pipe_screen* screen,
- struct pipe_surface** surface)
+static void r300_tex_surface_destroy(struct pipe_surface* s)
{
- struct pipe_surface* s = *surface;
-
- s->refcount--;
-
- if (s->refcount <= 0) {
- pipe_texture_reference(&s->texture, NULL);
- FREE(s);
- }
-
- *surface = NULL;
+ pipe_texture_reference(&s->texture, NULL);
+ FREE(s);
}
static struct pipe_texture*
@@ -173,12 +179,15 @@ static struct pipe_texture*
}
tex->tex = *base;
- tex->tex.refcount = 1;
+ pipe_reference_init(&tex->tex.reference, 1);
tex->tex.screen = screen;
- /* XXX tex->stride = *stride; */
+ tex->stride = *stride;
+
+ r300_setup_texture_state(tex, tex->tex.width[0], tex->tex.height[0],
+ tex->stride);
- pipe_buffer_reference(screen, &tex->buffer, buffer);
+ pipe_buffer_reference(&tex->buffer, buffer);
return (struct pipe_texture*)tex;
}
@@ -186,8 +195,26 @@ static struct pipe_texture*
void r300_init_screen_texture_functions(struct pipe_screen* screen)
{
screen->texture_create = r300_texture_create;
- screen->texture_release = r300_texture_release;
+ screen->texture_destroy = r300_texture_destroy;
screen->get_tex_surface = r300_get_tex_surface;
- screen->tex_surface_release = r300_tex_surface_release;
+ screen->tex_surface_destroy = r300_tex_surface_destroy;
screen->texture_blanket = r300_texture_blanket;
}
+
+boolean r300_get_texture_buffer(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride)
+{
+ struct r300_texture* tex = (struct r300_texture*)texture;
+ if (!tex) {
+ return FALSE;
+ }
+
+ pipe_buffer_reference(buffer, tex->buffer);
+
+ if (stride) {
+ *stride = tex->stride;
+ }
+
+ return TRUE;
+}
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 7964229a94..98fb5c9a08 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -28,7 +28,16 @@
#include "util/u_math.h"
#include "r300_context.h"
+#include "r300_reg.h"
void r300_init_screen_texture_functions(struct pipe_screen* screen);
+#ifndef R300_WINSYS_H
+
+boolean r300_get_texture_buffer(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride);
+
+#endif /* R300_WINSYS_H */
+
#endif /* R300_TEXTURE_H */
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index 5a3a212892..baa95282c3 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -33,10 +33,16 @@ extern "C" {
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
+#include "pipe/internal/p_winsys_screen.h"
struct radeon_cs;
struct r300_winsys {
+ /* Parent class */
+ struct pipe_winsys base;
+
+ /* Opaque Radeon-specific winsys object. */
+ void* radeon_winsys;
/* PCI ID */
uint32_t pci_id;
@@ -47,10 +53,6 @@ struct r300_winsys {
/* CS object. This is very much like Intel's batchbuffer.
* Fill it full of dwords and relocs and then submit.
* Repeat as needed. */
- /* Note: Unlike Mesa's version of this, we don't keep a copy of the CSM
- * that was used to create this CS. Is this a good idea? */
- /* Note: The pipe driver doesn't know how to use this. This is purely
- * for the winsys. */
struct radeon_cs* cs;
/* Check to see if there's room for commands. */
@@ -84,9 +86,12 @@ struct r300_winsys {
};
struct pipe_context* r300_create_context(struct pipe_screen* screen,
- struct pipe_winsys* winsys,
struct r300_winsys* r300_winsys);
+boolean r300_get_texture_buffer(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile
index 120bdfd9dd..516e3992fd 100644
--- a/src/gallium/drivers/softpipe/Makefile
+++ b/src/gallium/drivers/softpipe/Makefile
@@ -14,7 +14,7 @@ C_SOURCES = \
sp_draw_arrays.c \
sp_prim_setup.c \
sp_prim_vbuf.c \
- sp_quad.c \
+ sp_quad_pipe.c \
sp_quad_alpha_test.c \
sp_quad_blend.c \
sp_quad_colormask.c \
@@ -42,6 +42,3 @@ C_SOURCES = \
sp_surface.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/softpipe/SConscript b/src/gallium/drivers/softpipe/SConscript
index c1f7daa8ab..f8720638a7 100644
--- a/src/gallium/drivers/softpipe/SConscript
+++ b/src/gallium/drivers/softpipe/SConscript
@@ -17,7 +17,7 @@ softpipe = env.ConvenienceLibrary(
'sp_setup.c',
'sp_quad_alpha_test.c',
'sp_quad_blend.c',
- 'sp_quad.c',
+ 'sp_quad_pipe.c',
'sp_quad_colormask.c',
'sp_quad_coverage.c',
'sp_quad_depth_test.c',
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index c2d882a819..06ace27d14 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -32,7 +32,6 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "sp_clear.h"
@@ -53,15 +52,15 @@
* Map any drawing surfaces which aren't already mapped
*/
void
-softpipe_map_surfaces(struct softpipe_context *sp)
+softpipe_map_transfers(struct softpipe_context *sp)
{
unsigned i;
for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
- sp_tile_cache_map_surfaces(sp->cbuf_cache[i]);
+ sp_tile_cache_map_transfers(sp->cbuf_cache[i]);
}
- sp_tile_cache_map_surfaces(sp->zsbuf_cache);
+ sp_tile_cache_map_transfers(sp->zsbuf_cache);
}
@@ -69,7 +68,7 @@ softpipe_map_surfaces(struct softpipe_context *sp)
* Unmap any mapped drawing surfaces
*/
void
-softpipe_unmap_surfaces(struct softpipe_context *sp)
+softpipe_unmap_transfers(struct softpipe_context *sp)
{
uint i;
@@ -78,16 +77,15 @@ softpipe_unmap_surfaces(struct softpipe_context *sp)
sp_flush_tile_cache(sp, sp->zsbuf_cache);
for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
- sp_tile_cache_unmap_surfaces(sp->cbuf_cache[i]);
+ sp_tile_cache_unmap_transfers(sp->cbuf_cache[i]);
}
- sp_tile_cache_unmap_surfaces(sp->zsbuf_cache);
+ sp_tile_cache_unmap_transfers(sp->zsbuf_cache);
}
static void softpipe_destroy( struct pipe_context *pipe )
{
struct softpipe_context *softpipe = softpipe_context( pipe );
- struct pipe_screen *screen = pipe->screen;
uint i;
if (softpipe->draw)
@@ -116,7 +114,7 @@ static void softpipe_destroy( struct pipe_context *pipe )
for (i = 0; i < Elements(softpipe->constants); i++) {
if (softpipe->constants[i].buffer) {
- pipe_buffer_reference(screen, &softpipe->constants[i].buffer, NULL);
+ pipe_buffer_reference(&softpipe->constants[i].buffer, NULL);
}
}
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index e2451c6ecb..59d6df8f2d 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -32,11 +32,10 @@
#define SP_CONTEXT_H
#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
#include "draw/draw_vertex.h"
-#include "sp_quad.h"
+#include "sp_quad_pipe.h"
#include "sp_tex_sample.h"
@@ -51,7 +50,6 @@
*/
#define SP_NUM_QUAD_THREADS 1
-struct softpipe_winsys;
struct softpipe_vbuf_render;
struct draw_context;
struct draw_stage;
@@ -63,15 +61,15 @@ struct sp_vertex_shader;
struct softpipe_context {
struct pipe_context pipe; /**< base class */
- /* The most recent drawing state as set by the driver:
- */
- const struct pipe_blend_state *blend;
+ /** Constant state objects */
+ const struct pipe_blend_state *blend;
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
- const struct pipe_depth_stencil_alpha_state *depth_stencil;
+ const struct pipe_depth_stencil_alpha_state *depth_stencil;
const struct pipe_rasterizer_state *rasterizer;
const struct sp_fragment_shader *fs;
const struct sp_vertex_shader *vs;
+ /** Other rendering state */
struct pipe_blend_color blend_color;
struct pipe_clip_state clip;
struct pipe_constant_buffer constants[PIPE_SHADER_TYPES];
@@ -82,23 +80,20 @@ struct softpipe_context {
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
- unsigned dirty;
unsigned num_samplers;
unsigned num_textures;
unsigned num_vertex_elements;
unsigned num_vertex_buffers;
- boolean no_rast;
+ unsigned dirty; /**< Mask of SP_NEW_x flags */
/* Counter for occlusion queries. Note this supports overlapping
* queries.
*/
uint64_t occlusion_count;
- /*
- * Mapped vertex buffers
- */
+ /** Mapped vertex buffers */
ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS];
/** Mapped constant buffers */
@@ -108,16 +103,11 @@ struct softpipe_context {
struct vertex_info vertex_info;
struct vertex_info vertex_info_vbuf;
+ /** Which vertex shader output slot contains point size */
int psize_slot;
unsigned reduced_api_prim; /**< PIPE_PRIM_POINTS, _LINES or _TRIANGLES */
-#if 0
- /* Stipple derived state:
- */
- ubyte stipple_masks[16][16];
-#endif
-
/** Derived from scissor and surface bounds: */
struct pipe_scissor_state cliprect;
@@ -159,8 +149,9 @@ struct softpipe_context {
struct softpipe_tile_cache *tex_cache[PIPE_MAX_SAMPLERS];
- int use_sse : 1;
- int dump_fs : 1;
+ unsigned use_sse : 1;
+ unsigned dump_fs : 1;
+ unsigned no_rast : 1;
};
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 7e3a25e34b..f117096bf7 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -134,7 +134,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
if (sp->dirty)
softpipe_update_derived( sp );
- softpipe_map_surfaces(sp);
+ softpipe_map_transfers(sp);
softpipe_map_constant_buffers(sp);
/*
diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c
index c21faf57f3..035f4b963e 100644
--- a/src/gallium/drivers/softpipe/sp_flush.c
+++ b/src/gallium/drivers/softpipe/sp_flush.c
@@ -70,7 +70,7 @@ softpipe_flush( struct pipe_context *pipe,
* that's called before swapbuffers because we don't always want
* to unmap surfaces when flushing.
*/
- softpipe_unmap_surfaces(softpipe);
+ softpipe_unmap_transfers(softpipe);
}
/* Enable to dump BMPs of the color/depth buffers each frame */
diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c
index 453b0373f0..0c14d92864 100644
--- a/src/gallium/drivers/softpipe/sp_fs_exec.c
+++ b/src/gallium/drivers/softpipe/sp_fs_exec.c
@@ -29,13 +29,12 @@
#include "sp_context.h"
#include "sp_state.h"
#include "sp_fs.h"
-#include "sp_headers.h"
+#include "sp_quad.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/softpipe/sp_fs_llvm.c b/src/gallium/drivers/softpipe/sp_fs_llvm.c
index 34adac5226..f33b3e3285 100644
--- a/src/gallium/drivers/softpipe/sp_fs_llvm.c
+++ b/src/gallium/drivers/softpipe/sp_fs_llvm.c
@@ -37,7 +37,6 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
#include "tgsi/tgsi_sse2.h"
#if 0
diff --git a/src/gallium/drivers/softpipe/sp_fs_sse.c b/src/gallium/drivers/softpipe/sp_fs_sse.c
index 9a273c8764..366abe2ed4 100644
--- a/src/gallium/drivers/softpipe/sp_fs_sse.c
+++ b/src/gallium/drivers/softpipe/sp_fs_sse.c
@@ -29,13 +29,12 @@
#include "sp_context.h"
#include "sp_state.h"
#include "sp_fs.h"
-#include "sp_headers.h"
+#include "sp_quad.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_sse2.h"
@@ -146,7 +145,7 @@ softpipe_create_fs_sse(struct softpipe_context *softpipe,
return NULL;
}
- shader->base.shader = *templ;
+ shader->base.shader.tokens = NULL; /* don't hold reference to templ->tokens */
shader->base.prepare = fs_sse_prepare;
shader->base.run = fs_sse_run;
shader->base.delete = fs_sse_delete;
diff --git a/src/gallium/drivers/softpipe/sp_headers.h b/src/gallium/drivers/softpipe/sp_headers.h
deleted file mode 100644
index 4a42cb3c19..0000000000
--- a/src/gallium/drivers/softpipe/sp_headers.h
+++ /dev/null
@@ -1,95 +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.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef SP_HEADERS_H
-#define SP_HEADERS_H
-
-#include "pipe/p_state.h"
-#include "tgsi/tgsi_exec.h"
-
-#define PRIM_POINT 1
-#define PRIM_LINE 2
-#define PRIM_TRI 3
-
-
-/* The rasterizer generates 2x2 quads of fragment and feeds them to
- * the current fp_machine (see below).
- * Remember that Y=0=top with Y increasing down the window.
- */
-#define QUAD_TOP_LEFT 0
-#define QUAD_TOP_RIGHT 1
-#define QUAD_BOTTOM_LEFT 2
-#define QUAD_BOTTOM_RIGHT 3
-
-#define MASK_TOP_LEFT (1 << QUAD_TOP_LEFT)
-#define MASK_TOP_RIGHT (1 << QUAD_TOP_RIGHT)
-#define MASK_BOTTOM_LEFT (1 << QUAD_BOTTOM_LEFT)
-#define MASK_BOTTOM_RIGHT (1 << QUAD_BOTTOM_RIGHT)
-#define MASK_ALL 0xf
-
-
-/**
- * Encodes everything we need to know about a 2x2 pixel block. Uses
- * "Channel-Serial" or "SoA" layout.
- */
-struct quad_header_input
-{
- int x0;
- int y0;
- float coverage[QUAD_SIZE]; /** fragment coverage for antialiasing */
- unsigned facing:1; /**< Front (0) or back (1) facing? */
- unsigned prim:2; /**< PRIM_POINT, LINE, TRI */
-};
-
-struct quad_header_inout
-{
- unsigned mask:4;
-};
-
-struct quad_header_output
-{
- /** colors in SOA format (rrrr, gggg, bbbb, aaaa) */
- float color[PIPE_MAX_COLOR_BUFS][NUM_CHANNELS][QUAD_SIZE];
- float depth[QUAD_SIZE];
-};
-
-struct quad_header {
- struct quad_header_input input;
- struct quad_header_inout inout;
- struct quad_header_output output;
-
- const struct tgsi_interp_coef *coef;
- const struct tgsi_interp_coef *posCoef;
-
- unsigned nr_attrs;
-};
-
-#endif /* SP_HEADERS_H */
-
diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
index 9cd5784e5b..eef6e5806c 100644
--- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c
+++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
@@ -60,6 +60,8 @@ struct softpipe_vbuf_render
struct softpipe_context *softpipe;
uint prim;
uint vertex_size;
+ uint nr_vertices;
+ uint vertex_buffer_size;
void *vertex_buffer;
};
@@ -80,26 +82,76 @@ sp_vbuf_get_vertex_info(struct vbuf_render *vbr)
}
-static void *
+static boolean
sp_vbuf_allocate_vertices(struct vbuf_render *vbr,
- ushort vertex_size, ushort nr_vertices)
+ ushort vertex_size, ushort nr_vertices)
{
struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- assert(!cvbr->vertex_buffer);
- cvbr->vertex_buffer = align_malloc(vertex_size * nr_vertices, 16);
+ unsigned size = vertex_size * nr_vertices;
+
+ if (cvbr->vertex_buffer_size < size) {
+ align_free(cvbr->vertex_buffer);
+ cvbr->vertex_buffer = align_malloc(size, 16);
+ cvbr->vertex_buffer_size = size;
+ }
+
cvbr->vertex_size = vertex_size;
- return cvbr->vertex_buffer;
+ cvbr->nr_vertices = nr_vertices;
+
+ return cvbr->vertex_buffer != NULL;
}
-
static void
-sp_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
- unsigned vertex_size, unsigned vertices_used)
+sp_vbuf_release_vertices(struct vbuf_render *vbr)
+{
+#if 0
+ {
+ struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
+ const struct vertex_info *info =
+ softpipe_get_vbuf_vertex_info(cvbr->softpipe);
+ const float *vtx = (const float *) cvbr->vertex_buffer;
+ uint i, j;
+ debug_printf("%s (vtx_size = %u, vtx_used = %u)\n",
+ __FUNCTION__, cvbr->vertex_size, cvbr->nr_vertices);
+ for (i = 0; i < cvbr->nr_vertices; i++) {
+ for (j = 0; j < info->num_attribs; j++) {
+ uint k;
+ switch (info->attrib[j].emit) {
+ case EMIT_4F: k = 4; break;
+ case EMIT_3F: k = 3; break;
+ case EMIT_2F: k = 2; break;
+ case EMIT_1F: k = 1; break;
+ default: assert(0);
+ }
+ debug_printf("Vert %u attr %u: ", i, j);
+ while (k-- > 0) {
+ debug_printf("%g ", vtx[0]);
+ vtx++;
+ }
+ debug_printf("\n");
+ }
+ }
+ }
+#endif
+
+ /* keep the old allocation for next time */
+}
+
+static void *
+sp_vbuf_map_vertices(struct vbuf_render *vbr)
{
struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- align_free(vertices);
- assert(vertices == cvbr->vertex_buffer);
- cvbr->vertex_buffer = NULL;
+ return cvbr->vertex_buffer;
+}
+
+static void
+sp_vbuf_unmap_vertices(struct vbuf_render *vbr,
+ ushort min_index,
+ ushort max_index )
+{
+ struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
+ assert( cvbr->vertex_buffer_size >= (max_index+1) * cvbr->vertex_size );
+ /* do nothing */
}
@@ -115,8 +167,6 @@ sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
setup_prepare( setup_ctx );
-
-
cvbr->prim = prim;
return TRUE;
@@ -394,6 +444,8 @@ sp_init_vbuf(struct softpipe_context *sp)
sp->vbuf_render->base.get_vertex_info = sp_vbuf_get_vertex_info;
sp->vbuf_render->base.allocate_vertices = sp_vbuf_allocate_vertices;
+ sp->vbuf_render->base.map_vertices = sp_vbuf_map_vertices;
+ sp->vbuf_render->base.unmap_vertices = sp_vbuf_unmap_vertices;
sp->vbuf_render->base.set_primitive = sp_vbuf_set_primitive;
sp->vbuf_render->base.draw = sp_vbuf_draw;
sp->vbuf_render->base.draw_arrays = sp_vbuf_draw_arrays;
diff --git a/src/gallium/drivers/softpipe/sp_quad.h b/src/gallium/drivers/softpipe/sp_quad.h
index 08513cb95f..bd6c6cb912 100644
--- a/src/gallium/drivers/softpipe/sp_quad.h
+++ b/src/gallium/drivers/softpipe/sp_quad.h
@@ -31,39 +31,76 @@
#ifndef SP_QUAD_H
#define SP_QUAD_H
+#include "pipe/p_state.h"
+#include "tgsi/tgsi_exec.h"
-struct softpipe_context;
-struct quad_header;
+#define QUAD_PRIM_POINT 1
+#define QUAD_PRIM_LINE 2
+#define QUAD_PRIM_TRI 3
-struct quad_stage {
- struct softpipe_context *softpipe;
- struct quad_stage *next;
+/* The rasterizer generates 2x2 quads of fragment and feeds them to
+ * the current fp_machine (see below).
+ * Remember that Y=0=top with Y increasing down the window.
+ */
+#define QUAD_TOP_LEFT 0
+#define QUAD_TOP_RIGHT 1
+#define QUAD_BOTTOM_LEFT 2
+#define QUAD_BOTTOM_RIGHT 3
+
+#define MASK_TOP_LEFT (1 << QUAD_TOP_LEFT)
+#define MASK_TOP_RIGHT (1 << QUAD_TOP_RIGHT)
+#define MASK_BOTTOM_LEFT (1 << QUAD_BOTTOM_LEFT)
+#define MASK_BOTTOM_RIGHT (1 << QUAD_BOTTOM_RIGHT)
+#define MASK_ALL 0xf
+
+
+/**
+ * Quad stage inputs (pos, coverage, front/back face, etc)
+ */
+struct quad_header_input
+{
+ int x0, y0; /**< quad window pos, always even */
+ float coverage[QUAD_SIZE]; /**< fragment coverage for antialiasing */
+ unsigned facing:1; /**< Front (0) or back (1) facing? */
+ unsigned prim:2; /**< QUAD_PRIM_POINT, LINE, TRI */
+};
- void (*begin)(struct quad_stage *qs);
- /** the stage action */
- void (*run)(struct quad_stage *qs, struct quad_header *quad);
+/**
+ * Quad stage inputs/outputs.
+ */
+struct quad_header_inout
+{
+ unsigned mask:4;
+};
+
- void (*destroy)(struct quad_stage *qs);
+/**
+ * Quad stage outputs (color & depth).
+ */
+struct quad_header_output
+{
+ /** colors in SOA format (rrrr, gggg, bbbb, aaaa) */
+ float color[PIPE_MAX_COLOR_BUFS][NUM_CHANNELS][QUAD_SIZE];
+ float depth[QUAD_SIZE];
};
-struct quad_stage *sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_earlyz_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_alpha_test_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_stencil_test_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_occlusion_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_coverage_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_blend_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_colormask_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_output_stage( struct softpipe_context *softpipe );
+/**
+ * Encodes everything we need to know about a 2x2 pixel block. Uses
+ * "Channel-Serial" or "SoA" layout.
+ */
+struct quad_header {
+ struct quad_header_input input;
+ struct quad_header_inout inout;
+ struct quad_header_output output;
-void sp_build_quad_pipeline(struct softpipe_context *sp);
+ const struct tgsi_interp_coef *coef;
+ const struct tgsi_interp_coef *posCoef;
-void sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad);
+ unsigned nr_attrs;
+};
#endif /* SP_QUAD_H */
diff --git a/src/gallium/drivers/softpipe/sp_quad_alpha_test.c b/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
index 85c9f037a3..0845bae0e6 100644
--- a/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
@@ -4,8 +4,8 @@
*/
#include "sp_context.h"
-#include "sp_headers.h"
#include "sp_quad.h"
+#include "sp_quad_pipe.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c
index fb1d430a4f..e134e44337 100644
--- a/src/gallium/drivers/softpipe/sp_quad_blend.c
+++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
@@ -34,10 +34,10 @@
#include "util/u_math.h"
#include "util/u_memory.h"
#include "sp_context.h"
-#include "sp_headers.h"
+#include "sp_quad.h"
#include "sp_surface.h"
#include "sp_tile_cache.h"
-#include "sp_quad.h"
+#include "sp_quad_pipe.h"
#define VEC4_COPY(DST, SRC) \
diff --git a/src/gallium/drivers/softpipe/sp_quad_bufloop.c b/src/gallium/drivers/softpipe/sp_quad_bufloop.c
index d7d6a6974d..953d8516b9 100644
--- a/src/gallium/drivers/softpipe/sp_quad_bufloop.c
+++ b/src/gallium/drivers/softpipe/sp_quad_bufloop.c
@@ -1,9 +1,9 @@
#include "util/u_memory.h"
#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
#include "sp_quad.h"
+#include "sp_surface.h"
+#include "sp_quad_pipe.h"
/**
diff --git a/src/gallium/drivers/softpipe/sp_quad_colormask.c b/src/gallium/drivers/softpipe/sp_quad_colormask.c
index 563c2fc739..dc90e5d5e9 100644
--- a/src/gallium/drivers/softpipe/sp_quad_colormask.c
+++ b/src/gallium/drivers/softpipe/sp_quad_colormask.c
@@ -34,9 +34,9 @@
#include "util/u_math.h"
#include "util/u_memory.h"
#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
#include "sp_quad.h"
+#include "sp_surface.h"
+#include "sp_quad_pipe.h"
#include "sp_tile_cache.h"
diff --git a/src/gallium/drivers/softpipe/sp_quad_coverage.c b/src/gallium/drivers/softpipe/sp_quad_coverage.c
index c27fd1482d..4aeee85870 100644
--- a/src/gallium/drivers/softpipe/sp_quad_coverage.c
+++ b/src/gallium/drivers/softpipe/sp_quad_coverage.c
@@ -35,8 +35,8 @@
#include "pipe/p_defines.h"
#include "util/u_memory.h"
#include "sp_context.h"
-#include "sp_headers.h"
#include "sp_quad.h"
+#include "sp_quad_pipe.h"
/**
@@ -46,10 +46,11 @@ static void
coverage_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
+ const uint prim = quad->input.prim;
- if ((softpipe->rasterizer->poly_smooth && quad->input.prim == PRIM_TRI) ||
- (softpipe->rasterizer->line_smooth && quad->input.prim == PRIM_LINE) ||
- (softpipe->rasterizer->point_smooth && quad->input.prim == PRIM_POINT)) {
+ if ((softpipe->rasterizer->poly_smooth && prim == QUAD_PRIM_TRI) ||
+ (softpipe->rasterizer->line_smooth && prim == QUAD_PRIM_LINE) ||
+ (softpipe->rasterizer->point_smooth && prim == QUAD_PRIM_POINT)) {
uint cbuf;
/* loop over colorbuffer outputs */
diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
index 523bd3e080..d463930bae 100644
--- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
@@ -32,9 +32,9 @@
#include "pipe/p_defines.h"
#include "util/u_memory.h"
#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
#include "sp_quad.h"
+#include "sp_surface.h"
+#include "sp_quad_pipe.h"
#include "sp_tile_cache.h"
diff --git a/src/gallium/drivers/softpipe/sp_quad_earlyz.c b/src/gallium/drivers/softpipe/sp_quad_earlyz.c
index 6e2dde304e..496fd39ed1 100644
--- a/src/gallium/drivers/softpipe/sp_quad_earlyz.c
+++ b/src/gallium/drivers/softpipe/sp_quad_earlyz.c
@@ -31,8 +31,8 @@
#include "pipe/p_defines.h"
#include "util/u_memory.h"
-#include "sp_headers.h"
#include "sp_quad.h"
+#include "sp_quad_pipe.h"
/**
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index 5dacbbe55f..adca5df73d 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -43,8 +43,8 @@
#include "sp_context.h"
#include "sp_state.h"
-#include "sp_headers.h"
#include "sp_quad.h"
+#include "sp_quad_pipe.h"
#include "sp_texture.h"
#include "sp_tex_sample.h"
diff --git a/src/gallium/drivers/softpipe/sp_quad_occlusion.c b/src/gallium/drivers/softpipe/sp_quad_occlusion.c
index 169bd82876..dfa7ff3b1d 100644
--- a/src/gallium/drivers/softpipe/sp_quad_occlusion.c
+++ b/src/gallium/drivers/softpipe/sp_quad_occlusion.c
@@ -35,9 +35,9 @@
#include "pipe/p_defines.h"
#include "util/u_memory.h"
#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
#include "sp_quad.h"
+#include "sp_surface.h"
+#include "sp_quad_pipe.h"
static unsigned count_bits( unsigned val )
{
diff --git a/src/gallium/drivers/softpipe/sp_quad_output.c b/src/gallium/drivers/softpipe/sp_quad_output.c
index a37c8b4c39..92d5f9f3c1 100644
--- a/src/gallium/drivers/softpipe/sp_quad_output.c
+++ b/src/gallium/drivers/softpipe/sp_quad_output.c
@@ -27,9 +27,9 @@
#include "util/u_memory.h"
#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
#include "sp_quad.h"
+#include "sp_surface.h"
+#include "sp_quad_pipe.h"
#include "sp_tile_cache.h"
diff --git a/src/gallium/drivers/softpipe/sp_quad.c b/src/gallium/drivers/softpipe/sp_quad_pipe.c
index 892ef87ee9..892ef87ee9 100644
--- a/src/gallium/drivers/softpipe/sp_quad.c
+++ b/src/gallium/drivers/softpipe/sp_quad_pipe.c
diff --git a/src/gallium/drivers/softpipe/sp_quad_pipe.h b/src/gallium/drivers/softpipe/sp_quad_pipe.h
new file mode 100644
index 0000000000..0e40586ffc
--- /dev/null
+++ b/src/gallium/drivers/softpipe/sp_quad_pipe.h
@@ -0,0 +1,74 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+/* Authors: Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef SP_QUAD_PIPE_H
+#define SP_QUAD_PIPE_H
+
+
+struct softpipe_context;
+struct quad_header;
+
+
+/**
+ * Fragment processing is performed on 2x2 blocks of pixels called "quads".
+ * Quad processing is performed with a pipeline of stages represented by
+ * this type.
+ */
+struct quad_stage {
+ struct softpipe_context *softpipe;
+
+ struct quad_stage *next;
+
+ void (*begin)(struct quad_stage *qs);
+
+ /** the stage action */
+ void (*run)(struct quad_stage *qs, struct quad_header *quad);
+
+ void (*destroy)(struct quad_stage *qs);
+};
+
+
+struct quad_stage *sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_earlyz_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_alpha_test_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_stencil_test_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_occlusion_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_coverage_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_blend_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_colormask_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_output_stage( struct softpipe_context *softpipe );
+
+void sp_build_quad_pipeline(struct softpipe_context *sp);
+
+void sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad);
+
+#endif /* SP_QUAD_PIPE_H */
diff --git a/src/gallium/drivers/softpipe/sp_quad_stencil.c b/src/gallium/drivers/softpipe/sp_quad_stencil.c
index 7495515764..5e9d447737 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stencil.c
+++ b/src/gallium/drivers/softpipe/sp_quad_stencil.c
@@ -5,10 +5,10 @@
#include "sp_context.h"
-#include "sp_headers.h"
+#include "sp_quad.h"
#include "sp_surface.h"
#include "sp_tile_cache.h"
-#include "sp_quad.h"
+#include "sp_quad_pipe.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/softpipe/sp_quad_stipple.c b/src/gallium/drivers/softpipe/sp_quad_stipple.c
index ccf37f6be5..05e862f097 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stipple.c
+++ b/src/gallium/drivers/softpipe/sp_quad_stipple.c
@@ -4,8 +4,8 @@
*/
#include "sp_context.h"
-#include "sp_headers.h"
#include "sp_quad.h"
+#include "sp_quad_pipe.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
@@ -19,11 +19,13 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
static const uint bit31 = 1 << 31;
static const uint bit30 = 1 << 30;
- if (quad->input.prim == PRIM_TRI) {
+ if (quad->input.prim == QUAD_PRIM_TRI) {
struct softpipe_context *softpipe = qs->softpipe;
/* need to invert Y to index into OpenGL's stipple pattern */
int y0, y1;
uint stipple0, stipple1;
+ const int col0 = quad->input.x0 % 32;
+
if (softpipe->rasterizer->origin_lower_left) {
y0 = softpipe->framebuffer.height - 1 - quad->input.y0;
y1 = y0 - 1;
@@ -32,12 +34,11 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
y0 = quad->input.y0;
y1 = y0 + 1;
}
+
stipple0 = softpipe->poly_stipple.stipple[y0 % 32];
stipple1 = softpipe->poly_stipple.stipple[y1 % 32];
-#if 1
- {
- const int col0 = quad->input.x0 % 32;
+ /* turn off quad mask bits that fail the stipple test */
if ((stipple0 & (bit31 >> col0)) == 0)
quad->inout.mask &= ~MASK_TOP_LEFT;
@@ -49,19 +50,11 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
if ((stipple1 & (bit30 >> col0)) == 0)
quad->inout.mask &= ~MASK_BOTTOM_RIGHT;
- }
-#else
- /* We'd like to use this code, but we'd need to redefine
- * MASK_TOP_LEFT to be (1 << 1) and MASK_TOP_RIGHT to be (1 << 0),
- * and similarly for the BOTTOM bits. But that may have undesirable
- * side effects elsewhere.
- */
- const int col0 = 30 - (quad->input.x0 % 32);
- quad->inout.mask &= (((stipple0 >> col0) & 0x3) |
- (((stipple1 >> col0) & 0x3) << 2));
-#endif
- if (!quad->inout.mask)
+
+ if (!quad->inout.mask) {
+ /* all fragments failed stipple test, end of quad pipeline */
return;
+ }
}
qs->next->run(qs->next, quad);
diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c
index b0d8e01426..93dab236d6 100644
--- a/src/gallium/drivers/softpipe/sp_query.c
+++ b/src/gallium/drivers/softpipe/sp_query.c
@@ -31,7 +31,6 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_query.h"
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index b1adb9cb7a..0925653b5d 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -32,13 +32,12 @@
* \author Brian Paul
*/
-#include "sp_setup.h"
-
#include "sp_context.h"
-#include "sp_headers.h"
+#include "sp_prim_setup.h"
#include "sp_quad.h"
+#include "sp_quad_pipe.h"
+#include "sp_setup.h"
#include "sp_state.h"
-#include "sp_prim_setup.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vertex.h"
@@ -265,17 +264,20 @@ is_inf_or_nan(float x)
}
-static boolean cull_tri( struct setup_context *setup,
- float det )
+/**
+ * Do triangle cull test using tri determinant (sign indicates orientation)
+ * \return true if triangle is to be culled.
+ */
+static INLINE boolean
+cull_tri(const struct setup_context *setup, float det)
{
- if (det != 0)
- {
+ if (det != 0) {
/* if (det < 0 then Z points toward camera and triangle is
* counter-clockwise winding.
*/
unsigned winding = (det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW;
-
- if ((winding & setup->winding) == 0)
+
+ if ((winding & setup->winding) == 0)
return FALSE;
}
@@ -968,7 +970,7 @@ void setup_tri( struct setup_context *setup,
setup_tri_coefficients( setup );
setup_tri_edges( setup );
- setup->quad.input.prim = PRIM_TRI;
+ setup->quad.input.prim = QUAD_PRIM_TRI;
setup->span.y = 0;
setup->span.y_flags = 0;
@@ -1009,7 +1011,7 @@ void setup_tri( struct setup_context *setup,
* for a line.
*/
static void
-line_linear_coeff(struct setup_context *setup,
+line_linear_coeff(const struct setup_context *setup,
struct tgsi_interp_coef *coef,
uint vertSlot, uint i)
{
@@ -1029,9 +1031,9 @@ line_linear_coeff(struct setup_context *setup,
* for a line.
*/
static void
-line_persp_coeff(struct setup_context *setup,
- struct tgsi_interp_coef *coef,
- uint vertSlot, uint i)
+line_persp_coeff(const struct setup_context *setup,
+ struct tgsi_interp_coef *coef,
+ uint vertSlot, uint i)
{
/* XXX double-check/verify this arithmetic */
const float a0 = setup->vmin[vertSlot][i] * setup->vmin[0][3];
@@ -1206,7 +1208,7 @@ setup_line(struct setup_context *setup,
setup->quad.input.x0 = setup->quad.input.y0 = -1;
setup->quad.inout.mask = 0x0;
- setup->quad.input.prim = PRIM_LINE;
+ setup->quad.input.prim = QUAD_PRIM_LINE;
/* XXX temporary: set coverage to 1.0 so the line appears
* if AA mode happens to be enabled.
*/
@@ -1266,7 +1268,7 @@ setup_line(struct setup_context *setup,
static void
-point_persp_coeff(struct setup_context *setup,
+point_persp_coeff(const struct setup_context *setup,
const float (*vert)[4],
struct tgsi_interp_coef *coef,
uint vertSlot, uint i)
@@ -1361,7 +1363,7 @@ setup_point( struct setup_context *setup,
}
}
- setup->quad.input.prim = PRIM_POINT;
+ setup->quad.input.prim = QUAD_PRIM_POINT;
if (halfSize <= 0.5 && !round) {
/* special case for 1-pixel points */
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index 3eff41ffa5..9776e978e3 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -85,7 +85,7 @@ struct sp_fragment_shader {
/** Subclass of pipe_shader_state */
struct sp_vertex_shader {
- struct pipe_shader_state shader; /* Note: this field not actually used */
+ struct pipe_shader_state shader;
struct draw_vertex_shader *draw_data;
};
@@ -184,10 +184,10 @@ softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags);
void
-softpipe_map_surfaces(struct softpipe_context *sp);
+softpipe_map_transfers(struct softpipe_context *sp);
void
-softpipe_unmap_surfaces(struct softpipe_context *sp);
+softpipe_unmap_transfers(struct softpipe_context *sp);
void
softpipe_map_texture_surfaces(struct softpipe_context *sp);
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index 4d01a9dbe1..4330c20393 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -31,12 +31,12 @@
#include "pipe/p_defines.h"
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
#include "pipe/internal/p_winsys_screen.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_scan.h"
+#include "tgsi/tgsi_parse.h"
void *
@@ -98,17 +98,28 @@ softpipe_create_vs_state(struct pipe_context *pipe,
struct sp_vertex_shader *state;
state = CALLOC_STRUCT(sp_vertex_shader);
- if (state == NULL ) {
- return NULL;
- }
+ if (state == NULL )
+ goto fail;
+
+ /* copy shader tokens, the ones passed in will go away.
+ */
+ state->shader.tokens = tgsi_dup_tokens(templ->tokens);
+ if (state->shader.tokens == NULL)
+ goto fail;
state->draw_data = draw_create_vertex_shader(softpipe->draw, templ);
- if (state->draw_data == NULL) {
- FREE( state );
- return NULL;
- }
+ if (state->draw_data == NULL)
+ goto fail;
return state;
+
+fail:
+ if (state) {
+ FREE( (void *)state->shader.tokens );
+ FREE( state->draw_data );
+ FREE( state );
+ }
+ return NULL;
}
@@ -146,14 +157,12 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
const struct pipe_constant_buffer *buf)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- struct pipe_screen *screen = pipe->screen;
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
/* note: reference counting */
- pipe_buffer_reference(screen,
- &softpipe->constants[shader].buffer,
+ pipe_buffer_reference(&softpipe->constants[shader].buffer,
buf ? buf->buffer : NULL);
softpipe->dirty |= SP_NEW_CONSTANTS;
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 99a28c0d7e..cb517b02e4 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -30,7 +30,6 @@
*/
#include "util/u_memory.h"
-#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c
index 1493c65884..7c06d864a7 100644
--- a/src/gallium/drivers/softpipe/sp_state_surface.c
+++ b/src/gallium/drivers/softpipe/sp_state_surface.c
@@ -27,7 +27,6 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_inlines.h"
#include "sp_context.h"
#include "sp_state.h"
diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c
index 6ade732698..ef04843f17 100644
--- a/src/gallium/drivers/softpipe/sp_surface.c
+++ b/src/gallium/drivers/softpipe/sp_surface.c
@@ -29,10 +29,21 @@
#include "sp_context.h"
+static void
+sp_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)
+{
+ util_surface_copy(pipe, FALSE,
+ dest, destx, desty,
+ src, srcx, srcy,
+ width, height);
+}
void
sp_init_surface_functions(struct softpipe_context *sp)
{
- sp->pipe.surface_copy = util_surface_copy;
+ sp->pipe.surface_copy = sp_surface_copy;
sp->pipe.surface_fill = util_surface_fill;
}
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 32aa5025e4..adbd0cb7f0 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -34,7 +34,7 @@
*/
#include "sp_context.h"
-#include "sp_headers.h"
+#include "sp_quad.h"
#include "sp_surface.h"
#include "sp_texture.h"
#include "sp_tex_sample.h"
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 3eed0d0d29..48b2c22af4 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -59,7 +59,6 @@ static boolean
softpipe_texture_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
- struct pipe_winsys *ws = screen->winsys;
struct pipe_texture *pt = &spt->base;
unsigned level;
unsigned width = pt->width[0];
@@ -87,9 +86,9 @@ softpipe_texture_layout(struct pipe_screen *screen,
depth = minify(depth);
}
- spt->buffer = ws->buffer_create(ws, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- buffer_size);
+ spt->buffer = screen->buffer_create(screen, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ buffer_size);
return spt->buffer != NULL;
}
@@ -98,19 +97,18 @@ static boolean
softpipe_displaytarget_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
- struct pipe_winsys *ws = screen->winsys;
unsigned usage = (PIPE_BUFFER_USAGE_CPU_READ_WRITE |
PIPE_BUFFER_USAGE_GPU_READ_WRITE);
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
- spt->buffer = ws->surface_buffer_create( ws,
- spt->base.width[0],
- spt->base.height[0],
- spt->base.format,
- usage,
- &spt->stride[0]);
+ spt->buffer = screen->surface_buffer_create( screen,
+ spt->base.width[0],
+ spt->base.height[0],
+ spt->base.format,
+ usage,
+ &spt->stride[0]);
return spt->buffer != NULL;
}
@@ -128,7 +126,7 @@ softpipe_texture_create(struct pipe_screen *screen,
return NULL;
spt->base = *templat;
- spt->base.refcount = 1;
+ pipe_reference_init(&spt->base.reference, 1);
spt->base.screen = screen;
if (spt->base.tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
@@ -140,7 +138,7 @@ softpipe_texture_create(struct pipe_screen *screen,
goto fail;
}
- assert(spt->base.refcount == 1);
+ assert(p_atomic_read(&spt->base.reference.count) == 1);
return &spt->base;
fail:
@@ -170,32 +168,25 @@ softpipe_texture_blanket(struct pipe_screen * screen,
return NULL;
spt->base = *base;
- spt->base.refcount = 1;
+ pipe_reference_init(&spt->base.reference, 1);
spt->base.screen = screen;
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
spt->stride[0] = stride[0];
- pipe_buffer_reference(screen, &spt->buffer, buffer);
+ pipe_buffer_reference(&spt->buffer, buffer);
return &spt->base;
}
static void
-softpipe_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+softpipe_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
-
- if (--(*pt)->refcount <= 0) {
- struct softpipe_texture *spt = softpipe_texture(*pt);
+ struct softpipe_texture *spt = softpipe_texture(pt);
- pipe_buffer_reference(screen, &spt->buffer, NULL);
- FREE(spt);
- }
- *pt = NULL;
+ pipe_buffer_reference(&spt->buffer, NULL);
+ FREE(spt);
}
@@ -212,15 +203,11 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
- ps->block = pt->block;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = spt->stride[level];
ps->offset = spt->level_offset[level];
ps->usage = usage;
@@ -247,10 +234,11 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps->level = level;
ps->zslice = zslice;
- if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
- ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
- ps->nblocksy *
- ps->stride;
+ if (pt->target == PIPE_TEXTURE_CUBE) {
+ ps->offset += face * pt->nblocksy[level] * spt->stride[level];
+ }
+ else if (pt->target == PIPE_TEXTURE_3D) {
+ ps->offset += zslice * pt->nblocksy[level] * spt->stride[level];
}
else {
assert(face == 0);
@@ -262,38 +250,99 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
static void
-softpipe_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **s)
+softpipe_tex_surface_destroy(struct pipe_surface *surf)
{
- struct pipe_surface *surf = *s;
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For softpipe, nothing to do.
*/
assert(surf->texture);
- if (--surf->refcount == 0) {
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
+}
+
+
+static struct pipe_transfer *
+softpipe_get_tex_transfer(struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level, unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y, unsigned w, unsigned h)
+{
+ struct softpipe_texture *sptex = softpipe_texture(texture);
+ struct softpipe_transfer *spt;
+
+ assert(texture);
+ assert(level <= texture->last_level);
+
+ spt = CALLOC_STRUCT(softpipe_transfer);
+ if (spt) {
+ struct pipe_transfer *pt = &spt->base;
+ pipe_texture_reference(&pt->texture, texture);
+ pt->format = texture->format;
+ pt->block = texture->block;
+ pt->x = x;
+ pt->y = y;
+ pt->width = w;
+ pt->height = h;
+ pt->nblocksx = texture->nblocksx[level];
+ pt->nblocksy = texture->nblocksy[level];
+ pt->stride = sptex->stride[level];
+ pt->usage = usage;
+ pt->face = face;
+ pt->level = level;
+ pt->zslice = zslice;
+
+ spt->offset = sptex->level_offset[level];
+
+ if (texture->target == PIPE_TEXTURE_CUBE) {
+ spt->offset += face * pt->nblocksy * pt->stride;
+ }
+ else if (texture->target == PIPE_TEXTURE_3D) {
+ spt->offset += zslice * pt->nblocksy * pt->stride;
+ }
+ else {
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+ return pt;
}
- *s = NULL;
+ return NULL;
+}
+
+
+static void
+softpipe_tex_transfer_destroy(struct pipe_transfer *transfer)
+{
+ /* Effectively do the texture_update work here - if texture images
+ * needed post-processing to put them into hardware layout, this is
+ * where it would happen. For softpipe, nothing to do.
+ */
+ assert (transfer->texture);
+ pipe_texture_reference(&transfer->texture, NULL);
+ FREE(transfer);
}
static void *
-softpipe_surface_map( struct pipe_screen *screen,
- struct pipe_surface *surface,
- unsigned flags )
+softpipe_transfer_map( struct pipe_screen *screen,
+ struct pipe_transfer *transfer )
{
ubyte *map;
struct softpipe_texture *spt;
+ unsigned flags = 0;
- if (flags & ~surface->usage) {
- assert(0);
- return NULL;
+ assert(transfer->texture);
+ spt = softpipe_texture(transfer->texture);
+
+ if (transfer->usage != PIPE_TRANSFER_READ) {
+ flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+ }
+
+ if (transfer->usage != PIPE_TRANSFER_WRITE) {
+ flags |= PIPE_BUFFER_USAGE_CPU_READ;
}
- assert(surface->texture);
- spt = softpipe_texture(surface->texture);
map = pipe_buffer_map(screen, spt->buffer, flags);
if (map == NULL)
return NULL;
@@ -301,8 +350,7 @@ softpipe_surface_map( struct pipe_screen *screen,
/* May want to different things here depending on read/write nature
* of the map:
*/
- if (surface->texture &&
- (flags & PIPE_BUFFER_USAGE_CPU_WRITE))
+ if (transfer->texture && transfer->usage != PIPE_TRANSFER_READ)
{
/* Do something to notify sharing contexts of a texture change.
* In softpipe, that would mean flushing the texture cache.
@@ -310,18 +358,20 @@ softpipe_surface_map( struct pipe_screen *screen,
softpipe_screen(screen)->timestamp++;
}
- return map + surface->offset;
+ return map + softpipe_transfer(transfer)->offset +
+ transfer->y / transfer->block.height * transfer->stride +
+ transfer->x / transfer->block.width * transfer->block.size;
}
static void
-softpipe_surface_unmap(struct pipe_screen *screen,
- struct pipe_surface *surface)
+softpipe_transfer_unmap(struct pipe_screen *screen,
+ struct pipe_transfer *transfer)
{
struct softpipe_texture *spt;
- assert(surface->texture);
- spt = softpipe_texture(surface->texture);
+ assert(transfer->texture);
+ spt = softpipe_texture(transfer->texture);
pipe_buffer_unmap( screen, spt->buffer );
}
@@ -338,11 +388,13 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = softpipe_texture_create;
screen->texture_blanket = softpipe_texture_blanket;
- screen->texture_release = softpipe_texture_release;
+ screen->texture_destroy = softpipe_texture_destroy;
screen->get_tex_surface = softpipe_get_tex_surface;
- screen->tex_surface_release = softpipe_tex_surface_release;
+ screen->tex_surface_destroy = softpipe_tex_surface_destroy;
- screen->surface_map = softpipe_surface_map;
- screen->surface_unmap = softpipe_surface_unmap;
+ screen->get_tex_transfer = softpipe_get_tex_transfer;
+ screen->tex_transfer_destroy = softpipe_tex_transfer_destroy;
+ screen->transfer_map = softpipe_transfer_map;
+ screen->transfer_unmap = softpipe_transfer_unmap;
}
diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h
index c1636920cd..893aa7d11d 100644
--- a/src/gallium/drivers/softpipe/sp_texture.h
+++ b/src/gallium/drivers/softpipe/sp_texture.h
@@ -51,14 +51,27 @@ struct softpipe_texture
boolean modified;
};
+struct softpipe_transfer
+{
+ struct pipe_transfer base;
+
+ unsigned long offset;
+};
+
-/** cast wrapper */
+/** cast wrappers */
static INLINE struct softpipe_texture *
softpipe_texture(struct pipe_texture *pt)
{
return (struct softpipe_texture *) pt;
}
+static INLINE struct softpipe_transfer *
+softpipe_transfer(struct pipe_transfer *pt)
+{
+ return (struct softpipe_transfer *) pt;
+}
+
extern void
softpipe_init_texture_funcs( struct softpipe_context *softpipe );
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index ab76009375..69292753f1 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -26,7 +26,7 @@
**************************************************************************/
/**
- * Framebuffer/surface tile caching.
+ * Texture tile caching.
*
* Author:
* Brian Paul
@@ -40,7 +40,7 @@
#include "sp_texture.h"
#include "sp_tile_cache.h"
-#define NUM_ENTRIES 32
+#define NUM_ENTRIES 50
/** XXX move these */
@@ -52,7 +52,8 @@ struct softpipe_tile_cache
{
struct pipe_screen *screen;
struct pipe_surface *surface; /**< the surface we're caching */
- void *surface_map;
+ struct pipe_transfer *transfer;
+ void *transfer_map;
struct pipe_texture *texture; /**< if caching a texture */
struct softpipe_cached_tile entries[NUM_ENTRIES];
uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32];
@@ -60,8 +61,8 @@ struct softpipe_tile_cache
uint clear_val;
boolean depth_stencil; /** Is the surface a depth/stencil format? */
- struct pipe_surface *tex_surf;
- void *tex_surf_map;
+ struct pipe_transfer *tex_trans;
+ void *tex_trans_map;
int tex_face, tex_level, tex_z;
struct softpipe_cached_tile tile; /**< scratch tile for clears */
@@ -131,16 +132,19 @@ sp_create_tile_cache( struct pipe_screen *screen )
void
sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
{
+ struct pipe_screen *screen;
uint pos;
for (pos = 0; pos < NUM_ENTRIES; pos++) {
/*assert(tc->entries[pos].x < 0);*/
}
- if (tc->surface) {
- pipe_surface_reference(&tc->surface, NULL);
+ if (tc->transfer) {
+ screen = tc->transfer->texture->screen;
+ screen->tex_transfer_destroy(tc->transfer);
}
- if (tc->tex_surf) {
- pipe_surface_reference(&tc->tex_surf, NULL);
+ if (tc->tex_trans) {
+ screen = tc->tex_trans->texture->screen;
+ screen->tex_transfer_destroy(tc->tex_trans);
}
FREE( tc );
@@ -156,18 +160,30 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
{
assert(!tc->texture);
- if (tc->surface_map) {
- tc->screen->surface_unmap(tc->screen, tc->surface);
- tc->surface_map = NULL;
+ if (tc->transfer) {
+ struct pipe_screen *screen = tc->transfer->texture->screen;
+
+ if (ps == tc->surface)
+ return;
+
+ if (tc->transfer_map) {
+ screen->transfer_unmap(screen, tc->transfer);
+ tc->transfer_map = NULL;
+ }
+
+ screen->tex_transfer_destroy(tc->transfer);
+ tc->transfer = NULL;
}
- pipe_surface_reference(&tc->surface, ps);
+ tc->surface = ps;
- if (tc->surface) {
- if (tc->surface_map) /* XXX: this is always NULL!? */
- tc->surface_map = tc->screen->surface_map(tc->screen, tc->surface,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ if (ps) {
+ struct pipe_screen *screen = ps->texture->screen;
+
+ tc->transfer = screen->get_tex_transfer(screen, ps->texture, ps->face,
+ ps->level, ps->zslice,
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0, ps->width, ps->height);
tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM ||
ps->format == PIPE_FORMAT_X8Z24_UNORM ||
@@ -181,7 +197,7 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
/**
- * Return the surface being cached.
+ * Return the transfer being cached.
*/
struct pipe_surface *
sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
@@ -191,30 +207,27 @@ sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
void
-sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc)
+sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc)
{
- if (tc->surface && !tc->surface_map)
- tc->surface_map = tc->screen->surface_map(tc->screen, tc->surface,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_CPU_READ);
-
- if (tc->tex_surf && !tc->tex_surf_map)
- tc->tex_surf_map = tc->screen->surface_map(tc->screen, tc->tex_surf,
- PIPE_BUFFER_USAGE_CPU_READ);
+ if (tc->transfer && !tc->transfer_map)
+ tc->transfer_map = tc->screen->transfer_map(tc->screen, tc->transfer);
+
+ if (tc->tex_trans && !tc->tex_trans_map)
+ tc->tex_trans_map = tc->screen->transfer_map(tc->screen, tc->tex_trans);
}
void
-sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc)
+sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc)
{
- if (tc->surface_map) {
- tc->screen->surface_unmap(tc->screen, tc->surface);
- tc->surface_map = NULL;
+ if (tc->transfer_map) {
+ tc->screen->transfer_unmap(tc->screen, tc->transfer);
+ tc->transfer_map = NULL;
}
- if (tc->tex_surf_map) {
- tc->screen->surface_unmap(tc->screen, tc->tex_surf);
- tc->tex_surf_map = NULL;
+ if (tc->tex_trans_map) {
+ tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
+ tc->tex_trans_map = NULL;
}
}
@@ -229,15 +242,21 @@ sp_tile_cache_set_texture(struct pipe_context *pipe,
{
uint i;
- assert(!tc->surface);
+ assert(!tc->transfer);
pipe_texture_reference(&tc->texture, texture);
- if (tc->tex_surf_map) {
- tc->screen->surface_unmap(tc->screen, tc->tex_surf);
- tc->tex_surf_map = NULL;
+ if (tc->tex_trans) {
+ struct pipe_screen *screen = tc->tex_trans->texture->screen;
+
+ if (tc->tex_trans_map) {
+ screen->transfer_unmap(screen, tc->tex_trans);
+ tc->tex_trans_map = NULL;
+ }
+
+ screen->tex_transfer_destroy(tc->tex_trans);
+ tc->tex_trans = NULL;
}
- pipe_surface_reference(&tc->tex_surf, NULL);
/* mark as entries as invalid/empty */
/* XXX we should try to avoid this when the teximage hasn't changed */
@@ -328,20 +347,20 @@ static void
sp_tile_cache_flush_clear(struct pipe_context *pipe,
struct softpipe_tile_cache *tc)
{
- struct pipe_surface *ps = tc->surface;
- const uint w = tc->surface->width;
- const uint h = tc->surface->height;
+ struct pipe_transfer *pt = tc->transfer;
+ const uint w = tc->transfer->width;
+ const uint h = tc->transfer->height;
uint x, y;
uint numCleared = 0;
/* clear the scratch tile to the clear value */
- clear_tile(&tc->tile, ps->format, tc->clear_val);
+ clear_tile(&tc->tile, pt->format, tc->clear_val);
/* push the tile to all positions marked as clear */
for (y = 0; y < h; y += TILE_SIZE) {
for (x = 0; x < w; x += TILE_SIZE) {
if (is_clear_flag_set(tc->clear_flags, x, y)) {
- pipe_put_tile_raw(ps,
+ pipe_put_tile_raw(pt,
x, y, TILE_SIZE, TILE_SIZE,
tc->tile.data.color32, 0/*STRIDE*/);
@@ -359,28 +378,28 @@ sp_tile_cache_flush_clear(struct pipe_context *pipe,
/**
- * Flush the tile cache: write all dirty tiles back to the surface.
+ * Flush the tile cache: write all dirty tiles back to the transfer.
* any tiles "flagged" as cleared will be "really" cleared.
*/
void
sp_flush_tile_cache(struct softpipe_context *softpipe,
struct softpipe_tile_cache *tc)
{
- struct pipe_surface *ps = tc->surface;
+ struct pipe_transfer *pt = tc->transfer;
int inuse = 0, pos;
- if (ps) {
- /* caching a drawing surface */
+ if (pt) {
+ /* caching a drawing transfer */
for (pos = 0; pos < NUM_ENTRIES; pos++) {
struct softpipe_cached_tile *tile = tc->entries + pos;
if (tile->x >= 0) {
if (tc->depth_stencil) {
- pipe_put_tile_raw(ps,
+ pipe_put_tile_raw(pt,
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
tile->data.depth32, 0/*STRIDE*/);
}
else {
- pipe_put_tile_rgba(ps,
+ pipe_put_tile_rgba(pt,
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
(float *) tile->data.color);
}
@@ -415,7 +434,7 @@ struct softpipe_cached_tile *
sp_get_cached_tile(struct softpipe_context *softpipe,
struct softpipe_tile_cache *tc, int x, int y)
{
- struct pipe_surface *ps = tc->surface;
+ struct pipe_transfer *pt = tc->transfer;
/* tile pos in framebuffer: */
const int tile_x = x & ~(TILE_SIZE - 1);
@@ -431,12 +450,12 @@ sp_get_cached_tile(struct softpipe_context *softpipe,
if (tile->x != -1) {
/* put dirty tile back in framebuffer */
if (tc->depth_stencil) {
- pipe_put_tile_raw(ps,
+ pipe_put_tile_raw(pt,
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
tile->data.depth32, 0/*STRIDE*/);
}
else {
- pipe_put_tile_rgba(ps,
+ pipe_put_tile_rgba(pt,
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
(float *) tile->data.color);
}
@@ -448,22 +467,22 @@ sp_get_cached_tile(struct softpipe_context *softpipe,
if (is_clear_flag_set(tc->clear_flags, x, y)) {
/* don't get tile from framebuffer, just clear it */
if (tc->depth_stencil) {
- clear_tile(tile, ps->format, tc->clear_val);
+ clear_tile(tile, pt->format, tc->clear_val);
}
else {
- clear_tile_rgba(tile, ps->format, tc->clear_color);
+ clear_tile_rgba(tile, pt->format, tc->clear_color);
}
clear_clear_flag(tc->clear_flags, x, y);
}
else {
- /* get new tile data from surface */
+ /* get new tile data from transfer */
if (tc->depth_stencil) {
- pipe_get_tile_raw(ps,
+ pipe_get_tile_raw(pt,
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
tile->data.depth32, 0/*STRIDE*/);
}
else {
- pipe_get_tile_rgba(ps,
+ pipe_get_tile_rgba(pt,
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
(float *) tile->data.color);
}
@@ -484,7 +503,7 @@ sp_get_cached_tile(struct softpipe_context *softpipe,
static INLINE uint
tex_cache_pos(int x, int y, int z, int face, int level)
{
- uint entry = x + y * 5 + z * 4 + face + level;
+ uint entry = x + y * 9 + z * 3 + face + level * 7;
return entry % NUM_ENTRIES;
}
@@ -510,8 +529,12 @@ sp_get_cached_tile_tex(struct softpipe_context *sp,
if (tc->texture) {
struct softpipe_texture *spt = softpipe_texture(tc->texture);
if (spt->modified) {
- /* texture was modified, force a cache reload */
- tile->x = -1;
+ /* texture was modified, invalidate all cached tiles */
+ uint p;
+ for (p = 0; p < NUM_ENTRIES; p++) {
+ tile = tc->entries + p;
+ tile->x = -1;
+ }
spt->modified = FALSE;
}
}
@@ -523,28 +546,40 @@ sp_get_cached_tile_tex(struct softpipe_context *sp,
level != tile->level) {
/* cache miss */
- /* check if we need to get a new surface */
- if (!tc->tex_surf ||
+#if 0
+ printf("miss at %u x=%d y=%d z=%d face=%d level=%d\n", pos,
+ x/TILE_SIZE, y/TILE_SIZE, z, face, level);
+#endif
+ /* check if we need to get a new transfer */
+ if (!tc->tex_trans ||
tc->tex_face != face ||
tc->tex_level != level ||
tc->tex_z != z) {
- /* get new surface (view into texture) */
+ /* get new transfer (view into texture) */
+
+ if (tc->tex_trans) {
+ if (tc->tex_trans_map) {
+ tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
+ tc->tex_trans_map = NULL;
+ }
- if (tc->tex_surf_map)
- tc->screen->surface_unmap(tc->screen, tc->tex_surf);
+ screen->tex_transfer_destroy(tc->tex_trans);
+ tc->tex_trans = NULL;
+ }
- tc->tex_surf = screen->get_tex_surface(screen, tc->texture, face, level, z,
- PIPE_BUFFER_USAGE_CPU_READ);
- tc->tex_surf_map = screen->surface_map(screen, tc->tex_surf,
- PIPE_BUFFER_USAGE_CPU_READ);
+ tc->tex_trans = screen->get_tex_transfer(screen, tc->texture, face, level, z,
+ PIPE_TRANSFER_READ, 0, 0,
+ tc->texture->width[level],
+ tc->texture->height[level]);
+ tc->tex_trans_map = screen->transfer_map(screen, tc->tex_trans);
tc->tex_face = face;
tc->tex_level = level;
tc->tex_z = z;
}
- /* get tile from the surface (view into texture) */
- pipe_get_tile_rgba(tc->tex_surf,
+ /* get tile from the transfer (view into texture) */
+ pipe_get_tile_rgba(tc->tex_trans,
tile_x, tile_y, TILE_SIZE, TILE_SIZE,
(float *) tile->data.color);
tile->x = tile_x;
@@ -571,7 +606,7 @@ sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue)
tc->clear_val = clearValue;
- switch (tc->surface->format) {
+ switch (tc->transfer->format) {
case PIPE_FORMAT_R8G8B8A8_UNORM:
r = (clearValue >> 24) & 0xff;
g = (clearValue >> 16) & 0xff;
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h
index a66bb50bcc..9ac3fdda94 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.h
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.h
@@ -74,10 +74,10 @@ extern struct pipe_surface *
sp_tile_cache_get_surface(struct softpipe_tile_cache *tc);
extern void
-sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc);
+sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc);
extern void
-sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc);
+sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc);
extern void
sp_tile_cache_set_texture(struct pipe_context *pipe,
diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile
index 3859b8acb0..e087db169a 100644
--- a/src/gallium/drivers/trace/Makefile
+++ b/src/gallium/drivers/trace/Makefile
@@ -4,15 +4,11 @@ include $(TOP)/configs/current
LIBNAME = trace
C_SOURCES = \
+ tr_buffer.c \
tr_context.c \
tr_dump.c \
tr_screen.c \
tr_state.c \
- tr_texture.c \
- tr_winsys.c
-
+ tr_texture.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript
index 0a6bfb8f4c..4215215d1a 100644
--- a/src/gallium/drivers/trace/SConscript
+++ b/src/gallium/drivers/trace/SConscript
@@ -5,12 +5,12 @@ env = env.Clone()
trace = env.ConvenienceLibrary(
target = 'trace',
source = [
+ 'tr_buffer.c',
'tr_context.c',
'tr_dump.c',
'tr_screen.c',
'tr_state.c',
'tr_texture.c',
- 'tr_winsys.c',
])
-Export('trace') \ No newline at end of file
+Export('trace')
diff --git a/src/gallium/drivers/trace/tr_buffer.c b/src/gallium/drivers/trace/tr_buffer.c
new file mode 100644
index 0000000000..6ffce1660e
--- /dev/null
+++ b/src/gallium/drivers/trace/tr_buffer.c
@@ -0,0 +1,70 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "util/u_memory.h"
+
+#include "tr_buffer.h"
+
+
+struct pipe_buffer *
+trace_buffer_create(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer)
+{
+ struct trace_buffer *tr_buf;
+
+ if(!buffer)
+ goto error;
+
+ assert(buffer->screen == tr_scr->screen);
+
+ tr_buf = CALLOC_STRUCT(trace_buffer);
+ if(!tr_buf)
+ goto error;
+
+ memcpy(&tr_buf->base, buffer, sizeof(struct pipe_buffer));
+
+ pipe_reference_init(&tr_buf->base.reference, 1);
+ tr_buf->base.screen = &tr_scr->base;
+ tr_buf->buffer = buffer;
+
+ return &tr_buf->base;
+
+error:
+ pipe_buffer_reference(&buffer, NULL);
+ return NULL;
+}
+
+
+void
+trace_buffer_destroy(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer)
+{
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, buffer);
+ pipe_buffer_reference(&tr_buf->buffer, NULL);
+ FREE(tr_buf);
+}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_reg.h b/src/gallium/drivers/trace/tr_buffer.h
index 4f33bee438..e9e4d354da 100644
--- a/src/gallium/winsys/drm/intel/dri/intel_reg.h
+++ b/src/gallium/drivers/trace/tr_buffer.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,29 +25,46 @@
*
**************************************************************************/
+#ifndef TR_BUFFER_H_
+#define TR_BUFFER_H_
-#ifndef _INTEL_REG_H_
-#define _INTEL_REG_H_
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
-#define BR00_BITBLT_CLIENT 0x40000000
-#define BR00_OP_COLOR_BLT 0x10000000
-#define BR00_OP_SRC_COPY_BLT 0x10C00000
-#define BR13_SOLID_PATTERN 0x80000000
+#include "tr_screen.h"
-#define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|0x4)
-#define XY_COLOR_BLT_WRITE_ALPHA (1<<21)
-#define XY_COLOR_BLT_WRITE_RGB (1<<20)
-#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
-#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
-#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
+struct trace_buffer
+{
+ struct pipe_buffer base;
-#define MI_WAIT_FOR_EVENT ((0x3<<23))
-#define MI_WAIT_FOR_PLANE_B_FLIP (1<<6)
-#define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
+ struct pipe_buffer *buffer;
-#define MI_BATCH_BUFFER_END (0xA<<23)
+ void *map;
+ boolean range_flushed;
+};
+
+
+static INLINE struct trace_buffer *
+trace_buffer(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer)
+{
+ if(!buffer)
+ return NULL;
+ assert(tr_scr);
+ assert(buffer->screen == &tr_scr->base);
+ return (struct trace_buffer *)buffer;
+}
+
+
+struct pipe_buffer *
+trace_buffer_create(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer);
+
+void
+trace_buffer_destroy(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer);
#endif
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index ec8be27077..c894972904 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -30,48 +30,66 @@
#include "tr_dump.h"
#include "tr_state.h"
+#include "tr_buffer.h"
#include "tr_screen.h"
#include "tr_texture.h"
-#include "tr_winsys.h"
#include "tr_context.h"
-static INLINE struct pipe_texture *
+static INLINE struct pipe_buffer *
+trace_buffer_unwrap(struct trace_context *tr_ctx,
+ struct pipe_buffer *buffer)
+{
+ struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+ struct trace_buffer *tr_buf;
+
+ if(!buffer)
+ return NULL;
+
+ tr_buf = trace_buffer(tr_scr, buffer);
+
+ assert(tr_buf->buffer);
+ assert(tr_buf->buffer->screen == tr_scr->screen);
+ return tr_buf->buffer;
+}
+
+
+static INLINE struct pipe_texture *
trace_texture_unwrap(struct trace_context *tr_ctx,
struct pipe_texture *texture)
{
- struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+ struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
struct trace_texture *tr_tex;
-
+
if(!texture)
return NULL;
-
+
tr_tex = trace_texture(tr_scr, texture);
-
+
assert(tr_tex->texture);
assert(tr_tex->texture->screen == tr_scr->screen);
return tr_tex->texture;
}
-static INLINE struct pipe_surface *
+static INLINE struct pipe_surface *
trace_surface_unwrap(struct trace_context *tr_ctx,
struct pipe_surface *surface)
{
- struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+ struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
struct trace_texture *tr_tex;
struct trace_surface *tr_surf;
-
+
if(!surface)
return NULL;
assert(surface->texture);
if(!surface->texture)
return surface;
-
+
tr_tex = trace_texture(tr_scr, surface->texture);
tr_surf = trace_surface(tr_tex, surface);
-
+
assert(tr_surf->surface);
assert(tr_surf->surface->texture->screen == tr_scr->screen);
return tr_surf->surface;
@@ -86,7 +104,7 @@ trace_context_set_edgeflags(struct pipe_context *_pipe,
struct pipe_context *pipe = tr_ctx->pipe;
trace_dump_call_begin("pipe_context", "set_edgeflags");
-
+
trace_dump_arg(ptr, pipe);
/* FIXME: we don't know how big this array is */
trace_dump_arg(ptr, bitfield);
@@ -115,24 +133,27 @@ trace_context_draw_arrays(struct pipe_context *_pipe,
result = pipe->draw_arrays(pipe, mode, start, count);;
trace_dump_ret(bool, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE boolean
trace_context_draw_elements(struct pipe_context *_pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_buffer *_indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
+ struct trace_screen *tr_scr = trace_screen(_pipe->screen);
struct trace_context *tr_ctx = trace_context(_pipe);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer);
struct pipe_context *pipe = tr_ctx->pipe;
+ struct pipe_buffer *indexBuffer = tr_buf->buffer;
boolean result;
- trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
+ trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
trace_dump_call_begin("pipe_context", "draw_elements");
@@ -146,28 +167,31 @@ trace_context_draw_elements(struct pipe_context *_pipe,
result = pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);;
trace_dump_ret(bool, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE boolean
trace_context_draw_range_elements(struct pipe_context *_pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_buffer *_indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
- unsigned mode,
- unsigned start,
+ unsigned mode,
+ unsigned start,
unsigned count)
{
+ struct trace_screen *tr_scr = trace_screen(_pipe->screen);
struct trace_context *tr_ctx = trace_context(_pipe);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer);
struct pipe_context *pipe = tr_ctx->pipe;
+ struct pipe_buffer *indexBuffer = tr_buf->buffer;
boolean result;
- trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
+ trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
trace_dump_call_begin("pipe_context", "draw_range_elements");
@@ -180,15 +204,15 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
trace_dump_arg(uint, start);
trace_dump_arg(uint, count);
- result = pipe->draw_range_elements(pipe,
- indexBuffer,
- indexSize, minIndex, maxIndex,
+ result = pipe->draw_range_elements(pipe,
+ indexBuffer,
+ indexSize, minIndex, maxIndex,
mode, start, count);
-
+
trace_dump_ret(bool, result);
-
+
trace_dump_call_end();
-
+
return result;
}
@@ -209,9 +233,9 @@ trace_context_create_query(struct pipe_context *_pipe,
result = pipe->create_query(pipe, query_type);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
@@ -235,7 +259,7 @@ trace_context_destroy_query(struct pipe_context *_pipe,
static INLINE void
-trace_context_begin_query(struct pipe_context *_pipe,
+trace_context_begin_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -253,7 +277,7 @@ trace_context_begin_query(struct pipe_context *_pipe,
static INLINE void
-trace_context_end_query(struct pipe_context *_pipe,
+trace_context_end_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -271,7 +295,7 @@ trace_context_end_query(struct pipe_context *_pipe,
static INLINE boolean
-trace_context_get_query_result(struct pipe_context *_pipe,
+trace_context_get_query_result(struct pipe_context *_pipe,
struct pipe_query *query,
boolean wait,
uint64_t *presult)
@@ -290,9 +314,9 @@ trace_context_get_query_result(struct pipe_context *_pipe,
trace_dump_arg(uint, result);
trace_dump_ret(bool, _result);
-
+
trace_dump_call_end();
-
+
return _result;
}
@@ -315,13 +339,13 @@ trace_context_create_blend_state(struct pipe_context *_pipe,
trace_dump_ret(ptr, result);
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_blend_state(struct pipe_context *_pipe,
+trace_context_bind_blend_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -339,7 +363,7 @@ trace_context_bind_blend_state(struct pipe_context *_pipe,
static INLINE void
-trace_context_delete_blend_state(struct pipe_context *_pipe,
+trace_context_delete_blend_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -372,15 +396,15 @@ trace_context_create_sampler_state(struct pipe_context *_pipe,
result = pipe->create_sampler_state(pipe, state);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_sampler_states(struct pipe_context *_pipe,
+trace_context_bind_sampler_states(struct pipe_context *_pipe,
unsigned num_states, void **states)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -399,7 +423,7 @@ trace_context_bind_sampler_states(struct pipe_context *_pipe,
static INLINE void
-trace_context_delete_sampler_state(struct pipe_context *_pipe,
+trace_context_delete_sampler_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -432,15 +456,15 @@ trace_context_create_rasterizer_state(struct pipe_context *_pipe,
result = pipe->create_rasterizer_state(pipe, state);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
+trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -458,7 +482,7 @@ trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
static INLINE void
-trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
+trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -489,17 +513,17 @@ trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(depth_stencil_alpha_state, state);
-
+
trace_dump_ret(ptr, result);
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
+trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -517,7 +541,7 @@ trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
static INLINE void
-trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
+trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -550,15 +574,15 @@ trace_context_create_fs_state(struct pipe_context *_pipe,
result = pipe->create_fs_state(pipe, state);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_fs_state(struct pipe_context *_pipe,
+trace_context_bind_fs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -576,7 +600,7 @@ trace_context_bind_fs_state(struct pipe_context *_pipe,
static INLINE void
-trace_context_delete_fs_state(struct pipe_context *_pipe,
+trace_context_delete_fs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -609,15 +633,15 @@ trace_context_create_vs_state(struct pipe_context *_pipe,
result = pipe->create_vs_state(pipe, state);;
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
return result;
}
static INLINE void
-trace_context_bind_vs_state(struct pipe_context *_pipe,
+trace_context_bind_vs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -635,7 +659,7 @@ trace_context_bind_vs_state(struct pipe_context *_pipe,
static INLINE void
-trace_context_delete_vs_state(struct pipe_context *_pipe,
+trace_context_delete_vs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -696,8 +720,9 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe,
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
- trace_winsys_user_buffer_update(_pipe->winsys, (struct pipe_buffer *)buffer);
-
+ if (buffer)
+ trace_screen_user_buffer_update(_pipe->screen, buffer->buffer);
+
trace_dump_call_begin("pipe_context", "set_constant_buffer");
trace_dump_arg(ptr, pipe);
@@ -705,7 +730,13 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe,
trace_dump_arg(uint, index);
trace_dump_arg(constant_buffer, buffer);
- pipe->set_constant_buffer(pipe, shader, index, buffer);;
+ if (buffer) {
+ struct pipe_constant_buffer _buffer;
+ _buffer.buffer = trace_buffer_unwrap(tr_ctx, buffer->buffer);
+ pipe->set_constant_buffer(pipe, shader, index, &_buffer);
+ } else {
+ pipe->set_constant_buffer(pipe, shader, index, buffer);
+ }
trace_dump_call_end();
}
@@ -719,7 +750,7 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_framebuffer_state unwrapped_state;
unsigned i;
-
+
/* Unwrap the input state */
memcpy(&unwrapped_state, state, sizeof(unwrapped_state));
for(i = 0; i < state->nr_cbufs; ++i)
@@ -728,7 +759,7 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
unwrapped_state.cbufs[i] = NULL;
unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
state = &unwrapped_state;
-
+
trace_dump_call_begin("pipe_context", "set_framebuffer_state");
trace_dump_arg(ptr, pipe);
@@ -803,7 +834,7 @@ trace_context_set_sampler_textures(struct pipe_context *_pipe,
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS];
unsigned i;
-
+
for(i = 0; i < num_textures; ++i)
unwrapped_textures[i] = trace_texture_unwrap(tr_ctx, textures[i]);
textures = unwrapped_textures;
@@ -830,18 +861,27 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe,
unsigned i;
for(i = 0; i < num_buffers; ++i)
- trace_winsys_user_buffer_update(_pipe->winsys, buffers[i].buffer);
+ trace_screen_user_buffer_update(_pipe->screen, buffers[i].buffer);
trace_dump_call_begin("pipe_context", "set_vertex_buffers");
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, num_buffers);
-
+
trace_dump_arg_begin("buffers");
trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
trace_dump_arg_end();
- pipe->set_vertex_buffers(pipe, num_buffers, buffers);;
+ if (num_buffers) {
+ struct pipe_vertex_buffer *_buffers = malloc(num_buffers * sizeof(*_buffers));
+ memcpy(_buffers, buffers, num_buffers * sizeof(*_buffers));
+ for (i = 0; i < num_buffers; i++)
+ _buffers[i].buffer = trace_buffer_unwrap(tr_ctx, buffers[i].buffer);
+ pipe->set_vertex_buffers(pipe, num_buffers, _buffers);
+ free(_buffers);
+ } else {
+ pipe->set_vertex_buffers(pipe, num_buffers, NULL);
+ }
trace_dump_call_end();
}
@@ -872,7 +912,6 @@ trace_context_set_vertex_elements(struct pipe_context *_pipe,
static INLINE void
trace_context_surface_copy(struct pipe_context *_pipe,
- boolean do_flip,
struct pipe_surface *dest,
unsigned destx, unsigned desty,
struct pipe_surface *src,
@@ -884,11 +923,10 @@ trace_context_surface_copy(struct pipe_context *_pipe,
dest = trace_surface_unwrap(tr_ctx, dest);
src = trace_surface_unwrap(tr_ctx, src);
-
+
trace_dump_call_begin("pipe_context", "surface_copy");
trace_dump_arg(ptr, pipe);
- trace_dump_arg(bool, do_flip);
trace_dump_arg(ptr, dest);
trace_dump_arg(uint, destx);
trace_dump_arg(uint, desty);
@@ -898,10 +936,10 @@ trace_context_surface_copy(struct pipe_context *_pipe,
trace_dump_arg(uint, width);
trace_dump_arg(uint, height);
- pipe->surface_copy(pipe, do_flip,
- dest, destx, desty,
+ pipe->surface_copy(pipe,
+ dest, destx, desty,
src, srcx, srcy, width, height);
-
+
trace_dump_call_end();
}
@@ -934,7 +972,7 @@ trace_context_surface_fill(struct pipe_context *_pipe,
static INLINE void
-trace_context_clear(struct pipe_context *_pipe,
+trace_context_clear(struct pipe_context *_pipe,
struct pipe_surface *surface,
unsigned clearValue)
{
@@ -988,7 +1026,7 @@ trace_context_destroy(struct pipe_context *_pipe)
trace_dump_arg(ptr, pipe);
pipe->destroy(pipe);
-
+
trace_dump_call_end();
FREE(tr_ctx);
@@ -996,23 +1034,25 @@ trace_context_destroy(struct pipe_context *_pipe)
struct pipe_context *
-trace_context_create(struct pipe_screen *screen,
+trace_context_create(struct pipe_screen *_screen,
struct pipe_context *pipe)
{
+ struct trace_screen *tr_scr = trace_screen(_screen);
struct trace_context *tr_ctx;
-
+ struct pipe_screen *screen = tr_scr->screen;
+
if(!pipe)
goto error1;
-
+
if(!trace_dump_enabled())
goto error1;
-
+
tr_ctx = CALLOC_STRUCT(trace_context);
if(!tr_ctx)
goto error1;
- tr_ctx->base.winsys = screen->winsys;
- tr_ctx->base.screen = screen;
+ tr_ctx->base.winsys = _screen->winsys;
+ tr_ctx->base.screen = _screen;
tr_ctx->base.destroy = trace_context_destroy;
tr_ctx->base.set_edgeflags = trace_context_set_edgeflags;
tr_ctx->base.draw_arrays = trace_context_draw_arrays;
@@ -1057,16 +1097,14 @@ trace_context_create(struct pipe_screen *screen,
tr_ctx->base.flush = trace_context_flush;
tr_ctx->pipe = pipe;
-
+
trace_dump_call_begin("", "pipe_context_create");
- trace_dump_arg_begin("screen");
- trace_dump_ptr(pipe->screen);
- trace_dump_arg_end();
+ trace_dump_arg(ptr, screen);
trace_dump_ret(ptr, pipe);
trace_dump_call_end();
return &tr_ctx->base;
-
+
error1:
return pipe;
}
diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h
index 7831900ec2..d02b22a069 100644
--- a/src/gallium/drivers/trace/tr_context.h
+++ b/src/gallium/drivers/trace/tr_context.h
@@ -30,7 +30,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_context.h"
@@ -38,11 +38,11 @@
extern "C" {
#endif
-
+
struct trace_context
{
struct pipe_context base;
-
+
struct pipe_context *pipe;
};
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index a0ead0ded3..6837c94542 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -29,35 +29,38 @@
/**
* @file
* Trace dumping functions.
- *
+ *
* For now we just use standard XML for dumping the trace calls, as this is
- * simple to write, parse, and visually inspect, but the actual representation
- * is abstracted out of this file, so that we can switch to a binary
+ * simple to write, parse, and visually inspect, but the actual representation
+ * is abstracted out of this file, so that we can switch to a binary
* representation if/when it becomes justified.
- *
- * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
+ *
+ * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
*/
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
#include <stdlib.h>
#endif
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.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"
+#include "tr_texture.h"
+#include "tr_buffer.h"
static struct util_stream *stream = NULL;
static unsigned refcount = 0;
-static INLINE void
+static INLINE void
trace_dump_write(const char *buf, size_t size)
{
if(stream)
@@ -65,14 +68,14 @@ trace_dump_write(const char *buf, size_t size)
}
-static INLINE void
+static INLINE void
trace_dump_writes(const char *s)
{
trace_dump_write(s, strlen(s));
}
-static INLINE void
+static INLINE void
trace_dump_writef(const char *format, ...)
{
static char buf[1024];
@@ -85,8 +88,8 @@ trace_dump_writef(const char *format, ...)
}
-static INLINE void
-trace_dump_escape(const char *str)
+static INLINE void
+trace_dump_escape(const char *str)
{
const unsigned char *p = (const unsigned char *)str;
unsigned char c;
@@ -109,7 +112,7 @@ trace_dump_escape(const char *str)
}
-static INLINE void
+static INLINE void
trace_dump_indent(unsigned level)
{
unsigned i;
@@ -118,14 +121,14 @@ trace_dump_indent(unsigned level)
}
-static INLINE void
-trace_dump_newline(void)
+static INLINE void
+trace_dump_newline(void)
{
trace_dump_writes("\n");
}
-static INLINE void
+static INLINE void
trace_dump_tag(const char *name)
{
trace_dump_writes("<");
@@ -134,7 +137,7 @@ trace_dump_tag(const char *name)
}
-static INLINE void
+static INLINE void
trace_dump_tag_begin(const char *name)
{
trace_dump_writes("<");
@@ -142,8 +145,8 @@ trace_dump_tag_begin(const char *name)
trace_dump_writes(">");
}
-static INLINE void
-trace_dump_tag_begin1(const char *name,
+static INLINE void
+trace_dump_tag_begin1(const char *name,
const char *attr1, const char *value1)
{
trace_dump_writes("<");
@@ -156,8 +159,8 @@ trace_dump_tag_begin1(const char *name,
}
-static INLINE void
-trace_dump_tag_begin2(const char *name,
+static INLINE void
+trace_dump_tag_begin2(const char *name,
const char *attr1, const char *value1,
const char *attr2, const char *value2)
{
@@ -175,8 +178,8 @@ trace_dump_tag_begin2(const char *name,
}
-static INLINE void
-trace_dump_tag_begin3(const char *name,
+static INLINE void
+trace_dump_tag_begin3(const char *name,
const char *attr1, const char *value1,
const char *attr2, const char *value2,
const char *attr3, const char *value3)
@@ -207,7 +210,7 @@ trace_dump_tag_end(const char *name)
trace_dump_writes(">");
}
-static void
+static void
trace_dump_trace_close(void)
{
if(stream) {
@@ -221,30 +224,30 @@ trace_dump_trace_close(void)
boolean trace_dump_trace_begin()
{
const char *filename;
-
+
filename = debug_get_option("GALLIUM_TRACE", NULL);
if(!filename)
return FALSE;
-
+
if(!stream) {
-
+
stream = util_stream_create(filename, 0);
if(!stream)
return FALSE;
-
+
trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
trace_dump_writes("<trace version='0.1'>\n");
-
-#if defined(PIPE_OS_LINUX)
- /* Linux applications rarely cleanup GL / Gallium resources so catch
- * application exit here */
+
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
+ /* Linux applications rarely cleanup GL / Gallium resources so catch
+ * application exit here */
atexit(trace_dump_trace_close);
#endif
}
-
+
++refcount;
-
+
return TRUE;
}
@@ -402,3 +405,49 @@ void trace_dump_ptr(const void *value)
else
trace_dump_null();
}
+
+void trace_dump_buffer_ptr(struct pipe_buffer *_buffer)
+{
+ if (_buffer) {
+ struct trace_screen *tr_scr = trace_screen(_buffer->screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
+ trace_dump_ptr(tr_buf->buffer);
+ } else {
+ trace_dump_null();
+ }
+}
+
+void trace_dump_texture_ptr(struct pipe_texture *_texture)
+{
+ if (_texture) {
+ struct trace_screen *tr_scr = trace_screen(_texture->screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _texture);
+ trace_dump_ptr(tr_tex->texture);
+ } else {
+ trace_dump_null();
+ }
+}
+
+void trace_dump_surface_ptr(struct pipe_surface *_surface)
+{
+ if (_surface) {
+ struct trace_screen *tr_scr = trace_screen(_surface->texture->screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture);
+ struct trace_surface *tr_surf = trace_surface(tr_tex, _surface);
+ trace_dump_ptr(tr_surf->surface);
+ } else {
+ trace_dump_null();
+ }
+}
+
+void trace_dump_transfer_ptr(struct pipe_transfer *_transfer)
+{
+ if (_transfer) {
+ struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture);
+ struct trace_transfer *tr_tran = trace_transfer(tr_tex, _transfer);
+ trace_dump_ptr(tr_tran->transfer);
+ } else {
+ trace_dump_null();
+ }
+}
diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h
index 76a53731b3..26409f26c6 100644
--- a/src/gallium/drivers/trace/tr_dump.h
+++ b/src/gallium/drivers/trace/tr_dump.h
@@ -37,6 +37,11 @@
#include "pipe/p_compiler.h"
+struct pipe_buffer;
+struct pipe_texture;
+struct pipe_surface;
+struct pipe_transfer;
+
boolean trace_dump_trace_begin(void);
boolean trace_dump_enabled(void);
void trace_dump_trace_end(void);
@@ -63,10 +68,14 @@ void trace_dump_member_begin(const char *name);
void trace_dump_member_end(void);
void trace_dump_null(void);
void trace_dump_ptr(const void *value);
-
+/* will turn a wrapped object into the real one and dump ptr */
+void trace_dump_buffer_ptr(struct pipe_buffer *_buffer);
+void trace_dump_texture_ptr(struct pipe_texture *_texture);
+void trace_dump_surface_ptr(struct pipe_surface *_surface);
+void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
/*
- * Code saving macros.
+ * Code saving macros.
*/
#define trace_dump_arg(_type, _arg) \
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 8789f86b1a..954576d721 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -27,12 +27,14 @@
#include "util/u_memory.h"
+#include "tr_buffer.h"
#include "tr_dump.h"
#include "tr_state.h"
-#include "tr_winsys.h"
#include "tr_texture.h"
#include "tr_screen.h"
+#include "pipe/p_inlines.h"
+
static const char *
trace_screen_get_name(struct pipe_screen *_screen)
@@ -40,17 +42,17 @@ trace_screen_get_name(struct pipe_screen *_screen)
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
const char *result;
-
+
trace_dump_call_begin("pipe_screen", "get_name");
-
+
trace_dump_arg(ptr, screen);
result = screen->get_name(screen);
-
+
trace_dump_ret(string, result);
-
+
trace_dump_call_end();
-
+
return result;
}
@@ -61,80 +63,80 @@ trace_screen_get_vendor(struct pipe_screen *_screen)
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
const char *result;
-
+
trace_dump_call_begin("pipe_screen", "get_vendor");
-
+
trace_dump_arg(ptr, screen);
-
+
result = screen->get_vendor(screen);
-
+
trace_dump_ret(string, result);
-
+
trace_dump_call_end();
-
+
return result;
}
-static int
-trace_screen_get_param(struct pipe_screen *_screen,
+static int
+trace_screen_get_param(struct pipe_screen *_screen,
int param)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
int result;
-
+
trace_dump_call_begin("pipe_screen", "get_param");
-
+
trace_dump_arg(ptr, screen);
trace_dump_arg(int, param);
result = screen->get_param(screen, param);
-
+
trace_dump_ret(int, result);
-
+
trace_dump_call_end();
-
+
return result;
}
-static float
-trace_screen_get_paramf(struct pipe_screen *_screen,
+static float
+trace_screen_get_paramf(struct pipe_screen *_screen,
int param)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
float result;
-
+
trace_dump_call_begin("pipe_screen", "get_paramf");
-
+
trace_dump_arg(ptr, screen);
trace_dump_arg(int, param);
result = screen->get_paramf(screen, param);
-
+
trace_dump_ret(float, result);
-
+
trace_dump_call_end();
-
+
return result;
}
-static boolean
+static boolean
trace_screen_is_format_supported(struct pipe_screen *_screen,
enum pipe_format format,
enum pipe_texture_target target,
- unsigned tex_usage,
+ unsigned tex_usage,
unsigned geom_flags)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
boolean result;
-
+
trace_dump_call_begin("pipe_screen", "is_format_supported");
-
+
trace_dump_arg(ptr, screen);
trace_dump_arg(format, format);
trace_dump_arg(int, target);
@@ -142,15 +144,45 @@ trace_screen_is_format_supported(struct pipe_screen *_screen,
trace_dump_arg(uint, geom_flags);
result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags);
-
+
trace_dump_ret(bool, result);
-
+
trace_dump_call_end();
-
+
return result;
}
+static void
+trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
+ struct pipe_surface *_surface,
+ void *context_private)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture);
+ struct trace_surface *tr_surf = trace_surface(tr_tex, _surface);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_surface *surface = tr_surf->surface;
+
+ trace_dump_call_begin("pipe_screen", "flush_frontbuffer");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, surface);
+ /* XXX: hide, as there is nothing we can do with this
+ trace_dump_arg(ptr, context_private);
+ */
+
+ screen->flush_frontbuffer(screen, surface, context_private);
+
+ trace_dump_call_end();
+}
+
+
+/********************************************************************
+ * texture
+ */
+
+
static struct pipe_texture *
trace_screen_texture_create(struct pipe_screen *_screen,
const struct pipe_texture *templat)
@@ -158,20 +190,20 @@ trace_screen_texture_create(struct pipe_screen *_screen,
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
struct pipe_texture *result;
-
+
trace_dump_call_begin("pipe_screen", "texture_create");
trace_dump_arg(ptr, screen);
trace_dump_arg(template, templat);
result = screen->texture_create(screen, templat);
-
+
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
result = trace_texture_create(tr_scr, result);
-
+
return result;
}
@@ -195,71 +227,60 @@ trace_screen_texture_blanket(struct pipe_screen *_screen,
trace_dump_arg(ptr, buffer);
result = screen->texture_blanket(screen, templat, ppitch, buffer);
-
+
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
result = trace_texture_create(tr_scr, result);
-
+
return result;
}
-static void
-trace_screen_texture_release(struct pipe_screen *_screen,
- struct pipe_texture **ptexture)
+static void
+trace_screen_texture_destroy(struct pipe_texture *_texture)
{
- struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_screen *tr_scr = trace_screen(_texture->screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _texture);
struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct pipe_texture *texture;
-
- assert(ptexture);
- if(*ptexture) {
- tr_tex = trace_texture(tr_scr, *ptexture);
- texture = tr_tex->texture;
- assert(texture->screen == screen);
- }
- else
- texture = NULL;
-
- if (*ptexture) {
- if (!--(*ptexture)->refcount) {
- trace_dump_call_begin("pipe_screen", "texture_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, texture);
-
- trace_texture_destroy(tr_scr, *ptexture);
-
- trace_dump_call_end();
- }
-
- *ptexture = NULL;
- }
+ struct pipe_texture *texture = tr_tex->texture;
+
+ assert(texture->screen == screen);
+
+ trace_dump_call_begin("pipe_screen", "texture_destroy");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, texture);
+
+ trace_dump_call_end();
+
+ trace_texture_destroy(tr_scr, _texture);
}
+/********************************************************************
+ * surface
+ */
+
+
static struct pipe_surface *
trace_screen_get_tex_surface(struct pipe_screen *_screen,
- struct pipe_texture *texture,
+ struct pipe_texture *_texture,
unsigned face, unsigned level,
unsigned zslice,
unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _texture);
struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct pipe_surface *result;
-
- assert(texture);
- tr_tex = trace_texture(tr_scr, texture);
- texture = tr_tex->texture;
+ struct pipe_texture *texture = tr_tex->texture;
+ struct pipe_surface *result = NULL;
+
assert(texture->screen == screen);
-
+
trace_dump_call_begin("pipe_screen", "get_tex_surface");
-
+
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, texture);
trace_dump_arg(uint, face);
@@ -270,133 +291,538 @@ trace_screen_get_tex_surface(struct pipe_screen *_screen,
result = screen->get_tex_surface(screen, texture, face, level, zslice, usage);
trace_dump_ret(ptr, result);
-
+
trace_dump_call_end();
-
+
result = trace_surface_create(tr_tex, result);
return result;
}
-static void
-trace_screen_tex_surface_release(struct pipe_screen *_screen,
- struct pipe_surface **psurface)
+static void
+trace_screen_tex_surface_destroy(struct pipe_surface *_surface)
+{
+ struct trace_screen *tr_scr = trace_screen(_surface->texture->screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture);
+ struct trace_surface *tr_surf = trace_surface(tr_tex, _surface);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_surface *surface = tr_surf->surface;
+
+ trace_dump_call_begin("pipe_screen", "tex_surface_destroy");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, surface);
+
+ trace_dump_call_end();
+
+ trace_surface_destroy(tr_tex, _surface);
+}
+
+
+/********************************************************************
+ * transfer
+ */
+
+
+static struct pipe_transfer *
+trace_screen_get_tex_transfer(struct pipe_screen *_screen,
+ struct pipe_texture *_texture,
+ unsigned face, unsigned level,
+ unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y, unsigned w, unsigned h)
{
struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _texture);
struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct trace_surface *tr_surf;
- struct pipe_surface *surface;
-
- assert(psurface);
- if(*psurface) {
- tr_tex = trace_texture(tr_scr, (*psurface)->texture);
- tr_surf = trace_surface(tr_tex, *psurface);
- surface = tr_surf->surface;
- }
- else
- surface = NULL;
-
- if (*psurface) {
- if (!--(*psurface)->refcount) {
- trace_dump_call_begin("pipe_screen", "tex_surface_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, surface);
+ struct pipe_texture *texture = tr_tex->texture;
+ struct pipe_transfer *result = NULL;
- trace_surface_destroy(tr_tex, *psurface);
+ assert(texture->screen == screen);
- trace_dump_call_end();
- }
-
- *psurface = NULL;
- }
+ trace_dump_call_begin("pipe_screen", "get_tex_transfer");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, texture);
+ trace_dump_arg(uint, face);
+ trace_dump_arg(uint, level);
+ trace_dump_arg(uint, zslice);
+ trace_dump_arg(uint, usage);
+
+ trace_dump_arg(uint, x);
+ trace_dump_arg(uint, y);
+ trace_dump_arg(uint, w);
+ trace_dump_arg(uint, h);
+
+ result = screen->get_tex_transfer(screen, texture, face, level, zslice, usage,
+ x, y, w, h);
+
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
+
+ result = trace_transfer_create(tr_tex, result);
+
+ return result;
+}
+
+
+static void
+trace_screen_tex_transfer_destroy(struct pipe_transfer *_transfer)
+{
+ struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture);
+ struct trace_transfer *tr_tran = trace_transfer(tr_tex, _transfer);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_transfer *transfer = tr_tran->transfer;
+
+ trace_dump_call_begin("pipe_screen", "tex_transfer_destroy");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, transfer);
+
+ trace_dump_call_end();
+
+ trace_transfer_destroy(tr_tex, _transfer);
}
static void *
-trace_screen_surface_map(struct pipe_screen *_screen,
- struct pipe_surface *surface,
- unsigned flags)
+trace_screen_transfer_map(struct pipe_screen *_screen,
+ struct pipe_transfer *_transfer)
{
struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture);
+ struct trace_transfer *tr_trans = trace_transfer(tr_tex, _transfer);
struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct trace_surface *tr_surf;
+ struct pipe_transfer *transfer = tr_trans->transfer;
void *map;
-
- tr_tex = trace_texture(tr_scr, surface->texture);
- tr_surf = trace_surface(tr_tex, surface);
- surface = tr_surf->surface;
- map = screen->surface_map(screen, surface, flags);
+ map = screen->transfer_map(screen, transfer);
if(map) {
- if(flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
- assert(!tr_surf->map);
- tr_surf->map = map;
+ if(transfer->usage != PIPE_TRANSFER_READ) {
+ assert(!tr_trans->map);
+ tr_trans->map = map;
}
}
-
+
return map;
}
-static void
-trace_screen_surface_unmap(struct pipe_screen *_screen,
- struct pipe_surface *surface)
+static void
+trace_screen_transfer_unmap(struct pipe_screen *_screen,
+ struct pipe_transfer *_transfer)
{
struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture);
+ struct trace_transfer *tr_trans = trace_transfer(tr_tex, _transfer);
struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct trace_surface *tr_surf;
-
- tr_tex = trace_texture(tr_scr, surface->texture);
- tr_surf = trace_surface(tr_tex, surface);
- surface = tr_surf->surface;
-
- if(tr_surf->map) {
- size_t size = surface->nblocksy * surface->stride;
-
- trace_dump_call_begin("pipe_winsys", "surface_write");
-
+ struct pipe_transfer *transfer = tr_trans->transfer;
+
+ if(tr_trans->map) {
+ size_t size = transfer->nblocksy * transfer->stride;
+
+ trace_dump_call_begin("pipe_screen", "transfer_write");
+
trace_dump_arg(ptr, screen);
-
- trace_dump_arg(ptr, surface);
-
- trace_dump_arg_begin("data");
- trace_dump_bytes(tr_surf->map, size);
- trace_dump_arg_end();
+
+ trace_dump_arg(ptr, transfer);
trace_dump_arg_begin("stride");
- trace_dump_uint(surface->stride);
+ trace_dump_uint(transfer->stride);
+ trace_dump_arg_end();
+
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(tr_trans->map, size);
trace_dump_arg_end();
trace_dump_arg_begin("size");
trace_dump_uint(size);
trace_dump_arg_end();
-
+
trace_dump_call_end();
- tr_surf->map = NULL;
+ tr_trans->map = NULL;
+ }
+
+ screen->transfer_unmap(screen, transfer);
+}
+
+
+/********************************************************************
+ * buffer
+ */
+
+
+static struct pipe_buffer *
+trace_screen_surface_buffer_create(struct pipe_screen *_screen,
+ unsigned width, unsigned height,
+ enum pipe_format format,
+ unsigned usage,
+ unsigned *pstride)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ unsigned stride;
+ struct pipe_buffer *result;
+
+ trace_dump_call_begin("pipe_screen", "surface_buffer_create");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(uint, width);
+ trace_dump_arg(uint, height);
+ trace_dump_arg(format, format);
+ trace_dump_arg(uint, usage);
+
+ result = screen->surface_buffer_create(screen,
+ width, height,
+ format,
+ usage,
+ pstride);
+
+ stride = *pstride;
+
+ trace_dump_arg(uint, stride);
+
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
+
+ return trace_buffer_create(tr_scr, result);
+}
+
+
+static struct pipe_buffer *
+trace_screen_buffer_create(struct pipe_screen *_screen,
+ unsigned alignment,
+ unsigned usage,
+ unsigned size)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *result;
+
+ trace_dump_call_begin("pipe_screen", "buffer_create");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(uint, alignment);
+ trace_dump_arg(uint, usage);
+ trace_dump_arg(uint, size);
+
+ result = screen->buffer_create(screen, alignment, usage, size);
+
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
+
+ /* Zero the buffer to avoid dumping uninitialized memory */
+ if(result->usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
+ void *map;
+ map = pipe_buffer_map(screen, result, PIPE_BUFFER_USAGE_CPU_WRITE);
+ if(map) {
+ memset(map, 0, result->size);
+ screen->buffer_unmap(screen, result);
+ }
+ }
+
+ return trace_buffer_create(tr_scr, result);
+}
+
+
+static struct pipe_buffer *
+trace_screen_user_buffer_create(struct pipe_screen *_screen,
+ void *data,
+ unsigned size)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *result;
+
+ trace_dump_call_begin("pipe_screen", "user_buffer_create");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(data, size);
+ trace_dump_arg_end();
+ trace_dump_arg(uint, size);
+
+ result = screen->user_buffer_create(screen, data, size);
+
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
+
+ if(result) {
+ assert(!(result->usage & TRACE_BUFFER_USAGE_USER));
+ result->usage |= TRACE_BUFFER_USAGE_USER;
+ }
+
+ return trace_buffer_create(tr_scr, result);
+}
+
+
+/**
+ * This function is used to track if data has been changed on a user buffer
+ * without map/unmap being called.
+ */
+void
+trace_screen_user_buffer_update(struct pipe_screen *_screen,
+ struct pipe_buffer *_buffer)
+{
+#if 0
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ const void *map;
+
+ if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) {
+ map = screen->buffer_map(screen, buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ if(map) {
+ trace_dump_call_begin("pipe_winsys", "buffer_write");
+
+ trace_dump_arg(ptr, screen);
+
+ trace_dump_arg(ptr, buffer);
+
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(map, buffer->size);
+ trace_dump_arg_end();
+
+ trace_dump_arg_begin("size");
+ trace_dump_uint(buffer->size);
+ trace_dump_arg_end();
+
+ trace_dump_call_end();
+
+ screen->buffer_unmap(screen, buffer);
+ }
+ }
+#endif
+}
+
+
+static void *
+trace_screen_buffer_map(struct pipe_screen *_screen,
+ struct pipe_buffer *_buffer,
+ unsigned usage)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
+ void *map;
+
+ assert(screen->buffer_map);
+ map = screen->buffer_map(screen, buffer, usage);
+ if(map) {
+ if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
+ tr_buf->map = map;
+ }
+ }
+
+ return map;
+}
+
+
+static void *
+trace_screen_buffer_map_range(struct pipe_screen *_screen,
+ struct pipe_buffer *_buffer,
+ unsigned offset,
+ unsigned length,
+ unsigned usage)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
+ void *map;
+
+ assert(screen->buffer_map_range);
+ map = screen->buffer_map_range(screen, buffer, offset, length, usage);
+ if(map) {
+ if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
+ tr_buf->map = map;
+ }
}
- screen->surface_unmap(screen, surface);
+ return map;
+}
+
+
+static void
+buffer_write(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned offset,
+ const char *map,
+ unsigned size)
+{
+ assert(map);
+
+ trace_dump_call_begin("pipe_screen", "buffer_write");
+
+ trace_dump_arg(ptr, screen);
+
+ trace_dump_arg(ptr, buffer);
+
+ trace_dump_arg(uint, offset);
+
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(map + offset, size);
+ trace_dump_arg_end();
+
+ trace_dump_arg(uint, size);
+
+ trace_dump_call_end();
+
+}
+
+
+static void
+trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen,
+ struct pipe_buffer *_buffer,
+ unsigned offset,
+ unsigned length)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
+
+ assert(tr_buf->map);
+ buffer_write(screen, buffer, offset, tr_buf->map, length);
+ tr_buf->range_flushed = TRUE;
+ screen->buffer_flush_mapped_range(screen, buffer, offset, length);
+}
+
+
+static void
+trace_screen_buffer_unmap(struct pipe_screen *_screen,
+ struct pipe_buffer *_buffer)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
+
+ if (tr_buf->map && !tr_buf->range_flushed)
+ buffer_write(screen, buffer, tr_buf->map, 0, buffer->size);
+ tr_buf->map = NULL;
+ tr_buf->range_flushed = FALSE;
+ screen->buffer_unmap(screen, buffer);
+}
+
+
+static void
+trace_screen_buffer_destroy(struct pipe_buffer *_buffer)
+{
+ struct trace_screen *tr_scr = trace_screen(_buffer->screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
+ struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
+
+ trace_dump_call_begin("pipe_screen", "buffer_destroy");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, buffer);
+
+ trace_dump_call_end();
+
+ trace_buffer_destroy(tr_scr, _buffer);
+}
+
+
+/********************************************************************
+ * fence
+ */
+
+
+static void
+trace_screen_fence_reference(struct pipe_screen *_screen,
+ struct pipe_fence_handle **dst,
+ struct pipe_fence_handle *src)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+
+ trace_dump_call_begin("pipe_screen", "fence_reference");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, dst);
+ trace_dump_arg(ptr, src);
+
+ screen->fence_reference(screen, dst, src);
+
+ trace_dump_call_end();
+}
+
+
+static int
+trace_screen_fence_signalled(struct pipe_screen *_screen,
+ struct pipe_fence_handle *fence,
+ unsigned flag)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ int result;
+
+ trace_dump_call_begin("pipe_screen", "fence_signalled");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, fence);
+ trace_dump_arg(uint, flag);
+
+ result = screen->fence_signalled(screen, fence, flag);
+
+ trace_dump_ret(int, result);
+
+ trace_dump_call_end();
+
+ return result;
}
+static int
+trace_screen_fence_finish(struct pipe_screen *_screen,
+ struct pipe_fence_handle *fence,
+ unsigned flag)
+{
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct pipe_screen *screen = tr_scr->screen;
+ int result;
+
+ trace_dump_call_begin("pipe_screen", "fence_finish");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, fence);
+ trace_dump_arg(uint, flag);
+
+ result = screen->fence_finish(screen, fence, flag);
+
+ trace_dump_ret(int, result);
+
+ trace_dump_call_end();
+
+ return result;
+}
+
+
+/********************************************************************
+ * screen
+ */
+
static void
trace_screen_destroy(struct pipe_screen *_screen)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
-
+
trace_dump_call_begin("pipe_screen", "destroy");
-
+
trace_dump_arg(ptr, screen);
screen->destroy(screen);
-
+
trace_dump_call_end();
trace_dump_trace_end();
@@ -410,21 +836,27 @@ trace_screen_create(struct pipe_screen *screen)
{
struct trace_screen *tr_scr;
struct pipe_winsys *winsys;
-
+
if(!screen)
goto error1;
if(!trace_dump_trace_begin())
goto error1;
+ trace_dump_call_begin("", "pipe_screen_create");
+
tr_scr = CALLOC_STRUCT(trace_screen);
if(!tr_scr)
goto error2;
+#if 0
winsys = trace_winsys_create(screen->winsys);
if(!winsys)
goto error3;
-
+#else
+ winsys = screen->winsys;
+#endif
+
tr_scr->base.winsys = winsys;
tr_scr->base.destroy = trace_screen_destroy;
tr_scr->base.get_name = trace_screen_get_name;
@@ -434,26 +866,43 @@ trace_screen_create(struct pipe_screen *screen)
tr_scr->base.is_format_supported = trace_screen_is_format_supported;
tr_scr->base.texture_create = trace_screen_texture_create;
tr_scr->base.texture_blanket = trace_screen_texture_blanket;
- tr_scr->base.texture_release = trace_screen_texture_release;
+ tr_scr->base.texture_destroy = trace_screen_texture_destroy;
tr_scr->base.get_tex_surface = trace_screen_get_tex_surface;
- tr_scr->base.tex_surface_release = trace_screen_tex_surface_release;
- tr_scr->base.surface_map = trace_screen_surface_map;
- tr_scr->base.surface_unmap = trace_screen_surface_unmap;
-
+ tr_scr->base.tex_surface_destroy = trace_screen_tex_surface_destroy;
+ tr_scr->base.get_tex_transfer = trace_screen_get_tex_transfer;
+ tr_scr->base.tex_transfer_destroy = trace_screen_tex_transfer_destroy;
+ tr_scr->base.transfer_map = trace_screen_transfer_map;
+ tr_scr->base.transfer_unmap = trace_screen_transfer_unmap;
+ tr_scr->base.buffer_create = trace_screen_buffer_create;
+ tr_scr->base.user_buffer_create = trace_screen_user_buffer_create;
+ tr_scr->base.surface_buffer_create = trace_screen_surface_buffer_create;
+ if (screen->buffer_map)
+ tr_scr->base.buffer_map = trace_screen_buffer_map;
+ if (screen->buffer_map_range)
+ tr_scr->base.buffer_map_range = trace_screen_buffer_map_range;
+ if (screen->buffer_flush_mapped_range)
+ tr_scr->base.buffer_flush_mapped_range = trace_screen_buffer_flush_mapped_range;
+ if (screen->buffer_unmap)
+ tr_scr->base.buffer_unmap = trace_screen_buffer_unmap;
+ tr_scr->base.buffer_destroy = trace_screen_buffer_destroy;
+ tr_scr->base.fence_reference = trace_screen_fence_reference;
+ tr_scr->base.fence_signalled = trace_screen_fence_signalled;
+ tr_scr->base.fence_finish = trace_screen_fence_finish;
+ tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer;
tr_scr->screen = screen;
- trace_dump_call_begin("", "pipe_screen_create");
- trace_dump_arg_begin("winsys");
- trace_dump_ptr(screen->winsys);
- trace_dump_arg_end();
trace_dump_ret(ptr, screen);
trace_dump_call_end();
return &tr_scr->base;
+#if 0
error3:
FREE(tr_scr);
+#endif
error2:
+ trace_dump_ret(ptr, screen);
+ trace_dump_call_end();
trace_dump_trace_end();
error1:
return screen;
diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h
index 93fefdb9a5..8c65516b50 100644
--- a/src/gallium/drivers/trace/tr_screen.h
+++ b/src/gallium/drivers/trace/tr_screen.h
@@ -36,11 +36,19 @@
extern "C" {
#endif
-
+
+/**
+ * It often happens that new data is written directly to the user buffers
+ * without mapping/unmapping. This flag marks user buffers, so that their
+ * contents can be dumpped before being used by the pipe context.
+ */
+#define TRACE_BUFFER_USAGE_USER (1 << 31)
+
+
struct trace_screen
{
struct pipe_screen base;
-
+
struct pipe_screen *screen;
};
@@ -53,6 +61,11 @@ struct pipe_screen *
trace_screen_create(struct pipe_screen *screen);
+void
+trace_screen_user_buffer_update(struct pipe_screen *screen,
+ struct pipe_buffer *buffer);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c
index 524f2d6194..b6a1ce0d62 100644
--- a/src/gallium/drivers/trace/tr_state.c
+++ b/src/gallium/drivers/trace/tr_state.c
@@ -50,6 +50,14 @@ void trace_dump_block(const struct pipe_format_block *block)
}
+static void trace_dump_reference(const struct pipe_reference *reference)
+{
+ trace_dump_struct_begin("pipe_reference");
+ trace_dump_member(int, &reference->count, count);
+ trace_dump_struct_end();
+}
+
+
void trace_dump_template(const struct pipe_texture *templat)
{
if(!templat) {
@@ -58,10 +66,10 @@ void trace_dump_template(const struct pipe_texture *templat)
}
trace_dump_struct_begin("pipe_texture");
-
+
trace_dump_member(int, templat, target);
trace_dump_member(format, templat, format);
-
+
trace_dump_member_begin("width");
trace_dump_array(uint, templat->width, 1);
trace_dump_member_end();
@@ -77,10 +85,10 @@ void trace_dump_template(const struct pipe_texture *templat)
trace_dump_member_begin("block");
trace_dump_block(&templat->block);
trace_dump_member_end();
-
+
trace_dump_member(uint, templat, last_level);
trace_dump_member(uint, templat, tex_usage);
-
+
trace_dump_struct_end();
}
@@ -114,8 +122,7 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
trace_dump_member(uint, state, line_stipple_factor);
trace_dump_member(uint, state, line_stipple_pattern);
trace_dump_member(bool, state, line_last_pixel);
- trace_dump_member(bool, state, bypass_clipping);
- trace_dump_member(bool, state, bypass_vs);
+ trace_dump_member(bool, state, bypass_vs_clip_and_viewport);
trace_dump_member(bool, state, origin_lower_left);
trace_dump_member(bool, state, flatshade_first);
trace_dump_member(bool, state, gl_rasterization_rules);
@@ -126,9 +133,9 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
trace_dump_member(float, state, point_size_max);
trace_dump_member(float, state, offset_units);
trace_dump_member(float, state, offset_scale);
-
+
trace_dump_member_array(uint, state, sprite_coord_mode);
-
+
trace_dump_struct_end();
}
@@ -144,10 +151,10 @@ void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
trace_dump_member_begin("stipple");
trace_dump_array(uint,
- state->stipple,
+ state->stipple,
Elements(state->stipple));
trace_dump_member_end();
-
+
trace_dump_struct_end();
}
@@ -163,7 +170,7 @@ void trace_dump_viewport_state(const struct pipe_viewport_state *state)
trace_dump_member_array(float, state, scale);
trace_dump_member_array(float, state, translate);
-
+
trace_dump_struct_end();
}
@@ -189,7 +196,7 @@ void trace_dump_scissor_state(const struct pipe_scissor_state *state)
void trace_dump_clip_state(const struct pipe_clip_state *state)
{
unsigned i;
-
+
if(!state) {
trace_dump_null();
return;
@@ -222,7 +229,7 @@ void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
trace_dump_struct_begin("pipe_constant_buffer");
- trace_dump_member(ptr, state, buffer);
+ trace_dump_member(buffer_ptr, state, buffer);
trace_dump_struct_end();
}
@@ -238,7 +245,7 @@ void trace_dump_shader_state(const struct pipe_shader_state *state)
}
tgsi_dump_str(state->tokens, 0, str, sizeof(str));
-
+
trace_dump_struct_begin("pipe_shader_state");
trace_dump_member_begin("tokens");
@@ -252,7 +259,7 @@ void trace_dump_shader_state(const struct pipe_shader_state *state)
void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
{
unsigned i;
-
+
if(!state) {
trace_dump_null();
return;
@@ -268,7 +275,7 @@ void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_
trace_dump_member(bool, &state->depth, occlusion_count);
trace_dump_struct_end();
trace_dump_member_end();
-
+
trace_dump_member_begin("stencil");
trace_dump_array_begin();
for(i = 0; i < Elements(state->stencil); ++i) {
@@ -397,22 +404,47 @@ void trace_dump_surface(const struct pipe_surface *state)
trace_dump_struct_begin("pipe_surface");
+ trace_dump_reference(&state->reference);
+
trace_dump_member(format, state, format);
trace_dump_member(uint, state, status);
trace_dump_member(uint, state, clear_value);
trace_dump_member(uint, state, width);
trace_dump_member(uint, state, height);
+ trace_dump_member(uint, state, layout);
+ trace_dump_member(uint, state, offset);
+ trace_dump_member(uint, state, usage);
+
+ trace_dump_member(ptr, state, texture);
+ trace_dump_member(uint, state, face);
+ trace_dump_member(uint, state, level);
+ trace_dump_member(uint, state, zslice);
+
+ trace_dump_struct_end();
+}
+
+
+void trace_dump_transfer(const struct pipe_transfer *state)
+{
+ if(!state) {
+ trace_dump_null();
+ return;
+ }
+
+ trace_dump_struct_begin("pipe_transfer");
+
+ trace_dump_member(format, state, format);
+ trace_dump_member(uint, state, width);
+ trace_dump_member(uint, state, height);
+
trace_dump_member_begin("block");
trace_dump_block(&state->block);
trace_dump_member_end();
-
+
trace_dump_member(uint, state, nblocksx);
trace_dump_member(uint, state, nblocksy);
trace_dump_member(uint, state, stride);
- trace_dump_member(uint, state, layout);
- trace_dump_member(uint, state, offset);
- trace_dump_member(uint, state, refcount);
trace_dump_member(uint, state, usage);
trace_dump_member(ptr, state, texture);
@@ -436,7 +468,7 @@ void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
trace_dump_member(uint, state, stride);
trace_dump_member(uint, state, max_index);
trace_dump_member(uint, state, buffer_offset);
- trace_dump_member(ptr, state, buffer);
+ trace_dump_member(buffer_ptr, state, buffer);
trace_dump_struct_end();
}
@@ -455,7 +487,7 @@ void trace_dump_vertex_element(const struct pipe_vertex_element *state)
trace_dump_member(uint, state, vertex_buffer_index);
trace_dump_member(uint, state, nr_components);
-
+
trace_dump_member(format, state, src_format);
trace_dump_struct_end();
diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h
index 5ae533dc66..513ed0ac98 100644
--- a/src/gallium/drivers/trace/tr_state.h
+++ b/src/gallium/drivers/trace/tr_state.h
@@ -68,6 +68,8 @@ void trace_dump_sampler_state(const struct pipe_sampler_state *state);
void trace_dump_surface(const struct pipe_surface *state);
+void trace_dump_transfer(const struct pipe_transfer *state);
+
void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state);
void trace_dump_vertex_element(const struct pipe_vertex_element *state);
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
index 1cc4f0bd43..7b392f0728 100644
--- a/src/gallium/drivers/trace/tr_texture.c
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -25,7 +25,6 @@
*
**************************************************************************/
-#include "pipe/p_inlines.h"
#include "util/u_hash_table.h"
#include "util/u_memory.h"
@@ -34,26 +33,28 @@
struct pipe_texture *
-trace_texture_create(struct trace_screen *tr_scr,
+trace_texture_create(struct trace_screen *tr_scr,
struct pipe_texture *texture)
{
struct trace_texture *tr_tex;
-
+
if(!texture)
goto error;
-
+
assert(texture->screen == tr_scr->screen);
-
+
tr_tex = CALLOC_STRUCT(trace_texture);
if(!tr_tex)
goto error;
-
+
memcpy(&tr_tex->base, texture, sizeof(struct pipe_texture));
+
+ pipe_reference_init(&tr_tex->base.reference, 1);
tr_tex->base.screen = &tr_scr->base;
tr_tex->texture = texture;
-
+
return &tr_tex->base;
-
+
error:
pipe_texture_reference(&texture, NULL);
return NULL;
@@ -61,38 +62,39 @@ error:
void
-trace_texture_destroy(struct trace_screen *tr_scr,
+trace_texture_destroy(struct trace_screen *tr_scr,
struct pipe_texture *texture)
{
- struct trace_texture *tr_tex = trace_texture(tr_scr, texture);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, texture);
pipe_texture_reference(&tr_tex->texture, NULL);
FREE(tr_tex);
}
struct pipe_surface *
-trace_surface_create(struct trace_texture *tr_tex,
+trace_surface_create(struct trace_texture *tr_tex,
struct pipe_surface *surface)
{
struct trace_surface *tr_surf;
-
+
if(!surface)
goto error;
-
+
assert(surface->texture == tr_tex->texture);
-
+
tr_surf = CALLOC_STRUCT(trace_surface);
if(!tr_surf)
goto error;
-
+
memcpy(&tr_surf->base, surface, sizeof(struct pipe_surface));
-
+
+ pipe_reference_init(&tr_surf->base.reference, 1);
tr_surf->base.texture = NULL;
pipe_texture_reference(&tr_surf->base.texture, &tr_tex->base);
tr_surf->surface = surface;
return &tr_surf->base;
-
+
error:
pipe_surface_reference(&surface, NULL);
return NULL;
@@ -100,7 +102,7 @@ error:
void
-trace_surface_destroy(struct trace_texture *tr_tex,
+trace_surface_destroy(struct trace_texture *tr_tex,
struct pipe_surface *surface)
{
struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
@@ -109,3 +111,45 @@ trace_surface_destroy(struct trace_texture *tr_tex,
FREE(tr_surf);
}
+
+struct pipe_transfer *
+trace_transfer_create(struct trace_texture *tr_tex,
+ struct pipe_transfer *transfer)
+{
+ struct trace_transfer *tr_trans;
+
+ if(!transfer)
+ goto error;
+
+ assert(transfer->texture == tr_tex->texture);
+
+ tr_trans = CALLOC_STRUCT(trace_transfer);
+ if(!tr_trans)
+ goto error;
+
+ memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer));
+
+ tr_trans->base.texture = NULL;
+ pipe_texture_reference(&tr_trans->base.texture, &tr_tex->base);
+ tr_trans->transfer = transfer;
+ assert(tr_trans->base.texture == &tr_tex->base);
+
+ return &tr_trans->base;
+
+error:
+ transfer->texture->screen->tex_transfer_destroy(transfer);
+ return NULL;
+}
+
+
+void
+trace_transfer_destroy(struct trace_texture *tr_tex,
+ struct pipe_transfer *transfer)
+{
+ struct trace_transfer *tr_trans = trace_transfer(tr_tex, transfer);
+ struct pipe_screen *screen = tr_trans->transfer->texture->screen;
+ pipe_texture_reference(&tr_trans->base.texture, NULL);
+ screen->tex_transfer_destroy(tr_trans->transfer);
+ FREE(tr_trans);
+}
+
diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h
index 9e72edb8a3..9c21bc7d27 100644
--- a/src/gallium/drivers/trace/tr_texture.h
+++ b/src/gallium/drivers/trace/tr_texture.h
@@ -48,48 +48,78 @@ struct trace_surface
struct pipe_surface base;
struct pipe_surface *surface;
-
+};
+
+
+struct trace_transfer
+{
+ struct pipe_transfer base;
+
+ struct pipe_transfer *transfer;
+
void *map;
};
static INLINE struct trace_texture *
-trace_texture(struct trace_screen *tr_scr,
+trace_texture(struct trace_screen *tr_scr,
struct pipe_texture *texture)
{
if(!texture)
return NULL;
+ assert(tr_scr);
assert(texture->screen == &tr_scr->base);
return (struct trace_texture *)texture;
}
static INLINE struct trace_surface *
-trace_surface(struct trace_texture *tr_tex,
+trace_surface(struct trace_texture *tr_tex,
struct pipe_surface *surface)
{
if(!surface)
return NULL;
+ assert(tr_tex);
assert(surface->texture == &tr_tex->base);
return (struct trace_surface *)surface;
}
+static INLINE struct trace_transfer *
+trace_transfer(struct trace_texture *tr_tex,
+ struct pipe_transfer *transfer)
+{
+ if(!transfer)
+ return NULL;
+ assert(tr_tex);
+ assert(transfer->texture == &tr_tex->base);
+ return (struct trace_transfer *)transfer;
+}
+
+
struct pipe_texture *
-trace_texture_create(struct trace_screen *tr_scr,
+trace_texture_create(struct trace_screen *tr_scr,
struct pipe_texture *texture);
void
-trace_texture_destroy(struct trace_screen *tr_scr,
+trace_texture_destroy(struct trace_screen *tr_scr,
struct pipe_texture *texture);
struct pipe_surface *
-trace_surface_create(struct trace_texture *tr_tex,
+trace_surface_create(struct trace_texture *tr_tex,
struct pipe_surface *surface);
void
trace_surface_destroy(struct trace_texture *tr_tex,
struct pipe_surface *surface);
+struct pipe_transfer *
+trace_transfer_create(struct trace_texture *tr_tex,
+ struct pipe_transfer *transfer);
+
+void
+trace_transfer_destroy(struct trace_texture *tr_tex,
+ struct pipe_transfer *transfer);
+
#endif /* TR_TEXTURE_H_ */
diff --git a/src/gallium/drivers/trace/tr_winsys.c b/src/gallium/drivers/trace/tr_winsys.c
deleted file mode 100644
index c4148fe810..0000000000
--- a/src/gallium/drivers/trace/tr_winsys.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "util/u_memory.h"
-#include "util/u_hash_table.h"
-
-#include "tr_dump.h"
-#include "tr_state.h"
-#include "tr_screen.h"
-#include "tr_texture.h"
-#include "tr_winsys.h"
-
-
-static unsigned trace_buffer_hash(void *buffer)
-{
- return (unsigned)(uintptr_t)buffer;
-}
-
-
-static int trace_buffer_compare(void *buffer1, void *buffer2)
-{
- return (char *)buffer2 - (char *)buffer1;
-}
-
-
-static const char *
-trace_winsys_get_name(struct pipe_winsys *_winsys)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- const char *result;
-
- trace_dump_call_begin("pipe_winsys", "get_name");
-
- trace_dump_arg(ptr, winsys);
-
- result = winsys->get_name(winsys);
-
- trace_dump_ret(string, result);
-
- trace_dump_call_end();
-
- return result;
-}
-
-
-static void
-trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys,
- struct pipe_surface *surface,
- void *context_private)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
-
- assert(surface);
- if(surface->texture) {
- struct trace_screen *tr_scr = trace_screen(surface->texture->screen);
- struct trace_texture *tr_tex = trace_texture(tr_scr, surface->texture);
- struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
- surface = tr_surf->surface;
- }
-
- trace_dump_call_begin("pipe_winsys", "flush_frontbuffer");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg(ptr, surface);
- /* XXX: hide, as there is nothing we can do with this
- trace_dump_arg(ptr, context_private);
- */
-
- winsys->flush_frontbuffer(winsys, surface, context_private);
-
- trace_dump_call_end();
-}
-
-
-static struct pipe_buffer *
-trace_winsys_surface_buffer_create(struct pipe_winsys *_winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned *pstride)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- unsigned stride;
- struct pipe_buffer *result;
-
- trace_dump_call_begin("pipe_winsys", "surface_buffer_create");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg(uint, width);
- trace_dump_arg(uint, height);
- trace_dump_arg(format, format);
- trace_dump_arg(uint, usage);
-
- result = winsys->surface_buffer_create(winsys,
- width, height,
- format,
- usage,
- pstride);
-
- stride = *pstride;
-
- trace_dump_arg(uint, stride);
-
- trace_dump_ret(ptr, result);
-
- trace_dump_call_end();
-
- return result;
-}
-
-
-static struct pipe_buffer *
-trace_winsys_buffer_create(struct pipe_winsys *_winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- struct pipe_buffer *buffer;
-
- trace_dump_call_begin("pipe_winsys", "buffer_create");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg(uint, alignment);
- trace_dump_arg(uint, usage);
- trace_dump_arg(uint, size);
-
- buffer = winsys->buffer_create(winsys, alignment, usage, size);
-
- trace_dump_ret(ptr, buffer);
-
- trace_dump_call_end();
-
- /* Zero the buffer to avoid dumping uninitialized memory */
- if(buffer->usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
- void *map;
- map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
- if(map) {
- memset(map, 0, buffer->size);
- winsys->buffer_unmap(winsys, buffer);
- }
- }
-
- return buffer;
-}
-
-
-static struct pipe_buffer *
-trace_winsys_user_buffer_create(struct pipe_winsys *_winsys,
- void *data,
- unsigned size)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- struct pipe_buffer *result;
-
- trace_dump_call_begin("pipe_winsys", "user_buffer_create");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg_begin("data");
- trace_dump_bytes(data, size);
- trace_dump_arg_end();
- trace_dump_arg(uint, size);
-
- result = winsys->user_buffer_create(winsys, data, size);
-
- trace_dump_ret(ptr, result);
-
- trace_dump_call_end();
-
- /* XXX: Mark the user buffers. (we should wrap pipe_buffers, but is is
- * impossible to do so while texture-less surfaces are still around */
- if(result) {
- assert(!(result->usage & TRACE_BUFFER_USAGE_USER));
- result->usage |= TRACE_BUFFER_USAGE_USER;
- }
-
- return result;
-}
-
-
-void
-trace_winsys_user_buffer_update(struct pipe_winsys *_winsys,
- struct pipe_buffer *buffer)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- const void *map;
-
- if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) {
- map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_READ);
- if(map) {
- trace_dump_call_begin("pipe_winsys", "buffer_write");
-
- trace_dump_arg(ptr, winsys);
-
- trace_dump_arg(ptr, buffer);
-
- trace_dump_arg_begin("data");
- trace_dump_bytes(map, buffer->size);
- trace_dump_arg_end();
-
- trace_dump_arg_begin("size");
- trace_dump_uint(buffer->size);
- trace_dump_arg_end();
-
- trace_dump_call_end();
-
- winsys->buffer_unmap(winsys, buffer);
- }
- }
-}
-
-
-static void *
-trace_winsys_buffer_map(struct pipe_winsys *_winsys,
- struct pipe_buffer *buffer,
- unsigned usage)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- void *map;
-
- map = winsys->buffer_map(winsys, buffer, usage);
- if(map) {
- if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
- assert(!hash_table_get(tr_ws->buffer_maps, buffer));
- hash_table_set(tr_ws->buffer_maps, buffer, map);
- }
- }
-
- return map;
-}
-
-
-static void
-trace_winsys_buffer_unmap(struct pipe_winsys *_winsys,
- struct pipe_buffer *buffer)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- const void *map;
-
- map = hash_table_get(tr_ws->buffer_maps, buffer);
- if(map) {
- trace_dump_call_begin("pipe_winsys", "buffer_write");
-
- trace_dump_arg(ptr, winsys);
-
- trace_dump_arg(ptr, buffer);
-
- trace_dump_arg_begin("data");
- trace_dump_bytes(map, buffer->size);
- trace_dump_arg_end();
-
- trace_dump_arg_begin("size");
- trace_dump_uint(buffer->size);
- trace_dump_arg_end();
-
- trace_dump_call_end();
-
- hash_table_remove(tr_ws->buffer_maps, buffer);
- }
-
- winsys->buffer_unmap(winsys, buffer);
-}
-
-
-static void
-trace_winsys_buffer_destroy(struct pipe_winsys *_winsys,
- struct pipe_buffer *buffer)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
-
- trace_dump_call_begin("pipe_winsys", "buffer_destroy");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg(ptr, buffer);
-
- winsys->buffer_destroy(winsys, buffer);
-
- trace_dump_call_end();
-}
-
-
-static void
-trace_winsys_fence_reference(struct pipe_winsys *_winsys,
- struct pipe_fence_handle **pdst,
- struct pipe_fence_handle *src)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- struct pipe_fence_handle *dst = *pdst;
-
- trace_dump_call_begin("pipe_winsys", "fence_reference");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg(ptr, dst);
- trace_dump_arg(ptr, src);
-
- winsys->fence_reference(winsys, pdst, src);
-
- trace_dump_call_end();
-}
-
-
-static int
-trace_winsys_fence_signalled(struct pipe_winsys *_winsys,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- int result;
-
- trace_dump_call_begin("pipe_winsys", "fence_signalled");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg(ptr, fence);
- trace_dump_arg(uint, flag);
-
- result = winsys->fence_signalled(winsys, fence, flag);
-
- trace_dump_ret(int, result);
-
- trace_dump_call_end();
-
- return result;
-}
-
-
-static int
-trace_winsys_fence_finish(struct pipe_winsys *_winsys,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- int result;
-
- trace_dump_call_begin("pipe_winsys", "fence_finish");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg(ptr, fence);
- trace_dump_arg(uint, flag);
-
- result = winsys->fence_finish(winsys, fence, flag);
-
- trace_dump_ret(int, result);
-
- trace_dump_call_end();
-
- return result;
-}
-
-
-static void
-trace_winsys_destroy(struct pipe_winsys *_winsys)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
-
- trace_dump_call_begin("pipe_winsys", "destroy");
-
- trace_dump_arg(ptr, winsys);
-
- /*
- winsys->destroy(winsys);
- */
-
- trace_dump_call_end();
-
- hash_table_destroy(tr_ws->buffer_maps);
-
- FREE(tr_ws);
-}
-
-
-struct pipe_winsys *
-trace_winsys_create(struct pipe_winsys *winsys)
-{
- struct trace_winsys *tr_ws;
-
- if(!winsys)
- goto error1;
-
- tr_ws = CALLOC_STRUCT(trace_winsys);
- if(!tr_ws)
- goto error1;
-
- tr_ws->base.destroy = trace_winsys_destroy;
- tr_ws->base.get_name = trace_winsys_get_name;
- tr_ws->base.flush_frontbuffer = trace_winsys_flush_frontbuffer;
- tr_ws->base.surface_buffer_create = trace_winsys_surface_buffer_create;
- tr_ws->base.buffer_create = trace_winsys_buffer_create;
- tr_ws->base.user_buffer_create = trace_winsys_user_buffer_create;
- tr_ws->base.buffer_map = trace_winsys_buffer_map;
- tr_ws->base.buffer_unmap = trace_winsys_buffer_unmap;
- tr_ws->base.buffer_destroy = trace_winsys_buffer_destroy;
- tr_ws->base.fence_reference = trace_winsys_fence_reference;
- tr_ws->base.fence_signalled = trace_winsys_fence_signalled;
- tr_ws->base.fence_finish = trace_winsys_fence_finish;
-
- tr_ws->winsys = winsys;
-
- tr_ws->buffer_maps = hash_table_create(trace_buffer_hash,
- trace_buffer_compare);
- if(!tr_ws->buffer_maps)
- goto error2;
-
- trace_dump_call_begin("", "pipe_winsys_create");
- trace_dump_ret(ptr, winsys);
- trace_dump_call_end();
-
- return &tr_ws->base;
-
-error2:
- FREE(tr_ws);
-error1:
- return winsys;
-}
diff --git a/src/gallium/include/pipe/internal/p_winsys_screen.h b/src/gallium/include/pipe/internal/p_winsys_screen.h
index ee835578b2..f4a29e63c7 100644
--- a/src/gallium/include/pipe/internal/p_winsys_screen.h
+++ b/src/gallium/include/pipe/internal/p_winsys_screen.h
@@ -68,6 +68,11 @@ struct pipe_winsys
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.
*/
@@ -149,8 +154,7 @@ struct pipe_winsys
void (*buffer_unmap)( struct pipe_winsys *ws,
struct pipe_buffer *buf );
- void (*buffer_destroy)( struct pipe_winsys *ws,
- struct pipe_buffer *buf );
+ void (*buffer_destroy)( struct pipe_buffer *buf );
/** Set ptr = fence, with reference counting */
diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h
new file mode 100644
index 0000000000..f2fe083efa
--- /dev/null
+++ b/src/gallium/include/pipe/p_atomic.h
@@ -0,0 +1,382 @@
+/**
+ * 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.
+ */
+#define PIPE_ATOMIC_OS_UNLOCKED \
+ (defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \
+ defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT))
+
+#define PIPE_ATOMIC_OS_MS_INTERLOCK \
+ (!defined(PIPE_CC_GCC) && \
+ !PIPE_ATOMIC_OS_UNLOCKED && \
+ defined(PIPE_SUBSYSTEM_WINDOWS_USER))
+
+#define PIPE_ATOMIC_OS_PROVIDED \
+ (PIPE_ATOMIC_OS_UNLOCKED || \
+ PIPE_ATOMIC_OS_MS_INTERLOCK)
+
+/* Where no OS-provided implementation is available, fall back to
+ * either locally coded assembly or ultimately a mutex-based
+ * implementation:
+ */
+#define PIPE_ATOMIC_ASM_GCC_X86 \
+ (!PIPE_ATOMIC_OS_PROVIDED && \
+ defined(PIPE_CC_GCC) && \
+ defined(PIPE_ARCH_X86))
+
+/* KW: this was originally used when x86 asm wasn't available.
+ * Maintain that logic here.
+ */
+#define PIPE_ATOMIC_GCC_INTRINISIC \
+ (!PIPE_ATOMIC_OS_PROVIDED && \
+ !PIPE_ATOMIC_ASM_GCC_X86 && \
+ defined(PIPE_CC_GCC))
+
+#define PIPE_ATOMIC_ASM_MSVC_X86 \
+ (!PIPE_ATOMIC_OS_PROVIDED && \
+ defined(PIPE_CC_MSVC) && \
+ defined(PIPE_ARCH_X86))
+
+#define PIPE_ATOMIC_ASM \
+ (PIPE_ATOMIC_ASM_GCC_X86 || \
+ PIPE_ATOMIC_ASM_GCC_INTRINSIC || \
+ PIPE_ATOMIC_ASM_MSVC_X86)
+
+
+/* Where no OS-provided or locally-coded assembly implemenation is
+ * available, use pipe_mutex:
+ */
+#define PIPE_ATOMIC_MUTEX \
+ (!PIPE_ATOMIC_OS_PROVIDED && \
+ !PIPE_ATOMIC_ASM)
+
+
+
+#if (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 (PIPE_ATOMIC_ASM_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 (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 (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 (PIPE_ATOMIC_OS_MS_INTERLOCK)
+
+#define PIPE_ATOMIC "MS userspace interlocks"
+
+#include <windows.h>
+
+struct pipe_atomic
+{
+ 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);
+}
+
+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 (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_config.h b/src/gallium/include/pipe/p_config.h
index 05cbd2fc4d..7f7657031d 100644
--- a/src/gallium/include/pipe/p_config.h
+++ b/src/gallium/include/pipe/p_config.h
@@ -111,6 +111,10 @@
#define PIPE_OS_LINUX
#endif
+#if defined(__FreeBSD__)
+#define PIPE_OS_BSD
+#endif
+
#if defined(_WIN32) || defined(WIN32)
#define PIPE_OS_WINDOWS
#endif
@@ -122,9 +126,9 @@
* NOTE: There is no way to auto-detect most of these.
*/
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
#define PIPE_SUBSYSTEM_DRI
-#endif /* PIPE_OS_LINUX */
+#endif /* PIPE_OS_LINUX || PIPE_OS_BSD */
#if defined(PIPE_OS_WINDOWS)
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 9454cc87db..2452bf3522 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -193,7 +193,6 @@ struct pipe_context {
*/
/*@{*/
void (*surface_copy)(struct pipe_context *pipe,
- boolean do_flip,/**< flip surface contents vertically */
struct pipe_surface *dest,
unsigned destx, unsigned desty,
struct pipe_surface *src, /* don't make this const -
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 4f0b301f31..52d443970b 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -194,6 +194,16 @@ enum pipe_texture_target {
/**
+ * Transfer object usage flags
+ */
+enum pipe_transfer_usage {
+ PIPE_TRANSFER_READ,
+ PIPE_TRANSFER_WRITE,
+ PIPE_TRANSFER_READ_WRITE //< Read/modify/write
+};
+
+
+/**
* Buffer usage flags
*/
#define PIPE_BUFFER_USAGE_CPU_READ (1 << 0)
@@ -205,6 +215,7 @@ enum pipe_texture_target {
#define PIPE_BUFFER_USAGE_INDEX (1 << 6)
#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7)
#define PIPE_BUFFER_USAGE_DISCARD (1 << 8)
+#define PIPE_BUFFER_USAGE_DONTBLOCK (1 << 9)
/** Pipe driver custom usage flags should be greater or equal to this value */
#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16)
@@ -247,6 +258,7 @@ enum pipe_texture_target {
#define PIPE_PRIM_QUADS 7
#define PIPE_PRIM_QUAD_STRIP 8
#define PIPE_PRIM_POLYGON 9
+#define PIPE_PRIM_MAX 10
/**
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index b42f98ceba..3f65a60436 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -30,8 +30,9 @@
#define PIPE_FORMAT_H
#include "p_compiler.h"
-#include "p_debug.h"
+/* FIXME: remove these header dependencies */
+#include "util/u_debug.h"
#include "util/u_string.h"
#ifdef __cplusplus
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index 1219c817b4..1232c87968 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -38,95 +38,6 @@ extern "C" {
#endif
-/* XXX: these are a kludge. will fix when all surfaces are views into
- * textures, and free-floating winsys surfaces go away.
- */
-static INLINE void *
-pipe_surface_map( struct pipe_surface *surf, unsigned flags )
-{
- struct pipe_screen *screen;
- assert(surf->texture);
- screen = surf->texture->screen;
- return screen->surface_map( screen, surf, flags );
-}
-
-static INLINE void
-pipe_surface_unmap( struct pipe_surface *surf )
-{
- struct pipe_screen *screen;
- assert(surf->texture);
- screen = surf->texture->screen;
- screen->surface_unmap( screen, surf );
-}
-
-
-
-/**
- * Set 'ptr' to point to 'surf' and update reference counting.
- * The old thing pointed to, if any, will be unreferenced first.
- * 'surf' may be NULL.
- */
-static INLINE void
-pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
-{
- /* bump the refcount first */
- if (surf) {
- assert(surf->refcount);
- surf->refcount++;
- }
-
- if (*ptr) {
- struct pipe_screen *screen;
- assert((*ptr)->refcount);
- assert((*ptr)->texture);
- screen = (*ptr)->texture->screen;
- screen->tex_surface_release( screen, ptr );
- assert(!*ptr);
- }
-
- *ptr = surf;
-}
-
-
-/**
- * \sa pipe_surface_reference
- */
-static INLINE void
-pipe_texture_reference(struct pipe_texture **ptr,
- struct pipe_texture *pt)
-{
- assert(ptr);
-
- if (pt) {
- assert(pt->refcount);
- pt->refcount++;
- }
-
- if (*ptr) {
- struct pipe_screen *screen = (*ptr)->screen;
- assert(screen);
- assert((*ptr)->refcount);
- screen->texture_release(screen, ptr);
-
- assert(!*ptr);
- }
-
- *ptr = pt;
-}
-
-
-static INLINE void
-pipe_texture_release(struct pipe_texture **ptr)
-{
- struct pipe_screen *screen;
- assert(ptr);
- screen = (*ptr)->screen;
- assert((*ptr)->refcount);
- screen->texture_release(screen, ptr);
- *ptr = NULL;
-}
-
-
/**
* Convenience wrappers for screen buffer functions.
*/
@@ -149,7 +60,13 @@ pipe_buffer_map(struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned usage)
{
- return screen->buffer_map(screen, buf, usage);
+ if(screen->buffer_map_range) {
+ unsigned offset = 0;
+ unsigned length = buf->size;
+ return screen->buffer_map_range(screen, buf, offset, length, usage);
+ }
+ else
+ return screen->buffer_map(screen, buf, usage);
}
static INLINE void
@@ -159,26 +76,74 @@ pipe_buffer_unmap(struct pipe_screen *screen,
screen->buffer_unmap(screen, buf);
}
-/* XXX: thread safety issues!
- */
+static INLINE void *
+pipe_buffer_map_range(struct pipe_screen *screen,
+ struct pipe_buffer *buf,
+ unsigned offset,
+ unsigned length,
+ unsigned usage)
+{
+ assert(offset < buf->size);
+ assert(offset + length <= buf->size);
+ assert(length);
+ if(screen->buffer_map_range)
+ return screen->buffer_map_range(screen, buf, offset, length, usage);
+ else
+ return screen->buffer_map(screen, buf, usage);
+}
+
static INLINE void
-pipe_buffer_reference(struct pipe_screen *screen,
- struct pipe_buffer **ptr,
- struct pipe_buffer *buf)
+pipe_buffer_flush_mapped_range(struct pipe_screen *screen,
+ struct pipe_buffer *buf,
+ unsigned offset,
+ unsigned length)
{
- if (buf) {
- assert(buf->refcount);
- buf->refcount++;
- }
+ assert(offset < buf->size);
+ assert(offset + length <= buf->size);
+ assert(length);
+ if(screen->buffer_flush_mapped_range)
+ screen->buffer_flush_mapped_range(screen, buf, offset, length);
+}
- if (*ptr) {
- assert((*ptr)->refcount);
- if(--(*ptr)->refcount == 0) {
- screen->buffer_destroy( screen, *ptr );
- }
+static INLINE void
+pipe_buffer_write(struct pipe_screen *screen,
+ struct pipe_buffer *buf,
+ unsigned offset, unsigned size,
+ const void *data)
+{
+ uint8_t *map;
+
+ assert(offset < buf->size);
+ assert(offset + size <= buf->size);
+ assert(size);
+
+ map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE);
+ assert(map);
+ if(map) {
+ memcpy(map + offset, data, size);
+ pipe_buffer_flush_mapped_range(screen, buf, offset, size);
+ pipe_buffer_unmap(screen, buf);
}
+}
- *ptr = buf;
+static INLINE void
+pipe_buffer_read(struct pipe_screen *screen,
+ struct pipe_buffer *buf,
+ unsigned offset, unsigned size,
+ void *data)
+{
+ uint8_t *map;
+
+ assert(offset < buf->size);
+ assert(offset + size <= buf->size);
+ assert(size);
+
+ map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ);
+ assert(map);
+ if(map) {
+ memcpy(data, map + offset, size);
+ pipe_buffer_unmap(screen, buf);
+ }
}
diff --git a/src/gallium/drivers/trace/tr_winsys.h b/src/gallium/include/pipe/p_refcnt.h
index 0fd2a40556..60844e40a5 100644
--- a/src/gallium/drivers/trace/tr_winsys.h
+++ b/src/gallium/include/pipe/p_refcnt.h
@@ -1,8 +1,8 @@
/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ *
+ * Copyright 2009 VMware, Inc.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,55 +22,67 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
+ *
**************************************************************************/
-#ifndef TR_WINSYS_H_
-#define TR_WINSYS_H_
-
+#ifndef P_REFCNT_H
+#define P_REFCNT_H
-#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
-#include "pipe/internal/p_winsys_screen.h"
-
-/**
- * It often happens that new data is written directly to the user buffers
- * without mapping/unmapping. This flag marks user buffers, so that their
- * contents can be dumpped before being used by the pipe context.
- */
-#define TRACE_BUFFER_USAGE_USER (1 << 31)
+#include "p_defines.h"
+#include "p_atomic.h"
-struct hash_table;
+#ifdef __cplusplus
+extern "C" {
+#endif
-struct trace_winsys
+struct pipe_reference
{
- struct pipe_winsys base;
-
- struct pipe_winsys *winsys;
-
- struct hash_table *buffer_maps;
+ struct pipe_atomic count;
};
-static INLINE struct trace_winsys *
-trace_winsys(struct pipe_winsys *winsys)
+static INLINE void
+pipe_reference_init(struct pipe_reference *reference, unsigned count)
{
- assert(winsys);
- return (struct trace_winsys *)winsys;
+ p_atomic_set(&reference->count, count);
}
+/**
+ * Set 'ptr' to point to 'reference' and update reference counting.
+ * The old thing pointed to, if any, will be unreferenced first.
+ * 'reference' may be NULL.
+ *
+ * XXX: thread safety issues!
+ */
+static INLINE bool
+pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference)
+{
+ bool destroy = FALSE;
+
+ /* bump the reference.count first */
+ if (reference) {
+ assert(p_atomic_read(&reference->count) != 0);
+ p_atomic_inc(&reference->count);
+ }
-struct pipe_winsys *
-trace_winsys_create(struct pipe_winsys *winsys);
+ if (*ptr) {
+ assert(p_atomic_read(&(*ptr)->count) != 0);
+ if (p_atomic_dec_zero(&(*ptr)->count)) {
+ destroy = TRUE;
+ }
+ }
+ *ptr = reference;
-void
-trace_winsys_user_buffer_update(struct pipe_winsys *winsys,
- struct pipe_buffer *buffer);
+ return destroy;
+}
+#ifdef __cplusplus
+}
+#endif
-#endif /* TR_WINSYS_H_ */
+#endif /* P_REFCNT_H */
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 17d1548253..ed3a026023 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -55,6 +55,7 @@ struct pipe_winsys;
struct pipe_buffer;
+
/**
* Gallium screen/adapter context. Basically everything
* hardware-specific that doesn't actually require a rendering
@@ -112,8 +113,7 @@ struct pipe_screen {
const unsigned *stride,
struct pipe_buffer *buffer);
- void (*texture_release)(struct pipe_screen *,
- struct pipe_texture **pt);
+ void (*texture_destroy)(struct pipe_texture *pt);
/** Get a surface which is a "view" into a texture */
struct pipe_surface *(*get_tex_surface)(struct pipe_screen *,
@@ -122,18 +122,25 @@ struct pipe_screen {
unsigned zslice,
unsigned usage );
- /* Surfaces allocated by the above must be released here:
- */
- void (*tex_surface_release)( struct pipe_screen *,
- struct pipe_surface ** );
+ void (*tex_surface_destroy)(struct pipe_surface *);
- void *(*surface_map)( struct pipe_screen *,
- struct pipe_surface *surface,
- unsigned flags );
+ /** Get a transfer object for transferring data to/from a texture */
+ struct pipe_transfer *(*get_tex_transfer)(struct pipe_screen *,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level,
+ unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y,
+ unsigned w, unsigned h);
+
+ void (*tex_transfer_destroy)(struct pipe_transfer *);
+
+ void *(*transfer_map)( struct pipe_screen *,
+ struct pipe_transfer *transfer );
- void (*surface_unmap)( struct pipe_screen *,
- struct pipe_surface *surface );
+ void (*transfer_unmap)( struct pipe_screen *,
+ struct pipe_transfer *transfer );
/**
@@ -195,12 +202,37 @@ struct pipe_screen {
void *(*buffer_map)( struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned usage );
+ /**
+ * Map a subrange of the buffer data store into the client's address space.
+ *
+ * The returned pointer is always relative to buffer start, regardless of
+ * the specified range. This is different from the ARB_map_buffer_range
+ * semantics because we don't forbid multiple mappings of the same buffer
+ * (yet).
+ */
+ void *(*buffer_map_range)( struct pipe_screen *screen,
+ struct pipe_buffer *buf,
+ unsigned offset,
+ unsigned length,
+ unsigned usage);
+
+ /**
+ * Notify a range that was actually written into.
+ *
+ * The range is relative to the buffer start, regardless of the range
+ * specified to buffer_map_range. This is different from the
+ * ARB_map_buffer_range semantics because we don't forbid multiple mappings
+ * of the same buffer (yet).
+ */
+ void (*buffer_flush_mapped_range)( struct pipe_screen *screen,
+ struct pipe_buffer *buf,
+ unsigned offset,
+ unsigned length);
void (*buffer_unmap)( struct pipe_screen *screen,
- struct pipe_buffer *buf );
+ struct pipe_buffer *buf );
- void (*buffer_destroy)( struct pipe_screen *screen,
- struct pipe_buffer *buf );
+ void (*buffer_destroy)( struct pipe_buffer *buf );
/**
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 35df70e7b7..4dafdd6f0a 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -191,8 +191,8 @@ struct tgsi_immediate_float32
/*
* GL_EXT_vertex_shader
*/
-#define TGSI_OPCODE_INDEX 22
-#define TGSI_OPCODE_NEGATE 23
+#define TGSI_OPCODE_INDEX 22 /* considered for removal */
+#define TGSI_OPCODE_NEGATE 23 /* considered for removal */
#define TGSI_OPCODE_MADD TGSI_OPCODE_MAD
#define TGSI_OPCODE_FRAC 24
#define TGSI_OPCODE_SETGE TGSI_OPCODE_SGE
@@ -206,7 +206,7 @@ struct tgsi_immediate_float32
#define TGSI_OPCODE_RECIP TGSI_OPCODE_RCP
#define TGSI_OPCODE_RECIPSQRT TGSI_OPCODE_RSQ
#define TGSI_OPCODE_CROSSPRODUCT 31
-#define TGSI_OPCODE_MULTIPLYMATRIX 32
+#define TGSI_OPCODE_MULTIPLYMATRIX 32 /* considered for removal */
/*
* GL_NV_vertex_program1_1
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 9dc541630c..aad41fab11 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -43,6 +43,8 @@
#include "p_compiler.h"
#include "p_defines.h"
#include "p_format.h"
+#include "p_refcnt.h"
+#include "p_screen.h"
#ifdef __cplusplus
@@ -64,23 +66,20 @@ extern "C" {
/* fwd decls */
-struct pipe_screen;
struct pipe_surface;
-
/**
* The driver will certainly subclass this to include actual memory
* management information.
*/
struct pipe_buffer
{
+ struct pipe_reference reference;
+ struct pipe_screen *screen;
unsigned alignment;
unsigned usage;
unsigned size;
-
- /** Reference count */
- unsigned refcount;
};
@@ -109,9 +108,15 @@ struct pipe_rasterizer_state
unsigned line_stipple_factor:8; /**< [1..256] actually */
unsigned line_stipple_pattern:16;
unsigned line_last_pixel:1;
- unsigned bypass_clipping:1;
- unsigned bypass_vs:1; /**< Skip the vertex shader. Note that the shader is
- still needed though, to indicate inputs/outputs */
+
+ /**
+ * Vertex coordinates are pre-transformed to screen space. Skip
+ * the vertex shader, clipping and viewport processing. Note that
+ * a vertex shader is still needed though, to indicate the mapping
+ * from vertex elements to fragment shader input semantics.
+ */
+ unsigned bypass_vs_clip_and_viewport:1;
+
unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */
unsigned flatshade_first:1; /**< take color attribute from the first vertex of a primitive */
unsigned gl_rasterization_rules:1; /**< enable tweaks for GL rasterization? */
@@ -275,18 +280,14 @@ struct pipe_sampler_state
*/
struct pipe_surface
{
+ struct pipe_reference reference;
enum pipe_format format; /**< PIPE_FORMAT_x */
unsigned status; /**< PIPE_SURFACE_STATUS_x */
unsigned clear_value; /**< XXX may be temporary */
unsigned width; /**< logical width in pixels */
unsigned height; /**< logical height in pixels */
- struct pipe_format_block block;
- unsigned nblocksx; /**< allocated width in blocks */
- unsigned nblocksy; /**< allocated height in blocks */
- unsigned stride; /**< stride in bytes between rows of blocks */
unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */
unsigned offset; /**< offset from start of buffer, in bytes */
- unsigned refcount;
unsigned usage; /**< PIPE_BUFFER_USAGE_* */
struct pipe_texture *texture; /**< texture into which this is a view */
@@ -297,10 +298,35 @@ struct pipe_surface
/**
+ * Transfer object. For data transfer to/from a texture.
+ */
+struct pipe_transfer
+{
+ enum pipe_format format; /**< PIPE_FORMAT_x */
+ unsigned x; /**< x offset from start of texture image */
+ unsigned y; /**< y offset from start of texture image */
+ unsigned width; /**< logical width in pixels */
+ unsigned height; /**< logical height in pixels */
+ struct pipe_format_block block;
+ unsigned nblocksx; /**< allocated width in blocks */
+ unsigned nblocksy; /**< allocated height in blocks */
+ unsigned stride; /**< stride in bytes between rows of blocks */
+ unsigned usage; /**< PIPE_TRANSFER_* */
+
+ struct pipe_texture *texture; /**< texture to transfer to/from */
+ unsigned face;
+ unsigned level;
+ unsigned zslice;
+};
+
+
+/**
* Texture object.
*/
struct pipe_texture
{
+ struct pipe_reference reference;
+
enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
enum pipe_format format; /**< PIPE_FORMAT_x */
@@ -319,10 +345,6 @@ struct pipe_texture
unsigned tex_usage; /* PIPE_TEXTURE_USAGE_* */
- /* These are also refcounted:
- */
- unsigned refcount;
-
struct pipe_screen *screen; /**< screen that this texture belongs to */
};
@@ -359,6 +381,35 @@ 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((struct pipe_reference **)ptr, &buf->reference))
+ old_buf->screen->buffer_destroy(old_buf);
+}
+
+static INLINE void
+pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
+{
+ struct pipe_surface *old_surf = *ptr;
+
+ if (pipe_reference((struct pipe_reference **)ptr, &surf->reference))
+ old_surf->texture->screen->tex_surface_destroy(old_surf);
+}
+
+static INLINE void
+pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
+{
+ struct pipe_texture *old_tex = *ptr;
+
+ if (pipe_reference((struct pipe_reference **)ptr, &tex->reference))
+ old_tex->screen->texture_destroy(old_tex);
+}
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h
index 8af3cd958b..a9cd77541d 100644
--- a/src/gallium/include/pipe/p_thread.h
+++ b/src/gallium/include/pipe/p_thread.h
@@ -38,7 +38,7 @@
#include "pipe/p_compiler.h"
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
#include <pthread.h> /* POSIX threads headers */
#include <stdio.h> /* for perror() */
@@ -73,7 +73,7 @@ typedef pthread_cond_t pipe_condvar;
static pipe_mutex mutex = PTHREAD_MUTEX_INITIALIZER
#define pipe_mutex_init(mutex) \
- pthread_mutex_init(&(mutex), NULL)
+ (void) pthread_mutex_init(&(mutex), NULL)
#define pipe_mutex_destroy(mutex) \
pthread_mutex_destroy(&(mutex))
@@ -134,20 +134,20 @@ static INLINE int pipe_thread_destroy( pipe_thread thread )
typedef CRITICAL_SECTION pipe_mutex;
-#define pipe_static_mutex(name) \
- /*static*/ pipe_mutex name = {0,0,0,0,0,0}
+#define pipe_static_mutex(mutex) \
+ /*static*/ pipe_mutex mutex = {0,0,0,0,0,0}
-#define pipe_mutex_init(name) \
- InitializeCriticalSection(&name)
+#define pipe_mutex_init(mutex) \
+ InitializeCriticalSection(&mutex)
-#define pipe_mutex_destroy(name) \
- DeleteCriticalSection(&name)
+#define pipe_mutex_destroy(mutex) \
+ DeleteCriticalSection(&mutex)
-#define pipe_mutex_lock(name) \
- EnterCriticalSection(&name)
+#define pipe_mutex_lock(mutex) \
+ EnterCriticalSection(&mutex)
-#define pipe_mutex_unlock(name) \
- LeaveCriticalSection(&name)
+#define pipe_mutex_unlock(mutex) \
+ LeaveCriticalSection(&mutex)
/* XXX: dummy definitions, make it compile */
@@ -210,7 +210,7 @@ typedef unsigned pipe_condvar;
*/
typedef struct {
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
pthread_key_t key;
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
DWORD key;
@@ -225,7 +225,7 @@ typedef struct {
static INLINE void
pipe_tsd_init(pipe_tsd *tsd)
{
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
perror("pthread_key_create(): failed to allocate key for thread specific data");
exit(-1);
@@ -242,7 +242,7 @@ pipe_tsd_get(pipe_tsd *tsd)
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
pipe_tsd_init(tsd);
}
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
return pthread_getspecific(tsd->key);
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
assert(0);
@@ -259,7 +259,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value)
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
pipe_tsd_init(tsd);
}
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
if (pthread_setspecific(tsd->key, value) != 0) {
perror("pthread_set_specific() failed");
exit(-1);
diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h
index 54480fa047..435435da29 100644
--- a/src/gallium/include/state_tracker/drm_api.h
+++ b/src/gallium/include/state_tracker/drm_api.h
@@ -2,14 +2,18 @@
#ifndef _DRM_API_H_
#define _DRM_API_H_
+#include "pipe/p_compiler.h"
+
struct pipe_screen;
struct pipe_winsys;
+struct pipe_buffer;
struct pipe_context;
+struct pipe_texture;
struct drm_api
{
/**
- * Special buffer function
+ * Special buffer functions
*/
/*@{*/
struct pipe_screen* (*create_screen)(int drmFB, int pciID);
@@ -17,17 +21,27 @@ struct drm_api
/*@}*/
/**
- * Special buffer function
+ * Special buffer functions
*/
/*@{*/
- struct pipe_buffer* (*buffer_from_handle)(struct pipe_winsys *winsys, const char *name, unsigned handle);
- unsigned (*handle_from_buffer)(struct pipe_winsys *winsys, struct pipe_buffer *buffer);
+ boolean (*buffer_from_texture)(struct pipe_texture *texture,
+ struct pipe_buffer **buffer,
+ unsigned *stride);
+ struct pipe_buffer* (*buffer_from_handle)(struct pipe_screen *screen,
+ const char *name,
+ unsigned handle);
+ boolean (*handle_from_buffer)(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle);
+ boolean (*global_handle_from_buffer)(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle);
/*@}*/
};
/**
* A driver needs to export this symbol
*/
-extern struct drm_api drm_api_hocks;
+extern struct drm_api drm_api_hooks;
#endif
diff --git a/src/gallium/state_trackers/dri2/Makefile b/src/gallium/state_trackers/dri2/Makefile
new file mode 100644
index 0000000000..47750e997e
--- /dev/null
+++ b/src/gallium/state_trackers/dri2/Makefile
@@ -0,0 +1,28 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = dri2drm
+
+LIBRARY_INCLUDES = \
+ -I$(TOP)/include \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/drivers/dri/common \
+ -I$(TOP)/src/mesa/main \
+ $(shell pkg-config --cflags-only-I libdrm)
+
+
+C_SOURCES = \
+ dri_context.c \
+ dri_screen.c \
+ dri_drawable.c \
+ dri_extensions.c
+
+# $(TOP)/src/mesa/drivers/dri/common/utils.c \
+ $(TOP)/src/mesa/drivers/dri/common/vblank.c \
+ $(TOP)/src/mesa/drivers/dri/common/dri_util.c \
+ $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \
+ $(TOP)/src/mesa/drivers/common/driverfuncs.c \
+ $(TOP)/src/mesa/drivers/dri/common/texmem.c \
+ $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c
+
+include ../../Makefile.template
diff --git a/src/gallium/state_trackers/glx/dri/dri_context.c b/src/gallium/state_trackers/dri2/dri_context.c
index 9424e18bee..92c26ac70f 100644
--- a/src/gallium/state_trackers/glx/dri/dri_context.c
+++ b/src/gallium/state_trackers/dri2/dri_context.c
@@ -18,22 +18,29 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
*
**************************************************************************/
-
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
#include "dri_screen.h"
-#include "dri_context.h"
-#include "dri_winsys.h"
+#include "dri_drawable.h"
+
+
+#include "state_tracker/drm_api.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
#include "pipe/p_context.h"
+#include "dri_context.h"
+
#include "util/u_memory.h"
@@ -59,33 +66,33 @@ dri_create_context(const __GLcontextModes *visual,
ctx->cPriv = cPriv;
ctx->sPriv = sPriv;
- driParseConfigFiles(&ctx->optionCache,
+ driParseConfigFiles(&ctx->optionCache,
&screen->optionCache,
- sPriv->myNum,
+ sPriv->myNum,
"dri");
-
- ctx->pipe = screen->pipe_screen->create_context(screen->pipe_screen,
- screen->pipe_winsys,
- hw_winsys );
+
+ ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen);
+
if (ctx->pipe == NULL)
goto fail;
- ctx->pipe->priv = ctx; /* I guess */
+ /* used in dri_flush_frontbuffer */
+ ctx->pipe->priv = ctx;
ctx->st = st_create_context(ctx->pipe, visual, st_share);
if (ctx->st == NULL)
goto fail;
- dri_init_extensions( ctx );
+ dri_init_extensions(ctx);
return GL_TRUE;
fail:
if (ctx && ctx->st)
- st_destroy_context( ctx->st );
+ st_destroy_context(ctx->st);
if (ctx && ctx->pipe)
- ctx->pipe->destroy( ctx->pipe );
+ ctx->pipe->destroy(ctx->pipe);
FREE(ctx);
return FALSE;
@@ -97,14 +104,13 @@ dri_destroy_context(__DRIcontextPrivate *cPriv)
{
struct dri_context *ctx = dri_context(cPriv);
struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
- struct pipe_winsys *winsys = screen->winsys;
/* No particular reason to wait for command completion before
* destroying a context, but it is probably worthwhile flushing it
* to avoid having to add code elsewhere to cope with flushing a
* partially destroyed context.
*/
- st_flush(ctx->st);
+ st_flush(ctx->st, 0, NULL);
if (screen->dummyContext == ctx)
screen->dummyContext = NULL;
@@ -143,26 +149,22 @@ dri_make_current(__DRIcontextPrivate *cPriv,
*/
screen->dummyContext = ctx;
- st_make_current( ctx->st,
- draw->stfb,
- read->stfb );
+ st_make_current(ctx->st,
+ draw->stfb,
+ read->stfb);
+ /* used in dri_flush_frontbuffer */
ctx->dPriv = driDrawPriv;
- /* Update window sizes if necessary:
- */
- if (draw->stamp != driDrawPriv->lastStamp) {
- dri_update_window_size( draw );
- }
-
- if (read->stamp != driReadPriv->lastStamp) {
- dri_update_window_size( read );
- }
-
- }
- else {
+ if (driDrawPriv)
+ dri_get_buffers(driDrawPriv);
+ if (driDrawPriv != driReadPriv && driReadPriv)
+ dri_get_buffers(driReadPriv);
+ } else {
st_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/glx/dri/dri_context.h b/src/gallium/state_trackers/dri2/dri_context.h
index 4e6a305abb..e910472700 100644
--- a/src/gallium/state_trackers/glx/dri/dri_context.h
+++ b/src/gallium/state_trackers/dri2/dri_context.h
@@ -1,6 +1,7 @@
/**************************************************************************
*
- * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc.
+ * All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -17,12 +18,16 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
*
**************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
#ifndef DRI_CONTEXT_H
#define DRI_CONTEXT_H
@@ -35,22 +40,21 @@
struct pipe_context;
struct pipe_fence;
struct st_context;
+struct dri_drawable;
struct dri_context
{
+ /* dri */
+ __DRIscreenPrivate *sPriv;
__DRIcontextPrivate *cPriv;
__DRIdrawablePrivate *dPriv;
+ driOptionCache optionCache;
+
+ /* gallium */
struct st_context *st;
struct pipe_context *pipe;
-
- boolean locked;
-
- /**
- * Configuration cache
- */
- driOptionCache optionCache;
};
@@ -60,13 +64,14 @@ dri_context(__DRIcontextPrivate *driContextPriv)
return (struct dri_context *) driContextPriv->driverPrivate;
}
+
/***********************************************************************
* dri_context.c
*/
-void
+void
dri_destroy_context(__DRIcontextPrivate * driContextPriv);
-boolean
+boolean
dri_unbind_context(__DRIcontextPrivate * driContextPriv);
boolean
@@ -80,16 +85,12 @@ dri_create_context(const __GLcontextModes * visual,
void *sharedContextPrivate);
-
/***********************************************************************
- * dri_lock.c
+ * dri_extensions.c
*/
-void dri_lock_hardware( struct dri_context *context,
- struct dri_drawable *drawable );
-
-void dri_unlock_hardware( struct dri_context *dri );
-boolean dri_is_locked( struct dri_context *dri );
-
-
+void
+dri_init_extensions(struct dri_context *ctx);
#endif
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri2/dri_drawable.c b/src/gallium/state_trackers/dri2/dri_drawable.c
new file mode 100644
index 0000000000..2e3f4099e2
--- /dev/null
+++ b/src/gallium/state_trackers/dri2/dri_drawable.c
@@ -0,0 +1,325 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_screen.h"
+#include "pipe/p_inlines.h"
+#include "state_tracker/drm_api.h"
+#include "state_tracker/st_public.h"
+#include "state_tracker/st_context.h"
+#include "state_tracker/st_cb_fbo.h"
+
+#include "util/u_memory.h"
+
+
+static void
+dri_copy_to_front(__DRIdrawablePrivate *dPriv,
+ struct pipe_surface *from,
+ int x, int y, unsigned w, unsigned h)
+{
+ /* TODO send a message to the Xserver to copy to the real front buffer */
+}
+
+
+static struct pipe_surface *
+dri_surface_from_handle(struct pipe_screen *screen,
+ unsigned handle,
+ enum pipe_format format,
+ unsigned width,
+ unsigned height,
+ unsigned pitch)
+{
+ struct pipe_surface *surface = NULL;
+ struct pipe_texture *texture = NULL;
+ struct pipe_texture templat;
+ struct pipe_buffer *buf = NULL;
+
+ buf = drm_api_hooks.buffer_from_handle(screen, "dri2 buffer", handle);
+ if (!buf)
+ return NULL;
+
+ memset(&templat, 0, sizeof(templat));
+ templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ templat.target = PIPE_TEXTURE_2D;
+ templat.last_level = 0;
+ templat.depth[0] = 1;
+ templat.format = format;
+ templat.width[0] = width;
+ templat.height[0] = height;
+ pf_get_block(templat.format, &templat.block);
+
+ texture = screen->texture_blanket(screen,
+ &templat,
+ &pitch,
+ buf);
+
+ /* we don't need the buffer from this point on */
+ pipe_buffer_reference(&buf, NULL);
+
+ if (!texture)
+ return NULL;
+
+ surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+
+ /* we don't need the texture from this point on */
+ pipe_texture_reference(&texture, NULL);
+ return surface;
+}
+
+
+/**
+ * This will be called a drawable is known to have been resized.
+ */
+void
+dri_get_buffers(__DRIdrawablePrivate *dPriv)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct pipe_surface *surface = NULL;
+ struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
+ __DRIbuffer *buffers = NULL;
+ __DRIscreen *dri_screen = drawable->sPriv;
+ __DRIdrawable *dri_drawable = drawable->dPriv;
+ boolean have_depth = FALSE;
+ int i, count;
+
+ buffers = (*dri_screen->dri2.loader->getBuffers)(dri_drawable,
+ &dri_drawable->w,
+ &dri_drawable->h,
+ drawable->attachments,
+ drawable->num_attachments,
+ &count,
+ dri_drawable->loaderPrivate);
+
+ if (buffers == NULL) {
+ return;
+ }
+
+ /* set one cliprect to cover the whole dri_drawable */
+ dri_drawable->x = 0;
+ dri_drawable->y = 0;
+ dri_drawable->backX = 0;
+ dri_drawable->backY = 0;
+ dri_drawable->numClipRects = 1;
+ dri_drawable->pClipRects[0].x1 = 0;
+ dri_drawable->pClipRects[0].y1 = 0;
+ dri_drawable->pClipRects[0].x2 = dri_drawable->w;
+ dri_drawable->pClipRects[0].y2 = dri_drawable->h;
+ dri_drawable->numBackClipRects = 1;
+ dri_drawable->pBackClipRects[0].x1 = 0;
+ dri_drawable->pBackClipRects[0].y1 = 0;
+ dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
+ dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
+
+ for (i = 0; i < count; i++) {
+ enum pipe_format format = 0;
+ int index = 0;
+
+ switch (buffers[i].attachment) {
+ case __DRI_BUFFER_FRONT_LEFT:
+ index = ST_SURFACE_FRONT_LEFT;
+ format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ break;
+ case __DRI_BUFFER_FAKE_FRONT_LEFT:
+ index = ST_SURFACE_FRONT_LEFT;
+ format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ break;
+ case __DRI_BUFFER_BACK_LEFT:
+ index = ST_SURFACE_BACK_LEFT;
+ format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ break;
+ case __DRI_BUFFER_DEPTH:
+ index = ST_SURFACE_DEPTH;
+ format = PIPE_FORMAT_Z24S8_UNORM;
+ break;
+ case __DRI_BUFFER_STENCIL:
+ index = ST_SURFACE_DEPTH;
+ format = PIPE_FORMAT_Z24S8_UNORM;
+ break;
+ case __DRI_BUFFER_ACCUM:
+ default:
+ assert(0);
+ }
+ assert(buffers[i].cpp == 4);
+
+ if (index == ST_SURFACE_DEPTH) {
+ if (have_depth)
+ continue;
+ else
+ have_depth = TRUE;
+ }
+
+ surface = dri_surface_from_handle(screen,
+ buffers[i].name,
+ format,
+ dri_drawable->w,
+ dri_drawable->h,
+ buffers[i].pitch);
+
+ st_set_framebuffer_surface(drawable->stfb, index, surface);
+ pipe_surface_reference(&surface, NULL);
+ }
+ /* this needed, or else the state tracker fails to pick the new buffers */
+ st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h);
+}
+
+
+void
+dri_flush_frontbuffer(struct pipe_screen *screen,
+ struct pipe_surface *surf,
+ void *context_private)
+{
+ struct dri_context *ctx = (struct dri_context *)context_private;
+ dri_copy_to_front(ctx->dPriv, surf, 0, 0, surf->width, surf->height);
+}
+
+
+void
+dri_swap_buffers(__DRIdrawablePrivate * dPriv)
+{
+ /* not needed for dri2 */
+ assert(0);
+}
+
+
+void
+dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
+{
+ /* not needed for dri2 */
+ assert(0);
+}
+
+
+/**
+ * This is called when we need to set up GL rendering to a new X window.
+ */
+boolean
+dri_create_buffer(__DRIscreenPrivate *sPriv,
+ __DRIdrawablePrivate *dPriv,
+ const __GLcontextModes *visual,
+ boolean isPixmap)
+{
+ enum pipe_format colorFormat, depthFormat, stencilFormat;
+ struct dri_screen *screen = sPriv->private;
+ struct dri_drawable *drawable = NULL;
+ struct pipe_screen *pscreen = screen->pipe_screen;
+ int i;
+
+ if (isPixmap)
+ goto fail; /* not implemented */
+
+ drawable = CALLOC_STRUCT(dri_drawable);
+ if (drawable == NULL)
+ goto fail;
+
+ /* XXX: todo: use the pipe_screen queries to figure out which
+ * render targets are supportable.
+ */
+ assert(visual->redBits == 8);
+ assert(visual->depthBits == 24 || visual->depthBits == 0);
+ assert(visual->stencilBits == 8 || visual->stencilBits == 0);
+
+ colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+ if (visual->depthBits) {
+ if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET |
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
+ depthFormat = PIPE_FORMAT_Z24S8_UNORM;
+ else
+ depthFormat = PIPE_FORMAT_S8Z24_UNORM;
+ } else
+ depthFormat = PIPE_FORMAT_NONE;
+
+ if (visual->stencilBits) {
+ if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET |
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
+ stencilFormat = PIPE_FORMAT_Z24S8_UNORM;
+ else
+ stencilFormat = PIPE_FORMAT_S8Z24_UNORM;
+ } else
+ stencilFormat = PIPE_FORMAT_NONE;
+
+ drawable->stfb = st_create_framebuffer(visual,
+ colorFormat,
+ depthFormat,
+ stencilFormat,
+ dPriv->w,
+ dPriv->h,
+ (void*) drawable);
+ if (drawable->stfb == NULL)
+ goto fail;
+
+ drawable->sPriv = sPriv;
+ drawable->dPriv = dPriv;
+ dPriv->driverPrivate = (void *) drawable;
+
+ /* setup dri2 buffers information */
+ i = 0;
+ drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+#if 0
+ /* TODO incase of double buffer visual, delay fake creation */
+ drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
+#endif
+ if (visual->doubleBufferMode)
+ drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+ if (visual->depthBits)
+ drawable->attachments[i++] = __DRI_BUFFER_DEPTH;
+ if (visual->stencilBits)
+ drawable->attachments[i++] = __DRI_BUFFER_STENCIL;
+ drawable->num_attachments = i;
+
+ return GL_TRUE;
+fail:
+ FREE(drawable);
+ return GL_FALSE;
+}
+
+
+void
+dri_destroy_buffer(__DRIdrawablePrivate *dPriv)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+
+ st_unreference_framebuffer(drawable->stfb);
+
+ FREE(drawable);
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/glx/dri/dri_drawable.h b/src/gallium/state_trackers/dri2/dri_drawable.h
index 1001bb8c57..185c657b35 100644
--- a/src/gallium/state_trackers/glx/dri/dri_drawable.h
+++ b/src/gallium/state_trackers/dri2/dri_drawable.h
@@ -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,12 +37,14 @@ struct st_framebuffer;
struct dri_drawable
{
+ /* dri */
__DRIdrawablePrivate *dPriv;
- unsigned stamp;
+ __DRIscreenPrivate *sPriv;
- struct pipe_fence *last_swap_fence;
- struct pipe_fence *first_swap_fence;
+ unsigned attachments[8];
+ unsigned num_attachments;
+ /* gallium */
struct st_framebuffer *stfb;
};
@@ -57,17 +59,31 @@ dri_drawable(__DRIdrawablePrivate * driDrawPriv)
/***********************************************************************
* dri_drawable.c
*/
-
-void
+boolean
+dri_create_buffer(__DRIscreenPrivate *sPriv,
+ __DRIdrawablePrivate *dPriv,
+ const __GLcontextModes *visual,
+ boolean isPixmap);
+
+void
+dri_flush_frontbuffer(struct pipe_screen *screen,
+ struct pipe_surface *surf,
+ void *context_private);
+
+void
dri_swap_buffers(__DRIdrawablePrivate * dPriv);
-void
+void
dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv,
- int x, int y,
+ int x, int y,
int w, int h);
-void
-dri_update_window_size(__DRIdrawablePrivate *dPriv);
+void
+dri_get_buffers(__DRIdrawablePrivate * dPriv);
+void
+dri_destroy_buffer(__DRIdrawablePrivate *dPriv);
#endif
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/glx/dri/dri_extensions.c b/src/gallium/state_trackers/dri2/dri_extensions.c
index 126faf7601..732d1e89b0 100644
--- a/src/gallium/state_trackers/glx/dri/dri_extensions.c
+++ b/src/gallium/state_trackers/dri2/dri_extensions.c
@@ -18,17 +18,23 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
*
**************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
-
-
+#include "dri_screen.h"
+#include "dri_context.h"
+#include "state_tracker/st_context.h"
#define need_GL_ARB_multisample
+#define need_GL_ARB_occlusion_query
#define need_GL_ARB_point_parameters
#define need_GL_ARB_texture_compression
#define need_GL_ARB_vertex_buffer_object
@@ -53,6 +59,7 @@
const struct dri_extension card_extensions[] = {
{"GL_ARB_multisample", GL_ARB_multisample_functions},
{"GL_ARB_multitexture", NULL},
+ {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions},
{"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
{"GL_ARB_texture_border_clamp", NULL},
{"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
@@ -96,13 +103,17 @@ const struct dri_extension card_extensions[] = {
};
-
-void
-dri_init_extensions( void )
+void
+dri_init_extensions(struct dri_context *ctx)
{
/* The card_extensions list should be pruned according to the
- * capabilities of the pipe_screen. This is actually something
+ * capabilities of the pipe_screen. This is actually something
* that can/should be done inside st_create_context().
*/
- driInitExtensions( ctx->st->ctx, card_extensions, GL_TRUE );
+ if (ctx)
+ driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE);
+ else
+ driInitExtensions(NULL, card_extensions, GL_FALSE);
}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/glx/dri/dri_screen.c b/src/gallium/state_trackers/dri2/dri_screen.c
index f7119b949a..ab5878a4bc 100644
--- a/src/gallium/state_trackers/glx/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri2/dri_screen.c
@@ -18,23 +18,29 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
*
**************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
#include "utils.h"
#include "vblank.h"
#include "xmlpool.h"
-#include "dri_context.h"
#include "dri_screen.h"
+#include "dri_context.h"
+#include "dri_drawable.h"
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "pipe/p_inlines.h"
+#include "state_tracker/drm_api.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_cb_fbo.h"
@@ -44,19 +50,15 @@ PUBLIC const char __driConfigOptions[] =
DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
-// DRI_CONF_FORCE_S3TC_ENABLE(false)
+ /*DRI_CONF_FORCE_S3TC_ENABLE(false)*/
DRI_CONF_ALLOW_LARGE_TEXTURES(1)
DRI_CONF_SECTION_END DRI_CONF_END;
-const uint __driNConfigOptions = 3;
-
-static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
-
-extern const struct dri_extension card_extensions[];
+const uint __driNConfigOptions = 3;
-static const __DRIextension *driScreenExtensions[] = {
+static const __DRIextension *dri_screen_extensions[] = {
&driReadDrawableExtension,
&driCopySubBufferExtension.base,
&driSwapControlExtension.base,
@@ -66,46 +68,40 @@ static const __DRIextension *driScreenExtensions[] = {
};
-
-
-static const char *
-dri_get_name( struct pipe_winsys *winsys )
+static void
+dri_get_drm_minor(struct dri_screen *screen)
{
- return "dri";
+ /* TODO get the real minor */
+ screen->minor = 0;
}
-
static void
-dri_destroy_screen(__DRIscreenPrivate * sPriv)
+dri_get_device_id(struct dri_screen *screen)
{
- struct dri_screen *screen = dri_screen(sPriv);
-
- screen->pipe_screen->destroy( screen->pipe_screen );
- screen->pipe_winsys->destroy( screen->pipe_winsys );
- FREE(screen);
- sPriv->private = NULL;
-}
+ char path[512];
+ FILE *file;
+ /*
+ * There must be a better way to get the deviceID.
+ * XXX this only works on Linux.
+ */
+ snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", screen->minor);
+ file = fopen(path, "r");
+ if (!file) {
+ return;
+ }
-/**
- * Get information about previous buffer swaps.
- */
-static int
-dri_get_swap_info(__DRIdrawablePrivate * dPriv,
- __DRIswapInfo * sInfo)
-{
- if (dPriv == NULL ||
- dPriv->driverPrivate == NULL ||
- sInfo == NULL)
- return -1;
- else
- return 0;
+ fgets(path, sizeof(path), file);
+ sscanf(path, "%x", &screen->deviceID);
+ fclose(file);
}
+
static const __DRIconfig **
dri_fill_in_modes(__DRIscreenPrivate *psp,
- unsigned pixel_bits )
+ unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer)
{
__DRIconfig **configs;
__GLcontextModes *m;
@@ -115,17 +111,19 @@ dri_fill_in_modes(__DRIscreenPrivate *psp,
uint8_t msaa_samples_array[1];
unsigned depth_buffer_factor;
unsigned back_buffer_factor;
+ unsigned msaa_samples_factor;
GLenum fb_format;
GLenum fb_type;
int i;
static const GLenum back_buffer_modes[] = {
- GLX_NONE, GLX_SWAP_UNDEFINED_OML
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
};
+ /* TODO probe the hardware of what is supports */
depth_bits_array[0] = 0;
- depth_bits_array[1] = depth_bits;
- depth_bits_array[2] = depth_bits;
+ depth_bits_array[1] = 24;
+ depth_bits_array[2] = 24;
stencil_bits_array[0] = 0; /* no depth or stencil */
stencil_bits_array[1] = 0; /* z24x8 */
@@ -134,9 +132,10 @@ dri_fill_in_modes(__DRIscreenPrivate *psp,
msaa_samples_array[0] = 0;
depth_buffer_factor = 3;
- back_buffer_factor = 1;
+ back_buffer_factor = 3;
+ msaa_samples_factor = 1;
- num_modes = depth_buffer_factor * back_buffer_factor * 4;
+ num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
if (pixel_bits == 16) {
fb_format = GL_RGB;
@@ -148,85 +147,92 @@ dri_fill_in_modes(__DRIscreenPrivate *psp,
}
configs = driCreateConfigs(fb_format, fb_type,
- depth_bits_array,
- stencil_bits_array, depth_buffer_factor,
+ depth_bits_array,
+ stencil_bits_array, depth_buffer_factor,
back_buffer_modes, back_buffer_factor,
- msaa_samples_array, 1);
+ msaa_samples_array, msaa_samples_factor);
if (configs == NULL) {
debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__);
return NULL;
}
- return configs;
+ for (i = 0; configs[i]; i++) {
+ m = &configs[i]->modes;
+ if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return (const const __DRIconfig **) configs;
}
+/**
+ * Get information about previous buffer swaps.
+ */
+int
+dri_get_swap_info(__DRIdrawablePrivate * dPriv,
+ __DRIswapInfo * sInfo)
+{
+ if (dPriv == NULL ||
+ dPriv->driverPrivate == NULL ||
+ sInfo == NULL)
+ return -1;
+ else
+ return 0;
+}
-/* This is the driver specific part of the createNewScreen entry point.
- *
- * Returns the __GLcontextModes supported by this driver.
+
+/**
+ * NULL stub for old dri loaders
*/
-static const __DRIconfig **dri_init_screen(__DRIscreenPrivate *sPriv)
+const __DRIconfig **
+dri_init_screen(__DRIscreenPrivate *sPriv)
{
- static const __DRIversion ddx_expected = { 1, 6, 0 }; /* hw query */
- static const __DRIversion dri_expected = { 4, 0, 0 };
- static const __DRIversion drm_expected = { 1, 5, 0 }; /* hw query */
- struct dri_screen *screen;
+ return NULL;
+}
- if (!driCheckDriDdxDrmVersions2("dri",
- &sPriv->dri_version, &dri_expected,
- &sPriv->ddx_version, &ddx_expected,
- &sPriv->drm_version, &drm_expected)) {
- return NULL;
- }
- /* Set up dispatch table to cope with all known extensions:
- */
- driInitExtensions( NULL, card_extensions, GL_FALSE );
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ *
+ * Returns the __GLcontextModes supported by this driver.
+ */
+const __DRIconfig **
+dri_init_screen2(__DRIscreenPrivate *sPriv)
+{
+ struct dri_screen *screen;
+ /* Set up dispatch table to cope with all known extensions */
+ dri_init_extensions(NULL);
screen = CALLOC_STRUCT(dri_screen);
if (!screen)
goto fail;
screen->sPriv = sPriv;
+ screen->fd = sPriv->fd;
+ dri_get_drm_minor(screen);
+ dri_get_device_id(screen);
sPriv->private = (void *) screen;
+ sPriv->extensions = dri_screen_extensions;
- /* Search the registered winsys' for one that likes this sPriv.
- * This is required in situations where multiple devices speak to
- * the same DDX and are built into the same binary.
- *
- * Note that cases like Intel i915 vs i965 doesn't fall into this
- * category because they are built into separate binaries.
- *
- * Nonetheless, it's healthy to keep that level of detail out of
- * this state_tracker.
- */
- for (i = 0;
- i < dri1_winsys_count &&
- screen->st_winsys == NULL;
- i++)
- {
- screen->dri_winsys =
- dri_winsys[i]->check_dri_privates( sPriv->pDevPriv,
- sPriv->pSAREA
- /* versions, etc?? */));
+ screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, screen->deviceID);
+ if (!screen->pipe_screen) {
+ debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
+ goto fail;
}
-
+
+ /* We need to hook in here */
+ screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer;
driParseOptionInfo(&screen->optionCache,
- __driConfigOptions,
+ __driConfigOptions,
__driNConfigOptions);
-
- /* Plug our info back into the __DRIscreenPrivate:
- */
- sPriv->private = (void *) screen;
- sPriv->extensions = driScreenExtensions;
-
- return dri_fill_in_modes(sPriv,
- dri_priv->cpp * 8,
+ return dri_fill_in_modes(sPriv,
+ 4 * 8,
24,
8,
1);
@@ -235,21 +241,32 @@ fail:
}
+void
+dri_destroy_screen(__DRIscreenPrivate * sPriv)
+{
+ struct dri_screen *screen = dri_screen(sPriv);
+
+ screen->pipe_screen->destroy(screen->pipe_screen);
+ FREE(screen);
+ sPriv->private = NULL;
+}
-const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = dri_init_screen,
- .DestroyScreen = dri_destroy_screen,
- .CreateContext = dri_create_context,
- .DestroyContext = dri_destroy_context,
- .CreateBuffer = dri_create_buffer,
- .DestroyBuffer = dri_destroy_buffer,
- .SwapBuffers = dri_swap_buffers,
- .MakeCurrent = dri_make_current,
- .UnbindContext = dri_unbind_context,
- .GetSwapInfo = dri_get_swap_info,
- .GetDrawableMSC = driDrawableGetMSC32,
- .WaitForMSC = driWaitForMSC32,
- .CopySubBuffer = dri_copy_sub_buffer,
- //.InitScreen2 = dri_init_screen2,
+PUBLIC const struct __DriverAPIRec driDriverAPI = {
+ .InitScreen = dri_init_screen, /* not supported but exported */
+ .DestroyScreen = dri_destroy_screen,
+ .CreateContext = dri_create_context,
+ .DestroyContext = dri_destroy_context,
+ .CreateBuffer = dri_create_buffer,
+ .DestroyBuffer = dri_destroy_buffer,
+ .SwapBuffers = dri_swap_buffers, /* not supported but exported */
+ .MakeCurrent = dri_make_current,
+ .UnbindContext = dri_unbind_context,
+ .GetSwapInfo = dri_get_swap_info,
+ .GetDrawableMSC = driDrawableGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */
+ .InitScreen2 = dri_init_screen2,
};
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/glx/dri/dri_screen.h b/src/gallium/state_trackers/dri2/dri_screen.h
index 12ed86d22a..fe2676d0be 100644
--- a/src/gallium/state_trackers/glx/dri/dri_screen.h
+++ b/src/gallium/state_trackers/dri2/dri_screen.h
@@ -18,12 +18,16 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.
*
**************************************************************************/
+/*
+ * Author: Keith Whitwell <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
#ifndef DRI_SCREEN_H
#define DRI_SCREEN_H
@@ -35,27 +39,8 @@
struct dri_screen
{
- __DRIScreenPrivate *sPriv;
- struct pipe_winsys *pipe_winsys;
- struct pipe_screen *pipe_screen;
-
- struct {
- /* Need a pipe_surface pointer to do client-side swapbuffers:
- */
- unsigned long buffer_handle;
- struct pipe_surface *surface;
- struct pipe_texture *texture;
-
- int pitch; /* row stride, in bytes */
- int width;
- int height;
- int size;
- int cpp; /* for front and back buffers */
- } front;
-
- int deviceID;
- int drmMinor;
-
+ /* dri */
+ __DRIscreenPrivate *sPriv;
/**
* Configuration cache with default values for all contexts
@@ -67,8 +52,16 @@ struct dri_screen
* which we need a rendering context, but none is currently bound.
*/
struct dri_context *dummyContext;
-};
+ /* drm */
+ int deviceID;
+ int fd;
+ int minor;
+
+ /* gallium */
+ struct pipe_winsys *pipe_winsys;
+ struct pipe_screen *pipe_screen;
+};
/** cast wrapper */
@@ -79,5 +72,19 @@ dri_screen(__DRIscreenPrivate *sPriv)
}
+/***********************************************************************
+ * dri_screen.c
+ */
+const __DRIconfig **
+dri_init_screen2(__DRIscreenPrivate *sPriv);
+
+void
+dri_destroy_screen(__DRIscreenPrivate * sPriv);
+
+int
+dri_get_swap_info(__DRIdrawablePrivate * dPriv,
+ __DRIswapInfo * sInfo);
#endif
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile
index c9124b1c90..692a3c8b76 100644
--- a/src/gallium/state_trackers/egl/Makefile
+++ b/src/gallium/state_trackers/egl/Makefile
@@ -6,15 +6,15 @@ TOP = ../../../..
include ${TOP}/configs/current
-CFLAGS += -g -Wall -Werror=implicit-function-declaration -fPIC \
+CFLAGS := \
-I${GALLIUMDIR}/include \
-I${GALLIUMDIR}/auxiliary \
-I${TOP}/src/mesa/drivers/dri/common \
-I${TOP}/src/mesa \
-I$(TOP)/include \
-I$(TOP)/src/egl/main \
- $(shell pkg-config --cflags pixman-1 xorg-server) \
- ${LIBDRM_CFLAGS}
+ ${LIBDRM_CFLAGS} \
+ ${CFLAGS}
#############################################
diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c
index 8564972b91..36548fae26 100644
--- a/src/gallium/state_trackers/egl/egl_context.c
+++ b/src/gallium/state_trackers/egl/egl_context.c
@@ -115,7 +115,7 @@ drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext
_eglInitContext(drv, dpy, &ctx->base, config, attrib_list);
- ctx->pipe = drm_api_hocks.create_context(dev->screen);
+ ctx->pipe = drm_api_hooks.create_context(dev->screen);
if (!ctx->pipe)
goto err_pipe;
diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c
index 091d437d81..e6e80b985a 100644
--- a/src/gallium/state_trackers/egl/egl_surface.c
+++ b/src/gallium/state_trackers/egl/egl_surface.c
@@ -16,11 +16,11 @@
* Util functions
*/
-static struct drm_mode_modeinfo *
+static drmModeModeInfoPtr
drm_find_mode(drmModeConnectorPtr connector, _EGLMode *mode)
{
int i;
- struct drm_mode_modeinfo *m = NULL;
+ drmModeModeInfoPtr m = NULL;
for (i = 0; i < connector->count_modes; i++) {
m = &connector->modes[i];
@@ -132,7 +132,7 @@ drm_create_texture(_EGLDriver *drv,
scrn->front.width = w;
scrn->front.height = h;
scrn->front.pitch = pitch;
- scrn->front.handle = drm_api_hocks.handle_from_buffer(dev->winsys, scrn->buffer);
+ drm_api_hooks.handle_from_buffer(screen, scrn->buffer, &scrn->front.handle);
if (0)
goto err_handle;
@@ -143,7 +143,7 @@ err_handle:
err_surf:
pipe_texture_reference(&texture, NULL);
err_tex:
- pipe_buffer_reference(screen, &buf, NULL);
+ pipe_buffer_reference(&buf, NULL);
err_buf:
return;
}
@@ -173,7 +173,7 @@ drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen)
pipe_surface_reference(&screen->surface, NULL);
pipe_texture_reference(&screen->tex, NULL);
- pipe_buffer_reference(dev->screen, &screen->buffer, NULL);
+ pipe_buffer_reference(&screen->buffer, NULL);
screen->shown = 0;
}
@@ -271,7 +271,6 @@ drm_show_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy,
struct drm_device *dev = (struct drm_device *)drv;
struct drm_surface *surf = lookup_drm_surface(surface);
struct drm_screen *scrn = lookup_drm_screen(dpy, screen);
- struct pipe_context *pipe;
_EGLMode *mode = _eglLookupMode(dpy, m);
int ret;
unsigned int i, k;
@@ -349,7 +348,7 @@ err_fb:
err_bo:
pipe_surface_reference(&scrn->surface, NULL);
pipe_texture_reference(&scrn->tex, NULL);
- pipe_buffer_reference(dev->screen, &scrn->buffer, NULL);
+ pipe_buffer_reference(&scrn->buffer, NULL);
return EGL_FALSE;
}
@@ -392,7 +391,6 @@ drm_swap_buffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw)
if (surf->screen) {
surf->user->pipe->flush(surf->user->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
surf->user->pipe->surface_copy(surf->user->pipe,
- 0,
surf->screen->surface,
0, 0,
back_surf,
diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c
index dec82c3a00..a22ef381b9 100644
--- a/src/gallium/state_trackers/egl/egl_tracker.c
+++ b/src/gallium/state_trackers/egl/egl_tracker.c
@@ -92,7 +92,7 @@ drm_update_res(struct drm_device *dev)
static void
drm_add_modes_from_connector(_EGLScreen *screen, drmModeConnectorPtr connector)
{
- struct drm_mode_modeinfo *m;
+ drmModeModeInfoPtr m = NULL;
int i;
for (i = 0; i < connector->count_modes; i++) {
@@ -121,7 +121,7 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
dev->drmFD = fd;
drm_get_device_id(dev);
- dev->screen = drm_api_hocks.create_screen(dev->drmFD, dev->deviceID);
+ dev->screen = drm_api_hooks.create_screen(dev->drmFD, dev->deviceID);
if (!dev->screen)
goto err_screen;
dev->winsys = dev->screen->winsys;
diff --git a/src/gallium/state_trackers/egl/egl_tracker.h b/src/gallium/state_trackers/egl/egl_tracker.h
index 0b4dd9797d..908bab5f9b 100644
--- a/src/gallium/state_trackers/egl/egl_tracker.h
+++ b/src/gallium/state_trackers/egl/egl_tracker.h
@@ -128,7 +128,7 @@ struct drm_screen
/*drmModeCrtcPtr crtc;*/
uint32_t crtcID;
- struct drm_mode_modeinfo *mode;
+ drmModeModeInfoPtr mode;
};
diff --git a/src/gallium/state_trackers/g3dvl/Makefile b/src/gallium/state_trackers/g3dvl/Makefile
index cddfca54fe..f9f4d6be3c 100644
--- a/src/gallium/state_trackers/g3dvl/Makefile
+++ b/src/gallium/state_trackers/g3dvl/Makefile
@@ -3,7 +3,7 @@ OBJECTS = vl_display.o vl_screen.o vl_context.o vl_surface.o vl_shader_build.o
vl_r16snorm_mc_buf.o
GALLIUMDIR = ../..
-CFLAGS += -g -Wall -Werror=implicit-function-declaration -fPIC \
+CFLAGS += -g -Wall -Werror-implicit-function-declaration -fPIC \
-I${GALLIUMDIR}/include \
-I${GALLIUMDIR}/auxiliary \
-I${GALLIUMDIR}/winsys/g3dvl \
diff --git a/src/gallium/state_trackers/g3dvl/vl_basic_csc.c b/src/gallium/state_trackers/g3dvl/vl_basic_csc.c
index 187a13a560..b61b49a2f8 100644
--- a/src/gallium/state_trackers/g3dvl/vl_basic_csc.c
+++ b/src/gallium/state_trackers/g3dvl/vl_basic_csc.c
@@ -237,10 +237,10 @@ static int vlDestroy
pipe->delete_fs_state(pipe, basic_csc->fragment_shader);
for (i = 0; i < 2; ++i)
- pipe_buffer_reference(pipe->screen, &basic_csc->vertex_bufs[i].buffer, NULL);
+ pipe_buffer_reference(&basic_csc->vertex_bufs[i].buffer, NULL);
- pipe_buffer_reference(pipe->screen, &basic_csc->vs_const_buf.buffer, NULL);
- pipe_buffer_reference(pipe->screen, &basic_csc->fs_const_buf.buffer, NULL);
+ pipe_buffer_reference(&basic_csc->vs_const_buf.buffer, NULL);
+ pipe_buffer_reference(&basic_csc->fs_const_buf.buffer, NULL);
FREE(basic_csc);
@@ -371,7 +371,7 @@ static int vlCreateVertexShader
unsigned int ti;
unsigned int i;
- assert(context);
+ assert(csc);
pipe = csc->pipe;
tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
@@ -458,7 +458,7 @@ static int vlCreateFragmentShader
unsigned int ti;
unsigned int i;
- assert(context);
+ assert(csc);
pipe = csc->pipe;
tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
diff --git a/src/gallium/state_trackers/g3dvl/vl_context.c b/src/gallium/state_trackers/g3dvl/vl_context.c
index 65ddb9f01e..1d8ad0b046 100644
--- a/src/gallium/state_trackers/g3dvl/vl_context.c
+++ b/src/gallium/state_trackers/g3dvl/vl_context.c
@@ -41,9 +41,7 @@ static int vlInitCommon(struct vlContext *context)
rast.line_stipple_factor = 0;
rast.line_stipple_pattern = 0;
rast.line_last_pixel = 0;
- /* Don't need clipping, but viewport mapping done here */
- rast.bypass_clipping = 0;
- rast.bypass_vs = 0;
+ rast.bypass_vs_clip_and_viewport = 0;
rast.origin_lower_left = 0;
rast.line_width = 1;
rast.point_smooth = 0;
diff --git a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c
index 2176bb86d8..eb8270ecad 100644
--- a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c
+++ b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c
@@ -66,7 +66,7 @@ struct vlR16SnormBufferedMC
struct vlVertex2f zero_block[3];
unsigned int num_macroblocks;
struct vlMpeg2MacroBlock *macroblocks;
- struct pipe_surface *tex_surface[3];
+ struct pipe_transfer *tex_transfer[3];
short *texels[3];
struct pipe_context *pipe;
@@ -187,7 +187,7 @@ static inline int vlGrabBlocks
assert(mc);
assert(blocks);
- tex_pitch = mc->tex_surface[0]->stride / mc->tex_surface[0]->block.size;
+ tex_pitch = mc->tex_transfer[0]->stride / mc->tex_transfer[0]->block.size;
texels = mc->texels[0] + mbpy * tex_pitch + mbpx;
for (y = 0; y < 2; ++y)
@@ -235,7 +235,7 @@ static inline int vlGrabBlocks
for (tb = 0; tb < 2; ++tb)
{
- tex_pitch = mc->tex_surface[tb + 1]->stride / mc->tex_surface[tb + 1]->block.size;
+ tex_pitch = mc->tex_transfer[tb + 1]->stride / mc->tex_transfer[tb + 1]->block.size;
texels = mc->texels[tb + 1] + mbpy * tex_pitch + mbpx;
if ((coded_block_pattern >> (1 - tb)) & 1)
@@ -635,8 +635,8 @@ static int vlFlush
for (i = 0; i < 3; ++i)
{
- pipe_surface_unmap(mc->tex_surface[i]);
- pipe_surface_reference(&mc->tex_surface[i], NULL);
+ pipe->screen->transfer_unmap(pipe->screen, mc->tex_transfer[i]);
+ pipe->screen->tex_transfer_destroy(mc->tex_transfer[i]);
}
mc->render_target.cbufs[0] = pipe->screen->get_tex_surface
@@ -809,14 +809,16 @@ static int vlRenderMacroBlocksMpeg2R16SnormBuffered
for (i = 0; i < 3; ++i)
{
- mc->tex_surface[i] = mc->pipe->screen->get_tex_surface
+ mc->tex_transfer[i] = mc->pipe->screen->get_tex_transfer
(
mc->pipe->screen,
mc->textures.all[i],
- 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
+ 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0,
+ surface->texture->width[0],
+ surface->texture->height[0]
);
- mc->texels[i] = pipe_surface_map(mc->tex_surface[i], PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD);
+ mc->texels[i] = mc->pipe->screen->transfer_map(mc->pipe->screen, mc->tex_transfer[i]);
}
}
@@ -854,7 +856,7 @@ static int vlDestroy
pipe->delete_sampler_state(pipe, mc->samplers.all[i]);
for (i = 0; i < 3; ++i)
- pipe_buffer_reference(pipe->screen, &mc->vertex_bufs.all[i].buffer, NULL);
+ pipe_buffer_reference(&mc->vertex_bufs.all[i].buffer, NULL);
/* Textures 3 & 4 are not created directly, no need to release them here */
for (i = 0; i < 3; ++i)
@@ -871,8 +873,8 @@ static int vlDestroy
pipe->delete_fs_state(pipe, mc->b_fs[i]);
}
- pipe_buffer_reference(pipe->screen, &mc->vs_const_buf.buffer, NULL);
- pipe_buffer_reference(pipe->screen, &mc->fs_const_buf.buffer, NULL);
+ pipe_buffer_reference(&mc->vs_const_buf.buffer, NULL);
+ pipe_buffer_reference(&mc->fs_const_buf.buffer, NULL);
FREE(mc->macroblocks);
FREE(mc);
diff --git a/src/gallium/state_trackers/glx/dri/dri_drawable.c b/src/gallium/state_trackers/glx/dri/dri_drawable.c
deleted file mode 100644
index b712acda88..0000000000
--- a/src/gallium/state_trackers/glx/dri/dri_drawable.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "dri_screen.h"
-#include "dri_context.h"
-#include "dri_swapbuffers.h"
-
-#include "pipe/p_context.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_cb_fbo.h"
-
-
-static void
-blit_swapbuffers(__DRIdrawablePrivate *dPriv,
- __DRIcontextPrivate *cPriv,
- struct pipe_surface *src,
- const drm_clip_rect_t *rect)
-{
- struct dri_screen *screen = dri_screen(dPriv->driScreenPriv);
- struct dri_drawable *fb = dri_drawable(dPriv);
- struct dri_context *context = dri_context(cPriv);
-
- const int nbox = dPriv->numClipRects;
- const drm_clip_rect_t *pbox = dPriv->pClipRects;
-
- struct pipe_surface *dest = fb->front_surface;
- const int backWidth = fb->stfb->Base.Width;
- const int backHeight = fb->stfb->Base.Height;
- int i;
-
- for (i = 0; i < nbox; i++, pbox++) {
- drm_clip_rect_t box;
- drm_clip_rect_t sbox;
-
- if (pbox->x1 > pbox->x2 ||
- pbox->y1 > pbox->y2 ||
- (pbox->x2 - pbox->x1) > dest->width ||
- (pbox->y2 - pbox->y1) > dest->height)
- continue;
-
- box = *pbox;
-
- if (rect) {
- drm_clip_rect_t rrect;
-
- rrect.x1 = dPriv->x + rect->x1;
- rrect.y1 = (dPriv->h - rect->y1 - rect->y2) + dPriv->y;
- rrect.x2 = rect->x2 + rrect.x1;
- rrect.y2 = rect->y2 + rrect.y1;
- if (rrect.x1 > box.x1)
- box.x1 = rrect.x1;
- if (rrect.y1 > box.y1)
- box.y1 = rrect.y1;
- if (rrect.x2 < box.x2)
- box.x2 = rrect.x2;
- if (rrect.y2 < box.y2)
- box.y2 = rrect.y2;
-
- if (box.x1 > box.x2 || box.y1 > box.y2)
- continue;
- }
-
- /* restrict blit to size of actually rendered area */
- if (box.x2 - box.x1 > backWidth)
- box.x2 = backWidth + box.x1;
- if (box.y2 - box.y1 > backHeight)
- box.y2 = backHeight + box.y1;
-
- debug_printf("%s: box %d,%d-%d,%d\n", __FUNCTION__,
- box.x1, box.y1, box.x2, box.y2);
-
- sbox.x1 = box.x1 - dPriv->x;
- sbox.y1 = box.y1 - dPriv->y;
-
- ctx->st->pipe->surface_copy( ctx->st->pipe,
- FALSE,
- dest,
- box.x1, box.y1,
- src,
- sbox.x1, sbox.y1,
- box.x2 - box.x1,
- box.y2 - box.y1 );
- }
-}
-
-/**
- * Display a colorbuffer surface in an X window.
- * Used for SwapBuffers and flushing front buffer rendering.
- *
- * \param dPriv the window/drawable to display into
- * \param surf the surface to display
- * \param rect optional subrect of surface to display (may be NULL).
- */
-static void
-dri_display_surface(__DRIdrawablePrivate *dPriv,
- struct pipe_surface *source,
- const drm_clip_rect_t *rect)
-{
- struct dri_drawable *drawable = dri_drawable(dPriv);
- struct dri_screen *screen = dri_screen(dPriv->driScreenPriv);
- struct dri_context *context = screen->dummy_context;
- struct pipe_winsys *winsys = screen->winsys;
-
- if (!context)
- return;
-
- if (drawable->last_swap_fence) {
- winsys->fence_finish( winsys,
- drawable->last_swap_fence,
- 0 );
-
- winsys->fence_reference( winsys,
- &drawable->last_swap_fence,
- NULL );
- }
-
- drawable->last_swap_fence = drawable->first_swap_fence;
- drawable->first_swap_fence = NULL;
-
- /* Call lock_hardware to update dPriv cliprects.
- */
- dri_lock_hardware(context, drawable);
- {
- if (dPriv->numClipRects) {
- blit_swapbuffers( context, dPriv, source, rect );
- }
- }
- dri_unlock_hardware(context);
-
- if (drawble->stamp != drawable->dPriv->lastStamp) {
- dri_update_window_size( dpriv );
- }
-}
-
-
-
-/**
- * This will be called a drawable is known to have moved/resized.
- */
-void
-dri_update_window_size(__DRIdrawablePrivate *dPriv)
-{
- struct dri_drawable *drawable = dri_drawable(dPriv);
- st_resize_framebuffer(drawable->stfb, dPriv->w, dPriv->h);
- drawable->stamp = dPriv->lastStamp;
-}
-
-
-
-void
-dri_swap_buffers(__DRIdrawablePrivate * dPriv)
-{
- struct dri_drawable *drawable = dri_drawable(dPriv);
- struct pipe_surface *back_surf;
-
- assert(drawable);
- assert(drawable->stfb);
-
- back_surf = st_get_framebuffer_surface(drawable->stfb,
- ST_SURFACE_BACK_LEFT);
- if (back_surf) {
- st_notify_swapbuffers(drawable->stfb);
- dri_display_surface(dPriv, back_surf, NULL);
- st_notify_swapbuffers_complete(drawable->stfb);
- }
-}
-
-
-/**
- * Called via glXCopySubBufferMESA() to copy a subrect of the back
- * buffer to the front buffer/screen.
- */
-void
-dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
-{
- struct dri_drawable *drawable = dri_drawable(dPriv);
- struct pipe_surface *back_surf;
-
- assert(drawable);
- assert(drawable->stfb);
-
- back_surf = st_get_framebuffer_surface(drawable->stfb,
- ST_SURFACE_BACK_LEFT);
- if (back_surf) {
- drm_clip_rect_t rect;
- rect.x1 = x;
- rect.y1 = y;
- rect.x2 = w;
- rect.y2 = h;
-
- st_notify_swapbuffers(drawable->stfb);
- dri_display_surface(dPriv, back_surf, &rect);
- }
-}
-
-
-
-/*
- * The state tracker keeps track of whether the fake frontbuffer has
- * been touched by any rendering since the last time we copied its
- * contents to the real frontbuffer. Our task is easy:
- */
-static void
-dri_flush_frontbuffer( struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
-{
- struct dri_context *dri = (struct dri_context *) context_private;
- __DRIdrawablePrivate *dPriv = dri->driDrawable;
-
- dri_display_surface(dPriv, surf, NULL);
-}
-
-
-
-/* Need to create a surface which wraps the front surface to support
- * client-side swapbuffers.
- */
-static void
-dri_create_front_surface(struct dri_screen *screen,
- struct pipe_winsys *winsys,
- unsigned handle)
-{
- struct pipe_screen *pipe_screen = screen->pipe_screen;
- struct pipe_texture *texture;
- struct pipe_texture templat;
- struct pipe_surface *surface;
- struct pipe_buffer *buffer;
- unsigned pitch;
-
- assert(screen->front.cpp == 4);
-
-// buffer = dri_buffer_from_handle(screen->winsys,
-// "front", handle);
-
- if (!buffer)
- return;
-
- screen->front.buffer = dri_bo(buffer);
-
- memset(&templat, 0, sizeof(templat));
- templat.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
- templat.target = PIPE_TEXTURE_2D;
- templat.last_level = 0;
- templat.depth[0] = 1;
- templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
- templat.width[0] = screen->front.width;
- templat.height[0] = screen->front.height;
- pf_get_block(templat.format, &templat.block);
- pitch = screen->front.pitch;
-
- texture = pipe_screen->texture_blanket(pipe_screen,
- &templat,
- &pitch,
- buffer);
-
- /* Unref the buffer we don't need it anyways */
- pipe_buffer_reference(screen, &buffer, NULL);
-
- surface = pipe_screen->get_tex_surface(pipe_screen,
- texture,
- 0,
- 0,
- 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
- screen->front.texture = texture;
- screen->front.surface = surface;
-}
-
-/**
- * This is called when we need to set up GL rendering to a new X window.
- */
-static boolean
-dri_create_buffer(__DRIscreenPrivate *sPriv,
- __DRIdrawablePrivate *dPriv,
- const __GLcontextModes *visual,
- boolean isPixmap)
-{
- enum pipe_format colorFormat, depthFormat, stencilFormat;
- struct dri_drawable *drawable;
-
- if (isPixmap)
- goto fail; /* not implemented */
-
- drawable = CALLOC_STRUCT(dri_drawable);
- if (drawable == NULL)
- goto fail;
-
- /* XXX: todo: use the pipe_screen queries to figure out which
- * render targets are supportable.
- */
- if (visual->redBits == 5)
- colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
- else
- colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
-
- if (visual->depthBits == 16)
- depthFormat = PIPE_FORMAT_Z16_UNORM;
- else if (visual->depthBits == 24) {
- if (visual->stencilBits == 8)
- depthFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
- depthFormat = PIPE_FORMAT_X8Z24_UNORM;
- }
-
- drawable->stfb = st_create_framebuffer(visual,
- colorFormat,
- depthFormat,
- dPriv->w,
- dPriv->h,
- (void*) drawable);
- if (drawable->stfb == NULL)
- goto fail;
-
- dPriv->driverPrivate = (void *) drawable;
- return GL_TRUE;
-
-fail:
- FREE(drawable);
- return GL_FALSE;
-}
-
-static void
-dri_destroy_buffer(__DRIdrawablePrivate *dPriv)
-{
- struct dri_drawable *drawable = dri_drawable(dPriv);
-
- /* No particular need to wait on fences before dereferencing them:
- */
- winsys->fence_reference( winsys, &ctx->last_swap_fence, NULL );
- winsys->fence_reference( winsys, &ctx->first_swap_fence, NULL );
-
- st_unreference_framebuffer(drawable->stfb);
-
- FREE(drawable);
-}
-
diff --git a/src/gallium/state_trackers/glx/dri/dri_lock.c b/src/gallium/state_trackers/glx/dri/dri_lock.c
deleted file mode 100644
index b272ab55f3..0000000000
--- a/src/gallium/state_trackers/glx/dri/dri_lock.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "pipe/p_thread.h"
-#include "dri_context.h"
-#include "xf86drm.h"
-
-pipe_static_mutex( lockMutex );
-
-static void
-dri_contended_lock(struct dri_context *ctx)
-{
- __DRIdrawablePrivate *dPriv = ctx->dPriv;
- __DRIcontextPrivate *cPriv = ctx->cPriv;
- __DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
-
- drmGetLock(sPriv->fd, cPriv->hHWContext, 0);
-
- /* Perform round trip communication with server (including dropping
- * and retaking the above lock) to update window dimensions:
- */
- if (dPriv)
- DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
-}
-
-
-/* Lock the hardware and validate our state.
- */
-void dri_lock_hardware( struct dri_context *ctx )
-{
- __DRIcontextPrivate *cPriv = ctx->cPriv;
- __DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
- char __ret = 0;
-
- pipe_mutex_lock(lockMutex);
- assert(!ctx->locked);
-
- DRM_CAS((drmLock *) &sPriv->pSAREA->lock,
- cPriv->hHWContext,
- (DRM_LOCK_HELD | cPriv->hHWContext),
- __ret);
-
- if (__ret)
- dri_contended_lock( ctx );
-
- ctx->locked = TRUE;
-}
-
-
-/* Unlock the hardware using the global current context
- */
-void dri_unlock_hardware( struct dri_context *ctx )
-{
- __DRIcontextPrivate *cPriv = ctx->cPriv;
- __DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
-
- assert(ctx->locked);
- ctx->locked = FALSE;
-
- DRM_UNLOCK(sPriv->fd,
- (drmLock *) &sPriv->pSAREA->lock,
- cPriv->hHWContext);
-
- pipe_mutex_unlock(lockMutex);
-}
diff --git a/src/gallium/state_trackers/glx/xlib/Makefile b/src/gallium/state_trackers/glx/xlib/Makefile
index 1b63db1f0e..6d10b090aa 100644
--- a/src/gallium/state_trackers/glx/xlib/Makefile
+++ b/src/gallium/state_trackers/glx/xlib/Makefile
@@ -3,23 +3,15 @@ include $(TOP)/configs/current
LIBNAME = xlib
-
-DRIVER_INCLUDES = \
+LIBRARY_INCLUDES = \
-I$(TOP)/include \
-I$(TOP)/src/mesa \
- -I$(TOP)/src/mesa/main \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/auxiliary
+ -I$(TOP)/src/mesa/main
C_SOURCES = \
- glxapi.c \
- fakeglx.c \
- fakeglx_fonts.c \
+ glxapi.c \
+ fakeglx.c \
+ fakeglx_fonts.c \
xm_api.c
-
include ../../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/state_trackers/glx/xlib/SConscript b/src/gallium/state_trackers/glx/xlib/SConscript
index 14cdad69cb..0dbe341397 100644
--- a/src/gallium/state_trackers/glx/xlib/SConscript
+++ b/src/gallium/state_trackers/glx/xlib/SConscript
@@ -5,8 +5,7 @@ Import('*')
if env['platform'] == 'linux' \
and 'mesa' in env['statetrackers'] \
- and ('softpipe' or 'i915simple' or 'trace') in env['drivers'] \
- and not env['dri']:
+ and ('softpipe' or 'i915simple' or 'trace') in env['drivers']:
env = env.Clone()
@@ -15,6 +14,8 @@ if env['platform'] == 'linux' \
'#/src/mesa/main',
])
+ env.Append(CPPDEFINES = ['USE_XSHM'])
+
st_xlib = env.ConvenienceLibrary(
target = 'st_xlib',
source = [ 'glxapi.c',
diff --git a/src/gallium/state_trackers/glx/xlib/glxapi.c b/src/gallium/state_trackers/glx/xlib/glxapi.c
index 1ff04804f1..c2cb34d7cf 100644
--- a/src/gallium/state_trackers/glx/xlib/glxapi.c
+++ b/src/gallium/state_trackers/glx/xlib/glxapi.c
@@ -34,13 +34,21 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include "main/glheader.h"
#include "glapi/glapi.h"
#include "glxapi.h"
#include "fakeglx.h"
#include "pipe/p_thread.h"
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+# define PUBLIC __attribute__((visibility("default")))
+# define USED __attribute__((used))
+#else
+# define PUBLIC
+# define USED
+#endif
+
+
struct display_dispatch {
Display *Dpy;
struct _glxapi_table *Table;
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 33dc044ad5..a3d1651653 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -458,7 +458,7 @@ xmesa_free_buffer(XMesaBuffer buffer)
XDestroyImage(buffer->tempImage);
/* Unreference. If count = zero we'll really delete the buffer */
- _mesa_unreference_framebuffer(&fb);
+ _mesa_reference_framebuffer(&fb, NULL);
XFreeGC(b->xm_visual->display, b->gc);
@@ -763,7 +763,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
c->xm_visual = v;
c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
-
+ c->xm_read_buffer = NULL;
+
/* XXX: create once per Xlib Display.
*/
screen = driver.create_pipe_screen();
@@ -1037,27 +1038,25 @@ PUBLIC
GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
XMesaBuffer readBuffer )
{
+ XMesaContext old_ctx = XMesaGetCurrentContext();
+
+ if (old_ctx && old_ctx != c) {
+ XMesaFlush(old_ctx);
+ old_ctx->xm_buffer = NULL;
+ old_ctx->xm_read_buffer = NULL;
+ }
+
if (c) {
if (!drawBuffer || !readBuffer)
return GL_FALSE; /* must specify buffers! */
-#if 0
- /* XXX restore this optimization */
- if (&(c->mesa) == _mesa_get_current_context()
- && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer
- && c->mesa.ReadBuffer == &readBuffer->mesa_buffer
- && xmesa_buffer(c->mesa.DrawBuffer)->wasCurrent) {
- /* same context and buffer, do nothing */
- return GL_TRUE;
- }
-#endif
+ if (c == old_ctx &&
+ c->xm_buffer == drawBuffer &&
+ c->xm_read_buffer == readBuffer)
+ return GL_TRUE;
c->xm_buffer = drawBuffer;
-
- /* Call this periodically to detect when the user has begun using
- * GL rendering from multiple threads.
- */
- _glapi_check_multithread();
+ c->xm_read_buffer = readBuffer;
st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb);
@@ -1071,6 +1070,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
else {
/* Detach */
st_make_current( NULL, NULL, NULL );
+
}
return GL_TRUE;
}
@@ -1143,7 +1143,6 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
return;
pipe->surface_copy(pipe,
- FALSE,
surf_front, x, y, /* dest */
surf_back, x, y, /* src */
width, height);
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h
index 2b8302d174..bdd434cd36 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
@@ -295,6 +295,7 @@ struct xmesa_context {
struct st_context *st;
XMesaVisual xm_visual; /** pixel format info */
XMesaBuffer xm_buffer; /** current drawbuffer */
+ XMesaBuffer xm_read_buffer; /** current readbuffer */
};
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index f4c4b36ea7..79e68de1df 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -42,13 +42,15 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
-#include "util/u_memory.h"
-#include "pipe/p_shader_tokens.h"
+#include "pipe/p_shader_tokens.h"
+#include "pipe/internal/p_winsys_screen.h"
#include "cso_cache/cso_context.h"
-#include "util/u_draw_quad.h"
-#include "util/u_tile.h"
-#include "tgsi/tgsi_text.h"
-#include "tgsi/tgsi_dump.h"
+#include "util/u_draw_quad.h"
+#include "util/u_tile.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "tgsi/tgsi_text.h"
+#include "tgsi/tgsi_dump.h"
#include "st_device.h"
#include "st_sample.h"
@@ -93,7 +95,7 @@
%include "p_compiler.i"
-%include "pipe/p_defines.h";
+%include "p_defines.h";
%include "p_format.i"
%include "p_device.i"
diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i
index 7b8b64b592..1fdbdf98b2 100644
--- a/src/gallium/state_trackers/python/p_context.i
+++ b/src/gallium/state_trackers/python/p_context.i
@@ -121,7 +121,6 @@ struct st_context {
struct pipe_constant_buffer state;
memset(&state, 0, sizeof(state));
state.buffer = buffer ? buffer->buffer : NULL;
- state.size = buffer->buffer->size;
$self->pipe->set_constant_buffer($self->pipe, shader, index, &state);
}
@@ -161,7 +160,7 @@ struct st_context {
struct pipe_vertex_buffer state;
memset(&state, 0, sizeof(state));
- state.pitch = pitch;
+ state.stride = pitch;
state.max_index = max_index;
state.buffer_offset = buffer_offset;
state.buffer = buffer ? buffer->buffer : NULL;
@@ -248,7 +247,7 @@ struct st_context {
util_draw_vertex_buffer(pipe, vbuf, 0, prim, num_verts, num_attribs);
error2:
- pipe_buffer_reference(screen, &vbuf, NULL);
+ pipe_buffer_reference(&vbuf, NULL);
error1:
;
}
@@ -266,13 +265,12 @@ error1:
* Surface functions
*/
- void surface_copy(int do_flip,
- struct pipe_surface *dest,
+ void surface_copy(struct pipe_surface *dest,
unsigned destx, unsigned desty,
struct pipe_surface *src,
unsigned srcx, unsigned srcy,
unsigned width, unsigned height) {
- $self->pipe->surface_copy($self->pipe, do_flip, dest, destx, desty, src, srcx, srcy, width, height);
+ $self->pipe->surface_copy($self->pipe, dest, destx, desty, src, srcx, srcy, width, height);
}
void surface_fill(struct pipe_surface *dst,
diff --git a/src/gallium/state_trackers/python/p_state.i b/src/gallium/state_trackers/python/p_state.i
index 7f5760b3b6..110b3d5da4 100644
--- a/src/gallium/state_trackers/python/p_state.i
+++ b/src/gallium/state_trackers/python/p_state.i
@@ -37,6 +37,7 @@
%ignore winsys;
%ignore pipe_vertex_buffer::buffer;
+%include "pipe/p_compiler.h";
%include "pipe/p_state.h";
diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i
index 08ba0ebe4d..1e64fc8e41 100644
--- a/src/gallium/state_trackers/python/p_texture.i
+++ b/src/gallium/state_trackers/python/p_texture.i
@@ -121,6 +121,50 @@
pipe_put_tile_rgba($self, x, y, w, h, rgba);
}
+ %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
+ void
+ get_tile_rgba8(unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH)
+ {
+ unsigned surface_usage;
+ float *rgba;
+ unsigned char *rgba8;
+ unsigned i, j, k;
+
+ *LENGTH = 0;
+ *STRING = NULL;
+
+ if (!$self)
+ return;
+
+ *LENGTH = h*w*4;
+ *STRING = (char *) malloc(*LENGTH);
+ if(!*STRING)
+ return;
+
+ rgba = malloc(w*4*sizeof(float));
+ if(!rgba)
+ return;
+
+ rgba8 = (unsigned char *) *STRING;
+
+ /* XXX: force mappable surface */
+ surface_usage = $self->usage;
+ $self->usage |= PIPE_BUFFER_USAGE_CPU_READ;
+
+ for(j = 0; j < h; ++j) {
+ pipe_get_tile_rgba($self,
+ x, y + j, w, 1,
+ rgba);
+ for(i = 0; i < w; ++i)
+ for(k = 0; k <4; ++k)
+ rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[i*4 + k]);
+ }
+
+ $self->usage = surface_usage;
+
+ free(rgba);
+ }
+
void
get_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, unsigned *z) {
pipe_get_tile_z($self, x, y, w, h, z);
@@ -181,7 +225,7 @@ struct st_buffer {
unsigned __len__(void)
{
- assert($self->buffer->refcount);
+ assert(p_atomic_read(&$self->buffer->reference.count) > 0);
return $self->buffer->size;
}
@@ -191,7 +235,7 @@ struct st_buffer {
struct pipe_screen *screen = $self->st_dev->screen;
const char *map;
- assert($self->buffer->refcount);
+ assert(p_atomic_read(&$self->buffer->reference.count) > 0);
*LENGTH = $self->buffer->size;
*STRING = (char *) malloc($self->buffer->size);
@@ -211,7 +255,7 @@ struct st_buffer {
struct pipe_screen *screen = $self->st_dev->screen;
char *map;
- assert($self->buffer->refcount);
+ assert(p_atomic_read(&$self->buffer->reference.count) > 0);
if(offset > $self->buffer->size) {
PyErr_SetString(PyExc_ValueError, "offset must be smaller than buffer size");
diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py
index f418f80d7b..e6999a2211 100755
--- a/src/gallium/state_trackers/python/retrace/interpreter.py
+++ b/src/gallium/state_trackers/python/retrace/interpreter.py
@@ -35,21 +35,19 @@ import model
import parser
+try:
+ from struct import unpack_from
+except ImportError:
+ def unpack_from(fmt, buf, offset=0):
+ size = struct.calcsize(fmt)
+ return struct.unpack(fmt, buf[offset:offset + size])
+
+
def make_image(surface):
- pixels = gallium.FloatArray(surface.height*surface.width*4)
- surface.get_tile_rgba(0, 0, surface.width, surface.height, pixels)
+ data = surface.get_tile_rgba8(0, 0, surface.width, surface.height)
import Image
- outimage = Image.new(
- mode='RGB',
- size=(surface.width, surface.height),
- color=(0,0,0))
- outpixels = outimage.load()
- for y in range(0, surface.height):
- for x in range(0, surface.width):
- offset = (y*surface.width + x)*4
- r, g, b, a = [int(pixels[offset + ch]*255) for ch in range(4)]
- outpixels[x, y] = r, g, b
+ outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1)
return outimage
def save_image(filename, surface):
@@ -77,6 +75,7 @@ def show_image(surface):
root.mainloop()
+verbose = 1
class Struct:
@@ -297,6 +296,7 @@ class Context(Object):
self.zsbuf = None
self.vbufs = []
self.velems = []
+ self.dirty = False
def destroy(self):
pass
@@ -374,18 +374,23 @@ class Context(Object):
_state.ucp = ucp
self.real.set_clip(_state)
+ def dump_constant_buffer(self, buffer):
+ if verbose < 2:
+ return
+
+ data = buffer.read()
+ format = '4f'
+ index = 0
+ for offset in range(0, len(data), struct.calcsize(format)):
+ x, y, z, w = unpack_from(format, data, offset)
+ sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w))
+ index += 1
+
def set_constant_buffer(self, shader, index, state):
if state is not None:
self.real.set_constant_buffer(shader, index, state.buffer)
- if 1:
- data = state.buffer.read()
- format = '4f'
- index = 0
- for offset in range(0, len(data), struct.calcsize(format)):
- x, y, z, w = struct.unpack_from(format, data, offset)
- sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w))
- index += 1
+ self.dump_constant_buffer(state.buffer)
def set_framebuffer_state(self, state):
_state = gallium.Framebuffer()
@@ -436,6 +441,9 @@ class Context(Object):
pass
def dump_vertices(self, start, count):
+ if verbose < 2:
+ return
+
for index in range(start, start + count):
if index >= start + 16:
sys.stdout.write('\t...\n')
@@ -454,12 +462,15 @@ class Context(Object):
}[velem.src_format]
data = vbuf.buffer.read()
- values = struct.unpack_from(format, data, offset)
+ values = unpack_from(format, data, offset)
sys.stdout.write('\t\t{' + ', '.join(map(str, values)) + '},\n')
assert len(values) == velem.nr_components
sys.stdout.write('\t},\n')
def dump_indices(self, ibuf, isize, start, count):
+ if verbose < 2:
+ return
+
format = {
1: 'B',
2: 'H',
@@ -477,7 +488,7 @@ class Context(Object):
sys.stdout.write('\t...\n')
break
offset = i*isize
- index, = struct.unpack_from(format, data, offset)
+ index, = unpack_from(format, data, offset)
sys.stdout.write('\t\t%u,\n' % index)
minindex = min(minindex, index)
maxindex = max(maxindex, index)
@@ -489,25 +500,35 @@ class Context(Object):
self.dump_vertices(start, count)
self.real.draw_arrays(mode, start, count)
+
+ self.dirty = True
def draw_elements(self, indexBuffer, indexSize, mode, start, count):
- minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count)
- self.dump_vertices(minindex, maxindex - minindex)
+ if verbose >= 2:
+ minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count)
+ self.dump_vertices(minindex, maxindex - minindex)
self.real.draw_elements(indexBuffer, indexSize, mode, start, count)
+
+ self.dirty = True
def draw_range_elements(self, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count):
- minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count)
- minindex = min(minindex, minIndex)
- maxindex = min(maxindex, maxIndex)
- self.dump_vertices(minindex, maxindex - minindex)
+ if verbose >= 2:
+ minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count)
+ minindex = min(minindex, minIndex)
+ maxindex = min(maxindex, maxIndex)
+ self.dump_vertices(minindex, maxindex - minindex)
self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count)
+
+ self.dirty = True
def flush(self, flags):
self.real.flush(flags)
- if flags & gallium.PIPE_FLUSH_FRAME:
- self._update()
+ if self.dirty:
+ if flags & gallium.PIPE_FLUSH_FRAME:
+ self._update()
+ self.dirty = False
return None
def clear(self, surface, value):
@@ -553,7 +574,8 @@ class Interpreter(parser.TraceDumper):
if (call.klass, call.method) in self.ignore_calls:
return
- parser.TraceDumper.handle_call(self, call)
+ if verbose >= 1:
+ parser.TraceDumper.handle_call(self, call)
args = [self.interpret_arg(arg) for name, arg in call.args]
diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py
index 193479f7d6..d3ccb6c2f4 100644
--- a/src/gallium/state_trackers/python/samples/tri.py
+++ b/src/gallium/state_trackers/python/samples/tri.py
@@ -31,20 +31,10 @@ from gallium import *
def make_image(surface):
- pixels = FloatArray(surface.height*surface.width*4)
- surface.get_tile_rgba(0, 0, surface.width, surface.height, pixels)
+ data = surface.get_tile_rgba8(0, 0, surface.width, surface.height)
import Image
- outimage = Image.new(
- mode='RGB',
- size=(surface.width, surface.height),
- color=(0,0,0))
- outpixels = outimage.load()
- for y in range(0, surface.height):
- for x in range(0, surface.width):
- offset = (y*surface.width + x)*4
- r, g, b, a = [int(pixels[offset + ch]*255) for ch in range(4)]
- outpixels[x, y] = r, g, b
+ outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1)
return outimage
def save_image(filename, surface):
diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c
index 20dd8d269d..366d4eb19a 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -51,11 +51,20 @@ st_device_really_destroy(struct st_device *st_dev)
}
+static void
+st_device_reference(struct st_device **ptr, struct st_device *st_dev)
+{
+ struct st_device *old_dev = *ptr;
+
+ if (pipe_reference((struct pipe_reference **)ptr, &st_dev->reference))
+ st_device_really_destroy(old_dev);
+}
+
+
void
st_device_destroy(struct st_device *st_dev)
{
- if(!--st_dev->refcount)
- st_device_really_destroy(st_dev);
+ st_device_reference(&st_dev, NULL);
}
@@ -72,7 +81,7 @@ st_device_create_from_st_winsys(const struct st_winsys *st_ws)
if(!st_dev)
return NULL;
- st_dev->refcount = 1;
+ pipe_reference_init(&st_dev->reference, 1);
st_dev->st_ws = st_ws;
st_dev->real_screen = st_ws->screen_create();
@@ -124,8 +133,7 @@ st_context_destroy(struct st_context *st_ctx)
FREE(st_ctx);
- if(!--st_dev->refcount)
- st_device_really_destroy(st_dev);
+ st_device_reference(&st_dev, NULL);
}
}
@@ -139,8 +147,7 @@ st_context_create(struct st_device *st_dev)
if(!st_ctx)
return NULL;
- st_ctx->st_dev = st_dev;
- ++st_dev->refcount;
+ st_device_reference(&st_ctx->st_dev, st_dev);
st_ctx->real_pipe = st_dev->st_ws->context_create(st_dev->real_screen);
if(!st_ctx->real_pipe) {
@@ -185,8 +192,7 @@ st_context_create(struct st_device *st_dev)
memset(&rasterizer, 0, sizeof(rasterizer));
rasterizer.front_winding = PIPE_WINDING_CW;
rasterizer.cull_mode = PIPE_WINDING_NONE;
- rasterizer.bypass_clipping = 1;
- /*rasterizer.bypass_vs = 1;*/
+ rasterizer.bypass_vs_clip_and_viewport = 1;
cso_set_rasterizer(st_ctx->cso, &rasterizer);
}
@@ -225,7 +231,7 @@ st_context_create(struct st_device *st_dev)
{
struct pipe_screen *screen = st_dev->screen;
struct pipe_texture templat;
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
unsigned i;
memset( &templat, 0, sizeof( templat ) );
@@ -241,17 +247,21 @@ st_context_create(struct st_device *st_dev)
st_ctx->default_texture = screen->texture_create( screen, &templat );
if(st_ctx->default_texture) {
- surface = screen->get_tex_surface( screen,
- st_ctx->default_texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE );
- if(surface) {
+ transfer = screen->get_tex_transfer(screen,
+ st_ctx->default_texture,
+ 0, 0, 0,
+ PIPE_TRANSFER_WRITE,
+ 0, 0,
+ st_ctx->default_texture->width[0],
+ st_ctx->default_texture->height[0]);
+ if (transfer) {
uint32_t *map;
- map = (uint32_t *) pipe_surface_map(surface, PIPE_BUFFER_USAGE_CPU_WRITE );
+ map = (uint32_t *) screen->transfer_map(screen, transfer);
if(map) {
*map = 0x00000000;
- pipe_surface_unmap( surface );
+ screen->transfer_unmap(screen, transfer);
}
- pipe_surface_reference(&surface, NULL);
+ screen->tex_transfer_destroy(transfer);
}
}
@@ -263,24 +273,19 @@ st_context_create(struct st_device *st_dev)
/* vertex shader */
{
- struct pipe_shader_state vert_shader;
-
const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC };
const uint semantic_indexes[] = { 0, 0 };
st_ctx->vs = util_make_vertex_passthrough_shader(st_ctx->pipe,
2,
semantic_names,
- semantic_indexes,
- &vert_shader);
+ semantic_indexes);
cso_set_vertex_shader_handle(st_ctx->cso, st_ctx->vs);
}
/* fragment shader */
{
- struct pipe_shader_state frag_shader;
- st_ctx->fs = util_make_fragment_passthrough_shader(st_ctx->pipe,
- &frag_shader);
+ st_ctx->fs = util_make_fragment_passthrough_shader(st_ctx->pipe);
cso_set_fragment_shader_handle(st_ctx->cso, st_ctx->fs);
}
@@ -292,8 +297,7 @@ void
st_buffer_destroy(struct st_buffer *st_buf)
{
if(st_buf) {
- struct pipe_screen *screen = st_buf->st_dev->screen;
- pipe_buffer_reference(screen, &st_buf->buffer, NULL);
+ pipe_buffer_reference(&st_buf->buffer, NULL);
FREE(st_buf);
}
}
diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h
index 7cfe6de9f6..0641aff149 100644
--- a/src/gallium/state_trackers/python/st_device.h
+++ b/src/gallium/state_trackers/python/st_device.h
@@ -68,13 +68,13 @@ struct st_context {
struct st_device {
+ /* FIXME: we also need to refcount for textures and surfaces... */
+ struct pipe_reference reference;
+
const struct st_winsys *st_ws;
struct pipe_screen *real_screen;
struct pipe_screen *screen;
-
- /* FIXME: we also need to refcount for textures and surfaces... */
- unsigned refcount;
};
diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c
index 7765df3c4a..c2ffe9fce1 100644
--- a/src/gallium/state_trackers/python/st_sample.c
+++ b/src/gallium/state_trackers/python/st_sample.c
@@ -451,6 +451,7 @@ st_sample_dxt_pixel_block(enum pipe_format format,
break;
default:
assert(0);
+ return;
}
i = st_random() % n;
@@ -524,26 +525,42 @@ st_sample_pixel_block(enum pipe_format format,
void
st_sample_surface(struct pipe_surface *surface, float *rgba)
{
- const struct pipe_format_block *block = &surface->block;
- unsigned rgba_stride = surface->width*4;
+ struct pipe_screen *screen = surface->texture->screen;
+ uint rgba_stride = surface->width * 4;
+ struct pipe_transfer *transfer;
void *raw;
- unsigned x, y;
- raw = pipe_surface_map(surface, PIPE_BUFFER_USAGE_CPU_READ);
- if(!raw)
+ transfer = screen->get_tex_transfer(screen,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_READ,
+ 0, 0,
+ surface->width,
+ surface->height);
+ if (!transfer)
return;
- for (y = 0; y < surface->nblocksy; ++y) {
- for(x = 0; x < surface->nblocksx; ++x) {
- st_sample_pixel_block(surface->format,
- block,
- (uint8_t*)raw + y*surface->stride + x*block->size,
- rgba + y*block->height*rgba_stride + x*block->width*4,
- rgba_stride,
- MIN2(block->width, surface->width - x*block->width),
- MIN2(block->height, surface->height - y*block->height));
- }
+ raw = screen->transfer_map(screen, transfer);
+ if (raw) {
+ const struct pipe_format_block *block = &transfer->block;
+ uint x, y;
+
+ for (y = 0; y < transfer->nblocksy; ++y) {
+ for (x = 0; x < transfer->nblocksx; ++x) {
+ st_sample_pixel_block(surface->format,
+ block,
+ (uint8_t *) raw + y * transfer->stride + x * block->size,
+ rgba + y * block->height * rgba_stride + x * block->width * 4,
+ rgba_stride,
+ MIN2(block->width, surface->width - x*block->width),
+ MIN2(block->height, surface->height - y*block->height));
+ }
+ }
+
+ screen->transfer_unmap(screen, transfer);
}
- pipe_surface_unmap(surface);
+ screen->tex_transfer_destroy(transfer);
}
diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c
index 4d798df99b..426f347d18 100644
--- a/src/gallium/state_trackers/python/st_softpipe_winsys.c
+++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c
@@ -124,7 +124,7 @@ st_softpipe_buffer_create(struct pipe_winsys *winsys,
{
struct st_softpipe_buffer *buffer = CALLOC_STRUCT(st_softpipe_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
@@ -149,7 +149,7 @@ st_softpipe_user_buffer_create(struct pipe_winsys *winsys,
if(!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;
diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript
index c72f495735..2141b02d68 100644
--- a/src/gallium/state_trackers/wgl/SConscript
+++ b/src/gallium/state_trackers/wgl/SConscript
@@ -14,13 +14,10 @@ if env['platform'] in ['windows']:
env.Append(CPPDEFINES = [
'_GDI32_', # prevent wgl* being declared __declspec(dllimport)
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
- '__GL_EXPORTS',
- '_GNU_H_WINDOWS32_DEFINES',
+ 'WIN32_THREADS', # use Win32 thread API
])
sources = [
- 'stw.c',
-
'icd/stw_icd.c',
'wgl/stw_wgl.c',
diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c
index 1aa4b8a6e2..faf7f2f410 100644
--- a/src/gallium/state_trackers/wgl/icd/stw_icd.c
+++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c
@@ -30,82 +30,17 @@
#include "GL/gl.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "shared/stw_public.h"
#include "icd/stw_icd.h"
-#include "stw.h"
+#define DBG 0
-#define DRV_CONTEXT_MAX 32
+static GLCLTPROCTABLE cpt;
+static boolean cpt_initialized = FALSE;
-struct stw_icd
-{
- pipe_mutex mutex;
-
- GLCLTPROCTABLE cpt;
- boolean cpt_initialized;
-
- struct {
- struct stw_context *ctx;
- } ctx_array[DRV_CONTEXT_MAX];
-};
-
-
-static struct stw_icd *stw_icd = NULL;
-
-
-boolean
-stw_icd_init( void )
-{
- static struct stw_icd stw_icd_storage;
-
- assert(!stw_icd);
-
- stw_icd = &stw_icd_storage;
- memset(stw_icd, 0, sizeof *stw_icd);
-
- pipe_mutex_init( stw_icd->mutex );
-
- return TRUE;
-}
-
-void
-stw_icd_cleanup(void)
-{
- int i;
-
- if (!stw_icd)
- return;
-
- pipe_mutex_lock( stw_icd->mutex );
- {
- /* Ensure all contexts are destroyed */
- for (i = 0; i < DRV_CONTEXT_MAX; i++)
- if (stw_icd->ctx_array[i].ctx)
- stw_delete_context( stw_icd->ctx_array[i].ctx );
- }
- pipe_mutex_unlock( stw_icd->mutex );
-
- pipe_mutex_init( stw_icd->mutex );
- stw_icd = NULL;
-}
-
-
-static struct stw_context *
-lookup_context( struct stw_icd *icd,
- DHGLRC dhglrc )
-{
- if (dhglrc == 0 ||
- dhglrc >= DRV_CONTEXT_MAX)
- return NULL;
-
- if (icd == NULL)
- return NULL;
-
- return icd->ctx_array[dhglrc - 1].ctx;
-}
BOOL APIENTRY
DrvCopyContext(
@@ -113,63 +48,16 @@ DrvCopyContext(
DHGLRC dhrcDest,
UINT fuMask )
{
- BOOL ret = FALSE;
-
- if (!stw_icd)
- return FALSE;
-
- pipe_mutex_lock( stw_icd->mutex );
- {
- struct stw_context *src = lookup_context( stw_icd, dhrcSource );
- struct stw_context *dst = lookup_context( stw_icd, dhrcDest );
-
- if (src == NULL || dst == NULL)
- goto done;
-
- ret = stw_copy_context( src, dst, fuMask );
- }
-done:
- pipe_mutex_unlock( stw_icd->mutex );
-
- return ret;
+ return stw_copy_context(dhrcSource, dhrcDest, fuMask);
}
+
DHGLRC APIENTRY
DrvCreateLayerContext(
HDC hdc,
INT iLayerPlane )
{
- DHGLRC handle = 0;
-
- if (!stw_icd)
- return handle;
-
- pipe_mutex_lock( stw_icd->mutex );
- {
- int i;
-
- for (i = 0; i < DRV_CONTEXT_MAX; i++) {
- if (stw_icd->ctx_array[i].ctx == NULL)
- break;
- }
-
- /* No slot available, fail:
- */
- if (i == DRV_CONTEXT_MAX)
- goto done;
-
- stw_icd->ctx_array[i].ctx = stw_create_context( hdc, iLayerPlane );
- if (stw_icd->ctx_array[i].ctx == NULL)
- goto done;
-
- /* success:
- */
- handle = (DHGLRC) i + 1;
- }
-done:
- pipe_mutex_unlock( stw_icd->mutex );
-
- return handle;
+ return stw_create_layer_context( hdc, iLayerPlane );
}
DHGLRC APIENTRY
@@ -183,30 +71,7 @@ BOOL APIENTRY
DrvDeleteContext(
DHGLRC dhglrc )
{
- BOOL ret = FALSE;
-
- if (!stw_icd)
- return ret;
-
- pipe_mutex_lock( stw_icd->mutex );
- {
- struct stw_context *ctx;
-
- ctx = lookup_context( stw_icd, dhglrc );
- if (ctx == NULL)
- goto done;
-
- if (stw_delete_context( ctx ) == FALSE)
- goto done;
-
- stw_icd->ctx_array[dhglrc - 1].ctx = NULL;
- ret = TRUE;
-
- }
-done:
- pipe_mutex_unlock( stw_icd->mutex );
-
- return ret;
+ return stw_delete_context( dhglrc );
}
BOOL APIENTRY
@@ -217,7 +82,8 @@ DrvDescribeLayerPlane(
UINT nBytes,
LPLAYERPLANEDESCRIPTOR plpd )
{
- debug_printf( "%s\n", __FUNCTION__ );
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
return FALSE;
}
@@ -233,8 +99,9 @@ DrvDescribePixelFormat(
r = stw_pixelformat_describe( hdc, iPixelFormat, cjpfd, ppfd );
- debug_printf( "%s( %p, %d, %u, %p ) = %d\n",
- __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r );
+ if (DBG)
+ debug_printf( "%s( %p, %d, %u, %p ) = %d\n",
+ __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r );
return r;
}
@@ -247,7 +114,8 @@ DrvGetLayerPaletteEntries(
INT cEntries,
COLORREF *pcr )
{
- debug_printf( "%s\n", __FUNCTION__ );
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
return 0;
}
@@ -260,7 +128,8 @@ DrvGetProcAddress(
r = stw_get_proc_address( lpszProc );
- debug_printf( "%s( \", __FUNCTION__%s\" ) = %p\n", lpszProc, r );
+ if (DBG)
+ debug_printf( "%s( \", __FUNCTION__%s\" ) = %p\n", lpszProc, r );
return r;
}
@@ -271,7 +140,8 @@ DrvRealizeLayerPalette(
INT iLayerPlane,
BOOL bRealize )
{
- debug_printf( "%s\n", __FUNCTION__ );
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
return FALSE;
}
@@ -280,32 +150,7 @@ BOOL APIENTRY
DrvReleaseContext(
DHGLRC dhglrc )
{
- BOOL ret = FALSE;
-
- if (!stw_icd)
- return ret;
-
- pipe_mutex_lock( stw_icd->mutex );
- {
- struct stw_context *ctx;
-
- /* XXX: The expectation is that ctx is the same context which is
- * current for this thread. We should check that and return False
- * if not the case.
- */
- ctx = lookup_context( stw_icd, dhglrc );
- if (ctx == NULL)
- goto done;
-
- if (stw_make_current( NULL, NULL ) == FALSE)
- goto done;
-
- ret = TRUE;
- }
-done:
- pipe_mutex_unlock( stw_icd->mutex );
-
- return ret;
+ return stw_release_context(dhglrc);
}
void APIENTRY
@@ -313,7 +158,8 @@ DrvSetCallbackProcs(
INT nProcs,
PROC *pProcs )
{
- debug_printf( "%s( %d, %p )\n", __FUNCTION__, nProcs, pProcs );
+ if (DBG)
+ debug_printf( "%s( %d, %p )\n", __FUNCTION__, nProcs, pProcs );
return;
}
@@ -671,38 +517,21 @@ DrvSetContext(
DHGLRC dhglrc,
PFN_SETPROCTABLE pfnSetProcTable )
{
- PGLCLTPROCTABLE result = NULL;
-
- if (!stw_icd)
- return result;
-
- pipe_mutex_lock( stw_icd->mutex );
- {
- struct stw_context *ctx;
-
+ if (DBG)
debug_printf( "%s( 0x%p, %u, 0x%p )\n",
__FUNCTION__, hdc, dhglrc, pfnSetProcTable );
- /* Although WGL allows different dispatch entrypoints per
- */
- if (!stw_icd->cpt_initialized) {
- init_proc_table( &stw_icd->cpt );
- stw_icd->cpt_initialized = TRUE;
- }
-
- ctx = lookup_context( stw_icd, dhglrc );
- if (ctx == NULL)
- goto done;
-
- if (!stw_make_current( hdc, ctx ))
- goto done;
-
- result = &stw_icd->cpt;
+ /* Although WGL allows different dispatch entrypoints per
+ */
+ if (!cpt_initialized) {
+ init_proc_table( &cpt );
+ cpt_initialized = TRUE;
}
-done:
- pipe_mutex_unlock( stw_icd->mutex );
- return result;
+ if (!stw_make_current( hdc, dhglrc ))
+ return NULL;
+
+ return &cpt;
}
int APIENTRY
@@ -713,7 +542,8 @@ DrvSetLayerPaletteEntries(
INT cEntries,
CONST COLORREF *pcr )
{
- debug_printf( "%s\n", __FUNCTION__ );
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
return 0;
}
@@ -727,7 +557,8 @@ DrvSetPixelFormat(
r = stw_pixelformat_set( hdc, iPixelFormat );
- debug_printf( "%s( %p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
+ if (DBG)
+ debug_printf( "%s( %p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
return r;
}
@@ -737,7 +568,8 @@ DrvShareLists(
DHGLRC dhglrc1,
DHGLRC dhglrc2 )
{
- debug_printf( "%s\n", __FUNCTION__ );
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
return FALSE;
}
@@ -746,7 +578,8 @@ BOOL APIENTRY
DrvSwapBuffers(
HDC hdc )
{
- debug_printf( "%s( %p )\n", __FUNCTION__, hdc );
+ if (DBG)
+ debug_printf( "%s( %p )\n", __FUNCTION__, hdc );
return stw_swap_buffers( hdc );
}
@@ -756,7 +589,8 @@ DrvSwapLayerBuffers(
HDC hdc,
UINT fuPlanes )
{
- debug_printf( "%s\n", __FUNCTION__ );
+ if (DBG)
+ debug_printf( "%s\n", __FUNCTION__ );
return FALSE;
}
@@ -765,7 +599,8 @@ BOOL APIENTRY
DrvValidateVersion(
ULONG ulVersion )
{
- debug_printf( "%s( %u )\n", __FUNCTION__, ulVersion );
+ if (DBG)
+ debug_printf( "%s( %u )\n", __FUNCTION__, ulVersion );
/* TODO: get the expected version from the winsys */
diff --git a/src/gallium/state_trackers/wgl/opengl32.mingw.def b/src/gallium/state_trackers/wgl/opengl32.mingw.def
new file mode 100644
index 0000000000..1f03ea3b37
--- /dev/null
+++ b/src/gallium/state_trackers/wgl/opengl32.mingw.def
@@ -0,0 +1,387 @@
+EXPORTS
+; GlmfBeginGlsBlock = GlmfBeginGlsBlock@4
+; GlmfCloseMetaFile = GlmfCloseMetaFile@4
+; GlmfEndGlsBlock = GlmfEndGlsBlock@4
+; GlmfEndPlayback = GlmfEndPlayback@4
+; GlmfInitPlayback = GlmfInitPlayback@12
+; GlmfPlayGlsRecord = GlmfPlayGlsRecord@16
+ glAccum = glAccum@8
+ glAlphaFunc = glAlphaFunc@8
+ glAreTexturesResident = glAreTexturesResident@12
+ glArrayElement = glArrayElement@4
+ glBegin = glBegin@4
+ glBindTexture = glBindTexture@8
+ glBitmap = glBitmap@28
+ glBlendFunc = glBlendFunc@8
+ glCallList = glCallList@4
+ glCallLists = glCallLists@12
+ glClear = glClear@4
+ glClearAccum = glClearAccum@16
+ glClearColor = glClearColor@16
+ glClearDepth = glClearDepth@8
+ glClearIndex = glClearIndex@4
+ glClearStencil = glClearStencil@4
+ glClipPlane = glClipPlane@8
+ glColor3b = glColor3b@12
+ glColor3bv = glColor3bv@4
+ glColor3d = glColor3d@24
+ glColor3dv = glColor3dv@4
+ glColor3f = glColor3f@12
+ glColor3fv = glColor3fv@4
+ glColor3i = glColor3i@12
+ glColor3iv = glColor3iv@4
+ glColor3s = glColor3s@12
+ glColor3sv = glColor3sv@4
+ glColor3ub = glColor3ub@12
+ glColor3ubv = glColor3ubv@4
+ glColor3ui = glColor3ui@12
+ glColor3uiv = glColor3uiv@4
+ glColor3us = glColor3us@12
+ glColor3usv = glColor3usv@4
+ glColor4b = glColor4b@16
+ glColor4bv = glColor4bv@4
+ glColor4d = glColor4d@32
+ glColor4dv = glColor4dv@4
+ glColor4f = glColor4f@16
+ glColor4fv = glColor4fv@4
+ glColor4i = glColor4i@16
+ glColor4iv = glColor4iv@4
+ glColor4s = glColor4s@16
+ glColor4sv = glColor4sv@4
+ glColor4ub = glColor4ub@16
+ glColor4ubv = glColor4ubv@4
+ glColor4ui = glColor4ui@16
+ glColor4uiv = glColor4uiv@4
+ glColor4us = glColor4us@16
+ glColor4usv = glColor4usv@4
+ glColorMask = glColorMask@16
+ glColorMaterial = glColorMaterial@8
+ glColorPointer = glColorPointer@16
+ glCopyPixels = glCopyPixels@20
+ glCopyTexImage1D = glCopyTexImage1D@28
+ glCopyTexImage2D = glCopyTexImage2D@32
+ glCopyTexSubImage1D = glCopyTexSubImage1D@24
+ glCopyTexSubImage2D = glCopyTexSubImage2D@32
+ glCullFace = glCullFace@4
+; glDebugEntry = glDebugEntry@8
+ glDeleteLists = glDeleteLists@8
+ glDeleteTextures = glDeleteTextures@8
+ glDepthFunc = glDepthFunc@4
+ glDepthMask = glDepthMask@4
+ glDepthRange = glDepthRange@16
+ glDisable = glDisable@4
+ glDisableClientState = glDisableClientState@4
+ glDrawArrays = glDrawArrays@12
+ glDrawBuffer = glDrawBuffer@4
+ glDrawElements = glDrawElements@16
+ glDrawPixels = glDrawPixels@20
+ glEdgeFlag = glEdgeFlag@4
+ glEdgeFlagPointer = glEdgeFlagPointer@8
+ glEdgeFlagv = glEdgeFlagv@4
+ glEnable = glEnable@4
+ glEnableClientState = glEnableClientState@4
+ glEnd = glEnd@0
+ glEndList = glEndList@0
+ glEvalCoord1d = glEvalCoord1d@8
+ glEvalCoord1dv = glEvalCoord1dv@4
+ glEvalCoord1f = glEvalCoord1f@4
+ glEvalCoord1fv = glEvalCoord1fv@4
+ glEvalCoord2d = glEvalCoord2d@16
+ glEvalCoord2dv = glEvalCoord2dv@4
+ glEvalCoord2f = glEvalCoord2f@8
+ glEvalCoord2fv = glEvalCoord2fv@4
+ glEvalMesh1 = glEvalMesh1@12
+ glEvalMesh2 = glEvalMesh2@20
+ glEvalPoint1 = glEvalPoint1@4
+ glEvalPoint2 = glEvalPoint2@8
+ glFeedbackBuffer = glFeedbackBuffer@12
+ glFinish = glFinish@0
+ glFlush = glFlush@0
+ glFogf = glFogf@8
+ glFogfv = glFogfv@8
+ glFogi = glFogi@8
+ glFogiv = glFogiv@8
+ glFrontFace = glFrontFace@4
+ glFrustum = glFrustum@48
+ glGenLists = glGenLists@4
+ glGenTextures = glGenTextures@8
+ glGetBooleanv = glGetBooleanv@8
+ glGetClipPlane = glGetClipPlane@8
+ glGetDoublev = glGetDoublev@8
+ glGetError = glGetError@0
+ glGetFloatv = glGetFloatv@8
+ glGetIntegerv = glGetIntegerv@8
+ glGetLightfv = glGetLightfv@12
+ glGetLightiv = glGetLightiv@12
+ glGetMapdv = glGetMapdv@12
+ glGetMapfv = glGetMapfv@12
+ glGetMapiv = glGetMapiv@12
+ glGetMaterialfv = glGetMaterialfv@12
+ glGetMaterialiv = glGetMaterialiv@12
+ glGetPixelMapfv = glGetPixelMapfv@8
+ glGetPixelMapuiv = glGetPixelMapuiv@8
+ glGetPixelMapusv = glGetPixelMapusv@8
+ glGetPointerv = glGetPointerv@8
+ glGetPolygonStipple = glGetPolygonStipple@4
+ glGetString = glGetString@4
+ glGetTexEnvfv = glGetTexEnvfv@12
+ glGetTexEnviv = glGetTexEnviv@12
+ glGetTexGendv = glGetTexGendv@12
+ glGetTexGenfv = glGetTexGenfv@12
+ glGetTexGeniv = glGetTexGeniv@12
+ glGetTexImage = glGetTexImage@20
+ glGetTexLevelParameterfv = glGetTexLevelParameterfv@16
+ glGetTexLevelParameteriv = glGetTexLevelParameteriv@16
+ glGetTexParameterfv = glGetTexParameterfv@12
+ glGetTexParameteriv = glGetTexParameteriv@12
+ glHint = glHint@8
+ glIndexMask = glIndexMask@4
+ glIndexPointer = glIndexPointer@12
+ glIndexd = glIndexd@8
+ glIndexdv = glIndexdv@4
+ glIndexf = glIndexf@4
+ glIndexfv = glIndexfv@4
+ glIndexi = glIndexi@4
+ glIndexiv = glIndexiv@4
+ glIndexs = glIndexs@4
+ glIndexsv = glIndexsv@4
+ glIndexub = glIndexub@4
+ glIndexubv = glIndexubv@4
+ glInitNames = glInitNames@0
+ glInterleavedArrays = glInterleavedArrays@12
+ glIsEnabled = glIsEnabled@4
+ glIsList = glIsList@4
+ glIsTexture = glIsTexture@4
+ glLightModelf = glLightModelf@8
+ glLightModelfv = glLightModelfv@8
+ glLightModeli = glLightModeli@8
+ glLightModeliv = glLightModeliv@8
+ glLightf = glLightf@12
+ glLightfv = glLightfv@12
+ glLighti = glLighti@12
+ glLightiv = glLightiv@12
+ glLineStipple = glLineStipple@8
+ glLineWidth = glLineWidth@4
+ glListBase = glListBase@4
+ glLoadIdentity = glLoadIdentity@0
+ glLoadMatrixd = glLoadMatrixd@4
+ glLoadMatrixf = glLoadMatrixf@4
+ glLoadName = glLoadName@4
+ glLogicOp = glLogicOp@4
+ glMap1d = glMap1d@32
+ glMap1f = glMap1f@24
+ glMap2d = glMap2d@56
+ glMap2f = glMap2f@40
+ glMapGrid1d = glMapGrid1d@20
+ glMapGrid1f = glMapGrid1f@12
+ glMapGrid2d = glMapGrid2d@40
+ glMapGrid2f = glMapGrid2f@24
+ glMaterialf = glMaterialf@12
+ glMaterialfv = glMaterialfv@12
+ glMateriali = glMateriali@12
+ glMaterialiv = glMaterialiv@12
+ glMatrixMode = glMatrixMode@4
+ glMultMatrixd = glMultMatrixd@4
+ glMultMatrixf = glMultMatrixf@4
+ glNewList = glNewList@8
+ glNormal3b = glNormal3b@12
+ glNormal3bv = glNormal3bv@4
+ glNormal3d = glNormal3d@24
+ glNormal3dv = glNormal3dv@4
+ glNormal3f = glNormal3f@12
+ glNormal3fv = glNormal3fv@4
+ glNormal3i = glNormal3i@12
+ glNormal3iv = glNormal3iv@4
+ glNormal3s = glNormal3s@12
+ glNormal3sv = glNormal3sv@4
+ glNormalPointer = glNormalPointer@12
+ glOrtho = glOrtho@48
+ glPassThrough = glPassThrough@4
+ glPixelMapfv = glPixelMapfv@12
+ glPixelMapuiv = glPixelMapuiv@12
+ glPixelMapusv = glPixelMapusv@12
+ glPixelStoref = glPixelStoref@8
+ glPixelStorei = glPixelStorei@8
+ glPixelTransferf = glPixelTransferf@8
+ glPixelTransferi = glPixelTransferi@8
+ glPixelZoom = glPixelZoom@8
+ glPointSize = glPointSize@4
+ glPolygonMode = glPolygonMode@8
+ glPolygonOffset = glPolygonOffset@8
+ glPolygonStipple = glPolygonStipple@4
+ glPopAttrib = glPopAttrib@0
+ glPopClientAttrib = glPopClientAttrib@0
+ glPopMatrix = glPopMatrix@0
+ glPopName = glPopName@0
+ glPrioritizeTextures = glPrioritizeTextures@12
+ glPushAttrib = glPushAttrib@4
+ glPushClientAttrib = glPushClientAttrib@4
+ glPushMatrix = glPushMatrix@0
+ glPushName = glPushName@4
+ glRasterPos2d = glRasterPos2d@16
+ glRasterPos2dv = glRasterPos2dv@4
+ glRasterPos2f = glRasterPos2f@8
+ glRasterPos2fv = glRasterPos2fv@4
+ glRasterPos2i = glRasterPos2i@8
+ glRasterPos2iv = glRasterPos2iv@4
+ glRasterPos2s = glRasterPos2s@8
+ glRasterPos2sv = glRasterPos2sv@4
+ glRasterPos3d = glRasterPos3d@24
+ glRasterPos3dv = glRasterPos3dv@4
+ glRasterPos3f = glRasterPos3f@12
+ glRasterPos3fv = glRasterPos3fv@4
+ glRasterPos3i = glRasterPos3i@12
+ glRasterPos3iv = glRasterPos3iv@4
+ glRasterPos3s = glRasterPos3s@12
+ glRasterPos3sv = glRasterPos3sv@4
+ glRasterPos4d = glRasterPos4d@32
+ glRasterPos4dv = glRasterPos4dv@4
+ glRasterPos4f = glRasterPos4f@16
+ glRasterPos4fv = glRasterPos4fv@4
+ glRasterPos4i = glRasterPos4i@16
+ glRasterPos4iv = glRasterPos4iv@4
+ glRasterPos4s = glRasterPos4s@16
+ glRasterPos4sv = glRasterPos4sv@4
+ glReadBuffer = glReadBuffer@4
+ glReadPixels = glReadPixels@28
+ glRectd = glRectd@32
+ glRectdv = glRectdv@8
+ glRectf = glRectf@16
+ glRectfv = glRectfv@8
+ glRecti = glRecti@16
+ glRectiv = glRectiv@8
+ glRects = glRects@16
+ glRectsv = glRectsv@8
+ glRenderMode = glRenderMode@4
+ glRotated = glRotated@32
+ glRotatef = glRotatef@16
+ glScaled = glScaled@24
+ glScalef = glScalef@12
+ glScissor = glScissor@16
+ glSelectBuffer = glSelectBuffer@8
+ glShadeModel = glShadeModel@4
+ glStencilFunc = glStencilFunc@12
+ glStencilMask = glStencilMask@4
+ glStencilOp = glStencilOp@12
+ glTexCoord1d = glTexCoord1d@8
+ glTexCoord1dv = glTexCoord1dv@4
+ glTexCoord1f = glTexCoord1f@4
+ glTexCoord1fv = glTexCoord1fv@4
+ glTexCoord1i = glTexCoord1i@4
+ glTexCoord1iv = glTexCoord1iv@4
+ glTexCoord1s = glTexCoord1s@4
+ glTexCoord1sv = glTexCoord1sv@4
+ glTexCoord2d = glTexCoord2d@16
+ glTexCoord2dv = glTexCoord2dv@4
+ glTexCoord2f = glTexCoord2f@8
+ glTexCoord2fv = glTexCoord2fv@4
+ glTexCoord2i = glTexCoord2i@8
+ glTexCoord2iv = glTexCoord2iv@4
+ glTexCoord2s = glTexCoord2s@8
+ glTexCoord2sv = glTexCoord2sv@4
+ glTexCoord3d = glTexCoord3d@24
+ glTexCoord3dv = glTexCoord3dv@4
+ glTexCoord3f = glTexCoord3f@12
+ glTexCoord3fv = glTexCoord3fv@4
+ glTexCoord3i = glTexCoord3i@12
+ glTexCoord3iv = glTexCoord3iv@4
+ glTexCoord3s = glTexCoord3s@12
+ glTexCoord3sv = glTexCoord3sv@4
+ glTexCoord4d = glTexCoord4d@32
+ glTexCoord4dv = glTexCoord4dv@4
+ glTexCoord4f = glTexCoord4f@16
+ glTexCoord4fv = glTexCoord4fv@4
+ glTexCoord4i = glTexCoord4i@16
+ glTexCoord4iv = glTexCoord4iv@4
+ glTexCoord4s = glTexCoord4s@16
+ glTexCoord4sv = glTexCoord4sv@4
+ glTexCoordPointer = glTexCoordPointer@16
+ glTexEnvf = glTexEnvf@12
+ glTexEnvfv = glTexEnvfv@12
+ glTexEnvi = glTexEnvi@12
+ glTexEnviv = glTexEnviv@12
+ glTexGend = glTexGend@16
+ glTexGendv = glTexGendv@12
+ glTexGenf = glTexGenf@12
+ glTexGenfv = glTexGenfv@12
+ glTexGeni = glTexGeni@12
+ glTexGeniv = glTexGeniv@12
+ glTexImage1D = glTexImage1D@32
+ glTexImage2D = glTexImage2D@36
+ glTexParameterf = glTexParameterf@12
+ glTexParameterfv = glTexParameterfv@12
+ glTexParameteri = glTexParameteri@12
+ glTexParameteriv = glTexParameteriv@12
+ glTexSubImage1D = glTexSubImage1D@28
+ glTexSubImage2D = glTexSubImage2D@36
+ glTranslated = glTranslated@24
+ glTranslatef = glTranslatef@12
+ glVertex2d = glVertex2d@16
+ glVertex2dv = glVertex2dv@4
+ glVertex2f = glVertex2f@8
+ glVertex2fv = glVertex2fv@4
+ glVertex2i = glVertex2i@8
+ glVertex2iv = glVertex2iv@4
+ glVertex2s = glVertex2s@8
+ glVertex2sv = glVertex2sv@4
+ glVertex3d = glVertex3d@24
+ glVertex3dv = glVertex3dv@4
+ glVertex3f = glVertex3f@12
+ glVertex3fv = glVertex3fv@4
+ glVertex3i = glVertex3i@12
+ glVertex3iv = glVertex3iv@4
+ glVertex3s = glVertex3s@12
+ glVertex3sv = glVertex3sv@4
+ glVertex4d = glVertex4d@32
+ glVertex4dv = glVertex4dv@4
+ glVertex4f = glVertex4f@16
+ glVertex4fv = glVertex4fv@4
+ glVertex4i = glVertex4i@16
+ glVertex4iv = glVertex4iv@4
+ glVertex4s = glVertex4s@16
+ glVertex4sv = glVertex4sv@4
+ glVertexPointer = glVertexPointer@16
+ glViewport = glViewport@16
+ wglChoosePixelFormat = wglChoosePixelFormat@8
+ wglCopyContext = wglCopyContext@12
+ wglCreateContext = wglCreateContext@4
+ wglCreateLayerContext = wglCreateLayerContext@8
+ wglDeleteContext = wglDeleteContext@4
+ wglDescribeLayerPlane = wglDescribeLayerPlane@20
+ wglDescribePixelFormat = wglDescribePixelFormat@16
+ wglGetCurrentContext = wglGetCurrentContext@0
+ wglGetCurrentDC = wglGetCurrentDC@0
+; wglGetDefaultProcAddress = wglGetDefaultProcAddress@4
+ wglGetLayerPaletteEntries = wglGetLayerPaletteEntries@20
+ wglGetPixelFormat = wglGetPixelFormat@4
+ wglGetProcAddress = wglGetProcAddress@4
+ wglMakeCurrent = wglMakeCurrent@8
+ wglRealizeLayerPalette = wglRealizeLayerPalette@12
+ wglSetLayerPaletteEntries = wglSetLayerPaletteEntries@20
+ wglSetPixelFormat = wglSetPixelFormat@12
+ wglShareLists = wglShareLists@8
+ wglSwapBuffers = wglSwapBuffers@4
+ wglSwapLayerBuffers = wglSwapLayerBuffers@8
+; wglSwapMultipleBuffers = wglSwapMultipleBuffers@8
+ wglUseFontBitmapsA = wglUseFontBitmapsA@16
+ wglUseFontBitmapsW = wglUseFontBitmapsW@16
+ wglUseFontOutlinesA = wglUseFontOutlinesA@32
+ wglUseFontOutlinesW = wglUseFontOutlinesW@32
+ DrvCopyContext = DrvCopyContext@12
+ DrvCreateContext = DrvCreateContext@4
+ DrvCreateLayerContext = DrvCreateLayerContext@8
+ DrvDeleteContext = DrvDeleteContext@4
+ DrvDescribeLayerPlane = DrvDescribeLayerPlane@20
+ DrvDescribePixelFormat = DrvDescribePixelFormat@16
+ DrvGetLayerPaletteEntries = DrvGetLayerPaletteEntries@20
+ DrvGetProcAddress = DrvGetProcAddress@4
+ DrvRealizeLayerPalette = DrvRealizeLayerPalette@12
+ DrvReleaseContext = DrvReleaseContext@4
+ DrvSetCallbackProcs = DrvSetCallbackProcs@8
+ DrvSetContext = DrvSetContext@12
+ DrvSetLayerPaletteEntries = DrvSetLayerPaletteEntries@20
+ DrvSetPixelFormat = DrvSetPixelFormat@8
+ DrvShareLists = DrvShareLists@8
+ DrvSwapBuffers = DrvSwapBuffers@4
+ DrvSwapLayerBuffers = DrvSwapLayerBuffers@8
+ DrvValidateVersion = DrvValidateVersion@4
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index 2abf97b5ad..d77daac39c 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -40,26 +40,38 @@
#include "stw_public.h"
#include "stw_context.h"
-static struct stw_context *ctx_head = NULL;
-
static HDC current_hdc = NULL;
-static struct stw_context *current_hrc = NULL;
+static UINT_PTR current_hglrc = 0;
BOOL
stw_copy_context(
- struct stw_context *src,
- struct stw_context *dst,
+ UINT_PTR hglrcSrc,
+ UINT_PTR hglrcDst,
UINT mask )
{
- (void) src;
- (void) dst;
- (void) mask;
+ struct stw_context *src;
+ struct stw_context *dst;
+ BOOL ret = FALSE;
+
+ pipe_mutex_lock( stw_dev->mutex );
+
+ src = stw_lookup_context( hglrcSrc );
+ dst = stw_lookup_context( hglrcDst );
+
+ if (src && dst) {
+ /* FIXME */
+ (void) src;
+ (void) dst;
+ (void) mask;
+ }
- return FALSE;
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ return ret;
}
-struct stw_context *
-stw_create_context(
+UINT_PTR
+stw_create_layer_context(
HDC hdc,
int iLayerPlane )
{
@@ -68,19 +80,23 @@ stw_create_context(
struct stw_context *ctx = NULL;
GLvisual *visual = NULL;
struct pipe_context *pipe = NULL;
+ UINT_PTR hglrc = 0;
+ if(!stw_dev)
+ return 0;
+
if (iLayerPlane != 0)
- return NULL;
+ return 0;
pfi = stw_pixelformat_get( hdc );
if (pfi == 0)
- return NULL;
+ return 0;
pf = pixelformat_get_info( pfi - 1 );
ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
- return NULL;
+ return 0;
ctx->hdc = hdc;
ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL );
@@ -119,10 +135,26 @@ stw_create_context(
ctx->st->ctx->DriverCtx = ctx;
- ctx->next = ctx_head;
- ctx_head = ctx;
+ pipe_mutex_lock( stw_dev->mutex );
+ {
+ UINT_PTR i;
+
+ for (i = 0; i < STW_CONTEXT_MAX; i++) {
+ if (stw_dev->ctx_array[i].ctx == NULL) {
+ /* success:
+ */
+ stw_dev->ctx_array[i].ctx = ctx;
+ hglrc = i + 1;
+ break;
+ }
+ }
+ }
+ pipe_mutex_unlock( stw_dev->mutex );
- return ctx;
+ /* Success?
+ */
+ if (hglrc != 0)
+ return hglrc;
fail:
if (visual)
@@ -132,47 +164,83 @@ fail:
pipe->destroy( pipe );
FREE( ctx );
- return NULL;
+ return 0;
}
-
BOOL
stw_delete_context(
- struct stw_context *hglrc )
+ UINT_PTR hglrc )
{
- struct stw_context **link = &ctx_head;
- struct stw_context *ctx = ctx_head;
+ struct stw_context *ctx ;
+ BOOL ret = FALSE;
+
+ if (!stw_dev)
+ return FALSE;
- while (ctx != NULL) {
- if (ctx == hglrc) {
- GLcontext *glctx = ctx->st->ctx;
- GET_CURRENT_CONTEXT( glcurctx );
- struct stw_framebuffer *fb;
+ pipe_mutex_lock( stw_dev->mutex );
- /* Unbind current if deleting current context.
- */
- if (glcurctx == glctx)
- st_make_current( NULL, NULL, NULL );
+ ctx = stw_lookup_context(hglrc);
+ if (ctx) {
+ GLcontext *glctx = ctx->st->ctx;
+ GET_CURRENT_CONTEXT( glcurctx );
+ struct stw_framebuffer *fb;
- fb = framebuffer_from_hdc( ctx->hdc );
- if (fb)
- framebuffer_destroy( fb );
+ /* Unbind current if deleting current context.
+ */
+ if (glcurctx == glctx)
+ st_make_current( NULL, NULL, NULL );
- if (WindowFromDC( ctx->hdc ) != NULL)
- ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc );
+ fb = framebuffer_from_hdc( ctx->hdc );
+ if (fb)
+ framebuffer_destroy( fb );
- st_destroy_context( ctx->st );
+ if (WindowFromDC( ctx->hdc ) != NULL)
+ ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc );
- *link = ctx->next;
- FREE( ctx );
- return TRUE;
- }
+ st_destroy_context( ctx->st );
- link = &ctx->next;
- ctx = ctx->next;
+ FREE( ctx );
+
+ stw_dev->ctx_array[hglrc - 1].ctx = NULL;
+
+ ret = TRUE;
}
- return FALSE;
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ return ret;
+}
+
+BOOL
+stw_release_context(
+ UINT_PTR hglrc )
+{
+ BOOL ret = FALSE;
+
+ if (!stw_dev)
+ return ret;
+
+ pipe_mutex_lock( stw_dev->mutex );
+ {
+ struct stw_context *ctx;
+
+ /* XXX: The expectation is that ctx is the same context which is
+ * current for this thread. We should check that and return False
+ * if not the case.
+ */
+ ctx = stw_lookup_context( hglrc );
+ if (ctx == NULL)
+ goto done;
+
+ if (stw_make_current( NULL, 0 ) == FALSE)
+ goto done;
+
+ ret = TRUE;
+ }
+done:
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ return ret;
}
/* Find the width and height of the window named by hdc.
@@ -193,10 +261,10 @@ get_window_size( HDC hdc, GLuint *width, GLuint *height )
}
}
-struct stw_context *
+UINT_PTR
stw_get_current_context( void )
{
- return current_hrc;
+ return current_hglrc;
}
HDC
@@ -208,35 +276,43 @@ stw_get_current_dc( void )
BOOL
stw_make_current(
HDC hdc,
- struct stw_context *hglrc )
+ UINT_PTR hglrc )
{
- struct stw_context *ctx = ctx_head;
+ struct stw_context *ctx;
GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
GLuint width = 0;
GLuint height = 0;
+ struct stw_context *curctx;
+
+ if (!stw_dev)
+ return FALSE;
+
+ pipe_mutex_lock( stw_dev->mutex );
+ ctx = stw_lookup_context( hglrc );
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ if (ctx == NULL)
+ return FALSE;
current_hdc = hdc;
- current_hrc = hglrc;
+ current_hglrc = hglrc;
- if (hdc == NULL || hglrc == NULL) {
- st_make_current( NULL, NULL, NULL );
- return TRUE;
+ if (glcurctx != NULL) {
+ curctx = (struct stw_context *) glcurctx->DriverCtx;
+
+ if (curctx != ctx)
+ st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
}
- while (ctx != NULL) {
- if (ctx == hglrc)
- break;
- ctx = ctx->next;
+ if (hdc == NULL || hglrc == 0) {
+ st_make_current( NULL, NULL, NULL );
+ return TRUE;
}
- if (ctx == NULL)
- return FALSE;
/* Return if already current.
*/
if (glcurctx != NULL) {
- struct stw_context *curctx = (struct stw_context *) glcurctx->DriverCtx;
-
if (curctx != NULL && curctx == ctx && ctx->hdc == hdc)
return TRUE;
}
@@ -273,20 +349,3 @@ stw_make_current(
return TRUE;
}
-
-struct stw_context *
-stw_context_from_hdc(
- HDC hdc )
-{
- struct stw_context *ctx = ctx_head;
-
- while (ctx != NULL) {
- if (ctx->hdc == hdc)
- return ctx;
- ctx = ctx->next;
- }
- return NULL;
-}
-
-
-
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h
index 89a8f900d8..b289615272 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.h
@@ -37,17 +37,6 @@ struct stw_context
struct st_context *st;
HDC hdc;
DWORD color_bits;
- struct stw_context *next;
};
-struct stw_context *
-stw_context_from_hdc(HDC hdc );
-
-
-
-
-
-
-
-
#endif /* STW_CONTEXT_H */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c
index 6873e813ee..0dca856d73 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_device.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_device.c
@@ -27,14 +27,19 @@
#include <windows.h>
-#include "pipe/p_debug.h"
+#include "glapi/glthread.h"
+#include "util/u_debug.h"
#include "pipe/p_screen.h"
#include "shared/stw_device.h"
#include "shared/stw_winsys.h"
#include "shared/stw_pixelformat.h"
#include "shared/stw_public.h"
-#include "stw.h"
+
+#ifdef WIN32_THREADS
+extern _glthread_Mutex OneTimeLock;
+extern void FreeAllTSD(void);
+#endif
struct stw_device *stw_dev = NULL;
@@ -57,23 +62,35 @@ st_flush_frontbuffer(struct pipe_screen *screen,
boolean
-stw_shared_init(const struct stw_winsys *stw_winsys)
+st_init(const struct stw_winsys *stw_winsys)
{
static struct stw_device stw_dev_storage;
+ debug_printf("%s\n", __FUNCTION__);
+
assert(!stw_dev);
stw_dev = &stw_dev_storage;
memset(stw_dev, 0, sizeof(*stw_dev));
+#ifdef DEBUG
+ stw_dev->memdbg_no = debug_memory_begin();
+#endif
+
stw_dev->stw_winsys = stw_winsys;
+#ifdef WIN32_THREADS
+ _glthread_INIT_MUTEX(OneTimeLock);
+#endif
+
stw_dev->screen = stw_winsys->create_screen();
if(!stw_dev->screen)
goto error1;
stw_dev->screen->flush_frontbuffer = st_flush_frontbuffer;
+ pipe_mutex_init( stw_dev->mutex );
+
pixelformat_init();
return TRUE;
@@ -85,7 +102,51 @@ error1:
void
-stw_shared_cleanup(void)
+st_cleanup(void)
{
+ UINT_PTR i;
+
+ debug_printf("%s\n", __FUNCTION__);
+
+ if (!stw_dev)
+ return;
+
+ pipe_mutex_lock( stw_dev->mutex );
+ {
+ /* Ensure all contexts are destroyed */
+ for (i = 0; i < STW_CONTEXT_MAX; i++)
+ if (stw_dev->ctx_array[i].ctx)
+ stw_delete_context( i + 1 );
+ }
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ pipe_mutex_destroy( stw_dev->mutex );
+
+ stw_dev->screen->destroy(stw_dev->screen);
+
+#ifdef WIN32_THREADS
+ _glthread_DESTROY_MUTEX(OneTimeLock);
+ FreeAllTSD();
+#endif
+
+#ifdef DEBUG
+ debug_memory_end(stw_dev->memdbg_no);
+#endif
+
stw_dev = NULL;
}
+
+
+struct stw_context *
+stw_lookup_context( UINT_PTR dhglrc )
+{
+ if (dhglrc == 0 ||
+ dhglrc >= STW_CONTEXT_MAX)
+ return NULL;
+
+ if (stw_dev == NULL)
+ return NULL;
+
+ return stw_dev->ctx_array[dhglrc - 1].ctx;
+}
+
diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.h b/src/gallium/state_trackers/wgl/shared/stw_device.h
index bc0bce37c6..80da14b84f 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_device.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_device.h
@@ -25,8 +25,15 @@
*
**************************************************************************/
-#ifndef ST_DEVICE_H_
-#define ST_DEVICE_H_
+#ifndef STW_DEVICE_H_
+#define STW_DEVICE_H_
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_thread.h"
+
+
+#define STW_CONTEXT_MAX 32
struct pipe_screen;
@@ -35,10 +42,22 @@ struct stw_device
{
const struct stw_winsys *stw_winsys;
struct pipe_screen *screen;
+
+ pipe_mutex mutex;
+
+ struct {
+ struct stw_context *ctx;
+ } ctx_array[STW_CONTEXT_MAX];
+
+#ifdef DEBUG
+ unsigned long memdbg_no;
+#endif
};
+struct stw_context *
+stw_lookup_context( UINT_PTR hglrc );
extern struct stw_device *stw_dev;
-#endif /* ST_DEVICE_H_ */
+#endif /* STW_DEVICE_H_ */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
index c70b31a488..17c96c411f 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
@@ -79,6 +79,14 @@ window_proc(
return CallWindowProc( fb->WndProc, hWnd, uMsg, wParam, lParam );
}
+static INLINE boolean
+stw_is_supported_depth_stencil(enum pipe_format format)
+{
+ struct pipe_screen *screen = stw_dev->screen;
+ return screen->is_format_supported(screen, format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+}
+
/* Create a new framebuffer object which will correspond to the given HDC.
*/
struct stw_framebuffer *
@@ -101,18 +109,43 @@ framebuffer_create(
if (visual->depthBits == 0)
depthFormat = PIPE_FORMAT_NONE;
- else if (visual->depthBits <= 16)
+ else if (visual->depthBits <= 16 &&
+ stw_is_supported_depth_stencil(PIPE_FORMAT_Z16_UNORM))
depthFormat = PIPE_FORMAT_Z16_UNORM;
- else if (visual->depthBits <= 24)
+ else if (visual->depthBits <= 24 && visual->stencilBits != 8 &&
+ stw_is_supported_depth_stencil(PIPE_FORMAT_X8Z24_UNORM)) {
+ depthFormat = PIPE_FORMAT_X8Z24_UNORM;
+ }
+ else if (visual->depthBits <= 24 && visual->stencilBits != 8 &&
+ stw_is_supported_depth_stencil(PIPE_FORMAT_Z24X8_UNORM)) {
+ depthFormat = PIPE_FORMAT_Z24X8_UNORM;
+ }
+ else if (visual->depthBits <= 24 && visual->stencilBits == 8 &&
+ stw_is_supported_depth_stencil(PIPE_FORMAT_S8Z24_UNORM)) {
depthFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
+ }
+ else if (visual->depthBits <= 24 && visual->stencilBits == 8 &&
+ stw_is_supported_depth_stencil(PIPE_FORMAT_Z24S8_UNORM)) {
+ depthFormat = PIPE_FORMAT_Z24S8_UNORM;
+ }
+ else if(stw_is_supported_depth_stencil(PIPE_FORMAT_Z32_UNORM)) {
depthFormat = PIPE_FORMAT_Z32_UNORM;
+ }
+ else if(stw_is_supported_depth_stencil(PIPE_FORMAT_Z32_FLOAT)) {
+ depthFormat = PIPE_FORMAT_Z32_FLOAT;
+ }
+ else {
+ assert(0);
+ depthFormat = PIPE_FORMAT_NONE;
+ }
- if (visual->stencilBits == 8) {
- if (depthFormat == PIPE_FORMAT_S8Z24_UNORM)
- stencilFormat = depthFormat;
- else
- stencilFormat = PIPE_FORMAT_S8_UNORM;
+ if (depthFormat == PIPE_FORMAT_S8Z24_UNORM ||
+ depthFormat == PIPE_FORMAT_Z24S8_UNORM) {
+ stencilFormat = depthFormat;
+ }
+ else if (visual->stencilBits == 8 &&
+ stw_is_supported_depth_stencil(PIPE_FORMAT_S8_UNORM)) {
+ stencilFormat = PIPE_FORMAT_S8_UNORM;
}
else {
stencilFormat = PIPE_FORMAT_NONE;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
index 84b7b287b9..2992a1ac0a 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "stw_pixelformat.h"
#include "stw_public.h"
@@ -76,6 +76,18 @@ add_standard_pixelformats(
pf->flags = flags;
pf->color = color24;
+ pf->alpha = alpha8;
+ pf->depth = depth16;
+ pf++;
+
+ pf->flags = flags;
+ pf->color = color24;
+ pf->alpha = alpha8;
+ pf->depth = depth24s8;
+ pf++;
+
+ pf->flags = flags;
+ pf->color = color24;
pf->alpha = noalpha;
pf->depth = depth16;
pf++;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_public.h b/src/gallium/state_trackers/wgl/shared/stw_public.h
index 75b504a50f..39d377c16b 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_public.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_public.h
@@ -29,31 +29,24 @@
#define STW_PUBLIC_H
#include <windows.h>
-#include "pipe/p_compiler.h"
-struct stw_winsys;
-struct stw_context;
-
-boolean
-st_shared_init(const struct stw_winsys *stw_winsys);
-
-void
-st_shared_cleanup(void);
-
-
-BOOL stw_copy_context( struct stw_context *src,
- struct stw_context *dst,
+BOOL stw_copy_context( UINT_PTR hglrcSrc,
+ UINT_PTR hglrcDst,
UINT mask );
-struct stw_context *stw_create_context( HDC hdc, int iLayerPlane );
+UINT_PTR stw_create_layer_context( HDC hdc,
+ int iLayerPlane );
+
+BOOL stw_delete_context( UINT_PTR hglrc );
-BOOL stw_delete_context( struct stw_context *ctx );
+BOOL
+stw_release_context( UINT_PTR dhglrc );
-struct stw_context *stw_get_current_context( void );
+UINT_PTR stw_get_current_context( void );
HDC stw_get_current_dc( void );
-BOOL stw_make_current( HDC hdc, struct stw_context *ctx );
+BOOL stw_make_current( HDC hdc, UINT_PTR hglrc );
BOOL stw_swap_buffers( HDC hdc );
diff --git a/src/gallium/state_trackers/wgl/shared/stw_quirks.c b/src/gallium/state_trackers/wgl/shared/stw_quirks.c
index 0961ce3bb0..2f7091a52c 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_quirks.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_quirks.c
@@ -111,3 +111,6 @@ void gl_dispatch_stub_770(void){}
void gl_dispatch_stub_771(void){}
void gl_dispatch_stub_772(void){}
void gl_dispatch_stub_773(void){}
+void gl_dispatch_stub_774(void){}
+void gl_dispatch_stub_750(void){}
+void gl_dispatch_stub_742(void){}
diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
index f50b79b4e1..e06d2640b4 100644
--- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
+++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
@@ -27,25 +27,9 @@
#include <windows.h>
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "shared/stw_public.h"
#include "stw_wgl.h"
-#include "stw.h"
-
-boolean stw_wgl_init( void )
-{
- debug_printf("%s\n", __FUNCTION__);
- return TRUE;
-}
-
-void stw_wgl_cleanup( void )
-{
-}
-
-static INLINE struct stw_context *stw_context( HGLRC hglrc )
-{
- return (struct stw_context *)hglrc;
-}
WINGDIAPI BOOL APIENTRY
@@ -54,8 +38,8 @@ wglCopyContext(
HGLRC hglrcDst,
UINT mask )
{
- return stw_copy_context( stw_context(hglrcSrc),
- stw_context(hglrcDst),
+ return stw_copy_context( (UINT_PTR)hglrcSrc,
+ (UINT_PTR)hglrcDst,
mask );
}
@@ -63,7 +47,7 @@ WINGDIAPI HGLRC APIENTRY
wglCreateContext(
HDC hdc )
{
- return (HGLRC) stw_create_context( hdc, 0 );
+ return wglCreateLayerContext(hdc, 0);
}
WINGDIAPI HGLRC APIENTRY
@@ -71,21 +55,21 @@ wglCreateLayerContext(
HDC hdc,
int iLayerPlane )
{
- return (HGLRC) stw_create_context( hdc, iLayerPlane );
+ return (HGLRC) stw_create_layer_context( hdc, iLayerPlane );
}
WINGDIAPI BOOL APIENTRY
wglDeleteContext(
HGLRC hglrc )
{
- return stw_delete_context( stw_context(hglrc) );
+ return stw_delete_context( (UINT_PTR)hglrc );
}
WINGDIAPI HGLRC APIENTRY
wglGetCurrentContext( VOID )
{
- return (HGLRC) stw_get_current_context();
+ return (HGLRC)stw_get_current_context();
}
WINGDIAPI HDC APIENTRY
@@ -99,7 +83,7 @@ wglMakeCurrent(
HDC hdc,
HGLRC hglrc )
{
- return stw_make_current( hdc, stw_context(hglrc) );
+ return stw_make_current( hdc, (UINT_PTR)hglrc );
}
diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.h b/src/gallium/state_trackers/wgl/wgl/stw_wgl.h
index b86cc240f2..a98179944a 100644
--- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.h
+++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.h
@@ -31,7 +31,7 @@
#include <windows.h>
-#include "GL/gl.h"
+#include <GL/gl.h>
/*
diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile
new file mode 100644
index 0000000000..a00ea3e2a4
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/Makefile
@@ -0,0 +1,29 @@
+TARGET = libxorgtracker.a
+CFILES = $(wildcard ./*.c)
+OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES))
+GALLIUMDIR = ../..
+TOP = ../../../..
+
+include $(TOP)/configs/current
+
+CFLAGS = -DHAVE_CONFIG_H \
+ -g -Wall -Wimplicit-function-declaration -fPIC \
+ $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
+ -I$(GALLIUMDIR)/include \
+ -I$(GALLIUMDIR)/auxiliary \
+ -I$(TOP)/src/mesa/drivers/dri/common \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/include \
+ -I$(TOP)/src/egl/main
+
+#############################################
+
+.PHONY = all clean
+
+all: $(TARGET)
+
+$(TARGET): $(OBJECTS)
+ ar rcs $(TARGET) $(OBJECTS)
+
+clean:
+ rm -rf $(OBJECTS) $(TARGET)
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
new file mode 100644
index 0000000000..7304113a65
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <math.h>
+#include <stdint.h>
+
+#include "xorg-server.h"
+#include <xf86.h>
+#include <xf86i2c.h>
+#include <xf86Crtc.h>
+#include "xorg_tracker.h"
+#include "xf86Modes.h"
+
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+
+#include "pipe/p_inlines.h"
+
+struct crtc_private
+{
+ drmModeCrtcPtr drm_crtc;
+
+ /* hwcursor */
+ struct pipe_buffer *cursor_buf;
+ unsigned cursor_handle;
+};
+
+static void
+crtc_dpms(xf86CrtcPtr crtc, int mode)
+{
+ //ScrnInfoPtr pScrn = crtc->scrn;
+
+ switch (mode) {
+ case DPMSModeOn:
+ case DPMSModeStandby:
+ case DPMSModeSuspend:
+ break;
+ case DPMSModeOff:
+ break;
+ }
+}
+
+static Bool
+crtc_lock(xf86CrtcPtr crtc)
+{
+ return FALSE;
+}
+
+static void
+crtc_unlock(xf86CrtcPtr crtc)
+{
+}
+
+static void
+crtc_prepare(xf86CrtcPtr crtc)
+{
+}
+
+static void
+crtc_commit(xf86CrtcPtr crtc)
+{
+}
+
+static Bool
+crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
+ DisplayModePtr adjusted_mode)
+{
+ return TRUE;
+}
+
+static void
+crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
+ DisplayModePtr adjusted_mode, int x, int y)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ xf86OutputPtr output = config->output[config->compat_output];
+ drmModeConnectorPtr drm_connector = output->driver_private;
+ struct crtc_private *crtcp = crtc->driver_private;
+ drmModeCrtcPtr drm_crtc = crtcp->drm_crtc;
+ drmModeModeInfo drm_mode;
+
+ drm_mode.clock = mode->Clock;
+ drm_mode.hdisplay = mode->HDisplay;
+ drm_mode.hsync_start = mode->HSyncStart;
+ drm_mode.hsync_end = mode->HSyncEnd;
+ drm_mode.htotal = mode->HTotal;
+ drm_mode.vdisplay = mode->VDisplay;
+ drm_mode.vsync_start = mode->VSyncStart;
+ drm_mode.vsync_end = mode->VSyncEnd;
+ drm_mode.vtotal = mode->VTotal;
+ drm_mode.flags = mode->Flags;
+ drm_mode.hskew = mode->HSkew;
+ drm_mode.vscan = mode->VScan;
+ drm_mode.vrefresh = mode->VRefresh;
+ if (!mode->name)
+ xf86SetModeDefaultName(mode);
+ strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN);
+
+ drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y,
+ &drm_connector->connector_id, 1, &drm_mode);
+}
+
+#if 0
+static void
+crtc_load_lut(xf86CrtcPtr crtc)
+{
+ //ScrnInfoPtr pScrn = crtc->scrn;
+}
+#endif
+
+static void
+crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue,
+ int size)
+{
+}
+
+static void *
+crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
+{
+ //ScrnInfoPtr pScrn = crtc->scrn;
+
+ return NULL;
+}
+
+static PixmapPtr
+crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
+{
+ //ScrnInfoPtr pScrn = crtc->scrn;
+
+ return NULL;
+}
+
+static void
+crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
+{
+ //ScrnInfoPtr pScrn = crtc->scrn;
+}
+
+static void
+crtc_destroy(xf86CrtcPtr crtc)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ struct crtc_private *crtcp = crtc->driver_private;
+
+ if (crtcp->cursor_buf)
+ pipe_buffer_reference(&crtcp->cursor_buf, NULL);
+
+ drmModeFreeCrtc(crtcp->drm_crtc);
+ xfree(crtcp);
+}
+
+static void
+crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
+{
+ unsigned char *ptr;
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ struct crtc_private *crtcp = crtc->driver_private;
+
+ if (!crtcp->cursor_buf) {
+ crtcp->cursor_buf = pipe_buffer_create(ms->screen,
+ 0,
+ PIPE_BUFFER_USAGE_CPU_WRITE |
+ PIPE_BUFFER_USAGE_GPU_READ,
+ 64*64*4);
+ drm_api_hooks.handle_from_buffer(ms->screen,
+ crtcp->cursor_buf,
+ &crtcp->cursor_handle);
+ }
+
+ ptr = pipe_buffer_map(ms->screen, crtcp->cursor_buf, PIPE_BUFFER_USAGE_CPU_WRITE);
+
+ if (ptr)
+ memcpy(ptr, image, 64 * 64 * 4);
+
+ pipe_buffer_unmap(ms->screen, crtcp->cursor_buf);
+}
+
+static void
+crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ struct crtc_private *crtcp = crtc->driver_private;
+
+ drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y);
+}
+
+static void
+crtc_show_cursor(xf86CrtcPtr crtc)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ struct crtc_private *crtcp = crtc->driver_private;
+
+ if (crtcp->cursor_buf)
+ drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id,
+ crtcp->cursor_handle, 64, 64);
+}
+
+static void
+crtc_hide_cursor(xf86CrtcPtr crtc)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ struct crtc_private *crtcp = crtc->driver_private;
+
+ drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0);
+}
+
+static const xf86CrtcFuncsRec crtc_funcs = {
+ .dpms = crtc_dpms,
+ .save = NULL,
+ .restore = NULL,
+ .lock = crtc_lock,
+ .unlock = crtc_unlock,
+ .mode_fixup = crtc_mode_fixup,
+ .prepare = crtc_prepare,
+ .mode_set = crtc_mode_set,
+ .commit = crtc_commit,
+ .gamma_set = crtc_gamma_set,
+ .shadow_create = crtc_shadow_create,
+ .shadow_allocate = crtc_shadow_allocate,
+ .shadow_destroy = crtc_shadow_destroy,
+ .set_cursor_position = crtc_set_cursor_position,
+ .show_cursor = crtc_show_cursor,
+ .hide_cursor = crtc_hide_cursor,
+ .load_cursor_image = NULL, /* lets convert to argb only */
+ .set_cursor_colors = NULL, /* using argb only */
+ .load_cursor_argb = crtc_load_cursor_argb,
+ .destroy = crtc_destroy,
+};
+
+void
+cursor_destroy(xf86CrtcPtr crtc)
+{
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ struct crtc_private *crtcp = crtc->driver_private;
+
+ if (crtcp->cursor_buf) {
+ pipe_buffer_reference(&crtcp->cursor_buf, NULL);
+ }
+}
+
+void
+crtc_init(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ xf86CrtcPtr crtc;
+ drmModeResPtr res;
+ drmModeCrtcPtr drm_crtc = NULL;
+ struct crtc_private *crtcp;
+ int c;
+
+ res = drmModeGetResources(ms->fd);
+ if (res == 0) {
+ ErrorF("Failed drmModeGetResources %d\n", errno);
+ return;
+ }
+
+ for (c = 0; c < res->count_crtcs; c++) {
+ drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]);
+ if (!drm_crtc)
+ continue;
+
+ crtc = xf86CrtcCreate(pScrn, &crtc_funcs);
+ if (crtc == NULL)
+ goto out;
+
+ crtcp = xcalloc(1, sizeof(struct crtc_private));
+ if (!crtcp) {
+ xf86CrtcDestroy(crtc);
+ goto out;
+ }
+
+ crtcp->drm_crtc = drm_crtc;
+
+ crtc->driver_private = crtcp;
+
+ }
+
+ out:
+ drmModeFreeResources(res);
+}
+
+/* vim: set sw=4 ts=8 sts=4: */
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
new file mode 100644
index 0000000000..d04204e1bf
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "xorg_tracker.h"
+
+#include "dri2.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
+
+typedef struct {
+ PixmapPtr pPixmap;
+ struct pipe_texture *tex;
+ struct pipe_buffer *buf;
+} *BufferPrivatePtr;
+
+static DRI2BufferPtr
+driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
+{
+ struct pipe_texture *depth, *tex;
+ struct pipe_buffer *buf;
+ ScreenPtr pScreen = pDraw->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ BufferPrivatePtr privates;
+ DRI2BufferPtr buffers;
+ PixmapPtr pPixmap;
+ unsigned stride, handle;
+ int i;
+
+ buffers = xcalloc(count, sizeof *buffers);
+ if (!buffers)
+ goto fail_buffers;
+
+ privates = xcalloc(count, sizeof *privates);
+ if (!privates)
+ goto fail_privates;
+
+ depth = NULL;
+ for (i = 0; i < count; i++) {
+ pPixmap = NULL;
+ tex = NULL;
+ buf = NULL;
+ if (attachments[i] == DRI2BufferFrontLeft) {
+ if (pDraw->type == DRAWABLE_PIXMAP)
+ pPixmap = (PixmapPtr) pDraw;
+ else
+ pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
+ pPixmap->refcnt++;
+ tex = xorg_exa_get_texture(pPixmap);
+ } else if (attachments[i] == DRI2BufferStencil) {
+ pipe_texture_reference(&tex, depth);
+ } else if (attachments[i] == DRI2BufferDepth) {
+ struct pipe_texture template;
+
+ memset(&template, 0, sizeof(template));
+ template.target = PIPE_TEXTURE_2D;
+ template.compressed = 0;
+ template.format = PIPE_FORMAT_S8Z24_UNORM;
+ pf_get_block(template.format, &template.block);
+ template.width[0] = pDraw->width;
+ template.height[0] = pDraw->height;
+ template.depth[0] = 1;
+ template.last_level = 0;
+ template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ tex = ms->screen->texture_create(ms->screen, &template);
+ } else {
+ struct pipe_texture template;
+ memset(&template, 0, sizeof(template));
+ template.target = PIPE_TEXTURE_2D;
+ template.compressed = 0;
+ template.format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ pf_get_block(template.format, &template.block);
+ template.width[0] = pDraw->width;
+ template.height[0] = pDraw->height;
+ template.depth[0] = 1;
+ template.last_level = 0;
+ template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ tex = ms->screen->texture_create(ms->screen, &template);
+ }
+
+ drm_api_hooks.buffer_from_texture(tex, &buf, &stride);
+ drm_api_hooks.global_handle_from_buffer(ms->screen, buf, &handle);
+
+ buffers[i].name = handle;
+ buffers[i].attachment = attachments[i];
+ buffers[i].pitch = stride;
+ buffers[i].cpp = 4;
+ buffers[i].driverPrivate = &privates[i];
+ buffers[i].flags = 0; /* not tiled */
+ privates[i].pPixmap = pPixmap;
+ privates[i].buf = buf;
+ privates[i].tex = tex;
+ }
+
+ return buffers;
+
+fail_privates:
+ xfree(buffers);
+fail_buffers:
+ return NULL;
+}
+
+static void
+driDestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ BufferPrivatePtr private;
+ int i;
+
+ for (i = 0; i < count; i++) {
+ private = buffers[i].driverPrivate;
+
+ if (private->pPixmap)
+ (*pScreen->DestroyPixmap)(private->pPixmap);
+
+ pipe_texture_reference(&private->tex, NULL);
+ pipe_buffer_reference(&private->buf, NULL);
+ }
+
+ if (buffers) {
+ xfree(buffers[0].driverPrivate);
+ xfree(buffers);
+ }
+}
+
+static void
+driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
+ DRI2BufferPtr pDestBuffer, DRI2BufferPtr pSrcBuffer)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ BufferPrivatePtr dst_priv = pDestBuffer->driverPrivate;
+ BufferPrivatePtr src_priv = pSrcBuffer->driverPrivate;
+
+ struct pipe_surface *dst_surf =
+ ms->screen->get_tex_surface(ms->screen, dst_priv->tex, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+ struct pipe_surface *src_surf =
+ ms->screen->get_tex_surface(ms->screen, src_priv->tex, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_READ);
+
+ ms->ctx->surface_copy(ms->ctx, dst_surf, 0, 0, src_surf,
+ 0, 0, pDraw->width, pDraw->height);
+
+ pipe_surface_reference(&dst_surf, NULL);
+ pipe_surface_reference(&src_surf, NULL);
+}
+
+Bool
+driScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ DRI2InfoRec dri2info;
+
+ dri2info.version = 1;
+ dri2info.fd = ms->fd;
+#if 0
+ dri2info.driverName = pScrn->name;
+#else
+ dri2info.driverName = "i915"; /* FIXME */
+#endif
+ dri2info.deviceName = "/dev/dri/card0"; /* FIXME */
+
+ dri2info.CreateBuffers = driCreateBuffers;
+ dri2info.DestroyBuffers = driDestroyBuffers;
+ dri2info.CopyRegion = driCopyRegion;
+
+ return DRI2ScreenInit(pScreen, &dri2info);
+}
+
+void
+driCloseScreen(ScreenPtr pScreen)
+{
+ DRI2CloseScreen(pScreen);
+}
+
+/* vim: set sw=4 ts=8 sts=4: */
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
new file mode 100644
index 0000000000..8a2711e70c
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -0,0 +1,695 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+
+#include "xorg-server.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "compiler.h"
+#include "xf86RAC.h"
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+#include "xf86Resources.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include <X11/extensions/randr.h>
+#include "fb.h"
+#include "edid.h"
+#include "xf86i2c.h"
+#include "xf86Crtc.h"
+#include "miscstruct.h"
+#include "dixstruct.h"
+#include "xf86xv.h"
+#include <X11/extensions/Xv.h>
+#ifndef XSERVER_LIBPCIACCESS
+#error "libpciaccess needed"
+#endif
+
+#include <pciaccess.h>
+
+#include "xorg_tracker.h"
+#include "xorg_winsys.h"
+
+static void AdjustFrame(int scrnIndex, int x, int y, int flags);
+static Bool CloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool EnterVT(int scrnIndex, int flags);
+static Bool SaveHWState(ScrnInfoPtr pScrn);
+static Bool RestoreHWState(ScrnInfoPtr pScrn);
+
+
+static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+static void FreeScreen(int scrnIndex, int flags);
+static void LeaveVT(int scrnIndex, int flags);
+static Bool SwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool PreInit(ScrnInfoPtr pScrn, int flags);
+
+typedef enum
+{
+ OPTION_SW_CURSOR,
+} modesettingOpts;
+
+static const OptionInfoRec Options[] = {
+ {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE}
+};
+
+/*
+ * Functions that might be needed
+ */
+
+static const char *exaSymbols[] = {
+ "exaGetVersion",
+ "exaDriverInit",
+ "exaDriverFini",
+ "exaOffscreenAlloc",
+ "exaOffscreenFree",
+ "exaWaitSync",
+ NULL
+};
+
+static const char *fbSymbols[] = {
+ "fbPictureInit",
+ "fbScreenInit",
+ NULL
+};
+
+static const char *ddcSymbols[] = {
+ "xf86PrintEDID",
+ "xf86SetDDCproperties",
+ NULL
+};
+
+/*
+ * Exported Xorg driver functions to winsys
+ */
+
+void
+xorg_tracker_loader_ref_sym_lists()
+{
+ LoaderRefSymLists(exaSymbols, fbSymbols, ddcSymbols, NULL);
+}
+
+const OptionInfoRec *
+xorg_tracker_available_options(int chipid, int busid)
+{
+ return Options;
+}
+
+void
+xorg_tracker_set_functions(ScrnInfoPtr scrn)
+{
+ scrn->PreInit = PreInit;
+ scrn->ScreenInit = ScreenInit;
+ scrn->SwitchMode = SwitchMode;
+ scrn->AdjustFrame = AdjustFrame;
+ scrn->EnterVT = EnterVT;
+ scrn->LeaveVT = LeaveVT;
+ scrn->FreeScreen = FreeScreen;
+ scrn->ValidMode = ValidMode;
+}
+
+/*
+ * Static Xorg funtctions
+ */
+
+static Bool
+GetRec(ScrnInfoPtr pScrn)
+{
+ if (pScrn->driverPrivate)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1);
+
+ return TRUE;
+}
+
+static void
+FreeRec(ScrnInfoPtr pScrn)
+{
+ if (!pScrn)
+ return;
+
+ if (!pScrn->driverPrivate)
+ return;
+
+ xfree(pScrn->driverPrivate);
+
+ pScrn->driverPrivate = NULL;
+}
+
+static void
+ProbeDDC(ScrnInfoPtr pScrn, int index)
+{
+ ConfiguredMonitor = NULL;
+}
+
+static Bool
+CreateFrontBuffer(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ ScreenPtr pScreen = pScrn->pScreen;
+ PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
+
+ ms->noEvict = TRUE;
+ pScreen->ModifyPixmapHeader(rootPixmap,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->depth, pScrn->bitsPerPixel,
+ pScrn->displayWidth * pScrn->bitsPerPixel / 8,
+ NULL);
+ ms->noEvict = FALSE;
+
+ drmModeAddFB(ms->fd,
+ pScrn->virtualX,
+ pScrn->virtualY,
+ pScrn->depth,
+ pScrn->bitsPerPixel,
+ pScrn->displayWidth * pScrn->bitsPerPixel / 8,
+ xorg_exa_get_pixmap_handle(rootPixmap), &ms->fb_id);
+
+ pScrn->frameX0 = 0;
+ pScrn->frameY0 = 0;
+ AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+ return TRUE;
+}
+
+static Bool
+crtc_resize(ScrnInfoPtr pScrn, int width, int height)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ //ScreenPtr pScreen = pScrn->pScreen;
+ //PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
+ //Bool fbAccessDisabled;
+ //CARD8 *fbstart;
+
+ if (width == pScrn->virtualX && height == pScrn->virtualY)
+ return TRUE;
+
+ ErrorF("RESIZING TO %dx%d\n", width, height);
+
+ pScrn->virtualX = width;
+ pScrn->virtualY = height;
+
+ /* HW dependent - FIXME */
+ pScrn->displayWidth = pScrn->virtualX;
+
+ drmModeRmFB(ms->fd, ms->fb_id);
+
+ /* now create new frontbuffer */
+ return CreateFrontBuffer(pScrn);
+}
+
+static const xf86CrtcConfigFuncsRec crtc_config_funcs = {
+ crtc_resize
+};
+
+static Bool
+PreInit(ScrnInfoPtr pScrn, int flags)
+{
+ xf86CrtcConfigPtr xf86_config;
+ modesettingPtr ms;
+ rgb defaultWeight = { 0, 0, 0 };
+ EntityInfoPtr pEnt;
+ EntPtr msEnt = NULL;
+ char *BusID;
+ int max_width, max_height;
+
+ if (pScrn->numEntities != 1)
+ return FALSE;
+
+ pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+
+ if (flags & PROBE_DETECT) {
+ ProbeDDC(pScrn, pEnt->index);
+ return TRUE;
+ }
+
+ /* Allocate driverPrivate */
+ if (!GetRec(pScrn))
+ return FALSE;
+
+ ms = modesettingPTR(pScrn);
+ ms->SaveGeneration = -1;
+ ms->pEnt = pEnt;
+
+ pScrn->displayWidth = 640; /* default it */
+
+ if (ms->pEnt->location.type != BUS_PCI)
+ return FALSE;
+
+ ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
+
+ /* Allocate an entity private if necessary */
+ if (xf86IsEntityShared(pScrn->entityList[0])) {
+ FatalError("Entity");
+#if 0
+ msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
+ modesettingEntityIndex)->ptr;
+ ms->entityPrivate = msEnt;
+#else
+ (void)msEnt;
+#endif
+ } else
+ ms->entityPrivate = NULL;
+
+ if (xf86RegisterResources(ms->pEnt->index, NULL, ResNone)) {
+ return FALSE;
+ }
+
+ if (xf86IsEntityShared(pScrn->entityList[0])) {
+ if (xf86IsPrimInitDone(pScrn->entityList[0])) {
+ /* do something */
+ } else {
+ xf86SetPrimInitDone(pScrn->entityList[0]);
+ }
+ }
+
+ BusID = xalloc(64);
+ sprintf(BusID, "PCI:%d:%d:%d",
+ ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
+ ms->PciInfo->dev, ms->PciInfo->func
+ );
+
+ ms->fd = drmOpen(NULL, BusID);
+
+ if (ms->fd < 0)
+ return FALSE;
+
+ pScrn->racMemFlags = RAC_FB | RAC_COLORMAP;
+ pScrn->monitor = pScrn->confScreen->monitor;
+ pScrn->progClock = TRUE;
+ pScrn->rgbBits = 8;
+
+ if (!xf86SetDepthBpp
+ (pScrn, 0, 0, 0,
+ PreferConvert24to32 | SupportConvert24to32 | Support32bppFb))
+ return FALSE;
+
+ switch (pScrn->depth) {
+ case 15:
+ case 16:
+ case 24:
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by the driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ xf86PrintDepthBpp(pScrn);
+
+ if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight))
+ return FALSE;
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+
+ /* Process the options */
+ xf86CollectOptions(pScrn, NULL);
+ if (!(ms->Options = xalloc(sizeof(Options))))
+ return FALSE;
+ memcpy(ms->Options, Options, sizeof(Options));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
+
+ /* Allocate an xf86CrtcConfig */
+ xf86CrtcConfigInit(pScrn, &crtc_config_funcs);
+ xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+
+ max_width = 8192;
+ max_height = 8192;
+ xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height);
+
+ if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) {
+ ms->SWCursor = TRUE;
+ }
+
+ SaveHWState(pScrn);
+
+ crtc_init(pScrn);
+ output_init(pScrn);
+
+ if (!xf86InitialConfiguration(pScrn, TRUE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n");
+ RestoreHWState(pScrn);
+ return FALSE;
+ }
+
+ RestoreHWState(pScrn);
+
+ /*
+ * If the driver can do gamma correction, it should call xf86SetGamma() here.
+ */
+ {
+ Gamma zeros = { 0.0, 0.0, 0.0 };
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ if (pScrn->modes == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
+ return FALSE;
+ }
+
+ pScrn->currentMode = pScrn->modes;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ /* Load the required sub modules */
+ if (!xf86LoadSubModule(pScrn, "fb")) {
+ return FALSE;
+ }
+
+ xf86LoaderReqSymLists(fbSymbols, NULL);
+
+ xf86LoadSubModule(pScrn, "exa");
+
+#ifdef DRI2
+ xf86LoadSubModule(pScrn, "dri2");
+#endif
+
+ return TRUE;
+}
+
+static Bool
+SaveHWState(ScrnInfoPtr pScrn)
+{
+ /*xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);*/
+
+ return TRUE;
+}
+
+static Bool
+RestoreHWState(ScrnInfoPtr pScrn)
+{
+ /*xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);*/
+
+ return TRUE;
+}
+
+static Bool
+CreateScreenResources(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ PixmapPtr rootPixmap;
+ Bool ret;
+
+ ms->noEvict = TRUE;
+
+ pScreen->CreateScreenResources = ms->createScreenResources;
+ ret = pScreen->CreateScreenResources(pScreen);
+ pScreen->CreateScreenResources = CreateScreenResources;
+
+ rootPixmap = pScreen->GetScreenPixmap(pScreen);
+
+ if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
+ FatalError("Couldn't adjust screen pixmap\n");
+
+ ms->noEvict = FALSE;
+
+ drmModeAddFB(ms->fd,
+ pScrn->virtualX,
+ pScrn->virtualY,
+ pScrn->depth,
+ pScrn->bitsPerPixel,
+ pScrn->displayWidth * pScrn->bitsPerPixel / 8,
+ xorg_exa_get_pixmap_handle(rootPixmap), &ms->fb_id);
+
+ AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+ return ret;
+}
+
+static Bool
+ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ VisualPtr visual;
+
+ /* deal with server regeneration */
+ if (ms->fd < 0) {
+ char *BusID;
+
+ BusID = xalloc(64);
+ sprintf(BusID, "PCI:%d:%d:%d",
+ ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
+ ms->PciInfo->dev, ms->PciInfo->func
+ );
+
+ ms->fd = drmOpen(NULL, BusID);
+
+ if (ms->fd < 0)
+ return FALSE;
+ }
+
+ if (!ms->screen) {
+ ms->screen = drm_api_hooks.create_screen(ms->fd, ms->PciInfo->device_id);
+
+ if (!ms->screen) {
+ FatalError("Could not init pipe_screen\n");
+ return FALSE;
+ }
+ }
+
+ pScrn->pScreen = pScreen;
+
+ /* HW dependent - FIXME */
+ pScrn->displayWidth = pScrn->virtualX;
+
+ miClearVisualTypes();
+
+ if (!miSetVisualTypes(pScrn->depth,
+ miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
+
+ if (!miSetPixmapDepths())
+ return FALSE;
+
+ pScrn->memPhysBase = 0;
+ pScrn->fbOffset = 0;
+
+ if (!fbScreenInit(pScreen, NULL,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth, pScrn->bitsPerPixel))
+ return FALSE;
+
+ if (pScrn->bitsPerPixel > 8) {
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = pScrn->offset.red;
+ visual->offsetGreen = pScrn->offset.green;
+ visual->offsetBlue = pScrn->offset.blue;
+ visual->redMask = pScrn->mask.red;
+ visual->greenMask = pScrn->mask.green;
+ visual->blueMask = pScrn->mask.blue;
+ }
+ }
+ }
+
+ fbPictureInit(pScreen, NULL, 0);
+
+ ms->createScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = CreateScreenResources;
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ ms->exa = xorg_exa_init(pScrn);
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+ /* Need to extend HWcursor support to handle mask interleave */
+ if (!ms->SWCursor)
+ xf86_cursors_init(pScreen, 64, 64,
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
+ HARDWARE_CURSOR_ARGB);
+
+ /* Must force it before EnterVT, so we are in control of VT and
+ * later memory should be bound when allocating, e.g rotate_mem */
+ pScrn->vtSema = TRUE;
+
+ pScreen->SaveScreen = xf86SaveScreen;
+ ms->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = CloseScreen;
+
+ if (!xf86CrtcScreenInit(pScreen))
+ return FALSE;
+
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ xf86DPMSInit(pScreen, xf86DPMSSet, 0);
+
+ if (serverGeneration == 1)
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+
+#if 1
+#ifdef DRI2
+ driScreenInit(pScreen);
+#endif
+#endif
+
+ return EnterVT(scrnIndex, 1);
+}
+
+static void
+AdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ xf86OutputPtr output = config->output[config->compat_output];
+ xf86CrtcPtr crtc = output->crtc;
+
+ if (crtc && crtc->enabled) {
+ crtc->funcs->mode_set(crtc, pScrn->currentMode, pScrn->currentMode, x,
+ y);
+ crtc->x = output->initial_x + x;
+ crtc->y = output->initial_y + y;
+ }
+}
+
+static void
+FreeScreen(int scrnIndex, int flags)
+{
+ FreeRec(xf86Screens[scrnIndex]);
+}
+
+/* HACK */
+void
+cursor_destroy(xf86CrtcPtr crtc);
+
+static void
+LeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int o;
+
+ for (o = 0; o < config->num_crtc; o++) {
+ xf86CrtcPtr crtc = config->crtc[o];
+
+ cursor_destroy(crtc);
+
+ if (crtc->rotatedPixmap || crtc->rotatedData) {
+ crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
+ crtc->rotatedData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+ }
+
+ drmModeRmFB(ms->fd, ms->fb_id);
+
+ RestoreHWState(pScrn);
+
+ pScrn->vtSema = FALSE;
+}
+
+/*
+ * This gets called when gaining control of the VT, and from ScreenInit().
+ */
+static Bool
+EnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ modesettingPtr ms = modesettingPTR(pScrn);
+
+ /*
+ * Only save state once per server generation since that's what most
+ * drivers do. Could change this to save state at each VT enter.
+ */
+ if (ms->SaveGeneration != serverGeneration) {
+ ms->SaveGeneration = serverGeneration;
+ SaveHWState(pScrn);
+ }
+
+ if (!flags) /* signals startup as we'll do this in CreateScreenResources */
+ CreateFrontBuffer(pScrn);
+
+ if (!xf86SetDesiredModes(pScrn))
+ return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ return xf86SetSingleMode(pScrn, mode, RR_Rotate_0);
+}
+
+static Bool
+CloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ modesettingPtr ms = modesettingPTR(pScrn);
+
+ if (pScrn->vtSema) {
+ LeaveVT(scrnIndex, 0);
+ }
+#ifdef DRI2
+ driCloseScreen(pScreen);
+#endif
+
+ pScreen->CreateScreenResources = ms->createScreenResources;
+
+ if (ms->exa)
+ xorg_exa_close(pScrn);
+
+ drmClose(ms->fd);
+ ms->fd = -1;
+
+ pScrn->vtSema = FALSE;
+ pScreen->CloseScreen = ms->CloseScreen;
+ return (*pScreen->CloseScreen) (scrnIndex, pScreen);
+}
+
+static ModeStatus
+ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ return MODE_OK;
+}
+
+/* vim: set sw=4 ts=8 sts=4: */
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
new file mode 100644
index 0000000000..56c8fdccb2
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -0,0 +1,528 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "xf86.h"
+#include "xorg_tracker.h"
+
+#include "pipe/p_format.h"
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
+
+struct exa_entity
+{
+ ExaDriverPtr pExa;
+ struct pipe_context *ctx;
+ struct pipe_screen *scrn;
+};
+
+struct PixmapPriv
+{
+ int flags;
+ struct pipe_texture *tex;
+ unsigned int color;
+ struct pipe_surface *src_surf; /* for copies */
+
+ struct pipe_transfer *map_transfer;
+ unsigned map_count;
+};
+
+/*
+ * Helper functions
+ */
+
+static void
+exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp)
+{
+ switch (depth) {
+ case 32:
+ *format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ assert(*bbp == 32);
+ break;
+ case 24:
+ *format = PIPE_FORMAT_X8R8G8B8_UNORM;
+ assert(*bbp == 32);
+ break;
+ case 16:
+ *format = PIPE_FORMAT_R5G6B5_UNORM;
+ assert(*bbp == 16);
+ break;
+ case 15:
+ *format = PIPE_FORMAT_A1R5G5B5_UNORM;
+ assert(*bbp == 16);
+ break;
+ case 8:
+ case 4:
+ case 1:
+ *format = PIPE_FORMAT_A8R8G8B8_UNORM; /* bad bad bad */
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+/*
+ * Static exported EXA functions
+ */
+
+static void
+ExaWaitMarker(ScreenPtr pScreen, int marker)
+{
+}
+
+static int
+ExaMarkSync(ScreenPtr pScreen)
+{
+ return 1;
+}
+
+static Bool
+ExaPrepareAccess(PixmapPtr pPix, int index)
+{
+ ScreenPtr pScreen = pPix->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_entity *exa = ms->exa;
+ struct PixmapPriv *priv;
+
+ priv = exaGetPixmapDriverPrivate(pPix);
+
+ if (!priv)
+ return FALSE;
+
+ if (!priv->tex)
+ return FALSE;
+
+ if (priv->map_count++ == 0)
+ {
+ priv->map_transfer =
+ exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0,
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0, priv->tex->width[0], priv->tex->height[0]);
+
+ pPix->devPrivate.ptr =
+ exa->scrn->transfer_map(exa->scrn, priv->map_transfer);
+ pPix->devKind = priv->map_transfer->stride;
+ }
+
+ return TRUE;
+}
+
+static void
+ExaFinishAccess(PixmapPtr pPix, int index)
+{
+ ScreenPtr pScreen = pPix->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_entity *exa = ms->exa;
+ struct PixmapPriv *priv;
+ priv = exaGetPixmapDriverPrivate(pPix);
+
+ if (!priv)
+ return;
+
+ if (!priv->map_transfer)
+ return;
+
+ if (--priv->map_count == 0) {
+ assert(priv->map_transfer);
+ exa->scrn->transfer_unmap(exa->scrn, priv->map_transfer);
+ exa->scrn->tex_transfer_destroy(priv->map_transfer);
+ priv->map_transfer = NULL;
+ }
+}
+
+static void
+ExaDone(PixmapPtr pPixmap)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct exa_entity *exa = ms->exa;
+
+ if (!priv)
+ return;
+
+ if (priv->src_surf)
+ exa->scrn->tex_surface_destroy(priv->src_surf);
+ priv->src_surf = NULL;
+}
+
+static void
+ExaDoneComposite(PixmapPtr pPixmap)
+{
+
+}
+
+static Bool
+ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct exa_entity *exa = ms->exa;
+
+ if (1)
+ return FALSE;
+
+ if (pPixmap->drawable.depth < 15)
+ return FALSE;
+
+ if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planeMask))
+ return FALSE;
+
+ if (!priv || !priv->tex)
+ return FALSE;
+
+ if (alu != GXcopy)
+ return FALSE;
+
+ if (!exa->ctx || !exa->ctx->surface_fill)
+ return FALSE;
+
+ priv->color = fg;
+
+ return TRUE;
+}
+
+static void
+ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_entity *exa = ms->exa;
+ struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct pipe_surface *surf =
+ exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+
+ exa->ctx->surface_fill(exa->ctx, surf, x0, y0, x1 - x0, y1 - y0,
+ priv->color);
+
+ exa->scrn->tex_surface_destroy(surf);
+}
+
+static Bool
+ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
+ int ydir, int alu, Pixel planeMask)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_entity *exa = ms->exa;
+ struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
+ struct PixmapPriv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap);
+
+ if (1)
+ return FALSE;
+
+ if (alu != GXcopy)
+ return FALSE;
+
+ if (pSrcPixmap->drawable.depth < 15 || pDstPixmap->drawable.depth < 15)
+ return FALSE;
+
+ if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask))
+ return FALSE;
+
+ if (!priv || !src_priv)
+ return FALSE;
+
+ if (!priv->tex || !src_priv->tex)
+ return FALSE;
+
+ if (!exa->ctx || !exa->ctx->surface_copy)
+ return FALSE;
+
+ priv->src_surf =
+ exa->scrn->get_tex_surface(exa->scrn, src_priv->tex, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+
+ return TRUE;
+}
+
+static void
+ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
+ int width, int height)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_entity *exa = ms->exa;
+ struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
+ struct pipe_surface *surf =
+ exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+
+ exa->ctx->surface_copy(exa->ctx, surf, dstX, dstY, priv->src_surf,
+ srcX, srcY, width, height);
+ exa->scrn->tex_surface_destroy(surf);
+}
+
+static Bool
+ExaPrepareComposite(int op, PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture, PicturePtr pDstPicture,
+ PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
+{
+ return FALSE;
+}
+
+static void
+ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
+ int dstX, int dstY, int width, int height)
+{
+}
+
+static Bool
+ExaCheckComposite(int op,
+ PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ return FALSE;
+}
+
+static void *
+ExaCreatePixmap(ScreenPtr pScreen, int size, int align)
+{
+ struct PixmapPriv *priv;
+
+ priv = xcalloc(1, sizeof(struct PixmapPriv));
+ if (!priv)
+ return NULL;
+
+ return priv;
+}
+
+static void
+ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv)
+{
+ struct PixmapPriv *priv = (struct PixmapPriv *)dPriv;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+
+ if (!priv)
+ return;
+
+ if (priv->tex)
+ ms->screen->texture_destroy(priv->tex);
+
+ xfree(priv);
+}
+
+static Bool
+ExaPixmapIsOffscreen(PixmapPtr pPixmap)
+{
+ struct PixmapPriv *priv;
+
+ priv = exaGetPixmapDriverPrivate(pPixmap);
+
+ if (!priv)
+ return FALSE;
+
+ if (priv->tex)
+ return TRUE;
+
+ return FALSE;
+}
+
+unsigned
+xorg_exa_get_pixmap_handle(PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct PixmapPriv *priv;
+ struct pipe_buffer *buffer = NULL;
+ unsigned handle;
+ unsigned stride;
+
+ if (!ms->exa) {
+ FatalError("NO MS->EXA\n");
+ return 0;
+ }
+
+ priv = exaGetPixmapDriverPrivate(pPixmap);
+
+ if (!priv) {
+ FatalError("NO PIXMAP PRIVATE\n");
+ return 0;
+ }
+
+ drm_api_hooks.buffer_from_texture(priv->tex, &buffer, &stride);
+ drm_api_hooks.handle_from_buffer(ms->screen, buffer, &handle);
+ pipe_buffer_reference(&buffer, NULL);
+ return handle;
+}
+
+static Bool
+ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
+ int depth, int bitsPerPixel, int devKind,
+ pointer pPixData)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_entity *exa = ms->exa;
+
+ if (!priv)
+ return FALSE;
+
+ if (depth <= 0)
+ depth = pPixmap->drawable.depth;
+
+ if (bitsPerPixel <= 0)
+ bitsPerPixel = pPixmap->drawable.bitsPerPixel;
+
+ if (width <= 0)
+ width = pPixmap->drawable.width;
+
+ if (height <= 0)
+ height = pPixmap->drawable.height;
+
+ if (width <= 0 || height <= 0 || depth <= 0)
+ return FALSE;
+
+ miModifyPixmapHeader(pPixmap, width, height, depth,
+ bitsPerPixel, devKind, NULL);
+
+ /* Deal with screen resize */
+ if (priv->tex && (priv->tex->width[0] != width || priv->tex->height[0] != height)) {
+ pipe_texture_reference(&priv->tex, NULL);
+ }
+
+ if (!priv->tex) {
+ struct pipe_texture template;
+
+ memset(&template, 0, sizeof(template));
+ template.target = PIPE_TEXTURE_2D;
+ template.compressed = 0;
+ exa_get_pipe_format(depth, &template.format, &bitsPerPixel);
+ pf_get_block(template.format, &template.block);
+ template.width[0] = width;
+ template.height[0] = height;
+ template.depth[0] = 1;
+ template.last_level = 0;
+ template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ priv->tex = exa->scrn->texture_create(exa->scrn, &template);
+ }
+
+ return TRUE;
+}
+
+struct pipe_texture *
+xorg_exa_get_texture(PixmapPtr pPixmap)
+{
+ struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct pipe_texture *tex = NULL;
+ pipe_texture_reference(&tex, priv->tex);
+ return tex;
+}
+
+void
+xorg_exa_close(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_entity *exa = ms->exa;
+
+ if (exa->ctx)
+ exa->ctx->destroy(exa->ctx);
+
+ exaDriverFini(pScrn->pScreen);
+ xfree(exa);
+ ms->exa = NULL;
+}
+
+void *
+xorg_exa_init(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_entity *exa;
+ ExaDriverPtr pExa;
+
+ exa = xcalloc(1, sizeof(struct exa_entity));
+ if (!exa)
+ return NULL;
+
+ pExa = exaDriverAlloc();
+ if (!pExa) {
+ goto out_err;
+ }
+
+ memset(pExa, 0, sizeof(*pExa));
+ pExa->exa_major = 2;
+ pExa->exa_minor = 2;
+ pExa->memoryBase = 0;
+ pExa->memorySize = 0;
+ pExa->offScreenBase = 0;
+ pExa->pixmapOffsetAlign = 0;
+ pExa->pixmapPitchAlign = 1;
+ pExa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS;
+ pExa->maxX = 8191; /* FIXME */
+ pExa->maxY = 8191; /* FIXME */
+ pExa->WaitMarker = ExaWaitMarker;
+ pExa->MarkSync = ExaMarkSync;
+ pExa->PrepareSolid = ExaPrepareSolid;
+ pExa->Solid = ExaSolid;
+ pExa->DoneSolid = ExaDone;
+ pExa->PrepareCopy = ExaPrepareCopy;
+ pExa->Copy = ExaCopy;
+ pExa->DoneCopy = ExaDone;
+ pExa->CheckComposite = ExaCheckComposite;
+ pExa->PrepareComposite = ExaPrepareComposite;
+ pExa->Composite = ExaComposite;
+ pExa->DoneComposite = ExaDoneComposite;
+ pExa->PixmapIsOffscreen = ExaPixmapIsOffscreen;
+ pExa->PrepareAccess = ExaPrepareAccess;
+ pExa->FinishAccess = ExaFinishAccess;
+ pExa->CreatePixmap = ExaCreatePixmap;
+ pExa->DestroyPixmap = ExaDestroyPixmap;
+ pExa->ModifyPixmapHeader = ExaModifyPixmapHeader;
+
+ if (!exaDriverInit(pScrn->pScreen, pExa)) {
+ goto out_err;
+ }
+
+ exa->scrn = ms->screen;
+ exa->ctx = drm_api_hooks.create_context(exa->scrn);
+ /* Share context with DRI */
+ ms->ctx = exa->ctx;
+
+ return (void *)exa;
+
+ out_err:
+ xorg_exa_close(pScrn);
+
+ return NULL;
+}
+
+/* vim: set sw=4 ts=8 sts=4: */
diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c
new file mode 100644
index 0000000000..950af942f5
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_output.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "xorg-server.h"
+#include <xf86.h>
+#include <xf86i2c.h>
+#include <xf86Crtc.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+
+#include "X11/Xatom.h"
+
+#include "xorg_tracker.h"
+
+static char *connector_enum_list[] = {
+ "Unknown",
+ "VGA",
+ "DVI-I",
+ "DVI-D",
+ "DVI-A",
+ "Composite",
+ "SVIDEO",
+ "LVDS",
+ "Component",
+ "9-pin DIN",
+ "DisplayPort",
+ "HDMI Type A",
+ "HDMI Type B",
+};
+
+static void
+dpms(xf86OutputPtr output, int mode)
+{
+}
+
+static void
+save(xf86OutputPtr output)
+{
+}
+
+static void
+restore(xf86OutputPtr output)
+{
+}
+
+static int
+mode_valid(xf86OutputPtr output, DisplayModePtr pMode)
+{
+ return MODE_OK;
+}
+
+static Bool
+mode_fixup(xf86OutputPtr output, DisplayModePtr mode,
+ DisplayModePtr adjusted_mode)
+{
+ return TRUE;
+}
+
+static void
+prepare(xf86OutputPtr output)
+{
+ dpms(output, DPMSModeOff);
+}
+
+static void
+mode_set(xf86OutputPtr output, DisplayModePtr mode,
+ DisplayModePtr adjusted_mode)
+{
+}
+
+static void
+commit(xf86OutputPtr output)
+{
+ dpms(output, DPMSModeOn);
+
+ if (output->scrn->pScreen != NULL)
+ xf86_reload_cursors(output->scrn->pScreen);
+}
+
+static xf86OutputStatus
+detect(xf86OutputPtr output)
+{
+ drmModeConnectorPtr drm_connector = output->driver_private;
+
+ switch (drm_connector->connection) {
+ case DRM_MODE_CONNECTED:
+ return XF86OutputStatusConnected;
+ case DRM_MODE_DISCONNECTED:
+ return XF86OutputStatusDisconnected;
+ default:
+ return XF86OutputStatusUnknown;
+ }
+}
+
+static DisplayModePtr
+get_modes(xf86OutputPtr output)
+{
+ drmModeConnectorPtr drm_connector = output->driver_private;
+ drmModeModeInfoPtr drm_mode = NULL;
+ DisplayModePtr modes = NULL, mode = NULL;
+ int i;
+
+ for (i = 0; i < drm_connector->count_modes; i++) {
+ drm_mode = &drm_connector->modes[i];
+ if (drm_mode) {
+ mode = xcalloc(1, sizeof(DisplayModeRec));
+ if (!mode)
+ continue;
+ mode->type = 0;
+ mode->Clock = drm_mode->clock;
+ mode->HDisplay = drm_mode->hdisplay;
+ mode->HSyncStart = drm_mode->hsync_start;
+ mode->HSyncEnd = drm_mode->hsync_end;
+ mode->HTotal = drm_mode->htotal;
+ mode->VDisplay = drm_mode->vdisplay;
+ mode->VSyncStart = drm_mode->vsync_start;
+ mode->VSyncEnd = drm_mode->vsync_end;
+ mode->VTotal = drm_mode->vtotal;
+ mode->Flags = drm_mode->flags;
+ mode->HSkew = drm_mode->hskew;
+ mode->VScan = drm_mode->vscan;
+ mode->VRefresh = xf86ModeVRefresh(mode);
+ mode->Private = (void *)drm_mode;
+ xf86SetModeDefaultName(mode);
+ modes = xf86ModesAdd(modes, mode);
+ xf86PrintModeline(0, mode);
+ }
+ }
+
+ return modes;
+}
+
+static void
+destroy(xf86OutputPtr output)
+{
+ drmModeFreeConnector(output->driver_private);
+}
+
+static void
+create_resources(xf86OutputPtr output)
+{
+#ifdef RANDR_12_INTERFACE
+#endif /* RANDR_12_INTERFACE */
+}
+
+#ifdef RANDR_12_INTERFACE
+static Bool
+set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value)
+{
+ return TRUE;
+}
+#endif /* RANDR_12_INTERFACE */
+
+#ifdef RANDR_13_INTERFACE
+static Bool
+get_property(xf86OutputPtr output, Atom property)
+{
+ return TRUE;
+}
+#endif /* RANDR_13_INTERFACE */
+
+#ifdef RANDR_GET_CRTC_INTERFACE
+static xf86CrtcPtr
+get_crtc(xf86OutputPtr output)
+{
+ return NULL;
+}
+#endif
+
+static const xf86OutputFuncsRec output_funcs = {
+ .create_resources = create_resources,
+ .dpms = dpms,
+ .save = save,
+ .restore = restore,
+ .mode_valid = mode_valid,
+ .mode_fixup = mode_fixup,
+ .prepare = prepare,
+ .mode_set = mode_set,
+ .commit = commit,
+ .detect = detect,
+ .get_modes = get_modes,
+#ifdef RANDR_12_INTERFACE
+ .set_property = set_property,
+#endif
+#ifdef RANDR_13_INTERFACE
+ .get_property = get_property,
+#endif
+ .destroy = destroy,
+#ifdef RANDR_GET_CRTC_INTERFACE
+ .get_crtc = get_crtc,
+#endif
+};
+
+void
+output_init(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ xf86OutputPtr output;
+ drmModeResPtr res;
+ drmModeConnectorPtr drm_connector = NULL;
+ drmModeEncoderPtr drm_encoder = NULL;
+ char *name;
+ int c, v, p;
+
+ res = drmModeGetResources(ms->fd);
+ if (res == 0) {
+ DRV_ERROR("Failed drmModeGetResources\n");
+ return;
+ }
+
+ for (c = 0; c < res->count_connectors; c++) {
+ drm_connector = drmModeGetConnector(ms->fd, res->connectors[c]);
+ if (!drm_connector)
+ goto out;
+
+#if 0
+ for (p = 0; p < drm_connector->count_props; p++) {
+ drmModePropertyPtr prop;
+
+ prop = drmModeGetProperty(ms->fd, drm_connector->props[p]);
+
+ name = NULL;
+ if (prop) {
+ ErrorF("VALUES %d\n", prop->count_values);
+
+ for (v = 0; v < prop->count_values; v++)
+ ErrorF("%s %lld\n", prop->name, prop->values[v]);
+ }
+ }
+#else
+ (void)p;
+ (void)v;
+#endif
+
+ name = connector_enum_list[drm_connector->connector_type];
+
+ output = xf86OutputCreate(pScrn, &output_funcs, name);
+ if (!output)
+ continue;
+
+ drm_encoder = drmModeGetEncoder(ms->fd, drm_connector->encoders[0]);
+ if (drm_encoder) {
+ output->possible_crtcs = drm_encoder->possible_crtcs;
+ output->possible_clones = drm_encoder->possible_clones;
+ } else {
+ output->possible_crtcs = 0;
+ output->possible_clones = 0;
+ }
+ output->driver_private = drm_connector;
+ output->subpixel_order = SubPixelHorizontalRGB;
+ output->interlaceAllowed = FALSE;
+ output->doubleScanAllowed = FALSE;
+ }
+
+ out:
+ drmModeFreeResources(res);
+}
+
+/* vim: set sw=4 ts=8 sts=4: */
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
new file mode 100644
index 0000000000..82c3890dfb
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#ifndef _XORG_TRACKER_H_
+#define _XORG_TRACKER_H_
+
+#include <errno.h>
+#include <drm.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+#include "exa.h"
+
+#include "pipe/p_screen.h"
+#include "state_tracker/drm_api.h"
+
+#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
+
+typedef struct
+{
+ int lastInstance;
+ int refCount;
+ ScrnInfoPtr pScrn_1;
+ ScrnInfoPtr pScrn_2;
+} EntRec, *EntPtr;
+
+typedef struct _modesettingRec
+{
+ /* drm */
+ int fd;
+ unsigned fb_id;
+
+ /* X */
+ EntPtr entityPrivate;
+
+ int Chipset;
+ EntityInfoPtr pEnt;
+ struct pci_device *PciInfo;
+
+ Bool noAccel;
+ Bool SWCursor;
+ CloseScreenProcPtr CloseScreen;
+
+ /* Broken-out options. */
+ OptionInfoPtr Options;
+
+ unsigned int SaveGeneration;
+
+ CreateScreenResourcesProcPtr createScreenResources;
+
+ /* gallium */
+ struct pipe_screen *screen;
+ struct pipe_context *ctx;
+
+ /* exa */
+ void *exa;
+ Bool noEvict;
+
+} modesettingRec, *modesettingPtr;
+
+#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
+
+
+/***********************************************************************
+ * xorg_exa.c
+ */
+struct pipe_texture *
+xorg_exa_get_texture(PixmapPtr pPixmap);
+
+unsigned
+xorg_exa_get_pixmap_handle(PixmapPtr pPixmap);
+
+void *
+xorg_exa_init(ScrnInfoPtr pScrn);
+
+void
+xorg_exa_close(ScrnInfoPtr pScrn);
+
+
+/***********************************************************************
+ * xorg_dri2.c
+ */
+Bool
+driScreenInit(ScreenPtr pScreen);
+
+void
+driCloseScreen(ScreenPtr pScreen);
+
+
+/***********************************************************************
+ * xorg_crtc.c
+ */
+void
+crtc_init(ScrnInfoPtr pScrn);
+
+
+/***********************************************************************
+ * xorg_output.c
+ */
+void
+output_init(ScrnInfoPtr pScrn);
+
+
+#endif /* _XORG_TRACKER_H_ */
diff --git a/src/gallium/state_trackers/wgl/stw.h b/src/gallium/state_trackers/xorg/xorg_winsys.h
index 450af4ccb6..d523080e90 100644
--- a/src/gallium/state_trackers/wgl/stw.h
+++ b/src/gallium/state_trackers/xorg/xorg_winsys.h
@@ -1,5 +1,4 @@
-/**************************************************************************
- *
+/*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
@@ -23,31 +22,30 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
- **************************************************************************/
-
-#ifndef STW_H
-#define STW_H
-
-#include "pipe/p_compiler.h"
-
-struct stw_winsys;
-
-/* Public interface:
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
*/
-boolean stw_init( const struct stw_winsys *stw_winsys );
-void stw_cleanup( void );
+/*
+ * File with all the junk needed to personalize the a xorg driver.
+ */
+#ifndef _XORG_WINSYS_H_
+#define _XORG_WINSYS_H_
-/* Internal functions
- */
-boolean stw_shared_init( const struct stw_winsys *stw_winsys );
-boolean stw_icd_init( void );
-boolean stw_wgl_init( void );
+#include "xorg-server.h"
+#include "xf86.h"
+#include "xf86Resources.h"
+#include "pciaccess.h"
-void stw_shared_cleanup( void );
-void stw_icd_cleanup( void );
-void stw_wgl_cleanup( void );
+#ifndef XSERVER_LIBPCIACCESS
+#error "libpciaccess needed"
+#endif
+void xorg_tracker_set_functions(ScrnInfoPtr scrn);
+const OptionInfoRec * xorg_tracker_available_options(int chipid, int busid);
+void xorg_tracker_loader_ref_sym_lists(void);
-#endif /* STW_H */
+#endif
diff --git a/src/gallium/winsys/Makefile b/src/gallium/winsys/Makefile
index 2360a6a94a..bce5b3f9e0 100644
--- a/src/gallium/winsys/Makefile
+++ b/src/gallium/winsys/Makefile
@@ -1,24 +1,12 @@
+# src/gallium/winsys/Makefile
TOP = ../../..
include $(TOP)/configs/current
-
SUBDIRS = $(GALLIUM_WINSYS_DIRS)
-
-default: subdirs
-
-
-subdirs:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
-
-
-# Dummy install target
-install:
diff --git a/src/gallium/winsys/drm/Makefile b/src/gallium/winsys/drm/Makefile
index a84fcd8418..fee0191643 100644
--- a/src/gallium/winsys/drm/Makefile
+++ b/src/gallium/winsys/drm/Makefile
@@ -1,38 +1,12 @@
-# src/gallium/winsys/drm/Makefile
-
+# src/gallium/winsys/Makefile
TOP = ../../../..
-
include $(TOP)/configs/current
SUBDIRS = $(GALLIUM_WINSYS_DRM_DIRS)
-default: $(TOP)/$(LIB_DIR)/gallium subdirs
-
-
-$(TOP)/$(LIB_DIR)/gallium:
- -mkdir -p $(TOP)/$(LIB_DIR)/gallium
-
-
-subdirs:
- @for dir in $(SUBDIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
- fi \
- done
-
-
-install:
- @for dir in $(SUBDIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) install) || exit 1 ; \
- fi \
- done
-
-
-clean:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) clean) ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
- -rm -f common/*.o
diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template
index cccf8abdfd..9f92cb4207 100644
--- a/src/gallium/winsys/drm/Makefile.template
+++ b/src/gallium/winsys/drm/Makefile.template
@@ -79,25 +79,24 @@ SHARED_INCLUDES = \
##### TARGETS #####
-default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME) $(LIBNAME_EGL) $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME_EGL)
-
+default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
- $(TOP)/bin/mklib -noprefix -o $@ \
+ $(MKLIB) -noprefix -o $@ \
$(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
$(LIBNAME_EGL): $(WINSYS_OBJECTS) $(LIBS)
- $(TOP)/bin/mklib -o $(LIBNAME_EGL) \
+ $(MKLIB) -o $(LIBNAME_EGL) \
-linker "$(CC)" \
-noprefix \
$(OBJECTS) $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) $(PIPE_DRIVERS) $(WINOBJ) $(DRI_LIB_DEPS) \
--whole-archive $(LIBS) $(GALLIUM_AUXILIARIES) --no-whole-archive $(DRIVER_EXTRAS)
-$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(LIBNAME)
- $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
+$(TOP)/$(LIB_DIR)/gallium:
+ mkdir -p $@
-$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME_EGL): $(LIBNAME_EGL)
- $(INSTALL) $(LIBNAME_EGL) $(TOP)/$(LIB_DIR)/gallium
+$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
+ $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
rm -f depend
@@ -118,8 +117,8 @@ clean:
install: $(LIBNAME)
- $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
- $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
+ $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+ $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
include depend
diff --git a/src/gallium/winsys/drm/intel/Makefile b/src/gallium/winsys/drm/intel/Makefile
index eede9fc866..d8feef6824 100644
--- a/src/gallium/winsys/drm/intel/Makefile
+++ b/src/gallium/winsys/drm/intel/Makefile
@@ -1,25 +1,12 @@
+# src/gallium/winsys/drm/intel/Makefile
TOP = ../../../../..
include $(TOP)/configs/current
+SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS)
-SUBDIRS = gem egl
-
-
-default: subdirs
-
-
-subdirs:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
- rm -f `find . -name depend`
-
-
-# Dummy install target
-install:
diff --git a/src/gallium/winsys/drm/intel/common/Makefile b/src/gallium/winsys/drm/intel/common/Makefile
deleted file mode 100644
index bf1a7d691f..0000000000
--- a/src/gallium/winsys/drm/intel/common/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = inteldrm
-
-C_SOURCES = \
- intel_be_batchbuffer.c \
- intel_be_context.c \
- intel_be_device.c \
- ws_dri_bufmgr.c \
- ws_dri_drmpool.c \
- ws_dri_fencemgr.c \
- ws_dri_mallocpool.c \
- ws_dri_slabpool.c
-
-
-include ./Makefile.template
-
-DRIVER_DEFINES = $(shell pkg-config libdrm --cflags \
- && pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-symlinks:
-
diff --git a/src/gallium/winsys/drm/intel/common/Makefile.template b/src/gallium/winsys/drm/intel/common/Makefile.template
deleted file mode 100644
index 02ed363a43..0000000000
--- a/src/gallium/winsys/drm/intel/common/Makefile.template
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*-makefile-*-
-
-
-# We still have a dependency on the "dri" buffer manager. Most likely
-# the interface can be reused in non-dri environments, and also as a
-# frontend to simpler memory managers.
-#
-COMMON_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/include \
- $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks $(LIBNAME)
-
-
-$(LIBNAME): $(OBJECTS) Makefile Makefile.template
- $(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean::
- -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
-
-
-include depend
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c b/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c
deleted file mode 100644
index bc13a5761e..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c
+++ /dev/null
@@ -1,429 +0,0 @@
-
-#include "intel_be_batchbuffer.h"
-#include "intel_be_context.h"
-#include "intel_be_device.h"
-#include <errno.h>
-
-#include "xf86drm.h"
-
-static void
-intel_realloc_relocs(struct intel_be_batchbuffer *batch, int num_relocs)
-{
- unsigned long size = num_relocs * I915_RELOC0_STRIDE + I915_RELOC_HEADER;
-
- size *= sizeof(uint32_t);
- batch->reloc = realloc(batch->reloc, size);
- batch->reloc_size = num_relocs;
-}
-
-
-void
-intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch)
-{
- /*
- * Get a new, free batchbuffer.
- */
- drmBO *bo;
- struct drm_bo_info_req *req;
-
- driBOUnrefUserList(batch->list);
- driBOResetList(batch->list);
-
- /* base.size is the size available to the i915simple driver */
- batch->base.size = batch->device->max_batch_size - BATCH_RESERVED;
- batch->base.actual_size = batch->device->max_batch_size;
- driBOData(batch->buffer, batch->base.actual_size, NULL, NULL, 0);
-
- /*
- * Add the batchbuffer to the validate list.
- */
-
- driBOAddListItem(batch->list, batch->buffer,
- DRM_BO_FLAG_EXE | DRM_BO_FLAG_MEM_TT,
- DRM_BO_FLAG_EXE | DRM_BO_MASK_MEM,
- &batch->dest_location, &batch->node);
-
- req = &batch->node->bo_arg.d.req.bo_req;
-
- /*
- * Set up information needed for us to make relocations
- * relative to the underlying drm buffer objects.
- */
-
- driReadLockKernelBO();
- bo = driBOKernel(batch->buffer);
- req->presumed_offset = (uint64_t) bo->offset;
- req->hint = DRM_BO_HINT_PRESUMED_OFFSET;
- batch->drmBOVirtual = (uint8_t *) bo->virtual;
- driReadUnlockKernelBO();
-
- /*
- * Adjust the relocation buffer size.
- */
-
- if (batch->reloc_size > INTEL_MAX_RELOCS ||
- batch->reloc == NULL)
- intel_realloc_relocs(batch, INTEL_DEFAULT_RELOCS);
-
- assert(batch->reloc != NULL);
- batch->reloc[0] = 0; /* No relocs yet. */
- batch->reloc[1] = 1; /* Reloc type 1 */
- batch->reloc[2] = 0; /* Only a single relocation list. */
- batch->reloc[3] = 0; /* Only a single relocation list. */
-
- batch->base.map = driBOMap(batch->buffer, DRM_BO_FLAG_WRITE, 0);
- batch->poolOffset = driBOPoolOffset(batch->buffer);
- batch->base.ptr = batch->base.map;
- batch->dirty_state = ~0;
- batch->nr_relocs = 0;
- batch->flags = 0;
- batch->id = 0;//batch->intel->intelScreen->batch_id++;
-}
-
-/*======================================================================
- * Public functions
- */
-struct intel_be_batchbuffer *
-intel_be_batchbuffer_alloc(struct intel_be_context *intel)
-{
- struct intel_be_batchbuffer *batch = calloc(sizeof(*batch), 1);
-
- batch->intel = intel;
- batch->device = intel->device;
-
- driGenBuffers(intel->device->batchPool, "batchbuffer", 1,
- &batch->buffer, 4096,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, 0);
- batch->last_fence = NULL;
- batch->list = driBOCreateList(20);
- batch->reloc = NULL;
- intel_be_batchbuffer_reset(batch);
- return batch;
-}
-
-void
-intel_be_batchbuffer_free(struct intel_be_batchbuffer *batch)
-{
- if (batch->last_fence) {
- driFenceFinish(batch->last_fence,
- DRM_FENCE_TYPE_EXE, FALSE);
- driFenceUnReference(&batch->last_fence);
- }
- if (batch->base.map) {
- driBOUnmap(batch->buffer);
- batch->base.map = NULL;
- }
- driBOUnReference(batch->buffer);
- driBOFreeList(batch->list);
- if (batch->reloc)
- free(batch->reloc);
- batch->buffer = NULL;
- free(batch);
-}
-
-void
-intel_be_offset_relocation(struct intel_be_batchbuffer *batch,
- unsigned pre_add,
- struct _DriBufferObject *driBO,
- uint64_t val_flags,
- uint64_t val_mask)
-{
- int itemLoc;
- struct _drmBONode *node;
- uint32_t *reloc;
- struct drm_bo_info_req *req;
-
- driBOAddListItem(batch->list, driBO, val_flags, val_mask,
- &itemLoc, &node);
- req = &node->bo_arg.d.req.bo_req;
-
- if (!(req->hint & DRM_BO_HINT_PRESUMED_OFFSET)) {
-
- /*
- * Stop other threads from tampering with the underlying
- * drmBO while we're reading its offset.
- */
-
- driReadLockKernelBO();
- req->presumed_offset = (uint64_t) driBOKernel(driBO)->offset;
- driReadUnlockKernelBO();
- req->hint = DRM_BO_HINT_PRESUMED_OFFSET;
- }
-
- pre_add += driBOPoolOffset(driBO);
-
- if (batch->nr_relocs == batch->reloc_size)
- intel_realloc_relocs(batch, batch->reloc_size * 2);
-
- reloc = batch->reloc +
- (I915_RELOC_HEADER + batch->nr_relocs * I915_RELOC0_STRIDE);
-
- reloc[0] = ((uint8_t *)batch->base.ptr - batch->drmBOVirtual);
- i915_batchbuffer_dword(&batch->base, req->presumed_offset + pre_add);
- reloc[1] = pre_add;
- reloc[2] = itemLoc;
- reloc[3] = batch->dest_location;
- batch->nr_relocs++;
-}
-
-static void
-i915_drm_copy_reply(const struct drm_bo_info_rep * rep, drmBO * buf)
-{
- buf->handle = rep->handle;
- buf->flags = rep->flags;
- buf->size = rep->size;
- buf->offset = rep->offset;
- buf->mapHandle = rep->arg_handle;
- buf->proposedFlags = rep->proposed_flags;
- buf->start = rep->buffer_start;
- buf->fenceFlags = rep->fence_flags;
- buf->replyFlags = rep->rep_flags;
- buf->pageAlignment = rep->page_alignment;
-}
-
-static int
-i915_execbuf(struct intel_be_batchbuffer *batch,
- unsigned int used,
- boolean ignore_cliprects,
- drmBOList *list,
- struct drm_i915_execbuffer *ea)
-{
-// struct intel_be_context *intel = batch->intel;
- drmBONode *node;
- drmMMListHead *l;
- struct drm_i915_op_arg *arg, *first;
- struct drm_bo_op_req *req;
- struct drm_bo_info_rep *rep;
- uint64_t *prevNext = NULL;
- drmBO *buf;
- int ret = 0;
- uint32_t count = 0;
-
- first = NULL;
- for (l = list->list.next; l != &list->list; l = l->next) {
- node = DRMLISTENTRY(drmBONode, l, head);
-
- arg = &node->bo_arg;
- req = &arg->d.req;
-
- if (!first)
- first = arg;
-
- if (prevNext)
- *prevNext = (unsigned long)arg;
-
- prevNext = &arg->next;
- req->bo_req.handle = node->buf->handle;
- req->op = drm_bo_validate;
- req->bo_req.flags = node->arg0;
- req->bo_req.mask = node->arg1;
- req->bo_req.hint |= 0;
- count++;
- }
-
- memset(ea, 0, sizeof(*ea));
- ea->num_buffers = count;
- ea->batch.start = batch->poolOffset;
- ea->batch.used = used;
-#if 0 /* ZZZ JB: no cliprects used */
- ea->batch.cliprects = intel->pClipRects;
- ea->batch.num_cliprects = ignore_cliprects ? 0 : intel->numClipRects;
- ea->batch.DR1 = 0;
- ea->batch.DR4 = 0;((((GLuint) intel->drawX) & 0xffff) |
- (((GLuint) intel->drawY) << 16));
-#else
- ea->batch.cliprects = NULL;
- ea->batch.num_cliprects = 0;
- ea->batch.DR1 = 0;
- ea->batch.DR4 = 0;
-#endif
- ea->fence_arg.flags = DRM_I915_FENCE_FLAG_FLUSHED;
- ea->ops_list = (unsigned long) first;
- first->reloc_ptr = (unsigned long) batch->reloc;
- batch->reloc[0] = batch->nr_relocs;
-
- //return -EFAULT;
- do {
- ret = drmCommandWriteRead(batch->device->fd, DRM_I915_EXECBUFFER, ea,
- sizeof(*ea));
- } while (ret == -EAGAIN);
-
- if (ret != 0)
- return ret;
-
- for (l = list->list.next; l != &list->list; l = l->next) {
- node = DRMLISTENTRY(drmBONode, l, head);
- arg = &node->bo_arg;
- rep = &arg->d.rep.bo_info;
-
- if (!arg->handled) {
- return -EFAULT;
- }
- if (arg->d.rep.ret)
- return arg->d.rep.ret;
-
- buf = node->buf;
- i915_drm_copy_reply(rep, buf);
- }
- return 0;
-}
-
-/* TODO: Push this whole function into bufmgr.
- */
-static struct _DriFenceObject *
-do_flush_locked(struct intel_be_batchbuffer *batch,
- unsigned int used,
- boolean ignore_cliprects, boolean allow_unlock)
-{
- struct intel_be_context *intel = batch->intel;
- struct _DriFenceObject *fo;
- drmFence fence;
- drmBOList *boList;
- struct drm_i915_execbuffer ea;
- int ret = 0;
-
- driBOValidateUserList(batch->list);
- boList = driGetdrmBOList(batch->list);
-
-#if 0 /* ZZZ JB Allways run */
- if (!(intel->numClipRects == 0 && !ignore_cliprects)) {
-#else
- if (1) {
-#endif
- ret = i915_execbuf(batch, used, ignore_cliprects, boList, &ea);
- } else {
- driPutdrmBOList(batch->list);
- fo = NULL;
- goto out;
- }
- driPutdrmBOList(batch->list);
- if (ret)
- abort();
-
- if (ea.fence_arg.error != 0) {
-
- /*
- * The hardware has been idled by the kernel.
- * Don't fence the driBOs.
- */
-
- if (batch->last_fence)
- driFenceUnReference(&batch->last_fence);
-#if 0 /* ZZZ JB: no _mesa_* funcs in gallium */
- _mesa_printf("fence error\n");
-#endif
- batch->last_fence = NULL;
- fo = NULL;
- goto out;
- }
-
- fence.handle = ea.fence_arg.handle;
- fence.fence_class = ea.fence_arg.fence_class;
- fence.type = ea.fence_arg.type;
- fence.flags = ea.fence_arg.flags;
- fence.signaled = ea.fence_arg.signaled;
-
- fo = driBOFenceUserList(batch->device->fenceMgr, batch->list,
- "SuperFence", &fence);
-
- if (driFenceType(fo) & DRM_I915_FENCE_TYPE_RW) {
- if (batch->last_fence)
- driFenceUnReference(&batch->last_fence);
- /*
- * FIXME: Context last fence??
- */
- batch->last_fence = fo;
- driFenceReference(fo);
- }
- out:
-#if 0 /* ZZZ JB: fix this */
- intel->vtbl.lost_hardware(intel);
-#else
- (void)intel;
-#endif
- return fo;
-}
-
-
-struct _DriFenceObject *
-intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch)
-{
- struct intel_be_context *intel = batch->intel;
- unsigned int used = batch->base.ptr - batch->base.map;
- boolean was_locked = batch->intel->hardware_locked(intel);
- struct _DriFenceObject *fence;
-
- if (used == 0) {
- driFenceReference(batch->last_fence);
- return batch->last_fence;
- }
-
- /* Add the MI_BATCH_BUFFER_END. Always add an MI_FLUSH - this is a
- * performance drain that we would like to avoid.
- */
-#if 0 /* ZZZ JB: what should we do here? */
- if (used & 4) {
- ((int *) batch->base.ptr)[0] = intel->vtbl.flush_cmd();
- ((int *) batch->base.ptr)[1] = 0;
- ((int *) batch->base.ptr)[2] = MI_BATCH_BUFFER_END;
- used += 12;
- }
- else {
- ((int *) batch->base.ptr)[0] = intel->vtbl.flush_cmd();
- ((int *) batch->base.ptr)[1] = MI_BATCH_BUFFER_END;
- used += 8;
- }
-#else
- if (used & 4) {
- ((int *) batch->base.ptr)[0] = ((0<<29)|(4<<23)); // MI_FLUSH;
- ((int *) batch->base.ptr)[1] = 0;
- ((int *) batch->base.ptr)[2] = (0xA<<23); // MI_BATCH_BUFFER_END;
- used += 12;
- }
- else {
- ((int *) batch->base.ptr)[0] = ((0<<29)|(4<<23)); // MI_FLUSH;
- ((int *) batch->base.ptr)[1] = (0xA<<23); // MI_BATCH_BUFFER_END;
- used += 8;
- }
-#endif
- driBOUnmap(batch->buffer);
- batch->base.ptr = NULL;
- batch->base.map = NULL;
-
- /* TODO: Just pass the relocation list and dma buffer up to the
- * kernel.
- */
- if (!was_locked)
- intel->hardware_lock(intel);
-
- fence = do_flush_locked(batch, used, !(batch->flags & INTEL_BATCH_CLIPRECTS),
- FALSE);
-
- if (!was_locked)
- intel->hardware_unlock(intel);
-
- /* Reset the buffer:
- */
- intel_be_batchbuffer_reset(batch);
- return fence;
-}
-
-void
-intel_be_batchbuffer_finish(struct intel_be_batchbuffer *batch)
-{
- struct _DriFenceObject *fence = intel_be_batchbuffer_flush(batch);
- driFenceFinish(fence, driFenceType(fence), FALSE);
- driFenceUnReference(&fence);
-}
-
-#if 0
-void
-intel_be_batchbuffer_data(struct intel_be_batchbuffer *batch,
- const void *data, unsigned int bytes, unsigned int flags)
-{
- assert((bytes & 3) == 0);
- intel_batchbuffer_require_space(batch, bytes, flags);
- memcpy(batch->base.ptr, data, bytes);
- batch->base.ptr += bytes;
-}
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h b/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h
deleted file mode 100644
index f150e3a674..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h
+++ /dev/null
@@ -1,69 +0,0 @@
-
-#ifndef INTEL_BE_BATCHBUFFER_H
-#define INTEL_BE_BATCHBUFFER_H
-
-#include "i915simple/i915_batch.h"
-
-#include "ws_dri_bufmgr.h"
-
-#define BATCH_RESERVED 16
-
-#define INTEL_DEFAULT_RELOCS 100
-#define INTEL_MAX_RELOCS 400
-
-#define INTEL_BATCH_NO_CLIPRECTS 0x1
-#define INTEL_BATCH_CLIPRECTS 0x2
-
-struct intel_be_context;
-struct intel_be_device;
-
-struct intel_be_batchbuffer
-{
- struct i915_batchbuffer base;
-
- struct intel_be_context *intel;
- struct intel_be_device *device;
-
- struct _DriBufferObject *buffer;
- struct _DriFenceObject *last_fence;
- uint32_t flags;
-
- struct _DriBufferList *list;
- size_t list_count;
-
- uint32_t *reloc;
- size_t reloc_size;
- size_t nr_relocs;
-
- uint32_t dirty_state;
- uint32_t id;
-
- uint32_t poolOffset;
- uint8_t *drmBOVirtual;
- struct _drmBONode *node; /* Validation list node for this buffer */
- int dest_location; /* Validation list sequence for this buffer */
-};
-
-struct intel_be_batchbuffer *
-intel_be_batchbuffer_alloc(struct intel_be_context *intel);
-
-void
-intel_be_batchbuffer_free(struct intel_be_batchbuffer *batch);
-
-void
-intel_be_batchbuffer_finish(struct intel_be_batchbuffer *batch);
-
-struct _DriFenceObject *
-intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch);
-
-void
-intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch);
-
-void
-intel_be_offset_relocation(struct intel_be_batchbuffer *batch,
- unsigned pre_add,
- struct _DriBufferObject *driBO,
- uint64_t val_flags,
- uint64_t val_mask);
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_context.c b/src/gallium/winsys/drm/intel/common/intel_be_context.c
deleted file mode 100644
index 1af39674f4..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_context.c
+++ /dev/null
@@ -1,107 +0,0 @@
-
-/*
- * Authors: Jakob Bornecrantz <jakob-at-tungstengraphics.com>
- */
-
-#include "ws_dri_fencemgr.h"
-#include "intel_be_device.h"
-#include "intel_be_context.h"
-#include "intel_be_batchbuffer.h"
-
-static INLINE struct intel_be_context *
-intel_be_context(struct i915_winsys *sws)
-{
- return (struct intel_be_context *)sws;
-}
-
-/* Simple batchbuffer interface:
- */
-
-static struct i915_batchbuffer*
-intel_i915_batch_get(struct i915_winsys *sws)
-{
- struct intel_be_context *intel = intel_be_context(sws);
- return &intel->batch->base;
-}
-
-static void intel_i915_batch_reloc(struct i915_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags,
- unsigned delta)
-{
- struct intel_be_context *intel = intel_be_context(sws);
-
- unsigned flags = DRM_BO_FLAG_MEM_TT;
- unsigned mask = DRM_BO_MASK_MEM;
-
- if (access_flags & I915_BUFFER_ACCESS_WRITE) {
- flags |= DRM_BO_FLAG_WRITE;
- mask |= DRM_BO_FLAG_WRITE;
- }
-
- if (access_flags & I915_BUFFER_ACCESS_READ) {
- flags |= DRM_BO_FLAG_READ;
- mask |= DRM_BO_FLAG_READ;
- }
-
- intel_be_offset_relocation(intel->batch,
- delta,
- dri_bo(buf),
- flags,
- mask);
-}
-
-static void intel_i915_batch_flush(struct i915_winsys *sws,
- struct pipe_fence_handle **fence)
-{
- struct intel_be_context *intel = intel_be_context(sws);
-
- union {
- struct _DriFenceObject *dri;
- struct pipe_fence_handle *pipe;
- } fu;
-
- if (fence)
- assert(!*fence);
-
- fu.dri = intel_be_batchbuffer_flush(intel->batch);
-
- if (!fu.dri) {
- assert(0);
- *fence = NULL;
- return;
- }
-
- if (fu.dri) {
- if (fence)
- *fence = fu.pipe;
- else
- driFenceUnReference(&fu.dri);
- }
-
-}
-
-boolean
-intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *device)
-{
- assert(intel);
- assert(device);
-
- intel->device = device;
-
- /* TODO move framebuffer createion to the driver */
-
- intel->base.batch_get = intel_i915_batch_get;
- intel->base.batch_reloc = intel_i915_batch_reloc;
- intel->base.batch_flush = intel_i915_batch_flush;
-
- intel->batch = intel_be_batchbuffer_alloc(intel);
-
- return true;
-}
-
-void
-intel_be_destroy_context(struct intel_be_context *intel)
-{
- intel_be_batchbuffer_free(intel->batch);
-}
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_context.h b/src/gallium/winsys/drm/intel/common/intel_be_context.h
deleted file mode 100644
index d5cbc93594..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_context.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* These need to be diffrent from the intel winsys */
-#ifndef INTEL_BE_CONTEXT_H
-#define INTEL_BE_CONTEXT_H
-
-#include "i915simple/i915_winsys.h"
-
-struct intel_be_context
-{
- /** Interface to i915simple driver */
- struct i915_winsys base;
-
- struct intel_be_device *device;
- struct intel_be_batchbuffer *batch;
-
- /*
- * Hardware lock functions.
- *
- * Needs to be filled in by the winsys.
- */
- void (*hardware_lock)(struct intel_be_context *context);
- void (*hardware_unlock)(struct intel_be_context *context);
- boolean (*hardware_locked)(struct intel_be_context *context);
-};
-
-/**
- * Intialize a allocated intel_be_context struct.
- *
- * Remember to set the hardware_* functions.
- */
-boolean
-intel_be_init_context(struct intel_be_context *intel,
- struct intel_be_device *device);
-
-/**
- * Destroy a intel_be_context.
- * Does not free the struct that is up to the winsys.
- */
-void
-intel_be_destroy_context(struct intel_be_context *intel);
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_device.c b/src/gallium/winsys/drm/intel/common/intel_be_device.c
deleted file mode 100644
index 85ab1a2684..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_device.c
+++ /dev/null
@@ -1,296 +0,0 @@
-
-
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- * Jakob Bornecrantz <jakob-at-tungstengraphics-dot-com>
- */
-
-#include "intel_be_device.h"
-#include "ws_dri_bufmgr.h"
-#include "ws_dri_bufpool.h"
-#include "ws_dri_fencemgr.h"
-
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
-#include "util/u_memory.h"
-
-#include "i915simple/i915_screen.h"
-
-/* Turn a pipe winsys into an intel/pipe winsys:
- */
-static INLINE struct intel_be_device *
-intel_be_device( struct pipe_winsys *winsys )
-{
- return (struct intel_be_device *)winsys;
-}
-
-
-/*
- * Buffer functions.
- *
- * Most callbacks map direcly onto dri_bufmgr operations:
- */
-
-static void *intel_be_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags )
-{
- unsigned drm_flags = 0;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
- drm_flags |= DRM_BO_FLAG_WRITE;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_READ)
- drm_flags |= DRM_BO_FLAG_READ;
-
- return driBOMap( dri_bo(buf), drm_flags, 0 );
-}
-
-static void intel_be_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- driBOUnmap( dri_bo(buf) );
-}
-
-static void
-intel_be_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- driBOUnReference( dri_bo(buf) );
- FREE(buf);
-}
-
-static struct pipe_buffer *
-intel_be_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size )
-{
- struct intel_be_buffer *buffer = CALLOC_STRUCT( intel_be_buffer );
- struct intel_be_device *iws = intel_be_device(winsys);
- unsigned flags = 0;
- struct _DriBufferPool *pool;
-
- buffer->base.refcount = 1;
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) {
- flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
- pool = iws->mallocPool;
- } else if (usage & PIPE_BUFFER_USAGE_CUSTOM) {
- /* For vertex buffers */
- flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
- pool = iws->vertexPool;
- } else {
- flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
- pool = iws->regionPool;
- }
-
- if (usage & PIPE_BUFFER_USAGE_GPU_READ)
- flags |= DRM_BO_FLAG_READ;
-
- if (usage & PIPE_BUFFER_USAGE_GPU_WRITE)
- flags |= DRM_BO_FLAG_WRITE;
-
- /* drm complains if we don't set any read/write flags.
- */
- if ((flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) == 0)
- flags |= DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
-
- buffer->pool = pool;
- driGenBuffers( buffer->pool,
- "pipe buffer", 1, &buffer->driBO, alignment, flags, 0 );
-
- driBOData( buffer->driBO, size, NULL, buffer->pool, 0 );
-
- return &buffer->base;
-}
-
-
-static struct pipe_buffer *
-intel_be_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
-{
- struct intel_be_buffer *buffer = CALLOC_STRUCT( intel_be_buffer );
- struct intel_be_device *iws = intel_be_device(winsys);
-
- driGenUserBuffer( iws->regionPool,
- "pipe user buffer", &buffer->driBO, ptr, bytes );
-
- buffer->base.refcount = 1;
-
- return &buffer->base;
-}
-
-struct pipe_buffer *
-intel_be_buffer_from_handle(struct intel_be_device *device,
- const char* name, unsigned handle)
-{
- struct intel_be_buffer *be_buf = malloc(sizeof(*be_buf));
- struct pipe_buffer *buffer;
-
- if (!be_buf)
- goto err;
-
- memset(be_buf, 0, sizeof(*be_buf));
-
- driGenBuffers(device->staticPool, name, 1, &be_buf->driBO, 0, 0, 0);
- driBOSetReferenced(be_buf->driBO, handle);
-
- if (0) /** XXX TODO check error */
- goto err_bo;
-
- buffer = &be_buf->base;
- buffer->refcount = 1;
- buffer->alignment = 0;
- buffer->usage = 0;
- buffer->size = driBOSize(be_buf->driBO);
-
- return buffer;
-err_bo:
- free(be_buf);
-err:
- return NULL;
-}
-
-
-static struct pipe_buffer *
-intel_i915_surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned *stride)
-{
- const unsigned alignment = 64;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy;
-
- pf_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = round_up(nblocksx * block.size, alignment);
-
- return winsys->buffer_create(winsys, alignment,
- usage,
- *stride * nblocksy);
-}
-
-
-/*
- * Fence functions
- */
-
-static void
-intel_be_fence_reference( struct pipe_winsys *sws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence )
-{
- if (*ptr)
- driFenceUnReference((struct _DriFenceObject **)ptr);
-
- if (fence)
- *ptr = (struct pipe_fence_handle *)driFenceReference((struct _DriFenceObject *)fence);
-}
-
-static int
-intel_be_fence_signalled( struct pipe_winsys *sws,
- struct pipe_fence_handle *fence,
- unsigned flag )
-{
- return driFenceSignaled((struct _DriFenceObject *)fence, flag);
-}
-
-static int
-intel_be_fence_finish( struct pipe_winsys *sws,
- struct pipe_fence_handle *fence,
- unsigned flag )
-{
- return driFenceFinish((struct _DriFenceObject *)fence, flag, 0);
-}
-
-
-/*
- * Misc functions
- */
-
-boolean
-intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
-{
- dev->fd = fd;
- dev->max_batch_size = 16 * 4096;
- dev->max_vertex_size = 128 * 4096;
-
- dev->base.buffer_create = intel_be_buffer_create;
- dev->base.user_buffer_create = intel_be_user_buffer_create;
- dev->base.buffer_map = intel_be_buffer_map;
- dev->base.buffer_unmap = intel_be_buffer_unmap;
- dev->base.buffer_destroy = intel_be_buffer_destroy;
- dev->base.surface_buffer_create = intel_i915_surface_buffer_create;
- dev->base.fence_reference = intel_be_fence_reference;
- dev->base.fence_signalled = intel_be_fence_signalled;
- dev->base.fence_finish = intel_be_fence_finish;
-
-#if 0 /* Set by the winsys */
- dev->base.flush_frontbuffer = intel_flush_frontbuffer;
- dev->base.get_name = intel_get_name;
-#endif
-
- dev->fMan = driInitFreeSlabManager(10, 10);
- dev->fenceMgr = driFenceMgrTTMInit(dev->fd);
-
- dev->mallocPool = driMallocPoolInit();
- dev->staticPool = driDRMPoolInit(dev->fd);
- /* Sizes: 64 128 256 512 1024 2048 4096 8192 16384 32768 */
- dev->regionPool = driSlabPoolInit(dev->fd,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT,
- 64,
- 10, 120, 4096 * 64, 0,
- dev->fMan);
-
- dev->vertexPool = driSlabPoolInit(dev->fd,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT,
- dev->max_vertex_size,
- 1, 120, dev->max_vertex_size * 4, 0,
- dev->fMan);
-
- dev->batchPool = driSlabPoolInit(dev->fd,
- DRM_BO_FLAG_EXE |
- DRM_BO_FLAG_MEM_TT,
- DRM_BO_FLAG_EXE |
- DRM_BO_FLAG_MEM_TT,
- dev->max_batch_size,
- 1, 40, dev->max_batch_size * 16, 0,
- dev->fMan);
-
- /* Fill in this struct with callbacks that i915simple will need to
- * communicate with the window system, buffer manager, etc.
- */
- dev->screen = i915_create_screen(&dev->base, id);
-
- return true;
-}
-
-void
-intel_be_destroy_device(struct intel_be_device *dev)
-{
- driPoolTakeDown(dev->mallocPool);
- driPoolTakeDown(dev->staticPool);
- driPoolTakeDown(dev->regionPool);
- driPoolTakeDown(dev->vertexPool);
- driPoolTakeDown(dev->batchPool);
-
- /** TODO takedown fenceMgr and fMan */
-}
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_device.h b/src/gallium/winsys/drm/intel/common/intel_be_device.h
deleted file mode 100644
index 534d638b6a..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_device.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef INTEL_DRM_DEVICE_H
-#define INTEL_DRM_DEVICE_H
-
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_context.h"
-
-/*
- * Device
- */
-
-struct intel_be_device
-{
- struct pipe_winsys base;
-
- /**
- * Hw level screen
- */
- struct pipe_screen *screen;
-
- int fd; /**< Drm file discriptor */
-
- size_t max_batch_size;
- size_t max_vertex_size;
-
- struct _DriFenceMgr *fenceMgr;
-
- struct _DriBufferPool *batchPool;
- struct _DriBufferPool *regionPool;
- struct _DriBufferPool *mallocPool;
- struct _DriBufferPool *vertexPool;
- struct _DriBufferPool *staticPool;
- struct _DriFreeSlabManager *fMan;
-};
-
-boolean
-intel_be_init_device(struct intel_be_device *device, int fd, unsigned id);
-
-void
-intel_be_destroy_device(struct intel_be_device *dev);
-
-/*
- * Buffer
- */
-
-struct intel_be_buffer {
- struct pipe_buffer base;
- struct _DriBufferPool *pool;
- struct _DriBufferObject *driBO;
-};
-
-/**
- * Create a be buffer from a drm bo handle
- *
- * Takes a reference
- */
-struct pipe_buffer *
-intel_be_buffer_from_handle(struct intel_be_device *device,
- const char* name, unsigned handle);
-
-static INLINE struct intel_be_buffer *
-intel_be_buffer(struct pipe_buffer *buf)
-{
- return (struct intel_be_buffer *)buf;
-}
-
-static INLINE struct _DriBufferObject *
-dri_bo(struct pipe_buffer *buf)
-{
- return intel_be_buffer(buf)->driBO;
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
deleted file mode 100644
index 517a97b3ee..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
+++ /dev/null
@@ -1,949 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- * Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include <xf86drm.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "pipe/p_thread.h"
-#include "errno.h"
-#include "ws_dri_bufmgr.h"
-#include "string.h"
-#include "pipe/p_debug.h"
-#include "ws_dri_bufpool.h"
-#include "ws_dri_fencemgr.h"
-
-
-/*
- * This lock is here to protect drmBO structs changing underneath us during a
- * validate list call, since validatelist cannot take individiual locks for
- * each drmBO. Validatelist takes this lock in write mode. Any access to an
- * individual drmBO should take this lock in read mode, since in that case, the
- * driBufferObject mutex will protect the access. Locking order is
- * driBufferObject mutex - > this rw lock.
- */
-
-pipe_static_mutex(bmMutex);
-pipe_static_condvar(bmCond);
-
-static int kernelReaders = 0;
-static int num_buffers = 0;
-static int num_user_buffers = 0;
-
-static drmBO *drmBOListBuf(void *iterator)
-{
- drmBONode *node;
- drmMMListHead *l = (drmMMListHead *) iterator;
- node = DRMLISTENTRY(drmBONode, l, head);
- return node->buf;
-}
-
-static void *drmBOListIterator(drmBOList *list)
-{
- void *ret = list->list.next;
-
- if (ret == &list->list)
- return NULL;
- return ret;
-}
-
-static void *drmBOListNext(drmBOList *list, void *iterator)
-{
- void *ret;
-
- drmMMListHead *l = (drmMMListHead *) iterator;
- ret = l->next;
- if (ret == &list->list)
- return NULL;
- return ret;
-}
-
-static drmBONode *drmAddListItem(drmBOList *list, drmBO *item,
- uint64_t arg0,
- uint64_t arg1)
-{
- drmBONode *node;
- drmMMListHead *l;
-
- l = list->free.next;
- if (l == &list->free) {
- node = (drmBONode *) malloc(sizeof(*node));
- if (!node) {
- return NULL;
- }
- list->numCurrent++;
- }
- else {
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- }
- node->buf = item;
- node->arg0 = arg0;
- node->arg1 = arg1;
- DRMLISTADD(&node->head, &list->list);
- list->numOnList++;
- return node;
-}
-
-static int drmAddValidateItem(drmBOList *list, drmBO *buf, uint64_t flags,
- uint64_t mask, int *newItem)
-{
- drmBONode *node, *cur;
- drmMMListHead *l;
-
- *newItem = 0;
- cur = NULL;
-
- for (l = list->list.next; l != &list->list; l = l->next) {
- node = DRMLISTENTRY(drmBONode, l, head);
- if (node->buf == buf) {
- cur = node;
- break;
- }
- }
- if (!cur) {
- cur = drmAddListItem(list, buf, flags, mask);
- if (!cur) {
- return -ENOMEM;
- }
- *newItem = 1;
- cur->arg0 = flags;
- cur->arg1 = mask;
- }
- else {
- uint64_t memFlags = cur->arg0 & flags & DRM_BO_MASK_MEM;
- uint64_t accFlags = (cur->arg0 | flags) & ~DRM_BO_MASK_MEM;
-
- if (mask & cur->arg1 & ~DRM_BO_MASK_MEM & (cur->arg0 ^ flags)) {
- return -EINVAL;
- }
-
- cur->arg1 |= mask;
- cur->arg0 = (cur->arg0 & ~mask) | ((memFlags | accFlags) & mask);
-
- if (((cur->arg1 & DRM_BO_MASK_MEM) != 0) &&
- (cur->arg0 & DRM_BO_MASK_MEM) == 0) {
- return -EINVAL;
- }
- }
- return 0;
-}
-
-static void drmBOFreeList(drmBOList *list)
-{
- drmBONode *node;
- drmMMListHead *l;
-
- l = list->list.next;
- while(l != &list->list) {
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- free(node);
- l = list->list.next;
- list->numCurrent--;
- list->numOnList--;
- }
-
- l = list->free.next;
- while(l != &list->free) {
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- free(node);
- l = list->free.next;
- list->numCurrent--;
- }
-}
-
-static int drmAdjustListNodes(drmBOList *list)
-{
- drmBONode *node;
- drmMMListHead *l;
- int ret = 0;
-
- while(list->numCurrent < list->numTarget) {
- node = (drmBONode *) malloc(sizeof(*node));
- if (!node) {
- ret = -ENOMEM;
- break;
- }
- list->numCurrent++;
- DRMLISTADD(&node->head, &list->free);
- }
-
- while(list->numCurrent > list->numTarget) {
- l = list->free.next;
- if (l == &list->free)
- break;
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- free(node);
- list->numCurrent--;
- }
- return ret;
-}
-
-static int drmBOCreateList(int numTarget, drmBOList *list)
-{
- DRMINITLISTHEAD(&list->list);
- DRMINITLISTHEAD(&list->free);
- list->numTarget = numTarget;
- list->numCurrent = 0;
- list->numOnList = 0;
- return drmAdjustListNodes(list);
-}
-
-static int drmBOResetList(drmBOList *list)
-{
- drmMMListHead *l;
- int ret;
-
- ret = drmAdjustListNodes(list);
- if (ret)
- return ret;
-
- l = list->list.next;
- while (l != &list->list) {
- DRMLISTDEL(l);
- DRMLISTADD(l, &list->free);
- list->numOnList--;
- l = list->list.next;
- }
- return drmAdjustListNodes(list);
-}
-
-void driWriteLockKernelBO(void)
-{
- pipe_mutex_lock(bmMutex);
- while(kernelReaders != 0)
- pipe_condvar_wait(bmCond, bmMutex);
-}
-
-void driWriteUnlockKernelBO(void)
-{
- pipe_mutex_unlock(bmMutex);
-}
-
-void driReadLockKernelBO(void)
-{
- pipe_mutex_lock(bmMutex);
- kernelReaders++;
- pipe_mutex_unlock(bmMutex);
-}
-
-void driReadUnlockKernelBO(void)
-{
- pipe_mutex_lock(bmMutex);
- if (--kernelReaders == 0)
- pipe_condvar_broadcast(bmCond);
- pipe_mutex_unlock(bmMutex);
-}
-
-
-
-
-/*
- * TODO: Introduce fence pools in the same way as
- * buffer object pools.
- */
-
-typedef struct _DriBufferObject
-{
- DriBufferPool *pool;
- pipe_mutex mutex;
- int refCount;
- const char *name;
- uint64_t flags;
- unsigned hint;
- unsigned alignment;
- unsigned createdByReference;
- void *private;
- /* user-space buffer: */
- unsigned userBuffer;
- void *userData;
- unsigned userSize;
-} DriBufferObject;
-
-typedef struct _DriBufferList {
- drmBOList drmBuffers; /* List of kernel buffers needing validation */
- drmBOList driBuffers; /* List of user-space buffers needing validation */
-} DriBufferList;
-
-
-void
-bmError(int val, const char *file, const char *function, int line)
-{
- printf("Fatal video memory manager error \"%s\".\n"
- "Check kernel logs or set the LIBGL_DEBUG\n"
- "environment variable to \"verbose\" for more info.\n"
- "Detected in file %s, line %d, function %s.\n",
- strerror(-val), file, line, function);
-#ifndef NDEBUG
- abort();
-#else
- abort();
-#endif
-}
-
-extern drmBO *
-driBOKernel(struct _DriBufferObject *buf)
-{
- drmBO *ret;
-
- driReadLockKernelBO();
- pipe_mutex_lock(buf->mutex);
- assert(buf->private != NULL);
- ret = buf->pool->kernel(buf->pool, buf->private);
- if (!ret)
- BM_CKFATAL(-EINVAL);
- pipe_mutex_unlock(buf->mutex);
- driReadUnlockKernelBO();
-
- return ret;
-}
-
-void
-driBOWaitIdle(struct _DriBufferObject *buf, int lazy)
-{
-
- /*
- * This function may block. Is it sane to keep the mutex held during
- * that time??
- */
-
- pipe_mutex_lock(buf->mutex);
- BM_CKFATAL(buf->pool->waitIdle(buf->pool, buf->private, &buf->mutex, lazy));
- pipe_mutex_unlock(buf->mutex);
-}
-
-void *
-driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
-{
- void *virtual;
- int retval;
-
- if (buf->userBuffer) {
- return buf->userData;
- }
-
- pipe_mutex_lock(buf->mutex);
- assert(buf->private != NULL);
- retval = buf->pool->map(buf->pool, buf->private, flags, hint,
- &buf->mutex, &virtual);
- pipe_mutex_unlock(buf->mutex);
-
- return retval == 0 ? virtual : NULL;
-}
-
-void
-driBOUnmap(struct _DriBufferObject *buf)
-{
- if (buf->userBuffer)
- return;
-
- assert(buf->private != NULL);
- pipe_mutex_lock(buf->mutex);
- BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
- pipe_mutex_unlock(buf->mutex);
-}
-
-unsigned long
-driBOOffset(struct _DriBufferObject *buf)
-{
- unsigned long ret;
-
- assert(buf->private != NULL);
-
- pipe_mutex_lock(buf->mutex);
- ret = buf->pool->offset(buf->pool, buf->private);
- pipe_mutex_unlock(buf->mutex);
- return ret;
-}
-
-unsigned long
-driBOPoolOffset(struct _DriBufferObject *buf)
-{
- unsigned long ret;
-
- assert(buf->private != NULL);
-
- pipe_mutex_lock(buf->mutex);
- ret = buf->pool->poolOffset(buf->pool, buf->private);
- pipe_mutex_unlock(buf->mutex);
- return ret;
-}
-
-uint64_t
-driBOFlags(struct _DriBufferObject *buf)
-{
- uint64_t ret;
-
- assert(buf->private != NULL);
-
- driReadLockKernelBO();
- pipe_mutex_lock(buf->mutex);
- ret = buf->pool->flags(buf->pool, buf->private);
- pipe_mutex_unlock(buf->mutex);
- driReadUnlockKernelBO();
- return ret;
-}
-
-struct _DriBufferObject *
-driBOReference(struct _DriBufferObject *buf)
-{
- pipe_mutex_lock(buf->mutex);
- if (++buf->refCount == 1) {
- pipe_mutex_unlock(buf->mutex);
- BM_CKFATAL(-EINVAL);
- }
- pipe_mutex_unlock(buf->mutex);
- return buf;
-}
-
-void
-driBOUnReference(struct _DriBufferObject *buf)
-{
- int tmp;
-
- if (!buf)
- return;
-
- pipe_mutex_lock(buf->mutex);
- tmp = --buf->refCount;
- if (!tmp) {
- pipe_mutex_unlock(buf->mutex);
- if (buf->private) {
- if (buf->createdByReference)
- buf->pool->unreference(buf->pool, buf->private);
- else
- buf->pool->destroy(buf->pool, buf->private);
- }
- if (buf->userBuffer)
- num_user_buffers--;
- else
- num_buffers--;
- free(buf);
- } else
- pipe_mutex_unlock(buf->mutex);
-
-}
-
-
-int
-driBOData(struct _DriBufferObject *buf,
- unsigned size, const void *data,
- DriBufferPool *newPool,
- uint64_t flags)
-{
- void *virtual = NULL;
- int newBuffer;
- int retval = 0;
- struct _DriBufferPool *pool;
-
- assert(!buf->userBuffer); /* XXX just do a memcpy? */
-
- pipe_mutex_lock(buf->mutex);
- pool = buf->pool;
-
- if (pool == NULL && newPool != NULL) {
- buf->pool = newPool;
- pool = newPool;
- }
- if (newPool == NULL)
- newPool = pool;
-
- if (!pool->create) {
- assert((size_t)"driBOData called on invalid buffer\n" & 0);
- BM_CKFATAL(-EINVAL);
- }
-
- newBuffer = (!buf->private || pool != newPool ||
- pool->size(pool, buf->private) < size);
-
- if (!flags)
- flags = buf->flags;
-
- if (newBuffer) {
-
- if (buf->createdByReference) {
- assert((size_t)"driBOData requiring resizing called on shared buffer.\n" & 0);
- BM_CKFATAL(-EINVAL);
- }
-
- if (buf->private)
- buf->pool->destroy(buf->pool, buf->private);
-
- pool = newPool;
- buf->pool = newPool;
- buf->private = pool->create(pool, size, flags, DRM_BO_HINT_DONT_FENCE,
- buf->alignment);
- if (!buf->private)
- retval = -ENOMEM;
-
- if (retval == 0)
- retval = pool->map(pool, buf->private,
- DRM_BO_FLAG_WRITE,
- DRM_BO_HINT_DONT_BLOCK, &buf->mutex, &virtual);
- } else if (pool->map(pool, buf->private, DRM_BO_FLAG_WRITE,
- DRM_BO_HINT_DONT_BLOCK, &buf->mutex, &virtual)) {
- /*
- * Buffer is busy. need to create a new one.
- */
-
- void *newBuf;
-
- newBuf = pool->create(pool, size, flags, DRM_BO_HINT_DONT_FENCE,
- buf->alignment);
- if (newBuf) {
- buf->pool->destroy(buf->pool, buf->private);
- buf->private = newBuf;
- }
-
- retval = pool->map(pool, buf->private,
- DRM_BO_FLAG_WRITE, 0, &buf->mutex, &virtual);
- } else {
- uint64_t flag_diff = flags ^ buf->flags;
-
- /*
- * We might need to change buffer flags.
- */
-
- if (flag_diff){
- assert(pool->setStatus != NULL);
- BM_CKFATAL(pool->unmap(pool, buf->private));
- BM_CKFATAL(pool->setStatus(pool, buf->private, flag_diff,
- buf->flags));
- if (!data)
- goto out;
-
- retval = pool->map(pool, buf->private,
- DRM_BO_FLAG_WRITE, 0, &buf->mutex, &virtual);
- }
- }
-
- if (retval == 0) {
- if (data)
- memcpy(virtual, data, size);
-
- BM_CKFATAL(pool->unmap(pool, buf->private));
- }
-
- out:
- pipe_mutex_unlock(buf->mutex);
-
- return retval;
-}
-
-void
-driBOSubData(struct _DriBufferObject *buf,
- unsigned long offset, unsigned long size, const void *data)
-{
- void *virtual;
-
- assert(!buf->userBuffer); /* XXX just do a memcpy? */
-
- pipe_mutex_lock(buf->mutex);
- if (size && data) {
- BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
- DRM_BO_FLAG_WRITE, 0, &buf->mutex,
- &virtual));
- memcpy((unsigned char *) virtual + offset, data, size);
- BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
- }
- pipe_mutex_unlock(buf->mutex);
-}
-
-void
-driBOGetSubData(struct _DriBufferObject *buf,
- unsigned long offset, unsigned long size, void *data)
-{
- void *virtual;
-
- assert(!buf->userBuffer); /* XXX just do a memcpy? */
-
- pipe_mutex_lock(buf->mutex);
- if (size && data) {
- BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
- DRM_BO_FLAG_READ, 0, &buf->mutex, &virtual));
- memcpy(data, (unsigned char *) virtual + offset, size);
- BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
- }
- pipe_mutex_unlock(buf->mutex);
-}
-
-void
-driBOSetReferenced(struct _DriBufferObject *buf,
- unsigned long handle)
-{
- pipe_mutex_lock(buf->mutex);
- if (buf->private != NULL) {
- assert((size_t)"Invalid buffer for setReferenced\n" & 0);
- BM_CKFATAL(-EINVAL);
-
- }
- if (buf->pool->reference == NULL) {
- assert((size_t)"Invalid buffer pool for setReferenced\n" & 0);
- BM_CKFATAL(-EINVAL);
- }
- buf->private = buf->pool->reference(buf->pool, handle);
- if (!buf->private) {
- assert((size_t)"Invalid buffer pool for setStatic\n" & 0);
- BM_CKFATAL(-ENOMEM);
- }
- buf->createdByReference = TRUE;
- buf->flags = buf->pool->kernel(buf->pool, buf->private)->flags;
- pipe_mutex_unlock(buf->mutex);
-}
-
-int
-driGenBuffers(struct _DriBufferPool *pool,
- const char *name,
- unsigned n,
- struct _DriBufferObject *buffers[],
- unsigned alignment, uint64_t flags, unsigned hint)
-{
- struct _DriBufferObject *buf;
- int i;
-
- flags = (flags) ? flags : DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_MEM_VRAM |
- DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
-
- ++num_buffers;
-
- assert(pool);
-
- for (i = 0; i < n; ++i) {
- buf = (struct _DriBufferObject *) calloc(1, sizeof(*buf));
- if (!buf)
- return -ENOMEM;
-
- pipe_mutex_init(buf->mutex);
- pipe_mutex_lock(buf->mutex);
- buf->refCount = 1;
- buf->flags = flags;
- buf->hint = hint;
- buf->name = name;
- buf->alignment = alignment;
- buf->pool = pool;
- buf->createdByReference = 0;
- pipe_mutex_unlock(buf->mutex);
- buffers[i] = buf;
- }
- return 0;
-}
-
-void
-driGenUserBuffer(struct _DriBufferPool *pool,
- const char *name,
- struct _DriBufferObject **buffers,
- void *ptr, unsigned bytes)
-{
- const unsigned alignment = 1, flags = 0, hint = 0;
-
- --num_buffers; /* JB: is inced in GenBuffes */
- driGenBuffers(pool, name, 1, buffers, alignment, flags, hint);
- ++num_user_buffers;
-
- (*buffers)->userBuffer = 1;
- (*buffers)->userData = ptr;
- (*buffers)->userSize = bytes;
-}
-
-void
-driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[])
-{
- int i;
-
- for (i = 0; i < n; ++i) {
- driBOUnReference(buffers[i]);
- }
-}
-
-
-void
-driInitBufMgr(int fd)
-{
- ;
-}
-
-/*
- * Note that lists are per-context and don't need mutex protection.
- */
-
-struct _DriBufferList *
-driBOCreateList(int target)
-{
- struct _DriBufferList *list = calloc(sizeof(*list), 1);
-
- BM_CKFATAL(drmBOCreateList(target, &list->drmBuffers));
- BM_CKFATAL(drmBOCreateList(target, &list->driBuffers));
- return list;
-}
-
-int
-driBOResetList(struct _DriBufferList * list)
-{
- int ret;
- ret = drmBOResetList(&list->drmBuffers);
- if (ret)
- return ret;
- ret = drmBOResetList(&list->driBuffers);
- return ret;
-}
-
-void
-driBOFreeList(struct _DriBufferList * list)
-{
- drmBOFreeList(&list->drmBuffers);
- drmBOFreeList(&list->driBuffers);
- free(list);
-}
-
-
-/*
- * Copied from libdrm, because it is needed by driAddValidateItem.
- */
-
-static drmBONode *
-driAddListItem(drmBOList * list, drmBO * item,
- uint64_t arg0, uint64_t arg1)
-{
- drmBONode *node;
- drmMMListHead *l;
-
- l = list->free.next;
- if (l == &list->free) {
- node = (drmBONode *) malloc(sizeof(*node));
- if (!node) {
- return NULL;
- }
- list->numCurrent++;
- } else {
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- }
- memset(&node->bo_arg, 0, sizeof(node->bo_arg));
- node->buf = item;
- node->arg0 = arg0;
- node->arg1 = arg1;
- DRMLISTADDTAIL(&node->head, &list->list);
- list->numOnList++;
- return node;
-}
-
-/*
- * Slightly modified version compared to the libdrm version.
- * This one returns the list index of the buffer put on the list.
- */
-
-static int
-driAddValidateItem(drmBOList * list, drmBO * buf, uint64_t flags,
- uint64_t mask, int *itemLoc,
- struct _drmBONode **pnode)
-{
- drmBONode *node, *cur;
- drmMMListHead *l;
- int count = 0;
-
- cur = NULL;
-
- for (l = list->list.next; l != &list->list; l = l->next) {
- node = DRMLISTENTRY(drmBONode, l, head);
- if (node->buf == buf) {
- cur = node;
- break;
- }
- count++;
- }
- if (!cur) {
- cur = driAddListItem(list, buf, flags, mask);
- if (!cur)
- return -ENOMEM;
-
- cur->arg0 = flags;
- cur->arg1 = mask;
- } else {
- uint64_t memFlags = cur->arg0 & flags & DRM_BO_MASK_MEM;
- uint64_t accFlags = (cur->arg0 | flags) & ~DRM_BO_MASK_MEM;
-
- if (mask & cur->arg1 & ~DRM_BO_MASK_MEM & (cur->arg0 ^ flags)) {
- return -EINVAL;
- }
-
- cur->arg1 |= mask;
- cur->arg0 = (cur->arg0 & ~mask) | ((memFlags | accFlags) & mask);
-
- if (((cur->arg1 & DRM_BO_MASK_MEM) != 0) &&
- (cur->arg0 & DRM_BO_MASK_MEM) == 0) {
- return -EINVAL;
- }
- }
- *itemLoc = count;
- *pnode = cur;
- return 0;
-}
-
-
-void
-driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
- uint64_t flags, uint64_t mask, int *itemLoc,
- struct _drmBONode **node)
-{
- int newItem;
-
- pipe_mutex_lock(buf->mutex);
- BM_CKFATAL(driAddValidateItem(&list->drmBuffers,
- buf->pool->kernel(buf->pool, buf->private),
- flags, mask, itemLoc, node));
- BM_CKFATAL(drmAddValidateItem(&list->driBuffers, (drmBO *) buf,
- flags, mask, &newItem));
- if (newItem)
- buf->refCount++;
-
- pipe_mutex_unlock(buf->mutex);
-}
-
-drmBOList *driGetdrmBOList(struct _DriBufferList *list)
-{
- driWriteLockKernelBO();
- return &list->drmBuffers;
-}
-
-void driPutdrmBOList(struct _DriBufferList *list)
-{
- driWriteUnlockKernelBO();
-}
-
-
-void
-driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
-{
- pipe_mutex_lock(buf->mutex);
- if (buf->pool->fence)
- BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence));
- pipe_mutex_unlock(buf->mutex);
-
-}
-
-void
-driBOUnrefUserList(struct _DriBufferList *list)
-{
- struct _DriBufferObject *buf;
- void *curBuf;
-
- curBuf = drmBOListIterator(&list->driBuffers);
- while (curBuf) {
- buf = (struct _DriBufferObject *)drmBOListBuf(curBuf);
- driBOUnReference(buf);
- curBuf = drmBOListNext(&list->driBuffers, curBuf);
- }
-}
-
-struct _DriFenceObject *
-driBOFenceUserList(struct _DriFenceMgr *mgr,
- struct _DriBufferList *list, const char *name,
- drmFence *kFence)
-{
- struct _DriFenceObject *fence;
- struct _DriBufferObject *buf;
- void *curBuf;
-
- fence = driFenceCreate(mgr, kFence->fence_class, kFence->type,
- kFence, sizeof(*kFence));
- curBuf = drmBOListIterator(&list->driBuffers);
-
- /*
- * User-space fencing callbacks.
- */
-
- while (curBuf) {
- buf = (struct _DriBufferObject *) drmBOListBuf(curBuf);
- driBOFence(buf, fence);
- driBOUnReference(buf);
- curBuf = drmBOListNext(&list->driBuffers, curBuf);
- }
-
- driBOResetList(list);
- return fence;
-}
-
-void
-driBOValidateUserList(struct _DriBufferList * list)
-{
- void *curBuf;
- struct _DriBufferObject *buf;
-
- curBuf = drmBOListIterator(&list->driBuffers);
-
- /*
- * User-space validation callbacks.
- */
-
- while (curBuf) {
- buf = (struct _DriBufferObject *) drmBOListBuf(curBuf);
- pipe_mutex_lock(buf->mutex);
- if (buf->pool->validate)
- BM_CKFATAL(buf->pool->validate(buf->pool, buf->private, &buf->mutex));
- pipe_mutex_unlock(buf->mutex);
- curBuf = drmBOListNext(&list->driBuffers, curBuf);
- }
-}
-
-
-void
-driPoolTakeDown(struct _DriBufferPool *pool)
-{
- pool->takeDown(pool);
-
-}
-
-unsigned long
-driBOSize(struct _DriBufferObject *buf)
-{
- unsigned long size;
-
- pipe_mutex_lock(buf->mutex);
- size = buf->pool->size(buf->pool, buf->private);
- pipe_mutex_unlock(buf->mutex);
-
- return size;
-
-}
-
-drmBOList *driBOGetDRMBuffers(struct _DriBufferList *list)
-{
- return &list->drmBuffers;
-}
-
-drmBOList *driBOGetDRIBuffers(struct _DriBufferList *list)
-{
- return &list->driBuffers;
-}
-
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h
deleted file mode 100644
index e6c0cff0a0..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- * Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#ifndef _PSB_BUFMGR_H_
-#define _PSB_BUFMGR_H_
-#include <xf86mm.h>
-#include "i915_drm.h"
-#include "ws_dri_fencemgr.h"
-
-typedef struct _drmBONode
-{
- drmMMListHead head;
- drmBO *buf;
- struct drm_i915_op_arg bo_arg;
- uint64_t arg0;
- uint64_t arg1;
-} drmBONode;
-
-typedef struct _drmBOList {
- unsigned numTarget;
- unsigned numCurrent;
- unsigned numOnList;
- drmMMListHead list;
- drmMMListHead free;
-} drmBOList;
-
-
-struct _DriFenceObject;
-struct _DriBufferObject;
-struct _DriBufferPool;
-struct _DriBufferList;
-
-/*
- * Return a pointer to the libdrm buffer object this DriBufferObject
- * uses.
- */
-
-extern drmBO *driBOKernel(struct _DriBufferObject *buf);
-extern void *driBOMap(struct _DriBufferObject *buf, unsigned flags,
- unsigned hint);
-extern void driBOUnmap(struct _DriBufferObject *buf);
-extern unsigned long driBOOffset(struct _DriBufferObject *buf);
-extern unsigned long driBOPoolOffset(struct _DriBufferObject *buf);
-
-extern uint64_t driBOFlags(struct _DriBufferObject *buf);
-extern struct _DriBufferObject *driBOReference(struct _DriBufferObject *buf);
-extern void driBOUnReference(struct _DriBufferObject *buf);
-
-extern int driBOData(struct _DriBufferObject *r_buf,
- unsigned size, const void *data,
- struct _DriBufferPool *pool, uint64_t flags);
-
-extern void driBOSubData(struct _DriBufferObject *buf,
- unsigned long offset, unsigned long size,
- const void *data);
-extern void driBOGetSubData(struct _DriBufferObject *buf,
- unsigned long offset, unsigned long size,
- void *data);
-extern int driGenBuffers(struct _DriBufferPool *pool,
- const char *name,
- unsigned n,
- struct _DriBufferObject *buffers[],
- unsigned alignment, uint64_t flags, unsigned hint);
-extern void driGenUserBuffer(struct _DriBufferPool *pool,
- const char *name,
- struct _DriBufferObject *buffers[],
- void *ptr, unsigned bytes);
-extern void driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[]);
-extern void driInitBufMgr(int fd);
-extern struct _DriBufferList *driBOCreateList(int target);
-extern int driBOResetList(struct _DriBufferList * list);
-extern void driBOAddListItem(struct _DriBufferList * list,
- struct _DriBufferObject *buf,
- uint64_t flags, uint64_t mask, int *itemLoc,
- struct _drmBONode **node);
-
-extern void driBOValidateList(int fd, struct _DriBufferList * list);
-extern void driBOFreeList(struct _DriBufferList * list);
-extern struct _DriFenceObject *driBOFenceUserList(struct _DriFenceMgr *mgr,
- struct _DriBufferList *list,
- const char *name,
- drmFence *kFence);
-extern void driBOUnrefUserList(struct _DriBufferList *list);
-extern void driBOValidateUserList(struct _DriBufferList * list);
-extern drmBOList *driGetdrmBOList(struct _DriBufferList *list);
-extern void driPutdrmBOList(struct _DriBufferList *list);
-
-extern void driBOFence(struct _DriBufferObject *buf,
- struct _DriFenceObject *fence);
-
-extern void driPoolTakeDown(struct _DriBufferPool *pool);
-extern void driBOSetReferenced(struct _DriBufferObject *buf,
- unsigned long handle);
-unsigned long driBOSize(struct _DriBufferObject *buf);
-extern void driBOWaitIdle(struct _DriBufferObject *buf, int lazy);
-extern void driPoolTakeDown(struct _DriBufferPool *pool);
-
-extern void driReadLockKernelBO(void);
-extern void driReadUnlockKernelBO(void);
-extern void driWriteLockKernelBO(void);
-extern void driWriteUnlockKernelBO(void);
-
-/*
- * For debugging purposes.
- */
-
-extern drmBOList *driBOGetDRMBuffers(struct _DriBufferList *list);
-extern drmBOList *driBOGetDRIBuffers(struct _DriBufferList *list);
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h b/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
deleted file mode 100644
index ad3b6f3931..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#ifndef _PSB_BUFPOOL_H_
-#define _PSB_BUFPOOL_H_
-
-#include <xf86drm.h>
-#include "pipe/p_thread.h"
-struct _DriFenceObject;
-
-typedef struct _DriBufferPool
-{
- int fd;
- int (*map) (struct _DriBufferPool * pool, void *private,
- unsigned flags, int hint, pipe_mutex *mutex,
- void **virtual);
- int (*unmap) (struct _DriBufferPool * pool, void *private);
- int (*destroy) (struct _DriBufferPool * pool, void *private);
- unsigned long (*offset) (struct _DriBufferPool * pool, void *private);
- unsigned long (*poolOffset) (struct _DriBufferPool * pool, void *private);
- uint64_t (*flags) (struct _DriBufferPool * pool, void *private);
- unsigned long (*size) (struct _DriBufferPool * pool, void *private);
- void *(*create) (struct _DriBufferPool * pool, unsigned long size,
- uint64_t flags, unsigned hint, unsigned alignment);
- void *(*reference) (struct _DriBufferPool * pool, unsigned handle);
- int (*unreference) (struct _DriBufferPool * pool, void *private);
- int (*fence) (struct _DriBufferPool * pool, void *private,
- struct _DriFenceObject * fence);
- drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
- int (*validate) (struct _DriBufferPool * pool, void *private, pipe_mutex *mutex);
- int (*waitIdle) (struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
- int lazy);
- int (*setStatus) (struct _DriBufferPool *pool, void *private,
- uint64_t flag_diff, uint64_t old_flags);
- void (*takeDown) (struct _DriBufferPool * pool);
- void *data;
-} DriBufferPool;
-
-extern void bmError(int val, const char *file, const char *function,
- int line);
-#define BM_CKFATAL(val) \
- do{ \
- int tstVal = (val); \
- if (tstVal) \
- bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \
- } while(0);
-
-
-/*
- * Builtin pools.
- */
-
-/*
- * Kernel buffer objects. Size in multiples of page size. Page size aligned.
- */
-
-extern struct _DriBufferPool *driDRMPoolInit(int fd);
-extern struct _DriBufferPool *driMallocPoolInit(void);
-
-struct _DriFreeSlabManager;
-extern struct _DriBufferPool * driSlabPoolInit(int fd, uint64_t flags,
- uint64_t validMask,
- uint32_t smallestSize,
- uint32_t numSizes,
- uint32_t desiredNumBuffers,
- uint32_t maxSlabSize,
- uint32_t pageAlignment,
- struct _DriFreeSlabManager *fMan);
-extern void driFinishFreeSlabManager(struct _DriFreeSlabManager *fMan);
-extern struct _DriFreeSlabManager *
-driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec);
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
deleted file mode 100644
index 54618b1c82..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <xf86drm.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "ws_dri_bufpool.h"
-#include "ws_dri_bufmgr.h"
-#include "assert.h"
-
-/*
- * Buffer pool implementation using DRM buffer objects as DRI buffer objects.
- */
-
-static void *
-pool_create(struct _DriBufferPool *pool,
- unsigned long size, uint64_t flags, unsigned hint,
- unsigned alignment)
-{
- drmBO *buf = (drmBO *) malloc(sizeof(*buf));
- int ret;
- unsigned pageSize = getpagesize();
-
- if (!buf)
- return NULL;
-
- if ((alignment > pageSize) && (alignment % pageSize)) {
- free(buf);
- return NULL;
- }
-
- ret = drmBOCreate(pool->fd, size, alignment / pageSize,
- NULL,
- flags, hint, buf);
- if (ret) {
- free(buf);
- return NULL;
- }
-
- return (void *) buf;
-}
-
-static void *
-pool_reference(struct _DriBufferPool *pool, unsigned handle)
-{
- drmBO *buf = (drmBO *) malloc(sizeof(*buf));
- int ret;
-
- if (!buf)
- return NULL;
-
- ret = drmBOReference(pool->fd, handle, buf);
-
- if (ret) {
- free(buf);
- return NULL;
- }
-
- return (void *) buf;
-}
-
-static int
-pool_destroy(struct _DriBufferPool *pool, void *private)
-{
- int ret;
- drmBO *buf = (drmBO *) private;
- driReadLockKernelBO();
- ret = drmBOUnreference(pool->fd, buf);
- free(buf);
- driReadUnlockKernelBO();
- return ret;
-}
-
-static int
-pool_unreference(struct _DriBufferPool *pool, void *private)
-{
- int ret;
- drmBO *buf = (drmBO *) private;
- driReadLockKernelBO();
- ret = drmBOUnreference(pool->fd, buf);
- free(buf);
- driReadUnlockKernelBO();
- return ret;
-}
-
-static int
-pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, pipe_mutex *mutex, void **virtual)
-{
- drmBO *buf = (drmBO *) private;
- int ret;
-
- driReadLockKernelBO();
- ret = drmBOMap(pool->fd, buf, flags, hint, virtual);
- driReadUnlockKernelBO();
- return ret;
-}
-
-static int
-pool_unmap(struct _DriBufferPool *pool, void *private)
-{
- drmBO *buf = (drmBO *) private;
- int ret;
-
- driReadLockKernelBO();
- ret = drmBOUnmap(pool->fd, buf);
- driReadUnlockKernelBO();
-
- return ret;
-}
-
-static unsigned long
-pool_offset(struct _DriBufferPool *pool, void *private)
-{
- drmBO *buf = (drmBO *) private;
- unsigned long offset;
-
- driReadLockKernelBO();
- assert(buf->flags & DRM_BO_FLAG_NO_MOVE);
- offset = buf->offset;
- driReadUnlockKernelBO();
-
- return buf->offset;
-}
-
-static unsigned long
-pool_poolOffset(struct _DriBufferPool *pool, void *private)
-{
- return 0;
-}
-
-static uint64_t
-pool_flags(struct _DriBufferPool *pool, void *private)
-{
- drmBO *buf = (drmBO *) private;
- uint64_t flags;
-
- driReadLockKernelBO();
- flags = buf->flags;
- driReadUnlockKernelBO();
-
- return flags;
-}
-
-
-static unsigned long
-pool_size(struct _DriBufferPool *pool, void *private)
-{
- drmBO *buf = (drmBO *) private;
- unsigned long size;
-
- driReadLockKernelBO();
- size = buf->size;
- driReadUnlockKernelBO();
-
- return buf->size;
-}
-
-static int
-pool_fence(struct _DriBufferPool *pool, void *private,
- struct _DriFenceObject *fence)
-{
- /*
- * Noop. The kernel handles all fencing.
- */
-
- return 0;
-}
-
-static drmBO *
-pool_kernel(struct _DriBufferPool *pool, void *private)
-{
- return (drmBO *) private;
-}
-
-static int
-pool_waitIdle(struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
- int lazy)
-{
- drmBO *buf = (drmBO *) private;
- int ret;
-
- driReadLockKernelBO();
- ret = drmBOWaitIdle(pool->fd, buf, (lazy) ? DRM_BO_HINT_WAIT_LAZY:0);
- driReadUnlockKernelBO();
-
- return ret;
-}
-
-
-static void
-pool_takedown(struct _DriBufferPool *pool)
-{
- free(pool);
-}
-
-/*static int
-pool_setStatus(struct _DriBufferPool *pool, void *private,
- uint64_t flag_diff, uint64_t old_flags)
-{
- drmBO *buf = (drmBO *) private;
- uint64_t new_flags = old_flags ^ flag_diff;
- int ret;
-
- driReadLockKernelBO();
- ret = drmBOSetStatus(pool->fd, buf, new_flags, flag_diff,
- 0, 0, 0);
- driReadUnlockKernelBO();
- return ret;
-}*/
-
-struct _DriBufferPool *
-driDRMPoolInit(int fd)
-{
- struct _DriBufferPool *pool;
-
- pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
-
- if (!pool)
- return NULL;
-
- pool->fd = fd;
- pool->map = &pool_map;
- pool->unmap = &pool_unmap;
- pool->destroy = &pool_destroy;
- pool->offset = &pool_offset;
- pool->poolOffset = &pool_poolOffset;
- pool->flags = &pool_flags;
- pool->size = &pool_size;
- pool->create = &pool_create;
- pool->fence = &pool_fence;
- pool->kernel = &pool_kernel;
- pool->validate = NULL;
- pool->waitIdle = &pool_waitIdle;
- pool->takeDown = &pool_takedown;
- pool->reference = &pool_reference;
- pool->unreference = &pool_unreference;
- pool->data = NULL;
- return pool;
-}
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
deleted file mode 100644
index 831c75d30c..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
+++ /dev/null
@@ -1,377 +0,0 @@
-#include "ws_dri_fencemgr.h"
-#include "pipe/p_thread.h"
-#include <xf86mm.h>
-#include <string.h>
-#include <unistd.h>
-
-/*
- * Note: Locking order is
- * _DriFenceObject::mutex
- * _DriFenceMgr::mutex
- */
-
-struct _DriFenceMgr {
- /*
- * Constant members. Need no mutex protection.
- */
- struct _DriFenceMgrCreateInfo info;
- void *private;
-
- /*
- * These members are protected by this->mutex
- */
- pipe_mutex mutex;
- int refCount;
- drmMMListHead *heads;
- int num_fences;
-};
-
-struct _DriFenceObject {
-
- /*
- * These members are constant and need no mutex protection.
- */
- struct _DriFenceMgr *mgr;
- uint32_t fence_class;
- uint32_t fence_type;
-
- /*
- * These members are protected by mgr->mutex.
- */
- drmMMListHead head;
- int refCount;
-
- /*
- * These members are protected by this->mutex.
- */
- pipe_mutex mutex;
- uint32_t signaled_type;
- void *private;
-};
-
-uint32_t
-driFenceType(struct _DriFenceObject *fence)
-{
- return fence->fence_type;
-}
-
-struct _DriFenceMgr *
-driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info)
-{
- struct _DriFenceMgr *tmp;
- uint32_t i;
-
- tmp = calloc(1, sizeof(*tmp));
- if (!tmp)
- return NULL;
-
- pipe_mutex_init(tmp->mutex);
- pipe_mutex_lock(tmp->mutex);
- tmp->refCount = 1;
- tmp->info = *info;
- tmp->num_fences = 0;
- tmp->heads = calloc(tmp->info.num_classes, sizeof(*tmp->heads));
- if (!tmp->heads)
- goto out_err;
-
- for (i=0; i<tmp->info.num_classes; ++i) {
- DRMINITLISTHEAD(&tmp->heads[i]);
- }
- pipe_mutex_unlock(tmp->mutex);
- return tmp;
-
- out_err:
- if (tmp)
- free(tmp);
- return NULL;
-}
-
-static void
-driFenceMgrUnrefUnlock(struct _DriFenceMgr **pMgr)
-{
- struct _DriFenceMgr *mgr = *pMgr;
-
- *pMgr = NULL;
- if (--mgr->refCount == 0)
- free(mgr);
- else
- pipe_mutex_unlock(mgr->mutex);
-}
-
-void
-driFenceMgrUnReference(struct _DriFenceMgr **pMgr)
-{
- pipe_mutex_lock((*pMgr)->mutex);
- driFenceMgrUnrefUnlock(pMgr);
-}
-
-static void
-driFenceUnReferenceLocked(struct _DriFenceObject **pFence)
-{
- struct _DriFenceObject *fence = *pFence;
- struct _DriFenceMgr *mgr = fence->mgr;
-
- *pFence = NULL;
- if (--fence->refCount == 0) {
- DRMLISTDELINIT(&fence->head);
- if (fence->private)
- mgr->info.unreference(mgr, &fence->private);
- --mgr->num_fences;
- fence->mgr = NULL;
- --mgr->refCount;
- free(fence);
-
- }
-}
-
-
-static void
-driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
- drmMMListHead *list,
- uint32_t fence_class,
- uint32_t fence_type)
-{
- struct _DriFenceObject *entry;
- drmMMListHead *prev;
-
- while(list != &mgr->heads[fence_class]) {
- entry = DRMLISTENTRY(struct _DriFenceObject, list, head);
-
- /*
- * Up refcount so that entry doesn't disappear from under us
- * when we unlock-relock mgr to get the correct locking order.
- */
-
- ++entry->refCount;
- pipe_mutex_unlock(mgr->mutex);
- pipe_mutex_lock(entry->mutex);
- pipe_mutex_lock(mgr->mutex);
-
- prev = list->prev;
-
-
-
- if (list->prev == list) {
-
- /*
- * Somebody else removed the entry from the list.
- */
-
- pipe_mutex_unlock(entry->mutex);
- driFenceUnReferenceLocked(&entry);
- return;
- }
-
- entry->signaled_type |= (fence_type & entry->fence_type);
- if (entry->signaled_type == entry->fence_type) {
- DRMLISTDELINIT(list);
- mgr->info.unreference(mgr, &entry->private);
- }
- pipe_mutex_unlock(entry->mutex);
- driFenceUnReferenceLocked(&entry);
- list = prev;
- }
-}
-
-
-int
-driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
- int lazy_hint)
-{
- struct _DriFenceMgr *mgr = fence->mgr;
- int ret = 0;
-
- pipe_mutex_lock(fence->mutex);
-
- if ((fence->signaled_type & fence_type) == fence_type)
- goto out0;
-
- ret = mgr->info.finish(mgr, fence->private, fence_type, lazy_hint);
- if (ret)
- goto out0;
-
- pipe_mutex_lock(mgr->mutex);
- pipe_mutex_unlock(fence->mutex);
-
- driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
- fence_type);
- pipe_mutex_unlock(mgr->mutex);
- return 0;
-
- out0:
- pipe_mutex_unlock(fence->mutex);
- return ret;
-}
-
-uint32_t driFenceSignaledTypeCached(struct _DriFenceObject *fence)
-{
- uint32_t ret;
-
- pipe_mutex_lock(fence->mutex);
- ret = fence->signaled_type;
- pipe_mutex_unlock(fence->mutex);
-
- return ret;
-}
-
-int
-driFenceSignaledType(struct _DriFenceObject *fence, uint32_t flush_type,
- uint32_t *signaled)
-{
- int ret = 0;
- struct _DriFenceMgr *mgr;
-
- pipe_mutex_lock(fence->mutex);
- mgr = fence->mgr;
- *signaled = fence->signaled_type;
- if ((fence->signaled_type & flush_type) == flush_type)
- goto out0;
-
- ret = mgr->info.signaled(mgr, fence->private, flush_type, signaled);
- if (ret) {
- *signaled = fence->signaled_type;
- goto out0;
- }
-
- if ((fence->signaled_type | *signaled) == fence->signaled_type)
- goto out0;
-
- pipe_mutex_lock(mgr->mutex);
- pipe_mutex_unlock(fence->mutex);
-
- driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
- *signaled);
-
- pipe_mutex_unlock(mgr->mutex);
- return 0;
- out0:
- pipe_mutex_unlock(fence->mutex);
- return ret;
-}
-
-struct _DriFenceObject *
-driFenceReference(struct _DriFenceObject *fence)
-{
- pipe_mutex_lock(fence->mgr->mutex);
- ++fence->refCount;
- pipe_mutex_unlock(fence->mgr->mutex);
- return fence;
-}
-
-void
-driFenceUnReference(struct _DriFenceObject **pFence)
-{
- struct _DriFenceMgr *mgr;
-
- if (*pFence == NULL)
- return;
-
- mgr = (*pFence)->mgr;
- pipe_mutex_lock(mgr->mutex);
- ++mgr->refCount;
- driFenceUnReferenceLocked(pFence);
- driFenceMgrUnrefUnlock(&mgr);
-}
-
-struct _DriFenceObject
-*driFenceCreate(struct _DriFenceMgr *mgr, uint32_t fence_class,
- uint32_t fence_type, void *private, size_t private_size)
-{
- struct _DriFenceObject *fence;
- size_t fence_size = sizeof(*fence);
-
- if (private_size)
- fence_size = ((fence_size + 15) & ~15);
-
- fence = calloc(1, fence_size + private_size);
-
- if (!fence) {
- int ret = mgr->info.finish(mgr, private, fence_type, 0);
-
- if (ret)
- usleep(10000000);
-
- return NULL;
- }
-
- pipe_mutex_init(fence->mutex);
- pipe_mutex_lock(fence->mutex);
- pipe_mutex_lock(mgr->mutex);
- fence->refCount = 1;
- DRMLISTADDTAIL(&fence->head, &mgr->heads[fence_class]);
- fence->mgr = mgr;
- ++mgr->refCount;
- ++mgr->num_fences;
- pipe_mutex_unlock(mgr->mutex);
- fence->fence_class = fence_class;
- fence->fence_type = fence_type;
- fence->signaled_type = 0;
- fence->private = private;
- if (private_size) {
- fence->private = (void *)(((uint8_t *) fence) + fence_size);
- memcpy(fence->private, private, private_size);
- }
-
- pipe_mutex_unlock(fence->mutex);
- return fence;
-}
-
-
-static int
-tSignaled(struct _DriFenceMgr *mgr, void *private, uint32_t flush_type,
- uint32_t *signaled_type)
-{
- long fd = (long) mgr->private;
- int dummy;
- drmFence *fence = (drmFence *) private;
- int ret;
-
- *signaled_type = 0;
- ret = drmFenceSignaled((int) fd, fence, flush_type, &dummy);
- if (ret)
- return ret;
-
- *signaled_type = fence->signaled;
-
- return 0;
-}
-
-static int
-tFinish(struct _DriFenceMgr *mgr, void *private, uint32_t fence_type,
- int lazy_hint)
-{
- long fd = (long) mgr->private;
- unsigned flags = lazy_hint ? DRM_FENCE_FLAG_WAIT_LAZY : 0;
-
- return drmFenceWait((int)fd, flags, (drmFence *) private, fence_type);
-}
-
-static int
-tUnref(struct _DriFenceMgr *mgr, void **private)
-{
- long fd = (long) mgr->private;
- drmFence *fence = (drmFence *) *private;
- *private = NULL;
-
- return drmFenceUnreference(fd, fence);
-}
-
-struct _DriFenceMgr *driFenceMgrTTMInit(int fd)
-{
- struct _DriFenceMgrCreateInfo info;
- struct _DriFenceMgr *mgr;
-
- info.flags = DRI_FENCE_CLASS_ORDERED;
- info.num_classes = 4;
- info.signaled = tSignaled;
- info.finish = tFinish;
- info.unreference = tUnref;
-
- mgr = driFenceMgrCreate(&info);
- if (mgr == NULL)
- return NULL;
-
- mgr->private = (void *) (long) fd;
- return mgr;
-}
-
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h
deleted file mode 100644
index 4ea58dfe18..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h
+++ /dev/null
@@ -1,115 +0,0 @@
-#ifndef DRI_FENCEMGR_H
-#define DRI_FENCEMGR_H
-
-#include <stdint.h>
-#include <stdlib.h>
-
-struct _DriFenceObject;
-struct _DriFenceMgr;
-
-/*
- * Do a quick check to see if the fence manager has registered the fence
- * object as signaled. Note that this function may return a false negative
- * answer.
- */
-extern uint32_t driFenceSignaledTypeCached(struct _DriFenceObject *fence);
-
-/*
- * Check if the fence object is signaled. This function can be substantially
- * more expensive to call than the above function, but will not return a false
- * negative answer. The argument "flush_type" sets the types that the
- * underlying mechanism must make sure will eventually signal.
- */
-extern int driFenceSignaledType(struct _DriFenceObject *fence,
- uint32_t flush_type, uint32_t *signaled);
-
-/*
- * Convenience functions.
- */
-
-static inline int driFenceSignaled(struct _DriFenceObject *fence,
- uint32_t flush_type)
-{
- uint32_t signaled_types;
- int ret = driFenceSignaledType(fence, flush_type, &signaled_types);
- if (ret)
- return 0;
- return ((signaled_types & flush_type) == flush_type);
-}
-
-static inline int driFenceSignaledCached(struct _DriFenceObject *fence,
- uint32_t flush_type)
-{
- uint32_t signaled_types =
- driFenceSignaledTypeCached(fence);
-
- return ((signaled_types & flush_type) == flush_type);
-}
-
-/*
- * Reference a fence object.
- */
-extern struct _DriFenceObject *driFenceReference(struct _DriFenceObject *fence);
-
-/*
- * Unreference a fence object. The fence object pointer will be reset to NULL.
- */
-
-extern void driFenceUnReference(struct _DriFenceObject **pFence);
-
-
-/*
- * Wait for a fence to signal the indicated fence_type.
- * If "lazy_hint" is true, it indicates that the wait may sleep to avoid
- * busy-wait polling.
- */
-extern int driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
- int lazy_hint);
-
-/*
- * Create a DriFenceObject for manager "mgr".
- *
- * "private" is a pointer that should be used for the callbacks in
- * struct _DriFenceMgrCreateInfo.
- *
- * if private_size is nonzero, then the info stored at *private, with size
- * private size will be copied and the fence manager will instead use a
- * pointer to the copied data for the callbacks in
- * struct _DriFenceMgrCreateInfo. In that case, the object pointed to by
- * "private" may be destroyed after the call to driFenceCreate.
- */
-extern struct _DriFenceObject *driFenceCreate(struct _DriFenceMgr *mgr,
- uint32_t fence_class,
- uint32_t fence_type,
- void *private,
- size_t private_size);
-
-extern uint32_t driFenceType(struct _DriFenceObject *fence);
-
-/*
- * Fence creations are ordered. If a fence signals a fence_type,
- * it is safe to assume that all fences of the same class that was
- * created before that fence has signaled the same type.
- */
-
-#define DRI_FENCE_CLASS_ORDERED (1 << 0)
-
-struct _DriFenceMgrCreateInfo {
- uint32_t flags;
- uint32_t num_classes;
- int (*signaled) (struct _DriFenceMgr *mgr, void *private, uint32_t flush_type,
- uint32_t *signaled_type);
- int (*finish) (struct _DriFenceMgr *mgr, void *private, uint32_t fence_type, int lazy_hint);
- int (*unreference) (struct _DriFenceMgr *mgr, void **private);
-};
-
-extern struct _DriFenceMgr *
-driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info);
-
-void
-driFenceMgrUnReference(struct _DriFenceMgr **pMgr);
-
-extern struct _DriFenceMgr *
-driFenceMgrTTMInit(int fd);
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
deleted file mode 100644
index 60924eac9e..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <xf86drm.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "pipe/p_debug.h"
-#include "pipe/p_thread.h"
-#include "ws_dri_bufpool.h"
-#include "ws_dri_bufmgr.h"
-
-static void *
-pool_create(struct _DriBufferPool *pool,
- unsigned long size, uint64_t flags, unsigned hint,
- unsigned alignment)
-{
- unsigned long *private = malloc(size + 2*sizeof(unsigned long));
- if ((flags & DRM_BO_MASK_MEM) != DRM_BO_FLAG_MEM_LOCAL)
- abort();
-
- *private = size;
- return (void *)private;
-}
-
-
-static int
-pool_destroy(struct _DriBufferPool *pool, void *private)
-{
- free(private);
- return 0;
-}
-
-static int
-pool_waitIdle(struct _DriBufferPool *pool, void *private,
- pipe_mutex *mutex, int lazy)
-{
- return 0;
-}
-
-static int
-pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, pipe_mutex *mutex, void **virtual)
-{
- *virtual = (void *)((unsigned long *)private + 2);
- return 0;
-}
-
-static int
-pool_unmap(struct _DriBufferPool *pool, void *private)
-{
- return 0;
-}
-
-static unsigned long
-pool_offset(struct _DriBufferPool *pool, void *private)
-{
- /*
- * BUG
- */
- abort();
- return 0UL;
-}
-
-static unsigned long
-pool_poolOffset(struct _DriBufferPool *pool, void *private)
-{
- /*
- * BUG
- */
- abort();
-}
-
-static uint64_t
-pool_flags(struct _DriBufferPool *pool, void *private)
-{
- return DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
-}
-
-static unsigned long
-pool_size(struct _DriBufferPool *pool, void *private)
-{
- return *(unsigned long *) private;
-}
-
-
-static int
-pool_fence(struct _DriBufferPool *pool, void *private,
- struct _DriFenceObject *fence)
-{
- abort();
- return 0UL;
-}
-
-static drmBO *
-pool_kernel(struct _DriBufferPool *pool, void *private)
-{
- abort();
- return NULL;
-}
-
-static void
-pool_takedown(struct _DriBufferPool *pool)
-{
- free(pool);
-}
-
-
-struct _DriBufferPool *
-driMallocPoolInit(void)
-{
- struct _DriBufferPool *pool;
-
- pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
- if (!pool)
- return NULL;
-
- pool->data = NULL;
- pool->fd = -1;
- pool->map = &pool_map;
- pool->unmap = &pool_unmap;
- pool->destroy = &pool_destroy;
- pool->offset = &pool_offset;
- pool->poolOffset = &pool_poolOffset;
- pool->flags = &pool_flags;
- pool->size = &pool_size;
- pool->create = &pool_create;
- pool->fence = &pool_fence;
- pool->kernel = &pool_kernel;
- pool->validate = NULL;
- pool->waitIdle = &pool_waitIdle;
- pool->takeDown = &pool_takedown;
- return pool;
-}
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
deleted file mode 100644
index 391cea50a7..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
+++ /dev/null
@@ -1,968 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <stdint.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <unistd.h>
-#include <assert.h>
-#include "ws_dri_bufpool.h"
-#include "ws_dri_fencemgr.h"
-#include "ws_dri_bufmgr.h"
-#include "pipe/p_thread.h"
-
-#define DRI_SLABPOOL_ALLOC_RETRIES 100
-
-struct _DriSlab;
-
-struct _DriSlabBuffer {
- int isSlabBuffer;
- drmBO *bo;
- struct _DriFenceObject *fence;
- struct _DriSlab *parent;
- drmMMListHead head;
- uint32_t mapCount;
- uint32_t start;
- uint32_t fenceType;
- int unFenced;
- pipe_condvar event;
-};
-
-struct _DriKernelBO {
- int fd;
- drmBO bo;
- drmMMListHead timeoutHead;
- drmMMListHead head;
- struct timeval timeFreed;
- uint32_t pageAlignment;
- void *virtual;
-};
-
-struct _DriSlab{
- drmMMListHead head;
- drmMMListHead freeBuffers;
- uint32_t numBuffers;
- uint32_t numFree;
- struct _DriSlabBuffer *buffers;
- struct _DriSlabSizeHeader *header;
- struct _DriKernelBO *kbo;
-};
-
-
-struct _DriSlabSizeHeader {
- drmMMListHead slabs;
- drmMMListHead freeSlabs;
- drmMMListHead delayedBuffers;
- uint32_t numDelayed;
- struct _DriSlabPool *slabPool;
- uint32_t bufSize;
- pipe_mutex mutex;
-};
-
-struct _DriFreeSlabManager {
- struct timeval slabTimeout;
- struct timeval checkInterval;
- struct timeval nextCheck;
- drmMMListHead timeoutList;
- drmMMListHead unCached;
- drmMMListHead cached;
- pipe_mutex mutex;
-};
-
-
-struct _DriSlabPool {
-
- /*
- * The data of this structure remains constant after
- * initialization and thus needs no mutex protection.
- */
-
- struct _DriFreeSlabManager *fMan;
- uint64_t proposedFlags;
- uint64_t validMask;
- uint32_t *bucketSizes;
- uint32_t numBuckets;
- uint32_t pageSize;
- int fd;
- int pageAlignment;
- int maxSlabSize;
- int desiredNumBuffers;
- struct _DriSlabSizeHeader *headers;
-};
-
-/*
- * FIXME: Perhaps arrange timeout slabs in size buckets for fast
- * retreival??
- */
-
-
-static inline int
-driTimeAfterEq(struct timeval *arg1, struct timeval *arg2)
-{
- return ((arg1->tv_sec > arg2->tv_sec) ||
- ((arg1->tv_sec == arg2->tv_sec) &&
- (arg1->tv_usec > arg2->tv_usec)));
-}
-
-static inline void
-driTimeAdd(struct timeval *arg, struct timeval *add)
-{
- unsigned int sec;
-
- arg->tv_sec += add->tv_sec;
- arg->tv_usec += add->tv_usec;
- sec = arg->tv_usec / 1000000;
- arg->tv_sec += sec;
- arg->tv_usec -= sec*1000000;
-}
-
-static void
-driFreeKernelBO(struct _DriKernelBO *kbo)
-{
- if (!kbo)
- return;
-
- (void) drmBOUnreference(kbo->fd, &kbo->bo);
- free(kbo);
-}
-
-
-static void
-driFreeTimeoutKBOsLocked(struct _DriFreeSlabManager *fMan,
- struct timeval *time)
-{
- drmMMListHead *list, *next;
- struct _DriKernelBO *kbo;
-
- if (!driTimeAfterEq(time, &fMan->nextCheck))
- return;
-
- for (list = fMan->timeoutList.next, next = list->next;
- list != &fMan->timeoutList;
- list = next, next = list->next) {
-
- kbo = DRMLISTENTRY(struct _DriKernelBO, list, timeoutHead);
-
- if (!driTimeAfterEq(time, &kbo->timeFreed))
- break;
-
- DRMLISTDELINIT(&kbo->timeoutHead);
- DRMLISTDELINIT(&kbo->head);
- driFreeKernelBO(kbo);
- }
-
- fMan->nextCheck = *time;
- driTimeAdd(&fMan->nextCheck, &fMan->checkInterval);
-}
-
-
-/*
- * Add a _DriKernelBO to the free slab manager.
- * This means that it is available for reuse, but if it's not
- * reused in a while, it will be freed.
- */
-
-static void
-driSetKernelBOFree(struct _DriFreeSlabManager *fMan,
- struct _DriKernelBO *kbo)
-{
- struct timeval time;
-
- pipe_mutex_lock(fMan->mutex);
- gettimeofday(&time, NULL);
- driTimeAdd(&time, &fMan->slabTimeout);
-
- kbo->timeFreed = time;
-
- if (kbo->bo.flags & DRM_BO_FLAG_CACHED)
- DRMLISTADD(&kbo->head, &fMan->cached);
- else
- DRMLISTADD(&kbo->head, &fMan->unCached);
-
- DRMLISTADDTAIL(&kbo->timeoutHead, &fMan->timeoutList);
- driFreeTimeoutKBOsLocked(fMan, &time);
-
- pipe_mutex_unlock(fMan->mutex);
-}
-
-/*
- * Get a _DriKernelBO for us to use as storage for a slab.
- *
- */
-
-static struct _DriKernelBO *
-driAllocKernelBO(struct _DriSlabSizeHeader *header)
-
-{
- struct _DriSlabPool *slabPool = header->slabPool;
- struct _DriFreeSlabManager *fMan = slabPool->fMan;
- drmMMListHead *list, *next, *head;
- uint32_t size = header->bufSize * slabPool->desiredNumBuffers;
- struct _DriKernelBO *kbo;
- struct _DriKernelBO *kboTmp;
- int ret;
-
- /*
- * FIXME: We should perhaps allow some variation in slabsize in order
- * to efficiently reuse slabs.
- */
-
- size = (size <= slabPool->maxSlabSize) ? size : slabPool->maxSlabSize;
- size = (size + slabPool->pageSize - 1) & ~(slabPool->pageSize - 1);
- pipe_mutex_lock(fMan->mutex);
-
- kbo = NULL;
-
- retry:
- head = (slabPool->proposedFlags & DRM_BO_FLAG_CACHED) ?
- &fMan->cached : &fMan->unCached;
-
- for (list = head->next, next = list->next;
- list != head;
- list = next, next = list->next) {
-
- kboTmp = DRMLISTENTRY(struct _DriKernelBO, list, head);
-
- if ((kboTmp->bo.size == size) &&
- (slabPool->pageAlignment == 0 ||
- (kboTmp->pageAlignment % slabPool->pageAlignment) == 0)) {
-
- if (!kbo)
- kbo = kboTmp;
-
- if ((kbo->bo.proposedFlags ^ slabPool->proposedFlags) == 0)
- break;
-
- }
- }
-
- if (kbo) {
- DRMLISTDELINIT(&kbo->head);
- DRMLISTDELINIT(&kbo->timeoutHead);
- }
-
- pipe_mutex_unlock(fMan->mutex);
-
- if (kbo) {
- uint64_t new_mask = kbo->bo.proposedFlags ^ slabPool->proposedFlags;
-
- ret = 0;
- if (new_mask) {
- ret = drmBOSetStatus(kbo->fd, &kbo->bo, slabPool->proposedFlags,
- new_mask, DRM_BO_HINT_DONT_FENCE, 0, 0);
- }
- if (ret == 0)
- return kbo;
-
- driFreeKernelBO(kbo);
- kbo = NULL;
- goto retry;
- }
-
- kbo = calloc(1, sizeof(struct _DriKernelBO));
- if (!kbo)
- return NULL;
-
- kbo->fd = slabPool->fd;
- DRMINITLISTHEAD(&kbo->head);
- DRMINITLISTHEAD(&kbo->timeoutHead);
- ret = drmBOCreate(kbo->fd, size, slabPool->pageAlignment, NULL,
- slabPool->proposedFlags,
- DRM_BO_HINT_DONT_FENCE, &kbo->bo);
- if (ret)
- goto out_err0;
-
- ret = drmBOMap(kbo->fd, &kbo->bo,
- DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- 0, &kbo->virtual);
-
- if (ret)
- goto out_err1;
-
- ret = drmBOUnmap(kbo->fd, &kbo->bo);
- if (ret)
- goto out_err1;
-
- return kbo;
-
- out_err1:
- drmBOUnreference(kbo->fd, &kbo->bo);
- out_err0:
- free(kbo);
- return NULL;
-}
-
-
-static int
-driAllocSlab(struct _DriSlabSizeHeader *header)
-{
- struct _DriSlab *slab;
- struct _DriSlabBuffer *buf;
- uint32_t numBuffers;
- int ret;
- int i;
-
- slab = calloc(1, sizeof(*slab));
- if (!slab)
- return -ENOMEM;
-
- slab->kbo = driAllocKernelBO(header);
- if (!slab->kbo) {
- ret = -ENOMEM;
- goto out_err0;
- }
-
- numBuffers = slab->kbo->bo.size / header->bufSize;
-
- slab->buffers = calloc(numBuffers, sizeof(*slab->buffers));
- if (!slab->buffers) {
- ret = -ENOMEM;
- goto out_err1;
- }
-
- DRMINITLISTHEAD(&slab->head);
- DRMINITLISTHEAD(&slab->freeBuffers);
- slab->numBuffers = numBuffers;
- slab->numFree = 0;
- slab->header = header;
-
- buf = slab->buffers;
- for (i=0; i < numBuffers; ++i) {
- buf->parent = slab;
- buf->start = i* header->bufSize;
- buf->mapCount = 0;
- buf->isSlabBuffer = 1;
- pipe_condvar_init(buf->event);
- DRMLISTADDTAIL(&buf->head, &slab->freeBuffers);
- slab->numFree++;
- buf++;
- }
-
- DRMLISTADDTAIL(&slab->head, &header->slabs);
-
- return 0;
-
- out_err1:
- driSetKernelBOFree(header->slabPool->fMan, slab->kbo);
- free(slab->buffers);
- out_err0:
- free(slab);
- return ret;
-}
-
-/*
- * Delete a buffer from the slab header delayed list and put
- * it on the slab free list.
- */
-
-static void
-driSlabFreeBufferLocked(struct _DriSlabBuffer *buf)
-{
- struct _DriSlab *slab = buf->parent;
- struct _DriSlabSizeHeader *header = slab->header;
- drmMMListHead *list = &buf->head;
-
- DRMLISTDEL(list);
- DRMLISTADDTAIL(list, &slab->freeBuffers);
- slab->numFree++;
-
- if (slab->head.next == &slab->head)
- DRMLISTADDTAIL(&slab->head, &header->slabs);
-
- if (slab->numFree == slab->numBuffers) {
- list = &slab->head;
- DRMLISTDEL(list);
- DRMLISTADDTAIL(list, &header->freeSlabs);
- }
-
- if (header->slabs.next == &header->slabs ||
- slab->numFree != slab->numBuffers) {
-
- drmMMListHead *next;
- struct _DriFreeSlabManager *fMan = header->slabPool->fMan;
-
- for (list = header->freeSlabs.next, next = list->next;
- list != &header->freeSlabs;
- list = next, next = list->next) {
-
- slab = DRMLISTENTRY(struct _DriSlab, list, head);
-
- DRMLISTDELINIT(list);
- driSetKernelBOFree(fMan, slab->kbo);
- free(slab->buffers);
- free(slab);
- }
- }
-}
-
-static void
-driSlabCheckFreeLocked(struct _DriSlabSizeHeader *header, int wait)
-{
- drmMMListHead *list, *prev, *first;
- struct _DriSlabBuffer *buf;
- struct _DriSlab *slab;
- int firstWasSignaled = 1;
- int signaled;
- int i;
- int ret;
-
- /*
- * Rerun the freeing test if the youngest tested buffer
- * was signaled, since there might be more idle buffers
- * in the delay list.
- */
-
- while (firstWasSignaled) {
- firstWasSignaled = 0;
- signaled = 0;
- first = header->delayedBuffers.next;
-
- /* Only examine the oldest 1/3 of delayed buffers:
- */
- if (header->numDelayed > 3) {
- for (i = 0; i < header->numDelayed; i += 3) {
- first = first->next;
- }
- }
-
- for (list = first, prev = list->prev;
- list != &header->delayedBuffers;
- list = prev, prev = list->prev) {
- buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
- slab = buf->parent;
-
- if (!signaled) {
- if (wait) {
- ret = driFenceFinish(buf->fence, buf->fenceType, 0);
- if (ret)
- break;
- signaled = 1;
- wait = 0;
- } else {
- signaled = driFenceSignaled(buf->fence, buf->fenceType);
- }
- if (signaled) {
- if (list == first)
- firstWasSignaled = 1;
- driFenceUnReference(&buf->fence);
- header->numDelayed--;
- driSlabFreeBufferLocked(buf);
- }
- } else if (driFenceSignaledCached(buf->fence, buf->fenceType)) {
- driFenceUnReference(&buf->fence);
- header->numDelayed--;
- driSlabFreeBufferLocked(buf);
- }
- }
- }
-}
-
-
-static struct _DriSlabBuffer *
-driSlabAllocBuffer(struct _DriSlabSizeHeader *header)
-{
- static struct _DriSlabBuffer *buf;
- struct _DriSlab *slab;
- drmMMListHead *list;
- int count = DRI_SLABPOOL_ALLOC_RETRIES;
-
- pipe_mutex_lock(header->mutex);
- while(header->slabs.next == &header->slabs && count > 0) {
- driSlabCheckFreeLocked(header, 0);
- if (header->slabs.next != &header->slabs)
- break;
-
- pipe_mutex_unlock(header->mutex);
- if (count != DRI_SLABPOOL_ALLOC_RETRIES)
- usleep(1);
- pipe_mutex_lock(header->mutex);
- (void) driAllocSlab(header);
- count--;
- }
-
- list = header->slabs.next;
- if (list == &header->slabs) {
- pipe_mutex_unlock(header->mutex);
- return NULL;
- }
- slab = DRMLISTENTRY(struct _DriSlab, list, head);
- if (--slab->numFree == 0)
- DRMLISTDELINIT(list);
-
- list = slab->freeBuffers.next;
- DRMLISTDELINIT(list);
-
- pipe_mutex_unlock(header->mutex);
- buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
- return buf;
-}
-
-static void *
-pool_create(struct _DriBufferPool *driPool, unsigned long size,
- uint64_t flags, unsigned hint, unsigned alignment)
-{
- struct _DriSlabPool *pool = (struct _DriSlabPool *) driPool->data;
- struct _DriSlabSizeHeader *header;
- struct _DriSlabBuffer *buf;
- void *dummy;
- int i;
- int ret;
-
- /*
- * FIXME: Check for compatibility.
- */
-
- header = pool->headers;
- for (i=0; i<pool->numBuckets; ++i) {
- if (header->bufSize >= size)
- break;
- header++;
- }
-
- if (i < pool->numBuckets)
- return driSlabAllocBuffer(header);
-
-
- /*
- * Fall back to allocate a buffer object directly from DRM.
- * and wrap it in a driBO structure.
- */
-
-
- buf = calloc(1, sizeof(*buf));
-
- if (!buf)
- return NULL;
-
- buf->bo = calloc(1, sizeof(*buf->bo));
- if (!buf->bo)
- goto out_err0;
-
- if (alignment) {
- if ((alignment < pool->pageSize) && (pool->pageSize % alignment))
- goto out_err1;
- if ((alignment > pool->pageSize) && (alignment % pool->pageSize))
- goto out_err1;
- }
-
- ret = drmBOCreate(pool->fd, size, alignment / pool->pageSize, NULL,
- flags, hint, buf->bo);
- if (ret)
- goto out_err1;
-
- ret = drmBOMap(pool->fd, buf->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- 0, &dummy);
- if (ret)
- goto out_err2;
-
- ret = drmBOUnmap(pool->fd, buf->bo);
- if (ret)
- goto out_err2;
-
- return buf;
- out_err2:
- drmBOUnreference(pool->fd, buf->bo);
- out_err1:
- free(buf->bo);
- out_err0:
- free(buf);
- return NULL;
-}
-
-static int
-pool_destroy(struct _DriBufferPool *driPool, void *private)
-{
- struct _DriSlabBuffer *buf =
- (struct _DriSlabBuffer *) private;
- struct _DriSlab *slab;
- struct _DriSlabSizeHeader *header;
-
- if (!buf->isSlabBuffer) {
- struct _DriSlabPool *pool = (struct _DriSlabPool *) driPool->data;
- int ret;
-
- ret = drmBOUnreference(pool->fd, buf->bo);
- free(buf->bo);
- free(buf);
- return ret;
- }
-
- slab = buf->parent;
- header = slab->header;
-
- pipe_mutex_lock(header->mutex);
- buf->unFenced = 0;
- buf->mapCount = 0;
-
- if (buf->fence && !driFenceSignaledCached(buf->fence, buf->fenceType)) {
- DRMLISTADDTAIL(&buf->head, &header->delayedBuffers);
- header->numDelayed++;
- } else {
- if (buf->fence)
- driFenceUnReference(&buf->fence);
- driSlabFreeBufferLocked(buf);
- }
-
- pipe_mutex_unlock(header->mutex);
- return 0;
-}
-
-static int
-pool_waitIdle(struct _DriBufferPool *driPool, void *private,
- pipe_mutex *mutex, int lazy)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- while(buf->unFenced)
- pipe_condvar_wait(buf->event, *mutex);
-
- if (!buf->fence)
- return 0;
-
- driFenceFinish(buf->fence, buf->fenceType, lazy);
- driFenceUnReference(&buf->fence);
-
- return 0;
-}
-
-static int
-pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, pipe_mutex *mutex, void **virtual)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
- int busy;
-
- if (buf->isSlabBuffer)
- busy = buf->unFenced || (buf->fence && !driFenceSignaledCached(buf->fence, buf->fenceType));
- else
- busy = buf->fence && !driFenceSignaled(buf->fence, buf->fenceType);
-
-
- if (busy) {
- if (hint & DRM_BO_HINT_DONT_BLOCK)
- return -EBUSY;
- else {
- (void) pool_waitIdle(pool, private, mutex, 0);
- }
- }
-
- ++buf->mapCount;
- *virtual = (buf->isSlabBuffer) ?
- (void *) ((uint8_t *) buf->parent->kbo->virtual + buf->start) :
- (void *) buf->bo->virtual;
-
- return 0;
-}
-
-static int
-pool_unmap(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- --buf->mapCount;
- if (buf->mapCount == 0 && buf->isSlabBuffer)
- pipe_condvar_broadcast(buf->event);
-
- return 0;
-}
-
-static unsigned long
-pool_offset(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
- struct _DriSlab *slab;
- struct _DriSlabSizeHeader *header;
-
- if (!buf->isSlabBuffer) {
- assert(buf->bo->proposedFlags & DRM_BO_FLAG_NO_MOVE);
- return buf->bo->offset;
- }
-
- slab = buf->parent;
- header = slab->header;
-
- (void) header;
- assert(header->slabPool->proposedFlags & DRM_BO_FLAG_NO_MOVE);
- return slab->kbo->bo.offset + buf->start;
-}
-
-static unsigned long
-pool_poolOffset(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- return buf->start;
-}
-
-static uint64_t
-pool_flags(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- if (!buf->isSlabBuffer)
- return buf->bo->flags;
-
- return buf->parent->kbo->bo.flags;
-}
-
-static unsigned long
-pool_size(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
- if (!buf->isSlabBuffer)
- return buf->bo->size;
-
- return buf->parent->header->bufSize;
-}
-
-static int
-pool_fence(struct _DriBufferPool *pool, void *private,
- struct _DriFenceObject *fence)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
- drmBO *bo;
-
- if (buf->fence)
- driFenceUnReference(&buf->fence);
-
- buf->fence = driFenceReference(fence);
- bo = (buf->isSlabBuffer) ?
- &buf->parent->kbo->bo:
- buf->bo;
- buf->fenceType = bo->fenceFlags;
-
- buf->unFenced = 0;
- pipe_condvar_broadcast(buf->event);
-
- return 0;
-}
-
-static drmBO *
-pool_kernel(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- return (buf->isSlabBuffer) ? &buf->parent->kbo->bo : buf->bo;
-}
-
-static int
-pool_validate(struct _DriBufferPool *pool, void *private,
- pipe_mutex *mutex)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- if (!buf->isSlabBuffer)
- return 0;
-
- while(buf->mapCount != 0)
- pipe_condvar_wait(buf->event, *mutex);
-
- buf->unFenced = 1;
- return 0;
-}
-
-
-struct _DriFreeSlabManager *
-driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec)
-{
- struct _DriFreeSlabManager *tmp;
-
- tmp = calloc(1, sizeof(*tmp));
- if (!tmp)
- return NULL;
-
- pipe_mutex_init(tmp->mutex);
- pipe_mutex_lock(tmp->mutex);
- tmp->slabTimeout.tv_usec = slabTimeoutMsec*1000;
- tmp->slabTimeout.tv_sec = tmp->slabTimeout.tv_usec / 1000000;
- tmp->slabTimeout.tv_usec -= tmp->slabTimeout.tv_sec*1000000;
-
- tmp->checkInterval.tv_usec = checkIntervalMsec*1000;
- tmp->checkInterval.tv_sec = tmp->checkInterval.tv_usec / 1000000;
- tmp->checkInterval.tv_usec -= tmp->checkInterval.tv_sec*1000000;
-
- gettimeofday(&tmp->nextCheck, NULL);
- driTimeAdd(&tmp->nextCheck, &tmp->checkInterval);
- DRMINITLISTHEAD(&tmp->timeoutList);
- DRMINITLISTHEAD(&tmp->unCached);
- DRMINITLISTHEAD(&tmp->cached);
- pipe_mutex_unlock(tmp->mutex);
-
- return tmp;
-}
-
-void
-driFinishFreeSlabManager(struct _DriFreeSlabManager *fMan)
-{
- struct timeval time;
-
- time = fMan->nextCheck;
- driTimeAdd(&time, &fMan->checkInterval);
-
- pipe_mutex_lock(fMan->mutex);
- driFreeTimeoutKBOsLocked(fMan, &time);
- pipe_mutex_unlock(fMan->mutex);
-
- assert(fMan->timeoutList.next == &fMan->timeoutList);
- assert(fMan->unCached.next == &fMan->unCached);
- assert(fMan->cached.next == &fMan->cached);
-
- free(fMan);
-}
-
-static void
-driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
- struct _DriSlabSizeHeader *header)
-{
- pipe_mutex_init(header->mutex);
- pipe_mutex_lock(header->mutex);
-
- DRMINITLISTHEAD(&header->slabs);
- DRMINITLISTHEAD(&header->freeSlabs);
- DRMINITLISTHEAD(&header->delayedBuffers);
-
- header->numDelayed = 0;
- header->slabPool = pool;
- header->bufSize = size;
-
- pipe_mutex_unlock(header->mutex);
-}
-
-static void
-driFinishSizeHeader(struct _DriSlabSizeHeader *header)
-{
- drmMMListHead *list, *next;
- struct _DriSlabBuffer *buf;
-
- pipe_mutex_lock(header->mutex);
- for (list = header->delayedBuffers.next, next = list->next;
- list != &header->delayedBuffers;
- list = next, next = list->next) {
-
- buf = DRMLISTENTRY(struct _DriSlabBuffer, list , head);
- if (buf->fence) {
- (void) driFenceFinish(buf->fence, buf->fenceType, 0);
- driFenceUnReference(&buf->fence);
- }
- header->numDelayed--;
- driSlabFreeBufferLocked(buf);
- }
- pipe_mutex_unlock(header->mutex);
-}
-
-static void
-pool_takedown(struct _DriBufferPool *driPool)
-{
- struct _DriSlabPool *pool = driPool->data;
- int i;
-
- for (i=0; i<pool->numBuckets; ++i) {
- driFinishSizeHeader(&pool->headers[i]);
- }
-
- free(pool->headers);
- free(pool->bucketSizes);
- free(pool);
- free(driPool);
-}
-
-struct _DriBufferPool *
-driSlabPoolInit(int fd, uint64_t flags,
- uint64_t validMask,
- uint32_t smallestSize,
- uint32_t numSizes,
- uint32_t desiredNumBuffers,
- uint32_t maxSlabSize,
- uint32_t pageAlignment,
- struct _DriFreeSlabManager *fMan)
-{
- struct _DriBufferPool *driPool;
- struct _DriSlabPool *pool;
- uint32_t i;
-
- driPool = calloc(1, sizeof(*driPool));
- if (!driPool)
- return NULL;
-
- pool = calloc(1, sizeof(*pool));
- if (!pool)
- goto out_err0;
-
- pool->bucketSizes = calloc(numSizes, sizeof(*pool->bucketSizes));
- if (!pool->bucketSizes)
- goto out_err1;
-
- pool->headers = calloc(numSizes, sizeof(*pool->headers));
- if (!pool->headers)
- goto out_err2;
-
- pool->fMan = fMan;
- pool->proposedFlags = flags;
- pool->validMask = validMask;
- pool->numBuckets = numSizes;
- pool->pageSize = getpagesize();
- pool->fd = fd;
- pool->pageAlignment = pageAlignment;
- pool->maxSlabSize = maxSlabSize;
- pool->desiredNumBuffers = desiredNumBuffers;
-
- for (i=0; i<pool->numBuckets; ++i) {
- pool->bucketSizes[i] = (smallestSize << i);
- driInitSizeHeader(pool, pool->bucketSizes[i],
- &pool->headers[i]);
- }
-
- driPool->data = (void *) pool;
- driPool->map = &pool_map;
- driPool->unmap = &pool_unmap;
- driPool->destroy = &pool_destroy;
- driPool->offset = &pool_offset;
- driPool->poolOffset = &pool_poolOffset;
- driPool->flags = &pool_flags;
- driPool->size = &pool_size;
- driPool->create = &pool_create;
- driPool->fence = &pool_fence;
- driPool->kernel = &pool_kernel;
- driPool->validate = &pool_validate;
- driPool->waitIdle = &pool_waitIdle;
- driPool->takeDown = &pool_takedown;
-
- return driPool;
-
- out_err2:
- free(pool->bucketSizes);
- out_err1:
- free(pool);
- out_err0:
- free(driPool);
-
- return NULL;
-}
diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile
deleted file mode 100644
index 2046441a22..0000000000
--- a/src/gallium/winsys/drm/intel/dri/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i915_dri.so
-LIBNAME_EGL = egl_i915_dri.so
-
-PIPE_DRIVERS = \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- ../common/libinteldrm.a \
- $(TOP)/src/gallium/drivers/i915simple/libi915simple.a
-
-
-DRIVER_SOURCES = \
- intel_winsys_softpipe.c \
- intel_swapbuffers.c \
- intel_context.c \
- intel_lock.c \
- intel_screen.c
-
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I../common $(shell pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-
-include ../../Makefile.template
-
-#intel_tex_layout.o: $(TOP)/src/mesa/drivers/dri/intel/intel_tex_layout.c
-
-symlinks:
diff --git a/src/gallium/winsys/drm/intel/dri/SConscript b/src/gallium/winsys/drm/intel/dri/SConscript
deleted file mode 100644
index 6a4f50afcc..0000000000
--- a/src/gallium/winsys/drm/intel/dri/SConscript
+++ /dev/null
@@ -1,41 +0,0 @@
-Import('*')
-
-if 'mesa' in env['statetrackers']:
-
- env = drienv.Clone()
-
- env.Append(CPPPATH = [
- '../intel',
- 'server'
- ])
-
- #MINIGLX_SOURCES = server/intel_dri.c
-
- DRIVER_SOURCES = [
- 'intel_winsys_pipe.c',
- 'intel_winsys_softpipe.c',
- 'intel_winsys_i915.c',
- 'intel_batchbuffer.c',
- 'intel_swapbuffers.c',
- 'intel_context.c',
- 'intel_lock.c',
- 'intel_screen.c',
- 'intel_batchpool.c',
- ]
-
- sources = \
- COMMON_GALLIUM_SOURCES + \
- COMMON_BM_SOURCES + \
- DRIVER_SOURCES
-
- drivers = [
- softpipe,
- i915simple
- ]
-
- # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
- env.SharedLibrary(
- target ='i915tex_dri.so',
- source = sources,
- LIBS = drivers + mesa + auxiliaries + env['LIBS'],
- )
diff --git a/src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h b/src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h
deleted file mode 100644
index 3e95326168..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef INTEL_BATCHBUFFER_H
-#define INTEL_BATCHBUFFER_H
-
-#include "intel_be_batchbuffer.h"
-
-/*
- * Need to redefine the BATCH defines
- */
-
-#undef BEGIN_BATCH
-#define BEGIN_BATCH(dwords, relocs) \
- (i915_batchbuffer_check(&intel->base.batch->base, dwords, relocs))
-
-#undef OUT_BATCH
-#define OUT_BATCH(d) \
- i915_batchbuffer_dword(&intel->base.batch->base, d)
-
-#undef OUT_RELOC
-#define OUT_RELOC(buf,flags,mask,delta) do { \
- assert((delta) >= 0); \
- intel_be_offset_relocation(intel->base.batch, delta, buf, flags, mask); \
-} while (0)
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/intel_context.c b/src/gallium/winsys/drm/intel/dri/intel_context.c
deleted file mode 100644
index 97ef731aaa..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_context.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "i830_dri.h"
-
-#include "intel_screen.h"
-#include "intel_context.h"
-#include "intel_swapbuffers.h"
-#include "intel_batchbuffer.h"
-#include "intel_winsys_softpipe.h"
-
-#include "i915simple/i915_screen.h"
-
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_context.h"
-
-#include "utils.h"
-
-
-#ifdef DEBUG
-int __intel_debug = 0;
-#endif
-
-
-#define need_GL_ARB_multisample
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_window_pos
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_equation_separate
-#define need_GL_EXT_blend_func_separate
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_cull_vertex
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_multi_draw_arrays
-#define need_GL_EXT_secondary_color
-#define need_GL_NV_vertex_program
-#include "extension_helper.h"
-
-
-/**
- * Extension strings exported by the intel driver.
- *
- * \note
- * It appears that ARB_texture_env_crossbar has "disappeared" compared to the
- * old i830-specific driver.
- */
-const struct dri_extension card_extensions[] = {
- {"GL_ARB_multisample", GL_ARB_multisample_functions},
- {"GL_ARB_multitexture", NULL},
- {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
- {"GL_ARB_texture_border_clamp", NULL},
- {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
- {"GL_ARB_texture_cube_map", NULL},
- {"GL_ARB_texture_env_add", NULL},
- {"GL_ARB_texture_env_combine", NULL},
- {"GL_ARB_texture_env_dot3", NULL},
- {"GL_ARB_texture_mirrored_repeat", NULL},
- {"GL_ARB_texture_rectangle", NULL},
- {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
- {"GL_ARB_pixel_buffer_object", NULL},
- {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
- {"GL_ARB_window_pos", GL_ARB_window_pos_functions},
- {"GL_EXT_blend_color", GL_EXT_blend_color_functions},
- {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
- {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
- {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
- {"GL_EXT_blend_subtract", NULL},
- {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
- {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
- {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
- {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
- {"GL_EXT_packed_depth_stencil", NULL},
- {"GL_EXT_pixel_buffer_object", NULL},
- {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
- {"GL_EXT_stencil_wrap", NULL},
- {"GL_EXT_texture_edge_clamp", NULL},
- {"GL_EXT_texture_env_combine", NULL},
- {"GL_EXT_texture_env_dot3", NULL},
- {"GL_EXT_texture_filter_anisotropic", NULL},
- {"GL_EXT_texture_lod_bias", NULL},
- {"GL_3DFX_texture_compression_FXT1", NULL},
- {"GL_APPLE_client_storage", NULL},
- {"GL_MESA_pack_invert", NULL},
- {"GL_MESA_ycbcr_texture", NULL},
- {"GL_NV_blend_square", NULL},
- {"GL_NV_vertex_program", GL_NV_vertex_program_functions},
- {"GL_NV_vertex_program1_1", NULL},
- {"GL_SGIS_generate_mipmap", NULL },
- {NULL, NULL}
-};
-
-
-
-#ifdef DEBUG
-static const struct dri_debug_control debug_control[] = {
- {"ioctl", DEBUG_IOCTL},
- {"bat", DEBUG_BATCH},
- {"lock", DEBUG_LOCK},
- {"swap", DEBUG_SWAP},
- {NULL, 0}
-};
-#endif
-
-
-
-static void
-intel_lock_hardware(struct intel_be_context *context)
-{
- struct intel_context *intel = (struct intel_context *)context;
- LOCK_HARDWARE(intel);
-}
-
-static void
-intel_unlock_hardware(struct intel_be_context *context)
-{
- struct intel_context *intel = (struct intel_context *)context;
- UNLOCK_HARDWARE(intel);
-}
-
-static boolean
-intel_locked_hardware(struct intel_be_context *context)
-{
- struct intel_context *intel = (struct intel_context *)context;
- return intel->locked ? TRUE : FALSE;
-}
-
-GLboolean
-intelCreateContext(const __GLcontextModes * visual,
- __DRIcontextPrivate * driContextPriv,
- void *sharedContextPrivate)
-{
- struct intel_context *intel = CALLOC_STRUCT(intel_context);
- __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
- struct intel_screen *intelScreen = intel_screen(sPriv);
- drmI830Sarea *saPriv = intelScreen->sarea;
- int fthrottle_mode;
- GLboolean havePools;
- struct pipe_context *pipe;
- struct st_context *st_share = NULL;
-
- if (sharedContextPrivate) {
- st_share = ((struct intel_context *) sharedContextPrivate)->st;
- }
-
- driContextPriv->driverPrivate = intel;
- intel->intelScreen = intelScreen;
- intel->driScreen = sPriv;
- intel->sarea = saPriv;
-
- driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
- intel->driScreen->myNum, "i915");
-
-
- /*
- * memory pools
- */
- DRM_LIGHT_LOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
- // ZZZ JB should be per screen and not be done per context
- havePools = intelCreatePools(sPriv);
- DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
- if (!havePools)
- return GL_FALSE;
-
-
- /* Dri stuff */
- intel->hHWContext = driContextPriv->hHWContext;
- intel->driFd = sPriv->fd;
- intel->driHwLock = (drmLock *) & sPriv->pSAREA->lock;
-
- fthrottle_mode = driQueryOptioni(&intel->optionCache, "fthrottle_mode");
- intel->iw.irq_seq = -1;
- intel->irqsEmitted = 0;
-
- intel->last_swap_fence = NULL;
- intel->first_swap_fence = NULL;
-
-#ifdef DEBUG
- __intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
-#endif
- intel->base.hardware_lock = intel_lock_hardware;
- intel->base.hardware_unlock = intel_unlock_hardware;
- intel->base.hardware_locked = intel_locked_hardware;
-
- intel_be_init_context(&intel->base, &intelScreen->base);
-
- /*
- * Pipe-related setup
- */
- if (getenv("INTEL_SP")) {
- /* use softpipe driver instead of hw */
- pipe = intel_create_softpipe( intel, &intelScreen->base.base );
- }
- else {
- switch (intel->intelScreen->deviceID) {
- case PCI_CHIP_I945_G:
- case PCI_CHIP_I945_GM:
- case PCI_CHIP_I945_GME:
- case PCI_CHIP_G33_G:
- case PCI_CHIP_Q33_G:
- case PCI_CHIP_Q35_G:
- case PCI_CHIP_I915_G:
- case PCI_CHIP_I915_GM:
- pipe = i915_create_context(intelScreen->base.screen,
- &intelScreen->base.base,
- &intel->base.base);
- break;
- default:
- fprintf(stderr, "Unknown PCIID %x in %s, using software driver\n",
- intel->intelScreen->deviceID, __FUNCTION__);
-
- pipe = intel_create_softpipe( intel, &intelScreen->base.base );
- break;
- }
- }
-
- pipe->priv = intel;
-
- intel->st = st_create_context(pipe, visual, st_share);
-
- driInitExtensions( intel->st->ctx, card_extensions, GL_TRUE );
-
- return GL_TRUE;
-}
-
-
-void
-intelDestroyContext(__DRIcontextPrivate * driContextPriv)
-{
- struct intel_context *intel = intel_context(driContextPriv);
-
- assert(intel); /* should never be null */
- if (intel) {
- st_finish(intel->st);
-
- if (intel->last_swap_fence) {
- driFenceFinish(intel->last_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
- driFenceUnReference(&intel->last_swap_fence);
- intel->last_swap_fence = NULL;
- }
- if (intel->first_swap_fence) {
- driFenceFinish(intel->first_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
- driFenceUnReference(&intel->first_swap_fence);
- intel->first_swap_fence = NULL;
- }
-
- if (intel->intelScreen->dummyContext == intel)
- intel->intelScreen->dummyContext = NULL;
-
- st_destroy_context(intel->st);
- intel_be_destroy_context(&intel->base);
- free(intel);
- }
-}
-
-
-GLboolean
-intelUnbindContext(__DRIcontextPrivate * driContextPriv)
-{
- struct intel_context *intel = intel_context(driContextPriv);
- st_flush(intel->st, PIPE_FLUSH_RENDER_CACHE, NULL);
- /* XXX make_current(NULL)? */
- return GL_TRUE;
-}
-
-
-GLboolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv)
-{
- if (driContextPriv) {
- struct intel_context *intel = intel_context(driContextPriv);
- struct intel_framebuffer *draw_fb = intel_framebuffer(driDrawPriv);
- struct intel_framebuffer *read_fb = intel_framebuffer(driReadPriv);
-
- assert(draw_fb->stfb);
- assert(read_fb->stfb);
-
- /* This is for situations in which we need a rendering context but
- * there may not be any currently bound.
- */
- intel->intelScreen->dummyContext = intel;
-
- st_make_current(intel->st, draw_fb->stfb, read_fb->stfb);
-
- if ((intel->driDrawable != driDrawPriv) ||
- (intel->lastStamp != driDrawPriv->lastStamp)) {
- intel->driDrawable = driDrawPriv;
- intelUpdateWindowSize(driDrawPriv);
- intel->lastStamp = driDrawPriv->lastStamp;
- }
-
- /* The size of the draw buffer will have been updated above.
- * If the readbuffer is a different window, check/update its size now.
- */
- if (driReadPriv != driDrawPriv) {
- intelUpdateWindowSize(driReadPriv);
- }
-
- }
- else {
- st_make_current(NULL, NULL, NULL);
- }
-
- return GL_TRUE;
-}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_context.h b/src/gallium/winsys/drm/intel/dri/intel_context.h
deleted file mode 100644
index 5d22a422af..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_context.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_CONTEXT_H
-#define INTEL_CONTEXT_H
-
-#include <stdint.h>
-#include "drm.h"
-
-#include "pipe/p_debug.h"
-
-#include "intel_screen.h"
-#include "i915_drm.h"
-
-#include "intel_be_context.h"
-
-
-struct pipe_context;
-struct intel_context;
-struct _DriBufferObject;
-struct st_context;
-
-
-#define INTEL_MAX_FIXUP 64
-
-/**
- * Intel rendering context, contains a state tracker and intel-specific info.
- */
-struct intel_context
-{
- struct intel_be_context base;
- struct st_context *st;
-
- struct _DriFenceObject *last_swap_fence;
- struct _DriFenceObject *first_swap_fence;
-
-// struct intel_batchbuffer *batch;
-
- boolean locked;
- char *prevLockFile;
- int prevLockLine;
-
- uint irqsEmitted;
- drm_i915_irq_wait_t iw;
-
- drm_context_t hHWContext;
- drmLock *driHwLock;
- int driFd;
-
- __DRIdrawablePrivate *driDrawable;
- __DRIscreenPrivate *driScreen;
- struct intel_screen *intelScreen;
- drmI830Sarea *sarea;
-
- uint lastStamp;
-
- /**
- * Configuration cache
- */
- driOptionCache optionCache;
-};
-
-
-
-/**
- * Intel framebuffer.
- */
-struct intel_framebuffer
-{
- struct st_framebuffer *stfb;
-
- /* other fields TBD */
- int other;
-};
-
-
-
-
-/* These are functions now:
- */
-void LOCK_HARDWARE( struct intel_context *intel );
-void UNLOCK_HARDWARE( struct intel_context *intel );
-
-extern char *__progname;
-
-
-
-/* ================================================================
- * Debugging:
- */
-#ifdef DEBUG
-extern int __intel_debug;
-
-#define DEBUG_SWAP 0x1
-#define DEBUG_LOCK 0x2
-#define DEBUG_IOCTL 0x4
-#define DEBUG_BATCH 0x8
-
-#define DBG(flag, ...) do { \
- if (__intel_debug & (DEBUG_##flag)) \
- printf(__VA_ARGS__); \
-} while(0)
-
-#else
-#define DBG(flag, ...)
-#endif
-
-
-
-#define PCI_CHIP_845_G 0x2562
-#define PCI_CHIP_I830_M 0x3577
-#define PCI_CHIP_I855_GM 0x3582
-#define PCI_CHIP_I865_G 0x2572
-#define PCI_CHIP_I915_G 0x2582
-#define PCI_CHIP_I915_GM 0x2592
-#define PCI_CHIP_I945_G 0x2772
-#define PCI_CHIP_I945_GM 0x27A2
-#define PCI_CHIP_I945_GME 0x27AE
-#define PCI_CHIP_G33_G 0x29C2
-#define PCI_CHIP_Q35_G 0x29B2
-#define PCI_CHIP_Q33_G 0x29D2
-
-
-/** Cast wrapper */
-static INLINE struct intel_context *
-intel_context(__DRIcontextPrivate *driContextPriv)
-{
- return (struct intel_context *) driContextPriv->driverPrivate;
-}
-
-
-/** Cast wrapper */
-static INLINE struct intel_framebuffer *
-intel_framebuffer(__DRIdrawablePrivate * driDrawPriv)
-{
- return (struct intel_framebuffer *) driDrawPriv->driverPrivate;
-}
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/intel_lock.c b/src/gallium/winsys/drm/intel/dri/intel_lock.c
deleted file mode 100644
index ad1c202429..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_lock.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "main/glheader.h"
-#include "pipe/p_thread.h"
-#include <GL/internal/glcore.h>
-#include "state_tracker/st_public.h"
-#include "intel_context.h"
-#include "i830_dri.h"
-
-
-
-pipe_static_mutex( lockMutex );
-
-
-static void
-intelContendedLock(struct intel_context *intel, uint flags)
-{
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
- __DRIscreenPrivate *sPriv = intel->driScreen;
- struct intel_screen *intelScreen = intel_screen(sPriv);
- drmI830Sarea *sarea = intel->sarea;
-
- drmGetLock(intel->driFd, intel->hHWContext, flags);
-
- DBG(LOCK, "%s - got contended lock\n", __progname);
-
- /* If the window moved, may need to set a new cliprect now.
- *
- * NOTE: This releases and regains the hw lock, so all state
- * checking must be done *after* this call:
- */
- if (dPriv)
- DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
-
- if (sarea->width != intelScreen->front.width ||
- sarea->height != intelScreen->front.height) {
-
- intelUpdateScreenRotation(sPriv, sarea);
- }
-}
-
-
-/* Lock the hardware and validate our state.
- */
-void LOCK_HARDWARE( struct intel_context *intel )
-{
- char __ret = 0;
-
- pipe_mutex_lock(lockMutex);
- assert(!intel->locked);
-
- DRM_CAS(intel->driHwLock, intel->hHWContext,
- (DRM_LOCK_HELD|intel->hHWContext), __ret);
-
- if (__ret)
- intelContendedLock( intel, 0 );
-
- DBG(LOCK, "%s - locked\n", __progname);
-
- intel->locked = 1;
-}
-
-
-/* Unlock the hardware using the global current context
- */
-void UNLOCK_HARDWARE( struct intel_context *intel )
-{
- assert(intel->locked);
- intel->locked = 0;
-
- DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
-
- pipe_mutex_unlock(lockMutex);
-
- DBG(LOCK, "%s - unlocked\n", __progname);
-}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_screen.c b/src/gallium/winsys/drm/intel/dri/intel_screen.c
deleted file mode 100644
index ed75368982..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_screen.c
+++ /dev/null
@@ -1,703 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "utils.h"
-#include "vblank.h"
-#include "xmlpool.h"
-
-#include "intel_context.h"
-#include "intel_screen.h"
-#include "intel_batchbuffer.h"
-#include "intel_swapbuffers.h"
-
-#include "i830_dri.h"
-#include "ws_dri_bufpool.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_screen.h"
-#include "pipe/p_inlines.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_cb_fbo.h"
-
-static void
-intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys, unsigned handle);
-
-static void
-intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys, unsigned handle)
-{
- struct pipe_screen *screen = intelScreen->base.screen;
- struct pipe_texture *texture;
- struct pipe_texture templat;
- struct pipe_surface *surface;
- struct pipe_buffer *buffer;
- unsigned pitch;
-
- assert(intelScreen->front.cpp == 4);
-
- buffer = intel_be_buffer_from_handle(&intelScreen->base,
- "front", handle);
-
- if (!buffer)
- return;
-
- intelScreen->front.buffer = dri_bo(buffer);
-
- memset(&templat, 0, sizeof(templat));
- templat.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
- templat.target = PIPE_TEXTURE_2D;
- templat.last_level = 0;
- templat.depth[0] = 1;
- templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
- templat.width[0] = intelScreen->front.width;
- templat.height[0] = intelScreen->front.height;
- pf_get_block(templat.format, &templat.block);
- pitch = intelScreen->front.pitch;
-
- texture = screen->texture_blanket(screen,
- &templat,
- &pitch,
- buffer);
-
- /* Unref the buffer we don't need it anyways */
- pipe_buffer_reference(screen, &buffer, NULL);
-
- surface = screen->get_tex_surface(screen,
- texture,
- 0,
- 0,
- 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
- intelScreen->front.texture = texture;
- intelScreen->front.surface = surface;
-}
-
-PUBLIC const char __driConfigOptions[] =
- DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
- DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
- DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
- DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
-// DRI_CONF_FORCE_S3TC_ENABLE(false)
- DRI_CONF_ALLOW_LARGE_TEXTURES(1)
- DRI_CONF_SECTION_END DRI_CONF_END;
-
-const uint __driNConfigOptions = 3;
-
-#ifdef USE_NEW_INTERFACE
-static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
-#endif /*USE_NEW_INTERFACE */
-
-extern const struct dri_extension card_extensions[];
-
-static GLboolean
-intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
-{
- int ret;
- struct drm_i915_getparam gp;
-
- gp.param = param;
- gp.value = value;
-
- ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
- if (ret) {
- fprintf(stderr, "drm_i915_getparam: %d\n", ret);
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-static void
-intelSetTexOffset(__DRIcontext *pDRICtx, int texname,
- unsigned long long offset, int depth, uint pitch)
-{
- abort();
-#if 0
- struct intel_context *intel = (struct intel_context*)
- ((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
- struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
- struct st_texture_object *stObj = st_texture_object(tObj);
-
- if (!stObj)
- return;
-
- if (stObj->pt)
- st->pipe->texture_release(intel->st->pipe, &stObj->pt);
-
- stObj->imageOverride = GL_TRUE;
- stObj->depthOverride = depth;
- stObj->pitchOverride = pitch;
-
- if (offset)
- stObj->textureOffset = offset;
-#endif
-}
-
-
-#if 0
-static void
-intelHandleDrawableConfig(__DRIdrawablePrivate *dPriv,
- __DRIcontextPrivate *pcp,
- __DRIDrawableConfigEvent *event)
-{
- (void) dPriv;
- (void) pcp;
- (void) event;
-}
-#endif
-
-#if 0
-static void
-intelHandleBufferAttach(__DRIdrawablePrivate *dPriv,
- __DRIcontextPrivate *pcp,
- __DRIBufferAttachEvent *ba)
-{
- struct intel_screen *intelScreen = intel_screen(dPriv->driScreenPriv);
-
- switch (ba->buffer.attachment) {
- case DRI_DRAWABLE_BUFFER_FRONT_LEFT:
- intelScreen->front.width = dPriv->w;
- intelScreen->front.height = dPriv->h;
- intelScreen->front.cpp = ba->buffer.cpp;
- intelScreen->front.pitch = ba->buffer.pitch;
- driGenBuffers(intelScreen->base.staticPool, "front", 1, &intelScreen->front.buffer, 0, 0, 0);
- driBOSetReferenced(intelScreen->front.buffer, ba->buffer.handle);
- break;
-
- case DRI_DRAWABLE_BUFFER_BACK_LEFT:
- case DRI_DRAWABLE_BUFFER_DEPTH:
- case DRI_DRAWABLE_BUFFER_STENCIL:
- case DRI_DRAWABLE_BUFFER_ACCUM:
- /* anything ?? */
- break;
-
- default:
- fprintf(stderr, "unhandled buffer attach event, attachment type %d\n",
- ba->buffer.attachment);
- return;
- }
-}
-#endif
-
-static const __DRItexOffsetExtension intelTexOffsetExtension = {
- { __DRI_TEX_OFFSET },
- intelSetTexOffset,
-};
-
-#if 0
-static const __DRItexBufferExtension intelTexBufferExtension = {
- { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
- intelSetTexBuffer,
-};
-#endif
-
-static const __DRIextension *intelScreenExtensions[] = {
- &driReadDrawableExtension,
- &driCopySubBufferExtension.base,
- &driSwapControlExtension.base,
- &driFrameTrackingExtension.base,
- &driMediaStreamCounterExtension.base,
- &intelTexOffsetExtension.base,
-// &intelTexBufferExtension.base,
- NULL
-};
-
-
-static void
-intelPrintDRIInfo(struct intel_screen * intelScreen,
- __DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv)
-{
- fprintf(stderr, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
- intelScreen->front.size, intelScreen->front.offset,
- intelScreen->front.pitch);
- fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem);
-}
-
-
-#if 0
-static void
-intelPrintSAREA(const drmI830Sarea * sarea)
-{
- fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width,
- sarea->height);
- fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch);
- fprintf(stderr,
- "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->front_offset, sarea->front_size,
- (unsigned) sarea->front_handle);
- fprintf(stderr,
- "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->back_offset, sarea->back_size,
- (unsigned) sarea->back_handle);
- fprintf(stderr, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->depth_offset, sarea->depth_size,
- (unsigned) sarea->depth_handle);
- fprintf(stderr, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle);
- fprintf(stderr, "SAREA: rotation: %d\n", sarea->rotation);
- fprintf(stderr,
- "SAREA: rotated offset: 0x%08x size: 0x%x\n",
- sarea->rotated_offset, sarea->rotated_size);
- fprintf(stderr, "SAREA: rotated pitch: %d\n", sarea->rotated_pitch);
-}
-#endif
-
-
-/**
- * Use the information in the sarea to update the screen parameters
- * related to screen rotation. Needs to be called locked.
- */
-void
-intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea)
-{
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- if (intelScreen->front.map) {
- drmUnmap(intelScreen->front.map, intelScreen->front.size);
- intelScreen->front.map = NULL;
- }
-
- if (intelScreen->front.buffer)
- driDeleteBuffers(1, &intelScreen->front.buffer);
-
- intelScreen->front.width = sarea->width;
- intelScreen->front.height = sarea->height;
- intelScreen->front.offset = sarea->front_offset;
- intelScreen->front.pitch = sarea->pitch * intelScreen->front.cpp;
- intelScreen->front.size = sarea->front_size;
- intelScreen->front.handle = sarea->front_handle;
-
- assert( sarea->front_size >=
- intelScreen->front.pitch * intelScreen->front.height );
-
-#if 0 /* JB not important */
- if (!sarea->front_handle)
- return;
-
- if (drmMap(sPriv->fd,
- sarea->front_handle,
- intelScreen->front.size,
- (drmAddress *) & intelScreen->front.map) != 0) {
- fprintf(stderr, "drmMap(frontbuffer) failed!\n");
- return;
- }
-#endif
-
-#if 0 /* JB */
- if (intelScreen->staticPool) {
- driGenBuffers(intelScreen->staticPool, "static region", 1,
- &intelScreen->front.buffer, 64,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_NO_MOVE |
- DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0);
-
- driBOSetStatic(intelScreen->front.buffer,
- intelScreen->front.offset,
- intelScreen->front.pitch * intelScreen->front.height,
- intelScreen->front.map, 0);
- }
-#else
- if (intelScreen->base.staticPool) {
- if (intelScreen->front.buffer) {
- driBOUnReference(intelScreen->front.buffer);
- pipe_surface_reference(&intelScreen->front.surface, NULL);
- pipe_texture_reference(&intelScreen->front.texture, NULL);
- }
- intelCreateSurface(intelScreen, &intelScreen->base.base, sarea->front_bo_handle);
- }
-#endif
-}
-
-
-boolean
-intelCreatePools(__DRIscreenPrivate * sPriv)
-{
- //unsigned batchPoolSize = 1024*1024;
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- if (intelScreen->havePools)
- return GL_TRUE;
-
- intelScreen->havePools = GL_TRUE;
-
- if (intelScreen->sarea)
- intelUpdateScreenRotation(sPriv, intelScreen->sarea);
-
- return GL_TRUE;
-}
-
-static const char *
-intel_get_name( struct pipe_winsys *winsys )
-{
- return "Intel/DRI/ttm";
-}
-
-/*
- * The state tracker (should!) keep track of whether the fake
- * frontbuffer has been touched by any rendering since the last time
- * we copied its contents to the real frontbuffer. Our task is easy:
- */
-static void
-intel_flush_frontbuffer( struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
-{
- struct intel_context *intel = (struct intel_context *) context_private;
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
-
- intelDisplaySurface(dPriv, surf, NULL);
-}
-
-static boolean
-intelInitDriver(__DRIscreenPrivate * sPriv)
-{
- struct intel_screen *intelScreen;
- I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
-
- if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
- fprintf(stderr,
- "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
- return GL_FALSE;
- }
-
- /* Allocate the private area */
- intelScreen = CALLOC_STRUCT(intel_screen);
- if (!intelScreen)
- return GL_FALSE;
-
- /* parse information in __driConfigOptions */
- driParseOptionInfo(&intelScreen->optionCache,
- __driConfigOptions, __driNConfigOptions);
-
- sPriv->private = (void *) intelScreen;
- intelScreen->sarea = (drmI830Sarea *) (((GLubyte *) sPriv->pSAREA) +
- gDRIPriv->sarea_priv_offset);
-
- intelScreen->deviceID = gDRIPriv->deviceID;
-
- intelScreen->front.cpp = gDRIPriv->cpp;
- intelScreen->drmMinor = sPriv->drm_version.minor;
- intelUpdateScreenRotation(sPriv, intelScreen->sarea);
-
- if (0)
- intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
-
- sPriv->extensions = intelScreenExtensions;
-
- intelScreen->base.base.flush_frontbuffer = intel_flush_frontbuffer;
- intelScreen->base.base.get_name = intel_get_name;
- intel_be_init_device(&intelScreen->base, sPriv->fd, intelScreen->deviceID);
-
- return GL_TRUE;
-}
-
-
-static void
-intelDestroyScreen(__DRIscreenPrivate * sPriv)
-{
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- intel_be_destroy_device(&intelScreen->base);
- /* intelUnmapScreenRegions(intelScreen); */
-
- FREE(intelScreen);
- sPriv->private = NULL;
-}
-
-
-/**
- * This is called when we need to set up GL rendering to a new X window.
- */
-static boolean
-intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
- __DRIdrawablePrivate * driDrawPriv,
- const __GLcontextModes * visual, boolean isPixmap)
-{
- if (isPixmap) {
- return GL_FALSE; /* not implemented */
- }
- else {
- enum pipe_format colorFormat, depthFormat, stencilFormat;
- struct intel_framebuffer *intelfb = CALLOC_STRUCT(intel_framebuffer);
-
- if (!intelfb)
- return GL_FALSE;
-
- if (visual->redBits == 5)
- colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
- else
- colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
-
- if (visual->depthBits == 16)
- depthFormat = PIPE_FORMAT_Z16_UNORM;
- else if (visual->depthBits == 24)
- depthFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
- depthFormat = PIPE_FORMAT_NONE;
-
- if (visual->stencilBits == 8)
- stencilFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
- stencilFormat = PIPE_FORMAT_NONE;
-
- intelfb->stfb = st_create_framebuffer(visual,
- colorFormat,
- depthFormat,
- stencilFormat,
- driDrawPriv->w,
- driDrawPriv->h,
- (void*) intelfb);
- if (!intelfb->stfb) {
- free(intelfb);
- return GL_FALSE;
- }
-
- driDrawPriv->driverPrivate = (void *) intelfb;
- return GL_TRUE;
- }
-}
-
-static void
-intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
-{
- struct intel_framebuffer *intelfb = intel_framebuffer(driDrawPriv);
- assert(intelfb->stfb);
- st_unreference_framebuffer(intelfb->stfb);
- free(intelfb);
-}
-
-
-/**
- * Get information about previous buffer swaps.
- */
-static int
-intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
-{
- if ((dPriv == NULL) || (dPriv->driverPrivate == NULL)
- || (sInfo == NULL)) {
- return -1;
- }
-
- return 0;
-}
-
-static __DRIconfig **
-intelFillInModes(__DRIscreenPrivate *psp,
- unsigned pixel_bits, unsigned depth_bits,
- unsigned stencil_bits, GLboolean have_back_buffer)
-{
- __DRIconfig **configs;
- __GLcontextModes *m;
- unsigned num_modes;
- unsigned depth_buffer_factor;
- unsigned back_buffer_factor;
- GLenum fb_format;
- GLenum fb_type;
- int i;
-
- /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
- * support pageflipping at all.
- */
- static const GLenum back_buffer_modes[] = {
- GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
- };
-
- uint8_t depth_bits_array[3];
- uint8_t stencil_bits_array[3];
- uint8_t msaa_samples_array[1];
-
-
- depth_bits_array[0] = 0;
- depth_bits_array[1] = depth_bits;
- depth_bits_array[2] = depth_bits;
- msaa_samples_array[0] = 0;
-
- /* Just like with the accumulation buffer, always provide some modes
- * with a stencil buffer. It will be a sw fallback, but some apps won't
- * care about that.
- */
- stencil_bits_array[0] = 0;
- stencil_bits_array[1] = 0;
- if (depth_bits == 24)
- stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
-
- stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
-
- depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
- back_buffer_factor = (have_back_buffer) ? 3 : 1;
-
- num_modes = depth_buffer_factor * back_buffer_factor * 4;
-
- if (pixel_bits == 16) {
- fb_format = GL_RGB;
- fb_type = GL_UNSIGNED_SHORT_5_6_5;
- }
- else {
- fb_format = GL_BGRA;
- fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
- }
-
- configs = driCreateConfigs(fb_format, fb_type,
- depth_bits_array, stencil_bits_array,
- depth_buffer_factor, back_buffer_modes,
- back_buffer_factor, msaa_samples_array, 1);
- if (configs == NULL) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
- __LINE__);
- return NULL;
- }
-
- /* Mark the visual as slow if there are "fake" stencil bits.
- */
- for (i = 0; configs[i]; i++) {
- m = &configs[i]->modes;
- if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
- m->visualRating = GLX_SLOW_CONFIG;
- }
- }
-
- return configs;
-}
-
-/**
- * This is the driver specific part of the createNewScreen entry point.
- *
- * \todo maybe fold this into intelInitDriver
- *
- * \return the __GLcontextModes supported by this driver
- */
-static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
-{
-#ifdef I915
- static const __DRIversion ddx_expected = { 1, 5, 0 };
-#else
- static const __DRIversion ddx_expected = { 1, 6, 0 };
-#endif
- static const __DRIversion dri_expected = { 4, 0, 0 };
- static const __DRIversion drm_expected = { 1, 5, 0 };
- I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
-
- if (!driCheckDriDdxDrmVersions2("i915",
- &psp->dri_version, &dri_expected,
- &psp->ddx_version, &ddx_expected,
- &psp->drm_version, &drm_expected)) {
- return NULL;
- }
-
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- driInitExtensions( NULL, card_extensions, GL_FALSE );
- //intelInitExtensions(NULL, GL_TRUE);
-
- if (!intelInitDriver(psp))
- return NULL;
-
- psp->extensions = intelScreenExtensions;
-
- return (const __DRIconfig **)
- intelFillInModes(psp, dri_priv->cpp * 8,
- (dri_priv->cpp == 2) ? 16 : 24,
- (dri_priv->cpp == 2) ? 0 : 8, 1);
-}
-
-/**
- * This is the driver specific part of the createNewScreen entry point.
- *
- * \return the __GLcontextModes supported by this driver
- */
-static const
-__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
-{
- struct intel_screen *intelScreen;
-
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- //intelInitExtensions(NULL, GL_TRUE);
-
- /* Allocate the private area */
- intelScreen = CALLOC_STRUCT(intel_screen);
- if (!intelScreen) {
- fprintf(stderr, "\nERROR! Allocating private area failed\n");
- return GL_FALSE;
- }
- /* parse information in __driConfigOptions */
- driParseOptionInfo(&intelScreen->optionCache,
- __driConfigOptions, __driNConfigOptions);
-
- psp->private = (void *) intelScreen;
-
- intelScreen->drmMinor = psp->drm_version.minor;
-
- /* Determine chipset ID? */
- if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID,
- &intelScreen->deviceID))
- return GL_FALSE;
-
- psp->extensions = intelScreenExtensions;
-
- intel_be_init_device(&intelScreen->base, psp->fd, intelScreen->deviceID);
- intelScreen->base.base.flush_frontbuffer = intel_flush_frontbuffer;
- intelScreen->base.base.get_name = intel_get_name;
-
- return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
- intelFillInModes(psp, 32, 24, 8, 1));
-}
-
-const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = intelInitScreen,
- .DestroyScreen = intelDestroyScreen,
- .CreateContext = intelCreateContext,
- .DestroyContext = intelDestroyContext,
- .CreateBuffer = intelCreateBuffer,
- .DestroyBuffer = intelDestroyBuffer,
- .SwapBuffers = intelSwapBuffers,
- .MakeCurrent = intelMakeCurrent,
- .UnbindContext = intelUnbindContext,
- .GetSwapInfo = intelGetSwapInfo,
- .GetDrawableMSC = driDrawableGetMSC32,
- .WaitForMSC = driWaitForMSC32,
- .CopySubBuffer = intelCopySubBuffer,
-
- //.InitScreen2 = intelInitScreen2,
- //.HandleDrawableConfig = intelHandleDrawableConfig,
- //.HandleBufferAttach = intelHandleBufferAttach,
-};
diff --git a/src/gallium/winsys/drm/intel/dri/intel_screen.h b/src/gallium/winsys/drm/intel/dri/intel_screen.h
deleted file mode 100644
index 0bb43a915c..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_screen.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _INTEL_SCREEN_H_
-#define _INTEL_SCREEN_H_
-
-#include "dri_util.h"
-#include "i830_common.h"
-#include "xmlconfig.h"
-#include "ws_dri_bufpool.h"
-
-#include "pipe/p_compiler.h"
-
-#include "intel_be_device.h"
-
-struct intel_screen
-{
- struct intel_be_device base;
-
- struct {
- drm_handle_t handle;
-
- /* We create a static dri buffer for the frontbuffer.
- */
- struct _DriBufferObject *buffer;
- struct pipe_surface *surface;
- struct pipe_texture *texture;
-
- char *map; /* memory map */
- int offset; /* from start of video mem, in bytes */
- int pitch; /* row stride, in bytes */
- int width;
- int height;
- int size;
- int cpp; /* for front and back buffers */
- } front;
-
- int deviceID;
- int drmMinor;
-
- drmI830Sarea *sarea;
-
- /**
- * Configuration cache with default values for all contexts
- */
- driOptionCache optionCache;
-
- boolean havePools;
-
- /**
- * Temporary(?) context to use for SwapBuffers or other situations in
- * which we need a rendering context, but none is currently bound.
- */
- struct intel_context *dummyContext;
-
- /*
- * New stuff form the i915tex integration
- */
- unsigned batch_id;
-
-
- struct pipe_winsys *winsys;
-};
-
-
-
-/** cast wrapper */
-static INLINE struct intel_screen *
-intel_screen(__DRIscreenPrivate *sPriv)
-{
- return (struct intel_screen *) sPriv->private;
-}
-
-
-extern void
-intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea);
-
-
-extern void intelDestroyContext(__DRIcontextPrivate * driContextPriv);
-
-extern boolean intelUnbindContext(__DRIcontextPrivate * driContextPriv);
-
-extern boolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv);
-
-
-extern boolean
-intelCreatePools(__DRIscreenPrivate *sPriv);
-
-extern boolean
-intelCreateContext(const __GLcontextModes * visual,
- __DRIcontextPrivate * driContextPriv,
- void *sharedContextPrivate);
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c b/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c
deleted file mode 100644
index 34ad7eebe1..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "intel_screen.h"
-#include "intel_context.h"
-#include "intel_swapbuffers.h"
-
-#include "intel_reg.h"
-
-#include "pipe/p_context.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_cb_fbo.h"
-
-#include "ws_dri_bufmgr.h"
-#include "intel_batchbuffer.h"
-
-/**
- * Display a colorbuffer surface in an X window.
- * Used for SwapBuffers and flushing front buffer rendering.
- *
- * \param dPriv the window/drawable to display into
- * \param surf the surface to display
- * \param rect optional subrect of surface to display (may be NULL).
- */
-void
-intelDisplaySurface(__DRIdrawablePrivate *dPriv,
- struct pipe_surface *surf,
- const drm_clip_rect_t *rect)
-{
- struct intel_screen *intelScreen = intel_screen(dPriv->driScreenPriv);
- struct intel_context *intel = intelScreen->dummyContext;
-
- DBG(SWAP, "%s\n", __FUNCTION__);
-
- if (!intel) {
- /* XXX this is where some kind of extra/meta context could be useful */
- return;
- }
-
- if (intel->last_swap_fence) {
- driFenceFinish(intel->last_swap_fence, DRM_FENCE_TYPE_EXE, TRUE);
- driFenceUnReference(&intel->last_swap_fence);
- intel->last_swap_fence = NULL;
- }
- intel->last_swap_fence = intel->first_swap_fence;
- intel->first_swap_fence = NULL;
-
- /* The LOCK_HARDWARE is required for the cliprects. Buffer offsets
- * should work regardless.
- */
- LOCK_HARDWARE(intel);
- /* if this drawable isn't currently bound the LOCK_HARDWARE done on the
- * current context (which is what intelScreenContext should return) might
- * not get a contended lock and thus cliprects not updated (tests/manywin)
- */
- if (intel_context(dPriv->driContextPriv) != intel)
- DRI_VALIDATE_DRAWABLE_INFO(intel->driScreen, dPriv);
-
-
- if (dPriv && dPriv->numClipRects) {
- const int srcWidth = surf->width;
- const int srcHeight = surf->height;
- const int nbox = dPriv->numClipRects;
- const drm_clip_rect_t *pbox = dPriv->pClipRects;
- const int pitch = intelScreen->front.pitch / intelScreen->front.cpp;
- const int cpp = intelScreen->front.cpp;
- const int srcpitch = surf->stride / cpp;
- int BR13, CMD;
- int i;
-
- ASSERT(surf->buffer);
-
- DBG(SWAP, "screen pitch %d src surface pitch %d\n",
- pitch, surf->stride);
-
- if (cpp == 2) {
- BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24);
- CMD = XY_SRC_COPY_BLT_CMD;
- }
- else {
- BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24) | (1 << 25);
- CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
- XY_SRC_COPY_BLT_WRITE_RGB);
- }
-
- for (i = 0; i < nbox; i++, pbox++) {
- drm_clip_rect_t box;
- drm_clip_rect_t sbox;
-
- if (pbox->x1 > pbox->x2 ||
- pbox->y1 > pbox->y2 ||
- pbox->x2 > intelScreen->front.width ||
- pbox->y2 > intelScreen->front.height) {
- /* invalid cliprect, skip it */
- continue;
- }
-
- box = *pbox;
-
- if (rect) {
- /* intersect cliprect with user-provided src rect */
- drm_clip_rect_t rrect;
-
- rrect.x1 = dPriv->x + rect->x1;
- rrect.y1 = (dPriv->h - rect->y1 - rect->y2) + dPriv->y;
- rrect.x2 = rect->x2 + rrect.x1;
- rrect.y2 = rect->y2 + rrect.y1;
- if (rrect.x1 > box.x1)
- box.x1 = rrect.x1;
- if (rrect.y1 > box.y1)
- box.y1 = rrect.y1;
- if (rrect.x2 < box.x2)
- box.x2 = rrect.x2;
- if (rrect.y2 < box.y2)
- box.y2 = rrect.y2;
-
- if (box.x1 > box.x2 || box.y1 > box.y2)
- continue;
- }
-
- /* restrict blit to size of actually rendered area */
- if (box.x2 - box.x1 > srcWidth)
- box.x2 = srcWidth + box.x1;
- if (box.y2 - box.y1 > srcHeight)
- box.y2 = srcHeight + box.y1;
-
- DBG(SWAP, "box x1 x2 y1 y2 %d %d %d %d\n",
- box.x1, box.x2, box.y1, box.y2);
-
- sbox.x1 = box.x1 - dPriv->x;
- sbox.y1 = box.y1 - dPriv->y;
-
- assert(box.x1 < box.x2);
- assert(box.y1 < box.y2);
-
- /* XXX this could be done with pipe->surface_copy() */
- /* XXX should have its own batch buffer */
- if (!BEGIN_BATCH(8, 2)) {
- /*
- * Since we share this batch buffer with a context
- * we can't flush it since that risks a GPU lockup
- */
- assert(0);
- continue;
- }
-
- OUT_BATCH(CMD);
- OUT_BATCH(BR13);
- OUT_BATCH((box.y1 << 16) | box.x1);
- OUT_BATCH((box.y2 << 16) | box.x2);
-
- OUT_RELOC(intelScreen->front.buffer,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
- OUT_BATCH((sbox.y1 << 16) | sbox.x1);
- OUT_BATCH((srcpitch * cpp) & 0xffff);
- OUT_RELOC(dri_bo(surf->buffer),
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
-
- }
-
- if (intel->first_swap_fence)
- driFenceUnReference(&intel->first_swap_fence);
- intel->first_swap_fence = intel_be_batchbuffer_flush(intel->base.batch);
- }
-
- UNLOCK_HARDWARE(intel);
-
- if (intel->lastStamp != dPriv->lastStamp) {
- intelUpdateWindowSize(dPriv);
- intel->lastStamp = dPriv->lastStamp;
- }
-}
-
-
-
-/**
- * This will be called whenever the currently bound window is moved/resized.
- */
-void
-intelUpdateWindowSize(__DRIdrawablePrivate *dPriv)
-{
- struct intel_framebuffer *intelfb = intel_framebuffer(dPriv);
- assert(intelfb->stfb);
- st_resize_framebuffer(intelfb->stfb, dPriv->w, dPriv->h);
-}
-
-
-
-void
-intelSwapBuffers(__DRIdrawablePrivate * dPriv)
-{
- struct intel_framebuffer *intel_fb = intel_framebuffer(dPriv);
- struct pipe_surface *back_surf;
-
- assert(intel_fb);
- assert(intel_fb->stfb);
-
- back_surf = st_get_framebuffer_surface(intel_fb->stfb,
- ST_SURFACE_BACK_LEFT);
- if (back_surf) {
- st_notify_swapbuffers(intel_fb->stfb);
- intelDisplaySurface(dPriv, back_surf, NULL);
- st_notify_swapbuffers_complete(intel_fb->stfb);
- }
-}
-
-
-/**
- * Called via glXCopySubBufferMESA() to copy a subrect of the back
- * buffer to the front buffer/screen.
- */
-void
-intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
-{
- struct intel_framebuffer *intel_fb = intel_framebuffer(dPriv);
- struct pipe_surface *back_surf;
-
- assert(intel_fb);
- assert(intel_fb->stfb);
-
- back_surf = st_get_framebuffer_surface(intel_fb->stfb,
- ST_SURFACE_BACK_LEFT);
- if (back_surf) {
- drm_clip_rect_t rect;
- rect.x1 = x;
- rect.y1 = y;
- rect.x2 = w;
- rect.y2 = h;
-
- st_notify_swapbuffers(intel_fb->stfb);
- intelDisplaySurface(dPriv, back_surf, &rect);
- }
-}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h b/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h
deleted file mode 100644
index 46c9bab3af..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_SWAPBUFFERS_H
-#define INTEL_SWAPBUFFERS_H
-
-
-struct pipe_surface;
-
-
-extern void intelDisplaySurface(__DRIdrawablePrivate * dPriv,
- struct pipe_surface *surf,
- const drm_clip_rect_t * rect);
-
-extern void intelSwapBuffers(__DRIdrawablePrivate * dPriv);
-
-extern void intelCopySubBuffer(__DRIdrawablePrivate * dPriv,
- int x, int y, int w, int h);
-
-extern void intelUpdateWindowSize(__DRIdrawablePrivate *dPriv);
-
-
-#endif /* INTEL_SWAPBUFFERS_H */
diff --git a/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c b/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c
deleted file mode 100644
index 20920a2052..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include "intel_context.h"
-#include "intel_winsys_softpipe.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_format.h"
-#include "util/u_memory.h"
-#include "softpipe/sp_winsys.h"
-
-
-struct intel_softpipe_winsys {
- struct softpipe_winsys sws;
- struct intel_context *intel;
-};
-
-/**
- * Return list of surface formats supported by this driver.
- */
-static boolean
-intel_is_format_supported(struct softpipe_winsys *sws,
- enum pipe_format format)
-{
- switch(format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-
-/**
- * Create rendering context which uses software rendering.
- */
-struct pipe_context *
-intel_create_softpipe( struct intel_context *intel,
- struct pipe_winsys *winsys )
-{
- struct intel_softpipe_winsys *isws = CALLOC_STRUCT( intel_softpipe_winsys );
- struct pipe_screen *screen = softpipe_create_screen(winsys);
-
- /* Fill in this struct with callbacks that softpipe will need to
- * communicate with the window system, buffer manager, etc.
- */
- isws->sws.is_format_supported = intel_is_format_supported;
- isws->intel = intel;
-
- /* Create the softpipe context:
- */
- return softpipe_create( screen, winsys, &isws->sws );
-}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h b/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h
deleted file mode 100644
index 5fa14cb749..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_SOFTPIPE_H
-#define INTEL_SOFTPIPE_H
-
-struct pipe_winsys;
-struct pipe_context;
-struct intel_context;
-
-struct pipe_context *
-intel_create_softpipe( struct intel_context *intel,
- struct pipe_winsys *winsys );
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/server/i830_common.h b/src/gallium/winsys/drm/intel/dri/server/i830_common.h
deleted file mode 100644
index 3452ddb3c9..0000000000
--- a/src/gallium/winsys/drm/intel/dri/server/i830_common.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/**************************************************************************
-
-Copyright 2001 VA Linux Systems Inc., Fremont, California.
-Copyright 2002 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
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-
-#ifndef _I830_COMMON_H_
-#define _I830_COMMON_H_
-
-
-#define I830_NR_TEX_REGIONS 255 /* maximum due to use of chars for next/prev */
-#define I830_LOG_MIN_TEX_REGION_SIZE 14
-
-
-/* Driver specific DRM command indices
- * NOTE: these are not OS specific, but they are driver specific
- */
-#define DRM_I830_INIT 0x00
-#define DRM_I830_FLUSH 0x01
-#define DRM_I830_FLIP 0x02
-#define DRM_I830_BATCHBUFFER 0x03
-#define DRM_I830_IRQ_EMIT 0x04
-#define DRM_I830_IRQ_WAIT 0x05
-#define DRM_I830_GETPARAM 0x06
-#define DRM_I830_SETPARAM 0x07
-#define DRM_I830_ALLOC 0x08
-#define DRM_I830_FREE 0x09
-#define DRM_I830_INIT_HEAP 0x0a
-#define DRM_I830_CMDBUFFER 0x0b
-#define DRM_I830_DESTROY_HEAP 0x0c
-#define DRM_I830_SET_VBLANK_PIPE 0x0d
-#define DRM_I830_GET_VBLANK_PIPE 0x0e
-#define DRM_I830_MMIO 0x10
-
-typedef struct {
- enum {
- I830_INIT_DMA = 0x01,
- I830_CLEANUP_DMA = 0x02,
- I830_RESUME_DMA = 0x03
- } func;
- unsigned int mmio_offset;
- int sarea_priv_offset;
- unsigned int ring_start;
- unsigned int ring_end;
- unsigned int ring_size;
- unsigned int front_offset;
- unsigned int back_offset;
- unsigned int depth_offset;
- unsigned int w;
- unsigned int h;
- unsigned int pitch;
- unsigned int pitch_bits;
- unsigned int back_pitch;
- unsigned int depth_pitch;
- unsigned int cpp;
- unsigned int chipset;
-} drmI830Init;
-
-typedef struct {
- drmTextureRegion texList[I830_NR_TEX_REGIONS+1];
- int last_upload; /* last time texture was uploaded */
- int last_enqueue; /* last time a buffer was enqueued */
- int last_dispatch; /* age of the most recently dispatched buffer */
- int ctxOwner; /* last context to upload state */
- /** Last context that used the buffer manager. */
- int texAge;
- int pf_enabled; /* is pageflipping allowed? */
- int pf_active;
- int pf_current_page; /* which buffer is being displayed? */
- int perf_boxes; /* performance boxes to be displayed */
- int width, height; /* screen size in pixels */
-
- drm_handle_t front_handle;
- int front_offset;
- int front_size;
-
- drm_handle_t back_handle;
- int back_offset;
- int back_size;
-
- drm_handle_t depth_handle;
- int depth_offset;
- int depth_size;
-
- drm_handle_t tex_handle;
- int tex_offset;
- int tex_size;
- int log_tex_granularity;
- int pitch;
- int rotation; /* 0, 90, 180 or 270 */
- int rotated_offset;
- int rotated_size;
- int rotated_pitch;
- int virtualX, virtualY;
-
- unsigned int front_tiled;
- unsigned int back_tiled;
- unsigned int depth_tiled;
- unsigned int rotated_tiled;
- unsigned int rotated2_tiled;
-
- int planeA_x;
- int planeA_y;
- int planeA_w;
- int planeA_h;
- int planeB_x;
- int planeB_y;
- int planeB_w;
- int planeB_h;
-
- /* Triple buffering */
- drm_handle_t third_handle;
- int third_offset;
- int third_size;
- unsigned int third_tiled;
-
- /* buffer object handles for the static buffers. May change
- * over the lifetime of the client, though it doesn't in our current
- * implementation.
- */
- unsigned int front_bo_handle;
- unsigned int back_bo_handle;
- unsigned int third_bo_handle;
- unsigned int depth_bo_handle;
-} drmI830Sarea;
-
-/* Flags for perf_boxes
- */
-#define I830_BOX_RING_EMPTY 0x1 /* populated by kernel */
-#define I830_BOX_FLIP 0x2 /* populated by kernel */
-#define I830_BOX_WAIT 0x4 /* populated by kernel & client */
-#define I830_BOX_TEXTURE_LOAD 0x8 /* populated by kernel */
-#define I830_BOX_LOST_CONTEXT 0x10 /* populated by client */
-
-
-typedef struct {
- int start; /* agp offset */
- int used; /* nr bytes in use */
- int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
- int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/
- int num_cliprects; /* mulitpass with multiple cliprects? */
- drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
-} drmI830BatchBuffer;
-
-typedef struct {
- char *buf; /* agp offset */
- int sz; /* nr bytes in use */
- int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
- int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/
- int num_cliprects; /* mulitpass with multiple cliprects? */
- drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
-} drmI830CmdBuffer;
-
-typedef struct {
- int *irq_seq;
-} drmI830IrqEmit;
-
-typedef struct {
- int irq_seq;
-} drmI830IrqWait;
-
-typedef struct {
- int param;
- int *value;
-} drmI830GetParam;
-
-#define I830_PARAM_IRQ_ACTIVE 1
-#define I830_PARAM_ALLOW_BATCHBUFFER 2
-
-typedef struct {
- int param;
- int value;
-} drmI830SetParam;
-
-#define I830_SETPARAM_USE_MI_BATCHBUFFER_START 1
-#define I830_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
-#define I830_SETPARAM_ALLOW_BATCHBUFFER 3
-
-
-/* A memory manager for regions of shared memory:
- */
-#define I830_MEM_REGION_AGP 1
-
-typedef struct {
- int region;
- int alignment;
- int size;
- int *region_offset; /* offset from start of fb or agp */
-} drmI830MemAlloc;
-
-typedef struct {
- int region;
- int region_offset;
-} drmI830MemFree;
-
-typedef struct {
- int region;
- int size;
- int start;
-} drmI830MemInitHeap;
-
-typedef struct {
- int region;
-} drmI830MemDestroyHeap;
-
-#define DRM_I830_VBLANK_PIPE_A 1
-#define DRM_I830_VBLANK_PIPE_B 2
-
-typedef struct {
- int pipe;
-} drmI830VBlankPipe;
-
-#define MMIO_READ 0
-#define MMIO_WRITE 1
-
-#define MMIO_REGS_IA_PRIMATIVES_COUNT 0
-#define MMIO_REGS_IA_VERTICES_COUNT 1
-#define MMIO_REGS_VS_INVOCATION_COUNT 2
-#define MMIO_REGS_GS_PRIMITIVES_COUNT 3
-#define MMIO_REGS_GS_INVOCATION_COUNT 4
-#define MMIO_REGS_CL_PRIMITIVES_COUNT 5
-#define MMIO_REGS_CL_INVOCATION_COUNT 6
-#define MMIO_REGS_PS_INVOCATION_COUNT 7
-#define MMIO_REGS_PS_DEPTH_COUNT 8
-
-typedef struct {
- unsigned int read_write:1;
- unsigned int reg:31;
- void __user *data;
-} drmI830MMIO;
-
-#endif /* _I830_DRM_H_ */
diff --git a/src/gallium/winsys/drm/intel/dri/server/i830_dri.h b/src/gallium/winsys/drm/intel/dri/server/i830_dri.h
deleted file mode 100644
index 0d514b6c38..0000000000
--- a/src/gallium/winsys/drm/intel/dri/server/i830_dri.h
+++ /dev/null
@@ -1,62 +0,0 @@
-
-#ifndef _I830_DRI_H
-#define _I830_DRI_H
-
-#include "xf86drm.h"
-#include "i830_common.h"
-
-#define I830_MAX_DRAWABLES 256
-
-#define I830_MAJOR_VERSION 1
-#define I830_MINOR_VERSION 7
-#define I830_PATCHLEVEL 2
-
-#define I830_REG_SIZE 0x80000
-
-typedef struct _I830DRIRec {
- drm_handle_t regs;
- drmSize regsSize;
-
- drmSize unused1; /* backbufferSize */
- drm_handle_t unused2; /* backbuffer */
-
- drmSize unused3; /* depthbufferSize */
- drm_handle_t unused4; /* depthbuffer */
-
- drmSize unused5; /* rotatedSize */
- drm_handle_t unused6; /* rotatedbuffer */
-
- drm_handle_t unused7; /* textures */
- int unused8; /* textureSize */
-
- drm_handle_t unused9; /* agp_buffers */
- drmSize unused10; /* agp_buf_size */
-
- int deviceID;
- int width;
- int height;
- int mem;
- int cpp;
- int bitsPerPixel;
-
- int unused11[8]; /* was front/back/depth/rotated offset/pitch */
-
- int unused12; /* logTextureGranularity */
- int unused13; /* textureOffset */
-
- int irq;
- int sarea_priv_offset;
-} I830DRIRec, *I830DRIPtr;
-
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} I830ConfigPrivRec, *I830ConfigPrivPtr;
-
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} I830DRIContextRec, *I830DRIContextPtr;
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri2/Makefile b/src/gallium/winsys/drm/intel/dri2/Makefile
new file mode 100644
index 0000000000..1a02109274
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/dri2/Makefile
@@ -0,0 +1,22 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i915_dri.so
+
+PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \
+ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \
+ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a
+
+
+DRIVER_SOURCES =
+
+C_SOURCES = \
+ $(COMMON_GALLIUM_SOURCES) \
+ $(DRIVER_SOURCES)
+
+include ../../Makefile.template
+
+DRI_LIB_DEPS += -ldrm_intel
+
+symlinks:
diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile
index 7147d89e0d..c5217ad2d6 100644
--- a/src/gallium/winsys/drm/intel/egl/Makefile
+++ b/src/gallium/winsys/drm/intel/egl/Makefile
@@ -1,19 +1,16 @@
TOP = ../../../../../..
+GALLIUMDIR = ../../../..
include $(TOP)/configs/current
LIBNAME = EGL_i915.so
PIPE_DRIVERS = \
- ../gem/libinteldrm.a \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/drivers/i915simple/libi915simple.a \
$(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
+ $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a
-
-DRIVER_SOURCES = \
- intel_context.c \
- intel_device.c \
- intel_api.c
+DRIVER_SOURCES =
C_SOURCES = \
$(COMMON_GALLIUM_SOURCES) \
diff --git a/src/gallium/winsys/drm/intel/egl/intel_api.c b/src/gallium/winsys/drm/intel/egl/intel_api.c
deleted file mode 100644
index 5dc4a7b052..0000000000
--- a/src/gallium/winsys/drm/intel/egl/intel_api.c
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#include "intel_api.h"
-
-struct drm_api drm_api_hocks =
-{
- .create_screen = intel_create_screen,
- .create_context = intel_create_context,
- .buffer_from_handle = intel_be_buffer_from_handle,
- .handle_from_buffer = intel_be_handle_from_buffer,
-};
diff --git a/src/gallium/winsys/drm/intel/egl/intel_api.h b/src/gallium/winsys/drm/intel/egl/intel_api.h
deleted file mode 100644
index 8ec165ab01..0000000000
--- a/src/gallium/winsys/drm/intel/egl/intel_api.h
+++ /dev/null
@@ -1,14 +0,0 @@
-
-#ifndef _INTEL_API_H_
-#define _INTEL_API_H_
-
-#include "pipe/p_compiler.h"
-
-#include "state_tracker/drm_api.h"
-
-#include "intel_be_device.h"
-
-struct pipe_screen *intel_create_screen(int drmFD, int pciID);
-struct pipe_context *intel_create_context(struct pipe_screen *screen);
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/egl/intel_context.c b/src/gallium/winsys/drm/intel/egl/intel_context.c
deleted file mode 100644
index 57e5ff7bc1..0000000000
--- a/src/gallium/winsys/drm/intel/egl/intel_context.c
+++ /dev/null
@@ -1,83 +0,0 @@
-
-#include "i915simple/i915_screen.h"
-
-#include "intel_be_device.h"
-#include "intel_be_context.h"
-
-#include "pipe/p_defines.h"
-#include "pipe/p_context.h"
-
-#include "intel_api.h"
-
-struct intel_context
-{
- struct intel_be_context base;
-
- /* stuff */
-};
-
-/*
- * Hardware lock functions.
- * Doesn't do anything in EGL
- */
-
-static void
-intel_lock_hardware(struct intel_be_context *context)
-{
- (void)context;
-}
-
-static void
-intel_unlock_hardware(struct intel_be_context *context)
-{
- (void)context;
-}
-
-static boolean
-intel_locked_hardware(struct intel_be_context *context)
-{
- (void)context;
- return FALSE;
-}
-
-
-/*
- * Misc functions.
- */
-static void
-intel_destroy_be_context(struct i915_winsys *winsys)
-{
- struct intel_context *intel = (struct intel_context *)winsys;
-
- intel_be_destroy_context(&intel->base);
- free(intel);
-}
-
-struct pipe_context *
-intel_create_context(struct pipe_screen *screen)
-{
- struct intel_context *intel;
- struct pipe_context *pipe;
- struct intel_be_device *device = (struct intel_be_device *)screen->winsys;
-
- intel = (struct intel_context *)malloc(sizeof(*intel));
- memset(intel, 0, sizeof(*intel));
-
- intel->base.hardware_lock = intel_lock_hardware;
- intel->base.hardware_unlock = intel_unlock_hardware;
- intel->base.hardware_locked = intel_locked_hardware;
-
- intel_be_init_context(&intel->base, device);
-
- intel->base.base.destroy = intel_destroy_be_context;
-
-#if 0
- pipe = intel_create_softpipe(intel, screen->winsys);
-#else
- pipe = i915_create_context(screen, &device->base, &intel->base.base);
-#endif
-
- pipe->priv = intel;
-
- return pipe;
-}
diff --git a/src/gallium/winsys/drm/intel/egl/intel_device.c b/src/gallium/winsys/drm/intel/egl/intel_device.c
deleted file mode 100644
index 6b281402d5..0000000000
--- a/src/gallium/winsys/drm/intel/egl/intel_device.c
+++ /dev/null
@@ -1,48 +0,0 @@
-
-#include <stdio.h>
-#include "pipe/p_defines.h"
-#include "intel_be_device.h"
-#include "i915simple/i915_screen.h"
-
-#include "intel_api.h"
-
-struct intel_device
-{
- struct intel_be_device base;
-
- int deviceID;
-};
-
-static void
-intel_destroy_winsys(struct pipe_winsys *winsys)
-{
- struct intel_device *dev = (struct intel_device *)winsys;
-
- intel_be_destroy_device(&dev->base);
-
- free(dev);
-}
-
-struct pipe_screen *
-intel_create_screen(int drmFD, int deviceID)
-{
- struct intel_device *dev;
- struct pipe_screen *screen;
-
- /* Allocate the private area */
- dev = malloc(sizeof(*dev));
- if (!dev)
- return NULL;
- memset(dev, 0, sizeof(*dev));
-
- dev->deviceID = deviceID;
-
- intel_be_init_device(&dev->base, drmFD, deviceID);
-
- /* we need to hock our own destroy function in here */
- dev->base.base.destroy = intel_destroy_winsys;
-
- screen = i915_create_screen(&dev->base.base, deviceID);
-
- return screen;
-}
diff --git a/src/gallium/winsys/drm/intel/gem/Makefile b/src/gallium/winsys/drm/intel/gem/Makefile
index b25fc258f4..7ab1a2a771 100644
--- a/src/gallium/winsys/drm/intel/gem/Makefile
+++ b/src/gallium/winsys/drm/intel/gem/Makefile
@@ -6,13 +6,11 @@ LIBNAME = inteldrm
C_SOURCES = \
intel_be_batchbuffer.c \
intel_be_context.c \
- intel_be_device.c
+ intel_be_device.c \
+ intel_be_api.c
+LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
-include ./Makefile.template
-
-DRIVER_DEFINES = $(shell pkg-config libdrm --cflags \
- && pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-symlinks:
+LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
+include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/intel/gem/Makefile.template b/src/gallium/winsys/drm/intel/gem/Makefile.template
deleted file mode 100644
index b60e978894..0000000000
--- a/src/gallium/winsys/drm/intel/gem/Makefile.template
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*-makefile-*-
-
-
-# We still have a dependency on the "dri" buffer manager. Most likely
-# the interface can be reused in non-dri environments, and also as a
-# frontend to simpler memory managers.
-#
-COMMON_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/include \
- $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks lib$(LIBNAME).a
-
-
-lib$(LIBNAME).a: $(OBJECTS) Makefile Makefile.template
- $(TOP)/bin/mklib -o $(LIBNAME) -static $(OBJECTS) $(DRIVER_LIBS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean::
- -rm -f *.o */*.o *~ *.so *.a *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
-
-
-include depend
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.c b/src/gallium/winsys/drm/intel/gem/intel_be_api.c
new file mode 100644
index 0000000000..f4ef7c2d88
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.c
@@ -0,0 +1,15 @@
+
+#include "intel_be_api.h"
+#include "i915simple/i915_winsys.h"
+
+struct drm_api drm_api_hooks =
+{
+ /* intel_be_context.c */
+ .create_context = intel_be_create_context,
+ /* intel_be_device.c */
+ .create_screen = intel_be_create_screen,
+ .buffer_from_texture = i915_get_texture_buffer,
+ .buffer_from_handle = intel_be_buffer_from_handle,
+ .handle_from_buffer = intel_be_handle_from_buffer,
+ .global_handle_from_buffer = intel_be_global_handle_from_buffer,
+};
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.h b/src/gallium/winsys/drm/intel/gem/intel_be_api.h
new file mode 100644
index 0000000000..73e458d4ba
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.h
@@ -0,0 +1,14 @@
+
+#ifndef _INTEL_BE_API_H_
+#define _INTEL_BE_API_H_
+
+#include "pipe/p_compiler.h"
+
+#include "state_tracker/drm_api.h"
+
+#include "intel_be_device.h"
+
+struct pipe_screen *intel_be_create_screen(int drmFD, int pciID);
+struct pipe_context *intel_be_create_context(struct pipe_screen *screen);
+
+#endif
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c b/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c
index d9556e1f38..d5e63c3bae 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c
@@ -21,7 +21,7 @@ intel_be_batchbuffer_alloc(struct intel_be_context *intel)
batch->base.size = 0;
batch->base.actual_size = intel->device->max_batch_size;
batch->base.relocs = 0;
- batch->base.max_relocs = INTEL_DEFAULT_RELOCS;
+ batch->base.max_relocs = 500;/*INTEL_DEFAULT_RELOCS;*/
batch->base.map = malloc(batch->base.actual_size);
memset(batch->base.map, 0, batch->base.actual_size);
@@ -47,7 +47,6 @@ intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch)
batch->base.size = batch->base.actual_size - BATCH_RESERVED;
batch->base.relocs = 0;
- batch->base.max_relocs = INTEL_DEFAULT_RELOCS;
batch->bo = drm_intel_bo_alloc(dev->pools.gem,
"gallium3d_batch_buffer",
@@ -115,10 +114,10 @@ intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch,
if (fence) {
if (*fence)
- intel_be_fence_unreference(*fence);
+ intel_be_fence_reference(fence, NULL);
(*fence) = CALLOC_STRUCT(intel_be_fence);
- (*fence)->refcount = 1;
+ pipe_reference_init(&(*fence)->reference, 1);
(*fence)->bo = NULL;
}
}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_context.c b/src/gallium/winsys/drm/intel/gem/intel_be_context.c
index 95e761d78d..bb6f1b916c 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_context.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_context.c
@@ -1,10 +1,14 @@
+#include "pipe/p_screen.h"
+
#include "intel_be_device.h"
#include "intel_be_context.h"
#include "intel_be_batchbuffer.h"
#include "i915_drm.h"
+#include "intel_be_api.h"
+
static struct i915_batchbuffer *
intel_be_batch_get(struct i915_winsys *sws)
{
@@ -57,6 +61,21 @@ intel_be_batch_flush(struct i915_winsys *sws,
intel_be_batchbuffer_flush(intel->batch, f);
}
+
+/*
+ * Misc functions.
+ */
+
+static void
+intel_be_destroy_context(struct i915_winsys *winsys)
+{
+ struct intel_be_context *intel = intel_be_context(winsys);
+
+ intel_be_batchbuffer_free(intel->batch);
+
+ free(intel);
+}
+
boolean
intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *device)
{
@@ -68,13 +87,32 @@ intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *de
intel->base.batch_reloc = intel_be_batch_reloc;
intel->base.batch_flush = intel_be_batch_flush;
+ intel->base.destroy = intel_be_destroy_context;
+
intel->batch = intel_be_batchbuffer_alloc(intel);
return true;
}
-void
-intel_be_destroy_context(struct intel_be_context *intel)
+struct pipe_context *
+intel_be_create_context(struct pipe_screen *screen)
{
- intel_be_batchbuffer_free(intel->batch);
+ struct intel_be_context *intel;
+ struct pipe_context *pipe;
+ struct intel_be_device *device = intel_be_device(screen->winsys);
+
+ intel = (struct intel_be_context *)malloc(sizeof(*intel));
+ memset(intel, 0, sizeof(*intel));
+
+ intel_be_init_context(intel, device);
+
+#if 0
+ pipe = intel_create_softpipe(intel, screen->winsys);
+#else
+ pipe = i915_create_context(screen, &device->base, &intel->base);
+#endif
+
+ pipe->priv = intel;
+
+ return pipe;
}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_context.h b/src/gallium/winsys/drm/intel/gem/intel_be_context.h
index 9cee1a4e52..5a369669c0 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_context.h
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_context.h
@@ -11,15 +11,6 @@ struct intel_be_context
struct intel_be_device *device;
struct intel_be_batchbuffer *batch;
-
- /*
- * Hardware lock functions.
- *
- * Needs to be filled in by the winsys.
- */
- void (*hardware_lock)(struct intel_be_context *context);
- void (*hardware_unlock)(struct intel_be_context *context);
- boolean (*hardware_locked)(struct intel_be_context *context);
};
static INLINE struct intel_be_context *
@@ -37,12 +28,4 @@ boolean
intel_be_init_context(struct intel_be_context *intel,
struct intel_be_device *device);
-/**
- * Destroy a intel_be_context.
- *
- * Does not free the struct that is up to the winsys.
- */
-void
-intel_be_destroy_context(struct intel_be_context *intel);
-
#endif
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c
index 82c1cb2f32..0f6300323b 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c
@@ -9,17 +9,9 @@
#include "intel_be_fence.h"
-#include "i915simple/i915_screen.h"
+#include "i915simple/i915_winsys.h"
-
-/**
- * Turn a pipe winsys into an intel/pipe winsys:
- */
-static INLINE struct intel_be_device *
-intel_be_device(struct pipe_winsys *winsys)
-{
- return (struct intel_be_device *)winsys;
-}
+#include "intel_be_api.h"
/*
* Buffer
@@ -34,6 +26,12 @@ intel_be_buffer_map(struct pipe_winsys *winsys,
int write = 0;
int ret;
+ if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+ /* Remove this when drm_intel_bo_map supports DONTBLOCK
+ */
+ return NULL;
+ }
+
if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
write = 1;
@@ -53,8 +51,7 @@ intel_be_buffer_unmap(struct pipe_winsys *winsys,
}
static void
-intel_be_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+intel_be_buffer_destroy(struct pipe_buffer *buf)
{
drm_intel_bo_unreference(intel_bo(buf));
free(buf);
@@ -74,10 +71,12 @@ intel_be_buffer_create(struct pipe_winsys *winsys,
if (!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
+ buffer->flinked = FALSE;
+ buffer->flink = 0;
if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) {
/* Local buffer */
@@ -115,7 +114,7 @@ intel_be_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned byte
if (!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = 0;
buffer->base.usage = 0;
buffer->base.size = bytes;
@@ -141,10 +140,10 @@ err:
}
struct pipe_buffer *
-intel_be_buffer_from_handle(struct pipe_winsys *winsys,
+intel_be_buffer_from_handle(struct pipe_screen *screen,
const char* name, unsigned handle)
{
- struct intel_be_device *dev = intel_be_device(winsys);
+ struct intel_be_device *dev = intel_be_device(screen->winsys);
struct intel_be_buffer *buffer = CALLOC_STRUCT(intel_be_buffer);
if (!buffer)
@@ -155,7 +154,8 @@ intel_be_buffer_from_handle(struct pipe_winsys *winsys,
if (!buffer->bo)
goto err;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->base.screen = screen;
buffer->base.alignment = buffer->bo->align;
buffer->base.usage = PIPE_BUFFER_USAGE_GPU_READ |
PIPE_BUFFER_USAGE_GPU_WRITE |
@@ -170,14 +170,39 @@ err:
return NULL;
}
-unsigned
-intel_be_handle_from_buffer(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+boolean
+intel_be_handle_from_buffer(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle)
{
- drm_intel_bo *bo = intel_bo(buf);
- return bo->handle;
+ drm_intel_bo *bo;
+
+ if (!buffer)
+ return FALSE;
+
+ *handle = intel_bo(buffer)->handle;
+ return TRUE;
}
+boolean
+intel_be_global_handle_from_buffer(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle)
+{
+ struct intel_be_buffer *buf = intel_be_buffer(buffer);
+
+ if (!buffer)
+ return FALSE;
+
+ if (!buf->flinked) {
+ if (drm_intel_bo_flink(intel_bo(buffer), &buf->flink))
+ return FALSE;
+ buf->flinked = TRUE;
+ }
+
+ *handle = buf->flink;
+ return TRUE;
+}
/*
* Fence
*/
@@ -190,15 +215,7 @@ intel_be_fence_refunref(struct pipe_winsys *sws,
struct intel_be_fence **p = (struct intel_be_fence **)ptr;
struct intel_be_fence *f = (struct intel_be_fence *)fence;
- assert(p);
-
- if (f)
- intel_be_fence_reference(f);
-
- if (*p)
- intel_be_fence_unreference(*p);
-
- *p = f;
+ intel_be_fence_reference(p, f);
}
static int
@@ -233,10 +250,21 @@ intel_be_fence_finish(struct pipe_winsys *sws,
* Misc functions
*/
+static void
+intel_be_destroy_winsys(struct pipe_winsys *winsys)
+{
+ struct intel_be_device *dev = intel_be_device(winsys);
+
+ drm_intel_bufmgr_destroy(dev->pools.gem);
+
+ free(dev);
+}
+
boolean
intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
{
dev->fd = fd;
+ dev->id = id;
dev->max_batch_size = 16 * 4096;
dev->max_vertex_size = 128 * 4096;
@@ -253,13 +281,28 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
dev->base.fence_signalled = intel_be_fence_signalled;
dev->base.fence_finish = intel_be_fence_finish;
+ dev->base.destroy = intel_be_destroy_winsys;
+
dev->pools.gem = drm_intel_bufmgr_gem_init(dev->fd, dev->max_batch_size);
return true;
}
-void
-intel_be_destroy_device(struct intel_be_device *dev)
+struct pipe_screen *
+intel_be_create_screen(int drmFD, int deviceID)
{
- drm_intel_bufmgr_destroy(dev->pools.gem);
+ struct intel_be_device *dev;
+ struct pipe_screen *screen;
+
+ /* Allocate the private area */
+ dev = malloc(sizeof(*dev));
+ if (!dev)
+ return NULL;
+ memset(dev, 0, sizeof(*dev));
+
+ intel_be_init_device(dev, drmFD, deviceID);
+
+ screen = i915_create_screen(&dev->base, deviceID);
+
+ return screen;
}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.h b/src/gallium/winsys/drm/intel/gem/intel_be_device.h
index f06890163c..47d2176cb4 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_device.h
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.h
@@ -18,6 +18,8 @@ struct intel_be_device
int fd; /**< Drm file discriptor */
+ unsigned id;
+
size_t max_batch_size;
size_t max_vertex_size;
@@ -26,12 +28,15 @@ struct intel_be_device
} pools;
};
+static INLINE struct intel_be_device *
+intel_be_device(struct pipe_winsys *winsys)
+{
+ return (struct intel_be_device *)winsys;
+}
+
boolean
intel_be_init_device(struct intel_be_device *device, int fd, unsigned id);
-void
-intel_be_destroy_device(struct intel_be_device *dev);
-
/*
* Buffer
*/
@@ -39,6 +44,8 @@ intel_be_destroy_device(struct intel_be_device *dev);
struct intel_be_buffer {
struct pipe_buffer base;
drm_intel_bo *bo;
+ boolean flinked;
+ unsigned flink;
};
/**
@@ -47,7 +54,7 @@ struct intel_be_buffer {
* Takes a reference.
*/
struct pipe_buffer *
-intel_be_buffer_from_handle(struct pipe_winsys *winsys,
+intel_be_buffer_from_handle(struct pipe_screen *screen,
const char* name, unsigned handle);
/**
@@ -55,9 +62,20 @@ intel_be_buffer_from_handle(struct pipe_winsys *winsys,
*
* If buffer is destroyed handle may become invalid.
*/
-unsigned
-intel_be_handle_from_buffer(struct pipe_winsys *winsys,
- struct pipe_buffer *buffer);
+boolean
+intel_be_handle_from_buffer(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle);
+
+/**
+ * Gets the global handle from a buffer.
+ *
+ * If buffer is destroyed handle may become invalid.
+ */
+boolean
+intel_be_global_handle_from_buffer(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle);
static INLINE struct intel_be_buffer *
intel_be_buffer(struct pipe_buffer *buf)
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_fence.h b/src/gallium/winsys/drm/intel/gem/intel_be_fence.h
index 0fe18f66f8..a8abb01a9e 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_fence.h
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_fence.h
@@ -15,23 +15,19 @@
*/
struct intel_be_fence
{
- uint32_t refcount;
+ struct pipe_reference reference;
drm_intel_bo *bo;
};
static INLINE void
-intel_be_fence_reference(struct intel_be_fence *f)
+intel_be_fence_reference(struct intel_be_fence **ptr, struct intel_be_fence *f)
{
- f->refcount++;
-}
+ struct intel_be_fence *old_fence = *ptr;
-static INLINE void
-intel_be_fence_unreference(struct intel_be_fence *f)
-{
- if (!--f->refcount) {
- if (f->bo)
- drm_intel_bo_unreference(f->bo);
- free(f);
+ if (pipe_reference((struct pipe_reference**)ptr, &f->reference)) {
+ if (old_fence->bo)
+ drm_intel_bo_unreference(old_fence->bo);
+ free(old_fence);
}
}
diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile
new file mode 100644
index 0000000000..a45ca570db
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/Makefile
@@ -0,0 +1,43 @@
+TARGET = modesetting_drv.so
+CFILES = $(wildcard ./*.c)
+OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES))
+GALLIUMDIR = ../../../..
+TOP = ../../../../../..
+
+include ${TOP}/configs/current
+
+CFLAGS = -DHAVE_CONFIG_H \
+ -g -Wall -Wimplicit-function-declaration -fPIC \
+ $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
+ -I../gem \
+ -I${GALLIUMDIR}/include \
+ -I${GALLIUMDIR}/drivers \
+ -I${GALLIUMDIR}/auxiliary \
+ -I${TOP}/src/mesa \
+ -I$(TOP)/include \
+ -I$(TOP)/src/egl/main
+
+LIBS = \
+ $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a \
+ $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \
+ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a \
+ $(GALLIUM_AUXILIARIES)
+
+#############################################
+
+
+
+all default: $(TARGET)
+
+$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a
+ $(TOP)/bin/mklib -noprefix -o $@ \
+ $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
+
+clean:
+ rm -rf $(OBJECTS) $(TARGET)
+
+install:
+ $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+ $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_xorg.c b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c
new file mode 100644
index 0000000000..aea39247e5
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "../../../../state_trackers/xorg/xorg_winsys.h"
+
+static void intel_xorg_identify(int flags);
+static Bool intel_xorg_pci_probe(DriverPtr driver,
+ int entity_num,
+ struct pci_device *device,
+ intptr_t match_data);
+
+static const struct pci_id_match intel_xorg_device_match[] = {
+ {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0},
+ {0x8086, 0x27A2, 0xffff, 0xffff, 0, 0, 0},
+ {0, 0, 0},
+};
+
+static SymTabRec intel_xorg_chipsets[] = {
+ {0x2592, "Intel Graphics Device"},
+ {0x27A2, "Intel Graphics Device"},
+ {-1, NULL}
+};
+
+static PciChipsets intel_xorg_pci_devices[] = {
+ {0x2592, 0x2592, RES_SHARED_VGA},
+ {0x27A2, 0x27A2, RES_SHARED_VGA},
+ {-1, -1, RES_UNDEFINED}
+};
+
+static XF86ModuleVersionInfo intel_xorg_version = {
+ "modesetting",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 0, 1, 0, /* major, minor, patch */
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+ 1,
+ "modesetting",
+ intel_xorg_identify,
+ NULL,
+ xorg_tracker_available_options,
+ NULL,
+ 0,
+ NULL,
+ intel_xorg_device_match,
+ intel_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(intel_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+ &intel_xorg_version,
+ intel_xorg_setup,
+ NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = 0;
+
+ /* This module should be loaded only once, but check to be sure.
+ */
+ if (!setupDone) {
+ setupDone = 1;
+ xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+ /*
+ * Tell the loader about symbols from other modules that this module
+ * might refer to.
+ */
+ xorg_tracker_loader_ref_sym_lists();
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer) 1;
+ } else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+static void
+intel_xorg_identify(int flags)
+{
+ xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+ intel_xorg_chipsets);
+}
+
+static Bool
+intel_xorg_pci_probe(DriverPtr driver,
+ int entity_num, struct pci_device *device, intptr_t match_data)
+{
+ ScrnInfoPtr scrn = NULL;
+ EntityInfoPtr entity;
+
+ scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
+ NULL, NULL, NULL, NULL, NULL);
+ if (scrn != NULL) {
+ scrn->driverVersion = 1;
+ scrn->driverName = "modesetting";
+ scrn->name = "modesetting";
+ scrn->Probe = NULL;
+
+ entity = xf86GetEntityInfo(entity_num);
+
+ /* Use all the functions from the xorg tracker */
+ xorg_tracker_set_functions(scrn);
+ }
+ return scrn != NULL;
+}
diff --git a/src/gallium/winsys/drm/nouveau/Makefile b/src/gallium/winsys/drm/nouveau/Makefile
index b5735329ec..f8c8135854 100644
--- a/src/gallium/winsys/drm/nouveau/Makefile
+++ b/src/gallium/winsys/drm/nouveau/Makefile
@@ -1,25 +1,12 @@
+# src/gallium/winsys/drm/nouveau/Makefile
TOP = ../../../../..
include $(TOP)/configs/current
+SUBDIRS = drm dri dri2
-SUBDIRS = common dri
-
-
-default: subdirs
-
-
-subdirs:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
- rm -f `find . -name depend`
-
-
-# Dummy install target
-install:
diff --git a/src/gallium/winsys/drm/nouveau/common/Makefile b/src/gallium/winsys/drm/nouveau/common/Makefile
deleted file mode 100644
index c6dd6dd7f9..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nouveaudrm
-
-C_SOURCES = \
- nouveau_context.c \
- nouveau_lock.c \
- nouveau_screen.c \
- nouveau_winsys.c \
- nouveau_winsys_pipe.c \
- nouveau_winsys_softpipe.c
-
-include ./Makefile.template
-
-DRIVER_DEFINES = $(shell pkg-config libdrm --cflags \
- && pkg-config libdrm --atleast-version=2.3.1 \
- && pkg-config libdrm_nouveau --exact-version=0.5 \
- && pkg-config libdrm_nouveau --cflags \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-symlinks:
-
diff --git a/src/gallium/winsys/drm/nouveau/common/Makefile.template b/src/gallium/winsys/drm/nouveau/common/Makefile.template
deleted file mode 100644
index f0d098bb1c..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/Makefile.template
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*-makefile-*-
-
-COMMON_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/include \
- $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks lib$(LIBNAME).a
-
-
-lib$(LIBNAME).a: $(OBJECTS) Makefile Makefile.template
- $(TOP)/bin/mklib -o $(LIBNAME) -static $(OBJECTS) $(DRIVER_LIBS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean::
- -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
-
-
-include depend
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_context.c b/src/gallium/winsys/drm/nouveau/common/nouveau_context.c
deleted file mode 100644
index d6ae0827cd..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_context.c
+++ /dev/null
@@ -1,206 +0,0 @@
-#include <pipe/p_defines.h>
-#include <pipe/p_context.h>
-#include <pipe/p_screen.h>
-#include <util/u_memory.h>
-#include "nouveau_context.h"
-#include "nouveau_dri.h"
-#include "nouveau_local.h"
-#include "nouveau_screen.h"
-#include "nouveau_winsys_pipe.h"
-
-static void
-nouveau_channel_context_destroy(struct nouveau_channel_context *nvc)
-{
- nouveau_channel_free(&nvc->channel);
-
- FREE(nvc);
-}
-
-static struct nouveau_channel_context *
-nouveau_channel_context_create(struct nouveau_device *dev)
-{
- struct nouveau_channel_context *nvc;
- int ret;
-
- nvc = CALLOC_STRUCT(nouveau_channel_context);
- if (!nvc)
- return NULL;
-
- if ((ret = nouveau_channel_alloc(dev, 0x8003d001, 0x8003d002,
- &nvc->channel))) {
- NOUVEAU_ERR("Error creating GPU channel: %d\n", ret);
- nouveau_channel_context_destroy(nvc);
- return NULL;
- }
-
- nvc->next_handle = 0x77000000;
- return nvc;
-}
-
-int
-nouveau_context_init(struct nouveau_screen *nv_screen,
- drm_context_t hHWContext, drmLock *sarea_lock,
- struct nouveau_context *nv_share,
- struct nouveau_context *nv)
-{
- struct pipe_context *pipe = NULL;
- struct nouveau_channel_context *nvc = NULL;
- struct nouveau_device *dev = nv_screen->device;
- int i;
-
- switch (dev->chipset & 0xf0) {
- case 0x00:
- /* NV04 */
- case 0x10:
- case 0x20:
- /* NV10 */
- case 0x30:
- /* NV30 */
- case 0x40:
- case 0x60:
- /* NV40 */
- case 0x50:
- case 0x80:
- case 0x90:
- /* G80 */
- break;
- default:
- NOUVEAU_ERR("Unsupported chipset: NV%02x\n", dev->chipset);
- return 1;
- }
-
- nv->nv_screen = nv_screen;
-
- {
- struct nouveau_device_priv *nvdev = nouveau_device(dev);
-
- nvdev->ctx = hHWContext;
- nvdev->lock = sarea_lock;
- }
-
- /* Attempt to share a single channel between multiple contexts from
- * a single process.
- */
- nvc = nv_screen->nvc;
- if (!nvc && nv_share)
- nvc = nv_share->nvc;
-
- /*XXX: temporary - disable multi-context/single-channel on pre-NV4x */
- switch (dev->chipset & 0xf0) {
- case 0x40:
- case 0x60:
- /* NV40 class */
- case 0x50:
- case 0x80:
- case 0x90:
- /* G80 class */
- break;
- default:
- nvc = NULL;
- break;
- }
-
- if (!nvc) {
- nvc = nouveau_channel_context_create(dev);
- if (!nvc) {
- NOUVEAU_ERR("Failed initialising GPU context\n");
- return 1;
- }
- nv_screen->nvc = nvc;
- }
-
- nvc->refcount++;
- nv->nvc = nvc;
-
- /* Find a free slot for a pipe context, allocate a new one if needed */
- nv->pctx_id = -1;
- for (i = 0; i < nvc->nr_pctx; i++) {
- if (nvc->pctx[i] == NULL) {
- nv->pctx_id = i;
- break;
- }
- }
-
- if (nv->pctx_id < 0) {
- nv->pctx_id = nvc->nr_pctx++;
- nvc->pctx =
- realloc(nvc->pctx,
- sizeof(struct pipe_context *) * nvc->nr_pctx);
- }
-
- /* Create pipe */
- if (!getenv("NOUVEAU_FORCE_SOFTPIPE")) {
- struct pipe_screen *pscreen;
-
- pipe = nouveau_pipe_create(nv);
- if (!pipe)
- NOUVEAU_ERR("Couldn't create hw pipe\n");
- pscreen = nvc->pscreen;
-
- nv->cap.hw_vertex_buffer =
- pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF);
- nv->cap.hw_index_buffer =
- pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF);
- }
-
- if (!pipe) {
- NOUVEAU_MSG("Using softpipe\n");
- pipe = nouveau_create_softpipe(nv);
- if (!pipe) {
- NOUVEAU_ERR("Error creating pipe, bailing\n");
- return 1;
- }
- }
-
- {
- struct pipe_texture *fb_tex;
- struct pipe_surface *fb_surf;
- struct nouveau_pipe_buffer *fb_buf;
- enum pipe_format format;
-
- fb_buf = calloc(1, sizeof(struct nouveau_pipe_buffer));
- fb_buf->base.refcount = 1;
- fb_buf->base.usage = PIPE_BUFFER_USAGE_PIXEL;
-
- nouveau_bo_fake(dev, nv_screen->front_offset, NOUVEAU_BO_VRAM,
- nv_screen->front_pitch*nv_screen->front_height,
- NULL, &fb_buf->bo);
-
- if (nv_screen->front_cpp == 4)
- format = PIPE_FORMAT_A8R8G8B8_UNORM;
- else
- format = PIPE_FORMAT_R5G6B5_UNORM;
-
- fb_surf = nouveau_surface_buffer_ref(nv, &fb_buf->base, format,
- nv_screen->front_pitch /
- nv_screen->front_cpp,
- nv_screen->front_height,
- nv_screen->front_pitch,
- &fb_tex);
-
- nv->frontbuffer = fb_surf;
- nv->frontbuffer_texture = fb_tex;
- }
-
- pipe->priv = nv;
- return 0;
-}
-
-void
-nouveau_context_cleanup(struct nouveau_context *nv)
-{
- struct nouveau_channel_context *nvc = nv->nvc;
-
- assert(nv);
-
- if (nv->pctx_id >= 0) {
- nvc->pctx[nv->pctx_id] = NULL;
- if (--nvc->refcount <= 0) {
- nouveau_channel_context_destroy(nvc);
- nv->nv_screen->nvc = NULL;
- }
- }
-
- /* XXX: Who cleans up the pipe? */
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_context.h b/src/gallium/winsys/drm/nouveau/common/nouveau_context.h
deleted file mode 100644
index 02d2745680..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_context.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef __NOUVEAU_CONTEXT_H__
-#define __NOUVEAU_CONTEXT_H__
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau_drmif.h"
-#include "nouveau_device.h"
-#include "nouveau_channel.h"
-#include "nouveau_pushbuf.h"
-#include "nouveau_bo.h"
-#include "nouveau_grobj.h"
-#include "nouveau_notifier.h"
-#include "nouveau_class.h"
-#include "nouveau_local.h"
-
-struct nouveau_channel_context {
- struct pipe_screen *pscreen;
- int refcount;
-
- unsigned cur_pctx;
- unsigned nr_pctx;
- struct pipe_context **pctx;
-
- struct nouveau_channel *channel;
- unsigned next_handle;
-};
-
-struct nouveau_context {
- int locked;
- struct nouveau_screen *nv_screen;
- struct pipe_surface *frontbuffer;
- struct pipe_texture *frontbuffer_texture;
-
- struct {
- int hw_vertex_buffer;
- int hw_index_buffer;
- } cap;
-
- /* Hardware context */
- struct nouveau_channel_context *nvc;
- int pctx_id;
-};
-
-extern int nouveau_context_init(struct nouveau_screen *nv_screen,
- drm_context_t hHWContext, drmLock *sarea_lock,
- struct nouveau_context *nv_share,
- struct nouveau_context *nv);
-extern void nouveau_context_cleanup(struct nouveau_context *nv);
-
-extern void LOCK_HARDWARE(struct nouveau_context *);
-extern void UNLOCK_HARDWARE(struct nouveau_context *);
-
-extern uint32_t *nouveau_pipe_dma_beginp(struct nouveau_grobj *, int, int);
-extern void nouveau_pipe_dma_kickoff(struct nouveau_channel *);
-
-/* Must be provided by clients of common code */
-extern void
-nouveau_contended_lock(struct nouveau_context *nv);
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_local.h b/src/gallium/winsys/drm/nouveau/common/nouveau_local.h
deleted file mode 100644
index 11175bce7a..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_local.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __NOUVEAU_LOCAL_H__
-#define __NOUVEAU_LOCAL_H__
-
-#include "pipe/p_compiler.h"
-#include "nouveau_winsys_pipe.h"
-#include <stdio.h>
-
-/* Debug output */
-#define NOUVEAU_MSG(fmt, args...) do { \
- fprintf(stdout, "nouveau: "fmt, ##args); \
- fflush(stdout); \
-} while(0)
-
-#define NOUVEAU_ERR(fmt, args...) do { \
- fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); \
- fflush(stderr); \
-} while(0)
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_screen.c b/src/gallium/winsys/drm/nouveau/common/nouveau_screen.c
deleted file mode 100644
index 422fbf0207..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_screen.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <util/u_memory.h>
-#include "nouveau_dri.h"
-#include "nouveau_local.h"
-#include "nouveau_screen.h"
-
-int
-nouveau_screen_init(struct nouveau_dri *nv_dri, int dev_fd,
- struct nouveau_screen *nv_screen)
-{
- int ret;
-
- ret = nouveau_device_open_existing(&nv_screen->device, 0,
- dev_fd, 0);
- if (ret) {
- NOUVEAU_ERR("Failed opening nouveau device: %d\n", ret);
- return 1;
- }
-
- nv_screen->front_offset = nv_dri->front_offset;
- nv_screen->front_pitch = nv_dri->front_pitch * (nv_dri->bpp / 8);
- nv_screen->front_cpp = nv_dri->bpp / 8;
- nv_screen->front_height = nv_dri->height;
-
- return 0;
-}
-
-void
-nouveau_screen_cleanup(struct nouveau_screen *nv_screen)
-{
- nouveau_device_close(&nv_screen->device);
-}
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_screen.h b/src/gallium/winsys/drm/nouveau/common/nouveau_screen.h
deleted file mode 100644
index 3e68e219d8..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_screen.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __NOUVEAU_SCREEN_H__
-#define __NOUVEAU_SCREEN_H__
-
-#include <stdint.h>
-
-struct nouveau_device;
-struct nouveau_dri;
-
-struct nouveau_screen {
- struct nouveau_device *device;
-
- uint32_t front_offset;
- uint32_t front_pitch;
- uint32_t front_cpp;
- uint32_t front_height;
-
- void *nvc;
-};
-
-int
-nouveau_screen_init(struct nouveau_dri *nv_dri, int dev_fd,
- struct nouveau_screen *nv_screen);
-
-void
-nouveau_screen_cleanup(struct nouveau_screen *nv_screen);
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c
deleted file mode 100644
index 881df98556..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c
+++ /dev/null
@@ -1,242 +0,0 @@
-#include "pipe/internal/p_winsys_screen.h"
-#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
-#include <util/u_memory.h>
-#include "nouveau_context.h"
-#include "nouveau_local.h"
-#include "nouveau_screen.h"
-#include "nouveau_winsys_pipe.h"
-
-static const char *
-nouveau_get_name(struct pipe_winsys *pws)
-{
- return "Nouveau/DRI";
-}
-
-static uint32_t
-nouveau_flags_from_usage(struct nouveau_context *nv, unsigned usage)
-{
- struct nouveau_device *dev = nv->nv_screen->device;
- uint32_t flags = NOUVEAU_BO_LOCAL;
-
- if (usage & PIPE_BUFFER_USAGE_PIXEL) {
- if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
- flags |= NOUVEAU_BO_GART;
- if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE))
- flags |= NOUVEAU_BO_VRAM;
-
- switch (dev->chipset & 0xf0) {
- case 0x50:
- case 0x80:
- case 0x90:
- flags |= NOUVEAU_BO_TILED;
- if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
- flags |= NOUVEAU_BO_ZTILE;
- break;
- default:
- break;
- }
- }
-
- if (usage & PIPE_BUFFER_USAGE_VERTEX) {
- if (nv->cap.hw_vertex_buffer)
- flags |= NOUVEAU_BO_GART;
- }
-
- if (usage & PIPE_BUFFER_USAGE_INDEX) {
- if (nv->cap.hw_index_buffer)
- flags |= NOUVEAU_BO_GART;
- }
-
- return flags;
-}
-
-static struct pipe_buffer *
-nouveau_pipe_bo_create(struct pipe_winsys *pws, unsigned alignment,
- unsigned usage, unsigned size)
-{
- struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws;
- struct nouveau_context *nv = nvpws->nv;
- struct nouveau_device *dev = nv->nv_screen->device;
- struct nouveau_pipe_buffer *nvbuf;
- uint32_t flags;
-
- nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
- if (!nvbuf)
- return NULL;
- nvbuf->base.refcount = 1;
- nvbuf->base.alignment = alignment;
- nvbuf->base.usage = usage;
- nvbuf->base.size = size;
-
- flags = nouveau_flags_from_usage(nv, usage);
-
- if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) {
- FREE(nvbuf);
- return NULL;
- }
-
- return &nvbuf->base;
-}
-
-static struct pipe_buffer *
-nouveau_pipe_bo_user_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
-{
- struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws;
- struct nouveau_device *dev = nvpws->nv->nv_screen->device;
- struct nouveau_pipe_buffer *nvbuf;
-
- nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
- if (!nvbuf)
- return NULL;
- nvbuf->base.refcount = 1;
- nvbuf->base.size = bytes;
-
- if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) {
- FREE(nvbuf);
- return NULL;
- }
-
- return &nvbuf->base;
-}
-
-static void
-nouveau_pipe_bo_del(struct pipe_winsys *ws, struct pipe_buffer *buf)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-
- nouveau_bo_ref(NULL, &nvbuf->bo);
- FREE(nvbuf);
-}
-
-static void *
-nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
- unsigned flags)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
- uint32_t map_flags = 0;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_READ)
- map_flags |= NOUVEAU_BO_RD;
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
- map_flags |= NOUVEAU_BO_WR;
-
-#if 0
- if (flags & PIPE_BUFFER_USAGE_DISCARD &&
- !(flags & PIPE_BUFFER_USAGE_CPU_READ) &&
- nouveau_bo_busy(nvbuf->bo, map_flags)) {
- struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws;
- struct nouveau_context *nv = nvpws->nv;
- struct nouveau_device *dev = nv->nv_screen->device;
- struct nouveau_bo *rename;
- uint32_t flags = nouveau_flags_from_usage(nv, buf->usage);
-
- if (!nouveau_bo_new(dev, flags, buf->alignment, buf->size, &rename)) {
- nouveau_bo_ref(NULL, &nvbuf->bo);
- nvbuf->bo = rename;
- }
- }
-#endif
-
- if (nouveau_bo_map(nvbuf->bo, map_flags))
- return NULL;
- return nvbuf->bo->map;
-}
-
-static void
-nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-
- nouveau_bo_unmap(nvbuf->bo);
-}
-
-static void
-nouveau_pipe_fence_reference(struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *pfence)
-{
- *ptr = pfence;
-}
-
-static int
-nouveau_pipe_fence_signalled(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence, unsigned flag)
-{
- return 0;
-}
-
-static int
-nouveau_pipe_fence_finish(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence, unsigned flag)
-{
- return 0;
-}
-
-struct pipe_surface *
-nouveau_surface_buffer_ref(struct nouveau_context *nv, struct pipe_buffer *pb,
- enum pipe_format format, int w, int h,
- unsigned pitch, struct pipe_texture **ppt)
-{
- struct pipe_screen *pscreen = nv->nvc->pscreen;
- struct pipe_texture tmpl, *pt;
- struct pipe_surface *ps;
-
- memset(&tmpl, 0, sizeof(tmpl));
- tmpl.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- NOUVEAU_TEXTURE_USAGE_LINEAR;
- tmpl.target = PIPE_TEXTURE_2D;
- tmpl.width[0] = w;
- tmpl.height[0] = h;
- tmpl.depth[0] = 1;
- tmpl.format = format;
- pf_get_block(tmpl.format, &tmpl.block);
- tmpl.nblocksx[0] = pf_get_nblocksx(&tmpl.block, w);
- tmpl.nblocksy[0] = pf_get_nblocksy(&tmpl.block, h);
-
- pt = pscreen->texture_blanket(pscreen, &tmpl, &pitch, pb);
- if (!pt)
- return NULL;
-
- ps = pscreen->get_tex_surface(pscreen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
- *ppt = pt;
- return ps;
-}
-
-static void
-nouveau_destroy(struct pipe_winsys *pws)
-{
- FREE(pws);
-}
-
-struct pipe_winsys *
-nouveau_create_pipe_winsys(struct nouveau_context *nv)
-{
- struct nouveau_pipe_winsys *nvpws;
- struct pipe_winsys *pws;
-
- nvpws = CALLOC_STRUCT(nouveau_pipe_winsys);
- if (!nvpws)
- return NULL;
- nvpws->nv = nv;
- pws = &nvpws->pws;
-
- pws->flush_frontbuffer = nouveau_flush_frontbuffer;
-
- pws->buffer_create = nouveau_pipe_bo_create;
- pws->buffer_destroy = nouveau_pipe_bo_del;
- pws->user_buffer_create = nouveau_pipe_bo_user_create;
- pws->buffer_map = nouveau_pipe_bo_map;
- pws->buffer_unmap = nouveau_pipe_bo_unmap;
-
- pws->fence_reference = nouveau_pipe_fence_reference;
- pws->fence_signalled = nouveau_pipe_fence_signalled;
- pws->fence_finish = nouveau_pipe_fence_finish;
-
- pws->get_name = nouveau_get_name;
- pws->destroy = nouveau_destroy;
-
- return &nvpws->pws;
-}
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.h
deleted file mode 100644
index 1eb8043478..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef NOUVEAU_PIPE_WINSYS_H
-#define NOUVEAU_PIPE_WINSYS_H
-
-#include "pipe/p_context.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "nouveau_context.h"
-
-struct nouveau_pipe_buffer {
- struct pipe_buffer base;
- struct nouveau_bo *bo;
-};
-
-static INLINE struct nouveau_pipe_buffer *
-nouveau_pipe_buffer(struct pipe_buffer *buf)
-{
- return (struct nouveau_pipe_buffer *)buf;
-}
-
-struct nouveau_pipe_winsys {
- struct pipe_winsys pws;
-
- struct nouveau_context *nv;
-};
-
-extern struct pipe_winsys *
-nouveau_create_pipe_winsys(struct nouveau_context *nv);
-
-struct pipe_context *
-nouveau_create_softpipe(struct nouveau_context *nv);
-
-struct pipe_context *
-nouveau_pipe_create(struct nouveau_context *nv);
-
-/* Must be provided by clients of common code */
-extern void
-nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
- void *context_private);
-
-struct pipe_surface *
-nouveau_surface_buffer_ref(struct nouveau_context *nv, struct pipe_buffer *pb,
- enum pipe_format format, int w, int h,
- unsigned pitch, struct pipe_texture **ppt);
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_softpipe.c b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_softpipe.c
deleted file mode 100644
index 396e4f2a2e..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_softpipe.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include "pipe/internal/p_winsys_screen.h"
-#include <pipe/p_screen.h>
-#include <pipe/p_defines.h>
-#include <pipe/p_format.h>
-#include <softpipe/sp_winsys.h>
-#include <util/u_memory.h>
-#include "nouveau_context.h"
-#include "nouveau_winsys_pipe.h"
-
-struct nouveau_softpipe_winsys {
- struct softpipe_winsys sws;
- struct nouveau_context *nv;
-};
-
-/**
- * Return list of surface formats supported by this driver.
- */
-static boolean
-nouveau_is_format_supported(struct softpipe_winsys *sws,
- enum pipe_format format)
-{
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_Z24S8_UNORM:
- return TRUE;
- default:
- break;
- };
-
- return FALSE;
-}
-
-struct pipe_context *
-nouveau_create_softpipe(struct nouveau_context *nv)
-{
- struct nouveau_softpipe_winsys *nvsws;
- struct pipe_screen *pscreen;
- struct pipe_winsys *ws;
- struct pipe_context *pipe;
-
- ws = nouveau_create_pipe_winsys(nv);
- if (!ws)
- return NULL;
- pscreen = softpipe_create_screen(ws);
- if (!pscreen) {
- ws->destroy(ws);
- return NULL;
- }
- nvsws = CALLOC_STRUCT(nouveau_softpipe_winsys);
- if (!nvsws) {
- ws->destroy(ws);
- pscreen->destroy(pscreen);
- return NULL;
- }
-
- nvsws->sws.is_format_supported = nouveau_is_format_supported;
- nvsws->nv = nv;
-
- pipe = softpipe_create(pscreen, ws, &nvsws->sws);
- if (!pipe) {
- ws->destroy(ws);
- pscreen->destroy(pscreen);
- FREE(nvsws);
- return NULL;
- }
-
- return pipe;
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile
index 3f3553b61d..f7db6201fe 100644
--- a/src/gallium/winsys/drm/nouveau/dri/Makefile
+++ b/src/gallium/winsys/drm/nouveau/dri/Makefile
@@ -6,19 +6,19 @@ LIBNAME = nouveau_dri.so
MINIGLX_SOURCES =
PIPE_DRIVERS = \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
$(TOP)/src/gallium/drivers/nv04/libnv04.a \
$(TOP)/src/gallium/drivers/nv10/libnv10.a \
$(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a
-
+
DRIVER_SOURCES = \
- nouveau_context_dri.c \
- nouveau_screen_dri.c \
+ nouveau_context.c \
+ nouveau_screen.c \
nouveau_swapbuffers.c \
- ../common/libnouveaudrm.a
+ nouveau_lock.c
C_SOURCES = \
$(COMMON_GALLIUM_SOURCES) \
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c
index aacfe984d1..deb6ffcff1 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.c
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c
@@ -5,23 +5,15 @@
#include <state_tracker/st_public.h>
#include <state_tracker/st_context.h>
+#include <state_tracker/drm_api.h>
#include <pipe/p_defines.h>
#include <pipe/p_context.h>
#include <pipe/p_screen.h>
-#include "../common/nouveau_winsys_pipe.h"
-#include "../common/nouveau_dri.h"
-#include "../common/nouveau_local.h"
-#include "nouveau_context_dri.h"
-#include "nouveau_screen_dri.h"
+#include "nouveau_context.h"
+#include "nouveau_screen.h"
-#ifdef DEBUG
-static const struct dri_debug_control debug_control[] = {
- { "bo", DEBUG_BO },
- { NULL, 0 }
-};
-int __nouveau_debug = 0;
-#endif
+#include "nouveau_drmif.h"
GLboolean
nouveau_context_create(const __GLcontextModes *glVis,
@@ -29,34 +21,38 @@ nouveau_context_create(const __GLcontextModes *glVis,
void *sharedContextPrivate)
{
__DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv;
- struct nouveau_screen_dri *nv_screen = driScrnPriv->private;
- struct nouveau_context_dri *nv = CALLOC_STRUCT(nouveau_context_dri);
- struct st_context *st_share = NULL;
- struct nouveau_context_dri *nv_share = NULL;
+ struct nouveau_screen *nv_screen = driScrnPriv->private;
+ struct nouveau_context *nv;
struct pipe_context *pipe;
+ struct st_context *st_share = NULL;
- if (sharedContextPrivate) {
- st_share = ((struct nouveau_context_dri *)sharedContextPrivate)->st;
- nv_share = st_share->pipe->priv;
+ if (sharedContextPrivate)
+ st_share = ((struct nouveau_context *)sharedContextPrivate)->st;
+
+ nv = CALLOC_STRUCT(nouveau_context);
+ if (!nv)
+ return GL_FALSE;
+
+ {
+ struct nouveau_device_priv *nvdev =
+ nouveau_device(nv_screen->device);
+
+ nvdev->ctx = driContextPriv->hHWContext;
+ nvdev->lock = (drmLock *)&driScrnPriv->pSAREA->lock;
}
- if (nouveau_context_init(&nv_screen->base, driContextPriv->hHWContext,
- (drmLock *)&driScrnPriv->pSAREA->lock,
- &nv_share->base, &nv->base)) {
+ pipe = drm_api_hooks.create_context(nv_screen->pscreen);
+ if (!pipe) {
+ FREE(nv);
return GL_FALSE;
}
+ pipe->priv = nv;
- pipe = nv->base.nvc->pctx[nv->base.pctx_id];
- driContextPriv->driverPrivate = (void *)nv;
- //nv->nv_screen = nv_screen;
+ driContextPriv->driverPrivate = nv;
nv->dri_screen = driScrnPriv;
driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache,
nv->dri_screen->myNum, "nouveau");
-#ifdef DEBUG
- __nouveau_debug = driParseDebugString(getenv("NOUVEAU_DEBUG"),
- debug_control);
-#endif
nv->st = st_create_context(pipe, glVis, st_share);
return GL_TRUE;
@@ -65,15 +61,13 @@ nouveau_context_create(const __GLcontextModes *glVis,
void
nouveau_context_destroy(__DRIcontextPrivate *driContextPriv)
{
- struct nouveau_context_dri *nv = driContextPriv->driverPrivate;
+ struct nouveau_context *nv = driContextPriv->driverPrivate;
assert(nv);
st_finish(nv->st);
st_destroy_context(nv->st);
- nouveau_context_cleanup(&nv->base);
-
FREE(nv);
}
@@ -82,7 +76,7 @@ nouveau_context_bind(__DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv)
{
- struct nouveau_context_dri *nv;
+ struct nouveau_context *nv;
struct nouveau_framebuffer *draw, *read;
if (!driContextPriv) {
@@ -115,7 +109,7 @@ nouveau_context_bind(__DRIcontextPrivate *driContextPriv,
GLboolean
nouveau_context_unbind(__DRIcontextPrivate *driContextPriv)
{
- struct nouveau_context_dri *nv = driContextPriv->driverPrivate;
+ struct nouveau_context *nv = driContextPriv->driverPrivate;
(void)nv;
st_flush(nv->st, 0, NULL);
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h
index 64cf326411..2779b092e6 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.h
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h
@@ -3,15 +3,16 @@
#include <dri_util.h>
#include <xmlconfig.h>
-#include <nouveau/nouveau_winsys.h>
-#include "../common/nouveau_context.h"
+
+#include "nouveau/nouveau_winsys.h"
+
+#define NOUVEAU_ERR(fmt, args...) debug_printf("%s: "fmt, __func__, ##args)
struct nouveau_framebuffer {
struct st_framebuffer *stfb;
};
-struct nouveau_context_dri {
- struct nouveau_context base;
+struct nouveau_context {
struct st_context *st;
/* DRI stuff */
@@ -21,6 +22,7 @@ struct nouveau_context_dri {
driOptionCache dri_option_cache;
drm_context_t drm_context;
drmLock drm_lock;
+ int locked;
};
extern GLboolean nouveau_context_create(const __GLcontextModes *,
@@ -31,6 +33,10 @@ extern GLboolean nouveau_context_bind(__DRIcontextPrivate *,
__DRIdrawablePrivate *read);
extern GLboolean nouveau_context_unbind(__DRIcontextPrivate *);
+extern void nouveau_contended_lock(struct nouveau_context *nv);
+extern void LOCK_HARDWARE(struct nouveau_context *nv);
+extern void UNLOCK_HARDWARE(struct nouveau_context *nv);
+
#ifdef DEBUG
extern int __nouveau_debug;
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_dri.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h
index 1207c2d609..1207c2d609 100644
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_dri.h
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_lock.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c
index e8cf051ed9..92f5bd09c9 100644
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_lock.c
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c
@@ -28,6 +28,7 @@
#include <pipe/p_thread.h>
#include "nouveau_context.h"
#include "nouveau_screen.h"
+#include "nouveau_drmif.h"
pipe_static_mutex(lockMutex);
@@ -36,7 +37,7 @@ pipe_static_mutex(lockMutex);
void
LOCK_HARDWARE(struct nouveau_context *nv)
{
- struct nouveau_screen *nv_screen = nv->nv_screen;
+ struct nouveau_screen *nv_screen = nv->dri_screen->private;
struct nouveau_device *dev = nv_screen->device;
struct nouveau_device_priv *nvdev = nouveau_device(dev);
char __ret=0;
@@ -59,7 +60,7 @@ LOCK_HARDWARE(struct nouveau_context *nv)
void
UNLOCK_HARDWARE(struct nouveau_context *nv)
{
- struct nouveau_screen *nv_screen = nv->nv_screen;
+ struct nouveau_screen *nv_screen = nv->dri_screen->private;
struct nouveau_device *dev = nv_screen->device;
struct nouveau_device_priv *nvdev = nouveau_device(dev);
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c
index 964a9028aa..c4cbbc2124 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.c
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c
@@ -5,12 +5,15 @@
#include <pipe/p_context.h>
#include <state_tracker/st_public.h>
#include <state_tracker/st_cb_fbo.h>
-#include <nouveau_drm.h>
-#include "../common/nouveau_dri.h"
-#include "../common/nouveau_local.h"
-#include "nouveau_context_dri.h"
-#include "nouveau_screen_dri.h"
+#include <state_tracker/drm_api.h>
+
+#include "nouveau_context.h"
+#include "nouveau_screen.h"
#include "nouveau_swapbuffers.h"
+#include "nouveau_dri.h"
+
+#include "nouveau_drm.h"
+#include "nouveau_drmif.h"
#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12
#error nouveau_drm.h version does not match expected version
@@ -178,11 +181,58 @@ nouveau_fill_in_modes(__DRIscreenPrivate *psp,
return configs;
}
+static struct pipe_surface *
+dri_surface_from_handle(struct pipe_screen *screen,
+ unsigned handle,
+ enum pipe_format format,
+ unsigned width,
+ unsigned height,
+ unsigned pitch)
+{
+ struct pipe_surface *surface = NULL;
+ struct pipe_texture *texture = NULL;
+ struct pipe_texture templat;
+ struct pipe_buffer *buf = NULL;
+
+ buf = drm_api_hooks.buffer_from_handle(screen, "front buffer", handle);
+ if (!buf)
+ return NULL;
+
+ memset(&templat, 0, sizeof(templat));
+ templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ templat.target = PIPE_TEXTURE_2D;
+ templat.last_level = 0;
+ templat.depth[0] = 1;
+ templat.format = format;
+ templat.width[0] = width;
+ templat.height[0] = height;
+ pf_get_block(templat.format, &templat.block);
+
+ texture = screen->texture_blanket(screen,
+ &templat,
+ &pitch,
+ buf);
+
+ /* we don't need the buffer from this point on */
+ pipe_buffer_reference(&buf, NULL);
+
+ if (!texture)
+ return NULL;
+
+ surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+
+ /* we don't need the texture from this point on */
+ pipe_texture_reference(&texture, NULL);
+ return surface;
+}
+
static const __DRIconfig **
nouveau_screen_create(__DRIscreenPrivate *psp)
{
struct nouveau_dri *nv_dri = psp->pDevPriv;
- struct nouveau_screen_dri *nv_screen;
+ struct nouveau_screen *nv_screen;
static const __DRIversion ddx_expected =
{ 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
static const __DRIversion dri_expected = { 4, 0, 0 };
@@ -210,17 +260,38 @@ nouveau_screen_create(__DRIscreenPrivate *psp)
return NULL;
}
- nv_screen = CALLOC_STRUCT(nouveau_screen_dri);
+ nv_screen = CALLOC_STRUCT(nouveau_screen);
if (!nv_screen)
return NULL;
- driParseOptionInfo(&nv_screen->option_cache,
- __driConfigOptions, __driNConfigOptions);
+ nouveau_device_open_existing(&nv_screen->device, 0, psp->fd, 0);
- if (nouveau_screen_init(nv_dri, psp->fd, &nv_screen->base)) {
+ nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, 0);
+ if (!nv_screen->pscreen) {
FREE(nv_screen);
return NULL;
}
+ nv_screen->pscreen->flush_frontbuffer = nouveau_flush_frontbuffer;
+
+ {
+ enum pipe_format format;
+
+ if (nv_dri->bpp == 16)
+ format = PIPE_FORMAT_R5G6B5_UNORM;
+ else
+ format = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+ nv_screen->fb = dri_surface_from_handle(nv_screen->pscreen,
+ nv_dri->front_offset,
+ format,
+ nv_dri->width,
+ nv_dri->height,
+ nv_dri->front_pitch *
+ nv_dri->bpp / 8);
+ }
+
+ driParseOptionInfo(&nv_screen->option_cache,
+ __driConfigOptions, __driNConfigOptions);
nv_screen->driScrnPriv = psp;
psp->private = (void *)nv_screen;
@@ -234,10 +305,9 @@ nouveau_screen_create(__DRIscreenPrivate *psp)
static void
nouveau_screen_destroy(__DRIscreenPrivate *driScrnPriv)
{
- struct nouveau_screen_dri *nv_screen = driScrnPriv->private;
+ struct nouveau_screen *nv_screen = driScrnPriv->private;
driScrnPriv->private = NULL;
- nouveau_screen_cleanup(&nv_screen->base);
FREE(nv_screen);
}
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h
index 1498087819..ac078f3c63 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.h
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h
@@ -1,13 +1,16 @@
#ifndef __NOUVEAU_SCREEN_DRI_H__
#define __NOUVEAU_SCREEN_DRI_H__
-#include "../common/nouveau_screen.h"
#include "xmlconfig.h"
-struct nouveau_screen_dri {
- struct nouveau_screen base;
+struct nouveau_screen {
__DRIscreenPrivate *driScrnPriv;
driOptionCache option_cache;
+
+ struct nouveau_device *device;
+
+ struct pipe_screen *pscreen;
+ struct pipe_surface *fb;
};
#endif
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c
index 58cb6f7265..9c841a0b2d 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c
@@ -7,23 +7,25 @@
#include <state_tracker/st_context.h>
#include <state_tracker/st_cb_fbo.h>
-#include "../common/nouveau_local.h"
-#include "nouveau_context_dri.h"
-#include "nouveau_screen_dri.h"
+#include "nouveau_context.h"
+#include "nouveau_screen.h"
#include "nouveau_swapbuffers.h"
+#include "nouveau_pushbuf.h"
+
void
nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
const drm_clip_rect_t *rect)
{
- struct nouveau_context_dri *nv = dPriv->driContextPriv->driverPrivate;
- struct pipe_context *pipe = nv->base.nvc->pctx[nv->base.pctx_id];
+ struct nouveau_context *nv = dPriv->driContextPriv->driverPrivate;
+ struct nouveau_screen *nv_screen = nv->dri_screen->private;
+ struct pipe_context *pipe = nv->st->pipe;
drm_clip_rect_t *pbox;
int nbox, i;
- LOCK_HARDWARE(&nv->base);
+ LOCK_HARDWARE(nv);
if (!dPriv->numClipRects) {
- UNLOCK_HARDWARE(&nv->base);
+ UNLOCK_HARDWARE(nv);
return;
}
pbox = dPriv->pClipRects;
@@ -39,12 +41,12 @@ nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
- pipe->surface_copy(pipe, FALSE, nv->base.frontbuffer,
- dx, dy, surf, sx, sy, w, h);
+ pipe->surface_copy(pipe, nv_screen->fb, dx, dy, surf,
+ sx, sy, w, h);
}
- FIRE_RING(nv->base.nvc->channel);
- UNLOCK_HARDWARE(&nv->base);
+ pipe->flush(pipe, 0, NULL);
+ UNLOCK_HARDWARE(nv);
if (nv->last_stamp != dPriv->lastStamp) {
struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
@@ -86,19 +88,19 @@ nouveau_swap_buffers(__DRIdrawablePrivate *dPriv)
}
void
-nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
+nouveau_flush_frontbuffer(struct pipe_screen *pscreen, struct pipe_surface *ps,
void *context_private)
{
- struct nouveau_context_dri *nv = context_private;
+ struct nouveau_context *nv = context_private;
__DRIdrawablePrivate *dPriv = nv->dri_drawable;
- nouveau_copy_buffer(dPriv, surf, NULL);
+ nouveau_copy_buffer(dPriv, ps, NULL);
}
void
nouveau_contended_lock(struct nouveau_context *nv)
{
- struct nouveau_context_dri *nv_sub = (struct nouveau_context_dri*)nv;
+ struct nouveau_context *nv_sub = (struct nouveau_context*)nv;
__DRIdrawablePrivate *dPriv = nv_sub->dri_drawable;
__DRIscreenPrivate *sPriv = nv_sub->dri_screen;
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h
index 825d3da6da..4ca9cc2283 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h
@@ -1,10 +1,11 @@
#ifndef __NOUVEAU_SWAPBUFFERS_H__
#define __NOUVEAU_SWAPBUFFERS_H__
-extern void nouveau_copy_buffer(__DRIdrawablePrivate *, struct pipe_surface *,
- const drm_clip_rect_t *);
-extern void nouveau_copy_sub_buffer(__DRIdrawablePrivate *,
- int x, int y, int w, int h);
-extern void nouveau_swap_buffers(__DRIdrawablePrivate *);
+void nouveau_copy_buffer(__DRIdrawablePrivate *, struct pipe_surface *,
+ const drm_clip_rect_t *);
+void nouveau_copy_sub_buffer(__DRIdrawablePrivate *, int x, int y, int w, int h);
+void nouveau_swap_buffers(__DRIdrawablePrivate *);
+void nouveau_flush_frontbuffer(struct pipe_screen *, struct pipe_surface *,
+ void *context_private);
#endif
diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile
new file mode 100644
index 0000000000..728870d2e1
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/dri2/Makefile
@@ -0,0 +1,26 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = nouveau_dri2.so
+
+PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \
+ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
+ $(TOP)/src/gallium/drivers/nv04/libnv04.a \
+ $(TOP)/src/gallium/drivers/nv10/libnv10.a \
+ $(TOP)/src/gallium/drivers/nv20/libnv20.a \
+ $(TOP)/src/gallium/drivers/nv30/libnv30.a \
+ $(TOP)/src/gallium/drivers/nv40/libnv40.a \
+ $(TOP)/src/gallium/drivers/nv50/libnv50.a
+
+DRIVER_SOURCES =
+
+C_SOURCES = \
+ $(COMMON_GALLIUM_SOURCES) \
+ $(DRIVER_SOURCES)
+
+include ../../Makefile.template
+
+DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
+
+symlinks:
diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile
new file mode 100644
index 0000000000..2da78d8690
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/Makefile
@@ -0,0 +1,13 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = nouveaudrm
+
+C_SOURCES = nouveau_drm_api.c \
+ nouveau_winsys_pipe.c \
+ nouveau_winsys.c
+
+LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I)
+LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
+
+include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
new file mode 100644
index 0000000000..c0127e803f
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
@@ -0,0 +1,194 @@
+#include "util/u_memory.h"
+
+#include "nouveau_drm_api.h"
+#include "nouveau_winsys_pipe.h"
+
+#include "nouveau_drmif.h"
+#include "nouveau_channel.h"
+#include "nouveau_bo.h"
+
+static struct pipe_screen *
+nouveau_drm_create_screen(int fd, int pciid)
+{
+ struct pipe_winsys *ws;
+ struct nouveau_winsys *nvws;
+ struct nouveau_device *dev = NULL;
+ struct pipe_screen *(*init)(struct pipe_winsys *,
+ struct nouveau_winsys *);
+ int ret;
+
+ ret = nouveau_device_open_existing(&dev, 0, fd, 0);
+ if (ret)
+ 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;
+ case 0x40:
+ case 0x60:
+ init = nv40_screen_create;
+ break;
+ case 0x80:
+ case 0x90:
+ case 0xa0:
+ init = nv50_screen_create;
+ break;
+ default:
+ debug_printf("%s: unknown chipset nv%02x\n", __func__,
+ dev->chipset);
+ return NULL;
+ }
+
+ ws = nouveau_pipe_winsys_new(dev);
+ if (!ws) {
+ nouveau_device_close(&dev);
+ return NULL;
+ }
+
+ nvws = nouveau_winsys_new(ws);
+ if (!nvws) {
+ ws->destroy(ws);
+ return NULL;
+ }
+
+ nouveau_pipe_winsys(ws)->pscreen = init(ws, nvws);
+ if (!nouveau_pipe_winsys(ws)->pscreen) {
+ ws->destroy(ws);
+ return NULL;
+ }
+
+ return nouveau_pipe_winsys(ws)->pscreen;
+}
+
+static struct pipe_context *
+nouveau_drm_create_context(struct pipe_screen *pscreen)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen);
+ struct pipe_context *(*init)(struct pipe_screen *, unsigned);
+ unsigned chipset = nvpws->channel->device->chipset;
+ 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;
+ case 0x40:
+ case 0x60:
+ init = nv40_create;
+ break;
+ case 0x80:
+ case 0x90:
+ case 0xa0:
+ init = nv50_create;
+ break;
+ default:
+ debug_printf("%s: unknown chipset nv%02x\n", __func__, chipset);
+ return NULL;
+ }
+
+ /* Find a free slot for a pipe context, allocate a new one if needed */
+ for (i = 0; i < nvpws->nr_pctx; i++) {
+ if (nvpws->pctx[i] == NULL)
+ break;
+ }
+
+ if (i == nvpws->nr_pctx) {
+ nvpws->nr_pctx++;
+ nvpws->pctx = realloc(nvpws->pctx,
+ sizeof(*nvpws->pctx) * nvpws->nr_pctx);
+ }
+
+ nvpws->pctx[i] = init(pscreen, i);
+ return nvpws->pctx[i];
+}
+
+static boolean
+nouveau_drm_pb_from_pt(struct pipe_texture *pt, struct pipe_buffer **ppb,
+ unsigned *stride)
+{
+ return false;
+}
+
+static struct pipe_buffer *
+nouveau_drm_pb_from_handle(struct pipe_screen *pscreen, const char *name,
+ unsigned handle)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen);
+ struct nouveau_device *dev = nvpws->channel->device;
+ struct nouveau_pipe_buffer *nvpb;
+ int ret;
+
+ nvpb = CALLOC_STRUCT(nouveau_pipe_buffer);
+ if (!nvpb)
+ return NULL;
+
+ ret = nouveau_bo_handle_ref(dev, handle, &nvpb->bo);
+ if (ret) {
+ debug_printf("%s: ref name 0x%08x failed with %d\n",
+ __func__, handle, ret);
+ FREE(nvpb);
+ return NULL;
+ }
+
+ pipe_reference_init(&nvpb->base.reference, 1);
+ nvpb->base.screen = pscreen;
+ nvpb->base.alignment = 0;
+ nvpb->base.usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE |
+ PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ nvpb->base.size = nvpb->bo->size;
+ return &nvpb->base;
+}
+
+static boolean
+nouveau_drm_handle_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb,
+ unsigned *handle)
+{
+ struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb);
+
+ if (!nvpb)
+ return FALSE;
+
+ *handle = nvpb->bo->handle;
+ return TRUE;
+}
+
+static boolean
+nouveau_drm_name_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb,
+ unsigned *handle)
+{
+ struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb);
+
+ if (!nvpb)
+ return FALSE;
+
+ return nouveau_bo_handle_get(nvpb->bo, handle) == 0;
+}
+
+struct drm_api drm_api_hooks = {
+ .create_screen = nouveau_drm_create_screen,
+ .create_context = nouveau_drm_create_context,
+ .buffer_from_texture = nouveau_drm_pb_from_pt,
+ .buffer_from_handle = nouveau_drm_pb_from_handle,
+ .handle_from_buffer = nouveau_drm_handle_from_pb,
+ .global_handle_from_buffer = nouveau_drm_name_from_pb,
+};
+
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
new file mode 100644
index 0000000000..2782c83c0e
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
@@ -0,0 +1,5 @@
+#ifndef __NOUVEAU_DRM_API_H__
+#define __NOUVEAU_DRM_API_H__
+#include "state_tracker/drm_api.h"
+
+#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c
index b6199f8e6d..e3175fd775 100644
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys.c
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c
@@ -1,18 +1,14 @@
#include "util/u_memory.h"
-#include "nouveau_context.h"
-#include "nouveau_screen.h"
#include "nouveau_winsys_pipe.h"
-#include "nouveau/nouveau_winsys.h"
-
static int
nouveau_pipe_notifier_alloc(struct nouveau_winsys *nvws, int count,
struct nouveau_notifier **notify)
{
- struct nouveau_context *nv = nvws->nv;
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws);
- return nouveau_notifier_alloc(nv->nvc->channel, nv->nvc->next_handle++,
+ return nouveau_notifier_alloc(nvpws->channel, nvpws->next_handle++,
count, notify);
}
@@ -20,12 +16,11 @@ static int
nouveau_pipe_grobj_alloc(struct nouveau_winsys *nvws, int grclass,
struct nouveau_grobj **grobj)
{
- struct nouveau_context *nv = nvws->nv;
- struct nouveau_channel *chan = nv->nvc->channel;
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws);
+ struct nouveau_channel *chan = nvpws->channel;
int ret;
- ret = nouveau_grobj_alloc(chan, nv->nvc->next_handle++,
- grclass, grobj);
+ ret = nouveau_grobj_alloc(chan, nvpws->next_handle++, grclass, grobj);
if (ret)
return ret;
@@ -62,55 +57,18 @@ nouveau_pipe_get_bo(struct pipe_buffer *pb)
return nouveau_pipe_buffer(pb)->bo;
}
-struct pipe_context *
-nouveau_pipe_create(struct nouveau_context *nv)
+struct nouveau_winsys *
+nouveau_winsys_new(struct pipe_winsys *ws)
{
- struct nouveau_channel_context *nvc = nv->nvc;
- struct nouveau_winsys *nvws = CALLOC_STRUCT(nouveau_winsys);
- struct pipe_screen *(*hws_create)(struct pipe_winsys *,
- struct nouveau_winsys *);
- struct pipe_context *(*hw_create)(struct pipe_screen *, unsigned);
- struct pipe_winsys *ws;
- unsigned chipset = nv->nv_screen->device->chipset;
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+ struct nouveau_winsys *nvws;
+ nvws = CALLOC_STRUCT(nouveau_winsys);
if (!nvws)
return NULL;
- switch (chipset & 0xf0) {
- case 0x00:
- hws_create = nv04_screen_create;
- hw_create = nv04_create;
- break;
- case 0x10:
- hws_create = nv10_screen_create;
- hw_create = nv10_create;
- break;
- case 0x20:
- hws_create = nv20_screen_create;
- hw_create = nv20_create;
- break;
- case 0x30:
- hws_create = nv30_screen_create;
- hw_create = nv30_create;
- break;
- case 0x40:
- case 0x60:
- hws_create = nv40_screen_create;
- hw_create = nv40_create;
- break;
- case 0x50:
- case 0x80:
- case 0x90:
- hws_create = nv50_screen_create;
- hw_create = nv50_create;
- break;
- default:
- NOUVEAU_ERR("Unknown chipset NV%02x\n", chipset);
- return NULL;
- }
-
- nvws->nv = nv;
- nvws->channel = nv->nvc->channel;
+ nvws->ws = ws;
+ nvws->channel = nvpws->channel;
nvws->res_init = nouveau_resource_init;
nvws->res_alloc = nouveau_resource_alloc;
@@ -131,11 +89,6 @@ nouveau_pipe_create(struct nouveau_context *nv)
nvws->get_bo = nouveau_pipe_get_bo;
- ws = nouveau_create_pipe_winsys(nv);
-
- if (!nvc->pscreen)
- nvc->pscreen = hws_create(ws, nvws);
- nvc->pctx[nv->pctx_id] = hw_create(nvc->pscreen, nv->pctx_id);
- return nvc->pctx[nv->pctx_id];
+ return nvws;
}
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c
new file mode 100644
index 0000000000..9e03a9f5db
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c
@@ -0,0 +1,204 @@
+#include "pipe/internal/p_winsys_screen.h"
+#include <pipe/p_defines.h>
+#include <pipe/p_inlines.h>
+#include <util/u_memory.h>
+
+#include "nouveau_winsys_pipe.h"
+
+#include "nouveau_drmif.h"
+#include "nouveau_bo.h"
+
+static const char *
+nouveau_get_name(struct pipe_winsys *pws)
+{
+ return "Nouveau/DRI";
+}
+
+static uint32_t
+nouveau_flags_from_usage(struct pipe_winsys *ws, unsigned usage)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+ struct pipe_screen *pscreen = nvpws->pscreen;
+ uint32_t flags = NOUVEAU_BO_LOCAL;
+
+ if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER)
+ flags |= NOUVEAU_BO_GART;
+
+ if (usage & PIPE_BUFFER_USAGE_PIXEL) {
+ if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
+ flags |= NOUVEAU_BO_GART;
+ if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE))
+ flags |= NOUVEAU_BO_VRAM;
+
+ switch (nvpws->channel->device->chipset & 0xf0) {
+ case 0x50:
+ case 0x80:
+ case 0x90:
+ flags |= NOUVEAU_BO_TILED;
+ if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
+ flags |= NOUVEAU_BO_ZTILE;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+ if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF))
+ flags |= NOUVEAU_BO_GART;
+ }
+
+ if (usage & PIPE_BUFFER_USAGE_INDEX) {
+ if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF))
+ flags |= NOUVEAU_BO_GART;
+ }
+
+ return flags;
+}
+
+static struct pipe_buffer *
+nouveau_pipe_bo_create(struct pipe_winsys *ws, unsigned alignment,
+ unsigned usage, unsigned size)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+ struct nouveau_device *dev = nvpws->channel->device;
+ struct nouveau_pipe_buffer *nvbuf;
+ uint32_t flags;
+
+ nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
+ if (!nvbuf)
+ return NULL;
+ pipe_reference_init(&nvbuf->base.reference, 1);
+ nvbuf->base.alignment = alignment;
+ nvbuf->base.usage = usage;
+ nvbuf->base.size = size;
+
+ flags = nouveau_flags_from_usage(ws, usage);
+ if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) {
+ FREE(nvbuf);
+ return NULL;
+ }
+
+ return &nvbuf->base;
+}
+
+static struct pipe_buffer *
+nouveau_pipe_bo_user_create(struct pipe_winsys *ws, void *ptr, unsigned bytes)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+ struct nouveau_device *dev = nvpws->channel->device;
+ struct nouveau_pipe_buffer *nvbuf;
+
+ nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
+ if (!nvbuf)
+ return NULL;
+ pipe_reference_init(&nvbuf->base.reference, 1);
+ nvbuf->base.size = bytes;
+
+ if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) {
+ FREE(nvbuf);
+ return NULL;
+ }
+
+ return &nvbuf->base;
+}
+
+static void
+nouveau_pipe_bo_del(struct pipe_buffer *buf)
+{
+ struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
+
+ nouveau_bo_ref(NULL, &nvbuf->bo);
+ FREE(nvbuf);
+}
+
+static void *
+nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
+ unsigned flags)
+{
+ struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
+ uint32_t map_flags = 0;
+
+ if (flags & PIPE_BUFFER_USAGE_CPU_READ)
+ map_flags |= NOUVEAU_BO_RD;
+ if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
+ map_flags |= NOUVEAU_BO_WR;
+
+ if (nouveau_bo_map(nvbuf->bo, map_flags))
+ return NULL;
+ return nvbuf->bo->map;
+}
+
+static void
+nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
+{
+ struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
+
+ nouveau_bo_unmap(nvbuf->bo);
+}
+
+static void
+nouveau_pipe_fence_reference(struct pipe_winsys *ws,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *pfence)
+{
+ *ptr = pfence;
+}
+
+static int
+nouveau_pipe_fence_signalled(struct pipe_winsys *ws,
+ struct pipe_fence_handle *pfence, unsigned flag)
+{
+ return 0;
+}
+
+static int
+nouveau_pipe_fence_finish(struct pipe_winsys *ws,
+ struct pipe_fence_handle *pfence, unsigned flag)
+{
+ return 0;
+}
+
+static void
+nouveau_destroy(struct pipe_winsys *ws)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+
+ nouveau_device_close(&nvpws->channel->device);
+ FREE(nvpws);
+}
+
+struct pipe_winsys *
+nouveau_pipe_winsys_new(struct nouveau_device *dev)
+{
+ struct nouveau_pipe_winsys *nvpws;
+ int ret;
+
+ nvpws = CALLOC_STRUCT(nouveau_pipe_winsys);
+ if (!nvpws)
+ return NULL;
+
+ ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202,
+ &nvpws->channel);
+ if (ret) {
+ debug_printf("%s: error opening GPU channel: %d\n",
+ __func__, ret);
+ FREE(nvpws);
+ return NULL;
+ }
+ nvpws->next_handle = 0x77000000;
+
+ nvpws->base.buffer_create = nouveau_pipe_bo_create;
+ nvpws->base.buffer_destroy = nouveau_pipe_bo_del;
+ nvpws->base.user_buffer_create = nouveau_pipe_bo_user_create;
+ nvpws->base.buffer_map = nouveau_pipe_bo_map;
+ nvpws->base.buffer_unmap = nouveau_pipe_bo_unmap;
+
+ nvpws->base.fence_reference = nouveau_pipe_fence_reference;
+ nvpws->base.fence_signalled = nouveau_pipe_fence_signalled;
+ nvpws->base.fence_finish = nouveau_pipe_fence_finish;
+
+ nvpws->base.get_name = nouveau_get_name;
+ nvpws->base.destroy = nouveau_destroy;
+ return &nvpws->base;
+}
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h
new file mode 100644
index 0000000000..10e1e269e8
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h
@@ -0,0 +1,52 @@
+#ifndef NOUVEAU_PIPE_WINSYS_H
+#define NOUVEAU_PIPE_WINSYS_H
+
+#include "pipe/internal/p_winsys_screen.h"
+#include "pipe/p_context.h"
+
+#include "nouveau/nouveau_winsys.h"
+
+#include "nouveau_device.h"
+
+struct nouveau_pipe_buffer {
+ struct pipe_buffer base;
+ struct nouveau_bo *bo;
+};
+
+static INLINE struct nouveau_pipe_buffer *
+nouveau_pipe_buffer(struct pipe_buffer *buf)
+{
+ return (struct nouveau_pipe_buffer *)buf;
+}
+
+struct nouveau_pipe_winsys {
+ struct pipe_winsys base;
+
+ struct pipe_screen *pscreen;
+
+ struct nouveau_channel *channel;
+ uint32_t next_handle;
+
+ unsigned nr_pctx;
+ struct pipe_context **pctx;
+};
+
+static INLINE struct nouveau_pipe_winsys *
+nouveau_pipe_winsys(struct pipe_winsys *ws)
+{
+ return (struct nouveau_pipe_winsys *)ws;
+}
+
+static INLINE struct nouveau_pipe_winsys *
+nouveau_screen(struct pipe_screen *pscreen)
+{
+ return nouveau_pipe_winsys(pscreen->winsys);
+}
+
+struct pipe_winsys *
+nouveau_pipe_winsys_new(struct nouveau_device *);
+
+struct nouveau_winsys *
+nouveau_winsys_new(struct pipe_winsys *ws);
+
+#endif
diff --git a/src/gallium/winsys/drm/radeon/Makefile b/src/gallium/winsys/drm/radeon/Makefile
index dca1e3233a..bacdf3de28 100644
--- a/src/gallium/winsys/drm/radeon/Makefile
+++ b/src/gallium/winsys/drm/radeon/Makefile
@@ -1,32 +1,12 @@
-
+# src/gallium/winsys/drm/radeon/Makefile
TOP = ../../../../..
include $(TOP)/configs/current
-LIBNAME = radeon_dri.so
-
-MINIGLX_SOURCES =
-
-PIPE_DRIVERS = \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/drivers/r300/libr300.a
-
-DRIVER_SOURCES = \
- radeon_buffer.c \
- radeon_context.c \
- radeon_r300.c \
- radeon_screen.c \
- radeon_winsys_softpipe.c
-
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I../../../drivers/r300
-
-include ../Makefile.template
-
-DRI_LIB_DEPS += -ldrm_radeon
+SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
-symlinks:
+default install clean:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
+ fi \
+ done
diff --git a/src/gallium/winsys/drm/radeon/core/Makefile b/src/gallium/winsys/drm/radeon/core/Makefile
new file mode 100644
index 0000000000..42a6f4abc2
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/core/Makefile
@@ -0,0 +1,18 @@
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = radeonwinsys
+
+C_SOURCES = \
+ radeon_buffer.c \
+ radeon_drm.c \
+ radeon_r300.c \
+ radeon_winsys_softpipe.c
+
+LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/r300 \
+ $(shell pkg-config libdrm --cflags-only-I)
+
+include ../../../../Makefile.template
+
+symlinks:
diff --git a/src/gallium/winsys/drm/radeon/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
index 259a505c0a..9dca510c81 100644
--- a/src/gallium/winsys/drm/radeon/radeon_buffer.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
@@ -1,5 +1,6 @@
/*
* Copyright © 2008 Jérôme Glisse
+ * 2009 Corbin Simpson
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -26,37 +27,31 @@
/*
* Authors:
* Jérôme Glisse <glisse@freedesktop.org>
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
*/
-#include <stdio.h>
-#include "dri_util.h"
-#include "state_tracker/st_public.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+
#include "radeon_buffer.h"
-#include "radeon_screen.h"
-#include "radeon_context.h"
-#include "radeon_bo.h"
-#include "radeon_drm.h"
static const char *radeon_get_name(struct pipe_winsys *ws)
{
- return "RADEON/DRI2";
+ return "Radeon/GEM+KMS";
}
static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
- unsigned alignment,
- unsigned usage,
- unsigned size)
+ unsigned alignment,
+ unsigned usage,
+ unsigned size)
{
- struct radeon_pipe_winsys *radeon_ws = (struct radeon_pipe_winsys *)ws;
+ struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws;
struct radeon_pipe_buffer *radeon_buffer;
uint32_t domain;
- radeon_buffer = calloc(1, sizeof(*radeon_buffer));
+ radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
if (radeon_buffer == NULL) {
return NULL;
}
- radeon_buffer->base.refcount = 1;
+
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
radeon_buffer->base.alignment = alignment;
radeon_buffer->base.usage = usage;
radeon_buffer->base.size = size;
@@ -69,21 +64,21 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
if (usage & PIPE_BUFFER_USAGE_VERTEX) {
domain |= RADEON_GEM_DOMAIN_GTT;
}
-
if (usage & PIPE_BUFFER_USAGE_INDEX) {
domain |= RADEON_GEM_DOMAIN_GTT;
}
- radeon_buffer->bo = radeon_bo_open(radeon_ws->radeon_screen->bom, 0,
- size, alignment, domain, 0);
+
+ radeon_buffer->bo = radeon_bo_open(radeon_ws->bom, 0, size, alignment,
+ domain, 0);
if (radeon_buffer->bo == NULL) {
- free(radeon_buffer);
+ FREE(radeon_buffer);
}
return &radeon_buffer->base;
}
static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
- void *ptr,
- unsigned bytes)
+ void *ptr,
+ unsigned bytes)
{
struct radeon_pipe_buffer *radeon_buffer;
@@ -97,7 +92,7 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
return &radeon_buffer->base;
}
-static void radeon_buffer_del(struct pipe_winsys *ws, struct pipe_buffer *buffer)
+static void radeon_buffer_del(struct pipe_buffer *buffer)
{
struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer;
@@ -106,15 +101,20 @@ static void radeon_buffer_del(struct pipe_winsys *ws, struct pipe_buffer *buffer
}
static void *radeon_buffer_map(struct pipe_winsys *ws,
- struct pipe_buffer *buffer,
- unsigned flags)
+ struct pipe_buffer *buffer,
+ unsigned flags)
{
struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer;
int write = 0;
+ if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+ /* XXX Remove this when radeon_bo_map supports DONTBLOCK */
+ return NULL;
+ }
if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
write = 1;
}
+
if (radeon_bo_map(radeon_buffer->bo, write))
return NULL;
return radeon_buffer->bo->ptr;
@@ -128,59 +128,62 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws, struct pipe_buffer *buff
}
static void radeon_fence_reference(struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *pfence)
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *pfence)
{
}
static int radeon_fence_signalled(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence,
- unsigned flag)
+ struct pipe_fence_handle *pfence,
+ unsigned flag)
{
return 1;
}
static int radeon_fence_finish(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence,
- unsigned flag)
+ struct pipe_fence_handle *pfence,
+ unsigned flag)
{
return 0;
}
static void radeon_flush_frontbuffer(struct pipe_winsys *pipe_winsys,
- struct pipe_surface *pipe_surface,
- void *context_private)
+ struct pipe_surface *pipe_surface,
+ void *context_private)
{
/* TODO: call dri2CopyRegion */
}
-struct pipe_winsys *radeon_pipe_winsys(struct radeon_screen *radeon_screen)
+struct radeon_winsys* radeon_pipe_winsys(int fd)
{
- struct radeon_pipe_winsys *radeon_ws;
+ struct radeon_winsys* radeon_ws;
+ struct radeon_bo_manager* bom;
- radeon_ws = calloc(1, sizeof(struct radeon_pipe_winsys));
+ radeon_ws = CALLOC_STRUCT(radeon_winsys);
if (radeon_ws == NULL) {
return NULL;
}
- radeon_ws->radeon_screen = radeon_screen;
- radeon_ws->winsys.flush_frontbuffer = radeon_flush_frontbuffer;
+ bom = radeon_bo_manager_gem_ctor(fd);
+ radeon_ws->bom = bom;
- radeon_ws->winsys.buffer_create = radeon_buffer_create;
- radeon_ws->winsys.buffer_destroy = radeon_buffer_del;
- radeon_ws->winsys.user_buffer_create = radeon_buffer_user_create;
- radeon_ws->winsys.buffer_map = radeon_buffer_map;
- radeon_ws->winsys.buffer_unmap = radeon_buffer_unmap;
+ radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer;
- radeon_ws->winsys.fence_reference = radeon_fence_reference;
- radeon_ws->winsys.fence_signalled = radeon_fence_signalled;
- radeon_ws->winsys.fence_finish = radeon_fence_finish;
+ radeon_ws->base.buffer_create = radeon_buffer_create;
+ radeon_ws->base.buffer_destroy = radeon_buffer_del;
+ radeon_ws->base.user_buffer_create = radeon_buffer_user_create;
+ radeon_ws->base.buffer_map = radeon_buffer_map;
+ radeon_ws->base.buffer_unmap = radeon_buffer_unmap;
- radeon_ws->winsys.get_name = radeon_get_name;
+ radeon_ws->base.fence_reference = radeon_fence_reference;
+ radeon_ws->base.fence_signalled = radeon_fence_signalled;
+ radeon_ws->base.fence_finish = radeon_fence_finish;
- return &radeon_ws->winsys;
-}
+ radeon_ws->base.get_name = radeon_get_name;
+ return radeon_ws;
+}
+#if 0
static struct pipe_buffer *radeon_buffer_from_handle(struct radeon_screen *radeon_screen,
uint32_t handle)
{
@@ -196,7 +199,7 @@ static struct pipe_buffer *radeon_buffer_from_handle(struct radeon_screen *radeo
radeon_bo_unref(bo);
return NULL;
}
- radeon_buffer->base.refcount = 1;
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
radeon_buffer->bo = bo;
return &radeon_buffer->base;
@@ -231,9 +234,10 @@ struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_co
pt = pipe_screen->texture_blanket(pipe_screen, &tmpl, &pitch, pb);
if (pt == NULL) {
- pipe_buffer_reference(pipe_screen, &pb, NULL);
+ pipe_buffer_reference(&pb, NULL);
}
ps = pipe_screen->get_tex_surface(pipe_screen, pt, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_WRITE);
return ps;
}
+#endif
diff --git a/src/gallium/winsys/drm/radeon/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
index c626c20229..40ad0fc8d1 100644
--- a/src/gallium/winsys/drm/radeon/radeon_buffer.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
@@ -30,22 +30,35 @@
#ifndef RADEON_BUFFER_H
#define RADEON_BUFFER_H
+#include <stdio.h>
+
#include "pipe/internal/p_winsys_screen.h"
-#include "radeon_screen.h"
-#include "radeon_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+
+//#include "state_tracker/st_public.h"
+
+#include "util/u_memory.h"
+
#include "radeon_bo.h"
+#include "radeon_drm.h"
+
struct radeon_pipe_buffer {
struct pipe_buffer base;
struct radeon_bo *bo;
};
-struct radeon_pipe_winsys {
- struct pipe_winsys winsys;
- struct radeon_screen *radeon_screen;
+struct radeon_winsys {
+ /* Parent class. */
+ struct pipe_winsys base;
+
+ /* Radeon BO manager.
+ * This corresponds to void* radeon_winsys in r300_winsys. */
+ struct radeon_bo_manager* bom;
};
-struct pipe_winsys *radeon_pipe_winsys(struct radeon_screen *radeon_screen);
+struct radeon_winsys* radeon_pipe_winsys(int fb);
struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context,
uint32_t handle,
enum pipe_format format,
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
new file mode 100644
index 0000000000..3446654e28
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright © 2009 Corbin Simpson
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
+ */
+
+#include "radeon_drm.h"
+
+/* Create a pipe_screen. */
+struct pipe_screen* radeon_create_screen(int drmFB, int pciID)
+{
+ struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB);
+
+ if (getenv("RADEON_SOFTPIPE")) {
+ return softpipe_create_screen((struct pipe_winsys*)winsys);
+ } else {
+ struct r300_winsys* r300 = radeon_create_r300_winsys(drmFB, winsys);
+ FREE(winsys);
+ return r300_create_screen(r300);
+ }
+}
+
+/* Create a pipe_context. */
+struct pipe_context* radeon_create_context(struct pipe_screen* screen)
+{
+ if (getenv("RADEON_SOFTPIPE")) {
+ return radeon_create_softpipe(screen->winsys);
+ } else {
+ return r300_create_context(screen, screen->winsys);
+ }
+}
+
+boolean radeon_buffer_from_texture(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride)
+{
+ return FALSE;
+}
+
+/* Create a buffer from a handle. */
+/* XXX what's up with name? */
+struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen,
+ const char* name,
+ unsigned handle)
+{
+ struct radeon_bo_manager* bom =
+ ((struct radeon_winsys*)screen->winsys)->bom;
+ struct radeon_pipe_buffer* radeon_buffer;
+ struct radeon_bo* bo = NULL;
+
+ bo = radeon_bo_open(bom, handle, 0, 0, 0, 0);
+ if (bo == NULL) {
+ return NULL;
+ }
+
+ radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
+ if (radeon_buffer == NULL) {
+ radeon_bo_unref(bo);
+ return NULL;
+ }
+
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
+ radeon_buffer->base.screen = screen;
+ radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
+ radeon_buffer->bo = bo;
+ return &radeon_buffer->base;
+}
+
+boolean radeon_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle)
+{
+ struct radeon_pipe_buffer* radeon_buffer =
+ (struct radeon_pipe_buffer*)buffer;
+ *handle = radeon_buffer->bo->handle;
+ return TRUE;
+}
+
+boolean radeon_global_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle)
+{
+ /* XXX WTF is the difference here? global? */
+ struct radeon_pipe_buffer* radeon_buffer =
+ (struct radeon_pipe_buffer*)buffer;
+ *handle = radeon_buffer->bo->handle;
+ return TRUE;
+}
+
+struct drm_api drm_api_hooks = {
+ .create_screen = radeon_create_screen,
+ .create_context = radeon_create_context,
+ /* XXX fix this */
+ .buffer_from_texture = r300_get_texture_buffer,
+ .buffer_from_handle = radeon_buffer_from_handle,
+ .handle_from_buffer = radeon_handle_from_buffer,
+ .global_handle_from_buffer = radeon_global_handle_from_buffer,
+};
diff --git a/src/gallium/winsys/drm/radeon/radeon_context.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
index d7222b4469..ca2d98ed1a 100644
--- a/src/gallium/winsys/drm/radeon/radeon_context.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008 Jérôme Glisse
+ * Copyright © 2009 Corbin Simpson
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -25,46 +25,39 @@
*/
/*
* Authors:
- * Jérôme Glisse <glisse@freedesktop.org>
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
*/
-#ifndef RADEON_CONTEXT_H
-#define RADEON_CONTEXT_H
+#ifndef RADEON_DRM_H
+#define RADEON_DRM_H
-#include "dri_util.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "radeon_screen.h"
+#include "pipe/p_screen.h"
+#include "util/u_memory.h"
+
+#include "state_tracker/drm_api.h"
+
+#include "radeon_buffer.h"
#include "radeon_r300.h"
+#include "radeon_winsys_softpipe.h"
+
+struct pipe_screen* radeon_create_screen(int drmFB, int pciID);
+
+struct pipe_context* radeon_create_context(struct pipe_screen* screen);
+
+boolean radeon_buffer_from_texture(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride);
-struct radeon_framebuffer {
- struct st_framebuffer *st_framebuffer;
- unsigned attachments;
-};
+struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen,
+ const char* name,
+ unsigned handle);
-struct radeon_context {
- /* st */
- struct st_context *st_context;
- /* pipe */
- struct pipe_screen *pipe_screen;
- struct pipe_winsys *pipe_winsys;
- /* DRI */
- __DRIscreenPrivate *dri_screen;
- __DRIdrawablePrivate *dri_drawable;
- __DRIdrawablePrivate *dri_readable;
- /* DRM */
- int drm_fd;
- /* RADEON */
- struct radeon_screen *radeon_screen;
-};
+boolean radeon_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle);
-GLboolean radeon_context_create(const __GLcontextModes*,
- __DRIcontextPrivate*,
- void*);
-void radeon_context_destroy(__DRIcontextPrivate*);
-GLboolean radeon_context_bind(__DRIcontextPrivate*,
- __DRIdrawablePrivate*,
- __DRIdrawablePrivate*);
-GLboolean radeon_context_unbind(__DRIcontextPrivate*);
+boolean radeon_global_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle);
#endif
diff --git a/src/gallium/winsys/drm/radeon/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
index 8fe2375e34..c7b6813014 100644
--- a/src/gallium/winsys/drm/radeon/radeon_r300.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
@@ -75,9 +75,10 @@ static void do_ioctls(struct r300_winsys* winsys, int fd)
}
-struct r300_winsys* radeon_create_r300_winsys(int fd)
+struct r300_winsys*
+radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys)
{
- struct r300_winsys* winsys = calloc(1, sizeof(struct r300_winsys));
+ struct r300_winsys* winsys = CALLOC_STRUCT(r300_winsys);
do_ioctls(winsys, fd);
@@ -92,5 +93,7 @@ struct r300_winsys* radeon_create_r300_winsys(int fd)
winsys->end_cs = radeon_cs_end;
winsys->flush_cs = radeon_r300_flush_cs;
+ memcpy(winsys, old_winsys, sizeof(struct radeon_winsys));
+
return winsys;
}
diff --git a/src/gallium/winsys/drm/radeon/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h
index 8ed95a3a9b..5c373cd084 100644
--- a/src/gallium/winsys/drm/radeon/radeon_r300.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h
@@ -31,4 +31,5 @@
#include "radeon_buffer.h"
-struct r300_winsys* radeon_create_r300_winsys(int fd);
+struct r300_winsys*
+radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys);
diff --git a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c
index 8402e1fa5a..226e16674c 100644
--- a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c
@@ -28,12 +28,7 @@
/*
* Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
-#include <stdio.h>
-#include "imports.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_format.h"
-#include "softpipe/sp_winsys.h"
-#include "radeon_context.h"
+
#include "radeon_winsys_softpipe.h"
struct radeon_softpipe_winsys {
@@ -57,21 +52,20 @@ static boolean radeon_is_format_supported(struct softpipe_winsys *sws, uint form
return FALSE;
}
-struct pipe_context *radeon_create_softpipe(struct radeon_context *radeon_context)
+struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys)
{
- struct radeon_softpipe_winsys *radeon_sp_ws;
+ struct softpipe_winsys *sp_winsys;
struct pipe_screen *pipe_screen;
- pipe_screen = softpipe_create_screen(radeon_context->pipe_winsys);
+ pipe_screen = softpipe_create_screen(winsys);
- radeon_sp_ws = CALLOC_STRUCT(radeon_softpipe_winsys);
- if (radeon_sp_ws == NULL) {
+ sp_winsys = CALLOC_STRUCT(softpipe_winsys);
+ if (sp_winsys == NULL) {
return NULL;
}
- radeon_context->pipe_screen = pipe_screen;
- radeon_sp_ws->radeon_context = radeon_context;
- radeon_sp_ws->sp_winsys.is_format_supported = radeon_is_format_supported;
+
+ sp_winsys->is_format_supported = radeon_is_format_supported;
return softpipe_create(pipe_screen,
- radeon_context->pipe_winsys,
- &radeon_sp_ws->sp_winsys);
+ winsys,
+ sp_winsys);
}
diff --git a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h
index 519eab769c..04740e41a5 100644
--- a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h
@@ -30,8 +30,15 @@
#ifndef RADEON_WINSYS_SOFTPIPE_H
#define RADEON_WINSYS_SOFTPIPE_H
-#include "radeon_context.h"
+#include <stdio.h>
-struct pipe_context *radeon_create_softpipe(struct radeon_context *radeon_context);
+#include "pipe/p_defines.h"
+#include "pipe/p_format.h"
+
+#include "softpipe/sp_winsys.h"
+
+#include "util/u_memory.h"
+
+struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys);
#endif
diff --git a/src/gallium/winsys/drm/radeon/dri2/Makefile b/src/gallium/winsys/drm/radeon/dri2/Makefile
new file mode 100644
index 0000000000..f471c44349
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/dri2/Makefile
@@ -0,0 +1,25 @@
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = radeon_dri.so
+
+MINIGLX_SOURCES =
+
+PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \
+ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a
+
+C_SOURCES = \
+ $(COMMON_GALLIUM_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../../Makefile.template
+
+DRI_LIB_DEPS += -ldrm_radeon
+
+symlinks:
diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile
new file mode 100644
index 0000000000..d989b3aa93
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/egl/Makefile
@@ -0,0 +1,25 @@
+TOP = ../../../../../..
+GALLIUMDIR = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = EGL_r300.so
+
+PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
+ $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a
+
+DRIVER_SOURCES =
+
+C_SOURCES = \
+ $(COMMON_GALLIUM_SOURCES) \
+ $(DRIVER_SOURCES)
+
+DRIVER_EXTRAS = -ldrm_radeon
+
+ASM_SOURCES =
+
+include ../../Makefile.template
+
+symlinks:
diff --git a/src/gallium/winsys/drm/radeon/radeon_context.c b/src/gallium/winsys/drm/radeon/radeon_context.c
deleted file mode 100644
index a9d1577634..0000000000
--- a/src/gallium/winsys/drm/radeon/radeon_context.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright © 2008 Jérôme Glisse
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- * Jérôme Glisse <glisse@freedesktop.org>
- */
-#include <stdio.h>
-#include "dri_util.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "radeon_screen.h"
-#include "radeon_context.h"
-#include "radeon_buffer.h"
-#include "radeon_winsys_softpipe.h"
-
-#define need_GL_ARB_fragment_program
-#define need_GL_ARB_multisample
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_shader_objects
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_vertex_shader
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_equation_separate
-#define need_GL_EXT_blend_func_separate
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_cull_vertex
-#define need_GL_EXT_compiled_vertex_array
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_multi_draw_arrays
-#define need_GL_EXT_secondary_color
-#define need_GL_VERSION_2_0
-#define need_GL_VERSION_2_1
-#include "extension_helper.h"
-
-/**
- * Extension strings exported by the radeon driver.
- */
-const struct dri_extension radeon_card_extensions[] = {
- {"GL_ARB_multitexture", NULL},
- {"GL_ARB_texture_border_clamp", NULL},
- {"GL_ARB_texture_rectangle", NULL},
- {"GL_ARB_pixel_buffer_object", NULL},
- {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
- {"GL_ARB_shader_objects", GL_ARB_shader_objects_functions},
- {"GL_ARB_shading_language_100", GL_VERSION_2_0_functions},
- {"GL_ARB_shading_language_120", GL_VERSION_2_1_functions},
- {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
- {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
- {"GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions},
- {"GL_EXT_blend_color", GL_EXT_blend_color_functions},
- {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
- {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
- {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
- {"GL_EXT_blend_subtract", NULL},
- {"GL_EXT_compiled_vertex_array", GL_EXT_compiled_vertex_array_functions},
- {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
- {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
- {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
- {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
- {"GL_EXT_packed_depth_stencil", NULL},
- {"GL_EXT_pixel_buffer_object", NULL},
- {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
- {"GL_EXT_stencil_wrap", NULL},
- {NULL, NULL}
-};
-
-static void radeon_update_renderbuffers(__DRIcontext *dri_context,
- __DRIdrawable *dri_drawable)
-{
- struct radeon_framebuffer *radeon_fb;
- struct radeon_context *radeon_context;
- unsigned attachments[10];
- __DRIbuffer *buffers;
- __DRIscreen *screen;
- int i, count;
-
- radeon_context = dri_context->driverPrivate;
- screen = dri_drawable->driScreenPriv;
- radeon_fb = dri_drawable->driverPrivate;
- for (count = 0, i = 0; count < 6; count++) {
- if (radeon_fb->attachments & (1 << count)) {
- attachments[i++] = count;
- }
- }
-
- buffers = (*screen->dri2.loader->getBuffers)(dri_drawable,
- &dri_drawable->w,
- &dri_drawable->h,
- attachments,
- i,
- &count,
- dri_drawable->loaderPrivate);
- if (buffers == NULL) {
- return;
- }
-
- /* set one cliprect to cover the whole dri_drawable */
- dri_drawable->x = 0;
- dri_drawable->y = 0;
- dri_drawable->backX = 0;
- dri_drawable->backY = 0;
- dri_drawable->numClipRects = 1;
- dri_drawable->pClipRects[0].x1 = 0;
- dri_drawable->pClipRects[0].y1 = 0;
- dri_drawable->pClipRects[0].x2 = dri_drawable->w;
- dri_drawable->pClipRects[0].y2 = dri_drawable->h;
- dri_drawable->numBackClipRects = 1;
- dri_drawable->pBackClipRects[0].x1 = 0;
- dri_drawable->pBackClipRects[0].y1 = 0;
- dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
- dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
-
- for (i = 0; i < count; i++) {
- struct pipe_surface *ps;
- enum pipe_format format = 0;
- int index = 0;
-
- switch (buffers[i].attachment) {
- case __DRI_BUFFER_FRONT_LEFT:
- index = ST_SURFACE_FRONT_LEFT;
- switch (buffers[i].cpp) {
- case 4:
- format = PIPE_FORMAT_A8R8G8B8_UNORM;
- break;
- case 2:
- format = PIPE_FORMAT_R5G6B5_UNORM;
- break;
- default:
- /* FIXME: error */
- return;
- }
- break;
- case __DRI_BUFFER_BACK_LEFT:
- index = ST_SURFACE_BACK_LEFT;
- switch (buffers[i].cpp) {
- case 4:
- format = PIPE_FORMAT_A8R8G8B8_UNORM;
- break;
- case 2:
- format = PIPE_FORMAT_R5G6B5_UNORM;
- break;
- default:
- /* FIXME: error */
- return;
- }
- break;
- case __DRI_BUFFER_STENCIL:
- case __DRI_BUFFER_DEPTH:
- index = ST_SURFACE_DEPTH;
- switch (buffers[i].cpp) {
- case 4:
- format = PIPE_FORMAT_Z24S8_UNORM;
- break;
- case 2:
- format = PIPE_FORMAT_Z16_UNORM;
- break;
- default:
- /* FIXME: error */
- return;
- }
- break;
- case __DRI_BUFFER_ACCUM:
- default:
- fprintf(stderr,
- "unhandled buffer attach event, attacment type %d\n",
- buffers[i].attachment);
- return;
- }
-
- ps = radeon_surface_from_handle(radeon_context,
- buffers[i].name,
- format,
- dri_drawable->w,
- dri_drawable->h,
- buffers[i].pitch);
- assert(ps);
- st_set_framebuffer_surface(radeon_fb->st_framebuffer, index, ps);
- }
- st_resize_framebuffer(radeon_fb->st_framebuffer,
- dri_drawable->w,
- dri_drawable->h);
-}
-
-GLboolean radeon_context_create(const __GLcontextModes *visual,
- __DRIcontextPrivate *dri_context,
- void *shared_context)
-{
- __DRIscreenPrivate *dri_screen;
- struct radeon_context *radeon_context;
- struct radeon_screen *radeon_screen;
- struct pipe_context *pipe;
- struct st_context *shared_st_context = NULL;
-
- dri_context->driverPrivate = NULL;
- radeon_context = calloc(1, sizeof(struct radeon_context));
- if (radeon_context == NULL) {
- return GL_FALSE;
- }
-
- if (shared_context) {
- shared_st_context = ((struct radeon_context*)shared_context)->st_context;
- }
-
- dri_screen = dri_context->driScreenPriv;
- radeon_screen = dri_screen->private;
- radeon_context->dri_screen = dri_screen;
- radeon_context->radeon_screen = radeon_screen;
- radeon_context->drm_fd = dri_screen->fd;
-
- radeon_context->pipe_winsys = radeon_pipe_winsys(radeon_screen);
- if (radeon_context->pipe_winsys == NULL) {
- free(radeon_context);
- return GL_FALSE;
- }
-
- if (!getenv("RADEON_SOFTPIPE")) {
- fprintf(stderr, "Creating r300 context...\n");
- pipe =
- r300_create_context(NULL,
- radeon_context->pipe_winsys,
- radeon_create_r300_winsys(radeon_context->drm_fd));
- radeon_context->pipe_screen = pipe->screen;
- } else {
- pipe = radeon_create_softpipe(radeon_context);
- }
- radeon_context->st_context = st_create_context(pipe, visual,
- shared_st_context);
- driInitExtensions(radeon_context->st_context->ctx,
- radeon_card_extensions, GL_TRUE);
- dri_context->driverPrivate = radeon_context;
- return GL_TRUE;
-}
-
-void radeon_context_destroy(__DRIcontextPrivate *dri_context)
-{
- struct radeon_context *radeon_context;
-
- radeon_context = dri_context->driverPrivate;
- st_finish(radeon_context->st_context);
- st_destroy_context(radeon_context->st_context);
- free(radeon_context);
-}
-
-GLboolean radeon_context_bind(__DRIcontextPrivate *dri_context,
- __DRIdrawablePrivate *dri_drawable,
- __DRIdrawablePrivate *dri_readable)
-{
- struct radeon_framebuffer *drawable;
- struct radeon_framebuffer *readable;
- struct radeon_context *radeon_context;
-
- if (dri_context == NULL) {
- st_make_current(NULL, NULL, NULL);
- return GL_TRUE;
- }
-
- radeon_context = dri_context->driverPrivate;
- drawable = dri_drawable->driverPrivate;
- readable = dri_readable->driverPrivate;
- st_make_current(radeon_context->st_context,
- drawable->st_framebuffer,
- readable->st_framebuffer);
-
- radeon_update_renderbuffers(dri_context, dri_drawable);
- if (dri_drawable != dri_readable) {
- radeon_update_renderbuffers(dri_context, dri_readable);
- }
- return GL_TRUE;
-}
-
-GLboolean radeon_context_unbind(__DRIcontextPrivate *dri_context)
-{
- struct radeon_context *radeon_context;
-
- radeon_context = dri_context->driverPrivate;
- st_flush(radeon_context->st_context, PIPE_FLUSH_RENDER_CACHE, NULL);
- return GL_TRUE;
-}
diff --git a/src/gallium/winsys/drm/radeon/radeon_screen.c b/src/gallium/winsys/drm/radeon/radeon_screen.c
deleted file mode 100644
index e31caff0bf..0000000000
--- a/src/gallium/winsys/drm/radeon/radeon_screen.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright © 2008 Jérôme Glisse
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- * Jérôme Glisse <glisse@freedesktop.org>
- */
-#include <stdio.h>
-#include "pipe/p_screen.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "utils.h"
-#include "xf86drm.h"
-#include "drm.h"
-#include "dri_util.h"
-#include "radeon_screen.h"
-#include "radeon_context.h"
-#include "radeon_buffer.h"
-#include "radeon_bo.h"
-#include "radeon_bo_gem.h"
-#include "radeon_drm.h"
-
-extern const struct dri_extension radeon_card_extensions[];
-
-static const __DRIextension *radeon_screen_extensions[] = {
- &driReadDrawableExtension,
- &driCopySubBufferExtension.base,
- &driSwapControlExtension.base,
- &driFrameTrackingExtension.base,
- &driMediaStreamCounterExtension.base,
- NULL
-};
-
-static __DRIconfig **radeon_fill_in_modes(unsigned pixel_bits,
- unsigned depth_bits,
- GLboolean have_back_buffer)
-{
- __DRIconfig **configs;
- unsigned depth_buffer_factor;
- unsigned back_buffer_factor;
- unsigned num_modes;
- GLenum fb_format;
- GLenum fb_type;
- uint8_t depth_bits_array[3];
- uint8_t stencil_bits_array[3];
- uint8_t msaa_samples_array[1];
- /* TODO: pageflipping ? */
- static const GLenum back_buffer_modes[] = {
- GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
- };
-
- stencil_bits_array[0] = 0;
- stencil_bits_array[1] = 0;
- if (depth_bits == 24) {
- stencil_bits_array[2] = 8;
- num_modes = 3;
- }
-
- depth_bits_array[0] = 0;
- depth_bits_array[1] = depth_bits;
- depth_bits_array[2] = depth_bits;
- depth_buffer_factor = (depth_bits == 24) ? 3 : 2;
-
- back_buffer_factor = (have_back_buffer) ? 3 : 1;
-
- msaa_samples_array[0] = 0;
-
- if (pixel_bits == 16) {
- fb_format = GL_RGB;
- fb_type = GL_UNSIGNED_SHORT_5_6_5;
- } else {
- fb_format = GL_BGRA;
- fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
- }
-
- configs = (__DRIconfig **)driCreateConfigs(fb_format,
- fb_type,
- depth_bits_array,
- stencil_bits_array,
- depth_buffer_factor,
- back_buffer_modes,
- back_buffer_factor,
- msaa_samples_array,
- 1);
- if (configs == NULL) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n",
- __FILE__, __LINE__);
- return NULL;
- }
- return configs;
-}
-
-static void radeon_screen_destroy(__DRIscreenPrivate *dri_screen)
-{
- struct radeon_screen *radeon_screen = (struct radeon_screen*)dri_screen->private;
-
- radeon_bo_manager_gem_dtor(radeon_screen->bom);
- dri_screen = NULL;
- free(radeon_screen);
-}
-
-static const __DRIconfig **radeon_screen_init(__DRIscreenPrivate *dri_screen)
-{
- struct radeon_screen *radeon_screen;
-
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- driInitExtensions(NULL, radeon_card_extensions, GL_FALSE);
-
- radeon_screen = calloc(1, sizeof(struct radeon_screen));
- if (radeon_screen == NULL) {
- fprintf(stderr, "\nERROR! Allocating private area failed\n");
- return NULL;
- }
- dri_screen->private = (void*)radeon_screen;
- dri_screen->extensions = radeon_screen_extensions;
- radeon_screen->dri_screen = dri_screen;
-
- radeon_screen->bom = radeon_bo_manager_gem_ctor(dri_screen->fd);
- if (radeon_screen->bom == NULL) {
- radeon_screen_destroy(dri_screen);
- return NULL;
- }
-
- return driConcatConfigs(radeon_fill_in_modes(16, 16, 1),
- radeon_fill_in_modes(32, 24, 1));
-}
-
-static boolean radeon_buffer_create(__DRIscreenPrivate *dri_screen,
- __DRIdrawablePrivate *dri_drawable,
- const __GLcontextModes *visual,
- boolean is_pixmap)
-{
- if (is_pixmap) {
- /* TODO: implement ? */
- return GL_FALSE;
- } else {
- enum pipe_format color_format, depth_format, stencil_format;
- struct radeon_framebuffer *radeon_fb;
-
- radeon_fb = calloc(1, sizeof(struct radeon_framebuffer));
- if (radeon_fb == NULL) {
- return GL_FALSE;
- }
-
- switch (visual->redBits) {
- case 5:
- color_format = PIPE_FORMAT_R5G6B5_UNORM;
- break;
- default:
- color_format = PIPE_FORMAT_A8R8G8B8_UNORM;
- break;
- }
-
- switch (visual->depthBits) {
- case 24:
- depth_format = PIPE_FORMAT_S8Z24_UNORM;
- break;
- case 16:
- depth_format = PIPE_FORMAT_Z16_UNORM;
- break;
- default:
- depth_format = PIPE_FORMAT_NONE;
- break;
- }
-
- switch (visual->stencilBits) {
- case 8:
- /* force depth format */
- depth_format = PIPE_FORMAT_S8Z24_UNORM;
- stencil_format = PIPE_FORMAT_S8Z24_UNORM;
- break;
- default:
- stencil_format = PIPE_FORMAT_NONE;
- break;
- }
-
- radeon_fb->st_framebuffer = st_create_framebuffer(visual,
- color_format,
- depth_format,
- stencil_format,
- dri_drawable->w,
- dri_drawable->h,
- (void*)radeon_fb);
- if (radeon_fb->st_framebuffer == NULL) {
- free(radeon_fb);
- return GL_FALSE;
- }
- dri_drawable->driverPrivate = (void *) radeon_fb;
-
- radeon_fb->attachments = (1 << __DRI_BUFFER_FRONT_LEFT);
- if (visual->doubleBufferMode) {
- radeon_fb->attachments |= (1 << __DRI_BUFFER_BACK_LEFT);
- }
- if (visual->depthBits || visual->stencilBits) {
- radeon_fb->attachments |= (1 << __DRI_BUFFER_DEPTH);
- }
-
- return GL_TRUE;
- }
-}
-
-static void radeon_buffer_destroy(__DRIdrawablePrivate * dri_drawable)
-{
- struct radeon_framebuffer *radeon_fb;
-
- radeon_fb = dri_drawable->driverPrivate;
- assert(radeon_fb->st_framebuffer);
- st_unreference_framebuffer(radeon_fb->st_framebuffer);
- free(radeon_fb);
-}
-
-static void radeon_swap_buffers(__DRIdrawablePrivate *dri_drawable)
-{
- struct radeon_framebuffer *radeon_fb;
- struct pipe_surface *back_surf = NULL;
-
- radeon_fb = dri_drawable->driverPrivate;
- assert(radeon_fb);
- assert(radeon_fb->st_framebuffer);
-
- st_get_framebuffer_surface(radeon_fb->st_framebuffer,
- ST_SURFACE_BACK_LEFT,
- &back_surf);
- if (back_surf) {
- st_notify_swapbuffers(radeon_fb->st_framebuffer);
- /* TODO: do we want to do anythings ? */
- st_notify_swapbuffers_complete(radeon_fb->st_framebuffer);
- }
-}
-
-/**
- * Called via glXCopySubBufferMESA() to copy a subrect of the back
- * buffer to the front buffer/screen.
- */
-static void radeon_copy_sub_buffer(__DRIdrawablePrivate *dri_drawable,
- int x, int y, int w, int h)
-{
- /* TODO: ... */
-}
-
-const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = NULL,
- .DestroyScreen = radeon_screen_destroy,
- .CreateContext = radeon_context_create,
- .DestroyContext = radeon_context_destroy,
- .CreateBuffer = radeon_buffer_create,
- .DestroyBuffer = radeon_buffer_destroy,
- .SwapBuffers = radeon_swap_buffers,
- .MakeCurrent = radeon_context_bind,
- .UnbindContext = radeon_context_unbind,
- .CopySubBuffer = radeon_copy_sub_buffer,
- .InitScreen2 = radeon_screen_init,
-};
diff --git a/src/gallium/winsys/drm/radeon/radeon_screen.h b/src/gallium/winsys/drm/radeon/radeon_screen.h
deleted file mode 100644
index 01b7fa6531..0000000000
--- a/src/gallium/winsys/drm/radeon/radeon_screen.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright © 2008 Jérôme Glisse
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- * Jérôme Glisse <glisse@freedesktop.org>
- */
-#ifndef RADEON_SCREEN_H
-#define RADEON_SCREEN_H
-
-#include "dri_util.h"
-#include "radeon_bo.h"
-
-struct radeon_screen {
- __DRIscreenPrivate *dri_screen;
- struct radeon_bo_manager *bom;
-};
-
-#endif
diff --git a/src/gallium/winsys/drm/radeon/xorg/Makefile b/src/gallium/winsys/drm/radeon/xorg/Makefile
new file mode 100644
index 0000000000..6ffd4a3a54
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/xorg/Makefile
@@ -0,0 +1,42 @@
+TARGET = modesetting_drv.so
+CFILES = $(wildcard ./*.c)
+OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES))
+GALLIUMDIR = ../../../..
+TOP = ../../../../../..
+
+include ${TOP}/configs/current
+
+CFLAGS = -DHAVE_CONFIG_H \
+ -g -Wall -Wimplicit-function-declaration -fPIC \
+ $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
+ -I${GALLIUMDIR}/include \
+ -I${GALLIUMDIR}/drivers \
+ -I${GALLIUMDIR}/auxiliary \
+ -I${TOP}/src/mesa \
+ -I$(TOP)/include \
+ -I$(TOP)/src/egl/main
+
+LIBS = \
+ $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a \
+ $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a \
+ $(GALLIUM_AUXILIARIES)
+
+#############################################
+
+
+
+all default: $(TARGET)
+
+$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a
+ $(TOP)/bin/mklib -noprefix -o $@ \
+ $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_radeon
+
+clean:
+ rm -rf $(OBJECTS) $(TARGET)
+
+install:
+ $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+ $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c
new file mode 100644
index 0000000000..6f77fbe5de
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ * Author: Corbin Simpson <MostAwesomedude@gmail.com>
+ *
+ */
+
+#include "../../../../state_trackers/xorg/xorg_winsys.h"
+
+static void radeon_xorg_identify(int flags);
+static Bool radeon_xorg_pci_probe(DriverPtr driver,
+ int entity_num,
+ struct pci_device *device,
+ intptr_t match_data);
+
+static const struct pci_id_match radeon_xorg_device_match[] = {
+ {0x1002, 0x5E4D, 0xffff, 0xffff, 0, 0, 0},
+ {0x1002, 0x7249, 0xffff, 0xffff, 0, 0, 0},
+ {0, 0, 0},
+};
+
+static SymTabRec radeon_xorg_chipsets[] = {
+ {0x5E4D, "Radeon RV410 PCIE (X700)"},
+ {0x7249, "Radeon R580 PCIE (X1900 XT)"},
+ {-1, NULL}
+};
+
+static PciChipsets radeon_xorg_pci_devices[] = {
+ {0x5E4D, 0x5E4D, RES_SHARED_VGA},
+ {0x7249, 0x7249, RES_SHARED_VGA},
+ {-1, -1, RES_UNDEFINED}
+};
+
+static XF86ModuleVersionInfo radeon_xorg_version = {
+ "modesetting",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 0, 1, 0, /* major, minor, patch */
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+ 1,
+ "modesetting",
+ radeon_xorg_identify,
+ NULL,
+ xorg_tracker_available_options,
+ NULL,
+ 0,
+ NULL,
+ radeon_xorg_device_match,
+ radeon_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(radeon_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+ &radeon_xorg_version,
+ radeon_xorg_setup,
+ NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+radeon_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = 0;
+
+ /* This module should be loaded only once, but check to be sure.
+ */
+ if (!setupDone) {
+ setupDone = 1;
+ xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+ /*
+ * Tell the loader about symbols from other modules that this module
+ * might refer to.
+ */
+ xorg_tracker_loader_ref_sym_lists();
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer) 1;
+ } else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+static void
+radeon_xorg_identify(int flags)
+{
+ xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+ radeon_xorg_chipsets);
+}
+
+static Bool
+radeon_xorg_pci_probe(DriverPtr driver,
+ int entity_num, struct pci_device *device, intptr_t match_data)
+{
+ ScrnInfoPtr scrn = NULL;
+ EntityInfoPtr entity;
+
+ scrn = xf86ConfigPciEntity(scrn, 0, entity_num, radeon_xorg_pci_devices,
+ NULL, NULL, NULL, NULL, NULL);
+ if (scrn != NULL) {
+ scrn->driverVersion = 1;
+ scrn->driverName = "modesetting";
+ scrn->name = "modesetting";
+ scrn->Probe = NULL;
+
+ entity = xf86GetEntityInfo(entity_num);
+
+ /* Use all the functions from the xorg tracker */
+ xorg_tracker_set_functions(scrn);
+ }
+ return scrn != NULL;
+}
diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c
index c6b0e3d8c5..9ceb67d2ac 100644
--- a/src/gallium/winsys/egl_xlib/egl_xlib.c
+++ b/src/gallium/winsys/egl_xlib/egl_xlib.c
@@ -277,6 +277,7 @@ display_surface(struct pipe_winsys *pws,
struct pipe_surface *psurf,
struct xlib_egl_surface *xsurf)
{
+ struct softpipe_texture *spt = softpipe_texture(psurf->texture);
XImage *ximage;
void *data;
@@ -293,13 +294,13 @@ display_surface(struct pipe_winsys *pws,
assert(ximage->format);
assert(ximage->bitmap_unit);
- data = pws->buffer_map(pws, softpipe_texture(psurf->texture)->buffer, 0);
+ data = pws->buffer_map(pws, spt->buffer, 0);
/* update XImage's fields */
ximage->data = data;
ximage->width = psurf->width;
ximage->height = psurf->height;
- ximage->bytes_per_line = psurf->stride;
+ ximage->bytes_per_line = spt->stride[psurf->level];
XPutImage(xsurf->Dpy, xsurf->Win, xsurf->Gc,
ximage, 0, 0, 0, 0, psurf->width, psurf->height);
@@ -309,7 +310,7 @@ display_surface(struct pipe_winsys *pws,
ximage->data = NULL;
XDestroyImage(ximage);
- pws->buffer_unmap(pws, softpipe_texture(psurf->texture)->buffer);
+ pws->buffer_unmap(pws, spt->buffer);
}
diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c
index 739bfa1c1a..aa1bfa8e88 100644
--- a/src/gallium/winsys/egl_xlib/sw_winsys.c
+++ b/src/gallium/winsys/egl_xlib/sw_winsys.c
@@ -99,7 +99,7 @@ buffer_create(struct pipe_winsys *pws,
if (!buffer)
return NULL;
- buffer->Base.refcount = 1;
+ pipe_reference_init(&buffer->Base.reference, 1);
buffer->Base.alignment = alignment;
buffer->Base.usage = usage;
buffer->Base.size = size;
@@ -121,7 +121,7 @@ user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
if (!buffer)
return NULL;
- buffer->Base.refcount = 1;
+ pipe_reference_init(&buffer->Base.reference, 1);
buffer->Base.size = bytes;
buffer->UserBuffer = TRUE;
buffer->Data = ptr;
@@ -148,7 +148,7 @@ buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
static void
-buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buf)
+buffer_destroy(struct pipe_buffer *buf)
{
struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf);
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c
index 864be37871..77e46a2054 100644
--- a/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c
+++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c
@@ -31,7 +31,7 @@ nouveau_copy_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf,
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
- pipe->surface_copy(pipe, FALSE, nv->base.frontbuffer,
+ pipe->surface_copy(pipe, nv->base.frontbuffer,
dx, dy, surf, sx, sy, w, h);
}
diff --git a/src/gallium/winsys/g3dvl/xsp_winsys.c b/src/gallium/winsys/g3dvl/xsp_winsys.c
index 40d683234f..5b9fdb5c1f 100644
--- a/src/gallium/winsys/g3dvl/xsp_winsys.c
+++ b/src/gallium/winsys/g3dvl/xsp_winsys.c
@@ -1,10 +1,12 @@
#include "vl_winsys.h"
#include <X11/Xutil.h>
-#include <pipe/p_winsys.h>
+#include <pipe/internal/p_winsys_screen.h>
#include <pipe/p_state.h>
#include <pipe/p_inlines.h>
#include <util/u_memory.h>
+#include <util/u_math.h>
#include <softpipe/sp_winsys.h>
+#include <softpipe/sp_texture.h>
/* pipe_winsys implementation */
@@ -37,7 +39,7 @@ static struct pipe_buffer* xsp_buffer_create(struct pipe_winsys *pws, unsigned a
assert(pws);
buffer = calloc(1, sizeof(struct xsp_buffer));
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
@@ -53,7 +55,7 @@ static struct pipe_buffer* xsp_user_buffer_create(struct pipe_winsys *pws, void
assert(pws);
buffer = calloc(1, sizeof(struct xsp_buffer));
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = size;
buffer->is_user_buffer = TRUE;
buffer->data = data;
@@ -96,12 +98,6 @@ static void xsp_buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buff
free(xsp_buf);
}
-/* Borrowed from Mesa's xm_winsys */
-static unsigned int round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
static struct pipe_buffer* xsp_surface_buffer_create
(
struct pipe_winsys *pws,
@@ -119,11 +115,11 @@ static struct pipe_buffer* xsp_surface_buffer_create
pf_get_block(format, &block);
nblocksx = pf_get_nblocksx(&block, width);
nblocksy = pf_get_nblocksy(&block, height);
- *stride = round_up(nblocksx * block.size, ALIGNMENT);
+ *stride = align(nblocksx * block.size, ALIGNMENT);
- return winsys->buffer_create(winsys, ALIGNMENT,
- usage,
- *stride * nblocksy);
+ return pws->buffer_create(pws, ALIGNMENT,
+ usage,
+ *stride * nblocksy);
}
static void xsp_fence_reference(struct pipe_winsys *pws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence)
@@ -167,7 +163,7 @@ static void xsp_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *
xsp_winsys->fbimage.width = surface->width;
xsp_winsys->fbimage.height = surface->height;
xsp_winsys->fbimage.bytes_per_line = surface->width * (xsp_winsys->fbimage.bits_per_pixel >> 3);
- xsp_winsys->fbimage.data = pipe_surface_map(surface, 0);
+ xsp_winsys->fbimage.data = ((struct xsp_buffer *)softpipe_texture(surface->texture)->buffer)->data + surface->offset;
XPutImage
(
@@ -183,7 +179,6 @@ static void xsp_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *
surface->height
);
XFlush(xsp_context->display);
- pipe_surface_unmap(surface);
}
static const char* xsp_get_name(struct pipe_winsys *pws)
diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript
index f9c1a34668..72b5df8ca2 100644
--- a/src/gallium/winsys/gdi/SConscript
+++ b/src/gallium/winsys/gdi/SConscript
@@ -11,12 +11,6 @@ if env['platform'] == 'windows':
'#src/gallium/state_trackers/wgl',
])
- env.Append(CPPDEFINES = [
- '__GL_EXPORTS',
- 'BUILD_GL32',
- '_GNU_H_WINDOWS32_DEFINES',
- ])
-
env.Append(LIBS = [
'gdi32',
'user32',
@@ -24,9 +18,13 @@ if env['platform'] == 'windows':
])
sources = [
- '#src/gallium/state_trackers/wgl/opengl32.def',
'gdi_softpipe_winsys.c',
]
+
+ if env['toolchain'] == 'crossmingw':
+ sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def']
+ else:
+ sources += ['#src/gallium/state_trackers/wgl/opengl32.def']
drivers = [
softpipe,
diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
index 4924dbf26a..440666d835 100644
--- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
@@ -87,8 +87,7 @@ gdi_softpipe_buffer_unmap(struct pipe_winsys *winsys,
static void
-gdi_softpipe_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+gdi_softpipe_buffer_destroy(struct pipe_buffer *buf)
{
struct gdi_softpipe_buffer *oldBuf = gdi_softpipe_buffer(buf);
@@ -118,7 +117,7 @@ gdi_softpipe_buffer_create(struct pipe_winsys *winsys,
{
struct gdi_softpipe_buffer *buffer = CALLOC_STRUCT(gdi_softpipe_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
@@ -143,7 +142,7 @@ gdi_softpipe_user_buffer_create(struct pipe_winsys *winsys,
if(!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;
@@ -273,14 +272,17 @@ gdi_softpipe_flush_frontbuffer(struct pipe_screen *screen,
struct pipe_surface *surface,
HDC hDC)
{
+ struct softpipe_texture *texture;
struct gdi_softpipe_buffer *buffer;
BITMAPINFO bmi;
- buffer = gdi_softpipe_buffer(softpipe_texture(surface->texture)->buffer);
+ texture = softpipe_texture(surface->texture);
+
+ buffer = gdi_softpipe_buffer(texture->buffer);
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = surface->stride / pf_get_size(surface->format);
+ bmi.bmiHeader.biWidth = texture->stride[surface->level] / pf_get_size(surface->format);
bmi.bmiHeader.biHeight= -(long)surface->height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = pf_get_bits(surface->format);
diff --git a/src/gallium/winsys/xlib/xlib_brw_aub.c b/src/gallium/winsys/xlib/xlib_brw_aub.c
index 2956e1b960..b6bd849ef2 100644
--- a/src/gallium/winsys/xlib/xlib_brw_aub.c
+++ b/src/gallium/winsys/xlib/xlib_brw_aub.c
@@ -34,8 +34,9 @@
#include "xlib_brw_aub.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
+#include "softpipe/sp_texture.h"
struct brw_aubfile {
@@ -322,10 +323,10 @@ void brw_aub_dump_bmp( struct brw_aubfile *aubfile,
struct aub_dump_bmp db;
unsigned format;
- assert(surface->block.width == 1);
- assert(surface->block.height == 1);
+ assert(surface->texture->block.width == 1);
+ assert(surface->texture->block.height == 1);
- if (surface->block.size == 4)
+ if (surface->texture->block.size == 4)
format = 0x7;
else
format = 0x3;
@@ -334,8 +335,9 @@ void brw_aub_dump_bmp( struct brw_aubfile *aubfile,
db.xmin = 0;
db.ymin = 0;
db.format = format;
- db.bpp = surface->block.size * 8;
- db.pitch = surface->stride/surface->block.size;
+ db.bpp = surface->texture->block.size * 8;
+ db.pitch = softpipe_texture(surface->texture)->stride[surface->level] /
+ surface->texture->block.size;
db.xsize = surface->width;
db.ysize = surface->height;
db.addr = gtt_offset;
diff --git a/src/gallium/winsys/xlib/xlib_brw_screen.c b/src/gallium/winsys/xlib/xlib_brw_screen.c
index 8e1bfab2f5..fe8dfff767 100644
--- a/src/gallium/winsys/xlib/xlib_brw_screen.c
+++ b/src/gallium/winsys/xlib/xlib_brw_screen.c
@@ -37,7 +37,6 @@
//#include "state_trackers/xlib/xmesaP.h"
#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "i965simple/brw_winsys.h"
@@ -57,10 +56,10 @@ buffer_from_surface(struct pipe_surface *surface)
}
struct aub_buffer {
+ struct pipe_reference reference;
char *data;
unsigned offset;
unsigned size;
- unsigned refcount;
unsigned map_count;
boolean dump_on_unmap;
};
@@ -144,8 +143,7 @@ static void aub_buffer_unmap(struct pipe_winsys *winsys,
static void
-aub_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+aub_buffer_destroy(struct pipe_buffer *buf)
{
free(buf);
}
@@ -189,7 +187,7 @@ aub_buffer_create(struct pipe_winsys *winsys,
struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer);
- sbo->refcount = 1;
+ pipe_reference_init(&sbo->reference, 1);
/* Could reuse buffers that are not referenced in current
* batchbuffer. Can't do that atm, so always reallocate:
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
index c87564f4dc..13e609f58f 100644
--- a/src/gallium/winsys/xlib/xlib_cell.c
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -107,22 +107,21 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
}
static void
-xm_buffer_destroy(struct pipe_winsys *pws,
+xm_buffer_destroy(/*struct pipe_winsys *pws,*/
struct pipe_buffer *buf)
{
struct xm_buffer *oldBuf = xm_buffer(buf);
- if (oldBuf->data) {
- {
+ if (oldBuf) {
+ if (oldBuf->data) {
if (!oldBuf->userBuffer) {
align_free(oldBuf->data);
}
- }
- oldBuf->data = NULL;
+ oldBuf->data = NULL;
+ }
+ free(oldBuf);
}
-
- free(oldBuf);
}
@@ -222,7 +221,8 @@ xm_flush_frontbuffer(struct pipe_winsys *pws,
* This function copies that XImage to the actual X Window.
*/
XMesaContext xmctx = (XMesaContext) context_private;
- xlib_cell_display_surface(xmctx->xm_buffer, surf);
+ if (xmctx)
+ xlib_cell_display_surface(xmctx->xm_buffer, surf);
}
@@ -242,7 +242,7 @@ xm_buffer_create(struct pipe_winsys *pws,
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
@@ -266,7 +266,7 @@ static struct pipe_buffer *
xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;
@@ -370,7 +370,7 @@ xlib_create_cell_winsys( void )
static struct pipe_screen *
-xlib_create_cell_screen( struct pipe_winsys *pws )
+xlib_create_cell_screen( void )
{
struct pipe_winsys *winsys;
struct pipe_screen *screen;
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index 586e1dfca5..762ebd9847 100644
--- a/src/gallium/winsys/xlib/xlib_softpipe.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -61,8 +61,10 @@ struct xm_buffer
void *mapped;
XImage *tempImage;
+#ifdef USE_XSHM
int shm;
XShmSegmentInfo shminfo;
+#endif
};
@@ -73,7 +75,9 @@ struct xmesa_pipe_winsys
{
struct pipe_winsys base;
/* struct xmesa_visual *xm_visual; */
+#ifdef USE_XSHM
int shm;
+#endif
};
@@ -89,7 +93,13 @@ xm_buffer( struct pipe_buffer *buf )
/**
* X Shared Memory Image extension code
*/
+#ifdef USE_XSHM
#define XSHM_ENABLED(b) ((b)->shm)
+#else
+#define XSHM_ENABLED(b) 0
+#endif
+
+#ifdef USE_XSHM
static volatile int mesaXErrorFlag = 0;
@@ -170,8 +180,12 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
(void) XSetErrorHandler(old_handler);
return;
}
+
+ b->shm = 1;
}
+#endif /* USE_XSHM */
+
/* Most callbacks map direcly onto dri_bufmgr operations:
@@ -193,12 +207,12 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
}
static void
-xm_buffer_destroy(struct pipe_winsys *pws,
- struct pipe_buffer *buf)
+xm_buffer_destroy(struct pipe_buffer *buf)
{
struct xm_buffer *oldBuf = xm_buffer(buf);
if (oldBuf->data) {
+#ifdef USE_XSHM
if (oldBuf->shminfo.shmid >= 0) {
shmdt(oldBuf->shminfo.shmaddr);
shmctl(oldBuf->shminfo.shmid, IPC_RMID, 0);
@@ -207,6 +221,7 @@ xm_buffer_destroy(struct pipe_winsys *pws,
oldBuf->shminfo.shmaddr = (char *) -1;
}
else
+#endif
{
if (!oldBuf->userBuffer) {
align_free(oldBuf->data);
@@ -220,7 +235,6 @@ xm_buffer_destroy(struct pipe_winsys *pws,
}
-
/**
* Display/copy the image in the surface into the X window specified
* by the XMesaBuffer.
@@ -230,8 +244,8 @@ xlib_softpipe_display_surface(struct xmesa_buffer *b,
struct pipe_surface *surf)
{
XImage *ximage;
- struct xm_buffer *xm_buf = xm_buffer(
- softpipe_texture(surf->texture)->buffer);
+ struct softpipe_texture *spt = softpipe_texture(surf->texture);
+ struct xm_buffer *xm_buf = xm_buffer(spt->buffer);
static boolean no_swap = 0;
static boolean firsttime = 1;
@@ -243,20 +257,26 @@ xlib_softpipe_display_surface(struct xmesa_buffer *b,
if (no_swap)
return;
+#ifdef USE_XSHM
if (XSHM_ENABLED(xm_buf) && (xm_buf->tempImage == NULL)) {
- assert(surf->block.width == 1);
- assert(surf->block.height == 1);
- alloc_shm_ximage(xm_buf, b, surf->stride/surf->block.size, surf->height);
+ assert(surf->texture->block.width == 1);
+ assert(surf->texture->block.height == 1);
+ alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] /
+ surf->texture->block.size, surf->height);
}
+#endif
ximage = (XSHM_ENABLED(xm_buf)) ? xm_buf->tempImage : b->tempImage;
ximage->data = xm_buf->data;
/* display image in Window */
+#ifdef USE_XSHM
if (XSHM_ENABLED(xm_buf)) {
XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
ximage, 0, 0, 0, 0, surf->width, surf->height, False);
- } else {
+ } else
+#endif
+ {
/* check that the XImage has been previously initialized */
assert(ximage->format);
assert(ximage->bitmap_unit);
@@ -264,7 +284,7 @@ xlib_softpipe_display_surface(struct xmesa_buffer *b,
/* update XImage's fields */
ximage->width = surf->width;
ximage->height = surf->height;
- ximage->bytes_per_line = surf->stride;
+ ximage->bytes_per_line = spt->stride[surf->level];
XPutImage(b->xm_visual->display, b->drawable, b->gc,
ximage, 0, 0, 0, 0, surf->width, surf->height);
@@ -301,12 +321,9 @@ xm_buffer_create(struct pipe_winsys *pws,
unsigned size)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
+#ifdef USE_XSHM
struct xmesa_pipe_winsys *xpws = (struct xmesa_pipe_winsys *) pws;
- buffer->base.refcount = 1;
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
buffer->shminfo.shmid = -1;
buffer->shminfo.shmaddr = (char *) -1;
@@ -315,12 +332,17 @@ xm_buffer_create(struct pipe_winsys *pws,
if (alloc_shm(buffer, size)) {
buffer->data = buffer->shminfo.shmaddr;
+ buffer->shm = 1;
}
}
+#endif
- if (buffer->data == NULL) {
- buffer->shm = 0;
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->base.alignment = alignment;
+ buffer->base.usage = usage;
+ buffer->base.size = size;
+ if (buffer->data == NULL) {
/* align to 16-byte multiple for Cell */
buffer->data = align_malloc(size, max(alignment, 16));
}
@@ -336,11 +358,13 @@ static struct pipe_buffer *
xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;
+#ifdef USE_XSHM
buffer->shm = 0;
+#endif
return &buffer->base;
}