summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-09-11 06:09:05 +1000
committerBen Skeggs <skeggsb@gmail.com>2008-09-11 06:09:05 +1000
commit7158203b081ad34c03382f07e0df748eae235e9b (patch)
treeee61efebbafb5464ec090c21b5e05533588789a1
parent02025148c28d03d644e3d66dde1a423fe21e1c44 (diff)
parenteb5b16d278e0f7ee0121049e43dfee1d52f2b0f7 (diff)
downloadexternal_mesa3d-7158203b081ad34c03382f07e0df748eae235e9b.zip
external_mesa3d-7158203b081ad34c03382f07e0df748eae235e9b.tar.gz
external_mesa3d-7158203b081ad34c03382f07e0df748eae235e9b.tar.bz2
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Conflicts: configs/default
-rw-r--r--Makefile2
-rw-r--r--SConstruct6
-rw-r--r--configs/default3
-rw-r--r--configs/linux-cell12
-rw-r--r--configs/linux-cell-debug10
-rw-r--r--configs/linux-dri3
-rw-r--r--include/GLES/gl.h1
-rw-r--r--include/GLES/glext.h1
-rw-r--r--include/GLES/glplatform.h1
-rw-r--r--include/GLES2/gl2.h1
-rw-r--r--include/GLES2/gl2ext.h1
-rw-r--r--include/GLES2/gl2platform.h1
-rw-r--r--progs/egl/eglgears.c2
-rw-r--r--progs/egl/egltri.c2
-rw-r--r--progs/trivial/Makefile1
-rw-r--r--progs/trivial/long-fixed-func.c151
-rw-r--r--progs/vp/exp.txt5
-rw-r--r--progs/vp/log.txt6
-rw-r--r--progs/vp/vp-tris.c63
-rw-r--r--progs/vp/windows/vp2003.sln21
-rw-r--r--progs/vp/windows/vp2003.vcproj121
-rw-r--r--scons/gallium.py34
-rw-r--r--src/egl/drivers/demo/Makefile3
-rw-r--r--src/egl/drivers/xdri/egl_xdri.c264
-rw-r--r--src/egl/main/eglsurface.c75
-rw-r--r--src/egl/main/eglsurface.h1
-rw-r--r--src/gallium/Makefile2
-rw-r--r--src/gallium/README.portability4
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_cache.c3
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c2
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_hash.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_context.h4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aapoint.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_clip.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_cull.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_flatshade.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_offset.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_stipple.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_twoside.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_unfilled.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_util.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_validate.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_vbuf.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_line.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_point.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.h4
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_emit.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_emit.c11
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c10
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c20
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_post_vs.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_util.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_varray.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache.c172
-rw-r--r--src/gallium/auxiliary/draw/draw_vbuf.h5
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos.c79
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos.h10
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos_io.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos_machine.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_llvm.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_sse.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_varient.c5
-rw-r--r--src/gallium/auxiliary/gallivm/gallivm_cpu.cpp3
-rw-r--r--src/gallium/auxiliary/gallivm/instructions.cpp2
-rw-r--r--src/gallium/auxiliary/gallivm/instructionssoa.cpp2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c27
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c40
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c80
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c22
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c26
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c126
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_validate.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_winsys.c2
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_execmem.c13
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_ppc_spe.c2
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_x86sse.c2
-rw-r--r--src/gallium/auxiliary/sct/sct.c2
-rw-r--r--src/gallium/auxiliary/tgsi/Makefile1
-rw-r--r--src/gallium/auxiliary/tgsi/SConscript1
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.c5
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.h6
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c275
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump_c.c134
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c317
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.h29
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.c161
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.h53
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sanity.c17
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_scan.c6
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sse2.c284
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c164
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_transform.c1
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_transform.h1
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_util.c1
-rw-r--r--src/gallium/auxiliary/translate/translate.c1
-rw-r--r--src/gallium/auxiliary/translate/translate.h2
-rw-r--r--src/gallium/auxiliary/translate/translate_cache.c2
-rw-r--r--src/gallium/auxiliary/translate/translate_generic.c8
-rw-r--r--src/gallium/auxiliary/translate/translate_sse.c2
-rw-r--r--src/gallium/auxiliary/util/Makefile10
-rw-r--r--src/gallium/auxiliary/util/SConscript7
-rw-r--r--src/gallium/auxiliary/util/p_debug.c112
-rw-r--r--src/gallium/auxiliary/util/p_util.c150
-rw-r--r--src/gallium/auxiliary/util/u_blit.c27
-rw-r--r--src/gallium/auxiliary/util/u_draw_quad.c12
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c44
-rw-r--r--src/gallium/auxiliary/util/u_handle_table.c4
-rw-r--r--src/gallium/auxiliary/util/u_hash_table.c5
-rw-r--r--src/gallium/auxiliary/util/u_math.c (renamed from src/gallium/drivers/trace/tr_stream.h)48
-rw-r--r--src/gallium/auxiliary/util/u_math.h438
-rw-r--r--src/gallium/auxiliary/util/u_memory.h232
-rw-r--r--src/gallium/auxiliary/util/u_mm.c2
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h191
-rw-r--r--src/gallium/auxiliary/util/u_pointer.h (renamed from src/gallium/include/pipe/p_pointer.h)20
-rw-r--r--src/gallium/auxiliary/util/u_rect.c328
-rw-r--r--src/gallium/auxiliary/util/u_rect.h72
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c2
-rw-r--r--src/gallium/auxiliary/util/u_snprintf.c9
-rw-r--r--src/gallium/auxiliary/util/u_stream.h61
-rw-r--r--src/gallium/auxiliary/util/u_stream_stdc.c (renamed from src/gallium/drivers/trace/tr_stream.c)56
-rw-r--r--src/gallium/auxiliary/util/u_stream_wd.c224
-rw-r--r--src/gallium/auxiliary/util/u_tile.c (renamed from src/gallium/auxiliary/util/p_tile.c)89
-rw-r--r--src/gallium/auxiliary/util/u_tile.h (renamed from src/gallium/auxiliary/util/p_tile.h)0
-rw-r--r--src/gallium/auxiliary/util/u_time.c20
-rw-r--r--src/gallium/auxiliary/util/u_time.h3
-rw-r--r--src/gallium/auxiliary/util/u_timed_winsys.c346
-rw-r--r--src/gallium/auxiliary/util/u_timed_winsys.h41
-rw-r--r--src/gallium/drivers/cell/common.h5
-rw-r--r--src/gallium/drivers/cell/ppu/Makefile2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_batch.c56
-rw-r--r--src/gallium/drivers/cell/ppu/cell_batch.h3
-rw-r--r--src/gallium/drivers/cell/ppu/cell_clear.c36
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.c46
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.h29
-rw-r--r--src/gallium/drivers/cell/ppu/cell_draw_arrays.c73
-rw-r--r--src/gallium/drivers/cell/ppu/cell_draw_arrays.h10
-rw-r--r--src/gallium/drivers/cell/ppu/cell_flush.c14
-rw-r--r--src/gallium/drivers/cell/ppu/cell_flush.h2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c31
-rw-r--r--src/gallium/drivers/cell/ppu/cell_render.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_screen.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_spu.c28
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state.h16
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_derived.c31
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_emit.c34
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_shader.c32
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_vertex.c12
-rw-r--r--src/gallium/drivers/cell/ppu/cell_surface.c99
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c143
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.h1
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vbuf.c13
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vertex_fetch.c4
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vertex_shader.c7
-rw-r--r--src/gallium/drivers/cell/ppu/cell_winsys.c2
-rw-r--r--src/gallium/drivers/cell/spu/Makefile2
-rw-r--r--src/gallium/drivers/cell/spu/spu_exec.c151
-rw-r--r--src/gallium/drivers/cell/spu/spu_exec.h2
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.c138
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.h8
-rw-r--r--src/gallium/drivers/cell/spu/spu_per_fragment_op.c4
-rw-r--r--src/gallium/drivers/cell/spu/spu_render.c2
-rw-r--r--src/gallium/drivers/cell/spu/spu_tile.c6
-rw-r--r--src/gallium/drivers/cell/spu/spu_tri.c2
-rw-r--r--src/gallium/drivers/cell/spu/spu_util.c24
-rw-r--r--src/gallium/drivers/cell/spu/spu_vertex_fetch.c3
-rw-r--r--src/gallium/drivers/cell/spu/spu_vertex_shader.c29
-rw-r--r--src/gallium/drivers/failover/fo_context.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_context.c13
-rw-r--r--src/gallium/drivers/i915simple/i915_debug_fp.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc.h1
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc_emit.c1
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc_translate.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_emit.c4
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_vbuf.c41
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c7
-rw-r--r--src/gallium/drivers/i915simple/i915_state.c3
-rw-r--r--src/gallium/drivers/i915simple/i915_state_derived.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_state_dynamic.c4
-rw-r--r--src/gallium/drivers/i915simple/i915_state_immediate.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_state_sampler.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_surface.c4
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c23
-rw-r--r--src/gallium/drivers/i965simple/brw_cc.c6
-rw-r--r--src/gallium/drivers/i965simple/brw_clip_state.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_context.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_curbe.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_draw_upload.c1
-rw-r--r--src/gallium/drivers/i965simple/brw_gs_state.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_screen.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_sf_state.c5
-rw-r--r--src/gallium/drivers/i965simple/brw_shader_info.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_state.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_state_batch.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_state_cache.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_state_pool.c13
-rw-r--r--src/gallium/drivers/i965simple/brw_state_upload.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_surface.c4
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.c20
-rw-r--r--src/gallium/drivers/i965simple/brw_vs_state.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_wm.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_decl.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_glsl.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_sampler_state.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_state.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_clear.c31
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c56
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h10
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c9
-rw-r--r--src/gallium/drivers/softpipe/sp_flush.c13
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_exec.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_llvm.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_sse.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_headers.h29
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_setup.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_vbuf.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_quad.c102
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_alpha_test.c9
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_blend.c45
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_bufloop.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_colormask.c11
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_coverage.c16
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_depth_test.c54
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_earlyz.c14
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c25
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_occlusion.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_output.c12
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_stencil.c46
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_stipple.c24
-rw-r--r--src/gallium/drivers/softpipe/sp_query.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_setup.c436
-rw-r--r--src/gallium/drivers/softpipe/sp_state_blend.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_state_rasterizer.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_surface.c121
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c77
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c13
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c4
-rw-r--r--src/gallium/drivers/trace/README53
-rw-r--r--src/gallium/drivers/trace/SConscript10
-rw-r--r--src/gallium/drivers/trace/tr_context.c596
-rw-r--r--src/gallium/drivers/trace/tr_context.h13
-rw-r--r--src/gallium/drivers/trace/tr_dump.c349
-rw-r--r--src/gallium/drivers/trace/tr_dump.h126
-rw-r--r--src/gallium/drivers/trace/tr_screen.c329
-rw-r--r--src/gallium/drivers/trace/tr_screen.h23
-rw-r--r--src/gallium/drivers/trace/tr_state.c519
-rw-r--r--src/gallium/drivers/trace/tr_state.h59
-rw-r--r--src/gallium/drivers/trace/tr_texture.c112
-rw-r--r--src/gallium/drivers/trace/tr_texture.h95
-rw-r--r--src/gallium/drivers/trace/tr_winsys.c265
-rw-r--r--src/gallium/drivers/trace/tr_winsys.h16
-rw-r--r--src/gallium/include/pipe/p_debug.h3
-rw-r--r--src/gallium/include/pipe/p_defines.h1
-rw-r--r--src/gallium/include/pipe/p_format.h29
-rw-r--r--src/gallium/include/pipe/p_inlines.h28
-rw-r--r--src/gallium/include/pipe/p_shader_tokens.h12
-rw-r--r--src/gallium/include/pipe/p_state.h14
-rw-r--r--src/gallium/include/pipe/p_thread.h403
-rw-r--r--src/gallium/include/pipe/p_util.h536
-rw-r--r--src/gallium/state_trackers/python/README7
-rw-r--r--src/gallium/state_trackers/python/SConscript2
-rw-r--r--src/gallium/state_trackers/python/gallium.i6
-rw-r--r--src/gallium/state_trackers/python/p_context.i70
-rw-r--r--src/gallium/state_trackers/python/p_state.i6
-rw-r--r--src/gallium/state_trackers/python/p_texture.i24
-rw-r--r--src/gallium/state_trackers/python/retrace/README17
-rwxr-xr-xsrc/gallium/state_trackers/python/retrace/interpreter.py480
-rwxr-xr-xsrc/gallium/state_trackers/python/retrace/model.py151
-rwxr-xr-xsrc/gallium/state_trackers/python/retrace/parser.py345
-rw-r--r--src/gallium/state_trackers/python/samples/tri.py3
-rw-r--r--src/gallium/state_trackers/python/st_device.c54
-rw-r--r--src/gallium/state_trackers/python/st_device.h8
-rw-r--r--src/gallium/state_trackers/python/st_hardpipe_winsys.c18
-rw-r--r--src/gallium/state_trackers/python/st_sample.c5
-rw-r--r--src/gallium/state_trackers/python/st_softpipe_winsys.c26
-rw-r--r--src/gallium/state_trackers/python/st_winsys.h6
-rw-r--r--src/gallium/winsys/SConscript2
-rw-r--r--src/gallium/winsys/common/intel_drm/glthread.h359
-rw-r--r--src/gallium/winsys/drm/Makefile (renamed from src/gallium/winsys/dri/Makefile)0
-rw-r--r--src/gallium/winsys/drm/Makefile.template (renamed from src/gallium/winsys/dri/Makefile.template)0
-rw-r--r--src/gallium/winsys/drm/SConscript (renamed from src/gallium/winsys/dri/SConscript)0
-rw-r--r--src/gallium/winsys/drm/intel/Makefile (renamed from src/gallium/winsys/common/Makefile)9
-rw-r--r--src/gallium/winsys/drm/intel/common/Makefile (renamed from src/gallium/winsys/common/intel_drm/Makefile)4
-rw-r--r--src/gallium/winsys/drm/intel/common/Makefile.template (renamed from src/gallium/winsys/common/Makefile.template)2
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c (renamed from src/gallium/winsys/common/intel_drm/intel_be_batchbuffer.c)0
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h (renamed from src/gallium/winsys/common/intel_drm/intel_be_batchbuffer.h)0
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_context.c (renamed from src/gallium/winsys/common/intel_drm/intel_be_context.c)0
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_context.h (renamed from src/gallium/winsys/common/intel_drm/intel_be_context.h)0
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_device.c (renamed from src/gallium/winsys/common/intel_drm/intel_be_device.c)2
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_device.h (renamed from src/gallium/winsys/common/intel_drm/intel_be_device.h)0
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c (renamed from src/gallium/winsys/common/intel_drm/ws_dri_bufmgr.c)102
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h (renamed from src/gallium/winsys/common/intel_drm/ws_dri_bufmgr.h)0
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h (renamed from src/gallium/winsys/common/intel_drm/ws_dri_bufpool.h)8
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c (renamed from src/gallium/winsys/common/intel_drm/ws_dri_drmpool.c)4
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c (renamed from src/gallium/winsys/common/intel_drm/ws_dri_fencemgr.c)66
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h (renamed from src/gallium/winsys/common/intel_drm/ws_dri_fencemgr.h)0
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c (renamed from src/gallium/winsys/common/intel_drm/ws_dri_mallocpool.c)6
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c (renamed from src/gallium/winsys/common/intel_drm/ws_dri_slabpool.c)66
-rw-r--r--src/gallium/winsys/drm/intel/dri/Makefile (renamed from src/gallium/winsys/dri/intel/Makefile)9
-rw-r--r--src/gallium/winsys/drm/intel/dri/SConscript (renamed from src/gallium/winsys/dri/intel/SConscript)0
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h (renamed from src/gallium/winsys/egl_drm/intel/intel_batchbuffer.h)2
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_context.c (renamed from src/gallium/winsys/dri/intel/intel_context.c)0
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_context.h (renamed from src/gallium/winsys/dri/intel/intel_context.h)2
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_lock.c (renamed from src/gallium/winsys/dri/intel/intel_lock.c)8
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_reg.h (renamed from src/gallium/winsys/dri/intel/intel_reg.h)0
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_screen.c (renamed from src/gallium/winsys/dri/intel/intel_screen.c)4
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_screen.h (renamed from src/gallium/winsys/dri/intel/intel_screen.h)4
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c (renamed from src/gallium/winsys/dri/intel/intel_swapbuffers.c)2
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h (renamed from src/gallium/winsys/dri/intel/intel_swapbuffers.h)0
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c (renamed from src/gallium/winsys/dri/intel/intel_winsys_softpipe.c)2
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h (renamed from src/gallium/winsys/dri/intel/intel_winsys_softpipe.h)0
-rw-r--r--src/gallium/winsys/drm/intel/dri/server/i830_common.h (renamed from src/gallium/winsys/dri/intel/server/i830_common.h)0
-rw-r--r--src/gallium/winsys/drm/intel/dri/server/i830_dri.h (renamed from src/gallium/winsys/dri/intel/server/i830_dri.h)0
-rw-r--r--src/gallium/winsys/drm/intel/egl/Makefile (renamed from src/gallium/winsys/egl_drm/intel/Makefile)9
-rw-r--r--src/gallium/winsys/drm/intel/egl/SConscript (renamed from src/gallium/winsys/egl_drm/intel/SConscript)0
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_batchbuffer.h (renamed from src/gallium/winsys/dri/intel/intel_batchbuffer.h)2
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_context.c (renamed from src/gallium/winsys/egl_drm/intel/intel_context.c)0
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_context.h (renamed from src/gallium/winsys/egl_drm/intel/intel_context.h)2
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_device.c (renamed from src/gallium/winsys/egl_drm/intel/intel_device.c)0
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_device.h (renamed from src/gallium/winsys/egl_drm/intel/intel_device.h)2
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_egl.c (renamed from src/gallium/winsys/egl_drm/intel/intel_egl.c)123
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_egl.h (renamed from src/gallium/winsys/egl_drm/intel/intel_egl.h)0
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_reg.h (renamed from src/gallium/winsys/egl_drm/intel/intel_reg.h)0
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_swapbuffers.c (renamed from src/gallium/winsys/egl_drm/intel/intel_swapbuffers.c)0
-rw-r--r--src/gallium/winsys/egl_drm/Makefile38
-rw-r--r--src/gallium/winsys/egl_drm/Makefile.template117
-rw-r--r--src/gallium/winsys/egl_xlib/egl_xlib.c2
-rw-r--r--src/gallium/winsys/egl_xlib/sw_winsys.c5
-rw-r--r--src/gallium/winsys/gdi/wmesa.c74
-rw-r--r--src/gallium/winsys/xlib/Makefile5
-rw-r--r--src/gallium/winsys/xlib/SConscript4
-rw-r--r--src/gallium/winsys/xlib/brw_aub.c2
-rw-r--r--src/gallium/winsys/xlib/glxapi.c26
-rw-r--r--src/gallium/winsys/xlib/xm_api.c18
-rw-r--r--src/gallium/winsys/xlib/xm_winsys.c106
-rw-r--r--src/gallium/winsys/xlib/xm_winsys_aub.c5
-rw-r--r--src/gallium/winsys/xlib/xmesaP.h3
-rw-r--r--src/glu/Makefile4
-rw-r--r--src/glw/Makefile8
-rw-r--r--src/mesa/SConscript1
-rw-r--r--src/mesa/main/arrayobj.c33
-rw-r--r--src/mesa/main/attrib.c89
-rw-r--r--src/mesa/main/bufferobj.c188
-rw-r--r--src/mesa/main/bufferobj.h11
-rw-r--r--src/mesa/main/context.c4
-rw-r--r--src/mesa/main/context.h3
-rw-r--r--src/mesa/main/ffvertex_prog.c54
-rw-r--r--src/mesa/main/framebuffer.c12
-rw-r--r--src/mesa/main/points.c4
-rw-r--r--src/mesa/main/texobj.c101
-rw-r--r--src/mesa/main/texstore.c4
-rw-r--r--src/mesa/main/varray.c15
-rw-r--r--src/mesa/shader/arbprogparse.c4
-rw-r--r--src/mesa/shader/prog_parameter.c31
-rw-r--r--src/mesa/shader/prog_parameter.h5
-rw-r--r--src/mesa/shader/prog_print.c4
-rw-r--r--src/mesa/shader/prog_statevars.c2
-rw-r--r--src/mesa/shader/prog_statevars.h2
-rw-r--r--src/mesa/shader/slang/library/slang_common_builtin.gc29
-rw-r--r--src/mesa/shader/slang/library/slang_common_builtin_gc.h1104
-rw-r--r--src/mesa/shader/slang/library/slang_vertex_builtin.gc5
-rw-r--r--src/mesa/shader/slang/library/slang_vertex_builtin_gc.h146
-rw-r--r--src/mesa/shader/slang/slang_codegen.c49
-rw-r--r--src/mesa/shader/slang/slang_emit.c158
-rw-r--r--src/mesa/shader/slang/slang_link.c82
-rw-r--r--src/mesa/sources.mak1
-rw-r--r--src/mesa/state_tracker/acc2.c319
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c8
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c12
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c57
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c34
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c2
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c10
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c18
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c11
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c12
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.h4
-rw-r--r--src/mesa/state_tracker/st_cb_flush.c2
-rw-r--r--src/mesa/state_tracker/st_cb_get.c97
-rw-r--r--src/mesa/state_tracker/st_cb_get.h37
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c128
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c64
-rw-r--r--src/mesa/state_tracker/st_cb_texture.h4
-rw-r--r--src/mesa/state_tracker/st_context.c12
-rw-r--r--src/mesa/state_tracker/st_context.h2
-rw-r--r--src/mesa/state_tracker/st_draw.c310
-rw-r--r--src/mesa/state_tracker/st_extensions.c20
-rw-r--r--src/mesa/state_tracker/st_format.c28
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c6
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c8
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c171
-rw-r--r--src/mesa/state_tracker/st_program.c76
-rw-r--r--src/mesa/state_tracker/st_program.h8
-rw-r--r--src/mesa/state_tracker/st_public.h13
-rw-r--r--src/mesa/state_tracker/st_texture.c98
-rw-r--r--src/mesa/state_tracker/st_texture.h6
-rw-r--r--src/mesa/vbo/vbo_exec_api.c8
-rw-r--r--src/mesa/vbo/vbo_exec_array.c12
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c26
-rw-r--r--src/mesa/vbo/vbo_save.c16
-rw-r--r--src/mesa/vbo/vbo_save_api.c17
-rw-r--r--src/mesa/vbo/vbo_save_draw.c28
417 files changed, 11650 insertions, 6318 deletions
diff --git a/Makefile b/Makefile
index 9b3be43..b6b8bce 100644
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,7 @@ realclean:
-rm -f `find . -name \*.a`
-rm -f `find . -name \*.so`
-rm -f `find . -name depend`
+ -rm -f `find . -name depend.bak`
-rm -rf lib*
$(MAKE) clean
-rm -f $(TOP)/configs/current
@@ -100,6 +101,7 @@ linux \
linux-alpha \
linux-alpha-static \
linux-cell \
+linux-cell-debug \
linux-debug \
linux-directfb \
linux-dri \
diff --git a/SConstruct b/SConstruct
index ee96bc5..c1dc624 100644
--- a/SConstruct
+++ b/SConstruct
@@ -32,10 +32,10 @@ import common
default_statetrackers = 'mesa'
if common.default_platform in ('linux', 'freebsd', 'darwin'):
- default_drivers = 'softpipe,failover,i915simple,i965simple'
+ default_drivers = 'softpipe,failover,i915simple,i965simple,trace'
default_winsys = 'xlib'
elif common.default_platform in ('winddk',):
- default_drivers = 'softpipe,i915simple'
+ default_drivers = 'softpipe,i915simple,trace'
default_winsys = 'all'
else:
default_drivers = 'all'
@@ -50,6 +50,8 @@ opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
['xlib', 'intel', 'gdi']))
+opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
+
env = Environment(
options = opts,
tools = ['gallium'],
diff --git a/configs/default b/configs/default
index 1443514..263955d 100644
--- a/configs/default
+++ b/configs/default
@@ -73,7 +73,6 @@ EGL_DRIVERS_DIRS = demo
GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
GALLIUM_DRIVER_DIRS = softpipe i915simple i965simple nv04 nv10 nv30 nv40 nv50 failover
-GALLIUM_WINSYS_COMMON_DIRS =
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVER_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
GALLIUM_WINSYS_DIRS = xlib egl_xlib
@@ -91,7 +90,7 @@ APP_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LI
# Installation directories (for make install)
INSTALL_DIR = /usr/local
-DRI_DRIVER_INSTALL_DIR = /usr/X11R6/lib/modules/dri
+DRI_DRIVER_INSTALL_DIR = /usr/lib/dri
# Where libGL will look for DRI hardware drivers
DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
diff --git a/configs/linux-cell b/configs/linux-cell
index a701fa7..cdaa17c 100644
--- a/configs/linux-cell
+++ b/configs/linux-cell
@@ -1,4 +1,4 @@
-# linux-cell
+# linux-cell (non-debug build)
include $(TOP)/configs/default
@@ -13,10 +13,13 @@ CC = ppu32-gcc
CXX = ppu32-g++
HOST_CC = gcc
-OPT_FLAGS = -g
+OPT_FLAGS = -O3
# Cell SDK location
-SDK = /opt/ibm/cell-sdk/prototype/sysroot/usr
+## For SDK 2.1: (plus, remove -DSPU_MAIN_PARAM_LONG_LONG below)
+#SDK = /opt/ibm/cell-sdk/prototype/sysroot/usr
+## For SDK 3.0:
+SDK = /opt/cell/sdk/usr/
CFLAGS = $(OPT_FLAGS) -Wall -Winline -fPIC -m32 -mabi=altivec -maltivec \
@@ -36,6 +39,8 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread \
-L$(SDK)/lib -m32 -Wl,-m,elf32ppc -R$(SDK)/lib -lspe2
+CELL_SPU_LIB = $(TOP)/src/gallium/drivers/cell/spu/g3d_spu.a
+
### SPU stuff
@@ -43,6 +48,7 @@ SPU_CC = spu-gcc
SPU_CFLAGS = $(OPT_FLAGS) -W -Wall -Winline -Wmissing-prototypes -Wno-main \
-I. -I$(SDK)/spu/include -I$(TOP)/src/mesa/ $(INCLUDE_DIRS) \
+ -DSPU_MAIN_PARAM_LONG_LONG \
-include spu_intrinsics.h
SPU_LFLAGS = -L$(SDK)/spu/lib -Wl,-N -lmisc
diff --git a/configs/linux-cell-debug b/configs/linux-cell-debug
new file mode 100644
index 0000000..42f3245
--- /dev/null
+++ b/configs/linux-cell-debug
@@ -0,0 +1,10 @@
+# linux-cell-debug
+
+include $(TOP)/configs/linux-cell
+
+# just override name and OPT_FLAGS here:
+
+CONFIG_NAME = linux-cell-debug
+
+OPT_FLAGS = -g -DDEBUG
+
diff --git a/configs/linux-dri b/configs/linux-dri
index ce5d2b7..8db6e41 100644
--- a/configs/linux-dri
+++ b/configs/linux-dri
@@ -55,8 +55,7 @@ EGL_DRIVERS_DIRS = demo dri xdri
DRIVER_DIRS =
WINDOW_SYSTEM = dri
-GALLIUM_WINSYS_DIRS = dri egl_xlib
-GALLIUM_WINSYS_COMMON_DIRS = intel_drm
+GALLIUM_WINSYS_DIRS = drm egl_xlib
# gamma are missing because they have not been converted to use the new
# interface.
diff --git a/include/GLES/gl.h b/include/GLES/gl.h
index 76cc947..8ffcdc1 100644
--- a/include/GLES/gl.h
+++ b/include/GLES/gl.h
@@ -1,7 +1,6 @@
#ifndef __gl_h_
#define __gl_h_
-/* $Id: gl.h 4533 2007-11-26 11:19:35Z markc $ */
#include <GLES/glplatform.h>
diff --git a/include/GLES/glext.h b/include/GLES/glext.h
index 4de33bc..a558294 100644
--- a/include/GLES/glext.h
+++ b/include/GLES/glext.h
@@ -1,7 +1,6 @@
#ifndef __glext_h_
#define __glext_h_
-/* $Id: glext.h 5687 2008-05-13 21:31:32Z oddhack $ */
#ifdef __cplusplus
extern "C" {
diff --git a/include/GLES/glplatform.h b/include/GLES/glplatform.h
index 6e725b1..7c8392b 100644
--- a/include/GLES/glplatform.h
+++ b/include/GLES/glplatform.h
@@ -1,7 +1,6 @@
#ifndef __glplatform_h_
#define __glplatform_h_
-/* $Id: glplatform.h 4585 2007-11-30 09:49:39Z markc $ */
#ifdef __cplusplus
extern "C" {
diff --git a/include/GLES2/gl2.h b/include/GLES2/gl2.h
index 6466170..5ce939c 100644
--- a/include/GLES2/gl2.h
+++ b/include/GLES2/gl2.h
@@ -1,7 +1,6 @@
#ifndef __gl2_h_
#define __gl2_h_
-/* $Id: gl2.h 5418 2008-03-26 19:57:12Z oddhack $ */
#include <GLES2/gl2platform.h>
diff --git a/include/GLES2/gl2ext.h b/include/GLES2/gl2ext.h
index 04418c1..305b29b 100644
--- a/include/GLES2/gl2ext.h
+++ b/include/GLES2/gl2ext.h
@@ -1,7 +1,6 @@
#ifndef __gl2ext_h_
#define __gl2ext_h_
-/* $Id: gl2ext.h 5767 2008-06-02 17:44:20Z benj $ */
#ifdef __cplusplus
extern "C" {
diff --git a/include/GLES2/gl2platform.h b/include/GLES2/gl2platform.h
index 7891a61..7e3dbc6 100644
--- a/include/GLES2/gl2platform.h
+++ b/include/GLES2/gl2platform.h
@@ -1,7 +1,6 @@
#ifndef __gl2platform_h_
#define __gl2platform_h_
-/* $Id: gl2platform.h 4532 2007-11-26 11:12:44Z markc $ */
#ifdef __cplusplus
extern "C" {
diff --git a/progs/egl/eglgears.c b/progs/egl/eglgears.c
index 20f6c1f..31346d9 100644
--- a/progs/egl/eglgears.c
+++ b/progs/egl/eglgears.c
@@ -415,7 +415,7 @@ main(int argc, char *argv[])
eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w);
eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h);
printf("%3d: %d x %d\n", i, w, h);
- if (w > width && h > height && w <= 1280 && h <= 1024) {
+ if (w > width && h > height) {
width = w;
height = h;
chosenMode = i;
diff --git a/progs/egl/egltri.c b/progs/egl/egltri.c
index 78c6793..44096d9 100644
--- a/progs/egl/egltri.c
+++ b/progs/egl/egltri.c
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w);
eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h);
printf("%3d: %d x %d\n", i, w, h);
- if (w > width && h > height && w <= 1280 && h <= 1024) {
+ if (w > width && h > height) {
width = w;
height = h;
chosenMode = i;
diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile
index 786576c..d745fef 100644
--- a/progs/trivial/Makefile
+++ b/progs/trivial/Makefile
@@ -41,6 +41,7 @@ SOURCES = \
linestrip-stipple-wide.c \
linestrip-stipple.c \
linestrip.c \
+ long-fixed-func.c \
pgon-mode.c \
point-clip.c \
point-param.c \
diff --git a/progs/trivial/long-fixed-func.c b/progs/trivial/long-fixed-func.c
new file mode 100644
index 0000000..88f4fe0
--- /dev/null
+++ b/progs/trivial/long-fixed-func.c
@@ -0,0 +1,151 @@
+/**
+ * Enable as much fixed-function vertex processing state as possible
+ * to test fixed-function -> program code generation.
+ */
+
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, (GLint)width, (GLint)height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+
+static void
+Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(.8,0,0);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glColor3f(0,.9,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.0, 0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ glutSwapBuffers();
+}
+
+
+static void
+Init(void)
+{
+ GLubyte tex[16][16][4];
+ GLfloat pos[4] = {5, 10, 3, 1.0};
+ int i, j;
+
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.3, 0.1, 0.3, 0.0);
+
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ if ((i+j) & 1) {
+ tex[i][j][0] = 100;
+ tex[i][j][1] = 100;
+ tex[i][j][2] = 100;
+ tex[i][j][3] = 255;
+ }
+ else {
+ tex[i][j][0] = 200;
+ tex[i][j][1] = 200;
+ tex[i][j][2] = 200;
+ tex[i][j][3] = 255;
+ }
+ }
+ }
+
+
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
+ glFogi(GL_FOG_MODE, GL_LINEAR);
+ glEnable(GL_FOG);
+
+ glPointParameterfv(GL_DISTANCE_ATTENUATION_EXT, pos);
+
+ for (i = 0; i < 8; i++) {
+ GLuint texObj;
+
+ glEnable(GL_LIGHT0 + i);
+ glLightf(GL_LIGHT0 + i, GL_SPOT_EXPONENT, 3.5);
+ glLightf(GL_LIGHT0 + i, GL_SPOT_CUTOFF, 30.);
+ glLightf(GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 3.);
+ glLightf(GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 3.);
+ glLightf(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 3.);
+ glLightfv(GL_LIGHT0 + i, GL_POSITION, pos);
+
+ glActiveTexture(GL_TEXTURE0 + i);
+ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+ glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+ glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+ glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+ glEnable(GL_TEXTURE_GEN_S);
+ glEnable(GL_TEXTURE_GEN_T);
+ glEnable(GL_TEXTURE_GEN_R);
+ glEnable(GL_TEXTURE_GEN_Q);
+ glEnable(GL_TEXTURE_2D);
+
+ glMatrixMode(GL_TEXTURE);
+ glScalef(2.0, 1.0, 3.0);
+
+ glGenTextures(1, &texObj);
+ glBindTexture(GL_TEXTURE_2D, texObj);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ }
+
+ glEnable(GL_LIGHTING);
+ glActiveTexture(GL_TEXTURE0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ if (key == 27) {
+ exit(0);
+ }
+ glutPostRedisplay();
+}
+
+
+int
+main(int argc, char **argv)
+{
+ GLenum type = GLUT_RGB | GLUT_DOUBLE;
+
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize( 250, 250);
+ glutInitDisplayMode(type);
+ if (glutCreateWindow("tri-long-fixedfunc") == GL_FALSE) {
+ exit(1);
+ }
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/vp/exp.txt b/progs/vp/exp.txt
new file mode 100644
index 0000000..601aae7
--- /dev/null
+++ b/progs/vp/exp.txt
@@ -0,0 +1,5 @@
+!!VP1.0
+EXP R0, v[COL0].x;
+ADD o[COL0], R0.z, -R0.w;
+MOV o[HPOS], v[OPOS];
+END
diff --git a/progs/vp/log.txt b/progs/vp/log.txt
new file mode 100644
index 0000000..9b04268
--- /dev/null
+++ b/progs/vp/log.txt
@@ -0,0 +1,6 @@
+!!VP1.0
+ADD R0, v[COL0], v[COL0];
+ADD R0, R0, R0;
+LOG o[COL0], R0.x;
+MOV o[HPOS], v[OPOS];
+END
diff --git a/progs/vp/vp-tris.c b/progs/vp/vp-tris.c
index eb450cb..3fe35f7 100644
--- a/progs/vp/vp-tris.c
+++ b/progs/vp/vp-tris.c
@@ -5,10 +5,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#define GL_GLEXT_PROTOTYPES
#include <GL/glut.h>
+
+#ifndef WIN32
#include <unistd.h>
#include <signal.h>
+#define GL_GLEXT_PROTOTYPES
+#else
+#include <GL/glext.h>
+#endif
+
+#ifdef WIN32
+static PFNGLBINDPROGRAMARBPROC glBindProgramARB = NULL;
+static PFNGLGENPROGRAMSARBPROC glGenProgramsARB = NULL;
+static PFNGLPROGRAMSTRINGARBPROC glProgramStringARB = NULL;
+static PFNGLISPROGRAMARBPROC glIsProgramARB = NULL;
+
+static PFNGLBINDPROGRAMNVPROC glBindProgramNV = NULL;
+static PFNGLGENPROGRAMSNVPROC glGenProgramsNV = NULL;
+static PFNGLLOADPROGRAMNVPROC glLoadProgramNV = NULL;
+static PFNGLISPROGRAMNVPROC glIsProgramNV = NULL;
+#endif
static const char *filename = NULL;
static GLuint nr_steps = 4;
@@ -25,6 +42,9 @@ static void usage( char *name )
unsigned show_fps = 0;
unsigned int frame_cnt = 0;
+
+#ifndef WIN32
+
void alarmhandler(int);
void alarmhandler (int sig)
@@ -39,6 +59,8 @@ void alarmhandler (int sig)
alarm(5);
}
+#endif
+
static void args(int argc, char *argv[])
{
GLint i;
@@ -83,7 +105,7 @@ static void Init( void )
exit(1);
}
- sz = fread(buf, 1, sizeof(buf), f);
+ sz = (GLuint) fread(buf, 1, sizeof(buf), f);
if (!feof(f)) {
fprintf(stderr, "file too long\n");
exit(1);
@@ -91,13 +113,37 @@ static void Init( void )
fprintf(stderr, "%.*s\n", sz, buf);
- glEnable(GL_VERTEX_PROGRAM_NV);
+ if (strncmp( buf, "!!VP", 4 ) == 0) {
+#ifdef WIN32
+ glBindProgramNV = (PFNGLBINDPROGRAMNVPROC) wglGetProcAddress( "glBindProgramNV" );
+ glGenProgramsNV = (PFNGLGENPROGRAMSNVPROC) wglGetProcAddress( "glGenProgramsNV" );
+ glLoadProgramNV = (PFNGLLOADPROGRAMNVPROC) wglGetProcAddress( "glLoadProgramNV" );
+ glIsProgramNV = (PFNGLISPROGRAMNVPROC) wglGetProcAddress( "glIsProgramNV" );
+#endif
+
+ glEnable( GL_VERTEX_PROGRAM_NV );
+ glGenProgramsNV( 1, &prognum );
+ glBindProgramNV( GL_VERTEX_PROGRAM_NV, prognum );
+ glLoadProgramNV( GL_VERTEX_PROGRAM_NV, prognum, sz, (const GLubyte *) buf );
+ assert( glIsProgramNV( prognum ) );
+ }
+ else {
+#ifdef WIN32
+ glBindProgramARB = (PFNGLBINDPROGRAMARBPROC) wglGetProcAddress( "glBindProgramARB" );
+ glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) wglGetProcAddress( "glGenProgramsARB" );
+ glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) wglGetProcAddress( "glProgramStringARB" );
+ glIsProgramARB = (PFNGLISPROGRAMARBPROC) wglGetProcAddress( "glIsProgramARB" );
+#endif
- glGenProgramsARB(1, &prognum);
+ glEnable(GL_VERTEX_PROGRAM_ARB);
- glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
- glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
- sz, (const GLubyte *) buf);
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ sz, (const GLubyte *) buf);
+ assert(glIsProgramARB(prognum));
+ }
errno = glGetError();
printf("glGetError = %d\n", errno);
@@ -109,7 +155,6 @@ static void Init( void )
printf("errorpos: %d\n", errorpos);
printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
}
- assert(glIsProgramARB(prognum));
}
@@ -236,10 +281,12 @@ int main( int argc, char *argv[] )
glutDisplayFunc( Display );
args( argc, argv );
Init();
+#ifndef WIN32
if (show_fps) {
signal(SIGALRM, alarmhandler);
alarm(5);
}
+#endif
glutMainLoop();
return 0;
}
diff --git a/progs/vp/windows/vp2003.sln b/progs/vp/windows/vp2003.sln
new file mode 100644
index 0000000..76de5cf
--- /dev/null
+++ b/progs/vp/windows/vp2003.sln
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vp2003", "vp2003.vcproj", "{E1C70416-98E7-4282-B6B2-6C9CF90B12C0}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Debug.ActiveCfg = Debug|Win32
+ {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Debug.Build.0 = Debug|Win32
+ {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Release.ActiveCfg = Release|Win32
+ {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/progs/vp/windows/vp2003.vcproj b/progs/vp/windows/vp2003.vcproj
new file mode 100644
index 0000000..adca2c5
--- /dev/null
+++ b/progs/vp/windows/vp2003.vcproj
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="vp2003"
+ ProjectGUID="{E1C70416-98E7-4282-B6B2-6C9CF90B12C0}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="glut32.lib"
+ OutputFile="$(OutDir)/vp2003.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/vp2003.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="glut32.lib"
+ OutputFile="$(OutDir)/vp2003.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\vp-tris.c">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/scons/gallium.py b/scons/gallium.py
index 43603e5..3631607 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -140,6 +140,29 @@ def createCodeGenerateMethod(env):
env.AddMethod(code_generate, 'CodeGenerate')
+def symlink(target, source, env):
+ target = str(target[0])
+ source = str(source[0])
+ if os.path.islink(target) or os.path.exists(target):
+ os.remove(target)
+ os.symlink(os.path.basename(source), target)
+
+def install_shared_library(env, source, version = ()):
+ source = str(source[0])
+ version = tuple(map(str, version))
+ target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib')
+ target_name = '.'.join((str(source),) + version)
+ last = env.InstallAs(os.path.join(target_dir, target_name), source)
+ while len(version):
+ version = version[:-1]
+ target_name = '.'.join((str(source),) + version)
+ action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
+ last = env.Command(os.path.join(target_dir, target_name), last, action)
+
+def createInstallMethods(env):
+ env.AddMethod(install_shared_library, 'InstallSharedLibrary')
+
+
def generate(env):
"""Common environment generation code"""
@@ -290,7 +313,7 @@ def generate(env):
]
if msvc:
# See also:
- # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
+ # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
# - cl /?
if debug:
cflags += [
@@ -302,7 +325,8 @@ def generate(env):
cflags += [
'/Ox', # maximum optimizations
'/Oi', # enable intrinsic functions
- '/Os', # favor code space
+ '/Ot', # favor code speed
+ #'/fp:fast', # fast floating point
]
if env['profile']:
cflags += [
@@ -313,6 +337,11 @@ def generate(env):
'/W3', # warning level
#'/Wp64', # enable 64 bit porting warnings
]
+ if env['machine'] == 'x86':
+ cflags += [
+ #'/QIfist', # Suppress _ftol
+ #'/arch:SSE2', # use the SSE2 instructions
+ ]
if platform == 'windows':
cflags += [
# TODO
@@ -420,6 +449,7 @@ def generate(env):
# Custom builders and methods
createConvenienceLibBuilder(env)
createCodeGenerateMethod(env)
+ createInstallMethods(env)
# for debugging
#print env.Dump()
diff --git a/src/egl/drivers/demo/Makefile b/src/egl/drivers/demo/Makefile
index 5c05633..e5a7be2 100644
--- a/src/egl/drivers/demo/Makefile
+++ b/src/egl/drivers/demo/Makefile
@@ -21,8 +21,7 @@ default: $(TOP)/$(LIB_DIR)/demodriver.so
$(TOP)/$(LIB_DIR)/demodriver.so: $(OBJECTS)
- $(TOP)/bin/mklib -o demodriver.so -noprefix \
- -install $(TOP)/$(LIB_DIR) $(OBJECTS)
+ $(TOP)/bin/mklib -o demodriver.so -noprefix $(OBJECTS)
diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c
index 3681d98..9ff7158 100644
--- a/src/egl/drivers/xdri/egl_xdri.c
+++ b/src/egl/drivers/xdri/egl_xdri.c
@@ -64,6 +64,12 @@
#include "egllog.h"
#include "eglsurface.h"
+#include <GL/gl.h>
+
+typedef void (*glGetIntegerv_t)(GLenum, GLint *);
+typedef void (*glBindTexture_t)(GLenum, GLuint);
+typedef void (*glCopyTexImage2D_t)(GLenum, GLint, GLenum, GLint, GLint,
+ GLint, GLint, GLint);
#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T))
@@ -99,6 +105,8 @@ struct xdri_egl_context
_EGLContext Base; /**< base class */
__DRIcontext driContext;
+
+ GLint bound_tex_object;
};
@@ -147,6 +155,11 @@ lookup_context(EGLContext c)
return (struct xdri_egl_context *) context;
}
+static struct xdri_egl_context *
+current_context(void)
+{
+ return (struct xdri_egl_context *) _eglGetCurrentContext();
+}
/** Map EGLConfig handle to xdri_egl_config object */
static struct xdri_egl_config *
@@ -210,7 +223,8 @@ create_configs(_EGLDisplay *disp, __GLXdisplayPrivate *glx_priv)
SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis);
SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis);
/* XXX only window rendering allowed ATM */
- SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
+ SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE,
+ (EGL_WINDOW_BIT | EGL_PBUFFER_BIT));
/* XXX possibly other things to init... */
@@ -651,6 +665,35 @@ xdri_eglInitialize(_EGLDriver *drv, EGLDisplay dpy,
}
+/*
+ * Do some clean-up that normally occurs in XCloseDisplay().
+ * We do this here because we're about to unload a dynamic library
+ * that has added some per-display extension data and callbacks.
+ * If we don't do this here we'll crash in XCloseDisplay() because it'll
+ * try to call functions that went away when the driver library was unloaded.
+ */
+static void
+FreeDisplayExt(Display *dpy)
+{
+ _XExtension *ext, *next;
+
+ for (ext = dpy->ext_procs; ext; ext = next) {
+ next = ext->next;
+ if (ext->close_display) {
+ ext->close_display(dpy, &ext->codes);
+ ext->close_display = NULL;
+ }
+ if (ext->name)
+ Xfree(ext->name);
+ Xfree(ext);
+ }
+ dpy->ext_procs = NULL;
+
+ _XFreeExtData (dpy->ext_data);
+ dpy->ext_data = NULL;
+}
+
+
/**
* Called via eglTerminate(), drv->API.Terminate().
*/
@@ -658,11 +701,16 @@ static EGLBoolean
xdri_eglTerminate(_EGLDriver *drv, EGLDisplay dpy)
{
struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv);
+ _EGLDisplay *disp = _eglLookupDisplay(dpy);
_eglLog(_EGL_DEBUG, "XDRI: eglTerminate");
_eglLog(_EGL_DEBUG, "XDRI: Closing %s", xdri_drv->dri_driver_name);
+
+ FreeDisplayExt(disp->Xdpy);
+
#if 0
+ /* this causes a segfault for some reason */
dlclose(xdri_drv->dri_driver_handle);
#endif
xdri_drv->dri_driver_handle = NULL;
@@ -820,6 +868,86 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
}
+/**
+ * Called via eglCreatePbufferSurface(), drv->API.CreatePbufferSurface().
+ */
+static EGLSurface
+xdri_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
+ const EGLint *attrib_list)
+{
+ _EGLDisplay *disp = _eglLookupDisplay(dpy);
+ struct xdri_egl_surface *xdri_surf;
+ struct xdri_egl_config *xdri_config = lookup_config(drv, dpy, config);
+ int scrn = DefaultScreen(disp->Xdpy);
+ Window window;
+
+ xdri_surf = CALLOC_STRUCT(xdri_egl_surface);
+ if (!xdri_surf)
+ return EGL_NO_SURFACE;
+
+ if (!_eglInitSurface(drv, dpy, &xdri_surf->Base, EGL_PBUFFER_BIT,
+ config, attrib_list)) {
+ free(xdri_surf);
+ return EGL_FALSE;
+ }
+
+ /* Create a dummy X window */
+ {
+ Window root = RootWindow(disp->Xdpy, scrn);
+ XSetWindowAttributes attr;
+ XVisualInfo *visInfo, visTemplate;
+ unsigned mask;
+ int nvis;
+
+ visTemplate.visualid = xdri_config->mode->visualID;
+ visInfo = XGetVisualInfo(disp->Xdpy, VisualIDMask, &visTemplate, &nvis);
+ if (!visInfo) {
+ return EGL_NO_SURFACE;
+ }
+
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(disp->Xdpy, root,
+ visInfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ window = XCreateWindow(disp->Xdpy, root, 0, 0,
+ xdri_surf->Base.Width, xdri_surf->Base.Height,
+ 0, visInfo->depth, InputOutput,
+ visInfo->visual, mask, &attr);
+
+ /*XMapWindow(disp->Xdpy, window);*/
+ XFree(visInfo);
+
+ /* set hints and properties */
+ /*
+ sizehints.width = xdri_surf->Base.Width;
+ sizehints.height = xdri_surf->Base.Height;
+ sizehints.flags = USPosition;
+ XSetNormalHints(disp->Xdpy, window, &sizehints);
+ */
+ }
+
+ if (!XF86DRICreateDrawable(disp->Xdpy, scrn, window, &xdri_surf->hDrawable)) {
+ free(xdri_surf);
+ return EGL_FALSE;
+ }
+
+ xdri_surf->driDrawable = window;
+
+ _eglSaveSurface(&xdri_surf->Base);
+
+ _eglLog(_EGL_DEBUG,
+ "XDRI: CreatePbufferSurface handle %d hDrawable %d",
+ _eglGetSurfaceHandle(&xdri_surf->Base),
+ (int) xdri_surf->hDrawable);
+
+ return _eglGetSurfaceHandle(&xdri_surf->Base);
+}
+
+
+
static EGLBoolean
xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
{
@@ -845,6 +973,137 @@ xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
static EGLBoolean
+xdri_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface,
+ EGLint buffer)
+{
+ typedef int (*bind_teximage)(__DRInativeDisplay *dpy,
+ __DRIid surface, __DRIscreen *psc,
+ int buffer, int target, int format,
+ int level, int mipmap);
+
+ bind_teximage egl_dri_bind_teximage;
+
+ _EGLDisplay *disp = _eglLookupDisplay(dpy);
+
+ struct xdri_egl_context *xdri_ctx = current_context();
+ struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv);
+ struct xdri_egl_surface *xdri_surf = lookup_surface(surface);
+
+ __DRIid dri_surf = xdri_surf ? xdri_surf->driDrawable : 0;
+
+ __GLXscreenConfigs *scrnConf = xdri_drv->glx_priv->screenConfigs;
+ __DRIscreen *psc = &scrnConf->driScreen;
+
+ /* this call just does error checking */
+ if (!_eglBindTexImage(drv, dpy, surface, buffer)) {
+ return EGL_FALSE;
+ }
+
+ egl_dri_bind_teximage =
+ (bind_teximage) dlsym(NULL, "egl_dri_bind_teximage");
+ if (egl_dri_bind_teximage) {
+ return egl_dri_bind_teximage(disp->Xdpy, dri_surf, psc,
+ buffer,
+ xdri_surf->Base.TextureTarget,
+ xdri_surf->Base.TextureFormat,
+ xdri_surf->Base.MipmapLevel,
+ xdri_surf->Base.MipmapTexture);
+ }
+ else {
+ /* fallback path based on glCopyTexImage() */
+ /* Get/save currently bound 2D texobj name */
+ glGetIntegerv_t glGetIntegerv_func =
+ (glGetIntegerv_t) dlsym(NULL, "glGetIntegerv");
+ GLint curTexObj = 0;
+ if (glGetIntegerv_func) {
+ (*glGetIntegerv_func)(GL_TEXTURE_BINDING_2D, &curTexObj);
+ }
+ xdri_ctx->bound_tex_object = curTexObj;
+ }
+
+ return EGL_FALSE;
+}
+
+
+static EGLBoolean
+xdri_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface,
+ EGLint buffer)
+{
+ typedef int (*release_teximage)(__DRInativeDisplay *dpy,
+ __DRIid surface, __DRIscreen *psc,
+ int buffer, int target, int format,
+ int level, int mipmap);
+ release_teximage egl_dri_release_teximage;
+
+ _EGLDisplay *disp = _eglLookupDisplay(dpy);
+
+ struct xdri_egl_context *xdri_ctx = current_context();
+ struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv);
+ struct xdri_egl_surface *xdri_surf = lookup_surface(surface);
+
+ __DRIid dri_surf = xdri_surf ? xdri_surf->driDrawable : 0;
+
+ __GLXscreenConfigs *scrnConf = xdri_drv->glx_priv->screenConfigs;
+ __DRIscreen *psc = &scrnConf->driScreen;
+
+ /* this call just does error checking */
+ if (!_eglReleaseTexImage(drv, dpy, surface, buffer)) {
+ return EGL_FALSE;
+ }
+
+ egl_dri_release_teximage =
+ (release_teximage) dlsym(NULL, "egl_dri_release_teximage");
+ if (egl_dri_release_teximage) {
+ return egl_dri_release_teximage(disp->Xdpy, dri_surf, psc,
+ buffer,
+ xdri_surf->Base.TextureTarget,
+ xdri_surf->Base.TextureFormat,
+ xdri_surf->Base.MipmapLevel,
+ xdri_surf->Base.MipmapTexture);
+ }
+ else {
+ /* fallback path based on glCopyTexImage() */
+ glGetIntegerv_t glGetIntegerv_func =
+ (glGetIntegerv_t) dlsym(NULL, "glGetIntegerv");
+ glBindTexture_t glBindTexture_func =
+ (glBindTexture_t) dlsym(NULL, "glBindTexture");
+ glCopyTexImage2D_t glCopyTexImage2D_func =
+ (glCopyTexImage2D_t) dlsym(NULL, "glCopyTexImage2D");
+ GLint curTexObj;
+ GLenum intFormat;
+ GLint level, width, height;
+
+ if (xdri_surf->Base.TextureFormat == EGL_TEXTURE_RGBA)
+ intFormat = GL_RGBA;
+ else
+ intFormat = GL_RGB;
+ level = xdri_surf->Base.MipmapLevel;
+ width = xdri_surf->Base.Width >> level;
+ height = xdri_surf->Base.Height >> level;
+
+ if (width > 0 && height > 0 &&
+ glGetIntegerv_func && glBindTexture_func && glCopyTexImage2D_func) {
+ glGetIntegerv_func(GL_TEXTURE_BINDING_2D, &curTexObj);
+ /* restore texobj from time of eglBindTexImage() call */
+ if (curTexObj != xdri_ctx->bound_tex_object)
+ glBindTexture_func(GL_TEXTURE_2D, xdri_ctx->bound_tex_object);
+ /* copy pbuffer image to texture */
+ glCopyTexImage2D_func(GL_TEXTURE_2D,
+ level,
+ intFormat,
+ 0, 0, width, height, 0);
+ /* restore current texture */
+ if (curTexObj != xdri_ctx->bound_tex_object)
+ glBindTexture_func(GL_TEXTURE_2D, curTexObj);
+ }
+ xdri_ctx->bound_tex_object = -1;
+ }
+
+ return EGL_FALSE;
+}
+
+
+static EGLBoolean
xdri_eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw)
{
_EGLDisplay *disp = _eglLookupDisplay(dpy);
@@ -897,7 +1156,10 @@ _eglMain(_EGLDisplay *disp, const char *args)
xdri_drv->Base.API.CreateContext = xdri_eglCreateContext;
xdri_drv->Base.API.MakeCurrent = xdri_eglMakeCurrent;
xdri_drv->Base.API.CreateWindowSurface = xdri_eglCreateWindowSurface;
+ xdri_drv->Base.API.CreatePbufferSurface = xdri_eglCreatePbufferSurface;
xdri_drv->Base.API.DestroySurface = xdri_eglDestroySurface;
+ xdri_drv->Base.API.BindTexImage = xdri_eglBindTexImage;
+ xdri_drv->Base.API.ReleaseTexImage = xdri_eglReleaseTexImage;
xdri_drv->Base.API.SwapBuffers = xdri_eglSwapBuffers;
xdri_drv->Base.ClientAPIsMask = (EGL_OPENGL_BIT |
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 3777049..6905aca 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -61,6 +61,12 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy,
return EGL_FALSE;
}
+ if ((GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE) & type) == 0) {
+ /* The config can't be used to create a surface of this type */
+ _eglError(EGL_BAD_CONFIG, func);
+ return EGL_FALSE;
+ }
+
/*
* Parse attribute list. Different kinds of surfaces support different
* attributes.
@@ -277,12 +283,7 @@ _eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw)
/* Basically just do error checking here. Drivers have to do the
* actual buffer swap.
*/
- _EGLContext *context = _eglGetCurrentContext();
_EGLSurface *surface = _eglLookupSurface(draw);
- if (context && context->DrawSurface != surface) {
- _eglError(EGL_BAD_SURFACE, "eglSwapBuffers");
- return EGL_FALSE;
- }
if (surface == NULL) {
_eglError(EGL_BAD_SURFACE, "eglSwapBuffers");
return EGL_FALSE;
@@ -484,7 +485,8 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
* Default fallback routine - drivers might override this.
*/
EGLBoolean
-_eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, EGLint attribute, EGLint value)
+_eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf,
+ EGLint attribute, EGLint value)
{
_EGLSurface *surface = _eglLookupSurface(surf);
@@ -506,18 +508,67 @@ _eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, EGLint attri
EGLBoolean
-_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf,
+ EGLint buffer)
{
- /* XXX unfinished */
- return EGL_FALSE;
+ /* Just do basic error checking and return success/fail.
+ * Drivers must implement the real stuff.
+ */
+ _EGLSurface *surface = _eglLookupSurface(surf);
+
+ if (!surface || surface->Type != EGL_PBUFFER_BIT) {
+ _eglError(EGL_BAD_SURFACE, "eglBindTexImage");
+ return EGL_FALSE;
+ }
+
+ if (surface->TextureFormat == EGL_NO_TEXTURE) {
+ _eglError(EGL_BAD_MATCH, "eglBindTexImage");
+ return EGL_FALSE;
+ }
+
+ if (buffer != EGL_BACK_BUFFER) {
+ _eglError(EGL_BAD_PARAMETER, "eglBindTexImage");
+ return EGL_FALSE;
+ }
+
+ surface->BoundToTexture = EGL_TRUE;
+
+ return EGL_TRUE;
}
EGLBoolean
-_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf,
+ EGLint buffer)
{
- /* XXX unfinished */
- return EGL_FALSE;
+ /* Just do basic error checking and return success/fail.
+ * Drivers must implement the real stuff.
+ */
+ _EGLSurface *surface = _eglLookupSurface(surf);
+
+ if (!surface || surface->Type != EGL_PBUFFER_BIT) {
+ _eglError(EGL_BAD_SURFACE, "eglBindTexImage");
+ return EGL_FALSE;
+ }
+
+ if (surface->TextureFormat == EGL_NO_TEXTURE) {
+ _eglError(EGL_BAD_MATCH, "eglBindTexImage");
+ return EGL_FALSE;
+ }
+
+ if (buffer != EGL_BACK_BUFFER) {
+ _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage");
+ return EGL_FALSE;
+ }
+
+ if (!surface->BoundToTexture) {
+ _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage");
+ return EGL_FALSE;
+ }
+
+ surface->BoundToTexture = EGL_FALSE;
+
+ return EGL_TRUE;
}
diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
index df1e701..50f965b 100644
--- a/src/egl/main/eglsurface.h
+++ b/src/egl/main/eglsurface.h
@@ -16,6 +16,7 @@ struct _egl_surface
/* May need reference counting here */
EGLBoolean IsBound;
EGLBoolean DeletePending;
+ EGLBoolean BoundToTexture;
EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
EGLint Width, Height;
diff --git a/src/gallium/Makefile b/src/gallium/Makefile
index 291973c..aa77021 100644
--- a/src/gallium/Makefile
+++ b/src/gallium/Makefile
@@ -2,7 +2,7 @@ TOP = ../..
include $(TOP)/configs/current
-SUBDIRS = auxiliary drivers winsys/common
+SUBDIRS = auxiliary drivers
default: subdirs
diff --git a/src/gallium/README.portability b/src/gallium/README.portability
index d5d5987..adecf4b 100644
--- a/src/gallium/README.portability
+++ b/src/gallium/README.portability
@@ -35,8 +35,8 @@ not available in Windows Kernel Mode. Use the appropriate p_*.h include.
* Use MALLOC, CALLOC, FREE instead of the malloc, calloc, free functions.
-* Use align_pointer() function defined in p_util.h for aligning pointers in a
-portable way.
+* Use align_pointer() function defined in u_memory.h for aligning pointers
+ in a portable way.
== Debugging ==
diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c b/src/gallium/auxiliary/cso_cache/cso_cache.c
index 36dc46f..6b1754e 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.c
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.c
@@ -28,9 +28,10 @@
/* Authors: Zack Rusin <zack@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
#include "pipe/p_debug.h"
+#include "util/u_memory.h"
+
#include "cso_cache.h"
#include "cso_hash.h"
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 86e4d46..f22ba40 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -36,7 +36,7 @@
*/
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/auxiliary/cso_cache/cso_hash.c b/src/gallium/auxiliary/cso_cache/cso_hash.c
index 0646efd..7f0044c 100644
--- a/src/gallium/auxiliary/cso_cache/cso_hash.c
+++ b/src/gallium/auxiliary/cso_cache/cso_hash.c
@@ -31,7 +31,7 @@
*/
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "cso_hash.h"
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 678c70e..7824905 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -31,7 +31,8 @@
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
#include "draw_context.h"
#include "draw_vbuf.h"
#include "draw_vs.h"
@@ -289,7 +290,7 @@ draw_enable_point_sprites(struct draw_context *draw, boolean enable)
* work for the drivers.
*/
int
-draw_find_vs_output(struct draw_context *draw,
+draw_find_vs_output(const struct draw_context *draw,
uint semantic_name, uint semantic_index)
{
const struct draw_vertex_shader *vs = draw->vs.vertex_shader;
@@ -315,7 +316,7 @@ draw_find_vs_output(struct draw_context *draw,
* Return number of vertex shader outputs.
*/
uint
-draw_num_vs_outputs(struct draw_context *draw)
+draw_num_vs_outputs(const struct draw_context *draw)
{
uint count = draw->vs.vertex_shader->info.num_outputs;
if (draw->extra_vp_outputs.slot > 0)
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index b8f2bfa..0ab3681 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -84,11 +84,11 @@ draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe
int
-draw_find_vs_output(struct draw_context *draw,
+draw_find_vs_output(const struct draw_context *draw,
uint semantic_name, uint semantic_index);
uint
-draw_num_vs_outputs(struct draw_context *draw);
+draw_num_vs_outputs(const struct draw_context *draw);
diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c
index 3355c87..3cde9d3 100644
--- a/src/gallium/auxiliary/draw/draw_pipe.c
+++ b/src/gallium/auxiliary/draw/draw_pipe.c
@@ -30,7 +30,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
#include "draw/draw_private.h"
#include "draw/draw_pipe.h"
@@ -238,7 +237,7 @@ void draw_pipeline_run( struct draw_context *draw,
do_line( draw, \
flags, \
verts + stride * ((i0) & ~DRAW_PIPE_FLAG_MASK), \
- verts + stride * (i+1))
+ verts + stride * (i1))
#define POINT(i0) \
do_point( draw, \
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 991304b..20841bb 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -32,11 +32,12 @@
*/
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index c7f4349..2c1cacb 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_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -47,6 +46,9 @@
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
#include "draw_context.h"
#include "draw_vs.h"
#include "draw_pipe.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index fa10f8e..3265dcd 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -32,7 +32,9 @@
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
#include "pipe/p_shader_tokens.h"
#include "draw_vs.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c
index d0d22a3..053be5f 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_cull.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c
@@ -33,7 +33,7 @@
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "draw_pipe.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
index 4741b22..43d1fec 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
@@ -28,7 +28,9 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
#include "pipe/p_shader_tokens.h"
#include "draw_vs.h"
#include "draw_pipe.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c
index 8f1650e..1fea5e6 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -32,7 +32,8 @@
* \author Brian Paul
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "draw_pipe.h"
@@ -84,8 +85,8 @@ static void do_offset_tri( struct draw_stage *stage,
float a = ey*fz - ez*fy;
float b = ez*fx - ex*fz;
- float dzdx = FABSF(a * inv_det);
- float dzdy = FABSF(b * inv_det);
+ float dzdx = fabsf(a * inv_det);
+ float dzdy = fabsf(b * inv_det);
float zoffset = offset->units + MAX2(dzdx, dzdy) * offset->scale;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index e97136f..b764d9c 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -34,12 +34,14 @@
*/
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index bf0db18..b65e2aa 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -36,10 +36,12 @@
*/
-#include "pipe/p_util.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
-#include "draw_pipe.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "draw/draw_pipe.h"
/** Subclass of draw_stage */
diff --git a/src/gallium/auxiliary/draw/draw_pipe_twoside.c b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
index 3ac825f..c329d92 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_twoside.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
@@ -28,7 +28,8 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "draw_vs.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
index 8f97fde..68835fd 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
@@ -33,7 +33,7 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "draw_private.h"
#include "draw_pipe.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_util.c b/src/gallium/auxiliary/draw/draw_pipe_util.c
index 04438f4..e22e5fe 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_util.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_util.c
@@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_private.h"
#include "draw/draw_pipe.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c
index 6be1d36..f34c687 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_validate.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c
@@ -28,7 +28,7 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "draw_private.h"
#include "draw_pipe.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index a6fde77..c0cf426 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -35,7 +35,8 @@
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "draw_vbuf.h"
#include "draw_private.h"
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index 29649f5..184e363 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -28,9 +28,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "draw_private.h"
#include "draw_pipe.h"
@@ -73,8 +74,8 @@ static void wideline_line( struct draw_stage *stage,
float *pos2 = v2->data[pos];
float *pos3 = v3->data[pos];
- const float dx = FABSF(pos0[0] - pos2[0]);
- const float dy = FABSF(pos0[1] - pos2[1]);
+ const float dx = fabsf(pos0[0] - pos2[0]);
+ const float dy = fabsf(pos0[1] - pos2[1]);
/* small tweak to meet GL specification */
const float bias = 0.125f;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index 5459098..4f13260 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -28,7 +28,8 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "draw_vs.h"
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index 85a7552..669c11c 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -30,7 +30,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"
diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h
index 3d2a9c7..c02f229 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -98,9 +98,9 @@ struct draw_pt_middle_end {
unsigned count);
/* Transform all vertices in a linear range and then draw them with
- * the supplied element list.
+ * the supplied element list. May fail and return FALSE.
*/
- void (*run_linear_elts)( struct draw_pt_middle_end *,
+ boolean (*run_linear_elts)( struct draw_pt_middle_end *,
unsigned fetch_start,
unsigned fetch_count,
const ushort *draw_elts,
diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c
index 40f05cb..d4eca80 100644
--- a/src/gallium/auxiliary/draw/draw_pt_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_emit.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c
index 07f4c99..6377f89 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index 4a1f3b0..5a4db6c 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"
@@ -324,7 +324,7 @@ static void fetch_emit_run_linear( struct draw_pt_middle_end *middle,
}
-static void fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
+static boolean fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
unsigned start,
unsigned count,
const ushort *draw_elts,
@@ -341,10 +341,8 @@ static void fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
hw_verts = draw->render->allocate_vertices( draw->render,
(ushort)feme->translate->key.output_stride,
(ushort)count );
- if (!hw_verts) {
- assert(0);
- return;
- }
+ if (!hw_verts)
+ return FALSE;
/* Single routine to fetch vertices and emit HW verts.
*/
@@ -367,6 +365,7 @@ static void fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
feme->translate->key.output_stride,
count );
+ 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 fdf9b6f..73fc70c 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
@@ -31,7 +31,8 @@
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"
@@ -331,7 +332,7 @@ fse_run(struct draw_pt_middle_end *middle,
-static void fse_run_linear_elts( struct draw_pt_middle_end *middle,
+static boolean fse_run_linear_elts( struct draw_pt_middle_end *middle,
unsigned start,
unsigned count,
const ushort *draw_elts,
@@ -350,8 +351,7 @@ static void fse_run_linear_elts( struct draw_pt_middle_end *middle,
(ushort)count );
if (!hw_verts) {
- assert(0);
- return;
+ return FALSE;
}
/* Single routine to fetch vertices, run shader and emit HW verts.
@@ -373,6 +373,8 @@ static void fse_run_linear_elts( struct draw_pt_middle_end *middle,
hw_verts,
fse->key.output_stride,
count );
+
+ 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 0aec4b7..ec3b41c 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -25,7 +25,8 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
#include "draw/draw_vertex.h"
@@ -119,7 +120,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
struct draw_context *draw = fpme->draw;
struct draw_vertex_shader *shader = draw->vs.vertex_shader;
unsigned opt = fpme->opt;
- unsigned alloc_count = align_int( fetch_count, 4 );
+ unsigned alloc_count = align( fetch_count, 4 );
struct vertex_header *pipeline_verts =
(struct vertex_header *)MALLOC(fpme->vertex_size * alloc_count);
@@ -195,7 +196,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
struct draw_context *draw = fpme->draw;
struct draw_vertex_shader *shader = draw->vs.vertex_shader;
unsigned opt = fpme->opt;
- unsigned alloc_count = align_int( count, 4 );
+ unsigned alloc_count = align( count, 4 );
struct vertex_header *pipeline_verts =
(struct vertex_header *)MALLOC(fpme->vertex_size * alloc_count);
@@ -261,7 +262,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
-static void fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
+static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
unsigned start,
unsigned count,
const ushort *draw_elts,
@@ -271,17 +272,13 @@ static void fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
struct draw_context *draw = fpme->draw;
struct draw_vertex_shader *shader = draw->vs.vertex_shader;
unsigned opt = fpme->opt;
- unsigned alloc_count = align_int( count, 4 );
+ unsigned alloc_count = align( count, 4 );
struct vertex_header *pipeline_verts =
(struct vertex_header *)MALLOC(fpme->vertex_size * alloc_count);
- if (!pipeline_verts) {
- /* Not much we can do here - just skip the rendering.
- */
- assert(0);
- return;
- }
+ if (!pipeline_verts)
+ return FALSE;
/* Fetch into our vertex buffer
*/
@@ -335,6 +332,7 @@ static void fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
}
FREE(pipeline_verts);
+ return TRUE;
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
index af6306b..96dc706 100644
--- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c
+++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_context.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
diff --git a/src/gallium/auxiliary/draw/draw_pt_util.c b/src/gallium/auxiliary/draw/draw_pt_util.c
index 32c8a96..3bc7939 100644
--- a/src/gallium/auxiliary/draw/draw_pt_util.c
+++ b/src/gallium/auxiliary/draw/draw_pt_util.c
@@ -30,7 +30,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"
diff --git a/src/gallium/auxiliary/draw/draw_pt_varray.c b/src/gallium/auxiliary/draw/draw_pt_varray.c
index 46e722a..c15afe6 100644
--- a/src/gallium/auxiliary/draw/draw_pt_varray.c
+++ b/src/gallium/auxiliary/draw/draw_pt_varray.c
@@ -25,7 +25,9 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"
diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index cda2987..80d7200 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"
@@ -63,7 +63,8 @@ struct vcache_frontend {
unsigned opt;
};
-static void vcache_flush( struct vcache_frontend *vcache )
+static INLINE void
+vcache_flush( struct vcache_frontend *vcache )
{
if (vcache->middle_prim != vcache->output_prim) {
vcache->middle_prim = vcache->output_prim;
@@ -86,7 +87,8 @@ static void vcache_flush( struct vcache_frontend *vcache )
vcache->draw_count = 0;
}
-static void vcache_check_flush( struct vcache_frontend *vcache )
+static INLINE void
+vcache_check_flush( struct vcache_frontend *vcache )
{
if ( vcache->draw_count + 6 >= DRAW_MAX ||
vcache->fetch_count + 4 >= FETCH_MAX )
@@ -96,9 +98,10 @@ static void vcache_check_flush( struct vcache_frontend *vcache )
}
-static INLINE void vcache_elt( struct vcache_frontend *vcache,
- unsigned felt,
- ushort flags )
+static INLINE void
+vcache_elt( struct vcache_frontend *vcache,
+ unsigned felt,
+ ushort flags )
{
unsigned idx = felt % CACHE_MAX;
@@ -115,10 +118,11 @@ static INLINE void vcache_elt( struct vcache_frontend *vcache,
-static void vcache_triangle( struct vcache_frontend *vcache,
- unsigned i0,
- unsigned i1,
- unsigned i2 )
+static INLINE void
+vcache_triangle( struct vcache_frontend *vcache,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2 )
{
vcache_elt(vcache, i0, 0);
vcache_elt(vcache, i1, 0);
@@ -127,11 +131,12 @@ static void vcache_triangle( struct vcache_frontend *vcache,
}
-static void vcache_triangle_flags( struct vcache_frontend *vcache,
- ushort flags,
- unsigned i0,
- unsigned i1,
- unsigned i2 )
+static INLINE void
+vcache_triangle_flags( struct vcache_frontend *vcache,
+ ushort flags,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2 )
{
vcache_elt(vcache, i0, flags);
vcache_elt(vcache, i1, 0);
@@ -139,9 +144,10 @@ static void vcache_triangle_flags( struct vcache_frontend *vcache,
vcache_check_flush(vcache);
}
-static void vcache_line( struct vcache_frontend *vcache,
- unsigned i0,
- unsigned i1 )
+static INLINE void
+vcache_line( struct vcache_frontend *vcache,
+ unsigned i0,
+ unsigned i1 )
{
vcache_elt(vcache, i0, 0);
vcache_elt(vcache, i1, 0);
@@ -149,10 +155,11 @@ static void vcache_line( struct vcache_frontend *vcache,
}
-static void vcache_line_flags( struct vcache_frontend *vcache,
- ushort flags,
- unsigned i0,
- unsigned i1 )
+static INLINE void
+vcache_line_flags( struct vcache_frontend *vcache,
+ ushort flags,
+ unsigned i0,
+ unsigned i1 )
{
vcache_elt(vcache, i0, flags);
vcache_elt(vcache, i1, 0);
@@ -160,28 +167,31 @@ static void vcache_line_flags( struct vcache_frontend *vcache,
}
-static void vcache_point( struct vcache_frontend *vcache,
- unsigned i0 )
+static INLINE void
+vcache_point( struct vcache_frontend *vcache,
+ unsigned i0 )
{
vcache_elt(vcache, i0, 0);
vcache_check_flush(vcache);
}
-static void vcache_quad( struct vcache_frontend *vcache,
- unsigned i0,
- unsigned i1,
- unsigned i2,
- unsigned i3 )
+static INLINE void
+vcache_quad( struct vcache_frontend *vcache,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2,
+ unsigned i3 )
{
vcache_triangle( vcache, i0, i1, i3 );
vcache_triangle( vcache, i1, i2, i3 );
}
-static void vcache_ef_quad( struct vcache_frontend *vcache,
- unsigned i0,
- unsigned i1,
- unsigned i2,
- unsigned i3 )
+static INLINE void
+vcache_ef_quad( struct vcache_frontend *vcache,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2,
+ unsigned i3 )
{
vcache_triangle_flags( vcache,
( DRAW_PIPE_RESET_STIPPLE |
@@ -213,10 +223,11 @@ static void vcache_ef_quad( struct vcache_frontend *vcache,
#define FUNC vcache_run
#include "draw_pt_vcache_tmp.h"
-static void rebase_uint_elts( const unsigned *src,
- unsigned count,
- int delta,
- ushort *dest )
+static INLINE void
+rebase_uint_elts( const unsigned *src,
+ unsigned count,
+ int delta,
+ ushort *dest )
{
unsigned i;
@@ -224,9 +235,10 @@ static void rebase_uint_elts( const unsigned *src,
dest[i] = (ushort)(src[i] + delta);
}
-static void rebase_ushort_elts( const ushort *src,
- unsigned count,
- int delta,
+static INLINE void
+rebase_ushort_elts( const ushort *src,
+ unsigned count,
+ int delta,
ushort *dest )
{
unsigned i;
@@ -235,10 +247,11 @@ static void rebase_ushort_elts( const ushort *src,
dest[i] = (ushort)(src[i] + delta);
}
-static void rebase_ubyte_elts( const ubyte *src,
- unsigned count,
- int delta,
- ushort *dest )
+static INLINE void
+rebase_ubyte_elts( const ubyte *src,
+ unsigned count,
+ int delta,
+ ushort *dest )
{
unsigned i;
@@ -248,9 +261,10 @@ static void rebase_ubyte_elts( const ubyte *src,
-static void translate_uint_elts( const unsigned *src,
- unsigned count,
- ushort *dest )
+static INLINE void
+translate_uint_elts( const unsigned *src,
+ unsigned count,
+ ushort *dest )
{
unsigned i;
@@ -258,9 +272,10 @@ static void translate_uint_elts( const unsigned *src,
dest[i] = (ushort)(src[i]);
}
-static void translate_ushort_elts( const ushort *src,
- unsigned count,
- ushort *dest )
+static INLINE void
+translate_ushort_elts( const ushort *src,
+ unsigned count,
+ ushort *dest )
{
unsigned i;
@@ -268,9 +283,10 @@ static void translate_ushort_elts( const ushort *src,
dest[i] = (ushort)(src[i]);
}
-static void translate_ubyte_elts( const ubyte *src,
- unsigned count,
- ushort *dest )
+static INLINE void
+translate_ubyte_elts( const ubyte *src,
+ unsigned count,
+ ushort *dest )
{
unsigned i;
@@ -282,7 +298,8 @@ static void translate_ubyte_elts( const ubyte *src,
#if 0
-static enum pipe_format format_from_get_elt( pt_elt_func get_elt )
+static INLINE enum pipe_format
+format_from_get_elt( pt_elt_func get_elt )
{
switch (draw->pt.user.eltSize) {
case 1: return PIPE_FORMAT_R8_UNORM;
@@ -293,10 +310,11 @@ static enum pipe_format format_from_get_elt( pt_elt_func get_elt )
}
#endif
-static void vcache_check_run( struct draw_pt_front_end *frontend,
- pt_elt_func get_elt,
- const void *elts,
- unsigned draw_count )
+static INLINE void
+vcache_check_run( struct draw_pt_front_end *frontend,
+ pt_elt_func get_elt,
+ const void *elts,
+ unsigned draw_count )
{
struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
struct draw_context *draw = vcache->draw;
@@ -306,6 +324,7 @@ static void vcache_check_run( struct draw_pt_front_end *frontend,
unsigned fetch_count = max_index + 1 - min_index;
const ushort *transformed_elts;
ushort *storage = NULL;
+ boolean ok;
if (0) debug_printf("fetch_count %d fetch_max %d draw_count %d\n", fetch_count,
@@ -313,7 +332,6 @@ static void vcache_check_run( struct draw_pt_front_end *frontend,
draw_count);
if (max_index == 0xffffffff ||
- fetch_count >= vcache->fetch_max ||
fetch_count > draw_count) {
if (0) debug_printf("fail\n");
goto fail;
@@ -395,14 +413,19 @@ static void vcache_check_run( struct draw_pt_front_end *frontend,
transformed_elts = storage;
}
- vcache->middle->run_linear_elts( vcache->middle,
- min_index, /* start */
- fetch_count,
- transformed_elts,
- draw_count );
-
+ ok = vcache->middle->run_linear_elts( vcache->middle,
+ min_index, /* start */
+ fetch_count,
+ transformed_elts,
+ draw_count );
+
FREE(storage);
- return;
+
+ if (ok)
+ return;
+
+ debug_printf("failed to execute atomic draw elts for %d/%d, splitting up\n",
+ fetch_count, draw_count);
fail:
vcache_run( frontend, get_elt, elts, draw_count );
@@ -411,10 +434,11 @@ static void vcache_check_run( struct draw_pt_front_end *frontend,
-static void vcache_prepare( struct draw_pt_front_end *frontend,
- unsigned prim,
- struct draw_pt_middle_end *middle,
- unsigned opt )
+static void
+vcache_prepare( struct draw_pt_front_end *frontend,
+ unsigned prim,
+ struct draw_pt_middle_end *middle,
+ unsigned opt )
{
struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
@@ -443,14 +467,16 @@ static void vcache_prepare( struct draw_pt_front_end *frontend,
-static void vcache_finish( struct draw_pt_front_end *frontend )
+static void
+vcache_finish( struct draw_pt_front_end *frontend )
{
struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
vcache->middle->finish( vcache->middle );
vcache->middle = NULL;
}
-static void vcache_destroy( struct draw_pt_front_end *frontend )
+static void
+vcache_destroy( struct draw_pt_front_end *frontend )
{
FREE(frontend);
}
diff --git a/src/gallium/auxiliary/draw/draw_vbuf.h b/src/gallium/auxiliary/draw/draw_vbuf.h
index e90f378..b0aa2df 100644
--- a/src/gallium/auxiliary/draw/draw_vbuf.h
+++ b/src/gallium/auxiliary/draw/draw_vbuf.h
@@ -37,8 +37,6 @@
#define DRAW_VBUF_H_
-#include "pipe/p_util.h"
-
struct draw_context;
struct vertex_info;
@@ -81,7 +79,8 @@ struct vbuf_render {
boolean (*set_primitive)( struct vbuf_render *, unsigned prim );
/**
- * DrawElements, note indices are ushort:
+ * DrawElements, note indices are ushort. The driver must complete
+ * this call, if necessary splitting the index list itself.
*/
void (*draw)( struct vbuf_render *,
const ushort *indices,
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index f798b20..34adbd4 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -31,11 +31,15 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
#include "pipe/p_shader_tokens.h"
+
#include "draw_private.h"
#include "draw_context.h"
#include "draw_vs.h"
+
#include "translate/translate.h"
#include "translate/translate_cache.h"
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c
index 441877d..a556477 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.c
@@ -29,8 +29,10 @@
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_debug.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi/tgsi_exec.h"
@@ -43,6 +45,7 @@
#ifdef PIPE_ARCH_X86
#define DISASSEM 0
+#define FAST_MATH 1
static const char *files[] =
{
@@ -117,21 +120,26 @@ static struct x86_reg get_reg_ptr(struct aos_compilation *cp,
switch (file) {
case TGSI_FILE_INPUT:
+ assert(idx < MAX_INPUTS);
return x86_make_disp(ptr, Offset(struct aos_machine, input[idx]));
case TGSI_FILE_OUTPUT:
return x86_make_disp(ptr, Offset(struct aos_machine, output[idx]));
case TGSI_FILE_TEMPORARY:
+ assert(idx < MAX_TEMPS);
return x86_make_disp(ptr, Offset(struct aos_machine, temp[idx]));
case AOS_FILE_INTERNAL:
+ assert(idx < MAX_INTERNALS);
return x86_make_disp(ptr, Offset(struct aos_machine, internal[idx]));
case TGSI_FILE_IMMEDIATE:
+ assert(idx < MAX_IMMEDIATES); /* just a sanity check */
return x86_make_disp(aos_get_x86(cp, 0, X86_IMMEDIATES), idx * 4 * sizeof(float));
case TGSI_FILE_CONSTANT:
+ assert(idx < MAX_CONSTANTS); /* just a sanity check */
return x86_make_disp(aos_get_x86(cp, 1, X86_CONSTANTS), idx * 4 * sizeof(float));
default:
@@ -1380,14 +1388,28 @@ static boolean emit_MAD( struct aos_compilation *cp, const struct tgsi_full_inst
return TRUE;
}
+
+
/* A wrapper for powf().
* Makes sure it is cdecl and operates on floats.
*/
static float PIPE_CDECL _powerf( float x, float y )
{
+#if FAST_MATH
+ return util_fast_pow(x, y);
+#else
return powf( x, y );
+#endif
}
+#if FAST_MATH
+static float PIPE_CDECL _exp2(float x)
+{
+ return util_fast_exp2(x);
+}
+#endif
+
+
/* Really not sufficient -- need to check for conditions that could
* generate inf/nan values, which will slow things down hugely.
*/
@@ -1442,6 +1464,48 @@ static boolean emit_POW( struct aos_compilation *cp, const struct tgsi_full_inst
}
+#if FAST_MATH
+static boolean emit_EXPBASE2( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
+{
+ uint i;
+
+ /* For absolute correctness, need to spill/invalidate all XMM regs
+ * too.
+ */
+ for (i = 0; i < 8; i++) {
+ if (cp->xmm[i].dirty)
+ spill(cp, i);
+ aos_release_xmm_reg(cp, i);
+ }
+
+ /* Push caller-save (ie scratch) regs.
+ */
+ x86_cdecl_caller_push_regs( cp->func );
+
+ x86_lea( cp->func, cp->stack_ESP, x86_make_disp(cp->stack_ESP, -4) );
+
+ x87_fld_src( cp, &op->FullSrcRegisters[0], 0 );
+ x87_fstp( cp->func, x86_make_disp( cp->stack_ESP, 0 ) );
+
+ /* tmp_EAX has been pushed & will be restored below */
+ x86_mov_reg_imm( cp->func, cp->tmp_EAX, (unsigned long) _exp2 );
+ x86_call( cp->func, cp->tmp_EAX );
+
+ x86_lea( cp->func, cp->stack_ESP, x86_make_disp(cp->stack_ESP, 4) );
+
+ x86_cdecl_caller_pop_regs( cp->func );
+
+ /* Note retval on x87 stack:
+ */
+ cp->func->x87_stack++;
+
+ x87_fstp_dest4( cp, &op->FullDstRegisters[0] );
+
+ return TRUE;
+}
+#endif
+
+
static boolean emit_RCP( struct aos_compilation *cp, const struct tgsi_full_instruction *op )
{
struct x86_reg arg0 = fetch_src(cp, &op->FullSrcRegisters[0]);
@@ -1662,7 +1726,9 @@ emit_instruction( struct aos_compilation *cp,
return emit_RND(cp, inst);
case TGSI_OPCODE_EXPBASE2:
-#if 0
+#if FAST_MATH
+ return emit_EXPBASE2(cp, inst);
+#elif 0
/* this seems to fail for "larger" exponents.
* See glean tvertProg1's EX2 test.
*/
@@ -1827,6 +1893,8 @@ static boolean build_vertex_program( struct draw_vs_varient_aos_sse *varient,
struct aos_compilation cp;
unsigned fixup, label;
+ util_init_math();
+
tgsi_parse_init( &parse, varient->base.vs->state.tokens );
memset(&cp, 0, sizeof(cp));
@@ -2046,6 +2114,11 @@ static void PIPE_CDECL vaos_run_linear( struct draw_vs_varient *varient,
start,
count,
output_buffer );
+
+ /* Sanity spot checks to make sure we didn't trash our constants */
+ assert(machine->internal[IMM_ONES][0] == 1.0f);
+ assert(machine->internal[IMM_IDENTITY][0] == 0.0f);
+ assert(machine->internal[IMM_NEGS][0] == -1.0f);
}
@@ -2135,4 +2208,4 @@ struct draw_vs_varient *draw_vs_varient_aos_sse( struct draw_vertex_shader *vs,
-#endif
+#endif /* PIPE_ARCH_X86 */
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.h b/src/gallium/auxiliary/draw/draw_vs_aos.h
index 64e021f..7fe6f79 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.h
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.h
@@ -51,11 +51,11 @@ struct x86_function;
#define W 3
#define MAX_INPUTS PIPE_MAX_ATTRIBS
-#define MAX_OUTPUTS PIPE_MAX_ATTRIBS
-#define MAX_TEMPS PIPE_MAX_ATTRIBS /* say */
-#define MAX_CONSTANTS PIPE_MAX_ATTRIBS /* say */
-#define MAX_IMMEDIATES PIPE_MAX_ATTRIBS /* say */
-#define MAX_INTERNALS 8
+#define MAX_OUTPUTS PIPE_MAX_SHADER_OUTPUTS
+#define MAX_TEMPS TGSI_EXEC_NUM_TEMPS
+#define MAX_CONSTANTS 1024 /** only used for sanity checking */
+#define MAX_IMMEDIATES 1024 /** only used for sanity checking */
+#define MAX_INTERNALS 8 /** see IMM_x values below */
#define AOS_FILE_INTERNAL TGSI_FILE_COUNT
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_io.c b/src/gallium/auxiliary/draw/draw_vs_aos_io.c
index eda677c..26297c7 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos_io.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos_io.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
@@ -55,9 +55,13 @@ static void emit_load_R32G32B32( struct aos_compilation *cp,
struct x86_reg src_ptr )
{
sse_movss(cp->func, data, x86_make_disp(src_ptr, 8));
+ /* data = z ? ? ? */
sse_shufps(cp->func, data, aos_get_internal_xmm( cp, IMM_IDENTITY ), SHUF(X,Y,Z,W) );
+ /* data = z ? 0 1 */
sse_shufps(cp->func, data, data, SHUF(Y,Z,X,W) );
+ /* data = ? 0 z 1 */
sse_movlps(cp->func, data, src_ptr);
+ /* data = x y z 1 */
}
static void emit_load_R32G32( struct aos_compilation *cp,
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_machine.c b/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
index e029b7b..b358bd2 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
@@ -29,8 +29,9 @@
#include "pipe/p_config.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi/tgsi_exec.h"
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index e26903d..4456380 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -31,7 +31,8 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c
index fc03473..2ce30b9 100644
--- a/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c
@@ -32,7 +32,6 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
#include "draw_context.h"
diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c
index 61f0c08..0efabd9 100644
--- a/src/gallium/auxiliary/draw/draw_vs_sse.c
+++ b/src/gallium/auxiliary/draw/draw_vs_sse.c
@@ -31,13 +31,14 @@
* Brian Paul
*/
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_config.h"
#include "draw_vs.h"
#if defined(PIPE_ARCH_X86)
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
diff --git a/src/gallium/auxiliary/draw/draw_vs_varient.c b/src/gallium/auxiliary/draw/draw_vs_varient.c
index ad0b829..4daf05d 100644
--- a/src/gallium/auxiliary/draw/draw_vs_varient.c
+++ b/src/gallium/auxiliary/draw/draw_vs_varient.c
@@ -30,7 +30,8 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"
@@ -298,7 +299,7 @@ struct draw_vs_varient *draw_vs_varient_generic( struct draw_vertex_shader *vs,
emit.element[i].input_offset = key->element[i].out.vs_output * 4 * sizeof(float);
emit.element[i].output_format = draw_translate_vinfo_format(key->element[i].out.format);
emit.element[i].output_offset = key->element[i].out.offset;
- assert(emit.element[i].input_offset < fetch.output_stride);
+ assert(emit.element[i].input_offset <= fetch.output_stride);
}
else {
emit.element[i].input_format = PIPE_FORMAT_R32_FLOAT;
diff --git a/src/gallium/auxiliary/gallivm/gallivm_cpu.cpp b/src/gallium/auxiliary/gallivm/gallivm_cpu.cpp
index cf5b978..e64bfb1 100644
--- a/src/gallium/auxiliary/gallivm/gallivm_cpu.cpp
+++ b/src/gallium/auxiliary/gallivm/gallivm_cpu.cpp
@@ -41,11 +41,12 @@
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/p_util.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_dump.h"
+#include "util/u_memory.h"
+
#include <llvm/Module.h>
#include <llvm/CallingConv.h>
#include <llvm/Constants.h>
diff --git a/src/gallium/auxiliary/gallivm/instructions.cpp b/src/gallium/auxiliary/gallivm/instructions.cpp
index 035224e..a82dc30 100644
--- a/src/gallium/auxiliary/gallivm/instructions.cpp
+++ b/src/gallium/auxiliary/gallivm/instructions.cpp
@@ -35,7 +35,7 @@
#include "storage.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include <llvm/CallingConv.h>
#include <llvm/Constants.h>
diff --git a/src/gallium/auxiliary/gallivm/instructionssoa.cpp b/src/gallium/auxiliary/gallivm/instructionssoa.cpp
index 76049ad..efddc04 100644
--- a/src/gallium/auxiliary/gallivm/instructionssoa.cpp
+++ b/src/gallium/auxiliary/gallivm/instructionssoa.cpp
@@ -29,7 +29,7 @@
#include "storagesoa.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include <llvm/CallingConv.h>
#include <llvm/Constants.h>
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index ce41418..17b2781 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -38,6 +38,7 @@
#if defined(PIPE_OS_LINUX)
#include <unistd.h>
+#include <sched.h>
#endif
#include "pipe/p_compiler.h"
@@ -45,7 +46,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_winsys.h"
#include "pipe/p_thread.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "pb_buffer.h"
@@ -68,7 +69,7 @@
struct fenced_buffer_list
{
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
struct pipe_winsys *winsys;
@@ -239,7 +240,7 @@ fenced_buffer_destroy(struct pb_buffer *buf)
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
assert(fenced_buf->base.base.refcount == 0);
if (fenced_buf->fence) {
struct pipe_winsys *winsys = fenced_list->winsys;
@@ -262,7 +263,7 @@ fenced_buffer_destroy(struct pb_buffer *buf)
else {
_fenced_buffer_destroy(fenced_buf);
}
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
}
@@ -395,7 +396,7 @@ buffer_fence(struct pb_buffer *buf,
return;
}
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
if (fenced_buf->fence)
_fenced_buffer_remove(fenced_list, fenced_buf);
if (fence) {
@@ -403,7 +404,7 @@ buffer_fence(struct pb_buffer *buf,
fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE;
_fenced_buffer_add(fenced_buf);
}
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
}
@@ -422,7 +423,7 @@ fenced_buffer_list_create(struct pipe_winsys *winsys)
fenced_list->numDelayed = 0;
- _glthread_INIT_MUTEX(fenced_list->mutex);
+ pipe_mutex_init(fenced_list->mutex);
return fenced_list;
}
@@ -432,28 +433,28 @@ void
fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
int wait)
{
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
_fenced_buffer_list_check_free(fenced_list, wait);
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
}
void
fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
{
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
/* Wait on outstanding fences */
while (fenced_list->numDelayed) {
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
#if defined(PIPE_OS_LINUX)
sched_yield();
#endif
_fenced_buffer_list_check_free(fenced_list, 1);
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
}
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
FREE(fenced_list);
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
index e90d2e5..20fc87b 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
@@ -35,7 +35,7 @@
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
index 0d2d6c0..2afaeaf 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
@@ -35,7 +35,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index bed4bec..1ec422f 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -38,7 +38,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_winsys.h"
#include "pipe/p_thread.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"
@@ -79,7 +79,7 @@ struct pb_cache_manager
struct pb_manager *provider;
unsigned usecs;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
struct list_head delayed;
size_t numDelayed;
@@ -153,7 +153,7 @@ pb_cache_buffer_destroy(struct pb_buffer *_buf)
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
struct pb_cache_manager *mgr = buf->mgr;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
assert(buf->base.base.refcount == 0);
_pb_cache_buffer_list_check_free(mgr);
@@ -162,7 +162,7 @@ pb_cache_buffer_destroy(struct pb_buffer *_buf)
util_time_add(&buf->start, mgr->usecs, &buf->end);
LIST_ADDTAIL(&buf->head, &mgr->delayed);
++mgr->numDelayed;
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
}
@@ -235,7 +235,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
struct list_head *curr, *next;
struct util_time now;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
buf = NULL;
curr = mgr->delayed.next;
@@ -249,27 +249,35 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
buf = curr_buf;
else if(util_time_timeout(&curr_buf->start, &curr_buf->end, &now))
_pb_cache_buffer_destroy(curr_buf);
+ else
+ /* This buffer (and all hereafter) are still hot in cache */
+ break;
curr = next;
next = curr->next;
}
/* keep searching in the hot buffers */
- while(!buf && curr != &mgr->delayed) {
- curr_buf = LIST_ENTRY(struct pb_cache_buffer, curr, head);
- if(pb_cache_is_buffer_compat(curr_buf, size, desc))
- buf = curr_buf;
- curr = next;
- next = curr->next;
+ if(!buf) {
+ while(curr != &mgr->delayed) {
+ curr_buf = LIST_ENTRY(struct pb_cache_buffer, curr, head);
+ if(pb_cache_is_buffer_compat(curr_buf, size, desc)) {
+ buf = curr_buf;
+ break;
+ }
+ /* no need to check the timeout here */
+ curr = next;
+ next = curr->next;
+ }
}
if(buf) {
LIST_DEL(&buf->head);
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
++buf->base.base.refcount;
return &buf->base;
}
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
buf = CALLOC_STRUCT(pb_cache_buffer);
if(!buf)
@@ -305,7 +313,7 @@ pb_cache_flush(struct pb_manager *_mgr)
struct list_head *curr, *next;
struct pb_cache_buffer *buf;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
curr = mgr->delayed.next;
next = curr->next;
while(curr != &mgr->delayed) {
@@ -314,7 +322,7 @@ pb_cache_flush(struct pb_manager *_mgr)
curr = next;
next = curr->next;
}
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
}
@@ -345,7 +353,7 @@ pb_cache_manager_create(struct pb_manager *provider,
mgr->usecs = usecs;
LIST_INITHEAD(&mgr->delayed);
mgr->numDelayed = 0;
- _glthread_INIT_MUTEX(mgr->mutex);
+ pipe_mutex_init(mgr->mutex);
return &mgr->base;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index d02e350..5f1ed3e 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -37,7 +37,8 @@
#include "pipe/p_debug.h"
#include "pipe/p_winsys.h"
#include "pipe/p_thread.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"
@@ -128,7 +129,7 @@ check_random_pattern(const uint8_t *dst, size_t size,
for(i = 0; i < size; ++i) {
if(*dst++ != random_pattern[i % sizeof(random_pattern)]) {
*min_ofs = MIN2(*min_ofs, i);
- *max_ofs = MIN2(*max_ofs, i);
+ *max_ofs = MAX2(*max_ofs, i);
result = FALSE;
}
}
@@ -137,12 +138,30 @@ check_random_pattern(const uint8_t *dst, size_t size,
static void
-pb_debug_buffer_destroy(struct pb_buffer *_buf)
+pb_debug_buffer_fill(struct pb_debug_buffer *buf)
{
- struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
uint8_t *map;
- assert(!buf->base.base.refcount);
+ map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ assert(map);
+ if(map) {
+ fill_random_pattern(map, buf->underflow_size);
+ fill_random_pattern(map + buf->underflow_size + buf->base.base.size,
+ buf->overflow_size);
+ pb_unmap(buf->buffer);
+ }
+}
+
+
+/**
+ * Check for under/over flows.
+ *
+ * Should be called with the buffer unmaped.
+ */
+static void
+pb_debug_buffer_check(struct pb_debug_buffer *buf)
+{
+ uint8_t *map;
map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_READ);
assert(map);
@@ -153,24 +172,45 @@ pb_debug_buffer_destroy(struct pb_buffer *_buf)
underflow = !check_random_pattern(map, buf->underflow_size,
&min_ofs, &max_ofs);
if(underflow) {
- debug_printf("buffer underflow (%u of %u bytes) detected\n",
- buf->underflow_size - min_ofs,
- buf->underflow_size);
+ debug_printf("buffer underflow (offset -%u%s to -%u bytes) detected\n",
+ buf->underflow_size - min_ofs,
+ min_ofs == 0 ? "+" : "",
+ buf->underflow_size - max_ofs);
}
overflow = !check_random_pattern(map + buf->underflow_size + buf->base.base.size,
buf->overflow_size,
&min_ofs, &max_ofs);
if(overflow) {
- debug_printf("buffer overflow (%u of %u bytes) detected\n",
+ debug_printf("buffer overflow (size %u plus offset %u to %u%s bytes) detected\n",
+ buf->base.base.size,
+ min_ofs,
max_ofs,
- buf->overflow_size);
+ max_ofs == buf->overflow_size - 1 ? "+" : "");
}
debug_assert(!underflow && !overflow);
-
+
+ /* re-fill if not aborted */
+ if(underflow)
+ fill_random_pattern(map, buf->underflow_size);
+ if(overflow)
+ fill_random_pattern(map + buf->underflow_size + buf->base.base.size,
+ buf->overflow_size);
+
pb_unmap(buf->buffer);
}
+}
+
+
+static void
+pb_debug_buffer_destroy(struct pb_buffer *_buf)
+{
+ struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
+
+ assert(!buf->base.base.refcount);
+
+ pb_debug_buffer_check(buf);
pb_reference(&buf->buffer, NULL);
FREE(buf);
@@ -182,9 +222,14 @@ pb_debug_buffer_map(struct pb_buffer *_buf,
unsigned flags)
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
- void *map = pb_map(buf->buffer, flags);
+ void *map;
+
+ pb_debug_buffer_check(buf);
+
+ map = pb_map(buf->buffer, flags);
if(!map)
return NULL;
+
return (uint8_t *)map + buf->underflow_size;
}
@@ -194,6 +239,8 @@ pb_debug_buffer_unmap(struct pb_buffer *_buf)
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
pb_unmap(buf->buffer);
+
+ pb_debug_buffer_check(buf);
}
@@ -226,7 +273,6 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
struct pb_debug_buffer *buf;
struct pb_desc real_desc;
size_t real_size;
- uint8_t *map;
buf = CALLOC_STRUCT(pb_debug_buffer);
if(!buf)
@@ -261,13 +307,7 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
buf->underflow_size = mgr->band_size;
buf->overflow_size = buf->buffer->base.size - buf->underflow_size - size;
- map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
- assert(map);
- if(map) {
- fill_random_pattern(map, buf->underflow_size);
- fill_random_pattern(map + buf->underflow_size + size, buf->overflow_size);
- pb_unmap(buf->buffer);
- }
+ pb_debug_buffer_fill(buf);
return &buf->base;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
index 05efd8c..8fc63ce 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
@@ -35,7 +35,7 @@
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_buffer_fenced.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index c51e582..e8c7f8e 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -36,7 +36,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_mm.h"
#include "pb_buffer.h"
@@ -53,7 +53,7 @@ struct mm_pb_manager
{
struct pb_manager base;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
size_t size;
struct mem_block *heap;
@@ -99,10 +99,10 @@ mm_buffer_destroy(struct pb_buffer *buf)
assert(buf->base.refcount == 0);
- _glthread_LOCK_MUTEX(mm->mutex);
+ pipe_mutex_lock(mm->mutex);
mmFreeMem(mm_buf->block);
FREE(buf);
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
}
@@ -158,11 +158,11 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
if(desc->alignment % (1 << mm->align2))
return NULL;
- _glthread_LOCK_MUTEX(mm->mutex);
+ pipe_mutex_lock(mm->mutex);
mm_buf = CALLOC_STRUCT(mm_buffer);
if (!mm_buf) {
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
return NULL;
}
@@ -185,7 +185,7 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
mm_buf->block = mmAllocMem(mm->heap, size, mm->align2, 0);
if(!mm_buf->block) {
FREE(mm_buf);
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
return NULL;
}
}
@@ -194,7 +194,7 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size);
assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size);
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
return SUPER(mm_buf);
}
@@ -204,14 +204,14 @@ mm_bufmgr_destroy(struct pb_manager *mgr)
{
struct mm_pb_manager *mm = mm_pb_manager(mgr);
- _glthread_LOCK_MUTEX(mm->mutex);
+ pipe_mutex_lock(mm->mutex);
mmDestroy(mm->heap);
pb_unmap(mm->buffer);
pb_reference(&mm->buffer, NULL);
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
FREE(mgr);
}
@@ -236,7 +236,7 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
mm->size = size;
mm->align2 = align2; /* 64-byte alignment */
- _glthread_INIT_MUTEX(mm->mutex);
+ pipe_mutex_init(mm->mutex);
mm->buffer = buffer;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
index 95af089..3ef72c5 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
@@ -39,7 +39,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "pb_buffer.h"
@@ -56,7 +56,7 @@ struct pool_pb_manager
{
struct pb_manager base;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
size_t bufSize;
size_t bufAlign;
@@ -110,10 +110,10 @@ pool_buffer_destroy(struct pb_buffer *buf)
assert(pool_buf->base.base.refcount == 0);
- _glthread_LOCK_MUTEX(pool->mutex);
+ pipe_mutex_lock(pool->mutex);
LIST_ADD(&pool_buf->head, &pool->free);
pool->numFree++;
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
}
@@ -124,9 +124,9 @@ pool_buffer_map(struct pb_buffer *buf, unsigned flags)
struct pool_pb_manager *pool = pool_buf->mgr;
void *map;
- _glthread_LOCK_MUTEX(pool->mutex);
+ pipe_mutex_lock(pool->mutex);
map = (unsigned char *) pool->map + pool_buf->start;
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
return map;
}
@@ -171,10 +171,10 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr,
assert(size == pool->bufSize);
assert(pool->bufAlign % desc->alignment == 0);
- _glthread_LOCK_MUTEX(pool->mutex);
+ pipe_mutex_lock(pool->mutex);
if (pool->numFree == 0) {
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
debug_printf("warning: out of fixed size buffer objects\n");
return NULL;
}
@@ -182,7 +182,7 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr,
item = pool->free.next;
if (item == &pool->free) {
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
debug_printf("error: fixed size buffer pool corruption\n");
return NULL;
}
@@ -190,7 +190,7 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr,
LIST_DEL(item);
--pool->numFree;
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
assert(pool_buf->base.base.refcount == 0);
@@ -206,14 +206,14 @@ static void
pool_bufmgr_destroy(struct pb_manager *mgr)
{
struct pool_pb_manager *pool = pool_pb_manager(mgr);
- _glthread_LOCK_MUTEX(pool->mutex);
+ pipe_mutex_lock(pool->mutex);
FREE(pool->bufs);
pb_unmap(pool->buffer);
pb_reference(&pool->buffer, NULL);
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
FREE(mgr);
}
@@ -246,7 +246,7 @@ pool_bufmgr_create(struct pb_manager *provider,
pool->bufSize = bufSize;
pool->bufAlign = desc->alignment;
- _glthread_INIT_MUTEX(pool->mutex);
+ pipe_mutex_init(pool->mutex);
pool->buffer = provider->create_buffer(provider, numBufs*bufSize, desc);
if (!pool->buffer)
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index 598d9ce..8698c4c 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -30,6 +30,8 @@
* @file
* S-lab pool implementation.
*
+ * @sa http://en.wikipedia.org/wiki/Slab_allocation
+ *
* @author Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
* @author Jose Fonseca <jrfonseca@tungstengraphics.com>
*/
@@ -39,7 +41,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"
@@ -49,46 +51,96 @@
struct pb_slab;
+
+/**
+ * Buffer in a slab.
+ *
+ * Sub-allocation of a contiguous buffer.
+ */
struct pb_slab_buffer
{
struct pb_buffer base;
struct pb_slab *slab;
+
struct list_head head;
+
unsigned mapCount;
+
+ /** Offset relative to the start of the slab buffer. */
size_t start;
- _glthread_Cond event;
+
+ /** Use when validating, to signal that all mappings are finished */
+ /* TODO: Actually validation does not reach this stage yet */
+ pipe_condvar event;
};
+
+/**
+ * Slab -- a contiguous piece of memory.
+ */
struct pb_slab
{
struct list_head head;
struct list_head freeBuffers;
size_t numBuffers;
size_t numFree;
+
struct pb_slab_buffer *buffers;
struct pb_slab_manager *mgr;
+ /** Buffer from the provider */
struct pb_buffer *bo;
+
void *virtual;
};
+
+/**
+ * It adds/removes slabs as needed in order to meet the allocation/destruction
+ * of individual buffers.
+ */
struct pb_slab_manager
{
struct pb_manager base;
+ /** From where we get our buffers */
struct pb_manager *provider;
+
+ /** Size of the buffers we hand on downstream */
size_t bufSize;
+
+ /** Size of the buffers we request upstream */
size_t slabSize;
+
+ /**
+ * Alignment, usage to be used to allocate the slab buffers.
+ *
+ * We can only provide buffers which are consistent (in alignment, usage)
+ * with this description.
+ */
struct pb_desc desc;
+ /**
+ * Partial slabs
+ *
+ * Full slabs are not stored in any list. Empty slabs are destroyed
+ * immediatly.
+ */
struct list_head slabs;
- struct list_head freeSlabs;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
};
+
/**
+ * Wrapper around several slabs, therefore capable of handling buffers of
+ * multiple sizes.
+ *
+ * This buffer manager just dispatches buffer allocations to the appropriate slab
+ * manager, according to the requested buffer size, or by passes the slab
+ * managers altogether for even greater sizes.
+ *
* The data of this structure remains constant after
* initialization and thus needs no mutex protection.
*/
@@ -97,12 +149,17 @@ struct pb_slab_range_manager
struct pb_manager base;
struct pb_manager *provider;
+
size_t minBufSize;
size_t maxBufSize;
+
+ /** @sa pb_slab_manager::desc */
struct pb_desc desc;
unsigned numBuckets;
size_t *bucketSizes;
+
+ /** Array of pb_slab_manager, one for each bucket size */
struct pb_manager **buckets;
};
@@ -143,7 +200,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf)
struct pb_slab_manager *mgr = slab->mgr;
struct list_head *list = &buf->head;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
assert(buf->base.base.refcount == 0);
@@ -156,30 +213,16 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf)
if (slab->head.next == &slab->head)
LIST_ADDTAIL(&slab->head, &mgr->slabs);
+ /* If the slab becomes totally empty, free it */
if (slab->numFree == slab->numBuffers) {
list = &slab->head;
- LIST_DEL(list);
- LIST_ADDTAIL(list, &mgr->freeSlabs);
+ LIST_DELINIT(list);
+ pb_reference(&slab->bo, NULL);
+ FREE(slab->buffers);
+ FREE(slab);
}
- if (mgr->slabs.next == &mgr->slabs || slab->numFree
- != slab->numBuffers) {
-
- struct list_head *next;
-
- for (list = mgr->freeSlabs.next, next = list->next; list
- != &mgr->freeSlabs; list = next, next = list->next) {
-
- slab = LIST_ENTRY(struct pb_slab, list, head);
-
- LIST_DELINIT(list);
- pb_reference(&slab->bo, NULL);
- FREE(slab->buffers);
- FREE(slab);
- }
- }
-
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
}
@@ -201,7 +244,7 @@ pb_slab_buffer_unmap(struct pb_buffer *_buf)
--buf->mapCount;
if (buf->mapCount == 0)
- _glthread_COND_BROADCAST(buf->event);
+ pipe_condvar_broadcast(buf->event);
}
@@ -225,6 +268,11 @@ pb_slab_buffer_vtbl = {
};
+/**
+ * Create a new slab.
+ *
+ * Called when we ran out of free slabs.
+ */
static enum pipe_error
pb_slab_create(struct pb_slab_manager *mgr)
{
@@ -238,17 +286,14 @@ pb_slab_create(struct pb_slab_manager *mgr)
if (!slab)
return PIPE_ERROR_OUT_OF_MEMORY;
- /*
- * FIXME: We should perhaps allow some variation in slabsize in order
- * to efficiently reuse slabs.
- */
-
slab->bo = mgr->provider->create_buffer(mgr->provider, mgr->slabSize, &mgr->desc);
if(!slab->bo) {
ret = PIPE_ERROR_OUT_OF_MEMORY;
goto out_err0;
}
+ /* Note down the slab virtual address. All mappings are accessed directly
+ * through this address so it is required that the buffer is pinned. */
slab->virtual = pb_map(slab->bo,
PIPE_BUFFER_USAGE_CPU_READ |
PIPE_BUFFER_USAGE_CPU_WRITE);
@@ -256,7 +301,6 @@ pb_slab_create(struct pb_slab_manager *mgr)
ret = PIPE_ERROR_OUT_OF_MEMORY;
goto out_err1;
}
-
pb_unmap(slab->bo);
numBuffers = slab->bo->base.size / mgr->bufSize;
@@ -283,12 +327,13 @@ pb_slab_create(struct pb_slab_manager *mgr)
buf->slab = slab;
buf->start = i* mgr->bufSize;
buf->mapCount = 0;
- _glthread_INIT_COND(buf->event);
+ pipe_condvar_init(buf->event);
LIST_ADDTAIL(&buf->head, &slab->freeBuffers);
slab->numFree++;
buf++;
}
+ /* Add this slab to the list of partial slabs */
LIST_ADDTAIL(&slab->head, &mgr->slabs);
return PIPE_OK;
@@ -328,23 +373,29 @@ pb_slab_manager_create_buffer(struct pb_manager *_mgr,
if(!pb_check_usage(desc->usage, mgr->desc.usage))
return NULL;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
+
+ /* Create a new slab, if we run out of partial slabs */
if (mgr->slabs.next == &mgr->slabs) {
(void) pb_slab_create(mgr);
if (mgr->slabs.next == &mgr->slabs) {
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
return NULL;
}
}
+
+ /* Allocate the buffer from a partial (or just created) slab */
list = mgr->slabs.next;
slab = LIST_ENTRY(struct pb_slab, list, head);
+
+ /* If totally full remove from the partial slab list */
if (--slab->numFree == 0)
LIST_DELINIT(list);
list = slab->freeBuffers.next;
LIST_DELINIT(list);
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
buf = LIST_ENTRY(struct pb_slab_buffer, list, head);
++buf->base.base.refcount;
@@ -386,9 +437,8 @@ pb_slab_manager_create(struct pb_manager *provider,
mgr->desc = *desc;
LIST_INITHEAD(&mgr->slabs);
- LIST_INITHEAD(&mgr->freeSlabs);
- _glthread_INIT_MUTEX(mgr->mutex);
+ pipe_mutex_init(mgr->mutex);
return &mgr->base;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c
index 362fd89..1e54fc3 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_validate.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c
@@ -35,7 +35,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_debug.h"
#include "pb_buffer.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_winsys.c b/src/gallium/auxiliary/pipebuffer/pb_winsys.c
index 9789440..28d137d 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_winsys.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_winsys.c
@@ -35,7 +35,7 @@
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pb_buffer.h"
diff --git a/src/gallium/auxiliary/rtasm/rtasm_execmem.c b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
index 300c1c2..1908758 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_execmem.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_execmem.c
@@ -33,7 +33,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "rtasm_execmem.h"
@@ -47,11 +47,12 @@
#include <unistd.h>
#include <sys/mman.h>
+#include "pipe/p_thread.h"
#include "util/u_mm.h"
#define EXEC_HEAP_SIZE (10*1024*1024)
-_glthread_DECLARE_STATIC_MUTEX(exec_mutex);
+pipe_static_mutex(exec_mutex);
static struct mem_block *exec_heap = NULL;
static unsigned char *exec_mem = NULL;
@@ -76,7 +77,7 @@ rtasm_exec_malloc(size_t size)
struct mem_block *block = NULL;
void *addr = NULL;
- _glthread_LOCK_MUTEX(exec_mutex);
+ pipe_mutex_lock(exec_mutex);
init_heap();
@@ -90,7 +91,7 @@ rtasm_exec_malloc(size_t size)
else
debug_printf("rtasm_exec_malloc failed\n");
- _glthread_UNLOCK_MUTEX(exec_mutex);
+ pipe_mutex_unlock(exec_mutex);
return addr;
}
@@ -99,7 +100,7 @@ rtasm_exec_malloc(size_t size)
void
rtasm_exec_free(void *addr)
{
- _glthread_LOCK_MUTEX(exec_mutex);
+ pipe_mutex_lock(exec_mutex);
if (exec_heap) {
struct mem_block *block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);
@@ -108,7 +109,7 @@ rtasm_exec_free(void *addr)
mmFreeMem(block);
}
- _glthread_UNLOCK_MUTEX(exec_mutex);
+ pipe_mutex_unlock(exec_mutex);
}
diff --git a/src/gallium/auxiliary/rtasm/rtasm_ppc_spe.c b/src/gallium/auxiliary/rtasm/rtasm_ppc_spe.c
index 7f6bf57..285ddc0 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_ppc_spe.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_ppc_spe.c
@@ -30,7 +30,7 @@
*/
#include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "rtasm_ppc_spe.h"
#ifdef GALLIUM_CELL
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
index f4ca282..6d4c081 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
@@ -27,7 +27,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
-#include "pipe/p_pointer.h"
+#include "util/u_pointer.h"
#include "rtasm_execmem.h"
#include "rtasm_x86sse.h"
diff --git a/src/gallium/auxiliary/sct/sct.c b/src/gallium/auxiliary/sct/sct.c
index 5e4126e..49bb7ea 100644
--- a/src/gallium/auxiliary/sct/sct.c
+++ b/src/gallium/auxiliary/sct/sct.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
#include "sct.h"
diff --git a/src/gallium/auxiliary/tgsi/Makefile b/src/gallium/auxiliary/tgsi/Makefile
index bbeff13..806a2bd 100644
--- a/src/gallium/auxiliary/tgsi/Makefile
+++ b/src/gallium/auxiliary/tgsi/Makefile
@@ -7,6 +7,7 @@ C_SOURCES = \
tgsi_build.c \
tgsi_dump.c \
tgsi_exec.c \
+ tgsi_info.c \
tgsi_iterate.c \
tgsi_parse.c \
tgsi_scan.c \
diff --git a/src/gallium/auxiliary/tgsi/SConscript b/src/gallium/auxiliary/tgsi/SConscript
index 03982e2..45bf3f6 100644
--- a/src/gallium/auxiliary/tgsi/SConscript
+++ b/src/gallium/auxiliary/tgsi/SConscript
@@ -7,6 +7,7 @@ tgsi = env.ConvenienceLibrary(
'tgsi_dump.c',
'tgsi_dump_c.c',
'tgsi_exec.c',
+ 'tgsi_info.c',
'tgsi_iterate.c',
'tgsi_parse.c',
'tgsi_sanity.c',
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 742ef14..74614d3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -26,7 +26,6 @@
**************************************************************************/
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_build.h"
#include "tgsi_parse.h"
@@ -820,7 +819,7 @@ tgsi_build_instruction_ext_nv(
unsigned cond_swizzle_z,
unsigned cond_swizzle_w,
unsigned cond_dst_update,
- unsigned cond_flow_update,
+ unsigned cond_flow_enable,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
@@ -837,7 +836,7 @@ tgsi_build_instruction_ext_nv(
instruction_ext_nv.CondSwizzleZ = cond_swizzle_z;
instruction_ext_nv.CondSwizzleW = cond_swizzle_w;
instruction_ext_nv.CondDstUpdate = cond_dst_update;
- instruction_ext_nv.CondFlowEnable = cond_flow_update;
+ instruction_ext_nv.CondFlowEnable = cond_flow_enable;
prev_token->Extended = 1;
instruction_grow( instruction, header );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.h b/src/gallium/auxiliary/tgsi/tgsi_build.h
index ed25830..7d62347 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.h
@@ -28,6 +28,10 @@
#ifndef TGSI_BUILD_H
#define TGSI_BUILD_H
+
+struct tgsi_token;
+
+
#if defined __cplusplus
extern "C" {
#endif
@@ -170,7 +174,7 @@ tgsi_build_instruction_ext_nv(
unsigned cond_swizzle_z,
unsigned cond_swizzle_w,
unsigned cond_dst_update,
- unsigned cond_flow_update,
+ unsigned cond_flow_enable,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index 29bb530..afc8ffa 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -28,6 +28,7 @@
#include "pipe/p_debug.h"
#include "util/u_string.h"
#include "tgsi_dump.h"
+#include "tgsi_info.h"
#include "tgsi_iterate.h"
struct dump_ctx
@@ -36,30 +37,40 @@ struct dump_ctx
uint instno;
- struct util_strbuf *sbuf;
+ void (*printf)(struct dump_ctx *ctx, const char *format, ...);
};
+static void
+dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
+{
+ va_list ap;
+ (void)ctx;
+ va_start(ap, format);
+ debug_vprintf(format, ap);
+ va_end(ap);
+}
+
static void
dump_enum(
- struct util_strbuf *sbuf,
+ struct dump_ctx *ctx,
uint e,
const char **enums,
uint enum_count )
{
if (e >= enum_count)
- util_strbuf_printf( sbuf, "%u", e );
+ ctx->printf( ctx, "%u", e );
else
- util_strbuf_printf( sbuf, "%s", enums[e] );
+ ctx->printf( ctx, "%s", enums[e] );
}
-#define EOL() util_strbuf_printf( sbuf, "\n" )
-#define TXT(S) util_strbuf_printf( sbuf, "%s", S )
-#define CHR(C) util_strbuf_printf( sbuf, "%c", C )
-#define UIX(I) util_strbuf_printf( sbuf, "0x%x", I )
-#define UID(I) util_strbuf_printf( sbuf, "%u", I )
-#define SID(I) util_strbuf_printf( sbuf, "%d", I )
-#define FLT(F) util_strbuf_printf( sbuf, "%10.4f", F )
-#define ENM(E,ENUMS) dump_enum( sbuf, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )
+#define EOL() ctx->printf( ctx, "\n" )
+#define TXT(S) ctx->printf( ctx, "%s", S )
+#define CHR(C) ctx->printf( ctx, "%c", C )
+#define UIX(I) ctx->printf( ctx, "0x%x", I )
+#define UID(I) ctx->printf( ctx, "%u", I )
+#define SID(I) ctx->printf( ctx, "%d", I )
+#define FLT(F) ctx->printf( ctx, "%10.4f", F )
+#define ENM(E,ENUMS) dump_enum( ctx, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )
static const char *processor_type_names[] =
{
@@ -103,129 +114,6 @@ static const char *immediate_type_names[] =
"FLT32"
};
-static const char *opcode_names[TGSI_OPCODE_LAST] =
-{
- "ARL",
- "MOV",
- "LIT",
- "RCP",
- "RSQ",
- "EXP",
- "LOG",
- "MUL",
- "ADD",
- "DP3",
- "DP4",
- "DST",
- "MIN",
- "MAX",
- "SLT",
- "SGE",
- "MAD",
- "SUB",
- "LERP",
- "CND",
- "CND0",
- "DOT2ADD",
- "INDEX",
- "NEGATE",
- "FRAC",
- "CLAMP",
- "FLOOR",
- "ROUND",
- "EXPBASE2",
- "LOGBASE2",
- "POWER",
- "CROSSPRODUCT",
- "MULTIPLYMATRIX",
- "ABS",
- "RCC",
- "DPH",
- "COS",
- "DDX",
- "DDY",
- "KILP",
- "PK2H",
- "PK2US",
- "PK4B",
- "PK4UB",
- "RFL",
- "SEQ",
- "SFL",
- "SGT",
- "SIN",
- "SLE",
- "SNE",
- "STR",
- "TEX",
- "TXD",
- "TXP",
- "UP2H",
- "UP2US",
- "UP4B",
- "UP4UB",
- "X2D",
- "ARA",
- "ARR",
- "BRA",
- "CAL",
- "RET",
- "SSG",
- "CMP",
- "SCS",
- "TXB",
- "NRM",
- "DIV",
- "DP2",
- "TXL",
- "BRK",
- "IF",
- "LOOP",
- "REP",
- "ELSE",
- "ENDIF",
- "ENDLOOP",
- "ENDREP",
- "PUSHA",
- "POPA",
- "CEIL",
- "I2F",
- "NOT",
- "TRUNC",
- "SHL",
- "SHR",
- "AND",
- "OR",
- "MOD",
- "XOR",
- "SAD",
- "TXF",
- "TXQ",
- "CONT",
- "EMIT",
- "ENDPRIM",
- "BGNLOOP2",
- "BGNSUB",
- "ENDLOOP2",
- "ENDSUB",
- "NOISE1",
- "NOISE2",
- "NOISE3",
- "NOISE4",
- "NOP",
- "M4X3",
- "M3X4",
- "M3X3",
- "M3X2",
- "NRM4",
- "CALLNZ",
- "IFC",
- "BREAKC",
- "KIL",
- "END",
- "SWZ"
-};
-
static const char *swizzle_names[] =
{
"x",
@@ -270,7 +158,7 @@ static const char *modulate_names[TGSI_MODULATE_COUNT] =
static void
_dump_register(
- struct util_strbuf *sbuf,
+ struct dump_ctx *ctx,
uint file,
int first,
int last )
@@ -287,7 +175,7 @@ _dump_register(
static void
_dump_register_ind(
- struct util_strbuf *sbuf,
+ struct dump_ctx *ctx,
uint file,
int index,
uint ind_file,
@@ -309,7 +197,7 @@ _dump_register_ind(
static void
_dump_writemask(
- struct util_strbuf *sbuf,
+ struct dump_ctx *ctx,
uint writemask )
{
if (writemask != TGSI_WRITEMASK_XYZW) {
@@ -330,18 +218,17 @@ iter_declaration(
struct tgsi_iterate_context *iter,
struct tgsi_full_declaration *decl )
{
- struct dump_ctx *ctx = (struct dump_ctx *) iter;
- struct util_strbuf *sbuf = ctx->sbuf;
+ struct dump_ctx *ctx = (struct dump_ctx *)iter;
TXT( "DCL " );
_dump_register(
- sbuf,
+ ctx,
decl->Declaration.File,
decl->DeclarationRange.First,
decl->DeclarationRange.Last );
_dump_writemask(
- sbuf,
+ ctx,
decl->Declaration.UsageMask );
if (decl->Declaration.Semantic) {
@@ -367,17 +254,11 @@ void
tgsi_dump_declaration(
const struct tgsi_full_declaration *decl )
{
- static char str[1024];
- struct util_strbuf sbuf;
struct dump_ctx ctx;
- util_strbuf_init(&sbuf, str, sizeof(str));
-
- ctx.sbuf = &sbuf;
+ ctx.printf = dump_ctx_printf;
iter_declaration( &ctx.iter, (struct tgsi_full_declaration *)decl );
-
- debug_printf("%s", str);
}
static boolean
@@ -386,7 +267,6 @@ iter_immediate(
struct tgsi_full_immediate *imm )
{
struct dump_ctx *ctx = (struct dump_ctx *) iter;
- struct util_strbuf *sbuf = ctx->sbuf;
uint i;
@@ -417,17 +297,11 @@ void
tgsi_dump_immediate(
const struct tgsi_full_immediate *imm )
{
- static char str[1024];
- struct util_strbuf sbuf;
struct dump_ctx ctx;
- util_strbuf_init(&sbuf, str, sizeof(str));
-
- ctx.sbuf = &sbuf;
+ ctx.printf = dump_ctx_printf;
iter_immediate( &ctx.iter, (struct tgsi_full_immediate *)imm );
-
- debug_printf("%s", str);
}
static boolean
@@ -436,7 +310,6 @@ iter_instruction(
struct tgsi_full_instruction *inst )
{
struct dump_ctx *ctx = (struct dump_ctx *) iter;
- struct util_strbuf *sbuf = ctx->sbuf;
uint instno = ctx->instno++;
uint i;
@@ -444,7 +317,7 @@ iter_instruction(
UID( instno );
CHR( ':' );
- ENM( inst->Instruction.Opcode, opcode_names );
+ TXT( tgsi_get_opcode_info( inst->Instruction.Opcode )->mnemonic );
switch (inst->Instruction.Saturate) {
case TGSI_SAT_NONE:
@@ -467,12 +340,12 @@ iter_instruction(
CHR( ' ' );
_dump_register(
- sbuf,
+ ctx,
dst->DstRegister.File,
dst->DstRegister.Index,
dst->DstRegister.Index );
ENM( dst->DstRegisterExtModulate.Modulate, modulate_names );
- _dump_writemask( sbuf, dst->DstRegister.WriteMask );
+ _dump_writemask( ctx, dst->DstRegister.WriteMask );
first_reg = FALSE;
}
@@ -499,7 +372,7 @@ iter_instruction(
if (src->SrcRegister.Indirect) {
_dump_register_ind(
- sbuf,
+ ctx,
src->SrcRegister.File,
src->SrcRegister.Index,
src->SrcRegisterInd.File,
@@ -507,7 +380,7 @@ iter_instruction(
}
else {
_dump_register(
- sbuf,
+ ctx,
src->SrcRegister.File,
src->SrcRegister.Index,
src->SrcRegister.Index );
@@ -582,18 +455,12 @@ tgsi_dump_instruction(
const struct tgsi_full_instruction *inst,
uint instno )
{
- static char str[1024];
- struct util_strbuf sbuf;
struct dump_ctx ctx;
- util_strbuf_init(&sbuf, str, sizeof(str));
-
ctx.instno = instno;
- ctx.sbuf = &sbuf;
+ ctx.printf = dump_ctx_printf;
iter_instruction( &ctx.iter, (struct tgsi_full_instruction *)inst );
-
- debug_printf("%s", str);
}
static boolean
@@ -601,7 +468,6 @@ prolog(
struct tgsi_iterate_context *iter )
{
struct dump_ctx *ctx = (struct dump_ctx *) iter;
- struct util_strbuf *sbuf = ctx->sbuf;
ENM( iter->processor.Processor, processor_type_names );
UID( iter->version.MajorVersion );
CHR( '.' );
@@ -611,21 +477,12 @@ prolog(
}
void
-tgsi_dump_str(
+tgsi_dump(
const struct tgsi_token *tokens,
- uint flags,
- char *str,
- size_t size)
+ uint flags )
{
- struct util_strbuf sbuf;
struct dump_ctx ctx;
- util_strbuf_init(&sbuf, str, size);
-
- /* sanity checks */
- assert( strcmp( opcode_names[TGSI_OPCODE_CONT], "CONT" ) == 0 );
- assert( strcmp( opcode_names[TGSI_OPCODE_END], "END" ) == 0 );
-
ctx.iter.prolog = prolog;
ctx.iter.iterate_instruction = iter_instruction;
ctx.iter.iterate_declaration = iter_declaration;
@@ -633,19 +490,57 @@ tgsi_dump_str(
ctx.iter.epilog = NULL;
ctx.instno = 0;
- ctx.sbuf = &sbuf;
+ ctx.printf = dump_ctx_printf;
tgsi_iterate_shader( tokens, &ctx.iter );
}
+struct str_dump_ctx
+{
+ struct dump_ctx base;
+ char *str;
+ char *ptr;
+ size_t left;
+};
+
+static void
+str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
+{
+ struct str_dump_ctx *sctx = (struct str_dump_ctx *)ctx;
+
+ if(sctx->left > 1) {
+ size_t written;
+ va_list ap;
+ va_start(ap, format);
+ written = util_vsnprintf(sctx->ptr, sctx->left, format, ap);
+ va_end(ap);
+ sctx->ptr += written;
+ sctx->left -= written;
+ }
+}
+
void
-tgsi_dump(
+tgsi_dump_str(
const struct tgsi_token *tokens,
- uint flags )
+ uint flags,
+ char *str,
+ size_t size)
{
- static char str[4096];
-
- tgsi_dump_str(tokens, flags, str, sizeof(str));
-
- debug_printf("%s", str);
+ struct str_dump_ctx ctx;
+
+ ctx.base.iter.prolog = prolog;
+ ctx.base.iter.iterate_instruction = iter_instruction;
+ ctx.base.iter.iterate_declaration = iter_declaration;
+ ctx.base.iter.iterate_immediate = iter_immediate;
+ ctx.base.iter.epilog = NULL;
+
+ ctx.base.instno = 0;
+ ctx.base.printf = &str_dump_ctx_printf;
+
+ ctx.str = str;
+ ctx.str[0] = 0;
+ ctx.ptr = str;
+ ctx.left = size;
+
+ tgsi_iterate_shader( tokens, &ctx.base.iter );
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
index eabd74b..be25cb4 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
@@ -26,11 +26,11 @@
**************************************************************************/
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
#include "util/u_string.h"
#include "tgsi_dump_c.h"
-#include "tgsi_parse.h"
#include "tgsi_build.h"
+#include "tgsi_info.h"
+#include "tgsi_parse.h"
static void
dump_enum(
@@ -104,128 +104,6 @@ static const char *TGSI_IMMS[] =
"IMM_FLOAT32"
};
-static const char *TGSI_OPCODES[TGSI_OPCODE_LAST] =
-{
- "OPCODE_ARL",
- "OPCODE_MOV",
- "OPCODE_LIT",
- "OPCODE_RCP",
- "OPCODE_RSQ",
- "OPCODE_EXP",
- "OPCODE_LOG",
- "OPCODE_MUL",
- "OPCODE_ADD",
- "OPCODE_DP3",
- "OPCODE_DP4",
- "OPCODE_DST",
- "OPCODE_MIN",
- "OPCODE_MAX",
- "OPCODE_SLT",
- "OPCODE_SGE",
- "OPCODE_MAD",
- "OPCODE_SUB",
- "OPCODE_LERP",
- "OPCODE_CND",
- "OPCODE_CND0",
- "OPCODE_DOT2ADD",
- "OPCODE_INDEX",
- "OPCODE_NEGATE",
- "OPCODE_FRAC",
- "OPCODE_CLAMP",
- "OPCODE_FLOOR",
- "OPCODE_ROUND",
- "OPCODE_EXPBASE2",
- "OPCODE_LOGBASE2",
- "OPCODE_POWER",
- "OPCODE_CROSSPRODUCT",
- "OPCODE_MULTIPLYMATRIX",
- "OPCODE_ABS",
- "OPCODE_RCC",
- "OPCODE_DPH",
- "OPCODE_COS",
- "OPCODE_DDX",
- "OPCODE_DDY",
- "OPCODE_KILP",
- "OPCODE_PK2H",
- "OPCODE_PK2US",
- "OPCODE_PK4B",
- "OPCODE_PK4UB",
- "OPCODE_RFL",
- "OPCODE_SEQ",
- "OPCODE_SFL",
- "OPCODE_SGT",
- "OPCODE_SIN",
- "OPCODE_SLE",
- "OPCODE_SNE",
- "OPCODE_STR",
- "OPCODE_TEX",
- "OPCODE_TXD",
- "OPCODE_TXP",
- "OPCODE_UP2H",
- "OPCODE_UP2US",
- "OPCODE_UP4B",
- "OPCODE_UP4UB",
- "OPCODE_X2D",
- "OPCODE_ARA",
- "OPCODE_ARR",
- "OPCODE_BRA",
- "OPCODE_CAL",
- "OPCODE_RET",
- "OPCODE_SSG",
- "OPCODE_CMP",
- "OPCODE_SCS",
- "OPCODE_TXB",
- "OPCODE_NRM",
- "OPCODE_DIV",
- "OPCODE_DP2",
- "OPCODE_TXL",
- "OPCODE_BRK",
- "OPCODE_IF",
- "OPCODE_LOOP",
- "OPCODE_REP",
- "OPCODE_ELSE",
- "OPCODE_ENDIF",
- "OPCODE_ENDLOOP",
- "OPCODE_ENDREP",
- "OPCODE_PUSHA",
- "OPCODE_POPA",
- "OPCODE_CEIL",
- "OPCODE_I2F",
- "OPCODE_NOT",
- "OPCODE_TRUNC",
- "OPCODE_SHL",
- "OPCODE_SHR",
- "OPCODE_AND",
- "OPCODE_OR",
- "OPCODE_MOD",
- "OPCODE_XOR",
- "OPCODE_SAD",
- "OPCODE_TXF",
- "OPCODE_TXQ",
- "OPCODE_CONT",
- "OPCODE_EMIT",
- "OPCODE_ENDPRIM",
- "OPCODE_BGNLOOP2",
- "OPCODE_BGNSUB",
- "OPCODE_ENDLOOP2",
- "OPCODE_ENDSUB",
- "OPCODE_NOISE1",
- "OPCODE_NOISE2",
- "OPCODE_NOISE3",
- "OPCODE_NOISE4",
- "OPCODE_NOP",
- "OPCODE_M4X3",
- "OPCODE_M3X4",
- "OPCODE_M3X3",
- "OPCODE_M3X2",
- "OPCODE_NRM4",
- "OPCODE_CALLNZ",
- "OPCODE_IFC",
- "OPCODE_BREAKC",
- "OPCODE_KIL",
- "OPCODE_END"
-};
-
static const char *TGSI_SATS[] =
{
"SAT_NONE",
@@ -428,8 +306,8 @@ dump_instruction_verbose(
{
unsigned i;
- TXT( "\nOpcode : " );
- ENM( inst->Instruction.Opcode, TGSI_OPCODES );
+ TXT( "\nOpcode : OPCODE_" );
+ TXT( tgsi_get_opcode_info( inst->Instruction.Opcode )->mnemonic );
if( deflt || fi->Instruction.Saturate != inst->Instruction.Saturate ) {
TXT( "\nSaturate : " );
ENM( inst->Instruction.Saturate, TGSI_SATS );
@@ -770,10 +648,6 @@ tgsi_dump_c(
uint deflt = flags & TGSI_DUMP_C_DEFAULT;
uint instno = 0;
- /* sanity checks */
- assert(strcmp(TGSI_OPCODES[TGSI_OPCODE_CONT], "OPCODE_CONT") == 0);
- assert(strcmp(TGSI_OPCODES[TGSI_OPCODE_END], "OPCODE_END") == 0);
-
tgsi_parse_init( &parse, tokens );
TXT( "tgsi-dump begin -----------------" );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index c4ba667..df00293 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,7 +26,7 @@
**************************************************************************/
/**
- * TGSI interpretor/executor.
+ * TGSI interpreter/executor.
*
* Flow control information:
*
@@ -52,17 +52,25 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi_exec.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#define FAST_MATH 1
#define TILE_TOP_LEFT 0
#define TILE_TOP_RIGHT 1
#define TILE_BOTTOM_LEFT 2
#define TILE_BOTTOM_RIGHT 3
+#define CHAN_X 0
+#define CHAN_Y 1
+#define CHAN_Z 2
+#define CHAN_W 3
+
/*
* Shorthand locations of various utility registers (_I = Index, _C = Channel)
*/
@@ -88,15 +96,14 @@
#define TEMP_OUTPUT_C TGSI_EXEC_TEMP_OUTPUT_C
#define TEMP_PRIMITIVE_I TGSI_EXEC_TEMP_PRIMITIVE_I
#define TEMP_PRIMITIVE_C TGSI_EXEC_TEMP_PRIMITIVE_C
+#define TEMP_CC_I TGSI_EXEC_TEMP_CC_I
+#define TEMP_CC_C TGSI_EXEC_TEMP_CC_C
#define TEMP_3_I TGSI_EXEC_TEMP_THREE_I
#define TEMP_3_C TGSI_EXEC_TEMP_THREE_C
#define TEMP_HALF_I TGSI_EXEC_TEMP_HALF_I
#define TEMP_HALF_C TGSI_EXEC_TEMP_HALF_C
#define TEMP_R0 TGSI_EXEC_TEMP_R0
-#define FOR_EACH_CHANNEL(CHAN)\
- for (CHAN = 0; CHAN < 4; CHAN++)
-
#define IS_CHANNEL_ENABLED(INST, CHAN)\
((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
@@ -104,11 +111,11 @@
((INST).FullDstRegisters[1].DstRegister.WriteMask & (1 << (CHAN)))
#define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\
- FOR_EACH_CHANNEL( CHAN )\
+ for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\
if (IS_CHANNEL_ENABLED( INST, CHAN ))
#define FOR_EACH_ENABLED_CHANNEL2(INST, CHAN)\
- FOR_EACH_CHANNEL( CHAN )\
+ for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\
if (IS_CHANNEL_ENABLED2( INST, CHAN ))
@@ -116,14 +123,6 @@
#define UPDATE_EXEC_MASK(MACH) \
MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask & MACH->FuncMask
-
-#define CHAN_X 0
-#define CHAN_Y 1
-#define CHAN_Z 2
-#define CHAN_W 3
-
-
-
/**
* Initialize machine state by expanding tokens to full instructions,
* allocating temporary storage, setting up constants, etc.
@@ -149,6 +148,8 @@ tgsi_exec_machine_bind_shader(
tgsi_dump(tokens, 0);
#endif
+ util_init_math();
+
mach->Tokens = tokens;
mach->Samplers = samplers;
@@ -452,10 +453,17 @@ micro_exp2(
union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src)
{
+#if FAST_MATH
+ dst->f[0] = util_fast_exp2( src->f[0] );
+ dst->f[1] = util_fast_exp2( src->f[1] );
+ dst->f[2] = util_fast_exp2( src->f[2] );
+ dst->f[3] = util_fast_exp2( src->f[3] );
+#else
dst->f[0] = powf( 2.0f, src->f[0] );
dst->f[1] = powf( 2.0f, src->f[1] );
dst->f[2] = powf( 2.0f, src->f[2] );
dst->f[3] = powf( 2.0f, src->f[3] );
+#endif
}
static void
@@ -532,10 +540,17 @@ micro_lg2(
union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src )
{
+#if FAST_MATH
+ dst->f[0] = util_fast_log2( src->f[0] );
+ dst->f[1] = util_fast_log2( src->f[1] );
+ dst->f[2] = util_fast_log2( src->f[2] );
+ dst->f[3] = util_fast_log2( src->f[3] );
+#else
dst->f[0] = logf( src->f[0] ) * 1.442695f;
dst->f[1] = logf( src->f[1] ) * 1.442695f;
dst->f[2] = logf( src->f[2] ) * 1.442695f;
dst->f[3] = logf( src->f[3] ) * 1.442695f;
+#endif
}
static void
@@ -800,10 +815,17 @@ micro_pow(
const union tgsi_exec_channel *src0,
const union tgsi_exec_channel *src1 )
{
+#if FAST_MATH
+ dst->f[0] = util_fast_pow( src0->f[0], src1->f[0] );
+ dst->f[1] = util_fast_pow( src0->f[1], src1->f[1] );
+ dst->f[2] = util_fast_pow( src0->f[2], src1->f[2] );
+ dst->f[3] = util_fast_pow( src0->f[3], src1->f[3] );
+#else
dst->f[0] = powf( src0->f[0], src1->f[0] );
dst->f[1] = powf( src0->f[1], src1->f[1] );
dst->f[2] = powf( src0->f[2], src1->f[2] );
dst->f[3] = powf( src0->f[3], src1->f[3] );
+#endif
}
static void
@@ -935,6 +957,7 @@ fetch_src_file_channel(
case TGSI_EXTSWIZZLE_W:
switch( file ) {
case TGSI_FILE_CONSTANT:
+ assert(mach->Consts);
chan->f[0] = mach->Consts[index->i[0]][swizzle];
chan->f[1] = mach->Consts[index->i[1]][swizzle];
chan->f[2] = mach->Consts[index->i[2]][swizzle];
@@ -1124,11 +1147,15 @@ store_dest(
const struct tgsi_full_instruction *inst,
uint chan_index )
{
+ uint i;
+ union tgsi_exec_channel null;
union tgsi_exec_channel *dst;
+ uint execmask = mach->ExecMask;
- switch( reg->DstRegister.File ) {
+ switch (reg->DstRegister.File) {
case TGSI_FILE_NULL:
- return;
+ dst = &null;
+ break;
case TGSI_FILE_OUTPUT:
dst = &mach->Outputs[mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]
@@ -1136,7 +1163,7 @@ store_dest(
break;
case TGSI_FILE_TEMPORARY:
- assert(reg->DstRegister.Index < TGSI_EXEC_NUM_TEMPS);
+ assert( reg->DstRegister.Index < TGSI_EXEC_NUM_TEMPS );
dst = &mach->Temps[reg->DstRegister.Index].xyzw[chan_index];
break;
@@ -1149,32 +1176,193 @@ store_dest(
return;
}
- switch (inst->Instruction.Saturate)
- {
+ if (inst->InstructionExtNv.CondFlowEnable) {
+ union tgsi_exec_channel *cc = &mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C];
+ uint swizzle;
+ uint shift;
+ uint mask;
+ uint test;
+
+ /* Only CC0 supported.
+ */
+ assert( inst->InstructionExtNv.CondFlowIndex < 1 );
+
+ switch (chan_index) {
+ case CHAN_X:
+ swizzle = inst->InstructionExtNv.CondSwizzleX;
+ break;
+ case CHAN_Y:
+ swizzle = inst->InstructionExtNv.CondSwizzleY;
+ break;
+ case CHAN_Z:
+ swizzle = inst->InstructionExtNv.CondSwizzleZ;
+ break;
+ case CHAN_W:
+ swizzle = inst->InstructionExtNv.CondSwizzleW;
+ break;
+ default:
+ assert( 0 );
+ return;
+ }
+
+ switch (swizzle) {
+ case TGSI_SWIZZLE_X:
+ shift = TGSI_EXEC_CC_X_SHIFT;
+ mask = TGSI_EXEC_CC_X_MASK;
+ break;
+ case TGSI_SWIZZLE_Y:
+ shift = TGSI_EXEC_CC_Y_SHIFT;
+ mask = TGSI_EXEC_CC_Y_MASK;
+ break;
+ case TGSI_SWIZZLE_Z:
+ shift = TGSI_EXEC_CC_Z_SHIFT;
+ mask = TGSI_EXEC_CC_Z_MASK;
+ break;
+ case TGSI_SWIZZLE_W:
+ shift = TGSI_EXEC_CC_W_SHIFT;
+ mask = TGSI_EXEC_CC_W_MASK;
+ break;
+ default:
+ assert( 0 );
+ return;
+ }
+
+ switch (inst->InstructionExtNv.CondMask) {
+ case TGSI_CC_GT:
+ test = ~(TGSI_EXEC_CC_GT << shift) & mask;
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (cc->u[i] & test)
+ execmask &= ~(1 << i);
+ break;
+
+ case TGSI_CC_EQ:
+ test = ~(TGSI_EXEC_CC_EQ << shift) & mask;
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (cc->u[i] & test)
+ execmask &= ~(1 << i);
+ break;
+
+ case TGSI_CC_LT:
+ test = ~(TGSI_EXEC_CC_LT << shift) & mask;
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (cc->u[i] & test)
+ execmask &= ~(1 << i);
+ break;
+
+ case TGSI_CC_GE:
+ test = ~((TGSI_EXEC_CC_GT | TGSI_EXEC_CC_EQ) << shift) & mask;
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (cc->u[i] & test)
+ execmask &= ~(1 << i);
+ break;
+
+ case TGSI_CC_LE:
+ test = ~((TGSI_EXEC_CC_LT | TGSI_EXEC_CC_EQ) << shift) & mask;
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (cc->u[i] & test)
+ execmask &= ~(1 << i);
+ break;
+
+ case TGSI_CC_NE:
+ test = ~((TGSI_EXEC_CC_GT | TGSI_EXEC_CC_LT | TGSI_EXEC_CC_UN) << shift) & mask;
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (cc->u[i] & test)
+ execmask &= ~(1 << i);
+ break;
+
+ case TGSI_CC_TR:
+ break;
+
+ case TGSI_CC_FL:
+ for (i = 0; i < QUAD_SIZE; i++)
+ execmask &= ~(1 << i);
+ break;
+
+ default:
+ assert( 0 );
+ return;
+ }
+ }
+
+ switch (inst->Instruction.Saturate) {
case TGSI_SAT_NONE:
- if (mach->ExecMask & 0x1)
- dst->i[0] = chan->i[0];
- if (mach->ExecMask & 0x2)
- dst->i[1] = chan->i[1];
- if (mach->ExecMask & 0x4)
- dst->i[2] = chan->i[2];
- if (mach->ExecMask & 0x8)
- dst->i[3] = chan->i[3];
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (execmask & (1 << i))
+ dst->i[i] = chan->i[i];
break;
case TGSI_SAT_ZERO_ONE:
- /* XXX need to obey ExecMask here */
- micro_max(dst, chan, &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]);
- micro_min(dst, dst, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C]);
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (execmask & (1 << i)) {
+ if (chan->f[i] < 0.0f)
+ dst->f[i] = 0.0f;
+ else if (chan->f[i] > 1.0f)
+ dst->f[i] = 1.0f;
+ else
+ dst->i[i] = chan->i[i];
+ }
break;
case TGSI_SAT_MINUS_PLUS_ONE:
- assert( 0 );
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (execmask & (1 << i)) {
+ if (chan->f[i] < -1.0f)
+ dst->f[i] = -1.0f;
+ else if (chan->f[i] > 1.0f)
+ dst->f[i] = 1.0f;
+ else
+ dst->i[i] = chan->i[i];
+ }
break;
default:
assert( 0 );
}
+
+ if (inst->InstructionExtNv.CondDstUpdate) {
+ union tgsi_exec_channel *cc = &mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C];
+ uint shift;
+ uint mask;
+
+ /* Only CC0 supported.
+ */
+ assert( inst->InstructionExtNv.CondDstIndex < 1 );
+
+ switch (chan_index) {
+ case CHAN_X:
+ shift = TGSI_EXEC_CC_X_SHIFT;
+ mask = ~TGSI_EXEC_CC_X_MASK;
+ break;
+ case CHAN_Y:
+ shift = TGSI_EXEC_CC_Y_SHIFT;
+ mask = ~TGSI_EXEC_CC_Y_MASK;
+ break;
+ case CHAN_Z:
+ shift = TGSI_EXEC_CC_Z_SHIFT;
+ mask = ~TGSI_EXEC_CC_Z_MASK;
+ break;
+ case CHAN_W:
+ shift = TGSI_EXEC_CC_W_SHIFT;
+ mask = ~TGSI_EXEC_CC_W_MASK;
+ break;
+ default:
+ assert( 0 );
+ return;
+ }
+
+ for (i = 0; i < QUAD_SIZE; i++)
+ if (execmask & (1 << i)) {
+ cc->u[i] &= mask;
+ if (dst->f[i] < 0.0f)
+ cc->u[i] |= TGSI_EXEC_CC_LT << shift;
+ else if (dst->f[i] > 0.0f)
+ cc->u[i] |= TGSI_EXEC_CC_GT << shift;
+ else if (dst->f[i] == 0.0f)
+ cc->u[i] |= TGSI_EXEC_CC_EQ << shift;
+ else
+ cc->u[i] |= TGSI_EXEC_CC_UN << shift;
+ }
+ }
}
#define FETCH(VAL,INDEX,CHAN)\
@@ -1234,10 +1422,34 @@ static void
exec_kilp(struct tgsi_exec_machine *mach,
const struct tgsi_full_instruction *inst)
{
- uint kilmask = 0; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
+ uint kilmask; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
- /* TODO: build kilmask from CC mask */
+ if (inst->InstructionExtNv.CondFlowEnable) {
+ uint swizzle[4];
+ uint chan_index;
+ kilmask = 0x0;
+
+ swizzle[0] = inst->InstructionExtNv.CondSwizzleX;
+ swizzle[1] = inst->InstructionExtNv.CondSwizzleY;
+ swizzle[2] = inst->InstructionExtNv.CondSwizzleZ;
+ swizzle[3] = inst->InstructionExtNv.CondSwizzleW;
+
+ for (chan_index = 0; chan_index < 4; chan_index++)
+ {
+ uint i;
+
+ for (i = 0; i < 4; i++) {
+ /* TODO: evaluate the condition code */
+ if (0)
+ kilmask |= 1 << i;
+ }
+ }
+ }
+ else {
+ /* "unconditional" kil */
+ kilmask = mach->ExecMask;
+ }
mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask;
}
@@ -1503,9 +1715,9 @@ exec_instruction(
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_ARL:
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_f2it( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
+ FETCH( &r[0], 0, chan_index );
+ micro_f2it( &r[0], &r[0] );
+ STORE( &r[0], 0, chan_index );
}
break;
@@ -1571,18 +1783,18 @@ exec_instruction(
micro_flr( &r[1], &r[0] ); /* r1 = floor(r0) */
if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
micro_exp2( &r[2], &r[1] ); /* r2 = 2 ^ r1 */
- STORE( &r[2], 0, CHAN_X ); /* store r2 */
+ STORE( &r[2], 0, CHAN_X ); /* store r2 */
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
micro_sub( &r[2], &r[0], &r[1] ); /* r2 = r0 - r1 */
- STORE( &r[2], 0, CHAN_Y ); /* store r2 */
+ STORE( &r[2], 0, CHAN_Y ); /* store r2 */
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
micro_exp2( &r[2], &r[0] ); /* r2 = 2 ^ r0 */
- STORE( &r[2], 0, CHAN_Z ); /* store r2 */
+ STORE( &r[2], 0, CHAN_Z ); /* store r2 */
}
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;
@@ -1592,18 +1804,18 @@ exec_instruction(
micro_lg2( &r[1], &r[2] ); /* r1 = lg2(r2) */
micro_flr( &r[0], &r[1] ); /* r0 = floor(r1) */
if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &r[0], 0, CHAN_X );
+ STORE( &r[0], 0, CHAN_X );
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
micro_exp2( &r[0], &r[0] ); /* r0 = 2 ^ r0 */
micro_div( &r[0], &r[2], &r[0] ); /* r0 = r2 / r0 */
- STORE( &r[0], 0, CHAN_Y );
+ STORE( &r[0], 0, CHAN_Y );
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- STORE( &r[1], 0, CHAN_Z );
+ STORE( &r[1], 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;
@@ -1839,7 +2051,11 @@ exec_instruction(
/* TGSI_OPCODE_EX2 */
FETCH(&r[0], 0, CHAN_X);
+#if FAST_MATH
+ micro_exp2( &r[0], &r[0] );
+#else
micro_pow( &r[0], &mach->Temps[TEMP_2_I].xyzw[TEMP_2_C], &r[0] );
+#endif
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
STORE( &r[0], 0, chan_index );
@@ -2158,7 +2374,7 @@ exec_instruction(
mach->FuncMask &= ~mach->ExecMask;
UPDATE_EXEC_MASK(mach);
- if (mach->ExecMask == 0x0) {
+ if (mach->FuncMask == 0x0) {
/* really return now (otherwise, keep executing */
if (mach->CallStackTop == 0) {
@@ -2515,6 +2731,13 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
mach->Primitives[0] = 0;
}
+ for (i = 0; i < QUAD_SIZE; i++) {
+ mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C].u[i] =
+ (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_X_SHIFT) |
+ (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_Y_SHIFT) |
+ (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_Z_SHIFT) |
+ (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_W_SHIFT);
+ }
/* execute declarations (interpolants) */
for (i = 0; i < mach->NumDeclarations; i++) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index 4f30650..c4e649e 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#if !defined TGSI_EXEC_H
+#ifndef TGSI_EXEC_H
#define TGSI_EXEC_H
#include "pipe/p_compiler.h"
@@ -140,11 +140,30 @@ struct tgsi_exec_labels
#define TGSI_EXEC_TEMP_PRIMITIVE_I (TGSI_EXEC_NUM_TEMPS + 2)
#define TGSI_EXEC_TEMP_PRIMITIVE_C 2
-#define TGSI_EXEC_TEMP_THREE_I (TGSI_EXEC_NUM_TEMPS + 2)
-#define TGSI_EXEC_TEMP_THREE_C 3
+/* NVIDIA condition code (CC) vector
+ */
+#define TGSI_EXEC_CC_GT 0x01
+#define TGSI_EXEC_CC_EQ 0x02
+#define TGSI_EXEC_CC_LT 0x04
+#define TGSI_EXEC_CC_UN 0x08
+
+#define TGSI_EXEC_CC_X_MASK 0x000000ff
+#define TGSI_EXEC_CC_X_SHIFT 0
+#define TGSI_EXEC_CC_Y_MASK 0x0000ff00
+#define TGSI_EXEC_CC_Y_SHIFT 8
+#define TGSI_EXEC_CC_Z_MASK 0x00ff0000
+#define TGSI_EXEC_CC_Z_SHIFT 16
+#define TGSI_EXEC_CC_W_MASK 0xff000000
+#define TGSI_EXEC_CC_W_SHIFT 24
+
+#define TGSI_EXEC_TEMP_CC_I (TGSI_EXEC_NUM_TEMPS + 2)
+#define TGSI_EXEC_TEMP_CC_C 3
+
+#define TGSI_EXEC_TEMP_THREE_I (TGSI_EXEC_NUM_TEMPS + 3)
+#define TGSI_EXEC_TEMP_THREE_C 0
#define TGSI_EXEC_TEMP_HALF_I (TGSI_EXEC_NUM_TEMPS + 3)
-#define TGSI_EXEC_TEMP_HALF_C 0
+#define TGSI_EXEC_TEMP_HALF_C 1
#define TGSI_EXEC_TEMP_R0 (TGSI_EXEC_NUM_TEMPS + 4)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
new file mode 100644
index 0000000..a4899cd
--- /dev/null
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -0,0 +1,161 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "pipe/p_debug.h"
+#include "tgsi_info.h"
+
+static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
+{
+ { 1, 1, 0, 0, "ARL" },
+ { 1, 1, 0, 0, "MOV" },
+ { 1, 1, 0, 0, "LIT" },
+ { 1, 1, 0, 0, "RCP" },
+ { 1, 1, 0, 0, "RSQ" },
+ { 1, 1, 0, 0, "EXP" },
+ { 1, 1, 0, 0, "LOG" },
+ { 1, 2, 0, 0, "MUL" },
+ { 1, 2, 0, 0, "ADD" },
+ { 1, 2, 0, 0, "DP3" },
+ { 1, 2, 0, 0, "DP4" },
+ { 1, 2, 0, 0, "DST" },
+ { 1, 2, 0, 0, "MIN" },
+ { 1, 2, 0, 0, "MAX" },
+ { 1, 2, 0, 0, "SLT" },
+ { 1, 2, 0, 0, "SGE" },
+ { 1, 3, 0, 0, "MAD" },
+ { 1, 2, 0, 0, "SUB" },
+ { 1, 3, 0, 0, "LERP" },
+ { 1, 3, 0, 0, "CND" },
+ { 1, 3, 0, 0, "CND0" },
+ { 1, 3, 0, 0, "DOT2ADD" },
+ { 1, 2, 0, 0, "INDEX" },
+ { 1, 1, 0, 0, "NEGATE" },
+ { 1, 1, 0, 0, "FRAC" },
+ { 1, 3, 0, 0, "CLAMP" },
+ { 1, 1, 0, 0, "FLOOR" },
+ { 1, 1, 0, 0, "ROUND" },
+ { 1, 1, 0, 0, "EXPBASE2" },
+ { 1, 1, 0, 0, "LOGBASE2" },
+ { 1, 2, 0, 0, "POWER" },
+ { 1, 2, 0, 0, "CROSSPRODUCT" },
+ { 1, 2, 0, 0, "MULTIPLYMATRIX" },
+ { 1, 1, 0, 0, "ABS" },
+ { 1, 1, 0, 0, "RCC" },
+ { 1, 2, 0, 0, "DPH" },
+ { 1, 1, 0, 0, "COS" },
+ { 1, 1, 0, 0, "DDX" },
+ { 1, 1, 0, 0, "DDY" },
+ { 0, 1, 0, 0, "KILP" },
+ { 1, 1, 0, 0, "PK2H" },
+ { 1, 1, 0, 0, "PK2US" },
+ { 1, 1, 0, 0, "PK4B" },
+ { 1, 1, 0, 0, "PK4UB" },
+ { 1, 2, 0, 0, "RFL" },
+ { 1, 2, 0, 0, "SEQ" },
+ { 1, 2, 0, 0, "SFL" },
+ { 1, 2, 0, 0, "SGT" },
+ { 1, 1, 0, 0, "SIN" },
+ { 1, 2, 0, 0, "SLE" },
+ { 1, 2, 0, 0, "SNE" },
+ { 1, 2, 0, 0, "STR" },
+ { 1, 2, 1, 0, "TEX" },
+ { 1, 4, 1, 0, "TXD" },
+ { 1, 2, 1, 0, "TXP" },
+ { 1, 1, 0, 0, "UP2H" },
+ { 1, 1, 0, 0, "UP2US" },
+ { 1, 1, 0, 0, "UP4B" },
+ { 1, 1, 0, 0, "UP4UB" },
+ { 1, 3, 0, 0, "X2D" },
+ { 1, 1, 0, 0, "ARA" },
+ { 1, 1, 0, 0, "ARR" },
+ { 0, 1, 0, 0, "BRA" },
+ { 0, 0, 0, 1, "CAL" },
+ { 0, 0, 0, 0, "RET" },
+ { 1, 1, 0, 0, "SSG" },
+ { 1, 3, 0, 0, "CMP" },
+ { 1, 1, 0, 0, "SCS" },
+ { 1, 2, 1, 0, "TXB" },
+ { 1, 1, 0, 0, "NRM" },
+ { 1, 2, 0, 0, "DIV" },
+ { 1, 2, 0, 0, "DP2" },
+ { 1, 2, 1, 0, "TXL" },
+ { 0, 0, 0, 0, "BRK" },
+ { 0, 1, 0, 1, "IF" },
+ { 0, 0, 0, 0, "LOOP" },
+ { 0, 1, 0, 0, "REP" },
+ { 0, 0, 0, 1, "ELSE" },
+ { 0, 0, 0, 0, "ENDIF" },
+ { 0, 0, 0, 0, "ENDLOOP" },
+ { 0, 0, 0, 0, "ENDREP" },
+ { 0, 1, 0, 0, "PUSHA" },
+ { 1, 0, 0, 0, "POPA" },
+ { 1, 1, 0, 0, "CEIL" },
+ { 1, 1, 0, 0, "I2F" },
+ { 1, 1, 0, 0, "NOT" },
+ { 1, 1, 0, 0, "TRUNC" },
+ { 1, 2, 0, 0, "SHL" },
+ { 1, 2, 0, 0, "SHR" },
+ { 1, 2, 0, 0, "AND" },
+ { 1, 2, 0, 0, "OR" },
+ { 1, 2, 0, 0, "MOD" },
+ { 1, 2, 0, 0, "XOR" },
+ { 1, 3, 0, 0, "SAD" },
+ { 1, 2, 1, 0, "TXF" },
+ { 1, 2, 1, 0, "TXQ" },
+ { 0, 0, 0, 0, "CONT" },
+ { 0, 0, 0, 0, "EMIT" },
+ { 0, 0, 0, 0, "ENDPRIM" },
+ { 0, 0, 0, 1, "BGNLOOP2" },
+ { 0, 0, 0, 0, "BGNSUB" },
+ { 0, 0, 0, 1, "ENDLOOP2" },
+ { 0, 0, 0, 0, "ENDSUB" },
+ { 1, 1, 0, 0, "NOISE1" },
+ { 1, 1, 0, 0, "NOISE2" },
+ { 1, 1, 0, 0, "NOISE3" },
+ { 1, 1, 0, 0, "NOISE4" },
+ { 0, 0, 0, 0, "NOP" },
+ { 1, 2, 0, 0, "M4X3" },
+ { 1, 2, 0, 0, "M3X4" },
+ { 1, 2, 0, 0, "M3X3" },
+ { 1, 2, 0, 0, "M3X2" },
+ { 1, 1, 0, 0, "NRM4" },
+ { 0, 1, 0, 0, "CALLNZ" },
+ { 0, 1, 0, 0, "IFC" },
+ { 0, 1, 0, 0, "BREAKC" },
+ { 0, 0, 0, 0, "KIL" },
+ { 0, 0, 0, 0, "END" },
+ { 1, 1, 0, 0, "SWZ" }
+};
+
+const struct tgsi_opcode_info *
+tgsi_get_opcode_info( uint opcode )
+{
+ if (opcode < TGSI_OPCODE_LAST)
+ return &opcode_info[opcode];
+ assert( 0 );
+ return NULL;
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.h b/src/gallium/auxiliary/tgsi/tgsi_info.h
new file mode 100644
index 0000000..7230bda
--- /dev/null
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef TGSI_INFO_H
+#define TGSI_INFO_H
+
+#include "pipe/p_shader_tokens.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+struct tgsi_opcode_info
+{
+ uint num_dst;
+ uint num_src;
+ boolean is_tex;
+ boolean is_branch;
+ const char *mnemonic;
+};
+
+const struct tgsi_opcode_info *
+tgsi_get_opcode_info( uint opcode );
+
+#if defined __cplusplus
+}
+#endif
+
+#endif /* TGSI_INFO_H */
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c
index d16f0cd..3757486 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c
@@ -26,10 +26,10 @@
**************************************************************************/
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_parse.h"
#include "tgsi_build.h"
+#include "util/u_memory.h"
void
tgsi_full_token_init(
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c
index 2e3ec96..c659027 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c
@@ -27,6 +27,7 @@
#include "pipe/p_debug.h"
#include "tgsi_sanity.h"
+#include "tgsi_info.h"
#include "tgsi_iterate.h"
#define MAX_REGISTERS 256
@@ -170,6 +171,7 @@ iter_instruction(
struct tgsi_full_instruction *inst )
{
struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;
+ const struct tgsi_opcode_info *info;
uint i;
/* There must be no other instructions after END.
@@ -181,6 +183,19 @@ iter_instruction(
ctx->index_of_END = ctx->num_instructions;
}
+ info = tgsi_get_opcode_info( inst->Instruction.Opcode );
+ if (info == NULL) {
+ report_error( ctx, "Invalid instruction opcode" );
+ return TRUE;
+ }
+
+ if (info->num_dst != inst->Instruction.NumDstRegs) {
+ report_error( ctx, "Invalid number of destination operands" );
+ }
+ if (info->num_src != inst->Instruction.NumSrcRegs) {
+ report_error( ctx, "Invalid number of source operands" );
+ }
+
/* Check destination and source registers' validity.
* Mark the registers as used.
*/
@@ -307,7 +322,7 @@ epilog(
/* Print totals, if any.
*/
if (ctx->errors || ctx->warnings)
- debug_printf( "\n%u errors, %u warnings", ctx->errors, ctx->warnings );
+ debug_printf( "%u errors, %u warnings\n", ctx->errors, ctx->warnings );
return TRUE;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 59bcf10..be4870a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -33,11 +33,11 @@
*/
-#include "tgsi_scan.h"
-#include "tgsi/tgsi_parse.h"
+#include "util/u_math.h"
#include "tgsi/tgsi_build.h"
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_scan.h"
-#include "pipe/p_util.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 47dc06f..4681b29 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,8 +25,9 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "pipe/p_debug.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi_exec.h"
@@ -42,15 +43,17 @@
*/
#define HIGH_PRECISION 1
+#define FAST_MATH 1
+
#define FOR_EACH_CHANNEL( CHAN )\
- for( CHAN = 0; CHAN < 4; CHAN++ )
+ for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
#define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
#define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
- if( IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
+ if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
#define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\
FOR_EACH_CHANNEL( CHAN )\
@@ -61,7 +64,11 @@
#define CHAN_Z 2
#define CHAN_W 3
+#define TEMP_ONE_I TGSI_EXEC_TEMP_ONE_I
+#define TEMP_ONE_C TGSI_EXEC_TEMP_ONE_C
+
#define TEMP_R0 TGSI_EXEC_TEMP_R0
+#define TEMP_ADDR TGSI_EXEC_TEMP_ADDR
/**
* X86 utility functions.
@@ -215,19 +222,61 @@ emit_ret(
static void
emit_const(
struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- sse_movss(
- func,
- make_xmm( xmm ),
- get_const( vec, chan ) );
- sse_shufps(
- func,
- make_xmm( xmm ),
- make_xmm( xmm ),
- SHUF( 0, 0, 0, 0 ) );
+ uint xmm,
+ int vec,
+ uint chan,
+ uint indirect,
+ uint indirectFile,
+ int indirectIndex )
+{
+ if (indirect) {
+ struct x86_reg r0 = get_input_base();
+ struct x86_reg r1 = get_output_base();
+ uint i;
+
+ assert( indirectFile == TGSI_FILE_ADDRESS );
+ assert( indirectIndex == 0 );
+
+ x86_push( func, r0 );
+ x86_push( func, r1 );
+
+ for (i = 0; i < QUAD_SIZE; i++) {
+ x86_lea( func, r0, get_const( vec, chan ) );
+ x86_mov( func, r1, x86_make_disp( get_temp( TEMP_ADDR, CHAN_X ), i * 4 ) );
+
+ /* Quick hack to multiply by 16 -- need to add SHL to rtasm.
+ */
+ x86_add( func, r1, r1 );
+ x86_add( func, r1, r1 );
+ x86_add( func, r1, r1 );
+ x86_add( func, r1, r1 );
+
+ x86_add( func, r0, r1 );
+ x86_mov( func, r1, x86_deref( r0 ) );
+ x86_mov( func, x86_make_disp( get_temp( TEMP_R0, CHAN_X ), i * 4 ), r1 );
+ }
+
+ x86_pop( func, r1 );
+ x86_pop( func, r0 );
+
+ sse_movaps(
+ func,
+ make_xmm( xmm ),
+ get_temp( TEMP_R0, CHAN_X ) );
+ }
+ else {
+ assert( vec >= 0 );
+
+ sse_movss(
+ func,
+ make_xmm( xmm ),
+ get_const( vec, chan ) );
+ sse_shufps(
+ func,
+ make_xmm( xmm ),
+ make_xmm( xmm ),
+ SHUF( 0, 0, 0, 0 ) );
+ }
}
static void
@@ -369,10 +418,12 @@ emit_addrs(
unsigned vec,
unsigned chan )
{
+ assert( vec == 0 );
+
emit_temps(
func,
xmm,
- vec + TGSI_EXEC_NUM_TEMPS,
+ vec + TGSI_EXEC_TEMP_ADDR,
chan );
}
@@ -550,12 +601,10 @@ static void PIPE_CDECL
cos4f(
float *store )
{
- const unsigned X = 0;
-
- store[X + 0] = cosf( store[X + 0] );
- store[X + 1] = cosf( store[X + 1] );
- store[X + 2] = cosf( store[X + 2] );
- store[X + 3] = cosf( store[X + 3] );
+ store[0] = cosf( store[0] );
+ store[1] = cosf( store[1] );
+ store[2] = cosf( store[2] );
+ store[3] = cosf( store[3] );
}
static void
@@ -573,12 +622,17 @@ static void PIPE_CDECL
ex24f(
float *store )
{
- const unsigned X = 0;
-
- store[X + 0] = powf( 2.0f, store[X + 0] );
- store[X + 1] = powf( 2.0f, store[X + 1] );
- store[X + 2] = powf( 2.0f, store[X + 2] );
- store[X + 3] = powf( 2.0f, store[X + 3] );
+#if FAST_MATH
+ store[0] = util_fast_exp2( store[0] );
+ store[1] = util_fast_exp2( store[1] );
+ store[2] = util_fast_exp2( store[2] );
+ store[3] = util_fast_exp2( store[3] );
+#else
+ store[0] = powf( 2.0f, store[0] );
+ store[1] = powf( 2.0f, store[1] );
+ store[2] = powf( 2.0f, store[2] );
+ store[3] = powf( 2.0f, store[3] );
+#endif
}
static void
@@ -607,12 +661,10 @@ static void PIPE_CDECL
flr4f(
float *store )
{
- const unsigned X = 0;
-
- store[X + 0] = floorf( store[X + 0] );
- store[X + 1] = floorf( store[X + 1] );
- store[X + 2] = floorf( store[X + 2] );
- store[X + 3] = floorf( store[X + 3] );
+ store[0] = floorf( store[0] );
+ store[1] = floorf( store[1] );
+ store[2] = floorf( store[2] );
+ store[3] = floorf( store[3] );
}
static void
@@ -630,12 +682,10 @@ static void PIPE_CDECL
frc4f(
float *store )
{
- const unsigned X = 0;
-
- store[X + 0] -= floorf( store[X + 0] );
- store[X + 1] -= floorf( store[X + 1] );
- store[X + 2] -= floorf( store[X + 2] );
- store[X + 3] -= floorf( store[X + 3] );
+ store[0] -= floorf( store[0] );
+ store[1] -= floorf( store[1] );
+ store[2] -= floorf( store[2] );
+ store[3] -= floorf( store[3] );
}
static void
@@ -653,12 +703,10 @@ static void PIPE_CDECL
lg24f(
float *store )
{
- const unsigned X = 0;
-
- store[X + 0] = LOG2( store[X + 0] );
- store[X + 1] = LOG2( store[X + 1] );
- store[X + 2] = LOG2( store[X + 2] );
- store[X + 3] = LOG2( store[X + 3] );
+ store[0] = util_fast_log2( store[0] );
+ store[1] = util_fast_log2( store[1] );
+ store[2] = util_fast_log2( store[2] );
+ store[3] = util_fast_log2( store[3] );
}
static void
@@ -712,12 +760,17 @@ static void PIPE_CDECL
pow4f(
float *store )
{
- const unsigned X = 0;
-
- store[X + 0] = powf( store[X + 0], store[X + 4] );
- store[X + 1] = powf( store[X + 1], store[X + 5] );
- store[X + 2] = powf( store[X + 2], store[X + 6] );
- store[X + 3] = powf( store[X + 3], store[X + 7] );
+#if FAST_MATH
+ store[0] = util_fast_pow( store[0], store[4] );
+ store[1] = util_fast_pow( store[1], store[5] );
+ store[2] = util_fast_pow( store[2], store[6] );
+ store[3] = util_fast_pow( store[3], store[7] );
+#else
+ store[0] = powf( store[0], store[4] );
+ store[1] = powf( store[1], store[5] );
+ store[2] = powf( store[2], store[6] );
+ store[3] = powf( store[3], store[7] );
+#endif
}
static void
@@ -812,12 +865,10 @@ static void PIPE_CDECL
sin4f(
float *store )
{
- const unsigned X = 0;
-
- store[X + 0] = sinf( store[X + 0] );
- store[X + 1] = sinf( store[X + 1] );
- store[X + 2] = sinf( store[X + 2] );
- store[X + 3] = sinf( store[X + 3] );
+ store[0] = sinf( store[0] );
+ store[1] = sinf( store[1] );
+ store[2] = sinf( store[2] );
+ store[3] = sinf( store[3] );
}
static void
@@ -855,18 +906,21 @@ emit_fetch(
{
unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
- switch( swizzle ) {
+ switch (swizzle) {
case TGSI_EXTSWIZZLE_X:
case TGSI_EXTSWIZZLE_Y:
case TGSI_EXTSWIZZLE_Z:
case TGSI_EXTSWIZZLE_W:
- switch( reg->SrcRegister.File ) {
+ switch (reg->SrcRegister.File) {
case TGSI_FILE_CONSTANT:
emit_const(
func,
xmm,
reg->SrcRegister.Index,
- swizzle );
+ swizzle,
+ reg->SrcRegister.Indirect,
+ reg->SrcRegisterInd.File,
+ reg->SrcRegisterInd.Index );
break;
case TGSI_FILE_IMMEDIATE:
@@ -910,8 +964,8 @@ emit_fetch(
emit_tempf(
func,
xmm,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C );
+ TEMP_ONE_I,
+ TEMP_ONE_C );
break;
default:
@@ -1125,8 +1179,8 @@ emit_setcc(
func,
make_xmm( 0 ),
get_temp(
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C ) );
+ TEMP_ONE_I,
+ TEMP_ONE_C ) );
STORE( func, *inst, 0, 0, chan_index );
}
}
@@ -1172,18 +1226,13 @@ emit_instruction(
{
unsigned chan_index;
- switch( inst->Instruction.Opcode ) {
+ switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_ARL:
-#if 0
- /* XXX this isn't working properly (see glean vertProg1 test) */
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH( func, *inst, 0, 0, chan_index );
emit_f2it( func, 0 );
STORE( func, *inst, 0, 0, chan_index );
}
-#else
- return 0;
-#endif
break;
case TGSI_OPCODE_MOV:
@@ -1200,8 +1249,8 @@ emit_instruction(
emit_tempf(
func,
0,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C);
+ TEMP_ONE_I,
+ TEMP_ONE_C);
if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ) {
STORE( func, *inst, 0, 0, CHAN_X );
}
@@ -1286,11 +1335,73 @@ emit_instruction(
break;
case TGSI_OPCODE_EXP:
- return 0;
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
+ IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ||
+ IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+ FETCH( func, *inst, 0, 0, CHAN_X );
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
+ IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+ emit_MOV( func, 1, 0 );
+ emit_flr( func, 1 );
+ /* dst.x = ex2(floor(src.x)) */
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X )) {
+ emit_MOV( func, 2, 1 );
+ emit_ex2( func, 2 );
+ STORE( func, *inst, 2, 0, CHAN_X );
+ }
+ /* dst.y = src.x - floor(src.x) */
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+ emit_MOV( func, 2, 0 );
+ emit_sub( func, 2, 1 );
+ STORE( func, *inst, 2, 0, CHAN_Y );
+ }
+ }
+ /* dst.z = ex2(src.x) */
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+ emit_ex2( func, 0 );
+ STORE( func, *inst, 0, 0, CHAN_Z );
+ }
+ }
+ /* dst.w = 1.0 */
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W )) {
+ emit_tempf( func, 0, TEMP_ONE_I, TEMP_ONE_C );
+ STORE( func, *inst, 0, 0, CHAN_W );
+ }
break;
case TGSI_OPCODE_LOG:
- return 0;
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
+ IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ||
+ IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+ FETCH( func, *inst, 0, 0, CHAN_X );
+ emit_abs( func, 0 );
+ emit_MOV( func, 1, 0 );
+ emit_lg2( func, 1 );
+ /* dst.z = lg2(abs(src.x)) */
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+ STORE( func, *inst, 1, 0, CHAN_Z );
+ }
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
+ IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+ emit_flr( func, 1 );
+ /* dst.x = floor(lg2(abs(src.x))) */
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X )) {
+ STORE( func, *inst, 1, 0, CHAN_X );
+ }
+ /* dst.x = abs(src)/ex2(floor(lg2(abs(src.x)))) */
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+ emit_ex2( func, 1 );
+ emit_rcp( func, 1, 1 );
+ emit_mul( func, 0, 1 );
+ STORE( func, *inst, 0, 0, CHAN_Y );
+ }
+ }
+ }
+ /* dst.w = 1.0 */
+ if (IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W )) {
+ emit_tempf( func, 0, TEMP_ONE_I, TEMP_ONE_C );
+ STORE( func, *inst, 0, 0, CHAN_W );
+ }
break;
case TGSI_OPCODE_MUL:
@@ -1356,8 +1467,8 @@ emit_instruction(
emit_tempf(
func,
0,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C );
+ TEMP_ONE_I,
+ TEMP_ONE_C );
STORE( func, *inst, 0, 0, CHAN_X );
}
IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
@@ -1560,8 +1671,8 @@ emit_instruction(
emit_tempf(
func,
0,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C );
+ TEMP_ONE_I,
+ TEMP_ONE_C );
STORE( func, *inst, 0, 0, CHAN_W );
}
break;
@@ -1688,8 +1799,8 @@ emit_instruction(
emit_tempf(
func,
0,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C );
+ TEMP_ONE_I,
+ TEMP_ONE_C );
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
STORE( func, *inst, 0, 0, chan_index );
}
@@ -1777,8 +1888,8 @@ emit_instruction(
emit_tempf(
func,
0,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C );
+ TEMP_ONE_I,
+ TEMP_ONE_C );
STORE( func, *inst, 0, 0, CHAN_W );
}
break;
@@ -2127,6 +2238,8 @@ tgsi_emit_sse2(
unsigned ok = 1;
uint num_immediates = 0;
+ util_init_math();
+
func->csr = func->store;
tgsi_parse_init( &parse, tokens );
@@ -2289,3 +2402,4 @@ tgsi_emit_sse2(
}
#endif /* PIPE_ARCH_X86 */
+
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 35cb305..9454563 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -28,6 +28,7 @@
#include "pipe/p_debug.h"
#include "tgsi_text.h"
#include "tgsi_build.h"
+#include "tgsi_info.h"
#include "tgsi_parse.h"
#include "tgsi_sanity.h"
#include "tgsi_util.h"
@@ -50,11 +51,18 @@ static boolean is_digit_alpha_underscore( const char *cur )
return is_digit( cur ) || is_alpha_underscore( cur );
}
+static boolean uprcase( char c )
+{
+ if (c >= 'a' && c <= 'z')
+ return c += 'A' - 'a';
+ return c;
+}
+
static boolean str_match_no_case( const char **pcur, const char *str )
{
const char *cur = *pcur;
- while (*str != '\0' && *str == toupper( *cur )) {
+ while (*str != '\0' && *str == uprcase( *cur )) {
str++;
cur++;
}
@@ -130,7 +138,7 @@ static boolean parse_float( const char **pcur, float *val )
}
if (!integral_part && !fractional_part)
return FALSE;
- if (toupper( *cur ) == 'E') {
+ if (uprcase( *cur ) == 'E') {
cur++;
if (*cur == '-' || *cur == '+')
cur++;
@@ -257,19 +265,19 @@ parse_opt_writemask(
cur++;
*writemask = TGSI_WRITEMASK_NONE;
eat_opt_white( &cur );
- if (toupper( *cur ) == 'X') {
+ if (uprcase( *cur ) == 'X') {
cur++;
*writemask |= TGSI_WRITEMASK_X;
}
- if (toupper( *cur ) == 'Y') {
+ if (uprcase( *cur ) == 'Y') {
cur++;
*writemask |= TGSI_WRITEMASK_Y;
}
- if (toupper( *cur ) == 'Z') {
+ if (uprcase( *cur ) == 'Z') {
cur++;
*writemask |= TGSI_WRITEMASK_Z;
}
- if (toupper( *cur ) == 'W') {
+ if (uprcase( *cur ) == 'W') {
cur++;
*writemask |= TGSI_WRITEMASK_W;
}
@@ -515,13 +523,13 @@ parse_optional_swizzle(
cur++;
eat_opt_white( &cur );
for (i = 0; i < 4; i++) {
- if (toupper( *cur ) == 'X')
+ if (uprcase( *cur ) == 'X')
swizzle[i] = TGSI_SWIZZLE_X;
- else if (toupper( *cur ) == 'Y')
+ else if (uprcase( *cur ) == 'Y')
swizzle[i] = TGSI_SWIZZLE_Y;
- else if (toupper( *cur ) == 'Z')
+ else if (uprcase( *cur ) == 'Z')
swizzle[i] = TGSI_SWIZZLE_Z;
- else if (toupper( *cur ) == 'W')
+ else if (uprcase( *cur ) == 'W')
swizzle[i] = TGSI_SWIZZLE_W;
else {
if (*cur == '0')
@@ -719,138 +727,6 @@ parse_src_operand(
return TRUE;
}
-struct opcode_info
-{
- uint num_dst;
- uint num_src;
- uint is_tex;
- uint is_branch;
- const char *mnemonic;
-};
-
-static const struct opcode_info opcode_info[TGSI_OPCODE_LAST] =
-{
- { 1, 1, 0, 0, "ARL" },
- { 1, 1, 0, 0, "MOV" },
- { 1, 1, 0, 0, "LIT" },
- { 1, 1, 0, 0, "RCP" },
- { 1, 1, 0, 0, "RSQ" },
- { 1, 1, 0, 0, "EXP" },
- { 1, 1, 0, 0, "LOG" },
- { 1, 2, 0, 0, "MUL" },
- { 1, 2, 0, 0, "ADD" },
- { 1, 2, 0, 0, "DP3" },
- { 1, 2, 0, 0, "DP4" },
- { 1, 2, 0, 0, "DST" },
- { 1, 2, 0, 0, "MIN" },
- { 1, 2, 0, 0, "MAX" },
- { 1, 2, 0, 0, "SLT" },
- { 1, 2, 0, 0, "SGE" },
- { 1, 3, 0, 0, "MAD" },
- { 1, 2, 0, 0, "SUB" },
- { 1, 3, 0, 0, "LERP" },
- { 1, 3, 0, 0, "CND" },
- { 1, 3, 0, 0, "CND0" },
- { 1, 3, 0, 0, "DOT2ADD" },
- { 1, 2, 0, 0, "INDEX" },
- { 1, 1, 0, 0, "NEGATE" },
- { 1, 1, 0, 0, "FRAC" },
- { 1, 3, 0, 0, "CLAMP" },
- { 1, 1, 0, 0, "FLOOR" },
- { 1, 1, 0, 0, "ROUND" },
- { 1, 1, 0, 0, "EXPBASE2" },
- { 1, 1, 0, 0, "LOGBASE2" },
- { 1, 2, 0, 0, "POWER" },
- { 1, 2, 0, 0, "CROSSPRODUCT" },
- { 1, 2, 0, 0, "MULTIPLYMATRIX" },
- { 1, 1, 0, 0, "ABS" },
- { 1, 1, 0, 0, "RCC" },
- { 1, 2, 0, 0, "DPH" },
- { 1, 1, 0, 0, "COS" },
- { 1, 1, 0, 0, "DDX" },
- { 1, 1, 0, 0, "DDY" },
- { 0, 1, 0, 0, "KILP" },
- { 1, 1, 0, 0, "PK2H" },
- { 1, 1, 0, 0, "PK2US" },
- { 1, 1, 0, 0, "PK4B" },
- { 1, 1, 0, 0, "PK4UB" },
- { 1, 2, 0, 0, "RFL" },
- { 1, 2, 0, 0, "SEQ" },
- { 1, 2, 0, 0, "SFL" },
- { 1, 2, 0, 0, "SGT" },
- { 1, 1, 0, 0, "SIN" },
- { 1, 2, 0, 0, "SLE" },
- { 1, 2, 0, 0, "SNE" },
- { 1, 2, 0, 0, "STR" },
- { 1, 2, 1, 0, "TEX" },
- { 1, 4, 1, 0, "TXD" },
- { 1, 2, 1, 0, "TXP" },
- { 1, 1, 0, 0, "UP2H" },
- { 1, 1, 0, 0, "UP2US" },
- { 1, 1, 0, 0, "UP4B" },
- { 1, 1, 0, 0, "UP4UB" },
- { 1, 3, 0, 0, "X2D" },
- { 1, 1, 0, 0, "ARA" },
- { 1, 1, 0, 0, "ARR" },
- { 0, 1, 0, 0, "BRA" },
- { 0, 0, 0, 1, "CAL" },
- { 0, 0, 0, 0, "RET" },
- { 1, 1, 0, 0, "SSG" },
- { 1, 3, 0, 0, "CMP" },
- { 1, 1, 0, 0, "SCS" },
- { 1, 2, 1, 0, "TXB" },
- { 1, 1, 0, 0, "NRM" },
- { 1, 2, 0, 0, "DIV" },
- { 1, 2, 0, 0, "DP2" },
- { 1, 2, 1, 0, "TXL" },
- { 0, 0, 0, 0, "BRK" },
- { 0, 1, 0, 1, "IF" },
- { 0, 0, 0, 0, "LOOP" },
- { 0, 1, 0, 0, "REP" },
- { 0, 0, 0, 1, "ELSE" },
- { 0, 0, 0, 0, "ENDIF" },
- { 0, 0, 0, 0, "ENDLOOP" },
- { 0, 0, 0, 0, "ENDREP" },
- { 0, 1, 0, 0, "PUSHA" },
- { 1, 0, 0, 0, "POPA" },
- { 1, 1, 0, 0, "CEIL" },
- { 1, 1, 0, 0, "I2F" },
- { 1, 1, 0, 0, "NOT" },
- { 1, 1, 0, 0, "TRUNC" },
- { 1, 2, 0, 0, "SHL" },
- { 1, 2, 0, 0, "SHR" },
- { 1, 2, 0, 0, "AND" },
- { 1, 2, 0, 0, "OR" },
- { 1, 2, 0, 0, "MOD" },
- { 1, 2, 0, 0, "XOR" },
- { 1, 3, 0, 0, "SAD" },
- { 1, 2, 1, 0, "TXF" },
- { 1, 2, 1, 0, "TXQ" },
- { 0, 0, 0, 0, "CONT" },
- { 0, 0, 0, 0, "EMIT" },
- { 0, 0, 0, 0, "ENDPRIM" },
- { 0, 0, 0, 1, "BGNLOOP2" },
- { 0, 0, 0, 0, "BGNSUB" },
- { 0, 0, 0, 1, "ENDLOOP2" },
- { 0, 0, 0, 0, "ENDSUB" },
- { 1, 1, 0, 0, "NOISE1" },
- { 1, 1, 0, 0, "NOISE2" },
- { 1, 1, 0, 0, "NOISE3" },
- { 1, 1, 0, 0, "NOISE4" },
- { 0, 0, 0, 0, "NOP" },
- { 1, 2, 0, 0, "M4X3" },
- { 1, 2, 0, 0, "M3X4" },
- { 1, 2, 0, 0, "M3X3" },
- { 1, 2, 0, 0, "M3X2" },
- { 1, 1, 0, 0, "NRM4" },
- { 0, 1, 0, 0, "CALLNZ" },
- { 0, 1, 0, 0, "IFC" },
- { 0, 1, 0, 0, "BREAKC" },
- { 0, 0, 0, 0, "KIL" },
- { 0, 0, 0, 0, "END" },
- { 1, 1, 0, 0, "SWZ" }
-};
-
static const char *texture_names[TGSI_TEXTURE_COUNT] =
{
"UNKNOWN",
@@ -871,7 +747,7 @@ parse_instruction(
{
uint i;
uint saturate = TGSI_SAT_NONE;
- const struct opcode_info *info;
+ const struct tgsi_opcode_info *info;
struct tgsi_full_instruction inst;
uint advance;
@@ -881,7 +757,7 @@ parse_instruction(
for (i = 0; i < TGSI_OPCODE_LAST; i++) {
const char *cur = ctx->cur;
- info = &opcode_info[i];
+ info = tgsi_get_opcode_info( i );
if (str_match_no_case( &cur, info->mnemonic )) {
if (str_match_no_case( &cur, "_SATNV" ))
saturate = TGSI_SAT_MINUS_PLUS_ONE;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c
index 357f77b..ea87da3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_transform.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_transform.c
@@ -31,6 +31,7 @@
* Authors: Brian Paul
*/
+#include "pipe/p_debug.h"
#include "tgsi_transform.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.h b/src/gallium/auxiliary/tgsi/tgsi_transform.h
index 3da0b382..a121adb 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_transform.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_transform.h
@@ -29,7 +29,6 @@
#define TGSI_TRANSFORM_H
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_build.h"
diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c
index 09486e6..50101a9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_util.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_util.c
@@ -26,7 +26,6 @@
**************************************************************************/
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_parse.h"
#include "tgsi_build.h"
diff --git a/src/gallium/auxiliary/translate/translate.c b/src/gallium/auxiliary/translate/translate.c
index b93fbf9..7678903 100644
--- a/src/gallium/auxiliary/translate/translate.c
+++ b/src/gallium/auxiliary/translate/translate.c
@@ -31,7 +31,6 @@
*/
#include "pipe/p_config.h"
-#include "pipe/p_util.h"
#include "pipe/p_state.h"
#include "translate.h"
diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h
index c3b754a..650cd81 100644
--- a/src/gallium/auxiliary/translate/translate.h
+++ b/src/gallium/auxiliary/translate/translate.h
@@ -57,7 +57,7 @@ struct translate_element
struct translate_key {
unsigned output_stride;
unsigned nr_elements;
- struct translate_element element[PIPE_MAX_ATTRIBS];
+ struct translate_element element[PIPE_MAX_ATTRIBS + 1];
};
diff --git a/src/gallium/auxiliary/translate/translate_cache.c b/src/gallium/auxiliary/translate/translate_cache.c
index 115dc92..d8069a1 100644
--- a/src/gallium/auxiliary/translate/translate_cache.c
+++ b/src/gallium/auxiliary/translate/translate_cache.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_state.h"
#include "translate.h"
#include "translate_cache.h"
diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c
index 4c8179f..8d39b64 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_state.h"
#include "translate.h"
@@ -415,6 +415,12 @@ static fetch_func get_fetch_func( enum pipe_format format )
static emit_func get_emit_func( enum pipe_format format )
{
+ /* silence warnings */
+ (void) emit_R32G32B32A32_FIXED;
+ (void) emit_R32G32B32_FIXED;
+ (void) emit_R32G32_FIXED;
+ (void) emit_R32_FIXED;
+
switch (format) {
case PIPE_FORMAT_R64_FLOAT:
return &emit_R64_FLOAT;
diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c
index 18a212a..7955186 100644
--- a/src/gallium/auxiliary/translate/translate_sse.c
+++ b/src/gallium/auxiliary/translate/translate_sse.c
@@ -28,7 +28,7 @@
#include "pipe/p_config.h"
#include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "util/u_simple_list.h"
#include "translate.h"
diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile
index db3d810..d3951e4 100644
--- a/src/gallium/auxiliary/util/Makefile
+++ b/src/gallium/auxiliary/util/Makefile
@@ -5,17 +5,21 @@ LIBNAME = util
C_SOURCES = \
p_debug.c \
- p_tile.c \
- p_util.c \
u_blit.c \
u_draw_quad.c \
u_gen_mipmap.c \
u_handle_table.c \
u_hash_table.c \
+ u_math.c \
u_mm.c \
+ u_rect.c \
u_simple_shaders.c \
u_snprintf.c \
- u_time.c
+ u_stream_stdc.c \
+ u_stream_wd.c \
+ u_tile.c \
+ u_time.c \
+ u_timed_winsys.c
include ../../Makefile.template
diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript
index 0309de1..e65c17b 100644
--- a/src/gallium/auxiliary/util/SConscript
+++ b/src/gallium/auxiliary/util/SConscript
@@ -6,16 +6,19 @@ util = env.ConvenienceLibrary(
'p_debug.c',
'p_debug_mem.c',
'p_debug_prof.c',
- 'p_tile.c',
- 'p_util.c',
'u_blit.c',
'u_draw_quad.c',
'u_gen_mipmap.c',
'u_handle_table.c',
'u_hash_table.c',
+ 'u_math.c',
'u_mm.c',
+ 'u_rect.c',
'u_simple_shaders.c',
'u_snprintf.c',
+ 'u_stream_stdc.c',
+ 'u_stream_wd.c',
+ 'u_tile.c',
'u_time.c',
])
diff --git a/src/gallium/auxiliary/util/p_debug.c b/src/gallium/auxiliary/util/p_debug.c
index 2c2f2f8..b6cff28 100644
--- a/src/gallium/auxiliary/util/p_debug.c
+++ b/src/gallium/auxiliary/util/p_debug.c
@@ -51,12 +51,15 @@
#endif
#include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
#include "pipe/p_debug.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
#include "util/u_string.h"
+#include "util/u_stream.h"
+#include "util/u_math.h"
+#include "util/u_tile.h"
#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
@@ -77,7 +80,7 @@ void _debug_vprintf(const char *format, va_list ap)
/* EngDebugPrint does not handle float point arguments, so we need to use
* our own vsnprintf implementation. It is also very slow, so buffer until
* we find a newline. */
- static char buf[512 + 1] = {'\0'};
+ static char buf[512] = {'\0'};
size_t len = strlen(buf);
int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
@@ -585,4 +588,109 @@ error2:
error1:
;
}
+
+
+#pragma pack(push,2)
+struct bmp_file_header {
+ uint16_t bfType;
+ uint32_t bfSize;
+ uint16_t bfReserved1;
+ uint16_t bfReserved2;
+ uint32_t bfOffBits;
+};
+#pragma pack(pop)
+
+struct bmp_info_header {
+ uint32_t biSize;
+ int32_t biWidth;
+ int32_t biHeight;
+ uint16_t biPlanes;
+ uint16_t biBitCount;
+ uint32_t biCompression;
+ uint32_t biSizeImage;
+ int32_t biXPelsPerMeter;
+ int32_t biYPelsPerMeter;
+ uint32_t biClrUsed;
+ uint32_t biClrImportant;
+};
+
+struct bmp_rgb_quad {
+ uint8_t rgbBlue;
+ uint8_t rgbGreen;
+ uint8_t rgbRed;
+ uint8_t rgbAlpha;
+};
+
+void
+debug_dump_surface_bmp(const char *filename,
+ struct pipe_surface *surface)
+{
+ struct util_stream *stream;
+ unsigned surface_usage;
+ struct bmp_file_header bmfh;
+ struct bmp_info_header bmih;
+ float *rgba;
+ unsigned x, y;
+
+ if (!surface)
+ goto error1;
+
+ rgba = MALLOC(surface->width*4*sizeof(float));
+ if(!rgba)
+ goto error1;
+
+ bmfh.bfType = 0x4d42;
+ bmfh.bfSize = 14 + 40 + surface->height*surface->width*4;
+ bmfh.bfReserved1 = 0;
+ bmfh.bfReserved2 = 0;
+ bmfh.bfOffBits = 14 + 40;
+
+ bmih.biSize = 40;
+ bmih.biWidth = surface->width;
+ bmih.biHeight = surface->height;
+ bmih.biPlanes = 1;
+ bmih.biBitCount = 32;
+ bmih.biCompression = 0;
+ bmih.biSizeImage = surface->height*surface->width*4;
+ bmih.biXPelsPerMeter = 0;
+ bmih.biYPelsPerMeter = 0;
+ bmih.biClrUsed = 0;
+ bmih.biClrImportant = 0;
+
+ stream = util_stream_create(filename, bmfh.bfSize);
+ if(!stream)
+ goto error2;
+
+ util_stream_write(stream, &bmfh, 14);
+ util_stream_write(stream, &bmih, 40);
+
+ /* XXX: force mappable surface */
+ surface_usage = surface->usage;
+ surface->usage |= PIPE_BUFFER_USAGE_CPU_READ;
+
+ y = surface->height;
+ while(y--) {
+ pipe_get_tile_rgba(surface,
+ 0, y, surface->width, 1,
+ rgba);
+ for(x = 0; x < surface->width; ++x)
+ {
+ struct bmp_rgb_quad pixel;
+ pixel.rgbRed = float_to_ubyte(rgba[x*4 + 0]);
+ pixel.rgbGreen = float_to_ubyte(rgba[x*4 + 1]);
+ pixel.rgbBlue = float_to_ubyte(rgba[x*4 + 2]);
+ pixel.rgbAlpha = float_to_ubyte(rgba[x*4 + 3]);
+ util_stream_write(stream, &pixel, 4);
+ }
+ }
+
+ surface->usage = surface_usage;
+
+ util_stream_close(stream);
+error2:
+ FREE(rgba);
+error1:
+ ;
+}
+
#endif
diff --git a/src/gallium/auxiliary/util/p_util.c b/src/gallium/auxiliary/util/p_util.c
deleted file mode 100644
index 271be4e..0000000
--- a/src/gallium/auxiliary/util/p_util.c
+++ /dev/null
@@ -1,150 +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.
- *
- **************************************************************************/
-
-/**
- * Miscellaneous utility functions.
- */
-
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_format.h"
-
-
-/**
- * Copy 2D rect from one place to another.
- * Position and sizes are in pixels.
- * src_pitch may be negative to do vertical flip of pixels from source.
- */
-void
-pipe_copy_rect(ubyte * dst,
- const struct pipe_format_block *block,
- unsigned dst_stride,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- const ubyte * src,
- int src_stride,
- unsigned src_x,
- int src_y)
-{
- unsigned i;
- int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
-
- assert(block->size > 0);
- assert(block->width > 0);
- assert(block->height > 0);
- assert(src_x >= 0);
- assert(src_y >= 0);
- assert(dst_x >= 0);
- assert(dst_y >= 0);
-
- dst_x /= block->width;
- dst_y /= block->height;
- width = (width + block->width - 1)/block->width;
- height = (height + block->height - 1)/block->height;
- src_x /= block->width;
- src_y /= block->height;
-
- dst += dst_x * block->size;
- src += src_x * block->size;
- dst += dst_y * dst_stride;
- src += src_y * src_stride_pos;
- width *= block->size;
-
- if (width == dst_stride && width == src_stride)
- memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- memcpy(dst, src, width);
- dst += dst_stride;
- src += src_stride;
- }
- }
-}
-
-void
-pipe_fill_rect(ubyte * dst,
- const struct pipe_format_block *block,
- unsigned dst_stride,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- uint32_t value)
-{
- unsigned i, j;
- unsigned width_size;
-
- assert(block->size > 0);
- assert(block->width > 0);
- assert(block->height > 0);
- assert(dst_x >= 0);
- assert(dst_y >= 0);
-
- dst_x /= block->width;
- dst_y /= block->height;
- width = (width + block->width - 1)/block->width;
- height = (height + block->height - 1)/block->height;
-
- dst += dst_x * block->size;
- dst += dst_y * dst_stride;
- width_size = width * block->size;
-
- switch (block->size) {
- case 1:
- if(dst_stride == width_size)
- memset(dst, (ubyte) value, height * width_size);
- else {
- for (i = 0; i < height; i++) {
- memset(dst, (ubyte) value, width_size);
- dst += dst_stride;
- }
- }
- break;
- case 2:
- for (i = 0; i < height; i++) {
- uint16_t *row = (uint16_t *)dst;
- for (j = 0; j < width; j++)
- *row++ = (uint16_t) value;
- dst += dst_stride;
- }
- break;
- case 4:
- for (i = 0; i < height; i++) {
- uint32_t *row = (uint32_t *)dst;
- for (j = 0; j < width; j++)
- *row++ = value;
- dst += dst_stride;
- }
- break;
- default:
- assert(0);
- break;
- }
-}
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index ae087df..9adf729 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -37,12 +37,13 @@
#include "pipe/p_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_shader_tokens.h"
-#include "util/u_draw_quad.h"
#include "util/u_blit.h"
+#include "util/u_draw_quad.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
#include "cso_cache/cso_context.h"
@@ -137,10 +138,10 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
/* fragment shader */
ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader);
- ctx->vbuf = pipe->winsys->buffer_create(pipe->winsys,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
- sizeof(ctx->vertices));
+ ctx->vbuf = pipe_buffer_create(pipe->screen,
+ 32,
+ PIPE_BUFFER_USAGE_VERTEX,
+ sizeof(ctx->vertices));
if (!ctx->vbuf) {
FREE(ctx);
ctx->pipe->delete_fs_state(ctx->pipe, ctx->fs);
@@ -173,7 +174,7 @@ util_destroy_blit(struct blit_state *ctx)
FREE((void*) ctx->vert_shader.tokens);
FREE((void*) ctx->frag_shader.tokens);
- pipe->winsys->buffer_destroy(pipe->winsys, ctx->vbuf);
+ pipe_buffer_reference(pipe->screen, &ctx->vbuf, NULL);
FREE(ctx);
}
@@ -213,12 +214,12 @@ setup_vertex_data(struct blit_state *ctx,
ctx->vertices[3][1][0] = 0.0f;
ctx->vertices[3][1][1] = 1.0f;
- buf = ctx->pipe->winsys->buffer_map(ctx->pipe->winsys, ctx->vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(buf, ctx->vertices, sizeof(ctx->vertices));
- ctx->pipe->winsys->buffer_unmap(ctx->pipe->winsys, ctx->vbuf);
+ pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
}
@@ -258,12 +259,12 @@ setup_vertex_data_tex(struct blit_state *ctx,
ctx->vertices[3][1][0] = s0;
ctx->vertices[3][1][1] = t1;
- buf = ctx->pipe->winsys->buffer_map(ctx->pipe->winsys, ctx->vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(buf, ctx->vertices, sizeof(ctx->vertices));
- ctx->pipe->winsys->buffer_unmap(ctx->pipe->winsys, ctx->vbuf);
+ pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
}
/**
* Copy pixel block from src surface to dst surface.
diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c
index bf143815..8ecae71 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.c
+++ b/src/gallium/auxiliary/util/u_draw_quad.c
@@ -86,11 +86,11 @@ util_draw_texquad(struct pipe_context *pipe,
vertexBytes = 4 * (4 * numAttribs * sizeof(float));
/* XXX create one-time */
- vbuf = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_VERTEX, vertexBytes);
+ vbuf = pipe_buffer_create(pipe->screen, 32,
+ PIPE_BUFFER_USAGE_VERTEX, vertexBytes);
if (vbuf) {
- float *v = (float *) pipe->winsys->buffer_map(pipe->winsys, vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ float *v = (float *) pipe_buffer_map(pipe->screen, vbuf,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
if (v) {
/*
* Load vertex buffer
@@ -123,10 +123,10 @@ util_draw_texquad(struct pipe_context *pipe,
v[28] = 0.0;
v[29] = 1.0;
- pipe->winsys->buffer_unmap(pipe->winsys, vbuf);
+ pipe_buffer_unmap(pipe->screen, vbuf);
util_draw_vertex_buffer(pipe, vbuf, PIPE_PRIM_TRIANGLE_FAN, 4, 2);
}
- pipe_buffer_reference(pipe->winsys, &vbuf, NULL);
+ pipe_buffer_reference(pipe->screen, &vbuf, NULL);
}
}
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 8713ff5..b19a649 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -37,10 +37,10 @@
#include "pipe/p_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_memory.h"
#include "util/u_draw_quad.h"
#include "util/u_gen_mipmap.h"
#include "util/u_simple_shaders.h"
@@ -580,7 +580,6 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
{
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_winsys *winsys = pipe->winsys;
const uint zslice = 0;
uint dstLevel;
@@ -595,19 +594,19 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
PIPE_BUFFER_USAGE_CPU_WRITE);
- srcMap = ((ubyte *) winsys->buffer_map(winsys, srcSurf->buffer,
- PIPE_BUFFER_USAGE_CPU_READ)
+ srcMap = ((ubyte *) pipe_buffer_map(screen, srcSurf->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ)
+ srcSurf->offset);
- dstMap = ((ubyte *) winsys->buffer_map(winsys, dstSurf->buffer,
- PIPE_BUFFER_USAGE_CPU_WRITE)
+ dstMap = ((ubyte *) pipe_buffer_map(screen, dstSurf->buffer,
+ PIPE_BUFFER_USAGE_CPU_WRITE)
+ dstSurf->offset);
reduce_1d(pt->format,
srcSurf->width, srcMap,
dstSurf->width, dstMap);
- winsys->buffer_unmap(winsys, srcSurf->buffer);
- winsys->buffer_unmap(winsys, dstSurf->buffer);
+ pipe_buffer_unmap(screen, srcSurf->buffer);
+ pipe_buffer_unmap(screen, dstSurf->buffer);
pipe_surface_reference(&srcSurf, NULL);
pipe_surface_reference(&dstSurf, NULL);
@@ -622,7 +621,6 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
{
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_winsys *winsys = pipe->winsys;
const uint zslice = 0;
uint dstLevel;
@@ -639,11 +637,11 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
PIPE_BUFFER_USAGE_CPU_WRITE);
- srcMap = ((ubyte *) winsys->buffer_map(winsys, srcSurf->buffer,
- PIPE_BUFFER_USAGE_CPU_READ)
+ srcMap = ((ubyte *) pipe_buffer_map(screen, srcSurf->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ)
+ srcSurf->offset);
- dstMap = ((ubyte *) winsys->buffer_map(winsys, dstSurf->buffer,
- PIPE_BUFFER_USAGE_CPU_WRITE)
+ dstMap = ((ubyte *) pipe_buffer_map(screen, dstSurf->buffer,
+ PIPE_BUFFER_USAGE_CPU_WRITE)
+ dstSurf->offset);
reduce_2d(pt->format,
@@ -652,8 +650,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
dstSurf->width, dstSurf->height,
dstSurf->stride, dstMap);
- winsys->buffer_unmap(winsys, srcSurf->buffer);
- winsys->buffer_unmap(winsys, dstSurf->buffer);
+ pipe_buffer_unmap(screen, srcSurf->buffer);
+ pipe_buffer_unmap(screen, dstSurf->buffer);
pipe_surface_reference(&srcSurf, NULL);
pipe_surface_reference(&dstSurf, NULL);
@@ -759,10 +757,10 @@ util_create_gen_mipmap(struct pipe_context *pipe,
/* fragment shader */
ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader);
- ctx->vbuf = pipe->winsys->buffer_create(pipe->winsys,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
- sizeof(ctx->vertices));
+ ctx->vbuf = pipe_buffer_create(pipe->screen,
+ 32,
+ PIPE_BUFFER_USAGE_VERTEX,
+ sizeof(ctx->vertices));
if (!ctx->vbuf) {
FREE(ctx);
return NULL;
@@ -805,12 +803,12 @@ set_vertex_data(struct gen_mipmap_state *ctx, float width, float height)
ctx->vertices[3][1][0] = 0.0f;
ctx->vertices[3][1][1] = 1.0f;
- buf = ctx->pipe->winsys->buffer_map(ctx->pipe->winsys, ctx->vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(buf, ctx->vertices, sizeof(ctx->vertices));
- ctx->pipe->winsys->buffer_unmap(ctx->pipe->winsys, ctx->vbuf);
+ pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
}
@@ -829,7 +827,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
FREE((void*) ctx->vert_shader.tokens);
FREE((void*) ctx->frag_shader.tokens);
- pipe->winsys->buffer_destroy(pipe->winsys, ctx->vbuf);
+ pipe_buffer_reference(pipe->screen, &ctx->vbuf, NULL);
FREE(ctx);
}
diff --git a/src/gallium/auxiliary/util/u_handle_table.c b/src/gallium/auxiliary/util/u_handle_table.c
index 2176a00..2c40011 100644
--- a/src/gallium/auxiliary/util/u_handle_table.c
+++ b/src/gallium/auxiliary/util/u_handle_table.c
@@ -35,9 +35,9 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
-#include "u_handle_table.h"
+#include "util/u_memory.h"
+#include "util/u_handle_table.h"
#define HANDLE_TABLE_INITIAL_SIZE 16
diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c
index dd5eca7..0bc8de9 100644
--- a/src/gallium/auxiliary/util/u_hash_table.c
+++ b/src/gallium/auxiliary/util/u_hash_table.c
@@ -40,10 +40,11 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
#include "cso_cache/cso_hash.h"
-#include "u_hash_table.h"
+
+#include "util/u_memory.h"
+#include "util/u_hash_table.h"
struct hash_table
diff --git a/src/gallium/drivers/trace/tr_stream.h b/src/gallium/auxiliary/util/u_math.c
index d50fed2..0729114 100644
--- a/src/gallium/drivers/trace/tr_stream.h
+++ b/src/gallium/auxiliary/util/u_math.c
@@ -1,20 +1,20 @@
/**************************************************************************
- *
+ *
* 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 streams (the
+ * copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT 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,31 +22,39 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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
- * Cross-platform sequential access stream abstraction.
- */
-#ifndef TR_STREAM_H
-#define TR_STREAM_H
+
+#include "util/u_math.h"
-#include "pipe/p_compiler.h"
-struct trace_stream;
+float pow2_table[POW2_TABLE_SIZE];
-struct trace_stream *
-trace_stream_create(const char *name, const char *ext);
+static void
+init_pow2_table(void)
+{
+ int i;
+ for (i = 0; i < POW2_TABLE_SIZE; i++) {
+ pow2_table[i] = (float) pow(2.0, i / POW2_TABLE_SCALE);
+ }
+}
-boolean
-trace_stream_write(struct trace_stream *stream, const void *data, size_t size);
+/**
+ * One time init for math utilities.
+ */
void
-trace_stream_close(struct trace_stream *stream);
+util_init_math(void)
+{
+ static boolean initialized = FALSE;
+ if (!initialized) {
+ init_pow2_table();
+ initialized = TRUE;
+ }
+}
-#endif /* TR_STREAM_H */
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
new file mode 100644
index 0000000..9b4ca39
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -0,0 +1,438 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+
+/**
+ * Math utilities and approximations for common math functions.
+ * Reduced precision is usually acceptable in shaders...
+ *
+ * "fast" is used in the names of functions which are low-precision,
+ * or at least lower-precision than the normal C lib functions.
+ */
+
+
+#ifndef U_MATH_H
+#define U_MATH_H
+
+
+#include "pipe/p_compiler.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+__inline double ceil(double val)
+{
+ double ceil_val;
+
+ if((val - (long) val) == 0) {
+ ceil_val = val;
+ }
+ else {
+ if(val > 0) {
+ ceil_val = (long) val + 1;
+ }
+ else {
+ ceil_val = (long) val;
+ }
+ }
+
+ return ceil_val;
+}
+
+#ifndef PIPE_SUBSYSTEM_WINDOWS_CE
+__inline double floor(double val)
+{
+ double floor_val;
+
+ if((val - (long) val) == 0) {
+ floor_val = val;
+ }
+ else {
+ if(val > 0) {
+ floor_val = (long) val;
+ }
+ else {
+ floor_val = (long) val - 1;
+ }
+ }
+
+ return floor_val;
+}
+#endif
+
+#pragma function(pow)
+__inline double __cdecl pow(double val, double exponent)
+{
+ /* XXX */
+ assert(0);
+ return 0;
+}
+
+#pragma function(log)
+__inline double __cdecl log(double val)
+{
+ /* XXX */
+ assert(0);
+ return 0;
+}
+
+#pragma function(atan2)
+__inline double __cdecl atan2(double val)
+{
+ /* XXX */
+ assert(0);
+ return 0;
+}
+#else
+#include <math.h>
+#include <stdarg.h>
+#endif
+
+
+#if defined(_MSC_VER)
+#if _MSC_VER < 1400 && !defined(__cplusplus) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+
+static INLINE float cosf( float f )
+{
+ return (float) cos( (double) f );
+}
+
+static INLINE float sinf( float f )
+{
+ return (float) sin( (double) f );
+}
+
+static INLINE float ceilf( float f )
+{
+ return (float) ceil( (double) f );
+}
+
+static INLINE float floorf( float f )
+{
+ return (float) floor( (double) f );
+}
+
+static INLINE float powf( float f, float g )
+{
+ return (float) pow( (double) f, (double) g );
+}
+
+static INLINE float sqrtf( float f )
+{
+ return (float) sqrt( (double) f );
+}
+
+static INLINE float fabsf( float f )
+{
+ return (float) fabs( (double) f );
+}
+
+static INLINE float logf( float f )
+{
+ return (float) log( (double) f );
+}
+
+#else
+/* Work-around an extra semi-colon in VS 2005 logf definition */
+#ifdef logf
+#undef logf
+#define logf(x) ((float)log((double)(x)))
+#endif /* logf */
+#endif
+#endif /* _MSC_VER */
+
+
+
+
+
+#define POW2_TABLE_SIZE 256
+#define POW2_TABLE_SCALE ((float) (POW2_TABLE_SIZE-1))
+extern float pow2_table[POW2_TABLE_SIZE];
+
+
+
+extern void
+util_init_math(void);
+
+
+union fi {
+ float f;
+ int i;
+ unsigned ui;
+};
+
+
+/**
+ * Fast approximation to exp(x).
+ * Compute with base 2 exponents: exp(x) = exp2(log2(e) * x)
+ * Note: log2(e) is a constant, k = 1.44269
+ * So, exp(x) = exp2(k * x);
+ * Identity: exp2(a + b) = exp2(a) * exp2(b)
+ * Let ipart = int(k*x)
+ * Let fpart = k*x - ipart;
+ * So, exp2(k*x) = exp2(ipart) * exp2(fpart)
+ * Compute exp2(ipart) with i << ipart
+ * Compute exp2(fpart) with lookup table.
+ */
+static INLINE float
+util_fast_exp(float x)
+{
+ if (x >= 0.0f) {
+ float k = 1.44269f; /* = log2(e) */
+ float kx = k * x;
+ int ipart = (int) kx;
+ float fpart = kx - (float) ipart;
+ float y = (float) (1 << ipart)
+ * pow2_table[(int) (fpart * POW2_TABLE_SCALE)];
+ return y;
+ }
+ else {
+ /* exp(-x) = 1.0 / exp(x) */
+ float k = -1.44269f;
+ float kx = k * x;
+ int ipart = (int) kx;
+ float fpart = kx - (float) ipart;
+ float y = (float) (1 << ipart)
+ * pow2_table[(int) (fpart * POW2_TABLE_SCALE)];
+ return 1.0f / y;
+ }
+}
+
+
+/**
+ * Fast version of 2^x
+ * XXX the above function could be implemented in terms of this one.
+ */
+static INLINE float
+util_fast_exp2(float x)
+{
+ if (x >= 0.0f) {
+ int ipart = (int) x;
+ float fpart = x - (float) ipart;
+ float y = (float) (1 << ipart)
+ * pow2_table[(int) (fpart * POW2_TABLE_SCALE)];
+ return y;
+ }
+ else {
+ /* exp(-x) = 1.0 / exp(x) */
+ int ipart = (int) -x;
+ float fpart = -x - (float) ipart;
+ float y = (float) (1 << ipart)
+ * pow2_table[(int) (fpart * POW2_TABLE_SCALE)];
+ return 1.0f / y;
+ }
+}
+
+
+/**
+ * Based on code from http://www.flipcode.com/totd/
+ */
+static INLINE float
+util_fast_log2(float val)
+{
+ union fi num;
+ int log_2;
+ num.f = val;
+ log_2 = ((num.i >> 23) & 255) - 128;
+ num.i &= ~(255 << 23);
+ num.i += 127 << 23;
+ num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
+ return num.f + log_2;
+}
+
+
+static INLINE float
+util_fast_pow(float x, float y)
+{
+ /* XXX this test may need adjustment */
+ if (y >= 3.0 && -0.02f <= x && x <= 0.02f)
+ return 0.0f;
+ return util_fast_exp2(util_fast_log2(x) * y);
+}
+
+
+
+/**
+ * Floor(x), returned as int.
+ */
+static INLINE int
+util_ifloor(float f)
+{
+ int ai, bi;
+ double af, bf;
+ union fi u;
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ u.f = (float) af; ai = u.i;
+ u.f = (float) bf; bi = u.i;
+ return (ai - bi) >> 1;
+}
+
+
+/**
+ * Round float to nearest int.
+ */
+static INLINE int
+util_iround(float f)
+{
+#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
+ int r;
+ __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
+ return r;
+#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
+ int r;
+ _asm {
+ fld f
+ fistp r
+ }
+ return r;
+#else
+ if (f >= 0.0f)
+ return (int) (f + 0.5f);
+ else
+ return (int) (f - 0.5f);
+#endif
+}
+
+
+
+#if defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
+/**
+ * Find first bit set in word. Least significant bit is 1.
+ * Return 0 if no bits set.
+ */
+static INLINE
+unsigned ffs( unsigned u )
+{
+ unsigned i;
+
+ if( u == 0 ) {
+ return 0;
+ }
+
+ __asm bsf eax, [u]
+ __asm inc eax
+ __asm mov [i], eax
+
+ return i;
+}
+#endif
+
+
+/**
+ * Return float bits.
+ */
+static INLINE unsigned
+fui( float f )
+{
+ union fi fi;
+ fi.f = f;
+ return fi.ui;
+}
+
+
+
+static INLINE float
+ubyte_to_float(ubyte ub)
+{
+ return (float) ub * (1.0f / 255.0f);
+}
+
+
+/**
+ * Convert float in [0,1] to ubyte in [0,255] with clamping.
+ */
+static INLINE ubyte
+float_to_ubyte(float f)
+{
+ const int ieee_0996 = 0x3f7f0000; /* 0.996 or so */
+ union fi tmp;
+
+ tmp.f = f;
+ if (tmp.i < 0) {
+ return (ubyte) 0;
+ }
+ else if (tmp.i >= ieee_0996) {
+ return (ubyte) 255;
+ }
+ else {
+ tmp.f = tmp.f * (255.0f/256.0f) + 32768.0f;
+ return (ubyte) tmp.i;
+ }
+}
+
+
+
+#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
+
+#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
+#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
+
+
+static INLINE int
+align(int value, int alignment)
+{
+ return (value + alignment - 1) & ~(alignment - 1);
+}
+
+
+#ifndef COPY_4V
+#define COPY_4V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+ (DST)[3] = (SRC)[3]; \
+} while (0)
+#endif
+
+
+#ifndef COPY_4FV
+#define COPY_4FV( DST, SRC ) COPY_4V(DST, SRC)
+#endif
+
+
+#ifndef ASSIGN_4V
+#define ASSIGN_4V( DST, V0, V1, V2, V3 ) \
+do { \
+ (DST)[0] = (V0); \
+ (DST)[1] = (V1); \
+ (DST)[2] = (V2); \
+ (DST)[3] = (V3); \
+} while (0)
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* U_MATH_H */
diff --git a/src/gallium/auxiliary/util/u_memory.h b/src/gallium/auxiliary/util/u_memory.h
new file mode 100644
index 0000000..8571027
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_memory.h
@@ -0,0 +1,232 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+
+/**
+ * Memory functions
+ */
+
+
+#ifndef U_MEMORY_H
+#define U_MEMORY_H
+
+
+#include "util/u_pointer.h"
+#include "pipe/p_debug.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Define ENOMEM for WINCE */
+#if (_WIN32_WCE < 600)
+#ifndef ENOMEM
+#define ENOMEM 12
+#endif
+#endif
+
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG)
+
+/* memory debugging */
+
+#include "pipe/p_debug.h"
+
+#define MALLOC( _size ) \
+ debug_malloc( __FILE__, __LINE__, __FUNCTION__, _size )
+#define CALLOC( _count, _size ) \
+ debug_calloc(__FILE__, __LINE__, __FUNCTION__, _count, _size )
+#define FREE( _ptr ) \
+ debug_free( __FILE__, __LINE__, __FUNCTION__, _ptr )
+#define REALLOC( _ptr, _old_size, _size ) \
+ debug_realloc( __FILE__, __LINE__, __FUNCTION__, _ptr, _old_size, _size )
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+
+void * __stdcall
+EngAllocMem(
+ unsigned long Flags,
+ unsigned long MemSize,
+ unsigned long Tag );
+
+void __stdcall
+EngFreeMem(
+ void *Mem );
+
+#define MALLOC( _size ) EngAllocMem( 0, _size, 'D3AG' )
+#define _FREE( _ptr ) EngFreeMem( _ptr )
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+
+void *
+ExAllocatePool(
+ unsigned long PoolType,
+ size_t NumberOfBytes);
+
+void
+ExFreePool(void *P);
+
+#define MALLOC(_size) ExAllocatePool(0, _size)
+#define _FREE(_ptr) ExFreePool(_ptr)
+
+#else
+
+#define MALLOC( SIZE ) malloc( SIZE )
+#define CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
+#define FREE( PTR ) free( PTR )
+#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE ) realloc( OLDPTR, NEWSIZE )
+
+#endif
+
+
+#ifndef CALLOC
+static INLINE void *
+CALLOC( unsigned count, unsigned size )
+{
+ void *ptr = MALLOC( count * size );
+ if( ptr ) {
+ memset( ptr, 0, count * size );
+ }
+ return ptr;
+}
+#endif /* !CALLOC */
+
+#ifndef FREE
+static INLINE void
+FREE( void *ptr )
+{
+ if( ptr ) {
+ _FREE( ptr );
+ }
+}
+#endif /* !FREE */
+
+#ifndef REALLOC
+static INLINE void *
+REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
+{
+ void *new_ptr = NULL;
+
+ if (new_size != 0) {
+ unsigned copy_size = old_size < new_size ? old_size : new_size;
+ new_ptr = MALLOC( new_size );
+ if (new_ptr && old_ptr && copy_size) {
+ memcpy( new_ptr, old_ptr, copy_size );
+ }
+ }
+
+ FREE( old_ptr );
+ return new_ptr;
+}
+#endif /* !REALLOC */
+
+
+#define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))
+
+#define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T))
+
+
+/**
+ * Return memory on given byte alignment
+ */
+static INLINE void *
+align_malloc(size_t bytes, uint alignment)
+{
+#if defined(HAVE_POSIX_MEMALIGN)
+ void *mem;
+ alignment = (alignment + (uint)sizeof(void*) - 1) & ~((uint)sizeof(void*) - 1);
+ if(posix_memalign(& mem, alignment, bytes) != 0)
+ return NULL;
+ return mem;
+#else
+ char *ptr, *buf;
+
+ assert( alignment > 0 );
+
+ ptr = (char *) MALLOC(bytes + alignment + sizeof(void *));
+ if (!ptr)
+ return NULL;
+
+ buf = (char *) align_pointer( ptr + sizeof(void *), alignment );
+ *(char **)(buf - sizeof(void *)) = ptr;
+
+ return buf;
+#endif /* defined(HAVE_POSIX_MEMALIGN) */
+}
+
+/**
+ * Free memory returned by align_malloc().
+ */
+static INLINE void
+align_free(void *ptr)
+{
+#if defined(HAVE_POSIX_MEMALIGN)
+ FREE(ptr);
+#else
+ void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
+ void *realAddr = *cubbyHole;
+ FREE(realAddr);
+#endif /* defined(HAVE_POSIX_MEMALIGN) */
+}
+
+
+/**
+ * Duplicate a block of memory.
+ */
+static INLINE void *
+mem_dup(const void *src, uint size)
+{
+ void *dup = MALLOC(size);
+ if (dup)
+ memcpy(dup, src, size);
+ return dup;
+}
+
+
+/**
+ * Number of elements in an array.
+ */
+#ifndef Elements
+#define Elements(x) (sizeof(x)/sizeof((x)[0]))
+#endif
+
+
+/**
+ * Offset of a field in a struct, in bytes.
+ */
+#define Offset(TYPE, MEMBER) ((unsigned)&(((TYPE *)NULL)->MEMBER))
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* U_MEMORY_H */
diff --git a/src/gallium/auxiliary/util/u_mm.c b/src/gallium/auxiliary/util/u_mm.c
index b49ae07..0f51dd5 100644
--- a/src/gallium/auxiliary/util/u_mm.c
+++ b/src/gallium/auxiliary/util/u_mm.c
@@ -24,9 +24,9 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
#include "pipe/p_debug.h"
+#include "util/u_memory.h"
#include "util/u_mm.h"
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index 06abb34..e0e8aa8 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -37,6 +37,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
+#include "util/u_math.h"
/**
@@ -141,6 +142,161 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
/**
+ * Unpack RGBA from a packed pixel, returning values as ubytes in [0,255].
+ */
+static INLINE void
+util_unpack_color_ub(enum pipe_format format, const void *src,
+ ubyte *r, ubyte *g, ubyte *b, ubyte *a)
+{
+ switch (format) {
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
+ {
+ uint p = ((const uint *) src)[0];
+ *r = (ubyte) ((p >> 24) & 0xff);
+ *g = (ubyte) ((p >> 16) & 0xff);
+ *b = (ubyte) ((p >> 8) & 0xff);
+ *a = (ubyte) ((p >> 0) & 0xff);
+ }
+ return;
+ case PIPE_FORMAT_R8G8B8X8_UNORM:
+ {
+ uint p = ((const uint *) src)[0];
+ *r = (ubyte) ((p >> 24) & 0xff);
+ *g = (ubyte) ((p >> 16) & 0xff);
+ *b = (ubyte) ((p >> 8) & 0xff);
+ *a = (ubyte) 0xff;
+ }
+ return;
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ {
+ uint p = ((const uint *) src)[0];
+ *r = (ubyte) ((p >> 16) & 0xff);
+ *g = (ubyte) ((p >> 8) & 0xff);
+ *b = (ubyte) ((p >> 0) & 0xff);
+ *a = (ubyte) ((p >> 24) & 0xff);
+ }
+ return;
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ {
+ uint p = ((const uint *) src)[0];
+ *r = (ubyte) ((p >> 16) & 0xff);
+ *g = (ubyte) ((p >> 8) & 0xff);
+ *b = (ubyte) ((p >> 0) & 0xff);
+ *a = (ubyte) 0xff;
+ }
+ return;
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ {
+ uint p = ((const uint *) src)[0];
+ *r = (ubyte) ((p >> 8) & 0xff);
+ *g = (ubyte) ((p >> 16) & 0xff);
+ *b = (ubyte) ((p >> 24) & 0xff);
+ *a = (ubyte) ((p >> 0) & 0xff);
+ }
+ return;
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ {
+ uint p = ((const uint *) src)[0];
+ *r = (ubyte) ((p >> 8) & 0xff);
+ *g = (ubyte) ((p >> 16) & 0xff);
+ *b = (ubyte) ((p >> 24) & 0xff);
+ *a = (ubyte) 0xff;
+ }
+ return;
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ {
+ ushort p = ((const ushort *) src)[0];
+ *r = (ubyte) (((p >> 8) & 0xf8) | ((p >> 13) & 0x7));
+ *g = (ubyte) (((p >> 3) & 0xfc) | ((p >> 9) & 0x3));
+ *b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7));
+ *a = (ubyte) 0xff;
+ }
+ return;
+ case PIPE_FORMAT_A1R5G5B5_UNORM:
+ {
+ ushort p = ((const ushort *) src)[0];
+ *r = (ubyte) (((p >> 7) & 0xf8) | ((p >> 12) & 0x7));
+ *g = (ubyte) (((p >> 2) & 0xf8) | ((p >> 7) & 0x7));
+ *b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7));
+ *a = (ubyte) (0xff * (p >> 15));
+ }
+ return;
+ case PIPE_FORMAT_A4R4G4B4_UNORM:
+ {
+ ushort p = ((const ushort *) src)[0];
+ *r = (ubyte) (((p >> 4) & 0xf0) | ((p >> 8) & 0xf));
+ *g = (ubyte) (((p >> 0) & 0xf0) | ((p >> 4) & 0xf));
+ *b = (ubyte) (((p << 4) & 0xf0) | ((p >> 0) & 0xf));
+ *a = (ubyte) (((p >> 8) & 0xf0) | ((p >> 12) & 0xf));
+ }
+ return;
+ case PIPE_FORMAT_A8_UNORM:
+ {
+ ubyte p = ((const ubyte *) src)[0];
+ *r = *g = *b = (ubyte) 0xff;
+ *a = p;
+ }
+ return;
+ case PIPE_FORMAT_L8_UNORM:
+ {
+ ubyte p = ((const ubyte *) src)[0];
+ *r = *g = *b = p;
+ *a = (ubyte) 0xff;
+ }
+ return;
+ case PIPE_FORMAT_I8_UNORM:
+ {
+ ubyte p = ((const ubyte *) src)[0];
+ *r = *g = *b = *a = p;
+ }
+ return;
+ case PIPE_FORMAT_R32G32B32A32_FLOAT:
+ {
+ const float *p = (const float *) src;
+ *r = float_to_ubyte(p[0]);
+ *g = float_to_ubyte(p[1]);
+ *b = float_to_ubyte(p[2]);
+ *a = float_to_ubyte(p[3]);
+ }
+ return;
+ case PIPE_FORMAT_R32G32B32_FLOAT:
+ {
+ const float *p = (const float *) src;
+ *r = float_to_ubyte(p[0]);
+ *g = float_to_ubyte(p[1]);
+ *b = float_to_ubyte(p[2]);
+ *a = (ubyte) 0xff;
+ }
+ return;
+
+ case PIPE_FORMAT_R32G32_FLOAT:
+ {
+ const float *p = (const float *) src;
+ *r = float_to_ubyte(p[0]);
+ *g = float_to_ubyte(p[1]);
+ *b = *a = (ubyte) 0xff;
+ }
+ return;
+
+ case PIPE_FORMAT_R32_FLOAT:
+ {
+ const float *p = (const float *) src;
+ *r = float_to_ubyte(p[0]);
+ *g = *b = *a = (ubyte) 0xff;
+ }
+ return;
+
+ /* XXX lots more cases to add */
+ default:
+ debug_print_format("gallium: unhandled format in util_unpack_color_ub()",
+ format);
+ assert(0);
+ }
+}
+
+
+
+/**
* Note rgba outside [0,1] will be clamped for int pixel formats.
*/
static INLINE void
@@ -150,10 +306,10 @@ util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
if (pf_size_x(format) <= 8) {
/* format uses 8-bit components or less */
- UNCLAMPED_FLOAT_TO_UBYTE(r, rgba[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(g, rgba[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(b, rgba[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(a, rgba[3]);
+ r = float_to_ubyte(rgba[0]);
+ g = float_to_ubyte(rgba[1]);
+ b = float_to_ubyte(rgba[2]);
+ a = float_to_ubyte(rgba[3]);
}
switch (format) {
@@ -286,4 +442,31 @@ util_pack_z(enum pipe_format format, double z)
}
+/**
+ * Pack 4 ubytes into a 4-byte word
+ */
+static INLINE unsigned
+pack_ub4(ubyte b0, ubyte b1, ubyte b2, ubyte b3)
+{
+ return ((((unsigned int)b0) << 0) |
+ (((unsigned int)b1) << 8) |
+ (((unsigned int)b2) << 16) |
+ (((unsigned int)b3) << 24));
+}
+
+
+/**
+ * Pack/convert 4 floats into one 4-byte word.
+ */
+static INLINE unsigned
+pack_ui32_float4(float a, float b, float c, float d)
+{
+ return pack_ub4( float_to_ubyte(a),
+ float_to_ubyte(b),
+ float_to_ubyte(c),
+ float_to_ubyte(d) );
+}
+
+
+
#endif /* U_PACK_COLOR_H */
diff --git a/src/gallium/include/pipe/p_pointer.h b/src/gallium/auxiliary/util/u_pointer.h
index 3a1e6be..e1af9f1 100644
--- a/src/gallium/include/pipe/p_pointer.h
+++ b/src/gallium/auxiliary/util/u_pointer.h
@@ -25,10 +25,10 @@
*
**************************************************************************/
-#ifndef P_POINTER_H
-#define P_POINTER_H
+#ifndef U_POINTER_H
+#define U_POINTER_H
-#include "p_compiler.h"
+#include "pipe/p_compiler.h"
#ifdef __cplusplus
extern "C" {
@@ -88,8 +88,20 @@ align_pointer( const void *unaligned, uintptr_t alignment )
return uintptr_to_pointer( aligned );
}
+
+/**
+ * Return a pointer aligned to next multiple of 16 bytes.
+ */
+static INLINE void *
+align16( void *unaligned )
+{
+ return align_pointer( unaligned, 16 );
+}
+
+
+
#ifdef __cplusplus
}
#endif
-#endif /* P_POINTER_H */
+#endif /* U_POINTER_H */
diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c
new file mode 100644
index 0000000..f5619ef
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_rect.c
@@ -0,0 +1,328 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+/**
+ * Rectangle-related helper functions.
+ */
+
+
+#include "pipe/p_defines.h"
+#include "pipe/p_format.h"
+#include "pipe/p_context.h"
+#include "pipe/p_screen.h"
+#include "util/u_rect.h"
+
+
+/**
+ * Copy 2D rect from one place to another.
+ * Position and sizes are in pixels.
+ * src_pitch may be negative to do vertical flip of pixels from source.
+ */
+void
+pipe_copy_rect(ubyte * dst,
+ const struct pipe_format_block *block,
+ unsigned dst_stride,
+ unsigned dst_x,
+ unsigned dst_y,
+ unsigned width,
+ unsigned height,
+ const ubyte * src,
+ int src_stride,
+ unsigned src_x,
+ int src_y)
+{
+ unsigned i;
+ int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
+
+ assert(block->size > 0);
+ assert(block->width > 0);
+ assert(block->height > 0);
+ assert(src_x >= 0);
+ assert(src_y >= 0);
+ assert(dst_x >= 0);
+ assert(dst_y >= 0);
+
+ dst_x /= block->width;
+ dst_y /= block->height;
+ width = (width + block->width - 1)/block->width;
+ height = (height + block->height - 1)/block->height;
+ src_x /= block->width;
+ src_y /= block->height;
+
+ dst += dst_x * block->size;
+ src += src_x * block->size;
+ dst += dst_y * dst_stride;
+ src += src_y * src_stride_pos;
+ width *= block->size;
+
+ if (width == dst_stride && width == src_stride)
+ memcpy(dst, src, height * width);
+ else {
+ for (i = 0; i < height; i++) {
+ memcpy(dst, src, width);
+ dst += dst_stride;
+ src += src_stride;
+ }
+ }
+}
+
+void
+pipe_fill_rect(ubyte * dst,
+ const struct pipe_format_block *block,
+ unsigned dst_stride,
+ unsigned dst_x,
+ unsigned dst_y,
+ unsigned width,
+ unsigned height,
+ uint32_t value)
+{
+ unsigned i, j;
+ unsigned width_size;
+
+ assert(block->size > 0);
+ assert(block->width > 0);
+ assert(block->height > 0);
+ assert(dst_x >= 0);
+ assert(dst_y >= 0);
+
+ dst_x /= block->width;
+ dst_y /= block->height;
+ width = (width + block->width - 1)/block->width;
+ height = (height + block->height - 1)/block->height;
+
+ dst += dst_x * block->size;
+ dst += dst_y * dst_stride;
+ width_size = width * block->size;
+
+ switch (block->size) {
+ case 1:
+ if(dst_stride == width_size)
+ memset(dst, (ubyte) value, height * width_size);
+ else {
+ for (i = 0; i < height; i++) {
+ memset(dst, (ubyte) value, width_size);
+ dst += dst_stride;
+ }
+ }
+ break;
+ case 2:
+ for (i = 0; i < height; i++) {
+ uint16_t *row = (uint16_t *)dst;
+ for (j = 0; j < width; j++)
+ *row++ = (uint16_t) value;
+ dst += dst_stride;
+ }
+ break;
+ case 4:
+ for (i = 0; i < height; i++) {
+ uint32_t *row = (uint32_t *)dst;
+ for (j = 0; j < width; j++)
+ *row++ = value;
+ dst += dst_stride;
+ }
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+
+
+/**
+ * Fallback function for pipe->surface_copy().
+ * Note: (X,Y)=(0,0) is always the upper-left corner.
+ * if do_flip, flip the image vertically on its way from src rect to dst rect.
+ * XXX should probably put this in new u_surface.c file...
+ */
+void
+util_surface_copy(struct pipe_context *pipe,
+ boolean do_flip,
+ struct pipe_surface *dst,
+ unsigned dst_x, unsigned dst_y,
+ struct pipe_surface *src,
+ unsigned src_x, unsigned src_y,
+ unsigned w, unsigned h)
+{
+ struct pipe_screen *screen = pipe->screen;
+ struct pipe_surface *new_src = NULL, *new_dst = NULL;
+ 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,
+ src->texture,
+ src->face,
+ src->level,
+ src->zslice,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ src = new_src;
+ }
+
+ 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->texture,
+ dst->face,
+ dst->level,
+ dst->zslice,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ dst = new_dst;
+ }
+
+ 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(src_map);
+ assert(dst_map);
+
+ 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,
+ w, h,
+ src_map,
+ do_flip ? -(int) src->stride : src->stride,
+ src_x, src_y);
+ }
+
+ pipe->screen->surface_unmap(pipe->screen, src);
+ pipe->screen->surface_unmap(pipe->screen, dst);
+
+ if (new_src)
+ screen->tex_surface_release(screen, &new_src);
+ if (new_dst)
+ screen->tex_surface_release(screen, &new_dst);
+}
+
+
+
+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))
+
+
+/**
+ * Fallback for pipe->surface_fill() function.
+ * XXX should probably put this in new u_surface.c file...
+ */
+void
+util_surface_fill(struct pipe_context *pipe,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height, unsigned value)
+{
+ struct pipe_screen *screen = pipe->screen;
+ struct pipe_surface *new_dst = NULL;
+ 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,
+ dst->texture,
+ dst->face,
+ dst->level,
+ dst->zslice,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ dst = new_dst;
+ }
+
+ dst_map = pipe->screen->surface_map(screen,
+ dst, PIPE_BUFFER_USAGE_CPU_WRITE);
+
+ assert(dst_map);
+
+ if (dst_map) {
+ assert(dst->stride > 0);
+
+ switch (dst->block.size) {
+ case 1:
+ case 2:
+ case 4:
+ pipe_fill_rect(dst_map, &dst->block, dst->stride,
+ dstx, dsty, 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 val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
+ ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
+ ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
+ ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
+ unsigned i, j;
+ val0 = (val0 << 8) | val0;
+ val1 = (val1 << 8) | val1;
+ val2 = (val2 << 8) | val2;
+ val3 = (val3 << 8) | val3;
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ row[j*4+0] = val0;
+ row[j*4+1] = val1;
+ row[j*4+2] = val2;
+ row[j*4+3] = val3;
+ }
+ row += dst->stride/2;
+ }
+ }
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ }
+
+ pipe->screen->surface_unmap(pipe->screen, dst);
+
+ if (new_dst)
+ screen->tex_surface_release(screen, &new_dst);
+}
diff --git a/src/gallium/auxiliary/util/u_rect.h b/src/gallium/auxiliary/util/u_rect.h
new file mode 100644
index 0000000..59e842e
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_rect.h
@@ -0,0 +1,72 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+
+/**
+ * Pipe copy/fill rect helpers.
+ */
+
+
+#ifndef U_RECT_H
+#define U_RECT_H
+
+
+#include "pipe/p_format.h"
+
+struct pipe_context;
+struct pipe_surface;
+
+
+extern void
+pipe_copy_rect(ubyte * dst, const struct pipe_format_block *block,
+ unsigned dst_stride, unsigned dst_x, unsigned dst_y,
+ unsigned width, unsigned height, const ubyte * src,
+ int src_stride, unsigned src_x, int src_y);
+
+extern void
+pipe_fill_rect(ubyte * dst, const struct pipe_format_block *block,
+ unsigned dst_stride, unsigned dst_x, unsigned dst_y,
+ unsigned width, unsigned height, uint32_t value);
+
+
+extern void
+util_surface_copy(struct pipe_context *pipe,
+ boolean do_flip,
+ struct pipe_surface *dst,
+ unsigned dst_x, unsigned dst_y,
+ struct pipe_surface *src,
+ unsigned src_x, unsigned src_y,
+ unsigned w, unsigned h);
+
+extern void
+util_surface_fill(struct pipe_context *pipe,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height, unsigned value);
+
+
+#endif /* U_RECT_H */
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index c34fb6e..f06d13c 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -37,10 +37,10 @@
#include "pipe/p_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
#include "tgsi/tgsi_build.h"
diff --git a/src/gallium/auxiliary/util/u_snprintf.c b/src/gallium/auxiliary/util/u_snprintf.c
index 7fa84d8..0d54299 100644
--- a/src/gallium/auxiliary/util/u_snprintf.c
+++ b/src/gallium/auxiliary/util/u_snprintf.c
@@ -334,6 +334,15 @@ static void *mymemcpy(void *, void *, size_t);
#endif /* HAVE_UINTPTR_T || defined(uintptr_t) */
#endif /* !defined(UINTPTR_T) */
+/* WinCE5.0 does not have uintptr_t defined */
+#if (_WIN32_WCE < 600)
+#ifdef UINTPTR_T
+#undef UINTPTR_T
+#endif
+#define UINTPTR_T unsigned long int
+#endif
+
+
/* Support for ptrdiff_t. */
#ifndef PTRDIFF_T
#if HAVE_PTRDIFF_T || defined(ptrdiff_t)
diff --git a/src/gallium/auxiliary/util/u_stream.h b/src/gallium/auxiliary/util/u_stream.h
new file mode 100644
index 0000000..a9d0f01
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_stream.h
@@ -0,0 +1,61 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Cross-platform sequential access stream abstraction.
+ */
+
+#ifndef U_STREAM_H
+#define U_STREAM_H
+
+
+#include "pipe/p_compiler.h"
+
+
+struct util_stream;
+
+
+/**
+ * Create a stream
+ * @param filename relative or absolute path (necessary for windows)
+ * @param optional maximum file size (0 for a growable size).
+ */
+struct util_stream *
+util_stream_create(const char *filename, size_t max_size);
+
+boolean
+util_stream_write(struct util_stream *stream, const void *data, size_t size);
+
+void
+util_stream_flush(struct util_stream *stream);
+
+void
+util_stream_close(struct util_stream *stream);
+
+
+#endif /* U_STREAM_H */
diff --git a/src/gallium/drivers/trace/tr_stream.c b/src/gallium/auxiliary/util/u_stream_stdc.c
index 14cc257..ca80bef 100644
--- a/src/gallium/drivers/trace/tr_stream.c
+++ b/src/gallium/auxiliary/util/u_stream_stdc.c
@@ -25,45 +25,42 @@
*
**************************************************************************/
+/**
+ * @file
+ * Stream implementation based on the Standard C Library.
+ */
+
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+
#include <stdio.h>
-#else
-#error Unsupported platform
-#endif
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
-#include "tr_stream.h"
+#include "u_stream.h"
-struct trace_stream
+struct util_stream
{
-#if defined(PIPE_OS_LINUX)
FILE *file;
-#endif
};
-struct trace_stream *
-trace_stream_create(const char *name, const char *ext)
+struct util_stream *
+util_stream_create(const char *filename, size_t max_size)
{
- struct trace_stream *stream;
- static unsigned file_no = 0;
- char filename[1024];
+ struct util_stream *stream;
+
+ (void)max_size;
- stream = CALLOC_STRUCT(trace_stream);
+ stream = CALLOC_STRUCT(util_stream);
if(!stream)
goto error1;
- snprintf(filename, sizeof(filename), "%s.%u.%s", name, file_no, ext);
-
-#if defined(PIPE_OS_LINUX)
stream->file = fopen(filename, "w");
if(!stream->file)
goto error2;
-#endif
return stream;
@@ -75,26 +72,35 @@ error1:
boolean
-trace_stream_write(struct trace_stream *stream, const void *data, size_t size)
+util_stream_write(struct util_stream *stream, const void *data, size_t size)
{
if(!stream)
return FALSE;
-#if defined(PIPE_OS_LINUX)
return fwrite(data, size, 1, stream->file) == size ? TRUE : FALSE;
-#endif
}
void
-trace_stream_close(struct trace_stream *stream)
+util_stream_flush(struct util_stream *stream)
+{
+ if(!stream)
+ return;
+
+ fflush(stream->file);
+}
+
+
+void
+util_stream_close(struct util_stream *stream)
{
if(!stream)
return;
-#if defined(PIPE_OS_LINUX)
fclose(stream->file);
-#endif
FREE(stream);
}
+
+
+#endif
diff --git a/src/gallium/auxiliary/util/u_stream_wd.c b/src/gallium/auxiliary/util/u_stream_wd.c
new file mode 100644
index 0000000..864489e
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_stream_wd.c
@@ -0,0 +1,224 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Stream implementation for the Windows Display driver.
+ */
+
+#include "pipe/p_config.h"
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+
+#include <windows.h>
+#include <winddi.h>
+
+#include "util/u_memory.h"
+#include "util/u_string.h"
+
+#include "u_stream.h"
+
+
+#define MAP_FILE_SIZE (4*1024*1024)
+
+
+struct util_stream
+{
+ char filename[MAX_PATH + 1];
+ WCHAR wFileName[MAX_PATH + 1];
+ boolean growable;
+ size_t map_size;
+ ULONG_PTR iFile;
+ char *pMap;
+ size_t written;
+ unsigned suffix;
+};
+
+
+static INLINE boolean
+util_stream_map(struct util_stream *stream)
+{
+ ULONG BytesInUnicodeString;
+ static char filename[MAX_PATH + 1];
+ unsigned filename_len;
+
+ if(stream->growable)
+ filename_len = util_snprintf(filename,
+ sizeof(filename),
+ "%s.%04x",
+ stream->filename,
+ stream->suffix++);
+ else
+ filename_len = util_snprintf(filename,
+ sizeof(filename),
+ "%s",
+ stream->filename);
+
+ EngMultiByteToUnicodeN(
+ stream->wFileName,
+ sizeof(stream->wFileName),
+ &BytesInUnicodeString,
+ filename,
+ filename_len);
+
+ stream->pMap = EngMapFile(stream->wFileName, stream->map_size, &stream->iFile);
+ if(!stream->pMap)
+ return FALSE;
+
+ memset(stream->pMap, 0, stream->map_size);
+ stream->written = 0;
+
+ return TRUE;
+}
+
+
+static INLINE void
+util_stream_unmap(struct util_stream *stream)
+{
+ EngUnmapFile(stream->iFile);
+ if(stream->written < stream->map_size) {
+ /* Truncate file size */
+ stream->pMap = EngMapFile(stream->wFileName, stream->written, &stream->iFile);
+ if(stream->pMap)
+ EngUnmapFile(stream->iFile);
+ }
+
+ stream->pMap = NULL;
+}
+
+
+static INLINE void
+util_stream_full_qualified_filename(char *dst, size_t size, const char *src)
+{
+ boolean need_drive, need_root;
+
+ if((('A' <= src[0] && src[0] <= 'Z') || ('a' <= src[0] && src[0] <= 'z')) && src[1] == ':') {
+ need_drive = FALSE;
+ need_root = src[2] == '\\' ? FALSE : TRUE;
+ }
+ else {
+ need_drive = TRUE;
+ need_root = src[0] == '\\' ? FALSE : TRUE;
+ }
+
+ util_snprintf(dst, size,
+ "\\??\\%s%s%s",
+ need_drive ? "C:" : "",
+ need_root ? "\\" : "",
+ src);
+}
+
+
+struct util_stream *
+util_stream_create(const char *filename, size_t max_size)
+{
+ struct util_stream *stream;
+
+ stream = CALLOC_STRUCT(util_stream);
+ if(!stream)
+ goto error1;
+
+ util_stream_full_qualified_filename(stream->filename,
+ sizeof(stream->filename),
+ filename);
+
+ if(max_size) {
+ stream->growable = FALSE;
+ stream->map_size = max_size;
+ }
+ else {
+ stream->growable = TRUE;
+ stream->map_size = MAP_FILE_SIZE;
+ }
+
+ if(!util_stream_map(stream))
+ goto error2;
+
+ return stream;
+
+error2:
+ FREE(stream);
+error1:
+ return NULL;
+}
+
+
+static INLINE void
+util_stream_copy(struct util_stream *stream, const char *data, size_t size)
+{
+ assert(stream->written + size <= stream->map_size);
+ memcpy(stream->pMap + stream->written, data, size);
+ stream->written += size;
+}
+
+
+boolean
+util_stream_write(struct util_stream *stream, const void *data, size_t size)
+{
+ if(!stream)
+ return FALSE;
+
+ if(!stream->pMap)
+ return FALSE;
+
+ while(stream->written + size > stream->map_size) {
+ size_t step = stream->map_size - stream->written;
+ util_stream_copy(stream, data, step);
+ data = (const char *)data + step;
+ size -= step;
+
+ util_stream_unmap(stream);
+ if(!stream->growable || !util_stream_map(stream))
+ return FALSE;
+ }
+
+ util_stream_copy(stream, data, size);
+
+ return TRUE;
+}
+
+
+void
+util_stream_flush(struct util_stream *stream)
+{
+ (void)stream;
+}
+
+
+void
+util_stream_close(struct util_stream *stream)
+{
+ if(!stream)
+ return;
+
+ util_stream_unmap(stream);
+
+ FREE(stream);
+}
+
+
+#endif
diff --git a/src/gallium/auxiliary/util/p_tile.c b/src/gallium/auxiliary/util/u_tile.c
index e366039..853c503 100644
--- a/src/gallium/auxiliary/util/p_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -33,11 +33,12 @@
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
-#include "p_tile.h"
-
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_rect.h"
+#include "util/u_tile.h"
/**
@@ -120,10 +121,10 @@ a8r8g8b8_get_tile_rgba(const unsigned *src,
float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
const unsigned pixel = *src++;
- pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
- pRow[1] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff);
- pRow[2] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff);
- pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
+ pRow[0] = ubyte_to_float((pixel >> 16) & 0xff);
+ pRow[1] = ubyte_to_float((pixel >> 8) & 0xff);
+ pRow[2] = ubyte_to_float((pixel >> 0) & 0xff);
+ pRow[3] = ubyte_to_float((pixel >> 24) & 0xff);
}
p += dst_stride;
}
@@ -142,10 +143,10 @@ a8r8g8b8_put_tile_rgba(unsigned *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r, g, b, a;
- UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]);
+ r = float_to_ubyte(pRow[0]);
+ g = float_to_ubyte(pRow[1]);
+ b = float_to_ubyte(pRow[2]);
+ a = float_to_ubyte(pRow[3]);
*dst++ = (a << 24) | (r << 16) | (g << 8) | b;
}
p += src_stride;
@@ -167,10 +168,10 @@ x8r8g8b8_get_tile_rgba(const unsigned *src,
float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
const unsigned pixel = *src++;
- pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
- pRow[1] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff);
- pRow[2] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff);
- pRow[3] = UBYTE_TO_FLOAT(0xff);
+ pRow[0] = ubyte_to_float((pixel >> 16) & 0xff);
+ pRow[1] = ubyte_to_float((pixel >> 8) & 0xff);
+ pRow[2] = ubyte_to_float((pixel >> 0) & 0xff);
+ pRow[3] = ubyte_to_float(0xff);
}
p += dst_stride;
}
@@ -189,9 +190,9 @@ x8r8g8b8_put_tile_rgba(unsigned *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r, g, b;
- UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
+ r = float_to_ubyte(pRow[0]);
+ g = float_to_ubyte(pRow[1]);
+ b = float_to_ubyte(pRow[2]);
*dst++ = (0xff << 24) | (r << 16) | (g << 8) | b;
}
p += src_stride;
@@ -213,10 +214,10 @@ b8g8r8a8_get_tile_rgba(const unsigned *src,
float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
const unsigned pixel = *src++;
- pRow[0] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff);
- pRow[1] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
- pRow[2] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
- pRow[3] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff);
+ pRow[0] = ubyte_to_float((pixel >> 8) & 0xff);
+ pRow[1] = ubyte_to_float((pixel >> 16) & 0xff);
+ pRow[2] = ubyte_to_float((pixel >> 24) & 0xff);
+ pRow[3] = ubyte_to_float((pixel >> 0) & 0xff);
}
p += dst_stride;
}
@@ -235,10 +236,10 @@ b8g8r8a8_put_tile_rgba(unsigned *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r, g, b, a;
- UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]);
+ r = float_to_ubyte(pRow[0]);
+ g = float_to_ubyte(pRow[1]);
+ b = float_to_ubyte(pRow[2]);
+ a = float_to_ubyte(pRow[3]);
*dst++ = (b << 24) | (g << 16) | (r << 8) | a;
}
p += src_stride;
@@ -282,10 +283,10 @@ a1r5g5b5_put_tile_rgba(ushort *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r, g, b, a;
- UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]);
+ r = float_to_ubyte(pRow[0]);
+ g = float_to_ubyte(pRow[1]);
+ b = float_to_ubyte(pRow[2]);
+ a = float_to_ubyte(pRow[3]);
r = r >> 3; /* 5 bits */
g = g >> 3; /* 5 bits */
b = b >> 3; /* 5 bits */
@@ -333,10 +334,10 @@ a4r4g4b4_put_tile_rgba(ushort *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r, g, b, a;
- UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]);
+ r = float_to_ubyte(pRow[0]);
+ g = float_to_ubyte(pRow[1]);
+ b = float_to_ubyte(pRow[2]);
+ a = float_to_ubyte(pRow[3]);
r >>= 4;
g >>= 4;
b >>= 4;
@@ -438,7 +439,7 @@ l8_get_tile_rgba(const ubyte *src,
for (j = 0; j < w; j++, src++, pRow += 4) {
pRow[0] =
pRow[1] =
- pRow[2] = UBYTE_TO_FLOAT(*src);
+ pRow[2] = ubyte_to_float(*src);
pRow[3] = 1.0;
}
p += dst_stride;
@@ -458,7 +459,7 @@ l8_put_tile_rgba(ubyte *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r;
- UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
+ r = float_to_ubyte(pRow[0]);
*dst++ = r;
}
p += src_stride;
@@ -483,7 +484,7 @@ a8_get_tile_rgba(const ubyte *src,
pRow[0] =
pRow[1] =
pRow[2] = 0.0;
- pRow[3] = UBYTE_TO_FLOAT(*src);
+ pRow[3] = ubyte_to_float(*src);
}
p += dst_stride;
}
@@ -502,7 +503,7 @@ a8_put_tile_rgba(ubyte *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned a;
- UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]);
+ a = float_to_ubyte(pRow[3]);
*dst++ = a;
}
p += src_stride;
@@ -613,7 +614,7 @@ i8_get_tile_rgba(const ubyte *src,
pRow[0] =
pRow[1] =
pRow[2] =
- pRow[3] = UBYTE_TO_FLOAT(*src);
+ pRow[3] = ubyte_to_float(*src);
}
p += dst_stride;
}
@@ -632,7 +633,7 @@ i8_put_tile_rgba(ubyte *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r;
- UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
+ r = float_to_ubyte(pRow[0]);
*dst++ = r;
}
p += src_stride;
@@ -656,8 +657,8 @@ a8l8_get_tile_rgba(const ushort *src,
ushort p = *src++;
pRow[0] =
pRow[1] =
- pRow[2] = UBYTE_TO_FLOAT(p & 0xff);
- pRow[3] = UBYTE_TO_FLOAT(p >> 8);
+ pRow[2] = ubyte_to_float(p & 0xff);
+ pRow[3] = ubyte_to_float(p >> 8);
}
p += dst_stride;
}
@@ -676,8 +677,8 @@ a8l8_put_tile_rgba(ushort *dst,
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r, a;
- UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]);
+ r = float_to_ubyte(pRow[0]);
+ a = float_to_ubyte(pRow[3]);
*dst++ = (a << 8) | r;
}
p += src_stride;
diff --git a/src/gallium/auxiliary/util/p_tile.h b/src/gallium/auxiliary/util/u_tile.h
index a8ac805..a8ac805 100644
--- a/src/gallium/auxiliary/util/p_tile.h
+++ b/src/gallium/auxiliary/util/u_tile.h
diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c
index 49dce75..bf7d1d1 100644
--- a/src/gallium/auxiliary/util/u_time.c
+++ b/src/gallium/auxiliary/util/u_time.c
@@ -136,6 +136,26 @@ util_time_diff(const struct util_time *t1,
}
+
+uint64_t
+util_time_micros( void )
+{
+ struct util_time t1;
+
+ util_time_get(&t1);
+
+#if defined(PIPE_OS_LINUX)
+ return t1.tv.tv_usec + t1.tv.tv_sec*1000000LL;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+ util_time_get_frequency();
+ return t1.counter*INT64_C(1000000)/frequency;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+ return t1.counter/10;
+#endif
+}
+
+
+
/**
* Compare two time values.
*
diff --git a/src/gallium/auxiliary/util/u_time.h b/src/gallium/auxiliary/util/u_time.h
index f9963ce..35d97d1 100644
--- a/src/gallium/auxiliary/util/u_time.h
+++ b/src/gallium/auxiliary/util/u_time.h
@@ -74,6 +74,9 @@ util_time_add(const struct util_time *t1,
int64_t usecs,
struct util_time *t2);
+uint64_t
+util_time_micros( void );
+
int64_t
util_time_diff(const struct util_time *t1,
const struct util_time *t2);
diff --git a/src/gallium/auxiliary/util/u_timed_winsys.c b/src/gallium/auxiliary/util/u_timed_winsys.c
new file mode 100644
index 0000000..8beb3b4
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_timed_winsys.c
@@ -0,0 +1,346 @@
+/**************************************************************************
+ *
+ * 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/p_winsys.h"
+#include "u_timed_winsys.h"
+#include "util/u_memory.h"
+#include "util/u_time.h"
+
+
+struct timed_winsys {
+ struct pipe_winsys base;
+ struct pipe_winsys *backend;
+ uint64_t last_dump;
+ struct {
+ const char *name_key;
+ double total;
+ unsigned calls;
+ } funcs[13];
+};
+
+
+static struct timed_winsys *timed_winsys( struct pipe_winsys *winsys )
+{
+ return (struct timed_winsys *)winsys;
+}
+
+
+static uint64_t time_start( void )
+{
+ return util_time_micros();
+}
+
+
+static void time_display( struct pipe_winsys *winsys )
+{
+ struct timed_winsys *tws = timed_winsys(winsys);
+ unsigned i;
+ double overall = 0;
+
+ for (i = 0; i < Elements(tws->funcs); i++) {
+ if (tws->funcs[i].name_key) {
+ debug_printf("*** %-25s %5.3fms (%d calls, avg %.3fms)\n",
+ tws->funcs[i].name_key,
+ tws->funcs[i].total,
+ tws->funcs[i].calls,
+ tws->funcs[i].total / tws->funcs[i].calls);
+ overall += tws->funcs[i].total;
+ tws->funcs[i].calls = 0;
+ tws->funcs[i].total = 0;
+ }
+ }
+
+ debug_printf("*** %-25s %5.3fms\n",
+ "OVERALL WINSYS",
+ overall);
+}
+
+static void time_finish( struct pipe_winsys *winsys,
+ long long startval,
+ unsigned idx,
+ const char *name )
+{
+ struct timed_winsys *tws = timed_winsys(winsys);
+ uint64_t endval = util_time_micros();
+ double elapsed = (endval - startval)/1000.0;
+
+ if (endval - startval > 1000LL)
+ debug_printf("*** %s %.3f\n", name, elapsed );
+
+ assert( tws->funcs[idx].name_key == name ||
+ tws->funcs[idx].name_key == NULL);
+
+ tws->funcs[idx].name_key = name;
+ tws->funcs[idx].total += elapsed;
+ tws->funcs[idx].calls++;
+
+ if (endval - tws->last_dump > 10LL * 1000LL * 1000LL) {
+ time_display( winsys );
+ tws->last_dump = endval;
+ }
+}
+
+
+/* Pipe has no concept of pools, but the psb driver passes a flag that
+ * can be mapped onto pools in the backend.
+ */
+static struct pipe_buffer *
+timed_buffer_create(struct pipe_winsys *winsys,
+ unsigned alignment,
+ unsigned usage,
+ unsigned size )
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ struct pipe_buffer *buf = backend->buffer_create( backend, alignment, usage, size );
+
+ time_finish(winsys, start, 0, __FUNCTION__);
+
+ return buf;
+}
+
+
+
+
+static struct pipe_buffer *
+timed_user_buffer_create(struct pipe_winsys *winsys,
+ void *data,
+ unsigned bytes)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ struct pipe_buffer *buf = backend->user_buffer_create( backend, data, bytes );
+
+ time_finish(winsys, start, 1, __FUNCTION__);
+
+ return buf;
+}
+
+
+static void *
+timed_buffer_map(struct pipe_winsys *winsys,
+ struct pipe_buffer *buf,
+ unsigned flags)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ void *map = backend->buffer_map( backend, buf, flags );
+
+ time_finish(winsys, start, 2, __FUNCTION__);
+
+ return map;
+}
+
+
+static void
+timed_buffer_unmap(struct pipe_winsys *winsys,
+ struct pipe_buffer *buf)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ backend->buffer_unmap( backend, buf );
+
+ time_finish(winsys, start, 3, __FUNCTION__);
+}
+
+
+static void
+timed_buffer_destroy(struct pipe_winsys *winsys,
+ struct pipe_buffer *buf)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ backend->buffer_destroy( backend, buf );
+
+ time_finish(winsys, start, 4, __FUNCTION__);
+}
+
+
+static void
+timed_flush_frontbuffer( struct pipe_winsys *winsys,
+ struct pipe_surface *surf,
+ void *context_private)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ backend->flush_frontbuffer( backend, surf, context_private );
+
+ time_finish(winsys, start, 5, __FUNCTION__);
+}
+
+
+
+
+static struct pipe_surface *
+timed_surface_alloc(struct pipe_winsys *winsys)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ struct pipe_surface *surf = backend->surface_alloc( backend );
+
+ time_finish(winsys, start, 6, __FUNCTION__);
+
+ return surf;
+}
+
+
+
+static int
+timed_surface_alloc_storage(struct pipe_winsys *winsys,
+ struct pipe_surface *surf,
+ unsigned width, unsigned height,
+ enum pipe_format format,
+ unsigned flags,
+ unsigned tex_usage)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ int ret = backend->surface_alloc_storage( backend, surf, width, height,
+ format, flags, tex_usage );
+
+ time_finish(winsys, start, 7, __FUNCTION__);
+
+ return ret;
+}
+
+
+static void
+timed_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ backend->surface_release( backend, s );
+
+ time_finish(winsys, start, 8, __FUNCTION__);
+}
+
+
+
+static const char *
+timed_get_name( struct pipe_winsys *winsys )
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ const char *ret = backend->get_name( backend );
+
+ time_finish(winsys, start, 9, __FUNCTION__);
+
+ return ret;
+}
+
+static void
+timed_fence_reference(struct pipe_winsys *winsys,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence)
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ backend->fence_reference( backend, ptr, fence );
+
+ time_finish(winsys, start, 10, __FUNCTION__);
+}
+
+
+static int
+timed_fence_signalled( struct pipe_winsys *winsys,
+ struct pipe_fence_handle *fence,
+ unsigned flag )
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ int ret = backend->fence_signalled( backend, fence, flag );
+
+ time_finish(winsys, start, 11, __FUNCTION__);
+
+ return ret;
+}
+
+static int
+timed_fence_finish( struct pipe_winsys *winsys,
+ struct pipe_fence_handle *fence,
+ unsigned flag )
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ uint64_t start = time_start();
+
+ int ret = backend->fence_finish( backend, fence, flag );
+
+ time_finish(winsys, start, 12, __FUNCTION__);
+
+ return ret;
+}
+
+static void
+timed_winsys_destroy( struct pipe_winsys *winsys )
+{
+ struct pipe_winsys *backend = timed_winsys(winsys)->backend;
+ backend->destroy( backend );
+ FREE(winsys);
+}
+
+
+
+struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend )
+{
+ struct timed_winsys *ws = CALLOC_STRUCT(timed_winsys);
+
+ ws->base.user_buffer_create = timed_user_buffer_create;
+ ws->base.buffer_map = timed_buffer_map;
+ ws->base.buffer_unmap = timed_buffer_unmap;
+ ws->base.buffer_destroy = timed_buffer_destroy;
+ ws->base.buffer_create = timed_buffer_create;
+ ws->base.flush_frontbuffer = timed_flush_frontbuffer;
+ ws->base.get_name = timed_get_name;
+ ws->base.surface_alloc = timed_surface_alloc;
+ ws->base.surface_alloc_storage = timed_surface_alloc_storage;
+ ws->base.surface_release = timed_surface_release;
+ ws->base.fence_reference = timed_fence_reference;
+ ws->base.fence_signalled = timed_fence_signalled;
+ ws->base.fence_finish = timed_fence_finish;
+ ws->base.destroy = timed_winsys_destroy;
+
+ ws->backend = backend;
+
+ return &ws->base;
+}
+
diff --git a/src/gallium/auxiliary/util/u_timed_winsys.h b/src/gallium/auxiliary/util/u_timed_winsys.h
new file mode 100644
index 0000000..5423651
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_timed_winsys.h
@@ -0,0 +1,41 @@
+/**************************************************************************
+ *
+ * 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>
+ */
+
+
+#ifndef U_TIMED_WINSYS_H
+#define U_TIMED_WINSYS_H
+
+
+struct pipe_winsys;
+struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend );
+
+
+#endif
diff --git a/src/gallium/drivers/cell/common.h b/src/gallium/drivers/cell/common.h
index f430e88..c0ca201 100644
--- a/src/gallium/drivers/cell/common.h
+++ b/src/gallium/drivers/cell/common.h
@@ -34,7 +34,6 @@
#define CELL_COMMON_H
#include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
@@ -107,6 +106,9 @@
#define CELL_BUFFER_STATUS_USED 20
+#define CELL_DEBUG_CHECKER (1 << 0)
+#define CELL_DEBUG_SYNC (1 << 1)
+
/**
*/
@@ -264,6 +266,7 @@ struct cell_init_info
{
unsigned id;
unsigned num_spus;
+ unsigned debug_flags; /**< mask of CELL_DEBUG_x flags */
struct cell_command *cmd;
/** Buffers for command batches, vertex/index data */
diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile
index 0389a95..25473e2 100644
--- a/src/gallium/drivers/cell/ppu/Makefile
+++ b/src/gallium/drivers/cell/ppu/Makefile
@@ -5,7 +5,7 @@
TOP = ../../../../..
-include $(TOP)/configs/linux-cell
+include $(TOP)/configs/current
# This is the "top-level" cell PPU driver code, will get pulled into libGL.so
diff --git a/src/gallium/drivers/cell/ppu/cell_batch.c b/src/gallium/drivers/cell/ppu/cell_batch.c
index f45e5f2..16882c0 100644
--- a/src/gallium/drivers/cell/ppu/cell_batch.c
+++ b/src/gallium/drivers/cell/ppu/cell_batch.c
@@ -32,6 +32,13 @@
+/**
+ * Search the buffer pool for an empty/free buffer and return its index.
+ * Buffers are used for storing vertex data, state and commands which
+ * will be sent to the SPUs.
+ * If no empty buffers are available, wait for one.
+ * \return buffer index in [0, CELL_NUM_BUFFERS-1]
+ */
uint
cell_get_empty_buffer(struct cell_context *cell)
{
@@ -74,6 +81,11 @@ cell_get_empty_buffer(struct cell_context *cell)
}
+/**
+ * Flush the current batch buffer to the SPUs.
+ * An empty buffer will be found and set as the new current batch buffer
+ * for subsequent commands/data.
+ */
void
cell_batch_flush(struct cell_context *cell)
{
@@ -93,11 +105,11 @@ cell_batch_flush(struct cell_context *cell)
/*
printf("cell_batch_dispatch: buf %u at %p, size %u\n",
- batch, &cell->batch_buffer[batch][0], size);
+ batch, &cell->buffer[batch][0], size);
*/
/*
- * Build "BATCH" command and sent to all SPUs.
+ * Build "BATCH" command and send to all SPUs.
*/
cmd_word = CELL_CMD_BATCH | (batch << 8) | (size << 16);
@@ -120,6 +132,9 @@ cell_batch_flush(struct cell_context *cell)
}
+/**
+ * Return the number of bytes free in the current batch buffer.
+ */
uint
cell_batch_free_space(const struct cell_context *cell)
{
@@ -129,7 +144,9 @@ cell_batch_free_space(const struct cell_context *cell)
/**
- * Append data to current batch.
+ * Append data to the current batch buffer.
+ * \param data address of block of bytes to append
+ * \param bytes size of block of bytes
*/
void
cell_batch_append(struct cell_context *cell, const void *data, uint bytes)
@@ -165,6 +182,10 @@ cell_batch_append(struct cell_context *cell, const void *data, uint bytes)
}
+/**
+ * Allocate space in the current batch buffer for 'bytes' space.
+ * \return address in batch buffer to put data
+ */
void *
cell_batch_alloc(struct cell_context *cell, uint bytes)
{
@@ -172,6 +193,10 @@ cell_batch_alloc(struct cell_context *cell, uint bytes)
}
+/**
+ * Same as \sa cell_batch_alloc, but return an address at a particular
+ * alignment.
+ */
void *
cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
uint alignment)
@@ -215,3 +240,28 @@ cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
return pos;
}
+
+
+/**
+ * One-time init of batch buffers.
+ */
+void
+cell_init_batch_buffers(struct cell_context *cell)
+{
+ uint spu, buf;
+
+ /* init command, vertex/index buffer info */
+ for (buf = 0; buf < CELL_NUM_BUFFERS; buf++) {
+ cell->buffer_size[buf] = 0;
+
+ /* init batch buffer status values,
+ * mark 0th buffer as used, rest as free.
+ */
+ for (spu = 0; spu < cell->num_spus; spu++) {
+ if (buf == 0)
+ cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED;
+ else
+ cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_FREE;
+ }
+ }
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_batch.h b/src/gallium/drivers/cell/ppu/cell_batch.h
index a6eee0a..f74dd60 100644
--- a/src/gallium/drivers/cell/ppu/cell_batch.h
+++ b/src/gallium/drivers/cell/ppu/cell_batch.h
@@ -54,5 +54,8 @@ extern void *
cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
uint alignment);
+extern void
+cell_init_batch_buffers(struct cell_context *cell);
+
#endif /* CELL_BATCH_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c
index 3ffe09a..c9c0c72 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.c
+++ b/src/gallium/drivers/cell/ppu/cell_clear.c
@@ -34,7 +34,8 @@
#include <assert.h>
#include <stdint.h>
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "util/u_pack_color.h"
#include "cell/common.h"
#include "cell_clear.h"
#include "cell_context.h"
@@ -44,10 +45,32 @@
#include "cell_state.h"
+/**
+ * Convert packed pixel from one format to another.
+ */
+static unsigned
+convert_color(enum pipe_format srcFormat, unsigned srcColor,
+ enum pipe_format dstFormat)
+{
+ ubyte r, g, b, a;
+ unsigned dstColor;
+
+ util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a);
+ util_pack_color_ub(r, g, b, a, dstFormat, &dstColor);
+
+ return dstColor;
+}
+
+
+
+/**
+ * Called via pipe->clear()
+ */
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;
@@ -56,16 +79,25 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
if (!cell->cbuf_map[0])
- cell->cbuf_map[0] = pipe_surface_map(ps);
+ 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;
}
else {
+ /* clear color buffer */
surfIndex = 0;
+
+ if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) {
+ clearValue = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue,
+ ps->format);
+ }
}
+ /* Build a CLEAR command and place it in the current batch buffer */
{
struct cell_command_clear_surface *clr
= (struct cell_command_clear_surface *)
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index 12eb5aa..71f1a30 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -35,7 +35,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_format.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "pipe/p_screen.h"
@@ -43,11 +43,11 @@
#include "draw/draw_private.h"
#include "cell/common.h"
+#include "cell_batch.h"
#include "cell_clear.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
#include "cell_flush.h"
-#include "cell_render.h"
#include "cell_state.h"
#include "cell_surface.h"
#include "cell_spu.h"
@@ -73,22 +73,32 @@ cell_draw_create(struct cell_context *cell)
{
struct draw_context *draw = draw_create();
+#if 0 /* broken */
if (getenv("GALLIUM_CELL_VS")) {
/* plug in SPU-based vertex transformation code */
draw->shader_queue_flush = cell_vertex_shader_queue_flush;
draw->driver_private = cell;
}
+#endif
return draw;
}
+#ifdef DEBUG
+static const struct debug_named_value cell_debug_flags[] = {
+ {"checker", CELL_DEBUG_CHECKER},/**< modulate tile clear color by SPU ID */
+ {"sync", CELL_DEBUG_SYNC}, /**< SPUs do synchronous DMA */
+ {NULL, 0}
+};
+#endif
+
+
struct pipe_context *
cell_create_context(struct pipe_screen *screen,
struct cell_winsys *cws)
{
struct cell_context *cell;
- uint spu, buf;
/* some fields need to be 16-byte aligned, so align the whole object */
cell = (struct cell_context*) align_malloc(sizeof(struct cell_context), 16);
@@ -102,13 +112,6 @@ cell_create_context(struct pipe_screen *screen,
cell->pipe.screen = screen;
cell->pipe.destroy = cell_destroy_context;
- /* state setters */
- cell->pipe.set_vertex_buffers = cell_set_vertex_buffers;
- cell->pipe.set_vertex_elements = cell_set_vertex_elements;
-
- cell->pipe.draw_arrays = cell_draw_arrays;
- cell->pipe.draw_elements = cell_draw_elements;
-
cell->pipe.clear = cell_clear_surface;
cell->pipe.flush = cell_flush;
@@ -118,20 +121,28 @@ cell_create_context(struct pipe_screen *screen,
cell->pipe.wait_query = cell_wait_query;
#endif
+ cell_init_draw_functions(cell);
cell_init_state_functions(cell);
cell_init_shader_functions(cell);
cell_init_surface_functions(cell);
cell_init_texture_functions(cell);
+ cell_init_vertex_functions(cell);
cell->draw = cell_draw_create(cell);
cell_init_vbuf(cell);
+
draw_set_rasterize_stage(cell->draw, cell->vbuf);
/* convert all points/lines to tris for the time being */
draw_wide_point_threshold(cell->draw, 0.0);
draw_wide_line_threshold(cell->draw, 0.0);
+ /* get env vars or read config file to get debug flags */
+ cell->debug_flags = debug_get_flags_option("CELL_DEBUG",
+ cell_debug_flags,
+ 0 );
+
/*
* SPU stuff
*/
@@ -142,20 +153,7 @@ cell_create_context(struct pipe_screen *screen,
cell_start_spus(cell);
- /* init command, vertex/index buffer info */
- for (buf = 0; buf < CELL_NUM_BUFFERS; buf++) {
- cell->buffer_size[buf] = 0;
-
- /* init batch buffer status values,
- * mark 0th buffer as used, rest as free.
- */
- for (spu = 0; spu < cell->num_spus; spu++) {
- if (buf == 0)
- cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED;
- else
- cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_FREE;
- }
- }
+ cell_init_batch_buffers(cell);
return &cell->pipe;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h
index f1d1ca8..8cec9f4 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.h
+++ b/src/gallium/drivers/cell/ppu/cell_context.h
@@ -39,8 +39,13 @@
#include "rtasm/rtasm_ppc_spe.h"
#include "tgsi/tgsi_scan.h"
+
struct cell_vbuf_render;
+
+/**
+ * Cell vertex shader state, subclass of pipe_shader_state.
+ */
struct cell_vertex_shader_state
{
struct pipe_shader_state shader;
@@ -49,6 +54,9 @@ struct cell_vertex_shader_state
};
+/**
+ * Cell fragment shader state, subclass of pipe_shader_state.
+ */
struct cell_fragment_shader_state
{
struct pipe_shader_state shader;
@@ -57,7 +65,11 @@ struct cell_fragment_shader_state
};
-struct cell_blend_state {
+/**
+ * Cell blend state atom, subclass of pipe_blend_state.
+ */
+struct cell_blend_state
+{
struct pipe_blend_state base;
/**
@@ -67,17 +79,24 @@ struct cell_blend_state {
};
-struct cell_depth_stencil_alpha_state {
- struct pipe_depth_stencil_alpha_state base;
+/**
+ * Cell depth/stencil/alpha state atom, subclass of
+ * pipe_depth_stencil_alpha_state.
+ */
+struct cell_depth_stencil_alpha_state
+{
+ struct pipe_depth_stencil_alpha_state base;
/**
* Generated code to perform alpha, stencil, and depth testing on the SPE
*/
struct spe_function code;
-
};
+/**
+ * Per-context state, subclass of pipe_context.
+ */
struct cell_context
{
struct pipe_context pipe;
@@ -144,6 +163,8 @@ struct cell_context
struct spe_function attrib_fetch;
unsigned attrib_fetch_offsets[PIPE_MAX_ATTRIBS];
+
+ unsigned debug_flags;
};
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
index 6e08cf6..880d535 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
@@ -34,6 +34,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
@@ -59,7 +60,8 @@ cell_map_constant_buffers(struct cell_context *sp)
}
draw_set_mapped_constant_buffer(sp->draw,
- sp->mapped_constants[PIPE_SHADER_VERTEX]);
+ sp->mapped_constants[PIPE_SHADER_VERTEX],
+ sp->constants[PIPE_SHADER_VERTEX].size);
}
static void
@@ -75,14 +77,6 @@ cell_unmap_constant_buffers(struct cell_context *sp)
}
-boolean
-cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count)
-{
- return cell_draw_elements(pipe, NULL, 0, mode, start, count);
-}
-
-
/**
* Draw vertex arrays, with optional indexing.
@@ -91,11 +85,13 @@ cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
*
* XXX should the element buffer be specified/bound with a separate function?
*/
-boolean
-cell_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned mode, unsigned start, unsigned count)
+static boolean
+cell_draw_range_elements(struct pipe_context *pipe,
+ struct pipe_buffer *indexBuffer,
+ unsigned indexSize,
+ unsigned min_index,
+ unsigned max_index,
+ unsigned mode, unsigned start, unsigned count)
{
struct cell_context *sp = cell_context(pipe);
struct draw_context *draw = sp->draw;
@@ -113,7 +109,7 @@ cell_draw_elements(struct pipe_context *pipe,
* Map vertex buffers
*/
for (i = 0; i < sp->num_vertex_buffers; i++) {
- void *buf = pipe->winsys->buffer_map(pipe->winsys,
+ void *buf = pipe_buffer_map(pipe->screen,
sp->vertex_buffer[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
cell_flush_buffer_range(sp, buf, sp->vertex_buffer[i].buffer->size);
@@ -121,7 +117,7 @@ cell_draw_elements(struct pipe_context *pipe,
}
/* Map index buffer, if present */
if (indexBuffer) {
- void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys,
+ void *mapped_indexes = pipe_buffer_map(pipe->screen,
indexBuffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
@@ -140,11 +136,11 @@ cell_draw_elements(struct pipe_context *pipe,
*/
for (i = 0; i < sp->num_vertex_buffers; i++) {
draw_set_mapped_vertex_buffer(draw, i, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
+ pipe_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer);
}
if (indexBuffer) {
draw_set_mapped_element_buffer(draw, 0, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+ pipe_buffer_unmap(pipe->screen, indexBuffer);
}
/* Note: leave drawing surfaces mapped */
@@ -152,3 +148,44 @@ cell_draw_elements(struct pipe_context *pipe,
return TRUE;
}
+
+
+static boolean
+cell_draw_elements(struct pipe_context *pipe,
+ struct pipe_buffer *indexBuffer,
+ unsigned indexSize,
+ unsigned mode, unsigned start, unsigned count)
+{
+ return cell_draw_range_elements( pipe, indexBuffer,
+ indexSize,
+ 0, 0xffffffff,
+ mode, start, count );
+}
+
+
+static boolean
+cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
+ unsigned start, unsigned count)
+{
+ return cell_draw_elements(pipe, NULL, 0, mode, start, count);
+}
+
+
+static void
+cell_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
+{
+ struct cell_context *cell = cell_context(pipe);
+ draw_set_edgeflags(cell->draw, edgeflags);
+}
+
+
+
+void
+cell_init_draw_functions(struct cell_context *cell)
+{
+ cell->pipe.draw_arrays = cell_draw_arrays;
+ cell->pipe.draw_elements = cell_draw_elements;
+ cell->pipe.draw_range_elements = cell_draw_range_elements;
+ cell->pipe.set_edgeflags = cell_set_edgeflags;
+}
+
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.h b/src/gallium/drivers/cell/ppu/cell_draw_arrays.h
index d5df4aa..148873a 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.h
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.h
@@ -29,14 +29,8 @@
#define CELL_DRAW_ARRAYS_H
-boolean cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count);
-
-boolean cell_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned mode, unsigned start, unsigned count);
-
+extern void
+cell_init_draw_functions(struct cell_context *cell);
#endif /* CELL_DRAW_ARRAYS_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_flush.c b/src/gallium/drivers/cell/ppu/cell_flush.c
index 3aaf3de..6596b72 100644
--- a/src/gallium/drivers/cell/ppu/cell_flush.c
+++ b/src/gallium/drivers/cell/ppu/cell_flush.c
@@ -34,6 +34,9 @@
#include "draw/draw_context.h"
+/**
+ * Called via pipe->flush()
+ */
void
cell_flush(struct pipe_context *pipe, unsigned flags,
struct pipe_fence_handle **fence)
@@ -50,16 +53,19 @@ cell_flush(struct pipe_context *pipe, unsigned flags,
flags |= CELL_FLUSH_WAIT;
draw_flush( cell->draw );
- cell_flush_int(pipe, flags);
+ cell_flush_int(cell, flags);
}
-/** internal flush */
+/**
+ * Cell internal flush function. Send the current batch buffer to all SPUs.
+ * If flags & CELL_FLUSH_WAIT, do not return until the SPUs are idle.
+ * \param flags bitmask of flags CELL_FLUSH_WAIT, or zero
+ */
void
-cell_flush_int(struct pipe_context *pipe, unsigned flags)
+cell_flush_int(struct cell_context *cell, unsigned flags)
{
static boolean flushing = FALSE; /* recursion catcher */
- struct cell_context *cell = cell_context(pipe);
uint i;
ASSERT(!flushing);
diff --git a/src/gallium/drivers/cell/ppu/cell_flush.h b/src/gallium/drivers/cell/ppu/cell_flush.h
index 8f0645c..509ae62 100644
--- a/src/gallium/drivers/cell/ppu/cell_flush.h
+++ b/src/gallium/drivers/cell/ppu/cell_flush.h
@@ -36,7 +36,7 @@ cell_flush(struct pipe_context *pipe, unsigned flags,
struct pipe_fence_handle **fence);
extern void
-cell_flush_int(struct pipe_context *pipe, unsigned flags);
+cell_flush_int(struct cell_context *cell, unsigned flags);
extern void
cell_flush_buffer_range(struct cell_context *cell, void *ptr,
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index 67b87f1..e04cf5f 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -30,10 +30,11 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
#include "cell_context.h"
+#include "cell_flush.h"
#include "cell_state.h"
#include "cell_texture.h"
#include "cell_state_per_fragment.h"
@@ -130,8 +131,9 @@ cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth)
}
-static void cell_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
+static void
+cell_set_clip_state(struct pipe_context *pipe,
+ const struct pipe_clip_state *clip)
{
struct cell_context *cell = cell_context(pipe);
@@ -294,6 +296,8 @@ cell_set_framebuffer_state(struct pipe_context *pipe,
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++) {
@@ -308,15 +312,28 @@ cell_set_framebuffer_state(struct pipe_context *pipe,
cell->zsbuf_map = NULL;
}
- /* update my state */
- cell->framebuffer = *fb;
+ /* Finish any pending rendering to the current surface before
+ * installing a new surface!
+ */
+ cell_flush_int(cell, CELL_FLUSH_WAIT);
+
+ /* update my state
+ * (this is also where old surfaces will finally get freed)
+ */
+ cell->framebuffer.width = fb->width;
+ cell->framebuffer.height = fb->height;
+ cell->framebuffer.num_cbufs = fb->num_cbufs;
+ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+ pipe_surface_reference(&cell->framebuffer.cbufs[i], fb->cbufs[i]);
+ }
+ pipe_surface_reference(&cell->framebuffer.zsbuf, fb->zsbuf);
/* map new surfaces */
if (csurf)
- cell->cbuf_map[0] = pipe_surface_map(csurf);
+ cell->cbuf_map[0] = pipe_surface_map(csurf, flags);
if (zsurf)
- cell->zsbuf_map = pipe_surface_map(zsurf);
+ cell->zsbuf_map = pipe_surface_map(zsurf, flags);
cell->dirty |= CELL_NEW_FRAMEBUFFER;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_render.c b/src/gallium/drivers/cell/ppu/cell_render.c
index b663b37..dd25ae8 100644
--- a/src/gallium/drivers/cell/ppu/cell_render.c
+++ b/src/gallium/drivers/cell/ppu/cell_render.c
@@ -33,7 +33,7 @@
#include "cell_context.h"
#include "cell_render.h"
#include "cell_spu.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_private.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c
index 2bf441a..139b371 100644
--- a/src/gallium/drivers/cell/ppu/cell_screen.c
+++ b/src/gallium/drivers/cell/ppu/cell_screen.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_spu.c b/src/gallium/drivers/cell/ppu/cell_spu.c
index 973c0b1..9508227 100644
--- a/src/gallium/drivers/cell/ppu/cell_spu.c
+++ b/src/gallium/drivers/cell/ppu/cell_spu.c
@@ -26,6 +26,11 @@
**************************************************************************/
+/**
+ * Utility/wrappers for communicating with the SPUs.
+ */
+
+
#include <pthread.h>
#include "cell_spu.h"
@@ -40,6 +45,9 @@ helpful headers:
*/
+/**
+ * Cell/SPU info that's not per-context.
+ */
struct cell_global_info cell_global;
@@ -74,7 +82,11 @@ wait_mbox_message(spe_context_ptr_t ctx)
}
-static void *cell_thread_function(void *arg)
+/**
+ * Called by pthread_create() to spawn an SPU thread.
+ */
+static void *
+cell_thread_function(void *arg)
{
struct cell_init_info *init = (struct cell_init_info *) arg;
unsigned entry = SPE_DEFAULT_ENTRY;
@@ -92,7 +104,10 @@ static void *cell_thread_function(void *arg)
/**
- * Create the SPU threads
+ * Create the SPU threads. This is done once during driver initialization.
+ * This involves setting the the "init" message which is sent to each SPU.
+ * The init message specifies an SPU id, total number of SPUs, location
+ * and number of batch buffers, etc.
*/
void
cell_start_spus(struct cell_context *cell)
@@ -100,7 +115,6 @@ cell_start_spus(struct cell_context *cell)
static boolean one_time_init = FALSE;
uint i, j;
-
if (one_time_init) {
fprintf(stderr, "PPU: Multiple rendering contexts not yet supported "
"on Cell.\n");
@@ -120,6 +134,7 @@ cell_start_spus(struct cell_context *cell)
for (i = 0; i < cell->num_spus; i++) {
cell_global.inits[i].id = i;
cell_global.inits[i].num_spus = cell->num_spus;
+ cell_global.inits[i].debug_flags = cell->debug_flags;
cell_global.inits[i].cmd = &cell_global.command[i];
for (j = 0; j < CELL_NUM_BUFFERS; j++) {
cell_global.inits[i].buffers[j] = cell->buffer[j];
@@ -137,14 +152,17 @@ cell_start_spus(struct cell_context *cell)
exit(1);
}
- pthread_create(&cell_global.spe_threads[i], NULL, &cell_thread_function,
- &cell_global.inits[i]);
+ pthread_create(&cell_global.spe_threads[i], /* returned thread handle */
+ NULL, /* pthread attribs */
+ &cell_thread_function, /* start routine */
+ &cell_global.inits[i]); /* thread argument */
}
}
/**
* Tell all the SPUs to stop/exit.
+ * This is done when the driver's exiting / cleaning up.
*/
void
cell_spu_exit(struct cell_context *cell)
diff --git a/src/gallium/drivers/cell/ppu/cell_state.h b/src/gallium/drivers/cell/ppu/cell_state.h
index 82580ea..a7771a5 100644
--- a/src/gallium/drivers/cell/ppu/cell_state.h
+++ b/src/gallium/drivers/cell/ppu/cell_state.h
@@ -48,19 +48,17 @@
#define CELL_NEW_VERTEX_INFO 0x8000
-void cell_set_vertex_elements(struct pipe_context *,
- unsigned count,
- const struct pipe_vertex_element *);
+extern void
+cell_update_derived( struct cell_context *softpipe );
-void cell_set_vertex_buffers(struct pipe_context *,
- unsigned count,
- const struct pipe_vertex_buffer *);
-void cell_update_derived( struct cell_context *softpipe );
+extern void
+cell_init_shader_functions(struct cell_context *cell);
-void
-cell_init_shader_functions(struct cell_context *cell);
+extern void
+cell_init_vertex_functions(struct cell_context *cell);
+
#endif /* CELL_STATE_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_state_derived.c b/src/gallium/drivers/cell/ppu/cell_state_derived.c
index 5480534..efc4f78 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_derived.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_derived.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
@@ -35,21 +35,6 @@
#include "cell_state_emit.h"
-static int
-find_vs_output(const struct cell_vertex_shader_state *vs,
- uint semantic_name,
- uint semantic_index)
-{
- uint i;
- for (i = 0; i < vs->info.num_outputs; i++) {
- if (vs->info.output_semantic_name[i] == semantic_name &&
- vs->info.output_semantic_index[i] == semantic_index)
- return i;
- }
- return -1;
-}
-
-
/**
* Determine how to map vertex program outputs to fragment program inputs.
* Basically, this will be used when computing the triangle interpolation
@@ -58,7 +43,6 @@ find_vs_output(const struct cell_vertex_shader_state *vs,
static void
calculate_vertex_layout( struct cell_context *cell )
{
- const struct cell_vertex_shader_state *vs = cell->vs;
const struct cell_fragment_shader_state *fs = cell->fs;
const enum interp_mode colorInterp
= cell->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
@@ -82,7 +66,7 @@ calculate_vertex_layout( struct cell_context *cell )
vinfo->num_attribs = 0;
/* we always want to emit vertex pos */
- src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0);
+ src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_POSITION, 0);
assert(src >= 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
@@ -98,14 +82,14 @@ calculate_vertex_layout( struct cell_context *cell )
break;
case TGSI_SEMANTIC_COLOR:
- src = find_vs_output(vs, TGSI_SEMANTIC_COLOR,
- fs->info.input_semantic_index[i]);
+ src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_COLOR,
+ fs->info.input_semantic_index[i]);
assert(src >= 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
break;
case TGSI_SEMANTIC_FOG:
- src = find_vs_output(vs, TGSI_SEMANTIC_FOG, 0);
+ src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_FOG, 0);
#if 1
if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */
src = 0;
@@ -116,7 +100,7 @@ calculate_vertex_layout( struct cell_context *cell )
case TGSI_SEMANTIC_GENERIC:
/* this includes texcoords and varying vars */
- src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC,
+ src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_GENERIC,
fs->info.input_semantic_index[i]);
assert(src >= 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
@@ -163,6 +147,9 @@ compute_cliprect(struct cell_context *sp)
+/**
+ * Update derived state, send current state to SPUs prior to rendering.
+ */
void cell_update_derived( struct cell_context *cell )
{
if (cell->dirty & (CELL_NEW_RASTERIZER |
diff --git a/src/gallium/drivers/cell/ppu/cell_state_emit.c b/src/gallium/drivers/cell/ppu/cell_state_emit.c
index 9cae67f..f2feaa3 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_emit.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_emit.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "cell_context.h"
#include "cell_state.h"
#include "cell_state_emit.h"
@@ -47,7 +47,10 @@ emit_state_cmd(struct cell_context *cell, uint cmd,
}
-
+/**
+ * For state marked as 'dirty', construct a state-update command block
+ * and insert it into the current batch buffer.
+ */
void
cell_emit_state(struct cell_context *cell)
{
@@ -90,7 +93,8 @@ cell_emit_state(struct cell_context *cell)
blend.size = (char *) cell->blend->code.csr
- (char *) cell->blend->code.store;
blend.read_fb = TRUE;
- } else {
+ }
+ else {
blend.base = 0;
blend.size = 0;
blend.read_fb = FALSE;
@@ -101,7 +105,6 @@ cell_emit_state(struct cell_context *cell)
if (cell->dirty & CELL_NEW_DEPTH_STENCIL) {
struct cell_command_depth_stencil_alpha_test dsat;
-
if (cell->depth_stencil != NULL) {
dsat.base = (intptr_t) cell->depth_stencil->code.store;
@@ -109,15 +112,15 @@ cell_emit_state(struct cell_context *cell)
- (char *) cell->depth_stencil->code.store;
dsat.read_depth = TRUE;
dsat.read_stencil = FALSE;
- } else {
+ }
+ else {
dsat.base = 0;
dsat.size = 0;
dsat.read_depth = FALSE;
dsat.read_stencil = FALSE;
}
- emit_state_cmd(cell, CELL_CMD_STATE_DEPTH_STENCIL, &dsat,
- sizeof(dsat));
+ emit_state_cmd(cell, CELL_CMD_STATE_DEPTH_STENCIL, &dsat, sizeof(dsat));
}
if (cell->dirty & CELL_NEW_SAMPLER) {
@@ -162,15 +165,14 @@ cell_emit_state(struct cell_context *cell)
const struct draw_context *const draw = cell->draw;
struct cell_shader_info info;
- info.num_outputs = draw->num_vs_outputs;
- info.declarations = (uintptr_t) draw->machine.Declarations;
- info.num_declarations = draw->machine.NumDeclarations;
- info.instructions = (uintptr_t) draw->machine.Instructions;
- info.num_instructions = draw->machine.NumInstructions;
- info.immediates = (uintptr_t) draw->machine.Imms;
- info.num_immediates = draw->machine.ImmLimit / 4;
+ info.num_outputs = draw_num_vs_outputs(draw);
+ info.declarations = (uintptr_t) draw->vs.machine.Declarations;
+ info.num_declarations = draw->vs.machine.NumDeclarations;
+ info.instructions = (uintptr_t) draw->vs.machine.Instructions;
+ info.num_instructions = draw->vs.machine.NumInstructions;
+ info.immediates = (uintptr_t) draw->vs.machine.Imms;
+ info.num_immediates = draw->vs.machine.ImmLimit / 4;
- emit_state_cmd(cell, CELL_CMD_STATE_BIND_VS,
- & info, sizeof(info));
+ emit_state_cmd(cell, CELL_CMD_STATE_BIND_VS, &info, sizeof(info));
}
}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c
index f5707f2..97e44ee 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c
@@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "draw/draw_context.h"
@@ -41,7 +41,7 @@
static INLINE struct cell_fragment_shader_state *
cell_fragment_shader_state(void *shader)
{
- return (struct pipe_shader_state *) shader;
+ return (struct cell_fragment_shader_state *) shader;
}
@@ -49,11 +49,14 @@ cell_fragment_shader_state(void *shader)
static INLINE struct cell_vertex_shader_state *
cell_vertex_shader_state(void *shader)
{
- return (struct pipe_shader_state *) shader;
+ return (struct cell_vertex_shader_state *) shader;
}
-
+/**
+ * Create fragment shader state.
+ * Called via pipe->create_fs_state()
+ */
static void *
cell_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
@@ -77,6 +80,9 @@ cell_create_fs_state(struct pipe_context *pipe,
}
+/**
+ * Called via pipe->bind_fs_state()
+ */
static void
cell_bind_fs_state(struct pipe_context *pipe, void *fs)
{
@@ -88,6 +94,9 @@ cell_bind_fs_state(struct pipe_context *pipe, void *fs)
}
+/**
+ * Called via pipe->delete_fs_state()
+ */
static void
cell_delete_fs_state(struct pipe_context *pipe, void *fs)
{
@@ -98,6 +107,10 @@ cell_delete_fs_state(struct pipe_context *pipe, void *fs)
}
+/**
+ * Create vertex shader state.
+ * Called via pipe->create_vs_state()
+ */
static void *
cell_create_vs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
@@ -128,6 +141,9 @@ cell_create_vs_state(struct pipe_context *pipe,
}
+/**
+ * Called via pipe->bind_vs_state()
+ */
static void
cell_bind_vs_state(struct pipe_context *pipe, void *vs)
{
@@ -142,6 +158,9 @@ cell_bind_vs_state(struct pipe_context *pipe, void *vs)
}
+/**
+ * Called via pipe->delete_vs_state()
+ */
static void
cell_delete_vs_state(struct pipe_context *pipe, void *vs)
{
@@ -154,6 +173,9 @@ cell_delete_vs_state(struct pipe_context *pipe, void *vs)
}
+/**
+ * Called via pipe->set_constant_buffer()
+ */
static void
cell_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
@@ -166,7 +188,7 @@ cell_set_constant_buffer(struct pipe_context *pipe,
assert(index == 0);
/* note: reference counting */
- pipe_buffer_reference(ws,
+ winsys_buffer_reference(ws,
&cell->constants[shader].buffer,
buf->buffer);
cell->constants[shader].size = buf->size;
diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c
index 114684c..fbe55c8 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c
@@ -35,7 +35,7 @@
#include "draw/draw_context.h"
-void
+static void
cell_set_vertex_elements(struct pipe_context *pipe,
unsigned count,
const struct pipe_vertex_element *elements)
@@ -53,7 +53,7 @@ cell_set_vertex_elements(struct pipe_context *pipe,
}
-void
+static void
cell_set_vertex_buffers(struct pipe_context *pipe,
unsigned count,
const struct pipe_vertex_buffer *buffers)
@@ -69,3 +69,11 @@ cell_set_vertex_buffers(struct pipe_context *pipe,
draw_set_vertex_buffers(cell->draw, count, buffers);
}
+
+
+void
+cell_init_vertex_functions(struct cell_context *cell)
+{
+ cell->pipe.set_vertex_buffers = cell_set_vertex_buffers;
+ cell->pipe.set_vertex_elements = cell_set_vertex_elements;
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_surface.c b/src/gallium/drivers/cell/ppu/cell_surface.c
index 5549eb4..732c640 100644
--- a/src/gallium/drivers/cell/ppu/cell_surface.c
+++ b/src/gallium/drivers/cell/ppu/cell_surface.c
@@ -25,106 +25,13 @@
*
**************************************************************************/
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
-#include "util/p_tile.h"
+#include "util/u_rect.h"
#include "cell_context.h"
-#include "cell_surface.h"
-
-
-static void
-cell_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->cpp == src->cpp );
-
- pipe_copy_rect(pipe_surface_map(dst),
- &dst->block,
- dst->stride,
- dstx, dsty,
- width, height,
- pipe_surface_map(src),
- do_flip ? -src->stride : src->stride,
- srcx, do_flip ? height - 1 - srcy : srcy);
-
- pipe_surface_unmap(src);
- pipe_surface_unmap(dst);
-}
-
-
-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))
-
-
-/**
- * Fill a rectangular sub-region. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-static void
-cell_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
-{
- unsigned i, j;
- void *dst_map = pipe_surface_map(dst);
-
- assert(dst->stride > 0);
-
- switch (dst->block.size) {
- case 1:
- case 2:
- case 4:
- pipe_fill_rect(dst_map, &dst->block, dst->stride, dstx, dsty, 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 val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
- ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
- ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
- ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
- val0 = (val0 << 8) | val0;
- val1 = (val1 << 8) | val1;
- val2 = (val2 << 8) | val2;
- val3 = (val3 << 8) | val3;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- row[j*4+0] = val0;
- row[j*4+1] = val1;
- row[j*4+2] = val2;
- row[j*4+3] = val3;
- }
- row += dst->stride/2;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
-
- pipe_surface_unmap( dst );
-}
void
cell_init_surface_functions(struct cell_context *cell)
{
- cell->pipe.surface_copy = cell_surface_copy;
- cell->pipe.surface_fill = cell_surface_fill;
+ cell->pipe.surface_copy = util_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 533b642..b6590df 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -33,8 +33,9 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "cell_context.h"
#include "cell_state.h"
@@ -62,17 +63,30 @@ cell_texture_layout(struct cell_texture * spt)
spt->buffer_size = 0;
for ( level = 0 ; level <= pt->last_level ; level++ ) {
+ unsigned size;
+ unsigned w_tile, h_tile;
+
+ /* width, height, rounded up to tile size */
+ w_tile = align(width, TILE_SIZE);
+ h_tile = align(height, TILE_SIZE);
+
pt->width[level] = width;
pt->height[level] = height;
pt->depth[level] = depth;
- pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);
+ pt->nblocksx[level] = pf_get_nblocksx(&pt->block, w_tile);
+ pt->nblocksy[level] = pf_get_nblocksy(&pt->block, h_tile);
+
+ spt->stride[level] = pt->nblocksx[level] * pt->block.size;
spt->level_offset[level] = spt->buffer_size;
- spt->buffer_size += (pt->nblocksy[level] *
- ((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
- pt->nblocksx[level] * pt->block.size;
+ size = pt->nblocksx[level] * pt->nblocksy[level] * pt->block.size;
+ if (pt->target == PIPE_TEXTURE_CUBE)
+ size *= 6;
+ else
+ size *= depth;
+
+ spt->buffer_size += size;
width = minify(width);
height = minify(height);
@@ -82,8 +96,8 @@ cell_texture_layout(struct cell_texture * spt)
static struct pipe_texture *
-cell_texture_create_screen(struct pipe_screen *screen,
- const struct pipe_texture *templat)
+cell_texture_create(struct pipe_screen *screen,
+ const struct pipe_texture *templat)
{
struct pipe_winsys *ws = screen->winsys;
struct cell_texture *spt = CALLOC_STRUCT(cell_texture);
@@ -110,8 +124,8 @@ cell_texture_create_screen(struct pipe_screen *screen,
static void
-cell_texture_release_screen(struct pipe_screen *screen,
- struct pipe_texture **pt)
+cell_texture_release(struct pipe_screen *screen,
+ struct pipe_texture **pt)
{
if (!*pt)
return;
@@ -127,7 +141,7 @@ cell_texture_release_screen(struct pipe_screen *screen,
DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
*/
- pipe_buffer_reference(screen->winsys, &spt->buffer, NULL);
+ pipe_buffer_reference(screen, &spt->buffer, NULL);
FREE(spt);
}
@@ -135,6 +149,7 @@ cell_texture_release_screen(struct pipe_screen *screen,
}
+#if 0
static void
cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture,
uint face, uint levelsMask)
@@ -142,12 +157,14 @@ cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture,
/* XXX TO DO: re-tile the texture data ... */
}
+#endif
static struct pipe_surface *
-cell_get_tex_surface_screen(struct pipe_screen *screen,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
+cell_get_tex_surface(struct pipe_screen *screen,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice,
+ unsigned usage)
{
struct pipe_winsys *ws = screen->winsys;
struct cell_texture *spt = cell_texture(pt);
@@ -157,7 +174,7 @@ cell_get_tex_surface_screen(struct pipe_screen *screen,
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe_buffer_reference(ws, &ps->buffer, spt->buffer);
+ winsys_buffer_reference(ws, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->block = pt->block;
ps->width = pt->width[level];
@@ -166,12 +183,21 @@ cell_get_tex_surface_screen(struct pipe_screen *screen,
ps->nblocksy = pt->nblocksy[level];
ps->stride = spt->stride[level];
ps->offset = spt->level_offset[level];
+ ps->usage = usage;
+
+ /* XXX may need to override usage flags (see sp_texture.c) */
+
+ pipe_texture_reference(&ps->texture, pt);
+ 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;
- } else {
+ }
+ else {
assert(face == 0);
assert(zslice == 0);
}
@@ -181,6 +207,11 @@ cell_get_tex_surface_screen(struct pipe_screen *screen,
+/**
+ * Copy tile data from linear layout to tiled layout.
+ * XXX this should be rolled into the future surface-creation code.
+ * XXX also need "untile" code...
+ */
static void
tile_copy_data(uint w, uint h, uint tile_size, uint *dst, const uint *src)
{
@@ -211,6 +242,7 @@ tile_copy_data(uint w, uint h, uint tile_size, uint *dst, const uint *src)
/**
* Convert linear texture image data to tiled format for SPU usage.
+ * XXX recast this in terms of pipe_surfaces (aka texture views).
*/
static void
cell_tile_texture(struct cell_context *cell,
@@ -228,10 +260,11 @@ cell_tile_texture(struct cell_context *cell,
assert(w % TILE_SIZE == 0);
assert(h % TILE_SIZE == 0);
- surf = screen->get_tex_surface(screen, &texture->base, face, level, zslice);
+ surf = screen->get_tex_surface(screen, &texture->base, face, level, zslice,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
ASSERT(surf);
- src = (const uint *) pipe_surface_map(surf);
+ src = (const uint *) pipe_surface_map(surf, PIPE_BUFFER_USAGE_CPU_WRITE);
if (texture->tiled_data) {
align_free(texture->tiled_data);
@@ -246,11 +279,12 @@ cell_tile_texture(struct cell_context *cell,
}
-
void
cell_update_texture_mapping(struct cell_context *cell)
{
+#if 0
uint face = 0, level = 0, zslice = 0;
+#endif
uint i;
for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
@@ -275,16 +309,79 @@ cell_update_texture_mapping(struct cell_context *cell)
}
+static void
+cell_tex_surface_release(struct pipe_screen *screen,
+ struct pipe_surface **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 ((*s)->texture);
+ pipe_texture_reference(&(*s)->texture, NULL);
+
+ screen->winsys->surface_release(screen->winsys, s);
+}
+
+
+static void *
+cell_surface_map( struct pipe_screen *screen,
+ struct pipe_surface *surface,
+ unsigned flags )
+{
+ ubyte *map;
+
+ if (flags & ~surface->usage) {
+ assert(0);
+ return NULL;
+ }
+
+ map = pipe_buffer_map( screen, surface->buffer, flags );
+ if (map == NULL)
+ return NULL;
+
+ /* May want to different things here depending on read/write nature
+ * of the map:
+ */
+ if (surface->texture &&
+ (flags & PIPE_BUFFER_USAGE_CPU_WRITE))
+ {
+ /* Do something to notify sharing contexts of a texture change.
+ * In softpipe, that would mean flushing the texture cache.
+ */
+#if 0
+ cell_screen(screen)->timestamp++;
+#endif
+ }
+
+ return map + surface->offset;
+}
+
+
+static void
+cell_surface_unmap(struct pipe_screen *screen,
+ struct pipe_surface *surface)
+{
+ pipe_buffer_unmap( screen, surface->buffer );
+}
+
+
void
cell_init_texture_functions(struct cell_context *cell)
{
- cell->pipe.texture_update = cell_texture_update;
+ /*cell->pipe.texture_update = cell_texture_update;*/
}
+
void
cell_init_screen_texture_funcs(struct pipe_screen *screen)
{
- screen->texture_create = cell_texture_create_screen;
- screen->texture_release = cell_texture_release_screen;
- screen->get_tex_surface = cell_get_tex_surface_screen;
+ screen->texture_create = cell_texture_create;
+ screen->texture_release = cell_texture_release;
+
+ screen->get_tex_surface = cell_get_tex_surface;
+ screen->tex_surface_release = cell_tex_surface_release;
+
+ screen->surface_map = cell_surface_map;
+ screen->surface_unmap = cell_surface_unmap;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h
index fcee069..6d37e95 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.h
+++ b/src/gallium/drivers/cell/ppu/cell_texture.h
@@ -41,6 +41,7 @@ struct cell_texture
struct pipe_texture base;
unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS];
+ unsigned long stride[PIPE_MAX_TEXTURE_LEVELS];
/* The data is held here:
*/
diff --git a/src/gallium/drivers/cell/ppu/cell_vbuf.c b/src/gallium/drivers/cell/ppu/cell_vbuf.c
index 3a181b5..aa63435 100644
--- a/src/gallium/drivers/cell/ppu/cell_vbuf.c
+++ b/src/gallium/drivers/cell/ppu/cell_vbuf.c
@@ -26,6 +26,11 @@
**************************************************************************/
/**
+ * Vertex buffer code. The draw module transforms vertices to window
+ * coords, etc. and emits the vertices into buffer supplied by this module.
+ * When a vertex buffer is full, or we flush, we'll send the vertex data
+ * to the SPUs.
+ *
* Authors
* Brian Paul
*/
@@ -37,6 +42,7 @@
#include "cell_spu.h"
#include "cell_vbuf.h"
#include "draw/draw_vbuf.h"
+#include "util/u_memory.h"
/** Allow vertex data to be inlined after RENDER command */
@@ -112,7 +118,7 @@ cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
}
cvbr->vertex_buf = ~0;
- cell_flush_int(&cell->pipe, 0x0);
+ cell_flush_int(cell, 0x0);
assert(vertices == cvbr->vertex_buffer);
cvbr->vertex_buffer = NULL;
@@ -120,12 +126,13 @@ cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
-static void
+static boolean
cell_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
{
struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
cvbr->prim = prim;
/*printf("cell_set_prim %u\n", prim);*/
+ return TRUE;
}
@@ -243,7 +250,7 @@ cell_vbuf_draw(struct vbuf_render *vbr,
#if 0
/* helpful for debug */
- cell_flush_int(&cell->pipe, CELL_FLUSH_WAIT);
+ cell_flush_int(cell, CELL_FLUSH_WAIT);
#endif
}
diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c b/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
index 49d5443..2ece025 100644
--- a/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
+++ b/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
@@ -260,6 +260,7 @@ emit_fetch(struct spe_function *p,
void cell_update_vertex_fetch(struct draw_context *draw)
{
+#if 0
struct cell_context *const cell =
(struct cell_context *) draw->driver_private;
struct spe_function *p = &cell->attrib_fetch;
@@ -337,4 +338,7 @@ void cell_update_vertex_fetch(struct draw_context *draw)
cell->attrib_fetch_offsets[function_index[i]];
}
}
+#else
+ assert(0);
+#endif
}
diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
index f753960..2b10c11 100644
--- a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
@@ -32,6 +32,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
@@ -50,6 +51,7 @@
void
cell_vertex_shader_queue_flush(struct draw_context *draw)
{
+#if 0
struct cell_context *const cell =
(struct cell_context *) draw->driver_private;
struct cell_command_vs *const vs = &cell_global.command[0].vs;
@@ -133,9 +135,12 @@ cell_vertex_shader_queue_flush(struct draw_context *draw)
vs->num_elts = n;
send_mbox_message(cell_global.spe_contexts[0], CELL_CMD_VS_EXECUTE);
- cell_flush_int(& cell->pipe, CELL_FLUSH_WAIT);
+ cell_flush_int(cell, CELL_FLUSH_WAIT);
}
draw->vs.post_nr = draw->vs.queue_nr;
draw->vs.queue_nr = 0;
+#else
+ assert(0);
+#endif
}
diff --git a/src/gallium/drivers/cell/ppu/cell_winsys.c b/src/gallium/drivers/cell/ppu/cell_winsys.c
index ebabce3..d570bbd 100644
--- a/src/gallium/drivers/cell/ppu/cell_winsys.c
+++ b/src/gallium/drivers/cell/ppu/cell_winsys.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "cell_winsys.h"
diff --git a/src/gallium/drivers/cell/spu/Makefile b/src/gallium/drivers/cell/spu/Makefile
index 8e83610..d49abb2 100644
--- a/src/gallium/drivers/cell/spu/Makefile
+++ b/src/gallium/drivers/cell/spu/Makefile
@@ -5,7 +5,7 @@
TOP = ../../../../..
-include $(TOP)/configs/linux-cell
+include $(TOP)/configs/current
PROG = g3d
diff --git a/src/gallium/drivers/cell/spu/spu_exec.c b/src/gallium/drivers/cell/spu/spu_exec.c
index 42e5022..e27df2d 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.c
+++ b/src/gallium/drivers/cell/spu/spu_exec.c
@@ -63,7 +63,6 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
@@ -383,10 +382,10 @@ fetch_src_file_channel(
break;
case TGSI_FILE_IMMEDIATE:
- assert( index->i[0] < (int) mach->ImmLimit );
- assert( index->i[1] < (int) mach->ImmLimit );
- assert( index->i[2] < (int) mach->ImmLimit );
- assert( index->i[3] < (int) mach->ImmLimit );
+ ASSERT( index->i[0] < (int) mach->ImmLimit );
+ ASSERT( index->i[1] < (int) mach->ImmLimit );
+ ASSERT( index->i[2] < (int) mach->ImmLimit );
+ ASSERT( index->i[3] < (int) mach->ImmLimit );
chan->f[0] = mach->Imms[index->i[0]][swizzle];
chan->f[1] = mach->Imms[index->i[1]][swizzle];
@@ -410,7 +409,7 @@ fetch_src_file_channel(
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
break;
@@ -423,7 +422,7 @@ fetch_src_file_channel(
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
}
@@ -472,7 +471,7 @@ fetch_source(
index.q = si_shli(index.q, 12);
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
index.i[0] += reg->SrcRegisterDim.Index;
@@ -559,7 +558,7 @@ store_dest(
break;
default:
- assert( 0 );
+ ASSERT( 0 );
return;
}
@@ -583,11 +582,11 @@ store_dest(
break;
case TGSI_SAT_MINUS_PLUS_ONE:
- assert( 0 );
+ ASSERT( 0 );
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
}
@@ -770,7 +769,7 @@ exec_tex(struct spu_exec_machine *mach,
break;
default:
- assert (0);
+ ASSERT (0);
}
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
@@ -862,7 +861,7 @@ exec_declaration(struct spu_exec_machine *mach,
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
if( mask == TGSI_WRITEMASK_XYZW ) {
@@ -972,11 +971,11 @@ exec_instruction(
break;
case TGSI_OPCODE_EXP:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_LOG:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_MUL:
@@ -1152,24 +1151,24 @@ exec_instruction(
break;
case TGSI_OPCODE_CND:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_CND0:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_DOT2ADD:
/* TGSI_OPCODE_DP2A */
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_INDEX:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_NEGATE:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_FRAC:
@@ -1182,7 +1181,7 @@ exec_instruction(
break;
case TGSI_OPCODE_CLAMP:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_FLOOR:
@@ -1277,7 +1276,7 @@ exec_instruction(
break;
case TGSI_OPCODE_MULTIPLYMATRIX:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_ABS:
@@ -1291,7 +1290,7 @@ exec_instruction(
break;
case TGSI_OPCODE_RCC:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_DPH:
@@ -1354,23 +1353,23 @@ exec_instruction(
break;
case TGSI_OPCODE_PK2H:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_PK2US:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_PK4B:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_PK4UB:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_RFL:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_SEQ:
@@ -1385,7 +1384,7 @@ exec_instruction(
break;
case TGSI_OPCODE_SFL:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_SGT:
@@ -1430,7 +1429,7 @@ exec_instruction(
break;
case TGSI_OPCODE_STR:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_TEX:
@@ -1453,7 +1452,7 @@ exec_instruction(
/* src[1] = d[strq]/dx */
/* src[2] = d[strq]/dy */
/* src[3] = sampler unit */
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_TXL:
@@ -1471,35 +1470,35 @@ exec_instruction(
break;
case TGSI_OPCODE_UP2H:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_UP2US:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_UP4B:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_UP4UB:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_X2D:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_ARA:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_ARR:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_BRA:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_CAL:
@@ -1508,14 +1507,14 @@ exec_instruction(
/* do the call */
/* push the Cond, Loop, Cont stacks */
- assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
+ ASSERT(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
mach->CondStack[mach->CondStackTop++] = mach->CondMask;
- assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ ASSERT(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
- assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ ASSERT(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->ContStack[mach->ContStackTop++] = mach->ContMask;
- assert(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING);
+ ASSERT(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING);
mach->FuncStack[mach->FuncStackTop++] = mach->FuncMask;
/* note that PC was already incremented above */
@@ -1539,13 +1538,13 @@ exec_instruction(
*pc = mach->CallStack[--mach->CallStackTop];
/* pop the Cond, Loop, Cont stacks */
- assert(mach->CondStackTop > 0);
+ ASSERT(mach->CondStackTop > 0);
mach->CondMask = mach->CondStack[--mach->CondStackTop];
- assert(mach->LoopStackTop > 0);
+ ASSERT(mach->LoopStackTop > 0);
mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
- assert(mach->ContStackTop > 0);
+ ASSERT(mach->ContStackTop > 0);
mach->ContMask = mach->ContStack[--mach->ContStackTop];
- assert(mach->FuncStackTop > 0);
+ ASSERT(mach->FuncStackTop > 0);
mach->FuncMask = mach->FuncStack[--mach->FuncStackTop];
UPDATE_EXEC_MASK(mach);
@@ -1553,7 +1552,7 @@ exec_instruction(
break;
case TGSI_OPCODE_SSG:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_CMP:
@@ -1593,11 +1592,11 @@ exec_instruction(
break;
case TGSI_OPCODE_NRM:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_DIV:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_DP2:
@@ -1616,7 +1615,7 @@ exec_instruction(
case TGSI_OPCODE_IF:
/* push CondMask */
- assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
+ ASSERT(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
mach->CondStack[mach->CondStackTop++] = mach->CondMask;
FETCH( &r[0], 0, CHAN_X );
/* update CondMask */
@@ -1640,7 +1639,7 @@ exec_instruction(
/* invert CondMask wrt previous mask */
{
uint prevMask;
- assert(mach->CondStackTop > 0);
+ ASSERT(mach->CondStackTop > 0);
prevMask = mach->CondStack[mach->CondStackTop - 1];
mach->CondMask = ~mach->CondMask & prevMask;
UPDATE_EXEC_MASK(mach);
@@ -1650,7 +1649,7 @@ exec_instruction(
case TGSI_OPCODE_ENDIF:
/* pop CondMask */
- assert(mach->CondStackTop > 0);
+ ASSERT(mach->CondStackTop > 0);
mach->CondMask = mach->CondStack[--mach->CondStackTop];
UPDATE_EXEC_MASK(mach);
break;
@@ -1661,19 +1660,19 @@ exec_instruction(
break;
case TGSI_OPCODE_REP:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_ENDREP:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_PUSHA:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_POPA:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_CEIL:
@@ -1747,7 +1746,7 @@ exec_instruction(
break;
case TGSI_OPCODE_MOD:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_XOR:
@@ -1760,15 +1759,15 @@ exec_instruction(
break;
case TGSI_OPCODE_SAD:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_TXF:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_TXQ:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_EMIT:
@@ -1785,9 +1784,9 @@ exec_instruction(
/* fall-through (for now) */
case TGSI_OPCODE_BGNLOOP2:
/* push LoopMask and ContMasks */
- assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ ASSERT(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
- assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ ASSERT(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->ContStack[mach->ContStackTop++] = mach->ContMask;
break;
@@ -1795,7 +1794,7 @@ exec_instruction(
/* fall-through (for now at least) */
case TGSI_OPCODE_ENDLOOP2:
/* Restore ContMask, but don't pop */
- assert(mach->ContStackTop > 0);
+ ASSERT(mach->ContStackTop > 0);
mach->ContMask = mach->ContStack[mach->ContStackTop - 1];
if (mach->LoopMask) {
/* repeat loop: jump to instruction just past BGNLOOP */
@@ -1803,10 +1802,10 @@ exec_instruction(
}
else {
/* exit loop: pop LoopMask */
- assert(mach->LoopStackTop > 0);
+ ASSERT(mach->LoopStackTop > 0);
mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
/* pop ContMask */
- assert(mach->ContStackTop > 0);
+ ASSERT(mach->ContStackTop > 0);
mach->ContMask = mach->ContStack[--mach->ContStackTop];
}
UPDATE_EXEC_MASK(mach);
@@ -1835,26 +1834,26 @@ exec_instruction(
break;
case TGSI_OPCODE_NOISE1:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_NOISE2:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_NOISE3:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_NOISE4:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_NOP:
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
}
@@ -1875,11 +1874,11 @@ spu_exec_machine_run( struct spu_exec_machine *mach )
mach->FuncMask = 0xf;
mach->ExecMask = 0xf;
- mach->CondStackTop = 0; /* temporarily subvert this assertion */
- assert(mach->CondStackTop == 0);
- assert(mach->LoopStackTop == 0);
- assert(mach->ContStackTop == 0);
- assert(mach->CallStackTop == 0);
+ mach->CondStackTop = 0; /* temporarily subvert this ASSERTion */
+ ASSERT(mach->CondStackTop == 0);
+ ASSERT(mach->LoopStackTop == 0);
+ ASSERT(mach->ContStackTop == 0);
+ ASSERT(mach->CallStackTop == 0);
mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0;
diff --git a/src/gallium/drivers/cell/spu/spu_exec.h b/src/gallium/drivers/cell/spu/spu_exec.h
index c68f78f..8605679 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.h
+++ b/src/gallium/drivers/cell/spu/spu_exec.h
@@ -99,7 +99,7 @@ struct spu_exec_machine
* 1 address
*/
struct spu_exec_vector Temps[TGSI_EXEC_NUM_TEMPS
- + TGSI_EXEC_NUM_ADDRS + 1]
+ + TGSI_EXEC_NUM_TEMP_EXTRAS + 1]
ALIGN16_ATTRIB;
struct spu_exec_vector *Addrs;
diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c
index e04ffeb..d223f32 100644
--- a/src/gallium/drivers/cell/spu/spu_main.c
+++ b/src/gallium/drivers/cell/spu/spu_main.c
@@ -55,6 +55,10 @@ struct spu_global spu;
struct spu_vs_context draw;
+
+/**
+ * Buffers containing dynamically generated SPU code:
+ */
static unsigned char attribute_fetch_code_buffer[136 * PIPE_MAX_ATTRIBS]
ALIGN16_ATTRIB;
@@ -136,54 +140,75 @@ really_clear_tiles(uint surfaceIndex)
static void
cmd_clear_surface(const struct cell_command_clear_surface *clear)
{
- const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
- uint i;
-
if (Debug)
printf("SPU %u: CLEAR SURF %u to 0x%08x\n", spu.init.id,
clear->surface, clear->value);
-#define CLEAR_OPT 1
-#if CLEAR_OPT
- /* set all tile's status to CLEAR */
if (clear->surface == 0) {
- memset(spu.ctile_status, TILE_STATUS_CLEAR, sizeof(spu.ctile_status));
spu.fb.color_clear_value = clear->value;
+ if (spu.init.debug_flags & CELL_DEBUG_CHECKER) {
+ uint x = (spu.init.id << 4) | (spu.init.id << 12) |
+ (spu.init.id << 20) | (spu.init.id << 28);
+ spu.fb.color_clear_value ^= x;
+ }
}
else {
- memset(spu.ztile_status, TILE_STATUS_CLEAR, sizeof(spu.ztile_status));
spu.fb.depth_clear_value = clear->value;
}
- return;
-#endif
+#define CLEAR_OPT 1
+#if CLEAR_OPT
+
+ /* Simply set all tiles' status to CLEAR.
+ * When we actually begin rendering into a tile, we'll initialize it to
+ * the clear value. If any tiles go untouched during the frame,
+ * really_clear_tiles() will set them to the clear value.
+ */
if (clear->surface == 0) {
- spu.fb.color_clear_value = clear->value;
- clear_c_tile(&spu.ctile);
+ memset(spu.ctile_status, TILE_STATUS_CLEAR, sizeof(spu.ctile_status));
}
else {
- spu.fb.depth_clear_value = clear->value;
- clear_z_tile(&spu.ztile);
+ memset(spu.ztile_status, TILE_STATUS_CLEAR, sizeof(spu.ztile_status));
}
+#else
+
+ /*
+ * This path clears the whole framebuffer to the clear color right now.
+ */
+
/*
printf("SPU: %s num=%d w=%d h=%d\n",
__FUNCTION__, num_tiles, spu.fb.width_tiles, spu.fb.height_tiles);
*/
- for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) {
- uint tx = i % spu.fb.width_tiles;
- uint ty = i / spu.fb.width_tiles;
- if (clear->surface == 0)
- put_tile(tx, ty, &spu.ctile, TAG_SURFACE_CLEAR, 0);
- else
- put_tile(tx, ty, &spu.ztile, TAG_SURFACE_CLEAR, 1);
- /* XXX we don't want this here, but it fixes bad tile results */
+ /* init a single tile to the clear value */
+ if (clear->surface == 0) {
+ clear_c_tile(&spu.ctile);
+ }
+ else {
+ clear_z_tile(&spu.ztile);
}
-#if 0
- wait_on_mask(1 << TAG_SURFACE_CLEAR);
-#endif
+ /* walk over my tiles, writing the 'clear' tile's data */
+ {
+ const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
+ uint i;
+ for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) {
+ uint tx = i % spu.fb.width_tiles;
+ uint ty = i / spu.fb.width_tiles;
+ if (clear->surface == 0)
+ put_tile(tx, ty, &spu.ctile, TAG_SURFACE_CLEAR, 0);
+ else
+ put_tile(tx, ty, &spu.ztile, TAG_SURFACE_CLEAR, 1);
+ }
+ }
+
+ if (spu.init.debug_flags & CELL_DEBUG_SYNC) {
+ wait_on_mask(1 << TAG_SURFACE_CLEAR);
+ }
+
+#endif /* CLEAR_OPT */
if (Debug)
printf("SPU %u: CLEAR SURF done\n", spu.init.id);
@@ -312,6 +337,21 @@ cmd_state_depth_stencil(const struct cell_command_depth_stencil_alpha_test *stat
static void
+cmd_state_logicop(const struct cell_command_logicop * code)
+{
+ mfc_get(logicop_code_buffer,
+ (unsigned int) code->base, /* src */
+ code->size,
+ TAG_BATCH_BUFFER,
+ 0, /* tid */
+ 0 /* rid */);
+ wait_on_mask(1 << TAG_BATCH_BUFFER);
+
+ spu.logicop = (logicop_func) logicop_code_buffer;
+}
+
+
+static void
cmd_state_sampler(const struct cell_command_sampler *sampler)
{
if (Debug)
@@ -381,6 +421,21 @@ cmd_state_vs_array_info(const struct cell_array_info *vs_info)
static void
+cmd_state_attrib_fetch(const struct cell_attribute_fetch_code *code)
+{
+ mfc_get(attribute_fetch_code_buffer,
+ (unsigned int) code->base, /* src */
+ code->size,
+ TAG_BATCH_BUFFER,
+ 0, /* tid */
+ 0 /* rid */);
+ wait_on_mask(1 << TAG_BATCH_BUFFER);
+
+ draw.vertex_fetch.code = attribute_fetch_code_buffer;
+}
+
+
+static void
cmd_finish(void)
{
if (Debug)
@@ -518,38 +573,15 @@ cmd_batch(uint opcode)
(struct cell_shader_info *) &buffer[pos+1]);
pos += (1 + ROUNDUP8(sizeof(struct cell_shader_info)) / 8);
break;
- case CELL_CMD_STATE_ATTRIB_FETCH: {
- struct cell_attribute_fetch_code *code =
- (struct cell_attribute_fetch_code *) &buffer[pos+1];
-
- mfc_get(attribute_fetch_code_buffer,
- (unsigned int) code->base, /* src */
- code->size,
- TAG_BATCH_BUFFER,
- 0, /* tid */
- 0 /* rid */);
- wait_on_mask(1 << TAG_BATCH_BUFFER);
-
- draw.vertex_fetch.code = attribute_fetch_code_buffer;
+ case CELL_CMD_STATE_ATTRIB_FETCH:
+ cmd_state_attrib_fetch((struct cell_attribute_fetch_code *)
+ &buffer[pos+1]);
pos += (1 + ROUNDUP8(sizeof(struct cell_attribute_fetch_code)) / 8);
break;
- }
- case CELL_CMD_STATE_LOGICOP: {
- struct cell_command_logicop *code =
- (struct cell_command_logicop *) &buffer[pos+1];
-
- mfc_get(logicop_code_buffer,
- (unsigned int) code->base, /* src */
- code->size,
- TAG_BATCH_BUFFER,
- 0, /* tid */
- 0 /* rid */);
- wait_on_mask(1 << TAG_BATCH_BUFFER);
-
- spu.logicop = (logicop_func) logicop_code_buffer;
+ case CELL_CMD_STATE_LOGICOP:
+ cmd_state_logicop((struct cell_command_logicop *) &buffer[pos+1]);
pos += (1 + ROUNDUP8(sizeof(struct cell_command_logicop)) / 8);
break;
- }
case CELL_CMD_FLUSH_BUFFER_RANGE: {
struct cell_buffer_range *br = (struct cell_buffer_range *)
&buffer[pos+1];
diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h
index e962e14..4879f8c 100644
--- a/src/gallium/drivers/cell/spu/spu_main.h
+++ b/src/gallium/drivers/cell/spu/spu_main.h
@@ -124,13 +124,13 @@ struct spu_global
struct spu_framebuffer fb;
boolean read_depth;
boolean read_stencil;
- frag_test_func frag_test;
+ frag_test_func frag_test; /**< Current depth/stencil test code */
- boolean read_fb;
- blend_func blend;
+ boolean read_fb; /**< Does current blend mode require framebuffer read? */
+ blend_func blend; /**< Current blend code */
qword const_blend_color[4] ALIGN16_ATTRIB;
- logicop_func logicop;
+ logicop_func logicop; /**< Current logicop code **/
struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS];
struct spu_texture texture[PIPE_MAX_SAMPLERS];
diff --git a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
index b4cffee..c0a729b 100644
--- a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
+++ b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
@@ -95,7 +95,7 @@ read_ds_quad(tile_t *buffer, unsigned x, unsigned y,
default:
- assert(0);
+ ASSERT(0);
break;
}
}
@@ -153,7 +153,7 @@ write_ds_quad(tile_t *buffer, unsigned x, unsigned y,
default:
- assert(0);
+ ASSERT(0);
break;
}
}
diff --git a/src/gallium/drivers/cell/spu/spu_render.c b/src/gallium/drivers/cell/spu/spu_render.c
index 6df59ab..305dc98 100644
--- a/src/gallium/drivers/cell/spu/spu_render.c
+++ b/src/gallium/drivers/cell/spu/spu_render.c
@@ -35,7 +35,7 @@
#include "spu_tri.h"
#include "spu_tile.h"
#include "cell/common.h"
-
+#include "util/u_memory.h"
/**
diff --git a/src/gallium/drivers/cell/spu/spu_tile.c b/src/gallium/drivers/cell/spu/spu_tile.c
index 12dc246..216a331 100644
--- a/src/gallium/drivers/cell/spu/spu_tile.c
+++ b/src/gallium/drivers/cell/spu/spu_tile.c
@@ -31,6 +31,9 @@
#include "spu_main.h"
+/**
+ * Get tile of color or Z values from main memory, put into SPU memory.
+ */
void
get_tile(uint tx, uint ty, tile_t *tile, int tag, int zBuf)
{
@@ -56,6 +59,9 @@ get_tile(uint tx, uint ty, tile_t *tile, int tag, int zBuf)
}
+/**
+ * Move tile of color or Z values from SPU memory to main memory.
+ */
void
put_tile(uint tx, uint ty, const tile_t *tile, int tag, int zBuf)
{
diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c
index ab4ff81..2a4e0b4 100644
--- a/src/gallium/drivers/cell/spu/spu_tri.c
+++ b/src/gallium/drivers/cell/spu/spu_tri.c
@@ -32,7 +32,7 @@
#include <transpose_matrix4x4.h>
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
#include "spu_colorpack.h"
#include "spu_main.h"
#include "spu_texture.h"
diff --git a/src/gallium/drivers/cell/spu/spu_util.c b/src/gallium/drivers/cell/spu/spu_util.c
index 74ab2bb..b8a0d4a 100644
--- a/src/gallium/drivers/cell/spu/spu_util.c
+++ b/src/gallium/drivers/cell/spu/spu_util.c
@@ -1,5 +1,7 @@
-#include "pipe/p_util.h"
+
+#include "cell/common.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_debug.h"
#include "tgsi/tgsi_parse.h"
//#include "tgsi_build.h"
#include "tgsi/tgsi_util.h"
@@ -19,7 +21,7 @@ tgsi_util_get_src_register_swizzle(
case 3:
return reg->SwizzleW;
default:
- assert( 0 );
+ ASSERT( 0 );
}
return 0;
}
@@ -39,7 +41,7 @@ tgsi_util_get_src_register_extswizzle(
case 3:
return reg->ExtSwizzleW;
default:
- assert( 0 );
+ ASSERT( 0 );
}
return 0;
}
@@ -59,12 +61,12 @@ tgsi_util_get_full_src_register_extswizzle(
&reg->SrcRegisterExtSwz,
component );
- assert (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
- assert (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
- assert (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
- assert (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
- assert (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
- assert (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
+ ASSERT (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
+ ASSERT (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
+ ASSERT (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
+ ASSERT (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
+ ASSERT (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
+ ASSERT (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
/*
* Second, calculate the simple swizzle for the unswizzled channel index.
@@ -94,7 +96,7 @@ tgsi_util_get_src_register_extnegate(
case 3:
return reg->NegateW;
default:
- assert( 0 );
+ ASSERT( 0 );
}
return 0;
}
@@ -119,7 +121,7 @@ tgsi_util_set_src_register_extnegate(
reg->NegateW = negate;
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
}
diff --git a/src/gallium/drivers/cell/spu/spu_vertex_fetch.c b/src/gallium/drivers/cell/spu/spu_vertex_fetch.c
index 219fd90..03375d8 100644
--- a/src/gallium/drivers/cell/spu/spu_vertex_fetch.c
+++ b/src/gallium/drivers/cell/spu/spu_vertex_fetch.c
@@ -32,7 +32,6 @@
* Ian Romanick <idr@us.ibm.com>
*/
-#include "pipe/p_util.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
#include "spu_exec.h"
@@ -93,7 +92,7 @@ static void generic_vertex_fetch(struct spu_vs_context *draw,
unsigned nr_attrs = draw->vertex_fetch.nr_attrs;
unsigned attr;
- assert(count <= 4);
+ ASSERT(count <= 4);
#if DRAW_DBG
printf("SPU: %s count = %u, nr_attrs = %u\n",
diff --git a/src/gallium/drivers/cell/spu/spu_vertex_shader.c b/src/gallium/drivers/cell/spu/spu_vertex_shader.c
index 3119a78..fbe5b34 100644
--- a/src/gallium/drivers/cell/spu/spu_vertex_shader.c
+++ b/src/gallium/drivers/cell/spu/spu_vertex_shader.c
@@ -34,16 +34,37 @@
#include <spu_mfcio.h>
-#include "pipe/p_util.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
-#include "spu_vertex_shader.h"
-#include "spu_exec.h"
+#include "util/u_math.h"
#include "draw/draw_private.h"
#include "draw/draw_context.h"
#include "cell/common.h"
+#include "spu_vertex_shader.h"
+#include "spu_exec.h"
#include "spu_main.h"
+
+#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
+
+
+#define CLIP_RIGHT_BIT 0x01
+#define CLIP_LEFT_BIT 0x02
+#define CLIP_TOP_BIT 0x04
+#define CLIP_BOTTOM_BIT 0x08
+#define CLIP_FAR_BIT 0x10
+#define CLIP_NEAR_BIT 0x20
+
+
+static INLINE float
+dot4(const float *a, const float *b)
+{
+ return (a[0]*b[0] +
+ a[1]*b[1] +
+ a[2]*b[2] +
+ a[3]*b[3]);
+}
+
static INLINE unsigned
compute_clipmask(const float *clip, /*const*/ float plane[][4], unsigned nr)
{
@@ -91,7 +112,7 @@ run_vertex_program(struct spu_vs_context *draw,
const float *scale = draw->viewport.scale;
const float *trans = draw->viewport.translate;
- assert(count <= 4);
+ ASSERT(count <= 4);
machine->Processor = TGSI_PROCESSOR_VERTEX;
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 014a3e3..10c4ffc 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -28,7 +28,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_context.h"
#include "fo_context.h"
diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c
index e3d1901..6dd3eda 100644
--- a/src/gallium/drivers/i915simple/i915_context.c
+++ b/src/gallium/drivers/i915simple/i915_context.c
@@ -35,7 +35,8 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
#include "pipe/p_screen.h"
@@ -45,7 +46,7 @@ static void i915_destroy( struct pipe_context *pipe )
draw_destroy( i915->draw );
- if(i915->winsys)
+ if(i915->winsys->destroy)
i915->winsys->destroy(i915->winsys);
FREE( i915 );
@@ -72,7 +73,7 @@ i915_draw_range_elements(struct pipe_context *pipe,
*/
for (i = 0; i < i915->num_vertex_buffers; i++) {
void *buf
- = pipe->winsys->buffer_map(pipe->winsys,
+ = pipe_buffer_map(pipe->screen,
i915->vertex_buffer[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, i, buf);
@@ -80,7 +81,7 @@ i915_draw_range_elements(struct pipe_context *pipe,
/* Map index buffer, if present */
if (indexBuffer) {
void *mapped_indexes
- = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
+ = pipe_buffer_map(pipe->screen, indexBuffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer_range(draw, indexSize,
min_index,
@@ -105,11 +106,11 @@ i915_draw_range_elements(struct pipe_context *pipe,
* unmap vertex/index buffers
*/
for (i = 0; i < i915->num_vertex_buffers; i++) {
- pipe->winsys->buffer_unmap(pipe->winsys, i915->vertex_buffer[i].buffer);
+ pipe_buffer_unmap(pipe->screen, i915->vertex_buffer[i].buffer);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
if (indexBuffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+ pipe_buffer_unmap(pipe->screen, indexBuffer);
draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL);
}
diff --git a/src/gallium/drivers/i915simple/i915_debug_fp.c b/src/gallium/drivers/i915simple/i915_debug_fp.c
index c024a05..48be3e1 100644
--- a/src/gallium/drivers/i915simple/i915_debug_fp.c
+++ b/src/gallium/drivers/i915simple/i915_debug_fp.c
@@ -29,7 +29,7 @@
#include "i915_reg.h"
#include "i915_debug.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
static void
diff --git a/src/gallium/drivers/i915simple/i915_fpc.h b/src/gallium/drivers/i915simple/i915_fpc.h
index 80a9576..2f0f99d 100644
--- a/src/gallium/drivers/i915simple/i915_fpc.h
+++ b/src/gallium/drivers/i915simple/i915_fpc.h
@@ -29,7 +29,6 @@
#ifndef I915_FPC_H
#define I915_FPC_H
-#include "pipe/p_util.h"
#include "i915_context.h"
#include "i915_reg.h"
diff --git a/src/gallium/drivers/i915simple/i915_fpc_emit.c b/src/gallium/drivers/i915simple/i915_fpc_emit.c
index 4bdeefb..b054ce4 100644
--- a/src/gallium/drivers/i915simple/i915_fpc_emit.c
+++ b/src/gallium/drivers/i915simple/i915_fpc_emit.c
@@ -28,6 +28,7 @@
#include "i915_reg.h"
#include "i915_context.h"
#include "i915_fpc.h"
+#include "util/u_math.h"
#define A0_DEST( reg ) (((reg)&UREG_TYPE_NR_MASK)>>UREG_A0_DEST_SHIFT_LEFT)
diff --git a/src/gallium/drivers/i915simple/i915_fpc_translate.c b/src/gallium/drivers/i915simple/i915_fpc_translate.c
index 6443298..34b4a84 100644
--- a/src/gallium/drivers/i915simple/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915simple/i915_fpc_translate.c
@@ -33,6 +33,8 @@
#include "i915_fpc.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "util/u_string.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_dump.h"
diff --git a/src/gallium/drivers/i915simple/i915_prim_emit.c b/src/gallium/drivers/i915simple/i915_prim_emit.c
index 9ffa460..d194c2f 100644
--- a/src/gallium/drivers/i915simple/i915_prim_emit.c
+++ b/src/gallium/drivers/i915simple/i915_prim_emit.c
@@ -27,7 +27,9 @@
#include "draw/draw_pipe.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_pack_color.h"
#include "i915_context.h"
#include "i915_winsys.h"
diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
index aef3682..4fda1ab 100644
--- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
@@ -41,9 +41,10 @@
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "i915_context.h"
#include "i915_reg.h"
@@ -114,7 +115,7 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
{
struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
struct i915_context *i915 = i915_render->i915;
- struct pipe_winsys *winsys = i915->pipe.winsys;
+ struct pipe_screen *screen = i915->pipe.screen;
size_t size = (size_t)vertex_size * (size_t)nr_vertices;
/* FIXME: handle failure */
@@ -123,20 +124,20 @@ 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(winsys, &i915_render->vbo, NULL);
+ pipe_buffer_reference(screen, &i915_render->vbo, NULL);
}
if (!i915_render->vbo) {
i915_render->vbo_size = MAX2(size, i915_render->vbo_alloc_size);
i915_render->vbo_offset = 0;
- i915_render->vbo = winsys->buffer_create(winsys,
- 64,
- I915_BUFFER_USAGE_LIT_VERTEX,
- i915_render->vbo_size);
- i915_render->vbo_ptr = winsys->buffer_map(winsys,
- i915_render->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- winsys->buffer_unmap(winsys, i915_render->vbo);
+ i915_render->vbo = pipe_buffer_create(screen,
+ 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->vbo = i915_render->vbo;
@@ -487,7 +488,7 @@ static struct vbuf_render *
i915_vbuf_render_create( struct i915_context *i915 )
{
struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render);
- struct pipe_winsys *winsys = i915->pipe.winsys;
+ struct pipe_screen *screen = i915->pipe.screen;
i915_render->i915 = i915;
@@ -509,14 +510,14 @@ i915_vbuf_render_create( struct i915_context *i915 )
i915_render->vbo_alloc_size = 128 * 4096;
i915_render->vbo_size = i915_render->vbo_alloc_size;
i915_render->vbo_offset = 0;
- i915_render->vbo = winsys->buffer_create(winsys,
- 64,
- I915_BUFFER_USAGE_LIT_VERTEX,
- i915_render->vbo_size);
- i915_render->vbo_ptr = winsys->buffer_map(winsys,
- i915_render->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- winsys->buffer_unmap(winsys, i915_render->vbo);
+ i915_render->vbo = pipe_buffer_create(screen,
+ 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);
return &i915_render->base;
}
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
index 0afa17b..1c97608 100644
--- a/src/gallium/drivers/i915simple/i915_screen.c
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -26,8 +26,9 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "util/u_string.h"
#include "i915_reg.h"
@@ -207,7 +208,7 @@ i915_surface_map( struct pipe_screen *screen,
struct pipe_surface *surface,
unsigned flags )
{
- char *map = screen->winsys->buffer_map( screen->winsys, surface->buffer, flags );
+ char *map = pipe_buffer_map( screen, surface->buffer, flags );
if (map == NULL)
return NULL;
@@ -226,7 +227,7 @@ static void
i915_surface_unmap(struct pipe_screen *screen,
struct pipe_surface *surface)
{
- screen->winsys->buffer_unmap( screen->winsys, surface->buffer );
+ pipe_buffer_unmap( screen, surface->buffer );
}
diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c
index e8521b3..d2487d8 100644
--- a/src/gallium/drivers/i915simple/i915_state.c
+++ b/src/gallium/drivers/i915simple/i915_state.c
@@ -31,8 +31,9 @@
#include "draw/draw_context.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "tgsi/tgsi_parse.h"
#include "i915_context.h"
diff --git a/src/gallium/drivers/i915simple/i915_state_derived.c b/src/gallium/drivers/i915simple/i915_state_derived.c
index 4daccec..4886150 100644
--- a/src/gallium/drivers/i915simple/i915_state_derived.c
+++ b/src/gallium/drivers/i915simple/i915_state_derived.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
diff --git a/src/gallium/drivers/i915simple/i915_state_dynamic.c b/src/gallium/drivers/i915simple/i915_state_dynamic.c
index 8cfbddd..86126a5 100644
--- a/src/gallium/drivers/i915simple/i915_state_dynamic.c
+++ b/src/gallium/drivers/i915simple/i915_state_dynamic.c
@@ -30,7 +30,9 @@
#include "i915_context.h"
#include "i915_reg.h"
#include "i915_state.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_pack_color.h"
#define FILE_DEBUG_FLAG DEBUG_STATE
diff --git a/src/gallium/drivers/i915simple/i915_state_immediate.c b/src/gallium/drivers/i915simple/i915_state_immediate.c
index 2501f2d..8c16bb4 100644
--- a/src/gallium/drivers/i915simple/i915_state_immediate.c
+++ b/src/gallium/drivers/i915simple/i915_state_immediate.c
@@ -33,7 +33,7 @@
#include "i915_context.h"
#include "i915_state.h"
#include "i915_reg.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/* All state expressable with the LOAD_STATE_IMMEDIATE_1 packet.
diff --git a/src/gallium/drivers/i915simple/i915_state_sampler.c b/src/gallium/drivers/i915simple/i915_state_sampler.c
index 7868f21..c09c106 100644
--- a/src/gallium/drivers/i915simple/i915_state_sampler.c
+++ b/src/gallium/drivers/i915simple/i915_state_sampler.c
@@ -27,7 +27,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "i915_state_inlines.h"
#include "i915_context.h"
diff --git a/src/gallium/drivers/i915simple/i915_surface.c b/src/gallium/drivers/i915simple/i915_surface.c
index 4430e81..62f1926 100644
--- a/src/gallium/drivers/i915simple/i915_surface.c
+++ b/src/gallium/drivers/i915simple/i915_surface.c
@@ -30,10 +30,10 @@
#include "i915_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
+#include "util/u_rect.h"
/* Assumes all values are within bounds -- no checking at this level -
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index cf4964b..bd87217 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -34,8 +34,9 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "i915_context.h"
#include "i915_texture.h"
@@ -79,7 +80,7 @@ static unsigned
power_of_two(unsigned x)
{
unsigned value = 1;
- while (value <= x)
+ while (value < x)
value = value << 1;
return value;
}
@@ -206,7 +207,7 @@ i945_miptree_layout_2d( struct i915_texture *tex )
unsigned nblocksy = pt->nblocksy[0];
#if 0 /* used for tiled display targets */
- if (pt->last_level == 0 && pt->cpp == 4)
+ if (pt->last_level == 0 && pt->block.size == 4)
if (i915_displaytarget_layout(tex))
return;
#endif
@@ -220,7 +221,7 @@ i945_miptree_layout_2d( struct i915_texture *tex )
*/
if (pt->last_level > 0) {
unsigned mip1_nblocksx
- = align_int(pf_get_nblocksx(&pt->block, minify(width)), align_x)
+ = align(pf_get_nblocksx(&pt->block, minify(width)), align_x)
+ pf_get_nblocksx(&pt->block, minify(minify(width)));
if (mip1_nblocksx > nblocksx)
@@ -229,14 +230,14 @@ i945_miptree_layout_2d( struct i915_texture *tex )
/* Pitch must be a whole number of dwords
*/
- tex->stride = align_int(tex->stride, 64);
+ tex->stride = align(tex->stride, 64);
tex->total_nblocksy = 0;
for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_level_info(tex, level, 1, width, height, 1);
i915_miptree_set_image_offset(tex, level, 0, x, y);
- nblocksy = align_int(nblocksy, align_y);
+ nblocksy = align(nblocksy, align_y);
/* Because the images are packed better, the final offset
* might not be the maximal one:
@@ -246,7 +247,7 @@ i945_miptree_layout_2d( struct i915_texture *tex )
/* Layout_below: step right after second mipmap level.
*/
if (level == 1) {
- x += align_int(nblocksx, align_x);
+ x += align(nblocksx, align_x);
}
else {
y += nblocksy;
@@ -644,7 +645,7 @@ i915_texture_release(struct pipe_screen *screen,
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe_buffer_reference(screen->winsys, &tex->buffer, NULL);
+ pipe_buffer_reference(screen, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@@ -683,7 +684,7 @@ i915_get_tex_surface(struct pipe_screen *screen,
ps->refcount = 1;
ps->winsys = ws;
pipe_texture_reference(&ps->texture, pt);
- pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
+ pipe_buffer_reference(screen, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->width = pt->width[level];
ps->height = pt->height[level];
@@ -727,7 +728,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->winsys, &tex->buffer, buffer);
+ pipe_buffer_reference(screen, &tex->buffer, buffer);
return &tex->base;
}
@@ -755,7 +756,7 @@ i915_tex_surface_release(struct pipe_screen *screen,
}
pipe_texture_reference(&surf->texture, NULL);
- pipe_buffer_reference(screen->winsys, &surf->buffer, NULL);
+ pipe_buffer_reference(screen, &surf->buffer, NULL);
FREE(surf);
}
diff --git a/src/gallium/drivers/i965simple/brw_cc.c b/src/gallium/drivers/i965simple/brw_cc.c
index 337e4f9..79d4150 100644
--- a/src/gallium/drivers/i965simple/brw_cc.c
+++ b/src/gallium/drivers/i965simple/brw_cc.c
@@ -29,7 +29,8 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "brw_context.h"
#include "brw_state.h"
@@ -232,8 +233,7 @@ static void upload_cc_unit( struct brw_context *brw )
cc.cc3.alpha_test_func =
brw_translate_compare_func(brw->attribs.DepthStencil->alpha.func);
- UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0],
- brw->attribs.DepthStencil->alpha.ref);
+ cc.cc7.alpha_ref.ub[0] = float_to_ubyte(brw->attribs.DepthStencil->alpha.ref);
cc.cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8;
}
diff --git a/src/gallium/drivers/i965simple/brw_clip_state.c b/src/gallium/drivers/i965simple/brw_clip_state.c
index ea5c05a..8e78dd5 100644
--- a/src/gallium/drivers/i965simple/brw_clip_state.c
+++ b/src/gallium/drivers/i965simple/brw_clip_state.c
@@ -32,7 +32,8 @@
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
static void upload_clip_unit( struct brw_context *brw )
diff --git a/src/gallium/drivers/i965simple/brw_context.c b/src/gallium/drivers/i965simple/brw_context.c
index 8326f7b..96920df 100644
--- a/src/gallium/drivers/i965simple/brw_context.c
+++ b/src/gallium/drivers/i965simple/brw_context.c
@@ -39,7 +39,7 @@
#include "pipe/p_winsys.h"
#include "pipe/p_context.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/i965simple/brw_curbe.c b/src/gallium/drivers/i965simple/brw_curbe.c
index 52bbd52..824ee7f 100644
--- a/src/gallium/drivers/i965simple/brw_curbe.c
+++ b/src/gallium/drivers/i965simple/brw_curbe.c
@@ -39,7 +39,8 @@
#include "brw_wm.h"
#include "pipe/p_state.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#define FILE_DEBUG_FLAG DEBUG_FALLBACKS
diff --git a/src/gallium/drivers/i965simple/brw_draw_upload.c b/src/gallium/drivers/i965simple/brw_draw_upload.c
index 9c0c78c..7c20ea5 100644
--- a/src/gallium/drivers/i965simple/brw_draw_upload.c
+++ b/src/gallium/drivers/i965simple/brw_draw_upload.c
@@ -33,6 +33,7 @@
#include "brw_context.h"
#include "brw_state.h"
+
struct brw_array_state {
union header_union header;
diff --git a/src/gallium/drivers/i965simple/brw_gs_state.c b/src/gallium/drivers/i965simple/brw_gs_state.c
index 3932e9e..5b8016b 100644
--- a/src/gallium/drivers/i965simple/brw_gs_state.c
+++ b/src/gallium/drivers/i965simple/brw_gs_state.c
@@ -34,7 +34,8 @@
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
diff --git a/src/gallium/drivers/i965simple/brw_screen.c b/src/gallium/drivers/i965simple/brw_screen.c
index fadfbf9..ab7cd62 100644
--- a/src/gallium/drivers/i965simple/brw_screen.c
+++ b/src/gallium/drivers/i965simple/brw_screen.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "util/u_string.h"
diff --git a/src/gallium/drivers/i965simple/brw_sf_state.c b/src/gallium/drivers/i965simple/brw_sf_state.c
index 9acd3ea..2a5de61 100644
--- a/src/gallium/drivers/i965simple/brw_sf_state.c
+++ b/src/gallium/drivers/i965simple/brw_sf_state.c
@@ -30,11 +30,12 @@
*/
-
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
static void upload_sf_vp(struct brw_context *brw)
{
diff --git a/src/gallium/drivers/i965simple/brw_shader_info.c b/src/gallium/drivers/i965simple/brw_shader_info.c
index 30f37a9..86d877d 100644
--- a/src/gallium/drivers/i965simple/brw_shader_info.c
+++ b/src/gallium/drivers/i965simple/brw_shader_info.c
@@ -1,7 +1,7 @@
#include "brw_context.h"
#include "brw_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c
index 27ca328..af46cb5 100644
--- a/src/gallium/drivers/i965simple/brw_state.c
+++ b/src/gallium/drivers/i965simple/brw_state.c
@@ -31,7 +31,7 @@
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_dump.h"
diff --git a/src/gallium/drivers/i965simple/brw_state_batch.c b/src/gallium/drivers/i965simple/brw_state_batch.c
index 35db76b..43a1c89 100644
--- a/src/gallium/drivers/i965simple/brw_state_batch.c
+++ b/src/gallium/drivers/i965simple/brw_state_batch.c
@@ -32,7 +32,7 @@
#include "brw_state.h"
#include "brw_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/* A facility similar to the data caching code above, which aims to
* prevent identical commands being issued repeatedly.
diff --git a/src/gallium/drivers/i965simple/brw_state_cache.c b/src/gallium/drivers/i965simple/brw_state_cache.c
index b3a5124..094248f 100644
--- a/src/gallium/drivers/i965simple/brw_state_cache.c
+++ b/src/gallium/drivers/i965simple/brw_state_cache.c
@@ -38,7 +38,7 @@
#include "brw_sf.h"
#include "brw_gs.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
diff --git a/src/gallium/drivers/i965simple/brw_state_pool.c b/src/gallium/drivers/i965simple/brw_state_pool.c
index f3174bf..007dc8f 100644
--- a/src/gallium/drivers/i965simple/brw_state_pool.c
+++ b/src/gallium/drivers/i965simple/brw_state_pool.c
@@ -43,7 +43,8 @@
*/
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "brw_context.h"
#include "brw_state.h"
@@ -91,10 +92,10 @@ static void brw_init_pool( struct brw_context *brw,
pool->size = size;
pool->brw = brw;
- pool->buffer = brw->pipe.winsys->buffer_create(brw->pipe.winsys,
- 4096,
- 0 /* DRM_BO_FLAG_MEM_TT */,
- size);
+ pool->buffer = pipe_buffer_create(brw->pipe.screen,
+ 4096,
+ 0 /* DRM_BO_FLAG_MEM_TT */,
+ size);
}
static void brw_destroy_pool( struct brw_context *brw,
@@ -102,7 +103,7 @@ static void brw_destroy_pool( struct brw_context *brw,
{
struct brw_mem_pool *pool = &brw->pool[pool_id];
- pipe_buffer_reference( pool->brw->pipe.winsys,
+ pipe_buffer_reference( pool->brw->pipe.screen,
&pool->buffer,
NULL );
}
diff --git a/src/gallium/drivers/i965simple/brw_state_upload.c b/src/gallium/drivers/i965simple/brw_state_upload.c
index e727601..bac9161 100644
--- a/src/gallium/drivers/i965simple/brw_state_upload.c
+++ b/src/gallium/drivers/i965simple/brw_state_upload.c
@@ -33,7 +33,7 @@
#include "brw_context.h"
#include "brw_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/* This is used to initialize brw->state.atoms[]. We could use this
* list directly except for a single atom, brw_constant_buffer, which
diff --git a/src/gallium/drivers/i965simple/brw_surface.c b/src/gallium/drivers/i965simple/brw_surface.c
index 0be3dfc..b89756c 100644
--- a/src/gallium/drivers/i965simple/brw_surface.c
+++ b/src/gallium/drivers/i965simple/brw_surface.c
@@ -29,10 +29,10 @@
#include "brw_context.h"
#include "brw_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
+#include "util/u_rect.h"
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.c b/src/gallium/drivers/i965simple/brw_tex_layout.c
index 8c77256..cc0c665 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.c
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.c
@@ -33,16 +33,16 @@
/* Code to layout images in a mipmap tree for i965.
*/
-#include "brw_tex_layout.h"
-
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "brw_context.h"
+#include "brw_tex_layout.h"
+
#define FILE_DEBUG_FLAG DEBUG_TEXTURE
@@ -144,7 +144,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
*/
if (pt->last_level > 0) {
unsigned mip1_nblocksx
- = align_int(pf_get_nblocksx(&pt->block, minify(width)), align_x)
+ = align(pf_get_nblocksx(&pt->block, minify(width)), align_x)
+ pf_get_nblocksx(&pt->block, minify(minify(width)));
if (mip1_nblocksx > nblocksx)
@@ -153,14 +153,14 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
/* Pitch must be a whole number of dwords
*/
- tex->stride = align_int(tex->stride, 64);
+ tex->stride = align(tex->stride, 64);
tex->total_nblocksy = 0;
for (level = 0; level <= pt->last_level; level++) {
intel_miptree_set_level_info(tex, level, 1, x, y, width,
height, 1);
- nblocksy = align_int(nblocksy, align_y);
+ nblocksy = align(nblocksy, align_y);
/* Because the images are packed better, the final offset
* might not be the maximal one:
@@ -170,7 +170,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
/* Layout_below: step right after second mipmap level.
*/
if (level == 1) {
- x += align_int(nblocksx, align_x);
+ x += align(nblocksx, align_x);
}
else {
y += nblocksy;
@@ -330,7 +330,7 @@ brw_texture_release_screen(struct pipe_screen *screen,
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe_buffer_reference(ws, &tex->buffer, NULL);
+ winsys_buffer_reference(ws, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@@ -369,7 +369,7 @@ brw_get_tex_surface_screen(struct pipe_screen *screen,
if (ps) {
assert(ps->format);
assert(ps->refcount);
- pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
+ winsys_buffer_reference(ws, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->width = pt->width[level];
ps->height = pt->height[level];
diff --git a/src/gallium/drivers/i965simple/brw_vs_state.c b/src/gallium/drivers/i965simple/brw_vs_state.c
index c734699..1eaff87 100644
--- a/src/gallium/drivers/i965simple/brw_vs_state.c
+++ b/src/gallium/drivers/i965simple/brw_vs_state.c
@@ -34,7 +34,8 @@
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
static void upload_vs_unit( struct brw_context *brw )
{
diff --git a/src/gallium/drivers/i965simple/brw_wm.c b/src/gallium/drivers/i965simple/brw_wm.c
index 7fc5f59..8de565b 100644
--- a/src/gallium/drivers/i965simple/brw_wm.c
+++ b/src/gallium/drivers/i965simple/brw_wm.c
@@ -35,7 +35,7 @@
#include "brw_wm.h"
#include "brw_eu.h"
#include "brw_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
diff --git a/src/gallium/drivers/i965simple/brw_wm_decl.c b/src/gallium/drivers/i965simple/brw_wm_decl.c
index e6f1a448..d50e66f 100644
--- a/src/gallium/drivers/i965simple/brw_wm_decl.c
+++ b/src/gallium/drivers/i965simple/brw_wm_decl.c
@@ -2,7 +2,8 @@
#include "brw_context.h"
#include "brw_eu.h"
#include "brw_wm.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/i965simple/brw_wm_glsl.c b/src/gallium/drivers/i965simple/brw_wm_glsl.c
index 6a4a5ae..ab6410a 100644
--- a/src/gallium/drivers/i965simple/brw_wm_glsl.c
+++ b/src/gallium/drivers/i965simple/brw_wm_glsl.c
@@ -2,7 +2,8 @@
#include "brw_context.h"
#include "brw_eu.h"
#include "brw_wm.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/i965simple/brw_wm_sampler_state.c b/src/gallium/drivers/i965simple/brw_wm_sampler_state.c
index b9eaee5..52b2909 100644
--- a/src/gallium/drivers/i965simple/brw_wm_sampler_state.c
+++ b/src/gallium/drivers/i965simple/brw_wm_sampler_state.c
@@ -34,7 +34,8 @@
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#define COMPAREFUNC_ALWAYS 0
diff --git a/src/gallium/drivers/i965simple/brw_wm_state.c b/src/gallium/drivers/i965simple/brw_wm_state.c
index f3aa36b..37a9bf9 100644
--- a/src/gallium/drivers/i965simple/brw_wm_state.c
+++ b/src/gallium/drivers/i965simple/brw_wm_state.c
@@ -34,7 +34,8 @@
#include "brw_state.h"
#include "brw_defines.h"
#include "brw_wm.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
/***********************************************************************
* WM unit - fragment programs and rasterization
diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c
index 1236706..dfa46c9 100644
--- a/src/gallium/drivers/softpipe/sp_clear.c
+++ b/src/gallium/drivers/softpipe/sp_clear.c
@@ -31,6 +31,7 @@
#include "pipe/p_defines.h"
+#include "util/u_pack_color.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_surface.h"
@@ -39,8 +40,28 @@
/**
+ * Convert packed pixel from one format to another.
+ */
+static unsigned
+convert_color(enum pipe_format srcFormat, unsigned srcColor,
+ enum pipe_format dstFormat)
+{
+ ubyte r, g, b, a;
+ unsigned dstColor;
+
+ util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a);
+ util_pack_color_ub(r, g, b, a, dstFormat, &dstColor);
+
+ return dstColor;
+}
+
+
+
+/**
* Clear the given surface to the specified value.
* No masking, no scissor (clear entire buffer).
+ * Note: when clearing a color buffer, the clearValue is always
+ * encoded as PIPE_FORMAT_A8R8G8B8_UNORM.
*/
void
softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
@@ -66,7 +87,15 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[i])) {
- sp_tile_cache_clear(softpipe->cbuf_cache[i], clearValue);
+ unsigned cv;
+ if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) {
+ cv = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue,
+ ps->format);
+ }
+ else {
+ cv = clearValue;
+ }
+ sp_tile_cache_clear(softpipe->cbuf_cache[i], cv);
softpipe->framebuffer.cbufs[i]->status = PIPE_SURFACE_STATUS_CLEAR;
}
}
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 626c3a9..cd1e666 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -32,7 +32,8 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_flush.h"
@@ -91,17 +92,19 @@ static void softpipe_destroy( struct pipe_context *pipe )
if (softpipe->draw)
draw_destroy( softpipe->draw );
- softpipe->quad.polygon_stipple->destroy( softpipe->quad.polygon_stipple );
- softpipe->quad.earlyz->destroy( softpipe->quad.earlyz );
- softpipe->quad.shade->destroy( softpipe->quad.shade );
- softpipe->quad.alpha_test->destroy( softpipe->quad.alpha_test );
- softpipe->quad.depth_test->destroy( softpipe->quad.depth_test );
- softpipe->quad.stencil_test->destroy( softpipe->quad.stencil_test );
- softpipe->quad.occlusion->destroy( softpipe->quad.occlusion );
- softpipe->quad.coverage->destroy( softpipe->quad.coverage );
- softpipe->quad.blend->destroy( softpipe->quad.blend );
- softpipe->quad.colormask->destroy( softpipe->quad.colormask );
- softpipe->quad.output->destroy( softpipe->quad.output );
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ softpipe->quad[i].polygon_stipple->destroy( softpipe->quad[i].polygon_stipple );
+ softpipe->quad[i].earlyz->destroy( softpipe->quad[i].earlyz );
+ softpipe->quad[i].shade->destroy( softpipe->quad[i].shade );
+ softpipe->quad[i].alpha_test->destroy( softpipe->quad[i].alpha_test );
+ softpipe->quad[i].depth_test->destroy( softpipe->quad[i].depth_test );
+ softpipe->quad[i].stencil_test->destroy( softpipe->quad[i].stencil_test );
+ softpipe->quad[i].occlusion->destroy( softpipe->quad[i].occlusion );
+ softpipe->quad[i].coverage->destroy( softpipe->quad[i].coverage );
+ softpipe->quad[i].blend->destroy( softpipe->quad[i].blend );
+ softpipe->quad[i].colormask->destroy( softpipe->quad[i].colormask );
+ softpipe->quad[i].output->destroy( softpipe->quad[i].output );
+ }
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
@@ -112,7 +115,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(ws, &softpipe->constants[i].buffer, NULL);
+ winsys_buffer_reference(ws, &softpipe->constants[i].buffer, NULL);
}
}
@@ -128,6 +131,8 @@ softpipe_create( struct pipe_screen *screen,
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
uint i;
+ util_init_math();
+
#ifdef PIPE_ARCH_X86
softpipe->use_sse = !debug_get_bool_option( "GALLIUM_NOSSE", FALSE );
#else
@@ -202,17 +207,19 @@ softpipe_create( struct pipe_screen *screen,
/* setup quad rendering stages */
- softpipe->quad.polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
- softpipe->quad.earlyz = sp_quad_earlyz_stage(softpipe);
- softpipe->quad.shade = sp_quad_shade_stage(softpipe);
- softpipe->quad.alpha_test = sp_quad_alpha_test_stage(softpipe);
- softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe);
- softpipe->quad.stencil_test = sp_quad_stencil_test_stage(softpipe);
- softpipe->quad.occlusion = sp_quad_occlusion_stage(softpipe);
- softpipe->quad.coverage = sp_quad_coverage_stage(softpipe);
- softpipe->quad.blend = sp_quad_blend_stage(softpipe);
- softpipe->quad.colormask = sp_quad_colormask_stage(softpipe);
- softpipe->quad.output = sp_quad_output_stage(softpipe);
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ softpipe->quad[i].polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
+ softpipe->quad[i].earlyz = sp_quad_earlyz_stage(softpipe);
+ softpipe->quad[i].shade = sp_quad_shade_stage(softpipe);
+ softpipe->quad[i].alpha_test = sp_quad_alpha_test_stage(softpipe);
+ softpipe->quad[i].depth_test = sp_quad_depth_test_stage(softpipe);
+ softpipe->quad[i].stencil_test = sp_quad_stencil_test_stage(softpipe);
+ softpipe->quad[i].occlusion = sp_quad_occlusion_stage(softpipe);
+ softpipe->quad[i].coverage = sp_quad_coverage_stage(softpipe);
+ softpipe->quad[i].blend = sp_quad_blend_stage(softpipe);
+ softpipe->quad[i].colormask = sp_quad_colormask_stage(softpipe);
+ softpipe->quad[i].output = sp_quad_output_stage(softpipe);
+ }
/*
* Create drawing context and plug our rendering stage into it.
@@ -254,3 +261,4 @@ softpipe_create( struct pipe_screen *screen,
softpipe_destroy(&softpipe->pipe);
return NULL;
}
+
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index 078886f..2b9a2a8 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -45,6 +45,10 @@
*/
#define USE_DRAW_STAGE_PSTIPPLE 1
+/* Number of threads working on individual quads.
+ * Setting to 1 disables this feature.
+ */
+#define SP_NUM_QUAD_THREADS 1
struct softpipe_winsys;
struct softpipe_vbuf_render;
@@ -133,7 +137,7 @@ struct softpipe_context {
struct quad_stage *output;
struct quad_stage *first; /**< points to one of the above stages */
- } quad;
+ } quad[SP_NUM_QUAD_THREADS];
/** The primitive drawing context */
struct draw_context *draw;
@@ -151,13 +155,11 @@ struct softpipe_context {
};
-
-
static INLINE struct softpipe_context *
softpipe_context( struct pipe_context *pipe )
{
return (struct softpipe_context *)pipe;
}
-
#endif /* SP_CONTEXT_H */
+
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 12b44a8..424bd56 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -34,6 +34,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "sp_context.h"
#include "sp_state.h"
@@ -135,7 +136,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
*/
for (i = 0; i < sp->num_vertex_buffers; i++) {
void *buf
- = pipe->winsys->buffer_map(pipe->winsys,
+ = pipe_buffer_map(pipe->screen,
sp->vertex_buffer[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, i, buf);
@@ -143,7 +144,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
/* Map index buffer, if present */
if (indexBuffer) {
void *mapped_indexes
- = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
+ = pipe_buffer_map(pipe->screen, indexBuffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer_range(draw, indexSize,
min_index,
@@ -164,11 +165,11 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
*/
for (i = 0; i < sp->num_vertex_buffers; i++) {
draw_set_mapped_vertex_buffer(draw, i, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
+ pipe_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer);
}
if (indexBuffer) {
draw_set_mapped_element_buffer(draw, 0, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+ pipe_buffer_unmap(pipe->screen, indexBuffer);
}
diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c
index e03994b6..401764b 100644
--- a/src/gallium/drivers/softpipe/sp_flush.c
+++ b/src/gallium/drivers/softpipe/sp_flush.c
@@ -73,6 +73,19 @@ softpipe_flush( struct pipe_context *pipe,
softpipe_unmap_surfaces(softpipe);
}
+ /* Enable to dump BMPs of the color/depth buffers each frame */
+#if 0
+ if(flags & PIPE_FLUSH_FRAME) {
+ static unsigned frame_no = 1;
+ static char filename[256];
+ util_snprintf(filename, sizeof(filename), "cbuf_%u.bmp", frame_no);
+ debug_dump_surface_bmp(filename, softpipe->framebuffer.cbufs[0]);
+ util_snprintf(filename, sizeof(filename), "zsbuf_%u.bmp", frame_no);
+ debug_dump_surface_bmp(filename, softpipe->framebuffer.zsbuf);
+ ++frame_no;
+ }
+#endif
+
if (fence)
*fence = NULL;
}
diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c
index cc171bb..701ee4c 100644
--- a/src/gallium/drivers/softpipe/sp_fs_exec.c
+++ b/src/gallium/drivers/softpipe/sp_fs_exec.c
@@ -34,7 +34,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_parse.h"
@@ -106,7 +106,7 @@ exec_run( const struct sp_fragment_shader *base,
/* Compute X, Y, Z, W vals for this quad */
sp_setup_pos_vector(quad->posCoef,
- (float)quad->x0, (float)quad->y0,
+ (float)quad->input.x0, (float)quad->input.y0,
&machine->QuadPos);
return tgsi_exec_machine_run( machine );
diff --git a/src/gallium/drivers/softpipe/sp_fs_llvm.c b/src/gallium/drivers/softpipe/sp_fs_llvm.c
index 20226da..34adac5 100644
--- a/src/gallium/drivers/softpipe/sp_fs_llvm.c
+++ b/src/gallium/drivers/softpipe/sp_fs_llvm.c
@@ -36,7 +36,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "tgsi/tgsi_sse2.h"
diff --git a/src/gallium/drivers/softpipe/sp_fs_sse.c b/src/gallium/drivers/softpipe/sp_fs_sse.c
index 8b7da7c..496ed43d 100644
--- a/src/gallium/drivers/softpipe/sp_fs_sse.c
+++ b/src/gallium/drivers/softpipe/sp_fs_sse.c
@@ -34,7 +34,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_sse2.h"
@@ -88,7 +88,7 @@ fs_sse_run( const struct sp_fragment_shader *base,
/* Compute X, Y, Z, W vals for this quad -- place in temp[0] for now */
sp_setup_pos_vector(quad->posCoef,
- (float)quad->x0, (float)quad->y0,
+ (float)quad->input.x0, (float)quad->input.y0,
machine->Temps);
/* init kill mask */
diff --git a/src/gallium/drivers/softpipe/sp_headers.h b/src/gallium/drivers/softpipe/sp_headers.h
index ae2ee21..4a42cb3 100644
--- a/src/gallium/drivers/softpipe/sp_headers.h
+++ b/src/gallium/drivers/softpipe/sp_headers.h
@@ -59,20 +59,31 @@
* Encodes everything we need to know about a 2x2 pixel block. Uses
* "Channel-Serial" or "SoA" layout.
*/
-struct quad_header {
+struct quad_header_input
+{
int x0;
int y0;
- unsigned mask:4;
+ 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 {
- /** colors in SOA format (rrrr, gggg, bbbb, aaaa) */
- float color[PIPE_MAX_COLOR_BUFS][NUM_CHANNELS][QUAD_SIZE];
- float depth[QUAD_SIZE];
- } outputs;
+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];
+};
- float coverage[QUAD_SIZE]; /** fragment coverage for antialiasing */
+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;
@@ -80,5 +91,5 @@ struct quad_header {
unsigned nr_attrs;
};
-
#endif /* SP_HEADERS_H */
+
diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c
index 941ab62..038ff04 100644
--- a/src/gallium/drivers/softpipe/sp_prim_setup.c
+++ b/src/gallium/drivers/softpipe/sp_prim_setup.c
@@ -41,7 +41,7 @@
#include "sp_prim_setup.h"
#include "draw/draw_pipe.h"
#include "draw/draw_vertex.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/**
* Triangle setup info (derived from draw_stage).
diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
index e9fae95..425e13c 100644
--- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c
+++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
@@ -43,6 +43,7 @@
#include "sp_setup.h"
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
+#include "util/u_memory.h"
#define SP_MAX_VBUF_INDEXES 1024
diff --git a/src/gallium/drivers/softpipe/sp_quad.c b/src/gallium/drivers/softpipe/sp_quad.c
index bc83d78..892ef87 100644
--- a/src/gallium/drivers/softpipe/sp_quad.c
+++ b/src/gallium/drivers/softpipe/sp_quad.c
@@ -33,29 +33,33 @@
static void
sp_push_quad_first(
struct softpipe_context *sp,
- struct quad_stage *quad )
+ struct quad_stage *quad,
+ uint i )
{
- quad->next = sp->quad.first;
- sp->quad.first = quad;
+ quad->next = sp->quad[i].first;
+ sp->quad[i].first = quad;
}
static void
sp_build_depth_stencil(
- struct softpipe_context *sp )
+ struct softpipe_context *sp,
+ uint i )
{
if (sp->depth_stencil->stencil[0].enabled ||
sp->depth_stencil->stencil[1].enabled) {
- sp_push_quad_first( sp, sp->quad.stencil_test );
+ sp_push_quad_first( sp, sp->quad[i].stencil_test, i );
}
else if (sp->depth_stencil->depth.enabled &&
sp->framebuffer.zsbuf) {
- sp_push_quad_first( sp, sp->quad.depth_test );
+ sp_push_quad_first( sp, sp->quad[i].depth_test, i );
}
}
void
sp_build_quad_pipeline(struct softpipe_context *sp)
{
+ uint i;
+
boolean early_depth_test =
sp->depth_stencil->depth.enabled &&
sp->framebuffer.zsbuf &&
@@ -64,49 +68,51 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
!sp->fs->info.writes_z;
/* build up the pipeline in reverse order... */
-
- sp->quad.first = sp->quad.output;
-
- if (sp->blend->colormask != 0xf) {
- sp_push_quad_first( sp, sp->quad.colormask );
- }
-
- if (sp->blend->blend_enable ||
- sp->blend->logicop_enable) {
- sp_push_quad_first( sp, sp->quad.blend );
- }
-
- if (sp->depth_stencil->depth.occlusion_count) {
- sp_push_quad_first( sp, sp->quad.occlusion );
- }
-
- if (sp->rasterizer->poly_smooth ||
- sp->rasterizer->line_smooth ||
- sp->rasterizer->point_smooth) {
- sp_push_quad_first( sp, sp->quad.coverage );
- }
-
- if (!early_depth_test) {
- sp_build_depth_stencil( sp );
- }
-
- if (sp->depth_stencil->alpha.enabled) {
- sp_push_quad_first( sp, sp->quad.alpha_test );
- }
-
- /* XXX always enable shader? */
- if (1) {
- sp_push_quad_first( sp, sp->quad.shade );
- }
-
- if (early_depth_test) {
- sp_build_depth_stencil( sp );
- sp_push_quad_first( sp, sp->quad.earlyz );
- }
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ sp->quad[i].first = sp->quad[i].output;
+
+ if (sp->blend->colormask != 0xf) {
+ sp_push_quad_first( sp, sp->quad[i].colormask, i );
+ }
+
+ if (sp->blend->blend_enable ||
+ sp->blend->logicop_enable) {
+ sp_push_quad_first( sp, sp->quad[i].blend, i );
+ }
+
+ if (sp->depth_stencil->depth.occlusion_count) {
+ sp_push_quad_first( sp, sp->quad[i].occlusion, i );
+ }
+
+ if (sp->rasterizer->poly_smooth ||
+ sp->rasterizer->line_smooth ||
+ sp->rasterizer->point_smooth) {
+ sp_push_quad_first( sp, sp->quad[i].coverage, i );
+ }
+
+ if (!early_depth_test) {
+ sp_build_depth_stencil( sp, i );
+ }
+
+ if (sp->depth_stencil->alpha.enabled) {
+ sp_push_quad_first( sp, sp->quad[i].alpha_test, i );
+ }
+
+ /* XXX always enable shader? */
+ if (1) {
+ sp_push_quad_first( sp, sp->quad[i].shade, i );
+ }
+
+ if (early_depth_test) {
+ sp_build_depth_stencil( sp, i );
+ sp_push_quad_first( sp, sp->quad[i].earlyz, i );
+ }
#if !USE_DRAW_STAGE_PSTIPPLE
- if (sp->rasterizer->poly_stipple_enable) {
- sp_push_quad_first( sp, sp->quad.polygon_stipple );
- }
+ if (sp->rasterizer->poly_stipple_enable) {
+ sp_push_quad_first( sp, sp->quad[i].polygon_stipple, i );
+ }
#endif
+ }
}
+
diff --git a/src/gallium/drivers/softpipe/sp_quad_alpha_test.c b/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
index 7a42b08..5bebd14 100644
--- a/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
@@ -7,7 +7,7 @@
#include "sp_headers.h"
#include "sp_quad.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
static void
@@ -17,11 +17,10 @@ alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
const float ref = softpipe->depth_stencil->alpha.ref;
unsigned passMask = 0x0, j;
const uint cbuf = 0; /* only output[0].alpha is tested */
- const float *aaaa = quad->outputs.color[cbuf][3];
+ const float *aaaa = quad->output.color[cbuf][3];
switch (softpipe->depth_stencil->alpha.func) {
case PIPE_FUNC_NEVER:
- quad->mask = 0x0;
break;
case PIPE_FUNC_LESS:
/*
@@ -76,9 +75,9 @@ alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
assert(0);
}
- quad->mask &= passMask;
+ quad->inout.mask &= passMask;
- if (quad->mask)
+ if (quad->inout.mask)
qs->next->run(qs->next, quad);
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c
index 74c6bff..6f64c6e 100644
--- a/src/gallium/drivers/softpipe/sp_quad_blend.c
+++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
@@ -31,7 +31,8 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -113,14 +114,14 @@ logicop_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *
tile = sp_get_cached_tile(softpipe,
softpipe->cbuf_cache[cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ quad->input.x0, quad->input.y0);
+ float (*quadColor)[4] = quad->output.color[cbuf];
uint i, j;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- int x = (quad->x0 & (TILE_SIZE-1)) + (j & 1);
- int y = (quad->y0 & (TILE_SIZE-1)) + (j >> 1);
+ int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
+ int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
@@ -128,15 +129,15 @@ logicop_quad(struct quad_stage *qs, struct quad_header *quad)
/* convert to ubyte */
for (j = 0; j < 4; j++) { /* loop over R,G,B,A channels */
- UNCLAMPED_FLOAT_TO_UBYTE(dst[j][0], dest[j][0]); /* P0 */
- UNCLAMPED_FLOAT_TO_UBYTE(dst[j][1], dest[j][1]); /* P1 */
- UNCLAMPED_FLOAT_TO_UBYTE(dst[j][2], dest[j][2]); /* P2 */
- UNCLAMPED_FLOAT_TO_UBYTE(dst[j][3], dest[j][3]); /* P3 */
-
- UNCLAMPED_FLOAT_TO_UBYTE(src[j][0], quadColor[j][0]); /* P0 */
- UNCLAMPED_FLOAT_TO_UBYTE(src[j][1], quadColor[j][1]); /* P1 */
- UNCLAMPED_FLOAT_TO_UBYTE(src[j][2], quadColor[j][2]); /* P2 */
- UNCLAMPED_FLOAT_TO_UBYTE(src[j][3], quadColor[j][3]); /* P3 */
+ dst[j][0] = float_to_ubyte(dest[j][0]); /* P0 */
+ dst[j][1] = float_to_ubyte(dest[j][1]); /* P1 */
+ dst[j][2] = float_to_ubyte(dest[j][2]); /* P2 */
+ dst[j][3] = float_to_ubyte(dest[j][3]); /* P3 */
+
+ src[j][0] = float_to_ubyte(quadColor[j][0]); /* P0 */
+ src[j][1] = float_to_ubyte(quadColor[j][1]); /* P1 */
+ src[j][2] = float_to_ubyte(quadColor[j][2]); /* P2 */
+ src[j][3] = float_to_ubyte(quadColor[j][3]); /* P3 */
}
switch (softpipe->blend->logicop_func) {
@@ -209,10 +210,10 @@ logicop_quad(struct quad_stage *qs, struct quad_header *quad)
}
for (j = 0; j < 4; j++) {
- quadColor[j][0] = UBYTE_TO_FLOAT(res[j][0]);
- quadColor[j][1] = UBYTE_TO_FLOAT(res[j][1]);
- quadColor[j][2] = UBYTE_TO_FLOAT(res[j][2]);
- quadColor[j][3] = UBYTE_TO_FLOAT(res[j][3]);
+ quadColor[j][0] = ubyte_to_float(res[j][0]);
+ quadColor[j][1] = ubyte_to_float(res[j][1]);
+ quadColor[j][2] = ubyte_to_float(res[j][2]);
+ quadColor[j][3] = ubyte_to_float(res[j][3]);
}
}
@@ -243,14 +244,14 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe,
softpipe->cbuf_cache[cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ quad->input.x0, quad->input.y0);
+ float (*quadColor)[4] = quad->output.color[cbuf];
uint i, j;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- int x = (quad->x0 & (TILE_SIZE-1)) + (j & 1);
- int y = (quad->y0 & (TILE_SIZE-1)) + (j >> 1);
+ int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
+ int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_bufloop.c b/src/gallium/drivers/softpipe/sp_quad_bufloop.c
index b3db428..92e9af0 100644
--- a/src/gallium/drivers/softpipe/sp_quad_bufloop.c
+++ b/src/gallium/drivers/softpipe/sp_quad_bufloop.c
@@ -1,5 +1,5 @@
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
diff --git a/src/gallium/drivers/softpipe/sp_quad_colormask.c b/src/gallium/drivers/softpipe/sp_quad_colormask.c
index 7fe0809..f32bdfa 100644
--- a/src/gallium/drivers/softpipe/sp_quad_colormask.c
+++ b/src/gallium/drivers/softpipe/sp_quad_colormask.c
@@ -31,7 +31,8 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -55,14 +56,14 @@ colormask_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe,
softpipe->cbuf_cache[cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ quad->input.x0, quad->input.y0);
+ float (*quadColor)[4] = quad->output.color[cbuf];
uint i, j;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- int x = (quad->x0 & (TILE_SIZE-1)) + (j & 1);
- int y = (quad->y0 & (TILE_SIZE-1)) + (j >> 1);
+ int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
+ int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_coverage.c b/src/gallium/drivers/softpipe/sp_quad_coverage.c
index dd5ebb2..ee29aa7 100644
--- a/src/gallium/drivers/softpipe/sp_quad_coverage.c
+++ b/src/gallium/drivers/softpipe/sp_quad_coverage.c
@@ -33,7 +33,7 @@
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_quad.h"
@@ -47,19 +47,19 @@ coverage_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
- if ((softpipe->rasterizer->poly_smooth && quad->prim == PRIM_TRI) ||
- (softpipe->rasterizer->line_smooth && quad->prim == PRIM_LINE) ||
- (softpipe->rasterizer->point_smooth && quad->prim == PRIM_POINT)) {
+ 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)) {
uint cbuf;
/* loop over colorbuffer outputs */
for (cbuf = 0; cbuf < softpipe->framebuffer.num_cbufs; cbuf++) {
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ float (*quadColor)[4] = quad->output.color[cbuf];
unsigned j;
for (j = 0; j < QUAD_SIZE; j++) {
- assert(quad->coverage[j] >= 0.0);
- assert(quad->coverage[j] <= 1.0);
- quadColor[3][j] *= quad->coverage[j];
+ assert(quad->input.coverage[j] >= 0.0);
+ assert(quad->input.coverage[j] <= 1.0);
+ quadColor[3][j] *= quad->input.coverage[j];
}
}
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
index 0c82692..523bd3e 100644
--- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
@@ -30,7 +30,7 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -60,7 +60,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
unsigned zmask = 0;
unsigned j;
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->x0, quad->y0);
+ = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->input.x0, quad->input.y0);
assert(ps); /* shouldn't get here if there's no zbuffer */
@@ -79,12 +79,12 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
float scale = 65535.0;
for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
}
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
bzzzz[j] = tile->data.depth16[y][x];
}
}
@@ -94,12 +94,12 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
double scale = (double) (uint) ~0UL;
for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
}
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
bzzzz[j] = tile->data.depth32[y][x];
}
}
@@ -111,12 +111,12 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
float scale = (float) ((1 << 24) - 1);
for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
}
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
bzzzz[j] = tile->data.depth32[y][x] & 0xffffff;
}
}
@@ -128,12 +128,12 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
float scale = (float) ((1 << 24) - 1);
for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
}
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
bzzzz[j] = tile->data.depth32[y][x] >> 8;
}
}
@@ -192,14 +192,14 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
assert(0);
}
- quad->mask &= zmask;
+ quad->inout.mask &= zmask;
if (softpipe->depth_stencil->depth.writemask) {
/* This is also efficient with sse / spe instructions:
*/
for (j = 0; j < QUAD_SIZE; j++) {
- if (quad->mask & (1 << j)) {
+ if (quad->inout.mask & (1 << j)) {
bzzzz[j] = qzzzz[j];
}
}
@@ -208,8 +208,8 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
switch (format) {
case PIPE_FORMAT_Z16_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
tile->data.depth16[y][x] = (ushort) bzzzz[j];
}
break;
@@ -218,15 +218,15 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
/* (yes, this falls through to a different case than above) */
case PIPE_FORMAT_Z32_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
tile->data.depth32[y][x] = bzzzz[j];
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
uint s8z24 = tile->data.depth32[y][x];
s8z24 = (s8z24 & 0xff000000) | bzzzz[j];
tile->data.depth32[y][x] = s8z24;
@@ -234,8 +234,8 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
break;
case PIPE_FORMAT_Z24S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
uint z24s8 = tile->data.depth32[y][x];
z24s8 = (z24s8 & 0xff) | (bzzzz[j] << 8);
tile->data.depth32[y][x] = z24s8;
@@ -243,8 +243,8 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
break;
case PIPE_FORMAT_Z24X8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
tile->data.depth32[y][x] = bzzzz[j] << 8;
}
break;
@@ -260,7 +260,7 @@ depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
sp_depth_test_quad(qs, quad);
- if (quad->mask)
+ if (quad->inout.mask)
qs->next->run(qs->next, quad);
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_earlyz.c b/src/gallium/drivers/softpipe/sp_quad_earlyz.c
index 22ea990..6e2dde3 100644
--- a/src/gallium/drivers/softpipe/sp_quad_earlyz.c
+++ b/src/gallium/drivers/softpipe/sp_quad_earlyz.c
@@ -30,7 +30,7 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_headers.h"
#include "sp_quad.h"
@@ -45,16 +45,16 @@ earlyz_quad(
struct quad_stage *qs,
struct quad_header *quad )
{
- const float fx = (float) quad->x0;
- const float fy = (float) quad->y0;
+ const float fx = (float) quad->input.x0;
+ const float fy = (float) quad->input.y0;
const float dzdx = quad->posCoef->dadx[2];
const float dzdy = quad->posCoef->dady[2];
const float z0 = quad->posCoef->a0[2] + dzdx * fx + dzdy * fy;
- quad->outputs.depth[0] = z0;
- quad->outputs.depth[1] = z0 + dzdx;
- quad->outputs.depth[2] = z0 + dzdy;
- quad->outputs.depth[3] = z0 + dzdx + dzdy;
+ quad->output.depth[0] = z0;
+ quad->output.depth[1] = z0 + dzdx;
+ quad->output.depth[2] = z0 + dzdy;
+ quad->output.depth[3] = z0 + dzdx + dzdy;
qs->next->run( qs->next, quad );
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index 8c88c19..1f0cb3e 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -35,7 +35,8 @@
* all the enabled attributes run contiguously.
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
@@ -84,7 +85,7 @@ shade_quad(
machine->InterpCoefs = quad->coef;
/* run shader */
- quad->mask &= softpipe->fs->run( softpipe->fs,
+ quad->inout.mask &= softpipe->fs->run( softpipe->fs,
&qss->machine,
quad );
@@ -100,16 +101,16 @@ shade_quad(
case TGSI_SEMANTIC_COLOR:
{
uint cbuf = sem_index[i];
- memcpy(quad->outputs.color[cbuf],
+ memcpy(quad->output.color[cbuf],
&machine->Outputs[i].xyzw[0].f[0],
- sizeof(quad->outputs.color[0]) );
+ sizeof(quad->output.color[0]) );
}
break;
case TGSI_SEMANTIC_POSITION:
{
uint j;
for (j = 0; j < 4; j++) {
- quad->outputs.depth[j] = machine->Outputs[0].xyzw[2].f[j];
+ quad->output.depth[j] = machine->Outputs[0].xyzw[2].f[j];
}
z_written = TRUE;
}
@@ -121,20 +122,20 @@ shade_quad(
if (!z_written) {
/* compute Z values now, as in the quad earlyz stage */
/* XXX we should really only do this if the earlyz stage is not used */
- const float fx = (float) quad->x0;
- const float fy = (float) quad->y0;
+ const float fx = (float) quad->input.x0;
+ const float fy = (float) quad->input.y0;
const float dzdx = quad->posCoef->dadx[2];
const float dzdy = quad->posCoef->dady[2];
const float z0 = quad->posCoef->a0[2] + dzdx * fx + dzdy * fy;
- quad->outputs.depth[0] = z0;
- quad->outputs.depth[1] = z0 + dzdx;
- quad->outputs.depth[2] = z0 + dzdy;
- quad->outputs.depth[3] = z0 + dzdx + dzdy;
+ quad->output.depth[0] = z0;
+ quad->output.depth[1] = z0 + dzdx;
+ quad->output.depth[2] = z0 + dzdy;
+ quad->output.depth[3] = z0 + dzdx + dzdy;
}
/* shader may cull fragments */
- if( quad->mask ) {
+ if( quad->inout.mask ) {
qs->next->run( qs->next, quad );
}
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_occlusion.c b/src/gallium/drivers/softpipe/sp_quad_occlusion.c
index 54254df..169bd82 100644
--- a/src/gallium/drivers/softpipe/sp_quad_occlusion.c
+++ b/src/gallium/drivers/softpipe/sp_quad_occlusion.c
@@ -33,7 +33,7 @@
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -54,7 +54,7 @@ occlusion_count_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
- softpipe->occlusion_count += count_bits(quad->mask);
+ softpipe->occlusion_count += count_bits(quad->inout.mask);
qs->next->run(qs->next, quad);
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_output.c b/src/gallium/drivers/softpipe/sp_quad_output.c
index 4008313..d05e12d 100644
--- a/src/gallium/drivers/softpipe/sp_quad_output.c
+++ b/src/gallium/drivers/softpipe/sp_quad_output.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -41,8 +41,8 @@ static void
output_quad(struct quad_stage *qs, struct quad_header *quad)
{
/* in-tile pos: */
- const int itx = quad->x0 % TILE_SIZE;
- const int ity = quad->y0 % TILE_SIZE;
+ const int itx = quad->input.x0 % TILE_SIZE;
+ const int ity = quad->input.y0 % TILE_SIZE;
struct softpipe_context *softpipe = qs->softpipe;
uint cbuf;
@@ -52,13 +52,13 @@ output_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe,
softpipe->cbuf_cache[cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ quad->input.x0, quad->input.y0);
+ float (*quadColor)[4] = quad->output.color[cbuf];
int i, j;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- if (quad->mask & (1 << j)) {
+ if (quad->inout.mask & (1 << j)) {
int x = itx + (j & 1);
int y = ity + (j >> 1);
for (i = 0; i < 4; i++) { /* loop over color chans */
diff --git a/src/gallium/drivers/softpipe/sp_quad_stencil.c b/src/gallium/drivers/softpipe/sp_quad_stencil.c
index b4c7e94..abb5487 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stencil.c
+++ b/src/gallium/drivers/softpipe/sp_quad_stencil.c
@@ -10,7 +10,7 @@
#include "sp_tile_cache.h"
#include "sp_quad.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/** Only 8-bit stencil supported */
@@ -206,9 +206,9 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
ubyte ref, wrtMask, valMask;
ubyte stencilVals[QUAD_SIZE];
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->x0, quad->y0);
+ = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->input.x0, quad->input.y0);
uint j;
- uint face = quad->facing;
+ uint face = quad->input.facing;
if (!softpipe->depth_stencil->stencil[1].enabled) {
/* single-sided stencil test, use front (face=0) state */
@@ -231,22 +231,22 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
switch (ps->format) {
case PIPE_FORMAT_S8Z24_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
stencilVals[j] = tile->data.depth32[y][x] >> 24;
}
break;
case PIPE_FORMAT_Z24S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
stencilVals[j] = tile->data.depth32[y][x] & 0xff;
}
break;
case PIPE_FORMAT_S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
stencilVals[j] = tile->data.stencil8[y][x];
}
break;
@@ -258,35 +258,35 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
unsigned passMask, failMask;
passMask = do_stencil_test(stencilVals, func, ref, valMask);
- failMask = quad->mask & ~passMask;
- quad->mask &= passMask;
+ failMask = quad->inout.mask & ~passMask;
+ quad->inout.mask &= passMask;
if (failOp != PIPE_STENCIL_OP_KEEP) {
apply_stencil_op(stencilVals, failMask, failOp, ref, wrtMask);
}
}
- if (quad->mask) {
+ if (quad->inout.mask) {
/* now the pixels that passed the stencil test are depth tested */
if (softpipe->depth_stencil->depth.enabled) {
- const unsigned origMask = quad->mask;
+ const unsigned origMask = quad->inout.mask;
sp_depth_test_quad(qs, quad); /* quad->mask is updated */
/* update stencil buffer values according to z pass/fail result */
if (zFailOp != PIPE_STENCIL_OP_KEEP) {
- const unsigned failMask = origMask & ~quad->mask;
+ const unsigned failMask = origMask & ~quad->inout.mask;
apply_stencil_op(stencilVals, failMask, zFailOp, ref, wrtMask);
}
if (zPassOp != PIPE_STENCIL_OP_KEEP) {
- const unsigned passMask = origMask & quad->mask;
+ const unsigned passMask = origMask & quad->inout.mask;
apply_stencil_op(stencilVals, passMask, zPassOp, ref, wrtMask);
}
}
else {
/* no depth test, apply Zpass operator to stencil buffer values */
- apply_stencil_op(stencilVals, quad->mask, zPassOp, ref, wrtMask);
+ apply_stencil_op(stencilVals, quad->inout.mask, zPassOp, ref, wrtMask);
}
}
@@ -295,8 +295,8 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
switch (ps->format) {
case PIPE_FORMAT_S8Z24_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
uint s8z24 = tile->data.depth32[y][x];
s8z24 = (stencilVals[j] << 24) | (s8z24 & 0xffffff);
tile->data.depth32[y][x] = s8z24;
@@ -304,8 +304,8 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
break;
case PIPE_FORMAT_Z24S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
uint z24s8 = tile->data.depth32[y][x];
z24s8 = (z24s8 & 0xffffff00) | stencilVals[j];
tile->data.depth32[y][x] = z24s8;
@@ -313,8 +313,8 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
break;
case PIPE_FORMAT_S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
tile->data.stencil8[y][x] = stencilVals[j];
}
break;
@@ -322,7 +322,7 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
assert(0);
}
- if (quad->mask)
+ if (quad->inout.mask)
qs->next->run(qs->next, quad);
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_stipple.c b/src/gallium/drivers/softpipe/sp_quad_stipple.c
index f1e9b80..ccf37f6 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stipple.c
+++ b/src/gallium/drivers/softpipe/sp_quad_stipple.c
@@ -7,7 +7,7 @@
#include "sp_headers.h"
#include "sp_quad.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/**
@@ -19,17 +19,17 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
static const uint bit31 = 1 << 31;
static const uint bit30 = 1 << 30;
- if (quad->prim == PRIM_TRI) {
+ if (quad->input.prim == 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;
if (softpipe->rasterizer->origin_lower_left) {
- y0 = softpipe->framebuffer.height - 1 - quad->y0;
+ y0 = softpipe->framebuffer.height - 1 - quad->input.y0;
y1 = y0 - 1;
}
else {
- y0 = quad->y0;
+ y0 = quad->input.y0;
y1 = y0 + 1;
}
stipple0 = softpipe->poly_stipple.stipple[y0 % 32];
@@ -37,18 +37,18 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
#if 1
{
- const int col0 = quad->x0 % 32;
+ const int col0 = quad->input.x0 % 32;
if ((stipple0 & (bit31 >> col0)) == 0)
- quad->mask &= ~MASK_TOP_LEFT;
+ quad->inout.mask &= ~MASK_TOP_LEFT;
if ((stipple0 & (bit30 >> col0)) == 0)
- quad->mask &= ~MASK_TOP_RIGHT;
+ quad->inout.mask &= ~MASK_TOP_RIGHT;
if ((stipple1 & (bit31 >> col0)) == 0)
- quad->mask &= ~MASK_BOTTOM_LEFT;
+ quad->inout.mask &= ~MASK_BOTTOM_LEFT;
if ((stipple1 & (bit30 >> col0)) == 0)
- quad->mask &= ~MASK_BOTTOM_RIGHT;
+ quad->inout.mask &= ~MASK_BOTTOM_RIGHT;
}
#else
/* We'd like to use this code, but we'd need to redefine
@@ -56,11 +56,11 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
* and similarly for the BOTTOM bits. But that may have undesirable
* side effects elsewhere.
*/
- const int col0 = 30 - (quad->x0 % 32);
- quad->mask &= (((stipple0 >> col0) & 0x3) |
+ const int col0 = 30 - (quad->input.x0 % 32);
+ quad->inout.mask &= (((stipple0 >> col0) & 0x3) |
(((stipple1 >> col0) & 0x3) << 2));
#endif
- if (!quad->mask)
+ if (!quad->inout.mask)
return;
}
diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c
index adf9ccf..2106ee1 100644
--- a/src/gallium/drivers/softpipe/sp_query.c
+++ b/src/gallium/drivers/softpipe/sp_query.c
@@ -32,7 +32,7 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_query.h"
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index f6b3d7a..9644dbd 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index b7f2f16..bc8263c 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -42,8 +42,11 @@
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vertex.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_thread.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
#define DEBUG_VERTS 0
#define DEBUG_FRAGS 0
@@ -59,6 +62,87 @@ struct edge {
int lines; /**< number of lines on this edge */
};
+#if SP_NUM_QUAD_THREADS > 1
+
+/* Set to 1 if you want other threads to be instantly
+ * notified of pending jobs.
+ */
+#define INSTANT_NOTEMPTY_NOTIFY 0
+
+struct thread_info
+{
+ struct setup_context *setup;
+ uint id;
+ pipe_thread handle;
+};
+
+struct quad_job;
+
+typedef void (* quad_job_routine)( struct setup_context *setup, uint thread, struct quad_job *job );
+
+struct quad_job
+{
+ struct quad_header_input input;
+ struct quad_header_inout inout;
+ quad_job_routine routine;
+};
+
+#define NUM_QUAD_JOBS 64
+
+struct quad_job_que
+{
+ struct quad_job jobs[NUM_QUAD_JOBS];
+ uint first;
+ uint last;
+ pipe_mutex que_mutex;
+ pipe_condvar que_notfull_condvar;
+ pipe_condvar que_notempty_condvar;
+ uint jobs_added;
+ uint jobs_done;
+ pipe_condvar que_done_condvar;
+};
+
+static void
+add_quad_job( struct quad_job_que *que, struct quad_header *quad, quad_job_routine routine )
+{
+#if INSTANT_NOTEMPTY_NOTIFY
+ boolean empty;
+#endif
+
+ /* Wait for empty slot, see if the que is empty.
+ */
+ pipe_mutex_lock( que->que_mutex );
+ while ((que->last + 1) % NUM_QUAD_JOBS == que->first) {
+#if !INSTANT_NOTEMPTY_NOTIFY
+ pipe_condvar_broadcast( que->que_notempty_condvar );
+#endif
+ pipe_condvar_wait( que->que_notfull_condvar, que->que_mutex );
+ }
+#if INSTANT_NOTEMPTY_NOTIFY
+ empty = que->last == que->first;
+#endif
+ que->jobs_added++;
+ pipe_mutex_unlock( que->que_mutex );
+
+ /* Submit new job.
+ */
+ que->jobs[que->last].input = quad->input;
+ que->jobs[que->last].inout = quad->inout;
+ que->jobs[que->last].routine = routine;
+ que->last = (que->last + 1) % NUM_QUAD_JOBS;
+
+#if INSTANT_NOTEMPTY_NOTIFY
+ /* If the que was empty, notify consumers there's a job to be done.
+ */
+ if (empty) {
+ pipe_mutex_lock( que->que_mutex );
+ pipe_condvar_broadcast( que->que_notempty_condvar );
+ pipe_mutex_unlock( que->que_mutex );
+ }
+#endif
+}
+
+#endif
/**
* Triangle setup info (derived from draw_stage).
@@ -86,6 +170,11 @@ struct setup_context {
struct tgsi_interp_coef posCoef; /* For Z, W */
struct quad_header quad;
+#if SP_NUM_QUAD_THREADS > 1
+ struct quad_job_que que;
+ struct thread_info threads[SP_NUM_QUAD_THREADS];
+#endif
+
struct {
int left[2]; /**< [0] = row0, [1] = row1 */
int right[2];
@@ -102,8 +191,78 @@ struct setup_context {
unsigned winding; /* which winding to cull */
};
+#if SP_NUM_QUAD_THREADS > 1
+
+static PIPE_THREAD_ROUTINE( quad_thread, param )
+{
+ struct thread_info *info = (struct thread_info *) param;
+ struct quad_job_que *que = &info->setup->que;
+
+ for (;;) {
+ struct quad_job job;
+ boolean full;
+
+ /* Wait for an available job.
+ */
+ pipe_mutex_lock( que->que_mutex );
+ while (que->last == que->first)
+ pipe_condvar_wait( que->que_notempty_condvar, que->que_mutex );
+
+ /* See if the que is full.
+ */
+ full = (que->last + 1) % NUM_QUAD_JOBS == que->first;
+
+ /* Take a job and remove it from que.
+ */
+ job = que->jobs[que->first];
+ que->first = (que->first + 1) % NUM_QUAD_JOBS;
+
+ /* Notify the producer if the que is not full.
+ */
+ if (full)
+ pipe_condvar_signal( que->que_notfull_condvar );
+ pipe_mutex_unlock( que->que_mutex );
+
+ job.routine( info->setup, info->id, &job );
+
+ /* Notify the producer if that's the last finished job.
+ */
+ pipe_mutex_lock( que->que_mutex );
+ que->jobs_done++;
+ if (que->jobs_added == que->jobs_done)
+ pipe_condvar_signal( que->que_done_condvar );
+ pipe_mutex_unlock( que->que_mutex );
+ }
+ return NULL;
+}
+
+#define WAIT_FOR_COMPLETION(setup) \
+ do {\
+ pipe_mutex_lock( setup->que.que_mutex );\
+ if (!INSTANT_NOTEMPTY_NOTIFY)\
+ pipe_condvar_broadcast( setup->que.que_notempty_condvar );\
+ while (setup->que.jobs_added != setup->que.jobs_done)\
+ pipe_condvar_wait( setup->que.que_done_condvar, setup->que.que_mutex );\
+ pipe_mutex_unlock( setup->que.que_mutex );\
+ } while (0)
+#else
+
+#define WAIT_FOR_COMPLETION(setup) ((void) 0)
+
+#endif
+
+/**
+ * Test if x is NaN or +/- infinity.
+ */
+static INLINE boolean
+is_inf_or_nan(float x)
+{
+ union fi tmp;
+ tmp.f = x;
+ return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
+}
static boolean cull_tri( struct setup_context *setup,
@@ -131,7 +290,7 @@ static boolean cull_tri( struct setup_context *setup,
* Clip setup->quad against the scissor/surface bounds.
*/
static INLINE void
-quad_clip(struct setup_context *setup)
+quad_clip( struct setup_context *setup, struct quad_header *quad )
{
const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect;
const int minx = (int) cliprect->minx;
@@ -139,22 +298,22 @@ quad_clip(struct setup_context *setup)
const int miny = (int) cliprect->miny;
const int maxy = (int) cliprect->maxy;
- if (setup->quad.x0 >= maxx ||
- setup->quad.y0 >= maxy ||
- setup->quad.x0 + 1 < minx ||
- setup->quad.y0 + 1 < miny) {
+ if (quad->input.x0 >= maxx ||
+ quad->input.y0 >= maxy ||
+ quad->input.x0 + 1 < minx ||
+ quad->input.y0 + 1 < miny) {
/* totally clipped */
- setup->quad.mask = 0x0;
+ quad->inout.mask = 0x0;
return;
}
- if (setup->quad.x0 < minx)
- setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT);
- if (setup->quad.y0 < miny)
- setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT);
- if (setup->quad.x0 == maxx - 1)
- setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
- if (setup->quad.y0 == maxy - 1)
- setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT);
+ if (quad->input.x0 < minx)
+ quad->inout.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT);
+ if (quad->input.y0 < miny)
+ quad->inout.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT);
+ if (quad->input.x0 == maxx - 1)
+ quad->inout.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
+ if (quad->input.y0 == maxy - 1)
+ quad->inout.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT);
}
@@ -162,35 +321,59 @@ quad_clip(struct setup_context *setup)
* Emit a quad (pass to next stage) with clipping.
*/
static INLINE void
-clip_emit_quad(struct setup_context *setup)
+clip_emit_quad( struct setup_context *setup, struct quad_header *quad, uint thread )
{
- quad_clip(setup);
- if (setup->quad.mask) {
+ quad_clip( setup, quad );
+ if (quad->inout.mask) {
struct softpipe_context *sp = setup->softpipe;
- sp->quad.first->run(sp->quad.first, &setup->quad);
+
+ sp->quad[thread].first->run( sp->quad[thread].first, quad );
}
}
+#if SP_NUM_QUAD_THREADS > 1
+
+static void
+clip_emit_quad_job( struct setup_context *setup, uint thread, struct quad_job *job )
+{
+ struct quad_header quad;
+
+ quad.input = job->input;
+ quad.inout = job->inout;
+ quad.coef = setup->quad.coef;
+ quad.posCoef = setup->quad.posCoef;
+ quad.nr_attrs = setup->quad.nr_attrs;
+ clip_emit_quad( setup, &quad, thread );
+}
+
+#define CLIP_EMIT_QUAD(setup) add_quad_job( &setup->que, &setup->quad, clip_emit_quad_job )
+
+#else
+
+#define CLIP_EMIT_QUAD(setup) clip_emit_quad( setup, &setup->quad, 0 )
+
+#endif
/**
* Emit a quad (pass to next stage). No clipping is done.
*/
static INLINE void
-emit_quad( struct setup_context *setup, int x, int y, unsigned mask )
+emit_quad( struct setup_context *setup, struct quad_header *quad, uint thread )
{
struct softpipe_context *sp = setup->softpipe;
- setup->quad.x0 = x;
- setup->quad.y0 = y;
- setup->quad.mask = mask;
+#if DEBUG_FRAGS
+ uint mask = quad->inout.mask;
+#endif
+
#if DEBUG_FRAGS
if (mask & 1) setup->numFragsEmitted++;
if (mask & 2) setup->numFragsEmitted++;
if (mask & 4) setup->numFragsEmitted++;
if (mask & 8) setup->numFragsEmitted++;
#endif
- sp->quad.first->run(sp->quad.first, &setup->quad);
+ sp->quad[thread].first->run( sp->quad[thread].first, quad );
#if DEBUG_FRAGS
- mask = setup->quad.mask;
+ mask = quad->inout.mask;
if (mask & 1) setup->numFragsWritten++;
if (mask & 2) setup->numFragsWritten++;
if (mask & 4) setup->numFragsWritten++;
@@ -198,6 +381,38 @@ emit_quad( struct setup_context *setup, int x, int y, unsigned mask )
#endif
}
+#if SP_NUM_QUAD_THREADS > 1
+
+static void
+emit_quad_job( struct setup_context *setup, uint thread, struct quad_job *job )
+{
+ struct quad_header quad;
+
+ quad.input = job->input;
+ quad.inout = job->inout;
+ quad.coef = setup->quad.coef;
+ quad.posCoef = setup->quad.posCoef;
+ quad.nr_attrs = setup->quad.nr_attrs;
+ emit_quad( setup, &quad, thread );
+}
+
+#define EMIT_QUAD(setup,x,y,mask) do {\
+ setup->quad.input.x0 = x;\
+ setup->quad.input.y0 = y;\
+ setup->quad.inout.mask = mask;\
+ add_quad_job( &setup->que, &setup->quad, emit_quad_job );\
+ } while (0)
+
+#else
+
+#define EMIT_QUAD(setup,x,y,mask) do {\
+ setup->quad.input.x0 = x;\
+ setup->quad.input.y0 = y;\
+ setup->quad.inout.mask = mask;\
+ emit_quad( setup, &setup->quad, 0 );\
+ } while (0)
+
+#endif
/**
* Given an X or Y coordinate, return the block/quad coordinate that it
@@ -237,7 +452,7 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_TOP_RIGHT;
if (x+1 >= xleft1 && x+1 < xright1)
mask |= MASK_BOTTOM_RIGHT;
- emit_quad( setup, x, setup->span.y, mask );
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -251,7 +466,7 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_TOP_LEFT;
if (x+1 >= xleft0 && x+1 < xright0)
mask |= MASK_TOP_RIGHT;
- emit_quad( setup, x, setup->span.y, mask );
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -265,7 +480,7 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_BOTTOM_LEFT;
if (x+1 >= xleft1 && x+1 < xright1)
mask |= MASK_BOTTOM_RIGHT;
- emit_quad( setup, x, setup->span.y, mask );
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -293,6 +508,9 @@ static void print_vertex(const struct setup_context *setup,
}
#endif
+/**
+ * \return FALSE if coords are inf/nan (cull the tri), TRUE otherwise
+ */
static boolean setup_sort_vertices( struct setup_context *setup,
float det,
const float (*v0)[4],
@@ -370,17 +588,20 @@ static boolean setup_sort_vertices( struct setup_context *setup,
setup->ebot.dx * setup->emaj.dy);
setup->oneoverarea = 1.0f / area;
+
/*
debug_printf("%s one-over-area %f area %f det %f\n",
__FUNCTION__, setup->oneoverarea, area, det );
*/
+ if (is_inf_or_nan(setup->oneoverarea))
+ return FALSE;
}
/* We need to know if this is a front or back-facing triangle for:
* - the GLSL gl_FrontFacing fragment attribute (bool)
* - two-sided stencil test
*/
- setup->quad.facing = (det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW);
+ setup->quad.input.facing = (det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW);
return TRUE;
}
@@ -577,7 +798,7 @@ static void setup_tri_coefficients( struct setup_context *setup )
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
- setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
+ setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
setup->coef[fragSlot].dady[1] = 0.0;
}
@@ -595,18 +816,18 @@ static void setup_tri_edges( struct setup_context *setup )
float vmid_y = setup->vmid[0][1] - 0.5f;
float vmax_y = setup->vmax[0][1] - 0.5f;
- setup->emaj.sy = CEILF(vmin_y);
- setup->emaj.lines = (int) CEILF(vmax_y - setup->emaj.sy);
+ setup->emaj.sy = ceilf(vmin_y);
+ setup->emaj.lines = (int) ceilf(vmax_y - setup->emaj.sy);
setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy;
setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy;
- setup->etop.sy = CEILF(vmid_y);
- setup->etop.lines = (int) CEILF(vmax_y - setup->etop.sy);
+ setup->etop.sy = ceilf(vmid_y);
+ setup->etop.lines = (int) ceilf(vmax_y - setup->etop.sy);
setup->etop.dxdy = setup->etop.dx / setup->etop.dy;
setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy;
- setup->ebot.sy = CEILF(vmin_y);
- setup->ebot.lines = (int) CEILF(vmid_y - setup->ebot.sy);
+ setup->ebot.sy = ceilf(vmin_y);
+ setup->ebot.lines = (int) ceilf(vmid_y - setup->ebot.sy);
setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy;
setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy;
}
@@ -742,11 +963,12 @@ void setup_tri( struct setup_context *setup,
if (cull_tri( setup, det ))
return;
- setup_sort_vertices( setup, det, v0, v1, v2 );
+ if (!setup_sort_vertices( setup, det, v0, v1, v2 ))
+ return;
setup_tri_coefficients( setup );
setup_tri_edges( setup );
- setup->quad.prim = PRIM_TRI;
+ setup->quad.input.prim = PRIM_TRI;
setup->span.y = 0;
setup->span.y_flags = 0;
@@ -771,6 +993,8 @@ void setup_tri( struct setup_context *setup,
flush_spans( setup );
+ WAIT_FOR_COMPLETION(setup);
+
#if DEBUG_FRAGS
printf("Tri: %u frags emitted, %u written\n",
setup->numFragsEmitted,
@@ -827,7 +1051,7 @@ line_persp_coeff(struct setup_context *setup,
* Compute the setup->coef[] array dadx, dady, a0 values.
* Must be called after setup->vmin,vmax are initialized.
*/
-static INLINE void
+static INLINE boolean
setup_line_coefficients(struct setup_context *setup,
const float (*v0)[4],
const float (*v1)[4])
@@ -836,6 +1060,7 @@ setup_line_coefficients(struct setup_context *setup,
const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
uint fragSlot;
+ float area;
/* use setup->vmin, vmax to point to vertices */
setup->vprovoke = v1;
@@ -844,9 +1069,12 @@ setup_line_coefficients(struct setup_context *setup,
setup->emaj.dx = setup->vmax[0][0] - setup->vmin[0][0];
setup->emaj.dy = setup->vmax[0][1] - setup->vmin[0][1];
- /* NOTE: this is not really 1/area */
- setup->oneoverarea = 1.0f / (setup->emaj.dx * setup->emaj.dx +
- setup->emaj.dy * setup->emaj.dy);
+
+ /* NOTE: this is not really area but something proportional to it */
+ area = setup->emaj.dx * setup->emaj.dx + setup->emaj.dy * setup->emaj.dy;
+ if (area == 0.0f || is_inf_or_nan(area))
+ return FALSE;
+ setup->oneoverarea = 1.0f / area;
/* z and w are done by linear interpolation:
*/
@@ -881,11 +1109,12 @@ setup_line_coefficients(struct setup_context *setup,
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
- setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
+ setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
setup->coef[fragSlot].dady[1] = 0.0;
}
}
+ return TRUE;
}
@@ -901,20 +1130,20 @@ plot(struct setup_context *setup, int x, int y)
const int quadY = y - iy;
const int mask = (1 << ix) << (2 * iy);
- if (quadX != setup->quad.x0 ||
- quadY != setup->quad.y0)
+ if (quadX != setup->quad.input.x0 ||
+ quadY != setup->quad.input.y0)
{
/* flush prev quad, start new quad */
- if (setup->quad.x0 != -1)
- clip_emit_quad(setup);
+ if (setup->quad.input.x0 != -1)
+ CLIP_EMIT_QUAD(setup);
- setup->quad.x0 = quadX;
- setup->quad.y0 = quadY;
- setup->quad.mask = 0x0;
+ setup->quad.input.x0 = quadX;
+ setup->quad.input.y0 = quadY;
+ setup->quad.inout.mask = 0x0;
}
- setup->quad.mask |= mask;
+ setup->quad.inout.mask |= mask;
}
@@ -942,18 +1171,19 @@ setup_line(struct setup_context *setup,
print_vertex(setup, v1);
#endif
- assert(v0[0][0] < 1.0e9);
- assert(v0[0][1] < 1.0e9);
- assert(v1[0][0] < 1.0e9);
- assert(v1[0][1] < 1.0e9);
-
if (setup->softpipe->no_rast)
return;
if (dx == 0 && dy == 0)
return;
- setup_line_coefficients(setup, v0, v1);
+ if (!setup_line_coefficients(setup, v0, v1))
+ return;
+
+ assert(v0[0][0] < 1.0e9);
+ assert(v0[0][1] < 1.0e9);
+ assert(v1[0][0] < 1.0e9);
+ assert(v1[0][1] < 1.0e9);
if (dx < 0) {
dx = -dx; /* make positive */
@@ -974,16 +1204,16 @@ setup_line(struct setup_context *setup,
assert(dx >= 0);
assert(dy >= 0);
- setup->quad.x0 = setup->quad.y0 = -1;
- setup->quad.mask = 0x0;
- setup->quad.prim = PRIM_LINE;
+ setup->quad.input.x0 = setup->quad.input.y0 = -1;
+ setup->quad.inout.mask = 0x0;
+ setup->quad.input.prim = PRIM_LINE;
/* XXX temporary: set coverage to 1.0 so the line appears
* if AA mode happens to be enabled.
*/
- setup->quad.coverage[0] =
- setup->quad.coverage[1] =
- setup->quad.coverage[2] =
- setup->quad.coverage[3] = 1.0;
+ setup->quad.input.coverage[0] =
+ setup->quad.input.coverage[1] =
+ setup->quad.input.coverage[2] =
+ setup->quad.input.coverage[3] = 1.0;
if (dx > dy) {
/*** X-major line ***/
@@ -1027,9 +1257,11 @@ setup_line(struct setup_context *setup,
}
/* draw final quad */
- if (setup->quad.mask) {
- clip_emit_quad(setup);
+ if (setup->quad.inout.mask) {
+ CLIP_EMIT_QUAD(setup);
}
+
+ WAIT_FOR_COMPLETION(setup);
}
@@ -1123,22 +1355,22 @@ setup_point( struct setup_context *setup,
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
- setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
+ setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
setup->coef[fragSlot].dady[1] = 0.0;
}
}
- setup->quad.prim = PRIM_POINT;
+ setup->quad.input.prim = PRIM_POINT;
if (halfSize <= 0.5 && !round) {
/* special case for 1-pixel points */
const int ix = ((int) x) & 1;
const int iy = ((int) y) & 1;
- setup->quad.x0 = (int) x - ix;
- setup->quad.y0 = (int) y - iy;
- setup->quad.mask = (1 << ix) << (2 * iy);
- clip_emit_quad(setup);
+ setup->quad.input.x0 = (int) x - ix;
+ setup->quad.input.y0 = (int) y - iy;
+ setup->quad.inout.mask = (1 << ix) << (2 * iy);
+ CLIP_EMIT_QUAD(setup);
}
else {
if (round) {
@@ -1158,15 +1390,15 @@ setup_point( struct setup_context *setup,
for (ix = ixmin; ix <= ixmax; ix += 2) {
float dx, dy, dist2, cover;
- setup->quad.mask = 0x0;
+ setup->quad.inout.mask = 0x0;
dx = (ix + 0.5f) - x;
dy = (iy + 0.5f) - y;
dist2 = dx * dx + dy * dy;
if (dist2 <= rmax2) {
cover = 1.0F - (dist2 - rmin2) * cscale;
- setup->quad.coverage[QUAD_TOP_LEFT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_TOP_LEFT;
+ setup->quad.input.coverage[QUAD_TOP_LEFT] = MIN2(cover, 1.0f);
+ setup->quad.inout.mask |= MASK_TOP_LEFT;
}
dx = (ix + 1.5f) - x;
@@ -1174,8 +1406,8 @@ setup_point( struct setup_context *setup,
dist2 = dx * dx + dy * dy;
if (dist2 <= rmax2) {
cover = 1.0F - (dist2 - rmin2) * cscale;
- setup->quad.coverage[QUAD_TOP_RIGHT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_TOP_RIGHT;
+ setup->quad.input.coverage[QUAD_TOP_RIGHT] = MIN2(cover, 1.0f);
+ setup->quad.inout.mask |= MASK_TOP_RIGHT;
}
dx = (ix + 0.5f) - x;
@@ -1183,8 +1415,8 @@ setup_point( struct setup_context *setup,
dist2 = dx * dx + dy * dy;
if (dist2 <= rmax2) {
cover = 1.0F - (dist2 - rmin2) * cscale;
- setup->quad.coverage[QUAD_BOTTOM_LEFT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_BOTTOM_LEFT;
+ setup->quad.input.coverage[QUAD_BOTTOM_LEFT] = MIN2(cover, 1.0f);
+ setup->quad.inout.mask |= MASK_BOTTOM_LEFT;
}
dx = (ix + 1.5f) - x;
@@ -1192,14 +1424,14 @@ setup_point( struct setup_context *setup,
dist2 = dx * dx + dy * dy;
if (dist2 <= rmax2) {
cover = 1.0F - (dist2 - rmin2) * cscale;
- setup->quad.coverage[QUAD_BOTTOM_RIGHT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_BOTTOM_RIGHT;
+ setup->quad.input.coverage[QUAD_BOTTOM_RIGHT] = MIN2(cover, 1.0f);
+ setup->quad.inout.mask |= MASK_BOTTOM_RIGHT;
}
- if (setup->quad.mask) {
- setup->quad.x0 = ix;
- setup->quad.y0 = iy;
- clip_emit_quad(setup);
+ if (setup->quad.inout.mask) {
+ setup->quad.input.x0 = ix;
+ setup->quad.input.y0 = iy;
+ CLIP_EMIT_QUAD(setup);
}
}
}
@@ -1243,14 +1475,16 @@ setup_point( struct setup_context *setup,
mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
}
- setup->quad.mask = mask;
- setup->quad.x0 = ix;
- setup->quad.y0 = iy;
- clip_emit_quad(setup);
+ setup->quad.inout.mask = mask;
+ setup->quad.input.x0 = ix;
+ setup->quad.input.y0 = iy;
+ CLIP_EMIT_QUAD(setup);
}
}
}
}
+
+ WAIT_FOR_COMPLETION(setup);
}
void setup_prepare( struct setup_context *setup )
@@ -1275,7 +1509,9 @@ void setup_prepare( struct setup_context *setup )
/* Note: nr_attrs is only used for debugging (vertex printing) */
setup->quad.nr_attrs = draw_num_vs_outputs(sp->draw);
- sp->quad.first->begin(sp->quad.first);
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ sp->quad[i].first->begin( sp->quad[i].first );
+ }
if (sp->reduced_api_prim == PIPE_PRIM_TRIANGLES &&
sp->rasterizer->fill_cw == PIPE_POLYGON_MODE_FILL &&
@@ -1303,11 +1539,31 @@ void setup_destroy_context( struct setup_context *setup )
struct setup_context *setup_create_context( struct softpipe_context *softpipe )
{
struct setup_context *setup = CALLOC_STRUCT(setup_context);
+#if SP_NUM_QUAD_THREADS > 1
+ uint i;
+#endif
setup->softpipe = softpipe;
setup->quad.coef = setup->coef;
setup->quad.posCoef = &setup->posCoef;
+#if SP_NUM_QUAD_THREADS > 1
+ setup->que.first = 0;
+ setup->que.last = 0;
+ pipe_mutex_init( setup->que.que_mutex );
+ pipe_condvar_init( setup->que.que_notfull_condvar );
+ pipe_condvar_init( setup->que.que_notempty_condvar );
+ setup->que.jobs_added = 0;
+ setup->que.jobs_done = 0;
+ pipe_condvar_init( setup->que.que_done_condvar );
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ setup->threads[i].setup = setup;
+ setup->threads[i].id = i;
+ setup->threads[i].handle = pipe_thread_create( quad_thread, &setup->threads[i] );
+ }
+#endif
+
return setup;
}
+
diff --git a/src/gallium/drivers/softpipe/sp_state_blend.c b/src/gallium/drivers/softpipe/sp_state_blend.c
index 2d40d6b..384fe55 100644
--- a/src/gallium/drivers/softpipe/sp_state_blend.c
+++ b/src/gallium/drivers/softpipe/sp_state_blend.c
@@ -28,7 +28,7 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_state.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index f10a1fa..6b6a4c3 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -25,7 +25,8 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index 76fe6bf..e5b609c 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -30,7 +30,7 @@
#include "sp_fs.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "pipe/p_shader_tokens.h"
@@ -152,7 +152,7 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
assert(index == 0);
/* note: reference counting */
- pipe_buffer_reference(ws,
+ winsys_buffer_reference(ws,
&softpipe->constants[shader].buffer,
buf ? buf->buffer : NULL);
softpipe->constants[shader].size = buf ? buf->size : 0;
diff --git a/src/gallium/drivers/softpipe/sp_state_rasterizer.c b/src/gallium/drivers/softpipe/sp_state_rasterizer.c
index 98e0435..87b7219 100644
--- a/src/gallium/drivers/softpipe/sp_state_rasterizer.c
+++ b/src/gallium/drivers/softpipe/sp_state_rasterizer.c
@@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_state.h"
#include "draw/draw_context.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 033288a..99a28c0 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -29,7 +29,7 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c
index 7dc15c3..6ade732 100644
--- a/src/gallium/drivers/softpipe/sp_surface.c
+++ b/src/gallium/drivers/softpipe/sp_surface.c
@@ -25,129 +25,14 @@
*
**************************************************************************/
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
-#include "util/p_tile.h"
+#include "util/u_rect.h"
#include "sp_context.h"
-#include "sp_surface.h"
-/**
- * Copy a rectangular region from one surface to another.
- * Surfaces must have same bpp.
- *
- * Assumes all values are within bounds -- no checking at this level -
- * do it higher up if required.
- */
-static void
-sp_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)
-{
- 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 );
-
- assert(dst->block.size == src->block.size);
- assert(dst->block.width == src->block.width);
- assert(dst->block.height == src->block.height);
- assert(src_map);
- assert(dst_map);
-
- /* If do_flip, invert src_y position and pass negative src stride */
- 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 ? src->height - 1 - srcy : srcy);
-
- pipe->screen->surface_unmap(pipe->screen, src);
- pipe->screen->surface_unmap(pipe->screen, dst);
-}
-
-
-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))
-
-
-/**
- * Fill a rectangular sub-region. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-static void
-sp_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
-{
- unsigned i, j;
- void *dst_map = pipe->screen->surface_map( pipe->screen,
- dst,
- PIPE_BUFFER_USAGE_CPU_WRITE );
-
- assert(dst->stride > 0);
-
-
- switch (dst->block.size) {
- case 1:
- case 2:
- case 4:
- pipe_fill_rect(dst_map, &dst->block, dst->stride, dstx, dsty, 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 val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
- ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
- ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
- ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
- val0 = (val0 << 8) | val0;
- val1 = (val1 << 8) | val1;
- val2 = (val2 << 8) | val2;
- val3 = (val3 << 8) | val3;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- row[j*4+0] = val0;
- row[j*4+1] = val1;
- row[j*4+2] = val2;
- row[j*4+3] = val3;
- }
- row += dst->stride/2;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
-
- pipe->screen->surface_unmap(pipe->screen, dst);
-}
-
-
void
sp_init_surface_functions(struct softpipe_context *sp)
{
- sp->pipe.surface_copy = sp_surface_copy;
- sp->pipe.surface_fill = sp_surface_fill;
+ sp->pipe.surface_copy = util_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 01f4d0c..49250ec 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -39,8 +39,9 @@
#include "sp_tile_cache.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "tgsi/tgsi_exec.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
/*
@@ -50,7 +51,7 @@
* Also note, FRAC(x) doesn't truly return the fractional part of x for x < 0.
* Instead, if x < 0 then FRAC(x) = 1 - true_frac(x).
*/
-#define FRAC(f) ((f) - ifloor(f))
+#define FRAC(f) ((f) - util_ifloor(f))
/**
@@ -99,7 +100,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
case PIPE_TEX_WRAP_REPEAT:
/* s limited to [0,1) */
/* i limited to [0,size-1] */
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
i = REMAINDER(i, size);
return i;
case PIPE_TEX_WRAP_CLAMP:
@@ -110,7 +111,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s >= 1.0F)
i = size - 1;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
return i;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
{
@@ -123,7 +124,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s > max)
i = size - 1;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
}
return i;
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
@@ -137,14 +138,14 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s >= max)
i = size;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_REPEAT:
{
const float min = 1.0F / (2.0F * size);
const float max = 1.0F - min;
- const int flr = ifloor(s);
+ const int flr = util_ifloor(s);
float u;
if (flr & 1)
u = 1.0F - (s - (float) flr);
@@ -155,20 +156,20 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (u > max)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP:
{
/* s limited to [0,1] */
/* i limited to [0,size-1] */
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u <= 0.0F)
i = 0;
else if (u >= 1.0F)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
@@ -177,13 +178,13 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
/* i limited to [0, size-1] */
const float min = 1.0F / (2.0F * size);
const float max = 1.0F - min;
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u < min)
i = 0;
else if (u > max)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
@@ -192,13 +193,13 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
/* i limited to [0, size-1] */
const float min = -1.0F / (2.0F * size);
const float max = 1.0F - min;
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u < min)
i = -1;
else if (u > max)
i = size;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
default:
@@ -225,7 +226,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
switch (wrapMode) {
case PIPE_TEX_WRAP_REPEAT:
u = s * size - 0.5F;
- *i0 = REMAINDER(ifloor(u), size);
+ *i0 = REMAINDER(util_ifloor(u), size);
*i1 = REMAINDER(*i0 + 1, size);
break;
case PIPE_TEX_WRAP_CLAMP:
@@ -236,7 +237,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
@@ -247,7 +248,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -265,19 +266,19 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
}
break;
case PIPE_TEX_WRAP_MIRROR_REPEAT:
{
- const int flr = ifloor(s);
+ const int flr = util_ifloor(s);
if (flr & 1)
u = 1.0F - (s - (float) flr);
else
u = s - (float) flr;
u = (u * size) - 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -286,23 +287,23 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
}
break;
case PIPE_TEX_WRAP_MIRROR_CLAMP:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (float) size;
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (float) size;
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -313,7 +314,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
{
const float min = -1.0F / (2.0F * size);
const float max = 1.0F - min;
- u = FABSF(s);
+ u = fabsf(s);
if (u <= min)
u = min * size;
else if (u >= max)
@@ -321,7 +322,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
}
break;
@@ -342,12 +343,12 @@ nearest_texcoord_unnorm(unsigned wrapMode, float s, unsigned size)
int i;
switch (wrapMode) {
case PIPE_TEX_WRAP_CLAMP:
- i = ifloor(s);
+ i = util_ifloor(s);
return CLAMP(i, 0, (int) size-1);
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
/* fall-through */
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- return ifloor( CLAMP(s, 0.5F, (float) size - 0.5F) );
+ return util_ifloor( CLAMP(s, 0.5F, (float) size - 0.5F) );
default:
assert(0);
return 0;
@@ -367,7 +368,7 @@ linear_texcoord_unnorm(unsigned wrapMode, float s, unsigned size,
case PIPE_TEX_WRAP_CLAMP:
/* Not exactly what the spec says, but it matches NVIDIA output */
s = CLAMP(s - 0.5F, 0.0f, (float) size - 1.0f);
- *i0 = ifloor(s);
+ *i0 = util_ifloor(s);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
@@ -375,7 +376,7 @@ linear_texcoord_unnorm(unsigned wrapMode, float s, unsigned size,
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
s = CLAMP(s, 0.5F, (float) size - 0.5F);
s -= 0.5F;
- *i0 = ifloor(s);
+ *i0 = util_ifloor(s);
*i1 = *i0 + 1;
if (*i1 > (int) size - 1)
*i1 = size - 1;
@@ -401,7 +402,7 @@ choose_cube_face(float rx, float ry, float rz, float *newS, float *newT)
+rz TEXTURE_CUBE_MAP_POSITIVE_Z_EXT +rx -ry rz
-rz TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT -rx -ry rz
*/
- const float arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz);
+ const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz);
unsigned face;
float sc, tc, ma;
@@ -476,16 +477,16 @@ compute_lambda(struct tgsi_sampler *sampler,
{
float dsdx = s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT];
float dsdy = s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT];
- dsdx = FABSF(dsdx);
- dsdy = FABSF(dsdy);
+ dsdx = fabsf(dsdx);
+ dsdy = fabsf(dsdy);
rho = MAX2(dsdx, dsdy) * sampler->texture->width[0];
}
if (t) {
float dtdx = t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT];
float dtdy = t[QUAD_TOP_LEFT] - t[QUAD_BOTTOM_LEFT];
float max;
- dtdx = FABSF(dtdx);
- dtdy = FABSF(dtdy);
+ dtdx = fabsf(dtdx);
+ dtdy = fabsf(dtdy);
max = MAX2(dtdx, dtdy) * sampler->texture->height[0];
rho = MAX2(rho, max);
}
@@ -493,13 +494,13 @@ compute_lambda(struct tgsi_sampler *sampler,
float dpdx = p[QUAD_BOTTOM_RIGHT] - p[QUAD_BOTTOM_LEFT];
float dpdy = p[QUAD_TOP_LEFT] - p[QUAD_BOTTOM_LEFT];
float max;
- dpdx = FABSF(dpdx);
- dpdy = FABSF(dpdy);
+ dpdx = fabsf(dpdx);
+ dpdy = fabsf(dpdy);
max = MAX2(dpdx, dpdy) * sampler->texture->depth[0];
rho = MAX2(rho, max);
}
- lambda = LOG2(rho);
+ lambda = util_fast_log2(rho);
lambda += lodbias + sampler->state->lod_bias;
lambda = CLAMP(lambda, sampler->state->min_lod, sampler->state->max_lod);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index f775591..cb48035 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -33,8 +33,9 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_state.h"
@@ -191,7 +192,7 @@ softpipe_texture_blanket(struct pipe_screen * screen,
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
spt->stride[0] = stride[0];
- pipe_buffer_reference(screen->winsys, &spt->buffer, buffer);
+ pipe_buffer_reference(screen, &spt->buffer, buffer);
return &spt->base;
}
@@ -207,7 +208,7 @@ softpipe_texture_release(struct pipe_screen *screen,
if (--(*pt)->refcount <= 0) {
struct softpipe_texture *spt = softpipe_texture(*pt);
- pipe_buffer_reference(screen->winsys, &spt->buffer, NULL);
+ pipe_buffer_reference(screen, &spt->buffer, NULL);
FREE(spt);
}
*pt = NULL;
@@ -230,7 +231,7 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe_buffer_reference(ws, &ps->buffer, spt->buffer);
+ pipe_buffer_reference(screen, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->block = pt->block;
ps->width = pt->width[level];
@@ -306,7 +307,7 @@ softpipe_surface_map( struct pipe_screen *screen,
return NULL;
}
- map = screen->winsys->buffer_map( screen->winsys, surface->buffer, flags );
+ map = pipe_buffer_map( screen, surface->buffer, flags );
if (map == NULL)
return NULL;
@@ -330,7 +331,7 @@ static void
softpipe_surface_unmap(struct pipe_screen *screen,
struct pipe_surface *surface)
{
- screen->winsys->buffer_unmap( screen->winsys, surface->buffer );
+ pipe_buffer_unmap( screen, surface->buffer );
}
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index 57c12ff..b50c984 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -32,9 +32,9 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_memory.h"
+#include "util/u_tile.h"
#include "sp_context.h"
#include "sp_surface.h"
#include "sp_texture.h"
diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README
index 81da610..e7a2f12 100644
--- a/src/gallium/drivers/trace/README
+++ b/src/gallium/drivers/trace/README
@@ -1,37 +1,64 @@
+ TRACE PIPE DRIVER
+
+
+= About =
+
This directory contains a Gallium3D pipe driver which traces all incoming calls.
+
+= Build Instructions =
+
To build, invoke scons on the top dir as
scons statetrackers=mesa drivers=softpipe,i915simple,trace winsys=xlib
+
+= Usage =
+
To use do
ln -s libGL.so build/linux-x86-debug/gallium/winsys/xlib/libGL.so.1
export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/gallium/winsys/xlib
- export GALLIUM_TRACE=y
ensure the right libGL.so is being picked by doing
- ldd `which glxingo`
+ ldd progs/trivial/tri
and then try running
- glxinfo
+ GALLIUM_TRACE=tri.trace progs/trivial/tri
-which should create a gallium.*.trace file, which is an XML file. You can view
-copying trace.xsl and trace.css to the same directory, and opening with a
-XSLT capable browser like Firefox or Internet Explorer. It often happens that
-the trace file was not properly terminated, and a
+which should create a tri.trace file, which is an XML file. You can view copying
+trace.xsl to the same directory, and opening with a XSLT capable browser such as
+Firefox or Internet Explorer.
- </trace>
-
-closing tag is missing from the file end. Add it before try to open or
-further transform it by doing
- echo '</trace>' >> gallium.??.trace
+= Integrating =
+
+You can integrate the trace pipe driver either inside the state tracker or the
+winsys. The procedure on both cases is the same. Let's assume you have a
+pipe_screen and a pipe_context pair obtained by the usual means (variable and
+function names are just for illustration purposes):
+
+ real_screen = real_screen_create(...);
+
+ real_context = real_context_create(...);
+
+The trace screen and pipe_context is then created by doing
+
+ trace_screen = trace_screen_create(real_screen);
+
+ trace_context = trace_context_create(trace_screen, real_context);
+
+You can then simply use trace_screen and trace_context instead of real_screen
+and real_context.
+
+Do not call trace_winsys_create. Simply pass trace_screen->winsys or
+trace_context->winsys in places you would pass winsys.
+You can create as many contexts you wish. Just ensure that you don't mistake
+trace_screen with real_screen when creating them.
-This is still work in progress.
--
Jose Fonseca <jrfonseca@tungstengraphics.com>
diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript
index 35507e2..0a6bfb8 100644
--- a/src/gallium/drivers/trace/SConscript
+++ b/src/gallium/drivers/trace/SConscript
@@ -3,14 +3,14 @@ Import('*')
env = env.Clone()
trace = env.ConvenienceLibrary(
- target = 'trace',
- source = [
+ target = 'trace',
+ source = [
'tr_context.c',
'tr_dump.c',
- 'tr_screen.c',
+ 'tr_screen.c',
'tr_state.c',
- 'tr_stream.c',
+ 'tr_texture.c',
'tr_winsys.c',
- ])
+ ])
Export('trace') \ No newline at end of file
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index f821263..1dd7719 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -25,33 +25,75 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "pipe/p_screen.h"
-#include "tr_stream.h"
#include "tr_dump.h"
#include "tr_state.h"
-#include "tr_winsys.h"
#include "tr_screen.h"
+#include "tr_texture.h"
+#include "tr_winsys.h"
#include "tr_context.h"
+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_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 *
+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_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;
+}
+
+
static INLINE void
trace_context_set_edgeflags(struct pipe_context *_pipe,
const unsigned *bitfield)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_edgeflags");
+ trace_dump_call_begin("pipe_context", "set_edgeflags");
- trace_dump_arg(stream, ptr, pipe);
+ trace_dump_arg(ptr, pipe);
/* FIXME: we don't know how big this array is */
- trace_dump_arg(stream, ptr, bitfield);
+ trace_dump_arg(ptr, bitfield);
pipe->set_edgeflags(pipe, bitfield);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -60,22 +102,21 @@ trace_context_draw_arrays(struct pipe_context *_pipe,
unsigned mode, unsigned start, unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
boolean result;
- trace_dump_call_begin(stream, "pipe_context", "draw_arrays");
+ trace_dump_call_begin("pipe_context", "draw_arrays");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, mode);
- trace_dump_arg(stream, uint, start);
- trace_dump_arg(stream, uint, count);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, mode);
+ trace_dump_arg(uint, start);
+ trace_dump_arg(uint, count);
result = pipe->draw_arrays(pipe, mode, start, count);;
- trace_dump_ret(stream, bool, result);
+ trace_dump_ret(bool, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -88,24 +129,25 @@ trace_context_draw_elements(struct pipe_context *_pipe,
unsigned mode, unsigned start, unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
boolean result;
- trace_dump_call_begin(stream, "pipe_context", "draw_elements");
+ trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
+
+ trace_dump_call_begin("pipe_context", "draw_elements");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, indexBuffer);
- trace_dump_arg(stream, uint, indexSize);
- trace_dump_arg(stream, uint, mode);
- trace_dump_arg(stream, uint, start);
- trace_dump_arg(stream, uint, count);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, indexBuffer);
+ trace_dump_arg(uint, indexSize);
+ trace_dump_arg(uint, mode);
+ trace_dump_arg(uint, start);
+ trace_dump_arg(uint, count);
result = pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);;
- trace_dump_ret(stream, bool, result);
+ trace_dump_ret(bool, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -122,29 +164,30 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
boolean result;
- trace_dump_call_begin(stream, "pipe_context", "draw_range_elements");
+ trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
+
+ trace_dump_call_begin("pipe_context", "draw_range_elements");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, indexBuffer);
- trace_dump_arg(stream, uint, indexSize);
- trace_dump_arg(stream, uint, minIndex);
- trace_dump_arg(stream, uint, maxIndex);
- trace_dump_arg(stream, uint, mode);
- trace_dump_arg(stream, uint, start);
- trace_dump_arg(stream, uint, count);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, indexBuffer);
+ trace_dump_arg(uint, indexSize);
+ trace_dump_arg(uint, minIndex);
+ trace_dump_arg(uint, maxIndex);
+ trace_dump_arg(uint, mode);
+ trace_dump_arg(uint, start);
+ trace_dump_arg(uint, count);
result = pipe->draw_range_elements(pipe,
indexBuffer,
indexSize, minIndex, maxIndex,
mode, start, count);
- trace_dump_ret(stream, bool, result);
+ trace_dump_ret(bool, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -155,20 +198,19 @@ trace_context_create_query(struct pipe_context *_pipe,
unsigned query_type)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_query *result;
- trace_dump_call_begin(stream, "pipe_context", "create_query");
+ trace_dump_call_begin("pipe_context", "create_query");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, query_type);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, query_type);
result = pipe->create_query(pipe, query_type);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -179,17 +221,16 @@ trace_context_destroy_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "destroy_query");
+ trace_dump_call_begin("pipe_context", "destroy_query");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, query);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, query);
pipe->destroy_query(pipe, query);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -198,17 +239,16 @@ trace_context_begin_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "begin_query");
+ trace_dump_call_begin("pipe_context", "begin_query");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, query);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, query);
pipe->begin_query(pipe, query);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -217,17 +257,16 @@ trace_context_end_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "end_query");
+ trace_dump_call_begin("pipe_context", "end_query");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, query);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, query);
pipe->end_query(pipe, query);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -238,22 +277,21 @@ trace_context_get_query_result(struct pipe_context *_pipe,
uint64 *presult)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
uint64 result;
boolean _result;
- trace_dump_call_begin(stream, "pipe_context", "get_query_result");
+ trace_dump_call_begin("pipe_context", "get_query_result");
- trace_dump_arg(stream, ptr, pipe);
+ trace_dump_arg(ptr, pipe);
_result = pipe->get_query_result(pipe, query, wait, presult);;
result = *presult;
- trace_dump_arg(stream, uint, result);
- trace_dump_ret(stream, bool, _result);
+ trace_dump_arg(uint, result);
+ trace_dump_ret(bool, _result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return _result;
}
@@ -264,20 +302,19 @@ trace_context_create_blend_state(struct pipe_context *_pipe,
const struct pipe_blend_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_blend_state");
+ trace_dump_call_begin("pipe_context", "create_blend_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, blend_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(blend_state, state);
result = pipe->create_blend_state(pipe, state);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -288,17 +325,16 @@ trace_context_bind_blend_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_blend_state");
+ trace_dump_call_begin("pipe_context", "bind_blend_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_blend_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -307,17 +343,16 @@ trace_context_delete_blend_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_blend_state");
+ trace_dump_call_begin("pipe_context", "delete_blend_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_blend_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -326,20 +361,19 @@ trace_context_create_sampler_state(struct pipe_context *_pipe,
const struct pipe_sampler_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_sampler_state");
+ trace_dump_call_begin("pipe_context", "create_sampler_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(sampler_state, state);
result = pipe->create_sampler_state(pipe, state);;
- trace_dump_ret(stream, sampler_state, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -350,18 +384,17 @@ trace_context_bind_sampler_states(struct pipe_context *_pipe,
unsigned num_states, void **states)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_sampler_states");
+ trace_dump_call_begin("pipe_context", "bind_sampler_states");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, num_states);
- trace_dump_arg_array(stream, ptr, states, num_states);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, num_states);
+ trace_dump_arg_array(ptr, states, num_states);
pipe->bind_sampler_states(pipe, num_states, states);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -370,17 +403,16 @@ trace_context_delete_sampler_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_sampler_state");
+ trace_dump_call_begin("pipe_context", "delete_sampler_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_sampler_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -389,20 +421,19 @@ trace_context_create_rasterizer_state(struct pipe_context *_pipe,
const struct pipe_rasterizer_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_rasterizer_state");
+ trace_dump_call_begin("pipe_context", "create_rasterizer_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, rasterizer_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(rasterizer_state, state);
result = pipe->create_rasterizer_state(pipe, state);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -413,17 +444,16 @@ trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_rasterizer_state");
+ trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_rasterizer_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -432,17 +462,16 @@ trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_rasterizer_state");
+ trace_dump_call_begin("pipe_context", "delete_rasterizer_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_rasterizer_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -451,20 +480,19 @@ trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
const struct pipe_depth_stencil_alpha_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_depth_stencil_alpha_state");
+ trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
result = pipe->create_depth_stencil_alpha_state(pipe, state);;
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, depth_stencil_alpha_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(depth_stencil_alpha_state, state);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -475,17 +503,16 @@ trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_depth_stencil_alpha_state");
+ trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_depth_stencil_alpha_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -494,17 +521,16 @@ trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_depth_stencil_alpha_state");
+ trace_dump_call_begin("pipe_context", "delete_depth_stencil_alpha_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_depth_stencil_alpha_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -513,20 +539,19 @@ trace_context_create_fs_state(struct pipe_context *_pipe,
const struct pipe_shader_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_fs_state");
+ trace_dump_call_begin("pipe_context", "create_fs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, shader_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(shader_state, state);
result = pipe->create_fs_state(pipe, state);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -537,17 +562,16 @@ trace_context_bind_fs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_fs_state");
+ trace_dump_call_begin("pipe_context", "bind_fs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_fs_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -556,17 +580,16 @@ trace_context_delete_fs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_fs_state");
+ trace_dump_call_begin("pipe_context", "delete_fs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_fs_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -575,20 +598,19 @@ trace_context_create_vs_state(struct pipe_context *_pipe,
const struct pipe_shader_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_vs_state");
+ trace_dump_call_begin("pipe_context", "create_vs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, shader_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(shader_state, state);
result = pipe->create_vs_state(pipe, state);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -599,17 +621,16 @@ trace_context_bind_vs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_vs_state");
+ trace_dump_call_begin("pipe_context", "bind_vs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_vs_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -618,17 +639,16 @@ trace_context_delete_vs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_vs_state");
+ trace_dump_call_begin("pipe_context", "delete_vs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_vs_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -637,17 +657,16 @@ trace_context_set_blend_color(struct pipe_context *_pipe,
const struct pipe_blend_color *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_blend_color");
+ trace_dump_call_begin("pipe_context", "set_blend_color");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, blend_color, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(blend_color, state);
pipe->set_blend_color(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -656,17 +675,16 @@ trace_context_set_clip_state(struct pipe_context *_pipe,
const struct pipe_clip_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_clip_state");
+ trace_dump_call_begin("pipe_context", "set_clip_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, clip_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(clip_state, state);
pipe->set_clip_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -676,19 +694,20 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe,
const struct pipe_constant_buffer *buffer)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_constant_buffer");
+ trace_winsys_user_buffer_update(_pipe->winsys, (struct pipe_buffer *)buffer);
+
+ trace_dump_call_begin("pipe_context", "set_constant_buffer");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, shader);
- trace_dump_arg(stream, uint, index);
- trace_dump_arg(stream, constant_buffer, buffer);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, shader);
+ trace_dump_arg(uint, index);
+ trace_dump_arg(constant_buffer, buffer);
pipe->set_constant_buffer(pipe, shader, index, buffer);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -697,17 +716,27 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
const struct pipe_framebuffer_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
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->num_cbufs; ++i)
+ unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
+ for(i = state->num_cbufs; i < PIPE_MAX_COLOR_BUFS; ++i)
+ 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_call_begin(stream, "pipe_context", "set_framebuffer_state");
-
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, framebuffer_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(framebuffer_state, state);
pipe->set_framebuffer_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -716,17 +745,16 @@ trace_context_set_polygon_stipple(struct pipe_context *_pipe,
const struct pipe_poly_stipple *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_polygon_stipple");
+ trace_dump_call_begin("pipe_context", "set_polygon_stipple");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, poly_stipple, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(poly_stipple, state);
pipe->set_polygon_stipple(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -735,17 +763,16 @@ trace_context_set_scissor_state(struct pipe_context *_pipe,
const struct pipe_scissor_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_scissor_state");
+ trace_dump_call_begin("pipe_context", "set_scissor_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, scissor_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(scissor_state, state);
pipe->set_scissor_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -754,17 +781,16 @@ trace_context_set_viewport_state(struct pipe_context *_pipe,
const struct pipe_viewport_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_viewport_state");
+ trace_dump_call_begin("pipe_context", "set_viewport_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, viewport_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(viewport_state, state);
pipe->set_viewport_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -774,18 +800,23 @@ trace_context_set_sampler_textures(struct pipe_context *_pipe,
struct pipe_texture **textures)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
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;
- trace_dump_call_begin(stream, "pipe_context", "set_sampler_textures");
+ trace_dump_call_begin("pipe_context", "set_sampler_textures");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, num_textures);
- trace_dump_arg_array(stream, ptr, textures, num_textures);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, num_textures);
+ trace_dump_arg_array(ptr, textures, num_textures);
pipe->set_sampler_textures(pipe, num_textures, textures);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -795,21 +826,24 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe,
const struct pipe_vertex_buffer *buffers)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
+ unsigned i;
+
+ for(i = 0; i < num_buffers; ++i)
+ trace_winsys_user_buffer_update(_pipe->winsys, buffers[i].buffer);
- trace_dump_call_begin(stream, "pipe_context", "set_vertex_buffers");
+ trace_dump_call_begin("pipe_context", "set_vertex_buffers");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, num_buffers);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, num_buffers);
- trace_dump_arg_begin(stream, "buffers");
- trace_dump_struct_array(stream, vertex_buffer, buffers, num_buffers);
- trace_dump_arg_end(stream);
+ 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);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -819,21 +853,20 @@ trace_context_set_vertex_elements(struct pipe_context *_pipe,
const struct pipe_vertex_element *elements)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_vertex_elements");
+ trace_dump_call_begin("pipe_context", "set_vertex_elements");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, num_elements);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, num_elements);
- trace_dump_arg_begin(stream, "elements");
- trace_dump_struct_array(stream, vertex_element, elements, num_elements);
- trace_dump_arg_end(stream);
+ trace_dump_arg_begin("elements");
+ trace_dump_struct_array(vertex_element, elements, num_elements);
+ trace_dump_arg_end();
pipe->set_vertex_elements(pipe, num_elements, elements);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -847,27 +880,29 @@ trace_context_surface_copy(struct pipe_context *_pipe,
unsigned width, unsigned height)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "surface_copy");
-
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, bool, do_flip);
- trace_dump_arg(stream, ptr, dest);
- trace_dump_arg(stream, uint, destx);
- trace_dump_arg(stream, uint, desty);
- trace_dump_arg(stream, ptr, src);
- trace_dump_arg(stream, uint, srcx);
- trace_dump_arg(stream, uint, srcy);
- trace_dump_arg(stream, uint, width);
- trace_dump_arg(stream, uint, height);
+ 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);
+ trace_dump_arg(ptr, src);
+ trace_dump_arg(uint, srcx);
+ trace_dump_arg(uint, srcy);
+ trace_dump_arg(uint, width);
+ trace_dump_arg(uint, height);
pipe->surface_copy(pipe, do_flip,
dest, destx, desty,
src, srcx, srcy, width, height);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -879,21 +914,22 @@ trace_context_surface_fill(struct pipe_context *_pipe,
unsigned value)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "surface_fill");
+ dst = trace_surface_unwrap(tr_ctx, dst);
+
+ trace_dump_call_begin("pipe_context", "surface_fill");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, dst);
- trace_dump_arg(stream, uint, dstx);
- trace_dump_arg(stream, uint, dsty);
- trace_dump_arg(stream, uint, width);
- trace_dump_arg(stream, uint, height);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, dst);
+ trace_dump_arg(uint, dstx);
+ trace_dump_arg(uint, dsty);
+ trace_dump_arg(uint, width);
+ trace_dump_arg(uint, height);
pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -903,18 +939,19 @@ trace_context_clear(struct pipe_context *_pipe,
unsigned clearValue)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "clear");
+ surface = trace_surface_unwrap(tr_ctx, surface);
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, surface);
- trace_dump_arg(stream, uint, clearValue);
+ trace_dump_call_begin("pipe_context", "clear");
+
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, surface);
+ trace_dump_arg(uint, clearValue);
pipe->clear(pipe, surface, clearValue);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -924,18 +961,19 @@ trace_context_flush(struct pipe_context *_pipe,
struct pipe_fence_handle **fence)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "flush");
+ trace_dump_call_begin("pipe_context", "flush");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, flags);
- trace_dump_arg(stream, ptr, fence);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, flags);
pipe->flush(pipe, flags, fence);;
- trace_dump_call_end(stream);
+ if(fence)
+ trace_dump_ret(ptr, *fence);
+
+ trace_dump_call_end();
}
@@ -943,36 +981,38 @@ static INLINE void
trace_context_destroy(struct pipe_context *_pipe)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "destroy");
+ trace_dump_call_begin("pipe_context", "destroy");
- trace_dump_arg(stream, ptr, pipe);
+ trace_dump_arg(ptr, pipe);
pipe->destroy(pipe);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
FREE(tr_ctx);
}
struct pipe_context *
-trace_context_create(struct pipe_context *pipe)
+trace_context_create(struct pipe_screen *screen,
+ struct pipe_context *pipe)
{
- struct trace_stream *stream;
struct trace_context *tr_ctx;
- if(!debug_get_bool_option("GALLIUM_TRACE", FALSE))
- return pipe;
+ if(!pipe)
+ goto error1;
+
+ if(!trace_dump_enabled())
+ goto error1;
tr_ctx = CALLOC_STRUCT(trace_context);
if(!tr_ctx)
- return NULL;
+ goto error1;
- tr_ctx->base.winsys = pipe->winsys;
- tr_ctx->base.screen = pipe->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;
@@ -1017,18 +1057,16 @@ trace_context_create(struct pipe_context *pipe)
tr_ctx->base.flush = trace_context_flush;
tr_ctx->pipe = pipe;
- tr_ctx->stream = stream = trace_winsys(pipe->winsys)->stream;
- /* We don't want to trace the internal pipe calls */
- pipe->winsys = trace_winsys(pipe->winsys)->winsys;
- pipe->screen = trace_screen(pipe->screen)->screen;
-
- trace_dump_call_begin(stream, "", "pipe_context_create");
- trace_dump_arg_begin(stream, "screen");
- trace_dump_ptr(stream, pipe->screen);
- trace_dump_arg_end(stream);
- trace_dump_ret(stream, ptr, pipe);
- trace_dump_call_end(stream);
+ trace_dump_call_begin("", "pipe_context_create");
+ trace_dump_arg_begin("screen");
+ trace_dump_ptr(pipe->screen);
+ trace_dump_arg_end();
+ 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 2c0b0c7..7831900 100644
--- a/src/gallium/drivers/trace/tr_context.h
+++ b/src/gallium/drivers/trace/tr_context.h
@@ -34,7 +34,9 @@
#include "pipe/p_context.h"
-struct trace_stream;
+#ifdef __cplusplus
+extern "C" {
+#endif
struct trace_context
@@ -42,8 +44,6 @@ struct trace_context
struct pipe_context base;
struct pipe_context *pipe;
-
- struct trace_stream *stream;
};
@@ -57,7 +57,12 @@ trace_context(struct pipe_context *pipe)
struct pipe_context *
-trace_context_create(struct pipe_context *pipe);
+trace_context_create(struct pipe_screen *screen,
+ struct pipe_context *pipe);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* TR_CONTEXT_H_ */
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 5269c4d..a0ead0d 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -38,326 +38,367 @@
* @author Jose Fonseca <jrfonseca@tungstengraphics.com>
*/
+#include "pipe/p_config.h"
+
+#if defined(PIPE_OS_LINUX)
+#include <stdlib.h>
+#endif
#include "pipe/p_compiler.h"
+#include "pipe/p_debug.h"
+#include "util/u_memory.h"
#include "util/u_string.h"
+#include "util/u_stream.h"
-#include "tr_stream.h"
#include "tr_dump.h"
+static struct util_stream *stream = NULL;
+static unsigned refcount = 0;
+
+
+static INLINE void
+trace_dump_write(const char *buf, size_t size)
+{
+ if(stream)
+ util_stream_write(stream, buf, size);
+}
+
+
static INLINE void
-trace_dump_write(struct trace_stream *stream, const char *s)
+trace_dump_writes(const char *s)
{
- trace_stream_write(stream, s, strlen(s));
+ trace_dump_write(s, strlen(s));
}
static INLINE void
-trace_dump_writef(struct trace_stream *stream, const char *format, ...)
+trace_dump_writef(const char *format, ...)
{
- char buf[1024];
+ static char buf[1024];
+ unsigned len;
va_list ap;
va_start(ap, format);
- util_vsnprintf(buf, sizeof(buf), format, ap);
+ len = util_vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
- trace_dump_write(stream, buf);
+ trace_dump_write(buf, len);
}
static INLINE void
-trace_dump_escape(struct trace_stream *stream, const char *str)
+trace_dump_escape(const char *str)
{
const unsigned char *p = (const unsigned char *)str;
unsigned char c;
while((c = *p++) != 0) {
if(c == '<')
- trace_dump_write(stream, "&lt;");
+ trace_dump_writes("&lt;");
else if(c == '>')
- trace_dump_write(stream, "&gt;");
+ trace_dump_writes("&gt;");
else if(c == '&')
- trace_dump_write(stream, "&amp;");
+ trace_dump_writes("&amp;");
else if(c == '\'')
- trace_dump_write(stream, "&apos;");
+ trace_dump_writes("&apos;");
else if(c == '\"')
- trace_dump_write(stream, "&quot;");
+ trace_dump_writes("&quot;");
else if(c >= 0x20 && c <= 0x7e)
- trace_dump_writef(stream, "%c", c);
+ trace_dump_writef("%c", c);
else
- trace_dump_writef(stream, "&#%u;", c);
+ trace_dump_writef("&#%u;", c);
}
}
static INLINE void
-trace_dump_indent(struct trace_stream *stream, unsigned level)
+trace_dump_indent(unsigned level)
{
unsigned i;
for(i = 0; i < level; ++i)
- trace_dump_write(stream, "\t");
+ trace_dump_writes("\t");
}
static INLINE void
-trace_dump_newline(struct trace_stream *stream)
+trace_dump_newline(void)
{
- trace_dump_write(stream, "\n");
+ trace_dump_writes("\n");
}
static INLINE void
-trace_dump_tag(struct trace_stream *stream,
- const char *name)
+trace_dump_tag(const char *name)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, "/>");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes("/>");
}
static INLINE void
-trace_dump_tag_begin(struct trace_stream *stream,
- const char *name)
+trace_dump_tag_begin(const char *name)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, ">");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes(">");
}
static INLINE void
-trace_dump_tag_begin1(struct trace_stream *stream,
- const char *name,
+trace_dump_tag_begin1(const char *name,
const char *attr1, const char *value1)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, " ");
- trace_dump_write(stream, attr1);
- trace_dump_write(stream, "='");
- trace_dump_escape(stream, value1);
- trace_dump_write(stream, "'>");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes(" ");
+ trace_dump_writes(attr1);
+ trace_dump_writes("='");
+ trace_dump_escape(value1);
+ trace_dump_writes("'>");
}
static INLINE void
-trace_dump_tag_begin2(struct trace_stream *stream,
- const char *name,
+trace_dump_tag_begin2(const char *name,
const char *attr1, const char *value1,
const char *attr2, const char *value2)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, " ");
- trace_dump_write(stream, attr1);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value1);
- trace_dump_write(stream, "\' ");
- trace_dump_write(stream, attr2);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value2);
- trace_dump_write(stream, "\'>");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes(" ");
+ trace_dump_writes(attr1);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value1);
+ trace_dump_writes("\' ");
+ trace_dump_writes(attr2);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value2);
+ trace_dump_writes("\'>");
}
static INLINE void
-trace_dump_tag_begin3(struct trace_stream *stream,
- const char *name,
+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)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, " ");
- trace_dump_write(stream, attr1);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value1);
- trace_dump_write(stream, "\' ");
- trace_dump_write(stream, attr2);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value2);
- trace_dump_write(stream, "\' ");
- trace_dump_write(stream, attr3);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value3);
- trace_dump_write(stream, "\'>");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes(" ");
+ trace_dump_writes(attr1);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value1);
+ trace_dump_writes("\' ");
+ trace_dump_writes(attr2);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value2);
+ trace_dump_writes("\' ");
+ trace_dump_writes(attr3);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value3);
+ trace_dump_writes("\'>");
}
static INLINE void
-trace_dump_tag_end(struct trace_stream *stream,
- const char *name)
+trace_dump_tag_end(const char *name)
{
- trace_dump_write(stream, "</");
- trace_dump_write(stream, name);
- trace_dump_write(stream, ">");
+ trace_dump_writes("</");
+ trace_dump_writes(name);
+ trace_dump_writes(">");
}
-
-void trace_dump_trace_begin(struct trace_stream *stream,
- unsigned version)
+static void
+trace_dump_trace_close(void)
{
- trace_dump_write(stream, "<?xml version='1.0' encoding='UTF-8'?>\n");
- trace_dump_write(stream, "<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
- trace_dump_writef(stream, "<trace version='%u'>\n", version);
+ if(stream) {
+ trace_dump_writes("</trace>\n");
+ util_stream_close(stream);
+ stream = NULL;
+ refcount = 0;
+ }
}
+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 */
+ atexit(trace_dump_trace_close);
+#endif
+ }
+
+ ++refcount;
+
+ return TRUE;
+}
+
+boolean trace_dump_enabled(void)
+{
+ return stream ? TRUE : FALSE;
+}
-void trace_dump_trace_end(struct trace_stream *stream)
+void trace_dump_trace_end(void)
{
- trace_dump_write(stream, "</trace>\n");
+ if(stream)
+ if(!--refcount)
+ trace_dump_trace_close();
}
-void trace_dump_call_begin(struct trace_stream *stream,
- const char *klass, const char *method)
+void trace_dump_call_begin(const char *klass, const char *method)
{
- trace_dump_indent(stream, 1);
- trace_dump_tag_begin2(stream, "call", "class", klass, "method", method);
- trace_dump_newline(stream);
+ trace_dump_indent(1);
+ trace_dump_tag_begin2("call", "class", klass, "method", method);
+ trace_dump_newline();
}
-void trace_dump_call_end(struct trace_stream *stream)
+void trace_dump_call_end(void)
{
- trace_dump_indent(stream, 1);
- trace_dump_tag_end(stream, "call");
- trace_dump_newline(stream);
+ trace_dump_indent(1);
+ trace_dump_tag_end("call");
+ trace_dump_newline();
+ util_stream_flush(stream);
}
-void trace_dump_arg_begin(struct trace_stream *stream,
- const char *name)
+void trace_dump_arg_begin(const char *name)
{
- trace_dump_indent(stream, 2);
- trace_dump_tag_begin1(stream, "arg", "name", name);
+ trace_dump_indent(2);
+ trace_dump_tag_begin1("arg", "name", name);
}
-void trace_dump_arg_end(struct trace_stream *stream)
+void trace_dump_arg_end(void)
{
- trace_dump_tag_end(stream, "arg");
- trace_dump_newline(stream);
+ trace_dump_tag_end("arg");
+ trace_dump_newline();
}
-void trace_dump_ret_begin(struct trace_stream *stream)
+void trace_dump_ret_begin(void)
{
- trace_dump_indent(stream, 2);
- trace_dump_tag_begin(stream, "ret");
+ trace_dump_indent(2);
+ trace_dump_tag_begin("ret");
}
-void trace_dump_ret_end(struct trace_stream *stream)
+void trace_dump_ret_end(void)
{
- trace_dump_tag_end(stream, "ret");
- trace_dump_newline(stream);
+ trace_dump_tag_end("ret");
+ trace_dump_newline();
}
-void trace_dump_bool(struct trace_stream *stream,
- int value)
+void trace_dump_bool(int value)
{
- trace_dump_writef(stream, "<bool>%c</bool>", value ? '1' : '0');
+ trace_dump_writef("<bool>%c</bool>", value ? '1' : '0');
}
-void trace_dump_int(struct trace_stream *stream,
- long int value)
+void trace_dump_int(long long int value)
{
- trace_dump_writef(stream, "<int>%li</int>", value);
+ trace_dump_writef("<int>%lli</int>", value);
}
-void trace_dump_uint(struct trace_stream *stream,
- long unsigned value)
+void trace_dump_uint(long long unsigned value)
{
- trace_dump_writef(stream, "<uint>%lu</uint>", value);
+ trace_dump_writef("<uint>%llu</uint>", value);
}
-void trace_dump_float(struct trace_stream *stream,
- double value)
+void trace_dump_float(double value)
{
- trace_dump_writef(stream, "<float>%g</float>", value);
+ trace_dump_writef("<float>%g</float>", value);
}
-void trace_dump_bytes(struct trace_stream *stream,
- const void *data,
+void trace_dump_bytes(const void *data,
long unsigned size)
{
static const char hex_table[16] = "0123456789ABCDEF";
const uint8_t *p = data;
long unsigned i;
- trace_dump_write(stream, "<bytes>");
+ trace_dump_writes("<bytes>");
for(i = 0; i < size; ++i) {
uint8_t byte = *p++;
char hex[2];
hex[0] = hex_table[byte >> 4];
hex[1] = hex_table[byte & 0xf];
- trace_stream_write(stream, hex, 2);
+ trace_dump_write(hex, 2);
}
- trace_dump_write(stream, "</bytes>");
+ trace_dump_writes("</bytes>");
}
-void trace_dump_string(struct trace_stream *stream,
- const char *str)
+void trace_dump_string(const char *str)
{
- trace_dump_write(stream, "<string>");
- trace_dump_escape(stream, str);
- trace_dump_write(stream, "</string>");
+ trace_dump_writes("<string>");
+ trace_dump_escape(str);
+ trace_dump_writes("</string>");
}
-void trace_dump_enum(struct trace_stream *stream,
- const char *value)
+void trace_dump_enum(const char *value)
{
- trace_dump_write(stream, "<enum>");
- trace_dump_escape(stream, value);
- trace_dump_write(stream, "</enum>");
+ trace_dump_writes("<enum>");
+ trace_dump_escape(value);
+ trace_dump_writes("</enum>");
}
-void trace_dump_array_begin(struct trace_stream *stream)
+void trace_dump_array_begin(void)
{
- trace_dump_write(stream, "<array>");
+ trace_dump_writes("<array>");
}
-void trace_dump_array_end(struct trace_stream *stream)
+void trace_dump_array_end(void)
{
- trace_dump_write(stream, "</array>");
+ trace_dump_writes("</array>");
}
-void trace_dump_elem_begin(struct trace_stream *stream)
+void trace_dump_elem_begin(void)
{
- trace_dump_write(stream, "<elem>");
+ trace_dump_writes("<elem>");
}
-void trace_dump_elem_end(struct trace_stream *stream)
+void trace_dump_elem_end(void)
{
- trace_dump_write(stream, "</elem>");
+ trace_dump_writes("</elem>");
}
-void trace_dump_struct_begin(struct trace_stream *stream,
- const char *name)
+void trace_dump_struct_begin(const char *name)
{
- trace_dump_writef(stream, "<struct name='%s'>", name);
+ trace_dump_writef("<struct name='%s'>", name);
}
-void trace_dump_struct_end(struct trace_stream *stream)
+void trace_dump_struct_end(void)
{
- trace_dump_write(stream, "</struct>");
+ trace_dump_writes("</struct>");
}
-void trace_dump_member_begin(struct trace_stream *stream,
- const char *name)
+void trace_dump_member_begin(const char *name)
{
- trace_dump_writef(stream, "<member name='%s'>", name);
+ trace_dump_writef("<member name='%s'>", name);
}
-void trace_dump_member_end(struct trace_stream *stream)
+void trace_dump_member_end(void)
{
- trace_dump_write(stream, "</member>");
+ trace_dump_writes("</member>");
}
-void trace_dump_null(struct trace_stream *stream)
+void trace_dump_null(void)
{
- trace_dump_write(stream, "<null/>");
+ trace_dump_writes("<null/>");
}
-void trace_dump_ptr(struct trace_stream *stream,
- const void *value)
+void trace_dump_ptr(const void *value)
{
if(value)
- trace_dump_writef(stream, "<ptr>%p</ptr>", value);
+ trace_dump_writef("<ptr>0x%08lx</ptr>", (unsigned long)(uintptr_t)value);
else
- trace_dump_null(stream);
+ trace_dump_null();
}
diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h
index b2367c3..76a5373 100644
--- a/src/gallium/drivers/trace/tr_dump.h
+++ b/src/gallium/drivers/trace/tr_dump.h
@@ -4,7 +4,7 @@
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation streams (the
+ * copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
@@ -34,100 +34,98 @@
#define TR_DUMP_H
-#include "pipe/p_util.h"
-
-
-struct trace_stream;
-
-
-void trace_dump_trace_begin(struct trace_stream *stream, unsigned version);
-void trace_dump_trace_end(struct trace_stream *stream);
-void trace_dump_call_begin(struct trace_stream *stream, const char *klass, const char *method);
-void trace_dump_call_end(struct trace_stream *stream);
-void trace_dump_arg_begin(struct trace_stream *stream, const char *name);
-void trace_dump_arg_end(struct trace_stream *stream);
-void trace_dump_ret_begin(struct trace_stream *stream);
-void trace_dump_ret_end(struct trace_stream *stream);
-void trace_dump_bool(struct trace_stream *stream, int value);
-void trace_dump_int(struct trace_stream *stream, long int value);
-void trace_dump_uint(struct trace_stream *stream, long unsigned value);
-void trace_dump_float(struct trace_stream *stream, double value);
-void trace_dump_bytes(struct trace_stream *stream, const void *data, long unsigned size);
-void trace_dump_string(struct trace_stream *stream, const char *str);
-void trace_dump_enum(struct trace_stream *stream, const char *value);
-void trace_dump_array_begin(struct trace_stream *stream);
-void trace_dump_array_end(struct trace_stream *stream);
-void trace_dump_elem_begin(struct trace_stream *stream);
-void trace_dump_elem_end(struct trace_stream *stream);
-void trace_dump_struct_begin(struct trace_stream *stream, const char *name);
-void trace_dump_struct_end(struct trace_stream *stream);
-void trace_dump_member_begin(struct trace_stream *stream, const char *name);
-void trace_dump_member_end(struct trace_stream *stream);
-void trace_dump_null(struct trace_stream *stream);
-void trace_dump_ptr(struct trace_stream *stream, const void *value);
+#include "pipe/p_compiler.h"
+
+
+boolean trace_dump_trace_begin(void);
+boolean trace_dump_enabled(void);
+void trace_dump_trace_end(void);
+void trace_dump_call_begin(const char *klass, const char *method);
+void trace_dump_call_end(void);
+void trace_dump_arg_begin(const char *name);
+void trace_dump_arg_end(void);
+void trace_dump_ret_begin(void);
+void trace_dump_ret_end(void);
+void trace_dump_bool(int value);
+void trace_dump_int(long long int value);
+void trace_dump_uint(long long unsigned value);
+void trace_dump_float(double value);
+void trace_dump_bytes(const void *data, long unsigned size);
+void trace_dump_string(const char *str);
+void trace_dump_enum(const char *value);
+void trace_dump_array_begin(void);
+void trace_dump_array_end(void);
+void trace_dump_elem_begin(void);
+void trace_dump_elem_end(void);
+void trace_dump_struct_begin(const char *name);
+void trace_dump_struct_end(void);
+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);
/*
* Code saving macros.
*/
-#define trace_dump_arg(_stream, _type, _arg) \
+#define trace_dump_arg(_type, _arg) \
do { \
- trace_dump_arg_begin(_stream, #_arg); \
- trace_dump_##_type(_stream, _arg); \
- trace_dump_arg_end(_stream); \
+ trace_dump_arg_begin(#_arg); \
+ trace_dump_##_type(_arg); \
+ trace_dump_arg_end(); \
} while(0)
-#define trace_dump_ret(_stream, _type, _arg) \
+#define trace_dump_ret(_type, _arg) \
do { \
- trace_dump_ret_begin(_stream); \
- trace_dump_##_type(_stream, _arg); \
- trace_dump_ret_end(_stream); \
+ trace_dump_ret_begin(); \
+ trace_dump_##_type(_arg); \
+ trace_dump_ret_end(); \
} while(0)
-#define trace_dump_array(_stream, _type, _obj, _size) \
+#define trace_dump_array(_type, _obj, _size) \
do { \
unsigned long idx; \
- trace_dump_array_begin(_stream); \
+ trace_dump_array_begin(); \
for(idx = 0; idx < (_size); ++idx) { \
- trace_dump_elem_begin(_stream); \
- trace_dump_##_type(_stream, (_obj)[idx]); \
- trace_dump_elem_end(_stream); \
+ trace_dump_elem_begin(); \
+ trace_dump_##_type((_obj)[idx]); \
+ trace_dump_elem_end(); \
} \
- trace_dump_array_end(_stream); \
+ trace_dump_array_end(); \
} while(0)
-#define trace_dump_struct_array(_stream, _type, _obj, _size) \
+#define trace_dump_struct_array(_type, _obj, _size) \
do { \
unsigned long idx; \
- trace_dump_array_begin(_stream); \
+ trace_dump_array_begin(); \
for(idx = 0; idx < (_size); ++idx) { \
- trace_dump_elem_begin(_stream); \
- trace_dump_##_type(_stream, &(_obj)[idx]); \
- trace_dump_elem_end(_stream); \
+ trace_dump_elem_begin(); \
+ trace_dump_##_type(&(_obj)[idx]); \
+ trace_dump_elem_end(); \
} \
- trace_dump_array_end(_stream); \
+ trace_dump_array_end(); \
} while(0)
-#define trace_dump_member(_stream, _type, _obj, _member) \
+#define trace_dump_member(_type, _obj, _member) \
do { \
- trace_dump_member_begin(_stream, #_member); \
- trace_dump_##_type(_stream, (_obj)->_member); \
- trace_dump_member_end(_stream); \
+ trace_dump_member_begin(#_member); \
+ trace_dump_##_type((_obj)->_member); \
+ trace_dump_member_end(); \
} while(0)
-#define trace_dump_arg_array(_stream, _type, _arg, _size) \
+#define trace_dump_arg_array(_type, _arg, _size) \
do { \
- trace_dump_arg_begin(_stream, #_arg); \
- trace_dump_array(_stream, _type, _arg, _size); \
- trace_dump_arg_end(_stream); \
+ trace_dump_arg_begin(#_arg); \
+ trace_dump_array(_type, _arg, _size); \
+ trace_dump_arg_end(); \
} while(0)
-#define trace_dump_member_array(_stream, _type, _obj, _member) \
+#define trace_dump_member_array(_type, _obj, _member) \
do { \
- trace_dump_member_begin(_stream, #_member); \
- trace_dump_array(_stream, _type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
- trace_dump_member_end(_stream); \
+ trace_dump_member_begin(#_member); \
+ trace_dump_array(_type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
+ trace_dump_member_end(); \
} while(0)
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 27c2180..8789f86 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -25,12 +25,12 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
-#include "tr_stream.h"
#include "tr_dump.h"
#include "tr_state.h"
#include "tr_winsys.h"
+#include "tr_texture.h"
#include "tr_screen.h"
@@ -38,19 +38,18 @@ static const char *
trace_screen_get_name(struct pipe_screen *_screen)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
const char *result;
- trace_dump_call_begin(stream, "pipe_screen", "get_name");
+ trace_dump_call_begin("pipe_screen", "get_name");
- trace_dump_arg(stream, ptr, screen);
+ trace_dump_arg(ptr, screen);
result = screen->get_name(screen);
- trace_dump_ret(stream, string, result);
+ trace_dump_ret(string, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -60,19 +59,18 @@ static const char *
trace_screen_get_vendor(struct pipe_screen *_screen)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
const char *result;
- trace_dump_call_begin(stream, "pipe_screen", "get_vendor");
+ trace_dump_call_begin("pipe_screen", "get_vendor");
- trace_dump_arg(stream, ptr, screen);
+ trace_dump_arg(ptr, screen);
result = screen->get_vendor(screen);
- trace_dump_ret(stream, string, result);
+ trace_dump_ret(string, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -83,20 +81,19 @@ trace_screen_get_param(struct pipe_screen *_screen,
int param)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
int result;
- trace_dump_call_begin(stream, "pipe_screen", "get_param");
+ trace_dump_call_begin("pipe_screen", "get_param");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, int, param);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(int, param);
result = screen->get_param(screen, param);
- trace_dump_ret(stream, int, result);
+ trace_dump_ret(int, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -107,20 +104,19 @@ trace_screen_get_paramf(struct pipe_screen *_screen,
int param)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
float result;
- trace_dump_call_begin(stream, "pipe_screen", "get_paramf");
+ trace_dump_call_begin("pipe_screen", "get_paramf");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, int, param);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(int, param);
result = screen->get_paramf(screen, param);
- trace_dump_ret(stream, float, result);
+ trace_dump_ret(float, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -134,23 +130,22 @@ trace_screen_is_format_supported(struct pipe_screen *_screen,
unsigned geom_flags)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
boolean result;
- trace_dump_call_begin(stream, "pipe_screen", "is_format_supported");
+ trace_dump_call_begin("pipe_screen", "is_format_supported");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, format, format);
- trace_dump_arg(stream, int, target);
- trace_dump_arg(stream, uint, tex_usage);
- trace_dump_arg(stream, uint, geom_flags);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(format, format);
+ trace_dump_arg(int, target);
+ trace_dump_arg(uint, tex_usage);
+ trace_dump_arg(uint, geom_flags);
result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags);
- trace_dump_ret(stream, bool, result);
+ trace_dump_ret(bool, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -161,20 +156,21 @@ trace_screen_texture_create(struct pipe_screen *_screen,
const struct pipe_texture *templat)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
struct pipe_texture *result;
- trace_dump_call_begin(stream, "pipe_screen", "texture_create");
+ trace_dump_call_begin("pipe_screen", "texture_create");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, template, templat);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(template, templat);
result = screen->texture_create(screen, templat);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
+
+ result = trace_texture_create(tr_scr, result);
return result;
}
@@ -187,23 +183,24 @@ trace_screen_texture_blanket(struct pipe_screen *_screen,
struct pipe_buffer *buffer)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
unsigned pitch = *ppitch;
struct pipe_texture *result;
- trace_dump_call_begin(stream, "pipe_screen", "texture_blanket");
+ trace_dump_call_begin("pipe_screen", "texture_blanket");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, template, templat);
- trace_dump_arg(stream, uint, pitch);
- trace_dump_arg(stream, ptr, buffer);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(template, templat);
+ trace_dump_arg(uint, pitch);
+ trace_dump_arg(ptr, buffer);
result = screen->texture_blanket(screen, templat, ppitch, buffer);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
- trace_dump_call_end(stream);
+ result = trace_texture_create(tr_scr, result);
return result;
}
@@ -214,20 +211,36 @@ trace_screen_texture_release(struct pipe_screen *_screen,
struct pipe_texture **ptexture)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_texture *texture = *ptexture;
-
- trace_dump_call_begin(stream, "pipe_screen", "texture_release");
-
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, texture);
-
- screen->texture_release(screen, ptexture);
-
- trace_dump_call_end(stream);
+ 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;
+ }
}
+
static struct pipe_surface *
trace_screen_get_tex_surface(struct pipe_screen *_screen,
struct pipe_texture *texture,
@@ -236,25 +249,32 @@ trace_screen_get_tex_surface(struct pipe_screen *_screen,
unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
+ struct trace_texture *tr_tex;
struct pipe_surface *result;
- trace_dump_call_begin(stream, "pipe_screen", "get_tex_surface");
+ assert(texture);
+ tr_tex = trace_texture(tr_scr, texture);
+ texture = tr_tex->texture;
+ assert(texture->screen == screen);
+
+ trace_dump_call_begin("pipe_screen", "get_tex_surface");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, texture);
- trace_dump_arg(stream, uint, face);
- trace_dump_arg(stream, uint, level);
- trace_dump_arg(stream, uint, zslice);
- trace_dump_arg(stream, uint, usage);
+ 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);
result = screen->get_tex_surface(screen, texture, face, level, zslice, usage);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
+ result = trace_surface_create(tr_tex, result);
+
return result;
}
@@ -264,18 +284,34 @@ trace_screen_tex_surface_release(struct pipe_screen *_screen,
struct pipe_surface **psurface)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_surface *surface = *psurface;
-
- trace_dump_call_begin(stream, "pipe_screen", "tex_surface_release");
-
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, surface);
-
- screen->tex_surface_release(screen, psurface);
-
- trace_dump_call_end(stream);
+ 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);
+
+ trace_surface_destroy(tr_tex, *psurface);
+
+ trace_dump_call_end();
+ }
+
+ *psurface = NULL;
+ }
}
@@ -285,23 +321,24 @@ trace_screen_surface_map(struct pipe_screen *_screen,
unsigned flags)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_surface *result;
-
- trace_dump_call_begin(stream, "pipe_screen", "surface_map");
-
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, surface);
- trace_dump_arg(stream, uint, flags);
-
- result = screen->surface_map(screen, surface, flags);
-
- trace_dump_ret(stream, ptr, result);
-
- trace_dump_call_end(stream);
-
- return result;
+ struct trace_texture *tr_tex;
+ struct trace_surface *tr_surf;
+ 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);
+ if(map) {
+ if(flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
+ assert(!tr_surf->map);
+ tr_surf->map = map;
+ }
+ }
+
+ return map;
}
@@ -310,17 +347,41 @@ trace_screen_surface_unmap(struct pipe_screen *_screen,
struct pipe_surface *surface)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
-
- trace_dump_call_begin(stream, "pipe_screen", "surface_unmap");
-
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, surface);
+ 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");
+
+ 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_begin("stride");
+ trace_dump_uint(surface->stride);
+ 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;
+ }
screen->surface_unmap(screen, surface);
-
- trace_dump_call_end(stream);
}
@@ -328,17 +389,18 @@ static void
trace_screen_destroy(struct pipe_screen *_screen)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
- trace_dump_call_begin(stream, "pipe_screen", "destroy");
+ trace_dump_call_begin("pipe_screen", "destroy");
- trace_dump_arg(stream, ptr, screen);
+ trace_dump_arg(ptr, screen);
screen->destroy(screen);
- trace_dump_call_end(stream);
-
+ trace_dump_call_end();
+
+ trace_dump_trace_end();
+
FREE(tr_scr);
}
@@ -346,17 +408,24 @@ trace_screen_destroy(struct pipe_screen *_screen)
struct pipe_screen *
trace_screen_create(struct pipe_screen *screen)
{
- struct trace_stream *stream;
struct trace_screen *tr_scr;
+ struct pipe_winsys *winsys;
- if(!debug_get_bool_option("GALLIUM_TRACE", FALSE))
- return screen;
-
+ if(!screen)
+ goto error1;
+
+ if(!trace_dump_trace_begin())
+ goto error1;
+
tr_scr = CALLOC_STRUCT(trace_screen);
if(!tr_scr)
- return NULL;
+ goto error2;
- tr_scr->base.winsys = screen->winsys;
+ winsys = trace_winsys_create(screen->winsys);
+ if(!winsys)
+ goto error3;
+
+ tr_scr->base.winsys = winsys;
tr_scr->base.destroy = trace_screen_destroy;
tr_scr->base.get_name = trace_screen_get_name;
tr_scr->base.get_vendor = trace_screen_get_vendor;
@@ -372,17 +441,29 @@ trace_screen_create(struct pipe_screen *screen)
tr_scr->base.surface_unmap = trace_screen_surface_unmap;
tr_scr->screen = screen;
- tr_scr->stream = stream = trace_winsys(screen->winsys)->stream;
-
- /* We don't want to trace the internal pipe calls */
- screen->winsys = trace_winsys(screen->winsys)->winsys;
- trace_dump_call_begin(stream, "", "pipe_screen_create");
- trace_dump_arg_begin(stream, "winsys");
- trace_dump_ptr(stream, screen->winsys);
- trace_dump_arg_end(stream);
- trace_dump_ret(stream, ptr, screen);
- trace_dump_call_end(stream);
+ 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;
+
+error3:
+ FREE(tr_scr);
+error2:
+ trace_dump_trace_end();
+error1:
+ return screen;
+}
+
+
+struct trace_screen *
+trace_screen(struct pipe_screen *screen)
+{
+ assert(screen);
+ assert(screen->destroy == trace_screen_destroy);
+ return (struct trace_screen *)screen;
}
diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h
index 40b8447..93fefdb 100644
--- a/src/gallium/drivers/trace/tr_screen.h
+++ b/src/gallium/drivers/trace/tr_screen.h
@@ -29,35 +29,32 @@
#define TR_SCREEN_H_
-#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
#include "pipe/p_screen.h"
-struct trace_stream;
-
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct trace_screen
{
struct pipe_screen base;
struct pipe_screen *screen;
-
- struct trace_stream *stream;
};
-static INLINE struct trace_screen *
-trace_screen(struct pipe_screen *screen)
-{
- assert(screen);
- return (struct trace_screen *)screen;
-}
-
+struct trace_screen *
+trace_screen(struct pipe_screen *screen);
struct pipe_screen *
trace_screen_create(struct pipe_screen *screen);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* TR_SCREEN_H_ */
diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c
index e074ae7..986d939 100644
--- a/src/gallium/drivers/trace/tr_state.c
+++ b/src/gallium/drivers/trace/tr_state.c
@@ -27,467 +27,438 @@
#include "pipe/p_compiler.h"
+#include "util/u_memory.h"
#include "tgsi/tgsi_dump.h"
#include "tr_dump.h"
#include "tr_state.h"
-void trace_dump_format(struct trace_stream *stream,
- enum pipe_format format)
+void trace_dump_format(enum pipe_format format)
{
- trace_dump_enum(stream, pf_name(format) );
+ trace_dump_enum(pf_name(format) );
}
-void trace_dump_block(struct trace_stream *stream,
- const struct pipe_format_block *block)
+void trace_dump_block(const struct pipe_format_block *block)
{
- trace_dump_struct_begin(stream, "pipe_format_block");
- trace_dump_member(stream, uint, block, size);
- trace_dump_member(stream, uint, block, width);
- trace_dump_member(stream, uint, block, height);
- trace_dump_struct_end(stream);
+ trace_dump_struct_begin("pipe_format_block");
+ trace_dump_member(uint, block, size);
+ trace_dump_member(uint, block, width);
+ trace_dump_member(uint, block, height);
+ trace_dump_struct_end();
}
-void trace_dump_template(struct trace_stream *stream,
- const struct pipe_texture *templat)
+void trace_dump_template(const struct pipe_texture *templat)
{
- assert(templat);
if(!templat) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_texture");
+ trace_dump_struct_begin("pipe_texture");
- trace_dump_member(stream, int, templat, target);
- trace_dump_member(stream, format, templat, format);
+ trace_dump_member(int, templat, target);
+ trace_dump_member(format, templat, format);
- trace_dump_member_begin(stream, "width");
- trace_dump_array(stream, uint, templat->width, 1);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("width");
+ trace_dump_array(uint, templat->width, 1);
+ trace_dump_member_end();
- trace_dump_member_begin(stream, "height");
- trace_dump_array(stream, uint, templat->height, 1);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("height");
+ trace_dump_array(uint, templat->height, 1);
+ trace_dump_member_end();
- trace_dump_member_begin(stream, "depth");
- trace_dump_array(stream, uint, templat->depth, 1);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("depth");
+ trace_dump_array(uint, templat->depth, 1);
+ trace_dump_member_end();
- trace_dump_member_begin(stream, "block");
- trace_dump_block(stream, &templat->block);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("block");
+ trace_dump_block(&templat->block);
+ trace_dump_member_end();
- trace_dump_member(stream, uint, templat, last_level);
- trace_dump_member(stream, uint, templat, tex_usage);
+ trace_dump_member(uint, templat, last_level);
+ trace_dump_member(uint, templat, tex_usage);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_rasterizer_state(struct trace_stream *stream,
- const struct pipe_rasterizer_state *state)
+void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_rasterizer_state");
-
- trace_dump_member(stream, bool, state, flatshade);
- trace_dump_member(stream, bool, state, light_twoside);
- trace_dump_member(stream, uint, state, front_winding);
- trace_dump_member(stream, uint, state, cull_mode);
- trace_dump_member(stream, uint, state, fill_cw);
- trace_dump_member(stream, uint, state, fill_ccw);
- trace_dump_member(stream, bool, state, offset_cw);
- trace_dump_member(stream, bool, state, offset_ccw);
- trace_dump_member(stream, bool, state, scissor);
- trace_dump_member(stream, bool, state, poly_smooth);
- trace_dump_member(stream, bool, state, poly_stipple_enable);
- trace_dump_member(stream, bool, state, point_smooth);
- trace_dump_member(stream, bool, state, point_sprite);
- trace_dump_member(stream, bool, state, point_size_per_vertex);
- trace_dump_member(stream, bool, state, multisample);
- trace_dump_member(stream, bool, state, line_smooth);
- trace_dump_member(stream, bool, state, line_stipple_enable);
- trace_dump_member(stream, uint, state, line_stipple_factor);
- trace_dump_member(stream, uint, state, line_stipple_pattern);
- trace_dump_member(stream, bool, state, line_last_pixel);
- trace_dump_member(stream, bool, state, bypass_clipping);
- trace_dump_member(stream, bool, state, bypass_vs);
- trace_dump_member(stream, bool, state, origin_lower_left);
- trace_dump_member(stream, bool, state, flatshade_first);
- trace_dump_member(stream, bool, state, gl_rasterization_rules);
-
- trace_dump_member(stream, float, state, line_width);
- trace_dump_member(stream, float, state, point_size);
- trace_dump_member(stream, float, state, point_size_min);
- trace_dump_member(stream, float, state, point_size_max);
- trace_dump_member(stream, float, state, offset_units);
- trace_dump_member(stream, float, state, offset_scale);
+ trace_dump_struct_begin("pipe_rasterizer_state");
+
+ trace_dump_member(bool, state, flatshade);
+ trace_dump_member(bool, state, light_twoside);
+ trace_dump_member(uint, state, front_winding);
+ trace_dump_member(uint, state, cull_mode);
+ trace_dump_member(uint, state, fill_cw);
+ trace_dump_member(uint, state, fill_ccw);
+ trace_dump_member(bool, state, offset_cw);
+ trace_dump_member(bool, state, offset_ccw);
+ trace_dump_member(bool, state, scissor);
+ trace_dump_member(bool, state, poly_smooth);
+ trace_dump_member(bool, state, poly_stipple_enable);
+ trace_dump_member(bool, state, point_smooth);
+ trace_dump_member(bool, state, point_sprite);
+ trace_dump_member(bool, state, point_size_per_vertex);
+ trace_dump_member(bool, state, multisample);
+ trace_dump_member(bool, state, line_smooth);
+ trace_dump_member(bool, state, line_stipple_enable);
+ 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, origin_lower_left);
+ trace_dump_member(bool, state, flatshade_first);
+ trace_dump_member(bool, state, gl_rasterization_rules);
+
+ trace_dump_member(float, state, line_width);
+ trace_dump_member(float, state, point_size);
+ trace_dump_member(float, state, point_size_min);
+ 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(stream, uint, state, sprite_coord_mode);
+ trace_dump_member_array(uint, state, sprite_coord_mode);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_poly_stipple(struct trace_stream *stream,
- const struct pipe_poly_stipple *state)
+void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_poly_stipple");
+ trace_dump_struct_begin("pipe_poly_stipple");
- trace_dump_member_begin(stream, "stipple");
- trace_dump_array(stream,
- uint,
+ trace_dump_member_begin("stipple");
+ trace_dump_array(uint,
state->stipple,
Elements(state->stipple));
- trace_dump_member_end(stream);
+ trace_dump_member_end();
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_viewport_state(struct trace_stream *stream,
- const struct pipe_viewport_state *state)
+void trace_dump_viewport_state(const struct pipe_viewport_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_viewport_state");
+ trace_dump_struct_begin("pipe_viewport_state");
- trace_dump_member_array(stream, float, state, scale);
- trace_dump_member_array(stream, float, state, translate);
+ trace_dump_member_array(float, state, scale);
+ trace_dump_member_array(float, state, translate);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_scissor_state(struct trace_stream *stream,
- const struct pipe_scissor_state *state)
+void trace_dump_scissor_state(const struct pipe_scissor_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_scissor_state");
+ trace_dump_struct_begin("pipe_scissor_state");
- trace_dump_member(stream, uint, state, minx);
- trace_dump_member(stream, uint, state, miny);
- trace_dump_member(stream, uint, state, maxx);
- trace_dump_member(stream, uint, state, maxy);
+ trace_dump_member(uint, state, minx);
+ trace_dump_member(uint, state, miny);
+ trace_dump_member(uint, state, maxx);
+ trace_dump_member(uint, state, maxy);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_clip_state(struct trace_stream *stream,
- const struct pipe_clip_state *state)
+void trace_dump_clip_state(const struct pipe_clip_state *state)
{
unsigned i;
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_scissor_state");
+ trace_dump_struct_begin("pipe_clip_state");
- trace_dump_member_begin(stream, "ucp");
- trace_dump_array_begin(stream);
- for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i)
- trace_dump_array(stream, float, state->ucp[i], 4);
- trace_dump_array_end(stream);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("ucp");
+ trace_dump_array_begin();
+ for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
+ trace_dump_elem_begin();
+ trace_dump_array(float, state->ucp[i], 4);
+ trace_dump_elem_end();
+ }
+ trace_dump_array_end();
+ trace_dump_member_end();
- trace_dump_member(stream, uint, state, nr);
+ trace_dump_member(uint, state, nr);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_constant_buffer(struct trace_stream *stream,
- const struct pipe_constant_buffer *state)
+void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_constant_buffer");
+ trace_dump_struct_begin("pipe_constant_buffer");
- trace_dump_member(stream, ptr, state, buffer);
- trace_dump_member(stream, uint, state, size);
+ trace_dump_member(ptr, state, buffer);
+ trace_dump_member(uint, state, size);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_shader_state(struct trace_stream *stream,
- const struct pipe_shader_state *state)
+void trace_dump_shader_state(const struct pipe_shader_state *state)
{
static char str[8192];
- assert(state);
+
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
tgsi_dump_str(state->tokens, 0, str, sizeof(str));
- trace_dump_struct_begin(stream, "pipe_shader_state");
+ trace_dump_struct_begin("pipe_shader_state");
- trace_dump_member_begin(stream, "tokens");
- trace_dump_string(stream, str);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("tokens");
+ trace_dump_string(str);
+ trace_dump_member_end();
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_depth_stencil_alpha_state(struct trace_stream *stream,
- const struct pipe_depth_stencil_alpha_state *state)
+void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
{
unsigned i;
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_depth_stencil_alpha_state");
+ trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
- trace_dump_member_begin(stream, "depth");
- trace_dump_struct_begin(stream, "pipe_depth_state");
- trace_dump_member(stream, bool, &state->depth, enabled);
- trace_dump_member(stream, bool, &state->depth, writemask);
- trace_dump_member(stream, uint, &state->depth, func);
- trace_dump_member(stream, bool, &state->depth, occlusion_count);
- trace_dump_struct_end(stream);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("depth");
+ trace_dump_struct_begin("pipe_depth_state");
+ trace_dump_member(bool, &state->depth, enabled);
+ trace_dump_member(bool, &state->depth, writemask);
+ trace_dump_member(uint, &state->depth, func);
+ trace_dump_member(bool, &state->depth, occlusion_count);
+ trace_dump_struct_end();
+ trace_dump_member_end();
- trace_dump_member_begin(stream, "stencil");
- trace_dump_array_begin(stream);
+ trace_dump_member_begin("stencil");
+ trace_dump_array_begin();
for(i = 0; i < Elements(state->stencil); ++i) {
- trace_dump_elem_begin(stream);
- trace_dump_struct_begin(stream, "pipe_stencil_state");
- trace_dump_member(stream, bool, &state->stencil[i], enabled);
- trace_dump_member(stream, uint, &state->stencil[i], func);
- trace_dump_member(stream, uint, &state->stencil[i], fail_op);
- trace_dump_member(stream, uint, &state->stencil[i], zpass_op);
- trace_dump_member(stream, uint, &state->stencil[i], zfail_op);
- trace_dump_member(stream, uint, &state->stencil[i], ref_value);
- trace_dump_member(stream, uint, &state->stencil[i], value_mask);
- trace_dump_member(stream, uint, &state->stencil[i], write_mask);
- trace_dump_struct_end(stream);
- trace_dump_elem_end(stream);
+ trace_dump_elem_begin();
+ trace_dump_struct_begin("pipe_stencil_state");
+ trace_dump_member(bool, &state->stencil[i], enabled);
+ trace_dump_member(uint, &state->stencil[i], func);
+ trace_dump_member(uint, &state->stencil[i], fail_op);
+ trace_dump_member(uint, &state->stencil[i], zpass_op);
+ trace_dump_member(uint, &state->stencil[i], zfail_op);
+ trace_dump_member(uint, &state->stencil[i], ref_value);
+ trace_dump_member(uint, &state->stencil[i], value_mask);
+ trace_dump_member(uint, &state->stencil[i], write_mask);
+ trace_dump_struct_end();
+ trace_dump_elem_end();
}
- trace_dump_array_end(stream);
- trace_dump_member_end(stream);
-
- trace_dump_member_begin(stream, "alpha");
- trace_dump_struct_begin(stream, "pipe_alpha_state");
- trace_dump_member(stream, bool, &state->alpha, enabled);
- trace_dump_member(stream, uint, &state->alpha, func);
- trace_dump_member(stream, float, &state->alpha, ref);
- trace_dump_struct_end(stream);
- trace_dump_member_end(stream);
-
- trace_dump_struct_end(stream);
+ trace_dump_array_end();
+ trace_dump_member_end();
+
+ trace_dump_member_begin("alpha");
+ trace_dump_struct_begin("pipe_alpha_state");
+ trace_dump_member(bool, &state->alpha, enabled);
+ trace_dump_member(uint, &state->alpha, func);
+ trace_dump_member(float, &state->alpha, ref);
+ trace_dump_struct_end();
+ trace_dump_member_end();
+
+ trace_dump_struct_end();
}
-void trace_dump_blend_state(struct trace_stream *stream,
- const struct pipe_blend_state *state)
+void trace_dump_blend_state(const struct pipe_blend_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_blend_state");
+ trace_dump_struct_begin("pipe_blend_state");
- trace_dump_member(stream, bool, state, blend_enable);
+ trace_dump_member(bool, state, blend_enable);
- trace_dump_member(stream, uint, state, rgb_func);
- trace_dump_member(stream, uint, state, rgb_src_factor);
- trace_dump_member(stream, uint, state, rgb_dst_factor);
+ trace_dump_member(uint, state, rgb_func);
+ trace_dump_member(uint, state, rgb_src_factor);
+ trace_dump_member(uint, state, rgb_dst_factor);
- trace_dump_member(stream, uint, state, alpha_func);
- trace_dump_member(stream, uint, state, alpha_src_factor);
- trace_dump_member(stream, uint, state, alpha_dst_factor);
+ trace_dump_member(uint, state, alpha_func);
+ trace_dump_member(uint, state, alpha_src_factor);
+ trace_dump_member(uint, state, alpha_dst_factor);
- trace_dump_member(stream, bool, state, logicop_enable);
- trace_dump_member(stream, uint, state, logicop_func);
+ trace_dump_member(bool, state, logicop_enable);
+ trace_dump_member(uint, state, logicop_func);
- trace_dump_member(stream, uint, state, colormask);
- trace_dump_member(stream, bool, state, dither);
+ trace_dump_member(uint, state, colormask);
+ trace_dump_member(bool, state, dither);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_blend_color(struct trace_stream *stream,
- const struct pipe_blend_color *state)
+void trace_dump_blend_color(const struct pipe_blend_color *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_blend_color");
+ trace_dump_struct_begin("pipe_blend_color");
- trace_dump_member_array(stream, float, state, color);
+ trace_dump_member_array(float, state, color);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_framebuffer_state(struct trace_stream *stream,
- const struct pipe_framebuffer_state *state)
+void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
{
- trace_dump_struct_begin(stream, "pipe_framebuffer_state");
+ trace_dump_struct_begin("pipe_framebuffer_state");
- trace_dump_member(stream, uint, state, width);
- trace_dump_member(stream, uint, state, height);
- trace_dump_member(stream, uint, state, num_cbufs);
- trace_dump_member_array(stream, ptr, state, cbufs);
- trace_dump_member(stream, ptr, state, zsbuf);
+ trace_dump_member(uint, state, width);
+ trace_dump_member(uint, state, height);
+ trace_dump_member(uint, state, num_cbufs);
+ trace_dump_member_array(ptr, state, cbufs);
+ trace_dump_member(ptr, state, zsbuf);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_sampler_state(struct trace_stream *stream,
- const struct pipe_sampler_state *state)
+void trace_dump_sampler_state(const struct pipe_sampler_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_sampler_state");
-
- trace_dump_member(stream, uint, state, wrap_s);
- trace_dump_member(stream, uint, state, wrap_t);
- trace_dump_member(stream, uint, state, wrap_r);
- trace_dump_member(stream, uint, state, min_img_filter);
- trace_dump_member(stream, uint, state, min_mip_filter);
- trace_dump_member(stream, uint, state, mag_img_filter);
- trace_dump_member(stream, bool, state, compare_mode);
- trace_dump_member(stream, uint, state, compare_func);
- trace_dump_member(stream, bool, state, normalized_coords);
- trace_dump_member(stream, uint, state, prefilter);
- trace_dump_member(stream, float, state, shadow_ambient);
- trace_dump_member(stream, float, state, lod_bias);
- trace_dump_member(stream, float, state, min_lod);
- trace_dump_member(stream, float, state, max_lod);
- trace_dump_member_array(stream, float, state, border_color);
- trace_dump_member(stream, float, state, max_anisotropy);
-
- trace_dump_struct_end(stream);
+ trace_dump_struct_begin("pipe_sampler_state");
+
+ trace_dump_member(uint, state, wrap_s);
+ trace_dump_member(uint, state, wrap_t);
+ trace_dump_member(uint, state, wrap_r);
+ trace_dump_member(uint, state, min_img_filter);
+ trace_dump_member(uint, state, min_mip_filter);
+ trace_dump_member(uint, state, mag_img_filter);
+ trace_dump_member(bool, state, compare_mode);
+ trace_dump_member(uint, state, compare_func);
+ trace_dump_member(bool, state, normalized_coords);
+ trace_dump_member(uint, state, prefilter);
+ trace_dump_member(float, state, shadow_ambient);
+ trace_dump_member(float, state, lod_bias);
+ trace_dump_member(float, state, min_lod);
+ trace_dump_member(float, state, max_lod);
+ trace_dump_member_array(float, state, border_color);
+ trace_dump_member(float, state, max_anisotropy);
+
+ trace_dump_struct_end();
}
-void trace_dump_surface(struct trace_stream *stream,
- const struct pipe_surface *state)
+void trace_dump_surface(const struct pipe_surface *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_surface");
+ trace_dump_struct_begin("pipe_surface");
- trace_dump_member(stream, ptr, state, buffer);
- trace_dump_member(stream, format, state, format);
- trace_dump_member(stream, uint, state, status);
- trace_dump_member(stream, uint, state, clear_value);
- trace_dump_member(stream, uint, state, width);
- trace_dump_member(stream, uint, state, height);
+ trace_dump_member(ptr, state, buffer);
+ 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_begin(stream, "block");
- trace_dump_block(stream, &state->block);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("block");
+ trace_dump_block(&state->block);
+ trace_dump_member_end();
- trace_dump_member(stream, uint, state, nblocksx);
- trace_dump_member(stream, uint, state, nblocksy);
- trace_dump_member(stream, uint, state, stride);
- trace_dump_member(stream, uint, state, layout);
- trace_dump_member(stream, uint, state, offset);
- trace_dump_member(stream, uint, state, refcount);
- trace_dump_member(stream, uint, state, usage);
-
- trace_dump_member(stream, ptr, state, texture);
- trace_dump_member(stream, uint, state, face);
- trace_dump_member(stream, uint, state, level);
- trace_dump_member(stream, uint, state, zslice);
-
- trace_dump_struct_end(stream);
+ 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);
+ 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_vertex_buffer(struct trace_stream *stream,
- const struct pipe_vertex_buffer *state)
+void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_vertex_buffer");
+ trace_dump_struct_begin("pipe_vertex_buffer");
- trace_dump_member(stream, uint, state, pitch);
- trace_dump_member(stream, uint, state, max_index);
- trace_dump_member(stream, uint, state, buffer_offset);
- trace_dump_member(stream, ptr, state, buffer);
+ trace_dump_member(uint, state, pitch);
+ trace_dump_member(uint, state, max_index);
+ trace_dump_member(uint, state, buffer_offset);
+ trace_dump_member(ptr, state, buffer);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_vertex_element(struct trace_stream *stream,
- const struct pipe_vertex_element *state)
+void trace_dump_vertex_element(const struct pipe_vertex_element *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_vertex_element");
+ trace_dump_struct_begin("pipe_vertex_element");
- trace_dump_member(stream, uint, state, src_offset);
+ trace_dump_member(uint, state, src_offset);
- trace_dump_member(stream, uint, state, vertex_buffer_index);
- trace_dump_member(stream, uint, state, nr_components);
+ trace_dump_member(uint, state, vertex_buffer_index);
+ trace_dump_member(uint, state, nr_components);
- trace_dump_member(stream, format, state, src_format);
+ trace_dump_member(format, state, src_format);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h
index c1df63d..5ae533d 100644
--- a/src/gallium/drivers/trace/tr_state.h
+++ b/src/gallium/drivers/trace/tr_state.h
@@ -4,7 +4,7 @@
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation streams (the
+ * copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
@@ -33,63 +33,44 @@
#include "pipe/p_shader_tokens.h"
-void trace_dump_format(struct trace_stream *stream,
- enum pipe_format format);
+void trace_dump_format(enum pipe_format format);
-void trace_dump_block(struct trace_stream *stream,
- const struct pipe_format_block *block);
+void trace_dump_block(const struct pipe_format_block *block);
-void trace_dump_template(struct trace_stream *stream,
- const struct pipe_texture *templat);
+void trace_dump_template(const struct pipe_texture *templat);
-void trace_dump_rasterizer_state(struct trace_stream *stream,
- const struct pipe_rasterizer_state *state);
+void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state);
-void trace_dump_poly_stipple(struct trace_stream *stream,
- const struct pipe_poly_stipple *state);
+void trace_dump_poly_stipple(const struct pipe_poly_stipple *state);
-void trace_dump_viewport_state(struct trace_stream *stream,
- const struct pipe_viewport_state *state);
+void trace_dump_viewport_state(const struct pipe_viewport_state *state);
-void trace_dump_scissor_state(struct trace_stream *stream,
- const struct pipe_scissor_state *state);
+void trace_dump_scissor_state(const struct pipe_scissor_state *state);
-void trace_dump_clip_state(struct trace_stream *stream,
- const struct pipe_clip_state *state);
+void trace_dump_clip_state(const struct pipe_clip_state *state);
-void trace_dump_constant_buffer(struct trace_stream *stream,
- const struct pipe_constant_buffer *state);
+void trace_dump_constant_buffer(const struct pipe_constant_buffer *state);
-void trace_dump_token(struct trace_stream *stream,
- const struct tgsi_token *token);
+void trace_dump_token(const struct tgsi_token *token);
-void trace_dump_shader_state(struct trace_stream *stream,
- const struct pipe_shader_state *state);
+void trace_dump_shader_state(const struct pipe_shader_state *state);
-void trace_dump_depth_stencil_alpha_state(struct trace_stream *stream,
- const struct pipe_depth_stencil_alpha_state *state);
+void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state);
-void trace_dump_blend_state(struct trace_stream *stream,
- const struct pipe_blend_state *state);
+void trace_dump_blend_state(const struct pipe_blend_state *state);
-void trace_dump_blend_color(struct trace_stream *stream,
- const struct pipe_blend_color *state);
+void trace_dump_blend_color(const struct pipe_blend_color *state);
-void trace_dump_framebuffer_state(struct trace_stream *stream,
- const struct pipe_framebuffer_state *state);
+void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state);
-void trace_dump_sampler_state(struct trace_stream *stream,
- const struct pipe_sampler_state *state);
+void trace_dump_sampler_state(const struct pipe_sampler_state *state);
-void trace_dump_surface(struct trace_stream *stream,
- const struct pipe_surface *state);
+void trace_dump_surface(const struct pipe_surface *state);
-void trace_dump_vertex_buffer(struct trace_stream *stream,
- const struct pipe_vertex_buffer *state);
+void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state);
-void trace_dump_vertex_element(struct trace_stream *stream,
- const struct pipe_vertex_element *state);
+void trace_dump_vertex_element(const struct pipe_vertex_element *state);
#endif /* TR_STATE_H */
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
new file mode 100644
index 0000000..440a787
--- /dev/null
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -0,0 +1,112 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "pipe/p_inlines.h"
+#include "util/u_hash_table.h"
+#include "util/u_memory.h"
+
+#include "tr_screen.h"
+#include "tr_texture.h"
+
+
+struct pipe_texture *
+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));
+ tr_tex->base.screen = &tr_scr->base;
+ tr_tex->texture = texture;
+
+ return &tr_tex->base;
+
+error:
+ pipe_texture_reference(&texture, NULL);
+ return NULL;
+}
+
+
+void
+trace_texture_destroy(struct trace_screen *tr_scr,
+ struct pipe_texture *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,
+ 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));
+
+ tr_surf->base.winsys = tr_tex->base.screen->winsys;
+ 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;
+}
+
+
+void
+trace_surface_destroy(struct trace_texture *tr_tex,
+ struct pipe_surface *surface)
+{
+ struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
+ pipe_texture_reference(&tr_surf->base.texture, NULL);
+ pipe_surface_reference(&tr_surf->surface, NULL);
+ FREE(tr_surf);
+}
+
diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h
new file mode 100644
index 0000000..9e72edb
--- /dev/null
+++ b/src/gallium/drivers/trace/tr_texture.h
@@ -0,0 +1,95 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef TR_TEXTURE_H_
+#define TR_TEXTURE_H_
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+#include "tr_screen.h"
+
+
+struct trace_texture
+{
+ struct pipe_texture base;
+
+ struct pipe_texture *texture;
+};
+
+
+struct trace_surface
+{
+ struct pipe_surface base;
+
+ struct pipe_surface *surface;
+
+ void *map;
+};
+
+
+static INLINE struct trace_texture *
+trace_texture(struct trace_screen *tr_scr,
+ struct pipe_texture *texture)
+{
+ if(!texture)
+ return NULL;
+ assert(texture->screen == &tr_scr->base);
+ return (struct trace_texture *)texture;
+}
+
+
+static INLINE struct trace_surface *
+trace_surface(struct trace_texture *tr_tex,
+ struct pipe_surface *surface)
+{
+ if(!surface)
+ return NULL;
+ assert(surface->texture == &tr_tex->base);
+ return (struct trace_surface *)surface;
+}
+
+
+struct pipe_texture *
+trace_texture_create(struct trace_screen *tr_scr,
+ struct pipe_texture *texture);
+
+void
+trace_texture_destroy(struct trace_screen *tr_scr,
+ struct pipe_texture *texture);
+
+struct pipe_surface *
+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);
+
+
+#endif /* TR_TEXTURE_H_ */
diff --git a/src/gallium/drivers/trace/tr_winsys.c b/src/gallium/drivers/trace/tr_winsys.c
index eec84a1..1778358 100644
--- a/src/gallium/drivers/trace/tr_winsys.c
+++ b/src/gallium/drivers/trace/tr_winsys.c
@@ -25,13 +25,13 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
-#include "pipe/p_state.h"
+#include "util/u_memory.h"
#include "util/u_hash_table.h"
-#include "tr_stream.h"
#include "tr_dump.h"
#include "tr_state.h"
+#include "tr_screen.h"
+#include "tr_texture.h"
#include "tr_winsys.h"
@@ -51,19 +51,18 @@ static const char *
trace_winsys_get_name(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
const char *result;
- trace_dump_call_begin(stream, "pipe_winsys", "get_name");
+ trace_dump_call_begin("pipe_winsys", "get_name");
- trace_dump_arg(stream, ptr, winsys);
+ trace_dump_arg(ptr, winsys);
result = winsys->get_name(winsys);
- trace_dump_ret(stream, string, result);
+ trace_dump_ret(string, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -75,18 +74,27 @@ trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys,
void *context_private)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
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(stream, "pipe_winsys", "flush_frontbuffer");
+ trace_dump_call_begin("pipe_winsys", "flush_frontbuffer");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, surface);
- trace_dump_arg(stream, ptr, context_private);
+ 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(stream);
+ trace_dump_call_end();
}
@@ -94,20 +102,21 @@ static struct pipe_surface *
trace_winsys_surface_alloc(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_surface *result;
- trace_dump_call_begin(stream, "pipe_winsys", "surface_alloc");
+ trace_dump_call_begin("pipe_winsys", "surface_alloc");
- trace_dump_arg(stream, ptr, winsys);
+ trace_dump_arg(ptr, winsys);
result = winsys->surface_alloc(winsys);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
+ assert(!result || !result->texture);
+
return result;
}
@@ -121,19 +130,20 @@ trace_winsys_surface_alloc_storage(struct pipe_winsys *_winsys,
unsigned tex_usage)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
- trace_dump_call_begin(stream, "pipe_winsys", "surface_alloc_storage");
+ assert(surface && !surface->texture);
+
+ trace_dump_call_begin("pipe_winsys", "surface_alloc_storage");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, surface);
- trace_dump_arg(stream, uint, width);
- trace_dump_arg(stream, uint, height);
- trace_dump_arg(stream, format, format);
- trace_dump_arg(stream, uint, flags);
- trace_dump_arg(stream, uint, tex_usage);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, surface);
+ trace_dump_arg(uint, width);
+ trace_dump_arg(uint, height);
+ trace_dump_arg(format, format);
+ trace_dump_arg(uint, flags);
+ trace_dump_arg(uint, tex_usage);
result = winsys->surface_alloc_storage(winsys,
surface,
@@ -142,9 +152,9 @@ trace_winsys_surface_alloc_storage(struct pipe_winsys *_winsys,
flags,
tex_usage);
- trace_dump_ret(stream, int, result);
+ trace_dump_ret(int, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -155,18 +165,19 @@ trace_winsys_surface_release(struct pipe_winsys *_winsys,
struct pipe_surface **psurface)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_surface *surface = *psurface;
- trace_dump_call_begin(stream, "pipe_winsys", "surface_release");
+ assert(psurface && *psurface && !(*psurface)->texture);
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, surface);
+ trace_dump_call_begin("pipe_winsys", "surface_release");
+
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, surface);
winsys->surface_release(winsys, psurface);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -177,22 +188,21 @@ trace_winsys_buffer_create(struct pipe_winsys *_winsys,
unsigned size)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_buffer *buffer;
- trace_dump_call_begin(stream, "pipe_winsys", "buffer_create");
+ trace_dump_call_begin("pipe_winsys", "buffer_create");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, uint, alignment);
- trace_dump_arg(stream, uint, usage);
- trace_dump_arg(stream, uint, size);
+ 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(stream, ptr, buffer);
+ trace_dump_ret(ptr, buffer);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
/* Zero the buffer to avoid dumping uninitialized memory */
if(buffer->usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
@@ -210,30 +220,71 @@ trace_winsys_buffer_create(struct pipe_winsys *_winsys,
static struct pipe_buffer *
trace_winsys_user_buffer_create(struct pipe_winsys *_winsys,
- void *ptr,
- unsigned bytes)
+ void *data,
+ unsigned size)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_buffer *result;
- trace_dump_call_begin(stream, "pipe_winsys", "user_buffer_create");
+ trace_dump_call_begin("pipe_winsys", "user_buffer_create");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, ptr);
- trace_dump_arg(stream, uint, bytes);
+ 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, ptr, bytes);
+ result = winsys->user_buffer_create(winsys, data, size);
+
+ trace_dump_ret(ptr, result);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_call_end();
- trace_dump_call_end(stream);
+ /* 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,
@@ -260,27 +311,26 @@ trace_winsys_buffer_unmap(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
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(stream, "pipe_winsys", "buffer_write");
+ trace_dump_call_begin("pipe_winsys", "buffer_write");
- trace_dump_arg(stream, ptr, winsys);
+ trace_dump_arg(ptr, winsys);
- trace_dump_arg(stream, ptr, buffer);
+ trace_dump_arg(ptr, buffer);
- trace_dump_arg_begin(stream, "data");
- trace_dump_bytes(stream, map, buffer->size);
- trace_dump_arg_end(stream);
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(map, buffer->size);
+ trace_dump_arg_end();
- trace_dump_arg_begin(stream, "size");
- trace_dump_uint(stream, buffer->size);
- trace_dump_arg_end(stream);
+ trace_dump_arg_begin("size");
+ trace_dump_uint(buffer->size);
+ trace_dump_arg_end();
- trace_dump_call_end(stream);
+ trace_dump_call_end();
hash_table_remove(tr_ws->buffer_maps, buffer);
}
@@ -294,17 +344,16 @@ trace_winsys_buffer_destroy(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
- trace_dump_call_begin(stream, "pipe_winsys", "buffer_destroy");
+ trace_dump_call_begin("pipe_winsys", "buffer_destroy");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, buffer);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, buffer);
winsys->buffer_destroy(winsys, buffer);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -314,19 +363,18 @@ trace_winsys_fence_reference(struct pipe_winsys *_winsys,
struct pipe_fence_handle *src)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_fence_handle *dst = *pdst;
- trace_dump_call_begin(stream, "pipe_winsys", "fence_reference");
+ trace_dump_call_begin("pipe_winsys", "fence_reference");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, dst);
- trace_dump_arg(stream, ptr, src);
+ 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(stream);
+ trace_dump_call_end();
}
@@ -336,21 +384,20 @@ trace_winsys_fence_signalled(struct pipe_winsys *_winsys,
unsigned flag)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
- trace_dump_call_begin(stream, "pipe_winsys", "fence_signalled");
+ trace_dump_call_begin("pipe_winsys", "fence_signalled");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, fence);
- trace_dump_arg(stream, uint, flag);
+ 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(stream, int, result);
+ trace_dump_ret(int, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -362,21 +409,20 @@ trace_winsys_fence_finish(struct pipe_winsys *_winsys,
unsigned flag)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
- trace_dump_call_begin(stream, "pipe_winsys", "fence_finish");
+ trace_dump_call_begin("pipe_winsys", "fence_finish");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, fence);
- trace_dump_arg(stream, uint, flag);
+ 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(stream, int, result);
+ trace_dump_ret(int, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -386,23 +432,20 @@ static void
trace_winsys_destroy(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
- trace_dump_call_begin(stream, "pipe_winsys", "destroy");
+ trace_dump_call_begin("pipe_winsys", "destroy");
- trace_dump_arg(stream, ptr, winsys);
+ trace_dump_arg(ptr, winsys);
- winsys->destroy(winsys);
+ /*
+ winsys->destroy(winsys);
+ */
- trace_dump_call_end(stream);
-
- trace_dump_trace_end(stream);
+ trace_dump_call_end();
hash_table_destroy(tr_ws->buffer_maps);
- trace_stream_close(tr_ws->stream);
-
FREE(tr_ws);
}
@@ -410,15 +453,14 @@ trace_winsys_destroy(struct pipe_winsys *_winsys)
struct pipe_winsys *
trace_winsys_create(struct pipe_winsys *winsys)
{
- struct trace_stream *stream;
struct trace_winsys *tr_ws;
- if(!debug_get_bool_option("GALLIUM_TRACE", FALSE))
- return winsys;
+ if(!winsys)
+ goto error1;
tr_ws = CALLOC_STRUCT(trace_winsys);
if(!tr_ws)
- return NULL;
+ goto error1;
tr_ws->base.destroy = trace_winsys_destroy;
tr_ws->base.get_name = trace_winsys_get_name;
@@ -437,20 +479,19 @@ trace_winsys_create(struct pipe_winsys *winsys)
tr_ws->winsys = winsys;
- tr_ws->stream = stream = trace_stream_create("gallium", "trace");
- if(!tr_ws->stream)
- return NULL;
-
tr_ws->buffer_maps = hash_table_create(trace_buffer_hash,
trace_buffer_compare);
if(!tr_ws->buffer_maps)
- return NULL;
+ goto error2;
- trace_dump_trace_begin(tr_ws->stream, 0);
-
- trace_dump_call_begin(stream, "", "pipe_winsys_create");
- trace_dump_ret(stream, ptr, winsys);
- trace_dump_call_end(stream);
+ 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/drivers/trace/tr_winsys.h b/src/gallium/drivers/trace/tr_winsys.h
index a3576da..062ddf6 100644
--- a/src/gallium/drivers/trace/tr_winsys.h
+++ b/src/gallium/drivers/trace/tr_winsys.h
@@ -34,8 +34,15 @@
#include "pipe/p_winsys.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)
+
+
struct hash_table;
-struct trace_stream;
struct trace_winsys
@@ -44,8 +51,6 @@ struct trace_winsys
struct pipe_winsys *winsys;
- struct trace_stream *stream;
-
struct hash_table *buffer_maps;
};
@@ -63,4 +68,9 @@ struct pipe_winsys *
trace_winsys_create(struct pipe_winsys *winsys);
+void
+trace_winsys_user_buffer_update(struct pipe_winsys *winsys,
+ struct pipe_buffer *buffer);
+
+
#endif /* TR_WINSYS_H_ */
diff --git a/src/gallium/include/pipe/p_debug.h b/src/gallium/include/pipe/p_debug.h
index 6478ae2..cb6196a 100644
--- a/src/gallium/include/pipe/p_debug.h
+++ b/src/gallium/include/pipe/p_debug.h
@@ -340,9 +340,12 @@ void debug_dump_image(const char *prefix,
const void *data);
void debug_dump_surface(const char *prefix,
struct pipe_surface *surface);
+void debug_dump_surface_bmp(const char *filename,
+ struct pipe_surface *surface);
#else
#define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0)
#define debug_dump_surface(prefix, surface) ((void)0)
+#define debug_dump_surface_bmp(filename, surface) ((void)0)
#endif
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index bdc6d4e..cda10a2 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -211,6 +211,7 @@ enum pipe_texture_target {
#define PIPE_FLUSH_RENDER_CACHE 0x1
#define PIPE_FLUSH_TEXTURE_CACHE 0x2
#define PIPE_FLUSH_SWAPBUFFERS 0x4
+#define PIPE_FLUSH_FRAME 0x8 /**< Mark the end of a frame */
/**
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index d9aa579..97a4c8c 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -531,6 +531,35 @@ pf_is_ycbcr( enum pipe_format format )
return pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR ? TRUE : FALSE;
}
+static INLINE boolean
+pf_has_alpha( enum pipe_format format )
+{
+ switch (pf_layout(format)) {
+ case PIPE_FORMAT_LAYOUT_RGBAZS:
+ case PIPE_FORMAT_LAYOUT_MIXED:
+ /* FIXME: pf_get_component_bits( PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_COMP_A ) should not return 0 right? */
+ if(format == PIPE_FORMAT_A8_UNORM ||
+ format == PIPE_FORMAT_A8L8_UNORM ||
+ format == PIPE_FORMAT_A8_L8_SRGB)
+ return TRUE;
+ return pf_get_component_bits( format, PIPE_FORMAT_COMP_A ) ? TRUE : FALSE;
+ case PIPE_FORMAT_LAYOUT_YCBCR:
+ return FALSE;
+ case PIPE_FORMAT_LAYOUT_DXT:
+ switch (format) {
+ case PIPE_FORMAT_DXT1_RGBA:
+ case PIPE_FORMAT_DXT3_RGBA:
+ case PIPE_FORMAT_DXT5_RGBA:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ default:
+ assert( 0 );
+ return FALSE;
+ }
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index 1e4b98e..d70de8e 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -109,7 +109,7 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
/* XXX: thread safety issues!
*/
static INLINE void
-pipe_buffer_reference(struct pipe_winsys *winsys,
+winsys_buffer_reference(struct pipe_winsys *winsys,
struct pipe_buffer **ptr,
struct pipe_buffer *buf)
{
@@ -164,48 +164,48 @@ pipe_texture_release(struct pipe_texture **ptr)
*/
static INLINE struct pipe_buffer *
-pipe_buffer_create( struct pipe_context *pipe,
+pipe_buffer_create( struct pipe_screen *screen,
unsigned alignment, unsigned usage, unsigned size )
{
- return pipe->winsys->buffer_create(pipe->winsys, alignment, usage, size);
+ return screen->winsys->buffer_create(screen->winsys, alignment, usage, size);
}
static INLINE struct pipe_buffer *
-pipe_user_buffer_create( struct pipe_context *pipe, void *ptr, unsigned size )
+pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size )
{
- return pipe->winsys->user_buffer_create(pipe->winsys, ptr, size);
+ return screen->winsys->user_buffer_create(screen->winsys, ptr, size);
}
static INLINE void
-pipe_buffer_destroy( struct pipe_context *pipe, struct pipe_buffer *buf )
+pipe_buffer_destroy( struct pipe_screen *screen, struct pipe_buffer *buf )
{
- pipe->winsys->buffer_destroy(pipe->winsys, buf);
+ screen->winsys->buffer_destroy(screen->winsys, buf);
}
static INLINE void *
-pipe_buffer_map(struct pipe_context *pipe,
+pipe_buffer_map(struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned usage)
{
- return pipe->winsys->buffer_map(pipe->winsys, buf, usage);
+ return screen->winsys->buffer_map(screen->winsys, buf, usage);
}
static INLINE void
-pipe_buffer_unmap(struct pipe_context *pipe,
+pipe_buffer_unmap(struct pipe_screen *screen,
struct pipe_buffer *buf)
{
- pipe->winsys->buffer_unmap(pipe->winsys, buf);
+ screen->winsys->buffer_unmap(screen->winsys, buf);
}
/* XXX when we're using this everywhere, get rid of
- * pipe_buffer_reference() above.
+ * winsys_buffer_reference() above.
*/
static INLINE void
-pipe_reference_buffer(struct pipe_context *pipe,
+pipe_buffer_reference(struct pipe_screen *screen,
struct pipe_buffer **ptr,
struct pipe_buffer *buf)
{
- pipe_buffer_reference(pipe->winsys, ptr, buf);
+ winsys_buffer_reference(screen->winsys, ptr, buf);
}
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 3ab0c7d..a562e3a 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -382,6 +382,7 @@ struct tgsi_immediate_float32
*/
#define TGSI_OPCODE_SGN TGSI_OPCODE_SSG
#define TGSI_OPCODE_MOVA TGSI_OPCODE_ARR
+/* EXPP - use TGSI_OPCODE_EX2 */
/*
* vs_2_x
@@ -469,12 +470,11 @@ struct tgsi_instruction_ext
#define TGSI_CC_GT 0
#define TGSI_CC_EQ 1
#define TGSI_CC_LT 2
-#define TGSI_CC_UN 3
-#define TGSI_CC_GE 4
-#define TGSI_CC_LE 5
-#define TGSI_CC_NE 6
-#define TGSI_CC_TR 7
-#define TGSI_CC_FL 8
+#define TGSI_CC_GE 3
+#define TGSI_CC_LE 4
+#define TGSI_CC_NE 5
+#define TGSI_CC_TR 6
+#define TGSI_CC_FL 7
#define TGSI_SWIZZLE_X 0
#define TGSI_SWIZZLE_Y 1
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 4d0f359..da78338 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -276,12 +276,12 @@ struct pipe_surface
enum pipe_format format; /**< PIPE_FORMAT_x */
unsigned status; /**< PIPE_SURFACE_STATUS_x */
unsigned clear_value; /**< XXX may be temporary */
- unsigned width;
- unsigned height;
+ unsigned width; /**< logical width in pixels */
+ unsigned height; /**< logical height in pixels */
struct pipe_format_block block;
- unsigned nblocksx;
- unsigned nblocksy;
- unsigned stride; /**< in bytes */
+ 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;
@@ -309,8 +309,8 @@ struct pipe_texture
unsigned depth[PIPE_MAX_TEXTURE_LEVELS];
struct pipe_format_block block;
- unsigned nblocksx[PIPE_MAX_TEXTURE_LEVELS];
- unsigned nblocksy[PIPE_MAX_TEXTURE_LEVELS];
+ unsigned nblocksx[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated width in blocks */
+ unsigned nblocksy[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated height in blocks */
unsigned last_level:8; /**< Index of last mipmap level present/defined */
unsigned compressed:1;
diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h
index 6e526b7..e01d5a6 100644
--- a/src/gallium/include/pipe/p_thread.h
+++ b/src/gallium/include/pipe/p_thread.h
@@ -23,307 +23,252 @@
*
**************************************************************************/
+
/**
- * @file
- * Thread
- *
- * Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu)
- * and Christoph Poliwoda (poliwoda@volumegraphics.com)
- * Revised by Keith Whitwell
- * Adapted for new gl dispatcher by Brian Paul
- *
- *
- *
- * DOCUMENTATION
- *
- * This thread module exports the following types:
- * _glthread_TSD Thread-specific data area
- * _glthread_Thread Thread datatype
- * _glthread_Mutex Mutual exclusion lock
- *
- * Macros:
- * _glthread_DECLARE_STATIC_MUTEX(name) Declare a non-local mutex
- * _glthread_INIT_MUTEX(name) Initialize a mutex
- * _glthread_LOCK_MUTEX(name) Lock a mutex
- * _glthread_UNLOCK_MUTEX(name) Unlock a mutex
- *
- * Functions:
- * _glthread_GetID(v) Get integer thread ID
- * _glthread_InitTSD() Initialize thread-specific data
- * _glthread_GetTSD() Get thread-specific data
- * _glthread_SetTSD() Set thread-specific data
- *
- * If this file is accidentally included by a non-threaded build,
- * it should not cause the build to fail, or otherwise cause problems.
- * In general, it should only be included when needed however.
+ * Thread, mutex, condition var and thread-specific data functions.
*/
-#ifndef _P_THREAD_H_
-#define _P_THREAD_H_
+#ifndef _P_THREAD2_H_
+#define _P_THREAD2_H_
-#if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\
- defined(WIN32_THREADS) || defined(USE_XTHREADS) || defined(BEOS_THREADS)) \
- && !defined(THREADS)
-# define THREADS
-#endif
-#ifdef VMS
-#include <GL/vms_x_fix.h>
-#endif
+#include "pipe/p_compiler.h"
+
+
+#if defined(PIPE_OS_LINUX)
-/*
- * POSIX threads. This should be your choice in the Unix world
- * whenever possible. When building with POSIX threads, be sure
- * to enable any compiler flags which will cause the MT-safe
- * libc (if one exists) to be used when linking, as well as any
- * header macros for MT-safe errno, etc. For Solaris, this is the -mt
- * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable
- * proper compiling for MT-safe libc etc.
- */
-#if defined(PTHREADS)
#include <pthread.h> /* POSIX threads headers */
+#include <stdio.h> /* for perror() */
-typedef struct {
- pthread_key_t key;
- int initMagic;
-} _glthread_TSD;
+typedef pthread_t pipe_thread;
+
+#define PIPE_THREAD_ROUTINE( name, param ) \
+ void *name( void *param )
-typedef pthread_t _glthread_Thread;
+static INLINE pipe_thread pipe_thread_create( void *(* routine)( void *), void *param )
+{
+ pipe_thread thread;
+ if (pthread_create( &thread, NULL, routine, param ))
+ return 0;
+ return thread;
+}
-typedef pthread_mutex_t _glthread_Mutex;
+static INLINE int pipe_thread_wait( pipe_thread thread )
+{
+ return pthread_join( thread, NULL );
+}
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name = PTHREAD_MUTEX_INITIALIZER
+static INLINE int pipe_thread_destroy( pipe_thread thread )
+{
+ return pthread_detach( thread );
+}
-#define _glthread_INIT_MUTEX(name) \
- pthread_mutex_init(&(name), NULL)
+typedef pthread_mutex_t pipe_mutex;
+typedef pthread_cond_t pipe_condvar;
-#define _glthread_DESTROY_MUTEX(name) \
- pthread_mutex_destroy(&(name))
+#define pipe_static_mutex(mutex) \
+ static pipe_mutex mutex = PTHREAD_MUTEX_INITIALIZER
-#define _glthread_LOCK_MUTEX(name) \
- (void) pthread_mutex_lock(&(name))
+#define pipe_mutex_init(mutex) \
+ pthread_mutex_init(&(mutex), NULL)
-#define _glthread_UNLOCK_MUTEX(name) \
- (void) pthread_mutex_unlock(&(name))
+#define pipe_mutex_destroy(mutex) \
+ pthread_mutex_destroy(&(mutex))
-typedef pthread_cond_t _glthread_Cond;
+#define pipe_mutex_lock(mutex) \
+ (void) pthread_mutex_lock(&(mutex))
-#define _glthread_DECLARE_STATIC_COND(name) \
- static _glthread_Cond name = PTHREAD_COND_INITIALIZER
+#define pipe_mutex_unlock(mutex) \
+ (void) pthread_mutex_unlock(&(mutex))
-#define _glthread_INIT_COND(cond) \
+#define pipe_static_condvar(mutex) \
+ static pipe_condvar mutex = PTHREAD_COND_INITIALIZER
+
+#define pipe_condvar_init(cond) \
pthread_cond_init(&(cond), NULL)
-#define _glthread_DESTROY_COND(name) \
- pthread_cond_destroy(&(name))
+#define pipe_condvar_destroy(cond) \
+ pthread_cond_destroy(&(cond))
-#define _glthread_COND_WAIT(cond, mutex) \
+#define pipe_condvar_wait(cond, mutex) \
pthread_cond_wait(&(cond), &(mutex))
-#define _glthread_COND_SIGNAL(cond) \
+#define pipe_condvar_signal(cond) \
pthread_cond_signal(&(cond))
-#define _glthread_COND_BROADCAST(cond) \
+#define pipe_condvar_broadcast(cond) \
pthread_cond_broadcast(&(cond))
-#endif /* PTHREADS */
-
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-
-/*
- * Solaris threads. Use only up to Solaris 2.4.
- * Solaris 2.5 and higher provide POSIX threads.
- * Be sure to compile with -mt on the Solaris compilers, or
- * use -D_REENTRANT if using gcc.
- */
-#ifdef SOLARIS_THREADS
-#include <thread.h>
-
-typedef struct {
- thread_key_t key;
- mutex_t keylock;
- int initMagic;
-} _glthread_TSD;
-
-typedef thread_t _glthread_Thread;
-
-typedef mutex_t _glthread_Mutex;
-
-/* XXX need to really implement mutex-related macros */
-#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
-#define _glthread_INIT_MUTEX(name) (void) name
-#define _glthread_DESTROY_MUTEX(name) (void) name
-#define _glthread_LOCK_MUTEX(name) (void) name
-#define _glthread_UNLOCK_MUTEX(name) (void) name
-
-#endif /* SOLARIS_THREADS */
-
-
-
-
-/*
- * Windows threads. Should work with Windows NT and 95.
- * IMPORTANT: Link with multithreaded runtime library when THREADS are
- * used!
- */
-#ifdef WIN32_THREADS
#include <windows.h>
-typedef struct {
- DWORD key;
- int initMagic;
-} _glthread_TSD;
+typedef HANDLE pipe_thread;
-typedef HANDLE _glthread_Thread;
+#define PIPE_THREAD_ROUTINE( name, param ) \
+ void * WINAPI name( void *param )
-typedef CRITICAL_SECTION _glthread_Mutex;
+static INLINE pipe_thread pipe_thread_create( void *(WINAPI * routine)( void *), void *param )
+{
+ DWORD id;
+ return CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) routine, param, 0, &id );
+}
-#define _glthread_DECLARE_STATIC_MUTEX(name) /*static*/ _glthread_Mutex name = {0,0,0,0,0,0}
-#define _glthread_INIT_MUTEX(name) InitializeCriticalSection(&name)
-#define _glthread_DESTROY_MUTEX(name) DeleteCriticalSection(&name)
-#define _glthread_LOCK_MUTEX(name) EnterCriticalSection(&name)
-#define _glthread_UNLOCK_MUTEX(name) LeaveCriticalSection(&name)
+static INLINE int pipe_thread_wait( pipe_thread thread )
+{
+ if (WaitForSingleObject( thread, INFINITE ) == WAIT_OBJECT_0)
+ return 0;
+ return -1;
+}
-#endif /* WIN32_THREADS */
+static INLINE int pipe_thread_destroy( pipe_thread thread )
+{
+ if (CloseHandle( thread ))
+ return 0;
+ return -1;
+}
+typedef CRITICAL_SECTION pipe_mutex;
+#define pipe_static_mutex(name) \
+ /*static*/ pipe_mutex name = {0,0,0,0,0,0}
+#define pipe_mutex_init(name) \
+ InitializeCriticalSection(&name)
-/*
- * XFree86 has its own thread wrapper, Xthreads.h
- * We wrap it again for GL.
- */
-#ifdef USE_XTHREADS
-#include <X11/Xthreads.h>
+#define pipe_mutex_destroy(name) \
+ DeleteCriticalSection(&name)
-typedef struct {
- xthread_key_t key;
- int initMagic;
-} _glthread_TSD;
-
-typedef xthread_t _glthread_Thread;
-
-typedef xmutex_rec _glthread_Mutex;
-
-#ifdef XMUTEX_INITIALIZER
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name = XMUTEX_INITIALIZER
-#else
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name
-#endif
-
-#define _glthread_INIT_MUTEX(name) \
- xmutex_init(&(name))
-
-#define _glthread_DESTROY_MUTEX(name) \
- xmutex_clear(&(name))
-
-#define _glthread_LOCK_MUTEX(name) \
- (void) xmutex_lock(&(name))
-
-#define _glthread_UNLOCK_MUTEX(name) \
- (void) xmutex_unlock(&(name))
-
-#endif /* USE_XTHREADS */
-
-
-
-/*
- * BeOS threads. R5.x required.
- */
-#ifdef BEOS_THREADS
-
-#include <kernel/OS.h>
-#include <support/TLS.h>
-
-typedef struct {
- int32 key;
- int initMagic;
-} _glthread_TSD;
-
-typedef thread_id _glthread_Thread;
-
-/* Use Benaphore, aka speeder semaphore */
-typedef struct {
- int32 lock;
- sem_id sem;
-} benaphore;
-typedef benaphore _glthread_Mutex;
-
-#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = { 0, 0 }
-#define _glthread_INIT_MUTEX(name) name.sem = create_sem(0, #name"_benaphore"), name.lock = 0
-#define _glthread_DESTROY_MUTEX(name) delete_sem(name.sem), name.lock = 0
-#define _glthread_LOCK_MUTEX(name) if (name.sem == 0) _glthread_INIT_MUTEX(name); \
- if (atomic_add(&(name.lock), 1) >= 1) acquire_sem(name.sem)
-#define _glthread_UNLOCK_MUTEX(name) if (atomic_add(&(name.lock), -1) > 1) release_sem(name.sem)
+#define pipe_mutex_lock(name) \
+ EnterCriticalSection(&name)
-#endif /* BEOS_THREADS */
+#define pipe_mutex_unlock(name) \
+ LeaveCriticalSection(&name)
+/* XXX: dummy definitions, make it compile */
+typedef unsigned pipe_condvar;
-#ifndef THREADS
+#define pipe_condvar_init(condvar) \
+ (void) condvar
-/*
- * THREADS not defined
- */
+#define pipe_condvar_broadcast(condvar) \
+ (void) condvar
-typedef unsigned _glthread_TSD;
+#else
-typedef unsigned _glthread_Thread;
+/** Dummy definitions */
-typedef unsigned _glthread_Mutex;
+typedef unsigned pipe_thread;
+typedef unsigned pipe_mutex;
+typedef unsigned pipe_condvar;
-#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
+#define pipe_static_mutex(mutex) \
+ static pipe_mutex mutex = 0
-#define _glthread_INIT_MUTEX(name) (void) name
+#define pipe_mutex_init(mutex) \
+ (void) mutex
-#define _glthread_DESTROY_MUTEX(name) (void) name
+#define pipe_mutex_destroy(mutex) \
+ (void) mutex
-#define _glthread_LOCK_MUTEX(name) (void) name
+#define pipe_mutex_lock(mutex) \
+ (void) mutex
-#define _glthread_UNLOCK_MUTEX(name) (void) name
+#define pipe_mutex_unlock(mutex) \
+ (void) mutex
-typedef unsigned _glthread_Cond;
+#define pipe_static_condvar(condvar) \
+ static unsigned condvar = 0
-#define _glthread_DECLARE_STATIC_COND(name) static _glthread_Cond name = 0
+#define pipe_condvar_init(condvar) \
+ (void) condvar
-#define _glthread_INIT_COND(name) (void) name
+#define pipe_condvar_destroy(condvar) \
+ (void) condvar
-#define _glthread_DESTROY_COND(name) (void) name
+#define pipe_condvar_wait(condvar, mutex) \
+ (void) condvar
-#define _glthread_COND_WAIT(name, mutex) (void) name
+#define pipe_condvar_signal(condvar) \
+ (void) condvar
-#define _glthread_COND_SIGNAL(name) (void) name
+#define pipe_condvar_broadcast(condvar) \
+ (void) condvar
-#define _glthread_COND_BROADCAST(name) (void) name
-#endif /* THREADS */
+#endif /* PIPE_OS_? */
/*
- * Platform independent thread specific data API.
+ * Thread-specific data.
*/
-extern unsigned long
-_glthread_GetID(void);
-
-
-extern void
-_glthread_InitTSD(_glthread_TSD *);
+typedef struct {
+#if defined(PIPE_OS_LINUX)
+ pthread_key_t key;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ DWORD key;
+#endif
+ int initMagic;
+} pipe_tsd;
-extern void *
-_glthread_GetTSD(_glthread_TSD *);
+#define PIPE_TSD_INIT_MAGIC 0xff8adc98
-extern void
-_glthread_SetTSD(_glthread_TSD *, void *);
+static INLINE void
+pipe_tsd_init(pipe_tsd *tsd)
+{
+#if defined(PIPE_OS_LINUX)
+ if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
+ perror("pthread_key_create(): failed to allocate key for thread specific data");
+ exit(-1);
+ }
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ assert(0);
+#endif
+ tsd->initMagic = PIPE_TSD_INIT_MAGIC;
+}
+
+static INLINE void *
+pipe_tsd_get(pipe_tsd *tsd)
+{
+ if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
+ pipe_tsd_init(tsd);
+ }
+#if defined(PIPE_OS_LINUX)
+ return pthread_getspecific(tsd->key);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ assert(0);
+ return NULL;
+#else
+ assert(0);
+ return NULL;
+#endif
+}
+
+static INLINE void
+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 (pthread_setspecific(tsd->key, value) != 0) {
+ perror("pthread_set_specific() failed");
+ exit(-1);
+ }
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ assert(0);
+#else
+ assert(0);
+#endif
+}
-#endif /* _P_THREAD_H_ */
+#endif /* _P_THREAD2_H_ */
diff --git a/src/gallium/include/pipe/p_util.h b/src/gallium/include/pipe/p_util.h
deleted file mode 100644
index eec4138..0000000
--- a/src/gallium/include/pipe/p_util.h
+++ /dev/null
@@ -1,536 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef P_UTIL_H
-#define P_UTIL_H
-
-#include "p_config.h"
-#include "p_compiler.h"
-#include "p_debug.h"
-#include "p_format.h"
-#include "p_pointer.h"
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
-__inline double ceil(double val)
-{
- double ceil_val;
-
- if((val - (long) val) == 0) {
- ceil_val = val;
- } else {
- if(val > 0) {
- ceil_val = (long) val + 1;
- } else {
- ceil_val = (long) val;
- }
- }
-
- return ceil_val;
-}
-
-#ifndef PIPE_SUBSYSTEM_WINDOWS_CE
-__inline double floor(double val)
-{
- double floor_val;
-
- if((val - (long) val) == 0) {
- floor_val = val;
- } else {
- if(val > 0) {
- floor_val = (long) val;
- } else {
- floor_val = (long) val - 1;
- }
- }
-
- return floor_val;
-}
-#endif
-
-#pragma function(pow)
-__inline double __cdecl pow(double val, double exponent)
-{
- /* XXX */
- assert(0);
- return 0;
-}
-
-#pragma function(log)
-__inline double __cdecl log(double val)
-{
- /* XXX */
- assert(0);
- return 0;
-}
-
-#pragma function(atan2)
-__inline double __cdecl atan2(double val)
-{
- /* XXX */
- assert(0);
- return 0;
-}
-#else
-#include <math.h>
-#include <stdarg.h>
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG)
-
-/* memory debugging */
-
-#include "p_debug.h"
-
-#define MALLOC( _size ) \
- debug_malloc( __FILE__, __LINE__, __FUNCTION__, _size )
-#define CALLOC( _count, _size ) \
- debug_calloc(__FILE__, __LINE__, __FUNCTION__, _count, _size )
-#define FREE( _ptr ) \
- debug_free( __FILE__, __LINE__, __FUNCTION__, _ptr )
-#define REALLOC( _ptr, _old_size, _size ) \
- debug_realloc( __FILE__, __LINE__, __FUNCTION__, _ptr, _old_size, _size )
-
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-
-void * __stdcall
-EngAllocMem(
- unsigned long Flags,
- unsigned long MemSize,
- unsigned long Tag );
-
-void __stdcall
-EngFreeMem(
- void *Mem );
-
-#define MALLOC( _size ) EngAllocMem( 0, _size, 'D3AG' )
-#define _FREE( _ptr ) EngFreeMem( _ptr )
-
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
-
-void *
-ExAllocatePool(
- unsigned long PoolType,
- size_t NumberOfBytes);
-
-void
-ExFreePool(void *P);
-
-#define MALLOC(_size) ExAllocatePool(0, _size)
-#define _FREE(_ptr) ExFreePool(_ptr)
-
-#else
-
-#define MALLOC( SIZE ) malloc( SIZE )
-#define CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
-#define FREE( PTR ) free( PTR )
-#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE ) realloc( OLDPTR, NEWSIZE )
-
-#endif
-
-
-#ifndef CALLOC
-static INLINE void *
-CALLOC( unsigned count, unsigned size )
-{
- void *ptr = MALLOC( count * size );
- if( ptr ) {
- memset( ptr, 0, count * size );
- }
- return ptr;
-}
-#endif /* !CALLOC */
-
-#ifndef FREE
-static INLINE void
-FREE( void *ptr )
-{
- if( ptr ) {
- _FREE( ptr );
- }
-}
-#endif /* !FREE */
-
-#ifndef REALLOC
-static INLINE void *
-REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
-{
- void *new_ptr = NULL;
-
- if (new_size != 0) {
- unsigned copy_size = old_size < new_size ? old_size : new_size;
- new_ptr = MALLOC( new_size );
- if (new_ptr && old_ptr && copy_size) {
- memcpy( new_ptr, old_ptr, copy_size );
- }
- }
-
- FREE( old_ptr );
- return new_ptr;
-}
-#endif /* !REALLOC */
-
-
-#define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))
-
-#define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T))
-
-
-/**
- * Return memory on given byte alignment
- */
-static INLINE void *
-align_malloc(size_t bytes, uint alignment)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
- void *mem;
- (void) posix_memalign(& mem, alignment, bytes);
- return mem;
-#else
- char *ptr, *buf;
-
- assert( alignment > 0 );
-
- ptr = (char *) MALLOC(bytes + alignment + sizeof(void *));
- if (!ptr)
- return NULL;
-
- buf = (char *) align_pointer( ptr + sizeof(void *), alignment );
- *(char **)(buf - sizeof(void *)) = ptr;
-
- return buf;
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-/**
- * Free memory returned by align_malloc().
- */
-static INLINE void
-align_free(void *ptr)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
- FREE(ptr);
-#else
- void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
- void *realAddr = *cubbyHole;
- FREE(realAddr);
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-
-
-/**
- * Duplicate a block of memory.
- */
-static INLINE void *
-mem_dup(const void *src, uint size)
-{
- void *dup = MALLOC(size);
- if (dup)
- memcpy(dup, src, size);
- return dup;
-}
-
-
-
-#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
-#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
-#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
-
-#ifndef Elements
-#define Elements(x) (sizeof(x)/sizeof((x)[0]))
-#endif
-#define Offset(TYPE, MEMBER) ((unsigned)&(((TYPE *)NULL)->MEMBER))
-
-/**
- * Return a pointer aligned to next multiple of 16 bytes.
- */
-static INLINE void *
-align16( void *unaligned )
-{
- return align_pointer( unaligned, 16 );
-}
-
-
-static INLINE int align_int(int x, int align)
-{
- return (x + align - 1) & ~(align - 1);
-}
-
-
-
-#if defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
-static INLINE unsigned ffs( unsigned u )
-{
- unsigned i;
-
- if( u == 0 ) {
- return 0;
- }
-
- __asm bsf eax, [u]
- __asm inc eax
- __asm mov [i], eax
-
- return i;
-}
-#endif
-
-union fi {
- float f;
- int i;
- unsigned ui;
-};
-
-#define UBYTE_TO_FLOAT( ub ) ((float)(ub) / 255.0F)
-
-#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
-
-/* This function/macro is sensitive to precision. Test very carefully
- * if you change it!
- */
-#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \
- do { \
- union fi __tmp; \
- __tmp.f = (F); \
- if (__tmp.i < 0) \
- UB = (ubyte) 0; \
- else if (__tmp.i >= IEEE_0996) \
- UB = (ubyte) 255; \
- else { \
- __tmp.f = __tmp.f * (255.0f/256.0f) + 32768.0f; \
- UB = (ubyte) __tmp.i; \
- } \
- } while (0)
-
-
-
-static INLINE unsigned pack_ub4( unsigned char b0,
- unsigned char b1,
- unsigned char b2,
- unsigned char b3 )
-{
- return ((((unsigned int)b0) << 0) |
- (((unsigned int)b1) << 8) |
- (((unsigned int)b2) << 16) |
- (((unsigned int)b3) << 24));
-}
-
-static INLINE unsigned fui( float f )
-{
- union fi fi;
- fi.f = f;
- return fi.ui;
-}
-
-static INLINE unsigned char float_to_ubyte( float f )
-{
- unsigned char ub;
- UNCLAMPED_FLOAT_TO_UBYTE(ub, f);
- return ub;
-}
-
-static INLINE unsigned pack_ui32_float4( float a,
- float b,
- float c,
- float d )
-{
- return pack_ub4( float_to_ubyte(a),
- float_to_ubyte(b),
- float_to_ubyte(c),
- float_to_ubyte(d) );
-}
-
-#define COPY_4V( DST, SRC ) \
-do { \
- (DST)[0] = (SRC)[0]; \
- (DST)[1] = (SRC)[1]; \
- (DST)[2] = (SRC)[2]; \
- (DST)[3] = (SRC)[3]; \
-} while (0)
-
-
-#define COPY_4FV( DST, SRC ) COPY_4V(DST, SRC)
-
-
-#define ASSIGN_4V( DST, V0, V1, V2, V3 ) \
-do { \
- (DST)[0] = (V0); \
- (DST)[1] = (V1); \
- (DST)[2] = (V2); \
- (DST)[3] = (V3); \
-} while (0)
-
-
-static INLINE int ifloor(float f)
-{
- int ai, bi;
- double af, bf;
- union fi u;
-
- af = (3 << 22) + 0.5 + (double)f;
- bf = (3 << 22) + 0.5 - (double)f;
- u.f = (float) af; ai = u.i;
- u.f = (float) bf; bi = u.i;
- return (ai - bi) >> 1;
-}
-
-
-#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
-static INLINE int iround(float f)
-{
- int r;
- __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
- return r;
-}
-#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
-static INLINE int iround(float f)
-{
- int r;
- _asm {
- fld f
- fistp r
- }
- return r;
-}
-#else
-#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
-#endif
-
-
-/* Could maybe have an inline version of this?
- */
-#if defined(__GNUC__)
-#define FABSF(x) fabsf(x)
-#else
-#define FABSF(x) ((float) fabs(x))
-#endif
-
-/* Pretty fast, and accurate.
- * Based on code from http://www.flipcode.com/totd/
- */
-static INLINE float LOG2(float val)
-{
- union fi num;
- int log_2;
-
- num.f = val;
- log_2 = ((num.i >> 23) & 255) - 128;
- num.i &= ~(255 << 23);
- num.i += 127 << 23;
- num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
- return num.f + log_2;
-}
-
-#if defined(__GNUC__)
-#define CEILF(x) ceilf(x)
-#else
-#define CEILF(x) ((float) ceil(x))
-#endif
-
-static INLINE int align(int value, int alignment)
-{
- return (value + alignment - 1) & ~(alignment - 1);
-}
-
-
-/* util/p_util.c
- */
-extern void pipe_copy_rect(ubyte * dst, const struct pipe_format_block *block,
- unsigned dst_stride, unsigned dst_x, unsigned dst_y,
- unsigned width, unsigned height, const ubyte * src,
- int src_stride, unsigned src_x, int src_y);
-
-extern void
-pipe_fill_rect(ubyte * dst, const struct pipe_format_block *block,
- unsigned dst_stride, unsigned dst_x, unsigned dst_y,
- unsigned width, unsigned height, uint32_t value);
-
-
-#if defined(_MSC_VER)
-#if _MSC_VER < 1400 && !defined(__cplusplus) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
-
-static INLINE float cosf( float f )
-{
- return (float) cos( (double) f );
-}
-
-static INLINE float sinf( float f )
-{
- return (float) sin( (double) f );
-}
-
-static INLINE float ceilf( float f )
-{
- return (float) ceil( (double) f );
-}
-
-static INLINE float floorf( float f )
-{
- return (float) floor( (double) f );
-}
-
-static INLINE float powf( float f, float g )
-{
- return (float) pow( (double) f, (double) g );
-}
-
-static INLINE float sqrtf( float f )
-{
- return (float) sqrt( (double) f );
-}
-
-static INLINE float fabsf( float f )
-{
- return (float) fabs( (double) f );
-}
-
-static INLINE float logf( float f )
-{
- return (float) log( (double) f );
-}
-
-#else
-/* Work-around an extra semi-colon in VS 2005 logf definition */
-#ifdef logf
-#undef logf
-#define logf(x) ((float)log((double)(x)))
-#endif /* logf */
-#endif
-#endif /* _MSC_VER */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/gallium/state_trackers/python/README b/src/gallium/state_trackers/python/README
index 8ab88ab..8f45fb6 100644
--- a/src/gallium/state_trackers/python/README
+++ b/src/gallium/state_trackers/python/README
@@ -24,9 +24,10 @@ and then try running
which should show a triangle.
-This is still in experimental phase, and there many limitations to what you can
-do with from Python.
-
+This is still work in progress:
+- errors are not handled properly and almost always result in crash
+- state atoms with array members are awkward to set
+- there no efficient way to view images
--
Jose Fonseca <jrfonseca@tungstengraphics.com>
diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript
index 973d96d..1581182 100644
--- a/src/gallium/state_trackers/python/SConscript
+++ b/src/gallium/state_trackers/python/SConscript
@@ -30,5 +30,5 @@ if 'python' in env['statetrackers']:
source = [
'st_hardpipe_winsys.c',
],
- LIBS = [pyst, softpipe] + auxiliaries + env['LIBS'],
+ LIBS = [pyst, softpipe, trace] + auxiliaries + env['LIBS'],
)
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index 8d7a49c..68d2db3 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -42,11 +42,11 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "cso_cache/cso_context.h"
#include "util/u_draw_quad.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
#include "tgsi/tgsi_text.h"
#include "tgsi/tgsi_dump.h"
@@ -55,6 +55,8 @@
%}
+%include "typemaps.i"
+
%include "carrays.i"
%array_class(unsigned char, ByteArray);
%array_class(int, IntArray);
diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i
index 521a2de..1fdcec6 100644
--- a/src/gallium/state_trackers/python/p_context.i
+++ b/src/gallium/state_trackers/python/p_context.i
@@ -68,6 +68,11 @@ struct st_context {
void set_fragment_shader( const struct pipe_shader_state *state ) {
void *fs;
+ if(!state) {
+ cso_set_fragment_shader_handle($self->cso, NULL);
+ return;
+ }
+
fs = $self->pipe->create_fs_state($self->pipe, state);
if(!fs)
return;
@@ -82,6 +87,11 @@ struct st_context {
void set_vertex_shader( const struct pipe_shader_state *state ) {
void *vs;
+ if(!state) {
+ cso_set_vertex_shader_handle($self->cso, NULL);
+ return;
+ }
+
vs = $self->pipe->create_vs_state($self->pipe, state);
if(!vs)
return;
@@ -110,7 +120,7 @@ struct st_context {
{
struct pipe_constant_buffer state;
memset(&state, 0, sizeof(state));
- state.buffer = buffer->buffer;
+ state.buffer = buffer ? buffer->buffer : NULL;
state.size = buffer->buffer->size;
$self->pipe->set_constant_buffer($self->pipe, shader, index, &state);
}
@@ -147,30 +157,38 @@ struct st_context {
unsigned buffer_offset,
struct st_buffer *buffer)
{
- unsigned i, num_vertex_buffers;
+ unsigned i;
struct pipe_vertex_buffer state;
memset(&state, 0, sizeof(state));
state.pitch = pitch;
state.max_index = max_index;
state.buffer_offset = buffer_offset;
- state.buffer = buffer->buffer;
+ state.buffer = buffer ? buffer->buffer : NULL;
memcpy(&$self->vertex_buffers[index], &state, sizeof(state));
for(i = 0; i < PIPE_MAX_ATTRIBS; ++i)
if(self->vertex_buffers[i].buffer)
- num_vertex_buffers = i + 1;
+ $self->num_vertex_buffers = i + 1;
$self->pipe->set_vertex_buffers($self->pipe,
- num_vertex_buffers,
+ $self->num_vertex_buffers,
$self->vertex_buffers);
}
void set_vertex_element(unsigned index,
- const struct pipe_vertex_element *element) {
+ const struct pipe_vertex_element *element)
+ {
memcpy(&$self->vertex_elements[index], element, sizeof(*element));
- $self->pipe->set_vertex_elements($self->pipe, PIPE_MAX_ATTRIBS, $self->vertex_elements);
+ }
+
+ void set_vertex_elements(unsigned num)
+ {
+ $self->num_vertex_elements = num;
+ $self->pipe->set_vertex_elements($self->pipe,
+ $self->num_vertex_elements,
+ $self->vertex_elements);
}
/*
@@ -183,8 +201,22 @@ struct st_context {
void draw_elements( struct st_buffer *indexBuffer,
unsigned indexSize,
- unsigned mode, unsigned start, unsigned count) {
- $self->pipe->draw_elements($self->pipe, indexBuffer->buffer, indexSize, mode, start, count);
+ unsigned mode, unsigned start, unsigned count)
+ {
+ $self->pipe->draw_elements($self->pipe,
+ indexBuffer->buffer,
+ indexSize,
+ mode, start, count);
+ }
+
+ void draw_range_elements( struct st_buffer *indexBuffer,
+ unsigned indexSize, unsigned minIndex, unsigned maxIndex,
+ unsigned mode, unsigned start, unsigned count)
+ {
+ $self->pipe->draw_range_elements($self->pipe,
+ indexBuffer->buffer,
+ indexSize, minIndex, maxIndex,
+ mode, start, count);
}
void draw_vertices(unsigned prim,
@@ -193,38 +225,38 @@ struct st_context {
const float *vertices)
{
struct pipe_context *pipe = $self->pipe;
- struct pipe_winsys *winsys = pipe->winsys;
+ struct pipe_screen *screen = pipe->screen;
struct pipe_buffer *vbuf;
float *map;
unsigned size;
size = num_verts * num_attribs * 4 * sizeof(float);
- vbuf = winsys->buffer_create(winsys,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
- size);
+ vbuf = pipe_buffer_create(screen,
+ 32,
+ PIPE_BUFFER_USAGE_VERTEX,
+ size);
if(!vbuf)
goto error1;
- map = winsys->buffer_map(winsys, vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pipe_buffer_map(screen, vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
if (!map)
goto error2;
memcpy(map, vertices, size);
- pipe->winsys->buffer_unmap(pipe->winsys, vbuf);
+ pipe_buffer_unmap(screen, vbuf);
util_draw_vertex_buffer(pipe, vbuf, prim, num_verts, num_attribs);
error2:
- pipe_buffer_reference(pipe->winsys, &vbuf, NULL);
+ pipe_buffer_reference(screen, &vbuf, NULL);
error1:
;
}
void
- flush(void) {
+ flush(unsigned flags = 0) {
struct pipe_fence_handle *fence = NULL;
- $self->pipe->flush($self->pipe, PIPE_FLUSH_RENDER_CACHE, &fence);
+ $self->pipe->flush($self->pipe, flags | PIPE_FLUSH_RENDER_CACHE, &fence);
/* TODO: allow asynchronous operation */
$self->pipe->winsys->fence_finish( $self->pipe->winsys, fence, 0 );
$self->pipe->winsys->fence_reference( $self->pipe->winsys, &fence, NULL );
diff --git a/src/gallium/state_trackers/python/p_state.i b/src/gallium/state_trackers/python/p_state.i
index 9834229..7f5760b 100644
--- a/src/gallium/state_trackers/python/p_state.i
+++ b/src/gallium/state_trackers/python/p_state.i
@@ -34,9 +34,15 @@
%module gallium;
+%ignore winsys;
+%ignore pipe_vertex_buffer::buffer;
+
%include "pipe/p_state.h";
+%array_class(struct pipe_stencil_state, StencilArray);
+
+
%extend pipe_framebuffer_state {
pipe_framebuffer_state(void) {
diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i
index fd38e07..33fb374 100644
--- a/src/gallium/state_trackers/python/p_texture.i
+++ b/src/gallium/state_trackers/python/p_texture.i
@@ -102,12 +102,12 @@
void unmap( void );
void
- get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, unsigned char *raw, unsigned stride) {
+ get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, char *raw, unsigned stride) {
pipe_get_tile_raw($self, x, y, w, h, raw, stride);
}
void
- put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const unsigned char *raw, unsigned stride) {
+ put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const char *raw, unsigned stride) {
pipe_put_tile_raw($self, x, y, w, h, raw, stride);
}
@@ -180,13 +180,25 @@ struct st_buffer {
}
void write( const char *STRING, unsigned LENGTH, unsigned offset = 0) {
- struct pipe_winsys *winsys = $self->st_dev->screen->winsys;
+ struct pipe_screen *screen = $self->st_dev->screen;
char *map;
- map = winsys->buffer_map(winsys, $self->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
- if(!map) {
+ assert($self->buffer->refcount);
+
+ if(offset > $self->buffer->size) {
+ PyErr_SetString(PyExc_ValueError, "offset must be smaller than buffer size");
+ return;
+ }
+
+ if(offset + LENGTH > $self->buffer->size) {
+ PyErr_SetString(PyExc_ValueError, "data length must fit inside the buffer");
+ return;
+ }
+
+ map = pipe_buffer_map(screen, $self->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ if(map) {
memcpy(map + offset, STRING, LENGTH);
- winsys->buffer_unmap(winsys, $self->buffer);
+ pipe_buffer_unmap(screen, $self->buffer);
}
}
};
diff --git a/src/gallium/state_trackers/python/retrace/README b/src/gallium/state_trackers/python/retrace/README
new file mode 100644
index 0000000..822cd11
--- /dev/null
+++ b/src/gallium/state_trackers/python/retrace/README
@@ -0,0 +1,17 @@
+This is an application written in python to replay the traces captured by the
+ trace pipe driver.
+
+
+To use it follow the instructions in src/gallium/drivers/trace/README and
+src/gallium/state_trackers/python/README, and then do
+
+ python src/gallium/state_trackers/python/samples/retrace/interpreter.py filename.trace
+
+
+This is still work in progress:
+- not everything is captured/replayed
+ - surface/textures contents
+- any tiny error will result in a crash
+
+--
+Jose Fonseca <jrfonseca@tungstengraphics.com>
diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py
new file mode 100755
index 0000000..351a6e7
--- /dev/null
+++ b/src/gallium/state_trackers/python/retrace/interpreter.py
@@ -0,0 +1,480 @@
+#!/usr/bin/env python
+#############################################################################
+#
+# Copyright 2008 Tungsten Graphics, Inc.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#############################################################################
+
+
+import sys
+import gallium
+import model
+import parser
+
+
+def make_image(surface):
+ pixels = gallium.FloatArray(surface.height*surface.width*4)
+ surface.get_tile_rgba(0, 0, surface.width, surface.height, pixels)
+
+ 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
+ return outimage
+
+def save_image(filename, surface):
+ outimage = make_image(surface)
+ outimage.save(filename, "PNG")
+
+def show_image(surface):
+ outimage = make_image(surface)
+
+ import Tkinter as tk
+ from PIL import Image, ImageTk
+ root = tk.Tk()
+
+ root.title('background image')
+
+ image1 = ImageTk.PhotoImage(outimage)
+ w = image1.width()
+ h = image1.height()
+ x = 100
+ y = 100
+ root.geometry("%dx%d+%d+%d" % (w, h, x, y))
+ panel1 = tk.Label(root, image=image1)
+ panel1.pack(side='top', fill='both', expand='yes')
+ panel1.image = image1
+ root.mainloop()
+
+
+
+
+class Struct:
+ """C-like struct"""
+
+ # A basic Python class can pass as a C-like structure
+ pass
+
+
+struct_factories = {
+ "pipe_blend_color": gallium.BlendColor,
+ "pipe_blend_state": gallium.Blend,
+ #"pipe_clip_state": gallium.Clip,
+ #"pipe_constant_buffer": gallium.ConstantBuffer,
+ "pipe_depth_state": gallium.Depth,
+ "pipe_stencil_state": gallium.Stencil,
+ "pipe_alpha_state": gallium.Alpha,
+ "pipe_depth_stencil_alpha_state": gallium.DepthStencilAlpha,
+ "pipe_format_block": gallium.FormatBlock,
+ #"pipe_framebuffer_state": gallium.Framebuffer,
+ "pipe_poly_stipple": gallium.PolyStipple,
+ "pipe_rasterizer_state": gallium.Rasterizer,
+ "pipe_sampler_state": gallium.Sampler,
+ "pipe_scissor_state": gallium.Scissor,
+ #"pipe_shader_state": gallium.Shader,
+ #"pipe_vertex_buffer": gallium.VertexBuffer,
+ "pipe_vertex_element": gallium.VertexElement,
+ "pipe_viewport_state": gallium.Viewport,
+ #"pipe_texture": gallium.Texture,
+}
+
+
+member_array_factories = {
+ "pipe_rasterizer_state": {"sprite_coord_mode": gallium.ByteArray},
+ "pipe_poly_stipple": {"stipple": gallium.UnsignedArray},
+ "pipe_viewport_state": {"scale": gallium.FloatArray, "translate": gallium.FloatArray},
+ #"pipe_clip_state": {"ucp": gallium.FloatArray},
+ "pipe_depth_stencil_alpha_state": {"stencil": gallium.StencilArray},
+ "pipe_blend_color": {"color": gallium.FloatArray},
+ "pipe_sampler_state": {"border_color": gallium.FloatArray},
+}
+
+
+class Translator(model.Visitor):
+ """Translate model arguments into regular Python objects"""
+
+ def __init__(self, interpreter):
+ self.interpreter = interpreter
+ self.result = None
+
+ def visit(self, node):
+ self.result = None
+ node.visit(self)
+ return self.result
+
+ def visit_literal(self, node):
+ self.result = node.value
+
+ def visit_named_constant(self, node):
+ # lookup the named constant in the gallium module
+ self.result = getattr(gallium, node.name)
+
+ def visit_array(self, node):
+ array = []
+ for element in node.elements:
+ array.append(self.visit(element))
+ self.result = array
+
+ def visit_struct(self, node):
+ struct_factory = struct_factories.get(node.name, Struct)
+ struct = struct_factory()
+ for member_name, member_node in node.members:
+ member_value = self.visit(member_node)
+ try:
+ array_factory = member_array_factories[node.name][member_name]
+ except KeyError:
+ pass
+ else:
+ assert isinstance(member_value, list)
+ array = array_factory(len(member_value))
+ for i in range(len(member_value)):
+ array[i] = member_value[i]
+ member_value = array
+ #print node.name, member_name, member_value
+ assert isinstance(struct, Struct) or hasattr(struct, member_name)
+ setattr(struct, member_name, member_value)
+ self.result = struct
+
+ def visit_pointer(self, node):
+ self.result = self.interpreter.lookup_object(node.address)
+
+
+class Object:
+
+ def __init__(self, interpreter, real):
+ self.interpreter = interpreter
+ self.real = real
+
+
+class Global(Object):
+
+ def __init__(self, interpreter, real):
+ self.interpreter = interpreter
+ self.real = real
+
+ def pipe_winsys_create(self):
+ return Winsys(self.interpreter, gallium.Device())
+
+ def pipe_screen_create(self, winsys):
+ return Screen(self.interpreter, winsys.real)
+
+ def pipe_context_create(self, screen):
+ context = screen.real.context_create()
+ return Context(self.interpreter, context)
+
+
+class Winsys(Object):
+
+ def __init__(self, interpreter, real):
+ self.interpreter = interpreter
+ self.real = real
+
+ def get_name(self):
+ pass
+
+ def user_buffer_create(self, data, size):
+ # We don't really care to distinguish between user and regular buffers
+ buffer = self.real.buffer_create(size,
+ 4,
+ gallium.PIPE_BUFFER_USAGE_CPU_READ |
+ gallium.PIPE_BUFFER_USAGE_CPU_WRITE )
+ buffer.write(data, size)
+ return buffer
+
+ def buffer_create(self, alignment, usage, size):
+ return self.real.buffer_create(size, alignment, usage)
+
+ def buffer_destroy(self, buffer):
+ pass
+
+ def buffer_write(self, buffer, data, size):
+ buffer.write(data, size)
+
+ def fence_finish(self, fence, flags):
+ pass
+
+ def fence_reference(self, dst, src):
+ pass
+
+ def flush_frontbuffer(self, surface):
+ pass
+
+ def surface_alloc(self):
+ return None
+
+ def surface_release(self, surface):
+ pass
+
+
+class Screen(Object):
+
+ def get_name(self):
+ pass
+
+ def get_vendor(self):
+ pass
+
+ def get_param(self, param):
+ pass
+
+ def get_paramf(self, param):
+ pass
+
+ def is_format_supported(self, format, target, tex_usage, geom_flags):
+ return self.real.is_format_supported(format, target, tex_usage, geom_flags)
+
+ def texture_create(self, template):
+ return self.real.texture_create(
+ format = template.format,
+ width = template.width[0],
+ height = template.height[0],
+ depth = template.depth[0],
+ last_level = template.last_level,
+ target = template.target,
+ tex_usage = template.tex_usage,
+ )
+
+ def texture_destroy(self, texture):
+ self.interpreter.unregister_object(texture)
+
+ def texture_release(self, surface):
+ pass
+
+ def get_tex_surface(self, texture, face, level, zslice, usage):
+ return texture.get_surface(face, level, zslice, usage)
+
+ def tex_surface_destroy(self, surface):
+ self.interpreter.unregister_object(surface)
+
+ def tex_surface_release(self, surface):
+ pass
+
+ def surface_write(self, surface, data, stride, size):
+ assert surface.nblocksy * stride == size
+ surface.put_tile_raw(0, 0, surface.width, surface.height, data, stride)
+
+
+class Context(Object):
+
+ def __init__(self, interpreter, real):
+ Object.__init__(self, interpreter, real)
+ self.cbufs = []
+ self.zsbuf = None
+
+ def destroy(self):
+ pass
+
+ def create_blend_state(self, state):
+ return state
+
+ def bind_blend_state(self, state):
+ if state is not None:
+ self.real.set_blend(state)
+
+ def delete_blend_state(self, state):
+ pass
+
+ def create_sampler_state(self, state):
+ return state
+
+ def delete_sampler_state(self, state):
+ pass
+
+ def bind_sampler_states(self, n, states):
+ for i in range(n):
+ self.real.set_sampler(i, states[i])
+
+ def create_rasterizer_state(self, state):
+ return state
+
+ def bind_rasterizer_state(self, state):
+ if state is not None:
+ self.real.set_rasterizer(state)
+
+ def delete_rasterizer_state(self, state):
+ pass
+
+ def create_depth_stencil_alpha_state(self, state):
+ return state
+
+ def bind_depth_stencil_alpha_state(self, state):
+ if state is not None:
+ self.real.set_depth_stencil_alpha(state)
+
+ def delete_depth_stencil_alpha_state(self, state):
+ pass
+
+ def create_fs_state(self, state):
+ tokens = str(state.tokens)
+ shader = gallium.Shader(tokens)
+ return shader
+
+ create_vs_state = create_fs_state
+
+ def bind_fs_state(self, state):
+ self.real.set_fragment_shader(state)
+
+ def bind_vs_state(self, state):
+ self.real.set_vertex_shader(state)
+
+ def delete_fs_state(self, state):
+ pass
+
+ delete_vs_state = delete_fs_state
+
+ def set_blend_color(self, state):
+ self.real.set_blend_color(state)
+
+ def set_clip_state(self, state):
+ _state = gallium.Clip()
+ _state.nr = state.nr
+ if state.nr:
+ # FIXME
+ ucp = gallium.FloatArray(gallium.PIPE_MAX_CLIP_PLANES*4)
+ for i in range(len(state.ucp)):
+ for j in range(len(state.ucp[i])):
+ ucp[i*4 + j] = state.ucp[i][j]
+ _state.ucp = ucp
+ self.real.set_clip(_state)
+
+ def set_constant_buffer(self, shader, index, state):
+ if state is not None:
+ self.real.set_constant_buffer(shader, index, state.buffer)
+
+ def set_framebuffer_state(self, state):
+ _state = gallium.Framebuffer()
+ _state.width = state.width
+ _state.height = state.height
+ _state.num_cbufs = state.num_cbufs
+ for i in range(len(state.cbufs)):
+ _state.set_cbuf(i, state.cbufs[i])
+ _state.set_zsbuf(state.zsbuf)
+ self.real.set_framebuffer(_state)
+
+ self.cbufs = state.cbufs
+ self.zsbuf = state.zsbuf
+
+ def set_polygon_stipple(self, state):
+ self.real.set_polygon_stipple(state)
+
+ def set_scissor_state(self, state):
+ self.real.set_scissor(state)
+
+ def set_viewport_state(self, state):
+ self.real.set_viewport(state)
+
+ def set_sampler_textures(self, n, textures):
+ for i in range(n):
+ self.real.set_sampler_texture(i, textures[i])
+
+ def set_vertex_buffers(self, n, vbufs):
+ for i in range(n):
+ vbuf = vbufs[i]
+ self.real.set_vertex_buffer(
+ i,
+ pitch = vbuf.pitch,
+ max_index = vbuf.max_index,
+ buffer_offset = vbuf.buffer_offset,
+ buffer = vbuf.buffer,
+ )
+
+ def set_vertex_elements(self, n, elements):
+ for i in range(n):
+ self.real.set_vertex_element(i, elements[i])
+ self.real.set_vertex_elements(n)
+
+ def set_edgeflags(self, bitfield):
+ # FIXME
+ pass
+
+ def draw_arrays(self, mode, start, count):
+ self.real.draw_arrays(mode, start, count)
+
+ def draw_elements(self, indexBuffer, indexSize, mode, start, count):
+ self.real.draw_elements(indexBuffer, indexSize, mode, start, count)
+
+ def draw_range_elements(self, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count):
+ self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count)
+
+ def flush(self, flags):
+ self.real.flush(flags)
+ if flags & gallium.PIPE_FLUSH_FRAME:
+ self._update()
+ return None
+
+ def clear(self, surface, value):
+ self.real.surface_clear(surface, value)
+
+ def _update(self):
+ self.real.flush()
+
+ if self.cbufs and self.cbufs[0]:
+ show_image(self.cbufs[0])
+
+
+class Interpreter(parser.TraceParser):
+
+ def __init__(self, stream):
+ parser.TraceParser.__init__(self, stream)
+ self.objects = {}
+ self.result = None
+ self.globl = Global(self, None)
+
+ def register_object(self, address, object):
+ self.objects[address] = object
+
+ def unregister_object(self, object):
+ # FIXME:
+ pass
+
+ def lookup_object(self, address):
+ return self.objects[address]
+
+ def interpret(self, trace):
+ for call in trace.calls:
+ self.interpret_call(call)
+
+ def handle_call(self, call):
+ sys.stderr.write("%s\n" % call)
+
+ args = [self.interpret_arg(arg) for name, arg in call.args]
+
+ if call.klass:
+ obj = args[0]
+ args = args[1:]
+ else:
+ obj = self.globl
+
+ method = getattr(obj, call.method)
+ ret = method(*args)
+
+ if call.ret and isinstance(call.ret, model.Pointer):
+ self.register_object(call.ret.address, ret)
+
+ def interpret_arg(self, node):
+ translator = Translator(self)
+ return translator.visit(node)
+
+
+if __name__ == '__main__':
+ parser.main(Interpreter)
diff --git a/src/gallium/state_trackers/python/retrace/model.py b/src/gallium/state_trackers/python/retrace/model.py
new file mode 100755
index 0000000..a17a765
--- /dev/null
+++ b/src/gallium/state_trackers/python/retrace/model.py
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+#############################################################################
+#
+# Copyright 2008 Tungsten Graphics, Inc.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#############################################################################
+
+
+'''Trace data model.'''
+
+
+class Node:
+
+ def visit(self, visitor):
+ raise NotImplementedError
+
+
+class Literal(Node):
+
+ def __init__(self, value):
+ self.value = value
+
+ def visit(self, visitor):
+ visitor.visit_literal(self)
+
+ def __str__(self):
+ if isinstance(self.value, str) and len(self.value) > 32:
+ return '...'
+ else:
+ return repr(self.value)
+
+
+class NamedConstant(Node):
+
+ def __init__(self, name):
+ self.name = name
+
+ def visit(self, visitor):
+ visitor.visit_named_constant(self)
+
+ def __str__(self):
+ return self.name
+
+
+class Array(Node):
+
+ def __init__(self, elements):
+ self.elements = elements
+
+ def visit(self, visitor):
+ visitor.visit_array(self)
+
+ def __str__(self):
+ return '{' + ', '.join([str(value) for value in self.elements]) + '}'
+
+
+class Struct(Node):
+
+ def __init__(self, name, members):
+ self.name = name
+ self.members = members
+
+ def visit(self, visitor):
+ visitor.visit_struct(self)
+
+ def __str__(self):
+ return '{' + ', '.join([name + ' = ' + str(value) for name, value in self.members]) + '}'
+
+
+class Pointer(Node):
+
+ def __init__(self, address):
+ self.address = address
+
+ def visit(self, visitor):
+ visitor.visit_pointer(self)
+
+ def __str__(self):
+ return self.address
+
+
+class Call:
+
+ def __init__(self, klass, method, args, ret):
+ self.klass = klass
+ self.method = method
+ self.args = args
+ self.ret = ret
+
+ def visit(self, visitor):
+ visitor.visit_call(self)
+
+ def __str__(self):
+ s = self.method
+ if self.klass:
+ s = self.klass + '::' + s
+ s += '(' + ', '.join([name + ' = ' + str(value) for name, value in self.args]) + ')'
+ if self.ret is not None:
+ s += ' = ' + str(self.ret)
+ return s
+
+
+class Trace:
+
+ def __init__(self, calls):
+ self.calls = calls
+
+ def visit(self, visitor):
+ visitor.visit_trace(self)
+
+ def __str__(self):
+ return '\n'.join([str(call) for call in self.calls])
+
+
+class Visitor:
+
+ def visit_literal(self, node):
+ raise NotImplementedError
+
+ def visit_named_constant(self, node):
+ raise NotImplementedError
+
+ def visit_array(self, node):
+ raise NotImplementedError
+
+ def visit_struct(self, node):
+ raise NotImplementedError
+
+ def visit_pointer(self, node):
+ raise NotImplementedError
+
+ def visit_call(self, node):
+ raise NotImplementedError
+
+ def visit_trace(self, node):
+ raise NotImplementedError
+
+
diff --git a/src/gallium/state_trackers/python/retrace/parser.py b/src/gallium/state_trackers/python/retrace/parser.py
new file mode 100755
index 0000000..6bc75ad
--- /dev/null
+++ b/src/gallium/state_trackers/python/retrace/parser.py
@@ -0,0 +1,345 @@
+#!/usr/bin/env python
+#############################################################################
+#
+# Copyright 2008 Tungsten Graphics, Inc.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#############################################################################
+
+
+import sys
+import xml.parsers.expat
+import binascii
+
+from model import *
+
+
+ELEMENT_START, ELEMENT_END, CHARACTER_DATA, EOF = range(4)
+
+
+class XmlToken:
+
+ def __init__(self, type, name_or_data, attrs = None, line = None, column = None):
+ assert type in (ELEMENT_START, ELEMENT_END, CHARACTER_DATA, EOF)
+ self.type = type
+ self.name_or_data = name_or_data
+ self.attrs = attrs
+ self.line = line
+ self.column = column
+
+ def __str__(self):
+ if self.type == ELEMENT_START:
+ return '<' + self.name_or_data + ' ...>'
+ if self.type == ELEMENT_END:
+ return '</' + self.name_or_data + '>'
+ if self.type == CHARACTER_DATA:
+ return self.name_or_data
+ if self.type == EOF:
+ return 'end of file'
+ assert 0
+
+
+class XmlTokenizer:
+ """Expat based XML tokenizer."""
+
+ def __init__(self, fp, skip_ws = True):
+ self.fp = fp
+ self.tokens = []
+ self.index = 0
+ self.final = False
+ self.skip_ws = skip_ws
+
+ self.character_pos = 0, 0
+ self.character_data = ''
+
+ self.parser = xml.parsers.expat.ParserCreate()
+ self.parser.StartElementHandler = self.handle_element_start
+ self.parser.EndElementHandler = self.handle_element_end
+ self.parser.CharacterDataHandler = self.handle_character_data
+
+ def handle_element_start(self, name, attributes):
+ self.finish_character_data()
+ line, column = self.pos()
+ token = XmlToken(ELEMENT_START, name, attributes, line, column)
+ self.tokens.append(token)
+
+ def handle_element_end(self, name):
+ self.finish_character_data()
+ line, column = self.pos()
+ token = XmlToken(ELEMENT_END, name, None, line, column)
+ self.tokens.append(token)
+
+ def handle_character_data(self, data):
+ if not self.character_data:
+ self.character_pos = self.pos()
+ self.character_data += data
+
+ def finish_character_data(self):
+ if self.character_data:
+ if not self.skip_ws or not self.character_data.isspace():
+ line, column = self.character_pos
+ token = XmlToken(CHARACTER_DATA, self.character_data, None, line, column)
+ self.tokens.append(token)
+ self.character_data = ''
+
+ def next(self):
+ size = 16*1024
+ while self.index >= len(self.tokens) and not self.final:
+ self.tokens = []
+ self.index = 0
+ data = self.fp.read(size)
+ self.final = len(data) < size
+ data = data.rstrip('\0')
+ try:
+ self.parser.Parse(data, self.final)
+ except xml.parsers.expat.ExpatError, e:
+ #if e.code == xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS:
+ if e.code == 3:
+ pass
+ else:
+ raise e
+ if self.index >= len(self.tokens):
+ line, column = self.pos()
+ token = XmlToken(EOF, None, None, line, column)
+ else:
+ token = self.tokens[self.index]
+ self.index += 1
+ return token
+
+ def pos(self):
+ return self.parser.CurrentLineNumber, self.parser.CurrentColumnNumber
+
+
+class TokenMismatch(Exception):
+
+ def __init__(self, expected, found):
+ self.expected = expected
+ self.found = found
+
+ def __str__(self):
+ return '%u:%u: %s expected, %s found' % (self.found.line, self.found.column, str(self.expected), str(self.found))
+
+
+
+class XmlParser:
+ """Base XML document parser."""
+
+ def __init__(self, fp):
+ self.tokenizer = XmlTokenizer(fp)
+ self.consume()
+
+ def consume(self):
+ self.token = self.tokenizer.next()
+
+ def match_element_start(self, name):
+ return self.token.type == ELEMENT_START and self.token.name_or_data == name
+
+ def match_element_end(self, name):
+ return self.token.type == ELEMENT_END and self.token.name_or_data == name
+
+ def element_start(self, name):
+ while self.token.type == CHARACTER_DATA:
+ self.consume()
+ if self.token.type != ELEMENT_START:
+ raise TokenMismatch(XmlToken(ELEMENT_START, name), self.token)
+ if self.token.name_or_data != name:
+ raise TokenMismatch(XmlToken(ELEMENT_START, name), self.token)
+ attrs = self.token.attrs
+ self.consume()
+ return attrs
+
+ def element_end(self, name):
+ while self.token.type == CHARACTER_DATA:
+ self.consume()
+ if self.token.type != ELEMENT_END:
+ raise TokenMismatch(XmlToken(ELEMENT_END, name), self.token)
+ if self.token.name_or_data != name:
+ raise TokenMismatch(XmlToken(ELEMENT_END, name), self.token)
+ self.consume()
+
+ def character_data(self, strip = True):
+ data = ''
+ while self.token.type == CHARACTER_DATA:
+ data += self.token.name_or_data
+ self.consume()
+ if strip:
+ data = data.strip()
+ return data
+
+
+class TraceParser(XmlParser):
+
+ def parse(self):
+ self.element_start('trace')
+ while self.token.type not in (ELEMENT_END, EOF):
+ call = self.parse_call()
+ self.handle_call(call)
+ if self.token.type != EOF:
+ self.element_end('trace')
+
+ def parse_call(self):
+ attrs = self.element_start('call')
+ klass = attrs['class']
+ method = attrs['method']
+ args = []
+ ret = None
+ while self.token.type == ELEMENT_START:
+ if self.token.name_or_data == 'arg':
+ arg = self.parse_arg()
+ args.append(arg)
+ elif self.token.name_or_data == 'ret':
+ ret = self.parse_ret()
+ elif self.token.name_or_data == 'call':
+ # ignore nested function calls
+ self.parse_call()
+ else:
+ raise TokenMismatch("<arg ...> or <ret ...>", self.token)
+ self.element_end('call')
+
+ return Call(klass, method, args, ret)
+
+ def parse_arg(self):
+ attrs = self.element_start('arg')
+ name = attrs['name']
+ value = self.parse_value()
+ self.element_end('arg')
+
+ return name, value
+
+ def parse_ret(self):
+ attrs = self.element_start('ret')
+ value = self.parse_value()
+ self.element_end('ret')
+
+ return value
+
+ def parse_value(self):
+ expected_tokens = ('null', 'bool', 'int', 'uint', 'float', 'string', 'enum', 'array', 'struct', 'ptr', 'bytes')
+ if self.token.type == ELEMENT_START:
+ if self.token.name_or_data in expected_tokens:
+ method = getattr(self, 'parse_' + self.token.name_or_data)
+ return method()
+ raise TokenMismatch(" or " .join(expected_tokens), self.token)
+
+ def parse_null(self):
+ self.element_start('null')
+ self.element_end('null')
+ return Literal(None)
+
+ def parse_bool(self):
+ self.element_start('bool')
+ value = int(self.character_data())
+ self.element_end('bool')
+ return Literal(value)
+
+ def parse_int(self):
+ self.element_start('int')
+ value = int(self.character_data())
+ self.element_end('int')
+ return Literal(value)
+
+ def parse_uint(self):
+ self.element_start('uint')
+ value = int(self.character_data())
+ self.element_end('uint')
+ return Literal(value)
+
+ def parse_float(self):
+ self.element_start('float')
+ value = float(self.character_data())
+ self.element_end('float')
+ return Literal(value)
+
+ def parse_enum(self):
+ self.element_start('enum')
+ name = self.character_data()
+ self.element_end('enum')
+ return NamedConstant(name)
+
+ def parse_string(self):
+ self.element_start('string')
+ value = self.character_data()
+ self.element_end('string')
+ return Literal(value)
+
+ def parse_bytes(self):
+ self.element_start('bytes')
+ value = binascii.a2b_hex(self.character_data())
+ self.element_end('bytes')
+ return Literal(value)
+
+ def parse_array(self):
+ self.element_start('array')
+ elems = []
+ while self.token.type != ELEMENT_END:
+ elems.append(self.parse_elem())
+ self.element_end('array')
+ return Array(elems)
+
+ def parse_elem(self):
+ self.element_start('elem')
+ value = self.parse_value()
+ self.element_end('elem')
+ return value
+
+ def parse_struct(self):
+ attrs = self.element_start('struct')
+ name = attrs['name']
+ members = []
+ while self.token.type != ELEMENT_END:
+ members.append(self.parse_member())
+ self.element_end('struct')
+ return Struct(name, members)
+
+ def parse_member(self):
+ attrs = self.element_start('member')
+ name = attrs['name']
+ value = self.parse_value()
+ self.element_end('member')
+
+ return name, value
+
+ def parse_ptr(self):
+ self.element_start('ptr')
+ address = self.character_data()
+ self.element_end('ptr')
+
+ return Pointer(address)
+
+ def handle_call(self, call):
+
+ pass
+
+
+class TraceDumper(TraceParser):
+
+
+ def handle_call(self, call):
+ print call
+
+
+def main(ParserFactory):
+ for arg in sys.argv[1:]:
+ if arg.endswith('.gz'):
+ import gzip
+ stream = gzip.GzipFile(arg, 'rt')
+ else:
+ stream = open(arg, 'rt')
+ parser = ParserFactory(stream)
+ parser.parse()
+
+
+if __name__ == '__main__':
+ main(TraceDumper)
diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py
index 1271c67..193479f 100644
--- a/src/gallium/state_trackers/python/samples/tri.py
+++ b/src/gallium/state_trackers/python/samples/tri.py
@@ -167,7 +167,6 @@ def test(dev):
1:MOV OUT[1], IN[1]
2:END
''')
- #vs.dump()
ctx.set_vertex_shader(vs)
# fragment shader
@@ -178,7 +177,6 @@ def test(dev):
0:MOV OUT[0], IN[0]
1:END
''')
- #fs.dump()
ctx.set_fragment_shader(fs)
nverts = 3
@@ -218,6 +216,7 @@ def test(dev):
ctx.flush()
show_image(cbuf.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ|PIPE_BUFFER_USAGE_CPU_WRITE))
+ #save_image('tri.png', cbuf.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ|PIPE_BUFFER_USAGE_CPU_WRITE))
diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c
index fbd5671..95c1378 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -26,13 +26,17 @@
**************************************************************************/
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_inlines.h"
#include "cso_cache/cso_context.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+
#include "st_device.h"
#include "st_winsys.h"
@@ -41,7 +45,7 @@ static void
st_device_really_destroy(struct st_device *st_dev)
{
if(st_dev->screen)
- st_dev->st_ws->screen_destroy(st_dev->screen);
+ st_dev->screen->destroy(st_dev->screen);
FREE(st_dev);
}
@@ -61,9 +65,7 @@ st_device_create_from_st_winsys(const struct st_winsys *st_ws)
struct st_device *st_dev;
if(!st_ws->screen_create ||
- !st_ws->screen_destroy ||
- !st_ws->context_create ||
- !st_ws->context_destroy)
+ !st_ws->context_create)
return NULL;
st_dev = CALLOC_STRUCT(st_device);
@@ -73,9 +75,17 @@ st_device_create_from_st_winsys(const struct st_winsys *st_ws)
st_dev->refcount = 1;
st_dev->st_ws = st_ws;
- st_dev->screen = st_ws->screen_create();
- if(!st_dev->screen)
+ st_dev->real_screen = st_ws->screen_create();
+ if(!st_dev->real_screen) {
+ st_device_destroy(st_dev);
+ return NULL;
+ }
+
+ st_dev->screen = trace_screen_create(st_dev->real_screen);
+ if(!st_dev->screen) {
st_device_destroy(st_dev);
+ return NULL;
+ }
return st_dev;
}
@@ -106,7 +116,7 @@ st_context_destroy(struct st_context *st_ctx)
}
if(st_ctx->pipe)
- st_ctx->st_dev->st_ws->context_destroy(st_ctx->pipe);
+ st_ctx->pipe->destroy(st_ctx->pipe);
for(i = 0; i < PIPE_MAX_SAMPLERS; ++i)
pipe_texture_reference(&st_ctx->sampler_textures[i], NULL);
@@ -132,13 +142,23 @@ st_context_create(struct st_device *st_dev)
st_ctx->st_dev = st_dev;
++st_dev->refcount;
- st_ctx->pipe = st_dev->st_ws->context_create(st_dev->screen);
- if(!st_ctx->pipe)
+ st_ctx->real_pipe = st_dev->st_ws->context_create(st_dev->real_screen);
+ if(!st_ctx->real_pipe) {
st_context_destroy(st_ctx);
+ return NULL;
+ }
+ st_ctx->pipe = trace_context_create(st_dev->screen, st_ctx->real_pipe);
+ if(!st_ctx->pipe) {
+ st_context_destroy(st_ctx);
+ return NULL;
+ }
+
st_ctx->cso = cso_create_context(st_ctx->pipe);
- if(!st_ctx->cso)
+ if(!st_ctx->cso) {
st_context_destroy(st_ctx);
+ return NULL;
+ }
/* disabled blending/masking */
{
@@ -272,8 +292,8 @@ void
st_buffer_destroy(struct st_buffer *st_buf)
{
if(st_buf) {
- struct pipe_winsys *winsys = st_buf->st_dev->screen->winsys;
- pipe_buffer_reference(winsys, &st_buf->buffer, NULL);
+ struct pipe_screen *screen = st_buf->st_dev->screen;
+ pipe_buffer_reference(screen, &st_buf->buffer, NULL);
FREE(st_buf);
}
}
@@ -283,7 +303,7 @@ struct st_buffer *
st_buffer_create(struct st_device *st_dev,
unsigned alignment, unsigned usage, unsigned size)
{
- struct pipe_winsys *winsys = st_dev->screen->winsys;
+ struct pipe_screen *screen = st_dev->screen;
struct st_buffer *st_buf;
st_buf = CALLOC_STRUCT(st_buffer);
@@ -292,9 +312,11 @@ st_buffer_create(struct st_device *st_dev,
st_buf->st_dev = st_dev;
- st_buf->buffer = winsys->buffer_create(winsys, alignment, usage, size);
- if(!st_buf->buffer)
+ st_buf->buffer = pipe_buffer_create(screen, alignment, usage, size);
+ if(!st_buf->buffer) {
st_buffer_destroy(st_buf);
+ return NULL;
+ }
return st_buf;
}
diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h
index 5b7adbe..7cfe6de 100644
--- a/src/gallium/state_trackers/python/st_device.h
+++ b/src/gallium/state_trackers/python/st_device.h
@@ -48,6 +48,7 @@ struct st_buffer {
struct st_context {
struct st_device *st_dev;
+ struct pipe_context *real_pipe;
struct pipe_context *pipe;
struct cso_context *cso;
@@ -57,14 +58,19 @@ struct st_context {
struct pipe_texture *default_texture;
struct pipe_texture *sampler_textures[PIPE_MAX_SAMPLERS];
+
+ unsigned num_vertex_buffers;
struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
+
+ unsigned num_vertex_elements;
struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS];
};
struct st_device {
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... */
diff --git a/src/gallium/state_trackers/python/st_hardpipe_winsys.c b/src/gallium/state_trackers/python/st_hardpipe_winsys.c
index 1e04998..8b33c70 100644
--- a/src/gallium/state_trackers/python/st_hardpipe_winsys.c
+++ b/src/gallium/state_trackers/python/st_hardpipe_winsys.c
@@ -42,13 +42,6 @@ extern void init_gallium(void);
void (*force_init_gallium_linkage)(void) = &init_gallium;
-static void
-st_hardpipe_screen_destroy(struct pipe_screen *screen)
-{
- st_softpipe_winsys.screen_destroy(screen);
-}
-
-
static struct pipe_screen *
st_hardpipe_screen_create(void)
{
@@ -56,13 +49,6 @@ st_hardpipe_screen_create(void)
}
-static void
-st_hardpipe_context_destroy(struct pipe_context *pipe)
-{
- st_softpipe_winsys.context_destroy(pipe);
-}
-
-
static struct pipe_context *
st_hardpipe_context_create(struct pipe_screen *screen)
{
@@ -72,7 +58,5 @@ st_hardpipe_context_create(struct pipe_screen *screen)
const struct st_winsys st_hardpipe_winsys = {
&st_hardpipe_screen_create,
- &st_hardpipe_screen_destroy,
- &st_hardpipe_context_create,
- &st_hardpipe_context_destroy
+ &st_hardpipe_context_create
};
diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c
index b47c7be..7765df3 100644
--- a/src/gallium/state_trackers/python/st_sample.c
+++ b/src/gallium/state_trackers/python/st_sample.c
@@ -29,9 +29,10 @@
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "st_sample.h"
diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c
index 1fda70c..f62113a 100644
--- a/src/gallium/state_trackers/python/st_softpipe_winsys.c
+++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c
@@ -39,8 +39,9 @@
#include "pipe/p_winsys.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
#include "st_winsys.h"
@@ -220,7 +221,7 @@ st_softpipe_surface_release(struct pipe_winsys *winsys,
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -253,13 +254,9 @@ st_softpipe_fence_finish(struct pipe_winsys *winsys,
}
-static void
-st_softpipe_screen_destroy(struct pipe_screen *screen)
+static void
+st_softpipe_destroy(struct pipe_winsys *winsys)
{
- struct pipe_winsys *winsys = screen->winsys;
-
- screen->destroy(screen);
-
FREE(winsys);
}
@@ -274,6 +271,8 @@ st_softpipe_screen_create(void)
if(!winsys)
return NULL;
+ winsys->destroy = st_softpipe_destroy;
+
winsys->buffer_create = st_softpipe_buffer_create;
winsys->user_buffer_create = st_softpipe_user_buffer_create;
winsys->buffer_map = st_softpipe_buffer_map;
@@ -293,19 +292,12 @@ st_softpipe_screen_create(void)
screen = softpipe_create_screen(winsys);
if(!screen)
- FREE(winsys);
+ st_softpipe_destroy(winsys);
return screen;
}
-static void
-st_softpipe_context_destroy(struct pipe_context *pipe)
-{
- pipe->destroy(pipe);
-}
-
-
static struct pipe_context *
st_softpipe_context_create(struct pipe_screen *screen)
{
@@ -315,7 +307,5 @@ st_softpipe_context_create(struct pipe_screen *screen)
const struct st_winsys st_softpipe_winsys = {
&st_softpipe_screen_create,
- &st_softpipe_screen_destroy,
&st_softpipe_context_create,
- &st_softpipe_context_destroy
};
diff --git a/src/gallium/state_trackers/python/st_winsys.h b/src/gallium/state_trackers/python/st_winsys.h
index 43db8b6..b8cb612 100644
--- a/src/gallium/state_trackers/python/st_winsys.h
+++ b/src/gallium/state_trackers/python/st_winsys.h
@@ -39,14 +39,8 @@ struct st_winsys
struct pipe_screen *
(*screen_create)(void);
- void
- (*screen_destroy)(struct pipe_screen *screen);
-
struct pipe_context *
(*context_create)(struct pipe_screen *screen);
-
- void
- (*context_destroy)(struct pipe_context *pipe);
};
diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript
index bf1718e..30c3378 100644
--- a/src/gallium/winsys/SConscript
+++ b/src/gallium/winsys/SConscript
@@ -2,7 +2,7 @@ Import('*')
if env['dri']:
SConscript([
- 'dri/SConscript',
+ 'drm/SConscript',
])
if 'xlib' in env['winsys']:
diff --git a/src/gallium/winsys/common/intel_drm/glthread.h b/src/gallium/winsys/common/intel_drm/glthread.h
deleted file mode 100644
index b8e9d5f..0000000
--- a/src/gallium/winsys/common/intel_drm/glthread.h
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.2
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/*
- * Thread support for gl dispatch.
- *
- * Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu)
- * and Christoph Poliwoda (poliwoda@volumegraphics.com)
- * Revised by Keith Whitwell
- * Adapted for new gl dispatcher by Brian Paul
- *
- *
- *
- * DOCUMENTATION
- *
- * This thread module exports the following types:
- * _glthread_TSD Thread-specific data area
- * _glthread_Thread Thread datatype
- * _glthread_Mutex Mutual exclusion lock
- *
- * Macros:
- * _glthread_DECLARE_STATIC_MUTEX(name) Declare a non-local mutex
- * _glthread_INIT_MUTEX(name) Initialize a mutex
- * _glthread_LOCK_MUTEX(name) Lock a mutex
- * _glthread_UNLOCK_MUTEX(name) Unlock a mutex
- *
- * Functions:
- * _glthread_GetID(v) Get integer thread ID
- * _glthread_InitTSD() Initialize thread-specific data
- * _glthread_GetTSD() Get thread-specific data
- * _glthread_SetTSD() Set thread-specific data
- *
- */
-
-/*
- * If this file is accidentally included by a non-threaded build,
- * it should not cause the build to fail, or otherwise cause problems.
- * In general, it should only be included when needed however.
- */
-
-#ifndef GLTHREAD_H
-#define GLTHREAD_H
-
-
-#if defined(USE_MGL_NAMESPACE)
-#define _glapi_Dispatch _mglapi_Dispatch
-#endif
-
-
-
-#if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\
- defined(WIN32_THREADS) || defined(USE_XTHREADS) || defined(BEOS_THREADS)) \
- && !defined(THREADS)
-# define THREADS
-#endif
-
-#ifdef VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-/*
- * POSIX threads. This should be your choice in the Unix world
- * whenever possible. When building with POSIX threads, be sure
- * to enable any compiler flags which will cause the MT-safe
- * libc (if one exists) to be used when linking, as well as any
- * header macros for MT-safe errno, etc. For Solaris, this is the -mt
- * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable
- * proper compiling for MT-safe libc etc.
- */
-#if defined(PTHREADS)
-#include <pthread.h> /* POSIX threads headers */
-
-typedef struct {
- pthread_key_t key;
- int initMagic;
-} _glthread_TSD;
-
-typedef pthread_t _glthread_Thread;
-
-typedef pthread_mutex_t _glthread_Mutex;
-
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name = PTHREAD_MUTEX_INITIALIZER
-
-#define _glthread_INIT_MUTEX(name) \
- pthread_mutex_init(&(name), NULL)
-
-#define _glthread_DESTROY_MUTEX(name) \
- pthread_mutex_destroy(&(name))
-
-#define _glthread_LOCK_MUTEX(name) \
- (void) pthread_mutex_lock(&(name))
-
-#define _glthread_UNLOCK_MUTEX(name) \
- (void) pthread_mutex_unlock(&(name))
-
-typedef pthread_cond_t _glthread_Cond;
-
-#define _glthread_DECLARE_STATIC_COND(name) \
- static _glthread_Cond name = PTHREAD_COND_INITIALIZER
-
-#define _glthread_INIT_COND(cond) \
- pthread_cond_init(&(cond), NULL)
-
-#define _glthread_DESTROY_COND(name) \
- pthread_cond_destroy(&(name))
-
-#define _glthread_COND_WAIT(cond, mutex) \
- pthread_cond_wait(&(cond), &(mutex))
-
-#define _glthread_COND_SIGNAL(cond) \
- pthread_cond_signal(&(cond))
-
-#define _glthread_COND_BROADCAST(cond) \
- pthread_cond_broadcast(&(cond))
-
-
-#else /* PTHREADS */
-
-typedef unsigned int _glthread_Cond;
-#define _glthread_DECLARE_STATIC_COND(name) \
-// #warning Condition variables not implemented.
-
-#define _glthread_INIT_COND(cond) \
- abort();
-
-#define _glthread_DESTROY_COND(name) \
- abort();
-
-#define _glthread_COND_WAIT(cond, mutex) \
- abort();
-
-#define _glthread_COND_SIGNAL(cond) \
- abort();
-
-#define _glthread_COND_BROADCAST(cond) \
- abort();
-
-#endif
-
-
-/*
- * Solaris threads. Use only up to Solaris 2.4.
- * Solaris 2.5 and higher provide POSIX threads.
- * Be sure to compile with -mt on the Solaris compilers, or
- * use -D_REENTRANT if using gcc.
- */
-#ifdef SOLARIS_THREADS
-#include <thread.h>
-
-typedef struct {
- thread_key_t key;
- mutex_t keylock;
- int initMagic;
-} _glthread_TSD;
-
-typedef thread_t _glthread_Thread;
-
-typedef mutex_t _glthread_Mutex;
-
-/* XXX need to really implement mutex-related macros */
-#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
-#define _glthread_INIT_MUTEX(name) (void) name
-#define _glthread_DESTROY_MUTEX(name) (void) name
-#define _glthread_LOCK_MUTEX(name) (void) name
-#define _glthread_UNLOCK_MUTEX(name) (void) name
-
-#endif /* SOLARIS_THREADS */
-
-
-
-
-/*
- * Windows threads. Should work with Windows NT and 95.
- * IMPORTANT: Link with multithreaded runtime library when THREADS are
- * used!
- */
-#ifdef WIN32_THREADS
-#include <windows.h>
-
-typedef struct {
- DWORD key;
- int initMagic;
-} _glthread_TSD;
-
-typedef HANDLE _glthread_Thread;
-
-typedef CRITICAL_SECTION _glthread_Mutex;
-
-#define _glthread_DECLARE_STATIC_MUTEX(name) /*static*/ _glthread_Mutex name = {0,0,0,0,0,0}
-#define _glthread_INIT_MUTEX(name) InitializeCriticalSection(&name)
-#define _glthread_DESTROY_MUTEX(name) DeleteCriticalSection(&name)
-#define _glthread_LOCK_MUTEX(name) EnterCriticalSection(&name)
-#define _glthread_UNLOCK_MUTEX(name) LeaveCriticalSection(&name)
-
-#endif /* WIN32_THREADS */
-
-
-
-
-/*
- * XFree86 has its own thread wrapper, Xthreads.h
- * We wrap it again for GL.
- */
-#ifdef USE_XTHREADS
-#include <X11/Xthreads.h>
-
-typedef struct {
- xthread_key_t key;
- int initMagic;
-} _glthread_TSD;
-
-typedef xthread_t _glthread_Thread;
-
-typedef xmutex_rec _glthread_Mutex;
-
-#ifdef XMUTEX_INITIALIZER
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name = XMUTEX_INITIALIZER
-#else
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name
-#endif
-
-#define _glthread_INIT_MUTEX(name) \
- xmutex_init(&(name))
-
-#define _glthread_DESTROY_MUTEX(name) \
- xmutex_clear(&(name))
-
-#define _glthread_LOCK_MUTEX(name) \
- (void) xmutex_lock(&(name))
-
-#define _glthread_UNLOCK_MUTEX(name) \
- (void) xmutex_unlock(&(name))
-
-#endif /* USE_XTHREADS */
-
-
-
-/*
- * BeOS threads. R5.x required.
- */
-#ifdef BEOS_THREADS
-
-#include <kernel/OS.h>
-#include <support/TLS.h>
-
-typedef struct {
- int32 key;
- int initMagic;
-} _glthread_TSD;
-
-typedef thread_id _glthread_Thread;
-
-/* Use Benaphore, aka speeder semaphore */
-typedef struct {
- int32 lock;
- sem_id sem;
-} benaphore;
-typedef benaphore _glthread_Mutex;
-
-#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = { 0, 0 }
-#define _glthread_INIT_MUTEX(name) name.sem = create_sem(0, #name"_benaphore"), name.lock = 0
-#define _glthread_DESTROY_MUTEX(name) delete_sem(name.sem), name.lock = 0
-#define _glthread_LOCK_MUTEX(name) if (name.sem == 0) _glthread_INIT_MUTEX(name); \
- if (atomic_add(&(name.lock), 1) >= 1) acquire_sem(name.sem)
-#define _glthread_UNLOCK_MUTEX(name) if (atomic_add(&(name.lock), -1) > 1) release_sem(name.sem)
-
-#endif /* BEOS_THREADS */
-
-
-
-#ifndef THREADS
-
-/*
- * THREADS not defined
- */
-
-typedef GLuint _glthread_TSD;
-
-typedef GLuint _glthread_Thread;
-
-typedef GLuint _glthread_Mutex;
-
-#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
-
-#define _glthread_INIT_MUTEX(name) (void) name
-
-#define _glthread_DESTROY_MUTEX(name) (void) name
-
-#define _glthread_LOCK_MUTEX(name) (void) name
-
-#define _glthread_UNLOCK_MUTEX(name) (void) name
-
-#endif /* THREADS */
-
-
-
-/*
- * Platform independent thread specific data API.
- */
-
-extern unsigned long
-_glthread_GetID(void);
-
-
-extern void
-_glthread_InitTSD(_glthread_TSD *);
-
-
-extern void *
-_glthread_GetTSD(_glthread_TSD *);
-
-
-extern void
-_glthread_SetTSD(_glthread_TSD *, void *);
-
-#if defined(GLX_USE_TLS)
-
-extern __thread struct _glapi_table * _glapi_tls_Dispatch
- __attribute__((tls_model("initial-exec")));
-
-#define GET_DISPATCH() _glapi_tls_Dispatch
-
-#elif !defined(GL_CALL)
-# if defined(THREADS)
-# define GET_DISPATCH() \
- ((__builtin_expect( _glapi_Dispatch != NULL, 1 )) \
- ? _glapi_Dispatch : _glapi_get_dispatch())
-# else
-# define GET_DISPATCH() _glapi_Dispatch
-# endif /* defined(THREADS) */
-#endif /* ndef GL_CALL */
-
-
-#endif /* THREADS_H */
diff --git a/src/gallium/winsys/dri/Makefile b/src/gallium/winsys/drm/Makefile
index f466ce6..f466ce6 100644
--- a/src/gallium/winsys/dri/Makefile
+++ b/src/gallium/winsys/drm/Makefile
diff --git a/src/gallium/winsys/dri/Makefile.template b/src/gallium/winsys/drm/Makefile.template
index 80e817b..80e817b 100644
--- a/src/gallium/winsys/dri/Makefile.template
+++ b/src/gallium/winsys/drm/Makefile.template
diff --git a/src/gallium/winsys/dri/SConscript b/src/gallium/winsys/drm/SConscript
index aef5210..aef5210 100644
--- a/src/gallium/winsys/dri/SConscript
+++ b/src/gallium/winsys/drm/SConscript
diff --git a/src/gallium/winsys/common/Makefile b/src/gallium/winsys/drm/intel/Makefile
index 4c0f354..a670ac04 100644
--- a/src/gallium/winsys/common/Makefile
+++ b/src/gallium/winsys/drm/intel/Makefile
@@ -1,8 +1,8 @@
-TOP = ../../../..
+TOP = ../../../../..
include $(TOP)/configs/current
-SUBDIRS = $(GALLIUM_WINSYS_COMMON_DIRS)
+SUBDIRS = common dri egl
default: subdirs
@@ -18,3 +18,8 @@ subdirs:
clean:
rm -f `find . -name \*.[oa]`
+ rm -f `find . -name depend`
+
+
+# Dummy install target
+install:
diff --git a/src/gallium/winsys/common/intel_drm/Makefile b/src/gallium/winsys/drm/intel/common/Makefile
index 913dbef..bf1a7d6 100644
--- a/src/gallium/winsys/common/intel_drm/Makefile
+++ b/src/gallium/winsys/drm/intel/common/Makefile
@@ -1,4 +1,4 @@
-TOP = ../../../../..
+TOP = ../../../../../..
include $(TOP)/configs/current
LIBNAME = inteldrm
@@ -14,7 +14,7 @@ C_SOURCES = \
ws_dri_slabpool.c
-include ../Makefile.template
+include ./Makefile.template
DRIVER_DEFINES = $(shell pkg-config libdrm --cflags \
&& pkg-config libdrm --atleast-version=2.3.1 \
diff --git a/src/gallium/winsys/common/Makefile.template b/src/gallium/winsys/drm/intel/common/Makefile.template
index 67af778..02ed363 100644
--- a/src/gallium/winsys/common/Makefile.template
+++ b/src/gallium/winsys/drm/intel/common/Makefile.template
@@ -39,7 +39,7 @@ INCLUDES = \
default: depend symlinks $(LIBNAME)
-$(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/gallium/winsys/common/Makefile.template
+$(LIBNAME): $(OBJECTS) Makefile Makefile.template
$(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS)
diff --git a/src/gallium/winsys/common/intel_drm/intel_be_batchbuffer.c b/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c
index bc13a57..bc13a57 100644
--- a/src/gallium/winsys/common/intel_drm/intel_be_batchbuffer.c
+++ b/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c
diff --git a/src/gallium/winsys/common/intel_drm/intel_be_batchbuffer.h b/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h
index f150e3a..f150e3a 100644
--- a/src/gallium/winsys/common/intel_drm/intel_be_batchbuffer.h
+++ b/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h
diff --git a/src/gallium/winsys/common/intel_drm/intel_be_context.c b/src/gallium/winsys/drm/intel/common/intel_be_context.c
index 1af3967..1af3967 100644
--- a/src/gallium/winsys/common/intel_drm/intel_be_context.c
+++ b/src/gallium/winsys/drm/intel/common/intel_be_context.c
diff --git a/src/gallium/winsys/common/intel_drm/intel_be_context.h b/src/gallium/winsys/drm/intel/common/intel_be_context.h
index d5cbc93..d5cbc93 100644
--- a/src/gallium/winsys/common/intel_drm/intel_be_context.h
+++ b/src/gallium/winsys/drm/intel/common/intel_be_context.h
diff --git a/src/gallium/winsys/common/intel_drm/intel_be_device.c b/src/gallium/winsys/drm/intel/common/intel_be_device.c
index 8db0329..019ee5c 100644
--- a/src/gallium/winsys/common/intel_drm/intel_be_device.c
+++ b/src/gallium/winsys/drm/intel/common/intel_be_device.c
@@ -13,8 +13,8 @@
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
#include "i915simple/i915_screen.h"
diff --git a/src/gallium/winsys/common/intel_drm/intel_be_device.h b/src/gallium/winsys/drm/intel/common/intel_be_device.h
index 3f8b3f5..3f8b3f5 100644
--- a/src/gallium/winsys/common/intel_drm/intel_be_device.h
+++ b/src/gallium/winsys/drm/intel/common/intel_be_device.h
diff --git a/src/gallium/winsys/common/intel_drm/ws_dri_bufmgr.c b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
index b6d901f..517a97b 100644
--- a/src/gallium/winsys/common/intel_drm/ws_dri_bufmgr.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
@@ -33,7 +33,7 @@
#include <xf86drm.h>
#include <stdlib.h>
#include <stdio.h>
-#include "glthread.h"
+#include "pipe/p_thread.h"
#include "errno.h"
#include "ws_dri_bufmgr.h"
#include "string.h"
@@ -51,8 +51,8 @@
* driBufferObject mutex - > this rw lock.
*/
-_glthread_DECLARE_STATIC_MUTEX(bmMutex);
-_glthread_DECLARE_STATIC_COND(bmCond);
+pipe_static_mutex(bmMutex);
+pipe_static_condvar(bmCond);
static int kernelReaders = 0;
static int num_buffers = 0;
@@ -241,29 +241,29 @@ static int drmBOResetList(drmBOList *list)
void driWriteLockKernelBO(void)
{
- _glthread_LOCK_MUTEX(bmMutex);
+ pipe_mutex_lock(bmMutex);
while(kernelReaders != 0)
- _glthread_COND_WAIT(bmCond, bmMutex);
+ pipe_condvar_wait(bmCond, bmMutex);
}
void driWriteUnlockKernelBO(void)
{
- _glthread_UNLOCK_MUTEX(bmMutex);
+ pipe_mutex_unlock(bmMutex);
}
void driReadLockKernelBO(void)
{
- _glthread_LOCK_MUTEX(bmMutex);
+ pipe_mutex_lock(bmMutex);
kernelReaders++;
- _glthread_UNLOCK_MUTEX(bmMutex);
+ pipe_mutex_unlock(bmMutex);
}
void driReadUnlockKernelBO(void)
{
- _glthread_LOCK_MUTEX(bmMutex);
+ pipe_mutex_lock(bmMutex);
if (--kernelReaders == 0)
- _glthread_COND_BROADCAST(bmCond);
- _glthread_UNLOCK_MUTEX(bmMutex);
+ pipe_condvar_broadcast(bmCond);
+ pipe_mutex_unlock(bmMutex);
}
@@ -277,7 +277,7 @@ void driReadUnlockKernelBO(void)
typedef struct _DriBufferObject
{
DriBufferPool *pool;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
int refCount;
const char *name;
uint64_t flags;
@@ -318,12 +318,12 @@ driBOKernel(struct _DriBufferObject *buf)
drmBO *ret;
driReadLockKernelBO();
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
assert(buf->private != NULL);
ret = buf->pool->kernel(buf->pool, buf->private);
if (!ret)
BM_CKFATAL(-EINVAL);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
driReadUnlockKernelBO();
return ret;
@@ -338,9 +338,9 @@ driBOWaitIdle(struct _DriBufferObject *buf, int lazy)
* that time??
*/
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
BM_CKFATAL(buf->pool->waitIdle(buf->pool, buf->private, &buf->mutex, lazy));
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
void *
@@ -353,11 +353,11 @@ driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
return buf->userData;
}
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
assert(buf->private != NULL);
retval = buf->pool->map(buf->pool, buf->private, flags, hint,
&buf->mutex, &virtual);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return retval == 0 ? virtual : NULL;
}
@@ -369,9 +369,9 @@ driBOUnmap(struct _DriBufferObject *buf)
return;
assert(buf->private != NULL);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
unsigned long
@@ -381,9 +381,9 @@ driBOOffset(struct _DriBufferObject *buf)
assert(buf->private != NULL);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
ret = buf->pool->offset(buf->pool, buf->private);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return ret;
}
@@ -394,9 +394,9 @@ driBOPoolOffset(struct _DriBufferObject *buf)
assert(buf->private != NULL);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
ret = buf->pool->poolOffset(buf->pool, buf->private);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return ret;
}
@@ -408,9 +408,9 @@ driBOFlags(struct _DriBufferObject *buf)
assert(buf->private != NULL);
driReadLockKernelBO();
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
ret = buf->pool->flags(buf->pool, buf->private);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
driReadUnlockKernelBO();
return ret;
}
@@ -418,12 +418,12 @@ driBOFlags(struct _DriBufferObject *buf)
struct _DriBufferObject *
driBOReference(struct _DriBufferObject *buf)
{
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (++buf->refCount == 1) {
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
BM_CKFATAL(-EINVAL);
}
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return buf;
}
@@ -435,10 +435,10 @@ driBOUnReference(struct _DriBufferObject *buf)
if (!buf)
return;
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
tmp = --buf->refCount;
if (!tmp) {
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
if (buf->private) {
if (buf->createdByReference)
buf->pool->unreference(buf->pool, buf->private);
@@ -451,7 +451,7 @@ driBOUnReference(struct _DriBufferObject *buf)
num_buffers--;
free(buf);
} else
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
@@ -469,7 +469,7 @@ driBOData(struct _DriBufferObject *buf,
assert(!buf->userBuffer); /* XXX just do a memcpy? */
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
pool = buf->pool;
if (pool == NULL && newPool != NULL) {
@@ -556,7 +556,7 @@ driBOData(struct _DriBufferObject *buf,
}
out:
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return retval;
}
@@ -569,7 +569,7 @@ driBOSubData(struct _DriBufferObject *buf,
assert(!buf->userBuffer); /* XXX just do a memcpy? */
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (size && data) {
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
DRM_BO_FLAG_WRITE, 0, &buf->mutex,
@@ -577,7 +577,7 @@ driBOSubData(struct _DriBufferObject *buf,
memcpy((unsigned char *) virtual + offset, data, size);
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
}
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
void
@@ -588,21 +588,21 @@ driBOGetSubData(struct _DriBufferObject *buf,
assert(!buf->userBuffer); /* XXX just do a memcpy? */
- _glthread_LOCK_MUTEX(buf->mutex);
+ 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));
}
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
void
driBOSetReferenced(struct _DriBufferObject *buf,
unsigned long handle)
{
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (buf->private != NULL) {
assert((size_t)"Invalid buffer for setReferenced\n" & 0);
BM_CKFATAL(-EINVAL);
@@ -619,7 +619,7 @@ driBOSetReferenced(struct _DriBufferObject *buf,
}
buf->createdByReference = TRUE;
buf->flags = buf->pool->kernel(buf->pool, buf->private)->flags;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
int
@@ -644,8 +644,8 @@ driGenBuffers(struct _DriBufferPool *pool,
if (!buf)
return -ENOMEM;
- _glthread_INIT_MUTEX(buf->mutex);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_init(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
buf->refCount = 1;
buf->flags = flags;
buf->hint = hint;
@@ -653,7 +653,7 @@ driGenBuffers(struct _DriBufferPool *pool,
buf->alignment = alignment;
buf->pool = pool;
buf->createdByReference = 0;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
buffers[i] = buf;
}
return 0;
@@ -818,7 +818,7 @@ driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
{
int newItem;
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
BM_CKFATAL(driAddValidateItem(&list->drmBuffers,
buf->pool->kernel(buf->pool, buf->private),
flags, mask, itemLoc, node));
@@ -827,7 +827,7 @@ driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
if (newItem)
buf->refCount++;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
drmBOList *driGetdrmBOList(struct _DriBufferList *list)
@@ -845,10 +845,10 @@ void driPutdrmBOList(struct _DriBufferList *list)
void
driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
{
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (buf->pool->fence)
BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence));
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
@@ -908,10 +908,10 @@ driBOValidateUserList(struct _DriBufferList * list)
while (curBuf) {
buf = (struct _DriBufferObject *) drmBOListBuf(curBuf);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (buf->pool->validate)
BM_CKFATAL(buf->pool->validate(buf->pool, buf->private, &buf->mutex));
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
curBuf = drmBOListNext(&list->driBuffers, curBuf);
}
}
@@ -929,9 +929,9 @@ driBOSize(struct _DriBufferObject *buf)
{
unsigned long size;
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
size = buf->pool->size(buf->pool, buf->private);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return size;
diff --git a/src/gallium/winsys/common/intel_drm/ws_dri_bufmgr.h b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h
index e6c0cff..e6c0cff 100644
--- a/src/gallium/winsys/common/intel_drm/ws_dri_bufmgr.h
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h
diff --git a/src/gallium/winsys/common/intel_drm/ws_dri_bufpool.h b/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
index bf60798..ad3b6f3 100644
--- a/src/gallium/winsys/common/intel_drm/ws_dri_bufpool.h
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
@@ -33,14 +33,14 @@
#define _PSB_BUFPOOL_H_
#include <xf86drm.h>
-#include <glthread.h>
+#include "pipe/p_thread.h"
struct _DriFenceObject;
typedef struct _DriBufferPool
{
int fd;
int (*map) (struct _DriBufferPool * pool, void *private,
- unsigned flags, int hint, _glthread_Mutex *mutex,
+ unsigned flags, int hint, pipe_mutex *mutex,
void **virtual);
int (*unmap) (struct _DriBufferPool * pool, void *private);
int (*destroy) (struct _DriBufferPool * pool, void *private);
@@ -55,8 +55,8 @@ typedef struct _DriBufferPool
int (*fence) (struct _DriBufferPool * pool, void *private,
struct _DriFenceObject * fence);
drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
- int (*validate) (struct _DriBufferPool * pool, void *private, _glthread_Mutex *mutex);
- int (*waitIdle) (struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex,
+ 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);
diff --git a/src/gallium/winsys/common/intel_drm/ws_dri_drmpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
index 40929ef..54618b1 100644
--- a/src/gallium/winsys/common/intel_drm/ws_dri_drmpool.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
@@ -113,7 +113,7 @@ pool_unreference(struct _DriBufferPool *pool, void *private)
static int
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, _glthread_Mutex *mutex, void **virtual)
+ int hint, pipe_mutex *mutex, void **virtual)
{
drmBO *buf = (drmBO *) private;
int ret;
@@ -202,7 +202,7 @@ pool_kernel(struct _DriBufferPool *pool, void *private)
}
static int
-pool_waitIdle(struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex,
+pool_waitIdle(struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
int lazy)
{
drmBO *buf = (drmBO *) private;
diff --git a/src/gallium/winsys/common/intel_drm/ws_dri_fencemgr.c b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
index b56bc26..831c75d 100644
--- a/src/gallium/winsys/common/intel_drm/ws_dri_fencemgr.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
@@ -1,5 +1,5 @@
#include "ws_dri_fencemgr.h"
-#include "glthread.h"
+#include "pipe/p_thread.h"
#include <xf86mm.h>
#include <string.h>
#include <unistd.h>
@@ -20,7 +20,7 @@ struct _DriFenceMgr {
/*
* These members are protected by this->mutex
*/
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
int refCount;
drmMMListHead *heads;
int num_fences;
@@ -44,7 +44,7 @@ struct _DriFenceObject {
/*
* These members are protected by this->mutex.
*/
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
uint32_t signaled_type;
void *private;
};
@@ -65,8 +65,8 @@ driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info)
if (!tmp)
return NULL;
- _glthread_INIT_MUTEX(tmp->mutex);
- _glthread_LOCK_MUTEX(tmp->mutex);
+ pipe_mutex_init(tmp->mutex);
+ pipe_mutex_lock(tmp->mutex);
tmp->refCount = 1;
tmp->info = *info;
tmp->num_fences = 0;
@@ -77,7 +77,7 @@ driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info)
for (i=0; i<tmp->info.num_classes; ++i) {
DRMINITLISTHEAD(&tmp->heads[i]);
}
- _glthread_UNLOCK_MUTEX(tmp->mutex);
+ pipe_mutex_unlock(tmp->mutex);
return tmp;
out_err:
@@ -95,13 +95,13 @@ driFenceMgrUnrefUnlock(struct _DriFenceMgr **pMgr)
if (--mgr->refCount == 0)
free(mgr);
else
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
}
void
driFenceMgrUnReference(struct _DriFenceMgr **pMgr)
{
- _glthread_LOCK_MUTEX((*pMgr)->mutex);
+ pipe_mutex_lock((*pMgr)->mutex);
driFenceMgrUnrefUnlock(pMgr);
}
@@ -143,9 +143,9 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
*/
++entry->refCount;
- _glthread_UNLOCK_MUTEX(mgr->mutex);
- _glthread_LOCK_MUTEX(entry->mutex);
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
+ pipe_mutex_lock(entry->mutex);
+ pipe_mutex_lock(mgr->mutex);
prev = list->prev;
@@ -157,7 +157,7 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
* Somebody else removed the entry from the list.
*/
- _glthread_UNLOCK_MUTEX(entry->mutex);
+ pipe_mutex_unlock(entry->mutex);
driFenceUnReferenceLocked(&entry);
return;
}
@@ -167,7 +167,7 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
DRMLISTDELINIT(list);
mgr->info.unreference(mgr, &entry->private);
}
- _glthread_UNLOCK_MUTEX(entry->mutex);
+ pipe_mutex_unlock(entry->mutex);
driFenceUnReferenceLocked(&entry);
list = prev;
}
@@ -181,7 +181,7 @@ driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
struct _DriFenceMgr *mgr = fence->mgr;
int ret = 0;
- _glthread_LOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(fence->mutex);
if ((fence->signaled_type & fence_type) == fence_type)
goto out0;
@@ -190,16 +190,16 @@ driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
if (ret)
goto out0;
- _glthread_LOCK_MUTEX(mgr->mutex);
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(mgr->mutex);
+ pipe_mutex_unlock(fence->mutex);
driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
fence_type);
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
return 0;
out0:
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return ret;
}
@@ -207,9 +207,9 @@ uint32_t driFenceSignaledTypeCached(struct _DriFenceObject *fence)
{
uint32_t ret;
- _glthread_LOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(fence->mutex);
ret = fence->signaled_type;
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return ret;
}
@@ -221,7 +221,7 @@ driFenceSignaledType(struct _DriFenceObject *fence, uint32_t flush_type,
int ret = 0;
struct _DriFenceMgr *mgr;
- _glthread_LOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(fence->mutex);
mgr = fence->mgr;
*signaled = fence->signaled_type;
if ((fence->signaled_type & flush_type) == flush_type)
@@ -236,25 +236,25 @@ driFenceSignaledType(struct _DriFenceObject *fence, uint32_t flush_type,
if ((fence->signaled_type | *signaled) == fence->signaled_type)
goto out0;
- _glthread_LOCK_MUTEX(mgr->mutex);
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(mgr->mutex);
+ pipe_mutex_unlock(fence->mutex);
driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
*signaled);
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
return 0;
out0:
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return ret;
}
struct _DriFenceObject *
driFenceReference(struct _DriFenceObject *fence)
{
- _glthread_LOCK_MUTEX(fence->mgr->mutex);
+ pipe_mutex_lock(fence->mgr->mutex);
++fence->refCount;
- _glthread_UNLOCK_MUTEX(fence->mgr->mutex);
+ pipe_mutex_unlock(fence->mgr->mutex);
return fence;
}
@@ -267,7 +267,7 @@ driFenceUnReference(struct _DriFenceObject **pFence)
return;
mgr = (*pFence)->mgr;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
++mgr->refCount;
driFenceUnReferenceLocked(pFence);
driFenceMgrUnrefUnlock(&mgr);
@@ -294,15 +294,15 @@ struct _DriFenceObject
return NULL;
}
- _glthread_INIT_MUTEX(fence->mutex);
- _glthread_LOCK_MUTEX(fence->mutex);
- _glthread_LOCK_MUTEX(mgr->mutex);
+ 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;
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
fence->fence_class = fence_class;
fence->fence_type = fence_type;
fence->signaled_type = 0;
@@ -312,7 +312,7 @@ struct _DriFenceObject
memcpy(fence->private, private, private_size);
}
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return fence;
}
diff --git a/src/gallium/winsys/common/intel_drm/ws_dri_fencemgr.h b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h
index 4ea58df..4ea58df 100644
--- a/src/gallium/winsys/common/intel_drm/ws_dri_fencemgr.h
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h
diff --git a/src/gallium/winsys/common/intel_drm/ws_dri_mallocpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
index a80555c..60924ea 100644
--- a/src/gallium/winsys/common/intel_drm/ws_dri_mallocpool.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
@@ -33,7 +33,7 @@
#include <stdlib.h>
#include <errno.h>
#include "pipe/p_debug.h"
-#include "glthread.h"
+#include "pipe/p_thread.h"
#include "ws_dri_bufpool.h"
#include "ws_dri_bufmgr.h"
@@ -60,14 +60,14 @@ pool_destroy(struct _DriBufferPool *pool, void *private)
static int
pool_waitIdle(struct _DriBufferPool *pool, void *private,
- _glthread_Mutex *mutex, int lazy)
+ pipe_mutex *mutex, int lazy)
{
return 0;
}
static int
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, _glthread_Mutex *mutex, void **virtual)
+ int hint, pipe_mutex *mutex, void **virtual)
{
*virtual = (void *)((unsigned long *)private + 2);
return 0;
diff --git a/src/gallium/winsys/common/intel_drm/ws_dri_slabpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
index dfcf6d6..391cea5 100644
--- a/src/gallium/winsys/common/intel_drm/ws_dri_slabpool.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
@@ -37,7 +37,7 @@
#include "ws_dri_bufpool.h"
#include "ws_dri_fencemgr.h"
#include "ws_dri_bufmgr.h"
-#include "glthread.h"
+#include "pipe/p_thread.h"
#define DRI_SLABPOOL_ALLOC_RETRIES 100
@@ -53,7 +53,7 @@ struct _DriSlabBuffer {
uint32_t start;
uint32_t fenceType;
int unFenced;
- _glthread_Cond event;
+ pipe_condvar event;
};
struct _DriKernelBO {
@@ -84,7 +84,7 @@ struct _DriSlabSizeHeader {
uint32_t numDelayed;
struct _DriSlabPool *slabPool;
uint32_t bufSize;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
};
struct _DriFreeSlabManager {
@@ -94,7 +94,7 @@ struct _DriFreeSlabManager {
drmMMListHead timeoutList;
drmMMListHead unCached;
drmMMListHead cached;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
};
@@ -196,7 +196,7 @@ driSetKernelBOFree(struct _DriFreeSlabManager *fMan,
{
struct timeval time;
- _glthread_LOCK_MUTEX(fMan->mutex);
+ pipe_mutex_lock(fMan->mutex);
gettimeofday(&time, NULL);
driTimeAdd(&time, &fMan->slabTimeout);
@@ -210,7 +210,7 @@ driSetKernelBOFree(struct _DriFreeSlabManager *fMan,
DRMLISTADDTAIL(&kbo->timeoutHead, &fMan->timeoutList);
driFreeTimeoutKBOsLocked(fMan, &time);
- _glthread_UNLOCK_MUTEX(fMan->mutex);
+ pipe_mutex_unlock(fMan->mutex);
}
/*
@@ -237,7 +237,7 @@ driAllocKernelBO(struct _DriSlabSizeHeader *header)
size = (size <= slabPool->maxSlabSize) ? size : slabPool->maxSlabSize;
size = (size + slabPool->pageSize - 1) & ~(slabPool->pageSize - 1);
- _glthread_LOCK_MUTEX(fMan->mutex);
+ pipe_mutex_lock(fMan->mutex);
kbo = NULL;
@@ -269,7 +269,7 @@ driAllocKernelBO(struct _DriSlabSizeHeader *header)
DRMLISTDELINIT(&kbo->timeoutHead);
}
- _glthread_UNLOCK_MUTEX(fMan->mutex);
+ pipe_mutex_unlock(fMan->mutex);
if (kbo) {
uint64_t new_mask = kbo->bo.proposedFlags ^ slabPool->proposedFlags;
@@ -360,7 +360,7 @@ driAllocSlab(struct _DriSlabSizeHeader *header)
buf->start = i* header->bufSize;
buf->mapCount = 0;
buf->isSlabBuffer = 1;
- _glthread_INIT_COND(buf->event);
+ pipe_condvar_init(buf->event);
DRMLISTADDTAIL(&buf->head, &slab->freeBuffers);
slab->numFree++;
buf++;
@@ -494,23 +494,23 @@ driSlabAllocBuffer(struct _DriSlabSizeHeader *header)
drmMMListHead *list;
int count = DRI_SLABPOOL_ALLOC_RETRIES;
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
while(header->slabs.next == &header->slabs && count > 0) {
driSlabCheckFreeLocked(header, 0);
if (header->slabs.next != &header->slabs)
break;
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
if (count != DRI_SLABPOOL_ALLOC_RETRIES)
usleep(1);
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
(void) driAllocSlab(header);
count--;
}
list = header->slabs.next;
if (list == &header->slabs) {
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
return NULL;
}
slab = DRMLISTENTRY(struct _DriSlab, list, head);
@@ -520,7 +520,7 @@ driSlabAllocBuffer(struct _DriSlabSizeHeader *header)
list = slab->freeBuffers.next;
DRMLISTDELINIT(list);
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
return buf;
}
@@ -618,7 +618,7 @@ pool_destroy(struct _DriBufferPool *driPool, void *private)
slab = buf->parent;
header = slab->header;
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
buf->unFenced = 0;
buf->mapCount = 0;
@@ -631,18 +631,18 @@ pool_destroy(struct _DriBufferPool *driPool, void *private)
driSlabFreeBufferLocked(buf);
}
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
return 0;
}
static int
pool_waitIdle(struct _DriBufferPool *driPool, void *private,
- _glthread_Mutex *mutex, int lazy)
+ pipe_mutex *mutex, int lazy)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
while(buf->unFenced)
- _glthread_COND_WAIT(buf->event, *mutex);
+ pipe_condvar_wait(buf->event, *mutex);
if (!buf->fence)
return 0;
@@ -655,7 +655,7 @@ pool_waitIdle(struct _DriBufferPool *driPool, void *private,
static int
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, _glthread_Mutex *mutex, void **virtual)
+ int hint, pipe_mutex *mutex, void **virtual)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
int busy;
@@ -689,7 +689,7 @@ pool_unmap(struct _DriBufferPool *pool, void *private)
--buf->mapCount;
if (buf->mapCount == 0 && buf->isSlabBuffer)
- _glthread_COND_BROADCAST(buf->event);
+ pipe_condvar_broadcast(buf->event);
return 0;
}
@@ -760,7 +760,7 @@ pool_fence(struct _DriBufferPool *pool, void *private,
buf->fenceType = bo->fenceFlags;
buf->unFenced = 0;
- _glthread_COND_BROADCAST(buf->event);
+ pipe_condvar_broadcast(buf->event);
return 0;
}
@@ -775,7 +775,7 @@ pool_kernel(struct _DriBufferPool *pool, void *private)
static int
pool_validate(struct _DriBufferPool *pool, void *private,
- _glthread_Mutex *mutex)
+ pipe_mutex *mutex)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
@@ -783,7 +783,7 @@ pool_validate(struct _DriBufferPool *pool, void *private,
return 0;
while(buf->mapCount != 0)
- _glthread_COND_WAIT(buf->event, *mutex);
+ pipe_condvar_wait(buf->event, *mutex);
buf->unFenced = 1;
return 0;
@@ -799,8 +799,8 @@ driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec)
if (!tmp)
return NULL;
- _glthread_INIT_MUTEX(tmp->mutex);
- _glthread_LOCK_MUTEX(tmp->mutex);
+ 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;
@@ -814,7 +814,7 @@ driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec)
DRMINITLISTHEAD(&tmp->timeoutList);
DRMINITLISTHEAD(&tmp->unCached);
DRMINITLISTHEAD(&tmp->cached);
- _glthread_UNLOCK_MUTEX(tmp->mutex);
+ pipe_mutex_unlock(tmp->mutex);
return tmp;
}
@@ -827,9 +827,9 @@ driFinishFreeSlabManager(struct _DriFreeSlabManager *fMan)
time = fMan->nextCheck;
driTimeAdd(&time, &fMan->checkInterval);
- _glthread_LOCK_MUTEX(fMan->mutex);
+ pipe_mutex_lock(fMan->mutex);
driFreeTimeoutKBOsLocked(fMan, &time);
- _glthread_UNLOCK_MUTEX(fMan->mutex);
+ pipe_mutex_unlock(fMan->mutex);
assert(fMan->timeoutList.next == &fMan->timeoutList);
assert(fMan->unCached.next == &fMan->unCached);
@@ -842,8 +842,8 @@ static void
driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
struct _DriSlabSizeHeader *header)
{
- _glthread_INIT_MUTEX(header->mutex);
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_init(header->mutex);
+ pipe_mutex_lock(header->mutex);
DRMINITLISTHEAD(&header->slabs);
DRMINITLISTHEAD(&header->freeSlabs);
@@ -853,7 +853,7 @@ driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
header->slabPool = pool;
header->bufSize = size;
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
}
static void
@@ -862,7 +862,7 @@ driFinishSizeHeader(struct _DriSlabSizeHeader *header)
drmMMListHead *list, *next;
struct _DriSlabBuffer *buf;
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
for (list = header->delayedBuffers.next, next = list->next;
list != &header->delayedBuffers;
list = next, next = list->next) {
@@ -875,7 +875,7 @@ driFinishSizeHeader(struct _DriSlabSizeHeader *header)
header->numDelayed--;
driSlabFreeBufferLocked(buf);
}
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
}
static void
diff --git a/src/gallium/winsys/dri/intel/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile
index e0716ea..2046441 100644
--- a/src/gallium/winsys/dri/intel/Makefile
+++ b/src/gallium/winsys/drm/intel/dri/Makefile
@@ -1,5 +1,4 @@
-
-TOP = ../../../../..
+TOP = ../../../../../..
include $(TOP)/configs/current
LIBNAME = i915_dri.so
@@ -7,7 +6,7 @@ LIBNAME_EGL = egl_i915_dri.so
PIPE_DRIVERS = \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/winsys/common/intel_drm/libinteldrm.a \
+ ../common/libinteldrm.a \
$(TOP)/src/gallium/drivers/i915simple/libi915simple.a
@@ -24,10 +23,10 @@ C_SOURCES = \
ASM_SOURCES =
-DRIVER_DEFINES = -I$(TOP)/src/mesa/drivers/dri/intel $(shell pkg-config libdrm --atleast-version=2.3.1 \
+DRIVER_DEFINES = -I../common $(shell pkg-config libdrm --atleast-version=2.3.1 \
&& echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-include ../Makefile.template
+include ../../Makefile.template
#intel_tex_layout.o: $(TOP)/src/mesa/drivers/dri/intel/intel_tex_layout.c
diff --git a/src/gallium/winsys/dri/intel/SConscript b/src/gallium/winsys/drm/intel/dri/SConscript
index 6a4f50a..6a4f50a 100644
--- a/src/gallium/winsys/dri/intel/SConscript
+++ b/src/gallium/winsys/drm/intel/dri/SConscript
diff --git a/src/gallium/winsys/egl_drm/intel/intel_batchbuffer.h b/src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h
index 1fa2719..3e95326 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_batchbuffer.h
+++ b/src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h
@@ -1,7 +1,7 @@
#ifndef INTEL_BATCHBUFFER_H
#define INTEL_BATCHBUFFER_H
-#include "intel_drm/intel_be_batchbuffer.h"
+#include "intel_be_batchbuffer.h"
/*
* Need to redefine the BATCH defines
diff --git a/src/gallium/winsys/dri/intel/intel_context.c b/src/gallium/winsys/drm/intel/dri/intel_context.c
index 97ef731..97ef731 100644
--- a/src/gallium/winsys/dri/intel/intel_context.c
+++ b/src/gallium/winsys/drm/intel/dri/intel_context.c
diff --git a/src/gallium/winsys/dri/intel/intel_context.h b/src/gallium/winsys/drm/intel/dri/intel_context.h
index ced18da..5d22a42 100644
--- a/src/gallium/winsys/dri/intel/intel_context.h
+++ b/src/gallium/winsys/drm/intel/dri/intel_context.h
@@ -36,7 +36,7 @@
#include "intel_screen.h"
#include "i915_drm.h"
-#include "intel_drm/intel_be_context.h"
+#include "intel_be_context.h"
struct pipe_context;
diff --git a/src/gallium/winsys/dri/intel/intel_lock.c b/src/gallium/winsys/drm/intel/dri/intel_lock.c
index 406284c..ad1c202 100644
--- a/src/gallium/winsys/dri/intel/intel_lock.c
+++ b/src/gallium/winsys/drm/intel/dri/intel_lock.c
@@ -27,7 +27,7 @@
#include "main/glheader.h"
-#include "glapi/glthread.h"
+#include "pipe/p_thread.h"
#include <GL/internal/glcore.h>
#include "state_tracker/st_public.h"
#include "intel_context.h"
@@ -35,7 +35,7 @@
-_glthread_DECLARE_STATIC_MUTEX( lockMutex );
+pipe_static_mutex( lockMutex );
static void
@@ -72,7 +72,7 @@ void LOCK_HARDWARE( struct intel_context *intel )
{
char __ret = 0;
- _glthread_LOCK_MUTEX(lockMutex);
+ pipe_mutex_lock(lockMutex);
assert(!intel->locked);
DRM_CAS(intel->driHwLock, intel->hHWContext,
@@ -96,7 +96,7 @@ void UNLOCK_HARDWARE( struct intel_context *intel )
DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
- _glthread_UNLOCK_MUTEX(lockMutex);
+ pipe_mutex_unlock(lockMutex);
DBG(LOCK, "%s - unlocked\n", __progname);
}
diff --git a/src/gallium/winsys/dri/intel/intel_reg.h b/src/gallium/winsys/drm/intel/dri/intel_reg.h
index 4f33bee..4f33bee 100644
--- a/src/gallium/winsys/dri/intel/intel_reg.h
+++ b/src/gallium/winsys/drm/intel/dri/intel_reg.h
diff --git a/src/gallium/winsys/dri/intel/intel_screen.c b/src/gallium/winsys/drm/intel/dri/intel_screen.c
index b3022fd..3a48648 100644
--- a/src/gallium/winsys/dri/intel/intel_screen.c
+++ b/src/gallium/winsys/drm/intel/dri/intel_screen.c
@@ -35,7 +35,7 @@
#include "intel_swapbuffers.h"
#include "i830_dri.h"
-#include "intel_drm/ws_dri_bufpool.h"
+#include "ws_dri_bufpool.h"
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
@@ -83,7 +83,7 @@ intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys,
buffer);
/* Unref the buffer we don't need it anyways */
- pipe_buffer_reference(screen->winsys, &buffer, NULL);
+ pipe_buffer_reference(screen, &buffer, NULL);
surface = screen->get_tex_surface(screen,
texture,
diff --git a/src/gallium/winsys/dri/intel/intel_screen.h b/src/gallium/winsys/drm/intel/dri/intel_screen.h
index e62f9e7..0bb43a9 100644
--- a/src/gallium/winsys/dri/intel/intel_screen.h
+++ b/src/gallium/winsys/drm/intel/dri/intel_screen.h
@@ -31,11 +31,11 @@
#include "dri_util.h"
#include "i830_common.h"
#include "xmlconfig.h"
-#include "intel_drm/ws_dri_bufpool.h"
+#include "ws_dri_bufpool.h"
#include "pipe/p_compiler.h"
-#include "intel_drm/intel_be_device.h"
+#include "intel_be_device.h"
struct intel_screen
{
diff --git a/src/gallium/winsys/dri/intel/intel_swapbuffers.c b/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c
index f751f97..8a18bfd 100644
--- a/src/gallium/winsys/dri/intel/intel_swapbuffers.c
+++ b/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c
@@ -36,7 +36,7 @@
#include "state_tracker/st_context.h"
#include "state_tracker/st_cb_fbo.h"
-#include "intel_drm/ws_dri_bufmgr.h"
+#include "ws_dri_bufmgr.h"
#include "intel_batchbuffer.h"
/**
diff --git a/src/gallium/winsys/dri/intel/intel_swapbuffers.h b/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h
index 46c9bab..46c9bab 100644
--- a/src/gallium/winsys/dri/intel/intel_swapbuffers.h
+++ b/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h
diff --git a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c b/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c
index 0d98d16..20920a2 100644
--- a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c
+++ b/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c
@@ -32,8 +32,8 @@
#include "intel_context.h"
#include "intel_winsys_softpipe.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "pipe/p_format.h"
+#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
diff --git a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.h b/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h
index 5fa14cb..5fa14cb 100644
--- a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.h
+++ b/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h
diff --git a/src/gallium/winsys/dri/intel/server/i830_common.h b/src/gallium/winsys/drm/intel/dri/server/i830_common.h
index 3452ddb..3452ddb 100644
--- a/src/gallium/winsys/dri/intel/server/i830_common.h
+++ b/src/gallium/winsys/drm/intel/dri/server/i830_common.h
diff --git a/src/gallium/winsys/dri/intel/server/i830_dri.h b/src/gallium/winsys/drm/intel/dri/server/i830_dri.h
index 0d514b6..0d514b6 100644
--- a/src/gallium/winsys/dri/intel/server/i830_dri.h
+++ b/src/gallium/winsys/drm/intel/dri/server/i830_dri.h
diff --git a/src/gallium/winsys/egl_drm/intel/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile
index e67b49f..f0b5a44 100644
--- a/src/gallium/winsys/egl_drm/intel/Makefile
+++ b/src/gallium/winsys/drm/intel/egl/Makefile
@@ -1,5 +1,4 @@
-
-TOP = ../../../../..
+TOP = ../../../../../..
include $(TOP)/configs/current
LIBNAME = EGL_i915.so
@@ -7,7 +6,7 @@ LIBNAME = EGL_i915.so
PIPE_DRIVERS = \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
$(TOP)/src/gallium/drivers/i915simple/libi915simple.a \
- $(TOP)/src/gallium/winsys/common/intel_drm/libinteldrm.a
+ ../common/libinteldrm.a
DRIVER_SOURCES = \
intel_swapbuffers.c \
@@ -21,9 +20,9 @@ C_SOURCES = \
ASM_SOURCES =
-DRIVER_DEFINES = -I$(TOP)/src/mesa/drivers/dri/intel $(shell pkg-config libdrm --atleast-version=2.3.1 \
+DRIVER_DEFINES = -I../common $(shell pkg-config libdrm --atleast-version=2.3.1 \
&& echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-include ../Makefile.template
+include ../../Makefile.template
symlinks:
diff --git a/src/gallium/winsys/egl_drm/intel/SConscript b/src/gallium/winsys/drm/intel/egl/SConscript
index 0ad19d4..0ad19d4 100644
--- a/src/gallium/winsys/egl_drm/intel/SConscript
+++ b/src/gallium/winsys/drm/intel/egl/SConscript
diff --git a/src/gallium/winsys/dri/intel/intel_batchbuffer.h b/src/gallium/winsys/drm/intel/egl/intel_batchbuffer.h
index 1fa2719..3e95326 100644
--- a/src/gallium/winsys/dri/intel/intel_batchbuffer.h
+++ b/src/gallium/winsys/drm/intel/egl/intel_batchbuffer.h
@@ -1,7 +1,7 @@
#ifndef INTEL_BATCHBUFFER_H
#define INTEL_BATCHBUFFER_H
-#include "intel_drm/intel_be_batchbuffer.h"
+#include "intel_be_batchbuffer.h"
/*
* Need to redefine the BATCH defines
diff --git a/src/gallium/winsys/egl_drm/intel/intel_context.c b/src/gallium/winsys/drm/intel/egl/intel_context.c
index 927addb..927addb 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_context.c
+++ b/src/gallium/winsys/drm/intel/egl/intel_context.c
diff --git a/src/gallium/winsys/egl_drm/intel/intel_context.h b/src/gallium/winsys/drm/intel/egl/intel_context.h
index dfa4720..477fdec 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_context.h
+++ b/src/gallium/winsys/drm/intel/egl/intel_context.h
@@ -29,7 +29,7 @@
#define INTEL_CONTEXT_H
#include "pipe/p_debug.h"
-#include "intel_drm/intel_be_context.h"
+#include "intel_be_context.h"
struct st_context;
diff --git a/src/gallium/winsys/egl_drm/intel/intel_device.c b/src/gallium/winsys/drm/intel/egl/intel_device.c
index b9649cb..b9649cb 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_device.c
+++ b/src/gallium/winsys/drm/intel/egl/intel_device.c
diff --git a/src/gallium/winsys/egl_drm/intel/intel_device.h b/src/gallium/winsys/drm/intel/egl/intel_device.h
index 2f9d4f8..323a7c2 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_device.h
+++ b/src/gallium/winsys/drm/intel/egl/intel_device.h
@@ -28,7 +28,7 @@
#ifndef _INTEL_SCREEN_H_
#define _INTEL_SCREEN_H_
-#include "intel_drm/intel_be_device.h"
+#include "intel_be_device.h"
#include "pipe/p_compiler.h"
diff --git a/src/gallium/winsys/egl_drm/intel/intel_egl.c b/src/gallium/winsys/drm/intel/egl/intel_egl.c
index 55f4d92..3204ed3 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_egl.c
+++ b/src/gallium/winsys/drm/intel/egl/intel_egl.c
@@ -66,7 +66,67 @@ egl_drm_create_device(int drmFD)
return device;
}
-__GLcontextModes* _gl_context_modes_create( unsigned count, size_t minimum_size );
+static void
+_egl_context_modes_destroy(__GLcontextModes *modes)
+{
+ _eglLog(_EGL_DEBUG, "%s", __FUNCTION__);
+
+ while (modes) {
+ __GLcontextModes * const next = modes->next;
+ free(modes);
+ modes = next;
+ }
+}
+/**
+ * Create a linked list of 'count' GLcontextModes.
+ * These are used during the client/server visual negotiation phase,
+ * then discarded.
+ */
+static __GLcontextModes *
+_egl_context_modes_create(unsigned count, size_t minimum_size)
+{
+ /* This code copied from libGLX, and modified */
+ const size_t size = (minimum_size > sizeof(__GLcontextModes))
+ ? minimum_size : sizeof(__GLcontextModes);
+ __GLcontextModes * head = NULL;
+ __GLcontextModes ** next;
+ unsigned i;
+
+ _eglLog(_EGL_DEBUG, "%s %d %d", __FUNCTION__, count, minimum_size);
+
+ next = & head;
+ for (i = 0 ; i < count ; i++) {
+ *next = (__GLcontextModes *) calloc(1, size);
+ if (*next == NULL) {
+ _egl_context_modes_destroy(head);
+ head = NULL;
+ break;
+ }
+
+ (*next)->doubleBufferMode = 1;
+ (*next)->visualID = GLX_DONT_CARE;
+ (*next)->visualType = GLX_DONT_CARE;
+ (*next)->visualRating = GLX_NONE;
+ (*next)->transparentPixel = GLX_NONE;
+ (*next)->transparentRed = GLX_DONT_CARE;
+ (*next)->transparentGreen = GLX_DONT_CARE;
+ (*next)->transparentBlue = GLX_DONT_CARE;
+ (*next)->transparentAlpha = GLX_DONT_CARE;
+ (*next)->transparentIndex = GLX_DONT_CARE;
+ (*next)->xRenderable = GLX_DONT_CARE;
+ (*next)->fbconfigID = GLX_DONT_CARE;
+ (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML;
+ (*next)->bindToTextureRgb = GLX_DONT_CARE;
+ (*next)->bindToTextureRgba = GLX_DONT_CARE;
+ (*next)->bindToMipmapTexture = GLX_DONT_CARE;
+ (*next)->bindToTextureTargets = 0;
+ (*next)->yInverted = GLX_DONT_CARE;
+
+ next = & ((*next)->next);
+ }
+
+ return head;
+}
struct drm_screen;
@@ -102,7 +162,6 @@ struct drm_screen
/* currently only support one connector */
drmModeConnectorPtr connector;
- uint32_t connectorID;
/* Has this screen been shown */
int shown;
@@ -190,7 +249,6 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
screen = malloc(sizeof(struct drm_screen));
memset(screen, 0, sizeof(*screen));
- screen->connectorID = res->connectors[i];
screen->connector = connector;
_eglInitScreen(&screen->base);
_eglAddScreen(disp, &screen->base);
@@ -225,17 +283,20 @@ static void
drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen)
{
struct drm_driver *drm_drv = (struct drm_driver *)drv;
+ unsigned int i;
intel_bind_frontbuffer(screen->surf->drawable, NULL);
screen->surf = NULL;
- drmModeSetCrtc(
- drm_drv->device->drmFD,
- drm_drv->res->crtcs[1],
- 0, // FD
- 0, 0,
- NULL, 0, // List of output ids
- NULL);
+ for (i = 0; i < drm_drv->res->count_crtcs; i++) {
+ drmModeSetCrtc(
+ drm_drv->device->drmFD,
+ drm_drv->res->crtcs[i],
+ 0, // FD
+ 0, 0,
+ NULL, 0, // List of output ids
+ NULL);
+ }
drmModeRmFB(drm_drv->device->drmFD, screen->fbID);
drmModeFreeFB(screen->fb);
@@ -306,7 +367,7 @@ visual_from_config(_EGLConfig *conf)
__GLcontextModes *visual;
(void)conf;
- visual = _gl_context_modes_create(1, sizeof(*visual));
+ visual = _egl_context_modes_create(1, sizeof(*visual));
visual->redBits = 8;
visual->greenBits = 8;
visual->blueBits = 8;
@@ -510,7 +571,7 @@ drm_find_mode(drmModeConnectorPtr connector, _EGLMode *mode)
m = &connector->modes[i];
if (m->hdisplay == mode->Width && m->vdisplay == mode->Height && m->vrefresh == mode->RefreshRate)
break;
- m = NULL;
+ m = &connector->modes[0]; /* if we can't find one, return first */
}
return m;
@@ -560,9 +621,10 @@ drm_show_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy,
struct drm_surface *surf = lookup_drm_surface(surface);
struct drm_screen *scrn = lookup_drm_screen(dpy, screen);
_EGLMode *mode = _eglLookupMode(dpy, m);
- size_t pitch = 2048 * 4;
+ size_t pitch = mode->Width * 4;
size_t size = mode->Height * pitch;
int ret;
+ unsigned int i,j,k;
if (scrn->shown)
drm_takedown_shown_screen(drv, scrn);
@@ -592,18 +654,29 @@ drm_show_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy,
if (!scrn->fb)
goto err_bo;
- scrn->mode = drm_find_mode(scrn->connector, mode);
- if (!scrn->mode)
- goto err_fb;
-
- ret = drmModeSetCrtc(
- drm_drv->device->drmFD,
- drm_drv->res->crtcs[1],
- scrn->fbID,
- 0, 0,
- &scrn->connectorID, 1,
- scrn->mode);
-
+ for (j = 0; j < drm_drv->res->count_connectors; j++) {
+ drmModeConnector *con = drmModeGetConnector(drm_drv->device->drmFD, drm_drv->res->connectors[j]);
+ scrn->mode = drm_find_mode(con, mode);
+ if (!scrn->mode)
+ goto err_fb;
+
+ for (k = 0; k < con->count_encoders; k++) {
+ drmModeEncoder *enc = drmModeGetEncoder(drm_drv->device->drmFD, con->encoders[k]);
+ for (i = 0; i < drm_drv->res->count_crtcs; i++) {
+ if (enc->possible_crtcs & (1<<i)) {
+ ret = drmModeSetCrtc(
+ drm_drv->device->drmFD,
+ drm_drv->res->crtcs[i],
+ scrn->fbID,
+ 0, 0,
+ &drm_drv->res->connectors[j], 1,
+ scrn->mode);
+ /* skip the other crtcs now */
+ i = drm_drv->res->count_crtcs;
+ }
+ }
+ }
+ }
scrn->front.handle = scrn->buffer.handle;
scrn->front.pitch = pitch;
diff --git a/src/gallium/winsys/egl_drm/intel/intel_egl.h b/src/gallium/winsys/drm/intel/egl/intel_egl.h
index 1ee27e0..1ee27e0 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_egl.h
+++ b/src/gallium/winsys/drm/intel/egl/intel_egl.h
diff --git a/src/gallium/winsys/egl_drm/intel/intel_reg.h b/src/gallium/winsys/drm/intel/egl/intel_reg.h
index 4f33bee..4f33bee 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_reg.h
+++ b/src/gallium/winsys/drm/intel/egl/intel_reg.h
diff --git a/src/gallium/winsys/egl_drm/intel/intel_swapbuffers.c b/src/gallium/winsys/drm/intel/egl/intel_swapbuffers.c
index 2edcbc7..2edcbc7 100644
--- a/src/gallium/winsys/egl_drm/intel/intel_swapbuffers.c
+++ b/src/gallium/winsys/drm/intel/egl/intel_swapbuffers.c
diff --git a/src/gallium/winsys/egl_drm/Makefile b/src/gallium/winsys/egl_drm/Makefile
deleted file mode 100644
index 4139d9e..0000000
--- a/src/gallium/winsys/egl_drm/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-# src/mesa/drivers/egl_drm/Makefile
-
-TOP = ../../../..
-
-include $(TOP)/configs/current
-
-
-
-default: $(TOP)/$(LIB_DIR) subdirs
-
-
-$(TOP)/$(LIB_DIR):
- -mkdir $(TOP)/$(LIB_DIR)
-
-
-subdirs:
- @for dir in $(DRI_DIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
- fi \
- done
-
-
-install:
- @for dir in $(DRI_DIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) install) || exit 1 ; \
- fi \
- done
-
-
-clean:
- @for dir in $(DRI_DIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) clean) ; \
- fi \
- done
- -rm -f common/*.o
diff --git a/src/gallium/winsys/egl_drm/Makefile.template b/src/gallium/winsys/egl_drm/Makefile.template
deleted file mode 100644
index 07abfa5..0000000
--- a/src/gallium/winsys/egl_drm/Makefile.template
+++ /dev/null
@@ -1,117 +0,0 @@
-# -*-makefile-*-
-
-MESA_MODULES = \
- $(TOP)/src/mesa/libmesa.a \
- $(GALLIUM_AUXILIARIES)
-
-COMMON_GALLIUM_SOURCES = \
- $(TOP)/src/mesa/drivers/dri/common/utils.c \
- $(TOP)/src/mesa/drivers/dri/common/vblank.c \
- $(TOP)/src/mesa/drivers/dri/common/dri_util.c \
- $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c
-
-COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \
- $(TOP)/src/mesa/drivers/common/driverfuncs.c \
- $(TOP)/src/mesa/drivers/dri/common/texmem.c \
- $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c
-
-COMMON_BM_SOURCES = \
- $(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \
- $(TOP)/src/mesa/drivers/dri/common/dri_drmpool.c
-
-
-ifeq ($(WINDOW_SYSTEM),dri)
-WINOBJ=
-WINLIB=
-INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES)
-
-OBJECTS = \
- $(C_SOURCES:.c=.o) \
- $(ASM_SOURCES:.S=.o)
-
-else
-# miniglx
-WINOBJ=
-WINLIB=-L$(MESA)/src/glx/mini
-MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini
-INCLUDES = $(MINIGLX_INCLUDES) \
- $(SHARED_INCLUDES) \
- $(PCIACCESS_CFLAGS)
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(MINIGLX_SOURCES:.c=.o) \
- $(ASM_SOURCES:.S=.o)
-endif
-
-
-### Include directories
-SHARED_INCLUDES = \
- -I. \
- -I$(TOP)/src/mesa/drivers/dri/common \
- -Iserver \
- -I$(TOP)/include \
- -I$(TOP)/include/GL/internal \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/winsys/common \
- -I$(TOP)/src/mesa \
- -I$(TOP)/src/mesa/main \
- -I$(TOP)/src/mesa/glapi \
- -I$(TOP)/src/mesa/math \
- -I$(TOP)/src/mesa/transform \
- -I$(TOP)/src/mesa/shader \
- -I$(TOP)/src/mesa/swrast \
- -I$(TOP)/src/mesa/swrast_setup \
- -I$(TOP)/src/egl/main \
- -I$(TOP)/src/egl/drivers/dri \
- $(LIBDRM_CFLAGS)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
-
-
-$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
- $(TOP)/bin/mklib -noprefix -o $@ \
- $(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
-
-
-$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
- $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)
-
-
-depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean:
- -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
-
-
-install: $(LIBNAME)
- $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
- $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
-
-
-include depend
diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c
index 829732e..e9f821d 100644
--- a/src/gallium/winsys/egl_xlib/egl_xlib.c
+++ b/src/gallium/winsys/egl_xlib/egl_xlib.c
@@ -38,8 +38,8 @@
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
#include "eglconfig.h"
diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c
index f4199e6..2fd190d 100644
--- a/src/gallium/winsys/egl_xlib/sw_winsys.c
+++ b/src/gallium/winsys/egl_xlib/sw_winsys.c
@@ -37,8 +37,9 @@
#include "pipe/p_winsys.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sw_winsys.h"
@@ -215,7 +216,7 @@ surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
diff --git a/src/gallium/winsys/gdi/wmesa.c b/src/gallium/winsys/gdi/wmesa.c
index 86b085a..ed3dd2b 100644
--- a/src/gallium/winsys/gdi/wmesa.c
+++ b/src/gallium/winsys/gdi/wmesa.c
@@ -12,8 +12,8 @@
#include "pipe/p_winsys.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
#include "glapi/glapi.h"
#include "colors.h"
@@ -118,48 +118,6 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC)
}
}
-
-/**
- * Create DIB for back buffer.
- * We write into this memory with the span routines and then blit it
- * to the window on a buffer swap.
- */
-BOOL wmCreateBackingStore(WMesaFramebuffer pwfb, long lxSize, long lySize)
-{
- HDC hdc = pwfb->hDC;
- BITMAPINFO bmi;
- LPBITMAPINFO pbmi = &bmi;
- HDC hic;
-
- pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- pbmi->bmiHeader.biWidth = lxSize;
- pbmi->bmiHeader.biHeight= -lySize;
- pbmi->bmiHeader.biPlanes = 1;
- pbmi->bmiHeader.biBitCount = pwfb->cColorBits;
- pbmi->bmiHeader.biCompression = BI_RGB;
- pbmi->bmiHeader.biSizeImage = 0;
- pbmi->bmiHeader.biXPelsPerMeter = 0;
- pbmi->bmiHeader.biYPelsPerMeter = 0;
- pbmi->bmiHeader.biClrUsed = 0;
- pbmi->bmiHeader.biClrImportant = 0;
-
- hic = CreateIC("display", NULL, NULL, NULL);
- pwfb->dib_hDC = CreateCompatibleDC(hic);
-
- pwfb->hbmDIB = CreateDIBSection(hic,
- pbmi,
- DIB_RGB_COLORS,
- (void **)&(pwfb->pbPixels),
- 0,
- 0);
- pwfb->hOldBitmap = SelectObject(pwfb->dib_hDC, pwfb->hbmDIB);
-
- DeleteDC(hic);
-
- wmSetPixelFormat(pwfb, pwfb->hDC);
- return TRUE;
-}
-
/**
* Create a new WMesaFramebuffer object which will correspond to the
* given HDC (Window handle).
@@ -201,10 +159,6 @@ wmesa_new_framebuffer(HDC hdc, GLvisual *visual, GLuint width, GLuint height)
pwfb->cColorBits = GetDeviceCaps(hdc, BITSPIXEL);
-#if 0
- wmCreateBackingStore(pwfb, width, height);
-#endif
-
pwfb->hDC = hdc;
/* insert at head of list */
pwfb->next = FirstFramebuffer;
@@ -266,16 +220,6 @@ static WMesaContext wmesa_context(const GLcontext *ctx)
return (WMesaContext) ctx;
}
-static wmDeleteBackingStore(WMesaFramebuffer pwfb)
-{
- if (pwfb->hbmDIB) {
- SelectObject(pwfb->dib_hDC, pwfb->hOldBitmap);
- DeleteDC(pwfb->dib_hDC);
- DeleteObject(pwfb->hbmDIB);
- }
-}
-
-
/**
* Find the width and height of the window named by hdc.
*/
@@ -383,11 +327,6 @@ wm_flush_frontbuffer(struct pipe_winsys *pws,
struct wm_buffer *wm_buf;
BITMAPINFO bmi, *pbmi;
-#if 0
- if (pwfb)
- BitBlt(pwfb->hDC, 0, 0, pwfb->stfb->Base.Width, pwfb->stfb->Base.Height,
- pwfb->dib_hDC, 0, 0, SRCCOPY);
-#else
wm_buf = wm_buffer(surf->buffer);
pbmi = &bmi;
@@ -405,7 +344,6 @@ wm_flush_frontbuffer(struct pipe_winsys *pws,
pbmi->bmiHeader.biClrImportant = 0;
StretchDIBits(pwfb->hDC, 0, 0, pwfb->stfb->Base.Width, pwfb->stfb->Base.Height, 0, 0, pwfb->stfb->Base.Width, pwfb->stfb->Base.Height, wm_buf->data, pbmi, 0, SRCCOPY);
-#endif
}
@@ -525,7 +463,7 @@ wm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -706,9 +644,6 @@ void WMesaDestroyContext( WMesaContext pwc )
/* clean up frame buffer resources */
pwfb = wmesa_lookup_framebuffer(pwc->hDC);
if (pwfb) {
-#if 0
- wmDeleteBackingStore(pwfb);
-#endif
wmesa_free_framebuffer(pwc->hDC);
}
@@ -779,10 +714,6 @@ void WMesaSwapBuffers( HDC hdc )
*/
st_notify_swapbuffers(pwfb->stfb);
-#if 0
- BitBlt(pwfb->hDC, 0, 0, pwfb->stfb->Base.Width, pwfb->stfb->Base.Height,
- pwfb->dib_hDC, 0, 0, SRCCOPY);
-#else
surf = st_get_framebuffer_surface(pwfb->stfb, ST_SURFACE_BACK_LEFT);
wm_buf = wm_buffer(surf->buffer);
@@ -809,7 +740,6 @@ void WMesaSwapBuffers( HDC hdc )
st_resize_framebuffer(pwfb->stfb, width, height);
}
-#endif
}
/* This is hopefully a temporary hack to define some needed dispatch
diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile
index ec92c79..11c7632 100644
--- a/src/gallium/winsys/xlib/Makefile
+++ b/src/gallium/winsys/xlib/Makefile
@@ -33,10 +33,7 @@ XLIB_WINSYS_SOURCES = \
XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
-ifeq ($(CONFIG_NAME), linux-cell)
-# The SPU code is in a separate .a file, unfortunately
-CELL_SPU_LIB = $(TOP)/src/gallium/drivers/cell/spu/g3d_spu.a
-endif
+# Note: CELL_SPU_LIB is only defined for cell configs
LIBS = \
$(GALLIUM_DRIVERS) \
diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript
index 8650f59..324fbef 100644
--- a/src/gallium/winsys/xlib/SConscript
+++ b/src/gallium/winsys/xlib/SConscript
@@ -36,8 +36,10 @@ if env['platform'] == 'linux' \
drivers += [trace]
# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
- env.SharedLibrary(
+ libgl = env.SharedLibrary(
target ='GL',
source = sources,
LIBS = glapi + mesa + drivers + auxiliaries + env['LIBS'],
)
+
+ env.InstallSharedLibrary(libgl, version=(1, 5))
diff --git a/src/gallium/winsys/xlib/brw_aub.c b/src/gallium/winsys/xlib/brw_aub.c
index 6e814ce..9e96efa 100644
--- a/src/gallium/winsys/xlib/brw_aub.c
+++ b/src/gallium/winsys/xlib/brw_aub.c
@@ -34,8 +34,8 @@
#include "brw_aub.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_debug.h"
+#include "util/u_memory.h"
struct brw_aubfile {
diff --git a/src/gallium/winsys/xlib/glxapi.c b/src/gallium/winsys/xlib/glxapi.c
index c2ccce6..c059fc3 100644
--- a/src/gallium/winsys/xlib/glxapi.c
+++ b/src/gallium/winsys/xlib/glxapi.c
@@ -37,6 +37,7 @@
#include "main/glheader.h"
#include "glapi/glapi.h"
#include "glxapi.h"
+#include "pipe/p_thread.h"
extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
@@ -127,26 +128,13 @@ get_dispatch(Display *dpy)
/**
* GLX API current context.
*/
-#if defined(GLX_USE_TLS)
-PUBLIC __thread void * CurrentContext
- __attribute__((tls_model("initial-exec")));
-#elif defined(THREADS)
-static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
-#else
-static GLXContext CurrentContext = 0;
-#endif
+pipe_tsd ContextTSD;
static void
SetCurrentContext(GLXContext c)
{
-#if defined(GLX_USE_TLS)
- CurrentContext = c;
-#elif defined(THREADS)
- _glthread_SetTSD(&ContextTSD, c);
-#else
- CurrentContext = c;
-#endif
+ pipe_tsd_set(&ContextTSD, c);
}
@@ -238,13 +226,7 @@ glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
GLXContext PUBLIC
glXGetCurrentContext(void)
{
-#if defined(GLX_USE_TLS)
- return CurrentContext;
-#elif defined(THREADS)
- return (GLXContext) _glthread_GetTSD(&ContextTSD);
-#else
- return CurrentContext;
-#endif
+ return (GLXContext) pipe_tsd_get(&ContextTSD);
}
diff --git a/src/gallium/winsys/xlib/xm_api.c b/src/gallium/winsys/xlib/xm_api.c
index 4e5441a..b010513 100644
--- a/src/gallium/winsys/xlib/xm_api.c
+++ b/src/gallium/winsys/xlib/xm_api.c
@@ -62,11 +62,11 @@
#include "xmesaP.h"
#include "main/context.h"
#include "main/framebuffer.h"
-#include "glapi/glthread.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "xm_winsys_aub.h"
@@ -74,7 +74,7 @@
/**
* Global X driver lock
*/
-_glthread_Mutex _xmesa_lock;
+pipe_mutex _xmesa_lock;
int xmesa_mode;
@@ -244,10 +244,10 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
#else
Status stat;
- _glthread_LOCK_MUTEX(_xmesa_lock);
+ pipe_mutex_lock(_xmesa_lock);
XSync(b->xm_visual->display, 0); /* added for Chromium */
stat = get_drawable_size(dpy, b->drawable, width, height);
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ pipe_mutex_unlock(_xmesa_lock);
if (!stat) {
/* probably querying a window that's recently been destroyed */
@@ -778,7 +778,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
uint pf;
if (firstTime) {
- _glthread_INIT_MUTEX(_xmesa_lock);
+ pipe_mutex_init(_xmesa_lock);
firstTime = GL_FALSE;
}
@@ -833,7 +833,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
fail:
if (c->st)
st_destroy_context(c->st);
- if (pipe)
+ else if (pipe)
pipe->destroy(pipe);
FREE(c);
return NULL;
@@ -844,7 +844,12 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
PUBLIC
void XMesaDestroyContext( XMesaContext c )
{
+ struct pipe_screen *screen = c->st->pipe->screen;
st_destroy_context(c->st);
+ /* FIXME: We should destroy the screen here, but if we do so, surfaces may
+ * outlive it, causing segfaults
+ screen->destroy(screen);
+ */
_mesa_free(c);
}
@@ -1293,6 +1298,7 @@ void XMesaFlush( XMesaContext c )
#ifdef XFree86Server
/* NOT_NEEDED */
#else
+ st_finish(c->st);
XSync( c->xm_visual->display, False );
#endif
}
diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c
index 6071a5a..5e9a1f9 100644
--- a/src/gallium/winsys/xlib/xm_winsys.c
+++ b/src/gallium/winsys/xlib/xm_winsys.c
@@ -42,8 +42,9 @@
#include "pipe/p_winsys.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
#ifdef GALLIUM_CELL
@@ -55,7 +56,6 @@
#endif
#ifdef GALLIUM_TRACE
-#include "trace/tr_winsys.h"
#include "trace/tr_screen.h"
#include "trace/tr_context.h"
#endif
@@ -83,18 +83,6 @@ struct xm_buffer
/**
- * Subclass of pipe_surface for Xlib winsys
- */
-struct xmesa_surface
-{
- struct pipe_surface surface;
-
- int tileSize;
- boolean no_swap;
-};
-
-
-/**
* Subclass of pipe_winsys for Xlib winsys
*/
struct xmesa_pipe_winsys
@@ -107,14 +95,6 @@ struct xmesa_pipe_winsys
/** Cast wrapper */
-static INLINE struct xmesa_surface *
-xmesa_surface(struct pipe_surface *ps)
-{
- return (struct xmesa_surface *) ps;
-}
-
-
-/** Cast wrapper */
static INLINE struct xm_buffer *
xm_buffer( struct pipe_buffer *buf )
{
@@ -307,16 +287,16 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE;
uint x, y;
- /* check that the XImage has been previously initialized */
- assert(ximage->format);
- assert(ximage->bitmap_unit);
-
if (XSHM_ENABLED(xm_buf) && (xm_buf->tempImage == NULL)) {
alloc_shm_ximage(xm_buf, b, TILE_SIZE, TILE_SIZE);
}
ximage = (XSHM_ENABLED(xm_buf)) ? xm_buf->tempImage : b->tempImage;
+ /* check that the XImage has been previously initialized */
+ assert(ximage->format);
+ assert(ximage->bitmap_unit);
+
if (!XSHM_ENABLED(xm_buf)) {
/* update XImage's fields */
ximage->width = TILE_SIZE;
@@ -326,11 +306,16 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
for (y = 0; y < surf->height; y += TILE_SIZE) {
for (x = 0; x < surf->width; x += TILE_SIZE) {
- int dx = x;
- int dy = y;
int tx = x / TILE_SIZE;
int ty = y / TILE_SIZE;
int offset = ty * tilesPerRow + tx;
+ int w = TILE_SIZE;
+ int h = TILE_SIZE;
+
+ if (y + h > surf->height)
+ h = surf->height - y;
+ if (x + w > surf->width)
+ w = surf->width - x;
offset *= 4 * TILE_SIZE * TILE_SIZE;
@@ -339,11 +324,12 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
if (XSHM_ENABLED(xm_buf)) {
#if defined(USE_XSHM) && !defined(XFree86Server)
XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, x, y, TILE_SIZE, TILE_SIZE, False);
+ ximage, 0, 0, x, y, w, h, False);
#endif
- } else {
+ }
+ else {
XPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, dx, dy, TILE_SIZE, TILE_SIZE);
+ ximage, 0, 0, x, y, w, h);
}
}
}
@@ -359,13 +345,24 @@ xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf)
{
XImage *ximage;
struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
- const struct xmesa_surface *xm_surf
- = xmesa_surface((struct pipe_surface *) surf);
+ static boolean no_swap = 0;
+ static boolean firsttime = 1;
+ static int tileSize = 0;
- if (xm_surf->no_swap)
+ if (firsttime) {
+ no_swap = getenv("SP_NO_RAST") != NULL;
+#ifdef GALLIUM_CELL
+ if (!getenv("GALLIUM_NOCELL")) {
+ tileSize = 32; /** probably temporary */
+ }
+#endif
+ firsttime = 0;
+ }
+
+ if (no_swap)
return;
- if (xm_surf->tileSize) {
+ if (tileSize) {
xmesa_display_surface_tiled(b, surf);
return;
}
@@ -532,29 +529,14 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys,
static struct pipe_surface *
xm_surface_alloc(struct pipe_winsys *ws)
{
- struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
- static boolean no_swap = 0;
- static boolean firsttime = 1;
-
- if (firsttime) {
- no_swap = getenv("SP_NO_RAST") != NULL;
- firsttime = 0;
- }
+ struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
assert(ws);
- xms->surface.refcount = 1;
- xms->surface.winsys = ws;
+ surface->refcount = 1;
+ surface->winsys = ws;
-#ifdef GALLIUM_CELL
- if (!getenv("GALLIUM_NOCELL")) {
- xms->tileSize = 32; /** probably temporary */
- }
-#endif
-
- xms->no_swap = no_swap;
-
- return &xms->surface;
+ return surface;
}
@@ -567,7 +549,7 @@ xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -651,11 +633,7 @@ xmesa_get_pipe_winsys(struct xmesa_visual *xm_vis)
ws->base.get_name = xm_get_name;
}
-#ifdef GALLIUM_TRACE
- return trace_winsys_create(&ws->base);
-#else
- return &ws->base;
-#endif
+ return &ws->base;
}
@@ -684,14 +662,12 @@ xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
{
struct pipe_screen *screen = softpipe_create_screen(pws);
-#ifdef GALLIUM_TRACE
- screen = trace_screen_create(screen);
-#endif
-
pipe = softpipe_create(screen, pws, NULL);
#ifdef GALLIUM_TRACE
- pipe = trace_context_create(pipe);
+ screen = trace_screen_create(screen);
+
+ pipe = trace_context_create(screen, pipe);
#endif
}
diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.c b/src/gallium/winsys/xlib/xm_winsys_aub.c
index 7fc9deb..b7c10b6 100644
--- a/src/gallium/winsys/xlib/xm_winsys_aub.c
+++ b/src/gallium/winsys/xlib/xm_winsys_aub.c
@@ -37,8 +37,9 @@
#include "xmesaP.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "i965simple/brw_winsys.h"
#include "i965simple/brw_screen.h"
#include "brw_aub.h"
@@ -307,7 +308,7 @@ aub_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
diff --git a/src/gallium/winsys/xlib/xmesaP.h b/src/gallium/winsys/xlib/xmesaP.h
index 9b15b2d..fcaeee5 100644
--- a/src/gallium/winsys/xlib/xmesaP.h
+++ b/src/gallium/winsys/xlib/xmesaP.h
@@ -35,9 +35,10 @@
#include "state_tracker/st_context.h"
#include "state_tracker/st_public.h"
+#include "pipe/p_thread.h"
-extern _glthread_Mutex _xmesa_lock;
+extern pipe_mutex _xmesa_lock;
extern XMesaBuffer XMesaBufferList;
diff --git a/src/glu/Makefile b/src/glu/Makefile
index 5ddc509..b8c55db 100644
--- a/src/glu/Makefile
+++ b/src/glu/Makefile
@@ -14,8 +14,8 @@ default: $(TOP)/configs/current
done
install:
- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
- $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(INSTALL_DIR)/$(LIB_DIR)
+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
+ $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
clean:
@for dir in $(SUBDIRS) ; do \
diff --git a/src/glw/Makefile b/src/glw/Makefile
index 12ab2fa..86a0bba 100644
--- a/src/glw/Makefile
+++ b/src/glw/Makefile
@@ -26,10 +26,10 @@ OBJECTS = $(GLW_SOURCES:.c=.o)
default: $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME)
install:
- $(INSTALL) -d $(INSTALL_DIR)/include/GL
- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
- $(INSTALL) -m 644 *.h $(INSTALL_DIR)/include/GL
- $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(INSTALL_DIR)/$(LIB_DIR)
+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
+ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
+ $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_DIR)/include/GL
+ $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
clean:
-rm depend depend.bak
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 2c74dc7..af8dfcb 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -153,6 +153,7 @@ if env['platform'] != 'winddk':
'state_tracker/st_cb_flush.c',
'state_tracker/st_cb_drawpixels.c',
'state_tracker/st_cb_fbo.c',
+ 'state_tracker/st_cb_get.c',
'state_tracker/st_cb_feedback.c',
'state_tracker/st_cb_program.c',
'state_tracker/st_cb_queryobj.c',
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index d62661e..1461239 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 7.2
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* (C) Copyright IBM Corporation 2006
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -77,7 +77,7 @@ lookup_arrayobj(GLcontext *ctx, GLuint id)
struct gl_array_object *
_mesa_new_array_object( GLcontext *ctx, GLuint name )
{
- struct gl_array_object *obj = MALLOC_STRUCT(gl_array_object);
+ struct gl_array_object *obj = CALLOC_STRUCT(gl_array_object);
if (obj)
_mesa_initialize_array_object(ctx, obj, name);
return obj;
@@ -219,6 +219,15 @@ _mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj )
}
+static void
+unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+{
+ if (bufObj != ctx->Array.NullBufferObj) {
+ _mesa_reference_buffer_object(ctx, &bufObj, NULL);
+ }
+}
+
+
/**********************************************************************/
/* API Functions */
/**********************************************************************/
@@ -320,18 +329,18 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
/* Unbind any buffer objects that might be bound to arrays in
* this array object.
*/
- _mesa_unbind_buffer_object( ctx, obj->Vertex.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Normal.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Color.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->FogCoord.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Index.BufferObj );
+ unbind_buffer_object( ctx, obj->Vertex.BufferObj );
+ unbind_buffer_object( ctx, obj->Normal.BufferObj );
+ unbind_buffer_object( ctx, obj->Color.BufferObj );
+ unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj );
+ unbind_buffer_object( ctx, obj->FogCoord.BufferObj );
+ unbind_buffer_object( ctx, obj->Index.BufferObj );
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- _mesa_unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj );
+ unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj );
}
- _mesa_unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj );
+ unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj );
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- _mesa_unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj );
+ unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj );
}
#endif
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index b990369..7179fba 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1269,6 +1269,29 @@ adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step)
}
+/**
+ * Copy gl_pixelstore_attrib from src to dst, updating buffer
+ * object refcounts.
+ */
+static void
+copy_pixelstore(GLcontext *ctx,
+ struct gl_pixelstore_attrib *dst,
+ const struct gl_pixelstore_attrib *src)
+{
+ dst->Alignment = src->Alignment;
+ dst->RowLength = src->RowLength;
+ dst->SkipPixels = src->SkipPixels;
+ dst->SkipRows = src->SkipRows;
+ dst->ImageHeight = src->ImageHeight;
+ dst->SkipImages = src->SkipImages;
+ dst->SwapBytes = src->SwapBytes;
+ dst->LsbFirst = src->LsbFirst;
+ dst->ClientStorage = src->ClientStorage;
+ dst->Invert = src->Invert;
+ _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
+}
+
+
#define GL_CLIENT_PACK_BIT (1<<20)
#define GL_CLIENT_UNPACK_BIT (1<<21)
@@ -1287,31 +1310,29 @@ _mesa_PushClientAttrib(GLbitfield mask)
return;
}
- /* Build linked list of attribute nodes which save all attribute */
- /* groups specified by the mask. */
+ /* Build linked list of attribute nodes which save all attribute
+ * groups specified by the mask.
+ */
head = NULL;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
struct gl_pixelstore_attrib *attr;
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Pack.BufferObj->RefCount++;
- ctx->Unpack.BufferObj->RefCount++;
-#endif
/* packing attribs */
- attr = MALLOC_STRUCT( gl_pixelstore_attrib );
- MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
+ attr = CALLOC_STRUCT( gl_pixelstore_attrib );
+ copy_pixelstore(ctx, attr, &ctx->Pack);
newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
/* unpacking attribs */
- attr = MALLOC_STRUCT( gl_pixelstore_attrib );
- MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
+ attr = CALLOC_STRUCT( gl_pixelstore_attrib );
+ copy_pixelstore(ctx, attr, &ctx->Unpack);
newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
+
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
struct gl_array_attrib *attr;
struct gl_array_object *obj;
@@ -1348,7 +1369,7 @@ _mesa_PushClientAttrib(GLbitfield mask)
void GLAPIENTRY
_mesa_PopClientAttrib(void)
{
- struct gl_attrib_node *attr, *next;
+ struct gl_attrib_node *node, *next;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -1359,37 +1380,31 @@ _mesa_PopClientAttrib(void)
}
ctx->ClientAttribStackDepth--;
- attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
+ node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
- while (attr) {
- switch (attr->kind) {
+ while (node) {
+ switch (node->kind) {
case GL_CLIENT_PACK_BIT:
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Pack.BufferObj->RefCount--;
- if (ctx->Pack.BufferObj->RefCount <= 0) {
- _mesa_remove_buffer_object( ctx, ctx->Pack.BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, ctx->Pack.BufferObj );
+ {
+ struct gl_pixelstore_attrib *store =
+ (struct gl_pixelstore_attrib *) node->data;
+ copy_pixelstore(ctx, &ctx->Pack, store);
+ _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL);
}
-#endif
- MEMCPY( &ctx->Pack, attr->data,
- sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
case GL_CLIENT_UNPACK_BIT:
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Unpack.BufferObj->RefCount--;
- if (ctx->Unpack.BufferObj->RefCount <= 0) {
- _mesa_remove_buffer_object( ctx, ctx->Unpack.BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, ctx->Unpack.BufferObj );
+ {
+ struct gl_pixelstore_attrib *store =
+ (struct gl_pixelstore_attrib *) node->data;
+ copy_pixelstore(ctx, &ctx->Unpack, store);
+ _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL);
}
-#endif
- MEMCPY( &ctx->Unpack, attr->data,
- sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
case GL_CLIENT_VERTEX_ARRAY_BIT: {
struct gl_array_attrib * data =
- (struct gl_array_attrib *) attr->data;
+ (struct gl_array_attrib *) node->data;
adjust_buffer_object_ref_counts(&ctx->Array, -1);
@@ -1424,10 +1439,10 @@ _mesa_PopClientAttrib(void)
break;
}
- next = attr->next;
- FREE( attr->data );
- FREE( attr );
- attr = next;
+ next = node->next;
+ FREE( node->data );
+ FREE( node );
+ node = next;
}
}
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index dc0307f..f1e0932 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -166,22 +166,75 @@ _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
if (bufObj->Data)
_mesa_free(bufObj->Data);
+
+ /* assign strange values here to help w/ debugging */
+ bufObj->RefCount = -1000;
+ bufObj->Name = ~0;
+
_mesa_free(bufObj);
}
+
+/**
+ * Set ptr to bufObj w/ reference counting.
+ */
void
-_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+_mesa_reference_buffer_object(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *bufObj)
{
- if (bufObj != ctx->Array.NullBufferObj) {
- bufObj->RefCount--;
- if (bufObj->RefCount <= 0) {
+ if (*ptr == bufObj)
+ return;
+
+ if (*ptr) {
+ /* Unreference the old texture */
+ GLboolean deleteFlag = GL_FALSE;
+ struct gl_buffer_object *oldObj = *ptr;
+
+ /*_glthread_LOCK_MUTEX(oldObj->Mutex);*/
+ ASSERT(oldObj->RefCount > 0);
+ oldObj->RefCount--;
+#if 0
+ printf("BufferObj %p %d DECR to %d\n",
+ (void *) oldObj, oldObj->Name, oldObj->RefCount);
+#endif
+ deleteFlag = (oldObj->RefCount == 0);
+ /*_glthread_UNLOCK_MUTEX(oldObj->Mutex);*/
+
+ if (deleteFlag) {
+
+ /* some sanity checking: don't delete a buffer still in use */
ASSERT(ctx->Array.ArrayBufferObj != bufObj);
ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj);
ASSERT(ctx->Driver.DeleteBuffer);
- ctx->Driver.DeleteBuffer(ctx, bufObj);
+
+ ctx->Driver.DeleteBuffer(ctx, oldObj);
}
+
+ *ptr = NULL;
+ }
+ ASSERT(!*ptr);
+
+ if (bufObj) {
+ /* reference new texture */
+ /*_glthread_LOCK_MUTEX(tex->Mutex);*/
+ if (bufObj->RefCount == 0) {
+ /* this buffer's being deleted (look just above) */
+ /* Not sure this can every really happen. Warn if it does. */
+ _mesa_problem(NULL, "referencing deleted buffer object");
+ *ptr = NULL;
+ }
+ else {
+ bufObj->RefCount++;
+#if 0
+ printf("BufferObj %p %d INCR to %d\n",
+ (void *) bufObj, bufObj->Name, bufObj->RefCount);
+#endif
+ *ptr = bufObj;
+ }
+ /*_glthread_UNLOCK_MUTEX(tex->Mutex);*/
}
}
@@ -204,33 +257,6 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
/**
- * Add the given buffer object to the buffer object pool.
- */
-void
-_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj )
-{
- if (obj->Name > 0) {
- /* insert into hash table */
- _mesa_HashInsert(ctx->Shared->BufferObjects, obj->Name, obj);
- }
-}
-
-
-/**
- * Remove the given buffer object from the buffer object pool.
- * Do not deallocate the buffer object though.
- */
-void
-_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
-{
- if (bufObj->Name > 0) {
- /* remove from hash table */
- _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
- }
-}
-
-
-/**
* Allocate space for and store data in a buffer object. Any data that was
* previously stored in the buffer object is lost. If \c data is \c NULL,
* memory will be allocated, but no copy will occur.
@@ -400,6 +426,7 @@ _mesa_init_buffer_objects( GLcontext *ctx )
{
/* Allocate the default buffer object and set refcount so high that
* it never gets deleted.
+ * XXX with recent/improved refcounting this may not longer be needed.
*/
ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0);
if (ctx->Array.NullBufferObj)
@@ -621,6 +648,23 @@ _mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer)
}
+/**
+ * If *ptr points to obj, set ptr = the Null/default buffer object.
+ * This is a helper for buffer object deletion.
+ * The GL spec says that deleting a buffer object causes it to get
+ * unbound from all arrays in the current context.
+ */
+static void
+unbind(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *obj)
+{
+ if (*ptr == obj) {
+ _mesa_reference_buffer_object(ctx, ptr, ctx->Array.NullBufferObj);
+ }
+}
+
+
/**********************************************************************/
/* API Functions */
@@ -678,28 +722,16 @@ _mesa_BindBufferARB(GLenum target, GLuint buffer)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
return;
}
- _mesa_save_buffer_object(ctx, newBufObj);
+ _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj);
}
}
- /* Make new binding */
- *bindTarget = newBufObj;
- newBufObj->RefCount++;
+ /* bind new buffer */
+ _mesa_reference_buffer_object(ctx, bindTarget, newBufObj);
/* Pass BindBuffer call to device driver */
if (ctx->Driver.BindBuffer && newBufObj)
ctx->Driver.BindBuffer( ctx, target, newBufObj );
-
- /* decr ref count on old buffer obj, delete if needed */
- if (oldBufObj) {
- oldBufObj->RefCount--;
- assert(oldBufObj->RefCount >= 0);
- if (oldBufObj->RefCount == 0) {
- assert(oldBufObj->Name != 0);
- ASSERT(ctx->Driver.DeleteBuffer);
- ctx->Driver.DeleteBuffer( ctx, oldBufObj );
- }
- }
}
@@ -731,54 +763,18 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
ASSERT(bufObj->Name == ids[i]);
- if (ctx->Array.ArrayObj->Vertex.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Vertex.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Normal.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Normal.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Color.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Color.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->SecondaryColor.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->FogCoord.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->FogCoord.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Index.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Index.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->EdgeFlag.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->Vertex.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Normal.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Color.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->SecondaryColor.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->FogCoord.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Index.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->EdgeFlag.BufferObj, bufObj);
for (j = 0; j < MAX_TEXTURE_UNITS; j++) {
- if (ctx->Array.ArrayObj->TexCoord[j].BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->TexCoord[j].BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->TexCoord[j].BufferObj, bufObj);
}
for (j = 0; j < VERT_ATTRIB_MAX; j++) {
- if (ctx->Array.ArrayObj->VertexAttrib[j].BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->VertexAttrib[j].BufferObj, bufObj);
}
if (ctx->Array.ArrayBufferObj == bufObj) {
@@ -796,8 +792,8 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
}
/* The ID is immediately freed for re-use */
- _mesa_remove_buffer_object(ctx, bufObj);
- _mesa_unbind_buffer_object(ctx, bufObj);
+ _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
+ _mesa_reference_buffer_object(ctx, &bufObj, NULL);
}
}
@@ -846,7 +842,7 @@ _mesa_GenBuffersARB(GLsizei n, GLuint *buffer)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB");
return;
}
- _mesa_save_buffer_object(ctx, bufObj);
+ _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, bufObj);
buffer[i] = first + i;
}
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 024e5a8..2f908c5 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -52,10 +52,9 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
GLuint name, GLenum target );
extern void
-_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj );
-
-extern void
-_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
+_mesa_reference_buffer_object(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *bufObj);
extern void
_mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
@@ -115,8 +114,6 @@ _mesa_unmap_readpix_pbo(GLcontext *ctx,
const struct gl_pixelstore_attrib *pack);
-extern void
-_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
/*
* API functions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 32460e9..ed3faec 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1214,6 +1214,10 @@ _mesa_initialize_context(GLcontext *ctx,
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
}
+#ifdef FEATURE_extra_context_init
+ _mesa_initialize_context_extra(ctx);
+#endif
+
ctx->FirstTimeCurrent = GL_TRUE;
return GL_TRUE;
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 099912a..9423b66 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -115,6 +115,9 @@ _mesa_initialize_context( GLcontext *ctx,
void *driverContext );
extern void
+_mesa_initialize_context_extra(GLcontext *ctx);
+
+extern void
_mesa_free_context_data( GLcontext *ctx );
extern void
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 5f3def2..787672b 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -319,7 +319,6 @@ static struct state_key *make_state_key( GLcontext *ctx )
*/
#define PREFER_DP4 0
-#define MAX_INSN 256
/* Use uregs to represent registers internally, translate to Mesa's
* expected formats on emit.
@@ -335,16 +334,18 @@ static struct state_key *make_state_key( GLcontext *ctx )
*/
struct ureg {
GLuint file:4;
- GLint idx:8; /* relative addressing may be negative */
+ GLint idx:9; /* relative addressing may be negative */
+ /* sizeof(idx) should == sizeof(prog_src_reg::Index) */
GLuint negate:1;
GLuint swz:12;
- GLuint pad:7;
+ GLuint pad:6;
};
struct tnl_program {
const struct state_key *state;
struct gl_vertex_program *program;
+ GLint max_inst; /** number of instructions allocated for program */
GLuint temp_in_use;
GLuint temp_reserved;
@@ -362,7 +363,7 @@ struct tnl_program {
static const struct ureg undef = {
PROGRAM_UNDEFINED,
- ~0,
+ 0,
0,
0,
0
@@ -558,6 +559,8 @@ static void emit_arg( struct prog_src_register *src,
src->Abs = 0;
src->NegateAbs = 0;
src->RelAddr = 0;
+ /* Check that bitfield sizes aren't exceeded */
+ ASSERT(src->Index == reg.idx);
}
static void emit_dst( struct prog_dst_register *dst,
@@ -571,6 +574,8 @@ static void emit_dst( struct prog_dst_register *dst,
dst->CondSwizzle = SWIZZLE_NOOP;
dst->CondSrc = 0;
dst->pad = 0;
+ /* Check that bitfield sizes aren't exceeded */
+ ASSERT(dst->Index == reg.idx);
}
static void debug_insn( struct prog_instruction *inst, const char *fn,
@@ -600,14 +605,37 @@ static void emit_op3fn(struct tnl_program *p,
const char *fn,
GLuint line)
{
- GLuint nr = p->program->Base.NumInstructions++;
- struct prog_instruction *inst = &p->program->Base.Instructions[nr];
+ GLuint nr;
+ struct prog_instruction *inst;
- if (p->program->Base.NumInstructions > MAX_INSN) {
- _mesa_problem(0, "Out of instructions in emit_op3fn\n");
- return;
+ assert((GLint) p->program->Base.NumInstructions <= p->max_inst);
+
+ if (p->program->Base.NumInstructions == p->max_inst) {
+ /* need to extend the program's instruction array */
+ struct prog_instruction *newInst;
+
+ /* double the size */
+ p->max_inst *= 2;
+
+ newInst = _mesa_alloc_instructions(p->max_inst);
+ if (!newInst) {
+ _mesa_error(NULL, GL_OUT_OF_MEMORY, "vertex program build");
+ return;
+ }
+
+ _mesa_copy_instructions(newInst,
+ p->program->Base.Instructions,
+ p->program->Base.NumInstructions);
+
+ _mesa_free_instructions(p->program->Base.Instructions,
+ p->program->Base.NumInstructions);
+
+ p->program->Base.Instructions = newInst;
}
+ nr = p->program->Base.NumInstructions++;
+
+ inst = &p->program->Base.Instructions[nr];
inst->Opcode = (enum prog_opcode) op;
inst->StringPos = 0;
inst->Data = 0;
@@ -1621,6 +1649,8 @@ static void build_tnl_program( struct tnl_program *p )
#if 0
else
build_constant_pointsize(p);
+#else
+ (void) build_constant_pointsize;
#endif
/* Finish up:
@@ -1657,7 +1687,11 @@ create_new_program( const struct state_key *key,
else
p.temp_reserved = ~((1<<max_temps)-1);
- p.program->Base.Instructions = _mesa_alloc_instructions(MAX_INSN);
+ /* Start by allocating 32 instructions.
+ * If we need more, we'll grow the instruction array as needed.
+ */
+ p.max_inst = 32;
+ p.program->Base.Instructions = _mesa_alloc_instructions(p.max_inst);
p.program->Base.String = NULL;
p.program->Base.NumInstructions =
p.program->Base.NumTemporaries =
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index dab449f..494743f 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -565,13 +565,13 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) {
fb->Visual.haveAccumBuffer = GL_TRUE;
fb->Visual.accumRedBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->RedBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->RedBits;
fb->Visual.accumGreenBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->GreenBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->GreenBits;
fb->Visual.accumBlueBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->BlueBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->BlueBits;
fb->Visual.accumAlphaBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->AlphaBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->AlphaBits;
}
compute_depth_max(fb);
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index d16344a..fbedbcb 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -244,11 +244,7 @@ _mesa_init_point(GLcontext *ctx)
ctx->Point.MaxSize
= MAX2(ctx->Const.MaxPointSize, ctx->Const.MaxPointSizeAA);
ctx->Point.Threshold = 1.0;
-#if FEATURE_es2_glsl
- ctx->Point.PointSprite = GL_TRUE; /* GL_ARB/NV_point_sprite */
-#else
ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */
-#endif
ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */
ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index c163a81..2a54ff7 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -142,6 +142,34 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj,
/**
+ * Some texture initialization can't be finished until we know which
+ * target it's getting bound to (GL_TEXTURE_1D/2D/etc).
+ */
+static void
+finish_texture_init(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *obj)
+{
+ assert(obj->Target == 0);
+
+ if (target == GL_TEXTURE_RECTANGLE_NV) {
+ /* have to init wrap and filter state here - kind of klunky */
+ obj->WrapS = GL_CLAMP_TO_EDGE;
+ obj->WrapT = GL_CLAMP_TO_EDGE;
+ obj->WrapR = GL_CLAMP_TO_EDGE;
+ obj->MinFilter = GL_LINEAR;
+ if (ctx->Driver.TexParameter) {
+ static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE};
+ static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR};
+ ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_S, fparam_wrap);
+ ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_T, fparam_wrap);
+ ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_R, fparam_wrap);
+ ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_MIN_FILTER, fparam_filter);
+ }
+ }
+}
+
+
+/**
* Deallocate a texture object struct. It should have already been
* removed from the texture object pool.
* Called via ctx->Driver.DeleteTexture() if not overriden by a driver.
@@ -830,44 +858,45 @@ _mesa_BindTexture( GLenum target, GLuint texName )
GET_CURRENT_CONTEXT(ctx);
const GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- struct gl_texture_object *newTexObj = NULL;
+ struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL;
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
_mesa_debug(ctx, "glBindTexture %s %d\n",
_mesa_lookup_enum_by_nr(target), (GLint) texName);
+ switch (target) {
+ case GL_TEXTURE_1D:
+ defaultTexObj = ctx->Shared->Default1D;
+ break;
+ case GL_TEXTURE_2D:
+ defaultTexObj = ctx->Shared->Default2D;
+ break;
+ case GL_TEXTURE_3D:
+ defaultTexObj = ctx->Shared->Default3D;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ defaultTexObj = ctx->Shared->DefaultCubeMap;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ defaultTexObj = ctx->Shared->DefaultRect;
+ break;
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ defaultTexObj = ctx->Shared->Default1DArray;
+ break;
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ defaultTexObj = ctx->Shared->Default2DArray;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)");
+ return;
+ }
+
/*
* Get pointer to new texture object (newTexObj)
*/
if (texName == 0) {
- /* newTexObj = a default texture object */
- switch (target) {
- case GL_TEXTURE_1D:
- newTexObj = ctx->Shared->Default1D;
- break;
- case GL_TEXTURE_2D:
- newTexObj = ctx->Shared->Default2D;
- break;
- case GL_TEXTURE_3D:
- newTexObj = ctx->Shared->Default3D;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- newTexObj = ctx->Shared->DefaultCubeMap;
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- newTexObj = ctx->Shared->DefaultRect;
- break;
- case GL_TEXTURE_1D_ARRAY_EXT:
- newTexObj = ctx->Shared->Default1DArray;
- break;
- case GL_TEXTURE_2D_ARRAY_EXT:
- newTexObj = ctx->Shared->Default2DArray;
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)");
- return;
- }
+ newTexObj = defaultTexObj;
}
else {
/* non-default texture object */
@@ -880,20 +909,8 @@ _mesa_BindTexture( GLenum target, GLuint texName )
"glBindTexture(target mismatch)" );
return;
}
- if (newTexObj->Target == 0 && target == GL_TEXTURE_RECTANGLE_NV) {
- /* have to init wrap and filter state here - kind of klunky */
- newTexObj->WrapS = GL_CLAMP_TO_EDGE;
- newTexObj->WrapT = GL_CLAMP_TO_EDGE;
- newTexObj->WrapR = GL_CLAMP_TO_EDGE;
- newTexObj->MinFilter = GL_LINEAR;
- if (ctx->Driver.TexParameter) {
- static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE};
- static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR};
- (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_S, fparam_wrap );
- (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_T, fparam_wrap );
- (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_R, fparam_wrap );
- (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_MIN_FILTER, fparam_filter );
- }
+ if (newTexObj->Target == 0) {
+ finish_texture_init(ctx, target, newTexObj);
}
}
else {
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index e821d9f..0fd6a2d 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2522,7 +2522,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
for (row = 0; row < srcHeight; row++) {
GLubyte stencil[MAX_WIDTH];
GLint i;
- /* the 24 depth bits will be in the high position: */
+ /* the 24 depth bits will be in the low position: */
_mesa_unpack_depth_span(ctx, srcWidth,
GL_UNSIGNED_INT, /* dst type */
dstRow, /* dst addr */
@@ -2536,7 +2536,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
ctx->_ImageTransferState);
/* merge stencil values into depth values */
for (i = 0; i < srcWidth; i++)
- dstRow[i] = stencil[i] << 24;
+ dstRow[i] |= stencil[i] << 24;
src += srcRowStride;
dstRow += dstRowStride / sizeof(GLuint);
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index a6aa9c3..9f1fcd9 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -62,14 +62,9 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
array->Normalized = normalized;
array->Ptr = (const GLubyte *) ptr;
#if FEATURE_ARB_vertex_buffer_object
- array->BufferObj->RefCount--;
- if (array->BufferObj->RefCount <= 0) {
- ASSERT(array->BufferObj->Name);
- _mesa_remove_buffer_object( ctx, array->BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj );
- }
- array->BufferObj = ctx->Array.ArrayBufferObj;
- array->BufferObj->RefCount++;
+ _mesa_reference_buffer_object(ctx, &array->BufferObj,
+ ctx->Array.ArrayBufferObj);
+
/* Compute the index of the last array element that's inside the buffer.
* Later in glDrawArrays we'll check if start + count > _MaxElement to
* be sure we won't go out of bounds.
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 78cc6aa..26ccdc7 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -3354,11 +3354,11 @@ debug_variables (GLcontext * ctx, struct var_cache *vc_head,
fprintf (stderr, "%s\n",
Program->Base.Parameters->Parameters[a + b].Name);
if (Program->Base.Parameters->Parameters[a + b].Type == PROGRAM_STATE_VAR) {
- const char *s;
+ char *s;
s = _mesa_program_state_string(Program->Base.Parameters->Parameters
[a + b].StateIndexes);
fprintf(stderr, "%s\n", s);
- _mesa_free((char *) s);
+ _mesa_free(s);
}
else
fprintf (stderr, "%f %f %f %f\n",
diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c
index e0d2096..bfe27d2 100644
--- a/src/mesa/shader/prog_parameter.c
+++ b/src/mesa/shader/prog_parameter.c
@@ -278,6 +278,26 @@ _mesa_add_uniform(struct gl_program_parameter_list *paramList,
/**
+ * Mark the named uniform as 'used'.
+ */
+void
+_mesa_use_uniform(struct gl_program_parameter_list *paramList,
+ const char *name)
+{
+ GLuint i;
+ for (i = 0; i < paramList->NumParameters; i++) {
+ struct gl_program_parameter *p = paramList->Parameters + i;
+ if (p->Type == PROGRAM_UNIFORM && _mesa_strcmp(p->Name, name) == 0) {
+ p->Used = GL_TRUE;
+ /* Note that large uniforms may occupy several slots so we're
+ * not done searching yet.
+ */
+ }
+ }
+}
+
+
+/**
* Add a sampler to the parameter list.
* \param name uniform's name
* \param datatype GL_SAMPLER_2D, GL_SAMPLER_2D_RECT_ARB, etc.
@@ -400,7 +420,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
const gl_state_index stateTokens[STATE_LENGTH])
{
const GLuint size = 4; /* XXX fix */
- const char *name;
+ char *name;
GLint index;
/* Check if the state reference is already in the list */
@@ -427,7 +447,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
paramList->StateFlags |= _mesa_program_state_flags(stateTokens);
/* free name string here since we duplicated it in add_parameter() */
- _mesa_free((void *) name);
+ _mesa_free(name);
return index;
}
@@ -591,21 +611,24 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list)
/** Not too efficient, but correct */
for (i = 0; i < list->NumParameters; i++) {
struct gl_program_parameter *p = list->Parameters + i;
+ struct gl_program_parameter *pCopy;
GLuint size = MIN2(p->Size, 4);
GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType,
list->ParameterValues[i], NULL);
ASSERT(j >= 0);
+ pCopy = clone->Parameters + j;
+ pCopy->Used = p->Used;
/* copy state indexes */
if (p->Type == PROGRAM_STATE_VAR) {
GLint k;
- struct gl_program_parameter *q = clone->Parameters + j;
for (k = 0; k < STATE_LENGTH; k++) {
- q->StateIndexes[k] = p->StateIndexes[k];
+ pCopy->StateIndexes[k] = p->StateIndexes[k];
}
}
else {
clone->Parameters[j].Size = p->Size;
}
+
}
clone->StateFlags = list->StateFlags;
diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h
index ac5c629..e8d3e9e 100644
--- a/src/mesa/shader/prog_parameter.h
+++ b/src/mesa/shader/prog_parameter.h
@@ -48,6 +48,7 @@ struct gl_program_parameter
enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
GLuint Size; /**< Number of components (1..4) */
+ GLboolean Used; /**< Helper flag for GLSL uniform tracking */
/**
* A sequence of STATE_* tokens and integers to identify GL state.
*/
@@ -112,6 +113,10 @@ extern GLint
_mesa_add_uniform(struct gl_program_parameter_list *paramList,
const char *name, GLuint size, GLenum datatype);
+extern void
+_mesa_use_uniform(struct gl_program_parameter_list *paramList,
+ const char *name);
+
extern GLint
_mesa_add_sampler(struct gl_program_parameter_list *paramList,
const char *name, GLenum datatype);
diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c
index 10c5afe..ec260f1 100644
--- a/src/mesa/shader/prog_print.c
+++ b/src/mesa/shader/prog_print.c
@@ -250,7 +250,9 @@ reg_string(enum register_file f, GLint index, gl_prog_print_mode mode,
{
struct gl_program_parameter *param
= prog->Parameters->Parameters + index;
- sprintf(str, _mesa_program_state_string(param->StateIndexes));
+ char *state = _mesa_program_state_string(param->StateIndexes);
+ sprintf(str, state);
+ _mesa_free(state);
}
break;
case PROGRAM_ADDRESS:
diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c
index 819db25..8acf37c 100644
--- a/src/mesa/shader/prog_statevars.c
+++ b/src/mesa/shader/prog_statevars.c
@@ -767,7 +767,7 @@ append_index(char *dst, GLint index)
* For example, return "state.matrix.texture[2].inverse".
* Use _mesa_free() to deallocate the string.
*/
-const char *
+char *
_mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
{
char str[1000] = "";
diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h
index 0a1c235..7b490e3 100644
--- a/src/mesa/shader/prog_statevars.h
+++ b/src/mesa/shader/prog_statevars.h
@@ -129,7 +129,7 @@ extern GLbitfield
_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]);
-extern const char *
+extern char *
_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc
index e908e6c..561e94f 100644
--- a/src/mesa/shader/slang/library/slang_common_builtin.gc
+++ b/src/mesa/shader/slang/library/slang_common_builtin.gc
@@ -473,32 +473,33 @@ vec4 pow(const vec4 a, const vec4 b)
float exp(const float a)
{
- const float e = 2.71828;
- __asm float_power __retVal, e, a;
+ // NOTE: log2(e) = 1.44269502
+ float t = a * 1.44269502;
+ __asm float_exp2 __retVal, t;
}
vec2 exp(const vec2 a)
{
- const float e = 2.71828;
- __asm float_power __retVal.x, e, a.x;
- __asm float_power __retVal.y, e, a.y;
+ vec2 t = a * 1.44269502;
+ __asm float_exp2 __retVal.x, t.x;
+ __asm float_exp2 __retVal.y, t.y;
}
vec3 exp(const vec3 a)
{
- const float e = 2.71828;
- __asm float_power __retVal.x, e, a.x;
- __asm float_power __retVal.y, e, a.y;
- __asm float_power __retVal.z, e, a.z;
+ vec3 t = a * 1.44269502;
+ __asm float_exp2 __retVal.x, t.x;
+ __asm float_exp2 __retVal.y, t.y;
+ __asm float_exp2 __retVal.z, t.z;
}
vec4 exp(const vec4 a)
{
- const float e = 2.71828;
- __asm float_power __retVal.x, e, a.x;
- __asm float_power __retVal.y, e, a.y;
- __asm float_power __retVal.z, e, a.z;
- __asm float_power __retVal.w, e, a.w;
+ vec4 t = a * 1.44269502;
+ __asm float_exp2 __retVal.x, t.x;
+ __asm float_exp2 __retVal.y, t.y;
+ __asm float_exp2 __retVal.z, t.z;
+ __asm float_exp2 __retVal.w, t.w;
}
diff --git a/src/mesa/shader/slang/library/slang_common_builtin_gc.h b/src/mesa/shader/slang/library/slang_common_builtin_gc.h
index 3b07c15..d202405 100644
--- a/src/mesa/shader/slang/library/slang_common_builtin_gc.h
+++ b/src/mesa/shader/slang/library/slang_common_builtin_gc.h
@@ -244,573 +244,573 @@
0,59,121,0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,
122,0,0,18,97,0,59,122,0,0,18,98,0,59,122,0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,18,
95,95,114,101,116,86,97,108,0,59,119,0,0,18,97,0,59,119,0,0,18,98,0,59,119,0,0,0,0,1,0,0,9,0,101,
-120,112,0,1,1,0,9,97,0,0,0,1,3,2,1,0,9,1,101,0,2,17,50,0,55,49,56,50,56,0,0,0,0,4,102,108,111,97,
-116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,0,18,101,0,0,18,97,0,0,0,0,1,0,0,10,
-0,101,120,112,0,1,1,0,10,97,0,0,0,1,3,2,1,0,9,1,101,0,2,17,50,0,55,49,56,50,56,0,0,0,0,4,102,108,
-111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,101,0,0,18,97,0,
-59,120,0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,121,
-0,0,18,101,0,0,18,97,0,59,121,0,0,0,0,1,0,0,11,0,101,120,112,0,1,1,0,11,97,0,0,0,1,3,2,1,0,9,1,101,
-0,2,17,50,0,55,49,56,50,56,0,0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,
-116,86,97,108,0,59,120,0,0,18,101,0,0,18,97,0,59,120,0,0,0,4,102,108,111,97,116,95,112,111,119,101,
-114,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,101,0,0,18,97,0,59,121,0,0,0,4,102,108,111,97,
-116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,101,0,0,18,97,0,59,122,
-0,0,0,0,1,0,0,12,0,101,120,112,0,1,1,0,12,97,0,0,0,1,3,2,1,0,9,1,101,0,2,17,50,0,55,49,56,50,56,0,
-0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,
-101,0,0,18,97,0,59,120,0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,18,95,95,114,101,116,86,
-97,108,0,59,121,0,0,18,101,0,0,18,97,0,59,121,0,0,0,4,102,108,111,97,116,95,112,111,119,101,114,0,
-18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,101,0,0,18,97,0,59,122,0,0,0,4,102,108,111,97,116,
-95,112,111,119,101,114,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,101,0,0,18,97,0,59,119,0,0,
-0,0,1,0,0,9,0,108,111,103,50,0,1,1,0,9,120,0,0,0,1,4,102,108,111,97,116,95,108,111,103,50,0,18,95,
-95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,0,0,10,0,108,111,103,50,0,1,1,0,10,118,0,0,0,1,4,102,
-108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,
-0,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,
-121,0,0,0,0,1,0,0,11,0,108,111,103,50,0,1,1,0,11,118,0,0,0,1,4,102,108,111,97,116,95,108,111,103,
-50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,108,
-111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,
-116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,122,0,0,0,0,1,0,0,
-12,0,108,111,103,50,0,1,1,0,12,118,0,0,0,1,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,
-101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,108,111,103,50,0,18,
-95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,108,111,103,
-50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,122,0,0,0,4,102,108,111,97,116,95,108,
-111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,118,0,59,119,0,0,0,0,1,0,0,9,0,108,111,
-103,0,1,1,0,9,120,0,0,0,1,3,2,1,0,9,1,99,0,2,17,48,0,54,57,51,49,52,55,49,56,49,0,0,0,0,8,58,108,
-111,103,50,0,18,120,0,0,0,18,99,0,48,0,0,1,0,0,10,0,108,111,103,0,1,1,0,10,118,0,0,0,1,3,2,1,0,9,1,
+120,112,0,1,1,0,9,97,0,0,0,1,3,2,0,0,9,1,116,0,2,18,97,0,17,49,0,52,52,50,54,57,53,48,50,0,0,48,0,
+0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,0,18,116,0,0,0,0,1,0,0,
+10,0,101,120,112,0,1,1,0,10,97,0,0,0,1,3,2,0,0,10,1,116,0,2,18,97,0,17,49,0,52,52,50,54,57,53,48,
+50,0,0,48,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,
+18,116,0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,
+121,0,0,18,116,0,59,121,0,0,0,0,1,0,0,11,0,101,120,112,0,1,1,0,11,97,0,0,0,1,3,2,0,0,11,1,116,0,2,
+18,97,0,17,49,0,52,52,50,54,57,53,48,50,0,0,48,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,
+95,114,101,116,86,97,108,0,59,120,0,0,18,116,0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,
+0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,116,0,59,121,0,0,0,4,102,108,111,97,116,95,101,
+120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,116,0,59,122,0,0,0,0,1,0,0,12,0,101,
+120,112,0,1,1,0,12,97,0,0,0,1,3,2,0,0,12,1,116,0,2,18,97,0,17,49,0,52,52,50,54,57,53,48,50,0,0,48,
+0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,116,0,
+59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,
+18,116,0,59,121,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,
+122,0,0,18,116,0,59,122,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,
+108,0,59,119,0,0,18,116,0,59,119,0,0,0,0,1,0,0,9,0,108,111,103,50,0,1,1,0,9,120,0,0,0,1,4,102,108,
+111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,0,0,10,0,108,
+111,103,50,0,1,1,0,10,118,0,0,0,1,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,
+97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,
+101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,0,1,0,0,11,0,108,111,103,50,0,1,1,0,11,118,0,
+0,0,1,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,
+0,59,120,0,0,0,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,
+0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,
+59,122,0,0,18,118,0,59,122,0,0,0,0,1,0,0,12,0,108,111,103,50,0,1,1,0,12,118,0,0,0,1,4,102,108,111,
+97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,
+108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,
+0,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,
+122,0,0,0,4,102,108,111,97,116,95,108,111,103,50,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,
+118,0,59,119,0,0,0,0,1,0,0,9,0,108,111,103,0,1,1,0,9,120,0,0,0,1,3,2,1,0,9,1,99,0,2,17,48,0,54,57,
+51,49,52,55,49,56,49,0,0,0,0,8,58,108,111,103,50,0,18,120,0,0,0,18,99,0,48,0,0,1,0,0,10,0,108,111,
+103,0,1,1,0,10,118,0,0,0,1,3,2,1,0,9,1,99,0,2,17,48,0,54,57,51,49,52,55,49,56,49,0,0,0,0,8,58,108,
+111,103,50,0,18,118,0,0,0,18,99,0,48,0,0,1,0,0,11,0,108,111,103,0,1,1,0,11,118,0,0,0,1,3,2,1,0,9,1,
99,0,2,17,48,0,54,57,51,49,52,55,49,56,49,0,0,0,0,8,58,108,111,103,50,0,18,118,0,0,0,18,99,0,48,0,
-0,1,0,0,11,0,108,111,103,0,1,1,0,11,118,0,0,0,1,3,2,1,0,9,1,99,0,2,17,48,0,54,57,51,49,52,55,49,56,
-49,0,0,0,0,8,58,108,111,103,50,0,18,118,0,0,0,18,99,0,48,0,0,1,0,0,12,0,108,111,103,0,1,1,0,12,118,
-0,0,0,1,3,2,1,0,9,1,99,0,2,17,48,0,54,57,51,49,52,55,49,56,49,0,0,0,0,8,58,108,111,103,50,0,18,118,
-0,0,0,18,99,0,48,0,0,1,0,0,9,0,101,120,112,50,0,1,1,0,9,97,0,0,0,1,4,102,108,111,97,116,95,101,120,
-112,50,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,10,0,101,120,112,50,0,1,1,0,10,97,
-0,0,0,1,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,97,
-0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,
-0,18,97,0,59,121,0,0,0,0,1,0,0,11,0,101,120,112,50,0,1,1,0,11,97,0,0,0,1,4,102,108,111,97,116,95,
-101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,97,0,59,120,0,0,0,4,102,108,111,97,
-116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,97,0,59,121,0,0,0,4,102,108,
-111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,97,0,59,122,0,0,0,0,
-1,0,0,12,0,101,120,112,50,0,1,1,0,12,97,0,0,0,1,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,
+0,1,0,0,12,0,108,111,103,0,1,1,0,12,118,0,0,0,1,3,2,1,0,9,1,99,0,2,17,48,0,54,57,51,49,52,55,49,56,
+49,0,0,0,0,8,58,108,111,103,50,0,18,118,0,0,0,18,99,0,48,0,0,1,0,0,9,0,101,120,112,50,0,1,1,0,9,97,
+0,0,0,1,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,
+1,0,0,10,0,101,120,112,50,0,1,1,0,10,97,0,0,0,1,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,
114,101,116,86,97,108,0,59,120,0,0,18,97,0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,
-18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,97,0,59,121,0,0,0,4,102,108,111,97,116,95,101,120,
-112,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,97,0,59,122,0,0,0,4,102,108,111,97,116,95,
-101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,97,0,59,119,0,0,0,0,1,0,0,9,0,115,
-113,114,116,0,1,1,0,9,120,0,0,0,1,3,2,0,0,9,1,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,
-114,0,0,18,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,0,18,
-114,0,0,0,0,1,0,0,10,0,115,113,114,116,0,1,1,0,10,118,0,0,0,1,3,2,0,0,9,1,114,0,0,0,4,102,108,111,
-97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,
-95,95,114,101,116,86,97,108,0,59,120,0,0,18,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,
-0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,
-121,0,0,18,114,0,0,0,0,1,0,0,11,0,115,113,114,116,0,1,1,0,11,118,0,0,0,1,3,2,0,0,9,1,114,0,0,0,4,
-102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,
-99,112,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,114,0,0,0,4,102,108,111,97,116,95,114,115,
-113,0,18,114,0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,
-86,97,108,0,59,121,0,0,18,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,
-122,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,114,
-0,0,0,0,1,0,0,12,0,115,113,114,116,0,1,1,0,12,118,0,0,0,1,3,2,0,0,9,1,114,0,0,0,4,102,108,111,97,
-116,95,114,115,113,0,18,114,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,
-95,114,101,116,86,97,108,0,59,120,0,0,18,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,
-0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,
-121,0,0,18,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,122,0,0,0,4,102,
-108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,114,0,0,0,4,102,108,
-111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,119,0,0,0,4,102,108,111,97,116,95,114,99,112,0,
-18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,114,0,0,0,0,1,0,0,9,0,105,110,118,101,114,115,101,
-115,113,114,116,0,1,1,0,9,120,0,0,0,1,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,
-86,97,108,0,59,120,0,0,18,120,0,0,0,0,1,0,0,10,0,105,110,118,101,114,115,101,115,113,114,116,0,1,1,
-0,10,118,0,0,0,1,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,
-18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,
-121,0,0,18,118,0,59,121,0,0,0,0,1,0,0,11,0,105,110,118,101,114,115,101,115,113,114,116,0,1,1,0,11,
-118,0,0,0,1,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,
-118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,121,0,
-0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,
-122,0,0,18,118,0,59,122,0,0,0,0,1,0,0,12,0,105,110,118,101,114,115,101,115,113,114,116,0,1,1,0,12,
-118,0,0,0,1,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,
-118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,121,0,
-0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,
-122,0,0,18,118,0,59,122,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,101,116,86,97,108,
-0,59,119,0,0,18,118,0,59,119,0,0,0,0,1,0,0,9,0,110,111,114,109,97,108,105,122,101,0,1,1,0,9,120,0,
-0,0,1,9,18,95,95,114,101,116,86,97,108,0,17,49,0,48,0,0,20,0,0,1,0,0,10,0,110,111,114,109,97,108,
-105,122,101,0,1,1,0,10,118,0,0,0,1,3,2,1,0,9,1,115,0,2,58,105,110,118,101,114,115,101,115,113,114,
-116,0,58,100,111,116,0,18,118,0,0,18,118,0,0,0,0,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,
-108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,18,115,0,0,0,0,1,0,0,11,0,110,
-111,114,109,97,108,105,122,101,0,1,1,0,11,118,0,0,0,1,3,2,0,0,9,1,116,109,112,0,0,0,4,118,101,99,
-51,95,100,111,116,0,18,116,109,112,0,0,18,118,0,0,18,118,0,0,0,4,102,108,111,97,116,95,114,115,113,
-0,18,116,109,112,0,0,18,116,109,112,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,
-95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,18,116,109,112,0,0,0,0,1,0,0,12,0,110,
-111,114,109,97,108,105,122,101,0,1,1,0,12,118,0,0,0,1,3,2,0,0,9,1,116,109,112,0,0,0,4,118,101,99,
-52,95,100,111,116,0,18,116,109,112,0,0,18,118,0,0,18,118,0,0,0,4,102,108,111,97,116,95,114,115,113,
-0,18,116,109,112,0,0,18,116,109,112,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,
-95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,18,116,109,112,0,0,0,0,1,0,0,9,0,97,98,
-115,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,97,98,115,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,
-0,0,0,1,0,0,10,0,97,98,115,0,1,1,0,10,97,0,0,0,1,4,118,101,99,52,95,97,98,115,0,18,95,95,114,101,
-116,86,97,108,0,59,120,121,0,0,18,97,0,0,0,0,1,0,0,11,0,97,98,115,0,1,1,0,11,97,0,0,0,1,4,118,101,
-99,52,95,97,98,115,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,0,0,1,0,0,12,0,
-97,98,115,0,1,1,0,12,97,0,0,0,1,4,118,101,99,52,95,97,98,115,0,18,95,95,114,101,116,86,97,108,0,0,
-18,97,0,0,0,0,1,0,0,9,0,115,105,103,110,0,1,1,0,9,120,0,0,0,1,3,2,0,0,9,1,112,0,0,1,1,110,0,0,0,4,
-118,101,99,52,95,115,103,116,0,18,112,0,0,18,120,0,0,17,48,0,48,0,0,0,0,4,118,101,99,52,95,115,103,
-116,0,18,110,0,0,17,48,0,48,0,0,0,18,120,0,0,0,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,
-18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,18,110,0,0,0,0,1,0,0,10,0,115,105,103,110,0,1,1,0,10,
-118,0,0,0,1,3,2,0,0,10,1,112,0,0,1,1,110,0,0,0,4,118,101,99,52,95,115,103,116,0,18,112,0,59,120,
-121,0,0,18,118,0,0,17,48,0,48,0,0,0,0,4,118,101,99,52,95,115,103,116,0,18,110,0,59,120,121,0,0,17,
-48,0,48,0,0,0,18,118,0,0,0,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,
-86,97,108,0,59,120,121,0,0,18,112,0,0,18,110,0,0,0,0,1,0,0,11,0,115,105,103,110,0,1,1,0,11,118,0,0,
-0,1,3,2,0,0,11,1,112,0,0,1,1,110,0,0,0,4,118,101,99,52,95,115,103,116,0,18,112,0,59,120,121,122,0,
-0,18,118,0,0,17,48,0,48,0,0,0,0,4,118,101,99,52,95,115,103,116,0,18,110,0,59,120,121,122,0,0,17,48,
-0,48,0,0,0,18,118,0,0,0,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,
-97,108,0,59,120,121,122,0,0,18,112,0,0,18,110,0,0,0,0,1,0,0,12,0,115,105,103,110,0,1,1,0,12,118,0,
-0,0,1,3,2,0,0,12,1,112,0,0,1,1,110,0,0,0,4,118,101,99,52,95,115,103,116,0,18,112,0,0,18,118,0,0,17,
-48,0,48,0,0,0,0,4,118,101,99,52,95,115,103,116,0,18,110,0,0,17,48,0,48,0,0,0,18,118,0,0,0,4,118,
-101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,18,110,0,
-0,0,0,1,0,0,9,0,102,108,111,111,114,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,102,108,111,111,114,0,
-18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,10,0,102,108,111,111,114,0,1,1,0,10,97,0,0,
-0,1,4,118,101,99,52,95,102,108,111,111,114,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,
-0,0,0,0,1,0,0,11,0,102,108,111,111,114,0,1,1,0,11,97,0,0,0,1,4,118,101,99,52,95,102,108,111,111,
-114,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,0,0,1,0,0,12,0,102,108,111,111,
-114,0,1,1,0,12,97,0,0,0,1,4,118,101,99,52,95,102,108,111,111,114,0,18,95,95,114,101,116,86,97,108,
-0,0,18,97,0,0,0,0,1,0,0,9,0,99,101,105,108,0,1,1,0,9,97,0,0,0,1,3,2,0,0,9,1,98,0,2,18,97,0,54,0,0,
-4,118,101,99,52,95,102,108,111,111,114,0,18,98,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,
-18,98,0,54,20,0,0,1,0,0,10,0,99,101,105,108,0,1,1,0,10,97,0,0,0,1,3,2,0,0,10,1,98,0,2,18,97,0,54,0,
-0,4,118,101,99,52,95,102,108,111,111,114,0,18,98,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,
-0,59,120,121,0,18,98,0,54,20,0,0,1,0,0,11,0,99,101,105,108,0,1,1,0,11,97,0,0,0,1,3,2,0,0,11,1,98,0,
-2,18,97,0,54,0,0,4,118,101,99,52,95,102,108,111,111,114,0,18,98,0,0,18,98,0,0,0,9,18,95,95,114,101,
-116,86,97,108,0,59,120,121,122,0,18,98,0,54,20,0,0,1,0,0,12,0,99,101,105,108,0,1,1,0,12,97,0,0,0,1,
-3,2,0,0,12,1,98,0,2,18,97,0,54,0,0,4,118,101,99,52,95,102,108,111,111,114,0,18,98,0,0,18,98,0,0,0,
-9,18,95,95,114,101,116,86,97,108,0,18,98,0,54,20,0,0,1,0,0,9,0,102,114,97,99,116,0,1,1,0,9,97,0,0,
-0,1,4,118,101,99,52,95,102,114,97,99,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,10,0,
-102,114,97,99,116,0,1,1,0,10,97,0,0,0,1,4,118,101,99,52,95,102,114,97,99,0,18,95,95,114,101,116,86,
-97,108,0,59,120,121,0,0,18,97,0,0,0,0,1,0,0,11,0,102,114,97,99,116,0,1,1,0,11,97,0,0,0,1,4,118,101,
-99,52,95,102,114,97,99,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,0,0,1,0,0,
-12,0,102,114,97,99,116,0,1,1,0,12,97,0,0,0,1,4,118,101,99,52,95,102,114,97,99,0,18,95,95,114,101,
-116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,9,0,109,111,100,0,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,0,
-9,1,111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,
-101,114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,0,58,102,108,111,111,
-114,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,10,0,109,111,100,0,1,1,
-0,10,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,0,9,1,111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,
-116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,
-108,0,59,120,121,0,18,97,0,18,98,0,58,102,108,111,111,114,0,18,97,0,18,111,110,101,79,118,101,114,
-66,0,48,0,0,48,47,20,0,0,1,0,0,11,0,109,111,100,0,1,1,0,11,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,0,9,1,
+18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,97,0,59,121,0,0,0,0,1,0,0,11,0,101,120,112,50,0,1,1,
+0,11,97,0,0,0,1,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,
+0,18,97,0,59,120,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,
+59,121,0,0,18,97,0,59,121,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,
+97,108,0,59,122,0,0,18,97,0,59,122,0,0,0,0,1,0,0,12,0,101,120,112,50,0,1,1,0,12,97,0,0,0,1,4,102,
+108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,97,0,59,120,0,0,
+0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,97,0,59,
+121,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,
+97,0,59,122,0,0,0,4,102,108,111,97,116,95,101,120,112,50,0,18,95,95,114,101,116,86,97,108,0,59,119,
+0,0,18,97,0,59,119,0,0,0,0,1,0,0,9,0,115,113,114,116,0,1,1,0,9,120,0,0,0,1,3,2,0,0,9,1,114,0,0,0,4,
+102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,
+18,95,95,114,101,116,86,97,108,0,0,18,114,0,0,0,0,1,0,0,10,0,115,113,114,116,0,1,1,0,10,118,0,0,0,
+1,3,2,0,0,9,1,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,120,0,0,0,4,
+102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,114,0,0,0,4,102,
+108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,
+112,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,114,0,0,0,0,1,0,0,11,0,115,113,114,116,0,1,1,
+0,11,118,0,0,0,1,3,2,0,0,9,1,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,
+59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,
+114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,
+116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,114,0,0,0,4,102,108,111,97,116,
+95,114,115,113,0,18,114,0,0,18,118,0,59,122,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,
+114,101,116,86,97,108,0,59,122,0,0,18,114,0,0,0,0,1,0,0,12,0,115,113,114,116,0,1,1,0,12,118,0,0,0,
+1,3,2,0,0,9,1,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,120,0,0,0,4,
+102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,114,0,0,0,4,102,
+108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,
+112,0,18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,114,0,0,0,4,102,108,111,97,116,95,114,115,113,
+0,18,114,0,0,18,118,0,59,122,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,
+108,0,59,122,0,0,18,114,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,118,0,59,119,0,0,
+0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,114,0,0,0,0,
+1,0,0,9,0,105,110,118,101,114,115,101,115,113,114,116,0,1,1,0,9,120,0,0,0,1,4,102,108,111,97,116,
+95,114,115,113,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,120,0,0,0,0,1,0,0,10,0,105,110,118,
+101,114,115,101,115,113,114,116,0,1,1,0,10,118,0,0,0,1,4,102,108,111,97,116,95,114,115,113,0,18,95,
+95,114,101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,115,113,0,
+18,95,95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,0,1,0,0,11,0,105,110,118,101,114,
+115,101,115,113,114,116,0,1,1,0,11,118,0,0,0,1,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,
+101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,
+95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,115,113,0,
+18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,122,0,0,0,0,1,0,0,12,0,105,110,118,101,114,
+115,101,115,113,114,116,0,1,1,0,12,118,0,0,0,1,4,102,108,111,97,116,95,114,115,113,0,18,95,95,114,
+101,116,86,97,108,0,59,120,0,0,18,118,0,59,120,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,95,
+95,114,101,116,86,97,108,0,59,121,0,0,18,118,0,59,121,0,0,0,4,102,108,111,97,116,95,114,115,113,0,
+18,95,95,114,101,116,86,97,108,0,59,122,0,0,18,118,0,59,122,0,0,0,4,102,108,111,97,116,95,114,115,
+113,0,18,95,95,114,101,116,86,97,108,0,59,119,0,0,18,118,0,59,119,0,0,0,0,1,0,0,9,0,110,111,114,
+109,97,108,105,122,101,0,1,1,0,9,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,17,49,0,48,0,0,20,
+0,0,1,0,0,10,0,110,111,114,109,97,108,105,122,101,0,1,1,0,10,118,0,0,0,1,3,2,1,0,9,1,115,0,2,58,
+105,110,118,101,114,115,101,115,113,114,116,0,58,100,111,116,0,18,118,0,0,18,118,0,0,0,0,0,0,0,4,
+118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,
+18,118,0,0,18,115,0,0,0,0,1,0,0,11,0,110,111,114,109,97,108,105,122,101,0,1,1,0,11,118,0,0,0,1,3,2,
+0,0,9,1,116,109,112,0,0,0,4,118,101,99,51,95,100,111,116,0,18,116,109,112,0,0,18,118,0,0,18,118,0,
+0,0,4,102,108,111,97,116,95,114,115,113,0,18,116,109,112,0,0,18,116,109,112,0,0,0,4,118,101,99,52,
+95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,
+0,18,116,109,112,0,0,0,0,1,0,0,12,0,110,111,114,109,97,108,105,122,101,0,1,1,0,12,118,0,0,0,1,3,2,
+0,0,9,1,116,109,112,0,0,0,4,118,101,99,52,95,100,111,116,0,18,116,109,112,0,0,18,118,0,0,18,118,0,
+0,0,4,102,108,111,97,116,95,114,115,113,0,18,116,109,112,0,0,18,116,109,112,0,0,0,4,118,101,99,52,
+95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,
+0,18,116,109,112,0,0,0,0,1,0,0,9,0,97,98,115,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,97,98,115,0,
+18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,10,0,97,98,115,0,1,1,0,10,97,0,0,0,1,4,118,
+101,99,52,95,97,98,115,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,0,0,0,1,0,0,11,0,
+97,98,115,0,1,1,0,11,97,0,0,0,1,4,118,101,99,52,95,97,98,115,0,18,95,95,114,101,116,86,97,108,0,59,
+120,121,122,0,0,18,97,0,0,0,0,1,0,0,12,0,97,98,115,0,1,1,0,12,97,0,0,0,1,4,118,101,99,52,95,97,98,
+115,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,9,0,115,105,103,110,0,1,1,0,9,120,0,0,
+0,1,3,2,0,0,9,1,112,0,0,1,1,110,0,0,0,4,118,101,99,52,95,115,103,116,0,18,112,0,0,18,120,0,0,17,48,
+0,48,0,0,0,0,4,118,101,99,52,95,115,103,116,0,18,110,0,0,17,48,0,48,0,0,0,18,120,0,0,0,4,118,101,
+99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,18,110,0,0,0,
+0,1,0,0,10,0,115,105,103,110,0,1,1,0,10,118,0,0,0,1,3,2,0,0,10,1,112,0,0,1,1,110,0,0,0,4,118,101,
+99,52,95,115,103,116,0,18,112,0,59,120,121,0,0,18,118,0,0,17,48,0,48,0,0,0,0,4,118,101,99,52,95,
+115,103,116,0,18,110,0,59,120,121,0,0,17,48,0,48,0,0,0,18,118,0,0,0,4,118,101,99,52,95,115,117,98,
+116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,112,0,0,18,110,0,0,0,0,1,0,
+0,11,0,115,105,103,110,0,1,1,0,11,118,0,0,0,1,3,2,0,0,11,1,112,0,0,1,1,110,0,0,0,4,118,101,99,52,
+95,115,103,116,0,18,112,0,59,120,121,122,0,0,18,118,0,0,17,48,0,48,0,0,0,0,4,118,101,99,52,95,115,
+103,116,0,18,110,0,59,120,121,122,0,0,17,48,0,48,0,0,0,18,118,0,0,0,4,118,101,99,52,95,115,117,98,
+116,114,97,99,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,112,0,0,18,110,0,0,0,0,
+1,0,0,12,0,115,105,103,110,0,1,1,0,12,118,0,0,0,1,3,2,0,0,12,1,112,0,0,1,1,110,0,0,0,4,118,101,99,
+52,95,115,103,116,0,18,112,0,0,18,118,0,0,17,48,0,48,0,0,0,0,4,118,101,99,52,95,115,103,116,0,18,
+110,0,0,17,48,0,48,0,0,0,18,118,0,0,0,4,118,101,99,52,95,115,117,98,116,114,97,99,116,0,18,95,95,
+114,101,116,86,97,108,0,0,18,112,0,0,18,110,0,0,0,0,1,0,0,9,0,102,108,111,111,114,0,1,1,0,9,97,0,0,
+0,1,4,118,101,99,52,95,102,108,111,111,114,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,
+0,10,0,102,108,111,111,114,0,1,1,0,10,97,0,0,0,1,4,118,101,99,52,95,102,108,111,111,114,0,18,95,95,
+114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,0,0,0,1,0,0,11,0,102,108,111,111,114,0,1,1,0,11,97,
+0,0,0,1,4,118,101,99,52,95,102,108,111,111,114,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,
+0,18,97,0,0,0,0,1,0,0,12,0,102,108,111,111,114,0,1,1,0,12,97,0,0,0,1,4,118,101,99,52,95,102,108,
+111,111,114,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,9,0,99,101,105,108,0,1,1,0,9,
+97,0,0,0,1,3,2,0,0,9,1,98,0,2,18,97,0,54,0,0,4,118,101,99,52,95,102,108,111,111,114,0,18,98,0,0,18,
+98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,98,0,54,20,0,0,1,0,0,10,0,99,101,105,108,0,1,1,0,10,
+97,0,0,0,1,3,2,0,0,10,1,98,0,2,18,97,0,54,0,0,4,118,101,99,52,95,102,108,111,111,114,0,18,98,0,0,
+18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,59,120,121,0,18,98,0,54,20,0,0,1,0,0,11,0,99,101,
+105,108,0,1,1,0,11,97,0,0,0,1,3,2,0,0,11,1,98,0,2,18,97,0,54,0,0,4,118,101,99,52,95,102,108,111,
+111,114,0,18,98,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,18,98,0,54,20,
+0,0,1,0,0,12,0,99,101,105,108,0,1,1,0,12,97,0,0,0,1,3,2,0,0,12,1,98,0,2,18,97,0,54,0,0,4,118,101,
+99,52,95,102,108,111,111,114,0,18,98,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,98,0,54,
+20,0,0,1,0,0,9,0,102,114,97,99,116,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,102,114,97,99,0,18,95,
+95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,10,0,102,114,97,99,116,0,1,1,0,10,97,0,0,0,1,4,
+118,101,99,52,95,102,114,97,99,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,0,0,0,1,0,
+0,11,0,102,114,97,99,116,0,1,1,0,11,97,0,0,0,1,4,118,101,99,52,95,102,114,97,99,0,18,95,95,114,101,
+116,86,97,108,0,59,120,121,122,0,0,18,97,0,0,0,0,1,0,0,12,0,102,114,97,99,116,0,1,1,0,12,97,0,0,0,
+1,4,118,101,99,52,95,102,114,97,99,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,0,0,1,0,0,9,0,
+109,111,100,0,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,0,9,1,111,110,101,79,118,101,114,66,0,0,0,4,
+102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,0,18,98,0,0,0,9,18,95,95,114,
+101,116,86,97,108,0,18,97,0,18,98,0,58,102,108,111,111,114,0,18,97,0,18,111,110,101,79,118,101,114,
+66,0,48,0,0,48,47,20,0,0,1,0,0,10,0,109,111,100,0,1,1,0,10,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,0,9,1,
111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,
-114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,18,97,0,18,98,0,58,102,
-108,111,111,114,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,12,0,109,
-111,100,0,1,1,0,12,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,0,9,1,111,110,101,79,118,101,114,66,0,0,0,4,102,
-108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,
+114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,59,120,121,0,18,97,0,18,98,0,58,102,108,
+111,111,114,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,11,0,109,111,
+100,0,1,1,0,11,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,0,9,1,111,110,101,79,118,101,114,66,0,0,0,4,102,108,
+111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,
+86,97,108,0,59,120,121,122,0,18,97,0,18,98,0,58,102,108,111,111,114,0,18,97,0,18,111,110,101,79,
+118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,12,0,109,111,100,0,1,1,0,12,97,0,0,1,1,0,9,98,0,0,0,1,3,
+2,0,0,9,1,111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,
+79,118,101,114,66,0,0,18,98,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,0,58,102,108,
+111,111,114,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,10,0,109,111,
+100,0,1,1,0,10,97,0,0,1,1,0,10,98,0,0,0,1,3,2,0,0,10,1,111,110,101,79,118,101,114,66,0,0,0,4,102,
+108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,120,0,0,18,98,0,59,120,0,0,0,
+4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,121,0,0,18,98,0,59,121,
+0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,0,58,102,108,111,111,114,0,18,97,0,18,111,
+110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,11,0,109,111,100,0,1,1,0,11,97,0,0,1,1,0,11,
+98,0,0,0,1,3,2,0,0,11,1,111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,
+18,111,110,101,79,118,101,114,66,0,59,120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,
+112,0,18,111,110,101,79,118,101,114,66,0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,108,111,97,116,95,
+114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,122,0,0,18,98,0,59,122,0,0,0,9,18,95,95,114,101,
116,86,97,108,0,18,97,0,18,98,0,58,102,108,111,111,114,0,18,97,0,18,111,110,101,79,118,101,114,66,
-0,48,0,0,48,47,20,0,0,1,0,0,10,0,109,111,100,0,1,1,0,10,97,0,0,1,1,0,10,98,0,0,0,1,3,2,0,0,10,1,
+0,48,0,0,48,47,20,0,0,1,0,0,12,0,109,111,100,0,1,1,0,12,97,0,0,1,1,0,12,98,0,0,0,1,3,2,0,0,12,1,
111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,
114,66,0,59,120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,
-118,101,114,66,0,59,121,0,0,18,98,0,59,121,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,
-0,58,102,108,111,111,114,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,11,
-0,109,111,100,0,1,1,0,11,97,0,0,1,1,0,11,98,0,0,0,1,3,2,0,0,11,1,111,110,101,79,118,101,114,66,0,0,
-0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,120,0,0,18,98,0,59,
-120,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,121,0,0,18,98,
-0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,122,0,0,
-18,98,0,59,122,0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,0,58,102,108,111,111,114,0,
-18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,12,0,109,111,100,0,1,1,0,12,
-97,0,0,1,1,0,12,98,0,0,0,1,3,2,0,0,12,1,111,110,101,79,118,101,114,66,0,0,0,4,102,108,111,97,116,
-95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,120,0,0,18,98,0,59,120,0,0,0,4,102,108,111,
-97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,
-108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,122,0,0,18,98,0,59,122,0,0,0,
-4,102,108,111,97,116,95,114,99,112,0,18,111,110,101,79,118,101,114,66,0,59,119,0,0,18,98,0,59,119,
-0,0,0,9,18,95,95,114,101,116,86,97,108,0,18,97,0,18,98,0,58,102,108,111,111,114,0,18,97,0,18,111,
-110,101,79,118,101,114,66,0,48,0,0,48,47,20,0,0,1,0,0,9,0,109,105,110,0,1,1,0,9,97,0,0,1,1,0,9,98,
-0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,
-0,1,0,0,10,0,109,105,110,0,1,1,0,10,97,0,0,1,1,0,10,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,
-95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,59,120,121,0,0,18,98,0,59,120,121,0,0,0,0,1,0,
-0,11,0,109,105,110,0,1,1,0,11,97,0,0,1,1,0,11,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,
-114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,59,120,121,122,0,0,18,98,0,59,120,121,122,0,0,0,
-0,1,0,0,12,0,109,105,110,0,1,1,0,12,97,0,0,1,1,0,12,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,
-95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,0,0,10,0,109,105,110,0,1,1,0,10,97,0,0,1,
-1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,59,
-120,121,0,0,18,98,0,0,0,0,1,0,0,11,0,109,105,110,0,1,1,0,11,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,
-52,95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,59,120,121,122,0,0,18,98,0,0,0,0,1,
-0,0,12,0,109,105,110,0,1,1,0,12,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,
-95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,0,0,9,0,109,97,120,0,1,1,0,9,97,0,0,1,1,0,9,
-98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,
-0,0,1,0,0,10,0,109,97,120,0,1,1,0,10,97,0,0,1,1,0,10,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,
-95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,97,0,59,120,121,0,0,18,98,0,59,120,121,0,0,0,0,1,0,
-0,11,0,109,97,120,0,1,1,0,11,97,0,0,1,1,0,11,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,
-114,101,116,86,97,108,0,59,120,121,122,0,0,18,97,0,59,120,121,122,0,0,18,98,0,59,120,121,122,0,0,0,
-0,1,0,0,12,0,109,97,120,0,1,1,0,12,97,0,0,1,1,0,12,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,
-95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,0,0,10,0,109,97,120,0,1,1,0,10,97,0,0,1,
-1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,59,120,
-121,0,0,18,98,0,0,0,0,1,0,0,11,0,109,97,120,0,1,1,0,11,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,
-95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,59,120,121,122,0,0,18,98,0,0,0,0,1,0,0,
-12,0,109,97,120,0,1,1,0,12,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,
-101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,0,0,9,0,99,108,97,109,112,0,1,1,0,9,118,97,108,0,0,
-1,1,0,9,109,105,110,86,97,108,0,0,1,1,0,9,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,
+118,101,114,66,0,59,121,0,0,18,98,0,59,121,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,111,110,
+101,79,118,101,114,66,0,59,122,0,0,18,98,0,59,122,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,
+111,110,101,79,118,101,114,66,0,59,119,0,0,18,98,0,59,119,0,0,0,9,18,95,95,114,101,116,86,97,108,0,
+18,97,0,18,98,0,58,102,108,111,111,114,0,18,97,0,18,111,110,101,79,118,101,114,66,0,48,0,0,48,47,
+20,0,0,1,0,0,9,0,109,105,110,0,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,
+18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,0,0,10,0,109,105,110,0,1,1,0,10,97,0,
+0,1,1,0,10,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,59,120,121,
+0,0,18,97,0,59,120,121,0,0,18,98,0,59,120,121,0,0,0,0,1,0,0,11,0,109,105,110,0,1,1,0,11,97,0,0,1,1,
+0,11,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,
+0,18,97,0,59,120,121,122,0,0,18,98,0,59,120,121,122,0,0,0,0,1,0,0,12,0,109,105,110,0,1,1,0,12,97,0,
+0,1,1,0,12,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,
+0,18,98,0,0,0,0,1,0,0,10,0,109,105,110,0,1,1,0,10,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,
+105,110,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,59,120,121,0,0,18,98,0,0,0,0,1,0,0,11,0,109,
+105,110,0,1,1,0,11,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,
+86,97,108,0,0,18,97,0,59,120,121,122,0,0,18,98,0,0,0,0,1,0,0,12,0,109,105,110,0,1,1,0,12,97,0,0,1,
+1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,105,110,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,
+98,0,0,0,0,1,0,0,9,0,109,97,120,0,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,97,120,
+0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,0,0,0,1,0,0,10,0,109,97,120,0,1,1,0,10,97,0,
+0,1,1,0,10,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,59,120,121,
+0,0,18,97,0,59,120,121,0,0,18,98,0,59,120,121,0,0,0,0,1,0,0,11,0,109,97,120,0,1,1,0,11,97,0,0,1,1,
+0,11,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,
+0,18,97,0,59,120,121,122,0,0,18,98,0,59,120,121,122,0,0,0,0,1,0,0,12,0,109,97,120,0,1,1,0,12,97,0,
+0,1,1,0,12,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,
+18,98,0,0,0,0,1,0,0,10,0,109,97,120,0,1,1,0,10,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,97,
+120,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,59,120,121,0,0,18,98,0,0,0,0,1,0,0,11,0,109,97,
+120,0,1,1,0,11,97,0,0,1,1,0,9,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,
+97,108,0,0,18,97,0,59,120,121,122,0,0,18,98,0,0,0,0,1,0,0,12,0,109,97,120,0,1,1,0,12,97,0,0,1,1,0,
+9,98,0,0,0,1,4,118,101,99,52,95,109,97,120,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,98,0,
+0,0,0,1,0,0,9,0,99,108,97,109,112,0,1,1,0,9,118,97,108,0,0,1,1,0,9,109,105,110,86,97,108,0,0,1,1,0,
+9,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,
+108,0,0,18,118,97,108,0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,0,0,10,0,
+99,108,97,109,112,0,1,1,0,10,118,97,108,0,0,1,1,0,9,109,105,110,86,97,108,0,0,1,1,0,9,109,97,120,
+86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,
+97,108,0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,0,0,11,0,99,108,97,109,
+112,0,1,1,0,11,118,97,108,0,0,1,1,0,9,109,105,110,86,97,108,0,0,1,1,0,9,109,97,120,86,97,108,0,0,0,
+1,4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,
+109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,0,0,12,0,99,108,97,109,112,0,1,1,0,12,
+118,97,108,0,0,1,1,0,9,109,105,110,86,97,108,0,0,1,1,0,9,109,97,120,86,97,108,0,0,0,1,4,118,101,99,
+52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,
+97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,0,0,10,0,99,108,97,109,112,0,1,1,0,10,118,97,108,0,0,
+1,1,0,10,109,105,110,86,97,108,0,0,1,1,0,10,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,
97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,97,108,0,0,18,
-109,97,120,86,97,108,0,0,0,0,1,0,0,10,0,99,108,97,109,112,0,1,1,0,10,118,97,108,0,0,1,1,0,9,109,
-105,110,86,97,108,0,0,1,1,0,9,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,97,109,112,0,
+109,97,120,86,97,108,0,0,0,0,1,0,0,11,0,99,108,97,109,112,0,1,1,0,11,118,97,108,0,0,1,1,0,11,109,
+105,110,86,97,108,0,0,1,1,0,11,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,97,109,112,0,
18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,
-97,108,0,0,0,0,1,0,0,11,0,99,108,97,109,112,0,1,1,0,11,118,97,108,0,0,1,1,0,9,109,105,110,86,97,
-108,0,0,1,1,0,9,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,
+97,108,0,0,0,0,1,0,0,12,0,99,108,97,109,112,0,1,1,0,12,118,97,108,0,0,1,1,0,12,109,105,110,86,97,
+108,0,0,1,1,0,12,109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,
101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,
-0,1,0,0,12,0,99,108,97,109,112,0,1,1,0,12,118,97,108,0,0,1,1,0,9,109,105,110,86,97,108,0,0,1,1,0,9,
-109,97,120,86,97,108,0,0,0,1,4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,
-0,0,18,118,97,108,0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,0,0,10,0,99,
-108,97,109,112,0,1,1,0,10,118,97,108,0,0,1,1,0,10,109,105,110,86,97,108,0,0,1,1,0,10,109,97,120,86,
-97,108,0,0,0,1,4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,
-108,0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,0,0,11,0,99,108,97,109,112,
-0,1,1,0,11,118,97,108,0,0,1,1,0,11,109,105,110,86,97,108,0,0,1,1,0,11,109,97,120,86,97,108,0,0,0,1,
-4,118,101,99,52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,
-105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,0,0,12,0,99,108,97,109,112,0,1,1,0,12,118,
-97,108,0,0,1,1,0,12,109,105,110,86,97,108,0,0,1,1,0,12,109,97,120,86,97,108,0,0,0,1,4,118,101,99,
-52,95,99,108,97,109,112,0,18,95,95,114,101,116,86,97,108,0,0,18,118,97,108,0,0,18,109,105,110,86,
-97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,1,0,0,9,0,109,105,120,0,1,1,0,9,120,0,0,1,1,0,9,121,0,0,
-1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,
-18,121,0,0,18,120,0,0,0,0,1,0,0,10,0,109,105,120,0,1,1,0,10,120,0,0,1,1,0,10,121,0,0,1,1,0,9,97,0,
-0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,
-120,0,0,0,0,1,0,0,11,0,109,105,120,0,1,1,0,11,120,0,0,1,1,0,11,121,0,0,1,1,0,9,97,0,0,0,1,4,118,
-101,99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,
-1,0,0,12,0,109,105,120,0,1,1,0,12,120,0,0,1,1,0,12,121,0,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,
+0,1,0,0,9,0,109,105,120,0,1,1,0,9,120,0,0,1,1,0,9,121,0,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,
108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,0,0,10,0,
-109,105,120,0,1,1,0,10,120,0,0,1,1,0,10,121,0,0,1,1,0,10,97,0,0,0,1,4,118,101,99,52,95,108,114,112,
+109,105,120,0,1,1,0,10,120,0,0,1,1,0,10,121,0,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,108,114,112,
0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,0,0,11,0,109,105,120,0,
-1,1,0,11,120,0,0,1,1,0,11,121,0,0,1,1,0,11,97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,
-114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,0,0,12,0,109,105,120,0,1,1,0,12,
-120,0,0,1,1,0,12,121,0,0,1,1,0,12,97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,114,101,116,
-86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,0,0,9,0,115,116,101,112,0,1,1,0,9,101,100,103,
-101,0,0,1,1,0,9,120,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,
-120,0,0,18,101,100,103,101,0,0,0,0,1,0,0,10,0,115,116,101,112,0,1,1,0,10,101,100,103,101,0,0,1,1,0,
-10,120,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,
-120,0,0,18,101,100,103,101,0,0,0,0,1,0,0,11,0,115,116,101,112,0,1,1,0,11,101,100,103,101,0,0,1,1,0,
-11,120,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,
-0,18,120,0,0,18,101,100,103,101,0,0,0,0,1,0,0,12,0,115,116,101,112,0,1,1,0,12,101,100,103,101,0,0,
-1,1,0,12,120,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,
-0,18,101,100,103,101,0,0,0,0,1,0,0,10,0,115,116,101,112,0,1,1,0,9,101,100,103,101,0,0,1,1,0,10,118,
-0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,
-0,18,101,100,103,101,0,0,0,0,1,0,0,11,0,115,116,101,112,0,1,1,0,9,101,100,103,101,0,0,1,1,0,11,118,
-0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,
-118,0,0,18,101,100,103,101,0,0,0,0,1,0,0,12,0,115,116,101,112,0,1,1,0,9,101,100,103,101,0,0,1,1,0,
-12,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,
-101,100,103,101,0,0,0,0,1,0,0,9,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,9,101,100,103,
-101,48,0,0,1,1,0,9,101,100,103,101,49,0,0,1,1,0,9,120,0,0,0,1,3,2,0,0,9,1,116,0,2,58,99,108,97,109,
-112,0,18,120,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,
-17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,
-116,0,48,47,48,0,0,1,0,0,10,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,10,101,100,103,101,
-48,0,0,1,1,0,10,101,100,103,101,49,0,0,1,1,0,10,118,0,0,0,1,3,2,0,0,10,1,116,0,2,58,99,108,97,109,
-112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,
-17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,
-116,0,48,47,48,0,0,1,0,0,11,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,11,101,100,103,101,
-48,0,0,1,1,0,11,101,100,103,101,49,0,0,1,1,0,11,118,0,0,0,1,3,2,0,0,11,1,116,0,2,58,99,108,97,109,
-112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,
-17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,
-116,0,48,47,48,0,0,1,0,0,12,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,12,101,100,103,101,
-48,0,0,1,1,0,12,101,100,103,101,49,0,0,1,1,0,12,118,0,0,0,1,3,2,0,0,12,1,116,0,2,58,99,108,97,109,
-112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,
-17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,
-116,0,48,47,48,0,0,1,0,0,10,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,9,101,100,103,101,48,
-0,0,1,1,0,9,101,100,103,101,49,0,0,1,1,0,10,118,0,0,0,1,3,2,0,0,10,1,116,0,2,58,99,108,97,109,112,
-0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,
-48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,
-48,47,48,0,0,1,0,0,11,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,9,101,100,103,101,48,0,0,1,
-1,0,9,101,100,103,101,49,0,0,1,1,0,11,118,0,0,0,1,3,2,0,0,11,1,116,0,2,58,99,108,97,109,112,0,18,
-118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,
-48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,
-47,48,0,0,1,0,0,12,0,115,109,111,111,116,104,115,116,101,112,0,1,1,0,9,101,100,103,101,48,0,0,1,1,
-0,9,101,100,103,101,49,0,0,1,1,0,12,118,0,0,0,1,3,2,0,0,12,1,116,0,2,58,99,108,97,109,112,0,18,118,
-0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,
-0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,
-0,0,1,0,0,9,0,108,101,110,103,116,104,0,1,1,0,9,120,0,0,0,1,8,58,97,98,115,0,18,120,0,0,0,0,0,1,0,
-0,9,0,108,101,110,103,116,104,0,1,1,0,10,118,0,0,0,1,3,2,0,0,9,1,114,0,0,0,3,2,1,0,9,1,112,0,2,58,
-100,111,116,0,18,118,0,0,18,118,0,0,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,112,
-0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,114,0,0,
-0,0,1,0,0,9,0,108,101,110,103,116,104,0,1,1,0,11,118,0,0,0,1,3,2,0,0,9,1,114,0,0,0,3,2,1,0,9,1,112,
-0,2,58,100,111,116,0,18,118,0,0,18,118,0,0,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,
-18,112,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,0,18,114,0,0,0,
-0,1,0,0,9,0,108,101,110,103,116,104,0,1,1,0,12,118,0,0,0,1,3,2,0,0,9,1,114,0,0,0,3,2,1,0,9,1,112,0,
-2,58,100,111,116,0,18,118,0,0,18,118,0,0,0,0,0,4,102,108,111,97,116,95,114,115,113,0,18,114,0,0,18,
-112,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,101,116,86,97,108,0,0,18,114,0,0,0,0,1,
-0,0,9,0,100,105,115,116,97,110,99,101,0,1,1,0,9,120,0,0,1,1,0,9,121,0,0,0,1,3,2,1,0,9,1,100,0,2,18,
-120,0,18,121,0,47,0,0,9,18,95,95,114,101,116,86,97,108,0,58,108,101,110,103,116,104,0,18,100,0,0,0,
-20,0,0,1,0,0,9,0,100,105,115,116,97,110,99,101,0,1,1,0,10,118,0,0,1,1,0,10,117,0,0,0,1,3,2,1,0,10,
-1,100,50,0,2,18,118,0,18,117,0,47,0,0,9,18,95,95,114,101,116,86,97,108,0,58,108,101,110,103,116,
-104,0,18,100,50,0,0,0,20,0,0,1,0,0,9,0,100,105,115,116,97,110,99,101,0,1,1,0,11,118,0,0,1,1,0,11,
-117,0,0,0,1,3,2,1,0,11,1,100,51,0,2,18,118,0,18,117,0,47,0,0,9,18,95,95,114,101,116,86,97,108,0,58,
-108,101,110,103,116,104,0,18,100,51,0,0,0,20,0,0,1,0,0,9,0,100,105,115,116,97,110,99,101,0,1,1,0,
-12,118,0,0,1,1,0,12,117,0,0,0,1,3,2,1,0,12,1,100,52,0,2,18,118,0,18,117,0,47,0,0,9,18,95,95,114,
-101,116,86,97,108,0,58,108,101,110,103,116,104,0,18,100,52,0,0,0,20,0,0,1,0,0,11,0,99,114,111,115,
-115,0,1,1,0,11,118,0,0,1,1,0,11,117,0,0,0,1,4,118,101,99,51,95,99,114,111,115,115,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,18,117,0,0,0,0,1,0,0,9,0,102,97,99,101,102,111,
-114,119,97,114,100,0,1,1,0,9,78,0,0,1,1,0,9,73,0,0,1,1,0,9,78,114,101,102,0,0,0,1,3,2,1,0,9,1,100,
-0,2,58,100,111,116,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,115,0,0,0,4,118,101,99,52,
-95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,0,0,8,58,109,105,120,0,18,78,0,54,0,18,78,0,
-0,18,115,0,0,0,0,0,1,0,0,10,0,102,97,99,101,102,111,114,119,97,114,100,0,1,1,0,10,78,0,0,1,1,0,10,
-73,0,0,1,1,0,10,78,114,101,102,0,0,0,1,3,2,1,0,9,1,100,0,2,58,100,111,116,0,18,78,114,101,102,0,0,
-18,73,0,0,0,0,0,3,2,0,0,9,1,115,0,0,0,4,118,101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,
-18,100,0,0,0,8,58,109,105,120,0,18,78,0,54,0,18,78,0,0,18,115,0,0,0,0,0,1,0,0,11,0,102,97,99,101,
-102,111,114,119,97,114,100,0,1,1,0,11,78,0,0,1,1,0,11,73,0,0,1,1,0,11,78,114,101,102,0,0,0,1,3,2,1,
-0,9,1,100,0,2,58,100,111,116,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,115,0,0,0,4,118,
-101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,0,0,8,58,109,105,120,0,18,78,0,54,
-0,18,78,0,0,18,115,0,0,0,0,0,1,0,0,12,0,102,97,99,101,102,111,114,119,97,114,100,0,1,1,0,12,78,0,0,
-1,1,0,12,73,0,0,1,1,0,12,78,114,101,102,0,0,0,1,3,2,1,0,9,1,100,0,2,58,100,111,116,0,18,78,114,101,
-102,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,115,0,0,0,4,118,101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,
-48,0,0,0,18,100,0,0,0,8,58,109,105,120,0,18,78,0,54,0,18,78,0,0,18,115,0,0,0,0,0,1,0,0,9,0,114,101,
-102,108,101,99,116,0,1,1,0,9,73,0,0,1,1,0,9,78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,
-18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,0,1,0,0,10,0,114,101,102,108,101,99,116,0,1,1,0,10,73,0,0,
-1,1,0,10,78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,
-47,0,0,1,0,0,11,0,114,101,102,108,101,99,116,0,1,1,0,11,73,0,0,1,1,0,11,78,0,0,0,1,8,18,73,0,17,50,
-0,48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,0,1,0,0,12,0,114,101,102,108,
-101,99,116,0,1,1,0,12,73,0,0,1,1,0,12,78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,18,78,0,
-0,18,73,0,0,0,48,18,78,0,48,47,0,0,1,0,0,9,0,114,101,102,114,97,99,116,0,1,1,0,9,73,0,0,1,1,0,9,78,
-0,0,1,1,0,9,101,116,97,0,0,0,1,3,2,0,0,9,1,110,95,100,111,116,95,105,0,2,58,100,111,116,0,18,78,0,
-0,18,73,0,0,0,0,0,3,2,0,0,9,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,97,0,48,17,49,0,48,
-0,0,18,110,95,100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,47,48,47,0,0,3,2,0,0,9,1,114,
-101,116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,101,116,118,97,108,0,17,48,0,48,
-0,0,20,0,9,18,114,101,116,118,97,108,0,18,101,116,97,0,18,73,0,48,18,101,116,97,0,18,110,95,100,
-111,116,95,105,0,48,58,115,113,114,116,0,18,107,0,0,0,46,18,78,0,48,47,20,0,8,18,114,101,116,118,
-97,108,0,0,0,1,0,0,10,0,114,101,102,114,97,99,116,0,1,1,0,10,73,0,0,1,1,0,10,78,0,0,1,1,0,9,101,
-116,97,0,0,0,1,3,2,0,0,9,1,110,95,100,111,116,95,105,0,2,58,100,111,116,0,18,78,0,0,18,73,0,0,0,0,
-0,3,2,0,0,9,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,97,0,48,17,49,0,48,0,0,18,110,95,
-100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,47,48,47,0,0,3,2,0,0,10,1,114,101,116,118,
-97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,101,116,118,97,108,0,58,118,101,99,50,0,17,
-48,0,48,0,0,0,0,20,0,9,18,114,101,116,118,97,108,0,18,101,116,97,0,18,73,0,48,18,101,116,97,0,18,
-110,95,100,111,116,95,105,0,48,58,115,113,114,116,0,18,107,0,0,0,46,18,78,0,48,47,20,0,8,18,114,
-101,116,118,97,108,0,0,0,1,0,0,11,0,114,101,102,114,97,99,116,0,1,1,0,11,73,0,0,1,1,0,11,78,0,0,1,
-1,0,9,101,116,97,0,0,0,1,3,2,0,0,9,1,110,95,100,111,116,95,105,0,2,58,100,111,116,0,18,78,0,0,18,
-73,0,0,0,0,0,3,2,0,0,9,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,97,0,48,17,49,0,48,0,0,
-18,110,95,100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,47,48,47,0,0,3,2,0,0,11,1,114,101,
-116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,101,116,118,97,108,0,58,118,101,99,
-51,0,17,48,0,48,0,0,0,0,20,0,9,18,114,101,116,118,97,108,0,18,101,116,97,0,18,73,0,48,18,101,116,
-97,0,18,110,95,100,111,116,95,105,0,48,58,115,113,114,116,0,18,107,0,0,0,46,18,78,0,48,47,20,0,8,
-18,114,101,116,118,97,108,0,0,0,1,0,0,12,0,114,101,102,114,97,99,116,0,1,1,0,12,73,0,0,1,1,0,12,78,
-0,0,1,1,0,9,101,116,97,0,0,0,1,3,2,0,0,9,1,110,95,100,111,116,95,105,0,2,58,100,111,116,0,18,78,0,
-0,18,73,0,0,0,0,0,3,2,0,0,9,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,97,0,48,17,49,0,48,
-0,0,18,110,95,100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,47,48,47,0,0,3,2,0,0,12,1,114,
-101,116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,101,116,118,97,108,0,58,118,101,
-99,52,0,17,48,0,48,0,0,0,0,20,0,9,18,114,101,116,118,97,108,0,18,101,116,97,0,18,73,0,48,18,101,
-116,97,0,18,110,95,100,111,116,95,105,0,48,58,115,113,114,116,0,18,107,0,0,0,46,18,78,0,48,47,20,0,
-8,18,114,101,116,118,97,108,0,0,0,1,0,0,13,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,
-0,1,0,0,13,109,0,0,1,0,0,13,110,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,48,0,57,18,110,0,16,8,
-48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,0,0,0,1,0,0,14,0,109,97,116,114,
-105,120,67,111,109,112,77,117,108,116,0,1,0,0,14,109,0,0,1,0,0,14,110,0,0,0,1,8,58,109,97,116,51,0,
-18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,
-0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,0,0,0,1,0,0,15,0,109,97,116,114,105,120,67,
-111,109,112,77,117,108,116,0,1,0,0,15,109,0,0,1,0,0,15,110,0,0,0,1,8,58,109,97,116,52,0,18,109,0,
-16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,
-0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,48,0,0,0,
-0,1,0,0,2,0,108,101,115,115,84,104,97,110,0,1,1,0,10,117,0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,
-95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,
-0,108,101,115,115,84,104,97,110,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,115,108,
-116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,108,
-101,115,115,84,104,97,110,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,52,95,115,108,116,0,
-18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,108,101,115,115,84,104,97,
-110,0,1,1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,
-97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,108,101,115,115,84,104,97,110,0,1,1,0,
-7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,108,101,115,115,84,104,97,110,0,1,1,0,8,117,0,
-0,1,1,0,8,118,0,0,0,1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,
-0,18,118,0,0,0,0,1,0,0,2,0,108,101,115,115,84,104,97,110,69,113,117,97,108,0,1,1,0,10,117,0,0,1,1,
-0,10,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,
-18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,108,101,115,115,84,104,97,110,69,113,117,97,108,0,1,1,0,11,117,
-0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,97,108,0,59,120,
-121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,108,101,115,115,84,104,97,110,69,113,117,97,108,0,
-1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,97,
-108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,108,101,115,115,84,104,97,110,69,113,117,97,108,0,1,1,
-0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,97,108,0,
-59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,108,101,115,115,84,104,97,110,69,113,117,97,108,
-0,1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,108,101,115,115,84,104,97,110,69,113,
-117,97,108,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,
-116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,103,114,101,97,116,101,114,84,104,97,110,0,1,
-1,0,10,117,0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,103,114,101,97,116,101,114,84,104,97,110,
-0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,101,116,86,
-97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,103,114,101,97,116,101,114,84,104,
-97,110,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,101,
-116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,103,114,101,97,116,101,114,84,104,97,110,0,1,
-1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,101,116,86,97,108,
-0,59,120,121,0,0,18,117,0,59,120,121,0,0,18,118,0,59,120,121,0,0,0,0,1,0,0,3,0,103,114,101,97,116,
-101,114,84,104,97,110,0,1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,18,95,
-95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,103,114,101,97,
-116,101,114,84,104,97,110,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,1,4,118,101,99,52,95,115,103,116,0,
-18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,103,114,101,97,116,101,114,
-84,104,97,110,69,113,117,97,108,0,1,1,0,10,117,0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,95,115,103,
-101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,103,114,
-101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,0,1,4,118,
-101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,
-0,0,0,1,0,0,4,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,12,117,0,0,1,1,
-0,12,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,
-118,0,0,0,0,1,0,0,2,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,6,117,0,0,
-1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,
-0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,
-1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,
-108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,103,114,101,97,116,101,114,84,104,97,
-110,69,113,117,97,108,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,
-95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,101,113,117,97,108,0,1,1,0,10,117,
-0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,
-121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,101,113,117,97,108,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,
-0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,
-0,18,118,0,0,0,0,1,0,0,4,0,101,113,117,97,108,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,
-52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,101,113,
-117,97,108,0,1,1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,
-116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,101,113,117,97,108,0,1,1,0,7,
-117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,101,113,117,97,108,0,1,1,0,8,117,0,0,1,1,0,8,
-118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,
-0,0,0,0,1,0,0,2,0,101,113,117,97,108,0,1,1,0,2,117,0,0,1,1,0,2,118,0,0,0,1,4,118,101,99,52,95,115,
-101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,101,
-113,117,97,108,0,1,1,0,3,117,0,0,1,1,0,3,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,
-101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,101,113,117,97,108,0,1,
-1,0,4,117,0,0,1,1,0,4,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,
-0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,110,111,116,69,113,117,97,108,0,1,1,0,10,117,0,0,1,1,0,10,
-118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,
-117,0,0,18,118,0,0,0,0,1,0,0,3,0,110,111,116,69,113,117,97,108,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,
-0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,
-0,18,118,0,0,0,0,1,0,0,4,0,110,111,116,69,113,117,97,108,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,
-118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,
-2,0,110,111,116,69,113,117,97,108,0,1,1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,110,
-101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,110,111,
-116,69,113,117,97,108,0,1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,
-95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,110,111,116,69,
-113,117,97,108,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,
-101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,110,111,116,69,113,117,97,108,0,1,1,0,2,
-117,0,0,1,1,0,2,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,
-120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,110,111,116,69,113,117,97,108,0,1,1,0,3,117,0,0,1,
-1,0,3,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,
-0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,110,111,116,69,113,117,97,108,0,1,1,0,4,117,0,0,1,1,0,4,
-118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,
-0,0,0,0,1,0,0,1,0,97,110,121,0,1,1,0,2,118,0,0,0,1,3,2,0,0,9,1,115,117,109,0,0,0,4,118,101,99,52,
-95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,
+1,1,0,11,120,0,0,1,1,0,11,121,0,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,114,
+101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,0,0,12,0,109,105,120,0,1,1,0,12,120,0,
+0,1,1,0,12,121,0,0,1,1,0,9,97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,
+108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,0,0,1,0,0,10,0,109,105,120,0,1,1,0,10,120,0,0,1,1,0,10,121,
+0,0,1,1,0,10,97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,
+0,0,18,121,0,0,18,120,0,0,0,0,1,0,0,11,0,109,105,120,0,1,1,0,11,120,0,0,1,1,0,11,121,0,0,1,1,0,11,
+97,0,0,0,1,4,118,101,99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,
+0,18,120,0,0,0,0,1,0,0,12,0,109,105,120,0,1,1,0,12,120,0,0,1,1,0,12,121,0,0,1,1,0,12,97,0,0,0,1,4,
+118,101,99,52,95,108,114,112,0,18,95,95,114,101,116,86,97,108,0,0,18,97,0,0,18,121,0,0,18,120,0,0,
+0,0,1,0,0,9,0,115,116,101,112,0,1,1,0,9,101,100,103,101,0,0,1,1,0,9,120,0,0,0,1,4,118,101,99,52,95,
+115,103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,18,101,100,103,101,0,0,0,0,1,0,0,10,0,
+115,116,101,112,0,1,1,0,10,101,100,103,101,0,0,1,1,0,10,120,0,0,0,1,4,118,101,99,52,95,115,103,101,
+0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,120,0,0,18,101,100,103,101,0,0,0,0,1,0,0,11,0,
+115,116,101,112,0,1,1,0,11,101,100,103,101,0,0,1,1,0,11,120,0,0,0,1,4,118,101,99,52,95,115,103,101,
+0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,120,0,0,18,101,100,103,101,0,0,0,0,1,0,0,
+12,0,115,116,101,112,0,1,1,0,12,101,100,103,101,0,0,1,1,0,12,120,0,0,0,1,4,118,101,99,52,95,115,
+103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,18,101,100,103,101,0,0,0,0,1,0,0,10,0,115,
+116,101,112,0,1,1,0,9,101,100,103,101,0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,
+95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,18,101,100,103,101,0,0,0,0,1,0,0,11,0,115,
+116,101,112,0,1,1,0,9,101,100,103,101,0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,
+95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,18,101,100,103,101,0,0,0,0,1,0,0,12,0,
+115,116,101,112,0,1,1,0,9,101,100,103,101,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,52,95,115,103,101,
+0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,18,101,100,103,101,0,0,0,0,1,0,0,9,0,115,109,111,
+111,116,104,115,116,101,112,0,1,1,0,9,101,100,103,101,48,0,0,1,1,0,9,101,100,103,101,49,0,0,1,1,0,
+9,120,0,0,0,1,3,2,0,0,9,1,116,0,2,58,99,108,97,109,112,0,18,120,0,18,101,100,103,101,48,0,47,18,
+101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,
+116,0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,0,0,10,0,115,109,111,111,
+116,104,115,116,101,112,0,1,1,0,10,101,100,103,101,48,0,0,1,1,0,10,101,100,103,101,49,0,0,1,1,0,10,
+118,0,0,0,1,3,2,0,0,10,1,116,0,2,58,99,108,97,109,112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,
+100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,
+0,18,116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,0,0,11,0,115,109,111,111,116,
+104,115,116,101,112,0,1,1,0,11,101,100,103,101,48,0,0,1,1,0,11,101,100,103,101,49,0,0,1,1,0,11,118,
+0,0,0,1,3,2,0,0,11,1,116,0,2,58,99,108,97,109,112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,
+103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,
+116,0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,0,0,12,0,115,109,111,111,116,104,
+115,116,101,112,0,1,1,0,12,101,100,103,101,48,0,0,1,1,0,12,101,100,103,101,49,0,0,1,1,0,12,118,0,0,
+0,1,3,2,0,0,12,1,116,0,2,58,99,108,97,109,112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,
+101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,
+0,48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,0,0,10,0,115,109,111,111,116,104,115,
+116,101,112,0,1,1,0,9,101,100,103,101,48,0,0,1,1,0,9,101,100,103,101,49,0,0,1,1,0,10,118,0,0,0,1,3,
+2,0,0,10,1,116,0,2,58,99,108,97,109,112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,
+49,0,18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,
+48,17,51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,0,0,11,0,115,109,111,111,116,104,115,116,
+101,112,0,1,1,0,9,101,100,103,101,48,0,0,1,1,0,9,101,100,103,101,49,0,0,1,1,0,11,118,0,0,0,1,3,2,0,
+0,11,1,116,0,2,58,99,108,97,109,112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,
+18,101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,
+51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,0,0,12,0,115,109,111,111,116,104,115,116,101,
+112,0,1,1,0,9,101,100,103,101,48,0,0,1,1,0,9,101,100,103,101,49,0,0,1,1,0,12,118,0,0,0,1,3,2,0,0,
+12,1,116,0,2,58,99,108,97,109,112,0,18,118,0,18,101,100,103,101,48,0,47,18,101,100,103,101,49,0,18,
+101,100,103,101,48,0,47,49,0,17,48,0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,51,
+0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,0,0,9,0,108,101,110,103,116,104,0,1,1,0,9,120,0,0,
+0,1,8,58,97,98,115,0,18,120,0,0,0,0,0,1,0,0,9,0,108,101,110,103,116,104,0,1,1,0,10,118,0,0,0,1,3,2,
+0,0,9,1,114,0,0,0,3,2,1,0,9,1,112,0,2,58,100,111,116,0,18,118,0,0,18,118,0,0,0,0,0,4,102,108,111,
+97,116,95,114,115,113,0,18,114,0,0,18,112,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,114,
+101,116,86,97,108,0,59,120,0,0,18,114,0,0,0,0,1,0,0,9,0,108,101,110,103,116,104,0,1,1,0,11,118,0,0,
+0,1,3,2,0,0,9,1,114,0,0,0,3,2,1,0,9,1,112,0,2,58,100,111,116,0,18,118,0,0,18,118,0,0,0,0,0,4,102,
+108,111,97,116,95,114,115,113,0,18,114,0,0,18,112,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,
+95,114,101,116,86,97,108,0,0,18,114,0,0,0,0,1,0,0,9,0,108,101,110,103,116,104,0,1,1,0,12,118,0,0,0,
+1,3,2,0,0,9,1,114,0,0,0,3,2,1,0,9,1,112,0,2,58,100,111,116,0,18,118,0,0,18,118,0,0,0,0,0,4,102,108,
+111,97,116,95,114,115,113,0,18,114,0,0,18,112,0,0,0,4,102,108,111,97,116,95,114,99,112,0,18,95,95,
+114,101,116,86,97,108,0,0,18,114,0,0,0,0,1,0,0,9,0,100,105,115,116,97,110,99,101,0,1,1,0,9,120,0,0,
+1,1,0,9,121,0,0,0,1,3,2,1,0,9,1,100,0,2,18,120,0,18,121,0,47,0,0,9,18,95,95,114,101,116,86,97,108,
+0,58,108,101,110,103,116,104,0,18,100,0,0,0,20,0,0,1,0,0,9,0,100,105,115,116,97,110,99,101,0,1,1,0,
+10,118,0,0,1,1,0,10,117,0,0,0,1,3,2,1,0,10,1,100,50,0,2,18,118,0,18,117,0,47,0,0,9,18,95,95,114,
+101,116,86,97,108,0,58,108,101,110,103,116,104,0,18,100,50,0,0,0,20,0,0,1,0,0,9,0,100,105,115,116,
+97,110,99,101,0,1,1,0,11,118,0,0,1,1,0,11,117,0,0,0,1,3,2,1,0,11,1,100,51,0,2,18,118,0,18,117,0,47,
+0,0,9,18,95,95,114,101,116,86,97,108,0,58,108,101,110,103,116,104,0,18,100,51,0,0,0,20,0,0,1,0,0,9,
+0,100,105,115,116,97,110,99,101,0,1,1,0,12,118,0,0,1,1,0,12,117,0,0,0,1,3,2,1,0,12,1,100,52,0,2,18,
+118,0,18,117,0,47,0,0,9,18,95,95,114,101,116,86,97,108,0,58,108,101,110,103,116,104,0,18,100,52,0,
+0,0,20,0,0,1,0,0,11,0,99,114,111,115,115,0,1,1,0,11,118,0,0,1,1,0,11,117,0,0,0,1,4,118,101,99,51,
+95,99,114,111,115,115,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,18,117,0,0,
+0,0,1,0,0,9,0,102,97,99,101,102,111,114,119,97,114,100,0,1,1,0,9,78,0,0,1,1,0,9,73,0,0,1,1,0,9,78,
+114,101,102,0,0,0,1,3,2,1,0,9,1,100,0,2,58,100,111,116,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,2,
+0,0,9,1,115,0,0,0,4,118,101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,0,0,8,58,
+109,105,120,0,18,78,0,54,0,18,78,0,0,18,115,0,0,0,0,0,1,0,0,10,0,102,97,99,101,102,111,114,119,97,
+114,100,0,1,1,0,10,78,0,0,1,1,0,10,73,0,0,1,1,0,10,78,114,101,102,0,0,0,1,3,2,1,0,9,1,100,0,2,58,
+100,111,116,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,115,0,0,0,4,118,101,99,52,95,115,
+103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,0,0,8,58,109,105,120,0,18,78,0,54,0,18,78,0,0,18,
+115,0,0,0,0,0,1,0,0,11,0,102,97,99,101,102,111,114,119,97,114,100,0,1,1,0,11,78,0,0,1,1,0,11,73,0,
+0,1,1,0,11,78,114,101,102,0,0,0,1,3,2,1,0,9,1,100,0,2,58,100,111,116,0,18,78,114,101,102,0,0,18,73,
+0,0,0,0,0,3,2,0,0,9,1,115,0,0,0,4,118,101,99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,
+100,0,0,0,8,58,109,105,120,0,18,78,0,54,0,18,78,0,0,18,115,0,0,0,0,0,1,0,0,12,0,102,97,99,101,102,
+111,114,119,97,114,100,0,1,1,0,12,78,0,0,1,1,0,12,73,0,0,1,1,0,12,78,114,101,102,0,0,0,1,3,2,1,0,9,
+1,100,0,2,58,100,111,116,0,18,78,114,101,102,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,115,0,0,0,4,118,101,
+99,52,95,115,103,116,0,18,115,0,0,17,48,0,48,0,0,0,18,100,0,0,0,8,58,109,105,120,0,18,78,0,54,0,18,
+78,0,0,18,115,0,0,0,0,0,1,0,0,9,0,114,101,102,108,101,99,116,0,1,1,0,9,73,0,0,1,1,0,9,78,0,0,0,1,8,
+18,73,0,17,50,0,48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,0,1,0,0,10,0,114,
+101,102,108,101,99,116,0,1,1,0,10,73,0,0,1,1,0,10,78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,
+116,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,0,1,0,0,11,0,114,101,102,108,101,99,116,0,1,1,0,11,
+73,0,0,1,1,0,11,78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,18,
+78,0,48,47,0,0,1,0,0,12,0,114,101,102,108,101,99,116,0,1,1,0,12,73,0,0,1,1,0,12,78,0,0,0,1,8,18,73,
+0,17,50,0,48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,0,1,0,0,9,0,114,101,102,
+114,97,99,116,0,1,1,0,9,73,0,0,1,1,0,9,78,0,0,1,1,0,9,101,116,97,0,0,0,1,3,2,0,0,9,1,110,95,100,
+111,116,95,105,0,2,58,100,111,116,0,18,78,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,107,0,2,17,49,0,48,0,0,
+18,101,116,97,0,18,101,116,97,0,48,17,49,0,48,0,0,18,110,95,100,111,116,95,105,0,18,110,95,100,111,
+116,95,105,0,48,47,48,47,0,0,3,2,0,0,9,1,114,101,116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,
+40,0,9,18,114,101,116,118,97,108,0,17,48,0,48,0,0,20,0,9,18,114,101,116,118,97,108,0,18,101,116,97,
+0,18,73,0,48,18,101,116,97,0,18,110,95,100,111,116,95,105,0,48,58,115,113,114,116,0,18,107,0,0,0,
+46,18,78,0,48,47,20,0,8,18,114,101,116,118,97,108,0,0,0,1,0,0,10,0,114,101,102,114,97,99,116,0,1,1,
+0,10,73,0,0,1,1,0,10,78,0,0,1,1,0,9,101,116,97,0,0,0,1,3,2,0,0,9,1,110,95,100,111,116,95,105,0,2,
+58,100,111,116,0,18,78,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,
+101,116,97,0,48,17,49,0,48,0,0,18,110,95,100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,47,
+48,47,0,0,3,2,0,0,10,1,114,101,116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,101,
+116,118,97,108,0,58,118,101,99,50,0,17,48,0,48,0,0,0,0,20,0,9,18,114,101,116,118,97,108,0,18,101,
+116,97,0,18,73,0,48,18,101,116,97,0,18,110,95,100,111,116,95,105,0,48,58,115,113,114,116,0,18,107,
+0,0,0,46,18,78,0,48,47,20,0,8,18,114,101,116,118,97,108,0,0,0,1,0,0,11,0,114,101,102,114,97,99,116,
+0,1,1,0,11,73,0,0,1,1,0,11,78,0,0,1,1,0,9,101,116,97,0,0,0,1,3,2,0,0,9,1,110,95,100,111,116,95,105,
+0,2,58,100,111,116,0,18,78,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,
+18,101,116,97,0,48,17,49,0,48,0,0,18,110,95,100,111,116,95,105,0,18,110,95,100,111,116,95,105,0,48,
+47,48,47,0,0,3,2,0,0,11,1,114,101,116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,114,
+101,116,118,97,108,0,58,118,101,99,51,0,17,48,0,48,0,0,0,0,20,0,9,18,114,101,116,118,97,108,0,18,
+101,116,97,0,18,73,0,48,18,101,116,97,0,18,110,95,100,111,116,95,105,0,48,58,115,113,114,116,0,18,
+107,0,0,0,46,18,78,0,48,47,20,0,8,18,114,101,116,118,97,108,0,0,0,1,0,0,12,0,114,101,102,114,97,99,
+116,0,1,1,0,12,73,0,0,1,1,0,12,78,0,0,1,1,0,9,101,116,97,0,0,0,1,3,2,0,0,9,1,110,95,100,111,116,95,
+105,0,2,58,100,111,116,0,18,78,0,0,18,73,0,0,0,0,0,3,2,0,0,9,1,107,0,2,17,49,0,48,0,0,18,101,116,
+97,0,18,101,116,97,0,48,17,49,0,48,0,0,18,110,95,100,111,116,95,105,0,18,110,95,100,111,116,95,105,
+0,48,47,48,47,0,0,3,2,0,0,12,1,114,101,116,118,97,108,0,0,0,10,18,107,0,17,48,0,48,0,0,40,0,9,18,
+114,101,116,118,97,108,0,58,118,101,99,52,0,17,48,0,48,0,0,0,0,20,0,9,18,114,101,116,118,97,108,0,
+18,101,116,97,0,18,73,0,48,18,101,116,97,0,18,110,95,100,111,116,95,105,0,48,58,115,113,114,116,0,
+18,107,0,0,0,46,18,78,0,48,47,20,0,8,18,114,101,116,118,97,108,0,0,0,1,0,0,13,0,109,97,116,114,105,
+120,67,111,109,112,77,117,108,116,0,1,0,0,13,109,0,0,1,0,0,13,110,0,0,0,1,8,58,109,97,116,50,0,18,
+109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,0,
+0,0,1,0,0,14,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,14,109,0,0,1,0,0,14,
+110,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,
+49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,0,0,0,1,0,0,
+15,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,15,109,0,0,1,0,0,15,110,0,0,0,1,
+8,58,109,97,116,52,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,
+110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,18,109,0,16,10,51,0,57,
+18,110,0,16,10,51,0,57,48,0,0,0,0,1,0,0,2,0,108,101,115,115,84,104,97,110,0,1,1,0,10,117,0,0,1,1,0,
+10,118,0,0,0,1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,
+117,0,0,18,118,0,0,0,0,1,0,0,3,0,108,101,115,115,84,104,97,110,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,
+0,1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,
+0,18,118,0,0,0,0,1,0,0,4,0,108,101,115,115,84,104,97,110,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,
+118,101,99,52,95,115,108,116,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,
+2,0,108,101,115,115,84,104,97,110,0,1,1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,108,
+116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,108,101,
+115,115,84,104,97,110,0,1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,108,116,0,18,95,
+95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,108,101,115,115,
+84,104,97,110,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,1,4,118,101,99,52,95,115,108,116,0,18,95,95,114,
+101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,108,101,115,115,84,104,97,110,69,113,117,
+97,108,0,1,1,0,10,117,0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,95,114,101,
+116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,108,101,115,115,84,104,97,110,
+69,113,117,97,108,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,115,108,101,0,18,95,
+95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,108,101,115,115,
+84,104,97,110,69,113,117,97,108,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,52,95,115,108,
+101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,108,101,115,115,84,
+104,97,110,69,113,117,97,108,0,1,1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,108,101,
+0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,108,101,115,
+115,84,104,97,110,69,113,117,97,108,0,1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,
+108,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,
+108,101,115,115,84,104,97,110,69,113,117,97,108,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,1,4,118,101,99,
+52,95,115,108,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,103,114,
+101,97,116,101,114,84,104,97,110,0,1,1,0,10,117,0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,95,115,
+103,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,103,
+114,101,97,116,101,114,84,104,97,110,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,
+115,103,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,
+4,0,103,114,101,97,116,101,114,84,104,97,110,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,
+52,95,115,103,116,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,103,114,
+101,97,116,101,114,84,104,97,110,0,1,1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,103,
+116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,59,120,121,0,0,18,118,0,59,120,121,
+0,0,0,0,1,0,0,3,0,103,114,101,97,116,101,114,84,104,97,110,0,1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,
+118,101,99,52,95,115,103,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,
+118,0,0,0,0,1,0,0,4,0,103,114,101,97,116,101,114,84,104,97,110,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,
+1,4,118,101,99,52,95,115,103,116,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,
+0,0,2,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,10,117,0,0,1,1,0,10,118,
+0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,
+0,18,118,0,0,0,0,1,0,0,3,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,11,
+117,0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,
+120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,103,114,101,97,116,101,114,84,104,97,110,69,
+113,117,97,108,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,95,
+114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,103,114,101,97,116,101,114,84,104,97,
+110,69,113,117,97,108,0,1,1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,103,101,0,18,95,
+95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,103,114,101,97,116,
+101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,
+115,103,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,
+4,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,
+1,4,118,101,99,52,95,115,103,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,
+0,0,2,0,101,113,117,97,108,0,1,1,0,10,117,0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,95,115,101,113,
+0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,101,113,117,
+97,108,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,
+116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,101,113,117,97,108,0,1,1,0,
+12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,
+0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,101,113,117,97,108,0,1,1,0,6,117,0,0,1,1,0,6,118,0,0,0,1,4,
+118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,
+0,0,0,1,0,0,3,0,101,113,117,97,108,0,1,1,0,7,117,0,0,1,1,0,7,118,0,0,0,1,4,118,101,99,52,95,115,
+101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,
+101,113,117,97,108,0,1,1,0,8,117,0,0,1,1,0,8,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,
+114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,101,113,117,97,108,0,1,1,0,2,117,0,0,
+1,1,0,2,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,
+0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,101,113,117,97,108,0,1,1,0,3,117,0,0,1,1,0,3,118,0,0,0,1,4,
+118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,
+118,0,0,0,0,1,0,0,4,0,101,113,117,97,108,0,1,1,0,4,117,0,0,1,1,0,4,118,0,0,0,1,4,118,101,99,52,95,
+115,101,113,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,110,111,116,
+69,113,117,97,108,0,1,1,0,10,117,0,0,1,1,0,10,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,
+95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,110,111,116,69,113,
+117,97,108,0,1,1,0,11,117,0,0,1,1,0,11,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,
+101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,110,111,116,69,113,117,
+97,108,0,1,1,0,12,117,0,0,1,1,0,12,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,
+116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,2,0,110,111,116,69,113,117,97,108,0,1,1,0,6,117,
+0,0,1,1,0,6,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,
+121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,110,111,116,69,113,117,97,108,0,1,1,0,7,117,0,0,1,1,0,
+7,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,
+18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,110,111,116,69,113,117,97,108,0,1,1,0,8,117,0,0,1,1,0,8,118,0,
+0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,
+0,1,0,0,2,0,110,111,116,69,113,117,97,108,0,1,1,0,2,117,0,0,1,1,0,2,118,0,0,0,1,4,118,101,99,52,95,
+115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,3,0,
+110,111,116,69,113,117,97,108,0,1,1,0,3,117,0,0,1,1,0,3,118,0,0,0,1,4,118,101,99,52,95,115,110,101,
+0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,4,0,110,111,
+116,69,113,117,97,108,0,1,1,0,4,117,0,0,1,1,0,4,118,0,0,0,1,4,118,101,99,52,95,115,110,101,0,18,95,
+95,114,101,116,86,97,108,0,0,18,117,0,0,18,118,0,0,0,0,1,0,0,1,0,97,110,121,0,1,1,0,2,118,0,0,0,1,
+3,2,0,0,9,1,115,117,109,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,118,0,
+59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,
+59,120,0,0,18,115,117,109,0,59,120,0,0,17,48,0,48,0,0,0,0,0,1,0,0,1,0,97,110,121,0,1,1,0,3,118,0,0,
+0,1,3,2,0,0,9,1,115,117,109,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,
+118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,
+18,115,117,109,0,59,120,0,0,18,118,0,59,122,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,
+101,116,86,97,108,0,59,120,0,0,18,115,117,109,0,59,120,0,0,17,48,0,48,0,0,0,0,0,1,0,0,1,0,97,110,
+121,0,1,1,0,4,118,0,0,0,1,3,2,0,0,9,1,115,117,109,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,
+109,0,59,120,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,
+117,109,0,59,120,0,0,18,115,117,109,0,59,120,0,0,18,118,0,59,122,0,0,0,4,118,101,99,52,95,97,100,
+100,0,18,115,117,109,0,59,120,0,0,18,115,117,109,0,59,120,0,0,18,118,0,59,119,0,0,0,4,118,101,99,
52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,115,117,109,0,59,120,0,0,17,48,
-0,48,0,0,0,0,0,1,0,0,1,0,97,110,121,0,1,1,0,3,118,0,0,0,1,3,2,0,0,9,1,115,117,109,0,0,0,4,118,101,
-99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,
-101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,115,117,109,0,59,120,0,0,18,118,0,59,122,
-0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,115,117,109,
-0,59,120,0,0,17,48,0,48,0,0,0,0,0,1,0,0,1,0,97,110,121,0,1,1,0,4,118,0,0,0,1,3,2,0,0,9,1,115,117,
-109,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,118,0,59,120,0,0,18,118,0,
-59,121,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,115,117,109,0,59,120,0,
-0,18,118,0,59,122,0,0,0,4,118,101,99,52,95,97,100,100,0,18,115,117,109,0,59,120,0,0,18,115,117,109,
-0,59,120,0,0,18,118,0,59,119,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,
-0,59,120,0,0,18,115,117,109,0,59,120,0,0,17,48,0,48,0,0,0,0,0,1,0,0,1,0,97,108,108,0,1,1,0,2,118,0,
-0,0,1,3,2,0,0,9,1,112,114,111,100,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,
-112,114,111,100,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,115,110,101,0,18,
-95,95,114,101,116,86,97,108,0,0,18,112,114,111,100,0,0,17,48,0,48,0,0,0,0,0,1,0,0,1,0,97,108,108,0,
-1,1,0,3,118,0,0,0,1,3,2,0,0,9,1,112,114,111,100,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,
-108,121,0,18,112,114,111,100,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,109,
-117,108,116,105,112,108,121,0,18,112,114,111,100,0,0,18,112,114,111,100,0,0,18,118,0,59,122,0,0,0,
-4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,112,114,111,100,0,0,17,48,0,
-48,0,0,0,0,0,1,0,0,1,0,97,108,108,0,1,1,0,4,118,0,0,0,1,3,2,0,0,9,1,112,114,111,100,0,0,0,4,118,
+0,48,0,0,0,0,0,1,0,0,1,0,97,108,108,0,1,1,0,2,118,0,0,0,1,3,2,0,0,9,1,112,114,111,100,0,0,0,4,118,
101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,114,111,100,0,0,18,118,0,59,120,0,0,18,118,0,
-59,121,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,114,111,100,0,0,18,112,
-114,111,100,0,0,18,118,0,59,122,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,
-114,111,100,0,0,18,112,114,111,100,0,0,18,118,0,59,119,0,0,0,4,118,101,99,52,95,115,110,101,0,18,
-95,95,114,101,116,86,97,108,0,0,18,112,114,111,100,0,0,17,48,0,48,0,0,0,0,0,1,0,0,2,0,110,111,116,
-0,1,1,0,2,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,
-0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,0,0,3,0,110,111,116,0,1,1,0,3,118,0,0,0,1,4,118,101,99,52,95,
-115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,
-1,0,0,4,0,110,111,116,0,1,1,0,4,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,
-86,97,108,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,0,1,1,0,
-16,115,97,109,112,108,101,114,0,0,1,1,0,9,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,
-120,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,
-114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,1,0,16,115,97,109,
-112,108,101,114,0,0,1,1,0,10,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,49,100,
-0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,
-120,121,121,121,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,1,0,16,115,
-97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,
-49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,
-100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,0,1,1,0,17,115,97,109,112,108,101,114,0,0,
-1,1,0,10,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,50,100,0,18,95,95,114,101,116,
-86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,
-120,116,117,114,101,50,68,80,114,111,106,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,
-111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,50,100,0,18,95,95,114,101,116,86,97,108,0,0,
-18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,120,121,122,122,0,0,0,0,1,0,0,12,0,
-116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,
-12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,50,100,0,18,95,95,114,101,116,86,
-97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,
-116,117,114,101,51,68,0,1,1,0,18,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,0,
-1,4,118,101,99,52,95,116,101,120,51,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,
-101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,
-106,0,1,1,0,18,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,
-95,116,101,120,112,51,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,
-18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,67,117,98,101,0,1,1,0,19,115,
-97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,99,
-117,98,101,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,
-114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,49,68,0,1,1,0,20,115,97,109,112,108,101,114,0,0,
-1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,49,100,0,18,95,95,114,101,116,
+59,121,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,112,114,111,
+100,0,0,17,48,0,48,0,0,0,0,0,1,0,0,1,0,97,108,108,0,1,1,0,3,118,0,0,0,1,3,2,0,0,9,1,112,114,111,
+100,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,114,111,100,0,0,18,118,0,59,
+120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,114,111,
+100,0,0,18,112,114,111,100,0,0,18,118,0,59,122,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,
+101,116,86,97,108,0,0,18,112,114,111,100,0,0,17,48,0,48,0,0,0,0,0,1,0,0,1,0,97,108,108,0,1,1,0,4,
+118,0,0,0,1,3,2,0,0,9,1,112,114,111,100,0,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,
+18,112,114,111,100,0,0,18,118,0,59,120,0,0,18,118,0,59,121,0,0,0,4,118,101,99,52,95,109,117,108,
+116,105,112,108,121,0,18,112,114,111,100,0,0,18,112,114,111,100,0,0,18,118,0,59,122,0,0,0,4,118,
+101,99,52,95,109,117,108,116,105,112,108,121,0,18,112,114,111,100,0,0,18,112,114,111,100,0,0,18,
+118,0,59,119,0,0,0,4,118,101,99,52,95,115,110,101,0,18,95,95,114,101,116,86,97,108,0,0,18,112,114,
+111,100,0,0,17,48,0,48,0,0,0,0,0,1,0,0,2,0,110,111,116,0,1,1,0,2,118,0,0,0,1,4,118,101,99,52,95,
+115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,0,
+0,3,0,110,111,116,0,1,1,0,3,118,0,0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,
+97,108,0,59,120,121,122,0,0,18,118,0,0,17,48,0,48,0,0,0,0,0,1,0,0,4,0,110,111,116,0,1,1,0,4,118,0,
+0,0,1,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,0,18,118,0,0,17,48,0,48,0,
+0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,
+0,9,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,49,100,0,18,95,95,114,101,116,86,97,
+108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,
+117,114,101,49,68,80,114,111,106,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,10,99,111,111,114,
+100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,
+97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,120,121,121,121,0,0,0,0,1,0,0,12,0,116,101,
+120,116,117,114,101,49,68,80,114,111,106,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,
+111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,49,100,0,18,95,95,114,101,116,86,97,108,0,0,
+18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,
+101,50,68,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,10,99,111,111,114,100,0,0,0,1,4,118,101,
+99,52,95,116,101,120,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,
+18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,1,0,
+17,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,
+120,112,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
+111,114,100,0,59,120,121,122,122,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,
+106,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,
+95,116,101,120,112,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,
+18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,51,68,0,1,1,0,18,115,97,109,
+112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,51,100,0,18,
+95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,
+0,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,0,1,1,0,18,115,97,109,112,108,101,114,0,
+0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,51,100,0,18,95,95,114,101,
+116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,
+101,120,116,117,114,101,67,117,98,101,0,1,1,0,19,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,
+111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,95,95,114,101,116,86,97,108,
+0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,
+119,49,68,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,
+99,52,95,116,101,120,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,
+18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,49,68,80,114,111,106,0,1,1,0,20,
+115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,
+112,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,
+114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,0,1,1,0,21,115,97,109,112,108,101,114,0,0,
+1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,50,100,0,18,95,95,114,101,116,
86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,
-97,100,111,119,49,68,80,114,111,106,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,
-114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,
-115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,
-68,0,1,1,0,21,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,
-95,116,101,120,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,
-111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,1,0,21,115,97,
-109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,50,
-100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,
-0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,82,101,99,116,0,1,1,0,22,115,97,109,112,108,101,
-114,0,0,1,1,0,10,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,114,101,99,116,0,18,
+97,100,111,119,50,68,80,114,111,106,0,1,1,0,21,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,
+114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,
+115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,
+101,50,68,82,101,99,116,0,1,1,0,22,115,97,109,112,108,101,114,0,0,1,1,0,10,99,111,111,114,100,0,0,
+0,1,4,118,101,99,52,95,116,101,120,95,114,101,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,115,
+97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,
+68,82,101,99,116,80,114,111,106,0,1,1,0,22,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,
+100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,95,114,101,99,116,0,18,95,95,114,101,116,86,97,108,
+0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,120,121,122,122,0,0,0,0,1,0,0,12,
+0,116,101,120,116,117,114,101,50,68,82,101,99,116,80,114,111,106,0,1,1,0,22,115,97,109,112,108,101,
+114,0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,95,114,101,99,116,0,
+18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,99,111,111,114,100,0,0,
+0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,82,101,99,116,0,1,1,0,23,115,97,109,112,108,101,114,0,
+0,1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,95,114,101,99,116,0,18,95,95,
+114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,
+0,115,104,97,100,111,119,50,68,82,101,99,116,80,114,111,106,0,1,1,0,23,115,97,109,112,108,101,114,
+0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,95,114,101,99,116,0,18,
95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,
-0,0,12,0,116,101,120,116,117,114,101,50,68,82,101,99,116,80,114,111,106,0,1,1,0,22,115,97,109,112,
-108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,116,101,120,112,95,114,101,
-99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,
-100,0,59,120,121,122,122,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,82,101,99,116,80,114,
-111,106,0,1,1,0,22,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,
-52,95,116,101,120,112,95,114,101,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,
-101,114,0,0,18,99,99,111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,82,101,99,116,
-0,1,1,0,23,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,0,1,4,118,101,99,52,95,
-116,101,120,95,114,101,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,
-0,18,99,111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,82,101,99,116,80,114,111,
-106,0,1,1,0,23,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,0,1,4,118,101,99,52,
-95,116,101,120,112,95,114,101,99,116,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,
-101,114,0,0,18,99,111,111,114,100,0,0,0,0,1,0,0,9,0,110,111,105,115,101,49,0,1,1,0,9,120,0,0,0,1,4,
-102,108,111,97,116,95,110,111,105,115,101,49,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,
-0,0,9,0,110,111,105,115,101,49,0,1,1,0,10,120,0,0,0,1,4,102,108,111,97,116,95,110,111,105,115,101,
-50,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,0,0,9,0,110,111,105,115,101,49,0,1,1,0,11,
-120,0,0,0,1,4,102,108,111,97,116,95,110,111,105,115,101,51,0,18,95,95,114,101,116,86,97,108,0,0,18,
-120,0,0,0,0,1,0,0,9,0,110,111,105,115,101,49,0,1,1,0,12,120,0,0,0,1,4,102,108,111,97,116,95,110,
-111,105,115,101,52,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,0,0,10,0,110,111,105,115,
-101,50,0,1,1,0,9,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,
-0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,
-0,17,49,57,0,51,52,0,0,46,0,0,20,0,0,1,0,0,10,0,110,111,105,115,101,50,0,1,1,0,10,120,0,0,0,1,9,18,
-95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,
-114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,49,57,
-0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,20,0,0,1,0,0,10,0,110,111,105,115,101,50,0,1,1,0,11,120,
-0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,
-9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,51,
-0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,0,46,0,0,20,0,0,1,0,0,10,0,110,
-111,105,115,101,50,0,1,1,0,12,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,
-105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,
-101,49,0,18,120,0,58,118,101,99,52,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,
-0,17,50,0,55,55,0,0,0,0,46,0,0,20,0,0,1,0,0,11,0,110,111,105,115,101,51,0,1,1,0,9,120,0,0,0,1,9,18,
+0,0,9,0,110,111,105,115,101,49,0,1,1,0,9,120,0,0,0,1,4,102,108,111,97,116,95,110,111,105,115,101,
+49,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,0,0,9,0,110,111,105,115,101,49,0,1,1,0,10,
+120,0,0,0,1,4,102,108,111,97,116,95,110,111,105,115,101,50,0,18,95,95,114,101,116,86,97,108,0,0,18,
+120,0,0,0,0,1,0,0,9,0,110,111,105,115,101,49,0,1,1,0,11,120,0,0,0,1,4,102,108,111,97,116,95,110,
+111,105,115,101,51,0,18,95,95,114,101,116,86,97,108,0,0,18,120,0,0,0,0,1,0,0,9,0,110,111,105,115,
+101,49,0,1,1,0,12,120,0,0,0,1,4,102,108,111,97,116,95,110,111,105,115,101,52,0,18,95,95,114,101,
+116,86,97,108,0,0,18,120,0,0,0,0,1,0,0,10,0,110,111,105,115,101,50,0,1,1,0,9,120,0,0,0,1,9,18,95,
+95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,
+101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,17,49,57,0,51,52,0,0,46,0,0,20,0,
+0,1,0,0,10,0,110,111,105,115,101,50,0,1,1,0,10,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,
+120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,
+110,111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,
+46,0,0,20,0,0,1,0,0,10,0,110,111,105,115,101,50,0,1,1,0,11,120,0,0,0,1,9,18,95,95,114,101,116,86,
+97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
+59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,51,0,17,49,57,0,51,52,0,0,0,17,55,0,54,
+54,0,0,0,17,51,0,50,51,0,0,0,0,46,0,0,20,0,0,1,0,0,10,0,110,111,105,115,101,50,0,1,1,0,12,120,0,0,
+0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,
+95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,52,0,17,
+49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,55,55,0,0,0,0,46,0,0,20,0,0,1,
+0,0,11,0,110,111,105,115,101,51,0,1,1,0,9,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,
+58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,
+111,105,115,101,49,0,18,120,0,17,49,57,0,51,52,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
+59,122,0,58,110,111,105,115,101,49,0,18,120,0,17,53,0,52,55,0,0,46,0,0,20,0,0,1,0,0,11,0,110,111,
+105,115,101,51,0,1,1,0,10,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,
+115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,
+49,0,18,120,0,58,118,101,99,50,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,20,0,9,18,95,
+95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,53,
+0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,0,46,0,0,20,0,0,1,0,0,11,0,110,111,105,115,101,51,0,1,1,0,11,
+120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,
+20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,
+99,51,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,0,46,0,0,20,0,9,18,95,95,
+114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,51,0,17,53,0,
+52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,0,0,46,0,0,20,0,0,1,0,0,11,0,110,111,105,
+115,101,51,0,1,1,0,12,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,
+101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,
+18,120,0,58,118,101,99,52,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,
+55,55,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,
+18,120,0,58,118,101,99,52,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,0,17,
+49,51,0,49,57,0,0,0,0,46,0,0,20,0,0,1,0,0,12,0,110,111,105,115,101,52,0,1,1,0,9,120,0,0,0,1,9,18,
95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,
114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,17,49,57,0,51,52,0,0,46,0,0,
20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,18,120,0,17,53,0,52,
-55,0,0,46,0,0,20,0,0,1,0,0,11,0,110,111,105,115,101,51,0,1,1,0,10,120,0,0,0,1,9,18,95,95,114,101,
-116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,
-97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,49,57,0,51,52,0,0,0,
-17,55,0,54,54,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,
-101,49,0,18,120,0,58,118,101,99,50,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,0,46,0,0,20,0,0,1,
-0,0,11,0,110,111,105,115,101,51,0,1,1,0,11,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,
-58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,
-111,105,115,101,49,0,18,120,0,58,118,101,99,51,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,
-0,50,51,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,
-0,18,120,0,58,118,101,99,51,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,0,0,
-46,0,0,20,0,0,1,0,0,11,0,110,111,105,115,101,51,0,1,1,0,12,120,0,0,0,1,9,18,95,95,114,101,116,86,
-97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
-59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,52,0,17,49,57,0,51,52,0,0,0,17,55,0,54,
-54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,55,55,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,
-59,122,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,52,0,17,53,0,52,55,0,0,0,17,49,55,0,56,
-53,0,0,0,17,49,49,0,48,52,0,0,0,17,49,51,0,49,57,0,0,0,0,46,0,0,20,0,0,1,0,0,12,0,110,111,105,115,
-101,52,0,1,1,0,9,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,
-0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,
-0,17,49,57,0,51,52,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,
-101,49,0,18,120,0,17,53,0,52,55,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,
-111,105,115,101,49,0,18,120,0,17,50,51,0,53,52,0,0,46,0,0,20,0,0,1,0,0,12,0,110,111,105,115,101,52,
-0,1,1,0,10,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,
-120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,
-118,101,99,50,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,
-97,108,0,59,122,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,53,0,52,55,0,0,0,17,
-49,55,0,56,53,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,
-101,49,0,18,120,0,58,118,101,99,50,0,17,50,51,0,53,52,0,0,0,17,50,57,0,49,49,0,0,0,0,46,0,0,20,0,0,
-1,0,0,12,0,110,111,105,115,101,52,0,1,1,0,11,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,
-0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,
-111,105,115,101,49,0,18,120,0,58,118,101,99,51,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,
-0,50,51,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,
-0,18,120,0,58,118,101,99,51,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,0,0,
-46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,101,49,0,18,120,0,58,
-118,101,99,51,0,17,50,51,0,53,52,0,0,0,17,50,57,0,49,49,0,0,0,17,51,49,0,57,49,0,0,0,0,46,0,0,20,0,
-0,1,0,0,12,0,110,111,105,115,101,52,0,1,1,0,12,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,
-120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,
-110,111,105,115,101,49,0,18,120,0,58,118,101,99,52,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,
-51,0,50,51,0,0,0,17,50,0,55,55,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,
-110,111,105,115,101,49,0,18,120,0,58,118,101,99,52,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,
-49,49,0,48,52,0,0,0,17,49,51,0,49,57,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,
-0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,52,0,17,50,51,0,53,52,0,0,0,17,50,57,0,49,49,
-0,0,0,17,51,49,0,57,49,0,0,0,17,51,55,0,52,56,0,0,0,0,46,0,0,20,0,0,0
+55,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,101,49,0,18,120,
+0,17,50,51,0,53,52,0,0,46,0,0,20,0,0,1,0,0,12,0,110,111,105,115,101,52,0,1,1,0,10,120,0,0,0,1,9,18,
+95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,49,0,18,120,0,0,0,20,0,9,18,95,95,
+114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,49,57,
+0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,
+111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,0,46,0,
+0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,
+99,50,0,17,50,51,0,53,52,0,0,0,17,50,57,0,49,49,0,0,0,0,46,0,0,20,0,0,1,0,0,12,0,110,111,105,115,
+101,52,0,1,1,0,11,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,101,
+49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,18,
+120,0,58,118,101,99,51,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,0,46,0,0,
+20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,
+99,51,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,0,0,46,0,0,20,0,9,18,95,95,
+114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,51,0,17,50,51,
+0,53,52,0,0,0,17,50,57,0,49,49,0,0,0,17,51,49,0,57,49,0,0,0,0,46,0,0,20,0,0,1,0,0,12,0,110,111,105,
+115,101,52,0,1,1,0,12,120,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,58,110,111,105,115,
+101,49,0,18,120,0,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,58,110,111,105,115,101,49,0,
+18,120,0,58,118,101,99,52,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,
+55,55,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,58,110,111,105,115,101,49,0,
+18,120,0,58,118,101,99,52,0,17,53,0,52,55,0,0,0,17,49,55,0,56,53,0,0,0,17,49,49,0,48,52,0,0,0,17,
+49,51,0,49,57,0,0,0,0,46,0,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,58,110,111,105,115,
+101,49,0,18,120,0,58,118,101,99,52,0,17,50,51,0,53,52,0,0,0,17,50,57,0,49,49,0,0,0,17,51,49,0,57,
+49,0,0,0,17,51,55,0,52,56,0,0,0,0,46,0,0,20,0,0,0
diff --git a/src/mesa/shader/slang/library/slang_vertex_builtin.gc b/src/mesa/shader/slang/library/slang_vertex_builtin.gc
index 20c924a..17e86d9 100644
--- a/src/mesa/shader/slang/library/slang_vertex_builtin.gc
+++ b/src/mesa/shader/slang/library/slang_vertex_builtin.gc
@@ -57,7 +57,10 @@ varying float gl_FogFragCoord;
vec4 ftransform()
{
- __retVal = gl_Vertex * gl_ModelViewProjectionMatrixTranspose;
+ __retVal = gl_ModelViewProjectionMatrix[0] * gl_Vertex.xxxx
+ + gl_ModelViewProjectionMatrix[1] * gl_Vertex.yyyy
+ + gl_ModelViewProjectionMatrix[2] * gl_Vertex.zzzz
+ + gl_ModelViewProjectionMatrix[3] * gl_Vertex.wwww;
}
diff --git a/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h b/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h
index 1a08a54..63d33af 100644
--- a/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h
+++ b/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h
@@ -20,75 +20,81 @@
0,2,2,3,0,12,1,103,108,95,84,101,120,67,111,111,114,100,0,3,18,103,108,95,77,97,120,84,101,120,116,
117,114,101,67,111,111,114,100,115,0,0,0,2,2,3,0,9,1,103,108,95,70,111,103,70,114,97,103,67,111,
111,114,100,0,0,0,1,0,0,12,0,102,116,114,97,110,115,102,111,114,109,0,0,1,9,18,95,95,114,101,116,
-86,97,108,0,18,103,108,95,86,101,114,116,101,120,0,18,103,108,95,77,111,100,101,108,86,105,101,119,
-80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,84,114,97,110,115,112,111,115,101,0,48,
-20,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,76,111,100,0,1,1,0,16,115,97,109,112,108,101,
-114,0,0,1,1,0,9,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,
-52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,
-100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,
-101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,
-0,116,101,120,116,117,114,101,49,68,80,114,111,106,76,111,100,0,1,1,0,16,115,97,109,112,108,101,
-114,0,0,1,1,0,10,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,
-114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,
-111,114,100,0,59,121,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,
-101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
-114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,
-106,76,111,100,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,
-108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,
-0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,
-114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,
-101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,
-0,116,101,120,116,117,114,101,50,68,76,111,100,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,10,
-99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,
-99,111,111,114,100,52,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,20,0,9,18,99,111,111,114,
-100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,
-101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,
-0,116,101,120,116,117,114,101,50,68,80,114,111,106,76,111,100,0,1,1,0,17,115,97,109,112,108,101,
-114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,
-114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,
-99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,
-4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,
-108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,80,
-114,111,106,76,111,100,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,
-1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,
-59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,
-112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,
-18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,
-0,0,1,0,0,12,0,116,101,120,116,117,114,101,51,68,76,111,100,0,1,1,0,18,115,97,109,112,108,101,114,
-0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,
-0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,121,122,0,20,0,
-9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,51,
-100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,
-52,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,76,111,100,0,1,1,0,18,115,
-97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,
-1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,122,0,18,99,111,111,114,
-100,0,59,120,121,122,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,
-119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,51,100,0,18,95,95,114,101,116,86,97,
-108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,
-116,117,114,101,67,117,98,101,76,111,100,0,1,1,0,19,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,
-111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,
-111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,
-0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,95,95,114,101,116,86,97,
-108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,
-100,111,119,49,68,76,111,100,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,
-0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,
-52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,
+86,97,108,0,18,103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,
+77,97,116,114,105,120,0,16,8,48,0,57,18,103,108,95,86,101,114,116,101,120,0,59,120,120,120,120,0,
+48,18,103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,
+114,105,120,0,16,10,49,0,57,18,103,108,95,86,101,114,116,101,120,0,59,121,121,121,121,0,48,46,18,
+103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,
+105,120,0,16,10,50,0,57,18,103,108,95,86,101,114,116,101,120,0,59,122,122,122,122,0,48,46,18,103,
+108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,
+120,0,16,10,51,0,57,18,103,108,95,86,101,114,116,101,120,0,59,119,119,119,119,0,48,46,20,0,0,1,0,0,
+12,0,116,101,120,116,117,114,101,49,68,76,111,100,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,
+9,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,
+99,111,111,114,100,52,0,59,120,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,
+0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,
+0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,116,101,120,116,
+117,114,101,49,68,80,114,111,106,76,111,100,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,10,99,
+111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,
+99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,121,0,49,
+20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,
+98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,
+114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,76,111,100,0,1,1,0,16,
+115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,
+12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,
+59,120,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,
111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,
-115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,
-49,68,80,114,111,106,76,111,100,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,
-100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,
-114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,
-112,99,111,111,114,100,0,59,122,0,18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,
-100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,
-116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,
-115,104,97,100,111,119,50,68,76,111,100,0,1,1,0,21,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,
-111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,
-111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,
-0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,
-0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,
-111,119,50,68,80,114,111,106,76,111,100,0,1,1,0,21,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,
+115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,
+114,101,50,68,76,111,100,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,10,99,111,111,114,100,0,0,
+1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,
+59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,
+108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,
+18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,116,101,120,116,117,
+114,101,50,68,80,114,111,106,76,111,100,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,
111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,
-111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,119,
-0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,
-111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,
-95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,0
+111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,122,
+0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,
+120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,
+111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,76,111,100,0,1,1,0,
+17,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,
+0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,
+100,0,59,120,121,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,
+18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,
+0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,
+117,114,101,51,68,76,111,100,0,1,1,0,18,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,
+0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,
+52,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,121,122,0,20,0,9,18,99,111,111,114,100,52,0,
+59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,51,100,0,18,95,95,114,101,116,86,
+97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,116,101,
+120,116,117,114,101,51,68,80,114,111,106,76,111,100,0,1,1,0,18,115,97,109,112,108,101,114,0,0,1,1,
+0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,
+9,18,112,99,111,111,114,100,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,121,122,0,18,99,111,
+111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,
+101,99,52,95,116,101,120,98,51,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
+114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,67,117,98,101,76,
+111,100,0,1,1,0,19,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,
+100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,
+18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,
+99,52,95,116,101,120,99,117,98,101,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
+114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,49,68,76,111,100,0,1,1,
+0,20,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,
+2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,
+114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,
+101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
+111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,49,68,80,114,111,106,76,111,100,0,1,1,0,
+20,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,
+0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,
+0,59,120,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,
+111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,
+101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
+114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,76,111,100,0,1,1,
+0,21,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,
+2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,
+114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,
+101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
+111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,76,111,100,0,1,1,0,
+21,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,
+0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,
+100,0,59,120,121,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,
+18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,
+4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,
+108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,0
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index db25106..7006e86 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1481,7 +1481,7 @@ _slang_simple_writemask(GLuint writemask, GLuint swizzle)
* \return GL_FALSE for simple writemasks, GL_TRUE for non-simple
*/
static GLboolean
-swizzle_to_writemask(GLuint swizzle,
+swizzle_to_writemask(slang_assemble_ctx *A, GLuint swizzle,
GLuint *writemaskOut, GLuint *swizzleOut)
{
GLuint mask = 0x0, newSwizzle[4];
@@ -1495,6 +1495,18 @@ swizzle_to_writemask(GLuint swizzle,
break;
}
assert(swz >= 0 && swz <= 3);
+
+ if (swizzle != SWIZZLE_XXXX &&
+ swizzle != SWIZZLE_YYYY &&
+ swizzle != SWIZZLE_ZZZZ &&
+ swizzle != SWIZZLE_WWWW &&
+ (mask & (1 << swz))) {
+ /* a channel can't be specified twice (ex: ".xyyz") */
+ slang_info_log_error(A->log, "Invalid writemask '%s'",
+ _mesa_swizzle_string(swizzle, 0, 0));
+ return GL_FALSE;
+ }
+
mask |= (1 << swz);
}
assert(mask <= 0xf);
@@ -1590,11 +1602,11 @@ resolve_swizzle(const slang_operation *oper)
* As above, but produce a writemask.
*/
static GLuint
-resolve_writemask(const slang_operation *oper)
+resolve_writemask(slang_assemble_ctx *A, const slang_operation *oper)
{
GLuint swizzle = resolve_swizzle(oper);
GLuint writemask, swizzleOut;
- swizzle_to_writemask(swizzle, &writemask, &swizzleOut);
+ swizzle_to_writemask(A, swizzle, &writemask, &swizzleOut);
return writemask;
}
@@ -1668,7 +1680,7 @@ _slang_gen_asm(slang_assemble_ctx *A, slang_operation *oper,
dest_oper = &oper->children[0];
- writemask = resolve_writemask(dest_oper);
+ writemask = resolve_writemask(A, dest_oper);
n0 = _slang_gen_operation(A, dest_oper);
if (!n0)
@@ -1980,6 +1992,12 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
fun = _slang_locate_struct_constructor(A, name);
}
+ /*
+ * At this point, some heuristics are used to try to find a function
+ * that matches the calling signature by means of casting or "unrolling"
+ * of constructors.
+ */
+
if (!fun && _slang_is_vec_mat_type(name)) {
/* Next, if this call looks like a vec() or mat() constructor call,
* try "unwinding" the args to satisfy a constructor.
@@ -1995,7 +2013,7 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
}
}
- if (!fun) {
+ if (!fun && _slang_is_vec_mat_type(name)) {
/* Next, try casting args to the types of the formal parameters */
int numArgs = oper->num_children;
fun = _slang_find_function_by_argc(A->space.funcs, name, numArgs);
@@ -2008,6 +2026,13 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
assert(fun);
}
+ if (!fun) {
+ slang_info_log_error(A->log,
+ "Function '%s' not found (check argument types)",
+ name);
+ return NULL;
+ }
+
n = _slang_gen_function_call(A, fun, oper, dest);
if (n && !n->Store && !dest
@@ -2716,7 +2741,11 @@ _slang_assignment_compatible(slang_assemble_ctx *A,
slang_typeinfo t0, t1;
GLuint sz0, sz1;
-
+ if (op0->type == SLANG_OPER_POSTINCREMENT ||
+ op0->type == SLANG_OPER_POSTDECREMENT) {
+ return GL_FALSE;
+ }
+
slang_typeinfo_construct(&t0);
_slang_typeof_operation(A, op0, &t0);
@@ -3020,7 +3049,7 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
if (lhs && rhs) {
/* convert lhs swizzle into writemask */
GLuint writemask, newSwizzle;
- if (!swizzle_to_writemask(lhs->Store->Swizzle,
+ if (!swizzle_to_writemask(A, lhs->Store->Swizzle,
&writemask, &newSwizzle)) {
/* Non-simple writemask, need to swizzle right hand side in
* order to put components into the right place.
@@ -3727,6 +3756,8 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
if (dbg) printf("UNIFORM (sz %d) ", totalSize);
}
else if (var->type.qualifier == SLANG_QUAL_VARYING) {
+ const GLint totalSize = array_size(size, var->array_len);
+
/* varyings must be float, vec or mat */
if (!_slang_type_is_float_vec_mat(var->type.specifier.type) &&
var->type.specifier.type != SLANG_SPEC_ARRAY) {
@@ -3744,10 +3775,10 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
if (prog) {
/* user-defined varying */
- GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, size);
+ GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, totalSize);
GLuint swizzle = _slang_var_swizzle(size, 0);
store = _slang_new_ir_storage_swz(PROGRAM_VARYING, varyingLoc,
- size, swizzle);
+ totalSize, swizzle);
}
else {
/* pre-defined varying, like gl_Color or gl_TexCoord */
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index f0c3791..9e8daa1 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -108,7 +108,9 @@ writemask_to_swizzle(GLuint writemask)
/**
- * Swizzle a swizzle. That is, return swz2(swz1)
+ * Swizzle a swizzle (function composition).
+ * That is, return swz2(swz1), or said another way: swz1.szw2
+ * Example: swizzle_swizzle(".zwxx", ".xxyw") yields ".zzwx"
*/
GLuint
_slang_swizzle_swizzle(GLuint swz1, GLuint swz2)
@@ -279,7 +281,7 @@ storage_to_src_reg(struct prog_src_register *src, const slang_ir_storage *st)
while (st->Parent) {
st = st->Parent;
index += st->Index;
- swizzle = _slang_swizzle_swizzle(st->Swizzle, swizzle);
+ swizzle = _slang_swizzle_swizzle(fix_swizzle(st->Swizzle), swizzle);
}
assert(st->File >= 0);
@@ -1636,6 +1638,88 @@ emit_struct_field(slang_emit_info *emitInfo, slang_ir_node *n)
}
+/**
+ * Emit code for a variable declaration.
+ * This usually doesn't result in any code generation, but just
+ * memory allocation.
+ */
+static struct prog_instruction *
+emit_var_decl(slang_emit_info *emitInfo, slang_ir_node *n)
+{
+ struct prog_instruction *inst;
+
+ assert(n->Store);
+ assert(n->Store->File != PROGRAM_UNDEFINED);
+ assert(n->Store->Size > 0);
+ /*assert(n->Store->Index < 0);*/
+
+ if (!n->Var || n->Var->isTemp) {
+ /* a nameless/temporary variable, will be freed after first use */
+ /*NEW*/
+ if (n->Store->Index < 0 && !_slang_alloc_temp(emitInfo->vt, n->Store)) {
+ slang_info_log_error(emitInfo->log,
+ "Ran out of registers, too many temporaries");
+ return NULL;
+ }
+ }
+ else {
+ /* a regular variable */
+ _slang_add_variable(emitInfo->vt, n->Var);
+ if (!_slang_alloc_var(emitInfo->vt, n->Store)) {
+ slang_info_log_error(emitInfo->log,
+ "Ran out of registers, too many variables");
+ return NULL;
+ }
+ /*
+ printf("IR_VAR_DECL %s %d store %p\n",
+ (char*) n->Var->a_name, n->Store->Index, (void*) n->Store);
+ */
+ assert(n->Var->aux == n->Store);
+ }
+ if (emitInfo->EmitComments) {
+ /* emit NOP with comment describing the variable's storage location */
+ char s[1000];
+ sprintf(s, "TEMP[%d]%s = variable %s (size %d)",
+ n->Store->Index,
+ _mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
+ (n->Var ? (char *) n->Var->a_name : "anonymous"),
+ n->Store->Size);
+ inst = emit_comment(emitInfo, s);
+ return inst;
+ }
+ return NULL;
+}
+
+
+/**
+ * Emit code for a reference to a variable.
+ * Actually, no code is generated but we may do some memory alloation.
+ * In particular, state vars (uniforms) are allocated on an as-needed basis.
+ */
+static struct prog_instruction *
+emit_var_ref(slang_emit_info *emitInfo, slang_ir_node *n)
+{
+ assert(n->Store);
+ assert(n->Store->File != PROGRAM_UNDEFINED);
+
+ if (n->Store->File == PROGRAM_STATE_VAR && n->Store->Index < 0) {
+ n->Store->Index = _slang_alloc_statevar(n, emitInfo->prog->Parameters);
+ }
+ else if (n->Store->File == PROGRAM_UNIFORM) {
+ /* mark var as used */
+ _mesa_use_uniform(emitInfo->prog->Parameters, (char *) n->Var->a_name);
+ }
+
+ if (n->Store->Index < 0) {
+ /* probably ran out of registers */
+ return NULL;
+ }
+ assert(n->Store->Size > 0);
+
+ return NULL;
+}
+
+
static struct prog_instruction *
emit(slang_emit_info *emitInfo, slang_ir_node *n)
{
@@ -1671,64 +1755,14 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
case IR_VAR_DECL:
/* Variable declaration - allocate a register for it */
- assert(n->Store);
- assert(n->Store->File != PROGRAM_UNDEFINED);
- assert(n->Store->Size > 0);
- /*assert(n->Store->Index < 0);*/
- if (!n->Var || n->Var->isTemp) {
- /* a nameless/temporary variable, will be freed after first use */
- /*NEW*/
- if (n->Store->Index < 0 && !_slang_alloc_temp(emitInfo->vt, n->Store)) {
- slang_info_log_error(emitInfo->log,
- "Ran out of registers, too many temporaries");
- return NULL;
- }
- }
- else {
- /* a regular variable */
- _slang_add_variable(emitInfo->vt, n->Var);
- if (!_slang_alloc_var(emitInfo->vt, n->Store)) {
- slang_info_log_error(emitInfo->log,
- "Ran out of registers, too many variables");
- return NULL;
- }
- /*
- printf("IR_VAR_DECL %s %d store %p\n",
- (char*) n->Var->a_name, n->Store->Index, (void*) n->Store);
- */
- assert(n->Var->aux == n->Store);
- }
- if (emitInfo->EmitComments) {
- /* emit NOP with comment describing the variable's storage location */
- char s[1000];
- sprintf(s, "TEMP[%d]%s = variable %s (size %d)",
- n->Store->Index,
- _mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
- (n->Var ? (char *) n->Var->a_name : "anonymous"),
- n->Store->Size);
- inst = emit_comment(emitInfo, s);
- return inst;
- }
- return NULL;
+ inst = emit_var_decl(emitInfo, n);
+ return inst;
case IR_VAR:
/* Reference to a variable
* Storage should have already been resolved/allocated.
*/
- assert(n->Store);
- assert(n->Store->File != PROGRAM_UNDEFINED);
-
- if (n->Store->File == PROGRAM_STATE_VAR &&
- n->Store->Index < 0) {
- n->Store->Index = _slang_alloc_statevar(n, emitInfo->prog->Parameters);
- }
-
- if (n->Store->Index < 0) {
- /* probably ran out of registers */
- return NULL;
- }
- assert(n->Store->Size > 0);
- break;
+ return emit_var_ref(emitInfo, n);
case IR_ELEMENT:
return emit_array_element(emitInfo, n);
@@ -1939,6 +1973,7 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt,
GET_CURRENT_CONTEXT(ctx);
GLboolean success;
slang_emit_info emitInfo;
+ GLuint maxUniforms;
emitInfo.log = log;
emitInfo.vt = vt;
@@ -1955,6 +1990,19 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt,
emitInfo.EmitHighLevelInstructions = GL_TRUE;
}
+ /* Check uniform/constant limits */
+ if (prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
+ maxUniforms = ctx->Const.FragmentProgram.MaxUniformComponents / 4;
+ }
+ else {
+ assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
+ maxUniforms = ctx->Const.VertexProgram.MaxUniformComponents / 4;
+ }
+ if (prog->Parameters->NumParameters > maxUniforms) {
+ slang_info_log_error(log, "Constant/uniform register limit exceeded");
+ return GL_FALSE;
+ }
+
(void) emit(&emitInfo, n);
/* finish up by adding the END opcode to program */
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index d96380e..57dbfc2 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -42,6 +42,20 @@
#include "slang_link.h"
+/**
+ * Record a linking error.
+ */
+static void
+link_error(struct gl_shader_program *shProg, const char *msg)
+{
+ if (shProg->InfoLog) {
+ _mesa_free(shProg->InfoLog);
+ }
+ shProg->InfoLog = _mesa_strdup(msg);
+ shProg->LinkStatus = GL_FALSE;
+}
+
+
/**
* Linking varying vars involves rearranging varying vars so that the
@@ -52,7 +66,6 @@ static GLboolean
link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
{
GLuint *map, i, firstVarying, newFile;
- GLbitfield varsWritten, varsRead;
map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint));
if (!map)
@@ -60,14 +73,13 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
for (i = 0; i < prog->Varying->NumParameters; i++) {
/* see if this varying is in the linked varying list */
- const struct gl_program_parameter *var
- = prog->Varying->Parameters + i;
-
+ const struct gl_program_parameter *var = prog->Varying->Parameters + i;
GLint j = _mesa_lookup_parameter_index(shProg->Varying, -1, var->Name);
if (j >= 0) {
/* already in list, check size */
if (var->Size != shProg->Varying->Parameters[j].Size) {
/* error */
+ link_error(shProg, "mismatched varying variable types");
return GL_FALSE;
}
}
@@ -75,9 +87,19 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
/* not already in linked list */
j = _mesa_add_varying(shProg->Varying, var->Name, var->Size);
}
- ASSERT(j >= 0);
- map[i] = j;
+ /* map varying[i] to varying[j].
+ * Note: the loop here takes care of arrays or large (sz>4) vars.
+ */
+ {
+ GLint sz = var->Size;
+ while (sz > 0) {
+ /*printf("Link varying from %d to %d\n", i, j);*/
+ map[i++] = j++;
+ sz -= 4;
+ }
+ i--; /* go back one */
+ }
}
@@ -96,9 +118,6 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
newFile = PROGRAM_INPUT;
}
- /* keep track of which varying vars we read and write */
- varsWritten = varsRead = 0x0;
-
/* OK, now scan the program/shader instructions looking for varying vars,
* replacing the old index with the new index.
*/
@@ -109,30 +128,22 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
if (inst->DstReg.File == PROGRAM_VARYING) {
inst->DstReg.File = newFile;
inst->DstReg.Index = map[ inst->DstReg.Index ] + firstVarying;
- varsWritten |= (1 << inst->DstReg.Index);
}
for (j = 0; j < 3; j++) {
if (inst->SrcReg[j].File == PROGRAM_VARYING) {
inst->SrcReg[j].File = newFile;
inst->SrcReg[j].Index = map[ inst->SrcReg[j].Index ] + firstVarying;
- varsRead |= (1 << inst->SrcReg[j].Index);
}
}
}
- if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
- prog->OutputsWritten |= varsWritten;
- /*printf("VERT OUTPUTS: 0x%x \n", varsWritten);*/
- }
- else {
- assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB);
- prog->InputsRead |= varsRead;
- /*printf("FRAG INPUTS: 0x%x\n", varsRead);*/
- }
-
free(map);
+ /* these will get recomputed before linking is completed */
+ prog->InputsRead = 0x0;
+ prog->OutputsWritten = 0x0;
+
return GL_TRUE;
}
@@ -162,7 +173,7 @@ link_uniform_vars(struct gl_shader_program *shProg,
* Furthermore, we'll need to fix the state-var's size/datatype info.
*/
- if (p->Type == PROGRAM_UNIFORM ||
+ if ((p->Type == PROGRAM_UNIFORM && p->Used) ||
p->Type == PROGRAM_SAMPLER) {
_mesa_append_uniform(shProg->Uniforms, p->Name, prog->Target, i);
}
@@ -382,21 +393,6 @@ fragment_program(struct gl_program *prog)
/**
- * Record a linking error.
- */
-static void
-link_error(struct gl_shader_program *shProg, const char *msg)
-{
- if (shProg->InfoLog) {
- _mesa_free(shProg->InfoLog);
- }
- shProg->InfoLog = _mesa_strdup(msg);
- shProg->LinkStatus = GL_FALSE;
-}
-
-
-
-/**
* Shader linker. Currently:
*
* 1. The last attached vertex shader and fragment shader are linked.
@@ -478,10 +474,14 @@ _slang_link(GLcontext *ctx,
}
/* link varying vars */
- if (shProg->VertexProgram)
- link_varying_vars(shProg, &shProg->VertexProgram->Base);
- if (shProg->FragmentProgram)
- link_varying_vars(shProg, &shProg->FragmentProgram->Base);
+ if (shProg->VertexProgram) {
+ if (!link_varying_vars(shProg, &shProg->VertexProgram->Base))
+ return;
+ }
+ if (shProg->FragmentProgram) {
+ if (!link_varying_vars(shProg, &shProg->FragmentProgram->Base))
+ return;
+ }
/* link uniform vars */
if (shProg->VertexProgram)
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index 0e0e109..14fd859 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -187,6 +187,7 @@ STATETRACKER_SOURCES = \
state_tracker/st_cb_bufferobjects.c \
state_tracker/st_cb_clear.c \
state_tracker/st_cb_flush.c \
+ state_tracker/st_cb_get.c \
state_tracker/st_cb_drawpixels.c \
state_tracker/st_cb_fbo.c \
state_tracker/st_cb_feedback.c \
diff --git a/src/mesa/state_tracker/acc2.c b/src/mesa/state_tracker/acc2.c
new file mode 100644
index 0000000..fa5de2b
--- /dev/null
+++ b/src/mesa/state_tracker/acc2.c
@@ -0,0 +1,319 @@
+/**************************************************************************
+ *
+ * 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:
+ * Brian Paul
+ */
+
+#include "main/imports.h"
+#include "main/image.h"
+#include "main/macros.h"
+
+#include "st_context.h"
+#include "st_cb_accum.h"
+#include "st_cb_fbo.h"
+#include "st_draw.h"
+#include "st_format.h"
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+#include "util/p_tile.h"
+
+
+#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \
+ us = ( (short) ( CLAMP((f), -1.0, 1.0) * 32767.0F) )
+
+
+/**
+ * For hardware that supports deep color buffers, we could accelerate
+ * most/all the accum operations with blending/texturing.
+ * For now, just use the get/put_tile() functions and do things in software.
+ */
+
+
+static void
+acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps,
+ uint x, uint y, uint w, uint h, float *p)
+{
+ const enum pipe_format f = acc_ps->format;
+ const int cpp = acc_ps->cpp;
+
+ acc_ps->format = PIPE_FORMAT_R16G16B16A16_SNORM;
+ acc_ps->cpp = 8;
+
+ pipe_get_tile_rgba(pipe, acc_ps, x, y, w, h, p);
+
+ acc_ps->format = f;
+ acc_ps->cpp = cpp;
+}
+
+
+static void
+acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps,
+ uint x, uint y, uint w, uint h, const float *p)
+{
+ enum pipe_format f = acc_ps->format;
+ const int cpp = acc_ps->cpp;
+
+ acc_ps->format = PIPE_FORMAT_R16G16B16A16_SNORM;
+ acc_ps->cpp = 8;
+
+ pipe_put_tile_rgba(pipe, acc_ps, x, y, w, h, p);
+
+ acc_ps->format = f;
+ acc_ps->cpp = cpp;
+}
+
+
+
+void
+st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
+{
+ struct pipe_context *pipe = ctx->st->pipe;
+ struct st_renderbuffer *acc_strb = st_renderbuffer(rb);
+ struct pipe_surface *acc_ps = acc_strb->surface;
+ const GLint xpos = ctx->DrawBuffer->_Xmin;
+ const GLint ypos = ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - xpos;
+ const GLint height = ctx->DrawBuffer->_Ymax - ypos;
+ const GLfloat r = ctx->Accum.ClearColor[0];
+ const GLfloat g = ctx->Accum.ClearColor[1];
+ const GLfloat b = ctx->Accum.ClearColor[2];
+ const GLfloat a = ctx->Accum.ClearColor[3];
+ GLfloat *accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+ int i;
+
+#if 1
+ GLvoid *map;
+
+ map = pipe_surface_map(acc_ps);
+ switch (acc_strb->format) {
+ case PIPE_FORMAT_R16G16B16A16_SNORM:
+ {
+ GLshort r = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]);
+ GLshort g = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]);
+ GLshort b = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]);
+ GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]);
+ int i, j;
+ for (i = 0; i < height; i++) {
+ GLshort *dst = ((GLshort *) map
+ + ((ypos + i) * acc_ps->pitch + xpos) * 4);
+ for (j = 0; j < width; j++) {
+ dst[0] = r;
+ dst[1] = g;
+ dst[2] = b;
+ dst[3] = a;
+ dst += 4;
+ }
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()");
+ }
+
+ pipe_surface_unmap(acc_ps);
+
+#else
+ for (i = 0; i < width * height; i++) {
+ accBuf[i*4+0] = r;
+ accBuf[i*4+1] = g;
+ accBuf[i*4+2] = b;
+ accBuf[i*4+3] = a;
+ }
+
+ acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+#endif
+}
+
+
+/** For ADD/MULT */
+static void
+accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias,
+ GLint xpos, GLint ypos, GLint width, GLint height,
+ struct pipe_surface *acc_ps)
+{
+ GLfloat *accBuf;
+ GLint i;
+
+ accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+
+ pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+
+ for (i = 0; i < 4 * width * height; i++) {
+ accBuf[i] = accBuf[i] * scale + bias;
+ }
+
+ pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+
+ free(accBuf);
+}
+
+
+static void
+accum_accum(struct pipe_context *pipe, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height,
+ struct pipe_surface *acc_ps,
+ struct pipe_surface *color_ps)
+{
+ GLfloat *colorBuf, *accBuf;
+ GLint i;
+
+ colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+ accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+
+ pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf);
+ acc_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+
+ for (i = 0; i < 4 * width * height; i++) {
+ accBuf[i] = accBuf[i] + colorBuf[i] * value;
+ }
+
+ acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+
+ free(colorBuf);
+ free(accBuf);
+}
+
+
+static void
+accum_load(struct pipe_context *pipe, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height,
+ struct pipe_surface *acc_ps,
+ struct pipe_surface *color_ps)
+{
+ GLfloat *buf;
+ GLint i;
+
+ buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+
+ pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf);
+
+ for (i = 0; i < 4 * width * height; i++) {
+ buf[i] = buf[i] * value;
+ }
+
+ acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf);
+
+ free(buf);
+}
+
+
+static void
+accum_return(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height,
+ struct pipe_surface *acc_ps,
+ struct pipe_surface *color_ps)
+{
+ struct pipe_context *pipe = ctx->st->pipe;
+ const GLubyte *colormask = ctx->Color.ColorMask;
+ GLfloat *abuf, *cbuf = NULL;
+ GLint i, ch;
+
+ abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+
+ acc_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf);
+
+ if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) {
+ cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+ pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf);
+ }
+
+ for (i = 0; i < width * height; i++) {
+ for (ch = 0; ch < 4; ch++) {
+ if (colormask[ch]) {
+ GLfloat val = abuf[i * 4 + ch] * value;
+ abuf[i * 4 + ch] = CLAMP(val, 0.0, 1.0);
+ }
+ else {
+ abuf[i * 4 + ch] = cbuf[i * 4 + ch];
+ }
+ }
+ }
+
+ pipe_put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf);
+
+ free(abuf);
+ if (cbuf)
+ free(cbuf);
+}
+
+
+static void
+st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
+{
+ struct st_context *st = ctx->st;
+ struct pipe_context *pipe = st->pipe;
+ struct st_renderbuffer *acc_strb
+ = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
+ struct st_renderbuffer *color_strb
+ = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
+ struct pipe_surface *acc_ps = acc_strb->surface;
+ struct pipe_surface *color_ps = color_strb->surface;
+
+ const GLint xpos = ctx->DrawBuffer->_Xmin;
+ const GLint ypos = ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - xpos;
+ const GLint height = ctx->DrawBuffer->_Ymax - ypos;
+
+ /* make sure color bufs aren't cached */
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+ switch (op) {
+ case GL_ADD:
+ if (value != 0.0F) {
+ accum_mad(pipe, 1.0, value, xpos, ypos, width, height, acc_ps);
+ }
+ break;
+ case GL_MULT:
+ if (value != 1.0F) {
+ accum_mad(pipe, value, 0.0, xpos, ypos, width, height, acc_ps);
+ }
+ break;
+ case GL_ACCUM:
+ if (value != 0.0F) {
+ accum_accum(pipe, value, xpos, ypos, width, height, acc_ps, color_ps);
+ }
+ break;
+ case GL_LOAD:
+ accum_load(pipe, value, xpos, ypos, width, height, acc_ps, color_ps);
+ break;
+ case GL_RETURN:
+ accum_return(ctx, value, xpos, ypos, width, height, acc_ps, color_ps);
+ break;
+ default:
+ assert(0);
+ }
+}
+
+
+
+void st_init_accum_functions(struct dd_function_table *functions)
+{
+ functions->Accum = st_Accum;
+}
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 2856e0f..d02e51c 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -73,8 +73,8 @@ void st_upload_constants( struct st_context *st,
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization.
*/
- pipe_reference_buffer(pipe, &cbuf->buffer, NULL );
- cbuf->buffer = pipe_buffer_create(pipe, 1, PIPE_BUFFER_USAGE_CONSTANT,
+ pipe_buffer_reference(pipe->screen, &cbuf->buffer, NULL );
+ cbuf->buffer = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT,
paramBytes );
if (0)
@@ -86,10 +86,10 @@ void st_upload_constants( struct st_context *st,
/* load Mesa constants into the constant buffer */
if (cbuf->buffer) {
- void *map = pipe_buffer_map(pipe, cbuf->buffer,
+ void *map = pipe_buffer_map(pipe->screen, cbuf->buffer,
PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(map, params->ParameterValues, paramBytes);
- pipe_buffer_unmap(pipe, cbuf->buffer);
+ pipe_buffer_unmap(pipe->screen, cbuf->buffer);
}
cbuf->size = paramBytes;
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 3ba6a97..cef61fb 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -35,6 +35,7 @@
#include "main/macros.h"
#include "st_context.h"
+#include "st_cb_texture.h"
#include "st_atom.h"
#include "st_program.h"
#include "pipe/p_context.h"
@@ -125,6 +126,8 @@ update_samplers(struct st_context *st)
st->state.num_samplers = 0;
+ /*printf("%s samplers used = 0x%x\n", __FUNCTION__, fs->Base.Base.SamplersUsed);*/
+
/* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
struct pipe_sampler_state *sampler = st->state.samplers + su;
@@ -136,8 +139,9 @@ update_samplers(struct st_context *st)
const struct gl_texture_object *texobj
= st->ctx->Texture.Unit[texUnit]._Current;
- if (!texobj)
- continue;
+ if (!texobj) {
+ texobj = st_get_default_texture(st);
+ }
sampler->wrap_s = gl_wrap_to_sp(texobj->WrapS);
sampler->wrap_t = gl_wrap_to_sp(texobj->WrapT);
@@ -184,11 +188,11 @@ update_samplers(struct st_context *st)
st->state.num_samplers = su + 1;
- /* XXX more sampler state here */
-
+ /*printf("%s su=%u non-null\n", __FUNCTION__, su);*/
cso_single_sampler(st->cso_context, su, sampler);
}
else {
+ /*printf("%s su=%u null\n", __FUNCTION__, su);*/
cso_single_sampler(st->cso_context, su, NULL);
}
}
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 4fa304e..cbd414e 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -39,6 +39,7 @@
#include "main/imports.h"
#include "main/mtypes.h"
+#include "main/macros.h"
#include "shader/program.h"
#include "pipe/p_context.h"
@@ -71,6 +72,8 @@ struct translated_vertex_program
/** Maps VERT_RESULT_x to slot */
GLuint output_to_slot[VERT_RESULT_MAX];
+ ubyte output_to_semantic_name[VERT_RESULT_MAX];
+ ubyte output_to_semantic_index[VERT_RESULT_MAX];
/** Pointer to the translated vertex program */
struct st_vertex_program *vp;
@@ -176,17 +179,22 @@ find_translated_vp(struct st_context *st,
const GLbitfield outputsWritten = stvp->Base.Base.OutputsWritten;
GLuint numVpOuts = 0;
GLboolean emitPntSize = GL_FALSE, emitBFC0 = GL_FALSE, emitBFC1 = GL_FALSE;
+ GLint maxGeneric;
/* Compute mapping of vertex program outputs to slots, which depends
* on the fragment program's input->slot mapping.
*/
for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
- /* set default: */
+ /* set defaults: */
xvp->output_to_slot[outAttr] = UNUSED;
+ xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_COUNT;
+ xvp->output_to_semantic_index[outAttr] = 99;
if (outAttr == VERT_RESULT_HPOS) {
/* always put xformed position into slot zero */
xvp->output_to_slot[VERT_RESULT_HPOS] = 0;
+ xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_POSITION;
+ xvp->output_to_semantic_index[outAttr] = 0;
numVpOuts++;
}
else if (outputsWritten & (1 << outAttr)) {
@@ -195,8 +203,11 @@ find_translated_vp(struct st_context *st,
if (fpInAttrib >= 0) {
GLuint fpInSlot = stfp->input_to_slot[fpInAttrib];
if (fpInSlot != ~0) {
+ /* match this vp output to the fp input */
GLuint vpOutSlot = stfp->input_map[fpInSlot];
xvp->output_to_slot[outAttr] = vpOutSlot;
+ xvp->output_to_semantic_name[outAttr] = stfp->input_semantic_name[fpInSlot];
+ xvp->output_to_semantic_index[outAttr] = stfp->input_semantic_index[fpInSlot];
numVpOuts++;
}
}
@@ -208,19 +219,27 @@ find_translated_vp(struct st_context *st,
emitBFC1 = GL_TRUE;
}
#if 0 /*debug*/
- printf("assign output_to_slot[%d] = %d\n", outAttr,
+ printf("assign vp output_to_slot[%d] = %d\n", outAttr,
xvp->output_to_slot[outAttr]);
#endif
}
/* must do these last */
- if (emitPntSize)
+ if (emitPntSize) {
xvp->output_to_slot[VERT_RESULT_PSIZ] = numVpOuts++;
- if (emitBFC0)
+ xvp->output_to_semantic_name[VERT_RESULT_PSIZ] = TGSI_SEMANTIC_PSIZE;
+ xvp->output_to_semantic_index[VERT_RESULT_PSIZ] = 0;
+ }
+ if (emitBFC0) {
xvp->output_to_slot[VERT_RESULT_BFC0] = numVpOuts++;
- if (emitBFC1)
+ xvp->output_to_semantic_name[VERT_RESULT_BFC0] = TGSI_SEMANTIC_COLOR;
+ xvp->output_to_semantic_index[VERT_RESULT_BFC0] = 0;
+ }
+ if (emitBFC1) {
xvp->output_to_slot[VERT_RESULT_BFC1] = numVpOuts++;
-
+ xvp->output_to_semantic_name[VERT_RESULT_BFC0] = TGSI_SEMANTIC_COLOR;
+ xvp->output_to_semantic_index[VERT_RESULT_BFC0] = 1;
+ }
/* Unneeded vertex program outputs will go to this slot.
* We could use this info to do dead code elimination in the
@@ -228,22 +247,38 @@ find_translated_vp(struct st_context *st,
*/
dummySlot = numVpOuts;
- /* Map vert program outputs that aren't used to the dummy slot */
+ /* find max GENERIC slot index */
+ maxGeneric = -1;
+ for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
+ if (xvp->output_to_semantic_name[outAttr] == TGSI_SEMANTIC_GENERIC) {
+ maxGeneric = MAX2(maxGeneric,
+ xvp->output_to_semantic_index[outAttr]);
+ }
+ }
+
+ /* Map vert program outputs that aren't used to the dummy slot
+ * (and an unused generic attribute slot).
+ */
for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
if (outputsWritten & (1 << outAttr)) {
- if (xvp->output_to_slot[outAttr] == UNUSED)
+ if (xvp->output_to_slot[outAttr] == UNUSED) {
xvp->output_to_slot[outAttr] = dummySlot;
+ xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_GENERIC;
+ xvp->output_to_semantic_index[outAttr] = maxGeneric + 1;
+ }
}
+
#if 0 /*debug*/
- printf("output_to_slot[%d] = %d\n", outAttr,
+ printf("vp output_to_slot[%d] = %d\n", outAttr,
xvp->output_to_slot[outAttr]);
#endif
-
}
assert(stvp->Base.Base.NumInstructions > 1);
- st_translate_vertex_program(st, stvp, xvp->output_to_slot);
+ st_translate_vertex_program(st, stvp, xvp->output_to_slot,
+ xvp->output_to_semantic_name,
+ xvp->output_to_semantic_index);
xvp->vp = stvp;
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 1ec671e..fb03766 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -49,6 +49,8 @@ update_textures(struct st_context *st)
st->state.num_textures = 0;
+ /*printf("%s samplers used = 0x%x\n", __FUNCTION__, fprog->Base.SamplersUsed);*/
+
for (su = 0; su < st->ctx->Const.MaxTextureCoordUnits; su++) {
struct pipe_texture *pt = NULL;
@@ -56,24 +58,34 @@ update_textures(struct st_context *st)
const GLuint texUnit = fprog->Base.SamplerUnits[su];
struct gl_texture_object *texObj
= st->ctx->Texture.Unit[texUnit]._Current;
- struct st_texture_object *stObj = st_texture_object(texObj);
-
- if (texObj) {
- GLboolean flush, retval;
+ struct st_texture_object *stObj;
+ GLboolean flush, retval;
- retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
- if (!retval) {
- /* out of mem */
- /* missing texture */
- continue;
- }
+ if (!texObj) {
+ texObj = st_get_default_texture(st);
+ }
+ stObj = st_texture_object(texObj);
- st->state.num_textures = su + 1;
+ retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
+ if (!retval) {
+ /* out of mem */
+ continue;
}
+ st->state.num_textures = su + 1;
+
pt = st_get_stobj_texture(stObj);
}
+ /*
+ if (pt) {
+ printf("%s su=%u non-null\n", __FUNCTION__, su);
+ }
+ else {
+ printf("%s su=%u null\n", __FUNCTION__, su);
+ }
+ */
+
pipe_texture_reference(&st->state.sampler_texture[su], pt);
}
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index a992e08..cf3a99e 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -42,7 +42,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index d5696a9..694104f 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -50,7 +50,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
#include "util/u_draw_quad.h"
#include "util/u_simple_shaders.h"
#include "shader/prog_instruction.h"
@@ -378,7 +378,7 @@ setup_bitmap_vertex_data(struct st_context *st,
void *buf;
if (!st->bitmap.vbuf) {
- st->bitmap.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX,
+ st->bitmap.vbuf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
sizeof(st->bitmap.vertices));
}
@@ -418,9 +418,9 @@ setup_bitmap_vertex_data(struct st_context *st,
}
/* put vertex data into vbuf */
- buf = pipe_buffer_map(pipe, st->bitmap.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
+ buf = pipe_buffer_map(pipe->screen, st->bitmap.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(buf, st->bitmap.vertices, sizeof(st->bitmap.vertices));
- pipe_buffer_unmap(pipe, st->bitmap.vbuf);
+ pipe_buffer_unmap(pipe->screen, st->bitmap.vbuf);
}
@@ -779,7 +779,7 @@ st_destroy_bitmap(struct st_context *st)
}
if (st->bitmap.vbuf) {
- pipe_buffer_destroy(pipe, st->bitmap.vbuf);
+ pipe_buffer_destroy(pipe->screen, st->bitmap.vbuf);
st->bitmap.vbuf = NULL;
}
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index af79aef..07fa2af 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -78,7 +78,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
struct st_buffer_object *st_obj = st_buffer_object(obj);
if (st_obj->buffer)
- pipe_reference_buffer(pipe, &st_obj->buffer, NULL);
+ pipe_buffer_reference(pipe->screen, &st_obj->buffer, NULL);
free(st_obj);
}
@@ -105,9 +105,9 @@ st_bufferobj_subdata(GLcontext *ctx,
if (offset >= st_obj->size || size > (st_obj->size - offset))
return;
- map = pipe_buffer_map(pipe, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pipe_buffer_map(pipe->screen, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(map + offset, data, size);
- pipe_buffer_unmap(pipe, st_obj->buffer);
+ pipe_buffer_unmap(pipe->screen, st_obj->buffer);
}
@@ -128,9 +128,9 @@ st_bufferobj_get_subdata(GLcontext *ctx,
if (offset >= st_obj->size || size > (st_obj->size - offset))
return;
- map = pipe_buffer_map(pipe, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe->screen, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_READ);
memcpy(data, map + offset, size);
- pipe_buffer_unmap(pipe, st_obj->buffer);
+ pipe_buffer_unmap(pipe->screen, st_obj->buffer);
}
@@ -171,9 +171,9 @@ st_bufferobj_data(GLcontext *ctx,
buffer_usage = 0;
}
- pipe_reference_buffer( pipe, &st_obj->buffer, NULL );
+ pipe_buffer_reference( pipe->screen, &st_obj->buffer, NULL );
- st_obj->buffer = pipe_buffer_create( pipe, 32, buffer_usage, size );
+ st_obj->buffer = pipe_buffer_create( pipe->screen, 32, buffer_usage, size );
st_obj->size = size;
@@ -207,7 +207,7 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
break;
}
- obj->Pointer = pipe_buffer_map(pipe, st_obj->buffer, flags);
+ obj->Pointer = pipe_buffer_map(pipe->screen, st_obj->buffer, flags);
return obj->Pointer;
}
@@ -221,7 +221,7 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
- pipe_buffer_unmap(pipe, st_obj->buffer);
+ pipe_buffer_unmap(pipe->screen, st_obj->buffer);
obj->Pointer = NULL;
return GL_TRUE;
}
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index e475f02..47ad3c2 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -116,7 +116,7 @@ st_destroy_clear(struct st_context *st)
st->clear.vs = NULL;
}
if (st->clear.vbuf) {
- pipe_buffer_destroy(pipe, st->clear.vbuf);
+ pipe_buffer_destroy(pipe->screen, st->clear.vbuf);
st->clear.vbuf = NULL;
}
}
@@ -152,7 +152,7 @@ draw_quad(GLcontext *ctx,
void *buf;
if (!st->clear.vbuf) {
- st->clear.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX,
+ st->clear.vbuf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
sizeof(st->clear.vertices));
}
@@ -180,9 +180,9 @@ draw_quad(GLcontext *ctx,
}
/* put vertex data into vbuf */
- buf = pipe_buffer_map(pipe, st->clear.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
+ buf = pipe_buffer_map(pipe->screen, st->clear.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(buf, st->clear.vertices, sizeof(st->clear.vertices));
- pipe_buffer_unmap(pipe, st->clear.vbuf);
+ pipe_buffer_unmap(pipe->screen, st->clear.vbuf);
/* draw */
util_draw_vertex_buffer(pipe, st->clear.vbuf,
@@ -414,6 +414,9 @@ clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
/* clear whole buffer w/out masking */
struct st_renderbuffer *strb = st_renderbuffer(rb);
uint clearValue;
+ /* NOTE: we always pass the clear color as PIPE_FORMAT_A8R8G8B8_UNORM
+ * at this time!
+ */
util_pack_color(ctx->Color.ClearColor, PIPE_FORMAT_A8R8G8B8_UNORM, &clearValue);
ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index db0c9fb..00bbcae 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -55,7 +55,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
#include "util/u_draw_quad.h"
#include "shader/prog_instruction.h"
#include "cso_cache/cso_context.h"
@@ -294,7 +294,7 @@ st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor)
}
stvp = (struct st_vertex_program *) p;
- st_translate_vertex_program(st, stvp, NULL);
+ st_translate_vertex_program(st, stvp, NULL, NULL, NULL);
st->drawpix.vert_shaders[passColor] = stvp;
@@ -487,17 +487,17 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
ubyte *map;
/* allocate/load buffer object with vertex data */
- buf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX,
+ buf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
sizeof(verts));
- map = pipe_buffer_map(pipe, buf, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pipe_buffer_map(pipe->screen, buf, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(map, verts, sizeof(verts));
- pipe_buffer_unmap(pipe, buf);
+ pipe_buffer_unmap(pipe->screen, buf);
util_draw_vertex_buffer(pipe, buf,
PIPE_PRIM_QUADS,
4, /* verts */
3); /* attribs/vert */
- pipe_buffer_reference(pipe->winsys, &buf, NULL);
+ pipe_buffer_reference(pipe->screen, &buf, NULL);
}
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h
index ff56001..44fa9fe 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -47,6 +47,10 @@ struct st_renderbuffer
struct st_texture_object *rtt; /**< GL render to texture's texture */
int rtt_level, rtt_face, rtt_slice;
+
+ /** Render to texture state */
+ struct pipe_texture *texture_save;
+ struct pipe_surface *surface_save;
};
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
index 5e866b0..d8f9537 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -91,7 +91,7 @@ void st_finish( struct st_context *st )
{
struct pipe_fence_handle *fence = NULL;
- st_flush(st, PIPE_FLUSH_RENDER_CACHE, &fence);
+ st_flush(st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
st->pipe->winsys->fence_finish(st->pipe->winsys, fence, 0);
st->pipe->winsys->fence_reference(st->pipe->winsys, &fence, NULL);
diff --git a/src/mesa/state_tracker/st_cb_get.c b/src/mesa/state_tracker/st_cb_get.c
new file mode 100644
index 0000000..e7d7f03
--- /dev/null
+++ b/src/mesa/state_tracker/st_cb_get.c
@@ -0,0 +1,97 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/**
+ * glGet functions
+ *
+ * \author Brian Paul
+ */
+
+#include "main/imports.h"
+#include "main/context.h"
+
+#include "pipe/p_defines.h"
+
+#include "st_cb_fbo.h"
+#include "st_cb_get.h"
+
+
+
+/**
+ * Examine the current color read buffer format to determine
+ * which GL pixel format/type combo is the best match.
+ */
+static void
+get_preferred_read_format_type(GLcontext *ctx, GLint *format, GLint *type)
+{
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct st_renderbuffer *strb = st_renderbuffer(fb->_ColorReadBuffer);
+
+ /* defaults */
+ *format = ctx->Const.ColorReadFormat;
+ *type = ctx->Const.ColorReadType;
+
+ if (strb) {
+ /* XXX could add more cases here... */
+ if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM) {
+ *format = GL_BGRA;
+ if (_mesa_little_endian())
+ *type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ else
+ *type = GL_UNSIGNED_INT_8_8_8_8;
+ }
+ }
+}
+
+
+/**
+ * We only intercept the OES preferred ReadPixels format/type.
+ * Everything else goes to the default _mesa_GetIntegerv.
+ */
+static GLboolean
+st_GetIntegerv(GLcontext *ctx, GLenum pname, GLint *params)
+{
+ GLint dummy;
+
+ switch (pname) {
+ case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+ get_preferred_read_format_type(ctx, &dummy, params);
+ return GL_TRUE;
+ case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+ get_preferred_read_format_type(ctx, params, &dummy);
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+void st_init_get_functions(struct dd_function_table *functions)
+{
+ functions->GetIntegerv = st_GetIntegerv;
+}
diff --git a/src/mesa/state_tracker/st_cb_get.h b/src/mesa/state_tracker/st_cb_get.h
new file mode 100644
index 0000000..8e9f3e9
--- /dev/null
+++ b/src/mesa/state_tracker/st_cb_get.h
@@ -0,0 +1,37 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef ST_CB_GET_H
+#define ST_CB_GET_H
+
+
+extern void
+st_init_get_functions(struct dd_function_table *functions);
+
+
+#endif
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index eb71779..c801532 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -41,7 +41,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
#include "st_context.h"
#include "st_cb_bitmap.h"
#include "st_cb_readpixels.h"
@@ -163,6 +163,124 @@ st_get_color_read_renderbuffer(GLcontext *ctx)
/**
+ * Try to do glReadPixels in a fast manner for common cases.
+ * \return GL_TRUE for success, GL_FALSE for failure
+ */
+static GLboolean
+st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *dest)
+{
+ enum combination {
+ A8R8G8B8_UNORM_TO_RGBA_UBYTE,
+ A8R8G8B8_UNORM_TO_RGB_UBYTE,
+ A8R8G8B8_UNORM_TO_BGRA_UINT
+ } combo;
+
+ if (ctx->_ImageTransferState)
+ return GL_FALSE;
+
+ if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM &&
+ format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ combo = A8R8G8B8_UNORM_TO_RGBA_UBYTE;
+ }
+ else if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM &&
+ format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ combo = A8R8G8B8_UNORM_TO_RGB_UBYTE;
+ }
+ else if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM &&
+ format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV) {
+ combo = A8R8G8B8_UNORM_TO_BGRA_UINT;
+ }
+ else {
+ return GL_FALSE;
+ }
+
+ /*printf("st_fast_readpixels combo %d\n", (GLint) combo);*/
+
+ {
+ struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_screen *screen = pipe->screen;
+ struct pipe_surface *surf;
+ const GLubyte *map;
+ GLubyte *dst;
+ GLint row, col, dy, dstStride;
+
+ surf = screen->get_tex_surface(screen, strb->texture, 0, 0, 0,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ if (!surf) {
+ return GL_FALSE;
+ }
+
+ map = screen->surface_map(screen, surf, PIPE_BUFFER_USAGE_CPU_READ);
+ if (!map) {
+ pipe_surface_reference(&surf, NULL);
+ return GL_FALSE;
+ }
+
+ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
+ y = surf->height - y - 1;
+ dy = -1;
+ }
+ else {
+ dy = 1;
+ }
+
+ dst = _mesa_image_address2d(pack, dest, width, height,
+ format, type, 0, 0);
+ dstStride = _mesa_image_row_stride(pack, width, format, type);
+
+ switch (combo) {
+ case A8R8G8B8_UNORM_TO_RGBA_UBYTE:
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = map + y * surf->stride + x * 4;
+ for (col = 0; col < width; col++) {
+ GLuint pixel = ((GLuint *) src)[col];
+ dst[col*4+0] = (pixel >> 16) & 0xff;
+ dst[col*4+1] = (pixel >> 8) & 0xff;
+ dst[col*4+2] = (pixel >> 0) & 0xff;
+ dst[col*4+3] = (pixel >> 24) & 0xff;
+ }
+ dst += dstStride;
+ y += dy;
+ }
+ break;
+ case A8R8G8B8_UNORM_TO_RGB_UBYTE:
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = map + y * surf->stride + x * 4;
+ for (col = 0; col < width; col++) {
+ GLuint pixel = ((GLuint *) src)[col];
+ dst[col*3+0] = (pixel >> 16) & 0xff;
+ dst[col*3+1] = (pixel >> 8) & 0xff;
+ dst[col*3+2] = (pixel >> 0) & 0xff;
+ }
+ dst += dstStride;
+ y += dy;
+ }
+ break;
+ case A8R8G8B8_UNORM_TO_BGRA_UINT:
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = map + y * surf->stride + x * 4;
+ memcpy(dst, src, 4 * width);
+ dst += dstStride;
+ y += dy;
+ }
+ break;
+ default:
+ ; /* nothing */
+ }
+
+ screen->surface_unmap(screen, surf);
+ pipe_surface_reference(&surf, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
* Do glReadPixels by getting rows from the framebuffer surface with
* get_tile(). Convert to requested format/type with Mesa image routines.
* Image transfer ops are done in software too.
@@ -219,6 +337,14 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
if (!strb)
return;
+ /* try a fast-path readpixels before anything else */
+ if (st_fast_readpixels(ctx, strb, x, y, width, height,
+ format, type, pack, dest)) {
+ /* success! */
+ _mesa_unmap_readpix_pbo(ctx, &clippedPacking);
+ return;
+ }
+
if (format == GL_RGBA && type == GL_FLOAT) {
/* write tile(row) directly into user's buffer */
df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width,
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 147ca5b..a3e8fc9 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -51,20 +51,13 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
#include "util/u_blit.h"
#define DBG if (0) printf
-static INLINE struct st_texture_image *
-st_texture_image(struct gl_texture_image *img)
-{
- return (struct st_texture_image *) img;
-}
-
-
static enum pipe_texture_target
gl_target_to_pipe(GLenum target)
{
@@ -933,7 +926,12 @@ fallback_copy_texsubimage(GLcontext *ctx,
struct pipe_texture *pt = stImage->pt;
struct pipe_surface *src_surf, *dest_surf;
- src_surf = strb->surface;
+ /* We'd use strb->surface, here but it's created for GPU read/write only */
+ src_surf = pipe->screen->get_tex_surface( pipe->screen,
+ strb->texture,
+ 0, 0, 0,
+ PIPE_BUFFER_USAGE_CPU_READ);
+
dest_surf = screen->get_tex_surface(screen, pt, face, level, destZ,
PIPE_BUFFER_USAGE_CPU_WRITE);
@@ -1016,6 +1014,7 @@ fallback_copy_texsubimage(GLcontext *ctx,
}
screen->tex_surface_release(screen, &dest_surf);
+ screen->tex_surface_release(screen, &src_surf);
}
@@ -1092,6 +1091,10 @@ st_copy_texsubimage(GLcontext *ctx,
stImage->face, stImage->level,
destZ,
PIPE_BUFFER_USAGE_GPU_WRITE);
+ if (do_flip)
+ srcY = strb->surface->height - srcY - height;
+
+ /* for surface_copy(), y=0=top, always */
pipe->surface_copy(pipe,
do_flip,
/* dest */
@@ -1455,6 +1458,49 @@ st_finalize_texture(GLcontext *ctx,
}
+/**
+ * Returns pointer to a default/dummy texture.
+ * This is typically used when the current shader has tex/sample instructions
+ * but the user has not provided a (any) texture(s).
+ */
+struct gl_texture_object *
+st_get_default_texture(struct st_context *st)
+{
+ if (!st->default_texture) {
+ static const GLenum target = GL_TEXTURE_2D;
+ GLubyte pixels[16][16][4];
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImg;
+
+ /* init image to gray */
+ memset(pixels, 127, sizeof(pixels));
+
+ texObj = st->ctx->Driver.NewTextureObject(st->ctx, 0, target);
+
+ texImg = _mesa_get_tex_image(st->ctx, texObj, target, 0);
+
+ _mesa_init_teximage_fields(st->ctx, target, texImg,
+ 16, 16, 1, 0, /* w, h, d, border */
+ GL_RGBA);
+
+ st_TexImage(st->ctx, 2, target,
+ 0, GL_RGBA, /* level, intformat */
+ 16, 16, 1, 0, /* w, h, d, border */
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels,
+ &st->ctx->DefaultPacking,
+ texObj, texImg,
+ 0, 0);
+
+ texObj->MinFilter = GL_NEAREST;
+ texObj->MagFilter = GL_NEAREST;
+ texObj->_Complete = GL_TRUE;
+
+ st->default_texture = texObj;
+ }
+ return st->default_texture;
+}
+
+
void
st_init_texture_functions(struct dd_function_table *functions)
{
diff --git a/src/mesa/state_tracker/st_cb_texture.h b/src/mesa/state_tracker/st_cb_texture.h
index 843745f..f1fe033 100644
--- a/src/mesa/state_tracker/st_cb_texture.h
+++ b/src/mesa/state_tracker/st_cb_texture.h
@@ -37,6 +37,10 @@ st_finalize_texture(GLcontext *ctx,
GLboolean *needFlush);
+extern struct gl_texture_object *
+st_get_default_texture(struct st_context *st);
+
+
extern void
st_init_texture_functions(struct dd_function_table *functions);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 6e4a376..08d4db7 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -49,6 +49,7 @@
#include "st_cb_drawtex.h"
#endif
#include "st_cb_fbo.h"
+#include "st_cb_get.h"
#if FEATURE_feedback
#include "st_cb_feedback.h"
#endif
@@ -195,10 +196,15 @@ static void st_destroy_context_priv( struct st_context *st )
for (i = 0; i < Elements(st->state.constants); i++) {
if (st->state.constants[i].buffer) {
- pipe_reference_buffer(st->pipe, &st->state.constants[i].buffer, NULL);
+ pipe_buffer_reference(st->pipe->screen, &st->state.constants[i].buffer, NULL);
}
}
+ if (st->default_texture) {
+ st->ctx->Driver.DeleteTexture(st->ctx, st->default_texture);
+ st->default_texture = NULL;
+ }
+
free( st );
}
@@ -223,10 +229,7 @@ void st_destroy_context( struct st_context *st )
cso_destroy_context(cso);
- /* Temporary workaround for mismatched pipe create and pipe destroy */
-#if !defined(PIPE_SUBSYSTEM_WINDOWS_USER) && !defined(PIPE_SUBSYSTEM_WINDOWS_CE)
pipe->destroy( pipe );
-#endif
free(ctx);
}
@@ -291,6 +294,7 @@ void st_init_driver_functions(struct dd_function_table *functions)
st_init_rasterpos_functions(functions);
#endif
st_init_fbo_functions(functions);
+ st_init_get_functions(functions);
#if FEATURE_feedback
st_init_feedback_functions(functions);
#endif
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 9633390..4314d9a 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -132,6 +132,8 @@ struct st_context
struct st_vertex_program *vp; /**< Currently bound vertex program */
struct st_fragment_program *fp; /**< Currently bound fragment program */
+ struct gl_texture_object *default_texture;
+
struct {
struct gl_program_cache *cache;
struct st_fragment_program *program; /**< cur pixel transfer prog */
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index cc3d745..bdf8648 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -32,6 +32,7 @@
#include "main/imports.h"
#include "main/image.h"
+#include "main/macros.h"
#include "vbo/vbo.h"
@@ -228,7 +229,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
if (!vec)
return NULL;
- map = pipe_buffer_map(pipe, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe->screen, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ);
map = ADD_POINTERS(map, array->Ptr);
for (i = 0; i < count; i++) {
@@ -238,7 +239,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
map += array->StrideB;
}
- pipe_buffer_unmap(pipe, stobj->buffer);
+ pipe_buffer_unmap(pipe->screen, stobj->buffer);
pipe->set_edgeflags(pipe, vec);
@@ -252,43 +253,174 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
}
+/**
+ * Examine the active arrays to determine if we have interleaved
+ * vertex arrays all living in one VBO, or all living in user space.
+ * \param userSpace returns whether the arrays are in user space.
+ */
+static GLboolean
+is_interleaved_arrays(const struct st_vertex_program *vp,
+ const struct gl_client_array **arrays,
+ GLboolean *userSpace)
+{
+ GLuint attr;
+ const struct gl_buffer_object *firstBufObj = NULL;
+ GLint firstStride = -1;
+ GLuint num_client_arrays = 0;
+ const GLubyte *client_addr = NULL;
+
+ for (attr = 0; attr < vp->num_inputs; attr++) {
+ const GLuint mesaAttr = vp->index_to_input[attr];
+ const struct gl_buffer_object *bufObj = arrays[mesaAttr]->BufferObj;
+ const GLsizei stride = arrays[mesaAttr]->StrideB; /* in bytes */
+
+ if (firstStride < 0) {
+ firstStride = stride;
+ }
+ else if (firstStride != stride) {
+ return GL_FALSE;
+ }
+
+ if (!bufObj || !bufObj->Name) {
+ num_client_arrays++;
+ /* Try to detect if the client-space arrays are
+ * "close" to each other.
+ */
+ if (!client_addr) {
+ client_addr = arrays[mesaAttr]->Ptr;
+ }
+ else if (abs(arrays[mesaAttr]->Ptr - client_addr) > firstStride) {
+ /* arrays start too far apart */
+ return GL_FALSE;
+ }
+ }
+ else if (!firstBufObj) {
+ firstBufObj = bufObj;
+ }
+ else if (bufObj != firstBufObj) {
+ return GL_FALSE;
+ }
+ }
+
+ *userSpace = (num_client_arrays == vp->num_inputs);
+ /*printf("user space: %d\n", (int) *userSpace);*/
+
+ return GL_TRUE;
+}
+
/**
- * This function gets plugged into the VBO module and is called when
- * we have something to render.
- * Basically, translate the information into the format expected by pipe.
+ * Once we know all the arrays are in user space, this function
+ * computes the memory range occupied by the arrays.
*/
-void
-st_draw_vbo(GLcontext *ctx,
- const struct gl_client_array **arrays,
- const struct _mesa_prim *prims,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint min_index,
- GLuint max_index)
+static void
+get_user_arrays_bounds(const struct st_vertex_program *vp,
+ const struct gl_client_array **arrays,
+ GLuint max_index,
+ const GLubyte **low, const GLubyte **high)
+{
+ const GLubyte *low_addr = NULL;
+ GLuint attr;
+ GLint stride;
+
+ for (attr = 0; attr < vp->num_inputs; attr++) {
+ const GLuint mesaAttr = vp->index_to_input[attr];
+ const GLubyte *start = arrays[mesaAttr]->Ptr;
+ stride = arrays[mesaAttr]->StrideB;
+ if (attr == 0) {
+ low_addr = start;
+ }
+ else {
+ low_addr = MIN2(low_addr, start);
+ }
+ }
+
+ *low = low_addr;
+ *high = low_addr + (max_index + 1) * stride;
+}
+
+
+/**
+ * Set up for drawing interleaved arrays that all live in one VBO
+ * or all live in user space.
+ * \param vbuffer returns vertex buffer info
+ * \param velements returns vertex element info
+ */
+static void
+setup_interleaved_attribs(GLcontext *ctx,
+ const struct st_vertex_program *vp,
+ const struct gl_client_array **arrays,
+ GLuint max_index,
+ GLboolean userSpace,
+ struct pipe_vertex_buffer *vbuffer,
+ struct pipe_vertex_element velements[])
{
struct pipe_context *pipe = ctx->st->pipe;
- const struct st_vertex_program *vp;
- const struct pipe_shader_state *vs;
- struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS];
GLuint attr;
- struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
+ const GLubyte *offset0;
- /* sanity check for pointer arithmetic below */
- assert(sizeof(arrays[0]->Ptr[0]) == 1);
+ for (attr = 0; attr < vp->num_inputs; attr++) {
+ const GLuint mesaAttr = vp->index_to_input[attr];
+ struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
+ struct st_buffer_object *stobj = st_buffer_object(bufobj);
+ GLsizei stride = arrays[mesaAttr]->StrideB;
+
+ /*printf("stobj %u = %p\n", attr, (void*)stobj);*/
+
+ if (attr == 0) {
+ if (userSpace) {
+ const GLubyte *low, *high;
+ get_user_arrays_bounds(vp, arrays, max_index, &low, &high);
+ /*printf("user buffer range: %p %p %d\n", low, high, high-low);*/
+ vbuffer->buffer =
+ pipe_user_buffer_create(pipe->screen, (void *) low, high - low);
+ vbuffer->buffer_offset = 0;
+ offset0 = low;
+ }
+ else {
+ vbuffer->buffer = NULL;
+ pipe_buffer_reference(pipe->screen, &vbuffer->buffer, stobj->buffer);
+ vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr;
+ offset0 = arrays[mesaAttr]->Ptr;
+ }
+ vbuffer->pitch = stride; /* in bytes */
+ vbuffer->max_index = max_index;
+ }
- st_validate_state(ctx->st);
+ velements[attr].src_offset =
+ (unsigned) (arrays[mesaAttr]->Ptr - offset0);
+ velements[attr].vertex_buffer_index = 0;
+ velements[attr].nr_components = arrays[mesaAttr]->Size;
+ velements[attr].src_format =
+ pipe_vertex_format(arrays[mesaAttr]->Type,
+ arrays[mesaAttr]->Size,
+ arrays[mesaAttr]->Normalized);
+ assert(velements[attr].src_format);
+ }
+}
- /* must get these after state validation! */
- vp = ctx->st->vp;
- vs = &ctx->st->vp->state;
- /* loop over TGSI shader inputs to determine vertex buffer
- * and attribute info
- */
+/**
+ * Set up a separate pipe_vertex_buffer and pipe_vertex_element for each
+ * vertex attribute.
+ * \param vbuffer returns vertex buffer info
+ * \param velements returns vertex element info
+ */
+static void
+setup_non_interleaved_attribs(GLcontext *ctx,
+ const struct st_vertex_program *vp,
+ const struct gl_client_array **arrays,
+ GLuint max_index,
+ struct pipe_vertex_buffer vbuffer[],
+ struct pipe_vertex_element velements[])
+{
+ struct pipe_context *pipe = ctx->st->pipe;
+ GLuint attr;
+
for (attr = 0; attr < vp->num_inputs; attr++) {
const GLuint mesaAttr = vp->index_to_input[attr];
struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
+ GLsizei stride = arrays[mesaAttr]->StrideB;
if (bufobj && bufobj->Name) {
/* Attribute data is in a VBO.
@@ -297,27 +429,39 @@ st_draw_vbo(GLcontext *ctx,
*/
struct st_buffer_object *stobj = st_buffer_object(bufobj);
assert(stobj->buffer);
+ /*printf("stobj %u = %p\n", attr, (void*) stobj);*/
vbuffer[attr].buffer = NULL;
- pipe_reference_buffer(pipe, &vbuffer[attr].buffer, stobj->buffer);
+ pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, stobj->buffer);
vbuffer[attr].buffer_offset = (unsigned) arrays[mesaAttr]->Ptr;
velements[attr].src_offset = 0;
}
else {
/* attribute data is in user-space memory, not a VBO */
uint bytes;
+ /*printf("user-space array %d stride %d\n", attr, stride);*/
- if (!arrays[mesaAttr]->StrideB) {
- bytes = arrays[mesaAttr]->Size
- * _mesa_sizeof_type(arrays[mesaAttr]->Type);
- } else {
- bytes = arrays[mesaAttr]->StrideB * (max_index + 1);
+ /* wrap user data */
+ if (arrays[mesaAttr]->Ptr) {
+ /* user's vertex array */
+ if (arrays[mesaAttr]->StrideB) {
+ bytes = arrays[mesaAttr]->StrideB * (max_index + 1);
+ }
+ else {
+ bytes = arrays[mesaAttr]->Size
+ * _mesa_sizeof_type(arrays[mesaAttr]->Type);
+ }
+ vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen,
+ (void *) arrays[mesaAttr]->Ptr, bytes);
+ }
+ else {
+ /* no array, use ctx->Current.Attrib[] value */
+ bytes = sizeof(ctx->Current.Attrib[0]);
+ vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen,
+ (void *) ctx->Current.Attrib[mesaAttr], bytes);
+ stride = 0;
}
- /* wrap user data */
- vbuffer[attr].buffer
- = pipe_user_buffer_create(pipe, (void *) arrays[mesaAttr]->Ptr,
- bytes);
vbuffer[attr].buffer_offset = 0;
velements[attr].src_offset = 0;
}
@@ -325,7 +469,7 @@ st_draw_vbo(GLcontext *ctx,
assert(velements[attr].src_offset <= 2048); /* 11-bit field */
/* common-case setup */
- vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */
+ vbuffer[attr].pitch = stride; /* in bytes */
vbuffer[attr].max_index = max_index;
velements[attr].vertex_buffer_index = attr;
velements[attr].nr_components = arrays[mesaAttr]->Size;
@@ -335,27 +479,81 @@ st_draw_vbo(GLcontext *ctx,
arrays[mesaAttr]->Normalized);
assert(velements[attr].src_format);
}
+}
+
+
+
+
+/**
+ * This function gets plugged into the VBO module and is called when
+ * we have something to render.
+ * Basically, translate the information into the format expected by gallium.
+ */
+void
+st_draw_vbo(GLcontext *ctx,
+ const struct gl_client_array **arrays,
+ const struct _mesa_prim *prims,
+ GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index)
+{
+ struct pipe_context *pipe = ctx->st->pipe;
+ const struct st_vertex_program *vp;
+ const struct pipe_shader_state *vs;
+ struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS];
+ GLuint attr;
+ struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
+ unsigned num_vbuffers, num_velements;
+ GLboolean userSpace;
+
+ /* sanity check for pointer arithmetic below */
+ assert(sizeof(arrays[0]->Ptr[0]) == 1);
+
+ st_validate_state(ctx->st);
+
+ /* must get these after state validation! */
+ vp = ctx->st->vp;
+ vs = &ctx->st->vp->state;
+
+ /*
+ * Setup the vbuffer[] and velements[] arrays.
+ */
+ if (is_interleaved_arrays(vp, arrays, &userSpace)) {
+ /*printf("Draw interleaved\n");*/
+ setup_interleaved_attribs(ctx, vp, arrays, max_index, userSpace,
+ vbuffer, velements);
+ num_vbuffers = 1;
+ num_velements = vp->num_inputs;
+ }
+ else {
+ /*printf("Draw non-interleaved\n");*/
+ setup_non_interleaved_attribs(ctx, vp, arrays, max_index,
+ vbuffer, velements);
+ num_vbuffers = vp->num_inputs;
+ num_velements = vp->num_inputs;
+ }
#if 0
{
GLuint i;
- for (i = 0; i < vp->num_inputs; i++) {
+ for (i = 0; i < num_vbuffers; i++) {
printf("buffers[%d].pitch = %u\n", i, vbuffer[i].pitch);
printf("buffers[%d].max_index = %u\n", i, vbuffer[i].max_index);
printf("buffers[%d].buffer_offset = %u\n", i, vbuffer[i].buffer_offset);
printf("buffers[%d].buffer = %p\n", i, (void*) vbuffer[i].buffer);
}
- for (i = 0; i < vp->num_inputs; i++) {
- printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset);
+ for (i = 0; i < num_velements; i++) {
printf("vlements[%d].vbuffer_index = %u\n", i, velements[i].vertex_buffer_index);
+ printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset);
printf("vlements[%d].nr_comps = %u\n", i, velements[i].nr_components);
printf("vlements[%d].format = %s\n", i, pf_name(velements[i].src_format));
}
}
#endif
- pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer);
- pipe->set_vertex_elements(pipe, vp->num_inputs, velements);
+ pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer);
+ pipe->set_vertex_elements(pipe, num_velements, velements);
/* do actual drawing */
if (ib) {
@@ -383,12 +581,12 @@ st_draw_vbo(GLcontext *ctx,
if (bufobj && bufobj->Name) {
/* elements/indexes are in a real VBO */
struct st_buffer_object *stobj = st_buffer_object(bufobj);
- pipe_reference_buffer(pipe, &indexBuf, stobj->buffer);
+ pipe_buffer_reference(pipe->screen, &indexBuf, stobj->buffer);
indexOffset = (unsigned) ib->ptr / indexSize;
}
else {
/* element/indicies are in user space memory */
- indexBuf = pipe_user_buffer_create(pipe, (void *) ib->ptr,
+ indexBuf = pipe_user_buffer_create(pipe->screen, (void *) ib->ptr,
ib->count * indexSize);
indexOffset = 0;
}
@@ -423,7 +621,7 @@ st_draw_vbo(GLcontext *ctx,
}
}
- pipe_reference_buffer(pipe, &indexBuf, NULL);
+ pipe_buffer_reference(pipe->screen, &indexBuf, NULL);
}
else {
/* non-indexed */
@@ -438,8 +636,8 @@ st_draw_vbo(GLcontext *ctx,
}
/* unreference buffers (frees wrapped user-space buffer objects) */
- for (attr = 0; attr < vp->num_inputs; attr++) {
- pipe_reference_buffer(pipe, &vbuffer[attr].buffer, NULL);
+ for (attr = 0; attr < num_vbuffers; attr++) {
+ pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL);
assert(!vbuffer[attr].buffer);
}
pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer);
@@ -552,7 +750,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
assert(stobj->buffer);
vbuffers[attr].buffer = NULL;
- pipe_reference_buffer(pipe, &vbuffers[attr].buffer, stobj->buffer);
+ pipe_buffer_reference(pipe->screen, &vbuffers[attr].buffer, stobj->buffer);
vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
}
@@ -564,7 +762,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* wrap user data */
vbuffers[attr].buffer
- = pipe_user_buffer_create(pipe, (void *) arrays[mesaAttr]->Ptr,
+ = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr,
bytes);
vbuffers[attr].buffer_offset = 0;
velements[attr].src_offset = 0;
@@ -586,7 +784,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
#endif
/* map the attrib buffer */
- map = pipe_buffer_map(pipe, vbuffers[attr].buffer,
+ map = pipe_buffer_map(pipe->screen, vbuffers[attr].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, attr, map);
}
@@ -614,7 +812,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
return;
}
- map = pipe_buffer_map(pipe, index_buffer_handle,
+ map = pipe_buffer_map(pipe->screen, index_buffer_handle,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer(draw, indexSize, map);
}
@@ -625,7 +823,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* map constant buffers */
- mapped_constants = pipe_buffer_map(pipe,
+ mapped_constants = pipe_buffer_map(pipe->screen,
st->state.constants[PIPE_SHADER_VERTEX].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_constant_buffer(st->draw, mapped_constants,
@@ -639,20 +837,20 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* unmap constant buffers */
- pipe_buffer_unmap(pipe, st->state.constants[PIPE_SHADER_VERTEX].buffer);
+ pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX].buffer);
/*
* unmap vertex/index buffers
*/
for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
if (draw->pt.vertex_buffer[i].buffer) {
- pipe_buffer_unmap(pipe, draw->pt.vertex_buffer[i].buffer);
- pipe_reference_buffer(pipe, &draw->pt.vertex_buffer[i].buffer, NULL);
+ pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer);
+ pipe_buffer_reference(pipe->screen, &draw->pt.vertex_buffer[i].buffer, NULL);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
}
if (ib) {
- pipe_buffer_unmap(pipe, index_buffer_handle);
+ pipe_buffer_unmap(pipe->screen, index_buffer_handle);
draw_set_mapped_element_buffer(draw, 0, NULL);
}
}
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index b7444b2..60fd440 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -218,6 +218,26 @@ void st_init_extensions(struct st_context *st)
/*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/
}
+ /* GL_EXT_packed_depth_stencil requires both the ability to render to
+ * a depth/stencil buffer and texture from depth/stencil source.
+ */
+ if (screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) &&
+ screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
+ }
+ else if (screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) &&
+ screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
+ }
+
if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB,
PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 2461f39..a8ae30a 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -342,6 +342,9 @@ default_depth_format(struct pipe_screen *screen,
/**
* Given an OpenGL internalFormat value for a texture or surface, return
* the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match.
+ * \param target one of PIPE_TEXTURE_x
+ * \param tex_usage either PIPE_TEXTURE_USAGE_RENDER_TARGET
+ * or PIPE_TEXTURE_USAGE_SAMPLER
*/
enum pipe_format
st_choose_format(struct pipe_context *pipe, GLint internalFormat,
@@ -515,14 +518,35 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
}
+static GLboolean
+is_stencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
/**
* Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
*/
enum pipe_format
st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat)
{
- return st_choose_format(pipe, internalFormat, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET);
+ uint usage;
+ if (is_stencil_format(internalFormat))
+ usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ else
+ usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ return st_choose_format(pipe, internalFormat, PIPE_TEXTURE_2D, usage);
}
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 039a9cf..0f4a03f 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -74,7 +74,7 @@ st_create_framebuffer( const __GLcontextModes *visual,
_mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
}
- if (visual->depthBits == 24 && visual->stencilBits == 8) {
+ if (depthFormat == stencilFormat && depthFormat != PIPE_FORMAT_NONE) {
/* combined depth/stencil buffer */
struct gl_renderbuffer *depthStencilRb
= st_new_renderbuffer_fb(depthFormat, samples);
@@ -265,7 +265,9 @@ st_notify_swapbuffers(struct st_framebuffer *stfb)
if (ctx && ctx->DrawBuffer == &stfb->Base) {
st_flush( ctx->st,
- PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_SWAPBUFFERS,
+ PIPE_FLUSH_RENDER_CACHE |
+ PIPE_FLUSH_SWAPBUFFERS |
+ PIPE_FLUSH_FRAME,
NULL );
ctx->st->frontbuffer_status = FRONT_STATUS_COPY_OF_BACK;
}
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 6db9bc0..b9d114b 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -128,10 +128,10 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
PIPE_BUFFER_USAGE_CPU_WRITE);
- srcData = (ubyte *) pipe_buffer_map(pipe, srcSurf->buffer,
+ srcData = (ubyte *) pipe_buffer_map(pipe->screen, srcSurf->buffer,
PIPE_BUFFER_USAGE_CPU_READ)
+ srcSurf->offset;
- dstData = (ubyte *) pipe_buffer_map(pipe, dstSurf->buffer,
+ dstData = (ubyte *) pipe_buffer_map(pipe->screen, dstSurf->buffer,
PIPE_BUFFER_USAGE_CPU_WRITE)
+ dstSurf->offset;
@@ -144,8 +144,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
dstSurf->stride, /* stride in bytes */
dstData);
- pipe_buffer_unmap(pipe, srcSurf->buffer);
- pipe_buffer_unmap(pipe, dstSurf->buffer);
+ pipe_buffer_unmap(pipe->screen, srcSurf->buffer);
+ pipe_buffer_unmap(pipe->screen, dstSurf->buffer);
pipe_surface_reference(&srcSurf, NULL);
pipe_surface_reference(&dstSurf, NULL);
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 198d406..5ec9fdd 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -47,7 +47,8 @@ static GLuint
map_register_file(
enum register_file file,
GLuint index,
- const GLuint immediateMapping[] )
+ const GLuint immediateMapping[],
+ GLboolean indirectAccess )
{
switch( file ) {
case PROGRAM_UNDEFINED:
@@ -66,11 +67,13 @@ map_register_file(
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
case PROGRAM_UNIFORM:
- if (immediateMapping && immediateMapping[index] != ~0)
+ if (!indirectAccess && immediateMapping && immediateMapping[index] != ~0)
return TGSI_FILE_IMMEDIATE;
else
return TGSI_FILE_CONSTANT;
case PROGRAM_CONSTANT:
+ if (indirectAccess)
+ return TGSI_FILE_CONSTANT;
return TGSI_FILE_IMMEDIATE;
case PROGRAM_INPUT:
return TGSI_FILE_INPUT;
@@ -98,7 +101,8 @@ map_register_file_index(
GLuint index,
const GLuint inputMapping[],
const GLuint outputMapping[],
- const GLuint immediateMapping[])
+ const GLuint immediateMapping[],
+ GLboolean indirectAccess )
{
switch( file ) {
case TGSI_FILE_INPUT:
@@ -109,6 +113,8 @@ map_register_file_index(
return outputMapping[index];
case TGSI_FILE_IMMEDIATE:
+ if (indirectAccess)
+ return index;
return immediateMapping[index];
default:
@@ -175,10 +181,11 @@ static struct tgsi_full_immediate
make_immediate(const float *value, uint size)
{
struct tgsi_full_immediate imm;
- imm.Immediate.Type = TGSI_TOKEN_TYPE_IMMEDIATE;
- imm.Immediate.Size = 1 + size; /* one for the token itself */
+
+ imm = tgsi_default_full_immediate();
+ imm.Immediate.Size += size;
imm.Immediate.DataType = TGSI_IMM_FLOAT32;
- imm.u.ImmediateFloat32 = (struct tgsi_immediate_float32 *) value;
+ imm.u.Pointer = value;
return imm;
}
@@ -189,6 +196,7 @@ compile_instruction(
const GLuint inputMapping[],
const GLuint outputMapping[],
const GLuint immediateMapping[],
+ GLboolean indirectAccess,
GLuint preamble_size,
GLuint processor,
GLboolean *insideSubroutine)
@@ -204,29 +212,32 @@ compile_instruction(
fullinst->Instruction.NumSrcRegs = _mesa_num_inst_src_regs( inst->Opcode );
fulldst = &fullinst->FullDstRegisters[0];
- fulldst->DstRegister.File = map_register_file( inst->DstReg.File, 0, NULL );
+ fulldst->DstRegister.File = map_register_file( inst->DstReg.File, 0, NULL, GL_FALSE );
fulldst->DstRegister.Index = map_register_file_index(
fulldst->DstRegister.File,
inst->DstReg.Index,
inputMapping,
outputMapping,
- NULL
- );
+ NULL,
+ GL_FALSE );
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );
- for( i = 0; i < fullinst->Instruction.NumSrcRegs; i++ ) {
+ for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
GLuint j;
fullsrc = &fullinst->FullSrcRegisters[i];
- fullsrc->SrcRegister.File = map_register_file( inst->SrcReg[i].File,
- inst->SrcReg[i].Index,
- immediateMapping );
+ fullsrc->SrcRegister.File = map_register_file(
+ inst->SrcReg[i].File,
+ inst->SrcReg[i].Index,
+ immediateMapping,
+ indirectAccess );
fullsrc->SrcRegister.Index = map_register_file_index(
fullsrc->SrcRegister.File,
inst->SrcReg[i].Index,
inputMapping,
outputMapping,
- immediateMapping);
+ immediateMapping,
+ indirectAccess );
/* swizzle (ext swizzle also depends on negation) */
{
@@ -609,6 +620,19 @@ make_temp_decl(
return decl;
}
+static struct tgsi_full_declaration
+make_addr_decl(
+ GLuint start_index,
+ GLuint end_index )
+{
+ struct tgsi_full_declaration decl;
+
+ decl = tgsi_default_full_declaration();
+ decl.Declaration.File = TGSI_FILE_ADDRESS;
+ decl.DeclarationRange.First = start_index;
+ decl.DeclarationRange.Last = end_index;
+ return decl;
+}
static struct tgsi_full_declaration
make_sampler_decl(GLuint index)
@@ -707,6 +731,7 @@ tgsi_translate_mesa_program(
GLuint immediates[1000];
GLuint numImmediates = 0;
GLboolean insideSubroutine = GL_FALSE;
+ GLboolean indirectAccess = GL_FALSE;
assert(procType == TGSI_PROCESSOR_FRAGMENT ||
procType == TGSI_PROCESSOR_VERTEX);
@@ -819,45 +844,78 @@ tgsi_translate_mesa_program(
inside_range = GL_FALSE;
fulldecl = make_temp_decl( start_range, i - 1 );
ti += tgsi_build_full_declaration(
- &fulldecl,
- &tokens[ti],
- header,
- maxTokens - ti );
+ &fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
}
}
}
+ /* Declare address register.
+ */
+ if (program->NumAddressRegs > 0) {
+ struct tgsi_full_declaration fulldecl;
+
+ assert( program->NumAddressRegs == 1 );
+
+ fulldecl = make_addr_decl( 0, 0 );
+ ti += tgsi_build_full_declaration(
+ &fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
+
+ indirectAccess = GL_TRUE;
+ }
+
/* immediates/literals */
memset(immediates, ~0, sizeof(immediates));
- for (i = 0; program->Parameters && i < program->Parameters->NumParameters;
- i++) {
- if (program->Parameters->Parameters[i].Type == PROGRAM_CONSTANT) {
- struct tgsi_full_immediate fullimm
- = make_immediate(program->Parameters->ParameterValues[i], 4);
- ti += tgsi_build_full_immediate(&fullimm,
- &tokens[ti],
- header,
- maxTokens - ti);
- immediates[i] = numImmediates;
- numImmediates++;
+ /* Emit immediates only when there is no address register in use.
+ * FIXME: Be smarter and recognize param arrays -- indirect addressing is
+ * only valid within the referenced array.
+ */
+ if (program->Parameters && !indirectAccess) {
+ for (i = 0; i < program->Parameters->NumParameters; i++) {
+ if (program->Parameters->Parameters[i].Type == PROGRAM_CONSTANT) {
+ struct tgsi_full_immediate fullimm;
+
+ fullimm = make_immediate( program->Parameters->ParameterValues[i], 4 );
+ ti += tgsi_build_full_immediate(
+ &fullimm,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
+ immediates[i] = numImmediates;
+ numImmediates++;
+ }
}
}
/* constant buffer refs */
- {
+ if (program->Parameters) {
GLint start = -1, end = -1;
- for (i = 0;
- program->Parameters && i < program->Parameters->NumParameters;
- i++) {
+ for (i = 0; i < program->Parameters->NumParameters; i++) {
GLboolean emit = (i == program->Parameters->NumParameters - 1);
+ GLboolean matches;
switch (program->Parameters->Parameters[i].Type) {
case PROGRAM_ENV_PARAM:
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
case PROGRAM_UNIFORM:
+ matches = GL_TRUE;
+ break;
+ case PROGRAM_CONSTANT:
+ matches = indirectAccess;
+ break;
+ default:
+ matches = GL_FALSE;
+ }
+
+ if (matches) {
if (start == -1) {
/* begin a sequence */
start = i;
@@ -867,8 +925,8 @@ tgsi_translate_mesa_program(
/* continue sequence */
end = i;
}
- break;
- default:
+ }
+ else {
if (start != -1) {
/* end of sequence */
emit = GL_TRUE;
@@ -877,11 +935,13 @@ tgsi_translate_mesa_program(
if (emit && start >= 0) {
struct tgsi_full_declaration fulldecl;
+
fulldecl = make_constant_decl( start, end );
- ti += tgsi_build_full_declaration(&fulldecl,
- &tokens[ti],
- header,
- maxTokens - ti);
+ ti += tgsi_build_full_declaration(
+ &fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
start = end = -1;
}
}
@@ -891,25 +951,27 @@ tgsi_translate_mesa_program(
for (i = 0; i < 8; i++) {
if (program->SamplersUsed & (1 << i)) {
struct tgsi_full_declaration fulldecl;
+
fulldecl = make_sampler_decl( i );
- ti += tgsi_build_full_declaration(&fulldecl,
- &tokens[ti],
- header,
- maxTokens - ti );
+ ti += tgsi_build_full_declaration(
+ &fulldecl,
+ &tokens[ti],
+ header,
+ maxTokens - ti );
}
}
-
- for( i = 0; i < program->NumInstructions; i++ ) {
+ for (i = 0; i < program->NumInstructions; i++) {
compile_instruction(
- &program->Instructions[i],
- &fullinst,
- inputMapping,
- outputMapping,
- immediates,
- preamble_size,
- procType,
- &insideSubroutine);
+ &program->Instructions[i],
+ &fullinst,
+ inputMapping,
+ outputMapping,
+ immediates,
+ indirectAccess,
+ preamble_size,
+ procType,
+ &insideSubroutine );
ti += tgsi_build_full_instruction(
&fullinst,
@@ -920,4 +982,3 @@ tgsi_translate_mesa_program(
return ti;
}
-
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 59314a3..936a6e3 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -55,7 +55,7 @@
#define TGSI_DEBUG 0
-/** XXX we should use the version of this from p_util.h but including
+/** XXX we should use the version of this from u_memory.h but including
* that header causes symbol collisions.
*/
static INLINE void *
@@ -71,15 +71,17 @@ mem_dup(const void *src, uint size)
/**
* Translate a Mesa vertex shader into a TGSI shader.
- * \param outputMapping to map vertex program output registers to TGSI
- * output slots
+ * \param outputMapping to map vertex program output registers (VERT_RESULT_x)
+ * to TGSI output slots
* \param tokensOut destination for TGSI tokens
* \return pointer to cached pipe_shader object.
*/
void
st_translate_vertex_program(struct st_context *st,
struct st_vertex_program *stvp,
- const GLuint outputMapping[])
+ const GLuint outputMapping[],
+ const ubyte *outputSemanticName,
+ const ubyte *outputSemanticIndex)
{
struct pipe_context *pipe = st->pipe;
struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
@@ -172,6 +174,20 @@ st_translate_vertex_program(struct st_context *st,
}
}
+#if 0
+ if (outputMapping && outputSemanticName) {
+ printf("VERT_RESULT written out_slot semantic_name semantic_index\n");
+ for (attr = 0; attr < VERT_RESULT_MAX; attr++) {
+ printf(" %-2d %c %3d %2d %2d\n",
+ attr,
+ ((stvp->Base.Base.OutputsWritten & (1 << attr)) ? 'Y' : ' '),
+ outputMapping[attr],
+ outputSemanticName[attr],
+ outputSemanticIndex[attr]);
+ }
+ }
+#endif
+
/* initialize output semantics to defaults */
for (i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
vs_output_semantic_name[i] = TGSI_SEMANTIC_GENERIC;
@@ -203,10 +219,6 @@ st_translate_vertex_program(struct st_context *st,
defaultOutputMapping[attr] = slot;
}
- /*
- printf("Output %u -> slot %u\n", attr, slot);
- */
-
switch (attr) {
case VERT_RESULT_HPOS:
assert(slot == 0);
@@ -248,15 +260,21 @@ st_translate_vertex_program(struct st_context *st,
case VERT_RESULT_TEX5:
case VERT_RESULT_TEX6:
case VERT_RESULT_TEX7:
- vs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- vs_output_semantic_index[slot] = num_generic++;
- break;
+ /* fall-through */
case VERT_RESULT_VAR0:
/* fall-through */
default:
- assert(attr - VERT_RESULT_VAR0 < MAX_VARYING);
- vs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- vs_output_semantic_index[slot] = num_generic++;
+ if (outputSemanticName) {
+ /* use provided semantic into */
+ assert(outputSemanticName[attr] != TGSI_SEMANTIC_COUNT);
+ vs_output_semantic_name[slot] = outputSemanticName[attr];
+ vs_output_semantic_index[slot] = outputSemanticIndex[attr];
+ }
+ else {
+ /* use default semantic info */
+ vs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
+ vs_output_semantic_index[slot] = num_generic++;
+ }
}
}
}
@@ -347,8 +365,6 @@ st_translate_fragment_program(struct st_context *st,
GLuint num_generic = 0;
GLuint num_tokens;
- ubyte fs_input_semantic_name[PIPE_MAX_SHADER_INPUTS];
- ubyte fs_input_semantic_index[PIPE_MAX_SHADER_INPUTS];
uint fs_num_inputs = 0;
ubyte fs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
@@ -378,23 +394,23 @@ st_translate_fragment_program(struct st_context *st,
switch (attr) {
case FRAG_ATTRIB_WPOS:
- fs_input_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
- fs_input_semantic_index[slot] = 0;
+ stfp->input_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
+ stfp->input_semantic_index[slot] = 0;
interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
break;
case FRAG_ATTRIB_COL0:
- fs_input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
- fs_input_semantic_index[slot] = 0;
+ stfp->input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
+ stfp->input_semantic_index[slot] = 0;
interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
break;
case FRAG_ATTRIB_COL1:
- fs_input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
- fs_input_semantic_index[slot] = 1;
+ stfp->input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
+ stfp->input_semantic_index[slot] = 1;
interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
break;
case FRAG_ATTRIB_FOGC:
- fs_input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
- fs_input_semantic_index[slot] = 0;
+ stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
+ stfp->input_semantic_index[slot] = 0;
interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
break;
case FRAG_ATTRIB_TEX0:
@@ -405,15 +421,15 @@ st_translate_fragment_program(struct st_context *st,
case FRAG_ATTRIB_TEX5:
case FRAG_ATTRIB_TEX6:
case FRAG_ATTRIB_TEX7:
- fs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- fs_input_semantic_index[slot] = num_generic++;
+ stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
+ stfp->input_semantic_index[slot] = num_generic++;
interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
break;
case FRAG_ATTRIB_VAR0:
/* fall-through */
default:
- fs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- fs_input_semantic_index[slot] = num_generic++;
+ stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
+ stfp->input_semantic_index[slot] = num_generic++;
interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
}
}
@@ -467,8 +483,8 @@ st_translate_fragment_program(struct st_context *st,
/* inputs */
fs_num_inputs,
inputMapping,
- fs_input_semantic_name,
- fs_input_semantic_index,
+ stfp->input_semantic_name,
+ stfp->input_semantic_index,
interpMode,
/* outputs */
fs_num_outputs,
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 086e939..078e2c4 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -58,6 +58,9 @@ struct st_fragment_program
/** map FP input back to VP output */
GLuint input_map[PIPE_MAX_SHADER_INPUTS];
+ ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
+ ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
+
struct pipe_shader_state state;
void *driver_shader;
@@ -143,6 +146,9 @@ st_translate_fragment_program(struct st_context *st,
extern void
st_translate_vertex_program(struct st_context *st,
struct st_vertex_program *vp,
- const GLuint vert_output_to_slot[]);
+ const GLuint vert_output_to_slot[],
+ const ubyte *fs_input_semantic_name,
+ const ubyte *fs_input_semantic_index);
+
#endif
diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h
index ca4e957..5cfb2e4 100644
--- a/src/mesa/state_tracker/st_public.h
+++ b/src/mesa/state_tracker/st_public.h
@@ -41,6 +41,10 @@
#define ST_SURFACE_BACK_RIGHT 3
#define ST_SURFACE_DEPTH 8
+#define ST_TEXTURE_2D 0x2
+#define ST_TEXTURE_RGB 0x1
+#define ST_TEXTURE_RGBA 0x2
+
struct st_context;
struct st_framebuffer;
@@ -93,6 +97,15 @@ void st_notify_swapbuffers(struct st_framebuffer *stfb);
void st_notify_swapbuffers_complete(struct st_framebuffer *stfb);
+/** Redirect rendering into stfb's surface to a texture image */
+int st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex,
+ int target, int format, int level);
+
+/** Undo surface-to-texture binding */
+int st_release_teximage(struct st_framebuffer *stfb, uint surfIndex,
+ int target, int format, int level);
+
+
/** Generic function type */
typedef void (*st_proc)();
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 289b78b..29b1634 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -27,8 +27,11 @@
#include "st_context.h"
#include "st_format.h"
+#include "st_public.h"
#include "st_texture.h"
+#include "st_cb_fbo.h"
#include "main/enums.h"
+#include "main/teximage.h"
#undef Elements /* fix re-defined macro warning */
@@ -36,8 +39,8 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_rect.h"
#define DBG if(0) printf
@@ -301,9 +304,6 @@ st_texture_image_copy(struct pipe_context *pipe,
struct pipe_surface *dst_surface;
GLuint i;
- /* XXX this is a hack */
- const GLuint copyHeight = dst->compressed ? height / 4 : height;
-
for (i = 0; i < depth; i++) {
GLuint srcLevel;
@@ -345,9 +345,97 @@ st_texture_image_copy(struct pipe_context *pipe,
0, 0, /* destX, Y */
src_surface,
0, 0, /* srcX, Y */
- width, copyHeight);
+ width, height);
screen->tex_surface_release(screen, &src_surface);
screen->tex_surface_release(screen, &dst_surface);
}
}
+
+
+/** Redirect rendering into stfb's surface to a texture image */
+int
+st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex,
+ int target, int format, int level)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct st_context *st = ctx->st;
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_screen *screen = pipe->screen;
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ struct st_texture_image *stImage;
+ struct st_renderbuffer *strb;
+ GLint face = 0, slice = 0;
+
+ assert(surfIndex <= ST_SURFACE_DEPTH);
+
+ strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer);
+
+ if (strb->texture_save || strb->surface_save) {
+ /* Error! */
+ return 0;
+ }
+
+ if (target == ST_TEXTURE_2D) {
+ texObj = texUnit->Current2D;
+ texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, level);
+ stImage = st_texture_image(texImage);
+ }
+ else {
+ /* unsupported target */
+ return 0;
+ }
+
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+ /* save the renderbuffer's surface/texture info */
+ pipe_texture_reference(&strb->texture_save, strb->texture);
+ pipe_surface_reference(&strb->surface_save, strb->surface);
+
+ /* plug in new surface/texture info */
+ pipe_texture_reference(&strb->texture, stImage->pt);
+ strb->surface = screen->get_tex_surface(screen, strb->texture,
+ face, level, slice,
+ (PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE));
+
+ st->dirty.st |= ST_NEW_FRAMEBUFFER;
+
+ return 1;
+}
+
+
+/** Undo surface-to-texture binding */
+int
+st_release_teximage(struct st_framebuffer *stfb, uint surfIndex,
+ int target, int format, int level)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct st_context *st = ctx->st;
+ struct st_renderbuffer *strb;
+
+ assert(surfIndex <= ST_SURFACE_DEPTH);
+
+ strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer);
+
+ if (!strb->texture_save || !strb->surface_save) {
+ /* Error! */
+ return 0;
+ }
+
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+ /* free tex surface, restore original */
+ pipe_surface_reference(&strb->surface, strb->surface_save);
+ pipe_texture_reference(&strb->texture, strb->texture_save);
+
+ pipe_surface_reference(&strb->surface_save, NULL);
+ pipe_texture_reference(&strb->texture_save, NULL);
+
+ st->dirty.st |= ST_NEW_FRAMEBUFFER;
+
+ return 1;
+}
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index 3febe6a..31f66ad 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -72,6 +72,12 @@ struct st_texture_object
};
+static INLINE struct st_texture_image *
+st_texture_image(struct gl_texture_image *img)
+{
+ return (struct st_texture_image *) img;
+}
+
static INLINE struct st_texture_object *
st_texture_object(struct gl_texture_object *obj)
{
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 579bbeb..d70b4bb 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -1,6 +1,6 @@
/**************************************************************************
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
+Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas.
All Rights Reserved.
@@ -31,6 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "main/glheader.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/macros.h"
#include "main/vtxfmt.h"
@@ -695,7 +696,10 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
* continuously, unless vbo_use_buffer_objects() is called to enable
* use of real VBOs.
*/
- exec->vtx.bufferobj = ctx->Array.NullBufferObj;
+ _mesa_reference_buffer_object(ctx,
+ &exec->vtx.bufferobj,
+ ctx->Array.NullBufferObj);
+
exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64);
vbo_exec_vtxfmt_init( exec );
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index bf97956..0f9d8da 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -47,9 +47,9 @@ static void get_minmax_index( GLuint count, GLuint type,
switch(type) {
case GL_UNSIGNED_INT: {
const GLuint *ui_indices = (const GLuint *)indices;
- GLuint max_ui = ui_indices[0];
+ GLuint max_ui = ui_indices[count-1];
GLuint min_ui = ui_indices[0];
- for (i = 1; i < count; i++) {
+ for (i = 0; i < count; i++) {
if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
}
@@ -59,9 +59,9 @@ static void get_minmax_index( GLuint count, GLuint type,
}
case GL_UNSIGNED_SHORT: {
const GLushort *us_indices = (const GLushort *)indices;
- GLuint max_us = us_indices[0];
+ GLuint max_us = us_indices[count-1];
GLuint min_us = us_indices[0];
- for (i = 1; i < count; i++) {
+ for (i = 0; i < count; i++) {
if (us_indices[i] > max_us) max_us = us_indices[i];
if (us_indices[i] < min_us) min_us = us_indices[i];
}
@@ -71,9 +71,9 @@ static void get_minmax_index( GLuint count, GLuint type,
}
case GL_UNSIGNED_BYTE: {
const GLubyte *ub_indices = (const GLubyte *)indices;
- GLuint max_ub = ub_indices[0];
+ GLuint max_ub = ub_indices[count-1];
GLuint min_ub = ub_indices[0];
- for (i = 1; i < count; i++) {
+ for (i = 0; i < count; i++) {
if (ub_indices[i] > max_ub) max_ub = ub_indices[i];
if (ub_indices[i] < min_ub) min_ub = ub_indices[i];
}
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 3609a74..f497e9a 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,7 @@
*/
#include "main/glheader.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/enums.h"
#include "main/state.h"
@@ -155,8 +156,12 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
*/
switch (get_program_mode(exec->ctx)) {
case VP_NONE:
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0]));
+ for (attr = 0; attr < 16; attr++) {
+ exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
+ }
+ for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
+ exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr];
+ }
map = vbo->map_vp_none;
break;
case VP_NV:
@@ -165,8 +170,10 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
* occurred. NV vertex programs cannot access material values,
* nor attributes greater than VERT_ATTRIB_TEX7.
*/
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
+ for (attr = 0; attr < 16; attr++) {
+ exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
+ exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr];
+ }
map = vbo->map_vp_arb;
break;
}
@@ -178,6 +185,9 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
const GLuint src = map[attr];
if (exec->vtx.attrsz[src]) {
+ /* override the default array set above */
+ exec->vtx.inputs[attr] = &arrays[attr];
+
if (exec->vtx.bufferobj->Name) {
/* a real buffer obj: Ptr is an offset, not a pointer*/
int offset;
@@ -195,7 +205,9 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat);
arrays[attr].Type = GL_FLOAT;
arrays[attr].Enabled = 1;
- arrays[attr].BufferObj = exec->vtx.bufferobj;
+ _mesa_reference_buffer_object(ctx,
+ &arrays[attr].BufferObj,
+ exec->vtx.bufferobj);
arrays[attr]._MaxElement = count; /* ??? */
data += exec->vtx.attrsz[src] * sizeof(GLfloat);
diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c
index 8dd8714..9757c3d 100644
--- a/src/mesa/vbo/vbo_save.c
+++ b/src/mesa/vbo/vbo_save.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 7.2
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,7 @@
#include "main/mtypes.h"
+#include "main/bufferobj.h"
#include "main/dlist.h"
#include "main/vtxfmt.h"
#include "main/imports.h"
@@ -71,19 +72,24 @@ void vbo_save_destroy( GLcontext *ctx )
{
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_save_context *save = &vbo->save;
+ GLuint i;
+
if (save->prim_store) {
if ( --save->prim_store->refcount == 0 ) {
FREE( save->prim_store );
save->prim_store = NULL;
}
if ( --save->vertex_store->refcount == 0 ) {
- if (save->vertex_store->bufferobj)
- ctx->Driver.DeleteBuffer( ctx, save->vertex_store->bufferobj );
-
+ _mesa_reference_buffer_object(ctx,
+ &save->vertex_store->bufferobj, NULL);
FREE( save->vertex_store );
save->vertex_store = NULL;
}
}
+
+ for (i = 0; i < VBO_ATTRIB_MAX; i++) {
+ _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL);
+ }
}
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index f62be5c..88d573f 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -1,6 +1,6 @@
/**************************************************************************
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
+Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas.
All Rights Reserved.
@@ -68,6 +68,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "main/glheader.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/dlist.h"
#include "main/enums.h"
@@ -85,6 +86,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
+/* An interesting VBO number/name to help with debugging */
+#define VBO_BUF_ID 12345
+
+
/*
* NOTE: Old 'parity' issue is gone, but copying can still be
* wrong-footed on replay.
@@ -170,7 +175,9 @@ static struct vbo_save_vertex_store *alloc_vertex_store( GLcontext *ctx )
* user. Perhaps there could be a special number for internal
* buffers:
*/
- vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB);
+ vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx,
+ VBO_BUF_ID,
+ GL_ARRAY_BUFFER_ARB);
ctx->Driver.BufferData( ctx,
GL_ARRAY_BUFFER_ARB,
@@ -190,8 +197,9 @@ static void free_vertex_store( GLcontext *ctx, struct vbo_save_vertex_store *ver
{
assert(!vertex_store->buffer);
- if (vertex_store->bufferobj)
- ctx->Driver.DeleteBuffer( ctx, vertex_store->bufferobj );
+ if (vertex_store->bufferobj) {
+ _mesa_reference_buffer_object(ctx, &vertex_store->bufferobj, NULL);
+ }
FREE( vertex_store );
}
@@ -1139,6 +1147,7 @@ void vbo_save_api_init( struct vbo_save_context *save )
_save_vtxfmt_init( ctx );
_save_current_init( ctx );
+ /* These will actually get set again when binding/drawing */
for (i = 0; i < VBO_ATTRIB_MAX; i++)
save->inputs[i] = &save->arrays[i];
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index bf5c6d4..ed82f09 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,7 @@
*/
#include "main/glheader.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/imports.h"
#include "main/mtypes.h"
@@ -115,8 +116,12 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
*/
switch (get_program_mode(ctx)) {
case VP_NONE:
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0]));
+ for (attr = 0; attr < 16; attr++) {
+ save->inputs[attr] = &vbo->legacy_currval[attr];
+ }
+ for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
+ save->inputs[attr + 16] = &vbo->mat_currval[attr];
+ }
map = vbo->map_vp_none;
break;
case VP_NV:
@@ -125,8 +130,10 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
* occurred. NV vertex programs cannot access material values,
* nor attributes greater than VERT_ATTRIB_TEX7.
*/
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
+ for (attr = 0; attr < 16; attr++) {
+ save->inputs[attr] = &vbo->legacy_currval[attr];
+ save->inputs[attr + 16] = &vbo->generic_currval[attr];
+ }
map = vbo->map_vp_arb;
break;
}
@@ -135,13 +142,18 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
GLuint src = map[attr];
if (node->attrsz[src]) {
- arrays[attr].Ptr = (const GLubyte *)data;
+ /* override the default array set above */
+ save->inputs[attr] = &arrays[attr];
+
+ arrays[attr].Ptr = (const GLubyte *) data;
arrays[attr].Size = node->attrsz[src];
arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat);
arrays[attr].Stride = node->vertex_size * sizeof(GLfloat);
arrays[attr].Type = GL_FLOAT;
arrays[attr].Enabled = 1;
- arrays[attr].BufferObj = node->vertex_store->bufferobj;
+ _mesa_reference_buffer_object(ctx,
+ &arrays[attr].BufferObj,
+ node->vertex_store->bufferobj);
arrays[attr]._MaxElement = node->count; /* ??? */
assert(arrays[attr].BufferObj->Name);